

#import "ShearViewController.h"
#import "Video.h"
#import "HowBodyFinnishOpenCustodianUnplugged.h"
#import "SurgeRegularFactoryEqualRecycle.h"
#import "WayMastersConfig.h"

@interface ShearViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) HowBodyFinnishOpenCustodianUnplugged *certHangGetBottomHindi;
@property (nonatomic, strong) SurgeRegularFactoryEqualRecycle *convertBehaviorPortalPerformedDingbats;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static SurgeRegularFactoryEqualRecycle *objectLawMilesPivotSentenceBalance = nil;
static HowBodyFinnishOpenCustodianUnplugged *leftPrimePoloKinAnchorsDownhill = nil;

@implementation ShearViewController

+ (void)caloriesGet {
    
    [Video stickyAlbumDidCalciumWristFont];

    leftPrimePoloKinAnchorsDownhill = [[HowBodyFinnishOpenCustodianUnplugged alloc] init];
    leftPrimePoloKinAnchorsDownhill.deviceLevel = EnableNapTerahertzIndicatorAllocator;

    [Video nepaliDuctilityResignFaxPong:leftPrimePoloKinAnchorsDownhill];

    objectLawMilesPivotSentenceBalance = [[SurgeRegularFactoryEqualRecycle alloc] init];
    objectLawMilesPivotSentenceBalance.deviceLevel = SaltSelection;
    objectLawMilesPivotSentenceBalance.cityWet = 7;
    objectLawMilesPivotSentenceBalance.accountsChargingFlowItsWrapped = YES;
    [Video nepaliDuctilityResignFaxPong:objectLawMilesPivotSentenceBalance];

    [objectLawMilesPivotSentenceBalance lawMixMaskBase];
}

+ (SurgeRegularFactoryEqualRecycle *)areChinaKernelCupIrregularScripts {
    return objectLawMilesPivotSentenceBalance;
}
+ (HowBodyFinnishOpenCustodianUnplugged *)logNetworkSpeakerCleanGeneratesFloating {
    return leftPrimePoloKinAnchorsDownhill;
}

- (HowBodyFinnishOpenCustodianUnplugged *)certHangGetBottomHindi {
    return leftPrimePoloKinAnchorsDownhill;
}

+ (void)chatFoldViewController:(UIViewController *)parentVC {
    ShearViewController *chain = [[ShearViewController alloc] init];
    UINavigationController *ear = [[UINavigationController alloc] initWithRootViewController:chain];
    ear.modalPresentationStyle = UIModalPresentationFullScreen;
    [parentVC presentViewController:ear animated:YES completion:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = tenYardJoin.preparedSeparatorCloudSizeLinearlyQuotes;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(snapEndAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(romanAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(pathNoticeAction)]
    ];
    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.convertBehaviorPortalPerformedDingbats = [ShearViewController areChinaKernelCupIrregularScripts];

    [self swipeIcy];
}

- (void)swipeIcy {
    if (!self.convertBehaviorPortalPerformedDingbats) {
        _textView.text = tenYardJoin.magnesiumPermittedBasalHourCascadeBounce;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.convertBehaviorPortalPerformedDingbats subStateDidDate:self.selectedDate];
        } else {
            logs = [self.convertBehaviorPortalPerformedDingbats depthSender];
        }

        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 = tenYardJoin.encryptSonHueRomanianStayStorm;
            }

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

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

- (void)snapEndAction {
    [self swipeIcy];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *slowBelow = [[NSDateFormatter alloc] init];
        slowBelow.dateFormat = tenYardJoin.transientRenamingSexualHighestStrongPreventedWalking;
        NSString *softCenter = [slowBelow stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = tenYardJoin.lazySuchDominantSquashIndoorWarn;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = tenYardJoin.ubiquityTwelveNumbersLateHandoverNewsstandPeer;
        } else {
            self.title = softCenter;
        }
    } else {
        self.title = tenYardJoin.friendsCommittedAllergyHockeyRemovableAlpine;
    }
}

- (void)pathNoticeAction {
    if (!self.convertBehaviorPortalPerformedDingbats) {
        return;
    }

    NSArray<NSDate *> *commentsAtomic = [self.convertBehaviorPortalPerformedDingbats cubePermute];
    if (commentsAtomic.count == 0) {
        UIAlertController *setup = [UIAlertController alertControllerWithTitle:tenYardJoin.hisEvaluateDeprecateRestCollapseSucceeded
                                                                       message:tenYardJoin.encryptSonHueRomanianStayStorm
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [setup addAction:[UIAlertAction actionWithTitle:tenYardJoin.borderedBrokenMoodStationDragLetter style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:setup animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:tenYardJoin.wrappedLabeledAskGeorgianCheckoutSoftwareRecovered
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:tenYardJoin.friendsCommittedAllergyHockeyRemovableAlpine
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self swipeIcy];
    }]];

    NSDateFormatter *slowBelow = [[NSDateFormatter alloc] init];
    slowBelow.dateFormat = tenYardJoin.transientRenamingSexualHighestStrongPreventedWalking;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in commentsAtomic) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = tenYardJoin.lazySuchDominantSquashIndoorWarn;
        } else if ([calendar isDateInYesterday:date]) {
            title = tenYardJoin.ubiquityTwelveNumbersLateHandoverNewsstandPeer;
        } else {
            title = [slowBelow stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:tenYardJoin.presentAlbumAudiencesBannerGlyphVision style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)romanAction {
    if (!self.convertBehaviorPortalPerformedDingbats) {
        return;
    }

    NSArray *tamilZip = [self.convertBehaviorPortalPerformedDingbats theIndirect];
    if (tamilZip.count == 0) {
        UIAlertController *setup = [UIAlertController alertControllerWithTitle:tenYardJoin.hisEvaluateDeprecateRestCollapseSucceeded
                                                                       message:tenYardJoin.menFunProtocolsAmpereStationRound
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [setup addAction:[UIAlertAction actionWithTitle:tenYardJoin.borderedBrokenMoodStationDragLetter style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:setup animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:tenYardJoin.strongMeanFemalePitchFactorGramResonant
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:tenYardJoin.thicknessProjectsPortraitsTalkAccountsAltitudeSubmitted
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self footballLess];
    }]];

    for (NSURL *fileURL in tamilZip) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:tenYardJoin.postalDrawIllQuoteRecipientLeadEstimated, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self decayWonFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:tenYardJoin.presentAlbumAudiencesBannerGlyphVision style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)footballLess {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *picture = [self.convertBehaviorPortalPerformedDingbats loopsAffiliate];

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

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

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

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

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

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

@end
