

#import "WatchViewController.h"
#import "Pulse.h"
#import "FastRejectSafeSubUnsavedPurple.h"
#import "TapMultipleMetadataProducedOld.h"
#import "PinDueListConfig.h"

@interface WatchViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) FastRejectSafeSubUnsavedPurple *referentFinnishResultsReportsFormat;
@property (nonatomic, strong) TapMultipleMetadataProducedOld *preserveExtensionClaimDegradedUnlearn;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static TapMultipleMetadataProducedOld *marqueeIdiomPressAirborneJobRetrieve = nil;
static FastRejectSafeSubUnsavedPurple *sourcesPenPushPubKazakhNap = nil;

@implementation WatchViewController

+ (void)contrastLog {
    
    [Pulse silencedNearbyPresentedDayFilterCorner];

    sourcesPenPushPubKazakhNap = [[FastRejectSafeSubUnsavedPurple alloc] init];
    sourcesPenPushPubKazakhNap.returnLevel = PinchBinListenFatShare;

    [Pulse samplerSerialFolderWorldOpen:sourcesPenPushPubKazakhNap];

    marqueeIdiomPressAirborneJobRetrieve = [[TapMultipleMetadataProducedOld alloc] init];
    marqueeIdiomPressAirborneJobRetrieve.returnLevel = SixGreenPiece;
    marqueeIdiomPressAirborneJobRetrieve.mapMust = 7;
    marqueeIdiomPressAirborneJobRetrieve.checkValidityAlongsideMindUndefined = YES;
    [Pulse samplerSerialFolderWorldOpen:marqueeIdiomPressAirborneJobRetrieve];

    [marqueeIdiomPressAirborneJobRetrieve youIcyAtomSide];
}

+ (TapMultipleMetadataProducedOld *)maxChunkySeekOldestDarkerDry {
    return marqueeIdiomPressAirborneJobRetrieve;
}
+ (FastRejectSafeSubUnsavedPurple *)cardDetectionRunDueExitsDetermine {
    return sourcesPenPushPubKazakhNap;
}

- (FastRejectSafeSubUnsavedPurple *)referentFinnishResultsReportsFormat {
    return sourcesPenPushPubKazakhNap;
}

+ (void)foodGolfViewController:(UIViewController *)parentVC {
    WatchViewController *allow = [[WatchViewController alloc] init];
    UINavigationController *box = [[UINavigationController alloc] initWithRootViewController:allow];
    box.modalPresentationStyle = UIModalPresentationFullScreen;
    [parentVC presentViewController:box animated:YES completion:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = lacrosseWho.indianScatteredServerRecentlyWorldSay;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(soloSeeAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(waterAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(willPhraseAction)]
    ];
    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.preserveExtensionClaimDegradedUnlearn = [WatchViewController maxChunkySeekOldestDarkerDry];

    [self unionOdd];
}

- (void)unionOdd {
    if (!self.preserveExtensionClaimDegradedUnlearn) {
        _textView.text = lacrosseWho.torqueSexualOptionalLexicalBoldfaceSender;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.preserveExtensionClaimDegradedUnlearn additionNowDate:self.selectedDate];
        } else {
            logs = [self.preserveExtensionClaimDegradedUnlearn yearsSecure];
        }

        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 = lacrosseWho.renderExtrasRawTightFootPrototype;
            }

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

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

- (void)soloSeeAction {
    [self unionOdd];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *kitGather = [[NSDateFormatter alloc] init];
        kitGather.dateFormat = lacrosseWho.hungarianBlockerCircleSoftAutomaticCoverFit;
        NSString *saltWeight = [kitGather stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = lacrosseWho.catalanPressureSenseCallbacksFormIcy;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = lacrosseWho.howAgeInhalerSigningProducesMarginGuarani;
        } else {
            self.title = saltWeight;
        }
    } else {
        self.title = lacrosseWho.redefinedTooDanishFactOptToo;
    }
}

- (void)willPhraseAction {
    if (!self.preserveExtensionClaimDegradedUnlearn) {
        return;
    }

    NSArray<NSDate *> *masterCropping = [self.preserveExtensionClaimDegradedUnlearn topExplicit];
    if (masterCropping.count == 0) {
        UIAlertController *cocoa = [UIAlertController alertControllerWithTitle:lacrosseWho.highlightHeapCapablePatternsSpaDevices
                                                                       message:lacrosseWho.renderExtrasRawTightFootPrototype
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [cocoa addAction:[UIAlertAction actionWithTitle:lacrosseWho.mantissaInvertedUbiquityWaySpineAdvised style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:cocoa animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:lacrosseWho.macintoshMixModifiedGenerateMathRenewalRed
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:lacrosseWho.redefinedTooDanishFactOptToo
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self unionOdd];
    }]];

    NSDateFormatter *kitGather = [[NSDateFormatter alloc] init];
    kitGather.dateFormat = lacrosseWho.hungarianBlockerCircleSoftAutomaticCoverFit;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in masterCropping) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = lacrosseWho.catalanPressureSenseCallbacksFormIcy;
        } else if ([calendar isDateInYesterday:date]) {
            title = lacrosseWho.howAgeInhalerSigningProducesMarginGuarani;
        } else {
            title = [kitGather stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:lacrosseWho.oldCurlStarTagalogProcessesSoftball style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)waterAction {
    if (!self.preserveExtensionClaimDegradedUnlearn) {
        return;
    }

    NSArray *hashHead = [self.preserveExtensionClaimDegradedUnlearn playbackDay];
    if (hashHead.count == 0) {
        UIAlertController *cocoa = [UIAlertController alertControllerWithTitle:lacrosseWho.highlightHeapCapablePatternsSpaDevices
                                                                       message:lacrosseWho.customMessageInuitAdvisedSongCell
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [cocoa addAction:[UIAlertAction actionWithTitle:lacrosseWho.mantissaInvertedUbiquityWaySpineAdvised style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:cocoa animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:lacrosseWho.dispatchNoteProvidesReflectLibraryLittleUnordered
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:lacrosseWho.rawUnsignedPolarOutTenValidityOverhang
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self redFollowRun];
    }]];

    for (NSURL *fileURL in hashHead) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:lacrosseWho.sheAnchorCookiesBestBasqueBorderedWon, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self startingFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:lacrosseWho.oldCurlStarTagalogProcessesSoftball style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)redFollowRun {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *sentWon = [self.preserveExtensionClaimDegradedUnlearn callIcyTapLove];

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

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

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

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

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

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

@end
