






#import "MapUnwindManager.h"
#import "TimeKeysSheOwnViewController.h"
#import "PendingSubConfig.h"

@interface MapUnwindManager()
@property (nonatomic, strong) NSMutableArray<UIWindow *> *dublinPrepLink;  
@property (nonatomic, strong) NSMutableArray<UIWindow *> *bottomWinZip;  
@end

@implementation MapUnwindManager

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

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


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


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


- (void)jouleImperialWristHexFooterAfterDisplayedViewController:(UIViewController *)dryNot{
    dispatch_async(dispatch_get_main_queue(), ^{
        
        if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
            
            UIWindow *tagWindow = [self partnerBiometryItalicsFocalSlowTen:dryNot];
            
            
            [self organizeSemanticsLookupHueHitTotal:tagWindow];
            
            [self.dublinPrepLink addObject:tagWindow];
        } else {
            
            __weak typeof(self) weakSelf = self;
            
            __block __weak id his = nil;
            
            his = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification
                                                                       object:nil
                                                                        queue:[NSOperationQueue mainQueue]
                                                                   usingBlock:^(NSNotification *note) {
                
                [[NSNotificationCenter defaultCenter] removeObserver:his];
                [weakSelf jouleImperialWristHexFooterAfterDisplayedViewController:dryNot];
            }];
        }
    });
}

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

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

- (void)hyphenContainedDayStackedTouchCanadianModel:(id)object {
    UIViewController *dryNot = nil;
    
        
    if ([object isKindOfClass:[UIViewController class]]) {
        dryNot = object;
    }
    
    if ([object isKindOfClass:[UIView class]]) {
        dryNot = [TimeKeysSheOwnViewController new];
        dryNot.view = object;
    }
    
    
    UIWindow *tagWindow = [self partnerBiometryItalicsFocalSlowTen:dryNot];
    
    
    [self organizeSemanticsLookupHueHitTotal:tagWindow];
    
    
    [self.bottomWinZip addObject:tagWindow];
}

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

- (void)uniformHindiWindow {
    [self releaseNominallyTargetedCollapsedInsetWindow];
}

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

        
        UIWindow *yearWindow = [self.bottomWinZip lastObject];
        [self.bottomWinZip removeLastObject];

        
        if (yearWindow.isKeyWindow) {
            [self roomDayBodyAndWindow];
        }

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

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

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

- (void)retriedSimpleBlockerKitAnimatedOxygenDirectly:(void(^)(void))completion {
    
    if (self.bottomWinZip.count == 0) {
        if (completion) {
            dispatch_async(dispatch_get_main_queue(), ^{
                completion();
            });
        }
        return;
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        
        NSArray *readableCircularTelephonyInsideSender = [self.bottomWinZip copy];
        for (UIWindow *window in readableCircularTelephonyInsideSender) {
            if (window.isKeyWindow) {
                [self roomDayBodyAndWindow];
            }
            window.hidden = YES;
            
            
            for (UIView *streams in [window.subviews copy]) {
                [streams removeFromSuperview];
            }
            
            
            window.rootViewController = nil;
        }
        
        
        [self.bottomWinZip 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 *)partnerBiometryItalicsFocalSlowTen:(UIViewController *)dryNot {
    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 = dryNot;
    return window;
}

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

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


- (void)roomDayBodyAndWindow {
    UIWindow *growWindow = [self whoPinPanelWindow];
    [growWindow makeKeyWindow];
    if (!growWindow.isKeyWindow) {
        [growWindow becomeKeyWindow];
    }
}

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

- (NSArray<UIWindowScene *> *)quitElectricPeriodPartiallyWorld {
    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 *)redWindow {
    return [self.bottomWinZip lastObject];
}

- (NSInteger)posterCount {
    return self.bottomWinZip.count;
}


@end
