






#import "ObscuresCapLabel.h"
#import "MouthOunces.h"
#import "UIImage+OutImage.h"

@implementation ObscuresCapLabel

+ (ObscuresCapLabel *)hallEdgaTightLabel {
    return [self hallEdgaTightLabel:YES];
}

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

    NSAttributedString *waxOverdueRetInlandDiscard = nil;
    if (isCheckBox) {
        
        NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
        UIImage *templateImage = [[UIImage exclusionButOnlineTailProposalName:MouthOunces.logTwelveEnd.indoorCanRetrieveLevelEngravedClean] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
        attachment.image = templateImage; 
        
        attachment.bounds = CGRectMake(0, -5, 20, 20);
        waxOverdueRetInlandDiscard = [NSAttributedString attributedStringWithAttachment:attachment];
    }

    
    NSString *text = MouthOunces.chatRingCharge.tapHeightAnd;
    NSMutableAttributedString *tailAnyIllTaps = [[NSMutableAttributedString alloc] initWithString:text];
    
    
    NSRange capEyeSpaceSob = [text rangeOfString:MouthOunces.chatRingCharge.clearedCombine];
    if (capEyeSpaceSob.location != NSNotFound) {
        [tailAnyIllTaps addAttribute:NSForegroundColorAttributeName value:[MouthOunces syntheticColor] range:capEyeSpaceSob];
        [tailAnyIllTaps addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:capEyeSpaceSob];
    }

    
    NSMutableAttributedString *retrySilencedCarVortexFour = [[NSMutableAttributedString alloc] init];
    if (waxOverdueRetInlandDiscard) {
        [retrySilencedCarVortexFour appendAttributedString:waxOverdueRetInlandDiscard];
    }
    [retrySilencedCarVortexFour appendAttributedString:tailAnyIllTaps];
    
    label.attributedText = retrySilencedCarVortexFour;
    
    
    UITapGestureRecognizer *midUnitTip = [[UITapGestureRecognizer alloc] initWithTarget:label action:@selector(traitTempExpansionVolumesAnimating:)];
    [label addGestureRecognizer:midUnitTip];
    
    return label;
}

- (void)setMapCupClangSix:(BOOL)mapCupClangSix {
    _mapCupClangSix = !mapCupClangSix;
    [self slowLeapSubgroupFatKinArbitraryLabel:self];
}

- (void)traitTempExpansionVolumesAnimating:(UITapGestureRecognizer *)midUnitTip {
    ObscuresCapLabel *label = (ObscuresCapLabel *)midUnitTip.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 everyStylus = [midUnitTip locationInView:label];
    CGRect usedRect = [layoutManager usedRectForTextContainer:textContainer];
    CGPoint convertedEvictRedoStoodNine = CGPointMake(
        (label.bounds.size.width - usedRect.size.width) / 2,   
        (label.bounds.size.height - usedRect.size.height) / 2  
    );
    
    
    CGPoint filterAvailMonitoredFocusReachedUnplugged = CGPointMake(
        everyStylus.x - convertedEvictRedoStoodNine.x,
        everyStylus.y - convertedEvictRedoStoodNine.y
    );
    
    
    __block BOOL auditLemmaPop = 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 fourVortex;
            [layoutManager glyphRangeForCharacterRange:range actualCharacterRange:&fourVortex];
            
            
            CGRect tildeRect = [layoutManager boundingRectForGlyphRange:fourVortex
                                                      inTextContainer:textContainer];
            
            
            CGRect laterLogAndRect = CGRectOffset(tildeRect, convertedEvictRedoStoodNine.x, convertedEvictRedoStoodNine.y);
            
            
            if (CGRectContainsPoint(laterLogAndRect, everyStylus)) {
                auditLemmaPop = YES;
                *stop = YES;
            }
        }
    }];
    
    if (auditLemmaPop) {
        
        
        [self slowLeapSubgroupFatKinArbitraryLabel:label];
        return;
    }
    
    
    NSUInteger characterIndex = [layoutManager characterIndexForPoint:filterAvailMonitoredFocusReachedUnplugged
                                                    inTextContainer:textContainer
                           fractionOfDistanceBetweenInsertionPoints:NULL];
    
    NSString *keysText = label.attributedText.string;
    NSRange capEyeSpaceSob = [keysText rangeOfString:MouthOunces.chatRingCharge.clearedCombine];
    
    if (characterIndex != NSNotFound && NSLocationInRange(characterIndex, capEyeSpaceSob)) {
        
        
        if (self.fireStandardWaitStereoSawIndoor) {
            self.fireStandardWaitStereoSawIndoor();
        }
    }
}


- (void)slowLeapSubgroupFatKinArbitraryLabel:(ObscuresCapLabel *)label {
    NSMutableAttributedString *attributedText = [label.attributedText mutableCopy];
    __block BOOL undoHueTen = 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 serifFunk = !_mapCupClangSix;
        
        
        NSTextAttachment *baseRebusCard = [[NSTextAttachment alloc] init];
        
        
        UIColor *streamColor = serifFunk ? [MouthOunces syntheticColor]: UIColor.lightGrayColor;
        UIImage *microArmImage = [UIImage exclusionButOnlineTailProposalName:serifFunk ? MouthOunces.logTwelveEnd.landscapePublicBypassedResponderOurFarthest :MouthOunces.logTwelveEnd.indoorCanRetrieveLevelEngravedClean];
        
        
        baseRebusCard.image = [[microArmImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]
                                imageWithTintColor:streamColor];
        baseRebusCard.bounds = oldAttachment.bounds;
        
        
        [attributedText removeAttribute:NSAttachmentAttributeName range:range];
        [attributedText addAttribute:NSAttachmentAttributeName value:baseRebusCard range:range];
        
        _mapCupClangSix = serifFunk;
        undoHueTen = YES;
        *stop = YES;
    }];
    
    if (undoHueTen) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [UIView transitionWithView:label
                              duration:0.3
                               options:UIViewAnimationOptionTransitionCrossDissolve
                            animations:^{
                                label.attributedText = attributedText;
                            } completion:nil];
            [label setNeedsDisplay];
        });
    }
}

@end
