






#import "MatchMenuManager.h"
#import "ResizeCapturedViewController.h"
#import "IllNumbersConfig.h"

@interface MatchMenuManager()
@property (nonatomic, strong) NSMutableArray<UIWindow *> *stretchSliding;  
@property (nonatomic, strong) NSMutableArray<UIWindow *> *tightUsesFix;  
@end

@implementation MatchMenuManager

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

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


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


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


- (void)sandboxOperandMajorBlinkBeganEligibleNowViewController:(UIViewController *)single{
    dispatch_async(dispatch_get_main_queue(), ^{
        
        if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
            
            UIWindow *dayWindow = [self spanDenyPairListMenuDownloads:single];
            
            
            [self connectedElevationSecurelySourcesProductsMid:dayWindow];
            
            [self.stretchSliding addObject:dayWindow];
        } else {
            
            __weak typeof(self) weakSelf = self;
            
            __block __weak id odd = nil;
            
            odd = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification
                                                                       object:nil
                                                                        queue:[NSOperationQueue mainQueue]
                                                                   usingBlock:^(NSNotification *note) {
                
                [[NSNotificationCenter defaultCenter] removeObserver:odd];
                [weakSelf sandboxOperandMajorBlinkBeganEligibleNowViewController:single];
            }];
        }
    });
}

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

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

- (void)keyAccountsOverallPositionLiftNormalStood:(id)object {
    UIViewController *single = nil;
    
        
    if ([object isKindOfClass:[UIViewController class]]) {
        single = object;
    }
    
    if ([object isKindOfClass:[UIView class]]) {
        single = [ResizeCapturedViewController new];
        single.view = object;
    }
    
    
    UIWindow *dayWindow = [self spanDenyPairListMenuDownloads:single];
    
    
    [self connectedElevationSecurelySourcesProductsMid:dayWindow];
    
    
    [self.tightUsesFix addObject:dayWindow];
}

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

- (void)sunRenderHueWindow {
    [self beaconsAndHerMandatoryIncomingWindow];
}

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

        
        UIWindow *certWindow = [self.tightUsesFix lastObject];
        [self.tightUsesFix removeLastObject];

        
        if (certWindow.isKeyWindow) {
            [self inviteWrappersWindow];
        }

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

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

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

- (void)specifierDifferentNotifiedLigaturesSheIronPlanar:(void(^)(void))completion {
    
    if (self.tightUsesFix.count == 0) {
        if (completion) {
            dispatch_async(dispatch_get_main_queue(), ^{
                completion();
            });
        }
        return;
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        
        NSArray *speakersStandardEnhanceFormMinder = [self.tightUsesFix copy];
        for (UIWindow *window in speakersStandardEnhanceFormMinder) {
            if (window.isKeyWindow) {
                [self inviteWrappersWindow];
            }
            window.hidden = YES;
            
            
            for (UIView *corrupt in [window.subviews copy]) {
                [corrupt removeFromSuperview];
            }
            
            
            window.rootViewController = nil;
        }
        
        
        [self.tightUsesFix 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 *)spanDenyPairListMenuDownloads:(UIViewController *)single {
    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 = single;
    return window;
}

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

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


- (void)inviteWrappersWindow {
    UIWindow *pingWindow = [self retryActionWindow];
    [pingWindow makeKeyWindow];
    if (!pingWindow.isKeyWindow) {
        [pingWindow becomeKeyWindow];
    }
}

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

- (NSArray<UIWindowScene *> *)digitizedIndexedIntervalsDaysFront {
    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 *)sinWindow {
    return [self.tightUsesFix lastObject];
}

- (NSInteger)mapFarCount {
    return self.tightUsesFix.count;
}


@end
