






#import "PopLabelCatLabel.h"
#import "LawExported.h"
#import "UIImage+NotImage.h"

@implementation PopLabelCatLabel

+ (PopLabelCatLabel *)serifCupStackLabel {
    return [self serifCupStackLabel:YES];
}

+ (PopLabelCatLabel *)serifCupStackLabel:(BOOL)isCheckBox {
    
    PopLabelCatLabel *label = [[PopLabelCatLabel alloc] init];
    label.numberOfLines = 0;
    label.textAlignment = NSTextAlignmentCenter;
    label.textColor = [UIColor lightGrayColor];
    label.font = [UIFont systemFontOfSize:12];
    label.userInteractionEnabled = YES; 

    NSAttributedString *callbacksSidebarTwitterUndoneProtocol = nil;
    if (isCheckBox) {
        
        NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
        UIImage *templateImage = [[UIImage watchedTopExceedsFileInvisibleName:LawExported.playVersions.permanentDirectoryFinalRefreshedSendFire] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
        attachment.image = templateImage; 
        
        attachment.bounds = CGRectMake(0, -5, 20, 20);
        callbacksSidebarTwitterUndoneProtocol = [NSAttributedString attributedStringWithAttachment:attachment];
    }

    
    NSString *text = LawExported.valueOutArtMen.greekLiftBit;
    NSMutableAttributedString *imageStoneKeys = [[NSMutableAttributedString alloc] initWithString:text];
    
    
    NSRange penSixFillMany = [text rangeOfString:LawExported.valueOutArtMen.signWonHeapAdd];
    if (penSixFillMany.location != NSNotFound) {
        [imageStoneKeys addAttribute:NSForegroundColorAttributeName value:[LawExported specifierColor] range:penSixFillMany];
        [imageStoneKeys addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:penSixFillMany];
    }

    
    NSMutableAttributedString *claimEmptyUbiquityRefusedMany = [[NSMutableAttributedString alloc] init];
    if (callbacksSidebarTwitterUndoneProtocol) {
        [claimEmptyUbiquityRefusedMany appendAttributedString:callbacksSidebarTwitterUndoneProtocol];
    }
    [claimEmptyUbiquityRefusedMany appendAttributedString:imageStoneKeys];
    
    label.attributedText = claimEmptyUbiquityRefusedMany;
    
    
    UITapGestureRecognizer *greekModal = [[UITapGestureRecognizer alloc] initWithTarget:label action:@selector(modifyOddCurlListMath:)];
    [label addGestureRecognizer:greekModal];
    
    return label;
}

- (void)setPoolCarPlayWin:(BOOL)poolCarPlayWin {
    _poolCarPlayWin = !poolCarPlayWin;
    [self fractionsComposedWaxClusterMantissaFathomsLabel:self];
}

- (void)modifyOddCurlListMath:(UITapGestureRecognizer *)greekModal {
    PopLabelCatLabel *label = (PopLabelCatLabel *)greekModal.view;
    if (!label.attributedText) return;
    
    
    NSTextStorage *textStorage = [[NSTextStorage alloc] initWithAttributedString:label.attributedText];
    NSLayoutManager *layoutManager = [[NSLayoutManager alloc] init];
    NSTextContainer *textContainer = [[NSTextContainer alloc] initWithSize:label.bounds.size];
    
    textContainer.lineFragmentPadding = 0;
    textContainer.maximumNumberOfLines = label.numberOfLines;
    textContainer.lineBreakMode = label.lineBreakMode;
    
    [textStorage addLayoutManager:layoutManager];
    [layoutManager addTextContainer:textContainer];
    
    
    [layoutManager ensureLayoutForTextContainer:textContainer];
    
    
    CGPoint gatherPaper = [greekModal locationInView:label];
    CGRect usedRect = [layoutManager usedRectForTextContainer:textContainer];
    CGPoint putIntegerSearchRadixShoulder = CGPointMake(
        (label.bounds.size.width - usedRect.size.width) / 2,   
        (label.bounds.size.height - usedRect.size.height) / 2  
    );
    
    
    CGPoint youCarrierPoloBackupUbiquitySidebar = CGPointMake(
        gatherPaper.x - putIntegerSearchRadixShoulder.x,
        gatherPaper.y - putIntegerSearchRadixShoulder.y
    );
    
    
    __block BOOL lawPreciseIts = NO;
    [label.attributedText enumerateAttribute:NSAttachmentAttributeName
                                    inRange:NSMakeRange(0, label.attributedText.length)
                                    options:0
                                 usingBlock:^(id value, NSRange range, BOOL *stop) {
        if ([value isKindOfClass:[NSTextAttachment class]]) {
            
            NSRange buddyRotor;
            [layoutManager glyphRangeForCharacterRange:range actualCharacterRange:&buddyRotor];
            
            
            CGRect clearRect = [layoutManager boundingRectForGlyphRange:buddyRotor
                                                      inTextContainer:textContainer];
            
            
            CGRect mutationRedRect = CGRectOffset(clearRect, putIntegerSearchRadixShoulder.x, putIntegerSearchRadixShoulder.y);
            
            
            if (CGRectContainsPoint(mutationRedRect, gatherPaper)) {
                lawPreciseIts = YES;
                *stop = YES;
            }
        }
    }];
    
    if (lawPreciseIts) {
        
        
        [self fractionsComposedWaxClusterMantissaFathomsLabel:label];
        return;
    }
    
    
    NSUInteger characterIndex = [layoutManager characterIndexForPoint:youCarrierPoloBackupUbiquitySidebar
                                                    inTextContainer:textContainer
                           fractionOfDistanceBetweenInsertionPoints:NULL];
    
    NSString *barsText = label.attributedText.string;
    NSRange penSixFillMany = [barsText rangeOfString:LawExported.valueOutArtMen.signWonHeapAdd];
    
    if (characterIndex != NSNotFound && NSLocationInRange(characterIndex, penSixFillMany)) {
        
        
        if (self.boyfriendJustStoreRenewalTallBad) {
            self.boyfriendJustStoreRenewalTallBad();
        }
    }
}


- (void)fractionsComposedWaxClusterMantissaFathomsLabel:(PopLabelCatLabel *)label {
    NSMutableAttributedString *attributedText = [label.attributedText mutableCopy];
    __block BOOL forRowIron = NO;
    
    [attributedText enumerateAttribute:NSAttachmentAttributeName
                             inRange:NSMakeRange(0, attributedText.length)
                             options:0
                          usingBlock:^(NSTextAttachment *oldAttachment, NSRange range, BOOL *stop) {
        if (![oldAttachment isKindOfClass:[NSTextAttachment class]]) return;
        
        
        BOOL rowRandom = !_poolCarPlayWin;
        
        
        NSTextAttachment *winPenRawYear = [[NSTextAttachment alloc] init];
        
        
        UIColor *wonCapColor = rowRandom ? [LawExported specifierColor]: UIColor.lightGrayColor;
        UIImage *sayDolbyImage = [UIImage watchedTopExceedsFileInvisibleName:rowRandom ? LawExported.playVersions.fitGopherBadDescenderTrailingSetting :LawExported.playVersions.permanentDirectoryFinalRefreshedSendFire];
        
        
        winPenRawYear.image = [[sayDolbyImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]
                                imageWithTintColor:wonCapColor];
        winPenRawYear.bounds = oldAttachment.bounds;
        
        
        [attributedText removeAttribute:NSAttachmentAttributeName range:range];
        [attributedText addAttribute:NSAttachmentAttributeName value:winPenRawYear range:range];
        
        _poolCarPlayWin = rowRandom;
        forRowIron = YES;
        *stop = YES;
    }];
    
    if (forRowIron) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [UIView transitionWithView:label
                              duration:0.3
                               options:UIViewAnimationOptionTransitionCrossDissolve
                            animations:^{
                                label.attributedText = attributedText;
                            } completion:nil];
            [label setNeedsDisplay];
        });
    }
}

@end
