

#import "LegalViewController.h"
#import "Clang.h"
#import "MindBalticCubicHistoryMarkOutside.h"
#import "CatMiterDonePairHex.h"
#import "GetTagSuchConfig.h"

@interface LegalViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) MindBalticCubicHistoryMarkOutside *cutBoxFilenamesHitFilter;
@property (nonatomic, strong) CatMiterDonePairHex *solveBackwardTransformSidebarOverlap;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static CatMiterDonePairHex *dietaryExemplarEditorialYouUpperVirtual = nil;
static MindBalticCubicHistoryMarkOutside *doubleIllMirroredModeNorthInstead = nil;

@implementation LegalViewController

+ (void)nineWrapKey {
    
    [Clang hertzFisheyeZipPoliciesRevokedAxes];

    doubleIllMirroredModeNorthInstead = [[MindBalticCubicHistoryMarkOutside alloc] init];
    doubleIllMirroredModeNorthInstead.littleLevel = MindInfoTicketsHalfPreferred;

    [Clang textSeventeenTwelveComposeDefined:doubleIllMirroredModeNorthInstead];

    dietaryExemplarEditorialYouUpperVirtual = [[CatMiterDonePairHex alloc] init];
    dietaryExemplarEditorialYouUpperVirtual.littleLevel = PushSobWasEgg;
    dietaryExemplarEditorialYouUpperVirtual.kinSong = 7;
    dietaryExemplarEditorialYouUpperVirtual.flippedResponseSetupCoalesceWelsh = YES;
    [Clang textSeventeenTwelveComposeDefined:dietaryExemplarEditorialYouUpperVirtual];

    [dietaryExemplarEditorialYouUpperVirtual mapEraAlarmEnd];
}

+ (CatMiterDonePairHex *)durationDownloadsCalciumPrintableAlbumPan {
    return dietaryExemplarEditorialYouUpperVirtual;
}
+ (MindBalticCubicHistoryMarkOutside *)idleDenySmallestEntriesDrainZooming {
    return doubleIllMirroredModeNorthInstead;
}

- (MindBalticCubicHistoryMarkOutside *)cutBoxFilenamesHitFilter {
    return doubleIllMirroredModeNorthInstead;
}

+ (void)limitNowViewController:(UIViewController *)parentVC {
    LegalViewController *cover = [[LegalViewController alloc] init];
    UINavigationController *kin = [[UINavigationController alloc] initWithRootViewController:cover];
    kin.modalPresentationStyle = UIModalPresentationFullScreen;
    [parentVC presentViewController:kin animated:YES completion:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = napSlashSon.expectDanceOurOutdoorHeapFact;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(wakeWasAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(givenAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(wireStrictAction)]
    ];
    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.solveBackwardTransformSidebarOverlap = [LegalViewController durationDownloadsCalciumPrintableAlbumPan];

    [self maleSpan];
}

- (void)maleSpan {
    if (!self.solveBackwardTransformSidebarOverlap) {
        _textView.text = napSlashSon.ourPenLeaseInitiallyScaleSin;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.solveBackwardTransformSidebarOverlap drumButKeepDate:self.selectedDate];
        } else {
            logs = [self.solveBackwardTransformSidebarOverlap outerExpire];
        }

        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 = napSlashSon.unsafeOutProxyLoadStackTarget;
            }

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

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

- (void)wakeWasAction {
    [self maleSpan];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *indoorCat = [[NSDateFormatter alloc] init];
        indoorCat.dateFormat = napSlashSon.seleniumLoopStylisticAutoTwoCarriageRenewing;
        NSString *menIllRoom = [indoorCat stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = napSlashSon.frenchAliveRuleMegawattsBitBegin;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = napSlashSon.geometricDegreeShiftCollectorFatalWorkoutOffset;
        } else {
            self.title = menIllRoom;
        }
    } else {
        self.title = napSlashSon.dragSalientAudibleOrdinalsMusicalLocator;
    }
}

- (void)wireStrictAction {
    if (!self.solveBackwardTransformSidebarOverlap) {
        return;
    }

    NSArray<NSDate *> *blinkThreeUsed = [self.solveBackwardTransformSidebarOverlap keysStartup];
    if (blinkThreeUsed.count == 0) {
        UIAlertController *prime = [UIAlertController alertControllerWithTitle:napSlashSon.planarSignalPublishShakeCloudUbiquity
                                                                       message:napSlashSon.unsafeOutProxyLoadStackTarget
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [prime addAction:[UIAlertAction actionWithTitle:napSlashSon.validatesBlackCompanyDidPositionsRecognize style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:prime animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:napSlashSon.tabRenewalPlateSurgeIndigoAgreementTwo
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:napSlashSon.dragSalientAudibleOrdinalsMusicalLocator
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self maleSpan];
    }]];

    NSDateFormatter *indoorCat = [[NSDateFormatter alloc] init];
    indoorCat.dateFormat = napSlashSon.seleniumLoopStylisticAutoTwoCarriageRenewing;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in blinkThreeUsed) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = napSlashSon.frenchAliveRuleMegawattsBitBegin;
        } else if ([calendar isDateInYesterday:date]) {
            title = napSlashSon.geometricDegreeShiftCollectorFatalWorkoutOffset;
        } else {
            title = [indoorCat stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:napSlashSon.muteCapableArmEyeLabeledDate style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)givenAction {
    if (!self.solveBackwardTransformSidebarOverlap) {
        return;
    }

    NSArray *oneDaily = [self.solveBackwardTransformSidebarOverlap photoMaxHue];
    if (oneDaily.count == 0) {
        UIAlertController *prime = [UIAlertController alertControllerWithTitle:napSlashSon.planarSignalPublishShakeCloudUbiquity
                                                                       message:napSlashSon.cropDriveWaxAllowRatingsVital
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [prime addAction:[UIAlertAction actionWithTitle:napSlashSon.validatesBlackCompanyDidPositionsRecognize style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:prime animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:napSlashSon.bloodClampDismissalZeroDetectionBeaconCheck
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:napSlashSon.marqueeGregorianWorldCivilPlusBankBound
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self hasSeparated];
    }]];

    for (NSURL *fileURL in oneDaily) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:napSlashSon.suddenGuideProducingRemoveAnalysisDashJustified, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self contrastFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:napSlashSon.muteCapableArmEyeLabeledDate style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)hasSeparated {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *grouped = [self.solveBackwardTransformSidebarOverlap sizeOddMinPart];

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

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

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

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

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

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

@end
