@a2simcode/dui 0.0.28 → 0.0.29
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.
|
@@ -24,6 +24,10 @@ declare const DIndexDesign: {
|
|
|
24
24
|
type: import('vue').PropType<Record<string, import('../../components/index.ts').FormSchemaConfig[]>>;
|
|
25
25
|
default: () => {};
|
|
26
26
|
};
|
|
27
|
+
actions: {
|
|
28
|
+
type: import('vue').PropType<Record<string, any>>;
|
|
29
|
+
default: () => {};
|
|
30
|
+
};
|
|
27
31
|
}>> & Readonly<{}>, {
|
|
28
32
|
reset: () => void;
|
|
29
33
|
validate: () => boolean;
|
|
@@ -37,6 +41,7 @@ declare const DIndexDesign: {
|
|
|
37
41
|
components: import('./src/interface').IndexDesignComponents[];
|
|
38
42
|
flowComponents: Record<string, any>[];
|
|
39
43
|
flowComponentConfigs: Record<string, import('../../components/index.ts').FormSchemaConfig[]>;
|
|
44
|
+
actions: Record<string, any>;
|
|
40
45
|
componentConfigs: Record<string, import('../../components/index.ts').FormSchemaConfig[]>;
|
|
41
46
|
}, true, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {
|
|
42
47
|
dragContainer: unknown;
|
|
@@ -74,6 +79,10 @@ declare const DIndexDesign: {
|
|
|
74
79
|
type: import('vue').PropType<Record<string, import('../../components/index.ts').FormSchemaConfig[]>>;
|
|
75
80
|
default: () => {};
|
|
76
81
|
};
|
|
82
|
+
actions: {
|
|
83
|
+
type: import('vue').PropType<Record<string, any>>;
|
|
84
|
+
default: () => {};
|
|
85
|
+
};
|
|
77
86
|
}>> & Readonly<{}>, {
|
|
78
87
|
reset: () => void;
|
|
79
88
|
validate: () => boolean;
|
|
@@ -87,6 +96,7 @@ declare const DIndexDesign: {
|
|
|
87
96
|
components: import('./src/interface').IndexDesignComponents[];
|
|
88
97
|
flowComponents: Record<string, any>[];
|
|
89
98
|
flowComponentConfigs: Record<string, import('../../components/index.ts').FormSchemaConfig[]>;
|
|
99
|
+
actions: Record<string, any>;
|
|
90
100
|
componentConfigs: Record<string, import('../../components/index.ts').FormSchemaConfig[]>;
|
|
91
101
|
}>;
|
|
92
102
|
__isFragment?: never;
|
|
@@ -116,6 +126,10 @@ declare const DIndexDesign: {
|
|
|
116
126
|
type: import('vue').PropType<Record<string, import('../../components/index.ts').FormSchemaConfig[]>>;
|
|
117
127
|
default: () => {};
|
|
118
128
|
};
|
|
129
|
+
actions: {
|
|
130
|
+
type: import('vue').PropType<Record<string, any>>;
|
|
131
|
+
default: () => {};
|
|
132
|
+
};
|
|
119
133
|
}>> & Readonly<{}>, {
|
|
120
134
|
reset: () => void;
|
|
121
135
|
validate: () => boolean;
|
|
@@ -129,6 +143,7 @@ declare const DIndexDesign: {
|
|
|
129
143
|
components: import('./src/interface').IndexDesignComponents[];
|
|
130
144
|
flowComponents: Record<string, any>[];
|
|
131
145
|
flowComponentConfigs: Record<string, import('../../components/index.ts').FormSchemaConfig[]>;
|
|
146
|
+
actions: Record<string, any>;
|
|
132
147
|
componentConfigs: Record<string, import('../../components/index.ts').FormSchemaConfig[]>;
|
|
133
148
|
}, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & {
|
|
134
149
|
install: (app: import('vue').App) => void;
|
|
@@ -58,6 +58,13 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
58
58
|
type: PropType<Record<string, FormSchemaConfig[]>>;
|
|
59
59
|
default: () => {};
|
|
60
60
|
};
|
|
61
|
+
/**
|
|
62
|
+
* @zh 操作集合(预览时使用)
|
|
63
|
+
*/
|
|
64
|
+
actions: {
|
|
65
|
+
type: PropType<Record<string, any>>;
|
|
66
|
+
default: () => {};
|
|
67
|
+
};
|
|
61
68
|
}>, {
|
|
62
69
|
reset: () => void;
|
|
63
70
|
validate: () => boolean;
|
|
@@ -124,10 +131,18 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
124
131
|
type: PropType<Record<string, FormSchemaConfig[]>>;
|
|
125
132
|
default: () => {};
|
|
126
133
|
};
|
|
134
|
+
/**
|
|
135
|
+
* @zh 操作集合(预览时使用)
|
|
136
|
+
*/
|
|
137
|
+
actions: {
|
|
138
|
+
type: PropType<Record<string, any>>;
|
|
139
|
+
default: () => {};
|
|
140
|
+
};
|
|
127
141
|
}>> & Readonly<{}>, {
|
|
128
142
|
components: IndexDesignComponents[];
|
|
129
143
|
flowComponents: Record<string, any>[];
|
|
130
144
|
flowComponentConfigs: Record<string, FormSchemaConfig[]>;
|
|
145
|
+
actions: Record<string, any>;
|
|
131
146
|
componentConfigs: Record<string, FormSchemaConfig[]>;
|
|
132
147
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {
|
|
133
148
|
dragContainer: unknown;
|
package/dist/dui.es.js
CHANGED
|
@@ -12220,6 +12220,10 @@ var br = /* @__PURE__ */ fg(dg, [["render", hg]]), gg = { class: "d-form-design
|
|
|
12220
12220
|
flowComponentConfigs: {
|
|
12221
12221
|
type: Object,
|
|
12222
12222
|
default: () => ({})
|
|
12223
|
+
},
|
|
12224
|
+
actions: {
|
|
12225
|
+
type: Object,
|
|
12226
|
+
default: () => ({})
|
|
12223
12227
|
}
|
|
12224
12228
|
},
|
|
12225
12229
|
setup(t, { expose: e }) {
|
|
@@ -12408,8 +12412,9 @@ var br = /* @__PURE__ */ fg(dg, [["render", hg]]), gg = { class: "d-form-design
|
|
|
12408
12412
|
}, {
|
|
12409
12413
|
default: ye(() => [ue(ie, {
|
|
12410
12414
|
ref_key: "previewRef",
|
|
12411
|
-
ref: K
|
|
12412
|
-
|
|
12415
|
+
ref: K,
|
|
12416
|
+
actions: t.actions
|
|
12417
|
+
}, null, 8, ["actions"])]),
|
|
12413
12418
|
_: 1
|
|
12414
12419
|
}, 512)
|
|
12415
12420
|
]);
|
package/dist/dui.umd.js
CHANGED
|
@@ -25,4 +25,4 @@ Target: ${n}`,EDGE_ORPHANED:t=>`Edge was orphaned (suddenly missing source or ta
|
|
|
25
25
|
Edge: ${t}`,EDGE_NOT_FOUND:t=>`Edge not found
|
|
26
26
|
Edge: ${t}`,USEVUEFLOW_OPTIONS:()=>"The options parameter is deprecated and will be removed in the next major version. Please use the id parameter instead"},we=class extends Error{constructor(t,...e){var n;super((n=Ki[t])==null?void 0:n.call(Ki,...e)),this.name="VueFlowError",this.code=t,this.args=e}};function ao(t){return"clientX"in t}function _d(t){return"sourceEvent"in t}function Pe(t,e){const n=ao(t);let o,i;return n?(o=t.clientX,i=t.clientY):"touches"in t&&t.touches.length>0?(o=t.touches[0].clientX,i=t.touches[0].clientY):"changedTouches"in t&&t.changedTouches.length>0?(o=t.changedTouches[0].clientX,i=t.changedTouches[0].clientY):(o=0,i=0),{x:o-(e?.left??0),y:i-(e?.top??0)}}var fn=()=>{var t;return typeof navigator<"u"&&((t=navigator?.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function wd(t){var e,n;return{width:((e=t.dimensions)==null?void 0:e.width)??t.width??0,height:((n=t.dimensions)==null?void 0:n.height)??t.height??0}}function hn(t,e=[1,1]){return{x:e[0]*Math.round(t.x/e[0]),y:e[1]*Math.round(t.y/e[1])}}var bd=()=>!0;function lo(t){t?.classList.remove("valid","connecting","vue-flow__handle-valid","vue-flow__handle-connecting")}function Cd(t,e,n){const o=[],i={x:t.x-n,y:t.y-n,width:n*2,height:n*2};for(const s of e.values())cn(i,ln(s))>0&&o.push(s);return o}var Ed=250;function xd(t,e,n,o){var i,s;let a=[],l=Number.POSITIVE_INFINITY;const d=Cd(t,n,e+Ed);for(const c of d){const u=[...((i=c.handleBounds)==null?void 0:i.source)??[],...((s=c.handleBounds)==null?void 0:s.target)??[]];for(const h of u){if(o.nodeId===h.nodeId&&o.type===h.type&&o.id===h.id)continue;const{x:f,y:g}=gt(c,h,h.position,!0),m=Math.sqrt((f-t.x)**2+(g-t.y)**2);m>e||(m<l?(a=[{...h,x:f,y:g}],l=m):m===l&&a.push({...h,x:f,y:g}))}}if(!a.length)return null;if(a.length>1){const c=o.type==="source"?"target":"source";return a.find(u=>u.type===c)??a[0]}return a[0]}function qi(t,{handle:e,connectionMode:n,fromNodeId:o,fromHandleId:i,fromType:s,doc:a,lib:l,flowId:d,isValidConnection:c=bd},u,h,f,g){const m=s==="target",E=e?a.querySelector(`.${l}-flow__handle[data-id="${d}-${e?.nodeId}-${e?.id}-${e?.type}"]`):null,{x:S,y:D}=Pe(t),B=a.elementFromPoint(S,D),w=B?.classList.contains(`${l}-flow__handle`)?B:E,M={handleDomNode:w,isValid:!1,connection:null,toHandle:null};if(w){const G=Ji(void 0,w),R=w.getAttribute("data-nodeid"),q=w.getAttribute("data-handleid"),K=w.classList.contains("connectable"),j=w.classList.contains("connectableend");if(!R||!G)return M;const Z={source:m?R:o,sourceHandle:m?q:i,target:m?o:R,targetHandle:m?i:q};M.connection=Z,M.isValid=K&&j&&(n===Fe.Strict?m&&G==="source"||!m&&G==="target":R!==o||q!==i)&&c(Z,{nodes:h,edges:u,sourceNode:f(Z.source),targetNode:f(Z.target)}),M.toHandle=Qi(R,G,q,g,n,!0)}return M}function Ji(t,e){return t||(e?.classList.contains("target")?"target":e?.classList.contains("source")?"source":null)}function Nd(t,e){let n=null;return e?n="valid":t&&!e&&(n="invalid"),n}function kd(t,e){let n=null;return e?n=!0:t&&!e&&(n=!1),n}function Qi(t,e,n,o,i,s=!1){var a,l,d;const c=o.get(t);if(!c)return null;const u=i===Fe.Strict?(a=c.handleBounds)==null?void 0:a[e]:[...((l=c.handleBounds)==null?void 0:l.source)??[],...((d=c.handleBounds)==null?void 0:d.target)??[]],h=(n?u?.find(f=>f.id===n):u?.[0])??null;return h&&s?{...h,...gt(c,h,h.position,!0)}:h}var co={[ae.Left]:ae.Right,[ae.Right]:ae.Left,[ae.Top]:ae.Bottom,[ae.Bottom]:ae.Top},Sd=["production","prod"];function Pt(t,...e){er()&&console.warn(`[Vue Flow]: ${t}`,...e)}function er(){return!Sd.includes(process.env.NODE_ENV||"")}function tr(t,e,n,o,i){const s=e.querySelectorAll(`.vue-flow__handle.${t}`);return s?.length?Array.from(s).map(a=>{const l=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),type:t,nodeId:i,position:a.getAttribute("data-handlepos"),x:(l.left-n.left)/o,y:(l.top-n.top)/o,...dn(a)}}):null}function uo(t,e,n,o,i,s=!1,a){i.value=!1,t.selected?(s||t.selected&&e)&&(o([t]),(0,r.nextTick)(()=>{a.blur()})):n([t])}function _e(t){return typeof(0,r.unref)(t)<"u"}function Dd(t,e,n,o){if(!t||!t.source||!t.target)return n(new we(ve.EDGE_INVALID,t?.id??"[ID UNKNOWN]")),!1;let i;return Ue(t)?i=t:i={...t,id:Bi(t)},i=Mi(i,void 0,o),ad(i,e)?!1:i}function Td(t,e,n,o,i){if(!e.source||!e.target)return i(new we(ve.EDGE_INVALID,t.id)),!1;if(!n)return i(new we(ve.EDGE_NOT_FOUND,t.id)),!1;const{id:s,...a}=t;return{...a,id:o?Bi(e):s,source:e.source,target:e.target,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle}}function nr(t,e,n){const o={},i=[];for(let s=0;s<t.length;++s){const a=t[s];if(!it(a)){n(new we(ve.NODE_INVALID,a?.id));continue}const l=id(a,e(a.id),a.parentNode);a.parentNode&&(o[a.parentNode]=!0),i[s]=l}for(const s of i){const a=e(s.parentNode)||i.find(l=>l.id===s.parentNode);s.parentNode&&!a&&n(new we(ve.NODE_MISSING_PARENT,s.id,s.parentNode)),(s.parentNode||o[s.id])&&(o[s.id]&&(s.isParent=!0),a&&(a.isParent=!0))}return i}function or(t,e,n,o,i,s){let a=i;const l=o.get(a)||new Map;o.set(a,l.set(n,e)),a=`${i}-${t}`;const d=o.get(a)||new Map;if(o.set(a,d.set(n,e)),s){a=`${i}-${t}-${s}`;const c=o.get(a)||new Map;o.set(a,c.set(n,e))}}function fo(t,e,n){t.clear();for(const o of n){const{source:i,target:s,sourceHandle:a=null,targetHandle:l=null}=o,d={edgeId:o.id,source:i,target:s,sourceHandle:a,targetHandle:l},c=`${i}-${a}--${s}-${l}`;or("source",d,`${s}-${l}--${i}-${a}`,t,i,a),or("target",d,c,t,s,l)}}function ir(t,e){if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;return!0}function ho(t,e,n,o,i,s,a,l){const d=[];for(const c of t){const u=Ue(c)?c:Dd(c,l,i,s);if(!u)continue;const h=n(u.source),f=n(u.target);if(!h||!f){i(new we(ve.EDGE_SOURCE_TARGET_MISSING,u.id,u.source,u.target));continue}if(!h){i(new we(ve.EDGE_SOURCE_MISSING,u.id,u.source));continue}if(!f){i(new we(ve.EDGE_TARGET_MISSING,u.id,u.target));continue}if(e&&!e(u,{edges:l,nodes:a,sourceNode:h,targetNode:f})){i(new we(ve.EDGE_INVALID,u.id));continue}const g=o(u.id);d.push({...Mi(u,g,s),sourceNode:h,targetNode:f})}return d}var rr=Symbol("vueFlow"),sr=Symbol("nodeId"),ar=Symbol("nodeRef"),Md=Symbol("edgeId"),Id=Symbol("edgeRef"),gn=Symbol("slots");function lr(t){const{vueFlowRef:e,snapToGrid:n,snapGrid:o,noDragClassName:i,nodeLookup:s,nodeExtent:a,nodeDragThreshold:l,viewport:d,autoPanOnNodeDrag:c,autoPanSpeed:u,nodesDraggable:h,panBy:f,findNode:g,multiSelectionActive:m,nodesSelectionActive:E,selectNodesOnDrag:S,removeSelectedElements:D,addSelectedNodes:B,updateNodePositions:w,emits:M}=pe(),{onStart:G,onDrag:R,onStop:q,onClick:K,el:j,disabled:Z,id:F,selectable:k,dragHandle:W}=t,b=(0,r.shallowRef)(!1);let P=[],v,N=null,I={x:void 0,y:void 0},T={x:0,y:0},z=null,O=!1,L=!1,ee=0,se=!1;const V=Rd(),X=({x:J,y:re})=>{I={x:J,y:re};let x=!1;if(P=P.map(p=>{const y={x:J-p.distance.x,y:re-p.distance.y},{computedPosition:C}=so(p,n.value?hn(y,o.value):y,M.error,a.value,p.parentNode?g(p.parentNode):void 0);return x=x||p.position.x!==C.x||p.position.y!==C.y,p.position=C,p}),L=L||x,!!x&&(w(P,!0,!0),b.value=!0,z)){const[p,y]=ro({id:F,dragItems:P,findNode:g});R({event:z,node:p,nodes:y})}},A=()=>{if(!N)return;const[J,re]=Li(T,N,u.value);if(J!==0||re!==0){const x={x:(I.x??0)-J/d.value.zoom,y:(I.y??0)-re/d.value.zoom};f({x:J,y:re})&&X(x)}ee=requestAnimationFrame(A)},U=(J,re)=>{O=!0;const x=g(F);!S.value&&!m.value&&x&&(x.selected||D()),x&&(0,r.toValue)(k)&&S.value&&uo(x,m.value,B,D,E,!1,re);const p=V(J.sourceEvent);if(I=p,P=hd(s.value,h.value,p,F),P.length){const[y,C]=ro({id:F,dragItems:P,findNode:g});G({event:J.sourceEvent,node:y,nodes:C})}},te=(J,re)=>{var x;J.sourceEvent.type==="touchmove"&&J.sourceEvent.touches.length>1||(L=!1,l.value===0&&U(J,re),I=V(J.sourceEvent),N=((x=e.value)==null?void 0:x.getBoundingClientRect())||null,T=Pe(J.sourceEvent,N))},ie=(J,re)=>{const x=V(J.sourceEvent);if(!se&&O&&c.value&&(se=!0,A()),!O){const p=x.xSnapped-(I.x??0),y=x.ySnapped-(I.y??0);Math.sqrt(p*p+y*y)>l.value&&U(J,re)}(I.x!==x.xSnapped||I.y!==x.ySnapped)&&P.length&&O&&(z=J.sourceEvent,T=Pe(J.sourceEvent,N),X(x))},le=J=>{let re=!1;if(!O&&!b.value&&!m.value){const x=J.sourceEvent,p=V(x),y=p.xSnapped-(I.x??0),C=p.ySnapped-(I.y??0),_=Math.sqrt(y*y+C*C);_!==0&&_<=l.value&&(K?.(x),re=!0)}if(P.length&&!re){L&&(w(P,!1,!1),L=!1);const[x,p]=ro({id:F,dragItems:P,findNode:g});q({event:J.sourceEvent,node:x,nodes:p})}P=[],b.value=!1,se=!1,O=!1,I={x:void 0,y:void 0},cancelAnimationFrame(ee)};return(0,r.watch)([()=>(0,r.toValue)(Z),j],([J,re],x,p)=>{if(re){const y=Te(re);J||(v=ol().on("start",C=>te(C,re)).on("drag",C=>ie(C,re)).on("end",C=>le(C)).filter(C=>{const _=C.target,Y=(0,r.toValue)(W);return!C.button&&(!i.value||!Xi(_,`.${i.value}`,re)&&(!Y||Xi(_,Y,re)))}),y.call(v)),p(()=>{y.on(".drag",null),v&&(v.on("start",null),v.on("drag",null),v.on("end",null))})}}),b}function Bd(){return{doubleClick:ne(),click:ne(),mouseEnter:ne(),mouseMove:ne(),mouseLeave:ne(),contextMenu:ne(),updateStart:ne(),update:ne(),updateEnd:ne()}}function zd(t,e){const n=Bd();return n.doubleClick.on(o=>{var i,s;e.edgeDoubleClick(o),(s=(i=t.events)==null?void 0:i.doubleClick)==null||s.call(i,o)}),n.click.on(o=>{var i,s;e.edgeClick(o),(s=(i=t.events)==null?void 0:i.click)==null||s.call(i,o)}),n.mouseEnter.on(o=>{var i,s;e.edgeMouseEnter(o),(s=(i=t.events)==null?void 0:i.mouseEnter)==null||s.call(i,o)}),n.mouseMove.on(o=>{var i,s;e.edgeMouseMove(o),(s=(i=t.events)==null?void 0:i.mouseMove)==null||s.call(i,o)}),n.mouseLeave.on(o=>{var i,s;e.edgeMouseLeave(o),(s=(i=t.events)==null?void 0:i.mouseLeave)==null||s.call(i,o)}),n.contextMenu.on(o=>{var i,s;e.edgeContextMenu(o),(s=(i=t.events)==null?void 0:i.contextMenu)==null||s.call(i,o)}),n.updateStart.on(o=>{var i,s;e.edgeUpdateStart(o),(s=(i=t.events)==null?void 0:i.updateStart)==null||s.call(i,o)}),n.update.on(o=>{var i,s;e.edgeUpdate(o),(s=(i=t.events)==null?void 0:i.update)==null||s.call(i,o)}),n.updateEnd.on(o=>{var i,s;e.edgeUpdateEnd(o),(s=(i=t.events)==null?void 0:i.updateEnd)==null||s.call(i,o)}),Object.entries(n).reduce((o,[i,s])=>(o.emit[i]=s.trigger,o.on[i]=s.on,o),{emit:{},on:{}})}function Rd(){const{viewport:t,snapGrid:e,snapToGrid:n,vueFlowRef:o}=pe();return i=>{var s;const a=((s=o.value)==null?void 0:s.getBoundingClientRect())??{left:0,top:0},{x:l,y:d}=Pe(_d(i)?i.sourceEvent:i,a),c=At({x:l,y:d},t.value),{x:u,y:h}=n.value?hn(c,e.value):c;return{xSnapped:u,ySnapped:h,...c}}}function pn(){return!0}function cr({handleId:t,nodeId:e,type:n,isValidConnection:o,edgeUpdaterType:i,onEdgeUpdate:s,onEdgeUpdateEnd:a}){const{id:l,vueFlowRef:d,connectionMode:c,connectionRadius:u,connectOnClick:h,connectionClickStartHandle:f,nodesConnectable:g,autoPanOnConnect:m,autoPanSpeed:E,findNode:S,panBy:D,startConnection:B,updateConnection:w,endConnection:M,emits:G,viewport:R,edges:q,nodes:K,isValidConnection:j,nodeLookup:Z}=pe();let F=null,k=!1,W=null;function b(v){var N;const I=(0,r.toValue)(n)==="target",T=ao(v),z=Ti(v.target),O=v.currentTarget;if(O&&(T&&v.button===0||!T)){let L=function(oe){x=Pe(oe,le),X=xd(At(x,R.value,!1,[1,1]),u.value,Z.value,C),p||(y(),p=!0);const Q=qi(oe,{handle:X,connectionMode:c.value,fromNodeId:(0,r.toValue)(e),fromHandleId:(0,r.toValue)(t),fromType:I?"target":"source",isValidConnection:V,doc:z,lib:"vue",flowId:l,nodeLookup:Z.value},q.value,K.value,S,Z.value);W=Q.handleDomNode,F=Q.connection,k=kd(!!X,Q.isValid);const ue={...H,isValid:k,to:Q.toHandle&&k?Rt({x:Q.toHandle.x,y:Q.toHandle.y},R.value):x,toHandle:Q.toHandle,toPosition:k&&Q.toHandle?Q.toHandle.position:co[C.position],toNode:Q.toHandle?Z.value.get(Q.toHandle.nodeId):null};if(k&&X&&H?.toHandle&&ue.toHandle&&H.toHandle.type===ue.toHandle.type&&H.toHandle.nodeId===ue.toHandle.nodeId&&H.toHandle.id===ue.toHandle.id&&H.to.x===ue.to.x&&H.to.y===ue.to.y)return;const fe=X??Q.toHandle;if(w(fe&&k?Rt({x:fe.x,y:fe.y},R.value):x,fe,Nd(!!fe,k)),H=ue,!X&&!k&&!W)return lo(re);F&&F.source!==F.target&&W&&(lo(re),re=W,W.classList.add("connecting","vue-flow__handle-connecting"),W.classList.toggle("valid",!!k),W.classList.toggle("vue-flow__handle-valid",!!k))},ee=function(oe){"touches"in oe&&oe.touches.length>0||((X||W)&&F&&k&&(s?s(oe,F):G.connect(F)),G.connectEnd(oe),i&&a?.(oe),lo(re),cancelAnimationFrame(A),M(oe),p=!1,k=!1,F=null,W=null,z.removeEventListener("mousemove",L),z.removeEventListener("mouseup",ee),z.removeEventListener("touchmove",L),z.removeEventListener("touchend",ee))};const se=S((0,r.toValue)(e));let V=(0,r.toValue)(o)||j.value||pn;!V&&se&&(V=(I?se.isValidSourcePos:se.isValidTargetPos)||pn);let X,A=0;const{x:U,y:te}=Pe(v),ie=Ji((0,r.toValue)(i),O),le=(N=d.value)==null?void 0:N.getBoundingClientRect();if(!le||!ie)return;const J=Qi((0,r.toValue)(e),ie,(0,r.toValue)(t),Z.value,c.value);if(!J)return;let re,x=Pe(v,le),p=!1;const y=()=>{if(!m.value)return;const[oe,Q]=Li(x,le,E.value);D({x:oe,y:Q}),A=requestAnimationFrame(y)},C={...J,nodeId:(0,r.toValue)(e),type:ie,position:J.position},_=Z.value.get((0,r.toValue)(e)),Y={inProgress:!0,isValid:null,from:gt(_,C,ae.Left,!0),fromHandle:C,fromPosition:C.position,fromNode:_,to:x,toHandle:null,toPosition:co[C.position],toNode:null};B({nodeId:(0,r.toValue)(e),id:(0,r.toValue)(t),type:ie,position:O?.getAttribute("data-handlepos")||ae.Top,...x},{x:U-le.left,y:te-le.top}),G.connectStart({event:v,nodeId:(0,r.toValue)(e),handleId:(0,r.toValue)(t),handleType:ie});let H=Y;z.addEventListener("mousemove",L),z.addEventListener("mouseup",ee),z.addEventListener("touchmove",L),z.addEventListener("touchend",ee)}}function P(v){var N,I;if(!h.value)return;const T=(0,r.toValue)(n)==="target";if(!f.value){G.clickConnectStart({event:v,nodeId:(0,r.toValue)(e),handleId:(0,r.toValue)(t)}),B({nodeId:(0,r.toValue)(e),type:(0,r.toValue)(n),id:(0,r.toValue)(t),position:ae.Top,...Pe(v)},void 0,!0);return}let z=(0,r.toValue)(o)||j.value||pn;const O=S((0,r.toValue)(e));if(!z&&O&&(z=(T?O.isValidSourcePos:O.isValidTargetPos)||pn),O&&(typeof O.connectable>"u"?g.value:O.connectable)===!1)return;const L=Ti(v.target),ee=qi(v,{handle:{nodeId:(0,r.toValue)(e),id:(0,r.toValue)(t),type:(0,r.toValue)(n),position:ae.Top,...Pe(v)},connectionMode:c.value,fromNodeId:f.value.nodeId,fromHandleId:f.value.id??null,fromType:f.value.type,isValidConnection:z,doc:L,lib:"vue",flowId:l,nodeLookup:Z.value},q.value,K.value,S,Z.value),se=((N=ee.connection)==null?void 0:N.source)===((I=ee.connection)==null?void 0:I.target);ee.isValid&&ee.connection&&!se&&G.connect(ee.connection),G.clickConnectEnd(v),M(v,!0)}return{handlePointerDown:b,handleClick:P}}function Ad(){return(0,r.inject)(sr,"")}function dr(t){const e=t??Ad()??"",n=(0,r.inject)(ar,(0,r.ref)(null)),{findNode:o,edges:i,emits:s}=pe(),a=o(e);return a||s.error(new we(ve.NODE_NOT_FOUND,e)),{id:e,nodeEl:n,node:a,parentNode:(0,r.computed)(()=>o(a.parentNode)),connectedEdges:(0,r.computed)(()=>$i([a],i.value))}}function $d(){return{doubleClick:ne(),click:ne(),mouseEnter:ne(),mouseMove:ne(),mouseLeave:ne(),contextMenu:ne(),dragStart:ne(),drag:ne(),dragStop:ne()}}function Pd(t,e){const n=$d();return n.doubleClick.on(o=>{var i,s;e.nodeDoubleClick(o),(s=(i=t.events)==null?void 0:i.doubleClick)==null||s.call(i,o)}),n.click.on(o=>{var i,s;e.nodeClick(o),(s=(i=t.events)==null?void 0:i.click)==null||s.call(i,o)}),n.mouseEnter.on(o=>{var i,s;e.nodeMouseEnter(o),(s=(i=t.events)==null?void 0:i.mouseEnter)==null||s.call(i,o)}),n.mouseMove.on(o=>{var i,s;e.nodeMouseMove(o),(s=(i=t.events)==null?void 0:i.mouseMove)==null||s.call(i,o)}),n.mouseLeave.on(o=>{var i,s;e.nodeMouseLeave(o),(s=(i=t.events)==null?void 0:i.mouseLeave)==null||s.call(i,o)}),n.contextMenu.on(o=>{var i,s;e.nodeContextMenu(o),(s=(i=t.events)==null?void 0:i.contextMenu)==null||s.call(i,o)}),n.dragStart.on(o=>{var i,s;e.nodeDragStart(o),(s=(i=t.events)==null?void 0:i.dragStart)==null||s.call(i,o)}),n.drag.on(o=>{var i,s;e.nodeDrag(o),(s=(i=t.events)==null?void 0:i.drag)==null||s.call(i,o)}),n.dragStop.on(o=>{var i,s;e.nodeDragStop(o),(s=(i=t.events)==null?void 0:i.dragStop)==null||s.call(i,o)}),Object.entries(n).reduce((o,[i,s])=>(o.emit[i]=s.trigger,o.on[i]=s.on,o),{emit:{},on:{}})}function ur(){const{getSelectedNodes:t,nodeExtent:e,updateNodePositions:n,findNode:o,snapGrid:i,snapToGrid:s,nodesDraggable:a,emits:l}=pe();return(d,c=!1)=>{const u=s.value?i.value[0]:5,h=s.value?i.value[1]:5,f=c?4:1,g=d.x*u*f,m=d.y*h*f,E=[];for(const S of t.value)if(S.draggable||a&&typeof S.draggable>"u"){const{position:D}=so(S,{x:S.computedPosition.x+g,y:S.computedPosition.y+m},l.error,e.value,S.parentNode?o(S.parentNode):void 0);E.push({id:S.id,position:D,from:S.position,distance:{x:d.x,y:d.y},dimensions:S.dimensions})}n(E,!0,!1)}}var mn=.1,Od=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2;function je(){return Pt("Viewport not initialized yet."),Promise.resolve(!1)}var Vd={zoomIn:je,zoomOut:je,zoomTo:je,fitView:je,setCenter:je,fitBounds:je,project:t=>t,screenToFlowCoordinate:t=>t,flowToScreenCoordinate:t=>t,setViewport:je,setTransform:je,getViewport:()=>({x:0,y:0,zoom:1}),getTransform:()=>({x:0,y:0,zoom:1}),viewportInitialized:!1};function Hd(t){function e(o,i){return new Promise(s=>{t.d3Selection&&t.d3Zoom?t.d3Zoom.interpolate(i?.interpolate==="linear"?Nt:qt).scaleBy(go(t.d3Selection,i?.duration,i?.ease,()=>{s(!0)}),o):s(!1)})}function n(o,i,s,a){return new Promise(l=>{var d;const{x:c,y:u}=Di({x:-o,y:-i},t.translateExtent),h=ut.translate(-c,-u).scale(s);t.d3Selection&&t.d3Zoom?(d=t.d3Zoom)==null||d.interpolate(a?.interpolate==="linear"?Nt:qt).transform(go(t.d3Selection,a?.duration,a?.ease,()=>{l(!0)}),h):l(!1)})}return(0,r.computed)(()=>t.d3Zoom&&t.d3Selection&&t.dimensions.width&&t.dimensions.height?{viewportInitialized:!0,zoomIn:o=>e(1.2,o),zoomOut:o=>e(1/1.2,o),zoomTo:(o,i)=>new Promise(s=>{t.d3Selection&&t.d3Zoom?t.d3Zoom.interpolate(i?.interpolate==="linear"?Nt:qt).scaleTo(go(t.d3Selection,i?.duration,i?.ease,()=>{s(!0)}),o):s(!1)}),setViewport:(o,i)=>n(o.x,o.y,o.zoom,i),setTransform:(o,i)=>n(o.x,o.y,o.zoom,i),getViewport:()=>({x:t.viewport.x,y:t.viewport.y,zoom:t.viewport.zoom}),getTransform:()=>({x:t.viewport.x,y:t.viewport.y,zoom:t.viewport.zoom}),fitView:(o={padding:mn,includeHiddenNodes:!1,duration:0})=>{var i,s;const a=[];for(const u of t.nodes)u.dimensions.width&&u.dimensions.height&&(o?.includeHiddenNodes||!u.hidden)&&(!((i=o.nodes)!=null&&i.length)||(s=o.nodes)!=null&&s.length&&o.nodes.includes(u.id))&&a.push(u);if(!a.length)return Promise.resolve(!1);const{x:l,y:d,zoom:c}=Pi(Ri(a),t.dimensions.width,t.dimensions.height,o.minZoom??t.minZoom,o.maxZoom??t.maxZoom,o.padding??mn);return n(l,d,c,o)},setCenter:(o,i,s)=>{const a=typeof s?.zoom<"u"?s.zoom:t.maxZoom;return n(t.dimensions.width/2-o*a,t.dimensions.height/2-i*a,a,s)},fitBounds:(o,i={padding:mn})=>{const{x:s,y:a,zoom:l}=Pi(o,t.dimensions.width,t.dimensions.height,t.minZoom,t.maxZoom,i.padding??mn);return n(s,a,l,i)},project:o=>At(o,t.viewport,t.snapToGrid,t.snapGrid),screenToFlowCoordinate:o=>{if(t.vueFlowRef){const{x:i,y:s}=t.vueFlowRef.getBoundingClientRect();return At({x:o.x-i,y:o.y-s},t.viewport,t.snapToGrid,t.snapGrid)}return{x:0,y:0}},flowToScreenCoordinate:o=>{if(t.vueFlowRef){const{x:i,y:s}=t.vueFlowRef.getBoundingClientRect();return Rt({x:o.x+i,y:o.y+s},t.viewport)}return{x:0,y:0}}}:Vd)}function go(t,e=0,n=Od,o=()=>{}){const i=typeof e=="number"&&e>0;return i||o(),i?t.transition().duration(e).ease(n).on("end",o):t}function Ld(t,e,n){const o=(0,r.effectScope)(!0);return o.run(()=>{const i=()=>{o.run(()=>{let E,S,D=!!(n.nodes.value.length||n.edges.value.length);E=st([t.modelValue,()=>{var B,w;return(w=(B=t.modelValue)==null?void 0:B.value)==null?void 0:w.length}],([B])=>{B&&Array.isArray(B)&&(S?.pause(),n.setElements(B),!S&&!D&&B.length?D=!0:S?.resume())}),S=st([n.nodes,n.edges,()=>n.edges.value.length,()=>n.nodes.value.length],([B,w])=>{var M;(M=t.modelValue)!=null&&M.value&&Array.isArray(t.modelValue.value)&&(E?.pause(),t.modelValue.value=[...B,...w],(0,r.nextTick)(()=>{E?.resume()}))},{immediate:D}),(0,r.onScopeDispose)(()=>{E?.stop(),S?.stop()})})},s=()=>{o.run(()=>{let E,S,D=!!n.nodes.value.length;E=st([t.nodes,()=>{var B,w;return(w=(B=t.nodes)==null?void 0:B.value)==null?void 0:w.length}],([B])=>{B&&Array.isArray(B)&&(S?.pause(),n.setNodes(B),!S&&!D&&B.length?D=!0:S?.resume())}),S=st([n.nodes,()=>n.nodes.value.length],([B])=>{var w;(w=t.nodes)!=null&&w.value&&Array.isArray(t.nodes.value)&&(E?.pause(),t.nodes.value=[...B],(0,r.nextTick)(()=>{E?.resume()}))},{immediate:D}),(0,r.onScopeDispose)(()=>{E?.stop(),S?.stop()})})},a=()=>{o.run(()=>{let E,S,D=!!n.edges.value.length;E=st([t.edges,()=>{var B,w;return(w=(B=t.edges)==null?void 0:B.value)==null?void 0:w.length}],([B])=>{B&&Array.isArray(B)&&(S?.pause(),n.setEdges(B),!S&&!D&&B.length?D=!0:S?.resume())}),S=st([n.edges,()=>n.edges.value.length],([B])=>{var w;(w=t.edges)!=null&&w.value&&Array.isArray(t.edges.value)&&(E?.pause(),t.edges.value=[...B],(0,r.nextTick)(()=>{E?.resume()}))},{immediate:D}),(0,r.onScopeDispose)(()=>{E?.stop(),S?.stop()})})},l=()=>{o.run(()=>{(0,r.watch)(()=>e.maxZoom,()=>{e.maxZoom&&_e(e.maxZoom)&&n.setMaxZoom(e.maxZoom)},{immediate:!0})})},d=()=>{o.run(()=>{(0,r.watch)(()=>e.minZoom,()=>{e.minZoom&&_e(e.minZoom)&&n.setMinZoom(e.minZoom)},{immediate:!0})})},c=()=>{o.run(()=>{(0,r.watch)(()=>e.translateExtent,()=>{e.translateExtent&&_e(e.translateExtent)&&n.setTranslateExtent(e.translateExtent)},{immediate:!0})})},u=()=>{o.run(()=>{(0,r.watch)(()=>e.nodeExtent,()=>{e.nodeExtent&&_e(e.nodeExtent)&&n.setNodeExtent(e.nodeExtent)},{immediate:!0})})},h=()=>{o.run(()=>{(0,r.watch)(()=>e.applyDefault,()=>{_e(e.applyDefault)&&(n.applyDefault.value=e.applyDefault)},{immediate:!0})})},f=()=>{o.run(()=>{const E=async S=>{let D=S;typeof e.autoConnect=="function"&&(D=await e.autoConnect(S)),D!==!1&&n.addEdges([D])};(0,r.watch)(()=>e.autoConnect,()=>{_e(e.autoConnect)&&(n.autoConnect.value=e.autoConnect)},{immediate:!0}),(0,r.watch)(n.autoConnect,(S,D,B)=>{S?n.onConnect(E):n.hooks.value.connect.off(E),B(()=>{n.hooks.value.connect.off(E)})},{immediate:!0})})},g=()=>{const E=["id","modelValue","translateExtent","nodeExtent","edges","nodes","maxZoom","minZoom","applyDefault","autoConnect"];for(const S of Object.keys(e)){const D=S;if(!E.includes(D)){const B=(0,r.toRef)(()=>e[D]),w=n[D];(0,r.isRef)(w)&&o.run(()=>{(0,r.watch)(B,M=>{_e(M)&&(w.value=M)},{immediate:!0})})}}};i(),s(),a(),d(),l(),c(),u(),h(),f(),g()}),()=>o.stop()}function Fd(){return{edgesChange:ne(),nodesChange:ne(),nodeDoubleClick:ne(),nodeClick:ne(),nodeMouseEnter:ne(),nodeMouseMove:ne(),nodeMouseLeave:ne(),nodeContextMenu:ne(),nodeDragStart:ne(),nodeDrag:ne(),nodeDragStop:ne(),nodesInitialized:ne(),miniMapNodeClick:ne(),miniMapNodeDoubleClick:ne(),miniMapNodeMouseEnter:ne(),miniMapNodeMouseMove:ne(),miniMapNodeMouseLeave:ne(),connect:ne(),connectStart:ne(),connectEnd:ne(),clickConnectStart:ne(),clickConnectEnd:ne(),paneReady:ne(),init:ne(),move:ne(),moveStart:ne(),moveEnd:ne(),selectionDragStart:ne(),selectionDrag:ne(),selectionDragStop:ne(),selectionContextMenu:ne(),selectionStart:ne(),selectionEnd:ne(),viewportChangeStart:ne(),viewportChange:ne(),viewportChangeEnd:ne(),paneScroll:ne(),paneClick:ne(),paneContextMenu:ne(),paneMouseEnter:ne(),paneMouseMove:ne(),paneMouseLeave:ne(),edgeContextMenu:ne(),edgeMouseEnter:ne(),edgeMouseMove:ne(),edgeMouseLeave:ne(),edgeDoubleClick:ne(),edgeClick:ne(),edgeUpdateStart:ne(),edgeUpdate:ne(),edgeUpdateEnd:ne(),updateNodeInternals:ne(),error:ne(t=>Pt(t.message))}}function Gd(t,e){const n=(0,r.getCurrentInstance)();(0,r.onBeforeMount)(()=>{for(const[i,s]of Object.entries(e.value)){const a=l=>{t(i,l)};s.setEmitter(a),_t(s.removeEmitter),s.setHasEmitListeners(()=>o(i)),_t(s.removeHasEmitListeners)}});function o(i){var s;const a=Wd(i);return!!((s=n?.vnode.props)!=null&&s[a])}}function Wd(t){const[e,...n]=t.split(":");return`on${e.replace(/(?:^|-)(\w)/g,(o,i)=>i.toUpperCase())}${n.length?`:${n.join(":")}`:""}`}function fr(){return{vueFlowRef:null,viewportRef:null,nodes:[],edges:[],connectionLookup:new Map,nodeTypes:{},edgeTypes:{},initialized:!1,dimensions:{width:0,height:0},viewport:{x:0,y:0,zoom:1},d3Zoom:null,d3Selection:null,d3ZoomHandler:null,minZoom:.5,maxZoom:2,translateExtent:[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],nodeExtent:[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],selectionMode:no.Full,paneDragging:!1,preventScrolling:!0,zoomOnScroll:!0,zoomOnPinch:!0,zoomOnDoubleClick:!0,panOnScroll:!1,panOnScrollSpeed:.5,panOnScrollMode:It.Free,paneClickDistance:0,panOnDrag:!0,edgeUpdaterRadius:10,onlyRenderVisibleElements:!1,defaultViewport:{x:0,y:0,zoom:1},nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,defaultMarkerColor:"#b1b1b7",connectionLineStyle:{},connectionLineType:null,connectionLineOptions:{type:nt.Bezier,style:{}},connectionMode:Fe.Loose,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectionPosition:{x:NaN,y:NaN},connectionRadius:20,connectOnClick:!0,connectionStatus:null,isValidConnection:null,snapGrid:[15,15],snapToGrid:!1,edgesUpdatable:!1,edgesFocusable:!0,nodesFocusable:!0,nodesConnectable:!0,nodesDraggable:!0,nodeDragThreshold:1,elementsSelectable:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,selectionKeyCode:"Shift",multiSelectionKeyCode:fn()?"Meta":"Control",zoomActivationKeyCode:fn()?"Meta":"Control",deleteKeyCode:"Backspace",panActivationKeyCode:"Space",hooks:Fd(),applyDefault:!0,autoConnect:!1,fitViewOnInit:!1,fitViewOnInitDone:!1,noDragClassName:"nodrag",noWheelClassName:"nowheel",noPanClassName:"nopan",defaultEdgeOptions:void 0,elevateEdgesOnSelect:!1,elevateNodesOnSelect:!0,autoPanOnNodeDrag:!0,autoPanOnConnect:!0,autoPanSpeed:15,disableKeyboardA11y:!1,ariaLiveMessage:""}}var Ud=["id","vueFlowRef","viewportRef","initialized","modelValue","nodes","edges","maxZoom","minZoom","translateExtent","hooks","defaultEdgeOptions"];function Yd(t,e,n){const o=Hd(t),i=x=>{const p=x??[];t.hooks.updateNodeInternals.trigger(p)},s=x=>sd(x,t.nodes,t.edges),a=x=>rd(x,t.nodes,t.edges),l=x=>$i(x,t.edges),d=({id:x,type:p,nodeId:y})=>{var C;const _=x?`-${p}-${x}`:`-${p}`;return Array.from(((C=t.connectionLookup.get(`${y}${_}`))==null?void 0:C.values())??[])},c=x=>{if(x)return e.value.get(x)},u=x=>{if(x)return n.value.get(x)},h=(x,p,y)=>{var C,_;const Y=[];for(const H of x){const oe={id:H.id,type:"position",dragging:y,from:H.from};if(p&&(oe.position=H.position,H.parentNode)){const Q=c(H.parentNode);oe.position={x:oe.position.x-(((C=Q?.computedPosition)==null?void 0:C.x)??0),y:oe.position.y-(((_=Q?.computedPosition)==null?void 0:_.y)??0)}}Y.push(oe)}Y?.length&&t.hooks.nodesChange.trigger(Y)},f=x=>{if(!t.vueFlowRef)return;const p=t.vueFlowRef.querySelector(".vue-flow__transformationpane");if(!p)return;const y=window.getComputedStyle(p),{m22:C}=new window.DOMMatrixReadOnly(y.transform),_=[];for(const Y of x){const H=Y,oe=c(H.id);if(oe){const Q=dn(H.nodeElement);if(Q.width&&Q.height&&(oe.dimensions.width!==Q.width||oe.dimensions.height!==Q.height||H.forceUpdate)){const ue=H.nodeElement.getBoundingClientRect();oe.dimensions=Q,oe.handleBounds.source=tr("source",H.nodeElement,ue,C,oe.id),oe.handleBounds.target=tr("target",H.nodeElement,ue,C,oe.id),_.push({id:oe.id,type:"dimensions",dimensions:Q})}}}!t.fitViewOnInitDone&&t.fitViewOnInit&&o.value.fitView().then(()=>{t.fitViewOnInitDone=!0}),_.length&&t.hooks.nodesChange.trigger(_)},g=(x,p)=>{const y=new Set,C=new Set;for(const H of x)it(H)?y.add(H.id):Ue(H)&&C.add(H.id);const _=Xe(e.value,y,!0),Y=Xe(n.value,C);if(t.multiSelectionActive){for(const H of y)_.push(Ye(H,p));for(const H of C)Y.push(Ye(H,p))}_.length&&t.hooks.nodesChange.trigger(_),Y.length&&t.hooks.edgesChange.trigger(Y)},m=x=>{if(t.multiSelectionActive){const p=x.map(y=>Ye(y.id,!0));t.hooks.nodesChange.trigger(p);return}t.hooks.nodesChange.trigger(Xe(e.value,new Set(x.map(p=>p.id)),!0)),t.hooks.edgesChange.trigger(Xe(n.value))},E=x=>{if(t.multiSelectionActive){const p=x.map(y=>Ye(y.id,!0));t.hooks.edgesChange.trigger(p);return}t.hooks.edgesChange.trigger(Xe(n.value,new Set(x.map(p=>p.id)))),t.hooks.nodesChange.trigger(Xe(e.value,new Set,!0))},S=x=>{g(x,!0)},D=x=>{const p=(x||t.nodes).map(y=>(y.selected=!1,Ye(y.id,!1)));t.hooks.nodesChange.trigger(p)},B=x=>{const p=(x||t.edges).map(y=>(y.selected=!1,Ye(y.id,!1)));t.hooks.edgesChange.trigger(p)},w=x=>{if(!x||!x.length)return g([],!1);const p=x.reduce((y,C)=>{const _=Ye(C.id,!1);return it(C)?y.nodes.push(_):y.edges.push(_),y},{nodes:[],edges:[]});p.nodes.length&&t.hooks.nodesChange.trigger(p.nodes),p.edges.length&&t.hooks.edgesChange.trigger(p.edges)},M=x=>{var p;(p=t.d3Zoom)==null||p.scaleExtent([x,t.maxZoom]),t.minZoom=x},G=x=>{var p;(p=t.d3Zoom)==null||p.scaleExtent([t.minZoom,x]),t.maxZoom=x},R=x=>{var p;(p=t.d3Zoom)==null||p.translateExtent(x),t.translateExtent=x},q=x=>{t.nodeExtent=x,i()},K=x=>{var p;(p=t.d3Zoom)==null||p.clickDistance(x)},j=x=>{t.nodesDraggable=x,t.nodesConnectable=x,t.elementsSelectable=x},Z=x=>{const p=x instanceof Function?x(t.nodes):x;!t.initialized&&!p.length||(t.nodes=nr(p,c,t.hooks.error.trigger))},F=x=>{const p=x instanceof Function?x(t.edges):x;if(!t.initialized&&!p.length)return;const y=ho(p,t.isValidConnection,c,u,t.hooks.error.trigger,t.defaultEdgeOptions,t.nodes,t.edges);fo(t.connectionLookup,n.value,y),t.edges=y},k=x=>{const p=x instanceof Function?x([...t.nodes,...t.edges]):x;!t.initialized&&!p.length||(Z(p.filter(it)),F(p.filter(Ue)))},W=x=>{let p=x instanceof Function?x(t.nodes):x;p=Array.isArray(p)?p:[p];const y=nr(p,c,t.hooks.error.trigger),C=[];for(const _ of y)C.push(Gi(_));C.length&&t.hooks.nodesChange.trigger(C)},b=x=>{let p=x instanceof Function?x(t.edges):x;p=Array.isArray(p)?p:[p];const y=ho(p,t.isValidConnection,c,u,t.hooks.error.trigger,t.defaultEdgeOptions,t.nodes,t.edges),C=[];for(const _ of y)C.push(Gi(_));C.length&&t.hooks.edgesChange.trigger(C)},P=(x,p=!0,y=!1)=>{const C=x instanceof Function?x(t.nodes):x,_=Array.isArray(C)?C:[C],Y=[],H=[];function oe(ue){const fe=l(ue);for(const ge of fe)(!_e(ge.deletable)||ge.deletable)&&H.push(Ui(ge.id,ge.source,ge.target,ge.sourceHandle,ge.targetHandle))}function Q(ue){const fe=[];for(const ge of t.nodes)ge.parentNode===ue&&fe.push(ge);if(fe.length){for(const ge of fe)Y.push(Wi(ge.id));p&&oe(fe);for(const ge of fe)Q(ge.id)}}for(const ue of _){const fe=typeof ue=="string"?c(ue):ue;fe&&(_e(fe.deletable)&&!fe.deletable||(Y.push(Wi(fe.id)),p&&oe([fe]),y&&Q(fe.id)))}H.length&&t.hooks.edgesChange.trigger(H),Y.length&&t.hooks.nodesChange.trigger(Y)},v=x=>{const p=x instanceof Function?x(t.edges):x,y=Array.isArray(p)?p:[p],C=[];for(const _ of y){const Y=typeof _=="string"?u(_):_;Y&&(_e(Y.deletable)&&!Y.deletable||C.push(Ui(typeof _=="string"?_:_.id,Y.source,Y.target,Y.sourceHandle,Y.targetHandle)))}t.hooks.edgesChange.trigger(C)},N=(x,p,y=!0)=>{const C=u(x.id);if(!C)return!1;const _=t.edges.indexOf(C),Y=Td(x,p,C,y,t.hooks.error.trigger);if(Y){const[H]=ho([Y],t.isValidConnection,c,u,t.hooks.error.trigger,t.defaultEdgeOptions,t.nodes,t.edges);return t.edges=t.edges.map((oe,Q)=>Q===_?H:oe),fo(t.connectionLookup,n.value,[H]),H}return!1},I=(x,p,y={replace:!1})=>{const C=u(x);if(!C)return;const _=typeof p=="function"?p(C):p;C.data=y.replace?_:{...C.data,..._}},T=x=>Fi(x,t.nodes),z=x=>{const p=Fi(x,t.edges);return fo(t.connectionLookup,n.value,p),p},O=(x,p,y={replace:!1})=>{const C=c(x);if(!C)return;const _=typeof p=="function"?p(C):p;y.replace?t.nodes.splice(t.nodes.indexOf(C),1,_):Object.assign(C,_)},L=(x,p,y={replace:!1})=>{const C=c(x);if(!C)return;const _=typeof p=="function"?p(C):p;C.data=y.replace?_:{...C.data,..._}},ee=(x,p,y=!1)=>{y?t.connectionClickStartHandle=x:t.connectionStartHandle=x,t.connectionEndHandle=null,t.connectionStatus=null,p&&(t.connectionPosition=p)},se=(x,p=null,y=null)=>{t.connectionStartHandle&&(t.connectionPosition=x,t.connectionEndHandle=p,t.connectionStatus=y)},V=(x,p)=>{t.connectionPosition={x:NaN,y:NaN},t.connectionEndHandle=null,t.connectionStatus=null,p?t.connectionClickStartHandle=null:t.connectionStartHandle=null},X=x=>{const p=od(x),y=p?null:zt(x)?x:c(x.id);return!p&&!y?[null,null,p]:[p?x:ln(y),y,p]},A=(x,p=!0,y=t.nodes)=>{const[C,_,Y]=X(x);if(!C)return[];const H=[];for(const oe of y||t.nodes){if(!Y&&(oe.id===_.id||!oe.computedPosition))continue;const Q=ln(oe),ue=cn(Q,C);(p&&ue>0||ue>=Q.width*Q.height||ue>=Number(C.width)*Number(C.height))&&H.push(oe)}return H},U=(x,p,y=!0)=>{const[C]=X(x);if(!C)return!1;const _=cn(C,p);return y&&_>0||_>=Number(C.width)*Number(C.height)},te=x=>{const{viewport:p,dimensions:y,d3Zoom:C,d3Selection:_,translateExtent:Y}=t;if(!C||!_||!x.x&&!x.y)return!1;const H=ut.translate(p.x+x.x,p.y+x.y).scale(p.zoom),oe=[[0,0],[y.width,y.height]],Q=C.constrain()(H,oe,Y),ue=t.viewport.x!==Q.x||t.viewport.y!==Q.y||t.viewport.zoom!==Q.k;return C.transform(_,Q),ue},ie=x=>{const p=x instanceof Function?x(t):x,y=["d3Zoom","d3Selection","d3ZoomHandler","viewportRef","vueFlowRef","dimensions","hooks"];_e(p.defaultEdgeOptions)&&(t.defaultEdgeOptions=p.defaultEdgeOptions);const C=p.modelValue||p.nodes||p.edges?[]:void 0;C&&(p.modelValue&&C.push(...p.modelValue),p.nodes&&C.push(...p.nodes),p.edges&&C.push(...p.edges),k(C));const _=()=>{_e(p.maxZoom)&&G(p.maxZoom),_e(p.minZoom)&&M(p.minZoom),_e(p.translateExtent)&&R(p.translateExtent)};for(const Y of Object.keys(p)){const H=Y,oe=p[H];![...Ud,...y].includes(H)&&_e(oe)&&(t[H]=oe)}An(()=>t.d3Zoom).not.toBeNull().then(_),t.initialized||(t.initialized=!0)};return{updateNodePositions:h,updateNodeDimensions:f,setElements:k,setNodes:Z,setEdges:F,addNodes:W,addEdges:b,removeNodes:P,removeEdges:v,findNode:c,findEdge:u,updateEdge:N,updateEdgeData:I,updateNode:O,updateNodeData:L,applyEdgeChanges:z,applyNodeChanges:T,addSelectedElements:S,addSelectedNodes:m,addSelectedEdges:E,setMinZoom:M,setMaxZoom:G,setTranslateExtent:R,setNodeExtent:q,setPaneClickDistance:K,removeSelectedElements:w,removeSelectedNodes:D,removeSelectedEdges:B,startConnection:ee,updateConnection:se,endConnection:V,setInteractive:j,setState:ie,getIntersectingNodes:A,getIncomers:s,getOutgoers:a,getConnectedEdges:l,getHandleConnections:d,isNodeIntersecting:U,panBy:te,fitView:x=>o.value.fitView(x),zoomIn:x=>o.value.zoomIn(x),zoomOut:x=>o.value.zoomOut(x),zoomTo:(x,p)=>o.value.zoomTo(x,p),setViewport:(x,p)=>o.value.setViewport(x,p),setTransform:(x,p)=>o.value.setTransform(x,p),getViewport:()=>o.value.getViewport(),getTransform:()=>o.value.getTransform(),setCenter:(x,p,y)=>o.value.setCenter(x,p,y),fitBounds:(x,p)=>o.value.fitBounds(x,p),project:x=>o.value.project(x),screenToFlowCoordinate:x=>o.value.screenToFlowCoordinate(x),flowToScreenCoordinate:x=>o.value.flowToScreenCoordinate(x),toObject:()=>{const x=[],p=[];for(const y of t.nodes){const{computedPosition:C,handleBounds:_,selected:Y,dimensions:H,isParent:oe,resizing:Q,dragging:ue,events:fe,...ge}=y;x.push(ge)}for(const y of t.edges){const{selected:C,sourceNode:_,targetNode:Y,events:H,...oe}=y;p.push(oe)}return JSON.parse(JSON.stringify({nodes:x,edges:p,position:[t.viewport.x,t.viewport.y],zoom:t.viewport.zoom,viewport:t.viewport}))},fromObject:x=>new Promise(p=>{const{nodes:y,edges:C,position:_,zoom:Y,viewport:H}=x;y&&Z(y),C&&F(C);const[oe,Q]=H?.x&&H?.y?[H.x,H.y]:_??[null,null];if(oe&&Q){const ue=H?.zoom||Y||t.viewport.zoom;return An(()=>o.value.viewportInitialized).toBe(!0).then(()=>{o.value.setViewport({x:oe,y:Q,zoom:ue}).then(()=>{p(!0)})})}else p(!0)}),updateNodeInternals:i,viewportHelper:o,$reset:()=>{const x=fr();if(t.edges=[],t.nodes=[],t.d3Zoom&&t.d3Selection){const p=ut.translate(x.defaultViewport.x??0,x.defaultViewport.y??0).scale(ot(x.defaultViewport.zoom??1,x.minZoom,x.maxZoom)),y=t.viewportRef.getBoundingClientRect(),C=[[0,0],[y.width,y.height]],_=t.d3Zoom.constrain()(p,C,x.translateExtent);t.d3Zoom.transform(t.d3Selection,_)}ie(x)},$destroy:()=>{}}}var Xd=["data-id","data-handleid","data-nodeid","data-handlepos"],pt=(0,r.defineComponent)({name:"Handle",compatConfig:{MODE:3},props:{id:{default:null},type:{},position:{default:()=>ae.Top},isValidConnection:{type:Function},connectable:{type:[Boolean,Number,String,Function],default:void 0},connectableStart:{type:Boolean,default:!0},connectableEnd:{type:Boolean,default:!0}},setup(t,{expose:e}){const n=(0,r.createPropsRestProxy)(t,["position","connectable","connectableStart","connectableEnd","id"]),o=(0,r.toRef)(()=>n.type??"source"),i=(0,r.toRef)(()=>n.isValidConnection??null),{id:s,connectionStartHandle:a,connectionClickStartHandle:l,connectionEndHandle:d,vueFlowRef:c,nodesConnectable:u,noDragClassName:h,noPanClassName:f}=pe(),{id:g,node:m,nodeEl:E,connectedEdges:S}=dr(),D=(0,r.ref)(),B=(0,r.toRef)(()=>typeof t.connectableStart<"u"?t.connectableStart:!0),w=(0,r.toRef)(()=>typeof t.connectableEnd<"u"?t.connectableEnd:!0),M=(0,r.toRef)(()=>{var F,k,W,b,P,v;return((F=a.value)==null?void 0:F.nodeId)===g&&((k=a.value)==null?void 0:k.id)===t.id&&((W=a.value)==null?void 0:W.type)===o.value||((b=d.value)==null?void 0:b.nodeId)===g&&((P=d.value)==null?void 0:P.id)===t.id&&((v=d.value)==null?void 0:v.type)===o.value}),G=(0,r.toRef)(()=>{var F,k,W;return((F=l.value)==null?void 0:F.nodeId)===g&&((k=l.value)==null?void 0:k.id)===t.id&&((W=l.value)==null?void 0:W.type)===o.value}),{handlePointerDown:R,handleClick:q}=cr({nodeId:g,handleId:t.id,isValidConnection:i,type:o}),K=(0,r.computed)(()=>typeof t.connectable=="string"&&t.connectable==="single"?!S.value.some(F=>{const k=F[`${o.value}Handle`];return F[o.value]!==g?!1:k?k===t.id:!0}):typeof t.connectable=="number"?S.value.filter(F=>{const k=F[`${o.value}Handle`];return F[o.value]!==g?!1:k?k===t.id:!0}).length<t.connectable:typeof t.connectable=="function"?t.connectable(m,S.value):_e(t.connectable)?t.connectable:u.value);(0,r.onMounted)(()=>{var F;if(!m.dimensions.width||!m.dimensions.height)return;const k=(F=m.handleBounds[o.value])==null?void 0:F.find(T=>T.id===t.id);if(!c.value||k)return;const W=c.value.querySelector(".vue-flow__transformationpane");if(!E.value||!D.value||!W||!t.id)return;const b=E.value.getBoundingClientRect(),P=D.value.getBoundingClientRect(),v=window.getComputedStyle(W),{m22:N}=new window.DOMMatrixReadOnly(v.transform),I={id:t.id,position:t.position,x:(P.left-b.left)/N,y:(P.top-b.top)/N,type:o.value,nodeId:g,...dn(D.value)};m.handleBounds[o.value]=[...m.handleBounds[o.value]??[],I]});function j(F){const k=ao(F);K.value&&B.value&&(k&&F.button===0||!k)&&R(F)}function Z(F){!g||!l.value&&!B.value||K.value&&q(F)}return e({handleClick:q,handlePointerDown:R,onClick:Z,onPointerDown:j}),(F,k)=>((0,r.openBlock)(),(0,r.createElementBlock)("div",{ref_key:"handle",ref:D,"data-id":`${(0,r.unref)(s)}-${(0,r.unref)(g)}-${t.id}-${o.value}`,"data-handleid":t.id,"data-nodeid":(0,r.unref)(g),"data-handlepos":F.position,class:(0,r.normalizeClass)(["vue-flow__handle",[`vue-flow__handle-${F.position}`,`vue-flow__handle-${t.id}`,(0,r.unref)(h),(0,r.unref)(f),o.value,{connectable:K.value,connecting:G.value,connectablestart:B.value,connectableend:w.value,connectionindicator:K.value&&(B.value&&!M.value||w.value&&M.value)}]]),onMousedown:j,onTouchstartPassive:j,onClick:Z},[(0,r.renderSlot)(F.$slots,"default",{id:F.id})],42,Xd))}}),yn=function({sourcePosition:t=ae.Bottom,targetPosition:e=ae.Top,label:n,connectable:o=!0,isValidTargetPos:i,isValidSourcePos:s,data:a}){const l=a.label??n;return[(0,r.h)(pt,{type:"target",position:e,connectable:o,isValidConnection:i}),typeof l!="string"&&l?(0,r.h)(l):(0,r.h)(r.Fragment,[l]),(0,r.h)(pt,{type:"source",position:t,connectable:o,isValidConnection:s})]};yn.props=["sourcePosition","targetPosition","label","isValidTargetPos","isValidSourcePos","connectable","data"],yn.inheritAttrs=!1,yn.compatConfig={MODE:3};var jd=yn,vn=function({targetPosition:t=ae.Top,label:e,connectable:n=!0,isValidTargetPos:o,data:i}){const s=i.label??e;return[(0,r.h)(pt,{type:"target",position:t,connectable:n,isValidConnection:o}),typeof s!="string"&&s?(0,r.h)(s):(0,r.h)(r.Fragment,[s])]};vn.props=["targetPosition","label","isValidTargetPos","connectable","data"],vn.inheritAttrs=!1,vn.compatConfig={MODE:3};var Zd=vn,_n=function({sourcePosition:t=ae.Bottom,label:e,connectable:n=!0,isValidSourcePos:o,data:i}){const s=i.label??e;return[typeof s!="string"&&s?(0,r.h)(s):(0,r.h)(r.Fragment,[s]),(0,r.h)(pt,{type:"source",position:t,connectable:n,isValidConnection:o})]};_n.props=["sourcePosition","label","isValidSourcePos","connectable","data"],_n.inheritAttrs=!1,_n.compatConfig={MODE:3};var Kd=_n,qd=["transform"],Jd=["width","height","x","y","rx","ry"],Qd=["y"],eu=(0,r.defineComponent)({name:"EdgeText",compatConfig:{MODE:3},props:{x:{},y:{},label:{},labelStyle:{default:()=>({})},labelShowBg:{type:Boolean,default:!0},labelBgStyle:{default:()=>({})},labelBgPadding:{default:()=>[2,4]},labelBgBorderRadius:{default:2}},setup(t){const e=(0,r.ref)({x:0,y:0,width:0,height:0}),n=(0,r.ref)(null),o=(0,r.computed)(()=>`translate(${t.x-e.value.width/2} ${t.y-e.value.height/2})`);(0,r.onMounted)(i),(0,r.watch)([()=>t.x,()=>t.y,n,()=>t.label],i);function i(){if(!n.value)return;const s=n.value.getBBox();(s.width!==e.value.width||s.height!==e.value.height)&&(e.value=s)}return(s,a)=>((0,r.openBlock)(),(0,r.createElementBlock)("g",{transform:o.value,class:"vue-flow__edge-textwrapper"},[s.labelShowBg?((0,r.openBlock)(),(0,r.createElementBlock)("rect",{key:0,class:"vue-flow__edge-textbg",width:`${e.value.width+2*s.labelBgPadding[0]}px`,height:`${e.value.height+2*s.labelBgPadding[1]}px`,x:-s.labelBgPadding[0],y:-s.labelBgPadding[1],style:(0,r.normalizeStyle)(s.labelBgStyle),rx:s.labelBgBorderRadius,ry:s.labelBgBorderRadius},null,12,Jd)):(0,r.createCommentVNode)("",!0),(0,r.createElementVNode)("text",(0,r.mergeProps)(s.$attrs,{ref_key:"el",ref:n,class:"vue-flow__edge-text",y:e.value.height/2,dy:"0.3em",style:s.labelStyle}),[(0,r.renderSlot)(s.$slots,"default",{},()=>[typeof s.label!="string"?((0,r.openBlock)(),(0,r.createBlock)((0,r.resolveDynamicComponent)(s.label),{key:0})):((0,r.openBlock)(),(0,r.createElementBlock)(r.Fragment,{key:1},[(0,r.createTextVNode)((0,r.toDisplayString)(s.label),1)],64))])],16,Qd)],8,qd))}}),tu=["id","d","marker-end","marker-start"],nu=["d","stroke-width"],Ot=(0,r.defineComponent)({name:"BaseEdge",inheritAttrs:!1,compatConfig:{MODE:3},props:{id:{},labelX:{},labelY:{},path:{},label:{},markerStart:{},markerEnd:{},interactionWidth:{default:20},labelStyle:{},labelShowBg:{type:Boolean},labelBgStyle:{},labelBgPadding:{},labelBgBorderRadius:{}},setup(t,{expose:e}){const n=(0,r.ref)(null),o=(0,r.ref)(null),i=(0,r.ref)(null),s=(0,r.useAttrs)();return e({pathEl:n,interactionEl:o,labelEl:i}),(a,l)=>((0,r.openBlock)(),(0,r.createElementBlock)(r.Fragment,null,[(0,r.createElementVNode)("path",(0,r.mergeProps)((0,r.unref)(s),{id:a.id,ref_key:"pathEl",ref:n,d:a.path,class:"vue-flow__edge-path","marker-end":a.markerEnd,"marker-start":a.markerStart}),null,16,tu),a.interactionWidth?((0,r.openBlock)(),(0,r.createElementBlock)("path",{key:0,ref_key:"interactionEl",ref:o,fill:"none",d:a.path,"stroke-width":a.interactionWidth,"stroke-opacity":0,class:"vue-flow__edge-interaction"},null,8,nu)):(0,r.createCommentVNode)("",!0),a.label&&a.labelX&&a.labelY?((0,r.openBlock)(),(0,r.createBlock)(eu,{key:1,ref_key:"labelEl",ref:i,x:a.labelX,y:a.labelY,label:a.label,"label-show-bg":a.labelShowBg,"label-bg-style":a.labelBgStyle,"label-bg-padding":a.labelBgPadding,"label-bg-border-radius":a.labelBgBorderRadius,"label-style":a.labelStyle},null,8,["x","y","label","label-show-bg","label-bg-style","label-bg-padding","label-bg-border-radius","label-style"])):(0,r.createCommentVNode)("",!0)],64))}});function hr({sourceX:t,sourceY:e,targetX:n,targetY:o}){const i=Math.abs(n-t)/2,s=n<t?n+i:n-i,a=Math.abs(o-e)/2;return[s,o<e?o+a:o-a,i,a]}function gr({sourceX:t,sourceY:e,targetX:n,targetY:o,sourceControlX:i,sourceControlY:s,targetControlX:a,targetControlY:l}){const d=t*.125+i*.375+a*.375+n*.125,c=e*.125+s*.375+l*.375+o*.125;return[d,c,Math.abs(d-t),Math.abs(c-e)]}function wn(t,e){return t>=0?.5*t:e*25*Math.sqrt(-t)}function pr({pos:t,x1:e,y1:n,x2:o,y2:i,c:s}){let a,l;switch(t){case ae.Left:a=e-wn(e-o,s),l=n;break;case ae.Right:a=e+wn(o-e,s),l=n;break;case ae.Top:a=e,l=n-wn(n-i,s);break;case ae.Bottom:a=e,l=n+wn(i-n,s);break}return[a,l]}function po(t){const{sourceX:e,sourceY:n,sourcePosition:o=ae.Bottom,targetX:i,targetY:s,targetPosition:a=ae.Top,curvature:l=.25}=t,[d,c]=pr({pos:o,x1:e,y1:n,x2:i,y2:s,c:l}),[u,h]=pr({pos:a,x1:i,y1:s,x2:e,y2:n,c:l}),[f,g,m,E]=gr({sourceX:e,sourceY:n,targetX:i,targetY:s,sourceControlX:d,sourceControlY:c,targetControlX:u,targetControlY:h});return[`M${e},${n} C${d},${c} ${u},${h} ${i},${s}`,f,g,m,E]}function mr({pos:t,x1:e,y1:n,x2:o,y2:i}){let s,a;switch(t){case ae.Left:case ae.Right:s=.5*(e+o),a=n;break;case ae.Top:case ae.Bottom:s=e,a=.5*(n+i);break}return[s,a]}function yr(t){const{sourceX:e,sourceY:n,sourcePosition:o=ae.Bottom,targetX:i,targetY:s,targetPosition:a=ae.Top}=t,[l,d]=mr({pos:o,x1:e,y1:n,x2:i,y2:s}),[c,u]=mr({pos:a,x1:i,y1:s,x2:e,y2:n}),[h,f,g,m]=gr({sourceX:e,sourceY:n,targetX:i,targetY:s,sourceControlX:l,sourceControlY:d,targetControlX:c,targetControlY:u});return[`M${e},${n} C${l},${d} ${c},${u} ${i},${s}`,h,f,g,m]}var vr={[ae.Left]:{x:-1,y:0},[ae.Right]:{x:1,y:0},[ae.Top]:{x:0,y:-1},[ae.Bottom]:{x:0,y:1}};function ou({source:t,sourcePosition:e=ae.Bottom,target:n}){return e===ae.Left||e===ae.Right?t.x<n.x?{x:1,y:0}:{x:-1,y:0}:t.y<n.y?{x:0,y:1}:{x:0,y:-1}}function _r(t,e){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function iu({source:t,sourcePosition:e=ae.Bottom,target:n,targetPosition:o=ae.Top,center:i,offset:s}){const a=vr[e],l=vr[o],d={x:t.x+a.x*s,y:t.y+a.y*s},c={x:n.x+l.x*s,y:n.y+l.y*s},u=ou({source:d,sourcePosition:e,target:c}),h=u.x!==0?"x":"y",f=u[h];let g,m,E;const S={x:0,y:0},D={x:0,y:0},[B,w,M,G]=hr({sourceX:t.x,sourceY:t.y,targetX:n.x,targetY:n.y});if(a[h]*l[h]===-1){m=i.x??B,E=i.y??w;const R=[{x:m,y:d.y},{x:m,y:c.y}],q=[{x:d.x,y:E},{x:c.x,y:E}];a[h]===f?g=h==="x"?R:q:g=h==="x"?q:R}else{const R=[{x:d.x,y:c.y}],q=[{x:c.x,y:d.y}];if(h==="x"?g=a.x===f?q:R:g=a.y===f?R:q,e===o){const Z=Math.abs(t[h]-n[h]);if(Z<=s){const F=Math.min(s-1,s-Z);a[h]===f?S[h]=(d[h]>t[h]?-1:1)*F:D[h]=(c[h]>n[h]?-1:1)*F}}if(e!==o){const Z=h==="x"?"y":"x",F=a[h]===l[Z],k=d[Z]>c[Z],W=d[Z]<c[Z];(a[h]===1&&(!F&&k||F&&W)||a[h]!==1&&(!F&&W||F&&k))&&(g=h==="x"?R:q)}const K={x:d.x+S.x,y:d.y+S.y},j={x:c.x+D.x,y:c.y+D.y};Math.max(Math.abs(K.x-g[0].x),Math.abs(j.x-g[0].x))>=Math.max(Math.abs(K.y-g[0].y),Math.abs(j.y-g[0].y))?(m=(K.x+j.x)/2,E=g[0].y):(m=g[0].x,E=(K.y+j.y)/2)}return[[t,{x:d.x+S.x,y:d.y+S.y},...g,{x:c.x+D.x,y:c.y+D.y},n],m,E,M,G]}function ru(t,e,n,o){const i=Math.min(_r(t,e)/2,_r(e,n)/2,o),{x:s,y:a}=e;if(t.x===s&&s===n.x||t.y===a&&a===n.y)return`L${s} ${a}`;if(t.y===a){const d=t.x<n.x?-1:1,c=t.y<n.y?1:-1;return`L ${s+i*d},${a}Q ${s},${a} ${s},${a+i*c}`}const l=t.x<n.x?1:-1;return`L ${s},${a+i*(t.y<n.y?-1:1)}Q ${s},${a} ${s+i*l},${a}`}function mo(t){const{sourceX:e,sourceY:n,sourcePosition:o=ae.Bottom,targetX:i,targetY:s,targetPosition:a=ae.Top,borderRadius:l=5,centerX:d,centerY:c,offset:u=20}=t,[h,f,g,m,E]=iu({source:{x:e,y:n},sourcePosition:o,target:{x:i,y:s},targetPosition:a,center:{x:d,y:c},offset:u});return[h.reduce((S,D,B)=>{let w;return B>0&&B<h.length-1?w=ru(h[B-1],D,h[B+1],l):w=`${B===0?"M":"L"}${D.x} ${D.y}`,S+=w,S},""),f,g,m,E]}function su(t){const{sourceX:e,sourceY:n,targetX:o,targetY:i}=t,[s,a,l,d]=hr({sourceX:e,sourceY:n,targetX:o,targetY:i});return[`M ${e},${n}L ${o},${i}`,s,a,l,d]}var au=(0,r.defineComponent)({name:"StraightEdge",props:["label","labelStyle","labelShowBg","labelBgStyle","labelBgPadding","labelBgBorderRadius","sourceY","sourceX","targetX","targetY","markerEnd","markerStart","interactionWidth"],compatConfig:{MODE:3},setup(t,{attrs:e}){return()=>{const[n,o,i]=su(t);return(0,r.h)(Ot,{path:n,labelX:o,labelY:i,...e,...t})}}}),wr=(0,r.defineComponent)({name:"SmoothStepEdge",props:["sourcePosition","targetPosition","label","labelStyle","labelShowBg","labelBgStyle","labelBgPadding","labelBgBorderRadius","sourceY","sourceX","targetX","targetY","borderRadius","markerEnd","markerStart","interactionWidth","offset"],compatConfig:{MODE:3},setup(t,{attrs:e}){return()=>{const[n,o,i]=mo({...t,sourcePosition:t.sourcePosition??ae.Bottom,targetPosition:t.targetPosition??ae.Top});return(0,r.h)(Ot,{path:n,labelX:o,labelY:i,...e,...t})}}}),lu=(0,r.defineComponent)({name:"StepEdge",props:["sourcePosition","targetPosition","label","labelStyle","labelShowBg","labelBgStyle","labelBgPadding","labelBgBorderRadius","sourceY","sourceX","targetX","targetY","markerEnd","markerStart","interactionWidth"],setup(t,{attrs:e}){return()=>(0,r.h)(wr,{...t,...e,borderRadius:0})}}),cu=(0,r.defineComponent)({name:"BezierEdge",props:["sourcePosition","targetPosition","label","labelStyle","labelShowBg","labelBgStyle","labelBgPadding","labelBgBorderRadius","sourceY","sourceX","targetX","targetY","curvature","markerEnd","markerStart","interactionWidth"],compatConfig:{MODE:3},setup(t,{attrs:e}){return()=>{const[n,o,i]=po({...t,sourcePosition:t.sourcePosition??ae.Bottom,targetPosition:t.targetPosition??ae.Top});return(0,r.h)(Ot,{path:n,labelX:o,labelY:i,...e,...t})}}}),du=(0,r.defineComponent)({name:"SimpleBezierEdge",props:["sourcePosition","targetPosition","label","labelStyle","labelShowBg","labelBgStyle","labelBgPadding","labelBgBorderRadius","sourceY","sourceX","targetX","targetY","markerEnd","markerStart","interactionWidth"],compatConfig:{MODE:3},setup(t,{attrs:e}){return()=>{const[n,o,i]=yr({...t,sourcePosition:t.sourcePosition??ae.Bottom,targetPosition:t.targetPosition??ae.Top});return(0,r.h)(Ot,{path:n,labelX:o,labelY:i,...e,...t})}}}),uu={input:Kd,default:jd,output:Zd},fu={default:cu,straight:au,step:lu,smoothstep:wr,simplebezier:du};function hu(t,e,n){const o=(0,r.computed)(()=>m=>e.value.get(m)),i=(0,r.computed)(()=>m=>n.value.get(m)),s=(0,r.computed)(()=>{const m={...fu,...t.edgeTypes},E=Object.keys(m);for(const S of t.edges)S.type&&!E.includes(S.type)&&(m[S.type]=S.type);return m}),a=(0,r.computed)(()=>{const m={...uu,...t.nodeTypes},E=Object.keys(m);for(const S of t.nodes)S.type&&!E.includes(S.type)&&(m[S.type]=S.type);return m}),l=(0,r.computed)(()=>t.onlyRenderVisibleElements?Ai(t.nodes,{x:0,y:0,width:t.dimensions.width,height:t.dimensions.height},t.viewport,!0):t.nodes),d=(0,r.computed)(()=>{if(t.onlyRenderVisibleElements){const m=[];for(const E of t.edges){const S=e.value.get(E.source),D=e.value.get(E.target);yd({sourcePos:S.computedPosition||{x:0,y:0},targetPos:D.computedPosition||{x:0,y:0},sourceWidth:S.dimensions.width,sourceHeight:S.dimensions.height,targetWidth:D.dimensions.width,targetHeight:D.dimensions.height,width:t.dimensions.width,height:t.dimensions.height,viewport:t.viewport})&&m.push(E)}return m}return t.edges}),c=(0,r.computed)(()=>[...l.value,...d.value]),u=(0,r.computed)(()=>{const m=[];for(const E of t.nodes)E.selected&&m.push(E);return m}),h=(0,r.computed)(()=>{const m=[];for(const E of t.edges)E.selected&&m.push(E);return m}),f=(0,r.computed)(()=>[...u.value,...h.value]),g=(0,r.computed)(()=>{const m=[];for(const E of t.nodes)E.dimensions.width&&E.dimensions.height&&E.handleBounds!==void 0&&m.push(E);return m});return{getNode:o,getEdge:i,getElements:c,getEdgeTypes:s,getNodeTypes:a,getEdges:d,getNodes:l,getSelectedElements:f,getSelectedNodes:u,getSelectedEdges:h,getNodesInitialized:g,areNodesInitialized:(0,r.computed)(()=>l.value.length>0&&g.value.length===l.value.length)}}var gu=class yt{constructor(){this.currentId=0,this.flows=new Map}static getInstance(){var e;const n=(e=(0,r.getCurrentInstance)())==null?void 0:e.appContext.app;return yt.instance=n?.config.globalProperties.$vueFlowStorage??yt.instance??new yt,n&&(n.config.globalProperties.$vueFlowStorage=yt.instance),yt.instance}set(e,n){return this.flows.set(e,n)}get(e){return this.flows.get(e)}remove(e){return this.flows.delete(e)}create(e,n){const o=(0,r.reactive)(fr()),i={};for(const[h,f]of Object.entries(o.hooks)){const g=`on${h.charAt(0).toUpperCase()+h.slice(1)}`;i[g]=f.on}const s={};for(const[h,f]of Object.entries(o.hooks))s[h]=f.trigger;const a=(0,r.computed)(()=>{const h=new Map;for(const f of o.nodes)h.set(f.id,f);return h}),l=(0,r.computed)(()=>{const h=new Map;for(const f of o.edges)h.set(f.id,f);return h}),d=hu(o,a,l),c=Yd(o,a,l);c.setState({...o,...n});const u={...i,...d,...c,...fs(o),nodeLookup:a,edgeLookup:l,emits:s,id:e,vueFlowVersion:"1.48.2",$destroy:()=>{this.remove(e)}};return this.set(e,u),u}getId(){return`vue-flow-${this.currentId++}`}};function pe(t){const e=gu.getInstance(),n=(0,r.getCurrentScope)(),o=typeof t=="object",i=o?t:{id:t},s=i.id,a=s??n?.vueFlowId;let l;if(n){const d=(0,r.inject)(rr,null);typeof d<"u"&&d!==null&&(!a||d.id===a)&&(l=d)}if(l||a&&(l=e.get(a)),!l||a&&l.id!==a){const d=s??e.getId(),c=e.create(d,i);l=c,(n??(0,r.effectScope)(!0)).run(()=>{(0,r.watch)(c.applyDefault,(u,h,f)=>{const g=E=>{c.applyNodeChanges(E)},m=E=>{c.applyEdgeChanges(E)};u?(c.onNodesChange(g),c.onEdgesChange(m)):(c.hooks.value.nodesChange.off(g),c.hooks.value.edgesChange.off(m)),f(()=>{c.hooks.value.nodesChange.off(g),c.hooks.value.edgesChange.off(m)})},{immediate:!0}),_t(()=>{if(l){const u=e.get(l.id);u?u.$destroy():Pt(`No store instance found for id ${l.id} in storage.`)}})})}else o&&l.setState(i);if(n&&((0,r.provide)(rr,l),n.vueFlowId=l.id),o){const d=(0,r.getCurrentInstance)();d?.type.name!=="VueFlow"&&l.emits.error(new we(ve.USEVUEFLOW_OPTIONS))}return l}function pu(t){const{emits:e,dimensions:n}=pe();let o;(0,r.onMounted)(()=>{const i=()=>{var s,a;if(!t.value||!(((a=(s=t.value).checkVisibility)==null?void 0:a.call(s))??!0))return;const l=dn(t.value);(l.width===0||l.height===0)&&e.error(new we(ve.MISSING_VIEWPORT_DIMENSIONS)),n.value={width:l.width||500,height:l.height||500}};i(),window.addEventListener("resize",i),t.value&&(o=new ResizeObserver(()=>i()),o.observe(t.value)),(0,r.onBeforeUnmount)(()=>{window.removeEventListener("resize",i),o&&t.value&&o.unobserve(t.value)})})}var mu=(0,r.defineComponent)({name:"UserSelection",compatConfig:{MODE:3},props:{userSelectionRect:{}},setup(t){return(e,n)=>((0,r.openBlock)(),(0,r.createElementBlock)("div",{class:"vue-flow__selection vue-flow__container",style:(0,r.normalizeStyle)({width:`${e.userSelectionRect.width}px`,height:`${e.userSelectionRect.height}px`,transform:`translate(${e.userSelectionRect.x}px, ${e.userSelectionRect.y}px)`})},null,4))}}),yu=["tabIndex"],vu=(0,r.defineComponent)({name:"NodesSelection",compatConfig:{MODE:3},setup(t){const{emits:e,viewport:n,getSelectedNodes:o,noPanClassName:i,disableKeyboardA11y:s,userSelectionActive:a}=pe(),l=ur(),d=(0,r.ref)(null),c=lr({el:d,onStart(m){e.selectionDragStart(m),e.nodeDragStart(m)},onDrag(m){e.selectionDrag(m),e.nodeDrag(m)},onStop(m){e.selectionDragStop(m),e.nodeDragStop(m)}});(0,r.onMounted)(()=>{var m;s.value||(m=d.value)==null||m.focus({preventScroll:!0})});const u=(0,r.computed)(()=>Ri(o.value)),h=(0,r.computed)(()=>({width:`${u.value.width}px`,height:`${u.value.height}px`,top:`${u.value.y}px`,left:`${u.value.x}px`}));function f(m){e.selectionContextMenu({event:m,nodes:o.value})}function g(m){s.value||ft[m.key]&&(m.preventDefault(),l({x:ft[m.key].x,y:ft[m.key].y},m.shiftKey))}return(m,E)=>!(0,r.unref)(a)&&u.value.width&&u.value.height?((0,r.openBlock)(),(0,r.createElementBlock)("div",{key:0,class:(0,r.normalizeClass)(["vue-flow__nodesselection vue-flow__container",(0,r.unref)(i)]),style:(0,r.normalizeStyle)({transform:`translate(${(0,r.unref)(n).x}px,${(0,r.unref)(n).y}px) scale(${(0,r.unref)(n).zoom})`})},[(0,r.createElementVNode)("div",{ref_key:"el",ref:d,class:(0,r.normalizeClass)([{dragging:(0,r.unref)(c)},"vue-flow__nodesselection-rect"]),style:(0,r.normalizeStyle)(h.value),tabIndex:(0,r.unref)(s)?void 0:-1,onContextmenu:f,onKeydown:g},null,46,yu)],6)):(0,r.createCommentVNode)("",!0)}});function _u(t,e){return{x:t.clientX-e.left,y:t.clientY-e.top}}var wu=(0,r.defineComponent)({name:"Pane",compatConfig:{MODE:3},props:{isSelecting:{type:Boolean},selectionKeyPressed:{type:Boolean}},setup(t){const{vueFlowRef:e,nodes:n,viewport:o,emits:i,userSelectionActive:s,removeSelectedElements:a,userSelectionRect:l,elementsSelectable:d,nodesSelectionActive:c,getSelectedEdges:u,getSelectedNodes:h,removeNodes:f,removeEdges:g,selectionMode:m,deleteKeyCode:E,multiSelectionKeyCode:S,multiSelectionActive:D,edgeLookup:B,nodeLookup:w,connectionLookup:M,defaultEdgeOptions:G,connectionStartHandle:R,panOnDrag:q}=pe(),K=(0,r.shallowRef)(null),j=(0,r.shallowRef)(new Set),Z=(0,r.shallowRef)(new Set),F=(0,r.shallowRef)(null),k=(0,r.toRef)(()=>d.value&&(t.isSelecting||s.value)),W=(0,r.toRef)(()=>R.value!==null);let b=!1,P=!1;const v=Bt(E,{actInsideInputWithModifier:!1}),N=Bt(S);(0,r.watch)(v,V=>{V&&(f(h.value),g(u.value),c.value=!1)}),(0,r.watch)(N,V=>{D.value=V});function I(V,X){return A=>{A.target===X&&V?.(A)}}function T(V){if(b||W.value){b=!1;return}i.paneClick(V),a(),c.value=!1}function z(V){var X;if(Array.isArray(q.value)&&((X=q.value)!=null&&X.includes(2))){V.preventDefault();return}i.paneContextMenu(V)}function O(V){i.paneScroll(V)}function L(V){var X,A,U;if(F.value=((X=e.value)==null?void 0:X.getBoundingClientRect())??null,!d.value||!t.isSelecting||V.button!==0||V.target!==K.value||!F.value)return;(U=(A=V.target)==null?void 0:A.setPointerCapture)==null||U.call(A,V.pointerId);const{x:te,y:ie}=_u(V,F.value);P=!0,b=!1,a(),l.value={width:0,height:0,startX:te,startY:ie,x:te,y:ie},i.selectionStart(V)}function ee(V){var X;if(!F.value||!l.value)return;b=!0;const{x:A,y:U}=Pe(V,F.value),{startX:te=0,startY:ie=0}=l.value,le={startX:te,startY:ie,x:A<te?A:te,y:U<ie?U:ie,width:Math.abs(A-te),height:Math.abs(U-ie)},J=j.value,re=Z.value;j.value=new Set(Ai(n.value,le,o.value,m.value===no.Partial,!0).map(p=>p.id)),Z.value=new Set;const x=((X=G.value)==null?void 0:X.selectable)??!0;for(const p of j.value){const y=M.value.get(p);if(y)for(const{edgeId:C}of y.values()){const _=B.value.get(C);_&&(_.selectable??x)&&Z.value.add(C)}}if(!ir(J,j.value)){const p=Xe(w.value,j.value,!0);i.nodesChange(p)}if(!ir(re,Z.value)){const p=Xe(B.value,Z.value);i.edgesChange(p)}l.value=le,s.value=!0,c.value=!1}function se(V){var X;V.button!==0||!P||((X=V.target)==null||X.releasePointerCapture(V.pointerId),!s.value&&l.value&&V.target===K.value&&T(V),s.value=!1,l.value=null,c.value=j.value.size>0,i.selectionEnd(V),t.selectionKeyPressed&&(b=!1),P=!1)}return(V,X)=>((0,r.openBlock)(),(0,r.createElementBlock)("div",{ref_key:"container",ref:K,class:(0,r.normalizeClass)(["vue-flow__pane vue-flow__container",{selection:V.isSelecting}]),onClick:X[0]||(X[0]=A=>k.value?void 0:I(T,K.value)(A)),onContextmenu:X[1]||(X[1]=A=>I(z,K.value)(A)),onWheelPassive:X[2]||(X[2]=A=>I(O,K.value)(A)),onPointerenter:X[3]||(X[3]=A=>k.value?void 0:(0,r.unref)(i).paneMouseEnter(A)),onPointerdown:X[4]||(X[4]=A=>k.value?L(A):(0,r.unref)(i).paneMouseMove(A)),onPointermove:X[5]||(X[5]=A=>k.value?ee(A):(0,r.unref)(i).paneMouseMove(A)),onPointerup:X[6]||(X[6]=A=>k.value?se(A):void 0),onPointerleave:X[7]||(X[7]=A=>(0,r.unref)(i).paneMouseLeave(A))},[(0,r.renderSlot)(V.$slots,"default"),(0,r.unref)(s)&&(0,r.unref)(l)?((0,r.openBlock)(),(0,r.createBlock)(mu,{key:0,"user-selection-rect":(0,r.unref)(l)},null,8,["user-selection-rect"])):(0,r.createCommentVNode)("",!0),(0,r.unref)(c)&&(0,r.unref)(h).length?((0,r.openBlock)(),(0,r.createBlock)(vu,{key:1})):(0,r.createCommentVNode)("",!0)],34))}}),bu=(0,r.defineComponent)({name:"Transform",compatConfig:{MODE:3},setup(t){const{viewport:e,fitViewOnInit:n,fitViewOnInitDone:o}=pe(),i=(0,r.computed)(()=>n.value?!o.value:!1),s=(0,r.computed)(()=>`translate(${e.value.x}px,${e.value.y}px) scale(${e.value.zoom})`);return(a,l)=>((0,r.openBlock)(),(0,r.createElementBlock)("div",{class:"vue-flow__transformationpane vue-flow__container",style:(0,r.normalizeStyle)({transform:s.value,opacity:i.value?0:void 0})},[(0,r.renderSlot)(a.$slots,"default")],4))}}),Cu=(0,r.defineComponent)({name:"Viewport",compatConfig:{MODE:3},setup(t){const{minZoom:e,maxZoom:n,defaultViewport:o,translateExtent:i,zoomActivationKeyCode:s,selectionKeyCode:a,panActivationKeyCode:l,panOnScroll:d,panOnScrollMode:c,panOnScrollSpeed:u,panOnDrag:h,zoomOnDoubleClick:f,zoomOnPinch:g,zoomOnScroll:m,preventScrolling:E,noWheelClassName:S,noPanClassName:D,emits:B,connectionStartHandle:w,userSelectionActive:M,paneDragging:G,d3Zoom:R,d3Selection:q,d3ZoomHandler:K,viewport:j,viewportRef:Z,paneClickDistance:F}=pe();pu(Z);const k=(0,r.shallowRef)(!1),W=(0,r.shallowRef)(!1);let b=null,P=!1,v=0,N={x:0,y:0,zoom:0};const I=Bt(l),T=Bt(a),z=Bt(s),O=(0,r.toRef)(()=>(!T.value||T.value&&a.value===!0)&&(I.value||h.value)),L=(0,r.toRef)(()=>I.value||d.value),ee=(0,r.toRef)(()=>a.value===!0&&O.value!==!0),se=(0,r.toRef)(()=>T.value&&a.value!==!0||M.value||ee.value),V=(0,r.toRef)(()=>w.value!==null);(0,r.onMounted)(()=>{if(!Z.value){Pt("Viewport element is missing");return}const ie=Z.value,le=ie.getBoundingClientRect(),J=Kc().clickDistance(F.value).scaleExtent([e.value,n.value]).translateExtent(i.value),re=Te(ie).call(J),x=re.on("wheel.zoom"),p=ut.translate(o.value.x??0,o.value.y??0).scale(ot(o.value.zoom??1,e.value,n.value)),y=[[0,0],[le.width,le.height]],C=J.constrain()(p,y,i.value);J.transform(re,C),J.wheelDelta(Vi),R.value=J,q.value=re,K.value=x,j.value={x:C.x,y:C.y,zoom:C.k},J.on("start",_=>{var Y;if(!_.sourceEvent)return null;v=_.sourceEvent.button,k.value=!0;const H=U(_.transform);((Y=_.sourceEvent)==null?void 0:Y.type)==="mousedown"&&(G.value=!0),N=H,B.viewportChangeStart(H),B.moveStart({event:_,flowTransform:H})}),J.on("end",_=>{if(!_.sourceEvent)return null;if(k.value=!1,G.value=!1,X(O.value,v??0)&&!P&&B.paneContextMenu(_.sourceEvent),P=!1,A(N,_.transform)){const Y=U(_.transform);N=Y,B.viewportChangeEnd(Y),B.moveEnd({event:_,flowTransform:Y})}}),J.filter(_=>{var Y;const H=z.value||m.value,oe=g.value&&_.ctrlKey,Q=_.button,ue=_.type==="wheel";if(Q===1&&_.type==="mousedown"&&(te(_,"vue-flow__node")||te(_,"vue-flow__edge")))return!0;if(!O.value&&!H&&!L.value&&!f.value&&!g.value||M.value||V.value&&!ue||!f.value&&_.type==="dblclick"||te(_,S.value)&&ue||te(_,D.value)&&(!ue||L.value&&ue&&!z.value)||!g.value&&_.ctrlKey&&ue||!H&&!L.value&&!oe&&ue)return!1;if(!g&&_.type==="touchstart"&&((Y=_.touches)==null?void 0:Y.length)>1)return _.preventDefault(),!1;if(!O.value&&(_.type==="mousedown"||_.type==="touchstart")||ee.value&&Array.isArray(h.value)&&h.value.includes(0)&&Q===0||Array.isArray(h.value)&&!h.value.includes(Q)&&(_.type==="mousedown"||_.type==="touchstart"))return!1;const fe=Array.isArray(h.value)&&h.value.includes(Q)||a.value===!0&&Array.isArray(h.value)&&!h.value.includes(0)||!Q||Q<=1;return(!_.ctrlKey||I.value||ue)&&fe}),(0,r.watch)([M,O],()=>{M.value&&!k.value?J.on("zoom",null):M.value||J.on("zoom",_=>{j.value={x:_.transform.x,y:_.transform.y,zoom:_.transform.k};const Y=U(_.transform);P=X(O.value,v??0),B.viewportChange(Y),B.move({event:_,flowTransform:Y})})},{immediate:!0}),(0,r.watch)([M,L,c,z,g,E,S],()=>{L.value&&!z.value&&!M.value?re.on("wheel.zoom",_=>{if(te(_,S.value))return!1;const Y=z.value||m.value,H=g.value&&_.ctrlKey;if(!(!E.value||L.value||Y||H))return!1;_.preventDefault(),_.stopImmediatePropagation();const oe=re.property("__zoom").k||1,Q=fn();if(!I.value&&_.ctrlKey&&g.value&&Q){const Ze=ze(_),Vt=oe*2**Vi(_);J.scaleTo(re,Vt,Ze,_);return}const ue=_.deltaMode===1?20:1;let fe=c.value===It.Vertical?0:_.deltaX*ue,ge=c.value===It.Horizontal?0:_.deltaY*ue;!Q&&_.shiftKey&&c.value!==It.Vertical&&!fe&&ge&&(fe=ge,ge=0),J.translateBy(re,-(fe/oe)*u.value,-(ge/oe)*u.value);const he=U(re.property("__zoom"));b&&clearTimeout(b),W.value?(B.move({event:_,flowTransform:he}),B.viewportChange(he),b=setTimeout(()=>{B.moveEnd({event:_,flowTransform:he}),B.viewportChangeEnd(he),W.value=!1},150)):(W.value=!0,B.moveStart({event:_,flowTransform:he}),B.viewportChangeStart(he))},{passive:!1}):typeof x<"u"&&re.on("wheel.zoom",function(_,Y){const H=!E.value&&_.type==="wheel"&&!_.ctrlKey,oe=z.value||m.value,Q=g.value&&_.ctrlKey;if(!oe&&!d.value&&!Q&&_.type==="wheel"||H||te(_,S.value))return null;_.preventDefault(),x.call(this,_,Y)},{passive:!1})},{immediate:!0})});function X(ie,le){return le===2&&Array.isArray(ie)&&ie.includes(2)}function A(ie,le){return ie.x!==le.x&&!Number.isNaN(le.x)||ie.y!==le.y&&!Number.isNaN(le.y)||ie.zoom!==le.k&&!Number.isNaN(le.k)}function U(ie){return{x:ie.x,y:ie.y,zoom:ie.k}}function te(ie,le){return ie.target.closest(`.${le}`)}return(ie,le)=>((0,r.openBlock)(),(0,r.createElementBlock)("div",{ref_key:"viewportRef",ref:Z,class:"vue-flow__viewport vue-flow__container"},[(0,r.createVNode)(wu,{"is-selecting":se.value,"selection-key-pressed":(0,r.unref)(T),class:(0,r.normalizeClass)({connecting:V.value,dragging:(0,r.unref)(G),draggable:(0,r.unref)(h)===!0||Array.isArray((0,r.unref)(h))&&(0,r.unref)(h).includes(0)})},{default:(0,r.withCtx)(()=>[(0,r.createVNode)(bu,null,{default:(0,r.withCtx)(()=>[(0,r.renderSlot)(ie.$slots,"default")]),_:3})]),_:3},8,["is-selecting","selection-key-pressed","class"])],512))}}),Eu=["id"],xu=["id"],Nu=["id"],ku=(0,r.defineComponent)({name:"A11yDescriptions",compatConfig:{MODE:3},setup(t){const{id:e,disableKeyboardA11y:n,ariaLiveMessage:o}=pe();return(i,s)=>((0,r.openBlock)(),(0,r.createElementBlock)(r.Fragment,null,[(0,r.createElementVNode)("div",{id:`${(0,r.unref)(Ni)}-${(0,r.unref)(e)}`,style:{display:"none"}}," Press enter or space to select a node. "+(0,r.toDisplayString)((0,r.unref)(n)?"":"You can then use the arrow keys to move the node around.")+" You can then use the arrow keys to move the node around, press delete to remove it and press escape to cancel. ",9,Eu),(0,r.createElementVNode)("div",{id:`${(0,r.unref)(ki)}-${(0,r.unref)(e)}`,style:{display:"none"}}," Press enter or space to select an edge. You can then press delete to remove it or press escape to cancel. ",8,xu),(0,r.unref)(n)?(0,r.createCommentVNode)("",!0):((0,r.openBlock)(),(0,r.createElementBlock)("div",{key:0,id:`${(0,r.unref)(nd)}-${(0,r.unref)(e)}`,"aria-live":"assertive","aria-atomic":"true",style:{position:"absolute",width:"1px",height:"1px",margin:"-1px",border:"0",padding:"0",overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)","clip-path":"inset(100%)"}},(0,r.toDisplayString)((0,r.unref)(o)),9,Nu))],64))}});function Su(){const t=pe();(0,r.watch)(()=>t.viewportHelper.value.viewportInitialized,e=>{e&&setTimeout(()=>{t.emits.init(t),t.emits.paneReady(t)},1)})}function Du(t,e,n){return n===ae.Left?t-e:n===ae.Right?t+e:t}function Tu(t,e,n){return n===ae.Top?t-e:n===ae.Bottom?t+e:t}var yo=function({radius:t=10,centerX:e=0,centerY:n=0,position:o=ae.Top,type:i}){return(0,r.h)("circle",{class:`vue-flow__edgeupdater vue-flow__edgeupdater-${i}`,cx:Du(e,t,o),cy:Tu(n,t,o),r:t,stroke:"transparent",fill:"transparent"})};yo.props=["radius","centerX","centerY","position","type"],yo.compatConfig={MODE:3};var br=yo,Mu=(0,r.defineComponent)({name:"Edge",compatConfig:{MODE:3},props:["id"],setup(t){const{id:e,addSelectedEdges:n,connectionMode:o,edgeUpdaterRadius:i,emits:s,nodesSelectionActive:a,noPanClassName:l,getEdgeTypes:d,removeSelectedEdges:c,findEdge:u,findNode:h,isValidConnection:f,multiSelectionActive:g,disableKeyboardA11y:m,elementsSelectable:E,edgesUpdatable:S,edgesFocusable:D,hooks:B}=pe(),w=(0,r.computed)(()=>u(t.id)),{emit:M,on:G}=zd(w.value,s),R=(0,r.inject)(gn),q=(0,r.getCurrentInstance)(),K=(0,r.ref)(!1),j=(0,r.ref)(!1),Z=(0,r.ref)(""),F=(0,r.ref)(null),k=(0,r.ref)("source"),W=(0,r.ref)(null),b=(0,r.toRef)(()=>typeof w.value.selectable>"u"?E.value:w.value.selectable),P=(0,r.toRef)(()=>typeof w.value.updatable>"u"?S.value:w.value.updatable),v=(0,r.toRef)(()=>typeof w.value.focusable>"u"?D.value:w.value.focusable);(0,r.provide)(Md,t.id),(0,r.provide)(Id,W);const N=(0,r.computed)(()=>w.value.class instanceof Function?w.value.class(w.value):w.value.class),I=(0,r.computed)(()=>w.value.style instanceof Function?w.value.style(w.value):w.value.style),T=(0,r.computed)(()=>{const p=w.value.type||"default",y=R?.[`edge-${p}`];if(y)return y;let C=w.value.template??d.value[p];if(typeof C=="string"&&q){const _=Object.keys(q.appContext.components);_&&_.includes(p)&&(C=(0,r.resolveComponent)(p,!1))}return C&&typeof C!="string"?C:(s.error(new we(ve.EDGE_TYPE_MISSING,C)),!1)}),{handlePointerDown:z}=cr({nodeId:Z,handleId:F,type:k,isValidConnection:f,edgeUpdaterType:k,onEdgeUpdate:ee,onEdgeUpdateEnd:se});return()=>{const p=h(w.value.source),y=h(w.value.target),C="pathOptions"in w.value?w.value.pathOptions:{};if(!p&&!y)return s.error(new we(ve.EDGE_SOURCE_TARGET_MISSING,w.value.id,w.value.source,w.value.target)),null;if(!p)return s.error(new we(ve.EDGE_SOURCE_MISSING,w.value.id,w.value.source)),null;if(!y)return s.error(new we(ve.EDGE_TARGET_MISSING,w.value.id,w.value.target)),null;if(!w.value||w.value.hidden||p.hidden||y.hidden)return null;let _;o.value===Fe.Strict?_=p.handleBounds.source:_=[...p.handleBounds.source||[],...p.handleBounds.target||[]];const Y=Zi(_,w.value.sourceHandle);let H;o.value===Fe.Strict?H=y.handleBounds.target:H=[...y.handleBounds.target||[],...y.handleBounds.source||[]];const oe=Zi(H,w.value.targetHandle),Q=Y?.position||ae.Bottom,ue=oe?.position||ae.Top,{x:fe,y:ge}=gt(p,Y,Q),{x:he,y:Ze}=gt(y,oe,ue);return w.value.sourceX=fe,w.value.sourceY=ge,w.value.targetX=he,w.value.targetY=Ze,(0,r.h)("g",{ref:W,key:t.id,"data-id":t.id,class:["vue-flow__edge",`vue-flow__edge-${T.value===!1?"default":w.value.type||"default"}`,l.value,N.value,{updating:K.value,selected:w.value.selected,animated:w.value.animated,inactive:!b.value&&!B.value.edgeClick.hasListeners()}],tabIndex:v.value?0:void 0,"aria-label":w.value.ariaLabel===null?void 0:w.value.ariaLabel??`Edge from ${w.value.source} to ${w.value.target}`,"aria-describedby":v.value?`${ki}-${e}`:void 0,"aria-roledescription":"edge",role:v.value?"group":"img",...w.value.domAttributes,onClick:X,onContextmenu:A,onDblclick:U,onMouseenter:te,onMousemove:ie,onMouseleave:le,onKeyDown:v.value?x:void 0},[j.value?null:(0,r.h)(T.value===!1?d.value.default:T.value,{id:t.id,sourceNode:p,targetNode:y,source:w.value.source,target:w.value.target,type:w.value.type,updatable:P.value,selected:w.value.selected,animated:w.value.animated,label:w.value.label,labelStyle:w.value.labelStyle,labelShowBg:w.value.labelShowBg,labelBgStyle:w.value.labelBgStyle,labelBgPadding:w.value.labelBgPadding,labelBgBorderRadius:w.value.labelBgBorderRadius,data:w.value.data,events:{...w.value.events,...G},style:I.value,markerStart:`url('#${$t(w.value.markerStart,e)}')`,markerEnd:`url('#${$t(w.value.markerEnd,e)}')`,sourcePosition:Q,targetPosition:ue,sourceX:fe,sourceY:ge,targetX:he,targetY:Ze,sourceHandleId:w.value.sourceHandle,targetHandleId:w.value.targetHandle,interactionWidth:w.value.interactionWidth,...C}),[P.value==="source"||P.value===!0?[(0,r.h)("g",{onMousedown:J,onMouseenter:O,onMouseout:L},(0,r.h)(br,{position:Q,centerX:fe,centerY:ge,radius:i.value,type:"source","data-type":"source"}))]:null,P.value==="target"||P.value===!0?[(0,r.h)("g",{onMousedown:re,onMouseenter:O,onMouseout:L},(0,r.h)(br,{position:ue,centerX:he,centerY:Ze,radius:i.value,type:"target","data-type":"target"}))]:null]])};function O(){K.value=!0}function L(){K.value=!1}function ee(p,y){M.update({event:p,edge:w.value,connection:y})}function se(p){M.updateEnd({event:p,edge:w.value}),j.value=!1}function V(p,y){p.button===0&&(j.value=!0,Z.value=y?w.value.target:w.value.source,F.value=(y?w.value.targetHandle:w.value.sourceHandle)??null,k.value=y?"target":"source",M.updateStart({event:p,edge:w.value}),z(p))}function X(p){var y;const C={event:p,edge:w.value};b.value&&(a.value=!1,w.value.selected&&g.value?(c([w.value]),(y=W.value)==null||y.blur()):n([w.value])),M.click(C)}function A(p){M.contextMenu({event:p,edge:w.value})}function U(p){M.doubleClick({event:p,edge:w.value})}function te(p){M.mouseEnter({event:p,edge:w.value})}function ie(p){M.mouseMove({event:p,edge:w.value})}function le(p){M.mouseLeave({event:p,edge:w.value})}function J(p){V(p,!0)}function re(p){V(p,!1)}function x(p){var y;!m.value&&Si.includes(p.key)&&b.value&&(p.key==="Escape"?((y=W.value)==null||y.blur(),c([u(t.id)])):n([u(t.id)]))}}}),Iu=(0,r.defineComponent)({name:"ConnectionLine",compatConfig:{MODE:3},setup(){var t;const{id:e,connectionMode:n,connectionStartHandle:o,connectionEndHandle:i,connectionPosition:s,connectionLineType:a,connectionLineStyle:l,connectionLineOptions:d,connectionStatus:c,viewport:u,findNode:h}=pe(),f=(t=(0,r.inject)(gn))==null?void 0:t["connection-line"],g=(0,r.computed)(()=>{var B;return h((B=o.value)==null?void 0:B.nodeId)}),m=(0,r.computed)(()=>{var B;return h((B=i.value)==null?void 0:B.nodeId)??null}),E=(0,r.computed)(()=>({x:(s.value.x-u.value.x)/u.value.zoom,y:(s.value.y-u.value.y)/u.value.zoom})),S=(0,r.computed)(()=>d.value.markerStart?`url(#${$t(d.value.markerStart,e)})`:""),D=(0,r.computed)(()=>d.value.markerEnd?`url(#${$t(d.value.markerEnd,e)})`:"");return()=>{var B,w,M;if(!g.value||!o.value)return null;const G=o.value.id,R=o.value.type,q=g.value.handleBounds;let K=q?.[R]??[];if(n.value===Fe.Loose){const I=q?.[R==="source"?"target":"source"]??[];K=[...K,...I]}if(!K)return null;const j=(G?K.find(I=>I.id===G):K[0])??null,Z=j?.position??ae.Top,{x:F,y:k}=gt(g.value,j,Z);let W=null;m.value&&(n.value===Fe.Strict?W=((B=m.value.handleBounds[R==="source"?"target":"source"])==null?void 0:B.find(I=>{var T;return I.id===((T=i.value)==null?void 0:T.id)}))||null:W=((w=[...m.value.handleBounds.source??[],...m.value.handleBounds.target??[]])==null?void 0:w.find(I=>{var T;return I.id===((T=i.value)==null?void 0:T.id)}))||null);const b=((M=i.value)==null?void 0:M.position)??(Z?co[Z]:null);if(!Z||!b)return null;const P=a.value??d.value.type??nt.Bezier;let v="";const N={sourceX:F,sourceY:k,sourcePosition:Z,targetX:E.value.x,targetY:E.value.y,targetPosition:b};return P===nt.Bezier?[v]=po(N):P===nt.Step?[v]=mo({...N,borderRadius:0}):P===nt.SmoothStep?[v]=mo(N):P===nt.SimpleBezier?[v]=yr(N):v=`M${F},${k} ${E.value.x},${E.value.y}`,(0,r.h)("svg",{class:"vue-flow__edges vue-flow__connectionline vue-flow__container"},(0,r.h)("g",{class:"vue-flow__connection"},f?(0,r.h)(f,{sourceX:F,sourceY:k,sourcePosition:Z,targetX:E.value.x,targetY:E.value.y,targetPosition:b,sourceNode:g.value,sourceHandle:j,targetNode:m.value,targetHandle:W,markerEnd:D.value,markerStart:S.value,connectionStatus:c.value}):(0,r.h)("path",{d:v,class:[d.value.class,c.value,"vue-flow__connection-path"],style:{...l.value,...d.value.style},"marker-end":D.value,"marker-start":S.value})))}}}),Bu=["id","markerWidth","markerHeight","markerUnits","orient"],zu=(0,r.defineComponent)({name:"MarkerType",compatConfig:{MODE:3},props:{id:{},type:{},color:{default:"none"},width:{default:12.5},height:{default:12.5},markerUnits:{default:"strokeWidth"},orient:{default:"auto-start-reverse"},strokeWidth:{default:1}},setup(t){return(e,n)=>((0,r.openBlock)(),(0,r.createElementBlock)("marker",{id:e.id,class:"vue-flow__arrowhead",viewBox:"-10 -10 20 20",refX:"0",refY:"0",markerWidth:`${e.width}`,markerHeight:`${e.height}`,markerUnits:e.markerUnits,orient:e.orient},[e.type===(0,r.unref)(Ge).ArrowClosed?((0,r.openBlock)(),(0,r.createElementBlock)("polyline",{key:0,style:(0,r.normalizeStyle)({stroke:e.color,fill:e.color,strokeWidth:e.strokeWidth}),"stroke-linecap":"round","stroke-linejoin":"round",points:"-5,-4 0,0 -5,4 -5,-4"},null,4)):(0,r.createCommentVNode)("",!0),e.type===(0,r.unref)(Ge).Arrow?((0,r.openBlock)(),(0,r.createElementBlock)("polyline",{key:1,style:(0,r.normalizeStyle)({stroke:e.color,strokeWidth:e.strokeWidth}),"stroke-linecap":"round","stroke-linejoin":"round",fill:"none",points:"-5,-4 0,0 -5,4"},null,4)):(0,r.createCommentVNode)("",!0)],8,Bu))}}),Ru={class:"vue-flow__marker vue-flow__container","aria-hidden":"true"},Au=(0,r.defineComponent)({name:"MarkerDefinitions",compatConfig:{MODE:3},setup(t){const{id:e,edges:n,connectionLineOptions:o,defaultMarkerColor:i}=pe(),s=(0,r.computed)(()=>{const a=new Set,l=[],d=c=>{if(c){const u=$t(c,e);a.has(u)||(typeof c=="object"?l.push({...c,id:u,color:c.color||i.value}):l.push({id:u,color:i.value,type:c}),a.add(u))}};for(const c of[o.value.markerEnd,o.value.markerStart])d(c);for(const c of n.value)for(const u of[c.markerStart,c.markerEnd])d(u);return l.sort((c,u)=>c.id.localeCompare(u.id))});return(a,l)=>((0,r.openBlock)(),(0,r.createElementBlock)("svg",Ru,[(0,r.createElementVNode)("defs",null,[((0,r.openBlock)(!0),(0,r.createElementBlock)(r.Fragment,null,(0,r.renderList)(s.value,d=>((0,r.openBlock)(),(0,r.createBlock)(zu,{id:d.id,key:d.id,type:d.type,color:d.color,width:d.width,height:d.height,markerUnits:d.markerUnits,"stroke-width":d.strokeWidth,orient:d.orient},null,8,["id","type","color","width","height","markerUnits","stroke-width","orient"]))),128))])]))}}),$u=(0,r.defineComponent)({name:"Edges",compatConfig:{MODE:3},setup(t){const{findNode:e,getEdges:n,elevateEdgesOnSelect:o}=pe();return(i,s)=>((0,r.openBlock)(),(0,r.createElementBlock)(r.Fragment,null,[(0,r.createVNode)(Au),((0,r.openBlock)(!0),(0,r.createElementBlock)(r.Fragment,null,(0,r.renderList)((0,r.unref)(n),a=>((0,r.openBlock)(),(0,r.createElementBlock)("svg",{key:a.id,class:"vue-flow__edges vue-flow__container",style:(0,r.normalizeStyle)({zIndex:(0,r.unref)(vd)(a,(0,r.unref)(e),(0,r.unref)(o))})},[(0,r.createVNode)((0,r.unref)(Mu),{id:a.id},null,8,["id"])],4))),128)),(0,r.createVNode)((0,r.unref)(Iu))],64))}}),Pu=(0,r.defineComponent)({name:"Node",compatConfig:{MODE:3},props:["id","resizeObserver"],setup(t){const{id:e,noPanClassName:n,selectNodesOnDrag:o,nodesSelectionActive:i,multiSelectionActive:s,emits:a,removeSelectedNodes:l,addSelectedNodes:d,updateNodeDimensions:c,onUpdateNodeInternals:u,getNodeTypes:h,nodeExtent:f,elevateNodesOnSelect:g,disableKeyboardA11y:m,ariaLiveMessage:E,snapToGrid:S,snapGrid:D,nodeDragThreshold:B,nodesDraggable:w,elementsSelectable:M,nodesConnectable:G,nodesFocusable:R,hooks:q}=pe(),K=(0,r.ref)(null);(0,r.provide)(ar,K),(0,r.provide)(sr,t.id);const j=(0,r.inject)(gn),Z=(0,r.getCurrentInstance)(),F=ur(),{node:k,parentNode:W}=dr(t.id),{emit:b,on:P}=Pd(k,a),v=(0,r.toRef)(()=>typeof k.draggable>"u"?w.value:k.draggable),N=(0,r.toRef)(()=>typeof k.selectable>"u"?M.value:k.selectable),I=(0,r.toRef)(()=>typeof k.connectable>"u"?G.value:k.connectable),T=(0,r.toRef)(()=>typeof k.focusable>"u"?R.value:k.focusable),z=(0,r.computed)(()=>N.value||v.value||q.value.nodeClick.hasListeners()||q.value.nodeDoubleClick.hasListeners()||q.value.nodeMouseEnter.hasListeners()||q.value.nodeMouseMove.hasListeners()||q.value.nodeMouseLeave.hasListeners()),O=(0,r.toRef)(()=>!!k.dimensions.width&&!!k.dimensions.height),L=(0,r.computed)(()=>{const y=k.type||"default",C=j?.[`node-${y}`];if(C)return C;let _=k.template||h.value[y];if(typeof _=="string"&&Z){const Y=Object.keys(Z.appContext.components);Y&&Y.includes(y)&&(_=(0,r.resolveComponent)(y,!1))}return _&&typeof _!="string"?_:(a.error(new we(ve.NODE_TYPE_MISSING,_)),!1)}),ee=lr({id:t.id,el:K,disabled:()=>!v.value,selectable:N,dragHandle:()=>k.dragHandle,onStart(y){b.dragStart(y)},onDrag(y){b.drag(y)},onStop(y){b.dragStop(y)},onClick(y){x(y)}}),se=(0,r.computed)(()=>k.class instanceof Function?k.class(k):k.class),V=(0,r.computed)(()=>{const y=(k.style instanceof Function?k.style(k):k.style)||{},C=k.width instanceof Function?k.width(k):k.width,_=k.height instanceof Function?k.height(k):k.height;return!y.width&&C&&(y.width=typeof C=="string"?C:`${C}px`),!y.height&&_&&(y.height=typeof _=="string"?_:`${_}px`),y}),X=(0,r.toRef)(()=>Number(k.zIndex??V.value.zIndex??0));return u(y=>{(y.includes(t.id)||!y.length)&&U()}),(0,r.onMounted)(()=>{(0,r.watch)(()=>k.hidden,(y=!1,C,_)=>{!y&&K.value&&(t.resizeObserver.observe(K.value),_(()=>{K.value&&t.resizeObserver.unobserve(K.value)}))},{immediate:!0,flush:"post"})}),(0,r.watch)([()=>k.type,()=>k.sourcePosition,()=>k.targetPosition],()=>{(0,r.nextTick)(()=>{c([{id:t.id,nodeElement:K.value,forceUpdate:!0}])})}),(0,r.watch)([()=>k.position.x,()=>k.position.y,()=>{var y;return(y=W.value)==null?void 0:y.computedPosition.x},()=>{var y;return(y=W.value)==null?void 0:y.computedPosition.y},()=>{var y;return(y=W.value)==null?void 0:y.computedPosition.z},X,()=>k.selected,()=>k.dimensions.height,()=>k.dimensions.width,()=>{var y;return(y=W.value)==null?void 0:y.dimensions.height},()=>{var y;return(y=W.value)==null?void 0:y.dimensions.width}],([y,C,_,Y,H,oe])=>{const Q={x:y,y:C,z:oe+(g.value&&k.selected?1e3:0)};typeof _<"u"&&typeof Y<"u"?k.computedPosition=fd({x:_,y:Y,z:H},Q):k.computedPosition=Q},{flush:"post",immediate:!0}),(0,r.watch)([()=>k.extent,f],([y,C],[_,Y])=>{(y!==_||C!==Y)&&A()}),k.extent==="parent"||typeof k.extent=="object"&&"range"in k.extent&&k.extent.range==="parent"?An(()=>O).toBe(!0).then(A):A(),()=>k.hidden?null:(0,r.h)("div",{ref:K,"data-id":k.id,class:["vue-flow__node",`vue-flow__node-${L.value===!1?"default":k.type||"default"}`,{[n.value]:v.value,dragging:ee?.value,draggable:v.value,selected:k.selected,selectable:N.value,parent:k.isParent},se.value],style:{visibility:O.value?"visible":"hidden",zIndex:k.computedPosition.z??X.value,transform:`translate(${k.computedPosition.x}px,${k.computedPosition.y}px)`,pointerEvents:z.value?"all":"none",...V.value},tabIndex:T.value?0:void 0,role:T.value?"group":void 0,"aria-describedby":m.value?void 0:`${Ni}-${e}`,"aria-label":k.ariaLabel,"aria-roledescription":"node",...k.domAttributes,onMouseenter:te,onMousemove:ie,onMouseleave:le,onContextmenu:J,onClick:x,onDblclick:re,onKeydown:p},[(0,r.h)(L.value===!1?h.value.default:L.value,{id:k.id,type:k.type,data:k.data,events:{...k.events,...P},selected:k.selected,resizing:k.resizing,dragging:ee.value,connectable:I.value,position:k.computedPosition,dimensions:k.dimensions,isValidTargetPos:k.isValidTargetPos,isValidSourcePos:k.isValidSourcePos,parent:k.parentNode,parentNodeId:k.parentNode,zIndex:k.computedPosition.z??X.value,targetPosition:k.targetPosition,sourcePosition:k.sourcePosition,label:k.label,dragHandle:k.dragHandle,onUpdateNodeInternals:U})]);function A(){const y=k.computedPosition,{computedPosition:C,position:_}=so(k,S.value?hn(y,D.value):y,a.error,f.value,W.value);(k.computedPosition.x!==C.x||k.computedPosition.y!==C.y)&&(k.computedPosition={...k.computedPosition,...C}),(k.position.x!==_.x||k.position.y!==_.y)&&(k.position=_)}function U(){K.value&&c([{id:t.id,nodeElement:K.value,forceUpdate:!0}])}function te(y){ee?.value||b.mouseEnter({event:y,node:k})}function ie(y){ee?.value||b.mouseMove({event:y,node:k})}function le(y){ee?.value||b.mouseLeave({event:y,node:k})}function J(y){return b.contextMenu({event:y,node:k})}function re(y){return b.doubleClick({event:y,node:k})}function x(y){N.value&&(!o.value||!v.value||B.value>0)&&uo(k,s.value,d,l,i,!1,K.value),b.click({event:y,node:k})}function p(y){if(!(oo(y)||m.value))if(Si.includes(y.key)&&N.value){const C=y.key==="Escape";uo(k,s.value,d,l,i,C,K.value)}else v.value&&k.selected&&ft[y.key]&&(y.preventDefault(),E.value=`Moved selected node ${y.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~k.position.x}, y: ${~~k.position.y}`,F({x:ft[y.key].x,y:ft[y.key].y},y.shiftKey))}}}),Ou={height:"0",width:"0"},Vu=(0,r.defineComponent)({name:"EdgeLabelRenderer",compatConfig:{MODE:3},setup(t){const{viewportRef:e}=pe(),n=(0,r.toRef)(()=>{var o;return(o=e.value)==null?void 0:o.getElementsByClassName("vue-flow__edge-labels")[0]});return(o,i)=>((0,r.openBlock)(),(0,r.createElementBlock)("svg",null,[((0,r.openBlock)(),(0,r.createElementBlock)("foreignObject",Ou,[((0,r.openBlock)(),(0,r.createBlock)(r.Teleport,{to:n.value,disabled:!n.value},[(0,r.renderSlot)(o.$slots,"default")],8,["to","disabled"]))]))]))}});function Hu(t={includeHiddenNodes:!1}){const{nodes:e}=pe();return(0,r.computed)(()=>{if(e.value.length===0)return!1;for(const n of e.value)if((t.includeHiddenNodes||!n.hidden)&&(n?.handleBounds===void 0||n.dimensions.width===0||n.dimensions.height===0))return!1;return!0})}var Lu={class:"vue-flow__nodes vue-flow__container"},Fu=(0,r.defineComponent)({name:"Nodes",compatConfig:{MODE:3},setup(t){const{getNodes:e,updateNodeDimensions:n,emits:o}=pe(),i=Hu(),s=(0,r.ref)();return(0,r.watch)(i,a=>{a&&(0,r.nextTick)(()=>{o.nodesInitialized(e.value)})},{immediate:!0}),(0,r.onMounted)(()=>{s.value=new ResizeObserver(a=>{const l=a.map(d=>({id:d.target.getAttribute("data-id"),nodeElement:d.target,forceUpdate:!0}));(0,r.nextTick)(()=>n(l))})}),(0,r.onBeforeUnmount)(()=>{var a;return(a=s.value)==null?void 0:a.disconnect()}),(a,l)=>((0,r.openBlock)(),(0,r.createElementBlock)("div",Lu,[s.value?((0,r.openBlock)(!0),(0,r.createElementBlock)(r.Fragment,{key:0},(0,r.renderList)((0,r.unref)(e),(d,c,u,h)=>{const f=[d.id];if(h&&h.key===d.id&&(0,r.isMemoSame)(h,f))return h;const g=((0,r.openBlock)(),(0,r.createBlock)((0,r.unref)(Pu),{id:d.id,key:d.id,"resize-observer":s.value},null,8,["id","resize-observer"]));return g.memo=f,g},l,0),128)):(0,r.createCommentVNode)("",!0)]))}});function Gu(){const{emits:t}=pe();(0,r.onMounted)(()=>{if(er()){const e=document.querySelector(".vue-flow__pane");e&&window.getComputedStyle(e).zIndex!=="1"&&t.error(new we(ve.MISSING_STYLES))}})}var Wu=(0,r.createElementVNode)("div",{class:"vue-flow__edge-labels"},null,-1),Uu=(0,r.defineComponent)({name:"VueFlow",compatConfig:{MODE:3},props:{id:{},modelValue:{},nodes:{},edges:{},edgeTypes:{},nodeTypes:{},connectionMode:{},connectionLineType:{},connectionLineStyle:{default:void 0},connectionLineOptions:{default:void 0},connectionRadius:{},isValidConnection:{type:[Function,null],default:void 0},deleteKeyCode:{default:void 0},selectionKeyCode:{type:[Boolean,null],default:void 0},multiSelectionKeyCode:{default:void 0},zoomActivationKeyCode:{default:void 0},panActivationKeyCode:{default:void 0},snapToGrid:{type:Boolean,default:void 0},snapGrid:{},onlyRenderVisibleElements:{type:Boolean,default:void 0},edgesUpdatable:{type:[Boolean,String],default:void 0},nodesDraggable:{type:Boolean,default:void 0},nodesConnectable:{type:Boolean,default:void 0},nodeDragThreshold:{},elementsSelectable:{type:Boolean,default:void 0},selectNodesOnDrag:{type:Boolean,default:void 0},panOnDrag:{type:[Boolean,Array],default:void 0},minZoom:{},maxZoom:{},defaultViewport:{},translateExtent:{},nodeExtent:{},defaultMarkerColor:{},zoomOnScroll:{type:Boolean,default:void 0},zoomOnPinch:{type:Boolean,default:void 0},panOnScroll:{type:Boolean,default:void 0},panOnScrollSpeed:{},panOnScrollMode:{},paneClickDistance:{},zoomOnDoubleClick:{type:Boolean,default:void 0},preventScrolling:{type:Boolean,default:void 0},selectionMode:{},edgeUpdaterRadius:{},fitViewOnInit:{type:Boolean,default:void 0},connectOnClick:{type:Boolean,default:void 0},applyDefault:{type:Boolean,default:void 0},autoConnect:{type:[Boolean,Function],default:void 0},noDragClassName:{},noWheelClassName:{},noPanClassName:{},defaultEdgeOptions:{},elevateEdgesOnSelect:{type:Boolean,default:void 0},elevateNodesOnSelect:{type:Boolean,default:void 0},disableKeyboardA11y:{type:Boolean,default:void 0},edgesFocusable:{type:Boolean,default:void 0},nodesFocusable:{type:Boolean,default:void 0},autoPanOnConnect:{type:Boolean,default:void 0},autoPanOnNodeDrag:{type:Boolean,default:void 0},autoPanSpeed:{}},emits:["nodesChange","edgesChange","nodesInitialized","paneReady","init","updateNodeInternals","error","connect","connectStart","connectEnd","clickConnectStart","clickConnectEnd","moveStart","move","moveEnd","selectionDragStart","selectionDrag","selectionDragStop","selectionContextMenu","selectionStart","selectionEnd","viewportChangeStart","viewportChange","viewportChangeEnd","paneScroll","paneClick","paneContextMenu","paneMouseEnter","paneMouseMove","paneMouseLeave","edgeUpdate","edgeContextMenu","edgeMouseEnter","edgeMouseMove","edgeMouseLeave","edgeDoubleClick","edgeClick","edgeUpdateStart","edgeUpdateEnd","nodeContextMenu","nodeMouseEnter","nodeMouseMove","nodeMouseLeave","nodeDoubleClick","nodeClick","nodeDragStart","nodeDrag","nodeDragStop","miniMapNodeClick","miniMapNodeDoubleClick","miniMapNodeMouseEnter","miniMapNodeMouseMove","miniMapNodeMouseLeave","update:modelValue","update:nodes","update:edges"],setup(t,{expose:e,emit:n}){const o=t,i=(0,r.useSlots)(),s=$n(o,"modelValue",n),a=$n(o,"nodes",n),l=$n(o,"edges",n),d=pe(o),c=Ld({modelValue:s,nodes:a,edges:l},o,d);return Gd(n,d.hooks),Su(),Gu(),(0,r.provide)(gn,i),(0,r.onUnmounted)(c),e(d),(u,h)=>((0,r.openBlock)(),(0,r.createElementBlock)("div",{ref:(0,r.unref)(d).vueFlowRef,class:"vue-flow"},[(0,r.createVNode)(Cu,null,{default:(0,r.withCtx)(()=>[(0,r.createVNode)($u),Wu,(0,r.createVNode)(Fu),(0,r.renderSlot)(u.$slots,"zoom-pane")]),_:3}),(0,r.renderSlot)(u.$slots,"default"),(0,r.createVNode)(ku)],512))}}),Yu=(0,r.defineComponent)({name:"Panel",compatConfig:{MODE:3},props:{position:{}},setup(t){const e=t,{userSelectionActive:n}=pe(),o=(0,r.computed)(()=>`${e.position}`.split("-"));return(i,s)=>((0,r.openBlock)(),(0,r.createElementBlock)("div",{class:(0,r.normalizeClass)(["vue-flow__panel",o.value]),style:(0,r.normalizeStyle)({pointerEvents:(0,r.unref)(n)?"none":"all"})},[(0,r.renderSlot)(i.$slots,"default")],6))}}),We=(t=>(t.Lines="lines",t.Dots="dots",t))(We||{}),Xu=function({dimensions:t,size:e,color:n}){return(0,r.h)("path",{stroke:n,"stroke-width":e,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})},ju=function({radius:t,color:e}){return(0,r.h)("circle",{cx:t,cy:t,r:t,fill:e})};We.Lines,We.Dots;var Zu={[We.Dots]:"#81818a",[We.Lines]:"#eee"},Ku=["id","x","y","width","height","patternTransform"],qu={key:2,height:"100",width:"100"},Ju=["fill"],Qu=["x","y","fill"],ef=(0,r.defineComponent)({name:"Background",compatConfig:{MODE:3},props:{id:{},variant:{default:()=>We.Dots},gap:{default:20},size:{default:1},lineWidth:{default:1},patternColor:{},color:{},bgColor:{},height:{default:100},width:{default:100},x:{default:0},y:{default:0},offset:{default:0}},setup(t){const{id:e,viewport:n}=pe(),o=(0,r.computed)(()=>{const a=n.value.zoom,[l,d]=Array.isArray(t.gap)?t.gap:[t.gap,t.gap],c=[l*a||1,d*a||1],u=t.size*a,[h,f]=Array.isArray(t.offset)?t.offset:[t.offset,t.offset];return{scaledGap:c,offset:[h*a||1+c[0]/2,f*a||1+c[1]/2],size:u}}),i=(0,r.toRef)(()=>`pattern-${e}${t.id?`-${t.id}`:""}`),s=(0,r.toRef)(()=>t.color||t.patternColor||Zu[t.variant||We.Dots]);return(a,l)=>((0,r.openBlock)(),(0,r.createElementBlock)("svg",{class:"vue-flow__background vue-flow__container",style:(0,r.normalizeStyle)({height:`${a.height>100?100:a.height}%`,width:`${a.width>100?100:a.width}%`})},[(0,r.renderSlot)(a.$slots,"pattern-container",{id:i.value},()=>[(0,r.createElementVNode)("pattern",{id:i.value,x:(0,r.unref)(n).x%o.value.scaledGap[0],y:(0,r.unref)(n).y%o.value.scaledGap[1],width:o.value.scaledGap[0],height:o.value.scaledGap[1],patternTransform:`translate(-${o.value.offset[0]},-${o.value.offset[1]})`,patternUnits:"userSpaceOnUse"},[(0,r.renderSlot)(a.$slots,"pattern",{},()=>[a.variant===(0,r.unref)(We).Lines?((0,r.openBlock)(),(0,r.createBlock)((0,r.unref)(Xu),{key:0,size:a.lineWidth,color:s.value,dimensions:o.value.scaledGap},null,8,["size","color","dimensions"])):a.variant===(0,r.unref)(We).Dots?((0,r.openBlock)(),(0,r.createBlock)((0,r.unref)(ju),{key:1,color:s.value,radius:o.value.size/2},null,8,["color","radius"])):(0,r.createCommentVNode)("",!0),a.bgColor?((0,r.openBlock)(),(0,r.createElementBlock)("svg",qu,[(0,r.createElementVNode)("rect",{width:"100%",height:"100%",fill:a.bgColor},null,8,Ju)])):(0,r.createCommentVNode)("",!0)])],8,Ku)]),(0,r.createElementVNode)("rect",{x:a.x,y:a.y,width:"100%",height:"100%",fill:`url(#${i.value})`},null,8,Qu),(0,r.renderSlot)(a.$slots,"default",{id:i.value})],4))}}),tf={name:"ControlButton",compatConfig:{MODE:3}},nf=(t,e)=>{const n=t.__vccOpts||t;for(const[o,i]of e)n[o]=i;return n},of={type:"button",class:"vue-flow__controls-button"};function rf(t,e,n,o,i,s){return(0,r.openBlock)(),(0,r.createElementBlock)("button",of,[(0,r.renderSlot)(t.$slots,"default")])}var bn=nf(tf,[["render",rf]]),sf={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},af=[(0,r.createElementVNode)("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"},null,-1)];function lf(t,e){return(0,r.openBlock)(),(0,r.createElementBlock)("svg",sf,af)}var cf={render:lf},df={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},uf=[(0,r.createElementVNode)("path",{d:"M0 0h32v4.2H0z"},null,-1)];function ff(t,e){return(0,r.openBlock)(),(0,r.createElementBlock)("svg",df,uf)}var hf={render:ff},gf={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},pf=[(0,r.createElementVNode)("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0 0 27.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94a.919.919 0 0 1-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"},null,-1)];function mf(t,e){return(0,r.openBlock)(),(0,r.createElementBlock)("svg",gf,pf)}var yf={render:mf},vf={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},_f=[(0,r.createElementVNode)("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 0 0 0 13.714v15.238A3.056 3.056 0 0 0 3.048 32h18.285a3.056 3.056 0 0 0 3.048-3.048V13.714a3.056 3.056 0 0 0-3.048-3.047zM12.19 24.533a3.056 3.056 0 0 1-3.047-3.047 3.056 3.056 0 0 1 3.047-3.048 3.056 3.056 0 0 1 3.048 3.048 3.056 3.056 0 0 1-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"},null,-1)];function wf(t,e){return(0,r.openBlock)(),(0,r.createElementBlock)("svg",vf,_f)}var bf={render:wf},Cf={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},Ef=[(0,r.createElementVNode)("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 0 0 0 13.714v15.238A3.056 3.056 0 0 0 3.048 32h18.285a3.056 3.056 0 0 0 3.048-3.048V13.714a3.056 3.056 0 0 0-3.048-3.047zM12.19 24.533a3.056 3.056 0 0 1-3.047-3.047 3.056 3.056 0 0 1 3.047-3.048 3.056 3.056 0 0 1 3.048 3.048 3.056 3.056 0 0 1-3.048 3.047z"},null,-1)];function xf(t,e){return(0,r.openBlock)(),(0,r.createElementBlock)("svg",Cf,Ef)}var Nf={render:xf},kf=(0,r.defineComponent)({name:"Controls",compatConfig:{MODE:3},props:{showZoom:{type:Boolean,default:!0},showFitView:{type:Boolean,default:!0},showInteractive:{type:Boolean,default:!0},fitViewParams:{},position:{default:()=>Ei.BottomLeft}},emits:["zoomIn","zoomOut","fitView","interactionChange"],setup(t,{emit:e}){const{nodesDraggable:n,nodesConnectable:o,elementsSelectable:i,setInteractive:s,zoomIn:a,zoomOut:l,fitView:d,viewport:c,minZoom:u,maxZoom:h}=pe(),f=(0,r.toRef)(()=>n.value||o.value||i.value),g=(0,r.toRef)(()=>c.value.zoom<=u.value),m=(0,r.toRef)(()=>c.value.zoom>=h.value);function E(){a(),e("zoomIn")}function S(){l(),e("zoomOut")}function D(){d(t.fitViewParams),e("fitView")}function B(){s(!f.value),e("interactionChange",!f.value)}return(w,M)=>((0,r.openBlock)(),(0,r.createBlock)((0,r.unref)(Yu),{class:"vue-flow__controls",position:w.position},{default:(0,r.withCtx)(()=>[(0,r.renderSlot)(w.$slots,"top"),w.showZoom?((0,r.openBlock)(),(0,r.createElementBlock)(r.Fragment,{key:0},[(0,r.renderSlot)(w.$slots,"control-zoom-in",{},()=>[(0,r.createVNode)(bn,{class:"vue-flow__controls-zoomin",disabled:m.value,onClick:E},{default:(0,r.withCtx)(()=>[(0,r.renderSlot)(w.$slots,"icon-zoom-in",{},()=>[((0,r.openBlock)(),(0,r.createBlock)((0,r.resolveDynamicComponent)((0,r.unref)(cf))))])]),_:3},8,["disabled"])]),(0,r.renderSlot)(w.$slots,"control-zoom-out",{},()=>[(0,r.createVNode)(bn,{class:"vue-flow__controls-zoomout",disabled:g.value,onClick:S},{default:(0,r.withCtx)(()=>[(0,r.renderSlot)(w.$slots,"icon-zoom-out",{},()=>[((0,r.openBlock)(),(0,r.createBlock)((0,r.resolveDynamicComponent)((0,r.unref)(hf))))])]),_:3},8,["disabled"])])],64)):(0,r.createCommentVNode)("",!0),w.showFitView?(0,r.renderSlot)(w.$slots,"control-fit-view",{key:1},()=>[(0,r.createVNode)(bn,{class:"vue-flow__controls-fitview",onClick:D},{default:(0,r.withCtx)(()=>[(0,r.renderSlot)(w.$slots,"icon-fit-view",{},()=>[((0,r.openBlock)(),(0,r.createBlock)((0,r.resolveDynamicComponent)((0,r.unref)(yf))))])]),_:3})]):(0,r.createCommentVNode)("",!0),w.showInteractive?(0,r.renderSlot)(w.$slots,"control-interactive",{key:2},()=>[w.showInteractive?((0,r.openBlock)(),(0,r.createBlock)(bn,{key:0,class:"vue-flow__controls-interactive",onClick:B},{default:(0,r.withCtx)(()=>[f.value?(0,r.renderSlot)(w.$slots,"icon-unlock",{key:0},()=>[((0,r.openBlock)(),(0,r.createBlock)((0,r.resolveDynamicComponent)((0,r.unref)(Nf))))]):(0,r.createCommentVNode)("",!0),f.value?(0,r.createCommentVNode)("",!0):(0,r.renderSlot)(w.$slots,"icon-lock",{key:1},()=>[((0,r.openBlock)(),(0,r.createBlock)((0,r.resolveDynamicComponent)((0,r.unref)(bf))))])]),_:3})):(0,r.createCommentVNode)("",!0)]):(0,r.createCommentVNode)("",!0),(0,r.renderSlot)(w.$slots,"default")]),_:3},8,["position"]))}}),Sf=["onClick"],Df={class:"d-flow-node-menus-item-name"},Tf=(0,r.defineComponent)({name:"DNodeMenus",__name:"nodeMenus",props:{fromNodeId:{},handleId:{}},emits:["addNode"],setup(t,{emit:e}){const n=t,o=e,i=(0,r.inject)("d_flow_design_provide",{}),s=i.getFlowComponents?.()||[],a=l=>{o("addNode",l.type),(0,r.nextTick)(()=>{n.handleId==="line"?i.addNodeByLine?.(l.type,n.fromNodeId||""):i.addNode?.(l.type,n.fromNodeId||"",n.handleId||"")})};return(l,d)=>{const c=(0,r.resolveComponent)("j-icon");return(0,r.openBlock)(),(0,r.createElementBlock)("div",{class:"d-flow-node-menus",onClick:(0,r.withModifiers)(()=>{},["stop"])},[((0,r.openBlock)(!0),(0,r.createElementBlock)(r.Fragment,null,(0,r.renderList)((0,r.unref)(s),(u,h)=>((0,r.openBlock)(),(0,r.createElementBlock)("div",{key:h,class:"d-flow-node-menus-item",onClick:f=>a(u)},[(0,r.createElementVNode)("div",{class:"d-flow-node-menus-item-icon",style:(0,r.normalizeStyle)({backgroundColor:u.iconColor||"var(--j-color-primary)"})},[(0,r.createVNode)(c,{icon:u.icon||"mdi:source-branch"},null,8,["icon"])],4),(0,r.createElementVNode)("div",Df,(0,r.toDisplayString)(u.name),1)],8,Sf))),128))])}}}),vo=Tf,Mf={class:"d-flow-step-name"},If={key:0,style:{color:"var(--j-color-text-2)"}},Bf={style:{color:"var(--j-color-text)"}},zf=(0,r.defineComponent)({name:"DStepNode",__name:"stepNode",props:{id:{},data:{}},setup(t){const e=t,{onNodeClick:n,onEdgeClick:o,onMoveStart:i,onConnectStart:s,onNodeDragStart:a,removeNodes:l,getEdges:d,getNodes:c,onNodesChange:u}=pe(),h=(0,r.inject)("d_flow_design_provide",{}),f=(0,r.computed)(()=>h.getFlowComponentMap?.value?.[e.data.type]||{}),g=()=>{l(e.id),h.onRemoveNode?.(e.id)},m=(0,r.ref)({});u(W=>{if(e.data.isInit&&W.findIndex(b=>b.type==="select"&&b.id===e.id&&b.id==="start"&&b.selected)!==-1){const b=c.value.find(P=>P.id==="start");b&&(b.data.isInit=!1),m.value.s1=!0}});const E=(0,r.ref)(!1),S=W=>{W.indexOf("t")!==-1&&!D.value||(E.value=!0,m.value[W]=!0)},D=(0,r.computed)(()=>d.value.findIndex(W=>W.target===e.id)===-1),B=(0,r.ref)(!1),w=()=>{B.value=!0},M=(W,b)=>{if(d.value.find(v=>v.source===b&&v.target===W))return!0;const P=d.value.filter(v=>v.target===W);for(let v=0;v<P.length;v++)if(M(P[v].source,b))return!0;return!1},G=W=>B.value?(B.value=!1,!1):M(W.source,W.target)?!1:W.source!==W.target&&W.sourceHandle!==W.targetHandle&&W.sourceHandle.indexOf("s")!==-1&&W.targetHandle.indexOf("t")!==-1,R=()=>{F(),Object.keys(m.value).forEach(W=>{m.value[W]=!1})},q=()=>{R()};n(()=>{console.log("onNodeClick"),E.value?E.value=!1:R()}),o(()=>{R()}),i(()=>{R()}),s(()=>{R()}),a(()=>{R()});const K=(0,r.ref)(),j=(0,r.ref)({top:0,left:0,bottom:0,right:0}),Z=(0,r.ref)({getBoundingClientRect:()=>j.value}),F=()=>{K.value?.handleClose()},k=W=>{const{clientX:b,clientY:P}=W;j.value=DOMRect.fromRect({x:b,y:P}),W.preventDefault(),K.value?.handleOpen()};return(W,b)=>{const P=(0,r.resolveComponent)("j-icon"),v=(0,r.resolveComponent)("el-popover"),N=(0,r.resolveComponent)("el-tooltip"),I=(0,r.resolveComponent)("el-dropdown-item"),T=(0,r.resolveComponent)("el-dropdown-menu"),z=(0,r.resolveComponent)("el-dropdown");return(0,r.openBlock)(),(0,r.createElementBlock)("div",{class:"d-flow-step",onContextmenu:(0,r.withModifiers)(k,["stop"])},[(0,r.createElementVNode)("div",{class:"d-flow-step-icon",style:(0,r.normalizeStyle)({backgroundColor:f.value.iconColor||"var(--j-color-primary)"})},[(0,r.createVNode)(P,{icon:f.value.icon||"mdi:source-branch"},null,8,["icon"])],4),(0,r.createElementVNode)("div",Mf,(0,r.toDisplayString)(f.value.name),1),t.data.type!=="start"?((0,r.openBlock)(),(0,r.createBlock)(N,{key:0,placement:"top","show-arrow":!1,"popper-class":"d-flow-step-tooltip"},{content:(0,r.withCtx)(()=>[D.value?((0,r.openBlock)(),(0,r.createElementBlock)("div",If,[...b[4]||(b[4]=[(0,r.createElementVNode)("span",{style:{color:"var(--j-color-text)","font-weight":"bold"}},"点击",-1),(0,r.createTextVNode)("添加节点 ",-1)])])):(0,r.createCommentVNode)("",!0),b[5]||(b[5]=(0,r.createElementVNode)("div",{style:{color:"var(--j-color-text-2)"}},[(0,r.createElementVNode)("span",{style:{color:"var(--j-color-text)","font-weight":"bold"}},"拖拽"),(0,r.createTextVNode)("连接节点 ")],-1))]),default:(0,r.withCtx)(()=>[(0,r.createVNode)((0,r.unref)(pt),{onClick:b[1]||(b[1]=O=>S("t1")),onMousedown:w,id:"t1",class:(0,r.normalizeClass)(["d-flow-step-target-handle",{"d-flow-step-target-handle-notadd":!D.value}]),type:"target",position:(0,r.unref)(ae).Left,"is-valid-connection":G},{default:(0,r.withCtx)(()=>[D.value?((0,r.openBlock)(),(0,r.createBlock)(v,{key:0,visible:m.value.t1,"onUpdate:visible":b[0]||(b[0]=O=>m.value.t1=O),placement:"left","popper-class":"d-flow-step-popper",trigger:"click","show-arrow":!1,"popper-options":{strategy:"fixed"}},{reference:(0,r.withCtx)(()=>[(0,r.createVNode)(P,{class:"d-flow-step-handle-plus",icon:"mdi:plus-circle"})]),default:(0,r.withCtx)(()=>[(0,r.createVNode)(vo,{"handle-id":"t1","from-node-id":t.id,onAddNode:q},null,8,["from-node-id"])]),_:1},8,["visible"])):(0,r.createCommentVNode)("",!0)]),_:1},8,["class","position"])]),_:1})):(0,r.createCommentVNode)("",!0),(0,r.createVNode)(N,{placement:"top","show-arrow":!1,"popper-class":"d-flow-step-tooltip"},{content:(0,r.withCtx)(()=>[...b[6]||(b[6]=[(0,r.createElementVNode)("div",{style:{color:"var(--j-color-text-2)"}},[(0,r.createElementVNode)("span",{style:{color:"var(--j-color-text)","font-weight":"bold"}},"点击"),(0,r.createTextVNode)("添加节点 ")],-1),(0,r.createElementVNode)("div",{style:{color:"var(--j-color-text-2)"}},[(0,r.createElementVNode)("span",{style:{color:"var(--j-color-text)","font-weight":"bold"}},"拖拽"),(0,r.createTextVNode)("连接节点 ")],-1)])]),default:(0,r.withCtx)(()=>[(0,r.createVNode)((0,r.unref)(pt),{onClick:b[3]||(b[3]=O=>S("s1")),onMousedown:w,id:"s1",class:"d-flow-step-source-handle",type:"source",position:(0,r.unref)(ae).Right,"is-valid-connection":G},{default:(0,r.withCtx)(()=>[(0,r.createVNode)(v,{visible:m.value.s1,"onUpdate:visible":b[2]||(b[2]=O=>m.value.s1=O),placement:"right",trigger:"click","popper-class":"d-flow-step-popper","show-arrow":!1,"popper-options":{strategy:"fixed"}},{reference:(0,r.withCtx)(()=>[(0,r.createVNode)(P,{class:"d-flow-step-handle-plus",icon:"mdi:plus-circle"})]),default:(0,r.withCtx)(()=>[(0,r.createVNode)(vo,{"handle-id":"s1","from-node-id":t.id,onAddNode:q},null,8,["from-node-id"])]),_:1},8,["visible"])]),_:1},8,["position"])]),_:1}),(0,r.createVNode)(z,{ref_key:"dropdownRef",ref:K,"popper-class":"d-flow-step-dropdown","virtual-ref":Z.value,"show-arrow":!1,"popper-options":{modifiers:[{name:"offset",options:{offset:[0,0]}}]},"virtual-triggering":"",trigger:"contextmenu",placement:"bottom-start"},{dropdown:(0,r.withCtx)(()=>[(0,r.createVNode)(T,null,{default:(0,r.withCtx)(()=>[t.data.type!="start"?((0,r.openBlock)(),(0,r.createBlock)(I,{key:0,onClick:g},{default:(0,r.withCtx)(()=>[...b[7]||(b[7]=[(0,r.createTextVNode)("删除",-1)])]),_:1})):(0,r.createCommentVNode)("",!0),f.value.des?((0,r.openBlock)(),(0,r.createElementBlock)("div",{key:1,style:(0,r.normalizeStyle)({width:"160px",padding:"4px 16px 0 16px","font-size":"12px","border-top":t.data.type!="start"?"1px solid var(--j-color-border)":void 0,"margin-top":t.data.type!="start"?"4px":void 0})},[b[8]||(b[8]=(0,r.createElementVNode)("div",{style:{"margin-bottom":"4px",color:"var(--j-color-text-2)"}},"关于",-1)),(0,r.createElementVNode)("div",Bf,(0,r.toDisplayString)(f.value.des),1)],4)):(0,r.createCommentVNode)("",!0)]),_:1})]),_:1},8,["virtual-ref"])],32)}}}),Rf=zf,Af=(0,r.defineComponent)({name:"DEdgeWithButton",__name:"edgeWithButton",props:{id:{},sourceX:{},sourceY:{},targetX:{},targetY:{},sourcePosition:{},targetPosition:{},markerEnd:{},style:{}},setup(t){const e=t,{onEdgeMouseEnter:n,onEdgeMouseLeave:o,onNodeClick:i,onEdgeClick:s,onMoveStart:a,onConnectStart:l,onNodeDragStart:d}=pe(),c=(0,r.computed)(()=>po(e)),u=(0,r.ref)(!1),h=(0,r.ref)(!1);n(({edge:S})=>{S.id===e.id&&(u.value=!0)}),o(()=>{u.value=!1});const f=(0,r.ref)(!1),g=()=>{f.value=!1,(0,r.nextTick)(()=>{h.value=!1})},m=()=>{h.value=!0,f.value=!0},E=()=>{g()};return i(()=>{g()}),s(()=>{g()}),a(()=>{g()}),l(()=>{g()}),d(()=>{g()}),(S,D)=>{const B=(0,r.resolveComponent)("j-icon"),w=(0,r.resolveComponent)("el-popover");return(0,r.openBlock)(),(0,r.createElementBlock)(r.Fragment,null,[(0,r.createVNode)((0,r.unref)(Ot),{id:t.id,style:(0,r.normalizeStyle)(t.style),path:c.value[0],"marker-end":t.markerEnd},null,8,["id","style","path","marker-end"]),(0,r.createVNode)((0,r.unref)(Vu),null,{default:(0,r.withCtx)(()=>[(0,r.createElementVNode)("div",{style:(0,r.normalizeStyle)({pointerEvents:"all",position:"absolute",transform:`translate(-50%, -50%) translate(${c.value[1]}px,${c.value[2]}px)`}),class:"nodrag nopan"},[(0,r.createVNode)(w,{visible:f.value,"show-arrow":!1,placement:"right","popper-class":"d-flow-step-popper"},{reference:(0,r.withCtx)(()=>[(0,r.withDirectives)((0,r.createElementVNode)("div",{onClick:(0,r.withModifiers)(m,["stop"]),class:"d-flow-edge-button"},[(0,r.createVNode)(B,{icon:"mdi:plus-circle"})],512),[[r.vShow,u.value||h.value]])]),default:(0,r.withCtx)(()=>[(0,r.createVNode)(vo,{"handle-id":"line","from-node-id":t.id,onAddNode:E},null,8,["from-node-id"])]),_:1},8,["visible"])],4)]),_:1})],64)}}}),$f=Af,Pf=(0,r.defineComponent)({name:"DFlow",__name:"flow",props:{nodes:{default:()=>[]},edges:{default:()=>[]}},setup(t){return(e,n)=>((0,r.openBlock)(),(0,r.createBlock)((0,r.unref)(Uu),{"min-zoom":.2,"max-zoom":4,"default-viewport":{zoom:1},"connection-mode":(0,r.unref)(Fe).Strict,nodes:t.nodes,edges:t.edges},{"edge-button":(0,r.withCtx)(o=>[(0,r.createVNode)($f,{id:o.id,"source-x":o.sourceX,"source-y":o.sourceY,"target-x":o.targetX,"target-y":o.targetY,"source-position":o.sourcePosition,"target-position":o.targetPosition,"marker-end":o.markerEnd,style:(0,r.normalizeStyle)(o.style)},null,8,["id","source-x","source-y","target-x","target-y","source-position","target-position","marker-end","style"])]),"node-step":(0,r.withCtx)(o=>[(0,r.createVNode)(Rf,(0,r.normalizeProps)((0,r.guardReactiveProps)(o)),null,16)]),default:(0,r.withCtx)(()=>[(0,r.createVNode)((0,r.unref)(kf),{position:"bottom-left"}),(0,r.createVNode)((0,r.unref)(ef))]),_:1},8,["connection-mode","nodes","edges"]))}}),Of=Pf,Vf={class:"d-flow-design"},Hf={class:"d-flow-design-canvas"},Lf={class:"d-flow-design-right"},Ff={class:"d-flow-design-title"},Gf={class:"d-flow-design-title-name"},Wf={class:"d-flow-design-panel"},Uf=(0,r.defineComponent)({name:"DFlowDesign",__name:"flowDesign",props:{components:{default:()=>[]},inputParams:{default:()=>({})},flowInit:{},flowComponentConfigInit:{},flowComponentConfigs:{default:()=>({})},flowComponentConfigChange:{}},emits:["nodeClick","edgeClick","paneClick","connect"],setup(t,{expose:e,emit:n}){const o=t,i=n,{addNodes:s,addEdges:a,removeEdges:l,addSelectedNodes:d,removeSelectedNodes:c,onConnect:u,onNodeClick:h,onPaneClick:f,onEdgeClick:g,getNodes:m,getEdges:E}=pe(),S=(0,r.computed)(()=>{const T={};return o.components.forEach(z=>{T[z.type]=z}),T.start={name:"开始",type:"start",icon:"ant-design:play-circle-outlined",des:"执行开始节点"},T}),D={id:"start",type:"step",data:{type:"start",isInit:!1},position:{x:80,y:160}},B=(0,r.ref)([D]),w=(0,r.ref)([]),M=(T,z)=>{if(z.indexOf("t")===-1){const O=E.value.filter(L=>L.source===T.id);if(O.length>0){let L=-1e6,ee=0;return O.forEach(se=>{L=Math.max(L,se.targetNode.position.y+se.targetNode.dimensions.height+32),ee=se.targetNode.position.x||0}),{x:ee,y:L}}return{x:T.position.x+T.dimensions.width+100,y:T.position.y}}return{x:T.position.x-100-T.dimensions.width,y:T.position.y}},G=(T,z,O)=>{const L=m.value.find(se=>se.id===z);if(!L)return;const ee={id:rt(),type:"step",data:{type:T},position:M(L,O)};if(o.flowInit){const se=o.flowInit(ee.data.type);se&&Object.keys(se).forEach(V=>{ee.data[V]=se[V]})}s(ee),O.indexOf("t")===-1?a({id:`${z}-${ee.id}`,source:z,target:ee.id,sourceHandle:"s1",targetHandle:"t1",type:"button",markerEnd:Ge.Arrow}):a({id:`${z}-${ee.id}`,source:ee.id,target:z,sourceHandle:"s1",targetHandle:"t1",type:"button",markerEnd:Ge.Arrow}),k(ee.id)},R=T=>{const z=m.value.find(O=>O.id===T);z&&(z.position.x+=100+z.dimensions.width,E.value.filter(O=>O.source===T).forEach(O=>{R(O.target)}))},q=(T,z)=>{const O=E.value.find(ee=>ee.id===z);if(!O)return;const L={id:rt(),type:"step",data:{type:T},position:{x:O.targetNode.position.x,y:O.targetNode.position.y}};if(o.flowInit){const ee=o.flowInit(L.data.type);ee&&Object.keys(ee).forEach(se=>{L.data[se]=ee[se]})}s(L),a({id:`${O.sourceNode.id}-${L.id}`,source:O.sourceNode.id,target:L.id,sourceHandle:"s1",targetHandle:"t1",type:"button",markerEnd:Ge.Arrow}),a({id:`${L.id}-${O.targetNode.id}`,source:L.id,target:O.targetNode.id,sourceHandle:"s1",targetHandle:"t1",type:"button",markerEnd:Ge.Arrow}),l(z),R(O.target),k(L.id)};u(T=>{console.log("onConnect",T),T.type="button",T.markerEnd=Ge.Arrow,a(T),i("connect",T)});const K=()=>o.components||[],j=(0,r.ref)(),Z=(0,r.computed)(()=>j.value?S.value[j.value.data.type]:void 0);h(T=>{j.value?.id!==T.node.id&&(j.value=T.node,P()),i("nodeClick",T.node)}),f(()=>{j.value=void 0,i("paneClick")}),g(T=>{j.value=void 0,i("edgeClick",T.edge)});const F=T=>{j.value?.id===T&&(j.value=void 0)},k=T=>{j.value&&c([j.value]),j.value=m.value.find(z=>z.id===T),j.value&&(P(),setTimeout(()=>{j.value&&d([j.value])},100))},W=(0,r.ref)(),b={};Object.keys(o.flowComponentConfigs).forEach(T=>{const z={type:"j-collapse",config:{defaultValue:[]},children:[]};o.flowComponentConfigs[T].forEach((O,L)=>{const ee=`_collapse${L}`;z.config?.defaultValue.push(ee),z.children?.push(O)}),b[T]=[z]});const P=()=>{const T=b[j.value?.data.type||""];T&&W.value?(W.value.init&&W.value.init(T,j.value?.data),o.flowComponentConfigInit&&o.flowComponentConfigInit({configRef:W,inputParams:o.inputParams,components:m.value,configData:j.value?.data})):W.value&&W.value.init&&W.value.init([])},v=(T,z)=>{j.value&&o.flowComponentConfigChange&&o.flowComponentConfigChange(j.value.data.type,{configRef:W,component:T,configData:j.value.data,...z,isFlowNode:!0})};return(0,r.provide)("d_flow_design_provide",{getFlowComponents:K,addNode:G,addNodeByLine:q,onRemoveNode:F,getFlowComponentMap:S}),e({getData:()=>{const T=[];return m.value.forEach(z=>{T.push({config:z.data,id:z.id,position:z.position,type:z.type})}),E.value.forEach(z=>{T.push({id:z.id,source:z.source,target:z.target,sourceHandle:z.sourceHandle,targetHandle:z.targetHandle,type:"line",config:{},position:{x:0,y:0}})}),T},setData:T=>{if(!T||T.length===0)D.data.isInit=!0,B.value=[D],k(D.id);else{D.data.isInit=!1;const z=[],O=[];T.forEach(L=>{if(L.type==="line")L.type="button",L.markerEnd=Ge.Arrow,O.push(L);else{const ee={id:L.id,type:L.type,data:L.config,position:L.position};z.push(ee)}}),B.value=z,w.value=O}}}),(T,z)=>{const O=(0,r.resolveComponent)("j-icon"),L=(0,r.resolveComponent)("j-form");return(0,r.openBlock)(),(0,r.createElementBlock)("div",Vf,[(0,r.createElementVNode)("div",Hf,[(0,r.createVNode)(Of,{nodes:B.value,edges:w.value},null,8,["nodes","edges"])]),(0,r.withDirectives)((0,r.createElementVNode)("div",Lf,[(0,r.createElementVNode)("div",Ff,[(0,r.createElementVNode)("div",{class:"d-flow-design-title-icon",style:(0,r.normalizeStyle)({backgroundColor:Z.value?.iconColor||"var(--j-color-primary)"})},[(0,r.createVNode)(O,{icon:Z.value?.icon||"mdi:source-branch"},null,8,["icon"])],4),(0,r.createElementVNode)("div",Gf,(0,r.toDisplayString)(Z.value?.name||""),1)]),(0,r.createElementVNode)("div",Wf,[(0,r.createVNode)(L,{config:{labelPosition:"top"},style:{padding:"0"},ref_key:"configRef",ref:W,onChange:v},null,512)])],512),[[r.vShow,j.value&&b[j.value.data.type]]])])}}}),Yf=Uf,Cr=qe(Yf),Xf={class:"d-input-flow j-block"},jf=(0,r.defineComponent)({name:"DInputFlow",__name:"inputFlow",props:{modelValue:{},type:{},btnText:{default:"事件"},title:{},size:{default:"default"},width:{default:1200},height:{default:800},beforeClose:{},flowComponents:{default:()=>[]},inputParams:{default:()=>({})},flowInit:{},flowComponentConfigInit:{},flowComponentConfigs:{default:()=>({})},flowComponentConfigChange:{}},emits:["update:modelValue","change"],setup(t,{emit:e}){const n=t,o=e,i=(0,r.ref)(),s=(0,r.computed)({get(){return n.modelValue},set(h){o("update:modelValue",h)}}),a=(0,r.computed)(()=>(n.modelValue?.trim(),n.btnText)),l=h=>{const f=typeof h=="string"?h:void 0;try{i.value?.setData(JSON.parse(f||"[]"))}catch{i.value?.setData([])}},d=async()=>{const h=i.value?.getData();return h?JSON.stringify(h):void 0},c=h=>{if(n.beforeClose){const f=typeof h=="string"?h:void 0;return n.beforeClose(f)}return!0},u=h=>{const f=h.value;o("change",{value:typeof f=="string"?f:void 0})};return(h,f)=>{const g=(0,r.resolveComponent)("d-flow-design"),m=(0,r.resolveComponent)("j-input-button");return(0,r.openBlock)(),(0,r.createBlock)(m,(0,r.mergeProps)(h.$attrs,{type:t.type,"btn-text":a.value,title:t.title,size:t.size,width:t.width,height:t.height,"before-close":c,ok:d,open:l,"destroy-on-close":"",modelValue:s.value,"onUpdate:modelValue":f[0]||(f[0]=E=>s.value=E),onChange:u}),{default:(0,r.withCtx)(()=>[(0,r.createElementVNode)("div",Xf,[(0,r.createVNode)(g,{ref_key:"flowRef",ref:i,components:t.flowComponents,"flow-init":t.flowInit,"flow-component-config-init":t.flowComponentConfigInit,"flow-component-configs":t.flowComponentConfigs,"flow-component-config-change":t.flowComponentConfigChange,"input-params":t.inputParams},null,8,["components","flow-init","flow-component-config-init","flow-component-configs","flow-component-config-change","input-params"])])]),_:1},16,["type","btn-text","title","size","width","height","modelValue"])}}}),Zf=jf,Er=qe(Zf),$=class De{static getElements(e,n=document){if(typeof e=="string"){const o="getElementById"in n?n:void 0;if(o&&!isNaN(+e[0])){const s=o.getElementById(e);return s?[s]:[]}let i=n.querySelectorAll(e);if(!i.length&&e[0]!=="."&&e[0]!=="#"&&(i=n.querySelectorAll("."+e),i.length||(i=n.querySelectorAll("#"+e)),!i.length)){const s=n.querySelector(`[gs-id="${e}"]`);return s?[s]:[]}return Array.from(i)}return[e]}static getElement(e,n=document){if(typeof e=="string"){const o="getElementById"in n?n:void 0;if(!e.length)return null;if(o&&e[0]==="#")return o.getElementById(e.substring(1));if(e[0]==="#"||e[0]==="."||e[0]==="[")return n.querySelector(e);if(o&&!isNaN(+e[0]))return o.getElementById(e);let i=n.querySelector(e);return o&&!i&&(i=o.getElementById(e)),i||(i=n.querySelector("."+e)),i}return e}static lazyLoad(e){return e.lazyLoad||e.grid?.opts?.lazyLoad&&e.lazyLoad!==!1}static createDiv(e,n){const o=document.createElement("div");return e.forEach(i=>{i&&o.classList.add(i)}),n?.appendChild(o),o}static shouldSizeToContent(e,n=!1){return e?.grid&&(n?e.sizeToContent===!0||e.grid.opts.sizeToContent===!0&&e.sizeToContent===void 0:!!e.sizeToContent||e.grid.opts.sizeToContent&&e.sizeToContent!==!1)}static isIntercepted(e,n){return!(e.y>=n.y+n.h||e.y+e.h<=n.y||e.x+e.w<=n.x||e.x>=n.x+n.w)}static isTouching(e,n){return De.isIntercepted(e,{x:n.x-.5,y:n.y-.5,w:n.w+1,h:n.h+1})}static areaIntercept(e,n){const o=e.x>n.x?e.x:n.x,i=e.x+e.w<n.x+n.w?e.x+e.w:n.x+n.w;if(i<=o)return 0;const s=e.y>n.y?e.y:n.y,a=e.y+e.h<n.y+n.h?e.y+e.h:n.y+n.h;return a<=s?0:(i-o)*(a-s)}static area(e){return e.w*e.h}static sort(e,n=1){return e.sort((i,s)=>{const a=n*((i.y??1e4)-(s.y??1e4));return a===0?n*((i.x??1e4)-(s.x??1e4)):a})}static find(e,n){return n?e.find(o=>o.id===n):void 0}static toBool(e){return typeof e=="boolean"?e:typeof e=="string"?(e=e.toLowerCase(),!(e===""||e==="no"||e==="false"||e==="0")):!!e}static toNumber(e){return e===null||e.length===0?void 0:Number(e)}static parseHeight(e){let n,o="px";if(typeof e=="string")if(e==="auto"||e==="")n=0;else{const i=e.match(/^(-[0-9]+\.[0-9]+|[0-9]*\.[0-9]+|-[0-9]+|[0-9]+)(px|em|rem|vh|vw|%|cm|mm)?$/);if(!i)throw new Error(`Invalid height val = ${e}`);o=i[2]||"px",n=parseFloat(i[1])}else n=e;return{h:n,unit:o}}static defaults(e,...n){return n.forEach(o=>{for(const i in o){if(!o.hasOwnProperty(i))return;e[i]===null||e[i]===void 0?e[i]=o[i]:typeof o[i]=="object"&&typeof e[i]=="object"&&De.defaults(e[i],o[i])}}),e}static same(e,n){if(typeof e!="object")return e==n;if(typeof e!=typeof n||Object.keys(e).length!==Object.keys(n).length)return!1;for(const o in e)if(e[o]!==n[o])return!1;return!0}static copyPos(e,n,o=!1){return n.x!==void 0&&(e.x=n.x),n.y!==void 0&&(e.y=n.y),n.w!==void 0&&(e.w=n.w),n.h!==void 0&&(e.h=n.h),o&&(n.minW&&(e.minW=n.minW),n.minH&&(e.minH=n.minH),n.maxW&&(e.maxW=n.maxW),n.maxH&&(e.maxH=n.maxH)),e}static samePos(e,n){return e&&n&&e.x===n.x&&e.y===n.y&&(e.w||1)===(n.w||1)&&(e.h||1)===(n.h||1)}static sanitizeMinMax(e){e.minW||delete e.minW,e.minH||delete e.minH,e.maxW||delete e.maxW,e.maxH||delete e.maxH}static removeInternalAndSame(e,n){if(!(typeof e!="object"||typeof n!="object")&&!(Array.isArray(e)||Array.isArray(n)))for(let o in e){const i=e[o],s=n[o];o[0]==="_"||i===s?delete e[o]:i&&typeof i=="object"&&s!==void 0&&(De.removeInternalAndSame(i,s),Object.keys(i).length||delete e[o])}}static removeInternalForSave(e,n=!0){for(let o in e)(o[0]==="_"||e[o]===null||e[o]===void 0)&&delete e[o];delete e.grid,n&&delete e.el,e.autoPosition||delete e.autoPosition,e.noResize||delete e.noResize,e.noMove||delete e.noMove,e.locked||delete e.locked,(e.w===1||e.w===e.minW)&&delete e.w,(e.h===1||e.h===e.minH)&&delete e.h}static throttle(e,n){let o=!1;return(...i)=>{o||(o=!0,setTimeout(()=>{e(...i),o=!1},n))}}static removePositioningStyles(e){const n=e.style;n.position&&n.removeProperty("position"),n.left&&n.removeProperty("left"),n.top&&n.removeProperty("top"),n.width&&n.removeProperty("width"),n.height&&n.removeProperty("height")}static getScrollElement(e){if(!e)return document.scrollingElement||document.documentElement;const n=getComputedStyle(e);return/(auto|scroll)/.test(n.overflow+n.overflowY)?e:De.getScrollElement(e.parentElement)}static updateScrollPosition(e,n,o){const i=De.getScrollElement(e);if(!i)return;const s=e.getBoundingClientRect(),a=i.getBoundingClientRect(),l=window.innerHeight||document.documentElement.clientHeight,d=s.bottom-Math.min(a.bottom,l),c=s.top-Math.max(a.top,0),u=i.scrollTop;c<0&&o<0?e.offsetHeight>a.height?i.scrollTop+=o:i.scrollTop+=Math.abs(c)>Math.abs(o)?o:c:d>0&&o>0&&(e.offsetHeight>a.height?i.scrollTop+=o:i.scrollTop+=d>o?o:d),n.top+=i.scrollTop-u}static updateScrollResize(e,n,o){const i=De.getScrollElement(n),s=i.clientHeight,a=i===De.getScrollElement()?0:i.getBoundingClientRect().top,l=e.clientY-a,d=l<o,c=l>s-o;d?i.scrollBy({behavior:"smooth",top:l-o}):c&&i.scrollBy({behavior:"smooth",top:o-(s-l)})}static clone(e){return e==null||typeof e!="object"?e:e instanceof Array?[...e]:{...e}}static cloneDeep(e){const n=["parentGrid","el","grid","subGrid","engine"],o=De.clone(e);for(const i in o)o.hasOwnProperty(i)&&typeof o[i]=="object"&&i.substring(0,2)!=="__"&&!n.find(s=>s===i)&&(o[i]=De.cloneDeep(e[i]));return o}static cloneNode(e){const n=e.cloneNode(!0);return n.removeAttribute("id"),n}static appendTo(e,n){let o;typeof n=="string"?o=De.getElement(n):o=n,o&&o.appendChild(e)}static addElStyles(e,n){if(n instanceof Object)for(const o in n)n.hasOwnProperty(o)&&(Array.isArray(n[o])?n[o].forEach(i=>{e.style[o]=i}):e.style[o]=n[o])}static initEvent(e,n){const o={type:n.type},i={button:0,which:0,buttons:1,bubbles:!0,cancelable:!0,target:n.target?n.target:e.target};return["altKey","ctrlKey","metaKey","shiftKey"].forEach(s=>o[s]=e[s]),["pageX","pageY","clientX","clientY","screenX","screenY"].forEach(s=>o[s]=e[s]),{...o,...i}}static simulateMouseEvent(e,n,o){const i=e,s=new MouseEvent(n,{bubbles:!0,composed:!0,cancelable:!0,view:window,detail:1,screenX:e.screenX,screenY:e.screenY,clientX:e.clientX,clientY:e.clientY,ctrlKey:i.ctrlKey??!1,altKey:i.altKey??!1,shiftKey:i.shiftKey??!1,metaKey:i.metaKey??!1,button:0,relatedTarget:e.target});(o||e.target).dispatchEvent(s)}static getValuesFromTransformedElement(e){const n=document.createElement("div");De.addElStyles(n,{opacity:"0",position:"fixed",top:"0px",left:"0px",width:"1px",height:"1px",zIndex:"-999999"}),e.appendChild(n);const o=n.getBoundingClientRect();return e.removeChild(n),n.remove(),{xScale:1/o.width,yScale:1/o.height,xOffset:o.left,yOffset:o.top}}static swap(e,n,o){if(!e)return;const i=e[n];e[n]=e[o],e[o]=i}static canBeRotated(e){return!(!e||e.w===e.h||e.locked||e.noResize||e.grid?.opts.disableResize||e.minW&&e.minW===e.maxW||e.minH&&e.minH===e.maxH)}},_o=class vt{constructor(e={}){this.addedNodes=[],this.removedNodes=[],this.defaultColumn=12,this.column=e.column||this.defaultColumn,this.column>this.defaultColumn&&(this.defaultColumn=this.column),this.maxRow=e.maxRow,this._float=e.float,this.nodes=e.nodes||[],this.onChange=e.onChange}batchUpdate(e=!0,n=!0){return!!this.batchMode===e?this:(this.batchMode=e,e?(this._prevFloat=this._float,this._float=!0,this.cleanNodes(),this.saveInitial()):(this._float=this._prevFloat,delete this._prevFloat,n&&this._packNodes(),this._notify()),this)}_useEntireRowArea(e,n){return(!this.float||this.batchMode&&!this._prevFloat)&&!this._hasLocked&&(!e._moving||e._skipDown||n.y<=e.y)}_fixCollisions(e,n=e,o,i={}){if(this.sortNodes(-1),o=o||this.collide(e,n),!o)return!1;if(e._moving&&!i.nested&&!this.float&&this.swap(e,o))return!0;let s=n;!this._loading&&this._useEntireRowArea(e,n)&&(s={x:0,w:this.column,y:n.y,h:n.h},o=this.collide(e,s,i.skip));let a=!1;const l={nested:!0,pack:!1};let d=0;for(;o=o||this.collide(e,s,i.skip);){if(d++>this.nodes.length*2)throw new Error("Infinite collide check");let c;if(o.locked||this._loading||e._moving&&!e._skipDown&&n.y>e.y&&!this.float&&(!this.collide(o,{...o,y:e.y},e)||!this.collide(o,{...o,y:n.y-o.h},e))){e._skipDown=e._skipDown||n.y>e.y;const u={...n,y:o.y+o.h,...l};c=this._loading&&$.samePos(e,u)?!0:this.moveNode(e,u),(o.locked||this._loading)&&c?$.copyPos(n,e):!o.locked&&c&&i.pack&&(this._packNodes(),n.y=o.y+o.h,$.copyPos(e,n)),a=a||c}else c=this.moveNode(o,{...o,y:n.y+n.h,skip:e,...l});if(!c)return a;o=void 0}return a}collide(e,n=e,o){const i=e._id,s=o?._id;return this.nodes.find(a=>a._id!==i&&a._id!==s&&$.isIntercepted(a,n))}collideAll(e,n=e,o){const i=e._id,s=o?._id;return this.nodes.filter(a=>a._id!==i&&a._id!==s&&$.isIntercepted(a,n))}directionCollideCoverage(e,n,o){if(!n.rect||!e._rect)return;const i=e._rect,s={...n.rect};s.y>i.y?(s.h+=s.y-i.y,s.y=i.y):s.h+=i.y-s.y,s.x>i.x?(s.w+=s.x-i.x,s.x=i.x):s.w+=i.x-s.x;let a,l=.5;for(let d of o){if(d.locked||!d._rect)break;const c=d._rect;let u=Number.MAX_VALUE,h=Number.MAX_VALUE;i.y<c.y?u=(s.y+s.h-c.y)/c.h:i.y+i.h>c.y+c.h&&(u=(c.y+c.h-s.y)/c.h),i.x<c.x?h=(s.x+s.w-c.x)/c.w:i.x+i.w>c.x+c.w&&(h=(c.x+c.w-s.x)/c.w);const f=Math.min(h,u);f>l&&(l=f,a=d)}return n.collide=a,a}cacheRects(e,n,o,i,s,a){return this.nodes.forEach(l=>l._rect={y:l.y*n+o,x:l.x*e+a,w:l.w*e-a-i,h:l.h*n-o-s}),this}swap(e,n){if(!n||n.locked||!e||e.locked)return!1;function o(){const s=n.x,a=n.y;return n.x=e.x,n.y=e.y,e.h!=n.h?(e.x=s,e.y=n.y+n.h):e.w!=n.w?(e.x=n.x+n.w,e.y=a):(e.x=s,e.y=a),e._dirty=n._dirty=!0,!0}let i;if(e.w===n.w&&e.h===n.h&&(e.x===n.x||e.y===n.y)&&(i=$.isTouching(e,n)))return o();if(i!==!1){if(e.w===n.w&&e.x===n.x&&(i||(i=$.isTouching(e,n)))){if(n.y<e.y){const s=e;e=n,n=s}return o()}if(i!==!1){if(e.h===n.h&&e.y===n.y&&(i||(i=$.isTouching(e,n)))){if(n.x<e.x){const s=e;e=n,n=s}return o()}return!1}}}isAreaEmpty(e,n,o,i){const s={x:e||0,y:n||0,w:o||1,h:i||1};return!this.collide(s)}compact(e="compact",n=!0){if(this.nodes.length===0)return this;n&&this.sortNodes();const o=this.batchMode;o||this.batchUpdate();const i=this._inColumnResize;i||(this._inColumnResize=!0);const s=this.nodes;return this.nodes=[],s.forEach((a,l,d)=>{let c;a.locked||(a.autoPosition=!0,e==="list"&&l&&(c=d[l-1])),this.addNode(a,!1,c)}),i||delete this._inColumnResize,o||this.batchUpdate(!1),this}set float(e){this._float!==e&&(this._float=e||!1,e||this._packNodes()._notify())}get float(){return this._float||!1}sortNodes(e=1){return this.nodes=$.sort(this.nodes,e),this}_packNodes(){return this.batchMode?this:(this.sortNodes(),this.float?this.nodes.forEach(e=>{if(e._updating||e._orig===void 0||e.y===e._orig.y)return;let n=e.y;for(;n>e._orig.y;)--n,this.collide(e,{x:e.x,y:n,w:e.w,h:e.h})||(e._dirty=!0,e.y=n)}):this.nodes.forEach((e,n)=>{if(!e.locked)for(;e.y>0;){const o=n===0?0:e.y-1;if(!(n===0||!this.collide(e,{x:e.x,y:o,w:e.w,h:e.h})))break;e._dirty=e.y!==o,e.y=o}}),this)}prepareNode(e,n){e._id=e._id??vt._idSeq++;const o=e.id;if(o){let s=1;for(;this.nodes.find(a=>a.id===e.id&&a!==e);)e.id=o+"_"+s++}(e.x===void 0||e.y===void 0||e.x===null||e.y===null)&&(e.autoPosition=!0);const i={x:0,y:0,w:1,h:1};return $.defaults(e,i),e.autoPosition||delete e.autoPosition,e.noResize||delete e.noResize,e.noMove||delete e.noMove,$.sanitizeMinMax(e),typeof e.x=="string"&&(e.x=Number(e.x)),typeof e.y=="string"&&(e.y=Number(e.y)),typeof e.w=="string"&&(e.w=Number(e.w)),typeof e.h=="string"&&(e.h=Number(e.h)),isNaN(e.x)&&(e.x=i.x,e.autoPosition=!0),isNaN(e.y)&&(e.y=i.y,e.autoPosition=!0),isNaN(e.w)&&(e.w=i.w),isNaN(e.h)&&(e.h=i.h),this.nodeBoundFix(e,n),e}nodeBoundFix(e,n){const o=e._orig||$.copyPos({},e);if(e.maxW&&(e.w=Math.min(e.w||1,e.maxW)),e.maxH&&(e.h=Math.min(e.h||1,e.maxH)),e.minW&&(e.w=Math.max(e.w||1,e.minW)),e.minH&&(e.h=Math.max(e.h||1,e.minH)),(e.x||0)+(e.w||1)>this.column&&this.column<this.defaultColumn&&!this._inColumnResize&&!this.skipCacheUpdate&&e._id!=null&&this.findCacheLayout(e,this.defaultColumn)===-1){const i={...e};i.autoPosition||i.x===void 0?(delete i.x,delete i.y):i.x=Math.min(this.defaultColumn-1,i.x),i.w=Math.min(this.defaultColumn,i.w||1),this.cacheOneLayout(i,this.defaultColumn)}return e.w>this.column?e.w=this.column:e.w<1&&(e.w=1),this.maxRow&&e.h>this.maxRow?e.h=this.maxRow:e.h<1&&(e.h=1),e.x<0&&(e.x=0),e.y<0&&(e.y=0),e.x+e.w>this.column&&(n?e.w=this.column-e.x:e.x=this.column-e.w),this.maxRow&&e.y+e.h>this.maxRow&&(n?e.h=this.maxRow-e.y:e.y=this.maxRow-e.h),$.samePos(e,o)||(e._dirty=!0),this}getDirtyNodes(e){return e?this.nodes.filter(n=>n._dirty&&!$.samePos(n,n._orig)):this.nodes.filter(n=>n._dirty)}_notify(e){if(this.batchMode||!this.onChange)return this;const n=(e||[]).concat(this.getDirtyNodes());return this.onChange(n),this}cleanNodes(){return this.batchMode?this:(this.nodes.forEach(e=>{delete e._dirty,delete e._lastTried}),this)}saveInitial(){return this.nodes.forEach(e=>{e._orig=$.copyPos({},e),delete e._dirty}),this._hasLocked=this.nodes.some(e=>e.locked),this}restoreInitial(){return this.nodes.forEach(e=>{!e._orig||$.samePos(e,e._orig)||($.copyPos(e,e._orig),e._dirty=!0)}),this._notify(),this}findEmptyPosition(e,n=this.nodes,o=this.column,i){const s=i?i.y*o+(i.x+i.w):0;let a=!1;for(let l=s;!a;++l){const d=l%o,c=Math.floor(l/o);if(d+e.w>o)continue;const u={x:d,y:c,w:e.w,h:e.h};n.find(h=>$.isIntercepted(u,h))||((e.x!==d||e.y!==c)&&(e._dirty=!0),e.x=d,e.y=c,delete e.autoPosition,a=!0)}return a}addNode(e,n=!1,o){const i=this.nodes.find(a=>a._id===e._id);if(i)return i;this._inColumnResize?this.nodeBoundFix(e):this.prepareNode(e),delete e._temporaryRemoved,delete e._removeDOM;let s;return e.autoPosition&&this.findEmptyPosition(e,this.nodes,this.column,o)&&(delete e.autoPosition,s=!0),this.nodes.push(e),n&&this.addedNodes.push(e),s||this._fixCollisions(e),this.batchMode||this._packNodes()._notify(),e}removeNode(e,n=!0,o=!1){return this.nodes.find(i=>i._id===e._id)?(o&&this.removedNodes.push(e),n&&(e._removeDOM=!0),this.nodes=this.nodes.filter(i=>i._id!==e._id),e._isAboutToRemove||this._packNodes(),this._notify([e]),this):this}removeAll(e=!0,n=!0){if(delete this._layouts,!this.nodes.length)return this;e&&this.nodes.forEach(i=>i._removeDOM=!0);const o=this.nodes;return this.removedNodes=n?o:[],this.nodes=[],this._notify(o)}moveNodeCheck(e,n){if(!this.changedPosConstrain(e,n))return!1;if(n.pack=!0,!this.maxRow)return this.moveNode(e,n);let o;const i=new vt({column:this.column,float:this.float,nodes:this.nodes.map(a=>a._id===e._id?(o={...a},o):{...a})});if(!o)return!1;const s=i.moveNode(o,n)&&i.getRow()<=Math.max(this.getRow(),this.maxRow);if(!s&&!n.resizing&&n.collide){const a=n.collide.el.gridstackNode;if(this.swap(e,a))return this._notify(),!0}return s?(i.nodes.filter(a=>a._dirty).forEach(a=>{const l=this.nodes.find(d=>d._id===a._id);l&&($.copyPos(l,a),l._dirty=!0)}),this._notify(),!0):!1}willItFit(e){if(delete e._willFitPos,!this.maxRow)return!0;const n=new vt({column:this.column,float:this.float,nodes:this.nodes.map(i=>({...i}))}),o={...e};return this.cleanupNode(o),delete o.el,delete o._id,delete o.content,delete o.grid,n.addNode(o),n.getRow()<=this.maxRow?(e._willFitPos=$.copyPos({},o),!0):!1}changedPosConstrain(e,n){return n.w=n.w||e.w,n.h=n.h||e.h,e.x!==n.x||e.y!==n.y?!0:(e.maxW&&(n.w=Math.min(n.w,e.maxW)),e.maxH&&(n.h=Math.min(n.h,e.maxH)),e.minW&&(n.w=Math.max(n.w,e.minW)),e.minH&&(n.h=Math.max(n.h,e.minH)),e.w!==n.w||e.h!==n.h)}moveNode(e,n){if(!e||!n)return!1;let o;n.pack===void 0&&!this.batchMode&&(o=n.pack=!0),typeof n.x!="number"&&(n.x=e.x),typeof n.y!="number"&&(n.y=e.y),typeof n.w!="number"&&(n.w=e.w),typeof n.h!="number"&&(n.h=e.h);const i=e.w!==n.w||e.h!==n.h,s=$.copyPos({},e,!0);if($.copyPos(s,n),this.nodeBoundFix(s,i),$.copyPos(n,s),!n.forceCollide&&$.samePos(e,n))return!1;const a=$.copyPos({},e),l=this.collideAll(e,s,n.skip);let d=!0;if(l.length){const c=e._moving&&!n.nested;let u=c?this.directionCollideCoverage(e,n,l):l[0];if(c&&u&&e.grid?.opts?.subGridDynamic&&!e.grid._isTemp){const h=$.areaIntercept(n.rect,u._rect),f=$.area(n.rect),g=$.area(u._rect);h/(f<g?f:g)>.8&&(u.grid.makeSubGrid(u.el,void 0,e),u=void 0)}u?d=!this._fixCollisions(e,s,u,n):(d=!1,o&&delete n.pack)}return d&&!$.samePos(e,s)&&(e._dirty=!0,$.copyPos(e,s)),n.pack&&this._packNodes()._notify(),!$.samePos(e,a)}getRow(){return this.nodes.reduce((e,n)=>Math.max(e,n.y+n.h),0)}beginUpdate(e){return e._updating||(e._updating=!0,delete e._skipDown,this.batchMode||this.saveInitial()),this}endUpdate(){const e=this.nodes.find(n=>n._updating);return e&&(delete e._updating,delete e._skipDown),this}save(e=!0,n,o){const i=this._layouts?.length||0;let s;i&&(o?o!==this.column&&(s=this._layouts[o]):this.column!==i-1&&(s=this._layouts[i-1]));const a=[];return this.sortNodes(),this.nodes.forEach(l=>{const d=s?.find(u=>u._id===l._id),c={...l,...d||{}};$.removeInternalForSave(c,!e),n&&n(l,c),a.push(c)}),a}layoutsNodesChange(e){return!this._layouts||this._inColumnResize?this:(this._layouts.forEach((n,o)=>{if(!n||o===this.column)return this;if(o<this.column)this._layouts[o]=void 0;else{const i=o/this.column;e.forEach(s=>{if(!s._orig)return;const a=n.find(l=>l._id===s._id);a&&(a.y>=0&&s.y!==s._orig.y&&(a.y+=s.y-s._orig.y,a.y<0&&(a.y=0)),s.x!==s._orig.x&&(a.x=Math.round(s.x*i),a.x<0&&(a.x=0)),s.w!==s._orig.w&&(a.w=Math.round(s.w*i),a.w<1&&(a.w=1)))})}}),this)}columnChanged(e,n,o="moveScale"){if(!this.nodes.length||!n||e===n)return this;const i=o==="compact"||o==="list";i&&this.sortNodes(1),n<e&&this.cacheLayout(this.nodes,e),this.batchUpdate();let s=[],a=i?this.nodes:$.sort(this.nodes,-1);if(n>e&&this._layouts){const l=this._layouts[n]||[],d=this._layouts.length-1;!l.length&&e!==d&&this._layouts[d]?.length&&(e=d,this._layouts[d].forEach(c=>{const u=a.find(h=>h._id===c._id);u&&(!i&&!c.autoPosition&&(u.x=c.x??u.x,u.y=c.y??u.y),u.w=c.w??u.w,(c.x==null||c.y===void 0)&&(u.autoPosition=!0))})),l.forEach(c=>{const u=a.findIndex(h=>h._id===c._id);if(u!==-1){const h=a[u];if(i){h.w=c.w;return}(c.autoPosition||isNaN(c.x)||isNaN(c.y))&&this.findEmptyPosition(c,s),c.autoPosition||(h.x=c.x??h.x,h.y=c.y??h.y,h.w=c.w??h.w,s.push(h)),a.splice(u,1)}})}if(i)this.compact(o,!1);else{if(a.length)if(typeof o=="function")o(n,e,s,a);else{const l=i||o==="none"?1:n/e,d=o==="move"||o==="moveScale",c=o==="scale"||o==="moveScale";a.forEach(u=>{u.x=n===1?0:d?Math.round(u.x*l):Math.min(u.x,n-1),u.w=n===1||e===1?1:c?Math.round(u.w*l)||1:Math.min(u.w,n),s.push(u)}),a=[]}s=$.sort(s,-1),this._inColumnResize=!0,this.nodes=[],s.forEach(l=>{this.addNode(l,!1),delete l._orig})}return this.nodes.forEach(l=>delete l._orig),this.batchUpdate(!1,!i),delete this._inColumnResize,this}cacheLayout(e,n,o=!1){const i=[];return e.forEach((s,a)=>{s._id===void 0&&(s._id=(s.id?this.nodes.find(l=>l.id===s.id):void 0)?._id??vt._idSeq++),i[a]={x:s.x,y:s.y,w:s.w,_id:s._id}}),this._layouts=o?[]:this._layouts||[],this._layouts[n]=i,this}cacheOneLayout(e,n){e._id=e._id??vt._idSeq++;const o={x:e.x,y:e.y,w:e.w,_id:e._id};(e.autoPosition||e.x===void 0)&&(delete o.x,delete o.y,e.autoPosition&&(o.autoPosition=!0)),this._layouts=this._layouts||[],this._layouts[n]=this._layouts[n]||[];const i=this.findCacheLayout(e,n);return i===-1?this._layouts[n].push(o):this._layouts[n][i]=o,this}findCacheLayout(e,n){return this._layouts?.[n]?.findIndex(o=>o._id===e._id)??-1}removeNodeFromLayoutCache(e){if(this._layouts)for(let n=0;n<this._layouts.length;n++){const o=this.findCacheLayout(e,n);o!==-1&&this._layouts[n].splice(o,1)}}cleanupNode(e){for(const n in e)n[0]==="_"&&n!=="_id"&&delete e[n];return this}};_o._idSeq=0;var ke={alwaysShowResizeHandle:"mobile",animate:!0,auto:!0,cellHeight:"auto",cellHeightThrottle:100,cellHeightUnit:"px",column:12,draggable:{handle:".grid-stack-item-content",appendTo:"body",scroll:!0},handle:".grid-stack-item-content",itemClass:"grid-stack-item",margin:10,marginUnit:"px",maxRow:0,minRow:0,placeholderClass:"grid-stack-placeholder",placeholderText:"",removableOptions:{accept:"grid-stack-item",decline:"grid-stack-non-removable"},resizable:{handles:"se"},rtl:"auto"},de=class{},Be=typeof window<"u"&&typeof document<"u"&&("ontouchstart"in document||"ontouchstart"in window||window.DocumentTouch&&document instanceof window.DocumentTouch||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0),Se=class{};function Cn(t,e){t.touches.length>1||(t.cancelable&&t.preventDefault(),$.simulateMouseEvent(t.changedTouches[0],e))}function xr(t,e){t.cancelable&&t.preventDefault(),$.simulateMouseEvent(t,e)}function En(t){Se.touchHandled||(Se.touchHandled=!0,Cn(t,"mousedown"))}function xn(t){Se.touchHandled&&Cn(t,"mousemove")}function Nn(t){if(!Se.touchHandled)return;Se.pointerLeaveTimeout&&(window.clearTimeout(Se.pointerLeaveTimeout),delete Se.pointerLeaveTimeout);const e=!!de.dragElement;Cn(t,"mouseup"),e||Cn(t,"click"),Se.touchHandled=!1}function kn(t){t.pointerType!=="mouse"&&t.target.releasePointerCapture(t.pointerId)}function Nr(t){de.dragElement&&t.pointerType!=="mouse"&&xr(t,"mouseenter")}function kr(t){de.dragElement&&t.pointerType!=="mouse"&&(Se.pointerLeaveTimeout=window.setTimeout(()=>{delete Se.pointerLeaveTimeout,xr(t,"mouseleave")},10))}var Sr=class Fr{constructor(e,n,o){this.host=e,this.dir=n,this.option=o,this.moving=!1,this._mouseDown=this._mouseDown.bind(this),this._mouseMove=this._mouseMove.bind(this),this._mouseUp=this._mouseUp.bind(this),this._keyEvent=this._keyEvent.bind(this),this._init()}_init(){if(this.option.element)try{this.el=this.option.element instanceof HTMLElement?this.option.element:this.host.querySelector(this.option.element)}catch(e){this.option.element=void 0,console.error("Query for resizeable handle failed, falling back",e)}return this.el||(this.el=document.createElement("div"),this.host.appendChild(this.el)),this.el.classList.add("ui-resizable-handle"),this.el.classList.add(`${Fr.prefix}${this.dir}`),this.el.style.zIndex="100",this.el.style.userSelect="none",this.el.addEventListener("mousedown",this._mouseDown),Be&&(this.el.addEventListener("touchstart",En),this.el.addEventListener("pointerdown",kn)),this}destroy(){return this.moving&&this._mouseUp(this.mouseDownEvent),this.el.removeEventListener("mousedown",this._mouseDown),Be&&(this.el.removeEventListener("touchstart",En),this.el.removeEventListener("pointerdown",kn)),this.option.element||this.host.removeChild(this.el),delete this.el,delete this.host,this}_mouseDown(e){this.mouseDownEvent=e,document.addEventListener("mousemove",this._mouseMove,{capture:!0,passive:!0}),document.addEventListener("mouseup",this._mouseUp,!0),Be&&(this.el.addEventListener("touchmove",xn),this.el.addEventListener("touchend",Nn)),e.stopPropagation(),e.preventDefault()}_mouseMove(e){const n=this.mouseDownEvent;this.moving?this._triggerEvent("move",e):Math.abs(e.x-n.x)+Math.abs(e.y-n.y)>2&&(this.moving=!0,this._triggerEvent("start",this.mouseDownEvent),this._triggerEvent("move",e),document.addEventListener("keydown",this._keyEvent)),e.stopPropagation()}_mouseUp(e){this.moving&&(this._triggerEvent("stop",e),document.removeEventListener("keydown",this._keyEvent)),document.removeEventListener("mousemove",this._mouseMove,!0),document.removeEventListener("mouseup",this._mouseUp,!0),Be&&(this.el.removeEventListener("touchmove",xn),this.el.removeEventListener("touchend",Nn)),delete this.moving,delete this.mouseDownEvent,e.stopPropagation(),e.preventDefault()}_keyEvent(e){e.key==="Escape"&&(this.host.gridstackNode?.grid?.engine.restoreInitial(),this._mouseUp(this.mouseDownEvent))}_triggerEvent(e,n){return this.option[e]&&this.option[e](n),this}};Sr.prefix="ui-resizable-";var wo=class{constructor(){this._eventRegister={}}get disabled(){return this._disabled}on(t,e){this._eventRegister[t]=e}off(t){delete this._eventRegister[t]}enable(){this._disabled=!1}disable(){this._disabled=!0}destroy(){delete this._eventRegister}triggerEvent(t,e){if(!this.disabled&&this._eventRegister&&this._eventRegister[t])return this._eventRegister[t](e)}},Dr=class Co extends wo{constructor(e,n={}){super(),this.el=e,this.option=n,this.rectScale={x:1,y:1},this._ui=()=>{const o=this.el.parentElement.getBoundingClientRect(),i={width:this.originalRect.width,height:this.originalRect.height+this.scrolled,left:this.originalRect.left,top:this.originalRect.top-this.scrolled},s=this.temporalRect||i;return{position:{left:(s.left-o.left)*this.rectScale.x,top:(s.top-o.top)*this.rectScale.y},size:{width:s.width*this.rectScale.x,height:s.height*this.rectScale.y}}},this._mouseOver=this._mouseOver.bind(this),this._mouseOut=this._mouseOut.bind(this),this.enable(),this._setupAutoHide(this.option.autoHide),this._setupHandlers()}on(e,n){super.on(e,n)}off(e){super.off(e)}enable(){super.enable(),this.el.classList.remove("ui-resizable-disabled"),this._setupAutoHide(this.option.autoHide)}disable(){super.disable(),this.el.classList.add("ui-resizable-disabled"),this._setupAutoHide(!1)}destroy(){this._removeHandlers(),this._setupAutoHide(!1),delete this.el,super.destroy()}updateOption(e){const n=e.handles&&e.handles!==this.option.handles,o=e.autoHide&&e.autoHide!==this.option.autoHide;return Object.keys(e).forEach(i=>this.option[i]=e[i]),n&&(this._removeHandlers(),this._setupHandlers()),o&&this._setupAutoHide(this.option.autoHide),this}_setupAutoHide(e){return e?(this.el.classList.add("ui-resizable-autohide"),this.el.addEventListener("mouseover",this._mouseOver),this.el.addEventListener("mouseout",this._mouseOut)):(this.el.classList.remove("ui-resizable-autohide"),this.el.removeEventListener("mouseover",this._mouseOver),this.el.removeEventListener("mouseout",this._mouseOut),de.overResizeElement===this&&delete de.overResizeElement),this}_mouseOver(e){de.overResizeElement||de.dragElement||(de.overResizeElement=this,this.el.classList.remove("ui-resizable-autohide"))}_mouseOut(e){de.overResizeElement===this&&(delete de.overResizeElement,this.el.classList.add("ui-resizable-autohide"))}_setupHandlers(){return this.handlers=this.option.handles.split(",").map(e=>e.trim()).map(e=>new Sr(this.el,e,{element:this.option.element,start:n=>this._resizeStart(n),stop:n=>this._resizeStop(n),move:n=>this._resizing(n,e)})),this}_resizeStart(e){this.sizeToContent=$.shouldSizeToContent(this.el.gridstackNode,!0),this.originalRect=this.el.getBoundingClientRect(),this.scrollEl=$.getScrollElement(this.el),this.scrollY=this.scrollEl.scrollTop,this.scrolled=0,this.startEvent=e,this._setupHelper(),this._applyChange();const n=$.initEvent(e,{type:"resizestart",target:this.el});return this.option.start&&this.option.start(n,this._ui()),this.el.classList.add("ui-resizable-resizing"),this.triggerEvent("resizestart",n),this}_resizing(e,n){this.scrolled=this.scrollEl.scrollTop-this.scrollY,this.temporalRect=this._getChange(e,n),this._applyChange();const o=$.initEvent(e,{type:"resize",target:this.el});return this.option.resize&&this.option.resize(o,this._ui()),this.triggerEvent("resize",o),this}_resizeStop(e){const n=$.initEvent(e,{type:"resizestop",target:this.el});return this._cleanHelper(),this.option.stop&&this.option.stop(n),this.el.classList.remove("ui-resizable-resizing"),this.triggerEvent("resizestop",n),delete this.startEvent,delete this.originalRect,delete this.temporalRect,delete this.scrollY,delete this.scrolled,this}_setupHelper(){this.elOriginStyleVal=Co._originStyleProp.map(o=>this.el.style[o]),this.parentOriginStylePosition=this.el.parentElement.style.position;const e=this.el.parentElement,n=$.getValuesFromTransformedElement(e);return this.rectScale={x:n.xScale,y:n.yScale},getComputedStyle(this.el.parentElement).position.match(/static/)&&(this.el.parentElement.style.position="relative"),this.el.style.position="absolute",this.el.style.opacity="0.8",this}_cleanHelper(){return Co._originStyleProp.forEach((e,n)=>{this.el.style[e]=this.elOriginStyleVal[n]||null}),this.el.parentElement.style.position=this.parentOriginStylePosition||null,this}_getChange(e,n){const o=this.startEvent,i={width:this.originalRect.width,height:this.originalRect.height+this.scrolled,left:this.originalRect.left,top:this.originalRect.top-this.scrolled},s=e.clientX-o.clientX,a=this.sizeToContent?0:e.clientY-o.clientY;let l,d;n.indexOf("e")>-1?i.width+=s:n.indexOf("w")>-1&&(i.width-=s,i.left+=s,l=!0),n.indexOf("s")>-1?i.height+=a:n.indexOf("n")>-1&&(i.height-=a,i.top+=a,d=!0);const c=this._constrainSize(i.width,i.height,l,d);return Math.round(i.width)!==Math.round(c.width)&&(n.indexOf("w")>-1&&(i.left+=i.width-c.width),i.width=c.width),Math.round(i.height)!==Math.round(c.height)&&(n.indexOf("n")>-1&&(i.top+=i.height-c.height),i.height=c.height),i}_constrainSize(e,n,o,i){const s=this.option,a=(o?s.maxWidthMoveLeft:s.maxWidth)||Number.MAX_SAFE_INTEGER,l=s.minWidth/this.rectScale.x||e,d=(i?s.maxHeightMoveUp:s.maxHeight)||Number.MAX_SAFE_INTEGER,c=s.minHeight/this.rectScale.y||n;return{width:Math.min(a,Math.max(l,e)),height:Math.min(d,Math.max(c,n))}}_applyChange(){let e={left:0,top:0,width:0,height:0};if(this.el.style.position==="absolute"){const{left:n,top:o}=this.el.parentElement.getBoundingClientRect();e={left:n,top:o,width:0,height:0}}return this.temporalRect?(Object.keys(this.temporalRect).forEach(n=>{const o=this.temporalRect[n],i=n==="width"||n==="left"?this.rectScale.x:n==="height"||n==="top"?this.rectScale.y:1;this.el.style[n]=(o-e[n])*i+"px"}),this):this}_removeHandlers(){return this.handlers.forEach(e=>e.destroy()),delete this.handlers,this}};Dr._originStyleProp=["width","height","position","left","top","opacity","zIndex"];var Kf='input,textarea,button,select,option,[contenteditable="true"],.ui-resizable-handle',Tr=class Eo extends wo{constructor(e,n={}){super(),this.el=e,this.option=n,this.dragTransform={xScale:1,yScale:1,xOffset:0,yOffset:0};const o=n?.handle?.substring(1),i=e.gridstackNode;this.dragEls=!o||e.classList.contains(o)?[e]:i?.subGrid?[e.querySelector(n.handle)||e]:Array.from(e.querySelectorAll(n.handle)),this.dragEls.length===0&&(this.dragEls=[e]),this._mouseDown=this._mouseDown.bind(this),this._mouseMove=this._mouseMove.bind(this),this._mouseUp=this._mouseUp.bind(this),this._keyEvent=this._keyEvent.bind(this),this.enable()}on(e,n){super.on(e,n)}off(e){super.off(e)}enable(){this.disabled!==!1&&(super.enable(),this.dragEls.forEach(e=>{e.addEventListener("mousedown",this._mouseDown),Be&&(e.addEventListener("touchstart",En),e.addEventListener("pointerdown",kn))}),this.el.classList.remove("ui-draggable-disabled"))}disable(e=!1){this.disabled!==!0&&(super.disable(),this.dragEls.forEach(n=>{n.removeEventListener("mousedown",this._mouseDown),Be&&(n.removeEventListener("touchstart",En),n.removeEventListener("pointerdown",kn))}),e||this.el.classList.add("ui-draggable-disabled"))}destroy(){this.dragTimeout&&window.clearTimeout(this.dragTimeout),delete this.dragTimeout,this.mouseDownEvent&&this._mouseUp(this.mouseDownEvent),this.disable(!0),delete this.el,delete this.helper,delete this.option,super.destroy()}updateOption(e){return Object.keys(e).forEach(n=>this.option[n]=e[n]),this}_mouseDown(e){if(Se.touchHandled&&e.isTrusted&&(Se.touchHandled=!1),!de.mouseHandled)return e.button!==0||!this.dragEls.find(n=>n===e.target)&&e.target.closest(Kf)||this.option.cancel&&e.target.closest(this.option.cancel)||(this.mouseDownEvent=e,delete this.dragging,delete de.dragElement,delete de.dropElement,document.addEventListener("mousemove",this._mouseMove,{capture:!0,passive:!0}),document.addEventListener("mouseup",this._mouseUp,!0),Be&&(e.currentTarget.addEventListener("touchmove",xn),e.currentTarget.addEventListener("touchend",Nn)),e.preventDefault(),document.activeElement&&document.activeElement.blur(),de.mouseHandled=!0),!0}_callDrag(e){if(!this.dragging)return;const n=$.initEvent(e,{target:this.el,type:"drag"});this.option.drag&&this.option.drag(n,this.ui()),this.triggerEvent("drag",n)}_mouseMove(e){const n=this.mouseDownEvent;if(this.lastDrag=e,this.dragging)if(this._dragFollow(e),de.pauseDrag){const o=Number.isInteger(de.pauseDrag)?de.pauseDrag:100;this.dragTimeout&&window.clearTimeout(this.dragTimeout),this.dragTimeout=window.setTimeout(()=>this._callDrag(e),o)}else this._callDrag(e);else if(Math.abs(e.x-n.x)+Math.abs(e.y-n.y)>3){this.dragging=!0,de.dragElement=this;const o=this.el.gridstackNode?.grid;o?de.dropElement=o.el.ddElement.ddDroppable:delete de.dropElement,this.helper=this._createHelper(),this._setupHelperContainmentStyle(),this.dragTransform=$.getValuesFromTransformedElement(this.helperContainment),this.dragOffset=this._getDragOffset(e,this.el,this.helperContainment),this._setupHelperStyle(e);const i=$.initEvent(e,{target:this.el,type:"dragstart"});this.option.start&&this.option.start(i,this.ui()),this.triggerEvent("dragstart",i),document.addEventListener("keydown",this._keyEvent)}return!0}_mouseUp(e){if(document.removeEventListener("mousemove",this._mouseMove,!0),document.removeEventListener("mouseup",this._mouseUp,!0),Be&&e.currentTarget&&(e.currentTarget.removeEventListener("touchmove",xn,!0),e.currentTarget.removeEventListener("touchend",Nn,!0)),this.dragging){delete this.dragging,delete this.el.gridstackNode?._origRotate,document.removeEventListener("keydown",this._keyEvent),de.dropElement?.el===this.el.parentElement&&delete de.dropElement,this.helperContainment.style.position=this.parentOriginStylePosition||null,this.helper!==this.el&&this.helper.remove(),this._removeHelperStyle();const n=$.initEvent(e,{target:this.el,type:"dragstop"});this.option.stop&&this.option.stop(n),this.triggerEvent("dragstop",n),de.dropElement&&de.dropElement.drop(e)}delete this.helper,delete this.mouseDownEvent,delete de.dragElement,delete de.dropElement,delete de.mouseHandled,e.preventDefault()}_keyEvent(e){const n=this.el.gridstackNode,o=n?.grid||de.dropElement?.el?.gridstack;if(e.key==="Escape")n&&n._origRotate&&(n._orig=n._origRotate,delete n._origRotate),o?.cancelDrag(),this._mouseUp(this.mouseDownEvent);else if(n&&o&&(e.key==="r"||e.key==="R")){if(!$.canBeRotated(n))return;n._origRotate=n._origRotate||{...n._orig},delete n._moving,o.setAnimation(!1).rotate(n.el,{top:-this.dragOffset.offsetTop,left:-this.dragOffset.offsetLeft}).setAnimation(),n._moving=!0,this.dragOffset=this._getDragOffset(this.lastDrag,n.el,this.helperContainment),this.helper.style.width=this.dragOffset.width+"px",this.helper.style.height=this.dragOffset.height+"px",$.swap(n._orig,"w","h"),delete n._rect,this._mouseMove(this.lastDrag)}}_createHelper(){let e=this.el;return typeof this.option.helper=="function"?e=this.option.helper(this.el):this.option.helper==="clone"&&(e=$.cloneNode(this.el)),e.parentElement||$.appendTo(e,this.option.appendTo==="parent"?this.el.parentElement:this.option.appendTo),this.dragElementOriginStyle=Eo.originStyleProp.map(n=>this.el.style[n]),e}_setupHelperStyle(e){this.helper.classList.add("ui-draggable-dragging"),this.el.gridstackNode?.grid?.el.classList.add("grid-stack-dragging");const n=this.helper.style;return n.pointerEvents="none",n.width=this.dragOffset.width+"px",n.height=this.dragOffset.height+"px",n.willChange="left, top",n.position="fixed",this._dragFollow(e),n.transition="none",setTimeout(()=>{this.helper&&(n.transition=null)},0),this}_removeHelperStyle(){if(this.helper.classList.remove("ui-draggable-dragging"),this.el.gridstackNode?.grid?.el.classList.remove("grid-stack-dragging"),!this.helper?.gridstackNode?._isAboutToRemove&&this.dragElementOriginStyle){const e=this.helper,n=this.dragElementOriginStyle.transition||null;e.style.transition=this.dragElementOriginStyle.transition="none",Eo.originStyleProp.forEach(o=>e.style[o]=this.dragElementOriginStyle[o]||null),setTimeout(()=>e.style.transition=n,50)}return delete this.dragElementOriginStyle,this}_dragFollow(e){const n={left:0,top:0},o=this.helper.style,i=this.dragOffset;o.left=(e.clientX+i.offsetLeft-n.left)*this.dragTransform.xScale+"px",o.top=(e.clientY+i.offsetTop-n.top)*this.dragTransform.yScale+"px"}_setupHelperContainmentStyle(){return this.helperContainment=this.helper.parentElement,this.helper.style.position!=="fixed"&&(this.parentOriginStylePosition=this.helperContainment.style.position,getComputedStyle(this.helperContainment).position.match(/static/)&&(this.helperContainment.style.position="relative")),this}_getDragOffset(e,n,o){let i=0,s=0;o&&(i=this.dragTransform.xOffset,s=this.dragTransform.yOffset);const a=n.getBoundingClientRect();return{left:a.left,top:a.top,offsetLeft:-e.clientX+a.left-i,offsetTop:-e.clientY+a.top-s,width:a.width*this.dragTransform.xScale,height:a.height*this.dragTransform.yScale}}ui(){const e=this.el.parentElement.getBoundingClientRect(),n=this.helper.getBoundingClientRect();return{position:{top:(n.top-e.top)*this.dragTransform.yScale,left:(n.left-e.left)*this.dragTransform.xScale}}}};Tr.originStyleProp=["width","height","transform","transform-origin","transition","pointerEvents","position","left","top","minWidth","willChange"];var qf=class extends wo{constructor(t,e={}){super(),this.el=t,this.option=e,this._mouseEnter=this._mouseEnter.bind(this),this._mouseLeave=this._mouseLeave.bind(this),this.enable(),this._setupAccept()}on(t,e){super.on(t,e)}off(t){super.off(t)}enable(){this.disabled!==!1&&(super.enable(),this.el.classList.add("ui-droppable"),this.el.classList.remove("ui-droppable-disabled"),this.el.addEventListener("mouseenter",this._mouseEnter),this.el.addEventListener("mouseleave",this._mouseLeave),Be&&(this.el.addEventListener("pointerenter",Nr),this.el.addEventListener("pointerleave",kr)))}disable(t=!1){this.disabled!==!0&&(super.disable(),this.el.classList.remove("ui-droppable"),t||this.el.classList.add("ui-droppable-disabled"),this.el.removeEventListener("mouseenter",this._mouseEnter),this.el.removeEventListener("mouseleave",this._mouseLeave),Be&&(this.el.removeEventListener("pointerenter",Nr),this.el.removeEventListener("pointerleave",kr)))}destroy(){this.disable(!0),this.el.classList.remove("ui-droppable"),this.el.classList.remove("ui-droppable-disabled"),super.destroy()}updateOption(t){return Object.keys(t).forEach(e=>this.option[e]=t[e]),this._setupAccept(),this}_mouseEnter(t){if(!de.dragElement||Se.touchHandled&&t.isTrusted||!this._canDrop(de.dragElement.el))return;t.preventDefault(),t.stopPropagation(),de.dropElement&&de.dropElement!==this&&de.dropElement._mouseLeave(t,!0),de.dropElement=this;const e=$.initEvent(t,{target:this.el,type:"dropover"});this.option.over&&this.option.over(e,this._ui(de.dragElement)),this.triggerEvent("dropover",e),this.el.classList.add("ui-droppable-over")}_mouseLeave(t,e=!1){if(!de.dragElement||de.dropElement!==this)return;t.preventDefault(),t.stopPropagation();const n=$.initEvent(t,{target:this.el,type:"dropout"});if(this.option.out&&this.option.out(n,this._ui(de.dragElement)),this.triggerEvent("dropout",n),de.dropElement===this&&(delete de.dropElement,!e)){let o,i=this.el.parentElement;for(;!o&&i;)o=i.ddElement?.ddDroppable,i=i.parentElement;o&&o._mouseEnter(t)}}drop(t){t.preventDefault();const e=$.initEvent(t,{target:this.el,type:"drop"});this.option.drop&&this.option.drop(e,this._ui(de.dragElement)),this.triggerEvent("drop",e)}_canDrop(t){return t&&(!this.accept||this.accept(t))}_setupAccept(){return this.option.accept?(typeof this.option.accept=="string"?this.accept=t=>t.classList.contains(this.option.accept)||t.matches(this.option.accept):this.accept=this.option.accept,this):this}_ui(t){return{draggable:t.el,...t.ui()}}},Jf=class Gr{static init(e){return e.ddElement||(e.ddElement=new Gr(e)),e.ddElement}constructor(e){this.el=e}on(e,n){return this.ddDraggable&&["drag","dragstart","dragstop"].indexOf(e)>-1?this.ddDraggable.on(e,n):this.ddDroppable&&["drop","dropover","dropout"].indexOf(e)>-1?this.ddDroppable.on(e,n):this.ddResizable&&["resizestart","resize","resizestop"].indexOf(e)>-1&&this.ddResizable.on(e,n),this}off(e){return this.ddDraggable&&["drag","dragstart","dragstop"].indexOf(e)>-1?this.ddDraggable.off(e):this.ddDroppable&&["drop","dropover","dropout"].indexOf(e)>-1?this.ddDroppable.off(e):this.ddResizable&&["resizestart","resize","resizestop"].indexOf(e)>-1&&this.ddResizable.off(e),this}setupDraggable(e){return this.ddDraggable?this.ddDraggable.updateOption(e):this.ddDraggable=new Tr(this.el,e),this}cleanDraggable(){return this.ddDraggable&&(this.ddDraggable.destroy(),delete this.ddDraggable),this}setupResizable(e){return this.ddResizable?this.ddResizable.updateOption(e):this.ddResizable=new Dr(this.el,e),this}cleanResizable(){return this.ddResizable&&(this.ddResizable.destroy(),delete this.ddResizable),this}setupDroppable(e){return this.ddDroppable?this.ddDroppable.updateOption(e):this.ddDroppable=new qf(this.el,e),this}cleanDroppable(){return this.ddDroppable&&(this.ddDroppable.destroy(),delete this.ddDroppable),this}},Qf=class{resizable(t,e,n,o){return this._getDDElements(t,e).forEach(i=>{if(e==="disable"||e==="enable")i.ddResizable&&i.ddResizable[e]();else if(e==="destroy")i.ddResizable&&i.cleanResizable();else if(e==="option")i.setupResizable({[n]:o});else{const s=i.el.gridstackNode.grid;let a=i.el.getAttribute("gs-resize-handles")||s.opts.resizable.handles||"e,s,se";a==="all"&&(a="n,e,s,w,se,sw,ne,nw");const l=!s.opts.alwaysShowResizeHandle;i.setupResizable({...s.opts.resizable,handles:a,autoHide:l,start:e.start,stop:e.stop,resize:e.resize})}}),this}draggable(t,e,n,o){return this._getDDElements(t,e).forEach(i=>{if(e==="disable"||e==="enable")i.ddDraggable&&i.ddDraggable[e]();else if(e==="destroy")i.ddDraggable&&i.cleanDraggable();else if(e==="option")i.setupDraggable({[n]:o});else{const s=i.el.gridstackNode.grid;i.setupDraggable({...s.opts.draggable,start:e.start,stop:e.stop,drag:e.drag})}}),this}dragIn(t,e){return this._getDDElements(t).forEach(n=>n.setupDraggable(e)),this}droppable(t,e,n,o){return typeof e.accept=="function"&&!e._accept&&(e._accept=e.accept,e.accept=i=>e._accept(i)),this._getDDElements(t,e).forEach(i=>{e==="disable"||e==="enable"?i.ddDroppable&&i.ddDroppable[e]():e==="destroy"?i.ddDroppable&&i.cleanDroppable():e==="option"?i.setupDroppable({[n]:o}):i.setupDroppable(e)}),this}isDroppable(t){return!!(t?.ddElement?.ddDroppable&&!t.ddElement.ddDroppable.disabled)}isDraggable(t){return!!(t?.ddElement?.ddDraggable&&!t.ddElement.ddDraggable.disabled)}isResizable(t){return!!(t?.ddElement?.ddResizable&&!t.ddElement.ddResizable.disabled)}on(t,e,n){return this._getDDElements(t).forEach(o=>o.on(e,i=>{n(i,de.dragElement?de.dragElement.el:i.target,de.dragElement?de.dragElement.helper:null)})),this}off(t,e){return this._getDDElements(t).forEach(n=>n.off(e)),this}_getDDElements(t,e){const n=t.gridstack||e!=="destroy"&&e!=="disable",o=$.getElements(t);return o.length?o.map(i=>i.ddElement||(n?Jf.init(i):null)).filter(i=>i):[]}},Ce=new Qf,mt=class ce{static init(e={},n=".grid-stack"){if(typeof document>"u")return null;const o=ce.getGridElement(n);return o?(o.gridstack||(o.gridstack=new ce(o,$.cloneDeep(e))),o.gridstack):(console.error(typeof n=="string"?'GridStack.initAll() no grid was found with selector "'+n+`" - element missing or wrong selector ?
|
|
27
27
|
Note: ".grid-stack" is required for proper CSS styling and drag/drop, and is the default selector.`:"GridStack.init() no grid element was passed."),null)}static initAll(e={},n=".grid-stack"){const o=[];return typeof document>"u"||(ce.getGridElements(n).forEach(i=>{i.gridstack||(i.gridstack=new ce(i,$.cloneDeep(e))),o.push(i.gridstack)}),o.length===0&&console.error('GridStack.initAll() no grid was found with selector "'+n+`" - element missing or wrong selector ?
|
|
28
|
-
Note: ".grid-stack" is required for proper CSS styling and drag/drop, and is the default selector.`)),o}static addGrid(e,n={}){if(!e)return null;let o=e;if(o.gridstack){const i=o.gridstack;return n&&(i.opts={...i.opts,...n}),n.children!==void 0&&i.load(n.children),i}return(!e.classList.contains("grid-stack")||ce.addRemoveCB)&&(ce.addRemoveCB?o=ce.addRemoveCB(e,n,!0,!0):o=$.createDiv(["grid-stack",n.class],e)),ce.init(n,o)}static registerEngine(e){ce.engineClass=e}get placeholder(){if(!this._placeholder){this._placeholder=$.createDiv([this.opts.placeholderClass,ke.itemClass,this.opts.itemClass]);const e=$.createDiv(["placeholder-content"],this._placeholder);this.opts.placeholderText&&(e.textContent=this.opts.placeholderText)}return this._placeholder}constructor(e,n={}){this.el=e,this.opts=n,this.animationDelay=310,this._gsEventHandler={},this._extraDragRow=0,this.dragTransform={xScale:1,yScale:1,xOffset:0,yOffset:0},e.gridstack=this,this.opts=n=n||{},e.classList.contains("grid-stack")||this.el.classList.add("grid-stack"),n.row&&(n.minRow=n.maxRow=n.row,delete n.row);const o=$.toNumber(e.getAttribute("gs-row"));n.column==="auto"&&delete n.column,n.alwaysShowResizeHandle!==void 0&&(n._alwaysShowResizeHandle=n.alwaysShowResizeHandle);const i=n.columnOpts;if(i){const d=i.breakpoints;!i.columnWidth&&!d?.length?delete n.columnOpts:(i.columnMax=i.columnMax||12,d?.length>1&&d.sort((c,u)=>(u.w||0)-(c.w||0)))}const s={...$.cloneDeep(ke),column:$.toNumber(e.getAttribute("gs-column"))||ke.column,minRow:o||$.toNumber(e.getAttribute("gs-min-row"))||ke.minRow,maxRow:o||$.toNumber(e.getAttribute("gs-max-row"))||ke.maxRow,staticGrid:$.toBool(e.getAttribute("gs-static"))||ke.staticGrid,sizeToContent:$.toBool(e.getAttribute("gs-size-to-content"))||void 0,draggable:{handle:(n.handleClass?"."+n.handleClass:n.handle?n.handle:"")||ke.draggable.handle},removableOptions:{accept:n.itemClass||ke.removableOptions.accept,decline:ke.removableOptions.decline}};e.getAttribute("gs-animate")&&(s.animate=$.toBool(e.getAttribute("gs-animate"))),n=$.defaults(n,s),this._initMargin(),this.checkDynamicColumn(),this._updateColumnVar(n),n.rtl==="auto"&&(n.rtl=e.style.direction==="rtl"),n.rtl&&this.el.classList.add("grid-stack-rtl");const a=this.el.closest("."+ke.itemClass)?.gridstackNode;if(a&&(a.subGrid=this,this.parentGridNode=a,this.el.classList.add("grid-stack-nested"),a.el.classList.add("grid-stack-sub-grid")),this._isAutoCellHeight=n.cellHeight==="auto",this._isAutoCellHeight||n.cellHeight==="initial")this.cellHeight(void 0);else{typeof n.cellHeight=="number"&&n.cellHeightUnit&&n.cellHeightUnit!==ke.cellHeightUnit&&(n.cellHeight=n.cellHeight+n.cellHeightUnit,delete n.cellHeightUnit);const d=n.cellHeight;delete n.cellHeight,this.cellHeight(d)}n.alwaysShowResizeHandle==="mobile"&&(n.alwaysShowResizeHandle=Be),this._setStaticClass();const l=n.engineClass||ce.engineClass||_o;if(this.engine=new l({column:this.getColumn(),float:n.float,maxRow:n.maxRow,onChange:d=>{d.forEach(c=>{const u=c.el;u&&(c._removeDOM?(u&&u.remove(),delete c._removeDOM):this._writePosAttr(u,c))}),this._updateContainerHeight()}}),n.auto&&(this.batchUpdate(),this.engine._loading=!0,this.getGridItems().forEach(d=>this._prepareElement(d)),delete this.engine._loading,this.batchUpdate(!1)),n.children){const d=n.children;delete n.children,d.length&&this.load(d)}this.setAnimation(),n.subGridDynamic&&!de.pauseDrag&&(de.pauseDrag=!0),n.draggable?.pause!==void 0&&(de.pauseDrag=n.draggable.pause),this._setupRemoveDrop(),this._setupAcceptWidget(),this._updateResizeEvent()}_updateColumnVar(e=this.opts){this.el.classList.add("gs-"+e.column),typeof e.column=="number"&&this.el.style.setProperty("--gs-column-width",`${100/e.column}%`)}addWidget(e){if(!e)return;if(typeof e=="string"){console.error("V11: GridStack.addWidget() does not support string anymore. see #2736");return}if(e.ELEMENT_NODE)return console.error("V11: GridStack.addWidget() does not support HTMLElement anymore. use makeWidget()"),this.makeWidget(e);let n,o=e;if(o.grid=this,o.el?n=o.el:ce.addRemoveCB?n=ce.addRemoveCB(this.el,e,!0,!1):n=this.createWidgetDivs(o),!n)return;if(o=n.gridstackNode,o&&n.parentElement===this.el&&this.engine.nodes.find(s=>s._id===o._id))return n;const i=this._readAttr(n);return $.defaults(e,i),this.engine.prepareNode(e),this.el.appendChild(n),this.makeWidget(n,e),n}createWidgetDivs(e){const n=$.createDiv(["grid-stack-item",this.opts.itemClass]),o=$.createDiv(["grid-stack-item-content"],n);return $.lazyLoad(e)?e.visibleObservable||(e.visibleObservable=new IntersectionObserver(([i])=>{i.isIntersecting&&(e.visibleObservable?.disconnect(),delete e.visibleObservable,ce.renderCB(o,e),e.grid?.prepareDragDrop(e.el))}),window.setTimeout(()=>e.visibleObservable?.observe(n))):ce.renderCB(o,e),n}makeSubGrid(e,n,o,i=!0){let s=e.gridstackNode;if(s||(s=this.makeWidget(e).gridstackNode),s.subGrid?.el)return s.subGrid;let a,l=this;for(;l&&!a;)a=l.opts?.subGridOpts,l=l.parentGridNode?.grid;n=$.cloneDeep({...this.opts,id:void 0,children:void 0,column:"auto",columnOpts:void 0,layout:"list",subGridOpts:void 0,...a||{},...n||s.subGridOpts||{}}),s.subGridOpts=n;let d;n.column==="auto"&&(d=!0,n.column=Math.max(s.w||1,o?.w||1),delete n.columnOpts);let c=s.el.querySelector(".grid-stack-item-content"),u,h;if(i&&(this._removeDD(s.el),h={...s,x:0,y:0},$.removeInternalForSave(h),delete h.subGridOpts,s.content&&(h.content=s.content,delete s.content),ce.addRemoveCB?u=ce.addRemoveCB(this.el,h,!0,!1):(u=$.createDiv(["grid-stack-item"]),u.appendChild(c),c=$.createDiv(["grid-stack-item-content"],s.el)),this.prepareDragDrop(s.el)),o){const g=d?n.column:s.w,m=s.h+o.h,E=s.el.style;E.transition="none",this.update(s.el,{w:g,h:m}),setTimeout(()=>E.transition=null)}const f=s.subGrid=ce.addGrid(c,n);return o?._moving&&(f._isTemp=!0),d&&(f._autoColumn=!0),i&&f.makeWidget(u,h),o&&(o._moving?window.setTimeout(()=>$.simulateMouseEvent(o._event,"mouseenter",f.el),0):f.makeWidget(s.el,s)),this.resizeToContentCheck(!1,s),f}removeAsSubGrid(e){const n=this.parentGridNode?.grid;n&&(n.batchUpdate(),n.removeWidget(this.parentGridNode.el,!0,!0),this.engine.nodes.forEach(o=>{o.x+=this.parentGridNode.x,o.y+=this.parentGridNode.y,n.makeWidget(o.el,o)}),n.batchUpdate(!1),this.parentGridNode&&delete this.parentGridNode.subGrid,delete this.parentGridNode,e&&window.setTimeout(()=>$.simulateMouseEvent(e._event,"mouseenter",n.el),0))}save(e=!0,n=!1,o=ce.saveCB,i){const s=this.engine.save(e,o,i);if(s.forEach(a=>{if(e&&a.el&&!a.subGrid&&!o)a.content=a.el.querySelector(".grid-stack-item-content")?.innerHTML,a.content||delete a.content;else if(!e&&!o&&delete a.content,a.subGrid?.el){const l=a.w||a.subGrid.getColumn(),d=a.subGrid.save(e,n,o,l);a.subGridOpts=n?d:{children:d},delete a.subGrid}delete a.el}),n){const a=$.cloneDeep(this.opts);a.marginBottom===a.marginTop&&a.marginRight===a.marginLeft&&a.marginTop===a.marginRight&&(a.margin=a.marginTop,delete a.marginTop,delete a.marginRight,delete a.marginBottom,delete a.marginLeft),a.rtl===(this.el.style.direction==="rtl")&&(a.rtl="auto"),this._isAutoCellHeight&&(a.cellHeight="auto"),this._autoColumn&&(a.column="auto");const l=a._alwaysShowResizeHandle;return delete a._alwaysShowResizeHandle,l!==void 0?a.alwaysShowResizeHandle=l:delete a.alwaysShowResizeHandle,$.removeInternalAndSame(a,ke),a.children=s,a}return s}load(e,n=ce.addRemoveCB||!0){e=$.cloneDeep(e);const o=this.getColumn();e.forEach(u=>{u.w=u.w||u.minW||1,u.h=u.h||u.minH||1}),e=$.sort(e),this.engine.skipCacheUpdate=this._ignoreLayoutsNodeChange=!0;let i=0;e.forEach(u=>{i=Math.max(i,(u.x||0)+u.w)}),i>this.engine.defaultColumn&&(this.engine.defaultColumn=i),i>o&&(this.engine.nodes.length===0&&this.responseLayout?(this.engine.nodes=e,this.engine.columnChanged(i,o,this.responseLayout),e=this.engine.nodes,this.engine.nodes=[],delete this.responseLayout):this.engine.cacheLayout(e,i,!0));const s=ce.addRemoveCB;typeof n=="function"&&(ce.addRemoveCB=n);const a=[];this.batchUpdate();const l=!this.engine.nodes.length,d=l&&this.opts.animate;d&&this.setAnimation(!1),!l&&n&&[...this.engine.nodes].forEach(u=>{u.id&&($.find(e,u.id)||(ce.addRemoveCB&&ce.addRemoveCB(this.el,u,!1,!1),a.push(u),this.removeWidget(u.el,!0,!1)))}),this.engine._loading=!0;const c=[];return this.engine.nodes=this.engine.nodes.filter(u=>$.find(e,u.id)?(c.push(u),!1):!0),e.forEach(u=>{const h=$.find(c,u.id);if(h){if($.shouldSizeToContent(h)&&(u.h=h.h),this.engine.nodeBoundFix(u),(u.autoPosition||u.x===void 0||u.y===void 0)&&(u.w=u.w||h.w,u.h=u.h||h.h,this.engine.findEmptyPosition(u)),this.engine.nodes.push(h),$.samePos(h,u)&&this.engine.nodes.length>1&&(this.moveNode(h,{...u,forceCollide:!0}),$.copyPos(u,h)),this.update(h.el,u),u.subGridOpts?.children){const f=h.el.querySelector(".grid-stack");f&&f.gridstack&&f.gridstack.load(u.subGridOpts.children)}}else n&&this.addWidget(u)}),delete this.engine._loading,this.engine.removedNodes=a,this.batchUpdate(!1),delete this._ignoreLayoutsNodeChange,delete this.engine.skipCacheUpdate,s?ce.addRemoveCB=s:delete ce.addRemoveCB,d&&this.setAnimation(!0,!0),this}batchUpdate(e=!0){return this.engine.batchUpdate(e),e||(this._updateContainerHeight(),this._triggerRemoveEvent(),this._triggerAddEvent(),this._triggerChangeEvent()),this}getCellHeight(e=!1){if(this.opts.cellHeight&&this.opts.cellHeight!=="auto"&&(!e||!this.opts.cellHeightUnit||this.opts.cellHeightUnit==="px"))return this.opts.cellHeight;if(this.opts.cellHeightUnit==="rem")return this.opts.cellHeight*parseFloat(getComputedStyle(document.documentElement).fontSize);if(this.opts.cellHeightUnit==="em")return this.opts.cellHeight*parseFloat(getComputedStyle(this.el).fontSize);if(this.opts.cellHeightUnit==="cm")return this.opts.cellHeight*(96/2.54);if(this.opts.cellHeightUnit==="mm")return this.opts.cellHeight*(96/2.54)/10;const n=this.el.querySelector("."+this.opts.itemClass);if(n){const i=$.toNumber(n.getAttribute("gs-h"))||1;return Math.round(n.offsetHeight/i)}const o=parseInt(this.el.getAttribute("gs-current-row"));return o?Math.round(this.el.getBoundingClientRect().height/o):this.opts.cellHeight}cellHeight(e){if(e!==void 0&&this._isAutoCellHeight!==(e==="auto")&&(this._isAutoCellHeight=e==="auto",this._updateResizeEvent()),(e==="initial"||e==="auto")&&(e=void 0),e===void 0){const o=-this.opts.marginRight-this.opts.marginLeft+this.opts.marginTop+this.opts.marginBottom;e=this.cellWidth()+o}const n=$.parseHeight(e);return this.opts.cellHeightUnit===n.unit&&this.opts.cellHeight===n.h?this:(this.opts.cellHeightUnit=n.unit,this.opts.cellHeight=n.h,this.el.style.setProperty("--gs-cell-height",`${this.opts.cellHeight}${this.opts.cellHeightUnit}`),this._updateContainerHeight(),this.resizeToContentCheck(),this)}cellWidth(){return this._widthOrContainer()/this.getColumn()}_widthOrContainer(e=!1){return e&&this.opts.columnOpts?.breakpointForWindow?window.innerWidth:this.el.clientWidth||this.el.parentElement.clientWidth||window.innerWidth}checkDynamicColumn(){const e=this.opts.columnOpts;if(!e||!e.columnWidth&&!e.breakpoints?.length)return!1;const n=this.getColumn();let o=n;const i=this._widthOrContainer(!0);if(e.columnWidth)o=Math.min(Math.round(i/e.columnWidth)||1,e.columnMax);else{o=e.columnMax;let s=0;for(;s<e.breakpoints.length&&i<=e.breakpoints[s].w;)o=e.breakpoints[s++].c||n}if(o!==n){const s=e.breakpoints?.find(a=>a.c===o);return this.column(o,s?.layout||e.layout),!0}return!1}compact(e="compact",n=!0){return this.engine.compact(e,n),this._triggerChangeEvent(),this}column(e,n="moveScale"){if(!e||e<1||this.opts.column===e)return this;const o=this.getColumn();return this.opts.column=e,this.engine?(this.engine.column=e,this.el.classList.remove("gs-"+o),this._updateColumnVar(),this.engine.columnChanged(o,e,n),this._isAutoCellHeight&&this.cellHeight(),this.resizeToContentCheck(!0),this._ignoreLayoutsNodeChange=!0,this._triggerChangeEvent(),delete this._ignoreLayoutsNodeChange,this):(this.responseLayout=n,this)}getColumn(){return this.opts.column}getGridItems(){return Array.from(this.el.children).filter(e=>e.matches("."+this.opts.itemClass)&&!e.matches("."+this.opts.placeholderClass))}isIgnoreChangeCB(){return this._ignoreLayoutsNodeChange}destroy(e=!0){if(this.el)return this.offAll(),this._updateResizeEvent(!0),this.setStatic(!0,!1),this.setAnimation(!1),e?this.el.parentNode.removeChild(this.el):(this.removeAll(e),this.el.removeAttribute("gs-current-row")),this.parentGridNode&&delete this.parentGridNode.subGrid,delete this.parentGridNode,delete this.opts,delete this._placeholder?.gridstackNode,delete this._placeholder,delete this.engine,delete this.el.gridstack,delete this.el,this}float(e){return this.opts.float!==e&&(this.opts.float=this.engine.float=e,this._triggerChangeEvent()),this}getFloat(){return this.engine.float}getCellFromPixel(e,n=!1){const o=this.el.getBoundingClientRect();let i;n?i={top:o.top+document.documentElement.scrollTop,left:o.left}:i={top:this.el.offsetTop,left:this.el.offsetLeft};const s=e.left-i.left,a=e.top-i.top,l=o.width/this.getColumn(),d=o.height/parseInt(this.el.getAttribute("gs-current-row"));return{x:Math.floor(s/l),y:Math.floor(a/d)}}getRow(){return Math.max(this.engine.getRow(),this.opts.minRow||0)}isAreaEmpty(e,n,o,i){return this.engine.isAreaEmpty(e,n,o,i)}makeWidget(e,n){const o=ce.getElement(e);if(!o||o.gridstackNode)return o;o.parentElement||this.el.appendChild(o),this._prepareElement(o,!0,n);const i=o.gridstackNode;this._updateContainerHeight(),i.subGridOpts&&this.makeSubGrid(o,i.subGridOpts,void 0,!1);let s;return this.opts.column===1&&!this._ignoreLayoutsNodeChange&&(s=this._ignoreLayoutsNodeChange=!0),this._triggerAddEvent(),this._triggerChangeEvent(),s&&delete this._ignoreLayoutsNodeChange,o}on(e,n){return e.indexOf(" ")!==-1?(e.split(" ").forEach(o=>this.on(o,n)),this):(e==="change"||e==="added"||e==="removed"||e==="enable"||e==="disable"?(e==="enable"||e==="disable"?this._gsEventHandler[e]=o=>n(o):this._gsEventHandler[e]=o=>{o.detail&&n(o,o.detail)},this.el.addEventListener(e,this._gsEventHandler[e])):e==="drag"||e==="dragstart"||e==="dragstop"||e==="resizestart"||e==="resize"||e==="resizestop"||e==="dropped"||e==="resizecontent"?this._gsEventHandler[e]=n:console.error("GridStack.on("+e+") event not supported"),this)}off(e){return e.indexOf(" ")!==-1?(e.split(" ").forEach(n=>this.off(n)),this):((e==="change"||e==="added"||e==="removed"||e==="enable"||e==="disable")&&this._gsEventHandler[e]&&this.el.removeEventListener(e,this._gsEventHandler[e]),delete this._gsEventHandler[e],this)}offAll(){return Object.keys(this._gsEventHandler).forEach(e=>this.off(e)),this}removeWidget(e,n=!0,o=!0){return e?(ce.getElements(e).forEach(i=>{if(i.parentElement&&i.parentElement!==this.el)return;let s=i.gridstackNode;s||(s=this.engine.nodes.find(a=>i===a.el)),s&&(n&&ce.addRemoveCB&&ce.addRemoveCB(this.el,s,!1,!1),delete i.gridstackNode,this._removeDD(i),this.engine.removeNode(s,n,o),n&&i.parentElement&&i.remove())}),o&&(this._triggerRemoveEvent(),this._triggerChangeEvent()),this):(console.error("Error: GridStack.removeWidget(undefined) called"),this)}removeAll(e=!0,n=!0){return this.engine.nodes.forEach(o=>{e&&ce.addRemoveCB&&ce.addRemoveCB(this.el,o,!1,!1),delete o.el.gridstackNode,this.opts.staticGrid||this._removeDD(o.el)}),this.engine.removeAll(e,n),n&&this._triggerRemoveEvent(),this}setAnimation(e=this.opts.animate,n){return n?setTimeout(()=>{this.opts&&this.setAnimation(e)}):e?this.el.classList.add("grid-stack-animate"):this.el.classList.remove("grid-stack-animate"),this.opts.animate=e,this}hasAnimationCSS(){return this.el.classList.contains("grid-stack-animate")}setStatic(e,n=!0,o=!0){return!!this.opts.staticGrid===e?this:(e?this.opts.staticGrid=!0:delete this.opts.staticGrid,this._setupRemoveDrop(),this._setupAcceptWidget(),this.engine.nodes.forEach(i=>{this.prepareDragDrop(i.el),i.subGrid&&o&&i.subGrid.setStatic(e,n,o)}),n&&this._setStaticClass(),this)}updateOptions(e){const n=this.opts;return e===n?this:(e.acceptWidgets!==void 0&&(n.acceptWidgets=e.acceptWidgets,this._setupAcceptWidget()),e.animate!==void 0&&this.setAnimation(e.animate),e.cellHeight&&this.cellHeight(e.cellHeight),e.class!==void 0&&e.class!==n.class&&(n.class&&this.el.classList.remove(n.class),e.class&&this.el.classList.add(e.class)),e.columnOpts?(this.opts.columnOpts=e.columnOpts,this.checkDynamicColumn()):e.columnOpts===null&&this.opts.columnOpts?(delete this.opts.columnOpts,this._updateResizeEvent()):typeof e.column=="number"&&this.column(e.column),e.margin!==void 0&&this.margin(e.margin),e.staticGrid!==void 0&&this.setStatic(e.staticGrid),e.disableDrag!==void 0&&!e.staticGrid&&this.enableMove(!e.disableDrag),e.disableResize!==void 0&&!e.staticGrid&&this.enableResize(!e.disableResize),e.float!==void 0&&this.float(e.float),e.row!==void 0?(n.minRow=n.maxRow=n.row=e.row,this._updateContainerHeight()):(e.minRow!==void 0&&(n.minRow=e.minRow,this._updateContainerHeight()),e.maxRow!==void 0&&(n.maxRow=e.maxRow)),e.lazyLoad!==void 0&&(n.lazyLoad=e.lazyLoad),e.children?.length&&this.load(e.children),this)}update(e,n){return ce.getElements(e).forEach(o=>{const i=o?.gridstackNode;if(!i)return;const s={...$.copyPos({},i),...$.cloneDeep(n)};this.engine.nodeBoundFix(s),delete s.autoPosition;const a=["x","y","w","h"];let l;if(a.some(u=>s[u]!==void 0&&s[u]!==i[u])&&(l={},a.forEach(u=>{l[u]=s[u]!==void 0?s[u]:i[u],delete s[u]})),!l&&(s.minW||s.minH||s.maxW||s.maxH)&&(l={}),s.content!==void 0){const u=o.querySelector(".grid-stack-item-content");u&&u.textContent!==s.content&&(i.content=s.content,ce.renderCB(u,s),i.subGrid?.el&&(u.appendChild(i.subGrid.el),i.subGrid._updateContainerHeight())),delete s.content}let d=!1,c=!1;for(const u in s)u[0]!=="_"&&i[u]!==s[u]&&(i[u]=s[u],d=!0,c=c||!this.opts.staticGrid&&(u==="noResize"||u==="noMove"||u==="locked"));if($.sanitizeMinMax(i),l){const u=l.w!==void 0&&l.w!==i.w;this.moveNode(i,l),u&&i.subGrid?i.subGrid.onResize(this.hasAnimationCSS()?i.w:void 0):this.resizeToContentCheck(u,i),delete i._orig}(l||d)&&this._writeAttr(o,i),c&&this.prepareDragDrop(i.el),ce.updateCB&&ce.updateCB(i)}),this}moveNode(e,n){const o=e._updating;o||this.engine.cleanNodes().beginUpdate(e),this.engine.moveNode(e,n),this._updateContainerHeight(),o||(this._triggerChangeEvent(),this.engine.endUpdate())}resizeToContent(e){if(!e||(e.classList.remove("size-to-content-max"),!e.clientHeight))return;const n=e.gridstackNode;if(!n)return;const o=n.grid;if(!o||e.parentElement!==o.el)return;const i=o.getCellHeight(!0);if(!i)return;let s=n.h?n.h*i:e.clientHeight,a;if(n.resizeToContentParent&&(a=e.querySelector(n.resizeToContentParent)),a||(a=e.querySelector(ce.resizeToContentParent)),!a)return;const l=e.clientHeight-a.clientHeight,d=n.h?n.h*i-l:a.clientHeight;let c;if(n.subGrid){c=n.subGrid.getRow()*n.subGrid.getCellHeight(!0);const f=n.subGrid.el.getBoundingClientRect(),g=e.getBoundingClientRect();c+=f.top-g.top}else{if(n.subGridOpts?.children?.length)return;{const f=a.firstElementChild;if(!f){console.error(`Error: GridStack.resizeToContent() widget id:${n.id} '${ce.resizeToContentParent}'.firstElementChild is null, make sure to have a div like container. Skipping sizing.`);return}c=f.getBoundingClientRect().height||d}}if(d===c)return;s+=c-d;let u=Math.ceil(s/i);const h=Number.isInteger(n.sizeToContent)?n.sizeToContent:0;h&&u>h&&(u=h,e.classList.add("size-to-content-max")),n.minH&&u<n.minH?u=n.minH:n.maxH&&u>n.maxH&&(u=n.maxH),u!==n.h&&(o._ignoreLayoutsNodeChange=!0,o.moveNode(n,{h:u}),delete o._ignoreLayoutsNodeChange)}resizeToContentCBCheck(e){ce.resizeToContentCB?ce.resizeToContentCB(e):this.resizeToContent(e)}rotate(e,n){return ce.getElements(e).forEach(o=>{const i=o.gridstackNode;if(!$.canBeRotated(i))return;const s={w:i.h,h:i.w,minH:i.minW,minW:i.minH,maxH:i.maxW,maxW:i.maxH};if(n){const l=n.left>0?Math.floor(n.left/this.cellWidth()):0,d=n.top>0?Math.floor(n.top/this.opts.cellHeight):0;s.x=i.x+l-(i.h-(d+1)),s.y=i.y+d-l}Object.keys(s).forEach(l=>{s[l]===void 0&&delete s[l]});const a=i._orig;this.update(o,s),i._orig=a}),this}margin(e){if(!(typeof e=="string"&&e.split(" ").length>1)){const n=$.parseHeight(e);if(this.opts.marginUnit===n.unit&&this.opts.margin===n.h)return}return this.opts.margin=e,this.opts.marginTop=this.opts.marginBottom=this.opts.marginLeft=this.opts.marginRight=void 0,this._initMargin(),this}getMargin(){return this.opts.margin}willItFit(e){return this.engine.willItFit(e)}_triggerChangeEvent(){if(this.engine.batchMode)return this;const e=this.engine.getDirtyNodes(!0);return e&&e.length&&(this._ignoreLayoutsNodeChange||this.engine.layoutsNodesChange(e),this._triggerEvent("change",e)),this.engine.saveInitial(),this}_triggerAddEvent(){if(this.engine.batchMode)return this;if(this.engine.addedNodes?.length){this._ignoreLayoutsNodeChange||this.engine.layoutsNodesChange(this.engine.addedNodes),this.engine.addedNodes.forEach(n=>{delete n._dirty});const e=[...this.engine.addedNodes];this.engine.addedNodes=[],this._triggerEvent("added",e)}return this}_triggerRemoveEvent(){if(this.engine.batchMode)return this;if(this.engine.removedNodes?.length){const e=[...this.engine.removedNodes];this.engine.removedNodes=[],this._triggerEvent("removed",e)}return this}_triggerEvent(e,n){const o=n?new CustomEvent(e,{bubbles:!1,detail:n}):new Event(e);let i=this;for(;i.parentGridNode;)i=i.parentGridNode.grid;return i.el.dispatchEvent(o),this}_updateContainerHeight(){if(!this.engine||this.engine.batchMode)return this;const e=this.parentGridNode;let n=this.getRow()+this._extraDragRow;const o=this.opts.cellHeight,i=this.opts.cellHeightUnit;if(!o)return this;if(!e&&!this.opts.minRow){const s=$.parseHeight(getComputedStyle(this.el).minHeight);if(s.h>0&&s.unit===i){const a=Math.floor(s.h/o);n<a&&(n=a)}}return this.el.setAttribute("gs-current-row",String(n)),this.el.style.removeProperty("min-height"),this.el.style.removeProperty("height"),n&&(this.el.style[e?"minHeight":"height"]=n*o+i),e&&$.shouldSizeToContent(e)&&e.grid.resizeToContentCBCheck(e.el),this}_prepareElement(e,n=!1,o){o=o||this._readAttr(e),e.gridstackNode=o,o.el=e,o.grid=this,o=this.engine.addNode(o,n),this._writeAttr(e,o),e.classList.add(ke.itemClass,this.opts.itemClass);const i=$.shouldSizeToContent(o);return i?e.classList.add("size-to-content"):e.classList.remove("size-to-content"),i&&this.resizeToContentCheck(!1,o),$.lazyLoad(o)||this.prepareDragDrop(o.el),this}_writePosAttr(e,n){return(!n._moving&&!n._resizing||this._placeholder===e)&&(e.style.top=n.y?n.y===1?"var(--gs-cell-height)":`calc(${n.y} * var(--gs-cell-height))`:null,e.style.left=n.x?n.x===1?"var(--gs-column-width)":`calc(${n.x} * var(--gs-column-width))`:null,e.style.width=n.w>1?`calc(${n.w} * var(--gs-column-width))`:null,e.style.height=n.h>1?`calc(${n.h} * var(--gs-cell-height))`:null),e.setAttribute("gs-x",String(n.x)),e.setAttribute("gs-y",String(n.y)),n.w>1?e.setAttribute("gs-w",String(n.w)):e.removeAttribute("gs-w"),n.h>1?e.setAttribute("gs-h",String(n.h)):e.removeAttribute("gs-h"),this}_writeAttr(e,n){if(!n)return this;this._writePosAttr(e,n);const o={noResize:"gs-no-resize",noMove:"gs-no-move",locked:"gs-locked",id:"gs-id",sizeToContent:"gs-size-to-content"};for(const i in o)n[i]?e.setAttribute(o[i],String(n[i])):e.removeAttribute(o[i]);return this}_readAttr(e,n=!0){const o={};o.x=$.toNumber(e.getAttribute("gs-x")),o.y=$.toNumber(e.getAttribute("gs-y")),o.w=$.toNumber(e.getAttribute("gs-w")),o.h=$.toNumber(e.getAttribute("gs-h")),o.autoPosition=$.toBool(e.getAttribute("gs-auto-position")),o.noResize=$.toBool(e.getAttribute("gs-no-resize")),o.noMove=$.toBool(e.getAttribute("gs-no-move")),o.locked=$.toBool(e.getAttribute("gs-locked"));const i=e.getAttribute("gs-size-to-content");i&&(i==="true"||i==="false"?o.sizeToContent=$.toBool(i):o.sizeToContent=parseInt(i,10)),o.id=e.getAttribute("gs-id"),o.maxW=$.toNumber(e.getAttribute("gs-max-w")),o.minW=$.toNumber(e.getAttribute("gs-min-w")),o.maxH=$.toNumber(e.getAttribute("gs-max-h")),o.minH=$.toNumber(e.getAttribute("gs-min-h")),n&&(o.w===1&&e.removeAttribute("gs-w"),o.h===1&&e.removeAttribute("gs-h"),o.maxW&&e.removeAttribute("gs-max-w"),o.minW&&e.removeAttribute("gs-min-w"),o.maxH&&e.removeAttribute("gs-max-h"),o.minH&&e.removeAttribute("gs-min-h"));for(const s in o){if(!o.hasOwnProperty(s))return;!o[s]&&o[s]!==0&&s!=="sizeToContent"&&delete o[s]}return o}_setStaticClass(){const e=["grid-stack-static"];return this.opts.staticGrid?(this.el.classList.add(...e),this.el.setAttribute("gs-static","true")):(this.el.classList.remove(...e),this.el.removeAttribute("gs-static")),this}onResize(e=this.el?.clientWidth){if(!e||this.prevWidth===e)return;this.prevWidth=e,this.batchUpdate();let n=!1;return this._autoColumn&&this.parentGridNode?this.opts.column!==this.parentGridNode.w&&(this.column(this.parentGridNode.w,this.opts.layout||"list"),n=!0):n=this.checkDynamicColumn(),this._isAutoCellHeight&&this.cellHeight(),this.engine.nodes.forEach(o=>{o.subGrid&&o.subGrid.onResize()}),this._skipInitialResize||this.resizeToContentCheck(n),delete this._skipInitialResize,this.batchUpdate(!1),this}resizeToContentCheck(e=!1,n=void 0){if(this.engine){if(e&&this.hasAnimationCSS())return setTimeout(()=>this.resizeToContentCheck(!1,n),this.animationDelay);if(n)$.shouldSizeToContent(n)&&this.resizeToContentCBCheck(n.el);else if(this.engine.nodes.some(o=>$.shouldSizeToContent(o))){const o=[...this.engine.nodes];this.batchUpdate(),o.forEach(i=>{$.shouldSizeToContent(i)&&this.resizeToContentCBCheck(i.el)}),this._ignoreLayoutsNodeChange=!0,this.batchUpdate(!1),this._ignoreLayoutsNodeChange=!1}this._gsEventHandler.resizecontent&&this._gsEventHandler.resizecontent(null,n?[n]:this.engine.nodes)}}_updateResizeEvent(e=!1){const n=!this.parentGridNode&&(this._isAutoCellHeight||this.opts.sizeToContent||this.opts.columnOpts||this.engine.nodes.find(o=>o.sizeToContent));return!e&&n&&!this.resizeObserver?(this._sizeThrottle=$.throttle(()=>this.onResize(),this.opts.cellHeightThrottle),this.resizeObserver=new ResizeObserver(()=>this._sizeThrottle()),this.resizeObserver.observe(this.el),this._skipInitialResize=!0):(e||!n)&&this.resizeObserver&&(this.resizeObserver.disconnect(),delete this.resizeObserver,delete this._sizeThrottle),this}static getElement(e=".grid-stack-item"){return $.getElement(e)}static getElements(e=".grid-stack-item"){return $.getElements(e)}static getGridElement(e){return ce.getElement(e)}static getGridElements(e){return $.getElements(e)}_initMargin(){let e,n=0,o=[];typeof this.opts.margin=="string"&&(o=this.opts.margin.split(" ")),o.length===2?(this.opts.marginTop=this.opts.marginBottom=o[0],this.opts.marginLeft=this.opts.marginRight=o[1]):o.length===4?(this.opts.marginTop=o[0],this.opts.marginRight=o[1],this.opts.marginBottom=o[2],this.opts.marginLeft=o[3]):(e=$.parseHeight(this.opts.margin),this.opts.marginUnit=e.unit,n=this.opts.margin=e.h),["marginTop","marginRight","marginBottom","marginLeft"].forEach(s=>{this.opts[s]===void 0?this.opts[s]=n:(e=$.parseHeight(this.opts[s]),this.opts[s]=e.h,delete this.opts.margin)}),this.opts.marginUnit=e.unit,this.opts.marginTop===this.opts.marginBottom&&this.opts.marginLeft===this.opts.marginRight&&this.opts.marginTop===this.opts.marginRight&&(this.opts.margin=this.opts.marginTop);const i=this.el.style;return i.setProperty("--gs-item-margin-top",`${this.opts.marginTop}${this.opts.marginUnit}`),i.setProperty("--gs-item-margin-bottom",`${this.opts.marginBottom}${this.opts.marginUnit}`),i.setProperty("--gs-item-margin-right",`${this.opts.marginRight}${this.opts.marginUnit}`),i.setProperty("--gs-item-margin-left",`${this.opts.marginLeft}${this.opts.marginUnit}`),this}static getDD(){return Ce}static setupDragIn(e,n,o,i=document){n?.pause!==void 0&&(de.pauseDrag=n.pause),n={appendTo:"body",helper:"clone",...n||{}},(typeof e=="string"?$.getElements(e,i):e).forEach((s,a)=>{Ce.isDraggable(s)||Ce.dragIn(s,n),o?.[a]&&(s.gridstackNode=o[a])})}movable(e,n){return this.opts.staticGrid?this:(ce.getElements(e).forEach(o=>{const i=o.gridstackNode;i&&(n?delete i.noMove:i.noMove=!0,this.prepareDragDrop(i.el))}),this)}resizable(e,n){return this.opts.staticGrid?this:(ce.getElements(e).forEach(o=>{const i=o.gridstackNode;i&&(n?delete i.noResize:i.noResize=!0,this.prepareDragDrop(i.el))}),this)}disable(e=!0){if(!this.opts.staticGrid)return this.enableMove(!1,e),this.enableResize(!1,e),this._triggerEvent("disable"),this}enable(e=!0){if(!this.opts.staticGrid)return this.enableMove(!0,e),this.enableResize(!0,e),this._triggerEvent("enable"),this}enableMove(e,n=!0){return this.opts.staticGrid?this:(e?delete this.opts.disableDrag:this.opts.disableDrag=!0,this.engine.nodes.forEach(o=>{this.prepareDragDrop(o.el),o.subGrid&&n&&o.subGrid.enableMove(e,n)}),this)}enableResize(e,n=!0){return this.opts.staticGrid?this:(e?delete this.opts.disableResize:this.opts.disableResize=!0,this.engine.nodes.forEach(o=>{this.prepareDragDrop(o.el),o.subGrid&&n&&o.subGrid.enableResize(e,n)}),this)}cancelDrag(){const e=this._placeholder?.gridstackNode;e&&(e._isExternal?(e._isAboutToRemove=!0,this.engine.removeNode(e)):e._isAboutToRemove&&ce._itemRemoving(e.el,!1),this.engine.restoreInitial())}_removeDD(e){return Ce.draggable(e,"destroy").resizable(e,"destroy"),e.gridstackNode&&delete e.gridstackNode._initDD,delete e.ddElement,this}_setupAcceptWidget(){if(this.opts.staticGrid||!this.opts.acceptWidgets&&!this.opts.removable)return Ce.droppable(this.el,"destroy"),this;let e,n;const o=(i,s,a)=>{a=a||s;const l=a.gridstackNode;if(!l)return;if(!l.grid?.el){a.style.transform=`scale(${1/this.dragTransform.xScale},${1/this.dragTransform.yScale})`;const f=a.getBoundingClientRect();a.style.left=f.x+(this.dragTransform.xScale-1)*(i.clientX-f.x)/this.dragTransform.xScale+"px",a.style.top=f.y+(this.dragTransform.yScale-1)*(i.clientY-f.y)/this.dragTransform.yScale+"px",a.style.transformOrigin="0px 0px"}let{top:d,left:c}=a.getBoundingClientRect();const u=this.el.getBoundingClientRect();c-=u.left,d-=u.top;const h={position:{top:d*this.dragTransform.xScale,left:c*this.dragTransform.yScale}};if(l._temporaryRemoved){if(l.x=Math.max(0,Math.round(c/n)),l.y=Math.max(0,Math.round(d/e)),delete l.autoPosition,this.engine.nodeBoundFix(l),!this.engine.willItFit(l)){if(l.autoPosition=!0,!this.engine.willItFit(l)){Ce.off(s,"drag");return}l._willFitPos&&($.copyPos(l,l._willFitPos),delete l._willFitPos)}this._onStartMoving(a,i,h,l,n,e)}else this._dragOrResize(a,i,h,l,n,e)};return Ce.droppable(this.el,{accept:i=>{const s=i.gridstackNode||this._readAttr(i,!1);if(s?.grid===this)return!0;if(!this.opts.acceptWidgets)return!1;let a=!0;if(typeof this.opts.acceptWidgets=="function")a=this.opts.acceptWidgets(i);else{const l=this.opts.acceptWidgets===!0?".grid-stack-item":this.opts.acceptWidgets;a=i.matches(l)}if(a&&s&&this.opts.maxRow){const l={w:s.w,h:s.h,minW:s.minW,minH:s.minH};a=this.engine.willItFit(l)}return a}}).on(this.el,"dropover",(i,s,a)=>{let l=a?.gridstackNode||s.gridstackNode;if(l?.grid===this&&!l._temporaryRemoved)return!1;if(l?._sidebarOrig&&(l.w=l._sidebarOrig.w,l.h=l._sidebarOrig.h),l?.grid&&l.grid!==this&&!l._temporaryRemoved&&l.grid._leave(s,a),a=a||s,n=this.cellWidth(),e=this.getCellHeight(!0),!l){const u=a.getAttribute("data-gs-widget")||a.getAttribute("gridstacknode");if(u){try{l=JSON.parse(u)}catch{console.error("Gridstack dropover: Bad JSON format: ",u)}a.removeAttribute("data-gs-widget"),a.removeAttribute("gridstacknode")}l||(l=this._readAttr(a)),l._sidebarOrig={w:l.w,h:l.h}}l.grid||(l.el||(l={...l}),l._isExternal=!0,a.gridstackNode=l);const d=l.w||Math.round(a.offsetWidth/n)||1,c=l.h||Math.round(a.offsetHeight/e)||1;return l.grid&&l.grid!==this?(s._gridstackNodeOrig||(s._gridstackNodeOrig=l),s.gridstackNode=l={...l,w:d,h:c,grid:this},delete l.x,delete l.y,this.engine.cleanupNode(l).nodeBoundFix(l),l._initDD=l._isExternal=l._temporaryRemoved=!0):(l.w=d,l.h=c,l._temporaryRemoved=!0),ce._itemRemoving(l.el,!1),Ce.on(s,"drag",o),o(i,s,a),!1}).on(this.el,"dropout",(i,s,a)=>{const l=a?.gridstackNode||s.gridstackNode;return l&&(!l.grid||l.grid===this)&&(this._leave(s,a),this._isTemp&&this.removeAsSubGrid(l)),!1}).on(this.el,"drop",(i,s,a)=>{const l=a?.gridstackNode||s.gridstackNode;if(l?.grid===this&&!l._isExternal)return!1;const d=!!this.placeholder.parentElement,c=s!==a;this.placeholder.remove(),delete this.placeholder.gridstackNode,d&&this.opts.animate&&(this.setAnimation(!1),this.setAnimation(!0,!0));const u=s._gridstackNodeOrig;if(delete s._gridstackNodeOrig,d&&u?.grid&&u.grid!==this){const f=u.grid;f.engine.removeNodeFromLayoutCache(u),f.engine.removedNodes.push(u),f._triggerRemoveEvent()._triggerChangeEvent(),f.parentGridNode&&!f.engine.nodes.length&&f.opts.subGridDynamic&&f.removeAsSubGrid()}if(!l||(d&&(this.engine.cleanupNode(l),l.grid=this),delete l.grid?._isTemp,Ce.off(s,"drag"),a!==s?(a.remove(),s=a):s.remove(),this._removeDD(s),!d))return!1;const h=l.subGrid?.el?.gridstack;return $.copyPos(l,this._readAttr(this.placeholder)),$.removePositioningStyles(s),c&&(l.content||l.subGridOpts||ce.addRemoveCB)?(delete l.el,s=this.addWidget(l)):(this._prepareElement(s,!0,l),this.el.appendChild(s),this.resizeToContentCheck(!1,l),h&&(h.parentGridNode=l),this._updateContainerHeight()),this.engine.addedNodes.push(l),this._triggerAddEvent(),this._triggerChangeEvent(),this.engine.endUpdate(),this._gsEventHandler.dropped&&this._gsEventHandler.dropped({...i,type:"dropped"},u&&u.grid?u:void 0,l),!1}),this}static _itemRemoving(e,n){if(!e)return;const o=e?e.gridstackNode:void 0;!o?.grid||e.classList.contains(o.grid.opts.removableOptions.decline)||(n?o._isAboutToRemove=!0:delete o._isAboutToRemove,n?e.classList.add("grid-stack-item-removing"):e.classList.remove("grid-stack-item-removing"))}_setupRemoveDrop(){if(typeof this.opts.removable!="string")return this;const e=document.querySelector(this.opts.removable);return e?(!this.opts.staticGrid&&!Ce.isDroppable(e)&&Ce.droppable(e,this.opts.removableOptions).on(e,"dropover",(n,o)=>ce._itemRemoving(o,!0)).on(e,"dropout",(n,o)=>ce._itemRemoving(o,!1)),this):this}prepareDragDrop(e,n=!1){const o=e?.gridstackNode;if(!o)return;const i=o.noMove||this.opts.disableDrag,s=o.noResize||this.opts.disableResize,a=this.opts.staticGrid||i&&s;if((n||a)&&(o._initDD&&(this._removeDD(e),delete o._initDD),a&&e.classList.add("ui-draggable-disabled","ui-resizable-disabled"),!n))return this;if(!o._initDD){let l,d;const c=(f,g)=>{this.triggerEvent(f,f.target),l=this.cellWidth(),d=this.getCellHeight(!0),this._onStartMoving(e,f,g,o,l,d)},u=(f,g)=>{this._dragOrResize(e,f,g,o,l,d)},h=f=>{this.placeholder.remove(),delete this.placeholder.gridstackNode,delete o._moving,delete o._resizing,delete o._event,delete o._lastTried;const g=o.w!==o._orig.w,m=f.target;if(!(!m.gridstackNode||m.gridstackNode.grid!==this)){if(o.el=m,o._isAboutToRemove){const E=e.gridstackNode.grid;E._gsEventHandler[f.type]&&E._gsEventHandler[f.type](f,m),E.engine.nodes.push(o),E.removeWidget(e,!0,!0)}else $.removePositioningStyles(m),o._temporaryRemoved?(this._writePosAttr(m,o),this.engine.addNode(o)):this._writePosAttr(m,o),this.triggerEvent(f,m);this._extraDragRow=0,this._updateContainerHeight(),this._triggerChangeEvent(),this.engine.endUpdate(),f.type==="resizestop"&&(Number.isInteger(o.sizeToContent)&&(o.sizeToContent=o.h),this.resizeToContentCheck(g,o))}};Ce.draggable(e,{start:c,stop:h,drag:u}).resizable(e,{start:c,stop:h,resize:u}),o._initDD=!0}return Ce.draggable(e,i?"disable":"enable").resizable(e,s?"disable":"enable"),this}_onStartMoving(e,n,o,i,s,a){if(this.engine.cleanNodes().beginUpdate(i),this._writePosAttr(this.placeholder,i),this.el.appendChild(this.placeholder),this.placeholder.gridstackNode=i,i.grid?.el)this.dragTransform=$.getValuesFromTransformedElement(e);else if(this.placeholder&&this.placeholder.closest(".grid-stack")){const l=this.placeholder.closest(".grid-stack");this.dragTransform=$.getValuesFromTransformedElement(l)}else this.dragTransform={xScale:1,xOffset:0,yScale:1,yOffset:0};if(i.el=this.placeholder,i._lastUiPosition=o.position,i._prevYPix=o.position.top,i._moving=n.type==="dragstart",i._resizing=n.type==="resizestart",delete i._lastTried,n.type==="dropover"&&i._temporaryRemoved&&(this.engine.addNode(i),i._moving=!0),this.engine.cacheRects(s,a,this.opts.marginTop,this.opts.marginRight,this.opts.marginBottom,this.opts.marginLeft),n.type==="resizestart"){const l=this.getColumn()-i.x,d=(this.opts.maxRow||Number.MAX_SAFE_INTEGER)-i.y;Ce.resizable(e,"option","minWidth",s*Math.min(i.minW||1,l)).resizable(e,"option","minHeight",a*Math.min(i.minH||1,d)).resizable(e,"option","maxWidth",s*Math.min(i.maxW||Number.MAX_SAFE_INTEGER,l)).resizable(e,"option","maxWidthMoveLeft",s*Math.min(i.maxW||Number.MAX_SAFE_INTEGER,i.x+i.w)).resizable(e,"option","maxHeight",a*Math.min(i.maxH||Number.MAX_SAFE_INTEGER,d)).resizable(e,"option","maxHeightMoveUp",a*Math.min(i.maxH||Number.MAX_SAFE_INTEGER,i.y+i.h))}}_dragOrResize(e,n,o,i,s,a){const l={...i._orig};let d,c=this.opts.marginLeft,u=this.opts.marginRight,h=this.opts.marginTop,f=this.opts.marginBottom;const g=Math.round(a*.1),m=Math.round(s*.1);if(c=Math.min(c,m),u=Math.min(u,m),h=Math.min(h,g),f=Math.min(f,g),n.type==="drag"){if(i._temporaryRemoved)return;const S=o.position.top-i._prevYPix;i._prevYPix=o.position.top,this.opts.draggable.scroll!==!1&&$.updateScrollPosition(e,o.position,S);const D=o.position.left+(o.position.left>i._lastUiPosition.left?-u:c),B=o.position.top+(o.position.top>i._lastUiPosition.top?-f:h);l.x=Math.round(D/s),l.y=Math.round(B/a);const w=this._extraDragRow;if(this.engine.collide(i,l)){const M=this.getRow();let G=Math.max(0,l.y+i.h-M);this.opts.maxRow&&M+G>this.opts.maxRow&&(G=Math.max(0,this.opts.maxRow-M)),this._extraDragRow=G}else this._extraDragRow=0;if(this._extraDragRow!==w&&this._updateContainerHeight(),i.x===l.x&&i.y===l.y)return}else if(n.type==="resize"){if(l.x<0||($.updateScrollResize(n,e,a),l.w=Math.round((o.size.width-c)/s),l.h=Math.round((o.size.height-h)/a),i.w===l.w&&i.h===l.h)||i._lastTried&&i._lastTried.w===l.w&&i._lastTried.h===l.h)return;const S=o.position.left+c,D=o.position.top+h;l.x=Math.round(S/s),l.y=Math.round(D/a),d=!0}i._event=n,i._lastTried=l;const E={x:o.position.left+c,y:o.position.top+h,w:(o.size?o.size.width:i.w*s)-c-u,h:(o.size?o.size.height:i.h*a)-h-f};if(this.engine.moveNodeCheck(i,{...l,cellWidth:s,cellHeight:a,rect:E,resizing:d})){i._lastUiPosition=o.position,this.engine.cacheRects(s,a,h,u,f,c),delete i._skipDown,d&&i.subGrid&&i.subGrid.onResize(),this._extraDragRow=0,this._updateContainerHeight();const S=n.target;i._sidebarOrig||this._writePosAttr(S,i),this.triggerEvent(n,S)}}triggerEvent(e,n){let o=this;for(;o.parentGridNode;)o=o.parentGridNode.grid;o._gsEventHandler[e.type]&&o._gsEventHandler[e.type](e,n)}_leave(e,n){n=n||e;const o=n.gridstackNode;if(!o||(n.style.transform=n.style.transformOrigin=null,Ce.off(e,"drag"),o._temporaryRemoved))return;o._temporaryRemoved=!0,this.engine.removeNode(o),o.el=o._isExternal&&n?n:e;const i=o._sidebarOrig;o._isExternal&&this.engine.cleanupNode(o),o._sidebarOrig=i,this.opts.removable===!0&&ce._itemRemoving(e,!0),e._gridstackNodeOrig?(e.gridstackNode=e._gridstackNodeOrig,delete e._gridstackNodeOrig):o._isExternal&&this.engine.restoreInitial()}};mt.renderCB=(t,e)=>{t&&e?.content&&(t.textContent=e.content)},mt.resizeToContentParent=".grid-stack-item-content",mt.Utils=$,mt.Engine=_o,mt.GDRev="12.4.2";var eh={class:"d-layout"},th=["gs-id","gs-x","gs-y","gs-w","gs-h","gs-locked","gs-no-resize","gs-no-move","gs-min-w","gs-min-h","gs-max-w","gs-max-h"],nh=(0,r.defineComponent)({name:"DLayout",__name:"layout",props:{modelValue:{default:()=>[]},column:{default:24},cellHeight:{default:60},draggable:{type:Boolean,default:!0},resizable:{type:Boolean,default:!0},disable:{type:Boolean,default:!1},animate:{type:Boolean,default:!0},float:{type:Boolean,default:!0},removable:{type:Boolean,default:!1},removableOptions:{}},emits:["update:modelValue","added","removed","changed","dragStart","dragStop","resizeStart","resizeStop"],setup(t,{expose:e,emit:n}){const o=t,i=n,s=(0,r.ref)();let a=null;const l=async()=>{s.value&&(await(0,r.nextTick)(),a&&a.destroy(!1),a=mt.init({column:o.column,cellHeight:o.cellHeight,disableDrag:!(o.draggable&&!o.disable),disableResize:!(o.resizable&&!o.disable),animate:o.animate,float:o.float,removable:o.removable,removableOptions:o.removableOptions},s.value),a.on("added",(f,g)=>{const m=g[0];m&&(i("added",d(m)),u())}),a.on("removed",(f,g)=>{const m=g[0];m&&(i("removed",d(m)),u())}),a.on("change",()=>{u(),i("changed",(a?.save()||[]).map(f=>d(f)))}),a.on("dragstart",(f,g)=>{g&&i("dragStart",f,d(g.gridstackNode||g))}),a.on("dragstop",(f,g)=>{g&&i("dragStop",f,d(g.gridstackNode||g))}),a.on("resizestart",(f,g)=>{g&&i("resizeStart",f,d(g.gridstackNode||g))}),a.on("resizestop",(f,g)=>{g&&i("resizeStop",f,d(g.gridstackNode||g))}))},d=f=>({id:f.id||f.el?.getAttribute("gs-id")||"",x:f.x||0,y:f.y||0,w:f.w||1,h:f.h||1,locked:f.locked||!1,noResize:f.noResize||!1,noMove:f.noMove||!1,minW:f.minW,minH:f.minH,maxW:f.maxW,maxH:f.maxH}),c=async()=>{if(!a||!s.value)return;await(0,r.nextTick)();const f=a.engine.nodes;new Set(f.map(m=>m.id));const g=new Set(o.modelValue.map(m=>m.id));f.forEach(m=>{if(!g.has(m.id||"")){const E=m.el;E&&a&&a.removeWidget(E,!1)}}),o.modelValue.forEach(m=>{const E=f.find(S=>S.id===m.id);if(E)E.el&&a&&a.update(E.el,{x:m.x,y:m.y,w:m.w,h:m.h,locked:m.locked,noResize:m.noResize,noMove:m.noMove,minW:m.minW,minH:m.minH,maxW:m.maxW,maxH:m.maxH});else{if(!s.value||!a)return;const S=s.value.querySelector(`[gs-id="${m.id}"]`);S&&a.makeWidget(S)}})},u=()=>{a&&i("update:modelValue",a.save().map(f=>{const g={id:f.id||"",x:f.x||0,y:f.y||0,w:f.w||1,h:f.h||1},m=o.modelValue.find(E=>E.id===g.id);return m&&Object.keys(m).forEach(E=>{["id","x","y","w","h"].includes(E)||(g[E]=m[E])}),g}))},h=(0,r.computed)(()=>o.modelValue);return(0,r.watch)(()=>o.modelValue,async()=>{a&&(await(0,r.nextTick)(),c())},{deep:!0}),(0,r.watch)(()=>[o.column,o.cellHeight,o.draggable,o.resizable,o.disable,o.animate,o.float,o.removable],()=>{l()}),(0,r.onMounted)(()=>{l()}),(0,r.onBeforeUnmount)(()=>{a&&(a.destroy(!1),a=null)}),e({addItem:async f=>{if(a&&s.value){await(0,r.nextTick)();const g=s.value.querySelector(`[gs-id="${f.id}"]`);g&&(a.makeWidget(g),a.update(g,{x:f.x,y:f.y,w:f.w,h:f.h,locked:f.locked,noResize:f.noResize,noMove:f.noMove,minW:f.minW,minH:f.minH,maxW:f.maxW,maxH:f.maxH}))}},removeItem:f=>{if(a&&s.value){const g=s.value.querySelector(`[gs-id="${f}"]`);g&&a.removeWidget(g,!1)}},clear:()=>{a&&a.removeAll(!1)},getGrid:()=>a}),(f,g)=>((0,r.openBlock)(),(0,r.createElementBlock)("div",eh,[(0,r.createElementVNode)("div",{ref_key:"gridContainerRef",ref:s},[((0,r.openBlock)(!0),(0,r.createElementBlock)(r.Fragment,null,(0,r.renderList)(h.value,m=>((0,r.openBlock)(),(0,r.createElementBlock)("div",{key:m.id,"gs-id":m.id,"gs-x":m.x,"gs-y":m.y,"gs-w":m.w,"gs-h":m.h,"gs-locked":m.locked,"gs-no-resize":m.noResize,"gs-no-move":m.noMove,"gs-min-w":m.minW,"gs-min-h":m.minH,"gs-max-w":m.maxW,"gs-max-h":m.maxH,class:"d-layout-item"},[(0,r.renderSlot)(f.$slots,"item",{item:m})],8,th))),128))],512)]))}}),oh=nh,Mr=qe(oh),be=(t,e="",n=!1)=>n?`${t}pt`:e?`${t}${e}`:`${t}px`,xe=(t,e=0)=>t==null||isNaN(t)?0:Number(Number(t).toFixed(e)),ih=t=>t*3/4,rh=t=>t*4/3,sh=["onMousedown"],ah={key:2,class:"d-draggable__mask"},lh=(0,r.defineComponent)({name:"DDraggable",__name:"draggable",props:{index:{},mask:{type:Boolean,default:!0},scale:{default:1},readonly:{type:Boolean,default:!1},resize:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},step:{default:1},zIndex:{default:1},isActiveBgTransparent:{type:Boolean,default:!1},left:{default:0},top:{default:0},width:{},height:{},activeFlag:{type:Boolean,default:!1},isPt:{type:Boolean,default:!1}},emits:["focus","blur","over","out"],setup(t,{expose:e,emit:n}){const o=t,i=n,s=(0,r.ref)(),a=(0,r.ref)(),l=(0,r.ref)(0),d=(0,r.ref)(0),c=(0,r.ref)(0),u=(0,r.ref)(0),h=(0,r.ref)(null),f=(0,r.ref)(!1),g=(0,r.ref)(!1),m=(0,r.ref)(!1),E=(0,r.ref)(!1),S=(0,r.ref)([{classname:"left"},{classname:"right"},{classname:"top"},{classname:"bottom"},{classname:"top-left"},{classname:"top-right"},{classname:"bottom-left"},{classname:"bottom-right"}]),D=(0,r.computed)(()=>o.scale),B=(0,r.computed)(()=>({left:be(D.value,"",o.isPt)})),w=(0,r.computed)(()=>({left:be(-D.value,"",o.isPt)})),M=(0,r.computed)(()=>({left:"auto",right:be(-D.value,"",o.isPt)})),G=(0,r.computed)(()=>({top:be(-D.value,"",o.isPt)})),R=(0,r.computed)(()=>({top:"auto",bottom:be(-D.value,"",o.isPt)})),q=(0,r.computed)(()=>{const V=8*D.value;return{width:be(V,"",o.isPt),height:be(V,"",o.isPt)}}),K=(0,r.computed)(()=>({fontSize:be(16*D.value,"",o.isPt)})),j=(0,r.computed)(()=>Object.assign((()=>{if(E.value){const V={zIndex:9999,...B.value};return o.isActiveBgTransparent&&(E.value||g.value)&&!o.readonly&&!o.disabled&&(V.backgroundColor="color-mix(in srgb, var(--j-color-primary-bg) 60%, transparent)"),V}return{zIndex:o.zIndex}})(),{top:be(u.value,"",o.isPt),width:be(l.value,"",o.isPt),height:be(d.value,"",o.isPt),padding:be(8*D.value,"",o.isPt),...B.value,left:be(c.value,"",o.isPt)}));(0,r.watch)(()=>o.width,V=>{l.value=xe(F(V))||(h.value?.offsetWidth??0)}),(0,r.watch)(()=>o.height,V=>{d.value=xe(F(V))||(h.value?.offsetHeight??0)},{deep:!0}),(0,r.watch)(()=>o.left,V=>{c.value=xe(F(V))}),(0,r.watch)(()=>o.top,V=>{u.value=xe(F(V))}),(0,r.watch)(l,V=>{s.value&&(s.value.style.width=be(V,"",o.isPt),o.resize&&h.value?.style&&(h.value.style.width=be(V,"",o.isPt)))}),(0,r.watch)(d,V=>{s.value&&(s.value.style.height=be(V,"",o.isPt),o.resize&&h.value?.style&&(h.value.style.height=be(V,"",o.isPt)))}),(0,r.watch)(()=>o.activeFlag,V=>{Z(V)});const Z=V=>{E.value=V},F=V=>V===void 0?0:o.isPt?rh(V):V,k=()=>{a.value&&a.value.firstChild&&(h.value=a.value.firstChild,l.value=xe(F(o.width))||(h.value?.offsetWidth??0),d.value=xe(F(o.height))||(h.value?.offsetHeight??0),c.value=xe(F(o.left)),u.value=xe(F(o.top)),Z(o.activeFlag))},W=V=>{c.value=V},b=V=>{u.value=V},P=V=>{const X=8*D.value/2,A={};return V.split("-").forEach(U=>{A[U]=be(-X,"",o.isPt)}),A},v=V=>{g.value=V},N=V=>o.isPt?ih(V):V,I=()=>{f.value=!0,i("focus",{index:o.index,width:N(l.value),height:N(d.value),left:N(c.value),top:N(u.value)})},T=()=>{f.value=!1,m.value=!1,i("blur",{index:o.index,width:N(l.value),height:N(d.value),left:N(c.value),top:N(u.value)})},z=()=>{document.onmouseup=()=>{document.onmousemove=null,document.onmouseup=null,T()}},O=(V,X)=>{if(o.disabled||o.readonly)return;let A,U,te,ie,le,J;m.value=!0,I();let re=V.clientX,x=V.clientY;document.onmousemove=p=>{f.value=!0,X==="right"?(A=!0,U=!1):X==="left"?(A=!0,te=!0,le=!0,U=!1):X==="top"?(A=!1,U=!0,ie=!0,J=!0):X==="bottom"?(A=!1,U=!0):X==="bottom-right"?(A=!0,U=!0):X==="bottom-left"?(A=!0,U=!0,te=!0,le=!0):X==="top-right"?(A=!0,U=!0,ie=!0,J=!0):X==="top-left"&&(A=!0,U=!0,te=!0,le=!0,ie=!0,J=!0);const y=p.clientX-re,C=p.clientY-x;if(re=p.clientX,x=p.clientY,A){let _=y*o.step;le&&(_=-_),te&&(c.value=xe(c.value-_)),l.value=xe(l.value+_)}if(U){let _=C*o.step;J&&(_=-_),ie&&(u.value=xe(u.value-_)),d.value=xe(d.value+_)}},z()},L=()=>{g.value=!1,i("out",{index:o.index,width:N(l.value),height:N(d.value),left:N(c.value),top:N(u.value)})},ee=()=>{o.disabled||o.readonly||(g.value=!0,i("over",{index:o.index,width:N(l.value),height:N(d.value),left:N(c.value),top:N(u.value)}))},se=V=>{if(o.disabled||o.readonly)return;E.value=!0,I();let X=V.clientX,A=V.clientY;document.onmousemove=U=>{const te=U.clientX-X,ie=U.clientY-A;X=U.clientX,A=U.clientY,c.value=xe(c.value+te*o.step),u.value=xe(u.value+ie*o.step)},z()};return(0,r.onMounted)(()=>{k()}),e({setActive:Z,setLeft:W,setTop:b,setOverActive:v}),(V,X)=>((0,r.openBlock)(),(0,r.createElementBlock)("div",{class:(0,r.normalizeClass)(["d-draggable",{"d-draggable--active":(E.value||g.value)&&!t.readonly&&!t.disabled},{"d-draggable--pt":t.isPt&&!t.readonly&&!t.disabled},{"d-draggable--move":f.value},{"d-draggable--click":t.disabled}]),onMousedown:(0,r.withModifiers)(se,["stop"]),onMouseover:(0,r.withModifiers)(ee,["stop"]),onMouseout:(0,r.withModifiers)(L,["stop"]),style:(0,r.normalizeStyle)(j.value)},[(0,r.createElementVNode)("div",{class:"d-draggable__wrapper",ref_key:"wrapper",ref:s},[(E.value||g.value||f.value)&&!t.readonly&&!t.disabled?((0,r.openBlock)(),(0,r.createElementBlock)(r.Fragment,{key:0},[(0,r.createElementVNode)("div",{style:(0,r.normalizeStyle)({...B.value,...G.value}),class:"d-draggable__line d-draggable__line--left"},null,4),(0,r.createElementVNode)("div",{style:(0,r.normalizeStyle)({...B.value,...w.value}),class:"d-draggable__line d-draggable__line--top"},null,4),t.isPt?((0,r.openBlock)(),(0,r.createElementBlock)(r.Fragment,{key:1},[(0,r.createElementVNode)("div",{style:(0,r.normalizeStyle)({...B.value,...G.value,transform:"none"}),class:"d-draggable__line d-draggable__line--left"},null,4),(0,r.createElementVNode)("div",{style:(0,r.normalizeStyle)({...B.value,...w.value,transform:"none"}),class:"d-draggable__line d-draggable__line--top"},null,4),(0,r.createElementVNode)("div",{style:(0,r.normalizeStyle)({...B.value,...R.value}),class:"d-draggable__line d-draggable__line--left"},null,4),(0,r.createElementVNode)("div",{style:(0,r.normalizeStyle)({...B.value,...M.value}),class:"d-draggable__line d-draggable__line--top"},null,4),(0,r.createElementVNode)("div",{style:(0,r.normalizeStyle)({...B.value,...R.value,transform:"none"}),class:"d-draggable__line d-draggable__line--left"},null,4),(0,r.createElementVNode)("div",{style:(0,r.normalizeStyle)({...B.value,...M.value,transform:"none"}),class:"d-draggable__line d-draggable__line--top"},null,4)],64)):((0,r.openBlock)(),(0,r.createElementBlock)("div",{key:0,class:"d-draggable__line d-draggable__line--label",style:(0,r.normalizeStyle)(K.value)},(0,r.toDisplayString)(c.value)+","+(0,r.toDisplayString)(u.value),5))],64)):(0,r.createCommentVNode)("",!0),!t.readonly&&!t.disabled?((0,r.openBlock)(!0),(0,r.createElementBlock)(r.Fragment,{key:1},(0,r.renderList)(S.value,(A,U)=>((0,r.openBlock)(),(0,r.createElementBlock)(r.Fragment,{key:U},[E.value?((0,r.openBlock)(),(0,r.createElementBlock)("div",{key:0,class:(0,r.normalizeClass)(["d-draggable__range",`d-draggable__range--${A.classname}`]),style:(0,r.normalizeStyle)([q.value,P(A.classname)]),onMousedown:(0,r.withModifiers)(te=>O(te,A.classname),["stop"])},null,46,sh)):(0,r.createCommentVNode)("",!0)],64))),128)):(0,r.createCommentVNode)("",!0),(0,r.createElementVNode)("div",{class:"d-draggable__item",ref_key:"item",ref:a},[(0,r.renderSlot)(V.$slots,"default")],512),!t.disabled&&t.mask?((0,r.openBlock)(),(0,r.createElementBlock)("div",ah)):(0,r.createCommentVNode)("",!0)],512)],38))}}),ch=lh,Ir=qe(ch),dh=t=>{const e=uh(t.components);return{formConfig:t.form,componentList:e}},Br=(t,e)=>{let n={},o=[];const i={};if(t.ver==="V3"){const s=t;n=s.form;const a={};s.components.forEach(l=>{const d=e[l.type];a[l.containerId]=a[l.containerId]||[];const c={id:l.id,name:l.name,type:l.type,dragType:d?.dragType||"component",componentName:d?.componentName||"",runtimeType:d?.runtimeType,groupId:l.groupId,config:l.config,isInput:d?.isInput!==!1,containerId:l.containerId,level:l.level};d?.dragType==="container"&&(c.children=[]),i[c.id]=c,a[l.containerId].push(c)}),Object.keys(a).forEach(l=>{i[l]&&(i[l].children=a[l])}),o=a.form||[]}return{formConfig:n,componentList:o,componentDic:i}},bo=(t,e)=>{const n={ver:"V3",form:{...t},components:[],db:{}};return zr(e||[],n.components),n},zr=(t,e)=>{t.forEach(n=>{if(n.type==="pkey")return;const o={id:n.id,name:n.name,type:n.type,runtimeType:n.runtimeType||n.componentName||n.type,groupId:n.groupId||"",config:n.config,containerId:n.containerId,level:n.level};n.dragType==="container"&&zr(n.children||[],e),e.push(o)})},uh=t=>{const e={},n={};return t.forEach(o=>{e[o.containerId]=e[o.containerId]||[];const i={id:o.id,type:o.runtimeType,slot:o.groupId,config:{rule:[]}};o.config&&Object.keys(o.config).forEach(s=>{if(s==="required"){o.config.required&&i.config?.rule?.push({required:!0,message:o.config.requiredMsg||"请输入"});return}if(s==="patterns"){o.config.patterns.forEach(a=>{a.reg&&a.msg&&i.config?.rule?.push({pattern:new RegExp(a.reg),message:`请输入${a.msg||""}`})});return}i.config[s]=o.config[s]}),o.type==="pkey"&&(i.config.isPkey=!0),e[o.containerId].push(i),n[o.id]=i}),Object.keys(e).forEach(o=>{const i=n[o];if(i){const s=e[o];if(["j-tabs","j-collapse"].includes(i.type||"")&&i.config?.groups){const a={};s.forEach(l=>{if(l.slot!==void 0&&l.slot!==null){const d=l.slot.toString();a[d]||(a[d]=[]),delete l.slot,a[d].push(l)}}),i.children=i.config.groups.map(l=>{const d=a[l._i]||[],c={label:l.label};l.active&&i.type==="j-collapse"&&(c.active=l.active);let u;if(i.type==="j-tabs"&&i.config?.tabKey&&i.config?.options.length>0){const f=i.config.options.find(g=>g.label===l._i);f&&(u=({formData:g})=>({display:f.value.includes(g[i.config?.tabKey||""])?f.display:!f.display}))}const h={config:c,children:d};return u&&(h.getCompConfig=u),h}),delete i.config.groups}else i.children=s}}),e.form},Rr=(t,e,n,o,i,s,a,l)=>{const d=(0,r.ref)(),c=(0,r.reactive)({}),u=(0,r.computed)(()=>{const v=[];return Object.keys(c).forEach(N=>{const I=c[N];I.dragType==="component"&&I.type!=="pkey"&&v.push(I)}),v}),h=(v=[],N)=>{const I=e?.value?.init;typeof I=="function"&&I(v,N)},f=v=>i?i(v,{componentDic:c,components:u.value,configData:d.value.config}):{},g=(v,N)=>{if(d.value?.id===v)return;const I=c[v]||N;if(I?d.value=I:v===n.id?d.value=n:d.value=null,d.value){const T=s[d.value.type];T?(h(T,d.value.config),f(d.value.type)):h([])}else h([]);N&&ye("dragClick",{id:N.id})},m=()=>t.value.$el.getBoundingClientRect(),E=v=>v===n.id?n:c[v]||{},S=v=>{const N=[];if(v===n.id)N.push({id:v,name:n.name});else{const I=c[v];if(I){N.push({id:v,name:I.name});const T=S(I.containerId);N.push(...T)}}return N},D=(v,N)=>{const I=c[N];if(I===void 0)return!1;const T=I.containerId;return v===T?!0:T===n.id?!1:D(v,T)},B=v=>o?o(v)||{}:{},w=(v,N,I,T)=>{if(l){const z=E(v);return l(I.componentType,{container:z,groupId:N,configData:I},T)}return!1},M=({name:v,type:N,dragType:I,isInput:T,componentName:z,runtimeType:O},L,ee,se,V=!1)=>{const X=B(N);if(X.id=rt(),X.span=24,X.componentType=N,G(L,X.componentType))return;w(L,se,X,!0);const A={id:X.id,name:v,type:N,runtimeType:O,componentName:z||"",dragType:I||"component",containerId:L,isInput:!!T,level:c[L]?c[L].level+1:1,config:X,isNewAdd:!V,groupId:se};return A.dragType==="container"&&(A.children=[]),c[A.id]=A,E(L).children?.splice(ee,0,A),A},G=(v,N)=>!!(E(v).config.componentType==="gridtable"&&["divider","label","text","textEditor","viewTable","card","collapse","tabs","qrcode","barcode","tableLayout"].includes(N)),R=(v,N,I=!1)=>{let T=null;const z=E(v).children,O=z?.findIndex(L=>L.id===N)||0;if(I&&z&&z.length>1){let L=O+1;O>0&&(L=O-1),T=z[L]}return z?.splice(O,1),T?.id},q=(v,N,I,T)=>{const z=E(N).children,O=v.containerId!==N;v.containerId=N,v.groupId=T,z?.splice(I,0,v),w(N,T,v.config,O)&&(W(),g(v.id))},K=v=>{let N="";const I=E(v);return I&&(I.children&&I.children.length>0&&I.children.forEach(T=>{K(T.id)}),N=R(I.containerId,v,!0)||"",delete c[v]),d.value&&d.value.id===v&&(d.value=null,e.value.init([])),N},j=(v,N=[])=>{const I=E(v);if(I&&I.children&&I.children.length>0){const T=[];I.children.forEach(z=>{z.groupId&&N.includes(z.groupId)&&T.push(z.id)}),T.forEach(z=>{K(z),delete c[z]})}},Z=(v,N)=>{const I=E(v);I&&(I.children&&I.children.length>0&&I.children.forEach(T=>{T.groupId===N&&K(T.id)}),delete c[v])},F=v=>{const N=Sn(E(v));N.id=rt(),N.config.id=N.id,c[N.id]=N;const I=E(N.containerId).children,T=I?.findIndex(z=>z.id===v)||0;I?.splice(T+1,0,N)},k=()=>{n.children=[],Wr(c),d.value&&(ye("dragClick",{id:""}),d.value=null,e.value.init([]))},W=()=>{d.value&&(ye("dragClick",{id:""}),d.value=null,e.value.init([]))},b=v=>{const N=d.value,I=E(N.containerId).children,T=I?.findIndex(z=>z.id===N.id)||0;K(N.id),(0,r.nextTick)(()=>{const z=a[v],O=B(v);O.id=N.id,O.span=N.config.span,O.componentType=v,O.table=N.config.table,O.field=N.config.field,N.config.isSubTable&&(O.isSubTable=N.config.isSubTable);const L={id:O.id,name:z.name,type:v,runtimeType:z.runtimeType,componentName:z.componentName||"",dragType:N.dragType,groupId:N.groupId,containerId:N.containerId,isInput:N.isInput,level:N.level,config:O,isNewAdd:!0};c[L.id]=L,I?.splice(T,0,L)})},P=v=>{ye("dragAddByClick",v)};return(0,r.provide)("d-drag-design-provide",{activedComponent:d,getDesignLocals:m,getComponent:E,getParentComponents:S,isMyChildComponent:D,selectComponent:g,addComponent:M,deleteComponent:K,copyComponent:F,removeComponentFromContainer:R,addComponentToContainer:q,top:n,deleteChildren:Z,deleteChildrens:j}),{activedComponent:d,clearComponents:k,changeComponent:b,schemaComponentDic:c,clearSelect:W,addComponent:M,addComponentByTable:P,designComponentList:u}},fh=(0,r.defineComponent)({__name:"importComponent",props:{componentList:{type:Array,default:()=>[]},tableList:{type:Array,default:()=>[]}},setup(t,{expose:e}){const n=t,o=(0,r.computed)(()=>n.tableList.map(c=>({label:c.comment?`${c.name}(${c.comment})`:c.name,value:c.name}))),i=(0,r.ref)(),s=[{id:"layout",type:"j-layout",config:{top:48,topMove:!1,autoSize:["default"]},children:[{id:"table",type:"j-select",slot:"top",config:{label:"表名选择",loadOptions:()=>o,allowClear:!1}},{id:"fields",type:"j-table",config:{editConfig:{isAddBtn:!1,isRemoveBtn:!1},height:"100%",isMultiple:!0},children:[{id:"name",type:"span",config:{label:"字段名"}},{id:"type",type:"j-select",config:{label:"组件选择",options:n.componentList,width:200}}]}]}],a=(c,u)=>{if(c.id==="table"){const h=n.tableList.find(f=>f.name===u.value);if(h){const f=h.columns.map(g=>({value:g.name,name:g.coment?`${g.name}(${g.coment})`:g.name,type:"input",label:g.coment||g.name,selected:!g.isPrimary}));i.value.setFormData({fields:f})}}};return(0,r.onMounted)(()=>{i.value.init(s)}),e({ok:()=>{const c=i.value.getFormData(!1);return{addList:c.fields.filter(u=>u.selected),table:c.table,containerId:c.containerId,isSubTable:c.isSubTable}},closed:()=>{}}),(c,u)=>{const h=(0,r.resolveComponent)("j-form");return(0,r.openBlock)(),(0,r.createBlock)(h,{ref_key:"formRef",ref:i,"form-config":{labelWidth:"72px"},onChange:a},null,512)}}}),hh=fh,gh=(0,r.defineComponent)({props:{componentData:{type:Object,default:()=>({})},globalConfig:{type:Object,default:()=>({})}},setup(t){const{t:e}=(0,Ke.useAppInject)();return{labelWidth:(0,r.computed)(()=>t.componentData.config?.notShowLabel?"0px":t.componentData.config?.labelWidth===void 0&&t.globalConfig.labelWidth!==void 0?`${t.globalConfig.labelWidth}px`:t.componentData.config?.labelWidth?`${t.componentData.config?.labelWidth}px`:void 0),inputConfig:(0,r.computed)(()=>{const n={...t.componentData?.config};return t.globalConfig.size===void 0&&(n.size=t.globalConfig.size),n.display=!0,n}),t:e}}}),ph=(t,e)=>{const n=t.__vccOpts||t;for(const[o,i]of e)n[o]=i;return n};function mh(t,e,n,o,i,s){const a=(0,r.resolveComponent)("j-comp"),l=(0,r.resolveComponent)("el-form-item");return t.componentData.isInput?((0,r.openBlock)(),(0,r.createBlock)(l,{key:0,"label-width":t.labelWidth,label:t.t(t.componentData.config?.notShowLabel?"":t.componentData.config?.label||""),rules:t.componentData.config?.required?[{required:!0,message:""}]:[]},{default:(0,r.withCtx)(()=>[(0,r.createVNode)(a,{type:t.componentData?.componentName||t.componentData?.type,config:t.inputConfig,modelValue:t.componentData?.config.defaultValue},null,8,["type","config","modelValue"])]),_:1},8,["label-width","label","rules"])):t.componentData?.children?((0,r.openBlock)(),(0,r.createBlock)((0,r.resolveDynamicComponent)(t.componentData?.componentName),(0,r.mergeProps)({key:1},t.componentData?.config,{"global-config":t.globalConfig,"component-data":t.componentData}),null,16,["global-config","component-data"])):((0,r.openBlock)(),(0,r.createBlock)((0,r.resolveDynamicComponent)(t.componentData?.componentName),(0,r.normalizeProps)((0,r.mergeProps)({key:2},t.componentData?.config)),null,16))}var Ar=ph(gh,[["render",mh]]),yh={class:"d-form-design j-block"},vh={class:"d-form-design-left"},_h={class:"d-form-design-component-list"},wh={class:"j-component-tool"},bh={class:"j-component-tool-name"},Ch={class:"d-form-design-center"},Eh={class:"d-form-design-container"},xh={key:0,class:"d-form-design-empty"},Nh={class:"d-form-design-right"},kh={class:"d-form-design-panel-title"},Sh={style:{margin:"0","font-size":"14px"}},Dh={class:"d-form-design-panel"},Th=(0,r.defineComponent)({name:"DFormDesign",__name:"formDesign",props:{notBindTable:{type:Boolean,default:!1},components:{default:()=>[]},componentConfigs:{default:()=>({})},componentInit:{type:Function,default:void 0},containerAddComponent:{type:Function,default:void 0},componentConfigInit:{type:Function,default:void 0},componentConfigChange:{type:Function,default:void 0},componentConfigValidate:{type:Function,default:void 0},flowComponents:{default:()=>[]},flowInit:{type:Function,default:void 0},flowComponentConfigInit:{type:Function,default:void 0},flowComponentConfigChange:{type:Function,default:void 0},flowComponentConfigs:{default:()=>({})},actions:{}},setup(t,{expose:e}){const n=t,{t:o,warning:i,error:s}=(0,Ke.useAppInject)(),a=(0,r.reactive)({name:"表单",id:"form",type:"form",level:0,children:[],dragType:"container",componentName:"",containerId:"",isInput:!1,config:{}}),l=(0,r.ref)([]),d=n.components.length;for(let p=0;p<d;p++)l.value.push(p);n.componentInit&&(a.config=n.componentInit("form")||{});const c=(0,r.ref)([]),u=(0,r.computed)(()=>c.value.map(p=>({label:p.comment?`${p.name}(${p.comment})`:p.name,value:p.name}))),h=(0,r.computed)(()=>{if(R.value){const p=G.value.getFormData(!1);if(p.table){const y=c.value.find(C=>C.name===p.table);if(y)return y.columns.map(C=>({value:C.name,label:C.coment?`${C.name}(${C.coment})`:C.name,coment:C.coment}))}}return[]}),f=p=>{c.value=p},g={},m=[];n.components.forEach(({children:p})=>{p.forEach(y=>{g[y.type]=y,y.dragType=y.dragType||"component",y.isInput!==!1&&(y.isInput=!0,m.push({label:y.name,value:y.type}))})});const E=p=>{p.forEach(y=>{y.type==="d-input-flow"&&(y.config=y.config||{},y.config.flowComponents=n.flowComponents,y.config.flowInit=n.flowInit,y.config.flowComponentConfigInit=C=>{n.flowComponentConfigInit&&(C.designComponents=F.value,C.component=R.value,n.flowComponentConfigInit(C))},y.config.flowComponentConfigs=n.flowComponentConfigs,y.config.flowComponentConfigChange=n.flowComponentConfigChange),y.children&&E(y.children)})},S={};Object.keys(n.componentConfigs||{}).forEach(p=>{const{hasBase:y,isInput:C,hasTwoPlaceholder:_,hasPlaceholder:Y,hasSpan:H,hasLabel:oe,bindTable:Q,labelTitle:ue}=g[p]||{hasBase:!1},fe=[{id:"id",type:"j-input",config:{label:"ID",readonly:!0}},{id:"componentType",type:"j-select",config:{label:"类型",allowClear:!1,display:C,options:m}},{id:"label",type:"j-input",config:{label:ue||"标题"},getCompConfig:({formData:he})=>({display:oe!==!1&&!he.notShowLabel})},{id:"notShowLabel",type:"j-switch",config:{label:"不显示"+(ue||"标题"),activeValue:!0,inactiveValue:!1},getCompConfig:({formData:he})=>({display:oe!==!1&&!he.isSubTable})},{id:"labelWidth",type:"j-number",config:{label:"标题宽度"},getCompConfig:({formData:he})=>({display:C&&!he.notShowLabel&&!he.isSubTable})},{id:"placeholder",type:"j-input",config:{display:C&&!_&&Y!==!1,label:"占位提示"}},{id:"startPlaceholder",type:"j-input",config:{display:!!_,label:"开始占位"}},{id:"endPlaceholder",type:"j-input",config:{display:!!_,label:"结束占位"}},{id:"span",type:"j-slider",config:{label:"表单栅栏",min:6,max:24,showTooltip:!0,step:6,showStops:!0,defautValue:24},getCompConfig:({formData:he})=>({display:H!==!1&&!he.isSubTable})},{id:"width",type:"j-number",config:{label:"单元格宽度",min:1},getCompConfig:({formData:he})=>({display:!!he.isSubTable})},{id:"isNotSave",type:"j-switch",config:{label:"不存表",display:C&&Q!==!1,activeValue:!0,inactiveValue:!1}},{id:"table",type:"j-select",config:{label:"数据表",loadOptions:()=>u},getCompConfig:({formData:he})=>({display:(C&&Q!==!1||Q===!0)&&(!he.isSubTable||Q===!0)&&!he.isNotSave&&!n.notBindTable})},{id:"field",type:"j-select",config:{label:"表字段",loadOptions:()=>h},getCompConfig:({formData:he})=>({display:C&&Q!==!1&&!he.isNotSave&&!n.notBindTable})},{id:"csType",type:"j-select",config:{label:"字段类型",allowClear:!1,options:[{label:"短文本",value:"string"},{label:"长文本",value:"text"},{label:"整数",value:"int"},{label:"小数",value:"decimal"},{label:"时间日期",value:"DateTime"}]},getCompConfig:({formData:he})=>({display:C&&Q!==!1&&!he.isNotSave&&n.notBindTable})},{id:"fieldLen",type:"j-number",config:{label:"字段长度"},getCompConfig:({formData:he})=>({display:C&&Q!==!1&&!he.isNotSave&&n.notBindTable&&he.csType==="string"})}],ge={type:"j-collapse",config:{defaultValue:[]},children:[]};y!==!1&&(ge.children?.push({config:{label:"基础信息"},children:[...fe]}),ge.config?.defaultValue.push("_collapse0")),ge.children?.push(...n.componentConfigs[p]),E(ge.children||[]),S[p]=[ge]});const D=p=>{const{value:y}=p||{};p.id==="componentType"&&K(y),R.value&&n.componentConfigChange&&(p.id==="field"&&p.data?.coment&&(R.value.config.label=p.data?.coment),n.componentConfigChange(R.value.type,{configRef:G,configData:R.value.config,...p})),p.id==="table"&&R.value&&R.value.type==="gridtable"&&(R.value.children||[]).forEach(C=>{C.isInput&&(C.config.table=y)})},B=(p,y)=>{g[p]?.isInput&&(n.notBindTable&&(y.configData.csType||G.value.setFormData({main:{csType:g[p]?.csType,fieldLen:g[p]?.fieldLen}})),u.value.length===1&&G.value.setFormData({main:{table:u.value[0].value}})),n.componentConfigInit&&n.componentConfigInit(p,{configRef:G,...y,notBindTable:n.notBindTable})},w=(p,y,C)=>{let _=!1;const Y=g[p];return y.container.type==="gridtable"?(!y.configData.isSubTable||C)&&(y.configData.isSubTable=!0,Y.isInput&&(y.configData.table=y.container.config.table,y.configData.field=""),_=!0):y.configData.isSubTable&&(_=!0,y.configData.isSubTable=!1,Y.isInput&&(y.configData.table="")),n.containerAddComponent&&n.containerAddComponent(p,y),_},M=(0,r.ref)(),G=(0,r.ref)(),{activedComponent:R,clearComponents:q,changeComponent:K,schemaComponentDic:j,addComponentByTable:Z,designComponentList:F}=Rr(M,G,a,n.componentInit,B,S,g,w),k=(0,r.computed)(()=>R.value?`【${R.value.name}】`:"");(0,r.provide)("dui-design-provide",{designItemName:Ar});const W=()=>{n.componentInit&&(a.config=n.componentInit("form")||{}),q()},b=()=>{let p=0;const y=bo(a.config,a.children||[]);if(n.notBindTable){const C={};y.components.forEach(H=>{const{isInput:oe,bindTable:Q}=g[H.type]||{hasBase:!1};oe&&Q!==!1?H.config.table&&!C.main&&(C.main={name:H.config.table,comment:"主表",type:"main",pKey:"J_Id"}):Q&&(C[H.id]={name:H.config.table||"t"+new Date().getTime()+p,comment:`子表${H.config.label}`,type:"chlid",field:"J_PId",relationField:"J_Id",pKey:"J_Id"},H.config.table=C[H.id].name,p++)}),C.main||(C.main={name:"t"+new Date().getTime()+p,comment:"主表",type:"main",pKey:"J_Id"},p++);let _=0;y.components.forEach(H=>{const{isInput:oe,bindTable:Q}=g[H.type]||{hasBase:!1};!H.config.isNotSave&&oe&&Q!==!1&&(H.config.csType||(H.config.csType=g[H.type]?.csType,H.config.fieldLen=g[H.type]?.fieldLen),H.config.isSubTable?H.config.table=C[H.containerId].name:H.config.table=C.main.name,H.config.field=H.config.field||`f${Math.floor(Date.now()/1e3)}${_}`,_++)});const Y=[];Object.keys(C).forEach(H=>{C[H].type==="chlid"&&(C[H].relationName=C.main.name,C[H].comment+=`,关联主表${C.main.name}`),Y.push(C[H])}),y.db=Y}else{const C={};c.value.forEach(_=>{_.columns.forEach(Y=>{C[`${_.name}_${Y.name}`]=Y.csType})}),y.components.forEach(_=>{_.config.table&&_.config.field&&(_.config.csType=C[`${_.config.table}_${_.config.field}`])})}return n.notBindTable?y.db.forEach(C=>{if(!y.components.find(_=>_.config.table===C.name&&_.config.field==="J_Id")){const _=y.components.find(Y=>Y.config.table===C.name&&Y.config.field);_&&y.components.push({id:C.name+"_J_Id",name:C.name+"_J_Id",type:"pkey",runtimeType:"j-input",groupId:"",config:{display:!1,table:C.name,field:"J_Id",label:"主键"},containerId:_.containerId,level:_.level})}}):c.value.forEach(C=>{C.columns.forEach(_=>{if(_.isPrimary&&!y.components.find(Y=>Y.config.table===C.name&&Y.config.field===_.name)){const Y=y.components.find(H=>H.config.table===C.name&&H.config.field);Y&&y.components.push({id:C.name+"_"+_.name,name:C.name+"_"+_.name,type:"pkey",runtimeType:"j-input",groupId:"",config:{display:!1,table:C.name,field:_.name,label:"主键"+_.name,isIdentity:_.isIdentity},containerId:Y.containerId,level:Y.level})}})}),y},P=p=>{const y=Br(p,g);a.config=y.formConfig,a.children?.push(...y.componentList),Object.keys(y.componentDic).forEach(C=>{j[C]=y.componentDic[C]})},v=()=>I(bo(a.config,a.children||[]).components,{},{}),N=p=>{const{isInput:y,bindTable:C}=g[p]||{hasBase:!1};if(!y&&C)return!0},I=(p,y,C)=>{if(!n.notBindTable)for(const _ of p){const{isInput:Y,bindTable:H}=g[_.type]||{hasBase:!1};if(!_.config.isNotSave&&_.type!=="pkey"){if(Y&&H!==!1){if((0,Ke.isNullOrEmpty)(_.config.table))return s&&s(`请【${_.config.label}】绑定数据表!`),!1;if(!_.config.isSubTable){if(C[_.config.table]&&N(C[_.config.table].type))return s&&s(`【${_.config.label}】和【${C[_.config.table].config.label}】重复绑定【${_.config.table}】表!`),!1;_.config.table&&(C[_.config.table]=_)}}else if(H){if((0,Ke.isNullOrEmpty)(_.config.table))return s&&s(`【${_.config.label}】请绑定数据表!`),!1;if(C[_.config.table])return s&&s(`【${_.config.label}】和【${C[_.config.table].config.label}】重复绑定【${_.config.table}】表!`),!1;_.config.table&&(C[_.config.table]=_)}}}for(const _ of p){if(!n.notBindTable){const{isInput:Y,bindTable:H}=g[_.type]||{hasBase:!1};if(!_.config.isNotSave&&Y&&H!==!1){if((0,Ke.isNullOrEmpty)(_.config.field))return s&&s(`请【${_.config.label}】绑定表字段!`),!1;if(y[`${_.config.table}-${_.config.field}`])return s&&s(`【${_.config.label}】和【${y[`${_.config.table}-${_.config.field}`].config.label}】重复绑定【${_.config.field}】字段!`),!1;y[`${_.config.table}-${_.config.field}`]=_}}if(n.componentConfigValidate&&!n.componentConfigValidate(_.type,{configData:_.config,errorTip:s}))return!1}return!0},T=(0,r.ref)(),z=(0,r.ref)(),O=(0,r.reactive)({width:0,height:0,formConfig:{}});let L=0;const ee=p=>{if(z.value)L=0,z.value.init(p||[]);else{if(L>600){console.warn("表单组件加载超时");return}L++,setTimeout(()=>{ee(p)},100)}},se=()=>{},V=()=>{},X=(0,r.ref)(),A=(0,r.ref)(),U=()=>{const{addList:p,table:y}=A.value?.ok()||{addList:[]};if(p.length<=0)i&&i("请选择字段!");else{if(R.value?.config.componentType==="gridtable"||R.value?.config.isSubTable)if(R.value.config.table){if(R.value.config.table!==y){i&&i("请设置相同的表和子表!");return}}else{let C=R.value;R.value.config.isSubTable&&(C=j[R.value.containerId]),C.config.table=y,(C.children||[]).forEach(_=>{_.isInput&&(_.config.table=y)}),G.value.setFormData({main:{table:y}})}p.forEach(C=>{const _=(0,Ke.deepClone)(g[C.type]);_.config={table:y,field:C.value,label:C.label},Z(_)}),X.value.close()}},te=()=>{A.value?.closed()};return e({setTables:p=>{f(p)},getSchema:()=>b(),setSchema:p=>P(p),reset:()=>W(),validate:()=>v()}),(p,y)=>{const C=(0,r.resolveComponent)("j-icon"),_=(0,r.resolveComponent)("d-drag-tool"),Y=(0,r.resolveComponent)("el-collapse-item"),H=(0,r.resolveComponent)("el-collapse"),oe=(0,r.resolveComponent)("d-drag-form-list"),Q=(0,r.resolveComponent)("el-row"),ue=(0,r.resolveComponent)("d-drag-container"),fe=(0,r.resolveComponent)("j-form"),ge=(0,r.resolveComponent)("j-layer");return(0,r.openBlock)(),(0,r.createElementBlock)("div",yh,[(0,r.createElementVNode)("div",vh,[(0,r.createElementVNode)("div",_h,[(0,r.createVNode)(H,{modelValue:l.value,"onUpdate:modelValue":y[0]||(y[0]=he=>l.value=he)},{default:(0,r.withCtx)(()=>[((0,r.openBlock)(!0),(0,r.createElementBlock)(r.Fragment,null,(0,r.renderList)(t.components,(he,Ze)=>((0,r.openBlock)(),(0,r.createBlock)(Y,{key:Ze,title:he.name,name:Ze},{default:(0,r.withCtx)(()=>[((0,r.openBlock)(!0),(0,r.createElementBlock)(r.Fragment,null,(0,r.renderList)(he.children,(Vt,Qh)=>((0,r.openBlock)(),(0,r.createBlock)(_,{key:Qh,config:Vt},{default:(0,r.withCtx)(()=>[(0,r.createElementVNode)("div",wh,[(0,r.createVNode)(C,{class:"j-component-tool-icon",icon:Vt.icon,size:14},null,8,["icon"]),(0,r.createElementVNode)("div",bh,(0,r.toDisplayString)((0,r.unref)(o)(Vt.name)),1)])]),_:2},1032,["config"]))),128))]),_:2},1032,["title","name"]))),128))]),_:1},8,["modelValue"])])]),(0,r.createElementVNode)("div",Ch,[(0,r.createElementVNode)("div",Eh,[(0,r.createVNode)(ue,{ref_key:"dragContainer",ref:M,class:"d-form-design-drag-container","is-component-container":!1,"component-data":a},{default:(0,r.withCtx)(()=>[!a.children||a.children.length===0?((0,r.openBlock)(),(0,r.createElementBlock)("div",xh,[...y[1]||(y[1]=[(0,r.createElementVNode)("div",null,"请从左侧拖拽组件到此处",-1)])])):((0,r.openBlock)(),(0,r.createBlock)(Q,{key:1},{default:(0,r.withCtx)(()=>[(0,r.createVNode)(oe,{"component-list":a.children,"global-config":a.config},null,8,["component-list","global-config"])]),_:1}))]),_:1},8,["component-data"])])]),(0,r.withDirectives)((0,r.createElementVNode)("div",Nh,[(0,r.createElementVNode)("div",kh,[(0,r.createElementVNode)("span",Sh,(0,r.toDisplayString)(`${(0,r.unref)(o)("属性配置")}${k.value}`),1)]),(0,r.createElementVNode)("div",Dh,[(0,r.createVNode)(fe,{config:{labelPosition:"top",size:"small"},collapseAnimate:!1,style:{padding:"0"},ref_key:"configRef",ref:G,onChange:D},null,512)])],512),[[r.vShow,(0,r.unref)(R)]]),(0,r.createVNode)(ge,{ref_key:"previewFormLayerRef",ref:T,width:O.width,height:O.height,onOk:se,onClosed:V},{default:(0,r.withCtx)(()=>[(0,r.createVNode)(fe,{config:O.formConfig,"is-preview":!0,ref_key:"previewFormRef",ref:z,actions:t.actions},null,8,["config","actions"])]),_:1},8,["width","height"]),(0,r.createVNode)(ge,{ref_key:"importFormLayerRef",ref:X,width:800,height:600,"btn-text":"确认",onOk:U,onClosed:te},{default:(0,r.withCtx)(()=>[(0,r.createVNode)(hh,{"component-list":m,"table-list":c.value,ref_key:"importComponentRef",ref:A},null,8,["table-list"])]),_:1},512)])}}}),Mh=Th,$r=qe(Mh,[Ar]),Pr=(t,e)=>{const n={ver:"V3",indexPage:{...t},components:[]};return Or(e||[],n.components),n},Or=(t,e)=>{t.forEach(n=>{const o={id:n.id,name:n.name,type:n.type,runtimeType:n.runtimeType||n.componentName||n.type,groupId:n.groupId||"",config:n.config,containerId:n.containerId,level:n.level};n.dragType==="container"&&Or(n.children||[],e),e.push(o)})},Ih=t=>{const e=Bh(t.components);return{pageConfig:t.indexPage,componentList:e}},Bh=t=>{const e={},n={};return t.forEach(o=>{e[o.containerId]=e[o.containerId]||[];const i={id:o.id,type:o.runtimeType,slot:o.groupId,config:{}};o.config&&Object.keys(o.config).forEach(s=>{i.config[s]=o.config[s]}),e[o.containerId].push(i),n[o.id]=i}),Object.keys(e).forEach(o=>{const i=n[o];if(i){const s=e[o];if(["j-tabs","j-collapse"].includes(i.type||"")&&i.config?.groups){const a={};s.forEach(l=>{if(l.slot!==void 0&&l.slot!==null){const d=l.slot.toString();a[d]||(a[d]=[]),delete l.slot,a[d].push(l)}}),i.children=i.config.groups.map(l=>{const d=a[l._i]||[];return{config:{label:l.label},children:d}}),delete i.config.groups}else i.children=s}}),e.indexPage||[]},zh=(t,e)=>{let n={},o=[];const i={};if(t.ver==="V3"){const s=t;n=s.indexPage;const a={};s.components.forEach(l=>{const d=e[l.type];if(!d)return;a[l.containerId]=a[l.containerId]||[];const c={id:l.id,name:l.name,type:l.type,dragType:d.dragType||"component",componentName:d.componentName||"",runtimeType:d.runtimeType,groupId:l.groupId,config:l.config,isInput:!1,containerId:l.containerId,level:l.level};i[c.id]=c,a[l.containerId].push(c),c.dragType==="container"&&(c.children=[])}),Object.keys(a).forEach(l=>{i[l]&&(i[l].children=a[l])}),o=a.indexPage||[]}return{pageConfig:n,componentList:o,componentDic:i}},Rh=(0,r.defineComponent)({name:"DIndexDesignItem",__name:"indexDesignItem",props:{componentData:{type:Object,default:()=>({})},globalConfig:{type:Object,default:()=>({})}},setup(t){return(e,n)=>((0,r.openBlock)(),(0,r.createBlock)((0,r.resolveDynamicComponent)(t.componentData?.componentName),(0,r.mergeProps)(t.componentData?.config,{"global-config":t.globalConfig,"component-data":t.componentData}),null,16,["global-config","component-data"]))}}),Vr=Rh,Ah={class:"d-index-design j-block"},$h={class:"d-index-design-left"},Ph={class:"j-component-list"},Oh={class:"j-component-tool"},Vh={class:"j-component-tool-name"},Hh={class:"d-index-design-center"},Lh={class:"design-toolbar"},Fh={class:"design-container"},Gh={key:0,class:"j-block design-empty"},Wh={class:"d-index-design-right"},Uh={class:"d-index-design-panel-title"},Yh={style:{margin:"0","font-size":"14px"}},Xh={class:"d-index-design-panel"},jh=(0,r.defineComponent)({name:"DIndexDesign",__name:"indexDesign",props:{components:{type:Array,default:()=>[]},componentConfigs:{type:Object,default:()=>({})},componentInit:Function,containerAddComponent:Function,componentConfigInit:Function,componentConfigChange:Function,flowComponents:{type:Array,default:()=>[]},flowInit:Function,flowComponentConfigInit:Function,flowComponentConfigChange:Function,flowComponentConfigs:{type:Object,default:()=>({})}},setup(t,{expose:e}){const{t:n}=(0,Ke.useAppInject)(),o=t,i=v=>{v.forEach(N=>{N.type==="d-input-flow"&&(N.config=N.config||{},N.config.flowComponents=o.flowComponents,N.config.flowInit=o.flowInit,N.config.flowComponentConfigInit=I=>{o.flowComponentConfigInit&&(I.designComponents=S.value,I.component=g.value,o.flowComponentConfigInit(I))},N.config.flowComponentConfigs=o.flowComponentConfigs,N.config.flowComponentConfigChange=o.flowComponentConfigChange),N.children&&i(N.children)})},s=(0,r.reactive)({name:"页面",id:"indexPage",type:"indexPage",level:0,children:[],dragType:"container",componentName:"",containerId:"",isInput:!1,config:{}});o.componentInit&&(s.config=o.componentInit("indexPage")||{});const a={},l=[];o.components.forEach(({children:v})=>{v.forEach(N=>{a[N.type]=N,N.dragType=N.dragType||"component",l.push({label:N.name,value:N.type})})});const d={};Object.keys(o.componentConfigs).forEach(v=>{const{hasBase:N}=a[v]||{hasBase:!1},I=[{id:"id",type:"j-input",config:{label:"ID",readonly:!0}},{id:"label",type:"j-input",config:{label:"名称"}}],T={type:"j-collapse",config:{defaultValue:[]},children:[]};N!==!1&&(T.children?.push({config:{label:"基础信息"},children:[...I]}),T.config?.defaultValue.push("_collapse0")),T.children?.push(...o.componentConfigs[v]),i(T.children||[]),d[v]=[T]});const c=v=>{g.value&&o.componentConfigChange&&o.componentConfigChange(g.value.type,{configRef:f,configData:g.value.config,...v})},u=(v,N)=>{o.componentConfigInit&&o.componentConfigInit(v,{configRef:f,...N})},h=(0,r.ref)(),f=(0,r.ref)(),{activedComponent:g,clearComponents:m,schemaComponentDic:E,designComponentList:S}=Rr(h,f,s,o.componentInit,u,d,a,o.containerAddComponent),D=(0,r.computed)(()=>g.value?`【${g.value.name}】`:""),B=(0,r.ref)([]),w=o.components.length;for(let v=0;v<w;v++)B.value.push(v);(0,r.provide)("dui-design-provide",{designItemName:Vr});const M=()=>{m()},G=()=>{o.componentInit&&(s.config=o.componentInit("indexPage")||{}),m()},R=()=>(console.log("pValidate"),!0),q=()=>Pr(s.config,s.children||[]),K=v=>{const N=zh(v,a);s.config=N.pageConfig,s.children?.push(...N.componentList),Object.keys(N.componentDic).forEach(I=>{E[I]=N.componentDic[I]})},j=(0,r.ref)(),Z=(0,r.ref)();(0,r.ref)(""),(0,r.reactive)({formConfig:{}});let F=0;const k=v=>{if(Z.value)F=0,Z.value.init(v);else{if(F>600){console.warn("组件加载超时");return}F++,setTimeout(()=>{k(v)},100)}},W=()=>{},b=()=>{},P=()=>{const{componentList:v}=Ih(Pr(s.config,s.children||[]));j.value.open("页面预览","full"),(0,r.nextTick)(()=>{k(v)})};return e({reset:G,validate:R,getSchema:q,setSchema:K}),(v,N)=>{const I=(0,r.resolveComponent)("j-icon"),T=(0,r.resolveComponent)("d-drag-tool"),z=(0,r.resolveComponent)("el-collapse-item"),O=(0,r.resolveComponent)("el-collapse"),L=(0,r.resolveComponent)("j-button"),ee=(0,r.resolveComponent)("el-tooltip"),se=(0,r.resolveComponent)("el-divider"),V=(0,r.resolveComponent)("el-empty"),X=(0,r.resolveComponent)("d-drag-index-list"),A=(0,r.resolveComponent)("d-drag-container"),U=(0,r.resolveComponent)("j-form"),te=(0,r.resolveComponent)("j-page"),ie=(0,r.resolveComponent)("j-layer");return(0,r.openBlock)(),(0,r.createElementBlock)("div",Ah,[(0,r.createElementVNode)("div",$h,[N[1]||(N[1]=(0,r.createElementVNode)("div",{class:"d-index-design-panel-title"},"组件库",-1)),(0,r.createElementVNode)("div",Ph,[(0,r.createVNode)(O,{modelValue:B.value,"onUpdate:modelValue":N[0]||(N[0]=le=>B.value=le)},{default:(0,r.withCtx)(()=>[((0,r.openBlock)(!0),(0,r.createElementBlock)(r.Fragment,null,(0,r.renderList)(t.components,(le,J)=>((0,r.openBlock)(),(0,r.createBlock)(z,{key:J,title:le.name,name:J},{default:(0,r.withCtx)(()=>[((0,r.openBlock)(!0),(0,r.createElementBlock)(r.Fragment,null,(0,r.renderList)(le.children,(re,x)=>((0,r.openBlock)(),(0,r.createBlock)(T,{key:x,config:re},{default:(0,r.withCtx)(()=>[(0,r.createElementVNode)("div",Oh,[(0,r.createVNode)(I,{class:"j-component-tool-icon",icon:re.icon,size:14},null,8,["icon"]),(0,r.createElementVNode)("div",Vh,(0,r.toDisplayString)((0,r.unref)(n)(re.name)),1)])]),_:2},1032,["config"]))),128))]),_:2},1032,["title","name"]))),128))]),_:1},8,["modelValue"])])]),(0,r.createElementVNode)("div",Hh,[(0,r.createElementVNode)("div",Lh,[N[2]||(N[2]=(0,r.createElementVNode)("div",null,null,-1)),(0,r.createElementVNode)("div",null,[(0,r.createVNode)(ee,{content:(0,r.unref)(n)("清空")},{default:(0,r.withCtx)(()=>[(0,r.createVNode)(L,{danger:"",type:"text",onClick:M,icon:"mdi:delete-outline"})]),_:1},8,["content"]),(0,r.createVNode)(se,{direction:"vertical"}),(0,r.createVNode)(ee,{content:(0,r.unref)(n)("预览")},{default:(0,r.withCtx)(()=>[(0,r.createVNode)(L,{type:"text",onClick:P,icon:"mdi:play-circle-outline"})]),_:1},8,["content"])])]),(0,r.createElementVNode)("div",Fh,[(0,r.createVNode)(A,{ref_key:"dragContainer",ref:h,class:"design-drag-container","is-component-container":!1,"component-data":s},{default:(0,r.withCtx)(()=>[!s.children||s.children.length===0?((0,r.openBlock)(),(0,r.createElementBlock)("div",Gh,[(0,r.createVNode)(V,{description:(0,r.unref)(n)("请从左侧拖拽组件到此处"),"image-size":100},null,8,["description"])])):((0,r.openBlock)(),(0,r.createBlock)(X,{key:1,"component-list":s.children,"global-config":s.config},null,8,["component-list","global-config"]))]),_:1},8,["component-data"])])]),(0,r.withDirectives)((0,r.createElementVNode)("div",Wh,[(0,r.createElementVNode)("div",Uh,[(0,r.createElementVNode)("span",Yh,(0,r.toDisplayString)(`${(0,r.unref)(n)("属性配置")}${D.value}`),1)]),(0,r.createElementVNode)("div",Xh,[(0,r.createVNode)(U,{config:{labelPosition:"top",size:"small"},collapseAnimate:!1,style:{padding:"0"},ref_key:"configRef",ref:f,onChange:c},null,512)])],512),[[r.vShow,(0,r.unref)(g)&&d[(0,r.unref)(g).type]]]),(0,r.createVNode)(ie,{ref_key:"previewLayerRef",ref:j,"has-btns":!1,onOk:W,onClosed:b},{default:(0,r.withCtx)(()=>[(0,r.createVNode)(te,{ref_key:"previewRef",ref:Z},null,512)]),_:1},512)])}}}),Zh=jh,Hr=qe(Zh,[Vr]),Kh=[So,Mn,In,Bn,zn,Cr,Er,Mr,Ir,$r,Hr],Lr=new WeakSet,qh=t=>{Lr.has(t)||(Lr.add(t),Kh.forEach(e=>{const n=e.name;n&&t.component(n,e)}))},Jh={install:qh};me.DDrag=So,me.DDraggable=Ir,me.DFlowDesign=Cr,me.DFormDesign=$r,me.DIndexDesign=Hr,me.DInputFlow=Er,me.DLayout=Mr,me.default=Jh,me.dragContainer=In,me.dragFormList=Bn,me.dragIndexList=zn,me.dragTool=Mn,me.toFormDesignSchema=Br,me.toFormSaveSchema=bo,me.toFormSchema=dh});
|
|
28
|
+
Note: ".grid-stack" is required for proper CSS styling and drag/drop, and is the default selector.`)),o}static addGrid(e,n={}){if(!e)return null;let o=e;if(o.gridstack){const i=o.gridstack;return n&&(i.opts={...i.opts,...n}),n.children!==void 0&&i.load(n.children),i}return(!e.classList.contains("grid-stack")||ce.addRemoveCB)&&(ce.addRemoveCB?o=ce.addRemoveCB(e,n,!0,!0):o=$.createDiv(["grid-stack",n.class],e)),ce.init(n,o)}static registerEngine(e){ce.engineClass=e}get placeholder(){if(!this._placeholder){this._placeholder=$.createDiv([this.opts.placeholderClass,ke.itemClass,this.opts.itemClass]);const e=$.createDiv(["placeholder-content"],this._placeholder);this.opts.placeholderText&&(e.textContent=this.opts.placeholderText)}return this._placeholder}constructor(e,n={}){this.el=e,this.opts=n,this.animationDelay=310,this._gsEventHandler={},this._extraDragRow=0,this.dragTransform={xScale:1,yScale:1,xOffset:0,yOffset:0},e.gridstack=this,this.opts=n=n||{},e.classList.contains("grid-stack")||this.el.classList.add("grid-stack"),n.row&&(n.minRow=n.maxRow=n.row,delete n.row);const o=$.toNumber(e.getAttribute("gs-row"));n.column==="auto"&&delete n.column,n.alwaysShowResizeHandle!==void 0&&(n._alwaysShowResizeHandle=n.alwaysShowResizeHandle);const i=n.columnOpts;if(i){const d=i.breakpoints;!i.columnWidth&&!d?.length?delete n.columnOpts:(i.columnMax=i.columnMax||12,d?.length>1&&d.sort((c,u)=>(u.w||0)-(c.w||0)))}const s={...$.cloneDeep(ke),column:$.toNumber(e.getAttribute("gs-column"))||ke.column,minRow:o||$.toNumber(e.getAttribute("gs-min-row"))||ke.minRow,maxRow:o||$.toNumber(e.getAttribute("gs-max-row"))||ke.maxRow,staticGrid:$.toBool(e.getAttribute("gs-static"))||ke.staticGrid,sizeToContent:$.toBool(e.getAttribute("gs-size-to-content"))||void 0,draggable:{handle:(n.handleClass?"."+n.handleClass:n.handle?n.handle:"")||ke.draggable.handle},removableOptions:{accept:n.itemClass||ke.removableOptions.accept,decline:ke.removableOptions.decline}};e.getAttribute("gs-animate")&&(s.animate=$.toBool(e.getAttribute("gs-animate"))),n=$.defaults(n,s),this._initMargin(),this.checkDynamicColumn(),this._updateColumnVar(n),n.rtl==="auto"&&(n.rtl=e.style.direction==="rtl"),n.rtl&&this.el.classList.add("grid-stack-rtl");const a=this.el.closest("."+ke.itemClass)?.gridstackNode;if(a&&(a.subGrid=this,this.parentGridNode=a,this.el.classList.add("grid-stack-nested"),a.el.classList.add("grid-stack-sub-grid")),this._isAutoCellHeight=n.cellHeight==="auto",this._isAutoCellHeight||n.cellHeight==="initial")this.cellHeight(void 0);else{typeof n.cellHeight=="number"&&n.cellHeightUnit&&n.cellHeightUnit!==ke.cellHeightUnit&&(n.cellHeight=n.cellHeight+n.cellHeightUnit,delete n.cellHeightUnit);const d=n.cellHeight;delete n.cellHeight,this.cellHeight(d)}n.alwaysShowResizeHandle==="mobile"&&(n.alwaysShowResizeHandle=Be),this._setStaticClass();const l=n.engineClass||ce.engineClass||_o;if(this.engine=new l({column:this.getColumn(),float:n.float,maxRow:n.maxRow,onChange:d=>{d.forEach(c=>{const u=c.el;u&&(c._removeDOM?(u&&u.remove(),delete c._removeDOM):this._writePosAttr(u,c))}),this._updateContainerHeight()}}),n.auto&&(this.batchUpdate(),this.engine._loading=!0,this.getGridItems().forEach(d=>this._prepareElement(d)),delete this.engine._loading,this.batchUpdate(!1)),n.children){const d=n.children;delete n.children,d.length&&this.load(d)}this.setAnimation(),n.subGridDynamic&&!de.pauseDrag&&(de.pauseDrag=!0),n.draggable?.pause!==void 0&&(de.pauseDrag=n.draggable.pause),this._setupRemoveDrop(),this._setupAcceptWidget(),this._updateResizeEvent()}_updateColumnVar(e=this.opts){this.el.classList.add("gs-"+e.column),typeof e.column=="number"&&this.el.style.setProperty("--gs-column-width",`${100/e.column}%`)}addWidget(e){if(!e)return;if(typeof e=="string"){console.error("V11: GridStack.addWidget() does not support string anymore. see #2736");return}if(e.ELEMENT_NODE)return console.error("V11: GridStack.addWidget() does not support HTMLElement anymore. use makeWidget()"),this.makeWidget(e);let n,o=e;if(o.grid=this,o.el?n=o.el:ce.addRemoveCB?n=ce.addRemoveCB(this.el,e,!0,!1):n=this.createWidgetDivs(o),!n)return;if(o=n.gridstackNode,o&&n.parentElement===this.el&&this.engine.nodes.find(s=>s._id===o._id))return n;const i=this._readAttr(n);return $.defaults(e,i),this.engine.prepareNode(e),this.el.appendChild(n),this.makeWidget(n,e),n}createWidgetDivs(e){const n=$.createDiv(["grid-stack-item",this.opts.itemClass]),o=$.createDiv(["grid-stack-item-content"],n);return $.lazyLoad(e)?e.visibleObservable||(e.visibleObservable=new IntersectionObserver(([i])=>{i.isIntersecting&&(e.visibleObservable?.disconnect(),delete e.visibleObservable,ce.renderCB(o,e),e.grid?.prepareDragDrop(e.el))}),window.setTimeout(()=>e.visibleObservable?.observe(n))):ce.renderCB(o,e),n}makeSubGrid(e,n,o,i=!0){let s=e.gridstackNode;if(s||(s=this.makeWidget(e).gridstackNode),s.subGrid?.el)return s.subGrid;let a,l=this;for(;l&&!a;)a=l.opts?.subGridOpts,l=l.parentGridNode?.grid;n=$.cloneDeep({...this.opts,id:void 0,children:void 0,column:"auto",columnOpts:void 0,layout:"list",subGridOpts:void 0,...a||{},...n||s.subGridOpts||{}}),s.subGridOpts=n;let d;n.column==="auto"&&(d=!0,n.column=Math.max(s.w||1,o?.w||1),delete n.columnOpts);let c=s.el.querySelector(".grid-stack-item-content"),u,h;if(i&&(this._removeDD(s.el),h={...s,x:0,y:0},$.removeInternalForSave(h),delete h.subGridOpts,s.content&&(h.content=s.content,delete s.content),ce.addRemoveCB?u=ce.addRemoveCB(this.el,h,!0,!1):(u=$.createDiv(["grid-stack-item"]),u.appendChild(c),c=$.createDiv(["grid-stack-item-content"],s.el)),this.prepareDragDrop(s.el)),o){const g=d?n.column:s.w,m=s.h+o.h,E=s.el.style;E.transition="none",this.update(s.el,{w:g,h:m}),setTimeout(()=>E.transition=null)}const f=s.subGrid=ce.addGrid(c,n);return o?._moving&&(f._isTemp=!0),d&&(f._autoColumn=!0),i&&f.makeWidget(u,h),o&&(o._moving?window.setTimeout(()=>$.simulateMouseEvent(o._event,"mouseenter",f.el),0):f.makeWidget(s.el,s)),this.resizeToContentCheck(!1,s),f}removeAsSubGrid(e){const n=this.parentGridNode?.grid;n&&(n.batchUpdate(),n.removeWidget(this.parentGridNode.el,!0,!0),this.engine.nodes.forEach(o=>{o.x+=this.parentGridNode.x,o.y+=this.parentGridNode.y,n.makeWidget(o.el,o)}),n.batchUpdate(!1),this.parentGridNode&&delete this.parentGridNode.subGrid,delete this.parentGridNode,e&&window.setTimeout(()=>$.simulateMouseEvent(e._event,"mouseenter",n.el),0))}save(e=!0,n=!1,o=ce.saveCB,i){const s=this.engine.save(e,o,i);if(s.forEach(a=>{if(e&&a.el&&!a.subGrid&&!o)a.content=a.el.querySelector(".grid-stack-item-content")?.innerHTML,a.content||delete a.content;else if(!e&&!o&&delete a.content,a.subGrid?.el){const l=a.w||a.subGrid.getColumn(),d=a.subGrid.save(e,n,o,l);a.subGridOpts=n?d:{children:d},delete a.subGrid}delete a.el}),n){const a=$.cloneDeep(this.opts);a.marginBottom===a.marginTop&&a.marginRight===a.marginLeft&&a.marginTop===a.marginRight&&(a.margin=a.marginTop,delete a.marginTop,delete a.marginRight,delete a.marginBottom,delete a.marginLeft),a.rtl===(this.el.style.direction==="rtl")&&(a.rtl="auto"),this._isAutoCellHeight&&(a.cellHeight="auto"),this._autoColumn&&(a.column="auto");const l=a._alwaysShowResizeHandle;return delete a._alwaysShowResizeHandle,l!==void 0?a.alwaysShowResizeHandle=l:delete a.alwaysShowResizeHandle,$.removeInternalAndSame(a,ke),a.children=s,a}return s}load(e,n=ce.addRemoveCB||!0){e=$.cloneDeep(e);const o=this.getColumn();e.forEach(u=>{u.w=u.w||u.minW||1,u.h=u.h||u.minH||1}),e=$.sort(e),this.engine.skipCacheUpdate=this._ignoreLayoutsNodeChange=!0;let i=0;e.forEach(u=>{i=Math.max(i,(u.x||0)+u.w)}),i>this.engine.defaultColumn&&(this.engine.defaultColumn=i),i>o&&(this.engine.nodes.length===0&&this.responseLayout?(this.engine.nodes=e,this.engine.columnChanged(i,o,this.responseLayout),e=this.engine.nodes,this.engine.nodes=[],delete this.responseLayout):this.engine.cacheLayout(e,i,!0));const s=ce.addRemoveCB;typeof n=="function"&&(ce.addRemoveCB=n);const a=[];this.batchUpdate();const l=!this.engine.nodes.length,d=l&&this.opts.animate;d&&this.setAnimation(!1),!l&&n&&[...this.engine.nodes].forEach(u=>{u.id&&($.find(e,u.id)||(ce.addRemoveCB&&ce.addRemoveCB(this.el,u,!1,!1),a.push(u),this.removeWidget(u.el,!0,!1)))}),this.engine._loading=!0;const c=[];return this.engine.nodes=this.engine.nodes.filter(u=>$.find(e,u.id)?(c.push(u),!1):!0),e.forEach(u=>{const h=$.find(c,u.id);if(h){if($.shouldSizeToContent(h)&&(u.h=h.h),this.engine.nodeBoundFix(u),(u.autoPosition||u.x===void 0||u.y===void 0)&&(u.w=u.w||h.w,u.h=u.h||h.h,this.engine.findEmptyPosition(u)),this.engine.nodes.push(h),$.samePos(h,u)&&this.engine.nodes.length>1&&(this.moveNode(h,{...u,forceCollide:!0}),$.copyPos(u,h)),this.update(h.el,u),u.subGridOpts?.children){const f=h.el.querySelector(".grid-stack");f&&f.gridstack&&f.gridstack.load(u.subGridOpts.children)}}else n&&this.addWidget(u)}),delete this.engine._loading,this.engine.removedNodes=a,this.batchUpdate(!1),delete this._ignoreLayoutsNodeChange,delete this.engine.skipCacheUpdate,s?ce.addRemoveCB=s:delete ce.addRemoveCB,d&&this.setAnimation(!0,!0),this}batchUpdate(e=!0){return this.engine.batchUpdate(e),e||(this._updateContainerHeight(),this._triggerRemoveEvent(),this._triggerAddEvent(),this._triggerChangeEvent()),this}getCellHeight(e=!1){if(this.opts.cellHeight&&this.opts.cellHeight!=="auto"&&(!e||!this.opts.cellHeightUnit||this.opts.cellHeightUnit==="px"))return this.opts.cellHeight;if(this.opts.cellHeightUnit==="rem")return this.opts.cellHeight*parseFloat(getComputedStyle(document.documentElement).fontSize);if(this.opts.cellHeightUnit==="em")return this.opts.cellHeight*parseFloat(getComputedStyle(this.el).fontSize);if(this.opts.cellHeightUnit==="cm")return this.opts.cellHeight*(96/2.54);if(this.opts.cellHeightUnit==="mm")return this.opts.cellHeight*(96/2.54)/10;const n=this.el.querySelector("."+this.opts.itemClass);if(n){const i=$.toNumber(n.getAttribute("gs-h"))||1;return Math.round(n.offsetHeight/i)}const o=parseInt(this.el.getAttribute("gs-current-row"));return o?Math.round(this.el.getBoundingClientRect().height/o):this.opts.cellHeight}cellHeight(e){if(e!==void 0&&this._isAutoCellHeight!==(e==="auto")&&(this._isAutoCellHeight=e==="auto",this._updateResizeEvent()),(e==="initial"||e==="auto")&&(e=void 0),e===void 0){const o=-this.opts.marginRight-this.opts.marginLeft+this.opts.marginTop+this.opts.marginBottom;e=this.cellWidth()+o}const n=$.parseHeight(e);return this.opts.cellHeightUnit===n.unit&&this.opts.cellHeight===n.h?this:(this.opts.cellHeightUnit=n.unit,this.opts.cellHeight=n.h,this.el.style.setProperty("--gs-cell-height",`${this.opts.cellHeight}${this.opts.cellHeightUnit}`),this._updateContainerHeight(),this.resizeToContentCheck(),this)}cellWidth(){return this._widthOrContainer()/this.getColumn()}_widthOrContainer(e=!1){return e&&this.opts.columnOpts?.breakpointForWindow?window.innerWidth:this.el.clientWidth||this.el.parentElement.clientWidth||window.innerWidth}checkDynamicColumn(){const e=this.opts.columnOpts;if(!e||!e.columnWidth&&!e.breakpoints?.length)return!1;const n=this.getColumn();let o=n;const i=this._widthOrContainer(!0);if(e.columnWidth)o=Math.min(Math.round(i/e.columnWidth)||1,e.columnMax);else{o=e.columnMax;let s=0;for(;s<e.breakpoints.length&&i<=e.breakpoints[s].w;)o=e.breakpoints[s++].c||n}if(o!==n){const s=e.breakpoints?.find(a=>a.c===o);return this.column(o,s?.layout||e.layout),!0}return!1}compact(e="compact",n=!0){return this.engine.compact(e,n),this._triggerChangeEvent(),this}column(e,n="moveScale"){if(!e||e<1||this.opts.column===e)return this;const o=this.getColumn();return this.opts.column=e,this.engine?(this.engine.column=e,this.el.classList.remove("gs-"+o),this._updateColumnVar(),this.engine.columnChanged(o,e,n),this._isAutoCellHeight&&this.cellHeight(),this.resizeToContentCheck(!0),this._ignoreLayoutsNodeChange=!0,this._triggerChangeEvent(),delete this._ignoreLayoutsNodeChange,this):(this.responseLayout=n,this)}getColumn(){return this.opts.column}getGridItems(){return Array.from(this.el.children).filter(e=>e.matches("."+this.opts.itemClass)&&!e.matches("."+this.opts.placeholderClass))}isIgnoreChangeCB(){return this._ignoreLayoutsNodeChange}destroy(e=!0){if(this.el)return this.offAll(),this._updateResizeEvent(!0),this.setStatic(!0,!1),this.setAnimation(!1),e?this.el.parentNode.removeChild(this.el):(this.removeAll(e),this.el.removeAttribute("gs-current-row")),this.parentGridNode&&delete this.parentGridNode.subGrid,delete this.parentGridNode,delete this.opts,delete this._placeholder?.gridstackNode,delete this._placeholder,delete this.engine,delete this.el.gridstack,delete this.el,this}float(e){return this.opts.float!==e&&(this.opts.float=this.engine.float=e,this._triggerChangeEvent()),this}getFloat(){return this.engine.float}getCellFromPixel(e,n=!1){const o=this.el.getBoundingClientRect();let i;n?i={top:o.top+document.documentElement.scrollTop,left:o.left}:i={top:this.el.offsetTop,left:this.el.offsetLeft};const s=e.left-i.left,a=e.top-i.top,l=o.width/this.getColumn(),d=o.height/parseInt(this.el.getAttribute("gs-current-row"));return{x:Math.floor(s/l),y:Math.floor(a/d)}}getRow(){return Math.max(this.engine.getRow(),this.opts.minRow||0)}isAreaEmpty(e,n,o,i){return this.engine.isAreaEmpty(e,n,o,i)}makeWidget(e,n){const o=ce.getElement(e);if(!o||o.gridstackNode)return o;o.parentElement||this.el.appendChild(o),this._prepareElement(o,!0,n);const i=o.gridstackNode;this._updateContainerHeight(),i.subGridOpts&&this.makeSubGrid(o,i.subGridOpts,void 0,!1);let s;return this.opts.column===1&&!this._ignoreLayoutsNodeChange&&(s=this._ignoreLayoutsNodeChange=!0),this._triggerAddEvent(),this._triggerChangeEvent(),s&&delete this._ignoreLayoutsNodeChange,o}on(e,n){return e.indexOf(" ")!==-1?(e.split(" ").forEach(o=>this.on(o,n)),this):(e==="change"||e==="added"||e==="removed"||e==="enable"||e==="disable"?(e==="enable"||e==="disable"?this._gsEventHandler[e]=o=>n(o):this._gsEventHandler[e]=o=>{o.detail&&n(o,o.detail)},this.el.addEventListener(e,this._gsEventHandler[e])):e==="drag"||e==="dragstart"||e==="dragstop"||e==="resizestart"||e==="resize"||e==="resizestop"||e==="dropped"||e==="resizecontent"?this._gsEventHandler[e]=n:console.error("GridStack.on("+e+") event not supported"),this)}off(e){return e.indexOf(" ")!==-1?(e.split(" ").forEach(n=>this.off(n)),this):((e==="change"||e==="added"||e==="removed"||e==="enable"||e==="disable")&&this._gsEventHandler[e]&&this.el.removeEventListener(e,this._gsEventHandler[e]),delete this._gsEventHandler[e],this)}offAll(){return Object.keys(this._gsEventHandler).forEach(e=>this.off(e)),this}removeWidget(e,n=!0,o=!0){return e?(ce.getElements(e).forEach(i=>{if(i.parentElement&&i.parentElement!==this.el)return;let s=i.gridstackNode;s||(s=this.engine.nodes.find(a=>i===a.el)),s&&(n&&ce.addRemoveCB&&ce.addRemoveCB(this.el,s,!1,!1),delete i.gridstackNode,this._removeDD(i),this.engine.removeNode(s,n,o),n&&i.parentElement&&i.remove())}),o&&(this._triggerRemoveEvent(),this._triggerChangeEvent()),this):(console.error("Error: GridStack.removeWidget(undefined) called"),this)}removeAll(e=!0,n=!0){return this.engine.nodes.forEach(o=>{e&&ce.addRemoveCB&&ce.addRemoveCB(this.el,o,!1,!1),delete o.el.gridstackNode,this.opts.staticGrid||this._removeDD(o.el)}),this.engine.removeAll(e,n),n&&this._triggerRemoveEvent(),this}setAnimation(e=this.opts.animate,n){return n?setTimeout(()=>{this.opts&&this.setAnimation(e)}):e?this.el.classList.add("grid-stack-animate"):this.el.classList.remove("grid-stack-animate"),this.opts.animate=e,this}hasAnimationCSS(){return this.el.classList.contains("grid-stack-animate")}setStatic(e,n=!0,o=!0){return!!this.opts.staticGrid===e?this:(e?this.opts.staticGrid=!0:delete this.opts.staticGrid,this._setupRemoveDrop(),this._setupAcceptWidget(),this.engine.nodes.forEach(i=>{this.prepareDragDrop(i.el),i.subGrid&&o&&i.subGrid.setStatic(e,n,o)}),n&&this._setStaticClass(),this)}updateOptions(e){const n=this.opts;return e===n?this:(e.acceptWidgets!==void 0&&(n.acceptWidgets=e.acceptWidgets,this._setupAcceptWidget()),e.animate!==void 0&&this.setAnimation(e.animate),e.cellHeight&&this.cellHeight(e.cellHeight),e.class!==void 0&&e.class!==n.class&&(n.class&&this.el.classList.remove(n.class),e.class&&this.el.classList.add(e.class)),e.columnOpts?(this.opts.columnOpts=e.columnOpts,this.checkDynamicColumn()):e.columnOpts===null&&this.opts.columnOpts?(delete this.opts.columnOpts,this._updateResizeEvent()):typeof e.column=="number"&&this.column(e.column),e.margin!==void 0&&this.margin(e.margin),e.staticGrid!==void 0&&this.setStatic(e.staticGrid),e.disableDrag!==void 0&&!e.staticGrid&&this.enableMove(!e.disableDrag),e.disableResize!==void 0&&!e.staticGrid&&this.enableResize(!e.disableResize),e.float!==void 0&&this.float(e.float),e.row!==void 0?(n.minRow=n.maxRow=n.row=e.row,this._updateContainerHeight()):(e.minRow!==void 0&&(n.minRow=e.minRow,this._updateContainerHeight()),e.maxRow!==void 0&&(n.maxRow=e.maxRow)),e.lazyLoad!==void 0&&(n.lazyLoad=e.lazyLoad),e.children?.length&&this.load(e.children),this)}update(e,n){return ce.getElements(e).forEach(o=>{const i=o?.gridstackNode;if(!i)return;const s={...$.copyPos({},i),...$.cloneDeep(n)};this.engine.nodeBoundFix(s),delete s.autoPosition;const a=["x","y","w","h"];let l;if(a.some(u=>s[u]!==void 0&&s[u]!==i[u])&&(l={},a.forEach(u=>{l[u]=s[u]!==void 0?s[u]:i[u],delete s[u]})),!l&&(s.minW||s.minH||s.maxW||s.maxH)&&(l={}),s.content!==void 0){const u=o.querySelector(".grid-stack-item-content");u&&u.textContent!==s.content&&(i.content=s.content,ce.renderCB(u,s),i.subGrid?.el&&(u.appendChild(i.subGrid.el),i.subGrid._updateContainerHeight())),delete s.content}let d=!1,c=!1;for(const u in s)u[0]!=="_"&&i[u]!==s[u]&&(i[u]=s[u],d=!0,c=c||!this.opts.staticGrid&&(u==="noResize"||u==="noMove"||u==="locked"));if($.sanitizeMinMax(i),l){const u=l.w!==void 0&&l.w!==i.w;this.moveNode(i,l),u&&i.subGrid?i.subGrid.onResize(this.hasAnimationCSS()?i.w:void 0):this.resizeToContentCheck(u,i),delete i._orig}(l||d)&&this._writeAttr(o,i),c&&this.prepareDragDrop(i.el),ce.updateCB&&ce.updateCB(i)}),this}moveNode(e,n){const o=e._updating;o||this.engine.cleanNodes().beginUpdate(e),this.engine.moveNode(e,n),this._updateContainerHeight(),o||(this._triggerChangeEvent(),this.engine.endUpdate())}resizeToContent(e){if(!e||(e.classList.remove("size-to-content-max"),!e.clientHeight))return;const n=e.gridstackNode;if(!n)return;const o=n.grid;if(!o||e.parentElement!==o.el)return;const i=o.getCellHeight(!0);if(!i)return;let s=n.h?n.h*i:e.clientHeight,a;if(n.resizeToContentParent&&(a=e.querySelector(n.resizeToContentParent)),a||(a=e.querySelector(ce.resizeToContentParent)),!a)return;const l=e.clientHeight-a.clientHeight,d=n.h?n.h*i-l:a.clientHeight;let c;if(n.subGrid){c=n.subGrid.getRow()*n.subGrid.getCellHeight(!0);const f=n.subGrid.el.getBoundingClientRect(),g=e.getBoundingClientRect();c+=f.top-g.top}else{if(n.subGridOpts?.children?.length)return;{const f=a.firstElementChild;if(!f){console.error(`Error: GridStack.resizeToContent() widget id:${n.id} '${ce.resizeToContentParent}'.firstElementChild is null, make sure to have a div like container. Skipping sizing.`);return}c=f.getBoundingClientRect().height||d}}if(d===c)return;s+=c-d;let u=Math.ceil(s/i);const h=Number.isInteger(n.sizeToContent)?n.sizeToContent:0;h&&u>h&&(u=h,e.classList.add("size-to-content-max")),n.minH&&u<n.minH?u=n.minH:n.maxH&&u>n.maxH&&(u=n.maxH),u!==n.h&&(o._ignoreLayoutsNodeChange=!0,o.moveNode(n,{h:u}),delete o._ignoreLayoutsNodeChange)}resizeToContentCBCheck(e){ce.resizeToContentCB?ce.resizeToContentCB(e):this.resizeToContent(e)}rotate(e,n){return ce.getElements(e).forEach(o=>{const i=o.gridstackNode;if(!$.canBeRotated(i))return;const s={w:i.h,h:i.w,minH:i.minW,minW:i.minH,maxH:i.maxW,maxW:i.maxH};if(n){const l=n.left>0?Math.floor(n.left/this.cellWidth()):0,d=n.top>0?Math.floor(n.top/this.opts.cellHeight):0;s.x=i.x+l-(i.h-(d+1)),s.y=i.y+d-l}Object.keys(s).forEach(l=>{s[l]===void 0&&delete s[l]});const a=i._orig;this.update(o,s),i._orig=a}),this}margin(e){if(!(typeof e=="string"&&e.split(" ").length>1)){const n=$.parseHeight(e);if(this.opts.marginUnit===n.unit&&this.opts.margin===n.h)return}return this.opts.margin=e,this.opts.marginTop=this.opts.marginBottom=this.opts.marginLeft=this.opts.marginRight=void 0,this._initMargin(),this}getMargin(){return this.opts.margin}willItFit(e){return this.engine.willItFit(e)}_triggerChangeEvent(){if(this.engine.batchMode)return this;const e=this.engine.getDirtyNodes(!0);return e&&e.length&&(this._ignoreLayoutsNodeChange||this.engine.layoutsNodesChange(e),this._triggerEvent("change",e)),this.engine.saveInitial(),this}_triggerAddEvent(){if(this.engine.batchMode)return this;if(this.engine.addedNodes?.length){this._ignoreLayoutsNodeChange||this.engine.layoutsNodesChange(this.engine.addedNodes),this.engine.addedNodes.forEach(n=>{delete n._dirty});const e=[...this.engine.addedNodes];this.engine.addedNodes=[],this._triggerEvent("added",e)}return this}_triggerRemoveEvent(){if(this.engine.batchMode)return this;if(this.engine.removedNodes?.length){const e=[...this.engine.removedNodes];this.engine.removedNodes=[],this._triggerEvent("removed",e)}return this}_triggerEvent(e,n){const o=n?new CustomEvent(e,{bubbles:!1,detail:n}):new Event(e);let i=this;for(;i.parentGridNode;)i=i.parentGridNode.grid;return i.el.dispatchEvent(o),this}_updateContainerHeight(){if(!this.engine||this.engine.batchMode)return this;const e=this.parentGridNode;let n=this.getRow()+this._extraDragRow;const o=this.opts.cellHeight,i=this.opts.cellHeightUnit;if(!o)return this;if(!e&&!this.opts.minRow){const s=$.parseHeight(getComputedStyle(this.el).minHeight);if(s.h>0&&s.unit===i){const a=Math.floor(s.h/o);n<a&&(n=a)}}return this.el.setAttribute("gs-current-row",String(n)),this.el.style.removeProperty("min-height"),this.el.style.removeProperty("height"),n&&(this.el.style[e?"minHeight":"height"]=n*o+i),e&&$.shouldSizeToContent(e)&&e.grid.resizeToContentCBCheck(e.el),this}_prepareElement(e,n=!1,o){o=o||this._readAttr(e),e.gridstackNode=o,o.el=e,o.grid=this,o=this.engine.addNode(o,n),this._writeAttr(e,o),e.classList.add(ke.itemClass,this.opts.itemClass);const i=$.shouldSizeToContent(o);return i?e.classList.add("size-to-content"):e.classList.remove("size-to-content"),i&&this.resizeToContentCheck(!1,o),$.lazyLoad(o)||this.prepareDragDrop(o.el),this}_writePosAttr(e,n){return(!n._moving&&!n._resizing||this._placeholder===e)&&(e.style.top=n.y?n.y===1?"var(--gs-cell-height)":`calc(${n.y} * var(--gs-cell-height))`:null,e.style.left=n.x?n.x===1?"var(--gs-column-width)":`calc(${n.x} * var(--gs-column-width))`:null,e.style.width=n.w>1?`calc(${n.w} * var(--gs-column-width))`:null,e.style.height=n.h>1?`calc(${n.h} * var(--gs-cell-height))`:null),e.setAttribute("gs-x",String(n.x)),e.setAttribute("gs-y",String(n.y)),n.w>1?e.setAttribute("gs-w",String(n.w)):e.removeAttribute("gs-w"),n.h>1?e.setAttribute("gs-h",String(n.h)):e.removeAttribute("gs-h"),this}_writeAttr(e,n){if(!n)return this;this._writePosAttr(e,n);const o={noResize:"gs-no-resize",noMove:"gs-no-move",locked:"gs-locked",id:"gs-id",sizeToContent:"gs-size-to-content"};for(const i in o)n[i]?e.setAttribute(o[i],String(n[i])):e.removeAttribute(o[i]);return this}_readAttr(e,n=!0){const o={};o.x=$.toNumber(e.getAttribute("gs-x")),o.y=$.toNumber(e.getAttribute("gs-y")),o.w=$.toNumber(e.getAttribute("gs-w")),o.h=$.toNumber(e.getAttribute("gs-h")),o.autoPosition=$.toBool(e.getAttribute("gs-auto-position")),o.noResize=$.toBool(e.getAttribute("gs-no-resize")),o.noMove=$.toBool(e.getAttribute("gs-no-move")),o.locked=$.toBool(e.getAttribute("gs-locked"));const i=e.getAttribute("gs-size-to-content");i&&(i==="true"||i==="false"?o.sizeToContent=$.toBool(i):o.sizeToContent=parseInt(i,10)),o.id=e.getAttribute("gs-id"),o.maxW=$.toNumber(e.getAttribute("gs-max-w")),o.minW=$.toNumber(e.getAttribute("gs-min-w")),o.maxH=$.toNumber(e.getAttribute("gs-max-h")),o.minH=$.toNumber(e.getAttribute("gs-min-h")),n&&(o.w===1&&e.removeAttribute("gs-w"),o.h===1&&e.removeAttribute("gs-h"),o.maxW&&e.removeAttribute("gs-max-w"),o.minW&&e.removeAttribute("gs-min-w"),o.maxH&&e.removeAttribute("gs-max-h"),o.minH&&e.removeAttribute("gs-min-h"));for(const s in o){if(!o.hasOwnProperty(s))return;!o[s]&&o[s]!==0&&s!=="sizeToContent"&&delete o[s]}return o}_setStaticClass(){const e=["grid-stack-static"];return this.opts.staticGrid?(this.el.classList.add(...e),this.el.setAttribute("gs-static","true")):(this.el.classList.remove(...e),this.el.removeAttribute("gs-static")),this}onResize(e=this.el?.clientWidth){if(!e||this.prevWidth===e)return;this.prevWidth=e,this.batchUpdate();let n=!1;return this._autoColumn&&this.parentGridNode?this.opts.column!==this.parentGridNode.w&&(this.column(this.parentGridNode.w,this.opts.layout||"list"),n=!0):n=this.checkDynamicColumn(),this._isAutoCellHeight&&this.cellHeight(),this.engine.nodes.forEach(o=>{o.subGrid&&o.subGrid.onResize()}),this._skipInitialResize||this.resizeToContentCheck(n),delete this._skipInitialResize,this.batchUpdate(!1),this}resizeToContentCheck(e=!1,n=void 0){if(this.engine){if(e&&this.hasAnimationCSS())return setTimeout(()=>this.resizeToContentCheck(!1,n),this.animationDelay);if(n)$.shouldSizeToContent(n)&&this.resizeToContentCBCheck(n.el);else if(this.engine.nodes.some(o=>$.shouldSizeToContent(o))){const o=[...this.engine.nodes];this.batchUpdate(),o.forEach(i=>{$.shouldSizeToContent(i)&&this.resizeToContentCBCheck(i.el)}),this._ignoreLayoutsNodeChange=!0,this.batchUpdate(!1),this._ignoreLayoutsNodeChange=!1}this._gsEventHandler.resizecontent&&this._gsEventHandler.resizecontent(null,n?[n]:this.engine.nodes)}}_updateResizeEvent(e=!1){const n=!this.parentGridNode&&(this._isAutoCellHeight||this.opts.sizeToContent||this.opts.columnOpts||this.engine.nodes.find(o=>o.sizeToContent));return!e&&n&&!this.resizeObserver?(this._sizeThrottle=$.throttle(()=>this.onResize(),this.opts.cellHeightThrottle),this.resizeObserver=new ResizeObserver(()=>this._sizeThrottle()),this.resizeObserver.observe(this.el),this._skipInitialResize=!0):(e||!n)&&this.resizeObserver&&(this.resizeObserver.disconnect(),delete this.resizeObserver,delete this._sizeThrottle),this}static getElement(e=".grid-stack-item"){return $.getElement(e)}static getElements(e=".grid-stack-item"){return $.getElements(e)}static getGridElement(e){return ce.getElement(e)}static getGridElements(e){return $.getElements(e)}_initMargin(){let e,n=0,o=[];typeof this.opts.margin=="string"&&(o=this.opts.margin.split(" ")),o.length===2?(this.opts.marginTop=this.opts.marginBottom=o[0],this.opts.marginLeft=this.opts.marginRight=o[1]):o.length===4?(this.opts.marginTop=o[0],this.opts.marginRight=o[1],this.opts.marginBottom=o[2],this.opts.marginLeft=o[3]):(e=$.parseHeight(this.opts.margin),this.opts.marginUnit=e.unit,n=this.opts.margin=e.h),["marginTop","marginRight","marginBottom","marginLeft"].forEach(s=>{this.opts[s]===void 0?this.opts[s]=n:(e=$.parseHeight(this.opts[s]),this.opts[s]=e.h,delete this.opts.margin)}),this.opts.marginUnit=e.unit,this.opts.marginTop===this.opts.marginBottom&&this.opts.marginLeft===this.opts.marginRight&&this.opts.marginTop===this.opts.marginRight&&(this.opts.margin=this.opts.marginTop);const i=this.el.style;return i.setProperty("--gs-item-margin-top",`${this.opts.marginTop}${this.opts.marginUnit}`),i.setProperty("--gs-item-margin-bottom",`${this.opts.marginBottom}${this.opts.marginUnit}`),i.setProperty("--gs-item-margin-right",`${this.opts.marginRight}${this.opts.marginUnit}`),i.setProperty("--gs-item-margin-left",`${this.opts.marginLeft}${this.opts.marginUnit}`),this}static getDD(){return Ce}static setupDragIn(e,n,o,i=document){n?.pause!==void 0&&(de.pauseDrag=n.pause),n={appendTo:"body",helper:"clone",...n||{}},(typeof e=="string"?$.getElements(e,i):e).forEach((s,a)=>{Ce.isDraggable(s)||Ce.dragIn(s,n),o?.[a]&&(s.gridstackNode=o[a])})}movable(e,n){return this.opts.staticGrid?this:(ce.getElements(e).forEach(o=>{const i=o.gridstackNode;i&&(n?delete i.noMove:i.noMove=!0,this.prepareDragDrop(i.el))}),this)}resizable(e,n){return this.opts.staticGrid?this:(ce.getElements(e).forEach(o=>{const i=o.gridstackNode;i&&(n?delete i.noResize:i.noResize=!0,this.prepareDragDrop(i.el))}),this)}disable(e=!0){if(!this.opts.staticGrid)return this.enableMove(!1,e),this.enableResize(!1,e),this._triggerEvent("disable"),this}enable(e=!0){if(!this.opts.staticGrid)return this.enableMove(!0,e),this.enableResize(!0,e),this._triggerEvent("enable"),this}enableMove(e,n=!0){return this.opts.staticGrid?this:(e?delete this.opts.disableDrag:this.opts.disableDrag=!0,this.engine.nodes.forEach(o=>{this.prepareDragDrop(o.el),o.subGrid&&n&&o.subGrid.enableMove(e,n)}),this)}enableResize(e,n=!0){return this.opts.staticGrid?this:(e?delete this.opts.disableResize:this.opts.disableResize=!0,this.engine.nodes.forEach(o=>{this.prepareDragDrop(o.el),o.subGrid&&n&&o.subGrid.enableResize(e,n)}),this)}cancelDrag(){const e=this._placeholder?.gridstackNode;e&&(e._isExternal?(e._isAboutToRemove=!0,this.engine.removeNode(e)):e._isAboutToRemove&&ce._itemRemoving(e.el,!1),this.engine.restoreInitial())}_removeDD(e){return Ce.draggable(e,"destroy").resizable(e,"destroy"),e.gridstackNode&&delete e.gridstackNode._initDD,delete e.ddElement,this}_setupAcceptWidget(){if(this.opts.staticGrid||!this.opts.acceptWidgets&&!this.opts.removable)return Ce.droppable(this.el,"destroy"),this;let e,n;const o=(i,s,a)=>{a=a||s;const l=a.gridstackNode;if(!l)return;if(!l.grid?.el){a.style.transform=`scale(${1/this.dragTransform.xScale},${1/this.dragTransform.yScale})`;const f=a.getBoundingClientRect();a.style.left=f.x+(this.dragTransform.xScale-1)*(i.clientX-f.x)/this.dragTransform.xScale+"px",a.style.top=f.y+(this.dragTransform.yScale-1)*(i.clientY-f.y)/this.dragTransform.yScale+"px",a.style.transformOrigin="0px 0px"}let{top:d,left:c}=a.getBoundingClientRect();const u=this.el.getBoundingClientRect();c-=u.left,d-=u.top;const h={position:{top:d*this.dragTransform.xScale,left:c*this.dragTransform.yScale}};if(l._temporaryRemoved){if(l.x=Math.max(0,Math.round(c/n)),l.y=Math.max(0,Math.round(d/e)),delete l.autoPosition,this.engine.nodeBoundFix(l),!this.engine.willItFit(l)){if(l.autoPosition=!0,!this.engine.willItFit(l)){Ce.off(s,"drag");return}l._willFitPos&&($.copyPos(l,l._willFitPos),delete l._willFitPos)}this._onStartMoving(a,i,h,l,n,e)}else this._dragOrResize(a,i,h,l,n,e)};return Ce.droppable(this.el,{accept:i=>{const s=i.gridstackNode||this._readAttr(i,!1);if(s?.grid===this)return!0;if(!this.opts.acceptWidgets)return!1;let a=!0;if(typeof this.opts.acceptWidgets=="function")a=this.opts.acceptWidgets(i);else{const l=this.opts.acceptWidgets===!0?".grid-stack-item":this.opts.acceptWidgets;a=i.matches(l)}if(a&&s&&this.opts.maxRow){const l={w:s.w,h:s.h,minW:s.minW,minH:s.minH};a=this.engine.willItFit(l)}return a}}).on(this.el,"dropover",(i,s,a)=>{let l=a?.gridstackNode||s.gridstackNode;if(l?.grid===this&&!l._temporaryRemoved)return!1;if(l?._sidebarOrig&&(l.w=l._sidebarOrig.w,l.h=l._sidebarOrig.h),l?.grid&&l.grid!==this&&!l._temporaryRemoved&&l.grid._leave(s,a),a=a||s,n=this.cellWidth(),e=this.getCellHeight(!0),!l){const u=a.getAttribute("data-gs-widget")||a.getAttribute("gridstacknode");if(u){try{l=JSON.parse(u)}catch{console.error("Gridstack dropover: Bad JSON format: ",u)}a.removeAttribute("data-gs-widget"),a.removeAttribute("gridstacknode")}l||(l=this._readAttr(a)),l._sidebarOrig={w:l.w,h:l.h}}l.grid||(l.el||(l={...l}),l._isExternal=!0,a.gridstackNode=l);const d=l.w||Math.round(a.offsetWidth/n)||1,c=l.h||Math.round(a.offsetHeight/e)||1;return l.grid&&l.grid!==this?(s._gridstackNodeOrig||(s._gridstackNodeOrig=l),s.gridstackNode=l={...l,w:d,h:c,grid:this},delete l.x,delete l.y,this.engine.cleanupNode(l).nodeBoundFix(l),l._initDD=l._isExternal=l._temporaryRemoved=!0):(l.w=d,l.h=c,l._temporaryRemoved=!0),ce._itemRemoving(l.el,!1),Ce.on(s,"drag",o),o(i,s,a),!1}).on(this.el,"dropout",(i,s,a)=>{const l=a?.gridstackNode||s.gridstackNode;return l&&(!l.grid||l.grid===this)&&(this._leave(s,a),this._isTemp&&this.removeAsSubGrid(l)),!1}).on(this.el,"drop",(i,s,a)=>{const l=a?.gridstackNode||s.gridstackNode;if(l?.grid===this&&!l._isExternal)return!1;const d=!!this.placeholder.parentElement,c=s!==a;this.placeholder.remove(),delete this.placeholder.gridstackNode,d&&this.opts.animate&&(this.setAnimation(!1),this.setAnimation(!0,!0));const u=s._gridstackNodeOrig;if(delete s._gridstackNodeOrig,d&&u?.grid&&u.grid!==this){const f=u.grid;f.engine.removeNodeFromLayoutCache(u),f.engine.removedNodes.push(u),f._triggerRemoveEvent()._triggerChangeEvent(),f.parentGridNode&&!f.engine.nodes.length&&f.opts.subGridDynamic&&f.removeAsSubGrid()}if(!l||(d&&(this.engine.cleanupNode(l),l.grid=this),delete l.grid?._isTemp,Ce.off(s,"drag"),a!==s?(a.remove(),s=a):s.remove(),this._removeDD(s),!d))return!1;const h=l.subGrid?.el?.gridstack;return $.copyPos(l,this._readAttr(this.placeholder)),$.removePositioningStyles(s),c&&(l.content||l.subGridOpts||ce.addRemoveCB)?(delete l.el,s=this.addWidget(l)):(this._prepareElement(s,!0,l),this.el.appendChild(s),this.resizeToContentCheck(!1,l),h&&(h.parentGridNode=l),this._updateContainerHeight()),this.engine.addedNodes.push(l),this._triggerAddEvent(),this._triggerChangeEvent(),this.engine.endUpdate(),this._gsEventHandler.dropped&&this._gsEventHandler.dropped({...i,type:"dropped"},u&&u.grid?u:void 0,l),!1}),this}static _itemRemoving(e,n){if(!e)return;const o=e?e.gridstackNode:void 0;!o?.grid||e.classList.contains(o.grid.opts.removableOptions.decline)||(n?o._isAboutToRemove=!0:delete o._isAboutToRemove,n?e.classList.add("grid-stack-item-removing"):e.classList.remove("grid-stack-item-removing"))}_setupRemoveDrop(){if(typeof this.opts.removable!="string")return this;const e=document.querySelector(this.opts.removable);return e?(!this.opts.staticGrid&&!Ce.isDroppable(e)&&Ce.droppable(e,this.opts.removableOptions).on(e,"dropover",(n,o)=>ce._itemRemoving(o,!0)).on(e,"dropout",(n,o)=>ce._itemRemoving(o,!1)),this):this}prepareDragDrop(e,n=!1){const o=e?.gridstackNode;if(!o)return;const i=o.noMove||this.opts.disableDrag,s=o.noResize||this.opts.disableResize,a=this.opts.staticGrid||i&&s;if((n||a)&&(o._initDD&&(this._removeDD(e),delete o._initDD),a&&e.classList.add("ui-draggable-disabled","ui-resizable-disabled"),!n))return this;if(!o._initDD){let l,d;const c=(f,g)=>{this.triggerEvent(f,f.target),l=this.cellWidth(),d=this.getCellHeight(!0),this._onStartMoving(e,f,g,o,l,d)},u=(f,g)=>{this._dragOrResize(e,f,g,o,l,d)},h=f=>{this.placeholder.remove(),delete this.placeholder.gridstackNode,delete o._moving,delete o._resizing,delete o._event,delete o._lastTried;const g=o.w!==o._orig.w,m=f.target;if(!(!m.gridstackNode||m.gridstackNode.grid!==this)){if(o.el=m,o._isAboutToRemove){const E=e.gridstackNode.grid;E._gsEventHandler[f.type]&&E._gsEventHandler[f.type](f,m),E.engine.nodes.push(o),E.removeWidget(e,!0,!0)}else $.removePositioningStyles(m),o._temporaryRemoved?(this._writePosAttr(m,o),this.engine.addNode(o)):this._writePosAttr(m,o),this.triggerEvent(f,m);this._extraDragRow=0,this._updateContainerHeight(),this._triggerChangeEvent(),this.engine.endUpdate(),f.type==="resizestop"&&(Number.isInteger(o.sizeToContent)&&(o.sizeToContent=o.h),this.resizeToContentCheck(g,o))}};Ce.draggable(e,{start:c,stop:h,drag:u}).resizable(e,{start:c,stop:h,resize:u}),o._initDD=!0}return Ce.draggable(e,i?"disable":"enable").resizable(e,s?"disable":"enable"),this}_onStartMoving(e,n,o,i,s,a){if(this.engine.cleanNodes().beginUpdate(i),this._writePosAttr(this.placeholder,i),this.el.appendChild(this.placeholder),this.placeholder.gridstackNode=i,i.grid?.el)this.dragTransform=$.getValuesFromTransformedElement(e);else if(this.placeholder&&this.placeholder.closest(".grid-stack")){const l=this.placeholder.closest(".grid-stack");this.dragTransform=$.getValuesFromTransformedElement(l)}else this.dragTransform={xScale:1,xOffset:0,yScale:1,yOffset:0};if(i.el=this.placeholder,i._lastUiPosition=o.position,i._prevYPix=o.position.top,i._moving=n.type==="dragstart",i._resizing=n.type==="resizestart",delete i._lastTried,n.type==="dropover"&&i._temporaryRemoved&&(this.engine.addNode(i),i._moving=!0),this.engine.cacheRects(s,a,this.opts.marginTop,this.opts.marginRight,this.opts.marginBottom,this.opts.marginLeft),n.type==="resizestart"){const l=this.getColumn()-i.x,d=(this.opts.maxRow||Number.MAX_SAFE_INTEGER)-i.y;Ce.resizable(e,"option","minWidth",s*Math.min(i.minW||1,l)).resizable(e,"option","minHeight",a*Math.min(i.minH||1,d)).resizable(e,"option","maxWidth",s*Math.min(i.maxW||Number.MAX_SAFE_INTEGER,l)).resizable(e,"option","maxWidthMoveLeft",s*Math.min(i.maxW||Number.MAX_SAFE_INTEGER,i.x+i.w)).resizable(e,"option","maxHeight",a*Math.min(i.maxH||Number.MAX_SAFE_INTEGER,d)).resizable(e,"option","maxHeightMoveUp",a*Math.min(i.maxH||Number.MAX_SAFE_INTEGER,i.y+i.h))}}_dragOrResize(e,n,o,i,s,a){const l={...i._orig};let d,c=this.opts.marginLeft,u=this.opts.marginRight,h=this.opts.marginTop,f=this.opts.marginBottom;const g=Math.round(a*.1),m=Math.round(s*.1);if(c=Math.min(c,m),u=Math.min(u,m),h=Math.min(h,g),f=Math.min(f,g),n.type==="drag"){if(i._temporaryRemoved)return;const S=o.position.top-i._prevYPix;i._prevYPix=o.position.top,this.opts.draggable.scroll!==!1&&$.updateScrollPosition(e,o.position,S);const D=o.position.left+(o.position.left>i._lastUiPosition.left?-u:c),B=o.position.top+(o.position.top>i._lastUiPosition.top?-f:h);l.x=Math.round(D/s),l.y=Math.round(B/a);const w=this._extraDragRow;if(this.engine.collide(i,l)){const M=this.getRow();let G=Math.max(0,l.y+i.h-M);this.opts.maxRow&&M+G>this.opts.maxRow&&(G=Math.max(0,this.opts.maxRow-M)),this._extraDragRow=G}else this._extraDragRow=0;if(this._extraDragRow!==w&&this._updateContainerHeight(),i.x===l.x&&i.y===l.y)return}else if(n.type==="resize"){if(l.x<0||($.updateScrollResize(n,e,a),l.w=Math.round((o.size.width-c)/s),l.h=Math.round((o.size.height-h)/a),i.w===l.w&&i.h===l.h)||i._lastTried&&i._lastTried.w===l.w&&i._lastTried.h===l.h)return;const S=o.position.left+c,D=o.position.top+h;l.x=Math.round(S/s),l.y=Math.round(D/a),d=!0}i._event=n,i._lastTried=l;const E={x:o.position.left+c,y:o.position.top+h,w:(o.size?o.size.width:i.w*s)-c-u,h:(o.size?o.size.height:i.h*a)-h-f};if(this.engine.moveNodeCheck(i,{...l,cellWidth:s,cellHeight:a,rect:E,resizing:d})){i._lastUiPosition=o.position,this.engine.cacheRects(s,a,h,u,f,c),delete i._skipDown,d&&i.subGrid&&i.subGrid.onResize(),this._extraDragRow=0,this._updateContainerHeight();const S=n.target;i._sidebarOrig||this._writePosAttr(S,i),this.triggerEvent(n,S)}}triggerEvent(e,n){let o=this;for(;o.parentGridNode;)o=o.parentGridNode.grid;o._gsEventHandler[e.type]&&o._gsEventHandler[e.type](e,n)}_leave(e,n){n=n||e;const o=n.gridstackNode;if(!o||(n.style.transform=n.style.transformOrigin=null,Ce.off(e,"drag"),o._temporaryRemoved))return;o._temporaryRemoved=!0,this.engine.removeNode(o),o.el=o._isExternal&&n?n:e;const i=o._sidebarOrig;o._isExternal&&this.engine.cleanupNode(o),o._sidebarOrig=i,this.opts.removable===!0&&ce._itemRemoving(e,!0),e._gridstackNodeOrig?(e.gridstackNode=e._gridstackNodeOrig,delete e._gridstackNodeOrig):o._isExternal&&this.engine.restoreInitial()}};mt.renderCB=(t,e)=>{t&&e?.content&&(t.textContent=e.content)},mt.resizeToContentParent=".grid-stack-item-content",mt.Utils=$,mt.Engine=_o,mt.GDRev="12.4.2";var eh={class:"d-layout"},th=["gs-id","gs-x","gs-y","gs-w","gs-h","gs-locked","gs-no-resize","gs-no-move","gs-min-w","gs-min-h","gs-max-w","gs-max-h"],nh=(0,r.defineComponent)({name:"DLayout",__name:"layout",props:{modelValue:{default:()=>[]},column:{default:24},cellHeight:{default:60},draggable:{type:Boolean,default:!0},resizable:{type:Boolean,default:!0},disable:{type:Boolean,default:!1},animate:{type:Boolean,default:!0},float:{type:Boolean,default:!0},removable:{type:Boolean,default:!1},removableOptions:{}},emits:["update:modelValue","added","removed","changed","dragStart","dragStop","resizeStart","resizeStop"],setup(t,{expose:e,emit:n}){const o=t,i=n,s=(0,r.ref)();let a=null;const l=async()=>{s.value&&(await(0,r.nextTick)(),a&&a.destroy(!1),a=mt.init({column:o.column,cellHeight:o.cellHeight,disableDrag:!(o.draggable&&!o.disable),disableResize:!(o.resizable&&!o.disable),animate:o.animate,float:o.float,removable:o.removable,removableOptions:o.removableOptions},s.value),a.on("added",(f,g)=>{const m=g[0];m&&(i("added",d(m)),u())}),a.on("removed",(f,g)=>{const m=g[0];m&&(i("removed",d(m)),u())}),a.on("change",()=>{u(),i("changed",(a?.save()||[]).map(f=>d(f)))}),a.on("dragstart",(f,g)=>{g&&i("dragStart",f,d(g.gridstackNode||g))}),a.on("dragstop",(f,g)=>{g&&i("dragStop",f,d(g.gridstackNode||g))}),a.on("resizestart",(f,g)=>{g&&i("resizeStart",f,d(g.gridstackNode||g))}),a.on("resizestop",(f,g)=>{g&&i("resizeStop",f,d(g.gridstackNode||g))}))},d=f=>({id:f.id||f.el?.getAttribute("gs-id")||"",x:f.x||0,y:f.y||0,w:f.w||1,h:f.h||1,locked:f.locked||!1,noResize:f.noResize||!1,noMove:f.noMove||!1,minW:f.minW,minH:f.minH,maxW:f.maxW,maxH:f.maxH}),c=async()=>{if(!a||!s.value)return;await(0,r.nextTick)();const f=a.engine.nodes;new Set(f.map(m=>m.id));const g=new Set(o.modelValue.map(m=>m.id));f.forEach(m=>{if(!g.has(m.id||"")){const E=m.el;E&&a&&a.removeWidget(E,!1)}}),o.modelValue.forEach(m=>{const E=f.find(S=>S.id===m.id);if(E)E.el&&a&&a.update(E.el,{x:m.x,y:m.y,w:m.w,h:m.h,locked:m.locked,noResize:m.noResize,noMove:m.noMove,minW:m.minW,minH:m.minH,maxW:m.maxW,maxH:m.maxH});else{if(!s.value||!a)return;const S=s.value.querySelector(`[gs-id="${m.id}"]`);S&&a.makeWidget(S)}})},u=()=>{a&&i("update:modelValue",a.save().map(f=>{const g={id:f.id||"",x:f.x||0,y:f.y||0,w:f.w||1,h:f.h||1},m=o.modelValue.find(E=>E.id===g.id);return m&&Object.keys(m).forEach(E=>{["id","x","y","w","h"].includes(E)||(g[E]=m[E])}),g}))},h=(0,r.computed)(()=>o.modelValue);return(0,r.watch)(()=>o.modelValue,async()=>{a&&(await(0,r.nextTick)(),c())},{deep:!0}),(0,r.watch)(()=>[o.column,o.cellHeight,o.draggable,o.resizable,o.disable,o.animate,o.float,o.removable],()=>{l()}),(0,r.onMounted)(()=>{l()}),(0,r.onBeforeUnmount)(()=>{a&&(a.destroy(!1),a=null)}),e({addItem:async f=>{if(a&&s.value){await(0,r.nextTick)();const g=s.value.querySelector(`[gs-id="${f.id}"]`);g&&(a.makeWidget(g),a.update(g,{x:f.x,y:f.y,w:f.w,h:f.h,locked:f.locked,noResize:f.noResize,noMove:f.noMove,minW:f.minW,minH:f.minH,maxW:f.maxW,maxH:f.maxH}))}},removeItem:f=>{if(a&&s.value){const g=s.value.querySelector(`[gs-id="${f}"]`);g&&a.removeWidget(g,!1)}},clear:()=>{a&&a.removeAll(!1)},getGrid:()=>a}),(f,g)=>((0,r.openBlock)(),(0,r.createElementBlock)("div",eh,[(0,r.createElementVNode)("div",{ref_key:"gridContainerRef",ref:s},[((0,r.openBlock)(!0),(0,r.createElementBlock)(r.Fragment,null,(0,r.renderList)(h.value,m=>((0,r.openBlock)(),(0,r.createElementBlock)("div",{key:m.id,"gs-id":m.id,"gs-x":m.x,"gs-y":m.y,"gs-w":m.w,"gs-h":m.h,"gs-locked":m.locked,"gs-no-resize":m.noResize,"gs-no-move":m.noMove,"gs-min-w":m.minW,"gs-min-h":m.minH,"gs-max-w":m.maxW,"gs-max-h":m.maxH,class:"d-layout-item"},[(0,r.renderSlot)(f.$slots,"item",{item:m})],8,th))),128))],512)]))}}),oh=nh,Mr=qe(oh),be=(t,e="",n=!1)=>n?`${t}pt`:e?`${t}${e}`:`${t}px`,xe=(t,e=0)=>t==null||isNaN(t)?0:Number(Number(t).toFixed(e)),ih=t=>t*3/4,rh=t=>t*4/3,sh=["onMousedown"],ah={key:2,class:"d-draggable__mask"},lh=(0,r.defineComponent)({name:"DDraggable",__name:"draggable",props:{index:{},mask:{type:Boolean,default:!0},scale:{default:1},readonly:{type:Boolean,default:!1},resize:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},step:{default:1},zIndex:{default:1},isActiveBgTransparent:{type:Boolean,default:!1},left:{default:0},top:{default:0},width:{},height:{},activeFlag:{type:Boolean,default:!1},isPt:{type:Boolean,default:!1}},emits:["focus","blur","over","out"],setup(t,{expose:e,emit:n}){const o=t,i=n,s=(0,r.ref)(),a=(0,r.ref)(),l=(0,r.ref)(0),d=(0,r.ref)(0),c=(0,r.ref)(0),u=(0,r.ref)(0),h=(0,r.ref)(null),f=(0,r.ref)(!1),g=(0,r.ref)(!1),m=(0,r.ref)(!1),E=(0,r.ref)(!1),S=(0,r.ref)([{classname:"left"},{classname:"right"},{classname:"top"},{classname:"bottom"},{classname:"top-left"},{classname:"top-right"},{classname:"bottom-left"},{classname:"bottom-right"}]),D=(0,r.computed)(()=>o.scale),B=(0,r.computed)(()=>({left:be(D.value,"",o.isPt)})),w=(0,r.computed)(()=>({left:be(-D.value,"",o.isPt)})),M=(0,r.computed)(()=>({left:"auto",right:be(-D.value,"",o.isPt)})),G=(0,r.computed)(()=>({top:be(-D.value,"",o.isPt)})),R=(0,r.computed)(()=>({top:"auto",bottom:be(-D.value,"",o.isPt)})),q=(0,r.computed)(()=>{const V=8*D.value;return{width:be(V,"",o.isPt),height:be(V,"",o.isPt)}}),K=(0,r.computed)(()=>({fontSize:be(16*D.value,"",o.isPt)})),j=(0,r.computed)(()=>Object.assign((()=>{if(E.value){const V={zIndex:9999,...B.value};return o.isActiveBgTransparent&&(E.value||g.value)&&!o.readonly&&!o.disabled&&(V.backgroundColor="color-mix(in srgb, var(--j-color-primary-bg) 60%, transparent)"),V}return{zIndex:o.zIndex}})(),{top:be(u.value,"",o.isPt),width:be(l.value,"",o.isPt),height:be(d.value,"",o.isPt),padding:be(8*D.value,"",o.isPt),...B.value,left:be(c.value,"",o.isPt)}));(0,r.watch)(()=>o.width,V=>{l.value=xe(F(V))||(h.value?.offsetWidth??0)}),(0,r.watch)(()=>o.height,V=>{d.value=xe(F(V))||(h.value?.offsetHeight??0)},{deep:!0}),(0,r.watch)(()=>o.left,V=>{c.value=xe(F(V))}),(0,r.watch)(()=>o.top,V=>{u.value=xe(F(V))}),(0,r.watch)(l,V=>{s.value&&(s.value.style.width=be(V,"",o.isPt),o.resize&&h.value?.style&&(h.value.style.width=be(V,"",o.isPt)))}),(0,r.watch)(d,V=>{s.value&&(s.value.style.height=be(V,"",o.isPt),o.resize&&h.value?.style&&(h.value.style.height=be(V,"",o.isPt)))}),(0,r.watch)(()=>o.activeFlag,V=>{Z(V)});const Z=V=>{E.value=V},F=V=>V===void 0?0:o.isPt?rh(V):V,k=()=>{a.value&&a.value.firstChild&&(h.value=a.value.firstChild,l.value=xe(F(o.width))||(h.value?.offsetWidth??0),d.value=xe(F(o.height))||(h.value?.offsetHeight??0),c.value=xe(F(o.left)),u.value=xe(F(o.top)),Z(o.activeFlag))},W=V=>{c.value=V},b=V=>{u.value=V},P=V=>{const X=8*D.value/2,A={};return V.split("-").forEach(U=>{A[U]=be(-X,"",o.isPt)}),A},v=V=>{g.value=V},N=V=>o.isPt?ih(V):V,I=()=>{f.value=!0,i("focus",{index:o.index,width:N(l.value),height:N(d.value),left:N(c.value),top:N(u.value)})},T=()=>{f.value=!1,m.value=!1,i("blur",{index:o.index,width:N(l.value),height:N(d.value),left:N(c.value),top:N(u.value)})},z=()=>{document.onmouseup=()=>{document.onmousemove=null,document.onmouseup=null,T()}},O=(V,X)=>{if(o.disabled||o.readonly)return;let A,U,te,ie,le,J;m.value=!0,I();let re=V.clientX,x=V.clientY;document.onmousemove=p=>{f.value=!0,X==="right"?(A=!0,U=!1):X==="left"?(A=!0,te=!0,le=!0,U=!1):X==="top"?(A=!1,U=!0,ie=!0,J=!0):X==="bottom"?(A=!1,U=!0):X==="bottom-right"?(A=!0,U=!0):X==="bottom-left"?(A=!0,U=!0,te=!0,le=!0):X==="top-right"?(A=!0,U=!0,ie=!0,J=!0):X==="top-left"&&(A=!0,U=!0,te=!0,le=!0,ie=!0,J=!0);const y=p.clientX-re,C=p.clientY-x;if(re=p.clientX,x=p.clientY,A){let _=y*o.step;le&&(_=-_),te&&(c.value=xe(c.value-_)),l.value=xe(l.value+_)}if(U){let _=C*o.step;J&&(_=-_),ie&&(u.value=xe(u.value-_)),d.value=xe(d.value+_)}},z()},L=()=>{g.value=!1,i("out",{index:o.index,width:N(l.value),height:N(d.value),left:N(c.value),top:N(u.value)})},ee=()=>{o.disabled||o.readonly||(g.value=!0,i("over",{index:o.index,width:N(l.value),height:N(d.value),left:N(c.value),top:N(u.value)}))},se=V=>{if(o.disabled||o.readonly)return;E.value=!0,I();let X=V.clientX,A=V.clientY;document.onmousemove=U=>{const te=U.clientX-X,ie=U.clientY-A;X=U.clientX,A=U.clientY,c.value=xe(c.value+te*o.step),u.value=xe(u.value+ie*o.step)},z()};return(0,r.onMounted)(()=>{k()}),e({setActive:Z,setLeft:W,setTop:b,setOverActive:v}),(V,X)=>((0,r.openBlock)(),(0,r.createElementBlock)("div",{class:(0,r.normalizeClass)(["d-draggable",{"d-draggable--active":(E.value||g.value)&&!t.readonly&&!t.disabled},{"d-draggable--pt":t.isPt&&!t.readonly&&!t.disabled},{"d-draggable--move":f.value},{"d-draggable--click":t.disabled}]),onMousedown:(0,r.withModifiers)(se,["stop"]),onMouseover:(0,r.withModifiers)(ee,["stop"]),onMouseout:(0,r.withModifiers)(L,["stop"]),style:(0,r.normalizeStyle)(j.value)},[(0,r.createElementVNode)("div",{class:"d-draggable__wrapper",ref_key:"wrapper",ref:s},[(E.value||g.value||f.value)&&!t.readonly&&!t.disabled?((0,r.openBlock)(),(0,r.createElementBlock)(r.Fragment,{key:0},[(0,r.createElementVNode)("div",{style:(0,r.normalizeStyle)({...B.value,...G.value}),class:"d-draggable__line d-draggable__line--left"},null,4),(0,r.createElementVNode)("div",{style:(0,r.normalizeStyle)({...B.value,...w.value}),class:"d-draggable__line d-draggable__line--top"},null,4),t.isPt?((0,r.openBlock)(),(0,r.createElementBlock)(r.Fragment,{key:1},[(0,r.createElementVNode)("div",{style:(0,r.normalizeStyle)({...B.value,...G.value,transform:"none"}),class:"d-draggable__line d-draggable__line--left"},null,4),(0,r.createElementVNode)("div",{style:(0,r.normalizeStyle)({...B.value,...w.value,transform:"none"}),class:"d-draggable__line d-draggable__line--top"},null,4),(0,r.createElementVNode)("div",{style:(0,r.normalizeStyle)({...B.value,...R.value}),class:"d-draggable__line d-draggable__line--left"},null,4),(0,r.createElementVNode)("div",{style:(0,r.normalizeStyle)({...B.value,...M.value}),class:"d-draggable__line d-draggable__line--top"},null,4),(0,r.createElementVNode)("div",{style:(0,r.normalizeStyle)({...B.value,...R.value,transform:"none"}),class:"d-draggable__line d-draggable__line--left"},null,4),(0,r.createElementVNode)("div",{style:(0,r.normalizeStyle)({...B.value,...M.value,transform:"none"}),class:"d-draggable__line d-draggable__line--top"},null,4)],64)):((0,r.openBlock)(),(0,r.createElementBlock)("div",{key:0,class:"d-draggable__line d-draggable__line--label",style:(0,r.normalizeStyle)(K.value)},(0,r.toDisplayString)(c.value)+","+(0,r.toDisplayString)(u.value),5))],64)):(0,r.createCommentVNode)("",!0),!t.readonly&&!t.disabled?((0,r.openBlock)(!0),(0,r.createElementBlock)(r.Fragment,{key:1},(0,r.renderList)(S.value,(A,U)=>((0,r.openBlock)(),(0,r.createElementBlock)(r.Fragment,{key:U},[E.value?((0,r.openBlock)(),(0,r.createElementBlock)("div",{key:0,class:(0,r.normalizeClass)(["d-draggable__range",`d-draggable__range--${A.classname}`]),style:(0,r.normalizeStyle)([q.value,P(A.classname)]),onMousedown:(0,r.withModifiers)(te=>O(te,A.classname),["stop"])},null,46,sh)):(0,r.createCommentVNode)("",!0)],64))),128)):(0,r.createCommentVNode)("",!0),(0,r.createElementVNode)("div",{class:"d-draggable__item",ref_key:"item",ref:a},[(0,r.renderSlot)(V.$slots,"default")],512),!t.disabled&&t.mask?((0,r.openBlock)(),(0,r.createElementBlock)("div",ah)):(0,r.createCommentVNode)("",!0)],512)],38))}}),ch=lh,Ir=qe(ch),dh=t=>{const e=uh(t.components);return{formConfig:t.form,componentList:e}},Br=(t,e)=>{let n={},o=[];const i={};if(t.ver==="V3"){const s=t;n=s.form;const a={};s.components.forEach(l=>{const d=e[l.type];a[l.containerId]=a[l.containerId]||[];const c={id:l.id,name:l.name,type:l.type,dragType:d?.dragType||"component",componentName:d?.componentName||"",runtimeType:d?.runtimeType,groupId:l.groupId,config:l.config,isInput:d?.isInput!==!1,containerId:l.containerId,level:l.level};d?.dragType==="container"&&(c.children=[]),i[c.id]=c,a[l.containerId].push(c)}),Object.keys(a).forEach(l=>{i[l]&&(i[l].children=a[l])}),o=a.form||[]}return{formConfig:n,componentList:o,componentDic:i}},bo=(t,e)=>{const n={ver:"V3",form:{...t},components:[],db:{}};return zr(e||[],n.components),n},zr=(t,e)=>{t.forEach(n=>{if(n.type==="pkey")return;const o={id:n.id,name:n.name,type:n.type,runtimeType:n.runtimeType||n.componentName||n.type,groupId:n.groupId||"",config:n.config,containerId:n.containerId,level:n.level};n.dragType==="container"&&zr(n.children||[],e),e.push(o)})},uh=t=>{const e={},n={};return t.forEach(o=>{e[o.containerId]=e[o.containerId]||[];const i={id:o.id,type:o.runtimeType,slot:o.groupId,config:{rule:[]}};o.config&&Object.keys(o.config).forEach(s=>{if(s==="required"){o.config.required&&i.config?.rule?.push({required:!0,message:o.config.requiredMsg||"请输入"});return}if(s==="patterns"){o.config.patterns.forEach(a=>{a.reg&&a.msg&&i.config?.rule?.push({pattern:new RegExp(a.reg),message:`请输入${a.msg||""}`})});return}i.config[s]=o.config[s]}),o.type==="pkey"&&(i.config.isPkey=!0),e[o.containerId].push(i),n[o.id]=i}),Object.keys(e).forEach(o=>{const i=n[o];if(i){const s=e[o];if(["j-tabs","j-collapse"].includes(i.type||"")&&i.config?.groups){const a={};s.forEach(l=>{if(l.slot!==void 0&&l.slot!==null){const d=l.slot.toString();a[d]||(a[d]=[]),delete l.slot,a[d].push(l)}}),i.children=i.config.groups.map(l=>{const d=a[l._i]||[],c={label:l.label};l.active&&i.type==="j-collapse"&&(c.active=l.active);let u;if(i.type==="j-tabs"&&i.config?.tabKey&&i.config?.options.length>0){const f=i.config.options.find(g=>g.label===l._i);f&&(u=({formData:g})=>({display:f.value.includes(g[i.config?.tabKey||""])?f.display:!f.display}))}const h={config:c,children:d};return u&&(h.getCompConfig=u),h}),delete i.config.groups}else i.children=s}}),e.form},Rr=(t,e,n,o,i,s,a,l)=>{const d=(0,r.ref)(),c=(0,r.reactive)({}),u=(0,r.computed)(()=>{const v=[];return Object.keys(c).forEach(N=>{const I=c[N];I.dragType==="component"&&I.type!=="pkey"&&v.push(I)}),v}),h=(v=[],N)=>{const I=e?.value?.init;typeof I=="function"&&I(v,N)},f=v=>i?i(v,{componentDic:c,components:u.value,configData:d.value.config}):{},g=(v,N)=>{if(d.value?.id===v)return;const I=c[v]||N;if(I?d.value=I:v===n.id?d.value=n:d.value=null,d.value){const T=s[d.value.type];T?(h(T,d.value.config),f(d.value.type)):h([])}else h([]);N&&ye("dragClick",{id:N.id})},m=()=>t.value.$el.getBoundingClientRect(),E=v=>v===n.id?n:c[v]||{},S=v=>{const N=[];if(v===n.id)N.push({id:v,name:n.name});else{const I=c[v];if(I){N.push({id:v,name:I.name});const T=S(I.containerId);N.push(...T)}}return N},D=(v,N)=>{const I=c[N];if(I===void 0)return!1;const T=I.containerId;return v===T?!0:T===n.id?!1:D(v,T)},B=v=>o?o(v)||{}:{},w=(v,N,I,T)=>{if(l){const z=E(v);return l(I.componentType,{container:z,groupId:N,configData:I},T)}return!1},M=({name:v,type:N,dragType:I,isInput:T,componentName:z,runtimeType:O},L,ee,se,V=!1)=>{const X=B(N);if(X.id=rt(),X.span=24,X.componentType=N,G(L,X.componentType))return;w(L,se,X,!0);const A={id:X.id,name:v,type:N,runtimeType:O,componentName:z||"",dragType:I||"component",containerId:L,isInput:!!T,level:c[L]?c[L].level+1:1,config:X,isNewAdd:!V,groupId:se};return A.dragType==="container"&&(A.children=[]),c[A.id]=A,E(L).children?.splice(ee,0,A),A},G=(v,N)=>!!(E(v).config.componentType==="gridtable"&&["divider","label","text","textEditor","viewTable","card","collapse","tabs","qrcode","barcode","tableLayout"].includes(N)),R=(v,N,I=!1)=>{let T=null;const z=E(v).children,O=z?.findIndex(L=>L.id===N)||0;if(I&&z&&z.length>1){let L=O+1;O>0&&(L=O-1),T=z[L]}return z?.splice(O,1),T?.id},q=(v,N,I,T)=>{const z=E(N).children,O=v.containerId!==N;v.containerId=N,v.groupId=T,z?.splice(I,0,v),w(N,T,v.config,O)&&(W(),g(v.id))},K=v=>{let N="";const I=E(v);return I&&(I.children&&I.children.length>0&&I.children.forEach(T=>{K(T.id)}),N=R(I.containerId,v,!0)||"",delete c[v]),d.value&&d.value.id===v&&(d.value=null,e.value.init([])),N},j=(v,N=[])=>{const I=E(v);if(I&&I.children&&I.children.length>0){const T=[];I.children.forEach(z=>{z.groupId&&N.includes(z.groupId)&&T.push(z.id)}),T.forEach(z=>{K(z),delete c[z]})}},Z=(v,N)=>{const I=E(v);I&&(I.children&&I.children.length>0&&I.children.forEach(T=>{T.groupId===N&&K(T.id)}),delete c[v])},F=v=>{const N=Sn(E(v));N.id=rt(),N.config.id=N.id,c[N.id]=N;const I=E(N.containerId).children,T=I?.findIndex(z=>z.id===v)||0;I?.splice(T+1,0,N)},k=()=>{n.children=[],Wr(c),d.value&&(ye("dragClick",{id:""}),d.value=null,e.value.init([]))},W=()=>{d.value&&(ye("dragClick",{id:""}),d.value=null,e.value.init([]))},b=v=>{const N=d.value,I=E(N.containerId).children,T=I?.findIndex(z=>z.id===N.id)||0;K(N.id),(0,r.nextTick)(()=>{const z=a[v],O=B(v);O.id=N.id,O.span=N.config.span,O.componentType=v,O.table=N.config.table,O.field=N.config.field,N.config.isSubTable&&(O.isSubTable=N.config.isSubTable);const L={id:O.id,name:z.name,type:v,runtimeType:z.runtimeType,componentName:z.componentName||"",dragType:N.dragType,groupId:N.groupId,containerId:N.containerId,isInput:N.isInput,level:N.level,config:O,isNewAdd:!0};c[L.id]=L,I?.splice(T,0,L)})},P=v=>{ye("dragAddByClick",v)};return(0,r.provide)("d-drag-design-provide",{activedComponent:d,getDesignLocals:m,getComponent:E,getParentComponents:S,isMyChildComponent:D,selectComponent:g,addComponent:M,deleteComponent:K,copyComponent:F,removeComponentFromContainer:R,addComponentToContainer:q,top:n,deleteChildren:Z,deleteChildrens:j}),{activedComponent:d,clearComponents:k,changeComponent:b,schemaComponentDic:c,clearSelect:W,addComponent:M,addComponentByTable:P,designComponentList:u}},fh=(0,r.defineComponent)({__name:"importComponent",props:{componentList:{type:Array,default:()=>[]},tableList:{type:Array,default:()=>[]}},setup(t,{expose:e}){const n=t,o=(0,r.computed)(()=>n.tableList.map(c=>({label:c.comment?`${c.name}(${c.comment})`:c.name,value:c.name}))),i=(0,r.ref)(),s=[{id:"layout",type:"j-layout",config:{top:48,topMove:!1,autoSize:["default"]},children:[{id:"table",type:"j-select",slot:"top",config:{label:"表名选择",loadOptions:()=>o,allowClear:!1}},{id:"fields",type:"j-table",config:{editConfig:{isAddBtn:!1,isRemoveBtn:!1},height:"100%",isMultiple:!0},children:[{id:"name",type:"span",config:{label:"字段名"}},{id:"type",type:"j-select",config:{label:"组件选择",options:n.componentList,width:200}}]}]}],a=(c,u)=>{if(c.id==="table"){const h=n.tableList.find(f=>f.name===u.value);if(h){const f=h.columns.map(g=>({value:g.name,name:g.coment?`${g.name}(${g.coment})`:g.name,type:"input",label:g.coment||g.name,selected:!g.isPrimary}));i.value.setFormData({fields:f})}}};return(0,r.onMounted)(()=>{i.value.init(s)}),e({ok:()=>{const c=i.value.getFormData(!1);return{addList:c.fields.filter(u=>u.selected),table:c.table,containerId:c.containerId,isSubTable:c.isSubTable}},closed:()=>{}}),(c,u)=>{const h=(0,r.resolveComponent)("j-form");return(0,r.openBlock)(),(0,r.createBlock)(h,{ref_key:"formRef",ref:i,"form-config":{labelWidth:"72px"},onChange:a},null,512)}}}),hh=fh,gh=(0,r.defineComponent)({props:{componentData:{type:Object,default:()=>({})},globalConfig:{type:Object,default:()=>({})}},setup(t){const{t:e}=(0,Ke.useAppInject)();return{labelWidth:(0,r.computed)(()=>t.componentData.config?.notShowLabel?"0px":t.componentData.config?.labelWidth===void 0&&t.globalConfig.labelWidth!==void 0?`${t.globalConfig.labelWidth}px`:t.componentData.config?.labelWidth?`${t.componentData.config?.labelWidth}px`:void 0),inputConfig:(0,r.computed)(()=>{const n={...t.componentData?.config};return t.globalConfig.size===void 0&&(n.size=t.globalConfig.size),n.display=!0,n}),t:e}}}),ph=(t,e)=>{const n=t.__vccOpts||t;for(const[o,i]of e)n[o]=i;return n};function mh(t,e,n,o,i,s){const a=(0,r.resolveComponent)("j-comp"),l=(0,r.resolveComponent)("el-form-item");return t.componentData.isInput?((0,r.openBlock)(),(0,r.createBlock)(l,{key:0,"label-width":t.labelWidth,label:t.t(t.componentData.config?.notShowLabel?"":t.componentData.config?.label||""),rules:t.componentData.config?.required?[{required:!0,message:""}]:[]},{default:(0,r.withCtx)(()=>[(0,r.createVNode)(a,{type:t.componentData?.componentName||t.componentData?.type,config:t.inputConfig,modelValue:t.componentData?.config.defaultValue},null,8,["type","config","modelValue"])]),_:1},8,["label-width","label","rules"])):t.componentData?.children?((0,r.openBlock)(),(0,r.createBlock)((0,r.resolveDynamicComponent)(t.componentData?.componentName),(0,r.mergeProps)({key:1},t.componentData?.config,{"global-config":t.globalConfig,"component-data":t.componentData}),null,16,["global-config","component-data"])):((0,r.openBlock)(),(0,r.createBlock)((0,r.resolveDynamicComponent)(t.componentData?.componentName),(0,r.normalizeProps)((0,r.mergeProps)({key:2},t.componentData?.config)),null,16))}var Ar=ph(gh,[["render",mh]]),yh={class:"d-form-design j-block"},vh={class:"d-form-design-left"},_h={class:"d-form-design-component-list"},wh={class:"j-component-tool"},bh={class:"j-component-tool-name"},Ch={class:"d-form-design-center"},Eh={class:"d-form-design-container"},xh={key:0,class:"d-form-design-empty"},Nh={class:"d-form-design-right"},kh={class:"d-form-design-panel-title"},Sh={style:{margin:"0","font-size":"14px"}},Dh={class:"d-form-design-panel"},Th=(0,r.defineComponent)({name:"DFormDesign",__name:"formDesign",props:{notBindTable:{type:Boolean,default:!1},components:{default:()=>[]},componentConfigs:{default:()=>({})},componentInit:{type:Function,default:void 0},containerAddComponent:{type:Function,default:void 0},componentConfigInit:{type:Function,default:void 0},componentConfigChange:{type:Function,default:void 0},componentConfigValidate:{type:Function,default:void 0},flowComponents:{default:()=>[]},flowInit:{type:Function,default:void 0},flowComponentConfigInit:{type:Function,default:void 0},flowComponentConfigChange:{type:Function,default:void 0},flowComponentConfigs:{default:()=>({})},actions:{}},setup(t,{expose:e}){const n=t,{t:o,warning:i,error:s}=(0,Ke.useAppInject)(),a=(0,r.reactive)({name:"表单",id:"form",type:"form",level:0,children:[],dragType:"container",componentName:"",containerId:"",isInput:!1,config:{}}),l=(0,r.ref)([]),d=n.components.length;for(let p=0;p<d;p++)l.value.push(p);n.componentInit&&(a.config=n.componentInit("form")||{});const c=(0,r.ref)([]),u=(0,r.computed)(()=>c.value.map(p=>({label:p.comment?`${p.name}(${p.comment})`:p.name,value:p.name}))),h=(0,r.computed)(()=>{if(R.value){const p=G.value.getFormData(!1);if(p.table){const y=c.value.find(C=>C.name===p.table);if(y)return y.columns.map(C=>({value:C.name,label:C.coment?`${C.name}(${C.coment})`:C.name,coment:C.coment}))}}return[]}),f=p=>{c.value=p},g={},m=[];n.components.forEach(({children:p})=>{p.forEach(y=>{g[y.type]=y,y.dragType=y.dragType||"component",y.isInput!==!1&&(y.isInput=!0,m.push({label:y.name,value:y.type}))})});const E=p=>{p.forEach(y=>{y.type==="d-input-flow"&&(y.config=y.config||{},y.config.flowComponents=n.flowComponents,y.config.flowInit=n.flowInit,y.config.flowComponentConfigInit=C=>{n.flowComponentConfigInit&&(C.designComponents=F.value,C.component=R.value,n.flowComponentConfigInit(C))},y.config.flowComponentConfigs=n.flowComponentConfigs,y.config.flowComponentConfigChange=n.flowComponentConfigChange),y.children&&E(y.children)})},S={};Object.keys(n.componentConfigs||{}).forEach(p=>{const{hasBase:y,isInput:C,hasTwoPlaceholder:_,hasPlaceholder:Y,hasSpan:H,hasLabel:oe,bindTable:Q,labelTitle:ue}=g[p]||{hasBase:!1},fe=[{id:"id",type:"j-input",config:{label:"ID",readonly:!0}},{id:"componentType",type:"j-select",config:{label:"类型",allowClear:!1,display:C,options:m}},{id:"label",type:"j-input",config:{label:ue||"标题"},getCompConfig:({formData:he})=>({display:oe!==!1&&!he.notShowLabel})},{id:"notShowLabel",type:"j-switch",config:{label:"不显示"+(ue||"标题"),activeValue:!0,inactiveValue:!1},getCompConfig:({formData:he})=>({display:oe!==!1&&!he.isSubTable})},{id:"labelWidth",type:"j-number",config:{label:"标题宽度"},getCompConfig:({formData:he})=>({display:C&&!he.notShowLabel&&!he.isSubTable})},{id:"placeholder",type:"j-input",config:{display:C&&!_&&Y!==!1,label:"占位提示"}},{id:"startPlaceholder",type:"j-input",config:{display:!!_,label:"开始占位"}},{id:"endPlaceholder",type:"j-input",config:{display:!!_,label:"结束占位"}},{id:"span",type:"j-slider",config:{label:"表单栅栏",min:6,max:24,showTooltip:!0,step:6,showStops:!0,defautValue:24},getCompConfig:({formData:he})=>({display:H!==!1&&!he.isSubTable})},{id:"width",type:"j-number",config:{label:"单元格宽度",min:1},getCompConfig:({formData:he})=>({display:!!he.isSubTable})},{id:"isNotSave",type:"j-switch",config:{label:"不存表",display:C&&Q!==!1,activeValue:!0,inactiveValue:!1}},{id:"table",type:"j-select",config:{label:"数据表",loadOptions:()=>u},getCompConfig:({formData:he})=>({display:(C&&Q!==!1||Q===!0)&&(!he.isSubTable||Q===!0)&&!he.isNotSave&&!n.notBindTable})},{id:"field",type:"j-select",config:{label:"表字段",loadOptions:()=>h},getCompConfig:({formData:he})=>({display:C&&Q!==!1&&!he.isNotSave&&!n.notBindTable})},{id:"csType",type:"j-select",config:{label:"字段类型",allowClear:!1,options:[{label:"短文本",value:"string"},{label:"长文本",value:"text"},{label:"整数",value:"int"},{label:"小数",value:"decimal"},{label:"时间日期",value:"DateTime"}]},getCompConfig:({formData:he})=>({display:C&&Q!==!1&&!he.isNotSave&&n.notBindTable})},{id:"fieldLen",type:"j-number",config:{label:"字段长度"},getCompConfig:({formData:he})=>({display:C&&Q!==!1&&!he.isNotSave&&n.notBindTable&&he.csType==="string"})}],ge={type:"j-collapse",config:{defaultValue:[]},children:[]};y!==!1&&(ge.children?.push({config:{label:"基础信息"},children:[...fe]}),ge.config?.defaultValue.push("_collapse0")),ge.children?.push(...n.componentConfigs[p]),E(ge.children||[]),S[p]=[ge]});const D=p=>{const{value:y}=p||{};p.id==="componentType"&&K(y),R.value&&n.componentConfigChange&&(p.id==="field"&&p.data?.coment&&(R.value.config.label=p.data?.coment),n.componentConfigChange(R.value.type,{configRef:G,configData:R.value.config,...p})),p.id==="table"&&R.value&&R.value.type==="gridtable"&&(R.value.children||[]).forEach(C=>{C.isInput&&(C.config.table=y)})},B=(p,y)=>{g[p]?.isInput&&(n.notBindTable&&(y.configData.csType||G.value.setFormData({main:{csType:g[p]?.csType,fieldLen:g[p]?.fieldLen}})),u.value.length===1&&G.value.setFormData({main:{table:u.value[0].value}})),n.componentConfigInit&&n.componentConfigInit(p,{configRef:G,...y,notBindTable:n.notBindTable})},w=(p,y,C)=>{let _=!1;const Y=g[p];return y.container.type==="gridtable"?(!y.configData.isSubTable||C)&&(y.configData.isSubTable=!0,Y.isInput&&(y.configData.table=y.container.config.table,y.configData.field=""),_=!0):y.configData.isSubTable&&(_=!0,y.configData.isSubTable=!1,Y.isInput&&(y.configData.table="")),n.containerAddComponent&&n.containerAddComponent(p,y),_},M=(0,r.ref)(),G=(0,r.ref)(),{activedComponent:R,clearComponents:q,changeComponent:K,schemaComponentDic:j,addComponentByTable:Z,designComponentList:F}=Rr(M,G,a,n.componentInit,B,S,g,w),k=(0,r.computed)(()=>R.value?`【${R.value.name}】`:"");(0,r.provide)("dui-design-provide",{designItemName:Ar});const W=()=>{n.componentInit&&(a.config=n.componentInit("form")||{}),q()},b=()=>{let p=0;const y=bo(a.config,a.children||[]);if(n.notBindTable){const C={};y.components.forEach(H=>{const{isInput:oe,bindTable:Q}=g[H.type]||{hasBase:!1};oe&&Q!==!1?H.config.table&&!C.main&&(C.main={name:H.config.table,comment:"主表",type:"main",pKey:"J_Id"}):Q&&(C[H.id]={name:H.config.table||"t"+new Date().getTime()+p,comment:`子表${H.config.label}`,type:"chlid",field:"J_PId",relationField:"J_Id",pKey:"J_Id"},H.config.table=C[H.id].name,p++)}),C.main||(C.main={name:"t"+new Date().getTime()+p,comment:"主表",type:"main",pKey:"J_Id"},p++);let _=0;y.components.forEach(H=>{const{isInput:oe,bindTable:Q}=g[H.type]||{hasBase:!1};!H.config.isNotSave&&oe&&Q!==!1&&(H.config.csType||(H.config.csType=g[H.type]?.csType,H.config.fieldLen=g[H.type]?.fieldLen),H.config.isSubTable?H.config.table=C[H.containerId].name:H.config.table=C.main.name,H.config.field=H.config.field||`f${Math.floor(Date.now()/1e3)}${_}`,_++)});const Y=[];Object.keys(C).forEach(H=>{C[H].type==="chlid"&&(C[H].relationName=C.main.name,C[H].comment+=`,关联主表${C.main.name}`),Y.push(C[H])}),y.db=Y}else{const C={};c.value.forEach(_=>{_.columns.forEach(Y=>{C[`${_.name}_${Y.name}`]=Y.csType})}),y.components.forEach(_=>{_.config.table&&_.config.field&&(_.config.csType=C[`${_.config.table}_${_.config.field}`])})}return n.notBindTable?y.db.forEach(C=>{if(!y.components.find(_=>_.config.table===C.name&&_.config.field==="J_Id")){const _=y.components.find(Y=>Y.config.table===C.name&&Y.config.field);_&&y.components.push({id:C.name+"_J_Id",name:C.name+"_J_Id",type:"pkey",runtimeType:"j-input",groupId:"",config:{display:!1,table:C.name,field:"J_Id",label:"主键"},containerId:_.containerId,level:_.level})}}):c.value.forEach(C=>{C.columns.forEach(_=>{if(_.isPrimary&&!y.components.find(Y=>Y.config.table===C.name&&Y.config.field===_.name)){const Y=y.components.find(H=>H.config.table===C.name&&H.config.field);Y&&y.components.push({id:C.name+"_"+_.name,name:C.name+"_"+_.name,type:"pkey",runtimeType:"j-input",groupId:"",config:{display:!1,table:C.name,field:_.name,label:"主键"+_.name,isIdentity:_.isIdentity},containerId:Y.containerId,level:Y.level})}})}),y},P=p=>{const y=Br(p,g);a.config=y.formConfig,a.children?.push(...y.componentList),Object.keys(y.componentDic).forEach(C=>{j[C]=y.componentDic[C]})},v=()=>I(bo(a.config,a.children||[]).components,{},{}),N=p=>{const{isInput:y,bindTable:C}=g[p]||{hasBase:!1};if(!y&&C)return!0},I=(p,y,C)=>{if(!n.notBindTable)for(const _ of p){const{isInput:Y,bindTable:H}=g[_.type]||{hasBase:!1};if(!_.config.isNotSave&&_.type!=="pkey"){if(Y&&H!==!1){if((0,Ke.isNullOrEmpty)(_.config.table))return s&&s(`请【${_.config.label}】绑定数据表!`),!1;if(!_.config.isSubTable){if(C[_.config.table]&&N(C[_.config.table].type))return s&&s(`【${_.config.label}】和【${C[_.config.table].config.label}】重复绑定【${_.config.table}】表!`),!1;_.config.table&&(C[_.config.table]=_)}}else if(H){if((0,Ke.isNullOrEmpty)(_.config.table))return s&&s(`【${_.config.label}】请绑定数据表!`),!1;if(C[_.config.table])return s&&s(`【${_.config.label}】和【${C[_.config.table].config.label}】重复绑定【${_.config.table}】表!`),!1;_.config.table&&(C[_.config.table]=_)}}}for(const _ of p){if(!n.notBindTable){const{isInput:Y,bindTable:H}=g[_.type]||{hasBase:!1};if(!_.config.isNotSave&&Y&&H!==!1){if((0,Ke.isNullOrEmpty)(_.config.field))return s&&s(`请【${_.config.label}】绑定表字段!`),!1;if(y[`${_.config.table}-${_.config.field}`])return s&&s(`【${_.config.label}】和【${y[`${_.config.table}-${_.config.field}`].config.label}】重复绑定【${_.config.field}】字段!`),!1;y[`${_.config.table}-${_.config.field}`]=_}}if(n.componentConfigValidate&&!n.componentConfigValidate(_.type,{configData:_.config,errorTip:s}))return!1}return!0},T=(0,r.ref)(),z=(0,r.ref)(),O=(0,r.reactive)({width:0,height:0,formConfig:{}});let L=0;const ee=p=>{if(z.value)L=0,z.value.init(p||[]);else{if(L>600){console.warn("表单组件加载超时");return}L++,setTimeout(()=>{ee(p)},100)}},se=()=>{},V=()=>{},X=(0,r.ref)(),A=(0,r.ref)(),U=()=>{const{addList:p,table:y}=A.value?.ok()||{addList:[]};if(p.length<=0)i&&i("请选择字段!");else{if(R.value?.config.componentType==="gridtable"||R.value?.config.isSubTable)if(R.value.config.table){if(R.value.config.table!==y){i&&i("请设置相同的表和子表!");return}}else{let C=R.value;R.value.config.isSubTable&&(C=j[R.value.containerId]),C.config.table=y,(C.children||[]).forEach(_=>{_.isInput&&(_.config.table=y)}),G.value.setFormData({main:{table:y}})}p.forEach(C=>{const _=(0,Ke.deepClone)(g[C.type]);_.config={table:y,field:C.value,label:C.label},Z(_)}),X.value.close()}},te=()=>{A.value?.closed()};return e({setTables:p=>{f(p)},getSchema:()=>b(),setSchema:p=>P(p),reset:()=>W(),validate:()=>v()}),(p,y)=>{const C=(0,r.resolveComponent)("j-icon"),_=(0,r.resolveComponent)("d-drag-tool"),Y=(0,r.resolveComponent)("el-collapse-item"),H=(0,r.resolveComponent)("el-collapse"),oe=(0,r.resolveComponent)("d-drag-form-list"),Q=(0,r.resolveComponent)("el-row"),ue=(0,r.resolveComponent)("d-drag-container"),fe=(0,r.resolveComponent)("j-form"),ge=(0,r.resolveComponent)("j-layer");return(0,r.openBlock)(),(0,r.createElementBlock)("div",yh,[(0,r.createElementVNode)("div",vh,[(0,r.createElementVNode)("div",_h,[(0,r.createVNode)(H,{modelValue:l.value,"onUpdate:modelValue":y[0]||(y[0]=he=>l.value=he)},{default:(0,r.withCtx)(()=>[((0,r.openBlock)(!0),(0,r.createElementBlock)(r.Fragment,null,(0,r.renderList)(t.components,(he,Ze)=>((0,r.openBlock)(),(0,r.createBlock)(Y,{key:Ze,title:he.name,name:Ze},{default:(0,r.withCtx)(()=>[((0,r.openBlock)(!0),(0,r.createElementBlock)(r.Fragment,null,(0,r.renderList)(he.children,(Vt,Qh)=>((0,r.openBlock)(),(0,r.createBlock)(_,{key:Qh,config:Vt},{default:(0,r.withCtx)(()=>[(0,r.createElementVNode)("div",wh,[(0,r.createVNode)(C,{class:"j-component-tool-icon",icon:Vt.icon,size:14},null,8,["icon"]),(0,r.createElementVNode)("div",bh,(0,r.toDisplayString)((0,r.unref)(o)(Vt.name)),1)])]),_:2},1032,["config"]))),128))]),_:2},1032,["title","name"]))),128))]),_:1},8,["modelValue"])])]),(0,r.createElementVNode)("div",Ch,[(0,r.createElementVNode)("div",Eh,[(0,r.createVNode)(ue,{ref_key:"dragContainer",ref:M,class:"d-form-design-drag-container","is-component-container":!1,"component-data":a},{default:(0,r.withCtx)(()=>[!a.children||a.children.length===0?((0,r.openBlock)(),(0,r.createElementBlock)("div",xh,[...y[1]||(y[1]=[(0,r.createElementVNode)("div",null,"请从左侧拖拽组件到此处",-1)])])):((0,r.openBlock)(),(0,r.createBlock)(Q,{key:1},{default:(0,r.withCtx)(()=>[(0,r.createVNode)(oe,{"component-list":a.children,"global-config":a.config},null,8,["component-list","global-config"])]),_:1}))]),_:1},8,["component-data"])])]),(0,r.withDirectives)((0,r.createElementVNode)("div",Nh,[(0,r.createElementVNode)("div",kh,[(0,r.createElementVNode)("span",Sh,(0,r.toDisplayString)(`${(0,r.unref)(o)("属性配置")}${k.value}`),1)]),(0,r.createElementVNode)("div",Dh,[(0,r.createVNode)(fe,{config:{labelPosition:"top",size:"small"},collapseAnimate:!1,style:{padding:"0"},ref_key:"configRef",ref:G,onChange:D},null,512)])],512),[[r.vShow,(0,r.unref)(R)]]),(0,r.createVNode)(ge,{ref_key:"previewFormLayerRef",ref:T,width:O.width,height:O.height,onOk:se,onClosed:V},{default:(0,r.withCtx)(()=>[(0,r.createVNode)(fe,{config:O.formConfig,"is-preview":!0,ref_key:"previewFormRef",ref:z,actions:t.actions},null,8,["config","actions"])]),_:1},8,["width","height"]),(0,r.createVNode)(ge,{ref_key:"importFormLayerRef",ref:X,width:800,height:600,"btn-text":"确认",onOk:U,onClosed:te},{default:(0,r.withCtx)(()=>[(0,r.createVNode)(hh,{"component-list":m,"table-list":c.value,ref_key:"importComponentRef",ref:A},null,8,["table-list"])]),_:1},512)])}}}),Mh=Th,$r=qe(Mh,[Ar]),Pr=(t,e)=>{const n={ver:"V3",indexPage:{...t},components:[]};return Or(e||[],n.components),n},Or=(t,e)=>{t.forEach(n=>{const o={id:n.id,name:n.name,type:n.type,runtimeType:n.runtimeType||n.componentName||n.type,groupId:n.groupId||"",config:n.config,containerId:n.containerId,level:n.level};n.dragType==="container"&&Or(n.children||[],e),e.push(o)})},Ih=t=>{const e=Bh(t.components);return{pageConfig:t.indexPage,componentList:e}},Bh=t=>{const e={},n={};return t.forEach(o=>{e[o.containerId]=e[o.containerId]||[];const i={id:o.id,type:o.runtimeType,slot:o.groupId,config:{}};o.config&&Object.keys(o.config).forEach(s=>{i.config[s]=o.config[s]}),e[o.containerId].push(i),n[o.id]=i}),Object.keys(e).forEach(o=>{const i=n[o];if(i){const s=e[o];if(["j-tabs","j-collapse"].includes(i.type||"")&&i.config?.groups){const a={};s.forEach(l=>{if(l.slot!==void 0&&l.slot!==null){const d=l.slot.toString();a[d]||(a[d]=[]),delete l.slot,a[d].push(l)}}),i.children=i.config.groups.map(l=>{const d=a[l._i]||[];return{config:{label:l.label},children:d}}),delete i.config.groups}else i.children=s}}),e.indexPage||[]},zh=(t,e)=>{let n={},o=[];const i={};if(t.ver==="V3"){const s=t;n=s.indexPage;const a={};s.components.forEach(l=>{const d=e[l.type];if(!d)return;a[l.containerId]=a[l.containerId]||[];const c={id:l.id,name:l.name,type:l.type,dragType:d.dragType||"component",componentName:d.componentName||"",runtimeType:d.runtimeType,groupId:l.groupId,config:l.config,isInput:!1,containerId:l.containerId,level:l.level};i[c.id]=c,a[l.containerId].push(c),c.dragType==="container"&&(c.children=[])}),Object.keys(a).forEach(l=>{i[l]&&(i[l].children=a[l])}),o=a.indexPage||[]}return{pageConfig:n,componentList:o,componentDic:i}},Rh=(0,r.defineComponent)({name:"DIndexDesignItem",__name:"indexDesignItem",props:{componentData:{type:Object,default:()=>({})},globalConfig:{type:Object,default:()=>({})}},setup(t){return(e,n)=>((0,r.openBlock)(),(0,r.createBlock)((0,r.resolveDynamicComponent)(t.componentData?.componentName),(0,r.mergeProps)(t.componentData?.config,{"global-config":t.globalConfig,"component-data":t.componentData}),null,16,["global-config","component-data"]))}}),Vr=Rh,Ah={class:"d-index-design j-block"},$h={class:"d-index-design-left"},Ph={class:"j-component-list"},Oh={class:"j-component-tool"},Vh={class:"j-component-tool-name"},Hh={class:"d-index-design-center"},Lh={class:"design-toolbar"},Fh={class:"design-container"},Gh={key:0,class:"j-block design-empty"},Wh={class:"d-index-design-right"},Uh={class:"d-index-design-panel-title"},Yh={style:{margin:"0","font-size":"14px"}},Xh={class:"d-index-design-panel"},jh=(0,r.defineComponent)({name:"DIndexDesign",__name:"indexDesign",props:{components:{type:Array,default:()=>[]},componentConfigs:{type:Object,default:()=>({})},componentInit:Function,containerAddComponent:Function,componentConfigInit:Function,componentConfigChange:Function,flowComponents:{type:Array,default:()=>[]},flowInit:Function,flowComponentConfigInit:Function,flowComponentConfigChange:Function,flowComponentConfigs:{type:Object,default:()=>({})},actions:{type:Object,default:()=>({})}},setup(t,{expose:e}){const{t:n}=(0,Ke.useAppInject)(),o=t,i=v=>{v.forEach(N=>{N.type==="d-input-flow"&&(N.config=N.config||{},N.config.flowComponents=o.flowComponents,N.config.flowInit=o.flowInit,N.config.flowComponentConfigInit=I=>{o.flowComponentConfigInit&&(I.designComponents=S.value,I.component=g.value,o.flowComponentConfigInit(I))},N.config.flowComponentConfigs=o.flowComponentConfigs,N.config.flowComponentConfigChange=o.flowComponentConfigChange),N.children&&i(N.children)})},s=(0,r.reactive)({name:"页面",id:"indexPage",type:"indexPage",level:0,children:[],dragType:"container",componentName:"",containerId:"",isInput:!1,config:{}});o.componentInit&&(s.config=o.componentInit("indexPage")||{});const a={},l=[];o.components.forEach(({children:v})=>{v.forEach(N=>{a[N.type]=N,N.dragType=N.dragType||"component",l.push({label:N.name,value:N.type})})});const d={};Object.keys(o.componentConfigs).forEach(v=>{const{hasBase:N}=a[v]||{hasBase:!1},I=[{id:"id",type:"j-input",config:{label:"ID",readonly:!0}},{id:"label",type:"j-input",config:{label:"名称"}}],T={type:"j-collapse",config:{defaultValue:[]},children:[]};N!==!1&&(T.children?.push({config:{label:"基础信息"},children:[...I]}),T.config?.defaultValue.push("_collapse0")),T.children?.push(...o.componentConfigs[v]),i(T.children||[]),d[v]=[T]});const c=v=>{g.value&&o.componentConfigChange&&o.componentConfigChange(g.value.type,{configRef:f,configData:g.value.config,...v})},u=(v,N)=>{o.componentConfigInit&&o.componentConfigInit(v,{configRef:f,...N})},h=(0,r.ref)(),f=(0,r.ref)(),{activedComponent:g,clearComponents:m,schemaComponentDic:E,designComponentList:S}=Rr(h,f,s,o.componentInit,u,d,a,o.containerAddComponent),D=(0,r.computed)(()=>g.value?`【${g.value.name}】`:""),B=(0,r.ref)([]),w=o.components.length;for(let v=0;v<w;v++)B.value.push(v);(0,r.provide)("dui-design-provide",{designItemName:Vr});const M=()=>{m()},G=()=>{o.componentInit&&(s.config=o.componentInit("indexPage")||{}),m()},R=()=>(console.log("pValidate"),!0),q=()=>Pr(s.config,s.children||[]),K=v=>{const N=zh(v,a);s.config=N.pageConfig,s.children?.push(...N.componentList),Object.keys(N.componentDic).forEach(I=>{E[I]=N.componentDic[I]})},j=(0,r.ref)(),Z=(0,r.ref)();(0,r.ref)(""),(0,r.reactive)({formConfig:{}});let F=0;const k=v=>{if(Z.value)F=0,Z.value.init(v);else{if(F>600){console.warn("组件加载超时");return}F++,setTimeout(()=>{k(v)},100)}},W=()=>{},b=()=>{},P=()=>{const{componentList:v}=Ih(Pr(s.config,s.children||[]));j.value.open("页面预览","full"),(0,r.nextTick)(()=>{k(v)})};return e({reset:G,validate:R,getSchema:q,setSchema:K}),(v,N)=>{const I=(0,r.resolveComponent)("j-icon"),T=(0,r.resolveComponent)("d-drag-tool"),z=(0,r.resolveComponent)("el-collapse-item"),O=(0,r.resolveComponent)("el-collapse"),L=(0,r.resolveComponent)("j-button"),ee=(0,r.resolveComponent)("el-tooltip"),se=(0,r.resolveComponent)("el-divider"),V=(0,r.resolveComponent)("el-empty"),X=(0,r.resolveComponent)("d-drag-index-list"),A=(0,r.resolveComponent)("d-drag-container"),U=(0,r.resolveComponent)("j-form"),te=(0,r.resolveComponent)("j-page"),ie=(0,r.resolveComponent)("j-layer");return(0,r.openBlock)(),(0,r.createElementBlock)("div",Ah,[(0,r.createElementVNode)("div",$h,[N[1]||(N[1]=(0,r.createElementVNode)("div",{class:"d-index-design-panel-title"},"组件库",-1)),(0,r.createElementVNode)("div",Ph,[(0,r.createVNode)(O,{modelValue:B.value,"onUpdate:modelValue":N[0]||(N[0]=le=>B.value=le)},{default:(0,r.withCtx)(()=>[((0,r.openBlock)(!0),(0,r.createElementBlock)(r.Fragment,null,(0,r.renderList)(t.components,(le,J)=>((0,r.openBlock)(),(0,r.createBlock)(z,{key:J,title:le.name,name:J},{default:(0,r.withCtx)(()=>[((0,r.openBlock)(!0),(0,r.createElementBlock)(r.Fragment,null,(0,r.renderList)(le.children,(re,x)=>((0,r.openBlock)(),(0,r.createBlock)(T,{key:x,config:re},{default:(0,r.withCtx)(()=>[(0,r.createElementVNode)("div",Oh,[(0,r.createVNode)(I,{class:"j-component-tool-icon",icon:re.icon,size:14},null,8,["icon"]),(0,r.createElementVNode)("div",Vh,(0,r.toDisplayString)((0,r.unref)(n)(re.name)),1)])]),_:2},1032,["config"]))),128))]),_:2},1032,["title","name"]))),128))]),_:1},8,["modelValue"])])]),(0,r.createElementVNode)("div",Hh,[(0,r.createElementVNode)("div",Lh,[N[2]||(N[2]=(0,r.createElementVNode)("div",null,null,-1)),(0,r.createElementVNode)("div",null,[(0,r.createVNode)(ee,{content:(0,r.unref)(n)("清空")},{default:(0,r.withCtx)(()=>[(0,r.createVNode)(L,{danger:"",type:"text",onClick:M,icon:"mdi:delete-outline"})]),_:1},8,["content"]),(0,r.createVNode)(se,{direction:"vertical"}),(0,r.createVNode)(ee,{content:(0,r.unref)(n)("预览")},{default:(0,r.withCtx)(()=>[(0,r.createVNode)(L,{type:"text",onClick:P,icon:"mdi:play-circle-outline"})]),_:1},8,["content"])])]),(0,r.createElementVNode)("div",Fh,[(0,r.createVNode)(A,{ref_key:"dragContainer",ref:h,class:"design-drag-container","is-component-container":!1,"component-data":s},{default:(0,r.withCtx)(()=>[!s.children||s.children.length===0?((0,r.openBlock)(),(0,r.createElementBlock)("div",Gh,[(0,r.createVNode)(V,{description:(0,r.unref)(n)("请从左侧拖拽组件到此处"),"image-size":100},null,8,["description"])])):((0,r.openBlock)(),(0,r.createBlock)(X,{key:1,"component-list":s.children,"global-config":s.config},null,8,["component-list","global-config"]))]),_:1},8,["component-data"])])]),(0,r.withDirectives)((0,r.createElementVNode)("div",Wh,[(0,r.createElementVNode)("div",Uh,[(0,r.createElementVNode)("span",Yh,(0,r.toDisplayString)(`${(0,r.unref)(n)("属性配置")}${D.value}`),1)]),(0,r.createElementVNode)("div",Xh,[(0,r.createVNode)(U,{config:{labelPosition:"top",size:"small"},collapseAnimate:!1,style:{padding:"0"},ref_key:"configRef",ref:f,onChange:c},null,512)])],512),[[r.vShow,(0,r.unref)(g)&&d[(0,r.unref)(g).type]]]),(0,r.createVNode)(ie,{ref_key:"previewLayerRef",ref:j,"has-btns":!1,onOk:W,onClosed:b},{default:(0,r.withCtx)(()=>[(0,r.createVNode)(te,{ref_key:"previewRef",ref:Z,actions:t.actions},null,8,["actions"])]),_:1},512)])}}}),Zh=jh,Hr=qe(Zh,[Vr]),Kh=[So,Mn,In,Bn,zn,Cr,Er,Mr,Ir,$r,Hr],Lr=new WeakSet,qh=t=>{Lr.has(t)||(Lr.add(t),Kh.forEach(e=>{const n=e.name;n&&t.component(n,e)}))},Jh={install:qh};me.DDrag=So,me.DDraggable=Ir,me.DFlowDesign=Cr,me.DFormDesign=$r,me.DIndexDesign=Hr,me.DInputFlow=Er,me.DLayout=Mr,me.default=Jh,me.dragContainer=In,me.dragFormList=Bn,me.dragIndexList=zn,me.dragTool=Mn,me.toFormDesignSchema=Br,me.toFormSaveSchema=bo,me.toFormSchema=dh});
|