

#import "SceneViewController.h"
#import "Speak.h"
#import "DitherNotifyCupOneLightenCoached.h"
#import "ObstacleTightForkHairPackage.h"
#import "WeekZipBitConfig.h"

@interface SceneViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) DitherNotifyCupOneLightenCoached *vignetteCheckedExtraBecomeReorder;
@property (nonatomic, strong) ObstacleTightForkHairPackage *checkLiterArgumentsTremorFork;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static ObstacleTightForkHairPackage *forbidExtentsBigUighurRadialCompared = nil;
static DitherNotifyCupOneLightenCoached *dogAscentRetriedAlarmOpacitySpotlight = nil;

@implementation SceneViewController

+ (void)atomSpaTied {
    
    [Speak partlyAttitudeUnableTabDismissTied];

    dogAscentRetriedAlarmOpacitySpotlight = [[DitherNotifyCupOneLightenCoached alloc] init];
    dogAscentRetriedAlarmOpacitySpotlight.copticLevel = OrderingSigmaReplaceIntentsLoading;

    [Speak biotinTranslateDescribesNumeratorMarkup:dogAscentRetriedAlarmOpacitySpotlight];

    forbidExtentsBigUighurRadialCompared = [[ObstacleTightForkHairPackage alloc] init];
    forbidExtentsBigUighurRadialCompared.copticLevel = AirMixZoneAre;
    forbidExtentsBigUighurRadialCompared.entered = 7;
    forbidExtentsBigUighurRadialCompared.eggModeratePhonePrimaryFax = YES;
    [Speak biotinTranslateDescribesNumeratorMarkup:forbidExtentsBigUighurRadialCompared];

    [forbidExtentsBigUighurRadialCompared dogDanceWhoAge];
}

+ (ObstacleTightForkHairPackage *)bookmarksTabGlucoseFusionFusionOrnaments {
    return forbidExtentsBigUighurRadialCompared;
}
+ (DitherNotifyCupOneLightenCoached *)lostMegabytesRevealedPanoramasDecisionCover {
    return dogAscentRetriedAlarmOpacitySpotlight;
}

- (DitherNotifyCupOneLightenCoached *)vignetteCheckedExtraBecomeReorder {
    return dogAscentRetriedAlarmOpacitySpotlight;
}

+ (void)showFromViewController:(UIViewController *)parentVC {
    SceneViewController *early = [[SceneViewController alloc] init];
    UINavigationController *kit = [[UINavigationController alloc] initWithRootViewController:early];
    kit.modalPresentationStyle = UIModalPresentationFullScreen;
    [parentVC presentViewController:kit animated:YES completion:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = floaterFill.audiogramAdjustTerminalReasonOutsideDiamond;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(messageAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(delayAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(wrapKitUseAction)]
    ];
    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.checkLiterArgumentsTremorFork = [SceneViewController bookmarksTabGlucoseFusionFusionOrnaments];

    [self sawFrame];
}

- (void)sawFrame {
    if (!self.checkLiterArgumentsTremorFork) {
        _textView.text = floaterFill.lowLoopsHundredsMercuryConcludePartner;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.checkLiterArgumentsTremorFork zoomCatalanDate:self.selectedDate];
        } else {
            logs = [self.checkLiterArgumentsTremorFork additionPan];
        }

        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 = floaterFill.featuredRelationApertureLacrosseGoldenOrigins;
            }

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

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

- (void)messageAction {
    [self sawFrame];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *becomeRun = [[NSDateFormatter alloc] init];
        becomeRun.dateFormat = floaterFill.activatedUsabilityLocatorCoachedLoseSignDispose;
        NSString *rankScroll = [becomeRun stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = floaterFill.usesSayAnotherMovementCountedNow;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = floaterFill.settingsMaleObservingTalkModerateRowReporting;
        } else {
            self.title = rankScroll;
        }
    } else {
        self.title = floaterFill.balancedShapeLacrosseNominallyInnerSinhalese;
    }
}

- (void)wrapKitUseAction {
    if (!self.checkLiterArgumentsTremorFork) {
        return;
    }

    NSArray<NSDate *> *undoArtSizePin = [self.checkLiterArgumentsTremorFork keyTagsHold];
    if (undoArtSizePin.count == 0) {
        UIAlertController *plate = [UIAlertController alertControllerWithTitle:floaterFill.dayElderCentralsShelfSphereVoice
                                                                       message:floaterFill.featuredRelationApertureLacrosseGoldenOrigins
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [plate addAction:[UIAlertAction actionWithTitle:floaterFill.fitnessSpringArmInfinityNearestGuide style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:plate animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:floaterFill.shiftProfileAppearingPortObjectEndsLow
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:floaterFill.balancedShapeLacrosseNominallyInnerSinhalese
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self sawFrame];
    }]];

    NSDateFormatter *becomeRun = [[NSDateFormatter alloc] init];
    becomeRun.dateFormat = floaterFill.activatedUsabilityLocatorCoachedLoseSignDispose;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in undoArtSizePin) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = floaterFill.usesSayAnotherMovementCountedNow;
        } else if ([calendar isDateInYesterday:date]) {
            title = floaterFill.settingsMaleObservingTalkModerateRowReporting;
        } else {
            title = [becomeRun stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:floaterFill.readableSpokenDatabaseSoloBrowseTraverse style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)delayAction {
    if (!self.checkLiterArgumentsTremorFork) {
        return;
    }

    NSArray *dropFive = [self.checkLiterArgumentsTremorFork signalDatum];
    if (dropFive.count == 0) {
        UIAlertController *plate = [UIAlertController alertControllerWithTitle:floaterFill.dayElderCentralsShelfSphereVoice
                                                                       message:floaterFill.mountInvitedBurnCarPreferArbitrary
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [plate addAction:[UIAlertAction actionWithTitle:floaterFill.fitnessSpringArmInfinityNearestGuide style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:plate animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:floaterFill.waySliceColumnsJabberFooterIndoorReverses
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:floaterFill.sortingBodyKitCoercionAlongChromaticSafe
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self heavyTeamRed];
    }]];

    for (NSURL *fileURL in dropFive) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:floaterFill.cathedralUpdatingWeekBloodTicketsPopCreator, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self majorSeeFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:floaterFill.readableSpokenDatabaseSoloBrowseTraverse style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)heavyTeamRed {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *markYou = [self.checkLiterArgumentsTremorFork mustCharYouIcy];

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

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

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

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

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

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

@end
