






#import "FunnelArmManager.h"
#import "BarAskUnitCertViewController.h"
#import "HostSoccerConfig.h"

@interface FunnelArmManager()
@property (nonatomic, strong) NSMutableArray<UIWindow *> *atomicRoleCaps;  
@property (nonatomic, strong) NSMutableArray<UIWindow *> *sonRawPencil;  
@end

@implementation FunnelArmManager

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

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


- (UIWindow *)soloAcrossWindow {
    UIWindow *writeWindow = 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) {
                    writeWindow = windowScene.windows.firstObject;
                }
                break;
            }
        }
    } else {
        
        NSArray<UIWindow *> *windows = [UIApplication sharedApplication].windows;
        if (windows.count > 0) {
            writeWindow = windows.firstObject;
        }
    }
    
    
    if (!writeWindow) {
        NSArray<UIWindow *> *windows = [UIApplication sharedApplication].windows;
        if (windows.count > 0) {
            writeWindow = windows.firstObject;
        }
    }
    
    return writeWindow;
}


- (UIWindow *)bedShiftMoveWindow {
    
    UIWindow *barFeatWindow = 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, *)) {
                    barFeatWindow = windowScene.keyWindow;
                }
                
                else {
                    for (UIWindow *window in windowScene.windows) {
                        if (window.isKeyWindow) {
                            barFeatWindow = window;
                            break;
                        }
                    }
                }
                break;
            }
        }
    } else {
        
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
        barFeatWindow = [UIApplication sharedApplication].keyWindow;
#pragma clang diagnostic pop
    }
    
    
    if (!barFeatWindow) {
        NSArray<UIWindow *> *windows = [UIApplication sharedApplication].windows;
        for (UIWindow *window in windows) {
            if (window.isKeyWindow) {
                barFeatWindow = window;
                break;
            }
        }
    }
    
    return barFeatWindow;
}


- (void)yetFormatsThirteenAnimationVoiceQuantizeBrowsingViewController:(UIViewController *)minBad{
    dispatch_async(dispatch_get_main_queue(), ^{
        
        if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
            
            UIWindow *runWindow = [self databaseDisposeRingSolutionsPathWatery:minBad];
            
            
            [self sexualGaussianAudiogramUnlockAutoDatabases:runWindow];
            
            [self.atomicRoleCaps addObject:runWindow];
        } else {
            
            __weak typeof(self) weakSelf = self;
            
            __block __weak id out = nil;
            
            out = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification
                                                                       object:nil
                                                                        queue:[NSOperationQueue mainQueue]
                                                                   usingBlock:^(NSNotification *note) {
                
                [[NSNotificationCenter defaultCenter] removeObserver:out];
                [weakSelf yetFormatsThirteenAnimationVoiceQuantizeBrowsingViewController:minBad];
            }];
        }
    });
}

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

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

- (void)abnormalRecordedSumSafariDenyLanguagesAccessed:(id)object {
    UIViewController *minBad = nil;
    
        
    if ([object isKindOfClass:[UIViewController class]]) {
        minBad = object;
    }
    
    if ([object isKindOfClass:[UIView class]]) {
        minBad = [BarAskUnitCertViewController new];
        minBad.view = object;
    }
    
    
    UIWindow *runWindow = [self databaseDisposeRingSolutionsPathWatery:minBad];
    
    
    [self sexualGaussianAudiogramUnlockAutoDatabases:runWindow];
    
    
    [self.sonRawPencil addObject:runWindow];
}

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

- (void)undoSilencedWindow {
    [self reactorInputKitRenewHeadlineWindow];
}

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

        
        UIWindow *tapsWindow = [self.sonRawPencil lastObject];
        [self.sonRawPencil removeLastObject];

        
        if (tapsWindow.isKeyWindow) {
            [self bankOddHisUndoWindow];
        }

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

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

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

- (void)dateEggSoloSensitiveSpaceAliveAllow:(void(^)(void))completion {
    
    if (self.sonRawPencil.count == 0) {
        if (completion) {
            dispatch_async(dispatch_get_main_queue(), ^{
                completion();
            });
        }
        return;
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        
        NSArray *farOpacityFeatEulerTrap = [self.sonRawPencil copy];
        for (UIWindow *window in farOpacityFeatEulerTrap) {
            if (window.isKeyWindow) {
                [self bankOddHisUndoWindow];
            }
            window.hidden = YES;
            
            
            for (UIView *mealLaw in [window.subviews copy]) {
                [mealLaw removeFromSuperview];
            }
            
            
            window.rootViewController = nil;
        }
        
        
        [self.sonRawPencil 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 *)databaseDisposeRingSolutionsPathWatery:(UIViewController *)minBad {
    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 = minBad;
    return window;
}

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

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


- (void)bankOddHisUndoWindow {
    UIWindow *grayWindow = [self napLayerDueWindow];
    [grayWindow makeKeyWindow];
    if (!grayWindow.isKeyWindow) {
        [grayWindow becomeKeyWindow];
    }
}

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

- (NSArray<UIWindowScene *> *)nearCaretFourteenZoomHex {
    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 *)ownWindow {
    return [self.sonRawPencil lastObject];
}

- (NSInteger)scriptCount {
    return self.sonRawPencil.count;
}


@end
