

#import "TrustViewController.h"
#import "Birth.h"
#import "GroupedJapaneseVeryBehaviorResumePayments.h"
#import "TruncateUpsidePoloFrontSpeed.h"
#import "ExposeBeatConfig.h"

@interface TrustViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) GroupedJapaneseVeryBehaviorResumePayments *debuggingNarrativePaperCitySix;
@property (nonatomic, strong) TruncateUpsidePoloFrontSpeed *paletteSexElderMouthSecurity;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static TruncateUpsidePoloFrontSpeed *sidebarCelticSpecifierPanTelephotoZip = nil;
static GroupedJapaneseVeryBehaviorResumePayments *handoverSegmentsAttachStableTransientProduces = nil;

@implementation TrustViewController

+ (void)butMergeAsk {
    
    [Birth leakyCorruptLexicalThousandProtectedSnapshot];

    handoverSegmentsAttachStableTransientProduces = [[GroupedJapaneseVeryBehaviorResumePayments alloc] init];
    handoverSegmentsAttachStableTransientProduces.chooseLevel = TildeDiphthongMonotonicThermalMissing;

    [Birth capacityFreeAllocateBinLiner:handoverSegmentsAttachStableTransientProduces];

    sidebarCelticSpecifierPanTelephotoZip = [[TruncateUpsidePoloFrontSpeed alloc] init];
    sidebarCelticSpecifierPanTelephotoZip.chooseLevel = WinEraWasTurn;
    sidebarCelticSpecifierPanTelephotoZip.fitness = 7;
    sidebarCelticSpecifierPanTelephotoZip.outsideProducedConditionDivideBuffer = YES;
    [Birth capacityFreeAllocateBinLiner:sidebarCelticSpecifierPanTelephotoZip];

    [sidebarCelticSpecifierPanTelephotoZip sleepHangBrown];
}

+ (TruncateUpsidePoloFrontSpeed *)bothRouterCapturingFinishingLossyRaw {
    return sidebarCelticSpecifierPanTelephotoZip;
}
+ (GroupedJapaneseVeryBehaviorResumePayments *)solveReorderDrumViabilityReturnDays {
    return handoverSegmentsAttachStableTransientProduces;
}

- (GroupedJapaneseVeryBehaviorResumePayments *)debuggingNarrativePaperCitySix {
    return handoverSegmentsAttachStableTransientProduces;
}

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

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = daysRedHail.arraySecondAndExchangeNineSolve;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(zipIdleAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(minorAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(applierRawAction)]
    ];
    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.paletteSexElderMouthSecurity = [TrustViewController bothRouterCapturingFinishingLossyRaw];

    [self offBasic];
}

- (void)offBasic {
    if (!self.paletteSexElderMouthSecurity) {
        _textView.text = daysRedHail.releaseInlandRankSquashFlushOwn;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.paletteSexElderMouthSecurity primeRetainDate:self.selectedDate];
        } else {
            logs = [self.paletteSexElderMouthSecurity thatAnyTaps];
        }

        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 = daysRedHail.portionNodeGradeMicroHelpSuperiors;
            }

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

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

- (void)zipIdleAction {
    [self offBasic];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *longerArm = [[NSDateFormatter alloc] init];
        longerArm.dateFormat = daysRedHail.dragAdvanceBarLengthsReportsLeastCollation;
        NSString *fixLockAll = [longerArm stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = daysRedHail.attributePartiallyNoiseHundredViolationCentral;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = daysRedHail.inviteCricketGuideDismissedArchiveOddKit;
        } else {
            self.title = fixLockAll;
        }
    } else {
        self.title = daysRedHail.buildBounceEvaluateTipFamilyInfer;
    }
}

- (void)applierRawAction {
    if (!self.paletteSexElderMouthSecurity) {
        return;
    }

    NSArray<NSDate *> *skinLawOneTime = [self.paletteSexElderMouthSecurity subjectFire];
    if (skinLawOneTime.count == 0) {
        UIAlertController *smile = [UIAlertController alertControllerWithTitle:daysRedHail.headPortalBufferingAlpineFocusedNineteen
                                                                       message:daysRedHail.portionNodeGradeMicroHelpSuperiors
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [smile addAction:[UIAlertAction actionWithTitle:daysRedHail.slabToleranceConvertMasteringRaceRemovable style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:smile animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:daysRedHail.preserveNoticeCanadianDefaultsMagnitudeSilentAppending
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:daysRedHail.buildBounceEvaluateTipFamilyInfer
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self offBasic];
    }]];

    NSDateFormatter *longerArm = [[NSDateFormatter alloc] init];
    longerArm.dateFormat = daysRedHail.dragAdvanceBarLengthsReportsLeastCollation;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in skinLawOneTime) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = daysRedHail.attributePartiallyNoiseHundredViolationCentral;
        } else if ([calendar isDateInYesterday:date]) {
            title = daysRedHail.inviteCricketGuideDismissedArchiveOddKit;
        } else {
            title = [longerArm stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:daysRedHail.ourExistentNecessaryBrowseFriendsBin style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)minorAction {
    if (!self.paletteSexElderMouthSecurity) {
        return;
    }

    NSArray *bitsGrow = [self.paletteSexElderMouthSecurity wasHisEvict];
    if (bitsGrow.count == 0) {
        UIAlertController *smile = [UIAlertController alertControllerWithTitle:daysRedHail.headPortalBufferingAlpineFocusedNineteen
                                                                       message:daysRedHail.yardAlcoholTouchRevisionFindPrior
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [smile addAction:[UIAlertAction actionWithTitle:daysRedHail.slabToleranceConvertMasteringRaceRemovable style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:smile animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:daysRedHail.dependingLostAlongBeforeChinaVerifySuch
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:daysRedHail.bridgeDogUnifyArrangerObsoleteKeysUnlock
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self artNapStride];
    }]];

    for (NSURL *fileURL in bitsGrow) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:daysRedHail.carbonCountMapBlobAssertKoreanBook, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self warnBackFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:daysRedHail.ourExistentNecessaryBrowseFriendsBin style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)artNapStride {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *keysBus = [self.paletteSexElderMouthSecurity ringHoverPatch];

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

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

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

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

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

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

@end
