

#import "OceanViewController.h"
#import "Every.h"
#import "PoolHelloWonAndCanadianRet.h"
#import "MobileAuditBarrierWhiteLoad.h"
#import "EarYearAllConfig.h"

@interface OceanViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) PoolHelloWonAndCanadianRet *smallestFetchedArcadeRetStill;
@property (nonatomic, strong) MobileAuditBarrierWhiteLoad *loudMiterGlobalWritingBar;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static MobileAuditBarrierWhiteLoad *appleLoadDigestCanadianCostScale = nil;
static PoolHelloWonAndCanadianRet *rareConditionNormalizeRejectionLargerPressed = nil;

@implementation OceanViewController

+ (void)inuitHigher {
    
    [Every hairButCanSampleBankersSense];

    rareConditionNormalizeRejectionLargerPressed = [[PoolHelloWonAndCanadianRet alloc] init];
    rareConditionNormalizeRejectionLargerPressed.revertLevel = RecordPreferSummaryNameBaseline;

    [Every splatBrushHexConditionDivider:rareConditionNormalizeRejectionLargerPressed];

    appleLoadDigestCanadianCostScale = [[MobileAuditBarrierWhiteLoad alloc] init];
    appleLoadDigestCanadianCostScale.revertLevel = TaskHisBagSaw;
    appleLoadDigestCanadianCostScale.fixGain = 7;
    appleLoadDigestCanadianCostScale.copticSlideMembersMenDegree = YES;
    [Every splatBrushHexConditionDivider:appleLoadDigestCanadianCostScale];

    [appleLoadDigestCanadianCostScale dryLoudOutReal];
}

+ (MobileAuditBarrierWhiteLoad *)teaspoonsAdoptStrategyCollapseClosestZip {
    return appleLoadDigestCanadianCostScale;
}
+ (PoolHelloWonAndCanadianRet *)useDetectionPortSourceTwoMail {
    return rareConditionNormalizeRejectionLargerPressed;
}

- (PoolHelloWonAndCanadianRet *)smallestFetchedArcadeRetStill {
    return rareConditionNormalizeRejectionLargerPressed;
}

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

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = hueRateSent.insetInstallsResonantExecutionMarathiBrown;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(waxMealAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(agentAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(hintDefineAction)]
    ];
    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.loudMiterGlobalWritingBar = [OceanViewController teaspoonsAdoptStrategyCollapseClosestZip];

    [self manThumb];
}

- (void)manThumb {
    if (!self.loudMiterGlobalWritingBar) {
        _textView.text = hueRateSent.labeledBadActualNaturalDiacriticOnce;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.loudMiterGlobalWritingBar boxOutPanelDate:self.selectedDate];
        } else {
            logs = [self.loudMiterGlobalWritingBar fullyCapCan];
        }

        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 = hueRateSent.smileYahooSlovakMonotonicListenersWet;
            }

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

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

- (void)waxMealAction {
    [self manThumb];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *unionLost = [[NSDateFormatter alloc] init];
        unionLost.dateFormat = hueRateSent.contrastBusNormalTaggerSleetHeartChunky;
        NSString *manDropHue = [unionLost stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = hueRateSent.mealIterativeHelloAssistantHuePan;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = hueRateSent.goldenSoccerOperationNumbersInstancesReusablePaddle;
        } else {
            self.title = manDropHue;
        }
    } else {
        self.title = hueRateSent.limitedSoundCurlTwelveBirthExecuting;
    }
}

- (void)hintDefineAction {
    if (!self.loudMiterGlobalWritingBar) {
        return;
    }

    NSArray<NSDate *> *dismissOrdered = [self.loudMiterGlobalWritingBar objectPress];
    if (dismissOrdered.count == 0) {
        UIAlertController *welsh = [UIAlertController alertControllerWithTitle:hueRateSent.recordingFormattedLoveBrokenSoloistMail
                                                                       message:hueRateSent.smileYahooSlovakMonotonicListenersWet
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [welsh addAction:[UIAlertAction actionWithTitle:hueRateSent.bitmapWaxAppearsParseDarkerKin style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:welsh animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:hueRateSent.cardFilenameOperandReportArmRoleDecipher
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:hueRateSent.limitedSoundCurlTwelveBirthExecuting
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self manThumb];
    }]];

    NSDateFormatter *unionLost = [[NSDateFormatter alloc] init];
    unionLost.dateFormat = hueRateSent.contrastBusNormalTaggerSleetHeartChunky;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in dismissOrdered) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = hueRateSent.mealIterativeHelloAssistantHuePan;
        } else if ([calendar isDateInYesterday:date]) {
            title = hueRateSent.goldenSoccerOperationNumbersInstancesReusablePaddle;
        } else {
            title = [unionLost stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:hueRateSent.restoresAssistiveFourthDuplicateBigMatrix style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)agentAction {
    if (!self.loudMiterGlobalWritingBar) {
        return;
    }

    NSArray *keyPaper = [self.loudMiterGlobalWritingBar unitHerGolf];
    if (keyPaper.count == 0) {
        UIAlertController *welsh = [UIAlertController alertControllerWithTitle:hueRateSent.recordingFormattedLoveBrokenSoloistMail
                                                                       message:hueRateSent.hundredsSortingCommandsWarnReaderMax
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [welsh addAction:[UIAlertAction actionWithTitle:hueRateSent.bitmapWaxAppearsParseDarkerKin style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:welsh animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:hueRateSent.engineFullStopQuechuaForShadowLuminance
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:hueRateSent.integrateMustEraMediumOneMuteResults
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self notPutAbsent];
    }]];

    for (NSURL *fileURL in keyPaper) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:hueRateSent.passPriorAskTotalAirMaxSigma, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self overBurnFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:hueRateSent.restoresAssistiveFourthDuplicateBigMatrix style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)notPutAbsent {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *cubeArt = [self.loudMiterGlobalWritingBar redoSameTapHex];

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

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

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

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

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

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

@end
