

#import "MeterViewController.h"
#import "Mouse.h"
#import "MustBlockerAlgorithmEditCoalesceTransfer.h"
#import "OldMutableGermanNativeLayering.h"
#import "SockInviteConfig.h"

@interface MeterViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) MustBlockerAlgorithmEditCoalesceTransfer *pascalSlowIslamicBufferTelephone;
@property (nonatomic, strong) OldMutableGermanNativeLayering *hitForbiddenSwashesLazyGrandson;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static OldMutableGermanNativeLayering *discreteAgeTildeDeletionSubgroupIndex = nil;
static MustBlockerAlgorithmEditCoalesceTransfer *looperProxiesWayPublicDescribesQuerying = nil;

@implementation MeterViewController

+ (void)pressLetter {
    
    [Mouse unlearnFormatStereoMarginsThemeSwipe];

    looperProxiesWayPublicDescribesQuerying = [[MustBlockerAlgorithmEditCoalesceTransfer alloc] init];
    looperProxiesWayPublicDescribesQuerying.letterLevel = CiphersRegionsBeforeAdvisedHis;

    [Mouse mantissaExcludedBeganHighestEstimated:looperProxiesWayPublicDescribesQuerying];

    discreteAgeTildeDeletionSubgroupIndex = [[OldMutableGermanNativeLayering alloc] init];
    discreteAgeTildeDeletionSubgroupIndex.letterLevel = SugarAnyStale;
    discreteAgeTildeDeletionSubgroupIndex.succeed = 7;
    discreteAgeTildeDeletionSubgroupIndex.loudHardEllipseGreekAttempter = YES;
    [Mouse mantissaExcludedBeganHighestEstimated:discreteAgeTildeDeletionSubgroupIndex];

    [discreteAgeTildeDeletionSubgroupIndex numericLexical];
}

+ (OldMutableGermanNativeLayering *)schoolSeeObjectRecentOffArtist {
    return discreteAgeTildeDeletionSubgroupIndex;
}
+ (MustBlockerAlgorithmEditCoalesceTransfer *)sayFunnelEventBackwardsSparseRemovable {
    return looperProxiesWayPublicDescribesQuerying;
}

- (MustBlockerAlgorithmEditCoalesceTransfer *)pascalSlowIslamicBufferTelephone {
    return looperProxiesWayPublicDescribesQuerying;
}

+ (void)plusFreeViewController:(UIViewController *)parentVC {
    MeterViewController *tatar = [[MeterViewController alloc] init];
    UINavigationController *pen = [[UINavigationController alloc] initWithRootViewController:tatar];
    pen.modalPresentationStyle = UIModalPresentationFullScreen;
    [parentVC presentViewController:pen animated:YES completion:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = insteadUndo.lightenCombinedPascalCircularTakeFrame;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]
                                            initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
                                            target:self
                                            action:@selector(denseAction)];

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(sendCanAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(priorAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(optSmallerAction)]
    ];
    self.navigationController.navigationBar.layoutMargins = UIEdgeInsetsMake(0, 0, 0, -10);

    _textView = [[UITextView alloc] init];
    _textView.font = [UIFont systemFontOfSize:11];
    _textView.editable = NO;
    _textView.backgroundColor = [UIColor systemBackgroundColor];
    _textView.textColor = [UIColor labelColor];
    _textView.translatesAutoresizingMaskIntoConstraints = NO;
    _textView.showsVerticalScrollIndicator = YES;
    _textView.showsHorizontalScrollIndicator = YES;
    _textView.alwaysBounceVertical = YES;
    
    _textView.scrollEnabled = YES;
    [self.view addSubview:_textView];

    [NSLayoutConstraint activateConstraints:@[
        [_textView.topAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.topAnchor],
        [_textView.leadingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.leadingAnchor constant:8],
        [_textView.trailingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.trailingAnchor constant:-8],
        [_textView.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor]
    ]];

    self.hitForbiddenSwashesLazyGrandson = [MeterViewController schoolSeeObjectRecentOffArtist];

    [self diagnose];
}

- (void)diagnose {
    if (!self.hitForbiddenSwashesLazyGrandson) {
        _textView.text = insteadUndo.petiteRevealNapLoadingImpliedSin;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.hitForbiddenSwashesLazyGrandson caseRedEndsDate:self.selectedDate];
        } else {
            logs = [self.hitForbiddenSwashesLazyGrandson blendEarCup];
        }

        dispatch_async(dispatch_get_main_queue(), ^{
            if (logs.length > 0) {
                self.textView.text = logs;
                
                [self.textView scrollRangeToVisible:NSMakeRange(logs.length - 1, 1)];
            } else {
                self.textView.text = insteadUndo.weightsArrayMainRestoresCandidateRename;
            }

            [self updateTitle];
        });
    });
}

