

#import "SceneViewController.h"
#import "Quote.h"
#import "IntegrateSystemGenericNearLinkageAdvance.h"
#import "RetOwnInsetMoireEntity.h"
#import "SubRingEyeConfig.h"

@interface SceneViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) IntegrateSystemGenericNearLinkageAdvance *recorderChromaCupAndDisplays;
@property (nonatomic, strong) RetOwnInsetMoireEntity *curlAlpineEffortGaussianEasy;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static RetOwnInsetMoireEntity *hailMomentaryRoleOtherLawTwo = nil;
static IntegrateSystemGenericNearLinkageAdvance *saturatePassDependentSavePutDiamond = nil;

@implementation SceneViewController

+ (void)subSexGreek {
    
    [Quote controlsSampleUptimeMalayalamUnitReduction];

    saturatePassDependentSavePutDiamond = [[IntegrateSystemGenericNearLinkageAdvance alloc] init];
    saturatePassDependentSavePutDiamond.didTenLevel = TopDarkUtilitiesPressBirthday;

    [Quote discoveryExponentsLemmaHandStyle:saturatePassDependentSavePutDiamond];

    hailMomentaryRoleOtherLawTwo = [[RetOwnInsetMoireEntity alloc] init];
    hailMomentaryRoleOtherLawTwo.didTenLevel = BasalSaturate;
    hailMomentaryRoleOtherLawTwo.funSkin = 7;
    hailMomentaryRoleOtherLawTwo.uighurSetupModeSortingMisplaced = YES;
    [Quote discoveryExponentsLemmaHandStyle:hailMomentaryRoleOtherLawTwo];

    [hailMomentaryRoleOtherLawTwo orderMakerVery];
}

+ (RetOwnInsetMoireEntity *)stampWinBeginningLearnedThinWas {
    return hailMomentaryRoleOtherLawTwo;
}
+ (IntegrateSystemGenericNearLinkageAdvance *)dynamicAgreementDecayVolumesSubjectBag {
    return saturatePassDependentSavePutDiamond;
}

- (IntegrateSystemGenericNearLinkageAdvance *)recorderChromaCupAndDisplays {
    return saturatePassDependentSavePutDiamond;
}

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

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = youPenPower.flowBulgarianPenFlatnessFingerLimit;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(jumpTryAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(helloAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(socialListAction)]
    ];
    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.curlAlpineEffortGaussianEasy = [SceneViewController stampWinBeginningLearnedThinWas];

    [self queryMix];
}

- (void)queryMix {
    if (!self.curlAlpineEffortGaussianEasy) {
        _textView.text = youPenPower.welshEnterAttachAssemblyTwentyYet;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.curlAlpineEffortGaussianEasy danceVolumeDate:self.selectedDate];
        } else {
            logs = [self.curlAlpineEffortGaussianEasy wayJouleOut];
        }

        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 = youPenPower.aggregateHighestProxyIllegalCyclingDriven;
            }

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

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

- (void)jumpTryAction {
    [self queryMix];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *binResume = [[NSDateFormatter alloc] init];
        binResume.dateFormat = youPenPower.homeSheetExpectedUnlikelyMicroObstacleSaw;
        NSString *popScripts = [binResume stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = youPenPower.englishDescendHandleYoungerAffinityBoldface;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = youPenPower.burnWayModifyFathomsObsoleteLowElevated;
        } else {
            self.title = popScripts;
        }
    } else {
        self.title = youPenPower.retainExclusionTerminalAllBiometryFont;
    }
}

- (void)socialListAction {
    if (!self.curlAlpineEffortGaussianEasy) {
        return;
    }

    NSArray<NSDate *> *partSideUseRed = [self.curlAlpineEffortGaussianEasy withinTatar];
    if (partSideUseRed.count == 0) {
        UIAlertController *sleet = [UIAlertController alertControllerWithTitle:youPenPower.undoneCollisionHueInsertReloadCocoa
                                                                       message:youPenPower.aggregateHighestProxyIllegalCyclingDriven
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [sleet addAction:[UIAlertAction actionWithTitle:youPenPower.panoramasCommentNotationLinkageFatInstalls style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:sleet animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:youPenPower.containerPlayingKinStreetNetTailObserve
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:youPenPower.retainExclusionTerminalAllBiometryFont
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self queryMix];
    }]];

    NSDateFormatter *binResume = [[NSDateFormatter alloc] init];
    binResume.dateFormat = youPenPower.homeSheetExpectedUnlikelyMicroObstacleSaw;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in partSideUseRed) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = youPenPower.englishDescendHandleYoungerAffinityBoldface;
        } else if ([calendar isDateInYesterday:date]) {
            title = youPenPower.burnWayModifyFathomsObsoleteLowElevated;
        } else {
            title = [binResume stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:youPenPower.beginLessPhoneMinExtraKorean style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)helloAction {
    if (!self.curlAlpineEffortGaussianEasy) {
        return;
    }

    NSArray *headBack = [self.curlAlpineEffortGaussianEasy softSpeaker];
    if (headBack.count == 0) {
        UIAlertController *sleet = [UIAlertController alertControllerWithTitle:youPenPower.undoneCollisionHueInsertReloadCocoa
                                                                       message:youPenPower.republicPitchDublinHeightBandMeasure
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [sleet addAction:[UIAlertAction actionWithTitle:youPenPower.panoramasCommentNotationLinkageFatInstalls style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:sleet animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:youPenPower.ovulationReverseUnsignedWhoDatumFoggyCat
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:youPenPower.goalRollMetalTagAboutTwoAdaptive
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self undoFocusing];
    }]];

    for (NSURL *fileURL in headBack) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:youPenPower.commentGeneratesImperialDebuggerUnsavedLostError, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self pitchBoxFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:youPenPower.beginLessPhoneMinExtraKorean style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)undoFocusing {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *caseAir = [self.curlAlpineEffortGaussianEasy loadIllOutBeen];

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

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

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

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

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

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

@end
