

#import "GlyphViewController.h"
#import "Fetch.h"
#import "CanadianAreaResultTerahertzRankDescribe.h"
#import "ExistingUpscaleChangedOurLocalized.h"
#import "ItemOneMenConfig.h"

@interface GlyphViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) CanadianAreaResultTerahertzRankDescribe *additionMagnesiumBleedAppearsInfo;
@property (nonatomic, strong) ExistingUpscaleChangedOurLocalized *urgentListenCriteriaBestStrip;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static ExistingUpscaleChangedOurLocalized *finishPostDimensionEngravedMastersExec = nil;
static CanadianAreaResultTerahertzRankDescribe *prettyExposureBelowUnboundRedoLight = nil;

@implementation GlyphViewController

+ (void)itsRollFade {
    
    [Fetch nearbySymptomSeventeenLearnedQueryViability];

    prettyExposureBelowUnboundRedoLight = [[CanadianAreaResultTerahertzRankDescribe alloc] init];
    prettyExposureBelowUnboundRedoLight.butPutLevel = MidFixtureRestoresSentInterest;

    [Fetch swimmingParsecsUptimeAxialHas:prettyExposureBelowUnboundRedoLight];

    finishPostDimensionEngravedMastersExec = [[ExistingUpscaleChangedOurLocalized alloc] init];
    finishPostDimensionEngravedMastersExec.butPutLevel = LiveInherited;
    finishPostDimensionEngravedMastersExec.bendCut = 7;
    finishPostDimensionEngravedMastersExec.speakerNewtonsResponseConfigureParagraph = YES;
    [Fetch swimmingParsecsUptimeAxialHas:finishPostDimensionEngravedMastersExec];

    [finishPostDimensionEngravedMastersExec wrapDarwinTurn];
}

+ (ExistingUpscaleChangedOurLocalized *)keepLongerExplicitSummariesPartiallyReal {
    return finishPostDimensionEngravedMastersExec;
}
+ (CanadianAreaResultTerahertzRankDescribe *)tooErrorCanRetryStiffnessHelp {
    return prettyExposureBelowUnboundRedoLight;
}

- (CanadianAreaResultTerahertzRankDescribe *)additionMagnesiumBleedAppearsInfo {
    return prettyExposureBelowUnboundRedoLight;
}

+ (void)hostLateViewController:(UIViewController *)parentVC {
    GlyphViewController *smile = [[GlyphViewController alloc] init];
    UINavigationController *sub = [[UINavigationController alloc] initWithRootViewController:smile];
    sub.modalPresentationStyle = UIModalPresentationFullScreen;
    [parentVC presentViewController:sub animated:YES completion:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = qualityAway.unifyHourlyDiscardsActivityInsertionHow;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(expectsAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(scoreAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(sayTipTimeAction)]
    ];
    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.urgentListenCriteriaBestStrip = [GlyphViewController keepLongerExplicitSummariesPartiallyReal];

    [self lockHalf];
}

- (void)lockHalf {
    if (!self.urgentListenCriteriaBestStrip) {
        _textView.text = qualityAway.starPairUnifiedAreaMegabitsReuse;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.urgentListenCriteriaBestStrip foundMinderDate:self.selectedDate];
        } else {
            logs = [self.urgentListenCriteriaBestStrip membersFlag];
        }

        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 = qualityAway.optLateHebrewAsleepQuitHello;
            }

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

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

- (void)expectsAction {
    [self lockHalf];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *cupDecode = [[NSDateFormatter alloc] init];
        cupDecode.dateFormat = qualityAway.crossConnectedExportUnwindTodayDrainExtern;
        NSString *faceFrench = [cupDecode stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = qualityAway.watchedFlashChargingEnableModifiersEdit;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = qualityAway.expandTouchRespondReasonInterestCautionPong;
        } else {
            self.title = faceFrench;
        }
    } else {
        self.title = qualityAway.pieceForbidPickerAudiogramBikeGrade;
    }
}

- (void)sayTipTimeAction {
    if (!self.urgentListenCriteriaBestStrip) {
        return;
    }

    NSArray<NSDate *> *pageErrorShelf = [self.urgentListenCriteriaBestStrip adoptMaxNow];
    if (pageErrorShelf.count == 0) {
        UIAlertController *inner = [UIAlertController alertControllerWithTitle:qualityAway.sumRedoLikeLikeSchemesOriginal
                                                                       message:qualityAway.optLateHebrewAsleepQuitHello
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [inner addAction:[UIAlertAction actionWithTitle:qualityAway.improperSlabBrokenCircleBoxSolutions style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:inner animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:qualityAway.appendedConductorNotifiedCommonIntervalConstructRaw
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:qualityAway.pieceForbidPickerAudiogramBikeGrade
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self lockHalf];
    }]];

    NSDateFormatter *cupDecode = [[NSDateFormatter alloc] init];
    cupDecode.dateFormat = qualityAway.crossConnectedExportUnwindTodayDrainExtern;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in pageErrorShelf) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = qualityAway.watchedFlashChargingEnableModifiersEdit;
        } else if ([calendar isDateInYesterday:date]) {
            title = qualityAway.expandTouchRespondReasonInterestCautionPong;
        } else {
            title = [cupDecode stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:qualityAway.subDenseSmoothingDropFlexibleObservers style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)scoreAction {
    if (!self.urgentListenCriteriaBestStrip) {
        return;
    }

    NSArray *reliable = [self.urgentListenCriteriaBestStrip passWhoBank];
    if (reliable.count == 0) {
        UIAlertController *inner = [UIAlertController alertControllerWithTitle:qualityAway.sumRedoLikeLikeSchemesOriginal
                                                                       message:qualityAway.caretScannerTerabytesCurveIntegerOperating
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [inner addAction:[UIAlertAction actionWithTitle:qualityAway.improperSlabBrokenCircleBoxSolutions style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:inner animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:qualityAway.barSquashReportsInverseRetVisionRecording
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:qualityAway.handleOptimizedRelationSecurityUtteranceSummaryCharge
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self penNodeSlash];
    }]];

    for (NSURL *fileURL in reliable) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:qualityAway.tryTailEpsilonPongCatalogEmergencyTags, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self photoDryFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:qualityAway.subDenseSmoothingDropFlexibleObservers style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)penNodeSlash {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *jumpCup = [self.urgentListenCriteriaBestStrip logShowMidEcho];

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

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

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

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

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

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

@end
