{"version":3,"file":"index.mjs","sources":["../../../packages/control/index.ts"],"sourcesContent":["import { defineComponent, h, onMounted, onUnmounted } from \"vue\";\r\nimport { useEvent } from \"~/use/event\";\r\nimport { useMapRoot } from \"~/use/mapRoot\";\r\nimport { EVENTS, NATIVE_EVENTS, PROPS, useInit, useWatch } from \"./use\";\r\n\r\nexport const TdtControl = defineComponent({\r\n  name: \"TdtControl\",\r\n  props: PROPS,\r\n  emits: EVENTS,\r\n  setup(props, { emit, slots }) {\r\n    let controlRef = h(\"div\");\r\n\r\n    onMounted(async () => {\r\n      onUnmounted(() => tdtComponent && tdtMap?.removeControl(tdtComponent));\r\n\r\n      const tdtMap = await useMapRoot();\r\n      const tdtComponent = useInit(props);\r\n      tdtComponent.onAdd = () => controlRef.el;\r\n      tdtComponent.onRemove = () => {};\r\n      tdtMap.addControl(tdtComponent);\r\n      useEvent({ events: NATIVE_EVENTS, emit, instance: tdtComponent });\r\n      useWatch({ props, instance: tdtComponent });\r\n      emit(\"init\", tdtComponent);\r\n    });\r\n\r\n    return () => {\r\n      controlRef = h(\"div\", { class: \"tdt-control-custom\" }, slots.default?.());\r\n      return controlRef;\r\n    };\r\n  }\r\n});\r\n\r\nexport type TdtControlInstance = InstanceType<typeof TdtControl>;\r\n"],"names":["TdtControl","defineComponent","PROPS","EVENTS","props","emit","slots","controlRef","h","onMounted","onUnmounted","tdtComponent","tdtMap","useMapRoot","useInit","useEvent","NATIVE_EVENTS","useWatch","_a"],"mappings":";;;;;;AAKO,MAAMA,IAAaC,EAAgB;AAAA,EACxC,MAAM;AAAA,EACN,OAAOC;AAAA,EACP,OAAOC;AAAA,EACP,MAAMC,GAAO,EAAE,MAAAC,GAAM,OAAAC,KAAS;AACxB,QAAAC,IAAaC,EAAE,KAAK;AAExB,WAAAC,EAAU,YAAY;AACpB,MAAAC,EAAY,MAAMC,MAAgBC,KAAA,gBAAAA,EAAQ,cAAcD,GAAa;AAE/D,YAAAC,IAAS,MAAMC,EAAW,GAC1BF,IAAeG,EAAQV,CAAK;AACrB,MAAAO,EAAA,QAAQ,MAAMJ,EAAW,IACtCI,EAAa,WAAW,MAAM;AAAA,MAAC,GAC/BC,EAAO,WAAWD,CAAY,GAC9BI,EAAS,EAAE,QAAQC,GAAe,MAAAX,GAAM,UAAUM,GAAc,GAChEM,EAAS,EAAE,OAAAb,GAAO,UAAUO,EAAA,CAAc,GAC1CN,EAAK,QAAQM,CAAY;AAAA,IAAA,CAC1B,GAEM,MAAM;;AACE,aAAAJ,IAAAC,EAAE,OAAO,EAAE,OAAO,yBAAwBU,IAAAZ,EAAM,YAAN,gBAAAY,EAAA,KAAAZ,EAAiB,GACjEC;AAAA,IACT;AAAA,EAAA;AAEJ,CAAC;"}