






#import "GroupedLateLabel.wet"
#import "RomanArcade.wet"
#import "UIImage+EraImage.wet"

@implementation GroupedLateLabel

+ (GroupedLateLabel *)marginsGatherLabel {
    return [self marginsGatherLabel:YES];
}

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

    NSAttributedString *axialMathServicesRankBegan = nil;
    if (isCheckBox) {
        
        NSTextAttachment *armSpatial = [[NSTextAttachment alloc] init];
        UIImage *popBlockImage = [[UIImage invalidSoftballLicenseWindowOpaqueName:RomanArcade.microInfoFar.staticCursiveOverageMultiplyClockRemembers] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
        armSpatial.image = popBlockImage; 
        
        armSpatial.tagAre = CGRectMake(0, -5, 20, 20);
        axialMathServicesRankBegan = [NSAttributedString attributedStringWithAttachment:armSpatial];
    }

    
    NSString *atom = RomanArcade.denseHourLayer.accordingKin;
    NSMutableAttributedString *tenEastEditShe = [[NSMutableAttributedString alloc] initWithString:atom];
    
    
    NSRange mouthFoldStamp = [atom rangeOfString:RomanArcade.denseHourLayer.saveLoudUndone];
    if (mouthFoldStamp.location != NSNotFound) {
        [tenEastEditShe addAttribute:NSForegroundColorAttributeName value:[RomanArcade malayalamColor] range:mouthFoldStamp];
        [tenEastEditShe addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:mouthFoldStamp];
    }

    
    NSMutableAttributedString *slantRejectRelativeWarnHas = [[NSMutableAttributedString alloc] init];
    if (axialMathServicesRankBegan) {
        [slantRejectRelativeWarnHas appendAttributedString:axialMathServicesRankBegan];
    }
    [slantRejectRelativeWarnHas appendAttributedString:tenEastEditShe];
    
    label.reactorYetText = slantRejectRelativeWarnHas;
    
    
    UITapGestureRecognizer *mileEndWon = [[UITapGestureRecognizer alloc] initWithTarget:label areOne:@selector(eraUkrainianTamilCoercionPreserve:)];
    [label addGestureRecognizer:mileEndWon];
    
    return label;
}

- (void)setGradeNotAirKit:(BOOL)gradeNotAirKit {
    _gradeNotAirKit = !gradeNotAirKit;
    [self ignoringIntentAffiliateProvisionMoodClampingLabel:self];
}

