(function(c,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(c=typeof globalThis<"u"?globalThis:c||self,e(c.trame_vtk3d={},c.Vue))})(this,function(c,e){"use strict";function z(t){const o=Document.prototype.addEventListener;return Document.prototype.addEventListener=function(...a){e.unref(t).addEventListener(...a)},()=>{Document.prototype.addEventListener=o}}function C(t){const o=new Set;function a(u){["Control","Shift","Alt","Meta"].includes(u.key)&&o.add(u)}function n(u){for(const i of o)i.code===u.code&&o.delete(i)}function d(){o.size&&setTimeout(()=>{e.unref(t).focus()})}function f(u){if(e.unref(t).setPointerCapture(u.pointerId),document.activeElement!==e.unref(t)&&(e.unref(t).focus(),o.size))for(const i of o)e.unref(t).dispatchEvent(i)}function l(){o.clear()}return e.unref(t).addEventListener("pointerdown",f),e.unref(t).addEventListener("blur",d),document.addEventListener("keydown",a),document.addEventListener("keyup",n),window.addEventListener("blur",l),()=>{document.removeEventListener("keydown",a),document.removeEventListener("keyup",n),window.removeEventListener("blur",l)}}function P(t,o){const a={locateFile(){return"__trame_vtk3d/vtk3d.wasm"},canvas:e.unref(t),setWindowTitle(){}};function n(){try{o.value=new a.Scene;const d=z(t);o.value.start(),d()}catch(d){console.error(d)}}return a.onRuntimeInitialized=n,a}const L={Vtk3dScene:{emits:["on-ready","on-geometry","on-clicked","on-render","on-char","on-camera"],props:["camera","colorMaps","geometry","pathPrefix"],setup(t,{emit:o,expose:a}){const n=e.ref(null),d=e.ref(null),f=e.ref(null),l=e.ref(300),u=e.ref(300);let i=null,v=null,m=null;function p(){const r=e.unref(n);if(!e.unref(d)||!e.unref(f))return;const{clientWidth:s,clientHeight:M}=e.unref(d);l.value=s,u.value=M,r&&(r.setSize(l.value,u.value),r.render())}function w(r){r&&n.value&&(n.value.updateCamera(r),n.value.render())}function h(r){r&&n.value&&(n.value.updateGeometry(r),n.value.render())}function y(r){r&&n.value&&(n.value.updateColorMaps(r),n.value.render())}function E(r){r&&n.value&&(n.value.setPathPrefix(r),n.value.render())}function k(){h(t.geometry)}function b(){n.value&&(n.value.resetCamera(),n.value.render())}e.onMounted(async()=>{i=P(f,n),await window.vtk3d(i),await i.ready,v=C(f),e.unref(n).setCallback((r,s)=>{o(`on-${r}`,s)}),window.ResizeObserver&&(m=new ResizeObserver(p),m.observe(e.unref(d))),E(t.pathPrefix),y(t.colorMaps),w(t.camera),h(t.geometry),o("on-ready")}),e.onUnmounted(()=>{v&&(v(),v=void 0),m&&(m.disconnect(),m=void 0),i=null}),e.watch(()=>t.camera,w),e.watch(()=>t.geometry,h),e.watch(()=>t.colorMaps,y),e.watch(()=>t.pathPrefix,E);function g(r,...s){return e.unref(n)[r](...s)}function x(r,...s){return i==null?void 0:i.FS[r](...s)}return a({sceneExec:g,fsExec:x,resize:p,setPathPrefix:E,updateCamera:w,updateGeometry:h,updateColorMaps:y,update:k,resetCamera:b}),{container:d,canvas:f,canvasWidth:l,canvasHeight:u,sceneExec:g,fsExec:x,resize:p,scene:n,update:k,resetCamera:b}},template:`
    <div ref="container" style="position: relative; width: 100%; height: 100%">
      <canvas
        style="position: absolute; left: 0; top: 0; width: 100%; height: 100%;"
        ref="canvas"
        tabindex="-1"
        @contextmenu.prevent
        :width="canvasWidth"
        :height="canvasHeight"
      />
    </div>
  `}};function S(t){Object.keys(L).forEach(o=>{t.component(o,L[o])})}c.install=S,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
