@babsey/code-graph 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/code-graph.css +1 -1
- package/dist/code-graph.js +1563 -824
- package/dist/code-graph.umd.cjs +16 -4
- package/dist/javascript-DK1c6Ap1.js +10 -0
- package/dist/python-CKuCd7tg.js +10 -0
- package/package.json +3 -3
package/dist/code-graph.umd.cjs
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
(function(r,G){typeof exports=="object"&&typeof module<"u"?G(exports,require("mustache"),require("vue"),require("uuid"),require("@baklavajs/core"),require("@baklavajs/interface-types"),require("@baklavajs/engine"),require("@baklavajs/renderer-vue"),require("toposort"),require("@baklavajs/events"),require("@vueuse/core")):typeof define=="function"&&define.amd?define(["exports","mustache","vue","uuid","@baklavajs/core","@baklavajs/interface-types","@baklavajs/engine","@baklavajs/renderer-vue","toposort","@baklavajs/events","@vueuse/core"],G):(r=typeof globalThis<"u"?globalThis:r||self,G(r["@babsey/code-graph"]={},r.mustache,r.vue,r.uuid,r["@baklavajs/core"],r["@baklavajs/interface-types"],r["@baklavajs/engine"],r["@baklavajs/renderer-vue"],r.toposort,r["@baklavajs/events"],r["@vueuse/core"]))})(this,(function(r,G,e,j,O,I,R,f,nt,fe,ot){"use strict";G.escape=o=>o;class Y extends O.AbstractNode{state;isCodeNode=!0;name="";codeTemplate;inputs={};outputs={};constructor(){super(),this.initializeIo(),this.twoColumn=!0,this.state=e.reactive({codeTemplate:"",hidden:!1,integrated:!1,lockCode:!1,modules:[],props:null,script:"",variableName:"a"}),this.codeTemplate=function(){return`${this.name}(${ge(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 idx(){return this.graph.nodes.filter(t=>!t.state.integrated).indexOf(this)??-1}get idxByVariableNames(){return this.graph.getNodesBySameVariableNames(this.state.variableName).filter(t=>!t.state.integrated).indexOf(this)??-1}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 subgraph(){}get variableName(){return this.state.variableName?this.state.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(i=>i.to.id===this.inputs[t]?.id||i.from.id===this.inputs[t]?.id).map(i=>i.from.nodeId);a&&(s=s.concat(a))}if(n!=="inputs"&&this.outputs[t]){const a=this.graph.connections.filter(i=>i.from.id===this.outputs[t]?.id||i.from.id===this.outputs[t]?.id).map(i=>i.to.nodeId);a&&(s=s.concat(a))}return!s||s.length==0?[]:s.map(a=>this.graph.findNodeById(a))}registerCode(t){this.code=t}renderCode(t){return G.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}}class A extends Y{calculate=(t,n)=>{const s={};return this.lockCode||(s._code=this.renderCode({inputs:t,...n})),this.updateOutputValues(s),s};load(t){super.load(t),K(this.graph,t)}save(){const t=super.save();return be(this.graph,t),t}}const ge=(o,t=!0)=>{const n=[],s=Object.keys(o);return s.forEach(a=>{if(o[a]?.hidden)return;const l=t&&n.length<s.indexOf(a)?`${a}=`:"";n.push(`${l}{{ inputs.${a} }}`)}),n},K=(o,t)=>{if(!o)return;const n=o.findNodeById(t.id);if(!n||n.subgraph)return;const s=n;s.state&&(s.state.integrated=t.integrated,s.state.modules=t.modules,s.state.props=t.props),Object.entries(t.inputs).forEach(([a,i])=>{a!=="_code"&&s.inputs[a]&&(s.inputs[a].hidden=i.hidden)}),Object.entries(t.outputs).forEach(([a,i])=>{a!=="_code"&&s.outputs[a]&&(s.outputs[a].hidden=i.hidden)})},be=(o,t)=>{if(!o)return;const n=o.findNodeById(t.id);if(!n||n.subgraph)return;const s=n;s.state&&(t.integrated=s.state.integrated,t.modules=s.state.modules),Object.entries(t.inputs).forEach(([a,i])=>{a!=="_code"&&s.inputs[a]&&(i.hidden=s.inputs[a].hidden)}),Object.entries(t.outputs).forEach(([a,i])=>{a!=="_code"&&s.outputs[a]&&(i.hidden=s.outputs[a].hidden)})},st=["title"],H=e.defineComponent({__name:"CodeNodeInterface",props:{intf:{}},setup(o){return(t,n)=>(e.openBlock(),e.createElementBlock("div",{title:o.intf.value},e.toDisplayString(o.intf.name),9,st))}});class x extends O.NodeInterface{isCodeNode=!0;code;state;type=null;constructor(t,n){super(t,n),this.setComponent(e.markRaw(H)),this.state=e.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 L extends x{constructor(t="",n){super(t,n),this.setComponent(e.markRaw(H)),this.use(f.displayInSidebar,!0)}get value(){return super.value}set value(t){super.value=t,this.name!=="_code"&&this.setHidden(!1)}}const X=new I.NodeInterfaceType("boolean"),ke=new I.NodeInterfaceType("dict"),J=new I.NodeInterfaceType("list"),V=new I.NodeInterfaceType("node"),U=new I.NodeInterfaceType("number"),F=new I.NodeInterfaceType("string"),Q=new I.NodeInterfaceType("tuple"),at=o=>{new I.BaklavaInterfaceTypes(o.editor,{viewPlugin:o}).addTypes(X,ke,J,V,U,F,Q)};class it extends L{constructor(t,n){super(t,n),this.setComponent(e.markRaw(f.CheckboxInterfaceComponent)),this.use(I.setType,X)}getValue=()=>this.value?"True":"False"}class Ce extends x{isCodeNodeOutput=!0;suffix="";constructor(t="",n=""){super(t,""),this.suffix=n,this.setComponent(e.markRaw(H))}get codeValue(){return this.node?.outputs._code.value??""}get node(){const{graph:t}=f.useGraph();return t.value.findNodeById(this.nodeId)}}class Z extends L{min;max;constructor(t,n,s,a){super(t,n),this.min=s,this.max=a,this.use(I.setType,U)}validate(t){return(this.min===void 0||t>=this.min)&&(this.max===void 0||t<=this.max)}}class rt extends Z{component=e.markRaw(f.IntegerInterfaceComponent);validate(t){return Number.isInteger(t)&&super.validate(t)}}class lt extends L{constructor(t="",n=""){super(t,n),this.setComponent(e.markRaw(f.TextInputInterfaceComponent)),this.use(I.setType,J)}getValue=()=>`[${this.value}]`}class dt extends Z{component=e.markRaw(f.NumberInterfaceComponent)}class ee extends L{constructor(t,n){super(t,n),this.use(I.setType,F)}getValue=()=>`"${this.value}"`}class ct extends ee{component=e.markRaw(f.SelectInterfaceComponent);items;constructor(t,n,s){super(t,n),this.items=s}}class ut extends Z{component=e.markRaw(f.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}`}const pt=e.defineComponent({props:{intf:{type:Object,required:!0},modelValue:{type:String,required:!0}},emits:["update:modelValue"],setup(o,{emit:t}){return{v:e.computed({get:()=>o.modelValue,set:s=>{t("update:modelValue",s)}})}}}),M=(o,t)=>{const n=o.__vccOpts||o;for(const[s,a]of t)n[s]=a;return n},ht={style:{position:"relative"}},mt={style:{"font-size":"12px",padding:"0 6px",position:"absolute",top:"-8px","background-color":"var(--baklava-node-color-background)"}},ft=["placeholder","title"];function gt(o,t,n,s,a,i){return e.openBlock(),e.createElementBlock("div",ht,[e.createElementVNode("label",mt,e.toDisplayString(o.intf.name),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":t[0]||(t[0]=l=>o.v=l),type:"text",class:"baklava-input",placeholder:o.intf.name,title:o.intf.name},null,8,ft),[[e.vModelText,o.v]])])}const ye=M(pt,[["render",gt]]);class bt extends ee{component=e.markRaw(ye)}class kt extends ee{component=e.markRaw(f.TextareaInputInterfaceComponent)}class Ct extends L{constructor(t="",n=""){super(t,n),this.setComponent(e.markRaw(f.TextInputInterfaceComponent)),this.use(I.setType,Q)}getValue=()=>`(${this.value})`}function yt(o){return class extends A{type=o.type;inputs={};outputs={};constructor(){super(),this._title=o.title??o.type,this.executeFactory("input",o.inputs),this.executeFactory("output",o.outputs),o.calculate&&(this.calculate=(t,n)=>o.calculate.call(this,{inputs:t,...n})),o.onCreate?.call(this),this.name=o.name??o.type,this.updateModules(o.modules),o.variableName!=null&&(this.state.variableName=o.variableName),o.codeTemplate&&(this.codeTemplate=o.codeTemplate),this.addInput("_code",new x("",[]).use(I.setType,V).use(R.allowMultipleConnections).setHidden(!0)),this.addOutput("_code",new x("",[]).use(I.setType,V).use(R.allowMultipleConnections).setHidden(!0))}onPlaced(){o.onPlaced?.call(this)}onConnected(){o.onConnected?.call(this)}onDestroy(){o.onDestroy?.call(this)}onUnconnected(){o.onUnconnected?.call(this)}update(){o.update?.call(this)}executeFactory(t,n){Object.keys(n||{}).forEach(s=>{const a=n[s]();t==="input"?this.addInput(s,a):this.addOutput(s,a)})}}}class Ne extends A{}function Nt(o){return class extends Ne{type=o.type;inputs={};outputs={};preventUpdate=!1;staticInputKeys=Object.keys(o.inputs??{});staticOutputKeys=Object.keys(o.outputs??{});constructor(){super(),this._title=o.title??o.type,this.executeFactory("input",o.inputs),this.executeFactory("output",o.outputs),o.calculate&&(this.calculate=(t,n)=>o.calculate?.call(this,t,n)),o.onCreate?.call(this),this.name=o.name??o.type,this.updateModules(o.modules),o.codeTemplate&&(this.codeTemplate=o.codeTemplate),o.variableName&&(this.state.variableName=o.variableName),this.addInput("_code",new x("",[]).use(I.setType,V).use(R.allowMultipleConnections).setHidden(!0)),this.addOutput("_code",new x("",[]).use(I.setType,V).use(R.allowMultipleConnections).setHidden(!0)),this.staticInputKeys.push("_code"),this.staticOutputKeys.push("_code")}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(),o.onPlaced?.call(this)}onConnected(){o.onConnected?.call(this)}onDestroy(){o.onDestroy?.call(this)}onUnconnected(){o.onUnconnected?.call(this)}update(){o.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)){if(!this.inputs[n]){const s=t.inputs[n].value;let a;typeof s=="number"?a=new f.IntegerInterface(n,s).use(I.setType,U):a=new f.TextInputInterface(n,JSON.stringify(s)).use(I.setType,F),a.use(f.displayInSidebar,!0),this.addInput(n,a)}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)){if(!this.outputs[n]){const s=new Ce(n);this.addOutput(n,s)}this.outputs[n]&&(this.outputs[n].load(t.outputs[n]),this.outputs[n].nodeId=this.id)}K(this.graph,t),this.preventUpdate=!1,this.events.loaded.emit(this)}onUpdate(){if(this.preventUpdate)return;this.graph&&this.graph.activeTransactions++;const t=this.getStaticValues(this.staticInputKeys,this.inputs),n=this.getStaticValues(this.staticOutputKeys,this.outputs),s=o.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}updateInterfaces(t,n,s){const a=t==="input"?this.staticInputKeys:this.staticOutputKeys,i=t==="input"?this.inputs:this.outputs;for(const l of Object.keys(i))a.includes(l)||n[l]&&!s.includes(l)||(t==="input"?this.removeInput(l):this.removeOutput(l));for(const l of Object.keys(n)){if(i[l])continue;const d=n[l]();t==="input"?this.addInput(l,d):this.addOutput(l,d)}}updateProps(t){this.state.props=t,this.onUpdate()}executeFactory(t,n){Object.keys(n||{}).forEach(s=>{const a=n[s]();t==="input"?this.addInput(s,a):this.addOutput(s,a)})}}}const te="__baklava_SubgraphInputNode",ne="__baklava_SubgraphOutputNode";class _e extends A{graphInterfaceId;constructor(){super(),this.graphInterfaceId=j.v4()}onPlaced(){super.onPlaced(),this.initializeIo()}load(t){super.load(t),this.graphInterfaceId=t.graphInterfaceId}save(){return{...super.save(),graphInterfaceId:this.graphInterfaceId}}update(){}}class oe extends _e{static isGraphInputNode(t){return t.type===te}type=te;inputs={name:new O.NodeInterface("Name","Input")};outputs={placeholder:new O.NodeInterface("Value",void 0)}}class se extends _e{static isGraphOutputNode(t){return t.type===ne}type=ne;inputs={name:new O.NodeInterface("Name","Output"),placeholder:new O.NodeInterface("Value",void 0)};outputs={output:new O.NodeInterface("Output",void 0).setHidden(!0)};calculate=({placeholder:t})=>({output:t})}const _t=["component","connectionCount","events","hidden","hooks","id","isCodeNode","isInput","name","nodeId","port","templateId","value"];function Ie(o){return class extends Y{type=O.getGraphNodeTypeString(o);get title(){return this._title}set title(n){this.template.name=n}inputs={};outputs={};template=o;subgraph;update(){}onConnected(){}onUnconnected(){}calculate=async(n,s)=>{if(!this.subgraph)throw new Error(`GraphNode ${this.id}: calculate called without subgraph being initialized`);if(!s.engine||typeof s.engine!="object")throw new Error(`GraphNode ${this.id}: calculate called but no engine provided in context`);const a=s.engine.getInputValues(this.subgraph);for(const d of this.subgraph.inputs)a.set(d.nodeInterfaceId,n[d.id]);const i=await s.engine.runGraph(this.subgraph,a,s.globalValues);s.engine.pause(),R.applyResult(i,s.engine.editor),s.engine.resume();const l={};for(const d of this.subgraph.outputs)l[d.id]=i.get(d.nodeId)?.get("output");return l._calculationResults=i,this.lockCode||(l._code=this.renderCode({inputs:n,...s.globalValues})),this.updateOutputValues(l),l};load(n){if(!this.subgraph)throw new Error("Cannot load a graph node without a graph");if(!this.template)throw new Error("Unable to load graph node without graph template");this.subgraph.load(n.graphState),super.load(n)}save(){if(!this.subgraph)throw new Error("Cannot save a graph node without a graph");return{...super.save(),graphState:this.subgraph.save()}}onPlaced(){this.template.events.updated.subscribe(this,()=>this.initialize()),this.template.events.nameChanged.subscribe(this,n=>{this._title=n}),this.initialize()}onDestroy(){this.template.events.updated.unsubscribe(this),this.template.events.nameChanged.unsubscribe(this),this.subgraph?.destroy()}initialize(){this.subgraph&&this.subgraph.destroy(),this.subgraph=this.template.createGraph(),this._title=this.template.name,this.updateInterfaces(),this.state.codeTemplate=`{{ #nodes }}{{ script }}
|
|
2
|
-
{{ /nodes }}`,this.events.update.emit(null)}renderCode(n){return this.subgraph?this.subgraph.renderCode({nodes:this.subgraph.scriptedCodeNodes}):
|
|
3
|
-
This is likely an internal issue. Please report it on GitHub.`);const
|
|
4
|
-
This is likely an internal issue. Please report it on GitHub.`);return t.get(n)}}const wt={},Et={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 vt(o,t){return e.openBlock(),e.createElementBlock("svg",Et,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.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 ve=M(wt,[["render",vt]]),Bt={},Tt={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 Ot(o,t){return e.openBlock(),e.createElementBlock("svg",Tt,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.createElementVNode("path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"},null,-1),e.createElementVNode("path",{d:"M12 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"},null,-1),e.createElementVNode("path",{d:"M12 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"},null,-1)])])}const Be=M(Bt,[["render",Ot]]),xt={},Mt={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 St(o,t){return e.openBlock(),e.createElementBlock("svg",Mt,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.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 Te=M(xt,[["render",St]]),Vt={},$t={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 Gt(o,t){return e.openBlock(),e.createElementBlock("svg",$t,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.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 Oe=M(Vt,[["render",Gt]]),Rt={},jt={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 Pt(o,t){return e.openBlock(),e.createElementBlock("svg",jt,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.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 xe=M(Rt,[["render",Pt]]),Lt={},Dt={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 zt(o,t){return e.openBlock(),e.createElementBlock("svg",Dt,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.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 Me=M(Lt,[["render",zt]]),At={},Ht={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 Ut(o,t){return e.openBlock(),e.createElementBlock("svg",Ht,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.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 Se=M(At,[["render",Ut]]),Ft={},Wt={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 qt(o,t){return e.openBlock(),e.createElementBlock("svg",Wt,[...t[0]||(t[0]=[e.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 Ve=M(Ft,[["render",qt]]),Yt={},Kt={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 Xt(o,t){return e.openBlock(),e.createElementBlock("svg",Kt,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.createElementVNode("path",{d:"M7 4v16l13 -8z"},null,-1)])])}const $e=M(Yt,[["render",Xt]]),Jt={},Qt={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 Zt(o,t){return e.openBlock(),e.createElementBlock("svg",Qt,[...t[0]||(t[0]=[e.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 Ge=M(Jt,[["render",Zt]]),en={},tn={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 nn(o,t){return e.openBlock(),e.createElementBlock("svg",tn,[...t[0]||(t[0]=[e.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 Re=M(en,[["render",nn]]),on={},sn={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 an(o,t){return e.openBlock(),e.createElementBlock("svg",sn,[...t[0]||(t[0]=[e.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 je=M(on,[["render",an]]),rn={},ln={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-trash-off"};function dn(o,t){return e.openBlock(),e.createElementBlock("svg",ln,[...t[0]||(t[0]=[e.createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M3 3l18 18"></path><path d="M4 7h3m4 0h9"></path><path d="M10 11l0 6"></path><path d="M14 14l0 3"></path><path d="M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l.077 -.923"></path><path d="M18.384 14.373l.616 -7.373"></path><path d="M9 5v-1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3"></path>',8)])])}const Pe=M(rn,[["render",dn]]),ae="CLEAR_ALL",ie="RUN_ENGINE",re="TOGGLE_MINIMAP",le="TOGGLE_PALETTE",Le=(o,t,n)=>{const s=n.zoomToFit.paddingLeft;t.registerCommand(le,{execute:()=>{n.palette.enabled=!n.palette.enabled,n.zoomToFit.paddingLeft=n.palette.enabled?s:50},canExecute:()=>!0}),t.registerCommand(ae,{execute:()=>o.value.clear(),canExecute:()=>o.value.nodes.length>0}),t.registerCommand(re,{execute:()=>n.enableMinimap=!n.enableMinimap,canExecute:()=>o.value.nodes.length>1})},De=o=>{const t={command:ie,title:"Run",icon:e.computed(()=>$e)},n={command:le,title:"Toggle palette",icon:e.computed(()=>o.palette.enabled?Te:Oe)},s={command:ae,title:"Clear all",icon:e.computed(()=>Pe)},a={command:re,title:"Toggle minimap",icon:e.computed(()=>o.enableMinimap?Re:Ge)};o.toolbar.commands=[n,t,...f.DEFAULT_TOOLBAR_COMMANDS,s,a]},ze=(o,t)=>{t.registerCommand(ie,{execute:()=>o.runOnce(null),canExecute:()=>!0})};function Ae(o){const t=Symbol("CodeEngineToken");o.engine=new Ee(o.editor),ze(o.engine,o.commandHandler),o.loadEditor=n=>{o.engine?.pause(),o.displayedGraph.clear(),o.editor.load(n),o.commandHandler.executeCommand(f.Commands.CLEAR_CLIPBOARD_COMMAND),o.commandHandler.executeCommand(f.Commands.CLEAR_HISTORY_COMMAND),o.engine?.resume(),o.engine?.runOnce(null)},o.newGraph=()=>{o.engine?.pause(),o.displayedGraph.clear(),o.commandHandler.executeCommand(f.Commands.CLEAR_CLIPBOARD_COMMAND),o.commandHandler.executeCommand(f.Commands.CLEAR_HISTORY_COMMAND),o.displayedGraph.id=j.v4(),o.engine?.resume(),o.engine?.runOnce(null)},o.subscribe=()=>{o.displayedGraph.events.addConnection.subscribe(t,n=>{const s=o.displayedGraph.findNodeById(n.to.nodeId);s&&s.isCodeNode&&s.onConnected();const a=o.displayedGraph.findNodeById(n.from.nodeId);a&&a.isCodeNode&&a.onConnected()}),o.displayedGraph.events.removeConnection.subscribe(t,n=>{const s=o.displayedGraph.findNodeById(n.to.nodeId);s&&s.isCodeNode&&s.onUnconnected();const a=o.displayedGraph.findNodeById(n.from.nodeId);a&&a.isCodeNode&&a.onUnconnected()}),o.engine?.events.beforeRun.subscribe(t,()=>{o.engine?.pause(),o.displayedGraph.sortNodes(),o.engine?.resume()}),o.engine?.events.afterRun.subscribe(t,n=>{o.engine?.pause(),R.applyResult(n,o.editor),o.code.state.lockCode||o.code.renderCode({nodes:o.editor.graph.scriptedCodeNodes,modules:o.editor.graph.modules}),o.engine?.resume()})},o.unsubscribe=()=>{o.displayedGraph.events.addConnection.unsubscribe(t),o.displayedGraph.events.removeConnection.unsubscribe(t),o.engine?.events.beforeRun.unsubscribe(t),o.engine?.events.afterRun.unsubscribe(t)}}class D extends O.Graph{code=null;editor;_state=e.reactive({codeTemplate:"{{ #nodes }}{{ script }}{{ /nodes }}",lockCode:!1});constructor(t,n){super(t,n),this.editor=t,this.template=n,t.code&&(this.code=t.code)}get codeNodes(){return de(this)}get connections(){return super.connections}set connections(t){this._connections=t}get nodeIds(){return this.nodes.map(t=>t.id)}get nodes(){return super.nodes}set nodes(t){this._nodes=t}get scriptedCodeNodes(){return this.nodes.filter(t=>!t.state?.integrated)}get shortId(){return this.id.slice(0,6)}get state(){return this._state}get visibleNodes(){return this.nodes.filter(t=>!t.state?.hidden)}addNodeAtCoordinates=(t,n={x:0,y:0},s)=>(this.addNode(t,s),t.position&&(t.position=n),t);addConnection(t,n){t?.name!=="_code"&&(t.hidden=!1),n?.name!=="_code"&&(n.hidden=!1),super.addConnection(t,n)}clear(){this.selectedNodes=[],this._nodes=[],this._connections=[]}findNodeByType(t){return this.nodes.find(n=>n.type===t)}getNodesBySameType(t){return this.nodes.filter(n=>n.type===t)}getNodesBySameVariableNames(t){return this.nodes.filter(n=>n.state?.variableName===t)}hasConnection(t,n){return this.connections.some(s=>s.from.id===t.id&&s.to.id===n.id)}renderCode(t){return G.render(this.state?.codeTemplate||"",t)}sortNodes(){if(!(this.nodes.length===0||this.connections.length===0))try{let t=this.nodeIds;const n=this.connections.filter(i=>t.includes(i.to.nodeId)&&t.includes(i.from.nodeId)).map(i=>[i.to.nodeId,i.from.nodeId]);t.reverse(),t=nt.array(t,n),t.reverse();const s=this.nodes.map(i=>i.id).filter(i=>!t.includes(i));t=[...t,...s];const a=t.map(i=>this.findNodeById(i));a&&(this.nodes=a)}catch{console.warn("Failed to sort nodes.")}}}const de=o=>{const t=[];return o.nodes.length===0||o.nodes.forEach(n=>{n&&(n.hasOwnProperty("subgraph")?t.push(...de(n.subgraph)):n.hasOwnProperty("isCodeNode")&&t.push(n))}),t},cn=(o=0,t=100)=>({x:o*420,y:t}),un=o=>{const t={...o.position};return t.x-=440,t.y+=50,t};function pn(o,t){return Object.fromEntries(Object.entries(o).filter(t))}function hn(o,t){return Object.fromEntries(Object.entries(o).map(([n,s])=>[n,t(s)]))}class z extends O.GraphTemplate{static fromGraph(t,n){return new z(t.save(),n)}constructor(t,n){super(t,n)}get shortId(){return this.id.slice(0,6)}createGraph(t){const n=new Map,s=h=>{const w=j.v4();return n.set(h,w),w},a=h=>{const w=n.get(h);if(!w)throw new Error(`Unable to create graph from template: Could not map old id ${h} to new id`);return w},i=h=>hn(h,w=>({id:s(w.id),templateId:w.id,value:w.value})),l=this.nodes.map(h=>({...h,id:s(h.id),inputs:i(h.inputs),outputs:i(h.outputs)})),d=this.connections.map(h=>({id:s(h.id),from:a(h.from),to:a(h.to)})),u=this.inputs.map(h=>({id:h.id,name:h.name,nodeId:a(h.nodeId),nodeInterfaceId:a(h.nodeInterfaceId)})),p=this.outputs.map(h=>({id:h.id,name:h.name,nodeId:a(h.nodeId),nodeInterfaceId:a(h.nodeInterfaceId)})),b={id:j.v4(),nodes:l,connections:d,inputs:u,outputs:p};return t||(t=new D(this.editor)),t.load(b).forEach(h=>console.warn(h)),t.template=this,t}}const mn=o=>!(o instanceof D);function He(o,t){return{switchGraph:s=>{let a;if(mn(s))a=new D(o.value),s.createGraph(a);else{if(s!==o.value.graph)throw new Error("Can only switch using 'Graph' instance when it is the root graph. Otherwise a 'GraphTemplate' must be used.");a=s}t.value&&t.value!==o.value.graph&&t.value.destroy(),a.panning=a.panning??s.panning??{x:0,y:0},a.scaling=a.scaling??s.scaling??1,a.selectedNodes=a.selectedNodes??[],a.sidebar=a.sidebar??{visible:!1,nodeId:"",optionName:""},t.value=a,a.code?.engine?.runOnce(null)}}}const fn=e.defineComponent({__name:"CodeGraphEditor",props:{viewModel:{}},setup(o){const t=o,n=e.toRef(t,"viewModel"),s=a=>a.events.update.emit(null);return e.onMounted(()=>{n.value.subscribe&&n.value.subscribe(),n.value.engine?.start()}),e.onBeforeUnmount(()=>{n.value.unsubscribe&&n.value.unsubscribe(),n.value.engine?.stop()}),e.watch(n,(a,i)=>{i&&i.unsubscribe(),a&&a.subscribe()}),(a,i)=>(e.openBlock(),e.createBlock(e.unref(f.BaklavaEditor),{viewModel:n.value},{palette:e.withCtx(()=>[e.createVNode(e.unref(Fe))]),node:e.withCtx(l=>[e.createVNode(e.unref(Ue),e.mergeProps(l,{onUpdate:d=>s(l.node)}),null,16,["onUpdate"])]),sidebar:e.withCtx(l=>[e.createVNode(e.unref(We),e.normalizeProps(e.guardReactiveProps(l)),{codeEditor:e.withCtx(({node:d})=>[e.renderSlot(a.$slots,"sidebarCodeEditor",{node:d})]),_:3},16)]),_:3},8,["viewModel"]))}}),gn={class:"code-graph-info"},bn=e.defineComponent({__name:"CodeGraphInfo",props:{viewModel:{}},setup(o){return(t,n)=>(e.openBlock(),e.createElementBlock("div",gn,[e.createElementVNode("div",null,"Editor graph: "+e.toDisplayString(o.viewModel.editor.graph.shortId),1),e.createElementVNode("div",null,"Displayed graph: "+e.toDisplayString(o.viewModel.displayedGraph.shortId),1),e.createElementVNode("div",null,"Graphs: "+e.toDisplayString(o.viewModel.editor.graphIds),1),e.createElementVNode("div",null,"Graph templates: "+e.toDisplayString(o.viewModel.editor.graphTemplateIds),1),e.createElementVNode("div",null,"Engine status: "+e.toDisplayString(o.viewModel.engine?.status),1)]))}}),kn=["id","data-node-type"],Cn={class:"__title-label",style:{"flex-grow":"1"}},yn={key:0},Nn={class:"__menu",style:{display:"flex"}},_n={class:"__outputs"},In={key:0},wn=["id","title"],En={class:"__inputs"},vn={key:0},Bn=["id","title"],Ue=e.defineComponent({__name:"CodeGraphNode",props:{node:{},selected:{type:Boolean,default:!1},dragging:{type:Boolean}},emits:["select","start-drag","update"],setup(o,{emit:t}){const n=f.Components.ContextMenu,s=f.Components.NodeInterface,a=o,i=e.computed(()=>a.node),l=t,{viewModel:d}=f.useViewModel(),{graph:u,switchGraph:p}=f.useGraph(),b=e.ref(null),C=e.ref(!1),h=e.ref(""),w=e.ref(null),k=e.ref(!1);let _=0,c=0;const m=e.ref(!1),E=e.computed(()=>{const N=[{value:"edit",label:"Edit"},{value:"rename",label:"Rename"},{value:"delete",label:"Delete"}];return a.node.type.startsWith(O.GRAPH_NODE_TYPE_PREFIX)&&N.push({value:"editSubgraph",label:"Edit Subgraph"}),N}),y=e.computed(()=>({"--selected":a.selected,"--dragging":a.dragging,"--two-column":!!a.node.twoColumn,"--hidden":i.value.state?.hidden})),B=e.computed(()=>({"--reverse-y":a.node.reverseY??d.value.settings.nodes.reverseY})),W=e.computed(()=>({top:`${a.node.position?.y??0}px`,left:`${a.node.position?.x??0}px`,"--width":`${a.node.width??d.value.settings.nodes.defaultWidth}px`})),P=e.computed(()=>Object.values(a.node.inputs).filter(N=>!N.hidden)),me=e.computed(()=>Object.values(a.node.outputs).filter(N=>!N.hidden)),q=()=>{l("select")},g=N=>{a.selected||q(),l("start-drag",N)},S=()=>{m.value=!0},$=()=>{const N=d.value.displayedGraph.sidebar;N.nodeId="",N.visible=!1},Xe=()=>{const N=d.value.displayedGraph.sidebar;N.nodeId=a.node.id,N.visible=!0},qn=()=>{const N=d.value.displayedGraph.sidebar;N.nodeId=a.node.id},Yn=async N=>{switch(N){case"edit":Xe();break;case"delete":u.value.removeNode(a.node);break;case"rename":h.value=a.node.title,C.value=!0,await e.nextTick(),w.value?.focus();break;case"editSubgraph":p(a.node.template);break}},Je=()=>{i.value.title=h.value,C.value=!1},Qe=()=>{b.value&&d.value.hooks.renderNode.execute({node:a.node,el:b.value})},Kn=N=>{k.value=!0,_=a.node.width,c=N.clientX,N.preventDefault()},Ze=N=>{i.value.state&&(i.value.state.integrated=N,l("update"))},et=N=>{if(!k.value)return;const T=N.clientX-c,v=_+T/u.value.scaling,Xn=d.value.settings.nodes.minWidth,Jn=d.value.settings.nodes.maxWidth;i.value.width=Math.max(Xn,Math.min(Jn,v))},tt=()=>{k.value=!1};return e.onMounted(()=>{Qe(),window.addEventListener("mousemove",et),window.addEventListener("mouseup",tt)}),e.onUpdated(Qe),e.onBeforeUnmount(()=>{window.removeEventListener("mousemove",et),window.removeEventListener("mouseup",tt)}),(N,T)=>(e.openBlock(),e.createElementBlock("div",{id:i.value.id,ref_key:"el",ref:b,class:e.normalizeClass([y.value,"baklava-node"]),"data-node-type":i.value.type,style:e.normalizeStyle(W.value),onPointerdown:q},[e.unref(d).settings.nodes.resizable?(e.openBlock(),e.createElementBlock("div",{key:0,class:"__resize-handle",onMousedown:Kn},null,32)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"__title",onPointerdown:e.withModifiers(g,["self","stop"]),onContextmenu:e.withModifiers(S,["prevent"])},[i.value.inputs._code?(e.openBlock(),e.createBlock(e.unref(ce),{key:0,node:i.value,intf:i.value.inputs._code,title:i.value.inputs._code.value,class:"--input","data-interface-type":"node",style:{"flex-grow":"0"}},null,8,["node","intf","title"])):e.createCommentVNode("",!0),C.value?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:2,ref_key:"renameInputEl",ref:w,"onUpdate:modelValue":T[4]||(T[4]=v=>h.value=v),class:"baklava-input",placeholder:"Node Name",style:{"flex-grow":"1"},type:"text",onBlur:Je,onKeydown:e.withKeys(Je,["enter"])},null,544)),[[e.vModelText,h.value]]):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("div",Cn,[i.value.idx>-1?(e.openBlock(),e.createElementBlock("span",yn,e.toDisplayString(i.value.idx+1)+" - ",1)):e.createCommentVNode("",!0),e.createTextVNode(e.toDisplayString(i.value.title)+" "+e.toDisplayString(i.value.graph.shortId)+" "+e.toDisplayString(i.value.shortId),1)]),e.createElementVNode("div",Nn,[i.value.isCodeNode?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[i.value.state.lockCode?(e.openBlock(),e.createBlock(e.unref(Ve),{key:0,class:"--clickable mx-1",onClick:T[0]||(T[0]=v=>i.value.lockCode=!1)})):e.createCommentVNode("",!0),i.value.state.integrated?(e.openBlock(),e.createBlock(e.unref(ve),{key:1,class:"--clickable mx-1",onClick:T[1]||(T[1]=v=>Ze(!1))})):(e.openBlock(),e.createBlock(e.unref(je),{key:2,class:"--clickable mx-1",onClick:T[2]||(T[2]=v=>Ze(!0))})),!e.unref(d).displayedGraph.sidebar.visible&&e.unref(d).displayedGraph.sidebar.nodeId!==i.value.id?(e.openBlock(),e.createBlock(e.unref(Se),{key:3,class:"--clickable mx-1",onClick:Xe})):e.unref(d).displayedGraph.sidebar.visible&&e.unref(d).displayedGraph.sidebar.nodeId!==i.value.id?(e.openBlock(),e.createBlock(e.unref(xe),{key:4,class:"--clickable mx-1",onClick:qn})):(e.openBlock(),e.createBlock(e.unref(Me),{key:5,class:"--clickable mx-1",onClick:$}))],64)):e.createCommentVNode("",!0),e.createVNode(e.unref(Be),{class:"--clickable mx-1",onClick:S}),e.createVNode(e.unref(n),{modelValue:m.value,"onUpdate:modelValue":T[3]||(T[3]=v=>m.value=v),x:0,y:0,items:E.value,onClick:Yn},null,8,["modelValue","items"])])],64)),i.value.outputs._code?(e.openBlock(),e.createBlock(e.unref(ce),{key:3,node:i.value,intf:i.value.outputs._code,class:"--output",title:i.value.outputs._code.value,"data-interface-type":"node"},null,8,["node","intf","title"])):e.createCommentVNode("",!0)],32),e.createElementVNode("div",{class:e.normalizeClass(["__content",B.value]),onKeydown:T[5]||(T[5]=e.withKeys(e.withModifiers(()=>{},["stop"]),["delete"])),onContextmenu:T[6]||(T[6]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("div",_n,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(me.value,v=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:v.id},[i.value.state?.hidden?(e.openBlock(),e.createElementBlock("div",In,[v.port?(e.openBlock(),e.createElementBlock("div",{key:0,id:v.id,title:v.name,class:"baklava-node-interface --output --connected"},[...T[7]||(T[7]=[e.createElementVNode("div",{class:"__port"},null,-1)])],8,wn)):e.createCommentVNode("",!0)])):e.renderSlot(N.$slots,"nodeInterface",{key:1,type:"output",node:i.value,intf:v},()=>[e.createVNode(e.unref(s),{node:i.value,intf:v,title:v.value},null,8,["node","intf","title"])])],64))),128))]),e.createElementVNode("div",En,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(P.value,v=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:v.id},[i.value.state?.hidden?(e.openBlock(),e.createElementBlock("div",vn,[v.port?(e.openBlock(),e.createElementBlock("div",{key:0,id:v.id,title:v.name,class:"baklava-node-interface --input --connected"},[...T[8]||(T[8]=[e.createElementVNode("div",{class:"__port"},null,-1)])],8,Bn)):e.createCommentVNode("",!0)])):e.renderSlot(N.$slots,"nodeInterface",{key:1,node:i.value,intf:v,type:"input"},()=>[e.createVNode(e.unref(s),{node:i.value,intf:v,title:v.value},null,8,["node","intf","title"])])],64))),128))])],34)],46,kn))}}),Tn=["id"],On={class:"align-middle"},ce=e.defineComponent({__name:"CodeGraphNodeInterface",props:{node:{},intf:{}},setup(o){const t=o,{viewModel:n}=f.useViewModel(),{hoveredOver:s,temporaryConnection:a}=f.useTemporaryConnection(),i=e.ref(null),l=e.computed(()=>t.intf.connectionCount>0),d=e.computed(()=>({"--connected":l.value})),u=()=>{s(t.intf)},p=()=>{s(void 0)},b=()=>{i.value&&n.value.hooks.renderInterface.execute({intf:t.intf,el:i.value})};return e.onMounted(b),e.onUpdated(b),(C,h)=>(e.openBlock(),e.createElementBlock("div",{id:o.intf.id,ref_key:"el",ref:i,class:e.normalizeClass(["baklava-node-interface",d.value])},[o.intf.port?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["__port",{"--selected":e.unref(a)?.from===o.intf}]),onPointerover:u,onPointerout:p},null,34)):e.createCommentVNode("",!0),e.createElementVNode("span",On,[e.renderSlot(C.$slots,"default")])],10,Tn))}}),xn={class:"baklava-node --palette",style:{"margin-top":"-20px","margin-bottom":"20px"}},Mn={key:0,style:{display:"flex","justify-content":"space-between"}},Sn=["onClick"],Vn={key:0,style:{margin:"auto 0","font-size":"12px"}},Fe=e.defineComponent({__name:"CodeNodePalette",setup(o){const t=f.Components.PaletteEntry,{viewModel:n}=f.useViewModel(),{x:s,y:a}=ot.usePointer(),{transform:i}=f.useTransform(),l=f.useNodeCategories(n),d=e.inject("editorEl"),u=e.ref(""),p=e.ref(null),b=()=>u.value?l.value.filter(k=>k.name.toLowerCase().includes(u.value.toLowerCase())||Object.values(k.nodeTypes).some(_=>_.title.toLowerCase().includes(u.value.toLowerCase()))):l.value,C=k=>u.value?pn(k,_=>{const c=_[1];return c.category.includes(u.value.toLowerCase())||c.title?.toLowerCase().includes(u.value.toLowerCase())}):k,h=e.computed(()=>{if(!p.value||!d?.value)return{};const{left:k,top:_}=d.value.getBoundingClientRect();return{top:`${a.value-_}px`,left:`${s.value-k}px`}}),w=(k,_)=>{p.value={type:k,nodeInformation:_};const c=()=>{const m=e.reactive(new _.type);n.value.displayedGraph.addNode(m);const E=d.value.getBoundingClientRect(),[y,B]=i(s.value-E.left,a.value-E.top);m.position.x=y,m.position.y=B,p.value=null,document.removeEventListener("pointerup",c)};document.addEventListener("pointerup",c)};return(k,_)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{class:e.normalizeClass([{"--open":e.unref(n).settings.palette.enabled},"baklava-node-palette"]),onContextmenu:_[1]||(_[1]=e.withModifiers(()=>{},["stop","prevent"]))},[e.createElementVNode("div",xn,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":_[0]||(_[0]=c=>u.value=c),type:"text",class:"baklava-input",title:"Filter nodes",onKeyup:b},null,544),[[e.vModelText,u.value]])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b(),c=>(e.openBlock(),e.createElementBlock("section",{key:c.name},[c.name!=="default"?(e.openBlock(),e.createElementBlock("h3",Mn,[e.createElementVNode("div",{onClick:m=>u.value=c.name,style:{cursor:"pointer"}},e.toDisplayString(c.name),9,Sn),Object.keys(C(c.nodeTypes)).length<Object.values(c.nodeTypes).length?(e.openBlock(),e.createElementBlock("div",Vn," ( "+e.toDisplayString(Object.keys(C(c.nodeTypes)).length)+" / "+e.toDisplayString(Object.values(c.nodeTypes).length)+" ) ",1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(C(c.nodeTypes),(m,E)=>(e.openBlock(),e.createBlock(e.unref(t),{key:E,type:E,title:m.title,onPointerdown:y=>w(E,m)},null,8,["type","title","onPointerdown"]))),128))]))),128))],34),e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[p.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"baklava-dragged-node",style:e.normalizeStyle(h.value)},[e.createVNode(e.unref(t),{type:p.value.type,title:p.value.nodeInformation.title},null,8,["type","title"])],4)):e.createCommentVNode("",!0)]),_:1})],64))}}),$n=["title"],Gn={key:0,class:"__label"},ue=e.defineComponent({__name:"SidebarCheckbox",props:{disabled:{type:Boolean},inversed:{type:Boolean},modelValue:{type:Boolean},name:{}},emits:["update:modelValue"],setup(o,{emit:t}){const n=t;return(s,a)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["baklava-checkbox",{"--checked":o.inversed?!o.modelValue:o.modelValue,"--disabled":o.disabled}]),title:o.name,onClick:a[0]||(a[0]=i=>n("update:modelValue",!o.modelValue))},[a[1]||(a[1]=e.createElementVNode("div",{class:"__checkmark-container"},[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18"},[e.createElementVNode("path",{class:"__checkmark",d:"M 6 5 L 6 10 L 16 10",transform:"rotate(-45 10 10)"})])],-1)),o.name?(e.openBlock(),e.createElementBlock("div",Gn,e.toDisplayString(o.name),1)):e.createCommentVNode("",!0)],10,$n))}}),Rn={class:"__header"},jn={class:"__node-name"},Pn={class:"__interfaces"},Ln={class:"__inputs"},Dn={style:{display:"flex"}},zn={class:"__outputs"},An={key:0,class:"__interface"},Hn={style:{display:"flex"}},We=e.defineComponent({__name:"CodeGraphSidebar",setup(o){const{viewModel:t}=f.useViewModel(),{graph:n}=f.useGraph(),s=e.ref(null),a=e.toRef(t.value.settings.sidebar,"width"),i=e.computed(()=>t.value.settings.sidebar.resizable);let l=0,d=0;const u=e.computed(()=>{const m=n.value.sidebar.nodeId;return n.value.nodes.find(E=>E.id===m)}),p=e.computed(()=>u.value),b=e.computed(()=>({width:`${a.value}px`})),C=e.computed(()=>p.value?Object.values(p.value.inputs).filter(m=>m.displayInSidebar&&m.component):[]),h=e.computed(()=>p.value?Object.values(p.value.outputs).filter(m=>m.displayInSidebar&&m.component):[]),w=()=>{n.value.sidebar.visible=!1},k=()=>{u.value?.events.update.emit(null)},_=m=>{l=a.value,d=m.clientX,window.addEventListener("mousemove",c),window.addEventListener("mouseup",()=>{window.removeEventListener("mousemove",c)},{once:!0})},c=m=>{const E=s.value?.parentElement?.getBoundingClientRect().width??500,y=m.clientX-d;let B=l-y;B<300?B=300:B>.9*E&&(B=.9*E),a.value=B};return(m,E)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass([{"--open":e.unref(n).sidebar.visible},"baklava-sidebar"]),style:e.normalizeStyle(b.value),ref_key:"el",ref:s},[i.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"__resizer",onMousedown:_},null,32)):e.createCommentVNode("",!0),u.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("div",Rn,[e.createElementVNode("button",{tabindex:"-1",class:"__close",onClick:w},"×"),e.createElementVNode("div",jn,[e.createElementVNode("b",null,e.toDisplayString(u.value.title),1)])]),e.createElementVNode("div",Pn,[e.createElementVNode("div",Ln,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(C.value,y=>(e.openBlock(),e.createElementBlock("div",{key:y.id,class:"__interface"},[e.createElementVNode("div",Dn,[e.createVNode(ue,{modelValue:y.hidden,"onUpdate:modelValue":[B=>y.hidden=B,E[0]||(E[0]=()=>u.value?.events.update.emit(null))],disabled:!y.optional,inversed:"",style:{"padding-right":"8px"}},null,8,["modelValue","onUpdate:modelValue","disabled"]),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(y.component),{modelValue:y.value,"onUpdate:modelValue":B=>y.value=B,node:u.value,intf:y,style:{width:"100%"}},null,8,["modelValue","onUpdate:modelValue","node","intf"]))])]))),128))]),e.createElementVNode("div",zn,[p.value&&p.value.state?(e.openBlock(),e.createElementBlock("div",An,[E[3]||(E[3]=e.createElementVNode("label",null,"Variable name",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":E[1]||(E[1]=y=>p.value.state.variableName=y),type:"text",class:"baklava-input",title:"Variable name",onBlur:k,onKeydown:e.withKeys(k,["enter"])},null,544),[[e.vModelText,p.value.state.variableName]])])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.value,y=>(e.openBlock(),e.createElementBlock("div",{key:y.id,class:"__interface"},[e.createElementVNode("div",Hn,[e.createVNode(ue,{modelValue:y.hidden,"onUpdate:modelValue":[B=>y.hidden=B,E[2]||(E[2]=()=>u.value?.events.update.emit(null))],disabled:!y.optional,inversed:"",style:{"padding-right":"8px"}},null,8,["modelValue","onUpdate:modelValue","disabled"]),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(y.component),{modelValue:y.value,"onUpdate:modelValue":B=>y.value=B,node:u.value,intf:y,style:{width:"100%"}},null,8,["modelValue","onUpdate:modelValue","node","intf"]))])]))),128))])]),e.renderSlot(m.$slots,"codeEditor",{node:u.value})],64)):e.createCommentVNode("",!0)],6))}});class pe extends oe{_title="Subgraph Input";inputs={_code:new x("","").use(I.setType,V).setHidden(!0),name:new f.TextInputInterface("Name","Input").setPort(!1)};outputs={_code:new x("","").use(I.setType,V).setHidden(!0),placeholder:new O.NodeInterface("Connection",void 0)}}class he extends se{_title="Subgraph Output";inputs={_code:new x("","").use(I.setType,V).setHidden(!0),name:new f.TextInputInterface("Name","Output").setPort(!1),placeholder:new O.NodeInterface("Connection",void 0)};outputs={_code:new x("","").use(I.setType,V).setHidden(!0),output:new O.NodeInterface("Output",void 0).setHidden(!0)}}const qe="CREATE_SUBGRAPH",Ye=[O.GRAPH_INPUT_NODE_TYPE,O.GRAPH_OUTPUT_NODE_TYPE];function Ke(o,t,n){const s=()=>o.value.selectedNodes.filter(i=>!Ye.includes(i.type)).length>0,a=()=>{const{viewModel:i}=f.useViewModel(),l=o.value,d=o.value.editor;if(l.selectedNodes.length===0)return;const u=l.selectedNodes.filter(g=>!Ye.includes(g.type)),p=u.flatMap(g=>Object.values(g.inputs)),b=u.flatMap(g=>Object.values(g.outputs)),C=l.connections.filter(g=>!b.includes(g.from)&&p.includes(g.to)),h=l.connections.filter(g=>b.includes(g.from)&&!p.includes(g.to)),w=l.connections.filter(g=>b.includes(g.from)&&p.includes(g.to)),k=u.map(g=>g.save()),_=w.map(g=>({id:g.id,from:g.from.id,to:g.to.id})),c=new Map,{xLeft:m,xRight:E,yTop:y}=Un(u);for(const[g,S]of C.entries()){const $=new pe;$.inputs.name.value=S.to.name,k.push({...$.save(),position:{x:E-i.value.settings.nodes.defaultWidth-100,y:y+g*200}}),_.push({id:j.v4(),from:$.outputs.placeholder.id,to:S.to.id}),c.set(S.to.id,$.graphInterfaceId)}for(const[g,S]of h.entries()){const $=new he;$.inputs.name.value=S.from.name,k.push({...$.save(),position:{x:m+100,y:y+g*200}}),_.push({id:j.v4(),from:S.from.id,to:$.inputs.placeholder.id}),c.set(S.from.id,$.graphInterfaceId)}const B=e.reactive(new z({connections:_,nodes:k,inputs:[],outputs:[]},d));d.addGraphTemplate(B);const W=d.nodeTypes.get(O.getGraphNodeTypeString(B));if(!W)throw new Error("Unable to create subgraph: Could not find corresponding graph node type");l.activeTransactions++;const P=e.reactive(new W.type);l.addNode(P);const me=Math.round(u.map(g=>g.position.x).reduce((g,S)=>g+S,0)/u.length),q=Math.round(u.map(g=>g.position.y).reduce((g,S)=>g+S,0)/u.length);P.position.x=me,P.position.y=q,C.forEach(g=>{l.removeConnection(g),l.addConnection(g.from,P.inputs[c.get(g.to.id)])}),h.forEach(g=>{l.removeConnection(g),l.addConnection(P.outputs[c.get(g.from.id)],g.to)}),u.forEach(g=>l.removeNode(g)),l.activeTransactions--,t.canExecuteCommand(f.Commands.SAVE_SUBGRAPH_COMMAND)&&t.executeCommand(f.Commands.SAVE_SUBGRAPH_COMMAND),n(B),o.value.panning={...l.panning},o.value.scaling=l.scaling};t.registerCommand(qe,{canExecute:s,execute:a})}function Un(o){const t=o.reduce((a,i)=>{const l=i.position.x;return l<a?l:a},1/0),n=o.reduce((a,i)=>{const l=i.position.y;return l<a?l:a},1/0);return{xLeft:o.reduce((a,i)=>{const l=i.position.x+i.width;return l>a?l:a},-1/0),xRight:t,yTop:n}}class Fn extends O.Editor{code;graph;constructor(t){super(),this.code=t,this.graph=new D(this)}get graphIds(){const t=[];return this.graphs.forEach(n=>t.push(n.id)),t.map(n=>n.slice(0,6)).join(", ")}get graphTemplateIds(){const t=[];return this.graphTemplates.forEach(n=>t.push(n.id)),t.map(n=>n.slice(0,6)).join(", ")}addGraphTemplate(t){if(this.events.beforeAddGraphTemplate.emit(t).prevented)return;this._graphTemplates.push(t),this.graphTemplateEvents.addTarget(t.events),this.graphTemplateHooks.addTarget(t.hooks);const n=Ie(t);this.registerNodeType(n,{category:"Subgraphs",title:t.name}),this.events.addGraphTemplate.emit(t)}load(t){try{for(super._loading=!0,t=this.hooks.load.execute(t);this.graphTemplates.length>0;)this.removeGraphTemplate(this.graphTemplates[0]);t.graphTemplates.forEach(s=>{const a=new z(s,this);this.addGraphTemplate(a)});const n=this.graph.load(t.graph);return this.events.loaded.emit(),n.forEach(s=>console.warn(s)),n}finally{super._loading=!1}}registerCategoryModule(t,n){this.code.state.modules[t]=n}}function Wn(o){const t=e.ref(o?.code??new we),n=e.ref(o?.existingEditor??new Fn(t.value)),s=Symbol("ViewModelToken"),a=e.ref(null),i=e.shallowReadonly(a),{switchGraph:l}=He(n,a),d=e.computed(()=>i.value&&i.value!==n.value.graph),u=e.reactive(f.DEFAULT_SETTINGS());u.nodes.defaultWidth=400;const p=f.useCommandHandler(),b=f.useHistory(i,p),C=f.useClipboard(i,n,p),h={renderNode:new fe.SequentialHook(null),renderInterface:new fe.SequentialHook(null)},w=e.reactive({clipboard:C,code:t,commandHandler:p,displayedGraph:i,editor:n,history:b,hooks:h,isSubgraph:d,settings:u,switchGraph:l});return t.value.registerViewModel(w),Ae(w),f.registerDeleteNodesCommand(i,p),Ke(i,p,l),f.registerSaveSubgraphCommand(i,p),f.registerSwitchToMainGraphCommand(i,p,l),f.registerSidebarCommands(i,p),f.registerZoomToFitCommands(i,p,u),Le(i,p,u),De(u),e.watch(n,(k,_)=>{_&&(_.events.registerGraph.unsubscribe(s),_.graphEvents.beforeAddNode.unsubscribe(s),k.nodeHooks.beforeLoad.unsubscribe(s),k.nodeHooks.afterSave.unsubscribe(s),k.graphTemplateHooks.beforeLoad.unsubscribe(s),k.graphTemplateHooks.afterSave.unsubscribe(s),k.graph.hooks.load.unsubscribe(s),k.graph.hooks.save.unsubscribe(s)),k&&(k.nodeHooks.beforeLoad.subscribe(s,(c,m)=>(m.position=c.position??{x:0,y:0},m.width=c.width??u.nodes.defaultWidth,m.twoColumn=c.twoColumn??!1,c)),k.nodeHooks.afterSave.subscribe(s,(c,m)=>(c.position=m.position,c.width=m.width,c.twoColumn=m.twoColumn,c)),k.graphTemplateHooks.beforeLoad.subscribe(s,(c,m)=>(m.panning=c.panning,m.scaling=c.scaling,c)),k.graphTemplateHooks.afterSave.subscribe(s,(c,m)=>(c.panning=m.panning,c.scaling=m.scaling,c)),k.graph.hooks.load.subscribe(s,(c,m)=>(m.panning=c.panning,m.scaling=c.scaling,c)),k.graph.hooks.save.subscribe(s,(c,m)=>(c.panning=m.panning,c.scaling=m.scaling,c)),k.graphEvents.beforeAddNode.subscribe(s,c=>f.setViewNodeProperties(c,{defaultWidth:u.nodes.defaultWidth})),n.value.registerNodeType(pe,{category:"Subgraphs"}),n.value.registerNodeType(he,{category:"Subgraphs"}),l(k.graph))},{immediate:!0}),w}r.AbstractCodeNode=Y,r.CLEAR_ALL_COMMAND=ae,r.CREATE_SUBGRAPH_COMMAND=qe,r.CheckboxInterface=it,r.Code=we,r.CodeEngine=Ee,r.CodeGraph=D,r.CodeGraphEditor=fn,r.CodeGraphInfo=bn,r.CodeGraphInputNode=oe,r.CodeGraphNode=Ue,r.CodeGraphNodeInterface=ce,r.CodeGraphOutputNode=se,r.CodeGraphSidebar=We,r.CodeGraphTemplate=z,r.CodeNode=A,r.CodeNodeInputInterface=L,r.CodeNodeInterface=x,r.CodeNodeInterfaceComponent=H,r.CodeNodeOutputInterface=Ce,r.CodeNodePalette=Fe,r.CodeVariable=ve,r.DotsVertical=Be,r.DynamicCodeNode=Ne,r.GRAPH_INPUT_NODE_TYPE=te,r.GRAPH_OUTPUT_NODE_TYPE=ne,r.IntegerInterface=rt,r.LayoutSidebarLeftCollapse=Te,r.LayoutSidebarLeftExpand=Oe,r.LayoutSidebarRight=xe,r.LayoutSidebarRightCollapse=Me,r.LayoutSidebarRightExpand=Se,r.ListInputInterface=lt,r.LockCode=Ve,r.NumberInterface=dt,r.PlayerPlay=$e,r.RUN_ENGINE_COMMAND=ie,r.Schema=Ge,r.SchemaOff=Re,r.SelectInterface=ct,r.SidebarCheckbox=ue,r.SliderInterface=ut,r.SubgraphInputNode=pe,r.SubgraphOutputNode=he,r.TOGGLE_MINIMAP_COMMAND=re,r.TOGGLE_PALETTE_COMMAND=le,r.TextInputInterface=bt,r.TextInputInterfaceComponent=ye,r.TextareaInputInterface=kt,r.TransitionBottom=je,r.TrashOff=Pe,r.TupleInputInterface=Ct,r.addDefaultInterfaceTypes=at,r.allowMultipleConnections=It,r.booleanType=X,r.createCodeGraphNodeType=Ie,r.defineCodeNode=yt,r.defineDynamicCodeNode=Nt,r.dictType=ke,r.formatInputs=ge,r.getCodeNodes=de,r.getPositionAtColumn=cn,r.getPositionBeforeNode=un,r.listType=J,r.loadNodeState=K,r.nodeType=V,r.numberType=U,r.registerCodeEngine=Ae,r.registerCreateSubgraphCommand=Ke,r.registerCustomCommands=Le,r.registerRunEngineCommands=ze,r.saveNodeState=be,r.stringType=F,r.tupleType=Q,r.updateToolbarItems=De,r.useCodeGraph=Wn,r.useSwitchCodeGraph=He,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(c,A){typeof exports=="object"&&typeof module<"u"?A(exports,require("mustache"),require("vue"),require("uuid"),require("@baklavajs/core"),require("@baklavajs/interface-types"),require("@baklavajs/engine"),require("@baklavajs/renderer-vue"),require("toposort"),require("@baklavajs/events"),require("@vueuse/core")):typeof define=="function"&&define.amd?define(["exports","mustache","vue","uuid","@baklavajs/core","@baklavajs/interface-types","@baklavajs/engine","@baklavajs/renderer-vue","toposort","@baklavajs/events","@vueuse/core"],A):(c=typeof globalThis<"u"?globalThis:c||self,A(c["@babsey/code-graph"]={},c.mustache,c.vue,c.uuid,c["@baklavajs/core"],c["@baklavajs/interface-types"],c["@baklavajs/engine"],c["@baklavajs/renderer-vue"],c.toposort,c["@baklavajs/events"],c["@vueuse/core"]))})(this,(function(c,A,e,F,V,S,D,N,kt,$e,_t){"use strict";A.escape=o=>o;class de extends V.AbstractNode{state;isCodeNode=!0;name="";codeTemplate;inputs={};outputs={};constructor(){super(),this.initializeIo(),this.twoColumn=!0,this.state=e.reactive({codeTemplate:"",hidden:!1,integrated:!1,lockCode:!1,modules:[],props:null,script:"",variableName:"a"}),this.codeTemplate=function(){return`${this.name}(${Pe(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 idx(){return this.graph.nodes.filter(t=>!t.state.integrated).indexOf(this)??-1}get idxByVariableNames(){return this.graph.getNodesBySameVariableNames(this.state.variableName).filter(t=>!t.state.integrated).indexOf(this)??-1}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 subgraph(){}get variableName(){return this.state.variableName?this.state.variableName+(this.idxByVariableNames+1):""}getConnectedNodeByInterface(t,n){const a=this.getConnectedNodesByInterface(t,n);return a.length>0?a[0]:null}getConnectedNodes(t){let n=[];if(t!=="inputs"){const a=this.graph.connections.filter(s=>s.from.name!=="_code").filter(s=>s.from.nodeId===this.id).map(s=>s.to.nodeId);a&&(n=n.concat(a))}if(t!=="outputs"){const a=this.graph.connections.filter(s=>s.from.name!=="_code").filter(s=>s.to.nodeId===this.id).map(s=>s.from.nodeId);a&&(n=n.concat(a))}return!n||n.length==0?[]:n.map(a=>this.graph.findNodeById(a))}getConnectedNodesByInterface(t,n){let a=[];if(n!=="outputs"&&this.inputs[t]){const s=this.graph.connections.filter(r=>r.to.id===this.inputs[t]?.id||r.from.id===this.inputs[t]?.id).map(r=>r.from.nodeId);s&&(a=a.concat(s))}if(n!=="inputs"&&this.outputs[t]){const s=this.graph.connections.filter(r=>r.from.id===this.outputs[t]?.id||r.from.id===this.outputs[t]?.id).map(r=>r.to.nodeId);s&&(a=a.concat(s))}return!a||a.length==0?[]:a.map(s=>this.graph.findNodeById(s))}registerCode(t){this.code=t}renderCode(t){return A.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}}class Z extends de{calculate=(t,n)=>{const a={};return this.lockCode||(a._code=this.renderCode({inputs:t,...n})),this.updateOutputValues(a),a};load(t){super.load(t),ue(this.graph,t)}save(){const t=super.save();return je(this.graph,t),t}}const Pe=(o,t=!0)=>{const n=[],a=Object.keys(o);return a.forEach(s=>{if(o[s]?.hidden)return;const l=t&&n.length<a.indexOf(s)?`${s}=`:"";n.push(`${l}{{ inputs.${s} }}`)}),n},ue=(o,t)=>{if(!o)return;const n=o.findNodeById(t.id);if(!n||n.subgraph)return;const a=n;a.state&&(a.state.integrated=t.integrated,a.state.modules=t.modules,a.state.props=t.props),Object.entries(t.inputs).forEach(([s,r])=>{s!=="_code"&&a.inputs[s]&&(a.inputs[s].hidden=r.hidden)}),Object.entries(t.outputs).forEach(([s,r])=>{s!=="_code"&&a.outputs[s]&&(a.outputs[s].hidden=r.hidden)})},je=(o,t)=>{if(!o)return;const n=o.findNodeById(t.id);if(!n||n.subgraph)return;const a=n;a.state&&(t.integrated=a.state.integrated,t.modules=a.state.modules),Object.entries(t.inputs).forEach(([s,r])=>{s!=="_code"&&a.inputs[s]&&(r.hidden=a.inputs[s].hidden)}),Object.entries(t.outputs).forEach(([s,r])=>{s!=="_code"&&a.outputs[s]&&(r.hidden=a.outputs[s].hidden)})},Ct=["title"],ee=e.defineComponent({__name:"CodeNodeInterface",props:{intf:{}},setup(o){return(t,n)=>(e.openBlock(),e.createElementBlock("div",{title:o.intf.value},e.toDisplayString(o.intf.name),9,Ct))}});class j extends V.NodeInterface{isCodeNode=!0;code;state;type=null;constructor(t,n){super(t,n),this.setComponent(e.markRaw(ee)),this.state=e.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 W extends j{constructor(t="",n){super(t,n),this.setComponent(e.markRaw(ee)),this.use(N.displayInSidebar,!0)}get value(){return super.value}set value(t){super.value=t,this.name!=="_code"&&this.setHidden(!1)}}const pe=new S.NodeInterfaceType("boolean"),Re=new S.NodeInterfaceType("dict"),he=new S.NodeInterfaceType("list"),G=new S.NodeInterfaceType("node"),te=new S.NodeInterfaceType("number"),ne=new S.NodeInterfaceType("string"),fe=new S.NodeInterfaceType("tuple"),Nt=o=>{new S.BaklavaInterfaceTypes(o.editor,{viewPlugin:o}).addTypes(pe,Re,he,G,te,ne,fe)};class wt extends W{constructor(t,n){super(t,n),this.setComponent(e.markRaw(N.CheckboxInterfaceComponent)),this.use(S.setType,pe)}getValue=()=>this.value?"True":"False"}class Ge extends j{isCodeNodeOutput=!0;suffix="";constructor(t="",n=""){super(t,""),this.suffix=n,this.setComponent(e.markRaw(ee))}get codeValue(){return this.node?.outputs._code.value??""}get node(){const{graph:t}=N.useGraph();return t.value.findNodeById(this.nodeId)}}class me extends W{min;max;constructor(t,n,a,s){super(t,n),this.min=a,this.max=s,this.use(S.setType,te)}validate(t){return(this.min===void 0||t>=this.min)&&(this.max===void 0||t<=this.max)}}class Et extends me{component=e.markRaw(N.IntegerInterfaceComponent);validate(t){return Number.isInteger(t)&&super.validate(t)}}class It extends W{constructor(t="",n=""){super(t,n),this.setComponent(e.markRaw(N.TextInputInterfaceComponent)),this.use(S.setType,he)}getValue=()=>`[${this.value}]`}class vt extends me{component=e.markRaw(N.NumberInterfaceComponent)}class ge extends W{constructor(t,n){super(t,n),this.use(S.setType,ne)}getValue=()=>`"${this.value}"`}class Bt extends ge{component=e.markRaw(N.SelectInterfaceComponent);items;constructor(t,n,a){super(t,n),this.items=a}}class Tt extends me{component=e.markRaw(N.SliderInterfaceComponent);min;max;constructor(t,n,a,s){super(t,n,a,s),this.min=a,this.max=s}getValue=()=>`${Math.round(this.value*1e3)/1e3}`}const xt=e.defineComponent({props:{intf:{type:Object,required:!0},modelValue:{type:String,required:!0}},emits:["update:modelValue"],setup(o,{emit:t}){return{v:e.computed({get:()=>o.modelValue,set:a=>{t("update:modelValue",a)}})}}}),$=(o,t)=>{const n=o.__vccOpts||o;for(const[a,s]of t)n[a]=s;return n},Ot={style:{position:"relative"}},St={style:{"font-size":"12px",padding:"0 6px",position:"absolute",top:"-8px","background-color":"var(--baklava-node-color-background)"}},Mt=["placeholder","title"];function Vt(o,t,n,a,s,r){return e.openBlock(),e.createElementBlock("div",Ot,[e.createElementVNode("label",St,e.toDisplayString(o.intf.name),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":t[0]||(t[0]=l=>o.v=l),type:"text",class:"baklava-input",placeholder:o.intf.name,title:o.intf.name},null,8,Mt),[[e.vModelText,o.v]])])}const Le=$(xt,[["render",Vt]]);class $t extends ge{component=e.markRaw(Le)}class Pt extends ge{component=e.markRaw(N.TextareaInputInterfaceComponent)}class jt extends W{constructor(t="",n=""){super(t,n),this.setComponent(e.markRaw(N.TextInputInterfaceComponent)),this.use(S.setType,fe)}getValue=()=>`(${this.value})`}function Rt(o){return class extends Z{type=o.type;inputs={};outputs={};constructor(){super(),this._title=o.title??o.type,this.executeFactory("input",o.inputs),this.executeFactory("output",o.outputs),o.calculate&&(this.calculate=(t,n)=>o.calculate.call(this,{inputs:t,...n})),o.onCreate?.call(this),this.name=o.name??o.type,this.updateModules(o.modules),o.variableName!=null&&(this.state.variableName=o.variableName),o.codeTemplate&&(this.codeTemplate=o.codeTemplate),this.addInput("_code",new j("",[]).use(S.setType,G).use(D.allowMultipleConnections).setHidden(!0)),this.addOutput("_code",new j("",[]).use(S.setType,G).use(D.allowMultipleConnections).setHidden(!0))}onPlaced(){o.onPlaced?.call(this)}onConnected(){o.onConnected?.call(this)}onDestroy(){o.onDestroy?.call(this)}onUnconnected(){o.onUnconnected?.call(this)}update(){o.update?.call(this)}executeFactory(t,n){Object.keys(n||{}).forEach(a=>{const s=n[a]();t==="input"?this.addInput(a,s):this.addOutput(a,s)})}}}class Ae extends Z{}function Gt(o){return class extends Ae{type=o.type;inputs={};outputs={};preventUpdate=!1;staticInputKeys=Object.keys(o.inputs??{});staticOutputKeys=Object.keys(o.outputs??{});constructor(){super(),this._title=o.title??o.type,this.executeFactory("input",o.inputs),this.executeFactory("output",o.outputs),o.calculate&&(this.calculate=(t,n)=>o.calculate?.call(this,t,n)),o.onCreate?.call(this),this.name=o.name??o.type,this.updateModules(o.modules),o.codeTemplate&&(this.codeTemplate=o.codeTemplate),o.variableName&&(this.state.variableName=o.variableName),this.addInput("_code",new j("",[]).use(S.setType,G).use(D.allowMultipleConnections).setHidden(!0)),this.addOutput("_code",new j("",[]).use(S.setType,G).use(D.allowMultipleConnections).setHidden(!0)),this.staticInputKeys.push("_code"),this.staticOutputKeys.push("_code")}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(),o.onPlaced?.call(this)}onConnected(){o.onConnected?.call(this)}onDestroy(){o.onDestroy?.call(this)}onUnconnected(){o.onUnconnected?.call(this)}update(){o.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)){if(!this.inputs[n]){const a=t.inputs[n].value;let s;typeof a=="number"?s=new N.IntegerInterface(n,a).use(S.setType,te):s=new N.TextInputInterface(n,JSON.stringify(a)).use(S.setType,ne),s.use(N.displayInSidebar,!0),this.addInput(n,s)}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)){if(!this.outputs[n]){const a=new Ge(n);this.addOutput(n,a)}this.outputs[n]&&(this.outputs[n].load(t.outputs[n]),this.outputs[n].nodeId=this.id)}ue(this.graph,t),this.preventUpdate=!1,this.events.loaded.emit(this)}onUpdate(){if(this.preventUpdate)return;this.graph&&this.graph.activeTransactions++;const t=this.getStaticValues(this.staticInputKeys,this.inputs),n=this.getStaticValues(this.staticOutputKeys,this.outputs),a=o.onUpdate.call(this,t,n);this.updateInterfaces("input",a.inputs??{},a.forceUpdateInputs??[]),this.updateInterfaces("output",a.outputs??{},a.forceUpdateOutputs??[]),this.graph&&this.graph.activeTransactions--}getStaticValues(t,n){const a={};for(const s of t)a[s]=n[s].value;return a}updateInterfaces(t,n,a){const s=t==="input"?this.staticInputKeys:this.staticOutputKeys,r=t==="input"?this.inputs:this.outputs;for(const l of Object.keys(r))s.includes(l)||n[l]&&!a.includes(l)||(t==="input"?this.removeInput(l):this.removeOutput(l));for(const l of Object.keys(n)){if(r[l])continue;const i=n[l]();t==="input"?this.addInput(l,i):this.addOutput(l,i)}}updateProps(t){this.state.props=t,this.onUpdate()}executeFactory(t,n){Object.keys(n||{}).forEach(a=>{const s=n[a]();t==="input"?this.addInput(a,s):this.addOutput(a,s)})}}}const be="__baklava_SubgraphInputNode",ye="__baklava_SubgraphOutputNode";class De extends Z{graphInterfaceId;constructor(){super(),this.graphInterfaceId=F.v4()}onPlaced(){super.onPlaced(),this.initializeIo()}load(t){super.load(t),this.graphInterfaceId=t.graphInterfaceId}save(){return{...super.save(),graphInterfaceId:this.graphInterfaceId}}update(){}}class ke extends De{static isGraphInputNode(t){return t.type===be}type=be;inputs={name:new V.NodeInterface("Name","Input")};outputs={placeholder:new V.NodeInterface("Value",void 0)}}class _e extends De{static isGraphOutputNode(t){return t.type===ye}type=ye;inputs={name:new V.NodeInterface("Name","Output"),placeholder:new V.NodeInterface("Value",void 0)};outputs={output:new V.NodeInterface("Output",void 0).setHidden(!0)};calculate=({placeholder:t})=>({output:t})}const Lt=["component","connectionCount","events","hidden","hooks","id","isCodeNode","isInput","name","nodeId","port","templateId","value"];function ze(o){return class extends de{type=V.getGraphNodeTypeString(o);get title(){return this._title}set title(n){this.template.name=n}inputs={};outputs={};template=o;subgraph;update(){}onConnected(){}onUnconnected(){}calculate=async(n,a)=>{if(!this.subgraph)throw new Error(`GraphNode ${this.id}: calculate called without subgraph being initialized`);if(!a.engine||typeof a.engine!="object")throw new Error(`GraphNode ${this.id}: calculate called but no engine provided in context`);const s=a.engine.getInputValues(this.subgraph);for(const i of this.subgraph.inputs)s.set(i.nodeInterfaceId,n[i.id]);const r=await a.engine.runGraph(this.subgraph,s,a.globalValues);a.engine.pause(),D.applyResult(r,a.engine.editor),a.engine.resume();const l={};for(const i of this.subgraph.outputs)l[i.id]=r.get(i.nodeId)?.get("output");return l._calculationResults=r,this.lockCode||(l._code=this.renderCode({inputs:n,...a.globalValues})),this.updateOutputValues(l),l};load(n){if(!this.subgraph)throw new Error("Cannot load a graph node without a graph");if(!this.template)throw new Error("Unable to load graph node without graph template");this.subgraph.load(n.graphState),super.load(n)}save(){if(!this.subgraph)throw new Error("Cannot save a graph node without a graph");return{...super.save(),graphState:this.subgraph.save()}}onPlaced(){this.template.events.updated.subscribe(this,()=>this.initialize()),this.template.events.nameChanged.subscribe(this,n=>{this._title=n}),this.initialize()}onDestroy(){this.template.events.updated.unsubscribe(this),this.template.events.nameChanged.unsubscribe(this),this.subgraph?.destroy()}initialize(){this.subgraph&&this.subgraph.destroy(),this.subgraph=this.template.createGraph(),this._title=this.template.name,this.updateInterfaces(),this.state.codeTemplate=`{{ #nodes }}{{ script }}
|
|
2
|
+
{{ /nodes }}`,this.events.update.emit(null)}renderCode(n){return this.subgraph?this.subgraph.renderCode({nodes:this.subgraph.scriptedCodeNodes}):A.render(this.state.codeTemplate,n)}updateInterfaces(){if(!this.subgraph)throw new Error("Trying to update interfaces without graph instance");for(const n of this.subgraph.inputs)n.id in this.inputs?this.inputs[n.id].name=n.name:this.addInput(n.id,this.createProxyInterface(n,!0));for(const n of Object.keys(this.inputs))this.subgraph.inputs.some(a=>a.id===n)||this.removeInput(n);for(const n of this.subgraph.outputs)n.id in this.outputs?this.outputs[n.id].name=n.name:this.addOutput(n.id,this.createProxyInterface(n,!1));for(const n of Object.keys(this.outputs))this.subgraph.outputs.some(a=>a.id===n)||this.removeOutput(n);this.addInput("_code",new j("",[]).use(S.setType,G).use(D.allowMultipleConnections).setHidden(!0)),this.addOutput("_code",new j("",[]).use(S.setType,G).use(D.allowMultipleConnections).setHidden(!0)),this.addOutput("_calculationResults",new V.NodeInterface("_calculationResults",void 0).setHidden(!0))}createProxyInterface(n,a){const s=new j(n.name,void 0);return new Proxy(s,{get:(r,l)=>{if(Lt.includes(l)||l in r||typeof l=="string"&&l.startsWith("__v_"))return Reflect.get(r,l);let i;a?i=this.subgraph?.nodes.find(_=>ke.isGraphInputNode(_)&&_.graphInterfaceId===n.id)?.outputs.placeholder.id:i=this.subgraph?.nodes.find(_=>_e.isGraphOutputNode(_)&&_.graphInterfaceId===n.id)?.inputs.placeholder.id;const d=this.subgraph?.connections.find(m=>i===(a?m.from:m.to)?.id),p=a?d?.to:d?.from;if(p)return Reflect.get(p,l)}})}}}A.escape=o=>o;class oe{_id;_state;viewModel;constructor(){this._id=F.v4(),this._state=e.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=A.render(this.state.template||"",t)}}class At extends oe{constructor(){super(),this.loadTemplate(Promise.resolve().then(()=>zo))}}class Dt extends oe{constructor(){super(),this.loadTemplate(Promise.resolve().then(()=>Ho))}}const zt=o=>{o.allowMultipleConnections=!0};class He extends D.BaseEngine{order=new Map;constructor(t){super(t)}start(){super.start(),this.recalculateOrder=!0,this.calculateWithoutData()}async runGraph(t,n,a){this.order.has(t.id)||this.order.set(t.id,D.sortTopologically(t));const{calculationOrder:s,connectionsFromNode:r}=this.order.get(t.id),l=new Map;for(const i of s){const d={};Object.entries(i.inputs).forEach(([m,_])=>{d[m]=this.getInterfaceValue(n,_.id)}),i.isCodeNode&&(i.updateCodeTemplate(),i.updateOutputNames()),this.events.beforeNodeCalculation.emit({inputValues:d,node:i});let p;if(i.calculate){if(p=await i.calculate(d,{globalValues:a,engine:this}),r.has(i))for(const[m,_]of Object.entries(p))this.hooks.transferData.execute(p[m],_),r.get(i).forEach(f=>n.set(f.to.id,_))}else{p={};for(const[m,_]of Object.entries(i.outputs))p[m]=this.getInterfaceValue(n,_.id)}this.events.afterNodeCalculation.emit({outputValues:p,node:i}),l.set(i.id,new Map(Object.entries(p))),r.has(i)&&r.get(i).forEach(m=>{const _=Object.entries(i.outputs).find(([,v])=>v.id===m.from.id)?.[0];if(!_)throw new Error(`Could not find key for interface ${m.from.id}
|
|
3
|
+
This is likely an internal issue. Please report it on GitHub.`);const f=this.hooks.transferData.execute(p[_],m);m.to.allowMultipleConnections?n.has(m.to.id)?n.get(m.to.id).push(f):n.set(m.to.id,[f]):n.set(m.to.id,f)})}return l}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 a of t.nodes)Object.values(a.inputs).forEach(s=>{s.connectionCount===0&&n.set(s.id,s.getValue?s.getValue():s.value)}),a.calculate||Object.values(a.outputs).forEach(s=>{n.set(s.id,s.getValue?s.getValue():s.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}
|
|
4
|
+
This is likely an internal issue. Please report it on GitHub.`);return t.get(n)}}const Ht={},Ut={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 Ft(o,t){return e.openBlock(),e.createElementBlock("svg",Ut,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.createElementVNode("path",{d:"M5 12l5 5l10 -10"},null,-1)])])}const Ue=$(Ht,[["render",Ft]]),qt={},Wt={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 Yt(o,t){return e.openBlock(),e.createElementBlock("svg",Wt,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.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 Fe=$(qt,[["render",Yt]]),Kt={},Xt={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 Jt(o,t){return e.openBlock(),e.createElementBlock("svg",Xt,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.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),e.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 qe=$(Kt,[["render",Jt]]),Qt={},Zt={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 en(o,t){return e.openBlock(),e.createElementBlock("svg",Zt,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.createElementVNode("path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"},null,-1),e.createElementVNode("path",{d:"M12 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"},null,-1),e.createElementVNode("path",{d:"M12 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"},null,-1)])])}const We=$(Qt,[["render",en]]),tn={},nn={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 on(o,t){return e.openBlock(),e.createElementBlock("svg",nn,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.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 Ye=$(tn,[["render",on]]),sn={},an={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 rn(o,t){return e.openBlock(),e.createElementBlock("svg",an,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.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 Ke=$(sn,[["render",rn]]),ln={},cn={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 dn(o,t){return e.openBlock(),e.createElementBlock("svg",cn,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.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 Xe=$(ln,[["render",dn]]),un={},pn={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 hn(o,t){return e.openBlock(),e.createElementBlock("svg",pn,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.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 Je=$(un,[["render",hn]]),fn={},mn={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 gn(o,t){return e.openBlock(),e.createElementBlock("svg",mn,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.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 Qe=$(fn,[["render",gn]]),bn={},yn={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 kn(o,t){return e.openBlock(),e.createElementBlock("svg",yn,[...t[0]||(t[0]=[e.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 Ce=$(bn,[["render",kn]]),_n={},Cn={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 Nn(o,t){return e.openBlock(),e.createElementBlock("svg",Cn,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.createElementVNode("path",{d:"M7 4v16l13 -8z"},null,-1)])])}const Ze=$(_n,[["render",Nn]]),wn={},En={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 In(o,t){return e.openBlock(),e.createElementBlock("svg",En,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.createElementVNode("path",{d:"M12 5l0 14"},null,-1),e.createElementVNode("path",{d:"M5 12l14 0"},null,-1)])])}const et=$(wn,[["render",In]]),vn={},Bn={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 Tn(o,t){return e.openBlock(),e.createElementBlock("svg",Bn,[...t[0]||(t[0]=[e.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 tt=$(vn,[["render",Tn]]),xn={},On={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 Sn(o,t){return e.openBlock(),e.createElementBlock("svg",On,[...t[0]||(t[0]=[e.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 nt=$(xn,[["render",Sn]]),Mn={},Vn={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 $n(o,t){return e.openBlock(),e.createElementBlock("svg",Vn,[...t[0]||(t[0]=[e.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 ot=$(Mn,[["render",$n]]),Pn={},jn={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-trash-off"};function Rn(o,t){return e.openBlock(),e.createElementBlock("svg",jn,[...t[0]||(t[0]=[e.createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M3 3l18 18"></path><path d="M4 7h3m4 0h9"></path><path d="M10 11l0 6"></path><path d="M14 14l0 3"></path><path d="M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l.077 -.923"></path><path d="M18.384 14.373l.616 -7.373"></path><path d="M9 5v-1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3"></path>',8)])])}const st=$(Pn,[["render",Rn]]),Gn={},Ln={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 An(o,t){return e.openBlock(),e.createElementBlock("svg",Ln,[...t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.createElementVNode("path",{d:"M18 6l-12 12"},null,-1),e.createElementVNode("path",{d:"M6 6l12 12"},null,-1)])])}const at=$(Gn,[["render",An]]),Ne="CLEAR_ALL",we="RUN_ENGINE",Ee="TOGGLE_MINIMAP",Ie="TOGGLE_PALETTE",rt=(o,t,n)=>{const a=n.zoomToFit.paddingLeft;t.registerCommand(Ie,{execute:()=>{n.palette.enabled=!n.palette.enabled,n.zoomToFit.paddingLeft=n.palette.enabled?a:50},canExecute:()=>!0}),t.registerCommand(Ne,{execute:()=>o.value.clear(),canExecute:()=>o.value.nodes.length>0}),t.registerCommand(Ee,{execute:()=>n.enableMinimap=!n.enableMinimap,canExecute:()=>o.value.nodes.length>1})},it=o=>{const t={command:we,title:"Run",icon:e.computed(()=>Ze)},n={command:Ie,title:"Toggle palette",icon:e.computed(()=>o.palette.enabled?Ye:Ke)},a={command:Ne,title:"Clear all",icon:e.computed(()=>st)},s={command:Ee,title:"Toggle minimap",icon:e.computed(()=>o.enableMinimap?nt:tt)};o.toolbar.commands=[n,t,...N.DEFAULT_TOOLBAR_COMMANDS,a,s]},lt=(o,t)=>{t.registerCommand(we,{execute:()=>o.runOnce(null),canExecute:()=>!0})};function ct(o){const t=Symbol("CodeEngineToken");o.engine=new He(o.editor),lt(o.engine,o.commandHandler),o.loadEditor=n=>{o.engine?.pause(),o.displayedGraph.clear(),o.editor.load(n),o.commandHandler.executeCommand(N.Commands.CLEAR_CLIPBOARD_COMMAND),o.commandHandler.executeCommand(N.Commands.CLEAR_HISTORY_COMMAND),o.engine?.resume(),o.engine?.runOnce(null)},o.newGraph=()=>{o.engine?.pause(),o.displayedGraph.clear(),o.commandHandler.executeCommand(N.Commands.CLEAR_CLIPBOARD_COMMAND),o.commandHandler.executeCommand(N.Commands.CLEAR_HISTORY_COMMAND),o.displayedGraph.id=F.v4(),o.engine?.resume(),o.engine?.runOnce(null)},o.subscribe=()=>{o.displayedGraph.events.addConnection.subscribe(t,n=>{const a=o.displayedGraph.findNodeById(n.to.nodeId);a&&a.isCodeNode&&a.onConnected();const s=o.displayedGraph.findNodeById(n.from.nodeId);s&&s.isCodeNode&&s.onConnected()}),o.displayedGraph.events.removeConnection.subscribe(t,n=>{const a=o.displayedGraph.findNodeById(n.to.nodeId);a&&a.isCodeNode&&a.onUnconnected();const s=o.displayedGraph.findNodeById(n.from.nodeId);s&&s.isCodeNode&&s.onUnconnected()}),o.engine?.events.beforeRun.subscribe(t,()=>{o.engine?.pause(),o.displayedGraph.sortNodes(),o.engine?.resume()}),o.engine?.events.afterRun.subscribe(t,n=>{o.engine?.pause(),D.applyResult(n,o.editor),o.code.state.lockCode||o.code.renderCode({nodes:o.editor.graph.scriptedCodeNodes,modules:o.editor.code.modules}),o.engine?.resume()})},o.unsubscribe=()=>{o.displayedGraph.events.addConnection.unsubscribe(t),o.displayedGraph.events.removeConnection.unsubscribe(t),o.engine?.events.beforeRun.unsubscribe(t),o.engine?.events.afterRun.unsubscribe(t)}}class K extends V.Graph{code=null;editor;_state=e.reactive({codeTemplate:"{{ #nodes }}{{ script }}{{ /nodes }}",lockCode:!1});constructor(t,n){super(t,n),this.editor=t,this.template=n,t.code&&(this.code=t.code)}get codeNodes(){return ve(this)}get connections(){return super.connections}set connections(t){this._connections=t}get nodeIds(){return this.nodes.map(t=>t.id)}get nodes(){return super.nodes}set nodes(t){this._nodes=t}get scriptedCodeNodes(){return this.nodes.filter(t=>!t.state?.integrated)}get shortId(){return this.id.slice(0,6)}get state(){return this._state}get visibleNodes(){return this.nodes.filter(t=>!t.state?.hidden)}addNodeAtCoordinates=(t,n={x:0,y:0},a)=>(this.addNode(t,a),t.position&&(t.position=n),t);addConnection(t,n){t?.name!=="_code"&&(t.hidden=!1),n?.name!=="_code"&&(n.hidden=!1),super.addConnection(t,n)}clear(){this.selectedNodes=[],this._nodes=[],this._connections=[]}findNodeByType(t){return this.nodes.find(n=>n.type===t)}getNodesBySameType(t){return this.nodes.filter(n=>n.type===t)}getNodesBySameVariableNames(t){return this.nodes.filter(n=>n.state?.variableName===t)}hasConnection(t,n){return this.connections.some(a=>a.from.id===t.id&&a.to.id===n.id)}renderCode(t){return A.render(this.state?.codeTemplate||"",t)}sortNodes(){if(!(this.nodes.length===0||this.connections.length===0))try{let t=this.nodeIds;const n=this.connections.filter(r=>t.includes(r.to.nodeId)&&t.includes(r.from.nodeId)).map(r=>[r.to.nodeId,r.from.nodeId]);t.reverse(),t=kt.array(t,n),t.reverse();const a=this.nodes.map(r=>r.id).filter(r=>!t.includes(r));t=[...t,...a];const s=t.map(r=>this.findNodeById(r));s&&(this.nodes=s)}catch{console.warn("Failed to sort nodes.")}}}const ve=o=>{const t=[];return o.nodes.length===0||o.nodes.forEach(n=>{n&&(n.hasOwnProperty("subgraph")?t.push(...ve(n.subgraph)):n.hasOwnProperty("isCodeNode")&&t.push(n))}),t},Dn=(o=0,t=100)=>({x:o*420,y:t}),zn=o=>{const t={...o.position};return t.x-=440,t.y+=50,t};function Hn(o,t){return Object.fromEntries(Object.entries(o).filter(t))}function Un(o,t){return Object.fromEntries(Object.entries(o).map(([n,a])=>[n,t(a)]))}class X extends V.GraphTemplate{static fromGraph(t,n){return new X(t.save(),n)}constructor(t,n){super(t,n)}get shortId(){return this.id.slice(0,6)}createGraph(t){const n=new Map,a=f=>{const v=F.v4();return n.set(f,v),v},s=f=>{const v=n.get(f);if(!v)throw new Error(`Unable to create graph from template: Could not map old id ${f} to new id`);return v},r=f=>Un(f,v=>({id:a(v.id),templateId:v.id,value:v.value})),l=this.nodes.map(f=>({...f,id:a(f.id),inputs:r(f.inputs),outputs:r(f.outputs)})),i=this.connections.map(f=>({id:a(f.id),from:s(f.from),to:s(f.to)})),d=this.inputs.map(f=>({id:f.id,name:f.name,nodeId:s(f.nodeId),nodeInterfaceId:s(f.nodeInterfaceId)})),p=this.outputs.map(f=>({id:f.id,name:f.name,nodeId:s(f.nodeId),nodeInterfaceId:s(f.nodeInterfaceId)})),m={id:F.v4(),nodes:l,connections:i,inputs:d,outputs:p};return t||(t=new K(this.editor)),t.load(m).forEach(f=>console.warn(f)),t.template=this,t}}const Fn=o=>!(o instanceof K);function dt(o,t){return{switchGraph:a=>{let s;if(Fn(a))s=new K(o.value),a.createGraph(s);else{if(a!==o.value.graph)throw new Error("Can only switch using 'Graph' instance when it is the root graph. Otherwise a 'GraphTemplate' must be used.");s=a}t.value&&t.value!==o.value.graph&&t.value.destroy(),s.panning=s.panning??a.panning??{x:0,y:0},s.scaling=s.scaling??a.scaling??1,s.selectedNodes=s.selectedNodes??[],s.sidebar=s.sidebar??{visible:!1,nodeId:"",optionName:""},t.value=s,s.code?.engine?.runOnce(null)}}}function qn(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var se={exports:{}};var Wn=se.exports,ut;function Yn(){return ut||(ut=1,(function(o,t){(function(a,s){o.exports=s()})(Wn,function(){return(function(){var n={686:(function(r,l,i){i.d(l,{default:function(){return x}});var d=i(279),p=i.n(d),m=i(370),_=i.n(m),f=i(817),v=i.n(f);function g(b){try{return document.execCommand(b)}catch{return!1}}var C=function(h){var k=v()(h);return g("cut"),k},u=C;function y(b){var h=document.documentElement.getAttribute("dir")==="rtl",k=document.createElement("textarea");k.style.fontSize="12pt",k.style.border="0",k.style.padding="0",k.style.margin="0",k.style.position="absolute",k.style[h?"right":"left"]="-9999px";var E=window.pageYOffset||document.documentElement.scrollTop;return k.style.top="".concat(E,"px"),k.setAttribute("readonly",""),k.value=b,k}var O=function(h,k){var E=y(h);k.container.appendChild(E);var I=v()(E);return g("copy"),E.remove(),I},T=function(h){var k=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body},E="";return typeof h=="string"?E=O(h,k):h instanceof HTMLInputElement&&!["text","search","url","tel","password"].includes(h?.type)?E=O(h.value,k):(E=v()(h),g("copy")),E},M=T;function H(b){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?H=function(k){return typeof k}:H=function(k){return k&&typeof Symbol=="function"&&k.constructor===Symbol&&k!==Symbol.prototype?"symbol":typeof k},H(b)}var U=function(){var h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},k=h.action,E=k===void 0?"copy":k,I=h.container,B=h.target,L=h.text;if(E!=="copy"&&E!=="cut")throw new Error('Invalid "action" value, use either "copy" or "cut"');if(B!==void 0)if(B&&H(B)==="object"&&B.nodeType===1){if(E==="copy"&&B.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if(E==="cut"&&(B.hasAttribute("readonly")||B.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(L)return M(L,{container:I});if(B)return E==="cut"?u(B):M(B,{container:I})},J=U;function z(b){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?z=function(k){return typeof k}:z=function(k){return k&&typeof Symbol=="function"&&k.constructor===Symbol&&k!==Symbol.prototype?"symbol":typeof k},z(b)}function w(b,h){if(!(b instanceof h))throw new TypeError("Cannot call a class as a function")}function P(b,h){for(var k=0;k<h.length;k++){var E=h[k];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(b,E.key,E)}}function R(b,h,k){return h&&P(b.prototype,h),k&&P(b,k),b}function ae(b,h){if(typeof h!="function"&&h!==null)throw new TypeError("Super expression must either be null or a function");b.prototype=Object.create(h&&h.prototype,{constructor:{value:b,writable:!0,configurable:!0}}),h&&Q(b,h)}function Q(b,h){return Q=Object.setPrototypeOf||function(E,I){return E.__proto__=I,E},Q(b,h)}function Me(b){var h=Ve();return function(){var E=q(b),I;if(h){var B=q(this).constructor;I=Reflect.construct(E,arguments,B)}else I=E.apply(this,arguments);return re(this,I)}}function re(b,h){return h&&(z(h)==="object"||typeof h=="function")?h:ie(b)}function ie(b){if(b===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return b}function Ve(){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 q(b){return q=Object.setPrototypeOf?Object.getPrototypeOf:function(k){return k.__proto__||Object.getPrototypeOf(k)},q(b)}function Y(b,h){var k="data-clipboard-".concat(b);if(h.hasAttribute(k))return h.getAttribute(k)}var le=(function(b){ae(k,b);var h=Me(k);function k(E,I){var B;return w(this,k),B=h.call(this),B.resolveOptions(I),B.listenClick(E),B}return R(k,[{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=z(I.container)==="object"?I.container:document.body}},{key:"listenClick",value:function(I){var B=this;this.listener=_()(I,"click",function(L){return B.onClick(L)})}},{key:"onClick",value:function(I){var B=I.delegateTarget||I.currentTarget,L=this.action(B)||"copy",ce=J({action:L,container:this.container,target:this.target(B),text:this.text(B)});this.emit(ce?"success":"error",{action:L,text:ce,trigger:B,clearSelection:function(){B&&B.focus(),window.getSelection().removeAllRanges()}})}},{key:"defaultAction",value:function(I){return Y("action",I)}},{key:"defaultTarget",value:function(I){var B=Y("target",I);if(B)return document.querySelector(B)}},{key:"defaultText",value:function(I){return Y("text",I)}},{key:"destroy",value:function(){this.listener.destroy()}}],[{key:"copy",value:function(I){var B=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body};return M(I,B)}},{key:"cut",value:function(I){return u(I)}},{key:"isSupported",value:function(){var I=arguments.length>0&&arguments[0]!==void 0?arguments[0]:["copy","cut"],B=typeof I=="string"?[I]:I,L=!!document.queryCommandSupported;return B.forEach(function(ce){L=L&&!!document.queryCommandSupported(ce)}),L}}]),k})(p()),x=le}),828:(function(r){var l=9;if(typeof Element<"u"&&!Element.prototype.matches){var i=Element.prototype;i.matches=i.matchesSelector||i.mozMatchesSelector||i.msMatchesSelector||i.oMatchesSelector||i.webkitMatchesSelector}function d(p,m){for(;p&&p.nodeType!==l;){if(typeof p.matches=="function"&&p.matches(m))return p;p=p.parentNode}}r.exports=d}),438:(function(r,l,i){var d=i(828);function p(f,v,g,C,u){var y=_.apply(this,arguments);return f.addEventListener(g,y,u),{destroy:function(){f.removeEventListener(g,y,u)}}}function m(f,v,g,C,u){return typeof f.addEventListener=="function"?p.apply(null,arguments):typeof g=="function"?p.bind(null,document).apply(null,arguments):(typeof f=="string"&&(f=document.querySelectorAll(f)),Array.prototype.map.call(f,function(y){return p(y,v,g,C,u)}))}function _(f,v,g,C){return function(u){u.delegateTarget=d(u.target,v),u.delegateTarget&&C.call(f,u)}}r.exports=m}),879:(function(r,l){l.node=function(i){return i!==void 0&&i instanceof HTMLElement&&i.nodeType===1},l.nodeList=function(i){var d=Object.prototype.toString.call(i);return i!==void 0&&(d==="[object NodeList]"||d==="[object HTMLCollection]")&&"length"in i&&(i.length===0||l.node(i[0]))},l.string=function(i){return typeof i=="string"||i instanceof String},l.fn=function(i){var d=Object.prototype.toString.call(i);return d==="[object Function]"}}),370:(function(r,l,i){var d=i(879),p=i(438);function m(g,C,u){if(!g&&!C&&!u)throw new Error("Missing required arguments");if(!d.string(C))throw new TypeError("Second argument must be a String");if(!d.fn(u))throw new TypeError("Third argument must be a Function");if(d.node(g))return _(g,C,u);if(d.nodeList(g))return f(g,C,u);if(d.string(g))return v(g,C,u);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function _(g,C,u){return g.addEventListener(C,u),{destroy:function(){g.removeEventListener(C,u)}}}function f(g,C,u){return Array.prototype.forEach.call(g,function(y){y.addEventListener(C,u)}),{destroy:function(){Array.prototype.forEach.call(g,function(y){y.removeEventListener(C,u)})}}}function v(g,C,u){return p(document.body,g,C,u)}r.exports=m}),817:(function(r){function l(i){var d;if(i.nodeName==="SELECT")i.focus(),d=i.value;else if(i.nodeName==="INPUT"||i.nodeName==="TEXTAREA"){var p=i.hasAttribute("readonly");p||i.setAttribute("readonly",""),i.select(),i.setSelectionRange(0,i.value.length),p||i.removeAttribute("readonly"),d=i.value}else{i.hasAttribute("contenteditable")&&i.focus();var m=window.getSelection(),_=document.createRange();_.selectNodeContents(i),m.removeAllRanges(),m.addRange(_),d=m.toString()}return d}r.exports=l}),279:(function(r){function l(){}l.prototype={on:function(i,d,p){var m=this.e||(this.e={});return(m[i]||(m[i]=[])).push({fn:d,ctx:p}),this},once:function(i,d,p){var m=this;function _(){m.off(i,_),d.apply(p,arguments)}return _._=d,this.on(i,_,p)},emit:function(i){var d=[].slice.call(arguments,1),p=((this.e||(this.e={}))[i]||[]).slice(),m=0,_=p.length;for(m;m<_;m++)p[m].fn.apply(p[m].ctx,d);return this},off:function(i,d){var p=this.e||(this.e={}),m=p[i],_=[];if(m&&d)for(var f=0,v=m.length;f<v;f++)m[f].fn!==d&&m[f].fn._!==d&&_.push(m[f]);return _.length?p[i]=_:delete p[i],this}},r.exports=l,r.exports.TinyEmitter=l})},a={};function s(r){if(a[r])return a[r].exports;var l=a[r]={exports:{}};return n[r](l,l.exports,s),l.exports}return(function(){s.n=function(r){var l=r&&r.__esModule?function(){return r.default}:function(){return r};return s.d(l,{a:l}),l}})(),(function(){s.d=function(r,l){for(var i in l)s.o(l,i)&&!s.o(r,i)&&Object.defineProperty(r,i,{enumerable:!0,get:l[i]})}})(),(function(){s.o=function(r,l){return Object.prototype.hasOwnProperty.call(r,l)}})(),s(686)})().default})})(se)),se.exports}var Kn=Yn();const Xn=qn(Kn),Jn=o=>({toClipboard(t,n){return new Promise((a,s)=>{const r=document.createElement("button"),l=new Xn(r,{text:()=>t,action:()=>"copy",container:n!==void 0?n:document.body});l.on("success",i=>{l.destroy(),a(i)}),l.on("error",i=>{l.destroy(),s(i)}),document.body.appendChild(r),r.click(),document.body.removeChild(r)})}}),Qn={key:0,class:"baklava-button"},pt=e.defineComponent({__name:"CopyToClipboard",props:{text:String},setup(o){const{toClipboard:t}=Jn(),n=o,a=e.toRef(n,"text"),s=e.ref(!1),r=async()=>{try{await t(a.value),s.value=!0,setTimeout(()=>s.value=!1,1500),console.log("Copied to clipboard")}catch(l){console.error(l)}};return(l,i)=>(e.openBlock(),e.createElementBlock("div",null,[s.value?(e.openBlock(),e.createElementBlock("button",Qn,[e.createVNode(e.unref(Ue))])):(e.openBlock(),e.createElementBlock("button",{key:1,onClick:r,class:"baklava-button"},[e.createVNode(e.unref(qe))]))]))}}),Zn={class:"code-editor"},eo={class:"code-buttons"},to=e.defineComponent({__name:"CodeEditor",props:e.mergeModels({locked:{type:Boolean},extensions:{}},{modelValue:{required:!0,type:String},modelModifiers:{}}),emits:e.mergeModels(["update:locked"],["update:modelValue"]),setup(o,{emit:t}){const n=e.useModel(o,"modelValue"),a=t,s=r=>a("update:locked",r);return(r,l)=>{const i=e.resolveComponent("codemirror");return e.openBlock(),e.createElementBlock("div",Zn,[e.createElementVNode("div",eo,[o.locked?(e.openBlock(),e.createElementBlock("button",{key:0,class:"baklava-button",title:"The code is locked.",onClick:l[0]||(l[0]=d=>s(!1))},[e.createVNode(e.unref(Ce))])):e.createCommentVNode("",!0),e.createVNode(pt,{text:o.modelValue},null,8,["text"])]),e.createVNode(i,{modelValue:n.value,"onUpdate:modelValue":l[1]||(l[1]=d=>n.value=d),extensions:o.extensions,class:"codemirror",style:{height:"100%"},onKeydown:l[2]||(l[2]=d=>s(!0))},null,8,["modelValue","extensions"])])}}}),no=e.defineComponent({__name:"CodeGraphEditor",props:{viewModel:{}},setup(o){const t=o,n=e.toRef(t,"viewModel"),a=s=>s.events.update.emit(null);return e.onMounted(()=>{n.value.subscribe&&n.value.subscribe(),n.value.engine?.start()}),e.onBeforeUnmount(()=>{n.value.unsubscribe&&n.value.unsubscribe(),n.value.engine?.stop()}),e.watch(n,(s,r)=>{r&&r.unsubscribe(),s&&s.subscribe()}),(s,r)=>(e.openBlock(),e.createBlock(e.unref(N.BaklavaEditor),{viewModel:n.value},{palette:e.withCtx(()=>[e.createVNode(e.unref(mt))]),node:e.withCtx(l=>[e.createVNode(e.unref(ht),e.mergeProps(l,{onUpdate:i=>a(l.node)}),null,16,["onUpdate"])]),sidebar:e.withCtx(l=>[e.createVNode(e.unref(ft),e.normalizeProps(e.guardReactiveProps(l)),{codeEditor:e.withCtx(({node:i})=>[e.renderSlot(s.$slots,"sidebarCodeEditor",{node:i})]),_:3},16)]),_:3},8,["viewModel"]))}}),oo={class:"code-graph-info"},so=e.defineComponent({__name:"CodeGraphInfo",props:{viewModel:{}},setup(o){return(t,n)=>(e.openBlock(),e.createElementBlock("div",oo,[e.createElementVNode("div",null,"Editor graph: "+e.toDisplayString(o.viewModel.editor.graph.shortId),1),e.createElementVNode("div",null,"Displayed graph: "+e.toDisplayString(o.viewModel.displayedGraph.shortId),1),e.createElementVNode("div",null,"Graphs: "+e.toDisplayString(o.viewModel.editor.graphIds),1),e.createElementVNode("div",null,"Graph templates: "+e.toDisplayString(o.viewModel.editor.graphTemplateIds),1),e.createElementVNode("div",null,"Engine status: "+e.toDisplayString(o.viewModel.engine?.status),1)]))}}),ao=["id","data-node-type"],ro={class:"__title-label",style:{"flex-grow":"1"}},io={key:0},lo={class:"__menu",style:{display:"flex"}},co={class:"__outputs"},uo={key:0},po=["id","title"],ho={class:"__inputs"},fo={key:0},mo=["id","title"],ht=e.defineComponent({__name:"CodeGraphNode",props:{node:{},selected:{type:Boolean,default:!1},dragging:{type:Boolean}},emits:["select","start-drag","update"],setup(o,{emit:t}){const n=N.Components.ContextMenu,a=N.Components.NodeInterface,s=o,r=e.computed(()=>s.node),l=t,{viewModel:i}=N.useViewModel(),{graph:d,switchGraph:p}=N.useGraph(),m=e.ref(null),_=e.ref(!1),f=e.ref(""),v=e.ref(null),g=e.ref(!1);let C=0,u=0;const y=e.ref(!1),O=e.computed(()=>{const x=[{value:"edit",label:"Edit"},{value:"rename",label:"Rename"},{value:"delete",label:"Delete"}];return s.node.type.startsWith(V.GRAPH_NODE_TYPE_PREFIX)&&x.push({value:"editSubgraph",label:"Edit Subgraph"}),x}),T=e.computed(()=>({"--selected":s.selected,"--dragging":s.dragging,"--two-column":!!s.node.twoColumn,"--hidden":r.value.state?.hidden})),M=e.computed(()=>({"--reverse-y":s.node.reverseY??i.value.settings.nodes.reverseY})),H=e.computed(()=>({top:`${s.node.position?.y??0}px`,left:`${s.node.position?.x??0}px`,"--width":`${s.node.width??i.value.settings.nodes.defaultWidth}px`})),U=e.computed(()=>Object.values(s.node.inputs).filter(x=>!x.hidden)),J=e.computed(()=>Object.values(s.node.outputs).filter(x=>!x.hidden)),z=()=>{l("select")},w=x=>{s.selected||z(),l("start-drag",x)},P=()=>{y.value=!0},R=()=>{const x=i.value.displayedGraph.sidebar;x.nodeId="",x.visible=!1},ae=()=>{const x=i.value.displayedGraph.sidebar;x.nodeId=s.node.id,x.visible=!0},Q=()=>{const x=i.value.displayedGraph.sidebar;x.nodeId=s.node.id},Me=async x=>{switch(x){case"edit":ae();break;case"delete":d.value.removeNode(s.node);break;case"rename":f.value=s.node.title,_.value=!0,await e.nextTick(),v.value?.focus();break;case"editSubgraph":p(s.node.template);break}},re=()=>{r.value.title=f.value,_.value=!1},ie=()=>{m.value&&i.value.hooks.renderNode.execute({node:s.node,el:m.value})},Ve=x=>{g.value=!0,C=s.node.width,u=x.clientX,x.preventDefault()},q=x=>{r.value.state&&(r.value.state.integrated=x,l("update"))},Y=x=>{if(!g.value)return;const b=x.clientX-u,h=C+b/d.value.scaling,k=i.value.settings.nodes.minWidth,E=i.value.settings.nodes.maxWidth;r.value.width=Math.max(k,Math.min(E,h))},le=()=>{g.value=!1};return e.onMounted(()=>{ie(),window.addEventListener("mousemove",Y),window.addEventListener("mouseup",le)}),e.onUpdated(ie),e.onBeforeUnmount(()=>{window.removeEventListener("mousemove",Y),window.removeEventListener("mouseup",le)}),(x,b)=>(e.openBlock(),e.createElementBlock("div",{id:r.value.id,ref_key:"el",ref:m,class:e.normalizeClass([T.value,"baklava-node"]),"data-node-type":r.value.type,style:e.normalizeStyle(H.value),onPointerdown:z},[e.unref(i).settings.nodes.resizable?(e.openBlock(),e.createElementBlock("div",{key:0,class:"__resize-handle",onMousedown:Ve},null,32)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"__title",onPointerdown:e.withModifiers(w,["self","stop"]),onContextmenu:e.withModifiers(P,["prevent"])},[r.value.inputs._code?(e.openBlock(),e.createBlock(e.unref(Be),{key:0,node:r.value,intf:r.value.inputs._code,title:r.value.inputs._code.value,class:"--input","data-interface-type":"node",style:{"flex-grow":"0"}},null,8,["node","intf","title"])):e.createCommentVNode("",!0),_.value?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:2,ref_key:"renameInputEl",ref:v,"onUpdate:modelValue":b[4]||(b[4]=h=>f.value=h),class:"baklava-input",placeholder:"Node Name",style:{"flex-grow":"1"},type:"text",onBlur:re,onKeydown:e.withKeys(re,["enter"])},null,544)),[[e.vModelText,f.value]]):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("div",ro,[r.value.idx>-1?(e.openBlock(),e.createElementBlock("span",io,e.toDisplayString(r.value.idx+1)+" - ",1)):e.createCommentVNode("",!0),e.createTextVNode(e.toDisplayString(r.value.title)+" "+e.toDisplayString(r.value.graph.shortId)+" "+e.toDisplayString(r.value.shortId),1)]),e.createElementVNode("div",lo,[r.value.isCodeNode?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[r.value.state.lockCode?(e.openBlock(),e.createBlock(e.unref(Ce),{key:0,class:"--clickable mx-1",onClick:b[0]||(b[0]=h=>r.value.lockCode=!1)})):e.createCommentVNode("",!0),r.value.state.integrated?(e.openBlock(),e.createBlock(e.unref(Fe),{key:1,class:"--clickable mx-1",onClick:b[1]||(b[1]=h=>q(!1))})):(e.openBlock(),e.createBlock(e.unref(ot),{key:2,class:"--clickable mx-1",onClick:b[2]||(b[2]=h=>q(!0))})),!e.unref(i).displayedGraph.sidebar.visible&&e.unref(i).displayedGraph.sidebar.nodeId!==r.value.id?(e.openBlock(),e.createBlock(e.unref(Qe),{key:3,class:"--clickable mx-1",onClick:ae})):e.unref(i).displayedGraph.sidebar.visible&&e.unref(i).displayedGraph.sidebar.nodeId!==r.value.id?(e.openBlock(),e.createBlock(e.unref(Xe),{key:4,class:"--clickable mx-1",onClick:Q})):(e.openBlock(),e.createBlock(e.unref(Je),{key:5,class:"--clickable mx-1",onClick:R}))],64)):e.createCommentVNode("",!0),e.createVNode(e.unref(We),{class:"--clickable mx-1",onClick:P}),e.createVNode(e.unref(n),{modelValue:y.value,"onUpdate:modelValue":b[3]||(b[3]=h=>y.value=h),x:0,y:0,items:O.value,onClick:Me},null,8,["modelValue","items"])])],64)),r.value.outputs._code?(e.openBlock(),e.createBlock(e.unref(Be),{key:3,node:r.value,intf:r.value.outputs._code,class:"--output",title:r.value.outputs._code.value,"data-interface-type":"node"},null,8,["node","intf","title"])):e.createCommentVNode("",!0)],32),e.createElementVNode("div",{class:e.normalizeClass(["__content",M.value]),onKeydown:b[5]||(b[5]=e.withKeys(e.withModifiers(()=>{},["stop"]),["delete"])),onContextmenu:b[6]||(b[6]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("div",co,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(J.value,h=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:h.id},[r.value.state?.hidden?(e.openBlock(),e.createElementBlock("div",uo,[h.port?(e.openBlock(),e.createElementBlock("div",{key:0,id:h.id,title:h.name,class:"baklava-node-interface --output --connected"},[...b[7]||(b[7]=[e.createElementVNode("div",{class:"__port"},null,-1)])],8,po)):e.createCommentVNode("",!0)])):e.renderSlot(x.$slots,"nodeInterface",{key:1,type:"output",node:r.value,intf:h},()=>[e.createVNode(e.unref(a),{node:r.value,intf:h,title:h.value},null,8,["node","intf","title"])])],64))),128))]),e.createElementVNode("div",ho,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(U.value,h=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:h.id},[r.value.state?.hidden?(e.openBlock(),e.createElementBlock("div",fo,[h.port?(e.openBlock(),e.createElementBlock("div",{key:0,id:h.id,title:h.name,class:"baklava-node-interface --input --connected"},[...b[8]||(b[8]=[e.createElementVNode("div",{class:"__port"},null,-1)])],8,mo)):e.createCommentVNode("",!0)])):e.renderSlot(x.$slots,"nodeInterface",{key:1,node:r.value,intf:h,type:"input"},()=>[e.createVNode(e.unref(a),{node:r.value,intf:h,title:h.value},null,8,["node","intf","title"])])],64))),128))])],34)],46,ao))}}),go=["id"],bo={class:"align-middle"},Be=e.defineComponent({__name:"CodeGraphNodeInterface",props:{node:{},intf:{}},setup(o){const t=o,{viewModel:n}=N.useViewModel(),{hoveredOver:a,temporaryConnection:s}=N.useTemporaryConnection(),r=e.ref(null),l=e.computed(()=>t.intf.connectionCount>0),i=e.computed(()=>({"--connected":l.value})),d=()=>{a(t.intf)},p=()=>{a(void 0)},m=()=>{r.value&&n.value.hooks.renderInterface.execute({intf:t.intf,el:r.value})};return e.onMounted(m),e.onUpdated(m),(_,f)=>(e.openBlock(),e.createElementBlock("div",{id:o.intf.id,ref_key:"el",ref:r,class:e.normalizeClass(["baklava-node-interface",i.value])},[o.intf.port?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["__port",{"--selected":e.unref(s)?.from===o.intf}]),onPointerover:d,onPointerout:p},null,34)):e.createCommentVNode("",!0),e.createElementVNode("span",bo,[e.renderSlot(_.$slots,"default")])],10,go))}}),yo=["title"],ko={key:0,class:"__label"},Te=e.defineComponent({__name:"SidebarCheckbox",props:{disabled:{type:Boolean},inversed:{type:Boolean},modelValue:{type:Boolean},name:{}},emits:["update:modelValue"],setup(o,{emit:t}){const n=t;return(a,s)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["baklava-checkbox",{"--checked":o.inversed?!o.modelValue:o.modelValue,"--disabled":o.disabled}]),title:o.name,onClick:s[0]||(s[0]=r=>n("update:modelValue",!o.modelValue))},[s[1]||(s[1]=e.createElementVNode("div",{class:"__checkmark-container"},[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18"},[e.createElementVNode("path",{class:"__checkmark",d:"M 6 5 L 6 10 L 16 10",transform:"rotate(-45 10 10)"})])],-1)),o.name?(e.openBlock(),e.createElementBlock("div",ko,e.toDisplayString(o.name),1)):e.createCommentVNode("",!0)],10,yo))}}),_o={class:"__header"},Co={class:"__node-name"},No={class:"__interfaces"},wo={class:"__inputs"},Eo={style:{display:"flex"}},Io={class:"__outputs"},vo={key:0,class:"__interface"},Bo={style:{display:"flex"}},ft=e.defineComponent({__name:"CodeGraphSidebar",setup(o){const{viewModel:t}=N.useViewModel(),{graph:n}=N.useGraph(),a=e.ref(null),s=e.toRef(t.value.settings.sidebar,"width"),r=e.computed(()=>t.value.settings.sidebar.resizable);let l=0,i=0;const d=e.computed(()=>{const y=n.value.sidebar.nodeId;return n.value.nodes.find(O=>O.id===y)}),p=e.computed(()=>d.value),m=e.computed(()=>({width:`${s.value}px`})),_=e.computed(()=>p.value?Object.values(p.value.inputs).filter(y=>y.displayInSidebar&&y.component):[]),f=e.computed(()=>p.value?Object.values(p.value.outputs).filter(y=>y.displayInSidebar&&y.component):[]),v=()=>{n.value.sidebar.visible=!1},g=()=>{d.value?.events.update.emit(null)},C=y=>{l=s.value,i=y.clientX,window.addEventListener("mousemove",u),window.addEventListener("mouseup",()=>{window.removeEventListener("mousemove",u)},{once:!0})},u=y=>{const O=a.value?.parentElement?.getBoundingClientRect().width??500,T=y.clientX-i;let M=l-T;M<300?M=300:M>.9*O&&(M=.9*O),s.value=M};return(y,O)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass([{"--open":e.unref(n).sidebar.visible},"baklava-sidebar"]),style:e.normalizeStyle(m.value),ref_key:"el",ref:a},[r.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"__resizer",onMousedown:C},null,32)):e.createCommentVNode("",!0),d.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("div",_o,[e.createElementVNode("button",{tabindex:"-1",class:"__close",onClick:v},"×"),e.createElementVNode("div",Co,[e.createElementVNode("b",null,e.toDisplayString(d.value.title),1)])]),e.createElementVNode("div",No,[e.createElementVNode("div",wo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(_.value,T=>(e.openBlock(),e.createElementBlock("div",{key:T.id,class:"__interface"},[e.createElementVNode("div",Eo,[e.createVNode(Te,{modelValue:T.hidden,"onUpdate:modelValue":[M=>T.hidden=M,O[0]||(O[0]=()=>d.value?.events.update.emit(null))],disabled:!T.optional,inversed:"",style:{"padding-right":"8px"}},null,8,["modelValue","onUpdate:modelValue","disabled"]),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(T.component),{modelValue:T.value,"onUpdate:modelValue":M=>T.value=M,node:d.value,intf:T,style:{width:"100%"}},null,8,["modelValue","onUpdate:modelValue","node","intf"]))])]))),128))]),e.createElementVNode("div",Io,[p.value&&p.value.state?(e.openBlock(),e.createElementBlock("div",vo,[O[3]||(O[3]=e.createElementVNode("label",null,"Variable name",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":O[1]||(O[1]=T=>p.value.state.variableName=T),type:"text",class:"baklava-input",title:"Variable name",onBlur:g,onKeydown:e.withKeys(g,["enter"])},null,544),[[e.vModelText,p.value.state.variableName]])])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,T=>(e.openBlock(),e.createElementBlock("div",{key:T.id,class:"__interface"},[e.createElementVNode("div",Bo,[e.createVNode(Te,{modelValue:T.hidden,"onUpdate:modelValue":[M=>T.hidden=M,O[2]||(O[2]=()=>d.value?.events.update.emit(null))],disabled:!T.optional,inversed:"",style:{"padding-right":"8px"}},null,8,["modelValue","onUpdate:modelValue","disabled"]),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(T.component),{modelValue:T.value,"onUpdate:modelValue":M=>T.value=M,node:d.value,intf:T,style:{width:"100%"}},null,8,["modelValue","onUpdate:modelValue","node","intf"]))])]))),128))])]),e.renderSlot(y.$slots,"codeEditor",{node:d.value})],64)):e.createCommentVNode("",!0)],6))}}),To={class:"baklava-node --palette",style:{"margin-top":"-20px","margin-bottom":"20px"}},xo={key:0,style:{display:"flex","justify-content":"space-between"}},Oo=["onClick"],So={key:0,style:{margin:"auto 0","font-size":"12px"}},mt=e.defineComponent({__name:"CodeNodePalette",setup(o){const t=N.Components.PaletteEntry,{viewModel:n}=N.useViewModel(),{x:a,y:s}=_t.usePointer(),{transform:r}=N.useTransform(),l=N.useNodeCategories(n),i=e.inject("editorEl"),d=e.ref(""),p=e.ref(null),m=()=>d.value?l.value.filter(g=>g.name.toLowerCase().includes(d.value.toLowerCase())||Object.values(g.nodeTypes).some(C=>C.title.toLowerCase().includes(d.value.toLowerCase()))):l.value,_=g=>d.value?Hn(g,C=>{const u=C[1];return u.category.includes(d.value.toLowerCase())||u.title?.toLowerCase().includes(d.value.toLowerCase())}):g,f=e.computed(()=>{if(!p.value||!i?.value)return{};const{left:g,top:C}=i.value.getBoundingClientRect();return{top:`${s.value-C}px`,left:`${a.value-g}px`}}),v=(g,C)=>{p.value={type:g,nodeInformation:C};const u=()=>{const y=e.reactive(new C.type);n.value.displayedGraph.addNode(y);const O=i.value.getBoundingClientRect(),[T,M]=r(a.value-O.left,s.value-O.top);y.position.x=T,y.position.y=M,p.value=null,document.removeEventListener("pointerup",u)};document.addEventListener("pointerup",u)};return(g,C)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",{class:e.normalizeClass([{"--open":e.unref(n).settings.palette.enabled},"baklava-node-palette"]),onContextmenu:C[1]||(C[1]=e.withModifiers(()=>{},["stop","prevent"]))},[e.createElementVNode("div",To,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":C[0]||(C[0]=u=>d.value=u),type:"text",class:"baklava-input",title:"Filter nodes",onKeyup:m},null,544),[[e.vModelText,d.value]])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m(),u=>(e.openBlock(),e.createElementBlock("section",{key:u.name},[u.name!=="default"?(e.openBlock(),e.createElementBlock("h3",xo,[e.createElementVNode("div",{onClick:y=>d.value=u.name,style:{cursor:"pointer"}},e.toDisplayString(u.name),9,Oo),Object.keys(_(u.nodeTypes)).length<Object.values(u.nodeTypes).length?(e.openBlock(),e.createElementBlock("div",So," ( "+e.toDisplayString(Object.keys(_(u.nodeTypes)).length)+" / "+e.toDisplayString(Object.values(u.nodeTypes).length)+" ) ",1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(_(u.nodeTypes),(y,O)=>(e.openBlock(),e.createBlock(e.unref(t),{key:O,type:O,title:y.title,onPointerdown:T=>v(O,y)},null,8,["type","title","onPointerdown"]))),128))]))),128))],34),e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[p.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"baklava-dragged-node",style:e.normalizeStyle(f.value)},[e.createVNode(e.unref(t),{type:p.value.type,title:p.value.nodeInformation.title},null,8,["type","title"])],4)):e.createCommentVNode("",!0)]),_:1})],64))}}),Mo={},Vo={class:"prependIcon"},$o={class:"appendIcon"};function Po(o,t){const n=e.resolveComponent("router-link");return e.openBlock(),e.createBlock(n,{class:"navItem"},{default:e.withCtx(()=>[e.createElementVNode("span",Vo,[e.renderSlot(o.$slots,"prependIcon")]),e.renderSlot(o.$slots,"default"),e.createElementVNode("span",$o,[e.renderSlot(o.$slots,"appendIcon")])]),_:3})}const xe=$(Mo,[["render",Po]]),jo={class:"navbar"},Ro=["onClick"],Go=e.defineComponent({__name:"NavBar",props:{viewModel:{},editorStates:{},routes:{}},emits:["click:remove"],setup(o,{emit:t}){const n=t,a=s=>{n("click:remove",s)};return(s,r)=>(e.openBlock(),e.createElementBlock("nav",jo,[e.renderSlot(s.$slots,"prepend"),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.editorStates,l=>(e.openBlock(),e.createBlock(xe,{key:l.graph.id,class:e.normalizeClass({active:l.graph.id===o.viewModel.displayedGraph.id}),to:{name:o.routes?.edit??"edit",params:{editorId:l.graph.id}}},{appendIcon:e.withCtx(()=>[e.createElementVNode("button",{class:"remove",onClick:e.withModifiers(i=>a(l.graph.id),["prevent"])},[e.createVNode(e.unref(at))],8,Ro)]),default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(l.graph.id.slice(0,6))+" ",1)]),_:2},1032,["class","to"]))),128)),e.renderSlot(s.$slots,"append",{},()=>[e.createVNode(xe,{to:{name:o.routes?.new??"new"},class:"navItem"},{default:e.withCtx(()=>[e.createVNode(e.unref(et),{class:"plus"})]),_:1},8,["to"])])]))}});class Oe extends ke{_title="Subgraph Input";inputs={_code:new j("","").use(S.setType,G).setHidden(!0),name:new N.TextInputInterface("Name","Input").setPort(!1)};outputs={_code:new j("","").use(S.setType,G).setHidden(!0),placeholder:new V.NodeInterface("Connection",void 0)}}class Se extends _e{_title="Subgraph Output";inputs={_code:new j("","").use(S.setType,G).setHidden(!0),name:new N.TextInputInterface("Name","Output").setPort(!1),placeholder:new V.NodeInterface("Connection",void 0)};outputs={_code:new j("","").use(S.setType,G).setHidden(!0),output:new V.NodeInterface("Output",void 0).setHidden(!0)}}const gt="CREATE_SUBGRAPH",bt=[V.GRAPH_INPUT_NODE_TYPE,V.GRAPH_OUTPUT_NODE_TYPE];function yt(o,t,n){const a=()=>o.value.selectedNodes.filter(r=>!bt.includes(r.type)).length>0,s=()=>{const{viewModel:r}=N.useViewModel(),l=o.value,i=o.value.editor;if(l.selectedNodes.length===0)return;const d=l.selectedNodes.filter(w=>!bt.includes(w.type)),p=d.flatMap(w=>Object.values(w.inputs)),m=d.flatMap(w=>Object.values(w.outputs)),_=l.connections.filter(w=>!m.includes(w.from)&&p.includes(w.to)),f=l.connections.filter(w=>m.includes(w.from)&&!p.includes(w.to)),v=l.connections.filter(w=>m.includes(w.from)&&p.includes(w.to)),g=d.map(w=>w.save()),C=v.map(w=>({id:w.id,from:w.from.id,to:w.to.id})),u=new Map,{xLeft:y,xRight:O,yTop:T}=Lo(d);for(const[w,P]of _.entries()){const R=new Oe;R.inputs.name.value=P.to.name,g.push({...R.save(),position:{x:O-r.value.settings.nodes.defaultWidth-100,y:T+w*200}}),C.push({id:F.v4(),from:R.outputs.placeholder.id,to:P.to.id}),u.set(P.to.id,R.graphInterfaceId)}for(const[w,P]of f.entries()){const R=new Se;R.inputs.name.value=P.from.name,g.push({...R.save(),position:{x:y+100,y:T+w*200}}),C.push({id:F.v4(),from:P.from.id,to:R.inputs.placeholder.id}),u.set(P.from.id,R.graphInterfaceId)}const M=e.reactive(new X({connections:C,nodes:g,inputs:[],outputs:[]},i));i.addGraphTemplate(M);const H=i.nodeTypes.get(V.getGraphNodeTypeString(M));if(!H)throw new Error("Unable to create subgraph: Could not find corresponding graph node type");l.activeTransactions++;const U=e.reactive(new H.type);l.addNode(U);const J=Math.round(d.map(w=>w.position.x).reduce((w,P)=>w+P,0)/d.length),z=Math.round(d.map(w=>w.position.y).reduce((w,P)=>w+P,0)/d.length);U.position.x=J,U.position.y=z,_.forEach(w=>{l.removeConnection(w),l.addConnection(w.from,U.inputs[u.get(w.to.id)])}),f.forEach(w=>{l.removeConnection(w),l.addConnection(U.outputs[u.get(w.from.id)],w.to)}),d.forEach(w=>l.removeNode(w)),l.activeTransactions--,t.canExecuteCommand(N.Commands.SAVE_SUBGRAPH_COMMAND)&&t.executeCommand(N.Commands.SAVE_SUBGRAPH_COMMAND),n(M),o.value.panning={...l.panning},o.value.scaling=l.scaling};t.registerCommand(gt,{canExecute:a,execute:s})}function Lo(o){const t=o.reduce((s,r)=>{const l=r.position.x;return l<s?l:s},1/0),n=o.reduce((s,r)=>{const l=r.position.y;return l<s?l:s},1/0);return{xLeft:o.reduce((s,r)=>{const l=r.position.x+r.width;return l>s?l:s},-1/0),xRight:t,yTop:n}}class Ao extends V.Editor{code;graph;constructor(t){super(),this.code=t,this.graph=new K(this)}get graphIds(){const t=[];return this.graphs.forEach(n=>t.push(n.id)),t.map(n=>n.slice(0,6)).join(", ")}get graphTemplateIds(){const t=[];return this.graphTemplates.forEach(n=>t.push(n.id)),t.map(n=>n.slice(0,6)).join(", ")}addGraphTemplate(t){if(this.events.beforeAddGraphTemplate.emit(t).prevented)return;this._graphTemplates.push(t),this.graphTemplateEvents.addTarget(t.events),this.graphTemplateHooks.addTarget(t.hooks);const n=ze(t);this.registerNodeType(n,{category:"Subgraphs",title:t.name}),this.events.addGraphTemplate.emit(t)}load(t){try{for(super._loading=!0,t=this.hooks.load.execute(t);this.graphTemplates.length>0;)this.removeGraphTemplate(this.graphTemplates[0]);t.graphTemplates.forEach(a=>{const s=new X(a,this);this.addGraphTemplate(s)});const n=this.graph.load(t.graph);return this.events.loaded.emit(),n.forEach(a=>console.warn(a)),n}finally{super._loading=!1}}registerCategoryModule(t,n){this.code.state.modules[t]=n}}function Do(o){const t=e.ref(o?.code??new oe),n=e.ref(o?.existingEditor??new Ao(t.value)),a=Symbol("ViewModelToken"),s=e.ref(null),r=e.shallowReadonly(s),{switchGraph:l}=dt(n,s),i=e.computed(()=>r.value&&r.value!==n.value.graph),d=e.reactive(N.DEFAULT_SETTINGS());d.nodes.defaultWidth=400;const p=N.useCommandHandler(),m=N.useHistory(r,p),_=N.useClipboard(r,n,p),f={renderNode:new $e.SequentialHook(null),renderInterface:new $e.SequentialHook(null)},v=e.reactive({clipboard:_,code:t,commandHandler:p,displayedGraph:r,editor:n,history:m,hooks:f,isSubgraph:i,settings:d,switchGraph:l});return t.value.registerViewModel(v),ct(v),N.registerDeleteNodesCommand(r,p),yt(r,p,l),N.registerSaveSubgraphCommand(r,p),N.registerSwitchToMainGraphCommand(r,p,l),N.registerSidebarCommands(r,p),N.registerZoomToFitCommands(r,p,d),rt(r,p,d),it(d),e.watch(n,(g,C)=>{C&&(C.events.registerGraph.unsubscribe(a),C.graphEvents.beforeAddNode.unsubscribe(a),g.nodeHooks.beforeLoad.unsubscribe(a),g.nodeHooks.afterSave.unsubscribe(a),g.graphTemplateHooks.beforeLoad.unsubscribe(a),g.graphTemplateHooks.afterSave.unsubscribe(a),g.graph.hooks.load.unsubscribe(a),g.graph.hooks.save.unsubscribe(a)),g&&(g.nodeHooks.beforeLoad.subscribe(a,(u,y)=>(y.position=u.position??{x:0,y:0},y.width=u.width??d.nodes.defaultWidth,y.twoColumn=u.twoColumn??!1,u)),g.nodeHooks.afterSave.subscribe(a,(u,y)=>(u.position=y.position,u.width=y.width,u.twoColumn=y.twoColumn,u)),g.graphTemplateHooks.beforeLoad.subscribe(a,(u,y)=>(y.panning=u.panning,y.scaling=u.scaling,u)),g.graphTemplateHooks.afterSave.subscribe(a,(u,y)=>(u.panning=y.panning,u.scaling=y.scaling,u)),g.graph.hooks.load.subscribe(a,(u,y)=>(y.panning=u.panning,y.scaling=u.scaling,u)),g.graph.hooks.save.subscribe(a,(u,y)=>(u.panning=y.panning,u.scaling=y.scaling,u)),g.graphEvents.beforeAddNode.subscribe(a,u=>N.setViewNodeProperties(u,{defaultWidth:d.nodes.defaultWidth})),n.value.registerNodeType(Oe,{category:"Subgraphs"}),n.value.registerNodeType(Se,{category:"Subgraphs"}),l(g.graph))},{immediate:!0}),v}const zo=Object.freeze(Object.defineProperty({__proto__:null,default:`{{ #modules }}
|
|
5
|
+
{{ . }}
|
|
6
|
+
{{ /modules }}
|
|
7
|
+
|
|
8
|
+
{{ #nodes }}
|
|
9
|
+
{{ #commented }}# {{ /commented }}{{ #variableName }}{{ variableName }} = {{ /variableName }}{{ script }}
|
|
10
|
+
{{ /nodes }}`},Symbol.toStringTag,{value:"Module"})),Ho=Object.freeze(Object.defineProperty({__proto__:null,default:`{{ #modules }}
|
|
11
|
+
{{ . }}
|
|
12
|
+
{{ /modules }}
|
|
13
|
+
|
|
14
|
+
{{ #nodes }}
|
|
15
|
+
{{ #commented }}// {{ /commented }}{{ #variableName }}var {{ variableName }} = {{ /variableName }}{{ script }};
|
|
16
|
+
{{ /nodes }}`},Symbol.toStringTag,{value:"Module"}));c.AbstractCodeNode=de,c.CLEAR_ALL_COMMAND=Ne,c.CREATE_SUBGRAPH_COMMAND=gt,c.Check=Ue,c.CheckboxInterface=wt,c.Code=oe,c.CodeEditor=to,c.CodeEngine=He,c.CodeGraph=K,c.CodeGraphEditor=no,c.CodeGraphInfo=so,c.CodeGraphInputNode=ke,c.CodeGraphNode=ht,c.CodeGraphNodeInterface=Be,c.CodeGraphOutputNode=_e,c.CodeGraphSidebar=ft,c.CodeGraphTemplate=X,c.CodeNode=Z,c.CodeNodeInputInterface=W,c.CodeNodeInterface=j,c.CodeNodeInterfaceComponent=ee,c.CodeNodeOutputInterface=Ge,c.CodeNodePalette=mt,c.CodeVariable=Fe,c.Copy=qe,c.CopyToClipboard=pt,c.DotsVertical=We,c.DynamicCodeNode=Ae,c.GRAPH_INPUT_NODE_TYPE=be,c.GRAPH_OUTPUT_NODE_TYPE=ye,c.IntegerInterface=Et,c.JavascriptCode=Dt,c.LayoutSidebarLeftCollapse=Ye,c.LayoutSidebarLeftExpand=Ke,c.LayoutSidebarRight=Xe,c.LayoutSidebarRightCollapse=Je,c.LayoutSidebarRightExpand=Qe,c.ListInputInterface=It,c.LockCode=Ce,c.NavBar=Go,c.NavItem=xe,c.NumberInterface=vt,c.PlayerPlay=Ze,c.Plus=et,c.PythonCode=At,c.RUN_ENGINE_COMMAND=we,c.Schema=tt,c.SchemaOff=nt,c.SelectInterface=Bt,c.SidebarCheckbox=Te,c.SliderInterface=Tt,c.SubgraphInputNode=Oe,c.SubgraphOutputNode=Se,c.TOGGLE_MINIMAP_COMMAND=Ee,c.TOGGLE_PALETTE_COMMAND=Ie,c.TextInputInterface=$t,c.TextInputInterfaceComponent=Le,c.TextareaInputInterface=Pt,c.TransitionBottom=ot,c.TrashOff=st,c.TupleInputInterface=jt,c.X=at,c.addDefaultInterfaceTypes=Nt,c.allowMultipleConnections=zt,c.booleanType=pe,c.createCodeGraphNodeType=ze,c.defineCodeNode=Rt,c.defineDynamicCodeNode=Gt,c.dictType=Re,c.formatInputs=Pe,c.getCodeNodes=ve,c.getPositionAtColumn=Dn,c.getPositionBeforeNode=zn,c.listType=he,c.loadNodeState=ue,c.nodeType=G,c.numberType=te,c.registerCodeEngine=ct,c.registerCreateSubgraphCommand=yt,c.registerCustomCommands=rt,c.registerRunEngineCommands=lt,c.saveNodeState=je,c.stringType=ne,c.tupleType=fe,c.updateToolbarItems=it,c.useCodeGraph=Do,c.useSwitchCodeGraph=dt,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@babsey/code-graph",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"author": "babsey <spreizer@web.de>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"dev": "vite",
|
|
26
|
-
"build": "run-p
|
|
26
|
+
"build": "run-p type-check \"build-only {@}\" --",
|
|
27
27
|
"preview": "vite preview",
|
|
28
28
|
"build-only": "vite build",
|
|
29
|
-
"type-check": "vue-tsc
|
|
29
|
+
"type-check": "vue-tsc",
|
|
30
30
|
"clean": "rimraf dist",
|
|
31
31
|
"lint": "eslint . --fix",
|
|
32
32
|
"format": "prettier --write examples/**/src/ lib/ src/"
|