

#import "BrushViewController.h"
#import "Badge.h"
#import "SongTagFatDiscardThirdRanging.h"
#import "UsabilityRecentLocalityCheckerMap.h"
#import "OptTextSeeConfig.h"

@interface BrushViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) SongTagFatDiscardThirdRanging *memberFlightSemanticsSyntheticKey;
@property (nonatomic, strong) UsabilityRecentLocalityCheckerMap *existingEggAndCollapsedSodium;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static UsabilityRecentLocalityCheckerMap *audibleUnderAddressSkippedEffectiveBad = nil;
static SongTagFatDiscardThirdRanging *plainEnsureDitherCatArtBar = nil;

@implementation BrushViewController

+ (void)otherCommon {
    
    [Badge additionsDisparityAccessingWeekdayAutomaticAscender];

    plainEnsureDitherCatArtBar = [[SongTagFatDiscardThirdRanging alloc] init];
    plainEnsureDitherCatArtBar.sunEraLevel = CopperHitPurchasedHerMinute;

    [Badge signatureSimpleExtensionSundaneseDocuments:plainEnsureDitherCatArtBar];

    audibleUnderAddressSkippedEffectiveBad = [[UsabilityRecentLocalityCheckerMap alloc] init];
    audibleUnderAddressSkippedEffectiveBad.sunEraLevel = PinchRedBuilt;
    audibleUnderAddressSkippedEffectiveBad.younger = 7;
    audibleUnderAddressSkippedEffectiveBad.rawSecondaryClaimTryOutcome = YES;
    [Badge signatureSimpleExtensionSundaneseDocuments:audibleUnderAddressSkippedEffectiveBad];

    [audibleUnderAddressSkippedEffectiveBad appendAssamese];
}

+ (UsabilityRecentLocalityCheckerMap *)armSetupCancelingMobileZipRecord {
    return audibleUnderAddressSkippedEffectiveBad;
}
+ (SongTagFatDiscardThirdRanging *)ringBankAnyAndHueFactor {
    return plainEnsureDitherCatArtBar;
}

- (SongTagFatDiscardThirdRanging *)memberFlightSemanticsSyntheticKey {
    return plainEnsureDitherCatArtBar;
}

+ (void)albanianViewController:(UIViewController *)parentVC {
    BrushViewController *arrow = [[BrushViewController alloc] init];
    UINavigationController *bin = [[UINavigationController alloc] initWithRootViewController:arrow];
    bin.modalPresentationStyle = UIModalPresentationFullScreen;
    [parentVC presentViewController:bin animated:YES completion:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = notWillTone.thousandsManyAscendingContainsPongArmour;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(zoomingAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(clangAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(mountedMapAction)]
    ];
    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.existingEggAndCollapsedSodium = [BrushViewController armSetupCancelingMobileZipRecord];

    [self assetWas];
}

- (void)assetWas {
    if (!self.existingEggAndCollapsedSodium) {
        _textView.text = notWillTone.guestDistortedOuncesEndToneExemplar;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.existingEggAndCollapsedSodium upperKazakhDate:self.selectedDate];
        } else {
            logs = [self.existingEggAndCollapsedSodium sharingAtom];
        }

        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 = notWillTone.selectedHowMathAnimateWayNear;
            }

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

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

- (void)zoomingAction {
    [self assetWas];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *fiberMask = [[NSDateFormatter alloc] init];
        fiberMask.dateFormat = notWillTone.heartbeatExpectBeatSundaneseToolTibetanSlight;
        NSString *disposeHis = [fiberMask stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = notWillTone.megawattsWateryWrittenYearsSensorSign;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = notWillTone.dateAdditiveCadenceNowPageCollectorStrip;
        } else {
            self.title = disposeHis;
        }
    } else {
        self.title = notWillTone.addressesScopeTeethPatchUnloadCanadian;
    }
}

- (void)mountedMapAction {
    if (!self.existingEggAndCollapsedSodium) {
        return;
    }

    NSArray<NSDate *> *itsPeakHerRead = [self.existingEggAndCollapsedSodium animateRope];
    if (itsPeakHerRead.count == 0) {
        UIAlertController *quiet = [UIAlertController alertControllerWithTitle:notWillTone.bothNordicUtilitiesDaysLocallySpa
                                                                       message:notWillTone.selectedHowMathAnimateWayNear
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [quiet addAction:[UIAlertAction actionWithTitle:notWillTone.saltHairSeeInspiredRussianYears style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:quiet animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:notWillTone.hexEndModifiedSlashedSmoothingGracefulRatings
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:notWillTone.addressesScopeTeethPatchUnloadCanadian
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self assetWas];
    }]];

    NSDateFormatter *fiberMask = [[NSDateFormatter alloc] init];
    fiberMask.dateFormat = notWillTone.heartbeatExpectBeatSundaneseToolTibetanSlight;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in itsPeakHerRead) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = notWillTone.megawattsWateryWrittenYearsSensorSign;
        } else if ([calendar isDateInYesterday:date]) {
            title = notWillTone.dateAdditiveCadenceNowPageCollectorStrip;
        } else {
            title = [fiberMask stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:notWillTone.gestureDownloadResultingCreatingLigaturesIcy style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)clangAction {
    if (!self.existingEggAndCollapsedSodium) {
        return;
    }

    NSArray *eulerFit = [self.existingEggAndCollapsedSodium ownFeetBoth];
    if (eulerFit.count == 0) {
        UIAlertController *quiet = [UIAlertController alertControllerWithTitle:notWillTone.bothNordicUtilitiesDaysLocallySpa
                                                                       message:notWillTone.childLinkScannerSelectorsCountryEnd
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [quiet addAction:[UIAlertAction actionWithTitle:notWillTone.saltHairSeeInspiredRussianYears style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:quiet animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:notWillTone.factoredStableThirteenRowsExitsTertiaryObserving
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:notWillTone.outerGenerateRebusSupportedAccountGramEntry
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self carCarMaster];
    }]];

    for (NSURL *fileURL in eulerFit) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:notWillTone.ascentForkInteractAreSumPasteOff, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self pauseBusFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:notWillTone.gestureDownloadResultingCreatingLigaturesIcy style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)carCarMaster {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *chapter = [self.existingEggAndCollapsedSodium mayFontIconBus];

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

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

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

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

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

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

@end
