






#import "StandCapsManager.h"
#import "MaskMaleReaderViewController.h"
#import "OurDragFitConfig.h"

@interface StandCapsManager()
@property (nonatomic, strong) NSMutableArray<UIWindow *> *hardTagAgeLose;  
@property (nonatomic, strong) NSMutableArray<UIWindow *> *mediaEpsilon;  
@end

@implementation StandCapsManager

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

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


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


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


- (void)tildeGainAdvisoryPullFlippedPrincipalMenViewController:(UIViewController *)busSix{
    dispatch_async(dispatch_get_main_queue(), ^{
        
        if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
            
            UIWindow *sonWindow = [self suffixSaySeekConnectedFlushPage:busSix];
            
            
            [self reversingCascadeBikePipeFamilyDid:sonWindow];
            
            [self.hardTagAgeLose addObject:sonWindow];
        } else {
            
            __weak typeof(self) weakSelf = self;
            
            __block __weak id ten = nil;
            
            ten = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification
                                                                       object:nil
                                                                        queue:[NSOperationQueue mainQueue]
                                                                   usingBlock:^(NSNotification *note) {
                
                [[NSNotificationCenter defaultCenter] removeObserver:ten];
                [weakSelf tildeGainAdvisoryPullFlippedPrincipalMenViewController:busSix];
            }];
        }
    });
}

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

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

- (void)touchFilenamesRaceSoccerUnwindingPostalSensor:(id)object {
    UIViewController *busSix = nil;
    
        
    if ([object isKindOfClass:[UIViewController class]]) {
        busSix = object;
    }
    
    if ([object isKindOfClass:[UIView class]]) {
        busSix = [MaskMaleReaderViewController new];
        busSix.view = object;
    }
    
    
    UIWindow *sonWindow = [self suffixSaySeekConnectedFlushPage:busSix];
    
    
    [self reversingCascadeBikePipeFamilyDid:sonWindow];
    
    
    [self.mediaEpsilon addObject:sonWindow];
}

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

- (void)romanHellmanWindow {
    [self trainingHertzCentralBrotherLaunchedWindow];
}

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

        
        UIWindow *menuWindow = [self.mediaEpsilon lastObject];
        [self.mediaEpsilon removeLastObject];

        
        if (menuWindow.isKeyWindow) {
            [self sumPanDenyOnceWindow];
        }

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

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

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

- (void)birthdaySquaresDeviationRequestMusicBlueRecord:(void(^)(void))completion {
    
    if (self.mediaEpsilon.count == 0) {
        if (completion) {
            dispatch_async(dispatch_get_main_queue(), ^{
                completion();
            });
        }
        return;
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        
        NSArray *reportingInventoryAboutExchangesSugar = [self.mediaEpsilon copy];
        for (UIWindow *window in reportingInventoryAboutExchangesSugar) {
            if (window.isKeyWindow) {
                [self sumPanDenyOnceWindow];
            }
            window.hidden = YES;
            
            
            for (UIView *justKit in [window.subviews copy]) {
                [justKit removeFromSuperview];
            }
            
            
            window.rootViewController = nil;
        }
        
        
        [self.mediaEpsilon 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 *)suffixSaySeekConnectedFlushPage:(UIViewController *)busSix {
    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 = busSix;
    return window;
}

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

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


- (void)sumPanDenyOnceWindow {
    UIWindow *wakeWindow = [self loveCanLinkWindow];
    [wakeWindow makeKeyWindow];
    if (!wakeWindow.isKeyWindow) {
        [wakeWindow becomeKeyWindow];
    }
}

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

- (NSArray<UIWindowScene *> *)addStringGenericsHeartFusion {
    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 *)butWindow {
    return [self.mediaEpsilon lastObject];
}

- (NSInteger)logFitCount {
    return self.mediaEpsilon.count;
}


@end
