

#import "PriceViewController.h"
#import "Store.h"
#import "AllowBookmarksEngravedInsideWrestlingShe.h"
#import "DetectionAlbumTabFlushExporting.h"
#import "BlurPopTagConfig.h"

@interface PriceViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) AllowBookmarksEngravedInsideWrestlingShe *redExpansionBecomeGivenOutline;
@property (nonatomic, strong) DetectionAlbumTabFlushExporting *redoneQuotationAudiogramConcertStalled;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static DetectionAlbumTabFlushExporting *polishPersonLooperActionExistentProvide = nil;
static AllowBookmarksEngravedInsideWrestlingShe *appearTabReadDefineChargeHome = nil;

@implementation PriceViewController

+ (void)hallTagFoot {
    
    [Store brokenComposerChainIntervalsHerAssamese];

    appearTabReadDefineChargeHome = [[AllowBookmarksEngravedInsideWrestlingShe alloc] init];
    appearTabReadDefineChargeHome.dogOldLevel = PartKitChangedDecryptedSix;

    [Store capBuddhistTailBlurUnordered:appearTabReadDefineChargeHome];

    polishPersonLooperActionExistentProvide = [[DetectionAlbumTabFlushExporting alloc] init];
    polishPersonLooperActionExistentProvide.dogOldLevel = PermuteWindow;
    polishPersonLooperActionExistentProvide.seeGrow = 7;
    polishPersonLooperActionExistentProvide.sideDrumGoalLifetimeCat = YES;
    [Store capBuddhistTailBlurUnordered:polishPersonLooperActionExistentProvide];

    [polishPersonLooperActionExistentProvide miterHisSonOld];
}

+ (DetectionAlbumTabFlushExporting *)topSmoothGrantedBinEyeAre {
    return polishPersonLooperActionExistentProvide;
}
+ (AllowBookmarksEngravedInsideWrestlingShe *)farthestSexHardActivityDelayBin {
    return appearTabReadDefineChargeHome;
}

- (AllowBookmarksEngravedInsideWrestlingShe *)redExpansionBecomeGivenOutline {
    return appearTabReadDefineChargeHome;
}

+ (void)carriageViewController:(UIViewController *)parentVC {
    PriceViewController *chain = [[PriceViewController alloc] init];
    UINavigationController *ten = [[UINavigationController alloc] initWithRootViewController:chain];
    ten.modalPresentationStyle = UIModalPresentationFullScreen;
    [parentVC presentViewController:ten animated:YES completion:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = rowChildBar.reuseTapRecorderGrayHerSwipe;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(funLossAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(frontAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(bendSayKinAction)]
    ];
    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.redoneQuotationAudiogramConcertStalled = [PriceViewController topSmoothGrantedBinEyeAre];

    [self andArrow];
}

- (void)andArrow {
    if (!self.redoneQuotationAudiogramConcertStalled) {
        _textView.text = rowChildBar.immediateRatioEightLengthsMouthAll;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.redoneQuotationAudiogramConcertStalled dayMutationDate:self.selectedDate];
        } else {
            logs = [self.redoneQuotationAudiogramConcertStalled eyeThumbDid];
        }

        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 = rowChildBar.bracketedBadYearIncludingSayItalic;
            }

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

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

- (void)funLossAction {
    [self andArrow];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *optOutlet = [[NSDateFormatter alloc] init];
        optOutlet.dateFormat = rowChildBar.daysImmediateAuthorsViewRateDeclinedGlyph;
        NSString *minorPaper = [optOutlet stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = rowChildBar.feedHellmanTapsAnnotatedComparedPassively;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = rowChildBar.decodeRetYoungestHumanMenuButEra;
        } else {
            self.title = minorPaper;
        }
    } else {
        self.title = rowChildBar.thumbnailDispatchDogOceanAddRenewal;
    }
}

- (void)bendSayKinAction {
    if (!self.redoneQuotationAudiogramConcertStalled) {
        return;
    }

    NSArray<NSDate *> *subLateWeekOpt = [self.redoneQuotationAudiogramConcertStalled runLegalDry];
    if (subLateWeekOpt.count == 0) {
        UIAlertController *exist = [UIAlertController alertControllerWithTitle:rowChildBar.positiveSwedishDialogMiterElapsedSessions
                                                                       message:rowChildBar.bracketedBadYearIncludingSayItalic
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [exist addAction:[UIAlertAction actionWithTitle:rowChildBar.successNoiseBeenOneFoldClaim style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:exist animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:rowChildBar.spaBiotinRearZipNetScannedOldest
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:rowChildBar.thumbnailDispatchDogOceanAddRenewal
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self andArrow];
    }]];

    NSDateFormatter *optOutlet = [[NSDateFormatter alloc] init];
    optOutlet.dateFormat = rowChildBar.daysImmediateAuthorsViewRateDeclinedGlyph;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in subLateWeekOpt) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = rowChildBar.feedHellmanTapsAnnotatedComparedPassively;
        } else if ([calendar isDateInYesterday:date]) {
            title = rowChildBar.decodeRetYoungestHumanMenuButEra;
        } else {
            title = [optOutlet stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:rowChildBar.backwardSnowCancelingBehaveSunRain style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)frontAction {
    if (!self.redoneQuotationAudiogramConcertStalled) {
        return;
    }

    NSArray *binCubic = [self.redoneQuotationAudiogramConcertStalled netTipMaker];
    if (binCubic.count == 0) {
        UIAlertController *exist = [UIAlertController alertControllerWithTitle:rowChildBar.positiveSwedishDialogMiterElapsedSessions
                                                                       message:rowChildBar.kindSphereDublinGeneratorConvertTriangle
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [exist addAction:[UIAlertAction actionWithTitle:rowChildBar.successNoiseBeenOneFoldClaim style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:exist animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:rowChildBar.collisionIcyEngineerStayZipInstallsRun
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:rowChildBar.subNowLineUsageChangePolishRecent
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self resultingCat];
    }]];

    for (NSURL *fileURL in binCubic) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:rowChildBar.raiseStableExpertForwardCardioidVersionGranting, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self bikePintFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:rowChildBar.backwardSnowCancelingBehaveSunRain style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)resultingCat {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *farLeft = [self.redoneQuotationAudiogramConcertStalled digitalClamped];

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

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

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

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

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

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

@end
