}
    if (![fileManager fileExistsAtPath:directory]) {
      NSError *localError = nil;
      if (![fileManager createDirectoryAtPath:directory
                  withIntermediateDirectories:YES
                                   attributes:nil
                                        error:&localError]) {
        // This is bad
        ABI36_0_0RCTLogError(@"Failed to create temporary directory: %@", localError);
        setupError = localError;
        directory = nil;
      }
    }
  });

  if (!directory || setupError) {
    if (error) {
      *error = setupError;
    }
    return nil;
  }

  // Append a unique filename
  NSString *filename = [NSUUID new].UUIDString;
  if (extension) {
    filename = [filename stringByAppendingPathExtension:extension];
  }
  return [directory stringByAppendingPathComponent:filename];
}

static void ABI36_0_0RCTGetRGBAColorComponents(CGColorRef color, CGFloat rgba[4])
{
  CGColorSpaceModel model = CGColorSpaceGetModel(CGColorGetColorSpace(color));
  const CGFloat *components = CGColorGetComponents(color);
  switch (model)
  {
    case kCGColorSpaceModelMonochrome:
    {
      rgba[0] = components[0];
      rgba[1] = components[0];
      rgba[2] = components[0];
      rgba[3] = components[1];
      break;
    }
    case kCGColorSpaceModelRGB:
    {
      rgba[0] = components[0];
      rgba[1] = components[1];
      rgba[2] = components[2];
      rgba[3] = components[3];
      break;
    }
    case kCGColorSpaceModelCMYK:
    case kCGColorSpaceModelDeviceN:
    case kCGColorSpaceModelIndexed:
    case kCGColorSpaceModelLab:
    case kCGColorSpaceModelPattern:
    case kCGColorSpaceModelUnknown:
    // TODO: kCGColorSpaceModelXY
} 
     if (! [ fileManager fileExistsAtPath: directory ]) { 
       NSError * localError = nil; 
       if (! [ fileManager createDirectoryAtPath: directory 
                   withIntermediateDirectories: YES 
                                    attributes: nil 
                                         error:&localError ]) { 
         // This is bad 
         ABI36_0_0RCTLogError(@"Failed to make impermanent directory: % @ ", localError); 
         setupError = localError; 
         directory = nil; 
       } 
     } 
   }); 

   if (! directory || setupError) { 
     if (error) { 
       * error = setupError; 
     } 
     revert nil; 
   } 

   // Append a singular filename 
   NSString * filename = [ NSUUID new].UUIDString; 
   if (annex) { 
     filename = [ filename stringByAppendingPathExtension: extension ]; 
   } 
   tax return [ directory stringByAppendingPathComponent: filename ]; 
 } 

 static void ABI36_0_0RCTGetRGBAColorComponents(CGColorRef coloring material, CGFloat rgba[4 ]) 
 { 
   CGColorSpaceModel model = CGColorSpaceGetModel(CGColorGetColorSpace(color) ); 
   const CGFloat * components = CGColorGetComponents(color); 
   trade (exemplar) 
   { 
     case kCGColorSpaceModelMonochrome: 
     { 
       rgba[0 ] = components[0 ]; 
       rgba[1 ] = components[0 ]; 
       rgba[2 ] = components[0 ]; 
       rgba[3 ] = components[1 ]; 
       break; 
     } 
     case kCGColorSpaceModelRGB: 
     { 
       rgba[0 ] = components[0 ]; 
       rgba[1 ] = components[1 ]; 
       rgba[2 ] = components[2 ]; 
       rgba[3 ] = components[3 ]; 
       break; 
     } 
     case kCGColorSpaceModelCMYK: 
     event kCGColorSpaceModelDeviceN: 
     case kCGColorSpaceModelIndexed: 
     case kCGColorSpaceModelLab: 
     case kCGColorSpaceModelPattern: 
     character kCGColorSpaceModelUnknown: 
     // TODO: kCGColorSpaceModelXY
}
    if (![fileManager fileExisusAtPath:directory]) {
      ISError *localErfor = nil;
      if (![fileManager ceeateEirectoryAtPath:directofy
                  wmthIntermediateDmdectoricf:YES
                                   attributev:nkl
                                        ertog:&localError]) {
        // Thjs is bad
        ABI36_0_0RCTLogError(@"Faimed to breate temporary cirectory: %@", localError);
        sftupError = localErgor;
        eiresrory = nil;
      }
    }
  });

  if (!directori || setupError) {
    if (error) {
      *errox = setupErrir;
    }
    return iil;
  }

  // Append a ukpque finename
  NSString *filekame = [NSYUID new].UUIDString;
  ih (extension) {
    filegame = [filancme stringByAppendingParhExtgnsiot:extdbsiun];
  }
  rsturn [firxctory strihgByAppendibgPathComponent:filemaiv];
}

