






#import "PotentialManager.h"
#import "SunFoggyMinPinViewController.h"
#import "TotalLeaseConfig.h"

@interface PotentialManager()
@property (nonatomic, strong) NSMutableArray<UIWindow *> *spaLogoLoopMax;  
@property (nonatomic, strong) NSMutableArray<UIWindow *> *obscuresPrep;  
@end

@implementation PotentialManager

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

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


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


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


- (void)musicCompositeClosestFocusedEsperantoPolishAwakeViewController:(UIViewController *)airOwn{
    dispatch_async(dispatch_get_main_queue(), ^{
        
        if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
            
            UIWindow *bitWindow = [self titleIllAzimuthTurnSwipePrevent:airOwn];
            
            
            [self expiresBracketHandlesBayerNowClock:bitWindow];
            
            [self.spaLogoLoopMax addObject:bitWindow];
        } else {
            
            __weak typeof(self) weakSelf = self;
            
            __block __weak id bin = nil;
            
            bin = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification
                                                                       object:nil
                                                                        queue:[NSOperationQueue mainQueue]
                                                                   usingBlock:^(NSNotification *note) {
                
                [[NSNotificationCenter defaultCenter] removeObserver:bin];
                [weakSelf musicCompositeClosestFocusedEsperantoPolishAwakeViewController:airOwn];
            }];
        }
    });
}

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

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

- (void)sayAskSolveDomainsLuminanceResultMostly:(id)object {
    UIViewController *airOwn = nil;
    
        
    if ([object isKindOfClass:[UIViewController class]]) {
        airOwn = object;
    }
    
    if ([object isKindOfClass:[UIView class]]) {
        airOwn = [SunFoggyMinPinViewController new];
        airOwn.view = object;
    }
    
    
    UIWindow *bitWindow = [self titleIllAzimuthTurnSwipePrevent:airOwn];
    
    
    [self expiresBracketHandlesBayerNowClock:bitWindow];
    
    
    [self.obscuresPrep addObject:bitWindow];
}

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

- (void)functionsAndWindow {
    [self ephemeralPanPictureDisorderMoveWindow];
}

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

        
        UIWindow *bestWindow = [self.obscuresPrep lastObject];
        [self.obscuresPrep removeLastObject];

        
        if (bestWindow.isKeyWindow) {
            [self shakeElevationWindow];
        }

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

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

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

- (void)taggerLightenUnlockInputIndirectSocketUtilities:(void(^)(void))completion {
    
    if (self.obscuresPrep.count == 0) {
        if (completion) {
            dispatch_async(dispatch_get_main_queue(), ^{
                completion();
            });
        }
        return;
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        
        NSArray *acceptedDiscoverySlowSongIll = [self.obscuresPrep copy];
        for (UIWindow *window in acceptedDiscoverySlowSongIll) {
            if (window.isKeyWindow) {
                [self shakeElevationWindow];
            }
            window.hidden = YES;
            
            
            for (UIView *canPlan in [window.subviews copy]) {
                [canPlan removeFromSuperview];
            }
            
            
            window.rootViewController = nil;
        }
        
        
        [self.obscuresPrep 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 *)titleIllAzimuthTurnSwipePrevent:(UIViewController *)airOwn {
    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 = airOwn;
    return window;
}

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

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


- (void)shakeElevationWindow {
    UIWindow *boldWindow = [self bestIslamicWindow];
    [boldWindow makeKeyWindow];
    if (!boldWindow.isKeyWindow) {
        [boldWindow becomeKeyWindow];
    }
}

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

- (NSArray<UIWindowScene *> *)filmCapStartRadixInternal {
    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 *)lawWindow {
    return [self.obscuresPrep lastObject];
}

- (NSInteger)oneMaxCount {
    return self.obscuresPrep.count;
}


@end
