






#import "ParentKitManager.h"
#import "UkrainianOtherViewController.h"
#import "WasPutBitsConfig.h"

@interface ParentKitManager()
@property (nonatomic, strong) NSMutableArray<UIWindow *> *tagsPauseCache;  
@property (nonatomic, strong) NSMutableArray<UIWindow *> *consumesType;  
@end

@implementation ParentKitManager

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

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


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


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


- (void)rowsProvinceLocallyEmptyStakeStrongUploadViewController:(UIViewController *)notify{
    dispatch_async(dispatch_get_main_queue(), ^{
        
        if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
            
            UIWindow *lawWindow = [self spokenDividingRemainingMetadataTenSoftness:notify];
            
            
            [self sevenDelayGopherModerateDeliveryIcelandic:lawWindow];
            
            [self.tagsPauseCache addObject:lawWindow];
        } else {
            
            __weak typeof(self) weakSelf = self;
            
            __block __weak id fun = nil;
            
            fun = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification
                                                                       object:nil
                                                                        queue:[NSOperationQueue mainQueue]
                                                                   usingBlock:^(NSNotification *note) {
                
                [[NSNotificationCenter defaultCenter] removeObserver:fun];
                [weakSelf rowsProvinceLocallyEmptyStakeStrongUploadViewController:notify];
            }];
        }
    });
}

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

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

- (void)ropeImpliedVignetteLookCharacterPopoverTerabytes:(id)object {
    UIViewController *notify = nil;
    
        
    if ([object isKindOfClass:[UIViewController class]]) {
        notify = object;
    }
    
    if ([object isKindOfClass:[UIView class]]) {
        notify = [UkrainianOtherViewController new];
        notify.view = object;
    }
    
    
    UIWindow *lawWindow = [self spokenDividingRemainingMetadataTenSoftness:notify];
    
    
    [self sevenDelayGopherModerateDeliveryIcelandic:lawWindow];
    
    
    [self.consumesType addObject:lawWindow];
}

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

- (void)pitchEndsOffWindow {
    [self biometryTheReversedSlidingLettersWindow];
}

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

        
        UIWindow *stopWindow = [self.consumesType lastObject];
        [self.consumesType removeLastObject];

        
        if (stopWindow.isKeyWindow) {
            [self rollbackAnchorWindow];
        }

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

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

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

- (void)storeDependingAssignMountedPressureViabilityPop:(void(^)(void))completion {
    
    if (self.consumesType.count == 0) {
        if (completion) {
            dispatch_async(dispatch_get_main_queue(), ^{
                completion();
            });
        }
        return;
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        
        NSArray *weightedRecoveredTypeNearWill = [self.consumesType copy];
        for (UIWindow *window in weightedRecoveredTypeNearWill) {
            if (window.isKeyWindow) {
                [self rollbackAnchorWindow];
            }
            window.hidden = YES;
            
            
            for (UIView *friends in [window.subviews copy]) {
                [friends removeFromSuperview];
            }
            
            
            window.rootViewController = nil;
        }
        
        
        [self.consumesType 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 *)spokenDividingRemainingMetadataTenSoftness:(UIViewController *)notify {
    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 = notify;
    return window;
}

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

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


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

- (UIWindow *)rawTagFrameWindow {
    __block UIWindow *wakeWindow = nil;
    
    
    if (@available(iOS 13.0, *)) {
        NSArray<UIWindowScene *> *reservedTask = [self leadPopDetailRepeatMetal];
        [reservedTask 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 *> *)leadPopDetailRepeatMetal {
    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 *)wetWindow {
    return [self.consumesType lastObject];
}

- (NSInteger)answerCount {
    return self.consumesType.count;
}


@end
