






#import "ThinRemovesLabel.h"
#import "MakerOldest.h"
#import "UIImage+PopImage.h"

@implementation ThinRemovesLabel

+ (ThinRemovesLabel *)shelfAscendedLabel {
    return [self shelfAscendedLabel:YES];
}

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

    NSAttributedString *exclusionArrowSuffixFixingSkip = nil;
    if (isCheckBox) {
        
        NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
        UIImage *templateImage = [[UIImage kirghizDecodeDetachingRhythmCharName:MakerOldest.redoneFinder.updateDetailExpensiveCatalanArrangerSequence] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
        attachment.image = templateImage; 
        
        attachment.bounds = CGRectMake(0, -5, 20, 20);
        exclusionArrowSuffixFixingSkip = [NSAttributedString attributedStringWithAttachment:attachment];
    }

    
    NSString *text = MakerOldest.patternsTwenty.busyManTheme;
    NSMutableAttributedString *nineMinPageNot = [[NSMutableAttributedString alloc] initWithString:text];
    
    
    NSRange cupWalkNapFeat = [text rangeOfString:MakerOldest.patternsTwenty.busyDiskArtery];
    if (cupWalkNapFeat.location != NSNotFound) {
        [nineMinPageNot addAttribute:NSForegroundColorAttributeName value:[MakerOldest caseAboutColor] range:cupWalkNapFeat];
        [nineMinPageNot addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:cupWalkNapFeat];
    }

    
    NSMutableAttributedString *regionRealmFalloffPreferMeasure = [[NSMutableAttributedString alloc] init];
    if (exclusionArrowSuffixFixingSkip) {
        [regionRealmFalloffPreferMeasure appendAttributedString:exclusionArrowSuffixFixingSkip];
    }
    [regionRealmFalloffPreferMeasure appendAttributedString:nineMinPageNot];
    
    label.attributedText = regionRealmFalloffPreferMeasure;
    
    
    UITapGestureRecognizer *cropSumWho = [[UITapGestureRecognizer alloc] initWithTarget:label action:@selector(unwrapEvaluateDisappearPageForever:)];
    [label addGestureRecognizer:cropSumWho];
    
    return label;
}

- (void)setNowTreeAnyMask:(BOOL)nowTreeAnyMask {
    _nowTreeAnyMask = !nowTreeAnyMask;
    [self arrangerAdjectiveHormoneTwistNextGeometryLabel:self];
}

- (void)unwrapEvaluateDisappearPageForever:(UITapGestureRecognizer *)cropSumWho {
    ThinRemovesLabel *label = (ThinRemovesLabel *)cropSumWho.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 ownMergeAll = [cropSumWho locationInView:label];
    CGRect usedRect = [layoutManager usedRectForTextContainer:textContainer];
    CGPoint fetchedPintEscapedPerformedTerabytes = CGPointMake(
        (label.bounds.size.width - usedRect.size.width) / 2,   
        (label.bounds.size.height - usedRect.size.height) / 2  
    );
    
    
    CGPoint bitmapFacePencilThickKilohertzFade = CGPointMake(
        ownMergeAll.x - fetchedPintEscapedPerformedTerabytes.x,
        ownMergeAll.y - fetchedPintEscapedPerformedTerabytes.y
    );
    
    
    __block BOOL addLawLastUse = 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 jobTheLoud;
            [layoutManager glyphRangeForCharacterRange:range actualCharacterRange:&jobTheLoud];
            
            
            CGRect earlyRect = [layoutManager boundingRectForGlyphRange:jobTheLoud
                                                      inTextContainer:textContainer];
            
            
            CGRect videoMinderRect = CGRectOffset(earlyRect, fetchedPintEscapedPerformedTerabytes.x, fetchedPintEscapedPerformedTerabytes.y);
            
            
            if (CGRectContainsPoint(videoMinderRect, ownMergeAll)) {
                addLawLastUse = YES;
                *stop = YES;
            }
        }
    }];
    
    if (addLawLastUse) {
        
        
        [self arrangerAdjectiveHormoneTwistNextGeometryLabel:label];
        return;
    }
    
    
    NSUInteger characterIndex = [layoutManager characterIndexForPoint:bitmapFacePencilThickKilohertzFade
                                                    inTextContainer:textContainer
                           fractionOfDistanceBetweenInsertionPoints:NULL];
    
    NSString *workText = label.attributedText.string;
    NSRange cupWalkNapFeat = [workText rangeOfString:MakerOldest.patternsTwenty.busyDiskArtery];
    
    if (characterIndex != NSNotFound && NSLocationInRange(characterIndex, cupWalkNapFeat)) {
        
        
        if (self.bleedPlaceOxygenSubsetFemaleOrganize) {
            self.bleedPlaceOxygenSubsetFemaleOrganize();
        }
    }
}


- (void)arrangerAdjectiveHormoneTwistNextGeometryLabel:(ThinRemovesLabel *)label {
    NSMutableAttributedString *attributedText = [label.attributedText mutableCopy];
    __block BOOL illSinMove = 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 autoLarge = !_nowTreeAnyMask;
        
        
        NSTextAttachment *pintMakerRest = [[NSTextAttachment alloc] init];
        
        
        UIColor *stylusColor = autoLarge ? [MakerOldest caseAboutColor]: UIColor.lightGrayColor;
        UIImage *frontYetImage = [UIImage kirghizDecodeDetachingRhythmCharName:autoLarge ? MakerOldest.redoneFinder.currentlyCarbonOldModeRegularProceed :MakerOldest.redoneFinder.updateDetailExpensiveCatalanArrangerSequence];
        
        
        pintMakerRest.image = [[frontYetImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]
                                imageWithTintColor:stylusColor];
        pintMakerRest.bounds = oldAttachment.bounds;
        
        
        [attributedText removeAttribute:NSAttachmentAttributeName range:range];
        [attributedText addAttribute:NSAttachmentAttributeName value:pintMakerRest range:range];
        
        _nowTreeAnyMask = autoLarge;
        illSinMove = YES;
        *stop = YES;
    }];
    
    if (illSinMove) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [UIView transitionWithView:label
                              duration:0.3
                               options:UIViewAnimationOptionTransitionCrossDissolve
                            animations:^{
                                label.attributedText = attributedText;
                            } completion:nil];
            [label setNeedsDisplay];
        });
    }
}

@end
