






#import "WasFillerManager.h"
#import "AvailBringLoveViewController.h"
#import "GetTagSuchConfig.h"

@interface WasFillerManager()
@property (nonatomic, strong) NSMutableArray<UIWindow *> *freeUpdatePace;  
@property (nonatomic, strong) NSMutableArray<UIWindow *> *catFetchPrep;  
@end

@implementation WasFillerManager

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

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


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


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


- (void)ovulationWasPotassiumVersionsCatBleedTradViewController:(UIViewController *)tipIts{
    dispatch_async(dispatch_get_main_queue(), ^{
        
        if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
            
            UIWindow *hitWindow = [self atomInitiatedStreamYearsTextualIntrinsic:tipIts];
            
            
            [self dynamicEnclosingDurationForkRemembersHour:hitWindow];
            
            [self.freeUpdatePace addObject:hitWindow];
        } else {
            
            __weak typeof(self) weakSelf = self;
            
            __block __weak id six = nil;
            
            six = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification
                                                                       object:nil
                                                                        queue:[NSOperationQueue mainQueue]
                                                                   usingBlock:^(NSNotification *note) {
                
                [[NSNotificationCenter defaultCenter] removeObserver:six];
                [weakSelf ovulationWasPotassiumVersionsCatBleedTradViewController:tipIts];
            }];
        }
    });
}

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

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

- (void)wrappedUseClimbingCostShareMeasuredRare:(id)object {
    UIViewController *tipIts = nil;
    
        
    if ([object isKindOfClass:[UIViewController class]]) {
        tipIts = object;
    }
    
    if ([object isKindOfClass:[UIView class]]) {
        tipIts = [AvailBringLoveViewController new];
        tipIts.view = object;
    }
    
    
    UIWindow *hitWindow = [self atomInitiatedStreamYearsTextualIntrinsic:tipIts];
    
    
    [self dynamicEnclosingDurationForkRemembersHour:hitWindow];
    
    
    [self.catFetchPrep addObject:hitWindow];
}

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

- (void)saltTrailingWindow {
    [self seasonBuffersBufferingCancelledMatchWindow];
}

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

        
        UIWindow *readWindow = [self.catFetchPrep lastObject];
        [self.catFetchPrep removeLastObject];

        
        if (readWindow.isKeyWindow) {
            [self kindIdleResumeWindow];
        }

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

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

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

- (void)chainTipSpanPathTerminateDeltaAnswer:(void(^)(void))completion {
    
    if (self.catFetchPrep.count == 0) {
        if (completion) {
            dispatch_async(dispatch_get_main_queue(), ^{
                completion();
            });
        }
        return;
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        
        NSArray *fileContainedWireExtraPublic = [self.catFetchPrep copy];
        for (UIWindow *window in fileContainedWireExtraPublic) {
            if (window.isKeyWindow) {
                [self kindIdleResumeWindow];
            }
            window.hidden = YES;
            
            
            for (UIView *safeEar in [window.subviews copy]) {
                [safeEar removeFromSuperview];
            }
            
            
            window.rootViewController = nil;
        }
        
        
        [self.catFetchPrep 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 *)atomInitiatedStreamYearsTextualIntrinsic:(UIViewController *)tipIts {
    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 = tipIts;
    return window;
}

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

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


- (void)kindIdleResumeWindow {
    UIWindow *restWindow = [self scalingLiveWindow];
    [restWindow makeKeyWindow];
    if (!restWindow.isKeyWindow) {
        [restWindow becomeKeyWindow];
    }
}

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

- (NSArray<UIWindowScene *> *)copperEngravedHandlerHellmanWriting {
    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 *)tapWindow {
    return [self.catFetchPrep lastObject];
}

- (NSInteger)wasFixCount {
    return self.catFetchPrep.count;
}


@end
