export const appdelegate_header_snippet = `#import <Smartech/Smartech.h>`;

export const appdelegateSnippet = {
  fileName: 'AppDelegate.h',
  smartechHeaderSnippet: '#import <Smartech/Smartech.h>',
  hanselHeaderSnippet: '#import <SmartechNudges/Hansel.h>'

}

export const smartechBaseSnippet = {
  smartechInit: `[[Smartech sharedInstance] initSDKWithDelegate:self withLaunchOptions:launchOptions];`,
  debugLevel: `[[Smartech sharedInstance] setDebugLevel:SMTLogLevelVerbose];`,
  trackAppInstallUpdateBySmartech: `[[Smartech sharedInstance] trackAppInstallUpdateBySmartech];`,
  hanselLogSnippet: `[Hansel enableDebugLogs];`,
  didfinishRegex: /\(\s*BOOL\s*\)\s*application:(UIApplication\s*)application\s*didFinishLaunchingWithOptions:\s*\(NSDictionary\s*\*\)\s*launchOptions/,
  regexPattern: /application\s*:\s*\(UIApplication\s*\*\)\s*application\s*didFinishLaunchingWithOptions\s*:\s*\(NSDictionary\s*\*\)\s*launchOptions/
  //   // didfinishRegex: /\[super application:application didFinishLaunchingWithOptions/
}

export const deepLinkHandlerSnippet = (delayInSeconds: number) => {

  const delayValue = typeof delayInSeconds === 'number' && delayInSeconds > 0
    ? delayInSeconds
    : 1.5;

  return [
    "#pragma mark - SmartechDelegate Method",
    "- (void)handleDeeplinkActionWithURLString:(NSString *)deeplinkURLString andNotificationPayload:(NSDictionary *_Nullable)notificationPayload {",

    `dispatch_after(dispatch_time(DISPATCH_TIME_NOW, ${delayValue} * NSEC_PER_SEC), dispatch_get_main_queue(), ^{`,
    'NSLog(@"SMTLOGGER DEEPLINK: %@",deeplinkURLString);',
    '[[NSNotificationCenter defaultCenter] postNotificationName:kSMTDeeplinkNotificationIdentifier object:nil userInfo:notificationPayload];',
    "});",
    "}",
    "\n",
  ].join("\n");
}