{"version":3,"file":"lighting.cjs","sources":["../src/LightingEditor.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { onBeforeUnmount, onMounted, ref, useTemplateRef, watch } from \"vue\";\nimport {\n  LightingEditor as CoreLightingEditor,\n  type LightingConfig,\n  type LightingEditorOptions,\n  type LightingView,\n} from \"@aicut/core/lighting\";\nimport type { Theme } from \"@aicut/core\";\n\nconst props = defineProps<{\n  subjectImageUrl?: string;\n  defaultConfig?: Partial<LightingConfig>;\n  defaultView?: LightingView;\n  theme?: Theme;\n  locale?: LightingEditorOptions[\"locale\"];\n}>();\n\nconst emit = defineEmits<{\n  (e: \"ready\", api: CoreLightingEditor): void;\n  (e: \"change\", cfg: LightingConfig): void;\n}>();\n\nconst host = useTemplateRef<HTMLDivElement>(\"host\");\nlet editor: CoreLightingEditor | null = null;\n/**\n * Footer slot DOM node — set after mount so the Teleport target\n * exists before Vue tries to portal slot content into it.\n */\nconst footerSlot = ref<HTMLElement | null>(null);\n\nonMounted(() => {\n  if (!host.value) return;\n  editor = CoreLightingEditor.create({\n    container: host.value,\n    subjectImageUrl: props.subjectImageUrl,\n    config: props.defaultConfig,\n    view: props.defaultView,\n    theme: props.theme,\n    locale: props.locale,\n    onChange: (cfg) => emit(\"change\", cfg),\n  });\n  footerSlot.value = editor.controlsFooter;\n  emit(\"ready\", editor);\n});\n\nwatch(\n  () => props.theme,\n  (theme) => {\n    if (theme && editor) editor.setTheme(theme);\n  },\n);\nwatch(\n  () => props.locale,\n  (locale) => {\n    if (editor) editor.setLocale(locale ?? {});\n  },\n);\nwatch(\n  () => props.subjectImageUrl,\n  (url) => {\n    if (url && editor) editor.setSubjectImage(url);\n  },\n);\n\nonBeforeUnmount(() => {\n  editor?.destroy();\n  editor = null;\n  footerSlot.value = null;\n});\n\ndefineExpose({\n  api: (): CoreLightingEditor | null => editor,\n});\n</script>\n\n<template>\n  <div ref=\"host\" data-aicut-lighting-host=\"\">\n    <Teleport v-if=\"footerSlot\" :to=\"footerSlot\">\n      <slot name=\"controlsFooter\" />\n    </Teleport>\n  </div>\n</template>\n"],"names":["props","__props","emit","__emit","host","useTemplateRef","editor","footerSlot","ref","onMounted","CoreLightingEditor","cfg","watch","theme","locale","url","onBeforeUnmount","__expose","_createElementBlock","_createBlock","_Teleport","_renderSlot","_ctx"],"mappings":"wTAUA,MAAMA,EAAQC,EAQRC,EAAOC,EAKPC,EAAOC,EAAAA,eAA+B,MAAM,EAClD,IAAIC,EAAoC,KAKxC,MAAMC,EAAaC,EAAAA,IAAwB,IAAI,EAE/CC,OAAAA,EAAAA,UAAU,IAAM,CACTL,EAAK,QACVE,EAASI,EAAAA,eAAmB,OAAO,CACjC,UAAWN,EAAK,MAChB,gBAAiBJ,EAAM,gBACvB,OAAQA,EAAM,cACd,KAAMA,EAAM,YACZ,MAAOA,EAAM,MACb,OAAQA,EAAM,OACd,SAAWW,GAAQT,EAAK,SAAUS,CAAG,CAAA,CACtC,EACDJ,EAAW,MAAQD,EAAO,eAC1BJ,EAAK,QAASI,CAAM,EACtB,CAAC,EAEDM,EAAAA,MACE,IAAMZ,EAAM,MACXa,GAAU,CACLA,GAASP,GAAQA,EAAO,SAASO,CAAK,CAC5C,CAAA,EAEFD,EAAAA,MACE,IAAMZ,EAAM,OACXc,GAAW,CACNR,GAAQA,EAAO,UAAUQ,GAAU,CAAA,CAAE,CAC3C,CAAA,EAEFF,EAAAA,MACE,IAAMZ,EAAM,gBACXe,GAAQ,CACHA,GAAOT,GAAQA,EAAO,gBAAgBS,CAAG,CAC/C,CAAA,EAGFC,EAAAA,gBAAgB,IAAM,CACpBV,GAAA,MAAAA,EAAQ,UACRA,EAAS,KACTC,EAAW,MAAQ,IACrB,CAAC,EAEDU,EAAa,CACX,IAAK,IAAiCX,CAAA,CACvC,wBAICY,EAAAA,mBAIM,MAAA,SAJG,OAAJ,IAAId,EAAO,2BAAyB,EAAA,GACvBG,EAAA,qBAAhBY,EAAAA,YAEWC,EAAAA,SAAA,OAFkB,GAAIb,EAAA,KAAA,GAC/Bc,aAA8BC,EAAA,OAAA,gBAAA,CAAA"}