@kong-ui-public/entities-plugins 9.87.3 → 9.87.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/entities-plugins.es.js +605 -601
- package/dist/entities-plugins.umd.js +2 -2
- package/dist/style.css +1 -1
- package/dist/types/components/free-form/Datakit/flow-editor/store/flow.d.ts +3 -3
- package/dist/types/components/free-form/Datakit/flow-editor/store/flow.d.ts.map +1 -1
- package/dist/types/components/free-form/Datakit/flow-editor/store/history.d.ts.map +1 -1
- package/dist/types/components/free-form/Datakit/flow-editor/store/store.d.ts +2 -2
- package/dist/types/components/free-form/Datakit/flow-editor/store/store.d.ts.map +1 -1
- package/package.json +6 -6
|
@@ -116,7 +116,7 @@ will extend the wait time by about 12 minutes, continuously adjusting as new req
|
|
|
116
116
|
input: API
|
|
117
117
|
status: 200
|
|
118
118
|
`},Symbol.toStringTag,{value:"Module"})),WC={class:"dk-code-editor"},XC={class:"examples-content"},ZC={ref:"editor-root",class:"editor"},Ra="YAML Syntax",JC="datakit.insert-example",QC=Ee(t.defineComponent({__name:"CodeEditor",props:{editing:{type:Boolean}},emits:["change","error"],setup(e,{expose:n,emit:o}){const{t:r}=Fe.createI18n("en-us",He),{formData:i}=De(),a=o,l=t.useTemplateRef("editor-root"),s=t.shallowRef(null);function c(d){const u=s.value,f=u==null?void 0:u.getModel();if(!u||!f)return;const p=Xd[d];if(u.getValue()!==p){const m=f.getFullModelRange();u.pushUndoStop(),u.executeEdits(JC,[{range:m,text:p}]),u.pushUndoStop()}u.focus()}return t.onMounted(()=>{const d=lr.editor.create(l.value,{language:"yaml",automaticLayout:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,tabSize:2,scrollbar:{alwaysConsumeMouseWheel:!1},autoIndent:"keep"});s.value=d,i.config&&Object.keys(i.config).length>0&&d.setValue(Wd.dump(t.toRaw(i.config),{schema:Va,noArrayIndent:!0})),d.onDidChangeModelContent(()=>{const u=d.getModel(),f=d.getValue()||"";try{const p=Wd.load(f,{schema:Va,json:!0});lr.editor.setModelMarkers(u,Ra,[]),i.config=p,a("change",p)}catch(p){const{message:m,mark:h}=p,{line:y,column:g}=h||{line:0,column:0},_=m.split(`
|
|
119
|
-
`)[0],w=[{startLineNumber:y+1,startColumn:g+1,endLineNumber:y+1,endColumn:g+2,message:_,severity:lr.MarkerSeverity.Error,source:Ra}];lr.editor.setModelMarkers(u,Ra,w),a("error",_)}})}),t.onBeforeUnmount(()=>{var d;(d=s.value)==null||d.dispose()}),n({setExampleCode:c}),(d,u)=>(t.openBlock(),t.createElementBlock("div",WC,[t.createVNode(t.unref(Pe.KAlert),{class:"examples"},{icon:t.withCtx(()=>[t.createVNode(t.unref(Ne.SparklesIcon))]),default:t.withCtx(()=>[t.createElementVNode("div",XC,[t.createTextVNode(t.toDisplayString(t.unref(r)("plugins.free-form.datakit.description_example"))+" ",1),(t.openBlock(),t.createElementBlock(t.Fragment,null,t.renderList(Xd,(f,p)=>t.createVNode(t.unref(Pe.KButton),{key:p,appearance:"secondary",size:"small",onClick:m=>c(p)},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(r)(`plugins.free-form.datakit.examples.${p}`)),1)]),_:2},1032,["onClick"])),64))])]),_:1}),t.createElementVNode("div",ZC,null,512)]))}}),[["__scopeId","data-v-fd44a27b"]]),{t:Da}=Fe.createI18n("en-us",He);function St(e){return Da(`plugins.free-form.datakit.flow_editor.node_types.${e}.description`)}function vo(e){return Da(`plugins.free-form.datakit.flow_editor.node_types.${e}.summary`)}function eN(e){return Da(`plugins.free-form.datakit.flow_editor.node_types.${e}.name`)}const Tr={call:{type:"call",summary:vo("call"),description:St("call"),icon:Ne.NetworkIcon,io:{input:{fields:[{name:"headers"},{name:"body"},{name:"query"}]},output:{fields:[{name:"headers"},{name:"body"},{name:"status"}]}}},jq:{type:"jq",summary:vo("jq"),description:St("jq"),icon:Ne.CodeblockIcon,io:{input:{fields:[],configurable:!0},output:{fields:[]}}},exit:{type:"exit",summary:vo("exit"),description:St("exit"),icon:Ne.GatewayIcon,io:{input:{fields:[{name:"headers"},{name:"body"}]}}},property:{type:"property",summary:vo("property"),description:St("property"),icon:Ne.StackIcon,io:{input:{fields:[],configurable:!0},output:{fields:[]}}},static:{type:"static",summary:vo("static"),description:St("static"),icon:Ne.VitalsIcon,io:{output:{fields:[],configurable:!0}}}},Or={request:{type:"request",description:St("request"),io:{output:{fields:[{name:"headers"},{name:"body"},{name:"query"}]}}},service_request:{type:"service_request",description:St("service_request"),io:{input:{fields:[{name:"headers"},{name:"body"},{name:"query"}]}}},service_response:{type:"service_response",description:St("service_response"),io:{output:{fields:[{name:"headers"},{name:"body"}]}}},response:{type:"response",description:St("response"),io:{input:{fields:[{name:"headers"},{name:"body"}]}}}},Zd=Object.keys(Or),Ma=e=>Zd.includes(e),Lt=e=>Zd.includes(e),Jd=e=>Lt(e.type);function Kn(e){return Tn(e)}function So(e){return`${e}:${kr()}`}function $r(e){const[n,o]=e.split(".");return{nodeName:n,fieldName:o}}function Qd(e){const[n,o]=e.split(".");return{nodeId:n,fieldId:o}}function La(e){return Lt(e)?Or[e]:Tr[e]}function eu(e){var i,a,l,s,c,d;const n=La(e),o=((l=(a=(i=n.io)==null?void 0:i.input)==null?void 0:a.fields)==null?void 0:l.map(({name:u})=>u))??[],r=((d=(c=(s=n.io)==null?void 0:s.output)==null?void 0:c.fields)==null?void 0:d.map(({name:u})=>u))??[];return{input:o,output:r}}function tu(e){return(e??[]).map(n=>({id:So("field"),name:n}))}function jn(e,n,o){if(o)return e.fields[n].find(r=>r.name===o)}function Wt(e,n,o){if(o)return e.fields[n].find(r=>r.id===o)}function Fa(e,n){return n?e.fields.output.some(o=>o.id===n):!0}function nu(e,n){return n?e.fields.input.some(o=>o.id===n):!0}function tN(e){const n=e==="request"||e==="service_request"?"request":"response",o=Or[e];return{name:e,phase:n,position:{x:0,y:0},fields:eu(o.type),expanded:{}}}function nN(e,n){const o=e.toUpperCase();let r=1;for(;n.has(`${o}_${r}`);)r++;return`${o}_${r}`}function oN(e,n){const{commit:o,undo:r,redo:i,canUndo:a,canRedo:l,clear:s,reset:c,undoStack:d}=Ue.useManualRefHistory(e,{capacity:n==null?void 0:n.capacity,clone:n==null?void 0:n.clone});let u;function f(_){var w;(w=n==null?void 0:n.onHistoryChange)==null||w.call(n,_,e.value)}function p(_){if(!_){u=void 0,o(),f("commit");return}if(u!==_){u=_,o(),f("commit");return}o(),d.value.length>1&&d.value.splice(1,1),f("commit")}function m(){r(),u=void 0,f("undo")}function h(){i(),u=void 0,f("redo")}function y(){s(),u=void 0,f("clear")}function g(){c(),u=void 0,f("reset")}return{canUndo:a,canRedo:l,commit:p,undo:m,redo:h,clear:y,reset:g}}const rN="44px",iN="220px",aN="366px",lN="52px",Br=["request","service_request","service_response","response"],Vr=Br,ou=["GET","HEAD","POST","PUT","PATCH","DELETE","OPTIONS","TRACE","CONNECT"],xo="application/x-datakit+json",Ua={delete:["Delete"],undo:["Mod","Z"],redo:{mac:["Mod","Shift","Z"],windows:["Mod","Y"],linux:["Mod","Shift","Z"]},copy:["Mod","C"],paste:["Mod","V"],duplicate:["Mod","D"]};function ru(e,n){var u,f;const o=new Map(n.map(p=>[p.name,p])),r=[],i=[],a=new Map,l=[],s=new Map,c=p=>{const m=new Set,h=[...p];for(;h.length>0;){const y=h.shift();if(!m.has(y)&&(m.add(y),Ma(y)||(a.get(y).phase="request"),!!s.has(y)))for(const g of s.get(y))m.has(g)||h.push(g)}};let d=!1;for(const p of e){const m=o.get(p.name);!m&&!d&&(d=!0);const h=au(p.type,p,m);r.push(h),a.set(h.name,h)}for(const p of Vr)if(!a.has(p)){let m=o.get(p);m||(d||(d=!0),m=tN(p));const h=au(p,void 0,m);r.push(h),a.set(h.name,h)}for(const p of e)dN(p,l);for(const p of l){const m=a.get(p.source),h=a.get(p.target);if(!m||!h){m||console.warn(`[initEditorState] skip: source "${p.source}" not found`),h||console.warn(`[initEditorState] skip: target "${p.target}" not found`);continue}s.has(p.source)||s.set(p.source,new Set),s.get(p.source).add(p.target),s.has(p.target)||s.set(p.target,new Set),s.get(p.target).add(p.source),i.push({id:So("edge"),source:m.id,sourceField:(u=jn(m,"output",p.sourceField))==null?void 0:u.id,target:h.id,targetField:(f=jn(h,"input",p.targetField))==null?void 0:f.id})}return c(["request","service_request"]),{nodes:r,edges:i,needLayout:d}}function iu(e){const{type:n,name:o,phase:r,position:i,fields:a,config:l}=e,s=eu(n);return{id:So("node"),type:n,name:o??n,phase:r??"request",position:i??{x:0,y:0},expanded:{},fields:{input:tu((a==null?void 0:a.input)??s.input),output:tu((a==null?void 0:a.output)??s.output)},config:l?Kn(l):{}}}function sN(e){return Lt(e)?e==="request"||e==="service_request"?"request":"response":"request"}function au(e,n,o){return iu({type:e,name:n==null?void 0:n.name,phase:(o==null?void 0:o.phase)??sN(e),position:o==null?void 0:o.position,fields:uN(n,o),config:n?cN(n):void 0})}function cN(e){const{type:n,name:o,input:r,inputs:i,output:a,outputs:l,...s}=e;return Kn(s)}function dN(e,n){const o=e.name;if(e.input){const{nodeName:r,fieldName:i}=$r(e.input);r&&n.push({source:r,sourceField:i,target:o})}if(e.inputs)for(const[r,i]of Object.entries(e.inputs)){if(!i)continue;const{nodeName:a,fieldName:l}=$r(i);a&&n.push({source:a,sourceField:l,target:o,targetField:r})}if(e.output){const{nodeName:r,fieldName:i}=$r(e.output);r&&n.push({source:o,target:r,targetField:i})}if(e.outputs)for(const[r,i]of Object.entries(e.outputs)){if(!i)continue;const{nodeName:a,fieldName:l}=$r(i);a&&n.push({source:o,sourceField:r,target:a,targetField:l})}}function uN(e,n){var a,l;if(!e&&!n)return;const o=new Set,r=new Set;e!=null&&e.inputs&&Object.keys(e.inputs).forEach(s=>o.add(s)),e!=null&&e.outputs&&Object.keys(e.outputs).forEach(s=>r.add(s)),(e==null?void 0:e.type)==="static"&&e.values&&Object.keys(e.values).forEach(s=>r.add(s)),(a=n==null?void 0:n.fields)!=null&&a.input&&n.fields.input.forEach(s=>o.add(s)),(l=n==null?void 0:n.fields)!=null&&l.output&&n.fields.output.forEach(s=>r.add(s));const i={};return o.size&&(i.input=Array.from(o)),r.size&&(i.output=Array.from(r)),Object.keys(i).length?i:void 0}function fN(e){const n=t.computed(()=>{const c=new Map;return e.value.nodes.forEach(d=>c.set(d.id,d)),c}),o=t.computed(()=>e.value.edges);function r(c){const d=n.value.get(c.source),u=n.value.get(c.target);if(!d||!u)return c;const f=nu(d,c.sourceField)&&!Fa(d,c.sourceField),p=Fa(u,c.targetField);return f&&p?{source:c.target,sourceField:c.targetField,target:c.source,targetField:c.sourceField}:c}function i(c){const d=r(c),u=[],f=n.value.get(d.source),p=n.value.get(d.target);if(f||u.push("source node not found"),p||u.push("target node not found"),!f||!p)return{ok:!1,errors:u};Fa(f,d.sourceField)||u.push("source handle is not an output field"),nu(p,d.targetField)||u.push("target handle is not an input field"),p.name==="request"&&u.push('cannot target "request"'),f.name==="response"&&u.push('cannot source from "response"');const m=o.value.some(g=>g.target===d.target&&!g.targetField),h=o.value.some(g=>g.target===d.target&&!!g.targetField);(m&&d.targetField||h&&!d.targetField)&&u.push("cannot mix whole-node and field-level inputs on same target"),d.targetField&&o.value.some(g=>g.target===d.target&&g.targetField===d.targetField)&&u.push("target field already connected"),!d.targetField&&o.value.some(g=>g.target===d.target&&!g.targetField)&&u.push("target input already taken"),d.source===d.target&&u.push("self-loop not allowed");const y=Rr(o.value,d);return Ka(y)&&u.push("connection introduces a cycle"),u.length?{ok:!1,errors:u}:{ok:!0}}function a(){const c=[];for(const d of Vr)[...n.value.values()].some(u=>u.name===d)||c.push(`missing implicit node "${d}"`);for(const d of o.value){const u=n.value.get(d.source);n.value.get(d.target).name==="request"&&c.push(`edge "${d.id}" targets "request"`),u.name==="response"&&c.push(`edge "${d.id}" sources from "response"`)}return Ka(Rr(o.value))&&c.push("graph contains cycle"),c.length?{ok:!1,errors:c}:{ok:!0}}function l(c){return i(c).ok}function s(c){return!c.source||!c.target?!1:l({source:c.source,sourceField:c.sourceHandle,target:c.target,targetField:c.targetHandle})}return{canonicalizeConnection:r,validateConnection:i,validateGraph:a,isValidConnection:l,isValidVueFlowConnection:s,buildAdjacency:Rr}}function Ka(e){const n=new Set,o=new Set;function r(i){if(o.has(i))return!0;if(n.has(i))return!1;n.add(i),o.add(i);for(const a of e.get(i)??[])if(r(a))return!0;return o.delete(i),!1}for(const i of e.keys())if(r(i))return!0;return!1}function Rr(e,n){const o=new Map;for(const r of e)o.has(r.source)||o.set(r.source,[]),o.get(r.source).push(r.target),o.has(r.target)||o.set(r.target,[]);return n&&(o.has(n.source)||o.set(n.source,[]),o.get(n.source).push(n.target),o.has(n.target)||o.set(n.target,[])),o}const[pN,mN]=Ue.createInjectionState(function(n,o,r={}){const i=t.ref(ru(n,o)),a=t.ref(),l=t.ref(!1),s=t.ref(!1),c=oN(i,{capacity:200,clone:Kn,onHistoryChange:O=>{var k;O!=="clear"&&((k=r.onChange)==null||k.call(r,re(),q()))}}),d=t.ref(null),u=t.ref(new Set);function f(){i.value.needLayout=!1}const p=t.computed(()=>new Map(i.value.nodes.map(O=>[O.id,O]))),m=t.computed(()=>new Map(i.value.nodes.map(O=>[O.name,O]))),h=t.computed(()=>{const O=new Map,k=new Map;for(const C of i.value.edges)O.set(C.id,C),k.has(C.source)||k.set(C.source,new Set),k.get(C.source).add(C.id),k.has(C.target)||k.set(C.target,new Set),k.get(C.target).add(C.id);return{edgeMapById:O,edgeIdMapByNodeId:k}}),y=t.computed(()=>h.value.edgeMapById),g=t.computed(()=>h.value.edgeIdMapByNodeId),_=t.computed(()=>new Set(i.value.nodes.map(O=>O.name))),{canonicalizeConnection:w,validateConnection:b,validateGraph:v,isValidConnection:N,isValidVueFlowConnection:E}=fN(i);function S(O){return p.value.get(O)}function P(O){return m.value.get(O)}function B(O){return y.value.get(O)}function j(O){if(!g.value.has(O))return[];const k=[];return g.value.get(O).forEach(C=>{const A=B(C);A&&k.push(A)}),k}function G(O){return j(O).filter(k=>k.target===O)}function T(O){return j(O).filter(k=>k.source===O)}const Y=t.computed(()=>a.value?S(a.value):void 0);function I(O){a.value=O}function M(O){if(Lt(O.type))throw new Error("[createNode] implicit nodes are fixed.");return iu({type:O.type,name:O.name||(Lt(O.type)?void 0:nN(O.type,_.value)),phase:O.phase,position:O.position,fields:O.fields,config:O.config})}function R(O,k=!0){const C=M(O);if(C)return i.value.nodes.push(C),k&&c.commit(),C.id}function te(O,k=!0){i.value.edges=i.value.edges.filter(A=>A.source!==O&&A.target!==O),i.value.nodes=i.value.nodes.filter(A=>A.id!==O),a.value===O&&(a.value=void 0);const C=v();C.ok||console.warn("[removeNode] topology invalid:",C.errors.join("; ")),k&&c.commit()}function z(O,k,C=!0,A){const x=S(O);if(x){if(Ma(x.name)){console.warn("[renameNode] implicit node name is reserved.");return}x.name=k,C&&c.commit(A)}}function H(O,k,C=!0){const A=S(O);A&&(A.position={...k},C&&c.commit())}function L(O,k,C,A=!0){const x=S(O);x&&(x.expanded[k]=C??!x.expanded[k],A&&c.commit(`toggle:${O}:${k}`))}function F(O,k,C=!0,A){const x=S(O);x&&(x.config=Kn(k),C&&c.commit(A))}function Z(O,k,C,A=!0){const x=S(O);if(!x)return;const U=x.fields[k];if(U.some(V=>V.name===C)){console.warn(`[addField] field "${C}" already exists on ${k}.`);return}U.push({id:So("field"),name:C}),k==="input"?x.fields.input=U:x.fields.output=U,A&&c.commit()}function Q(O,k,C,A=!0){const x=S(O);if(!x)return;const U=x.fields.input,V=x.fields.output,J=U.find($=>$.id===k)??V.find($=>$.id===k);J&&(J.name=C,A&&c.commit())}function W(O,k,C=!0,A=!0){const x=S(O);if(!x)return;const U=x.fields.input,V=x.fields.output,J=U.findIndex(D=>D.id===k);J>=0&&U.splice(J,1);const $=V.findIndex(D=>D.id===k);$>=0&&V.splice($,1),x.fields.input=U,x.fields.output=V,C&&(i.value.edges=i.value.edges.filter(D=>D.sourceField!==k&&D.targetField!==k));const X=v();X.ok||console.warn("[removeField] topology invalid:",X.errors.join("; ")),A&&c.commit()}function ie(O,k=!0){const C=w(O),A=b(C);if(!A.ok){console.warn("[connectEdge] invalid connection:",A.errors.join("; "));return}const x={id:So("edge"),...C};i.value.edges.push(x);const U=v();if(!U.ok){i.value.edges.pop(),console.warn("[connectEdge] topology invalid:",U.errors.join("; "));return}return k&&c.commit(),x.id}function ae(O,k,C=!0){me(O,!1),ie(k,!1),C&&c.commit()}function me(O,k=!0){const C=i.value.edges.findIndex(U=>U.id===O);if(C<0)return;const A=i.value.edges[C];i.value.edges.splice(C,1);const x=v();if(!x.ok){i.value.edges.splice(C,0,A),console.warn("[disconnectEdge] topology invalid:",x.errors.join("; "));return}k&&c.commit()}function ge(O,k=!0){const C=G(O);for(const A of C)me(A.id,!1);k&&c.commit()}function ne(O,k=!0){const C=T(O);for(const A of C)me(A.id,!1);k&&c.commit()}function re(){var k,C,A,x,U;const O=[];for(const V of i.value.nodes){if(Lt(V.type))continue;let J;const $={};let X;const D={};for(const fe of i.value.edges.filter(oe=>oe.target===V.id)){const oe=S(fe.source);if(!oe)continue;const be=(k=Wt(oe,"output",fe.sourceField))==null?void 0:k.name,ve=be?`${oe.name}.${be}`:oe.name,ue=(C=Wt(V,"input",fe.targetField))==null?void 0:C.name;ue?$[ue]=ve:J===void 0&&(J=ve)}for(const fe of i.value.edges.filter(oe=>oe.source===V.id)){const oe=S(fe.target);if(!oe)continue;const be=oe.type;if(!Lt(be)||!((A=Or[be].io)!=null&&A.input))continue;const ve=(x=Wt(oe,"input",fe.targetField))==null?void 0:x.name,ue=ve?`${oe.name}.${ve}`:oe.name,de=(U=Wt(V,"output",fe.sourceField))==null?void 0:U.name;de?D[de]=ue:X===void 0&&(X=ue)}const pe={...Kn(V.config),name:V.name,type:V.type};Object.keys($).length>0?pe.inputs=$:J!==void 0&&(pe.input=J),Object.keys(D).length>0?pe.outputs=D:X!==void 0&&(pe.output=X),O.push(pe)}return O}function q(){return i.value.nodes.map(O=>Kn({name:O.name,phase:O.phase,position:{...O.position},expanded:{...O.expanded},fields:{input:O.fields.input.map(k=>k.name),output:O.fields.output.map(k=>k.name)}}))}function ee(O,k){i.value=ru(O,k),c.reset()}return{state:i,selection:a,modalOpen:l,newCreatedNodeId:d,invalidConfigNodeIds:u,propertiesPanelOpen:s,nodeMapById:p,nodeMapByName:m,edgeMapById:y,edgeIdMapByNodeId:g,getNodeById:S,getNodeByName:P,getEdgeById:B,getEdgesByNodeId:j,getInEdgesByNodeId:G,getOutEdgesByNodeId:T,selectedNode:Y,selectNode:I,createNode:M,addNode:R,removeNode:te,renameNode:z,moveNode:H,toggleExpanded:L,replaceConfig:F,addField:Z,renameField:Q,removeField:W,connectEdge:ie,replaceConnection:ae,disconnectEdge:me,disconnectInEdges:ge,disconnectOutEdges:ne,toConfigNodes:re,toUINodes:q,load:ee,commit:c.commit,undo:c.undo,redo:c.redo,canUndo:c.canUndo,canRedo:c.canRedo,clear:c.clear,reset:c.reset,isValidConnection:N,isValidVueFlowConnection:E,validateGraph:()=>v(),markAsLayoutCompleted:f}});function st(){const e=mN();if(!e)throw new Error("Editor state is not provided. Ensure you are using provideEditorStore in a parent component.");return e}const ja=Ue.createGlobalState(()=>{const e=Ue.useLocalStorage("datakit-editor-mode","flow"),n=Ue.useLocalStorage("datakit-editor-sidebar-expanded",!0);return{editorMode:e,sidePanelExpanded:n}});function Dr(e){return t.getCurrentScope()?(t.onScopeDispose(e),!0):!1}function Ft(e){return typeof e=="function"?e():t.unref(e)}const gN=typeof window<"u"&&typeof document<"u",hN=e=>typeof e<"u",yN=Object.prototype.toString,_N=e=>yN.call(e)==="[object Object]",bN=()=>{};function wN(e,n){function o(...r){return new Promise((i,a)=>{Promise.resolve(e(()=>n.apply(this,r),{fn:n,thisArg:this,args:r})).then(i).catch(a)})}return o}const lu=e=>e();function kN(e=lu){const n=t.ref(!0);function o(){n.value=!1}function r(){n.value=!0}const i=(...a)=>{n.value&&e(...a)};return{isActive:t.readonly(n),pause:o,resume:r,eventFilter:i}}function su(e,n=!1,o="Timeout"){return new Promise((r,i)=>{setTimeout(n?()=>i(o):r,e)})}function EN(e,n,o={}){const{eventFilter:r=lu,...i}=o;return t.watch(e,wN(r,n),i)}function Gn(e,n,o={}){const{eventFilter:r,...i}=o,{eventFilter:a,pause:l,resume:s,isActive:c}=kN(r);return{stop:EN(e,n,{...i,eventFilter:a}),pause:l,resume:s,isActive:c}}function CN(e,n={}){if(!t.isRef(e))return t.toRefs(e);const o=Array.isArray(e.value)?Array.from({length:e.value.length}):{};for(const r in e.value)o[r]=t.customRef(()=>({get(){return e.value[r]},set(i){var a;if((a=Ft(n.replaceRef))!=null?a:!0)if(Array.isArray(e.value)){const s=[...e.value];s[r]=i,e.value=s}else{const s={...e.value,[r]:i};Object.setPrototypeOf(s,Object.getPrototypeOf(e.value)),e.value=s}else e.value[r]=i}}));return o}function Ga(e,n=!1){function o(f,{flush:p="sync",deep:m=!1,timeout:h,throwOnTimeout:y}={}){let g=null;const w=[new Promise(b=>{g=t.watch(e,v=>{f(v)!==n&&(g==null||g(),b(v))},{flush:p,deep:m,immediate:!0})})];return h!=null&&w.push(su(h,y).then(()=>Ft(e)).finally(()=>g==null?void 0:g())),Promise.race(w)}function r(f,p){if(!t.isRef(f))return o(v=>v===f,p);const{flush:m="sync",deep:h=!1,timeout:y,throwOnTimeout:g}=p??{};let _=null;const b=[new Promise(v=>{_=t.watch([e,f],([N,E])=>{n!==(N===E)&&(_==null||_(),v(N))},{flush:m,deep:h,immediate:!0})})];return y!=null&&b.push(su(y,g).then(()=>Ft(e)).finally(()=>(_==null||_(),Ft(e)))),Promise.race(b)}function i(f){return o(p=>!!p,f)}function a(f){return r(null,f)}function l(f){return r(void 0,f)}function s(f){return o(Number.isNaN,f)}function c(f,p){return o(m=>{const h=Array.from(m);return h.includes(f)||h.includes(Ft(f))},p)}function d(f){return u(1,f)}function u(f=1,p){let m=-1;return o(()=>(m+=1,m>=f),p)}return Array.isArray(Ft(e))?{toMatch:o,toContains:c,changed:d,changedTimes:u,get not(){return Ga(e,!n)}}:{toMatch:o,toBe:r,toBeTruthy:i,toBeNull:a,toBeNaN:s,toBeUndefined:l,changed:d,changedTimes:u,get not(){return Ga(e,!n)}}}function qa(e){return Ga(e)}function NN(e){var n;const o=Ft(e);return(n=o==null?void 0:o.$el)!=null?n:o}const cu=gN?window:void 0;function du(...e){let n,o,r,i;if(typeof e[0]=="string"||Array.isArray(e[0])?([o,r,i]=e,n=cu):[n,o,r,i]=e,!n)return bN;Array.isArray(o)||(o=[o]),Array.isArray(r)||(r=[r]);const a=[],l=()=>{a.forEach(u=>u()),a.length=0},s=(u,f,p,m)=>(u.addEventListener(f,p,m),()=>u.removeEventListener(f,p,m)),c=t.watch(()=>[NN(n),Ft(i)],([u,f])=>{if(l(),!u)return;const p=_N(f)?{...f}:f;a.push(...o.flatMap(m=>r.map(h=>s(u,m,h,p))))},{immediate:!0,flush:"post"}),d=()=>{c(),l()};return Dr(d),d}function vN(e){return typeof e=="function"?e:typeof e=="string"?n=>n.key===e:Array.isArray(e)?n=>e.includes(n.key):()=>!0}function uu(...e){let n,o,r={};e.length===3?(n=e[0],o=e[1],r=e[2]):e.length===2?typeof e[1]=="object"?(n=!0,o=e[0],r=e[1]):(n=e[0],o=e[1]):(n=!0,o=e[0]);const{target:i=cu,eventName:a="keydown",passive:l=!1,dedupe:s=!1}=r,c=vN(n);return du(i,a,u=>{u.repeat&&Ft(s)||c(u)&&o(u)},l)}function SN(e){return JSON.parse(JSON.stringify(e))}function za(e,n,o,r={}){var i,a,l;const{clone:s=!1,passive:c=!1,eventName:d,deep:u=!1,defaultValue:f,shouldEmit:p}=r,m=t.getCurrentInstance(),h=o||(m==null?void 0:m.emit)||((i=m==null?void 0:m.$emit)==null?void 0:i.bind(m))||((l=(a=m==null?void 0:m.proxy)==null?void 0:a.$emit)==null?void 0:l.bind(m==null?void 0:m.proxy));let y=d;n||(n="modelValue"),y=y||`update:${n.toString()}`;const g=b=>s?typeof s=="function"?s(b):SN(b):b,_=()=>hN(e[n])?g(e[n]):f,w=b=>{p?p(b)&&h(y,b):h(y,b)};if(c){const b=_(),v=t.ref(b);let N=!1;return t.watch(()=>e[n],E=>{N||(N=!0,v.value=g(E),t.nextTick(()=>N=!1))}),t.watch(v,E=>{!N&&(E!==e[n]||u)&&w(E)},{deep:u}),v}else return t.computed({get(){return _()},set(b){w(b)}})}var xN={value:()=>{}};function Mr(){for(var e=0,n=arguments.length,o={},r;e<n;++e){if(!(r=arguments[e]+"")||r in o||/[\s.]/.test(r))throw new Error("illegal type: "+r);o[r]=[]}return new Lr(o)}function Lr(e){this._=e}function AN(e,n){return e.trim().split(/^|\s+/).map(function(o){var r="",i=o.indexOf(".");if(i>=0&&(r=o.slice(i+1),o=o.slice(0,i)),o&&!n.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:r}})}Lr.prototype=Mr.prototype={constructor:Lr,on:function(e,n){var o=this._,r=AN(e+"",o),i,a=-1,l=r.length;if(arguments.length<2){for(;++a<l;)if((i=(e=r[a]).type)&&(i=IN(o[i],e.name)))return i;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++a<l;)if(i=(e=r[a]).type)o[i]=fu(o[i],e.name,n);else if(n==null)for(i in o)o[i]=fu(o[i],e.name,null);return this},copy:function(){var e={},n=this._;for(var o in n)e[o]=n[o].slice();return new Lr(e)},call:function(e,n){if((i=arguments.length-2)>0)for(var o=new Array(i),r=0,i,a;r<i;++r)o[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(n,o)},apply:function(e,n,o){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(n,o)}};function IN(e,n){for(var o=0,r=e.length,i;o<r;++o)if((i=e[o]).name===n)return i.value}function fu(e,n,o){for(var r=0,i=e.length;r<i;++r)if(e[r].name===n){e[r]=xN,e=e.slice(0,r).concat(e.slice(r+1));break}return o!=null&&e.push({name:n,value:o}),e}var Ha="http://www.w3.org/1999/xhtml";const pu={svg:"http://www.w3.org/2000/svg",xhtml:Ha,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Fr(e){var n=e+="",o=n.indexOf(":");return o>=0&&(n=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),pu.hasOwnProperty(n)?{space:pu[n],local:e}:e}function PN(e){return function(){var n=this.ownerDocument,o=this.namespaceURI;return o===Ha&&n.documentElement.namespaceURI===Ha?n.createElement(e):n.createElementNS(o,e)}}function TN(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function mu(e){var n=Fr(e);return(n.local?TN:PN)(n)}function ON(){}function Ya(e){return e==null?ON:function(){return this.querySelector(e)}}function $N(e){typeof e!="function"&&(e=Ya(e));for(var n=this._groups,o=n.length,r=new Array(o),i=0;i<o;++i)for(var a=n[i],l=a.length,s=r[i]=new Array(l),c,d,u=0;u<l;++u)(c=a[u])&&(d=e.call(c,c.__data__,u,a))&&("__data__"in c&&(d.__data__=c.__data__),s[u]=d);return new ct(r,this._parents)}function BN(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function VN(){return[]}function gu(e){return e==null?VN:function(){return this.querySelectorAll(e)}}function RN(e){return function(){return BN(e.apply(this,arguments))}}function DN(e){typeof e=="function"?e=RN(e):e=gu(e);for(var n=this._groups,o=n.length,r=[],i=[],a=0;a<o;++a)for(var l=n[a],s=l.length,c,d=0;d<s;++d)(c=l[d])&&(r.push(e.call(c,c.__data__,d,l)),i.push(c));return new ct(r,i)}function hu(e){return function(){return this.matches(e)}}function yu(e){return function(n){return n.matches(e)}}var MN=Array.prototype.find;function LN(e){return function(){return MN.call(this.children,e)}}function FN(){return this.firstElementChild}function UN(e){return this.select(e==null?FN:LN(typeof e=="function"?e:yu(e)))}var KN=Array.prototype.filter;function jN(){return Array.from(this.children)}function GN(e){return function(){return KN.call(this.children,e)}}function qN(e){return this.selectAll(e==null?jN:GN(typeof e=="function"?e:yu(e)))}function zN(e){typeof e!="function"&&(e=hu(e));for(var n=this._groups,o=n.length,r=new Array(o),i=0;i<o;++i)for(var a=n[i],l=a.length,s=r[i]=[],c,d=0;d<l;++d)(c=a[d])&&e.call(c,c.__data__,d,a)&&s.push(c);return new ct(r,this._parents)}function _u(e){return new Array(e.length)}function HN(){return new ct(this._enter||this._groups.map(_u),this._parents)}function Ur(e,n){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=n}Ur.prototype={constructor:Ur,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,n){return this._parent.insertBefore(e,n)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function YN(e){return function(){return e}}function WN(e,n,o,r,i,a){for(var l=0,s,c=n.length,d=a.length;l<d;++l)(s=n[l])?(s.__data__=a[l],r[l]=s):o[l]=new Ur(e,a[l]);for(;l<c;++l)(s=n[l])&&(i[l]=s)}function XN(e,n,o,r,i,a,l){var s,c,d=new Map,u=n.length,f=a.length,p=new Array(u),m;for(s=0;s<u;++s)(c=n[s])&&(p[s]=m=l.call(c,c.__data__,s,n)+"",d.has(m)?i[s]=c:d.set(m,c));for(s=0;s<f;++s)m=l.call(e,a[s],s,a)+"",(c=d.get(m))?(r[s]=c,c.__data__=a[s],d.delete(m)):o[s]=new Ur(e,a[s]);for(s=0;s<u;++s)(c=n[s])&&d.get(p[s])===c&&(i[s]=c)}function ZN(e){return e.__data__}function JN(e,n){if(!arguments.length)return Array.from(this,ZN);var o=n?XN:WN,r=this._parents,i=this._groups;typeof e!="function"&&(e=YN(e));for(var a=i.length,l=new Array(a),s=new Array(a),c=new Array(a),d=0;d<a;++d){var u=r[d],f=i[d],p=f.length,m=QN(e.call(u,u&&u.__data__,d,r)),h=m.length,y=s[d]=new Array(h),g=l[d]=new Array(h),_=c[d]=new Array(p);o(u,f,y,g,_,m,n);for(var w=0,b=0,v,N;w<h;++w)if(v=y[w]){for(w>=b&&(b=w+1);!(N=g[b])&&++b<h;);v._next=N||null}}return l=new ct(l,r),l._enter=s,l._exit=c,l}function QN(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function e1(){return new ct(this._exit||this._groups.map(_u),this._parents)}function t1(e,n,o){var r=this.enter(),i=this,a=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),n!=null&&(i=n(i),i&&(i=i.selection())),o==null?a.remove():o(a),r&&i?r.merge(i).order():i}function n1(e){for(var n=e.selection?e.selection():e,o=this._groups,r=n._groups,i=o.length,a=r.length,l=Math.min(i,a),s=new Array(i),c=0;c<l;++c)for(var d=o[c],u=r[c],f=d.length,p=s[c]=new Array(f),m,h=0;h<f;++h)(m=d[h]||u[h])&&(p[h]=m);for(;c<i;++c)s[c]=o[c];return new ct(s,this._parents)}function o1(){for(var e=this._groups,n=-1,o=e.length;++n<o;)for(var r=e[n],i=r.length-1,a=r[i],l;--i>=0;)(l=r[i])&&(a&&l.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(l,a),a=l);return this}function r1(e){e||(e=i1);function n(f,p){return f&&p?e(f.__data__,p.__data__):!f-!p}for(var o=this._groups,r=o.length,i=new Array(r),a=0;a<r;++a){for(var l=o[a],s=l.length,c=i[a]=new Array(s),d,u=0;u<s;++u)(d=l[u])&&(c[u]=d);c.sort(n)}return new ct(i,this._parents).order()}function i1(e,n){return e<n?-1:e>n?1:e>=n?0:NaN}function a1(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function l1(){return Array.from(this)}function s1(){for(var e=this._groups,n=0,o=e.length;n<o;++n)for(var r=e[n],i=0,a=r.length;i<a;++i){var l=r[i];if(l)return l}return null}function c1(){let e=0;for(const n of this)++e;return e}function d1(){return!this.node()}function u1(e){for(var n=this._groups,o=0,r=n.length;o<r;++o)for(var i=n[o],a=0,l=i.length,s;a<l;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function f1(e){return function(){this.removeAttribute(e)}}function p1(e){return function(){this.removeAttributeNS(e.space,e.local)}}function m1(e,n){return function(){this.setAttribute(e,n)}}function g1(e,n){return function(){this.setAttributeNS(e.space,e.local,n)}}function h1(e,n){return function(){var o=n.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function y1(e,n){return function(){var o=n.apply(this,arguments);o==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,o)}}function _1(e,n){var o=Fr(e);if(arguments.length<2){var r=this.node();return o.local?r.getAttributeNS(o.space,o.local):r.getAttribute(o)}return this.each((n==null?o.local?p1:f1:typeof n=="function"?o.local?y1:h1:o.local?g1:m1)(o,n))}function bu(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function b1(e){return function(){this.style.removeProperty(e)}}function w1(e,n,o){return function(){this.style.setProperty(e,n,o)}}function k1(e,n,o){return function(){var r=n.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,o)}}function E1(e,n,o){return arguments.length>1?this.each((n==null?b1:typeof n=="function"?k1:w1)(e,n,o??"")):qn(this.node(),e)}function qn(e,n){return e.style.getPropertyValue(n)||bu(e).getComputedStyle(e,null).getPropertyValue(n)}function C1(e){return function(){delete this[e]}}function N1(e,n){return function(){this[e]=n}}function v1(e,n){return function(){var o=n.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function S1(e,n){return arguments.length>1?this.each((n==null?C1:typeof n=="function"?v1:N1)(e,n)):this.node()[e]}function wu(e){return e.trim().split(/^|\s+/)}function Wa(e){return e.classList||new ku(e)}function ku(e){this._node=e,this._names=wu(e.getAttribute("class")||"")}ku.prototype={add:function(e){var n=this._names.indexOf(e);n<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var n=this._names.indexOf(e);n>=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Eu(e,n){for(var o=Wa(e),r=-1,i=n.length;++r<i;)o.add(n[r])}function Cu(e,n){for(var o=Wa(e),r=-1,i=n.length;++r<i;)o.remove(n[r])}function x1(e){return function(){Eu(this,e)}}function A1(e){return function(){Cu(this,e)}}function I1(e,n){return function(){(n.apply(this,arguments)?Eu:Cu)(this,e)}}function P1(e,n){var o=wu(e+"");if(arguments.length<2){for(var r=Wa(this.node()),i=-1,a=o.length;++i<a;)if(!r.contains(o[i]))return!1;return!0}return this.each((typeof n=="function"?I1:n?x1:A1)(o,n))}function T1(){this.textContent=""}function O1(e){return function(){this.textContent=e}}function $1(e){return function(){var n=e.apply(this,arguments);this.textContent=n??""}}function B1(e){return arguments.length?this.each(e==null?T1:(typeof e=="function"?$1:O1)(e)):this.node().textContent}function V1(){this.innerHTML=""}function R1(e){return function(){this.innerHTML=e}}function D1(e){return function(){var n=e.apply(this,arguments);this.innerHTML=n??""}}function M1(e){return arguments.length?this.each(e==null?V1:(typeof e=="function"?D1:R1)(e)):this.node().innerHTML}function L1(){this.nextSibling&&this.parentNode.appendChild(this)}function F1(){return this.each(L1)}function U1(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function K1(){return this.each(U1)}function j1(e){var n=typeof e=="function"?e:mu(e);return this.select(function(){return this.appendChild(n.apply(this,arguments))})}function G1(){return null}function q1(e,n){var o=typeof e=="function"?e:mu(e),r=n==null?G1:typeof n=="function"?n:Ya(n);return this.select(function(){return this.insertBefore(o.apply(this,arguments),r.apply(this,arguments)||null)})}function z1(){var e=this.parentNode;e&&e.removeChild(this)}function H1(){return this.each(z1)}function Y1(){var e=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function W1(){var e=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function X1(e){return this.select(e?W1:Y1)}function Z1(e){return arguments.length?this.property("__data__",e):this.node().__data__}function J1(e){return function(n){e.call(this,n,this.__data__)}}function Q1(e){return e.trim().split(/^|\s+/).map(function(n){var o="",r=n.indexOf(".");return r>=0&&(o=n.slice(r+1),n=n.slice(0,r)),{type:n,name:o}})}function ev(e){return function(){var n=this.__on;if(n){for(var o=0,r=-1,i=n.length,a;o<i;++o)a=n[o],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):n[++r]=a;++r?n.length=r:delete this.__on}}}function tv(e,n,o){return function(){var r=this.__on,i,a=J1(n);if(r){for(var l=0,s=r.length;l<s;++l)if((i=r[l]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=o),i.value=n;return}}this.addEventListener(e.type,a,o),i={type:e.type,name:e.name,value:n,listener:a,options:o},r?r.push(i):this.__on=[i]}}function nv(e,n,o){var r=Q1(e+""),i,a=r.length,l;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,d=s.length,u;c<d;++c)for(i=0,u=s[c];i<a;++i)if((l=r[i]).type===u.type&&l.name===u.name)return u.value}return}for(s=n?tv:ev,i=0;i<a;++i)this.each(s(r[i],n,o));return this}function Nu(e,n,o){var r=bu(e),i=r.CustomEvent;typeof i=="function"?i=new i(n,o):(i=r.document.createEvent("Event"),o?(i.initEvent(n,o.bubbles,o.cancelable),i.detail=o.detail):i.initEvent(n,!1,!1)),e.dispatchEvent(i)}function ov(e,n){return function(){return Nu(this,e,n)}}function rv(e,n){return function(){return Nu(this,e,n.apply(this,arguments))}}function iv(e,n){return this.each((typeof n=="function"?rv:ov)(e,n))}function*av(){for(var e=this._groups,n=0,o=e.length;n<o;++n)for(var r=e[n],i=0,a=r.length,l;i<a;++i)(l=r[i])&&(yield l)}var vu=[null];function ct(e,n){this._groups=e,this._parents=n}function Ao(){return new ct([[document.documentElement]],vu)}function lv(){return this}ct.prototype=Ao.prototype={constructor:ct,select:$N,selectAll:DN,selectChild:UN,selectChildren:qN,filter:zN,data:JN,enter:HN,exit:e1,join:t1,merge:n1,selection:lv,order:o1,sort:r1,call:a1,nodes:l1,node:s1,size:c1,empty:d1,each:u1,attr:_1,style:E1,property:S1,classed:P1,text:B1,html:M1,raise:F1,lower:K1,append:j1,insert:q1,remove:H1,clone:X1,datum:Z1,on:nv,dispatch:iv,[Symbol.iterator]:av};function _t(e){return typeof e=="string"?new ct([[document.querySelector(e)]],[document.documentElement]):new ct([[e]],vu)}function sv(e){let n;for(;n=e.sourceEvent;)e=n;return e}function xt(e,n){if(e=sv(e),n===void 0&&(n=e.currentTarget),n){var o=n.ownerSVGElement||n;if(o.createSVGPoint){var r=o.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(n.getScreenCTM().inverse()),[r.x,r.y]}if(n.getBoundingClientRect){var i=n.getBoundingClientRect();return[e.clientX-i.left-n.clientLeft,e.clientY-i.top-n.clientTop]}}return[e.pageX,e.pageY]}const cv={passive:!1},Io={capture:!0,passive:!1};function Xa(e){e.stopImmediatePropagation()}function zn(e){e.preventDefault(),e.stopImmediatePropagation()}function Su(e){var n=e.document.documentElement,o=_t(e).on("dragstart.drag",zn,Io);"onselectstart"in n?o.on("selectstart.drag",zn,Io):(n.__noselect=n.style.MozUserSelect,n.style.MozUserSelect="none")}function xu(e,n){var o=e.document.documentElement,r=_t(e).on("dragstart.drag",null);n&&(r.on("click.drag",zn,Io),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in o?r.on("selectstart.drag",null):(o.style.MozUserSelect=o.__noselect,delete o.__noselect)}const Kr=e=>()=>e;function Za(e,{sourceEvent:n,subject:o,target:r,identifier:i,active:a,x:l,y:s,dx:c,dy:d,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},subject:{value:o,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:l,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:d,enumerable:!0,configurable:!0},_:{value:u}})}Za.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function dv(e){return!e.ctrlKey&&!e.button}function uv(){return this.parentNode}function fv(e,n){return n??{x:e.x,y:e.y}}function pv(){return navigator.maxTouchPoints||"ontouchstart"in this}function mv(){var e=dv,n=uv,o=fv,r=pv,i={},a=Mr("start","drag","end"),l=0,s,c,d,u,f=0;function p(v){v.on("mousedown.drag",m).filter(r).on("touchstart.drag",g).on("touchmove.drag",_,cv).on("touchend.drag touchcancel.drag",w).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function m(v,N){if(!(u||!e.call(this,v,N))){var E=b(this,n.call(this,v,N),v,N,"mouse");E&&(_t(v.view).on("mousemove.drag",h,Io).on("mouseup.drag",y,Io),Su(v.view),Xa(v),d=!1,s=v.clientX,c=v.clientY,E("start",v))}}function h(v){if(zn(v),!d){var N=v.clientX-s,E=v.clientY-c;d=N*N+E*E>f}i.mouse("drag",v)}function y(v){_t(v.view).on("mousemove.drag mouseup.drag",null),xu(v.view,d),zn(v),i.mouse("end",v)}function g(v,N){if(e.call(this,v,N)){var E=v.changedTouches,S=n.call(this,v,N),P=E.length,B,j;for(B=0;B<P;++B)(j=b(this,S,v,N,E[B].identifier,E[B]))&&(Xa(v),j("start",v,E[B]))}}function _(v){var N=v.changedTouches,E=N.length,S,P;for(S=0;S<E;++S)(P=i[N[S].identifier])&&(zn(v),P("drag",v,N[S]))}function w(v){var N=v.changedTouches,E=N.length,S,P;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),S=0;S<E;++S)(P=i[N[S].identifier])&&(Xa(v),P("end",v,N[S]))}function b(v,N,E,S,P,B){var j=a.copy(),G=xt(B||E,N),T,Y,I;if((I=o.call(v,new Za("beforestart",{sourceEvent:E,target:p,identifier:P,active:l,x:G[0],y:G[1],dx:0,dy:0,dispatch:j}),S))!=null)return T=I.x-G[0]||0,Y=I.y-G[1]||0,function M(R,te,z){var H=G,L;switch(R){case"start":i[P]=M,L=l++;break;case"end":delete i[P],--l;case"drag":G=xt(z||te,N),L=l;break}j.call(R,v,new Za(R,{sourceEvent:te,subject:I,target:p,identifier:P,active:L,x:G[0]+T,y:G[1]+Y,dx:G[0]-H[0],dy:G[1]-H[1],dispatch:j}),S)}}return p.filter=function(v){return arguments.length?(e=typeof v=="function"?v:Kr(!!v),p):e},p.container=function(v){return arguments.length?(n=typeof v=="function"?v:Kr(v),p):n},p.subject=function(v){return arguments.length?(o=typeof v=="function"?v:Kr(v),p):o},p.touchable=function(v){return arguments.length?(r=typeof v=="function"?v:Kr(!!v),p):r},p.on=function(){var v=a.on.apply(a,arguments);return v===a?p:v},p.clickDistance=function(v){return arguments.length?(f=(v=+v)*v,p):Math.sqrt(f)},p}function Ja(e,n,o){e.prototype=n.prototype=o,o.constructor=e}function Au(e,n){var o=Object.create(e.prototype);for(var r in n)o[r]=n[r];return o}function Po(){}var To=.7,jr=1/To,Hn="\\s*([+-]?\\d+)\\s*",Oo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",At="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",gv=/^#([0-9a-f]{3,8})$/,hv=new RegExp(`^rgb\\(${Hn},${Hn},${Hn}\\)$`),yv=new RegExp(`^rgb\\(${At},${At},${At}\\)$`),_v=new RegExp(`^rgba\\(${Hn},${Hn},${Hn},${Oo}\\)$`),bv=new RegExp(`^rgba\\(${At},${At},${At},${Oo}\\)$`),wv=new RegExp(`^hsl\\(${Oo},${At},${At}\\)$`),kv=new RegExp(`^hsla\\(${Oo},${At},${At},${Oo}\\)$`),Iu={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Ja(Po,mn,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Pu,formatHex:Pu,formatHex8:Ev,formatHsl:Cv,formatRgb:Tu,toString:Tu});function Pu(){return this.rgb().formatHex()}function Ev(){return this.rgb().formatHex8()}function Cv(){return Ru(this).formatHsl()}function Tu(){return this.rgb().formatRgb()}function mn(e){var n,o;return e=(e+"").trim().toLowerCase(),(n=gv.exec(e))?(o=n[1].length,n=parseInt(n[1],16),o===6?Ou(n):o===3?new rt(n>>8&15|n>>4&240,n>>4&15|n&240,(n&15)<<4|n&15,1):o===8?Gr(n>>24&255,n>>16&255,n>>8&255,(n&255)/255):o===4?Gr(n>>12&15|n>>8&240,n>>8&15|n>>4&240,n>>4&15|n&240,((n&15)<<4|n&15)/255):null):(n=hv.exec(e))?new rt(n[1],n[2],n[3],1):(n=yv.exec(e))?new rt(n[1]*255/100,n[2]*255/100,n[3]*255/100,1):(n=_v.exec(e))?Gr(n[1],n[2],n[3],n[4]):(n=bv.exec(e))?Gr(n[1]*255/100,n[2]*255/100,n[3]*255/100,n[4]):(n=wv.exec(e))?Vu(n[1],n[2]/100,n[3]/100,1):(n=kv.exec(e))?Vu(n[1],n[2]/100,n[3]/100,n[4]):Iu.hasOwnProperty(e)?Ou(Iu[e]):e==="transparent"?new rt(NaN,NaN,NaN,0):null}function Ou(e){return new rt(e>>16&255,e>>8&255,e&255,1)}function Gr(e,n,o,r){return r<=0&&(e=n=o=NaN),new rt(e,n,o,r)}function Nv(e){return e instanceof Po||(e=mn(e)),e?(e=e.rgb(),new rt(e.r,e.g,e.b,e.opacity)):new rt}function Qa(e,n,o,r){return arguments.length===1?Nv(e):new rt(e,n,o,r??1)}function rt(e,n,o,r){this.r=+e,this.g=+n,this.b=+o,this.opacity=+r}Ja(rt,Qa,Au(Po,{brighter(e){return e=e==null?jr:Math.pow(jr,e),new rt(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?To:Math.pow(To,e),new rt(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new rt(gn(this.r),gn(this.g),gn(this.b),qr(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:$u,formatHex:$u,formatHex8:vv,formatRgb:Bu,toString:Bu}));function $u(){return`#${hn(this.r)}${hn(this.g)}${hn(this.b)}`}function vv(){return`#${hn(this.r)}${hn(this.g)}${hn(this.b)}${hn((isNaN(this.opacity)?1:this.opacity)*255)}`}function Bu(){const e=qr(this.opacity);return`${e===1?"rgb(":"rgba("}${gn(this.r)}, ${gn(this.g)}, ${gn(this.b)}${e===1?")":`, ${e})`}`}function qr(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function gn(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function hn(e){return e=gn(e),(e<16?"0":"")+e.toString(16)}function Vu(e,n,o,r){return r<=0?e=n=o=NaN:o<=0||o>=1?e=n=NaN:n<=0&&(e=NaN),new bt(e,n,o,r)}function Ru(e){if(e instanceof bt)return new bt(e.h,e.s,e.l,e.opacity);if(e instanceof Po||(e=mn(e)),!e)return new bt;if(e instanceof bt)return e;e=e.rgb();var n=e.r/255,o=e.g/255,r=e.b/255,i=Math.min(n,o,r),a=Math.max(n,o,r),l=NaN,s=a-i,c=(a+i)/2;return s?(n===a?l=(o-r)/s+(o<r)*6:o===a?l=(r-n)/s+2:l=(n-o)/s+4,s/=c<.5?a+i:2-a-i,l*=60):s=c>0&&c<1?0:l,new bt(l,s,c,e.opacity)}function Sv(e,n,o,r){return arguments.length===1?Ru(e):new bt(e,n,o,r??1)}function bt(e,n,o,r){this.h=+e,this.s=+n,this.l=+o,this.opacity=+r}Ja(bt,Sv,Au(Po,{brighter(e){return e=e==null?jr:Math.pow(jr,e),new bt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?To:Math.pow(To,e),new bt(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,n=isNaN(e)||isNaN(this.s)?0:this.s,o=this.l,r=o+(o<.5?o:1-o)*n,i=2*o-r;return new rt(el(e>=240?e-240:e+120,i,r),el(e,i,r),el(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new bt(Du(this.h),zr(this.s),zr(this.l),qr(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=qr(this.opacity);return`${e===1?"hsl(":"hsla("}${Du(this.h)}, ${zr(this.s)*100}%, ${zr(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Du(e){return e=(e||0)%360,e<0?e+360:e}function zr(e){return Math.max(0,Math.min(1,e||0))}function el(e,n,o){return(e<60?n+(o-n)*e/60:e<180?o:e<240?n+(o-n)*(240-e)/60:n)*255}const tl=e=>()=>e;function xv(e,n){return function(o){return e+o*n}}function Av(e,n,o){return e=Math.pow(e,o),n=Math.pow(n,o)-e,o=1/o,function(r){return Math.pow(e+r*n,o)}}function Iv(e){return(e=+e)==1?Mu:function(n,o){return o-n?Av(n,o,e):tl(isNaN(n)?o:n)}}function Mu(e,n){var o=n-e;return o?xv(e,o):tl(isNaN(e)?n:e)}const Hr=function e(n){var o=Iv(n);function r(i,a){var l=o((i=Qa(i)).r,(a=Qa(a)).r),s=o(i.g,a.g),c=o(i.b,a.b),d=Mu(i.opacity,a.opacity);return function(u){return i.r=l(u),i.g=s(u),i.b=c(u),i.opacity=d(u),i+""}}return r.gamma=e,r}(1);function Pv(e,n){n||(n=[]);var o=e?Math.min(n.length,e.length):0,r=n.slice(),i;return function(a){for(i=0;i<o;++i)r[i]=e[i]*(1-a)+n[i]*a;return r}}function Tv(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Ov(e,n){var o=n?n.length:0,r=e?Math.min(o,e.length):0,i=new Array(r),a=new Array(o),l;for(l=0;l<r;++l)i[l]=$o(e[l],n[l]);for(;l<o;++l)a[l]=n[l];return function(s){for(l=0;l<r;++l)a[l]=i[l](s);return a}}function $v(e,n){var o=new Date;return e=+e,n=+n,function(r){return o.setTime(e*(1-r)+n*r),o}}function It(e,n){return e=+e,n=+n,function(o){return e*(1-o)+n*o}}function Bv(e,n){var o={},r={},i;(e===null||typeof e!="object")&&(e={}),(n===null||typeof n!="object")&&(n={});for(i in n)i in e?o[i]=$o(e[i],n[i]):r[i]=n[i];return function(a){for(i in o)r[i]=o[i](a);return r}}var nl=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ol=new RegExp(nl.source,"g");function Vv(e){return function(){return e}}function Rv(e){return function(n){return e(n)+""}}function Lu(e,n){var o=nl.lastIndex=ol.lastIndex=0,r,i,a,l=-1,s=[],c=[];for(e=e+"",n=n+"";(r=nl.exec(e))&&(i=ol.exec(n));)(a=i.index)>o&&(a=n.slice(o,a),s[l]?s[l]+=a:s[++l]=a),(r=r[0])===(i=i[0])?s[l]?s[l]+=i:s[++l]=i:(s[++l]=null,c.push({i:l,x:It(r,i)})),o=ol.lastIndex;return o<n.length&&(a=n.slice(o),s[l]?s[l]+=a:s[++l]=a),s.length<2?c[0]?Rv(c[0].x):Vv(n):(n=c.length,function(d){for(var u=0,f;u<n;++u)s[(f=c[u]).i]=f.x(d);return s.join("")})}function $o(e,n){var o=typeof n,r;return n==null||o==="boolean"?tl(n):(o==="number"?It:o==="string"?(r=mn(n))?(n=r,Hr):Lu:n instanceof mn?Hr:n instanceof Date?$v:Tv(n)?Pv:Array.isArray(n)?Ov:typeof n.valueOf!="function"&&typeof n.toString!="function"||isNaN(n)?Bv:It)(e,n)}var Fu=180/Math.PI,rl={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Uu(e,n,o,r,i,a){var l,s,c;return(l=Math.sqrt(e*e+n*n))&&(e/=l,n/=l),(c=e*o+n*r)&&(o-=e*c,r-=n*c),(s=Math.sqrt(o*o+r*r))&&(o/=s,r/=s,c/=s),e*r<n*o&&(e=-e,n=-n,c=-c,l=-l),{translateX:i,translateY:a,rotate:Math.atan2(n,e)*Fu,skewX:Math.atan(c)*Fu,scaleX:l,scaleY:s}}var Yr;function Dv(e){const n=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return n.isIdentity?rl:Uu(n.a,n.b,n.c,n.d,n.e,n.f)}function Mv(e){return e==null||(Yr||(Yr=document.createElementNS("http://www.w3.org/2000/svg","g")),Yr.setAttribute("transform",e),!(e=Yr.transform.baseVal.consolidate()))?rl:(e=e.matrix,Uu(e.a,e.b,e.c,e.d,e.e,e.f))}function Ku(e,n,o,r){function i(d){return d.length?d.pop()+" ":""}function a(d,u,f,p,m,h){if(d!==f||u!==p){var y=m.push("translate(",null,n,null,o);h.push({i:y-4,x:It(d,f)},{i:y-2,x:It(u,p)})}else(f||p)&&m.push("translate("+f+n+p+o)}function l(d,u,f,p){d!==u?(d-u>180?u+=360:u-d>180&&(d+=360),p.push({i:f.push(i(f)+"rotate(",null,r)-2,x:It(d,u)})):u&&f.push(i(f)+"rotate("+u+r)}function s(d,u,f,p){d!==u?p.push({i:f.push(i(f)+"skewX(",null,r)-2,x:It(d,u)}):u&&f.push(i(f)+"skewX("+u+r)}function c(d,u,f,p,m,h){if(d!==f||u!==p){var y=m.push(i(m)+"scale(",null,",",null,")");h.push({i:y-4,x:It(d,f)},{i:y-2,x:It(u,p)})}else(f!==1||p!==1)&&m.push(i(m)+"scale("+f+","+p+")")}return function(d,u){var f=[],p=[];return d=e(d),u=e(u),a(d.translateX,d.translateY,u.translateX,u.translateY,f,p),l(d.rotate,u.rotate,f,p),s(d.skewX,u.skewX,f,p),c(d.scaleX,d.scaleY,u.scaleX,u.scaleY,f,p),d=u=null,function(m){for(var h=-1,y=p.length,g;++h<y;)f[(g=p[h]).i]=g.x(m);return f.join("")}}}var Lv=Ku(Dv,"px, ","px)","deg)"),Fv=Ku(Mv,", ",")",")"),Uv=1e-12;function ju(e){return((e=Math.exp(e))+1/e)/2}function Kv(e){return((e=Math.exp(e))-1/e)/2}function jv(e){return((e=Math.exp(2*e))-1)/(e+1)}const Wr=function e(n,o,r){function i(a,l){var s=a[0],c=a[1],d=a[2],u=l[0],f=l[1],p=l[2],m=u-s,h=f-c,y=m*m+h*h,g,_;if(y<Uv)_=Math.log(p/d)/n,g=function(S){return[s+S*m,c+S*h,d*Math.exp(n*S*_)]};else{var w=Math.sqrt(y),b=(p*p-d*d+r*y)/(2*d*o*w),v=(p*p-d*d-r*y)/(2*p*o*w),N=Math.log(Math.sqrt(b*b+1)-b),E=Math.log(Math.sqrt(v*v+1)-v);_=(E-N)/n,g=function(S){var P=S*_,B=ju(N),j=d/(o*w)*(B*jv(n*P+N)-Kv(N));return[s+j*m,c+j*h,d*B/ju(n*P+N)]}}return g.duration=_*1e3*n/Math.SQRT2,g}return i.rho=function(a){var l=Math.max(.001,+a),s=l*l,c=s*s;return e(l,s,c)},i}(Math.SQRT2,2,4);var Yn=0,Bo=0,Vo=0,Gu=1e3,Xr,Ro,Zr=0,yn=0,Jr=0,Do=typeof performance=="object"&&performance.now?performance:Date,qu=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function il(){return yn||(qu(Gv),yn=Do.now()+Jr)}function Gv(){yn=0}function Qr(){this._call=this._time=this._next=null}Qr.prototype=zu.prototype={constructor:Qr,restart:function(e,n,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?il():+o)+(n==null?0:+n),!this._next&&Ro!==this&&(Ro?Ro._next=this:Xr=this,Ro=this),this._call=e,this._time=o,al()},stop:function(){this._call&&(this._call=null,this._time=1/0,al())}};function zu(e,n,o){var r=new Qr;return r.restart(e,n,o),r}function qv(){il(),++Yn;for(var e=Xr,n;e;)(n=yn-e._time)>=0&&e._call.call(void 0,n),e=e._next;--Yn}function Hu(){yn=(Zr=Do.now())+Jr,Yn=Bo=0;try{qv()}finally{Yn=0,Hv(),yn=0}}function zv(){var e=Do.now(),n=e-Zr;n>Gu&&(Jr-=n,Zr=e)}function Hv(){for(var e,n=Xr,o,r=1/0;n;)n._call?(r>n._time&&(r=n._time),e=n,n=n._next):(o=n._next,n._next=null,n=e?e._next=o:Xr=o);Ro=e,al(r)}function al(e){if(!Yn){Bo&&(Bo=clearTimeout(Bo));var n=e-yn;n>24?(e<1/0&&(Bo=setTimeout(Hu,e-Do.now()-Jr)),Vo&&(Vo=clearInterval(Vo))):(Vo||(Zr=Do.now(),Vo=setInterval(zv,Gu)),Yn=1,qu(Hu))}}function Yu(e,n,o){var r=new Qr;return n=n==null?0:+n,r.restart(i=>{r.stop(),e(i+n)},n,o),r}var Yv=Mr("start","end","cancel","interrupt"),Wv=[],Wu=0,Xu=1,ll=2,ei=3,Zu=4,sl=5,ti=6;function ni(e,n,o,r,i,a){var l=e.__transition;if(!l)e.__transition={};else if(o in l)return;Xv(e,o,{name:n,index:r,group:i,on:Yv,tween:Wv,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:Wu})}function cl(e,n){var o=wt(e,n);if(o.state>Wu)throw new Error("too late; already scheduled");return o}function Pt(e,n){var o=wt(e,n);if(o.state>ei)throw new Error("too late; already running");return o}function wt(e,n){var o=e.__transition;if(!o||!(o=o[n]))throw new Error("transition not found");return o}function Xv(e,n,o){var r=e.__transition,i;r[n]=o,o.timer=zu(a,0,o.time);function a(d){o.state=Xu,o.timer.restart(l,o.delay,o.time),o.delay<=d&&l(d-o.delay)}function l(d){var u,f,p,m;if(o.state!==Xu)return c();for(u in r)if(m=r[u],m.name===o.name){if(m.state===ei)return Yu(l);m.state===Zu?(m.state=ti,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete r[u]):+u<n&&(m.state=ti,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete r[u])}if(Yu(function(){o.state===ei&&(o.state=Zu,o.timer.restart(s,o.delay,o.time),s(d))}),o.state=ll,o.on.call("start",e,e.__data__,o.index,o.group),o.state===ll){for(o.state=ei,i=new Array(p=o.tween.length),u=0,f=-1;u<p;++u)(m=o.tween[u].value.call(e,e.__data__,o.index,o.group))&&(i[++f]=m);i.length=f+1}}function s(d){for(var u=d<o.duration?o.ease.call(null,d/o.duration):(o.timer.restart(c),o.state=sl,1),f=-1,p=i.length;++f<p;)i[f].call(e,u);o.state===sl&&(o.on.call("end",e,e.__data__,o.index,o.group),c())}function c(){o.state=ti,o.timer.stop(),delete r[n];for(var d in r)return;delete e.__transition}}function oi(e,n){var o=e.__transition,r,i,a=!0,l;if(o){n=n==null?null:n+"";for(l in o){if((r=o[l]).name!==n){a=!1;continue}i=r.state>ll&&r.state<sl,r.state=ti,r.timer.stop(),r.on.call(i?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete o[l]}a&&delete e.__transition}}function Zv(e){return this.each(function(){oi(this,e)})}function Jv(e,n){var o,r;return function(){var i=Pt(this,e),a=i.tween;if(a!==o){r=o=a;for(var l=0,s=r.length;l<s;++l)if(r[l].name===n){r=r.slice(),r.splice(l,1);break}}i.tween=r}}function Qv(e,n,o){var r,i;if(typeof o!="function")throw new Error;return function(){var a=Pt(this,e),l=a.tween;if(l!==r){i=(r=l).slice();for(var s={name:n,value:o},c=0,d=i.length;c<d;++c)if(i[c].name===n){i[c]=s;break}c===d&&i.push(s)}a.tween=i}}function eS(e,n){var o=this._id;if(e+="",arguments.length<2){for(var r=wt(this.node(),o).tween,i=0,a=r.length,l;i<a;++i)if((l=r[i]).name===e)return l.value;return null}return this.each((n==null?Jv:Qv)(o,e,n))}function dl(e,n,o){var r=e._id;return e.each(function(){var i=Pt(this,r);(i.value||(i.value={}))[n]=o.apply(this,arguments)}),function(i){return wt(i,r).value[n]}}function Ju(e,n){var o;return(typeof n=="number"?It:n instanceof mn?Hr:(o=mn(n))?(n=o,Hr):Lu)(e,n)}function tS(e){return function(){this.removeAttribute(e)}}function nS(e){return function(){this.removeAttributeNS(e.space,e.local)}}function oS(e,n,o){var r,i=o+"",a;return function(){var l=this.getAttribute(e);return l===i?null:l===r?a:a=n(r=l,o)}}function rS(e,n,o){var r,i=o+"",a;return function(){var l=this.getAttributeNS(e.space,e.local);return l===i?null:l===r?a:a=n(r=l,o)}}function iS(e,n,o){var r,i,a;return function(){var l,s=o(this),c;return s==null?void this.removeAttribute(e):(l=this.getAttribute(e),c=s+"",l===c?null:l===r&&c===i?a:(i=c,a=n(r=l,s)))}}function aS(e,n,o){var r,i,a;return function(){var l,s=o(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(l=this.getAttributeNS(e.space,e.local),c=s+"",l===c?null:l===r&&c===i?a:(i=c,a=n(r=l,s)))}}function lS(e,n){var o=Fr(e),r=o==="transform"?Fv:Ju;return this.attrTween(e,typeof n=="function"?(o.local?aS:iS)(o,r,dl(this,"attr."+e,n)):n==null?(o.local?nS:tS)(o):(o.local?rS:oS)(o,r,n))}function sS(e,n){return function(o){this.setAttribute(e,n.call(this,o))}}function cS(e,n){return function(o){this.setAttributeNS(e.space,e.local,n.call(this,o))}}function dS(e,n){var o,r;function i(){var a=n.apply(this,arguments);return a!==r&&(o=(r=a)&&cS(e,a)),o}return i._value=n,i}function uS(e,n){var o,r;function i(){var a=n.apply(this,arguments);return a!==r&&(o=(r=a)&&sS(e,a)),o}return i._value=n,i}function fS(e,n){var o="attr."+e;if(arguments.length<2)return(o=this.tween(o))&&o._value;if(n==null)return this.tween(o,null);if(typeof n!="function")throw new Error;var r=Fr(e);return this.tween(o,(r.local?dS:uS)(r,n))}function pS(e,n){return function(){cl(this,e).delay=+n.apply(this,arguments)}}function mS(e,n){return n=+n,function(){cl(this,e).delay=n}}function gS(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?pS:mS)(n,e)):wt(this.node(),n).delay}function hS(e,n){return function(){Pt(this,e).duration=+n.apply(this,arguments)}}function yS(e,n){return n=+n,function(){Pt(this,e).duration=n}}function _S(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?hS:yS)(n,e)):wt(this.node(),n).duration}function bS(e,n){if(typeof n!="function")throw new Error;return function(){Pt(this,e).ease=n}}function wS(e){var n=this._id;return arguments.length?this.each(bS(n,e)):wt(this.node(),n).ease}function kS(e,n){return function(){var o=n.apply(this,arguments);if(typeof o!="function")throw new Error;Pt(this,e).ease=o}}function ES(e){if(typeof e!="function")throw new Error;return this.each(kS(this._id,e))}function CS(e){typeof e!="function"&&(e=hu(e));for(var n=this._groups,o=n.length,r=new Array(o),i=0;i<o;++i)for(var a=n[i],l=a.length,s=r[i]=[],c,d=0;d<l;++d)(c=a[d])&&e.call(c,c.__data__,d,a)&&s.push(c);return new Ut(r,this._parents,this._name,this._id)}function NS(e){if(e._id!==this._id)throw new Error;for(var n=this._groups,o=e._groups,r=n.length,i=o.length,a=Math.min(r,i),l=new Array(r),s=0;s<a;++s)for(var c=n[s],d=o[s],u=c.length,f=l[s]=new Array(u),p,m=0;m<u;++m)(p=c[m]||d[m])&&(f[m]=p);for(;s<r;++s)l[s]=n[s];return new Ut(l,this._parents,this._name,this._id)}function vS(e){return(e+"").trim().split(/^|\s+/).every(function(n){var o=n.indexOf(".");return o>=0&&(n=n.slice(0,o)),!n||n==="start"})}function SS(e,n,o){var r,i,a=vS(n)?cl:Pt;return function(){var l=a(this,e),s=l.on;s!==r&&(i=(r=s).copy()).on(n,o),l.on=i}}function xS(e,n){var o=this._id;return arguments.length<2?wt(this.node(),o).on.on(e):this.each(SS(o,e,n))}function AS(e){return function(){var n=this.parentNode;for(var o in this.__transition)if(+o!==e)return;n&&n.removeChild(this)}}function IS(){return this.on("end.remove",AS(this._id))}function PS(e){var n=this._name,o=this._id;typeof e!="function"&&(e=Ya(e));for(var r=this._groups,i=r.length,a=new Array(i),l=0;l<i;++l)for(var s=r[l],c=s.length,d=a[l]=new Array(c),u,f,p=0;p<c;++p)(u=s[p])&&(f=e.call(u,u.__data__,p,s))&&("__data__"in u&&(f.__data__=u.__data__),d[p]=f,ni(d[p],n,o,p,d,wt(u,o)));return new Ut(a,this._parents,n,o)}function TS(e){var n=this._name,o=this._id;typeof e!="function"&&(e=gu(e));for(var r=this._groups,i=r.length,a=[],l=[],s=0;s<i;++s)for(var c=r[s],d=c.length,u,f=0;f<d;++f)if(u=c[f]){for(var p=e.call(u,u.__data__,f,c),m,h=wt(u,o),y=0,g=p.length;y<g;++y)(m=p[y])&&ni(m,n,o,y,p,h);a.push(p),l.push(u)}return new Ut(a,l,n,o)}var OS=Ao.prototype.constructor;function $S(){return new OS(this._groups,this._parents)}function BS(e,n){var o,r,i;return function(){var a=qn(this,e),l=(this.style.removeProperty(e),qn(this,e));return a===l?null:a===o&&l===r?i:i=n(o=a,r=l)}}function Qu(e){return function(){this.style.removeProperty(e)}}function VS(e,n,o){var r,i=o+"",a;return function(){var l=qn(this,e);return l===i?null:l===r?a:a=n(r=l,o)}}function RS(e,n,o){var r,i,a;return function(){var l=qn(this,e),s=o(this),c=s+"";return s==null&&(c=s=(this.style.removeProperty(e),qn(this,e))),l===c?null:l===r&&c===i?a:(i=c,a=n(r=l,s))}}function DS(e,n){var o,r,i,a="style."+n,l="end."+a,s;return function(){var c=Pt(this,e),d=c.on,u=c.value[a]==null?s||(s=Qu(n)):void 0;(d!==o||i!==u)&&(r=(o=d).copy()).on(l,i=u),c.on=r}}function MS(e,n,o){var r=(e+="")=="transform"?Lv:Ju;return n==null?this.styleTween(e,BS(e,r)).on("end.style."+e,Qu(e)):typeof n=="function"?this.styleTween(e,RS(e,r,dl(this,"style."+e,n))).each(DS(this._id,e)):this.styleTween(e,VS(e,r,n),o).on("end.style."+e,null)}function LS(e,n,o){return function(r){this.style.setProperty(e,n.call(this,r),o)}}function FS(e,n,o){var r,i;function a(){var l=n.apply(this,arguments);return l!==i&&(r=(i=l)&&LS(e,l,o)),r}return a._value=n,a}function US(e,n,o){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(n==null)return this.tween(r,null);if(typeof n!="function")throw new Error;return this.tween(r,FS(e,n,o??""))}function KS(e){return function(){this.textContent=e}}function jS(e){return function(){var n=e(this);this.textContent=n??""}}function GS(e){return this.tween("text",typeof e=="function"?jS(dl(this,"text",e)):KS(e==null?"":e+""))}function qS(e){return function(n){this.textContent=e.call(this,n)}}function zS(e){var n,o;function r(){var i=e.apply(this,arguments);return i!==o&&(n=(o=i)&&qS(i)),n}return r._value=e,r}function HS(e){var n="text";if(arguments.length<1)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;return this.tween(n,zS(e))}function YS(){for(var e=this._name,n=this._id,o=ef(),r=this._groups,i=r.length,a=0;a<i;++a)for(var l=r[a],s=l.length,c,d=0;d<s;++d)if(c=l[d]){var u=wt(c,n);ni(c,e,o,d,l,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Ut(r,this._parents,e,o)}function WS(){var e,n,o=this,r=o._id,i=o.size();return new Promise(function(a,l){var s={value:l},c={value:function(){--i===0&&a()}};o.each(function(){var d=Pt(this,r),u=d.on;u!==e&&(n=(e=u).copy(),n._.cancel.push(s),n._.interrupt.push(s),n._.end.push(c)),d.on=n}),i===0&&a()})}var XS=0;function Ut(e,n,o,r){this._groups=e,this._parents=n,this._name=o,this._id=r}function ef(){return++XS}var Kt=Ao.prototype;Ut.prototype={constructor:Ut,select:PS,selectAll:TS,selectChild:Kt.selectChild,selectChildren:Kt.selectChildren,filter:CS,merge:NS,selection:$S,transition:YS,call:Kt.call,nodes:Kt.nodes,node:Kt.node,size:Kt.size,empty:Kt.empty,each:Kt.each,on:xS,attr:lS,attrTween:fS,style:MS,styleTween:US,text:GS,textTween:HS,remove:IS,tween:eS,delay:gS,duration:_S,ease:wS,easeVarying:ES,end:WS,[Symbol.iterator]:Kt[Symbol.iterator]};function ZS(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var JS={time:null,delay:0,duration:250,ease:ZS};function QS(e,n){for(var o;!(o=e.__transition)||!(o=o[n]);)if(!(e=e.parentNode))throw new Error(`transition ${n} not found`);return o}function ex(e){var n,o;e instanceof Ut?(n=e._id,e=e._name):(n=ef(),(o=JS).time=il(),e=e==null?null:e+"");for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var l=r[a],s=l.length,c,d=0;d<s;++d)(c=l[d])&&ni(c,e,n,d,l,o||QS(c,n));return new Ut(r,this._parents,e,n)}Ao.prototype.interrupt=Zv,Ao.prototype.transition=ex;const ri=e=>()=>e;function tx(e,{sourceEvent:n,target:o,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function jt(e,n,o){this.k=e,this.x=n,this.y=o}jt.prototype={constructor:jt,scale:function(e){return e===1?this:new jt(this.k*e,this.x,this.y)},translate:function(e,n){return e===0&n===0?this:new jt(this.k,this.x+this.k*e,this.y+this.k*n)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Wn=new jt(1,0,0);jt.prototype;function ul(e){e.stopImmediatePropagation()}function Mo(e){e.preventDefault(),e.stopImmediatePropagation()}function nx(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function ox(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function tf(){return this.__zoom||Wn}function rx(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function ix(){return navigator.maxTouchPoints||"ontouchstart"in this}function ax(e,n,o){var r=e.invertX(n[0][0])-o[0][0],i=e.invertX(n[1][0])-o[1][0],a=e.invertY(n[0][1])-o[0][1],l=e.invertY(n[1][1])-o[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),l>a?(a+l)/2:Math.min(0,a)||Math.max(0,l))}function lx(){var e=nx,n=ox,o=ax,r=rx,i=ix,a=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],s=250,c=Wr,d=Mr("start","zoom","end"),u,f,p,m=500,h=150,y=0,g=10;function _(I){I.property("__zoom",tf).on("wheel.zoom",P,{passive:!1}).on("mousedown.zoom",B).on("dblclick.zoom",j).filter(i).on("touchstart.zoom",G).on("touchmove.zoom",T).on("touchend.zoom touchcancel.zoom",Y).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}_.transform=function(I,M,R,te){var z=I.selection?I.selection():I;z.property("__zoom",tf),I!==z?N(I,M,R,te):z.interrupt().each(function(){E(this,arguments).event(te).start().zoom(null,typeof M=="function"?M.apply(this,arguments):M).end()})},_.scaleBy=function(I,M,R,te){_.scaleTo(I,function(){var z=this.__zoom.k,H=typeof M=="function"?M.apply(this,arguments):M;return z*H},R,te)},_.scaleTo=function(I,M,R,te){_.transform(I,function(){var z=n.apply(this,arguments),H=this.__zoom,L=R==null?v(z):typeof R=="function"?R.apply(this,arguments):R,F=H.invert(L),Z=typeof M=="function"?M.apply(this,arguments):M;return o(b(w(H,Z),L,F),z,l)},R,te)},_.translateBy=function(I,M,R,te){_.transform(I,function(){return o(this.__zoom.translate(typeof M=="function"?M.apply(this,arguments):M,typeof R=="function"?R.apply(this,arguments):R),n.apply(this,arguments),l)},null,te)},_.translateTo=function(I,M,R,te,z){_.transform(I,function(){var H=n.apply(this,arguments),L=this.__zoom,F=te==null?v(H):typeof te=="function"?te.apply(this,arguments):te;return o(Wn.translate(F[0],F[1]).scale(L.k).translate(typeof M=="function"?-M.apply(this,arguments):-M,typeof R=="function"?-R.apply(this,arguments):-R),H,l)},te,z)};function w(I,M){return M=Math.max(a[0],Math.min(a[1],M)),M===I.k?I:new jt(M,I.x,I.y)}function b(I,M,R){var te=M[0]-R[0]*I.k,z=M[1]-R[1]*I.k;return te===I.x&&z===I.y?I:new jt(I.k,te,z)}function v(I){return[(+I[0][0]+ +I[1][0])/2,(+I[0][1]+ +I[1][1])/2]}function N(I,M,R,te){I.on("start.zoom",function(){E(this,arguments).event(te).start()}).on("interrupt.zoom end.zoom",function(){E(this,arguments).event(te).end()}).tween("zoom",function(){var z=this,H=arguments,L=E(z,H).event(te),F=n.apply(z,H),Z=R==null?v(F):typeof R=="function"?R.apply(z,H):R,Q=Math.max(F[1][0]-F[0][0],F[1][1]-F[0][1]),W=z.__zoom,ie=typeof M=="function"?M.apply(z,H):M,ae=c(W.invert(Z).concat(Q/W.k),ie.invert(Z).concat(Q/ie.k));return function(me){if(me===1)me=ie;else{var ge=ae(me),ne=Q/ge[2];me=new jt(ne,Z[0]-ge[0]*ne,Z[1]-ge[1]*ne)}L.zoom(null,me)}})}function E(I,M,R){return!R&&I.__zooming||new S(I,M)}function S(I,M){this.that=I,this.args=M,this.active=0,this.sourceEvent=null,this.extent=n.apply(I,M),this.taps=0}S.prototype={event:function(I){return I&&(this.sourceEvent=I),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(I,M){return this.mouse&&I!=="mouse"&&(this.mouse[1]=M.invert(this.mouse[0])),this.touch0&&I!=="touch"&&(this.touch0[1]=M.invert(this.touch0[0])),this.touch1&&I!=="touch"&&(this.touch1[1]=M.invert(this.touch1[0])),this.that.__zoom=M,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(I){var M=_t(this.that).datum();d.call(I,this.that,new tx(I,{sourceEvent:this.sourceEvent,target:_,transform:this.that.__zoom,dispatch:d}),M)}};function P(I,...M){if(!e.apply(this,arguments))return;var R=E(this,M).event(I),te=this.__zoom,z=Math.max(a[0],Math.min(a[1],te.k*Math.pow(2,r.apply(this,arguments)))),H=xt(I);if(R.wheel)(R.mouse[0][0]!==H[0]||R.mouse[0][1]!==H[1])&&(R.mouse[1]=te.invert(R.mouse[0]=H)),clearTimeout(R.wheel);else{if(te.k===z)return;R.mouse=[H,te.invert(H)],oi(this),R.start()}Mo(I),R.wheel=setTimeout(L,h),R.zoom("mouse",o(b(w(te,z),R.mouse[0],R.mouse[1]),R.extent,l));function L(){R.wheel=null,R.end()}}function B(I,...M){if(p||!e.apply(this,arguments))return;var R=I.currentTarget,te=E(this,M,!0).event(I),z=_t(I.view).on("mousemove.zoom",Z,!0).on("mouseup.zoom",Q,!0),H=xt(I,R),L=I.clientX,F=I.clientY;Su(I.view),ul(I),te.mouse=[H,this.__zoom.invert(H)],oi(this),te.start();function Z(W){if(Mo(W),!te.moved){var ie=W.clientX-L,ae=W.clientY-F;te.moved=ie*ie+ae*ae>y}te.event(W).zoom("mouse",o(b(te.that.__zoom,te.mouse[0]=xt(W,R),te.mouse[1]),te.extent,l))}function Q(W){z.on("mousemove.zoom mouseup.zoom",null),xu(W.view,te.moved),Mo(W),te.event(W).end()}}function j(I,...M){if(e.apply(this,arguments)){var R=this.__zoom,te=xt(I.changedTouches?I.changedTouches[0]:I,this),z=R.invert(te),H=R.k*(I.shiftKey?.5:2),L=o(b(w(R,H),te,z),n.apply(this,M),l);Mo(I),s>0?_t(this).transition().duration(s).call(N,L,te,I):_t(this).call(_.transform,L,te,I)}}function G(I,...M){if(e.apply(this,arguments)){var R=I.touches,te=R.length,z=E(this,M,I.changedTouches.length===te).event(I),H,L,F,Z;for(ul(I),L=0;L<te;++L)F=R[L],Z=xt(F,this),Z=[Z,this.__zoom.invert(Z),F.identifier],z.touch0?!z.touch1&&z.touch0[2]!==Z[2]&&(z.touch1=Z,z.taps=0):(z.touch0=Z,H=!0,z.taps=1+!!u);u&&(u=clearTimeout(u)),H&&(z.taps<2&&(f=Z[0],u=setTimeout(function(){u=null},m)),oi(this),z.start())}}function T(I,...M){if(this.__zooming){var R=E(this,M).event(I),te=I.changedTouches,z=te.length,H,L,F,Z;for(Mo(I),H=0;H<z;++H)L=te[H],F=xt(L,this),R.touch0&&R.touch0[2]===L.identifier?R.touch0[0]=F:R.touch1&&R.touch1[2]===L.identifier&&(R.touch1[0]=F);if(L=R.that.__zoom,R.touch1){var Q=R.touch0[0],W=R.touch0[1],ie=R.touch1[0],ae=R.touch1[1],me=(me=ie[0]-Q[0])*me+(me=ie[1]-Q[1])*me,ge=(ge=ae[0]-W[0])*ge+(ge=ae[1]-W[1])*ge;L=w(L,Math.sqrt(me/ge)),F=[(Q[0]+ie[0])/2,(Q[1]+ie[1])/2],Z=[(W[0]+ae[0])/2,(W[1]+ae[1])/2]}else if(R.touch0)F=R.touch0[0],Z=R.touch0[1];else return;R.zoom("touch",o(b(L,F,Z),R.extent,l))}}function Y(I,...M){if(this.__zooming){var R=E(this,M).event(I),te=I.changedTouches,z=te.length,H,L;for(ul(I),p&&clearTimeout(p),p=setTimeout(function(){p=null},m),H=0;H<z;++H)L=te[H],R.touch0&&R.touch0[2]===L.identifier?delete R.touch0:R.touch1&&R.touch1[2]===L.identifier&&delete R.touch1;if(R.touch1&&!R.touch0&&(R.touch0=R.touch1,delete R.touch1),R.touch0)R.touch0[1]=this.__zoom.invert(R.touch0[0]);else if(R.end(),R.taps===2&&(L=xt(L,this),Math.hypot(f[0]-L[0],f[1]-L[1])<g)){var F=_t(this).on("dblclick.zoom");F&&F.apply(this,arguments)}}}return _.wheelDelta=function(I){return arguments.length?(r=typeof I=="function"?I:ri(+I),_):r},_.filter=function(I){return arguments.length?(e=typeof I=="function"?I:ri(!!I),_):e},_.touchable=function(I){return arguments.length?(i=typeof I=="function"?I:ri(!!I),_):i},_.extent=function(I){return arguments.length?(n=typeof I=="function"?I:ri([[+I[0][0],+I[0][1]],[+I[1][0],+I[1][1]]]),_):n},_.scaleExtent=function(I){return arguments.length?(a[0]=+I[0],a[1]=+I[1],_):[a[0],a[1]]},_.translateExtent=function(I){return arguments.length?(l[0][0]=+I[0][0],l[1][0]=+I[1][0],l[0][1]=+I[0][1],l[1][1]=+I[1][1],_):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},_.constrain=function(I){return arguments.length?(o=I,_):o},_.duration=function(I){return arguments.length?(s=+I,_):s},_.interpolate=function(I){return arguments.length?(c=I,_):c},_.on=function(){var I=d.on.apply(d,arguments);return I===d?_:I},_.clickDistance=function(I){return arguments.length?(y=(I=+I)*I,_):Math.sqrt(y)},_.tapDistance=function(I){return arguments.length?(g=+I,_):g},_}var ye=(e=>(e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom",e))(ye||{}),fl=(e=>(e.Partial="partial",e.Full="full",e))(fl||{}),_n=(e=>(e.Bezier="default",e.SimpleBezier="simple-bezier",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e))(_n||{}),Xt=(e=>(e.Strict="strict",e.Loose="loose",e))(Xt||{}),ii=(e=>(e.Arrow="arrow",e.ArrowClosed="arrowclosed",e))(ii||{}),Lo=(e=>(e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal",e))(Lo||{}),nf=(e=>(e.TopLeft="top-left",e.TopCenter="top-center",e.TopRight="top-right",e.BottomLeft="bottom-left",e.BottomCenter="bottom-center",e.BottomRight="bottom-right",e))(nf||{});const sx=["INPUT","SELECT","TEXTAREA"],cx=typeof document<"u"?document:null;function pl(e){var n,o;const r=((o=(n=e.composedPath)==null?void 0:n.call(e))==null?void 0:o[0])||e.target,i=typeof(r==null?void 0:r.hasAttribute)=="function"?r.hasAttribute("contenteditable"):!1,a=typeof(r==null?void 0:r.closest)=="function"?r.closest(".nokey"):null;return sx.includes(r==null?void 0:r.nodeName)||i||!!a}function dx(e){return e.ctrlKey||e.metaKey||e.shiftKey||e.altKey}function of(e,n,o,r){const i=n.replace("+",`
|
|
119
|
+
`)[0],w=[{startLineNumber:y+1,startColumn:g+1,endLineNumber:y+1,endColumn:g+2,message:_,severity:lr.MarkerSeverity.Error,source:Ra}];lr.editor.setModelMarkers(u,Ra,w),a("error",_)}})}),t.onBeforeUnmount(()=>{var d;(d=s.value)==null||d.dispose()}),n({setExampleCode:c}),(d,u)=>(t.openBlock(),t.createElementBlock("div",WC,[t.createVNode(t.unref(Pe.KAlert),{class:"examples"},{icon:t.withCtx(()=>[t.createVNode(t.unref(Ne.SparklesIcon))]),default:t.withCtx(()=>[t.createElementVNode("div",XC,[t.createTextVNode(t.toDisplayString(t.unref(r)("plugins.free-form.datakit.description_example"))+" ",1),(t.openBlock(),t.createElementBlock(t.Fragment,null,t.renderList(Xd,(f,p)=>t.createVNode(t.unref(Pe.KButton),{key:p,appearance:"secondary",size:"small",onClick:m=>c(p)},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(r)(`plugins.free-form.datakit.examples.${p}`)),1)]),_:2},1032,["onClick"])),64))])]),_:1}),t.createElementVNode("div",ZC,null,512)]))}}),[["__scopeId","data-v-fd44a27b"]]),{t:Da}=Fe.createI18n("en-us",He);function St(e){return Da(`plugins.free-form.datakit.flow_editor.node_types.${e}.description`)}function vo(e){return Da(`plugins.free-form.datakit.flow_editor.node_types.${e}.summary`)}function eN(e){return Da(`plugins.free-form.datakit.flow_editor.node_types.${e}.name`)}const Tr={call:{type:"call",summary:vo("call"),description:St("call"),icon:Ne.NetworkIcon,io:{input:{fields:[{name:"headers"},{name:"body"},{name:"query"}]},output:{fields:[{name:"headers"},{name:"body"},{name:"status"}]}}},jq:{type:"jq",summary:vo("jq"),description:St("jq"),icon:Ne.CodeblockIcon,io:{input:{fields:[],configurable:!0},output:{fields:[]}}},exit:{type:"exit",summary:vo("exit"),description:St("exit"),icon:Ne.GatewayIcon,io:{input:{fields:[{name:"headers"},{name:"body"}]}}},property:{type:"property",summary:vo("property"),description:St("property"),icon:Ne.StackIcon,io:{input:{fields:[],configurable:!0},output:{fields:[]}}},static:{type:"static",summary:vo("static"),description:St("static"),icon:Ne.VitalsIcon,io:{output:{fields:[],configurable:!0}}}},Or={request:{type:"request",description:St("request"),io:{output:{fields:[{name:"headers"},{name:"body"},{name:"query"}]}}},service_request:{type:"service_request",description:St("service_request"),io:{input:{fields:[{name:"headers"},{name:"body"},{name:"query"}]}}},service_response:{type:"service_response",description:St("service_response"),io:{output:{fields:[{name:"headers"},{name:"body"}]}}},response:{type:"response",description:St("response"),io:{input:{fields:[{name:"headers"},{name:"body"}]}}}},Zd=Object.keys(Or),Ma=e=>Zd.includes(e),Lt=e=>Zd.includes(e),Jd=e=>Lt(e.type);function Kn(e){return Tn(e)}function So(e){return`${e}:${kr()}`}function $r(e){const[n,o]=e.split(".");return{nodeName:n,fieldName:o}}function Qd(e){const[n,o]=e.split(".");return{nodeId:n,fieldId:o}}function La(e){return Lt(e)?Or[e]:Tr[e]}function eu(e){var i,a,l,s,c,d;const n=La(e),o=((l=(a=(i=n.io)==null?void 0:i.input)==null?void 0:a.fields)==null?void 0:l.map(({name:u})=>u))??[],r=((d=(c=(s=n.io)==null?void 0:s.output)==null?void 0:c.fields)==null?void 0:d.map(({name:u})=>u))??[];return{input:o,output:r}}function tu(e){return(e??[]).map(n=>({id:So("field"),name:n}))}function jn(e,n,o){if(o)return e.fields[n].find(r=>r.name===o)}function Wt(e,n,o){if(o)return e.fields[n].find(r=>r.id===o)}function Fa(e,n){return n?e.fields.output.some(o=>o.id===n):!0}function nu(e,n){return n?e.fields.input.some(o=>o.id===n):!0}function tN(e){const n=e==="request"||e==="service_request"?"request":"response",o=Or[e];return{name:e,phase:n,position:{x:0,y:0},fields:eu(o.type),expanded:{}}}function nN(e,n){const o=e.toUpperCase();let r=1;for(;n.has(`${o}_${r}`);)r++;return`${o}_${r}`}function oN(e,n){const{commit:o,undo:r,redo:i,canUndo:a,canRedo:l,clear:s,reset:c,undoStack:d}=Ue.useManualRefHistory(e,{capacity:n==null?void 0:n.capacity,clone:n==null?void 0:n.clone});let u;function f(_){var w;(w=n==null?void 0:n.onHistoryChange)==null||w.call(n,_,e.value)}function p(_){if(!_){u=void 0,o(),f("commit");return}if(_!=="*"&&u!==_){u=_,o(),f("commit");return}o(),d.value.length>1?d.value.splice(1,1):d.value.length===1&&d.value.splice(0,1),f("commit")}function m(){r(),u=void 0,f("undo")}function h(){i(),u=void 0,f("redo")}function y(){s(),u=void 0,f("clear")}function g(){c(),u=void 0,f("reset")}return{canUndo:a,canRedo:l,commit:p,undo:m,redo:h,clear:y,reset:g}}const rN="44px",iN="220px",aN="366px",lN="52px",Br=["request","service_request","service_response","response"],Vr=Br,ou=["GET","HEAD","POST","PUT","PATCH","DELETE","OPTIONS","TRACE","CONNECT"],xo="application/x-datakit+json",Ua={delete:["Delete"],undo:["Mod","Z"],redo:{mac:["Mod","Shift","Z"],windows:["Mod","Y"],linux:["Mod","Shift","Z"]},copy:["Mod","C"],paste:["Mod","V"],duplicate:["Mod","D"]};function ru(e,n){var u,f;const o=new Map(n.map(p=>[p.name,p])),r=[],i=[],a=new Map,l=[],s=new Map,c=p=>{const m=new Set,h=[...p];for(;h.length>0;){const y=h.shift();if(!m.has(y)&&(m.add(y),Ma(y)||(a.get(y).phase="request"),!!s.has(y)))for(const g of s.get(y))m.has(g)||h.push(g)}};let d=!1;for(const p of e){const m=o.get(p.name);!m&&!d&&(d=!0);const h=au(p.type,p,m);r.push(h),a.set(h.name,h)}for(const p of Vr)if(!a.has(p)){let m=o.get(p);m||(d||(d=!0),m=tN(p));const h=au(p,void 0,m);r.push(h),a.set(h.name,h)}for(const p of e)dN(p,l);for(const p of l){const m=a.get(p.source),h=a.get(p.target);if(!m||!h){m||console.warn(`[initEditorState] skip: source "${p.source}" not found`),h||console.warn(`[initEditorState] skip: target "${p.target}" not found`);continue}s.has(p.source)||s.set(p.source,new Set),s.get(p.source).add(p.target),s.has(p.target)||s.set(p.target,new Set),s.get(p.target).add(p.source),i.push({id:So("edge"),source:m.id,sourceField:(u=jn(m,"output",p.sourceField))==null?void 0:u.id,target:h.id,targetField:(f=jn(h,"input",p.targetField))==null?void 0:f.id})}return c(["request","service_request"]),{nodes:r,edges:i,needLayout:d}}function iu(e){const{type:n,name:o,phase:r,position:i,fields:a,config:l}=e,s=eu(n);return{id:So("node"),type:n,name:o??n,phase:r??"request",position:i??{x:0,y:0},expanded:{},fields:{input:tu((a==null?void 0:a.input)??s.input),output:tu((a==null?void 0:a.output)??s.output)},config:l?Kn(l):{}}}function sN(e){return Lt(e)?e==="request"||e==="service_request"?"request":"response":"request"}function au(e,n,o){return iu({type:e,name:n==null?void 0:n.name,phase:(o==null?void 0:o.phase)??sN(e),position:o==null?void 0:o.position,fields:uN(n,o),config:n?cN(n):void 0})}function cN(e){const{type:n,name:o,input:r,inputs:i,output:a,outputs:l,...s}=e;return Kn(s)}function dN(e,n){const o=e.name;if(e.input){const{nodeName:r,fieldName:i}=$r(e.input);r&&n.push({source:r,sourceField:i,target:o})}if(e.inputs)for(const[r,i]of Object.entries(e.inputs)){if(!i)continue;const{nodeName:a,fieldName:l}=$r(i);a&&n.push({source:a,sourceField:l,target:o,targetField:r})}if(e.output){const{nodeName:r,fieldName:i}=$r(e.output);r&&n.push({source:o,target:r,targetField:i})}if(e.outputs)for(const[r,i]of Object.entries(e.outputs)){if(!i)continue;const{nodeName:a,fieldName:l}=$r(i);a&&n.push({source:o,sourceField:r,target:a,targetField:l})}}function uN(e,n){var a,l;if(!e&&!n)return;const o=new Set,r=new Set;e!=null&&e.inputs&&Object.keys(e.inputs).forEach(s=>o.add(s)),e!=null&&e.outputs&&Object.keys(e.outputs).forEach(s=>r.add(s)),(e==null?void 0:e.type)==="static"&&e.values&&Object.keys(e.values).forEach(s=>r.add(s)),(a=n==null?void 0:n.fields)!=null&&a.input&&n.fields.input.forEach(s=>o.add(s)),(l=n==null?void 0:n.fields)!=null&&l.output&&n.fields.output.forEach(s=>r.add(s));const i={};return o.size&&(i.input=Array.from(o)),r.size&&(i.output=Array.from(r)),Object.keys(i).length?i:void 0}function fN(e){const n=t.computed(()=>{const c=new Map;return e.value.nodes.forEach(d=>c.set(d.id,d)),c}),o=t.computed(()=>e.value.edges);function r(c){const d=n.value.get(c.source),u=n.value.get(c.target);if(!d||!u)return c;const f=nu(d,c.sourceField)&&!Fa(d,c.sourceField),p=Fa(u,c.targetField);return f&&p?{source:c.target,sourceField:c.targetField,target:c.source,targetField:c.sourceField}:c}function i(c){const d=r(c),u=[],f=n.value.get(d.source),p=n.value.get(d.target);if(f||u.push("source node not found"),p||u.push("target node not found"),!f||!p)return{ok:!1,errors:u};Fa(f,d.sourceField)||u.push("source handle is not an output field"),nu(p,d.targetField)||u.push("target handle is not an input field"),p.name==="request"&&u.push('cannot target "request"'),f.name==="response"&&u.push('cannot source from "response"');const m=o.value.some(g=>g.target===d.target&&!g.targetField),h=o.value.some(g=>g.target===d.target&&!!g.targetField);(m&&d.targetField||h&&!d.targetField)&&u.push("cannot mix whole-node and field-level inputs on same target"),d.targetField&&o.value.some(g=>g.target===d.target&&g.targetField===d.targetField)&&u.push("target field already connected"),!d.targetField&&o.value.some(g=>g.target===d.target&&!g.targetField)&&u.push("target input already taken"),d.source===d.target&&u.push("self-loop not allowed");const y=Rr(o.value,d);return Ka(y)&&u.push("connection introduces a cycle"),u.length?{ok:!1,errors:u}:{ok:!0}}function a(){const c=[];for(const d of Vr)[...n.value.values()].some(u=>u.name===d)||c.push(`missing implicit node "${d}"`);for(const d of o.value){const u=n.value.get(d.source);n.value.get(d.target).name==="request"&&c.push(`edge "${d.id}" targets "request"`),u.name==="response"&&c.push(`edge "${d.id}" sources from "response"`)}return Ka(Rr(o.value))&&c.push("graph contains cycle"),c.length?{ok:!1,errors:c}:{ok:!0}}function l(c){return i(c).ok}function s(c){return!c.source||!c.target?!1:l({source:c.source,sourceField:c.sourceHandle,target:c.target,targetField:c.targetHandle})}return{canonicalizeConnection:r,validateConnection:i,validateGraph:a,isValidConnection:l,isValidVueFlowConnection:s,buildAdjacency:Rr}}function Ka(e){const n=new Set,o=new Set;function r(i){if(o.has(i))return!0;if(n.has(i))return!1;n.add(i),o.add(i);for(const a of e.get(i)??[])if(r(a))return!0;return o.delete(i),!1}for(const i of e.keys())if(r(i))return!0;return!1}function Rr(e,n){const o=new Map;for(const r of e)o.has(r.source)||o.set(r.source,[]),o.get(r.source).push(r.target),o.has(r.target)||o.set(r.target,[]);return n&&(o.has(n.source)||o.set(n.source,[]),o.get(n.source).push(n.target),o.has(n.target)||o.set(n.target,[])),o}const[pN,mN]=Ue.createInjectionState(function(n,o,r={}){const i=t.ref(ru(n,o)),a=t.ref(),l=t.ref(!1),s=t.ref(!1),c=oN(i,{capacity:200,clone:Kn,onHistoryChange:O=>{var k;O!=="clear"&&((k=r.onChange)==null||k.call(r,re(),q()))}}),d=t.ref(null),u=t.ref(new Set);function f(){i.value.needLayout=!1}const p=t.computed(()=>new Map(i.value.nodes.map(O=>[O.id,O]))),m=t.computed(()=>new Map(i.value.nodes.map(O=>[O.name,O]))),h=t.computed(()=>{const O=new Map,k=new Map;for(const C of i.value.edges)O.set(C.id,C),k.has(C.source)||k.set(C.source,new Set),k.get(C.source).add(C.id),k.has(C.target)||k.set(C.target,new Set),k.get(C.target).add(C.id);return{edgeMapById:O,edgeIdMapByNodeId:k}}),y=t.computed(()=>h.value.edgeMapById),g=t.computed(()=>h.value.edgeIdMapByNodeId),_=t.computed(()=>new Set(i.value.nodes.map(O=>O.name))),{canonicalizeConnection:w,validateConnection:b,validateGraph:v,isValidConnection:N,isValidVueFlowConnection:E}=fN(i);function S(O){return p.value.get(O)}function P(O){return m.value.get(O)}function B(O){return y.value.get(O)}function j(O){if(!g.value.has(O))return[];const k=[];return g.value.get(O).forEach(C=>{const x=B(C);x&&k.push(x)}),k}function G(O){return j(O).filter(k=>k.target===O)}function T(O){return j(O).filter(k=>k.source===O)}const Y=t.computed(()=>a.value?S(a.value):void 0);function I(O){a.value=O}function M(O){if(Lt(O.type))throw new Error("[createNode] implicit nodes are fixed.");return iu({type:O.type,name:O.name||(Lt(O.type)?void 0:nN(O.type,_.value)),phase:O.phase,position:O.position,fields:O.fields,config:O.config})}function R(O,k=!0){const C=M(O);if(C)return i.value.nodes.push(C),k&&c.commit(),C.id}function te(O,k=!0){i.value.edges=i.value.edges.filter(x=>x.source!==O&&x.target!==O),i.value.nodes=i.value.nodes.filter(x=>x.id!==O),a.value===O&&(a.value=void 0);const C=v();C.ok||console.warn("[removeNode] topology invalid:",C.errors.join("; ")),k&&c.commit()}function z(O,k,C=!0,x){const A=S(O);if(A){if(Ma(A.name)){console.warn("[renameNode] implicit node name is reserved.");return}A.name=k,C&&c.commit(x)}}function H(O,k,C=!0){const x=S(O);x&&(x.position={...k},C&&c.commit())}function L(O,k,C,x=!0,A){const U=S(O);U&&(U.expanded[k]=C??!U.expanded[k],x&&c.commit(A??`toggle:${O}:${k}`))}function F(O,k,C=!0,x){const A=S(O);A&&(A.config=Kn(k),C&&c.commit(x))}function Z(O,k,C,x=!0){const A=S(O);if(!A)return;const U=A.fields[k];if(U.some(V=>V.name===C)){console.warn(`[addField] field "${C}" already exists on ${k}.`);return}U.push({id:So("field"),name:C}),k==="input"?A.fields.input=U:A.fields.output=U,x&&c.commit()}function Q(O,k,C,x=!0){const A=S(O);if(!A)return;const U=A.fields.input,V=A.fields.output,J=U.find($=>$.id===k)??V.find($=>$.id===k);J&&(J.name=C,x&&c.commit())}function W(O,k,C=!0,x=!0){const A=S(O);if(!A)return;const U=A.fields.input,V=A.fields.output,J=U.findIndex(D=>D.id===k);J>=0&&U.splice(J,1);const $=V.findIndex(D=>D.id===k);$>=0&&V.splice($,1),A.fields.input=U,A.fields.output=V,C&&(i.value.edges=i.value.edges.filter(D=>D.sourceField!==k&&D.targetField!==k));const X=v();X.ok||console.warn("[removeField] topology invalid:",X.errors.join("; ")),x&&c.commit()}function ie(O,k=!0){const C=w(O),x=b(C);if(!x.ok){console.warn("[connectEdge] invalid connection:",x.errors.join("; "));return}const A={id:So("edge"),...C};i.value.edges.push(A);const U=v();if(!U.ok){i.value.edges.pop(),console.warn("[connectEdge] topology invalid:",U.errors.join("; "));return}return k&&c.commit(),A.id}function ae(O,k,C=!0){me(O,!1),ie(k,!1),C&&c.commit()}function me(O,k=!0){const C=i.value.edges.findIndex(U=>U.id===O);if(C<0)return;const x=i.value.edges[C];i.value.edges.splice(C,1);const A=v();if(!A.ok){i.value.edges.splice(C,0,x),console.warn("[disconnectEdge] topology invalid:",A.errors.join("; "));return}k&&c.commit()}function ge(O,k=!0){const C=G(O);for(const x of C)me(x.id,!1);k&&c.commit()}function ne(O,k=!0){const C=T(O);for(const x of C)me(x.id,!1);k&&c.commit()}function re(){var k,C,x,A,U;const O=[];for(const V of i.value.nodes){if(Lt(V.type))continue;let J;const $={};let X;const D={};for(const fe of i.value.edges.filter(oe=>oe.target===V.id)){const oe=S(fe.source);if(!oe)continue;const be=(k=Wt(oe,"output",fe.sourceField))==null?void 0:k.name,ve=be?`${oe.name}.${be}`:oe.name,ue=(C=Wt(V,"input",fe.targetField))==null?void 0:C.name;ue?$[ue]=ve:J===void 0&&(J=ve)}for(const fe of i.value.edges.filter(oe=>oe.source===V.id)){const oe=S(fe.target);if(!oe)continue;const be=oe.type;if(!Lt(be)||!((x=Or[be].io)!=null&&x.input))continue;const ve=(A=Wt(oe,"input",fe.targetField))==null?void 0:A.name,ue=ve?`${oe.name}.${ve}`:oe.name,de=(U=Wt(V,"output",fe.sourceField))==null?void 0:U.name;de?D[de]=ue:X===void 0&&(X=ue)}const pe={...Kn(V.config),name:V.name,type:V.type};Object.keys($).length>0?pe.inputs=$:J!==void 0&&(pe.input=J),Object.keys(D).length>0?pe.outputs=D:X!==void 0&&(pe.output=X),O.push(pe)}return O}function q(){return i.value.nodes.map(O=>Kn({name:O.name,phase:O.phase,position:{...O.position},expanded:{...O.expanded},fields:{input:O.fields.input.map(k=>k.name),output:O.fields.output.map(k=>k.name)}}))}function ee(O,k){i.value=ru(O,k),c.reset()}return{state:i,selection:a,modalOpen:l,newCreatedNodeId:d,invalidConfigNodeIds:u,propertiesPanelOpen:s,nodeMapById:p,nodeMapByName:m,edgeMapById:y,edgeIdMapByNodeId:g,getNodeById:S,getNodeByName:P,getEdgeById:B,getEdgesByNodeId:j,getInEdgesByNodeId:G,getOutEdgesByNodeId:T,selectedNode:Y,selectNode:I,createNode:M,addNode:R,removeNode:te,renameNode:z,moveNode:H,toggleExpanded:L,replaceConfig:F,addField:Z,renameField:Q,removeField:W,connectEdge:ie,replaceConnection:ae,disconnectEdge:me,disconnectInEdges:ge,disconnectOutEdges:ne,toConfigNodes:re,toUINodes:q,load:ee,commit:c.commit,undo:c.undo,redo:c.redo,canUndo:c.canUndo,canRedo:c.canRedo,clear:c.clear,reset:c.reset,isValidConnection:N,isValidVueFlowConnection:E,validateGraph:()=>v(),markAsLayoutCompleted:f}});function st(){const e=mN();if(!e)throw new Error("Editor state is not provided. Ensure you are using provideEditorStore in a parent component.");return e}const ja=Ue.createGlobalState(()=>{const e=Ue.useLocalStorage("datakit-editor-mode","flow"),n=Ue.useLocalStorage("datakit-editor-sidebar-expanded",!0);return{editorMode:e,sidePanelExpanded:n}});function Dr(e){return t.getCurrentScope()?(t.onScopeDispose(e),!0):!1}function Ft(e){return typeof e=="function"?e():t.unref(e)}const gN=typeof window<"u"&&typeof document<"u",hN=e=>typeof e<"u",yN=Object.prototype.toString,_N=e=>yN.call(e)==="[object Object]",bN=()=>{};function wN(e,n){function o(...r){return new Promise((i,a)=>{Promise.resolve(e(()=>n.apply(this,r),{fn:n,thisArg:this,args:r})).then(i).catch(a)})}return o}const lu=e=>e();function kN(e=lu){const n=t.ref(!0);function o(){n.value=!1}function r(){n.value=!0}const i=(...a)=>{n.value&&e(...a)};return{isActive:t.readonly(n),pause:o,resume:r,eventFilter:i}}function su(e,n=!1,o="Timeout"){return new Promise((r,i)=>{setTimeout(n?()=>i(o):r,e)})}function EN(e,n,o={}){const{eventFilter:r=lu,...i}=o;return t.watch(e,wN(r,n),i)}function Gn(e,n,o={}){const{eventFilter:r,...i}=o,{eventFilter:a,pause:l,resume:s,isActive:c}=kN(r);return{stop:EN(e,n,{...i,eventFilter:a}),pause:l,resume:s,isActive:c}}function CN(e,n={}){if(!t.isRef(e))return t.toRefs(e);const o=Array.isArray(e.value)?Array.from({length:e.value.length}):{};for(const r in e.value)o[r]=t.customRef(()=>({get(){return e.value[r]},set(i){var a;if((a=Ft(n.replaceRef))!=null?a:!0)if(Array.isArray(e.value)){const s=[...e.value];s[r]=i,e.value=s}else{const s={...e.value,[r]:i};Object.setPrototypeOf(s,Object.getPrototypeOf(e.value)),e.value=s}else e.value[r]=i}}));return o}function Ga(e,n=!1){function o(f,{flush:p="sync",deep:m=!1,timeout:h,throwOnTimeout:y}={}){let g=null;const w=[new Promise(b=>{g=t.watch(e,v=>{f(v)!==n&&(g==null||g(),b(v))},{flush:p,deep:m,immediate:!0})})];return h!=null&&w.push(su(h,y).then(()=>Ft(e)).finally(()=>g==null?void 0:g())),Promise.race(w)}function r(f,p){if(!t.isRef(f))return o(v=>v===f,p);const{flush:m="sync",deep:h=!1,timeout:y,throwOnTimeout:g}=p??{};let _=null;const b=[new Promise(v=>{_=t.watch([e,f],([N,E])=>{n!==(N===E)&&(_==null||_(),v(N))},{flush:m,deep:h,immediate:!0})})];return y!=null&&b.push(su(y,g).then(()=>Ft(e)).finally(()=>(_==null||_(),Ft(e)))),Promise.race(b)}function i(f){return o(p=>!!p,f)}function a(f){return r(null,f)}function l(f){return r(void 0,f)}function s(f){return o(Number.isNaN,f)}function c(f,p){return o(m=>{const h=Array.from(m);return h.includes(f)||h.includes(Ft(f))},p)}function d(f){return u(1,f)}function u(f=1,p){let m=-1;return o(()=>(m+=1,m>=f),p)}return Array.isArray(Ft(e))?{toMatch:o,toContains:c,changed:d,changedTimes:u,get not(){return Ga(e,!n)}}:{toMatch:o,toBe:r,toBeTruthy:i,toBeNull:a,toBeNaN:s,toBeUndefined:l,changed:d,changedTimes:u,get not(){return Ga(e,!n)}}}function qa(e){return Ga(e)}function NN(e){var n;const o=Ft(e);return(n=o==null?void 0:o.$el)!=null?n:o}const cu=gN?window:void 0;function du(...e){let n,o,r,i;if(typeof e[0]=="string"||Array.isArray(e[0])?([o,r,i]=e,n=cu):[n,o,r,i]=e,!n)return bN;Array.isArray(o)||(o=[o]),Array.isArray(r)||(r=[r]);const a=[],l=()=>{a.forEach(u=>u()),a.length=0},s=(u,f,p,m)=>(u.addEventListener(f,p,m),()=>u.removeEventListener(f,p,m)),c=t.watch(()=>[NN(n),Ft(i)],([u,f])=>{if(l(),!u)return;const p=_N(f)?{...f}:f;a.push(...o.flatMap(m=>r.map(h=>s(u,m,h,p))))},{immediate:!0,flush:"post"}),d=()=>{c(),l()};return Dr(d),d}function vN(e){return typeof e=="function"?e:typeof e=="string"?n=>n.key===e:Array.isArray(e)?n=>e.includes(n.key):()=>!0}function uu(...e){let n,o,r={};e.length===3?(n=e[0],o=e[1],r=e[2]):e.length===2?typeof e[1]=="object"?(n=!0,o=e[0],r=e[1]):(n=e[0],o=e[1]):(n=!0,o=e[0]);const{target:i=cu,eventName:a="keydown",passive:l=!1,dedupe:s=!1}=r,c=vN(n);return du(i,a,u=>{u.repeat&&Ft(s)||c(u)&&o(u)},l)}function SN(e){return JSON.parse(JSON.stringify(e))}function za(e,n,o,r={}){var i,a,l;const{clone:s=!1,passive:c=!1,eventName:d,deep:u=!1,defaultValue:f,shouldEmit:p}=r,m=t.getCurrentInstance(),h=o||(m==null?void 0:m.emit)||((i=m==null?void 0:m.$emit)==null?void 0:i.bind(m))||((l=(a=m==null?void 0:m.proxy)==null?void 0:a.$emit)==null?void 0:l.bind(m==null?void 0:m.proxy));let y=d;n||(n="modelValue"),y=y||`update:${n.toString()}`;const g=b=>s?typeof s=="function"?s(b):SN(b):b,_=()=>hN(e[n])?g(e[n]):f,w=b=>{p?p(b)&&h(y,b):h(y,b)};if(c){const b=_(),v=t.ref(b);let N=!1;return t.watch(()=>e[n],E=>{N||(N=!0,v.value=g(E),t.nextTick(()=>N=!1))}),t.watch(v,E=>{!N&&(E!==e[n]||u)&&w(E)},{deep:u}),v}else return t.computed({get(){return _()},set(b){w(b)}})}var xN={value:()=>{}};function Mr(){for(var e=0,n=arguments.length,o={},r;e<n;++e){if(!(r=arguments[e]+"")||r in o||/[\s.]/.test(r))throw new Error("illegal type: "+r);o[r]=[]}return new Lr(o)}function Lr(e){this._=e}function AN(e,n){return e.trim().split(/^|\s+/).map(function(o){var r="",i=o.indexOf(".");if(i>=0&&(r=o.slice(i+1),o=o.slice(0,i)),o&&!n.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:r}})}Lr.prototype=Mr.prototype={constructor:Lr,on:function(e,n){var o=this._,r=AN(e+"",o),i,a=-1,l=r.length;if(arguments.length<2){for(;++a<l;)if((i=(e=r[a]).type)&&(i=IN(o[i],e.name)))return i;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++a<l;)if(i=(e=r[a]).type)o[i]=fu(o[i],e.name,n);else if(n==null)for(i in o)o[i]=fu(o[i],e.name,null);return this},copy:function(){var e={},n=this._;for(var o in n)e[o]=n[o].slice();return new Lr(e)},call:function(e,n){if((i=arguments.length-2)>0)for(var o=new Array(i),r=0,i,a;r<i;++r)o[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(n,o)},apply:function(e,n,o){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(n,o)}};function IN(e,n){for(var o=0,r=e.length,i;o<r;++o)if((i=e[o]).name===n)return i.value}function fu(e,n,o){for(var r=0,i=e.length;r<i;++r)if(e[r].name===n){e[r]=xN,e=e.slice(0,r).concat(e.slice(r+1));break}return o!=null&&e.push({name:n,value:o}),e}var Ha="http://www.w3.org/1999/xhtml";const pu={svg:"http://www.w3.org/2000/svg",xhtml:Ha,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Fr(e){var n=e+="",o=n.indexOf(":");return o>=0&&(n=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),pu.hasOwnProperty(n)?{space:pu[n],local:e}:e}function PN(e){return function(){var n=this.ownerDocument,o=this.namespaceURI;return o===Ha&&n.documentElement.namespaceURI===Ha?n.createElement(e):n.createElementNS(o,e)}}function TN(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function mu(e){var n=Fr(e);return(n.local?TN:PN)(n)}function ON(){}function Ya(e){return e==null?ON:function(){return this.querySelector(e)}}function $N(e){typeof e!="function"&&(e=Ya(e));for(var n=this._groups,o=n.length,r=new Array(o),i=0;i<o;++i)for(var a=n[i],l=a.length,s=r[i]=new Array(l),c,d,u=0;u<l;++u)(c=a[u])&&(d=e.call(c,c.__data__,u,a))&&("__data__"in c&&(d.__data__=c.__data__),s[u]=d);return new ct(r,this._parents)}function BN(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function VN(){return[]}function gu(e){return e==null?VN:function(){return this.querySelectorAll(e)}}function RN(e){return function(){return BN(e.apply(this,arguments))}}function DN(e){typeof e=="function"?e=RN(e):e=gu(e);for(var n=this._groups,o=n.length,r=[],i=[],a=0;a<o;++a)for(var l=n[a],s=l.length,c,d=0;d<s;++d)(c=l[d])&&(r.push(e.call(c,c.__data__,d,l)),i.push(c));return new ct(r,i)}function hu(e){return function(){return this.matches(e)}}function yu(e){return function(n){return n.matches(e)}}var MN=Array.prototype.find;function LN(e){return function(){return MN.call(this.children,e)}}function FN(){return this.firstElementChild}function UN(e){return this.select(e==null?FN:LN(typeof e=="function"?e:yu(e)))}var KN=Array.prototype.filter;function jN(){return Array.from(this.children)}function GN(e){return function(){return KN.call(this.children,e)}}function qN(e){return this.selectAll(e==null?jN:GN(typeof e=="function"?e:yu(e)))}function zN(e){typeof e!="function"&&(e=hu(e));for(var n=this._groups,o=n.length,r=new Array(o),i=0;i<o;++i)for(var a=n[i],l=a.length,s=r[i]=[],c,d=0;d<l;++d)(c=a[d])&&e.call(c,c.__data__,d,a)&&s.push(c);return new ct(r,this._parents)}function _u(e){return new Array(e.length)}function HN(){return new ct(this._enter||this._groups.map(_u),this._parents)}function Ur(e,n){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=n}Ur.prototype={constructor:Ur,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,n){return this._parent.insertBefore(e,n)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function YN(e){return function(){return e}}function WN(e,n,o,r,i,a){for(var l=0,s,c=n.length,d=a.length;l<d;++l)(s=n[l])?(s.__data__=a[l],r[l]=s):o[l]=new Ur(e,a[l]);for(;l<c;++l)(s=n[l])&&(i[l]=s)}function XN(e,n,o,r,i,a,l){var s,c,d=new Map,u=n.length,f=a.length,p=new Array(u),m;for(s=0;s<u;++s)(c=n[s])&&(p[s]=m=l.call(c,c.__data__,s,n)+"",d.has(m)?i[s]=c:d.set(m,c));for(s=0;s<f;++s)m=l.call(e,a[s],s,a)+"",(c=d.get(m))?(r[s]=c,c.__data__=a[s],d.delete(m)):o[s]=new Ur(e,a[s]);for(s=0;s<u;++s)(c=n[s])&&d.get(p[s])===c&&(i[s]=c)}function ZN(e){return e.__data__}function JN(e,n){if(!arguments.length)return Array.from(this,ZN);var o=n?XN:WN,r=this._parents,i=this._groups;typeof e!="function"&&(e=YN(e));for(var a=i.length,l=new Array(a),s=new Array(a),c=new Array(a),d=0;d<a;++d){var u=r[d],f=i[d],p=f.length,m=QN(e.call(u,u&&u.__data__,d,r)),h=m.length,y=s[d]=new Array(h),g=l[d]=new Array(h),_=c[d]=new Array(p);o(u,f,y,g,_,m,n);for(var w=0,b=0,v,N;w<h;++w)if(v=y[w]){for(w>=b&&(b=w+1);!(N=g[b])&&++b<h;);v._next=N||null}}return l=new ct(l,r),l._enter=s,l._exit=c,l}function QN(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function e1(){return new ct(this._exit||this._groups.map(_u),this._parents)}function t1(e,n,o){var r=this.enter(),i=this,a=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),n!=null&&(i=n(i),i&&(i=i.selection())),o==null?a.remove():o(a),r&&i?r.merge(i).order():i}function n1(e){for(var n=e.selection?e.selection():e,o=this._groups,r=n._groups,i=o.length,a=r.length,l=Math.min(i,a),s=new Array(i),c=0;c<l;++c)for(var d=o[c],u=r[c],f=d.length,p=s[c]=new Array(f),m,h=0;h<f;++h)(m=d[h]||u[h])&&(p[h]=m);for(;c<i;++c)s[c]=o[c];return new ct(s,this._parents)}function o1(){for(var e=this._groups,n=-1,o=e.length;++n<o;)for(var r=e[n],i=r.length-1,a=r[i],l;--i>=0;)(l=r[i])&&(a&&l.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(l,a),a=l);return this}function r1(e){e||(e=i1);function n(f,p){return f&&p?e(f.__data__,p.__data__):!f-!p}for(var o=this._groups,r=o.length,i=new Array(r),a=0;a<r;++a){for(var l=o[a],s=l.length,c=i[a]=new Array(s),d,u=0;u<s;++u)(d=l[u])&&(c[u]=d);c.sort(n)}return new ct(i,this._parents).order()}function i1(e,n){return e<n?-1:e>n?1:e>=n?0:NaN}function a1(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function l1(){return Array.from(this)}function s1(){for(var e=this._groups,n=0,o=e.length;n<o;++n)for(var r=e[n],i=0,a=r.length;i<a;++i){var l=r[i];if(l)return l}return null}function c1(){let e=0;for(const n of this)++e;return e}function d1(){return!this.node()}function u1(e){for(var n=this._groups,o=0,r=n.length;o<r;++o)for(var i=n[o],a=0,l=i.length,s;a<l;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function f1(e){return function(){this.removeAttribute(e)}}function p1(e){return function(){this.removeAttributeNS(e.space,e.local)}}function m1(e,n){return function(){this.setAttribute(e,n)}}function g1(e,n){return function(){this.setAttributeNS(e.space,e.local,n)}}function h1(e,n){return function(){var o=n.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function y1(e,n){return function(){var o=n.apply(this,arguments);o==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,o)}}function _1(e,n){var o=Fr(e);if(arguments.length<2){var r=this.node();return o.local?r.getAttributeNS(o.space,o.local):r.getAttribute(o)}return this.each((n==null?o.local?p1:f1:typeof n=="function"?o.local?y1:h1:o.local?g1:m1)(o,n))}function bu(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function b1(e){return function(){this.style.removeProperty(e)}}function w1(e,n,o){return function(){this.style.setProperty(e,n,o)}}function k1(e,n,o){return function(){var r=n.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,o)}}function E1(e,n,o){return arguments.length>1?this.each((n==null?b1:typeof n=="function"?k1:w1)(e,n,o??"")):qn(this.node(),e)}function qn(e,n){return e.style.getPropertyValue(n)||bu(e).getComputedStyle(e,null).getPropertyValue(n)}function C1(e){return function(){delete this[e]}}function N1(e,n){return function(){this[e]=n}}function v1(e,n){return function(){var o=n.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function S1(e,n){return arguments.length>1?this.each((n==null?C1:typeof n=="function"?v1:N1)(e,n)):this.node()[e]}function wu(e){return e.trim().split(/^|\s+/)}function Wa(e){return e.classList||new ku(e)}function ku(e){this._node=e,this._names=wu(e.getAttribute("class")||"")}ku.prototype={add:function(e){var n=this._names.indexOf(e);n<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var n=this._names.indexOf(e);n>=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Eu(e,n){for(var o=Wa(e),r=-1,i=n.length;++r<i;)o.add(n[r])}function Cu(e,n){for(var o=Wa(e),r=-1,i=n.length;++r<i;)o.remove(n[r])}function x1(e){return function(){Eu(this,e)}}function A1(e){return function(){Cu(this,e)}}function I1(e,n){return function(){(n.apply(this,arguments)?Eu:Cu)(this,e)}}function P1(e,n){var o=wu(e+"");if(arguments.length<2){for(var r=Wa(this.node()),i=-1,a=o.length;++i<a;)if(!r.contains(o[i]))return!1;return!0}return this.each((typeof n=="function"?I1:n?x1:A1)(o,n))}function T1(){this.textContent=""}function O1(e){return function(){this.textContent=e}}function $1(e){return function(){var n=e.apply(this,arguments);this.textContent=n??""}}function B1(e){return arguments.length?this.each(e==null?T1:(typeof e=="function"?$1:O1)(e)):this.node().textContent}function V1(){this.innerHTML=""}function R1(e){return function(){this.innerHTML=e}}function D1(e){return function(){var n=e.apply(this,arguments);this.innerHTML=n??""}}function M1(e){return arguments.length?this.each(e==null?V1:(typeof e=="function"?D1:R1)(e)):this.node().innerHTML}function L1(){this.nextSibling&&this.parentNode.appendChild(this)}function F1(){return this.each(L1)}function U1(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function K1(){return this.each(U1)}function j1(e){var n=typeof e=="function"?e:mu(e);return this.select(function(){return this.appendChild(n.apply(this,arguments))})}function G1(){return null}function q1(e,n){var o=typeof e=="function"?e:mu(e),r=n==null?G1:typeof n=="function"?n:Ya(n);return this.select(function(){return this.insertBefore(o.apply(this,arguments),r.apply(this,arguments)||null)})}function z1(){var e=this.parentNode;e&&e.removeChild(this)}function H1(){return this.each(z1)}function Y1(){var e=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function W1(){var e=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function X1(e){return this.select(e?W1:Y1)}function Z1(e){return arguments.length?this.property("__data__",e):this.node().__data__}function J1(e){return function(n){e.call(this,n,this.__data__)}}function Q1(e){return e.trim().split(/^|\s+/).map(function(n){var o="",r=n.indexOf(".");return r>=0&&(o=n.slice(r+1),n=n.slice(0,r)),{type:n,name:o}})}function ev(e){return function(){var n=this.__on;if(n){for(var o=0,r=-1,i=n.length,a;o<i;++o)a=n[o],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):n[++r]=a;++r?n.length=r:delete this.__on}}}function tv(e,n,o){return function(){var r=this.__on,i,a=J1(n);if(r){for(var l=0,s=r.length;l<s;++l)if((i=r[l]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=o),i.value=n;return}}this.addEventListener(e.type,a,o),i={type:e.type,name:e.name,value:n,listener:a,options:o},r?r.push(i):this.__on=[i]}}function nv(e,n,o){var r=Q1(e+""),i,a=r.length,l;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,d=s.length,u;c<d;++c)for(i=0,u=s[c];i<a;++i)if((l=r[i]).type===u.type&&l.name===u.name)return u.value}return}for(s=n?tv:ev,i=0;i<a;++i)this.each(s(r[i],n,o));return this}function Nu(e,n,o){var r=bu(e),i=r.CustomEvent;typeof i=="function"?i=new i(n,o):(i=r.document.createEvent("Event"),o?(i.initEvent(n,o.bubbles,o.cancelable),i.detail=o.detail):i.initEvent(n,!1,!1)),e.dispatchEvent(i)}function ov(e,n){return function(){return Nu(this,e,n)}}function rv(e,n){return function(){return Nu(this,e,n.apply(this,arguments))}}function iv(e,n){return this.each((typeof n=="function"?rv:ov)(e,n))}function*av(){for(var e=this._groups,n=0,o=e.length;n<o;++n)for(var r=e[n],i=0,a=r.length,l;i<a;++i)(l=r[i])&&(yield l)}var vu=[null];function ct(e,n){this._groups=e,this._parents=n}function Ao(){return new ct([[document.documentElement]],vu)}function lv(){return this}ct.prototype=Ao.prototype={constructor:ct,select:$N,selectAll:DN,selectChild:UN,selectChildren:qN,filter:zN,data:JN,enter:HN,exit:e1,join:t1,merge:n1,selection:lv,order:o1,sort:r1,call:a1,nodes:l1,node:s1,size:c1,empty:d1,each:u1,attr:_1,style:E1,property:S1,classed:P1,text:B1,html:M1,raise:F1,lower:K1,append:j1,insert:q1,remove:H1,clone:X1,datum:Z1,on:nv,dispatch:iv,[Symbol.iterator]:av};function _t(e){return typeof e=="string"?new ct([[document.querySelector(e)]],[document.documentElement]):new ct([[e]],vu)}function sv(e){let n;for(;n=e.sourceEvent;)e=n;return e}function xt(e,n){if(e=sv(e),n===void 0&&(n=e.currentTarget),n){var o=n.ownerSVGElement||n;if(o.createSVGPoint){var r=o.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(n.getScreenCTM().inverse()),[r.x,r.y]}if(n.getBoundingClientRect){var i=n.getBoundingClientRect();return[e.clientX-i.left-n.clientLeft,e.clientY-i.top-n.clientTop]}}return[e.pageX,e.pageY]}const cv={passive:!1},Io={capture:!0,passive:!1};function Xa(e){e.stopImmediatePropagation()}function zn(e){e.preventDefault(),e.stopImmediatePropagation()}function Su(e){var n=e.document.documentElement,o=_t(e).on("dragstart.drag",zn,Io);"onselectstart"in n?o.on("selectstart.drag",zn,Io):(n.__noselect=n.style.MozUserSelect,n.style.MozUserSelect="none")}function xu(e,n){var o=e.document.documentElement,r=_t(e).on("dragstart.drag",null);n&&(r.on("click.drag",zn,Io),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in o?r.on("selectstart.drag",null):(o.style.MozUserSelect=o.__noselect,delete o.__noselect)}const Kr=e=>()=>e;function Za(e,{sourceEvent:n,subject:o,target:r,identifier:i,active:a,x:l,y:s,dx:c,dy:d,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},subject:{value:o,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:l,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:d,enumerable:!0,configurable:!0},_:{value:u}})}Za.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function dv(e){return!e.ctrlKey&&!e.button}function uv(){return this.parentNode}function fv(e,n){return n??{x:e.x,y:e.y}}function pv(){return navigator.maxTouchPoints||"ontouchstart"in this}function mv(){var e=dv,n=uv,o=fv,r=pv,i={},a=Mr("start","drag","end"),l=0,s,c,d,u,f=0;function p(v){v.on("mousedown.drag",m).filter(r).on("touchstart.drag",g).on("touchmove.drag",_,cv).on("touchend.drag touchcancel.drag",w).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function m(v,N){if(!(u||!e.call(this,v,N))){var E=b(this,n.call(this,v,N),v,N,"mouse");E&&(_t(v.view).on("mousemove.drag",h,Io).on("mouseup.drag",y,Io),Su(v.view),Xa(v),d=!1,s=v.clientX,c=v.clientY,E("start",v))}}function h(v){if(zn(v),!d){var N=v.clientX-s,E=v.clientY-c;d=N*N+E*E>f}i.mouse("drag",v)}function y(v){_t(v.view).on("mousemove.drag mouseup.drag",null),xu(v.view,d),zn(v),i.mouse("end",v)}function g(v,N){if(e.call(this,v,N)){var E=v.changedTouches,S=n.call(this,v,N),P=E.length,B,j;for(B=0;B<P;++B)(j=b(this,S,v,N,E[B].identifier,E[B]))&&(Xa(v),j("start",v,E[B]))}}function _(v){var N=v.changedTouches,E=N.length,S,P;for(S=0;S<E;++S)(P=i[N[S].identifier])&&(zn(v),P("drag",v,N[S]))}function w(v){var N=v.changedTouches,E=N.length,S,P;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),S=0;S<E;++S)(P=i[N[S].identifier])&&(Xa(v),P("end",v,N[S]))}function b(v,N,E,S,P,B){var j=a.copy(),G=xt(B||E,N),T,Y,I;if((I=o.call(v,new Za("beforestart",{sourceEvent:E,target:p,identifier:P,active:l,x:G[0],y:G[1],dx:0,dy:0,dispatch:j}),S))!=null)return T=I.x-G[0]||0,Y=I.y-G[1]||0,function M(R,te,z){var H=G,L;switch(R){case"start":i[P]=M,L=l++;break;case"end":delete i[P],--l;case"drag":G=xt(z||te,N),L=l;break}j.call(R,v,new Za(R,{sourceEvent:te,subject:I,target:p,identifier:P,active:L,x:G[0]+T,y:G[1]+Y,dx:G[0]-H[0],dy:G[1]-H[1],dispatch:j}),S)}}return p.filter=function(v){return arguments.length?(e=typeof v=="function"?v:Kr(!!v),p):e},p.container=function(v){return arguments.length?(n=typeof v=="function"?v:Kr(v),p):n},p.subject=function(v){return arguments.length?(o=typeof v=="function"?v:Kr(v),p):o},p.touchable=function(v){return arguments.length?(r=typeof v=="function"?v:Kr(!!v),p):r},p.on=function(){var v=a.on.apply(a,arguments);return v===a?p:v},p.clickDistance=function(v){return arguments.length?(f=(v=+v)*v,p):Math.sqrt(f)},p}function Ja(e,n,o){e.prototype=n.prototype=o,o.constructor=e}function Au(e,n){var o=Object.create(e.prototype);for(var r in n)o[r]=n[r];return o}function Po(){}var To=.7,jr=1/To,Hn="\\s*([+-]?\\d+)\\s*",Oo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",At="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",gv=/^#([0-9a-f]{3,8})$/,hv=new RegExp(`^rgb\\(${Hn},${Hn},${Hn}\\)$`),yv=new RegExp(`^rgb\\(${At},${At},${At}\\)$`),_v=new RegExp(`^rgba\\(${Hn},${Hn},${Hn},${Oo}\\)$`),bv=new RegExp(`^rgba\\(${At},${At},${At},${Oo}\\)$`),wv=new RegExp(`^hsl\\(${Oo},${At},${At}\\)$`),kv=new RegExp(`^hsla\\(${Oo},${At},${At},${Oo}\\)$`),Iu={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Ja(Po,mn,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Pu,formatHex:Pu,formatHex8:Ev,formatHsl:Cv,formatRgb:Tu,toString:Tu});function Pu(){return this.rgb().formatHex()}function Ev(){return this.rgb().formatHex8()}function Cv(){return Ru(this).formatHsl()}function Tu(){return this.rgb().formatRgb()}function mn(e){var n,o;return e=(e+"").trim().toLowerCase(),(n=gv.exec(e))?(o=n[1].length,n=parseInt(n[1],16),o===6?Ou(n):o===3?new rt(n>>8&15|n>>4&240,n>>4&15|n&240,(n&15)<<4|n&15,1):o===8?Gr(n>>24&255,n>>16&255,n>>8&255,(n&255)/255):o===4?Gr(n>>12&15|n>>8&240,n>>8&15|n>>4&240,n>>4&15|n&240,((n&15)<<4|n&15)/255):null):(n=hv.exec(e))?new rt(n[1],n[2],n[3],1):(n=yv.exec(e))?new rt(n[1]*255/100,n[2]*255/100,n[3]*255/100,1):(n=_v.exec(e))?Gr(n[1],n[2],n[3],n[4]):(n=bv.exec(e))?Gr(n[1]*255/100,n[2]*255/100,n[3]*255/100,n[4]):(n=wv.exec(e))?Vu(n[1],n[2]/100,n[3]/100,1):(n=kv.exec(e))?Vu(n[1],n[2]/100,n[3]/100,n[4]):Iu.hasOwnProperty(e)?Ou(Iu[e]):e==="transparent"?new rt(NaN,NaN,NaN,0):null}function Ou(e){return new rt(e>>16&255,e>>8&255,e&255,1)}function Gr(e,n,o,r){return r<=0&&(e=n=o=NaN),new rt(e,n,o,r)}function Nv(e){return e instanceof Po||(e=mn(e)),e?(e=e.rgb(),new rt(e.r,e.g,e.b,e.opacity)):new rt}function Qa(e,n,o,r){return arguments.length===1?Nv(e):new rt(e,n,o,r??1)}function rt(e,n,o,r){this.r=+e,this.g=+n,this.b=+o,this.opacity=+r}Ja(rt,Qa,Au(Po,{brighter(e){return e=e==null?jr:Math.pow(jr,e),new rt(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?To:Math.pow(To,e),new rt(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new rt(gn(this.r),gn(this.g),gn(this.b),qr(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:$u,formatHex:$u,formatHex8:vv,formatRgb:Bu,toString:Bu}));function $u(){return`#${hn(this.r)}${hn(this.g)}${hn(this.b)}`}function vv(){return`#${hn(this.r)}${hn(this.g)}${hn(this.b)}${hn((isNaN(this.opacity)?1:this.opacity)*255)}`}function Bu(){const e=qr(this.opacity);return`${e===1?"rgb(":"rgba("}${gn(this.r)}, ${gn(this.g)}, ${gn(this.b)}${e===1?")":`, ${e})`}`}function qr(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function gn(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function hn(e){return e=gn(e),(e<16?"0":"")+e.toString(16)}function Vu(e,n,o,r){return r<=0?e=n=o=NaN:o<=0||o>=1?e=n=NaN:n<=0&&(e=NaN),new bt(e,n,o,r)}function Ru(e){if(e instanceof bt)return new bt(e.h,e.s,e.l,e.opacity);if(e instanceof Po||(e=mn(e)),!e)return new bt;if(e instanceof bt)return e;e=e.rgb();var n=e.r/255,o=e.g/255,r=e.b/255,i=Math.min(n,o,r),a=Math.max(n,o,r),l=NaN,s=a-i,c=(a+i)/2;return s?(n===a?l=(o-r)/s+(o<r)*6:o===a?l=(r-n)/s+2:l=(n-o)/s+4,s/=c<.5?a+i:2-a-i,l*=60):s=c>0&&c<1?0:l,new bt(l,s,c,e.opacity)}function Sv(e,n,o,r){return arguments.length===1?Ru(e):new bt(e,n,o,r??1)}function bt(e,n,o,r){this.h=+e,this.s=+n,this.l=+o,this.opacity=+r}Ja(bt,Sv,Au(Po,{brighter(e){return e=e==null?jr:Math.pow(jr,e),new bt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?To:Math.pow(To,e),new bt(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,n=isNaN(e)||isNaN(this.s)?0:this.s,o=this.l,r=o+(o<.5?o:1-o)*n,i=2*o-r;return new rt(el(e>=240?e-240:e+120,i,r),el(e,i,r),el(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new bt(Du(this.h),zr(this.s),zr(this.l),qr(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=qr(this.opacity);return`${e===1?"hsl(":"hsla("}${Du(this.h)}, ${zr(this.s)*100}%, ${zr(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Du(e){return e=(e||0)%360,e<0?e+360:e}function zr(e){return Math.max(0,Math.min(1,e||0))}function el(e,n,o){return(e<60?n+(o-n)*e/60:e<180?o:e<240?n+(o-n)*(240-e)/60:n)*255}const tl=e=>()=>e;function xv(e,n){return function(o){return e+o*n}}function Av(e,n,o){return e=Math.pow(e,o),n=Math.pow(n,o)-e,o=1/o,function(r){return Math.pow(e+r*n,o)}}function Iv(e){return(e=+e)==1?Mu:function(n,o){return o-n?Av(n,o,e):tl(isNaN(n)?o:n)}}function Mu(e,n){var o=n-e;return o?xv(e,o):tl(isNaN(e)?n:e)}const Hr=function e(n){var o=Iv(n);function r(i,a){var l=o((i=Qa(i)).r,(a=Qa(a)).r),s=o(i.g,a.g),c=o(i.b,a.b),d=Mu(i.opacity,a.opacity);return function(u){return i.r=l(u),i.g=s(u),i.b=c(u),i.opacity=d(u),i+""}}return r.gamma=e,r}(1);function Pv(e,n){n||(n=[]);var o=e?Math.min(n.length,e.length):0,r=n.slice(),i;return function(a){for(i=0;i<o;++i)r[i]=e[i]*(1-a)+n[i]*a;return r}}function Tv(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Ov(e,n){var o=n?n.length:0,r=e?Math.min(o,e.length):0,i=new Array(r),a=new Array(o),l;for(l=0;l<r;++l)i[l]=$o(e[l],n[l]);for(;l<o;++l)a[l]=n[l];return function(s){for(l=0;l<r;++l)a[l]=i[l](s);return a}}function $v(e,n){var o=new Date;return e=+e,n=+n,function(r){return o.setTime(e*(1-r)+n*r),o}}function It(e,n){return e=+e,n=+n,function(o){return e*(1-o)+n*o}}function Bv(e,n){var o={},r={},i;(e===null||typeof e!="object")&&(e={}),(n===null||typeof n!="object")&&(n={});for(i in n)i in e?o[i]=$o(e[i],n[i]):r[i]=n[i];return function(a){for(i in o)r[i]=o[i](a);return r}}var nl=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ol=new RegExp(nl.source,"g");function Vv(e){return function(){return e}}function Rv(e){return function(n){return e(n)+""}}function Lu(e,n){var o=nl.lastIndex=ol.lastIndex=0,r,i,a,l=-1,s=[],c=[];for(e=e+"",n=n+"";(r=nl.exec(e))&&(i=ol.exec(n));)(a=i.index)>o&&(a=n.slice(o,a),s[l]?s[l]+=a:s[++l]=a),(r=r[0])===(i=i[0])?s[l]?s[l]+=i:s[++l]=i:(s[++l]=null,c.push({i:l,x:It(r,i)})),o=ol.lastIndex;return o<n.length&&(a=n.slice(o),s[l]?s[l]+=a:s[++l]=a),s.length<2?c[0]?Rv(c[0].x):Vv(n):(n=c.length,function(d){for(var u=0,f;u<n;++u)s[(f=c[u]).i]=f.x(d);return s.join("")})}function $o(e,n){var o=typeof n,r;return n==null||o==="boolean"?tl(n):(o==="number"?It:o==="string"?(r=mn(n))?(n=r,Hr):Lu:n instanceof mn?Hr:n instanceof Date?$v:Tv(n)?Pv:Array.isArray(n)?Ov:typeof n.valueOf!="function"&&typeof n.toString!="function"||isNaN(n)?Bv:It)(e,n)}var Fu=180/Math.PI,rl={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Uu(e,n,o,r,i,a){var l,s,c;return(l=Math.sqrt(e*e+n*n))&&(e/=l,n/=l),(c=e*o+n*r)&&(o-=e*c,r-=n*c),(s=Math.sqrt(o*o+r*r))&&(o/=s,r/=s,c/=s),e*r<n*o&&(e=-e,n=-n,c=-c,l=-l),{translateX:i,translateY:a,rotate:Math.atan2(n,e)*Fu,skewX:Math.atan(c)*Fu,scaleX:l,scaleY:s}}var Yr;function Dv(e){const n=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return n.isIdentity?rl:Uu(n.a,n.b,n.c,n.d,n.e,n.f)}function Mv(e){return e==null||(Yr||(Yr=document.createElementNS("http://www.w3.org/2000/svg","g")),Yr.setAttribute("transform",e),!(e=Yr.transform.baseVal.consolidate()))?rl:(e=e.matrix,Uu(e.a,e.b,e.c,e.d,e.e,e.f))}function Ku(e,n,o,r){function i(d){return d.length?d.pop()+" ":""}function a(d,u,f,p,m,h){if(d!==f||u!==p){var y=m.push("translate(",null,n,null,o);h.push({i:y-4,x:It(d,f)},{i:y-2,x:It(u,p)})}else(f||p)&&m.push("translate("+f+n+p+o)}function l(d,u,f,p){d!==u?(d-u>180?u+=360:u-d>180&&(d+=360),p.push({i:f.push(i(f)+"rotate(",null,r)-2,x:It(d,u)})):u&&f.push(i(f)+"rotate("+u+r)}function s(d,u,f,p){d!==u?p.push({i:f.push(i(f)+"skewX(",null,r)-2,x:It(d,u)}):u&&f.push(i(f)+"skewX("+u+r)}function c(d,u,f,p,m,h){if(d!==f||u!==p){var y=m.push(i(m)+"scale(",null,",",null,")");h.push({i:y-4,x:It(d,f)},{i:y-2,x:It(u,p)})}else(f!==1||p!==1)&&m.push(i(m)+"scale("+f+","+p+")")}return function(d,u){var f=[],p=[];return d=e(d),u=e(u),a(d.translateX,d.translateY,u.translateX,u.translateY,f,p),l(d.rotate,u.rotate,f,p),s(d.skewX,u.skewX,f,p),c(d.scaleX,d.scaleY,u.scaleX,u.scaleY,f,p),d=u=null,function(m){for(var h=-1,y=p.length,g;++h<y;)f[(g=p[h]).i]=g.x(m);return f.join("")}}}var Lv=Ku(Dv,"px, ","px)","deg)"),Fv=Ku(Mv,", ",")",")"),Uv=1e-12;function ju(e){return((e=Math.exp(e))+1/e)/2}function Kv(e){return((e=Math.exp(e))-1/e)/2}function jv(e){return((e=Math.exp(2*e))-1)/(e+1)}const Wr=function e(n,o,r){function i(a,l){var s=a[0],c=a[1],d=a[2],u=l[0],f=l[1],p=l[2],m=u-s,h=f-c,y=m*m+h*h,g,_;if(y<Uv)_=Math.log(p/d)/n,g=function(S){return[s+S*m,c+S*h,d*Math.exp(n*S*_)]};else{var w=Math.sqrt(y),b=(p*p-d*d+r*y)/(2*d*o*w),v=(p*p-d*d-r*y)/(2*p*o*w),N=Math.log(Math.sqrt(b*b+1)-b),E=Math.log(Math.sqrt(v*v+1)-v);_=(E-N)/n,g=function(S){var P=S*_,B=ju(N),j=d/(o*w)*(B*jv(n*P+N)-Kv(N));return[s+j*m,c+j*h,d*B/ju(n*P+N)]}}return g.duration=_*1e3*n/Math.SQRT2,g}return i.rho=function(a){var l=Math.max(.001,+a),s=l*l,c=s*s;return e(l,s,c)},i}(Math.SQRT2,2,4);var Yn=0,Bo=0,Vo=0,Gu=1e3,Xr,Ro,Zr=0,yn=0,Jr=0,Do=typeof performance=="object"&&performance.now?performance:Date,qu=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function il(){return yn||(qu(Gv),yn=Do.now()+Jr)}function Gv(){yn=0}function Qr(){this._call=this._time=this._next=null}Qr.prototype=zu.prototype={constructor:Qr,restart:function(e,n,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?il():+o)+(n==null?0:+n),!this._next&&Ro!==this&&(Ro?Ro._next=this:Xr=this,Ro=this),this._call=e,this._time=o,al()},stop:function(){this._call&&(this._call=null,this._time=1/0,al())}};function zu(e,n,o){var r=new Qr;return r.restart(e,n,o),r}function qv(){il(),++Yn;for(var e=Xr,n;e;)(n=yn-e._time)>=0&&e._call.call(void 0,n),e=e._next;--Yn}function Hu(){yn=(Zr=Do.now())+Jr,Yn=Bo=0;try{qv()}finally{Yn=0,Hv(),yn=0}}function zv(){var e=Do.now(),n=e-Zr;n>Gu&&(Jr-=n,Zr=e)}function Hv(){for(var e,n=Xr,o,r=1/0;n;)n._call?(r>n._time&&(r=n._time),e=n,n=n._next):(o=n._next,n._next=null,n=e?e._next=o:Xr=o);Ro=e,al(r)}function al(e){if(!Yn){Bo&&(Bo=clearTimeout(Bo));var n=e-yn;n>24?(e<1/0&&(Bo=setTimeout(Hu,e-Do.now()-Jr)),Vo&&(Vo=clearInterval(Vo))):(Vo||(Zr=Do.now(),Vo=setInterval(zv,Gu)),Yn=1,qu(Hu))}}function Yu(e,n,o){var r=new Qr;return n=n==null?0:+n,r.restart(i=>{r.stop(),e(i+n)},n,o),r}var Yv=Mr("start","end","cancel","interrupt"),Wv=[],Wu=0,Xu=1,ll=2,ei=3,Zu=4,sl=5,ti=6;function ni(e,n,o,r,i,a){var l=e.__transition;if(!l)e.__transition={};else if(o in l)return;Xv(e,o,{name:n,index:r,group:i,on:Yv,tween:Wv,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:Wu})}function cl(e,n){var o=wt(e,n);if(o.state>Wu)throw new Error("too late; already scheduled");return o}function Pt(e,n){var o=wt(e,n);if(o.state>ei)throw new Error("too late; already running");return o}function wt(e,n){var o=e.__transition;if(!o||!(o=o[n]))throw new Error("transition not found");return o}function Xv(e,n,o){var r=e.__transition,i;r[n]=o,o.timer=zu(a,0,o.time);function a(d){o.state=Xu,o.timer.restart(l,o.delay,o.time),o.delay<=d&&l(d-o.delay)}function l(d){var u,f,p,m;if(o.state!==Xu)return c();for(u in r)if(m=r[u],m.name===o.name){if(m.state===ei)return Yu(l);m.state===Zu?(m.state=ti,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete r[u]):+u<n&&(m.state=ti,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete r[u])}if(Yu(function(){o.state===ei&&(o.state=Zu,o.timer.restart(s,o.delay,o.time),s(d))}),o.state=ll,o.on.call("start",e,e.__data__,o.index,o.group),o.state===ll){for(o.state=ei,i=new Array(p=o.tween.length),u=0,f=-1;u<p;++u)(m=o.tween[u].value.call(e,e.__data__,o.index,o.group))&&(i[++f]=m);i.length=f+1}}function s(d){for(var u=d<o.duration?o.ease.call(null,d/o.duration):(o.timer.restart(c),o.state=sl,1),f=-1,p=i.length;++f<p;)i[f].call(e,u);o.state===sl&&(o.on.call("end",e,e.__data__,o.index,o.group),c())}function c(){o.state=ti,o.timer.stop(),delete r[n];for(var d in r)return;delete e.__transition}}function oi(e,n){var o=e.__transition,r,i,a=!0,l;if(o){n=n==null?null:n+"";for(l in o){if((r=o[l]).name!==n){a=!1;continue}i=r.state>ll&&r.state<sl,r.state=ti,r.timer.stop(),r.on.call(i?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete o[l]}a&&delete e.__transition}}function Zv(e){return this.each(function(){oi(this,e)})}function Jv(e,n){var o,r;return function(){var i=Pt(this,e),a=i.tween;if(a!==o){r=o=a;for(var l=0,s=r.length;l<s;++l)if(r[l].name===n){r=r.slice(),r.splice(l,1);break}}i.tween=r}}function Qv(e,n,o){var r,i;if(typeof o!="function")throw new Error;return function(){var a=Pt(this,e),l=a.tween;if(l!==r){i=(r=l).slice();for(var s={name:n,value:o},c=0,d=i.length;c<d;++c)if(i[c].name===n){i[c]=s;break}c===d&&i.push(s)}a.tween=i}}function eS(e,n){var o=this._id;if(e+="",arguments.length<2){for(var r=wt(this.node(),o).tween,i=0,a=r.length,l;i<a;++i)if((l=r[i]).name===e)return l.value;return null}return this.each((n==null?Jv:Qv)(o,e,n))}function dl(e,n,o){var r=e._id;return e.each(function(){var i=Pt(this,r);(i.value||(i.value={}))[n]=o.apply(this,arguments)}),function(i){return wt(i,r).value[n]}}function Ju(e,n){var o;return(typeof n=="number"?It:n instanceof mn?Hr:(o=mn(n))?(n=o,Hr):Lu)(e,n)}function tS(e){return function(){this.removeAttribute(e)}}function nS(e){return function(){this.removeAttributeNS(e.space,e.local)}}function oS(e,n,o){var r,i=o+"",a;return function(){var l=this.getAttribute(e);return l===i?null:l===r?a:a=n(r=l,o)}}function rS(e,n,o){var r,i=o+"",a;return function(){var l=this.getAttributeNS(e.space,e.local);return l===i?null:l===r?a:a=n(r=l,o)}}function iS(e,n,o){var r,i,a;return function(){var l,s=o(this),c;return s==null?void this.removeAttribute(e):(l=this.getAttribute(e),c=s+"",l===c?null:l===r&&c===i?a:(i=c,a=n(r=l,s)))}}function aS(e,n,o){var r,i,a;return function(){var l,s=o(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(l=this.getAttributeNS(e.space,e.local),c=s+"",l===c?null:l===r&&c===i?a:(i=c,a=n(r=l,s)))}}function lS(e,n){var o=Fr(e),r=o==="transform"?Fv:Ju;return this.attrTween(e,typeof n=="function"?(o.local?aS:iS)(o,r,dl(this,"attr."+e,n)):n==null?(o.local?nS:tS)(o):(o.local?rS:oS)(o,r,n))}function sS(e,n){return function(o){this.setAttribute(e,n.call(this,o))}}function cS(e,n){return function(o){this.setAttributeNS(e.space,e.local,n.call(this,o))}}function dS(e,n){var o,r;function i(){var a=n.apply(this,arguments);return a!==r&&(o=(r=a)&&cS(e,a)),o}return i._value=n,i}function uS(e,n){var o,r;function i(){var a=n.apply(this,arguments);return a!==r&&(o=(r=a)&&sS(e,a)),o}return i._value=n,i}function fS(e,n){var o="attr."+e;if(arguments.length<2)return(o=this.tween(o))&&o._value;if(n==null)return this.tween(o,null);if(typeof n!="function")throw new Error;var r=Fr(e);return this.tween(o,(r.local?dS:uS)(r,n))}function pS(e,n){return function(){cl(this,e).delay=+n.apply(this,arguments)}}function mS(e,n){return n=+n,function(){cl(this,e).delay=n}}function gS(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?pS:mS)(n,e)):wt(this.node(),n).delay}function hS(e,n){return function(){Pt(this,e).duration=+n.apply(this,arguments)}}function yS(e,n){return n=+n,function(){Pt(this,e).duration=n}}function _S(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?hS:yS)(n,e)):wt(this.node(),n).duration}function bS(e,n){if(typeof n!="function")throw new Error;return function(){Pt(this,e).ease=n}}function wS(e){var n=this._id;return arguments.length?this.each(bS(n,e)):wt(this.node(),n).ease}function kS(e,n){return function(){var o=n.apply(this,arguments);if(typeof o!="function")throw new Error;Pt(this,e).ease=o}}function ES(e){if(typeof e!="function")throw new Error;return this.each(kS(this._id,e))}function CS(e){typeof e!="function"&&(e=hu(e));for(var n=this._groups,o=n.length,r=new Array(o),i=0;i<o;++i)for(var a=n[i],l=a.length,s=r[i]=[],c,d=0;d<l;++d)(c=a[d])&&e.call(c,c.__data__,d,a)&&s.push(c);return new Ut(r,this._parents,this._name,this._id)}function NS(e){if(e._id!==this._id)throw new Error;for(var n=this._groups,o=e._groups,r=n.length,i=o.length,a=Math.min(r,i),l=new Array(r),s=0;s<a;++s)for(var c=n[s],d=o[s],u=c.length,f=l[s]=new Array(u),p,m=0;m<u;++m)(p=c[m]||d[m])&&(f[m]=p);for(;s<r;++s)l[s]=n[s];return new Ut(l,this._parents,this._name,this._id)}function vS(e){return(e+"").trim().split(/^|\s+/).every(function(n){var o=n.indexOf(".");return o>=0&&(n=n.slice(0,o)),!n||n==="start"})}function SS(e,n,o){var r,i,a=vS(n)?cl:Pt;return function(){var l=a(this,e),s=l.on;s!==r&&(i=(r=s).copy()).on(n,o),l.on=i}}function xS(e,n){var o=this._id;return arguments.length<2?wt(this.node(),o).on.on(e):this.each(SS(o,e,n))}function AS(e){return function(){var n=this.parentNode;for(var o in this.__transition)if(+o!==e)return;n&&n.removeChild(this)}}function IS(){return this.on("end.remove",AS(this._id))}function PS(e){var n=this._name,o=this._id;typeof e!="function"&&(e=Ya(e));for(var r=this._groups,i=r.length,a=new Array(i),l=0;l<i;++l)for(var s=r[l],c=s.length,d=a[l]=new Array(c),u,f,p=0;p<c;++p)(u=s[p])&&(f=e.call(u,u.__data__,p,s))&&("__data__"in u&&(f.__data__=u.__data__),d[p]=f,ni(d[p],n,o,p,d,wt(u,o)));return new Ut(a,this._parents,n,o)}function TS(e){var n=this._name,o=this._id;typeof e!="function"&&(e=gu(e));for(var r=this._groups,i=r.length,a=[],l=[],s=0;s<i;++s)for(var c=r[s],d=c.length,u,f=0;f<d;++f)if(u=c[f]){for(var p=e.call(u,u.__data__,f,c),m,h=wt(u,o),y=0,g=p.length;y<g;++y)(m=p[y])&&ni(m,n,o,y,p,h);a.push(p),l.push(u)}return new Ut(a,l,n,o)}var OS=Ao.prototype.constructor;function $S(){return new OS(this._groups,this._parents)}function BS(e,n){var o,r,i;return function(){var a=qn(this,e),l=(this.style.removeProperty(e),qn(this,e));return a===l?null:a===o&&l===r?i:i=n(o=a,r=l)}}function Qu(e){return function(){this.style.removeProperty(e)}}function VS(e,n,o){var r,i=o+"",a;return function(){var l=qn(this,e);return l===i?null:l===r?a:a=n(r=l,o)}}function RS(e,n,o){var r,i,a;return function(){var l=qn(this,e),s=o(this),c=s+"";return s==null&&(c=s=(this.style.removeProperty(e),qn(this,e))),l===c?null:l===r&&c===i?a:(i=c,a=n(r=l,s))}}function DS(e,n){var o,r,i,a="style."+n,l="end."+a,s;return function(){var c=Pt(this,e),d=c.on,u=c.value[a]==null?s||(s=Qu(n)):void 0;(d!==o||i!==u)&&(r=(o=d).copy()).on(l,i=u),c.on=r}}function MS(e,n,o){var r=(e+="")=="transform"?Lv:Ju;return n==null?this.styleTween(e,BS(e,r)).on("end.style."+e,Qu(e)):typeof n=="function"?this.styleTween(e,RS(e,r,dl(this,"style."+e,n))).each(DS(this._id,e)):this.styleTween(e,VS(e,r,n),o).on("end.style."+e,null)}function LS(e,n,o){return function(r){this.style.setProperty(e,n.call(this,r),o)}}function FS(e,n,o){var r,i;function a(){var l=n.apply(this,arguments);return l!==i&&(r=(i=l)&&LS(e,l,o)),r}return a._value=n,a}function US(e,n,o){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(n==null)return this.tween(r,null);if(typeof n!="function")throw new Error;return this.tween(r,FS(e,n,o??""))}function KS(e){return function(){this.textContent=e}}function jS(e){return function(){var n=e(this);this.textContent=n??""}}function GS(e){return this.tween("text",typeof e=="function"?jS(dl(this,"text",e)):KS(e==null?"":e+""))}function qS(e){return function(n){this.textContent=e.call(this,n)}}function zS(e){var n,o;function r(){var i=e.apply(this,arguments);return i!==o&&(n=(o=i)&&qS(i)),n}return r._value=e,r}function HS(e){var n="text";if(arguments.length<1)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;return this.tween(n,zS(e))}function YS(){for(var e=this._name,n=this._id,o=ef(),r=this._groups,i=r.length,a=0;a<i;++a)for(var l=r[a],s=l.length,c,d=0;d<s;++d)if(c=l[d]){var u=wt(c,n);ni(c,e,o,d,l,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Ut(r,this._parents,e,o)}function WS(){var e,n,o=this,r=o._id,i=o.size();return new Promise(function(a,l){var s={value:l},c={value:function(){--i===0&&a()}};o.each(function(){var d=Pt(this,r),u=d.on;u!==e&&(n=(e=u).copy(),n._.cancel.push(s),n._.interrupt.push(s),n._.end.push(c)),d.on=n}),i===0&&a()})}var XS=0;function Ut(e,n,o,r){this._groups=e,this._parents=n,this._name=o,this._id=r}function ef(){return++XS}var Kt=Ao.prototype;Ut.prototype={constructor:Ut,select:PS,selectAll:TS,selectChild:Kt.selectChild,selectChildren:Kt.selectChildren,filter:CS,merge:NS,selection:$S,transition:YS,call:Kt.call,nodes:Kt.nodes,node:Kt.node,size:Kt.size,empty:Kt.empty,each:Kt.each,on:xS,attr:lS,attrTween:fS,style:MS,styleTween:US,text:GS,textTween:HS,remove:IS,tween:eS,delay:gS,duration:_S,ease:wS,easeVarying:ES,end:WS,[Symbol.iterator]:Kt[Symbol.iterator]};function ZS(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var JS={time:null,delay:0,duration:250,ease:ZS};function QS(e,n){for(var o;!(o=e.__transition)||!(o=o[n]);)if(!(e=e.parentNode))throw new Error(`transition ${n} not found`);return o}function ex(e){var n,o;e instanceof Ut?(n=e._id,e=e._name):(n=ef(),(o=JS).time=il(),e=e==null?null:e+"");for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var l=r[a],s=l.length,c,d=0;d<s;++d)(c=l[d])&&ni(c,e,n,d,l,o||QS(c,n));return new Ut(r,this._parents,e,n)}Ao.prototype.interrupt=Zv,Ao.prototype.transition=ex;const ri=e=>()=>e;function tx(e,{sourceEvent:n,target:o,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function jt(e,n,o){this.k=e,this.x=n,this.y=o}jt.prototype={constructor:jt,scale:function(e){return e===1?this:new jt(this.k*e,this.x,this.y)},translate:function(e,n){return e===0&n===0?this:new jt(this.k,this.x+this.k*e,this.y+this.k*n)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Wn=new jt(1,0,0);jt.prototype;function ul(e){e.stopImmediatePropagation()}function Mo(e){e.preventDefault(),e.stopImmediatePropagation()}function nx(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function ox(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function tf(){return this.__zoom||Wn}function rx(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function ix(){return navigator.maxTouchPoints||"ontouchstart"in this}function ax(e,n,o){var r=e.invertX(n[0][0])-o[0][0],i=e.invertX(n[1][0])-o[1][0],a=e.invertY(n[0][1])-o[0][1],l=e.invertY(n[1][1])-o[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),l>a?(a+l)/2:Math.min(0,a)||Math.max(0,l))}function lx(){var e=nx,n=ox,o=ax,r=rx,i=ix,a=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],s=250,c=Wr,d=Mr("start","zoom","end"),u,f,p,m=500,h=150,y=0,g=10;function _(I){I.property("__zoom",tf).on("wheel.zoom",P,{passive:!1}).on("mousedown.zoom",B).on("dblclick.zoom",j).filter(i).on("touchstart.zoom",G).on("touchmove.zoom",T).on("touchend.zoom touchcancel.zoom",Y).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}_.transform=function(I,M,R,te){var z=I.selection?I.selection():I;z.property("__zoom",tf),I!==z?N(I,M,R,te):z.interrupt().each(function(){E(this,arguments).event(te).start().zoom(null,typeof M=="function"?M.apply(this,arguments):M).end()})},_.scaleBy=function(I,M,R,te){_.scaleTo(I,function(){var z=this.__zoom.k,H=typeof M=="function"?M.apply(this,arguments):M;return z*H},R,te)},_.scaleTo=function(I,M,R,te){_.transform(I,function(){var z=n.apply(this,arguments),H=this.__zoom,L=R==null?v(z):typeof R=="function"?R.apply(this,arguments):R,F=H.invert(L),Z=typeof M=="function"?M.apply(this,arguments):M;return o(b(w(H,Z),L,F),z,l)},R,te)},_.translateBy=function(I,M,R,te){_.transform(I,function(){return o(this.__zoom.translate(typeof M=="function"?M.apply(this,arguments):M,typeof R=="function"?R.apply(this,arguments):R),n.apply(this,arguments),l)},null,te)},_.translateTo=function(I,M,R,te,z){_.transform(I,function(){var H=n.apply(this,arguments),L=this.__zoom,F=te==null?v(H):typeof te=="function"?te.apply(this,arguments):te;return o(Wn.translate(F[0],F[1]).scale(L.k).translate(typeof M=="function"?-M.apply(this,arguments):-M,typeof R=="function"?-R.apply(this,arguments):-R),H,l)},te,z)};function w(I,M){return M=Math.max(a[0],Math.min(a[1],M)),M===I.k?I:new jt(M,I.x,I.y)}function b(I,M,R){var te=M[0]-R[0]*I.k,z=M[1]-R[1]*I.k;return te===I.x&&z===I.y?I:new jt(I.k,te,z)}function v(I){return[(+I[0][0]+ +I[1][0])/2,(+I[0][1]+ +I[1][1])/2]}function N(I,M,R,te){I.on("start.zoom",function(){E(this,arguments).event(te).start()}).on("interrupt.zoom end.zoom",function(){E(this,arguments).event(te).end()}).tween("zoom",function(){var z=this,H=arguments,L=E(z,H).event(te),F=n.apply(z,H),Z=R==null?v(F):typeof R=="function"?R.apply(z,H):R,Q=Math.max(F[1][0]-F[0][0],F[1][1]-F[0][1]),W=z.__zoom,ie=typeof M=="function"?M.apply(z,H):M,ae=c(W.invert(Z).concat(Q/W.k),ie.invert(Z).concat(Q/ie.k));return function(me){if(me===1)me=ie;else{var ge=ae(me),ne=Q/ge[2];me=new jt(ne,Z[0]-ge[0]*ne,Z[1]-ge[1]*ne)}L.zoom(null,me)}})}function E(I,M,R){return!R&&I.__zooming||new S(I,M)}function S(I,M){this.that=I,this.args=M,this.active=0,this.sourceEvent=null,this.extent=n.apply(I,M),this.taps=0}S.prototype={event:function(I){return I&&(this.sourceEvent=I),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(I,M){return this.mouse&&I!=="mouse"&&(this.mouse[1]=M.invert(this.mouse[0])),this.touch0&&I!=="touch"&&(this.touch0[1]=M.invert(this.touch0[0])),this.touch1&&I!=="touch"&&(this.touch1[1]=M.invert(this.touch1[0])),this.that.__zoom=M,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(I){var M=_t(this.that).datum();d.call(I,this.that,new tx(I,{sourceEvent:this.sourceEvent,target:_,transform:this.that.__zoom,dispatch:d}),M)}};function P(I,...M){if(!e.apply(this,arguments))return;var R=E(this,M).event(I),te=this.__zoom,z=Math.max(a[0],Math.min(a[1],te.k*Math.pow(2,r.apply(this,arguments)))),H=xt(I);if(R.wheel)(R.mouse[0][0]!==H[0]||R.mouse[0][1]!==H[1])&&(R.mouse[1]=te.invert(R.mouse[0]=H)),clearTimeout(R.wheel);else{if(te.k===z)return;R.mouse=[H,te.invert(H)],oi(this),R.start()}Mo(I),R.wheel=setTimeout(L,h),R.zoom("mouse",o(b(w(te,z),R.mouse[0],R.mouse[1]),R.extent,l));function L(){R.wheel=null,R.end()}}function B(I,...M){if(p||!e.apply(this,arguments))return;var R=I.currentTarget,te=E(this,M,!0).event(I),z=_t(I.view).on("mousemove.zoom",Z,!0).on("mouseup.zoom",Q,!0),H=xt(I,R),L=I.clientX,F=I.clientY;Su(I.view),ul(I),te.mouse=[H,this.__zoom.invert(H)],oi(this),te.start();function Z(W){if(Mo(W),!te.moved){var ie=W.clientX-L,ae=W.clientY-F;te.moved=ie*ie+ae*ae>y}te.event(W).zoom("mouse",o(b(te.that.__zoom,te.mouse[0]=xt(W,R),te.mouse[1]),te.extent,l))}function Q(W){z.on("mousemove.zoom mouseup.zoom",null),xu(W.view,te.moved),Mo(W),te.event(W).end()}}function j(I,...M){if(e.apply(this,arguments)){var R=this.__zoom,te=xt(I.changedTouches?I.changedTouches[0]:I,this),z=R.invert(te),H=R.k*(I.shiftKey?.5:2),L=o(b(w(R,H),te,z),n.apply(this,M),l);Mo(I),s>0?_t(this).transition().duration(s).call(N,L,te,I):_t(this).call(_.transform,L,te,I)}}function G(I,...M){if(e.apply(this,arguments)){var R=I.touches,te=R.length,z=E(this,M,I.changedTouches.length===te).event(I),H,L,F,Z;for(ul(I),L=0;L<te;++L)F=R[L],Z=xt(F,this),Z=[Z,this.__zoom.invert(Z),F.identifier],z.touch0?!z.touch1&&z.touch0[2]!==Z[2]&&(z.touch1=Z,z.taps=0):(z.touch0=Z,H=!0,z.taps=1+!!u);u&&(u=clearTimeout(u)),H&&(z.taps<2&&(f=Z[0],u=setTimeout(function(){u=null},m)),oi(this),z.start())}}function T(I,...M){if(this.__zooming){var R=E(this,M).event(I),te=I.changedTouches,z=te.length,H,L,F,Z;for(Mo(I),H=0;H<z;++H)L=te[H],F=xt(L,this),R.touch0&&R.touch0[2]===L.identifier?R.touch0[0]=F:R.touch1&&R.touch1[2]===L.identifier&&(R.touch1[0]=F);if(L=R.that.__zoom,R.touch1){var Q=R.touch0[0],W=R.touch0[1],ie=R.touch1[0],ae=R.touch1[1],me=(me=ie[0]-Q[0])*me+(me=ie[1]-Q[1])*me,ge=(ge=ae[0]-W[0])*ge+(ge=ae[1]-W[1])*ge;L=w(L,Math.sqrt(me/ge)),F=[(Q[0]+ie[0])/2,(Q[1]+ie[1])/2],Z=[(W[0]+ae[0])/2,(W[1]+ae[1])/2]}else if(R.touch0)F=R.touch0[0],Z=R.touch0[1];else return;R.zoom("touch",o(b(L,F,Z),R.extent,l))}}function Y(I,...M){if(this.__zooming){var R=E(this,M).event(I),te=I.changedTouches,z=te.length,H,L;for(ul(I),p&&clearTimeout(p),p=setTimeout(function(){p=null},m),H=0;H<z;++H)L=te[H],R.touch0&&R.touch0[2]===L.identifier?delete R.touch0:R.touch1&&R.touch1[2]===L.identifier&&delete R.touch1;if(R.touch1&&!R.touch0&&(R.touch0=R.touch1,delete R.touch1),R.touch0)R.touch0[1]=this.__zoom.invert(R.touch0[0]);else if(R.end(),R.taps===2&&(L=xt(L,this),Math.hypot(f[0]-L[0],f[1]-L[1])<g)){var F=_t(this).on("dblclick.zoom");F&&F.apply(this,arguments)}}}return _.wheelDelta=function(I){return arguments.length?(r=typeof I=="function"?I:ri(+I),_):r},_.filter=function(I){return arguments.length?(e=typeof I=="function"?I:ri(!!I),_):e},_.touchable=function(I){return arguments.length?(i=typeof I=="function"?I:ri(!!I),_):i},_.extent=function(I){return arguments.length?(n=typeof I=="function"?I:ri([[+I[0][0],+I[0][1]],[+I[1][0],+I[1][1]]]),_):n},_.scaleExtent=function(I){return arguments.length?(a[0]=+I[0],a[1]=+I[1],_):[a[0],a[1]]},_.translateExtent=function(I){return arguments.length?(l[0][0]=+I[0][0],l[1][0]=+I[1][0],l[0][1]=+I[0][1],l[1][1]=+I[1][1],_):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},_.constrain=function(I){return arguments.length?(o=I,_):o},_.duration=function(I){return arguments.length?(s=+I,_):s},_.interpolate=function(I){return arguments.length?(c=I,_):c},_.on=function(){var I=d.on.apply(d,arguments);return I===d?_:I},_.clickDistance=function(I){return arguments.length?(y=(I=+I)*I,_):Math.sqrt(y)},_.tapDistance=function(I){return arguments.length?(g=+I,_):g},_}var ye=(e=>(e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom",e))(ye||{}),fl=(e=>(e.Partial="partial",e.Full="full",e))(fl||{}),_n=(e=>(e.Bezier="default",e.SimpleBezier="simple-bezier",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e))(_n||{}),Xt=(e=>(e.Strict="strict",e.Loose="loose",e))(Xt||{}),ii=(e=>(e.Arrow="arrow",e.ArrowClosed="arrowclosed",e))(ii||{}),Lo=(e=>(e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal",e))(Lo||{}),nf=(e=>(e.TopLeft="top-left",e.TopCenter="top-center",e.TopRight="top-right",e.BottomLeft="bottom-left",e.BottomCenter="bottom-center",e.BottomRight="bottom-right",e))(nf||{});const sx=["INPUT","SELECT","TEXTAREA"],cx=typeof document<"u"?document:null;function pl(e){var n,o;const r=((o=(n=e.composedPath)==null?void 0:n.call(e))==null?void 0:o[0])||e.target,i=typeof(r==null?void 0:r.hasAttribute)=="function"?r.hasAttribute("contenteditable"):!1,a=typeof(r==null?void 0:r.closest)=="function"?r.closest(".nokey"):null;return sx.includes(r==null?void 0:r.nodeName)||i||!!a}function dx(e){return e.ctrlKey||e.metaKey||e.shiftKey||e.altKey}function of(e,n,o,r){const i=n.replace("+",`
|
|
120
120
|
`).replace(`
|
|
121
121
|
|
|
122
122
|
`,`
|
|
@@ -141,4 +141,4 @@ Edge: ${e}
|
|
|
141
141
|
Source: ${n}
|
|
142
142
|
Target: ${o}`,EDGE_ORPHANED:e=>`Edge was orphaned (suddenly missing source or target) and has been removed
|
|
143
143
|
Edge: ${e}`,EDGE_NOT_FOUND:e=>`Edge not found
|
|
144
|
-
Edge: ${e}`,USEVUEFLOW_OPTIONS:()=>"The options parameter is deprecated and will be removed in the next major version. Please use the id parameter instead"};class We extends Error{constructor(n,...o){var r;super((r=Af[n])==null?void 0:r.call(Af,...o)),this.name="VueFlowError",this.code=n,this.args=o}}function _l(e){return"clientX"in e}function Ax(e){return"sourceEvent"in e}function Tt(e,n){const o=_l(e);let r,i;return o?(r=e.clientX,i=e.clientY):"touches"in e&&e.touches.length>0?(r=e.touches[0].clientX,i=e.touches[0].clientY):"changedTouches"in e&&e.changedTouches.length>0?(r=e.changedTouches[0].clientX,i=e.changedTouches[0].clientY):(r=0,i=0),{x:r-((n==null?void 0:n.left)??0),y:i-((n==null?void 0:n.top)??0)}}const di=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Ix(e){var n,o;return{width:((n=e.dimensions)==null?void 0:n.width)??e.width??0,height:((o=e.dimensions)==null?void 0:o.height)??e.height??0}}function ui(e,n=[1,1]){return{x:n[0]*Math.round(e.x/n[0]),y:n[1]*Math.round(e.y/n[1])}}const Px=()=>!0;function bl(e){e==null||e.classList.remove("valid","connecting","vue-flow__handle-valid","vue-flow__handle-connecting")}function Tx(e,n,o){const r=[],i={x:e.x-o,y:e.y-o,width:o*2,height:o*2};for(const a of n.values())li(i,ai(a))>0&&r.push(a);return r}const Ox=250;function $x(e,n,o,r){var i,a;let l=[],s=Number.POSITIVE_INFINITY;const c=Tx(e,o,n+Ox);for(const d of c){const u=[...((i=d.handleBounds)==null?void 0:i.source)??[],...((a=d.handleBounds)==null?void 0:a.target)??[]];for(const f of u){if(r.nodeId===f.nodeId&&r.type===f.type&&r.id===f.id)continue;const{x:p,y:m}=Zn(d,f,f.position,!0),h=Math.sqrt((p-e.x)**2+(m-e.y)**2);h>n||(h<s?(l=[{...f,x:p,y:m}],s=h):h===s&&l.push({...f,x:p,y:m}))}}if(!l.length)return null;if(l.length>1){const d=r.type==="source"?"target":"source";return l.find(u=>u.type===d)??l[0]}return l[0]}function If(e,{handle:n,connectionMode:o,fromNodeId:r,fromHandleId:i,fromType:a,doc:l,lib:s,flowId:c,isValidConnection:d=Px},u,f,p){const m=a==="target",h=n?l.querySelector(`.${s}-flow__handle[data-id="${c}-${n==null?void 0:n.nodeId}-${n==null?void 0:n.id}-${n==null?void 0:n.type}"]`):null,{x:y,y:g}=Tt(e),_=l.elementFromPoint(y,g),w=_!=null&&_.classList.contains(`${s}-flow__handle`)?_:h,b={handleDomNode:w,isValid:!1,connection:null,toHandle:null};if(w){const v=Pf(void 0,w),N=w.getAttribute("data-nodeid"),E=w.getAttribute("data-handleid"),S=w.classList.contains("connectable"),P=w.classList.contains("connectableend");if(!N||!v)return b;const B={source:m?N:r,sourceHandle:m?E:i,target:m?r:N,targetHandle:m?i:E};b.connection=B;const G=S&&P&&(o===Xt.Strict?m&&v==="source"||!m&&v==="target":N!==r||E!==i);b.isValid=G&&d(B,{nodes:f,edges:u,sourceNode:p(r),targetNode:p(N)}),b.toHandle=n}return b}function Pf(e,n){return e||(n!=null&&n.classList.contains("target")?"target":n!=null&&n.classList.contains("source")?"source":null)}function Bx(e,n){let o=null;return n?o="valid":e&&!n&&(o="invalid"),o}function Vx(e,n){let o=null;return n?o=!0:e&&!n&&(o=!1),o}function Rx(e,n,o,r,i,a=!1){var l,s,c;const d=r.get(e);if(!d)return null;const u=i===Xt.Strict?(l=d.handleBounds)==null?void 0:l[n]:[...((s=d.handleBounds)==null?void 0:s.source)??[],...((c=d.handleBounds)==null?void 0:c.target)??[]],f=(o?u==null?void 0:u.find(p=>p.id===o):u==null?void 0:u[0])??null;return f&&a?{...f,...Zn(d,f,f.position,!0)}:f}const wl={[ye.Left]:ye.Right,[ye.Right]:ye.Left,[ye.Top]:ye.Bottom,[ye.Bottom]:ye.Top},Dx=["production","prod"];function fi(e,...n){Tf()&&console.warn(`[Vue Flow]: ${e}`,...n)}function Tf(){return!Dx.includes(process.env.NODE_ENV||"")}function Of(e,n,o,r,i){const a=n.querySelectorAll(`.vue-flow__handle.${e}`);return a!=null&&a.length?Array.from(a).map(l=>{const s=l.getBoundingClientRect();return{id:l.getAttribute("data-handleid"),type:e,nodeId:i,position:l.getAttribute("data-handlepos"),x:(s.left-o.left)/r,y:(s.top-o.top)/r,...si(l)}}):null}function kl(e,n,o,r,i,a=!1,l){i.value=!1,e.selected?(a||e.selected&&n)&&(r([e]),t.nextTick(()=>{l.blur()})):o([e])}function Ge(e){return typeof t.unref(e)<"u"}function Mx(e,n,o,r){if(!e||!e.source||!e.target)return o(new We(je.EDGE_INVALID,(e==null?void 0:e.id)??"[ID UNKNOWN]")),!1;let i;return Zt(e)?i=e:i={...e,id:ff(e)},i=df(i,void 0,r),_x(i,n)?!1:i}function Lx(e,n,o,r,i){if(!n.source||!n.target)return i(new We(je.EDGE_INVALID,e.id)),!1;if(!o)return i(new We(je.EDGE_NOT_FOUND,e.id)),!1;const{id:a,...l}=e;return{...l,id:r?ff(n):a,source:n.source,target:n.target,sourceHandle:n.sourceHandle,targetHandle:n.targetHandle}}function $f(e,n,o){const r={},i=[];for(let a=0;a<e.length;++a){const l=e[a];if(!wn(l)){o(new We(je.NODE_INVALID,l==null?void 0:l.id)||`[ID UNKNOWN|INDEX ${a}]`);continue}const s=gx(l,n(l.id),l.parentNode);l.parentNode&&(r[l.parentNode]=!0),i[a]=s}for(const a of i){const l=n(a.parentNode)||i.find(s=>s.id===a.parentNode);a.parentNode&&!l&&o(new We(je.NODE_MISSING_PARENT,a.id,a.parentNode)),(a.parentNode||r[a.id])&&(r[a.id]&&(a.isParent=!0),l&&(l.isParent=!0))}return i}function Bf(e,n,o,r,i,a){let l=i;const s=r.get(l)||new Map;r.set(l,s.set(o,n)),l=`${i}-${e}`;const c=r.get(l)||new Map;if(r.set(l,c.set(o,n)),a){l=`${i}-${e}-${a}`;const d=r.get(l)||new Map;r.set(l,d.set(o,n))}}function El(e,n,o){e.clear();for(const r of o){const{source:i,target:a,sourceHandle:l=null,targetHandle:s=null}=r,c={edgeId:r.id,source:i,target:a,sourceHandle:l,targetHandle:s},d=`${i}-${l}--${a}-${s}`,u=`${a}-${s}--${i}-${l}`;Bf("source",c,u,e,i,l),Bf("target",c,d,e,a,s)}}function Vf(e,n){if(e.size!==n.size)return!1;for(const o of e)if(!n.has(o))return!1;return!0}function Cl(e,n,o,r,i,a,l,s){const c=[];for(const d of e){const u=Zt(d)?d:Mx(d,s,i,a);if(!u)continue;const f=o(u.source),p=o(u.target);if(!f||!p){i(new We(je.EDGE_SOURCE_TARGET_MISSING,u.id,u.source,u.target));continue}if(!f){i(new We(je.EDGE_SOURCE_MISSING,u.id,u.source));continue}if(!p){i(new We(je.EDGE_TARGET_MISSING,u.id,u.target));continue}if(n&&!n(u,{edges:s,nodes:l,sourceNode:f,targetNode:p})){i(new We(je.EDGE_INVALID,u.id));continue}const m=r(u.id);c.push({...df(u,m,a),sourceNode:f,targetNode:p})}return c}const Rf=Symbol("vueFlow"),Df=Symbol("nodeId"),Mf=Symbol("nodeRef"),Fx=Symbol("edgeId"),Ux=Symbol("edgeRef"),pi=Symbol("slots");function Lf(e){const{vueFlowRef:n,snapToGrid:o,snapGrid:r,noDragClassName:i,nodes:a,nodeExtent:l,nodeDragThreshold:s,viewport:c,autoPanOnNodeDrag:d,autoPanSpeed:u,nodesDraggable:f,panBy:p,findNode:m,multiSelectionActive:h,nodesSelectionActive:y,selectNodesOnDrag:g,removeSelectedElements:_,addSelectedNodes:w,updateNodePositions:b,emits:v}=Oe(),{onStart:N,onDrag:E,onStop:S,onClick:P,el:B,disabled:j,id:G,selectable:T,dragHandle:Y}=e,I=t.shallowRef(!1);let M=[],R,te=null,z={x:void 0,y:void 0},H={x:0,y:0},L=null,F=!1,Z=0,Q=!1;const W=Gx(),ie=({x:q,y:ee})=>{z={x:q,y:ee};let O=!1;if(M=M.map(k=>{const C={x:q-k.distance.x,y:ee-k.distance.y},{computedPosition:A}=yl(k,o.value?ui(C,r.value):C,v.error,l.value,k.parentNode?m(k.parentNode):void 0);return O=O||k.position.x!==A.x||k.position.y!==A.y,k.position=A,k}),!!O&&(b(M,!0,!0),I.value=!0,L)){const[k,C]=hl({id:G,dragItems:M,findNode:m});E({event:L,node:k,nodes:C})}},ae=()=>{if(!te)return;const[q,ee]=wf(H,te,u.value);if(q!==0||ee!==0){const O={x:(z.x??0)-q/c.value.zoom,y:(z.y??0)-ee/c.value.zoom};p({x:q,y:ee})&&ie(O)}Z=requestAnimationFrame(ae)},me=(q,ee)=>{F=!0;const O=m(G);!g.value&&!h.value&&O&&(O.selected||_()),O&&t.toValue(T)&&g.value&&kl(O,h.value,w,_,y,!1,ee);const k=W(q.sourceEvent);if(z=k,M=Ex(a.value,f.value,k,m,G),M.length){const[C,A]=hl({id:G,dragItems:M,findNode:m});N({event:q.sourceEvent,node:C,nodes:A})}},ge=(q,ee)=>{var O;q.sourceEvent.type==="touchmove"&&q.sourceEvent.touches.length>1||(s.value===0&&me(q,ee),z=W(q.sourceEvent),te=((O=n.value)==null?void 0:O.getBoundingClientRect())||null,H=Tt(q.sourceEvent,te))},ne=(q,ee)=>{const O=W(q.sourceEvent);if(!Q&&F&&d.value&&(Q=!0,ae()),!F){const k=O.xSnapped-(z.x??0),C=O.ySnapped-(z.y??0);Math.sqrt(k*k+C*C)>s.value&&me(q,ee)}(z.x!==O.xSnapped||z.y!==O.ySnapped)&&M.length&&F&&(L=q.sourceEvent,H=Tt(q.sourceEvent,te),ie(O))},re=q=>{let ee=!1;if(!F&&!I.value&&!h.value){const O=q.sourceEvent,k=W(O),C=k.xSnapped-(z.x??0),A=k.ySnapped-(z.y??0),x=Math.sqrt(C*C+A*A);x!==0&&x<=s.value&&(P==null||P(O),ee=!0)}if(M.length&&!ee){b(M,!1,!1);const[O,k]=hl({id:G,dragItems:M,findNode:m});S({event:q.sourceEvent,node:O,nodes:k})}M=[],I.value=!1,Q=!1,F=!1,z={x:void 0,y:void 0},cancelAnimationFrame(Z)};return t.watch([()=>t.toValue(j),B],([q,ee],O,k)=>{if(ee){const C=_t(ee);q||(R=mv().on("start",A=>ge(A,ee)).on("drag",A=>ne(A,ee)).on("end",A=>re(A)).filter(A=>{const x=A.target,U=t.toValue(Y);return!A.button&&(!i.value||!vf(x,`.${i.value}`,ee)&&(!U||vf(x,U,ee)))}),C.call(R)),k(()=>{C.on(".drag",null),R&&(R.on("start",null),R.on("drag",null),R.on("end",null))})}}),I}function Kx(){return{doubleClick:he(),click:he(),mouseEnter:he(),mouseMove:he(),mouseLeave:he(),contextMenu:he(),updateStart:he(),update:he(),updateEnd:he()}}function jx(e,n){const o=Kx();return o.doubleClick.on(r=>{var i,a;n.edgeDoubleClick(r),(a=(i=e.events)==null?void 0:i.doubleClick)==null||a.call(i,r)}),o.click.on(r=>{var i,a;n.edgeClick(r),(a=(i=e.events)==null?void 0:i.click)==null||a.call(i,r)}),o.mouseEnter.on(r=>{var i,a;n.edgeMouseEnter(r),(a=(i=e.events)==null?void 0:i.mouseEnter)==null||a.call(i,r)}),o.mouseMove.on(r=>{var i,a;n.edgeMouseMove(r),(a=(i=e.events)==null?void 0:i.mouseMove)==null||a.call(i,r)}),o.mouseLeave.on(r=>{var i,a;n.edgeMouseLeave(r),(a=(i=e.events)==null?void 0:i.mouseLeave)==null||a.call(i,r)}),o.contextMenu.on(r=>{var i,a;n.edgeContextMenu(r),(a=(i=e.events)==null?void 0:i.contextMenu)==null||a.call(i,r)}),o.updateStart.on(r=>{var i,a;n.edgeUpdateStart(r),(a=(i=e.events)==null?void 0:i.updateStart)==null||a.call(i,r)}),o.update.on(r=>{var i,a;n.edgeUpdate(r),(a=(i=e.events)==null?void 0:i.update)==null||a.call(i,r)}),o.updateEnd.on(r=>{var i,a;n.edgeUpdateEnd(r),(a=(i=e.events)==null?void 0:i.updateEnd)==null||a.call(i,r)}),Object.entries(o).reduce((r,[i,a])=>(r.emit[i]=a.trigger,r.on[i]=a.on,r),{emit:{},on:{}})}function Gx(){const{viewport:e,snapGrid:n,snapToGrid:o,vueFlowRef:r}=Oe();return i=>{var a;const l=((a=r.value)==null?void 0:a.getBoundingClientRect())??{left:0,top:0},s=Ax(i)?i.sourceEvent:i,{x:c,y:d}=Tt(s,l),u=Ko({x:c,y:d},e.value),{x:f,y:p}=o.value?ui(u,n.value):u;return{xSnapped:f,ySnapped:p,...u}}}function mi(){return!0}function Ff({handleId:e,nodeId:n,type:o,isValidConnection:r,edgeUpdaterType:i,onEdgeUpdate:a,onEdgeUpdateEnd:l}){const{id:s,vueFlowRef:c,connectionMode:d,connectionRadius:u,connectOnClick:f,connectionClickStartHandle:p,nodesConnectable:m,autoPanOnConnect:h,autoPanSpeed:y,findNode:g,panBy:_,startConnection:w,updateConnection:b,endConnection:v,emits:N,viewport:E,edges:S,nodes:P,isValidConnection:B,nodeLookup:j}=Oe();let G=null,T=!1,Y=null;function I(R){var te;const z=t.toValue(o)==="target",H=_l(R),L=cf(R.target);if(H&&R.button===0||!H){let F=function(X){k=Tt(X,q),ie=$x(Ko(k,E.value,!1,[1,1]),u.value,j.value,x),C||(A(),C=!0);const D=If(X,{handle:ie,connectionMode:d.value,fromNodeId:t.toValue(n),fromHandleId:t.toValue(e),fromType:z?"target":"source",isValidConnection:W,doc:L,lib:"vue",flowId:s,nodeLookup:j.value},S.value,P.value,g);Y=D.handleDomNode,G=D.connection,T=Vx(!!ie,D.isValid);const pe={...$,isValid:T,to:D.toHandle&&T?ml({x:D.toHandle.x,y:D.toHandle.y},E.value):k,toHandle:D.toHandle,toPosition:T&&D.toHandle?D.toHandle.position:wl[x.position],toNode:D.toHandle?j.value.get(D.toHandle.nodeId):null};if(!(T&&ie&&($!=null&&$.toHandle)&&pe.toHandle&&$.toHandle.type===pe.toHandle.type&&$.toHandle.nodeId===pe.toHandle.nodeId&&$.toHandle.id===pe.toHandle.id&&$.to.x===pe.to.x&&$.to.y===pe.to.y)){if(b(ie&&T?ml({x:ie.x,y:ie.y},E.value):k,D.toHandle,Bx(!!ie,T)),$=pe,!ie&&!T&&!Y)return bl(O);G&&G.source!==G.target&&Y&&(bl(O),O=Y,Y.classList.add("connecting","vue-flow__handle-connecting"),Y.classList.toggle("valid",!!T),Y.classList.toggle("vue-flow__handle-valid",!!T))}},Z=function(X){(ie||Y)&&G&&T&&(a?a(X,G):N.connect(G)),N.connectEnd(X),i&&(l==null||l(X)),bl(O),cancelAnimationFrame(ae),v(X),C=!1,T=!1,G=null,Y=null,L.removeEventListener("mousemove",F),L.removeEventListener("mouseup",Z),L.removeEventListener("touchmove",F),L.removeEventListener("touchend",Z)};const Q=g(t.toValue(n));let W=t.toValue(r)||B.value||mi;!W&&Q&&(W=(z?Q.isValidSourcePos:Q.isValidTargetPos)||mi);let ie,ae=0;const{x:me,y:ge}=Tt(R),ne=L==null?void 0:L.elementFromPoint(me,ge),re=Pf(t.toValue(i),ne),q=(te=c.value)==null?void 0:te.getBoundingClientRect();if(!q||!re)return;const ee=Rx(t.toValue(n),re,t.toValue(e),j.value,d.value);if(!ee)return;let O,k=Tt(R,q),C=!1;const A=()=>{if(!h.value)return;const[X,D]=wf(k,q,y.value);_({x:X,y:D}),ae=requestAnimationFrame(A)},x={...ee,nodeId:t.toValue(n),type:re,position:ee.position},U=j.value.get(t.toValue(n)),J={inProgress:!0,isValid:null,from:Zn(U,x,ye.Left,!0),fromHandle:x,fromPosition:x.position,fromNode:U,to:k,toHandle:null,toPosition:wl[x.position],toNode:null};w({nodeId:t.toValue(n),id:t.toValue(e),type:re,position:(ne==null?void 0:ne.getAttribute("data-handlepos"))||ye.Top,...k},{x:me-q.left,y:ge-q.top}),N.connectStart({event:R,nodeId:t.toValue(n),handleId:t.toValue(e),handleType:re});let $=J;L.addEventListener("mousemove",F),L.addEventListener("mouseup",Z),L.addEventListener("touchmove",F),L.addEventListener("touchend",Z)}}function M(R){var te,z;if(!f.value)return;const H=t.toValue(o)==="target";if(!p.value){N.clickConnectStart({event:R,nodeId:t.toValue(n),handleId:t.toValue(e)}),w({nodeId:t.toValue(n),type:t.toValue(o),id:t.toValue(e),position:ye.Top,...Tt(R)},void 0,!0);return}let L=t.toValue(r)||B.value||mi;const F=g(t.toValue(n));if(!L&&F&&(L=(H?F.isValidSourcePos:F.isValidTargetPos)||mi),F&&(typeof F.connectable>"u"?m.value:F.connectable)===!1)return;const Z=cf(R.target),Q=If(R,{handle:{nodeId:t.toValue(n),id:t.toValue(e),type:t.toValue(o),position:ye.Top,...Tt(R)},connectionMode:d.value,fromNodeId:p.value.nodeId,fromHandleId:p.value.id??null,fromType:p.value.type,isValidConnection:L,doc:Z,lib:"vue",flowId:s,nodeLookup:j.value},S.value,P.value,g),W=((te=Q.connection)==null?void 0:te.source)===((z=Q.connection)==null?void 0:z.target);Q.isValid&&Q.connection&&!W&&N.connect(Q.connection),N.clickConnectEnd(R),v(R,!0)}return{handlePointerDown:I,handleClick:M}}function qx(){return t.inject(Df,"")}function Uf(e){const n=e??qx()??"",o=t.inject(Mf,t.ref(null)),{findNode:r,edges:i,emits:a}=Oe(),l=r(n);return l||a.error(new We(je.NODE_NOT_FOUND,n)),{id:n,nodeEl:o,node:l,parentNode:t.computed(()=>r(l.parentNode)),connectedEdges:t.computed(()=>hf([l],i.value))}}function zx(){return{doubleClick:he(),click:he(),mouseEnter:he(),mouseMove:he(),mouseLeave:he(),contextMenu:he(),dragStart:he(),drag:he(),dragStop:he()}}function Hx(e,n){const o=zx();return o.doubleClick.on(r=>{var i,a;n.nodeDoubleClick(r),(a=(i=e.events)==null?void 0:i.doubleClick)==null||a.call(i,r)}),o.click.on(r=>{var i,a;n.nodeClick(r),(a=(i=e.events)==null?void 0:i.click)==null||a.call(i,r)}),o.mouseEnter.on(r=>{var i,a;n.nodeMouseEnter(r),(a=(i=e.events)==null?void 0:i.mouseEnter)==null||a.call(i,r)}),o.mouseMove.on(r=>{var i,a;n.nodeMouseMove(r),(a=(i=e.events)==null?void 0:i.mouseMove)==null||a.call(i,r)}),o.mouseLeave.on(r=>{var i,a;n.nodeMouseLeave(r),(a=(i=e.events)==null?void 0:i.mouseLeave)==null||a.call(i,r)}),o.contextMenu.on(r=>{var i,a;n.nodeContextMenu(r),(a=(i=e.events)==null?void 0:i.contextMenu)==null||a.call(i,r)}),o.dragStart.on(r=>{var i,a;n.nodeDragStart(r),(a=(i=e.events)==null?void 0:i.dragStart)==null||a.call(i,r)}),o.drag.on(r=>{var i,a;n.nodeDrag(r),(a=(i=e.events)==null?void 0:i.drag)==null||a.call(i,r)}),o.dragStop.on(r=>{var i,a;n.nodeDragStop(r),(a=(i=e.events)==null?void 0:i.dragStop)==null||a.call(i,r)}),Object.entries(o).reduce((r,[i,a])=>(r.emit[i]=a.trigger,r.on[i]=a.on,r),{emit:{},on:{}})}function Kf(){const{getSelectedNodes:e,nodeExtent:n,updateNodePositions:o,findNode:r,snapGrid:i,snapToGrid:a,nodesDraggable:l,emits:s}=Oe();return(c,d=!1)=>{const u=a.value?i.value[0]:5,f=a.value?i.value[1]:5,p=d?4:1,m=c.x*u*p,h=c.y*f*p,y=[];for(const g of e.value)if(g.draggable||l&&typeof g.draggable>"u"){const _={x:g.computedPosition.x+m,y:g.computedPosition.y+h},{computedPosition:w}=yl(g,_,s.error,n.value,g.parentNode?r(g.parentNode):void 0);y.push({id:g.id,position:w,from:g.position,distance:{x:c.x,y:c.y},dimensions:g.dimensions})}o(y,!0,!1)}}const Nl=.1,Yx=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2;function en(){return fi("Viewport not initialized yet."),Promise.resolve(!1)}const Wx={zoomIn:en,zoomOut:en,zoomTo:en,fitView:en,setCenter:en,fitBounds:en,project:e=>e,screenToFlowCoordinate:e=>e,flowToScreenCoordinate:e=>e,setViewport:en,setTransform:en,getViewport:()=>({x:0,y:0,zoom:1}),getTransform:()=>({x:0,y:0,zoom:1}),viewportInitialized:!1};function Xx(e){function n(r,i){return new Promise(a=>{e.d3Selection&&e.d3Zoom?e.d3Zoom.interpolate((i==null?void 0:i.interpolate)==="linear"?$o:Wr).scaleBy(vl(e.d3Selection,i==null?void 0:i.duration,i==null?void 0:i.ease,()=>{a(!0)}),r):a(!1)})}function o(r,i,a,l){return new Promise(s=>{var c;const{x:d,y:u}=sf({x:-r,y:-i},e.translateExtent),f=Wn.translate(-d,-u).scale(a);e.d3Selection&&e.d3Zoom?(c=e.d3Zoom)==null||c.interpolate((l==null?void 0:l.interpolate)==="linear"?$o:Wr).transform(vl(e.d3Selection,l==null?void 0:l.duration,l==null?void 0:l.ease,()=>{s(!0)}),f):s(!1)})}return t.computed(()=>e.d3Zoom&&e.d3Selection&&e.dimensions.width&&e.dimensions.height?{viewportInitialized:!0,zoomIn:i=>n(1.2,i),zoomOut:i=>n(1/1.2,i),zoomTo:(i,a)=>new Promise(l=>{e.d3Selection&&e.d3Zoom?e.d3Zoom.interpolate((a==null?void 0:a.interpolate)==="linear"?$o:Wr).scaleTo(vl(e.d3Selection,a==null?void 0:a.duration,a==null?void 0:a.ease,()=>{l(!0)}),i):l(!1)}),setViewport:(i,a)=>o(i.x,i.y,i.zoom,a),setTransform:(i,a)=>o(i.x,i.y,i.zoom,a),getViewport:()=>({x:e.viewport.x,y:e.viewport.y,zoom:e.viewport.zoom}),getTransform:()=>({x:e.viewport.x,y:e.viewport.y,zoom:e.viewport.zoom}),fitView:(i={padding:Nl,includeHiddenNodes:!1,duration:0})=>{var a,l;const s=[];for(const p of e.nodes)p.dimensions.width&&p.dimensions.height&&((i==null?void 0:i.includeHiddenNodes)||!p.hidden)&&(!((a=i.nodes)!=null&&a.length)||(l=i.nodes)!=null&&l.length&&i.nodes.includes(p.id))&&s.push(p);if(!s.length)return Promise.resolve(!1);const c=mf(s),{x:d,y:u,zoom:f}=yf(c,e.dimensions.width,e.dimensions.height,i.minZoom??e.minZoom,i.maxZoom??e.maxZoom,i.padding??Nl,i.offset);return o(d,u,f,i)},setCenter:(i,a,l)=>{const s=typeof(l==null?void 0:l.zoom)<"u"?l.zoom:e.maxZoom,c=e.dimensions.width/2-i*s,d=e.dimensions.height/2-a*s;return o(c,d,s,l)},fitBounds:(i,a={padding:Nl})=>{const{x:l,y:s,zoom:c}=yf(i,e.dimensions.width,e.dimensions.height,e.minZoom,e.maxZoom,a.padding);return o(l,s,c,a)},project:i=>Ko(i,e.viewport,e.snapToGrid,e.snapGrid),screenToFlowCoordinate:i=>{if(e.vueFlowRef){const{x:a,y:l}=e.vueFlowRef.getBoundingClientRect(),s={x:i.x-a,y:i.y-l};return Ko(s,e.viewport,e.snapToGrid,e.snapGrid)}return{x:0,y:0}},flowToScreenCoordinate:i=>{if(e.vueFlowRef){const{x:a,y:l}=e.vueFlowRef.getBoundingClientRect(),s={x:i.x+a,y:i.y+l};return ml(s,e.viewport)}return{x:0,y:0}}}:Wx)}function vl(e,n=0,o=Yx,r=()=>{}){const i=typeof n=="number"&&n>0;return i||r(),i?e.transition().duration(n).ease(o).on("end",r):e}function Zx(e,n,o){const r=t.effectScope(!0);return r.run(()=>{const i=()=>{r.run(()=>{let y,g,_=!!(o.nodes.value.length||o.edges.value.length);y=Gn([e.modelValue,()=>{var w,b;return(b=(w=e.modelValue)==null?void 0:w.value)==null?void 0:b.length}],([w])=>{w&&Array.isArray(w)&&(g==null||g.pause(),o.setElements(w),!g&&!_&&w.length?_=!0:g==null||g.resume())}),g=Gn([o.nodes,o.edges,()=>o.edges.value.length,()=>o.nodes.value.length],([w,b])=>{var v;(v=e.modelValue)!=null&&v.value&&Array.isArray(e.modelValue.value)&&(y==null||y.pause(),e.modelValue.value=[...w,...b],t.nextTick(()=>{y==null||y.resume()}))},{immediate:_}),t.onScopeDispose(()=>{y==null||y.stop(),g==null||g.stop()})})},a=()=>{r.run(()=>{let y,g,_=!!o.nodes.value.length;y=Gn([e.nodes,()=>{var w,b;return(b=(w=e.nodes)==null?void 0:w.value)==null?void 0:b.length}],([w])=>{w&&Array.isArray(w)&&(g==null||g.pause(),o.setNodes(w),!g&&!_&&w.length?_=!0:g==null||g.resume())}),g=Gn([o.nodes,()=>o.nodes.value.length],([w])=>{var b;(b=e.nodes)!=null&&b.value&&Array.isArray(e.nodes.value)&&(y==null||y.pause(),e.nodes.value=[...w],t.nextTick(()=>{y==null||y.resume()}))},{immediate:_}),t.onScopeDispose(()=>{y==null||y.stop(),g==null||g.stop()})})},l=()=>{r.run(()=>{let y,g,_=!!o.edges.value.length;y=Gn([e.edges,()=>{var w,b;return(b=(w=e.edges)==null?void 0:w.value)==null?void 0:b.length}],([w])=>{w&&Array.isArray(w)&&(g==null||g.pause(),o.setEdges(w),!g&&!_&&w.length?_=!0:g==null||g.resume())}),g=Gn([o.edges,()=>o.edges.value.length],([w])=>{var b;(b=e.edges)!=null&&b.value&&Array.isArray(e.edges.value)&&(y==null||y.pause(),e.edges.value=[...w],t.nextTick(()=>{y==null||y.resume()}))},{immediate:_}),t.onScopeDispose(()=>{y==null||y.stop(),g==null||g.stop()})})},s=()=>{r.run(()=>{t.watch(()=>n.maxZoom,()=>{n.maxZoom&&Ge(n.maxZoom)&&o.setMaxZoom(n.maxZoom)},{immediate:!0})})},c=()=>{r.run(()=>{t.watch(()=>n.minZoom,()=>{n.minZoom&&Ge(n.minZoom)&&o.setMinZoom(n.minZoom)},{immediate:!0})})},d=()=>{r.run(()=>{t.watch(()=>n.translateExtent,()=>{n.translateExtent&&Ge(n.translateExtent)&&o.setTranslateExtent(n.translateExtent)},{immediate:!0})})},u=()=>{r.run(()=>{t.watch(()=>n.nodeExtent,()=>{n.nodeExtent&&Ge(n.nodeExtent)&&o.setNodeExtent(n.nodeExtent)},{immediate:!0})})},f=()=>{r.run(()=>{t.watch(()=>n.applyDefault,()=>{Ge(n.applyDefault)&&(o.applyDefault.value=n.applyDefault)},{immediate:!0})})},p=()=>{r.run(()=>{const y=async g=>{let _=g;typeof n.autoConnect=="function"&&(_=await n.autoConnect(g)),_!==!1&&o.addEdges([_])};t.watch(()=>n.autoConnect,()=>{Ge(n.autoConnect)&&(o.autoConnect.value=n.autoConnect)},{immediate:!0}),t.watch(o.autoConnect,(g,_,w)=>{g?o.onConnect(y):o.hooks.value.connect.off(y),w(()=>{o.hooks.value.connect.off(y)})},{immediate:!0})})},m=()=>{const y=["id","modelValue","translateExtent","nodeExtent","edges","nodes","maxZoom","minZoom","applyDefault","autoConnect"];for(const g of Object.keys(n)){const _=g;if(!y.includes(_)){const w=t.toRef(()=>n[_]),b=o[_];t.isRef(b)&&r.run(()=>{t.watch(w,v=>{Ge(v)&&(b.value=v)},{immediate:!0})})}}};(()=>{i(),a(),l(),c(),s(),d(),u(),f(),p(),m()})()}),()=>r.stop()}function Jx(){return{edgesChange:he(),nodesChange:he(),nodeDoubleClick:he(),nodeClick:he(),nodeMouseEnter:he(),nodeMouseMove:he(),nodeMouseLeave:he(),nodeContextMenu:he(),nodeDragStart:he(),nodeDrag:he(),nodeDragStop:he(),nodesInitialized:he(),miniMapNodeClick:he(),miniMapNodeDoubleClick:he(),miniMapNodeMouseEnter:he(),miniMapNodeMouseMove:he(),miniMapNodeMouseLeave:he(),connect:he(),connectStart:he(),connectEnd:he(),clickConnectStart:he(),clickConnectEnd:he(),paneReady:he(),init:he(),move:he(),moveStart:he(),moveEnd:he(),selectionDragStart:he(),selectionDrag:he(),selectionDragStop:he(),selectionContextMenu:he(),selectionStart:he(),selectionEnd:he(),viewportChangeStart:he(),viewportChange:he(),viewportChangeEnd:he(),paneScroll:he(),paneClick:he(),paneContextMenu:he(),paneMouseEnter:he(),paneMouseMove:he(),paneMouseLeave:he(),edgeContextMenu:he(),edgeMouseEnter:he(),edgeMouseMove:he(),edgeMouseLeave:he(),edgeDoubleClick:he(),edgeClick:he(),edgeUpdateStart:he(),edgeUpdate:he(),edgeUpdateEnd:he(),updateNodeInternals:he(),error:he(e=>fi(e.message))}}function Qx(e,n){t.onBeforeMount(()=>{for(const[o,r]of Object.entries(n.value)){const i=a=>{e(o,a)};r.fns.add(i),Dr(()=>{r.off(i)})}})}function jf(){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:fl.Full,paneDragging:!1,preventScrolling:!0,zoomOnScroll:!0,zoomOnPinch:!0,zoomOnDoubleClick:!0,panOnScroll:!1,panOnScrollSpeed:.5,panOnScrollMode:Lo.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:_n.Bezier,style:{}},connectionMode:Xt.Loose,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectionPosition:{x:Number.NaN,y:Number.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:di()?"Meta":"Control",zoomActivationKeyCode:di()?"Meta":"Control",deleteKeyCode:"Backspace",panActivationKeyCode:"Space",hooks:Jx(),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:""}}const eA=["id","vueFlowRef","viewportRef","initialized","modelValue","nodes","edges","maxZoom","minZoom","translateExtent","hooks","defaultEdgeOptions"];function tA(e,n,o){const r=Xx(e),i=k=>{const C=k??[];e.hooks.updateNodeInternals.trigger(C)},a=k=>yx(k,e.nodes,e.edges),l=k=>hx(k,e.nodes,e.edges),s=k=>hf(k,e.edges),c=({id:k,type:C,nodeId:A})=>{var x;return Array.from(((x=e.connectionLookup.get(`${A}-${C}-${k??null}`))==null?void 0:x.values())??[])},d=k=>{if(k)return n.value.get(k)},u=k=>{if(k)return o.value.get(k)},f=(k,C,A)=>{var x,U;const V=[];for(const J of k){const $={id:J.id,type:"position",dragging:A,from:J.from};if(C&&($.position=J.position,J.parentNode)){const X=d(J.parentNode);$.position={x:$.position.x-(((x=X==null?void 0:X.computedPosition)==null?void 0:x.x)??0),y:$.position.y-(((U=X==null?void 0:X.computedPosition)==null?void 0:U.y)??0)}}V.push($)}V!=null&&V.length&&e.hooks.nodesChange.trigger(V)},p=k=>{if(!e.vueFlowRef)return;const C=e.vueFlowRef.querySelector(".vue-flow__transformationpane");if(!C)return;const A=window.getComputedStyle(C),{m22:x}=new window.DOMMatrixReadOnly(A.transform),U=[];for(const V of k){const J=V,$=d(J.id);if($){const X=si(J.nodeElement);if(!!(X.width&&X.height&&($.dimensions.width!==X.width||$.dimensions.height!==X.height||J.forceUpdate))){const pe=J.nodeElement.getBoundingClientRect();$.dimensions=X,$.handleBounds.source=Of("source",J.nodeElement,pe,x,$.id),$.handleBounds.target=Of("target",J.nodeElement,pe,x,$.id),U.push({id:$.id,type:"dimensions",dimensions:X})}}}!e.fitViewOnInitDone&&e.fitViewOnInit&&r.value.fitView().then(()=>{e.fitViewOnInitDone=!0}),U.length&&e.hooks.nodesChange.trigger(U)},m=(k,C)=>{const A=new Set,x=new Set;for(const J of k)wn(J)?A.add(J.id):Zt(J)&&x.add(J.id);const U=Qt(n.value,A,!0),V=Qt(o.value,x);if(e.multiSelectionActive){for(const J of A)U.push(Jt(J,C));for(const J of x)V.push(Jt(J,C))}U.length&&e.hooks.nodesChange.trigger(U),V.length&&e.hooks.edgesChange.trigger(V)},h=k=>{if(e.multiSelectionActive){const C=k.map(A=>Jt(A.id,!0));e.hooks.nodesChange.trigger(C);return}e.hooks.nodesChange.trigger(Qt(n.value,new Set(k.map(C=>C.id)),!0)),e.hooks.edgesChange.trigger(Qt(o.value))},y=k=>{if(e.multiSelectionActive){const C=k.map(A=>Jt(A.id,!0));e.hooks.edgesChange.trigger(C);return}e.hooks.edgesChange.trigger(Qt(o.value,new Set(k.map(C=>C.id)))),e.hooks.nodesChange.trigger(Qt(n.value,new Set,!0))},g=k=>{m(k,!0)},_=k=>{const A=(k||e.nodes).map(x=>(x.selected=!1,Jt(x.id,!1)));e.hooks.nodesChange.trigger(A)},w=k=>{const A=(k||e.edges).map(x=>(x.selected=!1,Jt(x.id,!1)));e.hooks.edgesChange.trigger(A)},b=k=>{if(!k||!k.length)return m([],!1);const C=k.reduce((A,x)=>{const U=Jt(x.id,!1);return wn(x)?A.nodes.push(U):A.edges.push(U),A},{nodes:[],edges:[]});C.nodes.length&&e.hooks.nodesChange.trigger(C.nodes),C.edges.length&&e.hooks.edgesChange.trigger(C.edges)},v=k=>{var C;(C=e.d3Zoom)==null||C.scaleExtent([k,e.maxZoom]),e.minZoom=k},N=k=>{var C;(C=e.d3Zoom)==null||C.scaleExtent([e.minZoom,k]),e.maxZoom=k},E=k=>{var C;(C=e.d3Zoom)==null||C.translateExtent(k),e.translateExtent=k},S=k=>{e.nodeExtent=k,i()},P=k=>{var C;(C=e.d3Zoom)==null||C.clickDistance(k)},B=k=>{e.nodesDraggable=k,e.nodesConnectable=k,e.elementsSelectable=k},j=k=>{const C=k instanceof Function?k(e.nodes):k;!e.initialized&&!C.length||(e.nodes=$f(C,d,e.hooks.error.trigger))},G=k=>{const C=k instanceof Function?k(e.edges):k;if(!e.initialized&&!C.length)return;const A=Cl(C,e.isValidConnection,d,u,e.hooks.error.trigger,e.defaultEdgeOptions,e.nodes,e.edges);El(e.connectionLookup,o.value,A),e.edges=A},T=k=>{const C=k instanceof Function?k([...e.nodes,...e.edges]):k;!e.initialized&&!C.length||(j(C.filter(wn)),G(C.filter(Zt)))},Y=k=>{let C=k instanceof Function?k(e.nodes):k;C=Array.isArray(C)?C:[C];const A=$f(C,d,e.hooks.error.trigger),x=[];for(const U of A)x.push(Ef(U));x.length&&e.hooks.nodesChange.trigger(x)},I=k=>{let C=k instanceof Function?k(e.edges):k;C=Array.isArray(C)?C:[C];const A=Cl(C,e.isValidConnection,d,u,e.hooks.error.trigger,e.defaultEdgeOptions,e.nodes,e.edges),x=[];for(const U of A)x.push(Ef(U));x.length&&e.hooks.edgesChange.trigger(x)},M=(k,C=!0,A=!1)=>{const x=k instanceof Function?k(e.nodes):k,U=Array.isArray(x)?x:[x],V=[],J=[];function $(D){const pe=s(D);for(const le of pe)(!Ge(le.deletable)||le.deletable)&&J.push(Nf(le.id,le.source,le.target,le.sourceHandle,le.targetHandle))}function X(D){const pe=[];for(const le of e.nodes)le.parentNode===D&&pe.push(le);if(pe.length){for(const le of pe)V.push(Cf(le.id));C&&$(pe);for(const le of pe)X(le.id)}}for(const D of U){const pe=typeof D=="string"?d(D):D;pe&&(Ge(pe.deletable)&&!pe.deletable||(V.push(Cf(pe.id)),C&&$([pe]),A&&X(pe.id)))}J.length&&e.hooks.edgesChange.trigger(J),V.length&&e.hooks.nodesChange.trigger(V)},R=k=>{const C=k instanceof Function?k(e.edges):k,A=Array.isArray(C)?C:[C],x=[];for(const U of A){const V=typeof U=="string"?u(U):U;V&&(Ge(V.deletable)&&!V.deletable||x.push(Nf(typeof U=="string"?U:U.id,V.source,V.target,V.sourceHandle,V.targetHandle)))}e.hooks.edgesChange.trigger(x)},te=(k,C,A=!0)=>{const x=u(k.id);if(!x)return!1;const U=e.edges.indexOf(x),V=Lx(k,C,x,A,e.hooks.error.trigger);if(V){const[J]=Cl([V],e.isValidConnection,d,u,e.hooks.error.trigger,e.defaultEdgeOptions,e.nodes,e.edges);return e.edges=e.edges.map(($,X)=>X===U?J:$),El(e.connectionLookup,o.value,[J]),J}return!1},z=(k,C,A={replace:!1})=>{const x=u(k);if(!x)return;const U=typeof C=="function"?C(x):C;x.data=A.replace?U:{...x.data,...U}},H=k=>kf(k,e.nodes),L=k=>{const C=kf(k,e.edges);return El(e.connectionLookup,o.value,C),C},F=(k,C,A={replace:!1})=>{const x=d(k);if(!x)return;const U=typeof C=="function"?C(x):C;A.replace?e.nodes.splice(e.nodes.indexOf(x),1,U):Object.assign(x,U)},Z=(k,C,A={replace:!1})=>{const x=d(k);if(!x)return;const U=typeof C=="function"?C(x):C;x.data=A.replace?U:{...x.data,...U}},Q=(k,C,A=!1)=>{A?e.connectionClickStartHandle=k:e.connectionStartHandle=k,e.connectionEndHandle=null,e.connectionStatus=null,C&&(e.connectionPosition=C)},W=(k,C=null,A=null)=>{e.connectionStartHandle&&(e.connectionPosition=k,e.connectionEndHandle=C,e.connectionStatus=A)},ie=(k,C)=>{e.connectionPosition={x:Number.NaN,y:Number.NaN},e.connectionEndHandle=null,e.connectionStatus=null,C?e.connectionClickStartHandle=null:e.connectionStartHandle=null},ae=k=>{const C=mx(k),A=C?null:Uo(k)?k:d(k.id);return!C&&!A?[null,null,C]:[C?k:ai(A),A,C]},me=(k,C=!0,A=e.nodes)=>{const[x,U,V]=ae(k);if(!x)return[];const J=[];for(const $ of A||e.nodes){if(!V&&($.id===U.id||!$.computedPosition))continue;const X=ai($),D=li(X,x);(C&&D>0||D>=Number(x.width)*Number(x.height))&&J.push($)}return J},ge=(k,C,A=!0)=>{const[x]=ae(k);if(!x)return!1;const U=li(x,C);return A&&U>0||U>=Number(x.width)*Number(x.height)},ne=k=>{const{viewport:C,dimensions:A,d3Zoom:x,d3Selection:U,translateExtent:V}=e;if(!x||!U||!k.x&&!k.y)return!1;const J=Wn.translate(C.x+k.x,C.y+k.y).scale(C.zoom),$=[[0,0],[A.width,A.height]],X=x.constrain()(J,$,V),D=e.viewport.x!==X.x||e.viewport.y!==X.y||e.viewport.zoom!==X.k;return x.transform(U,X),D},re=k=>{const C=k instanceof Function?k(e):k,A=["d3Zoom","d3Selection","d3ZoomHandler","viewportRef","vueFlowRef","dimensions","hooks"];Ge(C.defaultEdgeOptions)&&(e.defaultEdgeOptions=C.defaultEdgeOptions);const x=C.modelValue||C.nodes||C.edges?[]:void 0;x&&(C.modelValue&&x.push(...C.modelValue),C.nodes&&x.push(...C.nodes),C.edges&&x.push(...C.edges),T(x));const U=()=>{Ge(C.maxZoom)&&N(C.maxZoom),Ge(C.minZoom)&&v(C.minZoom),Ge(C.translateExtent)&&E(C.translateExtent)};for(const V of Object.keys(C)){const J=V,$=C[J];![...eA,...A].includes(J)&&Ge($)&&(e[J]=$)}qa(()=>e.d3Zoom).not.toBeNull().then(U),e.initialized||(e.initialized=!0)};return{updateNodePositions:f,updateNodeDimensions:p,setElements:T,setNodes:j,setEdges:G,addNodes:Y,addEdges:I,removeNodes:M,removeEdges:R,findNode:d,findEdge:u,updateEdge:te,updateEdgeData:z,updateNode:F,updateNodeData:Z,applyEdgeChanges:L,applyNodeChanges:H,addSelectedElements:g,addSelectedNodes:h,addSelectedEdges:y,setMinZoom:v,setMaxZoom:N,setTranslateExtent:E,setNodeExtent:S,setPaneClickDistance:P,removeSelectedElements:b,removeSelectedNodes:_,removeSelectedEdges:w,startConnection:Q,updateConnection:W,endConnection:ie,setInteractive:B,setState:re,getIntersectingNodes:me,getIncomers:a,getOutgoers:l,getConnectedEdges:s,getHandleConnections:c,isNodeIntersecting:ge,panBy:ne,fitView:k=>r.value.fitView(k),zoomIn:k=>r.value.zoomIn(k),zoomOut:k=>r.value.zoomOut(k),zoomTo:(k,C)=>r.value.zoomTo(k,C),setViewport:(k,C)=>r.value.setViewport(k,C),setTransform:(k,C)=>r.value.setTransform(k,C),getViewport:()=>r.value.getViewport(),getTransform:()=>r.value.getTransform(),setCenter:(k,C,A)=>r.value.setCenter(k,C,A),fitBounds:(k,C)=>r.value.fitBounds(k,C),project:k=>r.value.project(k),screenToFlowCoordinate:k=>r.value.screenToFlowCoordinate(k),flowToScreenCoordinate:k=>r.value.flowToScreenCoordinate(k),toObject:()=>{const k=[],C=[];for(const A of e.nodes){const{computedPosition:x,handleBounds:U,selected:V,dimensions:J,isParent:$,resizing:X,dragging:D,events:pe,...le}=A;k.push(le)}for(const A of e.edges){const{selected:x,sourceNode:U,targetNode:V,events:J,...$}=A;C.push($)}return JSON.parse(JSON.stringify({nodes:k,edges:C,position:[e.viewport.x,e.viewport.y],zoom:e.viewport.zoom,viewport:e.viewport}))},fromObject:k=>new Promise(C=>{const{nodes:A,edges:x,position:U,zoom:V,viewport:J}=k;if(A&&j(A),x&&G(x),J!=null&&J.x&&(J!=null&&J.y)||U){const $=(J==null?void 0:J.x)||U[0],X=(J==null?void 0:J.y)||U[1],D=(J==null?void 0:J.zoom)||V||e.viewport.zoom;return qa(()=>r.value.viewportInitialized).toBe(!0).then(()=>{r.value.setViewport({x:$,y:X,zoom:D}).then(()=>{C(!0)})})}else C(!0)}),updateNodeInternals:i,viewportHelper:r,$reset:()=>{const k=jf();if(e.edges=[],e.nodes=[],e.d3Zoom&&e.d3Selection){const C=Wn.translate(k.defaultViewport.x??0,k.defaultViewport.y??0).scale(bn(k.defaultViewport.zoom??1,k.minZoom,k.maxZoom)),A=e.viewportRef.getBoundingClientRect(),x=[[0,0],[A.width,A.height]],U=e.d3Zoom.constrain()(C,x,k.translateExtent);e.d3Zoom.transform(e.d3Selection,U)}re(k)},$destroy:()=>{}}}const nA=["data-id","data-handleid","data-nodeid","data-handlepos"],oA={name:"Handle",compatConfig:{MODE:3}},tn=t.defineComponent({...oA,props:{id:{default:null},type:{},position:{default:()=>ye.Top},isValidConnection:{type:Function},connectable:{type:[Boolean,Number,String,Function],default:void 0},connectableStart:{type:Boolean,default:!0},connectableEnd:{type:Boolean,default:!0}},setup(e,{expose:n}){const o=t.createPropsRestProxy(e,["position","connectable","connectableStart","connectableEnd","id"]),r=t.toRef(()=>o.type??"source"),i=t.toRef(()=>o.isValidConnection??null),{id:a,connectionStartHandle:l,connectionClickStartHandle:s,connectionEndHandle:c,vueFlowRef:d,nodesConnectable:u,noDragClassName:f,noPanClassName:p}=Oe(),{id:m,node:h,nodeEl:y,connectedEdges:g}=Uf(),_=t.ref(),w=t.toRef(()=>typeof e.connectableStart<"u"?e.connectableStart:!0),b=t.toRef(()=>typeof e.connectableEnd<"u"?e.connectableEnd:!0),v=t.toRef(()=>{var G,T,Y,I,M,R;return((G=l.value)==null?void 0:G.nodeId)===m&&((T=l.value)==null?void 0:T.id)===e.id&&((Y=l.value)==null?void 0:Y.type)===r.value||((I=c.value)==null?void 0:I.nodeId)===m&&((M=c.value)==null?void 0:M.id)===e.id&&((R=c.value)==null?void 0:R.type)===r.value}),N=t.toRef(()=>{var G,T,Y;return((G=s.value)==null?void 0:G.nodeId)===m&&((T=s.value)==null?void 0:T.id)===e.id&&((Y=s.value)==null?void 0:Y.type)===r.value}),{handlePointerDown:E,handleClick:S}=Ff({nodeId:m,handleId:e.id,isValidConnection:i,type:r}),P=t.computed(()=>typeof e.connectable=="string"&&e.connectable==="single"?!g.value.some(G=>{const T=G[`${r.value}Handle`];return G[r.value]!==m?!1:T?T===e.id:!0}):typeof e.connectable=="number"?g.value.filter(G=>{const T=G[`${r.value}Handle`];return G[r.value]!==m?!1:T?T===e.id:!0}).length<e.connectable:typeof e.connectable=="function"?e.connectable(h,g.value):Ge(e.connectable)?e.connectable:u.value);t.onMounted(()=>{var G;if(!h.dimensions.width||!h.dimensions.height)return;const T=(G=h.handleBounds[r.value])==null?void 0:G.find(H=>H.id===e.id);if(!d.value||T)return;const Y=d.value.querySelector(".vue-flow__transformationpane");if(!y.value||!_.value||!Y||!e.id)return;const I=y.value.getBoundingClientRect(),M=_.value.getBoundingClientRect(),R=window.getComputedStyle(Y),{m22:te}=new window.DOMMatrixReadOnly(R.transform),z={id:e.id,position:e.position,x:(M.left-I.left)/te,y:(M.top-I.top)/te,type:r.value,nodeId:m,...si(_.value)};h.handleBounds[r.value]=[...h.handleBounds[r.value]??[],z]});function B(G){const T=_l(G);P.value&&w.value&&(T&&G.button===0||!T)&&E(G)}function j(G){!m||!s.value&&!w.value||P.value&&S(G)}return n({handleClick:S,handlePointerDown:E,onClick:j,onPointerDown:B}),(G,T)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"handle",ref:_,"data-id":`${t.unref(a)}-${t.unref(m)}-${e.id}-${r.value}`,"data-handleid":e.id,"data-nodeid":t.unref(m),"data-handlepos":G.position,class:t.normalizeClass(["vue-flow__handle",[`vue-flow__handle-${G.position}`,`vue-flow__handle-${e.id}`,t.unref(f),t.unref(p),r.value,{connectable:P.value,connecting:N.value,connectablestart:w.value,connectableend:b.value,connectionindicator:P.value&&(w.value&&!v.value||b.value&&v.value)}]]),onMousedown:B,onTouchstartPassive:B,onClick:j},[t.renderSlot(G.$slots,"default",{id:G.id})],42,nA))}}),gi=function({sourcePosition:e=ye.Bottom,targetPosition:n=ye.Top,label:o,connectable:r=!0,isValidTargetPos:i,isValidSourcePos:a,data:l}){const s=l.label??o;return[t.h(tn,{type:"target",position:n,connectable:r,isValidConnection:i}),typeof s!="string"&&s?t.h(s):t.h(t.Fragment,[s]),t.h(tn,{type:"source",position:e,connectable:r,isValidConnection:a})]};gi.props=["sourcePosition","targetPosition","label","isValidTargetPos","isValidSourcePos","connectable","data"],gi.inheritAttrs=!1,gi.compatConfig={MODE:3};const rA=gi,hi=function({targetPosition:e=ye.Top,label:n,connectable:o=!0,isValidTargetPos:r,data:i}){const a=i.label??n;return[t.h(tn,{type:"target",position:e,connectable:o,isValidConnection:r}),typeof a!="string"&&a?t.h(a):t.h(t.Fragment,[a])]};hi.props=["targetPosition","label","isValidTargetPos","connectable","data"],hi.inheritAttrs=!1,hi.compatConfig={MODE:3};const iA=hi,yi=function({sourcePosition:e=ye.Bottom,label:n,connectable:o=!0,isValidSourcePos:r,data:i}){const a=i.label??n;return[typeof a!="string"&&a?t.h(a):t.h(t.Fragment,[a]),t.h(tn,{type:"source",position:e,connectable:o,isValidConnection:r})]};yi.props=["sourcePosition","label","isValidSourcePos","connectable","data"],yi.inheritAttrs=!1,yi.compatConfig={MODE:3};const aA=yi,lA=["transform"],sA=["width","height","x","y","rx","ry"],cA=["y"],dA={name:"EdgeText",compatConfig:{MODE:3}},uA=t.defineComponent({...dA,props:{x:{},y:{},label:{},labelStyle:{default:()=>({})},labelShowBg:{type:Boolean,default:!0},labelBgStyle:{default:()=>({})},labelBgPadding:{default:()=>[2,4]},labelBgBorderRadius:{default:2}},setup(e){const n=t.ref({x:0,y:0,width:0,height:0}),o=t.ref(null),r=t.computed(()=>`translate(${e.x-n.value.width/2} ${e.y-n.value.height/2})`);t.onMounted(i),t.watch([()=>e.x,()=>e.y,o,()=>e.label],i);function i(){if(!o.value)return;const a=o.value.getBBox();(a.width!==n.value.width||a.height!==n.value.height)&&(n.value=a)}return(a,l)=>(t.openBlock(),t.createElementBlock("g",{transform:r.value,class:"vue-flow__edge-textwrapper"},[a.labelShowBg?(t.openBlock(),t.createElementBlock("rect",{key:0,class:"vue-flow__edge-textbg",width:`${n.value.width+2*a.labelBgPadding[0]}px`,height:`${n.value.height+2*a.labelBgPadding[1]}px`,x:-a.labelBgPadding[0],y:-a.labelBgPadding[1],style:t.normalizeStyle(a.labelBgStyle),rx:a.labelBgBorderRadius,ry:a.labelBgBorderRadius},null,12,sA)):t.createCommentVNode("",!0),t.createElementVNode("text",t.mergeProps(a.$attrs,{ref_key:"el",ref:o,class:"vue-flow__edge-text",y:n.value.height/2,dy:"0.3em",style:a.labelStyle}),[t.renderSlot(a.$slots,"default",{},()=>[typeof a.label!="string"?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(a.label),{key:0})):(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[t.createTextVNode(t.toDisplayString(a.label),1)],64))])],16,cA)],8,lA))}}),fA=["id","d","marker-end","marker-start"],pA=["d","stroke-width"],mA={name:"BaseEdge",inheritAttrs:!1,compatConfig:{MODE:3}},_i=t.defineComponent({...mA,props:{id:{},labelX:{},labelY:{},path:{},label:{},markerStart:{},markerEnd:{},interactionWidth:{default:20},labelStyle:{},labelShowBg:{type:Boolean},labelBgStyle:{},labelBgPadding:{},labelBgBorderRadius:{}},setup(e,{expose:n}){const o=t.ref(null),r=t.ref(null),i=t.ref(null),a=t.useAttrs();return n({pathEl:o,interactionEl:r,labelEl:i}),(l,s)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[t.createElementVNode("path",t.mergeProps(t.unref(a),{id:l.id,ref_key:"pathEl",ref:o,d:l.path,class:"vue-flow__edge-path","marker-end":l.markerEnd,"marker-start":l.markerStart}),null,16,fA),l.interactionWidth?(t.openBlock(),t.createElementBlock("path",{key:0,ref_key:"interactionEl",ref:r,fill:"none",d:l.path,"stroke-width":l.interactionWidth,"stroke-opacity":0,class:"vue-flow__edge-interaction"},null,8,pA)):t.createCommentVNode("",!0),l.label&&l.labelX&&l.labelY?(t.openBlock(),t.createBlock(uA,{key:1,ref_key:"labelEl",ref:i,x:l.labelX,y:l.labelY,label:l.label,"label-show-bg":l.labelShowBg,"label-bg-style":l.labelBgStyle,"label-bg-padding":l.labelBgPadding,"label-bg-border-radius":l.labelBgBorderRadius,"label-style":l.labelStyle},null,8,["x","y","label","label-show-bg","label-bg-style","label-bg-padding","label-bg-border-radius","label-style"])):t.createCommentVNode("",!0)],64))}});function Gf({sourceX:e,sourceY:n,targetX:o,targetY:r}){const i=Math.abs(o-e)/2,a=o<e?o+i:o-i,l=Math.abs(r-n)/2,s=r<n?r+l:r-l;return[a,s,i,l]}function qf({sourceX:e,sourceY:n,targetX:o,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:l,targetControlY:s}){const c=e*.125+i*.375+l*.375+o*.125,d=n*.125+a*.375+s*.375+r*.125,u=Math.abs(c-e),f=Math.abs(d-n);return[c,d,u,f]}function bi(e,n){return e>=0?.5*e:n*25*Math.sqrt(-e)}function zf({pos:e,x1:n,y1:o,x2:r,y2:i,c:a}){let l,s;switch(e){case ye.Left:l=n-bi(n-r,a),s=o;break;case ye.Right:l=n+bi(r-n,a),s=o;break;case ye.Top:l=n,s=o-bi(o-i,a);break;case ye.Bottom:l=n,s=o+bi(i-o,a);break}return[l,s]}function Hf(e){const{sourceX:n,sourceY:o,sourcePosition:r=ye.Bottom,targetX:i,targetY:a,targetPosition:l=ye.Top,curvature:s=.25}=e,[c,d]=zf({pos:r,x1:n,y1:o,x2:i,y2:a,c:s}),[u,f]=zf({pos:l,x1:i,y1:a,x2:n,y2:o,c:s}),[p,m,h,y]=qf({sourceX:n,sourceY:o,targetX:i,targetY:a,sourceControlX:c,sourceControlY:d,targetControlX:u,targetControlY:f});return[`M${n},${o} C${c},${d} ${u},${f} ${i},${a}`,p,m,h,y]}function Yf({pos:e,x1:n,y1:o,x2:r,y2:i}){let a,l;switch(e){case ye.Left:case ye.Right:a=.5*(n+r),l=o;break;case ye.Top:case ye.Bottom:a=n,l=.5*(o+i);break}return[a,l]}function Wf(e){const{sourceX:n,sourceY:o,sourcePosition:r=ye.Bottom,targetX:i,targetY:a,targetPosition:l=ye.Top}=e,[s,c]=Yf({pos:r,x1:n,y1:o,x2:i,y2:a}),[d,u]=Yf({pos:l,x1:i,y1:a,x2:n,y2:o}),[f,p,m,h]=qf({sourceX:n,sourceY:o,targetX:i,targetY:a,sourceControlX:s,sourceControlY:c,targetControlX:d,targetControlY:u});return[`M${n},${o} C${s},${c} ${d},${u} ${i},${a}`,f,p,m,h]}const Xf={[ye.Left]:{x:-1,y:0},[ye.Right]:{x:1,y:0},[ye.Top]:{x:0,y:-1},[ye.Bottom]:{x:0,y:1}};function gA({source:e,sourcePosition:n=ye.Bottom,target:o}){return n===ye.Left||n===ye.Right?e.x<o.x?{x:1,y:0}:{x:-1,y:0}:e.y<o.y?{x:0,y:1}:{x:0,y:-1}}function Zf(e,n){return Math.sqrt((n.x-e.x)**2+(n.y-e.y)**2)}function hA({source:e,sourcePosition:n=ye.Bottom,target:o,targetPosition:r=ye.Top,center:i,offset:a}){const l=Xf[n],s=Xf[r],c={x:e.x+l.x*a,y:e.y+l.y*a},d={x:o.x+s.x*a,y:o.y+s.y*a},u=gA({source:c,sourcePosition:n,target:d}),f=u.x!==0?"x":"y",p=u[f];let m,h,y;const g={x:0,y:0},_={x:0,y:0},[w,b,v,N]=Gf({sourceX:e.x,sourceY:e.y,targetX:o.x,targetY:o.y});if(l[f]*s[f]===-1){h=i.x??w,y=i.y??b;const S=[{x:h,y:c.y},{x:h,y:d.y}],P=[{x:c.x,y},{x:d.x,y}];l[f]===p?m=f==="x"?S:P:m=f==="x"?P:S}else{const S=[{x:c.x,y:d.y}],P=[{x:d.x,y:c.y}];if(f==="x"?m=l.x===p?P:S:m=l.y===p?S:P,n===r){const Y=Math.abs(e[f]-o[f]);if(Y<=a){const I=Math.min(a-1,a-Y);l[f]===p?g[f]=(c[f]>e[f]?-1:1)*I:_[f]=(d[f]>o[f]?-1:1)*I}}if(n!==r){const Y=f==="x"?"y":"x",I=l[f]===s[Y],M=c[Y]>d[Y],R=c[Y]<d[Y];(l[f]===1&&(!I&&M||I&&R)||l[f]!==1&&(!I&&R||I&&M))&&(m=f==="x"?S:P)}const B={x:c.x+g.x,y:c.y+g.y},j={x:d.x+_.x,y:d.y+_.y},G=Math.max(Math.abs(B.x-m[0].x),Math.abs(j.x-m[0].x)),T=Math.max(Math.abs(B.y-m[0].y),Math.abs(j.y-m[0].y));G>=T?(h=(B.x+j.x)/2,y=m[0].y):(h=m[0].x,y=(B.y+j.y)/2)}return[[e,{x:c.x+g.x,y:c.y+g.y},...m,{x:d.x+_.x,y:d.y+_.y},o],h,y,v,N]}function yA(e,n,o,r){const i=Math.min(Zf(e,n)/2,Zf(n,o)/2,r),{x:a,y:l}=n;if(e.x===a&&a===o.x||e.y===l&&l===o.y)return`L${a} ${l}`;if(e.y===l){const d=e.x<o.x?-1:1,u=e.y<o.y?1:-1;return`L ${a+i*d},${l}Q ${a},${l} ${a},${l+i*u}`}const s=e.x<o.x?1:-1,c=e.y<o.y?-1:1;return`L ${a},${l+i*c}Q ${a},${l} ${a+i*s},${l}`}function Sl(e){const{sourceX:n,sourceY:o,sourcePosition:r=ye.Bottom,targetX:i,targetY:a,targetPosition:l=ye.Top,borderRadius:s=5,centerX:c,centerY:d,offset:u=20}=e,[f,p,m,h,y]=hA({source:{x:n,y:o},sourcePosition:r,target:{x:i,y:a},targetPosition:l,center:{x:c,y:d},offset:u});return[f.reduce((_,w,b)=>{let v;return b>0&&b<f.length-1?v=yA(f[b-1],w,f[b+1],s):v=`${b===0?"M":"L"}${w.x} ${w.y}`,_+=v,_},""),p,m,h,y]}function _A(e){const{sourceX:n,sourceY:o,targetX:r,targetY:i}=e,[a,l,s,c]=Gf({sourceX:n,sourceY:o,targetX:r,targetY:i});return[`M ${n},${o}L ${r},${i}`,a,l,s,c]}const bA=t.defineComponent({name:"StraightEdge",props:["label","labelStyle","labelShowBg","labelBgStyle","labelBgPadding","labelBgBorderRadius","sourceY","sourceX","targetX","targetY","markerEnd","markerStart","interactionWidth"],compatConfig:{MODE:3},setup(e,{attrs:n}){return()=>{const[o,r,i]=_A(e);return t.h(_i,{path:o,labelX:r,labelY:i,...n,...e})}}}),Jf=t.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(e,{attrs:n}){return()=>{const[o,r,i]=Sl({...e,sourcePosition:e.sourcePosition??ye.Bottom,targetPosition:e.targetPosition??ye.Top});return t.h(_i,{path:o,labelX:r,labelY:i,...n,...e})}}}),wA=t.defineComponent({name:"StepEdge",props:["sourcePosition","targetPosition","label","labelStyle","labelShowBg","labelBgStyle","labelBgPadding","labelBgBorderRadius","sourceY","sourceX","targetX","targetY","markerEnd","markerStart","interactionWidth"],setup(e,{attrs:n}){return()=>t.h(Jf,{...e,...n,borderRadius:0})}}),kA=t.defineComponent({name:"BezierEdge",props:["sourcePosition","targetPosition","label","labelStyle","labelShowBg","labelBgStyle","labelBgPadding","labelBgBorderRadius","sourceY","sourceX","targetX","targetY","curvature","markerEnd","markerStart","interactionWidth"],compatConfig:{MODE:3},setup(e,{attrs:n}){return()=>{const[o,r,i]=Hf({...e,sourcePosition:e.sourcePosition??ye.Bottom,targetPosition:e.targetPosition??ye.Top});return t.h(_i,{path:o,labelX:r,labelY:i,...n,...e})}}}),EA=t.defineComponent({name:"SimpleBezierEdge",props:["sourcePosition","targetPosition","label","labelStyle","labelShowBg","labelBgStyle","labelBgPadding","labelBgBorderRadius","sourceY","sourceX","targetX","targetY","markerEnd","markerStart","interactionWidth"],compatConfig:{MODE:3},setup(e,{attrs:n}){return()=>{const[o,r,i]=Wf({...e,sourcePosition:e.sourcePosition??ye.Bottom,targetPosition:e.targetPosition??ye.Top});return t.h(_i,{path:o,labelX:r,labelY:i,...n,...e})}}}),CA={input:aA,default:rA,output:iA},NA={default:kA,straight:bA,step:wA,smoothstep:Jf,simplebezier:EA};function vA(e,n,o){const r=t.computed(()=>y=>n.value.get(y)),i=t.computed(()=>y=>o.value.get(y)),a=t.computed(()=>{const y={...NA,...e.edgeTypes},g=Object.keys(y);for(const _ of e.edges)_.type&&!g.includes(_.type)&&(y[_.type]=_.type);return y}),l=t.computed(()=>{const y={...CA,...e.nodeTypes},g=Object.keys(y);for(const _ of e.nodes)_.type&&!g.includes(_.type)&&(y[_.type]=_.type);return y}),s=t.computed(()=>e.onlyRenderVisibleElements?gf(e.nodes,{x:0,y:0,width:e.dimensions.width,height:e.dimensions.height},e.viewport,!0):e.nodes),c=t.computed(()=>{if(e.onlyRenderVisibleElements){const y=[];for(const g of e.edges){const _=n.value.get(g.source),w=n.value.get(g.target);Sx({sourcePos:_.computedPosition||{x:0,y:0},targetPos:w.computedPosition||{x:0,y:0},sourceWidth:_.dimensions.width,sourceHeight:_.dimensions.height,targetWidth:w.dimensions.width,targetHeight:w.dimensions.height,width:e.dimensions.width,height:e.dimensions.height,viewport:e.viewport})&&y.push(g)}return y}return e.edges}),d=t.computed(()=>[...s.value,...c.value]),u=t.computed(()=>{const y=[];for(const g of e.nodes)g.selected&&y.push(g);return y}),f=t.computed(()=>{const y=[];for(const g of e.edges)g.selected&&y.push(g);return y}),p=t.computed(()=>[...u.value,...f.value]),m=t.computed(()=>{const y=[];for(const g of e.nodes)g.dimensions.width&&g.dimensions.height&&g.handleBounds!==void 0&&y.push(g);return y}),h=t.computed(()=>s.value.length>0&&m.value.length===s.value.length);return{getNode:r,getEdge:i,getElements:d,getEdgeTypes:a,getNodeTypes:l,getEdges:c,getNodes:s,getSelectedElements:p,getSelectedNodes:u,getSelectedEdges:f,getNodesInitialized:m,areNodesInitialized:h}}class kn{constructor(){this.currentId=0,this.flows=new Map}static getInstance(){var n;const o=(n=t.getCurrentInstance())==null?void 0:n.appContext.app,r=(o==null?void 0:o.config.globalProperties.$vueFlowStorage)??kn.instance;return kn.instance=r??new kn,o&&(o.config.globalProperties.$vueFlowStorage=kn.instance),kn.instance}set(n,o){return this.flows.set(n,o)}get(n){return this.flows.get(n)}remove(n){return this.flows.delete(n)}create(n,o){const r=jf(),i=t.reactive(r),a={};for(const[p,m]of Object.entries(i.hooks)){const h=`on${p.charAt(0).toUpperCase()+p.slice(1)}`;a[h]=m.on}const l={};for(const[p,m]of Object.entries(i.hooks))l[p]=m.trigger;const s=t.computed(()=>{const p=new Map;for(const m of i.nodes)p.set(m.id,m);return p}),c=t.computed(()=>{const p=new Map;for(const m of i.edges)p.set(m.id,m);return p}),d=vA(i,s,c),u=tA(i,s,c);u.setState({...i,...o});const f={...a,...d,...u,...CN(i),nodeLookup:s,edgeLookup:c,emits:l,id:n,vueFlowVersion:"1.45.0",$destroy:()=>{this.remove(n)}};return this.set(n,f),f}getId(){return`vue-flow-${this.currentId++}`}}function Oe(e){const n=kn.getInstance(),o=t.getCurrentScope(),r=typeof e=="object",i=r?e:{id:e},a=i.id,l=a??(o==null?void 0:o.vueFlowId);let s;if(o){const c=t.inject(Rf,null);typeof c<"u"&&c!==null&&(!l||c.id===l)&&(s=c)}if(s||l&&(s=n.get(l)),!s||l&&s.id!==l){const c=a??n.getId(),d=n.create(c,i);s=d,(o??t.effectScope(!0)).run(()=>{t.watch(d.applyDefault,(f,p,m)=>{const h=g=>{d.applyNodeChanges(g)},y=g=>{d.applyEdgeChanges(g)};f?(d.onNodesChange(h),d.onEdgesChange(y)):(d.hooks.value.nodesChange.off(h),d.hooks.value.edgesChange.off(y)),m(()=>{d.hooks.value.nodesChange.off(h),d.hooks.value.edgesChange.off(y)})},{immediate:!0}),Dr(()=>{if(s){const f=n.get(s.id);f?f.$destroy():fi(`No store instance found for id ${s.id} in storage.`)}})})}else r&&s.setState(i);if(o&&(t.provide(Rf,s),o.vueFlowId=s.id),r){const c=t.getCurrentInstance();(c==null?void 0:c.type.name)!=="VueFlow"&&s.emits.error(new We(je.USEVUEFLOW_OPTIONS))}return s}function SA(e){const{emits:n,dimensions:o}=Oe();let r;t.onMounted(()=>{const i=e.value,a=()=>{if(!i)return;const l=si(i);(l.width===0||l.height===0)&&n.error(new We(je.MISSING_VIEWPORT_DIMENSIONS)),o.value={width:l.width||500,height:l.height||500}};a(),window.addEventListener("resize",a),i&&(r=new ResizeObserver(()=>a()),r.observe(i)),t.onBeforeUnmount(()=>{window.removeEventListener("resize",a),r&&i&&r.unobserve(i)})})}const xA={name:"UserSelection",compatConfig:{MODE:3}},AA=t.defineComponent({...xA,props:{userSelectionRect:{}},setup(e){return(n,o)=>(t.openBlock(),t.createElementBlock("div",{class:"vue-flow__selection vue-flow__container",style:t.normalizeStyle({width:`${n.userSelectionRect.width}px`,height:`${n.userSelectionRect.height}px`,transform:`translate(${n.userSelectionRect.x}px, ${n.userSelectionRect.y}px)`})},null,4))}}),IA=["tabIndex"],PA={name:"NodesSelection",compatConfig:{MODE:3}},TA=t.defineComponent({...PA,setup(e){const{emits:n,viewport:o,getSelectedNodes:r,noPanClassName:i,disableKeyboardA11y:a,userSelectionActive:l}=Oe(),s=Kf(),c=t.ref(null),d=Lf({el:c,onStart(h){n.selectionDragStart(h)},onDrag(h){n.selectionDrag(h)},onStop(h){n.selectionDragStop(h)}});t.onMounted(()=>{var h;a.value||(h=c.value)==null||h.focus({preventScroll:!0})});const u=t.computed(()=>mf(r.value)),f=t.computed(()=>({width:`${u.value.width}px`,height:`${u.value.height}px`,top:`${u.value.y}px`,left:`${u.value.x}px`}));function p(h){n.selectionContextMenu({event:h,nodes:r.value})}function m(h){a||Xn[h.key]&&(h.preventDefault(),s({x:Xn[h.key].x,y:Xn[h.key].y},h.shiftKey))}return(h,y)=>!t.unref(l)&&u.value.width&&u.value.height?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["vue-flow__nodesselection vue-flow__container",t.unref(i)]),style:t.normalizeStyle({transform:`translate(${t.unref(o).x}px,${t.unref(o).y}px) scale(${t.unref(o).zoom})`})},[t.createElementVNode("div",{ref_key:"el",ref:c,class:t.normalizeClass([{dragging:t.unref(d)},"vue-flow__nodesselection-rect"]),style:t.normalizeStyle(f.value),tabIndex:t.unref(a)?void 0:-1,onContextmenu:p,onKeydown:m},null,46,IA)],6)):t.createCommentVNode("",!0)}});function OA(e,n){return{x:e.clientX-n.left,y:e.clientY-n.top}}const $A={name:"Pane",compatConfig:{MODE:3}},BA=t.defineComponent({...$A,props:{isSelecting:{type:Boolean},selectionKeyPressed:{type:Boolean}},setup(e){const{vueFlowRef:n,nodes:o,viewport:r,emits:i,userSelectionActive:a,removeSelectedElements:l,userSelectionRect:s,elementsSelectable:c,nodesSelectionActive:d,getSelectedEdges:u,getSelectedNodes:f,removeNodes:p,removeEdges:m,selectionMode:h,deleteKeyCode:y,multiSelectionKeyCode:g,multiSelectionActive:_,edgeLookup:w,nodeLookup:b,connectionLookup:v,defaultEdgeOptions:N,connectionStartHandle:E}=Oe(),S=t.ref(null),P=t.ref(new Set),B=t.ref(new Set),j=t.ref(),G=t.toRef(()=>c.value&&(e.isSelecting||a.value)),T=t.toRef(()=>E.value!==null);let Y=!1,I=!1;const M=Fo(y,{actInsideInputWithModifier:!1}),R=Fo(g);t.watch(M,W=>{W&&(p(f.value),m(u.value),d.value=!1)}),t.watch(R,W=>{_.value=W});function te(W,ie){return ae=>{ae.target===ie&&(W==null||W(ae))}}function z(W){if(Y||T.value){Y=!1;return}i.paneClick(W),l(),d.value=!1}function H(W){W.preventDefault(),W.stopPropagation(),i.paneContextMenu(W)}function L(W){i.paneScroll(W)}function F(W){var ie,ae,me;if(j.value=(ie=n.value)==null?void 0:ie.getBoundingClientRect(),!c.value||!e.isSelecting||W.button!==0||W.target!==S.value||!j.value)return;(me=(ae=W.target)==null?void 0:ae.setPointerCapture)==null||me.call(ae,W.pointerId);const{x:ge,y:ne}=OA(W,j.value);I=!0,Y=!1,l(),s.value={width:0,height:0,startX:ge,startY:ne,x:ge,y:ne},i.selectionStart(W)}function Z(W){var ie;if(!j.value||!s.value)return;Y=!0;const{x:ae,y:me}=Tt(W,j.value),{startX:ge=0,startY:ne=0}=s.value,re={startX:ge,startY:ne,x:ae<ge?ae:ge,y:me<ne?me:ne,width:Math.abs(ae-ge),height:Math.abs(me-ne)},q=P.value,ee=B.value;P.value=new Set(gf(o.value,re,r.value,h.value===fl.Partial,!0).map(k=>k.id)),B.value=new Set;const O=((ie=N.value)==null?void 0:ie.selectable)??!0;for(const k of P.value){const C=v.value.get(k);if(C)for(const{edgeId:A}of C.values()){const x=w.value.get(A);x&&(x.selectable??O)&&B.value.add(A)}}if(!Vf(q,P.value)){const k=Qt(b.value,P.value,!0);i.nodesChange(k)}if(!Vf(ee,B.value)){const k=Qt(w.value,B.value);i.edgesChange(k)}s.value=re,a.value=!0,d.value=!1}function Q(W){var ie;W.button!==0||!I||((ie=W.target)==null||ie.releasePointerCapture(W.pointerId),!a.value&&s.value&&W.target===S.value&&z(W),a.value=!1,s.value=null,d.value=P.value.size>0,i.selectionEnd(W),e.selectionKeyPressed&&(Y=!1),I=!1)}return(W,ie)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"container",ref:S,class:t.normalizeClass(["vue-flow__pane vue-flow__container",{selection:W.isSelecting}]),onClick:ie[0]||(ie[0]=ae=>G.value?void 0:te(z,S.value)(ae)),onContextmenu:ie[1]||(ie[1]=ae=>te(H,S.value)(ae)),onWheelPassive:ie[2]||(ie[2]=ae=>te(L,S.value)(ae)),onPointerenter:ie[3]||(ie[3]=ae=>G.value?void 0:t.unref(i).paneMouseEnter(ae)),onPointerdown:ie[4]||(ie[4]=ae=>G.value?F(ae):t.unref(i).paneMouseMove(ae)),onPointermove:ie[5]||(ie[5]=ae=>G.value?Z(ae):t.unref(i).paneMouseMove(ae)),onPointerup:ie[6]||(ie[6]=ae=>G.value?Q(ae):void 0),onPointerleave:ie[7]||(ie[7]=ae=>t.unref(i).paneMouseLeave(ae))},[t.renderSlot(W.$slots,"default"),t.unref(a)&&t.unref(s)?(t.openBlock(),t.createBlock(AA,{key:0,"user-selection-rect":t.unref(s)},null,8,["user-selection-rect"])):t.createCommentVNode("",!0),t.unref(d)&&t.unref(f).length?(t.openBlock(),t.createBlock(TA,{key:1})):t.createCommentVNode("",!0)],34))}}),VA={name:"Transform",compatConfig:{MODE:3}},RA=t.defineComponent({...VA,setup(e){const{viewport:n,fitViewOnInit:o,fitViewOnInitDone:r}=Oe(),i=t.computed(()=>o.value?!r.value:!1),a=t.computed(()=>`translate(${n.value.x}px,${n.value.y}px) scale(${n.value.zoom})`);return(l,s)=>(t.openBlock(),t.createElementBlock("div",{class:"vue-flow__transformationpane vue-flow__container",style:t.normalizeStyle({transform:a.value,opacity:i.value?0:void 0})},[t.renderSlot(l.$slots,"default")],4))}}),DA={name:"Viewport",compatConfig:{MODE:3}},MA=t.defineComponent({...DA,setup(e){const{minZoom:n,maxZoom:o,defaultViewport:r,translateExtent:i,zoomActivationKeyCode:a,selectionKeyCode:l,panActivationKeyCode:s,panOnScroll:c,panOnScrollMode:d,panOnScrollSpeed:u,panOnDrag:f,zoomOnDoubleClick:p,zoomOnPinch:m,zoomOnScroll:h,preventScrolling:y,noWheelClassName:g,noPanClassName:_,emits:w,connectionStartHandle:b,userSelectionActive:v,paneDragging:N,d3Zoom:E,d3Selection:S,d3ZoomHandler:P,viewport:B,viewportRef:j,paneClickDistance:G}=Oe();SA(j);const T=t.shallowRef(!1),Y=t.shallowRef(!1);let I=null,M=!1,R=0,te={x:0,y:0,zoom:0};const z=Fo(s),H=Fo(l),L=Fo(a),F=t.toRef(()=>(!H.value||H.value&&l.value===!0)&&(z.value||f.value)),Z=t.toRef(()=>z.value||c.value),Q=t.toRef(()=>H.value||l.value===!0&&F.value!==!0);t.onMounted(()=>{if(!j.value){fi("Viewport element is missing");return}const ne=j.value,re=ne.getBoundingClientRect(),q=lx().clickDistance(G.value).scaleExtent([n.value,o.value]).translateExtent(i.value),ee=_t(ne).call(q),O=ee.on("wheel.zoom"),k=Wn.translate(r.value.x??0,r.value.y??0).scale(bn(r.value.zoom??1,n.value,o.value)),C=[[0,0],[re.width,re.height]],A=q.constrain()(k,C,i.value);q.transform(ee,A),q.wheelDelta(ie),E.value=q,S.value=ee,P.value=O,B.value={x:A.x,y:A.y,zoom:A.k},q.on("start",x=>{var U;if(!x.sourceEvent)return null;R=x.sourceEvent.button,T.value=!0;const V=me(x.transform);((U=x.sourceEvent)==null?void 0:U.type)==="mousedown"&&(N.value=!0),te=V,w.viewportChangeStart(V),w.moveStart({event:x,flowTransform:V})}),q.on("end",x=>{if(!x.sourceEvent)return null;if(T.value=!1,N.value=!1,W(F.value,R??0)&&!M&&w.paneContextMenu(x.sourceEvent),M=!1,ae(te,x.transform)){const U=me(x.transform);te=U,w.viewportChangeEnd(U),w.moveEnd({event:x,flowTransform:U})}}),q.filter(x=>{var U;const V=L.value||h.value,J=m.value&&x.ctrlKey,$=x.button;if($===1&&x.type==="mousedown"&&(ge(x,"vue-flow__node")||ge(x,"vue-flow__edge")))return!0;if(!F.value&&!V&&!Z.value&&!p.value&&!m.value||v.value||!p.value&&x.type==="dblclick"||ge(x,g.value)&&x.type==="wheel"||ge(x,_.value)&&(x.type!=="wheel"||Z.value&&x.type==="wheel"&&!L.value)||!m.value&&x.ctrlKey&&x.type==="wheel"||!V&&!Z.value&&!J&&x.type==="wheel")return!1;if(!m&&x.type==="touchstart"&&((U=x.touches)==null?void 0:U.length)>1)return x.preventDefault(),!1;if(!F.value&&(x.type==="mousedown"||x.type==="touchstart")||l.value===!0&&Array.isArray(f.value)&&f.value.includes(0)&&$===0||Array.isArray(f.value)&&!f.value.includes($)&&(x.type==="mousedown"||x.type==="touchstart"))return!1;const X=Array.isArray(f.value)&&f.value.includes($)||l.value===!0&&Array.isArray(f.value)&&!f.value.includes(0)||!$||$<=1;return(!x.ctrlKey||z.value||x.type==="wheel")&&X}),t.watch([v,F],()=>{v.value&&!T.value?q.on("zoom",null):v.value||q.on("zoom",x=>{B.value={x:x.transform.x,y:x.transform.y,zoom:x.transform.k};const U=me(x.transform);M=W(F.value,R??0),w.viewportChange(U),w.move({event:x,flowTransform:U})})},{immediate:!0}),t.watch([v,Z,d,L,m,y,g],()=>{Z.value&&!L.value&&!v.value?ee.on("wheel.zoom",x=>{if(ge(x,g.value))return!1;const U=L.value||h.value,V=m.value&&x.ctrlKey;if(!(!y.value||Z.value||U||V))return!1;x.preventDefault(),x.stopImmediatePropagation();const $=ee.property("__zoom").k||1,X=di();if(!z.value&&x.ctrlKey&&m.value&&X){const fe=xt(x),oe=ie(x),be=$*2**oe;q.scaleTo(ee,be,fe,x);return}const D=x.deltaMode===1?20:1;let pe=d.value===Lo.Vertical?0:x.deltaX*D,le=d.value===Lo.Horizontal?0:x.deltaY*D;!X&&x.shiftKey&&d.value!==Lo.Vertical&&!pe&&le&&(pe=le,le=0),q.translateBy(ee,-(pe/$)*u.value,-(le/$)*u.value);const _e=me(ee.property("__zoom"));I&&clearTimeout(I),Y.value?(w.move({event:x,flowTransform:_e}),w.viewportChange(_e),I=setTimeout(()=>{w.moveEnd({event:x,flowTransform:_e}),w.viewportChangeEnd(_e),Y.value=!1},150)):(Y.value=!0,w.moveStart({event:x,flowTransform:_e}),w.viewportChangeStart(_e))},{passive:!1}):typeof O<"u"&&ee.on("wheel.zoom",function(x,U){const V=!y.value&&x.type==="wheel"&&!x.ctrlKey,J=L.value||h.value,$=m.value&&x.ctrlKey;if(!J&&!c.value&&!$&&x.type==="wheel"||V||ge(x,g.value))return null;x.preventDefault(),O.call(this,x,U)},{passive:!1})},{immediate:!0})});function W(ne,re){return re===2&&Array.isArray(ne)&&ne.includes(2)}function ie(ne){const re=ne.ctrlKey&&di()?10:1;return-ne.deltaY*(ne.deltaMode===1?.05:ne.deltaMode?1:.002)*re}function ae(ne,re){return ne.x!==re.x&&!Number.isNaN(re.x)||ne.y!==re.y&&!Number.isNaN(re.y)||ne.zoom!==re.k&&!Number.isNaN(re.k)}function me(ne){return{x:ne.x,y:ne.y,zoom:ne.k}}function ge(ne,re){return ne.target.closest(`.${re}`)}return(ne,re)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"viewportRef",ref:j,class:"vue-flow__viewport vue-flow__container"},[t.createVNode(BA,{"is-selecting":Q.value,"selection-key-pressed":t.unref(H),class:t.normalizeClass({connecting:!!t.unref(b),dragging:t.unref(N),draggable:t.unref(f)===!0||Array.isArray(t.unref(f))&&t.unref(f).includes(0)})},{default:t.withCtx(()=>[t.createVNode(RA,null,{default:t.withCtx(()=>[t.renderSlot(ne.$slots,"default")]),_:3})]),_:3},8,["is-selecting","selection-key-pressed","class"])],512))}}),LA=["id"],FA=["id"],UA=["id"],KA={name:"A11yDescriptions",compatConfig:{MODE:3}},jA=t.defineComponent({...KA,setup(e){const{id:n,disableKeyboardA11y:o,ariaLiveMessage:r}=Oe();return(i,a)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[t.createElementVNode("div",{id:`${t.unref(rf)}-${t.unref(n)}`,style:{display:"none"}}," Press enter or space to select a node. "+t.toDisplayString(t.unref(o)?"":"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,LA),t.createElementVNode("div",{id:`${t.unref(af)}-${t.unref(n)}`,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,FA),t.unref(o)?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("div",{key:0,id:`${t.unref(px)}-${t.unref(n)}`,"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%)"}},t.toDisplayString(t.unref(r)),9,UA))],64))}});function GA(){const e=Oe();t.watch(()=>e.viewportHelper.value.viewportInitialized,n=>{n&&setTimeout(()=>{e.emits.init(e),e.emits.paneReady(e)},1)})}function qA(e,n,o){return o===ye.Left?e-n:o===ye.Right?e+n:e}function zA(e,n,o){return o===ye.Top?e-n:o===ye.Bottom?e+n:e}const xl=function({radius:e=10,centerX:n=0,centerY:o=0,position:r=ye.Top,type:i}){return t.h("circle",{class:`vue-flow__edgeupdater vue-flow__edgeupdater-${i}`,cx:qA(n,e,r),cy:zA(o,e,r),r:e,stroke:"transparent",fill:"transparent"})};xl.props=["radius","centerX","centerY","position","type"],xl.compatConfig={MODE:3};const Qf=xl,HA=t.defineComponent({name:"Edge",compatConfig:{MODE:3},props:["id"],setup(e){const{id:n,addSelectedEdges:o,connectionMode:r,edgeUpdaterRadius:i,emits:a,nodesSelectionActive:l,noPanClassName:s,getEdgeTypes:c,removeSelectedEdges:d,findEdge:u,findNode:f,isValidConnection:p,multiSelectionActive:m,disableKeyboardA11y:h,elementsSelectable:y,edgesUpdatable:g,edgesFocusable:_,hooks:w}=Oe(),b=t.computed(()=>u(e.id)),{emit:v,on:N}=jx(b.value,a),E=t.inject(pi),S=t.getCurrentInstance(),P=t.ref(!1),B=t.ref(!1),j=t.ref(""),G=t.ref(null),T=t.ref("source"),Y=t.ref(null),I=t.toRef(()=>typeof b.value.selectable>"u"?y.value:b.value.selectable),M=t.toRef(()=>typeof b.value.updatable>"u"?g.value:b.value.updatable),R=t.toRef(()=>typeof b.value.focusable>"u"?_.value:b.value.focusable);t.provide(Fx,e.id),t.provide(Ux,Y);const te=t.computed(()=>b.value.class instanceof Function?b.value.class(b.value):b.value.class),z=t.computed(()=>b.value.style instanceof Function?b.value.style(b.value):b.value.style),H=t.computed(()=>{const C=b.value.type||"default",A=E==null?void 0:E[`edge-${C}`];if(A)return A;let x=b.value.template??c.value[C];if(typeof x=="string"&&S){const U=Object.keys(S.appContext.components);U&&U.includes(C)&&(x=t.resolveComponent(C,!1))}return x&&typeof x!="string"?x:(a.error(new We(je.EDGE_TYPE_MISSING,x)),!1)}),{handlePointerDown:L}=Ff({nodeId:j,handleId:G,type:T,isValidConnection:p,edgeUpdaterType:T,onEdgeUpdate:Q,onEdgeUpdateEnd:W});return()=>{const C=f(b.value.source),A=f(b.value.target),x="pathOptions"in b.value?b.value.pathOptions:{};if(!C&&!A)return a.error(new We(je.EDGE_SOURCE_TARGET_MISSING,b.value.id,b.value.source,b.value.target)),null;if(!C)return a.error(new We(je.EDGE_SOURCE_MISSING,b.value.id,b.value.source)),null;if(!A)return a.error(new We(je.EDGE_TARGET_MISSING,b.value.id,b.value.target)),null;if(!b.value||b.value.hidden||C.hidden||A.hidden)return null;let U;r.value===Xt.Strict?U=C.handleBounds.source:U=[...C.handleBounds.source||[],...C.handleBounds.target||[]];const V=xf(U,b.value.sourceHandle);let J;r.value===Xt.Strict?J=A.handleBounds.target:J=[...A.handleBounds.target||[],...A.handleBounds.source||[]];const $=xf(J,b.value.targetHandle),X=(V==null?void 0:V.position)||ye.Bottom,D=($==null?void 0:$.position)||ye.Top,{x:pe,y:le}=Zn(C,V,X),{x:_e,y:fe}=Zn(A,$,D);return b.value.sourceX=pe,b.value.sourceY=le,b.value.targetX=_e,b.value.targetY=fe,t.h("g",{ref:Y,key:e.id,"data-id":e.id,class:["vue-flow__edge",`vue-flow__edge-${H.value===!1?"default":b.value.type||"default"}`,s.value,te.value,{updating:P.value,selected:b.value.selected,animated:b.value.animated,inactive:!I.value&&!w.value.edgeClick.hasListeners()}],tabIndex:R.value?0:void 0,"aria-label":b.value.ariaLabel===null?void 0:b.value.ariaLabel??`Edge from ${b.value.source} to ${b.value.target}`,"aria-describedby":R.value?`${af}-${n}`:void 0,"aria-roledescription":"edge",role:R.value?"group":"img",...b.value.domAttributes,onClick:ae,onContextmenu:me,onDblclick:ge,onMouseenter:ne,onMousemove:re,onMouseleave:q,onKeyDown:R.value?k:void 0},[B.value?null:t.h(H.value===!1?c.value.default:H.value,{id:e.id,sourceNode:C,targetNode:A,source:b.value.source,target:b.value.target,type:b.value.type,updatable:M.value,selected:b.value.selected,animated:b.value.animated,label:b.value.label,labelStyle:b.value.labelStyle,labelShowBg:b.value.labelShowBg,labelBgStyle:b.value.labelBgStyle,labelBgPadding:b.value.labelBgPadding,labelBgBorderRadius:b.value.labelBgBorderRadius,data:b.value.data,events:{...b.value.events,...N},style:z.value,markerStart:`url('#${jo(b.value.markerStart,n)}')`,markerEnd:`url('#${jo(b.value.markerEnd,n)}')`,sourcePosition:X,targetPosition:D,sourceX:pe,sourceY:le,targetX:_e,targetY:fe,sourceHandleId:b.value.sourceHandle,targetHandleId:b.value.targetHandle,interactionWidth:b.value.interactionWidth,...x}),[M.value==="source"||M.value===!0?[t.h("g",{onMousedown:ee,onMouseenter:F,onMouseout:Z},t.h(Qf,{position:X,centerX:pe,centerY:le,radius:i.value,type:"source","data-type":"source"}))]:null,M.value==="target"||M.value===!0?[t.h("g",{onMousedown:O,onMouseenter:F,onMouseout:Z},t.h(Qf,{position:D,centerX:_e,centerY:fe,radius:i.value,type:"target","data-type":"target"}))]:null]])};function F(){P.value=!0}function Z(){P.value=!1}function Q(C,A){v.update({event:C,edge:b.value,connection:A})}function W(C){v.updateEnd({event:C,edge:b.value}),B.value=!1}function ie(C,A){C.button===0&&(B.value=!0,j.value=A?b.value.target:b.value.source,G.value=(A?b.value.targetHandle:b.value.sourceHandle)??null,T.value=A?"target":"source",v.updateStart({event:C,edge:b.value}),L(C))}function ae(C){var A;const x={event:C,edge:b.value};I.value&&(l.value=!1,b.value.selected&&m.value?(d([b.value]),(A=Y.value)==null||A.blur()):o([b.value])),v.click(x)}function me(C){v.contextMenu({event:C,edge:b.value})}function ge(C){v.doubleClick({event:C,edge:b.value})}function ne(C){v.mouseEnter({event:C,edge:b.value})}function re(C){v.mouseMove({event:C,edge:b.value})}function q(C){v.mouseLeave({event:C,edge:b.value})}function ee(C){ie(C,!0)}function O(C){ie(C,!1)}function k(C){var A;!h.value&&lf.includes(C.key)&&I.value&&(C.key==="Escape"?((A=Y.value)==null||A.blur(),d([u(e.id)])):o([u(e.id)]))}}}),YA=t.defineComponent({name:"ConnectionLine",compatConfig:{MODE:3},setup(){var e;const{id:n,connectionMode:o,connectionStartHandle:r,connectionEndHandle:i,connectionPosition:a,connectionLineType:l,connectionLineStyle:s,connectionLineOptions:c,connectionStatus:d,viewport:u,findNode:f}=Oe(),p=(e=t.inject(pi))==null?void 0:e["connection-line"],m=t.computed(()=>{var w;return f((w=r.value)==null?void 0:w.nodeId)}),h=t.computed(()=>{var w;return f((w=i.value)==null?void 0:w.nodeId)??null}),y=t.computed(()=>({x:(a.value.x-u.value.x)/u.value.zoom,y:(a.value.y-u.value.y)/u.value.zoom})),g=t.computed(()=>c.value.markerStart?`url(#${jo(c.value.markerStart,n)})`:""),_=t.computed(()=>c.value.markerEnd?`url(#${jo(c.value.markerEnd,n)})`:"");return()=>{var w,b,v;if(!m.value||!r.value)return null;const N=r.value.id,E=r.value.type,S=m.value.handleBounds;let P=(S==null?void 0:S[E])??[];if(o.value===Xt.Loose){const z=(S==null?void 0:S[E==="source"?"target":"source"])??[];P=[...P,...z]}if(!P)return null;const B=(N?P.find(z=>z.id===N):P[0])??null,j=(B==null?void 0:B.position)??ye.Top,{x:G,y:T}=Zn(m.value,B,j);let Y=null;h.value&&(o.value===Xt.Strict?Y=((w=h.value.handleBounds[E==="source"?"target":"source"])==null?void 0:w.find(z=>{var H;return z.id===((H=i.value)==null?void 0:H.id)}))||null:Y=((b=[...h.value.handleBounds.source??[],...h.value.handleBounds.target??[]])==null?void 0:b.find(z=>{var H;return z.id===((H=i.value)==null?void 0:H.id)}))||null);const I=((v=i.value)==null?void 0:v.position)??(j?wl[j]:null);if(!j||!I)return null;const M=l.value??c.value.type??_n.Bezier;let R="";const te={sourceX:G,sourceY:T,sourcePosition:j,targetX:y.value.x,targetY:y.value.y,targetPosition:I};return M===_n.Bezier?[R]=Hf(te):M===_n.Step?[R]=Sl({...te,borderRadius:0}):M===_n.SmoothStep?[R]=Sl(te):M===_n.SimpleBezier?[R]=Wf(te):R=`M${G},${T} ${y.value.x},${y.value.y}`,t.h("svg",{class:"vue-flow__edges vue-flow__connectionline vue-flow__container"},t.h("g",{class:"vue-flow__connection"},p?t.h(p,{sourceX:G,sourceY:T,sourcePosition:j,targetX:y.value.x,targetY:y.value.y,targetPosition:I,sourceNode:m.value,sourceHandle:B,targetNode:h.value,targetHandle:Y,markerEnd:_.value,markerStart:g.value,connectionStatus:d.value}):t.h("path",{d:R,class:[c.value.class,d,"vue-flow__connection-path"],style:{...s.value,...c.value.style},"marker-end":_.value,"marker-start":g.value})))}}}),WA=["id","markerWidth","markerHeight","markerUnits","orient"],XA={name:"MarkerType",compatConfig:{MODE:3}},ZA=t.defineComponent({...XA,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(e){return(n,o)=>(t.openBlock(),t.createElementBlock("marker",{id:n.id,class:"vue-flow__arrowhead",viewBox:"-10 -10 20 20",refX:"0",refY:"0",markerWidth:`${n.width}`,markerHeight:`${n.height}`,markerUnits:n.markerUnits,orient:n.orient},[n.type===t.unref(ii).ArrowClosed?(t.openBlock(),t.createElementBlock("polyline",{key:0,style:t.normalizeStyle({stroke:n.color,fill:n.color,strokeWidth:n.strokeWidth}),"stroke-linecap":"round","stroke-linejoin":"round",points:"-5,-4 0,0 -5,4 -5,-4"},null,4)):t.createCommentVNode("",!0),n.type===t.unref(ii).Arrow?(t.openBlock(),t.createElementBlock("polyline",{key:1,style:t.normalizeStyle({stroke:n.color,strokeWidth:n.strokeWidth}),"stroke-linecap":"round","stroke-linejoin":"round",fill:"none",points:"-5,-4 0,0 -5,4"},null,4)):t.createCommentVNode("",!0)],8,WA))}}),JA={class:"vue-flow__marker vue-flow__container","aria-hidden":"true"},QA={name:"MarkerDefinitions",compatConfig:{MODE:3}},eI=t.defineComponent({...QA,setup(e){const{id:n,edges:o,connectionLineOptions:r,defaultMarkerColor:i}=Oe(),a=t.computed(()=>{const l=new Set,s=[],c=d=>{if(d){const u=jo(d,n);l.has(u)||(typeof d=="object"?s.push({...d,id:u,color:d.color||i.value}):s.push({id:u,color:i.value,type:d}),l.add(u))}};for(const d of[r.value.markerEnd,r.value.markerStart])c(d);for(const d of o.value)for(const u of[d.markerStart,d.markerEnd])c(u);return s.sort((d,u)=>d.id.localeCompare(u.id))});return(l,s)=>(t.openBlock(),t.createElementBlock("svg",JA,[t.createElementVNode("defs",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(a.value,c=>(t.openBlock(),t.createBlock(ZA,{id:c.id,key:c.id,type:c.type,color:c.color,width:c.width,height:c.height,markerUnits:c.markerUnits,"stroke-width":c.strokeWidth,orient:c.orient},null,8,["id","type","color","width","height","markerUnits","stroke-width","orient"]))),128))])]))}}),tI={name:"Edges",compatConfig:{MODE:3}},nI=t.defineComponent({...tI,setup(e){const{findNode:n,getEdges:o,elevateEdgesOnSelect:r}=Oe();return(i,a)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[t.createVNode(eI),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(o),l=>(t.openBlock(),t.createElementBlock("svg",{key:l.id,class:"vue-flow__edges vue-flow__container",style:t.normalizeStyle({zIndex:t.unref(xx)(l,t.unref(n),t.unref(r))})},[t.createVNode(t.unref(HA),{id:l.id},null,8,["id"])],4))),128)),t.createVNode(t.unref(YA))],64))}}),oI=t.defineComponent({name:"Node",compatConfig:{MODE:3},props:["id","resizeObserver"],setup(e){const{id:n,noPanClassName:o,selectNodesOnDrag:r,nodesSelectionActive:i,multiSelectionActive:a,emits:l,removeSelectedNodes:s,addSelectedNodes:c,updateNodeDimensions:d,onUpdateNodeInternals:u,getNodeTypes:f,nodeExtent:p,elevateNodesOnSelect:m,disableKeyboardA11y:h,ariaLiveMessage:y,snapToGrid:g,snapGrid:_,nodeDragThreshold:w,nodesDraggable:b,elementsSelectable:v,nodesConnectable:N,nodesFocusable:E,hooks:S}=Oe(),P=t.ref(null);t.provide(Mf,P),t.provide(Df,e.id);const B=t.inject(pi),j=t.getCurrentInstance(),G=Kf(),{node:T,parentNode:Y}=Uf(e.id),{emit:I,on:M}=Hx(T,l),R=t.toRef(()=>typeof T.draggable>"u"?b.value:T.draggable),te=t.toRef(()=>typeof T.selectable>"u"?v.value:T.selectable),z=t.toRef(()=>typeof T.connectable>"u"?N.value:T.connectable),H=t.toRef(()=>typeof T.focusable>"u"?E.value:T.focusable),L=t.computed(()=>te.value||R.value||S.value.nodeClick.hasListeners()||S.value.nodeDoubleClick.hasListeners()||S.value.nodeMouseEnter.hasListeners()||S.value.nodeMouseMove.hasListeners()||S.value.nodeMouseLeave.hasListeners()),F=t.toRef(()=>!!T.dimensions.width&&!!T.dimensions.height),Z=t.computed(()=>{const A=T.type||"default",x=B==null?void 0:B[`node-${A}`];if(x)return x;let U=T.template||f.value[A];if(typeof U=="string"&&j){const V=Object.keys(j.appContext.components);V&&V.includes(A)&&(U=t.resolveComponent(A,!1))}return U&&typeof U!="string"?U:(l.error(new We(je.NODE_TYPE_MISSING,U)),!1)}),Q=Lf({id:e.id,el:P,disabled:()=>!R.value,selectable:te,dragHandle:()=>T.dragHandle,onStart(A){I.dragStart(A)},onDrag(A){I.drag(A)},onStop(A){I.dragStop(A)},onClick(A){k(A)}}),W=t.computed(()=>T.class instanceof Function?T.class(T):T.class),ie=t.computed(()=>{const A=(T.style instanceof Function?T.style(T):T.style)||{},x=T.width instanceof Function?T.width(T):T.width,U=T.height instanceof Function?T.height(T):T.height;return!A.width&&x&&(A.width=typeof x=="string"?x:`${x}px`),!A.height&&U&&(A.height=typeof U=="string"?U:`${U}px`),A}),ae=t.toRef(()=>Number(T.zIndex??ie.value.zIndex??0));return u(A=>{(A.includes(e.id)||!A.length)&&ge()}),t.onMounted(()=>{t.watch(()=>T.hidden,(A=!1,x,U)=>{!A&&P.value&&(e.resizeObserver.observe(P.value),U(()=>{P.value&&e.resizeObserver.unobserve(P.value)}))},{immediate:!0,flush:"post"})}),t.watch([()=>T.type,()=>T.sourcePosition,()=>T.targetPosition],()=>{t.nextTick(()=>{d([{id:e.id,nodeElement:P.value,forceUpdate:!0}])})}),t.watch([()=>T.position.x,()=>T.position.y,()=>{var A;return(A=Y.value)==null?void 0:A.computedPosition.x},()=>{var A;return(A=Y.value)==null?void 0:A.computedPosition.y},()=>{var A;return(A=Y.value)==null?void 0:A.computedPosition.z},ae,()=>T.selected,()=>T.dimensions.height,()=>T.dimensions.width,()=>{var A;return(A=Y.value)==null?void 0:A.dimensions.height},()=>{var A;return(A=Y.value)==null?void 0:A.dimensions.width}],([A,x,U,V,J,$])=>{const X={x:A,y:x,z:$+(m.value&&T.selected?1e3:0)};typeof U<"u"&&typeof V<"u"?T.computedPosition=kx({x:U,y:V,z:J},X):T.computedPosition=X},{flush:"post",immediate:!0}),t.watch([()=>T.extent,p],([A,x],[U,V])=>{(A!==U||x!==V)&&me()}),T.extent==="parent"||typeof T.extent=="object"&&"range"in T.extent&&T.extent.range==="parent"?qa(()=>F).toBe(!0).then(me):me(),()=>T.hidden?null:t.h("div",{ref:P,"data-id":T.id,class:["vue-flow__node",`vue-flow__node-${Z.value===!1?"default":T.type||"default"}`,{[o.value]:R.value,dragging:Q==null?void 0:Q.value,draggable:R.value,selected:T.selected,selectable:te.value,parent:T.isParent},W.value],style:{visibility:F.value?"visible":"hidden",zIndex:T.computedPosition.z??ae.value,transform:`translate(${T.computedPosition.x}px,${T.computedPosition.y}px)`,pointerEvents:L.value?"all":"none",...ie.value},tabIndex:H.value?0:void 0,role:H.value?"group":void 0,"aria-describedby":h.value?void 0:`${rf}-${n}`,"aria-label":T.ariaLabel,"aria-roledescription":"node",...T.domAttributes,onMouseenter:ne,onMousemove:re,onMouseleave:q,onContextmenu:ee,onClick:k,onDblclick:O,onKeydown:C},[t.h(Z.value===!1?f.value.default:Z.value,{id:T.id,type:T.type,data:T.data,events:{...T.events,...M},selected:T.selected,resizing:T.resizing,dragging:Q.value,connectable:z.value,position:T.computedPosition,dimensions:T.dimensions,isValidTargetPos:T.isValidTargetPos,isValidSourcePos:T.isValidSourcePos,parent:T.parentNode,parentNodeId:T.parentNode,zIndex:T.computedPosition.z??ae.value,targetPosition:T.targetPosition,sourcePosition:T.sourcePosition,label:T.label,dragHandle:T.dragHandle,onUpdateNodeInternals:ge})]);function me(){const A=T.computedPosition,{computedPosition:x,position:U}=yl(T,g.value?ui(A,_.value):A,l.error,p.value,Y.value);(T.computedPosition.x!==x.x||T.computedPosition.y!==x.y)&&(T.computedPosition={...T.computedPosition,...x}),(T.position.x!==U.x||T.position.y!==U.y)&&(T.position=U)}function ge(){P.value&&d([{id:e.id,nodeElement:P.value,forceUpdate:!0}])}function ne(A){Q!=null&&Q.value||I.mouseEnter({event:A,node:T})}function re(A){Q!=null&&Q.value||I.mouseMove({event:A,node:T})}function q(A){Q!=null&&Q.value||I.mouseLeave({event:A,node:T})}function ee(A){return I.contextMenu({event:A,node:T})}function O(A){return I.doubleClick({event:A,node:T})}function k(A){te.value&&(!r.value||!R.value||w.value>0)&&kl(T,a.value,c,s,i,!1,P.value),I.click({event:A,node:T})}function C(A){if(!(pl(A)||h.value))if(lf.includes(A.key)&&te.value){const x=A.key==="Escape";kl(T,a.value,c,s,i,x,P.value)}else R.value&&T.selected&&Xn[A.key]&&(A.preventDefault(),y.value=`Moved selected node ${A.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~T.position.x}, y: ${~~T.position.y}`,G({x:Xn[A.key].x,y:Xn[A.key].y},A.shiftKey))}}});function rI(e={includeHiddenNodes:!1}){const{nodes:n}=Oe();return t.computed(()=>{if(n.value.length===0)return!1;for(const o of n.value)if((e.includeHiddenNodes||!o.hidden)&&((o==null?void 0:o.handleBounds)===void 0||o.dimensions.width===0||o.dimensions.height===0))return!1;return!0})}const iI={class:"vue-flow__nodes vue-flow__container"},aI={name:"Nodes",compatConfig:{MODE:3}},lI=t.defineComponent({...aI,setup(e){const{getNodes:n,updateNodeDimensions:o,emits:r}=Oe(),i=rI(),a=t.ref();return t.watch(i,l=>{l&&t.nextTick(()=>{r.nodesInitialized(n.value)})},{immediate:!0}),t.onMounted(()=>{a.value=new ResizeObserver(l=>{const s=l.map(c=>({id:c.target.getAttribute("data-id"),nodeElement:c.target,forceUpdate:!0}));t.nextTick(()=>o(s))})}),t.onBeforeUnmount(()=>{var l;return(l=a.value)==null?void 0:l.disconnect()}),(l,s)=>(t.openBlock(),t.createElementBlock("div",iI,[a.value?(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:0},t.renderList(t.unref(n),(c,d,u,f)=>{const p=[c.id];if(f&&f.key===c.id&&t.isMemoSame(f,p))return f;const m=(t.openBlock(),t.createBlock(t.unref(oI),{id:c.id,key:c.id,"resize-observer":a.value},null,8,["id","resize-observer"]));return m.memo=p,m},s,0),128)):t.createCommentVNode("",!0)]))}});function sI(){const{emits:e}=Oe();t.onMounted(()=>{if(Tf()){const n=document.querySelector(".vue-flow__pane");n&&window.getComputedStyle(n).zIndex!=="1"&&e.error(new We(je.MISSING_STYLES))}})}const cI=t.createElementVNode("div",{class:"vue-flow__edge-labels"},null,-1),dI={name:"VueFlow",compatConfig:{MODE:3}},ep=t.defineComponent({...dI,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(e,{expose:n,emit:o}){const r=e,i=t.useSlots(),a=za(r,"modelValue",o),l=za(r,"nodes",o),s=za(r,"edges",o),c=Oe(r),d=Zx({modelValue:a,nodes:l,edges:s},r,c);return Qx(o,c.hooks),GA(),sI(),t.provide(pi,i),t.onUnmounted(()=>{d()}),n(c),(u,f)=>(t.openBlock(),t.createElementBlock("div",{ref:t.unref(c).vueFlowRef,class:"vue-flow"},[t.createVNode(MA,null,{default:t.withCtx(()=>[t.createVNode(nI),cI,t.createVNode(lI),t.renderSlot(u.$slots,"zoom-pane")]),_:3}),t.renderSlot(u.$slots,"default"),t.createVNode(jA)],512))}}),uI={name:"Panel",compatConfig:{MODE:3}},fI=t.defineComponent({...uI,props:{position:{}},setup(e){const n=e,{userSelectionActive:o}=Oe(),r=t.computed(()=>`${n.position}`.split("-"));return(i,a)=>(t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["vue-flow__panel",r.value]),style:t.normalizeStyle({pointerEvents:t.unref(o)?"none":"all"})},[t.renderSlot(i.$slots,"default")],6))}});var Gt=(e=>(e.Lines="lines",e.Dots="dots",e))(Gt||{});const tp=function({dimensions:e,size:n,color:o}){return t.h("path",{stroke:o,"stroke-width":n,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`})},np=function({radius:e,color:n}){return t.h("circle",{cx:e,cy:e,r:e,fill:n})};Gt.Lines+"",Gt.Dots+"";const pI={[Gt.Dots]:"#81818a",[Gt.Lines]:"#eee"},mI=["id","x","y","width","height","patternTransform"],gI={key:2,height:"100",width:"100"},hI=["fill"],yI=["x","y","fill"],_I={name:"Background",compatConfig:{MODE:3}},bI=t.defineComponent({..._I,props:{id:{},variant:{default:()=>Gt.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(e){const{id:n,viewport:o}=Oe(),r=t.computed(()=>{const l=o.value.zoom,[s,c]=Array.isArray(e.gap)?e.gap:[e.gap,e.gap],d=[s*l||1,c*l||1],u=e.size*l,[f,p]=Array.isArray(e.offset)?e.offset:[e.offset,e.offset],m=[f*l||1+d[0]/2,p*l||1+d[1]/2];return{scaledGap:d,offset:m,size:u}}),i=t.toRef(()=>`pattern-${n}${e.id?`-${e.id}`:""}`),a=t.toRef(()=>e.color||e.patternColor||pI[e.variant||Gt.Dots]);return(l,s)=>(t.openBlock(),t.createElementBlock("svg",{class:"vue-flow__background vue-flow__container",style:t.normalizeStyle({height:`${l.height>100?100:l.height}%`,width:`${l.width>100?100:l.width}%`})},[t.renderSlot(l.$slots,"pattern-container",{id:i.value},()=>[t.createElementVNode("pattern",{id:i.value,x:t.unref(o).x%r.value.scaledGap[0],y:t.unref(o).y%r.value.scaledGap[1],width:r.value.scaledGap[0],height:r.value.scaledGap[1],patternTransform:`translate(-${r.value.offset[0]},-${r.value.offset[1]})`,patternUnits:"userSpaceOnUse"},[t.renderSlot(l.$slots,"pattern",{},()=>[l.variant===t.unref(Gt).Lines?(t.openBlock(),t.createBlock(t.unref(tp),{key:0,size:l.lineWidth,color:a.value,dimensions:r.value.scaledGap},null,8,["size","color","dimensions"])):l.variant===t.unref(Gt).Dots?(t.openBlock(),t.createBlock(t.unref(np),{key:1,color:a.value,radius:r.value.size/2},null,8,["color","radius"])):t.createCommentVNode("",!0),l.bgColor?(t.openBlock(),t.createElementBlock("svg",gI,[t.createElementVNode("rect",{width:"100%",height:"100%",fill:l.bgColor},null,8,hI)])):t.createCommentVNode("",!0)])],8,mI)]),t.createElementVNode("rect",{x:l.x,y:l.y,width:"100%",height:"100%",fill:`url(#${i.value})`},null,8,yI),t.renderSlot(l.$slots,"default",{id:i.value})],4))}}),wI={name:"ControlButton",compatConfig:{MODE:3}},kI=(e,n)=>{const o=e.__vccOpts||e;for(const[r,i]of n)o[r]=i;return o},EI={class:"vue-flow__controls-button"};function CI(e,n,o,r,i,a){return t.openBlock(),t.createElementBlock("button",EI,[t.renderSlot(e.$slots,"default")])}const wi=kI(wI,[["render",CI]]),NI={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},vI=[t.createElementVNode("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"},null,-1)];function SI(e,n){return t.openBlock(),t.createElementBlock("svg",NI,vI)}const xI={render:SI},AI={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},II=[t.createElementVNode("path",{d:"M0 0h32v4.2H0z"},null,-1)];function PI(e,n){return t.openBlock(),t.createElementBlock("svg",AI,II)}const TI={render:PI},OI={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},$I=[t.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 BI(e,n){return t.openBlock(),t.createElementBlock("svg",OI,$I)}const VI={render:BI},RI={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},DI=[t.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 MI(e,n){return t.openBlock(),t.createElementBlock("svg",RI,DI)}const LI={render:MI},FI={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},UI=[t.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 KI(e,n){return t.openBlock(),t.createElementBlock("svg",FI,UI)}const jI={render:KI},GI={name:"Controls",compatConfig:{MODE:3}},qI=t.defineComponent({...GI,props:{showZoom:{type:Boolean,default:!0},showFitView:{type:Boolean,default:!0},showInteractive:{type:Boolean,default:!0},fitViewParams:{},position:{default:()=>nf.BottomLeft}},emits:["zoomIn","zoomOut","fitView","interactionChange"],setup(e,{emit:n}){const{nodesDraggable:o,nodesConnectable:r,elementsSelectable:i,setInteractive:a,zoomIn:l,zoomOut:s,fitView:c,viewport:d,minZoom:u,maxZoom:f}=Oe(),p=t.toRef(()=>o.value||r.value||i.value),m=t.toRef(()=>d.value.zoom<=u.value),h=t.toRef(()=>d.value.zoom>=f.value);function y(){l(),n("zoomIn")}function g(){s(),n("zoomOut")}function _(){c(e.fitViewParams),n("fitView")}function w(){a(!p.value),n("interactionChange",!p.value)}return(b,v)=>(t.openBlock(),t.createBlock(t.unref(fI),{class:"vue-flow__controls",position:b.position},{default:t.withCtx(()=>[t.renderSlot(b.$slots,"top"),b.showZoom?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.renderSlot(b.$slots,"control-zoom-in",{},()=>[t.createVNode(wi,{class:"vue-flow__controls-zoomin",disabled:h.value,onClick:y},{default:t.withCtx(()=>[t.renderSlot(b.$slots,"icon-zoom-in",{},()=>[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(t.unref(xI))))])]),_:3},8,["disabled"])]),t.renderSlot(b.$slots,"control-zoom-out",{},()=>[t.createVNode(wi,{class:"vue-flow__controls-zoomout",disabled:m.value,onClick:g},{default:t.withCtx(()=>[t.renderSlot(b.$slots,"icon-zoom-out",{},()=>[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(t.unref(TI))))])]),_:3},8,["disabled"])])],64)):t.createCommentVNode("",!0),b.showFitView?t.renderSlot(b.$slots,"control-fit-view",{key:1},()=>[t.createVNode(wi,{class:"vue-flow__controls-fitview",onClick:_},{default:t.withCtx(()=>[t.renderSlot(b.$slots,"icon-fit-view",{},()=>[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(t.unref(VI))))])]),_:3})]):t.createCommentVNode("",!0),b.showInteractive?t.renderSlot(b.$slots,"control-interactive",{key:2},()=>[b.showInteractive?(t.openBlock(),t.createBlock(wi,{key:0,class:"vue-flow__controls-interactive",onClick:w},{default:t.withCtx(()=>[p.value?t.renderSlot(b.$slots,"icon-unlock",{key:0},()=>[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(t.unref(jI))))]):t.createCommentVNode("",!0),p.value?t.createCommentVNode("",!0):t.renderSlot(b.$slots,"icon-lock",{key:1},()=>[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(t.unref(LI))))])]),_:3})):t.createCommentVNode("",!0)]):t.createCommentVNode("",!0),t.renderSlot(b.$slots,"default")]),_:3},8,["position"]))}}),Go={padding:80,gaps:{nodes:40,edges:80,ranks:40}},zI=1600,HI=1.2,YI=0,op=Symbol("confirm-modal"),Jn="{key}",En={"kong.client.consumer":{dataType:"object",writable:!1,readable:!0},"kong.client.consumer_groups":{dataType:"array",writable:!1,readable:!0},"kong.client.credential":{dataType:"object",writable:!1,readable:!0},"kong.client.get_identity_realm_source":{dataType:"object",writable:!1,readable:!0},"kong.client.forwarded_ip":{dataType:"string",writable:!1,readable:!0},"kong.client.forwarded_port":{dataType:"number",writable:!1,readable:!0},"kong.client.ip":{dataType:"string",writable:!1,readable:!0},"kong.client.port":{dataType:"number",writable:!1,readable:!0},"kong.client.protocol":{dataType:"string",writable:!1,readable:!0},"kong.request.forwarded_host":{dataType:"string",writable:!1,readable:!0},"kong.request.forwarded_port":{dataType:"number",writable:!1,readable:!0},"kong.request.forwarded_scheme":{dataType:"string",writable:!1,readable:!0},"kong.request.port":{dataType:"number",writable:!1,readable:!0},"kong.response.source":{dataType:"string",writable:!1,readable:!0},"kong.router.route":{dataType:"object",writable:!1,readable:!0},"kong.route_id":{dataType:"string",writable:!1,readable:!0},"kong.route_name":{dataType:"string",writable:!1,readable:!0},"kong.router.service":{dataType:"object",writable:!1,readable:!0},"kong.service_name":{dataType:"string",writable:!1,readable:!0},"kong.service_id":{dataType:"string",writable:!1,readable:!0},"kong.service.response.status":{dataType:"number",writable:!1,readable:!0},"kong.version":{dataType:"string",writable:!1,readable:!0},"kong.node.id":{dataType:"string",writable:!1,readable:!0},"kong.configuration.{key}":{dataType:"any",writable:!1,readable:!0},"kong.service.target":{dataType:"string ({host}:{port})",writable:!0,readable:!1},"kong.service.request_scheme":{dataType:"string ({scheme})",writable:!0,readable:!1},"kong.ctx.plugin.{key}":{dataType:"any",writable:!0,readable:!0},"kong.ctx.shared.{key}":{dataType:"any",writable:!0,readable:!0}},ki=Object.keys(En).filter(e=>e.includes(Jn)).map(e=>e.replace(Jn,""));function Al(e){if(!e||!zo(e))return;const n=ki.find(o=>e.startsWith(o));if(n)return e.slice(n.length).replace(Jn,"")}function qo(e){if(!e)return null;const n=ki.find(o=>e.startsWith(o));return n||e}function zo(e){return e?ki.some(n=>e.startsWith(n)):!1}function rp(e){return e?zo(e)?qo(e)+Jn:e:null}function Il(e){var o;if(!e)return!1;const n=rp(e);return n?((o=En[n])==null?void 0:o.readable)??!1:!1}function Pl(e){var o;if(!e)return!1;const n=rp(e);return n?((o=En[n])==null?void 0:o.writable)??!1:!1}function WI(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var XI="\0",Cn="\0",ip="";let ZI=class{constructor(n){ze(this,"_isDirected",!0);ze(this,"_isMultigraph",!1);ze(this,"_isCompound",!1);ze(this,"_label");ze(this,"_defaultNodeLabelFn",()=>{});ze(this,"_defaultEdgeLabelFn",()=>{});ze(this,"_nodes",{});ze(this,"_in",{});ze(this,"_preds",{});ze(this,"_out",{});ze(this,"_sucs",{});ze(this,"_edgeObjs",{});ze(this,"_edgeLabels",{});ze(this,"_nodeCount",0);ze(this,"_edgeCount",0);ze(this,"_parent");ze(this,"_children");n&&(this._isDirected=Object.hasOwn(n,"directed")?n.directed:!0,this._isMultigraph=Object.hasOwn(n,"multigraph")?n.multigraph:!1,this._isCompound=Object.hasOwn(n,"compound")?n.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[Cn]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(n){return this._label=n,this}graph(){return this._label}setDefaultNodeLabel(n){return this._defaultNodeLabelFn=n,typeof n!="function"&&(this._defaultNodeLabelFn=()=>n),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var n=this;return this.nodes().filter(o=>Object.keys(n._in[o]).length===0)}sinks(){var n=this;return this.nodes().filter(o=>Object.keys(n._out[o]).length===0)}setNodes(n,o){var r=arguments,i=this;return n.forEach(function(a){r.length>1?i.setNode(a,o):i.setNode(a)}),this}setNode(n,o){return Object.hasOwn(this._nodes,n)?(arguments.length>1&&(this._nodes[n]=o),this):(this._nodes[n]=arguments.length>1?o:this._defaultNodeLabelFn(n),this._isCompound&&(this._parent[n]=Cn,this._children[n]={},this._children[Cn][n]=!0),this._in[n]={},this._preds[n]={},this._out[n]={},this._sucs[n]={},++this._nodeCount,this)}node(n){return this._nodes[n]}hasNode(n){return Object.hasOwn(this._nodes,n)}removeNode(n){var o=this;if(Object.hasOwn(this._nodes,n)){var r=i=>o.removeEdge(o._edgeObjs[i]);delete this._nodes[n],this._isCompound&&(this._removeFromParentsChildList(n),delete this._parent[n],this.children(n).forEach(function(i){o.setParent(i)}),delete this._children[n]),Object.keys(this._in[n]).forEach(r),delete this._in[n],delete this._preds[n],Object.keys(this._out[n]).forEach(r),delete this._out[n],delete this._sucs[n],--this._nodeCount}return this}setParent(n,o){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(o===void 0)o=Cn;else{o+="";for(var r=o;r!==void 0;r=this.parent(r))if(r===n)throw new Error("Setting "+o+" as parent of "+n+" would create a cycle");this.setNode(o)}return this.setNode(n),this._removeFromParentsChildList(n),this._parent[n]=o,this._children[o][n]=!0,this}_removeFromParentsChildList(n){delete this._children[this._parent[n]][n]}parent(n){if(this._isCompound){var o=this._parent[n];if(o!==Cn)return o}}children(n=Cn){if(this._isCompound){var o=this._children[n];if(o)return Object.keys(o)}else{if(n===Cn)return this.nodes();if(this.hasNode(n))return[]}}predecessors(n){var o=this._preds[n];if(o)return Object.keys(o)}successors(n){var o=this._sucs[n];if(o)return Object.keys(o)}neighbors(n){var o=this.predecessors(n);if(o){const i=new Set(o);for(var r of this.successors(n))i.add(r);return Array.from(i.values())}}isLeaf(n){var o;return this.isDirected()?o=this.successors(n):o=this.neighbors(n),o.length===0}filterNodes(n){var o=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});o.setGraph(this.graph());var r=this;Object.entries(this._nodes).forEach(function([l,s]){n(l)&&o.setNode(l,s)}),Object.values(this._edgeObjs).forEach(function(l){o.hasNode(l.v)&&o.hasNode(l.w)&&o.setEdge(l,r.edge(l))});var i={};function a(l){var s=r.parent(l);return s===void 0||o.hasNode(s)?(i[l]=s,s):s in i?i[s]:a(s)}return this._isCompound&&o.nodes().forEach(l=>o.setParent(l,a(l))),o}setDefaultEdgeLabel(n){return this._defaultEdgeLabelFn=n,typeof n!="function"&&(this._defaultEdgeLabelFn=()=>n),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(n,o){var r=this,i=arguments;return n.reduce(function(a,l){return i.length>1?r.setEdge(a,l,o):r.setEdge(a,l),l}),this}setEdge(){var n,o,r,i,a=!1,l=arguments[0];typeof l=="object"&&l!==null&&"v"in l?(n=l.v,o=l.w,r=l.name,arguments.length===2&&(i=arguments[1],a=!0)):(n=l,o=arguments[1],r=arguments[3],arguments.length>2&&(i=arguments[2],a=!0)),n=""+n,o=""+o,r!==void 0&&(r=""+r);var s=Ho(this._isDirected,n,o,r);if(Object.hasOwn(this._edgeLabels,s))return a&&(this._edgeLabels[s]=i),this;if(r!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(n),this.setNode(o),this._edgeLabels[s]=a?i:this._defaultEdgeLabelFn(n,o,r);var c=JI(this._isDirected,n,o,r);return n=c.v,o=c.w,Object.freeze(c),this._edgeObjs[s]=c,ap(this._preds[o],n),ap(this._sucs[n],o),this._in[o][s]=c,this._out[n][s]=c,this._edgeCount++,this}edge(n,o,r){var i=arguments.length===1?Tl(this._isDirected,arguments[0]):Ho(this._isDirected,n,o,r);return this._edgeLabels[i]}edgeAsObj(){const n=this.edge(...arguments);return typeof n!="object"?{label:n}:n}hasEdge(n,o,r){var i=arguments.length===1?Tl(this._isDirected,arguments[0]):Ho(this._isDirected,n,o,r);return Object.hasOwn(this._edgeLabels,i)}removeEdge(n,o,r){var i=arguments.length===1?Tl(this._isDirected,arguments[0]):Ho(this._isDirected,n,o,r),a=this._edgeObjs[i];return a&&(n=a.v,o=a.w,delete this._edgeLabels[i],delete this._edgeObjs[i],lp(this._preds[o],n),lp(this._sucs[n],o),delete this._in[o][i],delete this._out[n][i],this._edgeCount--),this}inEdges(n,o){var r=this._in[n];if(r){var i=Object.values(r);return o?i.filter(a=>a.v===o):i}}outEdges(n,o){var r=this._out[n];if(r){var i=Object.values(r);return o?i.filter(a=>a.w===o):i}}nodeEdges(n,o){var r=this.inEdges(n,o);if(r)return r.concat(this.outEdges(n,o))}};function ap(e,n){e[n]?e[n]++:e[n]=1}function lp(e,n){--e[n]||delete e[n]}function Ho(e,n,o,r){var i=""+n,a=""+o;if(!e&&i>a){var l=i;i=a,a=l}return i+ip+a+ip+(r===void 0?XI:r)}function JI(e,n,o,r){var i=""+n,a=""+o;if(!e&&i>a){var l=i;i=a,a=l}var s={v:i,w:a};return r&&(s.name=r),s}function Tl(e,n){return Ho(e,n.v,n.w,n.name)}var Ol=ZI,QI="2.2.4",eP={Graph:Ol,version:QI},tP=Ol,nP={write:oP,read:aP};function oP(e){var n={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:rP(e),edges:iP(e)};return e.graph()!==void 0&&(n.value=structuredClone(e.graph())),n}function rP(e){return e.nodes().map(function(n){var o=e.node(n),r=e.parent(n),i={v:n};return o!==void 0&&(i.value=o),r!==void 0&&(i.parent=r),i})}function iP(e){return e.edges().map(function(n){var o=e.edge(n),r={v:n.v,w:n.w};return n.name!==void 0&&(r.name=n.name),o!==void 0&&(r.value=o),r})}function aP(e){var n=new tP(e.options).setGraph(e.value);return e.nodes.forEach(function(o){n.setNode(o.v,o.value),o.parent&&n.setParent(o.v,o.parent)}),e.edges.forEach(function(o){n.setEdge({v:o.v,w:o.w,name:o.name},o.value)}),n}var lP=sP;function sP(e){var n={},o=[],r;function i(a){Object.hasOwn(n,a)||(n[a]=!0,r.push(a),e.successors(a).forEach(i),e.predecessors(a).forEach(i))}return e.nodes().forEach(function(a){r=[],i(a),r.length&&o.push(r)}),o}var sp=class{constructor(){ze(this,"_arr",[]);ze(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map(function(n){return n.key})}has(n){return Object.hasOwn(this._keyIndices,n)}priority(n){var o=this._keyIndices[n];if(o!==void 0)return this._arr[o].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(n,o){var r=this._keyIndices;if(n=String(n),!Object.hasOwn(r,n)){var i=this._arr,a=i.length;return r[n]=a,i.push({key:n,priority:o}),this._decrease(a),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var n=this._arr.pop();return delete this._keyIndices[n.key],this._heapify(0),n.key}decrease(n,o){var r=this._keyIndices[n];if(o>this._arr[r].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[r].priority+" New: "+o);this._arr[r].priority=o,this._decrease(r)}_heapify(n){var o=this._arr,r=2*n,i=r+1,a=n;r<o.length&&(a=o[r].priority<o[a].priority?r:a,i<o.length&&(a=o[i].priority<o[a].priority?i:a),a!==n&&(this._swap(n,a),this._heapify(a)))}_decrease(n){for(var o=this._arr,r=o[n].priority,i;n!==0&&(i=n>>1,!(o[i].priority<r));)this._swap(n,i),n=i}_swap(n,o){var r=this._arr,i=this._keyIndices,a=r[n],l=r[o];r[n]=l,r[o]=a,i[l.key]=n,i[a.key]=o}},cP=sp,cp=uP,dP=()=>1;function uP(e,n,o,r){return fP(e,String(n),o||dP,r||function(i){return e.outEdges(i)})}function fP(e,n,o,r){var i={},a=new cP,l,s,c=function(d){var u=d.v!==l?d.v:d.w,f=i[u],p=o(d),m=s.distance+p;if(p<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+d+" Weight: "+p);m<f.distance&&(f.distance=m,f.predecessor=l,a.decrease(u,m))};for(e.nodes().forEach(function(d){var u=d===n?0:Number.POSITIVE_INFINITY;i[d]={distance:u},a.add(d,u)});a.size()>0&&(l=a.removeMin(),s=i[l],s.distance!==Number.POSITIVE_INFINITY);)r(l).forEach(c);return i}var pP=cp,mP=gP;function gP(e,n,o){return e.nodes().reduce(function(r,i){return r[i]=pP(e,i,n,o),r},{})}var dp=hP;function hP(e){var n=0,o=[],r={},i=[];function a(l){var s=r[l]={onStack:!0,lowlink:n,index:n++};if(o.push(l),e.successors(l).forEach(function(u){Object.hasOwn(r,u)?r[u].onStack&&(s.lowlink=Math.min(s.lowlink,r[u].index)):(a(u),s.lowlink=Math.min(s.lowlink,r[u].lowlink))}),s.lowlink===s.index){var c=[],d;do d=o.pop(),r[d].onStack=!1,c.push(d);while(l!==d);i.push(c)}}return e.nodes().forEach(function(l){Object.hasOwn(r,l)||a(l)}),i}var yP=dp,_P=bP;function bP(e){return yP(e).filter(function(n){return n.length>1||n.length===1&&e.hasEdge(n[0],n[0])})}var wP=EP,kP=()=>1;function EP(e,n,o){return CP(e,n||kP,o||function(r){return e.outEdges(r)})}function CP(e,n,o){var r={},i=e.nodes();return i.forEach(function(a){r[a]={},r[a][a]={distance:0},i.forEach(function(l){a!==l&&(r[a][l]={distance:Number.POSITIVE_INFINITY})}),o(a).forEach(function(l){var s=l.v===a?l.w:l.v,c=n(l);r[a][s]={distance:c,predecessor:a}})}),i.forEach(function(a){var l=r[a];i.forEach(function(s){var c=r[s];i.forEach(function(d){var u=c[a],f=l[d],p=c[d],m=u.distance+f.distance;m<p.distance&&(p.distance=m,p.predecessor=f.predecessor)})})}),r}function up(e){var n={},o={},r=[];function i(a){if(Object.hasOwn(o,a))throw new $l;Object.hasOwn(n,a)||(o[a]=!0,n[a]=!0,e.predecessors(a).forEach(i),delete o[a],r.push(a))}if(e.sinks().forEach(i),Object.keys(n).length!==e.nodeCount())throw new $l;return r}class $l extends Error{constructor(){super(...arguments)}}var fp=up;up.CycleException=$l;var pp=fp,NP=vP;function vP(e){try{pp(e)}catch(n){if(n instanceof pp.CycleException)return!1;throw n}return!0}var mp=SP;function SP(e,n,o){Array.isArray(n)||(n=[n]);var r=e.isDirected()?s=>e.successors(s):s=>e.neighbors(s),i=o==="post"?xP:AP,a=[],l={};return n.forEach(s=>{if(!e.hasNode(s))throw new Error("Graph does not have node: "+s);i(s,r,l,a)}),a}function xP(e,n,o,r){for(var i=[[e,!1]];i.length>0;){var a=i.pop();a[1]?r.push(a[0]):Object.hasOwn(o,a[0])||(o[a[0]]=!0,i.push([a[0],!0]),gp(n(a[0]),l=>i.push([l,!1])))}}function AP(e,n,o,r){for(var i=[e];i.length>0;){var a=i.pop();Object.hasOwn(o,a)||(o[a]=!0,r.push(a),gp(n(a),l=>i.push(l)))}}function gp(e,n){for(var o=e.length;o--;)n(e[o],o,e);return e}var IP=mp,PP=TP;function TP(e,n){return IP(e,n,"post")}var OP=mp,$P=BP;function BP(e,n){return OP(e,n,"pre")}var VP=Ol,RP=sp,DP=MP;function MP(e,n){var o=new VP,r={},i=new RP,a;function l(c){var d=c.v===a?c.w:c.v,u=i.priority(d);if(u!==void 0){var f=n(c);f<u&&(r[d]=a,i.decrease(d,f))}}if(e.nodeCount()===0)return o;e.nodes().forEach(function(c){i.add(c,Number.POSITIVE_INFINITY),o.setNode(c)}),i.decrease(e.nodes()[0],0);for(var s=!1;i.size()>0;){if(a=i.removeMin(),Object.hasOwn(r,a))o.setEdge(a,r[a]);else{if(s)throw new Error("Input graph is not connected: "+e);s=!0}e.nodeEdges(a).forEach(l)}return o}var LP={components:lP,dijkstra:cp,dijkstraAll:mP,findCycles:_P,floydWarshall:wP,isAcyclic:NP,postorder:PP,preorder:$P,prim:DP,tarjan:dp,topsort:fp},hp=eP,kt={Graph:hp.Graph,json:nP,alg:LP,version:hp.version};let FP=class{constructor(){let n={};n._next=n._prev=n,this._sentinel=n}dequeue(){let n=this._sentinel,o=n._prev;if(o!==n)return yp(o),o}enqueue(n){let o=this._sentinel;n._prev&&n._next&&yp(n),n._next=o._next,o._next._prev=n,o._next=n,n._prev=o}toString(){let n=[],o=this._sentinel,r=o._prev;for(;r!==o;)n.push(JSON.stringify(r,UP)),r=r._prev;return"["+n.join(", ")+"]"}};function yp(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function UP(e,n){if(e!=="_next"&&e!=="_prev")return n}var KP=FP;let jP=kt.Graph,GP=KP;var qP=HP;let zP=()=>1;function HP(e,n){if(e.nodeCount()<=1)return[];let o=WP(e,n||zP);return YP(o.graph,o.buckets,o.zeroIdx).flatMap(i=>e.outEdges(i.v,i.w))}function YP(e,n,o){let r=[],i=n[n.length-1],a=n[0],l;for(;e.nodeCount();){for(;l=a.dequeue();)Bl(e,n,o,l);for(;l=i.dequeue();)Bl(e,n,o,l);if(e.nodeCount()){for(let s=n.length-2;s>0;--s)if(l=n[s].dequeue(),l){r=r.concat(Bl(e,n,o,l,!0));break}}}return r}function Bl(e,n,o,r,i){let a=i?[]:void 0;return e.inEdges(r.v).forEach(l=>{let s=e.edge(l),c=e.node(l.v);i&&a.push({v:l.v,w:l.w}),c.out-=s,Vl(n,o,c)}),e.outEdges(r.v).forEach(l=>{let s=e.edge(l),c=l.w,d=e.node(c);d.in-=s,Vl(n,o,d)}),e.removeNode(r.v),a}function WP(e,n){let o=new jP,r=0,i=0;e.nodes().forEach(s=>{o.setNode(s,{v:s,in:0,out:0})}),e.edges().forEach(s=>{let c=o.edge(s.v,s.w)||0,d=n(s),u=c+d;o.setEdge(s.v,s.w,u),i=Math.max(i,o.node(s.v).out+=d),r=Math.max(r,o.node(s.w).in+=d)});let a=XP(i+r+3).map(()=>new GP),l=r+1;return o.nodes().forEach(s=>{Vl(a,l,o.node(s))}),{graph:o,buckets:a,zeroIdx:l}}function Vl(e,n,o){o.out?o.in?e[o.out-o.in+n].enqueue(o):e[e.length-1].enqueue(o):e[0].enqueue(o)}function XP(e){const n=[];for(let o=0;o<e;o++)n.push(o);return n}let _p=kt.Graph;var qe={addBorderNode:iT,addDummyNode:bp,applyWithChunking:Ei,asNonCompoundGraph:JP,buildLayerMatrix:nT,intersectRect:tT,mapValues:fT,maxRank:kp,normalizeRanks:oT,notime:cT,partition:lT,pick:uT,predecessorWeights:eT,range:Cp,removeEmptyRanks:rT,simplify:ZP,successorWeights:QP,time:sT,uniqueId:Ep,zipObject:Rl};function bp(e,n,o,r){for(var i=r;e.hasNode(i);)i=Ep(r);return o.dummy=n,e.setNode(i,o),i}function ZP(e){let n=new _p().setGraph(e.graph());return e.nodes().forEach(o=>n.setNode(o,e.node(o))),e.edges().forEach(o=>{let r=n.edge(o.v,o.w)||{weight:0,minlen:1},i=e.edge(o);n.setEdge(o.v,o.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),n}function JP(e){let n=new _p({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(o=>{e.children(o).length||n.setNode(o,e.node(o))}),e.edges().forEach(o=>{n.setEdge(o,e.edge(o))}),n}function QP(e){let n=e.nodes().map(o=>{let r={};return e.outEdges(o).forEach(i=>{r[i.w]=(r[i.w]||0)+e.edge(i).weight}),r});return Rl(e.nodes(),n)}function eT(e){let n=e.nodes().map(o=>{let r={};return e.inEdges(o).forEach(i=>{r[i.v]=(r[i.v]||0)+e.edge(i).weight}),r});return Rl(e.nodes(),n)}function tT(e,n){let o=e.x,r=e.y,i=n.x-o,a=n.y-r,l=e.width/2,s=e.height/2;if(!i&&!a)throw new Error("Not possible to find intersection inside of the rectangle");let c,d;return Math.abs(a)*l>Math.abs(i)*s?(a<0&&(s=-s),c=s*i/a,d=s):(i<0&&(l=-l),c=l,d=l*a/i),{x:o+c,y:r+d}}function nT(e){let n=Cp(kp(e)+1).map(()=>[]);return e.nodes().forEach(o=>{let r=e.node(o),i=r.rank;i!==void 0&&(n[i][r.order]=o)}),n}function oT(e){let n=e.nodes().map(r=>{let i=e.node(r).rank;return i===void 0?Number.MAX_VALUE:i}),o=Ei(Math.min,n);e.nodes().forEach(r=>{let i=e.node(r);Object.hasOwn(i,"rank")&&(i.rank-=o)})}function rT(e){let n=e.nodes().map(l=>e.node(l).rank),o=Ei(Math.min,n),r=[];e.nodes().forEach(l=>{let s=e.node(l).rank-o;r[s]||(r[s]=[]),r[s].push(l)});let i=0,a=e.graph().nodeRankFactor;Array.from(r).forEach((l,s)=>{l===void 0&&s%a!==0?--i:l!==void 0&&i&&l.forEach(c=>e.node(c).rank+=i)})}function iT(e,n,o,r){let i={width:0,height:0};return arguments.length>=4&&(i.rank=o,i.order=r),bp(e,"border",i,n)}function aT(e,n=wp){const o=[];for(let r=0;r<e.length;r+=n){const i=e.slice(r,r+n);o.push(i)}return o}const wp=65535;function Ei(e,n){if(n.length>wp){const o=aT(n);return e.apply(null,o.map(r=>e.apply(null,r)))}else return e.apply(null,n)}function kp(e){const o=e.nodes().map(r=>{let i=e.node(r).rank;return i===void 0?Number.MIN_VALUE:i});return Ei(Math.max,o)}function lT(e,n){let o={lhs:[],rhs:[]};return e.forEach(r=>{n(r)?o.lhs.push(r):o.rhs.push(r)}),o}function sT(e,n){let o=Date.now();try{return n()}finally{console.log(e+" time: "+(Date.now()-o)+"ms")}}function cT(e,n){return n()}let dT=0;function Ep(e){var n=++dT;return e+(""+n)}function Cp(e,n,o=1){n==null&&(n=e,e=0);let r=a=>a<n;o<0&&(r=a=>n<a);const i=[];for(let a=e;r(a);a+=o)i.push(a);return i}function uT(e,n){const o={};for(const r of n)e[r]!==void 0&&(o[r]=e[r]);return o}function fT(e,n){let o=n;return typeof n=="string"&&(o=r=>r[n]),Object.entries(e).reduce((r,[i,a])=>(r[i]=o(a,i),r),{})}function Rl(e,n){return e.reduce((o,r,i)=>(o[r]=n[i],o),{})}let pT=qP,mT=qe.uniqueId;var gT={run:hT,undo:_T};function hT(e){(e.graph().acyclicer==="greedy"?pT(e,o(e)):yT(e)).forEach(r=>{let i=e.edge(r);e.removeEdge(r),i.forwardName=r.name,i.reversed=!0,e.setEdge(r.w,r.v,i,mT("rev"))});function o(r){return i=>r.edge(i).weight}}function yT(e){let n=[],o={},r={};function i(a){Object.hasOwn(r,a)||(r[a]=!0,o[a]=!0,e.outEdges(a).forEach(l=>{Object.hasOwn(o,l.w)?n.push(l):i(l.w)}),delete o[a])}return e.nodes().forEach(i),n}function _T(e){e.edges().forEach(n=>{let o=e.edge(n);if(o.reversed){e.removeEdge(n);let r=o.forwardName;delete o.reversed,delete o.forwardName,e.setEdge(n.w,n.v,o,r)}})}let bT=qe;var wT={run:kT,undo:CT};function kT(e){e.graph().dummyChains=[],e.edges().forEach(n=>ET(e,n))}function ET(e,n){let o=n.v,r=e.node(o).rank,i=n.w,a=e.node(i).rank,l=n.name,s=e.edge(n),c=s.labelRank;if(a===r+1)return;e.removeEdge(n);let d,u,f;for(f=0,++r;r<a;++f,++r)s.points=[],u={width:0,height:0,edgeLabel:s,edgeObj:n,rank:r},d=bT.addDummyNode(e,"edge",u,"_d"),r===c&&(u.width=s.width,u.height=s.height,u.dummy="edge-label",u.labelpos=s.labelpos),e.setEdge(o,d,{weight:s.weight},l),f===0&&e.graph().dummyChains.push(d),o=d;e.setEdge(o,i,{weight:s.weight},l)}function CT(e){e.graph().dummyChains.forEach(n=>{let o=e.node(n),r=o.edgeLabel,i;for(e.setEdge(o.edgeObj,r);o.dummy;)i=e.successors(n)[0],e.removeNode(n),r.points.push({x:o.x,y:o.y}),o.dummy==="edge-label"&&(r.x=o.x,r.y=o.y,r.width=o.width,r.height=o.height),n=i,o=e.node(n)})}const{applyWithChunking:NT}=qe;var Ci={longestPath:vT,slack:ST};function vT(e){var n={};function o(r){var i=e.node(r);if(Object.hasOwn(n,r))return i.rank;n[r]=!0;let a=e.outEdges(r).map(s=>s==null?Number.POSITIVE_INFINITY:o(s.w)-e.edge(s).minlen);var l=NT(Math.min,a);return l===Number.POSITIVE_INFINITY&&(l=0),i.rank=l}e.sources().forEach(o)}function ST(e,n){return e.node(n.w).rank-e.node(n.v).rank-e.edge(n).minlen}var xT=kt.Graph,Ni=Ci.slack,Np=AT;function AT(e){var n=new xT({directed:!1}),o=e.nodes()[0],r=e.nodeCount();n.setNode(o,{});for(var i,a;IT(n,e)<r;)i=PT(n,e),a=n.hasNode(i.v)?Ni(e,i):-Ni(e,i),TT(n,e,a);return n}function IT(e,n){function o(r){n.nodeEdges(r).forEach(i=>{var a=i.v,l=r===a?i.w:a;!e.hasNode(l)&&!Ni(n,i)&&(e.setNode(l,{}),e.setEdge(r,l,{}),o(l))})}return e.nodes().forEach(o),e.nodeCount()}function PT(e,n){return n.edges().reduce((r,i)=>{let a=Number.POSITIVE_INFINITY;return e.hasNode(i.v)!==e.hasNode(i.w)&&(a=Ni(n,i)),a<r[0]?[a,i]:r},[Number.POSITIVE_INFINITY,null])[1]}function TT(e,n,o){e.nodes().forEach(r=>n.node(r).rank+=o)}var OT=Np,vp=Ci.slack,$T=Ci.longestPath,BT=kt.alg.preorder,VT=kt.alg.postorder,RT=qe.simplify,DT=Nn;Nn.initLowLimValues=Ml,Nn.initCutValues=Dl,Nn.calcCutValue=Sp,Nn.leaveEdge=Ap,Nn.enterEdge=Ip,Nn.exchangeEdges=Pp;function Nn(e){e=RT(e),$T(e);var n=OT(e);Ml(n),Dl(n,e);for(var o,r;o=Ap(n);)r=Ip(n,e,o),Pp(n,e,o,r)}function Dl(e,n){var o=VT(e,e.nodes());o=o.slice(0,o.length-1),o.forEach(r=>MT(e,n,r))}function MT(e,n,o){var r=e.node(o),i=r.parent;e.edge(o,i).cutvalue=Sp(e,n,o)}function Sp(e,n,o){var r=e.node(o),i=r.parent,a=!0,l=n.edge(o,i),s=0;return l||(a=!1,l=n.edge(i,o)),s=l.weight,n.nodeEdges(o).forEach(c=>{var d=c.v===o,u=d?c.w:c.v;if(u!==i){var f=d===a,p=n.edge(c).weight;if(s+=f?p:-p,FT(e,o,u)){var m=e.edge(o,u).cutvalue;s+=f?-m:m}}}),s}function Ml(e,n){arguments.length<2&&(n=e.nodes()[0]),xp(e,{},1,n)}function xp(e,n,o,r,i){var a=o,l=e.node(r);return n[r]=!0,e.neighbors(r).forEach(s=>{Object.hasOwn(n,s)||(o=xp(e,n,o,s,r))}),l.low=a,l.lim=o++,i?l.parent=i:delete l.parent,o}function Ap(e){return e.edges().find(n=>e.edge(n).cutvalue<0)}function Ip(e,n,o){var r=o.v,i=o.w;n.hasEdge(r,i)||(r=o.w,i=o.v);var a=e.node(r),l=e.node(i),s=a,c=!1;a.lim>l.lim&&(s=l,c=!0);var d=n.edges().filter(u=>c===Tp(e,e.node(u.v),s)&&c!==Tp(e,e.node(u.w),s));return d.reduce((u,f)=>vp(n,f)<vp(n,u)?f:u)}function Pp(e,n,o,r){var i=o.v,a=o.w;e.removeEdge(i,a),e.setEdge(r.v,r.w,{}),Ml(e),Dl(e,n),LT(e,n)}function LT(e,n){var o=e.nodes().find(i=>!n.node(i).parent),r=BT(e,o);r=r.slice(1),r.forEach(i=>{var a=e.node(i).parent,l=n.edge(i,a),s=!1;l||(l=n.edge(a,i),s=!0),n.node(i).rank=n.node(a).rank+(s?l.minlen:-l.minlen)})}function FT(e,n,o){return e.hasEdge(n,o)}function Tp(e,n,o){return o.low<=n.lim&&n.lim<=o.lim}var UT=Ci,Op=UT.longestPath,KT=Np,jT=DT,GT=qT;function qT(e){var n=e.graph().ranker;if(n instanceof Function)return n(e);switch(e.graph().ranker){case"network-simplex":$p(e);break;case"tight-tree":HT(e);break;case"longest-path":zT(e);break;case"none":break;default:$p(e)}}var zT=Op;function HT(e){Op(e),KT(e)}function $p(e){jT(e)}var YT=WT;function WT(e){let n=ZT(e);e.graph().dummyChains.forEach(o=>{let r=e.node(o),i=r.edgeObj,a=XT(e,n,i.v,i.w),l=a.path,s=a.lca,c=0,d=l[c],u=!0;for(;o!==i.w;){if(r=e.node(o),u){for(;(d=l[c])!==s&&e.node(d).maxRank<r.rank;)c++;d===s&&(u=!1)}if(!u){for(;c<l.length-1&&e.node(d=l[c+1]).minRank<=r.rank;)c++;d=l[c]}e.setParent(o,d),o=e.successors(o)[0]}})}function XT(e,n,o,r){let i=[],a=[],l=Math.min(n[o].low,n[r].low),s=Math.max(n[o].lim,n[r].lim),c,d;c=o;do c=e.parent(c),i.push(c);while(c&&(n[c].low>l||s>n[c].lim));for(d=c,c=r;(c=e.parent(c))!==d;)a.push(c);return{path:i.concat(a.reverse()),lca:d}}function ZT(e){let n={},o=0;function r(i){let a=o;e.children(i).forEach(r),n[i]={low:a,lim:o++}}return e.children().forEach(r),n}let vi=qe;var JT={run:QT,cleanup:nO};function QT(e){let n=vi.addDummyNode(e,"root",{},"_root"),o=eO(e),r=Object.values(o),i=vi.applyWithChunking(Math.max,r)-1,a=2*i+1;e.graph().nestingRoot=n,e.edges().forEach(s=>e.edge(s).minlen*=a);let l=tO(e)+1;e.children().forEach(s=>Bp(e,n,a,l,i,o,s)),e.graph().nodeRankFactor=a}function Bp(e,n,o,r,i,a,l){let s=e.children(l);if(!s.length){l!==n&&e.setEdge(n,l,{weight:0,minlen:o});return}let c=vi.addBorderNode(e,"_bt"),d=vi.addBorderNode(e,"_bb"),u=e.node(l);e.setParent(c,l),u.borderTop=c,e.setParent(d,l),u.borderBottom=d,s.forEach(f=>{Bp(e,n,o,r,i,a,f);let p=e.node(f),m=p.borderTop?p.borderTop:f,h=p.borderBottom?p.borderBottom:f,y=p.borderTop?r:2*r,g=m!==h?1:i-a[l]+1;e.setEdge(c,m,{weight:y,minlen:g,nestingEdge:!0}),e.setEdge(h,d,{weight:y,minlen:g,nestingEdge:!0})}),e.parent(l)||e.setEdge(n,c,{weight:0,minlen:i+a[l]})}function eO(e){var n={};function o(r,i){var a=e.children(r);a&&a.length&&a.forEach(l=>o(l,i+1)),n[r]=i}return e.children().forEach(r=>o(r,1)),n}function tO(e){return e.edges().reduce((n,o)=>n+e.edge(o).weight,0)}function nO(e){var n=e.graph();e.removeNode(n.nestingRoot),delete n.nestingRoot,e.edges().forEach(o=>{var r=e.edge(o);r.nestingEdge&&e.removeEdge(o)})}let oO=qe;var rO=iO;function iO(e){function n(o){let r=e.children(o),i=e.node(o);if(r.length&&r.forEach(n),Object.hasOwn(i,"minRank")){i.borderLeft=[],i.borderRight=[];for(let a=i.minRank,l=i.maxRank+1;a<l;++a)Vp(e,"borderLeft","_bl",o,i,a),Vp(e,"borderRight","_br",o,i,a)}}e.children().forEach(n)}function Vp(e,n,o,r,i,a){let l={width:0,height:0,rank:a,borderType:n},s=i[n][a-1],c=oO.addDummyNode(e,"border",l,o);i[n][a]=c,e.setParent(c,r),s&&e.setEdge(s,c,{weight:1})}var aO={adjust:lO,undo:sO};function lO(e){let n=e.graph().rankdir.toLowerCase();(n==="lr"||n==="rl")&&Rp(e)}function sO(e){let n=e.graph().rankdir.toLowerCase();(n==="bt"||n==="rl")&&cO(e),(n==="lr"||n==="rl")&&(dO(e),Rp(e))}function Rp(e){e.nodes().forEach(n=>Dp(e.node(n))),e.edges().forEach(n=>Dp(e.edge(n)))}function Dp(e){let n=e.width;e.width=e.height,e.height=n}function cO(e){e.nodes().forEach(n=>Ll(e.node(n))),e.edges().forEach(n=>{let o=e.edge(n);o.points.forEach(Ll),Object.hasOwn(o,"y")&&Ll(o)})}function Ll(e){e.y=-e.y}function dO(e){e.nodes().forEach(n=>Fl(e.node(n))),e.edges().forEach(n=>{let o=e.edge(n);o.points.forEach(Fl),Object.hasOwn(o,"x")&&Fl(o)})}function Fl(e){let n=e.x;e.x=e.y,e.y=n}let Mp=qe;var uO=fO;function fO(e){let n={},o=e.nodes().filter(c=>!e.children(c).length),r=o.map(c=>e.node(c).rank),i=Mp.applyWithChunking(Math.max,r),a=Mp.range(i+1).map(()=>[]);function l(c){if(n[c])return;n[c]=!0;let d=e.node(c);a[d.rank].push(c),e.successors(c).forEach(l)}return o.sort((c,d)=>e.node(c).rank-e.node(d).rank).forEach(l),a}let pO=qe.zipObject;var mO=gO;function gO(e,n){let o=0;for(let r=1;r<n.length;++r)o+=hO(e,n[r-1],n[r]);return o}function hO(e,n,o){let r=pO(o,o.map((d,u)=>u)),i=n.flatMap(d=>e.outEdges(d).map(u=>({pos:r[u.w],weight:e.edge(u).weight})).sort((u,f)=>u.pos-f.pos)),a=1;for(;a<o.length;)a<<=1;let l=2*a-1;a-=1;let s=new Array(l).fill(0),c=0;return i.forEach(d=>{let u=d.pos+a;s[u]+=d.weight;let f=0;for(;u>0;)u%2&&(f+=s[u+1]),u=u-1>>1,s[u]+=d.weight;c+=d.weight*f}),c}var yO=_O;function _O(e,n=[]){return n.map(o=>{let r=e.inEdges(o);if(r.length){let i=r.reduce((a,l)=>{let s=e.edge(l),c=e.node(l.v);return{sum:a.sum+s.weight*c.order,weight:a.weight+s.weight}},{sum:0,weight:0});return{v:o,barycenter:i.sum/i.weight,weight:i.weight}}else return{v:o}})}let bO=qe;var wO=kO;function kO(e,n){let o={};e.forEach((i,a)=>{let l=o[i.v]={indegree:0,in:[],out:[],vs:[i.v],i:a};i.barycenter!==void 0&&(l.barycenter=i.barycenter,l.weight=i.weight)}),n.edges().forEach(i=>{let a=o[i.v],l=o[i.w];a!==void 0&&l!==void 0&&(l.indegree++,a.out.push(o[i.w]))});let r=Object.values(o).filter(i=>!i.indegree);return EO(r)}function EO(e){let n=[];function o(i){return a=>{a.merged||(a.barycenter===void 0||i.barycenter===void 0||a.barycenter>=i.barycenter)&&CO(i,a)}}function r(i){return a=>{a.in.push(i),--a.indegree===0&&e.push(a)}}for(;e.length;){let i=e.pop();n.push(i),i.in.reverse().forEach(o(i)),i.out.forEach(r(i))}return n.filter(i=>!i.merged).map(i=>bO.pick(i,["vs","i","barycenter","weight"]))}function CO(e,n){let o=0,r=0;e.weight&&(o+=e.barycenter*e.weight,r+=e.weight),n.weight&&(o+=n.barycenter*n.weight,r+=n.weight),e.vs=n.vs.concat(e.vs),e.barycenter=o/r,e.weight=r,e.i=Math.min(n.i,e.i),n.merged=!0}let NO=qe;var vO=SO;function SO(e,n){let o=NO.partition(e,u=>Object.hasOwn(u,"barycenter")),r=o.lhs,i=o.rhs.sort((u,f)=>f.i-u.i),a=[],l=0,s=0,c=0;r.sort(xO(!!n)),c=Lp(a,i,c),r.forEach(u=>{c+=u.vs.length,a.push(u.vs),l+=u.barycenter*u.weight,s+=u.weight,c=Lp(a,i,c)});let d={vs:a.flat(!0)};return s&&(d.barycenter=l/s,d.weight=s),d}function Lp(e,n,o){let r;for(;n.length&&(r=n[n.length-1]).i<=o;)n.pop(),e.push(r.vs),o++;return o}function xO(e){return(n,o)=>n.barycenter<o.barycenter?-1:n.barycenter>o.barycenter?1:e?o.i-n.i:n.i-o.i}let AO=yO,IO=wO,PO=vO;var TO=Fp;function Fp(e,n,o,r){let i=e.children(n),a=e.node(n),l=a?a.borderLeft:void 0,s=a?a.borderRight:void 0,c={};l&&(i=i.filter(p=>p!==l&&p!==s));let d=AO(e,i);d.forEach(p=>{if(e.children(p.v).length){let m=Fp(e,p.v,o,r);c[p.v]=m,Object.hasOwn(m,"barycenter")&&$O(p,m)}});let u=IO(d,o);OO(u,c);let f=PO(u,r);if(l&&(f.vs=[l,f.vs,s].flat(!0),e.predecessors(l).length)){let p=e.node(e.predecessors(l)[0]),m=e.node(e.predecessors(s)[0]);Object.hasOwn(f,"barycenter")||(f.barycenter=0,f.weight=0),f.barycenter=(f.barycenter*f.weight+p.order+m.order)/(f.weight+2),f.weight+=2}return f}function OO(e,n){e.forEach(o=>{o.vs=o.vs.flatMap(r=>n[r]?n[r].vs:r)})}function $O(e,n){e.barycenter!==void 0?(e.barycenter=(e.barycenter*e.weight+n.barycenter*n.weight)/(e.weight+n.weight),e.weight+=n.weight):(e.barycenter=n.barycenter,e.weight=n.weight)}let BO=kt.Graph,VO=qe;var RO=DO;function DO(e,n,o){let r=MO(e),i=new BO({compound:!0}).setGraph({root:r}).setDefaultNodeLabel(a=>e.node(a));return e.nodes().forEach(a=>{let l=e.node(a),s=e.parent(a);(l.rank===n||l.minRank<=n&&n<=l.maxRank)&&(i.setNode(a),i.setParent(a,s||r),e[o](a).forEach(c=>{let d=c.v===a?c.w:c.v,u=i.edge(d,a),f=u!==void 0?u.weight:0;i.setEdge(d,a,{weight:e.edge(c).weight+f})}),Object.hasOwn(l,"minRank")&&i.setNode(a,{borderLeft:l.borderLeft[n],borderRight:l.borderRight[n]}))}),i}function MO(e){for(var n;e.hasNode(n=VO.uniqueId("_root")););return n}var LO=FO;function FO(e,n,o){let r={},i;o.forEach(a=>{let l=e.parent(a),s,c;for(;l;){if(s=e.parent(l),s?(c=r[s],r[s]=l):(c=i,i=l),c&&c!==l){n.setEdge(c,l);return}l=s}})}let UO=uO,KO=mO,jO=TO,GO=RO,qO=LO,zO=kt.Graph,Si=qe;var HO=Up;function Up(e,n){if(n&&typeof n.customOrder=="function"){n.customOrder(e,Up);return}let o=Si.maxRank(e),r=Kp(e,Si.range(1,o+1),"inEdges"),i=Kp(e,Si.range(o-1,-1,-1),"outEdges"),a=UO(e);if(jp(e,a),n&&n.disableOptimalOrderHeuristic)return;let l=Number.POSITIVE_INFINITY,s;for(let c=0,d=0;d<4;++c,++d){YO(c%2?r:i,c%4>=2),a=Si.buildLayerMatrix(e);let u=KO(e,a);u<l&&(d=0,s=Object.assign({},a),l=u)}jp(e,s)}function Kp(e,n,o){return n.map(function(r){return GO(e,r,o)})}function YO(e,n){let o=new zO;e.forEach(function(r){let i=r.graph().root,a=jO(r,i,o,n);a.vs.forEach((l,s)=>r.node(l).order=s),qO(r,o,a.vs)})}function jp(e,n){Object.values(n).forEach(o=>o.forEach((r,i)=>e.node(r).order=i))}let WO=kt.Graph,qt=qe;var XO={positionX:l$};function ZO(e,n){let o={};function r(i,a){let l=0,s=0,c=i.length,d=a[a.length-1];return a.forEach((u,f)=>{let p=QO(e,u),m=p?e.node(p).order:c;(p||u===d)&&(a.slice(s,f+1).forEach(h=>{e.predecessors(h).forEach(y=>{let g=e.node(y),_=g.order;(_<l||m<_)&&!(g.dummy&&e.node(h).dummy)&&Gp(o,y,h)})}),s=f+1,l=m)}),a}return n.length&&n.reduce(r),o}function JO(e,n){let o={};function r(a,l,s,c,d){let u;qt.range(l,s).forEach(f=>{u=a[f],e.node(u).dummy&&e.predecessors(u).forEach(p=>{let m=e.node(p);m.dummy&&(m.order<c||m.order>d)&&Gp(o,p,u)})})}function i(a,l){let s=-1,c,d=0;return l.forEach((u,f)=>{if(e.node(u).dummy==="border"){let p=e.predecessors(u);p.length&&(c=e.node(p[0]).order,r(l,d,f,s,c),d=f,s=c)}r(l,d,l.length,c,a.length)}),l}return n.length&&n.reduce(i),o}function QO(e,n){if(e.node(n).dummy)return e.predecessors(n).find(o=>e.node(o).dummy)}function Gp(e,n,o){if(n>o){let i=n;n=o,o=i}let r=e[n];r||(e[n]=r={}),r[o]=!0}function e$(e,n,o){if(n>o){let r=n;n=o,o=r}return!!e[n]&&Object.hasOwn(e[n],o)}function t$(e,n,o,r){let i={},a={},l={};return n.forEach(s=>{s.forEach((c,d)=>{i[c]=c,a[c]=c,l[c]=d})}),n.forEach(s=>{let c=-1;s.forEach(d=>{let u=r(d);if(u.length){u=u.sort((p,m)=>l[p]-l[m]);let f=(u.length-1)/2;for(let p=Math.floor(f),m=Math.ceil(f);p<=m;++p){let h=u[p];a[d]===d&&c<l[h]&&!e$(o,d,h)&&(a[h]=d,a[d]=i[d]=i[h],c=l[h])}}})}),{root:i,align:a}}function n$(e,n,o,r,i){let a={},l=o$(e,n,o,i),s=i?"borderLeft":"borderRight";function c(f,p){let m=l.nodes(),h=m.pop(),y={};for(;h;)y[h]?f(h):(y[h]=!0,m.push(h),m=m.concat(p(h))),h=m.pop()}function d(f){a[f]=l.inEdges(f).reduce((p,m)=>Math.max(p,a[m.v]+l.edge(m)),0)}function u(f){let p=l.outEdges(f).reduce((h,y)=>Math.min(h,a[y.w]-l.edge(y)),Number.POSITIVE_INFINITY),m=e.node(f);p!==Number.POSITIVE_INFINITY&&m.borderType!==s&&(a[f]=Math.max(a[f],p))}return c(d,l.predecessors.bind(l)),c(u,l.successors.bind(l)),Object.keys(r).forEach(f=>a[f]=a[o[f]]),a}function o$(e,n,o,r){let i=new WO,a=e.graph(),l=s$(a.nodesep,a.edgesep,r);return n.forEach(s=>{let c;s.forEach(d=>{let u=o[d];if(i.setNode(u),c){var f=o[c],p=i.edge(f,u);i.setEdge(f,u,Math.max(l(e,d,c),p||0))}c=d})}),i}function r$(e,n){return Object.values(n).reduce((o,r)=>{let i=Number.NEGATIVE_INFINITY,a=Number.POSITIVE_INFINITY;Object.entries(r).forEach(([s,c])=>{let d=c$(e,s)/2;i=Math.max(c+d,i),a=Math.min(c-d,a)});const l=i-a;return l<o[0]&&(o=[l,r]),o},[Number.POSITIVE_INFINITY,null])[1]}function i$(e,n){let o=Object.values(n),r=qt.applyWithChunking(Math.min,o),i=qt.applyWithChunking(Math.max,o);["u","d"].forEach(a=>{["l","r"].forEach(l=>{let s=a+l,c=e[s];if(c===n)return;let d=Object.values(c),u=r-qt.applyWithChunking(Math.min,d);l!=="l"&&(u=i-qt.applyWithChunking(Math.max,d)),u&&(e[s]=qt.mapValues(c,f=>f+u))})})}function a$(e,n){return qt.mapValues(e.ul,(o,r)=>{if(n)return e[n.toLowerCase()][r];{let i=Object.values(e).map(a=>a[r]).sort((a,l)=>a-l);return(i[1]+i[2])/2}})}function l$(e){let n=qt.buildLayerMatrix(e),o=Object.assign(ZO(e,n),JO(e,n)),r={},i;["u","d"].forEach(l=>{i=l==="u"?n:Object.values(n).reverse(),["l","r"].forEach(s=>{s==="r"&&(i=i.map(f=>Object.values(f).reverse()));let c=(l==="u"?e.predecessors:e.successors).bind(e),d=t$(e,i,o,c),u=n$(e,i,d.root,d.align,s==="r");s==="r"&&(u=qt.mapValues(u,f=>-f)),r[l+s]=u})});let a=r$(e,r);return i$(r,a),a$(r,e.graph().align)}function s$(e,n,o){return(r,i,a)=>{let l=r.node(i),s=r.node(a),c=0,d;if(c+=l.width/2,Object.hasOwn(l,"labelpos"))switch(l.labelpos.toLowerCase()){case"l":d=-l.width/2;break;case"r":d=l.width/2;break}if(d&&(c+=o?d:-d),d=0,c+=(l.dummy?n:e)/2,c+=(s.dummy?n:e)/2,c+=s.width/2,Object.hasOwn(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":d=s.width/2;break;case"r":d=-s.width/2;break}return d&&(c+=o?d:-d),d=0,c}}function c$(e,n){return e.node(n).width}let qp=qe,d$=XO.positionX;var u$=f$;function f$(e){e=qp.asNonCompoundGraph(e),p$(e),Object.entries(d$(e)).forEach(([n,o])=>e.node(n).x=o)}function p$(e){let n=qp.buildLayerMatrix(e),o=e.graph().ranksep,r=0;n.forEach(i=>{const a=i.reduce((l,s)=>{const c=e.node(s).height;return l>c?l:c},0);i.forEach(l=>e.node(l).y=r+a/2),r+=a+o})}let zp=gT,Hp=wT,m$=GT,g$=qe.normalizeRanks,h$=YT,y$=qe.removeEmptyRanks,Yp=JT,_$=rO,Wp=aO,b$=HO,w$=u$,mt=qe,k$=kt.Graph;var E$=C$;function C$(e,n){let o=n&&n.debugTiming?mt.time:mt.notime;o("layout",()=>{let r=o(" buildLayoutGraph",()=>$$(e));o(" runLayout",()=>N$(r,o,n)),o(" updateInputGraph",()=>v$(e,r))})}function N$(e,n,o){n(" makeSpaceForEdgeLabels",()=>B$(e)),n(" removeSelfEdges",()=>j$(e)),n(" acyclic",()=>zp.run(e)),n(" nestingGraph.run",()=>Yp.run(e)),n(" rank",()=>m$(mt.asNonCompoundGraph(e))),n(" injectEdgeLabelProxies",()=>V$(e)),n(" removeEmptyRanks",()=>y$(e)),n(" nestingGraph.cleanup",()=>Yp.cleanup(e)),n(" normalizeRanks",()=>g$(e)),n(" assignRankMinMax",()=>R$(e)),n(" removeEdgeLabelProxies",()=>D$(e)),n(" normalize.run",()=>Hp.run(e)),n(" parentDummyChains",()=>h$(e)),n(" addBorderSegments",()=>_$(e)),n(" order",()=>b$(e,o)),n(" insertSelfEdges",()=>G$(e)),n(" adjustCoordinateSystem",()=>Wp.adjust(e)),n(" position",()=>w$(e)),n(" positionSelfEdges",()=>q$(e)),n(" removeBorderNodes",()=>K$(e)),n(" normalize.undo",()=>Hp.undo(e)),n(" fixupEdgeLabelCoords",()=>F$(e)),n(" undoCoordinateSystem",()=>Wp.undo(e)),n(" translateGraph",()=>M$(e)),n(" assignNodeIntersects",()=>L$(e)),n(" reversePoints",()=>U$(e)),n(" acyclic.undo",()=>zp.undo(e))}function v$(e,n){e.nodes().forEach(o=>{let r=e.node(o),i=n.node(o);r&&(r.x=i.x,r.y=i.y,r.rank=i.rank,n.children(o).length&&(r.width=i.width,r.height=i.height))}),e.edges().forEach(o=>{let r=e.edge(o),i=n.edge(o);r.points=i.points,Object.hasOwn(i,"x")&&(r.x=i.x,r.y=i.y)}),e.graph().width=n.graph().width,e.graph().height=n.graph().height}let S$=["nodesep","edgesep","ranksep","marginx","marginy"],x$={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},A$=["acyclicer","ranker","rankdir","align"],I$=["width","height","rank"],Xp={width:0,height:0},P$=["minlen","weight","width","height","labeloffset"],T$={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},O$=["labelpos"];function $$(e){let n=new k$({multigraph:!0,compound:!0}),o=Kl(e.graph());return n.setGraph(Object.assign({},x$,Ul(o,S$),mt.pick(o,A$))),e.nodes().forEach(r=>{let i=Kl(e.node(r));const a=Ul(i,I$);Object.keys(Xp).forEach(l=>{a[l]===void 0&&(a[l]=Xp[l])}),n.setNode(r,a),n.setParent(r,e.parent(r))}),e.edges().forEach(r=>{let i=Kl(e.edge(r));n.setEdge(r,Object.assign({},T$,Ul(i,P$),mt.pick(i,O$)))}),n}function B$(e){let n=e.graph();n.ranksep/=2,e.edges().forEach(o=>{let r=e.edge(o);r.minlen*=2,r.labelpos.toLowerCase()!=="c"&&(n.rankdir==="TB"||n.rankdir==="BT"?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function V$(e){e.edges().forEach(n=>{let o=e.edge(n);if(o.width&&o.height){let r=e.node(n.v),a={rank:(e.node(n.w).rank-r.rank)/2+r.rank,e:n};mt.addDummyNode(e,"edge-proxy",a,"_ep")}})}function R$(e){let n=0;e.nodes().forEach(o=>{let r=e.node(o);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,n=Math.max(n,r.maxRank))}),e.graph().maxRank=n}function D$(e){e.nodes().forEach(n=>{let o=e.node(n);o.dummy==="edge-proxy"&&(e.edge(o.e).labelRank=o.rank,e.removeNode(n))})}function M$(e){let n=Number.POSITIVE_INFINITY,o=0,r=Number.POSITIVE_INFINITY,i=0,a=e.graph(),l=a.marginx||0,s=a.marginy||0;function c(d){let u=d.x,f=d.y,p=d.width,m=d.height;n=Math.min(n,u-p/2),o=Math.max(o,u+p/2),r=Math.min(r,f-m/2),i=Math.max(i,f+m/2)}e.nodes().forEach(d=>c(e.node(d))),e.edges().forEach(d=>{let u=e.edge(d);Object.hasOwn(u,"x")&&c(u)}),n-=l,r-=s,e.nodes().forEach(d=>{let u=e.node(d);u.x-=n,u.y-=r}),e.edges().forEach(d=>{let u=e.edge(d);u.points.forEach(f=>{f.x-=n,f.y-=r}),Object.hasOwn(u,"x")&&(u.x-=n),Object.hasOwn(u,"y")&&(u.y-=r)}),a.width=o-n+l,a.height=i-r+s}function L$(e){e.edges().forEach(n=>{let o=e.edge(n),r=e.node(n.v),i=e.node(n.w),a,l;o.points?(a=o.points[0],l=o.points[o.points.length-1]):(o.points=[],a=i,l=r),o.points.unshift(mt.intersectRect(r,a)),o.points.push(mt.intersectRect(i,l))})}function F$(e){e.edges().forEach(n=>{let o=e.edge(n);if(Object.hasOwn(o,"x"))switch((o.labelpos==="l"||o.labelpos==="r")&&(o.width-=o.labeloffset),o.labelpos){case"l":o.x-=o.width/2+o.labeloffset;break;case"r":o.x+=o.width/2+o.labeloffset;break}})}function U$(e){e.edges().forEach(n=>{let o=e.edge(n);o.reversed&&o.points.reverse()})}function K$(e){e.nodes().forEach(n=>{if(e.children(n).length){let o=e.node(n),r=e.node(o.borderTop),i=e.node(o.borderBottom),a=e.node(o.borderLeft[o.borderLeft.length-1]),l=e.node(o.borderRight[o.borderRight.length-1]);o.width=Math.abs(l.x-a.x),o.height=Math.abs(i.y-r.y),o.x=a.x+o.width/2,o.y=r.y+o.height/2}}),e.nodes().forEach(n=>{e.node(n).dummy==="border"&&e.removeNode(n)})}function j$(e){e.edges().forEach(n=>{if(n.v===n.w){var o=e.node(n.v);o.selfEdges||(o.selfEdges=[]),o.selfEdges.push({e:n,label:e.edge(n)}),e.removeEdge(n)}})}function G$(e){var n=mt.buildLayerMatrix(e);n.forEach(o=>{var r=0;o.forEach((i,a)=>{var l=e.node(i);l.order=a+r,(l.selfEdges||[]).forEach(s=>{mt.addDummyNode(e,"selfedge",{width:s.label.width,height:s.label.height,rank:l.rank,order:a+ ++r,e:s.e,label:s.label},"_se")}),delete l.selfEdges})})}function q$(e){e.nodes().forEach(n=>{var o=e.node(n);if(o.dummy==="selfedge"){var r=e.node(o.e.v),i=r.x+r.width/2,a=r.y,l=o.x-i,s=r.height/2;e.setEdge(o.e,o.label),e.removeNode(n),o.label.points=[{x:i+2*l/3,y:a-s},{x:i+5*l/6,y:a-s},{x:i+l,y:a},{x:i+5*l/6,y:a+s},{x:i+2*l/3,y:a+s}],o.label.x=o.x,o.label.y=o.y}})}function Ul(e,n){return mt.mapValues(mt.pick(e,n),Number)}function Kl(e){var n={};return e&&Object.entries(e).forEach(([o,r])=>{typeof o=="string"&&(o=o.toLowerCase()),n[o]=r}),n}let z$=qe,H$=kt.Graph;var Y$={debugOrdering:W$};function W$(e){let n=z$.buildLayerMatrix(e),o=new H$({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(r=>{o.setNode(r,{label:r}),o.setParent(r,"layer"+e.node(r).rank)}),e.edges().forEach(r=>o.setEdge(r.v,r.w,{},r.name)),n.forEach((r,i)=>{let a="layer"+i;o.setNode(a,{rank:"same"}),r.reduce((l,s)=>(o.setEdge(l,s,{style:"invis"}),s))}),o}var X$="1.1.5",Z$={graphlib:kt,layout:E$,debug:Y$,util:{time:qe.time,notime:qe.notime},version:X$};const Zp=WI(Z$);function J$(){const e=(...o)=>{console.warn("TOASTER_PROVIDER is not provided",...o)},n=t.inject(Ec,e);return o=>n(o)}function xi(e,n,o){const r=n?Wt(e,o,n):void 0;return`${e.name}${r?`.${r.name}`:""}`}function Yo(e,n){const o=n(e.source),r=n(e.target);return[xi(o,e.sourceField,"output"),xi(r,e.targetField,"input")]}function jl(e,n,o,r,i){const a=i(e),l=i(o);return[xi(a,n,"output"),xi(l,r,"input")]}function Q$(e){t.provide(op,e)}function Jp(){return t.inject(op,void 0)}function eB(){const e=Jp();if(!e)throw new Error("Confirm modal not provided");return e}function Qp(e){const n=e.match(/^(input|output)s@(.*)$/);if(n)return{io:n[1],field:n[2]}}function tB(){const e={x1:Number.POSITIVE_INFINITY,y1:Number.POSITIVE_INFINITY,x2:Number.NEGATIVE_INFINITY,y2:Number.NEGATIVE_INFINITY};return[r=>{e.x1=Math.min(e.x1,r.x),e.y1=Math.min(e.y1,r.y),e.x2=Math.max(e.x2,r.x+r.width),e.y2=Math.max(e.y2,r.y+r.height)},()=>{const r={...e};return r.x1>r.x2&&(r.x1=r.x2=0),r.y1>r.y2&&(r.y1=r.y2=0),r}]}const nB={default:lk,hover:ck,selected:sk};let em,Gl;function Ai(e){const n=e.id===em?"selected":e.id===Gl?"hover":"default",o=nB[n],{markerEnd:r}=e,i=typeof r=="object"?{...r,color:o}:{type:r,color:o};return{...e,style:{...e.style,stroke:o,strokeWidth:n==="selected"?1.5:void 0},markerEnd:i,zIndex:n==="default"?void 0:1}}const[oB,rB]=Ue.createInjectionState(function(e){const{phase:n,flowId:o,layoutOptions:r,readonly:i}=e,{viewport:a,padding:l=Go.padding,gaps:s=Go.gaps}=r,{nodes:c=Go.gaps.nodes,edges:d=Go.gaps.edges,ranks:u=Go.gaps.ranks}=s,f=Oe(o),p=st(),m=Jp(),h=J$(),{i18n:{t:y}}=xe(),{findNode:g,fitView:_,deleteKeyCode:w,onNodeClick:b,onNodeDragStop:v,onEdgeClick:N,onConnect:E,onNodesChange:S,onEdgesChange:P,onEdgeUpdate:B,onEdgeMouseEnter:j,onEdgeMouseLeave:G,setEdges:T}=f;w.value=["Delete","Backspace"];const{state:Y,commit:I,moveNode:M,selectNode:R,removeNode:te,getNodeById:z,connectEdge:H,disconnectEdge:L,getInEdgesByNodeId:F,commit:Z,undo:Q}=p;function W(q,ee){const O=z(q.source),k=z(q.target);return!!(O&&k&&O.phase===ee&&k.phase===ee)}const ie=t.computed(()=>Y.value.nodes.filter(q=>q.phase===n).map(q=>({id:q.id,type:"flow",position:q.position,data:q,deletable:!Jd(q)}))),ae=t.computed(()=>Y.value.edges.filter(q=>W(q,n)).map(q=>{const ee=z(q.source),O=z(q.target);if(ee){if(!O)throw new Error(`Missing target node "${q.target}" for edge "${q.id}" in phase "${n}"`)}else throw new Error(`Missing source node "${q.source}" for edge "${q.id}" in phase "${n}"`);return Ai({id:q.id,source:q.source,target:q.target,sourceHandle:q.sourceField?`outputs@${q.sourceField}`:"output",targetHandle:q.targetField?`inputs@${q.targetField}`:"input",markerEnd:ii.ArrowClosed,data:q,updatable:!i})})),me=t.computed(()=>({padding:l/Math.max(t.toValue(a==null?void 0:a.width)??0,t.toValue(a==null?void 0:a.height)??0)}));b(({node:q})=>{console.debug("[useFlow] onNodeClick",t.toRaw(q))}),N(({edge:q})=>{console.debug("[useFlow] onEdgeClick",t.toRaw(q))});async function ge({source:q,sourceHandle:ee,target:O,targetHandle:k}){if(console.debug("[useFlow] onConnect",{source:q,sourceHandle:ee,target:O,targetHandle:k}),!ee||!k)return;const C=Qp(ee),A=Qp(k);if((C==null?void 0:C.io)==="input"||(A==null?void 0:A.io)==="output"||ee==="output"&&k==="output")return;const x=F(O);let U=!1,V=!1;const J=[],$=[],X=(A==null?void 0:A.io)==="input"?x.filter(le=>!le.targetField):x.filter(le=>!!le.targetField);X.length>0&&(U=!0,X.forEach(le=>{$.push(Yo(le,z)),L(le.id,!1)}));const D=(A==null?void 0:A.io)==="input"?x.filter(le=>le.targetField===A.field):x.filter(le=>!le.targetField);if(D.length>0){if(D.some(_e=>_e.source===q&&_e.target===O&&_e.targetField===(A==null?void 0:A.field)&&_e.sourceField===(C==null?void 0:C.field)))return;V=!0,D.forEach(_e=>{$.push(Yo(_e,z)),L(_e.id,!1)})}const pe=H({source:q,sourceField:C==null?void 0:C.field,target:O,targetField:A==null?void 0:A.field},!1);if(J.push(jl(q,C==null?void 0:C.field,O,A==null?void 0:A.field,z)),Z(),pe){if(U||V){if(!m)throw new Error("Expected confirm modal to be provided here when reachable");await m(y(U?"plugins.free-form.datakit.flow_editor.confirm.message.switch":"plugins.free-form.datakit.flow_editor.confirm.message.override"),J,$)||Q()}}else Q(),h({message:y("plugins.free-form.datakit.flow_editor.error.invalid_connection"),appearance:"danger"})}E(ge),S(q=>{q.filter(ee=>ee.type==="select").sort((ee,O)=>ee.selected===O.selected?0:ee.selected?1:-1).forEach(ee=>{R(ee.selected?ee.id:void 0)}),q.forEach(ee=>{ee.type==="remove"&&te(ee.id,!0)})}),v(({node:q})=>{q&&M(q.id,q.position)}),P(q=>{q.filter(O=>O.type==="select").sort((O,k)=>O.selected===k.selected?0:O.selected?1:-1).forEach(O=>{em=O.selected?O.id:void 0,T(k=>k.map(C=>C.id!==O.id||!C.markerEnd?C:Ai({...C,zIndex:O.selected?1:void 0})))}),q.forEach(O=>{O.type==="remove"&&L(O.id,!0)})}),j(({edge:q})=>{Gl=q.id,T(ee=>ee.map(O=>O.id!==q.id?O:Ai(O)))}),G(({edge:q})=>{Gl=void 0,T(ee=>ee.map(O=>O.id!==q.id?O:Ai(O)))}),B(({edge:q,connection:ee})=>{L(q.id,!1),ge(ee)});function ne(q=!0){let ee,O;const k=[],C=fe=>{switch(fe.data.name){case"request":{if(n!=="request")throw new Error(`Unexpected request node in ${n} phase`);if(ee)throw new Error("Duplicated request node in request phase");return ee=fe,!0}case"service_request":{if(n!=="request")throw new Error(`Unexpected service_request node in ${n} phase`);if(O)throw new Error("Duplicated service_request node in request phase");return O=fe,!0}case"service_response":{if(n!=="response")throw new Error(`Unexpected service_response node in ${n} phase`);if(O)throw new Error("Duplicated service_response node in response phase");return O=fe,!0}case"response":{if(n!=="response")throw new Error(`Unexpected response node in ${n} phase`);if(ee)throw new Error("Duplicated response node in response phase");return ee=fe,!0}default:return k.push(fe),!1}};let A;for(const fe of ie.value)if(!C(fe)&&k.length>0){A||(A=new Zp.graphlib.Graph({multigraph:!0}),A.setGraph({rankdir:n==="request"?"LR":"RL",nodesep:c,edgesep:d,ranksep:u}));const oe=g(fe.id);if(!oe)throw new Error(`Node ${fe.id} is missing from the graph in ${n} phase`);A.setNode(fe.id,{width:oe.dimensions.width,height:oe.dimensions.height})}if(!ee||!O)throw new Error(`One or more implicit nodes are missing from ${n} phase`);const x=g(ee.id),U=g(O.id);if(!x||!U)throw new Error(`One or more implicit nodes are missing from the graph in ${n} phase`);if(k.length>0){if(!A)throw new Error("dagreGraph should be defined here if reachable");const fe=new Set([ee.id,O.id]);for(const oe of ae.value)!fe.has(oe.source)&&!fe.has(oe.target)&&A.setEdge(oe.source,oe.target,{points:[]});Zp.layout(A)}const[V,J]=tB(),$=fe=>({x:fe.x-fe.width/2,y:fe.y-fe.height/2,width:fe.width,height:fe.height});if(k.length>0){if(!A)throw new Error("dagreGraph should be defined here if reachable");for(const fe of k){const oe=A.node(fe.id),be=$(oe);V(be),M(fe.data.id,{x:be.x,y:be.y},!1)}}const X=J(),D=X.x2-X.x1,pe=X.y2-X.y1,le=Math.max(0,Math.min(t.toValue(a==null?void 0:a.width)??Number.POSITIVE_INFINITY,zI)-D-2*c-x.dimensions.width-U.dimensions.width-2*l),_e=X.y1+pe/2;M(ee.data.id,{x:X.x1-c-le/2-x.dimensions.width,y:_e-x.dimensions.height/2},!1),M(O.data.id,{x:X.x2+c+le/2,y:_e-U.dimensions.height/2},!1),q&&I(`autolayout-${o}`)}function re(q){_({...me.value,...q})}return{vueFlowStore:f,editorStore:p,readonly:i,nodes:ie,edges:ae,autoLayout:ne,fitViewParams:me,fitView:re}}),Ii=Ee(t.defineComponent({__name:"HandleTwig",props:{color:{},position:{default:()=>ye.Left},size:{default:()=>Number.parseFloat(fk)},type:{}},setup(e){t.useCssVars(o=>({"753622c4":o.color}));const n=t.computed(()=>({width:`${e.size}px`,minWidth:`${e.size}px`}));return(o,r)=>(t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["handle-twig",[o.type,o.position===t.unref(ye).Left?"left":"right"]]),style:t.normalizeStyle(n.value)},null,6))}}),[["__scopeId","data-v-eb2bc3f2"]]),tm=Ee(t.defineComponent({__name:"NodeBadge",props:{type:{},size:{},iconOnly:{type:Boolean}},setup(e){const n=t.computed(()=>{var i;if(!Lt(e.type))return((i=Tr[e.type])==null?void 0:i.icon)??void 0}),o=t.computed(()=>eN(e.type)),r=t.computed(()=>{switch(e.type){case"call":return"warning";case"jq":return"decorative";case"exit":return"danger";case"property":return"success";case"static":return"info";default:return"neutral"}});return(i,a)=>{const l=t.resolveComponent("KBadge");return t.openBlock(),t.createBlock(l,{appearance:r.value,class:t.normalizeClass({"icon-only":i.iconOnly}),size:i.size},{icon:t.withCtx(()=>[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(n.value)))]),default:t.withCtx(()=>[t.createTextVNode(" "+t.toDisplayString(o.value),1)]),_:1},8,["appearance","class","size"])}}}),[["__scopeId","data-v-aae106a9"]]);let Qn=null;function nm(){var n;if(Qn)return Qn;if(typeof navigator>"u")return Qn="windows";const e=((n=navigator.userAgentData)==null?void 0:n.platform)||navigator.platform||navigator.userAgent;return/Mac|iPhone|iPad|iPod/i.test(e)?Qn="mac":/Linux/i.test(e)&&!/Android/i.test(e)?Qn="linux":Qn="windows"}const iB={Shift:"⇧",Alt:"⌥",Ctrl:"⌃",Meta:"⌘",Mod:"⌘",Enter:"↩",ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Tab:"⇥",Esc:"⎋",Space:"Space",Delete:"⌫"},aB={Shift:"Shift",Alt:"Alt",Ctrl:"Ctrl",Meta:"Win",Mod:"Ctrl",Enter:"Enter",ArrowUp:"Up",ArrowDown:"Down",ArrowLeft:"Left",ArrowRight:"Right",Tab:"Tab",Esc:"Esc",Space:"Spacebar",Delete:"Delete"},lB={Shift:"Shift",Alt:"Alt",Ctrl:"Ctrl",Meta:"Super",Mod:"Ctrl",Enter:"Enter",ArrowUp:"Up",ArrowDown:"Down",ArrowLeft:"Left",ArrowRight:"Right",Tab:"Tab",Esc:"Esc",Space:"Space",Delete:"Delete"};function sB(e,n={}){const o=n.platform??nm(),r=n.joiner??(o==="mac"?"":" + "),i=o==="mac"?iB:o==="linux"?lB:aB;return(Array.isArray(e)?e:e[o]).map(l=>l in i?i[l]:l).join(r)}const cB={key:0,class:"label"},dB={class:"keys"},ql=Ee(t.defineComponent({__name:"HotkeyLabel",props:{label:{},keys:{},reverse:{type:Boolean}},setup(e){const n=sB(e.keys);return(o,r)=>(t.openBlock(),t.createElementBlock("span",{class:t.normalizeClass(["dk-hotkey-label",{reverse:o.reverse}])},[o.label?(t.openBlock(),t.createElementBlock("span",cB,t.toDisplayString(o.label),1)):t.createCommentVNode("",!0),t.createElementVNode("kbd",dB,t.toDisplayString(t.unref(n)),1)],2))}}),[["__scopeId","data-v-cc70d56b"]]),uB={class:"body"},fB={class:"name"},pB={class:"handle"},mB={class:"handle-label-wrapper"},gB={class:"handle-label-wrapper"},hB={class:"handle-label text"},yB={class:"handle"},_B={class:"handle-label-wrapper"},bB={class:"handle-label-wrapper"},wB={class:"handle-label text"},om=Ee(t.defineComponent({__name:"FlowNode",props:{data:{},error:{type:Boolean}},setup(e){const{t:n}=Fe.createI18n("en-us",He),o=rB(),{getInEdgesByNodeId:r,getOutEdgesByNodeId:i,toggleExpanded:a,removeNode:l}=st(),s=t.computed(()=>La(e.data.type)),c=t.computed(()=>e.data.fields.input.length>0),d=t.computed(()=>e.data.fields.output.length>0),u=t.computed(()=>c.value&&r(e.data.id).every(S=>S.targetField===void 0)),f=t.computed(()=>d.value&&i(e.data.id).every(S=>S.sourceField===void 0)),p=t.computed(()=>e.data.expanded.input??!1),m=t.computed(()=>e.data.expanded.output??!1),h=t.computed(()=>{var S,P;if(e.data.type==="property"){const B=(S=e.data.config)==null?void 0:S.property;return Pl(B)}return(P=s.value.io)==null?void 0:P.input}),y=t.computed(()=>{var S,P;if(e.data.type==="property"){const B=(S=e.data.config)==null?void 0:S.property;return Il(B)}return(P=s.value.io)==null?void 0:P.output}),g=t.computed(()=>Jd(e.data)),_=t.computed(()=>e.data.phase==="response"),w=t.computed(()=>e.data.phase==="request"?ye.Left:ye.Right),b=t.computed(()=>e.data.phase==="request"?ye.Right:ye.Left),v=t.computed(()=>g.value?n(`plugins.free-form.datakit.flow_editor.node_types.${e.data.type}.name`):e.data.name),N=t.computed(()=>g.value?rk:ik);function E(S){o!=null&&o.readonly||S==="input"&&!u.value||S==="output"&&!f.value||a(e.data.id,S)}return t.watch(u,S=>{S||a(e.data.id,"input",!0,!1)},{immediate:!0}),t.watch(f,S=>{S||a(e.data.id,"output",!0,!1)},{immediate:!0}),t.watch(()=>e.data.fields.input,(S,P)=>{go(S,P)||a(e.data.id,"input",S.length>0,!1)},{deep:!0}),t.watch(()=>e.data.fields.output,(S,P)=>{go(S,P)||a(e.data.id,"output",S.length>0,!1)},{deep:!0}),(S,P)=>(t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["flow-node",{reversed:_.value,implicit:g.value}])},[t.createElementVNode("div",uB,[g.value?t.createCommentVNode("",!0):(t.openBlock(),t.createBlock(t.unref(Pe.KTooltip),{key:0,class:"badge",placement:"top",text:S.data.type},{default:t.withCtx(()=>[t.createVNode(tm,{"icon-only":"",size:"small",type:S.data.type},null,8,["type"])]),_:1},8,["text"])),t.createElementVNode("div",fB,t.toDisplayString(v.value),1),S.error?(t.openBlock(),t.createBlock(t.unref(Ne.WarningIcon),{key:1,class:"error-icon",color:t.unref(Uc),size:16},null,8,["color"])):t.createCommentVNode("",!0),g.value?t.createCommentVNode("",!0):(t.openBlock(),t.createBlock(t.unref(Pe.KDropdown),{key:2,class:"menu","kpop-attributes":{offset:"4px"},width:"160"},{items:t.withCtx(()=>[t.createVNode(t.unref(Pe.KDropdownItem),{danger:"",onClick:P[0]||(P[0]=B=>t.unref(l)(S.data.id))},{default:t.withCtx(()=>[t.createVNode(ql,{keys:t.unref(Ua).delete,label:t.unref(n)("plugins.free-form.datakit.flow_editor.actions.delete")},null,8,["keys","label"])]),_:1})]),default:t.withCtx(()=>[t.createVNode(t.unref(Pe.KButton),{appearance:"tertiary",class:"menu-trigger",icon:"",size:"small"},{default:t.withCtx(()=>[t.createVNode(t.unref(Ne.MoreIcon),{color:t.unref(dk)},null,8,["color"])]),_:1})]),_:1}))]),t.createElementVNode("div",{class:t.normalizeClass(["handles",{reversed:_.value}])},[h.value?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["input-handles",{"has-fields":c.value}])},[t.createElementVNode("div",pB,[t.createVNode(t.unref(tn),{id:"input",position:w.value,type:"target"},null,8,["position"]),t.createElementVNode("div",mB,[t.createElementVNode("div",{class:t.normalizeClass(["handle-label trigger",{collapsible:u.value}]),onClick:P[1]||(P[1]=t.withModifiers(B=>E("input"),["stop"]))},[P[3]||(P[3]=t.createElementVNode("div",{class:"text"}," inputs ",-1)),c.value?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[p.value?t.createCommentVNode("",!0):(t.openBlock(),t.createBlock(t.unref(Ne.UnfoldMoreIcon),{key:0,size:t.unref(bo)},null,8,["size"])),p.value?(t.openBlock(),t.createBlock(t.unref(Ne.UnfoldLessIcon),{key:1,color:u.value?void 0:t.unref(Kc),size:t.unref(bo)},null,8,["color","size"])):t.createCommentVNode("",!0)],64)):t.createCommentVNode("",!0)],2),c.value&&p.value?(t.openBlock(),t.createBlock(Ii,{key:0,color:N.value,position:w.value,type:"bar"},null,8,["color","position"])):t.createCommentVNode("",!0)])]),c.value&&p.value?(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:0},t.renderList(S.data.fields.input,(B,j)=>(t.openBlock(),t.createElementBlock("div",{key:`inputs-${B.id}`,class:"handle indented"},[t.createVNode(t.unref(tn),{id:`inputs@${B.id}`,position:w.value,type:"target"},null,8,["id","position"]),t.createElementVNode("div",gB,[t.createElementVNode("div",hB,t.toDisplayString(B.name),1),t.createVNode(Ii,{color:N.value,position:w.value,type:j<S.data.fields.input.length-1?"trident":"corner"},null,8,["color","position","type"])])]))),128)):t.createCommentVNode("",!0)],2)):t.createCommentVNode("",!0),y.value?(t.openBlock(),t.createElementBlock("div",{key:1,class:t.normalizeClass(["output-handles",{"has-fields":d.value}])},[t.createElementVNode("div",yB,[t.createElementVNode("div",_B,[t.createElementVNode("div",{class:t.normalizeClass(["handle-label trigger",{collapsible:f.value}]),onClick:P[2]||(P[2]=t.withModifiers(B=>E("output"),["stop"]))},[P[4]||(P[4]=t.createElementVNode("div",{class:"text"}," outputs ",-1)),d.value?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[m.value?t.createCommentVNode("",!0):(t.openBlock(),t.createBlock(t.unref(Ne.UnfoldMoreIcon),{key:0,size:t.unref(bo)},null,8,["size"])),m.value?(t.openBlock(),t.createBlock(t.unref(Ne.UnfoldLessIcon),{key:1,color:f.value?void 0:t.unref(Kc),size:t.unref(bo)},null,8,["color","size"])):t.createCommentVNode("",!0)],64)):t.createCommentVNode("",!0)],2),d.value&&m.value?(t.openBlock(),t.createBlock(Ii,{key:0,color:N.value,position:b.value,type:"bar"},null,8,["color","position"])):t.createCommentVNode("",!0)]),t.createVNode(t.unref(tn),{id:"output",position:b.value,type:"source"},null,8,["position"])]),d.value&&m.value?(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:0},t.renderList(S.data.fields.output,(B,j)=>(t.openBlock(),t.createElementBlock("div",{key:`outputs-${B.id}`,class:"handle indented"},[t.createElementVNode("div",bB,[t.createElementVNode("div",wB,t.toDisplayString(B.name),1),t.createVNode(Ii,{color:N.value,position:b.value,type:j<S.data.fields.output.length-1?"trident":"corner"},null,8,["color","position","type"])]),t.createVNode(t.unref(tn),{id:`outputs@${B.id}`,position:b.value,type:"source"},null,8,["id","position"])]))),128)):t.createCommentVNode("",!0)],2)):t.createCommentVNode("",!0)],2)],2))}}),[["__scopeId","data-v-30aa85b4"]]),kB={key:0,class:"dk-flow-mask"},rm=Ee(t.defineComponent({__name:"FlowCanvas",props:{flowId:{},phase:{},readonly:{type:Boolean}},emits:["initialized"],setup(e,{expose:n,emit:o}){const r=o,i=t.useTemplateRef("flowCanvas"),a=Ue.useElementBounding(i),{i18n:{t:l}}=xe(),{vueFlowStore:s,editorStore:c,nodes:d,edges:u,autoLayout:f,fitViewParams:p,fitView:m}=oB({phase:e.phase,flowId:e.flowId,layoutOptions:{viewport:{width:a.width,height:a.height}},readonly:e.readonly}),{addNode:h,selectNode:y,propertiesPanelOpen:g,newCreatedNodeId:_,invalidConfigNodeIds:w}=c,{project:b,vueFlowRef:v,addSelectedNodes:N,getNodes:E}=s,S=t.ref(!1);async function P(Y){y(Y),await t.nextTick();const I=E.value.find(M=>M.id===Y);N(I?[I]:[])}function B(){e.readonly||(g.value=!0)}function j(Y){e.readonly||S.value||Y.preventDefault()}function G(Y){var Q,W;if(e.readonly||S.value)return;const I=(Q=Y.dataTransfer)==null?void 0:Q.getData(xo);if(!I)return;Y.preventDefault();const M=JSON.parse(I);if(M.action!=="create-node")return;const{top:R=0,left:te=0}=((W=v.value)==null?void 0:W.getBoundingClientRect())||{},z=b({x:Y.clientX-te,y:Y.clientY-R}),{type:H,anchor:L}=M.data,F={type:H,phase:e.phase,position:{x:z.x-L.offsetX,y:z.y-L.offsetY}},Z=h(F);P(Z),Z&&(_.value=Z,g.value=!0)}const T=()=>{f(),t.nextTick(()=>m())};if(e.phase==="response"&&!e.readonly){Ue.useEventListener("dragstart",I=>{var te;const M=(te=I.dataTransfer)==null?void 0:te.types.find(z=>z.startsWith(`${xo}/`));if(!M)return;const R=M.replace(`${xo}/`,"");(R==="call"||R==="exit")&&(S.value=!0)});const{start:Y}=Ue.useTimeoutFn(()=>{S.value=!1},80);Ue.useEventListener("dragover",()=>{Y()}),Ue.useEventListener("dragend",()=>{S.value=!1})}return n({autoLayout:f,fitView:m}),(Y,I)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"flowCanvas",ref:i,class:"dk-flow-canvas"},[t.createVNode(t.unref(ep),{id:Y.flowId,class:t.normalizeClass(["flow",{readonly:Y.readonly}]),edges:t.unref(u),"elements-selectable":!Y.readonly,"max-zoom":t.unref(HI),"min-zoom":t.unref(YI),"multi-selection-key-code":null,nodes:t.unref(d),"nodes-connectable":!Y.readonly,"nodes-draggable":!Y.readonly,"pan-on-drag":Y.readonly?!1:void 0,"pan-on-scroll":Y.readonly?!1:void 0,"zoom-on-double-click":Y.readonly?!1:void 0,"zoom-on-pinch":Y.readonly?!1:void 0,"zoom-on-scroll":Y.readonly?!1:void 0,onDragover:j,onDrop:G,onNodeClick:B,onNodesInitialized:I[0]||(I[0]=M=>r("initialized"))},{"node-flow":t.withCtx(M=>[t.createVNode(om,{data:M.data,error:t.unref(w).has(M.data.id)},null,8,["data","error"])]),default:t.withCtx(()=>[t.createVNode(t.unref(bI)),Y.readonly?t.createCommentVNode("",!0):(t.openBlock(),t.createBlock(t.unref(qI),{key:0,"fit-view-params":t.unref(p),position:"bottom-left","show-interactive":!1},{default:t.withCtx(()=>[t.createElementVNode("button",{class:"vue-flow__controls-button vue-flow__controls-interactive custom",onClick:T},[t.createVNode(t.unref(Ne.SparklesIcon),{size:18})])]),_:1},8,["fit-view-params"]))]),_:1},8,["id","class","edges","elements-selectable","max-zoom","min-zoom","nodes","nodes-connectable","nodes-draggable","pan-on-drag","pan-on-scroll","zoom-on-double-click","zoom-on-pinch","zoom-on-scroll"]),S.value?(t.openBlock(),t.createElementBlock("div",kB,t.toDisplayString(t.unref(l)("plugins.free-form.datakit.flow_editor.phase_mask_help")),1)):t.createCommentVNode("",!0)],512))}}),[["__scopeId","data-v-9fdbf607"]]),im=Ee(t.defineComponent({__name:"FlowPanels",props:{readonly:{type:Boolean},resizable:{type:Boolean}},setup(e,{expose:n}){const o=t.ref([!1,!1]),{state:r,markAsLayoutCompleted:i,commit:a,clear:l}=st(),s=t.useId(),c=`${s}-request`,d=`${s}-response`,u=Oe(c),f=Oe(d);function p(Z,Q){const{onPaneClick:W,onNodesChange:ie,onEdgesChange:ae,getSelectedNodes:me,getSelectedEdges:ge}=Z,{removeSelectedElements:ne}=Q;function re(q){if(!q){ne();return}q.some(ee=>ee.type==="select")&&me.value.length+ge.value.length>0&&ne()}ie(re),ae(re),W(()=>re())}p(u,f),p(f,u);const m=t.useTemplateRef("flowPanels"),h=t.useTemplateRef("requestLabel"),y=t.useTemplateRef("requestCanvasContainer"),g=t.useTemplateRef("requestFlow"),_=t.useTemplateRef("resizeHandle"),w=t.useTemplateRef("responseLabel"),b=t.useTemplateRef("responseCanvasContainer"),v=t.useTemplateRef("responseFlow"),N=Ue.useElementBounding(m),E=Ue.useElementBounding(h),S=Ue.useElementBounding(y),P=Ue.useElementBounding(_),B=Ue.useElementBounding(w),j=Ue.useElementBounding(b),G=t.computed(()=>Math.max(30,N.height.value*.03)),T=t.computed(()=>S.height.value<G.value),Y=t.computed(()=>j.height.value<G.value),I=t.ref("50%"),M=t.ref("50%"),R=()=>{e.resizable&&(T.value?(I.value="50%",M.value="50%"):(I.value="0",M.value="100%"))},te=()=>{e.resizable&&(Y.value?(I.value="50%",M.value="50%"):(I.value="100%",M.value="0"))},z=t.computed(()=>N.height.value-E.height.value-P.height.value-B.height.value),{isDragging:H}=Ue.useDraggable(_,{onMove(Z){if(!e.resizable)return;const Q=Math.max(0,Z.y-S.top.value),W=Math.min(1,Math.max(0,Q/z.value));I.value=`${W*100}%`,M.value=`${(1-W)*100}%`},onEnd(){e.resizable&&(S.height.value<G.value?(I.value="0",M.value="100%"):j.height.value<G.value&&(I.value="100%",M.value="0"))}}),L=()=>{t.nextTick(()=>{var Z,Q;(Z=g.value)==null||Z.fitView(),(Q=v.value)==null||Q.fitView()})},F=t.watch(o,([Z,Q])=>{var W,ie;Z&&Q&&(r.value.needLayout&&((W=g.value)==null||W.autoLayout(!1),(ie=v.value)==null||ie.autoLayout(!1),i(),a(),l()),L(),F.stop())},{deep:!0});return n({fitView:L}),(Z,Q)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"flowPanels",ref:m,class:"flow-panels"},[t.createElementVNode("div",{ref_key:"requestLabel",ref:h,class:t.normalizeClass(["label request",{resizable:Z.resizable}]),onClick:R},[Z.resizable?(t.openBlock(),t.createBlock(t.unref(Ne.ChevronDownIcon),{key:0,class:t.normalizeClass(["icon",{collapsed:T.value}])},null,8,["class"])):t.createCommentVNode("",!0),Q[2]||(Q[2]=t.createElementVNode("div",{class:"label-content"}," Request ",-1))],2),t.createElementVNode("div",{ref_key:"requestCanvasContainer",ref:y,class:t.normalizeClass(["canvas",{dragging:t.unref(H)}]),style:t.normalizeStyle({flexBasis:I.value})},[t.createVNode(rm,{ref_key:"requestFlow",ref:g,"flow-id":c,phase:"request",readonly:Z.readonly,onInitialized:Q[0]||(Q[0]=W=>o.value[0]=!0)},null,8,["readonly"])],6),t.createElementVNode("div",{ref_key:"resizeHandle",ref:_,class:t.normalizeClass(["resize-handle",{resizable:Z.resizable}])},null,2),t.createElementVNode("div",{ref_key:"responseLabel",ref:w,class:t.normalizeClass(["label response",{dragging:t.unref(H),resizable:Z.resizable}]),onClick:te},[Z.resizable?(t.openBlock(),t.createBlock(t.unref(Ne.ChevronDownIcon),{key:0,class:t.normalizeClass(["icon",{collapsed:Y.value}])},null,8,["class"])):t.createCommentVNode("",!0),Q[3]||(Q[3]=t.createElementVNode("div",{class:"label-content"}," Response ",-1))],2),t.createElementVNode("div",{ref_key:"responseCanvasContainer",ref:b,class:t.normalizeClass(["canvas response",{dragging:t.unref(H)}]),style:t.normalizeStyle({flexBasis:M.value})},[t.createVNode(rm,{ref_key:"responseFlow",ref:v,"flow-id":d,phase:"response",readonly:Z.readonly,onInitialized:Q[1]||(Q[1]=W=>o.value[1]=!0)},null,8,["readonly"])],6)],512))}}),[["__scopeId","data-v-b469482f"]]),EB={class:"dk-confirm-modal-body"},CB={class:"dk-confirm-modal-connections"},NB=Ee(t.defineComponent({__name:"ConflictModal",props:{title:{},message:{},addedConnections:{},removedConnections:{}},emits:["cancel","confirm"],setup(e,{expose:n,emit:o}){const{i18n:{t:r}}=xe(),i=o,a=t.ref(!1),l=t.ref(e.message),s=t.ref(e.addedConnections??[]),c=t.ref(e.removedConnections??[]);let d=null;function u(){a.value=!1,i("cancel"),d==null||d(!1)}function f(){a.value=!1,i("confirm"),d==null||d(!0)}async function p(m,h,y){return l.value=m,s.value=h??[],c.value=y??[],a.value=!0,await new Promise(g=>{d=g})}return n({open:p}),(m,h)=>{const y=t.resolveComponent("KModal");return t.openBlock(),t.createBlock(y,{"action-button-text":t.unref(r)("plugins.free-form.datakit.flow_editor.confirm.proceed"),"close-on-backdrop-click":"","max-width":"660px",title:m.title??t.unref(r)("plugins.free-form.datakit.flow_editor.confirm.title"),visible:a.value,"z-index":9999,onCancel:u,onProceed:f},{default:t.withCtx(()=>[t.createElementVNode("div",EB,[t.createElementVNode("p",null,t.toDisplayString(l.value),1),t.createElementVNode("p",null,t.toDisplayString(t.unref(r)("plugins.free-form.datakit.flow_editor.confirm.message.confirm")),1),t.createElementVNode("div",CB,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(s.value??[],([g,_])=>(t.openBlock(),t.createElementBlock("div",{key:`${g}-${_}`},[t.createVNode(t.unref(Ne.AddIcon),{color:t.unref(ak)},null,8,["color"]),t.createElementVNode("span",null,t.toDisplayString(g),1),h[0]||(h[0]=t.createTextVNode(" → ",-1)),t.createElementVNode("span",null,t.toDisplayString(_),1)]))),128)),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(c.value??[],([g,_])=>(t.openBlock(),t.createElementBlock("div",{key:`${g}-${_}`},[t.createVNode(t.unref(Ne.RemoveIcon),{color:t.unref(Uc)},null,8,["color"]),t.createElementVNode("span",null,t.toDisplayString(g),1),h[1]||(h[1]=t.createTextVNode(" → ",-1)),t.createElementVNode("span",null,t.toDisplayString(_),1)]))),128))])])]),_:1},8,["action-button-text","title","visible"])}}}),[["__scopeId","data-v-9874f282"]]),vB={class:"dk-editor-nav"},SB={class:"top"},xB={class:"bottom"},AB=Ee(t.defineComponent({__name:"EditorNav",emits:["back"],setup(e,{emit:n}){const{t:o}=Fe.createI18n("en-us",He),r=n,i=[{label:o("plugins.free-form.datakit.flow_editor.return_to_config"),icon:Ne.ArrowLeftIcon,onClick:()=>r("back")}],{sidePanelExpanded:a}=ja(),l=t.computed(()=>a.value?o("plugins.free-form.datakit.flow_editor.collapse_panel"):o("plugins.free-form.datakit.flow_editor.expand_panel")),s=t.ref(!1);function c(){a.value=!a.value}return(d,u)=>(t.openBlock(),t.createElementBlock("nav",vB,[t.createElementVNode("div",SB,[(t.openBlock(),t.createElementBlock(t.Fragment,null,t.renderList(i,({label:f,to:p,icon:m,onClick:h})=>t.createVNode(t.unref(Pe.KTooltip),{key:f,"kpop-attributes":{offset:"10px"},label:f,placement:"right"},{default:t.withCtx(()=>[(t.openBlock(),t.createBlock(t.unref(Pe.KButton),{key:f,appearance:"none",class:"nav-item",icon:"",to:p,onClick:h},{default:t.withCtx(()=>[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(m),{decorative:"",size:t.unref(wa)},null,8,["size"]))]),_:2},1032,["to","onClick"]))]),_:2},1032,["label"])),64))]),t.createElementVNode("div",xB,[t.createElementVNode("div",{class:t.normalizeClass(["side-panel-toggle",{expanded:t.unref(a)}]),onTransitionend:u[0]||(u[0]=t.withModifiers(f=>s.value=!1,["self"])),onTransitionstart:u[1]||(u[1]=t.withModifiers(f=>s.value=!0,["self"]))},[t.createVNode(t.unref(Pe.KTooltip),{label:s.value?void 0:l.value,placement:t.unref(a)?"left":"right"},{default:t.withCtx(()=>[t.createVNode(t.unref(Pe.KButton),{appearance:"none",class:"nav-item nav-item-toggle",icon:"",size:"large",onClick:c},{default:t.withCtx(()=>[t.unref(a)?(t.openBlock(),t.createBlock(t.unref(Ne.ChevronDoubleLeftIcon),{key:0,decorative:"",size:t.unref(wa)},null,8,["size"])):(t.openBlock(),t.createBlock(t.unref(Ne.ChevronDoubleRightIcon),{key:1,decorative:"",size:t.unref(wa)},null,8,["size"]))]),_:1})]),_:1},8,["label","placement"])],34)])]))}}),[["__scopeId","data-v-2915b6fa"]]);function IB(e){return e.closest('input, textarea, [contenteditable]:not([contenteditable="false"])')!=null}function PB({undo:e,redo:n,cut:o,copy:r,paste:i,enabled:a=!0}){if(typeof window>"u"||!e&&!n&&!o&&!r&&!i)return;const l=nm();return Ue.useEventListener(window,"keydown",s=>{if(!t.toValue(a)||IB(s.target))return;const c=s.key.toLowerCase();if(l==="mac"?s.metaKey:s.ctrlKey)switch(c){case"z":{if(e&&!s.shiftKey){s.preventDefault(),e();return}if(n&&s.shiftKey){s.preventDefault(),n();return}break}case"y":{if(l==="windows"&&n){s.preventDefault(),n();return}break}case"x":{if(o){s.preventDefault(),o();return}break}case"c":{if(r){s.preventDefault(),r();return}break}case"v":{if(i){s.preventDefault(),i();return}break}}},{passive:!1})}const TB={class:"dk-editor-main"},OB={class:"header"},$B={class:"actions"},BB={ref:"canvasContainer",class:"body"},VB=Ee(t.defineComponent({__name:"EditorMain",setup(e){const{t:n}=Fe.createI18n("en-us",He),{modalOpen:o,undo:r,redo:i,canUndo:a,canRedo:l}=st();function s(){o.value=!1}return PB({enabled:o,undo:r,redo:i}),(c,d)=>{const u=t.resolveComponent("KTooltip");return t.openBlock(),t.createElementBlock("div",TB,[t.createElementVNode("header",OB,[t.createElementVNode("div",$B,[t.createVNode(u,{"z-index":1e4},{content:t.withCtx(()=>[t.createVNode(ql,{keys:t.unref(Ua).undo,label:t.unref(n)("plugins.free-form.datakit.flow_editor.actions.undo"),reverse:""},null,8,["keys","label"])]),default:t.withCtx(()=>[t.createVNode(t.unref(Pe.KButton),{appearance:"tertiary",disabled:!t.unref(a),icon:"",onClick:t.unref(r)},{default:t.withCtx(()=>[t.createVNode(t.unref(Ne.RedoIcon),{class:"flip"})]),_:1},8,["disabled","onClick"])]),_:1}),t.createVNode(u,{"z-index":1e4},{content:t.withCtx(()=>[t.createVNode(ql,{keys:t.unref(Ua).redo,label:t.unref(n)("plugins.free-form.datakit.flow_editor.actions.redo"),reverse:""},null,8,["keys","label"])]),default:t.withCtx(()=>[t.createVNode(t.unref(Pe.KButton),{appearance:"tertiary",disabled:!t.unref(l),icon:"",onClick:t.unref(i)},{default:t.withCtx(()=>[t.createVNode(t.unref(Ne.RedoIcon))]),_:1},8,["disabled","onClick"])]),_:1}),d[0]||(d[0]=t.createElementVNode("div",{class:"divider"},null,-1)),t.createVNode(t.unref(Pe.KButton),{appearance:"tertiary",target:"_blank",to:"https://developer.konghq.com/plugins/datakit/"},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(n)("plugins.free-form.datakit.flow_editor.actions.view_docs"))+" ",1),t.createVNode(t.unref(Ne.ExternalLinkIcon))]),_:1}),t.createVNode(t.unref(Pe.KButton),{onClick:s},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(n)("plugins.free-form.datakit.flow_editor.actions.done")),1)]),_:1})])]),t.createElementVNode("div",BB,[t.createVNode(im,{resizable:""})],512)])}}}),[["__scopeId","data-v-35b58163"]]),RB={class:"icon"},DB={class:"content"},MB={class:"title"},LB={class:"description"},FB=Ee(t.defineComponent({__name:"NodePanelItem",props:{type:{}},setup(e){const{summary:n,icon:o}=Tr[e.type];return(r,i)=>(t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["dk-node-panel-item",{[`node-type-${r.type}`]:!0}])},[t.createElementVNode("div",RB,[t.createVNode(t.unref(o),{size:16})]),t.createElementVNode("div",DB,[t.createElementVNode("div",MB,t.toDisplayString(r.type),1),t.createElementVNode("div",LB,t.toDisplayString(t.unref(n)),1)])],2))}}),[["__scopeId","data-v-e75cecee"]]),UB={class:"dk-node-panel"},KB={class:"title"},jB={class:"node-list"},GB={"aria-hidden":"true",class:"preview",inert:""},qB=Ee(t.defineComponent({__name:"NodePanel",setup(e){const{t:n}=Fe.createI18n("en-us",He),{createNode:o}=st(),r=`dk-drag-preview-${t.useId()}`,i=t.shallowRef(),a=t.computed(()=>i.value?[{id:"preview",type:"flow",data:i.value,position:{x:0,y:0}}]:[]),l=async(s,c)=>{var P,B,j;const d=s.currentTarget,{left:u,top:f,width:p,height:m}=d.getBoundingClientRect(),h=s.clientX-u,y=s.clientY-f;i.value=o({type:c}),await t.nextTick();const g=document.querySelector(`#${r}`)||d,_=g.cloneNode(!0);_.classList.add("dk-drag-snapshot");const{offsetWidth:w,offsetHeight:b}=g;Object.assign(_.style,{position:"absolute",top:"-9999px",left:"-9999px",width:`${w}px`,height:`${b}px`}),document.body.appendChild(_);const v=h/p,N=y/m,E={ratioX:v,ratioY:N,offsetX:w*v,offsetY:b*N},S={action:"create-node",data:{type:c,anchor:E}};(P=s.dataTransfer)==null||P.setData(xo,JSON.stringify(S)),(B=s.dataTransfer)==null||B.setData(`${xo}/${c}`,c),(j=s.dataTransfer)==null||j.setDragImage(_,E.offsetX,E.offsetY),requestAnimationFrame(()=>{_.remove(),i.value=void 0})};return(s,c)=>{const d=t.resolveComponent("KLabel");return t.openBlock(),t.createElementBlock("div",UB,[t.createElementVNode("h3",KB,[t.createVNode(d,{class:"label",info:t.unref(n)("plugins.free-form.datakit.flow_editor.node_panel.description")},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(n)("plugins.free-form.datakit.flow_editor.node_panel.title")),1)]),_:1},8,["info"])]),t.createElementVNode("div",jB,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(Object.keys(t.unref(Tr)),u=>(t.openBlock(),t.createBlock(FB,{key:u,draggable:"true",type:u,onDragstart:f=>l(f,u)},null,8,["type","onDragstart"]))),128))]),t.createElementVNode("div",GB,[t.createVNode(t.unref(ep),{nodes:a.value},{"node-flow":t.withCtx(u=>[t.createVNode(om,{id:r,data:u.data},null,8,["data"])]),_:1},8,["nodes"])])])}}}),[["__scopeId","data-v-98011dca"]]),zB=t.defineComponent({__name:"HttpMethodField",props:{name:{}},setup(e){return(n,o)=>(t.openBlock(),t.createBlock(Nt,{items:t.unref(sa)([...t.unref(ou)]),name:n.name},null,8,["items","name"]))}}),HB=Ee(t.defineComponent({__name:"InputsRecordField",props:{name:{},items:{}},emits:["change:inputs"],setup(e){const{getSchema:n}=De(),{i18n:o}=xe(),r=t.computed(()=>{const i=n("inputs");return i?i.fields.map(a=>Object.keys(a)[0]):[]});return(i,a)=>(t.openBlock(),t.createBlock(nt,{"as-child":"",name:i.name,"reset-label-path":"isolate"},{default:t.withCtx(()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(r.value,l=>(t.openBlock(),t.createBlock(Nt,{key:l,class:"dk-inputs-field-indent",clearable:"","enable-filtering":"",items:i.items,name:l,placeholder:t.unref(o).t("plugins.free-form.datakit.flow_editor.node_properties.input.placeholder"),onChange:s=>i.$emit("change:inputs",l,s?s.value:null)},null,8,["items","name","placeholder","onChange"]))),128))]),_:1},8,["name"]))}}),[["__scopeId","data-v-fe101e72"]]),YB=["data-testid"],WB={class:"dk-inputs-map-field-entry-body"},XB={class:"dk-inputs-map-field-entry-content"},ZB={class:"dk-inputs-map-field-indent"},JB=Ee(t.defineComponent({__name:"InputsMapField",props:{items:{},fieldNameValidator:{},name:{},initialValue:{},label:{},keyPlaceholder:{},valuePlaceholder:{},defaultKey:{},defaultValue:{},labelAttributes:{},showVaultSecretPicker:{type:Boolean},keyOrder:{}},emits:["change:inputs","add:field","remove:field","rename:field","change"],setup(e,{emit:n}){const o=e,r=n,{entries:i,addEntry:a,removeEntry:l,field:s}=ha(o,r),{i18n:{t:c}}=xe(),d=t.useTemplateRef("root"),u=t.ref(null),f=t.ref({});let p;async function m(N,E="key"){var S;d.value&&(await t.nextTick(),(S=d.value.querySelector(`[data-${E}-input="${N}"]`))==null||S.focus())}function h(){const{id:N}=a(),E=i.value.findIndex(({key:S})=>!S);m(E===-1?i.value.length-1:E),u.value=N}function y(N){l(N.id),N.id===u.value&&(u.value=null),N.key.trim()!==""&&r("remove:field",N.key)}function g(N){p=N.key}function _(N){if(w(N)){N.key=p,delete f.value[N.id];return}if(N.id===u.value){if(N.key.trim()==="")return;r("add:field",N.key,N.value),u.value=null}else r("rename:field",p,N.key);p=N.key}function w(N){delete f.value[N.id];const E=o.fieldNameValidator("input",p,N.key);if(E)return f.value[N.id]=E,E}function b(N){w(N)}function v(N,E){N.id!==u.value&&r("change:inputs",N.key,E)}return(N,E)=>{const S=t.resolveComponent("KAlert"),P=t.resolveComponent("KLabel"),B=t.resolveComponent("KInput"),j=t.resolveComponent("KSelect"),G=t.resolveComponent("KButton");return t.unref(s).error?(t.openBlock(),t.createBlock(S,{key:0,appearance:"danger",message:t.unref(s).error.message},null,8,["message"])):(t.openBlock(),t.createElementBlock("div",{key:1,ref_key:"root",ref:d,class:"dk-inputs-map-field"},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(i),(T,Y)=>(t.openBlock(),t.createElementBlock("div",{key:T.id,class:"dk-inputs-map-field-entry dk-inputs-map-field-indent","data-testid":`ff-kv-container-${t.unref(s).path.value}.${Y}`},[t.createVNode(P,{for:`ff-kv-entry-key-${t.unref(s).path.value}.${Y}`},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(c)("plugins.free-form.datakit.flow_editor.node_properties.input_name.label")),1)]),_:2},1032,["for"]),t.createElementVNode("div",WB,[t.createElementVNode("div",XB,[t.createVNode(B,{id:`ff-kv-entry-key-${t.unref(s).path.value}.${Y}`,modelValue:T.key,"onUpdate:modelValue":[I=>T.key=I,I=>w(T)],modelModifiers:{trim:!0},class:"ff-kv-field-entry-key","data-key-input":Y,"data-testid":`ff-key-${t.unref(s).path.value}.${Y}`,error:!!f.value[T.id],"error-message":f.value[T.id],placeholder:t.unref(c)("plugins.free-form.datakit.flow_editor.node_properties.input_name.placeholder"),onBlur:I=>b(T),onChange:I=>_(T),onFocus:I=>g(T)},null,8,["id","modelValue","onUpdate:modelValue","data-key-input","data-testid","error","error-message","placeholder","onBlur","onChange","onFocus"]),t.createVNode(j,{modelValue:T.value,"onUpdate:modelValue":I=>T.value=I,class:"ff-kv-field-entry-value",clearable:"","data-testid":`ff-value-${t.unref(s).path.value}.${Y}`,"enable-filtering":"",items:N.items,placeholder:t.unref(c)("plugins.free-form.datakit.flow_editor.node_properties.input.placeholder"),onChange:I=>v(T,(I==null?void 0:I.value)??null)},null,8,["modelValue","onUpdate:modelValue","data-testid","items","placeholder","onChange"])]),t.createVNode(G,{appearance:"none",class:"dk-inputs-map-field-remove-btn","data-testid":`ff-kv-remove-btn-${t.unref(s).path.value}.${Y}`,icon:"",onClick:I=>y(T)},{default:t.withCtx(()=>[t.createVNode(t.unref(Ne.CloseIcon))]),_:2},1032,["data-testid","onClick"])])],8,YB))),128)),t.createElementVNode("div",ZB,[t.createVNode(G,{appearance:"tertiary","data-testid":`ff-kv-add-btn-${t.unref(s).path.value}`,disabled:!!u.value,onClick:h},{default:t.withCtx(()=>[t.createVNode(t.unref(Ne.AddIcon)),t.createTextVNode(" "+t.toDisplayString(t.unref(c)("plugins.free-form.datakit.flow_editor.node_properties.input.add_button")),1)]),_:1},8,["data-testid","disabled"])])],512))}}}),[["__scopeId","data-v-eed2c92b"]]),eo=t.defineComponent({__name:"InputsField",props:{items:{},fieldNames:{},fieldNameValidator:{}},emits:["change:input","change:inputs","add:field","remove:field","rename:field"],setup(e,{emit:n}){const o=n,{getSchema:r}=De(),{i18n:i}=xe(),a=t.computed(()=>r("inputs")),l=t.computed(()=>a.value?a.value.type==="record"?HB:JB:null);function s(p){o("change:input",p?p.value:null)}function c(p,m){o("add:field",p,m)}function d(p,m){o("change:inputs",p,m)}function u(p){o("remove:field",p)}function f(p,m){o("rename:field",p,m)}return(p,m)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[t.unref(r)("input")?(t.openBlock(),t.createBlock(Nt,{key:0,clearable:"","enable-filtering":"",items:p.items,label:"Inputs",name:"input",placeholder:t.unref(i).t("plugins.free-form.datakit.flow_editor.node_properties.input.placeholder"),onChange:s},null,8,["items","placeholder"])):t.createCommentVNode("",!0),l.value?(t.openBlock(),t.createBlock(t.unref(l),{key:1,"field-name-validator":p.fieldNameValidator,items:p.items,"key-order":p.fieldNames,name:"inputs","onAdd:field":c,"onChange:inputs":d,"onRemove:field":u,"onRename:field":f},null,8,["field-name-validator","items","key-order"])):t.createCommentVNode("",!0)],64))}}),QB={fields:[{input:{description:"filter input(s)",len_max:255,len_min:1,match_any:{err:"must be one of NODE_NAME or NODE_NAME.FIELD",patterns:["^[A-Za-z_][A-Za-z0-9_-]*$","^[A-Za-z_][A-Za-z0-9_-]*%..+$"]},required:!1,type:"string"}},{inputs:{description:"call node inputs",fields:[{body:{description:"HTTP request body",len_max:255,len_min:1,match_any:{err:"must be one of NODE_NAME or NODE_NAME.FIELD",patterns:["^[A-Za-z_][A-Za-z0-9_-]*$","^[A-Za-z_][A-Za-z0-9_-]*%..+$"]},required:!1,type:"string"}},{headers:{description:"HTTP request headers",len_max:255,len_min:1,match_any:{err:"must be one of NODE_NAME or NODE_NAME.FIELD",patterns:["^[A-Za-z_][A-Za-z0-9_-]*$","^[A-Za-z_][A-Za-z0-9_-]*%..+$"]},required:!1,type:"string"}},{query:{description:"HTTP request query",len_max:255,len_min:1,match_any:{err:"must be one of NODE_NAME or NODE_NAME.FIELD",patterns:["^[A-Za-z_][A-Za-z0-9_-]*$","^[A-Za-z_][A-Za-z0-9_-]*%..+$"]},required:!1,type:"string"}}],required:!1,type:"record"}}],type:"record"},eV={fields:[{input:{description:"filter input(s)",len_max:255,len_min:1,match_any:{err:"must be one of NODE_NAME or NODE_NAME.FIELD",patterns:["^[A-Za-z_][A-Za-z0-9_-]*$","^[A-Za-z_][A-Za-z0-9_-]*%..+$"]},required:!1,type:"string"}},{inputs:{description:"call node inputs",fields:[{body:{description:"HTTP request body",len_max:255,len_min:1,match_any:{err:"must be one of NODE_NAME or NODE_NAME.FIELD",patterns:["^[A-Za-z_][A-Za-z0-9_-]*$","^[A-Za-z_][A-Za-z0-9_-]*%..+$"]},required:!1,type:"string"}},{headers:{description:"HTTP request headers",len_max:255,len_min:1,match_any:{err:"must be one of NODE_NAME or NODE_NAME.FIELD",patterns:["^[A-Za-z_][A-Za-z0-9_-]*$","^[A-Za-z_][A-Za-z0-9_-]*%..+$"]},required:!1,type:"string"}}],required:!1,type:"record"}}],type:"record"};function tV(e){const n=Number(e);return!isNaN(n)&&isFinite(n)}function to(...e){return function(o){for(const r of e){const i=r(o);if(i)return i}}}function no(e){const{i18n:{t:n}}=xe(),o=()=>e?typeof e=="string"?e:n("plugins.free-form.datakit.flow_editor.node_properties.errors.not_empty",e):"Field is required";return function(i){if(i==null||typeof i=="string"&&i.trim()==="")return o()}}function am(e,n){const{i18n:{t:o}}=xe();return function(i){if(i!=null)switch(e){case"identifier":{const a=()=>n?typeof n=="string"?n:o("plugins.free-form.datakit.flow_editor.node_properties.errors.invalid_identifier_format",n):"Invalid identifier format";return/^[A-Za-z_][A-Za-z0-9_-]*$/.test(i)?void 0:a()}case"url":{const a=()=>n?typeof n=="string"?n:o("plugins.free-form.datakit.flow_editor.node_properties.errors.invalid_url_format"):"Invalid URL format";try{new URL(i);return}catch{return a()}}default:return}}}function nV(e=0,n=1/0,o){const{i18n:{t:r}}=xe();return function(a){if(a!=null&&typeof a=="string"&&(a.length<e||a.length>n))return o?typeof o=="string"?o:r("plugins.free-form.datakit.flow_editor.node_properties.errors.string_len_range",{fieldName:o.fieldName,minLength:e,maxLength:n}):`Value must be between ${e} and ${n} characters`}}function lm(e){const{i18n:{t:n}}=xe();return function(r){if(!tV(r))return e?typeof e=="string"?e:n("plugins.free-form.datakit.flow_editor.node_properties.errors.not_number",e):"Value must be a number"}}function sm(e,n){const{i18n:{t:o}}=xe();return function(i){if(i==null)return;const a=lm(n)(i);if(a)return a;const l=Number(i);switch(e){case"float":{const s=()=>n?typeof n=="string"?n:o("plugins.free-form.datakit.flow_editor.node_properties.errors.not_float",n):"Invalid float format";return Number.isFinite(l)?void 0:s()}case"integer":{const s=()=>n?typeof n=="string"?n:o("plugins.free-form.datakit.flow_editor.node_properties.errors.not_integer",n):"Invalid integer format";return Number.isInteger(l)?void 0:s()}default:return}}}function cm(e=-1/0,n=1/0,o){const{i18n:{t:r}}=xe();return function(a){if(a==null)return;const l=lm(o)(a);if(l)return l;const s=Number(a);if(s<e||s>n)return o?typeof o=="string"?o:r("plugins.free-form.datakit.flow_editor.node_properties.errors.number_range",{fieldName:o.fieldName,min:e,max:n}):`Value must be between ${e} and ${n}`}}function oV(e,n){const{state:o}=st(),{i18n:{t:r}}=xe();return function(a){if(o.value.nodes.some(l=>l.name===a&&l.id!==e))return n?typeof n=="string"?n:r("plugins.free-form.datakit.flow_editor.node_properties.errors.not_unique",n):"Name must be unique."}}function rV(e,n,o){const{i18n:{t:r}}=xe();return function(a){if(!n)return;if(o?n.fields[e].some(s=>s.name===a&&s.id!==o):n.fields[e].some(s=>s.name===a)){const s=r(e==="input"?"plugins.free-form.datakit.flow_editor.node_properties.input_name.label":"plugins.free-form.datakit.flow_editor.node_properties.output_value.value_name");return r("plugins.free-form.datakit.flow_editor.node_properties.errors.not_unique",{fieldName:s})}}}function iV(){const{i18n:{t:e}}=xe();return function(o){if(Ma(o))return e("plugins.free-form.datakit.flow_editor.node_properties.errors.reserved_node_name",{nodeName:o})}}function dm(e){const{i18n:{t:n}}=xe(),o={fieldName:n("plugins.free-form.datakit.flow_editor.node_properties.name")};return to(no(o),am("identifier",o),iV(),oV(e,o))}function aV(e){const{i18n:{t:n}}=xe(),{getNodeById:o}=st();return function(i,a,l){const s={fieldName:n(i==="input"?"plugins.free-form.datakit.flow_editor.node_properties.input_name.label":"plugins.free-form.datakit.flow_editor.node_properties.output_value.value_name")};return to(no(s),rV(i,o(e),l))(a)}}function lV(e){const n=t.ref({}),o=t.computed(()=>Object.values(n.value).every(l=>!l)),r={};Object.keys(e).forEach(l=>{const s=e[l],c=f=>{const p=typeof f=="function"?f():f,m=s(p);return n.value[l]=m,m},d=()=>{n.value[l]=void 0},u=f=>(d(),c(f));r[l]={handleChange:u,handleBlur:u,validate:u,isValid:t.computed(()=>n.value[l]===void 0),error:t.computed(()=>n.value[l])}});function i(){n.value={}}function a(l){var s;for(const c of Object.keys(e)){const d=l[c],u=typeof d=="function"?d():d;(s=r[c])==null||s.validate(u)}return n.value}return{isValid:o,errorMap:n,fields:r,clearErrors:i,validate:a}}function Pi(e){const{validationConfig:n,getValidationData:o,skipValidationOnMount:r,toggleNodeValid:i}=e,a=t.computed(()=>typeof n=="function"?n():n),l=t.computed(()=>lV(a.value)),s=t.computed(()=>l.value.fields),c=t.computed(()=>l.value.isValid.value);function d(){const f=o(),p=l.value.validate(f),m={};for(const h in a.value)m[h]=p[h];return m}function u(f,p){return{onBlur:()=>{const m=o(),h=s.value[f];h&&h.handleBlur(m[f])},onUpdate:()=>{const m=o(),h=s.value[f];h&&h.handleChange(m[f]),p==null||p()},error:t.computed(()=>{const m=s.value[f];return m?!m.isValid.value:!1}),errorMessage:t.computed(()=>{const m=s.value[f];return m?m.error.value??"":""})}}return t.onMounted(()=>{r!=null&&r.value||d()}),t.onBeforeUnmount(async()=>{try{const f=d(),p=Object.values(f).filter(Boolean).length>0;i(!p)}catch{}}),t.watch(()=>c.value,i,{immediate:!0}),{fields:s.value,isValid:c,validateAll:d,createFieldHandler:u}}function vn(e,n){const{state:o,renameNode:r,getNodeById:i,addField:a,renameField:l,removeField:s,replaceConfig:c,disconnectEdge:d,connectEdge:u,newCreatedNodeId:f,invalidConfigNodeIds:p,undo:m,commit:h}=st(),{i18n:{t:y}}=xe(),g=eB();let _=!1;t.watch(o,async()=>{_=!0,await t.nextTick(),_=!1},{immediate:!0,deep:!0}),console.log("state",o.value),window.store=st();const w=t.computed(()=>{const F=i(e);if(!F)throw new Error("Node not existed");return F}),b=t.computed(()=>{const Z=o.value.edges.filter(Q=>Q.target===e).reduce((Q,W)=>{var ne,re;const ie=i(W.source),ae=(ne=Wt(ie,"output",W.sourceField))==null?void 0:ne.id,me=(re=Wt(w.value,"input",W.targetField))==null?void 0:re.name,ge=ie.id+(ae?`.${ae}`:"");return me?Q.inputs={...Q.inputs,[me]:ge}:Q.input=ge,Q},{});return w.value.fields.input.forEach(Q=>{Z.inputs||(Z.inputs={}),Z.inputs[Q.name]||(Z.inputs[Q.name]=null)}),{...w.value.config,...Z,name:w.value.name}}),v=F=>{r(e,F??"",!0,`${e}:rename`)},N=(F,Z=!0)=>{if(_)return;if(!n)throw new Error("getFormInnerData is not defined");const Q=yc(n(),["name","input","inputs"]),W=F?`update:${e}:${F}`:void 0;c(e,Q,Z,W)},E=(F,Z)=>{const Q=jn(w.value,F,Z);if(!Q)throw new Error(`Field with name "${Z}" not found in node "${w.value.name}"`);return Q},S=(F,Z,Q)=>{const W=!!Q;a(e,F,Z,!W),W&&T(Z,Q)},P=(F,Z,Q)=>{if(_)return;const W=E(F,Z).id;l(e,W,Q)},B=(F,Z)=>{const Q=E(F,Z).id;s(e,Q)},j=t.computed(()=>o.value.edges.filter(F=>F.target===e&&!F.targetField)[0]),G=t.computed(()=>o.value.edges.filter(F=>F.target===e&&F.targetField)),T=async(F,Z)=>{if(_)return;const Q=Z==null,W=E("input",F).id;if(Q){const ee=G.value.find(O=>O.targetField===W);ee&&d(ee.id);return}const{nodeId:ie,fieldId:ae}=Qd(Z),me=E("input",F).id,ge=[];j.value&&(ge.push(Yo(j.value,i)),d(j.value.id,!1));const ne=G.value.find(ee=>ee.targetField===W);ne&&(ge.push(Yo(ne,i)),d(ne.id,!1)),u({source:ie,sourceField:ae,target:e,targetField:me},!1);const re=jl(ie,ae,e,me,i);h(),!(ge[0]&&re&&ge[0][1]===re[1])&&ge.length>0&&(await g(y("plugins.free-form.datakit.flow_editor.confirm.message.switch"),[re],ge)||m())},Y=async F=>{if(_)return;if(F==null){j.value&&d(j.value.id);return}const Q=[];for(const me of G.value.concat(j.value?[j.value]:[]))Q.push(Yo(me,i)),d(me.id,!1);const{nodeId:W,fieldId:ie}=Qd(F);u({source:W,sourceField:ie,target:e,targetField:void 0},!1);const ae=jl(W,ie,e,void 0,i);h(),Q.length>0&&(await g(y("plugins.free-form.datakit.flow_editor.confirm.message.switch"),[ae],Q)||m())},I=F=>{const Z=[...o.value.edges,{source:F,target:e}];return Ka(Rr(Z))},M=t.computed(()=>{var Z,Q;const F=[];for(const W of o.value.nodes)if((Z=La(W.type).io)!=null&&Z.output&&W.fields.output&&W.id!==e&&!(W.type==="property"&&!Il((Q=W.config)==null?void 0:Q.property))&&!I(W.id)&&!(w.value.phase==="request"&&W.phase==="response")){F.push({value:W.id,label:W.name});for(const ae of W.fields.output)F.push({value:`${W.id}.${ae.id}`,label:`${W.name}.${ae.name}`})}return F}),R=t.computed(()=>w.value.fields.input.map(F=>F.name)||[]),te=t.computed(()=>f.value===e);function z(F){p.value.delete(e),F||p.value.add(e)}const H=aV(e);function L(F,Z,Q){const W=i(e);if(!W)throw new Error("Node not found when validating field name");const ie=jn(W,F,Z);return H(F,Q,ie==null?void 0:ie.id)}return{formData:b,inputOptions:M,inputEdge:j,inputsEdges:G,inputsFieldNames:R,skipValidationOnMount:te,currentNode:w,setName:v,setConfig:N,addField:S,renameFieldByName:P,removeFieldByName:B,setInputs:T,setInput:Y,nameValidator:dm(e),fieldNameValidator:L,toggleNodeValid:z}}function Sn(e){const{getSchema:n}=De();return t.computed(()=>{if(Lt(e))switch(e){case"response":return eV;case"service_request":return QB}try{const l=n().fields[0].config.fields[0].nodes.elements.subschema_definitions[e];if(!l)throw new Error(`Subschema "${e}" not found in the schema.`);return l}catch(o){throw new Error(`Failed to get subschema "${e}": ${o.message}`)}})}const Wo=t.defineComponent({__name:"NameField",props:{name:{},validate:{type:Function}},emits:["update"],setup(e,{emit:n}){const o=e,r=n,{i18n:{t:i}}=xe(),a=t.ref(o.name),l=t.computed(()=>{const u=o.validate(a.value.trim());return u===void 0?"":u});let s=a.value.trim();function c(){if(l.value){a.value=s;return}r("update",a.value.trim())}function d(){s=a.value.trim()}return t.watch(()=>o.name,u=>{u!==a.value&&(a.value=u)}),(u,f)=>{const p=t.resolveComponent("KInput");return t.openBlock(),t.createBlock(p,{"model-value":a.value,"onUpdate:modelValue":f[0]||(f[0]=m=>a.value=m),"data-1p-ignore":"",error:!!l.value,"error-message":l.value,label:t.unref(i)("plugins.free-form.datakit.flow_editor.node_properties.name"),required:"",onChange:c,onFocus:d},null,8,["model-value","error","error-message","label"])}}}),sV=t.defineComponent({__name:"NodeFormCall",props:{nodeId:{}},setup(e){const{i18n:{t:n}}=xe(),o=t.useTemplateRef("form"),r=Sn("call"),{formData:i,setName:a,setConfig:l,inputOptions:s,setInputs:c,setInput:d,inputsFieldNames:u,nameValidator:f,skipValidationOnMount:p,toggleNodeValid:m,fieldNameValidator:h}=vn(e.nodeId,()=>o.value.getInnerData()),{createFieldHandler:y}=Pi({validationConfig:{url:to(no({fieldName:"URL"}),am("url",{fieldName:"URL"})),timeout:to(sm("integer",{fieldName:n("plugins.free-form.datakit.flow_editor.node_properties.timeout.label")}),cm(0,2147483646,{fieldName:n("plugins.free-form.datakit.flow_editor.node_properties.timeout.label")}))},getValidationData:()=>({url:i.value.url,timeout:i.value.timeout}),skipValidationOnMount:p,toggleNodeValid:m}),g=y("url",()=>l("url")),_=y("timeout",()=>l("timeout"));return(w,b)=>{const v=t.resolveComponent("KLabel");return t.openBlock(),t.createBlock(pt,{ref:"form",data:t.unref(i),schema:t.unref(r)},{default:t.withCtx(()=>[t.createVNode(Wo,{name:t.unref(i).name,validate:t.unref(f),onUpdate:t.unref(a)},null,8,["name","validate","onUpdate"]),t.createVNode(v,{class:"dk-node-configuration-label"},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(n)("plugins.free-form.datakit.flow_editor.node_properties.Configuration")),1)]),_:1}),t.createVNode(Vn,{error:t.unref(g).error.value,"error-message":t.unref(g).errorMessage.value,name:"url",onBlur:t.unref(g).onBlur,"onUpdate:modelValue":t.unref(g).onUpdate},null,8,["error","error-message","onBlur","onUpdate:modelValue"]),t.createVNode(zB,{name:"method","onUpdate:modelValue":b[0]||(b[0]=N=>t.unref(l)())}),t.createVNode(Rn,{error:t.unref(_).error.value,"error-message":t.unref(_).errorMessage.value,label:t.unref(n)("plugins.free-form.datakit.flow_editor.node_properties.timeout.label"),name:"timeout",onBlur:t.unref(_).onBlur,"onUpdate:modelValue":t.unref(_).onUpdate},null,8,["error","error-message","label","onBlur","onUpdate:modelValue"]),t.createVNode(Vn,{name:"ssl_server_name","onUpdate:modelValue":b[1]||(b[1]=N=>t.unref(l)("ssl_server_name"))}),t.createVNode(eo,{"field-name-validator":t.unref(h),"field-names":t.unref(u),items:t.unref(s),"onChange:input":t.unref(d),"onChange:inputs":t.unref(c)},null,8,["field-name-validator","field-names","items","onChange:input","onChange:inputs"])]),_:1},8,["data","schema"])}}}),cV=t.defineComponent({__name:"NodeFormServiceRequest",props:{nodeId:{}},setup(e){const n=t.useTemplateRef("form"),o=Sn("service_request"),{formData:r,inputOptions:i,setInputs:a,setInput:l,inputsFieldNames:s,fieldNameValidator:c}=vn(e.nodeId,()=>n.value.getInnerData());return(d,u)=>(t.openBlock(),t.createBlock(pt,{ref:"form",data:t.unref(r),schema:t.unref(o)},{default:t.withCtx(()=>[t.createVNode(eo,{"field-name-validator":t.unref(c),"field-names":t.unref(s),items:t.unref(i),"onChange:input":t.unref(l),"onChange:inputs":t.unref(a)},null,8,["field-name-validator","field-names","items","onChange:input","onChange:inputs"])]),_:1},8,["data","schema"]))}}),dV=t.defineComponent({__name:"NodeFormResponse",props:{nodeId:{}},setup(e){const n=t.useTemplateRef("form"),o=Sn("response"),{formData:r,inputOptions:i,setInputs:a,setInput:l,inputsFieldNames:s,fieldNameValidator:c}=vn(e.nodeId,()=>n.value.getInnerData());return(d,u)=>(t.openBlock(),t.createBlock(pt,{ref:"form",data:t.unref(r),schema:t.unref(o)},{default:t.withCtx(()=>[t.createVNode(eo,{"field-name-validator":t.unref(c),"field-names":t.unref(s),items:t.unref(i),"onChange:input":t.unref(l),"onChange:inputs":t.unref(a)},null,8,["field-name-validator","field-names","items","onChange:input","onChange:inputs"])]),_:1},8,["data","schema"]))}}),uV=t.defineComponent({__name:"NodeFormJq",props:{nodeId:{}},setup(e){const{i18n:{t:n}}=xe(),o=t.useTemplateRef("form"),r=Sn("jq"),{formData:i,setName:a,setConfig:l,inputOptions:s,setInputs:c,setInput:d,addField:u,removeFieldByName:f,renameFieldByName:p,inputsFieldNames:m,nameValidator:h,skipValidationOnMount:y,toggleNodeValid:g,fieldNameValidator:_}=vn(e.nodeId,()=>o.value.getInnerData());function w(P,B){u("input",P,B)}function b(P){f("input",P)}function v(P,B){p("input",P,B)}const N=n("plugins.free-form.datakit.flow_editor.node_properties.jq.label"),{createFieldHandler:E}=Pi({validationConfig:{jq:to(no({fieldName:N}),nV(1,10240,{fieldName:N}))},getValidationData:()=>({jq:i.value.jq}),skipValidationOnMount:y,toggleNodeValid:g}),S=E("jq",()=>l("jq"));return(P,B)=>{const j=t.resolveComponent("KLabel");return t.openBlock(),t.createBlock(pt,{ref:"form",data:t.unref(i),schema:t.unref(r)},{default:t.withCtx(()=>[t.createVNode(Wo,{name:t.unref(i).name,validate:t.unref(h),onUpdate:t.unref(a)},null,8,["name","validate","onUpdate"]),t.createVNode(j,{class:"dk-node-configuration-label"},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(n)("plugins.free-form.datakit.flow_editor.node_properties.Configuration")),1)]),_:1}),t.createVNode(Vn,{error:t.unref(S).error.value,help:t.unref(S).errorMessage.value,label:t.unref(N),multiline:"",name:"jq",resizable:"",rows:"2",onBlur:t.unref(S).onBlur,"onUpdate:modelValue":t.unref(S).onUpdate},null,8,["error","help","label","onBlur","onUpdate:modelValue"]),t.createVNode(eo,{"field-name-validator":t.unref(_),"field-names":t.unref(m),items:t.unref(s),"onAdd:field":w,"onChange:input":t.unref(d),"onChange:inputs":t.unref(c),"onRemove:field":b,"onRename:field":v},null,8,["field-name-validator","field-names","items","onChange:input","onChange:inputs"])]),_:1},8,["data","schema"])}}}),fV=Ee(t.defineComponent({__name:"OutputValueField",props:{fieldNameValidator:{},name:{},initialValue:{},label:{},keyPlaceholder:{},valuePlaceholder:{},defaultKey:{},defaultValue:{},labelAttributes:{},showVaultSecretPicker:{type:Boolean},keyOrder:{}},emits:["change:value","add:field","rename:field","remove:field","change"],setup(e,{emit:n}){const o=e,r=n,i=t.ref({}),{entries:a,addEntry:l,removeEntry:s,field:c}=ha(o,r,!1),{i18n:d}=xe(),u=t.useTemplateRef("root"),f=t.ref(null);let p;async function m(N,E="key"){var S;u.value&&(await t.nextTick(),(S=u.value.querySelector(`[data-${E}-input="${N}"]`))==null||S.focus())}function h(){const N=l(),E=a.value.findIndex(({key:S})=>!S);m(E===-1?a.value.length-1:E),f.value=N}function y(N){var E;N.id===((E=f.value)==null?void 0:E.id)&&(f.value=null),s(N.id),N.key.trim()!==""&&r("remove:field",N.key)}function g(N){p=N.key}function _(N){var E;if(b(N)){N.key=p,delete i.value[N.id];return}if(N.id===((E=f.value)==null?void 0:E.id)){if(N.key.trim()==="")return;f.value=null,r("add:field",N.key,N.value)}else r("rename:field",p,N.key);p=N.key}function w(N,E){var P;if(E.id===((P=f.value)==null?void 0:P.id))return;const S=N.target.value.trim();r("change:value",E.key,S)}function b(N){delete i.value[N.id];const E=o.fieldNameValidator("output",p,N.key);if(E)return i.value[N.id]=E,E}function v(N){b(N)}return t.watchEffect(()=>{f.value&&!a.value.some(N=>N.id===f.value.id)&&a.value.push(f.value)}),(N,E)=>{const S=t.resolveComponent("KAlert"),P=t.resolveComponent("KLabel"),B=t.resolveComponent("KButton"),j=t.resolveComponent("KInput"),G=t.resolveComponent("KCard");return t.unref(c).error?(t.openBlock(),t.createBlock(S,{key:0,appearance:"danger",message:t.unref(c).error.message},null,8,["message"])):(t.openBlock(),t.createElementBlock("div",{key:1,ref_key:"root",ref:u,class:"dk-output-value-field"},[t.createVNode(P,{class:"dk-node-configuration-label"},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(d).t("plugins.free-form.datakit.flow_editor.node_properties.output_value.label")),1)]),_:1}),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(a),(T,Y)=>(t.openBlock(),t.createBlock(G,{key:T.id,class:"dk-output-value-field-entry","data-testid":`ff-kv-container-${t.unref(c).path.value}.${Y}`},{actions:t.withCtx(()=>[t.createVNode(B,{appearance:"none","data-testid":`ff-kv-remove-btn-${t.unref(c).path.value}.${Y}`,icon:"",onClick:I=>y(T)},{default:t.withCtx(()=>[t.createVNode(t.unref(Ne.CloseIcon))]),_:2},1032,["data-testid","onClick"])]),default:t.withCtx(()=>[t.createVNode(j,{id:`ff-kv-entry-key-${t.unref(c).path.value}.${Y}`,modelValue:T.key,"onUpdate:modelValue":[I=>T.key=I,I=>b(T)],modelModifiers:{trim:!0},class:"ff-kv-field-entry-key","data-key-input":Y,"data-testid":`ff-key-${t.unref(c).path.value}.${Y}`,error:!!i.value[T.id],"error-message":i.value[T.id],label:t.unref(d).t("plugins.free-form.datakit.flow_editor.node_properties.output_value.value_name"),required:"",onBlur:I=>v(T),onChange:I=>_(T),onFocus:I=>g(T)},null,8,["id","modelValue","onUpdate:modelValue","data-key-input","data-testid","error","error-message","label","onBlur","onChange","onFocus"]),t.createVNode(j,{modelValue:T.value,"onUpdate:modelValue":I=>T.value=I,modelModifiers:{trim:!0},class:"ff-kv-field-entry-value","data-testid":`ff-value-${t.unref(c).path.value}.${Y}`,label:t.unref(d).t("plugins.free-form.datakit.flow_editor.node_properties.output_value.value"),onChange:I=>w(I,T)},null,8,["modelValue","onUpdate:modelValue","data-testid","label","onChange"])]),_:2},1032,["data-testid"]))),128)),t.createVNode(B,{appearance:"tertiary","data-testid":`ff-kv-add-btn-${t.unref(c).path.value}`,disabled:!!f.value,onClick:h},{default:t.withCtx(()=>[t.createVNode(t.unref(Ne.AddIcon)),t.createTextVNode(" "+t.toDisplayString(t.unref(d).t("plugins.free-form.datakit.flow_editor.node_properties.output_value.add_button")),1)]),_:1},8,["data-testid","disabled"])],512))}}}),[["__scopeId","data-v-5e17f8cb"]]);function pV(e){const n={};for(const[o,r]of Object.entries(e))typeof r=="object"&&r!==null?n[o]=JSON.stringify(r):n[o]=String(r);return n}function Ti(e){const n={};for(const[o,r]of Object.entries(e))if(r!=null){n[o]=r;try{r==="null"?n[o]=null:(r==="true"||r==="false"||/^-?\d+(\.\d+)?$/.test(r)||r.startsWith("{")&&r.endsWith("}")||r.startsWith("[")&&r.endsWith("]"))&&(n[o]=JSON.parse(r))}catch{}}return n}function mV(e,n,o){const r={};for(const i of Object.keys(e))i===n?r[o]=e[n]:r[i]=e[i];return r}const gV=t.defineComponent({__name:"NodeFormStatic",props:{nodeId:{}},setup(e){const{renameNode:n,getOutEdgesByNodeId:o,addField:r,renameField:i,removeField:a,replaceConfig:l,getNodeById:s}=st(),{fieldNameValidator:c}=vn(e.nodeId),d=Sn("static"),u=dm(e.nodeId),f=t.computed(()=>s(e.nodeId)),p=t.computed(()=>{var b;return((b=f.value)==null?void 0:b.fields.output.map(v=>v.name))||[]});function m(b){if(!f.value)throw new Error("No current node");n(f.value.id,b??"")}const h=t.computed(()=>{var B;if(!f.value)return{};const b=((B=f.value.config)==null?void 0:B.values)??{},v={},N=o(f.value.id).map(j=>j.sourceField).filter(Boolean).map(j=>Wt(f.value,"output",j)).map(j=>j==null?void 0:j.name).filter(Boolean),E=f.value.fields.output.map(j=>j.name),S=Object.keys(b);return new Set([...S,...N,...E]).forEach(j=>{if(j in b){v[j]=b[j];return}v[j]=""}),{name:f.value.name,values:pV(v)}});function y(b,v){if(!f.value)throw new Error("No selected node");const N=v!==void 0;if(r(e.nodeId,"output",b,!N),N){const E={values:Ti({...h.value.values,[b]:v})};l(e.nodeId,E)}}function g(b,v){if(!f.value)throw new Error("No selected node");const N=jn(f.value,"output",b);if(!N)throw new Error("No field found to rename");const E={values:Ti(mV(h.value.values??{},b,v))};l(e.nodeId,E,!1),i(e.nodeId,N.id,v)}function _(b){var E;if(!f.value)throw new Error("No selected node");const v=jn(f.value,"output",b);if(!v)throw new Error("No field found to delete");a((E=f.value)==null?void 0:E.id,v.id,!0,!1);const N={values:Ti({...h.value.values})};delete N.values[b],l(e.nodeId,N)}function w(b,v){if(!f.value)throw new Error("No selected node");const N={...h.value.values};N[b]=v;const E={values:Ti(N)};l(e.nodeId,E)}return(b,v)=>(t.openBlock(),t.createBlock(pt,{ref:"form",data:h.value,schema:t.unref(d)},{default:t.withCtx(()=>{var N;return[t.createVNode(Wo,{name:((N=f.value)==null?void 0:N.name)??"",validate:t.unref(u),onUpdate:m},null,8,["name","validate"]),t.createVNode(fV,{"field-name-validator":t.unref(c),"key-order":p.value,name:"values","onAdd:field":y,"onChange:value":w,"onRemove:field":_,"onRename:field":g},null,8,["field-name-validator","key-order"])]}),_:1},8,["data","schema"]))}}),hV={class:"dk-kong-property-item"},yV={class:"property-type"},_V={class:"property-badges"},bV=Ee(t.defineComponent({__name:"PropertiesField",props:{validators:{}},emits:["update:model-value","update:property-key"],setup(e,{emit:n}){const{i18n:{t:o}}=xe(),r=e,i=n,{formData:a}=De(),l=t.ref(qo(a.property)),s=t.computed(()=>zo(a.property)),c=t.ref(Al(a.property)),d=t.computed(()=>a.property??""),u=t.computed(()=>Object.entries(En).map(([m])=>{var g;const h=zo(m)?(g=a.property)==null?void 0:g.startsWith(m.replace(Jn,"")):a.property===m;return{label:h&&c.value?m.replace(Jn,c.value):m,value:m,selected:h}}));function f(m){const h=ki.find(y=>{var g;return(g=a.property)==null?void 0:g.startsWith(y)});h&&(a.property=h+m,r.validators.key.handleChange(a.property),i("update:property-key",a.property))}function p(m){l.value!==qo(m==null?void 0:m.value)&&(a.property=(m==null?void 0:m.value)||null,l.value=qo(a.property),r.validators.property.handleBlur(()=>a.property),i("update:model-value",a.property))}return t.watch(()=>a.property,m=>{c.value=Al(m),l.value=qo(m)}),(m,h)=>{const y=t.resolveComponent("KBadge"),g=t.resolveComponent("KSelect"),_=t.resolveComponent("KInput");return t.openBlock(),t.createElementBlock(t.Fragment,null,[(t.openBlock(),t.createBlock(g,{key:d.value,"enable-filtering":"",error:!m.validators.property.isValid.value,help:m.validators.property.error.value,items:u.value,label:"Property","label-attributes":{maxWidth:"300px",placement:"top",info:"The property name to get/set"},required:"",onBlur:h[0]||(h[0]=w=>m.validators.property.handleBlur(()=>t.unref(a).property)),onChange:p},{"item-template":t.withCtx(({item:w})=>[t.createElementVNode("div",hV,[t.createElementVNode("div",null,[t.createElementVNode("div",null,t.toDisplayString(w.label),1),t.createElementVNode("div",yV,t.toDisplayString(t.unref(En)[w.value].dataType),1)]),t.createElementVNode("div",_V,[t.unref(En)[w.value].readable?(t.openBlock(),t.createBlock(y,{key:0,appearance:"info"},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(o)("plugins.free-form.datakit.flow_editor.node_properties.property.get")),1)]),_:1})):t.createCommentVNode("",!0),t.unref(En)[w.value].writable?(t.openBlock(),t.createBlock(y,{key:1,appearance:"warning"},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(o)("plugins.free-form.datakit.flow_editor.node_properties.property.set")),1)]),_:1})):t.createCommentVNode("",!0)])])]),_:1},8,["error","help","items"])),s.value?(t.openBlock(),t.createBlock(_,{key:0,"model-value":c.value,"onUpdate:modelValue":[h[1]||(h[1]=w=>c.value=w),f],error:!m.validators.key.isValid.value,"error-message":m.validators.key.error.value,label:"key",required:"",onBlur:h[2]||(h[2]=w=>m.validators.key.handleBlur(()=>t.unref(a).property))},null,8,["model-value","error","error-message"])):t.createCommentVNode("",!0)],64)}}}),[["__scopeId","data-v-0ab1be87"]]),wV=t.defineComponent({__name:"NodeFormProperty",props:{nodeId:{}},setup(e){const n=t.useTemplateRef("form"),{selectedNode:o,disconnectInEdges:r,disconnectOutEdges:i}=st(),a=Sn("property"),{formData:l,setName:s,setConfig:c,inputOptions:d,setInputs:u,setInput:f,inputsFieldNames:p,nameValidator:m,toggleNodeValid:h,skipValidationOnMount:y,fieldNameValidator:g}=vn(e.nodeId,()=>n.value.getInnerData()),_=t.computed(()=>Pl(l.value.property));function w(v){var E;const N=(E=o.value)==null?void 0:E.id;if(!N)throw new Error("Expected selectedNode to be defined");Il(v)||i(N,!1),Pl(v)||r(N,!1),c()}const{fields:b}=Pi({validationConfig:()=>({property:no({fieldName:"Property"}),key:zo(l.value.property)?no({fieldName:"Key"}):()=>{}}),getValidationData:()=>({property:l.value.property,key:Al(l.value.property)}),skipValidationOnMount:y,toggleNodeValid:h});return(v,N)=>(t.openBlock(),t.createBlock(pt,{ref:"form",data:t.unref(l),schema:t.unref(a)},{default:t.withCtx(()=>[t.createVNode(Wo,{name:t.unref(l).name,validate:t.unref(m),onUpdate:t.unref(s)},null,8,["name","validate","onUpdate"]),t.createVNode(Nt,{name:"content_type","onUpdate:modelValue":t.unref(c)},null,8,["onUpdate:modelValue"]),t.createVNode(bV,{validators:t.unref(b),"onUpdate:modelValue":w,"onUpdate:propertyKey":N[0]||(N[0]=E=>t.unref(c)("property-key"))},null,8,["validators"]),_.value?(t.openBlock(),t.createBlock(eo,{key:0,"field-name-validator":t.unref(g),"field-names":t.unref(p),items:t.unref(d),"onChange:input":t.unref(f),"onChange:inputs":t.unref(u)},null,8,["field-name-validator","field-names","items","onChange:input","onChange:inputs"])):t.createCommentVNode("",!0)]),_:1},8,["data","schema"]))}}),kV=t.defineComponent({__name:"NodeFormExit",props:{nodeId:{}},setup(e){const n=t.useTemplateRef("form"),o=Sn("exit"),{formData:r,setName:i,setConfig:a,inputOptions:l,setInputs:s,setInput:c,inputsFieldNames:d,nameValidator:u,toggleNodeValid:f,skipValidationOnMount:p,fieldNameValidator:m}=vn(e.nodeId,()=>n.value.getInnerData()),{createFieldHandler:h}=Pi({validationConfig:{status:to(sm("integer",{fieldName:"Status"}),cm(200,255,{fieldName:"Status"}))},getValidationData:()=>({status:r.value.status}),skipValidationOnMount:p,toggleNodeValid:f}),y=h("status",()=>a("status"));return(g,_)=>(t.openBlock(),t.createBlock(pt,{ref:"form",data:t.unref(r),schema:t.unref(o)},{default:t.withCtx(()=>[t.createVNode(Wo,{name:t.unref(r).name,validate:t.unref(u),onUpdate:t.unref(i)},null,8,["name","validate","onUpdate"]),t.createVNode(Rn,{error:t.unref(y).error.value,"error-message":t.unref(y).errorMessage.value,name:"status",onBlur:t.unref(y).onBlur,"onUpdate:modelValue":t.unref(y).onUpdate},null,8,["error","error-message","onBlur","onUpdate:modelValue"]),t.createVNode(ga,{name:"warn_headers_sent","onUpdate:modelValue":_[0]||(_[0]=w=>t.unref(a)())}),t.createVNode(eo,{"field-name-validator":t.unref(m),"field-names":t.unref(d),items:t.unref(l),"onChange:input":t.unref(c),"onChange:inputs":t.unref(s)},null,8,["field-name-validator","field-names","items","onChange:input","onChange:inputs"])]),_:1},8,["data","schema"]))}}),EV=["innerHTML"],CV=Ee(t.defineComponent({__name:"NodePropertiesPanel",props:{maxWidth:{default:()=>aN},offsetTop:{default:()=>lN},visible:{type:Boolean},nodeId:{}},emits:["close"],setup(e){const{getNodeById:n}=st(),o=t.computed(()=>e.nodeId&&n(e.nodeId)),r=t.computed(()=>{var i;switch((i=o.value)==null?void 0:i.type){case"call":return sV;case"service_request":return cV;case"response":return dV;case"jq":return uV;case"static":return gV;case"property":return wV;case"exit":return kV;default:return null}});return(i,a)=>(t.openBlock(),t.createBlock(t.unref(Pe.KSlideout),{class:"dk-node-properties-panel","close-on-blur":!1,"has-overlay":!1,"max-width":i.maxWidth,"offset-top":i.offsetTop,visible:i.visible,onClose:a[0]||(a[0]=l=>i.$emit("close"))},t.createSlots({default:t.withCtx(()=>[o.value?(t.openBlock(),t.createElementBlock("div",{key:0,class:"dk-node-properties-panel-desc",innerHTML:t.unref(St)(o.value.type)},null,8,EV)):t.createCommentVNode("",!0),r.value?(t.openBlock(),t.createBlock(t.unref(r),{key:i.nodeId,class:"dk-node-properties-panel-form","node-id":i.nodeId},null,8,["node-id"])):t.createCommentVNode("",!0)]),_:2},[o.value?{name:"title",fn:t.withCtx(()=>[t.createVNode(tm,{type:o.value.type},null,8,["type"])]),key:"0"}:void 0]),1032,["max-width","offset-top","visible"]))}}),[["__scopeId","data-v-1bb64727"]]),NV={class:"dk-editor-content"},vV={class:"header"},SV={class:"title"},xV={class:"body"},AV={class:"node-selection-panel"},IV={class:"main"},PV=Ee(t.defineComponent({__name:"EditorContent",setup(e){const{t:n}=Fe.createI18n("en-us",He),{sidePanelExpanded:o}=ja(),{propertiesPanelOpen:r,selectedNode:i,newCreatedNodeId:a}=st();function l(){r.value=!1,a.value=null}t.watch(i,c=>{c||l(),(!c||c.id!==a.value)&&(a.value=null)});const s=t.ref(!1);return t.onMounted(()=>{s.value=!0}),(c,d)=>{var u;return t.openBlock(),t.createElementBlock("div",NV,[t.createElementVNode("aside",{class:t.normalizeClass(["side-panel",{expanded:t.unref(o),inited:s.value}])},[t.createElementVNode("header",vV,[t.createElementVNode("h2",SV,t.toDisplayString(t.unref(n)("plugins.free-form.datakit.flow_editor.name")),1)]),t.createElementVNode("div",xV,[t.createElementVNode("div",AV,[t.createVNode(qB)])])],2),t.createElementVNode("div",IV,[t.createVNode(VB)]),t.createVNode(CV,{"node-id":(u=t.unref(i))==null?void 0:u.id,visible:t.unref(r),onClose:l},null,8,["node-id","visible"])])}}}),[["__scopeId","data-v-4fa0b782"]]),TV={key:0,class:"dk-editor-modal"},OV=Ee(t.defineComponent({__name:"EditorModal",props:{open:{type:Boolean},openModifiers:{}},emits:["update:open"],setup(e){t.useCssVars(l=>({f0b8bf7e:t.unref(iN),ab521f8a:t.unref(rN)}));const n=t.useModel(e,"open"),o=t.ref(!1),r=t.useTemplateRef("confirm-modal");Q$(async(...l)=>{o.value=!0;const s=await r.value.open(...l);return o.value=!1,s});const i=Ue.useScrollLock(document);t.watch(n,l=>{i.value=!!l},{immediate:!0});function a(){n.value=!1}return(l,s)=>n.value?(t.openBlock(),t.createElementBlock("div",TV,[t.createVNode(AB,{class:"nav",onBack:a}),t.createVNode(PV,{ref:"content",class:"content",tabindex:"0"},null,512),t.createVNode(NB,{ref:"confirm-modal"},null,512)])):t.createCommentVNode("",!0)}}),[["__scopeId","data-v-2a45bec4"]]),$V={class:"dk-flow-editor"},BV={class:"flow-panels-container"},VV={class:"overlay"},RV={class:"field"},DV=Ee(t.defineComponent({__name:"FlowEditor",props:{isEditing:{type:Boolean}},emits:["change","error"],setup(e,{emit:n}){var c,d;const{t:o}=Fe.createI18n("en-us",He),{formData:r}=De(),i=n,a=t.useTemplateRef("flowPanels");function l(u,f){const p={...r.config,nodes:u},m={...r.__ui_data,nodes:f};r.config=p,r.__ui_data=m,i("change",p,m)}const{modalOpen:s}=pN(((c=r.config)==null?void 0:c.nodes)??[],((d=r.__ui_data)==null?void 0:d.nodes)??[],{onChange:l,isEditing:e.isEditing});return t.watch(s,()=>{var u;s.value||(u=a.value)==null||u.fitView()}),(u,f)=>{const p=t.resolveComponent("KButton");return t.openBlock(),t.createElementBlock("div",$V,[t.createElementVNode("div",BV,[t.createVNode(im,{ref_key:"flowPanels",ref:a,readonly:""},null,512),t.createElementVNode("div",VV,[t.createVNode(p,{appearance:"secondary",class:"button-open-editor",onClick:f[0]||(f[0]=m=>s.value=!0)},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(o)("plugins.free-form.datakit.flow_editor.cta"))+" ",1),t.createVNode(t.unref(Ne.ExpandIcon))]),_:1})])]),t.createVNode(OV,{open:t.unref(s),"onUpdate:open":f[1]||(f[1]=m=>t.isRef(s)?s.value=m:null)},null,8,["open"]),t.createElementVNode("div",RV,[t.createVNode(ga,{name:"config.debug"})])])}}}),[["__scopeId","data-v-2cde866e"]]);function MV(e,n){const o=[],r=(i,a)=>{typeof a=="string"&&o.push({nodeName:e.name,path:["nodes",n,...i],value:a})};if("input"in e&&e.input!=null&&r(["input"],e.input),"inputs"in e&&e.inputs&&typeof e.inputs=="object")for(const[i,a]of Object.entries(e.inputs))a!=null&&r(["inputs",i],a);if("output"in e&&e.output!=null&&r(["output"],e.output),"outputs"in e&&e.outputs&&typeof e.outputs=="object")for(const[i,a]of Object.entries(e.outputs))a!=null&&r(["outputs",i],a);return o}function LV(e){const n=e.path[2];return n==="output"||n==="outputs"}function FV(e){if(!e)return!1;for(const n of Object.values(e))if(n!=null)return!0;return!1}function um(e,n,o){if(!e.nodes)return;const r=e.nodes.map(c=>c.name),i=new Set;r.forEach((c,d)=>{i.has(c)&&o.addIssue({code:"custom",message:`Duplicate node name: "${c}"`,path:["nodes",d,"name"]}),i.add(c)}),e.nodes.forEach((c,d)=>{const u="input"in c&&c.input!=null,f="inputs"in c&&FV(c.inputs);u&&f&&o.addIssue({code:"custom",message:'A node cannot use both "input" and "inputs". Use one or the other.',path:["nodes",d,"inputs"]})});const a=new Set([...n,...r]),l=new Map,s=new Map;e.nodes.forEach((c,d)=>{for(const u of MV(c,d)){const f=u.value.split(".",1)[0];if(a.has(f)||o.addIssue({code:"custom",message:`Unknown node "${f}" in connection "${u.value}"`,path:u.path}),LV(u)){const p=`${u.nodeName}->${f}`;s.has(p)?o.addIssue({code:"custom",message:`Connection specified on both sides: "${u.nodeName}" outputs to "${f}" and "${f}" inputs from "${u.nodeName}". Specify it on one side only.`,path:u.path}):l.set(p,l.get(p)??u.path)}else{const p=`${f}->${u.nodeName}`;l.has(p)?o.addIssue({code:"custom",message:`Connection specified on both sides: "${f}" outputs to "${u.nodeName}" and "${u.nodeName}" inputs from "${f}". Specify it on one side only.`,path:u.path}):s.set(p,s.get(p)??u.path)}}})}const UV=ce.z.enum(Br),KV=ce.z.enum(Vr),fm=e=>Br.includes(e),zl=ce.z.enum(["call","jq","exit","property","static"]),pm=zl.options;ce.z.union([zl,UV]);const jV=/^[A-Za-z_][A-Za-z0-9_-]{0,254}$/,mm=ce.z.string().min(1).max(255).regex(jV,"Invalid node name (snake_case / kebab-case only)").refine(e=>!fm(e),"Name clashes with reserved implicit node").brand(),gm=ce.z.union([KV,mm]),GV=ce.z.string().min(1).brand(),Ot=ce.z.string().refine(e=>{if(gm.safeParse(e).success)return!0;const n=e.match(/^([^.]+)\.([^.]+)$/);if(!n)return!1;const[,o,r]=n;return gm.safeParse(o).success&&GV.safeParse(r).success},'Invalid connection, expected "NODE" or "NODE.FIELD"').nullish(),hm=ce.z.enum(ou),Xo=ce.z.object({type:ce.z.string(),name:mm,input:Ot,inputs:ce.z.record(ce.z.string(),Ot).nullish(),output:Ot,outputs:ce.z.record(ce.z.string(),Ot).nullish()}).loose(),qV=ce.z.object({type:ce.z.string(),name:ce.z.string()}).loose().superRefine((e,n)=>{const o=e.type,r=e.name;(typeof r!="string"||r.length===0||r.includes("."))&&n.addIssue({code:"custom",path:["name"],message:"invalid node name",fatal:!1}),pm.includes(o)||n.addIssue({code:"custom",path:["type"],message:`unknown node type "${o}", expected one of: ${pm.join(", ")}`})}),zV=Xo.extend({type:ce.z.literal("call"),method:hm.nullish(),ssl_server_name:ce.z.string().min(1).nullish(),timeout:ce.z.number().int().min(0).max(2147483646).nullish(),url:ce.z.url(),inputs:ce.z.object({body:Ot,headers:Ot,query:Ot}).partial().nullish(),outputs:ce.z.object({body:Ot,headers:Ot,status:Ot}).partial().nullish()}).strict(),HV=Xo.extend({type:ce.z.literal("exit"),status:ce.z.number().int().min(200).max(599).nullish(),warn_headers_sent:ce.z.boolean().nullish(),output:ce.z.never().optional(),outputs:ce.z.never().optional()}).strict(),YV=Xo.extend({type:ce.z.literal("jq"),jq:ce.z.string().min(1).max(10240),outputs:ce.z.never().optional()}).strict(),WV=Xo.extend({type:ce.z.literal("property"),content_type:ce.z.enum(["application/json","text/plain","application/octet-stream"]).nullish(),property:ce.z.string().min(1),inputs:ce.z.never().optional(),outputs:ce.z.never().optional()}).strict(),XV=Xo.extend({type:ce.z.literal("static"),values:ce.z.record(ce.z.string(),ce.z.unknown()),input:ce.z.never().optional(),inputs:ce.z.never().optional()}).strict(),ZV=qV.pipe(ce.z.discriminatedUnion("type",[zV,HV,YV,WV,XV]));ce.z.object({nodes:ce.z.array(ZV).min(1,"At least one node is required"),debug:ce.z.boolean().nullish()}).strict().superRefine((e,n)=>{um(e,Br,n)});const ym=zl.options,JV=ce.z.string().min(1).refine(e=>!e.includes("."),"Invalid node name").refine(e=>!fm(e),"Node name conflicts with reserved implicit node"),$t=ce.z.string().refine(e=>{if(!e||/\s/.test(e))return!1;const n=e.indexOf(".");if(n===-1)return!0;const o=e.slice(0,n),r=e.slice(n+1);return o.length>0&&r.length>0},"Invalid connection"),Zo=ce.z.object({type:ce.z.string(),name:JV,input:$t.nullish(),inputs:ce.z.record(ce.z.string(),$t.nullish()).nullish(),output:$t.nullish(),outputs:ce.z.record(ce.z.string(),$t.nullish()).nullish()}).loose(),QV=ce.z.object({type:ce.z.string(),name:ce.z.string()}).loose().superRefine((e,n)=>{const o=e.type,r=e.name;(typeof r!="string"||r.length===0||r.includes("."))&&n.addIssue({code:"custom",path:["name"],message:"Invalid node name",fatal:!1}),ym.includes(o)||n.addIssue({code:"custom",path:["type"],message:`unknown node type "${o}", expected one of: ${ym.join(", ")}`})}),eR=Zo.extend({type:ce.z.literal("call"),method:hm.nullish(),ssl_server_name:ce.z.string().nullish(),timeout:ce.z.union([ce.z.number(),ce.z.string()]).nullish(),url:ce.z.string().nullish(),inputs:ce.z.object({body:$t.nullish(),headers:$t.nullish(),query:$t.nullish()}).partial().nullish(),outputs:ce.z.object({body:$t.nullish(),headers:$t.nullish(),status:$t.nullish()}).partial().nullish()}).strict(),tR=Zo.extend({type:ce.z.literal("exit"),status:ce.z.union([ce.z.number(),ce.z.string()]).nullish(),warn_headers_sent:ce.z.boolean().nullish(),output:ce.z.never().optional(),outputs:ce.z.never().optional()}).strict(),nR=Zo.extend({type:ce.z.literal("jq"),jq:ce.z.string().nullish(),outputs:ce.z.never().optional()}).strict(),oR=Zo.extend({type:ce.z.literal("property"),content_type:ce.z.string().nullish(),property:ce.z.string().nullish(),inputs:ce.z.never().optional(),outputs:ce.z.never().optional()}).strict(),rR=Zo.extend({type:ce.z.literal("static"),values:ce.z.record(ce.z.string(),ce.z.unknown()).nullish(),input:ce.z.never().optional(),inputs:ce.z.never().optional()}).strict(),iR=QV.pipe(ce.z.discriminatedUnion("type",[eR,tR,nR,oR,rR])),aR=ce.z.object({nodes:ce.z.array(iR).nullish(),debug:ce.z.boolean().nullish()}).strict().superRefine((e,n)=>{!e||!Array.isArray(e.nodes)||um(e,Vr,n)}).nullish(),lR={class:"option-label"},sR=["innerHTML"],cR=Ee(t.defineComponent({__name:"DatakitForm",props:{generalInfoTitle:{},generalInfoDescription:{},pluginConfigTitle:{},pluginConfigDescription:{},schema:{},formSchema:{},model:{},formModel:{},formOptions:{},isEditing:{type:Boolean},onModelUpdated:{type:Function},onFormChange:{type:Function},onValidityChange:{type:Function}},setup(e){const{t:n}=Fe.createI18n("en-us",He),o=e,r=t.inject(kc.DATAKIT_ENABLE_FLOW_EDITOR,!1),{editorMode:i}=ja(),a=t.computed(()=>r&&s.value?i.value:"code"),l={flow:Ne.DesignIcon,code:Ne.CodeblockIcon},s=t.ref(!0),c=t.computed(()=>{const h=[{label:n("plugins.free-form.datakit.flow_editor.mode"),value:"flow"},{label:n("plugins.free-form.datakit.code_editor.mode"),value:"code"}];return h[0].disabled=!s.value,h}),d=t.computed(()=>{switch(a.value){case"code":return n("plugins.free-form.datakit.description_code");case"flow":return n("plugins.free-form.datakit.description_flow");default:return""}});t.watch(a,()=>{var h;(h=o.onValidityChange)==null||h.call(o,{model:"config",valid:!0})});function u(){var h;(h=o.onValidityChange)==null||h.call(o,{model:"config",valid:!0})}function f(){u()}function p(h){u();const{success:y}=aR.safeParse(h);s.value=y}function m(h){var y;s.value=!1,(y=o.onValidityChange)==null||y.call(o,{model:"config",valid:!1,error:h})}return(h,y)=>{const g=t.resolveComponent("KTooltip");return t.openBlock(),t.createBlock(zc,t.mergeProps(o,{class:"dk-form"}),t.createSlots({default:t.withCtx(_=>[t.createVNode(pt,t.mergeProps(_,{tag:"div"}),{default:t.withCtx(()=>[a.value==="flow"?(t.openBlock(),t.createBlock(DV,{key:0,"is-editing":o.isEditing,onChange:f},null,8,["is-editing"])):a.value==="code"?(t.openBlock(),t.createBlock(QC,{key:1,class:"code-editor",editing:o.isEditing,onChange:p,onError:m},null,8,["editing"])):t.createCommentVNode("",!0)]),_:2},1040)]),"plugin-config-description":t.withCtx(()=>[t.createElementVNode("span",{innerHTML:d.value},null,8,sR)]),_:2},[t.unref(r)?{name:"plugin-config-extra",fn:t.withCtx(()=>[t.createVNode(t.unref(Pe.KSegmentedControl),{"model-value":a.value,options:c.value,"onUpdate:modelValue":y[0]||(y[0]=_=>i.value=_)},{"option-label":t.withCtx(({option:_})=>[t.createVNode(g,{disabled:s.value||_.value!=="flow",text:t.unref(n)("plugins.free-form.datakit.flow_editor.disabled_tooltip")},{default:t.withCtx(()=>[t.createElementVNode("div",lR,[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(l[_.value]))),t.createTextVNode(" "+t.toDisplayString(_.label),1)])]),_:2},1032,["disabled","text"])]),_:1},8,["model-value","options"])]),key:"0"}:void 0]),1040)}}}),[["__scopeId","data-v-ef778da1"]]),_m=e=>{if(!(!e||typeof e!="object"))for(const[n,o]of Object.entries(e))typeof o=="string"&&(e[n]=o.split(/\s*,\s*/).filter(Boolean))},bm=e=>{if(!(!e||typeof e!="object"))for(const[n,o]of Object.entries(e))Array.isArray(o)&&(e[n]=o.join(", "))},dR=t.defineComponent({__name:"ConfigForm",props:{schema:{},data:{},onChange:{type:Function}},emits:["change"],setup(e,{emit:n}){const o=n,{i18n:{t:r}}=Re.useI18n(),l={prepareFormData:c=>{var u,f;const d=Tn(c);return(f=(u=d.config)==null?void 0:u.tools)!=null&&f.length&&d.config.tools.forEach(p=>{bm(p.headers),bm(p.query)}),d},hasValue:c=>!!(c!=null&&c.config)},s=c=>{var u,f;const d=Tn(c);(f=(u=d.config)==null?void 0:u.tools)!=null&&f.length&&d.config.tools.forEach(p=>{_m(p.headers),_m(p.query)}),o("change",d)};return(c,d)=>(t.openBlock(),t.createBlock(pt,{config:l,data:c.data,schema:c.schema,tag:"div",onChange:s},{default:t.withCtx(()=>[t.createVNode(nt,{"as-child":"",name:"config","reset-label-path":"reset"},{tools:t.withCtx(({name:u})=>[t.createVNode(Cr,{appearance:"tabs","item-label":(f,p)=>t.unref(r)("plugins.free-form.ai-mcp-proxy.tool_item_label",{index:p+1}),name:u,"sticky-tabs":""},null,8,["item-label","name"])]),_:1}),t.createVNode(Nr)]),_:1},8,["data","schema"]))}}),uR=t.defineComponent({__name:"AIMcpProxyForm",props:{schema:{},formSchema:{},model:{},formModel:{},formOptions:{},isEditing:{type:Boolean},onModelUpdated:{type:Function},onFormChange:{type:Function}},setup(e){const n=e,o=t.useSlots();return t.provide(Ie.AUTOFILL_SLOT,o==null?void 0:o[Ie.AUTOFILL_SLOT_NAME]),(r,i)=>(t.openBlock(),t.createBlock(_a,t.normalizeProps(t.guardReactiveProps(n)),{default:t.withCtx(a=>[t.createVNode(dR,t.normalizeProps(t.guardReactiveProps(a)),null,16)]),_:1},16))}}),fR=Ee(t.defineComponent({__name:"ConfigForm",props:{schema:{},data:{}},emits:["change"],setup(e,{emit:n}){const o=n,r=t.computed(()=>{const l=e.schema.fields.find(d=>Object.keys(d)[0]==="config").config.fields,s=[],c=[];for(const d of l){const u=Object.keys(d)[0];d[u].required?s.push(u):c.push(u)}return{required:s,nonRequired:c}}),i={hasValue:l=>!!(l!=null&&l.config)};function a(l){o("change",l)}return(l,s)=>(t.openBlock(),t.createBlock(pt,{config:i,data:l.data,schema:l.schema,tag:"div",onChange:a},{default:t.withCtx(()=>[t.createVNode(nt,{"as-child":"",name:"config",omit:r.value.nonRequired,"reset-label-path":"reset"},null,8,["omit"]),t.createVNode(Nr,{class:"ff-advanced-fields"},{default:t.withCtx(()=>[t.createVNode(nt,{"as-child":"",name:"config",omit:r.value.required,"reset-label-path":"reset"},null,8,["omit"])]),_:1})]),_:1},8,["data","schema"]))}}),[["__scopeId","data-v-3e5ed51d"]]),wm=Object.freeze(Object.defineProperty({__proto__:null,AIMcpProxyForm:uR,CommonForm:t.defineComponent({__name:"CommonForm",props:{generalInfoTitle:{},generalInfoDescription:{},pluginConfigTitle:{},pluginConfigDescription:{},schema:{},formSchema:{},model:{},formModel:{},formOptions:{},isEditing:{type:Boolean},onModelUpdated:{type:Function},onFormChange:{type:Function},onValidityChange:{type:Function}},setup(e){const n=e,o=t.useSlots();return t.provide(Ie.AUTOFILL_SLOT,o==null?void 0:o[Ie.AUTOFILL_SLOT_NAME]),(r,i)=>(t.openBlock(),t.createBlock(zc,t.normalizeProps(t.guardReactiveProps(n)),{default:t.withCtx(a=>[t.createVNode(fR,t.normalizeProps(t.guardReactiveProps(a)),null,16)]),_:1},16))}}),DatakitForm:cR,RequestCalloutForm:Tw,ServiceProtectionForm:Sk},Symbol.toStringTag,{value:"Module"})),pR={class:"kong-ui-entities-plugin-form"},mR={key:1,class:"entity-form"},gR={class:"plugin-config-empty-state"},hR=Ee(t.defineComponent({__name:"PluginEntityForm",props:{config:{type:Object,required:!0,validator:e=>!(!e||!["konnect","kongManager"].includes(e==null?void 0:e.app)||e.app==="konnect"&&!e.controlPlaneId||e.app==="kongManager"&&typeof e.workspace!="string")},entityMap:{type:Object,default:()=>({})},record:{type:Object,default:()=>({})},schema:{type:Object,default:()=>({})},rawSchema:{type:Object,default:()=>({})},editing:{type:Boolean,default:!1},credential:{type:Boolean,default:!1},enableVaultSecretPicker:{type:Boolean,default:!1},enableRedisPartial:{type:Boolean,default:!1}},emits:["loading","model-updated","showNewPartialModal","globalAction","validity-change"],setup(e,{emit:n}){var me,ge;const o=Object.keys(Ie.sharedForms),r=Object.keys(wm);if(new Set([...o,...r]).size!==o.length+r.length)throw new Error("Duplicate form component names found in `sharedForms` and `freeForm`");const i=n,a=e,{axiosInstance:l}=se.useAxios((me=a.config)==null?void 0:me.axiosRequestConfig),{parseSchema:s}=Re.useSchemas({entityId:((ge=a.entityMap.focusedEntity)==null?void 0:ge.id)||void 0,credential:a.credential,enableRedisPartial:a.enableRedisPartial,experimentalRenders:a.config.app==="konnect"?a.config.experimentalRenders:void 0}),{convertToDotNotation:c,unFlattenObject:d,dismissField:u,isObjectEmpty:f,unsetNullForeignKey:p}=Re.usePluginHelpers(),m=Re.useExperimentalFreeForms(),{objectsAreEqual:h}=se.useHelpers(),{i18n:{t:y}}=xe(),g=ne=>a.config.app==="konnect"?ne.replace(/{controlPlaneId}/gi,a.config.controlPlaneId||""):a.config.app==="kongManager"?ne.replace(/\/{workspace}/gi,a.config.workspace?`/${a.config.workspace}`:""):ne,_=(ne,re)=>{let q=`${a.config.apiBaseUrl}${Me.form[a.config.app].entityGetOne}`;return q=g(q),q=q.replace(/{entity}/gi,ne),q=q.replace(/{id}/gi,re),q},w=ne=>{let re=`${a.config.apiBaseUrl}${Me.form[a.config.app].entityGetAll}`;return re=g(re),re=re.replace(/{entity}/gi,ne),re},b=(ne,re)=>{const q=_(ne,re);return l.get(q)},v=(ne,re)=>{const q=w(ne);return a.config.app==="konnect"?l.get(q).then(ee=>{const{data:{data:O}}=ee;if(delete re.size,delete re.offset,O.length&&Object.keys(re).length===1){const k=Object.keys(re)[0],C=O.filter(A=>A[k]?!!A[k].toLowerCase().includes(re[k].toLowerCase()):!1);ee.data.data=C}return ee}):l.get(q,{params:re})},N=(ne,re,q)=>{const ee=w(ne);if(a.config.app==="konnect"){const{size:O,offset:k,...C}=re;if(ne==="consumer_groups")return l.get(ee,{params:{size:1e3},signal:q}).then(x=>{const{data:{data:U}}=x;if(U.length&&Object.keys(C).length===1){const V=Object.keys(C)[0],J=U.filter($=>$[V]?!!$[V].toLowerCase().includes(C[V].toLowerCase()):!1);x.data.data=J}return x});const A={size:O,offset:k};for(const x of Object.keys(C))A.filter={[x]:{contains:C[x]}};return l.get(ee,{params:A,signal:q})}return l.get(ee,{params:re,signal:q})},E=(ne,re=50)=>{const q=w(ne);return l.get(q,{params:{size:re}})};t.provide(Ie.FORMS_API_KEY,{getOne:b,getAll:v,getAllV2:N,peek:E}),t.provide(Ie.FORMS_CONFIG,a.config);const S=t.ref(""),P=t.ref(""),B=t.ref(null),j=t.ref({}),G=t.reactive({}),T=t.reactive({}),Y=t.computed(()=>{var ne;return(ne=B.value)==null?void 0:ne.options}),I=t.ref(!1),M=t.ref(),R=(ne,re)=>{I.value=ne??"",M.value=re},te=ne=>{var re;(re=M.value)==null||re.call(M,ne),I.value=!1},z=()=>{var C,A;const ne={...a.schema},re=T,q=G,ee=Object.keys(re),O={};if(!f(j.value))for(let x=0;x<((A=(C=j.value)==null?void 0:C.fields)==null?void 0:A.length);x++)ne[j.value.fields[x].model]=j.value.fields[x];Ie.customFields.forEach(x=>{ne[x]&&(ne[x].fields.forEach(U=>{U.fields&&U.fields.forEach(V=>{ne[V.model]=V}),U.model&&(ne[U.model]=U)}),delete ne[x])}),ee.forEach(x=>{var _e;if(!ne[x]){x==="partials"&&(O[x]=re[x]);return}const U=ne[x];let V=re[x];const J=q[x],$=Array.isArray(V)?"array":typeof V,X=U?U.valueType:null,D=U?U.valueArrayType:null,pe=U?U.transform:null;if(V==null&&J==null&&!U.submitWhenNull)return;if(U){if(X&&$!==X)switch(X){case"array":$==="string"&&V.length&&(V=V.split(",").map(fe=>{if(fe=fe.trim(),D==="string")return String(fe);if(D==="number")return Number(fe);if(D==="boolean"){if(typeof fe=="string")return fe.toLowerCase()==="true"||fe==="1";if(typeof fe=="number")return fe===1}return fe})),(!V||!V.length)&&(V=U.submitWhenNull?null:[]);break;case"number":V=Number(V);break;case"boolean":$==="string"&&(V=V.toLowerCase()==="true"||V==="1"),$==="number"&&(V=V===1);break;case"string":V=V==null?"":String(V);break}else X==="array"&&(!V||!V.length?V=U.submitWhenNull?null:[]:((_e=U.inputAttributes)==null?void 0:_e.type)==="number"&&(V=V.map(fe=>Number(fe))));if(U.type==="array"&&U.nestedFields){const fe=oe=>{Object.keys(oe).forEach(be=>{oe[be]&&typeof oe[be]=="object"&&!Array.isArray(oe[be])&&oe[be]!==null?fe(oe[be]):(oe[be]===void 0||oe[be]===null||typeof oe[be]=="number"&&isNaN(oe[be])||typeof oe[be]=="string"&&oe[be].trim().length===0)&&delete oe[be]})};V&&typeof V=="object"&&fe(V)}U.type==="object-advanced"&&U.fields&&V!==null&&(Object.entries(V).length===0?V=null:Object.keys(V).forEach(fe=>{Array.isArray(V[fe])||(V[fe]=V[fe].split(","))}))}let le=c(x);if(U.fieldNameHasDashes){const[fe,...oe]=le.split(".").reverse();le=[fe.replace(/_/g,"-"),...oe].reverse().join(".")}if(X==="object-expand"){let fe;[le,fe]=le.split(".");let oe={};O[le]&&(oe=O[le]),oe[fe]=V,V=oe}J!==void 0&&V===""&&V!==J?O[le]=X==="object"?{}:null:U.type==="checklist"&&V===""?O[le]=[]:V!==""&&(O[le]=V),O[le]=pe?pe(V):O[le],p(le,O)});const k=d(O);return P.value&&Object.assign(k,Q.value),k},H=(ne,re={})=>{u(T,re,ne,a.editing),i("model-updated",{model:T,originalModel:G,data:z()})},L=(ne,re)=>{var O;const q={[re]:ne};typeof((O=a.schema[re])==null?void 0:O.modelTransformer)=="function"&&(q[re]=a.schema[re].modelTransformer(ne));const ee=Object.assign({},T,q);Object.assign(T,ee),i("model-updated",{model:T,originalModel:G,data:z()})},F=ne=>{i("validity-change",ne)},Z=(ne,re)=>{Object.keys(ne).forEach(q=>{var A,x;let ee=re?`${re}-${q}`:q,O=a.schema[ee];if(!O){const U=re?`${re}-${q.replace(/-/g,"_")}`:q.replace(/-/g,"_");(A=a.schema[U])!=null&&A.fieldNameHasDashes&&(ee=U,O=a.schema[ee]),re&&((x=a.schema[re])==null?void 0:x.keyFromObject)===q&&(ee=re,O=a.schema[ee])}const k=ne[q],C=typeof k;if(O&&O.type==="object-advanced"&&!k){T[ee]={},G[ee]={};return}if(Array.isArray(k)){T[ee]=JSON.parse(JSON.stringify(k)),G[ee]=JSON.parse(JSON.stringify(k));return}if(C==="object"&&k&&!k.length)return Z(k,ee);if(C==="object"&&k&&k.length&&O.type==="input"){T[ee]=k.join(", "),G[ee]=k.join(", ");return}T[ee]=k,G[ee]=k}),i("model-updated",{model:T,originalModel:G,data:z()})},Q=t.shallowRef(a.record),W=ne=>{Q.value=ne,i("model-updated",{model:{...T,...ne},originalModel:G,data:z()})},ie=t.ref(!0),ae=()=>{var ne;if(a.record&&a.schema&&(Z({enabled:a.record.enabled??!0,...a.record.instance_name&&{instance_name:a.record.instance_name||""},...a.record.protocols&&{protocols:a.record.protocols},...a.record.tags&&{tags:a.record.tags}}),a.credential?((a.record.consumer_id||a.record.consumer)&&Z({consumer_id:a.record.consumer_id||a.record.consumer}),Z(a.record)):a.record.config&&((a.record.consumer_id||a.record.consumer||a.record.service_id||a.record.service||a.record.route_id||a.record.route||a.record.consumer_group_id||a.record.consumer_group)&&Z({service_id:a.record.service_id||a.record.service,route_id:a.record.route_id||a.record.route,consumer_id:a.record.consumer_id||a.record.consumer,consumer_group_id:a.record.consumer_group_id||a.record.consumer_group}),a.record.partials&&H("redis",{partials:a.record.partials}),P.value?W(a.record):Z(a.record.config,"config"))),Object.keys(a.entityMap).length&&!a.entityMap.global&&a.schema){const re={};for(const q in a.entityMap){const ee=a.entityMap[q].id,O=a.entityMap[q].idField,k=O==="consumer_group_id"?"consumer_group-id":JSON.parse(JSON.stringify(O).replace("_","-"));Object.prototype.hasOwnProperty.call(T,k)&&(re[k]=ee)}Z(re)}if((ne=a.entityMap.consumer)!=null&&ne.id&&a.schema&&a.credential){const re={};Object.prototype.hasOwnProperty.call(T,"consumer")&&(re.consumer=a.entityMap.consumer.id),Z(re)}ie.value=!1};return t.watch(ie,ne=>{i("loading",ne)}),t.watch(()=>a.schema,(ne,re)=>{var ee,O;if(h(ne||{},re||{}))return;const q=s(ne);Object.assign(T,q.model),j.value={fields:(O=(ee=j.value)==null?void 0:ee.fields)==null?void 0:O.map(k=>({...k,disabled:k.disabled||!1}))},Object.assign(G,JSON.parse(JSON.stringify(q.model))),P.value=wc(q.model.name,m),S.value=Ie.getSharedFormName(q.model.name),ae()},{immediate:!0,deep:!0}),t.onBeforeMount(()=>{var ne,re;B.value=s(a.schema),Object.assign(T,((ne=B.value)==null?void 0:ne.model)||{}),j.value=((re=B.value)==null?void 0:re.schema)||{},ae()}),(ne,re)=>{var ee;const q=t.resolveComponent("KSkeleton");return t.openBlock(),t.createElementBlock(t.Fragment,null,[t.createElementVNode("div",pR,[ie.value?(t.openBlock(),t.createBlock(q,{key:0,type:"form"})):T.id&&e.editing||!e.editing?(t.openBlock(),t.createElementBlock("div",mR,[P.value?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(wm[P.value]),{key:0,"form-model":T,"form-options":Y.value,"form-schema":j.value,"is-editing":e.editing,model:e.record,"on-form-change":W,"on-model-updated":L,"on-validity-change":F,schema:e.rawSchema,onGlobalAction:re[0]||(re[0]=(O,k)=>ne.$emit("globalAction",O,k))},t.createSlots({_:2},[e.enableVaultSecretPicker?{name:t.unref(Ie.AUTOFILL_SLOT_NAME),fn:t.withCtx(O=>[O.schema.referenceable?(t.openBlock(),t.createBlock(t.unref(ar.VaultSecretPickerProvider),t.mergeProps({key:0},O,{onOpen:R}),null,16)):t.createCommentVNode("",!0)]),key:"0"}:void 0]),1064,["form-model","form-options","form-schema","is-editing","model","schema"])):S.value?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(t.unref(Ie.sharedForms)[S.value]),{key:1,"enable-redis-partial":e.enableRedisPartial,"form-model":T,"form-options":Y.value,"form-schema":j.value,"is-editing":e.editing,"on-model-updated":L,"on-partial-toggled":H,"show-new-partial-modal":O=>ne.$emit("showNewPartialModal",O)},t.createSlots({_:2},[e.enableVaultSecretPicker?{name:t.unref(Ie.AUTOFILL_SLOT_NAME),fn:t.withCtx(O=>[O.schema.referenceable?(t.openBlock(),t.createBlock(t.unref(ar.VaultSecretPickerProvider),t.mergeProps({key:0},O,{onOpen:R}),null,16)):t.createCommentVNode("",!0)]),key:"0"}:void 0]),1064,["enable-redis-partial","form-model","form-options","form-schema","is-editing","show-new-partial-modal"])):(t.openBlock(),t.createBlock(t.unref(Ie.VueFormGenerator),{key:2,"enable-redis-partial":e.enableRedisPartial,"is-editing":e.editing,model:T,options:Y.value,schema:j.value,onModelUpdated:L,onPartialToggled:H,onRefreshModel:z,onShowNewPartialModal:re[1]||(re[1]=O=>ne.$emit("showNewPartialModal",O))},t.createSlots({"plugin-config-empty-state":t.withCtx(()=>[t.createElementVNode("div",gR,t.toDisplayString(t.unref(y)("plugins.form.grouping.plugin_configuration.empty")),1)]),_:2},[(ee=t.unref(Et)[T.name])!=null&&ee.fieldRules&&(a.config.isNewOtelSchema||T.name!=="opentelemetry")?{name:"plugin-config-before-content",fn:t.withCtx(()=>[t.createVNode(B0,{rules:t.unref(Et)[T.name].fieldRules},null,8,["rules"])]),key:"0"}:void 0,e.enableVaultSecretPicker?{name:t.unref(Ie.AUTOFILL_SLOT_NAME),fn:t.withCtx(O=>[O.schema.referenceable?(t.openBlock(),t.createBlock(t.unref(ar.VaultSecretPickerProvider),t.mergeProps({key:0},O,{onOpen:R}),null,16)):t.createCommentVNode("",!0)]),key:"1"}:void 0]),1032,["enable-redis-partial","is-editing","model","options","schema"]))])):t.createCommentVNode("",!0)]),t.createVNode(t.unref(ar.VaultSecretPicker),{config:a.config,setup:I.value,onCancel:re[2]||(re[2]=()=>I.value=!1),onProceed:te},null,8,["config","setup"])],64)}}}),[["__scopeId","data-v-5728fdd6"]]),yR={key:1},_R=t.defineComponent({__name:"PluginFormActionsWrapper",props:{teleportTarget:{type:String,default:""}},setup(e){return(n,o)=>e.teleportTarget?(t.openBlock(),t.createBlock(t.Teleport,{key:0,to:e.teleportTarget},[t.renderSlot(n.$slots,"default")],8,["to"])):(t.openBlock(),t.createElementBlock("div",yR,[t.renderSlot(n.$slots,"default")]))}}),bR={class:"kong-ui-entities-plugin-form-container"},wR={key:0},kR={class:"plugin-form-actions"},ER=Ee(t.defineComponent({__name:"PluginForm",props:{config:{type:Object,required:!0,validator:e=>!(!e||!["konnect","kongManager"].includes(e==null?void 0:e.app)||e.app==="konnect"&&!e.controlPlaneId||e.app==="kongManager"&&typeof e.workspace!="string")},pluginType:{type:String,required:!0},pluginId:{type:String,default:""},hideScopeSelection:{type:Boolean,default:!1},disableScopeSelection:{type:Boolean,default:!1},credential:{type:Boolean,default:!1},developer:{type:Boolean,default:!1},isWizardStep:{type:Boolean,default:!1},actionsTeleportTarget:{type:String,default:""},noCardWrapper:{type:Boolean,default:!1},hideViewConfigAction:{type:Boolean,default:!1},enableVaultSecretPicker:{type:Boolean,default:!1},schema:{type:Object,default:null},enableRedisPartial:{type:Boolean,default:!1},scopedEntitiesPermissions:{type:Object,default:null}},emits:["cancel","error:fetch-schema","error","loading","update","model-updated","showNewPartialModal","globalAction"],setup(e,{emit:n}){var J;const o=n,r=e,i=oo.useRouter(),{i18n:{t:a}}=Re.useI18n(),{customSchemas:l,typedefs:s}=Re.useSchemas({app:r.config.app,credential:r.credential,experimentalRenders:r.config.app==="konnect"?r.config.experimentalRenders:void 0}),{formatPluginFieldLabel:c}=Re.usePluginHelpers(),{getMessageFromError:d}=se.useErrors(),{capitalize:u}=se.useStringHelpers(),{objectsAreEqual:f}=se.useHelpers(),{axiosInstance:p}=se.useAxios((J=r.config)==null?void 0:J.axiosRequestConfig),m=t.ref(!1),h=t.computed(()=>!!r.pluginId),y=t.computed(()=>r.pluginId?se.EntityBaseFormType.Edit:se.EntityBaseFormType.Create),g=t.ref(void 0),_=t.ref(void 0),w=t.computed(()=>!!(r.credential&&r.config.entityId)),b=t.ref(void 0),v=t.ref({}),N=t.ref(),E=t.ref();t.provide(jc,{redisType:N,redisPath:E,isEditing:h.value});const S=t.ref(!1),P=t.reactive({enabled:!0,protocols:[],tags:[]}),B=t.reactive({fields:{enabled:!0,protocols:[],tags:[]},isReadonly:!1,clientErrorMessage:"",serverErrorMessage:""}),j=t.ref([{title:a("view_configuration.json"),hash:"#json"},{title:a("view_configuration.yaml"),hash:"#yaml"}]);r.config.app==="konnect"&&j.value.splice(1,0,{title:a("view_configuration.terraform"),hash:"#terraform"});const G=t.ref(""),T=t.computed(()=>{var X;if(w.value){let D=Me.form[r.config.app].credential[y.value];return D=D.replace(/{resourceEndpoint}/gi,R.value),D}let $;return r.config.entityType&&r.config.entityId?$=Me.form[r.config.app].edit.forEntity.replace(/{entityType}/gi,r.config.entityType).replace(/{entityId}/gi,r.config.entityId):$=Me.form[r.config.app].edit.all,r.config.app==="konnect"&&((X=Et[r.pluginType])!=null&&X.useUIData)?`${$}?__ui_data=true`:$}),Y=()=>{m.value=!m.value},I=t.computed(()=>{var _e,fe,oe,be,ve,ue,de,it;const $=r.config.entityType==="consumers"&&r.config.entityId||((fe=(_e=b.value)==null?void 0:_e.consumer)==null?void 0:fe.id),X=r.config.entityType==="consumer_groups"&&r.config.entityId||((be=(oe=b.value)==null?void 0:oe.consumer_group)==null?void 0:be.id),D=r.config.entityType==="services"&&r.config.entityId||((ue=(ve=b.value)==null?void 0:ve.service)==null?void 0:ue.id),pe=r.config.entityType==="routes"&&r.config.entityId||((it=(de=b.value)==null?void 0:de.route)==null?void 0:it.id);if(!($||X||D||pe))return{global:{entity:K.PluginScope.GLOBAL,entityEndpoint:"plugins"}};const le={};return D&&(le.service={entity:K.PluginScope.SERVICE,entityEndpoint:"services",id:D,idField:nn.SERVICE}),pe&&(le.route={entity:K.PluginScope.ROUTE,entityEndpoint:"routes",id:pe,idField:nn.ROUTE}),$&&(le.consumer={entity:K.PluginScope.CONSUMER,entityEndpoint:"consumers",id:$,idField:nn.CONSUMER}),X&&(le.consumer_group={entity:K.PluginScope.CONSUMER_GROUP,entityEndpoint:"consumer_groups",id:X,idField:nn.CONSUMER_GROUP}),r.config.entityType&&(le.focusedEntity={entity:K.PluginScope[r.config.entityType.substring(0,r.config.entityType.length-1).toUpperCase()],entityEndpoint:r.config.entityType,id:r.config.entityId,idField:nn[r.config.entityType.substring(0,r.config.entityType.length-1).toUpperCase()]}),le}),M=t.reactive({name:{default:r.pluginType,type:"input",inputType:"hidden",styleClasses:"d-none hidden-field",pinned:!0},enabled:{type:"switch",model:"enabled",label:a("plugins.form.fields.enabled.label"),textOn:a("plugins.form.fields.enabled.on_text"),textOff:a("plugins.form.fields.enabled.off_text"),styleClasses:"field-switch hide-label",default:!0,pinned:!0},selectionGroup:{type:r.hideScopeSelection&&(r.hideScopeSelection||y.value===se.EntityBaseFormType.Create&&r.config.entityId)?"foreign":"selectionGroup",disabled:r.disableScopeSelection,inputType:"hidden",styleClasses:"hide-label",fields:[{label:a("plugins.form.scoping.global.label"),description:a("plugins.form.scoping.global.help")}],pinned:!0},protocols:{id:"protocols",default:[],help:a("plugins.form.fields.protocols.help"),label:a("plugins.form.fields.protocols.label"),required:!0,styleClasses:"plugin-protocols-select",type:"multiselect",values:[{label:"grpc",value:"grpc"},{label:"grpcs",value:"grpcs"},{label:"http",value:"http"},{label:"https",value:"https"},{label:"tcp",value:"tcp"},{label:"tls",value:"tls"},{label:"tls_passthrough",value:"tls_passthrough"},{label:"udp",value:"udp"},{label:"ws",value:"ws"},{label:"wss",value:"wss"}]},instance_name:{default:"",type:"input",label:a("plugins.form.fields.instance_name.label"),inputType:"text",help:a("plugins.form.fields.instance_name.help")},tags:s.tags}),R=t.computed(()=>{var D;const $=r.developer?"developers":"consumers",X=((D=An[r.pluginType])==null?void 0:D.endpoint)||"/plugins";return`${$}/${r.config.entityId}${r.developer?"/credentials":""}${X}`}),te=$=>{const X=Array.from(new Set($.map(D=>typeof D)));return X.length>1?"string":X[0]},z=($,X,D,pe)=>{var oe,be;let le=X&&X.fields||[];const _e=l[r.pluginType],fe=(be=(oe=An[r.pluginType])==null?void 0:oe.schema)==null?void 0:be.fields;return Array.isArray(le)&&(le=le.reduce((ve,ue)=>{const de=Object.keys(ue)[0];return de.match(/-/g)?ve[de.replace(/-/g,"_")]={...ue[de],fieldNameHasDashes:!0}:ve[de]=ue[de],ve},{})),Object.keys(le).sort().forEach(ve=>{var Jo,Qo,er,tr,nr,or,rr;const ue=le[ve];ue.type==="set"&&(ue.type="array");const de=$?`${$}-${ve}`:`${ve}`;if((Jo=_e==null?void 0:_e.fieldsToDelete)!=null&&Jo.includes(de)){bc(D,de);return}if(Object.prototype.hasOwnProperty.call(ue,"overwrite")||ue.hidden)return;if(ue.type==="table")return z(de,ue.schema,D);if(ue.fields)return pe&&ue.type==="record"?(D[de]={type:"object",model:ve,schema:{fields:Object.values(z(de,ue,{},!0))}},D):z(de,ue,D);if(D[de]={id:de,model:ve},D[de].type=ue.type==="boolean"?"checkbox":"input",D[de].required=ue.required,D[de].referenceable=ue.referenceable,de.startsWith("config-"))if(!pe&&ue.type==="array"&&(G.value=de),pe&&G.value&&de.startsWith(G.value)){const Se=de.slice(G.value.length+1);D[de].label=Se.split("-").map(c).join(".")}else D[de].label=c(de);if(($==="config"||$.startsWith("config-"))&&(Qo=le[ve])!=null&&Qo.description&&(D[de].help=ir.marked.parse(le[ve].description,{mangle:!1,headerIds:!1})),ue.type==="map"){if(D[de].type="object-advanced",D[de].values=ue.values,ue.values.type==="array"){const{type:Se}=ue.values.elements||{};D[de].schema={fields:[{schema:{fields:[{...Te,model:de,valueArrayType:Se==="integer"?"number":Se||"string",inputAttributes:{...Te.inputAttributes,type:Se==="integer"?"number":"text",inputMode:Se==="integer"?"numeric":"text"}}]}}]}}else ue.values.fields&&(D[de].schema={fields:[{type:"object",model:"object",schema:{fields:ue.values.fields.map(Se=>{const at=Object.keys(Se)[0];return{model:at,type:"input",label:u(at),placeholder:at,inputType:Se[at].type}})}}]});return D}if(ue.enum&&ue.type==="array"&&(D[de].type="checklist",D[de].values=ue.enum,D[de].multi=!0,D[de].multiSelect=!0),ue.one_of&&ue.type!=="array"&&(D[de].type="select",D[de].values=ue.one_of,D[de].selectOptions={noneSelectedText:a("plugins.form.no_selection")}),ue.elements&&ue.type==="array"){const Se=ue.elements;if(D[de].referenceable=Se.referenceable,D[de].elements=Se,["string","integer","number"].includes(Se.type)&&!Se.one_of){const{id:at,help:Le,label:Ce,hint:Ae,values:$e,referenceable:zt,model:dt}=D[de],{inputAttributes:Oi,...gD}=JSON.parse(JSON.stringify(Te));Oi.type=Se.type==="string"?"text":"number",D[de]={id:at,help:Le,label:Ce,hint:Ae,values:$e,referenceable:zt,model:dt,inputAttributes:Oi,...gD}}}if(ue.hint&&(D[de].hint=ue.hint),_e&&!_e.overwriteDefault&&Object.keys(_e).forEach(Se=>{if(Se===de){const{help:at,label:Le,hint:Ce,values:Ae,referenceable:$e,elements:zt}=D[de],{help:dt,...Oi}=_e[Se];D[de]={help:at,label:Le,hint:Ce,values:Ae,referenceable:$e,elements:zt,...Oi},typeof dt=="string"&&(D[de].help=ir.marked.parse(dt,{mangle:!1,headerIds:!1}))}}),ue.type==="array"&&((er=ue.elements)==null?void 0:er.type)==="record"&&Array.isArray(ue.elements.fields)){let Se={};for(const Le of ue.elements.fields)Se={...Se,...Le};const at=(or=(nr=(tr=D[de])==null?void 0:tr.items)==null?void 0:nr.schema)==null?void 0:or.fields;if(Array.isArray(at))for(const Le of D[de].items.schema.fields){const Ce=(rr=Se[Le.model])==null?void 0:rr.description;Le.help===void 0&&typeof Ce=="string"&&(Le.help=ir.marked.parse(Ce,{mangle:!1,headerIds:!1}))}if(at||(D[de].type="array",D[de].newElementButtonLabelClasses="kong-form-new-element-button-label",D[de].fieldClasses="array-card-container-wrapper",D[de].itemContainerComponent="FieldArrayCardContainer",D[de].items={type:"object",schema:{fields:Object.values(z(de,ue.elements,{},!0))}},D[de].items.schema.fields.forEach(Le=>{var Ce,Ae;for(const $e of ue.elements.fields){const zt=Object.keys($e)[0],dt=((Ae=(Ce=Le.id)==null?void 0:Ce.split)==null?void 0:Ae.call(Ce,"-"))??[];if(dt[dt.length-1]===zt){Le.model=zt,Le.label=c(zt);break}}}),ue.elements.type==="record"&&(D[de].nestedFields=!0)),!D[de].nestedFields)D[de].items.default=()=>ue.elements.fields.reduce((Le,Ce)=>{const Ae=Object.keys(Ce)[0];return Le[Ae]=Ce[Ae].default,Le},{});else{const Le=(Ce,Ae)=>{if(Ce.type==="object"){Ce.model&&(Ae[Ce.model]={});for(const $e of Ce.schema.fields)Le($e,Ce.model?Ae[Ce.model]:Ae)}else Ce.model&&(Ae[Ce.model]=Ce.default)};D[de].items.default=()=>{const Ce={};return Le(D[de].items,Ce),Ce}}}if(w.value&&fe){for(let Se=0;Se<fe.length;Se++)if(fe[Se][de]){D[de]={...D[de],...fe[Se][de]};break}}if(ue.required&&ue.type!=="boolean"&&(D[de].required=!0,D[de].selectOptions={hideNoneSelectedText:!0}),ue.required&&ue.type==="boolean"&&(D[de].default=ue.default??!1),ue.default!=null&&typeof ue.default!="object"&&ue.default!=="function"&&(D[de].default=ue.default),D[de].type==="input"){["string","number"].includes(typeof D[de].default)&&r.config.app==="konnect"&&(D[de].placeholder=`Default: ${D[de].default===""?"<empty string>":D[de].default}`);const{type:Se}=ue.elements||{};Se&&(D[de].valueArrayType=Se==="integer"?"number":Se),D[de].inputType=ue.type==="array"||ue.type==="string"?ue.encrypted?"password":"text":ue.type}let it="string";ue.enum?it=te(ue.enum):ue.type==="boolean"?it="boolean":ue.type==="number"||ue.type==="integer"?(it="number",D[de].inputType="number"):ue.type==="array"?(it="array",D[de].default=ue.default,ue.len_min>0&&(D[de].submitWhenNull=!0)):ue.type==="foreign"?it="object":ue.default&&Array.isArray(ue.default)?(it="array",D[de].valueArrayType=te(ue.default)):ue.default&&(it=typeof ue.default),D[de].valueType=it,ue.fieldNameHasDashes&&(D[de].fieldNameHasDashes=!0)}),D},H=()=>{var de,it,Jo,Qo,er,tr,nr,or,rr,Se,at,Le;const $=((de=Et[r.pluginType])==null?void 0:de.scope.includes(K.PluginScope.SERVICE))??!0,X=((it=Et[r.pluginType])==null?void 0:it.scope.includes(K.PluginScope.ROUTE))??!0,D=((Jo=Et[r.pluginType])==null?void 0:Jo.scope.includes(K.PluginScope.CONSUMER))??!0,pe=r.config.disableConsumerGroupScope?!1:((Qo=Et[r.pluginType])==null?void 0:Qo.scope.includes(K.PluginScope.CONSUMER_GROUP))??!0,le=r.config.entityType==="consumers"&&!!r.config.entityId||!!((tr=(er=b.value)==null?void 0:er.consumer)!=null&&tr.id),_e=r.config.entityType==="consumer_groups"&&!!r.config.entityId||!!((or=(nr=b.value)==null?void 0:nr.consumer_group)!=null&&or.id),fe=r.config.entityType==="services"&&!!r.config.entityId||!!((Se=(rr=b.value)==null?void 0:rr.service)!=null&&Se.id),oe=r.config.entityType==="routes"&&!!r.config.entityId||!!((Le=(at=b.value)==null?void 0:at.route)!=null&&Le.id),be=[],ve=(Ce,Ae,$e)=>Ce?a("plugins.form.disable_source_scope_change",{scope:$e}):Ae?a("plugins.form.disable_data_retrieving",{scope:$e}):"",ue=Ce=>{var Ae,$e;return(($e=(Ae=r.scopedEntitiesPermissions)==null?void 0:Ae[Ce])==null?void 0:$e.canRetrieve)===!1};if($){const Ce=ue("service"),Ae="services",$e=fe&&r.disableScopeSelection;be.push({id:"service-id",model:"service-id",label:a("plugins.form.scoping.gateway_service.label"),placeholder:a("plugins.form.scoping.placeholder"),type:"AutoSuggestV2",labelField:"name",entity:Ae,inputValues:{fields:["name","id"]},help:a("plugins.form.scoping.gateway_service.help"),disabled:$e||Ce,disabledTooltip:ve($e,Ce,Ae)})}if(X){const Ce=ue("route"),Ae="routes",$e=oe&&r.disableScopeSelection;be.push({id:"route-id",model:"route-id",label:a("plugins.form.scoping.route.label"),placeholder:a("plugins.form.scoping.placeholder"),type:"AutoSuggestV2",entity:Ae,labelField:"name",inputValues:{fields:["name","id"],primaryField:"id"},help:a("plugins.form.scoping.route.help"),disabled:$e||Ce,disabledTooltip:ve($e,Ce,Ae)})}if(D){const Ce=ue("consumer"),Ae="consumers",$e=le&&r.disableScopeSelection;be.push({model:"consumer-id",label:a("plugins.form.scoping.consumer.label"),placeholder:a("plugins.form.scoping.placeholder"),type:"AutoSuggestV2",entity:Ae,labelField:"username",inputValues:{fields:["username","custom_id","id"],primaryField:"username"},help:a("plugins.form.scoping.consumer.help"),disabled:$e||Ce,disabledTooltip:ve($e,Ce,Ae)})}if(pe){const Ce=ue("consumer_group"),Ae="consumer_groups",$e=_e&&r.disableScopeSelection;be.push({model:"consumer_group-id",label:a("plugins.form.scoping.consumer_group.label"),placeholder:a("plugins.form.scoping.placeholder"),type:"AutoSuggestV2",entity:Ae,entityDataKey:"consumer_group",labelField:"name",inputValues:{fields:["name","id"],primaryField:"name"},help:a("plugins.form.scoping.consumer_group.help"),disabled:$e||Ce,disabledTooltip:ve($e,Ce,Ae)})}if(be.length){const Ce=[...$?["service"]:[],...X?["route"]:[],...D?["consumer"]:[],...pe?["consumer_group"]:[]],$e=Ce.splice(Ce.length-2,2).map(dt=>a(dt==="service"?"plugins.form.scoping.gateway_service.plural":`plugins.form.scoping.${dt}.plural`)).join(`${Ce.length>0?",":""} and/or `),zt=["Specific",[...Ce.length>0?[Ce.map(dt=>a(dt==="service"?"plugins.form.scoping.gateway_service.plural":`plugins.form.scoping.${dt}.plural`)).join(", ")]:[],$e].join(", ")].join(" ");M.selectionGroup.fields.push({label:a("plugins.form.scoping.label"),description:zt,fields:[]}),M.selectionGroup.fields[1].fields=be}l[r.pluginType]&&l[r.pluginType].overwriteDefault&&Object.hasOwnProperty.call(l[r.pluginType],"formSchema")&&Object.assign(M,l[r.pluginType].formSchema)},L=t.computed(()=>!f(B.fields,P,!0)),F=t.computed(()=>!U.value&&!S.value&&(y.value===se.EntityBaseFormType.Create||L.value)),Z=t.ref(!1),Q=t.ref(),W=$=>{r.credential&&$.password&&($.password=""),B.fields.id=($==null?void 0:$.id)||void 0,Q.value=$==null?void 0:$.ordering,Object.assign(P,B.fields),b.value=$,Z.value=!0},ie=t.ref({}),ae=$=>{var X;B.fields=$.model,B.fields.id=((X=b.value)==null?void 0:X.id)||void 0,Object.assign(P,$.originalModel),ie.value=$.data,r.isWizardStep&&o("model-updated",{model:B.fields,data:$.data,resourceEndpoint:R.value})},me=t.ref(new Map),ge=t.computed(()=>[B.clientErrorMessage,B.serverErrorMessage].filter(Boolean).join("; ")),ne=$=>{$.valid?me.value.delete($.model):me.value.set($.model,$.error),B.clientErrorMessage=[...me.value.entries()].map(([X,D])=>`${X}: ${typeof D=="string"?D:d(D)}`).join("; "),B.clientErrorMessage&&(B.serverErrorMessage="")};t.watch([I,Z],($,X)=>{const D=$[0]!==X[0],pe=$[1],le=X[1];if(!w.value&&y.value===se.EntityBaseFormType.Edit&&(D||pe&&pe!==le)){const _e=z("config",v.value,M);O.value&&(_e._isCustomPlugin=!0),N.value&&(_e._supported_redis_partial_type=N.value),_.value=_e}},{deep:!0});const re=()=>{r.config.cancelRoute?i.push(r.config.cancelRoute):o("cancel")},q=t.computed(()=>{let $=`${r.config.apiBaseUrl}${Me.form[r.config.app].validate}`;return r.config.app==="konnect"?$=$.replace(/{controlPlaneId}/gi,r.config.controlPlaneId||""):r.config.app==="kongManager"&&($=$.replace(/\/{workspace}/gi,r.config.workspace?`/${r.config.workspace}`:"")),$=$.replace(/{id}/gi,r.pluginId),$}),ee=t.computed(()=>{const $=r.config.entityType&&r.config.entityId&&!r.developer,X=w.value?Me.form[r.config.app].credential[y.value]:Me.form[r.config.app][y.value][$?"forEntity":"all"];let D=`${r.config.apiBaseUrl}${X}`;return r.config.app==="konnect"?D=D.replace(/{controlPlaneId}/gi,r.config.controlPlaneId||""):r.config.app==="kongManager"&&(D=D.replace(/\/{workspace}/gi,r.config.workspace?`/${r.config.workspace}`:"")),D=D.replace(/{resourceEndpoint}/gi,R.value),D=D.replace(/{id}/gi,r.pluginId),D=D.replace(/{entityType}/gi,r.config.entityType||""),D=D.replace(/{entityId}/gi,r.config.entityId||""),D}),O=t.computed(()=>!Object.keys(Et).includes(r.pluginType)),k=t.computed(()=>{const $=ie.value;if(w.value){for(const X in K.PluginScope){const D=K.PluginScope[X];$[D]&&!$[D].id&&($[D]={id:r.config.entityId})}delete $.created_at}return ie.value.partials&&E.value&&bc($,E.value),$}),C=async()=>{if(!B.clientErrorMessage&&!r.isWizardStep)try{B.isReadonly=!0;let $;const X=JSON.parse(JSON.stringify(k.value)),D=l[r.pluginType];typeof(D==null?void 0:D.shamefullyTransformPayload)=="function"&&D.shamefullyTransformPayload({originalModel:P,model:B.fields,payload:X,schema:_.value}),!w.value&&!O.value&&await p.post(q.value,X),y.value==="create"?$=await p.post(ee.value,X):y.value==="edit"&&($=r.config.app==="konnect"||N.value&&X.partials?await p.put(ee.value,Object.assign({ordering:Q.value},X)):await p.patch(ee.value,X)),Object.assign(P,B.fields),o("update",$==null?void 0:$.data)}catch($){B.serverErrorMessage=d($),o("error",$)}finally{B.isReadonly=!1}},A=t.computed(()=>{var pe;const $=w.value?(pe=An[r.pluginType])==null?void 0:pe.schemaEndpoint:r.pluginType,X=w.value?Me.form[r.config.app].credentialSchema:Me.form[r.config.app].pluginSchema;let D=`${r.config.apiBaseUrl}${X}`;return r.config.app==="konnect"?D=D.replace(/{controlPlaneId}/gi,r.config.controlPlaneId||""):r.config.app==="kongManager"&&(D=D.replace(/\/{workspace}/gi,r.config.workspace?`/${r.config.workspace}`:"")),D=D.replace(/{plugin}/gi,$),D}),x=t.ref(""),U=t.ref(!1),V=t.ref("");return t.onBeforeMount(async()=>{var $,X,D,pe;U.value=!0;try{if(w.value&&r.config.app==="konnect"){const le=($=An[r.pluginType])==null?void 0:$.schemaEndpoint,_e=Dm[le];x.value=le,_.value=z("",_e,{}),U.value=!1}else{const le=r.schema??(await p.get(A.value)).data;if(g.value=le,le)if(w.value)_.value=z("",le,{}),U.value=!1;else{const _e=le.fields.find(oe=>oe.config);v.value=_e?_e.config:le,le.supported_partials&&(N.value=Object.keys(le.supported_partials).find(oe=>[sr.REDIS_CE,sr.REDIS_EE].includes(oe)),E.value=(X=le.supported_partials[N.value])==null?void 0:X[0]),H();const fe=(D=le.fields.find(oe=>oe.protocols))==null?void 0:D.protocols;if(fe){const{default:oe=[],elements:be={}}=fe;M.protocols.default=oe,M.protocols.placeholder=r.config.app==="konnect"?a("plugins.form.fields.protocols.placeholderWithDefaultValues",{protocols:oe.join(", ")}):a("plugins.form.fields.protocols.placeholder"),(pe=be.one_of)!=null&&pe.length&&(M.protocols.values=be.one_of.map(ve=>({label:ve,value:ve})))}if(Z.value||y.value===se.EntityBaseFormType.Create){const oe=z("config",v.value,M);N.value&&(oe._supported_redis_partial_type=N.value),O.value&&(oe._isCustomPlugin=!0),_.value=oe}}}}catch(le){console.error(le),V.value=d(le),o("error:fetch-schema",le)}finally{U.value=!1}}),($,X)=>{const D=t.resolveComponent("KSkeleton"),pe=t.resolveComponent("KEmptyState"),le=t.resolveComponent("KButton"),_e=t.resolveComponent("KTabs"),fe=t.resolveComponent("KSlideout");return t.openBlock(),t.createElementBlock("div",bR,[U.value?(t.openBlock(),t.createBlock(D,{key:0,type:"form"})):V.value?(t.openBlock(),t.createBlock(pe,{key:1,"action-button-visible":!1,"data-testid":"plugin-form-schema-error","icon-variant":"error"},{default:t.withCtx(()=>[t.createElementVNode("h3",null,t.toDisplayString(t.unref(a)("errors.load_schema")),1)]),_:1})):(t.openBlock(),t.createBlock(t.unref(se.EntityBaseForm),{key:2,"can-submit":F.value,config:e.config,"edit-id":e.pluginId,"entity-type":t.unref(se.SupportedEntityType).Plugin,"error-message":ge.value,"fetch-url":T.value,"form-fields":k.value,"is-readonly":B.isReadonly,"no-validate":"","wrapper-component":e.noCardWrapper?"div":void 0,onCancel:re,"onFetch:error":X[4]||(X[4]=oe=>$.$emit("error",oe)),"onFetch:success":W,onLoading:X[5]||(X[5]=oe=>$.$emit("loading",oe))},{"form-actions":t.withCtx(()=>[e.isWizardStep?(t.openBlock(),t.createElementBlock("div",wR)):(t.openBlock(),t.createBlock(_R,{key:1,"teleport-target":e.actionsTeleportTarget},{default:t.withCtx(()=>[t.createElementVNode("div",kR,[e.hideViewConfigAction?t.createCommentVNode("",!0):(t.openBlock(),t.createBlock(le,{key:0,appearance:"tertiary","data-testid":`plugin-${h.value?"edit":"create"}-form-view-configuration`,onClick:X[3]||(X[3]=oe=>Y())},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(a)("actions.view_configuration")),1)]),_:1},8,["data-testid"])),t.createVNode(le,{appearance:"secondary",class:"form-action-button","data-testid":`plugin-${h.value?"edit":"create"}-form-cancel`,disabled:B.isReadonly,onClick:re},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(a)("actions.cancel")),1)]),_:1},8,["data-testid","disabled"]),t.createVNode(le,{appearance:"primary","data-testid":`plugin-${h.value?"edit":"create"}-form-submit`,disabled:!F.value||B.isReadonly,type:"submit",onClick:C},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(a)("actions.save")),1)]),_:1},8,["data-testid","disabled"])])]),_:1},8,["teleport-target"]))]),default:t.withCtx(()=>[t.createElementVNode("form",{hidden:"",onSubmit:C},null,32),t.createVNode(hR,{config:e.config,credential:w.value,editing:y.value===t.unref(se.EntityBaseFormType).Edit,"enable-redis-partial":e.enableRedisPartial,"enable-vault-secret-picker":r.enableVaultSecretPicker,"entity-map":I.value,"raw-schema":g.value,record:b.value,schema:_.value,onGlobalAction:X[0]||(X[0]=(oe,be)=>$.$emit("globalAction",oe,be)),onLoading:X[1]||(X[1]=oe=>S.value=oe),onModelUpdated:ae,onShowNewPartialModal:X[2]||(X[2]=oe=>$.$emit("showNewPartialModal",oe)),onValidityChange:ne},null,8,["config","credential","editing","enable-redis-partial","enable-vault-secret-picker","entity-map","raw-schema","record","schema"])]),_:1},8,["can-submit","config","edit-id","entity-type","error-message","fetch-url","form-fields","is-readonly","wrapper-component"])),t.createVNode(fe,{"close-on-blur":!1,"data-testid":"form-view-configuration-slideout","has-overlay":!1,"offset-top":60,title:t.unref(a)("view_configuration.title"),visible:m.value,onClose:Y},{default:t.withCtx(()=>[t.createElementVNode("div",null,t.toDisplayString(t.unref(a)("view_configuration.message")),1),t.createVNode(_e,{"data-testid":"form-view-configuration-slideout-tabs",tabs:j.value},{json:t.withCtx(()=>[t.createVNode(t.unref(se.JsonCodeBlock),{config:e.config,"entity-record":k.value,"fetcher-url":ee.value,"request-method":r.pluginId?"put":"post"},null,8,["config","entity-record","fetcher-url","request-method"])]),yaml:t.withCtx(()=>[t.createVNode(t.unref(se.YamlCodeBlock),{"entity-record":k.value},null,8,["entity-record"])]),terraform:t.withCtx(()=>[t.createVNode(t.unref(se.TerraformCodeBlock),{"credential-type":x.value,"entity-record":k.value,"entity-type":t.unref(se.SupportedEntityType).Plugin},null,8,["credential-type","entity-record","entity-type"])]),_:1},8,["tabs"])]),_:1},8,["title","visible"])])}}}),[["__scopeId","data-v-7a402d18"]]),CR={class:"kong-ui-entities-plugins-list"},NR={class:"button-row"},vR={class:"name-cell-wrapper"},SR={class:"info-wrapper"},xR={key:0,class:"info-name"},AR={key:1,class:"info-name"},IR={key:2,class:"info-type"},PR={key:1},TR=Ee(t.defineComponent({__name:"PluginList",props:{config:{type:Object,required:!0,validator:e=>!(!e||!["konnect","kongManager"].includes(e==null?void 0:e.app)||!e.createRoute||!e.getViewRoute||!e.getEditRoute||!e.getConfigureDynamicOrderingRoute||e.app==="kongManager"&&!e.isExactMatch&&!e.filterSchema)},cacheIdentifier:{type:String,default:""},canCreate:{type:Function,required:!1,default:async()=>!0},canDelete:{type:Function,required:!1,default:async()=>!0},canEdit:{type:Function,required:!1,default:async()=>!0},canToggle:{type:Function,required:!1,default:async()=>!0},canRetrieve:{type:Function,required:!1,default:async()=>!0},canRetrieveScopedEntity:{type:Function,required:!1,default:async()=>!0},canConfigureDynamicOrdering:{type:Function,required:!1,default:async()=>!0},title:{type:String,default:""},titleTag:{type:String,default:"h2"},useActionOutside:{type:Boolean,default:!1}},emits:["error","click:learn-more","copy:success","copy:error","delete:success","toggle-enabled"],setup(e,{emit:n}){var x,U;const o=Re.usePluginMetaData(),r=n,i=e,{i18n:{t:a}}=Re.useI18n(),l=oo.useRouter(),{axiosInstance:s}=se.useAxios((x=i.config)==null?void 0:x.axiosRequestConfig),{hasRecords:c,handleStateChange:d}=se.useTableState(()=>b.value),u=t.computed(()=>c.value&&i.config.app==="konnect"),f=t.computed(()=>!!i.config.entityId),p=t.computed(()=>{var V;return((V=i.config)==null?void 0:V.entityType)==="consumers"}),m=t.computed(()=>{var V;return((V=i.config)==null?void 0:V.entityType)==="consumer_groups"}),h=i.config.app==="konnect"||se.useGatewayFeatureSupported({gatewayInfo:i.config.gatewayInfo,supportedRange:{enterprise:["3.0"]}}),y=t.computed(()=>i.config.app!=="kongManager"||!!i.config.disableSorting),g={name:{label:a("plugins.list.table_headers.name"),searchable:!0,sortable:!0,hidable:!1}};(U=i.config)!=null&&U.entityId||(g.appliedTo={label:a("plugins.list.table_headers.applied_to"),sortable:!1}),g.enabled={label:a("plugins.list.table_headers.enabled"),searchable:!0,sortable:!0},h&&(g.ordering={label:a("plugins.list.table_headers.ordering"),sortable:!0}),g.tags={label:a("plugins.list.table_headers.tags"),sortable:!1};const _=g,w=t.computed(()=>{var J,$,X,D;let V=i.config.entityType?`${i.config.apiBaseUrl}${Me.list[i.config.app].forEntity}`:`${i.config.apiBaseUrl}${Me.list[i.config.app].all}`;return i.config.app==="konnect"?V=V.replace(/{controlPlaneId}/gi,((J=i.config)==null?void 0:J.controlPlaneId)||""):i.config.app==="kongManager"&&(V=V.replace(/\/{workspace}/gi,($=i.config)!=null&&$.workspace?`/${i.config.workspace}`:"")),V.replace(/{entityType}/gi,((X=i.config)==null?void 0:X.entityType)||"").replace(/{entityId}/gi,((D=i.config)==null?void 0:D.entityId)||"")}),b=t.ref(""),v=t.computed(()=>i.config.app==="konnect"||i.config.isExactMatch?{isExactMatch:!0,fields:{name:g.name,id:{label:a("plugins.list.table_headers.id"),sortable:!0}},placeholder:a(`search.placeholder.${i.config.isExactMatch?"exact":i.config.app}`)}:{isExactMatch:!1,fields:{enabled:{...g.enabled,label:a("search.filter.field.enabled")},name:g.name,instance_name:{label:a("plugins.list.table_headers.instance_name"),searchable:!0}},schema:i.config.filterSchema}),{fetcher:N,fetcherState:E,fetcherCacheKey:S}=se.useFetcher(t.computed(()=>({...i.config,cacheIdentifier:i.cacheIdentifier})),w),P=()=>{b.value=""},B=()=>{S.value++},j=t.ref(null),G=V=>{var $,X,D,pe;const J=[];return(($=V.route)!=null&&$.id||V.route_id)&&J.push({type:"route",badgeText:a("plugins.list.table_headers.applied_to_badges.route")}),((X=V.service)!=null&&X.id||V.service_id)&&J.push({type:"service",badgeText:a("plugins.list.table_headers.applied_to_badges.service")}),((D=V.consumer)!=null&&D.id||V.consumer_id)&&J.push({type:"consumer",badgeText:a("plugins.list.table_headers.applied_to_badges.consumer")}),((pe=V.consumer_group)!=null&&pe.id||V.consumer_group_id)&&J.push({type:"consumer_group",badgeText:a("plugins.list.table_headers.applied_to_badges.consumer_group")}),J.length?J:[{type:null,badgeText:a("plugins.list.table_headers.applied_to_badges.global")}]},T=async(V,J)=>{var $;return V===null?!1:await(($=i.canRetrieveScopedEntity)==null?void 0:$.call(i,V,J.id))},Y=(V,J)=>{var X,D,pe,le,_e;let $=null;switch(V){case"route":$=(X=J.route)==null?void 0:X.id;break;case"service":$=(D=J.service)==null?void 0:D.id;break;case"consumer":$=(pe=J.consumer)==null?void 0:pe.id;break;case"consumer_group":$=(le=J.consumer_group)==null?void 0:le.id;break}$&&((_e=i.config)!=null&&_e.getScopedEntityViewRoute)&&l.push(i.config.getScopedEntityViewRoute(V,$))},I=t.ref(!1),M=t.ref(null),R=t.computed(()=>{const V={action:"disable",id:"",name:""};if(M.value){const{enabled:J,id:$,name:X}=M.value;V.action=J?"disable":"enable",V.id=$,V.name=o.getDisplayName(X)||$}return V}),te=V=>{I.value=!0,M.value=V},z=()=>{I.value=!1,M.value=null},H=async()=>{var X,D,pe,le,_e,fe,oe,be;if(!await((X=i.canEdit)==null?void 0:X.call(i,M.value))||!M.value)return;let J=`${i.config.apiBaseUrl}${(_e=Me.item[i.config.app])==null?void 0:_e[(D=i.config)!=null&&D.entityType?"forEntity":"all"].replace(/{entityType}/gi,((pe=i.config)==null?void 0:pe.entityType)||"").replace(/{entityId}/gi,((le=i.config)==null?void 0:le.entityId)||"")}`.replace(/{id}/gi,M.value.id||"");i.config.app==="konnect"?J=J.replace(/{controlPlaneId}/gi,((fe=i.config)==null?void 0:fe.controlPlaneId)||""):i.config.app==="kongManager"&&(J=J.replace(/\/{workspace}/gi,(oe=i.config)!=null&&oe.workspace?`/${i.config.workspace}`:""));const $=!M.value.enabled;try{const{data:ve}=((be=i.config)==null?void 0:be.app)==="konnect"?await s.put(J,{...M.value,enabled:$},{timeout:12e4}):await s.patch(J,{...M.value,enabled:$},{timeout:12e4});r("toggle-enabled",$,ve),M.value.enabled=$}catch(ve){r("error",ve)}},L=async(V,J)=>{const $=V.id;if(!await J($)){r("copy:error",{entity:V,field:"id",message:a("errors.copy")});return}r("copy:success",{entity:V,field:"id",message:a("copy.success",{val:$})})},F=async(V,J)=>{const $=JSON.stringify(V);if(!await J($)){r("copy:error",{entity:V,message:a("errors.copy")});return}r("copy:success",{entity:V,message:a("copy.success_brief")})},Z=async V=>{var $;await(($=i.canRetrieve)==null?void 0:$.call(i,V))&&l.push(i.config.getViewRoute(V))},Q=V=>({label:a("actions.view"),to:i.config.getViewRoute(V)}),W=V=>({label:a("actions.edit"),to:i.config.getEditRoute(V)}),ie=V=>({label:a("actions.configure_dynamic_ordering"),to:i.config.getConfigureDynamicOrderingRoute(V)}),ae=t.ref(void 0),me=t.ref(!1),ge=t.ref(!1),ne=t.ref(""),re=se.useDeleteUrlBuilder(i.config,w.value),q=V=>{ae.value=V,me.value=!0},ee=()=>{me.value=!1},O=async()=>{var V,J,$;if((V=ae.value)!=null&&V.id){ge.value=!0;try{await s.delete(re(ae.value.id)),ge.value=!1,me.value=!1,S.value++,r("delete:success",ae.value)}catch(X){ne.value=(($=(J=X.response)==null?void 0:J.data)==null?void 0:$.message)||X.message||a("errors.delete"),r("error",X)}finally{ge.value=!1}}},k=()=>{l.push(i.config.createRoute)};t.watch(E,V=>{var J,$,X;if(V.status===se.FetcherStatus.Error){j.value={title:a("errors.general")},(X=($=(J=V.error)==null?void 0:J.response)==null?void 0:$.data)!=null&&X.message&&(j.value.message=V.error.response.data.message),r("error",V.error);return}j.value=null});const C=t.ref({ctaPath:i.config.createRoute,ctaText:void 0,message:`${a("plugins.list.empty_state.description")}${i.config.additionMessageForEmptyState?` ${i.config.additionMessageForEmptyState}`:""}`,title:a("plugins.title")}),A=t.ref(!1);return t.onBeforeMount(async()=>{A.value=await i.canCreate(),A.value&&(C.value.title=a("plugins.list.empty_state.title"),C.value.ctaText=a("actions.create"))}),(V,J)=>{const $=t.resolveComponent("KButton"),X=t.resolveComponent("KEmptyState"),D=t.resolveComponent("KBadge"),pe=t.resolveComponent("KTruncate"),le=t.resolveComponent("KInputSwitch"),_e=t.resolveComponent("KDropdownItem"),fe=t.resolveComponent("KClipboardProvider");return t.openBlock(),t.createElementBlock("div",CR,[t.createVNode(t.unref(se.EntityBaseTable),{"cache-identifier":e.cacheIdentifier,"disable-sorting":y.value,"empty-state-options":C.value,"enable-entity-actions":"","error-message":j.value,fetcher:t.unref(N),"fetcher-cache-key":t.unref(S),"pagination-type":"offset","preferences-storage-key":"kong-ui-entities-plugins-list",query:b.value,"table-headers":t.unref(_),title:e.title,"title-tag":e.titleTag,onClearSearchInput:P,"onClick:row":J[4]||(J[4]=oe=>Z(oe)),onSort:B,onState:t.unref(d)},t.createSlots({"toolbar-filter":t.withCtx(()=>[t.createVNode(t.unref(se.EntityFilter),{modelValue:b.value,"onUpdate:modelValue":J[0]||(J[0]=oe=>b.value=oe),config:v.value},null,8,["modelValue","config"])]),"toolbar-button":t.withCtx(()=>[(t.openBlock(),t.createBlock(t.Teleport,{disabled:!e.useActionOutside,to:"#kong-ui-app-page-header-action-button"},[t.createElementVNode("div",NR,[!f.value&&u.value?(t.openBlock(),t.createBlock($,{key:0,appearance:"secondary",class:"open-learning-hub","data-testid":"plugins-learn-more-button",icon:"",onClick:J[1]||(J[1]=oe=>V.$emit("click:learn-more"))},{default:t.withCtx(()=>[t.createVNode(t.unref(Ne.BookIcon),{decorative:""})]),_:1})):t.createCommentVNode("",!0),t.createVNode(t.unref(se.PermissionsWrapper),{"auth-function":()=>e.canCreate()},{default:t.withCtx(()=>[t.createVNode($,{appearance:"primary","data-testid":"toolbar-add-plugin",size:e.useActionOutside?"medium":"large",to:e.config.createRoute},{default:t.withCtx(()=>[t.createVNode(t.unref(Ne.AddIcon)),t.createTextVNode(" "+t.toDisplayString(t.unref(a)("plugins.list.toolbar_actions.new_plugin")),1)]),_:1},8,["size","to"])]),_:1},8,["auth-function"])])],8,["disabled"]))]),name:t.withCtx(({row:oe})=>[t.createElementVNode("div",vR,[t.createVNode(t.unref(io.PluginIcon),{class:"plugin-icon",name:oe.name,size:24},null,8,["name"]),t.createElementVNode("div",SR,[oe.instance_name?(t.openBlock(),t.createElementBlock("span",xR,t.toDisplayString(oe.instance_name),1)):(t.openBlock(),t.createElementBlock("span",AR,t.toDisplayString(t.unref(o).getDisplayName(oe.name)),1)),oe.instance_name?(t.openBlock(),t.createElementBlock("span",IR,t.toDisplayString(t.unref(o).getDisplayName(oe.name)),1)):t.createCommentVNode("",!0)])])]),appliedTo:t.withCtx(({row:oe})=>[G(oe).length>0?(t.openBlock(),t.createBlock(pe,{key:0},{default:t.withCtx(()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(G(oe),be=>(t.openBlock(),t.createBlock(t.unref(se.PermissionsWrapper),{key:be.badgeText,"auth-function":()=>T(be.type,oe),"force-show":""},{default:t.withCtx(({isAllowed:ve})=>[t.createVNode(D,{class:t.normalizeClass(ve||"disabled"),onClick:t.withModifiers(ue=>ve&&be.type&&Y(be.type,oe),["stop"])},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(be.badgeText),1)]),_:2},1032,["class","onClick"])]),_:2},1032,["auth-function"]))),128))]),_:2},1024)):(t.openBlock(),t.createElementBlock("span",PR,"-"))]),enabled:t.withCtx(({row:oe})=>[t.createVNode(t.unref(se.PermissionsWrapper),{"auth-function":async()=>!!(await e.canEdit(oe)&&await e.canToggle(oe)),"force-show":""},{default:t.withCtx(({isAllowed:be})=>{var ve,ue;return[t.createElementVNode("div",{onClick:J[3]||(J[3]=t.withModifiers(()=>{},["stop"]))},[t.createVNode(le,{disabled:!be,"disabled-tooltip-text":!be&&((ue=(ve=e.config).getToggleDisabledTooltip)==null?void 0:ue.call(ve,oe))||void 0,"model-value":oe.enabled,onClick:t.withModifiers(de=>be&&te(oe),["stop","prevent"])},null,8,["disabled","disabled-tooltip-text","model-value","onClick"])])]}),_:2},1032,["auth-function"])]),ordering:t.withCtx(({rowValue:oe})=>[t.createVNode(D,{appearance:t.unref(gc)(oe)?"info":"warning"},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(gc)(oe)?t.unref(a)("plugins.list.table_headers.ordering_badge.static"):t.unref(a)("plugins.list.table_headers.ordering_badge.dynamic")),1)]),_:2},1032,["appearance"])]),tags:t.withCtx(({rowValue:oe})=>[t.createVNode(t.unref(se.TableTags),{tags:oe},null,8,["tags"])]),actions:t.withCtx(({row:oe})=>[t.createVNode(fe,null,{default:t.withCtx(({copyToClipboard:be})=>[t.createVNode(_e,{"data-testid":"action-entity-copy-id",onClick:ve=>L(oe,be)},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(a)("actions.copy_id")),1)]),_:2},1032,["onClick"])]),_:2},1024),t.createVNode(fe,null,{default:t.withCtx(({copyToClipboard:be})=>[t.createVNode(_e,{"data-testid":"action-entity-copy-json",onClick:ve=>F(oe,be)},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(a)("actions.copy_json")),1)]),_:2},1032,["onClick"])]),_:2},1024),t.createVNode(t.unref(se.PermissionsWrapper),{"auth-function":()=>e.canRetrieve(oe)},{default:t.withCtx(()=>[t.createVNode(_e,{"data-testid":"action-entity-view","has-divider":"",item:Q(oe)},null,8,["item"])]),_:2},1032,["auth-function"]),t.createVNode(t.unref(se.PermissionsWrapper),{"auth-function":()=>e.canEdit(oe)},{default:t.withCtx(()=>[t.createVNode(_e,{"data-testid":"action-entity-edit",item:W(oe)},null,8,["item"])]),_:2},1032,["auth-function"]),!p.value&&!m.value&&t.unref(h)?(t.openBlock(),t.createBlock(t.unref(se.PermissionsWrapper),{key:0,"auth-function":()=>e.canConfigureDynamicOrdering(oe)},{default:t.withCtx(()=>[ie(oe)?(t.openBlock(),t.createBlock(_e,{key:0,"data-testid":"action-entity-config-dyn-order",item:ie(oe)},null,8,["item"])):t.createCommentVNode("",!0)]),_:2},1032,["auth-function"])):t.createCommentVNode("",!0),t.createVNode(t.unref(se.PermissionsWrapper),{"auth-function":()=>e.canDelete(oe)},{default:t.withCtx(()=>[t.createVNode(_e,{danger:"","data-testid":"action-entity-delete","has-divider":"",onClick:be=>q(oe)},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(a)("actions.delete")),1)]),_:2},1032,["onClick"])]),_:2},1032,["auth-function"])]),_:2},[!b.value&&e.config.app==="konnect"?{name:"empty-state",fn:t.withCtx(()=>{var oe;return[t.createVNode(X,{"data-testid":e.config.entityId?"nested-plugins-entity-empty-state":"plugins-entity-empty-state","icon-background":"",message:t.unref(a)("plugins.list.empty_state_v2.description"),title:t.unref(a)("plugins.list.empty_state_v2.title")},t.createSlots({icon:t.withCtx(()=>[t.createVNode(t.unref(Ne.PlugIcon),{decorative:""})]),action:t.withCtx(()=>[A.value?(t.openBlock(),t.createBlock($,{key:0,"data-testid":"entity-create-button",onClick:k},{default:t.withCtx(()=>[t.createVNode(t.unref(Ne.AddIcon),{decorative:""}),t.createTextVNode(" "+t.toDisplayString(t.unref(a)("plugins.list.empty_state_v2.create_cta")),1)]),_:1})):t.createCommentVNode("",!0),t.createVNode($,{appearance:"secondary","data-testid":"entity-learn-more-button",onClick:J[2]||(J[2]=be=>V.$emit("click:learn-more"))},{default:t.withCtx(()=>[t.createVNode(t.unref(Ne.BookIcon),{decorative:""}),t.createTextVNode(" "+t.toDisplayString(t.unref(a)("plugins.list.empty_state_v2.learn_more")),1)]),_:1})]),_:2},[(oe=e.config)!=null&&oe.isControlPlaneGroup?{name:"default",fn:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(a)("plugins.list.empty_state_v2.group")),1)]),key:"0"}:void 0]),1032,["data-testid","message","title"])]}),key:"0"}:void 0]),1032,["cache-identifier","disable-sorting","empty-state-options","error-message","fetcher","fetcher-cache-key","query","table-headers","title","title-tag","onState"]),t.createVNode(t.unref(se.EntityToggleModal),{action:R.value.action,"entity-id":R.value.id,"entity-name":R.value.name,"entity-type":t.unref(a)("glossary.plugin"),"on-confirm":H,visible:I.value,onCancel:z,onProceed:z},null,8,["action","entity-id","entity-name","entity-type","visible"]),t.createVNode(t.unref(se.EntityDeleteModal),{"action-pending":ge.value,description:t.unref(a)("delete.description"),"entity-name":ae.value&&(ae.value.instance_name||ae.value.name||ae.value.id),"entity-type":t.unref(se.EntityTypes).Plugin,error:ne.value,title:t.unref(a)("delete.title"),visible:me.value,onCancel:ee,onProceed:O},null,8,["action-pending","description","entity-name","entity-type","error","title","visible"])])}}}),[["__scopeId","data-v-582a936c"]]),OR={class:"plugin-select-card-wrapper"},$R=["data-testid"],BR={class:"plugin-card-header"},VR={class:"plugin-card-title"},RR={key:0,class:"plugin-card-actions"},DR=["data-testid","title"],MR={key:0,class:"plugin-card-text"},LR={key:0},FR=["title"],Hl=Ee(t.defineComponent({__name:"PluginSelectCard",props:{config:{type:Object,required:!0,validator:e=>!(!e||!["konnect","kongManager"].includes(e==null?void 0:e.app)||!e.getCreateRoute)},canDeleteCustomPlugin:{type:Boolean,default:!1},canEditCustomPlugin:{type:Boolean,default:!1},plugin:{type:Object,required:!0},navigateOnClick:{type:Boolean,default:!0}},emits:["plugin-clicked","custom-plugin-delete"],setup(e,{emit:n}){const o=n,r=e,i=oo.useRouter(),{i18n:{t:a}}=Re.useI18n(),l=t.computed(()=>r.config.app==="konnect"?r.config.controlPlaneId:""),s=t.computed(()=>!!(!r.plugin.available||r.plugin.disabledMessage)),c=t.computed(()=>!!(m.value&&!p.value&&r.navigateOnClick&&l.value&&(r.canDeleteCustomPlugin||r.canEditCustomPlugin))),d=()=>{i.push(r.config.getCreateRoute(r.plugin.id))},u=()=>{r.navigateOnClick?d():f()},f=()=>{o("plugin-clicked",r.plugin)},p=t.computed(()=>r.plugin.id==="custom-plugin-create"),m=t.computed(()=>r.config.app==="konnect"&&r.plugin.group===K.PluginGroup.CUSTOM_PLUGINS),h=()=>{r.config.app==="konnect"&&o("custom-plugin-delete")},y=(_,w)=>{const b=r.config;r.config.app==="konnect"&&typeof b.getCustomEditRoute=="function"&&b.getCustomEditRoute&&i.push(b.getCustomEditRoute(_,w))},g=()=>{if(!s.value&&r.config.app==="konnect"){const _=r.config;p.value&&_.createCustomRoute?i.push(_.createCustomRoute):m.value&&d()}};return(_,w)=>{const b=t.resolveComponent("KButton"),v=t.resolveComponent("KDropdownItem"),N=t.resolveComponent("KDropdownMenu"),E=t.resolveComponent("KTooltip");return t.openBlock(),t.createElementBlock("div",OR,[t.createVNode(E,{text:e.plugin.disabledMessage},{default:t.withCtx(()=>[t.createElementVNode("a",{class:t.normalizeClass(["plugin-select-card",{disabled:s.value}]),"data-testid":`${e.plugin.id}-card`,role:"button",onClick:w[1]||(w[1]=S=>s.value||m.value?void 0:u())},[t.createElementVNode("div",BR,[t.createElementVNode("div",VR,[t.createElementVNode("span",{class:t.normalizeClass({"non-custom-title":!m.value})},t.toDisplayString(e.plugin.name),3)]),c.value?(t.openBlock(),t.createElementBlock("div",RR,[t.createVNode(N,{"data-testid":"custom-plugin-actions","kpop-attributes":{placement:"bottom-end"},width:"150"},{default:t.withCtx(()=>[t.createVNode(b,{appearance:"tertiary",class:"actions-trigger","data-testid":"overflow-actions-button",icon:"",size:"small"},{default:t.withCtx(()=>[t.createVNode(t.unref(Ne.MoreIcon),{size:t.unref(uk)},null,8,["size"])]),_:1})]),items:t.withCtx(()=>[e.canDeleteCustomPlugin?(t.openBlock(),t.createBlock(v,{key:0,"data-testid":"edit-plugin-schema",onClick:w[0]||(w[0]=t.withModifiers(S=>y(e.plugin.name,e.plugin.customPluginType),["stop"]))},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(a)("actions.edit")),1)]),_:1})):t.createCommentVNode("",!0),e.canDeleteCustomPlugin?(t.openBlock(),t.createBlock(v,{key:1,danger:"","data-testid":"delete-plugin-schema","has-divider":"",onClick:t.withModifiers(h,["stop"])},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(a)("actions.delete")),1)]),_:1})):t.createCommentVNode("",!0)]),_:1})])):t.createCommentVNode("",!0)]),t.createElementVNode("div",{class:t.normalizeClass(["plugin-card-body",{"custom-plugin":m.value}]),"data-testid":e.plugin.name,title:e.plugin.available?e.plugin.name:t.unref(a)("plugins.select.unavailable_tooltip"),onClick:g},[t.createVNode(t.unref(io.PluginIcon),{alt:e.plugin.name,class:"plugin-card-icon",name:e.plugin.id,size:55},null,8,["alt","name"]),e.plugin.description||m.value&&!p.value?(t.openBlock(),t.createElementBlock("div",MR,[m.value&&!p.value?(t.openBlock(),t.createElementBlock("p",LR,t.toDisplayString(t.unref(a)("plugins.select.custom_badge_text")),1)):t.createCommentVNode("",!0),e.plugin.description?(t.openBlock(),t.createElementBlock("p",{key:1,class:"plugin-card-text",title:e.plugin.description},t.toDisplayString(e.plugin.description),9,FR)):t.createCommentVNode("",!0)])):t.createCommentVNode("",!0)],10,DR),t.createElementVNode("div",{class:"plugin-card-footer",onClick:g},t.toDisplayString(p.value?t.unref(a)("actions.create_custom"):e.plugin.exists?t.unref(a)("actions.enabled"):t.unref(a)("actions.enable")),1)],10,$R)]),_:1},8,["text"])])}}}),[["__scopeId","data-v-65d53934"]]),UR=Ee(t.defineComponent({__name:"DeleteCustomPluginSchemaModal",props:{config:{type:Object,required:!0,validator:e=>!(!e||!["konnect","kongManager"].includes(e==null?void 0:e.app))},plugin:{type:Object,required:!0}},emits:["closed","proceed"],setup(e,{emit:n}){var h;const o=e,r=n,{i18nT:i,i18n:{t:a}}=Re.useI18n(),{getMessageFromError:l}=se.useErrors(),{axiosInstance:s}=se.useAxios((h=o.config)==null?void 0:h.axiosRequestConfig),c=t.computed(()=>{var y;return f.value?a("delete.plugin_schema_in_use_title"):a("delete.title",{name:((y=o.plugin)==null?void 0:y.name)||a("delete.custom_plugin")})}),d=t.ref(!1),u=t.ref(""),f=t.ref(!1),p=t.computed(()=>{if(o.config.app==="konnect"){const y=o.plugin.customPluginType==="streaming"?Me.select[o.config.app].streamingCustomPluginItem:Me.select[o.config.app].schemaCustomPluginItem;let g=`${o.config.apiBaseUrl}${y}`;return g=g.replace(/{controlPlaneId}/gi,o.config.controlPlaneId||""),g=g.replace(/{pluginId}/gi,o.plugin.id),g}return null}),m=async()=>{var y,g,_,w;if(d.value=!0,u.value="",!(!((y=o.plugin)!=null&&y.name)||((g=o.config)==null?void 0:g.app)!=="konnect"))try{p.value&&await s.delete(p.value),r("proceed")}catch(b){const{response:v}=b;(v==null?void 0:v.status)===400&&((w=(_=v.data)==null?void 0:_.message)!=null&&w.includes("plugin schema is currently in use"))?f.value=!0:u.value=l(b)}finally{d.value=!1}};return(y,g)=>{const _=t.resolveComponent("KButton"),w=t.resolveComponent("KModal");return!f.value&&e.plugin?(t.openBlock(),t.createBlock(t.unref(se.EntityDeleteModal),{key:0,"action-pending":d.value,class:"delete-custom-plugin-schema-modal","data-testid":"delete-custom-plugin-schema-modal",description:t.unref(a)("delete.description_custom"),"entity-name":e.plugin.name,"entity-type":t.unref(se.EntityTypes).Plugin,error:u.value,"need-confirm":"",title:c.value,visible:"",onCancel:g[0]||(g[0]=b=>y.$emit("closed")),onProceed:m},null,8,["action-pending","description","entity-name","entity-type","error","title"])):e.plugin?(t.openBlock(),t.createBlock(w,{key:1,"action-button-disabled":d.value,class:"delete-custom-plugin-schema-modal","data-testid":"delete-custom-plugin-schema-modal",title:c.value,visible:"",onCancel:g[2]||(g[2]=b=>y.$emit("closed"))},{default:t.withCtx(()=>[t.createElementVNode("div",null,[t.createVNode(t.unref(i),{keypath:"delete.plugin_schema_in_use_message",tag:"p"},{name:t.withCtx(()=>[t.createElementVNode("strong",null,t.toDisplayString(e.plugin.name),1)]),_:1})])]),"footer-actions":t.withCtx(()=>[t.createElementVNode("div",null,[t.createVNode(_,{appearance:"tertiary",class:"cancel-button","data-testid":"delete-custom-plugin-form-cancel",onClick:g[1]||(g[1]=b=>y.$emit("closed"))},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(a)("actions.cancel")),1)]),_:1})])]),_:1},8,["action-button-disabled","title"])):t.createCommentVNode("",!0)}}}),[["__scopeId","data-v-9e0dee7f"]]),KR={class:"custom-plugins-grid"},jR={class:"empty-state-title"},GR={class:"empty-state-description"},Yl=310,qR=Ee(t.defineComponent({__name:"PluginCustomGrid",props:{config:{type:Object,required:!0,validator:e=>!(!e||!["konnect","kongManager"].includes(e==null?void 0:e.app)||!e.getCreateRoute)},canCreateCustomPlugin:{type:Boolean,default:!1},canDeleteCustomPlugin:{type:Boolean,default:!1},canEditCustomPlugin:{type:Boolean,default:!1},pluginList:{type:Object,default:()=>({})},navigateOnClick:{type:Boolean,default:!0}},emits:["plugin-clicked","revalidate","delete:success"],setup(e,{emit:n}){const o=e,r=n,{i18n:{t:i}}=Re.useI18n(),{getTallestPluginCardHeight:a,getToggleVisibility:l}=Re.usePluginHelpers(),s=t.ref(!0),c=N=>{r("plugin-clicked",N)},d=t.computed(()=>{if(o.config.app==="kongManager")return[];const N=JSON.parse(JSON.stringify(o.pluginList))[K.PluginGroup.CUSTOM_PLUGINS]||[];return o.canCreateCustomPlugin&&o.navigateOnClick&&o.config.createCustomRoute?[{id:"custom-plugin-create",name:i("plugins.select.tabs.custom.create.name"),available:!0,group:K.PluginGroup.CUSTOM_PLUGINS,description:i("plugins.select.tabs.custom.create.description")}].concat(N):N}),u=t.ref(!1),f=t.ref(null),p=N=>{u.value=!0,f.value={id:N.id,name:N.name,customPluginType:N.customPluginType}},m=N=>{var E;N&&(r("revalidate"),r("delete:success",((E=f.value)==null?void 0:E.name)||"")),u.value=!1,f.value=null},h=t.ref(Yl),y=t.ref(null),g=t.ref(null),_=t.computed(()=>s.value?{overflowY:"hidden",maxHeight:`${h.value}px`}:{}),w=t.ref(!1),b=()=>{h.value=Math.max(a(g.value),Yl),v()},v=()=>{var N,E;(N=g.value)!=null&&N.length&&(w.value=l(y.value,(E=g.value)==null?void 0:E.length))};return t.onMounted(async()=>{await t.nextTick(),h.value=Math.max(a(g.value),Yl),v(),window==null||window.addEventListener("resize",b)}),t.onUnmounted(()=>{window==null||window.removeEventListener("resize",b)}),(N,E)=>{const S=t.resolveComponent("KEmptyState"),P=t.resolveComponent("KCollapse");return t.openBlock(),t.createElementBlock("div",KR,[d.value.length?(t.openBlock(),t.createBlock(P,{key:1,modelValue:s.value,"onUpdate:modelValue":E[0]||(E[0]=B=>s.value=B),class:"custom-plugins-collapse","data-testid":`${t.unref(K.PluginGroup).CUSTOM_PLUGINS}-collapse`,title:t.unref(K.PluginGroup).CUSTOM_PLUGINS,"trigger-label":s.value?t.unref(i)("plugins.select.view_more"):t.unref(i)("plugins.select.view_less")},t.createSlots({"visible-content":t.withCtx(()=>[t.createElementVNode("div",{ref_key:"pluginCardContainerRef",ref:y,class:"plugin-card-container",style:t.normalizeStyle(_.value)},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(d.value,(B,j)=>(t.openBlock(),t.createBlock(Hl,{key:`plugin-card-${j}`,ref_for:!0,ref_key:"pluginCardRef",ref:g,"can-delete-custom-plugin":e.canDeleteCustomPlugin,"can-edit-custom-plugin":e.canEditCustomPlugin,config:e.config,"navigate-on-click":e.navigateOnClick,plugin:B,onCustomPluginDelete:G=>p(B),onPluginClicked:c},null,8,["can-delete-custom-plugin","can-edit-custom-plugin","config","navigate-on-click","plugin","onCustomPluginDelete"]))),128))],4)]),_:2},[w.value?void 0:{name:"trigger",fn:t.withCtx(()=>[E[2]||(E[2]=t.createTextVNode(" ",-1))]),key:"0"}]),1032,["modelValue","data-testid","title","trigger-label"])):(t.openBlock(),t.createBlock(S,{key:0,"action-button-visible":!1,class:"custom-plugins-empty-state","icon-variant":"kong"},{title:t.withCtx(()=>[t.createElementVNode("span",jR,t.toDisplayString(t.unref(i)("plugins.select.tabs.custom.empty_title")),1)]),default:t.withCtx(()=>[t.createElementVNode("span",GR,t.toDisplayString(t.unref(i)("plugins.select.tabs.custom.empty_description")),1)]),_:1})),u.value&&f.value?(t.openBlock(),t.createBlock(UR,{key:2,config:e.config,plugin:f.value,onClosed:m,onProceed:E[1]||(E[1]=B=>m(!0))},null,8,["config","plugin"])):t.createCommentVNode("",!0)])}}}),[["__scopeId","data-v-f4b90f47"]]),Wl=310,km=Ee(t.defineComponent({__name:"PluginSelectGroup",props:t.mergeModels({config:{type:Object,required:!0,validator:e=>!(!e||!["konnect","kongManager"].includes(e==null?void 0:e.app)||!e.getCreateRoute)},name:{type:String,required:!0},plugins:{type:Array,required:!0},navigateOnClick:{type:Boolean,default:!0}},{modelValue:{type:Boolean,required:!0},modelModifiers:{}}),emits:t.mergeModels(["plugin-clicked"],["update:modelValue"]),setup(e,{emit:n}){const o=t.useModel(e,"modelValue"),r=e,i=n,{i18n:{t:a}}=Re.useI18n(),{getTallestPluginCardHeight:l,getToggleVisibility:s}=Re.usePluginHelpers(),c=t.ref(Wl),d=t.ref(null),u=t.ref(null),f=t.computed(()=>o.value?{overflowY:"hidden",maxHeight:`${c.value}px`}:{}),p=t.ref(!1),m=()=>{c.value=Math.max(l(u.value),Wl),h()},h=()=>{var y,g;(y=u.value)!=null&&y.length&&(p.value=s(d.value,(g=u.value)==null?void 0:g.length))};return t.onMounted(async()=>{await t.nextTick(),c.value=Math.max(l(u.value),Wl),h(),window==null||window.addEventListener("resize",m)}),t.onUnmounted(()=>{window==null||window.removeEventListener("resize",m)}),(y,g)=>{const _=t.resolveComponent("KCollapse");return t.openBlock(),t.createBlock(_,{modelValue:o.value,"onUpdate:modelValue":g[0]||(g[0]=w=>o.value=w),class:"plugins-collapse","data-testid":`${r.name}-collapse`,title:r.name,"trigger-label":o.value?t.unref(a)("plugins.select.view_more"):t.unref(a)("plugins.select.view_less")},t.createSlots({"visible-content":t.withCtx(()=>[t.createElementVNode("div",{ref_key:"pluginCardContainerRef",ref:d,class:"plugin-card-container",style:t.normalizeStyle(f.value)},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(r.plugins,w=>(t.openBlock(),t.createBlock(Hl,{key:`plugin-card-${w.id}`,ref_for:!0,ref_key:"pluginCardRef",ref:u,config:e.config,"navigate-on-click":e.navigateOnClick,plugin:w,onPluginClicked:b=>i("plugin-clicked",w)},null,8,["config","navigate-on-click","plugin","onPluginClicked"]))),128))],4)]),_:2},[p.value?void 0:{name:"trigger",fn:t.withCtx(()=>[g[1]||(g[1]=t.createTextVNode(" ",-1))]),key:"0"}]),1032,["modelValue","data-testid","title","trigger-label"])}}}),[["__scopeId","data-v-a1074120"]]),zR={class:"plugin-select-grid"},HR={class:"empty-state-title"},YR={class:"empty-state-description"},Xl=t.defineComponent({__name:"PluginSelectGrid",props:{config:{type:Object,required:!0,validator:e=>!(!e||!["konnect","kongManager"].includes(e==null?void 0:e.app)||!e.getCreateRoute)},pluginList:{type:Object,default:()=>({})},navigateOnClick:{type:Boolean,default:!0},highlightedPlugins:{type:Array,default:()=>[]},highlightedPluginsTitle:{type:String,default:""},hideHighlightedPlugins:{type:Boolean,default:!1}},emits:["plugin-clicked"],setup(e,{emit:n}){const o=e,r=n,{i18n:{t:i}}=Re.useI18n(),a=t.ref(!1),l=t.ref(es),s=d=>{r("plugin-clicked",d)},c=t.computed(()=>{const d=JSON.parse(JSON.stringify(o.pluginList));return o.config.app==="konnect"&&delete d[K.PluginGroup.CUSTOM_PLUGINS],d});return(d,u)=>{const f=t.resolveComponent("KEmptyState");return t.openBlock(),t.createElementBlock("div",zR,[Object.keys(c.value).length?t.createCommentVNode("",!0):(t.openBlock(),t.createBlock(f,{key:0,"action-button-visible":!1,class:"plugins-empty-state","data-testid":"plugins-empty-state","icon-variant":"kong"},{title:t.withCtx(()=>[t.createElementVNode("span",HR,t.toDisplayString(t.unref(i)("plugins.select.tabs.kong.empty_title")),1)]),default:t.withCtx(()=>[t.createElementVNode("span",YR,t.toDisplayString(t.unref(i)("plugins.select.tabs.kong.empty_description")),1)]),_:1})),!o.hideHighlightedPlugins&&o.highlightedPlugins.length>0?(t.openBlock(),t.createBlock(km,{key:1,modelValue:a.value,"onUpdate:modelValue":u[0]||(u[0]=p=>a.value=p),config:e.config,name:o.highlightedPluginsTitle||t.unref(i)("plugins.select.highlighted_plugins.title"),"navigate-on-click":e.navigateOnClick,plugins:o.highlightedPlugins,onPluginClicked:u[1]||(u[1]=p=>s(p))},null,8,["modelValue","config","name","navigate-on-click","plugins"])):t.createCommentVNode("",!0),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(Ql),p=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[c.value[p]?(t.openBlock(),t.createElementBlock("div",{key:p},[t.createVNode(km,{modelValue:l.value[p],"onUpdate:modelValue":m=>l.value[p]=m,config:e.config,name:p,"navigate-on-click":e.navigateOnClick,plugins:c.value[p]||[],onPluginClicked:u[2]||(u[2]=m=>s(m))},null,8,["modelValue","onUpdate:modelValue","config","name","navigate-on-click","plugins"])])):t.createCommentVNode("",!0)],64))),256))])}}}),WR={class:"kong-ui-entities-plugin-select-form"},XR={class:"plugins-filter-input-container"},ZR={key:0},JR={key:3,"aria-live":"polite",class:"plugins-results-container"},QR={"data-testid":"kong-tab"},eD={class:"tab-description"},tD={"data-testid":"custom-tab"},nD={class:"tab-description"},oD=Ee(t.defineComponent({__name:"PluginSelect",props:{config:{type:Object,required:!0,validator:e=>!(!e||!["konnect","kongManager"].includes(e==null?void 0:e.app)||!e.getCreateRoute)},customPluginSupport:{type:String,default:"none"},canCreateCustomPlugin:{type:Function,required:!1,default:async()=>!0},canDeleteCustomPlugin:{type:Function,required:!1,default:async()=>!0},canEditCustomPlugin:{type:Function,required:!1,default:async()=>!0},navigateOnClick:{type:Boolean,default:!0},availableOnServer:{type:Boolean,default:!0},ignoredPlugins:{type:Array,default:()=>[]},disabledPlugins:{type:Object,default:()=>({})},highlightedPluginIds:{type:Array,default:()=>[]},highlightedPluginsTitle:{type:String,default:""}},emits:["loading","plugin-clicked","delete-custom:success"],setup(e,{emit:n}){var H;const o=e,r=n,i=oo.useRoute(),a=oo.useRouter(),{i18n:{t:l}}=Re.useI18n(),{pluginMetaData:s}=Re.usePluginMetaData(),{getMessageFromError:c}=se.useErrors(),{sortAlpha:d,objectsAreEqual:u}=se.useHelpers(),f=t.ref(""),p=t.ref(!0),m=t.ref(!1),h=t.ref(""),y=t.ref([]),g=t.ref([]),_=t.ref({}),w=t.ref([]),{axiosInstance:b}=se.useAxios((H=o.config)==null?void 0:H.axiosRequestConfig),v=t.computed(()=>_.value?Object.entries(_.value).filter(([L])=>L!==K.PluginGroup.CUSTOM_PLUGINS).reduce((L,[,F])=>{for(const Z of F)L[Z.id]=Z;return L},{}):{}),N=t.computed(()=>{var Z;if(!_.value)return{};const L=f.value.toLowerCase(),F=JSON.parse(JSON.stringify(_.value));for(const Q in _.value){const W=((Z=_.value[Q])==null?void 0:Z.filter(ie=>ie.name.toLowerCase().includes(L)||ie.id.toLowerCase().includes(L)||ie.group.toLowerCase().includes(L)))||[];W.length?F[Q]=W:delete F[Q]}return F}),E=t.computed(()=>o.highlightedPluginIds.reduce((L,F)=>{const Z=v.value[F];return Z&&L.push(Z),L},[])),S=t.computed(()=>Object.keys(N.value).length>0),P=t.computed(()=>Object.keys(_.value).length>0&&!S.value),B=t.computed(()=>o.config.app==="konnect"?[{hash:"#kong",title:l("plugins.select.tabs.kong.title")},{hash:"#custom",title:l("plugins.select.tabs.custom.title"),disabled:["none","disabled"].includes(o.customPluginSupport)}]:[]),j=t.computed(()=>{var F;let L=B.value.length&&((i==null?void 0:i.hash)||((F=B.value[0])==null?void 0:F.hash))||"";return L==="#custom"&&["none","disabled"].includes(o.customPluginSupport)&&(L="#kong"),L}),G=()=>[...new Set([...Object.keys({...o.availableOnServer?{}:s}),...y.value])].filter(L=>!o.ignoredPlugins.includes(L)).filter(L=>o.config.entityType&&(o.config.entityType==="services"&&s[L]&&!s[L].scope.includes(K.PluginScope.SERVICE)||o.config.entityType==="routes"&&s[L]&&!s[L].scope.includes(K.PluginScope.ROUTE)||o.config.entityType==="consumer_groups"&&s[L]&&!s[L].scope.includes(K.PluginScope.CONSUMER_GROUP)||o.config.entityType==="consumers"&&s[L]&&!s[L].scope.includes(K.PluginScope.CONSUMER))?!1:L).reduce((L,F)=>{var ae;const Z=s[F]&&s[F].name||F,Q={...s[F],id:F,name:Z,available:y.value.includes(F),disabledMessage:"",group:((ae=s[F])==null?void 0:ae.group)||K.PluginGroup.CUSTOM_PLUGINS};Q.group===K.PluginGroup.CUSTOM_PLUGINS&&(Q.customPluginType=g.value.find(me=>me.name===F)?"streaming":"schema"),o.disabledPlugins&&(Q.disabledMessage=o.disabledPlugins[F]);const W=Q.group||l("plugins.select.misc_plugins");let ie=L[W];return ie||(ie=[]),ie.push(Q),ie.sort(d("name")),L[W]=ie,L},{}),T=t.computed(()=>{var F;let L=`${o.config.apiBaseUrl}${Me.select[o.config.app].availablePlugins}`;return o.config.app==="konnect"?L=L.replace(/{controlPlaneId}/gi,o.config.controlPlaneId||""):o.config.app==="kongManager"&&(L=((F=o.config.gatewayInfo)==null?void 0:F.edition)==="community"?`${o.config.apiBaseUrl}${Me.select[o.config.app].availablePluginsForOss}`:L.replace(/\/{workspace}/gi,o.config.workspace?`/${o.config.workspace}`:"")),L}),Y=t.computed(()=>{if(o.config.app==="konnect"&&o.customPluginSupport==="streaming"){let L=`${o.config.apiBaseUrl}${Me.select[o.config.app].streamingCustomPlugins}`;return L=L.replace(/{controlPlaneId}/gi,o.config.controlPlaneId||""),L}return null}),I=t.computed(()=>{if(o.config.entityType&&o.config.entityId){let L=`${o.config.apiBaseUrl}${Me.list[o.config.app].forEntity}`;return o.config.app==="konnect"?L=L.replace(/{controlPlaneId}/gi,o.config.controlPlaneId||""):o.config.app==="kongManager"&&(L=L.replace(/\/{workspace}/gi,o.config.workspace?`/${o.config.workspace}`:"")),L.replace(/{entityType}/gi,o.config.entityType||"").replace(/{entityId}/gi,o.config.entityId||"")}return""}),M=L=>{a.replace({hash:L,query:i.query})};t.watch(()=>o.disabledPlugins,(L,F)=>{!u(L,F)&&!p.value&&(_.value=G())}),t.watch(()=>o.ignoredPlugins,(L,F)=>{!u(L,F)&&!p.value&&(_.value=G())}),t.watch(p,L=>{r("loading",L)});const R=t.ref(!1),te=t.ref(!1),z=t.ref(!1);return t.onBeforeMount(async()=>{R.value=await o.canCreateCustomPlugin(),te.value=await o.canEditCustomPlugin(),z.value=await o.canDeleteCustomPlugin()}),t.onMounted(async()=>{try{const{data:L}=await b.get(T.value);if(o.config.app==="konnect"){const{names:F}=L;if(y.value=F||[],Y.value){const{data:Z}=await b.get(Y.value);g.value=Z.data||[]}}else if(o.config.app==="kongManager"){const{plugins:{available_on_server:F}}=L;y.value=F?Object.keys(F):[]}}catch(L){m.value=!0,h.value=c(L)}if(I.value)try{const{data:{data:L}}=await b.get(I.value);if(L!=null&&L.length){const F=L.reduce((Z,Q)=>(Q.name&&Z.push(Q.name),Z),[]);w.value=w.value.concat(F)}}catch{}m.value||(_.value=G()),p.value=!1}),(L,F)=>{const Z=t.resolveComponent("KInput"),Q=t.resolveComponent("KSkeletonBox"),W=t.resolveComponent("KSkeleton"),ie=t.resolveComponent("KEmptyState"),ae=t.resolveComponent("KTooltip"),me=t.resolveComponent("KTabs");return t.openBlock(),t.createElementBlock("div",WR,[t.createElementVNode("div",XR,[t.createVNode(Z,{modelValue:f.value,"onUpdate:modelValue":F[0]||(F[0]=ge=>f.value=ge),modelModifiers:{trim:!0},class:"plugins-filter-input","data-testid":"plugins-filter",placeholder:t.unref(l)("search.placeholder.select"),type:"search"},null,8,["modelValue","placeholder"])]),p.value?(t.openBlock(),t.createElementBlock("section",ZR,[t.createVNode(Q,{class:"plugins-skeleton-title",width:"10"}),t.createVNode(W,{"card-count":8,class:"plugins-skeleton-cards",type:"card"})])):m.value?(t.openBlock(),t.createBlock(ie,{key:1,"action-button-visible":!1,"data-testid":"plugins-fetch-error","icon-variant":"error"},{default:t.withCtx(()=>[t.createElementVNode("h3",null,t.toDisplayString(h.value),1)]),_:1})):P.value&&f.value?(t.openBlock(),t.createBlock(ie,{key:2,"action-button-visible":!1,"data-testid":"plugins-empty-state","icon-variant":"search"},{default:t.withCtx(()=>[t.createElementVNode("h5",null,t.toDisplayString(t.unref(l)("search.no_results",{filter:f.value})),1)]),_:1})):(t.openBlock(),t.createElementBlock("section",JR,[B.value.length&&e.customPluginSupport!=="none"?(t.openBlock(),t.createBlock(me,{key:0,modelValue:j.value,"onUpdate:modelValue":F[5]||(F[5]=ge=>j.value=ge),"data-testid":"plugins-tabs",tabs:B.value,onChange:M},t.createSlots({kong:t.withCtx(()=>[t.createElementVNode("div",QR,[t.createElementVNode("p",eD,t.toDisplayString(t.unref(l)("plugins.select.tabs.kong.description")),1),t.createVNode(Xl,{config:e.config,"hide-highlighted-plugins":f.value.length>0,"highlighted-plugins":E.value,"highlighted-plugins-title":o.highlightedPluginsTitle,"navigate-on-click":e.navigateOnClick,"plugin-list":N.value,onPluginClicked:F[1]||(F[1]=ge=>L.$emit("plugin-clicked",ge))},null,8,["config","hide-highlighted-plugins","highlighted-plugins","highlighted-plugins-title","navigate-on-click","plugin-list"])])]),custom:t.withCtx(()=>[t.createElementVNode("div",tD,[t.createElementVNode("p",nD,t.toDisplayString(t.unref(l)("plugins.select.tabs.custom.description")),1),t.createVNode(qR,{"can-create-custom-plugin":R.value,"can-delete-custom-plugin":z.value,"can-edit-custom-plugin":te.value,config:e.config,"navigate-on-click":e.navigateOnClick,"plugin-list":N.value,"onDelete:success":F[2]||(F[2]=ge=>L.$emit("delete-custom:success",ge)),onPluginClicked:F[3]||(F[3]=ge=>L.$emit("plugin-clicked",ge)),onRevalidate:F[4]||(F[4]=()=>_.value=G())},null,8,["can-create-custom-plugin","can-delete-custom-plugin","can-edit-custom-plugin","config","navigate-on-click","plugin-list"])])]),_:2},[e.customPluginSupport==="disabled"?{name:"custom-anchor",fn:t.withCtx(()=>[t.createVNode(ae,{"max-width":"300",text:t.unref(l)("plugins.select.tabs.custom.disabled_tooltip")},{default:t.withCtx(()=>[t.createElementVNode("div",null,t.toDisplayString(t.unref(l)("plugins.select.tabs.custom.title")),1)]),_:1},8,["text"])]),key:"0"}:void 0]),1032,["modelValue","tabs"])):(t.openBlock(),t.createBlock(Xl,{key:1,config:e.config,"hide-highlighted-plugins":f.value.length>0,"highlighted-plugins":E.value,"highlighted-plugins-title":o.highlightedPluginsTitle,"navigate-on-click":e.navigateOnClick,"plugin-list":N.value,onPluginClicked:F[6]||(F[6]=ge=>L.$emit("plugin-clicked",ge))},null,8,["config","hide-highlighted-plugins","highlighted-plugins","highlighted-plugins-title","navigate-on-click","plugin-list"]))]))])}}}),[["__scopeId","data-v-c18b2b5c"]]),rD={class:"kong-ui-entity-plugin-config-card"},iD={class:"name-cell-wrapper"},aD={class:"info-name"},lD={key:0},sD={key:0},cD={key:0},dD={key:0},uD={key:0},Zl="config",fD=Ee(t.defineComponent({__name:"PluginConfigCard",props:{config:{type:Object,required:!0,validator:e=>!(!e||!["konnect","kongManager"].includes(e==null?void 0:e.app)||e.app==="konnect"&&!e.controlPlaneId||e.app==="kongManager"&&typeof e.workspace!="string"||!e.entityId||!e.pluginType)},configCardDoc:{type:String,default:"",required:!1},showIdAsLink:{type:Boolean,default:!1},hideTitle:{type:Boolean,default:!1},scopedEntityType:{type:String,required:!1,default:""},scopedEntityId:{type:String,required:!1,default:""},expandPartial:{type:Boolean,default:!0}},emits:["loading","fetch:error","error:fetch-schema","fetch:success","navigation-click"],setup(e,{emit:n}){var w;const o=n,r=e,{i18n:{t:i}}=Re.useI18n(),a=Re.usePluginMetaData(),{setFieldType:l}=Re.usePluginHelpers(),{getPropValue:s}=se.useHelpers(),c=t.computed(()=>{var b;return(b=Me.item[r.config.app])==null?void 0:b[r.scopedEntityType?"forEntity":"all"].replace(/{entityType}/gi,r.scopedEntityType).replace(/{entityId}/gi,r.scopedEntityId).concat(r.expandPartial?"?expand_partials=true":"")}),d=t.computed(()=>{var N,E;const b={},v=((N=y.value)==null?void 0:N.fields)||[];for(let S=0;S<v.length;S++){const P=y.value.fields[S],B=(E=Object.keys(P))==null?void 0:E[0];l(b,B,P[B])}return{...b,instance_name:{section:se.ConfigurationSchemaSection.Basic,order:1.5},consumer:{label:i("plugins.fields.consumer"),section:se.ConfigurationSchemaSection.Basic,order:6},route:{label:i("plugins.fields.route"),section:se.ConfigurationSchemaSection.Basic,order:6},service:{label:i("plugins.fields.service"),section:se.ConfigurationSchemaSection.Basic,order:6},consumer_group:{label:i("plugins.fields.consumer_group"),section:se.ConfigurationSchemaSection.Basic,order:6},protocols:{type:se.ConfigurationSchemaType.BadgeTag,section:se.ConfigurationSchemaSection.Basic,order:7}}}),u=t.computed(()=>{var v,N,E;if(!((v=y.value)!=null&&v.fields))return[];const b=(N=y.value.fields)==null?void 0:N.find(S=>{var B;return((B=Object.keys(S))==null?void 0:B[0])===Zl});return((E=b==null?void 0:b[Zl])==null?void 0:E.fields)||[]}),f=t.computed(()=>{var v,N;const b={};if(!u.value)return b;for(let E=0;E<((v=u.value)==null?void 0:v.length);E++){const S=u.value[E],P=(N=Object.keys(S))==null?void 0:N[0],B=S[P];B.required&&(b[P]={order:1}),l(b,P,B)}return b}),{getMessageFromError:p}=se.useErrors(),{axiosInstance:m}=se.useAxios((w=r.config)==null?void 0:w.axiosRequestConfig),h=t.computed(()=>{var v,N;let b=`${r.config.apiBaseUrl}${Me.form[r.config.app].pluginSchema}`;return r.config.app==="konnect"?b=b.replace(/{controlPlaneId}/gi,((v=r.config)==null?void 0:v.controlPlaneId)||""):r.config.app==="kongManager"&&(b=b.replace(/\/{workspace}/gi,(N=r.config)!=null&&N.workspace?`/${r.config.workspace}`:"")),b=b.replace(/{plugin}/gi,r.config.pluginType),b}),y=t.ref({});se.useSchemaProvider(y);const g=t.ref(!1),_=t.ref("");return t.onBeforeMount(async()=>{g.value=!0;try{const{data:b}=await m.get(h.value);y.value=b}catch(b){_.value=p(b),o("error:fetch-schema",b)}finally{g.value=!1}}),(b,v)=>{const N=t.resolveComponent("KSkeleton"),E=t.resolveComponent("KEmptyState"),S=t.resolveComponent("KCopy");return t.openBlock(),t.createElementBlock("div",rD,[g.value?(t.openBlock(),t.createBlock(N,{key:0,"data-testid":"plugin-config-card-loader","table-columns":2,type:"table"})):_.value?(t.openBlock(),t.createBlock(E,{key:1,"data-testid":"plugin-config-card-schema-error","icon-variant":"error"},{default:t.withCtx(()=>[t.createElementVNode("h3",null,t.toDisplayString(_.value),1)]),_:1})):(t.openBlock(),t.createBlock(t.unref(se.EntityBaseConfigCard),{key:2,config:e.config,"config-card-doc":e.configCardDoc,"config-schema":d.value,"entity-type":t.unref(se.SupportedEntityType).Plugin,"fetch-url":c.value,"hide-title":e.hideTitle,"plugin-config-key":Zl,"plugin-config-schema":f.value,"onFetch:error":v[0]||(v[0]=P=>b.$emit("fetch:error",P)),"onFetch:success":v[1]||(v[1]=P=>b.$emit("fetch:success",P)),onLoading:v[2]||(v[2]=P=>b.$emit("loading",P))},{name:t.withCtx(P=>[t.createElementVNode("div",iD,[t.createVNode(t.unref(io.PluginIcon),{class:"plugin-icon",name:t.unref(s)("rowValue",P),size:24},null,8,["name"]),t.createElementVNode("span",aD,t.toDisplayString(t.unref(a).getDisplayName(t.unref(s)("rowValue",P))),1)])]),consumer:t.withCtx(P=>[t.unref(s)("rowValue",P)?e.showIdAsLink?(t.openBlock(),t.createBlock(t.unref(se.InternalLinkItem),{key:1,item:{key:t.unref(s)("rowValue",P).id,value:t.unref(s)("rowValue",P).id,type:t.unref(se.ConfigurationSchemaType).LinkInternal},onNavigationClick:()=>b.$emit("navigation-click",t.unref(s)("rowValue",P).id,"consumer")},null,8,["item","onNavigationClick"])):(t.openBlock(),t.createBlock(S,{key:2,"copy-tooltip":t.unref(i)("copy.tooltip",{label:t.unref(s)("row",P).label}),"data-testid":"consumer-copy-uuid",text:t.unref(s)("rowValue",P).id},null,8,["copy-tooltip","text"])):(t.openBlock(),t.createElementBlock("span",lD,"–"))]),route:t.withCtx(P=>[t.unref(s)("rowValue",P)?e.showIdAsLink?(t.openBlock(),t.createBlock(t.unref(se.InternalLinkItem),{key:1,item:{key:t.unref(s)("rowValue",P).id,value:t.unref(s)("rowValue",P).id,type:t.unref(se.ConfigurationSchemaType).LinkInternal},onNavigationClick:()=>b.$emit("navigation-click",t.unref(s)("rowValue",P).id,"route")},null,8,["item","onNavigationClick"])):(t.openBlock(),t.createBlock(S,{key:2,"copy-tooltip":t.unref(i)("copy.tooltip",{label:t.unref(s)("row",P).label}),"data-testid":"route-copy-uuid",text:t.unref(s)("rowValue",P).id},null,8,["copy-tooltip","text"])):(t.openBlock(),t.createElementBlock("span",sD,"–"))]),service:t.withCtx(P=>[t.unref(s)("rowValue",P)?e.showIdAsLink?(t.openBlock(),t.createBlock(t.unref(se.InternalLinkItem),{key:1,item:{key:t.unref(s)("rowValue",P).id,value:t.unref(s)("rowValue",P).id,type:t.unref(se.ConfigurationSchemaType).LinkInternal},onNavigationClick:()=>b.$emit("navigation-click",t.unref(s)("rowValue",P).id,"service")},null,8,["item","onNavigationClick"])):(t.openBlock(),t.createBlock(S,{key:2,"copy-tooltip":t.unref(i)("copy.tooltip",{label:t.unref(s)("row",P).label}),"data-testid":"service-copy-uuid",text:t.unref(s)("rowValue",P).id},null,8,["copy-tooltip","text"])):(t.openBlock(),t.createElementBlock("span",cD,"–"))]),consumer_group:t.withCtx(P=>[t.unref(s)("rowValue",P)?e.showIdAsLink?(t.openBlock(),t.createBlock(t.unref(se.InternalLinkItem),{key:1,item:{key:t.unref(s)("rowValue",P).id,value:t.unref(s)("rowValue",P).id,type:t.unref(se.ConfigurationSchemaType).LinkInternal},onNavigationClick:()=>b.$emit("navigation-click",t.unref(s)("rowValue",P).id,"consumer_group")},null,8,["item","onNavigationClick"])):(t.openBlock(),t.createBlock(S,{key:2,"copy-tooltip":t.unref(i)("copy.tooltip",{label:t.unref(s)("row",P).label}),"data-testid":"consumer-group-copy-uuid",text:t.unref(s)("rowValue",P).id},null,8,["copy-tooltip","text"])):(t.openBlock(),t.createElementBlock("span",dD,"–"))]),partials:t.withCtx(P=>{var B,j,G,T,Y,I,M,R,te;return[t.unref(s)("rowValue",P)?e.showIdAsLink?(t.openBlock(),t.createBlock(t.unref(se.InternalLinkItem),{key:1,item:{key:(j=(B=t.unref(s)("rowValue",P))==null?void 0:B[0])==null?void 0:j.id,value:((T=(G=t.unref(s)("rowValue",P))==null?void 0:G[0])==null?void 0:T.id)+((I=(Y=t.unref(s)("rowValue",P))==null?void 0:Y[0])!=null&&I.name?"/"+((R=(M=t.unref(s)("rowValue",P))==null?void 0:M[0])==null?void 0:R.name):""),type:t.unref(se.ConfigurationSchemaType).LinkInternal},onNavigationClick:()=>{var z,H;return b.$emit("navigation-click",(H=(z=t.unref(s)("rowValue",P))==null?void 0:z[0])==null?void 0:H.id,"partial")}},null,8,["item","onNavigationClick"])):(t.openBlock(),t.createBlock(S,{key:2,"copy-tooltip":t.unref(i)("copy.tooltip",{label:t.unref(s)("row",P).label}),"data-testid":"partial-copy-uuid",text:(te=t.unref(s)("rowValue",P))==null?void 0:te[0].id},null,8,["copy-tooltip","text"])):(t.openBlock(),t.createElementBlock("span",uD,"–"))]}),_:1},8,["config","config-card-doc","config-schema","entity-type","fetch-url","hide-title","plugin-config-schema"]))])}}}),[["__scopeId","data-v-53806ec8"]]),{usePluginMetaData:pD,useProvideExperimentalFreeForms:mD}=Re;Object.defineProperty(we,"PluginGroup",{enumerable:!0,get:()=>K.PluginGroup}),Object.defineProperty(we,"PluginScope",{enumerable:!0,get:()=>K.PluginScope}),Object.defineProperty(we,"PluginIcon",{enumerable:!0,get:()=>io.PluginIcon}),Object.defineProperty(we,"getPluginIconURL",{enumerable:!0,get:()=>io.getPluginIconURL}),we.EXPERIMENTAL_FREE_FORM_PROVIDER=la,we.EntityTypeIdField=nn,we.FEATURE_FLAGS=kc,we.PLUGIN_GROUPS_COLLAPSE_STATUS=es,we.PluginConfigCard=fD,we.PluginForm=ER,we.PluginGroupArray=Ql,we.PluginList=TR,we.PluginPartialType=sr,we.PluginSelect=oD,we.PluginSelectCard=Hl,we.PluginSelectGrid=Xl,we.TOASTER_PROVIDER=Ec,we.pluginEndpoints=Me,we.usePluginMetaData=pD,we.useProvideExperimentalFreeForms=mD,Object.defineProperty(we,Symbol.toStringTag,{value:"Module"})});
|
|
144
|
+
Edge: ${e}`,USEVUEFLOW_OPTIONS:()=>"The options parameter is deprecated and will be removed in the next major version. Please use the id parameter instead"};class We extends Error{constructor(n,...o){var r;super((r=Af[n])==null?void 0:r.call(Af,...o)),this.name="VueFlowError",this.code=n,this.args=o}}function _l(e){return"clientX"in e}function Ax(e){return"sourceEvent"in e}function Tt(e,n){const o=_l(e);let r,i;return o?(r=e.clientX,i=e.clientY):"touches"in e&&e.touches.length>0?(r=e.touches[0].clientX,i=e.touches[0].clientY):"changedTouches"in e&&e.changedTouches.length>0?(r=e.changedTouches[0].clientX,i=e.changedTouches[0].clientY):(r=0,i=0),{x:r-((n==null?void 0:n.left)??0),y:i-((n==null?void 0:n.top)??0)}}const di=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Ix(e){var n,o;return{width:((n=e.dimensions)==null?void 0:n.width)??e.width??0,height:((o=e.dimensions)==null?void 0:o.height)??e.height??0}}function ui(e,n=[1,1]){return{x:n[0]*Math.round(e.x/n[0]),y:n[1]*Math.round(e.y/n[1])}}const Px=()=>!0;function bl(e){e==null||e.classList.remove("valid","connecting","vue-flow__handle-valid","vue-flow__handle-connecting")}function Tx(e,n,o){const r=[],i={x:e.x-o,y:e.y-o,width:o*2,height:o*2};for(const a of n.values())li(i,ai(a))>0&&r.push(a);return r}const Ox=250;function $x(e,n,o,r){var i,a;let l=[],s=Number.POSITIVE_INFINITY;const c=Tx(e,o,n+Ox);for(const d of c){const u=[...((i=d.handleBounds)==null?void 0:i.source)??[],...((a=d.handleBounds)==null?void 0:a.target)??[]];for(const f of u){if(r.nodeId===f.nodeId&&r.type===f.type&&r.id===f.id)continue;const{x:p,y:m}=Zn(d,f,f.position,!0),h=Math.sqrt((p-e.x)**2+(m-e.y)**2);h>n||(h<s?(l=[{...f,x:p,y:m}],s=h):h===s&&l.push({...f,x:p,y:m}))}}if(!l.length)return null;if(l.length>1){const d=r.type==="source"?"target":"source";return l.find(u=>u.type===d)??l[0]}return l[0]}function If(e,{handle:n,connectionMode:o,fromNodeId:r,fromHandleId:i,fromType:a,doc:l,lib:s,flowId:c,isValidConnection:d=Px},u,f,p){const m=a==="target",h=n?l.querySelector(`.${s}-flow__handle[data-id="${c}-${n==null?void 0:n.nodeId}-${n==null?void 0:n.id}-${n==null?void 0:n.type}"]`):null,{x:y,y:g}=Tt(e),_=l.elementFromPoint(y,g),w=_!=null&&_.classList.contains(`${s}-flow__handle`)?_:h,b={handleDomNode:w,isValid:!1,connection:null,toHandle:null};if(w){const v=Pf(void 0,w),N=w.getAttribute("data-nodeid"),E=w.getAttribute("data-handleid"),S=w.classList.contains("connectable"),P=w.classList.contains("connectableend");if(!N||!v)return b;const B={source:m?N:r,sourceHandle:m?E:i,target:m?r:N,targetHandle:m?i:E};b.connection=B;const G=S&&P&&(o===Xt.Strict?m&&v==="source"||!m&&v==="target":N!==r||E!==i);b.isValid=G&&d(B,{nodes:f,edges:u,sourceNode:p(r),targetNode:p(N)}),b.toHandle=n}return b}function Pf(e,n){return e||(n!=null&&n.classList.contains("target")?"target":n!=null&&n.classList.contains("source")?"source":null)}function Bx(e,n){let o=null;return n?o="valid":e&&!n&&(o="invalid"),o}function Vx(e,n){let o=null;return n?o=!0:e&&!n&&(o=!1),o}function Rx(e,n,o,r,i,a=!1){var l,s,c;const d=r.get(e);if(!d)return null;const u=i===Xt.Strict?(l=d.handleBounds)==null?void 0:l[n]:[...((s=d.handleBounds)==null?void 0:s.source)??[],...((c=d.handleBounds)==null?void 0:c.target)??[]],f=(o?u==null?void 0:u.find(p=>p.id===o):u==null?void 0:u[0])??null;return f&&a?{...f,...Zn(d,f,f.position,!0)}:f}const wl={[ye.Left]:ye.Right,[ye.Right]:ye.Left,[ye.Top]:ye.Bottom,[ye.Bottom]:ye.Top},Dx=["production","prod"];function fi(e,...n){Tf()&&console.warn(`[Vue Flow]: ${e}`,...n)}function Tf(){return!Dx.includes(process.env.NODE_ENV||"")}function Of(e,n,o,r,i){const a=n.querySelectorAll(`.vue-flow__handle.${e}`);return a!=null&&a.length?Array.from(a).map(l=>{const s=l.getBoundingClientRect();return{id:l.getAttribute("data-handleid"),type:e,nodeId:i,position:l.getAttribute("data-handlepos"),x:(s.left-o.left)/r,y:(s.top-o.top)/r,...si(l)}}):null}function kl(e,n,o,r,i,a=!1,l){i.value=!1,e.selected?(a||e.selected&&n)&&(r([e]),t.nextTick(()=>{l.blur()})):o([e])}function Ge(e){return typeof t.unref(e)<"u"}function Mx(e,n,o,r){if(!e||!e.source||!e.target)return o(new We(je.EDGE_INVALID,(e==null?void 0:e.id)??"[ID UNKNOWN]")),!1;let i;return Zt(e)?i=e:i={...e,id:ff(e)},i=df(i,void 0,r),_x(i,n)?!1:i}function Lx(e,n,o,r,i){if(!n.source||!n.target)return i(new We(je.EDGE_INVALID,e.id)),!1;if(!o)return i(new We(je.EDGE_NOT_FOUND,e.id)),!1;const{id:a,...l}=e;return{...l,id:r?ff(n):a,source:n.source,target:n.target,sourceHandle:n.sourceHandle,targetHandle:n.targetHandle}}function $f(e,n,o){const r={},i=[];for(let a=0;a<e.length;++a){const l=e[a];if(!wn(l)){o(new We(je.NODE_INVALID,l==null?void 0:l.id)||`[ID UNKNOWN|INDEX ${a}]`);continue}const s=gx(l,n(l.id),l.parentNode);l.parentNode&&(r[l.parentNode]=!0),i[a]=s}for(const a of i){const l=n(a.parentNode)||i.find(s=>s.id===a.parentNode);a.parentNode&&!l&&o(new We(je.NODE_MISSING_PARENT,a.id,a.parentNode)),(a.parentNode||r[a.id])&&(r[a.id]&&(a.isParent=!0),l&&(l.isParent=!0))}return i}function Bf(e,n,o,r,i,a){let l=i;const s=r.get(l)||new Map;r.set(l,s.set(o,n)),l=`${i}-${e}`;const c=r.get(l)||new Map;if(r.set(l,c.set(o,n)),a){l=`${i}-${e}-${a}`;const d=r.get(l)||new Map;r.set(l,d.set(o,n))}}function El(e,n,o){e.clear();for(const r of o){const{source:i,target:a,sourceHandle:l=null,targetHandle:s=null}=r,c={edgeId:r.id,source:i,target:a,sourceHandle:l,targetHandle:s},d=`${i}-${l}--${a}-${s}`,u=`${a}-${s}--${i}-${l}`;Bf("source",c,u,e,i,l),Bf("target",c,d,e,a,s)}}function Vf(e,n){if(e.size!==n.size)return!1;for(const o of e)if(!n.has(o))return!1;return!0}function Cl(e,n,o,r,i,a,l,s){const c=[];for(const d of e){const u=Zt(d)?d:Mx(d,s,i,a);if(!u)continue;const f=o(u.source),p=o(u.target);if(!f||!p){i(new We(je.EDGE_SOURCE_TARGET_MISSING,u.id,u.source,u.target));continue}if(!f){i(new We(je.EDGE_SOURCE_MISSING,u.id,u.source));continue}if(!p){i(new We(je.EDGE_TARGET_MISSING,u.id,u.target));continue}if(n&&!n(u,{edges:s,nodes:l,sourceNode:f,targetNode:p})){i(new We(je.EDGE_INVALID,u.id));continue}const m=r(u.id);c.push({...df(u,m,a),sourceNode:f,targetNode:p})}return c}const Rf=Symbol("vueFlow"),Df=Symbol("nodeId"),Mf=Symbol("nodeRef"),Fx=Symbol("edgeId"),Ux=Symbol("edgeRef"),pi=Symbol("slots");function Lf(e){const{vueFlowRef:n,snapToGrid:o,snapGrid:r,noDragClassName:i,nodes:a,nodeExtent:l,nodeDragThreshold:s,viewport:c,autoPanOnNodeDrag:d,autoPanSpeed:u,nodesDraggable:f,panBy:p,findNode:m,multiSelectionActive:h,nodesSelectionActive:y,selectNodesOnDrag:g,removeSelectedElements:_,addSelectedNodes:w,updateNodePositions:b,emits:v}=Oe(),{onStart:N,onDrag:E,onStop:S,onClick:P,el:B,disabled:j,id:G,selectable:T,dragHandle:Y}=e,I=t.shallowRef(!1);let M=[],R,te=null,z={x:void 0,y:void 0},H={x:0,y:0},L=null,F=!1,Z=0,Q=!1;const W=Gx(),ie=({x:q,y:ee})=>{z={x:q,y:ee};let O=!1;if(M=M.map(k=>{const C={x:q-k.distance.x,y:ee-k.distance.y},{computedPosition:x}=yl(k,o.value?ui(C,r.value):C,v.error,l.value,k.parentNode?m(k.parentNode):void 0);return O=O||k.position.x!==x.x||k.position.y!==x.y,k.position=x,k}),!!O&&(b(M,!0,!0),I.value=!0,L)){const[k,C]=hl({id:G,dragItems:M,findNode:m});E({event:L,node:k,nodes:C})}},ae=()=>{if(!te)return;const[q,ee]=wf(H,te,u.value);if(q!==0||ee!==0){const O={x:(z.x??0)-q/c.value.zoom,y:(z.y??0)-ee/c.value.zoom};p({x:q,y:ee})&&ie(O)}Z=requestAnimationFrame(ae)},me=(q,ee)=>{F=!0;const O=m(G);!g.value&&!h.value&&O&&(O.selected||_()),O&&t.toValue(T)&&g.value&&kl(O,h.value,w,_,y,!1,ee);const k=W(q.sourceEvent);if(z=k,M=Ex(a.value,f.value,k,m,G),M.length){const[C,x]=hl({id:G,dragItems:M,findNode:m});N({event:q.sourceEvent,node:C,nodes:x})}},ge=(q,ee)=>{var O;q.sourceEvent.type==="touchmove"&&q.sourceEvent.touches.length>1||(s.value===0&&me(q,ee),z=W(q.sourceEvent),te=((O=n.value)==null?void 0:O.getBoundingClientRect())||null,H=Tt(q.sourceEvent,te))},ne=(q,ee)=>{const O=W(q.sourceEvent);if(!Q&&F&&d.value&&(Q=!0,ae()),!F){const k=O.xSnapped-(z.x??0),C=O.ySnapped-(z.y??0);Math.sqrt(k*k+C*C)>s.value&&me(q,ee)}(z.x!==O.xSnapped||z.y!==O.ySnapped)&&M.length&&F&&(L=q.sourceEvent,H=Tt(q.sourceEvent,te),ie(O))},re=q=>{let ee=!1;if(!F&&!I.value&&!h.value){const O=q.sourceEvent,k=W(O),C=k.xSnapped-(z.x??0),x=k.ySnapped-(z.y??0),A=Math.sqrt(C*C+x*x);A!==0&&A<=s.value&&(P==null||P(O),ee=!0)}if(M.length&&!ee){b(M,!1,!1);const[O,k]=hl({id:G,dragItems:M,findNode:m});S({event:q.sourceEvent,node:O,nodes:k})}M=[],I.value=!1,Q=!1,F=!1,z={x:void 0,y:void 0},cancelAnimationFrame(Z)};return t.watch([()=>t.toValue(j),B],([q,ee],O,k)=>{if(ee){const C=_t(ee);q||(R=mv().on("start",x=>ge(x,ee)).on("drag",x=>ne(x,ee)).on("end",x=>re(x)).filter(x=>{const A=x.target,U=t.toValue(Y);return!x.button&&(!i.value||!vf(A,`.${i.value}`,ee)&&(!U||vf(A,U,ee)))}),C.call(R)),k(()=>{C.on(".drag",null),R&&(R.on("start",null),R.on("drag",null),R.on("end",null))})}}),I}function Kx(){return{doubleClick:he(),click:he(),mouseEnter:he(),mouseMove:he(),mouseLeave:he(),contextMenu:he(),updateStart:he(),update:he(),updateEnd:he()}}function jx(e,n){const o=Kx();return o.doubleClick.on(r=>{var i,a;n.edgeDoubleClick(r),(a=(i=e.events)==null?void 0:i.doubleClick)==null||a.call(i,r)}),o.click.on(r=>{var i,a;n.edgeClick(r),(a=(i=e.events)==null?void 0:i.click)==null||a.call(i,r)}),o.mouseEnter.on(r=>{var i,a;n.edgeMouseEnter(r),(a=(i=e.events)==null?void 0:i.mouseEnter)==null||a.call(i,r)}),o.mouseMove.on(r=>{var i,a;n.edgeMouseMove(r),(a=(i=e.events)==null?void 0:i.mouseMove)==null||a.call(i,r)}),o.mouseLeave.on(r=>{var i,a;n.edgeMouseLeave(r),(a=(i=e.events)==null?void 0:i.mouseLeave)==null||a.call(i,r)}),o.contextMenu.on(r=>{var i,a;n.edgeContextMenu(r),(a=(i=e.events)==null?void 0:i.contextMenu)==null||a.call(i,r)}),o.updateStart.on(r=>{var i,a;n.edgeUpdateStart(r),(a=(i=e.events)==null?void 0:i.updateStart)==null||a.call(i,r)}),o.update.on(r=>{var i,a;n.edgeUpdate(r),(a=(i=e.events)==null?void 0:i.update)==null||a.call(i,r)}),o.updateEnd.on(r=>{var i,a;n.edgeUpdateEnd(r),(a=(i=e.events)==null?void 0:i.updateEnd)==null||a.call(i,r)}),Object.entries(o).reduce((r,[i,a])=>(r.emit[i]=a.trigger,r.on[i]=a.on,r),{emit:{},on:{}})}function Gx(){const{viewport:e,snapGrid:n,snapToGrid:o,vueFlowRef:r}=Oe();return i=>{var a;const l=((a=r.value)==null?void 0:a.getBoundingClientRect())??{left:0,top:0},s=Ax(i)?i.sourceEvent:i,{x:c,y:d}=Tt(s,l),u=Ko({x:c,y:d},e.value),{x:f,y:p}=o.value?ui(u,n.value):u;return{xSnapped:f,ySnapped:p,...u}}}function mi(){return!0}function Ff({handleId:e,nodeId:n,type:o,isValidConnection:r,edgeUpdaterType:i,onEdgeUpdate:a,onEdgeUpdateEnd:l}){const{id:s,vueFlowRef:c,connectionMode:d,connectionRadius:u,connectOnClick:f,connectionClickStartHandle:p,nodesConnectable:m,autoPanOnConnect:h,autoPanSpeed:y,findNode:g,panBy:_,startConnection:w,updateConnection:b,endConnection:v,emits:N,viewport:E,edges:S,nodes:P,isValidConnection:B,nodeLookup:j}=Oe();let G=null,T=!1,Y=null;function I(R){var te;const z=t.toValue(o)==="target",H=_l(R),L=cf(R.target);if(H&&R.button===0||!H){let F=function(X){k=Tt(X,q),ie=$x(Ko(k,E.value,!1,[1,1]),u.value,j.value,A),C||(x(),C=!0);const D=If(X,{handle:ie,connectionMode:d.value,fromNodeId:t.toValue(n),fromHandleId:t.toValue(e),fromType:z?"target":"source",isValidConnection:W,doc:L,lib:"vue",flowId:s,nodeLookup:j.value},S.value,P.value,g);Y=D.handleDomNode,G=D.connection,T=Vx(!!ie,D.isValid);const pe={...$,isValid:T,to:D.toHandle&&T?ml({x:D.toHandle.x,y:D.toHandle.y},E.value):k,toHandle:D.toHandle,toPosition:T&&D.toHandle?D.toHandle.position:wl[A.position],toNode:D.toHandle?j.value.get(D.toHandle.nodeId):null};if(!(T&&ie&&($!=null&&$.toHandle)&&pe.toHandle&&$.toHandle.type===pe.toHandle.type&&$.toHandle.nodeId===pe.toHandle.nodeId&&$.toHandle.id===pe.toHandle.id&&$.to.x===pe.to.x&&$.to.y===pe.to.y)){if(b(ie&&T?ml({x:ie.x,y:ie.y},E.value):k,D.toHandle,Bx(!!ie,T)),$=pe,!ie&&!T&&!Y)return bl(O);G&&G.source!==G.target&&Y&&(bl(O),O=Y,Y.classList.add("connecting","vue-flow__handle-connecting"),Y.classList.toggle("valid",!!T),Y.classList.toggle("vue-flow__handle-valid",!!T))}},Z=function(X){(ie||Y)&&G&&T&&(a?a(X,G):N.connect(G)),N.connectEnd(X),i&&(l==null||l(X)),bl(O),cancelAnimationFrame(ae),v(X),C=!1,T=!1,G=null,Y=null,L.removeEventListener("mousemove",F),L.removeEventListener("mouseup",Z),L.removeEventListener("touchmove",F),L.removeEventListener("touchend",Z)};const Q=g(t.toValue(n));let W=t.toValue(r)||B.value||mi;!W&&Q&&(W=(z?Q.isValidSourcePos:Q.isValidTargetPos)||mi);let ie,ae=0;const{x:me,y:ge}=Tt(R),ne=L==null?void 0:L.elementFromPoint(me,ge),re=Pf(t.toValue(i),ne),q=(te=c.value)==null?void 0:te.getBoundingClientRect();if(!q||!re)return;const ee=Rx(t.toValue(n),re,t.toValue(e),j.value,d.value);if(!ee)return;let O,k=Tt(R,q),C=!1;const x=()=>{if(!h.value)return;const[X,D]=wf(k,q,y.value);_({x:X,y:D}),ae=requestAnimationFrame(x)},A={...ee,nodeId:t.toValue(n),type:re,position:ee.position},U=j.value.get(t.toValue(n)),J={inProgress:!0,isValid:null,from:Zn(U,A,ye.Left,!0),fromHandle:A,fromPosition:A.position,fromNode:U,to:k,toHandle:null,toPosition:wl[A.position],toNode:null};w({nodeId:t.toValue(n),id:t.toValue(e),type:re,position:(ne==null?void 0:ne.getAttribute("data-handlepos"))||ye.Top,...k},{x:me-q.left,y:ge-q.top}),N.connectStart({event:R,nodeId:t.toValue(n),handleId:t.toValue(e),handleType:re});let $=J;L.addEventListener("mousemove",F),L.addEventListener("mouseup",Z),L.addEventListener("touchmove",F),L.addEventListener("touchend",Z)}}function M(R){var te,z;if(!f.value)return;const H=t.toValue(o)==="target";if(!p.value){N.clickConnectStart({event:R,nodeId:t.toValue(n),handleId:t.toValue(e)}),w({nodeId:t.toValue(n),type:t.toValue(o),id:t.toValue(e),position:ye.Top,...Tt(R)},void 0,!0);return}let L=t.toValue(r)||B.value||mi;const F=g(t.toValue(n));if(!L&&F&&(L=(H?F.isValidSourcePos:F.isValidTargetPos)||mi),F&&(typeof F.connectable>"u"?m.value:F.connectable)===!1)return;const Z=cf(R.target),Q=If(R,{handle:{nodeId:t.toValue(n),id:t.toValue(e),type:t.toValue(o),position:ye.Top,...Tt(R)},connectionMode:d.value,fromNodeId:p.value.nodeId,fromHandleId:p.value.id??null,fromType:p.value.type,isValidConnection:L,doc:Z,lib:"vue",flowId:s,nodeLookup:j.value},S.value,P.value,g),W=((te=Q.connection)==null?void 0:te.source)===((z=Q.connection)==null?void 0:z.target);Q.isValid&&Q.connection&&!W&&N.connect(Q.connection),N.clickConnectEnd(R),v(R,!0)}return{handlePointerDown:I,handleClick:M}}function qx(){return t.inject(Df,"")}function Uf(e){const n=e??qx()??"",o=t.inject(Mf,t.ref(null)),{findNode:r,edges:i,emits:a}=Oe(),l=r(n);return l||a.error(new We(je.NODE_NOT_FOUND,n)),{id:n,nodeEl:o,node:l,parentNode:t.computed(()=>r(l.parentNode)),connectedEdges:t.computed(()=>hf([l],i.value))}}function zx(){return{doubleClick:he(),click:he(),mouseEnter:he(),mouseMove:he(),mouseLeave:he(),contextMenu:he(),dragStart:he(),drag:he(),dragStop:he()}}function Hx(e,n){const o=zx();return o.doubleClick.on(r=>{var i,a;n.nodeDoubleClick(r),(a=(i=e.events)==null?void 0:i.doubleClick)==null||a.call(i,r)}),o.click.on(r=>{var i,a;n.nodeClick(r),(a=(i=e.events)==null?void 0:i.click)==null||a.call(i,r)}),o.mouseEnter.on(r=>{var i,a;n.nodeMouseEnter(r),(a=(i=e.events)==null?void 0:i.mouseEnter)==null||a.call(i,r)}),o.mouseMove.on(r=>{var i,a;n.nodeMouseMove(r),(a=(i=e.events)==null?void 0:i.mouseMove)==null||a.call(i,r)}),o.mouseLeave.on(r=>{var i,a;n.nodeMouseLeave(r),(a=(i=e.events)==null?void 0:i.mouseLeave)==null||a.call(i,r)}),o.contextMenu.on(r=>{var i,a;n.nodeContextMenu(r),(a=(i=e.events)==null?void 0:i.contextMenu)==null||a.call(i,r)}),o.dragStart.on(r=>{var i,a;n.nodeDragStart(r),(a=(i=e.events)==null?void 0:i.dragStart)==null||a.call(i,r)}),o.drag.on(r=>{var i,a;n.nodeDrag(r),(a=(i=e.events)==null?void 0:i.drag)==null||a.call(i,r)}),o.dragStop.on(r=>{var i,a;n.nodeDragStop(r),(a=(i=e.events)==null?void 0:i.dragStop)==null||a.call(i,r)}),Object.entries(o).reduce((r,[i,a])=>(r.emit[i]=a.trigger,r.on[i]=a.on,r),{emit:{},on:{}})}function Kf(){const{getSelectedNodes:e,nodeExtent:n,updateNodePositions:o,findNode:r,snapGrid:i,snapToGrid:a,nodesDraggable:l,emits:s}=Oe();return(c,d=!1)=>{const u=a.value?i.value[0]:5,f=a.value?i.value[1]:5,p=d?4:1,m=c.x*u*p,h=c.y*f*p,y=[];for(const g of e.value)if(g.draggable||l&&typeof g.draggable>"u"){const _={x:g.computedPosition.x+m,y:g.computedPosition.y+h},{computedPosition:w}=yl(g,_,s.error,n.value,g.parentNode?r(g.parentNode):void 0);y.push({id:g.id,position:w,from:g.position,distance:{x:c.x,y:c.y},dimensions:g.dimensions})}o(y,!0,!1)}}const Nl=.1,Yx=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2;function en(){return fi("Viewport not initialized yet."),Promise.resolve(!1)}const Wx={zoomIn:en,zoomOut:en,zoomTo:en,fitView:en,setCenter:en,fitBounds:en,project:e=>e,screenToFlowCoordinate:e=>e,flowToScreenCoordinate:e=>e,setViewport:en,setTransform:en,getViewport:()=>({x:0,y:0,zoom:1}),getTransform:()=>({x:0,y:0,zoom:1}),viewportInitialized:!1};function Xx(e){function n(r,i){return new Promise(a=>{e.d3Selection&&e.d3Zoom?e.d3Zoom.interpolate((i==null?void 0:i.interpolate)==="linear"?$o:Wr).scaleBy(vl(e.d3Selection,i==null?void 0:i.duration,i==null?void 0:i.ease,()=>{a(!0)}),r):a(!1)})}function o(r,i,a,l){return new Promise(s=>{var c;const{x:d,y:u}=sf({x:-r,y:-i},e.translateExtent),f=Wn.translate(-d,-u).scale(a);e.d3Selection&&e.d3Zoom?(c=e.d3Zoom)==null||c.interpolate((l==null?void 0:l.interpolate)==="linear"?$o:Wr).transform(vl(e.d3Selection,l==null?void 0:l.duration,l==null?void 0:l.ease,()=>{s(!0)}),f):s(!1)})}return t.computed(()=>e.d3Zoom&&e.d3Selection&&e.dimensions.width&&e.dimensions.height?{viewportInitialized:!0,zoomIn:i=>n(1.2,i),zoomOut:i=>n(1/1.2,i),zoomTo:(i,a)=>new Promise(l=>{e.d3Selection&&e.d3Zoom?e.d3Zoom.interpolate((a==null?void 0:a.interpolate)==="linear"?$o:Wr).scaleTo(vl(e.d3Selection,a==null?void 0:a.duration,a==null?void 0:a.ease,()=>{l(!0)}),i):l(!1)}),setViewport:(i,a)=>o(i.x,i.y,i.zoom,a),setTransform:(i,a)=>o(i.x,i.y,i.zoom,a),getViewport:()=>({x:e.viewport.x,y:e.viewport.y,zoom:e.viewport.zoom}),getTransform:()=>({x:e.viewport.x,y:e.viewport.y,zoom:e.viewport.zoom}),fitView:(i={padding:Nl,includeHiddenNodes:!1,duration:0})=>{var a,l;const s=[];for(const p of e.nodes)p.dimensions.width&&p.dimensions.height&&((i==null?void 0:i.includeHiddenNodes)||!p.hidden)&&(!((a=i.nodes)!=null&&a.length)||(l=i.nodes)!=null&&l.length&&i.nodes.includes(p.id))&&s.push(p);if(!s.length)return Promise.resolve(!1);const c=mf(s),{x:d,y:u,zoom:f}=yf(c,e.dimensions.width,e.dimensions.height,i.minZoom??e.minZoom,i.maxZoom??e.maxZoom,i.padding??Nl,i.offset);return o(d,u,f,i)},setCenter:(i,a,l)=>{const s=typeof(l==null?void 0:l.zoom)<"u"?l.zoom:e.maxZoom,c=e.dimensions.width/2-i*s,d=e.dimensions.height/2-a*s;return o(c,d,s,l)},fitBounds:(i,a={padding:Nl})=>{const{x:l,y:s,zoom:c}=yf(i,e.dimensions.width,e.dimensions.height,e.minZoom,e.maxZoom,a.padding);return o(l,s,c,a)},project:i=>Ko(i,e.viewport,e.snapToGrid,e.snapGrid),screenToFlowCoordinate:i=>{if(e.vueFlowRef){const{x:a,y:l}=e.vueFlowRef.getBoundingClientRect(),s={x:i.x-a,y:i.y-l};return Ko(s,e.viewport,e.snapToGrid,e.snapGrid)}return{x:0,y:0}},flowToScreenCoordinate:i=>{if(e.vueFlowRef){const{x:a,y:l}=e.vueFlowRef.getBoundingClientRect(),s={x:i.x+a,y:i.y+l};return ml(s,e.viewport)}return{x:0,y:0}}}:Wx)}function vl(e,n=0,o=Yx,r=()=>{}){const i=typeof n=="number"&&n>0;return i||r(),i?e.transition().duration(n).ease(o).on("end",r):e}function Zx(e,n,o){const r=t.effectScope(!0);return r.run(()=>{const i=()=>{r.run(()=>{let y,g,_=!!(o.nodes.value.length||o.edges.value.length);y=Gn([e.modelValue,()=>{var w,b;return(b=(w=e.modelValue)==null?void 0:w.value)==null?void 0:b.length}],([w])=>{w&&Array.isArray(w)&&(g==null||g.pause(),o.setElements(w),!g&&!_&&w.length?_=!0:g==null||g.resume())}),g=Gn([o.nodes,o.edges,()=>o.edges.value.length,()=>o.nodes.value.length],([w,b])=>{var v;(v=e.modelValue)!=null&&v.value&&Array.isArray(e.modelValue.value)&&(y==null||y.pause(),e.modelValue.value=[...w,...b],t.nextTick(()=>{y==null||y.resume()}))},{immediate:_}),t.onScopeDispose(()=>{y==null||y.stop(),g==null||g.stop()})})},a=()=>{r.run(()=>{let y,g,_=!!o.nodes.value.length;y=Gn([e.nodes,()=>{var w,b;return(b=(w=e.nodes)==null?void 0:w.value)==null?void 0:b.length}],([w])=>{w&&Array.isArray(w)&&(g==null||g.pause(),o.setNodes(w),!g&&!_&&w.length?_=!0:g==null||g.resume())}),g=Gn([o.nodes,()=>o.nodes.value.length],([w])=>{var b;(b=e.nodes)!=null&&b.value&&Array.isArray(e.nodes.value)&&(y==null||y.pause(),e.nodes.value=[...w],t.nextTick(()=>{y==null||y.resume()}))},{immediate:_}),t.onScopeDispose(()=>{y==null||y.stop(),g==null||g.stop()})})},l=()=>{r.run(()=>{let y,g,_=!!o.edges.value.length;y=Gn([e.edges,()=>{var w,b;return(b=(w=e.edges)==null?void 0:w.value)==null?void 0:b.length}],([w])=>{w&&Array.isArray(w)&&(g==null||g.pause(),o.setEdges(w),!g&&!_&&w.length?_=!0:g==null||g.resume())}),g=Gn([o.edges,()=>o.edges.value.length],([w])=>{var b;(b=e.edges)!=null&&b.value&&Array.isArray(e.edges.value)&&(y==null||y.pause(),e.edges.value=[...w],t.nextTick(()=>{y==null||y.resume()}))},{immediate:_}),t.onScopeDispose(()=>{y==null||y.stop(),g==null||g.stop()})})},s=()=>{r.run(()=>{t.watch(()=>n.maxZoom,()=>{n.maxZoom&&Ge(n.maxZoom)&&o.setMaxZoom(n.maxZoom)},{immediate:!0})})},c=()=>{r.run(()=>{t.watch(()=>n.minZoom,()=>{n.minZoom&&Ge(n.minZoom)&&o.setMinZoom(n.minZoom)},{immediate:!0})})},d=()=>{r.run(()=>{t.watch(()=>n.translateExtent,()=>{n.translateExtent&&Ge(n.translateExtent)&&o.setTranslateExtent(n.translateExtent)},{immediate:!0})})},u=()=>{r.run(()=>{t.watch(()=>n.nodeExtent,()=>{n.nodeExtent&&Ge(n.nodeExtent)&&o.setNodeExtent(n.nodeExtent)},{immediate:!0})})},f=()=>{r.run(()=>{t.watch(()=>n.applyDefault,()=>{Ge(n.applyDefault)&&(o.applyDefault.value=n.applyDefault)},{immediate:!0})})},p=()=>{r.run(()=>{const y=async g=>{let _=g;typeof n.autoConnect=="function"&&(_=await n.autoConnect(g)),_!==!1&&o.addEdges([_])};t.watch(()=>n.autoConnect,()=>{Ge(n.autoConnect)&&(o.autoConnect.value=n.autoConnect)},{immediate:!0}),t.watch(o.autoConnect,(g,_,w)=>{g?o.onConnect(y):o.hooks.value.connect.off(y),w(()=>{o.hooks.value.connect.off(y)})},{immediate:!0})})},m=()=>{const y=["id","modelValue","translateExtent","nodeExtent","edges","nodes","maxZoom","minZoom","applyDefault","autoConnect"];for(const g of Object.keys(n)){const _=g;if(!y.includes(_)){const w=t.toRef(()=>n[_]),b=o[_];t.isRef(b)&&r.run(()=>{t.watch(w,v=>{Ge(v)&&(b.value=v)},{immediate:!0})})}}};(()=>{i(),a(),l(),c(),s(),d(),u(),f(),p(),m()})()}),()=>r.stop()}function Jx(){return{edgesChange:he(),nodesChange:he(),nodeDoubleClick:he(),nodeClick:he(),nodeMouseEnter:he(),nodeMouseMove:he(),nodeMouseLeave:he(),nodeContextMenu:he(),nodeDragStart:he(),nodeDrag:he(),nodeDragStop:he(),nodesInitialized:he(),miniMapNodeClick:he(),miniMapNodeDoubleClick:he(),miniMapNodeMouseEnter:he(),miniMapNodeMouseMove:he(),miniMapNodeMouseLeave:he(),connect:he(),connectStart:he(),connectEnd:he(),clickConnectStart:he(),clickConnectEnd:he(),paneReady:he(),init:he(),move:he(),moveStart:he(),moveEnd:he(),selectionDragStart:he(),selectionDrag:he(),selectionDragStop:he(),selectionContextMenu:he(),selectionStart:he(),selectionEnd:he(),viewportChangeStart:he(),viewportChange:he(),viewportChangeEnd:he(),paneScroll:he(),paneClick:he(),paneContextMenu:he(),paneMouseEnter:he(),paneMouseMove:he(),paneMouseLeave:he(),edgeContextMenu:he(),edgeMouseEnter:he(),edgeMouseMove:he(),edgeMouseLeave:he(),edgeDoubleClick:he(),edgeClick:he(),edgeUpdateStart:he(),edgeUpdate:he(),edgeUpdateEnd:he(),updateNodeInternals:he(),error:he(e=>fi(e.message))}}function Qx(e,n){t.onBeforeMount(()=>{for(const[o,r]of Object.entries(n.value)){const i=a=>{e(o,a)};r.fns.add(i),Dr(()=>{r.off(i)})}})}function jf(){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:fl.Full,paneDragging:!1,preventScrolling:!0,zoomOnScroll:!0,zoomOnPinch:!0,zoomOnDoubleClick:!0,panOnScroll:!1,panOnScrollSpeed:.5,panOnScrollMode:Lo.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:_n.Bezier,style:{}},connectionMode:Xt.Loose,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectionPosition:{x:Number.NaN,y:Number.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:di()?"Meta":"Control",zoomActivationKeyCode:di()?"Meta":"Control",deleteKeyCode:"Backspace",panActivationKeyCode:"Space",hooks:Jx(),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:""}}const eA=["id","vueFlowRef","viewportRef","initialized","modelValue","nodes","edges","maxZoom","minZoom","translateExtent","hooks","defaultEdgeOptions"];function tA(e,n,o){const r=Xx(e),i=k=>{const C=k??[];e.hooks.updateNodeInternals.trigger(C)},a=k=>yx(k,e.nodes,e.edges),l=k=>hx(k,e.nodes,e.edges),s=k=>hf(k,e.edges),c=({id:k,type:C,nodeId:x})=>{var A;return Array.from(((A=e.connectionLookup.get(`${x}-${C}-${k??null}`))==null?void 0:A.values())??[])},d=k=>{if(k)return n.value.get(k)},u=k=>{if(k)return o.value.get(k)},f=(k,C,x)=>{var A,U;const V=[];for(const J of k){const $={id:J.id,type:"position",dragging:x,from:J.from};if(C&&($.position=J.position,J.parentNode)){const X=d(J.parentNode);$.position={x:$.position.x-(((A=X==null?void 0:X.computedPosition)==null?void 0:A.x)??0),y:$.position.y-(((U=X==null?void 0:X.computedPosition)==null?void 0:U.y)??0)}}V.push($)}V!=null&&V.length&&e.hooks.nodesChange.trigger(V)},p=k=>{if(!e.vueFlowRef)return;const C=e.vueFlowRef.querySelector(".vue-flow__transformationpane");if(!C)return;const x=window.getComputedStyle(C),{m22:A}=new window.DOMMatrixReadOnly(x.transform),U=[];for(const V of k){const J=V,$=d(J.id);if($){const X=si(J.nodeElement);if(!!(X.width&&X.height&&($.dimensions.width!==X.width||$.dimensions.height!==X.height||J.forceUpdate))){const pe=J.nodeElement.getBoundingClientRect();$.dimensions=X,$.handleBounds.source=Of("source",J.nodeElement,pe,A,$.id),$.handleBounds.target=Of("target",J.nodeElement,pe,A,$.id),U.push({id:$.id,type:"dimensions",dimensions:X})}}}!e.fitViewOnInitDone&&e.fitViewOnInit&&r.value.fitView().then(()=>{e.fitViewOnInitDone=!0}),U.length&&e.hooks.nodesChange.trigger(U)},m=(k,C)=>{const x=new Set,A=new Set;for(const J of k)wn(J)?x.add(J.id):Zt(J)&&A.add(J.id);const U=Qt(n.value,x,!0),V=Qt(o.value,A);if(e.multiSelectionActive){for(const J of x)U.push(Jt(J,C));for(const J of A)V.push(Jt(J,C))}U.length&&e.hooks.nodesChange.trigger(U),V.length&&e.hooks.edgesChange.trigger(V)},h=k=>{if(e.multiSelectionActive){const C=k.map(x=>Jt(x.id,!0));e.hooks.nodesChange.trigger(C);return}e.hooks.nodesChange.trigger(Qt(n.value,new Set(k.map(C=>C.id)),!0)),e.hooks.edgesChange.trigger(Qt(o.value))},y=k=>{if(e.multiSelectionActive){const C=k.map(x=>Jt(x.id,!0));e.hooks.edgesChange.trigger(C);return}e.hooks.edgesChange.trigger(Qt(o.value,new Set(k.map(C=>C.id)))),e.hooks.nodesChange.trigger(Qt(n.value,new Set,!0))},g=k=>{m(k,!0)},_=k=>{const x=(k||e.nodes).map(A=>(A.selected=!1,Jt(A.id,!1)));e.hooks.nodesChange.trigger(x)},w=k=>{const x=(k||e.edges).map(A=>(A.selected=!1,Jt(A.id,!1)));e.hooks.edgesChange.trigger(x)},b=k=>{if(!k||!k.length)return m([],!1);const C=k.reduce((x,A)=>{const U=Jt(A.id,!1);return wn(A)?x.nodes.push(U):x.edges.push(U),x},{nodes:[],edges:[]});C.nodes.length&&e.hooks.nodesChange.trigger(C.nodes),C.edges.length&&e.hooks.edgesChange.trigger(C.edges)},v=k=>{var C;(C=e.d3Zoom)==null||C.scaleExtent([k,e.maxZoom]),e.minZoom=k},N=k=>{var C;(C=e.d3Zoom)==null||C.scaleExtent([e.minZoom,k]),e.maxZoom=k},E=k=>{var C;(C=e.d3Zoom)==null||C.translateExtent(k),e.translateExtent=k},S=k=>{e.nodeExtent=k,i()},P=k=>{var C;(C=e.d3Zoom)==null||C.clickDistance(k)},B=k=>{e.nodesDraggable=k,e.nodesConnectable=k,e.elementsSelectable=k},j=k=>{const C=k instanceof Function?k(e.nodes):k;!e.initialized&&!C.length||(e.nodes=$f(C,d,e.hooks.error.trigger))},G=k=>{const C=k instanceof Function?k(e.edges):k;if(!e.initialized&&!C.length)return;const x=Cl(C,e.isValidConnection,d,u,e.hooks.error.trigger,e.defaultEdgeOptions,e.nodes,e.edges);El(e.connectionLookup,o.value,x),e.edges=x},T=k=>{const C=k instanceof Function?k([...e.nodes,...e.edges]):k;!e.initialized&&!C.length||(j(C.filter(wn)),G(C.filter(Zt)))},Y=k=>{let C=k instanceof Function?k(e.nodes):k;C=Array.isArray(C)?C:[C];const x=$f(C,d,e.hooks.error.trigger),A=[];for(const U of x)A.push(Ef(U));A.length&&e.hooks.nodesChange.trigger(A)},I=k=>{let C=k instanceof Function?k(e.edges):k;C=Array.isArray(C)?C:[C];const x=Cl(C,e.isValidConnection,d,u,e.hooks.error.trigger,e.defaultEdgeOptions,e.nodes,e.edges),A=[];for(const U of x)A.push(Ef(U));A.length&&e.hooks.edgesChange.trigger(A)},M=(k,C=!0,x=!1)=>{const A=k instanceof Function?k(e.nodes):k,U=Array.isArray(A)?A:[A],V=[],J=[];function $(D){const pe=s(D);for(const le of pe)(!Ge(le.deletable)||le.deletable)&&J.push(Nf(le.id,le.source,le.target,le.sourceHandle,le.targetHandle))}function X(D){const pe=[];for(const le of e.nodes)le.parentNode===D&&pe.push(le);if(pe.length){for(const le of pe)V.push(Cf(le.id));C&&$(pe);for(const le of pe)X(le.id)}}for(const D of U){const pe=typeof D=="string"?d(D):D;pe&&(Ge(pe.deletable)&&!pe.deletable||(V.push(Cf(pe.id)),C&&$([pe]),x&&X(pe.id)))}J.length&&e.hooks.edgesChange.trigger(J),V.length&&e.hooks.nodesChange.trigger(V)},R=k=>{const C=k instanceof Function?k(e.edges):k,x=Array.isArray(C)?C:[C],A=[];for(const U of x){const V=typeof U=="string"?u(U):U;V&&(Ge(V.deletable)&&!V.deletable||A.push(Nf(typeof U=="string"?U:U.id,V.source,V.target,V.sourceHandle,V.targetHandle)))}e.hooks.edgesChange.trigger(A)},te=(k,C,x=!0)=>{const A=u(k.id);if(!A)return!1;const U=e.edges.indexOf(A),V=Lx(k,C,A,x,e.hooks.error.trigger);if(V){const[J]=Cl([V],e.isValidConnection,d,u,e.hooks.error.trigger,e.defaultEdgeOptions,e.nodes,e.edges);return e.edges=e.edges.map(($,X)=>X===U?J:$),El(e.connectionLookup,o.value,[J]),J}return!1},z=(k,C,x={replace:!1})=>{const A=u(k);if(!A)return;const U=typeof C=="function"?C(A):C;A.data=x.replace?U:{...A.data,...U}},H=k=>kf(k,e.nodes),L=k=>{const C=kf(k,e.edges);return El(e.connectionLookup,o.value,C),C},F=(k,C,x={replace:!1})=>{const A=d(k);if(!A)return;const U=typeof C=="function"?C(A):C;x.replace?e.nodes.splice(e.nodes.indexOf(A),1,U):Object.assign(A,U)},Z=(k,C,x={replace:!1})=>{const A=d(k);if(!A)return;const U=typeof C=="function"?C(A):C;A.data=x.replace?U:{...A.data,...U}},Q=(k,C,x=!1)=>{x?e.connectionClickStartHandle=k:e.connectionStartHandle=k,e.connectionEndHandle=null,e.connectionStatus=null,C&&(e.connectionPosition=C)},W=(k,C=null,x=null)=>{e.connectionStartHandle&&(e.connectionPosition=k,e.connectionEndHandle=C,e.connectionStatus=x)},ie=(k,C)=>{e.connectionPosition={x:Number.NaN,y:Number.NaN},e.connectionEndHandle=null,e.connectionStatus=null,C?e.connectionClickStartHandle=null:e.connectionStartHandle=null},ae=k=>{const C=mx(k),x=C?null:Uo(k)?k:d(k.id);return!C&&!x?[null,null,C]:[C?k:ai(x),x,C]},me=(k,C=!0,x=e.nodes)=>{const[A,U,V]=ae(k);if(!A)return[];const J=[];for(const $ of x||e.nodes){if(!V&&($.id===U.id||!$.computedPosition))continue;const X=ai($),D=li(X,A);(C&&D>0||D>=Number(A.width)*Number(A.height))&&J.push($)}return J},ge=(k,C,x=!0)=>{const[A]=ae(k);if(!A)return!1;const U=li(A,C);return x&&U>0||U>=Number(A.width)*Number(A.height)},ne=k=>{const{viewport:C,dimensions:x,d3Zoom:A,d3Selection:U,translateExtent:V}=e;if(!A||!U||!k.x&&!k.y)return!1;const J=Wn.translate(C.x+k.x,C.y+k.y).scale(C.zoom),$=[[0,0],[x.width,x.height]],X=A.constrain()(J,$,V),D=e.viewport.x!==X.x||e.viewport.y!==X.y||e.viewport.zoom!==X.k;return A.transform(U,X),D},re=k=>{const C=k instanceof Function?k(e):k,x=["d3Zoom","d3Selection","d3ZoomHandler","viewportRef","vueFlowRef","dimensions","hooks"];Ge(C.defaultEdgeOptions)&&(e.defaultEdgeOptions=C.defaultEdgeOptions);const A=C.modelValue||C.nodes||C.edges?[]:void 0;A&&(C.modelValue&&A.push(...C.modelValue),C.nodes&&A.push(...C.nodes),C.edges&&A.push(...C.edges),T(A));const U=()=>{Ge(C.maxZoom)&&N(C.maxZoom),Ge(C.minZoom)&&v(C.minZoom),Ge(C.translateExtent)&&E(C.translateExtent)};for(const V of Object.keys(C)){const J=V,$=C[J];![...eA,...x].includes(J)&&Ge($)&&(e[J]=$)}qa(()=>e.d3Zoom).not.toBeNull().then(U),e.initialized||(e.initialized=!0)};return{updateNodePositions:f,updateNodeDimensions:p,setElements:T,setNodes:j,setEdges:G,addNodes:Y,addEdges:I,removeNodes:M,removeEdges:R,findNode:d,findEdge:u,updateEdge:te,updateEdgeData:z,updateNode:F,updateNodeData:Z,applyEdgeChanges:L,applyNodeChanges:H,addSelectedElements:g,addSelectedNodes:h,addSelectedEdges:y,setMinZoom:v,setMaxZoom:N,setTranslateExtent:E,setNodeExtent:S,setPaneClickDistance:P,removeSelectedElements:b,removeSelectedNodes:_,removeSelectedEdges:w,startConnection:Q,updateConnection:W,endConnection:ie,setInteractive:B,setState:re,getIntersectingNodes:me,getIncomers:a,getOutgoers:l,getConnectedEdges:s,getHandleConnections:c,isNodeIntersecting:ge,panBy:ne,fitView:k=>r.value.fitView(k),zoomIn:k=>r.value.zoomIn(k),zoomOut:k=>r.value.zoomOut(k),zoomTo:(k,C)=>r.value.zoomTo(k,C),setViewport:(k,C)=>r.value.setViewport(k,C),setTransform:(k,C)=>r.value.setTransform(k,C),getViewport:()=>r.value.getViewport(),getTransform:()=>r.value.getTransform(),setCenter:(k,C,x)=>r.value.setCenter(k,C,x),fitBounds:(k,C)=>r.value.fitBounds(k,C),project:k=>r.value.project(k),screenToFlowCoordinate:k=>r.value.screenToFlowCoordinate(k),flowToScreenCoordinate:k=>r.value.flowToScreenCoordinate(k),toObject:()=>{const k=[],C=[];for(const x of e.nodes){const{computedPosition:A,handleBounds:U,selected:V,dimensions:J,isParent:$,resizing:X,dragging:D,events:pe,...le}=x;k.push(le)}for(const x of e.edges){const{selected:A,sourceNode:U,targetNode:V,events:J,...$}=x;C.push($)}return JSON.parse(JSON.stringify({nodes:k,edges:C,position:[e.viewport.x,e.viewport.y],zoom:e.viewport.zoom,viewport:e.viewport}))},fromObject:k=>new Promise(C=>{const{nodes:x,edges:A,position:U,zoom:V,viewport:J}=k;if(x&&j(x),A&&G(A),J!=null&&J.x&&(J!=null&&J.y)||U){const $=(J==null?void 0:J.x)||U[0],X=(J==null?void 0:J.y)||U[1],D=(J==null?void 0:J.zoom)||V||e.viewport.zoom;return qa(()=>r.value.viewportInitialized).toBe(!0).then(()=>{r.value.setViewport({x:$,y:X,zoom:D}).then(()=>{C(!0)})})}else C(!0)}),updateNodeInternals:i,viewportHelper:r,$reset:()=>{const k=jf();if(e.edges=[],e.nodes=[],e.d3Zoom&&e.d3Selection){const C=Wn.translate(k.defaultViewport.x??0,k.defaultViewport.y??0).scale(bn(k.defaultViewport.zoom??1,k.minZoom,k.maxZoom)),x=e.viewportRef.getBoundingClientRect(),A=[[0,0],[x.width,x.height]],U=e.d3Zoom.constrain()(C,A,k.translateExtent);e.d3Zoom.transform(e.d3Selection,U)}re(k)},$destroy:()=>{}}}const nA=["data-id","data-handleid","data-nodeid","data-handlepos"],oA={name:"Handle",compatConfig:{MODE:3}},tn=t.defineComponent({...oA,props:{id:{default:null},type:{},position:{default:()=>ye.Top},isValidConnection:{type:Function},connectable:{type:[Boolean,Number,String,Function],default:void 0},connectableStart:{type:Boolean,default:!0},connectableEnd:{type:Boolean,default:!0}},setup(e,{expose:n}){const o=t.createPropsRestProxy(e,["position","connectable","connectableStart","connectableEnd","id"]),r=t.toRef(()=>o.type??"source"),i=t.toRef(()=>o.isValidConnection??null),{id:a,connectionStartHandle:l,connectionClickStartHandle:s,connectionEndHandle:c,vueFlowRef:d,nodesConnectable:u,noDragClassName:f,noPanClassName:p}=Oe(),{id:m,node:h,nodeEl:y,connectedEdges:g}=Uf(),_=t.ref(),w=t.toRef(()=>typeof e.connectableStart<"u"?e.connectableStart:!0),b=t.toRef(()=>typeof e.connectableEnd<"u"?e.connectableEnd:!0),v=t.toRef(()=>{var G,T,Y,I,M,R;return((G=l.value)==null?void 0:G.nodeId)===m&&((T=l.value)==null?void 0:T.id)===e.id&&((Y=l.value)==null?void 0:Y.type)===r.value||((I=c.value)==null?void 0:I.nodeId)===m&&((M=c.value)==null?void 0:M.id)===e.id&&((R=c.value)==null?void 0:R.type)===r.value}),N=t.toRef(()=>{var G,T,Y;return((G=s.value)==null?void 0:G.nodeId)===m&&((T=s.value)==null?void 0:T.id)===e.id&&((Y=s.value)==null?void 0:Y.type)===r.value}),{handlePointerDown:E,handleClick:S}=Ff({nodeId:m,handleId:e.id,isValidConnection:i,type:r}),P=t.computed(()=>typeof e.connectable=="string"&&e.connectable==="single"?!g.value.some(G=>{const T=G[`${r.value}Handle`];return G[r.value]!==m?!1:T?T===e.id:!0}):typeof e.connectable=="number"?g.value.filter(G=>{const T=G[`${r.value}Handle`];return G[r.value]!==m?!1:T?T===e.id:!0}).length<e.connectable:typeof e.connectable=="function"?e.connectable(h,g.value):Ge(e.connectable)?e.connectable:u.value);t.onMounted(()=>{var G;if(!h.dimensions.width||!h.dimensions.height)return;const T=(G=h.handleBounds[r.value])==null?void 0:G.find(H=>H.id===e.id);if(!d.value||T)return;const Y=d.value.querySelector(".vue-flow__transformationpane");if(!y.value||!_.value||!Y||!e.id)return;const I=y.value.getBoundingClientRect(),M=_.value.getBoundingClientRect(),R=window.getComputedStyle(Y),{m22:te}=new window.DOMMatrixReadOnly(R.transform),z={id:e.id,position:e.position,x:(M.left-I.left)/te,y:(M.top-I.top)/te,type:r.value,nodeId:m,...si(_.value)};h.handleBounds[r.value]=[...h.handleBounds[r.value]??[],z]});function B(G){const T=_l(G);P.value&&w.value&&(T&&G.button===0||!T)&&E(G)}function j(G){!m||!s.value&&!w.value||P.value&&S(G)}return n({handleClick:S,handlePointerDown:E,onClick:j,onPointerDown:B}),(G,T)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"handle",ref:_,"data-id":`${t.unref(a)}-${t.unref(m)}-${e.id}-${r.value}`,"data-handleid":e.id,"data-nodeid":t.unref(m),"data-handlepos":G.position,class:t.normalizeClass(["vue-flow__handle",[`vue-flow__handle-${G.position}`,`vue-flow__handle-${e.id}`,t.unref(f),t.unref(p),r.value,{connectable:P.value,connecting:N.value,connectablestart:w.value,connectableend:b.value,connectionindicator:P.value&&(w.value&&!v.value||b.value&&v.value)}]]),onMousedown:B,onTouchstartPassive:B,onClick:j},[t.renderSlot(G.$slots,"default",{id:G.id})],42,nA))}}),gi=function({sourcePosition:e=ye.Bottom,targetPosition:n=ye.Top,label:o,connectable:r=!0,isValidTargetPos:i,isValidSourcePos:a,data:l}){const s=l.label??o;return[t.h(tn,{type:"target",position:n,connectable:r,isValidConnection:i}),typeof s!="string"&&s?t.h(s):t.h(t.Fragment,[s]),t.h(tn,{type:"source",position:e,connectable:r,isValidConnection:a})]};gi.props=["sourcePosition","targetPosition","label","isValidTargetPos","isValidSourcePos","connectable","data"],gi.inheritAttrs=!1,gi.compatConfig={MODE:3};const rA=gi,hi=function({targetPosition:e=ye.Top,label:n,connectable:o=!0,isValidTargetPos:r,data:i}){const a=i.label??n;return[t.h(tn,{type:"target",position:e,connectable:o,isValidConnection:r}),typeof a!="string"&&a?t.h(a):t.h(t.Fragment,[a])]};hi.props=["targetPosition","label","isValidTargetPos","connectable","data"],hi.inheritAttrs=!1,hi.compatConfig={MODE:3};const iA=hi,yi=function({sourcePosition:e=ye.Bottom,label:n,connectable:o=!0,isValidSourcePos:r,data:i}){const a=i.label??n;return[typeof a!="string"&&a?t.h(a):t.h(t.Fragment,[a]),t.h(tn,{type:"source",position:e,connectable:o,isValidConnection:r})]};yi.props=["sourcePosition","label","isValidSourcePos","connectable","data"],yi.inheritAttrs=!1,yi.compatConfig={MODE:3};const aA=yi,lA=["transform"],sA=["width","height","x","y","rx","ry"],cA=["y"],dA={name:"EdgeText",compatConfig:{MODE:3}},uA=t.defineComponent({...dA,props:{x:{},y:{},label:{},labelStyle:{default:()=>({})},labelShowBg:{type:Boolean,default:!0},labelBgStyle:{default:()=>({})},labelBgPadding:{default:()=>[2,4]},labelBgBorderRadius:{default:2}},setup(e){const n=t.ref({x:0,y:0,width:0,height:0}),o=t.ref(null),r=t.computed(()=>`translate(${e.x-n.value.width/2} ${e.y-n.value.height/2})`);t.onMounted(i),t.watch([()=>e.x,()=>e.y,o,()=>e.label],i);function i(){if(!o.value)return;const a=o.value.getBBox();(a.width!==n.value.width||a.height!==n.value.height)&&(n.value=a)}return(a,l)=>(t.openBlock(),t.createElementBlock("g",{transform:r.value,class:"vue-flow__edge-textwrapper"},[a.labelShowBg?(t.openBlock(),t.createElementBlock("rect",{key:0,class:"vue-flow__edge-textbg",width:`${n.value.width+2*a.labelBgPadding[0]}px`,height:`${n.value.height+2*a.labelBgPadding[1]}px`,x:-a.labelBgPadding[0],y:-a.labelBgPadding[1],style:t.normalizeStyle(a.labelBgStyle),rx:a.labelBgBorderRadius,ry:a.labelBgBorderRadius},null,12,sA)):t.createCommentVNode("",!0),t.createElementVNode("text",t.mergeProps(a.$attrs,{ref_key:"el",ref:o,class:"vue-flow__edge-text",y:n.value.height/2,dy:"0.3em",style:a.labelStyle}),[t.renderSlot(a.$slots,"default",{},()=>[typeof a.label!="string"?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(a.label),{key:0})):(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[t.createTextVNode(t.toDisplayString(a.label),1)],64))])],16,cA)],8,lA))}}),fA=["id","d","marker-end","marker-start"],pA=["d","stroke-width"],mA={name:"BaseEdge",inheritAttrs:!1,compatConfig:{MODE:3}},_i=t.defineComponent({...mA,props:{id:{},labelX:{},labelY:{},path:{},label:{},markerStart:{},markerEnd:{},interactionWidth:{default:20},labelStyle:{},labelShowBg:{type:Boolean},labelBgStyle:{},labelBgPadding:{},labelBgBorderRadius:{}},setup(e,{expose:n}){const o=t.ref(null),r=t.ref(null),i=t.ref(null),a=t.useAttrs();return n({pathEl:o,interactionEl:r,labelEl:i}),(l,s)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[t.createElementVNode("path",t.mergeProps(t.unref(a),{id:l.id,ref_key:"pathEl",ref:o,d:l.path,class:"vue-flow__edge-path","marker-end":l.markerEnd,"marker-start":l.markerStart}),null,16,fA),l.interactionWidth?(t.openBlock(),t.createElementBlock("path",{key:0,ref_key:"interactionEl",ref:r,fill:"none",d:l.path,"stroke-width":l.interactionWidth,"stroke-opacity":0,class:"vue-flow__edge-interaction"},null,8,pA)):t.createCommentVNode("",!0),l.label&&l.labelX&&l.labelY?(t.openBlock(),t.createBlock(uA,{key:1,ref_key:"labelEl",ref:i,x:l.labelX,y:l.labelY,label:l.label,"label-show-bg":l.labelShowBg,"label-bg-style":l.labelBgStyle,"label-bg-padding":l.labelBgPadding,"label-bg-border-radius":l.labelBgBorderRadius,"label-style":l.labelStyle},null,8,["x","y","label","label-show-bg","label-bg-style","label-bg-padding","label-bg-border-radius","label-style"])):t.createCommentVNode("",!0)],64))}});function Gf({sourceX:e,sourceY:n,targetX:o,targetY:r}){const i=Math.abs(o-e)/2,a=o<e?o+i:o-i,l=Math.abs(r-n)/2,s=r<n?r+l:r-l;return[a,s,i,l]}function qf({sourceX:e,sourceY:n,targetX:o,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:l,targetControlY:s}){const c=e*.125+i*.375+l*.375+o*.125,d=n*.125+a*.375+s*.375+r*.125,u=Math.abs(c-e),f=Math.abs(d-n);return[c,d,u,f]}function bi(e,n){return e>=0?.5*e:n*25*Math.sqrt(-e)}function zf({pos:e,x1:n,y1:o,x2:r,y2:i,c:a}){let l,s;switch(e){case ye.Left:l=n-bi(n-r,a),s=o;break;case ye.Right:l=n+bi(r-n,a),s=o;break;case ye.Top:l=n,s=o-bi(o-i,a);break;case ye.Bottom:l=n,s=o+bi(i-o,a);break}return[l,s]}function Hf(e){const{sourceX:n,sourceY:o,sourcePosition:r=ye.Bottom,targetX:i,targetY:a,targetPosition:l=ye.Top,curvature:s=.25}=e,[c,d]=zf({pos:r,x1:n,y1:o,x2:i,y2:a,c:s}),[u,f]=zf({pos:l,x1:i,y1:a,x2:n,y2:o,c:s}),[p,m,h,y]=qf({sourceX:n,sourceY:o,targetX:i,targetY:a,sourceControlX:c,sourceControlY:d,targetControlX:u,targetControlY:f});return[`M${n},${o} C${c},${d} ${u},${f} ${i},${a}`,p,m,h,y]}function Yf({pos:e,x1:n,y1:o,x2:r,y2:i}){let a,l;switch(e){case ye.Left:case ye.Right:a=.5*(n+r),l=o;break;case ye.Top:case ye.Bottom:a=n,l=.5*(o+i);break}return[a,l]}function Wf(e){const{sourceX:n,sourceY:o,sourcePosition:r=ye.Bottom,targetX:i,targetY:a,targetPosition:l=ye.Top}=e,[s,c]=Yf({pos:r,x1:n,y1:o,x2:i,y2:a}),[d,u]=Yf({pos:l,x1:i,y1:a,x2:n,y2:o}),[f,p,m,h]=qf({sourceX:n,sourceY:o,targetX:i,targetY:a,sourceControlX:s,sourceControlY:c,targetControlX:d,targetControlY:u});return[`M${n},${o} C${s},${c} ${d},${u} ${i},${a}`,f,p,m,h]}const Xf={[ye.Left]:{x:-1,y:0},[ye.Right]:{x:1,y:0},[ye.Top]:{x:0,y:-1},[ye.Bottom]:{x:0,y:1}};function gA({source:e,sourcePosition:n=ye.Bottom,target:o}){return n===ye.Left||n===ye.Right?e.x<o.x?{x:1,y:0}:{x:-1,y:0}:e.y<o.y?{x:0,y:1}:{x:0,y:-1}}function Zf(e,n){return Math.sqrt((n.x-e.x)**2+(n.y-e.y)**2)}function hA({source:e,sourcePosition:n=ye.Bottom,target:o,targetPosition:r=ye.Top,center:i,offset:a}){const l=Xf[n],s=Xf[r],c={x:e.x+l.x*a,y:e.y+l.y*a},d={x:o.x+s.x*a,y:o.y+s.y*a},u=gA({source:c,sourcePosition:n,target:d}),f=u.x!==0?"x":"y",p=u[f];let m,h,y;const g={x:0,y:0},_={x:0,y:0},[w,b,v,N]=Gf({sourceX:e.x,sourceY:e.y,targetX:o.x,targetY:o.y});if(l[f]*s[f]===-1){h=i.x??w,y=i.y??b;const S=[{x:h,y:c.y},{x:h,y:d.y}],P=[{x:c.x,y},{x:d.x,y}];l[f]===p?m=f==="x"?S:P:m=f==="x"?P:S}else{const S=[{x:c.x,y:d.y}],P=[{x:d.x,y:c.y}];if(f==="x"?m=l.x===p?P:S:m=l.y===p?S:P,n===r){const Y=Math.abs(e[f]-o[f]);if(Y<=a){const I=Math.min(a-1,a-Y);l[f]===p?g[f]=(c[f]>e[f]?-1:1)*I:_[f]=(d[f]>o[f]?-1:1)*I}}if(n!==r){const Y=f==="x"?"y":"x",I=l[f]===s[Y],M=c[Y]>d[Y],R=c[Y]<d[Y];(l[f]===1&&(!I&&M||I&&R)||l[f]!==1&&(!I&&R||I&&M))&&(m=f==="x"?S:P)}const B={x:c.x+g.x,y:c.y+g.y},j={x:d.x+_.x,y:d.y+_.y},G=Math.max(Math.abs(B.x-m[0].x),Math.abs(j.x-m[0].x)),T=Math.max(Math.abs(B.y-m[0].y),Math.abs(j.y-m[0].y));G>=T?(h=(B.x+j.x)/2,y=m[0].y):(h=m[0].x,y=(B.y+j.y)/2)}return[[e,{x:c.x+g.x,y:c.y+g.y},...m,{x:d.x+_.x,y:d.y+_.y},o],h,y,v,N]}function yA(e,n,o,r){const i=Math.min(Zf(e,n)/2,Zf(n,o)/2,r),{x:a,y:l}=n;if(e.x===a&&a===o.x||e.y===l&&l===o.y)return`L${a} ${l}`;if(e.y===l){const d=e.x<o.x?-1:1,u=e.y<o.y?1:-1;return`L ${a+i*d},${l}Q ${a},${l} ${a},${l+i*u}`}const s=e.x<o.x?1:-1,c=e.y<o.y?-1:1;return`L ${a},${l+i*c}Q ${a},${l} ${a+i*s},${l}`}function Sl(e){const{sourceX:n,sourceY:o,sourcePosition:r=ye.Bottom,targetX:i,targetY:a,targetPosition:l=ye.Top,borderRadius:s=5,centerX:c,centerY:d,offset:u=20}=e,[f,p,m,h,y]=hA({source:{x:n,y:o},sourcePosition:r,target:{x:i,y:a},targetPosition:l,center:{x:c,y:d},offset:u});return[f.reduce((_,w,b)=>{let v;return b>0&&b<f.length-1?v=yA(f[b-1],w,f[b+1],s):v=`${b===0?"M":"L"}${w.x} ${w.y}`,_+=v,_},""),p,m,h,y]}function _A(e){const{sourceX:n,sourceY:o,targetX:r,targetY:i}=e,[a,l,s,c]=Gf({sourceX:n,sourceY:o,targetX:r,targetY:i});return[`M ${n},${o}L ${r},${i}`,a,l,s,c]}const bA=t.defineComponent({name:"StraightEdge",props:["label","labelStyle","labelShowBg","labelBgStyle","labelBgPadding","labelBgBorderRadius","sourceY","sourceX","targetX","targetY","markerEnd","markerStart","interactionWidth"],compatConfig:{MODE:3},setup(e,{attrs:n}){return()=>{const[o,r,i]=_A(e);return t.h(_i,{path:o,labelX:r,labelY:i,...n,...e})}}}),Jf=t.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(e,{attrs:n}){return()=>{const[o,r,i]=Sl({...e,sourcePosition:e.sourcePosition??ye.Bottom,targetPosition:e.targetPosition??ye.Top});return t.h(_i,{path:o,labelX:r,labelY:i,...n,...e})}}}),wA=t.defineComponent({name:"StepEdge",props:["sourcePosition","targetPosition","label","labelStyle","labelShowBg","labelBgStyle","labelBgPadding","labelBgBorderRadius","sourceY","sourceX","targetX","targetY","markerEnd","markerStart","interactionWidth"],setup(e,{attrs:n}){return()=>t.h(Jf,{...e,...n,borderRadius:0})}}),kA=t.defineComponent({name:"BezierEdge",props:["sourcePosition","targetPosition","label","labelStyle","labelShowBg","labelBgStyle","labelBgPadding","labelBgBorderRadius","sourceY","sourceX","targetX","targetY","curvature","markerEnd","markerStart","interactionWidth"],compatConfig:{MODE:3},setup(e,{attrs:n}){return()=>{const[o,r,i]=Hf({...e,sourcePosition:e.sourcePosition??ye.Bottom,targetPosition:e.targetPosition??ye.Top});return t.h(_i,{path:o,labelX:r,labelY:i,...n,...e})}}}),EA=t.defineComponent({name:"SimpleBezierEdge",props:["sourcePosition","targetPosition","label","labelStyle","labelShowBg","labelBgStyle","labelBgPadding","labelBgBorderRadius","sourceY","sourceX","targetX","targetY","markerEnd","markerStart","interactionWidth"],compatConfig:{MODE:3},setup(e,{attrs:n}){return()=>{const[o,r,i]=Wf({...e,sourcePosition:e.sourcePosition??ye.Bottom,targetPosition:e.targetPosition??ye.Top});return t.h(_i,{path:o,labelX:r,labelY:i,...n,...e})}}}),CA={input:aA,default:rA,output:iA},NA={default:kA,straight:bA,step:wA,smoothstep:Jf,simplebezier:EA};function vA(e,n,o){const r=t.computed(()=>y=>n.value.get(y)),i=t.computed(()=>y=>o.value.get(y)),a=t.computed(()=>{const y={...NA,...e.edgeTypes},g=Object.keys(y);for(const _ of e.edges)_.type&&!g.includes(_.type)&&(y[_.type]=_.type);return y}),l=t.computed(()=>{const y={...CA,...e.nodeTypes},g=Object.keys(y);for(const _ of e.nodes)_.type&&!g.includes(_.type)&&(y[_.type]=_.type);return y}),s=t.computed(()=>e.onlyRenderVisibleElements?gf(e.nodes,{x:0,y:0,width:e.dimensions.width,height:e.dimensions.height},e.viewport,!0):e.nodes),c=t.computed(()=>{if(e.onlyRenderVisibleElements){const y=[];for(const g of e.edges){const _=n.value.get(g.source),w=n.value.get(g.target);Sx({sourcePos:_.computedPosition||{x:0,y:0},targetPos:w.computedPosition||{x:0,y:0},sourceWidth:_.dimensions.width,sourceHeight:_.dimensions.height,targetWidth:w.dimensions.width,targetHeight:w.dimensions.height,width:e.dimensions.width,height:e.dimensions.height,viewport:e.viewport})&&y.push(g)}return y}return e.edges}),d=t.computed(()=>[...s.value,...c.value]),u=t.computed(()=>{const y=[];for(const g of e.nodes)g.selected&&y.push(g);return y}),f=t.computed(()=>{const y=[];for(const g of e.edges)g.selected&&y.push(g);return y}),p=t.computed(()=>[...u.value,...f.value]),m=t.computed(()=>{const y=[];for(const g of e.nodes)g.dimensions.width&&g.dimensions.height&&g.handleBounds!==void 0&&y.push(g);return y}),h=t.computed(()=>s.value.length>0&&m.value.length===s.value.length);return{getNode:r,getEdge:i,getElements:d,getEdgeTypes:a,getNodeTypes:l,getEdges:c,getNodes:s,getSelectedElements:p,getSelectedNodes:u,getSelectedEdges:f,getNodesInitialized:m,areNodesInitialized:h}}class kn{constructor(){this.currentId=0,this.flows=new Map}static getInstance(){var n;const o=(n=t.getCurrentInstance())==null?void 0:n.appContext.app,r=(o==null?void 0:o.config.globalProperties.$vueFlowStorage)??kn.instance;return kn.instance=r??new kn,o&&(o.config.globalProperties.$vueFlowStorage=kn.instance),kn.instance}set(n,o){return this.flows.set(n,o)}get(n){return this.flows.get(n)}remove(n){return this.flows.delete(n)}create(n,o){const r=jf(),i=t.reactive(r),a={};for(const[p,m]of Object.entries(i.hooks)){const h=`on${p.charAt(0).toUpperCase()+p.slice(1)}`;a[h]=m.on}const l={};for(const[p,m]of Object.entries(i.hooks))l[p]=m.trigger;const s=t.computed(()=>{const p=new Map;for(const m of i.nodes)p.set(m.id,m);return p}),c=t.computed(()=>{const p=new Map;for(const m of i.edges)p.set(m.id,m);return p}),d=vA(i,s,c),u=tA(i,s,c);u.setState({...i,...o});const f={...a,...d,...u,...CN(i),nodeLookup:s,edgeLookup:c,emits:l,id:n,vueFlowVersion:"1.45.0",$destroy:()=>{this.remove(n)}};return this.set(n,f),f}getId(){return`vue-flow-${this.currentId++}`}}function Oe(e){const n=kn.getInstance(),o=t.getCurrentScope(),r=typeof e=="object",i=r?e:{id:e},a=i.id,l=a??(o==null?void 0:o.vueFlowId);let s;if(o){const c=t.inject(Rf,null);typeof c<"u"&&c!==null&&(!l||c.id===l)&&(s=c)}if(s||l&&(s=n.get(l)),!s||l&&s.id!==l){const c=a??n.getId(),d=n.create(c,i);s=d,(o??t.effectScope(!0)).run(()=>{t.watch(d.applyDefault,(f,p,m)=>{const h=g=>{d.applyNodeChanges(g)},y=g=>{d.applyEdgeChanges(g)};f?(d.onNodesChange(h),d.onEdgesChange(y)):(d.hooks.value.nodesChange.off(h),d.hooks.value.edgesChange.off(y)),m(()=>{d.hooks.value.nodesChange.off(h),d.hooks.value.edgesChange.off(y)})},{immediate:!0}),Dr(()=>{if(s){const f=n.get(s.id);f?f.$destroy():fi(`No store instance found for id ${s.id} in storage.`)}})})}else r&&s.setState(i);if(o&&(t.provide(Rf,s),o.vueFlowId=s.id),r){const c=t.getCurrentInstance();(c==null?void 0:c.type.name)!=="VueFlow"&&s.emits.error(new We(je.USEVUEFLOW_OPTIONS))}return s}function SA(e){const{emits:n,dimensions:o}=Oe();let r;t.onMounted(()=>{const i=e.value,a=()=>{if(!i)return;const l=si(i);(l.width===0||l.height===0)&&n.error(new We(je.MISSING_VIEWPORT_DIMENSIONS)),o.value={width:l.width||500,height:l.height||500}};a(),window.addEventListener("resize",a),i&&(r=new ResizeObserver(()=>a()),r.observe(i)),t.onBeforeUnmount(()=>{window.removeEventListener("resize",a),r&&i&&r.unobserve(i)})})}const xA={name:"UserSelection",compatConfig:{MODE:3}},AA=t.defineComponent({...xA,props:{userSelectionRect:{}},setup(e){return(n,o)=>(t.openBlock(),t.createElementBlock("div",{class:"vue-flow__selection vue-flow__container",style:t.normalizeStyle({width:`${n.userSelectionRect.width}px`,height:`${n.userSelectionRect.height}px`,transform:`translate(${n.userSelectionRect.x}px, ${n.userSelectionRect.y}px)`})},null,4))}}),IA=["tabIndex"],PA={name:"NodesSelection",compatConfig:{MODE:3}},TA=t.defineComponent({...PA,setup(e){const{emits:n,viewport:o,getSelectedNodes:r,noPanClassName:i,disableKeyboardA11y:a,userSelectionActive:l}=Oe(),s=Kf(),c=t.ref(null),d=Lf({el:c,onStart(h){n.selectionDragStart(h)},onDrag(h){n.selectionDrag(h)},onStop(h){n.selectionDragStop(h)}});t.onMounted(()=>{var h;a.value||(h=c.value)==null||h.focus({preventScroll:!0})});const u=t.computed(()=>mf(r.value)),f=t.computed(()=>({width:`${u.value.width}px`,height:`${u.value.height}px`,top:`${u.value.y}px`,left:`${u.value.x}px`}));function p(h){n.selectionContextMenu({event:h,nodes:r.value})}function m(h){a||Xn[h.key]&&(h.preventDefault(),s({x:Xn[h.key].x,y:Xn[h.key].y},h.shiftKey))}return(h,y)=>!t.unref(l)&&u.value.width&&u.value.height?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["vue-flow__nodesselection vue-flow__container",t.unref(i)]),style:t.normalizeStyle({transform:`translate(${t.unref(o).x}px,${t.unref(o).y}px) scale(${t.unref(o).zoom})`})},[t.createElementVNode("div",{ref_key:"el",ref:c,class:t.normalizeClass([{dragging:t.unref(d)},"vue-flow__nodesselection-rect"]),style:t.normalizeStyle(f.value),tabIndex:t.unref(a)?void 0:-1,onContextmenu:p,onKeydown:m},null,46,IA)],6)):t.createCommentVNode("",!0)}});function OA(e,n){return{x:e.clientX-n.left,y:e.clientY-n.top}}const $A={name:"Pane",compatConfig:{MODE:3}},BA=t.defineComponent({...$A,props:{isSelecting:{type:Boolean},selectionKeyPressed:{type:Boolean}},setup(e){const{vueFlowRef:n,nodes:o,viewport:r,emits:i,userSelectionActive:a,removeSelectedElements:l,userSelectionRect:s,elementsSelectable:c,nodesSelectionActive:d,getSelectedEdges:u,getSelectedNodes:f,removeNodes:p,removeEdges:m,selectionMode:h,deleteKeyCode:y,multiSelectionKeyCode:g,multiSelectionActive:_,edgeLookup:w,nodeLookup:b,connectionLookup:v,defaultEdgeOptions:N,connectionStartHandle:E}=Oe(),S=t.ref(null),P=t.ref(new Set),B=t.ref(new Set),j=t.ref(),G=t.toRef(()=>c.value&&(e.isSelecting||a.value)),T=t.toRef(()=>E.value!==null);let Y=!1,I=!1;const M=Fo(y,{actInsideInputWithModifier:!1}),R=Fo(g);t.watch(M,W=>{W&&(p(f.value),m(u.value),d.value=!1)}),t.watch(R,W=>{_.value=W});function te(W,ie){return ae=>{ae.target===ie&&(W==null||W(ae))}}function z(W){if(Y||T.value){Y=!1;return}i.paneClick(W),l(),d.value=!1}function H(W){W.preventDefault(),W.stopPropagation(),i.paneContextMenu(W)}function L(W){i.paneScroll(W)}function F(W){var ie,ae,me;if(j.value=(ie=n.value)==null?void 0:ie.getBoundingClientRect(),!c.value||!e.isSelecting||W.button!==0||W.target!==S.value||!j.value)return;(me=(ae=W.target)==null?void 0:ae.setPointerCapture)==null||me.call(ae,W.pointerId);const{x:ge,y:ne}=OA(W,j.value);I=!0,Y=!1,l(),s.value={width:0,height:0,startX:ge,startY:ne,x:ge,y:ne},i.selectionStart(W)}function Z(W){var ie;if(!j.value||!s.value)return;Y=!0;const{x:ae,y:me}=Tt(W,j.value),{startX:ge=0,startY:ne=0}=s.value,re={startX:ge,startY:ne,x:ae<ge?ae:ge,y:me<ne?me:ne,width:Math.abs(ae-ge),height:Math.abs(me-ne)},q=P.value,ee=B.value;P.value=new Set(gf(o.value,re,r.value,h.value===fl.Partial,!0).map(k=>k.id)),B.value=new Set;const O=((ie=N.value)==null?void 0:ie.selectable)??!0;for(const k of P.value){const C=v.value.get(k);if(C)for(const{edgeId:x}of C.values()){const A=w.value.get(x);A&&(A.selectable??O)&&B.value.add(x)}}if(!Vf(q,P.value)){const k=Qt(b.value,P.value,!0);i.nodesChange(k)}if(!Vf(ee,B.value)){const k=Qt(w.value,B.value);i.edgesChange(k)}s.value=re,a.value=!0,d.value=!1}function Q(W){var ie;W.button!==0||!I||((ie=W.target)==null||ie.releasePointerCapture(W.pointerId),!a.value&&s.value&&W.target===S.value&&z(W),a.value=!1,s.value=null,d.value=P.value.size>0,i.selectionEnd(W),e.selectionKeyPressed&&(Y=!1),I=!1)}return(W,ie)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"container",ref:S,class:t.normalizeClass(["vue-flow__pane vue-flow__container",{selection:W.isSelecting}]),onClick:ie[0]||(ie[0]=ae=>G.value?void 0:te(z,S.value)(ae)),onContextmenu:ie[1]||(ie[1]=ae=>te(H,S.value)(ae)),onWheelPassive:ie[2]||(ie[2]=ae=>te(L,S.value)(ae)),onPointerenter:ie[3]||(ie[3]=ae=>G.value?void 0:t.unref(i).paneMouseEnter(ae)),onPointerdown:ie[4]||(ie[4]=ae=>G.value?F(ae):t.unref(i).paneMouseMove(ae)),onPointermove:ie[5]||(ie[5]=ae=>G.value?Z(ae):t.unref(i).paneMouseMove(ae)),onPointerup:ie[6]||(ie[6]=ae=>G.value?Q(ae):void 0),onPointerleave:ie[7]||(ie[7]=ae=>t.unref(i).paneMouseLeave(ae))},[t.renderSlot(W.$slots,"default"),t.unref(a)&&t.unref(s)?(t.openBlock(),t.createBlock(AA,{key:0,"user-selection-rect":t.unref(s)},null,8,["user-selection-rect"])):t.createCommentVNode("",!0),t.unref(d)&&t.unref(f).length?(t.openBlock(),t.createBlock(TA,{key:1})):t.createCommentVNode("",!0)],34))}}),VA={name:"Transform",compatConfig:{MODE:3}},RA=t.defineComponent({...VA,setup(e){const{viewport:n,fitViewOnInit:o,fitViewOnInitDone:r}=Oe(),i=t.computed(()=>o.value?!r.value:!1),a=t.computed(()=>`translate(${n.value.x}px,${n.value.y}px) scale(${n.value.zoom})`);return(l,s)=>(t.openBlock(),t.createElementBlock("div",{class:"vue-flow__transformationpane vue-flow__container",style:t.normalizeStyle({transform:a.value,opacity:i.value?0:void 0})},[t.renderSlot(l.$slots,"default")],4))}}),DA={name:"Viewport",compatConfig:{MODE:3}},MA=t.defineComponent({...DA,setup(e){const{minZoom:n,maxZoom:o,defaultViewport:r,translateExtent:i,zoomActivationKeyCode:a,selectionKeyCode:l,panActivationKeyCode:s,panOnScroll:c,panOnScrollMode:d,panOnScrollSpeed:u,panOnDrag:f,zoomOnDoubleClick:p,zoomOnPinch:m,zoomOnScroll:h,preventScrolling:y,noWheelClassName:g,noPanClassName:_,emits:w,connectionStartHandle:b,userSelectionActive:v,paneDragging:N,d3Zoom:E,d3Selection:S,d3ZoomHandler:P,viewport:B,viewportRef:j,paneClickDistance:G}=Oe();SA(j);const T=t.shallowRef(!1),Y=t.shallowRef(!1);let I=null,M=!1,R=0,te={x:0,y:0,zoom:0};const z=Fo(s),H=Fo(l),L=Fo(a),F=t.toRef(()=>(!H.value||H.value&&l.value===!0)&&(z.value||f.value)),Z=t.toRef(()=>z.value||c.value),Q=t.toRef(()=>H.value||l.value===!0&&F.value!==!0);t.onMounted(()=>{if(!j.value){fi("Viewport element is missing");return}const ne=j.value,re=ne.getBoundingClientRect(),q=lx().clickDistance(G.value).scaleExtent([n.value,o.value]).translateExtent(i.value),ee=_t(ne).call(q),O=ee.on("wheel.zoom"),k=Wn.translate(r.value.x??0,r.value.y??0).scale(bn(r.value.zoom??1,n.value,o.value)),C=[[0,0],[re.width,re.height]],x=q.constrain()(k,C,i.value);q.transform(ee,x),q.wheelDelta(ie),E.value=q,S.value=ee,P.value=O,B.value={x:x.x,y:x.y,zoom:x.k},q.on("start",A=>{var U;if(!A.sourceEvent)return null;R=A.sourceEvent.button,T.value=!0;const V=me(A.transform);((U=A.sourceEvent)==null?void 0:U.type)==="mousedown"&&(N.value=!0),te=V,w.viewportChangeStart(V),w.moveStart({event:A,flowTransform:V})}),q.on("end",A=>{if(!A.sourceEvent)return null;if(T.value=!1,N.value=!1,W(F.value,R??0)&&!M&&w.paneContextMenu(A.sourceEvent),M=!1,ae(te,A.transform)){const U=me(A.transform);te=U,w.viewportChangeEnd(U),w.moveEnd({event:A,flowTransform:U})}}),q.filter(A=>{var U;const V=L.value||h.value,J=m.value&&A.ctrlKey,$=A.button;if($===1&&A.type==="mousedown"&&(ge(A,"vue-flow__node")||ge(A,"vue-flow__edge")))return!0;if(!F.value&&!V&&!Z.value&&!p.value&&!m.value||v.value||!p.value&&A.type==="dblclick"||ge(A,g.value)&&A.type==="wheel"||ge(A,_.value)&&(A.type!=="wheel"||Z.value&&A.type==="wheel"&&!L.value)||!m.value&&A.ctrlKey&&A.type==="wheel"||!V&&!Z.value&&!J&&A.type==="wheel")return!1;if(!m&&A.type==="touchstart"&&((U=A.touches)==null?void 0:U.length)>1)return A.preventDefault(),!1;if(!F.value&&(A.type==="mousedown"||A.type==="touchstart")||l.value===!0&&Array.isArray(f.value)&&f.value.includes(0)&&$===0||Array.isArray(f.value)&&!f.value.includes($)&&(A.type==="mousedown"||A.type==="touchstart"))return!1;const X=Array.isArray(f.value)&&f.value.includes($)||l.value===!0&&Array.isArray(f.value)&&!f.value.includes(0)||!$||$<=1;return(!A.ctrlKey||z.value||A.type==="wheel")&&X}),t.watch([v,F],()=>{v.value&&!T.value?q.on("zoom",null):v.value||q.on("zoom",A=>{B.value={x:A.transform.x,y:A.transform.y,zoom:A.transform.k};const U=me(A.transform);M=W(F.value,R??0),w.viewportChange(U),w.move({event:A,flowTransform:U})})},{immediate:!0}),t.watch([v,Z,d,L,m,y,g],()=>{Z.value&&!L.value&&!v.value?ee.on("wheel.zoom",A=>{if(ge(A,g.value))return!1;const U=L.value||h.value,V=m.value&&A.ctrlKey;if(!(!y.value||Z.value||U||V))return!1;A.preventDefault(),A.stopImmediatePropagation();const $=ee.property("__zoom").k||1,X=di();if(!z.value&&A.ctrlKey&&m.value&&X){const fe=xt(A),oe=ie(A),be=$*2**oe;q.scaleTo(ee,be,fe,A);return}const D=A.deltaMode===1?20:1;let pe=d.value===Lo.Vertical?0:A.deltaX*D,le=d.value===Lo.Horizontal?0:A.deltaY*D;!X&&A.shiftKey&&d.value!==Lo.Vertical&&!pe&&le&&(pe=le,le=0),q.translateBy(ee,-(pe/$)*u.value,-(le/$)*u.value);const _e=me(ee.property("__zoom"));I&&clearTimeout(I),Y.value?(w.move({event:A,flowTransform:_e}),w.viewportChange(_e),I=setTimeout(()=>{w.moveEnd({event:A,flowTransform:_e}),w.viewportChangeEnd(_e),Y.value=!1},150)):(Y.value=!0,w.moveStart({event:A,flowTransform:_e}),w.viewportChangeStart(_e))},{passive:!1}):typeof O<"u"&&ee.on("wheel.zoom",function(A,U){const V=!y.value&&A.type==="wheel"&&!A.ctrlKey,J=L.value||h.value,$=m.value&&A.ctrlKey;if(!J&&!c.value&&!$&&A.type==="wheel"||V||ge(A,g.value))return null;A.preventDefault(),O.call(this,A,U)},{passive:!1})},{immediate:!0})});function W(ne,re){return re===2&&Array.isArray(ne)&&ne.includes(2)}function ie(ne){const re=ne.ctrlKey&&di()?10:1;return-ne.deltaY*(ne.deltaMode===1?.05:ne.deltaMode?1:.002)*re}function ae(ne,re){return ne.x!==re.x&&!Number.isNaN(re.x)||ne.y!==re.y&&!Number.isNaN(re.y)||ne.zoom!==re.k&&!Number.isNaN(re.k)}function me(ne){return{x:ne.x,y:ne.y,zoom:ne.k}}function ge(ne,re){return ne.target.closest(`.${re}`)}return(ne,re)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"viewportRef",ref:j,class:"vue-flow__viewport vue-flow__container"},[t.createVNode(BA,{"is-selecting":Q.value,"selection-key-pressed":t.unref(H),class:t.normalizeClass({connecting:!!t.unref(b),dragging:t.unref(N),draggable:t.unref(f)===!0||Array.isArray(t.unref(f))&&t.unref(f).includes(0)})},{default:t.withCtx(()=>[t.createVNode(RA,null,{default:t.withCtx(()=>[t.renderSlot(ne.$slots,"default")]),_:3})]),_:3},8,["is-selecting","selection-key-pressed","class"])],512))}}),LA=["id"],FA=["id"],UA=["id"],KA={name:"A11yDescriptions",compatConfig:{MODE:3}},jA=t.defineComponent({...KA,setup(e){const{id:n,disableKeyboardA11y:o,ariaLiveMessage:r}=Oe();return(i,a)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[t.createElementVNode("div",{id:`${t.unref(rf)}-${t.unref(n)}`,style:{display:"none"}}," Press enter or space to select a node. "+t.toDisplayString(t.unref(o)?"":"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,LA),t.createElementVNode("div",{id:`${t.unref(af)}-${t.unref(n)}`,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,FA),t.unref(o)?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("div",{key:0,id:`${t.unref(px)}-${t.unref(n)}`,"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%)"}},t.toDisplayString(t.unref(r)),9,UA))],64))}});function GA(){const e=Oe();t.watch(()=>e.viewportHelper.value.viewportInitialized,n=>{n&&setTimeout(()=>{e.emits.init(e),e.emits.paneReady(e)},1)})}function qA(e,n,o){return o===ye.Left?e-n:o===ye.Right?e+n:e}function zA(e,n,o){return o===ye.Top?e-n:o===ye.Bottom?e+n:e}const xl=function({radius:e=10,centerX:n=0,centerY:o=0,position:r=ye.Top,type:i}){return t.h("circle",{class:`vue-flow__edgeupdater vue-flow__edgeupdater-${i}`,cx:qA(n,e,r),cy:zA(o,e,r),r:e,stroke:"transparent",fill:"transparent"})};xl.props=["radius","centerX","centerY","position","type"],xl.compatConfig={MODE:3};const Qf=xl,HA=t.defineComponent({name:"Edge",compatConfig:{MODE:3},props:["id"],setup(e){const{id:n,addSelectedEdges:o,connectionMode:r,edgeUpdaterRadius:i,emits:a,nodesSelectionActive:l,noPanClassName:s,getEdgeTypes:c,removeSelectedEdges:d,findEdge:u,findNode:f,isValidConnection:p,multiSelectionActive:m,disableKeyboardA11y:h,elementsSelectable:y,edgesUpdatable:g,edgesFocusable:_,hooks:w}=Oe(),b=t.computed(()=>u(e.id)),{emit:v,on:N}=jx(b.value,a),E=t.inject(pi),S=t.getCurrentInstance(),P=t.ref(!1),B=t.ref(!1),j=t.ref(""),G=t.ref(null),T=t.ref("source"),Y=t.ref(null),I=t.toRef(()=>typeof b.value.selectable>"u"?y.value:b.value.selectable),M=t.toRef(()=>typeof b.value.updatable>"u"?g.value:b.value.updatable),R=t.toRef(()=>typeof b.value.focusable>"u"?_.value:b.value.focusable);t.provide(Fx,e.id),t.provide(Ux,Y);const te=t.computed(()=>b.value.class instanceof Function?b.value.class(b.value):b.value.class),z=t.computed(()=>b.value.style instanceof Function?b.value.style(b.value):b.value.style),H=t.computed(()=>{const C=b.value.type||"default",x=E==null?void 0:E[`edge-${C}`];if(x)return x;let A=b.value.template??c.value[C];if(typeof A=="string"&&S){const U=Object.keys(S.appContext.components);U&&U.includes(C)&&(A=t.resolveComponent(C,!1))}return A&&typeof A!="string"?A:(a.error(new We(je.EDGE_TYPE_MISSING,A)),!1)}),{handlePointerDown:L}=Ff({nodeId:j,handleId:G,type:T,isValidConnection:p,edgeUpdaterType:T,onEdgeUpdate:Q,onEdgeUpdateEnd:W});return()=>{const C=f(b.value.source),x=f(b.value.target),A="pathOptions"in b.value?b.value.pathOptions:{};if(!C&&!x)return a.error(new We(je.EDGE_SOURCE_TARGET_MISSING,b.value.id,b.value.source,b.value.target)),null;if(!C)return a.error(new We(je.EDGE_SOURCE_MISSING,b.value.id,b.value.source)),null;if(!x)return a.error(new We(je.EDGE_TARGET_MISSING,b.value.id,b.value.target)),null;if(!b.value||b.value.hidden||C.hidden||x.hidden)return null;let U;r.value===Xt.Strict?U=C.handleBounds.source:U=[...C.handleBounds.source||[],...C.handleBounds.target||[]];const V=xf(U,b.value.sourceHandle);let J;r.value===Xt.Strict?J=x.handleBounds.target:J=[...x.handleBounds.target||[],...x.handleBounds.source||[]];const $=xf(J,b.value.targetHandle),X=(V==null?void 0:V.position)||ye.Bottom,D=($==null?void 0:$.position)||ye.Top,{x:pe,y:le}=Zn(C,V,X),{x:_e,y:fe}=Zn(x,$,D);return b.value.sourceX=pe,b.value.sourceY=le,b.value.targetX=_e,b.value.targetY=fe,t.h("g",{ref:Y,key:e.id,"data-id":e.id,class:["vue-flow__edge",`vue-flow__edge-${H.value===!1?"default":b.value.type||"default"}`,s.value,te.value,{updating:P.value,selected:b.value.selected,animated:b.value.animated,inactive:!I.value&&!w.value.edgeClick.hasListeners()}],tabIndex:R.value?0:void 0,"aria-label":b.value.ariaLabel===null?void 0:b.value.ariaLabel??`Edge from ${b.value.source} to ${b.value.target}`,"aria-describedby":R.value?`${af}-${n}`:void 0,"aria-roledescription":"edge",role:R.value?"group":"img",...b.value.domAttributes,onClick:ae,onContextmenu:me,onDblclick:ge,onMouseenter:ne,onMousemove:re,onMouseleave:q,onKeyDown:R.value?k:void 0},[B.value?null:t.h(H.value===!1?c.value.default:H.value,{id:e.id,sourceNode:C,targetNode:x,source:b.value.source,target:b.value.target,type:b.value.type,updatable:M.value,selected:b.value.selected,animated:b.value.animated,label:b.value.label,labelStyle:b.value.labelStyle,labelShowBg:b.value.labelShowBg,labelBgStyle:b.value.labelBgStyle,labelBgPadding:b.value.labelBgPadding,labelBgBorderRadius:b.value.labelBgBorderRadius,data:b.value.data,events:{...b.value.events,...N},style:z.value,markerStart:`url('#${jo(b.value.markerStart,n)}')`,markerEnd:`url('#${jo(b.value.markerEnd,n)}')`,sourcePosition:X,targetPosition:D,sourceX:pe,sourceY:le,targetX:_e,targetY:fe,sourceHandleId:b.value.sourceHandle,targetHandleId:b.value.targetHandle,interactionWidth:b.value.interactionWidth,...A}),[M.value==="source"||M.value===!0?[t.h("g",{onMousedown:ee,onMouseenter:F,onMouseout:Z},t.h(Qf,{position:X,centerX:pe,centerY:le,radius:i.value,type:"source","data-type":"source"}))]:null,M.value==="target"||M.value===!0?[t.h("g",{onMousedown:O,onMouseenter:F,onMouseout:Z},t.h(Qf,{position:D,centerX:_e,centerY:fe,radius:i.value,type:"target","data-type":"target"}))]:null]])};function F(){P.value=!0}function Z(){P.value=!1}function Q(C,x){v.update({event:C,edge:b.value,connection:x})}function W(C){v.updateEnd({event:C,edge:b.value}),B.value=!1}function ie(C,x){C.button===0&&(B.value=!0,j.value=x?b.value.target:b.value.source,G.value=(x?b.value.targetHandle:b.value.sourceHandle)??null,T.value=x?"target":"source",v.updateStart({event:C,edge:b.value}),L(C))}function ae(C){var x;const A={event:C,edge:b.value};I.value&&(l.value=!1,b.value.selected&&m.value?(d([b.value]),(x=Y.value)==null||x.blur()):o([b.value])),v.click(A)}function me(C){v.contextMenu({event:C,edge:b.value})}function ge(C){v.doubleClick({event:C,edge:b.value})}function ne(C){v.mouseEnter({event:C,edge:b.value})}function re(C){v.mouseMove({event:C,edge:b.value})}function q(C){v.mouseLeave({event:C,edge:b.value})}function ee(C){ie(C,!0)}function O(C){ie(C,!1)}function k(C){var x;!h.value&&lf.includes(C.key)&&I.value&&(C.key==="Escape"?((x=Y.value)==null||x.blur(),d([u(e.id)])):o([u(e.id)]))}}}),YA=t.defineComponent({name:"ConnectionLine",compatConfig:{MODE:3},setup(){var e;const{id:n,connectionMode:o,connectionStartHandle:r,connectionEndHandle:i,connectionPosition:a,connectionLineType:l,connectionLineStyle:s,connectionLineOptions:c,connectionStatus:d,viewport:u,findNode:f}=Oe(),p=(e=t.inject(pi))==null?void 0:e["connection-line"],m=t.computed(()=>{var w;return f((w=r.value)==null?void 0:w.nodeId)}),h=t.computed(()=>{var w;return f((w=i.value)==null?void 0:w.nodeId)??null}),y=t.computed(()=>({x:(a.value.x-u.value.x)/u.value.zoom,y:(a.value.y-u.value.y)/u.value.zoom})),g=t.computed(()=>c.value.markerStart?`url(#${jo(c.value.markerStart,n)})`:""),_=t.computed(()=>c.value.markerEnd?`url(#${jo(c.value.markerEnd,n)})`:"");return()=>{var w,b,v;if(!m.value||!r.value)return null;const N=r.value.id,E=r.value.type,S=m.value.handleBounds;let P=(S==null?void 0:S[E])??[];if(o.value===Xt.Loose){const z=(S==null?void 0:S[E==="source"?"target":"source"])??[];P=[...P,...z]}if(!P)return null;const B=(N?P.find(z=>z.id===N):P[0])??null,j=(B==null?void 0:B.position)??ye.Top,{x:G,y:T}=Zn(m.value,B,j);let Y=null;h.value&&(o.value===Xt.Strict?Y=((w=h.value.handleBounds[E==="source"?"target":"source"])==null?void 0:w.find(z=>{var H;return z.id===((H=i.value)==null?void 0:H.id)}))||null:Y=((b=[...h.value.handleBounds.source??[],...h.value.handleBounds.target??[]])==null?void 0:b.find(z=>{var H;return z.id===((H=i.value)==null?void 0:H.id)}))||null);const I=((v=i.value)==null?void 0:v.position)??(j?wl[j]:null);if(!j||!I)return null;const M=l.value??c.value.type??_n.Bezier;let R="";const te={sourceX:G,sourceY:T,sourcePosition:j,targetX:y.value.x,targetY:y.value.y,targetPosition:I};return M===_n.Bezier?[R]=Hf(te):M===_n.Step?[R]=Sl({...te,borderRadius:0}):M===_n.SmoothStep?[R]=Sl(te):M===_n.SimpleBezier?[R]=Wf(te):R=`M${G},${T} ${y.value.x},${y.value.y}`,t.h("svg",{class:"vue-flow__edges vue-flow__connectionline vue-flow__container"},t.h("g",{class:"vue-flow__connection"},p?t.h(p,{sourceX:G,sourceY:T,sourcePosition:j,targetX:y.value.x,targetY:y.value.y,targetPosition:I,sourceNode:m.value,sourceHandle:B,targetNode:h.value,targetHandle:Y,markerEnd:_.value,markerStart:g.value,connectionStatus:d.value}):t.h("path",{d:R,class:[c.value.class,d,"vue-flow__connection-path"],style:{...s.value,...c.value.style},"marker-end":_.value,"marker-start":g.value})))}}}),WA=["id","markerWidth","markerHeight","markerUnits","orient"],XA={name:"MarkerType",compatConfig:{MODE:3}},ZA=t.defineComponent({...XA,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(e){return(n,o)=>(t.openBlock(),t.createElementBlock("marker",{id:n.id,class:"vue-flow__arrowhead",viewBox:"-10 -10 20 20",refX:"0",refY:"0",markerWidth:`${n.width}`,markerHeight:`${n.height}`,markerUnits:n.markerUnits,orient:n.orient},[n.type===t.unref(ii).ArrowClosed?(t.openBlock(),t.createElementBlock("polyline",{key:0,style:t.normalizeStyle({stroke:n.color,fill:n.color,strokeWidth:n.strokeWidth}),"stroke-linecap":"round","stroke-linejoin":"round",points:"-5,-4 0,0 -5,4 -5,-4"},null,4)):t.createCommentVNode("",!0),n.type===t.unref(ii).Arrow?(t.openBlock(),t.createElementBlock("polyline",{key:1,style:t.normalizeStyle({stroke:n.color,strokeWidth:n.strokeWidth}),"stroke-linecap":"round","stroke-linejoin":"round",fill:"none",points:"-5,-4 0,0 -5,4"},null,4)):t.createCommentVNode("",!0)],8,WA))}}),JA={class:"vue-flow__marker vue-flow__container","aria-hidden":"true"},QA={name:"MarkerDefinitions",compatConfig:{MODE:3}},eI=t.defineComponent({...QA,setup(e){const{id:n,edges:o,connectionLineOptions:r,defaultMarkerColor:i}=Oe(),a=t.computed(()=>{const l=new Set,s=[],c=d=>{if(d){const u=jo(d,n);l.has(u)||(typeof d=="object"?s.push({...d,id:u,color:d.color||i.value}):s.push({id:u,color:i.value,type:d}),l.add(u))}};for(const d of[r.value.markerEnd,r.value.markerStart])c(d);for(const d of o.value)for(const u of[d.markerStart,d.markerEnd])c(u);return s.sort((d,u)=>d.id.localeCompare(u.id))});return(l,s)=>(t.openBlock(),t.createElementBlock("svg",JA,[t.createElementVNode("defs",null,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(a.value,c=>(t.openBlock(),t.createBlock(ZA,{id:c.id,key:c.id,type:c.type,color:c.color,width:c.width,height:c.height,markerUnits:c.markerUnits,"stroke-width":c.strokeWidth,orient:c.orient},null,8,["id","type","color","width","height","markerUnits","stroke-width","orient"]))),128))])]))}}),tI={name:"Edges",compatConfig:{MODE:3}},nI=t.defineComponent({...tI,setup(e){const{findNode:n,getEdges:o,elevateEdgesOnSelect:r}=Oe();return(i,a)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[t.createVNode(eI),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(o),l=>(t.openBlock(),t.createElementBlock("svg",{key:l.id,class:"vue-flow__edges vue-flow__container",style:t.normalizeStyle({zIndex:t.unref(xx)(l,t.unref(n),t.unref(r))})},[t.createVNode(t.unref(HA),{id:l.id},null,8,["id"])],4))),128)),t.createVNode(t.unref(YA))],64))}}),oI=t.defineComponent({name:"Node",compatConfig:{MODE:3},props:["id","resizeObserver"],setup(e){const{id:n,noPanClassName:o,selectNodesOnDrag:r,nodesSelectionActive:i,multiSelectionActive:a,emits:l,removeSelectedNodes:s,addSelectedNodes:c,updateNodeDimensions:d,onUpdateNodeInternals:u,getNodeTypes:f,nodeExtent:p,elevateNodesOnSelect:m,disableKeyboardA11y:h,ariaLiveMessage:y,snapToGrid:g,snapGrid:_,nodeDragThreshold:w,nodesDraggable:b,elementsSelectable:v,nodesConnectable:N,nodesFocusable:E,hooks:S}=Oe(),P=t.ref(null);t.provide(Mf,P),t.provide(Df,e.id);const B=t.inject(pi),j=t.getCurrentInstance(),G=Kf(),{node:T,parentNode:Y}=Uf(e.id),{emit:I,on:M}=Hx(T,l),R=t.toRef(()=>typeof T.draggable>"u"?b.value:T.draggable),te=t.toRef(()=>typeof T.selectable>"u"?v.value:T.selectable),z=t.toRef(()=>typeof T.connectable>"u"?N.value:T.connectable),H=t.toRef(()=>typeof T.focusable>"u"?E.value:T.focusable),L=t.computed(()=>te.value||R.value||S.value.nodeClick.hasListeners()||S.value.nodeDoubleClick.hasListeners()||S.value.nodeMouseEnter.hasListeners()||S.value.nodeMouseMove.hasListeners()||S.value.nodeMouseLeave.hasListeners()),F=t.toRef(()=>!!T.dimensions.width&&!!T.dimensions.height),Z=t.computed(()=>{const x=T.type||"default",A=B==null?void 0:B[`node-${x}`];if(A)return A;let U=T.template||f.value[x];if(typeof U=="string"&&j){const V=Object.keys(j.appContext.components);V&&V.includes(x)&&(U=t.resolveComponent(x,!1))}return U&&typeof U!="string"?U:(l.error(new We(je.NODE_TYPE_MISSING,U)),!1)}),Q=Lf({id:e.id,el:P,disabled:()=>!R.value,selectable:te,dragHandle:()=>T.dragHandle,onStart(x){I.dragStart(x)},onDrag(x){I.drag(x)},onStop(x){I.dragStop(x)},onClick(x){k(x)}}),W=t.computed(()=>T.class instanceof Function?T.class(T):T.class),ie=t.computed(()=>{const x=(T.style instanceof Function?T.style(T):T.style)||{},A=T.width instanceof Function?T.width(T):T.width,U=T.height instanceof Function?T.height(T):T.height;return!x.width&&A&&(x.width=typeof A=="string"?A:`${A}px`),!x.height&&U&&(x.height=typeof U=="string"?U:`${U}px`),x}),ae=t.toRef(()=>Number(T.zIndex??ie.value.zIndex??0));return u(x=>{(x.includes(e.id)||!x.length)&&ge()}),t.onMounted(()=>{t.watch(()=>T.hidden,(x=!1,A,U)=>{!x&&P.value&&(e.resizeObserver.observe(P.value),U(()=>{P.value&&e.resizeObserver.unobserve(P.value)}))},{immediate:!0,flush:"post"})}),t.watch([()=>T.type,()=>T.sourcePosition,()=>T.targetPosition],()=>{t.nextTick(()=>{d([{id:e.id,nodeElement:P.value,forceUpdate:!0}])})}),t.watch([()=>T.position.x,()=>T.position.y,()=>{var x;return(x=Y.value)==null?void 0:x.computedPosition.x},()=>{var x;return(x=Y.value)==null?void 0:x.computedPosition.y},()=>{var x;return(x=Y.value)==null?void 0:x.computedPosition.z},ae,()=>T.selected,()=>T.dimensions.height,()=>T.dimensions.width,()=>{var x;return(x=Y.value)==null?void 0:x.dimensions.height},()=>{var x;return(x=Y.value)==null?void 0:x.dimensions.width}],([x,A,U,V,J,$])=>{const X={x,y:A,z:$+(m.value&&T.selected?1e3:0)};typeof U<"u"&&typeof V<"u"?T.computedPosition=kx({x:U,y:V,z:J},X):T.computedPosition=X},{flush:"post",immediate:!0}),t.watch([()=>T.extent,p],([x,A],[U,V])=>{(x!==U||A!==V)&&me()}),T.extent==="parent"||typeof T.extent=="object"&&"range"in T.extent&&T.extent.range==="parent"?qa(()=>F).toBe(!0).then(me):me(),()=>T.hidden?null:t.h("div",{ref:P,"data-id":T.id,class:["vue-flow__node",`vue-flow__node-${Z.value===!1?"default":T.type||"default"}`,{[o.value]:R.value,dragging:Q==null?void 0:Q.value,draggable:R.value,selected:T.selected,selectable:te.value,parent:T.isParent},W.value],style:{visibility:F.value?"visible":"hidden",zIndex:T.computedPosition.z??ae.value,transform:`translate(${T.computedPosition.x}px,${T.computedPosition.y}px)`,pointerEvents:L.value?"all":"none",...ie.value},tabIndex:H.value?0:void 0,role:H.value?"group":void 0,"aria-describedby":h.value?void 0:`${rf}-${n}`,"aria-label":T.ariaLabel,"aria-roledescription":"node",...T.domAttributes,onMouseenter:ne,onMousemove:re,onMouseleave:q,onContextmenu:ee,onClick:k,onDblclick:O,onKeydown:C},[t.h(Z.value===!1?f.value.default:Z.value,{id:T.id,type:T.type,data:T.data,events:{...T.events,...M},selected:T.selected,resizing:T.resizing,dragging:Q.value,connectable:z.value,position:T.computedPosition,dimensions:T.dimensions,isValidTargetPos:T.isValidTargetPos,isValidSourcePos:T.isValidSourcePos,parent:T.parentNode,parentNodeId:T.parentNode,zIndex:T.computedPosition.z??ae.value,targetPosition:T.targetPosition,sourcePosition:T.sourcePosition,label:T.label,dragHandle:T.dragHandle,onUpdateNodeInternals:ge})]);function me(){const x=T.computedPosition,{computedPosition:A,position:U}=yl(T,g.value?ui(x,_.value):x,l.error,p.value,Y.value);(T.computedPosition.x!==A.x||T.computedPosition.y!==A.y)&&(T.computedPosition={...T.computedPosition,...A}),(T.position.x!==U.x||T.position.y!==U.y)&&(T.position=U)}function ge(){P.value&&d([{id:e.id,nodeElement:P.value,forceUpdate:!0}])}function ne(x){Q!=null&&Q.value||I.mouseEnter({event:x,node:T})}function re(x){Q!=null&&Q.value||I.mouseMove({event:x,node:T})}function q(x){Q!=null&&Q.value||I.mouseLeave({event:x,node:T})}function ee(x){return I.contextMenu({event:x,node:T})}function O(x){return I.doubleClick({event:x,node:T})}function k(x){te.value&&(!r.value||!R.value||w.value>0)&&kl(T,a.value,c,s,i,!1,P.value),I.click({event:x,node:T})}function C(x){if(!(pl(x)||h.value))if(lf.includes(x.key)&&te.value){const A=x.key==="Escape";kl(T,a.value,c,s,i,A,P.value)}else R.value&&T.selected&&Xn[x.key]&&(x.preventDefault(),y.value=`Moved selected node ${x.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~T.position.x}, y: ${~~T.position.y}`,G({x:Xn[x.key].x,y:Xn[x.key].y},x.shiftKey))}}});function rI(e={includeHiddenNodes:!1}){const{nodes:n}=Oe();return t.computed(()=>{if(n.value.length===0)return!1;for(const o of n.value)if((e.includeHiddenNodes||!o.hidden)&&((o==null?void 0:o.handleBounds)===void 0||o.dimensions.width===0||o.dimensions.height===0))return!1;return!0})}const iI={class:"vue-flow__nodes vue-flow__container"},aI={name:"Nodes",compatConfig:{MODE:3}},lI=t.defineComponent({...aI,setup(e){const{getNodes:n,updateNodeDimensions:o,emits:r}=Oe(),i=rI(),a=t.ref();return t.watch(i,l=>{l&&t.nextTick(()=>{r.nodesInitialized(n.value)})},{immediate:!0}),t.onMounted(()=>{a.value=new ResizeObserver(l=>{const s=l.map(c=>({id:c.target.getAttribute("data-id"),nodeElement:c.target,forceUpdate:!0}));t.nextTick(()=>o(s))})}),t.onBeforeUnmount(()=>{var l;return(l=a.value)==null?void 0:l.disconnect()}),(l,s)=>(t.openBlock(),t.createElementBlock("div",iI,[a.value?(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:0},t.renderList(t.unref(n),(c,d,u,f)=>{const p=[c.id];if(f&&f.key===c.id&&t.isMemoSame(f,p))return f;const m=(t.openBlock(),t.createBlock(t.unref(oI),{id:c.id,key:c.id,"resize-observer":a.value},null,8,["id","resize-observer"]));return m.memo=p,m},s,0),128)):t.createCommentVNode("",!0)]))}});function sI(){const{emits:e}=Oe();t.onMounted(()=>{if(Tf()){const n=document.querySelector(".vue-flow__pane");n&&window.getComputedStyle(n).zIndex!=="1"&&e.error(new We(je.MISSING_STYLES))}})}const cI=t.createElementVNode("div",{class:"vue-flow__edge-labels"},null,-1),dI={name:"VueFlow",compatConfig:{MODE:3}},ep=t.defineComponent({...dI,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(e,{expose:n,emit:o}){const r=e,i=t.useSlots(),a=za(r,"modelValue",o),l=za(r,"nodes",o),s=za(r,"edges",o),c=Oe(r),d=Zx({modelValue:a,nodes:l,edges:s},r,c);return Qx(o,c.hooks),GA(),sI(),t.provide(pi,i),t.onUnmounted(()=>{d()}),n(c),(u,f)=>(t.openBlock(),t.createElementBlock("div",{ref:t.unref(c).vueFlowRef,class:"vue-flow"},[t.createVNode(MA,null,{default:t.withCtx(()=>[t.createVNode(nI),cI,t.createVNode(lI),t.renderSlot(u.$slots,"zoom-pane")]),_:3}),t.renderSlot(u.$slots,"default"),t.createVNode(jA)],512))}}),uI={name:"Panel",compatConfig:{MODE:3}},fI=t.defineComponent({...uI,props:{position:{}},setup(e){const n=e,{userSelectionActive:o}=Oe(),r=t.computed(()=>`${n.position}`.split("-"));return(i,a)=>(t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["vue-flow__panel",r.value]),style:t.normalizeStyle({pointerEvents:t.unref(o)?"none":"all"})},[t.renderSlot(i.$slots,"default")],6))}});var Gt=(e=>(e.Lines="lines",e.Dots="dots",e))(Gt||{});const tp=function({dimensions:e,size:n,color:o}){return t.h("path",{stroke:o,"stroke-width":n,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`})},np=function({radius:e,color:n}){return t.h("circle",{cx:e,cy:e,r:e,fill:n})};Gt.Lines+"",Gt.Dots+"";const pI={[Gt.Dots]:"#81818a",[Gt.Lines]:"#eee"},mI=["id","x","y","width","height","patternTransform"],gI={key:2,height:"100",width:"100"},hI=["fill"],yI=["x","y","fill"],_I={name:"Background",compatConfig:{MODE:3}},bI=t.defineComponent({..._I,props:{id:{},variant:{default:()=>Gt.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(e){const{id:n,viewport:o}=Oe(),r=t.computed(()=>{const l=o.value.zoom,[s,c]=Array.isArray(e.gap)?e.gap:[e.gap,e.gap],d=[s*l||1,c*l||1],u=e.size*l,[f,p]=Array.isArray(e.offset)?e.offset:[e.offset,e.offset],m=[f*l||1+d[0]/2,p*l||1+d[1]/2];return{scaledGap:d,offset:m,size:u}}),i=t.toRef(()=>`pattern-${n}${e.id?`-${e.id}`:""}`),a=t.toRef(()=>e.color||e.patternColor||pI[e.variant||Gt.Dots]);return(l,s)=>(t.openBlock(),t.createElementBlock("svg",{class:"vue-flow__background vue-flow__container",style:t.normalizeStyle({height:`${l.height>100?100:l.height}%`,width:`${l.width>100?100:l.width}%`})},[t.renderSlot(l.$slots,"pattern-container",{id:i.value},()=>[t.createElementVNode("pattern",{id:i.value,x:t.unref(o).x%r.value.scaledGap[0],y:t.unref(o).y%r.value.scaledGap[1],width:r.value.scaledGap[0],height:r.value.scaledGap[1],patternTransform:`translate(-${r.value.offset[0]},-${r.value.offset[1]})`,patternUnits:"userSpaceOnUse"},[t.renderSlot(l.$slots,"pattern",{},()=>[l.variant===t.unref(Gt).Lines?(t.openBlock(),t.createBlock(t.unref(tp),{key:0,size:l.lineWidth,color:a.value,dimensions:r.value.scaledGap},null,8,["size","color","dimensions"])):l.variant===t.unref(Gt).Dots?(t.openBlock(),t.createBlock(t.unref(np),{key:1,color:a.value,radius:r.value.size/2},null,8,["color","radius"])):t.createCommentVNode("",!0),l.bgColor?(t.openBlock(),t.createElementBlock("svg",gI,[t.createElementVNode("rect",{width:"100%",height:"100%",fill:l.bgColor},null,8,hI)])):t.createCommentVNode("",!0)])],8,mI)]),t.createElementVNode("rect",{x:l.x,y:l.y,width:"100%",height:"100%",fill:`url(#${i.value})`},null,8,yI),t.renderSlot(l.$slots,"default",{id:i.value})],4))}}),wI={name:"ControlButton",compatConfig:{MODE:3}},kI=(e,n)=>{const o=e.__vccOpts||e;for(const[r,i]of n)o[r]=i;return o},EI={class:"vue-flow__controls-button"};function CI(e,n,o,r,i,a){return t.openBlock(),t.createElementBlock("button",EI,[t.renderSlot(e.$slots,"default")])}const wi=kI(wI,[["render",CI]]),NI={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},vI=[t.createElementVNode("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"},null,-1)];function SI(e,n){return t.openBlock(),t.createElementBlock("svg",NI,vI)}const xI={render:SI},AI={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},II=[t.createElementVNode("path",{d:"M0 0h32v4.2H0z"},null,-1)];function PI(e,n){return t.openBlock(),t.createElementBlock("svg",AI,II)}const TI={render:PI},OI={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},$I=[t.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 BI(e,n){return t.openBlock(),t.createElementBlock("svg",OI,$I)}const VI={render:BI},RI={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},DI=[t.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 MI(e,n){return t.openBlock(),t.createElementBlock("svg",RI,DI)}const LI={render:MI},FI={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},UI=[t.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 KI(e,n){return t.openBlock(),t.createElementBlock("svg",FI,UI)}const jI={render:KI},GI={name:"Controls",compatConfig:{MODE:3}},qI=t.defineComponent({...GI,props:{showZoom:{type:Boolean,default:!0},showFitView:{type:Boolean,default:!0},showInteractive:{type:Boolean,default:!0},fitViewParams:{},position:{default:()=>nf.BottomLeft}},emits:["zoomIn","zoomOut","fitView","interactionChange"],setup(e,{emit:n}){const{nodesDraggable:o,nodesConnectable:r,elementsSelectable:i,setInteractive:a,zoomIn:l,zoomOut:s,fitView:c,viewport:d,minZoom:u,maxZoom:f}=Oe(),p=t.toRef(()=>o.value||r.value||i.value),m=t.toRef(()=>d.value.zoom<=u.value),h=t.toRef(()=>d.value.zoom>=f.value);function y(){l(),n("zoomIn")}function g(){s(),n("zoomOut")}function _(){c(e.fitViewParams),n("fitView")}function w(){a(!p.value),n("interactionChange",!p.value)}return(b,v)=>(t.openBlock(),t.createBlock(t.unref(fI),{class:"vue-flow__controls",position:b.position},{default:t.withCtx(()=>[t.renderSlot(b.$slots,"top"),b.showZoom?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.renderSlot(b.$slots,"control-zoom-in",{},()=>[t.createVNode(wi,{class:"vue-flow__controls-zoomin",disabled:h.value,onClick:y},{default:t.withCtx(()=>[t.renderSlot(b.$slots,"icon-zoom-in",{},()=>[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(t.unref(xI))))])]),_:3},8,["disabled"])]),t.renderSlot(b.$slots,"control-zoom-out",{},()=>[t.createVNode(wi,{class:"vue-flow__controls-zoomout",disabled:m.value,onClick:g},{default:t.withCtx(()=>[t.renderSlot(b.$slots,"icon-zoom-out",{},()=>[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(t.unref(TI))))])]),_:3},8,["disabled"])])],64)):t.createCommentVNode("",!0),b.showFitView?t.renderSlot(b.$slots,"control-fit-view",{key:1},()=>[t.createVNode(wi,{class:"vue-flow__controls-fitview",onClick:_},{default:t.withCtx(()=>[t.renderSlot(b.$slots,"icon-fit-view",{},()=>[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(t.unref(VI))))])]),_:3})]):t.createCommentVNode("",!0),b.showInteractive?t.renderSlot(b.$slots,"control-interactive",{key:2},()=>[b.showInteractive?(t.openBlock(),t.createBlock(wi,{key:0,class:"vue-flow__controls-interactive",onClick:w},{default:t.withCtx(()=>[p.value?t.renderSlot(b.$slots,"icon-unlock",{key:0},()=>[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(t.unref(jI))))]):t.createCommentVNode("",!0),p.value?t.createCommentVNode("",!0):t.renderSlot(b.$slots,"icon-lock",{key:1},()=>[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(t.unref(LI))))])]),_:3})):t.createCommentVNode("",!0)]):t.createCommentVNode("",!0),t.renderSlot(b.$slots,"default")]),_:3},8,["position"]))}}),Go={padding:80,gaps:{nodes:40,edges:80,ranks:40}},zI=1600,HI=1.2,YI=0,op=Symbol("confirm-modal"),Jn="{key}",En={"kong.client.consumer":{dataType:"object",writable:!1,readable:!0},"kong.client.consumer_groups":{dataType:"array",writable:!1,readable:!0},"kong.client.credential":{dataType:"object",writable:!1,readable:!0},"kong.client.get_identity_realm_source":{dataType:"object",writable:!1,readable:!0},"kong.client.forwarded_ip":{dataType:"string",writable:!1,readable:!0},"kong.client.forwarded_port":{dataType:"number",writable:!1,readable:!0},"kong.client.ip":{dataType:"string",writable:!1,readable:!0},"kong.client.port":{dataType:"number",writable:!1,readable:!0},"kong.client.protocol":{dataType:"string",writable:!1,readable:!0},"kong.request.forwarded_host":{dataType:"string",writable:!1,readable:!0},"kong.request.forwarded_port":{dataType:"number",writable:!1,readable:!0},"kong.request.forwarded_scheme":{dataType:"string",writable:!1,readable:!0},"kong.request.port":{dataType:"number",writable:!1,readable:!0},"kong.response.source":{dataType:"string",writable:!1,readable:!0},"kong.router.route":{dataType:"object",writable:!1,readable:!0},"kong.route_id":{dataType:"string",writable:!1,readable:!0},"kong.route_name":{dataType:"string",writable:!1,readable:!0},"kong.router.service":{dataType:"object",writable:!1,readable:!0},"kong.service_name":{dataType:"string",writable:!1,readable:!0},"kong.service_id":{dataType:"string",writable:!1,readable:!0},"kong.service.response.status":{dataType:"number",writable:!1,readable:!0},"kong.version":{dataType:"string",writable:!1,readable:!0},"kong.node.id":{dataType:"string",writable:!1,readable:!0},"kong.configuration.{key}":{dataType:"any",writable:!1,readable:!0},"kong.service.target":{dataType:"string ({host}:{port})",writable:!0,readable:!1},"kong.service.request_scheme":{dataType:"string ({scheme})",writable:!0,readable:!1},"kong.ctx.plugin.{key}":{dataType:"any",writable:!0,readable:!0},"kong.ctx.shared.{key}":{dataType:"any",writable:!0,readable:!0}},ki=Object.keys(En).filter(e=>e.includes(Jn)).map(e=>e.replace(Jn,""));function Al(e){if(!e||!zo(e))return;const n=ki.find(o=>e.startsWith(o));if(n)return e.slice(n.length).replace(Jn,"")}function qo(e){if(!e)return null;const n=ki.find(o=>e.startsWith(o));return n||e}function zo(e){return e?ki.some(n=>e.startsWith(n)):!1}function rp(e){return e?zo(e)?qo(e)+Jn:e:null}function Il(e){var o;if(!e)return!1;const n=rp(e);return n?((o=En[n])==null?void 0:o.readable)??!1:!1}function Pl(e){var o;if(!e)return!1;const n=rp(e);return n?((o=En[n])==null?void 0:o.writable)??!1:!1}function WI(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var XI="\0",Cn="\0",ip="";let ZI=class{constructor(n){ze(this,"_isDirected",!0);ze(this,"_isMultigraph",!1);ze(this,"_isCompound",!1);ze(this,"_label");ze(this,"_defaultNodeLabelFn",()=>{});ze(this,"_defaultEdgeLabelFn",()=>{});ze(this,"_nodes",{});ze(this,"_in",{});ze(this,"_preds",{});ze(this,"_out",{});ze(this,"_sucs",{});ze(this,"_edgeObjs",{});ze(this,"_edgeLabels",{});ze(this,"_nodeCount",0);ze(this,"_edgeCount",0);ze(this,"_parent");ze(this,"_children");n&&(this._isDirected=Object.hasOwn(n,"directed")?n.directed:!0,this._isMultigraph=Object.hasOwn(n,"multigraph")?n.multigraph:!1,this._isCompound=Object.hasOwn(n,"compound")?n.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[Cn]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(n){return this._label=n,this}graph(){return this._label}setDefaultNodeLabel(n){return this._defaultNodeLabelFn=n,typeof n!="function"&&(this._defaultNodeLabelFn=()=>n),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var n=this;return this.nodes().filter(o=>Object.keys(n._in[o]).length===0)}sinks(){var n=this;return this.nodes().filter(o=>Object.keys(n._out[o]).length===0)}setNodes(n,o){var r=arguments,i=this;return n.forEach(function(a){r.length>1?i.setNode(a,o):i.setNode(a)}),this}setNode(n,o){return Object.hasOwn(this._nodes,n)?(arguments.length>1&&(this._nodes[n]=o),this):(this._nodes[n]=arguments.length>1?o:this._defaultNodeLabelFn(n),this._isCompound&&(this._parent[n]=Cn,this._children[n]={},this._children[Cn][n]=!0),this._in[n]={},this._preds[n]={},this._out[n]={},this._sucs[n]={},++this._nodeCount,this)}node(n){return this._nodes[n]}hasNode(n){return Object.hasOwn(this._nodes,n)}removeNode(n){var o=this;if(Object.hasOwn(this._nodes,n)){var r=i=>o.removeEdge(o._edgeObjs[i]);delete this._nodes[n],this._isCompound&&(this._removeFromParentsChildList(n),delete this._parent[n],this.children(n).forEach(function(i){o.setParent(i)}),delete this._children[n]),Object.keys(this._in[n]).forEach(r),delete this._in[n],delete this._preds[n],Object.keys(this._out[n]).forEach(r),delete this._out[n],delete this._sucs[n],--this._nodeCount}return this}setParent(n,o){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(o===void 0)o=Cn;else{o+="";for(var r=o;r!==void 0;r=this.parent(r))if(r===n)throw new Error("Setting "+o+" as parent of "+n+" would create a cycle");this.setNode(o)}return this.setNode(n),this._removeFromParentsChildList(n),this._parent[n]=o,this._children[o][n]=!0,this}_removeFromParentsChildList(n){delete this._children[this._parent[n]][n]}parent(n){if(this._isCompound){var o=this._parent[n];if(o!==Cn)return o}}children(n=Cn){if(this._isCompound){var o=this._children[n];if(o)return Object.keys(o)}else{if(n===Cn)return this.nodes();if(this.hasNode(n))return[]}}predecessors(n){var o=this._preds[n];if(o)return Object.keys(o)}successors(n){var o=this._sucs[n];if(o)return Object.keys(o)}neighbors(n){var o=this.predecessors(n);if(o){const i=new Set(o);for(var r of this.successors(n))i.add(r);return Array.from(i.values())}}isLeaf(n){var o;return this.isDirected()?o=this.successors(n):o=this.neighbors(n),o.length===0}filterNodes(n){var o=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});o.setGraph(this.graph());var r=this;Object.entries(this._nodes).forEach(function([l,s]){n(l)&&o.setNode(l,s)}),Object.values(this._edgeObjs).forEach(function(l){o.hasNode(l.v)&&o.hasNode(l.w)&&o.setEdge(l,r.edge(l))});var i={};function a(l){var s=r.parent(l);return s===void 0||o.hasNode(s)?(i[l]=s,s):s in i?i[s]:a(s)}return this._isCompound&&o.nodes().forEach(l=>o.setParent(l,a(l))),o}setDefaultEdgeLabel(n){return this._defaultEdgeLabelFn=n,typeof n!="function"&&(this._defaultEdgeLabelFn=()=>n),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(n,o){var r=this,i=arguments;return n.reduce(function(a,l){return i.length>1?r.setEdge(a,l,o):r.setEdge(a,l),l}),this}setEdge(){var n,o,r,i,a=!1,l=arguments[0];typeof l=="object"&&l!==null&&"v"in l?(n=l.v,o=l.w,r=l.name,arguments.length===2&&(i=arguments[1],a=!0)):(n=l,o=arguments[1],r=arguments[3],arguments.length>2&&(i=arguments[2],a=!0)),n=""+n,o=""+o,r!==void 0&&(r=""+r);var s=Ho(this._isDirected,n,o,r);if(Object.hasOwn(this._edgeLabels,s))return a&&(this._edgeLabels[s]=i),this;if(r!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(n),this.setNode(o),this._edgeLabels[s]=a?i:this._defaultEdgeLabelFn(n,o,r);var c=JI(this._isDirected,n,o,r);return n=c.v,o=c.w,Object.freeze(c),this._edgeObjs[s]=c,ap(this._preds[o],n),ap(this._sucs[n],o),this._in[o][s]=c,this._out[n][s]=c,this._edgeCount++,this}edge(n,o,r){var i=arguments.length===1?Tl(this._isDirected,arguments[0]):Ho(this._isDirected,n,o,r);return this._edgeLabels[i]}edgeAsObj(){const n=this.edge(...arguments);return typeof n!="object"?{label:n}:n}hasEdge(n,o,r){var i=arguments.length===1?Tl(this._isDirected,arguments[0]):Ho(this._isDirected,n,o,r);return Object.hasOwn(this._edgeLabels,i)}removeEdge(n,o,r){var i=arguments.length===1?Tl(this._isDirected,arguments[0]):Ho(this._isDirected,n,o,r),a=this._edgeObjs[i];return a&&(n=a.v,o=a.w,delete this._edgeLabels[i],delete this._edgeObjs[i],lp(this._preds[o],n),lp(this._sucs[n],o),delete this._in[o][i],delete this._out[n][i],this._edgeCount--),this}inEdges(n,o){var r=this._in[n];if(r){var i=Object.values(r);return o?i.filter(a=>a.v===o):i}}outEdges(n,o){var r=this._out[n];if(r){var i=Object.values(r);return o?i.filter(a=>a.w===o):i}}nodeEdges(n,o){var r=this.inEdges(n,o);if(r)return r.concat(this.outEdges(n,o))}};function ap(e,n){e[n]?e[n]++:e[n]=1}function lp(e,n){--e[n]||delete e[n]}function Ho(e,n,o,r){var i=""+n,a=""+o;if(!e&&i>a){var l=i;i=a,a=l}return i+ip+a+ip+(r===void 0?XI:r)}function JI(e,n,o,r){var i=""+n,a=""+o;if(!e&&i>a){var l=i;i=a,a=l}var s={v:i,w:a};return r&&(s.name=r),s}function Tl(e,n){return Ho(e,n.v,n.w,n.name)}var Ol=ZI,QI="2.2.4",eP={Graph:Ol,version:QI},tP=Ol,nP={write:oP,read:aP};function oP(e){var n={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:rP(e),edges:iP(e)};return e.graph()!==void 0&&(n.value=structuredClone(e.graph())),n}function rP(e){return e.nodes().map(function(n){var o=e.node(n),r=e.parent(n),i={v:n};return o!==void 0&&(i.value=o),r!==void 0&&(i.parent=r),i})}function iP(e){return e.edges().map(function(n){var o=e.edge(n),r={v:n.v,w:n.w};return n.name!==void 0&&(r.name=n.name),o!==void 0&&(r.value=o),r})}function aP(e){var n=new tP(e.options).setGraph(e.value);return e.nodes.forEach(function(o){n.setNode(o.v,o.value),o.parent&&n.setParent(o.v,o.parent)}),e.edges.forEach(function(o){n.setEdge({v:o.v,w:o.w,name:o.name},o.value)}),n}var lP=sP;function sP(e){var n={},o=[],r;function i(a){Object.hasOwn(n,a)||(n[a]=!0,r.push(a),e.successors(a).forEach(i),e.predecessors(a).forEach(i))}return e.nodes().forEach(function(a){r=[],i(a),r.length&&o.push(r)}),o}var sp=class{constructor(){ze(this,"_arr",[]);ze(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map(function(n){return n.key})}has(n){return Object.hasOwn(this._keyIndices,n)}priority(n){var o=this._keyIndices[n];if(o!==void 0)return this._arr[o].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(n,o){var r=this._keyIndices;if(n=String(n),!Object.hasOwn(r,n)){var i=this._arr,a=i.length;return r[n]=a,i.push({key:n,priority:o}),this._decrease(a),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var n=this._arr.pop();return delete this._keyIndices[n.key],this._heapify(0),n.key}decrease(n,o){var r=this._keyIndices[n];if(o>this._arr[r].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[r].priority+" New: "+o);this._arr[r].priority=o,this._decrease(r)}_heapify(n){var o=this._arr,r=2*n,i=r+1,a=n;r<o.length&&(a=o[r].priority<o[a].priority?r:a,i<o.length&&(a=o[i].priority<o[a].priority?i:a),a!==n&&(this._swap(n,a),this._heapify(a)))}_decrease(n){for(var o=this._arr,r=o[n].priority,i;n!==0&&(i=n>>1,!(o[i].priority<r));)this._swap(n,i),n=i}_swap(n,o){var r=this._arr,i=this._keyIndices,a=r[n],l=r[o];r[n]=l,r[o]=a,i[l.key]=n,i[a.key]=o}},cP=sp,cp=uP,dP=()=>1;function uP(e,n,o,r){return fP(e,String(n),o||dP,r||function(i){return e.outEdges(i)})}function fP(e,n,o,r){var i={},a=new cP,l,s,c=function(d){var u=d.v!==l?d.v:d.w,f=i[u],p=o(d),m=s.distance+p;if(p<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+d+" Weight: "+p);m<f.distance&&(f.distance=m,f.predecessor=l,a.decrease(u,m))};for(e.nodes().forEach(function(d){var u=d===n?0:Number.POSITIVE_INFINITY;i[d]={distance:u},a.add(d,u)});a.size()>0&&(l=a.removeMin(),s=i[l],s.distance!==Number.POSITIVE_INFINITY);)r(l).forEach(c);return i}var pP=cp,mP=gP;function gP(e,n,o){return e.nodes().reduce(function(r,i){return r[i]=pP(e,i,n,o),r},{})}var dp=hP;function hP(e){var n=0,o=[],r={},i=[];function a(l){var s=r[l]={onStack:!0,lowlink:n,index:n++};if(o.push(l),e.successors(l).forEach(function(u){Object.hasOwn(r,u)?r[u].onStack&&(s.lowlink=Math.min(s.lowlink,r[u].index)):(a(u),s.lowlink=Math.min(s.lowlink,r[u].lowlink))}),s.lowlink===s.index){var c=[],d;do d=o.pop(),r[d].onStack=!1,c.push(d);while(l!==d);i.push(c)}}return e.nodes().forEach(function(l){Object.hasOwn(r,l)||a(l)}),i}var yP=dp,_P=bP;function bP(e){return yP(e).filter(function(n){return n.length>1||n.length===1&&e.hasEdge(n[0],n[0])})}var wP=EP,kP=()=>1;function EP(e,n,o){return CP(e,n||kP,o||function(r){return e.outEdges(r)})}function CP(e,n,o){var r={},i=e.nodes();return i.forEach(function(a){r[a]={},r[a][a]={distance:0},i.forEach(function(l){a!==l&&(r[a][l]={distance:Number.POSITIVE_INFINITY})}),o(a).forEach(function(l){var s=l.v===a?l.w:l.v,c=n(l);r[a][s]={distance:c,predecessor:a}})}),i.forEach(function(a){var l=r[a];i.forEach(function(s){var c=r[s];i.forEach(function(d){var u=c[a],f=l[d],p=c[d],m=u.distance+f.distance;m<p.distance&&(p.distance=m,p.predecessor=f.predecessor)})})}),r}function up(e){var n={},o={},r=[];function i(a){if(Object.hasOwn(o,a))throw new $l;Object.hasOwn(n,a)||(o[a]=!0,n[a]=!0,e.predecessors(a).forEach(i),delete o[a],r.push(a))}if(e.sinks().forEach(i),Object.keys(n).length!==e.nodeCount())throw new $l;return r}class $l extends Error{constructor(){super(...arguments)}}var fp=up;up.CycleException=$l;var pp=fp,NP=vP;function vP(e){try{pp(e)}catch(n){if(n instanceof pp.CycleException)return!1;throw n}return!0}var mp=SP;function SP(e,n,o){Array.isArray(n)||(n=[n]);var r=e.isDirected()?s=>e.successors(s):s=>e.neighbors(s),i=o==="post"?xP:AP,a=[],l={};return n.forEach(s=>{if(!e.hasNode(s))throw new Error("Graph does not have node: "+s);i(s,r,l,a)}),a}function xP(e,n,o,r){for(var i=[[e,!1]];i.length>0;){var a=i.pop();a[1]?r.push(a[0]):Object.hasOwn(o,a[0])||(o[a[0]]=!0,i.push([a[0],!0]),gp(n(a[0]),l=>i.push([l,!1])))}}function AP(e,n,o,r){for(var i=[e];i.length>0;){var a=i.pop();Object.hasOwn(o,a)||(o[a]=!0,r.push(a),gp(n(a),l=>i.push(l)))}}function gp(e,n){for(var o=e.length;o--;)n(e[o],o,e);return e}var IP=mp,PP=TP;function TP(e,n){return IP(e,n,"post")}var OP=mp,$P=BP;function BP(e,n){return OP(e,n,"pre")}var VP=Ol,RP=sp,DP=MP;function MP(e,n){var o=new VP,r={},i=new RP,a;function l(c){var d=c.v===a?c.w:c.v,u=i.priority(d);if(u!==void 0){var f=n(c);f<u&&(r[d]=a,i.decrease(d,f))}}if(e.nodeCount()===0)return o;e.nodes().forEach(function(c){i.add(c,Number.POSITIVE_INFINITY),o.setNode(c)}),i.decrease(e.nodes()[0],0);for(var s=!1;i.size()>0;){if(a=i.removeMin(),Object.hasOwn(r,a))o.setEdge(a,r[a]);else{if(s)throw new Error("Input graph is not connected: "+e);s=!0}e.nodeEdges(a).forEach(l)}return o}var LP={components:lP,dijkstra:cp,dijkstraAll:mP,findCycles:_P,floydWarshall:wP,isAcyclic:NP,postorder:PP,preorder:$P,prim:DP,tarjan:dp,topsort:fp},hp=eP,kt={Graph:hp.Graph,json:nP,alg:LP,version:hp.version};let FP=class{constructor(){let n={};n._next=n._prev=n,this._sentinel=n}dequeue(){let n=this._sentinel,o=n._prev;if(o!==n)return yp(o),o}enqueue(n){let o=this._sentinel;n._prev&&n._next&&yp(n),n._next=o._next,o._next._prev=n,o._next=n,n._prev=o}toString(){let n=[],o=this._sentinel,r=o._prev;for(;r!==o;)n.push(JSON.stringify(r,UP)),r=r._prev;return"["+n.join(", ")+"]"}};function yp(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function UP(e,n){if(e!=="_next"&&e!=="_prev")return n}var KP=FP;let jP=kt.Graph,GP=KP;var qP=HP;let zP=()=>1;function HP(e,n){if(e.nodeCount()<=1)return[];let o=WP(e,n||zP);return YP(o.graph,o.buckets,o.zeroIdx).flatMap(i=>e.outEdges(i.v,i.w))}function YP(e,n,o){let r=[],i=n[n.length-1],a=n[0],l;for(;e.nodeCount();){for(;l=a.dequeue();)Bl(e,n,o,l);for(;l=i.dequeue();)Bl(e,n,o,l);if(e.nodeCount()){for(let s=n.length-2;s>0;--s)if(l=n[s].dequeue(),l){r=r.concat(Bl(e,n,o,l,!0));break}}}return r}function Bl(e,n,o,r,i){let a=i?[]:void 0;return e.inEdges(r.v).forEach(l=>{let s=e.edge(l),c=e.node(l.v);i&&a.push({v:l.v,w:l.w}),c.out-=s,Vl(n,o,c)}),e.outEdges(r.v).forEach(l=>{let s=e.edge(l),c=l.w,d=e.node(c);d.in-=s,Vl(n,o,d)}),e.removeNode(r.v),a}function WP(e,n){let o=new jP,r=0,i=0;e.nodes().forEach(s=>{o.setNode(s,{v:s,in:0,out:0})}),e.edges().forEach(s=>{let c=o.edge(s.v,s.w)||0,d=n(s),u=c+d;o.setEdge(s.v,s.w,u),i=Math.max(i,o.node(s.v).out+=d),r=Math.max(r,o.node(s.w).in+=d)});let a=XP(i+r+3).map(()=>new GP),l=r+1;return o.nodes().forEach(s=>{Vl(a,l,o.node(s))}),{graph:o,buckets:a,zeroIdx:l}}function Vl(e,n,o){o.out?o.in?e[o.out-o.in+n].enqueue(o):e[e.length-1].enqueue(o):e[0].enqueue(o)}function XP(e){const n=[];for(let o=0;o<e;o++)n.push(o);return n}let _p=kt.Graph;var qe={addBorderNode:iT,addDummyNode:bp,applyWithChunking:Ei,asNonCompoundGraph:JP,buildLayerMatrix:nT,intersectRect:tT,mapValues:fT,maxRank:kp,normalizeRanks:oT,notime:cT,partition:lT,pick:uT,predecessorWeights:eT,range:Cp,removeEmptyRanks:rT,simplify:ZP,successorWeights:QP,time:sT,uniqueId:Ep,zipObject:Rl};function bp(e,n,o,r){for(var i=r;e.hasNode(i);)i=Ep(r);return o.dummy=n,e.setNode(i,o),i}function ZP(e){let n=new _p().setGraph(e.graph());return e.nodes().forEach(o=>n.setNode(o,e.node(o))),e.edges().forEach(o=>{let r=n.edge(o.v,o.w)||{weight:0,minlen:1},i=e.edge(o);n.setEdge(o.v,o.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),n}function JP(e){let n=new _p({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(o=>{e.children(o).length||n.setNode(o,e.node(o))}),e.edges().forEach(o=>{n.setEdge(o,e.edge(o))}),n}function QP(e){let n=e.nodes().map(o=>{let r={};return e.outEdges(o).forEach(i=>{r[i.w]=(r[i.w]||0)+e.edge(i).weight}),r});return Rl(e.nodes(),n)}function eT(e){let n=e.nodes().map(o=>{let r={};return e.inEdges(o).forEach(i=>{r[i.v]=(r[i.v]||0)+e.edge(i).weight}),r});return Rl(e.nodes(),n)}function tT(e,n){let o=e.x,r=e.y,i=n.x-o,a=n.y-r,l=e.width/2,s=e.height/2;if(!i&&!a)throw new Error("Not possible to find intersection inside of the rectangle");let c,d;return Math.abs(a)*l>Math.abs(i)*s?(a<0&&(s=-s),c=s*i/a,d=s):(i<0&&(l=-l),c=l,d=l*a/i),{x:o+c,y:r+d}}function nT(e){let n=Cp(kp(e)+1).map(()=>[]);return e.nodes().forEach(o=>{let r=e.node(o),i=r.rank;i!==void 0&&(n[i][r.order]=o)}),n}function oT(e){let n=e.nodes().map(r=>{let i=e.node(r).rank;return i===void 0?Number.MAX_VALUE:i}),o=Ei(Math.min,n);e.nodes().forEach(r=>{let i=e.node(r);Object.hasOwn(i,"rank")&&(i.rank-=o)})}function rT(e){let n=e.nodes().map(l=>e.node(l).rank),o=Ei(Math.min,n),r=[];e.nodes().forEach(l=>{let s=e.node(l).rank-o;r[s]||(r[s]=[]),r[s].push(l)});let i=0,a=e.graph().nodeRankFactor;Array.from(r).forEach((l,s)=>{l===void 0&&s%a!==0?--i:l!==void 0&&i&&l.forEach(c=>e.node(c).rank+=i)})}function iT(e,n,o,r){let i={width:0,height:0};return arguments.length>=4&&(i.rank=o,i.order=r),bp(e,"border",i,n)}function aT(e,n=wp){const o=[];for(let r=0;r<e.length;r+=n){const i=e.slice(r,r+n);o.push(i)}return o}const wp=65535;function Ei(e,n){if(n.length>wp){const o=aT(n);return e.apply(null,o.map(r=>e.apply(null,r)))}else return e.apply(null,n)}function kp(e){const o=e.nodes().map(r=>{let i=e.node(r).rank;return i===void 0?Number.MIN_VALUE:i});return Ei(Math.max,o)}function lT(e,n){let o={lhs:[],rhs:[]};return e.forEach(r=>{n(r)?o.lhs.push(r):o.rhs.push(r)}),o}function sT(e,n){let o=Date.now();try{return n()}finally{console.log(e+" time: "+(Date.now()-o)+"ms")}}function cT(e,n){return n()}let dT=0;function Ep(e){var n=++dT;return e+(""+n)}function Cp(e,n,o=1){n==null&&(n=e,e=0);let r=a=>a<n;o<0&&(r=a=>n<a);const i=[];for(let a=e;r(a);a+=o)i.push(a);return i}function uT(e,n){const o={};for(const r of n)e[r]!==void 0&&(o[r]=e[r]);return o}function fT(e,n){let o=n;return typeof n=="string"&&(o=r=>r[n]),Object.entries(e).reduce((r,[i,a])=>(r[i]=o(a,i),r),{})}function Rl(e,n){return e.reduce((o,r,i)=>(o[r]=n[i],o),{})}let pT=qP,mT=qe.uniqueId;var gT={run:hT,undo:_T};function hT(e){(e.graph().acyclicer==="greedy"?pT(e,o(e)):yT(e)).forEach(r=>{let i=e.edge(r);e.removeEdge(r),i.forwardName=r.name,i.reversed=!0,e.setEdge(r.w,r.v,i,mT("rev"))});function o(r){return i=>r.edge(i).weight}}function yT(e){let n=[],o={},r={};function i(a){Object.hasOwn(r,a)||(r[a]=!0,o[a]=!0,e.outEdges(a).forEach(l=>{Object.hasOwn(o,l.w)?n.push(l):i(l.w)}),delete o[a])}return e.nodes().forEach(i),n}function _T(e){e.edges().forEach(n=>{let o=e.edge(n);if(o.reversed){e.removeEdge(n);let r=o.forwardName;delete o.reversed,delete o.forwardName,e.setEdge(n.w,n.v,o,r)}})}let bT=qe;var wT={run:kT,undo:CT};function kT(e){e.graph().dummyChains=[],e.edges().forEach(n=>ET(e,n))}function ET(e,n){let o=n.v,r=e.node(o).rank,i=n.w,a=e.node(i).rank,l=n.name,s=e.edge(n),c=s.labelRank;if(a===r+1)return;e.removeEdge(n);let d,u,f;for(f=0,++r;r<a;++f,++r)s.points=[],u={width:0,height:0,edgeLabel:s,edgeObj:n,rank:r},d=bT.addDummyNode(e,"edge",u,"_d"),r===c&&(u.width=s.width,u.height=s.height,u.dummy="edge-label",u.labelpos=s.labelpos),e.setEdge(o,d,{weight:s.weight},l),f===0&&e.graph().dummyChains.push(d),o=d;e.setEdge(o,i,{weight:s.weight},l)}function CT(e){e.graph().dummyChains.forEach(n=>{let o=e.node(n),r=o.edgeLabel,i;for(e.setEdge(o.edgeObj,r);o.dummy;)i=e.successors(n)[0],e.removeNode(n),r.points.push({x:o.x,y:o.y}),o.dummy==="edge-label"&&(r.x=o.x,r.y=o.y,r.width=o.width,r.height=o.height),n=i,o=e.node(n)})}const{applyWithChunking:NT}=qe;var Ci={longestPath:vT,slack:ST};function vT(e){var n={};function o(r){var i=e.node(r);if(Object.hasOwn(n,r))return i.rank;n[r]=!0;let a=e.outEdges(r).map(s=>s==null?Number.POSITIVE_INFINITY:o(s.w)-e.edge(s).minlen);var l=NT(Math.min,a);return l===Number.POSITIVE_INFINITY&&(l=0),i.rank=l}e.sources().forEach(o)}function ST(e,n){return e.node(n.w).rank-e.node(n.v).rank-e.edge(n).minlen}var xT=kt.Graph,Ni=Ci.slack,Np=AT;function AT(e){var n=new xT({directed:!1}),o=e.nodes()[0],r=e.nodeCount();n.setNode(o,{});for(var i,a;IT(n,e)<r;)i=PT(n,e),a=n.hasNode(i.v)?Ni(e,i):-Ni(e,i),TT(n,e,a);return n}function IT(e,n){function o(r){n.nodeEdges(r).forEach(i=>{var a=i.v,l=r===a?i.w:a;!e.hasNode(l)&&!Ni(n,i)&&(e.setNode(l,{}),e.setEdge(r,l,{}),o(l))})}return e.nodes().forEach(o),e.nodeCount()}function PT(e,n){return n.edges().reduce((r,i)=>{let a=Number.POSITIVE_INFINITY;return e.hasNode(i.v)!==e.hasNode(i.w)&&(a=Ni(n,i)),a<r[0]?[a,i]:r},[Number.POSITIVE_INFINITY,null])[1]}function TT(e,n,o){e.nodes().forEach(r=>n.node(r).rank+=o)}var OT=Np,vp=Ci.slack,$T=Ci.longestPath,BT=kt.alg.preorder,VT=kt.alg.postorder,RT=qe.simplify,DT=Nn;Nn.initLowLimValues=Ml,Nn.initCutValues=Dl,Nn.calcCutValue=Sp,Nn.leaveEdge=Ap,Nn.enterEdge=Ip,Nn.exchangeEdges=Pp;function Nn(e){e=RT(e),$T(e);var n=OT(e);Ml(n),Dl(n,e);for(var o,r;o=Ap(n);)r=Ip(n,e,o),Pp(n,e,o,r)}function Dl(e,n){var o=VT(e,e.nodes());o=o.slice(0,o.length-1),o.forEach(r=>MT(e,n,r))}function MT(e,n,o){var r=e.node(o),i=r.parent;e.edge(o,i).cutvalue=Sp(e,n,o)}function Sp(e,n,o){var r=e.node(o),i=r.parent,a=!0,l=n.edge(o,i),s=0;return l||(a=!1,l=n.edge(i,o)),s=l.weight,n.nodeEdges(o).forEach(c=>{var d=c.v===o,u=d?c.w:c.v;if(u!==i){var f=d===a,p=n.edge(c).weight;if(s+=f?p:-p,FT(e,o,u)){var m=e.edge(o,u).cutvalue;s+=f?-m:m}}}),s}function Ml(e,n){arguments.length<2&&(n=e.nodes()[0]),xp(e,{},1,n)}function xp(e,n,o,r,i){var a=o,l=e.node(r);return n[r]=!0,e.neighbors(r).forEach(s=>{Object.hasOwn(n,s)||(o=xp(e,n,o,s,r))}),l.low=a,l.lim=o++,i?l.parent=i:delete l.parent,o}function Ap(e){return e.edges().find(n=>e.edge(n).cutvalue<0)}function Ip(e,n,o){var r=o.v,i=o.w;n.hasEdge(r,i)||(r=o.w,i=o.v);var a=e.node(r),l=e.node(i),s=a,c=!1;a.lim>l.lim&&(s=l,c=!0);var d=n.edges().filter(u=>c===Tp(e,e.node(u.v),s)&&c!==Tp(e,e.node(u.w),s));return d.reduce((u,f)=>vp(n,f)<vp(n,u)?f:u)}function Pp(e,n,o,r){var i=o.v,a=o.w;e.removeEdge(i,a),e.setEdge(r.v,r.w,{}),Ml(e),Dl(e,n),LT(e,n)}function LT(e,n){var o=e.nodes().find(i=>!n.node(i).parent),r=BT(e,o);r=r.slice(1),r.forEach(i=>{var a=e.node(i).parent,l=n.edge(i,a),s=!1;l||(l=n.edge(a,i),s=!0),n.node(i).rank=n.node(a).rank+(s?l.minlen:-l.minlen)})}function FT(e,n,o){return e.hasEdge(n,o)}function Tp(e,n,o){return o.low<=n.lim&&n.lim<=o.lim}var UT=Ci,Op=UT.longestPath,KT=Np,jT=DT,GT=qT;function qT(e){var n=e.graph().ranker;if(n instanceof Function)return n(e);switch(e.graph().ranker){case"network-simplex":$p(e);break;case"tight-tree":HT(e);break;case"longest-path":zT(e);break;case"none":break;default:$p(e)}}var zT=Op;function HT(e){Op(e),KT(e)}function $p(e){jT(e)}var YT=WT;function WT(e){let n=ZT(e);e.graph().dummyChains.forEach(o=>{let r=e.node(o),i=r.edgeObj,a=XT(e,n,i.v,i.w),l=a.path,s=a.lca,c=0,d=l[c],u=!0;for(;o!==i.w;){if(r=e.node(o),u){for(;(d=l[c])!==s&&e.node(d).maxRank<r.rank;)c++;d===s&&(u=!1)}if(!u){for(;c<l.length-1&&e.node(d=l[c+1]).minRank<=r.rank;)c++;d=l[c]}e.setParent(o,d),o=e.successors(o)[0]}})}function XT(e,n,o,r){let i=[],a=[],l=Math.min(n[o].low,n[r].low),s=Math.max(n[o].lim,n[r].lim),c,d;c=o;do c=e.parent(c),i.push(c);while(c&&(n[c].low>l||s>n[c].lim));for(d=c,c=r;(c=e.parent(c))!==d;)a.push(c);return{path:i.concat(a.reverse()),lca:d}}function ZT(e){let n={},o=0;function r(i){let a=o;e.children(i).forEach(r),n[i]={low:a,lim:o++}}return e.children().forEach(r),n}let vi=qe;var JT={run:QT,cleanup:nO};function QT(e){let n=vi.addDummyNode(e,"root",{},"_root"),o=eO(e),r=Object.values(o),i=vi.applyWithChunking(Math.max,r)-1,a=2*i+1;e.graph().nestingRoot=n,e.edges().forEach(s=>e.edge(s).minlen*=a);let l=tO(e)+1;e.children().forEach(s=>Bp(e,n,a,l,i,o,s)),e.graph().nodeRankFactor=a}function Bp(e,n,o,r,i,a,l){let s=e.children(l);if(!s.length){l!==n&&e.setEdge(n,l,{weight:0,minlen:o});return}let c=vi.addBorderNode(e,"_bt"),d=vi.addBorderNode(e,"_bb"),u=e.node(l);e.setParent(c,l),u.borderTop=c,e.setParent(d,l),u.borderBottom=d,s.forEach(f=>{Bp(e,n,o,r,i,a,f);let p=e.node(f),m=p.borderTop?p.borderTop:f,h=p.borderBottom?p.borderBottom:f,y=p.borderTop?r:2*r,g=m!==h?1:i-a[l]+1;e.setEdge(c,m,{weight:y,minlen:g,nestingEdge:!0}),e.setEdge(h,d,{weight:y,minlen:g,nestingEdge:!0})}),e.parent(l)||e.setEdge(n,c,{weight:0,minlen:i+a[l]})}function eO(e){var n={};function o(r,i){var a=e.children(r);a&&a.length&&a.forEach(l=>o(l,i+1)),n[r]=i}return e.children().forEach(r=>o(r,1)),n}function tO(e){return e.edges().reduce((n,o)=>n+e.edge(o).weight,0)}function nO(e){var n=e.graph();e.removeNode(n.nestingRoot),delete n.nestingRoot,e.edges().forEach(o=>{var r=e.edge(o);r.nestingEdge&&e.removeEdge(o)})}let oO=qe;var rO=iO;function iO(e){function n(o){let r=e.children(o),i=e.node(o);if(r.length&&r.forEach(n),Object.hasOwn(i,"minRank")){i.borderLeft=[],i.borderRight=[];for(let a=i.minRank,l=i.maxRank+1;a<l;++a)Vp(e,"borderLeft","_bl",o,i,a),Vp(e,"borderRight","_br",o,i,a)}}e.children().forEach(n)}function Vp(e,n,o,r,i,a){let l={width:0,height:0,rank:a,borderType:n},s=i[n][a-1],c=oO.addDummyNode(e,"border",l,o);i[n][a]=c,e.setParent(c,r),s&&e.setEdge(s,c,{weight:1})}var aO={adjust:lO,undo:sO};function lO(e){let n=e.graph().rankdir.toLowerCase();(n==="lr"||n==="rl")&&Rp(e)}function sO(e){let n=e.graph().rankdir.toLowerCase();(n==="bt"||n==="rl")&&cO(e),(n==="lr"||n==="rl")&&(dO(e),Rp(e))}function Rp(e){e.nodes().forEach(n=>Dp(e.node(n))),e.edges().forEach(n=>Dp(e.edge(n)))}function Dp(e){let n=e.width;e.width=e.height,e.height=n}function cO(e){e.nodes().forEach(n=>Ll(e.node(n))),e.edges().forEach(n=>{let o=e.edge(n);o.points.forEach(Ll),Object.hasOwn(o,"y")&&Ll(o)})}function Ll(e){e.y=-e.y}function dO(e){e.nodes().forEach(n=>Fl(e.node(n))),e.edges().forEach(n=>{let o=e.edge(n);o.points.forEach(Fl),Object.hasOwn(o,"x")&&Fl(o)})}function Fl(e){let n=e.x;e.x=e.y,e.y=n}let Mp=qe;var uO=fO;function fO(e){let n={},o=e.nodes().filter(c=>!e.children(c).length),r=o.map(c=>e.node(c).rank),i=Mp.applyWithChunking(Math.max,r),a=Mp.range(i+1).map(()=>[]);function l(c){if(n[c])return;n[c]=!0;let d=e.node(c);a[d.rank].push(c),e.successors(c).forEach(l)}return o.sort((c,d)=>e.node(c).rank-e.node(d).rank).forEach(l),a}let pO=qe.zipObject;var mO=gO;function gO(e,n){let o=0;for(let r=1;r<n.length;++r)o+=hO(e,n[r-1],n[r]);return o}function hO(e,n,o){let r=pO(o,o.map((d,u)=>u)),i=n.flatMap(d=>e.outEdges(d).map(u=>({pos:r[u.w],weight:e.edge(u).weight})).sort((u,f)=>u.pos-f.pos)),a=1;for(;a<o.length;)a<<=1;let l=2*a-1;a-=1;let s=new Array(l).fill(0),c=0;return i.forEach(d=>{let u=d.pos+a;s[u]+=d.weight;let f=0;for(;u>0;)u%2&&(f+=s[u+1]),u=u-1>>1,s[u]+=d.weight;c+=d.weight*f}),c}var yO=_O;function _O(e,n=[]){return n.map(o=>{let r=e.inEdges(o);if(r.length){let i=r.reduce((a,l)=>{let s=e.edge(l),c=e.node(l.v);return{sum:a.sum+s.weight*c.order,weight:a.weight+s.weight}},{sum:0,weight:0});return{v:o,barycenter:i.sum/i.weight,weight:i.weight}}else return{v:o}})}let bO=qe;var wO=kO;function kO(e,n){let o={};e.forEach((i,a)=>{let l=o[i.v]={indegree:0,in:[],out:[],vs:[i.v],i:a};i.barycenter!==void 0&&(l.barycenter=i.barycenter,l.weight=i.weight)}),n.edges().forEach(i=>{let a=o[i.v],l=o[i.w];a!==void 0&&l!==void 0&&(l.indegree++,a.out.push(o[i.w]))});let r=Object.values(o).filter(i=>!i.indegree);return EO(r)}function EO(e){let n=[];function o(i){return a=>{a.merged||(a.barycenter===void 0||i.barycenter===void 0||a.barycenter>=i.barycenter)&&CO(i,a)}}function r(i){return a=>{a.in.push(i),--a.indegree===0&&e.push(a)}}for(;e.length;){let i=e.pop();n.push(i),i.in.reverse().forEach(o(i)),i.out.forEach(r(i))}return n.filter(i=>!i.merged).map(i=>bO.pick(i,["vs","i","barycenter","weight"]))}function CO(e,n){let o=0,r=0;e.weight&&(o+=e.barycenter*e.weight,r+=e.weight),n.weight&&(o+=n.barycenter*n.weight,r+=n.weight),e.vs=n.vs.concat(e.vs),e.barycenter=o/r,e.weight=r,e.i=Math.min(n.i,e.i),n.merged=!0}let NO=qe;var vO=SO;function SO(e,n){let o=NO.partition(e,u=>Object.hasOwn(u,"barycenter")),r=o.lhs,i=o.rhs.sort((u,f)=>f.i-u.i),a=[],l=0,s=0,c=0;r.sort(xO(!!n)),c=Lp(a,i,c),r.forEach(u=>{c+=u.vs.length,a.push(u.vs),l+=u.barycenter*u.weight,s+=u.weight,c=Lp(a,i,c)});let d={vs:a.flat(!0)};return s&&(d.barycenter=l/s,d.weight=s),d}function Lp(e,n,o){let r;for(;n.length&&(r=n[n.length-1]).i<=o;)n.pop(),e.push(r.vs),o++;return o}function xO(e){return(n,o)=>n.barycenter<o.barycenter?-1:n.barycenter>o.barycenter?1:e?o.i-n.i:n.i-o.i}let AO=yO,IO=wO,PO=vO;var TO=Fp;function Fp(e,n,o,r){let i=e.children(n),a=e.node(n),l=a?a.borderLeft:void 0,s=a?a.borderRight:void 0,c={};l&&(i=i.filter(p=>p!==l&&p!==s));let d=AO(e,i);d.forEach(p=>{if(e.children(p.v).length){let m=Fp(e,p.v,o,r);c[p.v]=m,Object.hasOwn(m,"barycenter")&&$O(p,m)}});let u=IO(d,o);OO(u,c);let f=PO(u,r);if(l&&(f.vs=[l,f.vs,s].flat(!0),e.predecessors(l).length)){let p=e.node(e.predecessors(l)[0]),m=e.node(e.predecessors(s)[0]);Object.hasOwn(f,"barycenter")||(f.barycenter=0,f.weight=0),f.barycenter=(f.barycenter*f.weight+p.order+m.order)/(f.weight+2),f.weight+=2}return f}function OO(e,n){e.forEach(o=>{o.vs=o.vs.flatMap(r=>n[r]?n[r].vs:r)})}function $O(e,n){e.barycenter!==void 0?(e.barycenter=(e.barycenter*e.weight+n.barycenter*n.weight)/(e.weight+n.weight),e.weight+=n.weight):(e.barycenter=n.barycenter,e.weight=n.weight)}let BO=kt.Graph,VO=qe;var RO=DO;function DO(e,n,o){let r=MO(e),i=new BO({compound:!0}).setGraph({root:r}).setDefaultNodeLabel(a=>e.node(a));return e.nodes().forEach(a=>{let l=e.node(a),s=e.parent(a);(l.rank===n||l.minRank<=n&&n<=l.maxRank)&&(i.setNode(a),i.setParent(a,s||r),e[o](a).forEach(c=>{let d=c.v===a?c.w:c.v,u=i.edge(d,a),f=u!==void 0?u.weight:0;i.setEdge(d,a,{weight:e.edge(c).weight+f})}),Object.hasOwn(l,"minRank")&&i.setNode(a,{borderLeft:l.borderLeft[n],borderRight:l.borderRight[n]}))}),i}function MO(e){for(var n;e.hasNode(n=VO.uniqueId("_root")););return n}var LO=FO;function FO(e,n,o){let r={},i;o.forEach(a=>{let l=e.parent(a),s,c;for(;l;){if(s=e.parent(l),s?(c=r[s],r[s]=l):(c=i,i=l),c&&c!==l){n.setEdge(c,l);return}l=s}})}let UO=uO,KO=mO,jO=TO,GO=RO,qO=LO,zO=kt.Graph,Si=qe;var HO=Up;function Up(e,n){if(n&&typeof n.customOrder=="function"){n.customOrder(e,Up);return}let o=Si.maxRank(e),r=Kp(e,Si.range(1,o+1),"inEdges"),i=Kp(e,Si.range(o-1,-1,-1),"outEdges"),a=UO(e);if(jp(e,a),n&&n.disableOptimalOrderHeuristic)return;let l=Number.POSITIVE_INFINITY,s;for(let c=0,d=0;d<4;++c,++d){YO(c%2?r:i,c%4>=2),a=Si.buildLayerMatrix(e);let u=KO(e,a);u<l&&(d=0,s=Object.assign({},a),l=u)}jp(e,s)}function Kp(e,n,o){return n.map(function(r){return GO(e,r,o)})}function YO(e,n){let o=new zO;e.forEach(function(r){let i=r.graph().root,a=jO(r,i,o,n);a.vs.forEach((l,s)=>r.node(l).order=s),qO(r,o,a.vs)})}function jp(e,n){Object.values(n).forEach(o=>o.forEach((r,i)=>e.node(r).order=i))}let WO=kt.Graph,qt=qe;var XO={positionX:l$};function ZO(e,n){let o={};function r(i,a){let l=0,s=0,c=i.length,d=a[a.length-1];return a.forEach((u,f)=>{let p=QO(e,u),m=p?e.node(p).order:c;(p||u===d)&&(a.slice(s,f+1).forEach(h=>{e.predecessors(h).forEach(y=>{let g=e.node(y),_=g.order;(_<l||m<_)&&!(g.dummy&&e.node(h).dummy)&&Gp(o,y,h)})}),s=f+1,l=m)}),a}return n.length&&n.reduce(r),o}function JO(e,n){let o={};function r(a,l,s,c,d){let u;qt.range(l,s).forEach(f=>{u=a[f],e.node(u).dummy&&e.predecessors(u).forEach(p=>{let m=e.node(p);m.dummy&&(m.order<c||m.order>d)&&Gp(o,p,u)})})}function i(a,l){let s=-1,c,d=0;return l.forEach((u,f)=>{if(e.node(u).dummy==="border"){let p=e.predecessors(u);p.length&&(c=e.node(p[0]).order,r(l,d,f,s,c),d=f,s=c)}r(l,d,l.length,c,a.length)}),l}return n.length&&n.reduce(i),o}function QO(e,n){if(e.node(n).dummy)return e.predecessors(n).find(o=>e.node(o).dummy)}function Gp(e,n,o){if(n>o){let i=n;n=o,o=i}let r=e[n];r||(e[n]=r={}),r[o]=!0}function e$(e,n,o){if(n>o){let r=n;n=o,o=r}return!!e[n]&&Object.hasOwn(e[n],o)}function t$(e,n,o,r){let i={},a={},l={};return n.forEach(s=>{s.forEach((c,d)=>{i[c]=c,a[c]=c,l[c]=d})}),n.forEach(s=>{let c=-1;s.forEach(d=>{let u=r(d);if(u.length){u=u.sort((p,m)=>l[p]-l[m]);let f=(u.length-1)/2;for(let p=Math.floor(f),m=Math.ceil(f);p<=m;++p){let h=u[p];a[d]===d&&c<l[h]&&!e$(o,d,h)&&(a[h]=d,a[d]=i[d]=i[h],c=l[h])}}})}),{root:i,align:a}}function n$(e,n,o,r,i){let a={},l=o$(e,n,o,i),s=i?"borderLeft":"borderRight";function c(f,p){let m=l.nodes(),h=m.pop(),y={};for(;h;)y[h]?f(h):(y[h]=!0,m.push(h),m=m.concat(p(h))),h=m.pop()}function d(f){a[f]=l.inEdges(f).reduce((p,m)=>Math.max(p,a[m.v]+l.edge(m)),0)}function u(f){let p=l.outEdges(f).reduce((h,y)=>Math.min(h,a[y.w]-l.edge(y)),Number.POSITIVE_INFINITY),m=e.node(f);p!==Number.POSITIVE_INFINITY&&m.borderType!==s&&(a[f]=Math.max(a[f],p))}return c(d,l.predecessors.bind(l)),c(u,l.successors.bind(l)),Object.keys(r).forEach(f=>a[f]=a[o[f]]),a}function o$(e,n,o,r){let i=new WO,a=e.graph(),l=s$(a.nodesep,a.edgesep,r);return n.forEach(s=>{let c;s.forEach(d=>{let u=o[d];if(i.setNode(u),c){var f=o[c],p=i.edge(f,u);i.setEdge(f,u,Math.max(l(e,d,c),p||0))}c=d})}),i}function r$(e,n){return Object.values(n).reduce((o,r)=>{let i=Number.NEGATIVE_INFINITY,a=Number.POSITIVE_INFINITY;Object.entries(r).forEach(([s,c])=>{let d=c$(e,s)/2;i=Math.max(c+d,i),a=Math.min(c-d,a)});const l=i-a;return l<o[0]&&(o=[l,r]),o},[Number.POSITIVE_INFINITY,null])[1]}function i$(e,n){let o=Object.values(n),r=qt.applyWithChunking(Math.min,o),i=qt.applyWithChunking(Math.max,o);["u","d"].forEach(a=>{["l","r"].forEach(l=>{let s=a+l,c=e[s];if(c===n)return;let d=Object.values(c),u=r-qt.applyWithChunking(Math.min,d);l!=="l"&&(u=i-qt.applyWithChunking(Math.max,d)),u&&(e[s]=qt.mapValues(c,f=>f+u))})})}function a$(e,n){return qt.mapValues(e.ul,(o,r)=>{if(n)return e[n.toLowerCase()][r];{let i=Object.values(e).map(a=>a[r]).sort((a,l)=>a-l);return(i[1]+i[2])/2}})}function l$(e){let n=qt.buildLayerMatrix(e),o=Object.assign(ZO(e,n),JO(e,n)),r={},i;["u","d"].forEach(l=>{i=l==="u"?n:Object.values(n).reverse(),["l","r"].forEach(s=>{s==="r"&&(i=i.map(f=>Object.values(f).reverse()));let c=(l==="u"?e.predecessors:e.successors).bind(e),d=t$(e,i,o,c),u=n$(e,i,d.root,d.align,s==="r");s==="r"&&(u=qt.mapValues(u,f=>-f)),r[l+s]=u})});let a=r$(e,r);return i$(r,a),a$(r,e.graph().align)}function s$(e,n,o){return(r,i,a)=>{let l=r.node(i),s=r.node(a),c=0,d;if(c+=l.width/2,Object.hasOwn(l,"labelpos"))switch(l.labelpos.toLowerCase()){case"l":d=-l.width/2;break;case"r":d=l.width/2;break}if(d&&(c+=o?d:-d),d=0,c+=(l.dummy?n:e)/2,c+=(s.dummy?n:e)/2,c+=s.width/2,Object.hasOwn(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":d=s.width/2;break;case"r":d=-s.width/2;break}return d&&(c+=o?d:-d),d=0,c}}function c$(e,n){return e.node(n).width}let qp=qe,d$=XO.positionX;var u$=f$;function f$(e){e=qp.asNonCompoundGraph(e),p$(e),Object.entries(d$(e)).forEach(([n,o])=>e.node(n).x=o)}function p$(e){let n=qp.buildLayerMatrix(e),o=e.graph().ranksep,r=0;n.forEach(i=>{const a=i.reduce((l,s)=>{const c=e.node(s).height;return l>c?l:c},0);i.forEach(l=>e.node(l).y=r+a/2),r+=a+o})}let zp=gT,Hp=wT,m$=GT,g$=qe.normalizeRanks,h$=YT,y$=qe.removeEmptyRanks,Yp=JT,_$=rO,Wp=aO,b$=HO,w$=u$,mt=qe,k$=kt.Graph;var E$=C$;function C$(e,n){let o=n&&n.debugTiming?mt.time:mt.notime;o("layout",()=>{let r=o(" buildLayoutGraph",()=>$$(e));o(" runLayout",()=>N$(r,o,n)),o(" updateInputGraph",()=>v$(e,r))})}function N$(e,n,o){n(" makeSpaceForEdgeLabels",()=>B$(e)),n(" removeSelfEdges",()=>j$(e)),n(" acyclic",()=>zp.run(e)),n(" nestingGraph.run",()=>Yp.run(e)),n(" rank",()=>m$(mt.asNonCompoundGraph(e))),n(" injectEdgeLabelProxies",()=>V$(e)),n(" removeEmptyRanks",()=>y$(e)),n(" nestingGraph.cleanup",()=>Yp.cleanup(e)),n(" normalizeRanks",()=>g$(e)),n(" assignRankMinMax",()=>R$(e)),n(" removeEdgeLabelProxies",()=>D$(e)),n(" normalize.run",()=>Hp.run(e)),n(" parentDummyChains",()=>h$(e)),n(" addBorderSegments",()=>_$(e)),n(" order",()=>b$(e,o)),n(" insertSelfEdges",()=>G$(e)),n(" adjustCoordinateSystem",()=>Wp.adjust(e)),n(" position",()=>w$(e)),n(" positionSelfEdges",()=>q$(e)),n(" removeBorderNodes",()=>K$(e)),n(" normalize.undo",()=>Hp.undo(e)),n(" fixupEdgeLabelCoords",()=>F$(e)),n(" undoCoordinateSystem",()=>Wp.undo(e)),n(" translateGraph",()=>M$(e)),n(" assignNodeIntersects",()=>L$(e)),n(" reversePoints",()=>U$(e)),n(" acyclic.undo",()=>zp.undo(e))}function v$(e,n){e.nodes().forEach(o=>{let r=e.node(o),i=n.node(o);r&&(r.x=i.x,r.y=i.y,r.rank=i.rank,n.children(o).length&&(r.width=i.width,r.height=i.height))}),e.edges().forEach(o=>{let r=e.edge(o),i=n.edge(o);r.points=i.points,Object.hasOwn(i,"x")&&(r.x=i.x,r.y=i.y)}),e.graph().width=n.graph().width,e.graph().height=n.graph().height}let S$=["nodesep","edgesep","ranksep","marginx","marginy"],x$={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},A$=["acyclicer","ranker","rankdir","align"],I$=["width","height","rank"],Xp={width:0,height:0},P$=["minlen","weight","width","height","labeloffset"],T$={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},O$=["labelpos"];function $$(e){let n=new k$({multigraph:!0,compound:!0}),o=Kl(e.graph());return n.setGraph(Object.assign({},x$,Ul(o,S$),mt.pick(o,A$))),e.nodes().forEach(r=>{let i=Kl(e.node(r));const a=Ul(i,I$);Object.keys(Xp).forEach(l=>{a[l]===void 0&&(a[l]=Xp[l])}),n.setNode(r,a),n.setParent(r,e.parent(r))}),e.edges().forEach(r=>{let i=Kl(e.edge(r));n.setEdge(r,Object.assign({},T$,Ul(i,P$),mt.pick(i,O$)))}),n}function B$(e){let n=e.graph();n.ranksep/=2,e.edges().forEach(o=>{let r=e.edge(o);r.minlen*=2,r.labelpos.toLowerCase()!=="c"&&(n.rankdir==="TB"||n.rankdir==="BT"?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function V$(e){e.edges().forEach(n=>{let o=e.edge(n);if(o.width&&o.height){let r=e.node(n.v),a={rank:(e.node(n.w).rank-r.rank)/2+r.rank,e:n};mt.addDummyNode(e,"edge-proxy",a,"_ep")}})}function R$(e){let n=0;e.nodes().forEach(o=>{let r=e.node(o);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,n=Math.max(n,r.maxRank))}),e.graph().maxRank=n}function D$(e){e.nodes().forEach(n=>{let o=e.node(n);o.dummy==="edge-proxy"&&(e.edge(o.e).labelRank=o.rank,e.removeNode(n))})}function M$(e){let n=Number.POSITIVE_INFINITY,o=0,r=Number.POSITIVE_INFINITY,i=0,a=e.graph(),l=a.marginx||0,s=a.marginy||0;function c(d){let u=d.x,f=d.y,p=d.width,m=d.height;n=Math.min(n,u-p/2),o=Math.max(o,u+p/2),r=Math.min(r,f-m/2),i=Math.max(i,f+m/2)}e.nodes().forEach(d=>c(e.node(d))),e.edges().forEach(d=>{let u=e.edge(d);Object.hasOwn(u,"x")&&c(u)}),n-=l,r-=s,e.nodes().forEach(d=>{let u=e.node(d);u.x-=n,u.y-=r}),e.edges().forEach(d=>{let u=e.edge(d);u.points.forEach(f=>{f.x-=n,f.y-=r}),Object.hasOwn(u,"x")&&(u.x-=n),Object.hasOwn(u,"y")&&(u.y-=r)}),a.width=o-n+l,a.height=i-r+s}function L$(e){e.edges().forEach(n=>{let o=e.edge(n),r=e.node(n.v),i=e.node(n.w),a,l;o.points?(a=o.points[0],l=o.points[o.points.length-1]):(o.points=[],a=i,l=r),o.points.unshift(mt.intersectRect(r,a)),o.points.push(mt.intersectRect(i,l))})}function F$(e){e.edges().forEach(n=>{let o=e.edge(n);if(Object.hasOwn(o,"x"))switch((o.labelpos==="l"||o.labelpos==="r")&&(o.width-=o.labeloffset),o.labelpos){case"l":o.x-=o.width/2+o.labeloffset;break;case"r":o.x+=o.width/2+o.labeloffset;break}})}function U$(e){e.edges().forEach(n=>{let o=e.edge(n);o.reversed&&o.points.reverse()})}function K$(e){e.nodes().forEach(n=>{if(e.children(n).length){let o=e.node(n),r=e.node(o.borderTop),i=e.node(o.borderBottom),a=e.node(o.borderLeft[o.borderLeft.length-1]),l=e.node(o.borderRight[o.borderRight.length-1]);o.width=Math.abs(l.x-a.x),o.height=Math.abs(i.y-r.y),o.x=a.x+o.width/2,o.y=r.y+o.height/2}}),e.nodes().forEach(n=>{e.node(n).dummy==="border"&&e.removeNode(n)})}function j$(e){e.edges().forEach(n=>{if(n.v===n.w){var o=e.node(n.v);o.selfEdges||(o.selfEdges=[]),o.selfEdges.push({e:n,label:e.edge(n)}),e.removeEdge(n)}})}function G$(e){var n=mt.buildLayerMatrix(e);n.forEach(o=>{var r=0;o.forEach((i,a)=>{var l=e.node(i);l.order=a+r,(l.selfEdges||[]).forEach(s=>{mt.addDummyNode(e,"selfedge",{width:s.label.width,height:s.label.height,rank:l.rank,order:a+ ++r,e:s.e,label:s.label},"_se")}),delete l.selfEdges})})}function q$(e){e.nodes().forEach(n=>{var o=e.node(n);if(o.dummy==="selfedge"){var r=e.node(o.e.v),i=r.x+r.width/2,a=r.y,l=o.x-i,s=r.height/2;e.setEdge(o.e,o.label),e.removeNode(n),o.label.points=[{x:i+2*l/3,y:a-s},{x:i+5*l/6,y:a-s},{x:i+l,y:a},{x:i+5*l/6,y:a+s},{x:i+2*l/3,y:a+s}],o.label.x=o.x,o.label.y=o.y}})}function Ul(e,n){return mt.mapValues(mt.pick(e,n),Number)}function Kl(e){var n={};return e&&Object.entries(e).forEach(([o,r])=>{typeof o=="string"&&(o=o.toLowerCase()),n[o]=r}),n}let z$=qe,H$=kt.Graph;var Y$={debugOrdering:W$};function W$(e){let n=z$.buildLayerMatrix(e),o=new H$({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(r=>{o.setNode(r,{label:r}),o.setParent(r,"layer"+e.node(r).rank)}),e.edges().forEach(r=>o.setEdge(r.v,r.w,{},r.name)),n.forEach((r,i)=>{let a="layer"+i;o.setNode(a,{rank:"same"}),r.reduce((l,s)=>(o.setEdge(l,s,{style:"invis"}),s))}),o}var X$="1.1.5",Z$={graphlib:kt,layout:E$,debug:Y$,util:{time:qe.time,notime:qe.notime},version:X$};const Zp=WI(Z$);function J$(){const e=(...o)=>{console.warn("TOASTER_PROVIDER is not provided",...o)},n=t.inject(Ec,e);return o=>n(o)}function xi(e,n,o){const r=n?Wt(e,o,n):void 0;return`${e.name}${r?`.${r.name}`:""}`}function Yo(e,n){const o=n(e.source),r=n(e.target);return[xi(o,e.sourceField,"output"),xi(r,e.targetField,"input")]}function jl(e,n,o,r,i){const a=i(e),l=i(o);return[xi(a,n,"output"),xi(l,r,"input")]}function Q$(e){t.provide(op,e)}function Jp(){return t.inject(op,void 0)}function eB(){const e=Jp();if(!e)throw new Error("Confirm modal not provided");return e}function Qp(e){const n=e.match(/^(input|output)s@(.*)$/);if(n)return{io:n[1],field:n[2]}}function tB(){const e={x1:Number.POSITIVE_INFINITY,y1:Number.POSITIVE_INFINITY,x2:Number.NEGATIVE_INFINITY,y2:Number.NEGATIVE_INFINITY};return[r=>{e.x1=Math.min(e.x1,r.x),e.y1=Math.min(e.y1,r.y),e.x2=Math.max(e.x2,r.x+r.width),e.y2=Math.max(e.y2,r.y+r.height)},()=>{const r={...e};return r.x1>r.x2&&(r.x1=r.x2=0),r.y1>r.y2&&(r.y1=r.y2=0),r}]}const nB={default:lk,hover:ck,selected:sk};let em,Gl;function Ai(e){const n=e.id===em?"selected":e.id===Gl?"hover":"default",o=nB[n],{markerEnd:r}=e,i=typeof r=="object"?{...r,color:o}:{type:r,color:o};return{...e,style:{...e.style,stroke:o,strokeWidth:n==="selected"?1.5:void 0},markerEnd:i,zIndex:n==="default"?void 0:1}}const[oB,rB]=Ue.createInjectionState(function(e){const{phase:n,flowId:o,layoutOptions:r,readonly:i}=e,{viewport:a,padding:l=Go.padding,gaps:s=Go.gaps}=r,{nodes:c=Go.gaps.nodes,edges:d=Go.gaps.edges,ranks:u=Go.gaps.ranks}=s,f=Oe(o),p=st(),m=Jp(),h=J$(),{i18n:{t:y}}=xe(),{findNode:g,fitView:_,deleteKeyCode:w,onNodeClick:b,onNodeDragStop:v,onEdgeClick:N,onConnect:E,onNodesChange:S,onEdgesChange:P,onEdgeUpdate:B,onEdgeMouseEnter:j,onEdgeMouseLeave:G,setEdges:T}=f;w.value=["Delete","Backspace"];const{state:Y,commit:I,moveNode:M,selectNode:R,removeNode:te,getNodeById:z,connectEdge:H,disconnectEdge:L,getInEdgesByNodeId:F,commit:Z,reset:Q}=p;function W(q,ee){const O=z(q.source),k=z(q.target);return!!(O&&k&&O.phase===ee&&k.phase===ee)}const ie=t.computed(()=>Y.value.nodes.filter(q=>q.phase===n).map(q=>({id:q.id,type:"flow",position:q.position,data:q,deletable:!Jd(q)}))),ae=t.computed(()=>Y.value.edges.filter(q=>W(q,n)).map(q=>{const ee=z(q.source),O=z(q.target);if(ee){if(!O)throw new Error(`Missing target node "${q.target}" for edge "${q.id}" in phase "${n}"`)}else throw new Error(`Missing source node "${q.source}" for edge "${q.id}" in phase "${n}"`);return Ai({id:q.id,source:q.source,target:q.target,sourceHandle:q.sourceField?`outputs@${q.sourceField}`:"output",targetHandle:q.targetField?`inputs@${q.targetField}`:"input",markerEnd:ii.ArrowClosed,data:q,updatable:!i})})),me=t.computed(()=>({padding:l/Math.max(t.toValue(a==null?void 0:a.width)??0,t.toValue(a==null?void 0:a.height)??0)}));b(({node:q})=>{console.debug("[useFlow] onNodeClick",t.toRaw(q))}),N(({edge:q})=>{console.debug("[useFlow] onEdgeClick",t.toRaw(q))});async function ge({source:q,sourceHandle:ee,target:O,targetHandle:k}){if(console.debug("[useFlow] onConnect",{source:q,sourceHandle:ee,target:O,targetHandle:k}),!ee||!k)return;const C=Qp(ee),x=Qp(k);if((C==null?void 0:C.io)==="input"||(x==null?void 0:x.io)==="output"||ee==="output"&&k==="output")return;const A=F(O);let U=!1,V=!1;const J=[],$=[],X=(x==null?void 0:x.io)==="input"?A.filter(le=>!le.targetField):A.filter(le=>!!le.targetField);X.length>0&&(U=!0,X.forEach(le=>{$.push(Yo(le,z)),L(le.id,!1)}));const D=(x==null?void 0:x.io)==="input"?A.filter(le=>le.targetField===x.field):A.filter(le=>!le.targetField);if(D.length>0){if(D.some(_e=>_e.source===q&&_e.target===O&&_e.targetField===(x==null?void 0:x.field)&&_e.sourceField===(C==null?void 0:C.field)))return;V=!0,D.forEach(_e=>{$.push(Yo(_e,z)),L(_e.id,!1)})}if(!H({source:q,sourceField:C==null?void 0:C.field,target:O,targetField:x==null?void 0:x.field},!1)){Q(),h({message:y("plugins.free-form.datakit.flow_editor.error.invalid_connection"),appearance:"danger"});return}if(J.push(jl(q,C==null?void 0:C.field,O,x==null?void 0:x.field,z)),U||V){if(!m)throw Q(),new Error("Expected confirm modal to be provided here when reachable");if(!await m(y(U?"plugins.free-form.datakit.flow_editor.confirm.message.switch":"plugins.free-form.datakit.flow_editor.confirm.message.override"),J,$)){Q();return}}Z()}E(ge),S(q=>{q.filter(ee=>ee.type==="select").sort((ee,O)=>ee.selected===O.selected?0:ee.selected?1:-1).forEach(ee=>{R(ee.selected?ee.id:void 0)}),q.forEach(ee=>{ee.type==="remove"&&te(ee.id,!0)})}),v(({node:q})=>{q&&M(q.id,q.position)}),P(q=>{q.filter(O=>O.type==="select").sort((O,k)=>O.selected===k.selected?0:O.selected?1:-1).forEach(O=>{em=O.selected?O.id:void 0,T(k=>k.map(C=>C.id!==O.id||!C.markerEnd?C:Ai({...C,zIndex:O.selected?1:void 0})))}),q.forEach(O=>{O.type==="remove"&&L(O.id,!0)})}),j(({edge:q})=>{Gl=q.id,T(ee=>ee.map(O=>O.id!==q.id?O:Ai(O)))}),G(({edge:q})=>{Gl=void 0,T(ee=>ee.map(O=>O.id!==q.id?O:Ai(O)))}),B(({edge:q,connection:ee})=>{L(q.id,!1),ge(ee)});function ne(q=!0){let ee,O;const k=[],C=fe=>{switch(fe.data.name){case"request":{if(n!=="request")throw new Error(`Unexpected request node in ${n} phase`);if(ee)throw new Error("Duplicated request node in request phase");return ee=fe,!0}case"service_request":{if(n!=="request")throw new Error(`Unexpected service_request node in ${n} phase`);if(O)throw new Error("Duplicated service_request node in request phase");return O=fe,!0}case"service_response":{if(n!=="response")throw new Error(`Unexpected service_response node in ${n} phase`);if(O)throw new Error("Duplicated service_response node in response phase");return O=fe,!0}case"response":{if(n!=="response")throw new Error(`Unexpected response node in ${n} phase`);if(ee)throw new Error("Duplicated response node in response phase");return ee=fe,!0}default:return k.push(fe),!1}};let x;for(const fe of ie.value)if(!C(fe)&&k.length>0){x||(x=new Zp.graphlib.Graph({multigraph:!0}),x.setGraph({rankdir:n==="request"?"LR":"RL",nodesep:c,edgesep:d,ranksep:u}));const oe=g(fe.id);if(!oe)throw new Error(`Node ${fe.id} is missing from the graph in ${n} phase`);x.setNode(fe.id,{width:oe.dimensions.width,height:oe.dimensions.height})}if(!ee||!O)throw new Error(`One or more implicit nodes are missing from ${n} phase`);const A=g(ee.id),U=g(O.id);if(!A||!U)throw new Error(`One or more implicit nodes are missing from the graph in ${n} phase`);if(k.length>0){if(!x)throw new Error("dagreGraph should be defined here if reachable");const fe=new Set([ee.id,O.id]);for(const oe of ae.value)!fe.has(oe.source)&&!fe.has(oe.target)&&x.setEdge(oe.source,oe.target,{points:[]});Zp.layout(x)}const[V,J]=tB(),$=fe=>({x:fe.x-fe.width/2,y:fe.y-fe.height/2,width:fe.width,height:fe.height});if(k.length>0){if(!x)throw new Error("dagreGraph should be defined here if reachable");for(const fe of k){const oe=x.node(fe.id),be=$(oe);V(be),M(fe.data.id,{x:be.x,y:be.y},!1)}}const X=J(),D=X.x2-X.x1,pe=X.y2-X.y1,le=Math.max(0,Math.min(t.toValue(a==null?void 0:a.width)??Number.POSITIVE_INFINITY,zI)-D-2*c-A.dimensions.width-U.dimensions.width-2*l),_e=X.y1+pe/2;M(ee.data.id,{x:X.x1-c-le/2-A.dimensions.width,y:_e-A.dimensions.height/2},!1),M(O.data.id,{x:X.x2+c+le/2,y:_e-U.dimensions.height/2},!1),q&&I(`autolayout-${o}`)}function re(q){_({...me.value,...q})}return{vueFlowStore:f,editorStore:p,readonly:i,nodes:ie,edges:ae,autoLayout:ne,fitViewParams:me,fitView:re}}),Ii=Ee(t.defineComponent({__name:"HandleTwig",props:{color:{},position:{default:()=>ye.Left},size:{default:()=>Number.parseFloat(fk)},type:{}},setup(e){t.useCssVars(o=>({"753622c4":o.color}));const n=t.computed(()=>({width:`${e.size}px`,minWidth:`${e.size}px`}));return(o,r)=>(t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["handle-twig",[o.type,o.position===t.unref(ye).Left?"left":"right"]]),style:t.normalizeStyle(n.value)},null,6))}}),[["__scopeId","data-v-eb2bc3f2"]]),tm=Ee(t.defineComponent({__name:"NodeBadge",props:{type:{},size:{},iconOnly:{type:Boolean}},setup(e){const n=t.computed(()=>{var i;if(!Lt(e.type))return((i=Tr[e.type])==null?void 0:i.icon)??void 0}),o=t.computed(()=>eN(e.type)),r=t.computed(()=>{switch(e.type){case"call":return"warning";case"jq":return"decorative";case"exit":return"danger";case"property":return"success";case"static":return"info";default:return"neutral"}});return(i,a)=>{const l=t.resolveComponent("KBadge");return t.openBlock(),t.createBlock(l,{appearance:r.value,class:t.normalizeClass({"icon-only":i.iconOnly}),size:i.size},{icon:t.withCtx(()=>[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(n.value)))]),default:t.withCtx(()=>[t.createTextVNode(" "+t.toDisplayString(o.value),1)]),_:1},8,["appearance","class","size"])}}}),[["__scopeId","data-v-aae106a9"]]);let Qn=null;function nm(){var n;if(Qn)return Qn;if(typeof navigator>"u")return Qn="windows";const e=((n=navigator.userAgentData)==null?void 0:n.platform)||navigator.platform||navigator.userAgent;return/Mac|iPhone|iPad|iPod/i.test(e)?Qn="mac":/Linux/i.test(e)&&!/Android/i.test(e)?Qn="linux":Qn="windows"}const iB={Shift:"⇧",Alt:"⌥",Ctrl:"⌃",Meta:"⌘",Mod:"⌘",Enter:"↩",ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Tab:"⇥",Esc:"⎋",Space:"Space",Delete:"⌫"},aB={Shift:"Shift",Alt:"Alt",Ctrl:"Ctrl",Meta:"Win",Mod:"Ctrl",Enter:"Enter",ArrowUp:"Up",ArrowDown:"Down",ArrowLeft:"Left",ArrowRight:"Right",Tab:"Tab",Esc:"Esc",Space:"Spacebar",Delete:"Delete"},lB={Shift:"Shift",Alt:"Alt",Ctrl:"Ctrl",Meta:"Super",Mod:"Ctrl",Enter:"Enter",ArrowUp:"Up",ArrowDown:"Down",ArrowLeft:"Left",ArrowRight:"Right",Tab:"Tab",Esc:"Esc",Space:"Space",Delete:"Delete"};function sB(e,n={}){const o=n.platform??nm(),r=n.joiner??(o==="mac"?"":" + "),i=o==="mac"?iB:o==="linux"?lB:aB;return(Array.isArray(e)?e:e[o]).map(l=>l in i?i[l]:l).join(r)}const cB={key:0,class:"label"},dB={class:"keys"},ql=Ee(t.defineComponent({__name:"HotkeyLabel",props:{label:{},keys:{},reverse:{type:Boolean}},setup(e){const n=sB(e.keys);return(o,r)=>(t.openBlock(),t.createElementBlock("span",{class:t.normalizeClass(["dk-hotkey-label",{reverse:o.reverse}])},[o.label?(t.openBlock(),t.createElementBlock("span",cB,t.toDisplayString(o.label),1)):t.createCommentVNode("",!0),t.createElementVNode("kbd",dB,t.toDisplayString(t.unref(n)),1)],2))}}),[["__scopeId","data-v-cc70d56b"]]),uB={class:"body"},fB={class:"name"},pB={class:"handle"},mB={class:"handle-label-wrapper"},gB={class:"handle-label-wrapper"},hB={class:"handle-label text"},yB={class:"handle"},_B={class:"handle-label-wrapper"},bB={class:"handle-label-wrapper"},wB={class:"handle-label text"},om=Ee(t.defineComponent({__name:"FlowNode",props:{data:{},error:{type:Boolean}},setup(e){const{t:n}=Fe.createI18n("en-us",He),o=rB(),{getInEdgesByNodeId:r,getOutEdgesByNodeId:i,toggleExpanded:a,removeNode:l}=st(),s=t.computed(()=>La(e.data.type)),c=t.computed(()=>e.data.fields.input.length>0),d=t.computed(()=>e.data.fields.output.length>0),u=t.computed(()=>c.value&&r(e.data.id).every(S=>S.targetField===void 0)),f=t.computed(()=>d.value&&i(e.data.id).every(S=>S.sourceField===void 0)),p=t.computed(()=>e.data.expanded.input??!1),m=t.computed(()=>e.data.expanded.output??!1),h=t.computed(()=>{var S,P;if(e.data.type==="property"){const B=(S=e.data.config)==null?void 0:S.property;return Pl(B)}return(P=s.value.io)==null?void 0:P.input}),y=t.computed(()=>{var S,P;if(e.data.type==="property"){const B=(S=e.data.config)==null?void 0:S.property;return Il(B)}return(P=s.value.io)==null?void 0:P.output}),g=t.computed(()=>Jd(e.data)),_=t.computed(()=>e.data.phase==="response"),w=t.computed(()=>e.data.phase==="request"?ye.Left:ye.Right),b=t.computed(()=>e.data.phase==="request"?ye.Right:ye.Left),v=t.computed(()=>g.value?n(`plugins.free-form.datakit.flow_editor.node_types.${e.data.type}.name`):e.data.name),N=t.computed(()=>g.value?rk:ik);function E(S){o!=null&&o.readonly||S==="input"&&!u.value||S==="output"&&!f.value||a(e.data.id,S)}return t.watch(u,S=>{S||a(e.data.id,"input",!0,!0,"*")},{immediate:!0}),t.watch(f,S=>{S||a(e.data.id,"output",!0,!0,"*")},{immediate:!0}),t.watch(()=>e.data.fields.input,(S,P)=>{go(S,P)||a(e.data.id,"input",S.length>0,!0,"*")},{deep:!0}),t.watch(()=>e.data.fields.output,(S,P)=>{go(S,P)||a(e.data.id,"output",S.length>0,!0,"*")},{deep:!0}),(S,P)=>(t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["flow-node",{reversed:_.value,implicit:g.value}])},[t.createElementVNode("div",uB,[g.value?t.createCommentVNode("",!0):(t.openBlock(),t.createBlock(t.unref(Pe.KTooltip),{key:0,class:"badge",placement:"top",text:S.data.type},{default:t.withCtx(()=>[t.createVNode(tm,{"icon-only":"",size:"small",type:S.data.type},null,8,["type"])]),_:1},8,["text"])),t.createElementVNode("div",fB,t.toDisplayString(v.value),1),S.error?(t.openBlock(),t.createBlock(t.unref(Ne.WarningIcon),{key:1,class:"error-icon",color:t.unref(Uc),size:16},null,8,["color"])):t.createCommentVNode("",!0),g.value?t.createCommentVNode("",!0):(t.openBlock(),t.createBlock(t.unref(Pe.KDropdown),{key:2,class:"menu","kpop-attributes":{offset:"4px"},width:"160"},{items:t.withCtx(()=>[t.createVNode(t.unref(Pe.KDropdownItem),{danger:"",onClick:P[0]||(P[0]=B=>t.unref(l)(S.data.id))},{default:t.withCtx(()=>[t.createVNode(ql,{keys:t.unref(Ua).delete,label:t.unref(n)("plugins.free-form.datakit.flow_editor.actions.delete")},null,8,["keys","label"])]),_:1})]),default:t.withCtx(()=>[t.createVNode(t.unref(Pe.KButton),{appearance:"tertiary",class:"menu-trigger",icon:"",size:"small"},{default:t.withCtx(()=>[t.createVNode(t.unref(Ne.MoreIcon),{color:t.unref(dk)},null,8,["color"])]),_:1})]),_:1}))]),t.createElementVNode("div",{class:t.normalizeClass(["handles",{reversed:_.value}])},[h.value?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["input-handles",{"has-fields":c.value}])},[t.createElementVNode("div",pB,[t.createVNode(t.unref(tn),{id:"input",position:w.value,type:"target"},null,8,["position"]),t.createElementVNode("div",mB,[t.createElementVNode("div",{class:t.normalizeClass(["handle-label trigger",{collapsible:u.value}]),onClick:P[1]||(P[1]=t.withModifiers(B=>E("input"),["stop"]))},[P[3]||(P[3]=t.createElementVNode("div",{class:"text"}," inputs ",-1)),c.value?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[p.value?t.createCommentVNode("",!0):(t.openBlock(),t.createBlock(t.unref(Ne.UnfoldMoreIcon),{key:0,size:t.unref(bo)},null,8,["size"])),p.value?(t.openBlock(),t.createBlock(t.unref(Ne.UnfoldLessIcon),{key:1,color:u.value?void 0:t.unref(Kc),size:t.unref(bo)},null,8,["color","size"])):t.createCommentVNode("",!0)],64)):t.createCommentVNode("",!0)],2),c.value&&p.value?(t.openBlock(),t.createBlock(Ii,{key:0,color:N.value,position:w.value,type:"bar"},null,8,["color","position"])):t.createCommentVNode("",!0)])]),c.value&&p.value?(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:0},t.renderList(S.data.fields.input,(B,j)=>(t.openBlock(),t.createElementBlock("div",{key:`inputs-${B.id}`,class:"handle indented"},[t.createVNode(t.unref(tn),{id:`inputs@${B.id}`,position:w.value,type:"target"},null,8,["id","position"]),t.createElementVNode("div",gB,[t.createElementVNode("div",hB,t.toDisplayString(B.name),1),t.createVNode(Ii,{color:N.value,position:w.value,type:j<S.data.fields.input.length-1?"trident":"corner"},null,8,["color","position","type"])])]))),128)):t.createCommentVNode("",!0)],2)):t.createCommentVNode("",!0),y.value?(t.openBlock(),t.createElementBlock("div",{key:1,class:t.normalizeClass(["output-handles",{"has-fields":d.value}])},[t.createElementVNode("div",yB,[t.createElementVNode("div",_B,[t.createElementVNode("div",{class:t.normalizeClass(["handle-label trigger",{collapsible:f.value}]),onClick:P[2]||(P[2]=t.withModifiers(B=>E("output"),["stop"]))},[P[4]||(P[4]=t.createElementVNode("div",{class:"text"}," outputs ",-1)),d.value?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[m.value?t.createCommentVNode("",!0):(t.openBlock(),t.createBlock(t.unref(Ne.UnfoldMoreIcon),{key:0,size:t.unref(bo)},null,8,["size"])),m.value?(t.openBlock(),t.createBlock(t.unref(Ne.UnfoldLessIcon),{key:1,color:f.value?void 0:t.unref(Kc),size:t.unref(bo)},null,8,["color","size"])):t.createCommentVNode("",!0)],64)):t.createCommentVNode("",!0)],2),d.value&&m.value?(t.openBlock(),t.createBlock(Ii,{key:0,color:N.value,position:b.value,type:"bar"},null,8,["color","position"])):t.createCommentVNode("",!0)]),t.createVNode(t.unref(tn),{id:"output",position:b.value,type:"source"},null,8,["position"])]),d.value&&m.value?(t.openBlock(!0),t.createElementBlock(t.Fragment,{key:0},t.renderList(S.data.fields.output,(B,j)=>(t.openBlock(),t.createElementBlock("div",{key:`outputs-${B.id}`,class:"handle indented"},[t.createElementVNode("div",bB,[t.createElementVNode("div",wB,t.toDisplayString(B.name),1),t.createVNode(Ii,{color:N.value,position:b.value,type:j<S.data.fields.output.length-1?"trident":"corner"},null,8,["color","position","type"])]),t.createVNode(t.unref(tn),{id:`outputs@${B.id}`,position:b.value,type:"source"},null,8,["id","position"])]))),128)):t.createCommentVNode("",!0)],2)):t.createCommentVNode("",!0)],2)],2))}}),[["__scopeId","data-v-225c2e47"]]),kB={key:0,class:"dk-flow-mask"},rm=Ee(t.defineComponent({__name:"FlowCanvas",props:{flowId:{},phase:{},readonly:{type:Boolean}},emits:["initialized"],setup(e,{expose:n,emit:o}){const r=o,i=t.useTemplateRef("flowCanvas"),a=Ue.useElementBounding(i),{i18n:{t:l}}=xe(),{vueFlowStore:s,editorStore:c,nodes:d,edges:u,autoLayout:f,fitViewParams:p,fitView:m}=oB({phase:e.phase,flowId:e.flowId,layoutOptions:{viewport:{width:a.width,height:a.height}},readonly:e.readonly}),{addNode:h,selectNode:y,propertiesPanelOpen:g,newCreatedNodeId:_,invalidConfigNodeIds:w}=c,{project:b,vueFlowRef:v,addSelectedNodes:N,getNodes:E}=s,S=t.ref(!1);async function P(Y){y(Y),await t.nextTick();const I=E.value.find(M=>M.id===Y);N(I?[I]:[])}function B(){e.readonly||(g.value=!0)}function j(Y){e.readonly||S.value||Y.preventDefault()}function G(Y){var Q,W;if(e.readonly||S.value)return;const I=(Q=Y.dataTransfer)==null?void 0:Q.getData(xo);if(!I)return;Y.preventDefault();const M=JSON.parse(I);if(M.action!=="create-node")return;const{top:R=0,left:te=0}=((W=v.value)==null?void 0:W.getBoundingClientRect())||{},z=b({x:Y.clientX-te,y:Y.clientY-R}),{type:H,anchor:L}=M.data,F={type:H,phase:e.phase,position:{x:z.x-L.offsetX,y:z.y-L.offsetY}},Z=h(F);P(Z),Z&&(_.value=Z,g.value=!0)}const T=()=>{f(),t.nextTick(()=>m())};if(e.phase==="response"&&!e.readonly){Ue.useEventListener("dragstart",I=>{var te;const M=(te=I.dataTransfer)==null?void 0:te.types.find(z=>z.startsWith(`${xo}/`));if(!M)return;const R=M.replace(`${xo}/`,"");(R==="call"||R==="exit")&&(S.value=!0)});const{start:Y}=Ue.useTimeoutFn(()=>{S.value=!1},80);Ue.useEventListener("dragover",()=>{Y()}),Ue.useEventListener("dragend",()=>{S.value=!1})}return n({autoLayout:f,fitView:m}),(Y,I)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"flowCanvas",ref:i,class:"dk-flow-canvas"},[t.createVNode(t.unref(ep),{id:Y.flowId,class:t.normalizeClass(["flow",{readonly:Y.readonly}]),edges:t.unref(u),"elements-selectable":!Y.readonly,"max-zoom":t.unref(HI),"min-zoom":t.unref(YI),"multi-selection-key-code":null,nodes:t.unref(d),"nodes-connectable":!Y.readonly,"nodes-draggable":!Y.readonly,"pan-on-drag":Y.readonly?!1:void 0,"pan-on-scroll":Y.readonly?!1:void 0,"zoom-on-double-click":Y.readonly?!1:void 0,"zoom-on-pinch":Y.readonly?!1:void 0,"zoom-on-scroll":Y.readonly?!1:void 0,onDragover:j,onDrop:G,onNodeClick:B,onNodesInitialized:I[0]||(I[0]=M=>r("initialized"))},{"node-flow":t.withCtx(M=>[t.createVNode(om,{data:M.data,error:t.unref(w).has(M.data.id)},null,8,["data","error"])]),default:t.withCtx(()=>[t.createVNode(t.unref(bI)),Y.readonly?t.createCommentVNode("",!0):(t.openBlock(),t.createBlock(t.unref(qI),{key:0,"fit-view-params":t.unref(p),position:"bottom-left","show-interactive":!1},{default:t.withCtx(()=>[t.createElementVNode("button",{class:"vue-flow__controls-button vue-flow__controls-interactive custom",onClick:T},[t.createVNode(t.unref(Ne.SparklesIcon),{size:18})])]),_:1},8,["fit-view-params"]))]),_:1},8,["id","class","edges","elements-selectable","max-zoom","min-zoom","nodes","nodes-connectable","nodes-draggable","pan-on-drag","pan-on-scroll","zoom-on-double-click","zoom-on-pinch","zoom-on-scroll"]),S.value?(t.openBlock(),t.createElementBlock("div",kB,t.toDisplayString(t.unref(l)("plugins.free-form.datakit.flow_editor.phase_mask_help")),1)):t.createCommentVNode("",!0)],512))}}),[["__scopeId","data-v-9fdbf607"]]),im=Ee(t.defineComponent({__name:"FlowPanels",props:{readonly:{type:Boolean},resizable:{type:Boolean}},setup(e,{expose:n}){const o=t.ref([!1,!1]),{state:r,markAsLayoutCompleted:i,commit:a,clear:l}=st(),s=t.useId(),c=`${s}-request`,d=`${s}-response`,u=Oe(c),f=Oe(d);function p(Z,Q){const{onPaneClick:W,onNodesChange:ie,onEdgesChange:ae,getSelectedNodes:me,getSelectedEdges:ge}=Z,{removeSelectedElements:ne}=Q;function re(q){if(!q){ne();return}q.some(ee=>ee.type==="select")&&me.value.length+ge.value.length>0&&ne()}ie(re),ae(re),W(()=>re())}p(u,f),p(f,u);const m=t.useTemplateRef("flowPanels"),h=t.useTemplateRef("requestLabel"),y=t.useTemplateRef("requestCanvasContainer"),g=t.useTemplateRef("requestFlow"),_=t.useTemplateRef("resizeHandle"),w=t.useTemplateRef("responseLabel"),b=t.useTemplateRef("responseCanvasContainer"),v=t.useTemplateRef("responseFlow"),N=Ue.useElementBounding(m),E=Ue.useElementBounding(h),S=Ue.useElementBounding(y),P=Ue.useElementBounding(_),B=Ue.useElementBounding(w),j=Ue.useElementBounding(b),G=t.computed(()=>Math.max(30,N.height.value*.03)),T=t.computed(()=>S.height.value<G.value),Y=t.computed(()=>j.height.value<G.value),I=t.ref("50%"),M=t.ref("50%"),R=()=>{e.resizable&&(T.value?(I.value="50%",M.value="50%"):(I.value="0",M.value="100%"))},te=()=>{e.resizable&&(Y.value?(I.value="50%",M.value="50%"):(I.value="100%",M.value="0"))},z=t.computed(()=>N.height.value-E.height.value-P.height.value-B.height.value),{isDragging:H}=Ue.useDraggable(_,{onMove(Z){if(!e.resizable)return;const Q=Math.max(0,Z.y-S.top.value),W=Math.min(1,Math.max(0,Q/z.value));I.value=`${W*100}%`,M.value=`${(1-W)*100}%`},onEnd(){e.resizable&&(S.height.value<G.value?(I.value="0",M.value="100%"):j.height.value<G.value&&(I.value="100%",M.value="0"))}}),L=()=>{t.nextTick(()=>{var Z,Q;(Z=g.value)==null||Z.fitView(),(Q=v.value)==null||Q.fitView()})},F=t.watch(o,([Z,Q])=>{var W,ie;Z&&Q&&(r.value.needLayout&&((W=g.value)==null||W.autoLayout(!1),(ie=v.value)==null||ie.autoLayout(!1),i(),a(),l()),L(),F.stop())},{deep:!0});return n({fitView:L}),(Z,Q)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"flowPanels",ref:m,class:"flow-panels"},[t.createElementVNode("div",{ref_key:"requestLabel",ref:h,class:t.normalizeClass(["label request",{resizable:Z.resizable}]),onClick:R},[Z.resizable?(t.openBlock(),t.createBlock(t.unref(Ne.ChevronDownIcon),{key:0,class:t.normalizeClass(["icon",{collapsed:T.value}])},null,8,["class"])):t.createCommentVNode("",!0),Q[2]||(Q[2]=t.createElementVNode("div",{class:"label-content"}," Request ",-1))],2),t.createElementVNode("div",{ref_key:"requestCanvasContainer",ref:y,class:t.normalizeClass(["canvas",{dragging:t.unref(H)}]),style:t.normalizeStyle({flexBasis:I.value})},[t.createVNode(rm,{ref_key:"requestFlow",ref:g,"flow-id":c,phase:"request",readonly:Z.readonly,onInitialized:Q[0]||(Q[0]=W=>o.value[0]=!0)},null,8,["readonly"])],6),t.createElementVNode("div",{ref_key:"resizeHandle",ref:_,class:t.normalizeClass(["resize-handle",{resizable:Z.resizable}])},null,2),t.createElementVNode("div",{ref_key:"responseLabel",ref:w,class:t.normalizeClass(["label response",{dragging:t.unref(H),resizable:Z.resizable}]),onClick:te},[Z.resizable?(t.openBlock(),t.createBlock(t.unref(Ne.ChevronDownIcon),{key:0,class:t.normalizeClass(["icon",{collapsed:Y.value}])},null,8,["class"])):t.createCommentVNode("",!0),Q[3]||(Q[3]=t.createElementVNode("div",{class:"label-content"}," Response ",-1))],2),t.createElementVNode("div",{ref_key:"responseCanvasContainer",ref:b,class:t.normalizeClass(["canvas response",{dragging:t.unref(H)}]),style:t.normalizeStyle({flexBasis:M.value})},[t.createVNode(rm,{ref_key:"responseFlow",ref:v,"flow-id":d,phase:"response",readonly:Z.readonly,onInitialized:Q[1]||(Q[1]=W=>o.value[1]=!0)},null,8,["readonly"])],6)],512))}}),[["__scopeId","data-v-b469482f"]]),EB={class:"dk-confirm-modal-body"},CB={class:"dk-confirm-modal-connections"},NB=Ee(t.defineComponent({__name:"ConflictModal",props:{title:{},message:{},addedConnections:{},removedConnections:{}},emits:["cancel","confirm"],setup(e,{expose:n,emit:o}){const{i18n:{t:r}}=xe(),i=o,a=t.ref(!1),l=t.ref(e.message),s=t.ref(e.addedConnections??[]),c=t.ref(e.removedConnections??[]);let d=null;function u(){a.value=!1,i("cancel"),d==null||d(!1)}function f(){a.value=!1,i("confirm"),d==null||d(!0)}async function p(m,h,y){return l.value=m,s.value=h??[],c.value=y??[],a.value=!0,await new Promise(g=>{d=g})}return n({open:p}),(m,h)=>{const y=t.resolveComponent("KModal");return t.openBlock(),t.createBlock(y,{"action-button-text":t.unref(r)("plugins.free-form.datakit.flow_editor.confirm.proceed"),"close-on-backdrop-click":"","max-width":"660px",title:m.title??t.unref(r)("plugins.free-form.datakit.flow_editor.confirm.title"),visible:a.value,"z-index":9999,onCancel:u,onProceed:f},{default:t.withCtx(()=>[t.createElementVNode("div",EB,[t.createElementVNode("p",null,t.toDisplayString(l.value),1),t.createElementVNode("p",null,t.toDisplayString(t.unref(r)("plugins.free-form.datakit.flow_editor.confirm.message.confirm")),1),t.createElementVNode("div",CB,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(s.value??[],([g,_])=>(t.openBlock(),t.createElementBlock("div",{key:`${g}-${_}`},[t.createVNode(t.unref(Ne.AddIcon),{color:t.unref(ak)},null,8,["color"]),t.createElementVNode("span",null,t.toDisplayString(g),1),h[0]||(h[0]=t.createTextVNode(" → ",-1)),t.createElementVNode("span",null,t.toDisplayString(_),1)]))),128)),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(c.value??[],([g,_])=>(t.openBlock(),t.createElementBlock("div",{key:`${g}-${_}`},[t.createVNode(t.unref(Ne.RemoveIcon),{color:t.unref(Uc)},null,8,["color"]),t.createElementVNode("span",null,t.toDisplayString(g),1),h[1]||(h[1]=t.createTextVNode(" → ",-1)),t.createElementVNode("span",null,t.toDisplayString(_),1)]))),128))])])]),_:1},8,["action-button-text","title","visible"])}}}),[["__scopeId","data-v-9874f282"]]),vB={class:"dk-editor-nav"},SB={class:"top"},xB={class:"bottom"},AB=Ee(t.defineComponent({__name:"EditorNav",emits:["back"],setup(e,{emit:n}){const{t:o}=Fe.createI18n("en-us",He),r=n,i=[{label:o("plugins.free-form.datakit.flow_editor.return_to_config"),icon:Ne.ArrowLeftIcon,onClick:()=>r("back")}],{sidePanelExpanded:a}=ja(),l=t.computed(()=>a.value?o("plugins.free-form.datakit.flow_editor.collapse_panel"):o("plugins.free-form.datakit.flow_editor.expand_panel")),s=t.ref(!1);function c(){a.value=!a.value}return(d,u)=>(t.openBlock(),t.createElementBlock("nav",vB,[t.createElementVNode("div",SB,[(t.openBlock(),t.createElementBlock(t.Fragment,null,t.renderList(i,({label:f,to:p,icon:m,onClick:h})=>t.createVNode(t.unref(Pe.KTooltip),{key:f,"kpop-attributes":{offset:"10px"},label:f,placement:"right"},{default:t.withCtx(()=>[(t.openBlock(),t.createBlock(t.unref(Pe.KButton),{key:f,appearance:"none",class:"nav-item",icon:"",to:p,onClick:h},{default:t.withCtx(()=>[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(m),{decorative:"",size:t.unref(wa)},null,8,["size"]))]),_:2},1032,["to","onClick"]))]),_:2},1032,["label"])),64))]),t.createElementVNode("div",xB,[t.createElementVNode("div",{class:t.normalizeClass(["side-panel-toggle",{expanded:t.unref(a)}]),onTransitionend:u[0]||(u[0]=t.withModifiers(f=>s.value=!1,["self"])),onTransitionstart:u[1]||(u[1]=t.withModifiers(f=>s.value=!0,["self"]))},[t.createVNode(t.unref(Pe.KTooltip),{label:s.value?void 0:l.value,placement:t.unref(a)?"left":"right"},{default:t.withCtx(()=>[t.createVNode(t.unref(Pe.KButton),{appearance:"none",class:"nav-item nav-item-toggle",icon:"",size:"large",onClick:c},{default:t.withCtx(()=>[t.unref(a)?(t.openBlock(),t.createBlock(t.unref(Ne.ChevronDoubleLeftIcon),{key:0,decorative:"",size:t.unref(wa)},null,8,["size"])):(t.openBlock(),t.createBlock(t.unref(Ne.ChevronDoubleRightIcon),{key:1,decorative:"",size:t.unref(wa)},null,8,["size"]))]),_:1})]),_:1},8,["label","placement"])],34)])]))}}),[["__scopeId","data-v-2915b6fa"]]);function IB(e){return e.closest('input, textarea, [contenteditable]:not([contenteditable="false"])')!=null}function PB({undo:e,redo:n,cut:o,copy:r,paste:i,enabled:a=!0}){if(typeof window>"u"||!e&&!n&&!o&&!r&&!i)return;const l=nm();return Ue.useEventListener(window,"keydown",s=>{if(!t.toValue(a)||IB(s.target))return;const c=s.key.toLowerCase();if(l==="mac"?s.metaKey:s.ctrlKey)switch(c){case"z":{if(e&&!s.shiftKey){s.preventDefault(),e();return}if(n&&s.shiftKey){s.preventDefault(),n();return}break}case"y":{if(l==="windows"&&n){s.preventDefault(),n();return}break}case"x":{if(o){s.preventDefault(),o();return}break}case"c":{if(r){s.preventDefault(),r();return}break}case"v":{if(i){s.preventDefault(),i();return}break}}},{passive:!1})}const TB={class:"dk-editor-main"},OB={class:"header"},$B={class:"actions"},BB={ref:"canvasContainer",class:"body"},VB=Ee(t.defineComponent({__name:"EditorMain",setup(e){const{t:n}=Fe.createI18n("en-us",He),{modalOpen:o,undo:r,redo:i,canUndo:a,canRedo:l}=st();function s(){o.value=!1}return PB({enabled:o,undo:r,redo:i}),(c,d)=>{const u=t.resolveComponent("KTooltip");return t.openBlock(),t.createElementBlock("div",TB,[t.createElementVNode("header",OB,[t.createElementVNode("div",$B,[t.createVNode(u,{"z-index":1e4},{content:t.withCtx(()=>[t.createVNode(ql,{keys:t.unref(Ua).undo,label:t.unref(n)("plugins.free-form.datakit.flow_editor.actions.undo"),reverse:""},null,8,["keys","label"])]),default:t.withCtx(()=>[t.createVNode(t.unref(Pe.KButton),{appearance:"tertiary",disabled:!t.unref(a),icon:"",onClick:t.unref(r)},{default:t.withCtx(()=>[t.createVNode(t.unref(Ne.RedoIcon),{class:"flip"})]),_:1},8,["disabled","onClick"])]),_:1}),t.createVNode(u,{"z-index":1e4},{content:t.withCtx(()=>[t.createVNode(ql,{keys:t.unref(Ua).redo,label:t.unref(n)("plugins.free-form.datakit.flow_editor.actions.redo"),reverse:""},null,8,["keys","label"])]),default:t.withCtx(()=>[t.createVNode(t.unref(Pe.KButton),{appearance:"tertiary",disabled:!t.unref(l),icon:"",onClick:t.unref(i)},{default:t.withCtx(()=>[t.createVNode(t.unref(Ne.RedoIcon))]),_:1},8,["disabled","onClick"])]),_:1}),d[0]||(d[0]=t.createElementVNode("div",{class:"divider"},null,-1)),t.createVNode(t.unref(Pe.KButton),{appearance:"tertiary",target:"_blank",to:"https://developer.konghq.com/plugins/datakit/"},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(n)("plugins.free-form.datakit.flow_editor.actions.view_docs"))+" ",1),t.createVNode(t.unref(Ne.ExternalLinkIcon))]),_:1}),t.createVNode(t.unref(Pe.KButton),{onClick:s},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(n)("plugins.free-form.datakit.flow_editor.actions.done")),1)]),_:1})])]),t.createElementVNode("div",BB,[t.createVNode(im,{resizable:""})],512)])}}}),[["__scopeId","data-v-35b58163"]]),RB={class:"icon"},DB={class:"content"},MB={class:"title"},LB={class:"description"},FB=Ee(t.defineComponent({__name:"NodePanelItem",props:{type:{}},setup(e){const{summary:n,icon:o}=Tr[e.type];return(r,i)=>(t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(["dk-node-panel-item",{[`node-type-${r.type}`]:!0}])},[t.createElementVNode("div",RB,[t.createVNode(t.unref(o),{size:16})]),t.createElementVNode("div",DB,[t.createElementVNode("div",MB,t.toDisplayString(r.type),1),t.createElementVNode("div",LB,t.toDisplayString(t.unref(n)),1)])],2))}}),[["__scopeId","data-v-e75cecee"]]),UB={class:"dk-node-panel"},KB={class:"title"},jB={class:"node-list"},GB={"aria-hidden":"true",class:"preview",inert:""},qB=Ee(t.defineComponent({__name:"NodePanel",setup(e){const{t:n}=Fe.createI18n("en-us",He),{createNode:o}=st(),r=`dk-drag-preview-${t.useId()}`,i=t.shallowRef(),a=t.computed(()=>i.value?[{id:"preview",type:"flow",data:i.value,position:{x:0,y:0}}]:[]),l=async(s,c)=>{var P,B,j;const d=s.currentTarget,{left:u,top:f,width:p,height:m}=d.getBoundingClientRect(),h=s.clientX-u,y=s.clientY-f;i.value=o({type:c}),await t.nextTick();const g=document.querySelector(`#${r}`)||d,_=g.cloneNode(!0);_.classList.add("dk-drag-snapshot");const{offsetWidth:w,offsetHeight:b}=g;Object.assign(_.style,{position:"absolute",top:"-9999px",left:"-9999px",width:`${w}px`,height:`${b}px`}),document.body.appendChild(_);const v=h/p,N=y/m,E={ratioX:v,ratioY:N,offsetX:w*v,offsetY:b*N},S={action:"create-node",data:{type:c,anchor:E}};(P=s.dataTransfer)==null||P.setData(xo,JSON.stringify(S)),(B=s.dataTransfer)==null||B.setData(`${xo}/${c}`,c),(j=s.dataTransfer)==null||j.setDragImage(_,E.offsetX,E.offsetY),requestAnimationFrame(()=>{_.remove(),i.value=void 0})};return(s,c)=>{const d=t.resolveComponent("KLabel");return t.openBlock(),t.createElementBlock("div",UB,[t.createElementVNode("h3",KB,[t.createVNode(d,{class:"label",info:t.unref(n)("plugins.free-form.datakit.flow_editor.node_panel.description")},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(n)("plugins.free-form.datakit.flow_editor.node_panel.title")),1)]),_:1},8,["info"])]),t.createElementVNode("div",jB,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(Object.keys(t.unref(Tr)),u=>(t.openBlock(),t.createBlock(FB,{key:u,draggable:"true",type:u,onDragstart:f=>l(f,u)},null,8,["type","onDragstart"]))),128))]),t.createElementVNode("div",GB,[t.createVNode(t.unref(ep),{nodes:a.value},{"node-flow":t.withCtx(u=>[t.createVNode(om,{id:r,data:u.data},null,8,["data"])]),_:1},8,["nodes"])])])}}}),[["__scopeId","data-v-98011dca"]]),zB=t.defineComponent({__name:"HttpMethodField",props:{name:{}},setup(e){return(n,o)=>(t.openBlock(),t.createBlock(Nt,{items:t.unref(sa)([...t.unref(ou)]),name:n.name},null,8,["items","name"]))}}),HB=Ee(t.defineComponent({__name:"InputsRecordField",props:{name:{},items:{}},emits:["change:inputs"],setup(e){const{getSchema:n}=De(),{i18n:o}=xe(),r=t.computed(()=>{const i=n("inputs");return i?i.fields.map(a=>Object.keys(a)[0]):[]});return(i,a)=>(t.openBlock(),t.createBlock(nt,{"as-child":"",name:i.name,"reset-label-path":"isolate"},{default:t.withCtx(()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(r.value,l=>(t.openBlock(),t.createBlock(Nt,{key:l,class:"dk-inputs-field-indent",clearable:"","enable-filtering":"",items:i.items,name:l,placeholder:t.unref(o).t("plugins.free-form.datakit.flow_editor.node_properties.input.placeholder"),onChange:s=>i.$emit("change:inputs",l,s?s.value:null)},null,8,["items","name","placeholder","onChange"]))),128))]),_:1},8,["name"]))}}),[["__scopeId","data-v-fe101e72"]]),YB=["data-testid"],WB={class:"dk-inputs-map-field-entry-body"},XB={class:"dk-inputs-map-field-entry-content"},ZB={class:"dk-inputs-map-field-indent"},JB=Ee(t.defineComponent({__name:"InputsMapField",props:{items:{},fieldNameValidator:{},name:{},initialValue:{},label:{},keyPlaceholder:{},valuePlaceholder:{},defaultKey:{},defaultValue:{},labelAttributes:{},showVaultSecretPicker:{type:Boolean},keyOrder:{}},emits:["change:inputs","add:field","remove:field","rename:field","change"],setup(e,{emit:n}){const o=e,r=n,{entries:i,addEntry:a,removeEntry:l,field:s}=ha(o,r),{i18n:{t:c}}=xe(),d=t.useTemplateRef("root"),u=t.ref(null),f=t.ref({});let p;async function m(N,E="key"){var S;d.value&&(await t.nextTick(),(S=d.value.querySelector(`[data-${E}-input="${N}"]`))==null||S.focus())}function h(){const{id:N}=a(),E=i.value.findIndex(({key:S})=>!S);m(E===-1?i.value.length-1:E),u.value=N}function y(N){l(N.id),N.id===u.value&&(u.value=null),N.key.trim()!==""&&r("remove:field",N.key)}function g(N){p=N.key}function _(N){if(w(N)){N.key=p,delete f.value[N.id];return}if(N.id===u.value){if(N.key.trim()==="")return;r("add:field",N.key,N.value),u.value=null}else r("rename:field",p,N.key);p=N.key}function w(N){delete f.value[N.id];const E=o.fieldNameValidator("input",p,N.key);if(E)return f.value[N.id]=E,E}function b(N){w(N)}function v(N,E){N.id!==u.value&&r("change:inputs",N.key,E)}return(N,E)=>{const S=t.resolveComponent("KAlert"),P=t.resolveComponent("KLabel"),B=t.resolveComponent("KInput"),j=t.resolveComponent("KSelect"),G=t.resolveComponent("KButton");return t.unref(s).error?(t.openBlock(),t.createBlock(S,{key:0,appearance:"danger",message:t.unref(s).error.message},null,8,["message"])):(t.openBlock(),t.createElementBlock("div",{key:1,ref_key:"root",ref:d,class:"dk-inputs-map-field"},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(i),(T,Y)=>(t.openBlock(),t.createElementBlock("div",{key:T.id,class:"dk-inputs-map-field-entry dk-inputs-map-field-indent","data-testid":`ff-kv-container-${t.unref(s).path.value}.${Y}`},[t.createVNode(P,{for:`ff-kv-entry-key-${t.unref(s).path.value}.${Y}`},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(c)("plugins.free-form.datakit.flow_editor.node_properties.input_name.label")),1)]),_:2},1032,["for"]),t.createElementVNode("div",WB,[t.createElementVNode("div",XB,[t.createVNode(B,{id:`ff-kv-entry-key-${t.unref(s).path.value}.${Y}`,modelValue:T.key,"onUpdate:modelValue":[I=>T.key=I,I=>w(T)],modelModifiers:{trim:!0},class:"ff-kv-field-entry-key","data-key-input":Y,"data-testid":`ff-key-${t.unref(s).path.value}.${Y}`,error:!!f.value[T.id],"error-message":f.value[T.id],placeholder:t.unref(c)("plugins.free-form.datakit.flow_editor.node_properties.input_name.placeholder"),onBlur:I=>b(T),onChange:I=>_(T),onFocus:I=>g(T)},null,8,["id","modelValue","onUpdate:modelValue","data-key-input","data-testid","error","error-message","placeholder","onBlur","onChange","onFocus"]),t.createVNode(j,{modelValue:T.value,"onUpdate:modelValue":I=>T.value=I,class:"ff-kv-field-entry-value",clearable:"","data-testid":`ff-value-${t.unref(s).path.value}.${Y}`,"enable-filtering":"",items:N.items,placeholder:t.unref(c)("plugins.free-form.datakit.flow_editor.node_properties.input.placeholder"),onChange:I=>v(T,(I==null?void 0:I.value)??null)},null,8,["modelValue","onUpdate:modelValue","data-testid","items","placeholder","onChange"])]),t.createVNode(G,{appearance:"none",class:"dk-inputs-map-field-remove-btn","data-testid":`ff-kv-remove-btn-${t.unref(s).path.value}.${Y}`,icon:"",onClick:I=>y(T)},{default:t.withCtx(()=>[t.createVNode(t.unref(Ne.CloseIcon))]),_:2},1032,["data-testid","onClick"])])],8,YB))),128)),t.createElementVNode("div",ZB,[t.createVNode(G,{appearance:"tertiary","data-testid":`ff-kv-add-btn-${t.unref(s).path.value}`,disabled:!!u.value,onClick:h},{default:t.withCtx(()=>[t.createVNode(t.unref(Ne.AddIcon)),t.createTextVNode(" "+t.toDisplayString(t.unref(c)("plugins.free-form.datakit.flow_editor.node_properties.input.add_button")),1)]),_:1},8,["data-testid","disabled"])])],512))}}}),[["__scopeId","data-v-eed2c92b"]]),eo=t.defineComponent({__name:"InputsField",props:{items:{},fieldNames:{},fieldNameValidator:{}},emits:["change:input","change:inputs","add:field","remove:field","rename:field"],setup(e,{emit:n}){const o=n,{getSchema:r}=De(),{i18n:i}=xe(),a=t.computed(()=>r("inputs")),l=t.computed(()=>a.value?a.value.type==="record"?HB:JB:null);function s(p){o("change:input",p?p.value:null)}function c(p,m){o("add:field",p,m)}function d(p,m){o("change:inputs",p,m)}function u(p){o("remove:field",p)}function f(p,m){o("rename:field",p,m)}return(p,m)=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[t.unref(r)("input")?(t.openBlock(),t.createBlock(Nt,{key:0,clearable:"","enable-filtering":"",items:p.items,label:"Inputs",name:"input",placeholder:t.unref(i).t("plugins.free-form.datakit.flow_editor.node_properties.input.placeholder"),onChange:s},null,8,["items","placeholder"])):t.createCommentVNode("",!0),l.value?(t.openBlock(),t.createBlock(t.unref(l),{key:1,"field-name-validator":p.fieldNameValidator,items:p.items,"key-order":p.fieldNames,name:"inputs","onAdd:field":c,"onChange:inputs":d,"onRemove:field":u,"onRename:field":f},null,8,["field-name-validator","items","key-order"])):t.createCommentVNode("",!0)],64))}}),QB={fields:[{input:{description:"filter input(s)",len_max:255,len_min:1,match_any:{err:"must be one of NODE_NAME or NODE_NAME.FIELD",patterns:["^[A-Za-z_][A-Za-z0-9_-]*$","^[A-Za-z_][A-Za-z0-9_-]*%..+$"]},required:!1,type:"string"}},{inputs:{description:"call node inputs",fields:[{body:{description:"HTTP request body",len_max:255,len_min:1,match_any:{err:"must be one of NODE_NAME or NODE_NAME.FIELD",patterns:["^[A-Za-z_][A-Za-z0-9_-]*$","^[A-Za-z_][A-Za-z0-9_-]*%..+$"]},required:!1,type:"string"}},{headers:{description:"HTTP request headers",len_max:255,len_min:1,match_any:{err:"must be one of NODE_NAME or NODE_NAME.FIELD",patterns:["^[A-Za-z_][A-Za-z0-9_-]*$","^[A-Za-z_][A-Za-z0-9_-]*%..+$"]},required:!1,type:"string"}},{query:{description:"HTTP request query",len_max:255,len_min:1,match_any:{err:"must be one of NODE_NAME or NODE_NAME.FIELD",patterns:["^[A-Za-z_][A-Za-z0-9_-]*$","^[A-Za-z_][A-Za-z0-9_-]*%..+$"]},required:!1,type:"string"}}],required:!1,type:"record"}}],type:"record"},eV={fields:[{input:{description:"filter input(s)",len_max:255,len_min:1,match_any:{err:"must be one of NODE_NAME or NODE_NAME.FIELD",patterns:["^[A-Za-z_][A-Za-z0-9_-]*$","^[A-Za-z_][A-Za-z0-9_-]*%..+$"]},required:!1,type:"string"}},{inputs:{description:"call node inputs",fields:[{body:{description:"HTTP request body",len_max:255,len_min:1,match_any:{err:"must be one of NODE_NAME or NODE_NAME.FIELD",patterns:["^[A-Za-z_][A-Za-z0-9_-]*$","^[A-Za-z_][A-Za-z0-9_-]*%..+$"]},required:!1,type:"string"}},{headers:{description:"HTTP request headers",len_max:255,len_min:1,match_any:{err:"must be one of NODE_NAME or NODE_NAME.FIELD",patterns:["^[A-Za-z_][A-Za-z0-9_-]*$","^[A-Za-z_][A-Za-z0-9_-]*%..+$"]},required:!1,type:"string"}}],required:!1,type:"record"}}],type:"record"};function tV(e){const n=Number(e);return!isNaN(n)&&isFinite(n)}function to(...e){return function(o){for(const r of e){const i=r(o);if(i)return i}}}function no(e){const{i18n:{t:n}}=xe(),o=()=>e?typeof e=="string"?e:n("plugins.free-form.datakit.flow_editor.node_properties.errors.not_empty",e):"Field is required";return function(i){if(i==null||typeof i=="string"&&i.trim()==="")return o()}}function am(e,n){const{i18n:{t:o}}=xe();return function(i){if(i!=null)switch(e){case"identifier":{const a=()=>n?typeof n=="string"?n:o("plugins.free-form.datakit.flow_editor.node_properties.errors.invalid_identifier_format",n):"Invalid identifier format";return/^[A-Za-z_][A-Za-z0-9_-]*$/.test(i)?void 0:a()}case"url":{const a=()=>n?typeof n=="string"?n:o("plugins.free-form.datakit.flow_editor.node_properties.errors.invalid_url_format"):"Invalid URL format";try{new URL(i);return}catch{return a()}}default:return}}}function nV(e=0,n=1/0,o){const{i18n:{t:r}}=xe();return function(a){if(a!=null&&typeof a=="string"&&(a.length<e||a.length>n))return o?typeof o=="string"?o:r("plugins.free-form.datakit.flow_editor.node_properties.errors.string_len_range",{fieldName:o.fieldName,minLength:e,maxLength:n}):`Value must be between ${e} and ${n} characters`}}function lm(e){const{i18n:{t:n}}=xe();return function(r){if(!tV(r))return e?typeof e=="string"?e:n("plugins.free-form.datakit.flow_editor.node_properties.errors.not_number",e):"Value must be a number"}}function sm(e,n){const{i18n:{t:o}}=xe();return function(i){if(i==null)return;const a=lm(n)(i);if(a)return a;const l=Number(i);switch(e){case"float":{const s=()=>n?typeof n=="string"?n:o("plugins.free-form.datakit.flow_editor.node_properties.errors.not_float",n):"Invalid float format";return Number.isFinite(l)?void 0:s()}case"integer":{const s=()=>n?typeof n=="string"?n:o("plugins.free-form.datakit.flow_editor.node_properties.errors.not_integer",n):"Invalid integer format";return Number.isInteger(l)?void 0:s()}default:return}}}function cm(e=-1/0,n=1/0,o){const{i18n:{t:r}}=xe();return function(a){if(a==null)return;const l=lm(o)(a);if(l)return l;const s=Number(a);if(s<e||s>n)return o?typeof o=="string"?o:r("plugins.free-form.datakit.flow_editor.node_properties.errors.number_range",{fieldName:o.fieldName,min:e,max:n}):`Value must be between ${e} and ${n}`}}function oV(e,n){const{state:o}=st(),{i18n:{t:r}}=xe();return function(a){if(o.value.nodes.some(l=>l.name===a&&l.id!==e))return n?typeof n=="string"?n:r("plugins.free-form.datakit.flow_editor.node_properties.errors.not_unique",n):"Name must be unique."}}function rV(e,n,o){const{i18n:{t:r}}=xe();return function(a){if(!n)return;if(o?n.fields[e].some(s=>s.name===a&&s.id!==o):n.fields[e].some(s=>s.name===a)){const s=r(e==="input"?"plugins.free-form.datakit.flow_editor.node_properties.input_name.label":"plugins.free-form.datakit.flow_editor.node_properties.output_value.value_name");return r("plugins.free-form.datakit.flow_editor.node_properties.errors.not_unique",{fieldName:s})}}}function iV(){const{i18n:{t:e}}=xe();return function(o){if(Ma(o))return e("plugins.free-form.datakit.flow_editor.node_properties.errors.reserved_node_name",{nodeName:o})}}function dm(e){const{i18n:{t:n}}=xe(),o={fieldName:n("plugins.free-form.datakit.flow_editor.node_properties.name")};return to(no(o),am("identifier",o),iV(),oV(e,o))}function aV(e){const{i18n:{t:n}}=xe(),{getNodeById:o}=st();return function(i,a,l){const s={fieldName:n(i==="input"?"plugins.free-form.datakit.flow_editor.node_properties.input_name.label":"plugins.free-form.datakit.flow_editor.node_properties.output_value.value_name")};return to(no(s),rV(i,o(e),l))(a)}}function lV(e){const n=t.ref({}),o=t.computed(()=>Object.values(n.value).every(l=>!l)),r={};Object.keys(e).forEach(l=>{const s=e[l],c=f=>{const p=typeof f=="function"?f():f,m=s(p);return n.value[l]=m,m},d=()=>{n.value[l]=void 0},u=f=>(d(),c(f));r[l]={handleChange:u,handleBlur:u,validate:u,isValid:t.computed(()=>n.value[l]===void 0),error:t.computed(()=>n.value[l])}});function i(){n.value={}}function a(l){var s;for(const c of Object.keys(e)){const d=l[c],u=typeof d=="function"?d():d;(s=r[c])==null||s.validate(u)}return n.value}return{isValid:o,errorMap:n,fields:r,clearErrors:i,validate:a}}function Pi(e){const{validationConfig:n,getValidationData:o,skipValidationOnMount:r,toggleNodeValid:i}=e,a=t.computed(()=>typeof n=="function"?n():n),l=t.computed(()=>lV(a.value)),s=t.computed(()=>l.value.fields),c=t.computed(()=>l.value.isValid.value);function d(){const f=o(),p=l.value.validate(f),m={};for(const h in a.value)m[h]=p[h];return m}function u(f,p){return{onBlur:()=>{const m=o(),h=s.value[f];h&&h.handleBlur(m[f])},onUpdate:()=>{const m=o(),h=s.value[f];h&&h.handleChange(m[f]),p==null||p()},error:t.computed(()=>{const m=s.value[f];return m?!m.isValid.value:!1}),errorMessage:t.computed(()=>{const m=s.value[f];return m?m.error.value??"":""})}}return t.onMounted(()=>{r!=null&&r.value||d()}),t.onBeforeUnmount(async()=>{try{const f=d(),p=Object.values(f).filter(Boolean).length>0;i(!p)}catch{}}),t.watch(()=>c.value,i,{immediate:!0}),{fields:s.value,isValid:c,validateAll:d,createFieldHandler:u}}function vn(e,n){const{state:o,renameNode:r,getNodeById:i,addField:a,renameField:l,removeField:s,replaceConfig:c,disconnectEdge:d,connectEdge:u,newCreatedNodeId:f,invalidConfigNodeIds:p,undo:m,commit:h}=st(),{i18n:{t:y}}=xe(),g=eB();let _=!1;t.watch(o,async()=>{_=!0,await t.nextTick(),_=!1},{immediate:!0,deep:!0}),console.log("state",o.value),window.store=st();const w=t.computed(()=>{const F=i(e);if(!F)throw new Error("Node not existed");return F}),b=t.computed(()=>{const Z=o.value.edges.filter(Q=>Q.target===e).reduce((Q,W)=>{var ne,re;const ie=i(W.source),ae=(ne=Wt(ie,"output",W.sourceField))==null?void 0:ne.id,me=(re=Wt(w.value,"input",W.targetField))==null?void 0:re.name,ge=ie.id+(ae?`.${ae}`:"");return me?Q.inputs={...Q.inputs,[me]:ge}:Q.input=ge,Q},{});return w.value.fields.input.forEach(Q=>{Z.inputs||(Z.inputs={}),Z.inputs[Q.name]||(Z.inputs[Q.name]=null)}),{...w.value.config,...Z,name:w.value.name}}),v=F=>{r(e,F??"",!0,`${e}:rename`)},N=(F,Z=!0)=>{if(_)return;if(!n)throw new Error("getFormInnerData is not defined");const Q=yc(n(),["name","input","inputs"]),W=F?`update:${e}:${F}`:void 0;c(e,Q,Z,W)},E=(F,Z)=>{const Q=jn(w.value,F,Z);if(!Q)throw new Error(`Field with name "${Z}" not found in node "${w.value.name}"`);return Q},S=(F,Z,Q)=>{const W=!!Q;a(e,F,Z,!W),W&&T(Z,Q)},P=(F,Z,Q)=>{if(_)return;const W=E(F,Z).id;l(e,W,Q)},B=(F,Z)=>{const Q=E(F,Z).id;s(e,Q)},j=t.computed(()=>o.value.edges.filter(F=>F.target===e&&!F.targetField)[0]),G=t.computed(()=>o.value.edges.filter(F=>F.target===e&&F.targetField)),T=async(F,Z)=>{if(_)return;const Q=Z==null,W=E("input",F).id;if(Q){const ee=G.value.find(O=>O.targetField===W);ee&&d(ee.id);return}const{nodeId:ie,fieldId:ae}=Qd(Z),me=E("input",F).id,ge=[];j.value&&(ge.push(Yo(j.value,i)),d(j.value.id,!1));const ne=G.value.find(ee=>ee.targetField===W);ne&&(ge.push(Yo(ne,i)),d(ne.id,!1)),u({source:ie,sourceField:ae,target:e,targetField:me},!1);const re=jl(ie,ae,e,me,i);h(),!(ge[0]&&re&&ge[0][1]===re[1])&&ge.length>0&&(await g(y("plugins.free-form.datakit.flow_editor.confirm.message.switch"),[re],ge)||m())},Y=async F=>{if(_)return;if(F==null){j.value&&d(j.value.id);return}const Q=[];for(const me of G.value.concat(j.value?[j.value]:[]))Q.push(Yo(me,i)),d(me.id,!1);const{nodeId:W,fieldId:ie}=Qd(F);u({source:W,sourceField:ie,target:e,targetField:void 0},!1);const ae=jl(W,ie,e,void 0,i);h(),Q.length>0&&(await g(y("plugins.free-form.datakit.flow_editor.confirm.message.switch"),[ae],Q)||m())},I=F=>{const Z=[...o.value.edges,{source:F,target:e}];return Ka(Rr(Z))},M=t.computed(()=>{var Z,Q;const F=[];for(const W of o.value.nodes)if((Z=La(W.type).io)!=null&&Z.output&&W.fields.output&&W.id!==e&&!(W.type==="property"&&!Il((Q=W.config)==null?void 0:Q.property))&&!I(W.id)&&!(w.value.phase==="request"&&W.phase==="response")){F.push({value:W.id,label:W.name});for(const ae of W.fields.output)F.push({value:`${W.id}.${ae.id}`,label:`${W.name}.${ae.name}`})}return F}),R=t.computed(()=>w.value.fields.input.map(F=>F.name)||[]),te=t.computed(()=>f.value===e);function z(F){p.value.delete(e),F||p.value.add(e)}const H=aV(e);function L(F,Z,Q){const W=i(e);if(!W)throw new Error("Node not found when validating field name");const ie=jn(W,F,Z);return H(F,Q,ie==null?void 0:ie.id)}return{formData:b,inputOptions:M,inputEdge:j,inputsEdges:G,inputsFieldNames:R,skipValidationOnMount:te,currentNode:w,setName:v,setConfig:N,addField:S,renameFieldByName:P,removeFieldByName:B,setInputs:T,setInput:Y,nameValidator:dm(e),fieldNameValidator:L,toggleNodeValid:z}}function Sn(e){const{getSchema:n}=De();return t.computed(()=>{if(Lt(e))switch(e){case"response":return eV;case"service_request":return QB}try{const l=n().fields[0].config.fields[0].nodes.elements.subschema_definitions[e];if(!l)throw new Error(`Subschema "${e}" not found in the schema.`);return l}catch(o){throw new Error(`Failed to get subschema "${e}": ${o.message}`)}})}const Wo=t.defineComponent({__name:"NameField",props:{name:{},validate:{type:Function}},emits:["update"],setup(e,{emit:n}){const o=e,r=n,{i18n:{t:i}}=xe(),a=t.ref(o.name),l=t.computed(()=>{const u=o.validate(a.value.trim());return u===void 0?"":u});let s=a.value.trim();function c(){if(l.value){a.value=s;return}r("update",a.value.trim())}function d(){s=a.value.trim()}return t.watch(()=>o.name,u=>{u!==a.value&&(a.value=u)}),(u,f)=>{const p=t.resolveComponent("KInput");return t.openBlock(),t.createBlock(p,{"model-value":a.value,"onUpdate:modelValue":f[0]||(f[0]=m=>a.value=m),"data-1p-ignore":"",error:!!l.value,"error-message":l.value,label:t.unref(i)("plugins.free-form.datakit.flow_editor.node_properties.name"),required:"",onChange:c,onFocus:d},null,8,["model-value","error","error-message","label"])}}}),sV=t.defineComponent({__name:"NodeFormCall",props:{nodeId:{}},setup(e){const{i18n:{t:n}}=xe(),o=t.useTemplateRef("form"),r=Sn("call"),{formData:i,setName:a,setConfig:l,inputOptions:s,setInputs:c,setInput:d,inputsFieldNames:u,nameValidator:f,skipValidationOnMount:p,toggleNodeValid:m,fieldNameValidator:h}=vn(e.nodeId,()=>o.value.getInnerData()),{createFieldHandler:y}=Pi({validationConfig:{url:to(no({fieldName:"URL"}),am("url",{fieldName:"URL"})),timeout:to(sm("integer",{fieldName:n("plugins.free-form.datakit.flow_editor.node_properties.timeout.label")}),cm(0,2147483646,{fieldName:n("plugins.free-form.datakit.flow_editor.node_properties.timeout.label")}))},getValidationData:()=>({url:i.value.url,timeout:i.value.timeout}),skipValidationOnMount:p,toggleNodeValid:m}),g=y("url",()=>l("url")),_=y("timeout",()=>l("timeout"));return(w,b)=>{const v=t.resolveComponent("KLabel");return t.openBlock(),t.createBlock(pt,{ref:"form",data:t.unref(i),schema:t.unref(r)},{default:t.withCtx(()=>[t.createVNode(Wo,{name:t.unref(i).name,validate:t.unref(f),onUpdate:t.unref(a)},null,8,["name","validate","onUpdate"]),t.createVNode(v,{class:"dk-node-configuration-label"},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(n)("plugins.free-form.datakit.flow_editor.node_properties.Configuration")),1)]),_:1}),t.createVNode(Vn,{error:t.unref(g).error.value,"error-message":t.unref(g).errorMessage.value,name:"url",onBlur:t.unref(g).onBlur,"onUpdate:modelValue":t.unref(g).onUpdate},null,8,["error","error-message","onBlur","onUpdate:modelValue"]),t.createVNode(zB,{name:"method","onUpdate:modelValue":b[0]||(b[0]=N=>t.unref(l)())}),t.createVNode(Rn,{error:t.unref(_).error.value,"error-message":t.unref(_).errorMessage.value,label:t.unref(n)("plugins.free-form.datakit.flow_editor.node_properties.timeout.label"),name:"timeout",onBlur:t.unref(_).onBlur,"onUpdate:modelValue":t.unref(_).onUpdate},null,8,["error","error-message","label","onBlur","onUpdate:modelValue"]),t.createVNode(Vn,{name:"ssl_server_name","onUpdate:modelValue":b[1]||(b[1]=N=>t.unref(l)("ssl_server_name"))}),t.createVNode(eo,{"field-name-validator":t.unref(h),"field-names":t.unref(u),items:t.unref(s),"onChange:input":t.unref(d),"onChange:inputs":t.unref(c)},null,8,["field-name-validator","field-names","items","onChange:input","onChange:inputs"])]),_:1},8,["data","schema"])}}}),cV=t.defineComponent({__name:"NodeFormServiceRequest",props:{nodeId:{}},setup(e){const n=t.useTemplateRef("form"),o=Sn("service_request"),{formData:r,inputOptions:i,setInputs:a,setInput:l,inputsFieldNames:s,fieldNameValidator:c}=vn(e.nodeId,()=>n.value.getInnerData());return(d,u)=>(t.openBlock(),t.createBlock(pt,{ref:"form",data:t.unref(r),schema:t.unref(o)},{default:t.withCtx(()=>[t.createVNode(eo,{"field-name-validator":t.unref(c),"field-names":t.unref(s),items:t.unref(i),"onChange:input":t.unref(l),"onChange:inputs":t.unref(a)},null,8,["field-name-validator","field-names","items","onChange:input","onChange:inputs"])]),_:1},8,["data","schema"]))}}),dV=t.defineComponent({__name:"NodeFormResponse",props:{nodeId:{}},setup(e){const n=t.useTemplateRef("form"),o=Sn("response"),{formData:r,inputOptions:i,setInputs:a,setInput:l,inputsFieldNames:s,fieldNameValidator:c}=vn(e.nodeId,()=>n.value.getInnerData());return(d,u)=>(t.openBlock(),t.createBlock(pt,{ref:"form",data:t.unref(r),schema:t.unref(o)},{default:t.withCtx(()=>[t.createVNode(eo,{"field-name-validator":t.unref(c),"field-names":t.unref(s),items:t.unref(i),"onChange:input":t.unref(l),"onChange:inputs":t.unref(a)},null,8,["field-name-validator","field-names","items","onChange:input","onChange:inputs"])]),_:1},8,["data","schema"]))}}),uV=t.defineComponent({__name:"NodeFormJq",props:{nodeId:{}},setup(e){const{i18n:{t:n}}=xe(),o=t.useTemplateRef("form"),r=Sn("jq"),{formData:i,setName:a,setConfig:l,inputOptions:s,setInputs:c,setInput:d,addField:u,removeFieldByName:f,renameFieldByName:p,inputsFieldNames:m,nameValidator:h,skipValidationOnMount:y,toggleNodeValid:g,fieldNameValidator:_}=vn(e.nodeId,()=>o.value.getInnerData());function w(P,B){u("input",P,B)}function b(P){f("input",P)}function v(P,B){p("input",P,B)}const N=n("plugins.free-form.datakit.flow_editor.node_properties.jq.label"),{createFieldHandler:E}=Pi({validationConfig:{jq:to(no({fieldName:N}),nV(1,10240,{fieldName:N}))},getValidationData:()=>({jq:i.value.jq}),skipValidationOnMount:y,toggleNodeValid:g}),S=E("jq",()=>l("jq"));return(P,B)=>{const j=t.resolveComponent("KLabel");return t.openBlock(),t.createBlock(pt,{ref:"form",data:t.unref(i),schema:t.unref(r)},{default:t.withCtx(()=>[t.createVNode(Wo,{name:t.unref(i).name,validate:t.unref(h),onUpdate:t.unref(a)},null,8,["name","validate","onUpdate"]),t.createVNode(j,{class:"dk-node-configuration-label"},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(n)("plugins.free-form.datakit.flow_editor.node_properties.Configuration")),1)]),_:1}),t.createVNode(Vn,{error:t.unref(S).error.value,help:t.unref(S).errorMessage.value,label:t.unref(N),multiline:"",name:"jq",resizable:"",rows:"2",onBlur:t.unref(S).onBlur,"onUpdate:modelValue":t.unref(S).onUpdate},null,8,["error","help","label","onBlur","onUpdate:modelValue"]),t.createVNode(eo,{"field-name-validator":t.unref(_),"field-names":t.unref(m),items:t.unref(s),"onAdd:field":w,"onChange:input":t.unref(d),"onChange:inputs":t.unref(c),"onRemove:field":b,"onRename:field":v},null,8,["field-name-validator","field-names","items","onChange:input","onChange:inputs"])]),_:1},8,["data","schema"])}}}),fV=Ee(t.defineComponent({__name:"OutputValueField",props:{fieldNameValidator:{},name:{},initialValue:{},label:{},keyPlaceholder:{},valuePlaceholder:{},defaultKey:{},defaultValue:{},labelAttributes:{},showVaultSecretPicker:{type:Boolean},keyOrder:{}},emits:["change:value","add:field","rename:field","remove:field","change"],setup(e,{emit:n}){const o=e,r=n,i=t.ref({}),{entries:a,addEntry:l,removeEntry:s,field:c}=ha(o,r,!1),{i18n:d}=xe(),u=t.useTemplateRef("root"),f=t.ref(null);let p;async function m(N,E="key"){var S;u.value&&(await t.nextTick(),(S=u.value.querySelector(`[data-${E}-input="${N}"]`))==null||S.focus())}function h(){const N=l(),E=a.value.findIndex(({key:S})=>!S);m(E===-1?a.value.length-1:E),f.value=N}function y(N){var E;N.id===((E=f.value)==null?void 0:E.id)&&(f.value=null),s(N.id),N.key.trim()!==""&&r("remove:field",N.key)}function g(N){p=N.key}function _(N){var E;if(b(N)){N.key=p,delete i.value[N.id];return}if(N.id===((E=f.value)==null?void 0:E.id)){if(N.key.trim()==="")return;f.value=null,r("add:field",N.key,N.value)}else r("rename:field",p,N.key);p=N.key}function w(N,E){var P;if(E.id===((P=f.value)==null?void 0:P.id))return;const S=N.target.value.trim();r("change:value",E.key,S)}function b(N){delete i.value[N.id];const E=o.fieldNameValidator("output",p,N.key);if(E)return i.value[N.id]=E,E}function v(N){b(N)}return t.watchEffect(()=>{f.value&&!a.value.some(N=>N.id===f.value.id)&&a.value.push(f.value)}),(N,E)=>{const S=t.resolveComponent("KAlert"),P=t.resolveComponent("KLabel"),B=t.resolveComponent("KButton"),j=t.resolveComponent("KInput"),G=t.resolveComponent("KCard");return t.unref(c).error?(t.openBlock(),t.createBlock(S,{key:0,appearance:"danger",message:t.unref(c).error.message},null,8,["message"])):(t.openBlock(),t.createElementBlock("div",{key:1,ref_key:"root",ref:u,class:"dk-output-value-field"},[t.createVNode(P,{class:"dk-node-configuration-label"},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(d).t("plugins.free-form.datakit.flow_editor.node_properties.output_value.label")),1)]),_:1}),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(a),(T,Y)=>(t.openBlock(),t.createBlock(G,{key:T.id,class:"dk-output-value-field-entry","data-testid":`ff-kv-container-${t.unref(c).path.value}.${Y}`},{actions:t.withCtx(()=>[t.createVNode(B,{appearance:"none","data-testid":`ff-kv-remove-btn-${t.unref(c).path.value}.${Y}`,icon:"",onClick:I=>y(T)},{default:t.withCtx(()=>[t.createVNode(t.unref(Ne.CloseIcon))]),_:2},1032,["data-testid","onClick"])]),default:t.withCtx(()=>[t.createVNode(j,{id:`ff-kv-entry-key-${t.unref(c).path.value}.${Y}`,modelValue:T.key,"onUpdate:modelValue":[I=>T.key=I,I=>b(T)],modelModifiers:{trim:!0},class:"ff-kv-field-entry-key","data-key-input":Y,"data-testid":`ff-key-${t.unref(c).path.value}.${Y}`,error:!!i.value[T.id],"error-message":i.value[T.id],label:t.unref(d).t("plugins.free-form.datakit.flow_editor.node_properties.output_value.value_name"),required:"",onBlur:I=>v(T),onChange:I=>_(T),onFocus:I=>g(T)},null,8,["id","modelValue","onUpdate:modelValue","data-key-input","data-testid","error","error-message","label","onBlur","onChange","onFocus"]),t.createVNode(j,{modelValue:T.value,"onUpdate:modelValue":I=>T.value=I,modelModifiers:{trim:!0},class:"ff-kv-field-entry-value","data-testid":`ff-value-${t.unref(c).path.value}.${Y}`,label:t.unref(d).t("plugins.free-form.datakit.flow_editor.node_properties.output_value.value"),onChange:I=>w(I,T)},null,8,["modelValue","onUpdate:modelValue","data-testid","label","onChange"])]),_:2},1032,["data-testid"]))),128)),t.createVNode(B,{appearance:"tertiary","data-testid":`ff-kv-add-btn-${t.unref(c).path.value}`,disabled:!!f.value,onClick:h},{default:t.withCtx(()=>[t.createVNode(t.unref(Ne.AddIcon)),t.createTextVNode(" "+t.toDisplayString(t.unref(d).t("plugins.free-form.datakit.flow_editor.node_properties.output_value.add_button")),1)]),_:1},8,["data-testid","disabled"])],512))}}}),[["__scopeId","data-v-5e17f8cb"]]);function pV(e){const n={};for(const[o,r]of Object.entries(e))typeof r=="object"&&r!==null?n[o]=JSON.stringify(r):n[o]=String(r);return n}function Ti(e){const n={};for(const[o,r]of Object.entries(e))if(r!=null){n[o]=r;try{r==="null"?n[o]=null:(r==="true"||r==="false"||/^-?\d+(\.\d+)?$/.test(r)||r.startsWith("{")&&r.endsWith("}")||r.startsWith("[")&&r.endsWith("]"))&&(n[o]=JSON.parse(r))}catch{}}return n}function mV(e,n,o){const r={};for(const i of Object.keys(e))i===n?r[o]=e[n]:r[i]=e[i];return r}const gV=t.defineComponent({__name:"NodeFormStatic",props:{nodeId:{}},setup(e){const{renameNode:n,getOutEdgesByNodeId:o,addField:r,renameField:i,removeField:a,replaceConfig:l,getNodeById:s}=st(),{fieldNameValidator:c}=vn(e.nodeId),d=Sn("static"),u=dm(e.nodeId),f=t.computed(()=>s(e.nodeId)),p=t.computed(()=>{var b;return((b=f.value)==null?void 0:b.fields.output.map(v=>v.name))||[]});function m(b){if(!f.value)throw new Error("No current node");n(f.value.id,b??"")}const h=t.computed(()=>{var B;if(!f.value)return{};const b=((B=f.value.config)==null?void 0:B.values)??{},v={},N=o(f.value.id).map(j=>j.sourceField).filter(Boolean).map(j=>Wt(f.value,"output",j)).map(j=>j==null?void 0:j.name).filter(Boolean),E=f.value.fields.output.map(j=>j.name),S=Object.keys(b);return new Set([...S,...N,...E]).forEach(j=>{if(j in b){v[j]=b[j];return}v[j]=""}),{name:f.value.name,values:pV(v)}});function y(b,v){if(!f.value)throw new Error("No selected node");const N=v!==void 0;if(r(e.nodeId,"output",b,!N),N){const E={values:Ti({...h.value.values,[b]:v})};l(e.nodeId,E)}}function g(b,v){if(!f.value)throw new Error("No selected node");const N=jn(f.value,"output",b);if(!N)throw new Error("No field found to rename");const E={values:Ti(mV(h.value.values??{},b,v))};l(e.nodeId,E,!1),i(e.nodeId,N.id,v)}function _(b){var E;if(!f.value)throw new Error("No selected node");const v=jn(f.value,"output",b);if(!v)throw new Error("No field found to delete");a((E=f.value)==null?void 0:E.id,v.id,!0,!1);const N={values:Ti({...h.value.values})};delete N.values[b],l(e.nodeId,N)}function w(b,v){if(!f.value)throw new Error("No selected node");const N={...h.value.values};N[b]=v;const E={values:Ti(N)};l(e.nodeId,E)}return(b,v)=>(t.openBlock(),t.createBlock(pt,{ref:"form",data:h.value,schema:t.unref(d)},{default:t.withCtx(()=>{var N;return[t.createVNode(Wo,{name:((N=f.value)==null?void 0:N.name)??"",validate:t.unref(u),onUpdate:m},null,8,["name","validate"]),t.createVNode(fV,{"field-name-validator":t.unref(c),"key-order":p.value,name:"values","onAdd:field":y,"onChange:value":w,"onRemove:field":_,"onRename:field":g},null,8,["field-name-validator","key-order"])]}),_:1},8,["data","schema"]))}}),hV={class:"dk-kong-property-item"},yV={class:"property-type"},_V={class:"property-badges"},bV=Ee(t.defineComponent({__name:"PropertiesField",props:{validators:{}},emits:["update:model-value","update:property-key"],setup(e,{emit:n}){const{i18n:{t:o}}=xe(),r=e,i=n,{formData:a}=De(),l=t.ref(qo(a.property)),s=t.computed(()=>zo(a.property)),c=t.ref(Al(a.property)),d=t.computed(()=>a.property??""),u=t.computed(()=>Object.entries(En).map(([m])=>{var g;const h=zo(m)?(g=a.property)==null?void 0:g.startsWith(m.replace(Jn,"")):a.property===m;return{label:h&&c.value?m.replace(Jn,c.value):m,value:m,selected:h}}));function f(m){const h=ki.find(y=>{var g;return(g=a.property)==null?void 0:g.startsWith(y)});h&&(a.property=h+m,r.validators.key.handleChange(a.property),i("update:property-key",a.property))}function p(m){l.value!==qo(m==null?void 0:m.value)&&(a.property=(m==null?void 0:m.value)||null,l.value=qo(a.property),r.validators.property.handleBlur(()=>a.property),i("update:model-value",a.property))}return t.watch(()=>a.property,m=>{c.value=Al(m),l.value=qo(m)}),(m,h)=>{const y=t.resolveComponent("KBadge"),g=t.resolveComponent("KSelect"),_=t.resolveComponent("KInput");return t.openBlock(),t.createElementBlock(t.Fragment,null,[(t.openBlock(),t.createBlock(g,{key:d.value,"enable-filtering":"",error:!m.validators.property.isValid.value,help:m.validators.property.error.value,items:u.value,label:"Property","label-attributes":{maxWidth:"300px",placement:"top",info:"The property name to get/set"},required:"",onBlur:h[0]||(h[0]=w=>m.validators.property.handleBlur(()=>t.unref(a).property)),onChange:p},{"item-template":t.withCtx(({item:w})=>[t.createElementVNode("div",hV,[t.createElementVNode("div",null,[t.createElementVNode("div",null,t.toDisplayString(w.label),1),t.createElementVNode("div",yV,t.toDisplayString(t.unref(En)[w.value].dataType),1)]),t.createElementVNode("div",_V,[t.unref(En)[w.value].readable?(t.openBlock(),t.createBlock(y,{key:0,appearance:"info"},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(o)("plugins.free-form.datakit.flow_editor.node_properties.property.get")),1)]),_:1})):t.createCommentVNode("",!0),t.unref(En)[w.value].writable?(t.openBlock(),t.createBlock(y,{key:1,appearance:"warning"},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(o)("plugins.free-form.datakit.flow_editor.node_properties.property.set")),1)]),_:1})):t.createCommentVNode("",!0)])])]),_:1},8,["error","help","items"])),s.value?(t.openBlock(),t.createBlock(_,{key:0,"model-value":c.value,"onUpdate:modelValue":[h[1]||(h[1]=w=>c.value=w),f],error:!m.validators.key.isValid.value,"error-message":m.validators.key.error.value,label:"key",required:"",onBlur:h[2]||(h[2]=w=>m.validators.key.handleBlur(()=>t.unref(a).property))},null,8,["model-value","error","error-message"])):t.createCommentVNode("",!0)],64)}}}),[["__scopeId","data-v-0ab1be87"]]),wV=t.defineComponent({__name:"NodeFormProperty",props:{nodeId:{}},setup(e){const n=t.useTemplateRef("form"),{selectedNode:o,disconnectInEdges:r,disconnectOutEdges:i}=st(),a=Sn("property"),{formData:l,setName:s,setConfig:c,inputOptions:d,setInputs:u,setInput:f,inputsFieldNames:p,nameValidator:m,toggleNodeValid:h,skipValidationOnMount:y,fieldNameValidator:g}=vn(e.nodeId,()=>n.value.getInnerData()),_=t.computed(()=>Pl(l.value.property));function w(v){var E;const N=(E=o.value)==null?void 0:E.id;if(!N)throw new Error("Expected selectedNode to be defined");Il(v)||i(N,!1),Pl(v)||r(N,!1),c()}const{fields:b}=Pi({validationConfig:()=>({property:no({fieldName:"Property"}),key:zo(l.value.property)?no({fieldName:"Key"}):()=>{}}),getValidationData:()=>({property:l.value.property,key:Al(l.value.property)}),skipValidationOnMount:y,toggleNodeValid:h});return(v,N)=>(t.openBlock(),t.createBlock(pt,{ref:"form",data:t.unref(l),schema:t.unref(a)},{default:t.withCtx(()=>[t.createVNode(Wo,{name:t.unref(l).name,validate:t.unref(m),onUpdate:t.unref(s)},null,8,["name","validate","onUpdate"]),t.createVNode(Nt,{name:"content_type","onUpdate:modelValue":t.unref(c)},null,8,["onUpdate:modelValue"]),t.createVNode(bV,{validators:t.unref(b),"onUpdate:modelValue":w,"onUpdate:propertyKey":N[0]||(N[0]=E=>t.unref(c)("property-key"))},null,8,["validators"]),_.value?(t.openBlock(),t.createBlock(eo,{key:0,"field-name-validator":t.unref(g),"field-names":t.unref(p),items:t.unref(d),"onChange:input":t.unref(f),"onChange:inputs":t.unref(u)},null,8,["field-name-validator","field-names","items","onChange:input","onChange:inputs"])):t.createCommentVNode("",!0)]),_:1},8,["data","schema"]))}}),kV=t.defineComponent({__name:"NodeFormExit",props:{nodeId:{}},setup(e){const n=t.useTemplateRef("form"),o=Sn("exit"),{formData:r,setName:i,setConfig:a,inputOptions:l,setInputs:s,setInput:c,inputsFieldNames:d,nameValidator:u,toggleNodeValid:f,skipValidationOnMount:p,fieldNameValidator:m}=vn(e.nodeId,()=>n.value.getInnerData()),{createFieldHandler:h}=Pi({validationConfig:{status:to(sm("integer",{fieldName:"Status"}),cm(200,255,{fieldName:"Status"}))},getValidationData:()=>({status:r.value.status}),skipValidationOnMount:p,toggleNodeValid:f}),y=h("status",()=>a("status"));return(g,_)=>(t.openBlock(),t.createBlock(pt,{ref:"form",data:t.unref(r),schema:t.unref(o)},{default:t.withCtx(()=>[t.createVNode(Wo,{name:t.unref(r).name,validate:t.unref(u),onUpdate:t.unref(i)},null,8,["name","validate","onUpdate"]),t.createVNode(Rn,{error:t.unref(y).error.value,"error-message":t.unref(y).errorMessage.value,name:"status",onBlur:t.unref(y).onBlur,"onUpdate:modelValue":t.unref(y).onUpdate},null,8,["error","error-message","onBlur","onUpdate:modelValue"]),t.createVNode(ga,{name:"warn_headers_sent","onUpdate:modelValue":_[0]||(_[0]=w=>t.unref(a)())}),t.createVNode(eo,{"field-name-validator":t.unref(m),"field-names":t.unref(d),items:t.unref(l),"onChange:input":t.unref(c),"onChange:inputs":t.unref(s)},null,8,["field-name-validator","field-names","items","onChange:input","onChange:inputs"])]),_:1},8,["data","schema"]))}}),EV=["innerHTML"],CV=Ee(t.defineComponent({__name:"NodePropertiesPanel",props:{maxWidth:{default:()=>aN},offsetTop:{default:()=>lN},visible:{type:Boolean},nodeId:{}},emits:["close"],setup(e){const{getNodeById:n}=st(),o=t.computed(()=>e.nodeId&&n(e.nodeId)),r=t.computed(()=>{var i;switch((i=o.value)==null?void 0:i.type){case"call":return sV;case"service_request":return cV;case"response":return dV;case"jq":return uV;case"static":return gV;case"property":return wV;case"exit":return kV;default:return null}});return(i,a)=>(t.openBlock(),t.createBlock(t.unref(Pe.KSlideout),{class:"dk-node-properties-panel","close-on-blur":!1,"has-overlay":!1,"max-width":i.maxWidth,"offset-top":i.offsetTop,visible:i.visible,onClose:a[0]||(a[0]=l=>i.$emit("close"))},t.createSlots({default:t.withCtx(()=>[o.value?(t.openBlock(),t.createElementBlock("div",{key:0,class:"dk-node-properties-panel-desc",innerHTML:t.unref(St)(o.value.type)},null,8,EV)):t.createCommentVNode("",!0),r.value?(t.openBlock(),t.createBlock(t.unref(r),{key:i.nodeId,class:"dk-node-properties-panel-form","node-id":i.nodeId},null,8,["node-id"])):t.createCommentVNode("",!0)]),_:2},[o.value?{name:"title",fn:t.withCtx(()=>[t.createVNode(tm,{type:o.value.type},null,8,["type"])]),key:"0"}:void 0]),1032,["max-width","offset-top","visible"]))}}),[["__scopeId","data-v-1bb64727"]]),NV={class:"dk-editor-content"},vV={class:"header"},SV={class:"title"},xV={class:"body"},AV={class:"node-selection-panel"},IV={class:"main"},PV=Ee(t.defineComponent({__name:"EditorContent",setup(e){const{t:n}=Fe.createI18n("en-us",He),{sidePanelExpanded:o}=ja(),{propertiesPanelOpen:r,selectedNode:i,newCreatedNodeId:a}=st();function l(){r.value=!1,a.value=null}t.watch(i,c=>{c||l(),(!c||c.id!==a.value)&&(a.value=null)});const s=t.ref(!1);return t.onMounted(()=>{s.value=!0}),(c,d)=>{var u;return t.openBlock(),t.createElementBlock("div",NV,[t.createElementVNode("aside",{class:t.normalizeClass(["side-panel",{expanded:t.unref(o),inited:s.value}])},[t.createElementVNode("header",vV,[t.createElementVNode("h2",SV,t.toDisplayString(t.unref(n)("plugins.free-form.datakit.flow_editor.name")),1)]),t.createElementVNode("div",xV,[t.createElementVNode("div",AV,[t.createVNode(qB)])])],2),t.createElementVNode("div",IV,[t.createVNode(VB)]),t.createVNode(CV,{"node-id":(u=t.unref(i))==null?void 0:u.id,visible:t.unref(r),onClose:l},null,8,["node-id","visible"])])}}}),[["__scopeId","data-v-4fa0b782"]]),TV={key:0,class:"dk-editor-modal"},OV=Ee(t.defineComponent({__name:"EditorModal",props:{open:{type:Boolean},openModifiers:{}},emits:["update:open"],setup(e){t.useCssVars(l=>({f0b8bf7e:t.unref(iN),ab521f8a:t.unref(rN)}));const n=t.useModel(e,"open"),o=t.ref(!1),r=t.useTemplateRef("confirm-modal");Q$(async(...l)=>{o.value=!0;const s=await r.value.open(...l);return o.value=!1,s});const i=Ue.useScrollLock(document);t.watch(n,l=>{i.value=!!l},{immediate:!0});function a(){n.value=!1}return(l,s)=>n.value?(t.openBlock(),t.createElementBlock("div",TV,[t.createVNode(AB,{class:"nav",onBack:a}),t.createVNode(PV,{ref:"content",class:"content",tabindex:"0"},null,512),t.createVNode(NB,{ref:"confirm-modal"},null,512)])):t.createCommentVNode("",!0)}}),[["__scopeId","data-v-2a45bec4"]]),$V={class:"dk-flow-editor"},BV={class:"flow-panels-container"},VV={class:"overlay"},RV={class:"field"},DV=Ee(t.defineComponent({__name:"FlowEditor",props:{isEditing:{type:Boolean}},emits:["change","error"],setup(e,{emit:n}){var c,d;const{t:o}=Fe.createI18n("en-us",He),{formData:r}=De(),i=n,a=t.useTemplateRef("flowPanels");function l(u,f){const p={...r.config,nodes:u},m={...r.__ui_data,nodes:f};r.config=p,r.__ui_data=m,i("change",p,m)}const{modalOpen:s}=pN(((c=r.config)==null?void 0:c.nodes)??[],((d=r.__ui_data)==null?void 0:d.nodes)??[],{onChange:l,isEditing:e.isEditing});return t.watch(s,()=>{var u;s.value||(u=a.value)==null||u.fitView()}),(u,f)=>{const p=t.resolveComponent("KButton");return t.openBlock(),t.createElementBlock("div",$V,[t.createElementVNode("div",BV,[t.createVNode(im,{ref_key:"flowPanels",ref:a,readonly:""},null,512),t.createElementVNode("div",VV,[t.createVNode(p,{appearance:"secondary",class:"button-open-editor",onClick:f[0]||(f[0]=m=>s.value=!0)},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(o)("plugins.free-form.datakit.flow_editor.cta"))+" ",1),t.createVNode(t.unref(Ne.ExpandIcon))]),_:1})])]),t.createVNode(OV,{open:t.unref(s),"onUpdate:open":f[1]||(f[1]=m=>t.isRef(s)?s.value=m:null)},null,8,["open"]),t.createElementVNode("div",RV,[t.createVNode(ga,{name:"config.debug"})])])}}}),[["__scopeId","data-v-2cde866e"]]);function MV(e,n){const o=[],r=(i,a)=>{typeof a=="string"&&o.push({nodeName:e.name,path:["nodes",n,...i],value:a})};if("input"in e&&e.input!=null&&r(["input"],e.input),"inputs"in e&&e.inputs&&typeof e.inputs=="object")for(const[i,a]of Object.entries(e.inputs))a!=null&&r(["inputs",i],a);if("output"in e&&e.output!=null&&r(["output"],e.output),"outputs"in e&&e.outputs&&typeof e.outputs=="object")for(const[i,a]of Object.entries(e.outputs))a!=null&&r(["outputs",i],a);return o}function LV(e){const n=e.path[2];return n==="output"||n==="outputs"}function FV(e){if(!e)return!1;for(const n of Object.values(e))if(n!=null)return!0;return!1}function um(e,n,o){if(!e.nodes)return;const r=e.nodes.map(c=>c.name),i=new Set;r.forEach((c,d)=>{i.has(c)&&o.addIssue({code:"custom",message:`Duplicate node name: "${c}"`,path:["nodes",d,"name"]}),i.add(c)}),e.nodes.forEach((c,d)=>{const u="input"in c&&c.input!=null,f="inputs"in c&&FV(c.inputs);u&&f&&o.addIssue({code:"custom",message:'A node cannot use both "input" and "inputs". Use one or the other.',path:["nodes",d,"inputs"]})});const a=new Set([...n,...r]),l=new Map,s=new Map;e.nodes.forEach((c,d)=>{for(const u of MV(c,d)){const f=u.value.split(".",1)[0];if(a.has(f)||o.addIssue({code:"custom",message:`Unknown node "${f}" in connection "${u.value}"`,path:u.path}),LV(u)){const p=`${u.nodeName}->${f}`;s.has(p)?o.addIssue({code:"custom",message:`Connection specified on both sides: "${u.nodeName}" outputs to "${f}" and "${f}" inputs from "${u.nodeName}". Specify it on one side only.`,path:u.path}):l.set(p,l.get(p)??u.path)}else{const p=`${f}->${u.nodeName}`;l.has(p)?o.addIssue({code:"custom",message:`Connection specified on both sides: "${f}" outputs to "${u.nodeName}" and "${u.nodeName}" inputs from "${f}". Specify it on one side only.`,path:u.path}):s.set(p,s.get(p)??u.path)}}})}const UV=ce.z.enum(Br),KV=ce.z.enum(Vr),fm=e=>Br.includes(e),zl=ce.z.enum(["call","jq","exit","property","static"]),pm=zl.options;ce.z.union([zl,UV]);const jV=/^[A-Za-z_][A-Za-z0-9_-]{0,254}$/,mm=ce.z.string().min(1).max(255).regex(jV,"Invalid node name (snake_case / kebab-case only)").refine(e=>!fm(e),"Name clashes with reserved implicit node").brand(),gm=ce.z.union([KV,mm]),GV=ce.z.string().min(1).brand(),Ot=ce.z.string().refine(e=>{if(gm.safeParse(e).success)return!0;const n=e.match(/^([^.]+)\.([^.]+)$/);if(!n)return!1;const[,o,r]=n;return gm.safeParse(o).success&&GV.safeParse(r).success},'Invalid connection, expected "NODE" or "NODE.FIELD"').nullish(),hm=ce.z.enum(ou),Xo=ce.z.object({type:ce.z.string(),name:mm,input:Ot,inputs:ce.z.record(ce.z.string(),Ot).nullish(),output:Ot,outputs:ce.z.record(ce.z.string(),Ot).nullish()}).loose(),qV=ce.z.object({type:ce.z.string(),name:ce.z.string()}).loose().superRefine((e,n)=>{const o=e.type,r=e.name;(typeof r!="string"||r.length===0||r.includes("."))&&n.addIssue({code:"custom",path:["name"],message:"invalid node name",fatal:!1}),pm.includes(o)||n.addIssue({code:"custom",path:["type"],message:`unknown node type "${o}", expected one of: ${pm.join(", ")}`})}),zV=Xo.extend({type:ce.z.literal("call"),method:hm.nullish(),ssl_server_name:ce.z.string().min(1).nullish(),timeout:ce.z.number().int().min(0).max(2147483646).nullish(),url:ce.z.url(),inputs:ce.z.object({body:Ot,headers:Ot,query:Ot}).partial().nullish(),outputs:ce.z.object({body:Ot,headers:Ot,status:Ot}).partial().nullish()}).strict(),HV=Xo.extend({type:ce.z.literal("exit"),status:ce.z.number().int().min(200).max(599).nullish(),warn_headers_sent:ce.z.boolean().nullish(),output:ce.z.never().optional(),outputs:ce.z.never().optional()}).strict(),YV=Xo.extend({type:ce.z.literal("jq"),jq:ce.z.string().min(1).max(10240),outputs:ce.z.never().optional()}).strict(),WV=Xo.extend({type:ce.z.literal("property"),content_type:ce.z.enum(["application/json","text/plain","application/octet-stream"]).nullish(),property:ce.z.string().min(1),inputs:ce.z.never().optional(),outputs:ce.z.never().optional()}).strict(),XV=Xo.extend({type:ce.z.literal("static"),values:ce.z.record(ce.z.string(),ce.z.unknown()),input:ce.z.never().optional(),inputs:ce.z.never().optional()}).strict(),ZV=qV.pipe(ce.z.discriminatedUnion("type",[zV,HV,YV,WV,XV]));ce.z.object({nodes:ce.z.array(ZV).min(1,"At least one node is required"),debug:ce.z.boolean().nullish()}).strict().superRefine((e,n)=>{um(e,Br,n)});const ym=zl.options,JV=ce.z.string().min(1).refine(e=>!e.includes("."),"Invalid node name").refine(e=>!fm(e),"Node name conflicts with reserved implicit node"),$t=ce.z.string().refine(e=>{if(!e||/\s/.test(e))return!1;const n=e.indexOf(".");if(n===-1)return!0;const o=e.slice(0,n),r=e.slice(n+1);return o.length>0&&r.length>0},"Invalid connection"),Zo=ce.z.object({type:ce.z.string(),name:JV,input:$t.nullish(),inputs:ce.z.record(ce.z.string(),$t.nullish()).nullish(),output:$t.nullish(),outputs:ce.z.record(ce.z.string(),$t.nullish()).nullish()}).loose(),QV=ce.z.object({type:ce.z.string(),name:ce.z.string()}).loose().superRefine((e,n)=>{const o=e.type,r=e.name;(typeof r!="string"||r.length===0||r.includes("."))&&n.addIssue({code:"custom",path:["name"],message:"Invalid node name",fatal:!1}),ym.includes(o)||n.addIssue({code:"custom",path:["type"],message:`unknown node type "${o}", expected one of: ${ym.join(", ")}`})}),eR=Zo.extend({type:ce.z.literal("call"),method:hm.nullish(),ssl_server_name:ce.z.string().nullish(),timeout:ce.z.union([ce.z.number(),ce.z.string()]).nullish(),url:ce.z.string().nullish(),inputs:ce.z.object({body:$t.nullish(),headers:$t.nullish(),query:$t.nullish()}).partial().nullish(),outputs:ce.z.object({body:$t.nullish(),headers:$t.nullish(),status:$t.nullish()}).partial().nullish()}).strict(),tR=Zo.extend({type:ce.z.literal("exit"),status:ce.z.union([ce.z.number(),ce.z.string()]).nullish(),warn_headers_sent:ce.z.boolean().nullish(),output:ce.z.never().optional(),outputs:ce.z.never().optional()}).strict(),nR=Zo.extend({type:ce.z.literal("jq"),jq:ce.z.string().nullish(),outputs:ce.z.never().optional()}).strict(),oR=Zo.extend({type:ce.z.literal("property"),content_type:ce.z.string().nullish(),property:ce.z.string().nullish(),inputs:ce.z.never().optional(),outputs:ce.z.never().optional()}).strict(),rR=Zo.extend({type:ce.z.literal("static"),values:ce.z.record(ce.z.string(),ce.z.unknown()).nullish(),input:ce.z.never().optional(),inputs:ce.z.never().optional()}).strict(),iR=QV.pipe(ce.z.discriminatedUnion("type",[eR,tR,nR,oR,rR])),aR=ce.z.object({nodes:ce.z.array(iR).nullish(),debug:ce.z.boolean().nullish()}).strict().superRefine((e,n)=>{!e||!Array.isArray(e.nodes)||um(e,Vr,n)}).nullish(),lR={class:"option-label"},sR=["innerHTML"],cR=Ee(t.defineComponent({__name:"DatakitForm",props:{generalInfoTitle:{},generalInfoDescription:{},pluginConfigTitle:{},pluginConfigDescription:{},schema:{},formSchema:{},model:{},formModel:{},formOptions:{},isEditing:{type:Boolean},onModelUpdated:{type:Function},onFormChange:{type:Function},onValidityChange:{type:Function}},setup(e){const{t:n}=Fe.createI18n("en-us",He),o=e,r=t.inject(kc.DATAKIT_ENABLE_FLOW_EDITOR,!1),{editorMode:i}=ja(),a=t.computed(()=>r&&s.value?i.value:"code"),l={flow:Ne.DesignIcon,code:Ne.CodeblockIcon},s=t.ref(!0),c=t.computed(()=>{const h=[{label:n("plugins.free-form.datakit.flow_editor.mode"),value:"flow"},{label:n("plugins.free-form.datakit.code_editor.mode"),value:"code"}];return h[0].disabled=!s.value,h}),d=t.computed(()=>{switch(a.value){case"code":return n("plugins.free-form.datakit.description_code");case"flow":return n("plugins.free-form.datakit.description_flow");default:return""}});t.watch(a,()=>{var h;(h=o.onValidityChange)==null||h.call(o,{model:"config",valid:!0})});function u(){var h;(h=o.onValidityChange)==null||h.call(o,{model:"config",valid:!0})}function f(){u()}function p(h){u();const{success:y}=aR.safeParse(h);s.value=y}function m(h){var y;s.value=!1,(y=o.onValidityChange)==null||y.call(o,{model:"config",valid:!1,error:h})}return(h,y)=>{const g=t.resolveComponent("KTooltip");return t.openBlock(),t.createBlock(zc,t.mergeProps(o,{class:"dk-form"}),t.createSlots({default:t.withCtx(_=>[t.createVNode(pt,t.mergeProps(_,{tag:"div"}),{default:t.withCtx(()=>[a.value==="flow"?(t.openBlock(),t.createBlock(DV,{key:0,"is-editing":o.isEditing,onChange:f},null,8,["is-editing"])):a.value==="code"?(t.openBlock(),t.createBlock(QC,{key:1,class:"code-editor",editing:o.isEditing,onChange:p,onError:m},null,8,["editing"])):t.createCommentVNode("",!0)]),_:2},1040)]),"plugin-config-description":t.withCtx(()=>[t.createElementVNode("span",{innerHTML:d.value},null,8,sR)]),_:2},[t.unref(r)?{name:"plugin-config-extra",fn:t.withCtx(()=>[t.createVNode(t.unref(Pe.KSegmentedControl),{"model-value":a.value,options:c.value,"onUpdate:modelValue":y[0]||(y[0]=_=>i.value=_)},{"option-label":t.withCtx(({option:_})=>[t.createVNode(g,{disabled:s.value||_.value!=="flow",text:t.unref(n)("plugins.free-form.datakit.flow_editor.disabled_tooltip")},{default:t.withCtx(()=>[t.createElementVNode("div",lR,[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(l[_.value]))),t.createTextVNode(" "+t.toDisplayString(_.label),1)])]),_:2},1032,["disabled","text"])]),_:1},8,["model-value","options"])]),key:"0"}:void 0]),1040)}}}),[["__scopeId","data-v-ef778da1"]]),_m=e=>{if(!(!e||typeof e!="object"))for(const[n,o]of Object.entries(e))typeof o=="string"&&(e[n]=o.split(/\s*,\s*/).filter(Boolean))},bm=e=>{if(!(!e||typeof e!="object"))for(const[n,o]of Object.entries(e))Array.isArray(o)&&(e[n]=o.join(", "))},dR=t.defineComponent({__name:"ConfigForm",props:{schema:{},data:{},onChange:{type:Function}},emits:["change"],setup(e,{emit:n}){const o=n,{i18n:{t:r}}=Re.useI18n(),l={prepareFormData:c=>{var u,f;const d=Tn(c);return(f=(u=d.config)==null?void 0:u.tools)!=null&&f.length&&d.config.tools.forEach(p=>{bm(p.headers),bm(p.query)}),d},hasValue:c=>!!(c!=null&&c.config)},s=c=>{var u,f;const d=Tn(c);(f=(u=d.config)==null?void 0:u.tools)!=null&&f.length&&d.config.tools.forEach(p=>{_m(p.headers),_m(p.query)}),o("change",d)};return(c,d)=>(t.openBlock(),t.createBlock(pt,{config:l,data:c.data,schema:c.schema,tag:"div",onChange:s},{default:t.withCtx(()=>[t.createVNode(nt,{"as-child":"",name:"config","reset-label-path":"reset"},{tools:t.withCtx(({name:u})=>[t.createVNode(Cr,{appearance:"tabs","item-label":(f,p)=>t.unref(r)("plugins.free-form.ai-mcp-proxy.tool_item_label",{index:p+1}),name:u,"sticky-tabs":""},null,8,["item-label","name"])]),_:1}),t.createVNode(Nr)]),_:1},8,["data","schema"]))}}),uR=t.defineComponent({__name:"AIMcpProxyForm",props:{schema:{},formSchema:{},model:{},formModel:{},formOptions:{},isEditing:{type:Boolean},onModelUpdated:{type:Function},onFormChange:{type:Function}},setup(e){const n=e,o=t.useSlots();return t.provide(Ie.AUTOFILL_SLOT,o==null?void 0:o[Ie.AUTOFILL_SLOT_NAME]),(r,i)=>(t.openBlock(),t.createBlock(_a,t.normalizeProps(t.guardReactiveProps(n)),{default:t.withCtx(a=>[t.createVNode(dR,t.normalizeProps(t.guardReactiveProps(a)),null,16)]),_:1},16))}}),fR=Ee(t.defineComponent({__name:"ConfigForm",props:{schema:{},data:{}},emits:["change"],setup(e,{emit:n}){const o=n,r=t.computed(()=>{const l=e.schema.fields.find(d=>Object.keys(d)[0]==="config").config.fields,s=[],c=[];for(const d of l){const u=Object.keys(d)[0];d[u].required?s.push(u):c.push(u)}return{required:s,nonRequired:c}}),i={hasValue:l=>!!(l!=null&&l.config)};function a(l){o("change",l)}return(l,s)=>(t.openBlock(),t.createBlock(pt,{config:i,data:l.data,schema:l.schema,tag:"div",onChange:a},{default:t.withCtx(()=>[t.createVNode(nt,{"as-child":"",name:"config",omit:r.value.nonRequired,"reset-label-path":"reset"},null,8,["omit"]),t.createVNode(Nr,{class:"ff-advanced-fields"},{default:t.withCtx(()=>[t.createVNode(nt,{"as-child":"",name:"config",omit:r.value.required,"reset-label-path":"reset"},null,8,["omit"])]),_:1})]),_:1},8,["data","schema"]))}}),[["__scopeId","data-v-3e5ed51d"]]),wm=Object.freeze(Object.defineProperty({__proto__:null,AIMcpProxyForm:uR,CommonForm:t.defineComponent({__name:"CommonForm",props:{generalInfoTitle:{},generalInfoDescription:{},pluginConfigTitle:{},pluginConfigDescription:{},schema:{},formSchema:{},model:{},formModel:{},formOptions:{},isEditing:{type:Boolean},onModelUpdated:{type:Function},onFormChange:{type:Function},onValidityChange:{type:Function}},setup(e){const n=e,o=t.useSlots();return t.provide(Ie.AUTOFILL_SLOT,o==null?void 0:o[Ie.AUTOFILL_SLOT_NAME]),(r,i)=>(t.openBlock(),t.createBlock(zc,t.normalizeProps(t.guardReactiveProps(n)),{default:t.withCtx(a=>[t.createVNode(fR,t.normalizeProps(t.guardReactiveProps(a)),null,16)]),_:1},16))}}),DatakitForm:cR,RequestCalloutForm:Tw,ServiceProtectionForm:Sk},Symbol.toStringTag,{value:"Module"})),pR={class:"kong-ui-entities-plugin-form"},mR={key:1,class:"entity-form"},gR={class:"plugin-config-empty-state"},hR=Ee(t.defineComponent({__name:"PluginEntityForm",props:{config:{type:Object,required:!0,validator:e=>!(!e||!["konnect","kongManager"].includes(e==null?void 0:e.app)||e.app==="konnect"&&!e.controlPlaneId||e.app==="kongManager"&&typeof e.workspace!="string")},entityMap:{type:Object,default:()=>({})},record:{type:Object,default:()=>({})},schema:{type:Object,default:()=>({})},rawSchema:{type:Object,default:()=>({})},editing:{type:Boolean,default:!1},credential:{type:Boolean,default:!1},enableVaultSecretPicker:{type:Boolean,default:!1},enableRedisPartial:{type:Boolean,default:!1}},emits:["loading","model-updated","showNewPartialModal","globalAction","validity-change"],setup(e,{emit:n}){var me,ge;const o=Object.keys(Ie.sharedForms),r=Object.keys(wm);if(new Set([...o,...r]).size!==o.length+r.length)throw new Error("Duplicate form component names found in `sharedForms` and `freeForm`");const i=n,a=e,{axiosInstance:l}=se.useAxios((me=a.config)==null?void 0:me.axiosRequestConfig),{parseSchema:s}=Re.useSchemas({entityId:((ge=a.entityMap.focusedEntity)==null?void 0:ge.id)||void 0,credential:a.credential,enableRedisPartial:a.enableRedisPartial,experimentalRenders:a.config.app==="konnect"?a.config.experimentalRenders:void 0}),{convertToDotNotation:c,unFlattenObject:d,dismissField:u,isObjectEmpty:f,unsetNullForeignKey:p}=Re.usePluginHelpers(),m=Re.useExperimentalFreeForms(),{objectsAreEqual:h}=se.useHelpers(),{i18n:{t:y}}=xe(),g=ne=>a.config.app==="konnect"?ne.replace(/{controlPlaneId}/gi,a.config.controlPlaneId||""):a.config.app==="kongManager"?ne.replace(/\/{workspace}/gi,a.config.workspace?`/${a.config.workspace}`:""):ne,_=(ne,re)=>{let q=`${a.config.apiBaseUrl}${Me.form[a.config.app].entityGetOne}`;return q=g(q),q=q.replace(/{entity}/gi,ne),q=q.replace(/{id}/gi,re),q},w=ne=>{let re=`${a.config.apiBaseUrl}${Me.form[a.config.app].entityGetAll}`;return re=g(re),re=re.replace(/{entity}/gi,ne),re},b=(ne,re)=>{const q=_(ne,re);return l.get(q)},v=(ne,re)=>{const q=w(ne);return a.config.app==="konnect"?l.get(q).then(ee=>{const{data:{data:O}}=ee;if(delete re.size,delete re.offset,O.length&&Object.keys(re).length===1){const k=Object.keys(re)[0],C=O.filter(x=>x[k]?!!x[k].toLowerCase().includes(re[k].toLowerCase()):!1);ee.data.data=C}return ee}):l.get(q,{params:re})},N=(ne,re,q)=>{const ee=w(ne);if(a.config.app==="konnect"){const{size:O,offset:k,...C}=re;if(ne==="consumer_groups")return l.get(ee,{params:{size:1e3},signal:q}).then(A=>{const{data:{data:U}}=A;if(U.length&&Object.keys(C).length===1){const V=Object.keys(C)[0],J=U.filter($=>$[V]?!!$[V].toLowerCase().includes(C[V].toLowerCase()):!1);A.data.data=J}return A});const x={size:O,offset:k};for(const A of Object.keys(C))x.filter={[A]:{contains:C[A]}};return l.get(ee,{params:x,signal:q})}return l.get(ee,{params:re,signal:q})},E=(ne,re=50)=>{const q=w(ne);return l.get(q,{params:{size:re}})};t.provide(Ie.FORMS_API_KEY,{getOne:b,getAll:v,getAllV2:N,peek:E}),t.provide(Ie.FORMS_CONFIG,a.config);const S=t.ref(""),P=t.ref(""),B=t.ref(null),j=t.ref({}),G=t.reactive({}),T=t.reactive({}),Y=t.computed(()=>{var ne;return(ne=B.value)==null?void 0:ne.options}),I=t.ref(!1),M=t.ref(),R=(ne,re)=>{I.value=ne??"",M.value=re},te=ne=>{var re;(re=M.value)==null||re.call(M,ne),I.value=!1},z=()=>{var C,x;const ne={...a.schema},re=T,q=G,ee=Object.keys(re),O={};if(!f(j.value))for(let A=0;A<((x=(C=j.value)==null?void 0:C.fields)==null?void 0:x.length);A++)ne[j.value.fields[A].model]=j.value.fields[A];Ie.customFields.forEach(A=>{ne[A]&&(ne[A].fields.forEach(U=>{U.fields&&U.fields.forEach(V=>{ne[V.model]=V}),U.model&&(ne[U.model]=U)}),delete ne[A])}),ee.forEach(A=>{var _e;if(!ne[A]){A==="partials"&&(O[A]=re[A]);return}const U=ne[A];let V=re[A];const J=q[A],$=Array.isArray(V)?"array":typeof V,X=U?U.valueType:null,D=U?U.valueArrayType:null,pe=U?U.transform:null;if(V==null&&J==null&&!U.submitWhenNull)return;if(U){if(X&&$!==X)switch(X){case"array":$==="string"&&V.length&&(V=V.split(",").map(fe=>{if(fe=fe.trim(),D==="string")return String(fe);if(D==="number")return Number(fe);if(D==="boolean"){if(typeof fe=="string")return fe.toLowerCase()==="true"||fe==="1";if(typeof fe=="number")return fe===1}return fe})),(!V||!V.length)&&(V=U.submitWhenNull?null:[]);break;case"number":V=Number(V);break;case"boolean":$==="string"&&(V=V.toLowerCase()==="true"||V==="1"),$==="number"&&(V=V===1);break;case"string":V=V==null?"":String(V);break}else X==="array"&&(!V||!V.length?V=U.submitWhenNull?null:[]:((_e=U.inputAttributes)==null?void 0:_e.type)==="number"&&(V=V.map(fe=>Number(fe))));if(U.type==="array"&&U.nestedFields){const fe=oe=>{Object.keys(oe).forEach(be=>{oe[be]&&typeof oe[be]=="object"&&!Array.isArray(oe[be])&&oe[be]!==null?fe(oe[be]):(oe[be]===void 0||oe[be]===null||typeof oe[be]=="number"&&isNaN(oe[be])||typeof oe[be]=="string"&&oe[be].trim().length===0)&&delete oe[be]})};V&&typeof V=="object"&&fe(V)}U.type==="object-advanced"&&U.fields&&V!==null&&(Object.entries(V).length===0?V=null:Object.keys(V).forEach(fe=>{Array.isArray(V[fe])||(V[fe]=V[fe].split(","))}))}let le=c(A);if(U.fieldNameHasDashes){const[fe,...oe]=le.split(".").reverse();le=[fe.replace(/_/g,"-"),...oe].reverse().join(".")}if(X==="object-expand"){let fe;[le,fe]=le.split(".");let oe={};O[le]&&(oe=O[le]),oe[fe]=V,V=oe}J!==void 0&&V===""&&V!==J?O[le]=X==="object"?{}:null:U.type==="checklist"&&V===""?O[le]=[]:V!==""&&(O[le]=V),O[le]=pe?pe(V):O[le],p(le,O)});const k=d(O);return P.value&&Object.assign(k,Q.value),k},H=(ne,re={})=>{u(T,re,ne,a.editing),i("model-updated",{model:T,originalModel:G,data:z()})},L=(ne,re)=>{var O;const q={[re]:ne};typeof((O=a.schema[re])==null?void 0:O.modelTransformer)=="function"&&(q[re]=a.schema[re].modelTransformer(ne));const ee=Object.assign({},T,q);Object.assign(T,ee),i("model-updated",{model:T,originalModel:G,data:z()})},F=ne=>{i("validity-change",ne)},Z=(ne,re)=>{Object.keys(ne).forEach(q=>{var x,A;let ee=re?`${re}-${q}`:q,O=a.schema[ee];if(!O){const U=re?`${re}-${q.replace(/-/g,"_")}`:q.replace(/-/g,"_");(x=a.schema[U])!=null&&x.fieldNameHasDashes&&(ee=U,O=a.schema[ee]),re&&((A=a.schema[re])==null?void 0:A.keyFromObject)===q&&(ee=re,O=a.schema[ee])}const k=ne[q],C=typeof k;if(O&&O.type==="object-advanced"&&!k){T[ee]={},G[ee]={};return}if(Array.isArray(k)){T[ee]=JSON.parse(JSON.stringify(k)),G[ee]=JSON.parse(JSON.stringify(k));return}if(C==="object"&&k&&!k.length)return Z(k,ee);if(C==="object"&&k&&k.length&&O.type==="input"){T[ee]=k.join(", "),G[ee]=k.join(", ");return}T[ee]=k,G[ee]=k}),i("model-updated",{model:T,originalModel:G,data:z()})},Q=t.shallowRef(a.record),W=ne=>{Q.value=ne,i("model-updated",{model:{...T,...ne},originalModel:G,data:z()})},ie=t.ref(!0),ae=()=>{var ne;if(a.record&&a.schema&&(Z({enabled:a.record.enabled??!0,...a.record.instance_name&&{instance_name:a.record.instance_name||""},...a.record.protocols&&{protocols:a.record.protocols},...a.record.tags&&{tags:a.record.tags}}),a.credential?((a.record.consumer_id||a.record.consumer)&&Z({consumer_id:a.record.consumer_id||a.record.consumer}),Z(a.record)):a.record.config&&((a.record.consumer_id||a.record.consumer||a.record.service_id||a.record.service||a.record.route_id||a.record.route||a.record.consumer_group_id||a.record.consumer_group)&&Z({service_id:a.record.service_id||a.record.service,route_id:a.record.route_id||a.record.route,consumer_id:a.record.consumer_id||a.record.consumer,consumer_group_id:a.record.consumer_group_id||a.record.consumer_group}),a.record.partials&&H("redis",{partials:a.record.partials}),P.value?W(a.record):Z(a.record.config,"config"))),Object.keys(a.entityMap).length&&!a.entityMap.global&&a.schema){const re={};for(const q in a.entityMap){const ee=a.entityMap[q].id,O=a.entityMap[q].idField,k=O==="consumer_group_id"?"consumer_group-id":JSON.parse(JSON.stringify(O).replace("_","-"));Object.prototype.hasOwnProperty.call(T,k)&&(re[k]=ee)}Z(re)}if((ne=a.entityMap.consumer)!=null&&ne.id&&a.schema&&a.credential){const re={};Object.prototype.hasOwnProperty.call(T,"consumer")&&(re.consumer=a.entityMap.consumer.id),Z(re)}ie.value=!1};return t.watch(ie,ne=>{i("loading",ne)}),t.watch(()=>a.schema,(ne,re)=>{var ee,O;if(h(ne||{},re||{}))return;const q=s(ne);Object.assign(T,q.model),j.value={fields:(O=(ee=j.value)==null?void 0:ee.fields)==null?void 0:O.map(k=>({...k,disabled:k.disabled||!1}))},Object.assign(G,JSON.parse(JSON.stringify(q.model))),P.value=wc(q.model.name,m),S.value=Ie.getSharedFormName(q.model.name),ae()},{immediate:!0,deep:!0}),t.onBeforeMount(()=>{var ne,re;B.value=s(a.schema),Object.assign(T,((ne=B.value)==null?void 0:ne.model)||{}),j.value=((re=B.value)==null?void 0:re.schema)||{},ae()}),(ne,re)=>{var ee;const q=t.resolveComponent("KSkeleton");return t.openBlock(),t.createElementBlock(t.Fragment,null,[t.createElementVNode("div",pR,[ie.value?(t.openBlock(),t.createBlock(q,{key:0,type:"form"})):T.id&&e.editing||!e.editing?(t.openBlock(),t.createElementBlock("div",mR,[P.value?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(wm[P.value]),{key:0,"form-model":T,"form-options":Y.value,"form-schema":j.value,"is-editing":e.editing,model:e.record,"on-form-change":W,"on-model-updated":L,"on-validity-change":F,schema:e.rawSchema,onGlobalAction:re[0]||(re[0]=(O,k)=>ne.$emit("globalAction",O,k))},t.createSlots({_:2},[e.enableVaultSecretPicker?{name:t.unref(Ie.AUTOFILL_SLOT_NAME),fn:t.withCtx(O=>[O.schema.referenceable?(t.openBlock(),t.createBlock(t.unref(ar.VaultSecretPickerProvider),t.mergeProps({key:0},O,{onOpen:R}),null,16)):t.createCommentVNode("",!0)]),key:"0"}:void 0]),1064,["form-model","form-options","form-schema","is-editing","model","schema"])):S.value?(t.openBlock(),t.createBlock(t.resolveDynamicComponent(t.unref(Ie.sharedForms)[S.value]),{key:1,"enable-redis-partial":e.enableRedisPartial,"form-model":T,"form-options":Y.value,"form-schema":j.value,"is-editing":e.editing,"on-model-updated":L,"on-partial-toggled":H,"show-new-partial-modal":O=>ne.$emit("showNewPartialModal",O)},t.createSlots({_:2},[e.enableVaultSecretPicker?{name:t.unref(Ie.AUTOFILL_SLOT_NAME),fn:t.withCtx(O=>[O.schema.referenceable?(t.openBlock(),t.createBlock(t.unref(ar.VaultSecretPickerProvider),t.mergeProps({key:0},O,{onOpen:R}),null,16)):t.createCommentVNode("",!0)]),key:"0"}:void 0]),1064,["enable-redis-partial","form-model","form-options","form-schema","is-editing","show-new-partial-modal"])):(t.openBlock(),t.createBlock(t.unref(Ie.VueFormGenerator),{key:2,"enable-redis-partial":e.enableRedisPartial,"is-editing":e.editing,model:T,options:Y.value,schema:j.value,onModelUpdated:L,onPartialToggled:H,onRefreshModel:z,onShowNewPartialModal:re[1]||(re[1]=O=>ne.$emit("showNewPartialModal",O))},t.createSlots({"plugin-config-empty-state":t.withCtx(()=>[t.createElementVNode("div",gR,t.toDisplayString(t.unref(y)("plugins.form.grouping.plugin_configuration.empty")),1)]),_:2},[(ee=t.unref(Et)[T.name])!=null&&ee.fieldRules&&(a.config.isNewOtelSchema||T.name!=="opentelemetry")?{name:"plugin-config-before-content",fn:t.withCtx(()=>[t.createVNode(B0,{rules:t.unref(Et)[T.name].fieldRules},null,8,["rules"])]),key:"0"}:void 0,e.enableVaultSecretPicker?{name:t.unref(Ie.AUTOFILL_SLOT_NAME),fn:t.withCtx(O=>[O.schema.referenceable?(t.openBlock(),t.createBlock(t.unref(ar.VaultSecretPickerProvider),t.mergeProps({key:0},O,{onOpen:R}),null,16)):t.createCommentVNode("",!0)]),key:"1"}:void 0]),1032,["enable-redis-partial","is-editing","model","options","schema"]))])):t.createCommentVNode("",!0)]),t.createVNode(t.unref(ar.VaultSecretPicker),{config:a.config,setup:I.value,onCancel:re[2]||(re[2]=()=>I.value=!1),onProceed:te},null,8,["config","setup"])],64)}}}),[["__scopeId","data-v-5728fdd6"]]),yR={key:1},_R=t.defineComponent({__name:"PluginFormActionsWrapper",props:{teleportTarget:{type:String,default:""}},setup(e){return(n,o)=>e.teleportTarget?(t.openBlock(),t.createBlock(t.Teleport,{key:0,to:e.teleportTarget},[t.renderSlot(n.$slots,"default")],8,["to"])):(t.openBlock(),t.createElementBlock("div",yR,[t.renderSlot(n.$slots,"default")]))}}),bR={class:"kong-ui-entities-plugin-form-container"},wR={key:0},kR={class:"plugin-form-actions"},ER=Ee(t.defineComponent({__name:"PluginForm",props:{config:{type:Object,required:!0,validator:e=>!(!e||!["konnect","kongManager"].includes(e==null?void 0:e.app)||e.app==="konnect"&&!e.controlPlaneId||e.app==="kongManager"&&typeof e.workspace!="string")},pluginType:{type:String,required:!0},pluginId:{type:String,default:""},hideScopeSelection:{type:Boolean,default:!1},disableScopeSelection:{type:Boolean,default:!1},credential:{type:Boolean,default:!1},developer:{type:Boolean,default:!1},isWizardStep:{type:Boolean,default:!1},actionsTeleportTarget:{type:String,default:""},noCardWrapper:{type:Boolean,default:!1},hideViewConfigAction:{type:Boolean,default:!1},enableVaultSecretPicker:{type:Boolean,default:!1},schema:{type:Object,default:null},enableRedisPartial:{type:Boolean,default:!1},scopedEntitiesPermissions:{type:Object,default:null}},emits:["cancel","error:fetch-schema","error","loading","update","model-updated","showNewPartialModal","globalAction"],setup(e,{emit:n}){var J;const o=n,r=e,i=oo.useRouter(),{i18n:{t:a}}=Re.useI18n(),{customSchemas:l,typedefs:s}=Re.useSchemas({app:r.config.app,credential:r.credential,experimentalRenders:r.config.app==="konnect"?r.config.experimentalRenders:void 0}),{formatPluginFieldLabel:c}=Re.usePluginHelpers(),{getMessageFromError:d}=se.useErrors(),{capitalize:u}=se.useStringHelpers(),{objectsAreEqual:f}=se.useHelpers(),{axiosInstance:p}=se.useAxios((J=r.config)==null?void 0:J.axiosRequestConfig),m=t.ref(!1),h=t.computed(()=>!!r.pluginId),y=t.computed(()=>r.pluginId?se.EntityBaseFormType.Edit:se.EntityBaseFormType.Create),g=t.ref(void 0),_=t.ref(void 0),w=t.computed(()=>!!(r.credential&&r.config.entityId)),b=t.ref(void 0),v=t.ref({}),N=t.ref(),E=t.ref();t.provide(jc,{redisType:N,redisPath:E,isEditing:h.value});const S=t.ref(!1),P=t.reactive({enabled:!0,protocols:[],tags:[]}),B=t.reactive({fields:{enabled:!0,protocols:[],tags:[]},isReadonly:!1,clientErrorMessage:"",serverErrorMessage:""}),j=t.ref([{title:a("view_configuration.json"),hash:"#json"},{title:a("view_configuration.yaml"),hash:"#yaml"}]);r.config.app==="konnect"&&j.value.splice(1,0,{title:a("view_configuration.terraform"),hash:"#terraform"});const G=t.ref(""),T=t.computed(()=>{var X;if(w.value){let D=Me.form[r.config.app].credential[y.value];return D=D.replace(/{resourceEndpoint}/gi,R.value),D}let $;return r.config.entityType&&r.config.entityId?$=Me.form[r.config.app].edit.forEntity.replace(/{entityType}/gi,r.config.entityType).replace(/{entityId}/gi,r.config.entityId):$=Me.form[r.config.app].edit.all,r.config.app==="konnect"&&((X=Et[r.pluginType])!=null&&X.useUIData)?`${$}?__ui_data=true`:$}),Y=()=>{m.value=!m.value},I=t.computed(()=>{var _e,fe,oe,be,ve,ue,de,it;const $=r.config.entityType==="consumers"&&r.config.entityId||((fe=(_e=b.value)==null?void 0:_e.consumer)==null?void 0:fe.id),X=r.config.entityType==="consumer_groups"&&r.config.entityId||((be=(oe=b.value)==null?void 0:oe.consumer_group)==null?void 0:be.id),D=r.config.entityType==="services"&&r.config.entityId||((ue=(ve=b.value)==null?void 0:ve.service)==null?void 0:ue.id),pe=r.config.entityType==="routes"&&r.config.entityId||((it=(de=b.value)==null?void 0:de.route)==null?void 0:it.id);if(!($||X||D||pe))return{global:{entity:K.PluginScope.GLOBAL,entityEndpoint:"plugins"}};const le={};return D&&(le.service={entity:K.PluginScope.SERVICE,entityEndpoint:"services",id:D,idField:nn.SERVICE}),pe&&(le.route={entity:K.PluginScope.ROUTE,entityEndpoint:"routes",id:pe,idField:nn.ROUTE}),$&&(le.consumer={entity:K.PluginScope.CONSUMER,entityEndpoint:"consumers",id:$,idField:nn.CONSUMER}),X&&(le.consumer_group={entity:K.PluginScope.CONSUMER_GROUP,entityEndpoint:"consumer_groups",id:X,idField:nn.CONSUMER_GROUP}),r.config.entityType&&(le.focusedEntity={entity:K.PluginScope[r.config.entityType.substring(0,r.config.entityType.length-1).toUpperCase()],entityEndpoint:r.config.entityType,id:r.config.entityId,idField:nn[r.config.entityType.substring(0,r.config.entityType.length-1).toUpperCase()]}),le}),M=t.reactive({name:{default:r.pluginType,type:"input",inputType:"hidden",styleClasses:"d-none hidden-field",pinned:!0},enabled:{type:"switch",model:"enabled",label:a("plugins.form.fields.enabled.label"),textOn:a("plugins.form.fields.enabled.on_text"),textOff:a("plugins.form.fields.enabled.off_text"),styleClasses:"field-switch hide-label",default:!0,pinned:!0},selectionGroup:{type:r.hideScopeSelection&&(r.hideScopeSelection||y.value===se.EntityBaseFormType.Create&&r.config.entityId)?"foreign":"selectionGroup",disabled:r.disableScopeSelection,inputType:"hidden",styleClasses:"hide-label",fields:[{label:a("plugins.form.scoping.global.label"),description:a("plugins.form.scoping.global.help")}],pinned:!0},protocols:{id:"protocols",default:[],help:a("plugins.form.fields.protocols.help"),label:a("plugins.form.fields.protocols.label"),required:!0,styleClasses:"plugin-protocols-select",type:"multiselect",values:[{label:"grpc",value:"grpc"},{label:"grpcs",value:"grpcs"},{label:"http",value:"http"},{label:"https",value:"https"},{label:"tcp",value:"tcp"},{label:"tls",value:"tls"},{label:"tls_passthrough",value:"tls_passthrough"},{label:"udp",value:"udp"},{label:"ws",value:"ws"},{label:"wss",value:"wss"}]},instance_name:{default:"",type:"input",label:a("plugins.form.fields.instance_name.label"),inputType:"text",help:a("plugins.form.fields.instance_name.help")},tags:s.tags}),R=t.computed(()=>{var D;const $=r.developer?"developers":"consumers",X=((D=An[r.pluginType])==null?void 0:D.endpoint)||"/plugins";return`${$}/${r.config.entityId}${r.developer?"/credentials":""}${X}`}),te=$=>{const X=Array.from(new Set($.map(D=>typeof D)));return X.length>1?"string":X[0]},z=($,X,D,pe)=>{var oe,be;let le=X&&X.fields||[];const _e=l[r.pluginType],fe=(be=(oe=An[r.pluginType])==null?void 0:oe.schema)==null?void 0:be.fields;return Array.isArray(le)&&(le=le.reduce((ve,ue)=>{const de=Object.keys(ue)[0];return de.match(/-/g)?ve[de.replace(/-/g,"_")]={...ue[de],fieldNameHasDashes:!0}:ve[de]=ue[de],ve},{})),Object.keys(le).sort().forEach(ve=>{var Jo,Qo,er,tr,nr,or,rr;const ue=le[ve];ue.type==="set"&&(ue.type="array");const de=$?`${$}-${ve}`:`${ve}`;if((Jo=_e==null?void 0:_e.fieldsToDelete)!=null&&Jo.includes(de)){bc(D,de);return}if(Object.prototype.hasOwnProperty.call(ue,"overwrite")||ue.hidden)return;if(ue.type==="table")return z(de,ue.schema,D);if(ue.fields)return pe&&ue.type==="record"?(D[de]={type:"object",model:ve,schema:{fields:Object.values(z(de,ue,{},!0))}},D):z(de,ue,D);if(D[de]={id:de,model:ve},D[de].type=ue.type==="boolean"?"checkbox":"input",D[de].required=ue.required,D[de].referenceable=ue.referenceable,de.startsWith("config-"))if(!pe&&ue.type==="array"&&(G.value=de),pe&&G.value&&de.startsWith(G.value)){const Se=de.slice(G.value.length+1);D[de].label=Se.split("-").map(c).join(".")}else D[de].label=c(de);if(($==="config"||$.startsWith("config-"))&&(Qo=le[ve])!=null&&Qo.description&&(D[de].help=ir.marked.parse(le[ve].description,{mangle:!1,headerIds:!1})),ue.type==="map"){if(D[de].type="object-advanced",D[de].values=ue.values,ue.values.type==="array"){const{type:Se}=ue.values.elements||{};D[de].schema={fields:[{schema:{fields:[{...Te,model:de,valueArrayType:Se==="integer"?"number":Se||"string",inputAttributes:{...Te.inputAttributes,type:Se==="integer"?"number":"text",inputMode:Se==="integer"?"numeric":"text"}}]}}]}}else ue.values.fields&&(D[de].schema={fields:[{type:"object",model:"object",schema:{fields:ue.values.fields.map(Se=>{const at=Object.keys(Se)[0];return{model:at,type:"input",label:u(at),placeholder:at,inputType:Se[at].type}})}}]});return D}if(ue.enum&&ue.type==="array"&&(D[de].type="checklist",D[de].values=ue.enum,D[de].multi=!0,D[de].multiSelect=!0),ue.one_of&&ue.type!=="array"&&(D[de].type="select",D[de].values=ue.one_of,D[de].selectOptions={noneSelectedText:a("plugins.form.no_selection")}),ue.elements&&ue.type==="array"){const Se=ue.elements;if(D[de].referenceable=Se.referenceable,D[de].elements=Se,["string","integer","number"].includes(Se.type)&&!Se.one_of){const{id:at,help:Le,label:Ce,hint:Ae,values:$e,referenceable:zt,model:dt}=D[de],{inputAttributes:Oi,...gD}=JSON.parse(JSON.stringify(Te));Oi.type=Se.type==="string"?"text":"number",D[de]={id:at,help:Le,label:Ce,hint:Ae,values:$e,referenceable:zt,model:dt,inputAttributes:Oi,...gD}}}if(ue.hint&&(D[de].hint=ue.hint),_e&&!_e.overwriteDefault&&Object.keys(_e).forEach(Se=>{if(Se===de){const{help:at,label:Le,hint:Ce,values:Ae,referenceable:$e,elements:zt}=D[de],{help:dt,...Oi}=_e[Se];D[de]={help:at,label:Le,hint:Ce,values:Ae,referenceable:$e,elements:zt,...Oi},typeof dt=="string"&&(D[de].help=ir.marked.parse(dt,{mangle:!1,headerIds:!1}))}}),ue.type==="array"&&((er=ue.elements)==null?void 0:er.type)==="record"&&Array.isArray(ue.elements.fields)){let Se={};for(const Le of ue.elements.fields)Se={...Se,...Le};const at=(or=(nr=(tr=D[de])==null?void 0:tr.items)==null?void 0:nr.schema)==null?void 0:or.fields;if(Array.isArray(at))for(const Le of D[de].items.schema.fields){const Ce=(rr=Se[Le.model])==null?void 0:rr.description;Le.help===void 0&&typeof Ce=="string"&&(Le.help=ir.marked.parse(Ce,{mangle:!1,headerIds:!1}))}if(at||(D[de].type="array",D[de].newElementButtonLabelClasses="kong-form-new-element-button-label",D[de].fieldClasses="array-card-container-wrapper",D[de].itemContainerComponent="FieldArrayCardContainer",D[de].items={type:"object",schema:{fields:Object.values(z(de,ue.elements,{},!0))}},D[de].items.schema.fields.forEach(Le=>{var Ce,Ae;for(const $e of ue.elements.fields){const zt=Object.keys($e)[0],dt=((Ae=(Ce=Le.id)==null?void 0:Ce.split)==null?void 0:Ae.call(Ce,"-"))??[];if(dt[dt.length-1]===zt){Le.model=zt,Le.label=c(zt);break}}}),ue.elements.type==="record"&&(D[de].nestedFields=!0)),!D[de].nestedFields)D[de].items.default=()=>ue.elements.fields.reduce((Le,Ce)=>{const Ae=Object.keys(Ce)[0];return Le[Ae]=Ce[Ae].default,Le},{});else{const Le=(Ce,Ae)=>{if(Ce.type==="object"){Ce.model&&(Ae[Ce.model]={});for(const $e of Ce.schema.fields)Le($e,Ce.model?Ae[Ce.model]:Ae)}else Ce.model&&(Ae[Ce.model]=Ce.default)};D[de].items.default=()=>{const Ce={};return Le(D[de].items,Ce),Ce}}}if(w.value&&fe){for(let Se=0;Se<fe.length;Se++)if(fe[Se][de]){D[de]={...D[de],...fe[Se][de]};break}}if(ue.required&&ue.type!=="boolean"&&(D[de].required=!0,D[de].selectOptions={hideNoneSelectedText:!0}),ue.required&&ue.type==="boolean"&&(D[de].default=ue.default??!1),ue.default!=null&&typeof ue.default!="object"&&ue.default!=="function"&&(D[de].default=ue.default),D[de].type==="input"){["string","number"].includes(typeof D[de].default)&&r.config.app==="konnect"&&(D[de].placeholder=`Default: ${D[de].default===""?"<empty string>":D[de].default}`);const{type:Se}=ue.elements||{};Se&&(D[de].valueArrayType=Se==="integer"?"number":Se),D[de].inputType=ue.type==="array"||ue.type==="string"?ue.encrypted?"password":"text":ue.type}let it="string";ue.enum?it=te(ue.enum):ue.type==="boolean"?it="boolean":ue.type==="number"||ue.type==="integer"?(it="number",D[de].inputType="number"):ue.type==="array"?(it="array",D[de].default=ue.default,ue.len_min>0&&(D[de].submitWhenNull=!0)):ue.type==="foreign"?it="object":ue.default&&Array.isArray(ue.default)?(it="array",D[de].valueArrayType=te(ue.default)):ue.default&&(it=typeof ue.default),D[de].valueType=it,ue.fieldNameHasDashes&&(D[de].fieldNameHasDashes=!0)}),D},H=()=>{var de,it,Jo,Qo,er,tr,nr,or,rr,Se,at,Le;const $=((de=Et[r.pluginType])==null?void 0:de.scope.includes(K.PluginScope.SERVICE))??!0,X=((it=Et[r.pluginType])==null?void 0:it.scope.includes(K.PluginScope.ROUTE))??!0,D=((Jo=Et[r.pluginType])==null?void 0:Jo.scope.includes(K.PluginScope.CONSUMER))??!0,pe=r.config.disableConsumerGroupScope?!1:((Qo=Et[r.pluginType])==null?void 0:Qo.scope.includes(K.PluginScope.CONSUMER_GROUP))??!0,le=r.config.entityType==="consumers"&&!!r.config.entityId||!!((tr=(er=b.value)==null?void 0:er.consumer)!=null&&tr.id),_e=r.config.entityType==="consumer_groups"&&!!r.config.entityId||!!((or=(nr=b.value)==null?void 0:nr.consumer_group)!=null&&or.id),fe=r.config.entityType==="services"&&!!r.config.entityId||!!((Se=(rr=b.value)==null?void 0:rr.service)!=null&&Se.id),oe=r.config.entityType==="routes"&&!!r.config.entityId||!!((Le=(at=b.value)==null?void 0:at.route)!=null&&Le.id),be=[],ve=(Ce,Ae,$e)=>Ce?a("plugins.form.disable_source_scope_change",{scope:$e}):Ae?a("plugins.form.disable_data_retrieving",{scope:$e}):"",ue=Ce=>{var Ae,$e;return(($e=(Ae=r.scopedEntitiesPermissions)==null?void 0:Ae[Ce])==null?void 0:$e.canRetrieve)===!1};if($){const Ce=ue("service"),Ae="services",$e=fe&&r.disableScopeSelection;be.push({id:"service-id",model:"service-id",label:a("plugins.form.scoping.gateway_service.label"),placeholder:a("plugins.form.scoping.placeholder"),type:"AutoSuggestV2",labelField:"name",entity:Ae,inputValues:{fields:["name","id"]},help:a("plugins.form.scoping.gateway_service.help"),disabled:$e||Ce,disabledTooltip:ve($e,Ce,Ae)})}if(X){const Ce=ue("route"),Ae="routes",$e=oe&&r.disableScopeSelection;be.push({id:"route-id",model:"route-id",label:a("plugins.form.scoping.route.label"),placeholder:a("plugins.form.scoping.placeholder"),type:"AutoSuggestV2",entity:Ae,labelField:"name",inputValues:{fields:["name","id"],primaryField:"id"},help:a("plugins.form.scoping.route.help"),disabled:$e||Ce,disabledTooltip:ve($e,Ce,Ae)})}if(D){const Ce=ue("consumer"),Ae="consumers",$e=le&&r.disableScopeSelection;be.push({model:"consumer-id",label:a("plugins.form.scoping.consumer.label"),placeholder:a("plugins.form.scoping.placeholder"),type:"AutoSuggestV2",entity:Ae,labelField:"username",inputValues:{fields:["username","custom_id","id"],primaryField:"username"},help:a("plugins.form.scoping.consumer.help"),disabled:$e||Ce,disabledTooltip:ve($e,Ce,Ae)})}if(pe){const Ce=ue("consumer_group"),Ae="consumer_groups",$e=_e&&r.disableScopeSelection;be.push({model:"consumer_group-id",label:a("plugins.form.scoping.consumer_group.label"),placeholder:a("plugins.form.scoping.placeholder"),type:"AutoSuggestV2",entity:Ae,entityDataKey:"consumer_group",labelField:"name",inputValues:{fields:["name","id"],primaryField:"name"},help:a("plugins.form.scoping.consumer_group.help"),disabled:$e||Ce,disabledTooltip:ve($e,Ce,Ae)})}if(be.length){const Ce=[...$?["service"]:[],...X?["route"]:[],...D?["consumer"]:[],...pe?["consumer_group"]:[]],$e=Ce.splice(Ce.length-2,2).map(dt=>a(dt==="service"?"plugins.form.scoping.gateway_service.plural":`plugins.form.scoping.${dt}.plural`)).join(`${Ce.length>0?",":""} and/or `),zt=["Specific",[...Ce.length>0?[Ce.map(dt=>a(dt==="service"?"plugins.form.scoping.gateway_service.plural":`plugins.form.scoping.${dt}.plural`)).join(", ")]:[],$e].join(", ")].join(" ");M.selectionGroup.fields.push({label:a("plugins.form.scoping.label"),description:zt,fields:[]}),M.selectionGroup.fields[1].fields=be}l[r.pluginType]&&l[r.pluginType].overwriteDefault&&Object.hasOwnProperty.call(l[r.pluginType],"formSchema")&&Object.assign(M,l[r.pluginType].formSchema)},L=t.computed(()=>!f(B.fields,P,!0)),F=t.computed(()=>!U.value&&!S.value&&(y.value===se.EntityBaseFormType.Create||L.value)),Z=t.ref(!1),Q=t.ref(),W=$=>{r.credential&&$.password&&($.password=""),B.fields.id=($==null?void 0:$.id)||void 0,Q.value=$==null?void 0:$.ordering,Object.assign(P,B.fields),b.value=$,Z.value=!0},ie=t.ref({}),ae=$=>{var X;B.fields=$.model,B.fields.id=((X=b.value)==null?void 0:X.id)||void 0,Object.assign(P,$.originalModel),ie.value=$.data,r.isWizardStep&&o("model-updated",{model:B.fields,data:$.data,resourceEndpoint:R.value})},me=t.ref(new Map),ge=t.computed(()=>[B.clientErrorMessage,B.serverErrorMessage].filter(Boolean).join("; ")),ne=$=>{$.valid?me.value.delete($.model):me.value.set($.model,$.error),B.clientErrorMessage=[...me.value.entries()].map(([X,D])=>`${X}: ${typeof D=="string"?D:d(D)}`).join("; "),B.clientErrorMessage&&(B.serverErrorMessage="")};t.watch([I,Z],($,X)=>{const D=$[0]!==X[0],pe=$[1],le=X[1];if(!w.value&&y.value===se.EntityBaseFormType.Edit&&(D||pe&&pe!==le)){const _e=z("config",v.value,M);O.value&&(_e._isCustomPlugin=!0),N.value&&(_e._supported_redis_partial_type=N.value),_.value=_e}},{deep:!0});const re=()=>{r.config.cancelRoute?i.push(r.config.cancelRoute):o("cancel")},q=t.computed(()=>{let $=`${r.config.apiBaseUrl}${Me.form[r.config.app].validate}`;return r.config.app==="konnect"?$=$.replace(/{controlPlaneId}/gi,r.config.controlPlaneId||""):r.config.app==="kongManager"&&($=$.replace(/\/{workspace}/gi,r.config.workspace?`/${r.config.workspace}`:"")),$=$.replace(/{id}/gi,r.pluginId),$}),ee=t.computed(()=>{const $=r.config.entityType&&r.config.entityId&&!r.developer,X=w.value?Me.form[r.config.app].credential[y.value]:Me.form[r.config.app][y.value][$?"forEntity":"all"];let D=`${r.config.apiBaseUrl}${X}`;return r.config.app==="konnect"?D=D.replace(/{controlPlaneId}/gi,r.config.controlPlaneId||""):r.config.app==="kongManager"&&(D=D.replace(/\/{workspace}/gi,r.config.workspace?`/${r.config.workspace}`:"")),D=D.replace(/{resourceEndpoint}/gi,R.value),D=D.replace(/{id}/gi,r.pluginId),D=D.replace(/{entityType}/gi,r.config.entityType||""),D=D.replace(/{entityId}/gi,r.config.entityId||""),D}),O=t.computed(()=>!Object.keys(Et).includes(r.pluginType)),k=t.computed(()=>{const $=ie.value;if(w.value){for(const X in K.PluginScope){const D=K.PluginScope[X];$[D]&&!$[D].id&&($[D]={id:r.config.entityId})}delete $.created_at}return ie.value.partials&&E.value&&bc($,E.value),$}),C=async()=>{if(!B.clientErrorMessage&&!r.isWizardStep)try{B.isReadonly=!0;let $;const X=JSON.parse(JSON.stringify(k.value)),D=l[r.pluginType];typeof(D==null?void 0:D.shamefullyTransformPayload)=="function"&&D.shamefullyTransformPayload({originalModel:P,model:B.fields,payload:X,schema:_.value}),!w.value&&!O.value&&await p.post(q.value,X),y.value==="create"?$=await p.post(ee.value,X):y.value==="edit"&&($=r.config.app==="konnect"||N.value&&X.partials?await p.put(ee.value,Object.assign({ordering:Q.value},X)):await p.patch(ee.value,X)),Object.assign(P,B.fields),o("update",$==null?void 0:$.data)}catch($){B.serverErrorMessage=d($),o("error",$)}finally{B.isReadonly=!1}},x=t.computed(()=>{var pe;const $=w.value?(pe=An[r.pluginType])==null?void 0:pe.schemaEndpoint:r.pluginType,X=w.value?Me.form[r.config.app].credentialSchema:Me.form[r.config.app].pluginSchema;let D=`${r.config.apiBaseUrl}${X}`;return r.config.app==="konnect"?D=D.replace(/{controlPlaneId}/gi,r.config.controlPlaneId||""):r.config.app==="kongManager"&&(D=D.replace(/\/{workspace}/gi,r.config.workspace?`/${r.config.workspace}`:"")),D=D.replace(/{plugin}/gi,$),D}),A=t.ref(""),U=t.ref(!1),V=t.ref("");return t.onBeforeMount(async()=>{var $,X,D,pe;U.value=!0;try{if(w.value&&r.config.app==="konnect"){const le=($=An[r.pluginType])==null?void 0:$.schemaEndpoint,_e=Dm[le];A.value=le,_.value=z("",_e,{}),U.value=!1}else{const le=r.schema??(await p.get(x.value)).data;if(g.value=le,le)if(w.value)_.value=z("",le,{}),U.value=!1;else{const _e=le.fields.find(oe=>oe.config);v.value=_e?_e.config:le,le.supported_partials&&(N.value=Object.keys(le.supported_partials).find(oe=>[sr.REDIS_CE,sr.REDIS_EE].includes(oe)),E.value=(X=le.supported_partials[N.value])==null?void 0:X[0]),H();const fe=(D=le.fields.find(oe=>oe.protocols))==null?void 0:D.protocols;if(fe){const{default:oe=[],elements:be={}}=fe;M.protocols.default=oe,M.protocols.placeholder=r.config.app==="konnect"?a("plugins.form.fields.protocols.placeholderWithDefaultValues",{protocols:oe.join(", ")}):a("plugins.form.fields.protocols.placeholder"),(pe=be.one_of)!=null&&pe.length&&(M.protocols.values=be.one_of.map(ve=>({label:ve,value:ve})))}if(Z.value||y.value===se.EntityBaseFormType.Create){const oe=z("config",v.value,M);N.value&&(oe._supported_redis_partial_type=N.value),O.value&&(oe._isCustomPlugin=!0),_.value=oe}}}}catch(le){console.error(le),V.value=d(le),o("error:fetch-schema",le)}finally{U.value=!1}}),($,X)=>{const D=t.resolveComponent("KSkeleton"),pe=t.resolveComponent("KEmptyState"),le=t.resolveComponent("KButton"),_e=t.resolveComponent("KTabs"),fe=t.resolveComponent("KSlideout");return t.openBlock(),t.createElementBlock("div",bR,[U.value?(t.openBlock(),t.createBlock(D,{key:0,type:"form"})):V.value?(t.openBlock(),t.createBlock(pe,{key:1,"action-button-visible":!1,"data-testid":"plugin-form-schema-error","icon-variant":"error"},{default:t.withCtx(()=>[t.createElementVNode("h3",null,t.toDisplayString(t.unref(a)("errors.load_schema")),1)]),_:1})):(t.openBlock(),t.createBlock(t.unref(se.EntityBaseForm),{key:2,"can-submit":F.value,config:e.config,"edit-id":e.pluginId,"entity-type":t.unref(se.SupportedEntityType).Plugin,"error-message":ge.value,"fetch-url":T.value,"form-fields":k.value,"is-readonly":B.isReadonly,"no-validate":"","wrapper-component":e.noCardWrapper?"div":void 0,onCancel:re,"onFetch:error":X[4]||(X[4]=oe=>$.$emit("error",oe)),"onFetch:success":W,onLoading:X[5]||(X[5]=oe=>$.$emit("loading",oe))},{"form-actions":t.withCtx(()=>[e.isWizardStep?(t.openBlock(),t.createElementBlock("div",wR)):(t.openBlock(),t.createBlock(_R,{key:1,"teleport-target":e.actionsTeleportTarget},{default:t.withCtx(()=>[t.createElementVNode("div",kR,[e.hideViewConfigAction?t.createCommentVNode("",!0):(t.openBlock(),t.createBlock(le,{key:0,appearance:"tertiary","data-testid":`plugin-${h.value?"edit":"create"}-form-view-configuration`,onClick:X[3]||(X[3]=oe=>Y())},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(a)("actions.view_configuration")),1)]),_:1},8,["data-testid"])),t.createVNode(le,{appearance:"secondary",class:"form-action-button","data-testid":`plugin-${h.value?"edit":"create"}-form-cancel`,disabled:B.isReadonly,onClick:re},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(a)("actions.cancel")),1)]),_:1},8,["data-testid","disabled"]),t.createVNode(le,{appearance:"primary","data-testid":`plugin-${h.value?"edit":"create"}-form-submit`,disabled:!F.value||B.isReadonly,type:"submit",onClick:C},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(a)("actions.save")),1)]),_:1},8,["data-testid","disabled"])])]),_:1},8,["teleport-target"]))]),default:t.withCtx(()=>[t.createElementVNode("form",{hidden:"",onSubmit:C},null,32),t.createVNode(hR,{config:e.config,credential:w.value,editing:y.value===t.unref(se.EntityBaseFormType).Edit,"enable-redis-partial":e.enableRedisPartial,"enable-vault-secret-picker":r.enableVaultSecretPicker,"entity-map":I.value,"raw-schema":g.value,record:b.value,schema:_.value,onGlobalAction:X[0]||(X[0]=(oe,be)=>$.$emit("globalAction",oe,be)),onLoading:X[1]||(X[1]=oe=>S.value=oe),onModelUpdated:ae,onShowNewPartialModal:X[2]||(X[2]=oe=>$.$emit("showNewPartialModal",oe)),onValidityChange:ne},null,8,["config","credential","editing","enable-redis-partial","enable-vault-secret-picker","entity-map","raw-schema","record","schema"])]),_:1},8,["can-submit","config","edit-id","entity-type","error-message","fetch-url","form-fields","is-readonly","wrapper-component"])),t.createVNode(fe,{"close-on-blur":!1,"data-testid":"form-view-configuration-slideout","has-overlay":!1,"offset-top":60,title:t.unref(a)("view_configuration.title"),visible:m.value,onClose:Y},{default:t.withCtx(()=>[t.createElementVNode("div",null,t.toDisplayString(t.unref(a)("view_configuration.message")),1),t.createVNode(_e,{"data-testid":"form-view-configuration-slideout-tabs",tabs:j.value},{json:t.withCtx(()=>[t.createVNode(t.unref(se.JsonCodeBlock),{config:e.config,"entity-record":k.value,"fetcher-url":ee.value,"request-method":r.pluginId?"put":"post"},null,8,["config","entity-record","fetcher-url","request-method"])]),yaml:t.withCtx(()=>[t.createVNode(t.unref(se.YamlCodeBlock),{"entity-record":k.value},null,8,["entity-record"])]),terraform:t.withCtx(()=>[t.createVNode(t.unref(se.TerraformCodeBlock),{"credential-type":A.value,"entity-record":k.value,"entity-type":t.unref(se.SupportedEntityType).Plugin},null,8,["credential-type","entity-record","entity-type"])]),_:1},8,["tabs"])]),_:1},8,["title","visible"])])}}}),[["__scopeId","data-v-7a402d18"]]),CR={class:"kong-ui-entities-plugins-list"},NR={class:"button-row"},vR={class:"name-cell-wrapper"},SR={class:"info-wrapper"},xR={key:0,class:"info-name"},AR={key:1,class:"info-name"},IR={key:2,class:"info-type"},PR={key:1},TR=Ee(t.defineComponent({__name:"PluginList",props:{config:{type:Object,required:!0,validator:e=>!(!e||!["konnect","kongManager"].includes(e==null?void 0:e.app)||!e.createRoute||!e.getViewRoute||!e.getEditRoute||!e.getConfigureDynamicOrderingRoute||e.app==="kongManager"&&!e.isExactMatch&&!e.filterSchema)},cacheIdentifier:{type:String,default:""},canCreate:{type:Function,required:!1,default:async()=>!0},canDelete:{type:Function,required:!1,default:async()=>!0},canEdit:{type:Function,required:!1,default:async()=>!0},canToggle:{type:Function,required:!1,default:async()=>!0},canRetrieve:{type:Function,required:!1,default:async()=>!0},canRetrieveScopedEntity:{type:Function,required:!1,default:async()=>!0},canConfigureDynamicOrdering:{type:Function,required:!1,default:async()=>!0},title:{type:String,default:""},titleTag:{type:String,default:"h2"},useActionOutside:{type:Boolean,default:!1}},emits:["error","click:learn-more","copy:success","copy:error","delete:success","toggle-enabled"],setup(e,{emit:n}){var A,U;const o=Re.usePluginMetaData(),r=n,i=e,{i18n:{t:a}}=Re.useI18n(),l=oo.useRouter(),{axiosInstance:s}=se.useAxios((A=i.config)==null?void 0:A.axiosRequestConfig),{hasRecords:c,handleStateChange:d}=se.useTableState(()=>b.value),u=t.computed(()=>c.value&&i.config.app==="konnect"),f=t.computed(()=>!!i.config.entityId),p=t.computed(()=>{var V;return((V=i.config)==null?void 0:V.entityType)==="consumers"}),m=t.computed(()=>{var V;return((V=i.config)==null?void 0:V.entityType)==="consumer_groups"}),h=i.config.app==="konnect"||se.useGatewayFeatureSupported({gatewayInfo:i.config.gatewayInfo,supportedRange:{enterprise:["3.0"]}}),y=t.computed(()=>i.config.app!=="kongManager"||!!i.config.disableSorting),g={name:{label:a("plugins.list.table_headers.name"),searchable:!0,sortable:!0,hidable:!1}};(U=i.config)!=null&&U.entityId||(g.appliedTo={label:a("plugins.list.table_headers.applied_to"),sortable:!1}),g.enabled={label:a("plugins.list.table_headers.enabled"),searchable:!0,sortable:!0},h&&(g.ordering={label:a("plugins.list.table_headers.ordering"),sortable:!0}),g.tags={label:a("plugins.list.table_headers.tags"),sortable:!1};const _=g,w=t.computed(()=>{var J,$,X,D;let V=i.config.entityType?`${i.config.apiBaseUrl}${Me.list[i.config.app].forEntity}`:`${i.config.apiBaseUrl}${Me.list[i.config.app].all}`;return i.config.app==="konnect"?V=V.replace(/{controlPlaneId}/gi,((J=i.config)==null?void 0:J.controlPlaneId)||""):i.config.app==="kongManager"&&(V=V.replace(/\/{workspace}/gi,($=i.config)!=null&&$.workspace?`/${i.config.workspace}`:"")),V.replace(/{entityType}/gi,((X=i.config)==null?void 0:X.entityType)||"").replace(/{entityId}/gi,((D=i.config)==null?void 0:D.entityId)||"")}),b=t.ref(""),v=t.computed(()=>i.config.app==="konnect"||i.config.isExactMatch?{isExactMatch:!0,fields:{name:g.name,id:{label:a("plugins.list.table_headers.id"),sortable:!0}},placeholder:a(`search.placeholder.${i.config.isExactMatch?"exact":i.config.app}`)}:{isExactMatch:!1,fields:{enabled:{...g.enabled,label:a("search.filter.field.enabled")},name:g.name,instance_name:{label:a("plugins.list.table_headers.instance_name"),searchable:!0}},schema:i.config.filterSchema}),{fetcher:N,fetcherState:E,fetcherCacheKey:S}=se.useFetcher(t.computed(()=>({...i.config,cacheIdentifier:i.cacheIdentifier})),w),P=()=>{b.value=""},B=()=>{S.value++},j=t.ref(null),G=V=>{var $,X,D,pe;const J=[];return(($=V.route)!=null&&$.id||V.route_id)&&J.push({type:"route",badgeText:a("plugins.list.table_headers.applied_to_badges.route")}),((X=V.service)!=null&&X.id||V.service_id)&&J.push({type:"service",badgeText:a("plugins.list.table_headers.applied_to_badges.service")}),((D=V.consumer)!=null&&D.id||V.consumer_id)&&J.push({type:"consumer",badgeText:a("plugins.list.table_headers.applied_to_badges.consumer")}),((pe=V.consumer_group)!=null&&pe.id||V.consumer_group_id)&&J.push({type:"consumer_group",badgeText:a("plugins.list.table_headers.applied_to_badges.consumer_group")}),J.length?J:[{type:null,badgeText:a("plugins.list.table_headers.applied_to_badges.global")}]},T=async(V,J)=>{var $;return V===null?!1:await(($=i.canRetrieveScopedEntity)==null?void 0:$.call(i,V,J.id))},Y=(V,J)=>{var X,D,pe,le,_e;let $=null;switch(V){case"route":$=(X=J.route)==null?void 0:X.id;break;case"service":$=(D=J.service)==null?void 0:D.id;break;case"consumer":$=(pe=J.consumer)==null?void 0:pe.id;break;case"consumer_group":$=(le=J.consumer_group)==null?void 0:le.id;break}$&&((_e=i.config)!=null&&_e.getScopedEntityViewRoute)&&l.push(i.config.getScopedEntityViewRoute(V,$))},I=t.ref(!1),M=t.ref(null),R=t.computed(()=>{const V={action:"disable",id:"",name:""};if(M.value){const{enabled:J,id:$,name:X}=M.value;V.action=J?"disable":"enable",V.id=$,V.name=o.getDisplayName(X)||$}return V}),te=V=>{I.value=!0,M.value=V},z=()=>{I.value=!1,M.value=null},H=async()=>{var X,D,pe,le,_e,fe,oe,be;if(!await((X=i.canEdit)==null?void 0:X.call(i,M.value))||!M.value)return;let J=`${i.config.apiBaseUrl}${(_e=Me.item[i.config.app])==null?void 0:_e[(D=i.config)!=null&&D.entityType?"forEntity":"all"].replace(/{entityType}/gi,((pe=i.config)==null?void 0:pe.entityType)||"").replace(/{entityId}/gi,((le=i.config)==null?void 0:le.entityId)||"")}`.replace(/{id}/gi,M.value.id||"");i.config.app==="konnect"?J=J.replace(/{controlPlaneId}/gi,((fe=i.config)==null?void 0:fe.controlPlaneId)||""):i.config.app==="kongManager"&&(J=J.replace(/\/{workspace}/gi,(oe=i.config)!=null&&oe.workspace?`/${i.config.workspace}`:""));const $=!M.value.enabled;try{const{data:ve}=((be=i.config)==null?void 0:be.app)==="konnect"?await s.put(J,{...M.value,enabled:$},{timeout:12e4}):await s.patch(J,{...M.value,enabled:$},{timeout:12e4});r("toggle-enabled",$,ve),M.value.enabled=$}catch(ve){r("error",ve)}},L=async(V,J)=>{const $=V.id;if(!await J($)){r("copy:error",{entity:V,field:"id",message:a("errors.copy")});return}r("copy:success",{entity:V,field:"id",message:a("copy.success",{val:$})})},F=async(V,J)=>{const $=JSON.stringify(V);if(!await J($)){r("copy:error",{entity:V,message:a("errors.copy")});return}r("copy:success",{entity:V,message:a("copy.success_brief")})},Z=async V=>{var $;await(($=i.canRetrieve)==null?void 0:$.call(i,V))&&l.push(i.config.getViewRoute(V))},Q=V=>({label:a("actions.view"),to:i.config.getViewRoute(V)}),W=V=>({label:a("actions.edit"),to:i.config.getEditRoute(V)}),ie=V=>({label:a("actions.configure_dynamic_ordering"),to:i.config.getConfigureDynamicOrderingRoute(V)}),ae=t.ref(void 0),me=t.ref(!1),ge=t.ref(!1),ne=t.ref(""),re=se.useDeleteUrlBuilder(i.config,w.value),q=V=>{ae.value=V,me.value=!0},ee=()=>{me.value=!1},O=async()=>{var V,J,$;if((V=ae.value)!=null&&V.id){ge.value=!0;try{await s.delete(re(ae.value.id)),ge.value=!1,me.value=!1,S.value++,r("delete:success",ae.value)}catch(X){ne.value=(($=(J=X.response)==null?void 0:J.data)==null?void 0:$.message)||X.message||a("errors.delete"),r("error",X)}finally{ge.value=!1}}},k=()=>{l.push(i.config.createRoute)};t.watch(E,V=>{var J,$,X;if(V.status===se.FetcherStatus.Error){j.value={title:a("errors.general")},(X=($=(J=V.error)==null?void 0:J.response)==null?void 0:$.data)!=null&&X.message&&(j.value.message=V.error.response.data.message),r("error",V.error);return}j.value=null});const C=t.ref({ctaPath:i.config.createRoute,ctaText:void 0,message:`${a("plugins.list.empty_state.description")}${i.config.additionMessageForEmptyState?` ${i.config.additionMessageForEmptyState}`:""}`,title:a("plugins.title")}),x=t.ref(!1);return t.onBeforeMount(async()=>{x.value=await i.canCreate(),x.value&&(C.value.title=a("plugins.list.empty_state.title"),C.value.ctaText=a("actions.create"))}),(V,J)=>{const $=t.resolveComponent("KButton"),X=t.resolveComponent("KEmptyState"),D=t.resolveComponent("KBadge"),pe=t.resolveComponent("KTruncate"),le=t.resolveComponent("KInputSwitch"),_e=t.resolveComponent("KDropdownItem"),fe=t.resolveComponent("KClipboardProvider");return t.openBlock(),t.createElementBlock("div",CR,[t.createVNode(t.unref(se.EntityBaseTable),{"cache-identifier":e.cacheIdentifier,"disable-sorting":y.value,"empty-state-options":C.value,"enable-entity-actions":"","error-message":j.value,fetcher:t.unref(N),"fetcher-cache-key":t.unref(S),"pagination-type":"offset","preferences-storage-key":"kong-ui-entities-plugins-list",query:b.value,"table-headers":t.unref(_),title:e.title,"title-tag":e.titleTag,onClearSearchInput:P,"onClick:row":J[4]||(J[4]=oe=>Z(oe)),onSort:B,onState:t.unref(d)},t.createSlots({"toolbar-filter":t.withCtx(()=>[t.createVNode(t.unref(se.EntityFilter),{modelValue:b.value,"onUpdate:modelValue":J[0]||(J[0]=oe=>b.value=oe),config:v.value},null,8,["modelValue","config"])]),"toolbar-button":t.withCtx(()=>[(t.openBlock(),t.createBlock(t.Teleport,{disabled:!e.useActionOutside,to:"#kong-ui-app-page-header-action-button"},[t.createElementVNode("div",NR,[!f.value&&u.value?(t.openBlock(),t.createBlock($,{key:0,appearance:"secondary",class:"open-learning-hub","data-testid":"plugins-learn-more-button",icon:"",onClick:J[1]||(J[1]=oe=>V.$emit("click:learn-more"))},{default:t.withCtx(()=>[t.createVNode(t.unref(Ne.BookIcon),{decorative:""})]),_:1})):t.createCommentVNode("",!0),t.createVNode(t.unref(se.PermissionsWrapper),{"auth-function":()=>e.canCreate()},{default:t.withCtx(()=>[t.createVNode($,{appearance:"primary","data-testid":"toolbar-add-plugin",size:e.useActionOutside?"medium":"large",to:e.config.createRoute},{default:t.withCtx(()=>[t.createVNode(t.unref(Ne.AddIcon)),t.createTextVNode(" "+t.toDisplayString(t.unref(a)("plugins.list.toolbar_actions.new_plugin")),1)]),_:1},8,["size","to"])]),_:1},8,["auth-function"])])],8,["disabled"]))]),name:t.withCtx(({row:oe})=>[t.createElementVNode("div",vR,[t.createVNode(t.unref(io.PluginIcon),{class:"plugin-icon",name:oe.name,size:24},null,8,["name"]),t.createElementVNode("div",SR,[oe.instance_name?(t.openBlock(),t.createElementBlock("span",xR,t.toDisplayString(oe.instance_name),1)):(t.openBlock(),t.createElementBlock("span",AR,t.toDisplayString(t.unref(o).getDisplayName(oe.name)),1)),oe.instance_name?(t.openBlock(),t.createElementBlock("span",IR,t.toDisplayString(t.unref(o).getDisplayName(oe.name)),1)):t.createCommentVNode("",!0)])])]),appliedTo:t.withCtx(({row:oe})=>[G(oe).length>0?(t.openBlock(),t.createBlock(pe,{key:0},{default:t.withCtx(()=>[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(G(oe),be=>(t.openBlock(),t.createBlock(t.unref(se.PermissionsWrapper),{key:be.badgeText,"auth-function":()=>T(be.type,oe),"force-show":""},{default:t.withCtx(({isAllowed:ve})=>[t.createVNode(D,{class:t.normalizeClass(ve||"disabled"),onClick:t.withModifiers(ue=>ve&&be.type&&Y(be.type,oe),["stop"])},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(be.badgeText),1)]),_:2},1032,["class","onClick"])]),_:2},1032,["auth-function"]))),128))]),_:2},1024)):(t.openBlock(),t.createElementBlock("span",PR,"-"))]),enabled:t.withCtx(({row:oe})=>[t.createVNode(t.unref(se.PermissionsWrapper),{"auth-function":async()=>!!(await e.canEdit(oe)&&await e.canToggle(oe)),"force-show":""},{default:t.withCtx(({isAllowed:be})=>{var ve,ue;return[t.createElementVNode("div",{onClick:J[3]||(J[3]=t.withModifiers(()=>{},["stop"]))},[t.createVNode(le,{disabled:!be,"disabled-tooltip-text":!be&&((ue=(ve=e.config).getToggleDisabledTooltip)==null?void 0:ue.call(ve,oe))||void 0,"model-value":oe.enabled,onClick:t.withModifiers(de=>be&&te(oe),["stop","prevent"])},null,8,["disabled","disabled-tooltip-text","model-value","onClick"])])]}),_:2},1032,["auth-function"])]),ordering:t.withCtx(({rowValue:oe})=>[t.createVNode(D,{appearance:t.unref(gc)(oe)?"info":"warning"},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(gc)(oe)?t.unref(a)("plugins.list.table_headers.ordering_badge.static"):t.unref(a)("plugins.list.table_headers.ordering_badge.dynamic")),1)]),_:2},1032,["appearance"])]),tags:t.withCtx(({rowValue:oe})=>[t.createVNode(t.unref(se.TableTags),{tags:oe},null,8,["tags"])]),actions:t.withCtx(({row:oe})=>[t.createVNode(fe,null,{default:t.withCtx(({copyToClipboard:be})=>[t.createVNode(_e,{"data-testid":"action-entity-copy-id",onClick:ve=>L(oe,be)},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(a)("actions.copy_id")),1)]),_:2},1032,["onClick"])]),_:2},1024),t.createVNode(fe,null,{default:t.withCtx(({copyToClipboard:be})=>[t.createVNode(_e,{"data-testid":"action-entity-copy-json",onClick:ve=>F(oe,be)},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(a)("actions.copy_json")),1)]),_:2},1032,["onClick"])]),_:2},1024),t.createVNode(t.unref(se.PermissionsWrapper),{"auth-function":()=>e.canRetrieve(oe)},{default:t.withCtx(()=>[t.createVNode(_e,{"data-testid":"action-entity-view","has-divider":"",item:Q(oe)},null,8,["item"])]),_:2},1032,["auth-function"]),t.createVNode(t.unref(se.PermissionsWrapper),{"auth-function":()=>e.canEdit(oe)},{default:t.withCtx(()=>[t.createVNode(_e,{"data-testid":"action-entity-edit",item:W(oe)},null,8,["item"])]),_:2},1032,["auth-function"]),!p.value&&!m.value&&t.unref(h)?(t.openBlock(),t.createBlock(t.unref(se.PermissionsWrapper),{key:0,"auth-function":()=>e.canConfigureDynamicOrdering(oe)},{default:t.withCtx(()=>[ie(oe)?(t.openBlock(),t.createBlock(_e,{key:0,"data-testid":"action-entity-config-dyn-order",item:ie(oe)},null,8,["item"])):t.createCommentVNode("",!0)]),_:2},1032,["auth-function"])):t.createCommentVNode("",!0),t.createVNode(t.unref(se.PermissionsWrapper),{"auth-function":()=>e.canDelete(oe)},{default:t.withCtx(()=>[t.createVNode(_e,{danger:"","data-testid":"action-entity-delete","has-divider":"",onClick:be=>q(oe)},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(a)("actions.delete")),1)]),_:2},1032,["onClick"])]),_:2},1032,["auth-function"])]),_:2},[!b.value&&e.config.app==="konnect"?{name:"empty-state",fn:t.withCtx(()=>{var oe;return[t.createVNode(X,{"data-testid":e.config.entityId?"nested-plugins-entity-empty-state":"plugins-entity-empty-state","icon-background":"",message:t.unref(a)("plugins.list.empty_state_v2.description"),title:t.unref(a)("plugins.list.empty_state_v2.title")},t.createSlots({icon:t.withCtx(()=>[t.createVNode(t.unref(Ne.PlugIcon),{decorative:""})]),action:t.withCtx(()=>[x.value?(t.openBlock(),t.createBlock($,{key:0,"data-testid":"entity-create-button",onClick:k},{default:t.withCtx(()=>[t.createVNode(t.unref(Ne.AddIcon),{decorative:""}),t.createTextVNode(" "+t.toDisplayString(t.unref(a)("plugins.list.empty_state_v2.create_cta")),1)]),_:1})):t.createCommentVNode("",!0),t.createVNode($,{appearance:"secondary","data-testid":"entity-learn-more-button",onClick:J[2]||(J[2]=be=>V.$emit("click:learn-more"))},{default:t.withCtx(()=>[t.createVNode(t.unref(Ne.BookIcon),{decorative:""}),t.createTextVNode(" "+t.toDisplayString(t.unref(a)("plugins.list.empty_state_v2.learn_more")),1)]),_:1})]),_:2},[(oe=e.config)!=null&&oe.isControlPlaneGroup?{name:"default",fn:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(a)("plugins.list.empty_state_v2.group")),1)]),key:"0"}:void 0]),1032,["data-testid","message","title"])]}),key:"0"}:void 0]),1032,["cache-identifier","disable-sorting","empty-state-options","error-message","fetcher","fetcher-cache-key","query","table-headers","title","title-tag","onState"]),t.createVNode(t.unref(se.EntityToggleModal),{action:R.value.action,"entity-id":R.value.id,"entity-name":R.value.name,"entity-type":t.unref(a)("glossary.plugin"),"on-confirm":H,visible:I.value,onCancel:z,onProceed:z},null,8,["action","entity-id","entity-name","entity-type","visible"]),t.createVNode(t.unref(se.EntityDeleteModal),{"action-pending":ge.value,description:t.unref(a)("delete.description"),"entity-name":ae.value&&(ae.value.instance_name||ae.value.name||ae.value.id),"entity-type":t.unref(se.EntityTypes).Plugin,error:ne.value,title:t.unref(a)("delete.title"),visible:me.value,onCancel:ee,onProceed:O},null,8,["action-pending","description","entity-name","entity-type","error","title","visible"])])}}}),[["__scopeId","data-v-582a936c"]]),OR={class:"plugin-select-card-wrapper"},$R=["data-testid"],BR={class:"plugin-card-header"},VR={class:"plugin-card-title"},RR={key:0,class:"plugin-card-actions"},DR=["data-testid","title"],MR={key:0,class:"plugin-card-text"},LR={key:0},FR=["title"],Hl=Ee(t.defineComponent({__name:"PluginSelectCard",props:{config:{type:Object,required:!0,validator:e=>!(!e||!["konnect","kongManager"].includes(e==null?void 0:e.app)||!e.getCreateRoute)},canDeleteCustomPlugin:{type:Boolean,default:!1},canEditCustomPlugin:{type:Boolean,default:!1},plugin:{type:Object,required:!0},navigateOnClick:{type:Boolean,default:!0}},emits:["plugin-clicked","custom-plugin-delete"],setup(e,{emit:n}){const o=n,r=e,i=oo.useRouter(),{i18n:{t:a}}=Re.useI18n(),l=t.computed(()=>r.config.app==="konnect"?r.config.controlPlaneId:""),s=t.computed(()=>!!(!r.plugin.available||r.plugin.disabledMessage)),c=t.computed(()=>!!(m.value&&!p.value&&r.navigateOnClick&&l.value&&(r.canDeleteCustomPlugin||r.canEditCustomPlugin))),d=()=>{i.push(r.config.getCreateRoute(r.plugin.id))},u=()=>{r.navigateOnClick?d():f()},f=()=>{o("plugin-clicked",r.plugin)},p=t.computed(()=>r.plugin.id==="custom-plugin-create"),m=t.computed(()=>r.config.app==="konnect"&&r.plugin.group===K.PluginGroup.CUSTOM_PLUGINS),h=()=>{r.config.app==="konnect"&&o("custom-plugin-delete")},y=(_,w)=>{const b=r.config;r.config.app==="konnect"&&typeof b.getCustomEditRoute=="function"&&b.getCustomEditRoute&&i.push(b.getCustomEditRoute(_,w))},g=()=>{if(!s.value&&r.config.app==="konnect"){const _=r.config;p.value&&_.createCustomRoute?i.push(_.createCustomRoute):m.value&&d()}};return(_,w)=>{const b=t.resolveComponent("KButton"),v=t.resolveComponent("KDropdownItem"),N=t.resolveComponent("KDropdownMenu"),E=t.resolveComponent("KTooltip");return t.openBlock(),t.createElementBlock("div",OR,[t.createVNode(E,{text:e.plugin.disabledMessage},{default:t.withCtx(()=>[t.createElementVNode("a",{class:t.normalizeClass(["plugin-select-card",{disabled:s.value}]),"data-testid":`${e.plugin.id}-card`,role:"button",onClick:w[1]||(w[1]=S=>s.value||m.value?void 0:u())},[t.createElementVNode("div",BR,[t.createElementVNode("div",VR,[t.createElementVNode("span",{class:t.normalizeClass({"non-custom-title":!m.value})},t.toDisplayString(e.plugin.name),3)]),c.value?(t.openBlock(),t.createElementBlock("div",RR,[t.createVNode(N,{"data-testid":"custom-plugin-actions","kpop-attributes":{placement:"bottom-end"},width:"150"},{default:t.withCtx(()=>[t.createVNode(b,{appearance:"tertiary",class:"actions-trigger","data-testid":"overflow-actions-button",icon:"",size:"small"},{default:t.withCtx(()=>[t.createVNode(t.unref(Ne.MoreIcon),{size:t.unref(uk)},null,8,["size"])]),_:1})]),items:t.withCtx(()=>[e.canDeleteCustomPlugin?(t.openBlock(),t.createBlock(v,{key:0,"data-testid":"edit-plugin-schema",onClick:w[0]||(w[0]=t.withModifiers(S=>y(e.plugin.name,e.plugin.customPluginType),["stop"]))},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(a)("actions.edit")),1)]),_:1})):t.createCommentVNode("",!0),e.canDeleteCustomPlugin?(t.openBlock(),t.createBlock(v,{key:1,danger:"","data-testid":"delete-plugin-schema","has-divider":"",onClick:t.withModifiers(h,["stop"])},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(a)("actions.delete")),1)]),_:1})):t.createCommentVNode("",!0)]),_:1})])):t.createCommentVNode("",!0)]),t.createElementVNode("div",{class:t.normalizeClass(["plugin-card-body",{"custom-plugin":m.value}]),"data-testid":e.plugin.name,title:e.plugin.available?e.plugin.name:t.unref(a)("plugins.select.unavailable_tooltip"),onClick:g},[t.createVNode(t.unref(io.PluginIcon),{alt:e.plugin.name,class:"plugin-card-icon",name:e.plugin.id,size:55},null,8,["alt","name"]),e.plugin.description||m.value&&!p.value?(t.openBlock(),t.createElementBlock("div",MR,[m.value&&!p.value?(t.openBlock(),t.createElementBlock("p",LR,t.toDisplayString(t.unref(a)("plugins.select.custom_badge_text")),1)):t.createCommentVNode("",!0),e.plugin.description?(t.openBlock(),t.createElementBlock("p",{key:1,class:"plugin-card-text",title:e.plugin.description},t.toDisplayString(e.plugin.description),9,FR)):t.createCommentVNode("",!0)])):t.createCommentVNode("",!0)],10,DR),t.createElementVNode("div",{class:"plugin-card-footer",onClick:g},t.toDisplayString(p.value?t.unref(a)("actions.create_custom"):e.plugin.exists?t.unref(a)("actions.enabled"):t.unref(a)("actions.enable")),1)],10,$R)]),_:1},8,["text"])])}}}),[["__scopeId","data-v-65d53934"]]),UR=Ee(t.defineComponent({__name:"DeleteCustomPluginSchemaModal",props:{config:{type:Object,required:!0,validator:e=>!(!e||!["konnect","kongManager"].includes(e==null?void 0:e.app))},plugin:{type:Object,required:!0}},emits:["closed","proceed"],setup(e,{emit:n}){var h;const o=e,r=n,{i18nT:i,i18n:{t:a}}=Re.useI18n(),{getMessageFromError:l}=se.useErrors(),{axiosInstance:s}=se.useAxios((h=o.config)==null?void 0:h.axiosRequestConfig),c=t.computed(()=>{var y;return f.value?a("delete.plugin_schema_in_use_title"):a("delete.title",{name:((y=o.plugin)==null?void 0:y.name)||a("delete.custom_plugin")})}),d=t.ref(!1),u=t.ref(""),f=t.ref(!1),p=t.computed(()=>{if(o.config.app==="konnect"){const y=o.plugin.customPluginType==="streaming"?Me.select[o.config.app].streamingCustomPluginItem:Me.select[o.config.app].schemaCustomPluginItem;let g=`${o.config.apiBaseUrl}${y}`;return g=g.replace(/{controlPlaneId}/gi,o.config.controlPlaneId||""),g=g.replace(/{pluginId}/gi,o.plugin.id),g}return null}),m=async()=>{var y,g,_,w;if(d.value=!0,u.value="",!(!((y=o.plugin)!=null&&y.name)||((g=o.config)==null?void 0:g.app)!=="konnect"))try{p.value&&await s.delete(p.value),r("proceed")}catch(b){const{response:v}=b;(v==null?void 0:v.status)===400&&((w=(_=v.data)==null?void 0:_.message)!=null&&w.includes("plugin schema is currently in use"))?f.value=!0:u.value=l(b)}finally{d.value=!1}};return(y,g)=>{const _=t.resolveComponent("KButton"),w=t.resolveComponent("KModal");return!f.value&&e.plugin?(t.openBlock(),t.createBlock(t.unref(se.EntityDeleteModal),{key:0,"action-pending":d.value,class:"delete-custom-plugin-schema-modal","data-testid":"delete-custom-plugin-schema-modal",description:t.unref(a)("delete.description_custom"),"entity-name":e.plugin.name,"entity-type":t.unref(se.EntityTypes).Plugin,error:u.value,"need-confirm":"",title:c.value,visible:"",onCancel:g[0]||(g[0]=b=>y.$emit("closed")),onProceed:m},null,8,["action-pending","description","entity-name","entity-type","error","title"])):e.plugin?(t.openBlock(),t.createBlock(w,{key:1,"action-button-disabled":d.value,class:"delete-custom-plugin-schema-modal","data-testid":"delete-custom-plugin-schema-modal",title:c.value,visible:"",onCancel:g[2]||(g[2]=b=>y.$emit("closed"))},{default:t.withCtx(()=>[t.createElementVNode("div",null,[t.createVNode(t.unref(i),{keypath:"delete.plugin_schema_in_use_message",tag:"p"},{name:t.withCtx(()=>[t.createElementVNode("strong",null,t.toDisplayString(e.plugin.name),1)]),_:1})])]),"footer-actions":t.withCtx(()=>[t.createElementVNode("div",null,[t.createVNode(_,{appearance:"tertiary",class:"cancel-button","data-testid":"delete-custom-plugin-form-cancel",onClick:g[1]||(g[1]=b=>y.$emit("closed"))},{default:t.withCtx(()=>[t.createTextVNode(t.toDisplayString(t.unref(a)("actions.cancel")),1)]),_:1})])]),_:1},8,["action-button-disabled","title"])):t.createCommentVNode("",!0)}}}),[["__scopeId","data-v-9e0dee7f"]]),KR={class:"custom-plugins-grid"},jR={class:"empty-state-title"},GR={class:"empty-state-description"},Yl=310,qR=Ee(t.defineComponent({__name:"PluginCustomGrid",props:{config:{type:Object,required:!0,validator:e=>!(!e||!["konnect","kongManager"].includes(e==null?void 0:e.app)||!e.getCreateRoute)},canCreateCustomPlugin:{type:Boolean,default:!1},canDeleteCustomPlugin:{type:Boolean,default:!1},canEditCustomPlugin:{type:Boolean,default:!1},pluginList:{type:Object,default:()=>({})},navigateOnClick:{type:Boolean,default:!0}},emits:["plugin-clicked","revalidate","delete:success"],setup(e,{emit:n}){const o=e,r=n,{i18n:{t:i}}=Re.useI18n(),{getTallestPluginCardHeight:a,getToggleVisibility:l}=Re.usePluginHelpers(),s=t.ref(!0),c=N=>{r("plugin-clicked",N)},d=t.computed(()=>{if(o.config.app==="kongManager")return[];const N=JSON.parse(JSON.stringify(o.pluginList))[K.PluginGroup.CUSTOM_PLUGINS]||[];return o.canCreateCustomPlugin&&o.navigateOnClick&&o.config.createCustomRoute?[{id:"custom-plugin-create",name:i("plugins.select.tabs.custom.create.name"),available:!0,group:K.PluginGroup.CUSTOM_PLUGINS,description:i("plugins.select.tabs.custom.create.description")}].concat(N):N}),u=t.ref(!1),f=t.ref(null),p=N=>{u.value=!0,f.value={id:N.id,name:N.name,customPluginType:N.customPluginType}},m=N=>{var E;N&&(r("revalidate"),r("delete:success",((E=f.value)==null?void 0:E.name)||"")),u.value=!1,f.value=null},h=t.ref(Yl),y=t.ref(null),g=t.ref(null),_=t.computed(()=>s.value?{overflowY:"hidden",maxHeight:`${h.value}px`}:{}),w=t.ref(!1),b=()=>{h.value=Math.max(a(g.value),Yl),v()},v=()=>{var N,E;(N=g.value)!=null&&N.length&&(w.value=l(y.value,(E=g.value)==null?void 0:E.length))};return t.onMounted(async()=>{await t.nextTick(),h.value=Math.max(a(g.value),Yl),v(),window==null||window.addEventListener("resize",b)}),t.onUnmounted(()=>{window==null||window.removeEventListener("resize",b)}),(N,E)=>{const S=t.resolveComponent("KEmptyState"),P=t.resolveComponent("KCollapse");return t.openBlock(),t.createElementBlock("div",KR,[d.value.length?(t.openBlock(),t.createBlock(P,{key:1,modelValue:s.value,"onUpdate:modelValue":E[0]||(E[0]=B=>s.value=B),class:"custom-plugins-collapse","data-testid":`${t.unref(K.PluginGroup).CUSTOM_PLUGINS}-collapse`,title:t.unref(K.PluginGroup).CUSTOM_PLUGINS,"trigger-label":s.value?t.unref(i)("plugins.select.view_more"):t.unref(i)("plugins.select.view_less")},t.createSlots({"visible-content":t.withCtx(()=>[t.createElementVNode("div",{ref_key:"pluginCardContainerRef",ref:y,class:"plugin-card-container",style:t.normalizeStyle(_.value)},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(d.value,(B,j)=>(t.openBlock(),t.createBlock(Hl,{key:`plugin-card-${j}`,ref_for:!0,ref_key:"pluginCardRef",ref:g,"can-delete-custom-plugin":e.canDeleteCustomPlugin,"can-edit-custom-plugin":e.canEditCustomPlugin,config:e.config,"navigate-on-click":e.navigateOnClick,plugin:B,onCustomPluginDelete:G=>p(B),onPluginClicked:c},null,8,["can-delete-custom-plugin","can-edit-custom-plugin","config","navigate-on-click","plugin","onCustomPluginDelete"]))),128))],4)]),_:2},[w.value?void 0:{name:"trigger",fn:t.withCtx(()=>[E[2]||(E[2]=t.createTextVNode(" ",-1))]),key:"0"}]),1032,["modelValue","data-testid","title","trigger-label"])):(t.openBlock(),t.createBlock(S,{key:0,"action-button-visible":!1,class:"custom-plugins-empty-state","icon-variant":"kong"},{title:t.withCtx(()=>[t.createElementVNode("span",jR,t.toDisplayString(t.unref(i)("plugins.select.tabs.custom.empty_title")),1)]),default:t.withCtx(()=>[t.createElementVNode("span",GR,t.toDisplayString(t.unref(i)("plugins.select.tabs.custom.empty_description")),1)]),_:1})),u.value&&f.value?(t.openBlock(),t.createBlock(UR,{key:2,config:e.config,plugin:f.value,onClosed:m,onProceed:E[1]||(E[1]=B=>m(!0))},null,8,["config","plugin"])):t.createCommentVNode("",!0)])}}}),[["__scopeId","data-v-f4b90f47"]]),Wl=310,km=Ee(t.defineComponent({__name:"PluginSelectGroup",props:t.mergeModels({config:{type:Object,required:!0,validator:e=>!(!e||!["konnect","kongManager"].includes(e==null?void 0:e.app)||!e.getCreateRoute)},name:{type:String,required:!0},plugins:{type:Array,required:!0},navigateOnClick:{type:Boolean,default:!0}},{modelValue:{type:Boolean,required:!0},modelModifiers:{}}),emits:t.mergeModels(["plugin-clicked"],["update:modelValue"]),setup(e,{emit:n}){const o=t.useModel(e,"modelValue"),r=e,i=n,{i18n:{t:a}}=Re.useI18n(),{getTallestPluginCardHeight:l,getToggleVisibility:s}=Re.usePluginHelpers(),c=t.ref(Wl),d=t.ref(null),u=t.ref(null),f=t.computed(()=>o.value?{overflowY:"hidden",maxHeight:`${c.value}px`}:{}),p=t.ref(!1),m=()=>{c.value=Math.max(l(u.value),Wl),h()},h=()=>{var y,g;(y=u.value)!=null&&y.length&&(p.value=s(d.value,(g=u.value)==null?void 0:g.length))};return t.onMounted(async()=>{await t.nextTick(),c.value=Math.max(l(u.value),Wl),h(),window==null||window.addEventListener("resize",m)}),t.onUnmounted(()=>{window==null||window.removeEventListener("resize",m)}),(y,g)=>{const _=t.resolveComponent("KCollapse");return t.openBlock(),t.createBlock(_,{modelValue:o.value,"onUpdate:modelValue":g[0]||(g[0]=w=>o.value=w),class:"plugins-collapse","data-testid":`${r.name}-collapse`,title:r.name,"trigger-label":o.value?t.unref(a)("plugins.select.view_more"):t.unref(a)("plugins.select.view_less")},t.createSlots({"visible-content":t.withCtx(()=>[t.createElementVNode("div",{ref_key:"pluginCardContainerRef",ref:d,class:"plugin-card-container",style:t.normalizeStyle(f.value)},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(r.plugins,w=>(t.openBlock(),t.createBlock(Hl,{key:`plugin-card-${w.id}`,ref_for:!0,ref_key:"pluginCardRef",ref:u,config:e.config,"navigate-on-click":e.navigateOnClick,plugin:w,onPluginClicked:b=>i("plugin-clicked",w)},null,8,["config","navigate-on-click","plugin","onPluginClicked"]))),128))],4)]),_:2},[p.value?void 0:{name:"trigger",fn:t.withCtx(()=>[g[1]||(g[1]=t.createTextVNode(" ",-1))]),key:"0"}]),1032,["modelValue","data-testid","title","trigger-label"])}}}),[["__scopeId","data-v-a1074120"]]),zR={class:"plugin-select-grid"},HR={class:"empty-state-title"},YR={class:"empty-state-description"},Xl=t.defineComponent({__name:"PluginSelectGrid",props:{config:{type:Object,required:!0,validator:e=>!(!e||!["konnect","kongManager"].includes(e==null?void 0:e.app)||!e.getCreateRoute)},pluginList:{type:Object,default:()=>({})},navigateOnClick:{type:Boolean,default:!0},highlightedPlugins:{type:Array,default:()=>[]},highlightedPluginsTitle:{type:String,default:""},hideHighlightedPlugins:{type:Boolean,default:!1}},emits:["plugin-clicked"],setup(e,{emit:n}){const o=e,r=n,{i18n:{t:i}}=Re.useI18n(),a=t.ref(!1),l=t.ref(es),s=d=>{r("plugin-clicked",d)},c=t.computed(()=>{const d=JSON.parse(JSON.stringify(o.pluginList));return o.config.app==="konnect"&&delete d[K.PluginGroup.CUSTOM_PLUGINS],d});return(d,u)=>{const f=t.resolveComponent("KEmptyState");return t.openBlock(),t.createElementBlock("div",zR,[Object.keys(c.value).length?t.createCommentVNode("",!0):(t.openBlock(),t.createBlock(f,{key:0,"action-button-visible":!1,class:"plugins-empty-state","data-testid":"plugins-empty-state","icon-variant":"kong"},{title:t.withCtx(()=>[t.createElementVNode("span",HR,t.toDisplayString(t.unref(i)("plugins.select.tabs.kong.empty_title")),1)]),default:t.withCtx(()=>[t.createElementVNode("span",YR,t.toDisplayString(t.unref(i)("plugins.select.tabs.kong.empty_description")),1)]),_:1})),!o.hideHighlightedPlugins&&o.highlightedPlugins.length>0?(t.openBlock(),t.createBlock(km,{key:1,modelValue:a.value,"onUpdate:modelValue":u[0]||(u[0]=p=>a.value=p),config:e.config,name:o.highlightedPluginsTitle||t.unref(i)("plugins.select.highlighted_plugins.title"),"navigate-on-click":e.navigateOnClick,plugins:o.highlightedPlugins,onPluginClicked:u[1]||(u[1]=p=>s(p))},null,8,["modelValue","config","name","navigate-on-click","plugins"])):t.createCommentVNode("",!0),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(t.unref(Ql),p=>(t.openBlock(),t.createElementBlock(t.Fragment,null,[c.value[p]?(t.openBlock(),t.createElementBlock("div",{key:p},[t.createVNode(km,{modelValue:l.value[p],"onUpdate:modelValue":m=>l.value[p]=m,config:e.config,name:p,"navigate-on-click":e.navigateOnClick,plugins:c.value[p]||[],onPluginClicked:u[2]||(u[2]=m=>s(m))},null,8,["modelValue","onUpdate:modelValue","config","name","navigate-on-click","plugins"])])):t.createCommentVNode("",!0)],64))),256))])}}}),WR={class:"kong-ui-entities-plugin-select-form"},XR={class:"plugins-filter-input-container"},ZR={key:0},JR={key:3,"aria-live":"polite",class:"plugins-results-container"},QR={"data-testid":"kong-tab"},eD={class:"tab-description"},tD={"data-testid":"custom-tab"},nD={class:"tab-description"},oD=Ee(t.defineComponent({__name:"PluginSelect",props:{config:{type:Object,required:!0,validator:e=>!(!e||!["konnect","kongManager"].includes(e==null?void 0:e.app)||!e.getCreateRoute)},customPluginSupport:{type:String,default:"none"},canCreateCustomPlugin:{type:Function,required:!1,default:async()=>!0},canDeleteCustomPlugin:{type:Function,required:!1,default:async()=>!0},canEditCustomPlugin:{type:Function,required:!1,default:async()=>!0},navigateOnClick:{type:Boolean,default:!0},availableOnServer:{type:Boolean,default:!0},ignoredPlugins:{type:Array,default:()=>[]},disabledPlugins:{type:Object,default:()=>({})},highlightedPluginIds:{type:Array,default:()=>[]},highlightedPluginsTitle:{type:String,default:""}},emits:["loading","plugin-clicked","delete-custom:success"],setup(e,{emit:n}){var H;const o=e,r=n,i=oo.useRoute(),a=oo.useRouter(),{i18n:{t:l}}=Re.useI18n(),{pluginMetaData:s}=Re.usePluginMetaData(),{getMessageFromError:c}=se.useErrors(),{sortAlpha:d,objectsAreEqual:u}=se.useHelpers(),f=t.ref(""),p=t.ref(!0),m=t.ref(!1),h=t.ref(""),y=t.ref([]),g=t.ref([]),_=t.ref({}),w=t.ref([]),{axiosInstance:b}=se.useAxios((H=o.config)==null?void 0:H.axiosRequestConfig),v=t.computed(()=>_.value?Object.entries(_.value).filter(([L])=>L!==K.PluginGroup.CUSTOM_PLUGINS).reduce((L,[,F])=>{for(const Z of F)L[Z.id]=Z;return L},{}):{}),N=t.computed(()=>{var Z;if(!_.value)return{};const L=f.value.toLowerCase(),F=JSON.parse(JSON.stringify(_.value));for(const Q in _.value){const W=((Z=_.value[Q])==null?void 0:Z.filter(ie=>ie.name.toLowerCase().includes(L)||ie.id.toLowerCase().includes(L)||ie.group.toLowerCase().includes(L)))||[];W.length?F[Q]=W:delete F[Q]}return F}),E=t.computed(()=>o.highlightedPluginIds.reduce((L,F)=>{const Z=v.value[F];return Z&&L.push(Z),L},[])),S=t.computed(()=>Object.keys(N.value).length>0),P=t.computed(()=>Object.keys(_.value).length>0&&!S.value),B=t.computed(()=>o.config.app==="konnect"?[{hash:"#kong",title:l("plugins.select.tabs.kong.title")},{hash:"#custom",title:l("plugins.select.tabs.custom.title"),disabled:["none","disabled"].includes(o.customPluginSupport)}]:[]),j=t.computed(()=>{var F;let L=B.value.length&&((i==null?void 0:i.hash)||((F=B.value[0])==null?void 0:F.hash))||"";return L==="#custom"&&["none","disabled"].includes(o.customPluginSupport)&&(L="#kong"),L}),G=()=>[...new Set([...Object.keys({...o.availableOnServer?{}:s}),...y.value])].filter(L=>!o.ignoredPlugins.includes(L)).filter(L=>o.config.entityType&&(o.config.entityType==="services"&&s[L]&&!s[L].scope.includes(K.PluginScope.SERVICE)||o.config.entityType==="routes"&&s[L]&&!s[L].scope.includes(K.PluginScope.ROUTE)||o.config.entityType==="consumer_groups"&&s[L]&&!s[L].scope.includes(K.PluginScope.CONSUMER_GROUP)||o.config.entityType==="consumers"&&s[L]&&!s[L].scope.includes(K.PluginScope.CONSUMER))?!1:L).reduce((L,F)=>{var ae;const Z=s[F]&&s[F].name||F,Q={...s[F],id:F,name:Z,available:y.value.includes(F),disabledMessage:"",group:((ae=s[F])==null?void 0:ae.group)||K.PluginGroup.CUSTOM_PLUGINS};Q.group===K.PluginGroup.CUSTOM_PLUGINS&&(Q.customPluginType=g.value.find(me=>me.name===F)?"streaming":"schema"),o.disabledPlugins&&(Q.disabledMessage=o.disabledPlugins[F]);const W=Q.group||l("plugins.select.misc_plugins");let ie=L[W];return ie||(ie=[]),ie.push(Q),ie.sort(d("name")),L[W]=ie,L},{}),T=t.computed(()=>{var F;let L=`${o.config.apiBaseUrl}${Me.select[o.config.app].availablePlugins}`;return o.config.app==="konnect"?L=L.replace(/{controlPlaneId}/gi,o.config.controlPlaneId||""):o.config.app==="kongManager"&&(L=((F=o.config.gatewayInfo)==null?void 0:F.edition)==="community"?`${o.config.apiBaseUrl}${Me.select[o.config.app].availablePluginsForOss}`:L.replace(/\/{workspace}/gi,o.config.workspace?`/${o.config.workspace}`:"")),L}),Y=t.computed(()=>{if(o.config.app==="konnect"&&o.customPluginSupport==="streaming"){let L=`${o.config.apiBaseUrl}${Me.select[o.config.app].streamingCustomPlugins}`;return L=L.replace(/{controlPlaneId}/gi,o.config.controlPlaneId||""),L}return null}),I=t.computed(()=>{if(o.config.entityType&&o.config.entityId){let L=`${o.config.apiBaseUrl}${Me.list[o.config.app].forEntity}`;return o.config.app==="konnect"?L=L.replace(/{controlPlaneId}/gi,o.config.controlPlaneId||""):o.config.app==="kongManager"&&(L=L.replace(/\/{workspace}/gi,o.config.workspace?`/${o.config.workspace}`:"")),L.replace(/{entityType}/gi,o.config.entityType||"").replace(/{entityId}/gi,o.config.entityId||"")}return""}),M=L=>{a.replace({hash:L,query:i.query})};t.watch(()=>o.disabledPlugins,(L,F)=>{!u(L,F)&&!p.value&&(_.value=G())}),t.watch(()=>o.ignoredPlugins,(L,F)=>{!u(L,F)&&!p.value&&(_.value=G())}),t.watch(p,L=>{r("loading",L)});const R=t.ref(!1),te=t.ref(!1),z=t.ref(!1);return t.onBeforeMount(async()=>{R.value=await o.canCreateCustomPlugin(),te.value=await o.canEditCustomPlugin(),z.value=await o.canDeleteCustomPlugin()}),t.onMounted(async()=>{try{const{data:L}=await b.get(T.value);if(o.config.app==="konnect"){const{names:F}=L;if(y.value=F||[],Y.value){const{data:Z}=await b.get(Y.value);g.value=Z.data||[]}}else if(o.config.app==="kongManager"){const{plugins:{available_on_server:F}}=L;y.value=F?Object.keys(F):[]}}catch(L){m.value=!0,h.value=c(L)}if(I.value)try{const{data:{data:L}}=await b.get(I.value);if(L!=null&&L.length){const F=L.reduce((Z,Q)=>(Q.name&&Z.push(Q.name),Z),[]);w.value=w.value.concat(F)}}catch{}m.value||(_.value=G()),p.value=!1}),(L,F)=>{const Z=t.resolveComponent("KInput"),Q=t.resolveComponent("KSkeletonBox"),W=t.resolveComponent("KSkeleton"),ie=t.resolveComponent("KEmptyState"),ae=t.resolveComponent("KTooltip"),me=t.resolveComponent("KTabs");return t.openBlock(),t.createElementBlock("div",WR,[t.createElementVNode("div",XR,[t.createVNode(Z,{modelValue:f.value,"onUpdate:modelValue":F[0]||(F[0]=ge=>f.value=ge),modelModifiers:{trim:!0},class:"plugins-filter-input","data-testid":"plugins-filter",placeholder:t.unref(l)("search.placeholder.select"),type:"search"},null,8,["modelValue","placeholder"])]),p.value?(t.openBlock(),t.createElementBlock("section",ZR,[t.createVNode(Q,{class:"plugins-skeleton-title",width:"10"}),t.createVNode(W,{"card-count":8,class:"plugins-skeleton-cards",type:"card"})])):m.value?(t.openBlock(),t.createBlock(ie,{key:1,"action-button-visible":!1,"data-testid":"plugins-fetch-error","icon-variant":"error"},{default:t.withCtx(()=>[t.createElementVNode("h3",null,t.toDisplayString(h.value),1)]),_:1})):P.value&&f.value?(t.openBlock(),t.createBlock(ie,{key:2,"action-button-visible":!1,"data-testid":"plugins-empty-state","icon-variant":"search"},{default:t.withCtx(()=>[t.createElementVNode("h5",null,t.toDisplayString(t.unref(l)("search.no_results",{filter:f.value})),1)]),_:1})):(t.openBlock(),t.createElementBlock("section",JR,[B.value.length&&e.customPluginSupport!=="none"?(t.openBlock(),t.createBlock(me,{key:0,modelValue:j.value,"onUpdate:modelValue":F[5]||(F[5]=ge=>j.value=ge),"data-testid":"plugins-tabs",tabs:B.value,onChange:M},t.createSlots({kong:t.withCtx(()=>[t.createElementVNode("div",QR,[t.createElementVNode("p",eD,t.toDisplayString(t.unref(l)("plugins.select.tabs.kong.description")),1),t.createVNode(Xl,{config:e.config,"hide-highlighted-plugins":f.value.length>0,"highlighted-plugins":E.value,"highlighted-plugins-title":o.highlightedPluginsTitle,"navigate-on-click":e.navigateOnClick,"plugin-list":N.value,onPluginClicked:F[1]||(F[1]=ge=>L.$emit("plugin-clicked",ge))},null,8,["config","hide-highlighted-plugins","highlighted-plugins","highlighted-plugins-title","navigate-on-click","plugin-list"])])]),custom:t.withCtx(()=>[t.createElementVNode("div",tD,[t.createElementVNode("p",nD,t.toDisplayString(t.unref(l)("plugins.select.tabs.custom.description")),1),t.createVNode(qR,{"can-create-custom-plugin":R.value,"can-delete-custom-plugin":z.value,"can-edit-custom-plugin":te.value,config:e.config,"navigate-on-click":e.navigateOnClick,"plugin-list":N.value,"onDelete:success":F[2]||(F[2]=ge=>L.$emit("delete-custom:success",ge)),onPluginClicked:F[3]||(F[3]=ge=>L.$emit("plugin-clicked",ge)),onRevalidate:F[4]||(F[4]=()=>_.value=G())},null,8,["can-create-custom-plugin","can-delete-custom-plugin","can-edit-custom-plugin","config","navigate-on-click","plugin-list"])])]),_:2},[e.customPluginSupport==="disabled"?{name:"custom-anchor",fn:t.withCtx(()=>[t.createVNode(ae,{"max-width":"300",text:t.unref(l)("plugins.select.tabs.custom.disabled_tooltip")},{default:t.withCtx(()=>[t.createElementVNode("div",null,t.toDisplayString(t.unref(l)("plugins.select.tabs.custom.title")),1)]),_:1},8,["text"])]),key:"0"}:void 0]),1032,["modelValue","tabs"])):(t.openBlock(),t.createBlock(Xl,{key:1,config:e.config,"hide-highlighted-plugins":f.value.length>0,"highlighted-plugins":E.value,"highlighted-plugins-title":o.highlightedPluginsTitle,"navigate-on-click":e.navigateOnClick,"plugin-list":N.value,onPluginClicked:F[6]||(F[6]=ge=>L.$emit("plugin-clicked",ge))},null,8,["config","hide-highlighted-plugins","highlighted-plugins","highlighted-plugins-title","navigate-on-click","plugin-list"]))]))])}}}),[["__scopeId","data-v-c18b2b5c"]]),rD={class:"kong-ui-entity-plugin-config-card"},iD={class:"name-cell-wrapper"},aD={class:"info-name"},lD={key:0},sD={key:0},cD={key:0},dD={key:0},uD={key:0},Zl="config",fD=Ee(t.defineComponent({__name:"PluginConfigCard",props:{config:{type:Object,required:!0,validator:e=>!(!e||!["konnect","kongManager"].includes(e==null?void 0:e.app)||e.app==="konnect"&&!e.controlPlaneId||e.app==="kongManager"&&typeof e.workspace!="string"||!e.entityId||!e.pluginType)},configCardDoc:{type:String,default:"",required:!1},showIdAsLink:{type:Boolean,default:!1},hideTitle:{type:Boolean,default:!1},scopedEntityType:{type:String,required:!1,default:""},scopedEntityId:{type:String,required:!1,default:""},expandPartial:{type:Boolean,default:!0}},emits:["loading","fetch:error","error:fetch-schema","fetch:success","navigation-click"],setup(e,{emit:n}){var w;const o=n,r=e,{i18n:{t:i}}=Re.useI18n(),a=Re.usePluginMetaData(),{setFieldType:l}=Re.usePluginHelpers(),{getPropValue:s}=se.useHelpers(),c=t.computed(()=>{var b;return(b=Me.item[r.config.app])==null?void 0:b[r.scopedEntityType?"forEntity":"all"].replace(/{entityType}/gi,r.scopedEntityType).replace(/{entityId}/gi,r.scopedEntityId).concat(r.expandPartial?"?expand_partials=true":"")}),d=t.computed(()=>{var N,E;const b={},v=((N=y.value)==null?void 0:N.fields)||[];for(let S=0;S<v.length;S++){const P=y.value.fields[S],B=(E=Object.keys(P))==null?void 0:E[0];l(b,B,P[B])}return{...b,instance_name:{section:se.ConfigurationSchemaSection.Basic,order:1.5},consumer:{label:i("plugins.fields.consumer"),section:se.ConfigurationSchemaSection.Basic,order:6},route:{label:i("plugins.fields.route"),section:se.ConfigurationSchemaSection.Basic,order:6},service:{label:i("plugins.fields.service"),section:se.ConfigurationSchemaSection.Basic,order:6},consumer_group:{label:i("plugins.fields.consumer_group"),section:se.ConfigurationSchemaSection.Basic,order:6},protocols:{type:se.ConfigurationSchemaType.BadgeTag,section:se.ConfigurationSchemaSection.Basic,order:7}}}),u=t.computed(()=>{var v,N,E;if(!((v=y.value)!=null&&v.fields))return[];const b=(N=y.value.fields)==null?void 0:N.find(S=>{var B;return((B=Object.keys(S))==null?void 0:B[0])===Zl});return((E=b==null?void 0:b[Zl])==null?void 0:E.fields)||[]}),f=t.computed(()=>{var v,N;const b={};if(!u.value)return b;for(let E=0;E<((v=u.value)==null?void 0:v.length);E++){const S=u.value[E],P=(N=Object.keys(S))==null?void 0:N[0],B=S[P];B.required&&(b[P]={order:1}),l(b,P,B)}return b}),{getMessageFromError:p}=se.useErrors(),{axiosInstance:m}=se.useAxios((w=r.config)==null?void 0:w.axiosRequestConfig),h=t.computed(()=>{var v,N;let b=`${r.config.apiBaseUrl}${Me.form[r.config.app].pluginSchema}`;return r.config.app==="konnect"?b=b.replace(/{controlPlaneId}/gi,((v=r.config)==null?void 0:v.controlPlaneId)||""):r.config.app==="kongManager"&&(b=b.replace(/\/{workspace}/gi,(N=r.config)!=null&&N.workspace?`/${r.config.workspace}`:"")),b=b.replace(/{plugin}/gi,r.config.pluginType),b}),y=t.ref({});se.useSchemaProvider(y);const g=t.ref(!1),_=t.ref("");return t.onBeforeMount(async()=>{g.value=!0;try{const{data:b}=await m.get(h.value);y.value=b}catch(b){_.value=p(b),o("error:fetch-schema",b)}finally{g.value=!1}}),(b,v)=>{const N=t.resolveComponent("KSkeleton"),E=t.resolveComponent("KEmptyState"),S=t.resolveComponent("KCopy");return t.openBlock(),t.createElementBlock("div",rD,[g.value?(t.openBlock(),t.createBlock(N,{key:0,"data-testid":"plugin-config-card-loader","table-columns":2,type:"table"})):_.value?(t.openBlock(),t.createBlock(E,{key:1,"data-testid":"plugin-config-card-schema-error","icon-variant":"error"},{default:t.withCtx(()=>[t.createElementVNode("h3",null,t.toDisplayString(_.value),1)]),_:1})):(t.openBlock(),t.createBlock(t.unref(se.EntityBaseConfigCard),{key:2,config:e.config,"config-card-doc":e.configCardDoc,"config-schema":d.value,"entity-type":t.unref(se.SupportedEntityType).Plugin,"fetch-url":c.value,"hide-title":e.hideTitle,"plugin-config-key":Zl,"plugin-config-schema":f.value,"onFetch:error":v[0]||(v[0]=P=>b.$emit("fetch:error",P)),"onFetch:success":v[1]||(v[1]=P=>b.$emit("fetch:success",P)),onLoading:v[2]||(v[2]=P=>b.$emit("loading",P))},{name:t.withCtx(P=>[t.createElementVNode("div",iD,[t.createVNode(t.unref(io.PluginIcon),{class:"plugin-icon",name:t.unref(s)("rowValue",P),size:24},null,8,["name"]),t.createElementVNode("span",aD,t.toDisplayString(t.unref(a).getDisplayName(t.unref(s)("rowValue",P))),1)])]),consumer:t.withCtx(P=>[t.unref(s)("rowValue",P)?e.showIdAsLink?(t.openBlock(),t.createBlock(t.unref(se.InternalLinkItem),{key:1,item:{key:t.unref(s)("rowValue",P).id,value:t.unref(s)("rowValue",P).id,type:t.unref(se.ConfigurationSchemaType).LinkInternal},onNavigationClick:()=>b.$emit("navigation-click",t.unref(s)("rowValue",P).id,"consumer")},null,8,["item","onNavigationClick"])):(t.openBlock(),t.createBlock(S,{key:2,"copy-tooltip":t.unref(i)("copy.tooltip",{label:t.unref(s)("row",P).label}),"data-testid":"consumer-copy-uuid",text:t.unref(s)("rowValue",P).id},null,8,["copy-tooltip","text"])):(t.openBlock(),t.createElementBlock("span",lD,"–"))]),route:t.withCtx(P=>[t.unref(s)("rowValue",P)?e.showIdAsLink?(t.openBlock(),t.createBlock(t.unref(se.InternalLinkItem),{key:1,item:{key:t.unref(s)("rowValue",P).id,value:t.unref(s)("rowValue",P).id,type:t.unref(se.ConfigurationSchemaType).LinkInternal},onNavigationClick:()=>b.$emit("navigation-click",t.unref(s)("rowValue",P).id,"route")},null,8,["item","onNavigationClick"])):(t.openBlock(),t.createBlock(S,{key:2,"copy-tooltip":t.unref(i)("copy.tooltip",{label:t.unref(s)("row",P).label}),"data-testid":"route-copy-uuid",text:t.unref(s)("rowValue",P).id},null,8,["copy-tooltip","text"])):(t.openBlock(),t.createElementBlock("span",sD,"–"))]),service:t.withCtx(P=>[t.unref(s)("rowValue",P)?e.showIdAsLink?(t.openBlock(),t.createBlock(t.unref(se.InternalLinkItem),{key:1,item:{key:t.unref(s)("rowValue",P).id,value:t.unref(s)("rowValue",P).id,type:t.unref(se.ConfigurationSchemaType).LinkInternal},onNavigationClick:()=>b.$emit("navigation-click",t.unref(s)("rowValue",P).id,"service")},null,8,["item","onNavigationClick"])):(t.openBlock(),t.createBlock(S,{key:2,"copy-tooltip":t.unref(i)("copy.tooltip",{label:t.unref(s)("row",P).label}),"data-testid":"service-copy-uuid",text:t.unref(s)("rowValue",P).id},null,8,["copy-tooltip","text"])):(t.openBlock(),t.createElementBlock("span",cD,"–"))]),consumer_group:t.withCtx(P=>[t.unref(s)("rowValue",P)?e.showIdAsLink?(t.openBlock(),t.createBlock(t.unref(se.InternalLinkItem),{key:1,item:{key:t.unref(s)("rowValue",P).id,value:t.unref(s)("rowValue",P).id,type:t.unref(se.ConfigurationSchemaType).LinkInternal},onNavigationClick:()=>b.$emit("navigation-click",t.unref(s)("rowValue",P).id,"consumer_group")},null,8,["item","onNavigationClick"])):(t.openBlock(),t.createBlock(S,{key:2,"copy-tooltip":t.unref(i)("copy.tooltip",{label:t.unref(s)("row",P).label}),"data-testid":"consumer-group-copy-uuid",text:t.unref(s)("rowValue",P).id},null,8,["copy-tooltip","text"])):(t.openBlock(),t.createElementBlock("span",dD,"–"))]),partials:t.withCtx(P=>{var B,j,G,T,Y,I,M,R,te;return[t.unref(s)("rowValue",P)?e.showIdAsLink?(t.openBlock(),t.createBlock(t.unref(se.InternalLinkItem),{key:1,item:{key:(j=(B=t.unref(s)("rowValue",P))==null?void 0:B[0])==null?void 0:j.id,value:((T=(G=t.unref(s)("rowValue",P))==null?void 0:G[0])==null?void 0:T.id)+((I=(Y=t.unref(s)("rowValue",P))==null?void 0:Y[0])!=null&&I.name?"/"+((R=(M=t.unref(s)("rowValue",P))==null?void 0:M[0])==null?void 0:R.name):""),type:t.unref(se.ConfigurationSchemaType).LinkInternal},onNavigationClick:()=>{var z,H;return b.$emit("navigation-click",(H=(z=t.unref(s)("rowValue",P))==null?void 0:z[0])==null?void 0:H.id,"partial")}},null,8,["item","onNavigationClick"])):(t.openBlock(),t.createBlock(S,{key:2,"copy-tooltip":t.unref(i)("copy.tooltip",{label:t.unref(s)("row",P).label}),"data-testid":"partial-copy-uuid",text:(te=t.unref(s)("rowValue",P))==null?void 0:te[0].id},null,8,["copy-tooltip","text"])):(t.openBlock(),t.createElementBlock("span",uD,"–"))]}),_:1},8,["config","config-card-doc","config-schema","entity-type","fetch-url","hide-title","plugin-config-schema"]))])}}}),[["__scopeId","data-v-53806ec8"]]),{usePluginMetaData:pD,useProvideExperimentalFreeForms:mD}=Re;Object.defineProperty(we,"PluginGroup",{enumerable:!0,get:()=>K.PluginGroup}),Object.defineProperty(we,"PluginScope",{enumerable:!0,get:()=>K.PluginScope}),Object.defineProperty(we,"PluginIcon",{enumerable:!0,get:()=>io.PluginIcon}),Object.defineProperty(we,"getPluginIconURL",{enumerable:!0,get:()=>io.getPluginIconURL}),we.EXPERIMENTAL_FREE_FORM_PROVIDER=la,we.EntityTypeIdField=nn,we.FEATURE_FLAGS=kc,we.PLUGIN_GROUPS_COLLAPSE_STATUS=es,we.PluginConfigCard=fD,we.PluginForm=ER,we.PluginGroupArray=Ql,we.PluginList=TR,we.PluginPartialType=sr,we.PluginSelect=oD,we.PluginSelectCard=Hl,we.PluginSelectGrid=Xl,we.TOASTER_PROVIDER=Ec,we.pluginEndpoints=Me,we.usePluginMetaData=pD,we.useProvideExperimentalFreeForms=mD,Object.defineProperty(we,Symbol.toStringTag,{value:"Module"})});
|