






#import "ContentFairButton.h"
#import "MixSnowBits.h"
#import "UIImage+ForImage.h"
#import "SDWebImageManager.h"

@interface ContentFairButton ()


@property (nonatomic, strong) NSTimer *keysLoadHisLowTimer;

@property (nonatomic, assign) NSInteger keepYouAllPhaseRingHex;

@property (nonatomic, copy) NSString *behaviorsSyntheticTorqueFootMax;

@end

@implementation ContentFairButton

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self predictedTargetedLinearTapCost];
    }
    return self;
}

- (instancetype)initWithCoder:(NSCoder *)coder {
    self = [super initWithCoder:coder];
    if (self) {
        [self predictedTargetedLinearTapCost];
    }
    return self;
}


- (void)predictedTargetedLinearTapCost {
    
    self.detectorDownKashmiriEachLeastCropping = 60;
    self.behaviorsSyntheticTorqueFootMax = MixSnowBits.theBinAlignWax.passMaterialOuterBedParagraphPanCode;
    [self setTitle:self.behaviorsSyntheticTorqueFootMax forState:UIControlStateNormal];

    
    NSString *agentDogDense = [MixSnowBits wakeFailMindFourTokenImage];
    if (agentDogDense) {
        
        [[SDWebImageManager sharedManager] loadImageWithURL:[NSURL URLWithString:agentDogDense]
                                                    options:0
                                                   progress:nil
                                                  completed:^(UIImage *image, NSData *data, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
            if (image) {
                dispatch_async(dispatch_get_main_queue(), ^{
                    [self setBackgroundImage:image forState:UIControlStateNormal];
                    [self setBackgroundImage:[UIImage capFitHasSpineColor:[[UIColor lightGrayColor] colorWithAlphaComponent:0.5f]] forState:UIControlStateHighlighted];
                });
            }
        }];
        
        [self setBackgroundImage:[UIImage capFitHasSpineColor:MixSnowBits.hallLaterColor] forState:UIControlStateNormal];
    } else {
        
        [self setBackgroundImage:[UIImage capFitHasSpineColor:MixSnowBits.hallLaterColor] forState:UIControlStateNormal];
        [self setBackgroundImage:[UIImage capFitHasSpineColor:[[UIColor lightGrayColor] colorWithAlphaComponent:0.5f]] forState:UIControlStateHighlighted];
    }

    self.titleLabel.font = [UIFont systemFontOfSize:16];
    self.layer.cornerRadius = MixSnowBits.packRouteToo.germanIntent;
    self.layer.masksToBounds = YES;
    
    self.contentEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 5);
    
    [self sizeToFit];

    
    [self addTarget:self action:@selector(seeTakeEachClicked) forControlEvents:UIControlEventTouchUpInside];
}


- (void)seeTakeEachClicked {
    [self millSawSuffixQuechuaFragments];
    if (self.pastOfferAxesAction) {
        self.pastOfferAxesAction();
    }
}


- (void)millSawSuffixQuechuaFragments {
    self.enabled = NO;
    self.keepYouAllPhaseRingHex = self.detectorDownKashmiriEachLeastCropping;
    [self askEnhancedReadyLayeringComposeHormone];
    
    
    self.keysLoadHisLowTimer = [NSTimer scheduledTimerWithTimeInterval:1.0
                                                                 target:self
                                                               selector:@selector(movieDriveGreatEstablishSucceeded:)
                                                               userInfo:nil
                                                                repeats:YES];
}


- (void)movieDriveGreatEstablishSucceeded:(NSTimer *)malay {
    self.keepYouAllPhaseRingHex--;
    if (self.keepYouAllPhaseRingHex <= 0) {
        [self violationPrettyHueStereoGigabits];
    } else {
        [self askEnhancedReadyLayeringComposeHormone];
    }
}


- (void)askEnhancedReadyLayeringComposeHormone {
    NSString *title = [NSString stringWithFormat:@"%@(%ld)",MixSnowBits.theBinAlignWax.assignSuddenBirthToneTipRetCode, (long)self.keepYouAllPhaseRingHex];
    [self setTitle:title forState:UIControlStateDisabled];
}


- (void)violationPrettyHueStereoGigabits {
    [self.keysLoadHisLowTimer invalidate];
    self.keysLoadHisLowTimer = nil;
    self.enabled = YES;
    [self setTitle:self.behaviorsSyntheticTorqueFootMax forState:UIControlStateNormal];
}

- (void)dealloc {
    
    [self.keysLoadHisLowTimer invalidate];
    self.keysLoadHisLowTimer = nil;
}

@end
