

#import "SplitViewController.h"
#import "Years.h"
#import "RecordCentersMarqueeUndoneScreenAmbient.h"
#import "GreaterHourlyMeanAlertOffer.h"
#import "StoodFocalConfig.h"

@interface SplitViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) RecordCentersMarqueeUndoneScreenAmbient *blockProcessedTildeMemberCreamy;
@property (nonatomic, strong) GreaterHourlyMeanAlertOffer *pageDenseProblemMakeTrap;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static GreaterHourlyMeanAlertOffer *hundredsCallbacksSchemesStepAnotherChat = nil;
static RecordCentersMarqueeUndoneScreenAmbient *encodeTenBlindingExpectingPetiteNap = nil;

@implementation SplitViewController

+ (void)costZoneBut {
    
    [Years addressImpliedAlcoholSphereAboutBarriers];

    encodeTenBlindingExpectingPetiteNap = [[RecordCentersMarqueeUndoneScreenAmbient alloc] init];
    encodeTenBlindingExpectingPetiteNap.artTenLevel = ChannelsUnionJustActionCompany;

    [Years firmwareBorderedInstallsSheTatar:encodeTenBlindingExpectingPetiteNap];

    hundredsCallbacksSchemesStepAnotherChat = [[GreaterHourlyMeanAlertOffer alloc] init];
    hundredsCallbacksSchemesStepAnotherChat.artTenLevel = SheLawIterate;
    hundredsCallbacksSchemesStepAnotherChat.popover = 7;
    hundredsCallbacksSchemesStepAnotherChat.changeKeyTwistModuleMinder = YES;
    [Years firmwareBorderedInstallsSheTatar:hundredsCallbacksSchemesStepAnotherChat];

    [hundredsCallbacksSchemesStepAnotherChat pinCapDeepIcon];
}

+ (GreaterHourlyMeanAlertOffer *)domainsFarLessTwoLexiconMan {
    return hundredsCallbacksSchemesStepAnotherChat;
}
+ (RecordCentersMarqueeUndoneScreenAmbient *)requestSinkBuilderDatabaseComponentPlane {
    return encodeTenBlindingExpectingPetiteNap;
}

- (RecordCentersMarqueeUndoneScreenAmbient *)blockProcessedTildeMemberCreamy {
    return encodeTenBlindingExpectingPetiteNap;
}

+ (void)bankPaceViewController:(UIViewController *)parentVC {
    SplitViewController *bleed = [[SplitViewController alloc] init];
    UINavigationController *sub = [[UINavigationController alloc] initWithRootViewController:bleed];
    sub.modalPresentationStyle = UIModalPresentationFullScreen;
    [parentVC presentViewController:sub animated:YES completion:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = gaelicHertz.trustDriveLoveChestAttempterLength;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(opacityAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(appleAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(veryPartlyAction)]
    ];
    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.pageDenseProblemMakeTrap = [SplitViewController domainsFarLessTwoLexiconMan];

    [self boxDutch];
}

- (void)boxDutch {
    if (!self.pageDenseProblemMakeTrap) {
        _textView.text = gaelicHertz.workspaceFriendEntryDaysPowerSphere;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.pageDenseProblemMakeTrap allowKelvinDate:self.selectedDate];
        } else {
            logs = [self.pageDenseProblemMakeTrap publicSpell];
        }

        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 = gaelicHertz.attitudeLayerExactGenericsBehaveOpposite;
            }

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

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

- (void)opacityAction {
    [self boxDutch];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *passInset = [[NSDateFormatter alloc] init];
        passInset.dateFormat = gaelicHertz.sixCriticalRainIndentBehaviorsPeriodHow;
        NSString *farRequest = [passInset stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = gaelicHertz.kashmiriMaxBurstFlashReloadArcade;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = gaelicHertz.contactsLoopsFireFourHelpHashStone;
        } else {
            self.title = farRequest;
        }
    } else {
        self.title = gaelicHertz.squareTheUploadedBlobRepeatsLoops;
    }
}

- (void)veryPartlyAction {
    if (!self.pageDenseProblemMakeTrap) {
        return;
    }

    NSArray<NSDate *> *serifAddMidKin = [self.pageDenseProblemMakeTrap oneDithered];
    if (serifAddMidKin.count == 0) {
        UIAlertController *miter = [UIAlertController alertControllerWithTitle:gaelicHertz.allowBringWinSubtitleScriptBlock
                                                                       message:gaelicHertz.attitudeLayerExactGenericsBehaveOpposite
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [miter addAction:[UIAlertAction actionWithTitle:gaelicHertz.indicatedVarianceAtomicNotSystemOverdue style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:miter animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:gaelicHertz.musicMayTenWarpBadWeightedPromotion
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:gaelicHertz.squareTheUploadedBlobRepeatsLoops
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self boxDutch];
    }]];

    NSDateFormatter *passInset = [[NSDateFormatter alloc] init];
    passInset.dateFormat = gaelicHertz.sixCriticalRainIndentBehaviorsPeriodHow;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in serifAddMidKin) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = gaelicHertz.kashmiriMaxBurstFlashReloadArcade;
        } else if ([calendar isDateInYesterday:date]) {
            title = gaelicHertz.contactsLoopsFireFourHelpHashStone;
        } else {
            title = [passInset stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:gaelicHertz.mouseStatementCarUpsideGetCup style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)appleAction {
    if (!self.pageDenseProblemMakeTrap) {
        return;
    }

    NSArray *ownerMin = [self.pageDenseProblemMakeTrap frameEditor];
    if (ownerMin.count == 0) {
        UIAlertController *miter = [UIAlertController alertControllerWithTitle:gaelicHertz.allowBringWinSubtitleScriptBlock
                                                                       message:gaelicHertz.fourthDiscardedAlternateBehaveTipEncrypted
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [miter addAction:[UIAlertAction actionWithTitle:gaelicHertz.indicatedVarianceAtomicNotSystemOverdue style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:miter animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:gaelicHertz.inspiredUndoFatAlongsideIdenticalDiscountsCentering
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:gaelicHertz.filenamesDisablesUkrainianClustersDynamicBitsSymptom
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self appendOrigin];
    }]];

    for (NSURL *fileURL in ownerMin) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:gaelicHertz.poolFairFunTabFormFullyPrincipal, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self providerFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:gaelicHertz.mouseStatementCarUpsideGetCup style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)appendOrigin {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *selfHer = [self.pageDenseProblemMakeTrap suitableFunnel];

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

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

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

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

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

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

@end
