

#import "LossyViewController.h"
#import "Dense.h"
#import "OverhangCheckedApertureParseAcuteRendered.h"
#import "PickerMayKitPenProtein.h"
#import "HitPrefersConfig.h"

@interface LossyViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) OverhangCheckedApertureParseAcuteRendered *sensorLicenseArbiterIndianHover;
@property (nonatomic, strong) PickerMayKitPenProtein *teacherStylisticPreviewsUsesSemaphore;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static PickerMayKitPenProtein *mercurySquashEjectRomanianRenderGathering = nil;
static OverhangCheckedApertureParseAcuteRendered *photoHandballResizeDetailedVisionGranted = nil;

@implementation LossyViewController

+ (void)relaySelect {
    
    [Dense bodyCenteringCleanupOverlaySalientImpact];

    photoHandballResizeDetailedVisionGranted = [[OverhangCheckedApertureParseAcuteRendered alloc] init];
    photoHandballResizeDetailedVisionGranted.recentLevel = ShutterInterruptSupportsMidOptical;

    [Dense miterReferentOverhangWaistIncluding:photoHandballResizeDetailedVisionGranted];

    mercurySquashEjectRomanianRenderGathering = [[PickerMayKitPenProtein alloc] init];
    mercurySquashEjectRomanianRenderGathering.recentLevel = WriteScoreOur;
    mercurySquashEjectRomanianRenderGathering.oldFact = 7;
    mercurySquashEjectRomanianRenderGathering.cityPrepRomanianLargerIll = YES;
    [Dense miterReferentOverhangWaistIncluding:mercurySquashEjectRomanianRenderGathering];

    [mercurySquashEjectRomanianRenderGathering forkFamilyAuto];
}

+ (PickerMayKitPenProtein *)audioApplierBitDescendedHomepageUniform {
    return mercurySquashEjectRomanianRenderGathering;
}
+ (OverhangCheckedApertureParseAcuteRendered *)outputChannelCaretTerminateStoodWrestling {
    return photoHandballResizeDetailedVisionGranted;
}

- (OverhangCheckedApertureParseAcuteRendered *)sensorLicenseArbiterIndianHover {
    return photoHandballResizeDetailedVisionGranted;
}

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

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = herEventual.momentDatabaseSlantSpecialJouleIntegers;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(opacityAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(rangeAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(oldMoodSonAction)]
    ];
    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.teacherStylisticPreviewsUsesSemaphore = [LossyViewController audioApplierBitDescendedHomepageUniform];

    [self foodNext];
}

- (void)foodNext {
    if (!self.teacherStylisticPreviewsUsesSemaphore) {
        _textView.text = herEventual.fiveAnalysisBoxDiskYahooStriation;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.teacherStylisticPreviewsUsesSemaphore blackWetSinDate:self.selectedDate];
        } else {
            logs = [self.teacherStylisticPreviewsUsesSemaphore auditBottom];
        }

        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 = herEventual.windowEyeLicenseCheckedAnimatorTraveled;
            }

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

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

- (void)opacityAction {
    [self foodNext];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *armpitDog = [[NSDateFormatter alloc] init];
        armpitDog.dateFormat = herEventual.minimumPrefixesOurPicturesSoftballAddressesRename;
        NSString *wideFuture = [armpitDog stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = herEventual.vitalStableAdaptorAffiliateCovariantSub;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = herEventual.yetScalingFairOuterEllipseElevationKerning;
        } else {
            self.title = wideFuture;
        }
    } else {
        self.title = herEventual.notMidExtractForbidExpiredAccessed;
    }
}

- (void)oldMoodSonAction {
    if (!self.teacherStylisticPreviewsUsesSemaphore) {
        return;
    }

    NSArray<NSDate *> *providedRecord = [self.teacherStylisticPreviewsUsesSemaphore cupNameSong];
    if (providedRecord.count == 0) {
        UIAlertController *stair = [UIAlertController alertControllerWithTitle:herEventual.youBusStoneHitWayExpect
                                                                       message:herEventual.windowEyeLicenseCheckedAnimatorTraveled
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [stair addAction:[UIAlertAction actionWithTitle:herEventual.echoGuaraniConvertMarathiManganeseWeekend style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:stair animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:herEventual.orangeDetailMisplacedAnchorsOutputStatementMonitored
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:herEventual.notMidExtractForbidExpiredAccessed
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self foodNext];
    }]];

    NSDateFormatter *armpitDog = [[NSDateFormatter alloc] init];
    armpitDog.dateFormat = herEventual.minimumPrefixesOurPicturesSoftballAddressesRename;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in providedRecord) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = herEventual.vitalStableAdaptorAffiliateCovariantSub;
        } else if ([calendar isDateInYesterday:date]) {
            title = herEventual.yetScalingFairOuterEllipseElevationKerning;
        } else {
            title = [armpitDog stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:herEventual.windowClickChromaBeginningMinimalJapanese 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.teacherStylisticPreviewsUsesSemaphore) {
        return;
    }

    NSArray *generics = [self.teacherStylisticPreviewsUsesSemaphore didAlignMin];
    if (generics.count == 0) {
        UIAlertController *stair = [UIAlertController alertControllerWithTitle:herEventual.youBusStoneHitWayExpect
                                                                       message:herEventual.weekdayPrefixesApplyTransferScrollsBox
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [stair addAction:[UIAlertAction actionWithTitle:herEventual.echoGuaraniConvertMarathiManganeseWeekend style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:stair animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:herEventual.atomicAnchoringHoursMediaSamplesSortingGesture
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:herEventual.freeProducerYardNoteEarYiddishStrictly
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self outSawRetain];
    }]];

    for (NSURL *fileURL in generics) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:herEventual.inventoryBrowseAlpineElderMusicianCountCoalesce, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self darkDownFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:herEventual.windowClickChromaBeginningMinimalJapanese style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)outSawRetain {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *spanish = [self.teacherStylisticPreviewsUsesSemaphore unloadAwayFlow];

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

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

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

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

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

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

@end
