

#import "SoundViewController.h"
#import "Renew.h"
#import "OneKoreanStorePrefixesRelayFinish.h"
#import "DenseTrialUnderCourseWrappers.h"
#import "TipBlueSixConfig.h"

@interface SoundViewController ()
@property (nonatomic, strong) UITextView *textView;
@property (nonatomic, strong) OneKoreanStorePrefixesRelayFinish *withRearrangeYetReceivingAdjusts;
@property (nonatomic, strong) DenseTrialUnderCourseWrappers *hertzSocialPaymentsGenerateEmpty;
@property (nonatomic, strong) NSDate *selectedDate; 
@end

static DenseTrialUnderCourseWrappers *whoSumPromptMolePowerChatter = nil;
static OneKoreanStorePrefixesRelayFinish *floatingCharEditChinaPostAnalysis = nil;

@implementation SoundViewController

+ (void)wonPositive {
    
    [Renew sessionsPitchRecursiveMaxAppearingNordic];

    floatingCharEditChinaPostAnalysis = [[OneKoreanStorePrefixesRelayFinish alloc] init];
    floatingCharEditChinaPostAnalysis.forDayLevel = HealthPrimeHealthAlwaysBasic;

    [Renew refusedActivateHostingPinchSpine:floatingCharEditChinaPostAnalysis];

    whoSumPromptMolePowerChatter = [[DenseTrialUnderCourseWrappers alloc] init];
    whoSumPromptMolePowerChatter.forDayLevel = AddOpenFatMin;
    whoSumPromptMolePowerChatter.skipped = 7;
    whoSumPromptMolePowerChatter.netMindSortNextAge = YES;
    [Renew refusedActivateHostingPinchSpine:whoSumPromptMolePowerChatter];

    [whoSumPromptMolePowerChatter busSlowItemFax];
}

+ (DenseTrialUnderCourseWrappers *)definesFloorChromaSubmitSuddenScaling {
    return whoSumPromptMolePowerChatter;
}
+ (OneKoreanStorePrefixesRelayFinish *)inhalerFunContextsEggSeedFlow {
    return floatingCharEditChinaPostAnalysis;
}

- (OneKoreanStorePrefixesRelayFinish *)withRearrangeYetReceivingAdjusts {
    return floatingCharEditChinaPostAnalysis;
}

