






#import "TeaspoonsManager.h"
#import "MakerOverTokenViewController.h"
#import "BringEvictConfig.h"

@interface TeaspoonsManager()
@property (nonatomic, strong) NSMutableArray<UIWindow *> *onceOptWaxBook;  
@property (nonatomic, strong) NSMutableArray<UIWindow *> *altimeterSin;  
@end

@implementation TeaspoonsManager

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

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


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


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


- (void)suffixMoleTrapSignDescendWeekFitnessViewController:(UIViewController *)hueSon{
    dispatch_async(dispatch_get_main_queue(), ^{
        
        if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
            
            UIWindow *mixWindow = [self quantityCheckSpecifiedDefinesLatvianBus:hueSon];
            
            
            [self tryVectorCanonicalWordEnhancedFavorites:mixWindow];
            
            [self.onceOptWaxBook addObject:mixWindow];
        } 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 suffixMoleTrapSignDescendWeekFitnessViewController:hueSon];
            }];
        }
    });
}

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

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

- (void)drivenMakeCheckedOcclusionCheckCalendarBasque:(id)object {
    UIViewController *hueSon = nil;
    
        
    if ([object isKindOfClass:[UIViewController class]]) {
        hueSon = object;
    }
    
    if ([object isKindOfClass:[UIView class]]) {
        hueSon = [MakerOverTokenViewController new];
        hueSon.view = object;
    }
    
    
    UIWindow *mixWindow = [self quantityCheckSpecifiedDefinesLatvianBus:hueSon];
    
    
    [self tryVectorCanonicalWordEnhancedFavorites:mixWindow];
    
    
    [self.altimeterSin addObject:mixWindow];
}

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

- (void)cupMainStoreWindow {
    [self shadowSpaSaltDefineWayWindow];
}

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

        
        UIWindow *wireWindow = [self.altimeterSin lastObject];
        [self.altimeterSin removeLastObject];

        
        if (wireWindow.isKeyWindow) {
            [self reuseBroadcastWindow];
        }

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

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

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

- (void)ouncesFinalizeGrantedHoursPongStylusBelow:(void(^)(void))completion {
    
    if (self.altimeterSin.count == 0) {
        if (completion) {
            dispatch_async(dispatch_get_main_queue(), ^{
                completion();
            });
        }
        return;
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        
        NSArray *thousandBetterElapsedVitalTwo = [self.altimeterSin copy];
        for (UIWindow *window in thousandBetterElapsedVitalTwo) {
            if (window.isKeyWindow) {
                [self reuseBroadcastWindow];
            }
            window.hidden = YES;
            
            
            for (UIView *atomWax in [window.subviews copy]) {
                [atomWax removeFromSuperview];
            }
            
            
            window.rootViewController = nil;
        }
        
        
        [self.altimeterSin 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 *)quantityCheckSpecifiedDefinesLatvianBus:(UIViewController *)hueSon {
    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 = hueSon;
    return window;
}

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

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


- (void)reuseBroadcastWindow {
    UIWindow *mileWindow = [self knowDisableWindow];
    [mileWindow makeKeyWindow];
    if (!mileWindow.isKeyWindow) {
        [mileWindow becomeKeyWindow];
    }
}

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

- (NSArray<UIWindowScene *> *)boundingPrivilegeVerticalMusicalExtends {
    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 *)eraWindow {
    return [self.altimeterSin lastObject];
}

- (NSInteger)dublinCount {
    return self.altimeterSin.count;
}


@end
