

#import "AlbumViewController.h"
#import "Trait.h"
#import "VitaminManualBookmarkInterruptOffGrade.h"
#import "DemandScatteredLinearlyDeleteNear.h"
#import "ArmourHeapConfig.h"

@interface AlbumViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) VitaminManualBookmarkInterruptOffGrade *logBestPackOuncesAssistant;
@property (nonatomic, strong) DemandScatteredLinearlyDeleteNear *wateryMoodHardRemainingParent;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static DemandScatteredLinearlyDeleteNear *traitPintPriorityReportsStalledAssert = nil;
static VitaminManualBookmarkInterruptOffGrade *planarModalBrownAuthorThreadsModifier = nil;

@implementation AlbumViewController

+ (void)weightedHis {
    
    [Trait specifiedAttempterUpdatingIndentCaseShowers];

    planarModalBrownAuthorThreadsModifier = [[VitaminManualBookmarkInterruptOffGrade alloc] init];
    planarModalBrownAuthorThreadsModifier.rhythmLevel = EmailBackUnwrapFourthInvoke;

    [Trait additionsOffAvailNeverSeparator:planarModalBrownAuthorThreadsModifier];

    traitPintPriorityReportsStalledAssert = [[DemandScatteredLinearlyDeleteNear alloc] init];
    traitPintPriorityReportsStalledAssert.rhythmLevel = CarOldStroked;
    traitPintPriorityReportsStalledAssert.userFat = 7;
    traitPintPriorityReportsStalledAssert.slightMostlyLoveTargetedFor = YES;
    [Trait additionsOffAvailNeverSeparator:traitPintPriorityReportsStalledAssert];

    [traitPintPriorityReportsStalledAssert talkFeedSumDay];
}

+ (DemandScatteredLinearlyDeleteNear *)sameDutchRevealedMountedCoalesceFocusing {
    return traitPintPriorityReportsStalledAssert;
}
+ (VitaminManualBookmarkInterruptOffGrade *)submitReservedEnteredCocoaImmutableSoft {
    return planarModalBrownAuthorThreadsModifier;
}

- (VitaminManualBookmarkInterruptOffGrade *)logBestPackOuncesAssistant {
    return planarModalBrownAuthorThreadsModifier;
}

+ (void)bookmarkViewController:(UIViewController *)parentVC {
    AlbumViewController *adopt = [[AlbumViewController alloc] init];
    UINavigationController *era = [[UINavigationController alloc] initWithRootViewController:adopt];
    era.modalPresentationStyle = UIModalPresentationFullScreen;
    [parentVC presentViewController:era animated:YES completion:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = fitAlbanian.intervalsPanoramasRetrieveCopticDetailConsumer;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(noneOldAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(hoverAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(joinFunHowAction)]
    ];
    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.wateryMoodHardRemainingParent = [AlbumViewController sameDutchRevealedMountedCoalesceFocusing];

    [self fairRest];
}

- (void)fairRest {
    if (!self.wateryMoodHardRemainingParent) {
        _textView.text = fitAlbanian.givenDriveParentPedometerAlienGranted;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.wateryMoodHardRemainingParent dayCapacityDate:self.selectedDate];
        } else {
            logs = [self.wateryMoodHardRemainingParent tapsBoxFunk];
        }

        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 = fitAlbanian.sixCapacityRationalEstimateMisplacedAccept;
            }

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

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

- (void)noneOldAction {
    [self fairRest];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *initiated = [[NSDateFormatter alloc] init];
        initiated.dateFormat = fitAlbanian.powerStorageOperateKeyDutchPercentImproper;
        NSString *farDarkDry = [initiated stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = fitAlbanian.waterOutBeaconsDirectDoubleGujarati;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = fitAlbanian.middleOperationSecondInjectionConjugateRestoringOperating;
        } else {
            self.title = farDarkDry;
        }
    } else {
        self.title = fitAlbanian.chooseYearsCondensedCurveCaptureCentrals;
    }
}

- (void)joinFunHowAction {
    if (!self.wateryMoodHardRemainingParent) {
        return;
    }

    NSArray<NSDate *> *alcoholNatural = [self.wateryMoodHardRemainingParent observeUnit];
    if (alcoholNatural.count == 0) {
        UIAlertController *bevel = [UIAlertController alertControllerWithTitle:fitAlbanian.staticSegueProduceMarkupAxialAlbanian
                                                                       message:fitAlbanian.sixCapacityRationalEstimateMisplacedAccept
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [bevel addAction:[UIAlertAction actionWithTitle:fitAlbanian.emptyElevatedHexAppendAccessoryRelative style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:bevel animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:fitAlbanian.imperialStrokingAcuteVitaminOperandRunningDispense
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:fitAlbanian.chooseYearsCondensedCurveCaptureCentrals
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self fairRest];
    }]];

    NSDateFormatter *initiated = [[NSDateFormatter alloc] init];
    initiated.dateFormat = fitAlbanian.powerStorageOperateKeyDutchPercentImproper;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in alcoholNatural) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = fitAlbanian.waterOutBeaconsDirectDoubleGujarati;
        } else if ([calendar isDateInYesterday:date]) {
            title = fitAlbanian.middleOperationSecondInjectionConjugateRestoringOperating;
        } else {
            title = [initiated stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:fitAlbanian.dismissalSuitableInsertLoudConcludeGender style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)hoverAction {
    if (!self.wateryMoodHardRemainingParent) {
        return;
    }

    NSArray *exactFit = [self.wateryMoodHardRemainingParent styleSingle];
    if (exactFit.count == 0) {
        UIAlertController *bevel = [UIAlertController alertControllerWithTitle:fitAlbanian.staticSegueProduceMarkupAxialAlbanian
                                                                       message:fitAlbanian.handleBypassedDetectedTwistSigmaSaw
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [bevel addAction:[UIAlertAction actionWithTitle:fitAlbanian.emptyElevatedHexAppendAccessoryRelative style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:bevel animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:fitAlbanian.prefixesSliderFirstBedTagDirtyEgg
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:fitAlbanian.exclusionEstonianEmptySinDownloadElapsedEnergy
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self acceptingKit];
    }]];

    for (NSURL *fileURL in exactFit) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:fitAlbanian.scrolledPauseKitMultipleGrowPrinterWrestling, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self farBlendFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:fitAlbanian.dismissalSuitableInsertLoudConcludeGender style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)acceptingKit {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *webpage = [self.wateryMoodHardRemainingParent secretHeadline];

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

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

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

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

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

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

@end
