{"version":3,"sources":["../../../src/utils/appearance.ts"],"sourcesContent":["import type { AllAppearance, AllIconKey, AllIconOverrides } from '@novu/js/ui';\nimport { outletScopeFor } from '../context/mountPointScopes';\nimport type { OutletStore } from '../context/OutletStore';\nimport type { ReactAllAppearance, ReactIconRenderer, ReactInboxAppearance, ReactSubscriptionAppearance } from './types';\n\nexport function adaptAppearanceForJs(\n  appearance: ReactInboxAppearance | ReactSubscriptionAppearance | ReactAllAppearance,\n  outlets: OutletStore\n): AllAppearance | undefined {\n  if (!appearance) {\n    return undefined;\n  }\n  const { icons, ...restAppearance } = appearance;\n  const jsAppearance = { ...restAppearance } as AllAppearance;\n\n  if (icons) {\n    const jsIcons: AllIconOverrides = {};\n    const iconKeys = Object.keys(icons) as Array<AllIconKey>;\n\n    for (const iconKey of iconKeys) {\n      // @ts-expect-error: cant easily fix this type error\n      const reactRenderer = icons[iconKey] as ReactIconRenderer;\n\n      if (reactRenderer) {\n        jsIcons[iconKey] = (el: HTMLDivElement, props: { class?: string }) => {\n          // hosted by the scope of the mount point the engine renders this icon into, not by the store it was built on\n          return outletScopeFor(el, outlets).mount(el, reactRenderer, [props]);\n        };\n      }\n    }\n\n    // JsAppearance also has .icons directly (from JsTheme part of JsAppearance)\n    jsAppearance.icons = jsIcons;\n  } else {\n    // If original didn't have icons, ensure the clone doesn't either\n    delete jsAppearance.icons;\n  }\n\n  return jsAppearance;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,8BAA+B;AAIxB,SAAS,qBACd,YACA,SAC2B;AAC3B,MAAI,CAAC,YAAY;AACf,WAAO;AAAA,EACT;AACA,QAAM,EAAE,OAAO,GAAG,eAAe,IAAI;AACrC,QAAM,eAAe,EAAE,GAAG,eAAe;AAEzC,MAAI,OAAO;AACT,UAAM,UAA4B,CAAC;AACnC,UAAM,WAAW,OAAO,KAAK,KAAK;AAElC,eAAW,WAAW,UAAU;AAE9B,YAAM,gBAAgB,MAAM,OAAO;AAEnC,UAAI,eAAe;AACjB,gBAAQ,OAAO,IAAI,CAAC,IAAoB,UAA8B;AAEpE,qBAAO,wCAAe,IAAI,OAAO,EAAE,MAAM,IAAI,eAAe,CAAC,KAAK,CAAC;AAAA,QACrE;AAAA,MACF;AAAA,IACF;AAGA,iBAAa,QAAQ;AAAA,EACvB,OAAO;AAEL,WAAO,aAAa;AAAA,EACtB;AAEA,SAAO;AACT;","names":[]}