

#import "MicroViewController.h"
#import "Order.h"
#import "WaistLatitudeDeletingUploadBothShortcuts.h"
#import "VoiceSilenceBasalRetryProgram.h"
#import "FitAzimuthConfig.h"

@interface MicroViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) WaistLatitudeDeletingUploadBothShortcuts *pingMinKinEraWill;
@property (nonatomic, strong) VoiceSilenceBasalRetryProgram *actionsEncryptDecoderCyrillicMusic;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static VoiceSilenceBasalRetryProgram *lengthExitsPutPromisedTrustedTerahertz = nil;
static WaistLatitudeDeletingUploadBothShortcuts *anyUnifyLibraryAffineHybridBin = nil;

@implementation MicroViewController

+ (void)queryingZip {
    
    [Order stackedBedWristSameAreCap];

    anyUnifyLibraryAffineHybridBin = [[WaistLatitudeDeletingUploadBothShortcuts alloc] init];
    anyUnifyLibraryAffineHybridBin.volumeLevel = ExtensionLabeledEnhancedReceivingUtility;

    [Order foodArchivedModernToolWet:anyUnifyLibraryAffineHybridBin];

    lengthExitsPutPromisedTrustedTerahertz = [[VoiceSilenceBasalRetryProgram alloc] init];
    lengthExitsPutPromisedTrustedTerahertz.volumeLevel = TiedRaisePush;
    lengthExitsPutPromisedTrustedTerahertz.faxFill = 7;
    lengthExitsPutPromisedTrustedTerahertz.blusteryHeavyMaleArtworkGenerics = YES;
    [Order foodArchivedModernToolWet:lengthExitsPutPromisedTrustedTerahertz];

    [lengthExitsPutPromisedTrustedTerahertz tamilSinkHuman];
}

+ (VoiceSilenceBasalRetryProgram *)alignedFreeExistentBaseGregorianHello {
    return lengthExitsPutPromisedTrustedTerahertz;
}
+ (WaistLatitudeDeletingUploadBothShortcuts *)pinSampleExclusiveAttributeSidebarEye {
    return anyUnifyLibraryAffineHybridBin;
}

- (WaistLatitudeDeletingUploadBothShortcuts *)pingMinKinEraWill {
    return anyUnifyLibraryAffineHybridBin;
}

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

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = bitWetDrain.exponentFoggyExceedsPosterCityAre;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(neutralAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(rangeAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(sinReclaimAction)]
    ];
    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.actionsEncryptDecoderCyrillicMusic = [MicroViewController alignedFreeExistentBaseGregorianHello];

    [self trackEgg];
}

- (void)trackEgg {
    if (!self.actionsEncryptDecoderCyrillicMusic) {
        _textView.text = bitWetDrain.renameRawKeysAgreementSharpnessTerminate;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.actionsEncryptDecoderCyrillicMusic notToneFailDate:self.selectedDate];
        } else {
            logs = [self.actionsEncryptDecoderCyrillicMusic vowelFixSun];
        }

        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 = bitWetDrain.sayValidatesMergeReloadDanceSoccer;
            }

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

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

- (void)neutralAction {
    [self trackEgg];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *targetWho = [[NSDateFormatter alloc] init];
        targetWho.dateFormat = bitWetDrain.darkenOverPictureEntitledSenseRatioJust;
        NSString *midMaxRows = [targetWho stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = bitWetDrain.bankersHeightOveragePongDatabasesQuit;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = bitWetDrain.maxAcquireInteriorAverageBreakingLexiconInactive;
        } else {
            self.title = midMaxRows;
        }
    } else {
        self.title = bitWetDrain.finnishHelpersItsWaterKelvinWrite;
    }
}

- (void)sinReclaimAction {
    if (!self.actionsEncryptDecoderCyrillicMusic) {
        return;
    }

    NSArray<NSDate *> *builtRaceSmall = [self.actionsEncryptDecoderCyrillicMusic oneDelivery];
    if (builtRaceSmall.count == 0) {
        UIAlertController *stamp = [UIAlertController alertControllerWithTitle:bitWetDrain.bagAutoAcceptingMutationsBloodLeap
                                                                       message:bitWetDrain.sayValidatesMergeReloadDanceSoccer
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [stamp addAction:[UIAlertAction actionWithTitle:bitWetDrain.grantingSpringWideBreakNineLoud style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:stamp animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:bitWetDrain.pageNepaliBoundHardExactFactorAnimated
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:bitWetDrain.finnishHelpersItsWaterKelvinWrite
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self trackEgg];
    }]];

    NSDateFormatter *targetWho = [[NSDateFormatter alloc] init];
    targetWho.dateFormat = bitWetDrain.darkenOverPictureEntitledSenseRatioJust;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in builtRaceSmall) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = bitWetDrain.bankersHeightOveragePongDatabasesQuit;
        } else if ([calendar isDateInYesterday:date]) {
            title = bitWetDrain.maxAcquireInteriorAverageBreakingLexiconInactive;
        } else {
            title = [targetWho stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:bitWetDrain.twentyBoldfaceMetabolicSayBitGopher style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)rangeAction {
    if (!self.actionsEncryptDecoderCyrillicMusic) {
        return;
    }

    NSArray *turnBlur = [self.actionsEncryptDecoderCyrillicMusic oldWhiteYou];
    if (turnBlur.count == 0) {
        UIAlertController *stamp = [UIAlertController alertControllerWithTitle:bitWetDrain.bagAutoAcceptingMutationsBloodLeap
                                                                       message:bitWetDrain.calciumNotifyDesiredAdvisoryBigConsole
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [stamp addAction:[UIAlertAction actionWithTitle:bitWetDrain.grantingSpringWideBreakNineLoud style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:stamp animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:bitWetDrain.yetDistinctSecretBridgedPrettyUnifyLeft
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:bitWetDrain.effectGrammarClientUrgentSquashLogLetters
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self sobSynthesis];
    }]];

    for (NSURL *fileURL in turnBlur) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:bitWetDrain.globalSharpnessInvertBlockRenderedRetryWeek, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self retSleetFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:bitWetDrain.twentyBoldfaceMetabolicSayBitGopher style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)sobSynthesis {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *howRoot = [self.actionsEncryptDecoderCyrillicMusic tradZipAskUnit];

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

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

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

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

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

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

@end
