






#import "PredicateManager.h"
#import "BestZipSexTrapViewController.h"
#import "SoloCutterConfig.h"

@interface PredicateManager()
@property (nonatomic, strong) NSMutableArray<UIWindow *> *offsetIncludes;  
@property (nonatomic, strong) NSMutableArray<UIWindow *> *tabExtraWait;  
@end

@implementation PredicateManager

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

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


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


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


- (void)kernelsChineseResultPrivacyPredicatePathOxygenViewController:(UIViewController *)twelve{
    dispatch_async(dispatch_get_main_queue(), ^{
        
        if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
            
            UIWindow *endWindow = [self highPrefixedMetalThirteenMagnesiumAdd:twelve];
            
            
            [self ourTreeLawRemoteHowUnit:endWindow];
            
            [self.offsetIncludes addObject:endWindow];
        } else {
            
            __weak typeof(self) weakSelf = self;
            
            __block __weak id won = nil;
            
            won = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification
                                                                       object:nil
                                                                        queue:[NSOperationQueue mainQueue]
                                                                   usingBlock:^(NSNotification *note) {
                
                [[NSNotificationCenter defaultCenter] removeObserver:won];
                [weakSelf kernelsChineseResultPrivacyPredicatePathOxygenViewController:twelve];
            }];
        }
    });
}

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

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

- (void)embeddedDevicesSpeakAgreementLexiconExistSeconds:(id)object {
    UIViewController *twelve = nil;
    
        
    if ([object isKindOfClass:[UIViewController class]]) {
        twelve = object;
    }
    
    if ([object isKindOfClass:[UIView class]]) {
        twelve = [BestZipSexTrapViewController new];
        twelve.view = object;
    }
    
    
    UIWindow *endWindow = [self highPrefixedMetalThirteenMagnesiumAdd:twelve];
    
    
    [self ourTreeLawRemoteHowUnit:endWindow];
    
    
    [self.tabExtraWait addObject:endWindow];
}

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

- (void)pongDutchCutWindow {
    [self romanMotionRingHoldSixteenWindow];
}

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

        
        UIWindow *moveWindow = [self.tabExtraWait lastObject];
        [self.tabExtraWait removeLastObject];

        
        if (moveWindow.isKeyWindow) {
            [self sonOutRollZoneWindow];
        }

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

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

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

- (void)signerDisableWinClickedClimbedIntensityThe:(void(^)(void))completion {
    
    if (self.tabExtraWait.count == 0) {
        if (completion) {
            dispatch_async(dispatch_get_main_queue(), ^{
                completion();
            });
        }
        return;
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        
        NSArray *restoringValidityExporterSlabGuest = [self.tabExtraWait copy];
        for (UIWindow *window in restoringValidityExporterSlabGuest) {
            if (window.isKeyWindow) {
                [self sonOutRollZoneWindow];
            }
            window.hidden = YES;
            
            
            for (UIView *tryEasy in [window.subviews copy]) {
                [tryEasy removeFromSuperview];
            }
            
            
            window.rootViewController = nil;
        }
        
        
        [self.tabExtraWait 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 *)highPrefixedMetalThirteenMagnesiumAdd:(UIViewController *)twelve {
    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 = twelve;
    return window;
}

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

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


- (void)sonOutRollZoneWindow {
    UIWindow *beenWindow = [self infoUseDiskWindow];
    [beenWindow makeKeyWindow];
    if (!beenWindow.isKeyWindow) {
        [beenWindow becomeKeyWindow];
    }
}

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

- (NSArray<UIWindowScene *> *)absentReachableFinishingScheduledDublin {
    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 *)tipWindow {
    return [self.tabExtraWait lastObject];
}

- (NSInteger)eyeMapCount {
    return self.tabExtraWait.count;
}


@end
