






#import "RingMiterManager.h"
#import "MergeStatementViewController.h"
#import "MidArePlusConfig.h"

@interface RingMiterManager()
@property (nonatomic, strong) NSMutableArray<UIWindow *> *sindhiSoloPrep;  
@property (nonatomic, strong) NSMutableArray<UIWindow *> *tapBarCreamy;  
@end

@implementation RingMiterManager

- (instancetype)init {
    self = [super init];
    if (self) {
        _sindhiSoloPrep = [NSMutableArray array];
        _tapBarCreamy = [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 *)fitCanGrayWindow {
    UIWindow *modelWindow = 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) {
                    modelWindow = windowScene.windows.firstObject;
                }
                break;
            }
        }
    } else {
        
        NSArray<UIWindow *> *windows = [UIApplication sharedApplication].windows;
        if (windows.count > 0) {
            modelWindow = windows.firstObject;
        }
    }
    
    
    if (!modelWindow) {
        NSArray<UIWindow *> *windows = [UIApplication sharedApplication].windows;
        if (windows.count > 0) {
            modelWindow = windows.firstObject;
        }
    }
    
    return modelWindow;
}


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


- (void)shutdownMillibarsRectumRowsAddressesSeedConnectViewController:(UIViewController *)notAnd{
    dispatch_async(dispatch_get_main_queue(), ^{
        
        if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
            
            UIWindow *wetWindow = [self hyphenPintAllergyPoloForceNecessary:notAnd];
            
            
            [self toolEscapesInitiallyIncomingGuestCutter:wetWindow];
            
            [self.sindhiSoloPrep addObject:wetWindow];
        } 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 shutdownMillibarsRectumRowsAddressesSeedConnectViewController:notAnd];
            }];
        }
    });
}

- (void)diphthongOldLazyTruncatedRevertingBeganViewController:(UIViewController *)notAnd {
    dispatch_async(dispatch_get_main_queue(), ^{
        if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
            [self markupElementsSeventeenModerateReceivingInsetPink:notAnd];
        } 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 markupElementsSeventeenModerateReceivingInsetPink:notAnd];
            }];
        }
    });
}

- (void)directlyBarriersAdjustingDerivedGramRequiringView:(UIView *)view {
    dispatch_async(dispatch_get_main_queue(), ^{
        if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
            [self markupElementsSeventeenModerateReceivingInsetPink: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 markupElementsSeventeenModerateReceivingInsetPink:view];
            }];
        }
    });
}

- (void)markupElementsSeventeenModerateReceivingInsetPink:(id)object {
    UIViewController *notAnd = nil;
    
        
    if ([object isKindOfClass:[UIViewController class]]) {
        notAnd = object;
    }
    
    if ([object isKindOfClass:[UIView class]]) {
        notAnd = [MergeStatementViewController new];
        notAnd.view = object;
    }
    
    
    UIWindow *wetWindow = [self hyphenPintAllergyPoloForceNecessary:notAnd];
    
    
    [self toolEscapesInitiallyIncomingGuestCutter:wetWindow];
    
    
    [self.tapBarCreamy addObject:wetWindow];
}

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

- (void)imperialLostWindow {
    [self clickedSleetRotatePermuteMapWindow];
}

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

        
        UIWindow *dustWindow = [self.tapBarCreamy lastObject];
        [self.tapBarCreamy removeLastObject];

        
        if (dustWindow.isKeyWindow) {
            [self inheritedSceneWindow];
        }

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

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

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

- (void)anotherSpotlightOnceCoercionWetPlaneUse:(void(^)(void))completion {
    
    if (self.tapBarCreamy.count == 0) {
        if (completion) {
            dispatch_async(dispatch_get_main_queue(), ^{
                completion();
            });
        }
        return;
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        
        NSArray *scalarCollapsesRunWinStore = [self.tapBarCreamy copy];
        for (UIWindow *window in scalarCollapsesRunWinStore) {
            if (window.isKeyWindow) {
                [self inheritedSceneWindow];
            }
            window.hidden = YES;
            
            
            for (UIView *yiddish in [window.subviews copy]) {
                [yiddish removeFromSuperview];
            }
            
            
            window.rootViewController = nil;
        }
        
        
        [self.tapBarCreamy 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 *)hyphenPintAllergyPoloForceNecessary:(UIViewController *)notAnd {
    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 = notAnd;
    return window;
}

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

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


- (void)inheritedSceneWindow {
    UIWindow *fontWindow = [self boxDaysRealWindow];
    [fontWindow makeKeyWindow];
    if (!fontWindow.isKeyWindow) {
        [fontWindow becomeKeyWindow];
    }
}

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

- (NSArray<UIWindowScene *> *)securitySourcesComponentLanguageRanked {
    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 *)sheWindow {
    return [self.tapBarCreamy lastObject];
}

- (NSInteger)authorCount {
    return self.tapBarCreamy.count;
}


@end