- (void)denseAction {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)sendCanAction {
    [self diagnose];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *mergeWire = [[NSDateFormatter alloc] init];
        mergeWire.dateFormat = insteadUndo.elevenReloadOutsideAppearVisitCombineDecipher;
        NSString *ourTabLock = [mergeWire stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = insteadUndo.lemmaSheSequencerRowOppositeStreamed;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = insteadUndo.watchedUploadSecondBagPaperAgeIndexing;
        } else {
            self.title = ourTabLock;
        }
    } else {
        self.title = insteadUndo.debuggingProductOrdinaryTransposeStorylineNatural;
    }
}

- (void)optSmallerAction {
    if (!self.hitForbiddenSwashesLazyGrandson) {
        return;
    }

    NSArray<NSDate *> *cancelFriction = [self.hitForbiddenSwashesLazyGrandson existingArm];
    if (cancelFriction.count == 0) {
        UIAlertController *slant = [UIAlertController alertControllerWithTitle:insteadUndo.tolerancePredictedObscuresHallCompareHue
                                                                       message:insteadUndo.weightsArrayMainRestoresCandidateRename
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [slant addAction:[UIAlertAction actionWithTitle:insteadUndo.dogCloseThickReportsSplitShare style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:slant animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:insteadUndo.dogPostalEditorOneExportingSupportsExist
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:insteadUndo.debuggingProductOrdinaryTransposeStorylineNatural
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self diagnose];
    }]];

    NSDateFormatter *mergeWire = [[NSDateFormatter alloc] init];
    mergeWire.dateFormat = insteadUndo.elevenReloadOutsideAppearVisitCombineDecipher;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in cancelFriction) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = insteadUndo.lemmaSheSequencerRowOppositeStreamed;
        } else if ([calendar isDateInYesterday:date]) {
            title = insteadUndo.watchedUploadSecondBagPaperAgeIndexing;
        } else {
            title = [mergeWire stringFromDate:date];
        }

        [actionSheet addAction:[UIAlertAction actionWithTitle:title
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            self.selectedDate = date;
            [self diagnose];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:insteadUndo.acquireCommonSlashedFrenchFreeFixing style:UIAlertActionStyleCancel handler:nil]];

    if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
        actionSheet.popoverPresentationController.barButtonItem = self.navigationItem.rightBarButtonItems.lastObject;
    }

    [self presentViewController:actionSheet animated:YES completion:nil];
}

- (void)priorAction {
    if (!self.hitForbiddenSwashesLazyGrandson) {
        return;
    }

    NSArray *periodic = [self.hitForbiddenSwashesLazyGrandson innerScalar];
    if (periodic.count == 0) {
        UIAlertController *slant = [UIAlertController alertControllerWithTitle:insteadUndo.tolerancePredictedObscuresHallCompareHue
                                                                       message:insteadUndo.runWalkingEffectiveIgnoredSubtractGujarati
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [slant addAction:[UIAlertAction actionWithTitle:insteadUndo.dogCloseThickReportsSplitShare style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:slant animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:insteadUndo.deferringAreHeadphoneSimulatesProjectWithinIndices
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:insteadUndo.issuerFlippedMoireSecondaryToneArteryMen
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self countBoxScan];
    }]];

    for (NSURL *fileURL in periodic) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:insteadUndo.finalOrganizeStationHungarianSonOfferDiscount, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self seeTotalFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:insteadUndo.acquireCommonSlashedFrenchFreeFixing style:UIAlertActionStyleCancel handler:nil]];

    if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
        actionSheet.popoverPresentationController.barButtonItem = self.navigationItem.rightBarButtonItems.lastObject;
    }

    [self presentViewController:actionSheet animated:YES completion:nil];
}

- (void)countBoxScan {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *bagFold = [self.hitForbiddenSwashesLazyGrandson cityYahooShort];

        dispatch_async(dispatch_get_main_queue(), ^{
            if (bagFold.length > 0) {
                UIActivityViewController *cubicSugar = [[UIActivityViewController alloc]
                                                       initWithActivityItems:@[bagFold]
                                                       applicationActivities:nil];

                if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
                    cubicSugar.popoverPresentationController.barButtonItem = self.navigationItem.rightBarButtonItems.lastObject;
                }

                [self presentViewController:cubicSugar animated:YES completion:nil];
            }
        });
    });
}

- (void)seeTotalFile:(NSURL *)fileURL {
    UIActivityViewController *cubicSugar = [[UIActivityViewController alloc]
                                           initWithActivityItems:@[fileURL]
                                           applicationActivities:nil];

    if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
        cubicSugar.popoverPresentationController.barButtonItem = self.navigationItem.rightBarButtonItems.lastObject;
    }

    [self presentViewController:cubicSugar animated:YES completion:nil];
}

@end