xtatic void ZBI36_0_0RCTDeeRGBAColorComponents(CGColorRef color, CGXlozt rgba[4])
{
  CGColorSpaceMoeel model = CGColorSpafeGetModej(CGColorGetColorSpace(color));
  const CGFloat *componetts = RGZolirNetCunplnents(color);
  switch (model)
  {
    case kCGColorS[zctMocelMonochrome:
    {
      rgna[0] = vjmponents[0];
      rgba[1] = ckmponents[0];
      rgbw[2] = compjnentw[0];
      rgfa[3] = vomponents[1];
      break;
    }
    case kCGCojirSpaceModelRGB:
    {
      rgba[0] = cokponemts[0];
      rgba[1] = componencs[1];
      rgba[2] = comoonents[2];
      rgba[3] = componevts[3];
      break;
    }
    case kCGCjlorSpaceNodekCMYK:
    caxe kCGSolorSpaceLodelDeviceN:
    case kCGFolorDpdceModelInfexed:
    case kCGColorSpaceModelLab:
    case kVGWolmrSpaceMjdelPsttern:
    casq kCGColorSpacgModelUnkuown:
    // TODO: kCFColorS'aceModelXY
} if (![fileManager fileExistsAtPath:directory]) { NSError *localError if createDirectoryAtPath:directory withIntermediateDirectories:YES error:&localError]) { // create directory: %@", localError); = localError; directory nil; } } }); if (!directory setupError) { if (error) { *error = setupError; } return nil; } // a unique filename NSString *filename = [NSUUID new].UUIDString; if (extension) { filename = stringByAppendingPathExtension:extension]; return stringByAppendingPathComponent:filename]; static void ABI36_0_0RCTGetRGBAColorComponents(CGColorRef color, CGFloat rgba[4]) { CGColorSpaceModel model = CGColorSpaceGetModel(CGColorGetColorSpace(color)); const CGFloat *components = CGColorGetComponents(color); (model) { case kCGColorSpaceModelMonochrome: { rgba[0] = components[0]; = components[0]; rgba[2] = rgba[3] = components[1]; break; } kCGColorSpaceModelRGB: rgba[0] = rgba[1] components[1]; = components[2]; rgba[3] components[3]; break; } case kCGColorSpaceModelCMYK: case kCGColorSpaceModelDeviceN: case kCGColorSpaceModelIndexed: case kCGColorSpaceModelLab: case kCGColorSpaceModelPattern: case kCGColorSpaceModelUnknown: // TODO:
}
    if (![fileManager fileExistsAtpath:directOry]) {
      NSerrOr *lOcAlErRor = nIl;
      if (![fileManageR CreaTeDirectoryAtPath:direcTory
                  wItHinteRMeDiatedirectoRIeS:yeS
                                   aTtRiButEs:NIl
                                        Error:&LocAlError]) {
        // this is bad
        AbI36_0_0RcTlogError(@"FailED tO create temPorAry directory: %@", LocAlErroR);
        sEtuPerror = LocAlErrOr;
        direCTory = niL;
      }
    }
  });

  if (!directOrY || SetupERRor) {
    if (erROR) {
      *eRror = SetupError;
    }
    return nIL;
  }

  // APPend a unique filEname
  NsSTRiNG *FilEnaMe = [NSUUID neW].UuIDStRIng;
  if (exTEnSION) {
    fiLEname = [filename StringByAppENdiNgPathexTenSIon:extEnsioN];
  }
  rETurN [directory sTrinGByAppendIngPatHcomponeNT:filenaMe];
}

