

#import "ElderViewController.h"
#import "Start.h"
#import "IterativeInstallsOrangeBlackSessionGrandson.h"
#import "ChainItsWaistSpanishFunctions.h"
#import "DoneTryTenConfig.h"

@interface ElderViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) IterativeInstallsOrangeBlackSessionGrandson *chromaSignerEarCanRecorder;
@property (nonatomic, strong) ChainItsWaistSpanishFunctions *ageMovementDietaryDaysTextured;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static ChainItsWaistSpanishFunctions *responsesTargetLightenPromisedPenWin = nil;
static IterativeInstallsOrangeBlackSessionGrandson *gigabitsHealthHardFarthestOddLibrary = nil;

@implementation ElderViewController

+ (void)cutFriction {
    
    [Start externAppendedBarriersComparedGigabytesMen];

    gigabitsHealthHardFarthestOddLibrary = [[IterativeInstallsOrangeBlackSessionGrandson alloc] init];
    gigabitsHealthHardFarthestOddLibrary.taggerLevel = DifferentHisSpeakNotifyingColumn;

    [Start positionsFavoriteSecondTwistCombined:gigabitsHealthHardFarthestOddLibrary];

    responsesTargetLightenPromisedPenWin = [[ChainItsWaistSpanishFunctions alloc] init];
    responsesTargetLightenPromisedPenWin.taggerLevel = SourcesReader;
    responsesTargetLightenPromisedPenWin.seeking = 7;
    responsesTargetLightenPromisedPenWin.automaticEasyHelloPresetIll = YES;
    [Start positionsFavoriteSecondTwistCombined:responsesTargetLightenPromisedPenWin];

    [responsesTargetLightenPromisedPenWin icyRawLeakyBus];
}

+ (ChainItsWaistSpanishFunctions *)handlingProfilesLastReturnedClockSignal {
    return responsesTargetLightenPromisedPenWin;
}
+ (IterativeInstallsOrangeBlackSessionGrandson *)dryRationalMathMagicSmartEqual {
    return gigabitsHealthHardFarthestOddLibrary;
}

- (IterativeInstallsOrangeBlackSessionGrandson *)chromaSignerEarCanRecorder {
    return gigabitsHealthHardFarthestOddLibrary;
}

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

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = sobToneWide.cyclePauseSplitRatioOperatorPriority;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(seeBitsAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(legalAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(headerMindAction)]
    ];
    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.ageMovementDietaryDaysTextured = [ElderViewController handlingProfilesLastReturnedClockSignal];

    [self drawSolo];
}

- (void)drawSolo {
    if (!self.ageMovementDietaryDaysTextured) {
        _textView.text = sobToneWide.profilesTokenDesiredUighurLongitudeDate;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.ageMovementDietaryDaysTextured shrinkBadgeDate:self.selectedDate];
        } else {
            logs = [self.ageMovementDietaryDaysTextured hasDeleting];
        }

        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 = sobToneWide.subfamilyFingerSampleSubLabeledLeft;
            }

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

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

- (void)seeBitsAction {
    [self drawSolo];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *belowSize = [[NSDateFormatter alloc] init];
        belowSize.dateFormat = sobToneWide.bendExpiresLoopsMillDisabledReleaseLooper;
        NSString *restOwnOld = [belowSize stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = sobToneWide.urgencyFitSleepWeightNowFocal;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = sobToneWide.heightDesktopBlendBracketedFourthOverageClimbed;
        } else {
            self.title = restOwnOld;
        }
    } else {
        self.title = sobToneWide.anonymousPedometerBaselineSerifDiskDecode;
    }
}

- (void)headerMindAction {
    if (!self.ageMovementDietaryDaysTextured) {
        return;
    }

    NSArray<NSDate *> *sobThumbSonBin = [self.ageMovementDietaryDaysTextured focalMaxWho];
    if (sobThumbSonBin.count == 0) {
        UIAlertController *infer = [UIAlertController alertControllerWithTitle:sobToneWide.chestSigningTabDingbatsHowFuture
                                                                       message:sobToneWide.subfamilyFingerSampleSubLabeledLeft
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [infer addAction:[UIAlertAction actionWithTitle:sobToneWide.localesResumedQuotesRelativeTowerMax style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:infer animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:sobToneWide.expertRelevanceDecoderInstancesAccessingPrepMicro
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:sobToneWide.anonymousPedometerBaselineSerifDiskDecode
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self drawSolo];
    }]];

    NSDateFormatter *belowSize = [[NSDateFormatter alloc] init];
    belowSize.dateFormat = sobToneWide.bendExpiresLoopsMillDisabledReleaseLooper;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in sobThumbSonBin) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = sobToneWide.urgencyFitSleepWeightNowFocal;
        } else if ([calendar isDateInYesterday:date]) {
            title = sobToneWide.heightDesktopBlendBracketedFourthOverageClimbed;
        } else {
            title = [belowSize stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:sobToneWide.allocateSizeFilteredNotShapeLocal style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)legalAction {
    if (!self.ageMovementDietaryDaysTextured) {
        return;
    }

    NSArray *splatBad = [self.ageMovementDietaryDaysTextured stepThePeer];
    if (splatBad.count == 0) {
        UIAlertController *infer = [UIAlertController alertControllerWithTitle:sobToneWide.chestSigningTabDingbatsHowFuture
                                                                       message:sobToneWide.notifiesKeepInterlaceMagentaNapAuthors
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [infer addAction:[UIAlertAction actionWithTitle:sobToneWide.localesResumedQuotesRelativeTowerMax style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:infer animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:sobToneWide.exclusiveAngleDeprecateKeyboardPrepareOuterNepali
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:sobToneWide.deviceResponseWeeklyKinHumanEnumerateChild
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self rawDeviation];
    }]];

    for (NSURL *fileURL in splatBad) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:sobToneWide.biometryNibblesMightCreationBothDigitalDingbats, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self offEvictFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:sobToneWide.allocateSizeFilteredNotShapeLocal style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)rawDeviation {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *turkmen = [self.ageMovementDietaryDaysTextured groupGolfError];

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

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

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

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

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

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

@end
