@woven-canvas/vue 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -167,5 +167,5 @@ ${y}
167
167
  `);l.push(f)}}),l.join(`
168
168
  `)}function W4(t,e,n={}){const{state:r}=e,{doc:o,tr:s}=r,i=t;o.descendants((a,l)=>{const c=s.mapping.map(l),u=s.mapping.map(l)+a.nodeSize;let f=null;if(a.marks.forEach(p=>{if(p!==i)return!1;f=p}),!f)return;let h=!1;if(Object.keys(n).forEach(p=>{n[p]!==f.attrs[p]&&(h=!0)}),h){const p=t.type.create({...t.attrs,...n});s.removeMark(c,u,t.type),s.addMark(c,u,p)}}),s.docChanged&&e.view.dispatch(s)}var Fh=class ES extends $h{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new ES(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function du(t){return new _4({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:o})=>{const s=We(t.getAttributes,void 0,r,o);if(s===!1||s===null)return null;const{tr:i}=e,a=r[r.length-1],l=r[0];let c=n.to;if(a){const u=l.search(/\S/),f=n.from+l.indexOf(a),h=f+a.length;if(v1(n.from,n.to,e.doc).filter(m=>m.mark.type.excluded.find(y=>y===t.type&&y!==m.mark.type)).filter(m=>m.to>f).length)return null;h<n.to&&i.delete(h,n.to),f>n.from&&i.delete(n.from+u,f),c=n.from+u+a.length,i.addMark(n.from+u,c,t.type.create(s||{})),i.removeStoredMark(t.type)}}})}function R1(t){return d.customRef((e,n)=>({get(){return e(),t},set(r){t=r,requestAnimationFrame(()=>{requestAnimationFrame(()=>{n()})})}}))}var U4=class extends O4{constructor(t={}){return super(t),this.contentComponent=null,this.appContext=null,this.reactiveState=R1(this.view.state),this.reactiveExtensionStorage=R1(this.extensionStorage),this.on("beforeTransaction",({nextState:e})=>{this.reactiveState.value=e,this.reactiveExtensionStorage.value=this.extensionStorage}),d.markRaw(this)}get state(){return this.reactiveState?this.reactiveState.value:this.view.state}get storage(){return this.reactiveExtensionStorage?this.reactiveExtensionStorage.value:super.storage}registerPlugin(t,e){const n=super.registerPlugin(t,e);return this.reactiveState&&(this.reactiveState.value=n),n}unregisterPlugin(t){const e=super.unregisterPlugin(t);return this.reactiveState&&e&&(this.reactiveState.value=e),e}},H4=d.defineComponent({name:"EditorContent",props:{editor:{default:null,type:Object}},setup(t){const e=d.ref(),n=d.getCurrentInstance();return d.watchEffect(()=>{const r=t.editor;r&&r.options.element&&e.value&&d.nextTick(()=>{var o;if(!e.value||!((o=r.view.dom)!=null&&o.parentNode))return;const s=d.unref(e.value);e.value.append(...r.view.dom.parentNode.childNodes),r.contentComponent=n.ctx._,n&&(r.appContext={...n.appContext,provides:n.provides}),r.setOptions({element:s}),r.createNodeViews()})}),d.onBeforeUnmount(()=>{const r=t.editor;r&&(r.contentComponent=null,r.appContext=null)}),{rootEl:e}},render(){return d.h("div",{ref:t=>{this.rootEl=t}})}});d.defineComponent({name:"NodeViewContent",props:{as:{type:String,default:"div"}},render(){return d.h(this.as,{style:{whiteSpace:"pre-wrap"},"data-node-view-content":""})}}),d.defineComponent({name:"NodeViewWrapper",props:{as:{type:String,default:"div"}},inject:["onDragStart","decorationClasses"],render(){var t,e;return d.h(this.as,{class:this.decorationClasses,style:{whiteSpace:"normal"},"data-node-view-wrapper":"",onDragstart:this.onDragStart},(e=(t=this.$slots).default)==null?void 0:e.call(t))}}),d.defineComponent({name:"MarkViewContent",props:{as:{type:String,default:"span"}},render(){return d.h(this.as,{style:{whiteSpace:"inherit"},"data-mark-view-content":""})}});var Z4=Fh.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
169
169
 
170
- `):""}),z1=Z4,$1="&nbsp;",K4=" ",Y4=Fh.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Fi(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);const r=e.parseInline(n);return r.length===1&&r[0].type==="text"&&(r[0].text===$1||r[0].text===K4)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e)=>{if(!t)return"";const n=Array.isArray(t.content)?t.content:[];return n.length===0?$1:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),L1=Y4,q4=Fh.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),V1=q4,F1=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]},J4=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,G4=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,X4=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Q4=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,eL=nl.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return F1("strong",{...Fi(this.options.HTMLAttributes,t),children:F1("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[uu({find:J4,type:this.type}),uu({find:X4,type:this.type})]},addPasteRules(){return[du({find:G4,type:this.type}),du({find:Q4,type:this.type})]}}),j1=eL,tL=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,nL=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,rL=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,oL=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,sL=nl.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",Fi(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[uu({find:tL,type:this.type}),uu({find:rL,type:this.type})]},addPasteRules(){return[du({find:nL,type:this.type}),du({find:oL,type:this.type})]}}),W1=sL,iL=nl.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",Fi(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const o=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!o)return;const s=o[2].trim();return{type:"underline",raw:o[0],text:s,tokens:n.inlineTokens(s)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),U1=iL,aL=Je.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).some(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),H1=aL,lL=20,Z1=(t,e=0)=>{const n=[];return!t.children.length||e>lL||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...Z1(r,e+1))}),n},cL=t=>{if(!t.children.length)return;const e=Z1(t);e&&e.forEach(n=>{var r,o;const s=n.getAttribute("style"),i=(o=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:o.getAttribute("style");n.setAttribute("style",`${i};${s}`)})},jh=nl.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&cL(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",Fi(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(o=>o.type===this.type).some(o=>Object.values(o.attrs).some(s=>!!s))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),uL=Je.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(o=>o.trim()).filter(Boolean);for(let o=r.length-1;o>=0;o-=1){const s=r[o].split(":");if(s.length>=2){const i=s[0].trim().toLowerCase(),a=s.slice(1).join(":").trim();if(i==="background-color")return a.replace(/['"]+/g,"")}}}return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),K1=Je.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(o=>o.trim()).filter(Boolean);for(let o=r.length-1;o>=0;o-=1){const s=r[o].split(":");if(s.length>=2){const i=s[0].trim().toLowerCase(),a=s.slice(1).join(":").trim();if(i==="color")return a.replace(/['"]+/g,"")}}}return(e=t.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),dL=Je.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>t.style.fontFamily,renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),fL=Je.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),hL=Je.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>t.style.lineHeight,renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});Je.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(uL.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(K1.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(dL.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(fL.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(hL.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(jh.configure(this.options.textStyle)),t}});var Y1=K1;function pL(t={}){return new wt({view(e){return new mL(e,t)}})}class mL{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let s=i=>{this[o](i)};return e.dom.addEventListener(o,s),{name:o,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,o=this.editorView.dom,s=o.getBoundingClientRect(),i=s.width/o.offsetWidth,a=s.height/o.offsetHeight;if(n){let f=e.nodeBefore,h=e.nodeAfter;if(f||h){let p=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(p){let m=p.getBoundingClientRect(),g=f?m.bottom:m.top;f&&h&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*a;r={left:m.left,right:m.right,top:g-y,bottom:g+y}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),h=this.width/2*i;r={left:f.left-h,right:f.left+h,top:f.top,bottom:f.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,u;if(!l||l==document.body&&getComputedStyle(l).position=="static")c=-pageXOffset,u=-pageYOffset;else{let f=l.getBoundingClientRect(),h=f.width/l.offsetWidth,p=f.height/l.offsetHeight;c=f.left-l.scrollLeft*h,u=f.top-l.scrollTop*p}this.element.style.left=(r.left-c)/i+"px",this.element.style.top=(r.top-u)/a+"px",this.element.style.width=(r.right-r.left)/i+"px",this.element.style.height=(r.bottom-r.top)/a+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),o=r&&r.type.spec.disableDropCursor,s=typeof o=="function"?o(this.editorView,n,e):o;if(n&&!s){let i=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=fv(this.editorView.state.doc,i,this.editorView.dragging.slice);a!=null&&(i=a)}this.setCursor(i),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class ot extends be{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return ot.valid(r)?new ot(r):be.near(r)}content(){return K.empty}eq(e){return e instanceof ot&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new ot(e.resolve(n.pos))}getBookmark(){return new Wh(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!gL(e)||!yL(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let o=n.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&ot.valid(e))return e;let o=e.pos,s=null;for(let i=e.depth;;i--){let a=e.node(i);if(n>0?e.indexAfter(i)<a.childCount:e.index(i)>0){s=a.child(n>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;o+=n;let l=e.doc.resolve(o);if(ot.valid(l))return l}for(;;){let i=n>0?s.firstChild:s.lastChild;if(!i){if(s.isAtom&&!s.isText&&!ae.isSelectable(s)){e=e.doc.resolve(o+s.nodeSize*n),r=!1;continue e}break}s=i,o+=n;let a=e.doc.resolve(o);if(ot.valid(a))return a}return null}}}ot.prototype.visible=!1,ot.findFrom=ot.findGapCursorFrom,be.jsonID("gapcursor",ot);class Wh{constructor(e){this.pos=e}map(e){return new Wh(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return ot.valid(n)?new ot(n):be.near(n)}}function q1(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function gL(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||q1(o.type))return!0;if(o.inlineContent)return!1}}return!0}function yL(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||q1(o.type))return!0;if(o.inlineContent)return!1}}return!0}function wL(){return new wt({props:{decorations:SL,createSelectionBetween(t,e,n){return e.pos==n.pos&&ot.valid(n)?new ot(n):null},handleClick:kL,handleKeyDown:vL,handleDOMEvents:{beforeinput:bL}}})}const vL=Qk({ArrowLeft:fu("horiz",-1),ArrowRight:fu("horiz",1),ArrowUp:fu("vert",-1),ArrowDown:fu("vert",1)});function fu(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,s){let i=r.selection,a=e>0?i.$to:i.$from,l=i.empty;if(i instanceof ye){if(!s.endOfTextblock(n)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let c=ot.findGapCursorFrom(a,e,l);return c?(o&&o(r.tr.setSelection(new ot(c))),!0):!1}}function kL(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!ot.valid(r))return!1;let o=t.posAtCoords({left:n.clientX,top:n.clientY});return o&&o.inside>-1&&ae.isSelectable(t.state.doc.nodeAt(o.inside))?!1:(t.dispatch(t.state.tr.setSelection(new ot(r))),!0)}function bL(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof ot))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let o=D.empty;for(let i=r.length-1;i>=0;i--)o=D.from(r[i].createAndFill(null,o));let s=t.state.tr.replace(n.pos,n.pos,new K(o,0,0));return s.setSelection(ye.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function SL(t){if(!(t.selection instanceof ot))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",nt.create(t.doc,[on.widget(t.selection.head,e,{key:"gapcursor"})])}var hu=200,Nt=function(){};Nt.prototype.append=function(e){return e.length?(e=Nt.from(e),!this.length&&e||e.length<hu&&this.leafAppend(e)||this.length<hu&&e.leafPrepend(this)||this.appendInner(e)):this},Nt.prototype.prepend=function(e){return e.length?Nt.from(e).append(this):this},Nt.prototype.appendInner=function(e){return new EL(this,e)},Nt.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Nt.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))},Nt.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Nt.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)},Nt.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(s,i){return o.push(e(s,i))},n,r),o},Nt.from=function(e){return e instanceof Nt?e:e&&e.length?new J1(e):Nt.empty};var J1=function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(o,s){return o==0&&s==this.length?this:new e(this.values.slice(o,s))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,s,i,a){for(var l=s;l<i;l++)if(o(this.values[l],a+l)===!1)return!1},e.prototype.forEachInvertedInner=function(o,s,i,a){for(var l=s-1;l>=i;l--)if(o(this.values[l],a+l)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=hu)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=hu)return new e(o.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e}(Nt);Nt.empty=new J1([]);var EL=function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,o,s,i){var a=this.left.length;if(o<a&&this.left.forEachInner(r,o,Math.min(s,a),i)===!1||s>a&&this.right.forEachInner(r,Math.max(o-a,0),Math.min(this.length,s)-a,i+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,o,s,i){var a=this.left.length;if(o>a&&this.right.forEachInvertedInner(r,o-a,Math.max(s,a)-a,i+a)===!1||s<a&&this.left.forEachInvertedInner(r,Math.min(o,a),s,i)===!1)return!1},e.prototype.sliceInner=function(r,o){if(r==0&&o==this.length)return this;var s=this.left.length;return o<=s?this.left.slice(r,o):r>=s?this.right.slice(r-s,o-s):this.left.slice(r,s).append(this.right.slice(0,o-s))},e.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new e(o,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(Nt);const CL=500;class rr{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,s;n&&(o=this.remapping(r,this.items.length),s=o.maps.length);let i=e.tr,a,l,c=[],u=[];return this.items.forEach((f,h)=>{if(!f.step){o||(o=this.remapping(r,h+1),s=o.maps.length),s--,u.push(f);return}if(o){u.push(new Cr(f.map));let p=f.step.map(o.slice(s)),m;p&&i.maybeStep(p).doc&&(m=i.mapping.maps[i.mapping.maps.length-1],c.push(new Cr(m,void 0,void 0,c.length+u.length))),s--,m&&o.appendMap(m,s)}else i.maybeStep(f.step);if(f.selection)return a=o?f.selection.map(o.slice(s)):f.selection,l=new rr(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:i,selection:a}}addTransform(e,n,r,o){let s=[],i=this.eventCount,a=this.items,l=!o&&a.length?a.get(a.length-1):null;for(let u=0;u<e.steps.length;u++){let f=e.steps[u].invert(e.docs[u]),h=new Cr(e.mapping.maps[u],f,n),p;(p=l&&l.merge(h))&&(h=p,u?s.pop():a=a.slice(0,a.length-1)),s.push(h),n&&(i++,n=void 0),o||(l=h)}let c=i-r.depth;return c>xL&&(a=_L(a,c),i-=c),new rr(a.append(s),i)}remapping(e,n){let r=new za;return this.items.forEach((o,s)=>{let i=o.mirrorOffset!=null&&s-o.mirrorOffset>=e?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,i)},e,n),r}addMaps(e){return this.eventCount==0?this:new rr(this.items.append(e.map(n=>new Cr(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],o=Math.max(0,this.items.length-n),s=e.mapping,i=e.steps.length,a=this.eventCount;this.items.forEach(h=>{h.selection&&a--},o);let l=n;this.items.forEach(h=>{let p=s.getMirror(--l);if(p==null)return;i=Math.min(i,p);let m=s.maps[p];if(h.step){let g=e.steps[p].invert(e.docs[p]),y=h.selection&&h.selection.map(s.slice(l+1,p));y&&a++,r.push(new Cr(m,g,y))}else r.push(new Cr(m))},o);let c=[];for(let h=n;h<i;h++)c.push(new Cr(s.maps[h]));let u=this.items.slice(0,o).append(c).append(r),f=new rr(u,a);return f.emptyItemCount()>CL&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,o=[],s=0;return this.items.forEach((i,a)=>{if(a>=e)o.push(i),i.selection&&s++;else if(i.step){let l=i.step.map(n.slice(r)),c=l&&l.getMap();if(r--,c&&n.appendMap(c,r),l){let u=i.selection&&i.selection.map(n.slice(r));u&&s++;let f=new Cr(c.invert(),l,u),h,p=o.length-1;(h=o.length&&o[p].merge(f))?o[p]=h:o.push(f)}}else i.map&&r--},this.items.length,0),new rr(Nt.from(o.reverse()),s)}}rr.empty=new rr(Nt.empty,0);function _L(t,e){let n;return t.forEach((r,o)=>{if(r.selection&&e--==0)return n=o,!1}),t.slice(n)}class Cr{constructor(e,n,r,o){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new Cr(n.getMap().invert(),n,this.selection)}}}class Ho{constructor(e,n,r,o,s){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=o,this.prevComposition=s}}const xL=20;function TL(t,e,n,r){let o=n.getMeta(Ds),s;if(o)return o.historyState;n.getMeta(IL)&&(t=new Ho(t.done,t.undone,null,0,-1));let i=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(i&&i.getMeta(Ds))return i.getMeta(Ds).redo?new Ho(t.done.addTransform(n,void 0,r,pu(e)),t.undone,G1(n.mapping.maps),t.prevTime,t.prevComposition):new Ho(t.done,t.undone.addTransform(n,void 0,r,pu(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let a=n.getMeta("composition"),l=t.prevTime==0||!i&&t.prevComposition!=a&&(t.prevTime<(n.time||0)-r.newGroupDelay||!ML(n,t.prevRanges)),c=i?Uh(t.prevRanges,n.mapping):G1(n.mapping.maps);return new Ho(t.done.addTransform(n,l?e.selection.getBookmark():void 0,r,pu(e)),rr.empty,c,n.time,a??t.prevComposition)}else return(s=n.getMeta("rebased"))?new Ho(t.done.rebased(n,s),t.undone.rebased(n,s),Uh(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Ho(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Uh(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function ML(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,o)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&o>=e[s]&&(n=!0)}),n}function G1(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,o,s,i)=>e.push(s,i));return e}function Uh(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let o=e.map(t[r],1),s=e.map(t[r+1],-1);o<=s&&n.push(o,s)}return n}function AL(t,e,n){let r=pu(e),o=Ds.get(e).spec.config,s=(n?t.undone:t.done).popEvent(e,r);if(!s)return null;let i=s.selection.resolve(s.transform.doc),a=(n?t.done:t.undone).addTransform(s.transform,e.selection.getBookmark(),o,r),l=new Ho(n?a:s.remaining,n?s.remaining:a,null,0,-1);return s.transform.setSelection(i).setMeta(Ds,{redo:n,historyState:l})}let Hh=!1,X1=null;function pu(t){let e=t.plugins;if(X1!=e){Hh=!1,X1=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Hh=!0;break}}return Hh}const Ds=new tn("history"),IL=new tn("closeHistory");function NL(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new wt({key:Ds,state:{init(){return new Ho(rr.empty,rr.empty,null,0,-1)},apply(e,n,r){return TL(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,o=r=="historyUndo"?eb:r=="historyRedo"?tb:null;return!o||!e.editable?!1:(n.preventDefault(),o(e.state,e.dispatch))}}}})}function Q1(t,e){return(n,r)=>{let o=Ds.getState(n);if(!o||(t?o.undone:o.done).eventCount==0)return!1;if(r){let s=AL(o,n,t);s&&r(e?s.scrollIntoView():s)}return!0}}const eb=Q1(!1,!0),tb=Q1(!0,!0);Je.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc;if(((t==null?void 0:t.mode)||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new wt({key:new tn("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const o=this.options.limit;if(o==null||o===0){t=!0;return}const s=this.storage.characters({node:r.doc});if(s>o){const i=s-o,a=0,l=i;console.warn(`[CharacterCount] Initial content exceeded limit of ${o} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(a,l);return t=!0,c}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const o=this.storage.characters({node:n.doc}),s=this.storage.characters({node:e.doc});if(s<=r||o>r&&s>r&&s<=o)return!0;if(o>r&&s>r&&s>o||!e.getMeta("paste"))return!1;const a=e.selection.$head.pos,l=s-r,c=a-l,u=a;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>r)}})]}}),Je.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[pL(this.options)]}}),Je.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new wt({key:new tn("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:o}=e,s=[];if(!n||!r)return nt.create(t,[]);let i=0;this.options.mode==="deepest"&&t.descendants((l,c)=>{if(l.isText)return;if(!(o>=c&&o<=c+l.nodeSize-1))return!1;i+=1});let a=0;return t.descendants((l,c)=>{if(l.isText||!(o>=c&&o<=c+l.nodeSize-1))return!1;if(a+=1,this.options.mode==="deepest"&&i-a>0||this.options.mode==="shallowest"&&a>1)return this.options.mode==="deepest";s.push(on.node(c,c+l.nodeSize,{class:this.options.className}))}),nt.create(t,s)}}})]}}),Je.create({name:"gapCursor",addProseMirrorPlugins(){return[wL()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=We(oe(t,"allowGapCursor",n)))!=null?e:null}}});var nb="placeholder";function BL(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}Je.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:nb,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${BL(this.options.dataAttribute)}`:`data-${nb}`;return[new wt({key:new tn("placeholder"),props:{decorations:({doc:e,selection:n})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:o}=n,s=[];if(!r)return null;const i=this.editor.isEmpty;return e.descendants((a,l)=>{const c=o>=l&&o<=l+a.nodeSize,u=!a.isLeaf&&su(a);if((c||!this.options.showOnlyCurrent)&&u){const f=[this.options.emptyNodeClass];i&&f.push(this.options.emptyEditorClass);const h=on.node(l,l+a.nodeSize,{class:f.join(" "),[t]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:a,pos:l,hasAnchor:c}):this.options.placeholder});s.push(h)}return this.options.includeChildren}),nt.create(e,s)}}})]}}),Je.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new wt({key:new tn("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||q$(n.selection)||t.view.dragging?null:nt.create(n.doc,[on.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function rb({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}Je.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new tn(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,o])=>o).filter(o=>(this.options.notAfter||[]).concat(n).includes(o.name));return[new wt({key:e,appendTransaction:(o,s,i)=>{const{doc:a,tr:l,schema:c}=i,u=e.getState(i),f=a.content.size,h=c.nodes[n];if(u)return l.insert(f,h.create())},state:{init:(o,s)=>{const i=s.tr.doc.lastChild;return!rb({node:i,types:r})},apply:(o,s)=>{if(!o.docChanged||o.getMeta("__uniqueIDTransaction"))return s;const i=o.doc.lastChild;return!rb({node:i,types:r})}}})]}});var PL=Je.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>eb(t,e),redo:()=>({state:t,dispatch:e})=>tb(t,e)}},addProseMirrorPlugins(){return[NL(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}});function Zo(t,e){const n=d.inject(Rn);if(!n)throw new Error("useComponents must be used within a WovenCanvas component");const r=d.shallowRef(new Map),o=new Map;function s(a){if(o.has(a))return;const l=n.getEditor();if(l){const u=l._getContext();if(R(u,a,e)){const f=new Map(r.value);f.set(a,e.snapshot(u,a)),r.value=f}else{const f=new Map(r.value);f.set(a,null),r.value=f}}const c=n.subscribeComponent(a,e.name,u=>{const f=new Map(r.value);f.set(a,u),r.value=f});o.set(a,c)}function i(a){const l=o.get(a);if(l){l(),o.delete(a);const c=new Map(r.value);c.delete(a),r.value=c}}return d.watch(()=>d.toValue(t),(a,l)=>{const c=new Set(a),u=new Set(l??[]);for(const f of u)c.has(f)||i(f);for(const f of c)u.has(f)||s(f)},{immediate:!0}),d.onUnmounted(()=>{for(const a of o.values())a();o.clear()}),r}function ob(){const t=d.inject(Rn);if(!t)throw new Error("useImageCreation must be used within a WovenCanvas component");const{nextEditorTick:e}=ut();function n(s){return new Promise((i,a)=>{const l=new window.Image;l.onload=()=>{i({width:l.naturalWidth,height:l.naturalHeight}),URL.revokeObjectURL(l.src)},l.onerror=()=>{a(new Error("Failed to load image")),URL.revokeObjectURL(l.src)},l.src=URL.createObjectURL(s)})}async function r(s,i,a,l={}){const{maxSize:c=400}=l,u=await n(s),f=await e(),h=Math.min(1,c/Math.max(u.width,u.height));let p=Math.round(u.width*h),m=Math.round(u.height*h);const g=Ut.read(f);g.enabled&&(p=Math.max(g.colWidth,Math.round(p/g.colWidth)*g.colWidth),m=Math.max(g.rowHeight,Math.round(m/g.rowHeight)*g.rowHeight));const y=Bt(f);ee(f,y,T);const w=T.write(f,y);w.tag="image",w.position[0]=i-p/2,w.position[1]=a-m/2,w.size[0]=p,w.size[1]=m,Ut.snapPosition(f,w.position);const v=crypto.randomUUID();ee(f,y,as);const b=as.write(f,y);b.identifier=v,b.uploadState=mr.Pending,ee(f,y,ea);const S=ea.write(f,y);return S.width=u.width,S.height=u.height,S.alt=s.name,ee(f,y,me,{id:crypto.randomUUID()}),(t==null?void 0:t.getAssetManager())&&o(y,v,s),y}async function o(s,i,a){const l=t==null?void 0:t.getAssetManager();if(l)try{await l.upload(i,a,{filename:a.name,mimeType:a.type});const c=await e(),u=as.write(c,s);u.uploadState=mr.Complete}catch{const c=await e(),u=as.write(c,s);u.uploadState=mr.Failed}}return{getImageDimensions:n,createImageBlock:r}}function sb(t){const e=d.inject(Rn);if(!e)throw new Error("useQuery must be used within a WovenCanvas component");const n=d.shallowRef([]),r=ie(f=>f.with(...t)),o=new Map;let s=!1;function i(f){const h=e.getEditor();if(!h)return{refs:{},unsubscribes:[]};const p=h._getContext(),m={},g=[];for(const y of t){const w=d.shallowRef(y.snapshot(p,f));m[y.name]=w;const v=e.subscribeComponent(f,y.name,b=>{w.value=b});g.push(v)}return{refs:m,unsubscribes:g}}function a(f){const h=o.get(f);if(h){for(const p of h.unsubscribes)p();o.delete(f)}}function l(){const f=[];for(const[h,p]of o)f.push({entityId:h,...p.refs});return f}function c(f){if(!s){const g=r.current(f);for(const y of g)o.set(y,i(y));n.value=l(),s=!0;return}const h=r.added(f),p=r.removed(f);let m=!1;for(const g of p)a(g),m=!0;for(const g of h)o.has(g)||(o.set(g,i(g)),m=!0);m&&(n.value=l())}const u=e.registerTickCallback(c);return d.onUnmounted(()=>{u();for(const f of o.keys())a(f)}),n}function jt(t){const e=d.inject(Rn);if(!e)throw new Error("useSingleton must be used within a WovenCanvas component");const n=d.shallowRef(t.default()),r=e.getEditor();if(r){const i=r._getContext();n.value=t.snapshot(i)}const o=e.subscribeSingleton(t.name,i=>{n.value=i??{}});let s=null;return r||(s=e.registerTickCallback(()=>{const i=e.getEditor();if(i){const a=i._getContext();n.value=t.snapshot(a),s==null||s(),s=null}})),d.onUnmounted(()=>{o(),s==null||s()}),n}function OL(t,e,n){if(n===0)return{width:t,height:e};if(Math.abs(n-Math.PI/2)<1e-4)return{width:e,height:t};const r=Math.abs(Math.cos(n)),o=Math.abs(Math.sin(n)),s=(e-o/r*t)/(r-o*o/r);return{width:t/r-s*o/r,height:s}}function Zh(t,e,n){const r=t.closest(".wov-block");if(!r){const E=t.getBoundingClientRect();return{width:E.width,height:E.height,left:0,top:0}}const o=window.getComputedStyle(r).transform,s=new DOMMatrix(o),i=Math.atan2(s.b,s.a),a=t.getBoundingClientRect(),l=new DOMPoint(a.left+a.width/2,a.top+a.height/2),c=e.value.left,u=e.value.top,f=e.value.zoom,h=new DOMMatrix;h.translateSelf(-c*f,-u*f),h.scaleSelf(f,f),h.invertSelf();const p=h.transformPoint(l),m=h.transformPoint(new DOMPoint(a.left,a.top)),g=h.transformPoint(new DOMPoint(a.right,a.bottom)),y=g.x-m.x,w=g.y-m.y,{width:v,height:b}=OL(y,w,-i),S=n.value.left,k=n.value.top;return{width:v,height:b,left:p.x-v/2-S,top:p.y-b/2-k}}function ib(t){if(t.startsWith("#"))return t.toUpperCase();const e=t.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(e){const n=parseInt(e[1],10).toString(16).padStart(2,"0"),r=parseInt(e[2],10).toString(16).padStart(2,"0"),o=parseInt(e[3],10).toString(16).padStart(2,"0");return`#${n}${r}${o}`.toUpperCase()}return t}function rl(t){const e=Math.round(t.red),n=Math.round(t.green),r=Math.round(t.blue),o=Math.round(t.alpha);return o<255?"#"+[e,n,r,o].map(s=>{const i=s.toString(16);return i.length===1?`0${i}`:i}).join(""):"#"+[e,n,r].map(s=>{const i=s.toString(16);return i.length===1?`0${i}`:i}).join("")}function Kh(t){t=t.replace(/^#/,"");let e,n,r,o=255;if(t.length===6)e=parseInt(t.slice(0,2),16),n=parseInt(t.slice(2,4),16),r=parseInt(t.slice(4,6),16);else if(t.length===8)e=parseInt(t.slice(0,2),16),n=parseInt(t.slice(2,4),16),r=parseInt(t.slice(4,6),16),o=parseInt(t.slice(6,8),16);else return null;return{red:e,green:n,blue:r,alpha:o}}function ab(t){const e=Kh(t);if(!e)return{h:0,s:100,v:100,a:255};const n=e.red/255,r=e.green/255,o=e.blue/255,s=Math.max(n,r,o),i=Math.min(n,r,o),a=s-i;let l=0;const c=s===0?0:a/s*100,u=s*100;if(a!==0)switch(s){case n:l=((r-o)/a+(r<o?6:0))*60;break;case r:l=((o-n)/a+2)*60;break;case o:l=((n-r)/a+4)*60;break}return{h:l,s:c,v:u,a:e.alpha}}function lb(t){const e=t.h/360,n=t.s/100,r=t.v/100;let o=0,s=0,i=0;const a=Math.floor(e*6),l=e*6-a,c=r*(1-n),u=r*(1-l*n),f=r*(1-(1-l)*n);switch(a%6){case 0:o=r,s=f,i=c;break;case 1:o=u,s=r,i=c;break;case 2:o=c,s=r,i=f;break;case 3:o=c,s=u,i=r;break;case 4:o=f,s=c,i=r;break;case 5:o=r,s=c,i=u;break}const h=p=>Math.round(p*255).toString(16).padStart(2,"0");return`#${h(o)}${h(s)}${h(i)}`}function cb(t){const e=t.h/360,n=t.s/100,r=t.v/100;let o=0,s=0,i=0;const a=Math.floor(e*6),l=e*6-a,c=r*(1-n),u=r*(1-l*n),f=r*(1-(1-l)*n);switch(a%6){case 0:o=r,s=f,i=c;break;case 1:o=u,s=r,i=c;break;case 2:o=c,s=r,i=f;break;case 3:o=c,s=u,i=r;break;case 4:o=f,s=c,i=r;break;case 5:o=r,s=c,i=u;break}const h=m=>Math.round(m*255).toString(16).padStart(2,"0"),p=Math.round(t.a).toString(16).padStart(2,"0");return t.a<255?`#${h(o)}${h(s)}${h(i)}${p}`:`#${h(o)}${h(s)}${h(i)}`}const hn=d.shallowRef(null),Yh=d.shallowRef(null),qh=d.shallowRef(null),Ko=d.ref(0);function ol(){const t={hasEditor:d.computed(()=>hn.value!==null),isBold:d.computed(()=>{var o;return Ko.value,((o=hn.value)==null?void 0:o.isActive("bold"))??!1}),isItalic:d.computed(()=>{var o;return Ko.value,((o=hn.value)==null?void 0:o.isActive("italic"))??!1}),isUnderline:d.computed(()=>{var o;return Ko.value,((o=hn.value)==null?void 0:o.isActive("underline"))??!1}),alignment:d.computed(()=>{Ko.value;const o=hn.value;return o?o.isActive({textAlign:"center"})?"center":o.isActive({textAlign:"right"})?"right":o.isActive({textAlign:"justify"})?"justify":"left":"left"}),color:d.computed(()=>{Ko.value;const o=hn.value;if(!o)return null;const i=o.getAttributes("textStyle").color??null;return i?ib(i):null})},e={toggleBold(){const o=hn.value;if(!o)return;const{from:s,to:i}=o.state.selection,a=s===i;let l=o.chain().focus();a&&(l=l.selectAll()),l=l.toggleBold(),a&&(l=l.setTextSelection(i)),l.run()},toggleItalic(){const o=hn.value;if(!o)return;const{from:s,to:i}=o.state.selection,a=s===i;let l=o.chain().focus();a&&(l=l.selectAll()),l=l.toggleItalic(),a&&(l=l.setTextSelection(i)),l.run()},toggleUnderline(){const o=hn.value;if(!o)return;const{from:s,to:i}=o.state.selection,a=s===i;let l=o.chain().focus();a&&(l=l.selectAll()),l=l.toggleUnderline(),a&&(l=l.setTextSelection(i)),l.run()},setAlignment(o){const s=hn.value;s&&s.chain().selectAll().setTextAlign(o).run()},setColor(o){const s=hn.value;if(!s)return;const{from:i,to:a}=s.state.selection;i===a?s.chain().focus().selectAll().setColor(o).setTextSelection(a).run():s.chain().focus().setColor(o).run()}};function n(o,s,i){hn.value=o,qh.value=s,Yh.value=i,o.on("selectionUpdate",()=>{Ko.value++}),o.on("transaction",()=>{Ko.value++})}function r(){hn.value=null,qh.value=null,Yh.value=null}return{editor:hn,blockElement:Yh,textElement:qh,state:t,commands:e,updateCounter:Ko,register:n,unregister:r}}const Fn=[z1,L1,V1,jh,Y1,j1,W1,U1,H1.configure({types:["paragraph"],alignments:["left","center","right","justify"],defaultAlignment:"left"})];function DL(t){return t.type==="text"&&typeof t.text=="string"}function Rs(t,e){if(DL(t)){e(t);return}if(t.content)for(const n of t.content)Rs(n,e)}function Jh(t,e){if(t.type==="paragraph"){e(t);return}if(t.content)for(const n of t.content)Jh(n,e)}function RL(t,e){var n;return((n=t.marks)==null?void 0:n.some(r=>r.type===e))??!1}function zL(t){var r,o;const e=(r=t.marks)==null?void 0:r.find(s=>s.type==="textStyle"),n=((o=e==null?void 0:e.attrs)==null?void 0:o.color)??null;return n?ib(n):null}function $L(t,e){if(!t.trim())return!1;const n=Uo(t,Fn);let r=!1,o=!0,s=0;return Rs(n,i=>{s++,RL(i,e)?r=!0:o=!1}),s===0?!1:o?!0:r?null:!1}function LL(t){if(!t.trim())return"left";const e=Uo(t,Fn);let n="left";return Jh(e,r=>{var s;const o=(s=r.attrs)==null?void 0:s.textAlign;o&&(n=o)}),n}function VL(t){if(!t.trim())return null;const e=Uo(t,Fn);let n=null;return Rs(e,r=>{n===null&&(n=zL(r))}),n}function Gh(t,e){if(!t.trim())return t;const n=Uo(t,Fn);return Rs(n,r=>{const o=r.marks??[];o.findIndex(i=>i.type===e)===-1&&(r.marks=[...o,{type:e}])}),ru(n,Fn)}function Xh(t,e){if(!t.trim())return t;const n=Uo(t,Fn);return Rs(n,r=>{const o=r.marks??[];r.marks=o.filter(s=>s.type!==e)}),ru(n,Fn)}function FL(t,e){if(!t.trim())return t;const n=Uo(t,Fn);return Jh(n,r=>{r.attrs={...r.attrs,textAlign:e}}),ru(n,Fn)}function jL(t,e){if(!t.trim())return t;const n=Uo(t,Fn);return Rs(n,r=>{const o=r.marks??[],s=o.findIndex(i=>i.type==="textStyle");s!==-1?(o[s]={...o[s],attrs:{...o[s].attrs,color:e}},r.marks=o):r.marks=[...o,{type:"textStyle",attrs:{color:e}}]}),ru(n,Fn)}function ub(t){const e=document.querySelector(`[data-entity-id="${t}"]`);if(!e)return null;const n=e.firstElementChild;return n||e.querySelector(".wov-editable-text")}function db(t,e,n,r){var l;const o=t.cloneNode(!0);o.style.position="absolute",o.style.visibility="hidden",o.style.pointerEvents="none",o.style.top="0",o.style.left="0";const s=o.classList.contains("wov-editable-text")?o:o.querySelector(".wov-editable-text");s&&(s.style.fontSize=`${r.fontSizePx}px`,s.style.fontFamily=r.fontFamily);const i=o.querySelector(".ProseMirror, .tiptap");i?i.innerHTML=r.content:s?s.innerHTML=r.content:o.innerHTML=r.content,(l=t.parentElement)==null||l.appendChild(o);const a=Zh(o,e,n);return o.remove(),a}function fb(t){const{nextEditorTick:e}=ut(),n=Zo(t,gt),r=jt(we),o=jt(_t),s=ol(),i={hasTextEntities:d.computed(()=>{for(const h of n.value.values())if(h)return!0;return!1}),hasTextContent:d.computed(()=>{for(const h of n.value.values()){if(!h)continue;const p=h.content?Uo(h.content,Fn):null;if(p){let m=!1;if(Rs(p,g=>{var y;(y=g.text)!=null&&y.trim()&&(m=!0)}),m)return!0}}return!1}),isBold:d.computed(()=>a("bold")),isItalic:d.computed(()=>a("italic")),isUnderline:d.computed(()=>a("underline")),alignment:d.computed(()=>{let h=null;for(const p of n.value.values()){if(!p)continue;const m=LL(p.content);if(h===null)h=m;else if(h!==m)return null}return h??"left"}),color:d.computed(()=>{let h=null,p=!1;for(const m of n.value.values()){if(!m)continue;const g=VL(m.content);if(!p)h=g,p=!0;else if(h!==g)return null}return h}),fontSize:d.computed(()=>{let h=null,p=!1;for(const m of n.value.values())if(m){if(!p)h=m.fontSizePx,p=!0;else if(h!==m.fontSizePx)return null}return h}),fontFamily:d.computed(()=>{let h=null,p=!1;for(const m of n.value.values())if(m){if(!p)h=m.fontFamily,p=!0;else if(h!==m.fontFamily)return null}return h})};function a(h){let p=null,m=!1;for(const g of n.value.values()){if(!g)continue;const y=$L(g.content,h);if(!m)p=y,m=!0;else if(p!==y)return null}return p}const l={toggleBold(){u(h=>i.isBold.value?Xh(h,"bold"):Gh(h,"bold"))},toggleItalic(){u(h=>i.isItalic.value?Xh(h,"italic"):Gh(h,"italic"))},toggleUnderline(){u(h=>i.isUnderline.value?Xh(h,"underline"):Gh(h,"underline"))},setAlignment(h){f(p=>FL(p,h))},setColor(h){f(p=>jL(p,h))},setFontSize(h){c(p=>({...p,fontSizePx:h}),p=>{p.fontSizePx=h})},setFontFamily(h){c(p=>({...p,fontFamily:h}),p=>{p.fontFamily=h})}};function c(h,p){const m=d.toValue(t),g=[];for(const y of m){const w=n.value.get(y);if(!w)continue;const v=ub(y);if(v){const b=db(v,r,o,h(w));g.push({entityId:y,...b})}}e(y=>{for(const w of m)p(gt.write(y,w));for(const{entityId:w,width:v,height:b,left:S,top:k}of g){const E=T.write(y,w);E.size=[v,b],E.position=[S,k]}d.nextTick(()=>{s.updateCounter.value++})})}function u(h){const p=d.toValue(t),m=[];for(const g of p){const y=n.value.get(g);if(!y)continue;const w=h(y.content),v=ub(g);if(v){const b=db(v,r,o,{...y,content:w});m.push({entityId:g,content:w,...b})}else m.push({entityId:g,content:w,width:0,height:0,left:0,top:0})}e(g=>{for(const{entityId:y,content:w,width:v,height:b,left:S,top:k}of m){const E=gt.write(g,y);if(E.content=w,v>0&&b>0){const _=T.write(g,y);_.size=[v,b],_.position=[S,k]}}})}function f(h){const p=d.toValue(t);e(m=>{for(const g of p){const y=gt.write(m,g);y.content=h(y.content)}})}return{state:i,commands:l}}function _r(t){const e=ol(),n=fb(t),r=e.state.hasEditor;return{state:d.reactive({hasTextToFormat:d.computed(()=>r.value||n.state.hasTextEntities.value),hasEditor:r,hasTextContent:d.computed(()=>n.state.hasTextContent.value),showTextMenuButtons:d.computed(()=>r.value||n.state.hasTextContent.value),isBold:d.computed(()=>r.value?e.state.isBold.value:n.state.isBold.value===!0),isItalic:d.computed(()=>r.value?e.state.isItalic.value:n.state.isItalic.value===!0),isUnderline:d.computed(()=>r.value?e.state.isUnderline.value:n.state.isUnderline.value===!0),alignment:d.computed(()=>r.value?e.state.alignment.value:n.state.alignment.value??"left"),color:d.computed(()=>r.value?e.state.color.value:n.state.color.value),fontSize:d.computed(()=>n.state.fontSize.value),fontFamily:d.computed(()=>n.state.fontFamily.value)}),commands:{toggleBold(){r.value?e.commands.toggleBold():n.commands.toggleBold()},toggleItalic(){r.value?e.commands.toggleItalic():n.commands.toggleItalic()},toggleUnderline(){r.value?e.commands.toggleUnderline():n.commands.toggleUnderline()},setAlignment(i){r.value?e.commands.setAlignment(i):n.commands.setAlignment(i)},setColor(i){r.value?e.commands.setColor(i):n.commands.setColor(i)},setFontSize(i){n.commands.setFontSize(i)},setFontFamily(i){n.commands.setFontFamily(i)}}}}function Qh(t){const e=jt(we),n=jt(_t),r=jt(af),o=jt(Xn),{nextEditorTick:s}=ut();let i=!1,a=null;function l(u,f){const{entityId:h}=d.toValue(t.blockData),p=d.toValue(t.minWidth)??0,m=d.toValue(t.minHeight)??0,g=Math.max(f.width,p),y=Math.max(f.height,m),w=T.read(u,h),v=Math.abs(w.size[0]-g)>.5,b=Math.abs(w.size[1]-y)>.5;if(!v&&!b)return;const S=T.write(u,h);S.size=[g,y],S.position=[f.left,f.top],r.value.transformBoxId!==null&&nf.spawn(u,{transformBoxId:r.value.transformBoxId})}d.watch(()=>o.value,()=>{const u=t.containerRef.value;u&&i&&(a=Zh(u,e,n)),s(f=>{const h=WL(f);i&&!h&&a&&(l(f,a),a=null),i=h})},{flush:"sync"});function c(u){const{content:f,...h}=u;s(p=>{const{entityId:m}=d.toValue(t.blockData);if(gt.read(p,m).content!==f){const y=gt.write(p,m);y.content=f}l(p,h)})}return{handleEditEnd:c}}function WL(t){const e=Xn.read(t);return e.state===_e.Dragging&&e.draggedEntity!==null&&R(t,e.draggedEntity,qe)&&qe.read(t,e.draggedEntity).kind===Gn.Stretch}function ep(){const t=d.inject(_f);if(!t)throw new Error("useToolbar must be used within a Toolbar component");return{activeTool:t.activeTool,heldTool:t.heldTool,setTool:t.setTool,dragOutTool:t.dragOutTool,onToolPointerDown:t.onToolPointerDown,onToolPointerUp:t.onToolPointerUp,isActive:e=>d.computed(()=>t.activeTool.value===e)}}const UL=500,HL=1500;function hb(){const t=d.ref(null),e=d.ref(!1),n=d.ref(!1);let r=null,o=null;function s(){r&&(clearTimeout(r),r=null),o&&(clearTimeout(o),o=null)}function i(c,u){s(),t.value={text:c,anchor:u},n.value?e.value=!0:r=setTimeout(()=>{e.value=!0,n.value=!0,r=null},UL)}function a(){s(),e.value=!1,t.value=null,n.value&&(o=setTimeout(()=>{n.value=!1,o=null},HL))}function l(){s(),e.value=!1,t.value=null,n.value=!1}return{activeTooltip:d.readonly(t),isVisible:d.readonly(e),isWarmedUp:d.readonly(n),show:i,hide:a,reset:l}}function Yo(){const t=d.inject(F0);if(!t)throw new Error("useTooltipSingleton must be used within a WovenCanvas component");return t}const ZL={key:1},KL=["innerHTML"],YL=50,qL=300,mu=d.defineComponent({__name:"EditableText",props:{blockElement:{},entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},emits:["editEnd"],setup(t,{expose:e,emit:n}){var k;const r=t,o=n,s=Tt(r.entityId,gt),i=jt(we),a=jt(_t),l=ol(),{nextEditorTick:c}=ut(),u=jt(On),f=d.ref(null);e({editableTextRef:f});const h=d.ref(((k=s.value)==null?void 0:k.content)??""),p=d.shallowRef(null);function m(E,_){var P;const M=s.value;return!M||M.constrainWidth||(((P=_.clipboardData)==null?void 0:P.getData("text/plain"))??"").length>YL&&c(V=>{const Z=gt.write(V,r.entityId);Z.constrainWidth=!0;const A=T.read(V,r.entityId),F=Math.max(A.size[0],qL),Y=T.write(V,r.entityId);Y.size=[F,A.size[1]],sy.spawn(V),Si.spawn(V)}),!1}function g(){var E,_;return new U4({extensions:[z1,L1,V1,jh,Y1,j1,W1,U1,H1.configure({types:["paragraph"],alignments:["left","center","right","justify"],defaultAlignment:((E=s.value)==null?void 0:E.defaultAlignment)??"left"}),PL],content:((_=s.value)==null?void 0:_.content)??"",editable:!0,parseOptions:{preserveWhitespace:!0},editorProps:{handlePaste:m}})}d.watch(()=>r.edited,async E=>{if(E&&f.value){if(p.value=g(),await y(p.value),!r.blockElement)return;l.register(p.value,f.value,r.blockElement)}else p.value&&(l.unregister(),w(p.value),p.value.destroy(),p.value=null)},{immediate:!0});async function y(E){var P;const _=(P=u.value)==null?void 0:P.position,M=a.value;await d.nextTick(),await new Promise(V=>requestAnimationFrame(V));const I=f.value;if(_&&M&&I){const V=_[0]+M.left,Z=_[1]+M.top,A=E.view.posAtCoords({left:V,top:Z});if(A){E.chain().focus().setTextSelection(A.pos).run();return}}E.commands.focus("start")}function w(E){let _=E.getHTML();const I=_.replace(/<[^>]*>/g,"").trim().length>0;I||(_=""),h.value=_,c(P=>{var Y,ce;const V=Xt(P,r.block.tag);if(!I&&((Y=V.editOptions)!=null&&Y.removeWhenTextEmpty)){st(P,r.entityId);return}const Z=(ce=f.value)==null?void 0:ce.closest(".wov-block"),A=(Z==null?void 0:Z.firstElementChild)??f.value;if(!A){console.warn("EditableText: no element to measure");return}const F=Zh(A,i,a);o("editEnd",{content:_,...F})})}d.watch(()=>{var E;return(E=s.value)==null?void 0:E.content},E=>{E!==void 0&&(p.value?p.value.getHTML()!==E&&p.value.commands.setContent(E,{emitUpdate:!1}):h.value=E)});const v=d.computed(()=>{const E=s.value;return E?{fontFamily:E.fontFamily,fontSize:`${E.fontSizePx}px`,lineHeight:E.lineHeight,letterSpacing:`${E.letterSpacingEm}em`,width:E.constrainWidth?"100%":"fit-content",whiteSpace:E.constrainWidth?"pre-wrap":"pre",minWidth:"2px",wordBreak:"break-word",pointerEvents:r.edited?"auto":"none",userSelect:r.edited?"auto":"none"}:{}});function b(E){E.key==="Control"||E.key==="Meta"||E.stopPropagation()}function S(E){r.edited&&E.stopPropagation()}return d.onUnmounted(()=>{p.value&&(l.unregister(),p.value.destroy(),p.value=null)}),(E,_)=>(d.openBlock(),d.createElementBlock("div",{ref_key:"editableTextRef",ref:f,class:"wov-editable-text",style:d.normalizeStyle(v.value),onKeydown:b,onPointerdown:S,onPointermove:S,onPointerup:S},[p.value?(d.openBlock(),d.createBlock(d.unref(H4),{key:0,editor:p.value},null,8,["editor"])):(d.openBlock(),d.createElementBlock("div",ZL,[d.createElementVNode("div",{class:"tiptap ProseMirror",innerHTML:h.value},null,8,KL)]))],36))}}),JL={class:"wov-shape-svg",viewBox:"0 0 100 100",preserveAspectRatio:"none"},GL=["d","fill","stroke","stroke-width","stroke-dasharray"],pb=d.defineComponent({__name:"ShapeBlock",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},setup(t){const e=t,n=Tt(e.entityId,Nn),r=Tt(e.entityId,cs),o=d.ref(null),s={[mt.Top]:"flex-start",[mt.Center]:"center",[mt.Bottom]:"flex-end"},i=d.computed(()=>n.value?`rgba(${n.value.fillRed}, ${n.value.fillGreen}, ${n.value.fillBlue}, ${(n.value.fillAlpha??255)/255})`:"rgba(0, 0, 0, 0)"),a=d.computed(()=>n.value?n.value.strokeKind===Ct.None?"none":`rgba(${n.value.strokeRed}, ${n.value.strokeGreen}, ${n.value.strokeBlue}, ${n.value.strokeAlpha/255})`:"rgba(0, 0, 0, 1)"),l=d.computed(()=>{var g;return((g=n.value)==null?void 0:g.strokeWidth)??2}),c=d.computed(()=>{var g;return((g=n.value)==null?void 0:g.strokeKind)??Ct.Solid}),u=d.computed(()=>{var g;return Ba[((g=n.value)==null?void 0:g.kind)??"rectangle"]??Ba.rectangle}),f=d.computed(()=>{const g=l.value;switch(c.value){case Ct.Dashed:return`${g*3} ${g*3}`;case Ct.None:return"";case Ct.Solid:default:return""}}),h=d.computed(()=>{var g;return{overflow:e.edited?"visible":"hidden",alignItems:s[((g=r.value)==null?void 0:g.value)??mt.Top]}}),{nextEditorTick:p}=ut();function m(g){p(y=>{if(gt.read(y,e.entityId).content===g.content)return;const v=gt.write(y,e.entityId);v.content=g.content})}return(g,y)=>(d.openBlock(),d.createElementBlock("div",{ref_key:"containerRef",ref:o,class:"wov-shape-block"},[(d.openBlock(),d.createElementBlock("svg",JL,[d.createElementVNode("path",{d:u.value,fill:i.value,stroke:a.value,"stroke-width":l.value,"stroke-dasharray":f.value,"stroke-linecap":"round","stroke-linejoin":"round","vector-effect":"non-scaling-stroke"},null,8,GL)])),d.createElementVNode("div",{class:"wov-shape-content",style:d.normalizeStyle(h.value)},[d.createVNode(mu,d.mergeProps(e,{"block-element":o.value,onEditEnd:m}),null,16,["block-element"])],4)],512))}}),XL=["data-text-empty"],mb=d.defineComponent({__name:"TextBlock",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},setup(t){const e=t,n=d.ref(null),r=Tt(e.entityId,gt),o=d.computed(()=>{var l;return(((l=r.value)==null?void 0:l.content)??"").replace(/<[^>]*>/g,"").trim().length===0}),{handleEditEnd:s}=Qh({blockData:e,containerRef:n});return(i,a)=>(d.openBlock(),d.createElementBlock("div",{ref_key:"containerRef",ref:n,class:"wov-text-block","data-text-empty":o.value||void 0},[d.createVNode(mu,d.mergeProps(e,{"block-element":n.value,onEditEnd:d.unref(s)}),null,16,["block-element","onEditEnd"])],8,XL))}}),gu=Math.min,zs=Math.max,yu=Math.round,wu=Math.floor,xr=t=>({x:t,y:t}),QL={left:"right",right:"left",bottom:"top",top:"bottom"},eV={start:"end",end:"start"};function gb(t,e,n){return zs(t,gu(e,n))}function vu(t,e){return typeof t=="function"?t(e):t}function $s(t){return t.split("-")[0]}function ku(t){return t.split("-")[1]}function yb(t){return t==="x"?"y":"x"}function wb(t){return t==="y"?"height":"width"}const tV=new Set(["top","bottom"]);function qo(t){return tV.has($s(t))?"y":"x"}function vb(t){return yb(qo(t))}function nV(t,e,n){n===void 0&&(n=!1);const r=ku(t),o=vb(t),s=wb(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(i=bu(i)),[i,bu(i)]}function rV(t){const e=bu(t);return[tp(t),e,tp(e)]}function tp(t){return t.replace(/start|end/g,e=>eV[e])}const kb=["left","right"],bb=["right","left"],oV=["top","bottom"],sV=["bottom","top"];function iV(t,e,n){switch(t){case"top":case"bottom":return n?e?bb:kb:e?kb:bb;case"left":case"right":return e?oV:sV;default:return[]}}function aV(t,e,n,r){const o=ku(t);let s=iV($s(t),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),e&&(s=s.concat(s.map(tp)))),s}function bu(t){return t.replace(/left|right|bottom|top/g,e=>QL[e])}function lV(t){return{top:0,right:0,bottom:0,left:0,...t}}function cV(t){return typeof t!="number"?lV(t):{top:t,right:t,bottom:t,left:t}}function Su(t){const{x:e,y:n,width:r,height:o}=t;return{width:r,height:o,top:n,left:e,right:e+r,bottom:n+o,x:e,y:n}}function Sb(t,e,n){let{reference:r,floating:o}=t;const s=qo(e),i=vb(e),a=wb(i),l=$s(e),c=s==="y",u=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,h=r[a]/2-o[a]/2;let p;switch(l){case"top":p={x:u,y:r.y-o.height};break;case"bottom":p={x:u,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch(ku(e)){case"start":p[i]-=h*(n&&c?-1:1);break;case"end":p[i]+=h*(n&&c?-1:1);break}return p}async function uV(t,e){var n;e===void 0&&(e={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=t,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=vu(e,t),m=cV(p),y=a[h?f==="floating"?"reference":"floating":f],w=Su(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(y)))==null||n?y:y.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),v=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,b=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),S=await(s.isElement==null?void 0:s.isElement(b))?await(s.getScale==null?void 0:s.getScale(b))||{x:1,y:1}:{x:1,y:1},k=Su(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:b,strategy:l}):v);return{top:(w.top-k.top+m.top)/S.y,bottom:(k.bottom-w.bottom+m.bottom)/S.y,left:(w.left-k.left+m.left)/S.x,right:(k.right-w.right+m.right)/S.x}}const dV=async(t,e,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(e));let c=await i.getElementRects({reference:t,floating:e,strategy:o}),{x:u,y:f}=Sb(c,r,l),h=r,p={},m=0;for(let y=0;y<a.length;y++){var g;const{name:w,fn:v}=a[y],{x:b,y:S,data:k,reset:E}=await v({x:u,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:c,platform:{...i,detectOverflow:(g=i.detectOverflow)!=null?g:uV},elements:{reference:t,floating:e}});u=b??u,f=S??f,p={...p,[w]:{...p[w],...k}},E&&m<=50&&(m++,typeof E=="object"&&(E.placement&&(h=E.placement),E.rects&&(c=E.rects===!0?await i.getElementRects({reference:t,floating:e,strategy:o}):E.rects),{x:u,y:f}=Sb(c,h,l)),y=-1)}return{x:u,y:f,placement:h,strategy:o,middlewareData:p}},fV=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:g=!0,...y}=vu(t,e);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const w=$s(o),v=qo(a),b=$s(a)===a,S=await(l.isRTL==null?void 0:l.isRTL(c.floating)),k=h||(b||!g?[bu(a)]:rV(a)),E=m!=="none";!h&&E&&k.push(...aV(a,g,m,S));const _=[a,...k],M=await l.detectOverflow(e,y),I=[];let P=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&I.push(M[w]),f){const F=nV(o,i,S);I.push(M[F[0]],M[F[1]])}if(P=[...P,{placement:o,overflows:I}],!I.every(F=>F<=0)){var V,Z;const F=(((V=s.flip)==null?void 0:V.index)||0)+1,Y=_[F];if(Y&&(!(f==="alignment"?v!==qo(Y):!1)||P.every(j=>qo(j.placement)===v?j.overflows[0]>0:!0)))return{data:{index:F,overflows:P},reset:{placement:Y}};let ce=(Z=P.filter(se=>se.overflows[0]<=0).sort((se,j)=>se.overflows[1]-j.overflows[1])[0])==null?void 0:Z.placement;if(!ce)switch(p){case"bestFit":{var A;const se=(A=P.filter(j=>{if(E){const X=qo(j.placement);return X===v||X==="y"}return!0}).map(j=>[j.placement,j.overflows.filter(X=>X>0).reduce((X,he)=>X+he,0)]).sort((j,X)=>j[1]-X[1])[0])==null?void 0:A[0];se&&(ce=se);break}case"initialPlacement":ce=a;break}if(o!==ce)return{reset:{placement:ce}}}return{}}}},hV=new Set(["left","top"]);async function pV(t,e){const{placement:n,platform:r,elements:o}=t,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=$s(n),a=ku(n),l=qo(n)==="y",c=hV.has(i)?-1:1,u=s&&l?-1:1,f=vu(e,t);let{mainAxis:h,crossAxis:p,alignmentAxis:m}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof m=="number"&&(p=a==="end"?m*-1:m),l?{x:p*u,y:h*c}:{x:h*c,y:p*u}}const mV=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=e,l=await pV(e,t);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},gV=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:o,platform:s}=e,{mainAxis:i=!0,crossAxis:a=!1,limiter:l={fn:w=>{let{x:v,y:b}=w;return{x:v,y:b}}},...c}=vu(t,e),u={x:n,y:r},f=await s.detectOverflow(e,c),h=qo($s(o)),p=yb(h);let m=u[p],g=u[h];if(i){const w=p==="y"?"top":"left",v=p==="y"?"bottom":"right",b=m+f[w],S=m-f[v];m=gb(b,m,S)}if(a){const w=h==="y"?"top":"left",v=h==="y"?"bottom":"right",b=g+f[w],S=g-f[v];g=gb(b,g,S)}const y=l.fn({...e,[p]:m,[h]:g});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[p]:i,[h]:a}}}}}};function Eu(){return typeof window<"u"}function Ls(t){return np(t)?(t.nodeName||"").toLowerCase():"#document"}function xn(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Tr(t){var e;return(e=(np(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function np(t){return Eu()?t instanceof Node||t instanceof xn(t).Node:!1}function or(t){return Eu()?t instanceof Element||t instanceof xn(t).Element:!1}function Mr(t){return Eu()?t instanceof HTMLElement||t instanceof xn(t).HTMLElement:!1}function Eb(t){return!Eu()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof xn(t).ShadowRoot}const yV=new Set(["inline","contents"]);function sl(t){const{overflow:e,overflowX:n,overflowY:r,display:o}=sr(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!yV.has(o)}const wV=new Set(["table","td","th"]);function vV(t){return wV.has(Ls(t))}const kV=[":popover-open",":modal"];function Cu(t){return kV.some(e=>{try{return t.matches(e)}catch{return!1}})}const bV=["transform","translate","scale","rotate","perspective"],SV=["transform","translate","scale","rotate","perspective","filter"],EV=["paint","layout","strict","content"];function rp(t){const e=op(),n=or(t)?sr(t):t;return bV.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||SV.some(r=>(n.willChange||"").includes(r))||EV.some(r=>(n.contain||"").includes(r))}function CV(t){let e=Jo(t);for(;Mr(e)&&!ji(e);){if(rp(e))return e;if(Cu(e))return null;e=Jo(e)}return null}function op(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const _V=new Set(["html","body","#document"]);function ji(t){return _V.has(Ls(t))}function sr(t){return xn(t).getComputedStyle(t)}function _u(t){return or(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Jo(t){if(Ls(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Eb(t)&&t.host||Tr(t);return Eb(e)?e.host:e}function Cb(t){const e=Jo(t);return ji(e)?t.ownerDocument?t.ownerDocument.body:t.body:Mr(e)&&sl(e)?e:Cb(e)}function il(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const o=Cb(t),s=o===((r=t.ownerDocument)==null?void 0:r.body),i=xn(o);if(s){const a=sp(i);return e.concat(i,i.visualViewport||[],sl(o)?o:[],a&&n?il(a):[])}return e.concat(o,il(o,[],n))}function sp(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function _b(t){const e=sr(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const o=Mr(t),s=o?t.offsetWidth:n,i=o?t.offsetHeight:r,a=yu(n)!==s||yu(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function ip(t){return or(t)?t:t.contextElement}function Wi(t){const e=ip(t);if(!Mr(e))return xr(1);const n=e.getBoundingClientRect(),{width:r,height:o,$:s}=_b(e);let i=(s?yu(n.width):n.width)/r,a=(s?yu(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const xV=xr(0);function xb(t){const e=xn(t);return!op()||!e.visualViewport?xV:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function TV(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==xn(t)?!1:e}function Vs(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const o=t.getBoundingClientRect(),s=ip(t);let i=xr(1);e&&(r?or(r)&&(i=Wi(r)):i=Wi(t));const a=TV(s,n,r)?xb(s):xr(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,u=o.width/i.x,f=o.height/i.y;if(s){const h=xn(s),p=r&&or(r)?xn(r):r;let m=h,g=sp(m);for(;g&&r&&p!==m;){const y=Wi(g),w=g.getBoundingClientRect(),v=sr(g),b=w.left+(g.clientLeft+parseFloat(v.paddingLeft))*y.x,S=w.top+(g.clientTop+parseFloat(v.paddingTop))*y.y;l*=y.x,c*=y.y,u*=y.x,f*=y.y,l+=b,c+=S,m=xn(g),g=sp(m)}}return Su({width:u,height:f,x:l,y:c})}function xu(t,e){const n=_u(t).scrollLeft;return e?e.left+n:Vs(Tr(t)).left+n}function Tb(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-xu(t,n),o=n.top+e.scrollTop;return{x:r,y:o}}function MV(t){let{elements:e,rect:n,offsetParent:r,strategy:o}=t;const s=o==="fixed",i=Tr(r),a=e?Cu(e.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=xr(1);const u=xr(0),f=Mr(r);if((f||!f&&!s)&&((Ls(r)!=="body"||sl(i))&&(l=_u(r)),Mr(r))){const p=Vs(r);c=Wi(r),u.x=p.x+r.clientLeft,u.y=p.y+r.clientTop}const h=i&&!f&&!s?Tb(i,l):xr(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+h.x,y:n.y*c.y-l.scrollTop*c.y+u.y+h.y}}function AV(t){return Array.from(t.getClientRects())}function IV(t){const e=Tr(t),n=_u(t),r=t.ownerDocument.body,o=zs(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),s=zs(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+xu(t);const a=-n.scrollTop;return sr(r).direction==="rtl"&&(i+=zs(e.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Mb=25;function NV(t,e){const n=xn(t),r=Tr(t),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const u=op();(!u||u&&e==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=xu(r);if(c<=0){const u=r.ownerDocument,f=u.body,h=getComputedStyle(f),p=u.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,m=Math.abs(r.clientWidth-f.clientWidth-p);m<=Mb&&(s-=m)}else c<=Mb&&(s+=c);return{width:s,height:i,x:a,y:l}}const BV=new Set(["absolute","fixed"]);function PV(t,e){const n=Vs(t,!0,e==="fixed"),r=n.top+t.clientTop,o=n.left+t.clientLeft,s=Mr(t)?Wi(t):xr(1),i=t.clientWidth*s.x,a=t.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function Ab(t,e,n){let r;if(e==="viewport")r=NV(t,n);else if(e==="document")r=IV(Tr(t));else if(or(e))r=PV(e,n);else{const o=xb(t);r={x:e.x-o.x,y:e.y-o.y,width:e.width,height:e.height}}return Su(r)}function Ib(t,e){const n=Jo(t);return n===e||!or(n)||ji(n)?!1:sr(n).position==="fixed"||Ib(n,e)}function OV(t,e){const n=e.get(t);if(n)return n;let r=il(t,[],!1).filter(a=>or(a)&&Ls(a)!=="body"),o=null;const s=sr(t).position==="fixed";let i=s?Jo(t):t;for(;or(i)&&!ji(i);){const a=sr(i),l=rp(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&BV.has(o.position)||sl(i)&&!l&&Ib(t,i))?r=r.filter(u=>u!==i):o=a,i=Jo(i)}return e.set(t,r),r}function DV(t){let{element:e,boundary:n,rootBoundary:r,strategy:o}=t;const i=[...n==="clippingAncestors"?Cu(e)?[]:OV(e,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,u)=>{const f=Ab(e,u,o);return c.top=zs(f.top,c.top),c.right=gu(f.right,c.right),c.bottom=gu(f.bottom,c.bottom),c.left=zs(f.left,c.left),c},Ab(e,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function RV(t){const{width:e,height:n}=_b(t);return{width:e,height:n}}function zV(t,e,n){const r=Mr(e),o=Tr(e),s=n==="fixed",i=Vs(t,!0,s,e);let a={scrollLeft:0,scrollTop:0};const l=xr(0);function c(){l.x=xu(o)}if(r||!r&&!s)if((Ls(e)!=="body"||sl(o))&&(a=_u(e)),r){const p=Vs(e,!0,s,e);l.x=p.x+e.clientLeft,l.y=p.y+e.clientTop}else o&&c();s&&!r&&o&&c();const u=o&&!r&&!s?Tb(o,a):xr(0),f=i.left+a.scrollLeft-l.x-u.x,h=i.top+a.scrollTop-l.y-u.y;return{x:f,y:h,width:i.width,height:i.height}}function ap(t){return sr(t).position==="static"}function Nb(t,e){if(!Mr(t)||sr(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Tr(t)===n&&(n=n.ownerDocument.body),n}function Bb(t,e){const n=xn(t);if(Cu(t))return n;if(!Mr(t)){let o=Jo(t);for(;o&&!ji(o);){if(or(o)&&!ap(o))return o;o=Jo(o)}return n}let r=Nb(t,e);for(;r&&vV(r)&&ap(r);)r=Nb(r,e);return r&&ji(r)&&ap(r)&&!rp(r)?n:r||CV(t)||n}const $V=async function(t){const e=this.getOffsetParent||Bb,n=this.getDimensions,r=await n(t.floating);return{reference:zV(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function LV(t){return sr(t).direction==="rtl"}const VV={convertOffsetParentRelativeRectToViewportRelativeRect:MV,getDocumentElement:Tr,getClippingRect:DV,getOffsetParent:Bb,getElementRects:$V,getClientRects:AV,getDimensions:RV,getScale:Wi,isElement:or,isRTL:LV};function Pb(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function FV(t,e){let n=null,r;const o=Tr(t);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=t.getBoundingClientRect(),{left:u,top:f,width:h,height:p}=c;if(a||e(),!h||!p)return;const m=wu(f),g=wu(o.clientWidth-(u+h)),y=wu(o.clientHeight-(f+p)),w=wu(u),b={rootMargin:-m+"px "+-g+"px "+-y+"px "+-w+"px",threshold:zs(0,gu(1,l))||1};let S=!0;function k(E){const _=E[0].intersectionRatio;if(_!==l){if(!S)return i();_?i(!1,_):r=setTimeout(()=>{i(!1,1e-7)},1e3)}_===1&&!Pb(c,t.getBoundingClientRect())&&i(),S=!1}try{n=new IntersectionObserver(k,{...b,root:o.ownerDocument})}catch{n=new IntersectionObserver(k,b)}n.observe(t)}return i(!0),s}function Ob(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=ip(t),u=o||s?[...c?il(c):[],...il(e)]:[];u.forEach(w=>{o&&w.addEventListener("scroll",n,{passive:!0}),s&&w.addEventListener("resize",n)});const f=c&&a?FV(c,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(w=>{let[v]=w;v&&v.target===c&&p&&(p.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var b;(b=p)==null||b.observe(e)})),n()}),c&&!l&&p.observe(c),p.observe(e));let m,g=l?Vs(t):null;l&&y();function y(){const w=Vs(t);g&&!Pb(g,w)&&n(),g=w,m=requestAnimationFrame(y)}return n(),()=>{var w;u.forEach(v=>{o&&v.removeEventListener("scroll",n),s&&v.removeEventListener("resize",n)}),f==null||f(),(w=p)==null||w.disconnect(),p=null,l&&cancelAnimationFrame(m)}}const Tu=mV,Mu=gV,Au=fV,jV=(t,e,n)=>{const r=new Map,o={platform:VV,...n},s={...o.platform,_c:r};return dV(t,e,{...o,platform:s})};function WV(t){return t!=null&&typeof t=="object"&&"$el"in t}function Db(t){if(WV(t)){const e=t.$el;return np(e)&&Ls(e)==="#comment"?null:e}return t}function al(t){return typeof t=="function"?t():d.unref(t)}function Rb(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function zb(t,e){const n=Rb(t);return Math.round(e*n)/n}function Iu(t,e,n){n===void 0&&(n={});const r=n.whileElementsMounted,o=d.computed(()=>{var _;return(_=al(n.open))!=null?_:!0}),s=d.computed(()=>al(n.middleware)),i=d.computed(()=>{var _;return(_=al(n.placement))!=null?_:"bottom"}),a=d.computed(()=>{var _;return(_=al(n.strategy))!=null?_:"absolute"}),l=d.computed(()=>{var _;return(_=al(n.transform))!=null?_:!0}),c=d.computed(()=>Db(t.value)),u=d.computed(()=>Db(e.value)),f=d.ref(0),h=d.ref(0),p=d.ref(a.value),m=d.ref(i.value),g=d.shallowRef({}),y=d.ref(!1),w=d.computed(()=>{const _={position:p.value,left:"0",top:"0"};if(!u.value)return _;const M=zb(u.value,f.value),I=zb(u.value,h.value);return l.value?{..._,transform:"translate("+M+"px, "+I+"px)",...Rb(u.value)>=1.5&&{willChange:"transform"}}:{position:p.value,left:M+"px",top:I+"px"}});let v;function b(){if(c.value==null||u.value==null)return;const _=o.value;jV(c.value,u.value,{middleware:s.value,placement:i.value,strategy:a.value}).then(M=>{f.value=M.x,h.value=M.y,p.value=M.strategy,m.value=M.placement,g.value=M.middlewareData,y.value=_!==!1})}function S(){typeof v=="function"&&(v(),v=void 0)}function k(){if(S(),r===void 0){b();return}if(c.value!=null&&u.value!=null){v=r(c.value,u.value,b);return}}function E(){o.value||(y.value=!1)}return d.watch([s,i,a,o],b,{flush:"sync"}),d.watch([c,u],k,{flush:"sync"}),d.watch(o,E,{flush:"sync"}),d.getCurrentScope()&&d.onScopeDispose(S),{x:d.shallowReadonly(f),y:d.shallowReadonly(h),strategy:d.shallowReadonly(p),placement:d.shallowReadonly(m),middlewareData:d.shallowReadonly(g),isPositioned:d.shallowReadonly(y),floatingStyles:w,update:b}}const UV=["menu-open"],jn=d.defineComponent({__name:"MenuDropdown",props:{title:{},disabled:{type:Boolean},placement:{default:"top"},offsetPx:{default:8}},emits:["open","close"],setup(t,{emit:e}){const n=t,r=e,o=d.inject("containerRef"),s=d.inject($0,null),i=d.inject(L0,0),a=Math.random().toString(36).slice(2);d.provide(L0,i+1);const{show:l,hide:c}=Yo(),u=d.ref(!1);s&&d.watch(()=>s.value.get(i),b=>{b!==void 0&&b!==a&&u.value&&(u.value=!1)});const f=d.ref(null),h=d.ref(null),{floatingStyles:p}=Iu(f,h,{placement:n.placement,middleware:[Tu(n.offsetPx),Au(),Mu({padding:8})],whileElementsMounted:Ob});function m(){n.disabled||(u.value=!u.value)}function g(){u.value=!1}function y(b){var M,I,P;const S=b.target,k=(M=f.value)==null?void 0:M.contains(S),E=(I=h.value)==null?void 0:I.contains(S),_=(P=S.closest)==null?void 0:P.call(S,".wov-menu-dropdown");!k&&!E&&!_&&g()}function w(){n.title&&f.value&&!u.value&&l(n.title,f.value)}function v(){c()}return d.watch(u,b=>{b?(c(),document.addEventListener("click",y,!0),s&&(s.value.set(i,a),s.value=new Map(s.value)),r("open")):(document.removeEventListener("click",y,!0),(s==null?void 0:s.value.get(i))===a&&(s.value.delete(i),s.value=new Map(s.value)),r("close"))}),d.onUnmounted(()=>{document.removeEventListener("click",y,!0)}),(b,S)=>(d.openBlock(),d.createElementBlock(d.Fragment,null,[d.createElementVNode("div",{ref_key:"buttonRef",ref:f,class:d.normalizeClass(["wov-menu-dropdown-trigger",{"is-open":u.value}]),"menu-open":u.value||void 0,onMousedown:S[0]||(S[0]=d.withModifiers(()=>{},["prevent"])),onClick:m,onMouseenter:w,onMouseleave:v},[d.renderSlot(b.$slots,"button",{isOpen:u.value})],42,UV),d.unref(o)?(d.openBlock(),d.createBlock(d.Teleport,{key:0,to:d.unref(o)},[u.value?(d.openBlock(),d.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:h,class:"wov-menu-dropdown",style:d.normalizeStyle(d.unref(p))},[d.renderSlot(b.$slots,"dropdown",{close:g})],4)):d.createCommentVNode("",!0)],8,["to"])):d.createCommentVNode("",!0)],64))}}),HV={},ZV={viewBox:"0 0 512 320",fill:"currentColor",style:{width:"7px",color:"var(--wov-gray-300)"}};function KV(t,e){return d.openBlock(),d.createElementBlock("svg",ZV,[...e[0]||(e[0]=[d.createElementVNode("path",{d:"M233.4 278.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 210.7 86.6 41.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"},null,-1)])])}const Wn=ys(HV,[["render",KV]]),YV={class:"wov-menu-button"},qV=["innerHTML"],JV=["onClick"],GV=["innerHTML"],lp=d.defineComponent({__name:"ArrowHeadButton",props:{entityIds:{},side:{}},setup(t){const e=t,{nextEditorTick:n}=ut(),r=d.shallowRef(null),o=d.computed(()=>{const a=r.value??(e.side==="start"?De.None:De.V);return xi(a)});n(a=>{let l=null;for(const c of e.entityIds){if(R(a,c,Pe)){const u=Pe.read(a,c),f=e.side==="start"?u.startArrowHead:u.endArrowHead;if(l===null)l=f;else if(f!==l){r.value=e.side==="start"?De.None:De.V;return}}if(R(a,c,xe)){const u=xe.read(a,c),f=e.side==="start"?u.startArrowHead:u.endArrowHead;if(l===null)l=f;else if(f!==l){r.value=e.side==="start"?De.None:De.V;return}}}r.value=l});function s(a){r.value=a,n(l=>{for(const c of e.entityIds){if(R(l,c,Pe)){const u=Pe.write(l,c);e.side==="start"?u.startArrowHead=a:u.endArrowHead=a}if(R(l,c,xe)){const u=xe.write(l,c);e.side==="start"?u.startArrowHead=a:u.endArrowHead=a}}})}function i(a){if(!a)return"";const l=e.side==="start";return`<line x1="${l?8:4}" y1="12" x2="${l?20:16}" y2="12" stroke="currentColor" stroke-width="2" stroke-linecap="round" /><g transform="${`translate(${l?4:20}, 12) scale(${l?"-0.8, 0.8":"0.8"})`}">${a.svg}</g>`}return(a,l)=>(d.openBlock(),d.createBlock(jn,{title:t.side==="start"?"Start Arrow Head":"End Arrow Head"},{button:d.withCtx(()=>[d.createElementVNode("div",YV,[(d.openBlock(),d.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",innerHTML:i(o.value)},null,8,qV)),d.createVNode(Wn,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(d.unref(Cf),c=>(d.openBlock(),d.createElementBlock("button",{key:c.kind,class:d.normalizeClass(["wov-menu-option",{"is-active":r.value===c.kind}]),onClick:u=>s(c.kind)},[(d.openBlock(),d.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",innerHTML:i(c)},null,8,GV))],10,JV))),128))]),_:1},8,["title"]))}}),XV={class:"wov-menu-button"},QV=["onClick"],$b=d.defineComponent({__name:"ArrowThicknessButton",props:{entityIds:{}},setup(t){const e=[{label:"S",value:2},{label:"M",value:4},{label:"L",value:8}],n=t,{nextEditorTick:r}=ut(),o=d.shallowRef(null);r(i=>{let a=null;for(const l of n.entityIds){if(R(i,l,Pe)){const c=Pe.read(i,l);if(a===null)a=c.thickness;else if(c.thickness!==a){o.value=null;return}}if(R(i,l,xe)){const c=xe.getThickness(i,l);if(a===null)a=c;else if(c!==a){o.value=null;return}}}o.value=a});function s(i){o.value=i,r(a=>{for(const l of n.entityIds){if(R(a,l,Pe)){const c=Pe.write(a,l);c.thickness=i}R(a,l,xe)&&xe.setThickness(a,l,i)}})}return(i,a)=>(d.openBlock(),d.createBlock(jn,{title:"Thickness"},{button:d.withCtx(()=>[d.createElementVNode("div",XV,[a[0]||(a[0]=d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-linecap":"round"},[d.createElementVNode("line",{x1:"4",y1:"5",x2:"20",y2:"5","stroke-width":"1"}),d.createElementVNode("line",{x1:"4",y1:"11",x2:"20",y2:"11","stroke-width":"2.5"}),d.createElementVNode("line",{x1:"4",y1:"19",x2:"20",y2:"19","stroke-width":"4"})],-1)),d.createVNode(Wn,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[(d.openBlock(),d.createElementBlock(d.Fragment,null,d.renderList(e,l=>d.createElementVNode("button",{key:l.value,class:d.normalizeClass(["wov-menu-option wov-arrow-thickness-option",{"is-active":o.value===l.value}]),onClick:c=>s(l.value)},d.toDisplayString(l.label),11,QV)),64))]),_:1}))}}),eF=["value"],tF=d.defineComponent({__name:"ColorInput",props:{modelValue:{}},emits:["update:modelValue"],setup(t,{emit:e}){const n=t,r=e,o=d.ref(n.modelValue??"");d.watch(()=>n.modelValue,u=>{u&&u!==o.value&&(o.value=u)});function s(u){const f=u.startsWith("#")?u:`#${u}`;return/^#[0-9A-Fa-f]{6}$/.test(f)}function i(u){return(u.startsWith("#")?u:`#${u}`).toLowerCase()}function a(u){let h=u.target.value;if((h.length===6||h.length===7)&&s(h)){const p=i(h);o.value=p,r("update:modelValue",p)}}function l(u){const h=u.target.value;if(h&&s(h)){const p=i(h);o.value=p,r("update:modelValue",p)}else n.modelValue&&(o.value=n.modelValue)}function c(u){if(u.stopPropagation(),u.key==="Enter"){const f=u.target,h=f.value;if(h&&s(h)){const p=i(h);o.value=p,r("update:modelValue",p),setTimeout(()=>f.select())}}}return(u,f)=>(d.openBlock(),d.createElementBlock("input",{id:"wov-color-input",class:"wov-color-input",type:"text",size:"1","aria-label":"Hex color value",autocomplete:"off",autocorrect:"off",autocapitalize:"off",spellcheck:"false",value:o.value,onInput:a,onChange:l,onKeydown:c},null,40,eF))}}),Lb=d.defineComponent({__name:"ColorSlider",props:{modelValue:{},thumbColor:{},background:{}},emits:["update:modelValue"],setup(t,{expose:e,emit:n}){const r=n,o=d.ref(null),s=d.ref(!1);function i(c){s.value=!0,a(c),window.addEventListener("pointermove",a),window.addEventListener("pointerup",l)}function a(c){if(!o.value)return;const u=o.value.getBoundingClientRect(),f=Math.max(0,Math.min(100,(c.clientY-u.top)/u.height*100));r("update:modelValue",f)}function l(){s.value=!1,window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",l)}return e({isDragging:s}),(c,u)=>(d.openBlock(),d.createElementBlock("div",{ref_key:"sliderRef",ref:o,class:"wov-color-slider",onPointerdown:d.withModifiers(i,["prevent"])},[t.background?(d.openBlock(),d.createElementBlock("div",{key:0,class:"wov-color-slider-gradient",style:d.normalizeStyle({background:t.background})},null,4)):d.createCommentVNode("",!0),d.createElementVNode("div",{class:"wov-color-slider-thumb",style:d.normalizeStyle({top:`${t.modelValue}%`,backgroundColor:t.thumbColor})},null,4)],544))}}),nF={class:"wov-color-picker"},rF={class:"wov-color-picker-area"},oF={class:"wov-color-picker-selector-gradient"},sF="linear-gradient(to bottom, red 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, red 100%)",Vb=d.defineComponent({__name:"ColorPicker",props:{modelValue:{},withOpacity:{type:Boolean}},emits:["update:modelValue"],setup(t,{emit:e}){const n=t,r=e,o=d.ref(null),s=d.ref(null),i=d.ref(null),a=d.ref({x:100,y:0}),l=d.ref(0),c=d.ref(0),u=d.ref(!1),f=d.computed(()=>{var E,_;return u.value||((E=o.value)==null?void 0:E.isDragging)||((_=s.value)==null?void 0:_.isDragging)}),h=d.computed(()=>({h:l.value/100*360,s:a.value.x,v:100-a.value.y,a:(100-c.value)/100*255})),p=d.computed(()=>lb({h:h.value.h,s:100,v:100})),m=d.computed(()=>lb({h:h.value.h,s:h.value.s,v:h.value.v})),g=d.computed(()=>n.withOpacity?cb(h.value):m.value),y=d.computed(()=>`linear-gradient(to top, transparent 0%, ${m.value} 100%)`);function w(E){if(E){const _=ab(E);a.value={x:_.s,y:100-_.v},l.value=_.h/360*100,c.value=100-_.a/255*100}}function v(E){w(E),r("update:modelValue",n.withOpacity?cb(ab(E)):E)}w(n.modelValue),d.watch(()=>n.modelValue,E=>{f.value||w(E)}),d.watch([a,l,c],()=>{f.value&&r("update:modelValue",g.value)});function b(E){u.value=!0,S(E),window.addEventListener("pointermove",S),window.addEventListener("pointerup",k)}function S(E){if(!i.value)return;const _=i.value.getBoundingClientRect(),M=Math.max(0,Math.min(100,(E.clientX-_.left)/_.width*100)),I=Math.max(0,Math.min(100,(E.clientY-_.top)/_.height*100));a.value={x:M,y:I}}function k(){u.value=!1,window.removeEventListener("pointermove",S),window.removeEventListener("pointerup",k)}return(E,_)=>(d.openBlock(),d.createElementBlock("div",nF,[d.createVNode(tF,{modelValue:g.value,"onUpdate:modelValue":v},null,8,["modelValue"]),d.createElementVNode("div",rF,[d.createElementVNode("div",{ref_key:"selectorRef",ref:i,class:"wov-color-picker-selector",style:d.normalizeStyle({backgroundColor:p.value}),onPointerdown:d.withModifiers(b,["prevent"])},[d.createElementVNode("div",oF,[d.createElementVNode("div",{class:"wov-color-picker-selector-thumb",style:d.normalizeStyle({left:`${a.value.x}%`,top:`${a.value.y}%`,backgroundColor:m.value})},null,4)])],36),d.createVNode(Lb,{ref_key:"hueSliderRef",ref:o,modelValue:l.value,"onUpdate:modelValue":_[0]||(_[0]=M=>l.value=M),thumbColor:p.value,background:sF},null,8,["modelValue","thumbColor"]),t.withOpacity?(d.openBlock(),d.createBlock(Lb,{key:0,ref_key:"opacitySliderRef",ref:s,modelValue:c.value,"onUpdate:modelValue":_[1]||(_[1]=M=>c.value=M),thumbColor:m.value,background:y.value,class:"wov-color-picker-opacity"},null,8,["modelValue","thumbColor","background"])):d.createCommentVNode("",!0)])]))}}),iF={class:"wov-color-bubbles-container"},aF={key:1,class:"wov-color-bubbles"},lF=["onClick"],Nu=d.defineComponent({__name:"ColorBubbles",props:{currentColor:{},palette:{},hideHighlight:{type:Boolean},withPicker:{type:Boolean},withOpacity:{type:Boolean}},emits:["change","picker-open"],setup(t,{emit:e}){const n=t,r=e,o=["#000000","#374151","#6B7280","#9CA3AF","#D1D5DB","#FFFFFF","#EF4444","#F97316","#EAB308","#22C55E","#14B8A6","#3B82F6","#8B5CF6","#EC4899"],s=d.computed(()=>{const m=n.palette??o,g=n.withPicker,y=m.length%2===1;return g&&!y||!g&&y?m.slice(0,-1):m}),i=d.ref(!1),a=d.ref(n.currentColor??"#ff0000");function l(m,g){const y=w=>{const v=w.replace(/^#/,"").toLowerCase();return v.length===6?v+"ff":v};return y(m)===y(g)}function c(m){return n.hideHighlight||!n.currentColor?!1:l(n.currentColor,m)}function u(){return n.hideHighlight||!n.currentColor?!1:!s.value.some(m=>l(n.currentColor,m))}function f(m){const g=Kh(m);g&&r("change",g)}function h(){!i.value&&n.currentColor&&(a.value=n.currentColor),i.value=!i.value,r("picker-open",i.value)}function p(m){a.value=m;const g=Kh(m);g&&r("change",g)}return(m,g)=>(d.openBlock(),d.createElementBlock("div",iF,[i.value?(d.openBlock(),d.createBlock(Vb,{key:0,modelValue:a.value,"onUpdate:modelValue":[g[0]||(g[0]=y=>a.value=y),p],withOpacity:t.withOpacity},null,8,["modelValue","withOpacity"])):(d.openBlock(),d.createElementBlock("div",aF,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(s.value,y=>(d.openBlock(),d.createElementBlock("div",{key:y,class:d.normalizeClass(["wov-color-bubble",{selected:c(y)}]),style:d.normalizeStyle({backgroundColor:y}),onMousedown:g[1]||(g[1]=d.withModifiers(()=>{},["prevent"])),onClick:w=>f(y)},null,46,lF))),128)),t.withPicker?(d.openBlock(),d.createElementBlock("div",{key:0,class:d.normalizeClass(["wov-color-bubble wov-rainbow-bubble",{selected:u()}]),onMousedown:g[2]||(g[2]=d.withModifiers(()=>{},["prevent"])),onClick:h},null,34)):d.createCommentVNode("",!0)]))]))}}),cF={class:"wov-color-button"},Fb=d.defineComponent({__name:"ColorButton",props:{entityIds:{}},setup(t){const e=t,{nextEditorTick:n}=ut(),r=Zo(()=>e.entityIds,In),o=d.computed(()=>{const c=new Set;for(const u of r.value.values())if(u){const f=rl(u);c.add(f)}return Array.from(c)}),s=d.computed(()=>o.value.length>1),i=d.computed(()=>o.value[0]??null),a=d.computed(()=>{if(o.value.length===0)return{backgroundColor:"#000"};if(o.value.length>=2){const c=o.value[0],u=o.value[1];return{background:`linear-gradient(45deg, ${c} 0%, ${c} 50%, ${u} 50%, ${u} 100%)`}}return{backgroundColor:o.value[0]}});function l(c){const u=rl(c);n(f=>{for(const h of e.entityIds)In.fromHex(f,h,u)})}return(c,u)=>(d.openBlock(),d.createBlock(jn,{title:"Color"},{button:d.withCtx(()=>[d.createElementVNode("div",cF,[d.createElementVNode("div",{class:"wov-color-swatch",style:d.normalizeStyle(a.value)},null,4),d.createVNode(Wn,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[d.createVNode(Nu,{currentColor:i.value??void 0,hideHighlight:s.value,withPicker:!0,onChange:l},null,8,["currentColor","hideHighlight"])]),_:1}))}}),Ui=d.defineComponent({__name:"MenuButton",props:{title:{}},emits:["click"],setup(t,{emit:e}){const n=t,r=e,o=d.ref(null),{show:s,hide:i}=Yo();function a(u){r("click",u)}function l(){n.title&&o.value&&s(n.title,o.value)}function c(){i()}return(u,f)=>(d.openBlock(),d.createElementBlock("button",{ref_key:"buttonRef",ref:o,class:"wov-menu-button",onClick:a,onMouseenter:l,onMouseleave:c},[d.renderSlot(u.$slots,"default")],544))}}),cp=d.defineComponent({__name:"MenuTooltip",setup(t){const{activeTooltip:e,isVisible:n}=Yo(),r=d.inject("containerRef"),o=d.ref(null),s=d.computed(()=>{var l;return((l=e.value)==null?void 0:l.anchor)??null}),{floatingStyles:i}=Iu(s,o,{placement:"top",middleware:[Tu(8),Au({fallbackPlacements:["bottom"]}),Mu({padding:8})]}),a=d.computed(()=>{var l;return n.value&&((l=e.value)==null?void 0:l.text)});return(l,c)=>d.unref(r)?(d.openBlock(),d.createBlock(d.Teleport,{key:0,to:d.unref(r)},[d.createVNode(d.Transition,{name:"wov-tooltip-fade"},{default:d.withCtx(()=>{var u;return[a.value?(d.openBlock(),d.createElementBlock("div",{key:0,ref_key:"tooltipRef",ref:o,class:"wov-menu-tooltip",style:d.normalizeStyle(d.unref(i))},d.toDisplayString((u=d.unref(e))==null?void 0:u.text),5)):d.createCommentVNode("",!0)]}),_:1})],8,["to"])):d.createCommentVNode("",!0)}}),uF={class:"wov-menu-button"},dF=["onClick"],jb=d.defineComponent({__name:"PenStrokeThicknessButton",props:{entityIds:{}},setup(t){const e=[{label:"S",value:4},{label:"M",value:8},{label:"L",value:16}],n=t,{nextEditorTick:r}=ut(),o=Zo(()=>n.entityIds,tr),s=d.computed(()=>{let a=null;for(const l of o.value.values())if(l){if(a===null)a=l.thickness;else if(l.thickness!==a)return null}return a});function i(a){r(l=>{for(const c of n.entityIds){const u=tr.write(l,c);u.thickness=a}})}return(a,l)=>(d.openBlock(),d.createBlock(jn,{title:"Thickness"},{button:d.withCtx(()=>[d.createElementVNode("div",uF,[l[0]||(l[0]=d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-linecap":"round"},[d.createElementVNode("line",{x1:"4",y1:"5",x2:"20",y2:"5","stroke-width":"1"}),d.createElementVNode("line",{x1:"4",y1:"11",x2:"20",y2:"11","stroke-width":"2.5"}),d.createElementVNode("line",{x1:"4",y1:"19",x2:"20",y2:"19","stroke-width":"4"})],-1)),d.createVNode(Wn,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[(d.openBlock(),d.createElementBlock(d.Fragment,null,d.renderList(e,c=>d.createElementVNode("button",{key:c.value,class:d.normalizeClass(["wov-menu-option wov-pen-thickness-option",{"is-active":s.value===c.value}]),onClick:u=>i(c.value)},d.toDisplayString(c.label),11,dF)),64))]),_:1}))}}),fF={class:"wov-fill-color-button"},hF={class:"wov-fill-dropdown"},pF={key:0,class:"wov-fill-mode-section"},mF=["title","onClick"],gF={viewBox:"0 0 24 24",fill:"none"},yF=["fill","fill-opacity","stroke","stroke-width","stroke-dasharray"],Wb=d.defineComponent({__name:"ShapeFillColorButton",props:{entityIds:{}},setup(t){const e=t,{nextEditorTick:n}=ut(),r=Zo(()=>e.entityIds,Nn),o=[{mode:"solid",label:"Solid",alpha:255},{mode:"faded",label:"Faded",alpha:128},{mode:"none",label:"None",alpha:0}],s=d.computed(()=>{const p=r.value.values().next().value,m=(p==null?void 0:p.fillAlpha)??255;return m===0?"none":m<200?"faded":"solid"}),i=d.computed(()=>{const p=new Set;for(const m of r.value.values())if(m){const g=m.fillAlpha??255;g===0?p.add("none"):g<200?p.add("faded"):p.add("solid")}return p.size>1});function a(p){n(m=>{for(const g of e.entityIds){const y=Nn.write(m,g);y.fillAlpha=p}})}const l=d.computed(()=>{const p=new Set;for(const m of r.value.values())if(m){const g=rl({red:m.fillRed,green:m.fillGreen,blue:m.fillBlue,alpha:m.fillAlpha??255});p.add(g)}return Array.from(p)}),c=d.computed(()=>l.value.length>1),u=d.computed(()=>l.value[0]??"#4a90d9");function f(p){n(m=>{for(const g of e.entityIds){const y=Nn.write(m,g);y.fillRed=p.red,y.fillGreen=p.green,y.fillBlue=p.blue,y.fillAlpha=p.alpha}})}const h=d.ref(!1);return(p,m)=>(d.openBlock(),d.createBlock(jn,{title:"Fill Color"},{button:d.withCtx(()=>[d.createElementVNode("div",fF,[m[1]||(m[1]=d.createElementVNode("svg",{viewBox:"0 0 20 20",class:"wov-fill-color-icon",stroke:"currentColor",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"},[d.createElementVNode("path",{d:"M5.879,2.625L14.121,2.625C15.906,2.625 17.375,4.094 17.375,5.879L17.375,14.121C17.375,15.906 15.906,17.375 14.121,17.375L5.88,17.375C4.095,17.375 2.626,15.906 2.626,14.121L2.626,5.88C2.626,4.095 4.095,2.626 5.88,2.626L5.879,2.625Z","stroke-width":"1.25"}),d.createElementVNode("path",{d:"M2.779,14.655L14.543,2.871M10.238,17.308L17.318,10.229M2.876,9.577L9.853,2.6M5.397,17.239L17.16,5.476","stroke-width":"1.25"})],-1)),d.createVNode(Wn,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[d.createElementVNode("div",hF,[h.value?d.createCommentVNode("",!0):(d.openBlock(),d.createElementBlock("div",pF,[(d.openBlock(),d.createElementBlock(d.Fragment,null,d.renderList(o,g=>d.createElementVNode("button",{key:g.mode,class:d.normalizeClass(["wov-fill-mode-option",{"is-active":!i.value&&g.mode===s.value}]),title:g.label,onClick:y=>a(g.alpha)},[(d.openBlock(),d.createElementBlock("svg",gF,[d.createElementVNode("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",fill:g.mode==="none"?"none":"currentColor","fill-opacity":g.mode==="faded"?.4:1,stroke:g.mode==="none"?"currentColor":"none","stroke-width":g.mode==="none"?1.5:0,"stroke-dasharray":g.mode==="none"?"3 3":""},null,8,yF)])),d.createElementVNode("span",null,d.toDisplayString(g.label),1)],10,mF)),64))])),d.createVNode(Nu,{currentColor:u.value,hideHighlight:c.value,withPicker:!0,withOpacity:!0,onChange:f,onPickerOpen:m[0]||(m[0]=g=>h.value=g)},null,8,["currentColor","hideHighlight"])])]),_:1}))}}),wF={class:"wov-shape-kind-button"},vF={class:"wov-shape-kind-dropdown"},kF=["onClick"],bF={viewBox:"0 0 20 20",class:"wov-shape-option-icon",fill:"none",stroke:"currentColor","stroke-width":"4"},SF=["d"],Ub=d.defineComponent({__name:"ShapeKindButton",props:{entityIds:{}},setup(t){const e=t,{nextEditorTick:n}=ut(),r=Zo(()=>e.entityIds,Nn),o=d.computed(()=>{const l=r.value.values().next().value;return(l==null?void 0:l.kind)??"rectangle"}),s=d.computed(()=>{const l=new Set;for(const c of r.value.values())c&&l.add(c.kind);return l.size>1}),i=d.computed(()=>Object.keys(Ba).map(l=>({kind:l,label:l.charAt(0).toUpperCase()+l.slice(1)})));function a(l){n(c=>{for(const u of e.entityIds){const f=Nn.write(c,u);f.kind=l}})}return(l,c)=>(d.openBlock(),d.createBlock(jn,{title:"Shape Type"},{button:d.withCtx(()=>[d.createElementVNode("div",wF,[c[0]||(c[0]=d.createElementVNode("svg",{viewBox:"0 0 20 20",class:"wov-shape-kind-icon",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[d.createElementVNode("circle",{cx:"6",cy:"6",r:"5"}),d.createElementVNode("rect",{x:"6",y:"6",width:"10",height:"10",fill:"var(--wov-gray-600)"})],-1)),d.createVNode(Wn,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[d.createElementVNode("div",vF,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(i.value,u=>(d.openBlock(),d.createElementBlock("button",{key:u.kind,class:d.normalizeClass(["wov-shape-kind-option",{"is-selected":!s.value&&u.kind===o.value}]),onClick:f=>a(u.kind)},[(d.openBlock(),d.createElementBlock("svg",bF,[d.createElementVNode("path",{d:d.unref(Ba)[u.kind],transform:"translate(2, 2) scale(0.16)"},null,8,SF)])),d.createElementVNode("span",null,d.toDisplayString(u.label),1)],10,kF))),128))])]),_:1}))}}),EF={class:"wov-stroke-style-section"},CF=["title","onClick"],_F={viewBox:"0 0 24 8",fill:"none",stroke:"currentColor","stroke-width":"2"},xF=["stroke-dasharray","stroke-opacity"],TF=d.defineComponent({__name:"StrokeStyleOptions",props:{currentStyle:{},hasMultipleStyles:{type:Boolean}},emits:["change"],setup(t,{emit:e}){const n=e,r=[{kind:Ct.Solid,label:"Solid"},{kind:Ct.Dashed,label:"Dashed"},{kind:Ct.None,label:"None"}];function o(i){switch(i){case Ct.Dashed:return"6 6";case Ct.None:return"";case Ct.Solid:default:return""}}function s(i){n("change",i)}return(i,a)=>(d.openBlock(),d.createElementBlock("div",EF,[(d.openBlock(),d.createElementBlock(d.Fragment,null,d.renderList(r,l=>d.createElementVNode("button",{key:l.kind,class:d.normalizeClass(["wov-stroke-style-option",{"is-active":!t.hasMultipleStyles&&l.kind===t.currentStyle}]),title:l.label,onClick:c=>s(l.kind)},[(d.openBlock(),d.createElementBlock("svg",_F,[d.createElementVNode("line",{x1:"2",y1:"4",x2:"22",y2:"4","stroke-linecap":"round","stroke-dasharray":o(l.kind),"stroke-opacity":l.kind===d.unref(Ct).None?.3:1},null,8,xF)])),d.createElementVNode("span",null,d.toDisplayString(l.label),1)],10,CF)),64))]))}}),MF={class:"wov-stroke-color-button"},AF={class:"wov-stroke-dropdown"},IF={key:1,class:"wov-stroke-divider"},Hb=d.defineComponent({__name:"ShapeStrokeColorButton",props:{entityIds:{}},setup(t){const e=t,{nextEditorTick:n}=ut(),r=Zo(()=>e.entityIds,Nn),o=d.ref(!1),s=d.computed(()=>{const h=new Set;for(const p of r.value.values())if(p){const m=rl({red:p.strokeRed,green:p.strokeGreen,blue:p.strokeBlue,alpha:255});h.add(m)}return Array.from(h)}),i=d.computed(()=>s.value.length>1),a=d.computed(()=>s.value[0]??"#000000"),l=d.computed(()=>{const h=r.value.values().next().value;return(h==null?void 0:h.strokeKind)??Ct.Solid}),c=d.computed(()=>{const h=new Set;for(const p of r.value.values())p&&h.add(p.strokeKind);return h.size>1});function u(h){n(p=>{for(const m of e.entityIds){const g=Nn.write(p,m);g.strokeRed=h.red,g.strokeGreen=h.green,g.strokeBlue=h.blue}})}function f(h){n(p=>{for(const m of e.entityIds){const g=Nn.write(p,m);g.strokeKind=h}})}return(h,p)=>(d.openBlock(),d.createBlock(jn,{title:"Stroke Color"},{button:d.withCtx(()=>[d.createElementVNode("div",MF,[p[1]||(p[1]=d.createElementVNode("svg",{viewBox:"0 0 20 20",class:"wov-stroke-color-icon",fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round"},[d.createElementVNode("path",{d:"M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43","stroke-width":"1.25"})],-1)),d.createVNode(Wn,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[d.createElementVNode("div",AF,[o.value?d.createCommentVNode("",!0):(d.openBlock(),d.createBlock(TF,{key:0,currentStyle:l.value,hasMultipleStyles:c.value,onChange:f},null,8,["currentStyle","hasMultipleStyles"])),o.value?d.createCommentVNode("",!0):(d.openBlock(),d.createElementBlock("div",IF)),d.createVNode(Nu,{currentColor:a.value,hideHighlight:i.value,withPicker:!0,onChange:u,onPickerOpen:p[0]||(p[0]=m=>o.value=m)},null,8,["currentColor","hideHighlight"])])]),_:1}))}}),NF={key:0,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},BF={key:1,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},PF={key:2,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},OF={key:3,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},up=d.defineComponent({__name:"TextAlignmentButton",props:{entityIds:{}},setup(t){const e=t,{state:n,commands:r}=_r(()=>e.entityIds),o=[Bn.Left,Bn.Center,Bn.Right,Bn.Justify];function s(){const i=o.indexOf(n.alignment),a=o[(i+1)%o.length];r.setAlignment(a)}return(i,a)=>d.unref(n).showTextMenuButtons?(d.openBlock(),d.createBlock(Ui,{key:0,title:"Text Align",onClick:s},{default:d.withCtx(()=>[d.unref(n).alignment===d.unref(Bn).Left?(d.openBlock(),d.createElementBlock("svg",NF,[...a[0]||(a[0]=[d.createElementVNode("path",{d:"M288 64c0 17.7-14.3 32-32 32L32 96C14.3 96 0 81.7 0 64S14.3 32 32 32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32L32 352c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zM0 192c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 224c-17.7 0-32-14.3-32-32zM448 448c0 17.7-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"},null,-1)])])):d.unref(n).alignment===d.unref(Bn).Center?(d.openBlock(),d.createElementBlock("svg",BF,[...a[1]||(a[1]=[d.createElementVNode("path",{d:"M352 64c0-17.7-14.3-32-32-32L128 32c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32zm96 128c0-17.7-14.3-32-32-32L32 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32zM0 448c0 17.7 14.3 32 32 32l384 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 416c-17.7 0-32 14.3-32 32zM352 320c0-17.7-14.3-32-32-32l-192 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32z"},null,-1)])])):d.unref(n).alignment===d.unref(Bn).Right?(d.openBlock(),d.createElementBlock("svg",PF,[...a[2]||(a[2]=[d.createElementVNode("path",{d:"M448 64c0 17.7-14.3 32-32 32L192 96c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32l-224 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zM0 192c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 224c-17.7 0-32-14.3-32-32zM448 448c0 17.7-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"},null,-1)])])):(d.openBlock(),d.createElementBlock("svg",OF,[...a[3]||(a[3]=[d.createElementVNode("path",{d:"M448 64c0-17.7-14.3-32-32-32L32 32C14.3 32 0 46.3 0 64S14.3 96 32 96l384 0c17.7 0 32-14.3 32-32zm0 256c0-17.7-14.3-32-32-32L32 288c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32zM0 192c0 17.7 14.3 32 32 32l384 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 160c-17.7 0-32 14.3-32 32zM448 448c0-17.7-14.3-32-32-32L32 416c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32z"},null,-1)])]))]),_:1})):d.createCommentVNode("",!0)}}),dp=d.defineComponent({__name:"TextBoldButton",props:{entityIds:{}},setup(t){const e=t,{state:n,commands:r}=_r(()=>e.entityIds);return(o,s)=>d.unref(n).showTextMenuButtons?(d.openBlock(),d.createBlock(Ui,{key:0,title:"Bold",class:d.normalizeClass({"wov-active":d.unref(n).isBold}),onClick:d.unref(r).toggleBold},{default:d.withCtx(()=>[...s[0]||(s[0]=[d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512",fill:"currentColor"},[d.createElementVNode("path",{d:"M0 64C0 46.3 14.3 32 32 32l48 0 16 0 128 0c70.7 0 128 57.3 128 128c0 31.3-11.3 60.1-30 82.3c37.1 22.4 62 63.1 62 109.7c0 70.7-57.3 128-128 128L96 480l-16 0-48 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l16 0 0-160L48 96 32 96C14.3 96 0 81.7 0 64zM224 224c35.3 0 64-28.7 64-64s-28.7-64-64-64L112 96l0 128 112 0zM112 288l0 128 144 0c35.3 0 64-28.7 64-64s-28.7-64-64-64l-32 0-112 0z"})],-1)])]),_:1},8,["class","onClick"])):d.createCommentVNode("",!0)}});function DF(t,e){return d.getCurrentScope()?(d.onScopeDispose(t,e),!0):!1}const RF=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const zF=Object.prototype.toString,$F=t=>zF.call(t)==="[object Object]",Bu=()=>{};function Pu(t){return Array.isArray(t)?t:[t]}function LF(t){return d.getCurrentInstance()}function VF(t,e=!0,n){LF()?d.onMounted(t,n):e?t():d.nextTick(t)}function FF(t,e,n){return d.watch(t,e,{...n,immediate:!0})}const Ou=RF?window:void 0;function ir(t){var e;const n=d.toValue(t);return(e=n==null?void 0:n.$el)!==null&&e!==void 0?e:n}function fp(...t){const e=(r,o,s,i)=>(r.addEventListener(o,s,i),()=>r.removeEventListener(o,s,i)),n=d.computed(()=>{const r=Pu(d.toValue(t[0])).filter(o=>o!=null);return r.every(o=>typeof o!="string")?r:void 0});return FF(()=>{var r,o;return[(r=(o=n.value)===null||o===void 0?void 0:o.map(s=>ir(s)))!==null&&r!==void 0?r:[Ou].filter(s=>s!=null),Pu(d.toValue(n.value?t[1]:t[0])),Pu(d.unref(n.value?t[2]:t[1])),d.toValue(n.value?t[3]:t[2])]},([r,o,s,i],a,l)=>{if(!(r!=null&&r.length)||!(o!=null&&o.length)||!(s!=null&&s.length))return;const c=$F(i)?{...i}:i,u=r.flatMap(f=>o.flatMap(h=>s.map(p=>e(f,h,p,c))));l(()=>{u.forEach(f=>f())})},{flush:"post"})}function jF(t,e,n={}){const{window:r=Ou,ignore:o=[],capture:s=!0,detectIframe:i=!1,controls:a=!1}=n;if(!r)return a?{stop:Bu,cancel:Bu,trigger:Bu}:Bu;let l=!0;const c=y=>d.toValue(o).some(w=>{if(typeof w=="string")return Array.from(r.document.querySelectorAll(w)).some(v=>v===y.target||y.composedPath().includes(v));{const v=ir(w);return v&&(y.target===v||y.composedPath().includes(v))}});function u(y){const w=d.toValue(y);return w&&w.$.subTree.shapeFlag===16}function f(y,w){const v=d.toValue(y),b=v.$.subTree&&v.$.subTree.children;return b==null||!Array.isArray(b)?!1:b.some(S=>S.el===w.target||w.composedPath().includes(S.el))}const h=y=>{const w=ir(t);if(y.target!=null&&!(!(w instanceof Element)&&u(t)&&f(t,y))&&!(!w||w===y.target||y.composedPath().includes(w))){if("detail"in y&&y.detail===0&&(l=!c(y)),!l){l=!0;return}e(y)}};let p=!1;const m=[fp(r,"click",y=>{p||(p=!0,setTimeout(()=>{p=!1},0),h(y))},{passive:!0,capture:s}),fp(r,"pointerdown",y=>{const w=ir(t);l=!c(y)&&!!(w&&!y.composedPath().includes(w))},{passive:!0}),i&&fp(r,"blur",y=>{setTimeout(()=>{var w;const v=ir(t);((w=r.document.activeElement)===null||w===void 0?void 0:w.tagName)==="IFRAME"&&!(v!=null&&v.contains(r.document.activeElement))&&e(y)},0)},{passive:!0})].filter(Boolean),g=()=>m.forEach(y=>y());return a?{stop:g,cancel:()=>{l=!1},trigger:y=>{l=!0,h(y),l=!1}}:g}function WF(){const t=d.shallowRef(!1),e=d.getCurrentInstance();return e&&d.onMounted(()=>{t.value=!0},e),t}function UF(t){const e=WF();return d.computed(()=>(e.value,!!t()))}function HF(t,e,n={}){const{window:r=Ou,...o}=n;let s;const i=UF(()=>r&&"ResizeObserver"in r),a=()=>{s&&(s.disconnect(),s=void 0)},l=d.watch(d.computed(()=>{const u=d.toValue(t);return Array.isArray(u)?u.map(f=>ir(f)):[ir(u)]}),u=>{if(a(),i.value&&r){s=new ResizeObserver(e);for(const f of u)f&&s.observe(f,o)}},{immediate:!0,flush:"post"}),c=()=>{a(),l()};return DF(c),{isSupported:i,stop:c}}function Zb(t,e={width:0,height:0},n={}){const{window:r=Ou,box:o="content-box"}=n,s=d.computed(()=>{var f;return(f=ir(t))===null||f===void 0||(f=f.namespaceURI)===null||f===void 0?void 0:f.includes("svg")}),i=d.shallowRef(e.width),a=d.shallowRef(e.height),{stop:l}=HF(t,([f])=>{const h=o==="border-box"?f.borderBoxSize:o==="content-box"?f.contentBoxSize:f.devicePixelContentBoxSize;if(r&&s.value){const p=ir(t);if(p){const m=p.getBoundingClientRect();i.value=m.width,a.value=m.height}}else if(h){const p=Pu(h);i.value=p.reduce((m,{inlineSize:g})=>m+g,0),a.value=p.reduce((m,{blockSize:g})=>m+g,0)}else i.value=f.contentRect.width,a.value=f.contentRect.height},n);VF(()=>{const f=ir(t);f&&(i.value="offsetWidth"in f?f.offsetWidth:e.width,a.value="offsetHeight"in f?f.offsetHeight:e.height)});const c=d.watch(()=>ir(t),f=>{i.value=f?e.width:0,a.value=f?e.height:0});function u(){l(),c()}return{width:i,height:a,stop:u}}function Kb(){const t=d.inject(Rn);if(!t)throw new Error("useFonts must be used within a WovenCanvas component");return d.computed(()=>{const e=t.getEditor();return e?e.fonts.filter(n=>n.selectable):[]})}const ZF={class:"wov-font-family-button"},KF={class:"wov-font-family-label"},YF={class:"wov-font-list"},qF=["onClick"],JF=["src","alt"],hp=d.defineComponent({__name:"TextFontFamilyButton",props:{entityIds:{}},setup(t){const e=t,{state:n,commands:r}=_r(()=>e.entityIds),o=Kb(),s=d.computed(()=>o.value.map(u=>({name:u.name,displayName:u.displayName,previewImage:u.previewImage}))),i=d.computed(()=>n.fontFamily),a=d.computed(()=>{const u=i.value;if(u===null)return"Mixed";const f=s.value.find(h=>h.name===u);return(f==null?void 0:f.displayName)??u});function l(u){r.setFontFamily(u)}function c(u){u.stopPropagation()}return(u,f)=>d.unref(n).showTextMenuButtons?(d.openBlock(),d.createBlock(jn,{key:0,title:"Font Family"},{button:d.withCtx(()=>[d.createElementVNode("div",ZF,[d.createElementVNode("span",KF,d.toDisplayString(a.value),1),d.createVNode(Wn,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[d.createElementVNode("div",{class:"wov-font-family-menu",onWheel:c,onClick:f[0]||(f[0]=d.withModifiers(()=>{},["stop"]))},[d.createElementVNode("div",YF,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(s.value,h=>(d.openBlock(),d.createElementBlock("div",{key:h.name,class:d.normalizeClass(["wov-font-item",{active:i.value===h.name}]),onClick:p=>l(h.name)},[h.previewImage?(d.openBlock(),d.createElementBlock("img",{key:0,class:"wov-font-preview",src:h.previewImage,alt:h.name},null,8,JF)):(d.openBlock(),d.createElementBlock("span",{key:1,class:"wov-font-name",style:d.normalizeStyle({fontFamily:h.name})},d.toDisplayString(h.displayName),5))],10,qF))),128))])],32)]),_:1})):d.createCommentVNode("",!0)}}),GF={class:"wov-font-size-button"},XF={class:"wov-font-size-label"},QF=["onClick"],e6={key:0,class:"wov-check-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},t6={class:"wov-input-container"},n6=["value"],pp=d.defineComponent({__name:"TextFontSizeButton",props:{entityIds:{}},setup(t){const e=t,{state:n,commands:r}=_r(()=>e.entityIds),o=[{label:"Small",value:16,displayValue:10},{label:"Medium",value:24,displayValue:12},{label:"Large",value:40,displayValue:16},{label:"Huge",value:96,displayValue:20}],s=d.computed(()=>n.fontSize),i=d.computed(()=>{const h=s.value;if(h===null)return"Mixed";const p=o.find(m=>m.value===h);return p?p.label:`${+h.toFixed(1)} px`}),a=d.computed(()=>{const h=s.value;return h===null?"":String(+h.toFixed(1))});function l(h){r.setFontSize(h)}function c(h){const p=h.target,m=Number.parseFloat(p.value);!Number.isNaN(m)&&m>0&&l(m)}function u(h){h.key==="Enter"&&h.target.blur()}function f(h){h.stopPropagation()}return(h,p)=>d.unref(n).showTextMenuButtons?(d.openBlock(),d.createBlock(jn,{key:0,title:"Font Size"},{button:d.withCtx(()=>[d.createElementVNode("div",GF,[d.createElementVNode("span",XF,d.toDisplayString(i.value),1),d.createVNode(Wn,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[d.createElementVNode("div",{class:"wov-font-size-menu",onWheel:f,onClick:p[0]||(p[0]=d.withModifiers(()=>{},["stop"]))},[(d.openBlock(),d.createElementBlock(d.Fragment,null,d.renderList(o,m=>d.createElementVNode("div",{key:m.value,class:d.normalizeClass(["wov-font-size-option",{active:s.value===m.value}]),onClick:g=>l(m.value)},[s.value===m.value?(d.openBlock(),d.createElementBlock("svg",e6,[...p[1]||(p[1]=[d.createElementVNode("path",{d:"M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"},null,-1)])])):d.createCommentVNode("",!0),d.createElementVNode("span",{class:"wov-option-label",style:d.normalizeStyle({fontSize:`${m.displayValue}px`})},d.toDisplayString(m.label),5)],10,QF)),64)),p[3]||(p[3]=d.createElementVNode("div",{class:"wov-separator"},null,-1)),d.createElementVNode("div",t6,[d.createElementVNode("input",{class:"wov-custom-input",value:a.value,onInput:c,onKeydown:u,placeholder:"Custom size"},null,40,n6),p[2]||(p[2]=d.createElementVNode("span",{class:"wov-px-suffix"},"px",-1))])],32)]),_:1})):d.createCommentVNode("",!0)}}),mp=d.defineComponent({__name:"TextItalicButton",props:{entityIds:{}},setup(t){const e=t,{state:n,commands:r}=_r(()=>e.entityIds);return(o,s)=>d.unref(n).showTextMenuButtons?(d.openBlock(),d.createBlock(Ui,{key:0,title:"Italic",class:d.normalizeClass({"wov-active":d.unref(n).isItalic}),onClick:d.unref(r).toggleItalic},{default:d.withCtx(()=>[...s[0]||(s[0]=[d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512",fill:"currentColor"},[d.createElementVNode("path",{d:"M128 64c0-17.7 14.3-32 32-32l192 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-58.7 0L160 416l64 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l58.7 0L224 96l-64 0c-17.7 0-32-14.3-32-32z"})],-1)])]),_:1},8,["class","onClick"])):d.createCommentVNode("",!0)}}),gp=d.defineComponent({__name:"TextUnderlineButton",props:{entityIds:{}},setup(t){const e=t,{state:n,commands:r}=_r(()=>e.entityIds);return(o,s)=>d.unref(n).showTextMenuButtons?(d.openBlock(),d.createBlock(Ui,{key:0,title:"Underline",class:d.normalizeClass({"wov-active":d.unref(n).isUnderline}),onClick:d.unref(r).toggleUnderline},{default:d.withCtx(()=>[...s[0]||(s[0]=[d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},[d.createElementVNode("path",{d:"M16 64c0-17.7 14.3-32 32-32l96 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-16 0 0 128c0 53 43 96 96 96s96-43 96-96l0-128-16 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l96 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-16 0 0 128c0 88.4-71.6 160-160 160s-160-71.6-160-160L64 96 48 96C30.3 96 16 81.7 16 64zM0 448c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32z"})],-1)])]),_:1},8,["class","onClick"])):d.createCommentVNode("",!0)}}),r6={class:"wov-text-color-button"},o6={class:"wov-text-icon-container"},yp=d.defineComponent({__name:"TextColorButton",props:{entityIds:{}},setup(t){const e=t,{state:n,commands:r}=_r(()=>e.entityIds),o=d.computed(()=>n.color??"#000000"),s=d.computed(()=>({backgroundColor:o.value}));function i(a){r.setColor(rl(a))}return(a,l)=>d.unref(n).showTextMenuButtons?(d.openBlock(),d.createBlock(jn,{key:0,title:"Text Color"},{button:d.withCtx(()=>[d.createElementVNode("div",r6,[d.createElementVNode("div",o6,[l[0]||(l[0]=d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 640",fill:"currentColor",class:"wov-text-icon"},[d.createElementVNode("path",{d:"M349.1 114.7C343.9 103.3 332.5 96 320 96C307.5 96 296.1 103.3 290.9 114.7L123.5 480L112 480C94.3 480 80 494.3 80 512C80 529.7 94.3 544 112 544L200 544C217.7 544 232 529.7 232 512C232 494.3 217.7 480 200 480L193.9 480L215.9 432L424.2 432L446.2 480L440.1 480C422.4 480 408.1 494.3 408.1 512C408.1 529.7 422.4 544 440.1 544L528.1 544C545.8 544 560.1 529.7 560.1 512C560.1 494.3 545.8 480 528.1 480L516.6 480L349.2 114.7zM394.8 368L245.2 368L320 204.8L394.8 368z"})],-1)),d.createElementVNode("div",{class:"wov-color-underline",style:d.normalizeStyle(s.value)},null,4)]),d.createVNode(Wn,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[d.createVNode(Nu,{currentColor:o.value,withPicker:!0,onChange:i},null,8,["currentColor"])]),_:1})):d.createCommentVNode("",!0)}}),s6={key:0,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-align-vertical-justify-start-icon lucide-align-vertical-justify-start"},i6={key:1,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-align-vertical-justify-center-icon lucide-align-vertical-justify-center"},a6={key:2,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-align-vertical-justify-end-icon lucide-align-vertical-justify-end"},Yb=d.defineComponent({__name:"VerticalAlignButton",props:{entityIds:{}},setup(t){const e=t,{nextEditorTick:n}=ut(),{state:r}=_r(()=>e.entityIds),o=[mt.Top,mt.Center,mt.Bottom],s=Zo(()=>e.entityIds,cs),i=d.computed(()=>{let l=null;for(const c of s.value.values()){const u=(c==null?void 0:c.value)??mt.Top;if(l===null)l=u;else if(l!==u)return null}return l});function a(){const l=i.value??mt.Top,c=o.indexOf(l),u=o[(c+1)%o.length];n(f=>{for(const h of e.entityIds){const p=cs.write(f,h);p.value=u}})}return(l,c)=>d.unref(r).showTextMenuButtons?(d.openBlock(),d.createBlock(Ui,{key:0,title:"Vertical Align",onClick:a},{default:d.withCtx(()=>[i.value===d.unref(mt).Top||i.value===null?(d.openBlock(),d.createElementBlock("svg",s6,[...c[0]||(c[0]=[d.createElementVNode("rect",{width:"14",height:"6",x:"5",y:"16",rx:"2"},null,-1),d.createElementVNode("rect",{width:"10",height:"6",x:"7",y:"6",rx:"2"},null,-1),d.createElementVNode("path",{d:"M2 2h20"},null,-1)])])):i.value===d.unref(mt).Center?(d.openBlock(),d.createElementBlock("svg",i6,[...c[1]||(c[1]=[d.createElementVNode("rect",{width:"14",height:"6",x:"5",y:"16",rx:"2"},null,-1),d.createElementVNode("rect",{width:"10",height:"6",x:"7",y:"2",rx:"2"},null,-1),d.createElementVNode("path",{d:"M2 12h20"},null,-1)])])):(d.openBlock(),d.createElementBlock("svg",a6,[...c[2]||(c[2]=[d.createElementVNode("rect",{width:"14",height:"6",x:"5",y:"12",rx:"2"},null,-1),d.createElementVNode("rect",{width:"10",height:"6",x:"7",y:"2",rx:"2"},null,-1),d.createElementVNode("path",{d:"M2 22h20"},null,-1)])]))]),_:1})):d.createCommentVNode("",!0)}}),l6={class:"wov-text-group-button"},c6={class:"wov-text-group-dropdown"},u6={class:"wov-text-group-row wov-text-group-row-full"},d6={class:"wov-text-group-row"},f6=d.defineComponent({__name:"TextButtonGroup",props:{entityIds:{},showVerticalAlign:{type:Boolean}},setup(t){const e=t,{state:n}=_r(()=>e.entityIds),r=d.inject("containerRef"),{width:o}=Zb(r),s=d.computed(()=>o.value>0&&o.value<600),i=d.ref(new Map);return d.provide($0,i),(a,l)=>d.unref(n).showTextMenuButtons?(d.openBlock(),d.createElementBlock(d.Fragment,{key:0},[s.value?(d.openBlock(),d.createBlock(jn,{key:0,title:"Text Formatting",placement:"top"},{button:d.withCtx(()=>[d.createElementVNode("div",l6,[l[0]||(l[0]=d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 640",fill:"currentColor",class:"wov-text-group-icon"},[d.createElementVNode("path",{d:"M349.1 114.7C343.9 103.3 332.5 96 320 96C307.5 96 296.1 103.3 290.9 114.7L123.5 480L112 480C94.3 480 80 494.3 80 512C80 529.7 94.3 544 112 544L200 544C217.7 544 232 529.7 232 512C232 494.3 217.7 480 200 480L193.9 480L215.9 432L424.2 432L446.2 480L440.1 480C422.4 480 408.1 494.3 408.1 512C408.1 529.7 422.4 544 440.1 544L528.1 544C545.8 544 560.1 529.7 560.1 512C560.1 494.3 545.8 480 528.1 480L516.6 480L349.2 114.7zM394.8 368L245.2 368L320 204.8L394.8 368z"})],-1)),d.createVNode(Wn,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[d.createElementVNode("div",c6,[d.createElementVNode("div",u6,[d.createVNode(hp,{entityIds:t.entityIds},null,8,["entityIds"]),l[1]||(l[1]=d.createElementVNode("div",{class:"wov-text-group-spacer"},null,-1)),d.createVNode(pp,{entityIds:t.entityIds},null,8,["entityIds"])]),d.createElementVNode("div",d6,[d.createVNode(dp,{entityIds:t.entityIds},null,8,["entityIds"]),d.createVNode(mp,{entityIds:t.entityIds},null,8,["entityIds"]),d.createVNode(gp,{entityIds:t.entityIds},null,8,["entityIds"]),l[2]||(l[2]=d.createElementVNode("div",{class:"wov-text-group-spacer"},null,-1)),d.createVNode(yp,{entityIds:t.entityIds},null,8,["entityIds"]),d.createVNode(up,{entityIds:t.entityIds},null,8,["entityIds"]),t.showVerticalAlign?(d.openBlock(),d.createBlock(Yb,{key:0,entityIds:t.entityIds},null,8,["entityIds"])):d.createCommentVNode("",!0)])])]),_:1})):(d.openBlock(),d.createElementBlock(d.Fragment,{key:1},[d.createVNode(hp,{entityIds:t.entityIds},null,8,["entityIds"]),d.createVNode(pp,{entityIds:t.entityIds},null,8,["entityIds"]),l[3]||(l[3]=d.createElementVNode("div",{divider:"",class:"wov-divider"},null,-1)),d.createVNode(dp,{entityIds:t.entityIds},null,8,["entityIds"]),d.createVNode(mp,{entityIds:t.entityIds},null,8,["entityIds"]),d.createVNode(gp,{entityIds:t.entityIds},null,8,["entityIds"]),l[4]||(l[4]=d.createElementVNode("div",{divider:"",class:"wov-divider"},null,-1)),d.createVNode(yp,{entityIds:t.entityIds},null,8,["entityIds"]),d.createVNode(up,{entityIds:t.entityIds},null,8,["entityIds"]),t.showVerticalAlign?(d.openBlock(),d.createBlock(Yb,{key:0,entityIds:t.entityIds},null,8,["entityIds"])):d.createCommentVNode("",!0)],64))],64)):d.createCommentVNode("",!0)}}),qb=d.defineComponent({__name:"CanvasBackground",props:{background:{}},setup(t){const e=t,n=jt(we),r=jt(Ut),o=d.inject("containerRef"),s=d.ref({width:0,height:0});let i=null;const a=d.ref(null);let l=null;typeof document<"u"&&(l=document.createElement("canvas"));function c(y,w,v,b){const S=b/2;y.beginPath(),y.arc(w,v,S,0,Math.PI*2),y.fill()}function u(y,w,v){if(!l)return null;const b=v.dotSize??2,S=y*v.subdivisionStep,k=w*v.subdivisionStep;l.width=S,l.height=k;const E=l.getContext("2d");if(!E)return null;if(E.clearRect(0,0,S,k),E.fillStyle=v.strokeColor,v.subdivisionStep===1)c(E,S/2,k/2,b);else for(let _=0;_<v.subdivisionStep;_++)for(let M=0;M<v.subdivisionStep;M++){const I=(_+.5)*(S/v.subdivisionStep),P=(M+.5)*(k/v.subdivisionStep),Z=_===0&&M===0?2*b:b;c(E,I,P,Z)}return E.createPattern(l,"repeat")}function f(y,w,v,b,S,k){y.lineWidth=k,y.beginPath(),y.moveTo(w,v),y.lineTo(b,S),y.stroke()}function h(y,w,v){if(!l)return null;const b=v.gridSize??1,S=y*v.subdivisionStep,k=w*v.subdivisionStep;l.width=S,l.height=k;const E=l.getContext("2d");if(!E)return null;if(E.clearRect(0,0,S,k),E.strokeStyle=v.strokeColor,v.subdivisionStep===1)f(E,0,0,S,0,b),f(E,0,0,0,k,b);else{const _=S/v.subdivisionStep,M=k/v.subdivisionStep;for(let I=0;I<=v.subdivisionStep;I++){const P=I*_,V=I%v.subdivisionStep===0;f(E,P,0,P,k,V?3*b:b)}for(let I=0;I<=v.subdivisionStep;I++){const P=I*M,V=I%v.subdivisionStep===0;f(E,0,P,S,P,V?3*b:b)}}return E.createPattern(l,"repeat")}function p(y){let w=r.value.colWidth,v=r.value.rowHeight;const b=e.background.subdivisionStep,S=s.value.width,k=s.value.height,E=n.value.left,_=n.value.top,M=E+S/n.value.zoom,I=_+k/n.value.zoom;let P=w*b,V=v*b,Z=0,A=0,F=Number.POSITIVE_INFINITY,Y=Number.POSITIVE_INFINITY;for(;;){P=b*w,V=b*v,Z=Math.floor(E/P)*P,A=Math.floor(_/V)*V;const je=Math.ceil(M/P)*P,ar=Math.ceil(I/V)*V;if(Y=Math.round((je-Z)/w),F=Math.round((ar-A)/v),Math.max(Y,F)>200)w*=2,v*=2;else break}const ce=w*n.value.zoom,se=v*n.value.zoom,j=Math.round(ce),X=Math.round(se),he=u(j,X,e.background);if(!he)return;he.setTransform(new DOMMatrix().scale(ce/j,se/X));const Te=(Z-E-w/2)*n.value.zoom,Ce=(A-_-v/2)*n.value.zoom;y.save(),y.translate(Te,Ce),y.fillStyle=he,y.fillRect(0,0,S+P*n.value.zoom,k+V*n.value.zoom),y.restore()}function m(y){let w=r.value.colWidth,v=r.value.rowHeight;const b=e.background.subdivisionStep,S=s.value.width,k=s.value.height,E=n.value.left,_=n.value.top,M=E+S/n.value.zoom,I=_+k/n.value.zoom;let P=w*b,V=v*b,Z=0,A=0,F=Number.POSITIVE_INFINITY,Y=Number.POSITIVE_INFINITY;for(;;){P=b*w,V=b*v,Z=Math.floor(E/P)*P,A=Math.floor(_/V)*V;const je=Math.ceil(M/P)*P,ar=Math.ceil(I/V)*V;if(Y=Math.round((je-Z)/w),F=Math.round((ar-A)/v),Math.max(Y,F)>200)w*=2,v*=2;else break}const ce=w*n.value.zoom,se=v*n.value.zoom,j=Math.round(ce),X=Math.round(se),he=h(j,X,e.background);if(!he)return;he.setTransform(new DOMMatrix().scale(ce/j,se/X));const Te=(Z-E)*n.value.zoom,Ce=(A-_)*n.value.zoom;y.save(),y.translate(Te,Ce),y.fillStyle=he,y.fillRect(0,0,S+P*n.value.zoom,k+V*n.value.zoom),y.restore()}function g(){const y=a.value;if(!y)return;const w=y.getContext("2d");if(!w)return;const{width:v,height:b}=s.value;v===0||b===0||(y.width=v,y.height=b,w.clearRect(0,0,v,b),w.fillStyle=e.background.color,w.fillRect(0,0,v,b),e.background.kind==="dots"?p(w):e.background.kind==="grid"&&m(w))}return d.watch(()=>[e.background,n.value,r.value,s.value],()=>{g()},{deep:!0}),d.onMounted(()=>{const y=o==null?void 0:o.value;if(y){const w=()=>{s.value={width:y.clientWidth,height:y.clientHeight}};w(),i=new ResizeObserver(w),i.observe(y)}g()}),d.onUnmounted(()=>{i==null||i.disconnect()}),(y,w)=>(d.openBlock(),d.createElementBlock("canvas",{ref_key:"canvasRef",ref:a,style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none"}},null,512))}});function Jb(t,e){if(e.length===0)return new Set;const n=e[0].tag,r=t.blockDefs[n];if(!r)return new Set;const o=new Set(r.components.map(s=>s.name));for(let s=1;s<e.length;s++){const i=e[s].tag,a=t.blockDefs[i];if(!a){o.clear();break}const l=new Set(a.components.map(c=>c.name));for(const c of o)l.has(c)||o.delete(c)}return o}const Gb=d.defineComponent({__name:"FloatingMenuBar",setup(t){const e=d.useSlots(),{reset:n}=Yo(),r=d.inject(V0),{selectedIds:o,commonComponents:s}=r,i=new Set(["color","text","verticalAlign","penStroke","elbowArrow","arcArrow","shape"]),a=d.computed(()=>{const c=[];for(const u of s.value){const f=`button:${u}`;!i.has(u)&&e[f]&&c.push(u)}return c});function l(){n()}return d.onUnmounted(()=>{n()}),(c,u)=>(d.openBlock(),d.createElementBlock("div",{class:"wov-floating-menu-bar",onMouseleave:l},[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(a.value,f=>d.renderSlot(c.$slots,`button:${f}`,{key:f,entityIds:d.unref(o)})),128)),d.renderSlot(c.$slots,"button:color",{entityIds:d.unref(o)},()=>[d.unref(s).has("color")?(d.openBlock(),d.createBlock(Fb,{key:0,entityIds:d.unref(o)},null,8,["entityIds"])):d.createCommentVNode("",!0)]),d.renderSlot(c.$slots,"button:shape",{entityIds:d.unref(o)},()=>[d.unref(s).has("shape")?(d.openBlock(),d.createElementBlock(d.Fragment,{key:0},[d.createVNode(Ub,{entityIds:d.unref(o)},null,8,["entityIds"]),d.createVNode(Wb,{entityIds:d.unref(o)},null,8,["entityIds"]),d.createVNode(Hb,{entityIds:d.unref(o)},null,8,["entityIds"])],64)):d.createCommentVNode("",!0)]),d.renderSlot(c.$slots,"button:penStroke",{entityIds:d.unref(o)},()=>[d.unref(s).has("penStroke")?(d.openBlock(),d.createBlock(jb,{key:0,entityIds:d.unref(o)},null,8,["entityIds"])):d.createCommentVNode("",!0)]),d.renderSlot(c.$slots,"button:arrowThickness",{entityIds:d.unref(o)},()=>[d.unref(s).has("elbowArrow")||d.unref(s).has("arcArrow")?(d.openBlock(),d.createBlock($b,{key:0,entityIds:d.unref(o)},null,8,["entityIds"])):d.createCommentVNode("",!0)]),d.renderSlot(c.$slots,"button:arrowHeadStart",{entityIds:d.unref(o)},()=>[d.unref(s).has("elbowArrow")||d.unref(s).has("arcArrow")?(d.openBlock(),d.createBlock(lp,{key:0,entityIds:d.unref(o),side:"start"},null,8,["entityIds"])):d.createCommentVNode("",!0)]),d.renderSlot(c.$slots,"button:arrowHeadEnd",{entityIds:d.unref(o)},()=>[d.unref(s).has("elbowArrow")||d.unref(s).has("arcArrow")?(d.openBlock(),d.createBlock(lp,{key:0,entityIds:d.unref(o),side:"end"},null,8,["entityIds"])):d.createCommentVNode("",!0)]),d.renderSlot(c.$slots,"button:text",{entityIds:d.unref(o)},()=>[d.unref(s).has("text")?(d.openBlock(),d.createBlock(f6,{key:0,entityIds:d.unref(o),showVerticalAlign:d.unref(s).has("verticalAlign")},null,8,["entityIds","showVerticalAlign"])):d.createCommentVNode("",!0)]),d.createVNode(cp)],32))}}),h6={class:"wov-floating-menu-inner"},Xb=d.defineComponent({__name:"FloatingMenu",setup(t){const e=d.inject(Rn),n=sb([T,xt]),r=jt(we),o=jt(_t),s=jt(Xn),i=ol(),a=d.computed(()=>n.value.map(S=>S.entityId)),l=d.computed(()=>{const S=e==null?void 0:e.getEditor();if(!S||n.value.length===0)return new Set;const k=n.value.map(E=>({tag:E.block.value.tag}));return Jb(S,k)});d.provide(V0,{selectedIds:a,commonComponents:l});const c=[0,0,0,0];function u(...S){let k=1/0,E=1/0,_=-1/0,M=-1/0,I=!1;for(const P of S){if(!P)continue;const V=P.getBoundingClientRect();V.width<=0||(I=!0,k=Math.min(k,V.left),E=Math.min(E,V.top),_=Math.max(_,V.right),M=Math.max(M,V.bottom))}return I?{x:k,y:E,left:k,top:E,right:_,bottom:M,width:_-k,height:M-E,toJSON:()=>({})}:null}const f=d.computed(()=>{if(n.value.length===0)return null;const S=r.value;if(!S)return null;let k=null;for(const E of n.value){const _=E.block.value;pt.getAabb(_.position,_.size,_.rotateZ,c),ne.translate(c,[-S.left,-S.top]),ne.scale(c,S.zoom),k===null?k=ne.clone(c):ne.union(k,c)}return k}),h=d.inject("containerRef"),p=d.computed(()=>{const S=h==null?void 0:h.value;if(!S)return null;r.value,i.updateCounter.value;const k=i.blockElement.value,E=i.textElement.value,_=u(k,E);if(_)return{getBoundingClientRect:()=>_};const M=f.value;if(!M)return null;const I=S.getBoundingClientRect();return{getBoundingClientRect(){return{x:I.left+M[0],y:I.top+M[1],width:M[2]-M[0],height:M[3]-M[1],top:I.top+M[1],left:I.left+M[0],right:I.left+M[2],bottom:I.top+M[3]}}}}),m=d.ref(null),g={name:"clampToViewport",fn({y:S,rects:k}){const M=window.innerHeight-k.floating.height-8;return{y:Math.max(8,Math.min(S,M))}}},{floatingStyles:y}=Iu(p,m,{placement:"top",middleware:[Tu(12),Au({fallbackPlacements:["bottom"]}),Mu({padding:8}),g]}),w=d.computed(()=>{const S=f.value,k=o.value;return!S||!k?!0:S[2]<0||S[0]>k.width||S[3]<0||S[1]>k.height}),v=[_e.Dragging,_e.SelectionBoxDragging],b=d.computed(()=>n.value.length>0&&!w.value&&!v.includes(s.value.state));return(S,k)=>(d.openBlock(),d.createBlock(d.Transition,{name:"wov-fade"},{default:d.withCtx(()=>[b.value?(d.openBlock(),d.createElementBlock("div",{key:0,ref_key:"floatingRef",ref:m,class:"wov-floating-menu",style:d.normalizeStyle(d.unref(y))},[d.createElementVNode("div",h6,[d.renderSlot(S.$slots,"default",{},()=>[d.createVNode(Gb)])])],4)):d.createCommentVNode("",!0)]),_:3}))}}),p6={key:0,class:"wov-loading-overlay"},m6={class:"wov-loading-spinner"},Qb=d.defineComponent({__name:"LoadingOverlay",props:{isLoading:{type:Boolean}},setup(t){const e=d.ref("|"),n=["|","/","-","\\"];let r=null;return d.onMounted(()=>{r=setInterval(()=>{const o=n.indexOf(e.value);e.value=n[(o+1)%n.length]},100)}),d.onUnmounted(()=>{r!==null&&clearInterval(r)}),(o,s)=>(d.openBlock(),d.createBlock(d.Transition,{name:"wov-loading-fade"},{default:d.withCtx(()=>[t.isLoading?(d.openBlock(),d.createElementBlock("div",p6,[d.createElementVNode("div",m6,d.toDisplayString(e.value),1)])):d.createCommentVNode("",!0)]),_:1}))}}),g6={class:"wov-action-bar"},y6=d.defineComponent({__name:"ActionBar",setup(t){const{getEditor:e}=ut(),n=d.inject(Rn),r=d.ref(!1),o=d.ref(!1);if(n){const l=n.registerTickCallback(c=>{const{store:u}=ls(c,"editing");r.value=u.canUndo(),o.value=u.canRedo()});d.onUnmounted(l)}function s(){const l=e();l==null||l.command(Hd)}function i(){const l=e();l==null||l.command(ql)}function a(){const l=e();l==null||l.command(Qd)}return(l,c)=>(d.openBlock(),d.createElementBlock("div",g6,[d.createElementVNode("button",{class:"wov-action-button",onClick:s,"aria-label":"Undo"},[...c[0]||(c[0]=[d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-undo-icon lucide-undo"},[d.createElementVNode("path",{d:"M3 7v6h6"}),d.createElementVNode("path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"})],-1)])]),d.createElementVNode("button",{class:"wov-action-button",onClick:i,"aria-label":"Redo"},[...c[1]||(c[1]=[d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-redo-icon lucide-redo"},[d.createElementVNode("path",{d:"M21 7v6h-6"}),d.createElementVNode("path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7"})],-1)])]),d.createElementVNode("button",{class:"wov-action-button",onClick:a,"aria-label":"Delete"},[...c[2]||(c[2]=[d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-trash-icon lucide-trash"},[d.createElementVNode("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}),d.createElementVNode("path",{d:"M3 6h18"}),d.createElementVNode("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})],-1)])])]))}}),Ar=d.defineComponent({__name:"ToolbarButton",props:{name:{},tooltip:{},dragOutSnapshot:{},placementSnapshot:{},cursor:{default:"crosshair"}},setup(t){const e=t,n=d.inject(_f);if(!n)throw new Error("ToolbarButton must be used within a Toolbar component");const r=n,o=d.ref(null),{show:s,hide:i}=Yo(),a=d.computed(()=>r.activeTool.value===e.name);function l(){r.setTool(e.name,e.placementSnapshot,e.cursor)}function c(){r.onToolPointerDown(e.name,e.dragOutSnapshot)}function u(){r.onToolPointerUp()}function f(){e.tooltip&&o.value&&s(e.tooltip,o.value)}function h(){i()}return(p,m)=>(d.openBlock(),d.createElementBlock("button",{ref_key:"buttonRef",ref:o,class:d.normalizeClass(["wov-toolbar-button",{selected:a.value}]),onClick:l,onPointerdown:c,onPointerup:u,onMouseenter:f,onMouseleave:h},[d.renderSlot(p.$slots,"default")],34))}}),w6='<?xml version="1.0" encoding="UTF-8"?><svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4.35 4.75" width="20" height="20"><defs><style>.cls-1{stroke:#fff;stroke-miterlimit:10;stroke-width:.25px;}</style></defs><path class="cls-1" d="M2.39,2.88s-.04.01-.05.02c-.01,0-.02.01-.03.02,0,.01-.02.02-.03.05l-.77,1.44c-.07.13-.1.19-.14.2-.03.01-.07,0-.1-.01-.03-.02-.05-.09-.09-.23L.16.41c-.03-.13-.05-.19-.03-.23.02-.03.04-.05.08-.06.04,0,.1.02.21.08l3.59,1.94c.13.07.19.1.2.14.01.03,0,.07-.01.1-.02.03-.09.05-.23.09l-1.58.4Z"/></svg>',v6='<?xml version="1.0" encoding="UTF-8"?><svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4.08 4.75" width="24" height="24"><defs><style>.cls-1{fill:#fff;stroke:#000;stroke-linecap:round;stroke-linejoin:round;stroke-width:.25px;}.cls-2{fill:none;stroke:#fff;stroke-miterlimit:10;stroke-width:.51px;}</style></defs><path class="cls-1" d="M.89,2.25v.63M.89,2.25V.75c0-.21.17-.38.38-.38s.38.17.38.38M.89,2.25c0-.21-.17-.37-.38-.37s-.38.17-.38.37v.5c0,1.04.86,1.87,1.91,1.87s1.91-.84,1.91-1.87v-1.25c0-.21-.17-.38-.38-.38s-.38.17.38.38M1.66.75v1.38M1.66.75v-.25c0-.21.17-.38.38-.38s.38.17.38.38v.25M2.42.75v1.38M2.42.75c0-.21.17-.38.38-.38s.38.17.38.38v.75M3.19,1.5v.63"/><line class="cls-2" x1="2.8" y1=".77" x2="2.8" y2="2.03"/><line class="cls-2" x1="2.04" y1=".64" x2="2.04" y2="2.02"/><line class="cls-2" x1="1.27" y1=".84" x2="1.27" y2="2.29"/></svg>',k6='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M4 8v-2a2 2 0 0 1 2 -2h2" /><path d="M4 16v2a2 2 0 0 0 2 2h2" /><path d="M16 4h2a2 2 0 0 1 2 2v2" /><path d="M16 20h2a2 2 0 0 0 2 -2v-2" /><path d="M9 12l6 0" /><path d="M12 9l0 6" /></svg>',Fs={Select:"select",Hand:"hand",Crosshair:"crosshair"},eS={[Fs.Select]:{makeSvg:()=>w6,hotspot:[1,0],rotationOffset:0},[Fs.Hand]:{makeSvg:()=>v6,hotspot:[12,12],rotationOffset:0},[Fs.Crosshair]:{makeSvg:()=>k6,hotspot:[12,12],rotationOffset:0}},b6={viewBox:"0 0 20 20",style:{"fill-rule":"evenodd","clip-rule":"evenodd","stroke-miterlimit":"10"}},tS=d.defineComponent({__name:"SelectTool",setup(t){const{nextEditorTick:e}=ut(),{activeTool:n}=ep();return d.watch(n,(r,o)=>{o==="select"&&e(s=>{Si.spawn(s)})}),(r,o)=>(d.openBlock(),d.createBlock(Ar,{name:"select",tooltip:"Select",cursor:d.unref(Fs).Select},{default:d.withCtx(()=>[(d.openBlock(),d.createElementBlock("svg",b6,[...o[0]||(o[0]=[d.createElementVNode("g",{transform:"matrix(4.21053,0,0,4.21053,0.842105,0)"},[d.createElementVNode("path",{fill:"none",stroke:"currentColor","stroke-width":"0.5",d:"M2.39,2.88C2.38,2.885 2.34,2.9 2.33,2.91C2.32,2.91 2.298,2.939 2.28,2.97L1.51,4.41C1.44,4.54 1.41,4.6 1.37,4.61C1.34,4.62 1.3,4.61 1.27,4.6C1.24,4.58 1.22,4.51 1.18,4.37L0.16,0.41C0.13,0.28 0.11,0.22 0.13,0.18C0.15,0.15 0.17,0.13 0.21,0.12C0.25,0.12 0.31,0.14 0.42,0.2L4.01,2.14C4.14,2.21 4.2,2.24 4.21,2.28C4.22,2.31 4.21,2.35 4.2,2.38C4.18,2.41 4.11,2.43 3.97,2.47L2.39,2.88Z"})],-1)])]))]),_:1},8,["cursor"]))}}),nS=d.defineComponent({__name:"HandTool",setup(t){return(e,n)=>(d.openBlock(),d.createBlock(Ar,{name:"hand",tooltip:"Hand",cursor:d.unref(Fs).Hand},{default:d.withCtx(()=>[...n[0]||(n[0]=[d.createElementVNode("svg",{viewBox:"0 0 20.56 24"},[d.createElementVNode("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4.47,11.39v3.18M4.47,11.39V3.81c0-1.06.86-1.92,1.92-1.92s1.92.86,1.92,1.92M4.47,11.39c0-1.06-.86-1.87-1.92-1.87s-1.92.86-1.92,1.87v2.53c0,5.25,4.35,9.45,9.65,9.45s9.65-4.24,9.65-9.45v-6.32c0-1.06-.86-1.92-1.92-1.92s-1.92.86-1.92,1.92M8.36,3.81v6.97M8.36,3.81v-1.26c0-1.06.86-1.92,1.92-1.92s1.92.86,1.92,1.92v1.26M12.2,3.81v6.97M12.2,3.81c0-1.06.86-1.92,1.92-1.92s1.92.86,1.92,1.92v3.79M16.09,7.6v3.18"})],-1)])]),_:1},8,["cursor"]))}}),rS=d.defineComponent({__name:"StickyNoteTool",setup(t){const e=JSON.stringify({block:{tag:"sticky-note",size:[200,200]},color:{red:255,green:242,blue:117},text:{defaultAlignment:Bn.Center},verticalAlign:{value:mt.Center}});return(n,r)=>(d.openBlock(),d.createBlock(Ar,{name:"sticky-note",tooltip:"Sticky Note","drag-out-snapshot":d.unref(e),"placement-snapshot":d.unref(e)},{default:d.withCtx(()=>[...r[0]||(r[0]=[d.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[d.createElementVNode("path",{d:"M4 4h12v12H4z"}),d.createElementVNode("path",{d:"M7 8h6M7 11h4"})],-1)])]),_:1},8,["drag-out-snapshot","placement-snapshot"]))}}),oS=d.defineComponent({__name:"ShapeTool",setup(t){const e=JSON.stringify({block:{tag:"shape",size:[200,200]},shape:{kind:"rectangle",strokeKind:Ct.Solid,strokeWidth:2,strokeRed:0,strokeGreen:0,strokeBlue:0,strokeAlpha:255,fillRed:255,fillGreen:255,fillBlue:255,fillAlpha:0},text:{defaultAlignment:Bn.Center},verticalAlign:{value:mt.Center}});return(n,r)=>(d.openBlock(),d.createBlock(Ar,{name:"shape",tooltip:"Shape","drag-out-snapshot":d.unref(e),"placement-snapshot":d.unref(e)},{default:d.withCtx(()=>[...r[0]||(r[0]=[d.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[d.createElementVNode("rect",{x:"3",y:"3",width:"14",height:"14",rx:"2"})],-1)])]),_:1},8,["drag-out-snapshot","placement-snapshot"]))}}),sS=d.defineComponent({__name:"EraserTool",setup(t){return(e,n)=>(d.openBlock(),d.createBlock(Ar,{name:"eraser",tooltip:"Eraser"},{default:d.withCtx(()=>[...n[0]||(n[0]=[d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 640",fill:"currentColor"},[d.createElementVNode("path",{d:"M210.5 480L333.5 480L398.8 414.7L225.3 241.2L98.6 367.9L210.6 479.9zM256 544L210.5 544C193.5 544 177.2 537.3 165.2 525.3L49 409C38.1 398.1 32 383.4 32 368C32 352.6 38.1 337.9 49 327L295 81C305.9 70.1 320.6 64 336 64C351.4 64 366.1 70.1 377 81L559 263C569.9 273.9 576 288.6 576 304C576 319.4 569.9 334.1 559 345L424 480L544 480C561.7 480 576 494.3 576 512C576 529.7 561.7 544 544 544L256 544z"})],-1)])]),_:1}))}}),iS=d.defineComponent({__name:"PenTool",setup(t){return(e,n)=>(d.openBlock(),d.createBlock(Ar,{name:"pen",tooltip:"Pen"},{default:d.withCtx(()=>[...n[0]||(n[0]=[d.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[d.createElementVNode("path",{d:"M13.586 3.586a2 2 0 1 1 2.828 2.828l-8.793 8.793-3.536.707.707-3.536 8.794-8.792Z","stroke-linecap":"round","stroke-linejoin":"round"}),d.createElementVNode("path",{d:"M12 5l3 3","stroke-linecap":"round"})],-1)])]),_:1}))}}),aS=d.defineComponent({__name:"TextTool",setup(t){const e=JSON.stringify({block:{tag:"text",size:[10,29]},text:{constrainWidth:!1,fontSizePx:24}}),n=JSON.stringify({block:{tag:"text",size:[36,29]},text:{content:"text",constrainWidth:!1,fontSizePx:24}});return(r,o)=>(d.openBlock(),d.createBlock(Ar,{name:"text",tooltip:"Text","drag-out-snapshot":d.unref(n),"placement-snapshot":d.unref(e)},{default:d.withCtx(()=>[...o[0]||(o[0]=[d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-type-icon lucide-type"},[d.createElementVNode("path",{d:"M12 4v16"}),d.createElementVNode("path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2"}),d.createElementVNode("path",{d:"M9 20h6"})],-1)])]),_:1},8,["drag-out-snapshot","placement-snapshot"]))}}),lS=d.defineComponent({__name:"ElbowArrowTool",setup(t){const e=JSON.stringify({block:{tag:"elbow-arrow",size:[200,200]},elbowArrow:{points:[0,0,.5,0,.5,1,1,1],pointCount:4,startArrowHead:De.None,endArrowHead:De.V},connector:{}});return(n,r)=>(d.openBlock(),d.createBlock(Ar,{name:"elbow-arrow",tooltip:"Elbow Arrow",cursor:"crosshair","drag-out-snapshot":d.unref(e)},{default:d.withCtx(()=>[...r[0]||(r[0]=[d.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},[d.createElementVNode("path",{d:"M4 6 L10 6 L10 14 L16 14"}),d.createElementVNode("path",{d:"M13 11 L16 14 L13 17"})],-1)])]),_:1},8,["drag-out-snapshot"]))}}),cS=d.defineComponent({__name:"ImageTool",setup(t){const{nextEditorTick:e}=ut(),{show:n,hide:r}=Yo(),{setTool:o}=ep(),{createImageBlock:s}=ob(),i=d.ref(null),a=d.ref(null);function l(){var h;(h=a.value)==null||h.click()}async function c(h){var S;const p=h.target,m=(S=p.files)==null?void 0:S[0];if(!m)return;if(p.value="",!m.type.startsWith("image/")){console.warn("Selected file is not an image");return}const g=await e(),y=we.read(g),w=_t.read(g),v=y.left+w.width/y.zoom/2,b=y.top+w.height/y.zoom/2;await s(m,v,b),o("select",void 0,Fs.Select)}function u(){i.value&&n("Image",i.value)}function f(){r()}return(h,p)=>(d.openBlock(),d.createElementBlock("button",{ref_key:"buttonRef",ref:i,class:"wov-toolbar-button",onClick:l,onMouseenter:u,onMouseleave:f},[p[0]||(p[0]=d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[d.createElementVNode("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),d.createElementVNode("circle",{cx:"9",cy:"9",r:"2"}),d.createElementVNode("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})],-1)),d.createElementVNode("input",{ref_key:"fileInputRef",ref:a,type:"file",accept:"image/*",style:{display:"none"},onChange:c},null,544)],544))}}),S6={class:"wov-toolbar-container"},uS=d.defineComponent({__name:"Toolbar",setup(t){const e=d.useSlots(),{reset:n}=Yo(),{nextEditorTick:r}=ut(),o=d.ref(null),s=d.ref(null),i=jt(ct),a=d.computed(()=>i.value.leftMouseTool),l=[tS,nS,aS,cS,oS,lS,rS,iS,sS],c=d.inject("containerRef"),u=d.ref(null),f=d.ref(!1),h=d.ref(null),p=d.ref(null),m=d.ref(1/0),g=d.ref(0),y=d.ref([]),w=d.ref(8),v=d.ref(48),{width:b}=Zb(c);function S(){return h.value?Array.from(h.value.children).filter(j=>!j.classList.contains("wov-overflow-button")&&!j.classList.contains("wov-menu-tooltip")):[]}function k(){var Te;const j=S();if(j.length===0)return;g.value=j.length;const X=getComputedStyle(h.value);w.value=parseFloat(X.gap)||8;const he=((Te=p.value)==null?void 0:Te.offsetWidth)||40;v.value=he+w.value,y.value=j.map(Ce=>Ce.offsetWidth)}function E(){if(y.value.length===0)return;const he=b.value-40-20,Te=w.value,Ce=v.value;let je=0,ar=0;for(let so=0;so<y.value.length;so++){const Ks=y.value[so],Go=je>0?Ks+Te:Ks,Xo=y.value.length-so-1>0?Ce:0;if(je+Go+Xo<=he)je+=Go,ar++;else break}m.value=Math.max(1,ar)}d.watch(b,()=>{y.value.length>0&&E()}),d.onMounted(()=>{d.nextTick(()=>{k(),E()})});const _=d.computed(()=>m.value<g.value);d.watchEffect(()=>{S().forEach((X,he)=>{X.style.display=he<m.value?"":"none"})}),d.watchEffect(()=>{if(!u.value)return;Array.from(u.value.children).forEach((X,he)=>{X.style.display=he>=m.value?"":"none"})});const{floatingStyles:M}=Iu(p,u,{placement:"top",middleware:[Tu(16),Au(),Mu({padding:8})],whileElementsMounted:Ob});function I(){f.value=!f.value}function P(){f.value=!1}function V(j){const X=j.target;p.value&&!p.value.contains(X)&&u.value&&!u.value.contains(X)&&P()}d.watch(f,j=>{j?document.addEventListener("click",V,!0):document.removeEventListener("click",V,!0)}),d.watch(_,j=>{j||P()});function Z(j,X,he){s.value=X??null,r(Te=>{const Ce=ct.write(Te);Ce.leftMouseTool=j,Ce.heldSnapshot=X??"",he&&Pn.setCursor(Te,he)})}function A(j){r(X=>{const he=ct.write(X);he.leftMouseTool="drag-out",he.heldSnapshot=j})}function F(j,X){o.value=j,s.value=X??null}function Y(){o.value=null,s.value=null}function ce(){n(),o.value&&s.value&&A(s.value),o.value=null,s.value=null}const se={activeTool:a,heldTool:o,setTool:Z,dragOutTool:A,onToolPointerDown:F,onToolPointerUp:Y};return d.provide(_f,se),(j,X)=>(d.openBlock(),d.createElementBlock("div",S6,[d.createVNode(y6),d.createElementVNode("div",{ref_key:"toolsContainerRef",ref:h,class:"wov-toolbar",onMouseleave:ce},[d.unref(e).default?d.renderSlot(j.$slots,"default",{key:0}):(d.openBlock(),d.createElementBlock(d.Fragment,{key:1},d.renderList(l,(he,Te)=>d.createVNode(d.resolveDynamicComponent(he),{key:Te})),64)),_.value?(d.openBlock(),d.createElementBlock("button",{key:2,ref_key:"overflowBtnRef",ref:p,class:d.normalizeClass(["wov-toolbar-button wov-overflow-button",{"menu-open":f.value}]),onClick:I},[...X[0]||(X[0]=[d.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[d.createElementVNode("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),d.createElementVNode("line",{x1:"5",y1:"12",x2:"19",y2:"12"})],-1)])],2)):d.createCommentVNode("",!0),d.createVNode(cp)],544),d.unref(c)?(d.openBlock(),d.createBlock(d.Teleport,{key:0,to:d.unref(c)},[f.value&&_.value?(d.openBlock(),d.createElementBlock("div",{key:0,ref_key:"overflowMenuRef",ref:u,class:"wov-toolbar-overflow-menu",style:d.normalizeStyle(d.unref(M))},[d.unref(e).default?d.renderSlot(j.$slots,"default",{key:0}):(d.openBlock(),d.createElementBlock(d.Fragment,{key:1},d.renderList(l,(he,Te)=>d.createVNode(d.resolveDynamicComponent(he),{key:Te})),64))],4)):d.createCommentVNode("",!0)],8,["to"])):d.createCommentVNode("",!0)]))}}),E6=d.defineComponent({__name:"ArcArrowTool",setup(t){return(e,n)=>(d.openBlock(),d.createBlock(Ar,{name:"arc-arrow",tooltip:"Arc Arrow",cursor:"crosshair"},{default:d.withCtx(()=>[...n[0]||(n[0]=[d.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},[d.createElementVNode("path",{d:"M4 14 Q 10 4, 16 14"}),d.createElementVNode("path",{d:"M13 11 L16 14 L12.5 15.5"})],-1)])]),_:1}))}}),C6={class:"wov-user-presence-avatars"},_6=["src","alt"],x6={class:"wov-user-presence-list"},T6=["src","alt"],M6={class:"wov-user-presence-name"},A6=4,dS=d.defineComponent({__name:"UserPresence",props:{users:{}},setup(t){const e=t,n=d.ref(!1),r=d.ref(null);jF(r,()=>{n.value=!1});function o(a){if(!a)return"?";const l=a.trim().split(/\s+/);return l.length>=2?(l[0][0]+l[1][0]).toUpperCase():a.slice(0,2).toUpperCase()}const s=d.computed(()=>e.users.map(a=>({sessionId:a.sessionId,name:a.name,color:a.color,avatar:a.avatar,initials:o(a.name)}))),i=d.computed(()=>s.value.slice(0,A6));return(a,l)=>t.users.length>1?(d.openBlock(),d.createElementBlock("div",{key:0,ref_key:"containerRef",ref:r,class:"wov-user-presence"},[d.createElementVNode("button",{class:d.normalizeClass(["wov-user-presence-trigger",{"is-open":n.value}]),onClick:l[0]||(l[0]=c=>n.value=!n.value)},[d.createElementVNode("div",C6,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(i.value,c=>(d.openBlock(),d.createElementBlock("div",{key:c.sessionId,class:"wov-user-avatar",style:d.normalizeStyle({backgroundColor:c.avatar?"transparent":c.color})},[c.avatar?(d.openBlock(),d.createElementBlock("img",{key:0,src:c.avatar,alt:c.name,class:"wov-user-avatar-img"},null,8,_6)):(d.openBlock(),d.createElementBlock(d.Fragment,{key:1},[d.createTextVNode(d.toDisplayString(c.initials),1)],64))],4))),128))])],2),n.value?(d.openBlock(),d.createElementBlock("div",{key:0,class:"wov-user-presence-dropdown",onWheel:l[1]||(l[1]=d.withModifiers(()=>{},["stop"]))},[d.createElementVNode("div",x6,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(s.value,c=>(d.openBlock(),d.createElementBlock("div",{key:c.sessionId,class:"wov-user-presence-item"},[d.createElementVNode("div",{class:"wov-user-avatar wov-user-avatar-small",style:d.normalizeStyle({backgroundColor:c.avatar?"transparent":c.color})},[c.avatar?(d.openBlock(),d.createElementBlock("img",{key:0,src:c.avatar,alt:c.name,class:"wov-user-avatar-img"},null,8,T6)):(d.openBlock(),d.createElementBlock(d.Fragment,{key:1},[d.createTextVNode(d.toDisplayString(c.initials),1)],64))],4),d.createElementVNode("span",M6,d.toDisplayString(c.name),1)]))),128))])],32)):d.createCommentVNode("",!0)],512)):d.createCommentVNode("",!0)}});async function wp(t,e){const n=await Tp(t,1,{upgrade(r){r.objectStoreNames.contains(e)||r.createObjectStore(e)}});return new I6(n,e)}var I6=class{constructor(t,e){this.db=t,this.storeName=e}async get(t){return this.db.get(this.storeName,t)}async put(t,e){await this.db.put(this.storeName,e,t)}async delete(t){await this.db.delete(this.storeName,t)}async getAllEntries(){const e=this.db.transaction(this.storeName,"readonly").objectStore(this.storeName),n=await e.getAllKeys(),r=await e.getAll(),o=[];for(let s=0;s<n.length;s++)o.push([n[s],r[s]]);return o}async clear(){const t=this.db.transaction(this.storeName,"readwrite");t.objectStore(this.storeName).clear(),await t.done}close(){this.db.close()}},N6=class{constructor(t){this.jobsStore=null,this.binariesStore=null,this.blobUrls=new Map,this.uploading=new Set,this.uploadPromises=new Map,this.provider=t.provider,this.documentId=t.documentId,this.maxRetries=t.provider.maxRetries??3,this.retryDelay=t.provider.retryDelay??5e3}async init(){const t=`wovencanvas-assets-${this.documentId}`,[e,n]=await Promise.all([wp(`${t}-jobs`,"jobs"),wp(`${t}-binaries`,"binaries")]);this.jobsStore=e,this.binariesStore=n}async upload(t,e,n){if(!this.jobsStore||!this.binariesStore)throw new Error("AssetManager not initialized");await this.binariesStore.put(t,e);const r={identifier:t,metadata:n,createdAt:Date.now(),retryCount:0};await this.jobsStore.put(t,r);const o=URL.createObjectURL(e);return this.blobUrls.set(t,o),new Promise((s,i)=>{this.uploadPromises.set(t,{resolve:s,reject:i}),this.startUpload(t)})}async getDisplayUrl(t){const e=this.blobUrls.get(t);if(e)return e;try{return await this.provider.resolveUrl(t)}catch(n){return console.error(`Failed to resolve URL for ${t}:`,n),null}}async resumePendingUploads(){if(!this.jobsStore||!this.binariesStore)throw new Error("AssetManager not initialized");const t=await this.jobsStore.getAllEntries();for(const[e]of t){const n=await this.binariesStore.get(e);if(n){const r=URL.createObjectURL(n);this.blobUrls.set(e,r)}this.startUpload(e)}}hasPendingUpload(t){return this.blobUrls.has(t)}isUploading(t){return this.uploading.has(t)}async cancelUpload(t){if(!this.jobsStore||!this.binariesStore)return;const e=this.blobUrls.get(t);e&&(URL.revokeObjectURL(e),this.blobUrls.delete(t)),await this.jobsStore.delete(t),await this.binariesStore.delete(t),this.uploading.delete(t);const n=this.uploadPromises.get(t);n&&(n.reject(new Error("Upload cancelled")),this.uploadPromises.delete(t))}close(){var t,e;for(const n of this.blobUrls.values())URL.revokeObjectURL(n);this.blobUrls.clear(),(t=this.jobsStore)==null||t.close(),(e=this.binariesStore)==null||e.close(),this.jobsStore=null,this.binariesStore=null}async startUpload(t){if(!this.jobsStore||!this.binariesStore||this.uploading.has(t))return;this.uploading.add(t);const e=await this.jobsStore.get(t),n=await this.binariesStore.get(t);if(!e||!n){this.uploading.delete(t);return}try{await this.provider.upload(n,t,e.metadata),await this.onUploadSuccess(t)}catch(r){await this.onUploadError(t,e,r)}}async onUploadSuccess(t){if(!this.jobsStore||!this.binariesStore)return;const e=this.blobUrls.get(t);e&&(URL.revokeObjectURL(e),this.blobUrls.delete(t)),await this.jobsStore.delete(t),await this.binariesStore.delete(t),this.uploading.delete(t);const n=this.uploadPromises.get(t);n&&(n.resolve(),this.uploadPromises.delete(t))}async onUploadError(t,e,n){if(!this.jobsStore)return;const r=n instanceof Error?n.message:"Unknown error";if(console.error(`Upload failed for ${t}:`,r),this.uploading.delete(t),e.retryCount<this.maxRetries){const o={...e,retryCount:e.retryCount+1};await this.jobsStore.put(t,o),setTimeout(()=>{this.startUpload(t)},this.retryDelay*2**e.retryCount)}else{const o=this.uploadPromises.get(t);o&&(o.reject(new Error(r)),this.uploadPromises.delete(t))}}},B6="wovencanvas-assets",P6="blobs",O6=class{constructor(){this.store=null,this.initPromise=null,this.maxRetries=3,this.retryDelay=5e3}async upload(t,e,n){return await(await this.getStore()).put(e,{blob:t,metadata:n}),{}}async resolveUrl(t){const n=await(await this.getStore()).get(t);if(!n)throw new Error(`Asset not found: ${t}`);return URL.createObjectURL(n.blob)}async delete(t){await(await this.getStore()).delete(t)}close(){this.store&&(this.store.close(),this.store=null,this.initPromise=null)}getStore(){return this.store?Promise.resolve(this.store):(this.initPromise||(this.initPromise=wp(B6,P6).then(t=>(this.store=t,t))),this.initPromise)}},fS=vr.object({minZoom:vr.number().default(.05),maxZoom:vr.number().default(2.7),disableWheel:vr.boolean().default(!1)});fS.parse({});var ll=Eo("panState",{state:C.string().max(16).default("idle"),panStartX:C.float64().default(0),panStartY:C.float64().default(0),velocityX:C.float64().default(0),velocityY:C.float64().default(0),targetX:C.float64().default(0),targetY:C.float64().default(0),expectedLeft:C.float64().default(0),expectedTop:C.float64().default(0)}),js=Ki({name:"pinchState"},{active:C.boolean().default(!1),prevDistance:C.float64().default(0),prevCenter:C.tuple(C.float64(),2).default([0,0])}),no=[0,0],Du=[0,0],cl=[0,0],vp=[0,0],kp=[0,0];function D6(t,e,n,r,o,s){r=Math.max(1e-4,r);const i=2/r,a=i*s,l=1/(1+a+.48*a*a+.235*a*a*a);$.copy(no,t),$.sub(no,e);const c=o*r,u=c*c,f=$.lengthSq(no);f>u&&$.scale(no,c/Math.sqrt(f)),$.copy(Du,t),$.sub(Du,no),$.set(cl,(n[0]+i*no[0])*s,(n[1]+i*no[1])*s);const h=[(n[0]-i*cl[0])*l,(n[1]-i*cl[1])*l],p=[Du[0]+(no[0]+cl[0])*l,Du[1]+(no[1]+cl[1])*l];return $.copy(vp,e),$.sub(vp,t),$.copy(kp,p),$.sub(kp,e),$.dot(vp,kp)>0&&(p[0]=e[0],p[1]=e[1],h[0]=(p[0]-e[0])/s,h[1]=(p[1]-e[1])/s),{position:p,velocity:h}}var bp=.1,hS=.1,R6=$r({guards:{hasVelocity:({event:t})=>{if(t.type!=="pointerUp")return!1;const e=t.velocity;return Math.hypot(e[0],e[1])>hS},isGlideComplete:({context:t})=>Math.hypot(t.velocityX,t.velocityY)<hS,cameraWasMoved:({context:t,event:e})=>{const n=we.read(e.ctx);return n.left!==t.expectedLeft||n.top!==t.expectedTop},isEscapeKey:({event:t})=>t.key===dn.Escape},actions:{setDragStart:Ke({panStartX:({event:t})=>t.worldPosition[0],panStartY:({event:t})=>t.worldPosition[1]}),moveCamera:({context:t,event:e})=>{const n=e,{ctx:r}=n,o=n.worldPosition[0]-t.panStartX,s=n.worldPosition[1]-t.panStartY,i=we.write(r);i.left-=o,i.top-=s},startGlide:Ke(({event:t})=>{const e=t,{ctx:n}=e,r=we.read(n),o=e.cameraZoom,s=-e.velocity[0]/o,i=-e.velocity[1]/o;return{velocityX:s,velocityY:i,targetX:r.left+s*bp,targetY:r.top+i*bp,expectedLeft:r.left,expectedTop:r.top}}),animateGlide:Ke(({context:t,event:e})=>{const n=e,{ctx:r,delta:o}=n,s=we.read(r),{position:i,velocity:a}=D6([s.left,s.top],[t.targetX,t.targetY],[t.velocityX,t.velocityY],bp,Number.POSITIVE_INFINITY,o),l=we.write(r);return l.left=i[0],l.top=i[1],{velocityX:a[0],velocityY:a[1],expectedLeft:i[0],expectedTop:i[1]}}),resetContext:Ke({panStartX:0,panStartY:0,velocityX:0,velocityY:0,targetX:0,targetY:0,expectedLeft:0,expectedTop:0})}}).createMachine({id:"pan",initial:"idle",context:{panStartX:0,panStartY:0,velocityX:0,velocityY:0,targetX:0,targetY:0,expectedLeft:0,expectedTop:0},states:{idle:{on:{pointerDown:{actions:"setDragStart",target:"panning"}}},panning:{entry:"moveCamera",on:{pointerMove:{actions:"moveCamera"},pointerUp:[{guard:"hasVelocity",actions:"startGlide",target:"gliding"},{target:"idle"}],keyDown:{guard:"isEscapeKey",target:"idle"}}},gliding:{on:{frame:[{guard:"cameraWasMoved",actions:"resetContext",target:"idle"},{guard:"isGlideComplete",actions:"resetContext",target:"idle"},{actions:"animateGlide"}],pointerDown:{actions:["resetContext","setDragStart"],target:"panning"}}}}}),z6=Se({phase:"input",priority:-100},t=>{const e=ll.read(t).state;if(js.read(t).active){e!=="idle"&&ll.copy(t,ll.default());return}const r=ct.getButtons(t,"hand"),s=[...Wr(t,r)];e==="gliding"&&s.push(sN(t)),s.push(...iN(t,[dn.Escape])),s.length!==0&&ll.run(t,R6,s)}),$6=ie(t=>t.with(Et)),L6=Se({phase:"input",priority:-100},t=>{const e=ls(t,"controls"),n=$6.current(t),r=[];for(let m=0;m<n.length;m++){const g=n[m],y=Et.read(t,g);y.pointerType===Vr.Touch&&r.push(y.position)}if(r.length!==2){if(js.read(t).active){const g=js.write(t);g.active=!1}return}const[o,s]=r,i=$.distance(o,s),a=$.midPoint(o,s),l=js.read(t);if(!l.active){const m=js.write(t);m.prevDistance=i,m.prevCenter=a,m.active=!0;return}const c=we.read(t),u=_t.read(t);if(l.prevDistance>0&&i>0){const m=i/l.prevDistance;let g=c.zoom*m;g=Math.min(e.maxZoom,Math.max(e.minZoom,g));const y=u.width/c.zoom,w=u.height/c.zoom,v=u.width/g,b=u.height/g,S=v-y,k=b-w,E=a[0]/u.width,_=a[1]/u.height,M=we.write(t);M.left-=E*S,M.top-=_*k,M.zoom=g}const f=a[0]-l.prevCenter[0],h=a[1]-l.prevCenter[1];if(f!==0||h!==0){const m=we.write(t);m.left-=f/m.zoom,m.top-=h/m.zoom}const p=js.write(t);p.prevDistance=i,p.prevCenter=a}),V6=Se({phase:"input",priority:-100},t=>{const e=Sn.read(t);if(!ct.wheelActive(t,"scroll",e.modDown))return;const r=ky(t).find(l=>l.type==="wheel");if(!r)return;const o=we.read(t),s=o.left+r.wheelDeltaX/o.zoom,i=o.top+r.wheelDeltaY/o.zoom,a=we.write(t);a.left=s,a.top=i}),F6=Se({phase:"input",priority:-100},t=>{const e=ls(t,"controls"),n=Sn.read(t);if(!ct.wheelActive(t,"zoom",n.modDown))return;const o=ky(t).find(S=>S.type==="wheel");if(!o)return;const s=we.read(t),i=_t.read(t),a=On.read(t);let l=2**(-.8*o.wheelDeltaY/500)*s.zoom;l=Math.min(e.maxZoom,Math.max(e.minZoom,l));const c=i.width/s.zoom,u=i.height/s.zoom,f=i.width/l,h=i.height/l,p=f-c,m=h-u,g=a.position[0]/i.width,y=a.position[1]/i.height,w=s.left-g*p,v=s.top-y*m,b=we.write(t);b.left=w,b.top=v,b.zoom=l});function j6(t={}){const e=fS.parse(t);return{name:"controls",resources:e,singletons:[ll,js],systems:[F6,V6,z6,L6],setup(n){if(e.disableWheel){const{domElement:r}=He(n);g2(r,!1)}}}}var W6=(t={})=>j6(t);const U6={class:"wov-selection-box"},H6=d.defineComponent({__name:"SelectionBox",setup(t){return(e,n)=>(d.openBlock(),d.createElementBlock("div",U6))}}),Z6={class:"wov-transform-box"},K6=d.defineComponent({__name:"TransformBox",setup(t){return(e,n)=>(d.openBlock(),d.createElementBlock("div",Z6))}}),Y6={},q6={class:"wov-transform-handle"};function J6(t,e){return d.openBlock(),d.createElementBlock("div",q6)}const G6=ys(Y6,[["render",J6]]),X6=d.defineComponent({__name:"StickyNote",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},setup(t){const e=t,n=Tt(e.entityId,In),r=Tt(e.entityId,cs),o=d.ref(null),s={[mt.Top]:"flex-start",[mt.Center]:"center",[mt.Bottom]:"flex-end"},i=d.computed(()=>{var l;return{backgroundColor:n.value?`rgb(${n.value.red}, ${n.value.green}, ${n.value.blue})`:void 0,minHeight:`${e.block.size[0]}px`,alignItems:s[((l=r.value)==null?void 0:l.value)??mt.Top]}}),{handleEditEnd:a}=Qh({blockData:e,containerRef:o,minWidth:()=>e.block.size[0],minHeight:()=>e.block.size[0]});return(l,c)=>(d.openBlock(),d.createElementBlock("div",{ref_key:"containerRef",ref:o,class:"wov-sticky-note",style:d.normalizeStyle(i.value)},[d.createVNode(mu,d.mergeProps(e,{"block-element":o.value,onEditEnd:d.unref(a)}),null,16,["block-element","onEditEnd"])],4))}}),Ru=Ki({name:"blockPlacementState"},{editedCheckpoint:C.string().default("").max(36)}),pS=ie(t=>t.with(Lr));function Q6(t){var e;if(!t)return null;try{const n=JSON.parse(t);return(e=n.block)!=null&&e.tag?n:(console.warn("Block snapshot missing required tag:",n),null)}catch{return console.warn("Invalid block snapshot JSON:",t),null}}function e5(t,e,n){const r=Xt(t,e.block.tag);if(!r)throw new Error(`Block placement: block definition for tag "${e.block.tag}" not found`);const o=e.block.size??[100,100],s=n[0]-o[0]/2,i=n[1]-o[1]/2,a=e.block.rank??Zn.genNext(t),l=Bt(t);"synced"in e||ee(t,l,me,{id:crypto.randomUUID()});const c=Object.assign({},e.block,{position:[s,i],size:o,rank:a});ee(t,l,T,c);for(const f of r.components)if(!(f.name in e))ee(t,l,f);else{const h=e[f.name];ee(t,l,f,h)}const{sessionId:u}=He(t);return ee(t,l,Rt,{sessionId:u}),l}function mS(t,e,n,r,o){const s=e5(t,e,n),i=T.read(t,s);if(ay(t,e.block.tag)&&(ee(t,s,Ca,{}),o==="placement")){const{store:u}=ls(t,"editing"),f=u.createCheckpoint();if(f){const h=Ru.write(t);h.editedCheckpoint=f}}const a=Xn.write(t);a.state=o==="dragOut"?_e.Dragging:_e.Pointing,a.dragStart=n,a.draggedEntity=s,a.draggedEntityStart=i.position,a.pointingStartClient=r,a.pointingStartWorld=n,a.isCloning=!1;const l=ct.write(t);l.leftMouseTool="select",l.heldSnapshot="";const c=Pn.write(t);c.cursorKind="select",c.rotation=0}function t5(t){const e=Ru.read(t);if(e.editedCheckpoint){const n=e.editedCheckpoint;Ru.write(t).editedCheckpoint="";const{store:r}=ls(t,"editing");r.onSettled(()=>r.squashToCheckpoint(n),{frames:5})}}const n5=Se({phase:"capture"},t=>{pS.removed(t).length>0&&pS.current(t).length===0&&t5(t);const e=ct.read(t);if(!e.heldSnapshot)return;const n=Wr(t,[bn.Left]);if(n.length===0)return;const r=Q6(e.heldSnapshot);if(!r)return;if(e.leftMouseTool==="drag-out"){const s=n.find(i=>i.type==="pointerMove"&&!i.obscured);if(!s)return;mS(t,r,s.worldPosition,s.screenPosition,"dragOut")}else{const s=n.find(i=>i.type==="pointerDown"&&!i.obscured);if(!s)return;mS(t,r,s.worldPosition,s.screenPosition,"placement")}}),r5=Se({phase:"update"},t=>{const{store:e}=ls(t,"editing");fe(t,Hd,()=>{e.canUndo()&&(t0(t),e.undo())}),fe(t,ql,()=>{e.canRedo()&&(t0(t),e.redo())})}),o5=[{name:"Figtree",displayName:"Figtree",url:"https://fonts.googleapis.com/css2?family=Figtree",previewImage:"https://storage.googleapis.com/scrolly-page-fonts/Figtree.png"},{name:"Shantell Sans",displayName:"Shantell Sans",url:"https://fonts.googleapis.com/css2?family=Shantell+Sans",previewImage:"https://storage.googleapis.com/scrolly-page-fonts/ShantellSans.png"},{name:"Courier Prime",displayName:"Courier Prime",url:"https://fonts.googleapis.com/css2?family=Courier+Prime",previewImage:"https://storage.googleapis.com/scrolly-page-fonts/CourierPrime.png"},{name:"EB Garamond",displayName:"EB Garamond",url:"https://fonts.googleapis.com/css2?family=EB+Garamond",previewImage:"https://storage.googleapis.com/scrolly-page-fonts/EBGaramond.png"}];function gS(t){return{name:"editing",resources:{store:t.store},singletons:[Ru],systems:[n5,r5],cursors:eS,fonts:o5,keybinds:[{command:Hd.name,key:dn.Z,mod:!0},{command:ql.name,key:dn.Y,mod:!0},{command:ql.name,key:dn.Z,mod:!0,shift:!0}]}}const s5=d.defineComponent({__name:"FileDropZone",props:{maxSize:{default:400}},setup(t){const e=t,{nextEditorTick:n}=ut(),{createImageBlock:r}=ob(),o=d.ref(!1);let s=0;const i=d.inject("containerRef");function a(v){var b;(b=v.dataTransfer)!=null&&b.types.some(S=>S==="Files"||S==="text/uri-list"||S==="text/html")&&(s++,s===1&&(o.value=!0))}function l(){s--,s===0&&(o.value=!1)}function c(){s=0,o.value=!1}d.onMounted(()=>{const v=i==null?void 0:i.value;v&&(v.addEventListener("dragenter",a),v.addEventListener("dragleave",l),v.addEventListener("drop",c))}),d.onUnmounted(()=>{const v=i==null?void 0:i.value;v&&(v.removeEventListener("dragenter",a),v.removeEventListener("dragleave",l),v.removeEventListener("drop",c))});function u(v){v.preventDefault(),v.dataTransfer&&(v.dataTransfer.dropEffect="copy")}function f(v){v.preventDefault()}function h(v){v.preventDefault()}async function p(v){if(v.preventDefault(),!v.dataTransfer)return;const b=v.clientX,S=v.clientY,k=Array.from(v.dataTransfer.files).filter(_=>_.type.startsWith("image/"));if(k.length>0){for(const _ of k)await y(_,b,S);return}const E=m(v.dataTransfer);E&&await w(E,b,S)}function m(v){const b=v.getData("text/uri-list");if(b){const _=b.split(`
170
+ `):""}),z1=Z4,$1="&nbsp;",K4=" ",Y4=Fh.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Fi(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);const r=e.parseInline(n);return r.length===1&&r[0].type==="text"&&(r[0].text===$1||r[0].text===K4)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e)=>{if(!t)return"";const n=Array.isArray(t.content)?t.content:[];return n.length===0?$1:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),L1=Y4,q4=Fh.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),V1=q4,F1=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]},J4=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,G4=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,X4=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Q4=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,eL=nl.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return F1("strong",{...Fi(this.options.HTMLAttributes,t),children:F1("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[uu({find:J4,type:this.type}),uu({find:X4,type:this.type})]},addPasteRules(){return[du({find:G4,type:this.type}),du({find:Q4,type:this.type})]}}),j1=eL,tL=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,nL=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,rL=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,oL=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,sL=nl.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",Fi(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[uu({find:tL,type:this.type}),uu({find:rL,type:this.type})]},addPasteRules(){return[du({find:nL,type:this.type}),du({find:oL,type:this.type})]}}),W1=sL,iL=nl.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",Fi(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const o=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!o)return;const s=o[2].trim();return{type:"underline",raw:o[0],text:s,tokens:n.inlineTokens(s)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),U1=iL,aL=Je.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).some(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),H1=aL,lL=20,Z1=(t,e=0)=>{const n=[];return!t.children.length||e>lL||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...Z1(r,e+1))}),n},cL=t=>{if(!t.children.length)return;const e=Z1(t);e&&e.forEach(n=>{var r,o;const s=n.getAttribute("style"),i=(o=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:o.getAttribute("style");n.setAttribute("style",`${i};${s}`)})},jh=nl.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&cL(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",Fi(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(o=>o.type===this.type).some(o=>Object.values(o.attrs).some(s=>!!s))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),uL=Je.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(o=>o.trim()).filter(Boolean);for(let o=r.length-1;o>=0;o-=1){const s=r[o].split(":");if(s.length>=2){const i=s[0].trim().toLowerCase(),a=s.slice(1).join(":").trim();if(i==="background-color")return a.replace(/['"]+/g,"")}}}return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),K1=Je.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(o=>o.trim()).filter(Boolean);for(let o=r.length-1;o>=0;o-=1){const s=r[o].split(":");if(s.length>=2){const i=s[0].trim().toLowerCase(),a=s.slice(1).join(":").trim();if(i==="color")return a.replace(/['"]+/g,"")}}}return(e=t.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),dL=Je.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>t.style.fontFamily,renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),fL=Je.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),hL=Je.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>t.style.lineHeight,renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}});Je.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(uL.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(K1.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(dL.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(fL.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(hL.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(jh.configure(this.options.textStyle)),t}});var Y1=K1;function pL(t={}){return new wt({view(e){return new mL(e,t)}})}class mL{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let s=i=>{this[o](i)};return e.dom.addEventListener(o,s),{name:o,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,o=this.editorView.dom,s=o.getBoundingClientRect(),i=s.width/o.offsetWidth,a=s.height/o.offsetHeight;if(n){let f=e.nodeBefore,h=e.nodeAfter;if(f||h){let p=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(p){let m=p.getBoundingClientRect(),g=f?m.bottom:m.top;f&&h&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*a;r={left:m.left,right:m.right,top:g-y,bottom:g+y}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),h=this.width/2*i;r={left:f.left-h,right:f.left+h,top:f.top,bottom:f.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,u;if(!l||l==document.body&&getComputedStyle(l).position=="static")c=-pageXOffset,u=-pageYOffset;else{let f=l.getBoundingClientRect(),h=f.width/l.offsetWidth,p=f.height/l.offsetHeight;c=f.left-l.scrollLeft*h,u=f.top-l.scrollTop*p}this.element.style.left=(r.left-c)/i+"px",this.element.style.top=(r.top-u)/a+"px",this.element.style.width=(r.right-r.left)/i+"px",this.element.style.height=(r.bottom-r.top)/a+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),o=r&&r.type.spec.disableDropCursor,s=typeof o=="function"?o(this.editorView,n,e):o;if(n&&!s){let i=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=fv(this.editorView.state.doc,i,this.editorView.dragging.slice);a!=null&&(i=a)}this.setCursor(i),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class ot extends be{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return ot.valid(r)?new ot(r):be.near(r)}content(){return K.empty}eq(e){return e instanceof ot&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new ot(e.resolve(n.pos))}getBookmark(){return new Wh(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!gL(e)||!yL(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let o=n.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&ot.valid(e))return e;let o=e.pos,s=null;for(let i=e.depth;;i--){let a=e.node(i);if(n>0?e.indexAfter(i)<a.childCount:e.index(i)>0){s=a.child(n>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;o+=n;let l=e.doc.resolve(o);if(ot.valid(l))return l}for(;;){let i=n>0?s.firstChild:s.lastChild;if(!i){if(s.isAtom&&!s.isText&&!ae.isSelectable(s)){e=e.doc.resolve(o+s.nodeSize*n),r=!1;continue e}break}s=i,o+=n;let a=e.doc.resolve(o);if(ot.valid(a))return a}return null}}}ot.prototype.visible=!1,ot.findFrom=ot.findGapCursorFrom,be.jsonID("gapcursor",ot);class Wh{constructor(e){this.pos=e}map(e){return new Wh(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return ot.valid(n)?new ot(n):be.near(n)}}function q1(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function gL(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||q1(o.type))return!0;if(o.inlineContent)return!1}}return!0}function yL(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||q1(o.type))return!0;if(o.inlineContent)return!1}}return!0}function wL(){return new wt({props:{decorations:SL,createSelectionBetween(t,e,n){return e.pos==n.pos&&ot.valid(n)?new ot(n):null},handleClick:kL,handleKeyDown:vL,handleDOMEvents:{beforeinput:bL}}})}const vL=Qk({ArrowLeft:fu("horiz",-1),ArrowRight:fu("horiz",1),ArrowUp:fu("vert",-1),ArrowDown:fu("vert",1)});function fu(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,s){let i=r.selection,a=e>0?i.$to:i.$from,l=i.empty;if(i instanceof ye){if(!s.endOfTextblock(n)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let c=ot.findGapCursorFrom(a,e,l);return c?(o&&o(r.tr.setSelection(new ot(c))),!0):!1}}function kL(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!ot.valid(r))return!1;let o=t.posAtCoords({left:n.clientX,top:n.clientY});return o&&o.inside>-1&&ae.isSelectable(t.state.doc.nodeAt(o.inside))?!1:(t.dispatch(t.state.tr.setSelection(new ot(r))),!0)}function bL(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof ot))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let o=D.empty;for(let i=r.length-1;i>=0;i--)o=D.from(r[i].createAndFill(null,o));let s=t.state.tr.replace(n.pos,n.pos,new K(o,0,0));return s.setSelection(ye.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function SL(t){if(!(t.selection instanceof ot))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",nt.create(t.doc,[on.widget(t.selection.head,e,{key:"gapcursor"})])}var hu=200,Nt=function(){};Nt.prototype.append=function(e){return e.length?(e=Nt.from(e),!this.length&&e||e.length<hu&&this.leafAppend(e)||this.length<hu&&e.leafPrepend(this)||this.appendInner(e)):this},Nt.prototype.prepend=function(e){return e.length?Nt.from(e).append(this):this},Nt.prototype.appendInner=function(e){return new EL(this,e)},Nt.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Nt.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))},Nt.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Nt.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)},Nt.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(s,i){return o.push(e(s,i))},n,r),o},Nt.from=function(e){return e instanceof Nt?e:e&&e.length?new J1(e):Nt.empty};var J1=function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(o,s){return o==0&&s==this.length?this:new e(this.values.slice(o,s))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,s,i,a){for(var l=s;l<i;l++)if(o(this.values[l],a+l)===!1)return!1},e.prototype.forEachInvertedInner=function(o,s,i,a){for(var l=s-1;l>=i;l--)if(o(this.values[l],a+l)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=hu)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=hu)return new e(o.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e}(Nt);Nt.empty=new J1([]);var EL=function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,o,s,i){var a=this.left.length;if(o<a&&this.left.forEachInner(r,o,Math.min(s,a),i)===!1||s>a&&this.right.forEachInner(r,Math.max(o-a,0),Math.min(this.length,s)-a,i+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,o,s,i){var a=this.left.length;if(o>a&&this.right.forEachInvertedInner(r,o-a,Math.max(s,a)-a,i+a)===!1||s<a&&this.left.forEachInvertedInner(r,Math.min(o,a),s,i)===!1)return!1},e.prototype.sliceInner=function(r,o){if(r==0&&o==this.length)return this;var s=this.left.length;return o<=s?this.left.slice(r,o):r>=s?this.right.slice(r-s,o-s):this.left.slice(r,s).append(this.right.slice(0,o-s))},e.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new e(o,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(Nt);const CL=500;class rr{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,s;n&&(o=this.remapping(r,this.items.length),s=o.maps.length);let i=e.tr,a,l,c=[],u=[];return this.items.forEach((f,h)=>{if(!f.step){o||(o=this.remapping(r,h+1),s=o.maps.length),s--,u.push(f);return}if(o){u.push(new Cr(f.map));let p=f.step.map(o.slice(s)),m;p&&i.maybeStep(p).doc&&(m=i.mapping.maps[i.mapping.maps.length-1],c.push(new Cr(m,void 0,void 0,c.length+u.length))),s--,m&&o.appendMap(m,s)}else i.maybeStep(f.step);if(f.selection)return a=o?f.selection.map(o.slice(s)):f.selection,l=new rr(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:i,selection:a}}addTransform(e,n,r,o){let s=[],i=this.eventCount,a=this.items,l=!o&&a.length?a.get(a.length-1):null;for(let u=0;u<e.steps.length;u++){let f=e.steps[u].invert(e.docs[u]),h=new Cr(e.mapping.maps[u],f,n),p;(p=l&&l.merge(h))&&(h=p,u?s.pop():a=a.slice(0,a.length-1)),s.push(h),n&&(i++,n=void 0),o||(l=h)}let c=i-r.depth;return c>xL&&(a=_L(a,c),i-=c),new rr(a.append(s),i)}remapping(e,n){let r=new za;return this.items.forEach((o,s)=>{let i=o.mirrorOffset!=null&&s-o.mirrorOffset>=e?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,i)},e,n),r}addMaps(e){return this.eventCount==0?this:new rr(this.items.append(e.map(n=>new Cr(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],o=Math.max(0,this.items.length-n),s=e.mapping,i=e.steps.length,a=this.eventCount;this.items.forEach(h=>{h.selection&&a--},o);let l=n;this.items.forEach(h=>{let p=s.getMirror(--l);if(p==null)return;i=Math.min(i,p);let m=s.maps[p];if(h.step){let g=e.steps[p].invert(e.docs[p]),y=h.selection&&h.selection.map(s.slice(l+1,p));y&&a++,r.push(new Cr(m,g,y))}else r.push(new Cr(m))},o);let c=[];for(let h=n;h<i;h++)c.push(new Cr(s.maps[h]));let u=this.items.slice(0,o).append(c).append(r),f=new rr(u,a);return f.emptyItemCount()>CL&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,o=[],s=0;return this.items.forEach((i,a)=>{if(a>=e)o.push(i),i.selection&&s++;else if(i.step){let l=i.step.map(n.slice(r)),c=l&&l.getMap();if(r--,c&&n.appendMap(c,r),l){let u=i.selection&&i.selection.map(n.slice(r));u&&s++;let f=new Cr(c.invert(),l,u),h,p=o.length-1;(h=o.length&&o[p].merge(f))?o[p]=h:o.push(f)}}else i.map&&r--},this.items.length,0),new rr(Nt.from(o.reverse()),s)}}rr.empty=new rr(Nt.empty,0);function _L(t,e){let n;return t.forEach((r,o)=>{if(r.selection&&e--==0)return n=o,!1}),t.slice(n)}class Cr{constructor(e,n,r,o){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new Cr(n.getMap().invert(),n,this.selection)}}}class Ho{constructor(e,n,r,o,s){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=o,this.prevComposition=s}}const xL=20;function TL(t,e,n,r){let o=n.getMeta(Ds),s;if(o)return o.historyState;n.getMeta(IL)&&(t=new Ho(t.done,t.undone,null,0,-1));let i=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(i&&i.getMeta(Ds))return i.getMeta(Ds).redo?new Ho(t.done.addTransform(n,void 0,r,pu(e)),t.undone,G1(n.mapping.maps),t.prevTime,t.prevComposition):new Ho(t.done,t.undone.addTransform(n,void 0,r,pu(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let a=n.getMeta("composition"),l=t.prevTime==0||!i&&t.prevComposition!=a&&(t.prevTime<(n.time||0)-r.newGroupDelay||!ML(n,t.prevRanges)),c=i?Uh(t.prevRanges,n.mapping):G1(n.mapping.maps);return new Ho(t.done.addTransform(n,l?e.selection.getBookmark():void 0,r,pu(e)),rr.empty,c,n.time,a??t.prevComposition)}else return(s=n.getMeta("rebased"))?new Ho(t.done.rebased(n,s),t.undone.rebased(n,s),Uh(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Ho(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Uh(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function ML(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,o)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&o>=e[s]&&(n=!0)}),n}function G1(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,o,s,i)=>e.push(s,i));return e}function Uh(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let o=e.map(t[r],1),s=e.map(t[r+1],-1);o<=s&&n.push(o,s)}return n}function AL(t,e,n){let r=pu(e),o=Ds.get(e).spec.config,s=(n?t.undone:t.done).popEvent(e,r);if(!s)return null;let i=s.selection.resolve(s.transform.doc),a=(n?t.done:t.undone).addTransform(s.transform,e.selection.getBookmark(),o,r),l=new Ho(n?a:s.remaining,n?s.remaining:a,null,0,-1);return s.transform.setSelection(i).setMeta(Ds,{redo:n,historyState:l})}let Hh=!1,X1=null;function pu(t){let e=t.plugins;if(X1!=e){Hh=!1,X1=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Hh=!0;break}}return Hh}const Ds=new tn("history"),IL=new tn("closeHistory");function NL(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new wt({key:Ds,state:{init(){return new Ho(rr.empty,rr.empty,null,0,-1)},apply(e,n,r){return TL(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,o=r=="historyUndo"?eb:r=="historyRedo"?tb:null;return!o||!e.editable?!1:(n.preventDefault(),o(e.state,e.dispatch))}}}})}function Q1(t,e){return(n,r)=>{let o=Ds.getState(n);if(!o||(t?o.undone:o.done).eventCount==0)return!1;if(r){let s=AL(o,n,t);s&&r(e?s.scrollIntoView():s)}return!0}}const eb=Q1(!1,!0),tb=Q1(!0,!0);Je.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc;if(((t==null?void 0:t.mode)||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new wt({key:new tn("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const o=this.options.limit;if(o==null||o===0){t=!0;return}const s=this.storage.characters({node:r.doc});if(s>o){const i=s-o,a=0,l=i;console.warn(`[CharacterCount] Initial content exceeded limit of ${o} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(a,l);return t=!0,c}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const o=this.storage.characters({node:n.doc}),s=this.storage.characters({node:e.doc});if(s<=r||o>r&&s>r&&s<=o)return!0;if(o>r&&s>r&&s>o||!e.getMeta("paste"))return!1;const a=e.selection.$head.pos,l=s-r,c=a-l,u=a;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>r)}})]}}),Je.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[pL(this.options)]}}),Je.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new wt({key:new tn("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:o}=e,s=[];if(!n||!r)return nt.create(t,[]);let i=0;this.options.mode==="deepest"&&t.descendants((l,c)=>{if(l.isText)return;if(!(o>=c&&o<=c+l.nodeSize-1))return!1;i+=1});let a=0;return t.descendants((l,c)=>{if(l.isText||!(o>=c&&o<=c+l.nodeSize-1))return!1;if(a+=1,this.options.mode==="deepest"&&i-a>0||this.options.mode==="shallowest"&&a>1)return this.options.mode==="deepest";s.push(on.node(c,c+l.nodeSize,{class:this.options.className}))}),nt.create(t,s)}}})]}}),Je.create({name:"gapCursor",addProseMirrorPlugins(){return[wL()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=We(oe(t,"allowGapCursor",n)))!=null?e:null}}});var nb="placeholder";function BL(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}Je.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:nb,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${BL(this.options.dataAttribute)}`:`data-${nb}`;return[new wt({key:new tn("placeholder"),props:{decorations:({doc:e,selection:n})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:o}=n,s=[];if(!r)return null;const i=this.editor.isEmpty;return e.descendants((a,l)=>{const c=o>=l&&o<=l+a.nodeSize,u=!a.isLeaf&&su(a);if((c||!this.options.showOnlyCurrent)&&u){const f=[this.options.emptyNodeClass];i&&f.push(this.options.emptyEditorClass);const h=on.node(l,l+a.nodeSize,{class:f.join(" "),[t]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:a,pos:l,hasAnchor:c}):this.options.placeholder});s.push(h)}return this.options.includeChildren}),nt.create(e,s)}}})]}}),Je.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new wt({key:new tn("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||q$(n.selection)||t.view.dragging?null:nt.create(n.doc,[on.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function rb({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}Je.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new tn(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,o])=>o).filter(o=>(this.options.notAfter||[]).concat(n).includes(o.name));return[new wt({key:e,appendTransaction:(o,s,i)=>{const{doc:a,tr:l,schema:c}=i,u=e.getState(i),f=a.content.size,h=c.nodes[n];if(u)return l.insert(f,h.create())},state:{init:(o,s)=>{const i=s.tr.doc.lastChild;return!rb({node:i,types:r})},apply:(o,s)=>{if(!o.docChanged||o.getMeta("__uniqueIDTransaction"))return s;const i=o.doc.lastChild;return!rb({node:i,types:r})}}})]}});var PL=Je.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>eb(t,e),redo:()=>({state:t,dispatch:e})=>tb(t,e)}},addProseMirrorPlugins(){return[NL(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}});function Zo(t,e){const n=d.inject(Rn);if(!n)throw new Error("useComponents must be used within a WovenCanvas component");const r=d.shallowRef(new Map),o=new Map;function s(a){if(o.has(a))return;const l=n.getEditor();if(l){const u=l._getContext();if(R(u,a,e)){const f=new Map(r.value);f.set(a,e.snapshot(u,a)),r.value=f}else{const f=new Map(r.value);f.set(a,null),r.value=f}}const c=n.subscribeComponent(a,e.name,u=>{const f=new Map(r.value);f.set(a,u),r.value=f});o.set(a,c)}function i(a){const l=o.get(a);if(l){l(),o.delete(a);const c=new Map(r.value);c.delete(a),r.value=c}}return d.watch(()=>d.toValue(t),(a,l)=>{const c=new Set(a),u=new Set(l??[]);for(const f of u)c.has(f)||i(f);for(const f of c)u.has(f)||s(f)},{immediate:!0}),d.onUnmounted(()=>{for(const a of o.values())a();o.clear()}),r}function ob(){const t=d.inject(Rn);if(!t)throw new Error("useImageCreation must be used within a WovenCanvas component");const{nextEditorTick:e}=ut();function n(s){return new Promise((i,a)=>{const l=new window.Image;l.onload=()=>{i({width:l.naturalWidth,height:l.naturalHeight}),URL.revokeObjectURL(l.src)},l.onerror=()=>{a(new Error("Failed to load image")),URL.revokeObjectURL(l.src)},l.src=URL.createObjectURL(s)})}async function r(s,i,a,l={}){const{maxSize:c=400}=l,u=await n(s),f=await e(),h=Math.min(1,c/Math.max(u.width,u.height));let p=Math.round(u.width*h),m=Math.round(u.height*h);const g=Ut.read(f);g.enabled&&(p=Math.max(g.colWidth,Math.round(p/g.colWidth)*g.colWidth),m=Math.max(g.rowHeight,Math.round(m/g.rowHeight)*g.rowHeight));const y=Bt(f);ee(f,y,T);const w=T.write(f,y);w.tag="image",w.position[0]=i-p/2,w.position[1]=a-m/2,w.size[0]=p,w.size[1]=m,Ut.snapPosition(f,w.position);const v=crypto.randomUUID();ee(f,y,as);const b=as.write(f,y);b.identifier=v,b.uploadState=mr.Pending,ee(f,y,ea);const S=ea.write(f,y);return S.width=u.width,S.height=u.height,S.alt=s.name,ee(f,y,me,{id:crypto.randomUUID()}),(t==null?void 0:t.getAssetManager())&&o(y,v,s),y}async function o(s,i,a){const l=t==null?void 0:t.getAssetManager();if(l)try{await l.upload(i,a,{filename:a.name,mimeType:a.type});const c=await e(),u=as.write(c,s);u.uploadState=mr.Complete}catch{const c=await e(),u=as.write(c,s);u.uploadState=mr.Failed}}return{getImageDimensions:n,createImageBlock:r}}function sb(t){const e=d.inject(Rn);if(!e)throw new Error("useQuery must be used within a WovenCanvas component");const n=d.shallowRef([]),r=ie(f=>f.with(...t)),o=new Map;let s=!1;function i(f){const h=e.getEditor();if(!h)return{refs:{},unsubscribes:[]};const p=h._getContext(),m={},g=[];for(const y of t){const w=d.shallowRef(y.snapshot(p,f));m[y.name]=w;const v=e.subscribeComponent(f,y.name,b=>{w.value=b});g.push(v)}return{refs:m,unsubscribes:g}}function a(f){const h=o.get(f);if(h){for(const p of h.unsubscribes)p();o.delete(f)}}function l(){const f=[];for(const[h,p]of o)f.push({entityId:h,...p.refs});return f}function c(f){if(!s){const g=r.current(f);for(const y of g)o.set(y,i(y));n.value=l(),s=!0;return}const h=r.added(f),p=r.removed(f);let m=!1;for(const g of p)a(g),m=!0;for(const g of h)o.has(g)||(o.set(g,i(g)),m=!0);m&&(n.value=l())}const u=e.registerTickCallback(c);return d.onUnmounted(()=>{u();for(const f of o.keys())a(f)}),n}function jt(t){const e=d.inject(Rn);if(!e)throw new Error("useSingleton must be used within a WovenCanvas component");const n=d.shallowRef(t.default()),r=e.getEditor();if(r){const i=r._getContext();n.value=t.snapshot(i)}const o=e.subscribeSingleton(t.name,i=>{n.value=i??{}});let s=null;return r||(s=e.registerTickCallback(()=>{const i=e.getEditor();if(i){const a=i._getContext();n.value=t.snapshot(a),s==null||s(),s=null}})),d.onUnmounted(()=>{o(),s==null||s()}),n}function OL(t,e,n){if(n===0)return{width:t,height:e};if(Math.abs(n-Math.PI/2)<1e-4)return{width:e,height:t};const r=Math.abs(Math.cos(n)),o=Math.abs(Math.sin(n)),s=(e-o/r*t)/(r-o*o/r);return{width:t/r-s*o/r,height:s}}function Zh(t,e,n){const r=t.closest(".wov-block");if(!r){const E=t.getBoundingClientRect();return{width:E.width,height:E.height,left:0,top:0}}const o=window.getComputedStyle(r).transform,s=new DOMMatrix(o),i=Math.atan2(s.b,s.a),a=t.getBoundingClientRect(),l=n.value.left,c=n.value.top,u=new DOMPoint(a.left+a.width/2-l,a.top+a.height/2-c),f=e.value.left,h=e.value.top,p=e.value.zoom,m=new DOMMatrix;m.translateSelf(-f*p,-h*p),m.scaleSelf(p,p),m.invertSelf();const g=m.transformPoint(u),y=m.transformPoint(new DOMPoint(a.left-l,a.top-c)),w=m.transformPoint(new DOMPoint(a.right-l,a.bottom-c)),v=w.x-y.x,b=w.y-y.y,{width:S,height:k}=OL(v,b,-i);return{width:S,height:k,left:g.x-S/2,top:g.y-k/2}}function ib(t){if(t.startsWith("#"))return t.toUpperCase();const e=t.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);if(e){const n=parseInt(e[1],10).toString(16).padStart(2,"0"),r=parseInt(e[2],10).toString(16).padStart(2,"0"),o=parseInt(e[3],10).toString(16).padStart(2,"0");return`#${n}${r}${o}`.toUpperCase()}return t}function rl(t){const e=Math.round(t.red),n=Math.round(t.green),r=Math.round(t.blue),o=Math.round(t.alpha);return o<255?"#"+[e,n,r,o].map(s=>{const i=s.toString(16);return i.length===1?`0${i}`:i}).join(""):"#"+[e,n,r].map(s=>{const i=s.toString(16);return i.length===1?`0${i}`:i}).join("")}function Kh(t){t=t.replace(/^#/,"");let e,n,r,o=255;if(t.length===6)e=parseInt(t.slice(0,2),16),n=parseInt(t.slice(2,4),16),r=parseInt(t.slice(4,6),16);else if(t.length===8)e=parseInt(t.slice(0,2),16),n=parseInt(t.slice(2,4),16),r=parseInt(t.slice(4,6),16),o=parseInt(t.slice(6,8),16);else return null;return{red:e,green:n,blue:r,alpha:o}}function ab(t){const e=Kh(t);if(!e)return{h:0,s:100,v:100,a:255};const n=e.red/255,r=e.green/255,o=e.blue/255,s=Math.max(n,r,o),i=Math.min(n,r,o),a=s-i;let l=0;const c=s===0?0:a/s*100,u=s*100;if(a!==0)switch(s){case n:l=((r-o)/a+(r<o?6:0))*60;break;case r:l=((o-n)/a+2)*60;break;case o:l=((n-r)/a+4)*60;break}return{h:l,s:c,v:u,a:e.alpha}}function lb(t){const e=t.h/360,n=t.s/100,r=t.v/100;let o=0,s=0,i=0;const a=Math.floor(e*6),l=e*6-a,c=r*(1-n),u=r*(1-l*n),f=r*(1-(1-l)*n);switch(a%6){case 0:o=r,s=f,i=c;break;case 1:o=u,s=r,i=c;break;case 2:o=c,s=r,i=f;break;case 3:o=c,s=u,i=r;break;case 4:o=f,s=c,i=r;break;case 5:o=r,s=c,i=u;break}const h=p=>Math.round(p*255).toString(16).padStart(2,"0");return`#${h(o)}${h(s)}${h(i)}`}function cb(t){const e=t.h/360,n=t.s/100,r=t.v/100;let o=0,s=0,i=0;const a=Math.floor(e*6),l=e*6-a,c=r*(1-n),u=r*(1-l*n),f=r*(1-(1-l)*n);switch(a%6){case 0:o=r,s=f,i=c;break;case 1:o=u,s=r,i=c;break;case 2:o=c,s=r,i=f;break;case 3:o=c,s=u,i=r;break;case 4:o=f,s=c,i=r;break;case 5:o=r,s=c,i=u;break}const h=m=>Math.round(m*255).toString(16).padStart(2,"0"),p=Math.round(t.a).toString(16).padStart(2,"0");return t.a<255?`#${h(o)}${h(s)}${h(i)}${p}`:`#${h(o)}${h(s)}${h(i)}`}const hn=d.shallowRef(null),Yh=d.shallowRef(null),qh=d.shallowRef(null),Ko=d.ref(0);function ol(){const t={hasEditor:d.computed(()=>hn.value!==null),isBold:d.computed(()=>{var o;return Ko.value,((o=hn.value)==null?void 0:o.isActive("bold"))??!1}),isItalic:d.computed(()=>{var o;return Ko.value,((o=hn.value)==null?void 0:o.isActive("italic"))??!1}),isUnderline:d.computed(()=>{var o;return Ko.value,((o=hn.value)==null?void 0:o.isActive("underline"))??!1}),alignment:d.computed(()=>{Ko.value;const o=hn.value;return o?o.isActive({textAlign:"center"})?"center":o.isActive({textAlign:"right"})?"right":o.isActive({textAlign:"justify"})?"justify":"left":"left"}),color:d.computed(()=>{Ko.value;const o=hn.value;if(!o)return null;const i=o.getAttributes("textStyle").color??null;return i?ib(i):null})},e={toggleBold(){const o=hn.value;if(!o)return;const{from:s,to:i}=o.state.selection,a=s===i;let l=o.chain().focus();a&&(l=l.selectAll()),l=l.toggleBold(),a&&(l=l.setTextSelection(i)),l.run()},toggleItalic(){const o=hn.value;if(!o)return;const{from:s,to:i}=o.state.selection,a=s===i;let l=o.chain().focus();a&&(l=l.selectAll()),l=l.toggleItalic(),a&&(l=l.setTextSelection(i)),l.run()},toggleUnderline(){const o=hn.value;if(!o)return;const{from:s,to:i}=o.state.selection,a=s===i;let l=o.chain().focus();a&&(l=l.selectAll()),l=l.toggleUnderline(),a&&(l=l.setTextSelection(i)),l.run()},setAlignment(o){const s=hn.value;s&&s.chain().selectAll().setTextAlign(o).run()},setColor(o){const s=hn.value;if(!s)return;const{from:i,to:a}=s.state.selection;i===a?s.chain().focus().selectAll().setColor(o).setTextSelection(a).run():s.chain().focus().setColor(o).run()}};function n(o,s,i){hn.value=o,qh.value=s,Yh.value=i,o.on("selectionUpdate",()=>{Ko.value++}),o.on("transaction",()=>{Ko.value++})}function r(){hn.value=null,qh.value=null,Yh.value=null}return{editor:hn,blockElement:Yh,textElement:qh,state:t,commands:e,updateCounter:Ko,register:n,unregister:r}}const Fn=[z1,L1,V1,jh,Y1,j1,W1,U1,H1.configure({types:["paragraph"],alignments:["left","center","right","justify"],defaultAlignment:"left"})];function DL(t){return t.type==="text"&&typeof t.text=="string"}function Rs(t,e){if(DL(t)){e(t);return}if(t.content)for(const n of t.content)Rs(n,e)}function Jh(t,e){if(t.type==="paragraph"){e(t);return}if(t.content)for(const n of t.content)Jh(n,e)}function RL(t,e){var n;return((n=t.marks)==null?void 0:n.some(r=>r.type===e))??!1}function zL(t){var r,o;const e=(r=t.marks)==null?void 0:r.find(s=>s.type==="textStyle"),n=((o=e==null?void 0:e.attrs)==null?void 0:o.color)??null;return n?ib(n):null}function $L(t,e){if(!t.trim())return!1;const n=Uo(t,Fn);let r=!1,o=!0,s=0;return Rs(n,i=>{s++,RL(i,e)?r=!0:o=!1}),s===0?!1:o?!0:r?null:!1}function LL(t){if(!t.trim())return"left";const e=Uo(t,Fn);let n="left";return Jh(e,r=>{var s;const o=(s=r.attrs)==null?void 0:s.textAlign;o&&(n=o)}),n}function VL(t){if(!t.trim())return null;const e=Uo(t,Fn);let n=null;return Rs(e,r=>{n===null&&(n=zL(r))}),n}function Gh(t,e){if(!t.trim())return t;const n=Uo(t,Fn);return Rs(n,r=>{const o=r.marks??[];o.findIndex(i=>i.type===e)===-1&&(r.marks=[...o,{type:e}])}),ru(n,Fn)}function Xh(t,e){if(!t.trim())return t;const n=Uo(t,Fn);return Rs(n,r=>{const o=r.marks??[];r.marks=o.filter(s=>s.type!==e)}),ru(n,Fn)}function FL(t,e){if(!t.trim())return t;const n=Uo(t,Fn);return Jh(n,r=>{r.attrs={...r.attrs,textAlign:e}}),ru(n,Fn)}function jL(t,e){if(!t.trim())return t;const n=Uo(t,Fn);return Rs(n,r=>{const o=r.marks??[],s=o.findIndex(i=>i.type==="textStyle");s!==-1?(o[s]={...o[s],attrs:{...o[s].attrs,color:e}},r.marks=o):r.marks=[...o,{type:"textStyle",attrs:{color:e}}]}),ru(n,Fn)}function ub(t){const e=document.querySelector(`[data-entity-id="${t}"]`);if(!e)return null;const n=e.firstElementChild;return n||e.querySelector(".wov-editable-text")}function db(t,e,n,r){var l;const o=t.cloneNode(!0);o.style.position="absolute",o.style.visibility="hidden",o.style.pointerEvents="none",o.style.top="0",o.style.left="0";const s=o.classList.contains("wov-editable-text")?o:o.querySelector(".wov-editable-text");s&&(s.style.fontSize=`${r.fontSizePx}px`,s.style.fontFamily=r.fontFamily);const i=o.querySelector(".ProseMirror, .tiptap");i?i.innerHTML=r.content:s?s.innerHTML=r.content:o.innerHTML=r.content,(l=t.parentElement)==null||l.appendChild(o);const a=Zh(o,e,n);return o.remove(),a}function fb(t){const{nextEditorTick:e}=ut(),n=Zo(t,gt),r=jt(we),o=jt(_t),s=ol(),i={hasTextEntities:d.computed(()=>{for(const h of n.value.values())if(h)return!0;return!1}),hasTextContent:d.computed(()=>{for(const h of n.value.values()){if(!h)continue;const p=h.content?Uo(h.content,Fn):null;if(p){let m=!1;if(Rs(p,g=>{var y;(y=g.text)!=null&&y.trim()&&(m=!0)}),m)return!0}}return!1}),isBold:d.computed(()=>a("bold")),isItalic:d.computed(()=>a("italic")),isUnderline:d.computed(()=>a("underline")),alignment:d.computed(()=>{let h=null;for(const p of n.value.values()){if(!p)continue;const m=LL(p.content);if(h===null)h=m;else if(h!==m)return null}return h??"left"}),color:d.computed(()=>{let h=null,p=!1;for(const m of n.value.values()){if(!m)continue;const g=VL(m.content);if(!p)h=g,p=!0;else if(h!==g)return null}return h}),fontSize:d.computed(()=>{let h=null,p=!1;for(const m of n.value.values())if(m){if(!p)h=m.fontSizePx,p=!0;else if(h!==m.fontSizePx)return null}return h}),fontFamily:d.computed(()=>{let h=null,p=!1;for(const m of n.value.values())if(m){if(!p)h=m.fontFamily,p=!0;else if(h!==m.fontFamily)return null}return h})};function a(h){let p=null,m=!1;for(const g of n.value.values()){if(!g)continue;const y=$L(g.content,h);if(!m)p=y,m=!0;else if(p!==y)return null}return p}const l={toggleBold(){u(h=>i.isBold.value?Xh(h,"bold"):Gh(h,"bold"))},toggleItalic(){u(h=>i.isItalic.value?Xh(h,"italic"):Gh(h,"italic"))},toggleUnderline(){u(h=>i.isUnderline.value?Xh(h,"underline"):Gh(h,"underline"))},setAlignment(h){f(p=>FL(p,h))},setColor(h){f(p=>jL(p,h))},setFontSize(h){c(p=>({...p,fontSizePx:h}),p=>{p.fontSizePx=h})},setFontFamily(h){c(p=>({...p,fontFamily:h}),p=>{p.fontFamily=h})}};function c(h,p){const m=d.toValue(t),g=[];for(const y of m){const w=n.value.get(y);if(!w)continue;const v=ub(y);if(v){const b=db(v,r,o,h(w));g.push({entityId:y,...b})}}e(y=>{for(const w of m)p(gt.write(y,w));for(const{entityId:w,width:v,height:b,left:S,top:k}of g){const E=T.write(y,w);E.size=[v,b],E.position=[S,k]}d.nextTick(()=>{s.updateCounter.value++})})}function u(h){const p=d.toValue(t),m=[];for(const g of p){const y=n.value.get(g);if(!y)continue;const w=h(y.content),v=ub(g);if(v){const b=db(v,r,o,{...y,content:w});m.push({entityId:g,content:w,...b})}else m.push({entityId:g,content:w,width:0,height:0,left:0,top:0})}e(g=>{for(const{entityId:y,content:w,width:v,height:b,left:S,top:k}of m){const E=gt.write(g,y);if(E.content=w,v>0&&b>0){const _=T.write(g,y);_.size=[v,b],_.position=[S,k]}}})}function f(h){const p=d.toValue(t);e(m=>{for(const g of p){const y=gt.write(m,g);y.content=h(y.content)}})}return{state:i,commands:l}}function _r(t){const e=ol(),n=fb(t),r=e.state.hasEditor;return{state:d.reactive({hasTextToFormat:d.computed(()=>r.value||n.state.hasTextEntities.value),hasEditor:r,hasTextContent:d.computed(()=>n.state.hasTextContent.value),showTextMenuButtons:d.computed(()=>r.value||n.state.hasTextContent.value),isBold:d.computed(()=>r.value?e.state.isBold.value:n.state.isBold.value===!0),isItalic:d.computed(()=>r.value?e.state.isItalic.value:n.state.isItalic.value===!0),isUnderline:d.computed(()=>r.value?e.state.isUnderline.value:n.state.isUnderline.value===!0),alignment:d.computed(()=>r.value?e.state.alignment.value:n.state.alignment.value??"left"),color:d.computed(()=>r.value?e.state.color.value:n.state.color.value),fontSize:d.computed(()=>n.state.fontSize.value),fontFamily:d.computed(()=>n.state.fontFamily.value)}),commands:{toggleBold(){r.value?e.commands.toggleBold():n.commands.toggleBold()},toggleItalic(){r.value?e.commands.toggleItalic():n.commands.toggleItalic()},toggleUnderline(){r.value?e.commands.toggleUnderline():n.commands.toggleUnderline()},setAlignment(i){r.value?e.commands.setAlignment(i):n.commands.setAlignment(i)},setColor(i){r.value?e.commands.setColor(i):n.commands.setColor(i)},setFontSize(i){n.commands.setFontSize(i)},setFontFamily(i){n.commands.setFontFamily(i)}}}}function Qh(t){const e=jt(we),n=jt(_t),r=jt(af),o=jt(Xn),{nextEditorTick:s}=ut();let i=!1,a=null;function l(u,f){const{entityId:h}=d.toValue(t.blockData),p=d.toValue(t.minWidth)??0,m=d.toValue(t.minHeight)??0,g=Math.max(f.width,p),y=Math.max(f.height,m),w=T.read(u,h),v=Math.abs(w.size[0]-g)>.5,b=Math.abs(w.size[1]-y)>.5;if(!v&&!b)return;const S=T.write(u,h);S.size=[g,y],S.position=[f.left,f.top],r.value.transformBoxId!==null&&nf.spawn(u,{transformBoxId:r.value.transformBoxId})}d.watch(()=>o.value,()=>{const u=t.containerRef.value;u&&i&&(a=Zh(u,e,n)),s(f=>{const h=WL(f);i&&!h&&a&&(l(f,a),a=null),i=h})},{flush:"sync"});function c(u){const{content:f,...h}=u;s(p=>{const{entityId:m}=d.toValue(t.blockData);if(gt.read(p,m).content!==f){const y=gt.write(p,m);y.content=f}l(p,h)})}return{handleEditEnd:c}}function WL(t){const e=Xn.read(t);return e.state===_e.Dragging&&e.draggedEntity!==null&&R(t,e.draggedEntity,qe)&&qe.read(t,e.draggedEntity).kind===Gn.Stretch}function ep(){const t=d.inject(_f);if(!t)throw new Error("useToolbar must be used within a Toolbar component");return{activeTool:t.activeTool,heldTool:t.heldTool,setTool:t.setTool,dragOutTool:t.dragOutTool,onToolPointerDown:t.onToolPointerDown,onToolPointerUp:t.onToolPointerUp,isActive:e=>d.computed(()=>t.activeTool.value===e)}}const UL=500,HL=1500;function hb(){const t=d.ref(null),e=d.ref(!1),n=d.ref(!1);let r=null,o=null;function s(){r&&(clearTimeout(r),r=null),o&&(clearTimeout(o),o=null)}function i(c,u){s(),t.value={text:c,anchor:u},n.value?e.value=!0:r=setTimeout(()=>{e.value=!0,n.value=!0,r=null},UL)}function a(){s(),e.value=!1,t.value=null,n.value&&(o=setTimeout(()=>{n.value=!1,o=null},HL))}function l(){s(),e.value=!1,t.value=null,n.value=!1}return{activeTooltip:d.readonly(t),isVisible:d.readonly(e),isWarmedUp:d.readonly(n),show:i,hide:a,reset:l}}function Yo(){const t=d.inject(F0);if(!t)throw new Error("useTooltipSingleton must be used within a WovenCanvas component");return t}const ZL={key:1},KL=["innerHTML"],YL=50,qL=300,mu=d.defineComponent({__name:"EditableText",props:{blockElement:{},entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},emits:["editEnd"],setup(t,{expose:e,emit:n}){var k;const r=t,o=n,s=Tt(r.entityId,gt),i=jt(we),a=jt(_t),l=ol(),{nextEditorTick:c}=ut(),u=jt(On),f=d.ref(null);e({editableTextRef:f});const h=d.ref(((k=s.value)==null?void 0:k.content)??""),p=d.shallowRef(null);function m(E,_){var P;const M=s.value;return!M||M.constrainWidth||(((P=_.clipboardData)==null?void 0:P.getData("text/plain"))??"").length>YL&&c(V=>{const Z=gt.write(V,r.entityId);Z.constrainWidth=!0;const A=T.read(V,r.entityId),F=Math.max(A.size[0],qL),Y=T.write(V,r.entityId);Y.size=[F,A.size[1]],sy.spawn(V),Si.spawn(V)}),!1}function g(){var E,_;return new U4({extensions:[z1,L1,V1,jh,Y1,j1,W1,U1,H1.configure({types:["paragraph"],alignments:["left","center","right","justify"],defaultAlignment:((E=s.value)==null?void 0:E.defaultAlignment)??"left"}),PL],content:((_=s.value)==null?void 0:_.content)??"",editable:!0,parseOptions:{preserveWhitespace:!0},editorProps:{handlePaste:m}})}d.watch(()=>r.edited,async E=>{if(E&&f.value){if(p.value=g(),await y(p.value),!r.blockElement)return;l.register(p.value,f.value,r.blockElement)}else p.value&&(l.unregister(),w(p.value),p.value.destroy(),p.value=null)},{immediate:!0});async function y(E){var P;const _=(P=u.value)==null?void 0:P.position,M=a.value;await d.nextTick(),await new Promise(V=>requestAnimationFrame(V));const I=f.value;if(_&&M&&I){const V=_[0]+M.left,Z=_[1]+M.top,A=E.view.posAtCoords({left:V,top:Z});if(A){E.chain().focus().setTextSelection(A.pos).run();return}}E.commands.focus("start")}function w(E){let _=E.getHTML();const I=_.replace(/<[^>]*>/g,"").trim().length>0;I||(_=""),h.value=_,c(P=>{var Y,ce;const V=Xt(P,r.block.tag);if(!I&&((Y=V.editOptions)!=null&&Y.removeWhenTextEmpty)){st(P,r.entityId);return}const Z=(ce=f.value)==null?void 0:ce.closest(".wov-block"),A=(Z==null?void 0:Z.firstElementChild)??f.value;if(!A){console.warn("EditableText: no element to measure");return}const F=Zh(A,i,a);o("editEnd",{content:_,...F})})}d.watch(()=>{var E;return(E=s.value)==null?void 0:E.content},E=>{E!==void 0&&(p.value?p.value.getHTML()!==E&&p.value.commands.setContent(E,{emitUpdate:!1}):h.value=E)});const v=d.computed(()=>{const E=s.value;return E?{fontFamily:E.fontFamily,fontSize:`${E.fontSizePx}px`,lineHeight:E.lineHeight,letterSpacing:`${E.letterSpacingEm}em`,width:E.constrainWidth?"100%":"fit-content",whiteSpace:E.constrainWidth?"pre-wrap":"pre",minWidth:"2px",wordBreak:"break-word",pointerEvents:r.edited?"auto":"none",userSelect:r.edited?"auto":"none"}:{}});function b(E){E.key==="Control"||E.key==="Meta"||E.stopPropagation()}function S(E){r.edited&&E.stopPropagation()}return d.onUnmounted(()=>{p.value&&(l.unregister(),p.value.destroy(),p.value=null)}),(E,_)=>(d.openBlock(),d.createElementBlock("div",{ref_key:"editableTextRef",ref:f,class:"wov-editable-text",style:d.normalizeStyle(v.value),onKeydown:b,onPointerdown:S,onPointermove:S,onPointerup:S},[p.value?(d.openBlock(),d.createBlock(d.unref(H4),{key:0,editor:p.value},null,8,["editor"])):(d.openBlock(),d.createElementBlock("div",ZL,[d.createElementVNode("div",{class:"tiptap ProseMirror",innerHTML:h.value},null,8,KL)]))],36))}}),JL={class:"wov-shape-svg",viewBox:"0 0 100 100",preserveAspectRatio:"none"},GL=["d","fill","stroke","stroke-width","stroke-dasharray"],pb=d.defineComponent({__name:"ShapeBlock",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},setup(t){const e=t,n=Tt(e.entityId,Nn),r=Tt(e.entityId,cs),o=d.ref(null),s={[mt.Top]:"flex-start",[mt.Center]:"center",[mt.Bottom]:"flex-end"},i=d.computed(()=>n.value?`rgba(${n.value.fillRed}, ${n.value.fillGreen}, ${n.value.fillBlue}, ${(n.value.fillAlpha??255)/255})`:"rgba(0, 0, 0, 0)"),a=d.computed(()=>n.value?n.value.strokeKind===Ct.None?"none":`rgba(${n.value.strokeRed}, ${n.value.strokeGreen}, ${n.value.strokeBlue}, ${n.value.strokeAlpha/255})`:"rgba(0, 0, 0, 1)"),l=d.computed(()=>{var g;return((g=n.value)==null?void 0:g.strokeWidth)??2}),c=d.computed(()=>{var g;return((g=n.value)==null?void 0:g.strokeKind)??Ct.Solid}),u=d.computed(()=>{var g;return Ba[((g=n.value)==null?void 0:g.kind)??"rectangle"]??Ba.rectangle}),f=d.computed(()=>{const g=l.value;switch(c.value){case Ct.Dashed:return`${g*3} ${g*3}`;case Ct.None:return"";case Ct.Solid:default:return""}}),h=d.computed(()=>{var g;return{overflow:e.edited?"visible":"hidden",alignItems:s[((g=r.value)==null?void 0:g.value)??mt.Top]}}),{nextEditorTick:p}=ut();function m(g){p(y=>{if(gt.read(y,e.entityId).content===g.content)return;const v=gt.write(y,e.entityId);v.content=g.content})}return(g,y)=>(d.openBlock(),d.createElementBlock("div",{ref_key:"containerRef",ref:o,class:"wov-shape-block"},[(d.openBlock(),d.createElementBlock("svg",JL,[d.createElementVNode("path",{d:u.value,fill:i.value,stroke:a.value,"stroke-width":l.value,"stroke-dasharray":f.value,"stroke-linecap":"round","stroke-linejoin":"round","vector-effect":"non-scaling-stroke"},null,8,GL)])),d.createElementVNode("div",{class:"wov-shape-content",style:d.normalizeStyle(h.value)},[d.createVNode(mu,d.mergeProps(e,{"block-element":o.value,onEditEnd:m}),null,16,["block-element"])],4)],512))}}),XL=["data-text-empty"],mb=d.defineComponent({__name:"TextBlock",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},setup(t){const e=t,n=d.ref(null),r=Tt(e.entityId,gt),o=d.computed(()=>{var l;return(((l=r.value)==null?void 0:l.content)??"").replace(/<[^>]*>/g,"").trim().length===0}),{handleEditEnd:s}=Qh({blockData:e,containerRef:n});return(i,a)=>(d.openBlock(),d.createElementBlock("div",{ref_key:"containerRef",ref:n,class:"wov-text-block","data-text-empty":o.value||void 0},[d.createVNode(mu,d.mergeProps(e,{"block-element":n.value,onEditEnd:d.unref(s)}),null,16,["block-element","onEditEnd"])],8,XL))}}),gu=Math.min,zs=Math.max,yu=Math.round,wu=Math.floor,xr=t=>({x:t,y:t}),QL={left:"right",right:"left",bottom:"top",top:"bottom"},eV={start:"end",end:"start"};function gb(t,e,n){return zs(t,gu(e,n))}function vu(t,e){return typeof t=="function"?t(e):t}function $s(t){return t.split("-")[0]}function ku(t){return t.split("-")[1]}function yb(t){return t==="x"?"y":"x"}function wb(t){return t==="y"?"height":"width"}const tV=new Set(["top","bottom"]);function qo(t){return tV.has($s(t))?"y":"x"}function vb(t){return yb(qo(t))}function nV(t,e,n){n===void 0&&(n=!1);const r=ku(t),o=vb(t),s=wb(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(i=bu(i)),[i,bu(i)]}function rV(t){const e=bu(t);return[tp(t),e,tp(e)]}function tp(t){return t.replace(/start|end/g,e=>eV[e])}const kb=["left","right"],bb=["right","left"],oV=["top","bottom"],sV=["bottom","top"];function iV(t,e,n){switch(t){case"top":case"bottom":return n?e?bb:kb:e?kb:bb;case"left":case"right":return e?oV:sV;default:return[]}}function aV(t,e,n,r){const o=ku(t);let s=iV($s(t),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),e&&(s=s.concat(s.map(tp)))),s}function bu(t){return t.replace(/left|right|bottom|top/g,e=>QL[e])}function lV(t){return{top:0,right:0,bottom:0,left:0,...t}}function cV(t){return typeof t!="number"?lV(t):{top:t,right:t,bottom:t,left:t}}function Su(t){const{x:e,y:n,width:r,height:o}=t;return{width:r,height:o,top:n,left:e,right:e+r,bottom:n+o,x:e,y:n}}function Sb(t,e,n){let{reference:r,floating:o}=t;const s=qo(e),i=vb(e),a=wb(i),l=$s(e),c=s==="y",u=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,h=r[a]/2-o[a]/2;let p;switch(l){case"top":p={x:u,y:r.y-o.height};break;case"bottom":p={x:u,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch(ku(e)){case"start":p[i]-=h*(n&&c?-1:1);break;case"end":p[i]+=h*(n&&c?-1:1);break}return p}async function uV(t,e){var n;e===void 0&&(e={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=t,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=vu(e,t),m=cV(p),y=a[h?f==="floating"?"reference":"floating":f],w=Su(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(y)))==null||n?y:y.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),v=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,b=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),S=await(s.isElement==null?void 0:s.isElement(b))?await(s.getScale==null?void 0:s.getScale(b))||{x:1,y:1}:{x:1,y:1},k=Su(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:b,strategy:l}):v);return{top:(w.top-k.top+m.top)/S.y,bottom:(k.bottom-w.bottom+m.bottom)/S.y,left:(w.left-k.left+m.left)/S.x,right:(k.right-w.right+m.right)/S.x}}const dV=async(t,e,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(e));let c=await i.getElementRects({reference:t,floating:e,strategy:o}),{x:u,y:f}=Sb(c,r,l),h=r,p={},m=0;for(let y=0;y<a.length;y++){var g;const{name:w,fn:v}=a[y],{x:b,y:S,data:k,reset:E}=await v({x:u,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:c,platform:{...i,detectOverflow:(g=i.detectOverflow)!=null?g:uV},elements:{reference:t,floating:e}});u=b??u,f=S??f,p={...p,[w]:{...p[w],...k}},E&&m<=50&&(m++,typeof E=="object"&&(E.placement&&(h=E.placement),E.rects&&(c=E.rects===!0?await i.getElementRects({reference:t,floating:e,strategy:o}):E.rects),{x:u,y:f}=Sb(c,h,l)),y=-1)}return{x:u,y:f,placement:h,strategy:o,middlewareData:p}},fV=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:g=!0,...y}=vu(t,e);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const w=$s(o),v=qo(a),b=$s(a)===a,S=await(l.isRTL==null?void 0:l.isRTL(c.floating)),k=h||(b||!g?[bu(a)]:rV(a)),E=m!=="none";!h&&E&&k.push(...aV(a,g,m,S));const _=[a,...k],M=await l.detectOverflow(e,y),I=[];let P=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&I.push(M[w]),f){const F=nV(o,i,S);I.push(M[F[0]],M[F[1]])}if(P=[...P,{placement:o,overflows:I}],!I.every(F=>F<=0)){var V,Z;const F=(((V=s.flip)==null?void 0:V.index)||0)+1,Y=_[F];if(Y&&(!(f==="alignment"?v!==qo(Y):!1)||P.every(j=>qo(j.placement)===v?j.overflows[0]>0:!0)))return{data:{index:F,overflows:P},reset:{placement:Y}};let ce=(Z=P.filter(se=>se.overflows[0]<=0).sort((se,j)=>se.overflows[1]-j.overflows[1])[0])==null?void 0:Z.placement;if(!ce)switch(p){case"bestFit":{var A;const se=(A=P.filter(j=>{if(E){const X=qo(j.placement);return X===v||X==="y"}return!0}).map(j=>[j.placement,j.overflows.filter(X=>X>0).reduce((X,he)=>X+he,0)]).sort((j,X)=>j[1]-X[1])[0])==null?void 0:A[0];se&&(ce=se);break}case"initialPlacement":ce=a;break}if(o!==ce)return{reset:{placement:ce}}}return{}}}},hV=new Set(["left","top"]);async function pV(t,e){const{placement:n,platform:r,elements:o}=t,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=$s(n),a=ku(n),l=qo(n)==="y",c=hV.has(i)?-1:1,u=s&&l?-1:1,f=vu(e,t);let{mainAxis:h,crossAxis:p,alignmentAxis:m}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof m=="number"&&(p=a==="end"?m*-1:m),l?{x:p*u,y:h*c}:{x:h*c,y:p*u}}const mV=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=e,l=await pV(e,t);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},gV=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:o,platform:s}=e,{mainAxis:i=!0,crossAxis:a=!1,limiter:l={fn:w=>{let{x:v,y:b}=w;return{x:v,y:b}}},...c}=vu(t,e),u={x:n,y:r},f=await s.detectOverflow(e,c),h=qo($s(o)),p=yb(h);let m=u[p],g=u[h];if(i){const w=p==="y"?"top":"left",v=p==="y"?"bottom":"right",b=m+f[w],S=m-f[v];m=gb(b,m,S)}if(a){const w=h==="y"?"top":"left",v=h==="y"?"bottom":"right",b=g+f[w],S=g-f[v];g=gb(b,g,S)}const y=l.fn({...e,[p]:m,[h]:g});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[p]:i,[h]:a}}}}}};function Eu(){return typeof window<"u"}function Ls(t){return np(t)?(t.nodeName||"").toLowerCase():"#document"}function xn(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Tr(t){var e;return(e=(np(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function np(t){return Eu()?t instanceof Node||t instanceof xn(t).Node:!1}function or(t){return Eu()?t instanceof Element||t instanceof xn(t).Element:!1}function Mr(t){return Eu()?t instanceof HTMLElement||t instanceof xn(t).HTMLElement:!1}function Eb(t){return!Eu()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof xn(t).ShadowRoot}const yV=new Set(["inline","contents"]);function sl(t){const{overflow:e,overflowX:n,overflowY:r,display:o}=sr(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!yV.has(o)}const wV=new Set(["table","td","th"]);function vV(t){return wV.has(Ls(t))}const kV=[":popover-open",":modal"];function Cu(t){return kV.some(e=>{try{return t.matches(e)}catch{return!1}})}const bV=["transform","translate","scale","rotate","perspective"],SV=["transform","translate","scale","rotate","perspective","filter"],EV=["paint","layout","strict","content"];function rp(t){const e=op(),n=or(t)?sr(t):t;return bV.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||SV.some(r=>(n.willChange||"").includes(r))||EV.some(r=>(n.contain||"").includes(r))}function CV(t){let e=Jo(t);for(;Mr(e)&&!ji(e);){if(rp(e))return e;if(Cu(e))return null;e=Jo(e)}return null}function op(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const _V=new Set(["html","body","#document"]);function ji(t){return _V.has(Ls(t))}function sr(t){return xn(t).getComputedStyle(t)}function _u(t){return or(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Jo(t){if(Ls(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Eb(t)&&t.host||Tr(t);return Eb(e)?e.host:e}function Cb(t){const e=Jo(t);return ji(e)?t.ownerDocument?t.ownerDocument.body:t.body:Mr(e)&&sl(e)?e:Cb(e)}function il(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const o=Cb(t),s=o===((r=t.ownerDocument)==null?void 0:r.body),i=xn(o);if(s){const a=sp(i);return e.concat(i,i.visualViewport||[],sl(o)?o:[],a&&n?il(a):[])}return e.concat(o,il(o,[],n))}function sp(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function _b(t){const e=sr(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const o=Mr(t),s=o?t.offsetWidth:n,i=o?t.offsetHeight:r,a=yu(n)!==s||yu(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function ip(t){return or(t)?t:t.contextElement}function Wi(t){const e=ip(t);if(!Mr(e))return xr(1);const n=e.getBoundingClientRect(),{width:r,height:o,$:s}=_b(e);let i=(s?yu(n.width):n.width)/r,a=(s?yu(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const xV=xr(0);function xb(t){const e=xn(t);return!op()||!e.visualViewport?xV:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function TV(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==xn(t)?!1:e}function Vs(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const o=t.getBoundingClientRect(),s=ip(t);let i=xr(1);e&&(r?or(r)&&(i=Wi(r)):i=Wi(t));const a=TV(s,n,r)?xb(s):xr(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,u=o.width/i.x,f=o.height/i.y;if(s){const h=xn(s),p=r&&or(r)?xn(r):r;let m=h,g=sp(m);for(;g&&r&&p!==m;){const y=Wi(g),w=g.getBoundingClientRect(),v=sr(g),b=w.left+(g.clientLeft+parseFloat(v.paddingLeft))*y.x,S=w.top+(g.clientTop+parseFloat(v.paddingTop))*y.y;l*=y.x,c*=y.y,u*=y.x,f*=y.y,l+=b,c+=S,m=xn(g),g=sp(m)}}return Su({width:u,height:f,x:l,y:c})}function xu(t,e){const n=_u(t).scrollLeft;return e?e.left+n:Vs(Tr(t)).left+n}function Tb(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-xu(t,n),o=n.top+e.scrollTop;return{x:r,y:o}}function MV(t){let{elements:e,rect:n,offsetParent:r,strategy:o}=t;const s=o==="fixed",i=Tr(r),a=e?Cu(e.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=xr(1);const u=xr(0),f=Mr(r);if((f||!f&&!s)&&((Ls(r)!=="body"||sl(i))&&(l=_u(r)),Mr(r))){const p=Vs(r);c=Wi(r),u.x=p.x+r.clientLeft,u.y=p.y+r.clientTop}const h=i&&!f&&!s?Tb(i,l):xr(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+h.x,y:n.y*c.y-l.scrollTop*c.y+u.y+h.y}}function AV(t){return Array.from(t.getClientRects())}function IV(t){const e=Tr(t),n=_u(t),r=t.ownerDocument.body,o=zs(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),s=zs(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+xu(t);const a=-n.scrollTop;return sr(r).direction==="rtl"&&(i+=zs(e.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Mb=25;function NV(t,e){const n=xn(t),r=Tr(t),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const u=op();(!u||u&&e==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=xu(r);if(c<=0){const u=r.ownerDocument,f=u.body,h=getComputedStyle(f),p=u.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,m=Math.abs(r.clientWidth-f.clientWidth-p);m<=Mb&&(s-=m)}else c<=Mb&&(s+=c);return{width:s,height:i,x:a,y:l}}const BV=new Set(["absolute","fixed"]);function PV(t,e){const n=Vs(t,!0,e==="fixed"),r=n.top+t.clientTop,o=n.left+t.clientLeft,s=Mr(t)?Wi(t):xr(1),i=t.clientWidth*s.x,a=t.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function Ab(t,e,n){let r;if(e==="viewport")r=NV(t,n);else if(e==="document")r=IV(Tr(t));else if(or(e))r=PV(e,n);else{const o=xb(t);r={x:e.x-o.x,y:e.y-o.y,width:e.width,height:e.height}}return Su(r)}function Ib(t,e){const n=Jo(t);return n===e||!or(n)||ji(n)?!1:sr(n).position==="fixed"||Ib(n,e)}function OV(t,e){const n=e.get(t);if(n)return n;let r=il(t,[],!1).filter(a=>or(a)&&Ls(a)!=="body"),o=null;const s=sr(t).position==="fixed";let i=s?Jo(t):t;for(;or(i)&&!ji(i);){const a=sr(i),l=rp(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&BV.has(o.position)||sl(i)&&!l&&Ib(t,i))?r=r.filter(u=>u!==i):o=a,i=Jo(i)}return e.set(t,r),r}function DV(t){let{element:e,boundary:n,rootBoundary:r,strategy:o}=t;const i=[...n==="clippingAncestors"?Cu(e)?[]:OV(e,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,u)=>{const f=Ab(e,u,o);return c.top=zs(f.top,c.top),c.right=gu(f.right,c.right),c.bottom=gu(f.bottom,c.bottom),c.left=zs(f.left,c.left),c},Ab(e,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function RV(t){const{width:e,height:n}=_b(t);return{width:e,height:n}}function zV(t,e,n){const r=Mr(e),o=Tr(e),s=n==="fixed",i=Vs(t,!0,s,e);let a={scrollLeft:0,scrollTop:0};const l=xr(0);function c(){l.x=xu(o)}if(r||!r&&!s)if((Ls(e)!=="body"||sl(o))&&(a=_u(e)),r){const p=Vs(e,!0,s,e);l.x=p.x+e.clientLeft,l.y=p.y+e.clientTop}else o&&c();s&&!r&&o&&c();const u=o&&!r&&!s?Tb(o,a):xr(0),f=i.left+a.scrollLeft-l.x-u.x,h=i.top+a.scrollTop-l.y-u.y;return{x:f,y:h,width:i.width,height:i.height}}function ap(t){return sr(t).position==="static"}function Nb(t,e){if(!Mr(t)||sr(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Tr(t)===n&&(n=n.ownerDocument.body),n}function Bb(t,e){const n=xn(t);if(Cu(t))return n;if(!Mr(t)){let o=Jo(t);for(;o&&!ji(o);){if(or(o)&&!ap(o))return o;o=Jo(o)}return n}let r=Nb(t,e);for(;r&&vV(r)&&ap(r);)r=Nb(r,e);return r&&ji(r)&&ap(r)&&!rp(r)?n:r||CV(t)||n}const $V=async function(t){const e=this.getOffsetParent||Bb,n=this.getDimensions,r=await n(t.floating);return{reference:zV(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function LV(t){return sr(t).direction==="rtl"}const VV={convertOffsetParentRelativeRectToViewportRelativeRect:MV,getDocumentElement:Tr,getClippingRect:DV,getOffsetParent:Bb,getElementRects:$V,getClientRects:AV,getDimensions:RV,getScale:Wi,isElement:or,isRTL:LV};function Pb(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function FV(t,e){let n=null,r;const o=Tr(t);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=t.getBoundingClientRect(),{left:u,top:f,width:h,height:p}=c;if(a||e(),!h||!p)return;const m=wu(f),g=wu(o.clientWidth-(u+h)),y=wu(o.clientHeight-(f+p)),w=wu(u),b={rootMargin:-m+"px "+-g+"px "+-y+"px "+-w+"px",threshold:zs(0,gu(1,l))||1};let S=!0;function k(E){const _=E[0].intersectionRatio;if(_!==l){if(!S)return i();_?i(!1,_):r=setTimeout(()=>{i(!1,1e-7)},1e3)}_===1&&!Pb(c,t.getBoundingClientRect())&&i(),S=!1}try{n=new IntersectionObserver(k,{...b,root:o.ownerDocument})}catch{n=new IntersectionObserver(k,b)}n.observe(t)}return i(!0),s}function Ob(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=ip(t),u=o||s?[...c?il(c):[],...il(e)]:[];u.forEach(w=>{o&&w.addEventListener("scroll",n,{passive:!0}),s&&w.addEventListener("resize",n)});const f=c&&a?FV(c,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(w=>{let[v]=w;v&&v.target===c&&p&&(p.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var b;(b=p)==null||b.observe(e)})),n()}),c&&!l&&p.observe(c),p.observe(e));let m,g=l?Vs(t):null;l&&y();function y(){const w=Vs(t);g&&!Pb(g,w)&&n(),g=w,m=requestAnimationFrame(y)}return n(),()=>{var w;u.forEach(v=>{o&&v.removeEventListener("scroll",n),s&&v.removeEventListener("resize",n)}),f==null||f(),(w=p)==null||w.disconnect(),p=null,l&&cancelAnimationFrame(m)}}const Tu=mV,Mu=gV,Au=fV,jV=(t,e,n)=>{const r=new Map,o={platform:VV,...n},s={...o.platform,_c:r};return dV(t,e,{...o,platform:s})};function WV(t){return t!=null&&typeof t=="object"&&"$el"in t}function Db(t){if(WV(t)){const e=t.$el;return np(e)&&Ls(e)==="#comment"?null:e}return t}function al(t){return typeof t=="function"?t():d.unref(t)}function Rb(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function zb(t,e){const n=Rb(t);return Math.round(e*n)/n}function Iu(t,e,n){n===void 0&&(n={});const r=n.whileElementsMounted,o=d.computed(()=>{var _;return(_=al(n.open))!=null?_:!0}),s=d.computed(()=>al(n.middleware)),i=d.computed(()=>{var _;return(_=al(n.placement))!=null?_:"bottom"}),a=d.computed(()=>{var _;return(_=al(n.strategy))!=null?_:"absolute"}),l=d.computed(()=>{var _;return(_=al(n.transform))!=null?_:!0}),c=d.computed(()=>Db(t.value)),u=d.computed(()=>Db(e.value)),f=d.ref(0),h=d.ref(0),p=d.ref(a.value),m=d.ref(i.value),g=d.shallowRef({}),y=d.ref(!1),w=d.computed(()=>{const _={position:p.value,left:"0",top:"0"};if(!u.value)return _;const M=zb(u.value,f.value),I=zb(u.value,h.value);return l.value?{..._,transform:"translate("+M+"px, "+I+"px)",...Rb(u.value)>=1.5&&{willChange:"transform"}}:{position:p.value,left:M+"px",top:I+"px"}});let v;function b(){if(c.value==null||u.value==null)return;const _=o.value;jV(c.value,u.value,{middleware:s.value,placement:i.value,strategy:a.value}).then(M=>{f.value=M.x,h.value=M.y,p.value=M.strategy,m.value=M.placement,g.value=M.middlewareData,y.value=_!==!1})}function S(){typeof v=="function"&&(v(),v=void 0)}function k(){if(S(),r===void 0){b();return}if(c.value!=null&&u.value!=null){v=r(c.value,u.value,b);return}}function E(){o.value||(y.value=!1)}return d.watch([s,i,a,o],b,{flush:"sync"}),d.watch([c,u],k,{flush:"sync"}),d.watch(o,E,{flush:"sync"}),d.getCurrentScope()&&d.onScopeDispose(S),{x:d.shallowReadonly(f),y:d.shallowReadonly(h),strategy:d.shallowReadonly(p),placement:d.shallowReadonly(m),middlewareData:d.shallowReadonly(g),isPositioned:d.shallowReadonly(y),floatingStyles:w,update:b}}const UV=["menu-open"],jn=d.defineComponent({__name:"MenuDropdown",props:{title:{},disabled:{type:Boolean},placement:{default:"top"},offsetPx:{default:8}},emits:["open","close"],setup(t,{emit:e}){const n=t,r=e,o=d.inject("containerRef"),s=d.inject($0,null),i=d.inject(L0,0),a=Math.random().toString(36).slice(2);d.provide(L0,i+1);const{show:l,hide:c}=Yo(),u=d.ref(!1);s&&d.watch(()=>s.value.get(i),b=>{b!==void 0&&b!==a&&u.value&&(u.value=!1)});const f=d.ref(null),h=d.ref(null),{floatingStyles:p}=Iu(f,h,{placement:n.placement,middleware:[Tu(n.offsetPx),Au(),Mu({padding:8})],whileElementsMounted:Ob});function m(){n.disabled||(u.value=!u.value)}function g(){u.value=!1}function y(b){var M,I,P;const S=b.target,k=(M=f.value)==null?void 0:M.contains(S),E=(I=h.value)==null?void 0:I.contains(S),_=(P=S.closest)==null?void 0:P.call(S,".wov-menu-dropdown");!k&&!E&&!_&&g()}function w(){n.title&&f.value&&!u.value&&l(n.title,f.value)}function v(){c()}return d.watch(u,b=>{b?(c(),document.addEventListener("click",y,!0),s&&(s.value.set(i,a),s.value=new Map(s.value)),r("open")):(document.removeEventListener("click",y,!0),(s==null?void 0:s.value.get(i))===a&&(s.value.delete(i),s.value=new Map(s.value)),r("close"))}),d.onUnmounted(()=>{document.removeEventListener("click",y,!0)}),(b,S)=>(d.openBlock(),d.createElementBlock(d.Fragment,null,[d.createElementVNode("div",{ref_key:"buttonRef",ref:f,class:d.normalizeClass(["wov-menu-dropdown-trigger",{"is-open":u.value}]),"menu-open":u.value||void 0,onMousedown:S[0]||(S[0]=d.withModifiers(()=>{},["prevent"])),onClick:m,onMouseenter:w,onMouseleave:v},[d.renderSlot(b.$slots,"button",{isOpen:u.value})],42,UV),d.unref(o)?(d.openBlock(),d.createBlock(d.Teleport,{key:0,to:d.unref(o)},[u.value?(d.openBlock(),d.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:h,class:"wov-menu-dropdown",style:d.normalizeStyle(d.unref(p))},[d.renderSlot(b.$slots,"dropdown",{close:g})],4)):d.createCommentVNode("",!0)],8,["to"])):d.createCommentVNode("",!0)],64))}}),HV={},ZV={viewBox:"0 0 512 320",fill:"currentColor",style:{width:"7px",color:"var(--wov-gray-300)"}};function KV(t,e){return d.openBlock(),d.createElementBlock("svg",ZV,[...e[0]||(e[0]=[d.createElementVNode("path",{d:"M233.4 278.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 210.7 86.6 41.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"},null,-1)])])}const Wn=ys(HV,[["render",KV]]),YV={class:"wov-menu-button"},qV=["innerHTML"],JV=["onClick"],GV=["innerHTML"],lp=d.defineComponent({__name:"ArrowHeadButton",props:{entityIds:{},side:{}},setup(t){const e=t,{nextEditorTick:n}=ut(),r=d.shallowRef(null),o=d.computed(()=>{const a=r.value??(e.side==="start"?De.None:De.V);return xi(a)});n(a=>{let l=null;for(const c of e.entityIds){if(R(a,c,Pe)){const u=Pe.read(a,c),f=e.side==="start"?u.startArrowHead:u.endArrowHead;if(l===null)l=f;else if(f!==l){r.value=e.side==="start"?De.None:De.V;return}}if(R(a,c,xe)){const u=xe.read(a,c),f=e.side==="start"?u.startArrowHead:u.endArrowHead;if(l===null)l=f;else if(f!==l){r.value=e.side==="start"?De.None:De.V;return}}}r.value=l});function s(a){r.value=a,n(l=>{for(const c of e.entityIds){if(R(l,c,Pe)){const u=Pe.write(l,c);e.side==="start"?u.startArrowHead=a:u.endArrowHead=a}if(R(l,c,xe)){const u=xe.write(l,c);e.side==="start"?u.startArrowHead=a:u.endArrowHead=a}}})}function i(a){if(!a)return"";const l=e.side==="start";return`<line x1="${l?8:4}" y1="12" x2="${l?20:16}" y2="12" stroke="currentColor" stroke-width="2" stroke-linecap="round" /><g transform="${`translate(${l?4:20}, 12) scale(${l?"-0.8, 0.8":"0.8"})`}">${a.svg}</g>`}return(a,l)=>(d.openBlock(),d.createBlock(jn,{title:t.side==="start"?"Start Arrow Head":"End Arrow Head"},{button:d.withCtx(()=>[d.createElementVNode("div",YV,[(d.openBlock(),d.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",innerHTML:i(o.value)},null,8,qV)),d.createVNode(Wn,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(d.unref(Cf),c=>(d.openBlock(),d.createElementBlock("button",{key:c.kind,class:d.normalizeClass(["wov-menu-option",{"is-active":r.value===c.kind}]),onClick:u=>s(c.kind)},[(d.openBlock(),d.createElementBlock("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",innerHTML:i(c)},null,8,GV))],10,JV))),128))]),_:1},8,["title"]))}}),XV={class:"wov-menu-button"},QV=["onClick"],$b=d.defineComponent({__name:"ArrowThicknessButton",props:{entityIds:{}},setup(t){const e=[{label:"S",value:2},{label:"M",value:4},{label:"L",value:8}],n=t,{nextEditorTick:r}=ut(),o=d.shallowRef(null);r(i=>{let a=null;for(const l of n.entityIds){if(R(i,l,Pe)){const c=Pe.read(i,l);if(a===null)a=c.thickness;else if(c.thickness!==a){o.value=null;return}}if(R(i,l,xe)){const c=xe.getThickness(i,l);if(a===null)a=c;else if(c!==a){o.value=null;return}}}o.value=a});function s(i){o.value=i,r(a=>{for(const l of n.entityIds){if(R(a,l,Pe)){const c=Pe.write(a,l);c.thickness=i}R(a,l,xe)&&xe.setThickness(a,l,i)}})}return(i,a)=>(d.openBlock(),d.createBlock(jn,{title:"Thickness"},{button:d.withCtx(()=>[d.createElementVNode("div",XV,[a[0]||(a[0]=d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-linecap":"round"},[d.createElementVNode("line",{x1:"4",y1:"5",x2:"20",y2:"5","stroke-width":"1"}),d.createElementVNode("line",{x1:"4",y1:"11",x2:"20",y2:"11","stroke-width":"2.5"}),d.createElementVNode("line",{x1:"4",y1:"19",x2:"20",y2:"19","stroke-width":"4"})],-1)),d.createVNode(Wn,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[(d.openBlock(),d.createElementBlock(d.Fragment,null,d.renderList(e,l=>d.createElementVNode("button",{key:l.value,class:d.normalizeClass(["wov-menu-option wov-arrow-thickness-option",{"is-active":o.value===l.value}]),onClick:c=>s(l.value)},d.toDisplayString(l.label),11,QV)),64))]),_:1}))}}),eF=["value"],tF=d.defineComponent({__name:"ColorInput",props:{modelValue:{}},emits:["update:modelValue"],setup(t,{emit:e}){const n=t,r=e,o=d.ref(n.modelValue??"");d.watch(()=>n.modelValue,u=>{u&&u!==o.value&&(o.value=u)});function s(u){const f=u.startsWith("#")?u:`#${u}`;return/^#[0-9A-Fa-f]{6}$/.test(f)}function i(u){return(u.startsWith("#")?u:`#${u}`).toLowerCase()}function a(u){let h=u.target.value;if((h.length===6||h.length===7)&&s(h)){const p=i(h);o.value=p,r("update:modelValue",p)}}function l(u){const h=u.target.value;if(h&&s(h)){const p=i(h);o.value=p,r("update:modelValue",p)}else n.modelValue&&(o.value=n.modelValue)}function c(u){if(u.stopPropagation(),u.key==="Enter"){const f=u.target,h=f.value;if(h&&s(h)){const p=i(h);o.value=p,r("update:modelValue",p),setTimeout(()=>f.select())}}}return(u,f)=>(d.openBlock(),d.createElementBlock("input",{id:"wov-color-input",class:"wov-color-input",type:"text",size:"1","aria-label":"Hex color value",autocomplete:"off",autocorrect:"off",autocapitalize:"off",spellcheck:"false",value:o.value,onInput:a,onChange:l,onKeydown:c},null,40,eF))}}),Lb=d.defineComponent({__name:"ColorSlider",props:{modelValue:{},thumbColor:{},background:{}},emits:["update:modelValue"],setup(t,{expose:e,emit:n}){const r=n,o=d.ref(null),s=d.ref(!1);function i(c){s.value=!0,a(c),window.addEventListener("pointermove",a),window.addEventListener("pointerup",l)}function a(c){if(!o.value)return;const u=o.value.getBoundingClientRect(),f=Math.max(0,Math.min(100,(c.clientY-u.top)/u.height*100));r("update:modelValue",f)}function l(){s.value=!1,window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",l)}return e({isDragging:s}),(c,u)=>(d.openBlock(),d.createElementBlock("div",{ref_key:"sliderRef",ref:o,class:"wov-color-slider",onPointerdown:d.withModifiers(i,["prevent"])},[t.background?(d.openBlock(),d.createElementBlock("div",{key:0,class:"wov-color-slider-gradient",style:d.normalizeStyle({background:t.background})},null,4)):d.createCommentVNode("",!0),d.createElementVNode("div",{class:"wov-color-slider-thumb",style:d.normalizeStyle({top:`${t.modelValue}%`,backgroundColor:t.thumbColor})},null,4)],544))}}),nF={class:"wov-color-picker"},rF={class:"wov-color-picker-area"},oF={class:"wov-color-picker-selector-gradient"},sF="linear-gradient(to bottom, red 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, red 100%)",Vb=d.defineComponent({__name:"ColorPicker",props:{modelValue:{},withOpacity:{type:Boolean}},emits:["update:modelValue"],setup(t,{emit:e}){const n=t,r=e,o=d.ref(null),s=d.ref(null),i=d.ref(null),a=d.ref({x:100,y:0}),l=d.ref(0),c=d.ref(0),u=d.ref(!1),f=d.computed(()=>{var E,_;return u.value||((E=o.value)==null?void 0:E.isDragging)||((_=s.value)==null?void 0:_.isDragging)}),h=d.computed(()=>({h:l.value/100*360,s:a.value.x,v:100-a.value.y,a:(100-c.value)/100*255})),p=d.computed(()=>lb({h:h.value.h,s:100,v:100})),m=d.computed(()=>lb({h:h.value.h,s:h.value.s,v:h.value.v})),g=d.computed(()=>n.withOpacity?cb(h.value):m.value),y=d.computed(()=>`linear-gradient(to top, transparent 0%, ${m.value} 100%)`);function w(E){if(E){const _=ab(E);a.value={x:_.s,y:100-_.v},l.value=_.h/360*100,c.value=100-_.a/255*100}}function v(E){w(E),r("update:modelValue",n.withOpacity?cb(ab(E)):E)}w(n.modelValue),d.watch(()=>n.modelValue,E=>{f.value||w(E)}),d.watch([a,l,c],()=>{f.value&&r("update:modelValue",g.value)});function b(E){u.value=!0,S(E),window.addEventListener("pointermove",S),window.addEventListener("pointerup",k)}function S(E){if(!i.value)return;const _=i.value.getBoundingClientRect(),M=Math.max(0,Math.min(100,(E.clientX-_.left)/_.width*100)),I=Math.max(0,Math.min(100,(E.clientY-_.top)/_.height*100));a.value={x:M,y:I}}function k(){u.value=!1,window.removeEventListener("pointermove",S),window.removeEventListener("pointerup",k)}return(E,_)=>(d.openBlock(),d.createElementBlock("div",nF,[d.createVNode(tF,{modelValue:g.value,"onUpdate:modelValue":v},null,8,["modelValue"]),d.createElementVNode("div",rF,[d.createElementVNode("div",{ref_key:"selectorRef",ref:i,class:"wov-color-picker-selector",style:d.normalizeStyle({backgroundColor:p.value}),onPointerdown:d.withModifiers(b,["prevent"])},[d.createElementVNode("div",oF,[d.createElementVNode("div",{class:"wov-color-picker-selector-thumb",style:d.normalizeStyle({left:`${a.value.x}%`,top:`${a.value.y}%`,backgroundColor:m.value})},null,4)])],36),d.createVNode(Lb,{ref_key:"hueSliderRef",ref:o,modelValue:l.value,"onUpdate:modelValue":_[0]||(_[0]=M=>l.value=M),thumbColor:p.value,background:sF},null,8,["modelValue","thumbColor"]),t.withOpacity?(d.openBlock(),d.createBlock(Lb,{key:0,ref_key:"opacitySliderRef",ref:s,modelValue:c.value,"onUpdate:modelValue":_[1]||(_[1]=M=>c.value=M),thumbColor:m.value,background:y.value,class:"wov-color-picker-opacity"},null,8,["modelValue","thumbColor","background"])):d.createCommentVNode("",!0)])]))}}),iF={class:"wov-color-bubbles-container"},aF={key:1,class:"wov-color-bubbles"},lF=["onClick"],Nu=d.defineComponent({__name:"ColorBubbles",props:{currentColor:{},palette:{},hideHighlight:{type:Boolean},withPicker:{type:Boolean},withOpacity:{type:Boolean}},emits:["change","picker-open"],setup(t,{emit:e}){const n=t,r=e,o=["#000000","#374151","#6B7280","#9CA3AF","#D1D5DB","#FFFFFF","#EF4444","#F97316","#EAB308","#22C55E","#14B8A6","#3B82F6","#8B5CF6","#EC4899"],s=d.computed(()=>{const m=n.palette??o,g=n.withPicker,y=m.length%2===1;return g&&!y||!g&&y?m.slice(0,-1):m}),i=d.ref(!1),a=d.ref(n.currentColor??"#ff0000");function l(m,g){const y=w=>{const v=w.replace(/^#/,"").toLowerCase();return v.length===6?v+"ff":v};return y(m)===y(g)}function c(m){return n.hideHighlight||!n.currentColor?!1:l(n.currentColor,m)}function u(){return n.hideHighlight||!n.currentColor?!1:!s.value.some(m=>l(n.currentColor,m))}function f(m){const g=Kh(m);g&&r("change",g)}function h(){!i.value&&n.currentColor&&(a.value=n.currentColor),i.value=!i.value,r("picker-open",i.value)}function p(m){a.value=m;const g=Kh(m);g&&r("change",g)}return(m,g)=>(d.openBlock(),d.createElementBlock("div",iF,[i.value?(d.openBlock(),d.createBlock(Vb,{key:0,modelValue:a.value,"onUpdate:modelValue":[g[0]||(g[0]=y=>a.value=y),p],withOpacity:t.withOpacity},null,8,["modelValue","withOpacity"])):(d.openBlock(),d.createElementBlock("div",aF,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(s.value,y=>(d.openBlock(),d.createElementBlock("div",{key:y,class:d.normalizeClass(["wov-color-bubble",{selected:c(y)}]),style:d.normalizeStyle({backgroundColor:y}),onMousedown:g[1]||(g[1]=d.withModifiers(()=>{},["prevent"])),onClick:w=>f(y)},null,46,lF))),128)),t.withPicker?(d.openBlock(),d.createElementBlock("div",{key:0,class:d.normalizeClass(["wov-color-bubble wov-rainbow-bubble",{selected:u()}]),onMousedown:g[2]||(g[2]=d.withModifiers(()=>{},["prevent"])),onClick:h},null,34)):d.createCommentVNode("",!0)]))]))}}),cF={class:"wov-color-button"},Fb=d.defineComponent({__name:"ColorButton",props:{entityIds:{}},setup(t){const e=t,{nextEditorTick:n}=ut(),r=Zo(()=>e.entityIds,In),o=d.computed(()=>{const c=new Set;for(const u of r.value.values())if(u){const f=rl(u);c.add(f)}return Array.from(c)}),s=d.computed(()=>o.value.length>1),i=d.computed(()=>o.value[0]??null),a=d.computed(()=>{if(o.value.length===0)return{backgroundColor:"#000"};if(o.value.length>=2){const c=o.value[0],u=o.value[1];return{background:`linear-gradient(45deg, ${c} 0%, ${c} 50%, ${u} 50%, ${u} 100%)`}}return{backgroundColor:o.value[0]}});function l(c){const u=rl(c);n(f=>{for(const h of e.entityIds)In.fromHex(f,h,u)})}return(c,u)=>(d.openBlock(),d.createBlock(jn,{title:"Color"},{button:d.withCtx(()=>[d.createElementVNode("div",cF,[d.createElementVNode("div",{class:"wov-color-swatch",style:d.normalizeStyle(a.value)},null,4),d.createVNode(Wn,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[d.createVNode(Nu,{currentColor:i.value??void 0,hideHighlight:s.value,withPicker:!0,onChange:l},null,8,["currentColor","hideHighlight"])]),_:1}))}}),Ui=d.defineComponent({__name:"MenuButton",props:{title:{}},emits:["click"],setup(t,{emit:e}){const n=t,r=e,o=d.ref(null),{show:s,hide:i}=Yo();function a(u){r("click",u)}function l(){n.title&&o.value&&s(n.title,o.value)}function c(){i()}return(u,f)=>(d.openBlock(),d.createElementBlock("button",{ref_key:"buttonRef",ref:o,class:"wov-menu-button",onClick:a,onMouseenter:l,onMouseleave:c},[d.renderSlot(u.$slots,"default")],544))}}),cp=d.defineComponent({__name:"MenuTooltip",setup(t){const{activeTooltip:e,isVisible:n}=Yo(),r=d.inject("containerRef"),o=d.ref(null),s=d.computed(()=>{var l;return((l=e.value)==null?void 0:l.anchor)??null}),{floatingStyles:i}=Iu(s,o,{placement:"top",middleware:[Tu(8),Au({fallbackPlacements:["bottom"]}),Mu({padding:8})]}),a=d.computed(()=>{var l;return n.value&&((l=e.value)==null?void 0:l.text)});return(l,c)=>d.unref(r)?(d.openBlock(),d.createBlock(d.Teleport,{key:0,to:d.unref(r)},[d.createVNode(d.Transition,{name:"wov-tooltip-fade"},{default:d.withCtx(()=>{var u;return[a.value?(d.openBlock(),d.createElementBlock("div",{key:0,ref_key:"tooltipRef",ref:o,class:"wov-menu-tooltip",style:d.normalizeStyle(d.unref(i))},d.toDisplayString((u=d.unref(e))==null?void 0:u.text),5)):d.createCommentVNode("",!0)]}),_:1})],8,["to"])):d.createCommentVNode("",!0)}}),uF={class:"wov-menu-button"},dF=["onClick"],jb=d.defineComponent({__name:"PenStrokeThicknessButton",props:{entityIds:{}},setup(t){const e=[{label:"S",value:4},{label:"M",value:8},{label:"L",value:16}],n=t,{nextEditorTick:r}=ut(),o=Zo(()=>n.entityIds,tr),s=d.computed(()=>{let a=null;for(const l of o.value.values())if(l){if(a===null)a=l.thickness;else if(l.thickness!==a)return null}return a});function i(a){r(l=>{for(const c of n.entityIds){const u=tr.write(l,c);u.thickness=a}})}return(a,l)=>(d.openBlock(),d.createBlock(jn,{title:"Thickness"},{button:d.withCtx(()=>[d.createElementVNode("div",uF,[l[0]||(l[0]=d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-linecap":"round"},[d.createElementVNode("line",{x1:"4",y1:"5",x2:"20",y2:"5","stroke-width":"1"}),d.createElementVNode("line",{x1:"4",y1:"11",x2:"20",y2:"11","stroke-width":"2.5"}),d.createElementVNode("line",{x1:"4",y1:"19",x2:"20",y2:"19","stroke-width":"4"})],-1)),d.createVNode(Wn,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[(d.openBlock(),d.createElementBlock(d.Fragment,null,d.renderList(e,c=>d.createElementVNode("button",{key:c.value,class:d.normalizeClass(["wov-menu-option wov-pen-thickness-option",{"is-active":s.value===c.value}]),onClick:u=>i(c.value)},d.toDisplayString(c.label),11,dF)),64))]),_:1}))}}),fF={class:"wov-fill-color-button"},hF={class:"wov-fill-dropdown"},pF={key:0,class:"wov-fill-mode-section"},mF=["title","onClick"],gF={viewBox:"0 0 24 24",fill:"none"},yF=["fill","fill-opacity","stroke","stroke-width","stroke-dasharray"],Wb=d.defineComponent({__name:"ShapeFillColorButton",props:{entityIds:{}},setup(t){const e=t,{nextEditorTick:n}=ut(),r=Zo(()=>e.entityIds,Nn),o=[{mode:"solid",label:"Solid",alpha:255},{mode:"faded",label:"Faded",alpha:128},{mode:"none",label:"None",alpha:0}],s=d.computed(()=>{const p=r.value.values().next().value,m=(p==null?void 0:p.fillAlpha)??255;return m===0?"none":m<200?"faded":"solid"}),i=d.computed(()=>{const p=new Set;for(const m of r.value.values())if(m){const g=m.fillAlpha??255;g===0?p.add("none"):g<200?p.add("faded"):p.add("solid")}return p.size>1});function a(p){n(m=>{for(const g of e.entityIds){const y=Nn.write(m,g);y.fillAlpha=p}})}const l=d.computed(()=>{const p=new Set;for(const m of r.value.values())if(m){const g=rl({red:m.fillRed,green:m.fillGreen,blue:m.fillBlue,alpha:m.fillAlpha??255});p.add(g)}return Array.from(p)}),c=d.computed(()=>l.value.length>1),u=d.computed(()=>l.value[0]??"#4a90d9");function f(p){n(m=>{for(const g of e.entityIds){const y=Nn.write(m,g);y.fillRed=p.red,y.fillGreen=p.green,y.fillBlue=p.blue,y.fillAlpha=p.alpha}})}const h=d.ref(!1);return(p,m)=>(d.openBlock(),d.createBlock(jn,{title:"Fill Color"},{button:d.withCtx(()=>[d.createElementVNode("div",fF,[m[1]||(m[1]=d.createElementVNode("svg",{viewBox:"0 0 20 20",class:"wov-fill-color-icon",stroke:"currentColor",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"},[d.createElementVNode("path",{d:"M5.879,2.625L14.121,2.625C15.906,2.625 17.375,4.094 17.375,5.879L17.375,14.121C17.375,15.906 15.906,17.375 14.121,17.375L5.88,17.375C4.095,17.375 2.626,15.906 2.626,14.121L2.626,5.88C2.626,4.095 4.095,2.626 5.88,2.626L5.879,2.625Z","stroke-width":"1.25"}),d.createElementVNode("path",{d:"M2.779,14.655L14.543,2.871M10.238,17.308L17.318,10.229M2.876,9.577L9.853,2.6M5.397,17.239L17.16,5.476","stroke-width":"1.25"})],-1)),d.createVNode(Wn,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[d.createElementVNode("div",hF,[h.value?d.createCommentVNode("",!0):(d.openBlock(),d.createElementBlock("div",pF,[(d.openBlock(),d.createElementBlock(d.Fragment,null,d.renderList(o,g=>d.createElementVNode("button",{key:g.mode,class:d.normalizeClass(["wov-fill-mode-option",{"is-active":!i.value&&g.mode===s.value}]),title:g.label,onClick:y=>a(g.alpha)},[(d.openBlock(),d.createElementBlock("svg",gF,[d.createElementVNode("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",fill:g.mode==="none"?"none":"currentColor","fill-opacity":g.mode==="faded"?.4:1,stroke:g.mode==="none"?"currentColor":"none","stroke-width":g.mode==="none"?1.5:0,"stroke-dasharray":g.mode==="none"?"3 3":""},null,8,yF)])),d.createElementVNode("span",null,d.toDisplayString(g.label),1)],10,mF)),64))])),d.createVNode(Nu,{currentColor:u.value,hideHighlight:c.value,withPicker:!0,withOpacity:!0,onChange:f,onPickerOpen:m[0]||(m[0]=g=>h.value=g)},null,8,["currentColor","hideHighlight"])])]),_:1}))}}),wF={class:"wov-shape-kind-button"},vF={class:"wov-shape-kind-dropdown"},kF=["onClick"],bF={viewBox:"0 0 20 20",class:"wov-shape-option-icon",fill:"none",stroke:"currentColor","stroke-width":"4"},SF=["d"],Ub=d.defineComponent({__name:"ShapeKindButton",props:{entityIds:{}},setup(t){const e=t,{nextEditorTick:n}=ut(),r=Zo(()=>e.entityIds,Nn),o=d.computed(()=>{const l=r.value.values().next().value;return(l==null?void 0:l.kind)??"rectangle"}),s=d.computed(()=>{const l=new Set;for(const c of r.value.values())c&&l.add(c.kind);return l.size>1}),i=d.computed(()=>Object.keys(Ba).map(l=>({kind:l,label:l.charAt(0).toUpperCase()+l.slice(1)})));function a(l){n(c=>{for(const u of e.entityIds){const f=Nn.write(c,u);f.kind=l}})}return(l,c)=>(d.openBlock(),d.createBlock(jn,{title:"Shape Type"},{button:d.withCtx(()=>[d.createElementVNode("div",wF,[c[0]||(c[0]=d.createElementVNode("svg",{viewBox:"0 0 20 20",class:"wov-shape-kind-icon",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[d.createElementVNode("circle",{cx:"6",cy:"6",r:"5"}),d.createElementVNode("rect",{x:"6",y:"6",width:"10",height:"10",fill:"var(--wov-gray-600)"})],-1)),d.createVNode(Wn,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[d.createElementVNode("div",vF,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(i.value,u=>(d.openBlock(),d.createElementBlock("button",{key:u.kind,class:d.normalizeClass(["wov-shape-kind-option",{"is-selected":!s.value&&u.kind===o.value}]),onClick:f=>a(u.kind)},[(d.openBlock(),d.createElementBlock("svg",bF,[d.createElementVNode("path",{d:d.unref(Ba)[u.kind],transform:"translate(2, 2) scale(0.16)"},null,8,SF)])),d.createElementVNode("span",null,d.toDisplayString(u.label),1)],10,kF))),128))])]),_:1}))}}),EF={class:"wov-stroke-style-section"},CF=["title","onClick"],_F={viewBox:"0 0 24 8",fill:"none",stroke:"currentColor","stroke-width":"2"},xF=["stroke-dasharray","stroke-opacity"],TF=d.defineComponent({__name:"StrokeStyleOptions",props:{currentStyle:{},hasMultipleStyles:{type:Boolean}},emits:["change"],setup(t,{emit:e}){const n=e,r=[{kind:Ct.Solid,label:"Solid"},{kind:Ct.Dashed,label:"Dashed"},{kind:Ct.None,label:"None"}];function o(i){switch(i){case Ct.Dashed:return"6 6";case Ct.None:return"";case Ct.Solid:default:return""}}function s(i){n("change",i)}return(i,a)=>(d.openBlock(),d.createElementBlock("div",EF,[(d.openBlock(),d.createElementBlock(d.Fragment,null,d.renderList(r,l=>d.createElementVNode("button",{key:l.kind,class:d.normalizeClass(["wov-stroke-style-option",{"is-active":!t.hasMultipleStyles&&l.kind===t.currentStyle}]),title:l.label,onClick:c=>s(l.kind)},[(d.openBlock(),d.createElementBlock("svg",_F,[d.createElementVNode("line",{x1:"2",y1:"4",x2:"22",y2:"4","stroke-linecap":"round","stroke-dasharray":o(l.kind),"stroke-opacity":l.kind===d.unref(Ct).None?.3:1},null,8,xF)])),d.createElementVNode("span",null,d.toDisplayString(l.label),1)],10,CF)),64))]))}}),MF={class:"wov-stroke-color-button"},AF={class:"wov-stroke-dropdown"},IF={key:1,class:"wov-stroke-divider"},Hb=d.defineComponent({__name:"ShapeStrokeColorButton",props:{entityIds:{}},setup(t){const e=t,{nextEditorTick:n}=ut(),r=Zo(()=>e.entityIds,Nn),o=d.ref(!1),s=d.computed(()=>{const h=new Set;for(const p of r.value.values())if(p){const m=rl({red:p.strokeRed,green:p.strokeGreen,blue:p.strokeBlue,alpha:255});h.add(m)}return Array.from(h)}),i=d.computed(()=>s.value.length>1),a=d.computed(()=>s.value[0]??"#000000"),l=d.computed(()=>{const h=r.value.values().next().value;return(h==null?void 0:h.strokeKind)??Ct.Solid}),c=d.computed(()=>{const h=new Set;for(const p of r.value.values())p&&h.add(p.strokeKind);return h.size>1});function u(h){n(p=>{for(const m of e.entityIds){const g=Nn.write(p,m);g.strokeRed=h.red,g.strokeGreen=h.green,g.strokeBlue=h.blue}})}function f(h){n(p=>{for(const m of e.entityIds){const g=Nn.write(p,m);g.strokeKind=h}})}return(h,p)=>(d.openBlock(),d.createBlock(jn,{title:"Stroke Color"},{button:d.withCtx(()=>[d.createElementVNode("div",MF,[p[1]||(p[1]=d.createElementVNode("svg",{viewBox:"0 0 20 20",class:"wov-stroke-color-icon",fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round"},[d.createElementVNode("path",{d:"M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43","stroke-width":"1.25"})],-1)),d.createVNode(Wn,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[d.createElementVNode("div",AF,[o.value?d.createCommentVNode("",!0):(d.openBlock(),d.createBlock(TF,{key:0,currentStyle:l.value,hasMultipleStyles:c.value,onChange:f},null,8,["currentStyle","hasMultipleStyles"])),o.value?d.createCommentVNode("",!0):(d.openBlock(),d.createElementBlock("div",IF)),d.createVNode(Nu,{currentColor:a.value,hideHighlight:i.value,withPicker:!0,onChange:u,onPickerOpen:p[0]||(p[0]=m=>o.value=m)},null,8,["currentColor","hideHighlight"])])]),_:1}))}}),NF={key:0,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},BF={key:1,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},PF={key:2,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},OF={key:3,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},up=d.defineComponent({__name:"TextAlignmentButton",props:{entityIds:{}},setup(t){const e=t,{state:n,commands:r}=_r(()=>e.entityIds),o=[Bn.Left,Bn.Center,Bn.Right,Bn.Justify];function s(){const i=o.indexOf(n.alignment),a=o[(i+1)%o.length];r.setAlignment(a)}return(i,a)=>d.unref(n).showTextMenuButtons?(d.openBlock(),d.createBlock(Ui,{key:0,title:"Text Align",onClick:s},{default:d.withCtx(()=>[d.unref(n).alignment===d.unref(Bn).Left?(d.openBlock(),d.createElementBlock("svg",NF,[...a[0]||(a[0]=[d.createElementVNode("path",{d:"M288 64c0 17.7-14.3 32-32 32L32 96C14.3 96 0 81.7 0 64S14.3 32 32 32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32L32 352c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zM0 192c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 224c-17.7 0-32-14.3-32-32zM448 448c0 17.7-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"},null,-1)])])):d.unref(n).alignment===d.unref(Bn).Center?(d.openBlock(),d.createElementBlock("svg",BF,[...a[1]||(a[1]=[d.createElementVNode("path",{d:"M352 64c0-17.7-14.3-32-32-32L128 32c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32zm96 128c0-17.7-14.3-32-32-32L32 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32zM0 448c0 17.7 14.3 32 32 32l384 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 416c-17.7 0-32 14.3-32 32zM352 320c0-17.7-14.3-32-32-32l-192 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l192 0c17.7 0 32-14.3 32-32z"},null,-1)])])):d.unref(n).alignment===d.unref(Bn).Right?(d.openBlock(),d.createElementBlock("svg",PF,[...a[2]||(a[2]=[d.createElementVNode("path",{d:"M448 64c0 17.7-14.3 32-32 32L192 96c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zm0 256c0 17.7-14.3 32-32 32l-224 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l224 0c17.7 0 32 14.3 32 32zM0 192c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 224c-17.7 0-32-14.3-32-32zM448 448c0 17.7-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"},null,-1)])])):(d.openBlock(),d.createElementBlock("svg",OF,[...a[3]||(a[3]=[d.createElementVNode("path",{d:"M448 64c0-17.7-14.3-32-32-32L32 32C14.3 32 0 46.3 0 64S14.3 96 32 96l384 0c17.7 0 32-14.3 32-32zm0 256c0-17.7-14.3-32-32-32L32 288c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32zM0 192c0 17.7 14.3 32 32 32l384 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 160c-17.7 0-32 14.3-32 32zM448 448c0-17.7-14.3-32-32-32L32 416c-17.7 0-32 14.3-32 32s14.3 32 32 32l384 0c17.7 0 32-14.3 32-32z"},null,-1)])]))]),_:1})):d.createCommentVNode("",!0)}}),dp=d.defineComponent({__name:"TextBoldButton",props:{entityIds:{}},setup(t){const e=t,{state:n,commands:r}=_r(()=>e.entityIds);return(o,s)=>d.unref(n).showTextMenuButtons?(d.openBlock(),d.createBlock(Ui,{key:0,title:"Bold",class:d.normalizeClass({"wov-active":d.unref(n).isBold}),onClick:d.unref(r).toggleBold},{default:d.withCtx(()=>[...s[0]||(s[0]=[d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512",fill:"currentColor"},[d.createElementVNode("path",{d:"M0 64C0 46.3 14.3 32 32 32l48 0 16 0 128 0c70.7 0 128 57.3 128 128c0 31.3-11.3 60.1-30 82.3c37.1 22.4 62 63.1 62 109.7c0 70.7-57.3 128-128 128L96 480l-16 0-48 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l16 0 0-160L48 96 32 96C14.3 96 0 81.7 0 64zM224 224c35.3 0 64-28.7 64-64s-28.7-64-64-64L112 96l0 128 112 0zM112 288l0 128 144 0c35.3 0 64-28.7 64-64s-28.7-64-64-64l-32 0-112 0z"})],-1)])]),_:1},8,["class","onClick"])):d.createCommentVNode("",!0)}});function DF(t,e){return d.getCurrentScope()?(d.onScopeDispose(t,e),!0):!1}const RF=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const zF=Object.prototype.toString,$F=t=>zF.call(t)==="[object Object]",Bu=()=>{};function Pu(t){return Array.isArray(t)?t:[t]}function LF(t){return d.getCurrentInstance()}function VF(t,e=!0,n){LF()?d.onMounted(t,n):e?t():d.nextTick(t)}function FF(t,e,n){return d.watch(t,e,{...n,immediate:!0})}const Ou=RF?window:void 0;function ir(t){var e;const n=d.toValue(t);return(e=n==null?void 0:n.$el)!==null&&e!==void 0?e:n}function fp(...t){const e=(r,o,s,i)=>(r.addEventListener(o,s,i),()=>r.removeEventListener(o,s,i)),n=d.computed(()=>{const r=Pu(d.toValue(t[0])).filter(o=>o!=null);return r.every(o=>typeof o!="string")?r:void 0});return FF(()=>{var r,o;return[(r=(o=n.value)===null||o===void 0?void 0:o.map(s=>ir(s)))!==null&&r!==void 0?r:[Ou].filter(s=>s!=null),Pu(d.toValue(n.value?t[1]:t[0])),Pu(d.unref(n.value?t[2]:t[1])),d.toValue(n.value?t[3]:t[2])]},([r,o,s,i],a,l)=>{if(!(r!=null&&r.length)||!(o!=null&&o.length)||!(s!=null&&s.length))return;const c=$F(i)?{...i}:i,u=r.flatMap(f=>o.flatMap(h=>s.map(p=>e(f,h,p,c))));l(()=>{u.forEach(f=>f())})},{flush:"post"})}function jF(t,e,n={}){const{window:r=Ou,ignore:o=[],capture:s=!0,detectIframe:i=!1,controls:a=!1}=n;if(!r)return a?{stop:Bu,cancel:Bu,trigger:Bu}:Bu;let l=!0;const c=y=>d.toValue(o).some(w=>{if(typeof w=="string")return Array.from(r.document.querySelectorAll(w)).some(v=>v===y.target||y.composedPath().includes(v));{const v=ir(w);return v&&(y.target===v||y.composedPath().includes(v))}});function u(y){const w=d.toValue(y);return w&&w.$.subTree.shapeFlag===16}function f(y,w){const v=d.toValue(y),b=v.$.subTree&&v.$.subTree.children;return b==null||!Array.isArray(b)?!1:b.some(S=>S.el===w.target||w.composedPath().includes(S.el))}const h=y=>{const w=ir(t);if(y.target!=null&&!(!(w instanceof Element)&&u(t)&&f(t,y))&&!(!w||w===y.target||y.composedPath().includes(w))){if("detail"in y&&y.detail===0&&(l=!c(y)),!l){l=!0;return}e(y)}};let p=!1;const m=[fp(r,"click",y=>{p||(p=!0,setTimeout(()=>{p=!1},0),h(y))},{passive:!0,capture:s}),fp(r,"pointerdown",y=>{const w=ir(t);l=!c(y)&&!!(w&&!y.composedPath().includes(w))},{passive:!0}),i&&fp(r,"blur",y=>{setTimeout(()=>{var w;const v=ir(t);((w=r.document.activeElement)===null||w===void 0?void 0:w.tagName)==="IFRAME"&&!(v!=null&&v.contains(r.document.activeElement))&&e(y)},0)},{passive:!0})].filter(Boolean),g=()=>m.forEach(y=>y());return a?{stop:g,cancel:()=>{l=!1},trigger:y=>{l=!0,h(y),l=!1}}:g}function WF(){const t=d.shallowRef(!1),e=d.getCurrentInstance();return e&&d.onMounted(()=>{t.value=!0},e),t}function UF(t){const e=WF();return d.computed(()=>(e.value,!!t()))}function HF(t,e,n={}){const{window:r=Ou,...o}=n;let s;const i=UF(()=>r&&"ResizeObserver"in r),a=()=>{s&&(s.disconnect(),s=void 0)},l=d.watch(d.computed(()=>{const u=d.toValue(t);return Array.isArray(u)?u.map(f=>ir(f)):[ir(u)]}),u=>{if(a(),i.value&&r){s=new ResizeObserver(e);for(const f of u)f&&s.observe(f,o)}},{immediate:!0,flush:"post"}),c=()=>{a(),l()};return DF(c),{isSupported:i,stop:c}}function Zb(t,e={width:0,height:0},n={}){const{window:r=Ou,box:o="content-box"}=n,s=d.computed(()=>{var f;return(f=ir(t))===null||f===void 0||(f=f.namespaceURI)===null||f===void 0?void 0:f.includes("svg")}),i=d.shallowRef(e.width),a=d.shallowRef(e.height),{stop:l}=HF(t,([f])=>{const h=o==="border-box"?f.borderBoxSize:o==="content-box"?f.contentBoxSize:f.devicePixelContentBoxSize;if(r&&s.value){const p=ir(t);if(p){const m=p.getBoundingClientRect();i.value=m.width,a.value=m.height}}else if(h){const p=Pu(h);i.value=p.reduce((m,{inlineSize:g})=>m+g,0),a.value=p.reduce((m,{blockSize:g})=>m+g,0)}else i.value=f.contentRect.width,a.value=f.contentRect.height},n);VF(()=>{const f=ir(t);f&&(i.value="offsetWidth"in f?f.offsetWidth:e.width,a.value="offsetHeight"in f?f.offsetHeight:e.height)});const c=d.watch(()=>ir(t),f=>{i.value=f?e.width:0,a.value=f?e.height:0});function u(){l(),c()}return{width:i,height:a,stop:u}}function Kb(){const t=d.inject(Rn);if(!t)throw new Error("useFonts must be used within a WovenCanvas component");return d.computed(()=>{const e=t.getEditor();return e?e.fonts.filter(n=>n.selectable):[]})}const ZF={class:"wov-font-family-button"},KF={class:"wov-font-family-label"},YF={class:"wov-font-list"},qF=["onClick"],JF=["src","alt"],hp=d.defineComponent({__name:"TextFontFamilyButton",props:{entityIds:{}},setup(t){const e=t,{state:n,commands:r}=_r(()=>e.entityIds),o=Kb(),s=d.computed(()=>o.value.map(u=>({name:u.name,displayName:u.displayName,previewImage:u.previewImage}))),i=d.computed(()=>n.fontFamily),a=d.computed(()=>{const u=i.value;if(u===null)return"Mixed";const f=s.value.find(h=>h.name===u);return(f==null?void 0:f.displayName)??u});function l(u){r.setFontFamily(u)}function c(u){u.stopPropagation()}return(u,f)=>d.unref(n).showTextMenuButtons?(d.openBlock(),d.createBlock(jn,{key:0,title:"Font Family"},{button:d.withCtx(()=>[d.createElementVNode("div",ZF,[d.createElementVNode("span",KF,d.toDisplayString(a.value),1),d.createVNode(Wn,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[d.createElementVNode("div",{class:"wov-font-family-menu",onWheel:c,onClick:f[0]||(f[0]=d.withModifiers(()=>{},["stop"]))},[d.createElementVNode("div",YF,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(s.value,h=>(d.openBlock(),d.createElementBlock("div",{key:h.name,class:d.normalizeClass(["wov-font-item",{active:i.value===h.name}]),onClick:p=>l(h.name)},[h.previewImage?(d.openBlock(),d.createElementBlock("img",{key:0,class:"wov-font-preview",src:h.previewImage,alt:h.name},null,8,JF)):(d.openBlock(),d.createElementBlock("span",{key:1,class:"wov-font-name",style:d.normalizeStyle({fontFamily:h.name})},d.toDisplayString(h.displayName),5))],10,qF))),128))])],32)]),_:1})):d.createCommentVNode("",!0)}}),GF={class:"wov-font-size-button"},XF={class:"wov-font-size-label"},QF=["onClick"],e6={key:0,class:"wov-check-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},t6={class:"wov-input-container"},n6=["value"],pp=d.defineComponent({__name:"TextFontSizeButton",props:{entityIds:{}},setup(t){const e=t,{state:n,commands:r}=_r(()=>e.entityIds),o=[{label:"Small",value:16,displayValue:10},{label:"Medium",value:24,displayValue:12},{label:"Large",value:40,displayValue:16},{label:"Huge",value:96,displayValue:20}],s=d.computed(()=>n.fontSize),i=d.computed(()=>{const h=s.value;if(h===null)return"Mixed";const p=o.find(m=>m.value===h);return p?p.label:`${+h.toFixed(1)} px`}),a=d.computed(()=>{const h=s.value;return h===null?"":String(+h.toFixed(1))});function l(h){r.setFontSize(h)}function c(h){const p=h.target,m=Number.parseFloat(p.value);!Number.isNaN(m)&&m>0&&l(m)}function u(h){h.key==="Enter"&&h.target.blur()}function f(h){h.stopPropagation()}return(h,p)=>d.unref(n).showTextMenuButtons?(d.openBlock(),d.createBlock(jn,{key:0,title:"Font Size"},{button:d.withCtx(()=>[d.createElementVNode("div",GF,[d.createElementVNode("span",XF,d.toDisplayString(i.value),1),d.createVNode(Wn,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[d.createElementVNode("div",{class:"wov-font-size-menu",onWheel:f,onClick:p[0]||(p[0]=d.withModifiers(()=>{},["stop"]))},[(d.openBlock(),d.createElementBlock(d.Fragment,null,d.renderList(o,m=>d.createElementVNode("div",{key:m.value,class:d.normalizeClass(["wov-font-size-option",{active:s.value===m.value}]),onClick:g=>l(m.value)},[s.value===m.value?(d.openBlock(),d.createElementBlock("svg",e6,[...p[1]||(p[1]=[d.createElementVNode("path",{d:"M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"},null,-1)])])):d.createCommentVNode("",!0),d.createElementVNode("span",{class:"wov-option-label",style:d.normalizeStyle({fontSize:`${m.displayValue}px`})},d.toDisplayString(m.label),5)],10,QF)),64)),p[3]||(p[3]=d.createElementVNode("div",{class:"wov-separator"},null,-1)),d.createElementVNode("div",t6,[d.createElementVNode("input",{class:"wov-custom-input",value:a.value,onInput:c,onKeydown:u,placeholder:"Custom size"},null,40,n6),p[2]||(p[2]=d.createElementVNode("span",{class:"wov-px-suffix"},"px",-1))])],32)]),_:1})):d.createCommentVNode("",!0)}}),mp=d.defineComponent({__name:"TextItalicButton",props:{entityIds:{}},setup(t){const e=t,{state:n,commands:r}=_r(()=>e.entityIds);return(o,s)=>d.unref(n).showTextMenuButtons?(d.openBlock(),d.createBlock(Ui,{key:0,title:"Italic",class:d.normalizeClass({"wov-active":d.unref(n).isItalic}),onClick:d.unref(r).toggleItalic},{default:d.withCtx(()=>[...s[0]||(s[0]=[d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512",fill:"currentColor"},[d.createElementVNode("path",{d:"M128 64c0-17.7 14.3-32 32-32l192 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-58.7 0L160 416l64 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l58.7 0L224 96l-64 0c-17.7 0-32-14.3-32-32z"})],-1)])]),_:1},8,["class","onClick"])):d.createCommentVNode("",!0)}}),gp=d.defineComponent({__name:"TextUnderlineButton",props:{entityIds:{}},setup(t){const e=t,{state:n,commands:r}=_r(()=>e.entityIds);return(o,s)=>d.unref(n).showTextMenuButtons?(d.openBlock(),d.createBlock(Ui,{key:0,title:"Underline",class:d.normalizeClass({"wov-active":d.unref(n).isUnderline}),onClick:d.unref(r).toggleUnderline},{default:d.withCtx(()=>[...s[0]||(s[0]=[d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",fill:"currentColor"},[d.createElementVNode("path",{d:"M16 64c0-17.7 14.3-32 32-32l96 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-16 0 0 128c0 53 43 96 96 96s96-43 96-96l0-128-16 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l96 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-16 0 0 128c0 88.4-71.6 160-160 160s-160-71.6-160-160L64 96 48 96C30.3 96 16 81.7 16 64zM0 448c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32z"})],-1)])]),_:1},8,["class","onClick"])):d.createCommentVNode("",!0)}}),r6={class:"wov-text-color-button"},o6={class:"wov-text-icon-container"},yp=d.defineComponent({__name:"TextColorButton",props:{entityIds:{}},setup(t){const e=t,{state:n,commands:r}=_r(()=>e.entityIds),o=d.computed(()=>n.color??"#000000"),s=d.computed(()=>({backgroundColor:o.value}));function i(a){r.setColor(rl(a))}return(a,l)=>d.unref(n).showTextMenuButtons?(d.openBlock(),d.createBlock(jn,{key:0,title:"Text Color"},{button:d.withCtx(()=>[d.createElementVNode("div",r6,[d.createElementVNode("div",o6,[l[0]||(l[0]=d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 640",fill:"currentColor",class:"wov-text-icon"},[d.createElementVNode("path",{d:"M349.1 114.7C343.9 103.3 332.5 96 320 96C307.5 96 296.1 103.3 290.9 114.7L123.5 480L112 480C94.3 480 80 494.3 80 512C80 529.7 94.3 544 112 544L200 544C217.7 544 232 529.7 232 512C232 494.3 217.7 480 200 480L193.9 480L215.9 432L424.2 432L446.2 480L440.1 480C422.4 480 408.1 494.3 408.1 512C408.1 529.7 422.4 544 440.1 544L528.1 544C545.8 544 560.1 529.7 560.1 512C560.1 494.3 545.8 480 528.1 480L516.6 480L349.2 114.7zM394.8 368L245.2 368L320 204.8L394.8 368z"})],-1)),d.createElementVNode("div",{class:"wov-color-underline",style:d.normalizeStyle(s.value)},null,4)]),d.createVNode(Wn,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[d.createVNode(Nu,{currentColor:o.value,withPicker:!0,onChange:i},null,8,["currentColor"])]),_:1})):d.createCommentVNode("",!0)}}),s6={key:0,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-align-vertical-justify-start-icon lucide-align-vertical-justify-start"},i6={key:1,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-align-vertical-justify-center-icon lucide-align-vertical-justify-center"},a6={key:2,xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-align-vertical-justify-end-icon lucide-align-vertical-justify-end"},Yb=d.defineComponent({__name:"VerticalAlignButton",props:{entityIds:{}},setup(t){const e=t,{nextEditorTick:n}=ut(),{state:r}=_r(()=>e.entityIds),o=[mt.Top,mt.Center,mt.Bottom],s=Zo(()=>e.entityIds,cs),i=d.computed(()=>{let l=null;for(const c of s.value.values()){const u=(c==null?void 0:c.value)??mt.Top;if(l===null)l=u;else if(l!==u)return null}return l});function a(){const l=i.value??mt.Top,c=o.indexOf(l),u=o[(c+1)%o.length];n(f=>{for(const h of e.entityIds){const p=cs.write(f,h);p.value=u}})}return(l,c)=>d.unref(r).showTextMenuButtons?(d.openBlock(),d.createBlock(Ui,{key:0,title:"Vertical Align",onClick:a},{default:d.withCtx(()=>[i.value===d.unref(mt).Top||i.value===null?(d.openBlock(),d.createElementBlock("svg",s6,[...c[0]||(c[0]=[d.createElementVNode("rect",{width:"14",height:"6",x:"5",y:"16",rx:"2"},null,-1),d.createElementVNode("rect",{width:"10",height:"6",x:"7",y:"6",rx:"2"},null,-1),d.createElementVNode("path",{d:"M2 2h20"},null,-1)])])):i.value===d.unref(mt).Center?(d.openBlock(),d.createElementBlock("svg",i6,[...c[1]||(c[1]=[d.createElementVNode("rect",{width:"14",height:"6",x:"5",y:"16",rx:"2"},null,-1),d.createElementVNode("rect",{width:"10",height:"6",x:"7",y:"2",rx:"2"},null,-1),d.createElementVNode("path",{d:"M2 12h20"},null,-1)])])):(d.openBlock(),d.createElementBlock("svg",a6,[...c[2]||(c[2]=[d.createElementVNode("rect",{width:"14",height:"6",x:"5",y:"12",rx:"2"},null,-1),d.createElementVNode("rect",{width:"10",height:"6",x:"7",y:"2",rx:"2"},null,-1),d.createElementVNode("path",{d:"M2 22h20"},null,-1)])]))]),_:1})):d.createCommentVNode("",!0)}}),l6={class:"wov-text-group-button"},c6={class:"wov-text-group-dropdown"},u6={class:"wov-text-group-row wov-text-group-row-full"},d6={class:"wov-text-group-row"},f6=d.defineComponent({__name:"TextButtonGroup",props:{entityIds:{},showVerticalAlign:{type:Boolean}},setup(t){const e=t,{state:n}=_r(()=>e.entityIds),r=d.inject("containerRef"),{width:o}=Zb(r),s=d.computed(()=>o.value>0&&o.value<600),i=d.ref(new Map);return d.provide($0,i),(a,l)=>d.unref(n).showTextMenuButtons?(d.openBlock(),d.createElementBlock(d.Fragment,{key:0},[s.value?(d.openBlock(),d.createBlock(jn,{key:0,title:"Text Formatting",placement:"top"},{button:d.withCtx(()=>[d.createElementVNode("div",l6,[l[0]||(l[0]=d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 640",fill:"currentColor",class:"wov-text-group-icon"},[d.createElementVNode("path",{d:"M349.1 114.7C343.9 103.3 332.5 96 320 96C307.5 96 296.1 103.3 290.9 114.7L123.5 480L112 480C94.3 480 80 494.3 80 512C80 529.7 94.3 544 112 544L200 544C217.7 544 232 529.7 232 512C232 494.3 217.7 480 200 480L193.9 480L215.9 432L424.2 432L446.2 480L440.1 480C422.4 480 408.1 494.3 408.1 512C408.1 529.7 422.4 544 440.1 544L528.1 544C545.8 544 560.1 529.7 560.1 512C560.1 494.3 545.8 480 528.1 480L516.6 480L349.2 114.7zM394.8 368L245.2 368L320 204.8L394.8 368z"})],-1)),d.createVNode(Wn,{class:"wov-chevron-down"})])]),dropdown:d.withCtx(()=>[d.createElementVNode("div",c6,[d.createElementVNode("div",u6,[d.createVNode(hp,{entityIds:t.entityIds},null,8,["entityIds"]),l[1]||(l[1]=d.createElementVNode("div",{class:"wov-text-group-spacer"},null,-1)),d.createVNode(pp,{entityIds:t.entityIds},null,8,["entityIds"])]),d.createElementVNode("div",d6,[d.createVNode(dp,{entityIds:t.entityIds},null,8,["entityIds"]),d.createVNode(mp,{entityIds:t.entityIds},null,8,["entityIds"]),d.createVNode(gp,{entityIds:t.entityIds},null,8,["entityIds"]),l[2]||(l[2]=d.createElementVNode("div",{class:"wov-text-group-spacer"},null,-1)),d.createVNode(yp,{entityIds:t.entityIds},null,8,["entityIds"]),d.createVNode(up,{entityIds:t.entityIds},null,8,["entityIds"]),t.showVerticalAlign?(d.openBlock(),d.createBlock(Yb,{key:0,entityIds:t.entityIds},null,8,["entityIds"])):d.createCommentVNode("",!0)])])]),_:1})):(d.openBlock(),d.createElementBlock(d.Fragment,{key:1},[d.createVNode(hp,{entityIds:t.entityIds},null,8,["entityIds"]),d.createVNode(pp,{entityIds:t.entityIds},null,8,["entityIds"]),l[3]||(l[3]=d.createElementVNode("div",{divider:"",class:"wov-divider"},null,-1)),d.createVNode(dp,{entityIds:t.entityIds},null,8,["entityIds"]),d.createVNode(mp,{entityIds:t.entityIds},null,8,["entityIds"]),d.createVNode(gp,{entityIds:t.entityIds},null,8,["entityIds"]),l[4]||(l[4]=d.createElementVNode("div",{divider:"",class:"wov-divider"},null,-1)),d.createVNode(yp,{entityIds:t.entityIds},null,8,["entityIds"]),d.createVNode(up,{entityIds:t.entityIds},null,8,["entityIds"]),t.showVerticalAlign?(d.openBlock(),d.createBlock(Yb,{key:0,entityIds:t.entityIds},null,8,["entityIds"])):d.createCommentVNode("",!0)],64))],64)):d.createCommentVNode("",!0)}}),qb=d.defineComponent({__name:"CanvasBackground",props:{background:{}},setup(t){const e=t,n=jt(we),r=jt(Ut),o=d.inject("containerRef"),s=d.ref({width:0,height:0});let i=null;const a=d.ref(null);let l=null;typeof document<"u"&&(l=document.createElement("canvas"));function c(y,w,v,b){const S=b/2;y.beginPath(),y.arc(w,v,S,0,Math.PI*2),y.fill()}function u(y,w,v){if(!l)return null;const b=v.dotSize??2,S=y*v.subdivisionStep,k=w*v.subdivisionStep;l.width=S,l.height=k;const E=l.getContext("2d");if(!E)return null;if(E.clearRect(0,0,S,k),E.fillStyle=v.strokeColor,v.subdivisionStep===1)c(E,S/2,k/2,b);else for(let _=0;_<v.subdivisionStep;_++)for(let M=0;M<v.subdivisionStep;M++){const I=(_+.5)*(S/v.subdivisionStep),P=(M+.5)*(k/v.subdivisionStep),Z=_===0&&M===0?2*b:b;c(E,I,P,Z)}return E.createPattern(l,"repeat")}function f(y,w,v,b,S,k){y.lineWidth=k,y.beginPath(),y.moveTo(w,v),y.lineTo(b,S),y.stroke()}function h(y,w,v){if(!l)return null;const b=v.gridSize??1,S=y*v.subdivisionStep,k=w*v.subdivisionStep;l.width=S,l.height=k;const E=l.getContext("2d");if(!E)return null;if(E.clearRect(0,0,S,k),E.strokeStyle=v.strokeColor,v.subdivisionStep===1)f(E,0,0,S,0,b),f(E,0,0,0,k,b);else{const _=S/v.subdivisionStep,M=k/v.subdivisionStep;for(let I=0;I<=v.subdivisionStep;I++){const P=I*_,V=I%v.subdivisionStep===0;f(E,P,0,P,k,V?3*b:b)}for(let I=0;I<=v.subdivisionStep;I++){const P=I*M,V=I%v.subdivisionStep===0;f(E,0,P,S,P,V?3*b:b)}}return E.createPattern(l,"repeat")}function p(y){let w=r.value.colWidth,v=r.value.rowHeight;const b=e.background.subdivisionStep,S=s.value.width,k=s.value.height,E=n.value.left,_=n.value.top,M=E+S/n.value.zoom,I=_+k/n.value.zoom;let P=w*b,V=v*b,Z=0,A=0,F=Number.POSITIVE_INFINITY,Y=Number.POSITIVE_INFINITY;for(;;){P=b*w,V=b*v,Z=Math.floor(E/P)*P,A=Math.floor(_/V)*V;const je=Math.ceil(M/P)*P,ar=Math.ceil(I/V)*V;if(Y=Math.round((je-Z)/w),F=Math.round((ar-A)/v),Math.max(Y,F)>200)w*=2,v*=2;else break}const ce=w*n.value.zoom,se=v*n.value.zoom,j=Math.round(ce),X=Math.round(se),he=u(j,X,e.background);if(!he)return;he.setTransform(new DOMMatrix().scale(ce/j,se/X));const Te=(Z-E-w/2)*n.value.zoom,Ce=(A-_-v/2)*n.value.zoom;y.save(),y.translate(Te,Ce),y.fillStyle=he,y.fillRect(0,0,S+P*n.value.zoom,k+V*n.value.zoom),y.restore()}function m(y){let w=r.value.colWidth,v=r.value.rowHeight;const b=e.background.subdivisionStep,S=s.value.width,k=s.value.height,E=n.value.left,_=n.value.top,M=E+S/n.value.zoom,I=_+k/n.value.zoom;let P=w*b,V=v*b,Z=0,A=0,F=Number.POSITIVE_INFINITY,Y=Number.POSITIVE_INFINITY;for(;;){P=b*w,V=b*v,Z=Math.floor(E/P)*P,A=Math.floor(_/V)*V;const je=Math.ceil(M/P)*P,ar=Math.ceil(I/V)*V;if(Y=Math.round((je-Z)/w),F=Math.round((ar-A)/v),Math.max(Y,F)>200)w*=2,v*=2;else break}const ce=w*n.value.zoom,se=v*n.value.zoom,j=Math.round(ce),X=Math.round(se),he=h(j,X,e.background);if(!he)return;he.setTransform(new DOMMatrix().scale(ce/j,se/X));const Te=(Z-E)*n.value.zoom,Ce=(A-_)*n.value.zoom;y.save(),y.translate(Te,Ce),y.fillStyle=he,y.fillRect(0,0,S+P*n.value.zoom,k+V*n.value.zoom),y.restore()}function g(){const y=a.value;if(!y)return;const w=y.getContext("2d");if(!w)return;const{width:v,height:b}=s.value;v===0||b===0||(y.width=v,y.height=b,w.clearRect(0,0,v,b),w.fillStyle=e.background.color,w.fillRect(0,0,v,b),e.background.kind==="dots"?p(w):e.background.kind==="grid"&&m(w))}return d.watch(()=>[e.background,n.value,r.value,s.value],()=>{g()},{deep:!0}),d.onMounted(()=>{const y=o==null?void 0:o.value;if(y){const w=()=>{s.value={width:y.clientWidth,height:y.clientHeight}};w(),i=new ResizeObserver(w),i.observe(y)}g()}),d.onUnmounted(()=>{i==null||i.disconnect()}),(y,w)=>(d.openBlock(),d.createElementBlock("canvas",{ref_key:"canvasRef",ref:a,style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none"}},null,512))}});function Jb(t,e){if(e.length===0)return new Set;const n=e[0].tag,r=t.blockDefs[n];if(!r)return new Set;const o=new Set(r.components.map(s=>s.name));for(let s=1;s<e.length;s++){const i=e[s].tag,a=t.blockDefs[i];if(!a){o.clear();break}const l=new Set(a.components.map(c=>c.name));for(const c of o)l.has(c)||o.delete(c)}return o}const Gb=d.defineComponent({__name:"FloatingMenuBar",setup(t){const e=d.useSlots(),{reset:n}=Yo(),r=d.inject(V0),{selectedIds:o,commonComponents:s}=r,i=new Set(["color","text","verticalAlign","penStroke","elbowArrow","arcArrow","shape"]),a=d.computed(()=>{const c=[];for(const u of s.value){const f=`button:${u}`;!i.has(u)&&e[f]&&c.push(u)}return c});function l(){n()}return d.onUnmounted(()=>{n()}),(c,u)=>(d.openBlock(),d.createElementBlock("div",{class:"wov-floating-menu-bar",onMouseleave:l},[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(a.value,f=>d.renderSlot(c.$slots,`button:${f}`,{key:f,entityIds:d.unref(o)})),128)),d.renderSlot(c.$slots,"button:color",{entityIds:d.unref(o)},()=>[d.unref(s).has("color")?(d.openBlock(),d.createBlock(Fb,{key:0,entityIds:d.unref(o)},null,8,["entityIds"])):d.createCommentVNode("",!0)]),d.renderSlot(c.$slots,"button:shape",{entityIds:d.unref(o)},()=>[d.unref(s).has("shape")?(d.openBlock(),d.createElementBlock(d.Fragment,{key:0},[d.createVNode(Ub,{entityIds:d.unref(o)},null,8,["entityIds"]),d.createVNode(Wb,{entityIds:d.unref(o)},null,8,["entityIds"]),d.createVNode(Hb,{entityIds:d.unref(o)},null,8,["entityIds"])],64)):d.createCommentVNode("",!0)]),d.renderSlot(c.$slots,"button:penStroke",{entityIds:d.unref(o)},()=>[d.unref(s).has("penStroke")?(d.openBlock(),d.createBlock(jb,{key:0,entityIds:d.unref(o)},null,8,["entityIds"])):d.createCommentVNode("",!0)]),d.renderSlot(c.$slots,"button:arrowThickness",{entityIds:d.unref(o)},()=>[d.unref(s).has("elbowArrow")||d.unref(s).has("arcArrow")?(d.openBlock(),d.createBlock($b,{key:0,entityIds:d.unref(o)},null,8,["entityIds"])):d.createCommentVNode("",!0)]),d.renderSlot(c.$slots,"button:arrowHeadStart",{entityIds:d.unref(o)},()=>[d.unref(s).has("elbowArrow")||d.unref(s).has("arcArrow")?(d.openBlock(),d.createBlock(lp,{key:0,entityIds:d.unref(o),side:"start"},null,8,["entityIds"])):d.createCommentVNode("",!0)]),d.renderSlot(c.$slots,"button:arrowHeadEnd",{entityIds:d.unref(o)},()=>[d.unref(s).has("elbowArrow")||d.unref(s).has("arcArrow")?(d.openBlock(),d.createBlock(lp,{key:0,entityIds:d.unref(o),side:"end"},null,8,["entityIds"])):d.createCommentVNode("",!0)]),d.renderSlot(c.$slots,"button:text",{entityIds:d.unref(o)},()=>[d.unref(s).has("text")?(d.openBlock(),d.createBlock(f6,{key:0,entityIds:d.unref(o),showVerticalAlign:d.unref(s).has("verticalAlign")},null,8,["entityIds","showVerticalAlign"])):d.createCommentVNode("",!0)]),d.createVNode(cp)],32))}}),h6={class:"wov-floating-menu-inner"},Xb=d.defineComponent({__name:"FloatingMenu",setup(t){const e=d.inject(Rn),n=sb([T,xt]),r=jt(we),o=jt(_t),s=jt(Xn),i=ol(),a=d.computed(()=>n.value.map(S=>S.entityId)),l=d.computed(()=>{const S=e==null?void 0:e.getEditor();if(!S||n.value.length===0)return new Set;const k=n.value.map(E=>({tag:E.block.value.tag}));return Jb(S,k)});d.provide(V0,{selectedIds:a,commonComponents:l});const c=[0,0,0,0];function u(...S){let k=1/0,E=1/0,_=-1/0,M=-1/0,I=!1;for(const P of S){if(!P)continue;const V=P.getBoundingClientRect();V.width<=0||(I=!0,k=Math.min(k,V.left),E=Math.min(E,V.top),_=Math.max(_,V.right),M=Math.max(M,V.bottom))}return I?{x:k,y:E,left:k,top:E,right:_,bottom:M,width:_-k,height:M-E,toJSON:()=>({})}:null}const f=d.computed(()=>{if(n.value.length===0)return null;const S=r.value;if(!S)return null;let k=null;for(const E of n.value){const _=E.block.value;pt.getAabb(_.position,_.size,_.rotateZ,c),ne.translate(c,[-S.left,-S.top]),ne.scale(c,S.zoom),k===null?k=ne.clone(c):ne.union(k,c)}return k}),h=d.inject("containerRef"),p=d.computed(()=>{const S=h==null?void 0:h.value;if(!S)return null;r.value,i.updateCounter.value;const k=i.blockElement.value,E=i.textElement.value,_=u(k,E);if(_)return{getBoundingClientRect:()=>_};const M=f.value;if(!M)return null;const I=S.getBoundingClientRect();return{getBoundingClientRect(){return{x:I.left+M[0],y:I.top+M[1],width:M[2]-M[0],height:M[3]-M[1],top:I.top+M[1],left:I.left+M[0],right:I.left+M[2],bottom:I.top+M[3]}}}}),m=d.ref(null),g={name:"clampToViewport",fn({y:S,rects:k}){const M=window.innerHeight-k.floating.height-8;return{y:Math.max(8,Math.min(S,M))}}},{floatingStyles:y}=Iu(p,m,{placement:"top",middleware:[Tu(12),Au({fallbackPlacements:["bottom"]}),Mu({padding:8}),g]}),w=d.computed(()=>{const S=f.value,k=o.value;return!S||!k?!0:S[2]<0||S[0]>k.width||S[3]<0||S[1]>k.height}),v=[_e.Dragging,_e.SelectionBoxDragging],b=d.computed(()=>n.value.length>0&&!w.value&&!v.includes(s.value.state));return(S,k)=>(d.openBlock(),d.createBlock(d.Transition,{name:"wov-fade"},{default:d.withCtx(()=>[b.value?(d.openBlock(),d.createElementBlock("div",{key:0,ref_key:"floatingRef",ref:m,class:"wov-floating-menu",style:d.normalizeStyle(d.unref(y))},[d.createElementVNode("div",h6,[d.renderSlot(S.$slots,"default",{},()=>[d.createVNode(Gb)])])],4)):d.createCommentVNode("",!0)]),_:3}))}}),p6={key:0,class:"wov-loading-overlay"},m6={class:"wov-loading-spinner"},Qb=d.defineComponent({__name:"LoadingOverlay",props:{isLoading:{type:Boolean}},setup(t){const e=d.ref("|"),n=["|","/","-","\\"];let r=null;return d.onMounted(()=>{r=setInterval(()=>{const o=n.indexOf(e.value);e.value=n[(o+1)%n.length]},100)}),d.onUnmounted(()=>{r!==null&&clearInterval(r)}),(o,s)=>(d.openBlock(),d.createBlock(d.Transition,{name:"wov-loading-fade"},{default:d.withCtx(()=>[t.isLoading?(d.openBlock(),d.createElementBlock("div",p6,[d.createElementVNode("div",m6,d.toDisplayString(e.value),1)])):d.createCommentVNode("",!0)]),_:1}))}}),g6={class:"wov-action-bar"},y6=d.defineComponent({__name:"ActionBar",setup(t){const{getEditor:e}=ut(),n=d.inject(Rn),r=d.ref(!1),o=d.ref(!1);if(n){const l=n.registerTickCallback(c=>{const{store:u}=ls(c,"editing");r.value=u.canUndo(),o.value=u.canRedo()});d.onUnmounted(l)}function s(){const l=e();l==null||l.command(Hd)}function i(){const l=e();l==null||l.command(ql)}function a(){const l=e();l==null||l.command(Qd)}return(l,c)=>(d.openBlock(),d.createElementBlock("div",g6,[d.createElementVNode("button",{class:"wov-action-button",onClick:s,"aria-label":"Undo"},[...c[0]||(c[0]=[d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-undo-icon lucide-undo"},[d.createElementVNode("path",{d:"M3 7v6h6"}),d.createElementVNode("path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"})],-1)])]),d.createElementVNode("button",{class:"wov-action-button",onClick:i,"aria-label":"Redo"},[...c[1]||(c[1]=[d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-redo-icon lucide-redo"},[d.createElementVNode("path",{d:"M21 7v6h-6"}),d.createElementVNode("path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7"})],-1)])]),d.createElementVNode("button",{class:"wov-action-button",onClick:a,"aria-label":"Delete"},[...c[2]||(c[2]=[d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-trash-icon lucide-trash"},[d.createElementVNode("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"}),d.createElementVNode("path",{d:"M3 6h18"}),d.createElementVNode("path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})],-1)])])]))}}),Ar=d.defineComponent({__name:"ToolbarButton",props:{name:{},tooltip:{},dragOutSnapshot:{},placementSnapshot:{},cursor:{default:"crosshair"}},setup(t){const e=t,n=d.inject(_f);if(!n)throw new Error("ToolbarButton must be used within a Toolbar component");const r=n,o=d.ref(null),{show:s,hide:i}=Yo(),a=d.computed(()=>r.activeTool.value===e.name);function l(){r.setTool(e.name,e.placementSnapshot,e.cursor)}function c(){r.onToolPointerDown(e.name,e.dragOutSnapshot)}function u(){r.onToolPointerUp()}function f(){e.tooltip&&o.value&&s(e.tooltip,o.value)}function h(){i()}return(p,m)=>(d.openBlock(),d.createElementBlock("button",{ref_key:"buttonRef",ref:o,class:d.normalizeClass(["wov-toolbar-button",{selected:a.value}]),onClick:l,onPointerdown:c,onPointerup:u,onMouseenter:f,onMouseleave:h},[d.renderSlot(p.$slots,"default")],34))}}),w6='<?xml version="1.0" encoding="UTF-8"?><svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4.35 4.75" width="20" height="20"><defs><style>.cls-1{stroke:#fff;stroke-miterlimit:10;stroke-width:.25px;}</style></defs><path class="cls-1" d="M2.39,2.88s-.04.01-.05.02c-.01,0-.02.01-.03.02,0,.01-.02.02-.03.05l-.77,1.44c-.07.13-.1.19-.14.2-.03.01-.07,0-.1-.01-.03-.02-.05-.09-.09-.23L.16.41c-.03-.13-.05-.19-.03-.23.02-.03.04-.05.08-.06.04,0,.1.02.21.08l3.59,1.94c.13.07.19.1.2.14.01.03,0,.07-.01.1-.02.03-.09.05-.23.09l-1.58.4Z"/></svg>',v6='<?xml version="1.0" encoding="UTF-8"?><svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4.08 4.75" width="24" height="24"><defs><style>.cls-1{fill:#fff;stroke:#000;stroke-linecap:round;stroke-linejoin:round;stroke-width:.25px;}.cls-2{fill:none;stroke:#fff;stroke-miterlimit:10;stroke-width:.51px;}</style></defs><path class="cls-1" d="M.89,2.25v.63M.89,2.25V.75c0-.21.17-.38.38-.38s.38.17.38.38M.89,2.25c0-.21-.17-.37-.38-.37s-.38.17-.38.37v.5c0,1.04.86,1.87,1.91,1.87s1.91-.84,1.91-1.87v-1.25c0-.21-.17-.38-.38-.38s-.38.17.38.38M1.66.75v1.38M1.66.75v-.25c0-.21.17-.38.38-.38s.38.17.38.38v.25M2.42.75v1.38M2.42.75c0-.21.17-.38.38-.38s.38.17.38.38v.75M3.19,1.5v.63"/><line class="cls-2" x1="2.8" y1=".77" x2="2.8" y2="2.03"/><line class="cls-2" x1="2.04" y1=".64" x2="2.04" y2="2.02"/><line class="cls-2" x1="1.27" y1=".84" x2="1.27" y2="2.29"/></svg>',k6='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M4 8v-2a2 2 0 0 1 2 -2h2" /><path d="M4 16v2a2 2 0 0 0 2 2h2" /><path d="M16 4h2a2 2 0 0 1 2 2v2" /><path d="M16 20h2a2 2 0 0 0 2 -2v-2" /><path d="M9 12l6 0" /><path d="M12 9l0 6" /></svg>',Fs={Select:"select",Hand:"hand",Crosshair:"crosshair"},eS={[Fs.Select]:{makeSvg:()=>w6,hotspot:[1,0],rotationOffset:0},[Fs.Hand]:{makeSvg:()=>v6,hotspot:[12,12],rotationOffset:0},[Fs.Crosshair]:{makeSvg:()=>k6,hotspot:[12,12],rotationOffset:0}},b6={viewBox:"0 0 20 20",style:{"fill-rule":"evenodd","clip-rule":"evenodd","stroke-miterlimit":"10"}},tS=d.defineComponent({__name:"SelectTool",setup(t){const{nextEditorTick:e}=ut(),{activeTool:n}=ep();return d.watch(n,(r,o)=>{o==="select"&&e(s=>{Si.spawn(s)})}),(r,o)=>(d.openBlock(),d.createBlock(Ar,{name:"select",tooltip:"Select",cursor:d.unref(Fs).Select},{default:d.withCtx(()=>[(d.openBlock(),d.createElementBlock("svg",b6,[...o[0]||(o[0]=[d.createElementVNode("g",{transform:"matrix(4.21053,0,0,4.21053,0.842105,0)"},[d.createElementVNode("path",{fill:"none",stroke:"currentColor","stroke-width":"0.5",d:"M2.39,2.88C2.38,2.885 2.34,2.9 2.33,2.91C2.32,2.91 2.298,2.939 2.28,2.97L1.51,4.41C1.44,4.54 1.41,4.6 1.37,4.61C1.34,4.62 1.3,4.61 1.27,4.6C1.24,4.58 1.22,4.51 1.18,4.37L0.16,0.41C0.13,0.28 0.11,0.22 0.13,0.18C0.15,0.15 0.17,0.13 0.21,0.12C0.25,0.12 0.31,0.14 0.42,0.2L4.01,2.14C4.14,2.21 4.2,2.24 4.21,2.28C4.22,2.31 4.21,2.35 4.2,2.38C4.18,2.41 4.11,2.43 3.97,2.47L2.39,2.88Z"})],-1)])]))]),_:1},8,["cursor"]))}}),nS=d.defineComponent({__name:"HandTool",setup(t){return(e,n)=>(d.openBlock(),d.createBlock(Ar,{name:"hand",tooltip:"Hand",cursor:d.unref(Fs).Hand},{default:d.withCtx(()=>[...n[0]||(n[0]=[d.createElementVNode("svg",{viewBox:"0 0 20.56 24"},[d.createElementVNode("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4.47,11.39v3.18M4.47,11.39V3.81c0-1.06.86-1.92,1.92-1.92s1.92.86,1.92,1.92M4.47,11.39c0-1.06-.86-1.87-1.92-1.87s-1.92.86-1.92,1.87v2.53c0,5.25,4.35,9.45,9.65,9.45s9.65-4.24,9.65-9.45v-6.32c0-1.06-.86-1.92-1.92-1.92s-1.92.86-1.92,1.92M8.36,3.81v6.97M8.36,3.81v-1.26c0-1.06.86-1.92,1.92-1.92s1.92.86,1.92,1.92v1.26M12.2,3.81v6.97M12.2,3.81c0-1.06.86-1.92,1.92-1.92s1.92.86,1.92,1.92v3.79M16.09,7.6v3.18"})],-1)])]),_:1},8,["cursor"]))}}),rS=d.defineComponent({__name:"StickyNoteTool",setup(t){const e=JSON.stringify({block:{tag:"sticky-note",size:[200,200]},color:{red:255,green:242,blue:117},text:{defaultAlignment:Bn.Center},verticalAlign:{value:mt.Center}});return(n,r)=>(d.openBlock(),d.createBlock(Ar,{name:"sticky-note",tooltip:"Sticky Note","drag-out-snapshot":d.unref(e),"placement-snapshot":d.unref(e)},{default:d.withCtx(()=>[...r[0]||(r[0]=[d.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[d.createElementVNode("path",{d:"M4 4h12v12H4z"}),d.createElementVNode("path",{d:"M7 8h6M7 11h4"})],-1)])]),_:1},8,["drag-out-snapshot","placement-snapshot"]))}}),oS=d.defineComponent({__name:"ShapeTool",setup(t){const e=JSON.stringify({block:{tag:"shape",size:[200,200]},shape:{kind:"rectangle",strokeKind:Ct.Solid,strokeWidth:2,strokeRed:0,strokeGreen:0,strokeBlue:0,strokeAlpha:255,fillRed:255,fillGreen:255,fillBlue:255,fillAlpha:0},text:{defaultAlignment:Bn.Center},verticalAlign:{value:mt.Center}});return(n,r)=>(d.openBlock(),d.createBlock(Ar,{name:"shape",tooltip:"Shape","drag-out-snapshot":d.unref(e),"placement-snapshot":d.unref(e)},{default:d.withCtx(()=>[...r[0]||(r[0]=[d.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[d.createElementVNode("rect",{x:"3",y:"3",width:"14",height:"14",rx:"2"})],-1)])]),_:1},8,["drag-out-snapshot","placement-snapshot"]))}}),sS=d.defineComponent({__name:"EraserTool",setup(t){return(e,n)=>(d.openBlock(),d.createBlock(Ar,{name:"eraser",tooltip:"Eraser"},{default:d.withCtx(()=>[...n[0]||(n[0]=[d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 640",fill:"currentColor"},[d.createElementVNode("path",{d:"M210.5 480L333.5 480L398.8 414.7L225.3 241.2L98.6 367.9L210.6 479.9zM256 544L210.5 544C193.5 544 177.2 537.3 165.2 525.3L49 409C38.1 398.1 32 383.4 32 368C32 352.6 38.1 337.9 49 327L295 81C305.9 70.1 320.6 64 336 64C351.4 64 366.1 70.1 377 81L559 263C569.9 273.9 576 288.6 576 304C576 319.4 569.9 334.1 559 345L424 480L544 480C561.7 480 576 494.3 576 512C576 529.7 561.7 544 544 544L256 544z"})],-1)])]),_:1}))}}),iS=d.defineComponent({__name:"PenTool",setup(t){return(e,n)=>(d.openBlock(),d.createBlock(Ar,{name:"pen",tooltip:"Pen"},{default:d.withCtx(()=>[...n[0]||(n[0]=[d.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5"},[d.createElementVNode("path",{d:"M13.586 3.586a2 2 0 1 1 2.828 2.828l-8.793 8.793-3.536.707.707-3.536 8.794-8.792Z","stroke-linecap":"round","stroke-linejoin":"round"}),d.createElementVNode("path",{d:"M12 5l3 3","stroke-linecap":"round"})],-1)])]),_:1}))}}),aS=d.defineComponent({__name:"TextTool",setup(t){const e=JSON.stringify({block:{tag:"text",size:[10,29]},text:{constrainWidth:!1,fontSizePx:24}}),n=JSON.stringify({block:{tag:"text",size:[36,29]},text:{content:"text",constrainWidth:!1,fontSizePx:24}});return(r,o)=>(d.openBlock(),d.createBlock(Ar,{name:"text",tooltip:"Text","drag-out-snapshot":d.unref(n),"placement-snapshot":d.unref(e)},{default:d.withCtx(()=>[...o[0]||(o[0]=[d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-type-icon lucide-type"},[d.createElementVNode("path",{d:"M12 4v16"}),d.createElementVNode("path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2"}),d.createElementVNode("path",{d:"M9 20h6"})],-1)])]),_:1},8,["drag-out-snapshot","placement-snapshot"]))}}),lS=d.defineComponent({__name:"ElbowArrowTool",setup(t){const e=JSON.stringify({block:{tag:"elbow-arrow",size:[200,200]},elbowArrow:{points:[0,0,.5,0,.5,1,1,1],pointCount:4,startArrowHead:De.None,endArrowHead:De.V},connector:{}});return(n,r)=>(d.openBlock(),d.createBlock(Ar,{name:"elbow-arrow",tooltip:"Elbow Arrow",cursor:"crosshair","drag-out-snapshot":d.unref(e)},{default:d.withCtx(()=>[...r[0]||(r[0]=[d.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},[d.createElementVNode("path",{d:"M4 6 L10 6 L10 14 L16 14"}),d.createElementVNode("path",{d:"M13 11 L16 14 L13 17"})],-1)])]),_:1},8,["drag-out-snapshot"]))}}),cS=d.defineComponent({__name:"ImageTool",setup(t){const{nextEditorTick:e}=ut(),{show:n,hide:r}=Yo(),{setTool:o}=ep(),{createImageBlock:s}=ob(),i=d.ref(null),a=d.ref(null);function l(){var h;(h=a.value)==null||h.click()}async function c(h){var S;const p=h.target,m=(S=p.files)==null?void 0:S[0];if(!m)return;if(p.value="",!m.type.startsWith("image/")){console.warn("Selected file is not an image");return}const g=await e(),y=we.read(g),w=_t.read(g),v=y.left+w.width/y.zoom/2,b=y.top+w.height/y.zoom/2;await s(m,v,b),o("select",void 0,Fs.Select)}function u(){i.value&&n("Image",i.value)}function f(){r()}return(h,p)=>(d.openBlock(),d.createElementBlock("button",{ref_key:"buttonRef",ref:i,class:"wov-toolbar-button",onClick:l,onMouseenter:u,onMouseleave:f},[p[0]||(p[0]=d.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[d.createElementVNode("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),d.createElementVNode("circle",{cx:"9",cy:"9",r:"2"}),d.createElementVNode("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})],-1)),d.createElementVNode("input",{ref_key:"fileInputRef",ref:a,type:"file",accept:"image/*",style:{display:"none"},onChange:c},null,544)],544))}}),S6={class:"wov-toolbar-container"},uS=d.defineComponent({__name:"Toolbar",setup(t){const e=d.useSlots(),{reset:n}=Yo(),{nextEditorTick:r}=ut(),o=d.ref(null),s=d.ref(null),i=jt(ct),a=d.computed(()=>i.value.leftMouseTool),l=[tS,nS,aS,cS,oS,lS,rS,iS,sS],c=d.inject("containerRef"),u=d.ref(null),f=d.ref(!1),h=d.ref(null),p=d.ref(null),m=d.ref(1/0),g=d.ref(0),y=d.ref([]),w=d.ref(8),v=d.ref(48),{width:b}=Zb(c);function S(){return h.value?Array.from(h.value.children).filter(j=>!j.classList.contains("wov-overflow-button")&&!j.classList.contains("wov-menu-tooltip")):[]}function k(){var Te;const j=S();if(j.length===0)return;g.value=j.length;const X=getComputedStyle(h.value);w.value=parseFloat(X.gap)||8;const he=((Te=p.value)==null?void 0:Te.offsetWidth)||40;v.value=he+w.value,y.value=j.map(Ce=>Ce.offsetWidth)}function E(){if(y.value.length===0)return;const he=b.value-40-20,Te=w.value,Ce=v.value;let je=0,ar=0;for(let so=0;so<y.value.length;so++){const Ks=y.value[so],Go=je>0?Ks+Te:Ks,Xo=y.value.length-so-1>0?Ce:0;if(je+Go+Xo<=he)je+=Go,ar++;else break}m.value=Math.max(1,ar)}d.watch(b,()=>{y.value.length>0&&E()}),d.onMounted(()=>{d.nextTick(()=>{k(),E()})});const _=d.computed(()=>m.value<g.value);d.watchEffect(()=>{S().forEach((X,he)=>{X.style.display=he<m.value?"":"none"})}),d.watchEffect(()=>{if(!u.value)return;Array.from(u.value.children).forEach((X,he)=>{X.style.display=he>=m.value?"":"none"})});const{floatingStyles:M}=Iu(p,u,{placement:"top",middleware:[Tu(16),Au(),Mu({padding:8})],whileElementsMounted:Ob});function I(){f.value=!f.value}function P(){f.value=!1}function V(j){const X=j.target;p.value&&!p.value.contains(X)&&u.value&&!u.value.contains(X)&&P()}d.watch(f,j=>{j?document.addEventListener("click",V,!0):document.removeEventListener("click",V,!0)}),d.watch(_,j=>{j||P()});function Z(j,X,he){s.value=X??null,r(Te=>{const Ce=ct.write(Te);Ce.leftMouseTool=j,Ce.heldSnapshot=X??"",he&&Pn.setCursor(Te,he)})}function A(j){r(X=>{const he=ct.write(X);he.leftMouseTool="drag-out",he.heldSnapshot=j})}function F(j,X){o.value=j,s.value=X??null}function Y(){o.value=null,s.value=null}function ce(){n(),o.value&&s.value&&A(s.value),o.value=null,s.value=null}const se={activeTool:a,heldTool:o,setTool:Z,dragOutTool:A,onToolPointerDown:F,onToolPointerUp:Y};return d.provide(_f,se),(j,X)=>(d.openBlock(),d.createElementBlock("div",S6,[d.createVNode(y6),d.createElementVNode("div",{ref_key:"toolsContainerRef",ref:h,class:"wov-toolbar",onMouseleave:ce},[d.unref(e).default?d.renderSlot(j.$slots,"default",{key:0}):(d.openBlock(),d.createElementBlock(d.Fragment,{key:1},d.renderList(l,(he,Te)=>d.createVNode(d.resolveDynamicComponent(he),{key:Te})),64)),_.value?(d.openBlock(),d.createElementBlock("button",{key:2,ref_key:"overflowBtnRef",ref:p,class:d.normalizeClass(["wov-toolbar-button wov-overflow-button",{"menu-open":f.value}]),onClick:I},[...X[0]||(X[0]=[d.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2"},[d.createElementVNode("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),d.createElementVNode("line",{x1:"5",y1:"12",x2:"19",y2:"12"})],-1)])],2)):d.createCommentVNode("",!0),d.createVNode(cp)],544),d.unref(c)?(d.openBlock(),d.createBlock(d.Teleport,{key:0,to:d.unref(c)},[f.value&&_.value?(d.openBlock(),d.createElementBlock("div",{key:0,ref_key:"overflowMenuRef",ref:u,class:"wov-toolbar-overflow-menu",style:d.normalizeStyle(d.unref(M))},[d.unref(e).default?d.renderSlot(j.$slots,"default",{key:0}):(d.openBlock(),d.createElementBlock(d.Fragment,{key:1},d.renderList(l,(he,Te)=>d.createVNode(d.resolveDynamicComponent(he),{key:Te})),64))],4)):d.createCommentVNode("",!0)],8,["to"])):d.createCommentVNode("",!0)]))}}),E6=d.defineComponent({__name:"ArcArrowTool",setup(t){return(e,n)=>(d.openBlock(),d.createBlock(Ar,{name:"arc-arrow",tooltip:"Arc Arrow",cursor:"crosshair"},{default:d.withCtx(()=>[...n[0]||(n[0]=[d.createElementVNode("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},[d.createElementVNode("path",{d:"M4 14 Q 10 4, 16 14"}),d.createElementVNode("path",{d:"M13 11 L16 14 L12.5 15.5"})],-1)])]),_:1}))}}),C6={class:"wov-user-presence-avatars"},_6=["src","alt"],x6={class:"wov-user-presence-list"},T6=["src","alt"],M6={class:"wov-user-presence-name"},A6=4,dS=d.defineComponent({__name:"UserPresence",props:{users:{}},setup(t){const e=t,n=d.ref(!1),r=d.ref(null);jF(r,()=>{n.value=!1});function o(a){if(!a)return"?";const l=a.trim().split(/\s+/);return l.length>=2?(l[0][0]+l[1][0]).toUpperCase():a.slice(0,2).toUpperCase()}const s=d.computed(()=>e.users.map(a=>({sessionId:a.sessionId,name:a.name,color:a.color,avatar:a.avatar,initials:o(a.name)}))),i=d.computed(()=>s.value.slice(0,A6));return(a,l)=>t.users.length>1?(d.openBlock(),d.createElementBlock("div",{key:0,ref_key:"containerRef",ref:r,class:"wov-user-presence"},[d.createElementVNode("button",{class:d.normalizeClass(["wov-user-presence-trigger",{"is-open":n.value}]),onClick:l[0]||(l[0]=c=>n.value=!n.value)},[d.createElementVNode("div",C6,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(i.value,c=>(d.openBlock(),d.createElementBlock("div",{key:c.sessionId,class:"wov-user-avatar",style:d.normalizeStyle({backgroundColor:c.avatar?"transparent":c.color})},[c.avatar?(d.openBlock(),d.createElementBlock("img",{key:0,src:c.avatar,alt:c.name,class:"wov-user-avatar-img"},null,8,_6)):(d.openBlock(),d.createElementBlock(d.Fragment,{key:1},[d.createTextVNode(d.toDisplayString(c.initials),1)],64))],4))),128))])],2),n.value?(d.openBlock(),d.createElementBlock("div",{key:0,class:"wov-user-presence-dropdown",onWheel:l[1]||(l[1]=d.withModifiers(()=>{},["stop"]))},[d.createElementVNode("div",x6,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(s.value,c=>(d.openBlock(),d.createElementBlock("div",{key:c.sessionId,class:"wov-user-presence-item"},[d.createElementVNode("div",{class:"wov-user-avatar wov-user-avatar-small",style:d.normalizeStyle({backgroundColor:c.avatar?"transparent":c.color})},[c.avatar?(d.openBlock(),d.createElementBlock("img",{key:0,src:c.avatar,alt:c.name,class:"wov-user-avatar-img"},null,8,T6)):(d.openBlock(),d.createElementBlock(d.Fragment,{key:1},[d.createTextVNode(d.toDisplayString(c.initials),1)],64))],4),d.createElementVNode("span",M6,d.toDisplayString(c.name),1)]))),128))])],32)):d.createCommentVNode("",!0)],512)):d.createCommentVNode("",!0)}});async function wp(t,e){const n=await Tp(t,1,{upgrade(r){r.objectStoreNames.contains(e)||r.createObjectStore(e)}});return new I6(n,e)}var I6=class{constructor(t,e){this.db=t,this.storeName=e}async get(t){return this.db.get(this.storeName,t)}async put(t,e){await this.db.put(this.storeName,e,t)}async delete(t){await this.db.delete(this.storeName,t)}async getAllEntries(){const e=this.db.transaction(this.storeName,"readonly").objectStore(this.storeName),n=await e.getAllKeys(),r=await e.getAll(),o=[];for(let s=0;s<n.length;s++)o.push([n[s],r[s]]);return o}async clear(){const t=this.db.transaction(this.storeName,"readwrite");t.objectStore(this.storeName).clear(),await t.done}close(){this.db.close()}},N6=class{constructor(t){this.jobsStore=null,this.binariesStore=null,this.blobUrls=new Map,this.uploading=new Set,this.uploadPromises=new Map,this.provider=t.provider,this.documentId=t.documentId,this.maxRetries=t.provider.maxRetries??3,this.retryDelay=t.provider.retryDelay??5e3}async init(){const t=`wovencanvas-assets-${this.documentId}`,[e,n]=await Promise.all([wp(`${t}-jobs`,"jobs"),wp(`${t}-binaries`,"binaries")]);this.jobsStore=e,this.binariesStore=n}async upload(t,e,n){if(!this.jobsStore||!this.binariesStore)throw new Error("AssetManager not initialized");await this.binariesStore.put(t,e);const r={identifier:t,metadata:n,createdAt:Date.now(),retryCount:0};await this.jobsStore.put(t,r);const o=URL.createObjectURL(e);return this.blobUrls.set(t,o),new Promise((s,i)=>{this.uploadPromises.set(t,{resolve:s,reject:i}),this.startUpload(t)})}async getDisplayUrl(t){const e=this.blobUrls.get(t);if(e)return e;try{return await this.provider.resolveUrl(t)}catch(n){return console.error(`Failed to resolve URL for ${t}:`,n),null}}async resumePendingUploads(){if(!this.jobsStore||!this.binariesStore)throw new Error("AssetManager not initialized");const t=await this.jobsStore.getAllEntries();for(const[e]of t){const n=await this.binariesStore.get(e);if(n){const r=URL.createObjectURL(n);this.blobUrls.set(e,r)}this.startUpload(e)}}hasPendingUpload(t){return this.blobUrls.has(t)}isUploading(t){return this.uploading.has(t)}async cancelUpload(t){if(!this.jobsStore||!this.binariesStore)return;const e=this.blobUrls.get(t);e&&(URL.revokeObjectURL(e),this.blobUrls.delete(t)),await this.jobsStore.delete(t),await this.binariesStore.delete(t),this.uploading.delete(t);const n=this.uploadPromises.get(t);n&&(n.reject(new Error("Upload cancelled")),this.uploadPromises.delete(t))}close(){var t,e;for(const n of this.blobUrls.values())URL.revokeObjectURL(n);this.blobUrls.clear(),(t=this.jobsStore)==null||t.close(),(e=this.binariesStore)==null||e.close(),this.jobsStore=null,this.binariesStore=null}async startUpload(t){if(!this.jobsStore||!this.binariesStore||this.uploading.has(t))return;this.uploading.add(t);const e=await this.jobsStore.get(t),n=await this.binariesStore.get(t);if(!e||!n){this.uploading.delete(t);return}try{await this.provider.upload(n,t,e.metadata),await this.onUploadSuccess(t)}catch(r){await this.onUploadError(t,e,r)}}async onUploadSuccess(t){if(!this.jobsStore||!this.binariesStore)return;const e=this.blobUrls.get(t);e&&(URL.revokeObjectURL(e),this.blobUrls.delete(t)),await this.jobsStore.delete(t),await this.binariesStore.delete(t),this.uploading.delete(t);const n=this.uploadPromises.get(t);n&&(n.resolve(),this.uploadPromises.delete(t))}async onUploadError(t,e,n){if(!this.jobsStore)return;const r=n instanceof Error?n.message:"Unknown error";if(console.error(`Upload failed for ${t}:`,r),this.uploading.delete(t),e.retryCount<this.maxRetries){const o={...e,retryCount:e.retryCount+1};await this.jobsStore.put(t,o),setTimeout(()=>{this.startUpload(t)},this.retryDelay*2**e.retryCount)}else{const o=this.uploadPromises.get(t);o&&(o.reject(new Error(r)),this.uploadPromises.delete(t))}}},B6="wovencanvas-assets",P6="blobs",O6=class{constructor(){this.store=null,this.initPromise=null,this.maxRetries=3,this.retryDelay=5e3}async upload(t,e,n){return await(await this.getStore()).put(e,{blob:t,metadata:n}),{}}async resolveUrl(t){const n=await(await this.getStore()).get(t);if(!n)throw new Error(`Asset not found: ${t}`);return URL.createObjectURL(n.blob)}async delete(t){await(await this.getStore()).delete(t)}close(){this.store&&(this.store.close(),this.store=null,this.initPromise=null)}getStore(){return this.store?Promise.resolve(this.store):(this.initPromise||(this.initPromise=wp(B6,P6).then(t=>(this.store=t,t))),this.initPromise)}},fS=vr.object({minZoom:vr.number().default(.05),maxZoom:vr.number().default(2.7),disableWheel:vr.boolean().default(!1)});fS.parse({});var ll=Eo("panState",{state:C.string().max(16).default("idle"),panStartX:C.float64().default(0),panStartY:C.float64().default(0),velocityX:C.float64().default(0),velocityY:C.float64().default(0),targetX:C.float64().default(0),targetY:C.float64().default(0),expectedLeft:C.float64().default(0),expectedTop:C.float64().default(0)}),js=Ki({name:"pinchState"},{active:C.boolean().default(!1),prevDistance:C.float64().default(0),prevCenter:C.tuple(C.float64(),2).default([0,0])}),no=[0,0],Du=[0,0],cl=[0,0],vp=[0,0],kp=[0,0];function D6(t,e,n,r,o,s){r=Math.max(1e-4,r);const i=2/r,a=i*s,l=1/(1+a+.48*a*a+.235*a*a*a);$.copy(no,t),$.sub(no,e);const c=o*r,u=c*c,f=$.lengthSq(no);f>u&&$.scale(no,c/Math.sqrt(f)),$.copy(Du,t),$.sub(Du,no),$.set(cl,(n[0]+i*no[0])*s,(n[1]+i*no[1])*s);const h=[(n[0]-i*cl[0])*l,(n[1]-i*cl[1])*l],p=[Du[0]+(no[0]+cl[0])*l,Du[1]+(no[1]+cl[1])*l];return $.copy(vp,e),$.sub(vp,t),$.copy(kp,p),$.sub(kp,e),$.dot(vp,kp)>0&&(p[0]=e[0],p[1]=e[1],h[0]=(p[0]-e[0])/s,h[1]=(p[1]-e[1])/s),{position:p,velocity:h}}var bp=.1,hS=.1,R6=$r({guards:{hasVelocity:({event:t})=>{if(t.type!=="pointerUp")return!1;const e=t.velocity;return Math.hypot(e[0],e[1])>hS},isGlideComplete:({context:t})=>Math.hypot(t.velocityX,t.velocityY)<hS,cameraWasMoved:({context:t,event:e})=>{const n=we.read(e.ctx);return n.left!==t.expectedLeft||n.top!==t.expectedTop},isEscapeKey:({event:t})=>t.key===dn.Escape},actions:{setDragStart:Ke({panStartX:({event:t})=>t.worldPosition[0],panStartY:({event:t})=>t.worldPosition[1]}),moveCamera:({context:t,event:e})=>{const n=e,{ctx:r}=n,o=n.worldPosition[0]-t.panStartX,s=n.worldPosition[1]-t.panStartY,i=we.write(r);i.left-=o,i.top-=s},startGlide:Ke(({event:t})=>{const e=t,{ctx:n}=e,r=we.read(n),o=e.cameraZoom,s=-e.velocity[0]/o,i=-e.velocity[1]/o;return{velocityX:s,velocityY:i,targetX:r.left+s*bp,targetY:r.top+i*bp,expectedLeft:r.left,expectedTop:r.top}}),animateGlide:Ke(({context:t,event:e})=>{const n=e,{ctx:r,delta:o}=n,s=we.read(r),{position:i,velocity:a}=D6([s.left,s.top],[t.targetX,t.targetY],[t.velocityX,t.velocityY],bp,Number.POSITIVE_INFINITY,o),l=we.write(r);return l.left=i[0],l.top=i[1],{velocityX:a[0],velocityY:a[1],expectedLeft:i[0],expectedTop:i[1]}}),resetContext:Ke({panStartX:0,panStartY:0,velocityX:0,velocityY:0,targetX:0,targetY:0,expectedLeft:0,expectedTop:0})}}).createMachine({id:"pan",initial:"idle",context:{panStartX:0,panStartY:0,velocityX:0,velocityY:0,targetX:0,targetY:0,expectedLeft:0,expectedTop:0},states:{idle:{on:{pointerDown:{actions:"setDragStart",target:"panning"}}},panning:{entry:"moveCamera",on:{pointerMove:{actions:"moveCamera"},pointerUp:[{guard:"hasVelocity",actions:"startGlide",target:"gliding"},{target:"idle"}],keyDown:{guard:"isEscapeKey",target:"idle"}}},gliding:{on:{frame:[{guard:"cameraWasMoved",actions:"resetContext",target:"idle"},{guard:"isGlideComplete",actions:"resetContext",target:"idle"},{actions:"animateGlide"}],pointerDown:{actions:["resetContext","setDragStart"],target:"panning"}}}}}),z6=Se({phase:"input",priority:-100},t=>{const e=ll.read(t).state;if(js.read(t).active){e!=="idle"&&ll.copy(t,ll.default());return}const r=ct.getButtons(t,"hand"),s=[...Wr(t,r)];e==="gliding"&&s.push(sN(t)),s.push(...iN(t,[dn.Escape])),s.length!==0&&ll.run(t,R6,s)}),$6=ie(t=>t.with(Et)),L6=Se({phase:"input",priority:-100},t=>{const e=ls(t,"controls"),n=$6.current(t),r=[];for(let m=0;m<n.length;m++){const g=n[m],y=Et.read(t,g);y.pointerType===Vr.Touch&&r.push(y.position)}if(r.length!==2){if(js.read(t).active){const g=js.write(t);g.active=!1}return}const[o,s]=r,i=$.distance(o,s),a=$.midPoint(o,s),l=js.read(t);if(!l.active){const m=js.write(t);m.prevDistance=i,m.prevCenter=a,m.active=!0;return}const c=we.read(t),u=_t.read(t);if(l.prevDistance>0&&i>0){const m=i/l.prevDistance;let g=c.zoom*m;g=Math.min(e.maxZoom,Math.max(e.minZoom,g));const y=u.width/c.zoom,w=u.height/c.zoom,v=u.width/g,b=u.height/g,S=v-y,k=b-w,E=a[0]/u.width,_=a[1]/u.height,M=we.write(t);M.left-=E*S,M.top-=_*k,M.zoom=g}const f=a[0]-l.prevCenter[0],h=a[1]-l.prevCenter[1];if(f!==0||h!==0){const m=we.write(t);m.left-=f/m.zoom,m.top-=h/m.zoom}const p=js.write(t);p.prevDistance=i,p.prevCenter=a}),V6=Se({phase:"input",priority:-100},t=>{const e=Sn.read(t);if(!ct.wheelActive(t,"scroll",e.modDown))return;const r=ky(t).find(l=>l.type==="wheel");if(!r)return;const o=we.read(t),s=o.left+r.wheelDeltaX/o.zoom,i=o.top+r.wheelDeltaY/o.zoom,a=we.write(t);a.left=s,a.top=i}),F6=Se({phase:"input",priority:-100},t=>{const e=ls(t,"controls"),n=Sn.read(t);if(!ct.wheelActive(t,"zoom",n.modDown))return;const o=ky(t).find(S=>S.type==="wheel");if(!o)return;const s=we.read(t),i=_t.read(t),a=On.read(t);let l=2**(-.8*o.wheelDeltaY/500)*s.zoom;l=Math.min(e.maxZoom,Math.max(e.minZoom,l));const c=i.width/s.zoom,u=i.height/s.zoom,f=i.width/l,h=i.height/l,p=f-c,m=h-u,g=a.position[0]/i.width,y=a.position[1]/i.height,w=s.left-g*p,v=s.top-y*m,b=we.write(t);b.left=w,b.top=v,b.zoom=l});function j6(t={}){const e=fS.parse(t);return{name:"controls",resources:e,singletons:[ll,js],systems:[F6,V6,z6,L6],setup(n){if(e.disableWheel){const{domElement:r}=He(n);g2(r,!1)}}}}var W6=(t={})=>j6(t);const U6={class:"wov-selection-box"},H6=d.defineComponent({__name:"SelectionBox",setup(t){return(e,n)=>(d.openBlock(),d.createElementBlock("div",U6))}}),Z6={class:"wov-transform-box"},K6=d.defineComponent({__name:"TransformBox",setup(t){return(e,n)=>(d.openBlock(),d.createElementBlock("div",Z6))}}),Y6={},q6={class:"wov-transform-handle"};function J6(t,e){return d.openBlock(),d.createElementBlock("div",q6)}const G6=ys(Y6,[["render",J6]]),X6=d.defineComponent({__name:"StickyNote",props:{entityId:{},block:{},stratum:{},selected:{type:Boolean},held:{},hovered:{type:Boolean},edited:{type:Boolean},opacity:{},connector:{}},setup(t){const e=t,n=Tt(e.entityId,In),r=Tt(e.entityId,cs),o=d.ref(null),s={[mt.Top]:"flex-start",[mt.Center]:"center",[mt.Bottom]:"flex-end"},i=d.computed(()=>{var l;return{backgroundColor:n.value?`rgb(${n.value.red}, ${n.value.green}, ${n.value.blue})`:void 0,minHeight:`${e.block.size[0]}px`,alignItems:s[((l=r.value)==null?void 0:l.value)??mt.Top]}}),{handleEditEnd:a}=Qh({blockData:e,containerRef:o,minWidth:()=>e.block.size[0],minHeight:()=>e.block.size[0]});return(l,c)=>(d.openBlock(),d.createElementBlock("div",{ref_key:"containerRef",ref:o,class:"wov-sticky-note",style:d.normalizeStyle(i.value)},[d.createVNode(mu,d.mergeProps(e,{"block-element":o.value,onEditEnd:d.unref(a)}),null,16,["block-element","onEditEnd"])],4))}}),Ru=Ki({name:"blockPlacementState"},{editedCheckpoint:C.string().default("").max(36)}),pS=ie(t=>t.with(Lr));function Q6(t){var e;if(!t)return null;try{const n=JSON.parse(t);return(e=n.block)!=null&&e.tag?n:(console.warn("Block snapshot missing required tag:",n),null)}catch{return console.warn("Invalid block snapshot JSON:",t),null}}function e5(t,e,n){const r=Xt(t,e.block.tag);if(!r)throw new Error(`Block placement: block definition for tag "${e.block.tag}" not found`);const o=e.block.size??[100,100],s=n[0]-o[0]/2,i=n[1]-o[1]/2,a=e.block.rank??Zn.genNext(t),l=Bt(t);"synced"in e||ee(t,l,me,{id:crypto.randomUUID()});const c=Object.assign({},e.block,{position:[s,i],size:o,rank:a});ee(t,l,T,c);for(const f of r.components)if(!(f.name in e))ee(t,l,f);else{const h=e[f.name];ee(t,l,f,h)}const{sessionId:u}=He(t);return ee(t,l,Rt,{sessionId:u}),l}function mS(t,e,n,r,o){const s=e5(t,e,n),i=T.read(t,s);if(ay(t,e.block.tag)&&(ee(t,s,Ca,{}),o==="placement")){const{store:u}=ls(t,"editing"),f=u.createCheckpoint();if(f){const h=Ru.write(t);h.editedCheckpoint=f}}const a=Xn.write(t);a.state=o==="dragOut"?_e.Dragging:_e.Pointing,a.dragStart=n,a.draggedEntity=s,a.draggedEntityStart=i.position,a.pointingStartClient=r,a.pointingStartWorld=n,a.isCloning=!1;const l=ct.write(t);l.leftMouseTool="select",l.heldSnapshot="";const c=Pn.write(t);c.cursorKind="select",c.rotation=0}function t5(t){const e=Ru.read(t);if(e.editedCheckpoint){const n=e.editedCheckpoint;Ru.write(t).editedCheckpoint="";const{store:r}=ls(t,"editing");r.onSettled(()=>r.squashToCheckpoint(n),{frames:5})}}const n5=Se({phase:"capture"},t=>{pS.removed(t).length>0&&pS.current(t).length===0&&t5(t);const e=ct.read(t);if(!e.heldSnapshot)return;const n=Wr(t,[bn.Left]);if(n.length===0)return;const r=Q6(e.heldSnapshot);if(!r)return;if(e.leftMouseTool==="drag-out"){const s=n.find(i=>i.type==="pointerMove"&&!i.obscured);if(!s)return;mS(t,r,s.worldPosition,s.screenPosition,"dragOut")}else{const s=n.find(i=>i.type==="pointerDown"&&!i.obscured);if(!s)return;mS(t,r,s.worldPosition,s.screenPosition,"placement")}}),r5=Se({phase:"update"},t=>{const{store:e}=ls(t,"editing");fe(t,Hd,()=>{e.canUndo()&&(t0(t),e.undo())}),fe(t,ql,()=>{e.canRedo()&&(t0(t),e.redo())})}),o5=[{name:"Figtree",displayName:"Figtree",url:"https://fonts.googleapis.com/css2?family=Figtree",previewImage:"https://storage.googleapis.com/scrolly-page-fonts/Figtree.png"},{name:"Shantell Sans",displayName:"Shantell Sans",url:"https://fonts.googleapis.com/css2?family=Shantell+Sans",previewImage:"https://storage.googleapis.com/scrolly-page-fonts/ShantellSans.png"},{name:"Courier Prime",displayName:"Courier Prime",url:"https://fonts.googleapis.com/css2?family=Courier+Prime",previewImage:"https://storage.googleapis.com/scrolly-page-fonts/CourierPrime.png"},{name:"EB Garamond",displayName:"EB Garamond",url:"https://fonts.googleapis.com/css2?family=EB+Garamond",previewImage:"https://storage.googleapis.com/scrolly-page-fonts/EBGaramond.png"}];function gS(t){return{name:"editing",resources:{store:t.store},singletons:[Ru],systems:[n5,r5],cursors:eS,fonts:o5,keybinds:[{command:Hd.name,key:dn.Z,mod:!0},{command:ql.name,key:dn.Y,mod:!0},{command:ql.name,key:dn.Z,mod:!0,shift:!0}]}}const s5=d.defineComponent({__name:"FileDropZone",props:{maxSize:{default:400}},setup(t){const e=t,{nextEditorTick:n}=ut(),{createImageBlock:r}=ob(),o=d.ref(!1);let s=0;const i=d.inject("containerRef");function a(v){var b;(b=v.dataTransfer)!=null&&b.types.some(S=>S==="Files"||S==="text/uri-list"||S==="text/html")&&(s++,s===1&&(o.value=!0))}function l(){s--,s===0&&(o.value=!1)}function c(){s=0,o.value=!1}d.onMounted(()=>{const v=i==null?void 0:i.value;v&&(v.addEventListener("dragenter",a),v.addEventListener("dragleave",l),v.addEventListener("drop",c))}),d.onUnmounted(()=>{const v=i==null?void 0:i.value;v&&(v.removeEventListener("dragenter",a),v.removeEventListener("dragleave",l),v.removeEventListener("drop",c))});function u(v){v.preventDefault(),v.dataTransfer&&(v.dataTransfer.dropEffect="copy")}function f(v){v.preventDefault()}function h(v){v.preventDefault()}async function p(v){if(v.preventDefault(),!v.dataTransfer)return;const b=v.clientX,S=v.clientY,k=Array.from(v.dataTransfer.files).filter(_=>_.type.startsWith("image/"));if(k.length>0){for(const _ of k)await y(_,b,S);return}const E=m(v.dataTransfer);E&&await w(E,b,S)}function m(v){const b=v.getData("text/uri-list");if(b){const _=b.split(`
171
171
  `).filter(M=>!M.startsWith("#")).find(M=>g(M));if(_)return _}const S=v.getData("text/html");if(S){const E=S.match(/<img[^>]+src=["']([^"']+)["']/i);if(E!=null&&E[1])return E[1]}const k=v.getData("text/plain");return k&&g(k)?k:null}function g(v){try{const S=new URL(v).pathname.toLowerCase();return/\.(jpg|jpeg|png|gif|webp|svg|bmp|ico)$/i.test(S)||v.startsWith("data:image/"),!0}catch{return!1}}async function y(v,b,S){const k=await n(),E=we.read(k),_=_t.read(k),M=E.left+(b-_.left)/E.zoom,I=E.top+(S-_.top)/E.zoom;await r(v,M,I,{maxSize:e.maxSize})}async function w(v,b,S){try{const k=await fetch(v);if(!k.ok){console.warn("Failed to fetch image from URL:",v);return}const E=await k.blob();if(!E.type.startsWith("image/")){console.warn("URL did not return an image:",v);return}const M=new URL(v).pathname.split("/").pop()||"image",I=new File([E],M,{type:E.type});await y(I,b,S)}catch(k){console.warn("Failed to load image from URL:",v,k)}}return(v,b)=>(d.openBlock(),d.createElementBlock("div",{class:d.normalizeClass(["wov-image-drop-zone",{"wov-drag-over":o.value}]),onDragover:u,onDragenter:f,onDragleave:h,onDrop:p},null,34))}}),i5={class:"wov-user-cursors"},a5={class:"wov-cursor-svg",viewBox:"0 0 4.35 4.75",width:"20",height:"20"},l5=["fill"],c5="M2.39,2.88s-.04.01-.05.02c-.01,0-.02.01-.03.02,0,.01-.02.02-.03.05l-.77,1.44c-.07.13-.1.19-.14.2-.03.01-.07,0-.1-.01-.03-.02-.05-.09-.09-.23L.16.41c-.03-.13-.05-.19-.03-.23.02-.03.04-.05.08-.06.04,0,.1.02.21.08l3.59,1.94c.13.07.19.1.2.14.01.03,0,.07-.01.1-.02.03-.09.05-.23.09l-1.58.4Z",u5=d.defineComponent({__name:"UserCursors",props:{users:{},currentSessionId:{},camera:{}},setup(t){const e=t,n=d.computed(()=>e.users.filter(r=>r.sessionId!==e.currentSessionId).map(r=>({...r,screenX:(r.position[0]-e.camera.left)*e.camera.zoom,screenY:(r.position[1]-e.camera.top)*e.camera.zoom})));return(r,o)=>(d.openBlock(),d.createElementBlock("div",i5,[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(n.value,s=>(d.openBlock(),d.createElementBlock("div",{key:s.sessionId,class:"wov-user-cursor",style:d.normalizeStyle({transform:`translate(${s.screenX}px, ${s.screenY}px)`})},[(d.openBlock(),d.createElementBlock("svg",a5,[d.createElementVNode("path",{fill:s.color,stroke:"#fff","stroke-miterlimit":"10","stroke-width":".25",d:c5},null,8,l5)])),d.createElementVNode("span",{class:"wov-cursor-label",style:d.normalizeStyle({backgroundColor:s.color})},d.toDisplayString(s.name),5)],4))),128))]))}}),d5={key:0,class:"wov-offline-indicator"},f5=d.defineComponent({__name:"OfflineIndicator",props:{isOnline:{type:Boolean}},setup(t){return(e,n)=>t.isOnline?d.createCommentVNode("",!0):(d.openBlock(),d.createElementBlock("div",d5,"Working Offline"))}}),h5={key:0,class:"wov-version-mismatch-overlay"},p5=d.defineComponent({__name:"VersionMismatch",props:{versionMismatch:{type:Boolean}},setup(t){function e(){window.location.reload()}return(n,r)=>t.versionMismatch?(d.openBlock(),d.createElementBlock("div",h5,[d.createElementVNode("div",{class:"wov-version-mismatch-dialog"},[r[0]||(r[0]=d.createElementVNode("p",null,"A new version is available.",-1)),r[1]||(r[1]=d.createElementVNode("p",null,"Please refresh the page to continue.",-1)),d.createElementVNode("button",{onClick:e},"Refresh")])])):d.createCommentVNode("",!0)}}),m5=d.defineComponent({__name:"BackToContentButton",setup(t){const{nextEditorTick:e}=ut(),n=jt(we),r=ie(l=>l.with(me,T,Ve)),o=d.ref(0),s=d.inject(Rn);if(s){const l=s.registerTickCallback(c=>{r.addedOrRemoved(c).length>0&&(o.value=r.current(c).length)});d.onUnmounted(l)}const i=d.ref(!1);d.watchEffect(()=>{i.value=!n.value.canSeeBlocks&&o.value>0});function a(){e(l=>{const c=r.current(l);if(c.length===0)return;let u=Number.POSITIVE_INFINITY,f=Number.POSITIVE_INFINITY,h=Number.NEGATIVE_INFINITY,p=Number.NEGATIVE_INFINITY;for(const E of c){const _=Ve.read(l,E);u=Math.min(u,_.value[0]),f=Math.min(f,_.value[1]),h=Math.max(h,_.value[2]),p=Math.max(p,_.value[3])}const m=_t.read(l),g=we.read(l);let y=Math.min(m.width/(h-u),m.height/(p-f));y/=1.1,y=Math.min(y,g.zoom);const w=(u+h)/2,v=(f+p)/2,b=w-m.width/y/2,S=v-m.height/y/2,k=we.write(l);k.left=b,k.top=S,k.zoom=y})}return(l,c)=>i.value?(d.openBlock(),d.createElementBlock("button",{key:0,class:"wov-back-to-content",onClick:a},[...c[0]||(c[0]=[d.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[d.createElementVNode("path",{d:"M10 12L6 8L10 4",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1),d.createTextVNode(" Back to content ",-1)])])):d.createCommentVNode("",!0)}}),g5=["data-entity-id","data-selected","data-held-by-other","data-hovered"],y5=d.defineComponent({__name:"WovenCanvas",props:{store:{},editor:{},background:{},assetProvider:{},pluginOptions:{},controls:{}},emits:["ready"],setup(t,{emit:e}){var yS;const n=ie(B=>B.tracking(T)),r=ie(B=>B.with(T).tracking(Ye)),o=ie(B=>B.with(T).tracking(xt)),s=ie(B=>B.with(T).tracking(Rt)),i=ie(B=>B.with(T).tracking(bo)),a=ie(B=>B.with(T).tracking(Lr)),l=ie(B=>B.with(T).tracking(lt)),c=ie(B=>B.tracking(jr)),u=t,f=e,h=d.ref(null),p=d.shallowRef(null),m=ey.parse(((yS=u.editor)==null?void 0:yS.user)??{}),g=new Set,y=new Map,w=d.shallowRef([]),v=new Map,b=new Map,S=new Set,k=new Map,E=d.shallowRef([]),_=d.ref(!0),M=d.ref(!1),I=d.ref(!0),P=d.shallowRef(we.default());function V(B,ke,U){let le=v.get(B);le||(le=new Map,v.set(B,le));let Q=le.get(ke);return Q||(Q=new Set,le.set(ke,Q)),Q.add(U),()=>{Q.delete(U),Q.size===0&&(le.delete(ke),le.size===0&&v.delete(B))}}function Z(B,ke,U,le=!1){const Q=v.get(ke);if(!Q)return;const W=Q.get(U.name);if(!W||W.size===0)return;let ft=null;le||(ft=U.snapshot(B,ke));for(const lr of W)lr(ft)}function A(B,ke){let U=b.get(B);return U||(U=new Set,b.set(B,U)),U.add(ke),()=>{U.delete(ke),U.size===0&&b.delete(B)}}function F(B,ke){const U=b.get(ke.name);if(!U||U.size===0)return;const le=ke.snapshot(B);for(const Q of U)Q(le)}function Y(B){return S.add(B),()=>{S.delete(B)}}function ce(){return m.sessionId}function se(B){return y.get(B)??null}const j={hasEntity:B=>g.has(B),getEditor:()=>p.value,getAssetManager:()=>je,getSessionId:ce,getUserBySessionId:se,subscribeComponent:V,subscribeSingleton:A,registerTickCallback:Y};d.provide(Rn,j),d.provide("containerRef",h);const X=hb();d.provide(F0,X);let he=0,Te=null,Ce=null,je=null;async function ar(){!p.value||!Ce||(p.value.nextTick(B=>{Ks(B),Go(B);for(const ke of S)ke(B);Ce&&Ce.sync(B)}),await p.value.tick(),Te=requestAnimationFrame(ar))}let so=null;d.onMounted(async()=>{var lr,pn;if(!h.value)return;so=()=>{var Ys;(Ys=h.value)==null||Ys.scrollTo(0,0)},h.value.addEventListener("scroll",so);const B=u.store??{},ke={...B};B.websocket&&(ke.websocket={...B.websocket,onVersionMismatch:Ys=>{var io,ul;M.value=!0,(ul=(io=B.websocket)==null?void 0:io.onVersionMismatch)==null||ul.call(io,Ys)},onConnectivityChange:Ys=>{var io,ul;_.value=Ys,(ul=(io=B.websocket)==null?void 0:io.onConnectivityChange)==null||ul.call(io,Ys)}}),Ce=new nm(ke);const U=[],le=u.pluginOptions;(le==null?void 0:le.controls)!==!1&&U.push(W6((le==null?void 0:le.controls)??{})),(le==null?void 0:le.selection)!==!1&&U.push(dP((le==null?void 0:le.selection)||void 0)),(le==null?void 0:le.eraser)!==!1&&U.push(HO((le==null?void 0:le.eraser)||void 0)),(le==null?void 0:le.pen)!==!1&&U.push(PD()),(le==null?void 0:le.arrows)!==!1&&U.push(sO((le==null?void 0:le.arrows)||void 0)),U.push(gS({store:Ce})),(lr=u.editor)!=null&&lr.plugins&&U.push(...u.editor.plugins);const Q={...u.editor,user:m,plugins:U,controls:u.controls},W=new nN(h.value,Q);await W.initialize(),await Ce.initialize({components:W.components,singletons:W.singletons});const ft=((pn=B.persistence)==null?void 0:pn.documentId)??"default";je=new N6({provider:u.assetProvider??new O6,documentId:ft}),await je.init(),await je.resumePendingUploads(),p.value=W,Te=requestAnimationFrame(ar),I.value=!1,f("ready",W,Ce)}),d.onUnmounted(()=>{var B;Te!==null&&cancelAnimationFrame(Te),je==null||je.close(),Ce==null||Ce.close(),(B=p.value)==null||B.dispose()});function Ks(B){const{events:ke,newIndex:U}=B.eventBuffer.readEvents(he);if(he=U,ke.length===0)return;const{componentsById:le,singletonsById:Q}=He(B);for(const{entityId:W,eventType:ft,componentId:lr}of ke){if(W===Js){if(ft===Le.CHANGED){const pn=Q.get(lr);pn&&F(B,pn)}continue}if(ft===Le.ADDED)g.add(W);else if(ft===Le.REMOVED)g.delete(W),v.delete(W);else if(ft===Le.COMPONENT_ADDED){g.add(W);const pn=le.get(lr);pn&&Z(B,W,pn)}else if(ft===Le.COMPONENT_REMOVED){const pn=le.get(lr);pn&&Z(B,W,pn,!0)}else if(ft===Le.CHANGED){const pn=le.get(lr);pn&&Z(B,W,pn)}}}function Go(B){var le;let ke=!1;for(const Q of n.added(B)){const W=T.snapshot(B,Q),ft=(le=p.value)==null?void 0:le.blockDefs[W.tag],lr=(ft==null?void 0:ft.stratum)??"content";k.set(Q,d.ref({entityId:Q,block:W,stratum:lr,selected:!1,held:null,hovered:!1,edited:!1,opacity:null,connector:null})),ke=!0}for(const Q of n.removed(B))k.delete(Q),ke=!0;for(const Q of n.changed(B)){const W=k.get(Q);if(W){const ft=T.snapshot(B,Q);W.value.block.rank!==ft.rank&&(ke=!0),W.value.block=ft}}let U=!1;for(const Q of c.addedOrChanged(B)){const W=jr.snapshot(B,Q);y.set(W.sessionId,W),U=!0}for(const Q of c.removed(B)){const W=jr.read(B,Q);y.delete(W.sessionId),U=!0}U&&(w.value=Array.from(y.values()));for(const Q of o.added(B)){const W=k.get(Q);W&&!W.value.selected&&(W.value.selected=!0)}for(const Q of o.removed(B)){const W=k.get(Q);W&&W.value.selected&&(W.value.selected=!1)}for(const Q of s.addedOrChanged(B)){const W=k.get(Q);W&&(W.value.held=Rt.snapshot(B,Q))}for(const Q of s.removed(B)){const W=k.get(Q);W&&W.value.held!==null&&(W.value.held=null)}for(const Q of i.added(B)){const W=k.get(Q);W&&!W.value.hovered&&(W.value.hovered=!0)}for(const Q of i.removed(B)){const W=k.get(Q);W&&W.value.hovered&&(W.value.hovered=!1)}for(const Q of a.added(B)){const W=k.get(Q);W&&!W.value.edited&&(W.value.edited=!0)}for(const Q of a.removed(B)){const W=k.get(Q);W&&W.value.edited&&(W.value.edited=!1)}for(const Q of l.addedOrChanged(B)){const W=k.get(Q);W&&(W.value.opacity=lt.snapshot(B,Q))}for(const Q of l.removed(B)){const W=k.get(Q);W&&W.value.opacity!==null&&(W.value.opacity=null)}for(const Q of r.addedOrChanged(B)){const W=k.get(Q);W&&(W.value.connector=Ye.snapshot(B,Q))}for(const Q of r.removed(B)){const W=k.get(Q);W&&W.value.connector!==null&&(W.value.connector=null)}if(ke){const Q=Array.from(k.values());Q.sort((W,ft)=>W.value.block.rank>ft.value.block.rank?1:-1),E.value=Q}}A(we.name,B=>{B&&(P.value=B)});function zu(B){const ke=B.rotateZ!==0,U=B.flip[0],le=B.flip[1];if(!ke&&!U&&!le)return;const Q=[];return ke&&Q.push(`rotate(${B.rotateZ}rad)`),U&&Q.push("scaleX(-1)"),le&&Q.push("scaleY(-1)"),Q.join(" ")}function Hi(B){const{held:ke}=B;if(!ke||!ke.sessionId||ke.sessionId===m.sessionId)return null;const U=se(ke.sessionId);return(U==null?void 0:U.color)??null}function Xo(B){const{block:ke,stratum:U,opacity:le}=B,Q=Hi(B),W=le!==null?le.value/255:1;return{position:"absolute",left:`${ke.position[0]}px`,top:`${ke.position[1]}px`,width:`${ke.size[0]}px`,height:`${ke.size[1]}px`,zIndex:Ld[U]*1e3,transform:zu(ke),opacity:W,pointerEvents:"none",userSelect:"none","--wov-held-by-color":Q??void 0,transition:W===1?"opacity 0ms 32ms":void 0}}return(B,ke)=>(d.openBlock(),d.createElementBlock("div",{ref_key:"containerRef",ref:h,class:"wov-root",style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"}},[t.background?d.renderSlot(B.$slots,"background",{key:0,background:t.background},()=>[d.createVNode(qb,{background:t.background},null,8,["background"])]):d.createCommentVNode("",!0),d.createElementVNode("div",{class:"wov-canvas",style:d.normalizeStyle({position:"absolute",transformOrigin:"0 0",transform:`scale(${P.value.zoom}) translate(${-P.value.left}px, ${-P.value.top}px)`,"--wov-zoom":P.value.zoom})},[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(E.value,U=>(d.openBlock(),d.createElementBlock("div",{key:U.value.entityId,"data-entity-id":U.value.entityId,style:d.normalizeStyle(Xo(U.value)),"data-selected":U.value.selected||void 0,"data-held-by-other":Hi(U.value)!==null||void 0,"data-hovered":U.value.hovered||void 0,class:"wov-block"},[d.renderSlot(B.$slots,`block:${U.value.block.tag}`,d.mergeProps({ref_for:!0},U.value),()=>[U.value.block.tag==="selection-box"?(d.openBlock(),d.createBlock(H6,d.mergeProps({key:0,ref_for:!0},U.value),null,16)):U.value.block.tag==="transform-box"?(d.openBlock(),d.createBlock(K6,d.mergeProps({key:1,ref_for:!0},U.value),null,16)):U.value.block.tag==="transform-handle"?(d.openBlock(),d.createBlock(G6,d.mergeProps({key:2,ref_for:!0},U.value),null,16)):U.value.block.tag==="arrow-handle"?(d.openBlock(),d.createBlock(W0,d.mergeProps({key:3,ref_for:!0},U.value),null,16)):U.value.block.tag==="arrow-terminal"?(d.openBlock(),d.createBlock(U0,d.mergeProps({key:4,ref_for:!0},U.value),null,16)):U.value.block.tag==="sticky-note"?(d.openBlock(),d.createBlock(X6,d.mergeProps({key:5,ref_for:!0},U.value),null,16)):U.value.block.tag==="eraser"?(d.openBlock(),d.createBlock(pw,d.mergeProps({key:6,ref_for:!0},U.value),null,16)):U.value.block.tag==="pen-stroke"?(d.openBlock(),d.createBlock(xw,d.mergeProps({key:7,ref_for:!0},U.value),null,16)):U.value.block.tag==="arc-arrow"?(d.openBlock(),d.createBlock(j0,d.mergeProps({key:8,ref_for:!0},U.value),null,16)):U.value.block.tag==="elbow-arrow"?(d.openBlock(),d.createBlock(H0,d.mergeProps({key:9,ref_for:!0},U.value),null,16)):U.value.block.tag==="text"?(d.openBlock(),d.createBlock(mb,d.mergeProps({key:10,ref_for:!0},U.value),null,16)):U.value.block.tag==="image"?(d.openBlock(),d.createBlock(mw,d.mergeProps({key:11,ref_for:!0},U.value),null,16)):U.value.block.tag==="shape"?(d.openBlock(),d.createBlock(pb,d.mergeProps({key:12,ref_for:!0},U.value),null,16)):d.createCommentVNode("",!0)])],12,g5))),128))],4),p.value?d.renderSlot(B.$slots,"user-cursors",{key:1,users:w.value,currentSessionId:d.unref(m).sessionId,camera:P.value},()=>[d.createVNode(u5,{users:w.value,"current-session-id":d.unref(m).sessionId,camera:P.value},null,8,["users","current-session-id","camera"])]):d.createCommentVNode("",!0),p.value?(d.openBlock(),d.createBlock(Xb,{key:2},{default:d.withCtx(U=>[d.renderSlot(B.$slots,"floating-menu",d.normalizeProps(d.guardReactiveProps(U)))]),_:3})):d.createCommentVNode("",!0),p.value?d.renderSlot(B.$slots,"user-presence",{key:3,users:w.value},()=>[d.createVNode(dS,{users:w.value},null,8,["users"])]):d.createCommentVNode("",!0),p.value?d.renderSlot(B.$slots,"toolbar",{key:4},()=>[d.createVNode(uS)]):d.createCommentVNode("",!0),p.value?d.renderSlot(B.$slots,"default",{key:5}):d.createCommentVNode("",!0),d.renderSlot(B.$slots,"offline-indicator",{isOnline:_.value},()=>[d.createVNode(f5,{"is-online":_.value},null,8,["is-online"])]),d.renderSlot(B.$slots,"version-mismatch",{versionMismatch:M.value},()=>[d.createVNode(p5,{"version-mismatch":M.value},null,8,["version-mismatch"])]),d.renderSlot(B.$slots,"back-to-content",{},()=>[d.createVNode(m5)]),d.renderSlot(B.$slots,"loading",{isLoading:I.value},()=>[d.createVNode(Qb,{"is-loading":I.value},null,8,["is-loading"])]),p.value?d.renderSlot(B.$slots,"file-drop-zone",{key:6},()=>[d.createVNode(s5)]):d.createCommentVNode("",!0)],512))}});L.ARROW_HEADS=Cf,L.ArcArrow=j0,L.ArcArrowTool=E6,L.ArrowHandle=W0,L.ArrowHead=Kr,L.ArrowHeadButton=lp,L.ArrowTerminal=U0,L.ArrowThicknessButton=$b,L.CURSORS=eS,L.CanvasBackground=qb,L.CanvasComponentDef=qt,L.CanvasSingletonDef=vt,L.CanvasStore=nm,L.ColorButton=Fb,L.ColorPicker=Vb,L.CursorKind=Fs,L.EditableText=mu,L.EditingPlugin=gS,L.ElbowArrow=H0,L.ElbowArrowTool=lS,L.Eraser=pw,L.EraserTool=sS,L.FloatingMenu=Xb,L.FloatingMenuBar=Gb,L.HandTool=nS,L.IconChevronDown=Wn,L.ImageBlock=mw,L.ImageTool=cS,L.LoadingOverlay=Qb,L.MenuButton=Ui,L.MenuDropdown=jn,L.MenuTooltip=cp,L.PenStroke=xw,L.PenStrokeThicknessButton=jb,L.PenTool=iS,L.SHAPES=Ba,L.SelectTool=tS,L.Shape=Nn,L.ShapeBlock=pb,L.ShapeFillColorButton=Wb,L.ShapeKindButton=Ub,L.ShapeStrokeColorButton=Hb,L.ShapeTool=oS,L.StickyNoteTool=rS,L.StrokeKind=Ct,L.Synced=me,L.TextAlignment=Bn,L.TextAlignmentButton=up,L.TextBlock=mb,L.TextBoldButton=dp,L.TextColorButton=yp,L.TextFontFamilyButton=hp,L.TextFontSizeButton=pp,L.TextItalicButton=mp,L.TextTool=aS,L.TextUnderlineButton=gp,L.Toolbar=uS,L.ToolbarButton=Ar,L.User=jr,L.UserPresence=dS,L.WovenCanvas=y5,L.computeCommonComponents=Jb,L.createTooltipContext=hb,L.defineCanvasComponent=Qe,L.defineCanvasSingleton=Ki,L.getArrowHead=xi,L.useComponent=Tt,L.useComponents=Zo,L.useEditorContext=ut,L.useFonts=Kb,L.useQuery=sb,L.useSingleton=jt,L.useTextBatchController=fb,L.useTextEditorController=ol,L.useTextFormatting=_r,L.useTextStretchBehavior=Qh,L.useToolbar=ep,L.useTooltipSingleton=Yo,Object.defineProperty(L,Symbol.toStringTag,{value:"Module"})});