{"version":3,"file":"index.mjs","sources":["../../../../packages/overlay/infowindow/index.ts"],"sourcesContent":["import { computed, defineComponent, h, onMounted, onUnmounted } from \"vue\";\r\nimport { useMapRoot } from \"~/use/mapRoot\";\r\nimport { useEvent } from \"~/use/event\";\r\nimport { EVENTS, NATIVE_EVENTS, PROPS, useInit, useWatch } from \"./use\";\r\n\r\nexport const TdtInfowindow = defineComponent({\r\n  name: \"TdtInfowindow\",\r\n  props: PROPS,\r\n  emits: EVENTS,\r\n  setup(props, { emit, slots }) {\r\n    const contentRef = computed(() => {\r\n      return h(\r\n        \"div\",\r\n        {\r\n          class: \"tdt-infowindow-custom\",\r\n          style: {\r\n            minWidth: props.minWidth,\r\n            maxWidth: props.maxWidth,\r\n            maxHeight: props.maxHeight,\r\n            display: slots.default && props.target ? \"block\" : \"none\"\r\n          }\r\n        },\r\n        slots.default?.()\r\n      );\r\n    });\r\n\r\n    onMounted(async () => {\r\n      onUnmounted(() => tdtMap?.closeInfoWindow());\r\n\r\n      const content = slots.default ? (contentRef.value.el as HTMLElement) : undefined;\r\n      const tdtMap = await useMapRoot();\r\n      const tdtComponent = useInit(props, content);\r\n      useEvent({ events: NATIVE_EVENTS, emit, instance: tdtComponent, emitted });\r\n      useWatch({ props, instance: tdtComponent, map: tdtMap });\r\n      emit(\"init\", tdtComponent);\r\n    });\r\n\r\n    function emitted(event: string) {\r\n      if (event === \"close\") {\r\n        emit(\"update:target\", null);\r\n      }\r\n    }\r\n\r\n    return () => contentRef.value;\r\n  }\r\n});\r\n\r\nexport type TdtInfowindowInstance = InstanceType<typeof TdtInfowindow>;\r\n"],"names":["TdtInfowindow","defineComponent","PROPS","EVENTS","props","emit","slots","contentRef","computed","h","_a","onMounted","onUnmounted","tdtMap","content","useMapRoot","tdtComponent","useInit","useEvent","NATIVE_EVENTS","emitted","useWatch","event"],"mappings":";;;;;;AAKO,MAAMA,IAAgBC,EAAgB;AAAA,EAC3C,MAAM;AAAA,EACN,OAAOC;AAAA,EACP,OAAOC;AAAA,EACP,MAAMC,GAAO,EAAE,MAAAC,GAAM,OAAAC,KAAS;AACtB,UAAAC,IAAaC,EAAS,MAAM;;AACzB,aAAAC;AAAA,QACL;AAAA,QACA;AAAA,UACE,OAAO;AAAA,UACP,OAAO;AAAA,YACL,UAAUL,EAAM;AAAA,YAChB,UAAUA,EAAM;AAAA,YAChB,WAAWA,EAAM;AAAA,YACjB,SAASE,EAAM,WAAWF,EAAM,SAAS,UAAU;AAAA,UAAA;AAAA,QAEvD;AAAA,SACAM,IAAAJ,EAAM,YAAN,gBAAAI,EAAA,KAAAJ;AAAA,MACF;AAAA,IAAA,CACD;AAED,IAAAK,EAAU,YAAY;AACR,MAAAC,EAAA,MAAMC,KAAA,gBAAAA,EAAQ,iBAAiB;AAE3C,YAAMC,IAAUR,EAAM,UAAWC,EAAW,MAAM,KAAqB,QACjEM,IAAS,MAAME,EAAW,GAC1BC,IAAeC,EAAQb,GAAOU,CAAO;AAC3C,MAAAI,EAAS,EAAE,QAAQC,GAAe,MAAAd,GAAM,UAAUW,GAAc,SAAAI,GAAS,GACzEC,EAAS,EAAE,OAAAjB,GAAO,UAAUY,GAAc,KAAKH,GAAQ,GACvDR,EAAK,QAAQW,CAAY;AAAA,IAAA,CAC1B;AAED,aAASI,EAAQE,GAAe;AAC9B,MAAIA,MAAU,WACZjB,EAAK,iBAAiB,IAAI;AAAA,IAC5B;AAGF,WAAO,MAAME,EAAW;AAAA,EAAA;AAE5B,CAAC;"}