

#import "FloatViewController.h"
#import "Album.h"
#import "AudibleAdvancedAirNeutralInitiallyServer.h"
#import "RetainMutationsLowPaperLearn.h"
#import "SizeFactorConfig.h"

@interface FloatViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) AudibleAdvancedAirNeutralInitiallyServer *butCellularReferenceCycleAction;
@property (nonatomic, strong) RetainMutationsLowPaperLearn *mutableForEpisodeNiacinTraverse;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static RetainMutationsLowPaperLearn *sentTenNormalizeHandlerChooseGroup = nil;
static AudibleAdvancedAirNeutralInitiallyServer *usageInitiatedOpaqueLocalesIndigoHome = nil;

@implementation FloatViewController

+ (void)stayPronoun {
    
    [Album offsetThroughPaceStepPermanentFirmware];

    usageInitiatedOpaqueLocalesIndigoHome = [[AudibleAdvancedAirNeutralInitiallyServer alloc] init];
    usageInitiatedOpaqueLocalesIndigoHome.redWhoLevel = CurrencyFlatnessTerminalOverflowAtom;

    [Album encryptedAuditedRestTranslateMargin:usageInitiatedOpaqueLocalesIndigoHome];

    sentTenNormalizeHandlerChooseGroup = [[RetainMutationsLowPaperLearn alloc] init];
    sentTenNormalizeHandlerChooseGroup.redWhoLevel = AreExpiredRun;
    sentTenNormalizeHandlerChooseGroup.midSeed = 7;
    sentTenNormalizeHandlerChooseGroup.vitalRankFathomsMillionSolve = YES;
    [Album encryptedAuditedRestTranslateMargin:sentTenNormalizeHandlerChooseGroup];

    [sentTenNormalizeHandlerChooseGroup foldLiveSlavic];
}

+ (RetainMutationsLowPaperLearn *)ownerCenteredIdentityTouchFilmBatch {
    return sentTenNormalizeHandlerChooseGroup;
}
+ (AudibleAdvancedAirNeutralInitiallyServer *)visualDownGrandauntDateMomentaryStreet {
    return usageInitiatedOpaqueLocalesIndigoHome;
}

- (AudibleAdvancedAirNeutralInitiallyServer *)butCellularReferenceCycleAction {
    return usageInitiatedOpaqueLocalesIndigoHome;
}

+ (void)tallGrowViewController:(UIViewController *)parentVC {
    FloatViewController *stone = [[FloatViewController alloc] init];
    UINavigationController *cup = [[UINavigationController alloc] initWithRootViewController:stone];
    cup.modalPresentationStyle = UIModalPresentationFullScreen;
    [parentVC presentViewController:cup animated:YES completion:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = kitCardMean.suggestBedLikePurposeScanHeight;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(sobTreeAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(aboveAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(dryNoneWhoAction)]
    ];
    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.mutableForEpisodeNiacinTraverse = [FloatViewController ownerCenteredIdentityTouchFilmBatch];

    [self centrals];
}

- (void)centrals {
    if (!self.mutableForEpisodeNiacinTraverse) {
        _textView.text = kitCardMean.bevelGeorgianPreventAdvancedBedEnable;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.mutableForEpisodeNiacinTraverse adoptLogCupDate:self.selectedDate];
        } else {
            logs = [self.mutableForEpisodeNiacinTraverse closeBitNow];
        }

        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 = kitCardMean.netscapeNowComplexOwnRequireOut;
            }

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

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

- (void)sobTreeAction {
    [self centrals];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *movieFeed = [[NSDateFormatter alloc] init];
        movieFeed.dateFormat = kitCardMean.revisionRenewClipPersonGarbagePaddlePreserves;
        NSString *tabVeryNow = [movieFeed stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = kitCardMean.flatLockJumpOceanIndigoBody;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = kitCardMean.annotatedTightTimeImplicitInputTwistGrandaunt;
        } else {
            self.title = tabVeryNow;
        }
    } else {
        self.title = kitCardMean.doubleAllocateUnsignedTooCreateDog;
    }
}

- (void)dryNoneWhoAction {
    if (!self.mutableForEpisodeNiacinTraverse) {
        return;
    }

    NSArray<NSDate *> *draftConverter = [self.mutableForEpisodeNiacinTraverse bannerMagic];
    if (draftConverter.count == 0) {
        UIAlertController *heart = [UIAlertController alertControllerWithTitle:kitCardMean.binClearMailOperandPetabytesBox
                                                                       message:kitCardMean.netscapeNowComplexOwnRequireOut
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [heart addAction:[UIAlertAction actionWithTitle:kitCardMean.cityOneAlignmentSpaSubtitlesShare style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:heart animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:kitCardMean.cathedralSimpleHailDiacriticPotassiumBoundKilogram
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:kitCardMean.doubleAllocateUnsignedTooCreateDog
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self centrals];
    }]];

    NSDateFormatter *movieFeed = [[NSDateFormatter alloc] init];
    movieFeed.dateFormat = kitCardMean.revisionRenewClipPersonGarbagePaddlePreserves;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in draftConverter) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = kitCardMean.flatLockJumpOceanIndigoBody;
        } else if ([calendar isDateInYesterday:date]) {
            title = kitCardMean.annotatedTightTimeImplicitInputTwistGrandaunt;
        } else {
            title = [movieFeed stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:kitCardMean.fourteenMethodSubjectMidHintProvince style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)aboveAction {
    if (!self.mutableForEpisodeNiacinTraverse) {
        return;
    }

    NSArray *ourPause = [self.mutableForEpisodeNiacinTraverse illPackHome];
    if (ourPause.count == 0) {
        UIAlertController *heart = [UIAlertController alertControllerWithTitle:kitCardMean.binClearMailOperandPetabytesBox
                                                                       message:kitCardMean.tornadoCampaignHueStrokedDuplexMode
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [heart addAction:[UIAlertAction actionWithTitle:kitCardMean.cityOneAlignmentSpaSubtitlesShare style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:heart animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:kitCardMean.appendedPaddleChargePrefixScalarNorthElement
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:kitCardMean.equalNewtonsBankersPromotionAuxiliaryMarathiSlant
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self touchSquared];
    }]];

    for (NSURL *fileURL in ourPause) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:kitCardMean.slopeOnceCutUserOddExternGiven, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self obscuresFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:kitCardMean.fourteenMethodSubjectMidHintProvince style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)touchSquared {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *menPart = [self.mutableForEpisodeNiacinTraverse roomDevicePick];

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

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

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

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

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

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

@end
