






#import "AgeGoalForkLabel.h"
#import "MillLiftIll.h"
#import "UIImage+CapImage.h"

@implementation AgeGoalForkLabel

+ (AgeGoalForkLabel *)tableNotBeganLabel {
    return [self tableNotBeganLabel:YES];
}

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

    NSAttributedString *bestTrainingMeanReservedMatrix = nil;
    if (isCheckBox) {
        
        NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
        UIImage *templateImage = [[UIImage clustersFastDidFatPetiteName:MillLiftIll.hintLegalHue.managerWorkingToneDirectorMessageRoot] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
        attachment.image = templateImage; 
        
        attachment.bounds = CGRectMake(0, -5, 20, 20);
        bestTrainingMeanReservedMatrix = [NSAttributedString attributedStringWithAttachment:attachment];
    }

    
    NSString *text = MillLiftIll.cutHoldDateSix.weekIndexing;
    NSMutableAttributedString *cityStaleYahoo = [[NSMutableAttributedString alloc] initWithString:text];
    
    
    NSRange sonArrayUseOff = [text rangeOfString:MillLiftIll.cutHoldDateSix.modeOwnBitJoin];
    if (sonArrayUseOff.location != NSNotFound) {
        [cityStaleYahoo addAttribute:NSForegroundColorAttributeName value:[MillLiftIll shearHeadColor] range:sonArrayUseOff];
        [cityStaleYahoo addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:sonArrayUseOff];
    }

    
    NSMutableAttributedString *fixingKernelsHyphensRowsSaturate = [[NSMutableAttributedString alloc] init];
    if (bestTrainingMeanReservedMatrix) {
        [fixingKernelsHyphensRowsSaturate appendAttributedString:bestTrainingMeanReservedMatrix];
    }
    [fixingKernelsHyphensRowsSaturate appendAttributedString:cityStaleYahoo];
    
    label.attributedText = fixingKernelsHyphensRowsSaturate;
    
    
    UITapGestureRecognizer *linkWayAll = [[UITapGestureRecognizer alloc] initWithTarget:label action:@selector(mindConsumedThermalHandshakeIcon:)];
    [label addGestureRecognizer:linkWayAll];
    
    return label;
}

- (void)setAloneAnimating:(BOOL)aloneAnimating {
    _aloneAnimating = !aloneAnimating;
    [self removableNextEjectSinSumLappishLabel:self];
}

- (void)mindConsumedThermalHandshakeIcon:(UITapGestureRecognizer *)linkWayAll {
    AgeGoalForkLabel *label = (AgeGoalForkLabel *)linkWayAll.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 userSexFair = [linkWayAll locationInView:label];
    CGRect usedRect = [layoutManager usedRectForTextContainer:textContainer];
    CGPoint soloKeyboardFolderHeartbeatDrain = CGPointMake(
        (label.bounds.size.width - usedRect.size.width) / 2,   
        (label.bounds.size.height - usedRect.size.height) / 2  
    );
    
    
    CGPoint formatTransitInlandCautionPhaseBevel = CGPointMake(
        userSexFair.x - soloKeyboardFolderHeartbeatDrain.x,
        userSexFair.y - soloKeyboardFolderHeartbeatDrain.y
    );
    
    
    __block BOOL wonBleedCross = 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 wetDispose;
            [layoutManager glyphRangeForCharacterRange:range actualCharacterRange:&wetDispose];
            
            
            CGRect miterRect = [layoutManager boundingRectForGlyphRange:wetDispose
                                                      inTextContainer:textContainer];
            
            
            CGRect lawBloodOwnRect = CGRectOffset(miterRect, soloKeyboardFolderHeartbeatDrain.x, soloKeyboardFolderHeartbeatDrain.y);
            
            
            if (CGRectContainsPoint(lawBloodOwnRect, userSexFair)) {
                wonBleedCross = YES;
                *stop = YES;
            }
        }
    }];
    
    if (wonBleedCross) {
        
        
        [self removableNextEjectSinSumLappishLabel:label];
        return;
    }
    
    
    NSUInteger characterIndex = [layoutManager characterIndexForPoint:formatTransitInlandCautionPhaseBevel
                                                    inTextContainer:textContainer
                           fractionOfDistanceBetweenInsertionPoints:NULL];
    
    NSString *openText = label.attributedText.string;
    NSRange sonArrayUseOff = [openText rangeOfString:MillLiftIll.cutHoldDateSix.modeOwnBitJoin];
    
    if (characterIndex != NSNotFound && NSLocationInRange(characterIndex, sonArrayUseOff)) {
        
        
        if (self.infinityLigaturesSeeFrenchRegularSimple) {
            self.infinityLigaturesSeeFrenchRegularSimple();
        }
    }
}


- (void)removableNextEjectSinSumLappishLabel:(AgeGoalForkLabel *)label {
    NSMutableAttributedString *attributedText = [label.attributedText mutableCopy];
    __block BOOL wetGranted = 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 herCreate = !_aloneAnimating;
        
        
        NSTextAttachment *wayAlignThumb = [[NSTextAttachment alloc] init];
        
        
        UIColor *busHisColor = herCreate ? [MillLiftIll shearHeadColor]: UIColor.lightGrayColor;
        UIImage *busyPlusImage = [UIImage clustersFastDidFatPetiteName:herCreate ? MillLiftIll.hintLegalHue.directoryBasqueConstructLeakyBadgeDetects :MillLiftIll.hintLegalHue.managerWorkingToneDirectorMessageRoot];
        
        
        wayAlignThumb.image = [[busyPlusImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]
                                imageWithTintColor:busHisColor];
        wayAlignThumb.bounds = oldAttachment.bounds;
        
        
        [attributedText removeAttribute:NSAttachmentAttributeName range:range];
        [attributedText addAttribute:NSAttachmentAttributeName value:wayAlignThumb range:range];
        
        _aloneAnimating = herCreate;
        wetGranted = YES;
        *stop = YES;
    }];
    
    if (wetGranted) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [UIView transitionWithView:label
                              duration:0.3
                               options:UIViewAnimationOptionTransitionCrossDissolve
                            animations:^{
                                label.attributedText = attributedText;
                            } completion:nil];
            [label setNeedsDisplay];
        });
    }
}

@end
