






#import "FeedSerifManager.h"
#import "NowPenSonAxialViewController.h"
#import "OurFastestConfig.h"

@interface FeedSerifManager()
@property (nonatomic, strong) NSMutableArray<UIWindow *> *sinShiftSinSix;  
@property (nonatomic, strong) NSMutableArray<UIWindow *> *stoodLenient;  
@end

@implementation FeedSerifManager

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

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


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


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


- (void)dayTheDayYearPresetHindiIndexViewController:(UIViewController *)torque{
    dispatch_async(dispatch_get_main_queue(), ^{
        
        if ([UIApplication sharedApplication].applicationState == UIApplicationStateActive) {
            
            UIWindow *wasWindow = [self succeededGivenTwentyClearedPutSlovenian:torque];
            
            
            [self messageTicketsConsumedLearnEstonianBuffering:wasWindow];
            
            [self.sinShiftSinSix addObject:wasWindow];
        } else {
            
            __weak typeof(self) weakSelf = self;
            
            __block __weak id tap = nil;
            
            tap = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidBecomeActiveNotification
                                                                       object:nil
                                                                        queue:[NSOperationQueue mainQueue]
                                                                   usingBlock:^(NSNotification *note) {
                
                [[NSNotificationCenter defaultCenter] removeObserver:tap];
                [weakSelf dayTheDayYearPresetHindiIndexViewController:torque];
            }];
        }
    });
}

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

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

- (void)quickWeightedHitAskTooMagneticBasic:(id)object {
    UIViewController *torque = nil;
    
        
    if ([object isKindOfClass:[UIViewController class]]) {
        torque = object;
    }
    
    if ([object isKindOfClass:[UIView class]]) {
        torque = [NowPenSonAxialViewController new];
        torque.view = object;
    }
    
    
    UIWindow *wasWindow = [self succeededGivenTwentyClearedPutSlovenian:torque];
    
    
    [self messageTicketsConsumedLearnEstonianBuffering:wasWindow];
    
    
    [self.stoodLenient addObject:wasWindow];
}

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

- (void)eightDidSoloWindow {
    [self gaspPedometerCinematicMirroredSmoothedWindow];
}

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

        
        UIWindow *flagWindow = [self.stoodLenient lastObject];
        [self.stoodLenient removeLastObject];

        
        if (flagWindow.isKeyWindow) {
            [self pickHardTheMidWindow];
        }

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

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

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

- (void)publicTabularFireActualDraftSwimmingAlong:(void(^)(void))completion {
    
    if (self.stoodLenient.count == 0) {
        if (completion) {
            dispatch_async(dispatch_get_main_queue(), ^{
                completion();
            });
        }
        return;
    }
    
    
    dispatch_async(dispatch_get_main_queue(), ^{
        
        NSArray *rearDoneDesiredWorldLease = [self.stoodLenient copy];
        for (UIWindow *window in rearDoneDesiredWorldLease) {
            if (window.isKeyWindow) {
                [self pickHardTheMidWindow];
            }
            window.hidden = YES;
            
            
            for (UIView *roomPin in [window.subviews copy]) {
                [roomPin removeFromSuperview];
            }
            
            
            window.rootViewController = nil;
        }
        
        
        [self.stoodLenient 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 *)succeededGivenTwentyClearedPutSlovenian:(UIViewController *)torque {
    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 = torque;
    return window;
}

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

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


- (void)pickHardTheMidWindow {
    UIWindow *wireWindow = [self triggerCapsWindow];
    [wireWindow makeKeyWindow];
    if (!wireWindow.isKeyWindow) {
        [wireWindow becomeKeyWindow];
    }
}

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

- (NSArray<UIWindowScene *> *)canonHandDisposeBulgarianDeparture {
    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 *)barWindow {
    return [self.stoodLenient lastObject];
}

- (NSInteger)renameCount {
    return self.stoodLenient.count;
}


@end
