brick-pdf 0.4.1 → 0.4.2
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.
- package/dist/brick-pdf.css +1 -1
- package/dist/brick-pdf.js +788 -787
- package/dist/brick-pdf.umd.cjs +4 -4
- package/package.json +1 -1
package/dist/brick-pdf.umd.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(function(b,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@vueuse/core"),require("sortablejs")):typeof define=="function"&&define.amd?define(["exports","vue","@vueuse/core","sortablejs"],e):(b=typeof globalThis<"u"?globalThis:b||self,e(b.BrickPdf={},b.Vue,b.VueUse,b.Sortable))})(this,(function(b,e,L,A){"use strict";function D(){return{pageSize:"A4",pageOrientation:"portrait",pageMargins:[40,60,40,60],defaultStyle:{font:"NotoSansJP",fontSize:12},styles:{},content:[]}}const z=new Map;function E(t){z.set(t.type,t)}function C(t){return z.get(t)}function H(){return Array.from(z.values())}function de(t){return z.delete(t)}function pe(){return{text:"New Text"}}function me(){return{fontSize:12}}function ue(t){const n={text:t.props.text},o=t.style;return o.fontSize&&(n.fontSize=o.fontSize),o.bold&&(n.bold=o.bold),o.italics&&(n.italics=o.italics),o.color&&(n.color=o.color),o.alignment&&(n.alignment=o.alignment),o.margin&&(n.margin=o.margin),o.font&&(n.font=o.font),o.lineHeight&&(n.lineHeight=o.lineHeight),o.characterSpacing&&(n.characterSpacing=o.characterSpacing),o.decoration&&(n.decoration=o.decoration),o.decorationStyle&&(n.decorationStyle=o.decorationStyle),o.decorationColor&&(n.decorationColor=o.decorationColor),o.background&&(n.background=o.background),o.link&&(n.link=o.link),o.opacity!==void 0&&(n.opacity=o.opacity),n}const fe=e.defineComponent({__name:"TextRenderer",props:{node:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",{class:"brick-el-text",style:e.normalizeStyle({fontSize:(t.node.style.fontSize??12)+"px",fontWeight:t.node.style.bold?"bold":"normal",fontStyle:t.node.style.italics?"italic":"normal",color:t.node.style.color,textAlign:t.node.style.alignment,lineHeight:t.node.style.lineHeight,textDecoration:t.node.style.decoration==="lineThrough"?"line-through":t.node.style.decoration,backgroundColor:t.node.style.background,opacity:t.node.style.opacity})},e.toDisplayString(t.node.props.text),5))}}),_=(t,n)=>{const o=t.__vccOpts||t;for(const[a,c]of n)o[a]=c;return o},ye=_(fe,[["__scopeId","data-v-a7cd1565"]]),ke={class:"brick-text-editor"},ge={type:"text",label:"Text",icon:"T",isContainer:!1,defaultProps:pe,defaultStyle:me,rendererComponent:ye,propertyEditorComponent:e.defineComponent({__name:"TextPropertyEditor",props:{node:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",ke))}}),propertyFields:[{key:"props.text",label:"Text Content",section:"content",type:"textarea",defaultValue:"New Text"},{key:"style.fontSize",label:"Font Size",section:"style",type:"number",min:6,max:72,step:1,defaultValue:12},{key:"style.bold",label:"Bold",section:"style",type:"toggle",defaultValue:!1},{key:"style.italics",label:"Italic",section:"style",type:"toggle",defaultValue:!1},{key:"style.color",label:"Color",section:"style",type:"color",defaultValue:"#000000"},{key:"style.alignment",label:"Alignment",section:"style",type:"select",options:[{label:"Left",value:"left"},{label:"Center",value:"center"},{label:"Right",value:"right"},{label:"Justify",value:"justify"}],defaultValue:"left"},{key:"style.lineHeight",label:"Line Height",section:"style",type:"number",min:.5,max:3,step:.1},{key:"style.background",label:"Background",section:"style",type:"color"},{key:"style.margin",label:"Margin",section:"layout",type:"margin",defaultValue:[0,0,0,0]},{key:"style.decoration",label:"Decoration",section:"advanced",type:"select",options:[{label:"None",value:void 0},{label:"Underline",value:"underline"},{label:"Overline",value:"overline"},{label:"Line Through",value:"lineThrough"}]},{key:"style.link",label:"Link URL",section:"advanced",type:"text"},{key:"style.opacity",label:"Opacity",section:"advanced",type:"slider",min:0,max:1,step:.1,defaultValue:1}],toPdfmake:ue};function be(){return{}}function he(){return{}}function _e(t,n){const o={stack:n(t.children)};return t.style.margin&&(o.margin=t.style.margin),t.style.fillColor&&(o.fillColor=t.style.fillColor),o}const Ee=_(e.defineComponent({__name:"StackRenderer",props:{node:{},path:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",{class:"brick-el-stack",style:e.normalizeStyle({backgroundColor:t.node.style.fillColor})},[e.renderSlot(n.$slots,"default",{},void 0,!0)],4))}}),[["__scopeId","data-v-c59e7405"]]),Be={class:"brick-stack-editor"},Se={type:"stack",label:"Stack",icon:"☰",isContainer:!0,acceptsChildTypes:null,defaultProps:be,defaultStyle:he,rendererComponent:Ee,propertyEditorComponent:e.defineComponent({__name:"StackPropertyEditor",props:{node:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",Be))}}),propertyFields:[{key:"style.fillColor",label:"Fill Color",section:"style",type:"color"},{key:"style.margin",label:"Margin",section:"layout",type:"margin",defaultValue:[0,0,0,0]}],toPdfmake:_e};function Ce(){return{columnGap:10}}function Ne(){return{}}function xe(t,n){const o={columns:n(t.children),columnGap:t.props.columnGap??10};return t.style.margin&&(o.margin=t.style.margin),o}const we=_(e.defineComponent({__name:"ColumnsRenderer",props:{node:{},path:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",{class:"brick-el-columns",style:e.normalizeStyle({"--column-gap":(t.node.props.columnGap??10)+"px"})},[e.renderSlot(n.$slots,"default",{},void 0,!0)],4))}}),[["__scopeId","data-v-217dd721"]]),Pe={class:"brick-columns-editor"},Ve={type:"columns",label:"Columns",icon:"▥",isContainer:!0,acceptsChildTypes:null,defaultProps:Ce,defaultStyle:Ne,rendererComponent:we,propertyEditorComponent:e.defineComponent({__name:"ColumnsPropertyEditor",props:{node:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",Pe))}}),propertyFields:[{key:"props.columnGap",label:"Column Gap",section:"layout",type:"number",min:0,max:50,step:1,defaultValue:10},{key:"style.margin",label:"Margin",section:"layout",type:"margin",defaultValue:[0,0,0,0]}],toPdfmake:xe};function $e(){return{headerRows:1,widths:["*","*"],body:[["Header 1","Header 2"],["Cell 1","Cell 2"]],layout:"lightHorizontalLines"}}function Ie(){return{fontSize:12}}function De(t){const n=t.props.body,o={table:{headerRows:t.props.headerRows,widths:t.props.widths,body:n.map(c=>c.map(r=>({text:r})))}},a=t.props.layout;return a&&a!=="none"&&(o.layout=a),t.style.fontSize&&(o.fontSize=t.style.fontSize),t.style.color&&(o.color=t.style.color),t.style.margin&&(o.margin=t.style.margin),o}const ze=_(e.defineComponent({__name:"TableRenderer",props:{node:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["brick-el-table","brick-el-table--"+(t.node.props.layout??"lightHorizontalLines")]),style:e.normalizeStyle({fontSize:(t.node.style.fontSize??12)+"px",color:t.node.style.color})},[e.createElementVNode("table",null,[e.createElementVNode("thead",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.props.body.slice(0,t.node.props.headerRows),(a,c)=>(e.openBlock(),e.createElementBlock("tr",{key:"h"+c},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a,(r,u)=>(e.openBlock(),e.createElementBlock("th",{key:u},e.toDisplayString(r),1))),128))]))),128))]),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.props.body.slice(t.node.props.headerRows),(a,c)=>(e.openBlock(),e.createElementBlock("tr",{key:"b"+c},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a,(r,u)=>(e.openBlock(),e.createElementBlock("td",{key:u},e.toDisplayString(r),1))),128))]))),128))])])],6))}}),[["__scopeId","data-v-b863b05d"]]),j=Symbol("brick-pdf-document-store");function J(t){const n=D();return{pageSize:t.pageSize??n.pageSize,pageOrientation:t.pageOrientation??n.pageOrientation,pageMargins:t.pageMargins??n.pageMargins,defaultStyle:t.defaultStyle??n.defaultStyle,styles:t.styles??n.styles,content:t.content??n.content}}function T(t){t.props=t.props??{},t.style=t.style??{},t.children=t.children??[];for(const n of t.children)T(n);return t}function Re(t){const n=t?J(t):D();for(const s of n.content)T(s);const o=e.reactive(n);function a(s,l){const i=l??o.content;for(let d=0;d<i.length;d++){const f=i[d];if(f){if(f.id===s)return{node:f,parent:i,index:d};if(f.children.length>0){const m=a(s,f.children);if(m)return m}}}return null}function c(s){o.content.splice(0,o.content.length,...s)}function r(){return JSON.parse(JSON.stringify(e.toRaw(o.content)))}function u(s){const l=J(s);for(const i of l.content)T(i);o.pageSize=l.pageSize,o.pageOrientation=l.pageOrientation,o.pageMargins=l.pageMargins,o.defaultStyle=l.defaultStyle,o.styles=l.styles,o.content.splice(0,o.content.length,...l.content)}function p(){return JSON.parse(JSON.stringify(e.toRaw(o)))}return{document:o,findNodeById:a,replaceContent:c,snapshotContent:r,loadDocument:u,exportDocument:p}}function Le(t){e.provide(j,t)}function R(){const t=e.inject(j);if(!t)throw new Error("useDocumentStore() requires a BrickPdf ancestor component");return t}const U=Symbol("brick-pdf-selection");function Te(t){const n=e.ref(null),o=e.computed(()=>n.value?t.findNodeById(n.value)?.node??null:null);function a(r){n.value=r}function c(){n.value=null}return{selectedId:n,selectedNode:o,select:a,deselect:c}}function Me(t){e.provide(U,t)}function N(){const t=e.inject(U);if(!t)throw new Error("useSelection() requires a BrickPdf ancestor component");return t}const W=Symbol("brick-pdf-element-actions");let Fe=0;function q(){return`el-${Date.now()}-${++Fe}`}function Y(t){return{...t,id:q(),props:structuredClone(t.props),style:structuredClone(t.style),children:t.children.map(Y)}}function Oe(t,n){function o(l,i,d){const f=C(l);if(!f)return null;n.record();const m={id:q(),type:l,props:f.defaultProps(),style:f.defaultStyle(),children:[]},y=i?t.findNodeById(i)?.node.children:t.document.content;if(!y)return null;const k=d??y.length;return y.splice(k,0,m),m}function a(l){const i=t.findNodeById(l);i&&(n.record(),i.parent.splice(i.index,1))}function c(l,i,d){const f=t.findNodeById(l);if(!f)return;n.record();const m=f.parent.splice(f.index,1)[0];if(!m)return;const y=i?t.findNodeById(i)?.node.children:t.document.content;y&&y.splice(d,0,m)}function r(l){const i=t.findNodeById(l);if(!i)return null;n.record();const d=Y(i.node);return i.parent.splice(i.index+1,0,d),d}function u(l,i){const d=t.findNodeById(l);d&&(n.record(),Object.assign(d.node.props,i))}function p(l,i){const d=t.findNodeById(l);d&&(n.record(),Object.assign(d.node.style,i))}function s(l,i){const d=t.findNodeById(l);d&&(n.record(),i?d.node.key=i:delete d.node.key)}return{addElement:o,removeElement:a,moveElement:c,duplicateElement:r,updateProps:u,updateStyle:p,updateKey:s}}function Ae(t){e.provide(W,t)}function x(){const t=e.inject(W);if(!t)throw new Error("useElementActions() requires a BrickPdf ancestor component");return t}const K=Symbol("brick-pdf-history"),He=50;function je(t){const n=e.ref([]),o=e.ref([]);let a=0;const c=e.computed(()=>n.value.length>0),r=e.computed(()=>o.value.length>0);function u(){const l=Date.now();if(l-a<100)return;a=l;const i=t.snapshotContent();n.value.push(i),n.value.length>He&&n.value.shift(),o.value=[]}function p(){const l=n.value.pop();l&&(o.value.push(t.snapshotContent()),t.replaceContent(l))}function s(){const l=o.value.pop();l&&(n.value.push(t.snapshotContent()),t.replaceContent(l))}return{canUndo:c,canRedo:r,record:u,undo:p,redo:s}}function Je(t){e.provide(K,t)}function G(){const t=e.inject(K);if(!t)throw new Error("useHistory() requires a BrickPdf ancestor component");return t}const X=Symbol("brick-pdf-drag-drop");function Ue(t,n){const o=e.ref(!1);function a(r){return A.create(r,{group:{name:"brick-elements",pull:"clone",put:!1},sort:!1,animation:150,onStart(){o.value=!0},onEnd(){o.value=!1}})}function c(r,u){return A.create(r,{group:{name:"brick-elements",put:!0},animation:150,fallbackOnBody:!0,swapThreshold:.5,emptyInsertThreshold:5,ghostClass:"brick-sortable-ghost",onStart(){o.value=!0},onAdd(p){const s=p.item,l=s.dataset.elementId,i=s.dataset.elementType,d=f=>{if(!u||!f)return!1;const m=t.findNodeById(u);if(!m)return!1;const y=C(m.node.type);return!!(y?.acceptsChildTypes&&!y.acceptsChildTypes.includes(f))};if(l){if(s.parentNode?.removeChild(s),d(i))return;n.moveElement(l,u,p.newIndex??0);return}i&&(s.parentNode?.removeChild(s),!d(i)&&n.addElement(i,u,p.newIndex))},onEnd(p){if(o.value=!1,p.from===p.to&&p.oldIndex!==void 0&&p.newIndex!==void 0&&p.oldIndex!==p.newIndex&&p.item.dataset.elementId){const s=u?t.findNodeById(u)?.node.children:t.document.content;if(!s)return;const l=s.splice(p.oldIndex,1)[0];l&&s.splice(p.newIndex,0,l)}}})}return{initToolbar:a,initContainer:c,isDragging:o}}function We(t){e.provide(X,t)}function M(){const t=e.inject(X);if(!t)throw new Error("useDragDrop() requires a BrickPdf ancestor component");return t}const Q={regular:"https://cdn.jsdelivr.net/npm/@expo-google-fonts/noto-sans-jp/NotoSansJP_400Regular.ttf",bold:"https://cdn.jsdelivr.net/npm/@expo-google-fonts/noto-sans-jp/NotoSansJP_700Bold.ttf"},w={regular:"NotoSansJP-Regular.ttf",bold:"NotoSansJP-Bold.ttf"},qe="NotoSansJP";function Ye(t){const n=new Uint8Array(t),o=32768;let a="";for(let c=0;c<n.length;c+=o){const r=n.subarray(c,c+o);a+=String.fromCharCode.apply(null,Array.from(r))}return btoa(a)}async function Z(t){const n=await fetch(t);if(!n.ok)throw new Error(`Failed to load font ${t}: HTTP ${n.status}`);const o=await n.arrayBuffer();return Ye(o)}let $=null;function Ke(){return $||($=(async()=>{const[t,n]=await Promise.all([Z(Q.regular),Z(Q.bold)]);return{vfs:{[w.regular]:t,[w.bold]:n},fonts:{[qe]:{normal:w.regular,bold:w.bold,italics:w.regular,bolditalics:w.bold}}}})().catch(t=>{throw $=null,t}),$)}const v=Symbol("brick-pdf-export");function Ge(t){return t.map(ee)}function ee(t){const n=C(t.type);return n?n.toPdfmake(t,Ge):{text:`[Unknown: ${t.type}]`}}function Xe(t){function n(){const r=t.document;return{pageSize:r.pageSize,pageOrientation:r.pageOrientation,pageMargins:r.pageMargins,defaultStyle:JSON.parse(JSON.stringify(e.toRaw(r.defaultStyle))),styles:JSON.parse(JSON.stringify(e.toRaw(r.styles))),content:r.content.map(ee)}}async function o(){const r=await import("pdfmake/build/pdfmake"),u=await import("pdfmake/build/vfs_fonts"),p=r.default||r,s=u.pdfMake?.vfs??u.default??{},l=await Ke();return p.addVirtualFileSystem({...s,...l.vfs}),p.setFonts({Roboto:{normal:"Roboto-Regular.ttf",bold:"Roboto-Medium.ttf",italics:"Roboto-Italic.ttf",bolditalics:"Roboto-MediumItalic.ttf"},...l.fonts}),p}function a(r){const u=n();o().then(p=>{p.createPdf(u).download(r??"document.pdf")})}function c(){const r=n();o().then(u=>{u.createPdf(r).open()})}return{toDocumentDefinition:n,exportPdf:a,openPdf:c}}function Qe(t){e.provide(v,t)}function te(){const t=e.inject(v);if(!t)throw new Error("usePdfExport() requires a BrickPdf ancestor component");return t}const ne=Symbol("brick-pdf-clipboard");let Ze=0;function ve(){return`el-${Date.now()}-${++Ze}`}function oe(t){return{...t,id:ve(),props:structuredClone(t.props),style:structuredClone(t.style),children:t.children.map(oe)}}function et(t,n){const o=e.ref(null),a=e.ref(!1),c=e.ref(null),r=e.ref(!1);function u(l){const i=t.findNodeById(l);i&&(o.value=structuredClone(i.node),a.value=!1,c.value=null,r.value=!0)}function p(l){const i=t.findNodeById(l);i&&(o.value=structuredClone(i.node),a.value=!0,c.value=l,r.value=!0)}function s(l){if(!o.value)return;a.value&&c.value&&(n.removeElement(c.value),a.value=!1,c.value=null);const i=oe(o.value),d=l?t.findNodeById(l)?.node.children:t.document.content;d&&(d.push(i),a.value&&(o.value=null,r.value=!1))}return{hasClipboard:r,copy:u,cut:p,paste:s}}function tt(t){e.provide(ne,t)}function nt(){const t=e.inject(ne);if(!t)throw new Error("useClipboard() requires a BrickPdf ancestor component");return t}const re=Symbol("brick-pdf-resize");function ot(t){const n=e.ref(!1);function o(a,c,r,u){n.value=!0;const p=u.clientX,s=u.clientY,l=r.width,i=r.height;function d(m){const y=m.clientX-p,k=m.clientY-s;let g=l,h=i;c.includes("e")&&(g=l+y),c.includes("w")&&(g=l-y),c.includes("s")&&(h=i+k),c.includes("n")&&(h=i-k),g=Math.max(20,g),h=Math.max(20,h),t.updateStyle(a,{width:Math.round(g),height:Math.round(h)})}function f(){n.value=!1,document.removeEventListener("pointermove",d),document.removeEventListener("pointerup",f)}document.addEventListener("pointermove",d),document.addEventListener("pointerup",f)}return{isResizing:n,startResize:o}}function rt(t){e.provide(re,t)}function lt(){const t=e.inject(re);if(!t)throw new Error("useResize() requires a BrickPdf ancestor component");return t}const it={class:"brick-table-editor"},at={class:"brick-table-editor__grid"},ct=["onClick"],st={class:"brick-table-editor__row-header"},dt=["onClick"],pt=["value","onInput"],mt={type:"table",label:"Table",icon:"▦",isContainer:!1,defaultProps:$e,defaultStyle:Ie,rendererComponent:ze,propertyEditorComponent:_(e.defineComponent({__name:"TablePropertyEditor",props:{node:{}},setup(t){const n=t,o=x();function a(){return n.node.props.body??[]}function c(){return n.node.props.widths??[]}function r(i,d,f){const m=a().map(y=>[...y]);m[i][d]=f,o.updateProps(n.node.id,{body:m})}function u(){const i=a().map(f=>[...f]),d=i[0]?.length??2;i.push(Array(d).fill("")),o.updateProps(n.node.id,{body:i})}function p(i){const d=a().map(m=>[...m]);if(d.length<=1)return;d.splice(i,1),n.node.props.headerRows>d.length?o.updateProps(n.node.id,{body:d,headerRows:d.length}):o.updateProps(n.node.id,{body:d})}function s(){const i=a().map(f=>[...f,""]),d=[...c(),"*"];o.updateProps(n.node.id,{body:i,widths:d})}function l(i){const d=a().map(m=>{const y=[...m];return y.splice(i,1),y});if((d[0]?.length??0)<1)return;const f=[...c()];f.splice(i,1),o.updateProps(n.node.id,{body:d,widths:f})}return(i,d)=>(e.openBlock(),e.createElementBlock("div",it,[e.createElementVNode("div",{class:"brick-table-editor__actions"},[e.createElementVNode("button",{class:"brick-table-editor__btn",onClick:u},"+ Row"),e.createElementVNode("button",{class:"brick-table-editor__btn",onClick:s},"+ Column")]),e.createElementVNode("div",at,[e.createElementVNode("table",null,[e.createElementVNode("thead",null,[e.createElementVNode("tr",null,[d[0]||(d[0]=e.createElementVNode("th",{class:"brick-table-editor__corner"},null,-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a()[0]??[],(f,m)=>(e.openBlock(),e.createElementBlock("th",{key:m,class:"brick-table-editor__col-header"},[e.createTextVNode(" Col "+e.toDisplayString(m+1)+" ",1),(a()[0]?.length??0)>1?(e.openBlock(),e.createElementBlock("button",{key:0,class:"brick-table-editor__remove-btn",title:"Remove column",onClick:y=>l(m)},"x",8,ct)):e.createCommentVNode("",!0)]))),128))])]),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a(),(f,m)=>(e.openBlock(),e.createElementBlock("tr",{key:m},[e.createElementVNode("td",st,[e.createTextVNode(e.toDisplayString(m+1)+" ",1),a().length>1?(e.openBlock(),e.createElementBlock("button",{key:0,class:"brick-table-editor__remove-btn",title:"Remove row",onClick:y=>p(m)},"x",8,dt)):e.createCommentVNode("",!0)]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f,(y,k)=>(e.openBlock(),e.createElementBlock("td",{key:k},[e.createElementVNode("input",{class:"brick-table-editor__cell",type:"text",value:y,onInput:g=>r(m,k,g.target.value)},null,40,pt)]))),128))]))),128))])])])]))}}),[["__scopeId","data-v-4895020c"]]),propertyFields:[{key:"props.headerRows",label:"Header Rows",section:"content",type:"number",min:0,max:10,step:1,defaultValue:1},{key:"props.layout",label:"Border Style",section:"style",type:"select",options:[{label:"Light Lines",value:"lightHorizontalLines"},{label:"Grid",value:"grid"},{label:"Header Only",value:"headerLineOnly"},{label:"No Borders",value:"noBorders"},{label:"None",value:"none"}],defaultValue:"lightHorizontalLines"},{key:"style.fontSize",label:"Font Size",section:"style",type:"number",min:6,max:72,step:1,defaultValue:12},{key:"style.color",label:"Text Color",section:"style",type:"color",defaultValue:"#000000"},{key:"style.margin",label:"Margin",section:"layout",type:"margin",defaultValue:[0,0,0,0]}],toPdfmake:De};function ut(){return{src:"",width:200,height:150,fit:null}}function ft(){return{}}function yt(t){const n={image:t.props.src};return t.props.width&&(n.width=t.props.width),t.props.height&&(n.height=t.props.height),t.props.fit&&(n.fit=t.props.fit),t.style.margin&&(n.margin=t.style.margin),t.style.alignment&&(n.alignment=t.style.alignment),t.style.opacity!==void 0&&(n.opacity=t.style.opacity),n}const kt={class:"brick-el-image"},gt=["src"],bt={key:1,class:"brick-el-image__placeholder"},ht=_(e.defineComponent({__name:"ImageRenderer",props:{node:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",kt,[t.node.props.src?(e.openBlock(),e.createElementBlock("img",{key:0,src:t.node.props.src,style:e.normalizeStyle({width:t.node.props.width+"px",height:t.node.props.height+"px",objectFit:"contain",opacity:t.node.style.opacity})},null,12,gt)):(e.openBlock(),e.createElementBlock("div",bt," No image selected "))]))}}),[["__scopeId","data-v-38184258"]]),_t={class:"brick-image-editor"},Et={type:"image",label:"Image",icon:"🖼",isContainer:!1,defaultProps:ut,defaultStyle:ft,rendererComponent:ht,propertyEditorComponent:e.defineComponent({__name:"ImagePropertyEditor",props:{node:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",_t))}}),propertyFields:[{key:"props.src",label:"Image (Base64)",section:"content",type:"file"},{key:"props.width",label:"Width",section:"layout",type:"number",min:10,max:1e3,step:10,defaultValue:200},{key:"props.height",label:"Height",section:"layout",type:"number",min:10,max:1e3,step:10,defaultValue:150},{key:"style.alignment",label:"Alignment",section:"style",type:"select",options:[{label:"Left",value:"left"},{label:"Center",value:"center"},{label:"Right",value:"right"}]},{key:"style.margin",label:"Margin",section:"layout",type:"margin",defaultValue:[0,0,0,0]},{key:"style.opacity",label:"Opacity",section:"advanced",type:"slider",min:0,max:1,step:.1,defaultValue:1}],toPdfmake:yt};function Bt(){return{ordered:!1,items:["Item 1","Item 2","Item 3"]}}function St(){return{fontSize:12}}function Ct(t){const n=t.props.items,a=t.props.ordered?{ol:n}:{ul:n};return t.style.fontSize&&(a.fontSize=t.style.fontSize),t.style.color&&(a.color=t.style.color),t.style.margin&&(a.margin=t.style.margin),a}const Nt=_(e.defineComponent({__name:"ListRenderer",props:{node:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",{class:"brick-el-list",style:e.normalizeStyle({fontSize:(t.node.style.fontSize??12)+"px",color:t.node.style.color})},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.node.props.ordered?"ol":"ul"),null,{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.props.items,(a,c)=>(e.openBlock(),e.createElementBlock("li",{key:c},e.toDisplayString(a),1))),128))]),_:1}))],4))}}),[["__scopeId","data-v-8107f859"]]),xt={class:"brick-list-editor"},wt={type:"list",label:"List",icon:"☰",isContainer:!1,defaultProps:Bt,defaultStyle:St,rendererComponent:Nt,propertyEditorComponent:e.defineComponent({__name:"ListPropertyEditor",props:{node:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",xt))}}),propertyFields:[{key:"props.ordered",label:"Ordered",section:"content",type:"toggle",defaultValue:!1},{key:"props.items",label:"Items",section:"content",type:"textarea",defaultValue:`Item 1
|
|
1
|
+
(function(b,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@vueuse/core"),require("sortablejs")):typeof define=="function"&&define.amd?define(["exports","vue","@vueuse/core","sortablejs"],e):(b=typeof globalThis<"u"?globalThis:b||self,e(b.BrickPdf={},b.Vue,b.VueUse,b.Sortable))})(this,(function(b,e,O,J){"use strict";function L(){return{pageSize:"A4",pageOrientation:"portrait",pageMargins:[40,60,40,60],defaultStyle:{font:"NotoSansJP",fontSize:12},styles:{},content:[]}}const T=new Map;function B(t){T.set(t.type,t)}function x(t){return T.get(t)}function U(){return Array.from(T.values())}function me(t){return T.delete(t)}function fe(){return{text:"New Text"}}function ye(){return{fontSize:12}}function ke(t){const n={text:t.props.text},o=t.style;return o.fontSize&&(n.fontSize=o.fontSize),o.bold&&(n.bold=o.bold),o.italics&&(n.italics=o.italics),o.color&&(n.color=o.color),o.alignment&&(n.alignment=o.alignment),o.margin&&(n.margin=o.margin),o.font&&(n.font=o.font),o.lineHeight&&(n.lineHeight=o.lineHeight),o.characterSpacing&&(n.characterSpacing=o.characterSpacing),o.decoration&&(n.decoration=o.decoration),o.decorationStyle&&(n.decorationStyle=o.decorationStyle),o.decorationColor&&(n.decorationColor=o.decorationColor),o.background&&(n.background=o.background),o.link&&(n.link=o.link),o.opacity!==void 0&&(n.opacity=o.opacity),n}const ge=e.defineComponent({__name:"TextRenderer",props:{node:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",{class:"brick-el-text",style:e.normalizeStyle({fontSize:(t.node.style.fontSize??12)+"px",fontWeight:t.node.style.bold?"bold":"normal",fontStyle:t.node.style.italics?"italic":"normal",color:t.node.style.color,textAlign:t.node.style.alignment,lineHeight:t.node.style.lineHeight,textDecoration:t.node.style.decoration==="lineThrough"?"line-through":t.node.style.decoration,backgroundColor:t.node.style.background,opacity:t.node.style.opacity})},e.toDisplayString(t.node.props.text),5))}}),_=(t,n)=>{const o=t.__vccOpts||t;for(const[a,c]of n)o[a]=c;return o},be=_(ge,[["__scopeId","data-v-a7cd1565"]]),_e={class:"brick-text-editor"},he={type:"text",label:"Text",icon:"T",isContainer:!1,defaultProps:fe,defaultStyle:ye,rendererComponent:be,propertyEditorComponent:e.defineComponent({__name:"TextPropertyEditor",props:{node:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",_e))}}),propertyFields:[{key:"props.text",label:"Text Content",section:"content",type:"textarea",defaultValue:"New Text"},{key:"style.fontSize",label:"Font Size",section:"style",type:"number",min:6,max:72,step:1,defaultValue:12},{key:"style.bold",label:"Bold",section:"style",type:"toggle",defaultValue:!1},{key:"style.italics",label:"Italic",section:"style",type:"toggle",defaultValue:!1},{key:"style.color",label:"Color",section:"style",type:"color",defaultValue:"#000000"},{key:"style.alignment",label:"Alignment",section:"style",type:"select",options:[{label:"Left",value:"left"},{label:"Center",value:"center"},{label:"Right",value:"right"},{label:"Justify",value:"justify"}],defaultValue:"left"},{key:"style.lineHeight",label:"Line Height",section:"style",type:"number",min:.5,max:3,step:.1},{key:"style.background",label:"Background",section:"style",type:"color"},{key:"style.margin",label:"Margin",section:"layout",type:"margin",defaultValue:[0,0,0,0]},{key:"style.decoration",label:"Decoration",section:"advanced",type:"select",options:[{label:"None",value:void 0},{label:"Underline",value:"underline"},{label:"Overline",value:"overline"},{label:"Line Through",value:"lineThrough"}]},{key:"style.link",label:"Link URL",section:"advanced",type:"text"},{key:"style.opacity",label:"Opacity",section:"advanced",type:"slider",min:0,max:1,step:.1,defaultValue:1}],toPdfmake:ke};function Ee(){return{}}function Be(){return{}}function Se(t,n){const o={stack:n(t.children)};return t.style.margin&&(o.margin=t.style.margin),t.style.fillColor&&(o.fillColor=t.style.fillColor),o}const Ce=_(e.defineComponent({__name:"StackRenderer",props:{node:{},path:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",{class:"brick-el-stack",style:e.normalizeStyle({backgroundColor:t.node.style.fillColor})},[e.renderSlot(n.$slots,"default",{},void 0,!0)],4))}}),[["__scopeId","data-v-c59e7405"]]),Ne={class:"brick-stack-editor"},xe={type:"stack",label:"Stack",icon:"☰",isContainer:!0,acceptsChildTypes:null,defaultProps:Ee,defaultStyle:Be,rendererComponent:Ce,propertyEditorComponent:e.defineComponent({__name:"StackPropertyEditor",props:{node:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",Ne))}}),propertyFields:[{key:"style.fillColor",label:"Fill Color",section:"style",type:"color"},{key:"style.margin",label:"Margin",section:"layout",type:"margin",defaultValue:[0,0,0,0]}],toPdfmake:Se};function we(){return{columnGap:10}}function Pe(){return{}}function Ve(t,n){const o={columns:n(t.children),columnGap:t.props.columnGap??10};return t.style.margin&&(o.margin=t.style.margin),o}const $e=_(e.defineComponent({__name:"ColumnsRenderer",props:{node:{},path:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",{class:"brick-el-columns",style:e.normalizeStyle({"--column-gap":(t.node.props.columnGap??10)+"px"})},[e.renderSlot(n.$slots,"default",{},void 0,!0)],4))}}),[["__scopeId","data-v-217dd721"]]),Ie={class:"brick-columns-editor"},De={type:"columns",label:"Columns",icon:"▥",isContainer:!0,acceptsChildTypes:null,defaultProps:we,defaultStyle:Pe,rendererComponent:$e,propertyEditorComponent:e.defineComponent({__name:"ColumnsPropertyEditor",props:{node:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",Ie))}}),propertyFields:[{key:"props.columnGap",label:"Column Gap",section:"layout",type:"number",min:0,max:50,step:1,defaultValue:10},{key:"style.margin",label:"Margin",section:"layout",type:"margin",defaultValue:[0,0,0,0]}],toPdfmake:Ve};function Re(){return{headerRows:1,widths:["*","*"],body:[["Header 1","Header 2"],["Cell 1","Cell 2"]],layout:"lightHorizontalLines"}}function ze(){return{fontSize:12}}function Le(t){const n=t.props.body,o={table:{headerRows:t.props.headerRows,widths:t.props.widths,body:n.map(c=>c.map(i=>({text:i})))}},a=t.props.layout;return a&&a!=="none"&&(o.layout=a),t.style.fontSize&&(o.fontSize=t.style.fontSize),t.style.color&&(o.color=t.style.color),t.style.margin&&(o.margin=t.style.margin),o}const Te=_(e.defineComponent({__name:"TableRenderer",props:{node:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["brick-el-table","brick-el-table--"+(t.node.props.layout??"lightHorizontalLines")]),style:e.normalizeStyle({fontSize:(t.node.style.fontSize??12)+"px",color:t.node.style.color})},[e.createElementVNode("table",null,[e.createElementVNode("thead",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.props.body.slice(0,t.node.props.headerRows),(a,c)=>(e.openBlock(),e.createElementBlock("tr",{key:"h"+c},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a,(i,s)=>(e.openBlock(),e.createElementBlock("th",{key:s},e.toDisplayString(i),1))),128))]))),128))]),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.props.body.slice(t.node.props.headerRows),(a,c)=>(e.openBlock(),e.createElementBlock("tr",{key:"b"+c},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a,(i,s)=>(e.openBlock(),e.createElementBlock("td",{key:s},e.toDisplayString(i),1))),128))]))),128))])])],6))}}),[["__scopeId","data-v-b863b05d"]]),W=Symbol("brick-pdf-document-store");function q(t){const n=L();return{pageSize:t.pageSize??n.pageSize,pageOrientation:t.pageOrientation??n.pageOrientation,pageMargins:t.pageMargins??n.pageMargins,defaultStyle:t.defaultStyle??n.defaultStyle,styles:t.styles??n.styles,content:t.content??n.content}}function A(t){t.props=t.props??{},t.style=t.style??{},t.children=t.children??[];for(const n of t.children)A(n);return t}function Me(t){const n=t?q(t):L();for(const d of n.content)A(d);const o=e.reactive(n);function a(d,l){const r=l??o.content;for(let p=0;p<r.length;p++){const f=r[p];if(f){if(f.id===d)return{node:f,parent:r,index:p};if(f.children.length>0){const m=a(d,f.children);if(m)return m}}}return null}function c(d){o.content.splice(0,o.content.length,...d)}function i(){return JSON.parse(JSON.stringify(e.toRaw(o.content)))}function s(d){const l=q(d);for(const r of l.content)A(r);o.pageSize=l.pageSize,o.pageOrientation=l.pageOrientation,o.pageMargins=l.pageMargins,o.defaultStyle=l.defaultStyle,o.styles=l.styles,o.content.splice(0,o.content.length,...l.content)}function u(){return JSON.parse(JSON.stringify(e.toRaw(o)))}return{document:o,findNodeById:a,replaceContent:c,snapshotContent:i,loadDocument:s,exportDocument:u}}function Fe(t){e.provide(W,t)}function M(){const t=e.inject(W);if(!t)throw new Error("useDocumentStore() requires a BrickPdf ancestor component");return t}const Y=Symbol("brick-pdf-selection");function Oe(t){const n=e.ref(null),o=e.computed(()=>n.value?t.findNodeById(n.value)?.node??null:null);function a(i){n.value=i}function c(){n.value=null}return{selectedId:n,selectedNode:o,select:a,deselect:c}}function Ae(t){e.provide(Y,t)}function w(){const t=e.inject(Y);if(!t)throw new Error("useSelection() requires a BrickPdf ancestor component");return t}const K=Symbol("brick-pdf-element-actions");let He=0;function G(){return`el-${Date.now()}-${++He}`}function X(t){return{...t,id:G(),props:structuredClone(t.props),style:structuredClone(t.style),children:t.children.map(X)}}function je(t,n){function o(l,r,p){const f=x(l);if(!f)return null;n.record();const m={id:G(),type:l,props:f.defaultProps(),style:f.defaultStyle(),children:[]},k=r?t.findNodeById(r)?.node.children:t.document.content;if(!k)return null;const g=p??k.length;return k.splice(g,0,m),m}function a(l){const r=t.findNodeById(l);r&&(n.record(),r.parent.splice(r.index,1))}function c(l,r,p){const f=t.findNodeById(l);if(!f)return;n.record();const m=f.parent.splice(f.index,1)[0];if(!m)return;const k=r?t.findNodeById(r)?.node.children:t.document.content;k&&k.splice(p,0,m)}function i(l){const r=t.findNodeById(l);if(!r)return null;n.record();const p=X(r.node);return r.parent.splice(r.index+1,0,p),p}function s(l,r){const p=t.findNodeById(l);p&&(n.record(),Object.assign(p.node.props,r))}function u(l,r){const p=t.findNodeById(l);p&&(n.record(),Object.assign(p.node.style,r))}function d(l,r){const p=t.findNodeById(l);p&&(n.record(),r?p.node.key=r:delete p.node.key)}return{addElement:o,removeElement:a,moveElement:c,duplicateElement:i,updateProps:s,updateStyle:u,updateKey:d}}function Je(t){e.provide(K,t)}function P(){const t=e.inject(K);if(!t)throw new Error("useElementActions() requires a BrickPdf ancestor component");return t}const Q=Symbol("brick-pdf-history"),Ue=50;function We(t){const n=e.ref([]),o=e.ref([]);let a=0;const c=e.computed(()=>n.value.length>0),i=e.computed(()=>o.value.length>0);function s(){const l=Date.now();if(l-a<100)return;a=l;const r=t.snapshotContent();n.value.push(r),n.value.length>Ue&&n.value.shift(),o.value=[]}function u(){const l=n.value.pop();l&&(o.value.push(t.snapshotContent()),t.replaceContent(l))}function d(){const l=o.value.pop();l&&(n.value.push(t.snapshotContent()),t.replaceContent(l))}return{canUndo:c,canRedo:i,record:s,undo:u,redo:d}}function qe(t){e.provide(Q,t)}function Z(){const t=e.inject(Q);if(!t)throw new Error("useHistory() requires a BrickPdf ancestor component");return t}const v=Symbol("brick-pdf-drag-drop");function Ye(t,n){const o=e.ref(!1);function a(i){return J.create(i,{group:{name:"brick-elements",pull:"clone",put:!1},sort:!1,animation:150,onStart(){o.value=!0},onEnd(){o.value=!1}})}function c(i,s){return J.create(i,{group:{name:"brick-elements",put:!0},animation:150,fallbackOnBody:!0,swapThreshold:.5,emptyInsertThreshold:5,ghostClass:"brick-sortable-ghost",onStart(){o.value=!0},onAdd(u){const d=u.item,l=d.dataset.elementId,r=d.dataset.elementType,p=f=>{if(!s||!f)return!1;const m=t.findNodeById(s);if(!m)return!1;const k=x(m.node.type);return!!(k?.acceptsChildTypes&&!k.acceptsChildTypes.includes(f))};if(l){if(d.parentNode?.removeChild(d),p(r))return;n.moveElement(l,s,u.newIndex??0);return}r&&(d.parentNode?.removeChild(d),!p(r)&&n.addElement(r,s,u.newIndex))},onEnd(u){if(o.value=!1,u.from===u.to&&u.oldIndex!==void 0&&u.newIndex!==void 0&&u.oldIndex!==u.newIndex&&u.item.dataset.elementId){const d=s?t.findNodeById(s)?.node.children:t.document.content;if(!d)return;const l=d.splice(u.oldIndex,1)[0];l&&d.splice(u.newIndex,0,l)}}})}return{initToolbar:a,initContainer:c,isDragging:o}}function Ke(t){e.provide(v,t)}function F(){const t=e.inject(v);if(!t)throw new Error("useDragDrop() requires a BrickPdf ancestor component");return t}const ee={regular:"https://cdn.jsdelivr.net/npm/@expo-google-fonts/noto-sans-jp/NotoSansJP_400Regular.ttf",bold:"https://cdn.jsdelivr.net/npm/@expo-google-fonts/noto-sans-jp/NotoSansJP_700Bold.ttf"},V={regular:"NotoSansJP-Regular.ttf",bold:"NotoSansJP-Bold.ttf"},Ge="NotoSansJP";function Xe(t){const n=new Uint8Array(t),o=32768;let a="";for(let c=0;c<n.length;c+=o){const i=n.subarray(c,c+o);a+=String.fromCharCode.apply(null,Array.from(i))}return btoa(a)}async function te(t){const n=await fetch(t);if(!n.ok)throw new Error(`Failed to load font ${t}: HTTP ${n.status}`);const o=await n.arrayBuffer();return Xe(o)}let R=null;function Qe(){return R||(R=(async()=>{const[t,n]=await Promise.all([te(ee.regular),te(ee.bold)]);return{vfs:{[V.regular]:t,[V.bold]:n},fonts:{[Ge]:{normal:V.regular,bold:V.bold,italics:V.regular,bolditalics:V.bold}}}})().catch(t=>{throw R=null,t}),R)}const ne=Symbol("brick-pdf-export");function Ze(t){return t.map(oe)}function oe(t){const n=x(t.type);return n?n.toPdfmake(t,Ze):{text:`[Unknown: ${t.type}]`}}function ve(t){function n(){const i=t.document;return{pageSize:i.pageSize,pageOrientation:i.pageOrientation,pageMargins:i.pageMargins,defaultStyle:JSON.parse(JSON.stringify(e.toRaw(i.defaultStyle))),styles:JSON.parse(JSON.stringify(e.toRaw(i.styles))),content:i.content.map(oe)}}async function o(){const i=await import("pdfmake/build/pdfmake"),s=await import("pdfmake/build/vfs_fonts"),u=i.default||i,d=s.pdfMake?.vfs??s.default??{},l=await Qe();return u.addVirtualFileSystem({...d,...l.vfs}),u.setFonts({Roboto:{normal:"Roboto-Regular.ttf",bold:"Roboto-Medium.ttf",italics:"Roboto-Italic.ttf",bolditalics:"Roboto-MediumItalic.ttf"},...l.fonts}),u}function a(i){const s=n();o().then(u=>{u.createPdf(s).download(i??"document.pdf")})}function c(){const i=n();o().then(s=>{s.createPdf(i).open()})}return{toDocumentDefinition:n,exportPdf:a,openPdf:c}}function et(t){e.provide(ne,t)}function re(){const t=e.inject(ne);if(!t)throw new Error("usePdfExport() requires a BrickPdf ancestor component");return t}const le=Symbol("brick-pdf-clipboard");let tt=0;function nt(){return`el-${Date.now()}-${++tt}`}function ie(t){return{...t,id:nt(),props:structuredClone(t.props),style:structuredClone(t.style),children:t.children.map(ie)}}function ot(t,n){const o=e.ref(null),a=e.ref(!1),c=e.ref(null),i=e.ref(!1);function s(l){const r=t.findNodeById(l);r&&(o.value=structuredClone(r.node),a.value=!1,c.value=null,i.value=!0)}function u(l){const r=t.findNodeById(l);r&&(o.value=structuredClone(r.node),a.value=!0,c.value=l,i.value=!0)}function d(l){if(!o.value)return;a.value&&c.value&&(n.removeElement(c.value),a.value=!1,c.value=null);const r=ie(o.value),p=l?t.findNodeById(l)?.node.children:t.document.content;p&&(p.push(r),a.value&&(o.value=null,i.value=!1))}return{hasClipboard:i,copy:s,cut:u,paste:d}}function rt(t){e.provide(le,t)}function lt(){const t=e.inject(le);if(!t)throw new Error("useClipboard() requires a BrickPdf ancestor component");return t}const ae=Symbol("brick-pdf-resize");function it(t){const n=e.ref(!1);function o(a,c,i,s){n.value=!0;const u=s.clientX,d=s.clientY,l=i.width,r=i.height;function p(m){const k=m.clientX-u,g=m.clientY-d;let y=l,h=r;c.includes("e")&&(y=l+k),c.includes("w")&&(y=l-k),c.includes("s")&&(h=r+g),c.includes("n")&&(h=r-g),y=Math.max(20,y),h=Math.max(20,h),t.updateStyle(a,{width:Math.round(y),height:Math.round(h)})}function f(){n.value=!1,document.removeEventListener("pointermove",p),document.removeEventListener("pointerup",f)}document.addEventListener("pointermove",p),document.addEventListener("pointerup",f)}return{isResizing:n,startResize:o}}function at(t){e.provide(ae,t)}function ct(){const t=e.inject(ae);if(!t)throw new Error("useResize() requires a BrickPdf ancestor component");return t}const st={class:"brick-table-editor"},dt={class:"brick-table-editor__grid"},pt=["onClick"],ut={class:"brick-table-editor__row-header"},mt=["onClick"],ft=["value","onInput"],yt={type:"table",label:"Table",icon:"▦",isContainer:!1,defaultProps:Re,defaultStyle:ze,rendererComponent:Te,propertyEditorComponent:_(e.defineComponent({__name:"TablePropertyEditor",props:{node:{}},setup(t){const n=t,o=P();function a(){return n.node.props.body??[]}function c(){return n.node.props.widths??[]}function i(r,p,f){const m=a().map(k=>[...k]);m[r][p]=f,o.updateProps(n.node.id,{body:m})}function s(){const r=a().map(f=>[...f]),p=r[0]?.length??2;r.push(Array(p).fill("")),o.updateProps(n.node.id,{body:r})}function u(r){const p=a().map(m=>[...m]);if(p.length<=1)return;p.splice(r,1),n.node.props.headerRows>p.length?o.updateProps(n.node.id,{body:p,headerRows:p.length}):o.updateProps(n.node.id,{body:p})}function d(){const r=a().map(f=>[...f,""]),p=[...c(),"*"];o.updateProps(n.node.id,{body:r,widths:p})}function l(r){const p=a().map(m=>{const k=[...m];return k.splice(r,1),k});if((p[0]?.length??0)<1)return;const f=[...c()];f.splice(r,1),o.updateProps(n.node.id,{body:p,widths:f})}return(r,p)=>(e.openBlock(),e.createElementBlock("div",st,[e.createElementVNode("div",{class:"brick-table-editor__actions"},[e.createElementVNode("button",{class:"brick-table-editor__btn",onClick:s},"+ Row"),e.createElementVNode("button",{class:"brick-table-editor__btn",onClick:d},"+ Column")]),e.createElementVNode("div",dt,[e.createElementVNode("table",null,[e.createElementVNode("thead",null,[e.createElementVNode("tr",null,[p[0]||(p[0]=e.createElementVNode("th",{class:"brick-table-editor__corner"},null,-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a()[0]??[],(f,m)=>(e.openBlock(),e.createElementBlock("th",{key:m,class:"brick-table-editor__col-header"},[e.createTextVNode(" Col "+e.toDisplayString(m+1)+" ",1),(a()[0]?.length??0)>1?(e.openBlock(),e.createElementBlock("button",{key:0,class:"brick-table-editor__remove-btn",title:"Remove column",onClick:k=>l(m)},"x",8,pt)):e.createCommentVNode("",!0)]))),128))])]),e.createElementVNode("tbody",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a(),(f,m)=>(e.openBlock(),e.createElementBlock("tr",{key:m},[e.createElementVNode("td",ut,[e.createTextVNode(e.toDisplayString(m+1)+" ",1),a().length>1?(e.openBlock(),e.createElementBlock("button",{key:0,class:"brick-table-editor__remove-btn",title:"Remove row",onClick:k=>u(m)},"x",8,mt)):e.createCommentVNode("",!0)]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f,(k,g)=>(e.openBlock(),e.createElementBlock("td",{key:g},[e.createElementVNode("input",{class:"brick-table-editor__cell",type:"text",value:k,onInput:y=>i(m,g,y.target.value)},null,40,ft)]))),128))]))),128))])])])]))}}),[["__scopeId","data-v-4895020c"]]),propertyFields:[{key:"props.headerRows",label:"Header Rows",section:"content",type:"number",min:0,max:10,step:1,defaultValue:1},{key:"props.layout",label:"Border Style",section:"style",type:"select",options:[{label:"Light Lines",value:"lightHorizontalLines"},{label:"Grid",value:"grid"},{label:"Header Only",value:"headerLineOnly"},{label:"No Borders",value:"noBorders"},{label:"None",value:"none"}],defaultValue:"lightHorizontalLines"},{key:"style.fontSize",label:"Font Size",section:"style",type:"number",min:6,max:72,step:1,defaultValue:12},{key:"style.color",label:"Text Color",section:"style",type:"color",defaultValue:"#000000"},{key:"style.margin",label:"Margin",section:"layout",type:"margin",defaultValue:[0,0,0,0]}],toPdfmake:Le};function kt(){return{src:"",width:200,height:150,fit:null}}function gt(){return{}}function bt(t){const n={image:t.props.src};return t.props.width&&(n.width=t.props.width),t.props.height&&(n.height=t.props.height),t.props.fit&&(n.fit=t.props.fit),t.style.margin&&(n.margin=t.style.margin),t.style.alignment&&(n.alignment=t.style.alignment),t.style.opacity!==void 0&&(n.opacity=t.style.opacity),n}const _t={class:"brick-el-image"},ht=["src"],Et={key:1,class:"brick-el-image__placeholder"},Bt=_(e.defineComponent({__name:"ImageRenderer",props:{node:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",_t,[t.node.props.src?(e.openBlock(),e.createElementBlock("img",{key:0,src:t.node.props.src,style:e.normalizeStyle({width:t.node.props.width+"px",height:t.node.props.height+"px",objectFit:"contain",opacity:t.node.style.opacity})},null,12,ht)):(e.openBlock(),e.createElementBlock("div",Et," No image selected "))]))}}),[["__scopeId","data-v-38184258"]]),St={class:"brick-image-editor"},Ct={type:"image",label:"Image",icon:"🖼",isContainer:!1,defaultProps:kt,defaultStyle:gt,rendererComponent:Bt,propertyEditorComponent:e.defineComponent({__name:"ImagePropertyEditor",props:{node:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",St))}}),propertyFields:[{key:"props.src",label:"Image (Base64)",section:"content",type:"file"},{key:"props.width",label:"Width",section:"layout",type:"number",min:10,max:1e3,step:10,defaultValue:200},{key:"props.height",label:"Height",section:"layout",type:"number",min:10,max:1e3,step:10,defaultValue:150},{key:"style.alignment",label:"Alignment",section:"style",type:"select",options:[{label:"Left",value:"left"},{label:"Center",value:"center"},{label:"Right",value:"right"}]},{key:"style.margin",label:"Margin",section:"layout",type:"margin",defaultValue:[0,0,0,0]},{key:"style.opacity",label:"Opacity",section:"advanced",type:"slider",min:0,max:1,step:.1,defaultValue:1}],toPdfmake:bt};function Nt(){return{ordered:!1,items:["Item 1","Item 2","Item 3"]}}function xt(){return{fontSize:12}}function wt(t){const n=t.props.items,a=t.props.ordered?{ol:n}:{ul:n};return t.style.fontSize&&(a.fontSize=t.style.fontSize),t.style.color&&(a.color=t.style.color),t.style.margin&&(a.margin=t.style.margin),a}const Pt=_(e.defineComponent({__name:"ListRenderer",props:{node:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",{class:"brick-el-list",style:e.normalizeStyle({fontSize:(t.node.style.fontSize??12)+"px",color:t.node.style.color})},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.node.props.ordered?"ol":"ul"),null,{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.props.items,(a,c)=>(e.openBlock(),e.createElementBlock("li",{key:c},e.toDisplayString(a),1))),128))]),_:1}))],4))}}),[["__scopeId","data-v-8107f859"]]),Vt={class:"brick-list-editor"},$t={type:"list",label:"List",icon:"☰",isContainer:!1,defaultProps:Nt,defaultStyle:xt,rendererComponent:Pt,propertyEditorComponent:e.defineComponent({__name:"ListPropertyEditor",props:{node:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",Vt))}}),propertyFields:[{key:"props.ordered",label:"Ordered",section:"content",type:"toggle",defaultValue:!1},{key:"props.items",label:"Items",section:"content",type:"textarea",defaultValue:`Item 1
|
|
2
2
|
Item 2
|
|
3
|
-
Item 3`},{key:"style.fontSize",label:"Font Size",section:"style",type:"number",min:6,max:72,step:1,defaultValue:12},{key:"style.color",label:"Color",section:"style",type:"color",defaultValue:"#000000"},{key:"style.margin",label:"Margin",section:"layout",type:"margin",defaultValue:[0,0,0,0]}],toPdfmake:Ct};function Pt(){return{data:"https://example.com",fit:100}}function Vt(){return{}}function $t(t){const n={qr:t.props.data,fit:t.props.fit??100};return t.style.alignment&&(n.alignment=t.style.alignment),t.style.margin&&(n.margin=t.style.margin),n}const It={class:"brick-el-qr__preview"},Dt=_(e.defineComponent({__name:"QrRenderer",props:{node:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",{class:"brick-el-qr",style:e.normalizeStyle({width:(t.node.props.fit??100)+"px",height:(t.node.props.fit??100)+"px"})},[e.createElementVNode("div",It,"QR: "+e.toDisplayString(t.node.props.data),1)],4))}}),[["__scopeId","data-v-f106ba48"]]),zt={class:"brick-qr-editor"},Rt={type:"qr",label:"QR Code",icon:"⊞",isContainer:!1,defaultProps:Pt,defaultStyle:Vt,rendererComponent:Dt,propertyEditorComponent:e.defineComponent({__name:"QrPropertyEditor",props:{node:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",zt))}}),propertyFields:[{key:"props.data",label:"QR Data",section:"content",type:"text",defaultValue:"https://example.com"},{key:"props.fit",label:"Size (px)",section:"layout",type:"number",min:50,max:500,step:10,defaultValue:100},{key:"style.alignment",label:"Alignment",section:"style",type:"select",options:[{label:"Left",value:"left"},{label:"Center",value:"center"},{label:"Right",value:"right"}]},{key:"style.margin",label:"Margin",section:"layout",type:"margin",defaultValue:[0,0,0,0]}],toPdfmake:$t};function Lt(){return{svg:'<svg viewBox="0 0 100 100"><rect width="100" height="100" fill="#eee" /><text x="50" y="55" text-anchor="middle" font-size="12">SVG</text></svg>',width:200,height:200}}function Tt(){return{}}function Mt(t){const n={svg:t.props.svg};return t.props.width&&(n.width=t.props.width),t.props.height&&(n.height=t.props.height),t.style.margin&&(n.margin=t.style.margin),t.style.alignment&&(n.alignment=t.style.alignment),n}const Ft=["innerHTML"],Ot=_(e.defineComponent({__name:"SvgRenderer",props:{node:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",{class:"brick-el-svg",style:e.normalizeStyle({width:t.node.props.width+"px",height:t.node.props.height+"px"}),innerHTML:t.node.props.svg},null,12,Ft))}}),[["__scopeId","data-v-5e9f3319"]]),At={class:"brick-svg-editor"},Ht={type:"svg",label:"SVG",icon:"◇",isContainer:!1,defaultProps:Lt,defaultStyle:Tt,rendererComponent:Ot,propertyEditorComponent:e.defineComponent({__name:"SvgPropertyEditor",props:{node:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",At))}}),propertyFields:[{key:"props.svg",label:"SVG Markup",section:"content",type:"textarea"},{key:"props.width",label:"Width",section:"layout",type:"number",min:10,max:1e3,step:10,defaultValue:200},{key:"props.height",label:"Height",section:"layout",type:"number",min:10,max:1e3,step:10,defaultValue:200},{key:"style.alignment",label:"Alignment",section:"style",type:"select",options:[{label:"Left",value:"left"},{label:"Center",value:"center"},{label:"Right",value:"right"}]},{key:"style.margin",label:"Margin",section:"layout",type:"margin",defaultValue:[0,0,0,0]}],toPdfmake:Mt};function jt(){return{}}function Jt(){return{}}function Ut(t){return{text:"",pageBreak:"after"}}const Wt={class:"brick-el-pagebreak"},qt=_(e.defineComponent({__name:"PageBreakRenderer",props:{node:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",Wt,[...o[0]||(o[0]=[e.createElementVNode("hr",null,null,-1),e.createElementVNode("span",null,"Page Break",-1),e.createElementVNode("hr",null,null,-1)])]))}}),[["__scopeId","data-v-60c05148"]]),Yt={class:"brick-pagebreak-editor"},Kt={type:"pageBreak",label:"Page Break",icon:"⏎",isContainer:!1,defaultProps:jt,defaultStyle:Jt,rendererComponent:qt,propertyEditorComponent:e.defineComponent({__name:"PageBreakPropertyEditor",props:{node:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",Yt,[...o[0]||(o[0]=[e.createElementVNode("p",{style:{color:"#999","font-size":"12px"}},"No configurable properties.",-1)])]))}}),propertyFields:[],toPdfmake:Ut};let le=!1;function Gt(){le||(le=!0,E(ge),E(Se),E(Ve),E(mt),E(Et),E(wt),E(Rt),E(Ht),E(Kt))}const Xt={key:0,class:"brick-dropzone__empty"},ie=_(e.defineComponent({__name:"DropZone",props:{parentId:{},layout:{}},setup(t){const n=t,o=e.ref(null);let a=null;const c=M(),{isDragging:r}=c;return e.onMounted(()=>{o.value&&(a=c.initContainer(o.value,n.parentId))}),e.onBeforeUnmount(()=>{a?.destroy()}),(u,p)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"el",ref:o,class:e.normalizeClass(["brick-dropzone",{"brick-dropzone--horizontal":t.layout==="horizontal","brick-dropzone--drag-active":e.unref(r)&&t.layout==="horizontal"}])},[e.renderSlot(u.$slots,"default",{},void 0,!0),u.$slots.default?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Xt," Drop elements here "))],2))}}),[["__scopeId","data-v-b9596dad"]]),Qt=["data-element-id","data-element-type"],Zt={key:1,class:"brick-canvas-element__unknown"},vt=_(e.defineComponent({__name:"CanvasElement",props:{node:{},path:{}},setup(t){const n=t,o=N(),a=x(),c=e.ref(null),r=e.computed(()=>C(n.node.type)),u=e.computed(()=>o.selectedId.value===n.node.id),p=e.computed(()=>r.value?r.value.propertyFields.some(m=>m.key==="props.width"||m.key==="style.width"):!1),s=e.computed(()=>r.value?r.value.propertyFields.some(m=>m.key==="props.height"||m.key==="style.height"):!1);function l(m){m.stopPropagation(),o.select(n.node.id)}function i(m){m.stopPropagation(),m.preventDefault();const y=m.clientX,k=c.value?.offsetWidth??200;function g(B){const V=B.clientX-y,S=Math.max(20,k+V);r.value?.propertyFields.some(I=>I.key==="props.width")?a.updateProps(n.node.id,{width:Math.round(S)}):a.updateStyle(n.node.id,{width:Math.round(S)})}function h(){document.removeEventListener("pointermove",g),document.removeEventListener("pointerup",h),document.body.style.cursor="",document.body.style.userSelect=""}document.body.style.cursor="ew-resize",document.body.style.userSelect="none",document.addEventListener("pointermove",g),document.addEventListener("pointerup",h)}function d(m){m.stopPropagation(),m.preventDefault();const y=m.clientY,k=c.value?.offsetHeight??100;function g(B){const V=B.clientY-y,S=Math.max(20,k+V);r.value?.propertyFields.some(I=>I.key==="props.height")?a.updateProps(n.node.id,{height:Math.round(S)}):a.updateStyle(n.node.id,{height:Math.round(S)})}function h(){document.removeEventListener("pointermove",g),document.removeEventListener("pointerup",h),document.body.style.cursor="",document.body.style.userSelect=""}document.body.style.cursor="ns-resize",document.body.style.userSelect="none",document.addEventListener("pointermove",g),document.addEventListener("pointerup",h)}function f(m){m.stopPropagation(),m.preventDefault();const y=m.clientX,k=m.clientY,g=c.value?.offsetWidth??200,h=c.value?.offsetHeight??100;function B(S){const F=S.clientX-y,I=S.clientY-k,ce=Math.max(20,g+F),se=Math.max(20,h+I),eo=r.value?.propertyFields.some(O=>O.key==="props.width"),to=r.value?.propertyFields.some(O=>O.key==="props.height");eo?a.updateProps(n.node.id,{width:Math.round(ce)}):a.updateStyle(n.node.id,{width:Math.round(ce)}),to?a.updateProps(n.node.id,{height:Math.round(se)}):a.updateStyle(n.node.id,{height:Math.round(se)})}function V(){document.removeEventListener("pointermove",B),document.removeEventListener("pointerup",V),document.body.style.cursor="",document.body.style.userSelect=""}document.body.style.cursor="nwse-resize",document.body.style.userSelect="none",document.addEventListener("pointermove",B),document.addEventListener("pointerup",V)}return(m,y)=>{const k=e.resolveComponent("CanvasElement",!0);return e.openBlock(),e.createElementBlock("div",{ref_key:"elRef",ref:c,class:e.normalizeClass(["brick-canvas-element",{"brick-canvas-element--selected":u.value}]),"data-element-id":t.node.id,"data-element-type":t.node.type,style:e.normalizeStyle({width:typeof t.node.style.width=="number"?t.node.style.width+"px":t.node.props.width?t.node.props.width+"px":t.node.style.width,height:t.node.style.height?t.node.style.height+"px":t.node.props.height?t.node.props.height+"px":void 0,marginTop:t.node.style.margin?.[1]+"px",marginRight:t.node.style.margin?.[2]+"px",marginBottom:t.node.style.margin?.[3]+"px",marginLeft:t.node.style.margin?.[0]+"px",textAlign:t.node.style.alignment}),onClick:l},[r.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(r.value.rendererComponent),{key:0,node:t.node,path:t.path},{default:e.withCtx(()=>[r.value.isContainer?(e.openBlock(),e.createBlock(ie,{key:0,"parent-id":t.node.id,layout:t.node.type==="columns"?"horizontal":"vertical"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.children,(g,h)=>(e.openBlock(),e.createBlock(k,{key:g.id,node:g,path:[...t.path,h]},null,8,["node","path"]))),128))]),_:1},8,["parent-id","layout"])):e.createCommentVNode("",!0)]),_:1},8,["node","path"])):(e.openBlock(),e.createElementBlock("div",Zt," Unknown element: "+e.toDisplayString(t.node.type),1)),u.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[p.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"brick-resize-handle brick-resize-handle--e",onPointerdown:i},null,32)):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:"brick-resize-handle brick-resize-handle--s",onPointerdown:d},null,32)):e.createCommentVNode("",!0),p.value&&s.value?(e.openBlock(),e.createElementBlock("div",{key:2,class:"brick-resize-handle brick-resize-handle--se",onPointerdown:f},null,32)):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0)],14,Qt)}}}),[["__scopeId","data-v-6b9cadc1"]]),en={class:"brick-doc-bar"},tn={class:"brick-doc-bar__field"},nn=["value"],on={class:"brick-doc-bar__field"},rn={class:"brick-doc-bar__field brick-doc-bar__field--margins"},ln={class:"brick-doc-bar__margins"},an=["placeholder","title","value","onInput"],cn={class:"brick-doc-bar__field"},sn=["value"],dn=_(e.defineComponent({__name:"DocumentSettings",setup(t){const n=R(),o=[{label:"A3",value:"A3"},{label:"A4",value:"A4"},{label:"A5",value:"A5"},{label:"Letter",value:"LETTER"},{label:"Legal",value:"LEGAL"}];function a(c,r){const u=[...n.document.pageMargins];u[c]=r,n.document.pageMargins=u}return(c,r)=>(e.openBlock(),e.createElementBlock("div",en,[e.createElementVNode("div",tn,[r[3]||(r[3]=e.createElementVNode("label",null,"Size",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":r[0]||(r[0]=u=>e.unref(n).document.pageSize=u)},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(o,u=>e.createElementVNode("option",{key:u.value,value:u.value},e.toDisplayString(u.label),9,nn)),64))],512),[[e.vModelSelect,e.unref(n).document.pageSize]])]),e.createElementVNode("div",on,[r[5]||(r[5]=e.createElementVNode("label",null,"Orientation",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":r[1]||(r[1]=u=>e.unref(n).document.pageOrientation=u)},[...r[4]||(r[4]=[e.createElementVNode("option",{value:"portrait"},"Portrait",-1),e.createElementVNode("option",{value:"landscape"},"Landscape",-1)])],512),[[e.vModelSelect,e.unref(n).document.pageOrientation]])]),e.createElementVNode("div",rn,[r[6]||(r[6]=e.createElementVNode("label",null,"Margins",-1)),e.createElementVNode("div",ln,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(["L","T","R","B"],(u,p)=>e.createElementVNode("input",{key:p,type:"number",placeholder:u,title:u,value:e.unref(n).document.pageMargins[p],onInput:s=>a(p,Number(s.target.value))},null,40,an)),64))])]),e.createElementVNode("div",cn,[r[7]||(r[7]=e.createElementVNode("label",null,"Font Size",-1)),e.createElementVNode("input",{type:"number",value:e.unref(n).document.defaultStyle?.fontSize??12,min:"6",max:"72",onInput:r[2]||(r[2]=u=>(e.unref(n).document.defaultStyle??={}).fontSize=Number(u.target.value))},null,40,sn)])]))}}),[["__scopeId","data-v-39a2b54f"]]),pn={class:"brick-canvas"},P=.75,mn=_(e.defineComponent({__name:"DesignCanvas",setup(t){const n=R(),o=N(),a={A3:[841.89,1190.55],A4:[595.28,841.89],A5:[419.53,595.28],LETTER:[612,792],LEGAL:[612,1008]},c=e.computed(()=>{const[p,s]=a[n.document.pageSize]??a.A4,l=n.document.pageOrientation==="landscape"?s:p;return Math.round(l*P)}),r=e.computed(()=>{const[p,s]=a[n.document.pageSize]??a.A4,l=n.document.pageOrientation==="landscape"?p:s;return Math.round(l*P)});function u(p){(p.target===p.currentTarget||p.target.classList.contains("brick-canvas__page"))&&o.deselect()}return(p,s)=>(e.openBlock(),e.createElementBlock("div",pn,[e.createVNode(dn),e.createElementVNode("div",{class:"brick-canvas__scroll",onClick:u},[e.createElementVNode("div",{class:"brick-canvas__page",style:e.normalizeStyle({width:c.value+"px",minHeight:r.value+"px",paddingTop:e.unref(n).document.pageMargins[1]*P+"px",paddingRight:e.unref(n).document.pageMargins[2]*P+"px",paddingBottom:e.unref(n).document.pageMargins[3]*P+"px",paddingLeft:e.unref(n).document.pageMargins[0]*P+"px"})},[e.createVNode(ie,{"parent-id":null},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(n).document.content,(l,i)=>(e.openBlock(),e.createBlock(vt,{key:l.id,node:l,path:[i]},null,8,["node","path"]))),128))]),_:1})],4)])]))}}),[["__scopeId","data-v-364329ec"]]),un=["data-element-type"],fn={class:"brick-element-list__icon"},yn={class:"brick-element-list__label"},kn=_(e.defineComponent({__name:"ToolbarElementList",setup(t){const n=e.ref(null);let o=null;const a=M(),c=H();return e.onMounted(()=>{n.value&&(o=a.initToolbar(n.value))}),e.onBeforeUnmount(()=>{o?.destroy()}),(r,u)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"el",ref:n,class:"brick-element-list"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(c),p=>(e.openBlock(),e.createElementBlock("div",{key:p.type,class:"brick-element-list__item","data-element-type":p.type},[e.createElementVNode("span",fn,e.toDisplayString(p.icon),1),e.createElementVNode("span",yn,e.toDisplayString(p.label),1)],8,un))),128))],512))}}),[["__scopeId","data-v-2d0b1dbf"]]),gn={class:"brick-field"},bn={class:"brick-field__label"},hn=["value"],_n=["value"],En=["value","min","max","step"],Bn=["value"],Sn=["value"],Cn=["value"],Nn={key:5,class:"brick-field__toggle"},xn=["checked"],wn={key:6,class:"brick-field__margin"},Pn=["placeholder","value","onInput"],Vn={key:7,class:"brick-field__slider"},$n=["value","min","max","step"],In={class:"brick-field__slider-value"},Dn=_(e.defineComponent({__name:"PropertyField",props:{descriptor:{},node:{}},setup(t){const n=t,o=x(),a=e.computed(()=>{const s=n.descriptor.key.split("."),l=s[0],i=s[1];if(l==="props")return n.node.props[i];if(l==="style")return n.node.style[i]}),c=e.computed(()=>{const s=a.value;return n.descriptor.type==="textarea"&&Array.isArray(s)?s.join(`
|
|
4
|
-
`):
|
|
5
|
-
`)),
|
|
3
|
+
Item 3`},{key:"style.fontSize",label:"Font Size",section:"style",type:"number",min:6,max:72,step:1,defaultValue:12},{key:"style.color",label:"Color",section:"style",type:"color",defaultValue:"#000000"},{key:"style.margin",label:"Margin",section:"layout",type:"margin",defaultValue:[0,0,0,0]}],toPdfmake:wt};function It(){return{data:"https://example.com",fit:100}}function Dt(){return{}}function Rt(t){const n={qr:t.props.data,fit:t.props.fit??100};return t.style.alignment&&(n.alignment=t.style.alignment),t.style.margin&&(n.margin=t.style.margin),n}const zt={class:"brick-el-qr__preview"},Lt=_(e.defineComponent({__name:"QrRenderer",props:{node:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",{class:"brick-el-qr",style:e.normalizeStyle({width:(t.node.props.fit??100)+"px",height:(t.node.props.fit??100)+"px"})},[e.createElementVNode("div",zt,"QR: "+e.toDisplayString(t.node.props.data),1)],4))}}),[["__scopeId","data-v-f106ba48"]]),Tt={class:"brick-qr-editor"},Mt={type:"qr",label:"QR Code",icon:"⊞",isContainer:!1,defaultProps:It,defaultStyle:Dt,rendererComponent:Lt,propertyEditorComponent:e.defineComponent({__name:"QrPropertyEditor",props:{node:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",Tt))}}),propertyFields:[{key:"props.data",label:"QR Data",section:"content",type:"text",defaultValue:"https://example.com"},{key:"props.fit",label:"Size (px)",section:"layout",type:"number",min:50,max:500,step:10,defaultValue:100},{key:"style.alignment",label:"Alignment",section:"style",type:"select",options:[{label:"Left",value:"left"},{label:"Center",value:"center"},{label:"Right",value:"right"}]},{key:"style.margin",label:"Margin",section:"layout",type:"margin",defaultValue:[0,0,0,0]}],toPdfmake:Rt};function Ft(){return{svg:'<svg viewBox="0 0 100 100"><rect width="100" height="100" fill="#eee" /><text x="50" y="55" text-anchor="middle" font-size="12">SVG</text></svg>',width:200,height:200}}function Ot(){return{}}function At(t){const n={svg:t.props.svg};return t.props.width&&(n.width=t.props.width),t.props.height&&(n.height=t.props.height),t.style.margin&&(n.margin=t.style.margin),t.style.alignment&&(n.alignment=t.style.alignment),n}const Ht=["innerHTML"],jt=_(e.defineComponent({__name:"SvgRenderer",props:{node:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",{class:"brick-el-svg",style:e.normalizeStyle({width:t.node.props.width+"px",height:t.node.props.height+"px"}),innerHTML:t.node.props.svg},null,12,Ht))}}),[["__scopeId","data-v-5e9f3319"]]),Jt={class:"brick-svg-editor"},Ut={type:"svg",label:"SVG",icon:"◇",isContainer:!1,defaultProps:Ft,defaultStyle:Ot,rendererComponent:jt,propertyEditorComponent:e.defineComponent({__name:"SvgPropertyEditor",props:{node:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",Jt))}}),propertyFields:[{key:"props.svg",label:"SVG Markup",section:"content",type:"textarea"},{key:"props.width",label:"Width",section:"layout",type:"number",min:10,max:1e3,step:10,defaultValue:200},{key:"props.height",label:"Height",section:"layout",type:"number",min:10,max:1e3,step:10,defaultValue:200},{key:"style.alignment",label:"Alignment",section:"style",type:"select",options:[{label:"Left",value:"left"},{label:"Center",value:"center"},{label:"Right",value:"right"}]},{key:"style.margin",label:"Margin",section:"layout",type:"margin",defaultValue:[0,0,0,0]}],toPdfmake:At};function Wt(){return{}}function qt(){return{}}function Yt(t){return{text:"",pageBreak:"after"}}const Kt={class:"brick-el-pagebreak"},Gt=_(e.defineComponent({__name:"PageBreakRenderer",props:{node:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",Kt,[...o[0]||(o[0]=[e.createElementVNode("hr",null,null,-1),e.createElementVNode("span",null,"Page Break",-1),e.createElementVNode("hr",null,null,-1)])]))}}),[["__scopeId","data-v-60c05148"]]),Xt={class:"brick-pagebreak-editor"},Qt={type:"pageBreak",label:"Page Break",icon:"⏎",isContainer:!1,defaultProps:Wt,defaultStyle:qt,rendererComponent:Gt,propertyEditorComponent:e.defineComponent({__name:"PageBreakPropertyEditor",props:{node:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",Xt,[...o[0]||(o[0]=[e.createElementVNode("p",{style:{color:"#999","font-size":"12px"}},"No configurable properties.",-1)])]))}}),propertyFields:[],toPdfmake:Yt};let ce=!1;function Zt(){ce||(ce=!0,B(he),B(xe),B(De),B(yt),B(Ct),B($t),B(Mt),B(Ut),B(Qt))}const vt={key:0,class:"brick-dropzone__empty"},se=_(e.defineComponent({__name:"DropZone",props:{parentId:{},layout:{}},setup(t){const n=t,o=e.ref(null);let a=null;const c=F(),{isDragging:i}=c;return e.onMounted(()=>{o.value&&(a=c.initContainer(o.value,n.parentId))}),e.onBeforeUnmount(()=>{a?.destroy()}),(s,u)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"el",ref:o,class:e.normalizeClass(["brick-dropzone",{"brick-dropzone--horizontal":t.layout==="horizontal","brick-dropzone--drag-active":e.unref(i)&&t.layout==="horizontal"}])},[e.renderSlot(s.$slots,"default",{},void 0,!0),s.$slots.default?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",vt," Drop elements here "))],2))}}),[["__scopeId","data-v-b9596dad"]]),en=["data-element-id","data-element-type"],tn={key:1,class:"brick-canvas-element__unknown"},nn=_(e.defineComponent({__name:"CanvasElement",props:{node:{},path:{}},setup(t){const n=t,o=w(),a=P(),{isDragging:c}=F(),i=e.ref(null),s=e.computed(()=>x(n.node.type)),u=e.computed(()=>o.selectedId.value===n.node.id),d=e.computed(()=>s.value?s.value.propertyFields.some(y=>y.key==="props.width"||y.key==="style.width"):!1),l=e.computed(()=>s.value?s.value.propertyFields.some(y=>y.key==="props.height"||y.key==="style.height"):!1),r=e.computed(()=>typeof n.node.style.width=="number"?n.node.style.width+"px":n.node.props.width?n.node.props.width+"px":n.node.style.width),p=e.computed(()=>c.value?{}:typeof r.value!="string"||!r.value.endsWith("px")?{}:n.node.style.alignment==="center"?{marginLeft:"auto",marginRight:"auto"}:n.node.style.alignment==="right"?{marginLeft:"auto"}:{});function f(y){y.stopPropagation(),o.select(n.node.id)}function m(y){y.stopPropagation(),y.preventDefault();const h=y.clientX,E=i.value?.offsetWidth??200;function S(I){const D=I.clientX-h,N=Math.max(20,E+D);s.value?.propertyFields.some(z=>z.key==="props.width")?a.updateProps(n.node.id,{width:Math.round(N)}):a.updateStyle(n.node.id,{width:Math.round(N)})}function C(){document.removeEventListener("pointermove",S),document.removeEventListener("pointerup",C),document.body.style.cursor="",document.body.style.userSelect=""}document.body.style.cursor="ew-resize",document.body.style.userSelect="none",document.addEventListener("pointermove",S),document.addEventListener("pointerup",C)}function k(y){y.stopPropagation(),y.preventDefault();const h=y.clientY,E=i.value?.offsetHeight??100;function S(I){const D=I.clientY-h,N=Math.max(20,E+D);s.value?.propertyFields.some(z=>z.key==="props.height")?a.updateProps(n.node.id,{height:Math.round(N)}):a.updateStyle(n.node.id,{height:Math.round(N)})}function C(){document.removeEventListener("pointermove",S),document.removeEventListener("pointerup",C),document.body.style.cursor="",document.body.style.userSelect=""}document.body.style.cursor="ns-resize",document.body.style.userSelect="none",document.addEventListener("pointermove",S),document.addEventListener("pointerup",C)}function g(y){y.stopPropagation(),y.preventDefault();const h=y.clientX,E=y.clientY,S=i.value?.offsetWidth??200,C=i.value?.offsetHeight??100;function I(N){const H=N.clientX-h,z=N.clientY-E,pe=Math.max(20,S+H),ue=Math.max(20,C+z),oo=s.value?.propertyFields.some(j=>j.key==="props.width"),ro=s.value?.propertyFields.some(j=>j.key==="props.height");oo?a.updateProps(n.node.id,{width:Math.round(pe)}):a.updateStyle(n.node.id,{width:Math.round(pe)}),ro?a.updateProps(n.node.id,{height:Math.round(ue)}):a.updateStyle(n.node.id,{height:Math.round(ue)})}function D(){document.removeEventListener("pointermove",I),document.removeEventListener("pointerup",D),document.body.style.cursor="",document.body.style.userSelect=""}document.body.style.cursor="nwse-resize",document.body.style.userSelect="none",document.addEventListener("pointermove",I),document.addEventListener("pointerup",D)}return(y,h)=>{const E=e.resolveComponent("CanvasElement",!0);return e.openBlock(),e.createElementBlock("div",{ref_key:"elRef",ref:i,class:e.normalizeClass(["brick-canvas-element",{"brick-canvas-element--selected":u.value}]),"data-element-id":t.node.id,"data-element-type":t.node.type,style:e.normalizeStyle({width:r.value,height:t.node.style.height?t.node.style.height+"px":t.node.props.height?t.node.props.height+"px":void 0,marginTop:t.node.style.margin?.[1]+"px",marginRight:t.node.style.margin?.[2]+"px",marginBottom:t.node.style.margin?.[3]+"px",marginLeft:t.node.style.margin?.[0]+"px",textAlign:t.node.style.alignment,...p.value}),onClick:f},[s.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(s.value.rendererComponent),{key:0,node:t.node,path:t.path},{default:e.withCtx(()=>[s.value.isContainer?(e.openBlock(),e.createBlock(se,{key:0,"parent-id":t.node.id,layout:t.node.type==="columns"?"horizontal":"vertical"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.node.children,(S,C)=>(e.openBlock(),e.createBlock(E,{key:S.id,node:S,path:[...t.path,C]},null,8,["node","path"]))),128))]),_:1},8,["parent-id","layout"])):e.createCommentVNode("",!0)]),_:1},8,["node","path"])):(e.openBlock(),e.createElementBlock("div",tn," Unknown element: "+e.toDisplayString(t.node.type),1)),u.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[d.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"brick-resize-handle brick-resize-handle--e",onPointerdown:m},null,32)):e.createCommentVNode("",!0),l.value?(e.openBlock(),e.createElementBlock("div",{key:1,class:"brick-resize-handle brick-resize-handle--s",onPointerdown:k},null,32)):e.createCommentVNode("",!0),d.value&&l.value?(e.openBlock(),e.createElementBlock("div",{key:2,class:"brick-resize-handle brick-resize-handle--se",onPointerdown:g},null,32)):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0)],14,en)}}}),[["__scopeId","data-v-6e0d4942"]]),on={class:"brick-doc-bar"},rn={class:"brick-doc-bar__field"},ln=["value"],an={class:"brick-doc-bar__field"},cn={class:"brick-doc-bar__field brick-doc-bar__field--margins"},sn={class:"brick-doc-bar__margins"},dn=["placeholder","title","value","onInput"],pn={class:"brick-doc-bar__field"},un=["value"],mn=_(e.defineComponent({__name:"DocumentSettings",setup(t){const n=M(),o=[{label:"A3",value:"A3"},{label:"A4",value:"A4"},{label:"A5",value:"A5"},{label:"Letter",value:"LETTER"},{label:"Legal",value:"LEGAL"}];function a(c,i){const s=[...n.document.pageMargins];s[c]=i,n.document.pageMargins=s}return(c,i)=>(e.openBlock(),e.createElementBlock("div",on,[e.createElementVNode("div",rn,[i[3]||(i[3]=e.createElementVNode("label",null,"Size",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":i[0]||(i[0]=s=>e.unref(n).document.pageSize=s)},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(o,s=>e.createElementVNode("option",{key:s.value,value:s.value},e.toDisplayString(s.label),9,ln)),64))],512),[[e.vModelSelect,e.unref(n).document.pageSize]])]),e.createElementVNode("div",an,[i[5]||(i[5]=e.createElementVNode("label",null,"Orientation",-1)),e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":i[1]||(i[1]=s=>e.unref(n).document.pageOrientation=s)},[...i[4]||(i[4]=[e.createElementVNode("option",{value:"portrait"},"Portrait",-1),e.createElementVNode("option",{value:"landscape"},"Landscape",-1)])],512),[[e.vModelSelect,e.unref(n).document.pageOrientation]])]),e.createElementVNode("div",cn,[i[6]||(i[6]=e.createElementVNode("label",null,"Margins",-1)),e.createElementVNode("div",sn,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(["L","T","R","B"],(s,u)=>e.createElementVNode("input",{key:u,type:"number",placeholder:s,title:s,value:e.unref(n).document.pageMargins[u],onInput:d=>a(u,Number(d.target.value))},null,40,dn)),64))])]),e.createElementVNode("div",pn,[i[7]||(i[7]=e.createElementVNode("label",null,"Font Size",-1)),e.createElementVNode("input",{type:"number",value:e.unref(n).document.defaultStyle?.fontSize??12,min:"6",max:"72",onInput:i[2]||(i[2]=s=>(e.unref(n).document.defaultStyle??={}).fontSize=Number(s.target.value))},null,40,un)])]))}}),[["__scopeId","data-v-39a2b54f"]]),fn={class:"brick-canvas"},$=.75,yn=_(e.defineComponent({__name:"DesignCanvas",setup(t){const n=M(),o=w(),a={A3:[841.89,1190.55],A4:[595.28,841.89],A5:[419.53,595.28],LETTER:[612,792],LEGAL:[612,1008]},c=e.computed(()=>{const[u,d]=a[n.document.pageSize]??a.A4,l=n.document.pageOrientation==="landscape"?d:u;return Math.round(l*$)}),i=e.computed(()=>{const[u,d]=a[n.document.pageSize]??a.A4,l=n.document.pageOrientation==="landscape"?u:d;return Math.round(l*$)});function s(u){(u.target===u.currentTarget||u.target.classList.contains("brick-canvas__page"))&&o.deselect()}return(u,d)=>(e.openBlock(),e.createElementBlock("div",fn,[e.createVNode(mn),e.createElementVNode("div",{class:"brick-canvas__scroll",onClick:s},[e.createElementVNode("div",{class:"brick-canvas__page",style:e.normalizeStyle({width:c.value+"px",minHeight:i.value+"px",paddingTop:e.unref(n).document.pageMargins[1]*$+"px",paddingRight:e.unref(n).document.pageMargins[2]*$+"px",paddingBottom:e.unref(n).document.pageMargins[3]*$+"px",paddingLeft:e.unref(n).document.pageMargins[0]*$+"px"})},[e.createVNode(se,{"parent-id":null},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(n).document.content,(l,r)=>(e.openBlock(),e.createBlock(nn,{key:l.id,node:l,path:[r]},null,8,["node","path"]))),128))]),_:1})],4)])]))}}),[["__scopeId","data-v-364329ec"]]),kn=["data-element-type"],gn={class:"brick-element-list__icon"},bn={class:"brick-element-list__label"},_n=_(e.defineComponent({__name:"ToolbarElementList",setup(t){const n=e.ref(null);let o=null;const a=F(),c=U();return e.onMounted(()=>{n.value&&(o=a.initToolbar(n.value))}),e.onBeforeUnmount(()=>{o?.destroy()}),(i,s)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"el",ref:n,class:"brick-element-list"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(c),u=>(e.openBlock(),e.createElementBlock("div",{key:u.type,class:"brick-element-list__item","data-element-type":u.type},[e.createElementVNode("span",gn,e.toDisplayString(u.icon),1),e.createElementVNode("span",bn,e.toDisplayString(u.label),1)],8,kn))),128))],512))}}),[["__scopeId","data-v-2d0b1dbf"]]),hn={class:"brick-field"},En={class:"brick-field__label"},Bn=["value"],Sn=["value"],Cn=["value","min","max","step"],Nn=["value"],xn=["value"],wn=["value"],Pn={key:5,class:"brick-field__toggle"},Vn=["checked"],$n={key:6,class:"brick-field__margin"},In=["placeholder","value","onInput"],Dn={key:7,class:"brick-field__slider"},Rn=["value","min","max","step"],zn={class:"brick-field__slider-value"},Ln=_(e.defineComponent({__name:"PropertyField",props:{descriptor:{},node:{}},setup(t){const n=t,o=P(),a=e.computed(()=>{const d=n.descriptor.key.split("."),l=d[0],r=d[1];if(l==="props")return n.node.props[r];if(l==="style")return n.node.style[r]}),c=e.computed(()=>{const d=a.value;return n.descriptor.type==="textarea"&&Array.isArray(d)?d.join(`
|
|
4
|
+
`):d});function i(d){const l=n.descriptor.key.split("."),r=l[0],p=l[1];let f=d;n.descriptor.type==="textarea"&&Array.isArray(a.value)&&(f=d.split(`
|
|
5
|
+
`)),r==="props"?o.updateProps(n.node.id,{[p]:f}):r==="style"&&o.updateStyle(n.node.id,{[p]:f})}function s(d,l){const p=[...c.value??[0,0,0,0]];p[d]=l,i(p)}function u(d){const r=d.target.files?.[0];if(!r)return;const p=new FileReader;p.onload=()=>{i(p.result)},p.readAsDataURL(r)}return(d,l)=>(e.openBlock(),e.createElementBlock("div",hn,[e.createElementVNode("label",En,e.toDisplayString(t.descriptor.label),1),t.descriptor.type==="text"?(e.openBlock(),e.createElementBlock("input",{key:0,type:"text",class:"brick-field__input",value:c.value,onInput:l[0]||(l[0]=r=>i(r.target.value))},null,40,Bn)):t.descriptor.type==="textarea"?(e.openBlock(),e.createElementBlock("textarea",{key:1,class:"brick-field__textarea",value:c.value,rows:"3",onInput:l[1]||(l[1]=r=>i(r.target.value))},null,40,Sn)):t.descriptor.type==="number"?(e.openBlock(),e.createElementBlock("input",{key:2,type:"number",class:"brick-field__input",value:c.value,min:t.descriptor.min,max:t.descriptor.max,step:t.descriptor.step,onInput:l[2]||(l[2]=r=>i(Number(r.target.value)))},null,40,Cn)):t.descriptor.type==="color"?(e.openBlock(),e.createElementBlock("input",{key:3,type:"color",class:"brick-field__color",value:c.value??"#000000",onInput:l[3]||(l[3]=r=>i(r.target.value))},null,40,Nn)):t.descriptor.type==="select"?(e.openBlock(),e.createElementBlock("select",{key:4,class:"brick-field__select",value:c.value,onChange:l[4]||(l[4]=r=>i(r.target.value||void 0))},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.descriptor.options,r=>(e.openBlock(),e.createElementBlock("option",{key:String(r.value),value:r.value},e.toDisplayString(r.label),9,wn))),128))],40,xn)):t.descriptor.type==="toggle"?(e.openBlock(),e.createElementBlock("label",Pn,[e.createElementVNode("input",{type:"checkbox",checked:c.value,onChange:l[5]||(l[5]=r=>i(r.target.checked))},null,40,Vn),e.createElementVNode("span",null,e.toDisplayString(c.value?"On":"Off"),1)])):t.descriptor.type==="margin"?(e.openBlock(),e.createElementBlock("div",$n,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(["L","T","R","B"],(r,p)=>e.createElementVNode("input",{key:r,type:"number",class:"brick-field__margin-input",placeholder:r,value:(c.value??[0,0,0,0])[p],onInput:f=>s(p,Number(f.target.value))},null,40,In)),64))])):t.descriptor.type==="slider"?(e.openBlock(),e.createElementBlock("div",Dn,[e.createElementVNode("input",{type:"range",value:c.value,min:t.descriptor.min,max:t.descriptor.max,step:t.descriptor.step,onInput:l[6]||(l[6]=r=>i(Number(r.target.value)))},null,40,Rn),e.createElementVNode("span",zn,e.toDisplayString(c.value),1)])):t.descriptor.type==="file"?(e.openBlock(),e.createElementBlock("input",{key:8,type:"file",accept:"image/*",class:"brick-field__file",onChange:u},null,32)):e.createCommentVNode("",!0)]))}}),[["__scopeId","data-v-5a3bec1b"]]),Tn={key:0,class:"brick-property-editor"},Mn={class:"brick-property-editor__type"},Fn={class:"brick-property-editor__key"},On=["value"],An={key:0,class:"brick-property-editor__group"},Hn={class:"brick-property-editor__group-title"},jn=_(e.defineComponent({__name:"PropertyEditor",setup(t){const n=w(),o=P();function a(d){const l=n.selectedNode.value;l&&o.updateKey(l.id,d.target.value)}const c=e.computed(()=>{const d=n.selectedNode.value;return d?x(d.type):null}),i=e.computed(()=>{if(!c.value)return{};const d={};for(const l of c.value.propertyFields)d[l.section]||(d[l.section]=[]),d[l.section].push(l);return d}),s={content:"Content",style:"Style",layout:"Layout",advanced:"Advanced"},u=["content","style","layout","advanced"];return(d,l)=>e.unref(n).selectedNode.value&&c.value?(e.openBlock(),e.createElementBlock("div",Tn,[e.createElementVNode("div",Mn,e.toDisplayString(c.value.icon)+" "+e.toDisplayString(c.value.label),1),e.createElementVNode("div",Fn,[l[0]||(l[0]=e.createElementVNode("label",{class:"brick-property-editor__key-label"},"Key",-1)),e.createElementVNode("input",{type:"text",class:"brick-property-editor__key-input",value:e.unref(n).selectedNode.value.key??"",placeholder:"(optional identifier)",onInput:a},null,40,On)]),(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(u,r=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:r},[i.value[r]?(e.openBlock(),e.createElementBlock("div",An,[e.createElementVNode("div",Hn,e.toDisplayString(s[r]),1),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value[r],p=>(e.openBlock(),e.createBlock(Ln,{key:p.key,descriptor:p,node:e.unref(n).selectedNode.value},null,8,["descriptor","node"]))),128))])):e.createCommentVNode("",!0)],64))),64)),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(c.value.propertyEditorComponent),{node:e.unref(n).selectedNode.value},null,8,["node"]))])):e.createCommentVNode("",!0)}}),[["__scopeId","data-v-e49ddc4f"]]),Jn={class:"brick-toolbar"},Un={class:"brick-toolbar__section"},Wn={key:0,class:"brick-toolbar__section"},qn=_(e.defineComponent({__name:"Toolbar",setup(t){const n=w();return(o,a)=>(e.openBlock(),e.createElementBlock("div",Jn,[e.createElementVNode("div",Un,[a[0]||(a[0]=e.createElementVNode("h3",{class:"brick-toolbar__title"},"Elements",-1)),e.createVNode(_n)]),e.unref(n).selectedNode.value?(e.openBlock(),e.createElementBlock("div",Wn,[a[1]||(a[1]=e.createElementVNode("h3",{class:"brick-toolbar__title"},"Properties",-1)),e.createVNode(jn)])):e.createCommentVNode("",!0)]))}}),[["__scopeId","data-v-0174c069"]]),Yn={class:"brick-actionbar"},Kn={class:"brick-actionbar__group"},Gn=["disabled"],Xn=["disabled"],Qn=["disabled"],Zn={class:"brick-actionbar__group"},vn=_(e.defineComponent({__name:"ActionBar",setup(t){const n=Z(),o=re(),a=w(),c=P(),i=M(),s=e.ref("document"),u=e.ref(null);function d(){const m=a.selectedId.value;m&&(a.deselect(),c.removeElement(m))}function l(){const m=s.value.trim()||"document",k=m.endsWith(".pdf")?m:m+".pdf";o.exportPdf(k)}function r(){const m=i.exportDocument(),k=JSON.stringify(m,null,2),g=new Blob([k],{type:"application/json"}),y=URL.createObjectURL(g),h=document.createElement("a"),E=s.value.trim()||"document";h.href=y,h.download=E.endsWith(".json")?E:E+".json",h.click(),URL.revokeObjectURL(y)}function p(){u.value?.click()}function f(m){const k=m.target,g=k.files?.[0];if(!g)return;const y=new FileReader;y.onload=()=>{try{const h=JSON.parse(y.result);if(!h.content||!h.pageSize){alert("Invalid brick-pdf JSON file.");return}a.deselect(),i.loadDocument(h)}catch{alert("Failed to parse JSON file.")}},y.readAsText(g),k.value=""}return(m,k)=>(e.openBlock(),e.createElementBlock("div",Yn,[e.createElementVNode("div",Kn,[e.createElementVNode("button",{class:"brick-actionbar__btn",disabled:!e.unref(n).canUndo.value,title:"Undo",onClick:k[0]||(k[0]=g=>e.unref(n).undo())}," Undo ",8,Gn),e.createElementVNode("button",{class:"brick-actionbar__btn",disabled:!e.unref(n).canRedo.value,title:"Redo",onClick:k[1]||(k[1]=g=>e.unref(n).redo())}," Redo ",8,Xn),e.createElementVNode("button",{class:"brick-actionbar__btn brick-actionbar__btn--danger",disabled:!e.unref(a).selectedId.value,title:"Delete selected element",onClick:d}," Delete ",8,Qn)]),e.createElementVNode("div",Zn,[e.createElementVNode("button",{class:"brick-actionbar__btn",title:"Import JSON",onClick:p}," Import JSON "),e.createElementVNode("button",{class:"brick-actionbar__btn",title:"Export JSON",onClick:r}," Export JSON "),e.createElementVNode("button",{class:"brick-actionbar__btn brick-actionbar__btn--primary",onClick:l}," Export PDF "),e.createElementVNode("button",{class:"brick-actionbar__btn",onClick:k[2]||(k[2]=g=>e.unref(o).openPdf())}," Preview ")]),e.createElementVNode("input",{ref_key:"fileInput",ref:u,type:"file",accept:".json",style:{display:"none"},onChange:f},null,544)]))}}),[["__scopeId","data-v-586445a9"]]),eo={class:"brick-pdf"},to={class:"brick-pdf__workspace"},de=_(e.defineComponent({__name:"BrickPdf",props:{modelValue:{}},emits:["update:modelValue"],setup(t,{emit:n}){const o=t,a=n;Zt();const c=Me(o.modelValue??L());Fe(c);const i=Oe(c);Ae(i);const s=We(c);qe(s);const u=je(c,s);Je(u);const d=Ye(c,u);Ke(d);const l=ve(c);et(l);const r=ot(c,u);rt(r);const p=it(u);at(p);const f=O.useMagicKeys(),m=f.Delete,k=f.Backspace;return O.whenever(m,()=>{if(!i.selectedId.value)return;const g=document.activeElement;if(g&&(g.tagName==="INPUT"||g.tagName==="TEXTAREA"||g.tagName==="SELECT"))return;const y=i.selectedId.value;i.deselect(),u.removeElement(y)}),O.whenever(k,()=>{if(!i.selectedId.value)return;const g=document.activeElement;if(g&&(g.tagName==="INPUT"||g.tagName==="TEXTAREA"||g.tagName==="SELECT"))return;const y=i.selectedId.value;i.deselect(),u.removeElement(y)}),e.watch(()=>c.document,()=>{a("update:modelValue",JSON.parse(JSON.stringify(e.toRaw(c.document))))},{deep:!0}),(g,y)=>(e.openBlock(),e.createElementBlock("div",eo,[e.createVNode(vn),e.createElementVNode("div",to,[e.createVNode(yn),e.createVNode(qn)])]))}}),[["__scopeId","data-v-f9b95ad8"]]),no={install(t){t.component("BrickPdf",de)}};b.BrickPdf=de,b.createDefaultDocument=L,b.default=no,b.getAllElementDefinitions=U,b.getElementDefinition=x,b.registerElement=B,b.unregisterElement=me,b.useClipboard=lt,b.useDocumentStore=M,b.useDragDrop=F,b.useElementActions=P,b.useHistory=Z,b.usePdfExport=re,b.useResize=ct,b.useSelection=w,Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|