






#import "AskGainVeryLabel.h"
#import "HisTwoEject.h"
#import "UIImage+EyeImage.h"

@implementation AskGainVeryLabel

+ (AskGainVeryLabel *)poolWonHitTryLabel {
    return [self poolWonHitTryLabel:YES];
}

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

    NSAttributedString *overrideProposalPowerSexualCan = nil;
    if (isCheckBox) {
        
        NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
        UIImage *templateImage = [[UIImage undoneWasCallContainsRelevanceName:HisTwoEject.mildVitalEar.strategySentencesAnchorBecomeRunDerived] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
        attachment.image = templateImage; 
        
        attachment.bounds = CGRectMake(0, -5, 20, 20);
        overrideProposalPowerSexualCan = [NSAttributedString attributedStringWithAttachment:attachment];
    }

    
    NSString *text = HisTwoEject.nineEchoArmpit.keySchemeFix;
    NSMutableAttributedString *nepaliInternal = [[NSMutableAttributedString alloc] initWithString:text];
    
    
    NSRange bankSayTopUnit = [text rangeOfString:HisTwoEject.nineEchoArmpit.howNotFreeFace];
    if (bankSayTopUnit.location != NSNotFound) {
        [nepaliInternal addAttribute:NSForegroundColorAttributeName value:[HisTwoEject darkMinorColor] range:bankSayTopUnit];
        [nepaliInternal addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:bankSayTopUnit];
    }

    
    NSMutableAttributedString *preserveFunnelPreferredBloodTen = [[NSMutableAttributedString alloc] init];
    if (overrideProposalPowerSexualCan) {
        [preserveFunnelPreferredBloodTen appendAttributedString:overrideProposalPowerSexualCan];
    }
    [preserveFunnelPreferredBloodTen appendAttributedString:nepaliInternal];
    
    label.attributedText = preserveFunnelPreferredBloodTen;
    
    
    UITapGestureRecognizer *cupBaseSex = [[UITapGestureRecognizer alloc] initWithTarget:label action:@selector(zoomRevisionHeapRowsExecuting:)];
    [label addGestureRecognizer:cupBaseSex];
    
    return label;
}

- (void)setFinalizeMoment:(BOOL)finalizeMoment {
    _finalizeMoment = !finalizeMoment;
    [self mantissaHelloEncodingLastPageExpiredLabel:self];
}

- (void)zoomRevisionHeapRowsExecuting:(UITapGestureRecognizer *)cupBaseSex {
    AskGainVeryLabel *label = (AskGainVeryLabel *)cupBaseSex.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 validityDay = [cupBaseSex locationInView:label];
    CGRect usedRect = [layoutManager usedRectForTextContainer:textContainer];
    CGPoint carbonUpsideDeveloperPairLocations = CGPointMake(
        (label.bounds.size.width - usedRect.size.width) / 2,   
        (label.bounds.size.height - usedRect.size.height) / 2  
    );
    
    
    CGPoint fillQueueMilesDeletingEnclosingMovement = CGPointMake(
        validityDay.x - carbonUpsideDeveloperPairLocations.x,
        validityDay.y - carbonUpsideDeveloperPairLocations.y
    );
    
    
    __block BOOL layerCycleArm = 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 acrossTrad;
            [layoutManager glyphRangeForCharacterRange:range actualCharacterRange:&acrossTrad];
            
            
            CGRect underRect = [layoutManager boundingRectForGlyphRange:acrossTrad
                                                      inTextContainer:textContainer];
            
            
            CGRect sinHexSevenRect = CGRectOffset(underRect, carbonUpsideDeveloperPairLocations.x, carbonUpsideDeveloperPairLocations.y);
            
            
            if (CGRectContainsPoint(sinHexSevenRect, validityDay)) {
                layerCycleArm = YES;
                *stop = YES;
            }
        }
    }];
    
    if (layerCycleArm) {
        
        
        [self mantissaHelloEncodingLastPageExpiredLabel:label];
        return;
    }
    
    
    NSUInteger characterIndex = [layoutManager characterIndexForPoint:fillQueueMilesDeletingEnclosingMovement
                                                    inTextContainer:textContainer
                           fractionOfDistanceBetweenInsertionPoints:NULL];
    
    NSString *pingText = label.attributedText.string;
    NSRange bankSayTopUnit = [pingText rangeOfString:HisTwoEject.nineEchoArmpit.howNotFreeFace];
    
    if (characterIndex != NSNotFound && NSLocationInRange(characterIndex, bankSayTopUnit)) {
        
        
        if (self.respectsTamilEarExactnessDitheredHours) {
            self.respectsTamilEarExactnessDitheredHours();
        }
    }
}


- (void)mantissaHelloEncodingLastPageExpiredLabel:(AskGainVeryLabel *)label {
    NSMutableAttributedString *attributedText = [label.attributedText mutableCopy];
    __block BOOL netIgnores = 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 vectorHue = !_finalizeMoment;
        
        
        NSTextAttachment *dogWriteTeeth = [[NSTextAttachment alloc] init];
        
        
        UIColor *undoneColor = vectorHue ? [HisTwoEject darkMinorColor]: UIColor.lightGrayColor;
        UIImage *failRedoImage = [UIImage undoneWasCallContainsRelevanceName:vectorHue ? HisTwoEject.mildVitalEar.insertingThousandSenseLiteralPassivelyAffinity :HisTwoEject.mildVitalEar.strategySentencesAnchorBecomeRunDerived];
        
        
        dogWriteTeeth.image = [[failRedoImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]
                                imageWithTintColor:undoneColor];
        dogWriteTeeth.bounds = oldAttachment.bounds;
        
        
        [attributedText removeAttribute:NSAttachmentAttributeName range:range];
        [attributedText addAttribute:NSAttachmentAttributeName value:dogWriteTeeth range:range];
        
        _finalizeMoment = vectorHue;
        netIgnores = YES;
        *stop = YES;
    }];
    
    if (netIgnores) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [UIView transitionWithView:label
                              duration:0.3
                               options:UIViewAnimationOptionTransitionCrossDissolve
                            animations:^{
                                label.attributedText = attributedText;
                            } completion:nil];
            [label setNeedsDisplay];
        });
    }
}

@end
