import{j as e}from"./reactflow-vendor-BDofclgK.js";import{c as p,S as g,a as d,F as u,I as j,B as x}from"./Stack-2Xb3rVeY.js";import{I as v,C as k,a as b}from"./TopMenu-B_0sOma9.js";import{r as t}from"./react-vendor-4ldeB94U.js";import{r as N,f as m,u as y}from"./index-D-ULYqgV.js";import{D as I,a as C,b as D,c as S}from"./dialog-BbYNcTN7.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 F=p("outline","box","IconBox",[["path",{d:"M12 3l8 4.5l0 9l-8 4.5l-8 -4.5l0 -9l8 -4.5",key:"svg-0"}],["path",{d:"M12 12l8 -4.5",key:"svg-1"}],["path",{d:"M12 12l0 9",key:"svg-2"}],["path",{d:"M12 12l-8 -4.5",key:"svg-3"}]]);/**
 * @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 P=p("outline","brand-github","IconBrandGithub",[["path",{d:"M9 19c-4.3 1.4 -4.3 -2.5 -6 -3m12 5v-3.5c0 -1 .1 -1.4 -.5 -2c2.8 -.3 5.5 -1.4 5.5 -6a4.6 4.6 0 0 0 -1.3 -3.2a4.2 4.2 0 0 0 -.1 -3.2s-1.1 -.3 -3.5 1.3a12.3 12.3 0 0 0 -6.2 0c-2.4 -1.6 -3.5 -1.3 -3.5 -1.3a4.2 4.2 0 0 0 -.1 3.2a4.6 4.6 0 0 0 -1.3 3.2c0 4.6 2.7 5.7 5.5 6c-.6 .6 -.6 1.2 -.5 2v3.5",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 _=p("outline","brand-tabler","IconBrandTabler",[["path",{d:"M8 9l3 3l-3 3",key:"svg-0"}],["path",{d:"M13 15l3 0",key:"svg-1"}],["path",{d:"M4 4m0 4a4 4 0 0 1 4 -4h8a4 4 0 0 1 4 4v8a4 4 0 0 1 -4 4h-8a4 4 0 0 1 -4 -4z",key:"svg-2"}]]);function f({path:r}){const[l,i]=t.useState([]),{setDropingNode:o}=N(),[h,c]=t.useState(!1);return t.useEffect(()=>{c(!0),m("/list_package_children?path="+encodeURIComponent(r)).then(a=>a.json()).then(a=>{i(a)}).finally(()=>{c(!1)})},[]),e.jsx("div",{className:"flex flex-col",children:e.jsxs("div",{className:"flex flex-col",children:[h&&e.jsx(g,{}),l.map(a=>{var s;return a.type==="folder"?e.jsx(M,{node:a},a.path):e.jsxs(d,{onClick:()=>{},children:[e.jsx(u,{children:e.jsx("p",{className:"text-muted-foreground",children:a.name})}),(s=a.functions)==null?void 0:s.map(n=>e.jsxs("div",{draggable:!0,onDragStart:B=>{console.log(n),o(n)},className:"flex flex-row items-center ml-2 py-1 font-semibold gap-1 cursor-pointer hover:bg-secondary",children:[e.jsx(_,{size:18}),e.jsx("span",{children:n.name})]},a.path+"_"+n.name))]},a.type+"_"+a.name)})]})})}function M({node:r}){const[l,i]=t.useState(!1);return e.jsxs(d,{className:"",children:[e.jsxs("div",{className:"flex flex-row items-center cursor-pointer hover:bg-secondary",onClick:()=>i(!l),children:[e.jsx(v,{size:8,className:l?"mr-1":"-rotate-90 mr-1"}),e.jsx(j,{className:"mr-1"}),r.name]}),l&&e.jsx("div",{className:"ml-3",children:e.jsx(f,{path:r.path})})]})}function w({onClose:r}){const{toast:l}=y(),[i,o]=t.useState([]),[h,c]=t.useState(null);t.useEffect(()=>{m("/package/list_community").then(s=>s.json()).then(o)},[]);const a=s=>{c(s),m("/package/install",{method:"POST",body:JSON.stringify({url:s})}).then(n=>n.json()).then(n=>{c(null),n.error?l({title:`❌Failed to install package ${s}`,description:n.error}):l({title:`✅Installed package ${s}`,description:"Please refresh the page."})})};return e.jsx(I,{onOpenChange:r,open:!0,children:e.jsxs(C,{className:"sm:max-w-[50vw]","aria-describedby":"Choose File",children:[e.jsx(D,{children:e.jsx(S,{children:"Community Node Packages"})}),e.jsx(d,{children:e.jsx("div",{className:"grid grid-cols-[2fr_3fr_1fr_1fr] gap-4",children:i.map(s=>e.jsxs(t.Fragment,{children:[e.jsx("div",{className:"font-bold",children:s.name}),e.jsx("div",{children:s.description}),e.jsx(u,{children:e.jsxs("a",{href:s.url,target:"_blank",className:"flex items-center",children:[e.jsx(P,{size:18}),e.jsx("span",{className:"ml-1",children:"Github"})]})}),e.jsx(x,{onClick:()=>a(s.url),isLoading:h===s.url,children:"Install"})]},s.url))})})]})})}function R(){const[r,l]=t.useState(!1),[i,o]=t.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(x,{onClick:()=>l(!0),left:e.jsx(F,{size:18}),children:"Nodes"}),r&&e.jsx(k,{onClose:()=>l(!1),backdrop:null,children:e.jsxs(d,{className:"w-[400px] py-2 px-2 overflow-y-auto h-[100vh]",children:[e.jsxs(u,{className:"justify-between",children:[e.jsx("h2",{className:"text-xl font-bold p-2",children:"Nodes"}),e.jsx(x,{onClick:()=>o(!0),left:e.jsx(b,{size:18}),children:e.jsx("span",{children:"Install Node Package"})})]}),e.jsx(f,{path:""})]})}),i&&e.jsx(w,{onClose:()=>o(!1)})]})}export{R as default};