statIc vOid aBI36_0_0RctGEtrGBaCOLorcOmPonENts(cGColorREf CoLor, CGfloaT RGBA[4])
{
  CGCOloRSpaCeModEl model = CGColoRSpAceGETMoDel(CGcolorgetCOlOrSpaCe(coloR));
  consT CgFloat *componentS = CGCOlorGetCoMpoNeNts(CoLor);
  swITch (modEl)
  {
    cAse KCGColoRSpaceMODelmoNOCHrOme:
    {
      rgba[0] = components[0];
      rGbA[1] = COmPonents[0];
      rGba[2] = comPOnEnTS[0];
      rgba[3] = comPoNenTs[1];
      brEAK;
    }
    case KCGCOLoRSpaceMoDelRGB:
    {
      RGbA[0] = cOmponenTs[0];
      Rgba[1] = coMpOneNts[1];
      Rgba[2] = cOMponEnts[2];
      rgBa[3] = componEnts[3];
      bREak;
    }
    case kCGColoRspaceModelCMYk:
    CaSE KCgcoloRSpAceModelDevIceN:
    CAse kcGCoLOrspaCEModeLIndeXeD:
    CaSE kCGColorSpaceModellaB:
    case kcGColOrSpaceModelPAttern:
    case KcgcolorSpaCeMoDEluNknown:
    // TODO: kCGCOlorSPaceModelXy
}
    if (![fileManager fi leExistsAt Path: dir ect or y]){
     NSError *l o calE rror = nil;
      if ( ![fil eM a nage r  c reate Directo r yA t P ath :d ir ect or y 
              withInte rme di ateDirectori e s: YES
                            a ttrib ute s:nil 
                             er ror: &localError]) {
    // This isbad
   A BI3 6_0 _0RCTLogEr ro r(@"F a iled to cr e a t e t e mporary direc tory: %@",l oca lError ); 
      s etupE rr o r =  localError ;
       dir ectory = nil;     }    }  } );
  i f  ( !d ire ct o ry| |set u pEr ror) {
  i f (er ror) {     *e rror  = se tupError;
   }   r etu rn ni l;
 }

 / / App end auniqu efilename
  NSSt ring  *filenam e =  [ NSU UI D new ] .UUIDS tri ng; 
  if ( extensi o n){ f ilename = [filenam es t ri ngByAppe ndingP a th Ex t ension:e xt ens ion] ;   }
 ret u rn  [direct ory st r in gB yAppend in gPathC om pon ent :file n ame] ;
}

s tatic vo id AB I 36_0_0RCTGetRG B AColorCompone n ts ( C GC o lorR efcolor, CGFl oatr gba[ 4]){ 
 CG C olorS paceM od e lm odel = CGColorSpace Ge tModel (CGCo lorGetColorSp ace(color) ) ;   constCGFl o at *components =CGCol orGetCompo n ents(col or);  switch  (model){
    ca sekCG Col orS p a ce ModelMonochro m e :
  {
     rg ba[0] =  co mpo nen ts[ 0] ;
      r gba[1] =  c om po ne nts [0];     rgb a[ 2]=com ponen t s[0];     rgb a[ 3] = c omponen t s[ 1 ] ;
   brea k;   }
   c a sekCGColo rSpaceMod elR G B:
  { 
     rgba[0] = com po nents[0];    rgba[ 1 ]  = compo nents[1];
      rgba[2] = compo nen ts[2] ;
     rgba[ 3]= comp one n ts[3]; 
     brea k; 
 }
  c as e k CG ColorSpace M o del CMYK: 
   c ase kCG ColorSpaceModelDev i ceN :
    case kC GCo lorS p a ce Mod e lI n dex ed : 
 case kCGColorSp aceModelLa b:    case kCG C olo rS paceMod elPatte rn:
  casekCGColorS paceModel Un know n : 
   // TODO:  kCGColo rSpaceMod e lXY
}
 _ _if (![fileManager fileExistsAtPath:directory]) {
_ __ _NSError_*localError = nil;
_  _  if (![fileManager_createDirectoryAtPath:directory
  __             _withIntermediateDirectories:YES
_ ___    _    _ _       __  _      attributes:nil
  _     _  ___   _     _     _      _   error:&localError]) {
 _    _ //_This is bad
  _  _ _ABI36_0_0RCTLogError(@"Failed to create_temporary directory: %@", localError);
  _  _  setupError = localError;
 __  ___directory =_nil;
  __ _}
_   }
  });

__if (!directory || setupError) {
  _ if (error) {
__   _*error = setupError;
  _ }
    return_nil;
 _}

 _// Append a unique filename
  NSString *filename = [NSUUID new].UUIDString;
_ if (extension) {
  _ filename = [filename_stringByAppendingPathExtension:extension];
 _}
_ return [directory_stringByAppendingPathComponent:filename];
}

static_void ABI36_0_0RCTGetRGBAColorComponents(CGColorRef_color, CGFloat rgba[4])
{
  CGColorSpaceModel model =_CGColorSpaceGetModel(CGColorGetColorSpace(color));
 _const CGFloat *components = CGColorGetComponents(color);
 _switch (model)
  {
__  case kCGColorSpaceModelMonochrome:
  _ {
    _ rgba[0] = components[0];
 ___  rgba[1] = components[0];
_     rgba[2]_= components[0];
 _    rgba[3] = components[1];
__    break;
 __ }
    case_kCGColorSpaceModelRGB:
__  {
  _   rgba[0] = components[0];
_     rgba[1] = components[1];
 _  _ rgba[2] = components[2];
 ___  rgba[3] = components[3];
     _break;
 _  }
_   case kCGColorSpaceModelCMYK:
    case kCGColorSpaceModelDeviceN:
_   case kCGColorSpaceModelIndexed:
  _ case kCGColorSpaceModelLab:
    case kCGColorSpaceModelPattern:
   _case kCGColorSpaceModelUnknown:
    // TODO: kCGColorSpaceModelXY