const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TopMenuNodes-D7_Py-Nv.js","assets/reactflow-vendor-DVEEOIVt.js","assets/react-vendor-4ldeB94U.js","assets/shallow-CUABpCwf.js","assets/index-BXU-m2Zz.js","assets/index-CTXEim1W.css","assets/CustomDrawer-NgkiQ4p9.js","assets/Stack-D0KwXe3b.js","assets/IconFolder-wFGRbLxB.js","assets/TopMenuCodePreviewButton-DQ4cmLOM.js"])))=>i.map(i=>d[i]);
import{_ as f}from"./index-BXU-m2Zz.js";import{j as o}from"./reactflow-vendor-DVEEOIVt.js";import{c as i,u as x,a as y,F as k,B as r,b as s,f as _,d as N}from"./shallow-CUABpCwf.js";import{r as c}from"./react-vendor-4ldeB94U.js";/**
 * @license @tabler/icons-react v3.18.0 - MIT
 *
 * This source code is licensed under the MIT license.
 * See the LICENSE file in the root directory of this source tree.
 */var b=i("outline","download","IconDownload",[["path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2",key:"svg-0"}],["path",{d:"M7 11l5 5l5 -5",key:"svg-1"}],["path",{d:"M12 4l0 12",key:"svg-2"}]]);/**
 * @license @tabler/icons-react v3.18.0 - MIT
 *
 * This source code is licensed under the MIT license.
 * See the LICENSE file in the root directory of this source tree.
 */var I=i("outline","folder-open","IconFolderOpen",[["path",{d:"M5 19l2.757 -7.351a1 1 0 0 1 .936 -.649h12.307a1 1 0 0 1 .986 1.164l-.996 5.211a2 2 0 0 1 -1.964 1.625h-14.026a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2h4l3 3h7a2 2 0 0 1 2 2v2",key:"svg-0"}]]);/**
 * @license @tabler/icons-react v3.18.0 - MIT
 *
 * This source code is licensed under the MIT license.
 * See the LICENSE file in the root directory of this source tree.
 */var O=i("filled","player-play-filled","IconPlayerPlayFilled",[["path",{d:"M6 4v16a1 1 0 0 0 1.524 .852l13 -8a1 1 0 0 0 0 -1.704l-13 -8a1 1 0 0 0 -1.524 .852z",key:"svg-0"}]]);const R=c.lazy(()=>f(()=>import("./TopMenuNodes-D7_Py-Nv.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8]))),z=c.lazy(()=>f(()=>import("./TopMenuCodePreviewButton-DQ4cmLOM.js"),__vite__mapDeps([9,1,2,3,4,5,6,7])));function M(){const{name:d,setName:u,loadGraph:g}=x(y(e=>({name:e.name,setName:e.setName,loadGraph:e.loadGraph}))),w=()=>{var t;(t=document.getElementById("workflow-download"))==null||t.click();const e=JSON.stringify(s.graph,null,2);console.log("common_app.graph",s.graph);const l=new Blob([e],{type:"application/json"}),n=URL.createObjectURL(l),a=document.createElement("a");a.href=n,a.download=`${d??"nozy_workflow"}.json`,a.click()},p=c.useRef(null),j=e=>{var a;const l=(a=e.target.files)==null?void 0:a[0],n=new FileReader;l&&(n.readAsText(l,"UTF-8"),n.onload=t=>{var h;const m=JSON.parse((h=t.target)==null?void 0:h.result);m.name=l.name.replace(/\.json$/,""),g(m)})},v=N("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",12);return o.jsxs("div",{className:"flex items-center justify-between absolute top-0 left-0 right-0",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(R,{}),o.jsx("div",{className:"text-sm",onClick:()=>{const e=prompt("Enter a name for this workflow");e&&u(e)},children:d??"Untitled"}),o.jsxs(k,{className:"gap-0",children:[o.jsx(r,{size:"sm",variant:"ghost",title:"Download workflow",onClick:w,children:o.jsx(b,{size:18})}),o.jsx(r,{size:"sm",variant:"ghost",title:"Open workflow",onClick:()=>{var e;(e=p.current)==null||e.click()},children:o.jsx(I,{size:18})}),o.jsx("input",{type:"file",accept:".json",id:"workflow-upload",ref:p,style:{display:"none"},onChange:j})]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(z,{}),o.jsx(r,{left:o.jsx(O,{size:15}),onClick:()=>{const e={job_id:v(),nodes:s.graph.nodes,edges:s.graph.edges,values:s.graph.values};console.log("graph",e),_("/queue_job",{method:"POST",body:JSON.stringify(e)})},children:"Run"})]})]})}export{M as default};
