@babsey/code-graph 0.7.0 → 0.7.1

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.
@@ -1151,7 +1151,7 @@ const ti = /* @__PURE__ */ Jo(ei), ni = (e) => ({
1151
1151
  ref: I,
1152
1152
  "onUpdate:modelValue": B[4] || (B[4] = (g) => p.value = g),
1153
1153
  class: "baklava-input",
1154
- placeholder: "Node Name",
1154
+ placeholder: "Variable name",
1155
1155
  style: { "flex-grow": "1" },
1156
1156
  type: "text",
1157
1157
  onBlur: Nt,
@@ -1,4 +1,4 @@
1
- (function(p,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("vue"),require("@baklavajs/renderer-vue"),require("@baklavajs/core"),require("@vueuse/core"),require("mustache"),require("uuid"),require("@baklavajs/interface-types"),require("@baklavajs/engine"),require("toposort"),require("@baklavajs/events")):typeof define=="function"&&define.amd?define(["exports","vue","@baklavajs/renderer-vue","@baklavajs/core","@vueuse/core","mustache","uuid","@baklavajs/interface-types","@baklavajs/engine","toposort","@baklavajs/events"],r):(p=typeof globalThis<"u"?globalThis:p||self,r(p["@babsey/code-graph"]={},p.vue,p["@baklavajs/renderer-vue"],p["@baklavajs/core"],p["@vueuse/core"],p.mustache,p.uuid,p["@baklavajs/interface-types"],p["@baklavajs/engine"],p.toposort,p["@baklavajs/events"]))})(this,(function(p,r,S,q,Pa,Le,xe,G,he,Ba,Kn){"use strict";const z=(e,t)=>{const n=e.__vccOpts||e;for(const[s,a]of t)n[s]=a;return n},Va={},La={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-check"};function Aa(e,t){return r.openBlock(),r.createElementBlock("svg",La,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M5 12l5 5l10 -10"},null,-1)])])}const Qn=z(Va,[["render",Aa]]),Ua={},$a={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-code-variable"};function Wa(e,t){return r.openBlock(),r.createElementBlock("svg",$a,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M4 8m0 2a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v4a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2z"},null,-1)])])}const es=z(Ua,[["render",Wa]]),Ha={},Fa={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-copy"};function Ga(e,t){return r.openBlock(),r.createElementBlock("svg",Fa,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z"},null,-1),r.createElementVNode("path",{d:"M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1"},null,-1)])])}const ts=z(Ha,[["render",Ga]]),ja={},za={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-dots-vertical"};function Za(e,t){return r.openBlock(),r.createElementBlock("svg",za,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"},null,-1),r.createElementVNode("path",{d:"M12 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"},null,-1),r.createElementVNode("path",{d:"M12 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"},null,-1)])])}const ns=z(ja,[["render",Za]]),qa={},Ja={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-download"};function Xa(e,t){return r.openBlock(),r.createElementBlock("svg",Ja,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"},null,-1),r.createElementVNode("path",{d:"M7 11l5 5l5 -5"},null,-1),r.createElementVNode("path",{d:"M12 4l0 12"},null,-1)])])}const ss=z(qa,[["render",Xa]]),Ka={},Qa={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-left-collapse"};function er(e,t){return r.openBlock(),r.createElementBlock("svg",Qa,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M18 3a3 3 0 0 1 2.995 2.824l.005 .176v12a3 3 0 0 1 -2.824 2.995l-.176 .005h-12a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-12a3 3 0 0 1 2.824 -2.995l.176 -.005h12zm0 2h-9v14h9a1 1 0 0 0 .993 -.883l.007 -.117v-12a1 1 0 0 0 -.883 -.993l-.117 -.007zm-2.293 4.293a1 1 0 0 1 .083 1.32l-.083 .094l-1.292 1.293l1.292 1.293a1 1 0 0 1 .083 1.32l-.083 .094a1 1 0 0 1 -1.32 .083l-.094 -.083l-2 -2a1 1 0 0 1 -.083 -1.32l.083 -.094l2 -2a1 1 0 0 1 1.414 0z"},null,-1)])])}const tr=z(Ka,[["render",er]]),nr={},sr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-left-expand"};function ar(e,t){return r.openBlock(),r.createElementBlock("svg",sr,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M18 3a3 3 0 0 1 2.995 2.824l.005 .176v12a3 3 0 0 1 -2.824 2.995l-.176 .005h-12a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-12a3 3 0 0 1 2.824 -2.995l.176 -.005h12zm0 2h-9v14h9a1 1 0 0 0 .993 -.883l.007 -.117v-12a1 1 0 0 0 -.883 -.993l-.117 -.007zm-4.387 4.21l.094 .083l2 2a1 1 0 0 1 .083 1.32l-.083 .094l-2 2a1 1 0 0 1 -1.497 -1.32l.083 -.094l1.292 -1.293l-1.292 -1.293a1 1 0 0 1 -.083 -1.32l.083 -.094a1 1 0 0 1 1.32 -.083z"},null,-1)])])}const rr=z(nr,[["render",ar]]),or={},ir={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right"};function lr(e,t){return r.openBlock(),r.createElementBlock("svg",ir,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M6 21a3 3 0 0 1 -3 -3v-12a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3zm8 -16h-8a1 1 0 0 0 -1 1v12a1 1 0 0 0 1 1h8z"},null,-1)])])}const dr=z(or,[["render",lr]]),cr={},ur={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right-collapse"};function hr(e,t){return r.openBlock(),r.createElementBlock("svg",ur,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M18 3a3 3 0 0 1 2.995 2.824l.005 .176v12a3 3 0 0 1 -2.824 2.995l-.176 .005h-12a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-12a3 3 0 0 1 2.824 -2.995l.176 -.005h12zm-3 2h-9a1 1 0 0 0 -.993 .883l-.007 .117v12a1 1 0 0 0 .883 .993l.117 .007h9v-14zm-5.387 4.21l.094 .083l2 2a1 1 0 0 1 .083 1.32l-.083 .094l-2 2a1 1 0 0 1 -1.497 -1.32l.083 -.094l1.292 -1.293l-1.292 -1.293a1 1 0 0 1 -.083 -1.32l.083 -.094a1 1 0 0 1 1.32 -.083z"},null,-1)])])}const as=z(cr,[["render",hr]]),fr={},pr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right-expand"};function mr(e,t){return r.openBlock(),r.createElementBlock("svg",pr,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M18 3a3 3 0 0 1 2.995 2.824l.005 .176v12a3 3 0 0 1 -2.824 2.995l-.176 .005h-12a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-12a3 3 0 0 1 2.824 -2.995l.176 -.005h12zm-3 2h-9a1 1 0 0 0 -.993 .883l-.007 .117v12a1 1 0 0 0 .883 .993l.117 .007h9v-14zm-3.293 4.293a1 1 0 0 1 .083 1.32l-.083 .094l-1.292 1.293l1.292 1.293a1 1 0 0 1 .083 1.32l-.083 .094a1 1 0 0 1 -1.32 .083l-.094 -.083l-2 -2a1 1 0 0 1 -.083 -1.32l.083 -.094l2 -2a1 1 0 0 1 1.414 0z"},null,-1)])])}const $t=z(fr,[["render",mr]]),_r={},yr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-lock-code"};function gr(e,t){return r.openBlock(),r.createElementBlock("svg",yr,[...t[0]||(t[0]=[r.createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M11.5 21h-4.5a2 2 0 0 1 -2 -2v-6a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2"></path><path d="M11 16a1 1 0 1 0 2 0a1 1 0 0 0 -2 0"></path><path d="M8 11v-4a4 4 0 1 1 8 0v4"></path><path d="M20 21l2 -2l-2 -2"></path><path d="M17 17l-2 2l2 2"></path>',6)])])}const Wt=z(_r,[["render",gr]]),kr={},br={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-player-play"};function wr(e,t){return r.openBlock(),r.createElementBlock("svg",br,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M7 4v16l13 -8z"},null,-1)])])}const vr=z(kr,[["render",wr]]),Nr={},Cr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-plus"};function Mr(e,t){return r.openBlock(),r.createElementBlock("svg",Cr,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M12 5l0 14"},null,-1),r.createElementVNode("path",{d:"M5 12l14 0"},null,-1)])])}const rs=z(Nr,[["render",Mr]]),Sr={},Or={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-restore"};function Er(e,t){return r.openBlock(),r.createElementBlock("svg",Or,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M3.06 13a9 9 0 1 0 .49 -4.087"},null,-1),r.createElementVNode("path",{d:"M3 4.001v5h5"},null,-1),r.createElementVNode("path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"},null,-1)])])}const os=z(Sr,[["render",Er]]),Tr={},Ir={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-schema"};function Dr(e,t){return r.openBlock(),r.createElementBlock("svg",Ir,[...t[0]||(t[0]=[r.createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M5 2h5v4h-5z"></path><path d="M15 10h5v4h-5z"></path><path d="M5 18h5v4h-5z"></path><path d="M5 10h5v4h-5z"></path><path d="M10 12h5"></path><path d="M7.5 6v4"></path><path d="M7.5 14v4"></path>',8)])])}const is=z(Tr,[["render",Dr]]),xr={},Yr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-schema-off"};function Rr(e,t){return r.openBlock(),r.createElementBlock("svg",Yr,[...t[0]||(t[0]=[r.createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M6 2h4v4m-4 0h-1v-1"></path><path d="M15 11v-1h5v4h-2"></path><path d="M5 18h5v4h-5z"></path><path d="M5 10h5v4h-5z"></path><path d="M10 12h2"></path><path d="M7.5 7.5v2.5"></path><path d="M7.5 14v4"></path><path d="M3 3l18 18"></path>',9)])])}const ls=z(xr,[["render",Rr]]),Pr={},Br={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-transition-bottom"};function Vr(e,t){return r.openBlock(),r.createElementBlock("svg",Br,[...t[0]||(t[0]=[r.createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M21 18a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3"></path><path d="M3 3m0 3a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v0a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3z"></path><path d="M12 9v8"></path><path d="M9 14l3 3l3 -3"></path>',5)])])}const ds=z(Pr,[["render",Vr]]),Lr={},Ar={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-upload"};function Ur(e,t){return r.openBlock(),r.createElementBlock("svg",Ar,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"},null,-1),r.createElementVNode("path",{d:"M7 9l5 -5l5 5"},null,-1),r.createElementVNode("path",{d:"M12 4l0 12"},null,-1)])])}const cs=z(Lr,[["render",Ur]]),$r={},Wr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-x"};function Hr(e,t){return r.openBlock(),r.createElementBlock("svg",Wr,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M18 6l-12 12"},null,-1),r.createElementVNode("path",{d:"M6 6l12 12"},null,-1)])])}const us=z($r,[["render",Hr]]),Fr=Object.freeze(Object.defineProperty({__proto__:null,Check:Qn,CodeVariable:es,Copy:ts,DotsVertical:ns,Download:ss,LayoutSidebarLeftCollapse:tr,LayoutSidebarLeftExpand:rr,LayoutSidebarRight:dr,LayoutSidebarRightCollapse:as,LayoutSidebarRightExpand:$t,LockCode:Wt,PlayerPlay:vr,Plus:rs,Restore:os,Schema:is,SchemaOff:ls,TransitionBottom:ds,Upload:cs,X:us},Symbol.toStringTag,{value:"Module"}));function Gr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ut={exports:{}};var jr=ut.exports,hs;function zr(){return hs||(hs=1,(function(e,t){(function(s,a){e.exports=a()})(jr,function(){return(function(){var n={686:(function(o,i,l){l.d(i,{default:function(){return j}});var d=l(279),c=l.n(d),h=l(370),b=l.n(h),m=l(817),D=l.n(m);function g(k){try{return document.execCommand(k)}catch{return!1}}var M=function(N){var v=D()(N);return g("cut"),v},f=M;function w(k){var N=document.documentElement.getAttribute("dir")==="rtl",v=document.createElement("textarea");v.style.fontSize="12pt",v.style.border="0",v.style.padding="0",v.style.margin="0",v.style.position="absolute",v.style[N?"right":"left"]="-9999px";var E=window.pageYOffset||document.documentElement.scrollTop;return v.style.top="".concat(E,"px"),v.setAttribute("readonly",""),v.value=k,v}var A=function(N,v){var E=w(N);v.container.appendChild(E);var I=D()(E);return g("copy"),E.remove(),I},V=function(N){var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body},E="";return typeof N=="string"?E=A(N,v):N instanceof HTMLInputElement&&!["text","search","url","tel","password"].includes(N?.type)?E=A(N.value,v):(E=D()(N),g("copy")),E},H=V;function Oe(k){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Oe=function(v){return typeof v}:Oe=function(v){return v&&typeof Symbol=="function"&&v.constructor===Symbol&&v!==Symbol.prototype?"symbol":typeof v},Oe(k)}var Ee=function(){var N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},v=N.action,E=v===void 0?"copy":v,I=N.container,R=N.target,ue=N.text;if(E!=="copy"&&E!=="cut")throw new Error('Invalid "action" value, use either "copy" or "cut"');if(R!==void 0)if(R&&Oe(R)==="object"&&R.nodeType===1){if(E==="copy"&&R.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if(E==="cut"&&(R.hasAttribute("readonly")||R.hasAttribute("disabled")))throw new Error(`Invalid "target" attribute. You can't cut text from elements with "readonly" or "disabled" attributes`)}else throw new Error('Invalid "target" value, use a valid Element');if(ue)return H(ue,{container:I});if(R)return E==="cut"?f(R):H(R,{container:I})},dt=Ee;function ye(k){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?ye=function(v){return typeof v}:ye=function(v){return v&&typeof Symbol=="function"&&v.constructor===Symbol&&v!==Symbol.prototype?"symbol":typeof v},ye(k)}function O(k,N){if(!(k instanceof N))throw new TypeError("Cannot call a class as a function")}function X(k,N){for(var v=0;v<N.length;v++){var E=N[v];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(k,E.key,E)}}function te(k,N,v){return N&&X(k.prototype,N),v&&X(k,v),k}function Jn(k,N){if(typeof N!="function"&&N!==null)throw new TypeError("Super expression must either be null or a function");k.prototype=Object.create(N&&N.prototype,{constructor:{value:k,writable:!0,configurable:!0}}),N&&ct(k,N)}function ct(k,N){return ct=Object.setPrototypeOf||function(E,I){return E.__proto__=I,E},ct(k,N)}function Vt(k){var N=At();return function(){var E=Ve(k),I;if(N){var R=Ve(this).constructor;I=Reflect.construct(E,arguments,R)}else I=E.apply(this,arguments);return Lt(this,I)}}function Lt(k,N){return N&&(ye(N)==="object"||typeof N=="function")?N:Xn(k)}function Xn(k){if(k===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return k}function At(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function Ve(k){return Ve=Object.setPrototypeOf?Object.getPrototypeOf:function(v){return v.__proto__||Object.getPrototypeOf(v)},Ve(k)}function qe(k,N){var v="data-clipboard-".concat(k);if(N.hasAttribute(v))return N.getAttribute(v)}var U=(function(k){Jn(v,k);var N=Vt(v);function v(E,I){var R;return O(this,v),R=N.call(this),R.resolveOptions(I),R.listenClick(E),R}return te(v,[{key:"resolveOptions",value:function(){var I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.action=typeof I.action=="function"?I.action:this.defaultAction,this.target=typeof I.target=="function"?I.target:this.defaultTarget,this.text=typeof I.text=="function"?I.text:this.defaultText,this.container=ye(I.container)==="object"?I.container:document.body}},{key:"listenClick",value:function(I){var R=this;this.listener=b()(I,"click",function(ue){return R.onClick(ue)})}},{key:"onClick",value:function(I){var R=I.delegateTarget||I.currentTarget,ue=this.action(R)||"copy",Ut=dt({action:ue,container:this.container,target:this.target(R),text:this.text(R)});this.emit(Ut?"success":"error",{action:ue,text:Ut,trigger:R,clearSelection:function(){R&&R.focus(),window.getSelection().removeAllRanges()}})}},{key:"defaultAction",value:function(I){return qe("action",I)}},{key:"defaultTarget",value:function(I){var R=qe("target",I);if(R)return document.querySelector(R)}},{key:"defaultText",value:function(I){return qe("text",I)}},{key:"destroy",value:function(){this.listener.destroy()}}],[{key:"copy",value:function(I){var R=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body};return H(I,R)}},{key:"cut",value:function(I){return f(I)}},{key:"isSupported",value:function(){var I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:["copy","cut"],R=typeof I=="string"?[I]:I,ue=!!document.queryCommandSupported;return R.forEach(function(Ut){ue=ue&&!!document.queryCommandSupported(Ut)}),ue}}]),v})(c()),j=U}),828:(function(o){var i=9;if(typeof Element<"u"&&!Element.prototype.matches){var l=Element.prototype;l.matches=l.matchesSelector||l.mozMatchesSelector||l.msMatchesSelector||l.oMatchesSelector||l.webkitMatchesSelector}function d(c,h){for(;c&&c.nodeType!==i;){if(typeof c.matches=="function"&&c.matches(h))return c;c=c.parentNode}}o.exports=d}),438:(function(o,i,l){var d=l(828);function c(m,D,g,M,f){var w=b.apply(this,arguments);return m.addEventListener(g,w,f),{destroy:function(){m.removeEventListener(g,w,f)}}}function h(m,D,g,M,f){return typeof m.addEventListener=="function"?c.apply(null,arguments):typeof g=="function"?c.bind(null,document).apply(null,arguments):(typeof m=="string"&&(m=document.querySelectorAll(m)),Array.prototype.map.call(m,function(w){return c(w,D,g,M,f)}))}function b(m,D,g,M){return function(f){f.delegateTarget=d(f.target,D),f.delegateTarget&&M.call(m,f)}}o.exports=h}),879:(function(o,i){i.node=function(l){return l!==void 0&&l instanceof HTMLElement&&l.nodeType===1},i.nodeList=function(l){var d=Object.prototype.toString.call(l);return l!==void 0&&(d==="[object NodeList]"||d==="[object HTMLCollection]")&&"length"in l&&(l.length===0||i.node(l[0]))},i.string=function(l){return typeof l=="string"||l instanceof String},i.fn=function(l){var d=Object.prototype.toString.call(l);return d==="[object Function]"}}),370:(function(o,i,l){var d=l(879),c=l(438);function h(g,M,f){if(!g&&!M&&!f)throw new Error("Missing required arguments");if(!d.string(M))throw new TypeError("Second argument must be a String");if(!d.fn(f))throw new TypeError("Third argument must be a Function");if(d.node(g))return b(g,M,f);if(d.nodeList(g))return m(g,M,f);if(d.string(g))return D(g,M,f);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function b(g,M,f){return g.addEventListener(M,f),{destroy:function(){g.removeEventListener(M,f)}}}function m(g,M,f){return Array.prototype.forEach.call(g,function(w){w.addEventListener(M,f)}),{destroy:function(){Array.prototype.forEach.call(g,function(w){w.removeEventListener(M,f)})}}}function D(g,M,f){return c(document.body,g,M,f)}o.exports=h}),817:(function(o){function i(l){var d;if(l.nodeName==="SELECT")l.focus(),d=l.value;else if(l.nodeName==="INPUT"||l.nodeName==="TEXTAREA"){var c=l.hasAttribute("readonly");c||l.setAttribute("readonly",""),l.select(),l.setSelectionRange(0,l.value.length),c||l.removeAttribute("readonly"),d=l.value}else{l.hasAttribute("contenteditable")&&l.focus();var h=window.getSelection(),b=document.createRange();b.selectNodeContents(l),h.removeAllRanges(),h.addRange(b),d=h.toString()}return d}o.exports=i}),279:(function(o){function i(){}i.prototype={on:function(l,d,c){var h=this.e||(this.e={});return(h[l]||(h[l]=[])).push({fn:d,ctx:c}),this},once:function(l,d,c){var h=this;function b(){h.off(l,b),d.apply(c,arguments)}return b._=d,this.on(l,b,c)},emit:function(l){var d=[].slice.call(arguments,1),c=((this.e||(this.e={}))[l]||[]).slice(),h=0,b=c.length;for(h;h<b;h++)c[h].fn.apply(c[h].ctx,d);return this},off:function(l,d){var c=this.e||(this.e={}),h=c[l],b=[];if(h&&d)for(var m=0,D=h.length;m<D;m++)h[m].fn!==d&&h[m].fn._!==d&&b.push(h[m]);return b.length?c[l]=b:delete c[l],this}},o.exports=i,o.exports.TinyEmitter=i})},s={};function a(o){if(s[o])return s[o].exports;var i=s[o]={exports:{}};return n[o](i,i.exports,a),i.exports}return(function(){a.n=function(o){var i=o&&o.__esModule?function(){return o.default}:function(){return o};return a.d(i,{a:i}),i}})(),(function(){a.d=function(o,i){for(var l in i)a.o(i,l)&&!a.o(o,l)&&Object.defineProperty(o,l,{enumerable:!0,get:i[l]})}})(),(function(){a.o=function(o,i){return Object.prototype.hasOwnProperty.call(o,i)}})(),a(686)})().default})})(ut)),ut.exports}var Zr=zr();const qr=Gr(Zr),Jr=e=>({toClipboard(t,n){return new Promise((s,a)=>{const o=document.createElement("button"),i=new qr(o,{text:()=>t,action:()=>"copy",container:n!==void 0?n:document.body});i.on("success",l=>{i.destroy(),s(l)}),i.on("error",l=>{i.destroy(),a(l)}),document.body.appendChild(o),o.click(),document.body.removeChild(o)})}}),Xr={key:0,class:"baklava-button"},fs=r.defineComponent({__name:"CopyToClipboard",props:{text:String},setup(e){const{toClipboard:t}=Jr(),n=e,s=r.toRef(n,"text"),a=r.ref(!1),o=async()=>{try{await t(s.value),a.value=!0,setTimeout(()=>a.value=!1,1500),console.log("Copied to clipboard")}catch(i){console.error(i)}};return(i,l)=>(r.openBlock(),r.createElementBlock("div",null,[a.value?(r.openBlock(),r.createElementBlock("button",Xr,[r.createVNode(r.unref(Qn))])):(r.openBlock(),r.createElementBlock("button",{key:1,onClick:o,class:"baklava-button"},[r.createVNode(r.unref(ts))]))]))}}),Kr={class:"code-editor"},Qr={class:"code-buttons"},eo=r.defineComponent({__name:"CodeEditor",props:r.mergeModels({locked:{type:Boolean},extensions:{}},{modelValue:{required:!0},modelModifiers:{}}),emits:r.mergeModels(["update:locked"],["update:modelValue"]),setup(e,{emit:t}){const n=r.useModel(e,"modelValue"),s=t,a=o=>s("update:locked",o);return(o,i)=>{const l=r.resolveComponent("codemirror");return r.openBlock(),r.createElementBlock("div",Kr,[r.createElementVNode("div",Qr,[e.locked?(r.openBlock(),r.createElementBlock("button",{key:0,class:"baklava-button",title:"The code is locked.",onClick:i[0]||(i[0]=d=>a(!1))},[r.createVNode(r.unref(Wt))])):r.createCommentVNode("",!0),r.createVNode(fs,{text:e.modelValue},null,8,["text"])]),r.createVNode(l,{modelValue:n.value,"onUpdate:modelValue":i[1]||(i[1]=d=>n.value=d),extensions:e.extensions,class:"codemirror",style:{height:"100%"},onKeydown:i[2]||(i[2]=d=>a(!0))},null,8,["modelValue","extensions"])])}}}),to=r.defineComponent({__name:"CodeGraphEditor",props:{viewModel:{}},setup(e){const t=e,n=r.toRef(t,"viewModel"),s=a=>a.events.update.emit(null);return r.onMounted(n.value.onMounted),r.onBeforeUnmount(n.value.onBeforeUnmount),r.watch(n,(a,o)=>{o&&o.onBeforeUnmount(),a&&a.onMounted()}),(a,o)=>(r.openBlock(),r.createBlock(r.unref(S.BaklavaEditor),{viewModel:n.value},{palette:r.withCtx(()=>[r.createVNode(r.unref(_s))]),node:r.withCtx(i=>[r.createVNode(r.unref(ps),r.mergeProps(i,{onUpdate:l=>s(i.node)}),null,16,["onUpdate"])]),sidebar:r.withCtx(i=>[r.createVNode(r.unref(ms),r.normalizeProps(r.guardReactiveProps(i)),{codeEditor:r.withCtx(({node:l})=>[r.renderSlot(a.$slots,"sidebarCodeEditor",{node:l})]),_:3},16)]),_:3},8,["viewModel"]))}}),no={class:"code-graph-info"},so=r.defineComponent({__name:"CodeGraphInfo",props:{viewModel:{}},setup(e){return(t,n)=>(r.openBlock(),r.createElementBlock("div",no,[r.createElementVNode("div",null,"Editor graph: "+r.toDisplayString(e.viewModel.editor.graph.shortId),1),r.createElementVNode("div",null,"Displayed graph: "+r.toDisplayString(e.viewModel.displayedGraph.shortId),1),r.createElementVNode("div",null,"Graphs: "+r.toDisplayString(e.viewModel.editor.graphIds),1),r.createElementVNode("div",null,"Graph templates: "+r.toDisplayString(e.viewModel.editor.graphTemplateIds),1),r.createElementVNode("div",null,"Engine status: "+r.toDisplayString(e.viewModel.engine?.status),1)]))}}),ao=["data-node-type","id"],ro={class:"__title-label",style:{"flex-grow":"1"}},oo={key:0},io={class:"__menu",style:{display:"flex"}},lo={class:"__outputs"},co={key:0},uo=["id","title"],ho={class:"__inputs"},fo={key:0},po=["id","title"],ps=r.defineComponent({__name:"CodeGraphNode",props:{node:{},selected:{type:Boolean,default:!1},dragging:{type:Boolean}},emits:["select","start-drag","update"],setup(e,{emit:t}){const n=S.Components.ContextMenu,s=S.Components.NodeInterface,a=e,o=r.computed(()=>a.node),i=t,{viewModel:l}=S.useViewModel(),{graph:d,switchGraph:c}=S.useGraph(),h=r.ref(null),b=r.ref(!1),m=r.ref(""),D=r.ref(null),g=r.ref(!1);let M=0,f=0;const w=r.ref(!1),A=r.computed(()=>{const U=[{value:"edit",label:"Edit"},{value:"rename",label:"Rename"},{value:"delete",label:"Delete"}];return a.node.type.startsWith(q.GRAPH_NODE_TYPE_PREFIX)&&U.push({value:"editSubgraph",label:"Edit Subgraph"}),U}),V=r.computed(()=>({"--selected":a.selected,"--dragging":a.dragging,"--two-column":!!a.node.twoColumn,"--hidden":o.value.state?.hidden})),H=r.computed(()=>({"--reverse-y":a.node.reverseY??l.value.settings.nodes.reverseY})),Oe=r.computed(()=>({top:`${a.node.position?.y??0}px`,left:`${a.node.position?.x??0}px`,"--width":`${a.node.width??l.value.settings.nodes.defaultWidth}px`})),Ee=r.computed(()=>Object.values(a.node.inputs).filter(U=>!U.hidden)),dt=r.computed(()=>Object.values(a.node.outputs).filter(U=>!U.hidden)),ye=()=>{Jn(),i("select")},O=U=>{a.selected||ye(),i("start-drag",U)},X=()=>{w.value=!0},te=()=>{const U=l.value.displayedGraph.sidebar;U.nodeId=a.node.id,U.visible=!0},Jn=()=>{const U=l.value.displayedGraph.sidebar;U.nodeId=a.node.id},ct=async U=>{switch(U){case"edit":te();break;case"delete":d.value.removeNode(a.node);break;case"rename":m.value=a.node.state.variableName,b.value=!0,await r.nextTick(),D.value?.focus();break;case"editSubgraph":c(a.node.template);break}},Vt=()=>{o.value.state.variableName=m.value,o.value.events.titleChanged.emit(o.value.state.variableName),b.value=!1},Lt=()=>{h.value&&l.value.hooks.renderNode.execute({node:a.node,el:h.value})},Xn=U=>{g.value=!0,M=a.node.width,f=U.clientX,U.preventDefault()},At=U=>{o.value.state&&(o.value.state.integrated=U,i("update"))},Ve=U=>{if(!g.value)return;const j=U.clientX-f,k=M+j/d.value.scaling,N=l.value.settings.nodes.minWidth,v=l.value.settings.nodes.maxWidth;o.value.width=Math.max(N,Math.min(v,k))},qe=()=>{g.value=!1};return r.onMounted(()=>{Lt(),window.addEventListener("mousemove",Ve),window.addEventListener("mouseup",qe)}),r.onUpdated(Lt),r.onBeforeUnmount(()=>{window.removeEventListener("mousemove",Ve),window.removeEventListener("mouseup",qe)}),(U,j)=>(r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass([V.value,"baklava-node"]),"data-node-type":o.value.type,id:o.value.id,style:r.normalizeStyle(Oe.value),ref_key:"el",ref:h,onPointerdown:ye},[r.unref(l).settings.nodes.resizable?(r.openBlock(),r.createElementBlock("div",{key:0,class:"__resize-handle",onMousedown:Xn},null,32)):r.createCommentVNode("",!0),r.createElementVNode("div",{class:"__title",onPointerdown:r.withModifiers(O,["self","stop"]),onContextmenu:r.withModifiers(X,["prevent"])},[o.value.inputs._code?(r.openBlock(),r.createBlock(r.unref(Ht),{key:0,intf:o.value.inputs._code,node:o.value,title:o.value.inputs._code.value,class:"--input","data-interface-type":"node",style:{"flex-grow":"0"}},null,8,["intf","node","title"])):r.createCommentVNode("",!0),b.value?r.withDirectives((r.openBlock(),r.createElementBlock("input",{key:2,ref_key:"renameInputEl",ref:D,"onUpdate:modelValue":j[4]||(j[4]=k=>m.value=k),class:"baklava-input",placeholder:"Node Name",style:{"flex-grow":"1"},type:"text",onBlur:Vt,onKeydown:r.withKeys(Vt,["enter"])},null,544)),[[r.vModelText,m.value]]):(r.openBlock(),r.createElementBlock(r.Fragment,{key:1},[r.createElementVNode("div",ro,[o.value.idx>-1?(r.openBlock(),r.createElementBlock("span",oo,r.toDisplayString(o.value.idx+1)+" > ",1)):r.createCommentVNode("",!0),r.createTextVNode(" "+r.toDisplayString(o.value.state.variableName.length>0?o.value.state.variableName:o.value.title),1)]),r.createElementVNode("div",io,[o.value.isCodeNode?(r.openBlock(),r.createElementBlock(r.Fragment,{key:0},[o.value.state.lockCode?(r.openBlock(),r.createBlock(r.unref(Wt),{key:0,class:"--clickable mx-1",onClick:j[0]||(j[0]=k=>o.value.lockCode=!1)})):r.createCommentVNode("",!0),o.value.hasConnectedOutputNodes?(r.openBlock(),r.createElementBlock(r.Fragment,{key:1},[o.value.state.integrated?(r.openBlock(),r.createBlock(r.unref(es),{key:1,class:"--clickable mx-1",onClick:j[2]||(j[2]=k=>At(!1))})):(r.openBlock(),r.createBlock(r.unref(ds),{key:0,class:"--clickable mx-1",onClick:j[1]||(j[1]=k=>At(!0))}))],64)):r.createCommentVNode("",!0),o.value.isSelected&&!r.unref(l).displayedGraph.sidebar.visible?(r.openBlock(),r.createBlock(r.unref($t),{key:2,class:"--clickable mx-1",onClick:te})):r.createCommentVNode("",!0)],64)):r.createCommentVNode("",!0),r.createVNode(r.unref(ns),{class:"--clickable mx-1",onClick:X}),r.createVNode(r.unref(n),{modelValue:w.value,"onUpdate:modelValue":j[3]||(j[3]=k=>w.value=k),x:0,y:0,items:A.value,onClick:ct},null,8,["modelValue","items"])])],64)),o.value.outputs._code?(r.openBlock(),r.createBlock(r.unref(Ht),{key:3,node:o.value,intf:o.value.outputs._code,class:"--output",title:o.value.outputs._code.value,"data-interface-type":"node"},null,8,["node","intf","title"])):r.createCommentVNode("",!0)],32),r.createElementVNode("div",{class:r.normalizeClass(["__content",H.value]),onKeydown:j[5]||(j[5]=r.withKeys(r.withModifiers(()=>{},["stop"]),["delete"])),onContextmenu:j[6]||(j[6]=r.withModifiers(()=>{},["prevent"]))},[r.createElementVNode("div",lo,[(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(dt.value,k=>(r.openBlock(),r.createElementBlock(r.Fragment,{key:k.id},[o.value.state?.hidden?(r.openBlock(),r.createElementBlock("div",co,[k.port?(r.openBlock(),r.createElementBlock("div",{key:0,id:k.id,title:k.name,class:"baklava-node-interface --output --connected"},[...j[7]||(j[7]=[r.createElementVNode("div",{class:"__port"},null,-1)])],8,uo)):r.createCommentVNode("",!0)])):r.renderSlot(U.$slots,"nodeInterface",{key:1,type:"output",node:o.value,intf:k},()=>[r.createVNode(r.unref(s),{node:o.value,intf:k,title:k.value},null,8,["node","intf","title"])])],64))),128))]),r.createElementVNode("div",ho,[(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(Ee.value,k=>(r.openBlock(),r.createElementBlock(r.Fragment,{key:k.id},[o.value.state?.hidden?(r.openBlock(),r.createElementBlock("div",fo,[k.port?(r.openBlock(),r.createElementBlock("div",{key:0,id:k.id,title:k.name,class:"baklava-node-interface --input --connected"},[...j[8]||(j[8]=[r.createElementVNode("div",{class:"__port"},null,-1)])],8,po)):r.createCommentVNode("",!0)])):r.renderSlot(U.$slots,"nodeInterface",{key:1,node:o.value,intf:k,type:"input"},()=>[r.createVNode(r.unref(s),{node:o.value,intf:k,title:k.value},null,8,["node","intf","title"])])],64))),128))])],34)],46,ao))}}),mo=["id"],_o={class:"align-middle"},Ht=r.defineComponent({__name:"CodeGraphNodeInterface",props:{node:{},intf:{}},setup(e){const t=e,{viewModel:n}=S.useViewModel(),{hoveredOver:s,temporaryConnection:a}=S.useTemporaryConnection(),o=r.ref(null),i=r.computed(()=>t.intf.connectionCount>0),l=r.computed(()=>({"--connected":i.value})),d=()=>{s(t.intf)},c=()=>{s(void 0)},h=()=>{o.value&&n.value.hooks.renderInterface.execute({intf:t.intf,el:o.value})};return r.onMounted(h),r.onUpdated(h),(b,m)=>(r.openBlock(),r.createElementBlock("div",{id:e.intf.id,ref_key:"el",ref:o,class:r.normalizeClass(["baklava-node-interface",l.value])},[e.intf.port?(r.openBlock(),r.createElementBlock("div",{key:0,class:r.normalizeClass([{"--selected":r.unref(a)?.from===e.intf},"__port"]),onPointerover:d,onPointerout:c},null,34)):r.createCommentVNode("",!0),r.createElementVNode("span",_o,[r.renderSlot(b.$slots,"default")])],10,mo))}}),yo=["title"],go={key:0,class:"__label"},Ft=r.defineComponent({__name:"SidebarCheckbox",props:{disabled:{type:Boolean},inversed:{type:Boolean},modelValue:{type:Boolean},name:{}},emits:["update:modelValue"],setup(e,{emit:t}){const n=t;return(s,a)=>(r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass(["baklava-checkbox",{"--checked":e.inversed?!e.modelValue:e.modelValue,"--disabled":e.disabled}]),title:e.name,onClick:a[0]||(a[0]=o=>n("update:modelValue",!e.modelValue))},[a[1]||(a[1]=r.createElementVNode("div",{class:"__checkmark-container"},[r.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18"},[r.createElementVNode("path",{class:"__checkmark",d:"M 6 5 L 6 10 L 16 10",transform:"rotate(-45 10 10)"})])],-1)),e.name?(r.openBlock(),r.createElementBlock("div",go,r.toDisplayString(e.name),1)):r.createCommentVNode("",!0)],10,yo))}}),ko={class:"__header"},bo={class:"__node-name"},wo={class:"__interfaces"},vo={class:"__inputs"},No={style:{display:"flex"}},Co={class:"__outputs"},Mo={key:0,class:"__interface"},So=["placeholder"],Oo={style:{display:"flex"}},ms=r.defineComponent({__name:"CodeGraphSidebar",setup(e){const{viewModel:t}=S.useViewModel(),{graph:n}=S.useGraph(),s=r.ref(null),a=r.toRef(t.value.settings.sidebar,"width"),o=r.computed(()=>t.value.settings.sidebar.resizable);let i=0,l=0;const d=r.computed(()=>{const w=n.value.sidebar.nodeId;return n.value.nodes.find(A=>A.id===w)}),c=r.computed(()=>d.value),h=r.computed(()=>({width:`${a.value}px`})),b=r.computed(()=>c.value?Object.values(c.value.inputs).filter(w=>w.displayInSidebar&&w.component):[]),m=r.computed(()=>c.value?Object.values(c.value.outputs).filter(w=>w.displayInSidebar&&w.component):[]),D=()=>{n.value.sidebar.visible=!1},g=()=>{d.value?.events.update.emit(null)},M=w=>{i=a.value,l=w.clientX,window.addEventListener("mousemove",f),window.addEventListener("mouseup",()=>{window.removeEventListener("mousemove",f)},{once:!0})},f=w=>{const A=s.value?.parentElement?.getBoundingClientRect().width??500,V=w.clientX-l;let H=i-V;H<300?H=300:H>.9*A&&(H=.9*A),a.value=H};return(w,A)=>(r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass([{"--open":r.unref(n).sidebar.visible},"baklava-sidebar"]),style:r.normalizeStyle(h.value),ref_key:"el",ref:s},[o.value?(r.openBlock(),r.createElementBlock("div",{key:0,class:"__resizer",onMousedown:M},null,32)):r.createCommentVNode("",!0),d.value?(r.openBlock(),r.createElementBlock(r.Fragment,{key:1},[r.createElementVNode("div",ko,[r.createElementVNode("button",{tabindex:"-1",class:"__close",onClick:D},"×"),r.createElementVNode("div",bo,[r.createElementVNode("b",null,r.toDisplayString(d.value.title),1)])]),r.createElementVNode("div",wo,[r.createElementVNode("div",vo,[(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(b.value,V=>(r.openBlock(),r.createElementBlock("div",{key:V.id,class:"__interface"},[r.createElementVNode("div",No,[r.createVNode(Ft,{modelValue:V.hidden,"onUpdate:modelValue":[H=>V.hidden=H,A[0]||(A[0]=()=>d.value?.events.update.emit(null))],disabled:!V.optional,inversed:"",style:{"padding-right":"8px"}},null,8,["modelValue","onUpdate:modelValue","disabled"]),(r.openBlock(),r.createBlock(r.resolveDynamicComponent(V.component),{modelValue:V.value,"onUpdate:modelValue":H=>V.value=H,node:d.value,intf:V,style:{width:"100%"}},null,8,["modelValue","onUpdate:modelValue","node","intf"]))])]))),128))]),r.createElementVNode("div",Co,[c.value&&c.value.state?(r.openBlock(),r.createElementBlock("div",Mo,[A[3]||(A[3]=r.createElementVNode("label",null,"Variable name",-1)),r.withDirectives(r.createElementVNode("input",{"onUpdate:modelValue":A[1]||(A[1]=V=>c.value.state.variableName=V),placeholder:c.value.variableName,type:"text",class:"baklava-input",title:"Variable name",onBlur:g,onKeydown:r.withKeys(g,["enter"])},null,40,So),[[r.vModelText,c.value.state.variableName]])])):r.createCommentVNode("",!0),(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(m.value,V=>(r.openBlock(),r.createElementBlock("div",{key:V.id,class:"__interface"},[r.createElementVNode("div",Oo,[r.createVNode(Ft,{modelValue:V.hidden,"onUpdate:modelValue":[H=>V.hidden=H,A[2]||(A[2]=()=>d.value?.events.update.emit(null))],disabled:!V.optional,inversed:"",style:{"padding-right":"8px"}},null,8,["modelValue","onUpdate:modelValue","disabled"]),(r.openBlock(),r.createBlock(r.resolveDynamicComponent(V.component),{modelValue:V.value,"onUpdate:modelValue":H=>V.value=H,node:d.value,intf:V,style:{width:"100%"}},null,8,["modelValue","onUpdate:modelValue","node","intf"]))])]))),128))])]),r.renderSlot(w.$slots,"codeEditor",{node:d.value})],64)):r.createCommentVNode("",!0)],6))}});function Eo(e,t){return Object.fromEntries(Object.entries(e).filter(t))}function To(e,t){return Object.fromEntries(Object.entries(e).map(([n,s])=>[n,t(s)]))}const Io={class:"baklava-node --palette",style:{"margin-top":"-20px","margin-bottom":"20px"}},Do={key:0,style:{display:"flex","justify-content":"space-between"}},xo=["onClick"],Yo={key:0,style:{margin:"auto 0","font-size":"12px"}},_s=r.defineComponent({__name:"CodeNodePalette",setup(e){const t=S.Components.PaletteEntry,{viewModel:n}=S.useViewModel(),{x:s,y:a}=Pa.usePointer(),{transform:o}=S.useTransform(),i=S.useNodeCategories(n),l=r.inject("editorEl"),d=r.ref(""),c=r.ref(null),h=()=>d.value?i.value.filter(g=>g.name.toLowerCase().includes(d.value.toLowerCase())||Object.values(g.nodeTypes).some(M=>M.title.toLowerCase().includes(d.value.toLowerCase()))):i.value,b=g=>d.value?Eo(g,M=>{const f=M[1];return f.category.includes(d.value.toLowerCase())||f.title?.toLowerCase().includes(d.value.toLowerCase())}):g,m=r.computed(()=>{if(!c.value||!l?.value)return{};const{left:g,top:M}=l.value.getBoundingClientRect();return{top:`${a.value-M}px`,left:`${s.value-g}px`}}),D=(g,M)=>{c.value={type:g,nodeInformation:M};const f=()=>{const w=r.reactive(new M.type);n.value.displayedGraph.addNode(w);const A=l.value.getBoundingClientRect(),[V,H]=o(s.value-A.left,a.value-A.top);w.position.x=V,w.position.y=H,c.value=null,document.removeEventListener("pointerup",f)};document.addEventListener("pointerup",f)};return(g,M)=>(r.openBlock(),r.createElementBlock(r.Fragment,null,[r.createElementVNode("div",{class:r.normalizeClass([{"--open":r.unref(n).settings.palette.enabled},"baklava-node-palette"]),onContextmenu:M[1]||(M[1]=r.withModifiers(()=>{},["stop","prevent"]))},[r.createElementVNode("div",Io,[r.withDirectives(r.createElementVNode("input",{"onUpdate:modelValue":M[0]||(M[0]=f=>d.value=f),type:"text",class:"baklava-input",title:"Filter nodes",onKeyup:h},null,544),[[r.vModelText,d.value]])]),(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(h(),f=>(r.openBlock(),r.createElementBlock("section",{key:f.name},[f.name!=="default"?(r.openBlock(),r.createElementBlock("h3",Do,[r.createElementVNode("div",{onClick:w=>d.value=f.name,style:{cursor:"pointer"}},r.toDisplayString(f.name),9,xo),Object.keys(b(f.nodeTypes)).length<Object.values(f.nodeTypes).length?(r.openBlock(),r.createElementBlock("div",Yo," ( "+r.toDisplayString(Object.keys(b(f.nodeTypes)).length)+" / "+r.toDisplayString(Object.values(f.nodeTypes).length)+" ) ",1)):r.createCommentVNode("",!0)])):r.createCommentVNode("",!0),(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(b(f.nodeTypes),(w,A)=>(r.openBlock(),r.createBlock(r.unref(t),{key:A,title:w.title,type:A,onPointerdown:V=>D(A,w)},null,8,["title","type","onPointerdown"]))),128))]))),128))],34),r.createVNode(r.Transition,{name:"fade"},{default:r.withCtx(()=>[c.value?(r.openBlock(),r.createElementBlock("div",{key:0,class:"baklava-dragged-node",style:r.normalizeStyle(m.value)},[r.createVNode(r.unref(t),{type:c.value.type,title:c.value.nodeInformation.title},null,8,["type","title"])],4)):r.createCommentVNode("",!0)]),_:1})],64))}}),Ro={},Po={class:"prependIcon"},Bo={class:"appendIcon"};function Vo(e,t){const n=r.resolveComponent("router-link");return r.openBlock(),r.createBlock(n,{class:"navItem"},{default:r.withCtx(()=>[r.createElementVNode("span",Po,[r.renderSlot(e.$slots,"prependIcon")]),r.renderSlot(e.$slots,"default"),r.createElementVNode("span",Bo,[r.renderSlot(e.$slots,"appendIcon")])]),_:3})}const Gt=z(Ro,[["render",Vo]]),Lo={class:"navbar"},Ao=["onClick"],Uo=r.defineComponent({__name:"NavBar",props:{viewModel:{},editorStates:{},routes:{}},emits:["click:remove"],setup(e,{emit:t}){const n=t,s=a=>{n("click:remove",a)};return(a,o)=>(r.openBlock(),r.createElementBlock("nav",Lo,[r.renderSlot(a.$slots,"prepend"),(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(e.editorStates,i=>(r.openBlock(),r.createBlock(Gt,{key:i.graph.id,class:r.normalizeClass({active:i.graph.id===e.viewModel.displayedGraph.id}),to:{name:e.routes?.edit??"edit",params:{editorId:i.graph.id}}},{appendIcon:r.withCtx(()=>[r.createElementVNode("button",{class:"remove",onClick:r.withModifiers(l=>s(i.graph.id),["prevent"])},[r.createVNode(r.unref(us))],8,Ao)]),default:r.withCtx(()=>[r.createTextVNode(r.toDisplayString(i.graph.id.slice(0,6))+" ",1)]),_:2},1032,["class","to"]))),128)),r.renderSlot(a.$slots,"append",{},()=>[r.createVNode(Gt,{to:{name:e.routes?.new??"new"},class:"navItem"},{default:r.withCtx(()=>[r.createVNode(r.unref(rs),{class:"plus"})]),_:1},8,["to"])])]))}}),$o=r.defineComponent({props:{intf:{type:Object,required:!0},modelValue:{type:String,required:!0}},emits:["update:modelValue"],setup(e,{emit:t}){return{v:r.computed({get:()=>e.modelValue,set:s=>{t("update:modelValue",s)}})}}}),Wo={style:{position:"relative"}},Ho={style:{"font-size":"12px",padding:"0 6px",position:"absolute",top:"-8px","background-color":"var(--baklava-node-color-background)"}},Fo=["placeholder","title"];function Go(e,t,n,s,a,o){return r.openBlock(),r.createElementBlock("div",Wo,[r.createElementVNode("label",Ho,r.toDisplayString(e.intf.name),1),r.withDirectives(r.createElementVNode("input",{"onUpdate:modelValue":t[0]||(t[0]=i=>e.v=i),type:"text",class:"baklava-input",placeholder:e.intf.name,title:e.intf.name},null,8,Fo),[[r.vModelText,e.v]])])}const jt=z($o,[["render",Go]]),jo=Object.freeze(Object.defineProperty({__proto__:null,CodeEditor:eo,CodeGraphEditor:to,CodeGraphInfo:so,CodeGraphNode:ps,CodeGraphNodeInterface:Ht,CodeGraphSidebar:ms,CodeNodePalette:_s,CopyToClipboard:fs,NavBar:Uo,NavItem:Gt,SidebarCheckbox:Ft,TextInputInterface:jt},Symbol.toStringTag,{value:"Module"}));Le.escape=e=>e;class zt extends q.AbstractNode{codeTemplate;isCodeNode=!0;mask=null;name="";state;_variableName="";inputs={};outputs={};constructor(){super(),this.initializeIo(),this.twoColumn=!0,this.state=r.reactive({codeTemplate:"",hidden:!1,integrated:!1,lockCode:!1,modules:[],props:null,script:"",variableName:""}),this.codeTemplate=function(){return`${this.name}(${ys(this.codeNodeInputs).join(", ")})`}}get code(){return this.graph.code}get codeNodeInputs(){return Object.fromEntries(Object.entries(this.inputs).filter(t=>t[1].isCodeNode&&t[1].type!="node"))}get codeNodeOutputs(){return Object.fromEntries(Object.entries(this.outputs).filter(t=>t[1].isCodeNode&&t[1].type!="node"))}get graph(){return super.graph}get hasConnectedOutputNodes(){return this.getConnectedNodes("outputs").length>0}get idx(){return this.graph.nodes.filter(t=>!t.state.integrated).indexOf(this)??-1}get idxByType(){return this.graph.getNodesByType(this.type).indexOf(this)??-1}get idxByVariableNames(){return this.graph.getNodesByVariableName(this.state.variableName??this._variableName).filter(t=>!t.state.integrated).indexOf(this)??-1}get isSelected(){return this.graph.selectedNodeIds.includes(this.id)}get lockCode(){return this.state.lockCode}set lockCode(t){this.state.lockCode=t,this.events.update.emit(null)}get optionalInputs(){return Object.fromEntries(Object.entries(this.codeNodeInputs).filter(t=>t[1].optional))}get requiredInputs(){return Object.fromEntries(Object.entries(this.codeNodeInputs).filter(t=>!t[1].optional))}get script(){return this.outputs._code?.value??""}set script(t){this.outputs._code&&(this.outputs._code.value=t),this.events.update.emit(null)}get shortId(){return this.id.slice(0,6)}get shownInSidebar(){return this.graph.sidebar.nodeId===this.id}get subgraph(){}get variableName(){return(this.state.variableName?this.state.variableName:this._variableName)+(this.idxByVariableNames+1)}getConnectedNodeByInterface(t,n){const s=this.getConnectedNodesByInterface(t,n);return s.length>0?s[0]:null}getConnectedNodes(t){let n=[];if(t!=="inputs"){const s=this.graph.connections.filter(a=>a.from.name!=="_code").filter(a=>a.from.nodeId===this.id).map(a=>a.to.nodeId);s&&(n=n.concat(s))}if(t!=="outputs"){const s=this.graph.connections.filter(a=>a.from.name!=="_code").filter(a=>a.to.nodeId===this.id).map(a=>a.from.nodeId);s&&(n=n.concat(s))}return!n||n.length==0?[]:n.map(s=>this.graph.findNodeById(s))}getConnectedNodesByInterface(t,n){let s=[];if(n!=="outputs"&&this.inputs[t]){const a=this.graph.connections.filter(o=>o.to.id===this.inputs[t]?.id||o.from.id===this.inputs[t]?.id).map(o=>o.from.nodeId);a&&(s=s.concat(a))}if(n!=="inputs"&&this.outputs[t]){const a=this.graph.connections.filter(o=>o.from.id===this.outputs[t]?.id||o.from.id===this.outputs[t]?.id).map(o=>o.to.nodeId);a&&(s=s.concat(a))}return!s||s.length==0?[]:s.map(a=>this.graph.findNodeById(a))}remove(){this.graph?.removeNode(this)}renderCode(t){return Le.render(this.state.codeTemplate,t)}updateCodeTemplate(){this.state.codeTemplate=this.codeTemplate.call(this)}updateModules(t){if(t)this.state.modules=t;else if(this.type.includes(".")){const n=this.type.split(".");this.state.modules.push(n.slice(0,n.length-1).join("."))}}updateOutputNames(){Object.values(this.codeNodeOutputs).forEach(t=>{t.name=this.state.integrated?"":this.variableName+t.suffix})}updateOutputValues(t){Object.keys(this.outputs).forEach(n=>{n!=="_code"&&(t[n]=this.state.integrated?t._code:this.outputs[n].name)})}updateProps(t){this.state.props=t}updateInputValues(t){const n=Object.keys(this.inputs);Object.keys(t).forEach(s=>{!n.includes(s)||!this.inputs[s]||(this.inputs[s].value=t[s],this.inputs[s].setHidden(!1))})}}class ht extends zt{calculate=(t,n)=>{const s={};return this.lockCode||(s._code=this.renderCode({inputs:t,...n})),this.updateOutputValues(s),s};executeFactory(t,n){Object.keys(n||{}).forEach(s=>{const a=n[s]();t==="input"?this.addInput(s,a):this.addOutput(s,a)})}load(t){super.load(t),Zt(this.graph,t),this.afterLoaded()}save(){const t=super.save();return gs(this.graph,t),t}}const ys=(e,t=!0)=>{const n=[],s=Object.keys(e);return s.forEach(a=>{if(e[a]?.hidden)return;const i=t&&n.length<s.indexOf(a)?`${a}=`:"";n.push(`${i}{{ inputs.${a} }}`)}),n},Zt=(e,t)=>{if(!e)return;const n=e.findNodeById(t.id);if(!n||n.subgraph)return;const s=n;s.state&&(s.state.integrated=t.integrated,t.props&&(s.state.props=t.props),t.variableName&&(s.state.variableName=t.variableName)),Object.entries(t.inputs).forEach(([a,o])=>{a!=="_code"&&s.inputs[a]&&(s.inputs[a].hidden=o.hidden,o.optional&&(s.inputs[a].state.optional=o.optional))}),Object.entries(t.outputs).forEach(([a,o])=>{a!=="_code"&&s.outputs[a]&&(s.outputs[a].hidden=o.hidden,o.optional&&(s.outputs[a].state.optional=o.optional))})},gs=(e,t)=>{if(!e)return;const n=e.findNodeById(t.id);if(!n||n.subgraph)return;const s=n;s.state&&(t.integrated=s.state.integrated,s.state.props&&(t.props=s.state.props),s.state.variableName&&(t.variableName=s.state.variableName)),Object.entries(t.inputs).forEach(([a,o])=>{if(a!=="_code"&&s.inputs[a]){const i=s.inputs[a];o.hidden=i.hidden,i.state?.optional&&(o.optional=i.state.optional),i.component?.__name&&(o.component=i.component.__name)}}),Object.entries(t.outputs).forEach(([a,o])=>{a!=="_code"&&s.outputs[a]&&(o.hidden=s.outputs[a].hidden)})},ks=(e,t)=>{switch(e){case"CheckBoxInterface":return new ws(t.id,t.value);case"IntegerInterface":return new tn(t.id,t.value,t.min,t.max);case"NumberInterface":return new Ns(t.id,t.value,t.min,t.max);case"SelectInterface":return new Cs(t.id,t.value,t.items);default:return new sn(t.id,t.value)}},zo=["title"],ft=r.defineComponent({__name:"CodeNodeInterface",props:{intf:{}},setup(e){return(t,n)=>(r.openBlock(),r.createElementBlock("div",{title:e.intf.value},r.toDisplayString(e.intf.name),9,zo))}});class Q extends q.NodeInterface{isCodeNode=!0;code;state;type=null;constructor(t,n){super(t,n),this.setComponent(r.markRaw(ft)),this.state=r.reactive({optional:!1})}get optional(){return this.state.optional}get shortId(){return this.id.slice(0,6)}getValue=()=>`${this.value??"None"}`;setOptional(t){return this.state.optional=t,this.setHidden(t),this}}class Ae extends Q{constructor(t="",n){super(t,n),this.setComponent(r.markRaw(ft)),this.use(S.displayInSidebar,!0)}get value(){return super.value}set value(t){super.value=t,this.name!=="_code"&&this.setHidden(!1)}}const qt=new G.NodeInterfaceType("boolean"),bs=new G.NodeInterfaceType("dict"),Jt=new G.NodeInterfaceType("list"),se=new G.NodeInterfaceType("node"),Xt=new G.NodeInterfaceType("number"),Kt=new G.NodeInterfaceType("string"),Qt=new G.NodeInterfaceType("tuple"),Zo=e=>{new G.BaklavaInterfaceTypes(e.editor,{viewPlugin:e}).addTypes(qt,bs,Jt,se,Xt,Kt,Qt)};class ws extends Ae{constructor(t,n){super(t,n),this.setComponent(r.markRaw(S.CheckboxInterfaceComponent)),this.use(G.setType,qt)}getValue=()=>this.value?"True":"False"}class vs extends Q{isCodeNodeOutput=!0;suffix="";constructor(t="",n=""){super(t,""),this.suffix=n,this.setComponent(r.markRaw(ft))}get codeValue(){return this.node?.outputs._code.value??""}get node(){const{graph:t}=S.useGraph();return t.value.findNodeById(this.nodeId)}}class en extends Ae{min;max;constructor(t,n,s,a){super(t,n),this.min=s,this.max=a,this.use(G.setType,Xt)}validate(t){return(this.min===void 0||t>=this.min)&&(this.max===void 0||t<=this.max)}}class tn extends en{component=r.markRaw(S.IntegerInterfaceComponent);validate(t){return Number.isInteger(t)&&super.validate(t)}}class qo extends Ae{constructor(t="",n=""){super(t,n),this.setComponent(r.markRaw(S.TextInputInterfaceComponent)),this.use(G.setType,Jt)}getValue=()=>`[${this.value}]`}class Ns extends en{component=r.markRaw(S.NumberInterfaceComponent)}class nn extends Ae{constructor(t,n){super(t,n),this.use(G.setType,Kt)}getValue=()=>`"${this.value}"`}class Cs extends nn{component=r.markRaw(S.SelectInterfaceComponent);items;constructor(t,n,s){super(t,n),this.items=s}}class Jo extends en{component=r.markRaw(S.SliderInterfaceComponent);min;max;constructor(t,n,s,a){super(t,n,s,a),this.min=s,this.max=a}getValue=()=>`${Math.round(this.value*1e3)/1e3}`}class sn extends nn{component=r.markRaw(jt)}class Xo extends nn{component=r.markRaw(S.TextareaInputInterfaceComponent)}class Ko extends Ae{constructor(t="",n=""){super(t,n),this.setComponent(r.markRaw(S.TextInputInterfaceComponent)),this.use(G.setType,Qt)}getValue=()=>`(${this.value})`}function Qo(e){return class extends ht{type=e.type;inputs={};outputs={};constructor(){super(),this._title=e.title??e.type,this.executeFactory("input",e.inputs),this.executeFactory("output",e.outputs),e.calculate&&(this.calculate=(t,n)=>e.calculate.call(this,t,n)),e.onCreate?.call(this),this.name=e.name??e.type,this.updateModules(e.modules),e.codeTemplate&&(this.codeTemplate=e.codeTemplate),e.variableName!=null&&(this._variableName=e.variableName),this.addInput("_code",new Q("_code",[]).use(G.setType,se).use(he.allowMultipleConnections).setHidden(!0)),this.addOutput("_code",new Q("_code",[]).use(G.setType,se).use(he.allowMultipleConnections).setHidden(!0))}afterGraphLoaded(){e.afterGraphLoaded?.call(this)}afterLoaded(){e.afterLoaded?.call(this)}onPlaced(){e.onPlaced?.call(this)}onConnected(){e.onConnected?.call(this)}onDestroy(){e.onDestroy?.call(this)}onGraphUpdate(){e.onGraphUpdate?.call(this)}onUnconnected(){e.onUnconnected?.call(this)}update(){e.update?.call(this)}}}class Ms extends ht{}function ei(e){return class extends Ms{type=e.type;inputs={};outputs={};preventUpdate=!1;staticInputKeys=Object.keys(e.inputs??{});staticOutputKeys=Object.keys(e.outputs??{});constructor(){super(),this._title=e.title??e.type,this.executeFactory("input",e.inputs),this.executeFactory("output",e.outputs),e.calculate&&(this.calculate=(t,n)=>e.calculate?.call(this,t,n)),e.onCreate?.call(this),this.name=e.name??e.type,this.updateModules(e.modules),e.codeTemplate&&(this.codeTemplate=e.codeTemplate),e.variableName&&(this._variableName=e.variableName),this.addInput("_code",new Q("_code",[]).use(G.setType,se).use(he.allowMultipleConnections).setHidden(!0)),this.addOutput("_code",new Q("_code",[]).use(G.setType,se).use(he.allowMultipleConnections).setHidden(!0)),this.staticInputKeys.push("_code"),this.staticOutputKeys.push("_code")}afterGraphLoaded(){e.afterGraphLoaded?.call(this)}afterLoaded(){e.afterLoaded?.call(this)}onPlaced(){this.events.update.subscribe(this,t=>{t&&(t.type==="input"&&this.staticInputKeys.includes(t.name)||t.type==="output"&&this.staticOutputKeys.includes(t.name))&&this.onUpdate()}),this.onUpdate(),e.onPlaced?.call(this)}onConnected(){e.onConnected?.call(this)}onDestroy(){e.onDestroy?.call(this)}onGraphUpdate(){e.onGraphUpdate?.call(this)}onUnconnected(){e.onUnconnected?.call(this)}update(){e.update?.call(this)}load(t){this.preventUpdate=!0,this.hooks.beforeLoad.execute(t),this.id=t.id,this.title=t.title;for(const n of this.staticInputKeys)this.inputs[n].load(t.inputs[n]),this.inputs[n].nodeId=this.id,n!=="_code"&&(this.inputs[n].hidden=t.inputs[n].hidden);for(const n of this.staticOutputKeys)this.outputs[n].load(t.outputs[n]),this.outputs[n].nodeId=this.id,n!=="_code"&&(this.outputs[n].hidden=t.outputs[n].hidden);this.preventUpdate=!1,this.onUpdate(),this.preventUpdate=!0;for(const n of Object.keys(t.inputs))if(!(this.staticInputKeys.includes(n)||!t.inputs[n])){if(!this.inputs[n]){const s=t.inputs[n],a=s.value;let o;s.component?o=ks(s.component,{...s,id:n}):typeof a=="number"?o=new tn(n,a):o=new sn(n,JSON.stringify(a)),o.use(S.displayInSidebar,!0),o.setOptional(s.optional??!1),o.setHidden(s.hidden??!1),this.addInput(n,o)}this.inputs[n]&&(this.inputs[n].load(t.inputs[n]),this.inputs[n].nodeId=this.id)}for(const n of Object.keys(t.outputs))if(!(this.staticOutputKeys.includes(n)||!t.outputs[n])){if(!this.outputs[n]){const s=new vs(n);this.addOutput(n,s)}this.outputs[n]&&(this.outputs[n].load(t.outputs[n]),this.outputs[n].nodeId=this.id)}Zt(this.graph,t),this.preventUpdate=!1,this.events.loaded.emit(this)}onUpdate(){if(!e.onUpdate||this.preventUpdate)return;this.graph&&this.graph.activeTransactions++;const t=this.getStaticValues(this.staticInputKeys,this.inputs),n=this.getStaticValues(this.staticOutputKeys,this.outputs),s=e.onUpdate.call(this,t,n);this.updateInterfaces("input",s.inputs??{},s.forceUpdateInputs??[]),this.updateInterfaces("output",s.outputs??{},s.forceUpdateOutputs??[]),this.graph&&this.graph.activeTransactions--}getStaticValues(t,n){const s={};for(const a of t)s[a]=n[a].value;return s}updateInputInterfaces(t={},n=[]){this.updateInterfaces("input",t,n)}updateInterfaces(t,n={},s=[]){const a=t==="input"?this.staticInputKeys:this.staticOutputKeys,o=t==="input"?this.inputs:this.outputs;for(const i of Object.keys(o))a.includes(i)||n[i]&&!s.includes(i)||(t==="input"?this.removeInput(i):this.removeOutput(i));for(const i of Object.keys(n)){if(o[i])continue;const l=n[i]();t==="input"?this.addInput(i,l):this.addOutput(i,l)}}updateProps(t){this.state.props=t,this.onUpdate()}}}Le.escape=e=>e;class pt{_id;_state;viewModel;constructor(){this._id=xe.v4(),this._state=r.reactive({lockCode:!1,modules:{},script:"",template:""})}get engine(){return this.viewModel?.engine}get graph(){return this.viewModel?.editor.graph}get id(){return this._id}get lockCode(){return this.state.lockCode}set lockCode(t){this.state.lockCode=t,this.engine?.runOnce(null)}get modules(){const t=[];return this.graph?.codeNodes.filter(n=>n.state.modules?.length>0).forEach(n=>t.push(...n.state.modules)),t?(t.sort(),Array.from(new Set(t.map(n=>this.state.modules[n])))):[]}get script(){return this.state.script}set script(t){this.state.script=t,this.engine?.runOnce(null)}get shortId(){return this.id.slice(0,6)}get state(){return this._state}clear(){this.state.script=""}async loadTemplate(t){t.then(n=>{this._state.template=n.default??""})}registerViewModel(t){this.viewModel=t}renderCode(t){this.state.script=Le.render(this.state.template||"",t??{})}}class ti extends pt{constructor(){super(),this.loadTemplate(Promise.resolve().then(()=>pu))}}class ni extends pt{constructor(){super(),this.loadTemplate(Promise.resolve().then(()=>mu))}}const si=e=>{e.allowMultipleConnections=!0};class Ss extends he.BaseEngine{order=new Map;constructor(t){super(t)}start(){super.start(),this.recalculateOrder=!0,this.calculateWithoutData()}async runGraph(t,n,s){this.order.has(t.id)||this.order.set(t.id,he.sortTopologically(t));const{calculationOrder:a,connectionsFromNode:o}=this.order.get(t.id),i=new Map;for(const l of a){const d={};Object.entries(l.inputs).forEach(([h,b])=>{d[h]=this.getInterfaceValue(n,b.id)}),l.isCodeNode&&(l.updateCodeTemplate(),l.updateOutputNames()),this.events.beforeNodeCalculation.emit({inputValues:d,node:l});let c;if(l.calculate){if(c=await l.calculate(d,{globalValues:s,engine:this}),o.has(l))for(const[h,b]of Object.entries(c))this.hooks.transferData.execute(c[h],b),o.get(l).forEach(m=>n.set(m.to.id,b))}else{c={};for(const[h,b]of Object.entries(l.outputs))c[h]=this.getInterfaceValue(n,b.id)}this.events.afterNodeCalculation.emit({outputValues:c,node:l}),i.set(l.id,new Map(Object.entries(c))),o.has(l)&&o.get(l).forEach(h=>{const b=Object.entries(l.outputs).find(([,D])=>D.id===h.from.id)?.[0];if(!b)throw new Error(`Could not find key for interface ${h.from.id}
1
+ (function(p,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("vue"),require("@baklavajs/renderer-vue"),require("@baklavajs/core"),require("@vueuse/core"),require("mustache"),require("uuid"),require("@baklavajs/interface-types"),require("@baklavajs/engine"),require("toposort"),require("@baklavajs/events")):typeof define=="function"&&define.amd?define(["exports","vue","@baklavajs/renderer-vue","@baklavajs/core","@vueuse/core","mustache","uuid","@baklavajs/interface-types","@baklavajs/engine","toposort","@baklavajs/events"],r):(p=typeof globalThis<"u"?globalThis:p||self,r(p["@babsey/code-graph"]={},p.vue,p["@baklavajs/renderer-vue"],p["@baklavajs/core"],p["@vueuse/core"],p.mustache,p.uuid,p["@baklavajs/interface-types"],p["@baklavajs/engine"],p.toposort,p["@baklavajs/events"]))})(this,(function(p,r,S,q,Pa,Le,xe,G,he,Ba,Kn){"use strict";const z=(e,t)=>{const n=e.__vccOpts||e;for(const[s,a]of t)n[s]=a;return n},Va={},La={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-check"};function Aa(e,t){return r.openBlock(),r.createElementBlock("svg",La,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M5 12l5 5l10 -10"},null,-1)])])}const Qn=z(Va,[["render",Aa]]),Ua={},$a={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-code-variable"};function Wa(e,t){return r.openBlock(),r.createElementBlock("svg",$a,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M4 8m0 2a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v4a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2z"},null,-1)])])}const es=z(Ua,[["render",Wa]]),Ha={},Fa={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-copy"};function Ga(e,t){return r.openBlock(),r.createElementBlock("svg",Fa,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z"},null,-1),r.createElementVNode("path",{d:"M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1"},null,-1)])])}const ts=z(Ha,[["render",Ga]]),ja={},za={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-dots-vertical"};function Za(e,t){return r.openBlock(),r.createElementBlock("svg",za,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"},null,-1),r.createElementVNode("path",{d:"M12 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"},null,-1),r.createElementVNode("path",{d:"M12 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"},null,-1)])])}const ns=z(ja,[["render",Za]]),qa={},Ja={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-download"};function Xa(e,t){return r.openBlock(),r.createElementBlock("svg",Ja,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"},null,-1),r.createElementVNode("path",{d:"M7 11l5 5l5 -5"},null,-1),r.createElementVNode("path",{d:"M12 4l0 12"},null,-1)])])}const ss=z(qa,[["render",Xa]]),Ka={},Qa={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-left-collapse"};function er(e,t){return r.openBlock(),r.createElementBlock("svg",Qa,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M18 3a3 3 0 0 1 2.995 2.824l.005 .176v12a3 3 0 0 1 -2.824 2.995l-.176 .005h-12a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-12a3 3 0 0 1 2.824 -2.995l.176 -.005h12zm0 2h-9v14h9a1 1 0 0 0 .993 -.883l.007 -.117v-12a1 1 0 0 0 -.883 -.993l-.117 -.007zm-2.293 4.293a1 1 0 0 1 .083 1.32l-.083 .094l-1.292 1.293l1.292 1.293a1 1 0 0 1 .083 1.32l-.083 .094a1 1 0 0 1 -1.32 .083l-.094 -.083l-2 -2a1 1 0 0 1 -.083 -1.32l.083 -.094l2 -2a1 1 0 0 1 1.414 0z"},null,-1)])])}const tr=z(Ka,[["render",er]]),nr={},sr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-left-expand"};function ar(e,t){return r.openBlock(),r.createElementBlock("svg",sr,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M18 3a3 3 0 0 1 2.995 2.824l.005 .176v12a3 3 0 0 1 -2.824 2.995l-.176 .005h-12a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-12a3 3 0 0 1 2.824 -2.995l.176 -.005h12zm0 2h-9v14h9a1 1 0 0 0 .993 -.883l.007 -.117v-12a1 1 0 0 0 -.883 -.993l-.117 -.007zm-4.387 4.21l.094 .083l2 2a1 1 0 0 1 .083 1.32l-.083 .094l-2 2a1 1 0 0 1 -1.497 -1.32l.083 -.094l1.292 -1.293l-1.292 -1.293a1 1 0 0 1 -.083 -1.32l.083 -.094a1 1 0 0 1 1.32 -.083z"},null,-1)])])}const rr=z(nr,[["render",ar]]),or={},ir={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right"};function lr(e,t){return r.openBlock(),r.createElementBlock("svg",ir,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M6 21a3 3 0 0 1 -3 -3v-12a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3zm8 -16h-8a1 1 0 0 0 -1 1v12a1 1 0 0 0 1 1h8z"},null,-1)])])}const dr=z(or,[["render",lr]]),cr={},ur={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right-collapse"};function hr(e,t){return r.openBlock(),r.createElementBlock("svg",ur,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M18 3a3 3 0 0 1 2.995 2.824l.005 .176v12a3 3 0 0 1 -2.824 2.995l-.176 .005h-12a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-12a3 3 0 0 1 2.824 -2.995l.176 -.005h12zm-3 2h-9a1 1 0 0 0 -.993 .883l-.007 .117v12a1 1 0 0 0 .883 .993l.117 .007h9v-14zm-5.387 4.21l.094 .083l2 2a1 1 0 0 1 .083 1.32l-.083 .094l-2 2a1 1 0 0 1 -1.497 -1.32l.083 -.094l1.292 -1.293l-1.292 -1.293a1 1 0 0 1 -.083 -1.32l.083 -.094a1 1 0 0 1 1.32 -.083z"},null,-1)])])}const as=z(cr,[["render",hr]]),fr={},pr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",class:"baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right-expand"};function mr(e,t){return r.openBlock(),r.createElementBlock("svg",pr,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M18 3a3 3 0 0 1 2.995 2.824l.005 .176v12a3 3 0 0 1 -2.824 2.995l-.176 .005h-12a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-12a3 3 0 0 1 2.824 -2.995l.176 -.005h12zm-3 2h-9a1 1 0 0 0 -.993 .883l-.007 .117v12a1 1 0 0 0 .883 .993l.117 .007h9v-14zm-3.293 4.293a1 1 0 0 1 .083 1.32l-.083 .094l-1.292 1.293l1.292 1.293a1 1 0 0 1 .083 1.32l-.083 .094a1 1 0 0 1 -1.32 .083l-.094 -.083l-2 -2a1 1 0 0 1 -.083 -1.32l.083 -.094l2 -2a1 1 0 0 1 1.414 0z"},null,-1)])])}const $t=z(fr,[["render",mr]]),_r={},yr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-lock-code"};function gr(e,t){return r.openBlock(),r.createElementBlock("svg",yr,[...t[0]||(t[0]=[r.createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M11.5 21h-4.5a2 2 0 0 1 -2 -2v-6a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2"></path><path d="M11 16a1 1 0 1 0 2 0a1 1 0 0 0 -2 0"></path><path d="M8 11v-4a4 4 0 1 1 8 0v4"></path><path d="M20 21l2 -2l-2 -2"></path><path d="M17 17l-2 2l2 2"></path>',6)])])}const Wt=z(_r,[["render",gr]]),kr={},br={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-player-play"};function wr(e,t){return r.openBlock(),r.createElementBlock("svg",br,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M7 4v16l13 -8z"},null,-1)])])}const vr=z(kr,[["render",wr]]),Nr={},Cr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-plus"};function Mr(e,t){return r.openBlock(),r.createElementBlock("svg",Cr,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M12 5l0 14"},null,-1),r.createElementVNode("path",{d:"M5 12l14 0"},null,-1)])])}const rs=z(Nr,[["render",Mr]]),Sr={},Or={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-restore"};function Er(e,t){return r.openBlock(),r.createElementBlock("svg",Or,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M3.06 13a9 9 0 1 0 .49 -4.087"},null,-1),r.createElementVNode("path",{d:"M3 4.001v5h5"},null,-1),r.createElementVNode("path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"},null,-1)])])}const os=z(Sr,[["render",Er]]),Tr={},Ir={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-schema"};function Dr(e,t){return r.openBlock(),r.createElementBlock("svg",Ir,[...t[0]||(t[0]=[r.createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M5 2h5v4h-5z"></path><path d="M15 10h5v4h-5z"></path><path d="M5 18h5v4h-5z"></path><path d="M5 10h5v4h-5z"></path><path d="M10 12h5"></path><path d="M7.5 6v4"></path><path d="M7.5 14v4"></path>',8)])])}const is=z(Tr,[["render",Dr]]),xr={},Yr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-schema-off"};function Rr(e,t){return r.openBlock(),r.createElementBlock("svg",Yr,[...t[0]||(t[0]=[r.createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M6 2h4v4m-4 0h-1v-1"></path><path d="M15 11v-1h5v4h-2"></path><path d="M5 18h5v4h-5z"></path><path d="M5 10h5v4h-5z"></path><path d="M10 12h2"></path><path d="M7.5 7.5v2.5"></path><path d="M7.5 14v4"></path><path d="M3 3l18 18"></path>',9)])])}const ls=z(xr,[["render",Rr]]),Pr={},Br={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-transition-bottom"};function Vr(e,t){return r.openBlock(),r.createElementBlock("svg",Br,[...t[0]||(t[0]=[r.createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M21 18a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3"></path><path d="M3 3m0 3a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v0a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3z"></path><path d="M12 9v8"></path><path d="M9 14l3 3l3 -3"></path>',5)])])}const ds=z(Pr,[["render",Vr]]),Lr={},Ar={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-upload"};function Ur(e,t){return r.openBlock(),r.createElementBlock("svg",Ar,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"},null,-1),r.createElementVNode("path",{d:"M7 9l5 -5l5 5"},null,-1),r.createElementVNode("path",{d:"M12 4l0 12"},null,-1)])])}const cs=z(Lr,[["render",Ur]]),$r={},Wr={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-x"};function Hr(e,t){return r.openBlock(),r.createElementBlock("svg",Wr,[...t[0]||(t[0]=[r.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),r.createElementVNode("path",{d:"M18 6l-12 12"},null,-1),r.createElementVNode("path",{d:"M6 6l12 12"},null,-1)])])}const us=z($r,[["render",Hr]]),Fr=Object.freeze(Object.defineProperty({__proto__:null,Check:Qn,CodeVariable:es,Copy:ts,DotsVertical:ns,Download:ss,LayoutSidebarLeftCollapse:tr,LayoutSidebarLeftExpand:rr,LayoutSidebarRight:dr,LayoutSidebarRightCollapse:as,LayoutSidebarRightExpand:$t,LockCode:Wt,PlayerPlay:vr,Plus:rs,Restore:os,Schema:is,SchemaOff:ls,TransitionBottom:ds,Upload:cs,X:us},Symbol.toStringTag,{value:"Module"}));function Gr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ut={exports:{}};var jr=ut.exports,hs;function zr(){return hs||(hs=1,(function(e,t){(function(s,a){e.exports=a()})(jr,function(){return(function(){var n={686:(function(o,i,l){l.d(i,{default:function(){return j}});var d=l(279),c=l.n(d),h=l(370),b=l.n(h),m=l(817),D=l.n(m);function g(k){try{return document.execCommand(k)}catch{return!1}}var M=function(N){var v=D()(N);return g("cut"),v},f=M;function w(k){var N=document.documentElement.getAttribute("dir")==="rtl",v=document.createElement("textarea");v.style.fontSize="12pt",v.style.border="0",v.style.padding="0",v.style.margin="0",v.style.position="absolute",v.style[N?"right":"left"]="-9999px";var E=window.pageYOffset||document.documentElement.scrollTop;return v.style.top="".concat(E,"px"),v.setAttribute("readonly",""),v.value=k,v}var A=function(N,v){var E=w(N);v.container.appendChild(E);var I=D()(E);return g("copy"),E.remove(),I},V=function(N){var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body},E="";return typeof N=="string"?E=A(N,v):N instanceof HTMLInputElement&&!["text","search","url","tel","password"].includes(N?.type)?E=A(N.value,v):(E=D()(N),g("copy")),E},H=V;function Oe(k){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Oe=function(v){return typeof v}:Oe=function(v){return v&&typeof Symbol=="function"&&v.constructor===Symbol&&v!==Symbol.prototype?"symbol":typeof v},Oe(k)}var Ee=function(){var N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},v=N.action,E=v===void 0?"copy":v,I=N.container,R=N.target,ue=N.text;if(E!=="copy"&&E!=="cut")throw new Error('Invalid "action" value, use either "copy" or "cut"');if(R!==void 0)if(R&&Oe(R)==="object"&&R.nodeType===1){if(E==="copy"&&R.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if(E==="cut"&&(R.hasAttribute("readonly")||R.hasAttribute("disabled")))throw new Error(`Invalid "target" attribute. You can't cut text from elements with "readonly" or "disabled" attributes`)}else throw new Error('Invalid "target" value, use a valid Element');if(ue)return H(ue,{container:I});if(R)return E==="cut"?f(R):H(R,{container:I})},dt=Ee;function ye(k){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?ye=function(v){return typeof v}:ye=function(v){return v&&typeof Symbol=="function"&&v.constructor===Symbol&&v!==Symbol.prototype?"symbol":typeof v},ye(k)}function O(k,N){if(!(k instanceof N))throw new TypeError("Cannot call a class as a function")}function X(k,N){for(var v=0;v<N.length;v++){var E=N[v];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(k,E.key,E)}}function te(k,N,v){return N&&X(k.prototype,N),v&&X(k,v),k}function Jn(k,N){if(typeof N!="function"&&N!==null)throw new TypeError("Super expression must either be null or a function");k.prototype=Object.create(N&&N.prototype,{constructor:{value:k,writable:!0,configurable:!0}}),N&&ct(k,N)}function ct(k,N){return ct=Object.setPrototypeOf||function(E,I){return E.__proto__=I,E},ct(k,N)}function Vt(k){var N=At();return function(){var E=Ve(k),I;if(N){var R=Ve(this).constructor;I=Reflect.construct(E,arguments,R)}else I=E.apply(this,arguments);return Lt(this,I)}}function Lt(k,N){return N&&(ye(N)==="object"||typeof N=="function")?N:Xn(k)}function Xn(k){if(k===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return k}function At(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function Ve(k){return Ve=Object.setPrototypeOf?Object.getPrototypeOf:function(v){return v.__proto__||Object.getPrototypeOf(v)},Ve(k)}function qe(k,N){var v="data-clipboard-".concat(k);if(N.hasAttribute(v))return N.getAttribute(v)}var U=(function(k){Jn(v,k);var N=Vt(v);function v(E,I){var R;return O(this,v),R=N.call(this),R.resolveOptions(I),R.listenClick(E),R}return te(v,[{key:"resolveOptions",value:function(){var I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.action=typeof I.action=="function"?I.action:this.defaultAction,this.target=typeof I.target=="function"?I.target:this.defaultTarget,this.text=typeof I.text=="function"?I.text:this.defaultText,this.container=ye(I.container)==="object"?I.container:document.body}},{key:"listenClick",value:function(I){var R=this;this.listener=b()(I,"click",function(ue){return R.onClick(ue)})}},{key:"onClick",value:function(I){var R=I.delegateTarget||I.currentTarget,ue=this.action(R)||"copy",Ut=dt({action:ue,container:this.container,target:this.target(R),text:this.text(R)});this.emit(Ut?"success":"error",{action:ue,text:Ut,trigger:R,clearSelection:function(){R&&R.focus(),window.getSelection().removeAllRanges()}})}},{key:"defaultAction",value:function(I){return qe("action",I)}},{key:"defaultTarget",value:function(I){var R=qe("target",I);if(R)return document.querySelector(R)}},{key:"defaultText",value:function(I){return qe("text",I)}},{key:"destroy",value:function(){this.listener.destroy()}}],[{key:"copy",value:function(I){var R=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body};return H(I,R)}},{key:"cut",value:function(I){return f(I)}},{key:"isSupported",value:function(){var I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:["copy","cut"],R=typeof I=="string"?[I]:I,ue=!!document.queryCommandSupported;return R.forEach(function(Ut){ue=ue&&!!document.queryCommandSupported(Ut)}),ue}}]),v})(c()),j=U}),828:(function(o){var i=9;if(typeof Element<"u"&&!Element.prototype.matches){var l=Element.prototype;l.matches=l.matchesSelector||l.mozMatchesSelector||l.msMatchesSelector||l.oMatchesSelector||l.webkitMatchesSelector}function d(c,h){for(;c&&c.nodeType!==i;){if(typeof c.matches=="function"&&c.matches(h))return c;c=c.parentNode}}o.exports=d}),438:(function(o,i,l){var d=l(828);function c(m,D,g,M,f){var w=b.apply(this,arguments);return m.addEventListener(g,w,f),{destroy:function(){m.removeEventListener(g,w,f)}}}function h(m,D,g,M,f){return typeof m.addEventListener=="function"?c.apply(null,arguments):typeof g=="function"?c.bind(null,document).apply(null,arguments):(typeof m=="string"&&(m=document.querySelectorAll(m)),Array.prototype.map.call(m,function(w){return c(w,D,g,M,f)}))}function b(m,D,g,M){return function(f){f.delegateTarget=d(f.target,D),f.delegateTarget&&M.call(m,f)}}o.exports=h}),879:(function(o,i){i.node=function(l){return l!==void 0&&l instanceof HTMLElement&&l.nodeType===1},i.nodeList=function(l){var d=Object.prototype.toString.call(l);return l!==void 0&&(d==="[object NodeList]"||d==="[object HTMLCollection]")&&"length"in l&&(l.length===0||i.node(l[0]))},i.string=function(l){return typeof l=="string"||l instanceof String},i.fn=function(l){var d=Object.prototype.toString.call(l);return d==="[object Function]"}}),370:(function(o,i,l){var d=l(879),c=l(438);function h(g,M,f){if(!g&&!M&&!f)throw new Error("Missing required arguments");if(!d.string(M))throw new TypeError("Second argument must be a String");if(!d.fn(f))throw new TypeError("Third argument must be a Function");if(d.node(g))return b(g,M,f);if(d.nodeList(g))return m(g,M,f);if(d.string(g))return D(g,M,f);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function b(g,M,f){return g.addEventListener(M,f),{destroy:function(){g.removeEventListener(M,f)}}}function m(g,M,f){return Array.prototype.forEach.call(g,function(w){w.addEventListener(M,f)}),{destroy:function(){Array.prototype.forEach.call(g,function(w){w.removeEventListener(M,f)})}}}function D(g,M,f){return c(document.body,g,M,f)}o.exports=h}),817:(function(o){function i(l){var d;if(l.nodeName==="SELECT")l.focus(),d=l.value;else if(l.nodeName==="INPUT"||l.nodeName==="TEXTAREA"){var c=l.hasAttribute("readonly");c||l.setAttribute("readonly",""),l.select(),l.setSelectionRange(0,l.value.length),c||l.removeAttribute("readonly"),d=l.value}else{l.hasAttribute("contenteditable")&&l.focus();var h=window.getSelection(),b=document.createRange();b.selectNodeContents(l),h.removeAllRanges(),h.addRange(b),d=h.toString()}return d}o.exports=i}),279:(function(o){function i(){}i.prototype={on:function(l,d,c){var h=this.e||(this.e={});return(h[l]||(h[l]=[])).push({fn:d,ctx:c}),this},once:function(l,d,c){var h=this;function b(){h.off(l,b),d.apply(c,arguments)}return b._=d,this.on(l,b,c)},emit:function(l){var d=[].slice.call(arguments,1),c=((this.e||(this.e={}))[l]||[]).slice(),h=0,b=c.length;for(h;h<b;h++)c[h].fn.apply(c[h].ctx,d);return this},off:function(l,d){var c=this.e||(this.e={}),h=c[l],b=[];if(h&&d)for(var m=0,D=h.length;m<D;m++)h[m].fn!==d&&h[m].fn._!==d&&b.push(h[m]);return b.length?c[l]=b:delete c[l],this}},o.exports=i,o.exports.TinyEmitter=i})},s={};function a(o){if(s[o])return s[o].exports;var i=s[o]={exports:{}};return n[o](i,i.exports,a),i.exports}return(function(){a.n=function(o){var i=o&&o.__esModule?function(){return o.default}:function(){return o};return a.d(i,{a:i}),i}})(),(function(){a.d=function(o,i){for(var l in i)a.o(i,l)&&!a.o(o,l)&&Object.defineProperty(o,l,{enumerable:!0,get:i[l]})}})(),(function(){a.o=function(o,i){return Object.prototype.hasOwnProperty.call(o,i)}})(),a(686)})().default})})(ut)),ut.exports}var Zr=zr();const qr=Gr(Zr),Jr=e=>({toClipboard(t,n){return new Promise((s,a)=>{const o=document.createElement("button"),i=new qr(o,{text:()=>t,action:()=>"copy",container:n!==void 0?n:document.body});i.on("success",l=>{i.destroy(),s(l)}),i.on("error",l=>{i.destroy(),a(l)}),document.body.appendChild(o),o.click(),document.body.removeChild(o)})}}),Xr={key:0,class:"baklava-button"},fs=r.defineComponent({__name:"CopyToClipboard",props:{text:String},setup(e){const{toClipboard:t}=Jr(),n=e,s=r.toRef(n,"text"),a=r.ref(!1),o=async()=>{try{await t(s.value),a.value=!0,setTimeout(()=>a.value=!1,1500),console.log("Copied to clipboard")}catch(i){console.error(i)}};return(i,l)=>(r.openBlock(),r.createElementBlock("div",null,[a.value?(r.openBlock(),r.createElementBlock("button",Xr,[r.createVNode(r.unref(Qn))])):(r.openBlock(),r.createElementBlock("button",{key:1,onClick:o,class:"baklava-button"},[r.createVNode(r.unref(ts))]))]))}}),Kr={class:"code-editor"},Qr={class:"code-buttons"},eo=r.defineComponent({__name:"CodeEditor",props:r.mergeModels({locked:{type:Boolean},extensions:{}},{modelValue:{required:!0},modelModifiers:{}}),emits:r.mergeModels(["update:locked"],["update:modelValue"]),setup(e,{emit:t}){const n=r.useModel(e,"modelValue"),s=t,a=o=>s("update:locked",o);return(o,i)=>{const l=r.resolveComponent("codemirror");return r.openBlock(),r.createElementBlock("div",Kr,[r.createElementVNode("div",Qr,[e.locked?(r.openBlock(),r.createElementBlock("button",{key:0,class:"baklava-button",title:"The code is locked.",onClick:i[0]||(i[0]=d=>a(!1))},[r.createVNode(r.unref(Wt))])):r.createCommentVNode("",!0),r.createVNode(fs,{text:e.modelValue},null,8,["text"])]),r.createVNode(l,{modelValue:n.value,"onUpdate:modelValue":i[1]||(i[1]=d=>n.value=d),extensions:e.extensions,class:"codemirror",style:{height:"100%"},onKeydown:i[2]||(i[2]=d=>a(!0))},null,8,["modelValue","extensions"])])}}}),to=r.defineComponent({__name:"CodeGraphEditor",props:{viewModel:{}},setup(e){const t=e,n=r.toRef(t,"viewModel"),s=a=>a.events.update.emit(null);return r.onMounted(n.value.onMounted),r.onBeforeUnmount(n.value.onBeforeUnmount),r.watch(n,(a,o)=>{o&&o.onBeforeUnmount(),a&&a.onMounted()}),(a,o)=>(r.openBlock(),r.createBlock(r.unref(S.BaklavaEditor),{viewModel:n.value},{palette:r.withCtx(()=>[r.createVNode(r.unref(_s))]),node:r.withCtx(i=>[r.createVNode(r.unref(ps),r.mergeProps(i,{onUpdate:l=>s(i.node)}),null,16,["onUpdate"])]),sidebar:r.withCtx(i=>[r.createVNode(r.unref(ms),r.normalizeProps(r.guardReactiveProps(i)),{codeEditor:r.withCtx(({node:l})=>[r.renderSlot(a.$slots,"sidebarCodeEditor",{node:l})]),_:3},16)]),_:3},8,["viewModel"]))}}),no={class:"code-graph-info"},so=r.defineComponent({__name:"CodeGraphInfo",props:{viewModel:{}},setup(e){return(t,n)=>(r.openBlock(),r.createElementBlock("div",no,[r.createElementVNode("div",null,"Editor graph: "+r.toDisplayString(e.viewModel.editor.graph.shortId),1),r.createElementVNode("div",null,"Displayed graph: "+r.toDisplayString(e.viewModel.displayedGraph.shortId),1),r.createElementVNode("div",null,"Graphs: "+r.toDisplayString(e.viewModel.editor.graphIds),1),r.createElementVNode("div",null,"Graph templates: "+r.toDisplayString(e.viewModel.editor.graphTemplateIds),1),r.createElementVNode("div",null,"Engine status: "+r.toDisplayString(e.viewModel.engine?.status),1)]))}}),ao=["data-node-type","id"],ro={class:"__title-label",style:{"flex-grow":"1"}},oo={key:0},io={class:"__menu",style:{display:"flex"}},lo={class:"__outputs"},co={key:0},uo=["id","title"],ho={class:"__inputs"},fo={key:0},po=["id","title"],ps=r.defineComponent({__name:"CodeGraphNode",props:{node:{},selected:{type:Boolean,default:!1},dragging:{type:Boolean}},emits:["select","start-drag","update"],setup(e,{emit:t}){const n=S.Components.ContextMenu,s=S.Components.NodeInterface,a=e,o=r.computed(()=>a.node),i=t,{viewModel:l}=S.useViewModel(),{graph:d,switchGraph:c}=S.useGraph(),h=r.ref(null),b=r.ref(!1),m=r.ref(""),D=r.ref(null),g=r.ref(!1);let M=0,f=0;const w=r.ref(!1),A=r.computed(()=>{const U=[{value:"edit",label:"Edit"},{value:"rename",label:"Rename"},{value:"delete",label:"Delete"}];return a.node.type.startsWith(q.GRAPH_NODE_TYPE_PREFIX)&&U.push({value:"editSubgraph",label:"Edit Subgraph"}),U}),V=r.computed(()=>({"--selected":a.selected,"--dragging":a.dragging,"--two-column":!!a.node.twoColumn,"--hidden":o.value.state?.hidden})),H=r.computed(()=>({"--reverse-y":a.node.reverseY??l.value.settings.nodes.reverseY})),Oe=r.computed(()=>({top:`${a.node.position?.y??0}px`,left:`${a.node.position?.x??0}px`,"--width":`${a.node.width??l.value.settings.nodes.defaultWidth}px`})),Ee=r.computed(()=>Object.values(a.node.inputs).filter(U=>!U.hidden)),dt=r.computed(()=>Object.values(a.node.outputs).filter(U=>!U.hidden)),ye=()=>{Jn(),i("select")},O=U=>{a.selected||ye(),i("start-drag",U)},X=()=>{w.value=!0},te=()=>{const U=l.value.displayedGraph.sidebar;U.nodeId=a.node.id,U.visible=!0},Jn=()=>{const U=l.value.displayedGraph.sidebar;U.nodeId=a.node.id},ct=async U=>{switch(U){case"edit":te();break;case"delete":d.value.removeNode(a.node);break;case"rename":m.value=a.node.state.variableName,b.value=!0,await r.nextTick(),D.value?.focus();break;case"editSubgraph":c(a.node.template);break}},Vt=()=>{o.value.state.variableName=m.value,o.value.events.titleChanged.emit(o.value.state.variableName),b.value=!1},Lt=()=>{h.value&&l.value.hooks.renderNode.execute({node:a.node,el:h.value})},Xn=U=>{g.value=!0,M=a.node.width,f=U.clientX,U.preventDefault()},At=U=>{o.value.state&&(o.value.state.integrated=U,i("update"))},Ve=U=>{if(!g.value)return;const j=U.clientX-f,k=M+j/d.value.scaling,N=l.value.settings.nodes.minWidth,v=l.value.settings.nodes.maxWidth;o.value.width=Math.max(N,Math.min(v,k))},qe=()=>{g.value=!1};return r.onMounted(()=>{Lt(),window.addEventListener("mousemove",Ve),window.addEventListener("mouseup",qe)}),r.onUpdated(Lt),r.onBeforeUnmount(()=>{window.removeEventListener("mousemove",Ve),window.removeEventListener("mouseup",qe)}),(U,j)=>(r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass([V.value,"baklava-node"]),"data-node-type":o.value.type,id:o.value.id,style:r.normalizeStyle(Oe.value),ref_key:"el",ref:h,onPointerdown:ye},[r.unref(l).settings.nodes.resizable?(r.openBlock(),r.createElementBlock("div",{key:0,class:"__resize-handle",onMousedown:Xn},null,32)):r.createCommentVNode("",!0),r.createElementVNode("div",{class:"__title",onPointerdown:r.withModifiers(O,["self","stop"]),onContextmenu:r.withModifiers(X,["prevent"])},[o.value.inputs._code?(r.openBlock(),r.createBlock(r.unref(Ht),{key:0,intf:o.value.inputs._code,node:o.value,title:o.value.inputs._code.value,class:"--input","data-interface-type":"node",style:{"flex-grow":"0"}},null,8,["intf","node","title"])):r.createCommentVNode("",!0),b.value?r.withDirectives((r.openBlock(),r.createElementBlock("input",{key:2,ref_key:"renameInputEl",ref:D,"onUpdate:modelValue":j[4]||(j[4]=k=>m.value=k),class:"baklava-input",placeholder:"Variable name",style:{"flex-grow":"1"},type:"text",onBlur:Vt,onKeydown:r.withKeys(Vt,["enter"])},null,544)),[[r.vModelText,m.value]]):(r.openBlock(),r.createElementBlock(r.Fragment,{key:1},[r.createElementVNode("div",ro,[o.value.idx>-1?(r.openBlock(),r.createElementBlock("span",oo,r.toDisplayString(o.value.idx+1)+" > ",1)):r.createCommentVNode("",!0),r.createTextVNode(" "+r.toDisplayString(o.value.state.variableName.length>0?o.value.state.variableName:o.value.title),1)]),r.createElementVNode("div",io,[o.value.isCodeNode?(r.openBlock(),r.createElementBlock(r.Fragment,{key:0},[o.value.state.lockCode?(r.openBlock(),r.createBlock(r.unref(Wt),{key:0,class:"--clickable mx-1",onClick:j[0]||(j[0]=k=>o.value.lockCode=!1)})):r.createCommentVNode("",!0),o.value.hasConnectedOutputNodes?(r.openBlock(),r.createElementBlock(r.Fragment,{key:1},[o.value.state.integrated?(r.openBlock(),r.createBlock(r.unref(es),{key:1,class:"--clickable mx-1",onClick:j[2]||(j[2]=k=>At(!1))})):(r.openBlock(),r.createBlock(r.unref(ds),{key:0,class:"--clickable mx-1",onClick:j[1]||(j[1]=k=>At(!0))}))],64)):r.createCommentVNode("",!0),o.value.isSelected&&!r.unref(l).displayedGraph.sidebar.visible?(r.openBlock(),r.createBlock(r.unref($t),{key:2,class:"--clickable mx-1",onClick:te})):r.createCommentVNode("",!0)],64)):r.createCommentVNode("",!0),r.createVNode(r.unref(ns),{class:"--clickable mx-1",onClick:X}),r.createVNode(r.unref(n),{modelValue:w.value,"onUpdate:modelValue":j[3]||(j[3]=k=>w.value=k),x:0,y:0,items:A.value,onClick:ct},null,8,["modelValue","items"])])],64)),o.value.outputs._code?(r.openBlock(),r.createBlock(r.unref(Ht),{key:3,node:o.value,intf:o.value.outputs._code,class:"--output",title:o.value.outputs._code.value,"data-interface-type":"node"},null,8,["node","intf","title"])):r.createCommentVNode("",!0)],32),r.createElementVNode("div",{class:r.normalizeClass(["__content",H.value]),onKeydown:j[5]||(j[5]=r.withKeys(r.withModifiers(()=>{},["stop"]),["delete"])),onContextmenu:j[6]||(j[6]=r.withModifiers(()=>{},["prevent"]))},[r.createElementVNode("div",lo,[(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(dt.value,k=>(r.openBlock(),r.createElementBlock(r.Fragment,{key:k.id},[o.value.state?.hidden?(r.openBlock(),r.createElementBlock("div",co,[k.port?(r.openBlock(),r.createElementBlock("div",{key:0,id:k.id,title:k.name,class:"baklava-node-interface --output --connected"},[...j[7]||(j[7]=[r.createElementVNode("div",{class:"__port"},null,-1)])],8,uo)):r.createCommentVNode("",!0)])):r.renderSlot(U.$slots,"nodeInterface",{key:1,type:"output",node:o.value,intf:k},()=>[r.createVNode(r.unref(s),{node:o.value,intf:k,title:k.value},null,8,["node","intf","title"])])],64))),128))]),r.createElementVNode("div",ho,[(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(Ee.value,k=>(r.openBlock(),r.createElementBlock(r.Fragment,{key:k.id},[o.value.state?.hidden?(r.openBlock(),r.createElementBlock("div",fo,[k.port?(r.openBlock(),r.createElementBlock("div",{key:0,id:k.id,title:k.name,class:"baklava-node-interface --input --connected"},[...j[8]||(j[8]=[r.createElementVNode("div",{class:"__port"},null,-1)])],8,po)):r.createCommentVNode("",!0)])):r.renderSlot(U.$slots,"nodeInterface",{key:1,node:o.value,intf:k,type:"input"},()=>[r.createVNode(r.unref(s),{node:o.value,intf:k,title:k.value},null,8,["node","intf","title"])])],64))),128))])],34)],46,ao))}}),mo=["id"],_o={class:"align-middle"},Ht=r.defineComponent({__name:"CodeGraphNodeInterface",props:{node:{},intf:{}},setup(e){const t=e,{viewModel:n}=S.useViewModel(),{hoveredOver:s,temporaryConnection:a}=S.useTemporaryConnection(),o=r.ref(null),i=r.computed(()=>t.intf.connectionCount>0),l=r.computed(()=>({"--connected":i.value})),d=()=>{s(t.intf)},c=()=>{s(void 0)},h=()=>{o.value&&n.value.hooks.renderInterface.execute({intf:t.intf,el:o.value})};return r.onMounted(h),r.onUpdated(h),(b,m)=>(r.openBlock(),r.createElementBlock("div",{id:e.intf.id,ref_key:"el",ref:o,class:r.normalizeClass(["baklava-node-interface",l.value])},[e.intf.port?(r.openBlock(),r.createElementBlock("div",{key:0,class:r.normalizeClass([{"--selected":r.unref(a)?.from===e.intf},"__port"]),onPointerover:d,onPointerout:c},null,34)):r.createCommentVNode("",!0),r.createElementVNode("span",_o,[r.renderSlot(b.$slots,"default")])],10,mo))}}),yo=["title"],go={key:0,class:"__label"},Ft=r.defineComponent({__name:"SidebarCheckbox",props:{disabled:{type:Boolean},inversed:{type:Boolean},modelValue:{type:Boolean},name:{}},emits:["update:modelValue"],setup(e,{emit:t}){const n=t;return(s,a)=>(r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass(["baklava-checkbox",{"--checked":e.inversed?!e.modelValue:e.modelValue,"--disabled":e.disabled}]),title:e.name,onClick:a[0]||(a[0]=o=>n("update:modelValue",!e.modelValue))},[a[1]||(a[1]=r.createElementVNode("div",{class:"__checkmark-container"},[r.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18"},[r.createElementVNode("path",{class:"__checkmark",d:"M 6 5 L 6 10 L 16 10",transform:"rotate(-45 10 10)"})])],-1)),e.name?(r.openBlock(),r.createElementBlock("div",go,r.toDisplayString(e.name),1)):r.createCommentVNode("",!0)],10,yo))}}),ko={class:"__header"},bo={class:"__node-name"},wo={class:"__interfaces"},vo={class:"__inputs"},No={style:{display:"flex"}},Co={class:"__outputs"},Mo={key:0,class:"__interface"},So=["placeholder"],Oo={style:{display:"flex"}},ms=r.defineComponent({__name:"CodeGraphSidebar",setup(e){const{viewModel:t}=S.useViewModel(),{graph:n}=S.useGraph(),s=r.ref(null),a=r.toRef(t.value.settings.sidebar,"width"),o=r.computed(()=>t.value.settings.sidebar.resizable);let i=0,l=0;const d=r.computed(()=>{const w=n.value.sidebar.nodeId;return n.value.nodes.find(A=>A.id===w)}),c=r.computed(()=>d.value),h=r.computed(()=>({width:`${a.value}px`})),b=r.computed(()=>c.value?Object.values(c.value.inputs).filter(w=>w.displayInSidebar&&w.component):[]),m=r.computed(()=>c.value?Object.values(c.value.outputs).filter(w=>w.displayInSidebar&&w.component):[]),D=()=>{n.value.sidebar.visible=!1},g=()=>{d.value?.events.update.emit(null)},M=w=>{i=a.value,l=w.clientX,window.addEventListener("mousemove",f),window.addEventListener("mouseup",()=>{window.removeEventListener("mousemove",f)},{once:!0})},f=w=>{const A=s.value?.parentElement?.getBoundingClientRect().width??500,V=w.clientX-l;let H=i-V;H<300?H=300:H>.9*A&&(H=.9*A),a.value=H};return(w,A)=>(r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass([{"--open":r.unref(n).sidebar.visible},"baklava-sidebar"]),style:r.normalizeStyle(h.value),ref_key:"el",ref:s},[o.value?(r.openBlock(),r.createElementBlock("div",{key:0,class:"__resizer",onMousedown:M},null,32)):r.createCommentVNode("",!0),d.value?(r.openBlock(),r.createElementBlock(r.Fragment,{key:1},[r.createElementVNode("div",ko,[r.createElementVNode("button",{tabindex:"-1",class:"__close",onClick:D},"×"),r.createElementVNode("div",bo,[r.createElementVNode("b",null,r.toDisplayString(d.value.title),1)])]),r.createElementVNode("div",wo,[r.createElementVNode("div",vo,[(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(b.value,V=>(r.openBlock(),r.createElementBlock("div",{key:V.id,class:"__interface"},[r.createElementVNode("div",No,[r.createVNode(Ft,{modelValue:V.hidden,"onUpdate:modelValue":[H=>V.hidden=H,A[0]||(A[0]=()=>d.value?.events.update.emit(null))],disabled:!V.optional,inversed:"",style:{"padding-right":"8px"}},null,8,["modelValue","onUpdate:modelValue","disabled"]),(r.openBlock(),r.createBlock(r.resolveDynamicComponent(V.component),{modelValue:V.value,"onUpdate:modelValue":H=>V.value=H,node:d.value,intf:V,style:{width:"100%"}},null,8,["modelValue","onUpdate:modelValue","node","intf"]))])]))),128))]),r.createElementVNode("div",Co,[c.value&&c.value.state?(r.openBlock(),r.createElementBlock("div",Mo,[A[3]||(A[3]=r.createElementVNode("label",null,"Variable name",-1)),r.withDirectives(r.createElementVNode("input",{"onUpdate:modelValue":A[1]||(A[1]=V=>c.value.state.variableName=V),placeholder:c.value.variableName,type:"text",class:"baklava-input",title:"Variable name",onBlur:g,onKeydown:r.withKeys(g,["enter"])},null,40,So),[[r.vModelText,c.value.state.variableName]])])):r.createCommentVNode("",!0),(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(m.value,V=>(r.openBlock(),r.createElementBlock("div",{key:V.id,class:"__interface"},[r.createElementVNode("div",Oo,[r.createVNode(Ft,{modelValue:V.hidden,"onUpdate:modelValue":[H=>V.hidden=H,A[2]||(A[2]=()=>d.value?.events.update.emit(null))],disabled:!V.optional,inversed:"",style:{"padding-right":"8px"}},null,8,["modelValue","onUpdate:modelValue","disabled"]),(r.openBlock(),r.createBlock(r.resolveDynamicComponent(V.component),{modelValue:V.value,"onUpdate:modelValue":H=>V.value=H,node:d.value,intf:V,style:{width:"100%"}},null,8,["modelValue","onUpdate:modelValue","node","intf"]))])]))),128))])]),r.renderSlot(w.$slots,"codeEditor",{node:d.value})],64)):r.createCommentVNode("",!0)],6))}});function Eo(e,t){return Object.fromEntries(Object.entries(e).filter(t))}function To(e,t){return Object.fromEntries(Object.entries(e).map(([n,s])=>[n,t(s)]))}const Io={class:"baklava-node --palette",style:{"margin-top":"-20px","margin-bottom":"20px"}},Do={key:0,style:{display:"flex","justify-content":"space-between"}},xo=["onClick"],Yo={key:0,style:{margin:"auto 0","font-size":"12px"}},_s=r.defineComponent({__name:"CodeNodePalette",setup(e){const t=S.Components.PaletteEntry,{viewModel:n}=S.useViewModel(),{x:s,y:a}=Pa.usePointer(),{transform:o}=S.useTransform(),i=S.useNodeCategories(n),l=r.inject("editorEl"),d=r.ref(""),c=r.ref(null),h=()=>d.value?i.value.filter(g=>g.name.toLowerCase().includes(d.value.toLowerCase())||Object.values(g.nodeTypes).some(M=>M.title.toLowerCase().includes(d.value.toLowerCase()))):i.value,b=g=>d.value?Eo(g,M=>{const f=M[1];return f.category.includes(d.value.toLowerCase())||f.title?.toLowerCase().includes(d.value.toLowerCase())}):g,m=r.computed(()=>{if(!c.value||!l?.value)return{};const{left:g,top:M}=l.value.getBoundingClientRect();return{top:`${a.value-M}px`,left:`${s.value-g}px`}}),D=(g,M)=>{c.value={type:g,nodeInformation:M};const f=()=>{const w=r.reactive(new M.type);n.value.displayedGraph.addNode(w);const A=l.value.getBoundingClientRect(),[V,H]=o(s.value-A.left,a.value-A.top);w.position.x=V,w.position.y=H,c.value=null,document.removeEventListener("pointerup",f)};document.addEventListener("pointerup",f)};return(g,M)=>(r.openBlock(),r.createElementBlock(r.Fragment,null,[r.createElementVNode("div",{class:r.normalizeClass([{"--open":r.unref(n).settings.palette.enabled},"baklava-node-palette"]),onContextmenu:M[1]||(M[1]=r.withModifiers(()=>{},["stop","prevent"]))},[r.createElementVNode("div",Io,[r.withDirectives(r.createElementVNode("input",{"onUpdate:modelValue":M[0]||(M[0]=f=>d.value=f),type:"text",class:"baklava-input",title:"Filter nodes",onKeyup:h},null,544),[[r.vModelText,d.value]])]),(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(h(),f=>(r.openBlock(),r.createElementBlock("section",{key:f.name},[f.name!=="default"?(r.openBlock(),r.createElementBlock("h3",Do,[r.createElementVNode("div",{onClick:w=>d.value=f.name,style:{cursor:"pointer"}},r.toDisplayString(f.name),9,xo),Object.keys(b(f.nodeTypes)).length<Object.values(f.nodeTypes).length?(r.openBlock(),r.createElementBlock("div",Yo," ( "+r.toDisplayString(Object.keys(b(f.nodeTypes)).length)+" / "+r.toDisplayString(Object.values(f.nodeTypes).length)+" ) ",1)):r.createCommentVNode("",!0)])):r.createCommentVNode("",!0),(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(b(f.nodeTypes),(w,A)=>(r.openBlock(),r.createBlock(r.unref(t),{key:A,title:w.title,type:A,onPointerdown:V=>D(A,w)},null,8,["title","type","onPointerdown"]))),128))]))),128))],34),r.createVNode(r.Transition,{name:"fade"},{default:r.withCtx(()=>[c.value?(r.openBlock(),r.createElementBlock("div",{key:0,class:"baklava-dragged-node",style:r.normalizeStyle(m.value)},[r.createVNode(r.unref(t),{type:c.value.type,title:c.value.nodeInformation.title},null,8,["type","title"])],4)):r.createCommentVNode("",!0)]),_:1})],64))}}),Ro={},Po={class:"prependIcon"},Bo={class:"appendIcon"};function Vo(e,t){const n=r.resolveComponent("router-link");return r.openBlock(),r.createBlock(n,{class:"navItem"},{default:r.withCtx(()=>[r.createElementVNode("span",Po,[r.renderSlot(e.$slots,"prependIcon")]),r.renderSlot(e.$slots,"default"),r.createElementVNode("span",Bo,[r.renderSlot(e.$slots,"appendIcon")])]),_:3})}const Gt=z(Ro,[["render",Vo]]),Lo={class:"navbar"},Ao=["onClick"],Uo=r.defineComponent({__name:"NavBar",props:{viewModel:{},editorStates:{},routes:{}},emits:["click:remove"],setup(e,{emit:t}){const n=t,s=a=>{n("click:remove",a)};return(a,o)=>(r.openBlock(),r.createElementBlock("nav",Lo,[r.renderSlot(a.$slots,"prepend"),(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(e.editorStates,i=>(r.openBlock(),r.createBlock(Gt,{key:i.graph.id,class:r.normalizeClass({active:i.graph.id===e.viewModel.displayedGraph.id}),to:{name:e.routes?.edit??"edit",params:{editorId:i.graph.id}}},{appendIcon:r.withCtx(()=>[r.createElementVNode("button",{class:"remove",onClick:r.withModifiers(l=>s(i.graph.id),["prevent"])},[r.createVNode(r.unref(us))],8,Ao)]),default:r.withCtx(()=>[r.createTextVNode(r.toDisplayString(i.graph.id.slice(0,6))+" ",1)]),_:2},1032,["class","to"]))),128)),r.renderSlot(a.$slots,"append",{},()=>[r.createVNode(Gt,{to:{name:e.routes?.new??"new"},class:"navItem"},{default:r.withCtx(()=>[r.createVNode(r.unref(rs),{class:"plus"})]),_:1},8,["to"])])]))}}),$o=r.defineComponent({props:{intf:{type:Object,required:!0},modelValue:{type:String,required:!0}},emits:["update:modelValue"],setup(e,{emit:t}){return{v:r.computed({get:()=>e.modelValue,set:s=>{t("update:modelValue",s)}})}}}),Wo={style:{position:"relative"}},Ho={style:{"font-size":"12px",padding:"0 6px",position:"absolute",top:"-8px","background-color":"var(--baklava-node-color-background)"}},Fo=["placeholder","title"];function Go(e,t,n,s,a,o){return r.openBlock(),r.createElementBlock("div",Wo,[r.createElementVNode("label",Ho,r.toDisplayString(e.intf.name),1),r.withDirectives(r.createElementVNode("input",{"onUpdate:modelValue":t[0]||(t[0]=i=>e.v=i),type:"text",class:"baklava-input",placeholder:e.intf.name,title:e.intf.name},null,8,Fo),[[r.vModelText,e.v]])])}const jt=z($o,[["render",Go]]),jo=Object.freeze(Object.defineProperty({__proto__:null,CodeEditor:eo,CodeGraphEditor:to,CodeGraphInfo:so,CodeGraphNode:ps,CodeGraphNodeInterface:Ht,CodeGraphSidebar:ms,CodeNodePalette:_s,CopyToClipboard:fs,NavBar:Uo,NavItem:Gt,SidebarCheckbox:Ft,TextInputInterface:jt},Symbol.toStringTag,{value:"Module"}));Le.escape=e=>e;class zt extends q.AbstractNode{codeTemplate;isCodeNode=!0;mask=null;name="";state;_variableName="";inputs={};outputs={};constructor(){super(),this.initializeIo(),this.twoColumn=!0,this.state=r.reactive({codeTemplate:"",hidden:!1,integrated:!1,lockCode:!1,modules:[],props:null,script:"",variableName:""}),this.codeTemplate=function(){return`${this.name}(${ys(this.codeNodeInputs).join(", ")})`}}get code(){return this.graph.code}get codeNodeInputs(){return Object.fromEntries(Object.entries(this.inputs).filter(t=>t[1].isCodeNode&&t[1].type!="node"))}get codeNodeOutputs(){return Object.fromEntries(Object.entries(this.outputs).filter(t=>t[1].isCodeNode&&t[1].type!="node"))}get graph(){return super.graph}get hasConnectedOutputNodes(){return this.getConnectedNodes("outputs").length>0}get idx(){return this.graph.nodes.filter(t=>!t.state.integrated).indexOf(this)??-1}get idxByType(){return this.graph.getNodesByType(this.type).indexOf(this)??-1}get idxByVariableNames(){return this.graph.getNodesByVariableName(this.state.variableName??this._variableName).filter(t=>!t.state.integrated).indexOf(this)??-1}get isSelected(){return this.graph.selectedNodeIds.includes(this.id)}get lockCode(){return this.state.lockCode}set lockCode(t){this.state.lockCode=t,this.events.update.emit(null)}get optionalInputs(){return Object.fromEntries(Object.entries(this.codeNodeInputs).filter(t=>t[1].optional))}get requiredInputs(){return Object.fromEntries(Object.entries(this.codeNodeInputs).filter(t=>!t[1].optional))}get script(){return this.outputs._code?.value??""}set script(t){this.outputs._code&&(this.outputs._code.value=t),this.events.update.emit(null)}get shortId(){return this.id.slice(0,6)}get shownInSidebar(){return this.graph.sidebar.nodeId===this.id}get subgraph(){}get variableName(){return(this.state.variableName?this.state.variableName:this._variableName)+(this.idxByVariableNames+1)}getConnectedNodeByInterface(t,n){const s=this.getConnectedNodesByInterface(t,n);return s.length>0?s[0]:null}getConnectedNodes(t){let n=[];if(t!=="inputs"){const s=this.graph.connections.filter(a=>a.from.name!=="_code").filter(a=>a.from.nodeId===this.id).map(a=>a.to.nodeId);s&&(n=n.concat(s))}if(t!=="outputs"){const s=this.graph.connections.filter(a=>a.from.name!=="_code").filter(a=>a.to.nodeId===this.id).map(a=>a.from.nodeId);s&&(n=n.concat(s))}return!n||n.length==0?[]:n.map(s=>this.graph.findNodeById(s))}getConnectedNodesByInterface(t,n){let s=[];if(n!=="outputs"&&this.inputs[t]){const a=this.graph.connections.filter(o=>o.to.id===this.inputs[t]?.id||o.from.id===this.inputs[t]?.id).map(o=>o.from.nodeId);a&&(s=s.concat(a))}if(n!=="inputs"&&this.outputs[t]){const a=this.graph.connections.filter(o=>o.from.id===this.outputs[t]?.id||o.from.id===this.outputs[t]?.id).map(o=>o.to.nodeId);a&&(s=s.concat(a))}return!s||s.length==0?[]:s.map(a=>this.graph.findNodeById(a))}remove(){this.graph?.removeNode(this)}renderCode(t){return Le.render(this.state.codeTemplate,t)}updateCodeTemplate(){this.state.codeTemplate=this.codeTemplate.call(this)}updateModules(t){if(t)this.state.modules=t;else if(this.type.includes(".")){const n=this.type.split(".");this.state.modules.push(n.slice(0,n.length-1).join("."))}}updateOutputNames(){Object.values(this.codeNodeOutputs).forEach(t=>{t.name=this.state.integrated?"":this.variableName+t.suffix})}updateOutputValues(t){Object.keys(this.outputs).forEach(n=>{n!=="_code"&&(t[n]=this.state.integrated?t._code:this.outputs[n].name)})}updateProps(t){this.state.props=t}updateInputValues(t){const n=Object.keys(this.inputs);Object.keys(t).forEach(s=>{!n.includes(s)||!this.inputs[s]||(this.inputs[s].value=t[s],this.inputs[s].setHidden(!1))})}}class ht extends zt{calculate=(t,n)=>{const s={};return this.lockCode||(s._code=this.renderCode({inputs:t,...n})),this.updateOutputValues(s),s};executeFactory(t,n){Object.keys(n||{}).forEach(s=>{const a=n[s]();t==="input"?this.addInput(s,a):this.addOutput(s,a)})}load(t){super.load(t),Zt(this.graph,t),this.afterLoaded()}save(){const t=super.save();return gs(this.graph,t),t}}const ys=(e,t=!0)=>{const n=[],s=Object.keys(e);return s.forEach(a=>{if(e[a]?.hidden)return;const i=t&&n.length<s.indexOf(a)?`${a}=`:"";n.push(`${i}{{ inputs.${a} }}`)}),n},Zt=(e,t)=>{if(!e)return;const n=e.findNodeById(t.id);if(!n||n.subgraph)return;const s=n;s.state&&(s.state.integrated=t.integrated,t.props&&(s.state.props=t.props),t.variableName&&(s.state.variableName=t.variableName)),Object.entries(t.inputs).forEach(([a,o])=>{a!=="_code"&&s.inputs[a]&&(s.inputs[a].hidden=o.hidden,o.optional&&(s.inputs[a].state.optional=o.optional))}),Object.entries(t.outputs).forEach(([a,o])=>{a!=="_code"&&s.outputs[a]&&(s.outputs[a].hidden=o.hidden,o.optional&&(s.outputs[a].state.optional=o.optional))})},gs=(e,t)=>{if(!e)return;const n=e.findNodeById(t.id);if(!n||n.subgraph)return;const s=n;s.state&&(t.integrated=s.state.integrated,s.state.props&&(t.props=s.state.props),s.state.variableName&&(t.variableName=s.state.variableName)),Object.entries(t.inputs).forEach(([a,o])=>{if(a!=="_code"&&s.inputs[a]){const i=s.inputs[a];o.hidden=i.hidden,i.state?.optional&&(o.optional=i.state.optional),i.component?.__name&&(o.component=i.component.__name)}}),Object.entries(t.outputs).forEach(([a,o])=>{a!=="_code"&&s.outputs[a]&&(o.hidden=s.outputs[a].hidden)})},ks=(e,t)=>{switch(e){case"CheckBoxInterface":return new ws(t.id,t.value);case"IntegerInterface":return new tn(t.id,t.value,t.min,t.max);case"NumberInterface":return new Ns(t.id,t.value,t.min,t.max);case"SelectInterface":return new Cs(t.id,t.value,t.items);default:return new sn(t.id,t.value)}},zo=["title"],ft=r.defineComponent({__name:"CodeNodeInterface",props:{intf:{}},setup(e){return(t,n)=>(r.openBlock(),r.createElementBlock("div",{title:e.intf.value},r.toDisplayString(e.intf.name),9,zo))}});class Q extends q.NodeInterface{isCodeNode=!0;code;state;type=null;constructor(t,n){super(t,n),this.setComponent(r.markRaw(ft)),this.state=r.reactive({optional:!1})}get optional(){return this.state.optional}get shortId(){return this.id.slice(0,6)}getValue=()=>`${this.value??"None"}`;setOptional(t){return this.state.optional=t,this.setHidden(t),this}}class Ae extends Q{constructor(t="",n){super(t,n),this.setComponent(r.markRaw(ft)),this.use(S.displayInSidebar,!0)}get value(){return super.value}set value(t){super.value=t,this.name!=="_code"&&this.setHidden(!1)}}const qt=new G.NodeInterfaceType("boolean"),bs=new G.NodeInterfaceType("dict"),Jt=new G.NodeInterfaceType("list"),se=new G.NodeInterfaceType("node"),Xt=new G.NodeInterfaceType("number"),Kt=new G.NodeInterfaceType("string"),Qt=new G.NodeInterfaceType("tuple"),Zo=e=>{new G.BaklavaInterfaceTypes(e.editor,{viewPlugin:e}).addTypes(qt,bs,Jt,se,Xt,Kt,Qt)};class ws extends Ae{constructor(t,n){super(t,n),this.setComponent(r.markRaw(S.CheckboxInterfaceComponent)),this.use(G.setType,qt)}getValue=()=>this.value?"True":"False"}class vs extends Q{isCodeNodeOutput=!0;suffix="";constructor(t="",n=""){super(t,""),this.suffix=n,this.setComponent(r.markRaw(ft))}get codeValue(){return this.node?.outputs._code.value??""}get node(){const{graph:t}=S.useGraph();return t.value.findNodeById(this.nodeId)}}class en extends Ae{min;max;constructor(t,n,s,a){super(t,n),this.min=s,this.max=a,this.use(G.setType,Xt)}validate(t){return(this.min===void 0||t>=this.min)&&(this.max===void 0||t<=this.max)}}class tn extends en{component=r.markRaw(S.IntegerInterfaceComponent);validate(t){return Number.isInteger(t)&&super.validate(t)}}class qo extends Ae{constructor(t="",n=""){super(t,n),this.setComponent(r.markRaw(S.TextInputInterfaceComponent)),this.use(G.setType,Jt)}getValue=()=>`[${this.value}]`}class Ns extends en{component=r.markRaw(S.NumberInterfaceComponent)}class nn extends Ae{constructor(t,n){super(t,n),this.use(G.setType,Kt)}getValue=()=>`"${this.value}"`}class Cs extends nn{component=r.markRaw(S.SelectInterfaceComponent);items;constructor(t,n,s){super(t,n),this.items=s}}class Jo extends en{component=r.markRaw(S.SliderInterfaceComponent);min;max;constructor(t,n,s,a){super(t,n,s,a),this.min=s,this.max=a}getValue=()=>`${Math.round(this.value*1e3)/1e3}`}class sn extends nn{component=r.markRaw(jt)}class Xo extends nn{component=r.markRaw(S.TextareaInputInterfaceComponent)}class Ko extends Ae{constructor(t="",n=""){super(t,n),this.setComponent(r.markRaw(S.TextInputInterfaceComponent)),this.use(G.setType,Qt)}getValue=()=>`(${this.value})`}function Qo(e){return class extends ht{type=e.type;inputs={};outputs={};constructor(){super(),this._title=e.title??e.type,this.executeFactory("input",e.inputs),this.executeFactory("output",e.outputs),e.calculate&&(this.calculate=(t,n)=>e.calculate.call(this,t,n)),e.onCreate?.call(this),this.name=e.name??e.type,this.updateModules(e.modules),e.codeTemplate&&(this.codeTemplate=e.codeTemplate),e.variableName!=null&&(this._variableName=e.variableName),this.addInput("_code",new Q("_code",[]).use(G.setType,se).use(he.allowMultipleConnections).setHidden(!0)),this.addOutput("_code",new Q("_code",[]).use(G.setType,se).use(he.allowMultipleConnections).setHidden(!0))}afterGraphLoaded(){e.afterGraphLoaded?.call(this)}afterLoaded(){e.afterLoaded?.call(this)}onPlaced(){e.onPlaced?.call(this)}onConnected(){e.onConnected?.call(this)}onDestroy(){e.onDestroy?.call(this)}onGraphUpdate(){e.onGraphUpdate?.call(this)}onUnconnected(){e.onUnconnected?.call(this)}update(){e.update?.call(this)}}}class Ms extends ht{}function ei(e){return class extends Ms{type=e.type;inputs={};outputs={};preventUpdate=!1;staticInputKeys=Object.keys(e.inputs??{});staticOutputKeys=Object.keys(e.outputs??{});constructor(){super(),this._title=e.title??e.type,this.executeFactory("input",e.inputs),this.executeFactory("output",e.outputs),e.calculate&&(this.calculate=(t,n)=>e.calculate?.call(this,t,n)),e.onCreate?.call(this),this.name=e.name??e.type,this.updateModules(e.modules),e.codeTemplate&&(this.codeTemplate=e.codeTemplate),e.variableName&&(this._variableName=e.variableName),this.addInput("_code",new Q("_code",[]).use(G.setType,se).use(he.allowMultipleConnections).setHidden(!0)),this.addOutput("_code",new Q("_code",[]).use(G.setType,se).use(he.allowMultipleConnections).setHidden(!0)),this.staticInputKeys.push("_code"),this.staticOutputKeys.push("_code")}afterGraphLoaded(){e.afterGraphLoaded?.call(this)}afterLoaded(){e.afterLoaded?.call(this)}onPlaced(){this.events.update.subscribe(this,t=>{t&&(t.type==="input"&&this.staticInputKeys.includes(t.name)||t.type==="output"&&this.staticOutputKeys.includes(t.name))&&this.onUpdate()}),this.onUpdate(),e.onPlaced?.call(this)}onConnected(){e.onConnected?.call(this)}onDestroy(){e.onDestroy?.call(this)}onGraphUpdate(){e.onGraphUpdate?.call(this)}onUnconnected(){e.onUnconnected?.call(this)}update(){e.update?.call(this)}load(t){this.preventUpdate=!0,this.hooks.beforeLoad.execute(t),this.id=t.id,this.title=t.title;for(const n of this.staticInputKeys)this.inputs[n].load(t.inputs[n]),this.inputs[n].nodeId=this.id,n!=="_code"&&(this.inputs[n].hidden=t.inputs[n].hidden);for(const n of this.staticOutputKeys)this.outputs[n].load(t.outputs[n]),this.outputs[n].nodeId=this.id,n!=="_code"&&(this.outputs[n].hidden=t.outputs[n].hidden);this.preventUpdate=!1,this.onUpdate(),this.preventUpdate=!0;for(const n of Object.keys(t.inputs))if(!(this.staticInputKeys.includes(n)||!t.inputs[n])){if(!this.inputs[n]){const s=t.inputs[n],a=s.value;let o;s.component?o=ks(s.component,{...s,id:n}):typeof a=="number"?o=new tn(n,a):o=new sn(n,JSON.stringify(a)),o.use(S.displayInSidebar,!0),o.setOptional(s.optional??!1),o.setHidden(s.hidden??!1),this.addInput(n,o)}this.inputs[n]&&(this.inputs[n].load(t.inputs[n]),this.inputs[n].nodeId=this.id)}for(const n of Object.keys(t.outputs))if(!(this.staticOutputKeys.includes(n)||!t.outputs[n])){if(!this.outputs[n]){const s=new vs(n);this.addOutput(n,s)}this.outputs[n]&&(this.outputs[n].load(t.outputs[n]),this.outputs[n].nodeId=this.id)}Zt(this.graph,t),this.preventUpdate=!1,this.events.loaded.emit(this)}onUpdate(){if(!e.onUpdate||this.preventUpdate)return;this.graph&&this.graph.activeTransactions++;const t=this.getStaticValues(this.staticInputKeys,this.inputs),n=this.getStaticValues(this.staticOutputKeys,this.outputs),s=e.onUpdate.call(this,t,n);this.updateInterfaces("input",s.inputs??{},s.forceUpdateInputs??[]),this.updateInterfaces("output",s.outputs??{},s.forceUpdateOutputs??[]),this.graph&&this.graph.activeTransactions--}getStaticValues(t,n){const s={};for(const a of t)s[a]=n[a].value;return s}updateInputInterfaces(t={},n=[]){this.updateInterfaces("input",t,n)}updateInterfaces(t,n={},s=[]){const a=t==="input"?this.staticInputKeys:this.staticOutputKeys,o=t==="input"?this.inputs:this.outputs;for(const i of Object.keys(o))a.includes(i)||n[i]&&!s.includes(i)||(t==="input"?this.removeInput(i):this.removeOutput(i));for(const i of Object.keys(n)){if(o[i])continue;const l=n[i]();t==="input"?this.addInput(i,l):this.addOutput(i,l)}}updateProps(t){this.state.props=t,this.onUpdate()}}}Le.escape=e=>e;class pt{_id;_state;viewModel;constructor(){this._id=xe.v4(),this._state=r.reactive({lockCode:!1,modules:{},script:"",template:""})}get engine(){return this.viewModel?.engine}get graph(){return this.viewModel?.editor.graph}get id(){return this._id}get lockCode(){return this.state.lockCode}set lockCode(t){this.state.lockCode=t,this.engine?.runOnce(null)}get modules(){const t=[];return this.graph?.codeNodes.filter(n=>n.state.modules?.length>0).forEach(n=>t.push(...n.state.modules)),t?(t.sort(),Array.from(new Set(t.map(n=>this.state.modules[n])))):[]}get script(){return this.state.script}set script(t){this.state.script=t,this.engine?.runOnce(null)}get shortId(){return this.id.slice(0,6)}get state(){return this._state}clear(){this.state.script=""}async loadTemplate(t){t.then(n=>{this._state.template=n.default??""})}registerViewModel(t){this.viewModel=t}renderCode(t){this.state.script=Le.render(this.state.template||"",t??{})}}class ti extends pt{constructor(){super(),this.loadTemplate(Promise.resolve().then(()=>pu))}}class ni extends pt{constructor(){super(),this.loadTemplate(Promise.resolve().then(()=>mu))}}const si=e=>{e.allowMultipleConnections=!0};class Ss extends he.BaseEngine{order=new Map;constructor(t){super(t)}start(){super.start(),this.recalculateOrder=!0,this.calculateWithoutData()}async runGraph(t,n,s){this.order.has(t.id)||this.order.set(t.id,he.sortTopologically(t));const{calculationOrder:a,connectionsFromNode:o}=this.order.get(t.id),i=new Map;for(const l of a){const d={};Object.entries(l.inputs).forEach(([h,b])=>{d[h]=this.getInterfaceValue(n,b.id)}),l.isCodeNode&&(l.updateCodeTemplate(),l.updateOutputNames()),this.events.beforeNodeCalculation.emit({inputValues:d,node:l});let c;if(l.calculate){if(c=await l.calculate(d,{globalValues:s,engine:this}),o.has(l))for(const[h,b]of Object.entries(c))this.hooks.transferData.execute(c[h],b),o.get(l).forEach(m=>n.set(m.to.id,b))}else{c={};for(const[h,b]of Object.entries(l.outputs))c[h]=this.getInterfaceValue(n,b.id)}this.events.afterNodeCalculation.emit({outputValues:c,node:l}),i.set(l.id,new Map(Object.entries(c))),o.has(l)&&o.get(l).forEach(h=>{const b=Object.entries(l.outputs).find(([,D])=>D.id===h.from.id)?.[0];if(!b)throw new Error(`Could not find key for interface ${h.from.id}
2
2
  This is likely an internal issue. Please report it on GitHub.`);const m=this.hooks.transferData.execute(c[b],h);b!=="_code"&&(h.to.allowMultipleConnections?n.has(h.to.id)?n.get(h.to.id).push(m):n.set(h.to.id,[m]):n.set(h.to.id,m))})}return i}async execute(t){this.recalculateOrder&&(this.order.clear(),this.recalculateOrder=!1);const n=this.getInputValues(this.editor.graph);return await this.runGraph(this.editor.graph,n,t)}getInputValues(t){const n=new Map;for(const s of t.nodes)Object.values(s.inputs).forEach(a=>{a.connectionCount===0&&n.set(a.id,a.getValue?a.getValue():a.value)}),s.calculate||Object.values(s.outputs).forEach(a=>{n.set(a.id,a.getValue?a.getValue():a.value)});return n}onChange(t){this.recalculateOrder=t||this.recalculateOrder,this.calculateWithoutData()}getInterfaceValue(t,n){if(!t.has(n))throw new Error(`Could not find value for interface ${n}
3
3
  This is likely an internal issue. Please report it on GitHub.`);return t.get(n)}}var Os;function _(){return Os.apply(null,arguments)}function ai(e){Os=e}function ie(e){return e instanceof Array||Object.prototype.toString.call(e)==="[object Array]"}function Ye(e){return e!=null&&Object.prototype.toString.call(e)==="[object Object]"}function P(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function an(e){if(Object.getOwnPropertyNames)return Object.getOwnPropertyNames(e).length===0;var t;for(t in e)if(P(e,t))return!1;return!0}function ee(e){return e===void 0}function ge(e){return typeof e=="number"||Object.prototype.toString.call(e)==="[object Number]"}function Je(e){return e instanceof Date||Object.prototype.toString.call(e)==="[object Date]"}function Es(e,t){var n=[],s,a=e.length;for(s=0;s<a;++s)n.push(t(e[s],s));return n}function Te(e,t){for(var n in t)P(t,n)&&(e[n]=t[n]);return P(t,"toString")&&(e.toString=t.toString),P(t,"valueOf")&&(e.valueOf=t.valueOf),e}function fe(e,t,n,s){return ta(e,t,n,s,!0).utc()}function ri(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidEra:null,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1,parsedDateParts:[],era:null,meridiem:null,rfc2822:!1,weekdayMismatch:!1}}function T(e){return e._pf==null&&(e._pf=ri()),e._pf}var rn;Array.prototype.some?rn=Array.prototype.some:rn=function(e){var t=Object(this),n=t.length>>>0,s;for(s=0;s<n;s++)if(s in t&&e.call(this,t[s],s,t))return!0;return!1};function on(e){var t=null,n=!1,s=e._d&&!isNaN(e._d.getTime());if(s&&(t=T(e),n=rn.call(t.parsedDateParts,function(a){return a!=null}),s=t.overflow<0&&!t.empty&&!t.invalidEra&&!t.invalidMonth&&!t.invalidWeekday&&!t.weekdayMismatch&&!t.nullInput&&!t.invalidFormat&&!t.userInvalidated&&(!t.meridiem||t.meridiem&&n),e._strict&&(s=s&&t.charsLeftOver===0&&t.unusedTokens.length===0&&t.bigHour===void 0)),Object.isFrozen==null||!Object.isFrozen(e))e._isValid=s;else return s;return e._isValid}function mt(e){var t=fe(NaN);return e!=null?Te(T(t),e):T(t).userInvalidated=!0,t}var Ts=_.momentProperties=[],ln=!1;function dn(e,t){var n,s,a,o=Ts.length;if(ee(t._isAMomentObject)||(e._isAMomentObject=t._isAMomentObject),ee(t._i)||(e._i=t._i),ee(t._f)||(e._f=t._f),ee(t._l)||(e._l=t._l),ee(t._strict)||(e._strict=t._strict),ee(t._tzm)||(e._tzm=t._tzm),ee(t._isUTC)||(e._isUTC=t._isUTC),ee(t._offset)||(e._offset=t._offset),ee(t._pf)||(e._pf=T(t)),ee(t._locale)||(e._locale=t._locale),o>0)for(n=0;n<o;n++)s=Ts[n],a=t[s],ee(a)||(e[s]=a);return e}function Xe(e){dn(this,e),this._d=new Date(e._d!=null?e._d.getTime():NaN),this.isValid()||(this._d=new Date(NaN)),ln===!1&&(ln=!0,_.updateOffset(this),ln=!1)}function le(e){return e instanceof Xe||e!=null&&e._isAMomentObject!=null}function Is(e){_.suppressDeprecationWarnings===!1&&typeof console<"u"&&console.warn&&console.warn("Deprecation warning: "+e)}function ae(e,t){var n=!0;return Te(function(){if(_.deprecationHandler!=null&&_.deprecationHandler(null,e),n){var s=[],a,o,i,l=arguments.length;for(o=0;o<l;o++){if(a="",typeof arguments[o]=="object"){a+=`
4
4
  [`+o+"] ";for(i in arguments[0])P(arguments[0],i)&&(a+=i+": "+arguments[0][i]+", ");a=a.slice(0,-2)}else a=arguments[o];s.push(a)}Is(e+`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babsey/code-graph",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "author": "babsey <spreizer@web.de>",
5
5
  "license": "MIT",
6
6
  "type": "module",