+ (void)showFromViewController:(UIViewController *)parentVC {
    SoundViewController *later = [[SoundViewController alloc] init];
    UINavigationController *she = [[UINavigationController alloc] initWithRootViewController:later];
    she.modalPresentationStyle = UIModalPresentationFullScreen;
    [parentVC presentViewController:she animated:YES completion:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = eggDrainBag.createMuteInviteUploadMenuMatch;
    self.view.backgroundColor = [UIColor systemBackgroundColor];

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

    self.navigationItem.rightBarButtonItems = @[
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                      target:self
                                                      action:@selector(burnWasAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction
                                                      target:self
                                                      action:@selector(unifyAction)],
        [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks
                                                      target:self
                                                      action:@selector(capGaspCupAction)]
    ];
    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.hertzSocialPaymentsGenerateEmpty = [SoundViewController definesFloorChromaSubmitSuddenScaling];

    [self waxMount];
}

- (void)waxMount {
    if (!self.hertzSocialPaymentsGenerateEmpty) {
        _textView.text = eggDrainBag.mixProtectedAboveVibrancyTapNarrative;
        return;
    }

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSString *logs;
        if (self.selectedDate) {
            logs = [self.hertzSocialPaymentsGenerateEmpty useFeedTurnDate:self.selectedDate];
        } else {
            logs = [self.hertzSocialPaymentsGenerateEmpty strokingBut];
        }

        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 = eggDrainBag.issueSocketChangedRuleCompositeTool;
            }

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

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

- (void)burnWasAction {
    [self waxMount];
}

- (void)updateTitle {
    if (self.selectedDate) {
        NSDateFormatter *loseTower = [[NSDateFormatter alloc] init];
        loseTower.dateFormat = eggDrainBag.italianAnnotatedEraBurnProvidingLighterRectum;
        NSString *sunTheSlab = [loseTower stringFromDate:self.selectedDate];

        NSCalendar *calendar = [NSCalendar currentCalendar];
        if ([calendar isDateInToday:self.selectedDate]) {
            self.title = eggDrainBag.swipeThreadHallDeclinedMegahertzFunctions;
        } else if ([calendar isDateInYesterday:self.selectedDate]) {
            self.title = eggDrainBag.requestPacketsFactSecurelyKinIntensityMegahertz;
        } else {
            self.title = sunTheSlab;
        }
    } else {
        self.title = eggDrainBag.trailingOutVowelArtistSelectionProduces;
    }
}

- (void)capGaspCupAction {
    if (!self.hertzSocialPaymentsGenerateEmpty) {
        return;
    }

    NSArray<NSDate *> *herNoteSeeBand = [self.hertzSocialPaymentsGenerateEmpty leaveSecure];
    if (herNoteSeeBand.count == 0) {
        UIAlertController *alert = [UIAlertController alertControllerWithTitle:eggDrainBag.packetEncryptNotHeavyEarlyCursors
                                                                       message:eggDrainBag.issueSocketChangedRuleCompositeTool
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [alert addAction:[UIAlertAction actionWithTitle:eggDrainBag.progressZoneSleepCommentsDoubleInteract style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:alert animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:eggDrainBag.deviceSaveMegawattsCollectMagicSonCommon
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:eggDrainBag.trailingOutVowelArtistSelectionProduces
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        self.selectedDate = nil;
        [self waxMount];
    }]];

    NSDateFormatter *loseTower = [[NSDateFormatter alloc] init];
    loseTower.dateFormat = eggDrainBag.italianAnnotatedEraBurnProvidingLighterRectum;

    NSCalendar *calendar = [NSCalendar currentCalendar];

    for (NSDate *date in herNoteSeeBand) {
        NSString *title;
        if ([calendar isDateInToday:date]) {
            title = eggDrainBag.swipeThreadHallDeclinedMegahertzFunctions;
        } else if ([calendar isDateInYesterday:date]) {
            title = eggDrainBag.requestPacketsFactSecurelyKinIntensityMegahertz;
        } else {
            title = [loseTower stringFromDate:date];
        }

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

    [actionSheet addAction:[UIAlertAction actionWithTitle:eggDrainBag.measuredSoloistYoungestIncludingIssuerOrigin style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)unifyAction {
    if (!self.hertzSocialPaymentsGenerateEmpty) {
        return;
    }

    NSArray *chloride = [self.hertzSocialPaymentsGenerateEmpty batterySolo];
    if (chloride.count == 0) {
        UIAlertController *alert = [UIAlertController alertControllerWithTitle:eggDrainBag.packetEncryptNotHeavyEarlyCursors
                                                                       message:eggDrainBag.usedRateZoneAllAskStone
                                                                preferredStyle:UIAlertControllerStyleAlert];
        [alert addAction:[UIAlertAction actionWithTitle:eggDrainBag.progressZoneSleepCommentsDoubleInteract style:UIAlertActionStyleDefault handler:nil]];
        [self presentViewController:alert animated:YES completion:nil];
        return;
    }

    UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:eggDrainBag.effectiveFirmwarePreparedOpenMotionBurmeseClinical
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

    [actionSheet addAction:[UIAlertAction actionWithTitle:eggDrainBag.inlandSnapAdobeMatchOurMagicPen
                                                    style:UIAlertActionStyleDefault
                                                  handler:^(UIAlertAction *action) {
        [self napRedHigher];
    }]];

    for (NSURL *fileURL in chloride) {
        NSString *fileName = fileURL.lastPathComponent;
        [actionSheet addAction:[UIAlertAction actionWithTitle:[NSString stringWithFormat:eggDrainBag.ticketsProcessorAccurateWarningColoredHindiUtility, fileName]
                                                        style:UIAlertActionStyleDefault
                                                      handler:^(UIAlertAction *action) {
            [self gradeArtFile:fileURL];
        }]];
    }

    [actionSheet addAction:[UIAlertAction actionWithTitle:eggDrainBag.measuredSoloistYoungestIncludingIssuerOrigin style:UIAlertActionStyleCancel handler:nil]];

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

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

- (void)napRedHigher {
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        
        NSString *raceDue = [self.hertzSocialPaymentsGenerateEmpty bothTagDropMix];

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

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

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

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

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

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

@end
