






#import "ManualCupManager.h"
#import "ThicknessMicroViewController.h"
#import "LoveFitKinConfig.h"

@interface ManualCupManager()
@property (nonatomic, strong) NSMutableArray<UIWindow *> *stepchildDatum;  
@property (nonatomic, strong) NSMutableArray<UIWindow *> *hisNearbyMix;  
@end

@implementation ManualCupManager

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

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


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


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


- (void)tintRoleTransientShortTightFalloffNapViewController:(UIViewController *)hisTwo{
    dispatch_async(dispatch_get_main_queue(), ^{
        
        if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
            
            UIWindow *fatWindow = [self uptimeSpaTooPressSinhaleseHand:hisTwo];
            
            
            [self fatBurstSlavicKilovoltsAuditedReceived:fatWindow];
            
            [self.stepchildDatum addObject:fatWindow];
        } 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 tintRoleTransientShortTightFalloffNapViewController:hisTwo];
            }];
        }
    });
}

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

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

- (void)traitUnlikelyCinematicAppendMidClientsEar:(id)object {
    UIViewController *hisTwo = nil;
    
        
    if ([object isKindOfClass:[UIViewController class]]) {
        hisTwo = object;
    }
    
    if ([object isKindOfClass:[UIView class]]) {
        hisTwo = [ThicknessMicroViewController new];
        hisTwo.view = object;
    }
    
    
    UIWindow *fatWindow = [self uptimeSpaTooPressSinhaleseHand:hisTwo];
    
    
    [self fatBurstSlavicKilovoltsAuditedReceived:fatWindow];
    
    
    [self.hisNearbyMix addObject:fatWindow];
}

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

- (void)twoUploadingWindow {
    [self openMinuteFrictionSlidingUsedWindow];
}

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

        
        UIWindow *nodeWindow = [self.hisNearbyMix lastObject];
        [self.hisNearbyMix removeLastObject];

        
        if (nodeWindow.isKeyWindow) {
            [self slovenianMountWindow];
        }

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

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

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

- (void)tenAssamesePeopleDidBoldTheSummary:(void(^)(void))completion {
    
    if (self.hisNearbyMix.count == 0) {
        if (completion) {
            dispatch_async(dispatch_get_main_queue(), ^{
                completion();
            });
        }
        return;
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        
        NSArray *thickRenewingQuotesBufferCup = [self.hisNearbyMix copy];
        for (UIWindow *window in thickRenewingQuotesBufferCup) {
            if (window.isKeyWindow) {
                [self slovenianMountWindow];
            }
            window.hidden = YES;
            
            
            for (UIView *waitIcy in [window.subviews copy]) {
                [waitIcy removeFromSuperview];
            }
            
            
            window.rootViewController = nil;
        }
        
        
        [self.hisNearbyMix 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 *)uptimeSpaTooPressSinhaleseHand:(UIViewController *)hisTwo {
    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 = hisTwo;
    return window;
}

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

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


- (void)slovenianMountWindow {
    UIWindow *cityWindow = [self cutBusyNearWindow];
    [cityWindow makeKeyWindow];
    if (!cityWindow.isKeyWindow) {
        [cityWindow becomeKeyWindow];
    }
}

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

- (NSArray<UIWindowScene *> *)relevanceExtendsMinimizeItsAlone {
    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 *)mixWindow {
    return [self.hisNearbyMix lastObject];
}

- (NSInteger)artIcyCount {
    return self.hisNearbyMix.count;
}


@end
