var u=Object.defineProperty;var f=(t,e,n)=>e in t?u(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var h=(t,e,n)=>(f(t,typeof e!="symbol"?e+"":e,n),n);import{A as E,l as s,G as d,H as c,I as m,F as p}from"./index.8886c9a8.js";import{c as R}from"./factory.448392fc.js";import{d as y}from"./index.1173b4aa.js";function _(t,e){const n=t.children||[];if(Array.isArray(n))for(let o=0;o<n.length;o++){const i=n[o];if(i.id===e.id){n.splice(o,1,e);return}else _(i,e)}}function C(t,e={},n,o){return y({data(){return{rendererKey:Symbol("key"),schema:null,components:t.markRaw(e)}},render(){const{schema:i,components:r,rendererKey:a}=this,l=o?o.current:void 0;return i?t.h(n,{key:a,schema:i,components:r,model:l}):null},methods:{sendComplete(){t.nextTick(()=>{s.emit(m)})},onChange(i){this.schema=i,this.rendererKey=Symbol("key"),this.sendComplete()},onNodeChange(i){const r=i.toSchema(),a=this.schema;!a||(a.id===r.id?this.onChange(r):(_(a,r),this.sendComplete()))}},mounted(){s.on(c,this.onChange),s.on(p,this.onNodeChange),s.emit(d),s.emit(m)},unmounted(){s.off(c,this.onChange),s.off(p,this.onNodeChange)}})}class b{constructor(){h(this,"app",null);h(this,"isReady",!1);h(this,"__callback__",null)}run(e,n){const{Vue:o,components:i={},container:r=document.body}=e||{};if(!o){E.error("Vue is not defined");return}s.on(d,()=>{this.isReady=!0,this.__callback__&&(s.emit(c,this.__callback__),this.__callback__=null)});const a=C(o,i,R(o),n),l=o.createApp(a);l.mount(r),this.app=l}draw(e){this.isReady?s.emit(c,e):this.__callback__=e}stop(){this.app&&(s.off(d),s.off(c),this.app.unmount(),this.app=null)}}export{b as R};
