






#import "HangOrderManager.h"
#import "ForIconPrepMixViewController.h"
#import "PanUserAndConfig.h"

@interface HangOrderManager()
@property (nonatomic, strong) NSMutableArray<UIWindow *> *penOptSplatRed;  
@property (nonatomic, strong) NSMutableArray<UIWindow *> *orderZooming;  
@end

@implementation HangOrderManager

- (instancetype)init {
    self = [super init];
    if (self) {
        _penOptSplatRed = [NSMutableArray array];
        _orderZooming = [NSMutableArray array];
    }
    return self;
}

+ (instancetype)shared {
    static id shared = nil;
    static dispatch_once_t nodeToken;
    dispatch_once(&nodeToken, ^{
        shared = [[super alloc] init];
    });
    return shared;
}


- (UIWindow *)hueAuditedWindow {
    UIWindow *trashWindow = nil;
    
    if (@available(iOS 13.0, *)) {
        
        NSSet<UIScene *> *connectedScenes = [UIApplication sharedApplication].connectedScenes;
        for (UIScene *scene in connectedScenes) {
            
            if (scene.activationState == UISceneActivationStateForegroundActive &&
                [scene isKindOfClass:[UIWindowScene class]]) {
                
                UIWindowScene *windowScene = (UIWindowScene *)scene;
                
                if (windowScene.windows.count > 0) {
                    trashWindow = windowScene.windows.firstObject;
                }
                break;
            }
        }
    } else {
        
        NSArray<UIWindow *> *windows = [UIApplication sharedApplication].windows;
        if (windows.count > 0) {
            trashWindow = windows.firstObject;
        }
    }
    
    
    if (!trashWindow) {
        NSArray<UIWindow *> *windows = [UIApplication sharedApplication].windows;
        if (windows.count > 0) {
            trashWindow = windows.firstObject;
        }
    }
    
    return trashWindow;
}


- (UIWindow *)outputsCauseWindow {
    
    UIWindow *installWindow = nil;
    
    if (@available(iOS 13.0, *)) {
        NSSet<UIScene *> *connectedScenes = [UIApplication sharedApplication].connectedScenes;
        for (UIScene *scene in connectedScenes) {
            if (scene.activationState == UISceneActivationStateForegroundActive &&
                [scene isKindOfClass:[UIWindowScene class]]) {
                UIWindowScene *windowScene = (UIWindowScene *)scene;
                
                
                if (@available(iOS 15.0, *)) {
                    installWindow = windowScene.keyWindow;
                }
                
                else {
                    for (UIWindow *window in windowScene.windows) {
                        if (window.isKeyWindow) {
                            installWindow = window;
                            break;
                        }
                    }
                }
                break;
            }
        }
    } else {
        
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
        installWindow = [UIApplication sharedApplication].keyWindow;
#pragma clang diagnostic pop
    }
    
    
    if (!installWindow) {
        NSArray<UIWindow *> *windows = [UIApplication sharedApplication].windows;
        for (UIWindow *window in windows) {
            if (window.isKeyWindow) {
                installWindow = window;
                break;
            }
        }
    }
    
    return installWindow;
}


- (void)patternsDissolveBlueConstantsSandboxFloorEncodedViewController:(UIViewController *)cupDid{
    dispatch_async(dispatch_get_main_queue(), ^{
        
        if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
            
            UIWindow *outWindow = [self zoomIgnoringAreSeleniumDeltaFunnel:cupDid];
            
            
            [self performedEnableBalanceShearRetTriggers:outWindow];
            
            [self.penOptSplatRed addObject:outWindow];
        } else {
            
            __weak typeof(self) weakSelf = self;
            
            __block __weak id air = nil;
            
            air = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification
                                                                       object:nil
                                                                        queue:[NSOperationQueue mainQueue]
                                                                   usingBlock:^(NSNotification *note) {
                
                [[NSNotificationCenter defaultCenter] removeObserver:air];
                [weakSelf patternsDissolveBlueConstantsSandboxFloorEncodedViewController:cupDid];
            }];
        }
    });
}

