






#import "DownloadBinLabel.h"
#import "FixChunkBad.h"
#import "UIImage+MenImage.h"

@implementation DownloadBinLabel

+ (DownloadBinLabel *)writeMeterAddLabel {
    return [self writeMeterAddLabel:YES];
}

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

    NSAttributedString *teluguEjectKinCheckingReorder = nil;
    if (isCheckBox) {
        
        NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
        UIImage *templateImage = [[UIImage exportForkEarQueueTallName:FixChunkBad.swedishTwist.irishExcludeUnlimitedAliveIntegerAscending] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
        attachment.image = templateImage; 
        
        attachment.bounds = CGRectMake(0, -5, 20, 20);
        teluguEjectKinCheckingReorder = [NSAttributedString attributedStringWithAttachment:attachment];
    }

    
    NSString *text = FixChunkBad.passLazyUnique.performsNear;
    NSMutableAttributedString *sumCapsBadPrep = [[NSMutableAttributedString alloc] initWithString:text];
    
    
    NSRange minCupTabRadix = [text rangeOfString:FixChunkBad.passLazyUnique.metadataReason];
    if (minCupTabRadix.location != NSNotFound) {
        [sumCapsBadPrep addAttribute:NSForegroundColorAttributeName value:[FixChunkBad topOpaqueColor] range:minCupTabRadix];
        [sumCapsBadPrep addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:minCupTabRadix];
    }

    
    NSMutableAttributedString *hexClaimTrademarkLegibleEntered = [[NSMutableAttributedString alloc] init];
    if (teluguEjectKinCheckingReorder) {
        [hexClaimTrademarkLegibleEntered appendAttributedString:teluguEjectKinCheckingReorder];
    }
    [hexClaimTrademarkLegibleEntered appendAttributedString:sumCapsBadPrep];
    
    label.attributedText = hexClaimTrademarkLegibleEntered;
    
    
    UITapGestureRecognizer *oneCellMax = [[UITapGestureRecognizer alloc] initWithTarget:label action:@selector(birthdayForceEggTopSupport:)];
    [label addGestureRecognizer:oneCellMax];
    
    return label;
}

- (void)setCubicSizeVital:(BOOL)cubicSizeVital {
    _cubicSizeVital = !cubicSizeVital;
    [self parsePassiveRadialAutomaticEitherAccuracyLabel:self];
}

- (void)birthdayForceEggTopSupport:(UITapGestureRecognizer *)oneCellMax {
    DownloadBinLabel *label = (DownloadBinLabel *)oneCellMax.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 cutWarpLogo = [oneCellMax locationInView:label];
    CGRect usedRect = [layoutManager usedRectForTextContainer:textContainer];
    CGPoint negativeTallCarArcheryPlane = CGPointMake(
        (label.bounds.size.width - usedRect.size.width) / 2,   
        (label.bounds.size.height - usedRect.size.height) / 2  
    );
    
    
    CGPoint lingerLiterSpanishLocatorLeftArm = CGPointMake(
        cutWarpLogo.x - negativeTallCarArcheryPlane.x,
        cutWarpLogo.y - negativeTallCarArcheryPlane.y
    );
    
    
    __block BOOL hallAbortStop = 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 chainSlant;
            [layoutManager glyphRangeForCharacterRange:range actualCharacterRange:&chainSlant];
            
            
            CGRect swipeRect = [layoutManager boundingRectForGlyphRange:chainSlant
                                                      inTextContainer:textContainer];
            
            
            CGRect swapWaxNeedRect = CGRectOffset(swipeRect, negativeTallCarArcheryPlane.x, negativeTallCarArcheryPlane.y);
            
            
            if (CGRectContainsPoint(swapWaxNeedRect, cutWarpLogo)) {
                hallAbortStop = YES;
                *stop = YES;
            }
        }
    }];
    
    if (hallAbortStop) {
        
        
        [self parsePassiveRadialAutomaticEitherAccuracyLabel:label];
        return;
    }
    
    
    NSUInteger characterIndex = [layoutManager characterIndexForPoint:lingerLiterSpanishLocatorLeftArm
                                                    inTextContainer:textContainer
                           fractionOfDistanceBetweenInsertionPoints:NULL];
    
    NSString *hailText = label.attributedText.string;
    NSRange minCupTabRadix = [hailText rangeOfString:FixChunkBad.passLazyUnique.metadataReason];
    
    if (characterIndex != NSNotFound && NSLocationInRange(characterIndex, minCupTabRadix)) {
        
        
        if (self.suchControlExponentsCatPreserveMill) {
            self.suchControlExponentsCatPreserveMill();
        }
    }
}


- (void)parsePassiveRadialAutomaticEitherAccuracyLabel:(DownloadBinLabel *)label {
    NSMutableAttributedString *attributedText = [label.attributedText mutableCopy];
    __block BOOL askNetFile = 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 kelvinBag = !_cubicSizeVital;
        
        
        NSTextAttachment *hertzAccounts = [[NSTextAttachment alloc] init];
        
        
        UIColor *herDryColor = kelvinBag ? [FixChunkBad topOpaqueColor]: UIColor.lightGrayColor;
        UIImage *chunkAreImage = [UIImage exportForkEarQueueTallName:kelvinBag ? FixChunkBad.swedishTwist.fragmentIcyStackQuietOffsetsSparse :FixChunkBad.swedishTwist.irishExcludeUnlimitedAliveIntegerAscending];
        
        
        hertzAccounts.image = [[chunkAreImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]
                                imageWithTintColor:herDryColor];
        hertzAccounts.bounds = oldAttachment.bounds;
        
        
        [attributedText removeAttribute:NSAttachmentAttributeName range:range];
        [attributedText addAttribute:NSAttachmentAttributeName value:hertzAccounts range:range];
        
        _cubicSizeVital = kelvinBag;
        askNetFile = YES;
        *stop = YES;
    }];
    
    if (askNetFile) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [UIView transitionWithView:label
                              duration:0.3
                               options:UIViewAnimationOptionTransitionCrossDissolve
                            animations:^{
                                label.attributedText = attributedText;
                            } completion:nil];
            [label setNeedsDisplay];
        });
    }
}

@end
