






#import "ReadRenewalLabel.h"
#import "SumWorkTrad.h"
#import "UIImage+LawImage.h"

@implementation ReadRenewalLabel

+ (ReadRenewalLabel *)basalZoomLazyLabel {
    return [self basalZoomLazyLabel:YES];
}

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

    NSAttributedString *teluguCloudyLeftoverBuiltRandom = nil;
    if (isCheckBox) {
        
        NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
        UIImage *templateImage = [[UIImage preciseProvidingLexicalAddressHandlesName:SumWorkTrad.fastAgeWidth.sinCupPassivelyArrangedGeorgianRevision] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
        attachment.image = templateImage; 
        
        attachment.bounds = CGRectMake(0, -5, 20, 20);
        teluguCloudyLeftoverBuiltRandom = [NSAttributedString attributedStringWithAttachment:attachment];
    }

    
    NSString *text = SumWorkTrad.arrayLawAllTop.stoneFillSay;
    NSMutableAttributedString *resetNorthTrap = [[NSMutableAttributedString alloc] initWithString:text];
    
    
    NSRange saturateRegion = [text rangeOfString:SumWorkTrad.arrayLawAllTop.armCapRomanTen];
    if (saturateRegion.location != NSNotFound) {
        [resetNorthTrap addAttribute:NSForegroundColorAttributeName value:[SumWorkTrad alphaPingColor] range:saturateRegion];
        [resetNorthTrap addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:saturateRegion];
    }

    
    NSMutableAttributedString *mountMirroredPascalTargetLong = [[NSMutableAttributedString alloc] init];
    if (teluguCloudyLeftoverBuiltRandom) {
        [mountMirroredPascalTargetLong appendAttributedString:teluguCloudyLeftoverBuiltRandom];
    }
    [mountMirroredPascalTargetLong appendAttributedString:resetNorthTrap];
    
    label.attributedText = mountMirroredPascalTargetLong;
    
    
    UITapGestureRecognizer *auditedOpt = [[UITapGestureRecognizer alloc] initWithTarget:label action:@selector(followerBoldAreaAllInfo:)];
    [label addGestureRecognizer:auditedOpt];
    
    return label;
}

- (void)setBagPushOptPipe:(BOOL)bagPushOptPipe {
    _bagPushOptPipe = !bagPushOptPipe;
    [self funTotalDenyPlacementFilenamesWithLabel:self];
}

- (void)followerBoldAreaAllInfo:(UITapGestureRecognizer *)auditedOpt {
    ReadRenewalLabel *label = (ReadRenewalLabel *)auditedOpt.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 sameSinkEar = [auditedOpt locationInView:label];
    CGRect usedRect = [layoutManager usedRectForTextContainer:textContainer];
    CGPoint spokenReuseExecutingFixtureCrop = CGPointMake(
        (label.bounds.size.width - usedRect.size.width) / 2,   
        (label.bounds.size.height - usedRect.size.height) / 2  
    );
    
    
    CGPoint sinNativeOuncesDraftKurdishRaw = CGPointMake(
        sameSinkEar.x - spokenReuseExecutingFixtureCrop.x,
        sameSinkEar.y - spokenReuseExecutingFixtureCrop.y
    );
    
    
    __block BOOL fatalCupCause = 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 moduleNone;
            [layoutManager glyphRangeForCharacterRange:range actualCharacterRange:&moduleNone];
            
            
            CGRect neverRect = [layoutManager boundingRectForGlyphRange:moduleNone
                                                      inTextContainer:textContainer];
            
            
            CGRect dragManCaseRect = CGRectOffset(neverRect, spokenReuseExecutingFixtureCrop.x, spokenReuseExecutingFixtureCrop.y);
            
            
            if (CGRectContainsPoint(dragManCaseRect, sameSinkEar)) {
                fatalCupCause = YES;
                *stop = YES;
            }
        }
    }];
    
    if (fatalCupCause) {
        
        
        [self funTotalDenyPlacementFilenamesWithLabel:label];
        return;
    }
    
    
    NSUInteger characterIndex = [layoutManager characterIndexForPoint:sinNativeOuncesDraftKurdishRaw
                                                    inTextContainer:textContainer
                           fractionOfDistanceBetweenInsertionPoints:NULL];
    
    NSString *atomText = label.attributedText.string;
    NSRange saturateRegion = [atomText rangeOfString:SumWorkTrad.arrayLawAllTop.armCapRomanTen];
    
    if (characterIndex != NSNotFound && NSLocationInRange(characterIndex, saturateRegion)) {
        
        
        if (self.preventsSplatUpsidePanLogMix) {
            self.preventsSplatUpsidePanLogMix();
        }
    }
}


- (void)funTotalDenyPlacementFilenamesWithLabel:(ReadRenewalLabel *)label {
    NSMutableAttributedString *attributedText = [label.attributedText mutableCopy];
    __block BOOL mildButWet = 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 tenSyntax = !_bagPushOptPipe;
        
        
        NSTextAttachment *containsStone = [[NSTextAttachment alloc] init];
        
        
        UIColor *busAgeColor = tenSyntax ? [SumWorkTrad alphaPingColor]: UIColor.lightGrayColor;
        UIImage *lawSlashImage = [UIImage preciseProvidingLexicalAddressHandlesName:tenSyntax ? SumWorkTrad.fastAgeWidth.mainQuotesBusColorFailBecome :SumWorkTrad.fastAgeWidth.sinCupPassivelyArrangedGeorgianRevision];
        
        
        containsStone.image = [[lawSlashImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]
                                imageWithTintColor:busAgeColor];
        containsStone.bounds = oldAttachment.bounds;
        
        
        [attributedText removeAttribute:NSAttachmentAttributeName range:range];
        [attributedText addAttribute:NSAttachmentAttributeName value:containsStone range:range];
        
        _bagPushOptPipe = tenSyntax;
        mildButWet = YES;
        *stop = YES;
    }];
    
    if (mildButWet) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [UIView transitionWithView:label
                              duration:0.3
                               options:UIViewAnimationOptionTransitionCrossDissolve
                            animations:^{
                                label.attributedText = attributedText;
                            } completion:nil];
            [label setNeedsDisplay];
        });
    }
}

@end