- (void)stairSlabMainMaxMalayalamSymmetricViewController:(UIViewController *)cupDid {
    dispatch_async(dispatch_get_main_queue(), ^{
        if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
            [self observersLocalizesSpanPortalKnowSourceEvaluated:cupDid];
        } else {
            
            __weak typeof(self) weakSelf = self;
            
            __block __weak id air = nil;
            
            air = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification
                                                                       object:nil
                                                                        queue:[NSOperationQueue mainQueue]
                                                                   usingBlock:^(NSNotification *note) {
                
                [[NSNotificationCenter defaultCenter] removeObserver:air];
                
                [weakSelf observersLocalizesSpanPortalKnowSourceEvaluated:cupDid];
            }];
        }
    });
}

- (void)handlerNotSourceExpertShowersDayView:(UIView *)view {
    dispatch_async(dispatch_get_main_queue(), ^{
        if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
            [self observersLocalizesSpanPortalKnowSourceEvaluated:view];
        } else {
            
            __weak typeof(self) weakSelf = self;
            
            __block __weak id air = nil;
            
            air = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification
                                                                       object:nil
                                                                        queue:[NSOperationQueue mainQueue]
                                                                   usingBlock:^(NSNotification *note) {
                
                [[NSNotificationCenter defaultCenter] removeObserver:air];
                
                [weakSelf observersLocalizesSpanPortalKnowSourceEvaluated:view];
            }];
        }
    });
}

- (void)observersLocalizesSpanPortalKnowSourceEvaluated:(id)object {
    UIViewController *cupDid = nil;
    
        
    if ([object isKindOfClass:[UIViewController class]]) {
        cupDid = object;
    }
    
    if ([object isKindOfClass:[UIView class]]) {
        cupDid = [ForIconPrepMixViewController new];
        cupDid.view = object;
    }
    
    
    UIWindow *outWindow = [self zoomIgnoringAreSeleniumDeltaFunnel:cupDid];
    
    
    [self performedEnableBalanceShearRetTriggers:outWindow];
    
    
    [self.orderZooming addObject:outWindow];
}

- (void)opacityHockeyRandomDrawingAdditionsKin:(NSNotification *)note {
    
    [[NSNotificationCenter defaultCenter] removeObserver:self
                                                    name:UIApplicationDidBecomeActiveNotification
                                                  object:nil];
    [self handlerNotSourceExpertShowersDayView:note.object];
}

- (void)waxMustGreenWindow {
    [self systolicConvergedMobileWhoGuideWindow];
}

- (void)systolicConvergedMobileWhoGuideWindow {
    dispatch_async(dispatch_get_main_queue(), ^{
        if (self.orderZooming.count == 0) return;

        
        UIWindow *siteWindow = [self.orderZooming lastObject];
        [self.orderZooming removeLastObject];

        
        if (siteWindow.isKeyWindow) {
            [self flashLaunchingWindow];
        }

        
        siteWindow.hidden = YES;
        
        
        for (UIView *flipHer in [siteWindow.subviews copy]) {
            [flipHer removeFromSuperview];
        }
        
        
        siteWindow.rootViewController = nil;
        
        
        [CATransaction flush];
        
        
        [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.05]];
    });
}

- (void)exponentsSpaRectangleSugarRemembersScreenViewController:(UIViewController *)rootViewController {
    dispatch_async(dispatch_get_main_queue(), ^{
        NSEnumerator *hexAdvancePreparingFatWarn = [self.orderZooming reverseObjectEnumerator];
        UIWindow *window = nil;
        
        
        while ((window = [hexAdvancePreparingFatWarn nextObject])) {
            if (window.rootViewController == rootViewController) {
                
                if (window.isKeyWindow) {
                    [self flashLaunchingWindow];
                }
                
                
                window.hidden = YES;
                
                
                for (UIView *flipHer in [window.subviews copy]) {
                    [flipHer removeFromSuperview];
                }
                
                
                window.rootViewController = nil;
                
                [self.orderZooming removeObject:window];
                
                
                [CATransaction flush];
                
                
                [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.05]];
                
                
                hexAdvancePreparingFatWarn = [self.orderZooming reverseObjectEnumerator];
            }
        }
    });
}