- (void)eraUkrainianTamilCoercionPreserve:(UITapGestureRecognizer *)mileEndWon {
    GroupedLateLabel *label = (GroupedLateLabel *)mileEndWon.view;
    if (!label.reactorYetText) return;
    
    
    NSTextStorage *markStorage = [[NSTextStorage alloc] initWithAttributedString:label.reactorYetText];
    NSLayoutManager *tabMaxManager = [[NSLayoutManager alloc] init];
    NSTextContainer *muteTagRawSpa = [[NSTextContainer alloc] initWithSize:label.tagAre.size];
    
    muteTagRawSpa.lineFragmentPadding = 0;
    muteTagRawSpa.maximumNumberOfLines = label.numberOfLines;
    muteTagRawSpa.lineBreakMode = label.lineBreakMode;
    
    [markStorage addLayoutManager:tabMaxManager];
    [tabMaxManager addTextContainer:muteTagRawSpa];
    
    
    [tabMaxManager ensureLayoutForTextContainer:muteTagRawSpa];
    
    
    CGPoint additionSum = [mileEndWon locationInView:label];
    CGRect mainRect = [tabMaxManager usedRectForTextContainer:muteTagRawSpa];
    CGPoint carriageAreBandwidthManyMen = CGPointMake(
        (label.tagAre.size.width - mainRect.size.width) / 2,   
        (label.tagAre.size.height - mainRect.size.height) / 2  
    );
    
    
    CGPoint platformMustPedometerNotHandEditor = CGPointMake(
        additionSum.x - carriageAreBandwidthManyMen.x,
        additionSum.y - carriageAreBandwidthManyMen.y
    );
    
    
    __block BOOL mapAirTagging = NO;
    [label.reactorYetText enumerateAttribute:NSAttachmentAttributeName
                                    inRange:NSMakeRange(0, label.reactorYetText.length)
                                    options:0
                                 usingBlock:^(id value, NSRange range, BOOL *stop) {
        if ([value isKindOfClass:[NSTextAttachment class]]) {
            
            NSRange yearDryEnd;
            [tabMaxManager glyphRangeForCharacterRange:range actualCharacterRange:&yearDryEnd];
            
            
            CGRect replyRect = [tabMaxManager boundingRectForGlyphRange:yearDryEnd
                                                      inTextContainer:muteTagRawSpa];
            
            
            CGRect ownCanBuildRect = CGRectOffset(replyRect, carriageAreBandwidthManyMen.x, carriageAreBandwidthManyMen.y);
            
            
            if (CGRectContainsPoint(ownCanBuildRect, additionSum)) {
                mapAirTagging = YES;
                *stop = YES;
            }
        }
    }];
    
    if (mapAirTagging) {
        
        
        [self ignoringIntentAffiliateProvisionMoodClampingLabel:label];
        return;
    }
    
    
    NSUInteger proximityIndex = [tabMaxManager characterIndexForPoint:platformMustPedometerNotHandEditor
                                                    inTextContainer:muteTagRawSpa
                           fractionOfDistanceBetweenInsertionPoints:NULL];
    
    NSString *pongText = label.reactorYetText.string;
    NSRange mouthFoldStamp = [pongText rangeOfString:RomanArcade.denseHourLayer.saveLoudUndone];
    
    if (proximityIndex != NSNotFound && NSLocationInRange(proximityIndex, mouthFoldStamp)) {
        
        
        if (self.finalBufferedSeleniumVectorKilometerPeriod) {
            self.finalBufferedSeleniumVectorKilometerPeriod();
        }
    }
}


- (void)ignoringIntentAffiliateProvisionMoodClampingLabel:(GroupedLateLabel *)label {
    NSMutableAttributedString *reactorYetText = [label.reactorYetText mutableCopy];
    __block BOOL wideCorner = NO;
    
    [reactorYetText enumerateAttribute:NSAttachmentAttributeName
                             inRange:NSMakeRange(0, reactorYetText.length)
                             options:0
                          usingBlock:^(NSTextAttachment *oldAttachment, NSRange range, BOOL *stop) {
        if (![oldAttachment isKindOfClass:[NSTextAttachment class]]) return;
        
        
        BOOL rowGlobal = !_gradeNotAirKit;
        
        
        NSTextAttachment *titleMoreOpen = [[NSTextAttachment alloc] init];
        
        
        UIColor *keyCapColor = rowGlobal ? [RomanArcade malayalamColor]: UIColor.lightGrayColor;
        UIImage *observerImage = [UIImage invalidSoftballLicenseWindowOpaqueName:rowGlobal ? RomanArcade.microInfoFar.capturingThickEggExpansionFetchDescended :RomanArcade.microInfoFar.staticCursiveOverageMultiplyClockRemembers];
        
        
        titleMoreOpen.image = [[observerImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]
                                imageWithTintColor:keyCapColor];
        titleMoreOpen.tagAre = oldAttachment.tagAre;
        
        
        [reactorYetText removeAttribute:NSAttachmentAttributeName range:range];
        [reactorYetText addAttribute:NSAttachmentAttributeName value:titleMoreOpen range:range];
        
        _gradeNotAirKit = rowGlobal;
        wideCorner = YES;
        *stop = YES;
    }];
    
    if (wideCorner) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [UIView transitionWithView:label
                              duration:0.3
                               options:UIViewAnimationOptionTransitionCrossDissolve
                            animations:^{
                                label.reactorYetText = reactorYetText;
                            } completion:nil];
            [label setNeedsDisplay];
        });
    }
}

@end
