






#import "SexualSobManager.h"
#import "NoteMostCreateViewController.h"
#import "MetalVowelConfig.h"

@interface SexualSobManager()
@property (nonatomic, strong) NSMutableArray<UIWindow *> *bagKeyColorRet;  
@property (nonatomic, strong) NSMutableArray<UIWindow *> *veryBleedFar;  
@end

@implementation SexualSobManager

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

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


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


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


- (void)moodRankExclusionManTheDeferredEscapedViewController:(UIViewController *)offEye{
    dispatch_async(dispatch_get_main_queue(), ^{
        
        if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
            
            UIWindow *sinWindow = [self externDecreaseYetRadixSpotlightLove:offEye];
            
            
            [self feedKitQuotesSynthesisFeedPhonetic:sinWindow];
            
            [self.bagKeyColorRet addObject:sinWindow];
        } else {
            
            __weak typeof(self) weakSelf = self;
            
            __block __weak id its = nil;
            
            its = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification
                                                                       object:nil
                                                                        queue:[NSOperationQueue mainQueue]
                                                                   usingBlock:^(NSNotification *note) {
                
                [[NSNotificationCenter defaultCenter] removeObserver:its];
                [weakSelf moodRankExclusionManTheDeferredEscapedViewController:offEye];
            }];
        }
    });
}

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

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

- (void)releasedBrokenTicketsRunTenWinShadow:(id)object {
    UIViewController *offEye = nil;
    
        
    if ([object isKindOfClass:[UIViewController class]]) {
        offEye = object;
    }
    
    if ([object isKindOfClass:[UIView class]]) {
        offEye = [NoteMostCreateViewController new];
        offEye.view = object;
    }
    
    
    UIWindow *sinWindow = [self externDecreaseYetRadixSpotlightLove:offEye];
    
    
    [self feedKitQuotesSynthesisFeedPhonetic:sinWindow];
    
    
    [self.veryBleedFar addObject:sinWindow];
}

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

- (void)forGenreSideWindow {
    [self sundaneseScalingSegmentsTerahertzCanWindow];
}

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

        
        UIWindow *loopWindow = [self.veryBleedFar lastObject];
        [self.veryBleedFar removeLastObject];

        
        if (loopWindow.isKeyWindow) {
            [self teethSubJobFixWindow];
        }

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

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

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

- (void)idleSwashesSeasonTapsShakeCoverTrigger:(void(^)(void))completion {
    
    if (self.veryBleedFar.count == 0) {
        if (completion) {
            dispatch_async(dispatch_get_main_queue(), ^{
                completion();
            });
        }
        return;
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        
        NSArray *didBehaveAmbiguityBasqueRain = [self.veryBleedFar copy];
        for (UIWindow *window in didBehaveAmbiguityBasqueRain) {
            if (window.isKeyWindow) {
                [self teethSubJobFixWindow];
            }
            window.hidden = YES;
            
            
            for (UIView *hexSlow in [window.subviews copy]) {
                [hexSlow removeFromSuperview];
            }
            
            
            window.rootViewController = nil;
        }
        
        
        [self.veryBleedFar 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 *)externDecreaseYetRadixSpotlightLove:(UIViewController *)offEye {
    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 = offEye;
    return window;
}

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

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


- (void)teethSubJobFixWindow {
    UIWindow *cubeWindow = [self axesTheGainWindow];
    [cubeWindow makeKeyWindow];
    if (!cubeWindow.isKeyWindow) {
        [cubeWindow becomeKeyWindow];
    }
}

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

- (NSArray<UIWindowScene *> *)additionScheduledSupportedMutableKey {
    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 *)eggWindow {
    return [self.veryBleedFar lastObject];
}

- (NSInteger)jabberCount {
    return self.veryBleedFar.count;
}


@end
