

#import "BirthViewController.h"
#import "Raise.h"
#import "FootballDaysCelticWetSubsetBlocker.h"
#import "DiastolicSucceededBurmeseTimeViolation.h"
#import "BlobCopticConfig.h"

@interface BirthViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) FootballDaysCelticWetSubsetBlocker *widgetStorylineEarPassVisit;
@property (nonatomic, strong) DiastolicSucceededBurmeseTimeViolation *orangeWeekdayBoldfaceFaceEye;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static DiastolicSucceededBurmeseTimeViolation *selectSheStrongMouseAppearingSimple = nil;
static FootballDaysCelticWetSubsetBlocker *ropeOutCousinPrimaryHusbandReverse = nil;

@implementation BirthViewController

+ (void)mainHisTail {
    
    [Raise hisMainClampLemmaComposedWas];

    ropeOutCousinPrimaryHusbandReverse = [[FootballDaysCelticWetSubsetBlocker alloc] init];
    ropeOutCousinPrimaryHusbandReverse.koreanLevel = ShelfZipElderAudienceOpacity;

    [Raise orderIllCycleSlashesSucceeded:ropeOutCousinPrimaryHusbandReverse];

    selectSheStrongMouseAppearingSimple = [[DiastolicSucceededBurmeseTimeViolation alloc] init];
    selectSheStrongMouseAppearingSimple.koreanLevel = PrepareSample;
    selectSheStrongMouseAppearingSimple.manTail = 7;
    selectSheStrongMouseAppearingSimple.wayDustGigabytesFoldHockey = YES;
    [Raise orderIllCycleSlashesSucceeded:selectSheStrongMouseAppearingSimple];

    [selectSheStrongMouseAppearingSimple sixHitFileNone];
}

+ (DiastolicSucceededBurmeseTimeViolation *)treePromotionTabularBlobEncodedSpeed {
    return selectSheStrongMouseAppearingSimple;
}
+ (FootballDaysCelticWetSubsetBlocker *)passivelyNumberCocoaWeekdayIdiomError {
    return ropeOutCousinPrimaryHusbandReverse;
}

- (FootballDaysCelticWetSubsetBlocker *)widgetStorylineEarPassVisit {
    return ropeOutCousinPrimaryHusbandReverse;
}

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

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = endStandard.obscuresPresenceSectionsDeviceShearResponses;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(kinBackAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(humanAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(manHitWaitAction)]
    ];
    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.orangeWeekdayBoldfaceFaceEye = [BirthViewController treePromotionTabularBlobEncodedSpeed];

    [self lazyFeed];
}

- (void)lazyFeed {
    if (!self.orangeWeekdayBoldfaceFaceEye) {
        _textView.text = endStandard.unableDisparityMirroredGaussianApplySix;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.orangeWeekdayBoldfaceFaceEye calciumMarkDate:self.selectedDate];
        } else {
            logs = [self.orangeWeekdayBoldfaceFaceEye idleSongSum];
        }

        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 = endStandard.outerStorylineErrorVeryDayEcho;
            }

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

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

- (void)kinBackAction {
    [self lazyFeed];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *nodePhone = [[NSDateFormatter alloc] init];
        nodePhone.dateFormat = endStandard.startRemovableExpireFatSelfGaspAxial;
        NSString *sourcesTip = [nodePhone stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = endStandard.spaMixRenderBodyReductionPublish;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = endStandard.transmitExporterAltimeterUndoAllWetSock;
        } else {
            self.title = sourcesTip;
        }
    } else {
        self.title = endStandard.converterGrayAlignedCapturesGermanForward;
    }
}

- (void)manHitWaitAction {
    if (!self.orangeWeekdayBoldfaceFaceEye) {
        return;
    }

    NSArray<NSDate *> *fractionsLocal = [self.orangeWeekdayBoldfaceFaceEye majorPartly];
    if (fractionsLocal.count == 0) {
        UIAlertController *splat = [UIAlertController alertControllerWithTitle:endStandard.seedSoccerBypassedRequiringCinematicFace
                                                                       message:endStandard.outerStorylineErrorVeryDayEcho
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [splat addAction:[UIAlertAction actionWithTitle:endStandard.balticUnlearnJoiningUniqueEntitiesManager style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:splat animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:endStandard.lightCheckUseDrawingLowExtentsOur
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:endStandard.converterGrayAlignedCapturesGermanForward
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self lazyFeed];
    }]];

    NSDateFormatter *nodePhone = [[NSDateFormatter alloc] init];
    nodePhone.dateFormat = endStandard.startRemovableExpireFatSelfGaspAxial;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in fractionsLocal) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = endStandard.spaMixRenderBodyReductionPublish;
        } else if ([calendar isDateInYesterday:date]) {
            title = endStandard.transmitExporterAltimeterUndoAllWetSock;
        } else {
            title = [nodePhone stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:endStandard.meterWinTicketsDaysMatchArm style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)humanAction {
    if (!self.orangeWeekdayBoldfaceFaceEye) {
        return;
    }

    NSArray *nextSlab = [self.orangeWeekdayBoldfaceFaceEye pastRetLead];
    if (nextSlab.count == 0) {
        UIAlertController *splat = [UIAlertController alertControllerWithTitle:endStandard.seedSoccerBypassedRequiringCinematicFace
                                                                       message:endStandard.readoutSongCurrentlyIndicatedWatchCollected
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [splat addAction:[UIAlertAction actionWithTitle:endStandard.balticUnlearnJoiningUniqueEntitiesManager style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:splat animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:endStandard.nowCubeTropicalStepOneAllDog
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:endStandard.brotherFormRaiseTriggersDisplayOfferImproper
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self seeAreaClean];
    }]];

    for (NSURL *fileURL in nextSlab) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:endStandard.expectedMagicCampaignEldestHelpersNoiseNative, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self preserveFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:endStandard.meterWinTicketsDaysMatchArm style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)seeAreaClean {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *showing = [self.orangeWeekdayBoldfaceFaceEye headlineFourth];

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

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

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

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

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

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

@end
