

#import "PlateViewController.h"
#import "Drive.h"
#import "CupBypassSpeakingSentExistInitiated.h"
#import "PlaceConvertTransformBarsHistory.h"
#import "OurDragFitConfig.h"

@interface PlateViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) CupBypassSpeakingSentExistInitiated *mirroringMarginSupplyInterPrecision;
@property (nonatomic, strong) PlaceConvertTransformBarsHistory *audiogramOldestFlashExpandedMove;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static PlaceConvertTransformBarsHistory *storylineButDigitNativeUtteranceShe = nil;
static CupBypassSpeakingSentExistInitiated *glyphSortMusicPreserveGraphicsFront = nil;

@implementation PlateViewController

+ (void)getPinkMean {
    
    [Drive orangeBrandHeadExcludeAvailablePerformed];

    glyphSortMusicPreserveGraphicsFront = [[CupBypassSpeakingSentExistInitiated alloc] init];
    glyphSortMusicPreserveGraphicsFront.funnelLevel = DailyProjectsProgressRequiringTemporary;

    [Drive stationSexObtainBookSwashes:glyphSortMusicPreserveGraphicsFront];

    storylineButDigitNativeUtteranceShe = [[PlaceConvertTransformBarsHistory alloc] init];
    storylineButDigitNativeUtteranceShe.funnelLevel = ComplexExpose;
    storylineButDigitNativeUtteranceShe.bendMan = 7;
    storylineButDigitNativeUtteranceShe.peerDayOrangeBeenRebuild = YES;
    [Drive stationSexObtainBookSwashes:storylineButDigitNativeUtteranceShe];

    [storylineButDigitNativeUtteranceShe requiringOcean];
}

+ (PlaceConvertTransformBarsHistory *)seleniumResponseHomepageCompanyTightKashmiri {
    return storylineButDigitNativeUtteranceShe;
}
+ (CupBypassSpeakingSentExistInitiated *)rareMinorExpensiveChangingPlaceIntensity {
    return glyphSortMusicPreserveGraphicsFront;
}

- (CupBypassSpeakingSentExistInitiated *)mirroringMarginSupplyInterPrecision {
    return glyphSortMusicPreserveGraphicsFront;
}

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

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = tooPolicies.truncatedFullyIntroClickedThreadBurst;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(penSaveAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(trashAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(foundMalayAction)]
    ];
    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.audiogramOldestFlashExpandedMove = [PlateViewController seleniumResponseHomepageCompanyTightKashmiri];

    [self funkMore];
}

- (void)funkMore {
    if (!self.audiogramOldestFlashExpandedMove) {
        _textView.text = tooPolicies.groupedSyntaxSoftballYardNowAre;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.audiogramOldestFlashExpandedMove weekdayRuleDate:self.selectedDate];
        } else {
            logs = [self.audiogramOldestFlashExpandedMove eyeNameMile];
        }

        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 = tooPolicies.pressureTitleOpenThicknessArrivalPitch;
            }

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

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

- (void)penSaveAction {
    [self funkMore];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *mixerHome = [[NSDateFormatter alloc] init];
        mixerHome.dateFormat = tooPolicies.remotelyWorldKeyboardButStandardAddNordic;
        NSString *sameReason = [mixerHome stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = tooPolicies.winBeatNotifyPicturesPublicDiscover;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = tooPolicies.samplesDeviceMajorFaxProvisionCutStation;
        } else {
            self.title = sameReason;
        }
    } else {
        self.title = tooPolicies.promptMenstrualSplitNowExcludedThousands;
    }
}

- (void)foundMalayAction {
    if (!self.audiogramOldestFlashExpandedMove) {
        return;
    }

    NSArray<NSDate *> *fatFixRawBuilt = [self.audiogramOldestFlashExpandedMove bagReplyPin];
    if (fatFixRawBuilt.count == 0) {
        UIAlertController *arrow = [UIAlertController alertControllerWithTitle:tooPolicies.elementFiberReuseAscentReadoutSite
                                                                       message:tooPolicies.pressureTitleOpenThicknessArrivalPitch
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [arrow addAction:[UIAlertAction actionWithTitle:tooPolicies.uptimeThreeBarCharArtLow style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:arrow animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:tooPolicies.tagsBankIconDimensionFrontCookieEvaluated
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:tooPolicies.promptMenstrualSplitNowExcludedThousands
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self funkMore];
    }]];

    NSDateFormatter *mixerHome = [[NSDateFormatter alloc] init];
    mixerHome.dateFormat = tooPolicies.remotelyWorldKeyboardButStandardAddNordic;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in fatFixRawBuilt) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = tooPolicies.winBeatNotifyPicturesPublicDiscover;
        } else if ([calendar isDateInYesterday:date]) {
            title = tooPolicies.samplesDeviceMajorFaxProvisionCutStation;
        } else {
            title = [mixerHome stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:tooPolicies.mainAssertionOldestModifyThinDry style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)trashAction {
    if (!self.audiogramOldestFlashExpandedMove) {
        return;
    }

    NSArray *bandMild = [self.audiogramOldestFlashExpandedMove armMaintain];
    if (bandMild.count == 0) {
        UIAlertController *arrow = [UIAlertController alertControllerWithTitle:tooPolicies.elementFiberReuseAscentReadoutSite
                                                                       message:tooPolicies.greenRecoveryTargetBayerElapsedTab
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [arrow addAction:[UIAlertAction actionWithTitle:tooPolicies.uptimeThreeBarCharArtLow style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:arrow animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:tooPolicies.underChallengeCaseMaskReliableOwnerRestored
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:tooPolicies.localesNegativeBuddyEmergencyTransitDateNormalize
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self subIndentSix];
    }]];

    for (NSURL *fileURL in bandMild) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:tooPolicies.invisiblePlugHistoryEyeRadioSpeakerNotation, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self aloneEarFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:tooPolicies.mainAssertionOldestModifyThinDry style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)subIndentSix {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *awayHue = [self.audiogramOldestFlashExpandedMove filmArmLawLoop];

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

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

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

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

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

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

@end
