

#import "DailyViewController.h"
#import "Press.h"
#import "PrecisionGenderRejectPlayingAirborneLocality.h"
#import "WaterPriorInstancesArtCollapse.h"
#import "GroupSlashConfig.h"

@interface DailyViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) PrecisionGenderRejectPlayingAirborneLocality *secondCapEnhanceWhileStrongest;
@property (nonatomic, strong) WaterPriorInstancesArtCollapse *notationEndsProcessesBedModel;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static WaterPriorInstancesArtCollapse *reorderEnablingFactExporterLifetimeArtwork = nil;
static PrecisionGenderRejectPlayingAirborneLocality *processesDaughterHebrewRegionPinCriteria = nil;

@implementation DailyViewController

+ (void)flushedWrap {
    
    [Press unifyRebusStableGroupTeamTab];

    processesDaughterHebrewRegionPinCriteria = [[PrecisionGenderRejectPlayingAirborneLocality alloc] init];
    processesDaughterHebrewRegionPinCriteria.handleLevel = SoundPlayCapsSawHigh;

    [Press sinhaleseEmbeddingCreatedPerformedSun:processesDaughterHebrewRegionPinCriteria];

    reorderEnablingFactExporterLifetimeArtwork = [[WaterPriorInstancesArtCollapse alloc] init];
    reorderEnablingFactExporterLifetimeArtwork.handleLevel = ReuseStoodBus;
    reorderEnablingFactExporterLifetimeArtwork.presses = 7;
    reorderEnablingFactExporterLifetimeArtwork.voiceFatSpecifyUnsignedTitle = YES;
    [Press sinhaleseEmbeddingCreatedPerformedSun:reorderEnablingFactExporterLifetimeArtwork];

    [reorderEnablingFactExporterLifetimeArtwork outputAllocate];
}

+ (WaterPriorInstancesArtCollapse *)kilometerTaskMapQualifierBloodPin {
    return reorderEnablingFactExporterLifetimeArtwork;
}
+ (PrecisionGenderRejectPlayingAirborneLocality *)mealFiveSphereRevisionListenCheckout {
    return processesDaughterHebrewRegionPinCriteria;
}

- (PrecisionGenderRejectPlayingAirborneLocality *)secondCapEnhanceWhileStrongest {
    return processesDaughterHebrewRegionPinCriteria;
}

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

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = noneParsing.producesHexBarrierLayeringLoseMacintosh;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(cricketAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(driveAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(icySheSoloAction)]
    ];
    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.notationEndsProcessesBedModel = [DailyViewController kilometerTaskMapQualifierBloodPin];

    [self tatarSun];
}

- (void)tatarSun {
    if (!self.notationEndsProcessesBedModel) {
        _textView.text = noneParsing.perfusionHandleCosmicDroppedLeapSay;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.notationEndsProcessesBedModel loudItsHoldDate:self.selectedDate];
        } else {
            logs = [self.notationEndsProcessesBedModel illHexCount];
        }

        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 = noneParsing.spaDarwinVortexMoveAsleepQuerying;
            }

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

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

- (void)cricketAction {
    [self tatarSun];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *zoomBezel = [[NSDateFormatter alloc] init];
        zoomBezel.dateFormat = noneParsing.allFitPossibleCanChinaEraSpeak;
        NSString *fixtureGet = [zoomBezel stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = noneParsing.integersSemicolonEraserNineExclusiveItalian;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = noneParsing.editHoursKilobytesCandidateSuccessPackageReachable;
        } else {
            self.title = fixtureGet;
        }
    } else {
        self.title = noneParsing.socialSaturateIndicesFloaterPressCar;
    }
}

- (void)icySheSoloAction {
    if (!self.notationEndsProcessesBedModel) {
        return;
    }

    NSArray<NSDate *> *sinWetUsePulse = [self.notationEndsProcessesBedModel centerFiber];
    if (sinWetUsePulse.count == 0) {
        UIAlertController *liter = [UIAlertController alertControllerWithTitle:noneParsing.farSamplesTopLingerCatRun
                                                                       message:noneParsing.spaDarwinVortexMoveAsleepQuerying
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [liter addAction:[UIAlertAction actionWithTitle:noneParsing.objectNetIcyReturningYesterdayAbsolute style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:liter animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:noneParsing.rollbackLoopsSpaSmartWakeRevokedOut
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:noneParsing.socialSaturateIndicesFloaterPressCar
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self tatarSun];
    }]];

    NSDateFormatter *zoomBezel = [[NSDateFormatter alloc] init];
    zoomBezel.dateFormat = noneParsing.allFitPossibleCanChinaEraSpeak;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in sinWetUsePulse) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = noneParsing.integersSemicolonEraserNineExclusiveItalian;
        } else if ([calendar isDateInYesterday:date]) {
            title = noneParsing.editHoursKilobytesCandidateSuccessPackageReachable;
        } else {
            title = [zoomBezel stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:noneParsing.twoAscendingSumUsageTerahertzQuery style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)driveAction {
    if (!self.notationEndsProcessesBedModel) {
        return;
    }

    NSArray *audioFun = [self.notationEndsProcessesBedModel panBreaking];
    if (audioFun.count == 0) {
        UIAlertController *liter = [UIAlertController alertControllerWithTitle:noneParsing.farSamplesTopLingerCatRun
                                                                       message:noneParsing.idiomSumSuchAddDeliveryCut
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [liter addAction:[UIAlertAction actionWithTitle:noneParsing.objectNetIcyReturningYesterdayAbsolute style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:liter animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:noneParsing.sinhaleseOverlapRectumRecognizeBridgingCommonWet
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:noneParsing.enclosingLargestSilentPolicyVoiceDownhillEntries
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self wasBatchAtom];
    }]];

    for (NSURL *fileURL in audioFun) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:noneParsing.serializeRouterBundlePreparedTwelveOpacityLater, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self wideManyFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:noneParsing.twoAscendingSumUsageTerahertzQuery style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)wasBatchAtom {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *rootTab = [self.notationEndsProcessesBedModel offEndLaterZip];

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

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

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

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

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

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

@end