- (void)additionsNumbersItalianBorderWrapperMatch {
    dispatch_async(dispatch_get_main_queue(), ^{
        
        for (UIWindow *window in [self.orderZooming reverseObjectEnumerator]) {
            if (window.isKeyWindow) {
                [self flashLaunchingWindow];
            }
            window.hidden = YES;
            
            
            for (UIView *flipHer in [window.subviews copy]) {
                [flipHer removeFromSuperview];
            }
            
            
            window.rootViewController = nil;
        }
        
        
        [self.orderZooming removeAllObjects];
        
        
        [CATransaction flush];
        
        
        [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.05]];
    });
}

- (void)offFingerShearInsertRatioMultiplyExpired:(void(^)(void))completion {
    
    if (self.orderZooming.count == 0) {
        if (completion) {
            dispatch_async(dispatch_get_main_queue(), ^{
                completion();
            });
        }
        return;
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        
        NSArray *checkerEscapeCreatorStepperRepeats = [self.orderZooming copy];
        for (UIWindow *window in checkerEscapeCreatorStepperRepeats) {
            if (window.isKeyWindow) {
                [self flashLaunchingWindow];
            }
            window.hidden = YES;
            
            
            for (UIView *flipHer in [window.subviews copy]) {
                [flipHer removeFromSuperview];
            }
            
            
            window.rootViewController = nil;
        }
        
        
        [self.orderZooming removeAllObjects];
        
        
        [CATransaction flush];
        
        
        [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
        
        
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            if (completion) {
                completion();
            }
        });
    });
}


- (UIWindow *)zoomIgnoringAreSeleniumDeltaFunnel:(UIViewController *)cupDid {
    UIWindow *window = nil;
    
    
    if (@available(iOS 13.0, *)) {
        for (UIScene *scene in [UIApplication sharedApplication].connectedScenes) {
            if (scene.activationState == UISceneActivationStateForegroundActive &&
                [scene isKindOfClass:[UIWindowScene class]]) {
                window = [[UIWindow alloc] initWithWindowScene:(UIWindowScene *)scene];
                break;
            }
        }
    }
    
    
    if (!window) {
        window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    }
    
    
    window.backgroundColor = [UIColor clearColor];
    window.rootViewController = cupDid;
    return window;
}

- (void)performedEnableBalanceShearRetTriggers:(UIWindow *)window {
    

    window.windowLevel = UIWindowLevelStatusBar + 100;
    [window makeKeyAndVisible];
}


- (void)flashLaunchingWindow {
    UIWindow *postWindow = [self menServicesWindow];
    [postWindow makeKeyWindow];
    if (!postWindow.isKeyWindow) {
        [postWindow becomeKeyWindow];
    }
}

- (UIWindow *)menServicesWindow {
    __block UIWindow *postWindow = nil;
    
    
    if (@available(iOS 13.0, *)) {
        NSArray<UIWindowScene *> *affectedHour = [self additionsEmailBaseSeeCause];
        [affectedHour enumerateObjectsUsingBlock:^(UIWindowScene * _Nonnull scene, NSUInteger idx, BOOL * _Nonnull stop) {
            
            if (@available(iOS 15.0, *)) {
                postWindow = scene.keyWindow;
            }
            
            if (!postWindow) {
                postWindow = [scene.windows firstObject];
            }
            if (postWindow) *stop = YES;
        }];
    }
    
    else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
        postWindow = [UIApplication sharedApplication].keyWindow;
#pragma clang diagnostic pop
    }
    
    
    if (!postWindow) {
        postWindow = [UIApplication sharedApplication].windows.firstObject;
    }
    
    return postWindow;
}

- (NSArray<UIWindowScene *> *)additionsEmailBaseSeeCause {
    NSPredicate *predicate = [NSPredicate predicateWithBlock:^BOOL(UIScene * _Nullable scene, NSDictionary<NSString *,id> * _Nullable bindings) {
        return scene.activationState == UISceneActivationStateForegroundActive;
    }];
    return [[UIApplication sharedApplication].connectedScenes filteredSetUsingPredicate:predicate].allObjects;
}


- (UIWindow *)wetWindow {
    return [self.orderZooming lastObject];
}

- (NSInteger)mostlyCount {
    return self.orderZooming.count;
}


@end
