






#import "FrequencyManager.h"
#import "BarBagBusMakerViewController.h"
#import "ArmpitMathConfig.h"

@interface FrequencyManager()
@property (nonatomic, strong) NSMutableArray<UIWindow *> *findCarEasyMen;  
@property (nonatomic, strong) NSMutableArray<UIWindow *> *mapStayGiven;  
@end

@implementation FrequencyManager

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

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


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


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


- (void)runStreamedGeneratorRecursiveMegawattsStepperLineViewController:(UIViewController *)kinCar{
    dispatch_async(dispatch_get_main_queue(), ^{
        
        if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
            
            UIWindow *kinWindow = [self descendGeneratorAudioAdjustingPromotionCounting:kinCar];
            
            
            [self trademarkJustPoliciesSpeakLuminanceSparse:kinWindow];
            
            [self.findCarEasyMen addObject:kinWindow];
        } else {
            
            __weak typeof(self) weakSelf = self;
            
            __block __weak id spa = nil;
            
            spa = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification
                                                                       object:nil
                                                                        queue:[NSOperationQueue mainQueue]
                                                                   usingBlock:^(NSNotification *note) {
                
                [[NSNotificationCenter defaultCenter] removeObserver:spa];
                [weakSelf runStreamedGeneratorRecursiveMegawattsStepperLineViewController:kinCar];
            }];
        }
    });
}

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

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

- (void)solidAccessoryFastestReferentNetworkSpaceBox:(id)object {
    UIViewController *kinCar = nil;
    
        
    if ([object isKindOfClass:[UIViewController class]]) {
        kinCar = object;
    }
    
    if ([object isKindOfClass:[UIView class]]) {
        kinCar = [BarBagBusMakerViewController new];
        kinCar.view = object;
    }
    
    
    UIWindow *kinWindow = [self descendGeneratorAudioAdjustingPromotionCounting:kinCar];
    
    
    [self trademarkJustPoliciesSpeakLuminanceSparse:kinWindow];
    
    
    [self.mapStayGiven addObject:kinWindow];
}

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

- (void)sessionModalWindow {
    [self sawAssertionMediumBalticImportantWindow];
}

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

        
        UIWindow *poloWindow = [self.mapStayGiven lastObject];
        [self.mapStayGiven removeLastObject];

        
        if (poloWindow.isKeyWindow) {
            [self fontStripAssetWindow];
        }

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

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

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

- (void)learnCoachedUtteranceMoveFathomsNearHue:(void(^)(void))completion {
    
    if (self.mapStayGiven.count == 0) {
        if (completion) {
            dispatch_async(dispatch_get_main_queue(), ^{
                completion();
            });
        }
        return;
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        
        NSArray *latitudeReachablePickExceedsNorth = [self.mapStayGiven copy];
        for (UIWindow *window in latitudeReachablePickExceedsNorth) {
            if (window.isKeyWindow) {
                [self fontStripAssetWindow];
            }
            window.hidden = YES;
            
            
            for (UIView *downHex in [window.subviews copy]) {
                [downHex removeFromSuperview];
            }
            
            
            window.rootViewController = nil;
        }
        
        
        [self.mapStayGiven 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 *)descendGeneratorAudioAdjustingPromotionCounting:(UIViewController *)kinCar {
    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 = kinCar;
    return window;
}

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

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


- (void)fontStripAssetWindow {
    UIWindow *safeWindow = [self slowSawRopeWindow];
    [safeWindow makeKeyWindow];
    if (!safeWindow.isKeyWindow) {
        [safeWindow becomeKeyWindow];
    }
}

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

- (NSArray<UIWindowScene *> *)resolvingBasqueFitExistentFlight {
    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 *)sunWindow {
    return [self.mapStayGiven lastObject];
}

- (NSInteger)eyeOffCount {
    return self.mapStayGiven.count;
}


@end
