@tuongaz/seeflow 0.1.97 → 0.1.98
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/web/assets/{architectureDiagram-3BPJPVTR-XQzgHME4.js → architectureDiagram-3BPJPVTR-DU1dz67I.js} +1 -1
- package/dist/web/assets/{blockDiagram-GPEHLZMM-D79pgdno.js → blockDiagram-GPEHLZMM-DSmqToeJ.js} +1 -1
- package/dist/web/assets/{c4Diagram-AAUBKEIU-DdpMasob.js → c4Diagram-AAUBKEIU-CNP992lo.js} +1 -1
- package/dist/web/assets/channel-v9-wsv2r.js +1 -0
- package/dist/web/assets/{chart-BS3qBv6b.js → chart-DF01veTJ.js} +1 -1
- package/dist/web/assets/{chunk-2J33WTMH-DMiLaW3V.js → chunk-2J33WTMH-LVhrEzuA.js} +1 -1
- package/dist/web/assets/{chunk-4BX2VUAB-BxRQSTSU.js → chunk-4BX2VUAB-7QT-8Ea8.js} +1 -1
- package/dist/web/assets/{chunk-55IACEB6-B8VO9ECP.js → chunk-55IACEB6-DekK1DpQ.js} +1 -1
- package/dist/web/assets/{chunk-727SXJPM-CtI4DnVU.js → chunk-727SXJPM-B2Ar-3-Y.js} +1 -1
- package/dist/web/assets/{chunk-AQP2D5EJ-BUDEtGcc.js → chunk-AQP2D5EJ-DFL9j35G.js} +1 -1
- package/dist/web/assets/{chunk-FMBD7UC4-XRBBZk8O.js → chunk-FMBD7UC4-BDQ2jKs8.js} +1 -1
- package/dist/web/assets/{chunk-ND2GUHAM-D0exlO6X.js → chunk-ND2GUHAM-DbrZoSgU.js} +1 -1
- package/dist/web/assets/{chunk-QZHKN3VN-CnyiTlpq.js → chunk-QZHKN3VN-BBiKBSEG.js} +1 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-CY00ktDc.js +1 -0
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-CY00ktDc.js +1 -0
- package/dist/web/assets/{code-block-CLrCA7Xe.js → code-block-Dqo0Jd1G.js} +1 -1
- package/dist/web/assets/{cose-bilkent-S5V4N54A-B4D1urlH.js → cose-bilkent-S5V4N54A-CGpaWYc4.js} +1 -1
- package/dist/web/assets/{dagre-BM42HDAG-CNe7Uulx.js → dagre-BM42HDAG-DTV9Prbv.js} +1 -1
- package/dist/web/assets/{diagram-2AECGRRQ--mgpxm9o.js → diagram-2AECGRRQ-DLqTKsZ1.js} +1 -1
- package/dist/web/assets/{diagram-5GNKFQAL-CGHMTFDB.js → diagram-5GNKFQAL-WeRlWvVf.js} +1 -1
- package/dist/web/assets/{diagram-KO2AKTUF-D31GLzm7.js → diagram-KO2AKTUF-Bla9fFa3.js} +1 -1
- package/dist/web/assets/{diagram-LMA3HP47-Bs2BLtxH.js → diagram-LMA3HP47-JmfK87A4.js} +1 -1
- package/dist/web/assets/{diagram-OG6HWLK6-CXUZ873r.js → diagram-OG6HWLK6-CWLzBnkl.js} +1 -1
- package/dist/web/assets/{erDiagram-TEJ5UH35-DL-eedkW.js → erDiagram-TEJ5UH35-zIaBabk9.js} +1 -1
- package/dist/web/assets/{flowDiagram-I6XJVG4X-BQCu7G6G.js → flowDiagram-I6XJVG4X-Bue3Noo8.js} +1 -1
- package/dist/web/assets/{ganttDiagram-6RSMTGT7-CyBhrhQa.js → ganttDiagram-6RSMTGT7-BHdGoBmM.js} +1 -1
- package/dist/web/assets/{gitGraphDiagram-PVQCEYII-D9OqlmQL.js → gitGraphDiagram-PVQCEYII-DY8i3xDG.js} +1 -1
- package/dist/web/assets/{index-BKZTnCOL.js → index-B-NP-7Oo.js} +5 -5
- package/dist/web/assets/{index.es-BpDX3yd0.js → index.es-PfKZum8P.js} +1 -1
- package/dist/web/assets/{infoDiagram-5YYISTIA-CMxwx_2B.js → infoDiagram-5YYISTIA-CjlY190O.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-DD1y6qVy.js → ishikawaDiagram-YF4QCWOH-UlDRmAcX.js} +1 -1
- package/dist/web/assets/{journeyDiagram-JHISSGLW-CHo991VZ.js → journeyDiagram-JHISSGLW-BQU5iM6n.js} +1 -1
- package/dist/web/assets/{jspdf.es.min-C8_HZhlK.js → jspdf.es.min-DZwedYLb.js} +3 -3
- package/dist/web/assets/{kanban-definition-UN3LZRKU-CoYkI8Ob.js → kanban-definition-UN3LZRKU-BHjSnSao.js} +1 -1
- package/dist/web/assets/{linear-CQGcGLyB.js → linear-DfckWaYF.js} +1 -1
- package/dist/web/assets/{markdown-Bud9JO0j.js → markdown-DK4rNWyg.js} +1 -1
- package/dist/web/assets/{mermaid.core-1G8gw6AK.js → mermaid.core-Q5Rkziel.js} +4 -4
- package/dist/web/assets/{mindmap-definition-RKZ34NQL-CJHnwtSU.js → mindmap-definition-RKZ34NQL-Cwl5O3Cf.js} +1 -1
- package/dist/web/assets/{pieDiagram-4H26LBE5-CXrXwuPG.js → pieDiagram-4H26LBE5-CfuqpLij.js} +1 -1
- package/dist/web/assets/{quadrantDiagram-W4KKPZXB-BVJKIfMF.js → quadrantDiagram-W4KKPZXB-DPMXHfS6.js} +1 -1
- package/dist/web/assets/{requirementDiagram-4Y6WPE33-ZFgLHB2Y.js → requirementDiagram-4Y6WPE33-DnkSyvnm.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-5OEKKPKP-cP9rHdFK.js → sankeyDiagram-5OEKKPKP-qgBj0gIh.js} +1 -1
- package/dist/web/assets/{sequenceDiagram-3UESZ5HK-BbruCi6T.js → sequenceDiagram-3UESZ5HK-Dv8lcfkG.js} +1 -1
- package/dist/web/assets/{stateDiagram-AJRCARHV-CqGbTDXI.js → stateDiagram-AJRCARHV-BHhRAlSF.js} +1 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-Z4OeqbFi.js +1 -0
- package/dist/web/assets/{time-CXSgtiIX.js → time-DLVqCHvN.js} +1 -1
- package/dist/web/assets/{timeline-definition-PNZ67QCA-B4in6942.js → timeline-definition-PNZ67QCA-Dj-PUcDW.js} +1 -1
- package/dist/web/assets/{vennDiagram-CIIHVFJN-D3Esdgtc.js → vennDiagram-CIIHVFJN-BVu8roqR.js} +1 -1
- package/dist/web/assets/{wardley-L42UT6IY-CqOLhiLD.js → wardley-L42UT6IY-V3a5jBUh.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-YWT4CUSO-DalbSLu7.js → wardleyDiagram-YWT4CUSO-BMdJmf1X.js} +1 -1
- package/dist/web/assets/{xychartDiagram-2RQKCTM6-Bgnuf0j-.js → xychartDiagram-2RQKCTM6-iibKxvlU.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/src/schema-catalog.ts +1 -1
- package/dist/web/assets/channel-l7nIO4lY.js +0 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-BPFTU8oh.js +0 -1
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-BPFTU8oh.js +0 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-e0EPpmUp.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/chart-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/chart-DF01veTJ.js","assets/step-CWvwoXpJ.js","assets/band-BEGRCkg7.js","assets/init-BFKUnIhM.js","assets/ordinal-BQ3KlzSu.js","assets/linear-DfckWaYF.js","assets/defaultLocale-CrowFXzY.js","assets/time-DLVqCHvN.js","assets/mermaid.core-Q5Rkziel.js","assets/purify.es-CLGrRn1w.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
function Iae(e,t){for(var n=0;n<t.length;n++){const o=t[n];if(typeof o!="string"&&!Array.isArray(o)){for(const r in o)if(r!=="default"&&!(r in e)){const a=Object.getOwnPropertyDescriptor(o,r);a&&Object.defineProperty(e,r,a.get?a:{enumerable:!0,get:()=>o[r]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))o(r);new MutationObserver(r=>{for(const a of r)if(a.type==="childList")for(const i of a.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&o(i)}).observe(document,{childList:!0,subtree:!0});function n(r){const a={};return r.integrity&&(a.integrity=r.integrity),r.referrerPolicy&&(a.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?a.credentials="include":r.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function o(r){if(r.ep)return;r.ep=!0;const a=n(r);fetch(r.href,a)}})();var sP=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Qh(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var $Z={exports:{}},yz={},jZ={exports:{}},Qe={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react.production.min.js
|
|
@@ -8466,7 +8466,7 @@ Error generating stack: `+a.message+`
|
|
|
8466
8466
|
+`).split(`
|
|
8467
8467
|
`)),h=l.reduce((u,f)=>u.concat(...f),[]);return[l,h]}return[[],[]]},[e]);return m.useEffect(()=>{const c=(t==null?void 0:t.target)??iU,l=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const h=y=>{var x,v;if(r.current=y.ctrlKey||y.metaKey||y.shiftKey||y.altKey,(!r.current||r.current&&!l)&&GY(y))return!1;const k=cU(y.code,s);if(a.current.add(y[k]),sU(i,a.current,!1)){const M=((v=(x=y.composedPath)==null?void 0:x.call(y))==null?void 0:v[0])||y.target,w=(M==null?void 0:M.nodeName)==="BUTTON"||(M==null?void 0:M.nodeName)==="A";t.preventDefault!==!1&&(r.current||!w)&&y.preventDefault(),o(!0)}},u=y=>{const g=cU(y.code,s);sU(i,a.current,!0)?(o(!1),a.current.clear()):a.current.delete(y[g]),y.key==="Meta"&&a.current.clear(),r.current=!1},f=()=>{a.current.clear(),o(!1)};return c==null||c.addEventListener("keydown",h),c==null||c.addEventListener("keyup",u),window.addEventListener("blur",f),window.addEventListener("contextmenu",f),()=>{c==null||c.removeEventListener("keydown",h),c==null||c.removeEventListener("keyup",u),window.removeEventListener("blur",f),window.removeEventListener("contextmenu",f)}}},[e,o]),n}function sU(e,t,n){return e.filter(o=>n||o.length===t.size).some(o=>o.every(r=>t.has(r)))}function cU(e,t){return t.includes(e)?"code":"key"}const zze=()=>{const e=wt();return m.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:o}=e.getState();return o?o.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[o,r,a],panZoom:i}=e.getState();return i?(await i.setViewport({x:t.x??o,y:t.y??r,zoom:t.zoom??a},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,o]=e.getState().transform;return{x:t,y:n,zoom:o}},setCenter:async(t,n,o)=>e.getState().setCenter(t,n,o),fitBounds:async(t,n)=>{const{width:o,height:r,minZoom:a,maxZoom:i,panZoom:s}=e.getState(),c=bq(t,o,r,a,i,(n==null?void 0:n.padding)??.1);return s?(await s.setViewport(c,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:o,snapGrid:r,snapToGrid:a,domNode:i}=e.getState();if(!i)return t;const{x:s,y:c}=i.getBoundingClientRect(),l={x:t.x-s,y:t.y-c},h=n.snapGrid??r,u=n.snapToGrid??a;return df(l,o,u,h)},flowToScreenPosition:t=>{const{transform:n,domNode:o}=e.getState();if(!o)return t;const{x:r,y:a}=o.getBoundingClientRect(),i=OP(t,n);return{x:i.x+r,y:i.y+a}}}),[])};function kQ(e,t){const n=[],o=new Map,r=[];for(const a of e)if(a.type==="add"){r.push(a);continue}else if(a.type==="remove"||a.type==="replace")o.set(a.id,[a]);else{const i=o.get(a.id);i?i.push(a):o.set(a.id,[a])}for(const a of t){const i=o.get(a.id);if(!i){n.push(a);continue}if(i[0].type==="remove")continue;if(i[0].type==="replace"){n.push({...i[0].item});continue}const s={...a};for(const c of i)Rze(c,s);n.push(s)}return r.length&&r.forEach(a=>{a.index!==void 0?n.splice(a.index,0,{...a.item}):n.push({...a.item})}),n}function Rze(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function vQ(e,t){return kQ(e,t)}function xQ(e,t){return kQ(e,t)}function cd(e,t){return{id:e,type:"select",selected:t}}function Ru(e,t=new Set,n=!1){const o=[];for(const[r,a]of e){const i=t.has(r);!(a.selected===void 0&&!i)&&a.selected!==i&&(n&&(a.selected=i),o.push(cd(a.id,i)))}return o}function lU({items:e=[],lookup:t}){var r;const n=[],o=new Map(e.map(a=>[a.id,a]));for(const[a,i]of e.entries()){const s=t.get(i.id),c=((r=s==null?void 0:s.internals)==null?void 0:r.userNode)??s;c!==void 0&&c!==i&&n.push({id:i.id,item:i,type:"replace"}),c===void 0&&n.push({item:i,type:"add",index:a})}for(const[a]of t)o.get(a)===void 0&&n.push({id:a,type:"remove"});return n}function dU(e){return{id:e.id,type:"remove"}}const uU=e=>Wje(e),Tze=e=>HY(e);function wQ(e){return m.forwardRef(e)}function hU(e){const[t,n]=m.useState(BigInt(0)),[o]=m.useState(()=>Dze(()=>n(r=>r+BigInt(1))));return kH(()=>{const r=o.get();r.length&&(e(r),o.reset())},[t]),o}function Dze(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const MQ=m.createContext(null);function Hze({children:e}){const t=wt(),n=m.useCallback(s=>{const{nodes:c=[],setNodes:l,hasDefaultNodes:h,onNodesChange:u,nodeLookup:f,fitViewQueued:y,onNodesChangeMiddlewareMap:g}=t.getState();let k=c;for(const v of s)k=typeof v=="function"?v(k):v;let x=lU({items:k,lookup:f});for(const v of g.values())x=v(x);h&&l(k),x.length>0?u==null||u(x):y&&window.requestAnimationFrame(()=>{const{fitViewQueued:v,nodes:M,setNodes:w}=t.getState();v&&w(M)})},[]),o=hU(n),r=m.useCallback(s=>{const{edges:c=[],setEdges:l,hasDefaultEdges:h,onEdgesChange:u,edgeLookup:f}=t.getState();let y=c;for(const g of s)y=typeof g=="function"?g(y):g;h?l(y):u&&u(lU({items:y,lookup:f}))},[]),a=hU(r),i=m.useMemo(()=>({nodeQueue:o,edgeQueue:a}),[]);return p.jsx(MQ.Provider,{value:i,children:e})}function Oze(){const e=m.useContext(MQ);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const qze=e=>!!e.panZoom;function Uz(){const e=zze(),t=wt(),n=Oze(),o=De(qze),r=m.useMemo(()=>{const a=u=>t.getState().nodeLookup.get(u),i=u=>{n.nodeQueue.push(u)},s=u=>{n.edgeQueue.push(u)},c=u=>{var v,M;const{nodeLookup:f,nodeOrigin:y}=t.getState(),g=uU(u)?u:f.get(u.id),k=g.parentId?UY(g.position,g.measured,g.parentId,f,y):g.position,x={...g,position:k,width:((v=g.measured)==null?void 0:v.width)??g.width,height:((M=g.measured)==null?void 0:M.height)??g.height};return y0(x)},l=(u,f,y={replace:!1})=>{i(g=>g.map(k=>{if(k.id===u){const x=typeof f=="function"?f(k):f;return y.replace&&uU(x)?x:{...k,...x}}return k}))},h=(u,f,y={replace:!1})=>{s(g=>g.map(k=>{if(k.id===u){const x=typeof f=="function"?f(k):f;return y.replace&&Tze(x)?x:{...k,...x}}return k}))};return{getNodes:()=>t.getState().nodes.map(u=>({...u})),getNode:u=>{var f;return(f=a(u))==null?void 0:f.internals.userNode},getInternalNode:a,getEdges:()=>{const{edges:u=[]}=t.getState();return u.map(f=>({...f}))},getEdge:u=>t.getState().edgeLookup.get(u),setNodes:i,setEdges:s,addNodes:u=>{const f=Array.isArray(u)?u:[u];n.nodeQueue.push(y=>[...y,...f])},addEdges:u=>{const f=Array.isArray(u)?u:[u];n.edgeQueue.push(y=>[...y,...f])},toObject:()=>{const{nodes:u=[],edges:f=[],transform:y}=t.getState(),[g,k,x]=y;return{nodes:u.map(v=>({...v})),edges:f.map(v=>({...v})),viewport:{x:g,y:k,zoom:x}}},deleteElements:async({nodes:u=[],edges:f=[]})=>{const{nodes:y,edges:g,onNodesDelete:k,onEdgesDelete:x,triggerNodeChanges:v,triggerEdgeChanges:M,onDelete:w,onBeforeDelete:b}=t.getState(),{nodes:C,edges:_}=await Yje({nodesToRemove:u,edgesToRemove:f,nodes:y,edges:g,onBeforeDelete:b}),S=_.length>0,j=C.length>0;if(S){const P=_.map(dU);x==null||x(_),M(P)}if(j){const P=C.map(dU);k==null||k(C),v(P)}return(j||S)&&(w==null||w({nodes:C,edges:_})),{deletedNodes:C,deletedEdges:_}},getIntersectingNodes:(u,f=!0,y)=>{const g=qB(u),k=g?u:c(u),x=y!==void 0;return k?(y||t.getState().nodes).filter(v=>{const M=t.getState().nodeLookup.get(v.id);if(M&&!g&&(v.id===u.id||!M.internals.positionAbsolute))return!1;const w=y0(x?v:M),b=Th(w,k);return f&&b>0||b>=w.width*w.height||b>=k.width*k.height}):[]},isNodeIntersecting:(u,f,y=!0)=>{const k=qB(u)?u:c(u);if(!k)return!1;const x=Th(k,f);return y&&x>0||x>=f.width*f.height||x>=k.width*k.height},updateNode:l,updateNodeData:(u,f,y={replace:!1})=>{l(u,g=>{const k=typeof f=="function"?f(g):f;return y.replace?{...g,data:k}:{...g,data:{...g.data,...k}}},y)},updateEdge:h,updateEdgeData:(u,f,y={replace:!1})=>{h(u,g=>{const k=typeof f=="function"?f(g):f;return y.replace?{...g,data:k}:{...g,data:{...g.data,...k}}},y)},getNodesBounds:u=>{const{nodeLookup:f,nodeOrigin:y}=t.getState();return Gje(u,{nodeLookup:f,nodeOrigin:y})},getHandleConnections:({type:u,id:f,nodeId:y})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${y}-${u}${f?`-${f}`:""}`))==null?void 0:g.values())??[])},getNodeConnections:({type:u,handleId:f,nodeId:y})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${y}${u?f?`-${u}-${f}`:`-${u}`:""}`))==null?void 0:g.values())??[])},fitView:async u=>{const f=t.getState().fitViewResolver??tPe();return t.setState({fitViewQueued:!0,fitViewOptions:u,fitViewResolver:f}),n.nodeQueue.push(y=>[...y]),f.promise}}},[]);return m.useMemo(()=>({...r,...e,viewportInitialized:o}),[o])}const fU=e=>e.selected,Fze=typeof window<"u"?window:void 0;function Vze({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=wt(),{deleteElements:o}=Uz(),r=Oh(e,{actInsideInputWithModifier:!1}),a=Oh(t,{target:Fze});m.useEffect(()=>{if(r){const{edges:i,nodes:s}=n.getState();o({nodes:s.filter(fU),edges:i.filter(fU)}),n.setState({nodesSelectionActive:!1})}},[r]),m.useEffect(()=>{n.setState({multiSelectionActive:a})},[a])}function Bze(e){const t=wt();m.useEffect(()=>{const n=()=>{var r,a,i,s;if(!e.current||!(((a=(r=e.current).checkVisibility)==null?void 0:a.call(r))??!0))return!1;const o=_q(e.current);(o.height===0||o.width===0)&&((s=(i=t.getState()).onError)==null||s.call(i,"004",Rr.error004())),t.setState({width:o.width||500,height:o.height||500})};if(e.current){n(),window.addEventListener("resize",n);const o=new ResizeObserver(()=>n());return o.observe(e.current),()=>{window.removeEventListener("resize",n),o&&e.current&&o.unobserve(e.current)}}},[])}const Wz={position:"absolute",width:"100%",height:"100%",top:0,left:0},Uze=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Wze({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:o=!1,panOnScrollSpeed:r=.5,panOnScrollMode:a=xd.Free,zoomOnDoubleClick:i=!0,panOnDrag:s=!0,defaultViewport:c,translateExtent:l,minZoom:h,maxZoom:u,zoomActivationKeyCode:f,preventScrolling:y=!0,children:g,noWheelClassName:k,noPanClassName:x,onViewportChange:v,isControlledViewport:M,paneClickDistance:w,selectionOnDrag:b}){const C=wt(),_=m.useRef(null),{userSelectionActive:S,lib:j,connectionInProgress:P}=De(Uze,Lt),A=Oh(f),N=m.useRef();Bze(_);const R=m.useCallback(W=>{v==null||v({x:W[0],y:W[1],zoom:W[2]}),M||C.setState({transform:W})},[v,M]);return m.useEffect(()=>{if(_.current){N.current=DPe({domNode:_.current,minZoom:h,maxZoom:u,translateExtent:l,viewport:c,onDraggingChange:T=>C.setState(O=>O.paneDragging===T?O:{paneDragging:T}),onPanZoomStart:(T,O)=>{const{onViewportChangeStart:I,onMoveStart:z}=C.getState();z==null||z(T,O),I==null||I(O)},onPanZoom:(T,O)=>{const{onViewportChange:I,onMove:z}=C.getState();z==null||z(T,O),I==null||I(O)},onPanZoomEnd:(T,O)=>{const{onViewportChangeEnd:I,onMoveEnd:z}=C.getState();z==null||z(T,O),I==null||I(O)}});const{x:W,y:$,zoom:H}=N.current.getViewport();return C.setState({panZoom:N.current,transform:[W,$,H],domNode:_.current.closest(".react-flow")}),()=>{var T;(T=N.current)==null||T.destroy()}}},[]),m.useEffect(()=>{var W;(W=N.current)==null||W.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:o,panOnScrollSpeed:r,panOnScrollMode:a,zoomOnDoubleClick:i,panOnDrag:s,zoomActivationKeyPressed:A,preventScrolling:y,noPanClassName:x,userSelectionActive:S,noWheelClassName:k,lib:j,onTransformChange:R,connectionInProgress:P,selectionOnDrag:b,paneClickDistance:w})},[e,t,n,o,r,a,i,s,A,y,x,S,k,j,R,P,b,w]),p.jsx("div",{className:"react-flow__renderer",ref:_,style:Wz,children:g})}const Gze=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Zze(){const{userSelectionActive:e,userSelectionRect:t}=De(Gze,Lt);return e&&t?p.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const kT=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},Xze=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function Kze({isSelecting:e,selectionKeyPressed:t,selectionMode:n=f0.Full,panOnDrag:o,paneClickDistance:r,selectionOnDrag:a,onSelectionStart:i,onSelectionEnd:s,onPaneClick:c,onPaneContextMenu:l,onPaneScroll:h,onPaneMouseEnter:u,onPaneMouseMove:f,onPaneMouseLeave:y,children:g}){const k=wt(),{userSelectionActive:x,elementsSelectable:v,dragging:M,connectionInProgress:w}=De(Xze,Lt),b=v&&(e||x),C=m.useRef(null),_=m.useRef(),S=m.useRef(new Set),j=m.useRef(new Set),P=m.useRef(!1),A=I=>{if(P.current||w){P.current=!1;return}c==null||c(I),k.getState().resetSelectedElements(),k.setState({nodesSelectionActive:!1})},N=I=>{if(Array.isArray(o)&&(o!=null&&o.includes(2))){I.preventDefault();return}l==null||l(I)},R=h?I=>h(I):void 0,W=I=>{P.current&&(I.stopPropagation(),P.current=!1)},$=I=>{var X,Y;const{domNode:z}=k.getState();if(_.current=z==null?void 0:z.getBoundingClientRect(),!_.current)return;const L=I.target===C.current;if(!L&&!!I.target.closest(".nokey")||!e||!(a&&L||t)||I.button!==0||!I.isPrimary)return;(Y=(X=I.target)==null?void 0:X.setPointerCapture)==null||Y.call(X,I.pointerId),P.current=!1;const{x:E,y:K}=Bo(I.nativeEvent,_.current);k.setState({userSelectionRect:{width:0,height:0,startX:E,startY:K,x:E,y:K}}),L||(I.stopPropagation(),I.preventDefault())},H=I=>{const{userSelectionRect:z,transform:L,nodeLookup:F,edgeLookup:D,connectionLookup:E,triggerNodeChanges:K,triggerEdgeChanges:X,defaultEdgeOptions:Y,resetSelectedElements:Q}=k.getState();if(!_.current||!z)return;const{x:te,y:ne}=Bo(I.nativeEvent,_.current),{startX:ie,startY:ke}=z;if(!P.current){const Re=t?0:r;if(Math.hypot(te-ie,ne-ke)<=Re)return;Q(),i==null||i(I)}P.current=!0;const ge={startX:ie,startY:ke,x:te<ie?te:ie,y:ne<ke?ne:ke,width:Math.abs(te-ie),height:Math.abs(ne-ke)},ve=S.current,ce=j.current;S.current=new Set(Mq(F,ge,L,n===f0.Partial,!0).map(Re=>Re.id)),j.current=new Set;const Ce=(Y==null?void 0:Y.selectable)??!0;for(const Re of S.current){const st=E.get(Re);if(st)for(const{edgeId:Vt}of st.values()){const It=D.get(Vt);It&&(It.selectable??Ce)&&j.current.add(Vt)}}if(!FB(ve,S.current)){const Re=Ru(F,S.current,!0);K(Re)}if(!FB(ce,j.current)){const Re=Ru(D,j.current);X(Re)}k.setState({userSelectionRect:ge,userSelectionActive:!0,nodesSelectionActive:!1})},T=I=>{var z,L;I.button===0&&((L=(z=I.target)==null?void 0:z.releasePointerCapture)==null||L.call(z,I.pointerId),!x&&I.target===C.current&&k.getState().userSelectionRect&&(A==null||A(I)),k.setState({userSelectionActive:!1,userSelectionRect:null}),P.current&&(s==null||s(I),k.setState({nodesSelectionActive:S.current.size>0})))},O=o===!0||Array.isArray(o)&&o.includes(0);return p.jsxs("div",{className:Kt(["react-flow__pane",{draggable:O,dragging:M,selection:e}]),onClick:b?void 0:kT(A,C),onContextMenu:kT(N,C),onWheel:kT(R,C),onPointerEnter:b?void 0:u,onPointerMove:b?H:f,onPointerUp:b?T:void 0,onPointerDownCapture:b?$:void 0,onClickCapture:b?W:void 0,onPointerLeave:y,ref:C,style:Wz,children:[g,p.jsx(Zze,{})]})}function vH({id:e,store:t,unselect:n=!1,nodeRef:o}){const{addSelectedNodes:r,unselectNodesAndEdges:a,multiSelectionActive:i,nodeLookup:s,onError:c}=t.getState(),l=s.get(e);if(!l){c==null||c("012",Rr.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&i)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>{var h;return(h=o==null?void 0:o.current)==null?void 0:h.blur()})):r([e])}function bQ({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:o,nodeId:r,isSelectable:a,nodeClickDistance:i}){const s=wt(),[c,l]=m.useState(!1),h=m.useRef();return m.useEffect(()=>{h.current=_Pe({getStoreItems:()=>s.getState(),onNodeMouseDown:u=>{vH({id:u,store:s,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}})},[]),m.useEffect(()=>{if(!(t||!e.current||!h.current))return h.current.update({noDragClassName:n,handleSelector:o,domNode:e.current,isSelectable:a,nodeId:r,nodeClickDistance:i}),()=>{var u;(u=h.current)==null||u.destroy()}},[n,o,t,a,e,r,i]),c}const Yze=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function _Q(){const e=wt();return m.useCallback(n=>{const{nodeExtent:o,snapToGrid:r,snapGrid:a,nodesDraggable:i,onError:s,updateNodePositions:c,nodeLookup:l,nodeOrigin:h}=e.getState(),u=new Map,f=Yze(i),y=r?a[0]:5,g=r?a[1]:5,k=n.direction.x*y*n.factor,x=n.direction.y*g*n.factor;for(const[,v]of l){if(!f(v))continue;let M={x:v.internals.positionAbsolute.x+k,y:v.internals.positionAbsolute.y+x};r&&(M=lf(M,a));const{position:w,positionAbsolute:b}=OY({nodeId:v.id,nextPosition:M,nodeLookup:l,nodeExtent:o,nodeOrigin:h,onError:s});v.position=w,v.internals.positionAbsolute=b,u.set(v.id,v)}c(u)},[])}const Aq=m.createContext(null),Qze=Aq.Provider;Aq.Consumer;const CQ=()=>m.useContext(Aq),Jze=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),eRe=(e,t,n)=>o=>{const{connectionClickStartHandle:r,connectionMode:a,connection:i}=o,{fromHandle:s,toHandle:c,isValid:l}=i,h=(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n;return{connectingFrom:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.id)===t&&(s==null?void 0:s.type)===n,connectingTo:h,clickConnecting:(r==null?void 0:r.nodeId)===e&&(r==null?void 0:r.id)===t&&(r==null?void 0:r.type)===n,isPossibleEndHandle:a===h0.Strict?(s==null?void 0:s.type)!==n:e!==(s==null?void 0:s.nodeId)||t!==(s==null?void 0:s.id),connectionInProcess:!!s,clickConnectionInProcess:!!r,valid:h&&l}};function tRe({type:e="source",position:t=ye.Top,isValidConnection:n,isConnectable:o=!0,isConnectableStart:r=!0,isConnectableEnd:a=!0,id:i,onConnect:s,children:c,className:l,onMouseDown:h,onTouchStart:u,...f},y){var H,T;const g=i||null,k=e==="target",x=wt(),v=CQ(),{connectOnClick:M,noPanClassName:w,rfId:b}=De(Jze,Lt),{connectingFrom:C,connectingTo:_,clickConnecting:S,isPossibleEndHandle:j,connectionInProcess:P,clickConnectionInProcess:A,valid:N}=De(eRe(v,g,e),Lt);v||(T=(H=x.getState()).onError)==null||T.call(H,"010",Rr.error010());const R=O=>{const{defaultEdgeOptions:I,onConnect:z,hasDefaultEdges:L}=x.getState(),F={...I,...O};if(L){const{edges:D,setEdges:E}=x.getState();E(cPe(F,D))}z==null||z(F),s==null||s(F)},W=O=>{if(!v)return;const I=ZY(O.nativeEvent);if(r&&(I&&O.button===0||!I)){const z=x.getState();gH.onPointerDown(O.nativeEvent,{handleDomNode:O.currentTarget,autoPanOnConnect:z.autoPanOnConnect,connectionMode:z.connectionMode,connectionRadius:z.connectionRadius,domNode:z.domNode,nodeLookup:z.nodeLookup,lib:z.lib,isTarget:k,handleId:g,nodeId:v,flowId:z.rfId,panBy:z.panBy,cancelConnection:z.cancelConnection,onConnectStart:z.onConnectStart,onConnectEnd:(...L)=>{var F,D;return(D=(F=x.getState()).onConnectEnd)==null?void 0:D.call(F,...L)},updateConnection:z.updateConnection,onConnect:R,isValidConnection:n||((...L)=>{var F,D;return((D=(F=x.getState()).isValidConnection)==null?void 0:D.call(F,...L))??!0}),getTransform:()=>x.getState().transform,getFromHandle:()=>x.getState().connection.fromHandle,autoPanSpeed:z.autoPanSpeed,dragThreshold:z.connectionDragThreshold})}I?h==null||h(O):u==null||u(O)},$=O=>{const{onClickConnectStart:I,onClickConnectEnd:z,connectionClickStartHandle:L,connectionMode:F,isValidConnection:D,lib:E,rfId:K,nodeLookup:X,connection:Y}=x.getState();if(!v||!L&&!r)return;if(!L){I==null||I(O.nativeEvent,{nodeId:v,handleId:g,handleType:e}),x.setState({connectionClickStartHandle:{nodeId:v,type:e,id:g}});return}const Q=WY(O.target),te=n||D,{connection:ne,isValid:ie}=gH.isValid(O.nativeEvent,{handle:{nodeId:v,id:g,type:e},connectionMode:F,fromNodeId:L.nodeId,fromHandleId:L.id||null,fromType:L.type,isValidConnection:te,flowId:K,doc:Q,lib:E,nodeLookup:X});ie&&ne&&R(ne);const ke=structuredClone(Y);delete ke.inProgress,ke.toPosition=ke.toHandle?ke.toHandle.position:null,z==null||z(O,ke),x.setState({connectionClickStartHandle:null})};return p.jsx("div",{"data-handleid":g,"data-nodeid":v,"data-handlepos":t,"data-id":`${b}-${v}-${g}-${e}`,className:Kt(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",w,l,{source:!k,target:k,connectable:o,connectablestart:r,connectableend:a,clickconnecting:S,connectingfrom:C,connectingto:_,valid:N,connectionindicator:o&&(!P||j)&&(P||A?a:r)}]),onMouseDown:W,onTouchStart:W,onClick:M?$:void 0,ref:y,...f,children:c})}const ht=m.memo(wQ(tRe));function nRe({data:e,isConnectable:t,sourcePosition:n=ye.Bottom}){return p.jsxs(p.Fragment,{children:[e==null?void 0:e.label,p.jsx(ht,{type:"source",position:n,isConnectable:t})]})}function oRe({data:e,isConnectable:t,targetPosition:n=ye.Top,sourcePosition:o=ye.Bottom}){return p.jsxs(p.Fragment,{children:[p.jsx(ht,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,p.jsx(ht,{type:"source",position:o,isConnectable:t})]})}function rRe(){return null}function aRe({data:e,isConnectable:t,targetPosition:n=ye.Top}){return p.jsxs(p.Fragment,{children:[p.jsx(ht,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const qP={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},pU={input:nRe,default:oRe,output:aRe,group:rRe};function iRe(e){var t,n,o,r;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((o=e.style)==null?void 0:o.width),height:e.height??((r=e.style)==null?void 0:r.height)}}const sRe=e=>{const{width:t,height:n,x:o,y:r}=cf(e.nodeLookup,{filter:a=>!!a.selected});return{width:Vo(t)?t:null,height:Vo(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${o}px,${r}px)`}};function cRe({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const o=wt(),{width:r,height:a,transformString:i,userSelectionActive:s}=De(sRe,Lt),c=_Q(),l=m.useRef(null);m.useEffect(()=>{var y;n||(y=l.current)==null||y.focus({preventScroll:!0})},[n]);const h=!s&&r!==null&&a!==null;if(bQ({nodeRef:l,disabled:!h}),!h)return null;const u=e?y=>{const g=o.getState().nodes.filter(k=>k.selected);e(y,g)}:void 0,f=y=>{Object.prototype.hasOwnProperty.call(qP,y.key)&&(y.preventDefault(),c({direction:qP[y.key],factor:y.shiftKey?4:1}))};return p.jsx("div",{className:Kt(["react-flow__nodesselection","react-flow__container",t]),style:{transform:i},children:p.jsx("div",{ref:l,className:"react-flow__nodesselection-rect",onContextMenu:u,tabIndex:n?void 0:-1,onKeyDown:n?void 0:f,style:{width:r,height:a}})})}const yU=typeof window<"u"?window:void 0,lRe=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function SQ({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:a,onPaneScroll:i,paneClickDistance:s,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:h,selectionMode:u,onSelectionStart:f,onSelectionEnd:y,multiSelectionKeyCode:g,panActivationKeyCode:k,zoomActivationKeyCode:x,elementsSelectable:v,zoomOnScroll:M,zoomOnPinch:w,panOnScroll:b,panOnScrollSpeed:C,panOnScrollMode:_,zoomOnDoubleClick:S,panOnDrag:j,defaultViewport:P,translateExtent:A,minZoom:N,maxZoom:R,preventScrolling:W,onSelectionContextMenu:$,noWheelClassName:H,noPanClassName:T,disableKeyboardA11y:O,onViewportChange:I,isControlledViewport:z}){const{nodesSelectionActive:L,userSelectionActive:F}=De(lRe,Lt),D=Oh(l,{target:yU}),E=Oh(k,{target:yU}),K=E||j,X=E||b,Y=h&&K!==!0,Q=D||F||Y;return Vze({deleteKeyCode:c,multiSelectionKeyCode:g}),p.jsx(Wze,{onPaneContextMenu:a,elementsSelectable:v,zoomOnScroll:M,zoomOnPinch:w,panOnScroll:X,panOnScrollSpeed:C,panOnScrollMode:_,zoomOnDoubleClick:S,panOnDrag:!D&&K,defaultViewport:P,translateExtent:A,minZoom:N,maxZoom:R,zoomActivationKeyCode:x,preventScrolling:W,noWheelClassName:H,noPanClassName:T,onViewportChange:I,isControlledViewport:z,paneClickDistance:s,selectionOnDrag:Y,children:p.jsxs(Kze,{onSelectionStart:f,onSelectionEnd:y,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:a,onPaneScroll:i,panOnDrag:K,isSelecting:!!Q,selectionMode:u,selectionKeyPressed:D,paneClickDistance:s,selectionOnDrag:Y,children:[e,L&&p.jsx(cRe,{onSelectionContextMenu:$,noPanClassName:T,disableKeyboardA11y:O})]})})}SQ.displayName="FlowRenderer";const dRe=m.memo(SQ),uRe=e=>t=>e?Mq(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function hRe(e){return De(m.useCallback(uRe(e),[e]),Lt)}const fRe=e=>e.updateNodeInternals;function pRe(){const e=De(fRe),[t]=m.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const o=new Map;n.forEach(r=>{const a=r.target.getAttribute("data-id");o.set(a,{id:a,nodeElement:r.target,force:!0})}),e(o)}));return m.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function yRe({node:e,nodeType:t,hasDimensions:n,resizeObserver:o}){const r=wt(),a=m.useRef(null),i=m.useRef(null),s=m.useRef(e.sourcePosition),c=m.useRef(e.targetPosition),l=m.useRef(t),h=n&&!!e.internals.handleBounds;return m.useEffect(()=>{a.current&&!e.hidden&&(!h||i.current!==a.current)&&(i.current&&(o==null||o.unobserve(i.current)),o==null||o.observe(a.current),i.current=a.current)},[h,e.hidden]),m.useEffect(()=>()=>{i.current&&(o==null||o.unobserve(i.current),i.current=null)},[]),m.useEffect(()=>{if(a.current){const u=l.current!==t,f=s.current!==e.sourcePosition,y=c.current!==e.targetPosition;(u||f||y)&&(l.current=t,s.current=e.sourcePosition,c.current=e.targetPosition,r.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}function mRe({id:e,onClick:t,onMouseEnter:n,onMouseMove:o,onMouseLeave:r,onContextMenu:a,onDoubleClick:i,nodesDraggable:s,elementsSelectable:c,nodesConnectable:l,nodesFocusable:h,resizeObserver:u,noDragClassName:f,noPanClassName:y,disableKeyboardA11y:g,rfId:k,nodeTypes:x,nodeClickDistance:v,onError:M}){const{node:w,internals:b,isParent:C}=De(te=>{const ne=te.nodeLookup.get(e),ie=te.parentLookup.has(e);return{node:ne,internals:ne.internals,isParent:ie}},Lt);let _=w.type||"default",S=(x==null?void 0:x[_])||pU[_];S===void 0&&(M==null||M("003",Rr.error003(_)),_="default",S=(x==null?void 0:x.default)||pU.default);const j=!!(w.draggable||s&&typeof w.draggable>"u"),P=!!(w.selectable||c&&typeof w.selectable>"u"),A=!!(w.connectable||l&&typeof w.connectable>"u"),N=!!(w.focusable||h&&typeof w.focusable>"u"),R=wt(),W=BY(w),$=yRe({node:w,nodeType:_,hasDimensions:W,resizeObserver:u}),H=bQ({nodeRef:$,disabled:w.hidden||!j,noDragClassName:f,handleSelector:w.dragHandle,nodeId:e,isSelectable:P,nodeClickDistance:v}),T=_Q();if(w.hidden)return null;const O=Ia(w),I=iRe(w),z=P||j||t||n||o||r,L=n?te=>n(te,{...b.userNode}):void 0,F=o?te=>o(te,{...b.userNode}):void 0,D=r?te=>r(te,{...b.userNode}):void 0,E=a?te=>a(te,{...b.userNode}):void 0,K=i?te=>i(te,{...b.userNode}):void 0,X=te=>{const{selectNodesOnDrag:ne,nodeDragThreshold:ie}=R.getState();P&&(!ne||!j||ie>0)&&vH({id:e,store:R,nodeRef:$}),t&&t(te,{...b.userNode})},Y=te=>{if(!(GY(te.nativeEvent)||g)){if(zY.includes(te.key)&&P){const ne=te.key==="Escape";vH({id:e,store:R,unselect:ne,nodeRef:$})}else if(j&&w.selected&&Object.prototype.hasOwnProperty.call(qP,te.key)){te.preventDefault();const{ariaLabelConfig:ne}=R.getState();R.setState({ariaLiveMessage:ne["node.a11yDescription.ariaLiveMessage"]({direction:te.key.replace("Arrow","").toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),T({direction:qP[te.key],factor:te.shiftKey?4:1})}}},Q=()=>{var ce;if(g||!((ce=$.current)!=null&&ce.matches(":focus-visible")))return;const{transform:te,width:ne,height:ie,autoPanOnNodeFocus:ke,setCenter:ge}=R.getState();if(!ke)return;Mq(new Map([[e,w]]),{x:0,y:0,width:ne,height:ie},te,!0).length>0||ge(w.position.x+O.width/2,w.position.y+O.height/2,{zoom:te[2]})};return p.jsx("div",{className:Kt(["react-flow__node",`react-flow__node-${_}`,{[y]:j},w.className,{selected:w.selected,selectable:P,parent:C,draggable:j,dragging:H}]),ref:$,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:z?"all":"none",visibility:W?"visible":"hidden",...w.style,...I},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:L,onMouseMove:F,onMouseLeave:D,onContextMenu:E,onClick:X,onDoubleClick:K,onKeyDown:N?Y:void 0,tabIndex:N?0:void 0,onFocus:N?Q:void 0,role:w.ariaRole??(N?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${yQ}-${k}`,"aria-label":w.ariaLabel,...w.domAttributes,children:p.jsx(Qze,{value:e,children:p.jsx(S,{id:e,data:w.data,type:_,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:w.selected??!1,selectable:P,draggable:j,deletable:w.deletable??!0,isConnectable:A,sourcePosition:w.sourcePosition,targetPosition:w.targetPosition,dragging:H,dragHandle:w.dragHandle,zIndex:b.z,parentId:w.parentId,...O})})})}var gRe=m.memo(mRe);const kRe=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function LQ(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:r,onError:a}=De(kRe,Lt),i=hRe(e.onlyRenderVisibleElements),s=pRe();return p.jsx("div",{className:"react-flow__nodes",style:Wz,children:i.map(c=>p.jsx(gRe,{id:c,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:s,nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:a},c))})}LQ.displayName="NodeRenderer";const vRe=m.memo(LQ);function xRe(e){return De(m.useCallback(n=>{if(!e)return n.edges.map(r=>r.id);const o=[];if(n.width&&n.height)for(const r of n.edges){const a=n.nodeLookup.get(r.source),i=n.nodeLookup.get(r.target);a&&i&&aPe({sourceNode:a,targetNode:i,width:n.width,height:n.height,transform:n.transform})&&o.push(r.id)}return o},[e]),Lt)}const wRe=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return p.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},MRe=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return p.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},mU={[Rh.Arrow]:wRe,[Rh.ArrowClosed]:MRe};function bRe(e){const t=wt();return m.useMemo(()=>{var r,a;return Object.prototype.hasOwnProperty.call(mU,e)?mU[e]:((a=(r=t.getState()).onError)==null||a.call(r,"009",Rr.error009(e)),null)},[e])}const _Re=({id:e,type:t,color:n,width:o=12.5,height:r=12.5,markerUnits:a="strokeWidth",strokeWidth:i,orient:s="auto-start-reverse"})=>{const c=bRe(t);return c?p.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${o}`,markerHeight:`${r}`,viewBox:"-10 -10 20 20",markerUnits:a,orient:s,refX:"0",refY:"0",children:p.jsx(c,{color:n,strokeWidth:i})}):null},IQ=({defaultColor:e,rfId:t})=>{const n=De(a=>a.edges),o=De(a=>a.defaultEdgeOptions),r=m.useMemo(()=>fPe(n,{id:t,defaultColor:e,defaultMarkerStart:o==null?void 0:o.markerStart,defaultMarkerEnd:o==null?void 0:o.markerEnd}),[n,o,t,e]);return r.length?p.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:p.jsx("defs",{children:r.map(a=>p.jsx(_Re,{id:a.id,type:a.type,color:a.color,width:a.width,height:a.height,markerUnits:a.markerUnits,strokeWidth:a.strokeWidth,orient:a.orient},a.id))})}):null};IQ.displayName="MarkerDefinitions";var CRe=m.memo(IQ);function NQ({x:e,y:t,label:n,labelStyle:o,labelShowBg:r=!0,labelBgStyle:a,labelBgPadding:i=[2,4],labelBgBorderRadius:s=2,children:c,className:l,...h}){const[u,f]=m.useState({x:1,y:0,width:0,height:0}),y=Kt(["react-flow__edge-textwrapper",l]),g=m.useRef(null);return m.useEffect(()=>{if(g.current){const k=g.current.getBBox();f({x:k.x,y:k.y,width:k.width,height:k.height})}},[n]),n?p.jsxs("g",{transform:`translate(${e-u.width/2} ${t-u.height/2})`,className:y,visibility:u.width?"visible":"hidden",...h,children:[r&&p.jsx("rect",{width:u.width+2*i[0],x:-i[0],y:-i[1],height:u.height+2*i[1],className:"react-flow__edge-textbg",style:a,rx:s,ry:s}),p.jsx("text",{className:"react-flow__edge-text",y:u.height/2,dy:"0.3em",ref:g,style:o,children:n}),c]}):null}NQ.displayName="EdgeText";const SRe=m.memo(NQ);function uf({path:e,labelX:t,labelY:n,label:o,labelStyle:r,labelShowBg:a,labelBgStyle:i,labelBgPadding:s,labelBgBorderRadius:c,interactionWidth:l=20,...h}){return p.jsxs(p.Fragment,{children:[p.jsx("path",{...h,d:e,fill:"none",className:Kt(["react-flow__edge-path",h.className])}),l?p.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:l,className:"react-flow__edge-interaction"}):null,o&&Vo(t)&&Vo(n)?p.jsx(SRe,{x:t,y:n,label:o,labelStyle:r,labelShowBg:a,labelBgStyle:i,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function gU({pos:e,x1:t,y1:n,x2:o,y2:r}){return e===ye.Left||e===ye.Right?[.5*(t+o),n]:[t,.5*(n+r)]}function AQ({sourceX:e,sourceY:t,sourcePosition:n=ye.Bottom,targetX:o,targetY:r,targetPosition:a=ye.Top}){const[i,s]=gU({pos:n,x1:e,y1:t,x2:o,y2:r}),[c,l]=gU({pos:a,x1:o,y1:r,x2:e,y2:t}),[h,u,f,y]=XY({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:i,sourceControlY:s,targetControlX:c,targetControlY:l});return[`M${e},${t} C${i},${s} ${c},${l} ${o},${r}`,h,u,f,y]}function EQ(e){return m.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:a,sourcePosition:i,targetPosition:s,label:c,labelStyle:l,labelShowBg:h,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:y,style:g,markerEnd:k,markerStart:x,interactionWidth:v})=>{const[M,w,b]=AQ({sourceX:n,sourceY:o,sourcePosition:i,targetX:r,targetY:a,targetPosition:s}),C=e.isInternal?void 0:t;return p.jsx(uf,{id:C,path:M,labelX:w,labelY:b,label:c,labelStyle:l,labelShowBg:h,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:y,style:g,markerEnd:k,markerStart:x,interactionWidth:v})})}const LRe=EQ({isInternal:!1}),$Q=EQ({isInternal:!0});LRe.displayName="SimpleBezierEdge";$Q.displayName="SimpleBezierEdgeInternal";function jQ(e){return m.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:a,label:i,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:h,labelBgBorderRadius:u,style:f,sourcePosition:y=ye.Bottom,targetPosition:g=ye.Top,markerEnd:k,markerStart:x,pathOptions:v,interactionWidth:M})=>{const[w,b,C]=Hh({sourceX:n,sourceY:o,sourcePosition:y,targetX:r,targetY:a,targetPosition:g,borderRadius:v==null?void 0:v.borderRadius,offset:v==null?void 0:v.offset,stepPosition:v==null?void 0:v.stepPosition}),_=e.isInternal?void 0:t;return p.jsx(uf,{id:_,path:w,labelX:b,labelY:C,label:i,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:h,labelBgBorderRadius:u,style:f,markerEnd:k,markerStart:x,interactionWidth:M})})}const PQ=jQ({isInternal:!1}),zQ=jQ({isInternal:!0});PQ.displayName="SmoothStepEdge";zQ.displayName="SmoothStepEdgeInternal";function RQ(e){return m.memo(({id:t,...n})=>{var r;const o=e.isInternal?void 0:t;return p.jsx(PQ,{...n,id:o,pathOptions:m.useMemo(()=>{var a;return{borderRadius:0,offset:(a=n.pathOptions)==null?void 0:a.offset}},[(r=n.pathOptions)==null?void 0:r.offset])})})}const IRe=RQ({isInternal:!1}),TQ=RQ({isInternal:!0});IRe.displayName="StepEdge";TQ.displayName="StepEdgeInternal";function DQ(e){return m.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:a,label:i,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:h,labelBgBorderRadius:u,style:f,markerEnd:y,markerStart:g,interactionWidth:k})=>{const[x,v,M]=YY({sourceX:n,sourceY:o,targetX:r,targetY:a}),w=e.isInternal?void 0:t;return p.jsx(uf,{id:w,path:x,labelX:v,labelY:M,label:i,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:h,labelBgBorderRadius:u,style:f,markerEnd:y,markerStart:g,interactionWidth:k})})}const NRe=DQ({isInternal:!1}),HQ=DQ({isInternal:!0});NRe.displayName="StraightEdge";HQ.displayName="StraightEdgeInternal";function OQ(e){return m.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:a,sourcePosition:i=ye.Bottom,targetPosition:s=ye.Top,label:c,labelStyle:l,labelShowBg:h,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:y,style:g,markerEnd:k,markerStart:x,pathOptions:v,interactionWidth:M})=>{const[w,b,C]=qz({sourceX:n,sourceY:o,sourcePosition:i,targetX:r,targetY:a,targetPosition:s,curvature:v==null?void 0:v.curvature}),_=e.isInternal?void 0:t;return p.jsx(uf,{id:_,path:w,labelX:b,labelY:C,label:c,labelStyle:l,labelShowBg:h,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:y,style:g,markerEnd:k,markerStart:x,interactionWidth:M})})}const ARe=OQ({isInternal:!1}),qQ=OQ({isInternal:!0});ARe.displayName="BezierEdge";qQ.displayName="BezierEdgeInternal";const kU={default:qQ,straight:HQ,step:TQ,smoothstep:zQ,simplebezier:$Q},vU={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},ERe=(e,t,n)=>n===ye.Left?e-t:n===ye.Right?e+t:e,$Re=(e,t,n)=>n===ye.Top?e-t:n===ye.Bottom?e+t:e,xU="react-flow__edgeupdater";function wU({position:e,centerX:t,centerY:n,radius:o=10,onMouseDown:r,onMouseEnter:a,onMouseOut:i,type:s}){return p.jsx("circle",{onMouseDown:r,onMouseEnter:a,onMouseOut:i,className:Kt([xU,`${xU}-${s}`]),cx:ERe(t,o,e),cy:$Re(n,o,e),r:o,stroke:"transparent",fill:"transparent"})}function jRe({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:o,sourceY:r,targetX:a,targetY:i,sourcePosition:s,targetPosition:c,onReconnect:l,onReconnectStart:h,onReconnectEnd:u,setReconnecting:f,setUpdateHover:y}){const g=wt(),k=(b,C)=>{if(b.button!==0)return;const{autoPanOnConnect:_,domNode:S,connectionMode:j,connectionRadius:P,lib:A,onConnectStart:N,cancelConnection:R,nodeLookup:W,rfId:$,panBy:H,updateConnection:T}=g.getState(),O=C.type==="target",I=(F,D)=>{f(!1),u==null||u(F,n,C.type,D)},z=F=>l==null?void 0:l(n,F),L=(F,D)=>{f(!0),h==null||h(b,n,C.type),N==null||N(F,D)};gH.onPointerDown(b.nativeEvent,{autoPanOnConnect:_,connectionMode:j,connectionRadius:P,domNode:S,handleId:C.id,nodeId:C.nodeId,nodeLookup:W,isTarget:O,edgeUpdaterType:C.type,lib:A,flowId:$,cancelConnection:R,panBy:H,isValidConnection:(...F)=>{var D,E;return((E=(D=g.getState()).isValidConnection)==null?void 0:E.call(D,...F))??!0},onConnect:z,onConnectStart:L,onConnectEnd:(...F)=>{var D,E;return(E=(D=g.getState()).onConnectEnd)==null?void 0:E.call(D,...F)},onReconnectEnd:I,updateConnection:T,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:b.currentTarget})},x=b=>k(b,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),v=b=>k(b,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),M=()=>y(!0),w=()=>y(!1);return p.jsxs(p.Fragment,{children:[(e===!0||e==="source")&&p.jsx(wU,{position:s,centerX:o,centerY:r,radius:t,onMouseDown:x,onMouseEnter:M,onMouseOut:w,type:"source"}),(e===!0||e==="target")&&p.jsx(wU,{position:c,centerX:a,centerY:i,radius:t,onMouseDown:v,onMouseEnter:M,onMouseOut:w,type:"target"})]})}function PRe({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:o,onClick:r,onDoubleClick:a,onContextMenu:i,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,reconnectRadius:h,onReconnect:u,onReconnectStart:f,onReconnectEnd:y,rfId:g,edgeTypes:k,noPanClassName:x,onError:v,disableKeyboardA11y:M}){let w=De(ge=>ge.edgeLookup.get(e));const b=De(ge=>ge.defaultEdgeOptions);w=b?{...b,...w}:w;let C=w.type||"default",_=(k==null?void 0:k[C])||kU[C];_===void 0&&(v==null||v("011",Rr.error011(C)),C="default",_=(k==null?void 0:k.default)||kU.default);const S=!!(w.focusable||t&&typeof w.focusable>"u"),j=typeof u<"u"&&(w.reconnectable||n&&typeof w.reconnectable>"u"),P=!!(w.selectable||o&&typeof w.selectable>"u"),A=m.useRef(null),[N,R]=m.useState(!1),[W,$]=m.useState(!1),H=wt(),{zIndex:T,sourceX:O,sourceY:I,targetX:z,targetY:L,sourcePosition:F,targetPosition:D}=De(m.useCallback(ge=>{const ve=ge.nodeLookup.get(w.source),ce=ge.nodeLookup.get(w.target);if(!ve||!ce)return{zIndex:w.zIndex,...vU};const Ce=hPe({id:e,sourceNode:ve,targetNode:ce,sourceHandle:w.sourceHandle||null,targetHandle:w.targetHandle||null,connectionMode:ge.connectionMode,onError:v});return{zIndex:rPe({selected:w.selected,zIndex:w.zIndex,sourceNode:ve,targetNode:ce,elevateOnSelect:ge.elevateEdgesOnSelect,zIndexMode:ge.zIndexMode}),...Ce||vU}},[w.source,w.target,w.sourceHandle,w.targetHandle,w.selected,w.zIndex]),Lt),E=m.useMemo(()=>w.markerStart?`url('#${yH(w.markerStart,g)}')`:void 0,[w.markerStart,g]),K=m.useMemo(()=>w.markerEnd?`url('#${yH(w.markerEnd,g)}')`:void 0,[w.markerEnd,g]);if(w.hidden||O===null||I===null||z===null||L===null)return null;const X=ge=>{var Re;const{addSelectedEdges:ve,unselectNodesAndEdges:ce,multiSelectionActive:Ce}=H.getState();P&&(H.setState({nodesSelectionActive:!1}),w.selected&&Ce?(ce({nodes:[],edges:[w]}),(Re=A.current)==null||Re.blur()):ve([e])),r&&r(ge,w)},Y=a?ge=>{a(ge,{...w})}:void 0,Q=i?ge=>{i(ge,{...w})}:void 0,te=s?ge=>{s(ge,{...w})}:void 0,ne=c?ge=>{c(ge,{...w})}:void 0,ie=l?ge=>{l(ge,{...w})}:void 0,ke=ge=>{var ve;if(!M&&zY.includes(ge.key)&&P){const{unselectNodesAndEdges:ce,addSelectedEdges:Ce}=H.getState();ge.key==="Escape"?((ve=A.current)==null||ve.blur(),ce({edges:[w]})):Ce([e])}};return p.jsx("svg",{style:{zIndex:T},children:p.jsxs("g",{className:Kt(["react-flow__edge",`react-flow__edge-${C}`,w.className,x,{selected:w.selected,animated:w.animated,inactive:!P&&!r,updating:N,selectable:P}]),onClick:X,onDoubleClick:Y,onContextMenu:Q,onMouseEnter:te,onMouseMove:ne,onMouseLeave:ie,onKeyDown:S?ke:void 0,tabIndex:S?0:void 0,role:w.ariaRole??(S?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":w.ariaLabel===null?void 0:w.ariaLabel||`Edge from ${w.source} to ${w.target}`,"aria-describedby":S?`${mQ}-${g}`:void 0,ref:A,...w.domAttributes,children:[!W&&p.jsx(_,{id:e,source:w.source,target:w.target,type:w.type,selected:w.selected,animated:w.animated,selectable:P,deletable:w.deletable??!0,label:w.label,labelStyle:w.labelStyle,labelShowBg:w.labelShowBg,labelBgStyle:w.labelBgStyle,labelBgPadding:w.labelBgPadding,labelBgBorderRadius:w.labelBgBorderRadius,sourceX:O,sourceY:I,targetX:z,targetY:L,sourcePosition:F,targetPosition:D,data:w.data,style:w.style,sourceHandleId:w.sourceHandle,targetHandleId:w.targetHandle,markerStart:E,markerEnd:K,pathOptions:"pathOptions"in w?w.pathOptions:void 0,interactionWidth:w.interactionWidth}),j&&p.jsx(jRe,{edge:w,isReconnectable:j,reconnectRadius:h,onReconnect:u,onReconnectStart:f,onReconnectEnd:y,sourceX:O,sourceY:I,targetX:z,targetY:L,sourcePosition:F,targetPosition:D,setUpdateHover:R,setReconnecting:$})]})})}var zRe=m.memo(PRe);const RRe=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function FQ({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:o,noPanClassName:r,onReconnect:a,onEdgeContextMenu:i,onEdgeMouseEnter:s,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:h,reconnectRadius:u,onEdgeDoubleClick:f,onReconnectStart:y,onReconnectEnd:g,disableKeyboardA11y:k}){const{edgesFocusable:x,edgesReconnectable:v,elementsSelectable:M,onError:w}=De(RRe,Lt),b=xRe(t);return p.jsxs("div",{className:"react-flow__edges",children:[p.jsx(CRe,{defaultColor:e,rfId:n}),b.map(C=>p.jsx(zRe,{id:C,edgesFocusable:x,edgesReconnectable:v,elementsSelectable:M,noPanClassName:r,onReconnect:a,onContextMenu:i,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,onClick:h,reconnectRadius:u,onDoubleClick:f,onReconnectStart:y,onReconnectEnd:g,rfId:n,onError:w,edgeTypes:o,disableKeyboardA11y:k},C))]})}FQ.displayName="EdgeRenderer";const TRe=m.memo(FQ),DRe=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function HRe({children:e}){const t=De(DRe);return p.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function ORe(e){const t=Uz(),n=m.useRef(!1);m.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const qRe=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function FRe(e){const t=De(qRe),n=wt();return m.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function VRe(e){return e.connection.inProgress?{...e.connection,to:df(e.connection.to,e.transform)}:{...e.connection}}function BRe(e){return VRe}function URe(e){const t=BRe();return De(t,Lt)}const WRe=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function GRe({containerStyle:e,style:t,type:n,component:o}){const{nodesConnectable:r,width:a,height:i,isValid:s,inProgress:c}=De(WRe,Lt);return!(a&&r&&c)?null:p.jsx("svg",{style:e,width:a,height:i,className:"react-flow__connectionline react-flow__container",children:p.jsx("g",{className:Kt(["react-flow__connection",DY(s)]),children:p.jsx(VQ,{style:t,type:n,CustomComponent:o,isValid:s})})})}const VQ=({style:e,type:t=ii.Bezier,CustomComponent:n,isValid:o})=>{const{inProgress:r,from:a,fromNode:i,fromHandle:s,fromPosition:c,to:l,toNode:h,toHandle:u,toPosition:f,pointer:y}=URe();if(!r)return;if(n)return p.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:i,fromHandle:s,fromX:a.x,fromY:a.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:DY(o),toNode:h,toHandle:u,pointer:y});let g="";const k={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case ii.Bezier:[g]=qz(k);break;case ii.SimpleBezier:[g]=AQ(k);break;case ii.Step:[g]=Hh({...k,borderRadius:0});break;case ii.SmoothStep:[g]=Hh(k);break;default:[g]=YY(k)}return p.jsx("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};VQ.displayName="ConnectionLine";const ZRe={};function MU(e=ZRe){m.useRef(e),wt(),m.useEffect(()=>{},[e])}function XRe(){wt(),m.useRef(!1),m.useEffect(()=>{},[])}function BQ({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:o,onEdgeClick:r,onNodeDoubleClick:a,onEdgeDoubleClick:i,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:h,onSelectionContextMenu:u,onSelectionStart:f,onSelectionEnd:y,connectionLineType:g,connectionLineStyle:k,connectionLineComponent:x,connectionLineContainerStyle:v,selectionKeyCode:M,selectionOnDrag:w,selectionMode:b,multiSelectionKeyCode:C,panActivationKeyCode:_,zoomActivationKeyCode:S,deleteKeyCode:j,onlyRenderVisibleElements:P,elementsSelectable:A,defaultViewport:N,translateExtent:R,minZoom:W,maxZoom:$,preventScrolling:H,defaultMarkerColor:T,zoomOnScroll:O,zoomOnPinch:I,panOnScroll:z,panOnScrollSpeed:L,panOnScrollMode:F,zoomOnDoubleClick:D,panOnDrag:E,onPaneClick:K,onPaneMouseEnter:X,onPaneMouseMove:Y,onPaneMouseLeave:Q,onPaneScroll:te,onPaneContextMenu:ne,paneClickDistance:ie,nodeClickDistance:ke,onEdgeContextMenu:ge,onEdgeMouseEnter:ve,onEdgeMouseMove:ce,onEdgeMouseLeave:Ce,reconnectRadius:Re,onReconnect:st,onReconnectStart:Vt,onReconnectEnd:It,noDragClassName:pe,noWheelClassName:se,noPanClassName:we,disableKeyboardA11y:re,nodeExtent:Be,rfId:an,viewport:J,onViewportChange:ue}){return MU(e),MU(t),XRe(),ORe(n),FRe(J),p.jsx(dRe,{onPaneClick:K,onPaneMouseEnter:X,onPaneMouseMove:Y,onPaneMouseLeave:Q,onPaneContextMenu:ne,onPaneScroll:te,paneClickDistance:ie,deleteKeyCode:j,selectionKeyCode:M,selectionOnDrag:w,selectionMode:b,onSelectionStart:f,onSelectionEnd:y,multiSelectionKeyCode:C,panActivationKeyCode:_,zoomActivationKeyCode:S,elementsSelectable:A,zoomOnScroll:O,zoomOnPinch:I,zoomOnDoubleClick:D,panOnScroll:z,panOnScrollSpeed:L,panOnScrollMode:F,panOnDrag:E,defaultViewport:N,translateExtent:R,minZoom:W,maxZoom:$,onSelectionContextMenu:u,preventScrolling:H,noDragClassName:pe,noWheelClassName:se,noPanClassName:we,disableKeyboardA11y:re,onViewportChange:ue,isControlledViewport:!!J,children:p.jsxs(HRe,{children:[p.jsx(TRe,{edgeTypes:t,onEdgeClick:r,onEdgeDoubleClick:i,onReconnect:st,onReconnectStart:Vt,onReconnectEnd:It,onlyRenderVisibleElements:P,onEdgeContextMenu:ge,onEdgeMouseEnter:ve,onEdgeMouseMove:ce,onEdgeMouseLeave:Ce,reconnectRadius:Re,defaultMarkerColor:T,noPanClassName:we,disableKeyboardA11y:re,rfId:an}),p.jsx(GRe,{style:k,type:g,component:x,containerStyle:v}),p.jsx("div",{className:"react-flow__edgelabel-renderer"}),p.jsx(vRe,{nodeTypes:e,onNodeClick:o,onNodeDoubleClick:a,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:h,nodeClickDistance:ke,onlyRenderVisibleElements:P,noPanClassName:we,noDragClassName:pe,disableKeyboardA11y:re,nodeExtent:Be,rfId:an}),p.jsx("div",{className:"react-flow__viewport-portal"})]})})}BQ.displayName="GraphView";const KRe=m.memo(BQ),bU=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:a,fitView:i,fitViewOptions:s,minZoom:c=.5,maxZoom:l=2,nodeOrigin:h,nodeExtent:u,zIndexMode:f="basic"}={})=>{const y=new Map,g=new Map,k=new Map,x=new Map,v=o??t??[],M=n??e??[],w=h??[0,0],b=u??zh;eQ(k,x,v);const{nodesInitialized:C}=mH(M,y,g,{nodeOrigin:w,nodeExtent:b,zIndexMode:f});let _=[0,0,1];if(i&&r&&a){const S=cf(y,{filter:N=>!!((N.width||N.initialWidth)&&(N.height||N.initialHeight))}),{x:j,y:P,zoom:A}=bq(S,r,a,c,l,(s==null?void 0:s.padding)??.1);_=[j,P,A]}return{rfId:"1",width:r??0,height:a??0,transform:_,nodes:M,nodesInitialized:C,nodeLookup:y,parentLookup:g,edges:v,edgeLookup:x,connectionLookup:k,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:o!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:zh,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:h0.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:w,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:i??!1,fitViewOptions:s,fitViewResolver:null,connection:{...TY},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:Qje,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:RY,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},YRe=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:a,fitView:i,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:h,nodeExtent:u,zIndexMode:f})=>mze((y,g)=>{async function k(){const{nodeLookup:x,panZoom:v,fitViewOptions:M,fitViewResolver:w,width:b,height:C,minZoom:_,maxZoom:S}=g();v&&(await Kje({nodes:x,width:b,height:C,panZoom:v,minZoom:_,maxZoom:S},M),w==null||w.resolve(!0),y({fitViewResolver:null}))}return{...bU({nodes:e,edges:t,width:r,height:a,fitView:i,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:h,nodeExtent:u,defaultNodes:n,defaultEdges:o,zIndexMode:f}),setNodes:x=>{const{nodeLookup:v,parentLookup:M,nodeOrigin:w,elevateNodesOnSelect:b,fitViewQueued:C,zIndexMode:_,nodesSelectionActive:S}=g(),{nodesInitialized:j,hasSelectedNodes:P}=mH(x,v,M,{nodeOrigin:w,nodeExtent:u,elevateNodesOnSelect:b,checkEquality:!0,zIndexMode:_}),A=S&&P;C&&j?(k(),y({nodes:x,nodesInitialized:j,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:A})):y({nodes:x,nodesInitialized:j,nodesSelectionActive:A})},setEdges:x=>{const{connectionLookup:v,edgeLookup:M}=g();eQ(v,M,x),y({edges:x})},setDefaultNodesAndEdges:(x,v)=>{if(x){const{setNodes:M}=g();M(x),y({hasDefaultNodes:!0})}if(v){const{setEdges:M}=g();M(v),y({hasDefaultEdges:!0})}},updateNodeInternals:x=>{const{triggerNodeChanges:v,nodeLookup:M,parentLookup:w,domNode:b,nodeOrigin:C,nodeExtent:_,debug:S,fitViewQueued:j,zIndexMode:P}=g(),{changes:A,updatedInternals:N}=xPe(x,M,w,b,C,_,P);N&&(mPe(M,w,{nodeOrigin:C,nodeExtent:_,zIndexMode:P}),j?(k(),y({fitViewQueued:!1,fitViewOptions:void 0})):y({}),(A==null?void 0:A.length)>0&&(S&&console.log("React Flow: trigger node changes",A),v==null||v(A)))},updateNodePositions:(x,v=!1)=>{const M=[];let w=[];const{nodeLookup:b,triggerNodeChanges:C,connection:_,updateConnection:S,onNodesChangeMiddlewareMap:j}=g();for(const[P,A]of x){const N=b.get(P),R=!!(N!=null&&N.expandParent&&(N!=null&&N.parentId)&&(A!=null&&A.position)),W={id:P,type:"position",position:R?{x:Math.max(0,A.position.x),y:Math.max(0,A.position.y)}:A.position,dragging:v};if(N&&_.inProgress&&_.fromNode.id===N.id){const $=Nd(N,_.fromHandle,ye.Left,!0);S({..._,from:$})}R&&N.parentId&&M.push({id:P,parentId:N.parentId,rect:{...A.internals.positionAbsolute,width:A.measured.width??0,height:A.measured.height??0}}),w.push(W)}if(M.length>0){const{parentLookup:P,nodeOrigin:A}=g(),N=Nq(M,b,P,A);w.push(...N)}for(const P of j.values())w=P(w);C(w)},triggerNodeChanges:x=>{const{onNodesChange:v,setNodes:M,nodes:w,hasDefaultNodes:b,debug:C}=g();if(x!=null&&x.length){if(b){const _=vQ(x,w);M(_)}C&&console.log("React Flow: trigger node changes",x),v==null||v(x)}},triggerEdgeChanges:x=>{const{onEdgesChange:v,setEdges:M,edges:w,hasDefaultEdges:b,debug:C}=g();if(x!=null&&x.length){if(b){const _=xQ(x,w);M(_)}C&&console.log("React Flow: trigger edge changes",x),v==null||v(x)}},addSelectedNodes:x=>{const{multiSelectionActive:v,edgeLookup:M,nodeLookup:w,triggerNodeChanges:b,triggerEdgeChanges:C}=g();if(v){const _=x.map(S=>cd(S,!0));b(_);return}b(Ru(w,new Set([...x]),!0)),C(Ru(M))},addSelectedEdges:x=>{const{multiSelectionActive:v,edgeLookup:M,nodeLookup:w,triggerNodeChanges:b,triggerEdgeChanges:C}=g();if(v){const _=x.map(S=>cd(S,!0));C(_);return}C(Ru(M,new Set([...x]))),b(Ru(w,new Set,!0))},unselectNodesAndEdges:({nodes:x,edges:v}={})=>{const{edges:M,nodes:w,nodeLookup:b,triggerNodeChanges:C,triggerEdgeChanges:_}=g(),S=x||w,j=v||M,P=[];for(const N of S){if(!N.selected)continue;const R=b.get(N.id);R&&(R.selected=!1),P.push(cd(N.id,!1))}const A=[];for(const N of j)N.selected&&A.push(cd(N.id,!1));C(P),_(A)},setMinZoom:x=>{const{panZoom:v,maxZoom:M}=g();v==null||v.setScaleExtent([x,M]),y({minZoom:x})},setMaxZoom:x=>{const{panZoom:v,minZoom:M}=g();v==null||v.setScaleExtent([M,x]),y({maxZoom:x})},setTranslateExtent:x=>{var v;(v=g().panZoom)==null||v.setTranslateExtent(x),y({translateExtent:x})},resetSelectedElements:()=>{const{edges:x,nodes:v,triggerNodeChanges:M,triggerEdgeChanges:w,elementsSelectable:b}=g();if(!b)return;const C=v.reduce((S,j)=>j.selected?[...S,cd(j.id,!1)]:S,[]),_=x.reduce((S,j)=>j.selected?[...S,cd(j.id,!1)]:S,[]);M(C),w(_)},setNodeExtent:x=>{const{nodes:v,nodeLookup:M,parentLookup:w,nodeOrigin:b,elevateNodesOnSelect:C,nodeExtent:_,zIndexMode:S}=g();x[0][0]===_[0][0]&&x[0][1]===_[0][1]&&x[1][0]===_[1][0]&&x[1][1]===_[1][1]||(mH(v,M,w,{nodeOrigin:b,nodeExtent:x,elevateNodesOnSelect:C,checkEquality:!1,zIndexMode:S}),y({nodeExtent:x}))},panBy:x=>{const{transform:v,width:M,height:w,panZoom:b,translateExtent:C}=g();return wPe({delta:x,panZoom:b,transform:v,translateExtent:C,width:M,height:w})},setCenter:async(x,v,M)=>{const{width:w,height:b,maxZoom:C,panZoom:_}=g();if(!_)return Promise.resolve(!1);const S=typeof(M==null?void 0:M.zoom)<"u"?M.zoom:C;return await _.setViewport({x:w/2-x*S,y:b/2-v*S,zoom:S},{duration:M==null?void 0:M.duration,ease:M==null?void 0:M.ease,interpolate:M==null?void 0:M.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{y({connection:{...TY}})},updateConnection:x=>{y({connection:x})},reset:()=>y({...bU()})}},Object.is);function QRe({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:o,initialWidth:r,initialHeight:a,initialMinZoom:i,initialMaxZoom:s,initialFitViewOptions:c,fitView:l,nodeOrigin:h,nodeExtent:u,zIndexMode:f,children:y}){const[g]=m.useState(()=>YRe({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:a,fitView:l,minZoom:i,maxZoom:s,fitViewOptions:c,nodeOrigin:h,nodeExtent:u,zIndexMode:f}));return p.jsx(gze,{value:g,children:p.jsx(Hze,{children:y})})}function JRe({children:e,nodes:t,edges:n,defaultNodes:o,defaultEdges:r,width:a,height:i,fitView:s,fitViewOptions:c,minZoom:l,maxZoom:h,nodeOrigin:u,nodeExtent:f,zIndexMode:y}){return m.useContext(Bz)?p.jsx(p.Fragment,{children:e}):p.jsx(QRe,{initialNodes:t,initialEdges:n,defaultNodes:o,defaultEdges:r,initialWidth:a,initialHeight:i,fitView:s,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:h,nodeOrigin:u,nodeExtent:f,zIndexMode:y,children:e})}const eTe={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function tTe({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,className:r,nodeTypes:a,edgeTypes:i,onNodeClick:s,onEdgeClick:c,onInit:l,onMove:h,onMoveStart:u,onMoveEnd:f,onConnect:y,onConnectStart:g,onConnectEnd:k,onClickConnectStart:x,onClickConnectEnd:v,onNodeMouseEnter:M,onNodeMouseMove:w,onNodeMouseLeave:b,onNodeContextMenu:C,onNodeDoubleClick:_,onNodeDragStart:S,onNodeDrag:j,onNodeDragStop:P,onNodesDelete:A,onEdgesDelete:N,onDelete:R,onSelectionChange:W,onSelectionDragStart:$,onSelectionDrag:H,onSelectionDragStop:T,onSelectionContextMenu:O,onSelectionStart:I,onSelectionEnd:z,onBeforeDelete:L,connectionMode:F,connectionLineType:D=ii.Bezier,connectionLineStyle:E,connectionLineComponent:K,connectionLineContainerStyle:X,deleteKeyCode:Y="Backspace",selectionKeyCode:Q="Shift",selectionOnDrag:te=!1,selectionMode:ne=f0.Full,panActivationKeyCode:ie="Space",multiSelectionKeyCode:ke=Dh()?"Meta":"Control",zoomActivationKeyCode:ge=Dh()?"Meta":"Control",snapToGrid:ve,snapGrid:ce,onlyRenderVisibleElements:Ce=!1,selectNodesOnDrag:Re,nodesDraggable:st,autoPanOnNodeFocus:Vt,nodesConnectable:It,nodesFocusable:pe,nodeOrigin:se=gQ,edgesFocusable:we,edgesReconnectable:re,elementsSelectable:Be=!0,defaultViewport:an=Aze,minZoom:J=.5,maxZoom:ue=2,translateExtent:je=zh,preventScrolling:Ue=!0,nodeExtent:Ke,defaultMarkerColor:Bt="#b1b1b7",zoomOnScroll:un=!0,zoomOnPinch:Ut=!0,panOnScroll:xe=!1,panOnScrollSpeed:Ae=.5,panOnScrollMode:Tt=xd.Free,zoomOnDoubleClick:jn=!0,panOnDrag:Nt=!0,onPaneClick:ho,onPaneMouseEnter:Ea,onPaneMouseMove:Wt,onPaneMouseLeave:Wd,onPaneScroll:Et,onPaneContextMenu:Yt,paneClickDistance:Gd=1,nodeClickDistance:Zd=0,children:Xd,onReconnect:Kd,onReconnectStart:Yd,onReconnectEnd:Qd,onEdgeContextMenu:qi,onEdgeDoubleClick:Fi,onEdgeMouseEnter:Vi,onEdgeMouseMove:Bi,onEdgeMouseLeave:Vr,reconnectRadius:Br=10,onNodesChange:Jd,onEdgesChange:eu,noDragClassName:Te="nodrag",noWheelClassName:$t="nowheel",noPanClassName:Ur="nopan",fitView:Ui,fitViewOptions:er,connectOnClick:tr,attributionPosition:Wr,proOptions:fo,defaultEdgeOptions:Gn,elevateNodesOnSelect:hn=!0,elevateEdgesOnSelect:Qt=!1,disableKeyboardA11y:po=!1,autoPanOnConnect:Wi,autoPanOnNodeDrag:tu,autoPanSpeed:Ao,connectionRadius:Gi,isValidConnection:kt,onError:yo,style:$a,id:Zi,nodeDragThreshold:Gr,connectionDragThreshold:Zr,viewport:nu,onViewportChange:Xi,width:nr,height:Xr,colorMode:vn="light",debug:or,onScroll:rr,ariaLabelConfig:Eo,zIndexMode:xn="basic",...$o},ja){const Pn=Zi||"1",Pa=Pze(vn),ar=m.useCallback(za=>{za.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),rr==null||rr(za)},[rr]);return p.jsx("div",{"data-testid":"rf__wrapper",...$o,onScroll:ar,style:{...$a,...eTe},ref:ja,className:Kt(["react-flow",r,Pa]),id:Zi,role:"application",children:p.jsxs(JRe,{nodes:e,edges:t,width:nr,height:Xr,fitView:Ui,fitViewOptions:er,minZoom:J,maxZoom:ue,nodeOrigin:se,nodeExtent:Ke,zIndexMode:xn,children:[p.jsx(jze,{nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:y,onConnectStart:g,onConnectEnd:k,onClickConnectStart:x,onClickConnectEnd:v,nodesDraggable:st,autoPanOnNodeFocus:Vt,nodesConnectable:It,nodesFocusable:pe,edgesFocusable:we,edgesReconnectable:re,elementsSelectable:Be,elevateNodesOnSelect:hn,elevateEdgesOnSelect:Qt,minZoom:J,maxZoom:ue,nodeExtent:Ke,onNodesChange:Jd,onEdgesChange:eu,snapToGrid:ve,snapGrid:ce,connectionMode:F,translateExtent:je,connectOnClick:tr,defaultEdgeOptions:Gn,fitView:Ui,fitViewOptions:er,onNodesDelete:A,onEdgesDelete:N,onDelete:R,onNodeDragStart:S,onNodeDrag:j,onNodeDragStop:P,onSelectionDrag:H,onSelectionDragStart:$,onSelectionDragStop:T,onMove:h,onMoveStart:u,onMoveEnd:f,noPanClassName:Ur,nodeOrigin:se,rfId:Pn,autoPanOnConnect:Wi,autoPanOnNodeDrag:tu,autoPanSpeed:Ao,onError:yo,connectionRadius:Gi,isValidConnection:kt,selectNodesOnDrag:Re,nodeDragThreshold:Gr,connectionDragThreshold:Zr,onBeforeDelete:L,debug:or,ariaLabelConfig:Eo,zIndexMode:xn}),p.jsx(KRe,{onInit:l,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:M,onNodeMouseMove:w,onNodeMouseLeave:b,onNodeContextMenu:C,onNodeDoubleClick:_,nodeTypes:a,edgeTypes:i,connectionLineType:D,connectionLineStyle:E,connectionLineComponent:K,connectionLineContainerStyle:X,selectionKeyCode:Q,selectionOnDrag:te,selectionMode:ne,deleteKeyCode:Y,multiSelectionKeyCode:ke,panActivationKeyCode:ie,zoomActivationKeyCode:ge,onlyRenderVisibleElements:Ce,defaultViewport:an,translateExtent:je,minZoom:J,maxZoom:ue,preventScrolling:Ue,zoomOnScroll:un,zoomOnPinch:Ut,zoomOnDoubleClick:jn,panOnScroll:xe,panOnScrollSpeed:Ae,panOnScrollMode:Tt,panOnDrag:Nt,onPaneClick:ho,onPaneMouseEnter:Ea,onPaneMouseMove:Wt,onPaneMouseLeave:Wd,onPaneScroll:Et,onPaneContextMenu:Yt,paneClickDistance:Gd,nodeClickDistance:Zd,onSelectionContextMenu:O,onSelectionStart:I,onSelectionEnd:z,onReconnect:Kd,onReconnectStart:Yd,onReconnectEnd:Qd,onEdgeContextMenu:qi,onEdgeDoubleClick:Fi,onEdgeMouseEnter:Vi,onEdgeMouseMove:Bi,onEdgeMouseLeave:Vr,reconnectRadius:Br,defaultMarkerColor:Bt,noDragClassName:Te,noWheelClassName:$t,noPanClassName:Ur,rfId:Pn,disableKeyboardA11y:po,nodeExtent:Ke,viewport:nu,onViewportChange:Xi}),p.jsx(Nze,{onSelectionChange:W}),Xd,p.jsx(_ze,{proOptions:fo,position:Wr}),p.jsx(bze,{rfId:Pn,disableKeyboardA11y:po})]})})}var nTe=wQ(tTe);const oTe=e=>{var t;return(t=e.domNode)==null?void 0:t.querySelector(".react-flow__edgelabel-renderer")};function rTe({children:e}){const t=De(oTe);return t?P0.createPortal(e,t):null}const aTe=e=>{var t;return(t=e.domNode)==null?void 0:t.querySelector(".react-flow__viewport-portal")};function iTe({children:e}){const t=De(aTe);return t?P0.createPortal(e,t):null}function UQ(){const e=wt();return m.useCallback(t=>{const{domNode:n,updateNodeInternals:o}=e.getState(),r=Array.isArray(t)?t:[t],a=new Map;r.forEach(i=>{const s=n==null?void 0:n.querySelector(`.react-flow__node[data-id="${i}"]`);s&&a.set(i,{id:i,nodeElement:s,force:!0})}),requestAnimationFrame(()=>o(a,{triggerFitView:!1}))},[])}function _U(e){return De(m.useCallback(n=>n.nodeLookup.get(e),[e]),Lt)}function sTe({dimensions:e,lineWidth:t,variant:n,className:o}){return p.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Kt(["react-flow__background-pattern",n,o])})}function cTe({radius:e,className:t}){return p.jsx("circle",{cx:e,cy:e,r:e,className:Kt(["react-flow__background-pattern","dots",t])})}var vi;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(vi||(vi={}));const lTe={[vi.Dots]:1,[vi.Lines]:1,[vi.Cross]:6},dTe=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function WQ({id:e,variant:t=vi.Dots,gap:n=20,size:o,lineWidth:r=1,offset:a=0,color:i,bgColor:s,style:c,className:l,patternClassName:h}){const u=m.useRef(null),{transform:f,patternId:y}=De(dTe,Lt),g=o||lTe[t],k=t===vi.Dots,x=t===vi.Cross,v=Array.isArray(n)?n:[n,n],M=[v[0]*f[2]||1,v[1]*f[2]||1],w=g*f[2],b=Array.isArray(a)?a:[a,a],C=x?[w,w]:M,_=[b[0]*f[2]||1+C[0]/2,b[1]*f[2]||1+C[1]/2],S=`${y}${e||""}`;return p.jsxs("svg",{className:Kt(["react-flow__background",l]),style:{...c,...Wz,"--xy-background-color-props":s,"--xy-background-pattern-color-props":i},ref:u,"data-testid":"rf__background",children:[p.jsx("pattern",{id:S,x:f[0]%M[0],y:f[1]%M[1],width:M[0],height:M[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${_[0]},-${_[1]})`,children:k?p.jsx(cTe,{radius:w/2,className:h}):p.jsx(sTe,{dimensions:C,lineWidth:r,variant:t,className:h})}),p.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${S})`})]})}WQ.displayName="Background";const uTe=m.memo(WQ);function hTe(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:p.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function fTe(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:p.jsx("path",{d:"M0 0h32v4.2H0z"})})}function pTe(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:p.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function yTe(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:p.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function mTe(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:p.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Tu({children:e,className:t,...n}){return p.jsx("button",{type:"button",className:Kt(["react-flow__controls-button",t]),...n,children:e})}const gTe=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function GQ({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:o=!0,fitViewOptions:r,onZoomIn:a,onZoomOut:i,onFitView:s,onInteractiveChange:c,className:l,children:h,position:u="bottom-left",orientation:f="vertical","aria-label":y}){const g=wt(),{isInteractive:k,minZoomReached:x,maxZoomReached:v,ariaLabelConfig:M}=De(gTe,Lt),{zoomIn:w,zoomOut:b,fitView:C}=Uz(),_=()=>{w(),a==null||a()},S=()=>{b(),i==null||i()},j=()=>{C(r),s==null||s()},P=()=>{g.setState({nodesDraggable:!k,nodesConnectable:!k,elementsSelectable:!k}),c==null||c(!k)},A=f==="horizontal"?"horizontal":"vertical";return p.jsxs(k0,{className:Kt(["react-flow__controls",A,l]),position:u,style:e,"data-testid":"rf__controls","aria-label":y??M["controls.ariaLabel"],children:[t&&p.jsxs(p.Fragment,{children:[p.jsx(Tu,{onClick:_,className:"react-flow__controls-zoomin",title:M["controls.zoomIn.ariaLabel"],"aria-label":M["controls.zoomIn.ariaLabel"],disabled:v,children:p.jsx(hTe,{})}),p.jsx(Tu,{onClick:S,className:"react-flow__controls-zoomout",title:M["controls.zoomOut.ariaLabel"],"aria-label":M["controls.zoomOut.ariaLabel"],disabled:x,children:p.jsx(fTe,{})})]}),n&&p.jsx(Tu,{className:"react-flow__controls-fitview",onClick:j,title:M["controls.fitView.ariaLabel"],"aria-label":M["controls.fitView.ariaLabel"],children:p.jsx(pTe,{})}),o&&p.jsx(Tu,{className:"react-flow__controls-interactive",onClick:P,title:M["controls.interactive.ariaLabel"],"aria-label":M["controls.interactive.ariaLabel"],children:k?p.jsx(mTe,{}):p.jsx(yTe,{})}),h]})}GQ.displayName="Controls";const kTe=m.memo(GQ);function vTe({id:e,x:t,y:n,width:o,height:r,style:a,color:i,strokeColor:s,strokeWidth:c,className:l,borderRadius:h,shapeRendering:u,selected:f,onClick:y}){const{background:g,backgroundColor:k}=a||{},x=i||g||k;return p.jsx("rect",{className:Kt(["react-flow__minimap-node",{selected:f},l]),x:t,y:n,rx:h,ry:h,width:o,height:r,style:{fill:x,stroke:s,strokeWidth:c},shapeRendering:u,onClick:y?v=>y(v,e):void 0})}const xTe=m.memo(vTe),wTe=e=>e.nodes.map(t=>t.id),vT=e=>e instanceof Function?e:()=>e;function MTe({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:o=5,nodeStrokeWidth:r,nodeComponent:a=xTe,onClick:i}){const s=De(wTe,Lt),c=vT(t),l=vT(e),h=vT(n),u=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return p.jsx(p.Fragment,{children:s.map(f=>p.jsx(_Te,{id:f,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:h,nodeBorderRadius:o,nodeStrokeWidth:r,NodeComponent:a,onClick:i,shapeRendering:u},f))})}function bTe({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:o,nodeBorderRadius:r,nodeStrokeWidth:a,shapeRendering:i,NodeComponent:s,onClick:c}){const{node:l,x:h,y:u,width:f,height:y}=De(g=>{const k=g.nodeLookup.get(e);if(!k)return{node:void 0,x:0,y:0,width:0,height:0};const x=k.internals.userNode,{x:v,y:M}=k.internals.positionAbsolute,{width:w,height:b}=Ia(x);return{node:x,x:v,y:M,width:w,height:b}},Lt);return!l||l.hidden||!BY(l)?null:p.jsx(s,{x:h,y:u,width:f,height:y,style:l.style,selected:!!l.selected,className:o(l),color:t(l),borderRadius:r,strokeColor:n(l),strokeWidth:a,shapeRendering:i,onClick:c,id:l.id})}const _Te=m.memo(bTe);var CTe=m.memo(MTe);const STe=200,LTe=150,ITe=e=>!e.hidden,NTe=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?VY(cf(e.nodeLookup,{filter:ITe}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},ATe="react-flow__minimap-desc";function ZQ({style:e,className:t,nodeStrokeColor:n,nodeColor:o,nodeClassName:r="",nodeBorderRadius:a=5,nodeStrokeWidth:i,nodeComponent:s,bgColor:c,maskColor:l,maskStrokeColor:h,maskStrokeWidth:u,position:f="bottom-right",onClick:y,onNodeClick:g,pannable:k=!1,zoomable:x=!1,ariaLabel:v,inversePan:M,zoomStep:w=1,offsetScale:b=5}){const C=wt(),_=m.useRef(null),{boundingRect:S,viewBB:j,rfId:P,panZoom:A,translateExtent:N,flowWidth:R,flowHeight:W,ariaLabelConfig:$}=De(NTe,Lt),H=(e==null?void 0:e.width)??STe,T=(e==null?void 0:e.height)??LTe,O=S.width/H,I=S.height/T,z=Math.max(O,I),L=z*H,F=z*T,D=b*z,E=S.x-(L-S.width)/2-D,K=S.y-(F-S.height)/2-D,X=L+D*2,Y=F+D*2,Q=`${ATe}-${P}`,te=m.useRef(0),ne=m.useRef();te.current=z,m.useEffect(()=>{if(_.current&&A)return ne.current=APe({domNode:_.current,panZoom:A,getTransform:()=>C.getState().transform,getViewScale:()=>te.current}),()=>{var ve;(ve=ne.current)==null||ve.destroy()}},[A]),m.useEffect(()=>{var ve;(ve=ne.current)==null||ve.update({translateExtent:N,width:R,height:W,inversePan:M,pannable:k,zoomStep:w,zoomable:x})},[k,x,M,w,N,R,W]);const ie=y?ve=>{var Re;const[ce,Ce]=((Re=ne.current)==null?void 0:Re.pointer(ve))||[0,0];y(ve,{x:ce,y:Ce})}:void 0,ke=g?m.useCallback((ve,ce)=>{const Ce=C.getState().nodeLookup.get(ce).internals.userNode;g(ve,Ce)},[]):void 0,ge=v??$["minimap.ariaLabel"];return p.jsx(k0,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof h=="string"?h:void 0,"--xy-minimap-mask-stroke-width-props":typeof u=="number"?u*z:void 0,"--xy-minimap-node-background-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof i=="number"?i:void 0},className:Kt(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:p.jsxs("svg",{width:H,height:T,viewBox:`${E} ${K} ${X} ${Y}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":Q,ref:_,onClick:ie,children:[ge&&p.jsx("title",{id:Q,children:ge}),p.jsx(CTe,{onClick:ke,nodeColor:o,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:r,nodeStrokeWidth:i,nodeComponent:s}),p.jsx("path",{className:"react-flow__minimap-mask",d:`M${E-D},${K-D}h${X+D*2}v${Y+D*2}h${-X-D*2}z
|
|
8468
8468
|
M${j.x},${j.y}h${j.width}v${j.height}h${-j.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}ZQ.displayName="MiniMap";const ETe=m.memo(ZQ),$Te=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,jTe={[_i.Line]:"right",[_i.Handle]:"bottom-right"};function PTe({nodeId:e,position:t,variant:n=_i.Handle,className:o,style:r=void 0,children:a,color:i,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:h=Number.MAX_VALUE,keepAspectRatio:u=!1,resizeDirection:f,autoScale:y=!0,shouldResize:g,onResizeStart:k,onResize:x,onResizeEnd:v}){const M=CQ(),w=typeof e=="string"?e:M,b=wt(),C=m.useRef(null),_=n===_i.Handle,S=De(m.useCallback($Te(_&&y),[_,y]),Lt),j=m.useRef(null),P=t??jTe[n];m.useEffect(()=>{if(!(!C.current||!w))return j.current||(j.current=BPe({domNode:C.current,nodeId:w,getStoreItems:()=>{const{nodeLookup:N,transform:R,snapGrid:W,snapToGrid:$,nodeOrigin:H,domNode:T}=b.getState();return{nodeLookup:N,transform:R,snapGrid:W,snapToGrid:$,nodeOrigin:H,paneDomNode:T}},onChange:(N,R)=>{const{triggerNodeChanges:W,nodeLookup:$,parentLookup:H,nodeOrigin:T}=b.getState(),O=[],I={x:N.x,y:N.y},z=$.get(w);if(z&&z.expandParent&&z.parentId){const L=z.origin??T,F=N.width??z.measured.width??0,D=N.height??z.measured.height??0,E={id:z.id,parentId:z.parentId,rect:{width:F,height:D,...UY({x:N.x??z.position.x,y:N.y??z.position.y},{width:F,height:D},z.parentId,$,L)}},K=Nq([E],$,H,T);O.push(...K),I.x=N.x?Math.max(L[0]*F,N.x):void 0,I.y=N.y?Math.max(L[1]*D,N.y):void 0}if(I.x!==void 0&&I.y!==void 0){const L={id:w,type:"position",position:{...I}};O.push(L)}if(N.width!==void 0&&N.height!==void 0){const F={id:w,type:"dimensions",resizing:!0,setAttributes:f?f==="horizontal"?"width":"height":!0,dimensions:{width:N.width,height:N.height}};O.push(F)}for(const L of R){const F={...L,type:"position"};O.push(F)}W(O)},onEnd:({width:N,height:R})=>{const W={id:w,type:"dimensions",resizing:!1,dimensions:{width:N,height:R}};b.getState().triggerNodeChanges([W])}})),j.current.update({controlPosition:P,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:h},keepAspectRatio:u,resizeDirection:f,onResizeStart:k,onResize:x,onResizeEnd:v,shouldResize:g}),()=>{var N;(N=j.current)==null||N.destroy()}},[P,s,c,l,h,u,k,x,v,g]);const A=P.split("-");return p.jsx("div",{className:Kt(["react-flow__resize-control","nodrag",...A,n,o]),ref:C,style:{...r,scale:S,...i&&{[_?"backgroundColor":"borderColor"]:i}},children:a})}const CU=m.memo(PTe),zTe=24,RTe=e=>({type:Rh.ArrowClosed,width:18,height:18,...e?{color:e}:{}}),TTe={solid:{},dashed:{strokeDasharray:"6 4"},dotted:{strokeDasharray:"2 4"}},DTe=3,SU=new WeakMap,HTe=(e,t,n=!1)=>{const o=SU.get(e);if(o&&o.isAdjacentToRunning===t&&o.selected===n)return o.edge;const r=e.style?TTe[e.style]:{},a=Pt(e.color,"edge"),i=e.borderSize??2,s=n?Math.max(DTe,i):i,l={...r,...a,...n?{strokeWidth:s,opacity:1}:{strokeWidth:s}},h=e.direction??"forward",u=a.stroke,f=RTe(u),y=h==="backward"||h==="both"?f:void 0,g=h==="forward"||h==="both"?f:void 0,k={id:e.id,source:e.source,target:e.target,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle,type:"editableEdge",label:e.label,animated:t,data:{path:e.path,sourceHandleAutoPicked:e.sourceHandleAutoPicked,targetHandleAutoPicked:e.targetHandleAutoPicked,sourcePin:e.sourcePin,targetPin:e.targetPin,fontSize:e.fontSize},style:l,markerStart:y,markerEnd:g,interactionWidth:zTe};return SU.set(e,{isAdjacentToRunning:t,selected:n,edge:k}),k},OTe=(e,t={})=>{const n=t.setTimer??((l,h)=>globalThis.setTimeout(l,h)),o=t.clearTimer??(l=>{globalThis.clearTimeout(l)});let r=null,a=null;return{schedule:l=>{r!==null&&o(r),a=l,r=n(()=>{r=null;const h=a;a=null,h&&h()},e)},flush:()=>{r!==null&&(o(r),r=null);const l=a;a=null,l&&l()},cancel:()=>{r!==null&&(o(r),r=null),a=null},get pending(){return r!==null}}},XQ="seeflow:detail-panel-width",ku=380,xH=320,wH=800;function MH(e){return Number.isFinite(e)?e<xH?xH:e>wH?wH:e:ku}function qTe(){if(typeof window>"u")return ku;try{const e=window.localStorage.getItem(XQ);if(e===null)return ku;const t=Number(e);return!Number.isFinite(t)||t<xH||t>wH?ku:t}catch{return ku}}function FTe(e){if(!(typeof window>"u"))try{const t=MH(e);window.localStorage.setItem(XQ,String(t))}catch{}}function VTe(e,t,n,o){const r=typeof window>"u"?null:window;if(!r)return;let a=MH(e);const i=c=>{a=MH(e+(t-c.clientX)),n.onWidth(a)},s=()=>{r.removeEventListener("pointermove",i),r.removeEventListener("pointerup",s),r.removeEventListener("pointercancel",s),n.onCommit(a)};r.addEventListener("pointermove",i),r.addEventListener("pointerup",s),r.addEventListener("pointercancel",s)}function BTe(e,t,n){return`${n!==void 0?n.replace(/\/+$/,""):"/api/projects"}/${encodeURIComponent(e)}/files/${encodeURI(t)}`}const FP=(e,t)=>{const n=e.w/2,o=e.h/2,r=e.x+n,a=e.y+o,i=t.x-r,s=t.y-a;if(i===0&&s===0)return{x:r,y:a,side:"right"};const c=Math.abs(i),l=Math.abs(s),h=c===0?Number.POSITIVE_INFINITY:n/c,u=l===0?Number.POSITIVE_INFINITY:o/l,f=Math.min(h,u),y=r+i*f,g=a+s*f,k=c*o>=l*n?i>=0?"right":"left":s>=0?"bottom":"top";return{x:y,y:g,side:k}},bH=(e,t)=>{const n=Math.max(0,Math.min(e.w,t.x-e.x)),o=Math.max(0,Math.min(e.h,t.y-e.y)),r=n,a=e.w-n,i=o,s=e.h-o,c=Math.min(r,a,i,s),l=e.h===0?0:o/e.h,h=e.w===0?0:n/e.w;return c===r?{side:"left",t:l}:c===a?{side:"right",t:l}:c===i?{side:"top",t:h}:{side:"bottom",t:h}},VP=(e,t)=>{const n=Math.min(1,Math.max(0,t.t));let o,r;switch(t.side){case"top":o=e.x+n*e.w,r=e.y;break;case"bottom":o=e.x+n*e.w,r=e.y+e.h;break;case"left":o=e.x,r=e.y+n*e.h;break;case"right":o=e.x+e.w,r=e.y+n*e.h;break}return{x:o,y:r,side:t.side}},UTe=(e,t)=>{const n=o=>Math.min(1,Math.max(0,o));switch(t.side){case"top":case"bottom":return{side:t.side,t:e.w===0?0:n((t.x-e.x)/e.w)};case"left":case"right":return{side:t.side,t:e.h===0?0:n((t.y-e.y)/e.h)}}},WTe=(e,t)=>{const n=(e==null?void 0:e.fallback)??{x:0,y:0,side:"right"},o=(t==null?void 0:t.fallback)??{x:0,y:0,side:"left"};if(!e||!t)return{source:n,target:o};const r={x:e.box.x+e.box.w/2,y:e.box.y+e.box.h/2},a={x:t.box.x+t.box.w/2,y:t.box.y+t.box.h/2},i=e.pin?VP(e.box,e.pin):e.autoPicked===!1?e.fallback:FP(e.box,a),s=t.pin?VP(t.box,t.pin):t.autoPicked===!1?t.fallback:FP(t.box,r);return{source:i,target:s}};function li({initialValue:e,onCommit:t,onExit:n,multiline:o=!1,commitMode:r="enter-commits",required:a=!1,field:i,className:s,style:c,placeholder:l}){const h=o||r==="blur-only",u=m.useRef(null),[f,y]=m.useState(!1),[g,k]=m.useState(e.length===0),x=m.useRef(OTe(400)),v=m.useRef(e),M=m.useRef(!1);m.useEffect(()=>{const N=u.current;if(!N)return;N.textContent=e,N.focus();const R=window.getSelection();if(R){const $=document.createRange();$.selectNodeContents(N),R.removeAllRanges(),R.addRange($)}const W=x.current;return()=>{W.flush()}},[]);const w=()=>{const N=u.current;return N?h?N.innerText:N.textContent??"":""},b=N=>{x.current.cancel(),N!==v.current&&(v.current=N,t(N))},C=()=>{const N=w();if(k(N.length===0),a&&N.trim().length===0){x.current.cancel();return}x.current.schedule(()=>b(N))},_=()=>{x.current.cancel();const N=w();if(a&&N.trim().length===0){const R=u.current;R&&(R.textContent=e),y(!0),setTimeout(()=>y(!1),320),n();return}b(N),n()},S=()=>{x.current.cancel();const N=u.current;N&&(N.textContent=e),n()},j=N=>{if(N.stopPropagation(),N.nativeEvent.stopPropagation(),N.key==="Enter"){if(r==="blur-only"||o&&N.shiftKey){N.preventDefault(),document.execCommand("insertText",!1,`
|
|
8469
|
-
`);return}N.preventDefault(),M.current=!0,_();return}N.key==="Escape"&&(N.preventDefault(),M.current=!0,S())},P=N=>{N.preventDefault();const R=N.clipboardData.getData("text/plain");document.execCommand("insertText",!1,R)},A=()=>{if(M.current){M.current=!1;return}_()};return p.jsx("div",{ref:u,"data-testid":"inline-edit-input","data-field":i,"data-placeholder":l,role:"textbox",tabIndex:0,contentEditable:!0,suppressContentEditableWarning:!0,spellCheck:!1,onInput:C,onKeyDown:j,onPaste:P,onBlur:A,onMouseDown:N=>N.stopPropagation(),onClick:N=>N.stopPropagation(),onDoubleClick:N=>N.stopPropagation(),style:c,className:oe("nodrag nopan nowheel sf:block sf:w-full sf:bg-transparent sf:p-0 sf:text-inherit sf:outline-none","sf:whitespace-pre-wrap sf:wrap-break-word",g&&l?"inline-edit-empty":"",f?"inline-edit-shake":"",s)})}const KQ=8,LU=12,IU={height:`${KQ}px`,borderColor:"transparent"},NU={width:`${KQ}px`,borderColor:"transparent"},GTe={width:`${LU}px`,height:`${LU}px`,background:"transparent",border:"none"},ZTe={width:"calc(10px / var(--rf-zoom, 1))",height:"calc(10px / var(--rf-zoom, 1))",background:"hsl(var(--background))",border:"calc(1px / var(--rf-zoom, 1)) solid hsl(var(--primary) / 0.6)",borderRadius:"calc(2px / var(--rf-zoom, 1))",zIndex:1},XTe=[{position:"top",style:IU},{position:"bottom",style:IU},{position:"left",style:NU},{position:"right",style:NU}],KTe=["top-left","top-right","bottom-left","bottom-right"],AU={pointerEvents:"none",cursor:"default"};function R0({visible:e,minWidth:t=80,minHeight:n=40,onResizeStart:o,onResize:r,onResizeEnd:a,cornerVariant:i="invisible"}){const s=i==="visible"?ZTe:GTe,c=h=>e?h:{...h,...AU},l=e?s:{...s,opacity:0,...AU};return p.jsxs(p.Fragment,{children:[XTe.map(({position:h,style:u})=>p.jsx(CU,{position:h,variant:_i.Line,minWidth:t,minHeight:n,style:c(u),onResizeStart:o,onResize:r,onResizeEnd:a,children:p.jsx("span",{"data-testid":"resize-control","data-position":h})},h)),KTe.map(h=>p.jsx(CU,{position:h,variant:_i.Handle,minWidth:t,minHeight:n,style:l,autoScale:!1,onResizeStart:o,onResize:r,onResizeEnd:a,children:p.jsx("span",{"data-testid":"resize-control","data-position":h})},h))]})}function T0(e){const{onResize:t,onResizeEnd:n,onResizeFinal:o,setResizing:r}=e,[a,i]=m.useState(!1),s=m.useRef(null),c=m.useRef(t),l=m.useRef(n),h=m.useRef(o),u=m.useRef(r);m.useEffect(()=>{c.current=t},[t]),m.useEffect(()=>{l.current=n},[n]),m.useEffect(()=>{h.current=o},[o]),m.useEffect(()=>{u.current=r},[r]);const f=m.useCallback((k,x)=>{var v;i(!0),(v=u.current)==null||v.call(u,!0),s.current=x?{x:x.x,y:x.y,width:x.width,height:x.height}:null},[]),y=m.useCallback((k,x)=>{var v;(v=c.current)==null||v.call(c,{x:x.x,y:x.y,width:x.width,height:x.height})},[]),g=m.useCallback((k,x)=>{var M,w,b,C;i(!1),(M=u.current)==null||M.call(u,!1);const v=s.current;s.current=null,!(v&&v.width===x.width&&v.height===x.height)&&((w=c.current)==null||w.call(c,{x:x.x,y:x.y,width:x.width,height:x.height}),(b=l.current)==null||b.call(l,{x:x.x,y:x.y,width:x.width,height:x.height}),v&&((C=h.current)==null||C.call(h,{x:x.x,y:x.y,width:x.width,height:x.height},v)))},[]);return{isResizing:a,onResizeStart:f,onResizeEvent:y,onResizeEnd:g}}const v0={width:48,height:48},EU="help-circle",YTe=24,QTe=24,dp="sf:opacity-0 sf:transition-opacity";function JTe(e){return Pt(e,"text").color??"currentColor"}const $U=new Set;function eDe({id:e,data:t,selected:n,isConnectable:o}){const{onResizeStart:r,onResizeEvent:a,onResizeEnd:i}=T0({onResize:v=>{var M;return(M=t.onResize)==null?void 0:M.call(t,e,v)},onResizeEnd:v=>{var M;return(M=t.onResizeEnd)==null?void 0:M.call(t,e,v)},setResizing:t.setResizing}),s=t.width!==void 0||t.height!==void 0,c=!!t.onNameChange,[l,h]=m.useState(!1),u=l0[t.icon];!u&&!$U.has(t.icon)&&($U.add(t.icon),console.warn(`[iconNode] Unknown icon "${t.icon}"; falling back to "${EU}".`));const f=u??l0[EU],y=JTe(t.color),g=t.strokeWidth??2,k={...s?{}:{width:v0.width,height:v0.height}},x=v=>{!c||l||(v.stopPropagation(),h(!0))};return p.jsxs("div",{className:oe("sf:group sf:relative",s?"sf:h-full sf:w-full":""),style:k,"data-testid":"icon-node","data-node-type":"icon",onDoubleClick:x,children:[p.jsx(R0,{visible:!!n&&!!t.onResize&&!l,cornerVariant:"visible",minWidth:YTe,minHeight:QTe,onResizeStart:r,onResize:a,onResizeEnd:i}),p.jsx(ht,{type:"target",position:ye.Top,id:"t",isConnectable:o,className:oe(dp,n&&"sf:opacity-100!")}),p.jsx(ht,{type:"target",position:ye.Left,id:"l",isConnectable:o,className:oe(dp,n&&"sf:opacity-100!")}),f?p.jsx(f,{color:y,strokeWidth:g,absoluteStrokeWidth:!0,"aria-label":t.alt,className:"sf:block sf:h-full sf:w-full sf:pointer-events-none sf:select-none"}):null,l&&c?p.jsx("div",{className:"sf:absolute sf:left-0 sf:right-0 sf:top-full sf:mt-1 sf:text-center sf:text-xs sf:text-muted-foreground",children:p.jsx(li,{initialValue:t.name??"",field:"icon-node-label",onCommit:v=>{var M;return(M=t.onNameChange)==null?void 0:M.call(t,e,v)},onExit:()=>h(!1),placeholder:"Label"})}):t.name?p.jsx("span",{"data-testid":"icon-node-label",className:"sf:pointer-events-none sf:absolute sf:left-0 sf:right-0 sf:top-full sf:mt-1 sf:truncate sf:text-center sf:text-xs sf:text-muted-foreground sf:select-none",children:t.name}):null,p.jsx(ht,{type:"source",position:ye.Right,id:"r",isConnectable:o,className:oe(dp,n&&"sf:opacity-100!")}),p.jsx(ht,{type:"source",position:ye.Bottom,id:"b",isConnectable:o,className:oe(dp,n&&"sf:opacity-100!")})]})}function tDe(e,t){return e.selected===t.selected&&e.data===t.data&&e.width===t.width&&e.height===t.height}const nDe=m.memo(eDe,tDe);function oDe(e,t){const n=e.screenToFlowPosition({x:t.width/2,y:t.height/2});return{x:n.x-v0.width/2,y:n.y-v0.height/2}}const YQ="seeflow:icon-recents",rDe=16;function QQ(){if(typeof window>"u")return[];try{const e=window.localStorage.getItem(YQ);if(e===null)return[];const t=JSON.parse(e);return Array.isArray(t)?t.every(n=>typeof n=="string")?t:[]:[]}catch{return[]}}function aDe(e){if(!(typeof window>"u"))try{const n=QQ().filter(r=>r!==e),o=[e,...n].slice(0,rDe);window.localStorage.setItem(YQ,JSON.stringify(o))}catch{}}const iDe=typeof navigator<"u"&&typeof navigator.platform=="string"&&navigator.platform.toLowerCase().includes("mac"),sDe=e=>e.length===1?e.toUpperCase():e==="Escape"?"Esc":e,Dt=(e,t=iDe)=>{const n=sDe(e.key);if(t){let r="";return e.meta&&(r+="⌘"),e.alt&&(r+="⌥"),e.shift&&(r+="⇧"),`${r}${n}`}const o=[];return e.meta&&o.push("Ctrl"),e.shift&&o.push("Shift"),e.alt&&o.push("Alt"),o.push(n),o.join("+")},Eq=[{id:"tool.select",label:"Select tool",description:"Switch to the selection tool",category:"Tools",shortcut:Dt({key:"V"})},{id:"tool.hand",label:"Hand tool",description:"Pan the canvas; node interaction is suspended while armed",category:"Tools",shortcut:Dt({key:"H"})},{id:"tool.rectangle",label:"Rectangle",description:"Draw rectangle nodes",category:"Tools",shortcut:Dt({key:"R"})},{id:"tool.ellipse",label:"Ellipse",description:"Draw ellipse nodes",category:"Tools",shortcut:Dt({key:"O"})},{id:"tool.text",label:"Text",description:"Add a text node",category:"Tools",shortcut:Dt({key:"T"})},{id:"tool.sticky",label:"Sticky note",description:"Add a sticky note",category:"Tools",shortcut:Dt({key:"S"})},{id:"tool.database",label:"Database",description:"Add a database node",category:"Tools",shortcut:Dt({key:"D"})},{id:"tool.server",label:"Server",description:"Add a server node",category:"Tools"},{id:"tool.user",label:"User",description:"Add a user node",category:"Tools"},{id:"tool.queue",label:"Queue",description:"Add a queue node",category:"Tools"},{id:"tool.cloud",label:"Cloud",description:"Add a cloud node",category:"Tools"},{id:"tool.diamond",label:"Diamond",description:"Add a diamond node (decision / gateway)",category:"Tools"},{id:"tool.hexagon",label:"Hexagon",description:"Add a hexagon node (microservice)",category:"Tools"},{id:"edit.undo",label:"Undo",category:"Edit",shortcut:Dt({meta:!0,key:"Z"}),enabled:e=>e.canUndo},{id:"edit.redo",label:"Redo",category:"Edit",shortcut:Dt({meta:!0,shift:!0,key:"Z"}),enabled:e=>e.canRedo},{id:"edit.copy",label:"Copy",category:"Edit",shortcut:Dt({meta:!0,key:"C"}),enabled:e=>e.hasSelection},{id:"edit.paste",label:"Paste",category:"Edit",shortcut:Dt({meta:!0,key:"V"}),enabled:e=>e.hasClipboard},{id:"edit.duplicate",label:"Duplicate",category:"Edit",shortcut:Dt({meta:!0,key:"D"}),enabled:e=>e.hasSelection},{id:"edit.delete",label:"Delete",category:"Edit",shortcut:Dt({key:"Delete"}),enabled:e=>e.hasSelection},{id:"edit.selectAll",label:"Select all",category:"Edit",shortcut:Dt({meta:!0,key:"A"})},{id:"view.fit",label:"Fit view",description:"Fit everything in the viewport",category:"View",shortcut:Dt({meta:!0,key:"0"})},{id:"view.zoomIn",label:"Zoom in",category:"View",shortcut:Dt({meta:!0,key:"="})},{id:"view.zoomOut",label:"Zoom out",category:"View",shortcut:Dt({meta:!0,key:"-"})},{id:"view.zoom100",label:"Zoom to 100%",category:"View",shortcut:Dt({key:"1"})},{id:"view.zoomToSelection",label:"Zoom to selection",category:"View",shortcut:Dt({key:"F"}),enabled:e=>e.hasSelection},{id:"layout.tidy",label:"Tidy layout",description:"Auto-layout the canvas or current selection",category:"Layout",shortcut:Dt({meta:!0,shift:!0,key:"L"})},{id:"selection.deselect",label:"Deselect",description:"Clear selection and exit draw mode",category:"Selection",shortcut:Dt({key:"Escape"})},{id:"help.commandPalette",label:"Open command palette",category:"Help",shortcut:Dt({meta:!0,key:"P"})},{id:"export.pdf",label:"Export to PDF",description:"Download the current canvas as a PDF",category:"File",enabled:e=>e.canExportDemo},{id:"export.png",label:"Export as image",description:"Download the current canvas as a PNG",category:"File",enabled:e=>e.canExportDemo}],xT=e=>{const t=Eq.find(n=>n.id===e);return t?t.shortcut?`${t.label} (${t.shortcut})`:t.label:""},cDe=1,lDe=10,dDe=e=>{if(e.metaKey||e.ctrlKey||e.altKey)return null;const t=e.shiftKey?lDe:cDe;switch(e.key){case"ArrowLeft":return{dx:-t,dy:0};case"ArrowRight":return{dx:t,dy:0};case"ArrowUp":return{dx:0,dy:-t};case"ArrowDown":return{dx:0,dy:t};default:return null}},uDe=e=>{if(!(e.metaKey||e.ctrlKey)||e.altKey)return null;switch(e.key){case"0":return"fit";case"=":case"+":return"in";case"-":case"_":return"out";default:return null}},hDe=(e,t,n)=>{if(t.length===0)return[];const o=new Map(n.map(a=>[a.id,a])),r=[];for(const a of t){const i=o.get(a);i&&r.push({id:a,position:{x:i.position.x+e.dx,y:i.position.y+e.dy}})}return r},fDe=({event:e,isEditableActive:t,hasNodes:n,hasConnectors:o,selectedIds:r,hasClipboard:a})=>{if(!(e.metaKey||e.ctrlKey))return{type:"noop"};if(e.shiftKey||e.altKey)return{type:"noop"};const i=e.key.toLowerCase();return i!=="a"&&i!=="c"&&i!=="v"&&i!=="d"?{type:"noop"}:t?{type:"noop"}:i==="a"?!n&&!o?{type:"noop"}:{type:"selectAll"}:i==="c"?r.length===0?{type:"noop"}:{type:"copy",ids:r}:i==="d"?r.length===0?{type:"noop"}:{type:"duplicate",ids:r}:a?{type:"paste"}:{type:"noop"}},pDe=(e,t)=>{if(t.isEditableActive||!(e.metaKey||e.ctrlKey)||e.altKey)return null;const n=e.key.toLowerCase();return n==="z"?e.shiftKey?"redo":"undo":n==="y"&&!e.shiftKey?"redo":null},yDe=e=>{if(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return null;switch(e.key.toLowerCase()){case"v":return"select";case"h":return"hand";case"r":return"rectangle";case"o":return"ellipse";case"t":return"text";case"s":return"sticky";case"d":return"database";default:return null}},Xa="seeflow",JQ=e=>`${e}:last-used-style:v1`,wT=()=>({node:{},connector:{}}),MT=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),$q=e=>{var t;try{const n=(t=globalThis.localStorage)==null?void 0:t.getItem(JQ(e));if(!n)return wT();const o=JSON.parse(n);if(!MT(o))return wT();const r=MT(o.node)?o.node:{},a=MT(o.connector)?o.connector:{};return{node:r,connector:a}}catch{return wT()}},eJ=(e,t)=>{var n;try{(n=globalThis.localStorage)==null||n.setItem(JQ(e),JSON.stringify(t))}catch{}},_2=e=>$q(e),jU=(e,t)=>{const{alt:n,...o}=t,r={...o};r.borderSize!==void 0&&r.borderWidth===void 0?r.borderWidth=r.borderSize:r.borderWidth!==void 0&&r.borderSize===void 0&&(r.borderSize=r.borderWidth);const a=$q(e);eJ(e,{...a,node:{...a.node,...r}})},mDe=(e,t)=>{const n=$q(e);eJ(e,{...n,connector:{...n.connector,...t}})},jq=1,PU=17,_H=(e,t)=>{if(!e)return{};const n={};for(const o of t)e[o]!==void 0&&(n[o]=e[o]);return n},gDe=["borderColor","backgroundColor","borderSize","borderStyle","fontSize","cornerRadius","shadow"],kDe=["borderColor","backgroundColor","borderSize","borderStyle","fontSize","shadow"],vDe=["fontSize"],xDe=["borderColor","borderWidth","borderStyle","shadow"];function zU(e,t,n){if(e==="text")return{width:t.width,height:t.height,fontSize:PU,..._H(n,vDe)};const o=e==="ellipse"?kDe:gDe;return{width:t.width,height:t.height,borderSize:jq,fontSize:PU,..._H(n,o)}}function wDe(e,t,n){return{path:e,width:t.width,height:t.height,borderWidth:jq,..._H(n,xDe)}}const ko=async(e,t,n,o,r)=>{const a={method:t},i={...o??{}};r!==void 0&&(i["content-type"]="application/json",a.body=JSON.stringify(r)),Object.keys(i).length>0&&(a.headers=i);const s=await e(n,a);if(!s.ok){let c=null;try{c=await s.json()}catch{}throw new Error((c==null?void 0:c.error)??`${t} ${n} → ${s.status}`)}return await s.json()},MDe=e=>{const{baseUrl:t,project:n,flow:o}=e,r=e.fetch??globalThis.fetch.bind(globalThis),a=e.headers,i=`${t}/api/projects/${encodeURIComponent(n)}`,s=`${i}/flows/${encodeURIComponent(o)}`;return{async createNode(c){const l=await ko(r,"POST",`${s}/nodes`,a,c);return{id:l.id,node:l.node}},async updateNode(c,l){await ko(r,"PATCH",`${s}/nodes/${c}`,a,l)},async updateNodePosition(c,l){return await ko(r,"PATCH",`${s}/nodes/${c}/position`,a,l)},async deleteNode(c){await ko(r,"DELETE",`${s}/nodes/${c}`,a)},async reorderNode(c,l){await ko(r,"PATCH",`${s}/nodes/${c}/order`,a,l)},async createConnector(c){return{id:(await ko(r,"POST",`${s}/connectors`,a,c)).id}},async updateConnector(c,l){await ko(r,"PATCH",`${s}/connectors/${c}`,a,l)},async deleteConnector(c){await ko(r,"DELETE",`${s}/connectors/${c}`,a)},async uploadImage(c,l,h){const u=new FormData;u.append("file",l),u.append("filename",h);const f=`${s}/nodes/${encodeURIComponent(c)}/files/upload`,y={method:"POST",body:u};a&&(y.headers={...a});const g=await r(f,y);if(!g.ok){let k=null;try{k=await g.json()}catch{}throw new Error((k==null?void 0:k.error)??`POST ${f} → ${g.status}`)}return await g.json()},async playAction(c){return await ko(r,"POST",`${s}/play/${c}`,a,{})},async openFile(c){await ko(r,"POST",`${i}/files/open`,a,{path:c})},async revealFile(c){await ko(r,"POST",`${i}/files/reveal`,a,{path:c})},async computeLayout(c,l){const h=await ko(r,"POST",`${t}/api/layout`,a,{nodes:c,edges:l});return{nodes:h.nodes,connectors:h.connectors}}}},bDe=500,_De=500,CDe=2e3,SDe=(e,t)=>{if(!e&&!t)return;if(!e)return{...t};if(!t)return{...e};const n={...t};for(const[o,r]of Object.entries(e))n[o]=r;return n},RU=(e,t,n)=>{const o=Date.now(),r=bDe,a=_De,{stack:i,cursor:s}=e;if(t.coalesceKey&&s>0){const h=i[s-1];if(h&&h.coalesceKey===t.coalesceKey&&o-h.capturedAt<=a){const u=i.slice(0,s);return u[s-1]={...h,do:t.do,capturedAt:o,beforeFields:SDe(h.beforeFields,t.beforeFields)},{stack:u,cursor:s}}}const c=i.slice(0,s);c.push({...t,capturedAt:o});let l=s+1;for(;c.length>r;)c.shift(),l-=1;return l<0&&(l=0),{stack:c,cursor:l}},LDe=e=>e.cursor===0?{state:e,entry:void 0}:{state:{...e,cursor:e.cursor-1},entry:e.stack[e.cursor-1]},IDe=e=>e.cursor===e.stack.length?{state:e,entry:void 0}:{state:{...e,cursor:e.cursor+1},entry:e.stack[e.cursor]},tJ=()=>({stack:[],cursor:0}),TU=e=>e.cursor===e.stack.length?e:{stack:e.stack.slice(0,e.cursor),cursor:e.cursor},NDe=(e,t,n=Date.now(),o=CDe)=>n-t>o?tJ():e,ADe=new Set(["borderColor","backgroundColor","borderSize","borderWidth","borderStyle","fontSize","textAlign","cornerRadius","shadow","color","strokeWidth"]);function EDe(e,t){let n={stack:[],cursor:0},o=0;const r=new Set;let a=null;const i=()=>({canUndo:n.cursor>0,canRedo:n.cursor<n.stack.length}),s=()=>{const k=i();for(const x of r)x(k)},c=()=>{if(a){o=Date.now();return}const k=TU(n);o=Date.now(),k!==n&&(n=k,s())},l=k=>{if(a){a.ops.push({redo:k.do,undo:k.undo});return}n=RU(n,{...k,capturedAt:Date.now()}),s()},h={createNode:async k=>{c();const x=await e.createNode(k);return l({do:async()=>{await e.createNode({...k,id:x.id})},undo:async()=>{await e.deleteNode(x.id)}}),x},updateNode:async(k,x)=>{c();const{nodes:v}=t(),M=v.find(_=>_.id===k);if(!M){await e.updateNode(k,x);return}const w={},b=M.data??{};for(const _ of Object.keys(x))if(_==="position")w[_]=M.position;else if(_==="type")w[_]=M.type;else{const S=b[_];w[_]=S===void 0&&ADe.has(_)?null:S}await e.updateNode(k,x);const C=Object.keys(x).sort().join(",");l({do:async()=>{await e.updateNode(k,x)},undo:async()=>{await e.updateNode(k,w)},coalesceKey:`update:${k}:${C}`,beforeFields:w})},updateNodePosition:async(k,x)=>{c();const{nodes:v}=t(),M=v.find(C=>C.id===k),w=M==null?void 0:M.position,b=await e.updateNodePosition(k,x);return w&&l({do:async()=>{await e.updateNodePosition(k,x)},undo:async()=>{await e.updateNodePosition(k,w)},coalesceKey:`pos:${k}`}),b},deleteNode:async k=>{c();const{nodes:x,connectors:v}=t(),M=x.find(b=>b.id===k);if(!M){await e.deleteNode(k);return}const w=v.filter(b=>b.source===k||b.target===k);await e.deleteNode(k),l({do:async()=>{await e.deleteNode(k)},undo:async()=>{await e.createNode({id:M.id,type:M.type,position:M.position,data:M.data??{}});for(const b of w)try{await e.createConnector({id:b.id,source:b.source,target:b.target,sourceHandle:b.sourceHandle,targetHandle:b.targetHandle,sourceHandleAutoPicked:b.sourceHandleAutoPicked,targetHandleAutoPicked:b.targetHandleAutoPicked,sourcePin:b.sourcePin,targetPin:b.targetPin,label:b.label,style:b.style,color:b.color,direction:b.direction,eventName:b.eventName,queueName:b.queueName,method:b.method,url:b.url})}catch(C){console.warn(`[seeflow/canvas] failed to restore connector ${b.id} during deleteNode undo:`,C)}}})},reorderNode:async(k,x)=>{c();const{nodes:v}=t(),M=v.findIndex(w=>w.id===k);if(M<0){await e.reorderNode(k,x);return}await e.reorderNode(k,x),l({do:async()=>{await e.reorderNode(k,x)},undo:async()=>{await e.reorderNode(k,{op:"toIndex",index:M})}})},createConnector:async k=>{c();const x=await e.createConnector(k);return l({do:async()=>{await e.createConnector({...k,id:x.id})},undo:async()=>{await e.deleteConnector(x.id)}}),x},updateConnector:async(k,x)=>{c();const{connectors:v}=t(),M=v.find(_=>_.id===k);if(!M){await e.updateConnector(k,x);return}const w={},b=M;for(const _ of Object.keys(x))w[_]=b[_];await e.updateConnector(k,x);const C=Object.keys(x).sort().join(",");l({do:async()=>{await e.updateConnector(k,x)},undo:async()=>{await e.updateConnector(k,w)},coalesceKey:`update:conn:${k}:${C}`,beforeFields:w})},deleteConnector:async k=>{c();const{connectors:x}=t(),v=x.find(M=>M.id===k);if(!v){await e.deleteConnector(k);return}await e.deleteConnector(k),l({do:async()=>{await e.deleteConnector(k)},undo:async()=>{await e.createConnector({id:v.id,source:v.source,target:v.target,sourceHandle:v.sourceHandle,targetHandle:v.targetHandle,sourceHandleAutoPicked:v.sourceHandleAutoPicked,targetHandleAutoPicked:v.targetHandleAutoPicked,sourcePin:v.sourcePin,targetPin:v.targetPin,label:v.label,style:v.style,color:v.color,direction:v.direction,eventName:v.eventName,queueName:v.queueName,method:v.method,url:v.url})}})},uploadImage:(k,x,v)=>e.uploadImage(k,x,v),...e.playAction?{playAction:k=>e.playAction(k)}:{},...e.openFile?{openFile:k=>e.openFile(k)}:{},...e.revealFile?{revealFile:k=>e.revealFile(k)}:{},...e.computeLayout?{computeLayout:(k,x)=>e.computeLayout(k,x)}:{}};let u=Promise.resolve();const f=async()=>{const k=LDe(n);k.entry&&(n=k.state,s(),await k.entry.undo())},y=async()=>{const k=IDe(n);k.entry&&(n=k.state,s(),await k.entry.do())};return{adapter:h,history:{get canUndo(){return n.cursor>0},get canRedo(){return n.cursor<n.stack.length},undo:()=>{o=Date.now();const k=u.then(f);return u=k.then(()=>{},()=>{}),k},redo:()=>{o=Date.now();const k=u.then(y);return u=k.then(()=>{},()=>{}),k},clear:()=>{n=tJ(),s()},markExternalChange:()=>{const k=NDe(n,o);k!==n&&(n=k,s())},batch:async(k,x,v)=>{if(a)return x();const M=TU(n);o=Date.now(),M!==n&&(n=M,s());const w={name:k,ops:[]};a=w;try{const b=await x();if(a=null,w.ops.length>0){const C=w.ops.slice();n=RU(n,{do:async()=>{for(const _ of C)await _.redo()},undo:async()=>{for(let _=C.length-1;_>=0;_--)await C[_].undo()},coalesceKey:v==null?void 0:v.coalesceKey,capturedAt:Date.now()}),s()}return b}catch(b){a=null;for(let C=w.ops.length-1;C>=0;C--)try{await w.ops[C].undo()}catch(_){console.warn(`[seeflow/canvas] batch '${k}' rollback inverse rejected:`,_)}throw b}},subscribe:k=>(r.add(k),k(i()),()=>{r.delete(k)})}}}function nJ(e,t,n){let o=null,r=!1;const a=new ResizeObserver(()=>{r||(o!==null&&clearTimeout(o),o=setTimeout(()=>{o=null,!r&&n()},t))});return a.observe(e),()=>{r||(r=!0,o!==null&&(clearTimeout(o),o=null),a.disconnect())}}const $De="modulepreload",jDe=function(e){return"/"+e},DU={},hf=function(t,n,o){let r=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),s=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));r=Promise.allSettled(n.map(c=>{if(c=jDe(c),c in DU)return;DU[c]=!0;const l=c.endsWith(".css"),h=l?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${h}`))return;const u=document.createElement("link");if(u.rel=l?"stylesheet":$De,l||(u.as="script"),u.crossOrigin="",u.href=c,s&&u.setAttribute("nonce",s),document.head.appendChild(u),l)return new Promise((f,y)=>{u.addEventListener("load",f),u.addEventListener("error",()=>y(new Error(`Unable to preload CSS for ${c}`)))})}))}function a(i){const s=new Event("vite:preloadError",{cancelable:!0});if(s.payload=i,window.dispatchEvent(s),!s.defaultPrevented)throw i}return r.then(i=>{for(const s of i||[])s.status==="rejected"&&a(s.reason);return t().catch(a)})};var at;(function(e){e.assertEqual=r=>{};function t(r){}e.assertIs=t;function n(r){throw new Error}e.assertNever=n,e.arrayToEnum=r=>{const a={};for(const i of r)a[i]=i;return a},e.getValidEnumValues=r=>{const a=e.objectKeys(r).filter(s=>typeof r[r[s]]!="number"),i={};for(const s of a)i[s]=r[s];return e.objectValues(i)},e.objectValues=r=>e.objectKeys(r).map(function(a){return r[a]}),e.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const a=[];for(const i in r)Object.prototype.hasOwnProperty.call(r,i)&&a.push(i);return a},e.find=(r,a)=>{for(const i of r)if(a(i))return i},e.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function o(r,a=" | "){return r.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}e.joinValues=o,e.jsonStringifyReplacer=(r,a)=>typeof a=="bigint"?a.toString():a})(at||(at={}));var HU;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(HU||(HU={}));const Le=at.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),oi=e=>{switch(typeof e){case"undefined":return Le.undefined;case"string":return Le.string;case"number":return Number.isNaN(e)?Le.nan:Le.number;case"boolean":return Le.boolean;case"function":return Le.function;case"bigint":return Le.bigint;case"symbol":return Le.symbol;case"object":return Array.isArray(e)?Le.array:e===null?Le.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?Le.promise:typeof Map<"u"&&e instanceof Map?Le.map:typeof Set<"u"&&e instanceof Set?Le.set:typeof Date<"u"&&e instanceof Date?Le.date:Le.object;default:return Le.unknown}},me=at.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Ma extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=o=>{this.issues=[...this.issues,o]},this.addIssues=(o=[])=>{this.issues=[...this.issues,...o]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(a){return a.message},o={_errors:[]},r=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(r);else if(i.code==="invalid_return_type")r(i.returnTypeError);else if(i.code==="invalid_arguments")r(i.argumentsError);else if(i.path.length===0)o._errors.push(n(i));else{let s=o,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(s[l]=s[l]||{_errors:[]},s[l]._errors.push(n(i))):s[l]=s[l]||{_errors:[]},s=s[l],c++}}};return r(this),o}static assert(t){if(!(t instanceof Ma))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,at.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},o=[];for(const r of this.issues)if(r.path.length>0){const a=r.path[0];n[a]=n[a]||[],n[a].push(t(r))}else o.push(t(r));return{formErrors:o,fieldErrors:n}}get formErrors(){return this.flatten()}}Ma.create=e=>new Ma(e);const CH=(e,t)=>{let n;switch(e.code){case me.invalid_type:e.received===Le.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case me.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,at.jsonStringifyReplacer)}`;break;case me.unrecognized_keys:n=`Unrecognized key(s) in object: ${at.joinValues(e.keys,", ")}`;break;case me.invalid_union:n="Invalid input";break;case me.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${at.joinValues(e.options)}`;break;case me.invalid_enum_value:n=`Invalid enum value. Expected ${at.joinValues(e.options)}, received '${e.received}'`;break;case me.invalid_arguments:n="Invalid function arguments";break;case me.invalid_return_type:n="Invalid function return type";break;case me.invalid_date:n="Invalid date";break;case me.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:at.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case me.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case me.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case me.custom:n="Invalid input";break;case me.invalid_intersection_types:n="Intersection results could not be merged";break;case me.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case me.not_finite:n="Number must be finite";break;default:n=t.defaultError,at.assertNever(e)}return{message:n}};let PDe=CH;function zDe(){return PDe}const RDe=e=>{const{data:t,path:n,errorMaps:o,issueData:r}=e,a=[...n,...r.path||[]],i={...r,path:a};if(r.message!==void 0)return{...r,path:a,message:r.message};let s="";const c=o.filter(l=>!!l).slice().reverse();for(const l of c)s=l(i,{data:t,defaultError:s}).message;return{...r,path:a,message:s}};function be(e,t){const n=zDe(),o=RDe({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===CH?void 0:CH].filter(r=>!!r)});e.common.issues.push(o)}class In{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const o=[];for(const r of n){if(r.status==="aborted")return Ve;r.status==="dirty"&&t.dirty(),o.push(r.value)}return{status:t.value,value:o}}static async mergeObjectAsync(t,n){const o=[];for(const r of n){const a=await r.key,i=await r.value;o.push({key:a,value:i})}return In.mergeObjectSync(t,o)}static mergeObjectSync(t,n){const o={};for(const r of n){const{key:a,value:i}=r;if(a.status==="aborted"||i.status==="aborted")return Ve;a.status==="dirty"&&t.dirty(),i.status==="dirty"&&t.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||r.alwaysSet)&&(o[a.value]=i.value)}return{status:t.value,value:o}}}const Ve=Object.freeze({status:"aborted"}),C2=e=>({status:"dirty",value:e}),Io=e=>({status:"valid",value:e}),OU=e=>e.status==="aborted",qU=e=>e.status==="dirty",x0=e=>e.status==="valid",BP=e=>typeof Promise<"u"&&e instanceof Promise;var Ne;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(Ne||(Ne={}));class Tr{constructor(t,n,o,r){this._cachedPath=[],this.parent=t,this.data=n,this._path=o,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const FU=(e,t)=>{if(x0(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new Ma(e.common.issues);return this._error=n,this._error}}};function Xe(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:o,description:r}=e;if(t&&(n||o))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:r}:{errorMap:(i,s)=>{const{message:c}=e;return i.code==="invalid_enum_value"?{message:c??s.defaultError}:typeof s.data>"u"?{message:c??o??s.defaultError}:i.code!=="invalid_type"?{message:s.defaultError}:{message:c??n??s.defaultError}},description:r}}class Je{get description(){return this._def.description}_getType(t){return oi(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:oi(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new In,ctx:{common:t.parent.common,data:t.data,parsedType:oi(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(BP(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const o=this.safeParse(t,n);if(o.success)return o.data;throw o.error}safeParse(t,n){const o={common:{issues:[],async:(n==null?void 0:n.async)??!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:oi(t)},r=this._parseSync({data:t,path:o.path,parent:o});return FU(o,r)}"~validate"(t){var o,r;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:oi(t)};if(!this["~standard"].async)try{const a=this._parseSync({data:t,path:[],parent:n});return x0(a)?{value:a.value}:{issues:n.common.issues}}catch(a){(r=(o=a==null?void 0:a.message)==null?void 0:o.toLowerCase())!=null&&r.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(a=>x0(a)?{value:a.value}:{issues:n.common.issues})}async parseAsync(t,n){const o=await this.safeParseAsync(t,n);if(o.success)return o.data;throw o.error}async safeParseAsync(t,n){const o={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:oi(t)},r=this._parse({data:t,path:o.path,parent:o}),a=await(BP(r)?r:Promise.resolve(r));return FU(o,a)}refine(t,n){const o=r=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(r):n;return this._refinement((r,a)=>{const i=t(r),s=()=>a.addIssue({code:me.custom,...o(r)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(s(),!1)):i?!0:(s(),!1)})}refinement(t,n){return this._refinement((o,r)=>t(o)?!0:(r.addIssue(typeof n=="function"?n(o,r):n),!1))}_refinement(t){return new b0({schema:this,typeName:qe.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return xi.create(this,this._def)}nullable(){return _0.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return jr.create(this)}promise(){return XP.create(this,this._def)}or(t){return WP.create([this,t],this._def)}and(t){return GP.create(this,t,this._def)}transform(t){return new b0({...Xe(this._def),schema:this,typeName:qe.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new AH({...Xe(this._def),innerType:this,defaultValue:n,typeName:qe.ZodDefault})}brand(){return new aHe({typeName:qe.ZodBranded,type:this,...Xe(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new EH({...Xe(this._def),innerType:this,catchValue:n,typeName:qe.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return Pq.create(this,t)}readonly(){return $H.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const TDe=/^c[^\s-]{8,}$/i,DDe=/^[0-9a-z]+$/,HDe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ODe=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,qDe=/^[a-z0-9_-]{21}$/i,FDe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,VDe=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,BDe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,UDe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let bT;const WDe=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,GDe=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ZDe=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,XDe=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,KDe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,YDe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,oJ="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",QDe=new RegExp(`^${oJ}$`);function rJ(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function JDe(e){return new RegExp(`^${rJ(e)}$`)}function eHe(e){let t=`${oJ}T${rJ(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function tHe(e,t){return!!((t==="v4"||!t)&&WDe.test(e)||(t==="v6"||!t)&&ZDe.test(e))}function nHe(e,t){if(!FDe.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const o=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),r=JSON.parse(atob(o));return!(typeof r!="object"||r===null||"typ"in r&&(r==null?void 0:r.typ)!=="JWT"||!r.alg||t&&r.alg!==t)}catch{return!1}}function oHe(e,t){return!!((t==="v4"||!t)&&GDe.test(e)||(t==="v6"||!t)&&XDe.test(e))}class ya extends Je{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Le.string){const a=this._getOrReturnCtx(t);return be(a,{code:me.invalid_type,expected:Le.string,received:a.parsedType}),Ve}const o=new In;let r;for(const a of this._def.checks)if(a.kind==="min")t.data.length<a.value&&(r=this._getOrReturnCtx(t,r),be(r,{code:me.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),o.dirty());else if(a.kind==="max")t.data.length>a.value&&(r=this._getOrReturnCtx(t,r),be(r,{code:me.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),o.dirty());else if(a.kind==="length"){const i=t.data.length>a.value,s=t.data.length<a.value;(i||s)&&(r=this._getOrReturnCtx(t,r),i?be(r,{code:me.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):s&&be(r,{code:me.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),o.dirty())}else if(a.kind==="email")BDe.test(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{validation:"email",code:me.invalid_string,message:a.message}),o.dirty());else if(a.kind==="emoji")bT||(bT=new RegExp(UDe,"u")),bT.test(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{validation:"emoji",code:me.invalid_string,message:a.message}),o.dirty());else if(a.kind==="uuid")ODe.test(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{validation:"uuid",code:me.invalid_string,message:a.message}),o.dirty());else if(a.kind==="nanoid")qDe.test(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{validation:"nanoid",code:me.invalid_string,message:a.message}),o.dirty());else if(a.kind==="cuid")TDe.test(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{validation:"cuid",code:me.invalid_string,message:a.message}),o.dirty());else if(a.kind==="cuid2")DDe.test(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{validation:"cuid2",code:me.invalid_string,message:a.message}),o.dirty());else if(a.kind==="ulid")HDe.test(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{validation:"ulid",code:me.invalid_string,message:a.message}),o.dirty());else if(a.kind==="url")try{new URL(t.data)}catch{r=this._getOrReturnCtx(t,r),be(r,{validation:"url",code:me.invalid_string,message:a.message}),o.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{validation:"regex",code:me.invalid_string,message:a.message}),o.dirty())):a.kind==="trim"?t.data=t.data.trim():a.kind==="includes"?t.data.includes(a.value,a.position)||(r=this._getOrReturnCtx(t,r),be(r,{code:me.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),o.dirty()):a.kind==="toLowerCase"?t.data=t.data.toLowerCase():a.kind==="toUpperCase"?t.data=t.data.toUpperCase():a.kind==="startsWith"?t.data.startsWith(a.value)||(r=this._getOrReturnCtx(t,r),be(r,{code:me.invalid_string,validation:{startsWith:a.value},message:a.message}),o.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(r=this._getOrReturnCtx(t,r),be(r,{code:me.invalid_string,validation:{endsWith:a.value},message:a.message}),o.dirty()):a.kind==="datetime"?eHe(a).test(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{code:me.invalid_string,validation:"datetime",message:a.message}),o.dirty()):a.kind==="date"?QDe.test(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{code:me.invalid_string,validation:"date",message:a.message}),o.dirty()):a.kind==="time"?JDe(a).test(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{code:me.invalid_string,validation:"time",message:a.message}),o.dirty()):a.kind==="duration"?VDe.test(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{validation:"duration",code:me.invalid_string,message:a.message}),o.dirty()):a.kind==="ip"?tHe(t.data,a.version)||(r=this._getOrReturnCtx(t,r),be(r,{validation:"ip",code:me.invalid_string,message:a.message}),o.dirty()):a.kind==="jwt"?nHe(t.data,a.alg)||(r=this._getOrReturnCtx(t,r),be(r,{validation:"jwt",code:me.invalid_string,message:a.message}),o.dirty()):a.kind==="cidr"?oHe(t.data,a.version)||(r=this._getOrReturnCtx(t,r),be(r,{validation:"cidr",code:me.invalid_string,message:a.message}),o.dirty()):a.kind==="base64"?KDe.test(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{validation:"base64",code:me.invalid_string,message:a.message}),o.dirty()):a.kind==="base64url"?YDe.test(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{validation:"base64url",code:me.invalid_string,message:a.message}),o.dirty()):at.assertNever(a);return{status:o.value,value:t.data}}_regex(t,n,o){return this.refinement(r=>t.test(r),{validation:n,code:me.invalid_string,...Ne.errToObj(o)})}_addCheck(t){return new ya({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Ne.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Ne.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Ne.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Ne.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Ne.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Ne.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Ne.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Ne.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Ne.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...Ne.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...Ne.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Ne.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...Ne.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...Ne.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...Ne.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...Ne.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...Ne.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...Ne.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...Ne.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...Ne.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...Ne.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...Ne.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...Ne.errToObj(n)})}nonempty(t){return this.min(1,Ne.errToObj(t))}trim(){return new ya({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ya({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ya({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}ya.create=e=>new ya({checks:[],typeName:qe.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...Xe(e)});function rHe(e,t){const n=(e.toString().split(".")[1]||"").length,o=(t.toString().split(".")[1]||"").length,r=n>o?n:o,a=Number.parseInt(e.toFixed(r).replace(".","")),i=Number.parseInt(t.toFixed(r).replace(".",""));return a%i/10**r}class w0 extends Je{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==Le.number){const a=this._getOrReturnCtx(t);return be(a,{code:me.invalid_type,expected:Le.number,received:a.parsedType}),Ve}let o;const r=new In;for(const a of this._def.checks)a.kind==="int"?at.isInteger(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{code:me.invalid_type,expected:"integer",received:"float",message:a.message}),r.dirty()):a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(o=this._getOrReturnCtx(t,o),be(o,{code:me.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(o=this._getOrReturnCtx(t,o),be(o,{code:me.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="multipleOf"?rHe(t.data,a.value)!==0&&(o=this._getOrReturnCtx(t,o),be(o,{code:me.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{code:me.not_finite,message:a.message}),r.dirty()):at.assertNever(a);return{status:r.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,Ne.toString(n))}gt(t,n){return this.setLimit("min",t,!1,Ne.toString(n))}lte(t,n){return this.setLimit("max",t,!0,Ne.toString(n))}lt(t,n){return this.setLimit("max",t,!1,Ne.toString(n))}setLimit(t,n,o,r){return new w0({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:o,message:Ne.toString(r)}]})}_addCheck(t){return new w0({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Ne.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ne.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ne.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ne.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ne.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:Ne.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:Ne.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Ne.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Ne.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&at.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const o of this._def.checks){if(o.kind==="finite"||o.kind==="int"||o.kind==="multipleOf")return!0;o.kind==="min"?(n===null||o.value>n)&&(n=o.value):o.kind==="max"&&(t===null||o.value<t)&&(t=o.value)}return Number.isFinite(n)&&Number.isFinite(t)}}w0.create=e=>new w0({checks:[],typeName:qe.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...Xe(e)});class qh extends Je{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==Le.bigint)return this._getInvalidInput(t);let o;const r=new In;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(o=this._getOrReturnCtx(t,o),be(o,{code:me.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(o=this._getOrReturnCtx(t,o),be(o,{code:me.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="multipleOf"?t.data%a.value!==BigInt(0)&&(o=this._getOrReturnCtx(t,o),be(o,{code:me.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):at.assertNever(a);return{status:r.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return be(n,{code:me.invalid_type,expected:Le.bigint,received:n.parsedType}),Ve}gte(t,n){return this.setLimit("min",t,!0,Ne.toString(n))}gt(t,n){return this.setLimit("min",t,!1,Ne.toString(n))}lte(t,n){return this.setLimit("max",t,!0,Ne.toString(n))}lt(t,n){return this.setLimit("max",t,!1,Ne.toString(n))}setLimit(t,n,o,r){return new qh({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:o,message:Ne.toString(r)}]})}_addCheck(t){return new qh({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Ne.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Ne.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Ne.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Ne.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:Ne.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}qh.create=e=>new qh({checks:[],typeName:qe.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...Xe(e)});class SH extends Je{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Le.boolean){const o=this._getOrReturnCtx(t);return be(o,{code:me.invalid_type,expected:Le.boolean,received:o.parsedType}),Ve}return Io(t.data)}}SH.create=e=>new SH({typeName:qe.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...Xe(e)});class UP extends Je{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Le.date){const a=this._getOrReturnCtx(t);return be(a,{code:me.invalid_type,expected:Le.date,received:a.parsedType}),Ve}if(Number.isNaN(t.data.getTime())){const a=this._getOrReturnCtx(t);return be(a,{code:me.invalid_date}),Ve}const o=new In;let r;for(const a of this._def.checks)a.kind==="min"?t.data.getTime()<a.value&&(r=this._getOrReturnCtx(t,r),be(r,{code:me.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),o.dirty()):a.kind==="max"?t.data.getTime()>a.value&&(r=this._getOrReturnCtx(t,r),be(r,{code:me.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),o.dirty()):at.assertNever(a);return{status:o.value,value:new Date(t.data.getTime())}}_addCheck(t){return new UP({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:Ne.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:Ne.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}UP.create=e=>new UP({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:qe.ZodDate,...Xe(e)});class VU extends Je{_parse(t){if(this._getType(t)!==Le.symbol){const o=this._getOrReturnCtx(t);return be(o,{code:me.invalid_type,expected:Le.symbol,received:o.parsedType}),Ve}return Io(t.data)}}VU.create=e=>new VU({typeName:qe.ZodSymbol,...Xe(e)});class BU extends Je{_parse(t){if(this._getType(t)!==Le.undefined){const o=this._getOrReturnCtx(t);return be(o,{code:me.invalid_type,expected:Le.undefined,received:o.parsedType}),Ve}return Io(t.data)}}BU.create=e=>new BU({typeName:qe.ZodUndefined,...Xe(e)});class UU extends Je{_parse(t){if(this._getType(t)!==Le.null){const o=this._getOrReturnCtx(t);return be(o,{code:me.invalid_type,expected:Le.null,received:o.parsedType}),Ve}return Io(t.data)}}UU.create=e=>new UU({typeName:qe.ZodNull,...Xe(e)});class WU extends Je{constructor(){super(...arguments),this._any=!0}_parse(t){return Io(t.data)}}WU.create=e=>new WU({typeName:qe.ZodAny,...Xe(e)});class LH extends Je{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Io(t.data)}}LH.create=e=>new LH({typeName:qe.ZodUnknown,...Xe(e)});class Ci extends Je{_parse(t){const n=this._getOrReturnCtx(t);return be(n,{code:me.invalid_type,expected:Le.never,received:n.parsedType}),Ve}}Ci.create=e=>new Ci({typeName:qe.ZodNever,...Xe(e)});class GU extends Je{_parse(t){if(this._getType(t)!==Le.undefined){const o=this._getOrReturnCtx(t);return be(o,{code:me.invalid_type,expected:Le.void,received:o.parsedType}),Ve}return Io(t.data)}}GU.create=e=>new GU({typeName:qe.ZodVoid,...Xe(e)});class jr extends Je{_parse(t){const{ctx:n,status:o}=this._processInputParams(t),r=this._def;if(n.parsedType!==Le.array)return be(n,{code:me.invalid_type,expected:Le.array,received:n.parsedType}),Ve;if(r.exactLength!==null){const i=n.data.length>r.exactLength.value,s=n.data.length<r.exactLength.value;(i||s)&&(be(n,{code:i?me.too_big:me.too_small,minimum:s?r.exactLength.value:void 0,maximum:i?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),o.dirty())}if(r.minLength!==null&&n.data.length<r.minLength.value&&(be(n,{code:me.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),o.dirty()),r.maxLength!==null&&n.data.length>r.maxLength.value&&(be(n,{code:me.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),o.dirty()),n.common.async)return Promise.all([...n.data].map((i,s)=>r.type._parseAsync(new Tr(n,i,n.path,s)))).then(i=>In.mergeArray(o,i));const a=[...n.data].map((i,s)=>r.type._parseSync(new Tr(n,i,n.path,s)));return In.mergeArray(o,a)}get element(){return this._def.type}min(t,n){return new jr({...this._def,minLength:{value:t,message:Ne.toString(n)}})}max(t,n){return new jr({...this._def,maxLength:{value:t,message:Ne.toString(n)}})}length(t,n){return new jr({...this._def,exactLength:{value:t,message:Ne.toString(n)}})}nonempty(t){return this.min(1,t)}}jr.create=(e,t)=>new jr({type:e,minLength:null,maxLength:null,exactLength:null,typeName:qe.ZodArray,...Xe(t)});function vu(e){if(e instanceof Zt){const t={};for(const n in e.shape){const o=e.shape[n];t[n]=xi.create(vu(o))}return new Zt({...e._def,shape:()=>t})}else return e instanceof jr?new jr({...e._def,type:vu(e.element)}):e instanceof xi?xi.create(vu(e.unwrap())):e instanceof _0?_0.create(vu(e.unwrap())):e instanceof Ad?Ad.create(e.items.map(t=>vu(t))):e}class Zt extends Je{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=at.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==Le.object){const l=this._getOrReturnCtx(t);return be(l,{code:me.invalid_type,expected:Le.object,received:l.parsedType}),Ve}const{status:o,ctx:r}=this._processInputParams(t),{shape:a,keys:i}=this._getCached(),s=[];if(!(this._def.catchall instanceof Ci&&this._def.unknownKeys==="strip"))for(const l in r.data)i.includes(l)||s.push(l);const c=[];for(const l of i){const h=a[l],u=r.data[l];c.push({key:{status:"valid",value:l},value:h._parse(new Tr(r,u,r.path,l)),alwaysSet:l in r.data})}if(this._def.catchall instanceof Ci){const l=this._def.unknownKeys;if(l==="passthrough")for(const h of s)c.push({key:{status:"valid",value:h},value:{status:"valid",value:r.data[h]}});else if(l==="strict")s.length>0&&(be(r,{code:me.unrecognized_keys,keys:s}),o.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const h of s){const u=r.data[h];c.push({key:{status:"valid",value:h},value:l._parse(new Tr(r,u,r.path,h)),alwaysSet:h in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const l=[];for(const h of c){const u=await h.key,f=await h.value;l.push({key:u,value:f,alwaysSet:h.alwaysSet})}return l}).then(l=>In.mergeObjectSync(o,l)):In.mergeObjectSync(o,c)}get shape(){return this._def.shape()}strict(t){return Ne.errToObj,new Zt({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,o)=>{var a,i;const r=((i=(a=this._def).errorMap)==null?void 0:i.call(a,n,o).message)??o.defaultError;return n.code==="unrecognized_keys"?{message:Ne.errToObj(t).message??r}:{message:r}}}:{}})}strip(){return new Zt({...this._def,unknownKeys:"strip"})}passthrough(){return new Zt({...this._def,unknownKeys:"passthrough"})}extend(t){return new Zt({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Zt({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:qe.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new Zt({...this._def,catchall:t})}pick(t){const n={};for(const o of at.objectKeys(t))t[o]&&this.shape[o]&&(n[o]=this.shape[o]);return new Zt({...this._def,shape:()=>n})}omit(t){const n={};for(const o of at.objectKeys(this.shape))t[o]||(n[o]=this.shape[o]);return new Zt({...this._def,shape:()=>n})}deepPartial(){return vu(this)}partial(t){const n={};for(const o of at.objectKeys(this.shape)){const r=this.shape[o];t&&!t[o]?n[o]=r:n[o]=r.optional()}return new Zt({...this._def,shape:()=>n})}required(t){const n={};for(const o of at.objectKeys(this.shape))if(t&&!t[o])n[o]=this.shape[o];else{let a=this.shape[o];for(;a instanceof xi;)a=a._def.innerType;n[o]=a}return new Zt({...this._def,shape:()=>n})}keyof(){return aJ(at.objectKeys(this.shape))}}Zt.create=(e,t)=>new Zt({shape:()=>e,unknownKeys:"strip",catchall:Ci.create(),typeName:qe.ZodObject,...Xe(t)});Zt.strictCreate=(e,t)=>new Zt({shape:()=>e,unknownKeys:"strict",catchall:Ci.create(),typeName:qe.ZodObject,...Xe(t)});Zt.lazycreate=(e,t)=>new Zt({shape:e,unknownKeys:"strip",catchall:Ci.create(),typeName:qe.ZodObject,...Xe(t)});class WP extends Je{_parse(t){const{ctx:n}=this._processInputParams(t),o=this._def.options;function r(a){for(const s of a)if(s.result.status==="valid")return s.result;for(const s of a)if(s.result.status==="dirty")return n.common.issues.push(...s.ctx.common.issues),s.result;const i=a.map(s=>new Ma(s.ctx.common.issues));return be(n,{code:me.invalid_union,unionErrors:i}),Ve}if(n.common.async)return Promise.all(o.map(async a=>{const i={...n,common:{...n.common,issues:[]},parent:null};return{result:await a._parseAsync({data:n.data,path:n.path,parent:i}),ctx:i}})).then(r);{let a;const i=[];for(const c of o){const l={...n,common:{...n.common,issues:[]},parent:null},h=c._parseSync({data:n.data,path:n.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return n.common.issues.push(...a.ctx.common.issues),a.result;const s=i.map(c=>new Ma(c));return be(n,{code:me.invalid_union,unionErrors:s}),Ve}}get options(){return this._def.options}}WP.create=(e,t)=>new WP({options:e,typeName:qe.ZodUnion,...Xe(t)});function IH(e,t){const n=oi(e),o=oi(t);if(e===t)return{valid:!0,data:e};if(n===Le.object&&o===Le.object){const r=at.objectKeys(t),a=at.objectKeys(e).filter(s=>r.indexOf(s)!==-1),i={...e,...t};for(const s of a){const c=IH(e[s],t[s]);if(!c.valid)return{valid:!1};i[s]=c.data}return{valid:!0,data:i}}else if(n===Le.array&&o===Le.array){if(e.length!==t.length)return{valid:!1};const r=[];for(let a=0;a<e.length;a++){const i=e[a],s=t[a],c=IH(i,s);if(!c.valid)return{valid:!1};r.push(c.data)}return{valid:!0,data:r}}else return n===Le.date&&o===Le.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class GP extends Je{_parse(t){const{status:n,ctx:o}=this._processInputParams(t),r=(a,i)=>{if(OU(a)||OU(i))return Ve;const s=IH(a.value,i.value);return s.valid?((qU(a)||qU(i))&&n.dirty(),{status:n.value,value:s.data}):(be(o,{code:me.invalid_intersection_types}),Ve)};return o.common.async?Promise.all([this._def.left._parseAsync({data:o.data,path:o.path,parent:o}),this._def.right._parseAsync({data:o.data,path:o.path,parent:o})]).then(([a,i])=>r(a,i)):r(this._def.left._parseSync({data:o.data,path:o.path,parent:o}),this._def.right._parseSync({data:o.data,path:o.path,parent:o}))}}GP.create=(e,t,n)=>new GP({left:e,right:t,typeName:qe.ZodIntersection,...Xe(n)});class Ad extends Je{_parse(t){const{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==Le.array)return be(o,{code:me.invalid_type,expected:Le.array,received:o.parsedType}),Ve;if(o.data.length<this._def.items.length)return be(o,{code:me.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Ve;!this._def.rest&&o.data.length>this._def.items.length&&(be(o,{code:me.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const a=[...o.data].map((i,s)=>{const c=this._def.items[s]||this._def.rest;return c?c._parse(new Tr(o,i,o.path,s)):null}).filter(i=>!!i);return o.common.async?Promise.all(a).then(i=>In.mergeArray(n,i)):In.mergeArray(n,a)}get items(){return this._def.items}rest(t){return new Ad({...this._def,rest:t})}}Ad.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Ad({items:e,typeName:qe.ZodTuple,rest:null,...Xe(t)})};class ZP extends Je{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==Le.object)return be(o,{code:me.invalid_type,expected:Le.object,received:o.parsedType}),Ve;const r=[],a=this._def.keyType,i=this._def.valueType;for(const s in o.data)r.push({key:a._parse(new Tr(o,s,o.path,s)),value:i._parse(new Tr(o,o.data[s],o.path,s)),alwaysSet:s in o.data});return o.common.async?In.mergeObjectAsync(n,r):In.mergeObjectSync(n,r)}get element(){return this._def.valueType}static create(t,n,o){return n instanceof Je?new ZP({keyType:t,valueType:n,typeName:qe.ZodRecord,...Xe(o)}):new ZP({keyType:ya.create(),valueType:t,typeName:qe.ZodRecord,...Xe(n)})}}class ZU extends Je{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==Le.map)return be(o,{code:me.invalid_type,expected:Le.map,received:o.parsedType}),Ve;const r=this._def.keyType,a=this._def.valueType,i=[...o.data.entries()].map(([s,c],l)=>({key:r._parse(new Tr(o,s,o.path,[l,"key"])),value:a._parse(new Tr(o,c,o.path,[l,"value"]))}));if(o.common.async){const s=new Map;return Promise.resolve().then(async()=>{for(const c of i){const l=await c.key,h=await c.value;if(l.status==="aborted"||h.status==="aborted")return Ve;(l.status==="dirty"||h.status==="dirty")&&n.dirty(),s.set(l.value,h.value)}return{status:n.value,value:s}})}else{const s=new Map;for(const c of i){const l=c.key,h=c.value;if(l.status==="aborted"||h.status==="aborted")return Ve;(l.status==="dirty"||h.status==="dirty")&&n.dirty(),s.set(l.value,h.value)}return{status:n.value,value:s}}}}ZU.create=(e,t,n)=>new ZU({valueType:t,keyType:e,typeName:qe.ZodMap,...Xe(n)});class Fh extends Je{_parse(t){const{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==Le.set)return be(o,{code:me.invalid_type,expected:Le.set,received:o.parsedType}),Ve;const r=this._def;r.minSize!==null&&o.data.size<r.minSize.value&&(be(o,{code:me.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),n.dirty()),r.maxSize!==null&&o.data.size>r.maxSize.value&&(be(o,{code:me.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),n.dirty());const a=this._def.valueType;function i(c){const l=new Set;for(const h of c){if(h.status==="aborted")return Ve;h.status==="dirty"&&n.dirty(),l.add(h.value)}return{status:n.value,value:l}}const s=[...o.data.values()].map((c,l)=>a._parse(new Tr(o,c,o.path,l)));return o.common.async?Promise.all(s).then(c=>i(c)):i(s)}min(t,n){return new Fh({...this._def,minSize:{value:t,message:Ne.toString(n)}})}max(t,n){return new Fh({...this._def,maxSize:{value:t,message:Ne.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}Fh.create=(e,t)=>new Fh({valueType:e,minSize:null,maxSize:null,typeName:qe.ZodSet,...Xe(t)});class XU extends Je{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}XU.create=(e,t)=>new XU({getter:e,typeName:qe.ZodLazy,...Xe(t)});class NH extends Je{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return be(n,{received:n.data,code:me.invalid_literal,expected:this._def.value}),Ve}return{status:"valid",value:t.data}}get value(){return this._def.value}}NH.create=(e,t)=>new NH({value:e,typeName:qe.ZodLiteral,...Xe(t)});function aJ(e,t){return new M0({values:e,typeName:qe.ZodEnum,...Xe(t)})}class M0 extends Je{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),o=this._def.values;return be(n,{expected:at.joinValues(o),received:n.parsedType,code:me.invalid_type}),Ve}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const n=this._getOrReturnCtx(t),o=this._def.values;return be(n,{received:n.data,code:me.invalid_enum_value,options:o}),Ve}return Io(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return M0.create(t,{...this._def,...n})}exclude(t,n=this._def){return M0.create(this.options.filter(o=>!t.includes(o)),{...this._def,...n})}}M0.create=aJ;class KU extends Je{_parse(t){const n=at.getValidEnumValues(this._def.values),o=this._getOrReturnCtx(t);if(o.parsedType!==Le.string&&o.parsedType!==Le.number){const r=at.objectValues(n);return be(o,{expected:at.joinValues(r),received:o.parsedType,code:me.invalid_type}),Ve}if(this._cache||(this._cache=new Set(at.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const r=at.objectValues(n);return be(o,{received:o.data,code:me.invalid_enum_value,options:r}),Ve}return Io(t.data)}get enum(){return this._def.values}}KU.create=(e,t)=>new KU({values:e,typeName:qe.ZodNativeEnum,...Xe(t)});class XP extends Je{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==Le.promise&&n.common.async===!1)return be(n,{code:me.invalid_type,expected:Le.promise,received:n.parsedType}),Ve;const o=n.parsedType===Le.promise?n.data:Promise.resolve(n.data);return Io(o.then(r=>this._def.type.parseAsync(r,{path:n.path,errorMap:n.common.contextualErrorMap})))}}XP.create=(e,t)=>new XP({type:e,typeName:qe.ZodPromise,...Xe(t)});class b0 extends Je{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===qe.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:o}=this._processInputParams(t),r=this._def.effect||null,a={addIssue:i=>{be(o,i),i.fatal?n.abort():n.dirty()},get path(){return o.path}};if(a.addIssue=a.addIssue.bind(a),r.type==="preprocess"){const i=r.transform(o.data,a);if(o.common.async)return Promise.resolve(i).then(async s=>{if(n.value==="aborted")return Ve;const c=await this._def.schema._parseAsync({data:s,path:o.path,parent:o});return c.status==="aborted"?Ve:c.status==="dirty"||n.value==="dirty"?C2(c.value):c});{if(n.value==="aborted")return Ve;const s=this._def.schema._parseSync({data:i,path:o.path,parent:o});return s.status==="aborted"?Ve:s.status==="dirty"||n.value==="dirty"?C2(s.value):s}}if(r.type==="refinement"){const i=s=>{const c=r.refinement(s,a);if(o.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(o.common.async===!1){const s=this._def.schema._parseSync({data:o.data,path:o.path,parent:o});return s.status==="aborted"?Ve:(s.status==="dirty"&&n.dirty(),i(s.value),{status:n.value,value:s.value})}else return this._def.schema._parseAsync({data:o.data,path:o.path,parent:o}).then(s=>s.status==="aborted"?Ve:(s.status==="dirty"&&n.dirty(),i(s.value).then(()=>({status:n.value,value:s.value}))))}if(r.type==="transform")if(o.common.async===!1){const i=this._def.schema._parseSync({data:o.data,path:o.path,parent:o});if(!x0(i))return Ve;const s=r.transform(i.value,a);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:s}}else return this._def.schema._parseAsync({data:o.data,path:o.path,parent:o}).then(i=>x0(i)?Promise.resolve(r.transform(i.value,a)).then(s=>({status:n.value,value:s})):Ve);at.assertNever(r)}}b0.create=(e,t,n)=>new b0({schema:e,typeName:qe.ZodEffects,effect:t,...Xe(n)});b0.createWithPreprocess=(e,t,n)=>new b0({schema:t,effect:{type:"preprocess",transform:e},typeName:qe.ZodEffects,...Xe(n)});class xi extends Je{_parse(t){return this._getType(t)===Le.undefined?Io(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}xi.create=(e,t)=>new xi({innerType:e,typeName:qe.ZodOptional,...Xe(t)});class _0 extends Je{_parse(t){return this._getType(t)===Le.null?Io(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}_0.create=(e,t)=>new _0({innerType:e,typeName:qe.ZodNullable,...Xe(t)});class AH extends Je{_parse(t){const{ctx:n}=this._processInputParams(t);let o=n.data;return n.parsedType===Le.undefined&&(o=this._def.defaultValue()),this._def.innerType._parse({data:o,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}AH.create=(e,t)=>new AH({innerType:e,typeName:qe.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Xe(t)});class EH extends Je{_parse(t){const{ctx:n}=this._processInputParams(t),o={...n,common:{...n.common,issues:[]}},r=this._def.innerType._parse({data:o.data,path:o.path,parent:{...o}});return BP(r)?r.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Ma(o.common.issues)},input:o.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new Ma(o.common.issues)},input:o.data})}}removeCatch(){return this._def.innerType}}EH.create=(e,t)=>new EH({innerType:e,typeName:qe.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Xe(t)});class YU extends Je{_parse(t){if(this._getType(t)!==Le.nan){const o=this._getOrReturnCtx(t);return be(o,{code:me.invalid_type,expected:Le.nan,received:o.parsedType}),Ve}return{status:"valid",value:t.data}}}YU.create=e=>new YU({typeName:qe.ZodNaN,...Xe(e)});class aHe extends Je{_parse(t){const{ctx:n}=this._processInputParams(t),o=n.data;return this._def.type._parse({data:o,path:n.path,parent:n})}unwrap(){return this._def.type}}class Pq extends Je{_parse(t){const{status:n,ctx:o}=this._processInputParams(t);if(o.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:o.data,path:o.path,parent:o});return a.status==="aborted"?Ve:a.status==="dirty"?(n.dirty(),C2(a.value)):this._def.out._parseAsync({data:a.value,path:o.path,parent:o})})();{const r=this._def.in._parseSync({data:o.data,path:o.path,parent:o});return r.status==="aborted"?Ve:r.status==="dirty"?(n.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:o.path,parent:o})}}static create(t,n){return new Pq({in:t,out:n,typeName:qe.ZodPipeline})}}class $H extends Je{_parse(t){const n=this._def.innerType._parse(t),o=r=>(x0(r)&&(r.value=Object.freeze(r.value)),r);return BP(n)?n.then(r=>o(r)):o(n)}unwrap(){return this._def.innerType}}$H.create=(e,t)=>new $H({innerType:e,typeName:qe.ZodReadonly,...Xe(t)});var qe;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(qe||(qe={}));const sn=ya.create,iJ=w0.create,iHe=SH.create,lh=LH.create;Ci.create;const ts=jr.create,rt=Zt.create,jH=WP.create;GP.create;Ad.create;const QU=ZP.create,up=NH.create,hp=M0.create;XP.create;xi.create;_0.create;const sHe=rt({$state:sn().min(1)}),sa=rt({$action:sn().min(1)}),cHe=rt({$cond:lh(),$then:lh(),$else:lh().optional()}),To=e=>jH([e,sHe,sa,cHe]),Ht=To(sn()),oa=To(iJ()),fp=To(iHe()),sJ={Card:rt({title:Ht.optional()}),Separator:rt({orientation:To(hp(["horizontal","vertical"])).optional()}),Tabs:rt({value:Ht.optional(),items:ts(rt({id:sn(),label:sn()})),onChange:sa.optional()}),Accordion:rt({items:ts(rt({id:sn(),title:sn(),content:sn()}))}),Badge:rt({label:Ht,variant:To(hp(["default","secondary","destructive","outline"])).optional()}),Avatar:rt({src:Ht.optional(),alt:Ht.optional(),fallback:Ht.optional()}),Progress:rt({value:oa}),Skeleton:rt({width:oa.optional(),height:oa.optional()}),Label:rt({text:Ht}),Heading:rt({level:To(jH([up(1),up(2),up(3),up(4)])).optional(),text:Ht}),Text:rt({text:Ht,muted:fp.optional()}),Icon:rt({name:Ht,size:oa.optional()}),Chart:rt({kind:To(hp(["bar","line","area","pie"])),data:To(ts(QU(sn(),lh()))),xKey:Ht.optional(),series:ts(rt({key:sn(),label:sn().optional()})).optional()}),Table:rt({columns:ts(rt({key:sn(),label:sn()})),rows:To(ts(QU(sn(),lh())))}),Metric:rt({label:Ht,value:To(jH([sn(),iJ()]))}),CodeBlock:rt({code:Ht,language:Ht.optional()}),Markdown:rt({content:Ht}),Button:rt({label:Ht,variant:To(hp(["default","destructive","outline","secondary","ghost","link"])).optional(),onClick:sa.optional(),disabled:fp.optional()}),Input:rt({value:Ht.optional(),placeholder:Ht.optional(),onChange:sa.optional()}),Checkbox:rt({checked:fp.optional(),onChange:sa.optional(),label:Ht.optional()}),Switch:rt({checked:fp.optional(),onChange:sa.optional()}),Select:rt({value:Ht.optional(),items:ts(rt({value:sn(),label:sn()})),onChange:sa.optional()}),Textarea:rt({value:Ht.optional(),placeholder:Ht.optional(),rows:oa.optional(),onChange:sa.optional()}),Slider:rt({value:oa.optional(),min:oa.optional(),max:oa.optional(),step:oa.optional(),onChange:sa.optional()})},cJ=Object.keys(sJ);Object.fromEntries(cJ.map(e=>[e,{props:sJ[e],description:e}]));function JU(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Dr(...e){return t=>{let n=!1;const o=e.map(r=>{const a=JU(r,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let r=0;r<o.length;r++){const a=o[r];typeof a=="function"?a():JU(e[r],null)}}}}function gt(...e){return m.useCallback(Dr(...e),e)}var lHe=Symbol.for("react.lazy"),KP=bO[" use ".trim().toString()];function dHe(e){return typeof e=="object"&&e!==null&&"then"in e}function lJ(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===lHe&&"_payload"in e&&dHe(e._payload)}function uHe(e){const t=fHe(e),n=m.forwardRef((o,r)=>{let{children:a,...i}=o;lJ(a)&&typeof KP=="function"&&(a=KP(a._payload));const s=m.Children.toArray(a),c=s.find(yHe);if(c){const l=c.props.children,h=s.map(u=>u===c?m.Children.count(l)>1?m.Children.only(null):m.isValidElement(l)?l.props.children:null:u);return p.jsx(t,{...i,ref:r,children:m.isValidElement(l)?m.cloneElement(l,void 0,h):null})}return p.jsx(t,{...i,ref:r,children:a})});return n.displayName=`${e}.Slot`,n}var hHe=uHe("Slot");function fHe(e){const t=m.forwardRef((n,o)=>{let{children:r,...a}=n;if(lJ(r)&&typeof KP=="function"&&(r=KP(r._payload)),m.isValidElement(r)){const i=gHe(r),s=mHe(a,r.props);return r.type!==m.Fragment&&(s.ref=o?Dr(o,i):i),m.cloneElement(r,s)}return m.Children.count(r)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var pHe=Symbol("radix.slottable");function yHe(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===pHe}function mHe(e,t){const n={...t};for(const o in t){const r=e[o],a=t[o];/^on[A-Z]/.test(o)?r&&a?n[o]=(...s)=>{const c=a(...s);return r(...s),c}:r&&(n[o]=r):o==="style"?n[o]={...r,...a}:o==="className"&&(n[o]=[r,a].filter(Boolean).join(" "))}return{...e,...n}}function gHe(e){var o,r;let t=(o=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(r=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}const eW=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,tW=QK,dJ=(e,t)=>n=>{var o;if((t==null?void 0:t.variants)==null)return tW(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:r,defaultVariants:a}=t,i=Object.keys(r).map(l=>{const h=n==null?void 0:n[l],u=a==null?void 0:a[l];if(h===null)return null;const f=eW(h)||eW(u);return r[l][f]}),s=n&&Object.entries(n).reduce((l,h)=>{let[u,f]=h;return f===void 0||(l[u]=f),l},{}),c=t==null||(o=t.compoundVariants)===null||o===void 0?void 0:o.reduce((l,h)=>{let{class:u,className:f,...y}=h;return Object.entries(y).every(g=>{let[k,x]=g;return Array.isArray(x)?x.includes({...a,...s}[k]):{...a,...s}[k]===x})?[...l,u,f]:l},[]);return tW(e,i,c,n==null?void 0:n.class,n==null?void 0:n.className)},kHe=dJ("sf:inline-flex sf:items-center sf:justify-center sf:whitespace-nowrap sf:rounded-md sf:text-sm sf:font-medium sf:ring-offset-background sf:transition-colors sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:focus-visible:ring-offset-2 sf:disabled:pointer-events-none sf:disabled:opacity-50",{variants:{variant:{default:"sf:bg-primary sf:text-primary-foreground sf:font-semibold sf:hover:bg-emerald-400",destructive:"sf:bg-destructive sf:text-destructive-foreground sf:hover:bg-destructive/90",outline:"sf:border sf:border-input sf:bg-background sf:hover:bg-secondary sf:hover:text-foreground",secondary:"sf:bg-secondary sf:text-secondary-foreground sf:hover:bg-secondary/80",ghost:"sf:text-muted-foreground sf:hover:bg-muted sf:hover:text-foreground",link:"sf:text-primary sf:underline-offset-4 sf:hover:underline"},size:{default:"sf:h-9 sf:px-4 sf:py-2",sm:"sf:h-8 sf:rounded-md sf:px-3",lg:"sf:h-11 sf:rounded-md sf:px-8",icon:"sf:h-9 sf:w-9"}},defaultVariants:{variant:"default",size:"default"}}),ut=m.forwardRef(({className:e,variant:t,size:n,asChild:o=!1,...r},a)=>{const i=o?hHe:"button";return p.jsx(i,{className:oe(kHe({variant:t,size:n,className:e})),ref:a,...r})});ut.displayName="Button";function uJ(e,[t,n]){return Math.min(n,Math.max(t,e))}function Ie(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e==null||e(r),n===!1||!r.defaultPrevented)return t==null?void 0:t(r)}}function vHe(e,t){const n=m.createContext(t),o=a=>{const{children:i,...s}=a,c=m.useMemo(()=>s,Object.values(s));return p.jsx(n.Provider,{value:c,children:i})};o.displayName=e+"Provider";function r(a){const i=m.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${a}\` must be used within \`${e}\``)}return[o,r]}function Qo(e,t=[]){let n=[];function o(a,i){const s=m.createContext(i),c=n.length;n=[...n,i];const l=u=>{var v;const{scope:f,children:y,...g}=u,k=((v=f==null?void 0:f[e])==null?void 0:v[c])||s,x=m.useMemo(()=>g,Object.values(g));return p.jsx(k.Provider,{value:x,children:y})};l.displayName=a+"Provider";function h(u,f){var k;const y=((k=f==null?void 0:f[e])==null?void 0:k[c])||s,g=m.useContext(y);if(g)return g;if(i!==void 0)return i;throw new Error(`\`${u}\` must be used within \`${a}\``)}return[l,h]}const r=()=>{const a=n.map(i=>m.createContext(i));return function(s){const c=(s==null?void 0:s[e])||a;return m.useMemo(()=>({[`__scope${e}`]:{...s,[e]:c}}),[s,c])}};return r.scopeName=e,[o,xHe(r,...t)]}function xHe(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const o=e.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(a){const i=o.reduce((s,{useScope:c,scopeName:l})=>{const u=c(a)[`__scope${l}`];return{...s,...u}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var Si=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},wHe=bO[" useInsertionEffect ".trim().toString()]||Si;function Td({prop:e,defaultProp:t,onChange:n=()=>{},caller:o}){const[r,a,i]=MHe({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:r;{const h=m.useRef(e!==void 0);m.useEffect(()=>{const u=h.current;u!==s&&console.warn(`${o} is changing from ${u?"controlled":"uncontrolled"} to ${s?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),h.current=s},[s,o])}const l=m.useCallback(h=>{var u;if(s){const f=bHe(h)?h(e):h;f!==e&&((u=i.current)==null||u.call(i,f))}else a(h)},[s,e,a,i]);return[c,l]}function MHe({defaultProp:e,onChange:t}){const[n,o]=m.useState(e),r=m.useRef(n),a=m.useRef(t);return wHe(()=>{a.current=t},[t]),m.useEffect(()=>{var i;r.current!==n&&((i=a.current)==null||i.call(a,n),r.current=n)},[n,r]),[n,o,a]}function bHe(e){return typeof e=="function"}var _He=m.createContext(void 0);function Gz(e){const t=m.useContext(_He);return e||t||"ltr"}function CHe(e){const t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}function hJ(e){const[t,n]=m.useState(void 0);return Si(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const o=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;const a=r[0];let i,s;if("borderBoxSize"in a){const c=a.borderBoxSize,l=Array.isArray(c)?c[0]:c;i=l.inlineSize,s=l.blockSize}else i=e.offsetWidth,s=e.offsetHeight;n({width:i,height:s})});return o.observe(e,{box:"border-box"}),()=>o.unobserve(e)}else n(void 0)},[e]),t}function C0(e){const t=SHe(e),n=m.forwardRef((o,r)=>{const{children:a,...i}=o,s=m.Children.toArray(a),c=s.find(IHe);if(c){const l=c.props.children,h=s.map(u=>u===c?m.Children.count(l)>1?m.Children.only(null):m.isValidElement(l)?l.props.children:null:u);return p.jsx(t,{...i,ref:r,children:m.isValidElement(l)?m.cloneElement(l,void 0,h):null})}return p.jsx(t,{...i,ref:r,children:a})});return n.displayName=`${e}.Slot`,n}function SHe(e){const t=m.forwardRef((n,o)=>{const{children:r,...a}=n;if(m.isValidElement(r)){const i=AHe(r),s=NHe(a,r.props);return r.type!==m.Fragment&&(s.ref=o?Dr(o,i):i),m.cloneElement(r,s)}return m.Children.count(r)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var fJ=Symbol("radix.slottable");function LHe(e){const t=({children:n})=>p.jsx(p.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=fJ,t}function IHe(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===fJ}function NHe(e,t){const n={...t};for(const o in t){const r=e[o],a=t[o];/^on[A-Z]/.test(o)?r&&a?n[o]=(...s)=>{const c=a(...s);return r(...s),c}:r&&(n[o]=r):o==="style"?n[o]={...r,...a}:o==="className"&&(n[o]=[r,a].filter(Boolean).join(" "))}return{...e,...n}}function AHe(e){var o,r;let t=(o=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(r=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var EHe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],We=EHe.reduce((e,t)=>{const n=C0(`Primitive.${t}`),o=m.forwardRef((r,a)=>{const{asChild:i,...s}=r,c=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),p.jsx(c,{...s,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function pJ(e,t){e&&P0.flushSync(()=>e.dispatchEvent(t))}function zq(e){const t=e+"CollectionProvider",[n,o]=Qo(t),[r,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=k=>{const{scope:x,children:v}=k,M=br.useRef(null),w=br.useRef(new Map).current;return p.jsx(r,{scope:x,itemMap:w,collectionRef:M,children:v})};i.displayName=t;const s=e+"CollectionSlot",c=C0(s),l=br.forwardRef((k,x)=>{const{scope:v,children:M}=k,w=a(s,v),b=gt(x,w.collectionRef);return p.jsx(c,{ref:b,children:M})});l.displayName=s;const h=e+"CollectionItemSlot",u="data-radix-collection-item",f=C0(h),y=br.forwardRef((k,x)=>{const{scope:v,children:M,...w}=k,b=br.useRef(null),C=gt(x,b),_=a(h,v);return br.useEffect(()=>(_.itemMap.set(b,{ref:b,...w}),()=>void _.itemMap.delete(b))),p.jsx(f,{[u]:"",ref:C,children:M})});y.displayName=h;function g(k){const x=a(e+"CollectionConsumer",k);return br.useCallback(()=>{const M=x.collectionRef.current;if(!M)return[];const w=Array.from(M.querySelectorAll(`[${u}]`));return Array.from(x.itemMap.values()).sort((_,S)=>w.indexOf(_.ref.current)-w.indexOf(S.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:l,ItemSlot:y},g,o]}var yJ=["PageUp","PageDown"],mJ=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],gJ={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},D0="Slider",[PH,$He,jHe]=zq(D0),[kJ]=Qo(D0,[jHe]),[PHe,Zz]=kJ(D0),vJ=m.forwardRef((e,t)=>{const{name:n,min:o=0,max:r=100,step:a=1,orientation:i="horizontal",disabled:s=!1,minStepsBetweenThumbs:c=0,defaultValue:l=[o],value:h,onValueChange:u=()=>{},onValueCommit:f=()=>{},inverted:y=!1,form:g,...k}=e,x=m.useRef(new Set),v=m.useRef(0),w=i==="horizontal"?zHe:RHe,[b=[],C]=Td({prop:h,defaultProp:l,onChange:N=>{var W;(W=[...x.current][v.current])==null||W.focus(),u(N)}}),_=m.useRef(b);function S(N){const R=qHe(b,N);A(N,R)}function j(N){A(N,v.current)}function P(){const N=_.current[v.current];b[v.current]!==N&&f(b)}function A(N,R,{commit:W}={commit:!1}){const $=UHe(a),H=WHe(Math.round((N-o)/a)*a+o,$),T=uJ(H,[o,r]);C((O=[])=>{const I=HHe(O,T,R);if(BHe(I,c*a)){v.current=I.indexOf(T);const z=String(I)!==String(O);return z&&W&&f(I),z?I:O}else return O})}return p.jsx(PHe,{scope:e.__scopeSlider,name:n,disabled:s,min:o,max:r,valueIndexToChangeRef:v,thumbs:x.current,values:b,orientation:i,form:g,children:p.jsx(PH.Provider,{scope:e.__scopeSlider,children:p.jsx(PH.Slot,{scope:e.__scopeSlider,children:p.jsx(w,{"aria-disabled":s,"data-disabled":s?"":void 0,...k,ref:t,onPointerDown:Ie(k.onPointerDown,()=>{s||(_.current=b)}),min:o,max:r,inverted:y,onSlideStart:s?void 0:S,onSlideMove:s?void 0:j,onSlideEnd:s?void 0:P,onHomeKeyDown:()=>!s&&A(o,0,{commit:!0}),onEndKeyDown:()=>!s&&A(r,b.length-1,{commit:!0}),onStepKeyDown:({event:N,direction:R})=>{if(!s){const H=yJ.includes(N.key)||N.shiftKey&&mJ.includes(N.key)?10:1,T=v.current,O=b[T],I=a*H*R;A(O+I,T,{commit:!0})}}})})})})});vJ.displayName=D0;var[xJ,wJ]=kJ(D0,{startEdge:"left",endEdge:"right",size:"width",direction:1}),zHe=m.forwardRef((e,t)=>{const{min:n,max:o,dir:r,inverted:a,onSlideStart:i,onSlideMove:s,onSlideEnd:c,onStepKeyDown:l,...h}=e,[u,f]=m.useState(null),y=gt(t,w=>f(w)),g=m.useRef(void 0),k=Gz(r),x=k==="ltr",v=x&&!a||!x&&a;function M(w){const b=g.current||u.getBoundingClientRect(),C=[0,b.width],S=Rq(C,v?[n,o]:[o,n]);return g.current=b,S(w-b.left)}return p.jsx(xJ,{scope:e.__scopeSlider,startEdge:v?"left":"right",endEdge:v?"right":"left",direction:v?1:-1,size:"width",children:p.jsx(MJ,{dir:k,"data-orientation":"horizontal",...h,ref:y,style:{...h.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:w=>{const b=M(w.clientX);i==null||i(b)},onSlideMove:w=>{const b=M(w.clientX);s==null||s(b)},onSlideEnd:()=>{g.current=void 0,c==null||c()},onStepKeyDown:w=>{const C=gJ[v?"from-left":"from-right"].includes(w.key);l==null||l({event:w,direction:C?-1:1})}})})}),RHe=m.forwardRef((e,t)=>{const{min:n,max:o,inverted:r,onSlideStart:a,onSlideMove:i,onSlideEnd:s,onStepKeyDown:c,...l}=e,h=m.useRef(null),u=gt(t,h),f=m.useRef(void 0),y=!r;function g(k){const x=f.current||h.current.getBoundingClientRect(),v=[0,x.height],w=Rq(v,y?[o,n]:[n,o]);return f.current=x,w(k-x.top)}return p.jsx(xJ,{scope:e.__scopeSlider,startEdge:y?"bottom":"top",endEdge:y?"top":"bottom",size:"height",direction:y?1:-1,children:p.jsx(MJ,{"data-orientation":"vertical",...l,ref:u,style:{...l.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:k=>{const x=g(k.clientY);a==null||a(x)},onSlideMove:k=>{const x=g(k.clientY);i==null||i(x)},onSlideEnd:()=>{f.current=void 0,s==null||s()},onStepKeyDown:k=>{const v=gJ[y?"from-bottom":"from-top"].includes(k.key);c==null||c({event:k,direction:v?-1:1})}})})}),MJ=m.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:o,onSlideMove:r,onSlideEnd:a,onHomeKeyDown:i,onEndKeyDown:s,onStepKeyDown:c,...l}=e,h=Zz(D0,n);return p.jsx(We.span,{...l,ref:t,onKeyDown:Ie(e.onKeyDown,u=>{u.key==="Home"?(i(u),u.preventDefault()):u.key==="End"?(s(u),u.preventDefault()):yJ.concat(mJ).includes(u.key)&&(c(u),u.preventDefault())}),onPointerDown:Ie(e.onPointerDown,u=>{const f=u.target;f.setPointerCapture(u.pointerId),u.preventDefault(),h.thumbs.has(f)?f.focus():o(u)}),onPointerMove:Ie(e.onPointerMove,u=>{u.target.hasPointerCapture(u.pointerId)&&r(u)}),onPointerUp:Ie(e.onPointerUp,u=>{const f=u.target;f.hasPointerCapture(u.pointerId)&&(f.releasePointerCapture(u.pointerId),a(u))})})}),bJ="SliderTrack",_J=m.forwardRef((e,t)=>{const{__scopeSlider:n,...o}=e,r=Zz(bJ,n);return p.jsx(We.span,{"data-disabled":r.disabled?"":void 0,"data-orientation":r.orientation,...o,ref:t})});_J.displayName=bJ;var zH="SliderRange",CJ=m.forwardRef((e,t)=>{const{__scopeSlider:n,...o}=e,r=Zz(zH,n),a=wJ(zH,n),i=m.useRef(null),s=gt(t,i),c=r.values.length,l=r.values.map(f=>IJ(f,r.min,r.max)),h=c>1?Math.min(...l):0,u=100-Math.max(...l);return p.jsx(We.span,{"data-orientation":r.orientation,"data-disabled":r.disabled?"":void 0,...o,ref:s,style:{...e.style,[a.startEdge]:h+"%",[a.endEdge]:u+"%"}})});CJ.displayName=zH;var RH="SliderThumb",SJ=m.forwardRef((e,t)=>{const n=$He(e.__scopeSlider),[o,r]=m.useState(null),a=gt(t,s=>r(s)),i=m.useMemo(()=>o?n().findIndex(s=>s.ref.current===o):-1,[n,o]);return p.jsx(THe,{...e,ref:a,index:i})}),THe=m.forwardRef((e,t)=>{const{__scopeSlider:n,index:o,name:r,...a}=e,i=Zz(RH,n),s=wJ(RH,n),[c,l]=m.useState(null),h=gt(t,M=>l(M)),u=c?i.form||!!c.closest("form"):!0,f=hJ(c),y=i.values[o],g=y===void 0?0:IJ(y,i.min,i.max),k=OHe(o,i.values.length),x=f==null?void 0:f[s.size],v=x?FHe(x,g,s.direction):0;return m.useEffect(()=>{if(c)return i.thumbs.add(c),()=>{i.thumbs.delete(c)}},[c,i.thumbs]),p.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[s.startEdge]:`calc(${g}% + ${v}px)`},children:[p.jsx(PH.ItemSlot,{scope:e.__scopeSlider,children:p.jsx(We.span,{role:"slider","aria-label":e["aria-label"]||k,"aria-valuemin":i.min,"aria-valuenow":y,"aria-valuemax":i.max,"aria-orientation":i.orientation,"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,tabIndex:i.disabled?void 0:0,...a,ref:h,style:y===void 0?{display:"none"}:e.style,onFocus:Ie(e.onFocus,()=>{i.valueIndexToChangeRef.current=o})})}),u&&p.jsx(LJ,{name:r??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:y},o)]})});SJ.displayName=RH;var DHe="RadioBubbleInput",LJ=m.forwardRef(({__scopeSlider:e,value:t,...n},o)=>{const r=m.useRef(null),a=gt(r,o),i=CHe(t);return m.useEffect(()=>{const s=r.current;if(!s)return;const c=window.HTMLInputElement.prototype,h=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&h){const u=new Event("input",{bubbles:!0});h.call(s,t),s.dispatchEvent(u)}},[i,t]),p.jsx(We.input,{style:{display:"none"},...n,ref:a,defaultValue:t})});LJ.displayName=DHe;function HHe(e=[],t,n){const o=[...e];return o[n]=t,o.sort((r,a)=>r-a)}function IJ(e,t,n){const a=100/(n-t)*(e-t);return uJ(a,[0,100])}function OHe(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function qHe(e,t){if(e.length===1)return 0;const n=e.map(r=>Math.abs(r-t)),o=Math.min(...n);return n.indexOf(o)}function FHe(e,t,n){const o=e/2,a=Rq([0,50],[0,o]);return(o-a(t)*n)*n}function VHe(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function BHe(e,t){if(t>0){const n=VHe(e);return Math.min(...n)>=t}return!0}function Rq(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const o=(t[1]-t[0])/(e[1]-e[0]);return t[0]+o*(n-e[0])}}function UHe(e){return(String(e).split(".")[1]||"").length}function WHe(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var NJ=vJ,GHe=_J,ZHe=CJ,XHe=SJ;const Tq=m.forwardRef(({className:e,...t},n)=>p.jsxs(NJ,{ref:n,className:oe("sf:relative sf:flex sf:w-full sf:touch-none sf:select-none sf:items-center",e),...t,children:[p.jsx(GHe,{className:"sf:relative sf:h-1.5 sf:w-full sf:grow sf:overflow-hidden sf:rounded-full sf:bg-secondary",children:p.jsx(ZHe,{className:"sf:absolute sf:h-full sf:bg-primary"})}),p.jsx(XHe,{className:"sf:block sf:h-4 sf:w-4 sf:rounded-full sf:border sf:border-primary/60 sf:bg-background sf:shadow-sm sf:transition-colors sf:hover:border-primary sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:disabled:pointer-events-none sf:disabled:opacity-50"})]}));Tq.displayName=NJ.displayName;const KHe={1:"sf:text-2xl sf:font-semibold sf:tracking-tight",2:"sf:text-xl sf:font-semibold sf:tracking-tight",3:"sf:text-lg sf:font-semibold",4:"sf:text-base sf:font-semibold"};function YHe({text:e,level:t=2}){const n=`h${t}`;return p.jsx(n,{className:oe(KHe[t]),children:e})}const AJ=m.createContext({custom:{}});function QHe({value:e,children:t}){return p.jsx(AJ.Provider,{value:e,children:t})}function JHe(){return m.useContext(AJ)}function S0({name:e,as:t,size:n=16,fallback:o=xNe,...r}){const a=JHe(),i=t??(e?a.custom[e]:void 0)??(e?l0[e]:void 0)??l0[o];return i?p.jsx(i,{size:n,...r}):null}function eOe({name:e,size:t=16}){return p.jsx(S0,{name:e,size:t,"aria-hidden":!0})}function tOe(e){return e==null?"":typeof e=="string"||typeof e=="number"?e:typeof e=="object"?JSON.stringify(e):String(e)}function nOe({label:e,value:t}){return p.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-1",children:[p.jsx("span",{className:"sf:text-muted-foreground sf:text-xs sf:uppercase sf:tracking-wide",children:e}),p.jsx("span",{className:"sf:font-semibold sf:text-2xl sf:tabular-nums",children:tOe(t)})]})}function oOe(e){return e==null?"":typeof e=="string"||typeof e=="number"?String(e):JSON.stringify(e)}function rOe({columns:e=[],rows:t=[]}){return p.jsx("div",{className:"sf:w-full sf:overflow-x-auto",children:p.jsxs("table",{className:"sf:w-full sf:text-left sf:text-sm",children:[p.jsx("thead",{className:"sf:border-b sf:bg-muted/50",children:p.jsx("tr",{children:e.map(n=>p.jsx("th",{scope:"col",className:"sf:px-3 sf:py-2 sf:font-medium sf:text-muted-foreground",children:n.label},n.key))})}),p.jsx("tbody",{children:t.map((n,o)=>p.jsx("tr",{className:"sf:border-b last:sf:border-0",children:e.map(r=>p.jsx("td",{className:"sf:px-3 sf:py-2",children:oOe(n[r.key])},r.key))},o))})]})})}function aOe({text:e,muted:t}){return p.jsx("p",{className:oe("sf:text-sm",t&&"sf:text-muted-foreground"),children:e})}function iOe({title:e,children:t}){return p.jsxs("div",{className:"sf:bg-card sf:p-4 sf:text-card-foreground sf:shadow-sm",children:[e!==void 0?p.jsx("div",{className:"sf:mb-3 sf:font-semibold sf:text-base sf:leading-tight",children:e}):null,p.jsx("div",{className:"sf:flex sf:flex-col sf:gap-3",children:t})]})}function sOe({orientation:e="horizontal"}){return p.jsx("div",{"aria-orientation":e,className:oe("sf:bg-border",e==="horizontal"?"sf:h-px sf:w-full":"sf:h-full sf:w-px")})}function cOe({value:e,items:t,onChange:n,children:o}){const r=t??[];return p.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-2",children:[p.jsx("div",{className:"sf:inline-flex sf:h-9 sf:items-center sf:justify-start sf:rounded-md sf:bg-muted sf:p-1 sf:text-muted-foreground",children:r.map(a=>p.jsx("button",{type:"button","data-state":e===a.id?"active":"inactive",onClick:()=>n==null?void 0:n({value:a.id}),className:"sf:inline-flex sf:items-center sf:justify-center sf:whitespace-nowrap sf:rounded-sm sf:px-3 sf:py-1 sf:text-xs sf:font-medium sf:transition-all sf:data-[state=active]:bg-background sf:data-[state=active]:text-foreground sf:data-[state=active]:shadow-sm",children:a.label},a.id))}),o]})}function lOe({items:e}){const t=e??[];return p.jsx("div",{className:"sf:flex sf:flex-col sf:divide-y sf:rounded-md sf:border",children:t.map(n=>p.jsxs("details",{className:"sf:group sf:px-3 sf:py-2",children:[p.jsx("summary",{className:"sf:cursor-pointer sf:py-1 sf:font-medium sf:text-sm",children:n.title}),p.jsx("div",{className:"sf:py-2 sf:text-muted-foreground sf:text-sm",children:n.content})]},n.id))})}const nW={default:"sf:bg-primary sf:text-primary-foreground",secondary:"sf:bg-secondary sf:text-secondary-foreground",destructive:"sf:bg-destructive sf:text-destructive-foreground",outline:"sf:border sf:border-border sf:text-foreground"};function dOe({label:e,variant:t="default"}){return p.jsx("span",{className:oe("sf:inline-flex sf:items-center sf:rounded-full sf:px-2.5 sf:py-0.5 sf:font-medium sf:text-xs",nW[t]??nW.default),children:e})}function uOe({src:e,alt:t,fallback:n}){return e?p.jsx("img",{src:e,alt:t??"",className:"sf:inline-block sf:h-9 sf:w-9 sf:rounded-full sf:object-cover"}):p.jsx("span",{className:"sf:inline-flex sf:h-9 sf:w-9 sf:items-center sf:justify-center sf:rounded-full sf:bg-muted sf:font-medium sf:text-muted-foreground sf:text-sm",children:n??"?"})}function hOe({value:e=0}){const t=Math.max(0,Math.min(100,e));return p.jsx("div",{"aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,className:"sf:relative sf:h-2 sf:w-full sf:overflow-hidden sf:rounded-full sf:bg-secondary",children:p.jsx("div",{className:"sf:h-full sf:bg-primary sf:transition-all",style:{width:`${t}%`}})})}function fOe({width:e,height:t}){return p.jsx("div",{className:"sf:animate-pulse sf:rounded-md sf:bg-muted",style:{width:e??"100%",height:t??16}})}function pOe({text:e}){return p.jsx("span",{className:"sf:font-medium sf:text-sm sf:leading-none",children:e})}function yOe({label:e,variant:t="default",onClick:n,disabled:o}){return p.jsx(ut,{variant:t,disabled:o,onClick:()=>n==null?void 0:n(),children:e})}const Dq="sf:flex sf:h-9 sf:w-full sf:rounded-md sf:border sf:border-input sf:bg-background sf:px-3 sf:py-1 sf:text-sm sf:shadow-sm sf:transition-colors sf:placeholder:text-muted-foreground sf:focus-visible:outline-hidden sf:focus-visible:ring-1 sf:focus-visible:ring-ring sf:disabled:cursor-not-allowed sf:disabled:opacity-50";function mOe({value:e,placeholder:t,onChange:n}){return p.jsx("input",{type:"text",value:e??"",placeholder:t,onChange:o=>n==null?void 0:n({value:o.target.value}),className:Dq})}function gOe({checked:e,onChange:t,label:n}){return p.jsxs("label",{className:"sf:inline-flex sf:items-center sf:gap-2 sf:text-sm",children:[p.jsx("input",{type:"checkbox",checked:e??!1,onChange:o=>t==null?void 0:t({checked:o.target.checked}),className:"sf:h-4 sf:w-4 sf:rounded sf:border sf:border-input sf:accent-primary"}),n]})}function kOe({checked:e,onChange:t}){return p.jsx("button",{type:"button",role:"switch","aria-checked":e??!1,onClick:()=>t==null?void 0:t({checked:!(e??!1)}),className:oe("sf:relative sf:inline-flex sf:h-5 sf:w-9 sf:shrink-0 sf:cursor-pointer sf:items-center sf:rounded-full sf:border-2 sf:border-transparent sf:transition-colors",e?"sf:bg-primary":"sf:bg-input"),children:p.jsx("span",{className:oe("sf:pointer-events-none sf:block sf:h-4 sf:w-4 sf:rounded-full sf:bg-background sf:shadow-lg sf:ring-0 sf:transition-transform",e?"sf:translate-x-4":"sf:translate-x-0")})})}function vOe({value:e,items:t,onChange:n}){return p.jsx("select",{value:e??"",onChange:o=>n==null?void 0:n({value:o.target.value}),className:Dq,children:(t??[]).map(o=>p.jsx("option",{value:o.value,children:o.label},o.value))})}function xOe({value:e,placeholder:t,rows:n,onChange:o}){return p.jsx("textarea",{value:e??"",placeholder:t,rows:n,onChange:r=>o==null?void 0:o({value:r.target.value}),className:oe(Dq,"sf:min-h-16 sf:py-2")})}function wOe({value:e,min:t=0,max:n=100,step:o=1,onChange:r}){return p.jsx(Tq,{value:e===void 0?void 0:[e],min:t,max:n,step:o,onValueChange:a=>{const[i]=a;typeof i=="number"&&(r==null||r({value:i}))}})}const MOe=m.lazy(()=>hf(()=>import("./chart-BS3qBv6b.js"),__vite__mapDeps([0,1,2,3,4,5,6,7])));function bOe(e){return p.jsx(m.Suspense,{fallback:null,children:p.jsx(MOe,{...e})})}const _Oe=m.lazy(()=>hf(()=>import("./markdown-Bud9JO0j.js"),[]));function COe(e){return p.jsx(m.Suspense,{fallback:null,children:p.jsx(_Oe,{...e})})}const SOe=m.lazy(()=>hf(()=>import("./code-block-CLrCA7Xe.js"),[]));function LOe(e){return p.jsx(m.Suspense,{fallback:null,children:p.jsx(SOe,{...e})})}const EJ={Card:iOe,Separator:sOe,Tabs:cOe,Accordion:lOe,Badge:dOe,Avatar:uOe,Progress:hOe,Skeleton:fOe,Label:pOe,Heading:YHe,Text:aOe,Icon:eOe,Chart:bOe,Table:rOe,Metric:nOe,CodeBlock:LOe,Markdown:COe,Button:yOe,Input:mOe,Checkbox:gOe,Switch:kOe,Select:vOe,Textarea:xOe,Slider:wOe},oW=cJ.filter(e=>EJ[e]===void 0);if(oW.length>0)throw new Error(`componentRegistry is missing impls for: ${oW.join(", ")}. Every catalog entry in COMPONENT_NAMES must have a matching component impl.`);const IOe={components:EJ};function NOe(e,t){return t.kind==="set"?{...e,[t.path]:t.value}:{...e,...t.partial}}function $J(e){return e===null||typeof e!="object"?!1:"$state"in e||"$action"in e||"$param"in e||"$cond"in e}function Jj(e,t,n,o){if(!$J(e))return e;if(typeof e.$state=="string")return t[e.$state];if(typeof e.$action=="string"){const r=e.$action;return o.has(r)?a=>n(r,a):void 0}if("$cond"in e){const r=Jj(e.$cond,t,n,o);return Jj(r?e.$then:e.$else,t,n,o)}return e}function AOe(e,t,n,o){if(!e)return{};const r={};for(const[a,i]of Object.entries(e))r[a]=Jj(i,t,n,o);return r}function rW({spec:e,nodeId:t,apiBaseUrl:n="/api",projectSlug:o,flowSlug:r}){const[a,i]=m.useReducer(NOe,e.state??{}),s=new Set(Object.keys(e.actions??{})),c=m.useCallback(async(l,h)=>{var y;const u=(y=e.actions)==null?void 0:y[l];if(!u)return;if(u.kind==="set"){const g=EOe(u.value,h,a);i({kind:"set",path:u.path,value:g});return}if(!o||!r)return;const f=`${n}/projects/${encodeURIComponent(o)}/flows/${encodeURIComponent(r)}/nodes/${encodeURIComponent(t)}/actions/${encodeURIComponent(l)}`;try{const g=await fetch(f,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(h??{})});if(!g.ok){const x=await g.text();i({kind:"set",path:`/__errors/${l}`,value:x});return}const k=await g.json();k!==null&&typeof k=="object"&&i({kind:"merge",partial:k})}catch(g){i({kind:"set",path:`/__errors/${l}`,value:g instanceof Error?g.message:String(g)})}},[e.actions,o,r,n,t,a]);return jJ(e.root,e,a,c,s)}function EOe(e,t,n){return $J(e)?typeof e.$param=="string"?t!==null&&typeof t=="object"?t[e.$param]:void 0:typeof e.$state=="string"?n[e.$state]:e:e}function jJ(e,t,n,o,r){const a=t.elements[e];if(!a)return null;const i=IOe.components[a.type];if(!i)return null;const s=AOe(a.props,n,o,r),l=(a.children??[]).map(h=>p.jsx($Oe,{children:jJ(h,t,n,o,r)},h));return p.jsx(i,{...s,children:l.length>0?l:void 0})}function $Oe({children:e}){return e}function Hr(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var o;return(o=t.current)==null?void 0:o.call(t,...n)},[])}function jOe(e,t=globalThis==null?void 0:globalThis.document){const n=Hr(e);m.useEffect(()=>{const o=r=>{r.key==="Escape"&&n(r)};return t.addEventListener("keydown",o,{capture:!0}),()=>t.removeEventListener("keydown",o,{capture:!0})},[n,t])}var POe="DismissableLayer",TH="dismissableLayer.update",zOe="dismissableLayer.pointerDownOutside",ROe="dismissableLayer.focusOutside",aW,PJ=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ff=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:o,onPointerDownOutside:r,onFocusOutside:a,onInteractOutside:i,onDismiss:s,...c}=e,l=m.useContext(PJ),[h,u]=m.useState(null),f=(h==null?void 0:h.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=m.useState({}),g=gt(t,S=>u(S)),k=Array.from(l.layers),[x]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),v=k.indexOf(x),M=h?k.indexOf(h):-1,w=l.layersWithOutsidePointerEventsDisabled.size>0,b=M>=v,C=HOe(S=>{const j=S.target,P=[...l.branches].some(A=>A.contains(j));!b||P||(r==null||r(S),i==null||i(S),S.defaultPrevented||s==null||s())},f),_=OOe(S=>{const j=S.target;[...l.branches].some(A=>A.contains(j))||(a==null||a(S),i==null||i(S),S.defaultPrevented||s==null||s())},f);return jOe(S=>{M===l.layers.size-1&&(o==null||o(S),!S.defaultPrevented&&s&&(S.preventDefault(),s()))},f),m.useEffect(()=>{if(h)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(aW=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(h)),l.layers.add(h),iW(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=aW)}},[h,f,n,l]),m.useEffect(()=>()=>{h&&(l.layers.delete(h),l.layersWithOutsidePointerEventsDisabled.delete(h),iW())},[h,l]),m.useEffect(()=>{const S=()=>y({});return document.addEventListener(TH,S),()=>document.removeEventListener(TH,S)},[]),p.jsx(We.div,{...c,ref:g,style:{pointerEvents:w?b?"auto":"none":void 0,...e.style},onFocusCapture:Ie(e.onFocusCapture,_.onFocusCapture),onBlurCapture:Ie(e.onBlurCapture,_.onBlurCapture),onPointerDownCapture:Ie(e.onPointerDownCapture,C.onPointerDownCapture)})});ff.displayName=POe;var TOe="DismissableLayerBranch",DOe=m.forwardRef((e,t)=>{const n=m.useContext(PJ),o=m.useRef(null),r=gt(t,o);return m.useEffect(()=>{const a=o.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),p.jsx(We.div,{...e,ref:r})});DOe.displayName=TOe;function HOe(e,t=globalThis==null?void 0:globalThis.document){const n=Hr(e),o=m.useRef(!1),r=m.useRef(()=>{});return m.useEffect(()=>{const a=s=>{if(s.target&&!o.current){let c=function(){zJ(zOe,n,l,{discrete:!0})};const l={originalEvent:s};s.pointerType==="touch"?(t.removeEventListener("click",r.current),r.current=c,t.addEventListener("click",r.current,{once:!0})):c()}else t.removeEventListener("click",r.current);o.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",a),t.removeEventListener("click",r.current)}},[t,n]),{onPointerDownCapture:()=>o.current=!0}}function OOe(e,t=globalThis==null?void 0:globalThis.document){const n=Hr(e),o=m.useRef(!1);return m.useEffect(()=>{const r=a=>{a.target&&!o.current&&zJ(ROe,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",r),()=>t.removeEventListener("focusin",r)},[t,n]),{onFocusCapture:()=>o.current=!0,onBlurCapture:()=>o.current=!1}}function iW(){const e=new CustomEvent(TH);document.dispatchEvent(e)}function zJ(e,t,n,{discrete:o}){const r=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&r.addEventListener(e,t,{once:!0}),o?pJ(r,a):r.dispatchEvent(a)}var _T=0;function Hq(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??sW()),document.body.insertAdjacentElement("beforeend",e[1]??sW()),_T++,()=>{_T===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),_T--}},[])}function sW(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var CT="focusScope.autoFocusOnMount",ST="focusScope.autoFocusOnUnmount",cW={bubbles:!1,cancelable:!0},qOe="FocusScope",Xz=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:o=!1,onMountAutoFocus:r,onUnmountAutoFocus:a,...i}=e,[s,c]=m.useState(null),l=Hr(r),h=Hr(a),u=m.useRef(null),f=gt(t,k=>c(k)),y=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(o){let k=function(w){if(y.paused||!s)return;const b=w.target;s.contains(b)?u.current=b:Ka(u.current,{select:!0})},x=function(w){if(y.paused||!s)return;const b=w.relatedTarget;b!==null&&(s.contains(b)||Ka(u.current,{select:!0}))},v=function(w){if(document.activeElement===document.body)for(const C of w)C.removedNodes.length>0&&Ka(s)};document.addEventListener("focusin",k),document.addEventListener("focusout",x);const M=new MutationObserver(v);return s&&M.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",k),document.removeEventListener("focusout",x),M.disconnect()}}},[o,s,y.paused]),m.useEffect(()=>{if(s){dW.add(y);const k=document.activeElement;if(!s.contains(k)){const v=new CustomEvent(CT,cW);s.addEventListener(CT,l),s.dispatchEvent(v),v.defaultPrevented||(FOe(GOe(RJ(s)),{select:!0}),document.activeElement===k&&Ka(s))}return()=>{s.removeEventListener(CT,l),setTimeout(()=>{const v=new CustomEvent(ST,cW);s.addEventListener(ST,h),s.dispatchEvent(v),v.defaultPrevented||Ka(k??document.body,{select:!0}),s.removeEventListener(ST,h),dW.remove(y)},0)}}},[s,l,h,y]);const g=m.useCallback(k=>{if(!n&&!o||y.paused)return;const x=k.key==="Tab"&&!k.altKey&&!k.ctrlKey&&!k.metaKey,v=document.activeElement;if(x&&v){const M=k.currentTarget,[w,b]=VOe(M);w&&b?!k.shiftKey&&v===b?(k.preventDefault(),n&&Ka(w,{select:!0})):k.shiftKey&&v===w&&(k.preventDefault(),n&&Ka(b,{select:!0})):v===M&&k.preventDefault()}},[n,o,y.paused]);return p.jsx(We.div,{tabIndex:-1,...i,ref:f,onKeyDown:g})});Xz.displayName=qOe;function FOe(e,{select:t=!1}={}){const n=document.activeElement;for(const o of e)if(Ka(o,{select:t}),document.activeElement!==n)return}function VOe(e){const t=RJ(e),n=lW(t,e),o=lW(t.reverse(),e);return[n,o]}function RJ(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{const r=o.tagName==="INPUT"&&o.type==="hidden";return o.disabled||o.hidden||r?NodeFilter.FILTER_SKIP:o.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function lW(e,t){for(const n of e)if(!BOe(n,{upTo:t}))return n}function BOe(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function UOe(e){return e instanceof HTMLInputElement&&"select"in e}function Ka(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&UOe(e)&&t&&e.select()}}var dW=WOe();function WOe(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=uW(e,t),e.unshift(t)},remove(t){var n;e=uW(e,t),(n=e[0])==null||n.resume()}}}function uW(e,t){const n=[...e],o=n.indexOf(t);return o!==-1&&n.splice(o,1),n}function GOe(e){return e.filter(t=>t.tagName!=="A")}var ZOe=bO[" useId ".trim().toString()]||(()=>{}),XOe=0;function Ln(e){const[t,n]=m.useState(ZOe());return Si(()=>{n(o=>o??String(XOe++))},[e]),e||(t?`radix-${t}`:"")}const KOe=["top","right","bottom","left"],Li=Math.min,Jn=Math.max,YP=Math.round,pp=Math.floor,Pr=e=>({x:e,y:e}),YOe={left:"right",right:"left",bottom:"top",top:"bottom"};function DH(e,t,n){return Jn(e,Li(t,n))}function ba(e,t){return typeof e=="function"?e(t):e}function _a(e){return e.split("-")[0]}function H0(e){return e.split("-")[1]}function Oq(e){return e==="x"?"y":"x"}function qq(e){return e==="y"?"height":"width"}function Ir(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Fq(e){return Oq(Ir(e))}function QOe(e,t,n){n===void 0&&(n=!1);const o=H0(e),r=Fq(e),a=qq(r);let i=r==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=QP(i)),[i,QP(i)]}function JOe(e){const t=QP(e);return[HH(e),t,HH(t)]}function HH(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const hW=["left","right"],fW=["right","left"],eqe=["top","bottom"],tqe=["bottom","top"];function nqe(e,t,n){switch(e){case"top":case"bottom":return n?t?fW:hW:t?hW:fW;case"left":case"right":return t?eqe:tqe;default:return[]}}function oqe(e,t,n,o){const r=H0(e);let a=nqe(_a(e),n==="start",o);return r&&(a=a.map(i=>i+"-"+r),t&&(a=a.concat(a.map(HH)))),a}function QP(e){const t=_a(e);return YOe[t]+e.slice(t.length)}function rqe(e){return{top:0,right:0,bottom:0,left:0,...e}}function TJ(e){return typeof e!="number"?rqe(e):{top:e,right:e,bottom:e,left:e}}function JP(e){const{x:t,y:n,width:o,height:r}=e;return{width:o,height:r,top:n,left:t,right:t+o,bottom:n+r,x:t,y:n}}function pW(e,t,n){let{reference:o,floating:r}=e;const a=Ir(t),i=Fq(t),s=qq(i),c=_a(t),l=a==="y",h=o.x+o.width/2-r.width/2,u=o.y+o.height/2-r.height/2,f=o[s]/2-r[s]/2;let y;switch(c){case"top":y={x:h,y:o.y-r.height};break;case"bottom":y={x:h,y:o.y+o.height};break;case"right":y={x:o.x+o.width,y:u};break;case"left":y={x:o.x-r.width,y:u};break;default:y={x:o.x,y:o.y}}switch(H0(t)){case"start":y[i]-=f*(n&&l?-1:1);break;case"end":y[i]+=f*(n&&l?-1:1);break}return y}async function aqe(e,t){var n;t===void 0&&(t={});const{x:o,y:r,platform:a,rects:i,elements:s,strategy:c}=e,{boundary:l="clippingAncestors",rootBoundary:h="viewport",elementContext:u="floating",altBoundary:f=!1,padding:y=0}=ba(t,e),g=TJ(y),x=s[f?u==="floating"?"reference":"floating":u],v=JP(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(x)))==null||n?x:x.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(s.floating)),boundary:l,rootBoundary:h,strategy:c})),M=u==="floating"?{x:o,y:r,width:i.floating.width,height:i.floating.height}:i.reference,w=await(a.getOffsetParent==null?void 0:a.getOffsetParent(s.floating)),b=await(a.isElement==null?void 0:a.isElement(w))?await(a.getScale==null?void 0:a.getScale(w))||{x:1,y:1}:{x:1,y:1},C=JP(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:M,offsetParent:w,strategy:c}):M);return{top:(v.top-C.top+g.top)/b.y,bottom:(C.bottom-v.bottom+g.bottom)/b.y,left:(v.left-C.left+g.left)/b.x,right:(C.right-v.right+g.right)/b.x}}const iqe=50,sqe=async(e,t,n)=>{const{placement:o="bottom",strategy:r="absolute",middleware:a=[],platform:i}=n,s=i.detectOverflow?i:{...i,detectOverflow:aqe},c=await(i.isRTL==null?void 0:i.isRTL(t));let l=await i.getElementRects({reference:e,floating:t,strategy:r}),{x:h,y:u}=pW(l,o,c),f=o,y=0;const g={};for(let k=0;k<a.length;k++){const x=a[k];if(!x)continue;const{name:v,fn:M}=x,{x:w,y:b,data:C,reset:_}=await M({x:h,y:u,initialPlacement:o,placement:f,strategy:r,middlewareData:g,rects:l,platform:s,elements:{reference:e,floating:t}});h=w??h,u=b??u,g[v]={...g[v],...C},_&&y<iqe&&(y++,typeof _=="object"&&(_.placement&&(f=_.placement),_.rects&&(l=_.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:r}):_.rects),{x:h,y:u}=pW(l,f,c)),k=-1)}return{x:h,y:u,placement:f,strategy:r,middlewareData:g}},cqe=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:o,placement:r,rects:a,platform:i,elements:s,middlewareData:c}=t,{element:l,padding:h=0}=ba(e,t)||{};if(l==null)return{};const u=TJ(h),f={x:n,y:o},y=Fq(r),g=qq(y),k=await i.getDimensions(l),x=y==="y",v=x?"top":"left",M=x?"bottom":"right",w=x?"clientHeight":"clientWidth",b=a.reference[g]+a.reference[y]-f[y]-a.floating[g],C=f[y]-a.reference[y],_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l));let S=_?_[w]:0;(!S||!await(i.isElement==null?void 0:i.isElement(_)))&&(S=s.floating[w]||a.floating[g]);const j=b/2-C/2,P=S/2-k[g]/2-1,A=Li(u[v],P),N=Li(u[M],P),R=A,W=S-k[g]-N,$=S/2-k[g]/2+j,H=DH(R,$,W),T=!c.arrow&&H0(r)!=null&&$!==H&&a.reference[g]/2-($<R?A:N)-k[g]/2<0,O=T?$<R?$-R:$-W:0;return{[y]:f[y]+O,data:{[y]:H,centerOffset:$-H-O,...T&&{alignmentOffset:O}},reset:T}}}),lqe=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,o;const{placement:r,middlewareData:a,rects:i,initialPlacement:s,platform:c,elements:l}=t,{mainAxis:h=!0,crossAxis:u=!0,fallbackPlacements:f,fallbackStrategy:y="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:k=!0,...x}=ba(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const v=_a(r),M=Ir(s),w=_a(s)===s,b=await(c.isRTL==null?void 0:c.isRTL(l.floating)),C=f||(w||!k?[QP(s)]:JOe(s)),_=g!=="none";!f&&_&&C.push(...oqe(s,k,g,b));const S=[s,...C],j=await c.detectOverflow(t,x),P=[];let A=((o=a.flip)==null?void 0:o.overflows)||[];if(h&&P.push(j[v]),u){const $=QOe(r,i,b);P.push(j[$[0]],j[$[1]])}if(A=[...A,{placement:r,overflows:P}],!P.every($=>$<=0)){var N,R;const $=(((N=a.flip)==null?void 0:N.index)||0)+1,H=S[$];if(H&&(!(u==="alignment"?M!==Ir(H):!1)||A.every(I=>Ir(I.placement)===M?I.overflows[0]>0:!0)))return{data:{index:$,overflows:A},reset:{placement:H}};let T=(R=A.filter(O=>O.overflows[0]<=0).sort((O,I)=>O.overflows[1]-I.overflows[1])[0])==null?void 0:R.placement;if(!T)switch(y){case"bestFit":{var W;const O=(W=A.filter(I=>{if(_){const z=Ir(I.placement);return z===M||z==="y"}return!0}).map(I=>[I.placement,I.overflows.filter(z=>z>0).reduce((z,L)=>z+L,0)]).sort((I,z)=>I[1]-z[1])[0])==null?void 0:W[0];O&&(T=O);break}case"initialPlacement":T=s;break}if(r!==T)return{reset:{placement:T}}}return{}}}};function yW(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function mW(e){return KOe.some(t=>e[t]>=0)}const dqe=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:o}=t,{strategy:r="referenceHidden",...a}=ba(e,t);switch(r){case"referenceHidden":{const i=await o.detectOverflow(t,{...a,elementContext:"reference"}),s=yW(i,n.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:mW(s)}}}case"escaped":{const i=await o.detectOverflow(t,{...a,altBoundary:!0}),s=yW(i,n.floating);return{data:{escapedOffsets:s,escaped:mW(s)}}}default:return{}}}}},DJ=new Set(["left","top"]);async function uqe(e,t){const{placement:n,platform:o,elements:r}=e,a=await(o.isRTL==null?void 0:o.isRTL(r.floating)),i=_a(n),s=H0(n),c=Ir(n)==="y",l=DJ.has(i)?-1:1,h=a&&c?-1:1,u=ba(t,e);let{mainAxis:f,crossAxis:y,alignmentAxis:g}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return s&&typeof g=="number"&&(y=s==="end"?g*-1:g),c?{x:y*h,y:f*l}:{x:f*l,y:y*h}}const hqe=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,o;const{x:r,y:a,placement:i,middlewareData:s}=t,c=await uqe(t,e);return i===((n=s.offset)==null?void 0:n.placement)&&(o=s.arrow)!=null&&o.alignmentOffset?{}:{x:r+c.x,y:a+c.y,data:{...c,placement:i}}}}},fqe=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:o,placement:r,platform:a}=t,{mainAxis:i=!0,crossAxis:s=!1,limiter:c={fn:v=>{let{x:M,y:w}=v;return{x:M,y:w}}},...l}=ba(e,t),h={x:n,y:o},u=await a.detectOverflow(t,l),f=Ir(_a(r)),y=Oq(f);let g=h[y],k=h[f];if(i){const v=y==="y"?"top":"left",M=y==="y"?"bottom":"right",w=g+u[v],b=g-u[M];g=DH(w,g,b)}if(s){const v=f==="y"?"top":"left",M=f==="y"?"bottom":"right",w=k+u[v],b=k-u[M];k=DH(w,k,b)}const x=c.fn({...t,[y]:g,[f]:k});return{...x,data:{x:x.x-n,y:x.y-o,enabled:{[y]:i,[f]:s}}}}}},pqe=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:o,placement:r,rects:a,middlewareData:i}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=ba(e,t),h={x:n,y:o},u=Ir(r),f=Oq(u);let y=h[f],g=h[u];const k=ba(s,t),x=typeof k=="number"?{mainAxis:k,crossAxis:0}:{mainAxis:0,crossAxis:0,...k};if(c){const w=f==="y"?"height":"width",b=a.reference[f]-a.floating[w]+x.mainAxis,C=a.reference[f]+a.reference[w]-x.mainAxis;y<b?y=b:y>C&&(y=C)}if(l){var v,M;const w=f==="y"?"width":"height",b=DJ.has(_a(r)),C=a.reference[u]-a.floating[w]+(b&&((v=i.offset)==null?void 0:v[u])||0)+(b?0:x.crossAxis),_=a.reference[u]+a.reference[w]+(b?0:((M=i.offset)==null?void 0:M[u])||0)-(b?x.crossAxis:0);g<C?g=C:g>_&&(g=_)}return{[f]:y,[u]:g}}}},yqe=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,o;const{placement:r,rects:a,platform:i,elements:s}=t,{apply:c=()=>{},...l}=ba(e,t),h=await i.detectOverflow(t,l),u=_a(r),f=H0(r),y=Ir(r)==="y",{width:g,height:k}=a.floating;let x,v;u==="top"||u==="bottom"?(x=u,v=f===(await(i.isRTL==null?void 0:i.isRTL(s.floating))?"start":"end")?"left":"right"):(v=u,x=f==="end"?"top":"bottom");const M=k-h.top-h.bottom,w=g-h.left-h.right,b=Li(k-h[x],M),C=Li(g-h[v],w),_=!t.middlewareData.shift;let S=b,j=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(j=w),(o=t.middlewareData.shift)!=null&&o.enabled.y&&(S=M),_&&!f){const A=Jn(h.left,0),N=Jn(h.right,0),R=Jn(h.top,0),W=Jn(h.bottom,0);y?j=g-2*(A!==0||N!==0?A+N:Jn(h.left,h.right)):S=k-2*(R!==0||W!==0?R+W:Jn(h.top,h.bottom))}await c({...t,availableWidth:j,availableHeight:S});const P=await i.getDimensions(s.floating);return g!==P.width||k!==P.height?{reset:{rects:!0}}:{}}}};function Kz(){return typeof window<"u"}function O0(e){return HJ(e)?(e.nodeName||"").toLowerCase():"#document"}function ro(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function qr(e){var t;return(t=(HJ(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function HJ(e){return Kz()?e instanceof Node||e instanceof ro(e).Node:!1}function Xo(e){return Kz()?e instanceof Element||e instanceof ro(e).Element:!1}function Na(e){return Kz()?e instanceof HTMLElement||e instanceof ro(e).HTMLElement:!1}function gW(e){return!Kz()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ro(e).ShadowRoot}function pf(e){const{overflow:t,overflowX:n,overflowY:o,display:r}=Ko(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&r!=="inline"&&r!=="contents"}function mqe(e){return/^(table|td|th)$/.test(O0(e))}function Yz(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const gqe=/transform|translate|scale|rotate|perspective|filter/,kqe=/paint|layout|strict|content/,ns=e=>!!e&&e!=="none";let LT;function Vq(e){const t=Xo(e)?Ko(e):e;return ns(t.transform)||ns(t.translate)||ns(t.scale)||ns(t.rotate)||ns(t.perspective)||!Bq()&&(ns(t.backdropFilter)||ns(t.filter))||gqe.test(t.willChange||"")||kqe.test(t.contain||"")}function vqe(e){let t=Ii(e);for(;Na(t)&&!L0(t);){if(Vq(t))return t;if(Yz(t))return null;t=Ii(t)}return null}function Bq(){return LT==null&&(LT=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),LT}function L0(e){return/^(html|body|#document)$/.test(O0(e))}function Ko(e){return ro(e).getComputedStyle(e)}function Qz(e){return Xo(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ii(e){if(O0(e)==="html")return e;const t=e.assignedSlot||e.parentNode||gW(e)&&e.host||qr(e);return gW(t)?t.host:t}function OJ(e){const t=Ii(e);return L0(t)?e.ownerDocument?e.ownerDocument.body:e.body:Na(t)&&pf(t)?t:OJ(t)}function Vh(e,t,n){var o;t===void 0&&(t=[]),n===void 0&&(n=!0);const r=OJ(e),a=r===((o=e.ownerDocument)==null?void 0:o.body),i=ro(r);if(a){const s=OH(i);return t.concat(i,i.visualViewport||[],pf(r)?r:[],s&&n?Vh(s):[])}else return t.concat(r,Vh(r,[],n))}function OH(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function qJ(e){const t=Ko(e);let n=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const r=Na(e),a=r?e.offsetWidth:n,i=r?e.offsetHeight:o,s=YP(n)!==a||YP(o)!==i;return s&&(n=a,o=i),{width:n,height:o,$:s}}function Uq(e){return Xo(e)?e:e.contextElement}function Ju(e){const t=Uq(e);if(!Na(t))return Pr(1);const n=t.getBoundingClientRect(),{width:o,height:r,$:a}=qJ(t);let i=(a?YP(n.width):n.width)/o,s=(a?YP(n.height):n.height)/r;return(!i||!Number.isFinite(i))&&(i=1),(!s||!Number.isFinite(s))&&(s=1),{x:i,y:s}}const xqe=Pr(0);function FJ(e){const t=ro(e);return!Bq()||!t.visualViewport?xqe:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function wqe(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ro(e)?!1:t}function Ed(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);const r=e.getBoundingClientRect(),a=Uq(e);let i=Pr(1);t&&(o?Xo(o)&&(i=Ju(o)):i=Ju(e));const s=wqe(a,n,o)?FJ(a):Pr(0);let c=(r.left+s.x)/i.x,l=(r.top+s.y)/i.y,h=r.width/i.x,u=r.height/i.y;if(a){const f=ro(a),y=o&&Xo(o)?ro(o):o;let g=f,k=OH(g);for(;k&&o&&y!==g;){const x=Ju(k),v=k.getBoundingClientRect(),M=Ko(k),w=v.left+(k.clientLeft+parseFloat(M.paddingLeft))*x.x,b=v.top+(k.clientTop+parseFloat(M.paddingTop))*x.y;c*=x.x,l*=x.y,h*=x.x,u*=x.y,c+=w,l+=b,g=ro(k),k=OH(g)}}return JP({width:h,height:u,x:c,y:l})}function Jz(e,t){const n=Qz(e).scrollLeft;return t?t.left+n:Ed(qr(e)).left+n}function VJ(e,t){const n=e.getBoundingClientRect(),o=n.left+t.scrollLeft-Jz(e,n),r=n.top+t.scrollTop;return{x:o,y:r}}function Mqe(e){let{elements:t,rect:n,offsetParent:o,strategy:r}=e;const a=r==="fixed",i=qr(o),s=t?Yz(t.floating):!1;if(o===i||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Pr(1);const h=Pr(0),u=Na(o);if((u||!u&&!a)&&((O0(o)!=="body"||pf(i))&&(c=Qz(o)),u)){const y=Ed(o);l=Ju(o),h.x=y.x+o.clientLeft,h.y=y.y+o.clientTop}const f=i&&!u&&!a?VJ(i,c):Pr(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+h.x+f.x,y:n.y*l.y-c.scrollTop*l.y+h.y+f.y}}function bqe(e){return Array.from(e.getClientRects())}function _qe(e){const t=qr(e),n=Qz(e),o=e.ownerDocument.body,r=Jn(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),a=Jn(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight);let i=-n.scrollLeft+Jz(e);const s=-n.scrollTop;return Ko(o).direction==="rtl"&&(i+=Jn(t.clientWidth,o.clientWidth)-r),{width:r,height:a,x:i,y:s}}const kW=25;function Cqe(e,t){const n=ro(e),o=qr(e),r=n.visualViewport;let a=o.clientWidth,i=o.clientHeight,s=0,c=0;if(r){a=r.width,i=r.height;const h=Bq();(!h||h&&t==="fixed")&&(s=r.offsetLeft,c=r.offsetTop)}const l=Jz(o);if(l<=0){const h=o.ownerDocument,u=h.body,f=getComputedStyle(u),y=h.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,g=Math.abs(o.clientWidth-u.clientWidth-y);g<=kW&&(a-=g)}else l<=kW&&(a+=l);return{width:a,height:i,x:s,y:c}}function Sqe(e,t){const n=Ed(e,!0,t==="fixed"),o=n.top+e.clientTop,r=n.left+e.clientLeft,a=Na(e)?Ju(e):Pr(1),i=e.clientWidth*a.x,s=e.clientHeight*a.y,c=r*a.x,l=o*a.y;return{width:i,height:s,x:c,y:l}}function vW(e,t,n){let o;if(t==="viewport")o=Cqe(e,n);else if(t==="document")o=_qe(qr(e));else if(Xo(t))o=Sqe(t,n);else{const r=FJ(e);o={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return JP(o)}function BJ(e,t){const n=Ii(e);return n===t||!Xo(n)||L0(n)?!1:Ko(n).position==="fixed"||BJ(n,t)}function Lqe(e,t){const n=t.get(e);if(n)return n;let o=Vh(e,[],!1).filter(s=>Xo(s)&&O0(s)!=="body"),r=null;const a=Ko(e).position==="fixed";let i=a?Ii(e):e;for(;Xo(i)&&!L0(i);){const s=Ko(i),c=Vq(i);!c&&s.position==="fixed"&&(r=null),(a?!c&&!r:!c&&s.position==="static"&&!!r&&(r.position==="absolute"||r.position==="fixed")||pf(i)&&!c&&BJ(e,i))?o=o.filter(h=>h!==i):r=s,i=Ii(i)}return t.set(e,o),o}function Iqe(e){let{element:t,boundary:n,rootBoundary:o,strategy:r}=e;const i=[...n==="clippingAncestors"?Yz(t)?[]:Lqe(t,this._c):[].concat(n),o],s=vW(t,i[0],r);let c=s.top,l=s.right,h=s.bottom,u=s.left;for(let f=1;f<i.length;f++){const y=vW(t,i[f],r);c=Jn(y.top,c),l=Li(y.right,l),h=Li(y.bottom,h),u=Jn(y.left,u)}return{width:l-u,height:h-c,x:u,y:c}}function Nqe(e){const{width:t,height:n}=qJ(e);return{width:t,height:n}}function Aqe(e,t,n){const o=Na(t),r=qr(t),a=n==="fixed",i=Ed(e,!0,a,t);let s={scrollLeft:0,scrollTop:0};const c=Pr(0);function l(){c.x=Jz(r)}if(o||!o&&!a)if((O0(t)!=="body"||pf(r))&&(s=Qz(t)),o){const y=Ed(t,!0,a,t);c.x=y.x+t.clientLeft,c.y=y.y+t.clientTop}else r&&l();a&&!o&&r&&l();const h=r&&!o&&!a?VJ(r,s):Pr(0),u=i.left+s.scrollLeft-c.x-h.x,f=i.top+s.scrollTop-c.y-h.y;return{x:u,y:f,width:i.width,height:i.height}}function IT(e){return Ko(e).position==="static"}function xW(e,t){if(!Na(e)||Ko(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return qr(e)===n&&(n=n.ownerDocument.body),n}function UJ(e,t){const n=ro(e);if(Yz(e))return n;if(!Na(e)){let r=Ii(e);for(;r&&!L0(r);){if(Xo(r)&&!IT(r))return r;r=Ii(r)}return n}let o=xW(e,t);for(;o&&mqe(o)&&IT(o);)o=xW(o,t);return o&&L0(o)&&IT(o)&&!Vq(o)?n:o||vqe(e)||n}const Eqe=async function(e){const t=this.getOffsetParent||UJ,n=this.getDimensions,o=await n(e.floating);return{reference:Aqe(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function $qe(e){return Ko(e).direction==="rtl"}const jqe={convertOffsetParentRelativeRectToViewportRelativeRect:Mqe,getDocumentElement:qr,getClippingRect:Iqe,getOffsetParent:UJ,getElementRects:Eqe,getClientRects:bqe,getDimensions:Nqe,getScale:Ju,isElement:Xo,isRTL:$qe};function WJ(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Pqe(e,t){let n=null,o;const r=qr(e);function a(){var s;clearTimeout(o),(s=n)==null||s.disconnect(),n=null}function i(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();const l=e.getBoundingClientRect(),{left:h,top:u,width:f,height:y}=l;if(s||t(),!f||!y)return;const g=pp(u),k=pp(r.clientWidth-(h+f)),x=pp(r.clientHeight-(u+y)),v=pp(h),w={rootMargin:-g+"px "+-k+"px "+-x+"px "+-v+"px",threshold:Jn(0,Li(1,c))||1};let b=!0;function C(_){const S=_[0].intersectionRatio;if(S!==c){if(!b)return i();S?i(!1,S):o=setTimeout(()=>{i(!1,1e-7)},1e3)}S===1&&!WJ(l,e.getBoundingClientRect())&&i(),b=!1}try{n=new IntersectionObserver(C,{...w,root:r.ownerDocument})}catch{n=new IntersectionObserver(C,w)}n.observe(e)}return i(!0),a}function zqe(e,t,n,o){o===void 0&&(o={});const{ancestorScroll:r=!0,ancestorResize:a=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:s=typeof IntersectionObserver=="function",animationFrame:c=!1}=o,l=Uq(e),h=r||a?[...l?Vh(l):[],...t?Vh(t):[]]:[];h.forEach(v=>{r&&v.addEventListener("scroll",n,{passive:!0}),a&&v.addEventListener("resize",n)});const u=l&&s?Pqe(l,n):null;let f=-1,y=null;i&&(y=new ResizeObserver(v=>{let[M]=v;M&&M.target===l&&y&&t&&(y.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var w;(w=y)==null||w.observe(t)})),n()}),l&&!c&&y.observe(l),t&&y.observe(t));let g,k=c?Ed(e):null;c&&x();function x(){const v=Ed(e);k&&!WJ(k,v)&&n(),k=v,g=requestAnimationFrame(x)}return n(),()=>{var v;h.forEach(M=>{r&&M.removeEventListener("scroll",n),a&&M.removeEventListener("resize",n)}),u==null||u(),(v=y)==null||v.disconnect(),y=null,c&&cancelAnimationFrame(g)}}const Rqe=hqe,Tqe=fqe,Dqe=lqe,Hqe=yqe,Oqe=dqe,wW=cqe,qqe=pqe,Fqe=(e,t,n)=>{const o=new Map,r={platform:jqe,...n},a={...r.platform,_c:o};return sqe(e,t,{...r,platform:a})};var Vqe=typeof document<"u",Bqe=function(){},eP=Vqe?m.useLayoutEffect:Bqe;function ez(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,o,r;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(o=n;o--!==0;)if(!ez(e[o],t[o]))return!1;return!0}if(r=Object.keys(e),n=r.length,n!==Object.keys(t).length)return!1;for(o=n;o--!==0;)if(!{}.hasOwnProperty.call(t,r[o]))return!1;for(o=n;o--!==0;){const a=r[o];if(!(a==="_owner"&&e.$$typeof)&&!ez(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function GJ(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function MW(e,t){const n=GJ(e);return Math.round(t*n)/n}function NT(e){const t=m.useRef(e);return eP(()=>{t.current=e}),t}function Uqe(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:o=[],platform:r,elements:{reference:a,floating:i}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[h,u]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,y]=m.useState(o);ez(f,o)||y(o);const[g,k]=m.useState(null),[x,v]=m.useState(null),M=m.useCallback(I=>{I!==_.current&&(_.current=I,k(I))},[]),w=m.useCallback(I=>{I!==S.current&&(S.current=I,v(I))},[]),b=a||g,C=i||x,_=m.useRef(null),S=m.useRef(null),j=m.useRef(h),P=c!=null,A=NT(c),N=NT(r),R=NT(l),W=m.useCallback(()=>{if(!_.current||!S.current)return;const I={placement:t,strategy:n,middleware:f};N.current&&(I.platform=N.current),Fqe(_.current,S.current,I).then(z=>{const L={...z,isPositioned:R.current!==!1};$.current&&!ez(j.current,L)&&(j.current=L,P0.flushSync(()=>{u(L)}))})},[f,t,n,N,R]);eP(()=>{l===!1&&j.current.isPositioned&&(j.current.isPositioned=!1,u(I=>({...I,isPositioned:!1})))},[l]);const $=m.useRef(!1);eP(()=>($.current=!0,()=>{$.current=!1}),[]),eP(()=>{if(b&&(_.current=b),C&&(S.current=C),b&&C){if(A.current)return A.current(b,C,W);W()}},[b,C,W,A,P]);const H=m.useMemo(()=>({reference:_,floating:S,setReference:M,setFloating:w}),[M,w]),T=m.useMemo(()=>({reference:b,floating:C}),[b,C]),O=m.useMemo(()=>{const I={position:n,left:0,top:0};if(!T.floating)return I;const z=MW(T.floating,h.x),L=MW(T.floating,h.y);return s?{...I,transform:"translate("+z+"px, "+L+"px)",...GJ(T.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:z,top:L}},[n,s,T.floating,h.x,h.y]);return m.useMemo(()=>({...h,update:W,refs:H,elements:T,floatingStyles:O}),[h,W,H,T,O])}const Wqe=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:o,padding:r}=typeof e=="function"?e(n):e;return o&&t(o)?o.current!=null?wW({element:o.current,padding:r}).fn(n):{}:o?wW({element:o,padding:r}).fn(n):{}}}},Gqe=(e,t)=>{const n=Rqe(e);return{name:n.name,fn:n.fn,options:[e,t]}},Zqe=(e,t)=>{const n=Tqe(e);return{name:n.name,fn:n.fn,options:[e,t]}},Xqe=(e,t)=>({fn:qqe(e).fn,options:[e,t]}),Kqe=(e,t)=>{const n=Dqe(e);return{name:n.name,fn:n.fn,options:[e,t]}},Yqe=(e,t)=>{const n=Hqe(e);return{name:n.name,fn:n.fn,options:[e,t]}},Qqe=(e,t)=>{const n=Oqe(e);return{name:n.name,fn:n.fn,options:[e,t]}},Jqe=(e,t)=>{const n=Wqe(e);return{name:n.name,fn:n.fn,options:[e,t]}};var eFe="Arrow",ZJ=m.forwardRef((e,t)=>{const{children:n,width:o=10,height:r=5,...a}=e;return p.jsx(We.svg,{...a,ref:t,width:o,height:r,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:p.jsx("polygon",{points:"0,0 30,0 15,10"})})});ZJ.displayName=eFe;var tFe=ZJ,Wq="Popper",[XJ,q0]=Qo(Wq),[nFe,KJ]=XJ(Wq),YJ=e=>{const{__scopePopper:t,children:n}=e,[o,r]=m.useState(null);return p.jsx(nFe,{scope:t,anchor:o,onAnchorChange:r,children:n})};YJ.displayName=Wq;var QJ="PopperAnchor",JJ=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:o,...r}=e,a=KJ(QJ,n),i=m.useRef(null),s=gt(t,i),c=m.useRef(null);return m.useEffect(()=>{const l=c.current;c.current=(o==null?void 0:o.current)||i.current,l!==c.current&&a.onAnchorChange(c.current)}),o?null:p.jsx(We.div,{...r,ref:s})});JJ.displayName=QJ;var Gq="PopperContent",[oFe,rFe]=XJ(Gq),eee=m.forwardRef((e,t)=>{var Q,te,ne,ie,ke,ge;const{__scopePopper:n,side:o="bottom",sideOffset:r=0,align:a="center",alignOffset:i=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:h=0,sticky:u="partial",hideWhenDetached:f=!1,updatePositionStrategy:y="optimized",onPlaced:g,...k}=e,x=KJ(Gq,n),[v,M]=m.useState(null),w=gt(t,ve=>M(ve)),[b,C]=m.useState(null),_=hJ(b),S=(_==null?void 0:_.width)??0,j=(_==null?void 0:_.height)??0,P=o+(a!=="center"?"-"+a:""),A=typeof h=="number"?h:{top:0,right:0,bottom:0,left:0,...h},N=Array.isArray(l)?l:[l],R=N.length>0,W={padding:A,boundary:N.filter(iFe),altBoundary:R},{refs:$,floatingStyles:H,placement:T,isPositioned:O,middlewareData:I}=Uqe({strategy:"fixed",placement:P,whileElementsMounted:(...ve)=>zqe(...ve,{animationFrame:y==="always"}),elements:{reference:x.anchor},middleware:[Gqe({mainAxis:r+j,alignmentAxis:i}),c&&Zqe({mainAxis:!0,crossAxis:!1,limiter:u==="partial"?Xqe():void 0,...W}),c&&Kqe({...W}),Yqe({...W,apply:({elements:ve,rects:ce,availableWidth:Ce,availableHeight:Re})=>{const{width:st,height:Vt}=ce.reference,It=ve.floating.style;It.setProperty("--radix-popper-available-width",`${Ce}px`),It.setProperty("--radix-popper-available-height",`${Re}px`),It.setProperty("--radix-popper-anchor-width",`${st}px`),It.setProperty("--radix-popper-anchor-height",`${Vt}px`)}}),b&&Jqe({element:b,padding:s}),sFe({arrowWidth:S,arrowHeight:j}),f&&Qqe({strategy:"referenceHidden",...W})]}),[z,L]=oee(T),F=Hr(g);Si(()=>{O&&(F==null||F())},[O,F]);const D=(Q=I.arrow)==null?void 0:Q.x,E=(te=I.arrow)==null?void 0:te.y,K=((ne=I.arrow)==null?void 0:ne.centerOffset)!==0,[X,Y]=m.useState();return Si(()=>{v&&Y(window.getComputedStyle(v).zIndex)},[v]),p.jsx("div",{ref:$.setFloating,"data-radix-popper-content-wrapper":"",style:{...H,transform:O?H.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:X,"--radix-popper-transform-origin":[(ie=I.transformOrigin)==null?void 0:ie.x,(ke=I.transformOrigin)==null?void 0:ke.y].join(" "),...((ge=I.hide)==null?void 0:ge.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:p.jsx(oFe,{scope:n,placedSide:z,onArrowChange:C,arrowX:D,arrowY:E,shouldHideArrow:K,children:p.jsx(We.div,{"data-side":z,"data-align":L,...k,ref:w,style:{...k.style,animation:O?void 0:"none"}})})})});eee.displayName=Gq;var tee="PopperArrow",aFe={top:"bottom",right:"left",bottom:"top",left:"right"},nee=m.forwardRef(function(t,n){const{__scopePopper:o,...r}=t,a=rFe(tee,o),i=aFe[a.placedSide];return p.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:p.jsx(tFe,{...r,ref:n,style:{...r.style,display:"block"}})})});nee.displayName=tee;function iFe(e){return e!==null}var sFe=e=>({name:"transformOrigin",options:e,fn(t){var x,v,M;const{placement:n,rects:o,middlewareData:r}=t,i=((x=r.arrow)==null?void 0:x.centerOffset)!==0,s=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[l,h]=oee(n),u={start:"0%",center:"50%",end:"100%"}[h],f=(((v=r.arrow)==null?void 0:v.x)??0)+s/2,y=(((M=r.arrow)==null?void 0:M.y)??0)+c/2;let g="",k="";return l==="bottom"?(g=i?u:`${f}px`,k=`${-c}px`):l==="top"?(g=i?u:`${f}px`,k=`${o.floating.height+c}px`):l==="right"?(g=`${-c}px`,k=i?u:`${y}px`):l==="left"&&(g=`${o.floating.width+c}px`,k=i?u:`${y}px`),{data:{x:g,y:k}}}});function oee(e){const[t,n="center"]=e.split("-");return[t,n]}var Zq=YJ,eR=JJ,Xq=eee,Kq=nee,cFe="Portal",yf=m.forwardRef((e,t)=>{var s;const{container:n,...o}=e,[r,a]=m.useState(!1);Si(()=>a(!0),[]);const i=n||r&&((s=globalThis==null?void 0:globalThis.document)==null?void 0:s.body);return i?ece.createPortal(p.jsx(We.div,{...o,ref:t}),i):null});yf.displayName=cFe;function lFe(e,t){return m.useReducer((n,o)=>t[n][o]??n,e)}var uo=e=>{const{present:t,children:n}=e,o=dFe(t),r=typeof n=="function"?n({present:o.isPresent}):m.Children.only(n),a=gt(o.ref,uFe(r));return typeof n=="function"||o.isPresent?m.cloneElement(r,{ref:a}):null};uo.displayName="Presence";function dFe(e){const[t,n]=m.useState(),o=m.useRef(null),r=m.useRef(e),a=m.useRef("none"),i=e?"mounted":"unmounted",[s,c]=lFe(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const l=yp(o.current);a.current=s==="mounted"?l:"none"},[s]),Si(()=>{const l=o.current,h=r.current;if(h!==e){const f=a.current,y=yp(l);e?c("MOUNT"):y==="none"||(l==null?void 0:l.display)==="none"?c("UNMOUNT"):c(h&&f!==y?"ANIMATION_OUT":"UNMOUNT"),r.current=e}},[e,c]),Si(()=>{if(t){let l;const h=t.ownerDocument.defaultView??window,u=y=>{const k=yp(o.current).includes(CSS.escape(y.animationName));if(y.target===t&&k&&(c("ANIMATION_END"),!r.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",l=h.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},f=y=>{y.target===t&&(a.current=yp(o.current))};return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",u),t.addEventListener("animationend",u),()=>{h.clearTimeout(l),t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",u),t.removeEventListener("animationend",u)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:m.useCallback(l=>{o.current=l?getComputedStyle(l):null,n(l)},[])}}function yp(e){return(e==null?void 0:e.animationName)||"none"}function uFe(e){var o,r;let t=(o=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(r=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var hFe=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},du=new WeakMap,mp=new WeakMap,gp={},AT=0,ree=function(e){return e&&(e.host||ree(e.parentNode))},fFe=function(e,t){return t.map(function(n){if(e.contains(n))return n;var o=ree(n);return o&&e.contains(o)?o:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},pFe=function(e,t,n,o){var r=fFe(t,Array.isArray(e)?e:[e]);gp[n]||(gp[n]=new WeakMap);var a=gp[n],i=[],s=new Set,c=new Set(r),l=function(u){!u||s.has(u)||(s.add(u),l(u.parentNode))};r.forEach(l);var h=function(u){!u||c.has(u)||Array.prototype.forEach.call(u.children,function(f){if(s.has(f))h(f);else try{var y=f.getAttribute(o),g=y!==null&&y!=="false",k=(du.get(f)||0)+1,x=(a.get(f)||0)+1;du.set(f,k),a.set(f,x),i.push(f),k===1&&g&&mp.set(f,!0),x===1&&f.setAttribute(n,"true"),g||f.setAttribute(o,"true")}catch(v){console.error("aria-hidden: cannot operate on ",f,v)}})};return h(t),s.clear(),AT++,function(){i.forEach(function(u){var f=du.get(u)-1,y=a.get(u)-1;du.set(u,f),a.set(u,y),f||(mp.has(u)||u.removeAttribute(o),mp.delete(u)),y||u.removeAttribute(n)}),AT--,AT||(du=new WeakMap,du=new WeakMap,mp=new WeakMap,gp={})}},Yq=function(e,t,n){n===void 0&&(n="data-aria-hidden");var o=Array.from(Array.isArray(e)?e:[e]),r=hFe(e);return r?(o.push.apply(o,Array.from(r.querySelectorAll("[aria-live], script"))),pFe(o,r,n,"aria-hidden")):function(){return null}},Sr=function(){return Sr=Object.assign||function(t){for(var n,o=1,r=arguments.length;o<r;o++){n=arguments[o];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},Sr.apply(this,arguments)};function aee(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]]);return n}function yFe(e,t,n){if(n||arguments.length===2)for(var o=0,r=t.length,a;o<r;o++)(a||!(o in t))&&(a||(a=Array.prototype.slice.call(t,0,o)),a[o]=t[o]);return e.concat(a||Array.prototype.slice.call(t))}var tP="right-scroll-bar-position",nP="width-before-scroll-bar",mFe="with-scroll-bars-hidden",gFe="--removed-body-scroll-bar-size";function ET(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function kFe(e,t){var n=m.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(o){var r=n.value;r!==o&&(n.value=o,n.callback(o,r))}}}})[0];return n.callback=t,n.facade}var vFe=typeof window<"u"?m.useLayoutEffect:m.useEffect,bW=new WeakMap;function xFe(e,t){var n=kFe(null,function(o){return e.forEach(function(r){return ET(r,o)})});return vFe(function(){var o=bW.get(n);if(o){var r=new Set(o),a=new Set(e),i=n.current;r.forEach(function(s){a.has(s)||ET(s,null)}),a.forEach(function(s){r.has(s)||ET(s,i)})}bW.set(n,e)},[e]),n}function wFe(e){return e}function MFe(e,t){t===void 0&&(t=wFe);var n=[],o=!1,r={read:function(){if(o)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(a){var i=t(a,o);return n.push(i),function(){n=n.filter(function(s){return s!==i})}},assignSyncMedium:function(a){for(o=!0;n.length;){var i=n;n=[],i.forEach(a)}n={push:function(s){return a(s)},filter:function(){return n}}},assignMedium:function(a){o=!0;var i=[];if(n.length){var s=n;n=[],s.forEach(a),i=n}var c=function(){var h=i;i=[],h.forEach(a)},l=function(){return Promise.resolve().then(c)};l(),n={push:function(h){i.push(h),l()},filter:function(h){return i=i.filter(h),n}}}};return r}function bFe(e){e===void 0&&(e={});var t=MFe(null);return t.options=Sr({async:!0,ssr:!1},e),t}var iee=function(e){var t=e.sideCar,n=aee(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var o=t.read();if(!o)throw new Error("Sidecar medium not found");return m.createElement(o,Sr({},n))};iee.isSideCarExport=!0;function _Fe(e,t){return e.useMedium(t),iee}var see=bFe(),$T=function(){},tR=m.forwardRef(function(e,t){var n=m.useRef(null),o=m.useState({onScrollCapture:$T,onWheelCapture:$T,onTouchMoveCapture:$T}),r=o[0],a=o[1],i=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,h=e.enabled,u=e.shards,f=e.sideCar,y=e.noRelative,g=e.noIsolation,k=e.inert,x=e.allowPinchZoom,v=e.as,M=v===void 0?"div":v,w=e.gapMode,b=aee(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=f,_=xFe([n,t]),S=Sr(Sr({},b),r);return m.createElement(m.Fragment,null,h&&m.createElement(C,{sideCar:see,removeScrollBar:l,shards:u,noRelative:y,noIsolation:g,inert:k,setCallbacks:a,allowPinchZoom:!!x,lockRef:n,gapMode:w}),i?m.cloneElement(m.Children.only(s),Sr(Sr({},S),{ref:_})):m.createElement(M,Sr({},S,{className:c,ref:_}),s))});tR.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};tR.classNames={fullWidth:nP,zeroRight:tP};var CFe=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function SFe(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=CFe();return t&&e.setAttribute("nonce",t),e}function LFe(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function IFe(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var NFe=function(){var e=0,t=null;return{add:function(n){e==0&&(t=SFe())&&(LFe(t,n),IFe(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},AFe=function(){var e=NFe();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},cee=function(){var e=AFe(),t=function(n){var o=n.styles,r=n.dynamic;return e(o,r),null};return t},EFe={left:0,top:0,right:0,gap:0},jT=function(e){return parseInt(e||"",10)||0},$Fe=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],o=t[e==="padding"?"paddingTop":"marginTop"],r=t[e==="padding"?"paddingRight":"marginRight"];return[jT(n),jT(o),jT(r)]},jFe=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return EFe;var t=$Fe(e),n=document.documentElement.clientWidth,o=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,o-n+t[2]-t[0])}},PFe=cee(),e0="data-scroll-locked",zFe=function(e,t,n,o){var r=e.left,a=e.top,i=e.right,s=e.gap;return n===void 0&&(n="margin"),`
|
|
8469
|
+
`);return}N.preventDefault(),M.current=!0,_();return}N.key==="Escape"&&(N.preventDefault(),M.current=!0,S())},P=N=>{N.preventDefault();const R=N.clipboardData.getData("text/plain");document.execCommand("insertText",!1,R)},A=()=>{if(M.current){M.current=!1;return}_()};return p.jsx("div",{ref:u,"data-testid":"inline-edit-input","data-field":i,"data-placeholder":l,role:"textbox",tabIndex:0,contentEditable:!0,suppressContentEditableWarning:!0,spellCheck:!1,onInput:C,onKeyDown:j,onPaste:P,onBlur:A,onMouseDown:N=>N.stopPropagation(),onClick:N=>N.stopPropagation(),onDoubleClick:N=>N.stopPropagation(),style:c,className:oe("nodrag nopan nowheel sf:block sf:w-full sf:bg-transparent sf:p-0 sf:text-inherit sf:outline-none","sf:whitespace-pre-wrap sf:wrap-break-word",g&&l?"inline-edit-empty":"",f?"inline-edit-shake":"",s)})}const KQ=8,LU=12,IU={height:`${KQ}px`,borderColor:"transparent"},NU={width:`${KQ}px`,borderColor:"transparent"},GTe={width:`${LU}px`,height:`${LU}px`,background:"transparent",border:"none"},ZTe={width:"calc(10px / var(--rf-zoom, 1))",height:"calc(10px / var(--rf-zoom, 1))",background:"hsl(var(--background))",border:"calc(1px / var(--rf-zoom, 1)) solid hsl(var(--primary) / 0.6)",borderRadius:"calc(2px / var(--rf-zoom, 1))",zIndex:1},XTe=[{position:"top",style:IU},{position:"bottom",style:IU},{position:"left",style:NU},{position:"right",style:NU}],KTe=["top-left","top-right","bottom-left","bottom-right"],AU={pointerEvents:"none",cursor:"default"};function R0({visible:e,minWidth:t=80,minHeight:n=40,onResizeStart:o,onResize:r,onResizeEnd:a,cornerVariant:i="invisible"}){const s=i==="visible"?ZTe:GTe,c=h=>e?h:{...h,...AU},l=e?s:{...s,opacity:0,...AU};return p.jsxs(p.Fragment,{children:[XTe.map(({position:h,style:u})=>p.jsx(CU,{position:h,variant:_i.Line,minWidth:t,minHeight:n,style:c(u),onResizeStart:o,onResize:r,onResizeEnd:a,children:p.jsx("span",{"data-testid":"resize-control","data-position":h})},h)),KTe.map(h=>p.jsx(CU,{position:h,variant:_i.Handle,minWidth:t,minHeight:n,style:l,autoScale:!1,onResizeStart:o,onResize:r,onResizeEnd:a,children:p.jsx("span",{"data-testid":"resize-control","data-position":h})},h))]})}function T0(e){const{onResize:t,onResizeEnd:n,onResizeFinal:o,setResizing:r}=e,[a,i]=m.useState(!1),s=m.useRef(null),c=m.useRef(t),l=m.useRef(n),h=m.useRef(o),u=m.useRef(r);m.useEffect(()=>{c.current=t},[t]),m.useEffect(()=>{l.current=n},[n]),m.useEffect(()=>{h.current=o},[o]),m.useEffect(()=>{u.current=r},[r]);const f=m.useCallback((k,x)=>{var v;i(!0),(v=u.current)==null||v.call(u,!0),s.current=x?{x:x.x,y:x.y,width:x.width,height:x.height}:null},[]),y=m.useCallback((k,x)=>{var v;(v=c.current)==null||v.call(c,{x:x.x,y:x.y,width:x.width,height:x.height})},[]),g=m.useCallback((k,x)=>{var M,w,b,C;i(!1),(M=u.current)==null||M.call(u,!1);const v=s.current;s.current=null,!(v&&v.width===x.width&&v.height===x.height)&&((w=c.current)==null||w.call(c,{x:x.x,y:x.y,width:x.width,height:x.height}),(b=l.current)==null||b.call(l,{x:x.x,y:x.y,width:x.width,height:x.height}),v&&((C=h.current)==null||C.call(h,{x:x.x,y:x.y,width:x.width,height:x.height},v)))},[]);return{isResizing:a,onResizeStart:f,onResizeEvent:y,onResizeEnd:g}}const v0={width:48,height:48},EU="help-circle",YTe=24,QTe=24,dp="sf:opacity-0 sf:transition-opacity";function JTe(e){return Pt(e,"text").color??"currentColor"}const $U=new Set;function eDe({id:e,data:t,selected:n,isConnectable:o}){const{onResizeStart:r,onResizeEvent:a,onResizeEnd:i}=T0({onResize:v=>{var M;return(M=t.onResize)==null?void 0:M.call(t,e,v)},onResizeEnd:v=>{var M;return(M=t.onResizeEnd)==null?void 0:M.call(t,e,v)},setResizing:t.setResizing}),s=t.width!==void 0||t.height!==void 0,c=!!t.onNameChange,[l,h]=m.useState(!1),u=l0[t.icon];!u&&!$U.has(t.icon)&&($U.add(t.icon),console.warn(`[iconNode] Unknown icon "${t.icon}"; falling back to "${EU}".`));const f=u??l0[EU],y=JTe(t.color),g=t.strokeWidth??2,k={...s?{}:{width:v0.width,height:v0.height}},x=v=>{!c||l||(v.stopPropagation(),h(!0))};return p.jsxs("div",{className:oe("sf:group sf:relative",s?"sf:h-full sf:w-full":""),style:k,"data-testid":"icon-node","data-node-type":"icon",onDoubleClick:x,children:[p.jsx(R0,{visible:!!n&&!!t.onResize&&!l,cornerVariant:"visible",minWidth:YTe,minHeight:QTe,onResizeStart:r,onResize:a,onResizeEnd:i}),p.jsx(ht,{type:"target",position:ye.Top,id:"t",isConnectable:o,className:oe(dp,n&&"sf:opacity-100!")}),p.jsx(ht,{type:"target",position:ye.Left,id:"l",isConnectable:o,className:oe(dp,n&&"sf:opacity-100!")}),f?p.jsx(f,{color:y,strokeWidth:g,absoluteStrokeWidth:!0,"aria-label":t.alt,className:"sf:block sf:h-full sf:w-full sf:pointer-events-none sf:select-none"}):null,l&&c?p.jsx("div",{className:"sf:absolute sf:left-0 sf:right-0 sf:top-full sf:mt-1 sf:text-center sf:text-xs sf:text-muted-foreground",children:p.jsx(li,{initialValue:t.name??"",field:"icon-node-label",onCommit:v=>{var M;return(M=t.onNameChange)==null?void 0:M.call(t,e,v)},onExit:()=>h(!1),placeholder:"Label"})}):t.name?p.jsx("span",{"data-testid":"icon-node-label",className:"sf:pointer-events-none sf:absolute sf:left-0 sf:right-0 sf:top-full sf:mt-1 sf:truncate sf:text-center sf:text-xs sf:text-muted-foreground sf:select-none",children:t.name}):null,p.jsx(ht,{type:"source",position:ye.Right,id:"r",isConnectable:o,className:oe(dp,n&&"sf:opacity-100!")}),p.jsx(ht,{type:"source",position:ye.Bottom,id:"b",isConnectable:o,className:oe(dp,n&&"sf:opacity-100!")})]})}function tDe(e,t){return e.selected===t.selected&&e.data===t.data&&e.width===t.width&&e.height===t.height}const nDe=m.memo(eDe,tDe);function oDe(e,t){const n=e.screenToFlowPosition({x:t.width/2,y:t.height/2});return{x:n.x-v0.width/2,y:n.y-v0.height/2}}const YQ="seeflow:icon-recents",rDe=16;function QQ(){if(typeof window>"u")return[];try{const e=window.localStorage.getItem(YQ);if(e===null)return[];const t=JSON.parse(e);return Array.isArray(t)?t.every(n=>typeof n=="string")?t:[]:[]}catch{return[]}}function aDe(e){if(!(typeof window>"u"))try{const n=QQ().filter(r=>r!==e),o=[e,...n].slice(0,rDe);window.localStorage.setItem(YQ,JSON.stringify(o))}catch{}}const iDe=typeof navigator<"u"&&typeof navigator.platform=="string"&&navigator.platform.toLowerCase().includes("mac"),sDe=e=>e.length===1?e.toUpperCase():e==="Escape"?"Esc":e,Dt=(e,t=iDe)=>{const n=sDe(e.key);if(t){let r="";return e.meta&&(r+="⌘"),e.alt&&(r+="⌥"),e.shift&&(r+="⇧"),`${r}${n}`}const o=[];return e.meta&&o.push("Ctrl"),e.shift&&o.push("Shift"),e.alt&&o.push("Alt"),o.push(n),o.join("+")},Eq=[{id:"tool.select",label:"Select tool",description:"Switch to the selection tool",category:"Tools",shortcut:Dt({key:"V"})},{id:"tool.hand",label:"Hand tool",description:"Pan the canvas; node interaction is suspended while armed",category:"Tools",shortcut:Dt({key:"H"})},{id:"tool.rectangle",label:"Rectangle",description:"Draw rectangle nodes",category:"Tools",shortcut:Dt({key:"R"})},{id:"tool.ellipse",label:"Ellipse",description:"Draw ellipse nodes",category:"Tools",shortcut:Dt({key:"O"})},{id:"tool.text",label:"Text",description:"Add a text node",category:"Tools",shortcut:Dt({key:"T"})},{id:"tool.sticky",label:"Sticky note",description:"Add a sticky note",category:"Tools",shortcut:Dt({key:"S"})},{id:"tool.database",label:"Database",description:"Add a database node",category:"Tools",shortcut:Dt({key:"D"})},{id:"tool.server",label:"Server",description:"Add a server node",category:"Tools"},{id:"tool.user",label:"User",description:"Add a user node",category:"Tools"},{id:"tool.queue",label:"Queue",description:"Add a queue node",category:"Tools"},{id:"tool.cloud",label:"Cloud",description:"Add a cloud node",category:"Tools"},{id:"tool.diamond",label:"Diamond",description:"Add a diamond node (decision / gateway)",category:"Tools"},{id:"tool.hexagon",label:"Hexagon",description:"Add a hexagon node (microservice)",category:"Tools"},{id:"edit.undo",label:"Undo",category:"Edit",shortcut:Dt({meta:!0,key:"Z"}),enabled:e=>e.canUndo},{id:"edit.redo",label:"Redo",category:"Edit",shortcut:Dt({meta:!0,shift:!0,key:"Z"}),enabled:e=>e.canRedo},{id:"edit.copy",label:"Copy",category:"Edit",shortcut:Dt({meta:!0,key:"C"}),enabled:e=>e.hasSelection},{id:"edit.paste",label:"Paste",category:"Edit",shortcut:Dt({meta:!0,key:"V"}),enabled:e=>e.hasClipboard},{id:"edit.duplicate",label:"Duplicate",category:"Edit",shortcut:Dt({meta:!0,key:"D"}),enabled:e=>e.hasSelection},{id:"edit.delete",label:"Delete",category:"Edit",shortcut:Dt({key:"Delete"}),enabled:e=>e.hasSelection},{id:"edit.selectAll",label:"Select all",category:"Edit",shortcut:Dt({meta:!0,key:"A"})},{id:"view.fit",label:"Fit view",description:"Fit everything in the viewport",category:"View",shortcut:Dt({meta:!0,key:"0"})},{id:"view.zoomIn",label:"Zoom in",category:"View",shortcut:Dt({meta:!0,key:"="})},{id:"view.zoomOut",label:"Zoom out",category:"View",shortcut:Dt({meta:!0,key:"-"})},{id:"view.zoom100",label:"Zoom to 100%",category:"View",shortcut:Dt({key:"1"})},{id:"view.zoomToSelection",label:"Zoom to selection",category:"View",shortcut:Dt({key:"F"}),enabled:e=>e.hasSelection},{id:"layout.tidy",label:"Tidy layout",description:"Auto-layout the canvas or current selection",category:"Layout",shortcut:Dt({meta:!0,shift:!0,key:"L"})},{id:"selection.deselect",label:"Deselect",description:"Clear selection and exit draw mode",category:"Selection",shortcut:Dt({key:"Escape"})},{id:"help.commandPalette",label:"Open command palette",category:"Help",shortcut:Dt({meta:!0,key:"P"})},{id:"export.pdf",label:"Export to PDF",description:"Download the current canvas as a PDF",category:"File",enabled:e=>e.canExportDemo},{id:"export.png",label:"Export as image",description:"Download the current canvas as a PNG",category:"File",enabled:e=>e.canExportDemo}],xT=e=>{const t=Eq.find(n=>n.id===e);return t?t.shortcut?`${t.label} (${t.shortcut})`:t.label:""},cDe=1,lDe=10,dDe=e=>{if(e.metaKey||e.ctrlKey||e.altKey)return null;const t=e.shiftKey?lDe:cDe;switch(e.key){case"ArrowLeft":return{dx:-t,dy:0};case"ArrowRight":return{dx:t,dy:0};case"ArrowUp":return{dx:0,dy:-t};case"ArrowDown":return{dx:0,dy:t};default:return null}},uDe=e=>{if(!(e.metaKey||e.ctrlKey)||e.altKey)return null;switch(e.key){case"0":return"fit";case"=":case"+":return"in";case"-":case"_":return"out";default:return null}},hDe=(e,t,n)=>{if(t.length===0)return[];const o=new Map(n.map(a=>[a.id,a])),r=[];for(const a of t){const i=o.get(a);i&&r.push({id:a,position:{x:i.position.x+e.dx,y:i.position.y+e.dy}})}return r},fDe=({event:e,isEditableActive:t,hasNodes:n,hasConnectors:o,selectedIds:r,hasClipboard:a})=>{if(!(e.metaKey||e.ctrlKey))return{type:"noop"};if(e.shiftKey||e.altKey)return{type:"noop"};const i=e.key.toLowerCase();return i!=="a"&&i!=="c"&&i!=="v"&&i!=="d"?{type:"noop"}:t?{type:"noop"}:i==="a"?!n&&!o?{type:"noop"}:{type:"selectAll"}:i==="c"?r.length===0?{type:"noop"}:{type:"copy",ids:r}:i==="d"?r.length===0?{type:"noop"}:{type:"duplicate",ids:r}:a?{type:"paste"}:{type:"noop"}},pDe=(e,t)=>{if(t.isEditableActive||!(e.metaKey||e.ctrlKey)||e.altKey)return null;const n=e.key.toLowerCase();return n==="z"?e.shiftKey?"redo":"undo":n==="y"&&!e.shiftKey?"redo":null},yDe=e=>{if(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return null;switch(e.key.toLowerCase()){case"v":return"select";case"h":return"hand";case"r":return"rectangle";case"o":return"ellipse";case"t":return"text";case"s":return"sticky";case"d":return"database";default:return null}},Xa="seeflow",JQ=e=>`${e}:last-used-style:v1`,wT=()=>({node:{},connector:{}}),MT=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),$q=e=>{var t;try{const n=(t=globalThis.localStorage)==null?void 0:t.getItem(JQ(e));if(!n)return wT();const o=JSON.parse(n);if(!MT(o))return wT();const r=MT(o.node)?o.node:{},a=MT(o.connector)?o.connector:{};return{node:r,connector:a}}catch{return wT()}},eJ=(e,t)=>{var n;try{(n=globalThis.localStorage)==null||n.setItem(JQ(e),JSON.stringify(t))}catch{}},_2=e=>$q(e),jU=(e,t)=>{const{alt:n,...o}=t,r={...o};r.borderSize!==void 0&&r.borderWidth===void 0?r.borderWidth=r.borderSize:r.borderWidth!==void 0&&r.borderSize===void 0&&(r.borderSize=r.borderWidth);const a=$q(e);eJ(e,{...a,node:{...a.node,...r}})},mDe=(e,t)=>{const n=$q(e);eJ(e,{...n,connector:{...n.connector,...t}})},jq=1,PU=17,_H=(e,t)=>{if(!e)return{};const n={};for(const o of t)e[o]!==void 0&&(n[o]=e[o]);return n},gDe=["borderColor","backgroundColor","borderSize","borderStyle","fontSize","cornerRadius","shadow"],kDe=["borderColor","backgroundColor","borderSize","borderStyle","fontSize","shadow"],vDe=["fontSize"],xDe=["borderColor","borderWidth","borderStyle","shadow"];function zU(e,t,n){if(e==="text")return{width:t.width,height:t.height,fontSize:PU,..._H(n,vDe)};const o=e==="ellipse"?kDe:gDe;return{width:t.width,height:t.height,borderSize:jq,fontSize:PU,..._H(n,o)}}function wDe(e,t,n){return{path:e,width:t.width,height:t.height,borderWidth:jq,..._H(n,xDe)}}const ko=async(e,t,n,o,r)=>{const a={method:t},i={...o??{}};r!==void 0&&(i["content-type"]="application/json",a.body=JSON.stringify(r)),Object.keys(i).length>0&&(a.headers=i);const s=await e(n,a);if(!s.ok){let c=null;try{c=await s.json()}catch{}throw new Error((c==null?void 0:c.error)??`${t} ${n} → ${s.status}`)}return await s.json()},MDe=e=>{const{baseUrl:t,project:n,flow:o}=e,r=e.fetch??globalThis.fetch.bind(globalThis),a=e.headers,i=`${t}/api/projects/${encodeURIComponent(n)}`,s=`${i}/flows/${encodeURIComponent(o)}`;return{async createNode(c){const l=await ko(r,"POST",`${s}/nodes`,a,c);return{id:l.id,node:l.node}},async updateNode(c,l){await ko(r,"PATCH",`${s}/nodes/${c}`,a,l)},async updateNodePosition(c,l){return await ko(r,"PATCH",`${s}/nodes/${c}/position`,a,l)},async deleteNode(c){await ko(r,"DELETE",`${s}/nodes/${c}`,a)},async reorderNode(c,l){await ko(r,"PATCH",`${s}/nodes/${c}/order`,a,l)},async createConnector(c){return{id:(await ko(r,"POST",`${s}/connectors`,a,c)).id}},async updateConnector(c,l){await ko(r,"PATCH",`${s}/connectors/${c}`,a,l)},async deleteConnector(c){await ko(r,"DELETE",`${s}/connectors/${c}`,a)},async uploadImage(c,l,h){const u=new FormData;u.append("file",l),u.append("filename",h);const f=`${s}/nodes/${encodeURIComponent(c)}/files/upload`,y={method:"POST",body:u};a&&(y.headers={...a});const g=await r(f,y);if(!g.ok){let k=null;try{k=await g.json()}catch{}throw new Error((k==null?void 0:k.error)??`POST ${f} → ${g.status}`)}return await g.json()},async playAction(c){return await ko(r,"POST",`${s}/play/${c}`,a,{})},async openFile(c){await ko(r,"POST",`${i}/files/open`,a,{path:c})},async revealFile(c){await ko(r,"POST",`${i}/files/reveal`,a,{path:c})},async computeLayout(c,l){const h=await ko(r,"POST",`${t}/api/layout`,a,{nodes:c,edges:l});return{nodes:h.nodes,connectors:h.connectors}}}},bDe=500,_De=500,CDe=2e3,SDe=(e,t)=>{if(!e&&!t)return;if(!e)return{...t};if(!t)return{...e};const n={...t};for(const[o,r]of Object.entries(e))n[o]=r;return n},RU=(e,t,n)=>{const o=Date.now(),r=bDe,a=_De,{stack:i,cursor:s}=e;if(t.coalesceKey&&s>0){const h=i[s-1];if(h&&h.coalesceKey===t.coalesceKey&&o-h.capturedAt<=a){const u=i.slice(0,s);return u[s-1]={...h,do:t.do,capturedAt:o,beforeFields:SDe(h.beforeFields,t.beforeFields)},{stack:u,cursor:s}}}const c=i.slice(0,s);c.push({...t,capturedAt:o});let l=s+1;for(;c.length>r;)c.shift(),l-=1;return l<0&&(l=0),{stack:c,cursor:l}},LDe=e=>e.cursor===0?{state:e,entry:void 0}:{state:{...e,cursor:e.cursor-1},entry:e.stack[e.cursor-1]},IDe=e=>e.cursor===e.stack.length?{state:e,entry:void 0}:{state:{...e,cursor:e.cursor+1},entry:e.stack[e.cursor]},tJ=()=>({stack:[],cursor:0}),TU=e=>e.cursor===e.stack.length?e:{stack:e.stack.slice(0,e.cursor),cursor:e.cursor},NDe=(e,t,n=Date.now(),o=CDe)=>n-t>o?tJ():e,ADe=new Set(["borderColor","backgroundColor","borderSize","borderWidth","borderStyle","fontSize","textAlign","cornerRadius","shadow","color","strokeWidth"]);function EDe(e,t){let n={stack:[],cursor:0},o=0;const r=new Set;let a=null;const i=()=>({canUndo:n.cursor>0,canRedo:n.cursor<n.stack.length}),s=()=>{const k=i();for(const x of r)x(k)},c=()=>{if(a){o=Date.now();return}const k=TU(n);o=Date.now(),k!==n&&(n=k,s())},l=k=>{if(a){a.ops.push({redo:k.do,undo:k.undo});return}n=RU(n,{...k,capturedAt:Date.now()}),s()},h={createNode:async k=>{c();const x=await e.createNode(k);return l({do:async()=>{await e.createNode({...k,id:x.id})},undo:async()=>{await e.deleteNode(x.id)}}),x},updateNode:async(k,x)=>{c();const{nodes:v}=t(),M=v.find(_=>_.id===k);if(!M){await e.updateNode(k,x);return}const w={},b=M.data??{};for(const _ of Object.keys(x))if(_==="position")w[_]=M.position;else if(_==="type")w[_]=M.type;else{const S=b[_];w[_]=S===void 0&&ADe.has(_)?null:S}await e.updateNode(k,x);const C=Object.keys(x).sort().join(",");l({do:async()=>{await e.updateNode(k,x)},undo:async()=>{await e.updateNode(k,w)},coalesceKey:`update:${k}:${C}`,beforeFields:w})},updateNodePosition:async(k,x)=>{c();const{nodes:v}=t(),M=v.find(C=>C.id===k),w=M==null?void 0:M.position,b=await e.updateNodePosition(k,x);return w&&l({do:async()=>{await e.updateNodePosition(k,x)},undo:async()=>{await e.updateNodePosition(k,w)},coalesceKey:`pos:${k}`}),b},deleteNode:async k=>{c();const{nodes:x,connectors:v}=t(),M=x.find(b=>b.id===k);if(!M){await e.deleteNode(k);return}const w=v.filter(b=>b.source===k||b.target===k);await e.deleteNode(k),l({do:async()=>{await e.deleteNode(k)},undo:async()=>{await e.createNode({id:M.id,type:M.type,position:M.position,data:M.data??{}});for(const b of w)try{await e.createConnector({id:b.id,source:b.source,target:b.target,sourceHandle:b.sourceHandle,targetHandle:b.targetHandle,sourceHandleAutoPicked:b.sourceHandleAutoPicked,targetHandleAutoPicked:b.targetHandleAutoPicked,sourcePin:b.sourcePin,targetPin:b.targetPin,label:b.label,style:b.style,color:b.color,direction:b.direction,eventName:b.eventName,queueName:b.queueName,method:b.method,url:b.url})}catch(C){console.warn(`[seeflow/canvas] failed to restore connector ${b.id} during deleteNode undo:`,C)}}})},reorderNode:async(k,x)=>{c();const{nodes:v}=t(),M=v.findIndex(w=>w.id===k);if(M<0){await e.reorderNode(k,x);return}await e.reorderNode(k,x),l({do:async()=>{await e.reorderNode(k,x)},undo:async()=>{await e.reorderNode(k,{op:"toIndex",index:M})}})},createConnector:async k=>{c();const x=await e.createConnector(k);return l({do:async()=>{await e.createConnector({...k,id:x.id})},undo:async()=>{await e.deleteConnector(x.id)}}),x},updateConnector:async(k,x)=>{c();const{connectors:v}=t(),M=v.find(_=>_.id===k);if(!M){await e.updateConnector(k,x);return}const w={},b=M;for(const _ of Object.keys(x))w[_]=b[_];await e.updateConnector(k,x);const C=Object.keys(x).sort().join(",");l({do:async()=>{await e.updateConnector(k,x)},undo:async()=>{await e.updateConnector(k,w)},coalesceKey:`update:conn:${k}:${C}`,beforeFields:w})},deleteConnector:async k=>{c();const{connectors:x}=t(),v=x.find(M=>M.id===k);if(!v){await e.deleteConnector(k);return}await e.deleteConnector(k),l({do:async()=>{await e.deleteConnector(k)},undo:async()=>{await e.createConnector({id:v.id,source:v.source,target:v.target,sourceHandle:v.sourceHandle,targetHandle:v.targetHandle,sourceHandleAutoPicked:v.sourceHandleAutoPicked,targetHandleAutoPicked:v.targetHandleAutoPicked,sourcePin:v.sourcePin,targetPin:v.targetPin,label:v.label,style:v.style,color:v.color,direction:v.direction,eventName:v.eventName,queueName:v.queueName,method:v.method,url:v.url})}})},uploadImage:(k,x,v)=>e.uploadImage(k,x,v),...e.playAction?{playAction:k=>e.playAction(k)}:{},...e.openFile?{openFile:k=>e.openFile(k)}:{},...e.revealFile?{revealFile:k=>e.revealFile(k)}:{},...e.computeLayout?{computeLayout:(k,x)=>e.computeLayout(k,x)}:{}};let u=Promise.resolve();const f=async()=>{const k=LDe(n);k.entry&&(n=k.state,s(),await k.entry.undo())},y=async()=>{const k=IDe(n);k.entry&&(n=k.state,s(),await k.entry.do())};return{adapter:h,history:{get canUndo(){return n.cursor>0},get canRedo(){return n.cursor<n.stack.length},undo:()=>{o=Date.now();const k=u.then(f);return u=k.then(()=>{},()=>{}),k},redo:()=>{o=Date.now();const k=u.then(y);return u=k.then(()=>{},()=>{}),k},clear:()=>{n=tJ(),s()},markExternalChange:()=>{const k=NDe(n,o);k!==n&&(n=k,s())},batch:async(k,x,v)=>{if(a)return x();const M=TU(n);o=Date.now(),M!==n&&(n=M,s());const w={name:k,ops:[]};a=w;try{const b=await x();if(a=null,w.ops.length>0){const C=w.ops.slice();n=RU(n,{do:async()=>{for(const _ of C)await _.redo()},undo:async()=>{for(let _=C.length-1;_>=0;_--)await C[_].undo()},coalesceKey:v==null?void 0:v.coalesceKey,capturedAt:Date.now()}),s()}return b}catch(b){a=null;for(let C=w.ops.length-1;C>=0;C--)try{await w.ops[C].undo()}catch(_){console.warn(`[seeflow/canvas] batch '${k}' rollback inverse rejected:`,_)}throw b}},subscribe:k=>(r.add(k),k(i()),()=>{r.delete(k)})}}}function nJ(e,t,n){let o=null,r=!1;const a=new ResizeObserver(()=>{r||(o!==null&&clearTimeout(o),o=setTimeout(()=>{o=null,!r&&n()},t))});return a.observe(e),()=>{r||(r=!0,o!==null&&(clearTimeout(o),o=null),a.disconnect())}}const $De="modulepreload",jDe=function(e){return"/"+e},DU={},hf=function(t,n,o){let r=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),s=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));r=Promise.allSettled(n.map(c=>{if(c=jDe(c),c in DU)return;DU[c]=!0;const l=c.endsWith(".css"),h=l?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${h}`))return;const u=document.createElement("link");if(u.rel=l?"stylesheet":$De,l||(u.as="script"),u.crossOrigin="",u.href=c,s&&u.setAttribute("nonce",s),document.head.appendChild(u),l)return new Promise((f,y)=>{u.addEventListener("load",f),u.addEventListener("error",()=>y(new Error(`Unable to preload CSS for ${c}`)))})}))}function a(i){const s=new Event("vite:preloadError",{cancelable:!0});if(s.payload=i,window.dispatchEvent(s),!s.defaultPrevented)throw i}return r.then(i=>{for(const s of i||[])s.status==="rejected"&&a(s.reason);return t().catch(a)})};var at;(function(e){e.assertEqual=r=>{};function t(r){}e.assertIs=t;function n(r){throw new Error}e.assertNever=n,e.arrayToEnum=r=>{const a={};for(const i of r)a[i]=i;return a},e.getValidEnumValues=r=>{const a=e.objectKeys(r).filter(s=>typeof r[r[s]]!="number"),i={};for(const s of a)i[s]=r[s];return e.objectValues(i)},e.objectValues=r=>e.objectKeys(r).map(function(a){return r[a]}),e.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const a=[];for(const i in r)Object.prototype.hasOwnProperty.call(r,i)&&a.push(i);return a},e.find=(r,a)=>{for(const i of r)if(a(i))return i},e.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function o(r,a=" | "){return r.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}e.joinValues=o,e.jsonStringifyReplacer=(r,a)=>typeof a=="bigint"?a.toString():a})(at||(at={}));var HU;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(HU||(HU={}));const Le=at.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),oi=e=>{switch(typeof e){case"undefined":return Le.undefined;case"string":return Le.string;case"number":return Number.isNaN(e)?Le.nan:Le.number;case"boolean":return Le.boolean;case"function":return Le.function;case"bigint":return Le.bigint;case"symbol":return Le.symbol;case"object":return Array.isArray(e)?Le.array:e===null?Le.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?Le.promise:typeof Map<"u"&&e instanceof Map?Le.map:typeof Set<"u"&&e instanceof Set?Le.set:typeof Date<"u"&&e instanceof Date?Le.date:Le.object;default:return Le.unknown}},me=at.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Ma extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=o=>{this.issues=[...this.issues,o]},this.addIssues=(o=[])=>{this.issues=[...this.issues,...o]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(a){return a.message},o={_errors:[]},r=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(r);else if(i.code==="invalid_return_type")r(i.returnTypeError);else if(i.code==="invalid_arguments")r(i.argumentsError);else if(i.path.length===0)o._errors.push(n(i));else{let s=o,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(s[l]=s[l]||{_errors:[]},s[l]._errors.push(n(i))):s[l]=s[l]||{_errors:[]},s=s[l],c++}}};return r(this),o}static assert(t){if(!(t instanceof Ma))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,at.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},o=[];for(const r of this.issues)if(r.path.length>0){const a=r.path[0];n[a]=n[a]||[],n[a].push(t(r))}else o.push(t(r));return{formErrors:o,fieldErrors:n}}get formErrors(){return this.flatten()}}Ma.create=e=>new Ma(e);const CH=(e,t)=>{let n;switch(e.code){case me.invalid_type:e.received===Le.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case me.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,at.jsonStringifyReplacer)}`;break;case me.unrecognized_keys:n=`Unrecognized key(s) in object: ${at.joinValues(e.keys,", ")}`;break;case me.invalid_union:n="Invalid input";break;case me.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${at.joinValues(e.options)}`;break;case me.invalid_enum_value:n=`Invalid enum value. Expected ${at.joinValues(e.options)}, received '${e.received}'`;break;case me.invalid_arguments:n="Invalid function arguments";break;case me.invalid_return_type:n="Invalid function return type";break;case me.invalid_date:n="Invalid date";break;case me.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:at.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case me.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case me.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case me.custom:n="Invalid input";break;case me.invalid_intersection_types:n="Intersection results could not be merged";break;case me.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case me.not_finite:n="Number must be finite";break;default:n=t.defaultError,at.assertNever(e)}return{message:n}};let PDe=CH;function zDe(){return PDe}const RDe=e=>{const{data:t,path:n,errorMaps:o,issueData:r}=e,a=[...n,...r.path||[]],i={...r,path:a};if(r.message!==void 0)return{...r,path:a,message:r.message};let s="";const c=o.filter(l=>!!l).slice().reverse();for(const l of c)s=l(i,{data:t,defaultError:s}).message;return{...r,path:a,message:s}};function be(e,t){const n=zDe(),o=RDe({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===CH?void 0:CH].filter(r=>!!r)});e.common.issues.push(o)}class In{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const o=[];for(const r of n){if(r.status==="aborted")return Ve;r.status==="dirty"&&t.dirty(),o.push(r.value)}return{status:t.value,value:o}}static async mergeObjectAsync(t,n){const o=[];for(const r of n){const a=await r.key,i=await r.value;o.push({key:a,value:i})}return In.mergeObjectSync(t,o)}static mergeObjectSync(t,n){const o={};for(const r of n){const{key:a,value:i}=r;if(a.status==="aborted"||i.status==="aborted")return Ve;a.status==="dirty"&&t.dirty(),i.status==="dirty"&&t.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||r.alwaysSet)&&(o[a.value]=i.value)}return{status:t.value,value:o}}}const Ve=Object.freeze({status:"aborted"}),C2=e=>({status:"dirty",value:e}),Io=e=>({status:"valid",value:e}),OU=e=>e.status==="aborted",qU=e=>e.status==="dirty",x0=e=>e.status==="valid",BP=e=>typeof Promise<"u"&&e instanceof Promise;var Ne;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(Ne||(Ne={}));class Tr{constructor(t,n,o,r){this._cachedPath=[],this.parent=t,this.data=n,this._path=o,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const FU=(e,t)=>{if(x0(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new Ma(e.common.issues);return this._error=n,this._error}}};function Xe(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:o,description:r}=e;if(t&&(n||o))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:r}:{errorMap:(i,s)=>{const{message:c}=e;return i.code==="invalid_enum_value"?{message:c??s.defaultError}:typeof s.data>"u"?{message:c??o??s.defaultError}:i.code!=="invalid_type"?{message:s.defaultError}:{message:c??n??s.defaultError}},description:r}}class Je{get description(){return this._def.description}_getType(t){return oi(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:oi(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new In,ctx:{common:t.parent.common,data:t.data,parsedType:oi(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(BP(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const o=this.safeParse(t,n);if(o.success)return o.data;throw o.error}safeParse(t,n){const o={common:{issues:[],async:(n==null?void 0:n.async)??!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:oi(t)},r=this._parseSync({data:t,path:o.path,parent:o});return FU(o,r)}"~validate"(t){var o,r;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:oi(t)};if(!this["~standard"].async)try{const a=this._parseSync({data:t,path:[],parent:n});return x0(a)?{value:a.value}:{issues:n.common.issues}}catch(a){(r=(o=a==null?void 0:a.message)==null?void 0:o.toLowerCase())!=null&&r.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(a=>x0(a)?{value:a.value}:{issues:n.common.issues})}async parseAsync(t,n){const o=await this.safeParseAsync(t,n);if(o.success)return o.data;throw o.error}async safeParseAsync(t,n){const o={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:oi(t)},r=this._parse({data:t,path:o.path,parent:o}),a=await(BP(r)?r:Promise.resolve(r));return FU(o,a)}refine(t,n){const o=r=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(r):n;return this._refinement((r,a)=>{const i=t(r),s=()=>a.addIssue({code:me.custom,...o(r)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(s(),!1)):i?!0:(s(),!1)})}refinement(t,n){return this._refinement((o,r)=>t(o)?!0:(r.addIssue(typeof n=="function"?n(o,r):n),!1))}_refinement(t){return new b0({schema:this,typeName:qe.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return xi.create(this,this._def)}nullable(){return _0.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return jr.create(this)}promise(){return XP.create(this,this._def)}or(t){return WP.create([this,t],this._def)}and(t){return GP.create(this,t,this._def)}transform(t){return new b0({...Xe(this._def),schema:this,typeName:qe.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new AH({...Xe(this._def),innerType:this,defaultValue:n,typeName:qe.ZodDefault})}brand(){return new aHe({typeName:qe.ZodBranded,type:this,...Xe(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new EH({...Xe(this._def),innerType:this,catchValue:n,typeName:qe.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return Pq.create(this,t)}readonly(){return $H.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const TDe=/^c[^\s-]{8,}$/i,DDe=/^[0-9a-z]+$/,HDe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ODe=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,qDe=/^[a-z0-9_-]{21}$/i,FDe=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,VDe=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,BDe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,UDe="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let bT;const WDe=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,GDe=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ZDe=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,XDe=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,KDe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,YDe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,oJ="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",QDe=new RegExp(`^${oJ}$`);function rJ(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function JDe(e){return new RegExp(`^${rJ(e)}$`)}function eHe(e){let t=`${oJ}T${rJ(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function tHe(e,t){return!!((t==="v4"||!t)&&WDe.test(e)||(t==="v6"||!t)&&ZDe.test(e))}function nHe(e,t){if(!FDe.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const o=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),r=JSON.parse(atob(o));return!(typeof r!="object"||r===null||"typ"in r&&(r==null?void 0:r.typ)!=="JWT"||!r.alg||t&&r.alg!==t)}catch{return!1}}function oHe(e,t){return!!((t==="v4"||!t)&&GDe.test(e)||(t==="v6"||!t)&&XDe.test(e))}class ya extends Je{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==Le.string){const a=this._getOrReturnCtx(t);return be(a,{code:me.invalid_type,expected:Le.string,received:a.parsedType}),Ve}const o=new In;let r;for(const a of this._def.checks)if(a.kind==="min")t.data.length<a.value&&(r=this._getOrReturnCtx(t,r),be(r,{code:me.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),o.dirty());else if(a.kind==="max")t.data.length>a.value&&(r=this._getOrReturnCtx(t,r),be(r,{code:me.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),o.dirty());else if(a.kind==="length"){const i=t.data.length>a.value,s=t.data.length<a.value;(i||s)&&(r=this._getOrReturnCtx(t,r),i?be(r,{code:me.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):s&&be(r,{code:me.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),o.dirty())}else if(a.kind==="email")BDe.test(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{validation:"email",code:me.invalid_string,message:a.message}),o.dirty());else if(a.kind==="emoji")bT||(bT=new RegExp(UDe,"u")),bT.test(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{validation:"emoji",code:me.invalid_string,message:a.message}),o.dirty());else if(a.kind==="uuid")ODe.test(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{validation:"uuid",code:me.invalid_string,message:a.message}),o.dirty());else if(a.kind==="nanoid")qDe.test(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{validation:"nanoid",code:me.invalid_string,message:a.message}),o.dirty());else if(a.kind==="cuid")TDe.test(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{validation:"cuid",code:me.invalid_string,message:a.message}),o.dirty());else if(a.kind==="cuid2")DDe.test(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{validation:"cuid2",code:me.invalid_string,message:a.message}),o.dirty());else if(a.kind==="ulid")HDe.test(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{validation:"ulid",code:me.invalid_string,message:a.message}),o.dirty());else if(a.kind==="url")try{new URL(t.data)}catch{r=this._getOrReturnCtx(t,r),be(r,{validation:"url",code:me.invalid_string,message:a.message}),o.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{validation:"regex",code:me.invalid_string,message:a.message}),o.dirty())):a.kind==="trim"?t.data=t.data.trim():a.kind==="includes"?t.data.includes(a.value,a.position)||(r=this._getOrReturnCtx(t,r),be(r,{code:me.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),o.dirty()):a.kind==="toLowerCase"?t.data=t.data.toLowerCase():a.kind==="toUpperCase"?t.data=t.data.toUpperCase():a.kind==="startsWith"?t.data.startsWith(a.value)||(r=this._getOrReturnCtx(t,r),be(r,{code:me.invalid_string,validation:{startsWith:a.value},message:a.message}),o.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(r=this._getOrReturnCtx(t,r),be(r,{code:me.invalid_string,validation:{endsWith:a.value},message:a.message}),o.dirty()):a.kind==="datetime"?eHe(a).test(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{code:me.invalid_string,validation:"datetime",message:a.message}),o.dirty()):a.kind==="date"?QDe.test(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{code:me.invalid_string,validation:"date",message:a.message}),o.dirty()):a.kind==="time"?JDe(a).test(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{code:me.invalid_string,validation:"time",message:a.message}),o.dirty()):a.kind==="duration"?VDe.test(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{validation:"duration",code:me.invalid_string,message:a.message}),o.dirty()):a.kind==="ip"?tHe(t.data,a.version)||(r=this._getOrReturnCtx(t,r),be(r,{validation:"ip",code:me.invalid_string,message:a.message}),o.dirty()):a.kind==="jwt"?nHe(t.data,a.alg)||(r=this._getOrReturnCtx(t,r),be(r,{validation:"jwt",code:me.invalid_string,message:a.message}),o.dirty()):a.kind==="cidr"?oHe(t.data,a.version)||(r=this._getOrReturnCtx(t,r),be(r,{validation:"cidr",code:me.invalid_string,message:a.message}),o.dirty()):a.kind==="base64"?KDe.test(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{validation:"base64",code:me.invalid_string,message:a.message}),o.dirty()):a.kind==="base64url"?YDe.test(t.data)||(r=this._getOrReturnCtx(t,r),be(r,{validation:"base64url",code:me.invalid_string,message:a.message}),o.dirty()):at.assertNever(a);return{status:o.value,value:t.data}}_regex(t,n,o){return this.refinement(r=>t.test(r),{validation:n,code:me.invalid_string,...Ne.errToObj(o)})}_addCheck(t){return new ya({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...Ne.errToObj(t)})}url(t){return this._addCheck({kind:"url",...Ne.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...Ne.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...Ne.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...Ne.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...Ne.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...Ne.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...Ne.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...Ne.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...Ne.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...Ne.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...Ne.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...Ne.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...Ne.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...Ne.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...Ne.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...Ne.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...Ne.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...Ne.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...Ne.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...Ne.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...Ne.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...Ne.errToObj(n)})}nonempty(t){return this.min(1,Ne.errToObj(t))}trim(){return new ya({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ya({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ya({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}ya.create=e=>new ya({checks:[],typeName:qe.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...Xe(e)});function rHe(e,t){const n=(e.toString().split(".")[1]||"").length,o=(t.toString().split(".")[1]||"").length,r=n>o?n:o,a=Number.parseInt(e.toFixed(r).replace(".","")),i=Number.parseInt(t.toFixed(r).replace(".",""));return a%i/10**r}class w0 extends Je{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==Le.number){const a=this._getOrReturnCtx(t);return be(a,{code:me.invalid_type,expected:Le.number,received:a.parsedType}),Ve}let o;const r=new In;for(const a of this._def.checks)a.kind==="int"?at.isInteger(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{code:me.invalid_type,expected:"integer",received:"float",message:a.message}),r.dirty()):a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(o=this._getOrReturnCtx(t,o),be(o,{code:me.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(o=this._getOrReturnCtx(t,o),be(o,{code:me.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="multipleOf"?rHe(t.data,a.value)!==0&&(o=this._getOrReturnCtx(t,o),be(o,{code:me.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(o=this._getOrReturnCtx(t,o),be(o,{code:me.not_finite,message:a.message}),r.dirty()):at.assertNever(a);return{status:r.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,Ne.toString(n))}gt(t,n){return this.setLimit("min",t,!1,Ne.toString(n))}lte(t,n){return this.setLimit("max",t,!0,Ne.toString(n))}lt(t,n){return this.setLimit("max",t,!1,Ne.toString(n))}setLimit(t,n,o,r){return new w0({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:o,message:Ne.toString(r)}]})}_addCheck(t){return new w0({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:Ne.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Ne.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Ne.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Ne.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Ne.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:Ne.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:Ne.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Ne.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Ne.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&at.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const o of this._def.checks){if(o.kind==="finite"||o.kind==="int"||o.kind==="multipleOf")return!0;o.kind==="min"?(n===null||o.value>n)&&(n=o.value):o.kind==="max"&&(t===null||o.value<t)&&(t=o.value)}return Number.isFinite(n)&&Number.isFinite(t)}}w0.create=e=>new w0({checks:[],typeName:qe.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...Xe(e)});class qh extends Je{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==Le.bigint)return this._getInvalidInput(t);let o;const r=new In;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(o=this._getOrReturnCtx(t,o),be(o,{code:me.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(o=this._getOrReturnCtx(t,o),be(o,{code:me.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="multipleOf"?t.data%a.value!==BigInt(0)&&(o=this._getOrReturnCtx(t,o),be(o,{code:me.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):at.assertNever(a);return{status:r.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return be(n,{code:me.invalid_type,expected:Le.bigint,received:n.parsedType}),Ve}gte(t,n){return this.setLimit("min",t,!0,Ne.toString(n))}gt(t,n){return this.setLimit("min",t,!1,Ne.toString(n))}lte(t,n){return this.setLimit("max",t,!0,Ne.toString(n))}lt(t,n){return this.setLimit("max",t,!1,Ne.toString(n))}setLimit(t,n,o,r){return new qh({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:o,message:Ne.toString(r)}]})}_addCheck(t){return new qh({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Ne.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Ne.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Ne.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Ne.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:Ne.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}qh.create=e=>new qh({checks:[],typeName:qe.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...Xe(e)});class SH extends Je{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==Le.boolean){const o=this._getOrReturnCtx(t);return be(o,{code:me.invalid_type,expected:Le.boolean,received:o.parsedType}),Ve}return Io(t.data)}}SH.create=e=>new SH({typeName:qe.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...Xe(e)});class UP extends Je{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==Le.date){const a=this._getOrReturnCtx(t);return be(a,{code:me.invalid_type,expected:Le.date,received:a.parsedType}),Ve}if(Number.isNaN(t.data.getTime())){const a=this._getOrReturnCtx(t);return be(a,{code:me.invalid_date}),Ve}const o=new In;let r;for(const a of this._def.checks)a.kind==="min"?t.data.getTime()<a.value&&(r=this._getOrReturnCtx(t,r),be(r,{code:me.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),o.dirty()):a.kind==="max"?t.data.getTime()>a.value&&(r=this._getOrReturnCtx(t,r),be(r,{code:me.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),o.dirty()):at.assertNever(a);return{status:o.value,value:new Date(t.data.getTime())}}_addCheck(t){return new UP({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:Ne.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:Ne.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}UP.create=e=>new UP({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:qe.ZodDate,...Xe(e)});class VU extends Je{_parse(t){if(this._getType(t)!==Le.symbol){const o=this._getOrReturnCtx(t);return be(o,{code:me.invalid_type,expected:Le.symbol,received:o.parsedType}),Ve}return Io(t.data)}}VU.create=e=>new VU({typeName:qe.ZodSymbol,...Xe(e)});class BU extends Je{_parse(t){if(this._getType(t)!==Le.undefined){const o=this._getOrReturnCtx(t);return be(o,{code:me.invalid_type,expected:Le.undefined,received:o.parsedType}),Ve}return Io(t.data)}}BU.create=e=>new BU({typeName:qe.ZodUndefined,...Xe(e)});class UU extends Je{_parse(t){if(this._getType(t)!==Le.null){const o=this._getOrReturnCtx(t);return be(o,{code:me.invalid_type,expected:Le.null,received:o.parsedType}),Ve}return Io(t.data)}}UU.create=e=>new UU({typeName:qe.ZodNull,...Xe(e)});class WU extends Je{constructor(){super(...arguments),this._any=!0}_parse(t){return Io(t.data)}}WU.create=e=>new WU({typeName:qe.ZodAny,...Xe(e)});class LH extends Je{constructor(){super(...arguments),this._unknown=!0}_parse(t){return Io(t.data)}}LH.create=e=>new LH({typeName:qe.ZodUnknown,...Xe(e)});class Ci extends Je{_parse(t){const n=this._getOrReturnCtx(t);return be(n,{code:me.invalid_type,expected:Le.never,received:n.parsedType}),Ve}}Ci.create=e=>new Ci({typeName:qe.ZodNever,...Xe(e)});class GU extends Je{_parse(t){if(this._getType(t)!==Le.undefined){const o=this._getOrReturnCtx(t);return be(o,{code:me.invalid_type,expected:Le.void,received:o.parsedType}),Ve}return Io(t.data)}}GU.create=e=>new GU({typeName:qe.ZodVoid,...Xe(e)});class jr extends Je{_parse(t){const{ctx:n,status:o}=this._processInputParams(t),r=this._def;if(n.parsedType!==Le.array)return be(n,{code:me.invalid_type,expected:Le.array,received:n.parsedType}),Ve;if(r.exactLength!==null){const i=n.data.length>r.exactLength.value,s=n.data.length<r.exactLength.value;(i||s)&&(be(n,{code:i?me.too_big:me.too_small,minimum:s?r.exactLength.value:void 0,maximum:i?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),o.dirty())}if(r.minLength!==null&&n.data.length<r.minLength.value&&(be(n,{code:me.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),o.dirty()),r.maxLength!==null&&n.data.length>r.maxLength.value&&(be(n,{code:me.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),o.dirty()),n.common.async)return Promise.all([...n.data].map((i,s)=>r.type._parseAsync(new Tr(n,i,n.path,s)))).then(i=>In.mergeArray(o,i));const a=[...n.data].map((i,s)=>r.type._parseSync(new Tr(n,i,n.path,s)));return In.mergeArray(o,a)}get element(){return this._def.type}min(t,n){return new jr({...this._def,minLength:{value:t,message:Ne.toString(n)}})}max(t,n){return new jr({...this._def,maxLength:{value:t,message:Ne.toString(n)}})}length(t,n){return new jr({...this._def,exactLength:{value:t,message:Ne.toString(n)}})}nonempty(t){return this.min(1,t)}}jr.create=(e,t)=>new jr({type:e,minLength:null,maxLength:null,exactLength:null,typeName:qe.ZodArray,...Xe(t)});function vu(e){if(e instanceof Zt){const t={};for(const n in e.shape){const o=e.shape[n];t[n]=xi.create(vu(o))}return new Zt({...e._def,shape:()=>t})}else return e instanceof jr?new jr({...e._def,type:vu(e.element)}):e instanceof xi?xi.create(vu(e.unwrap())):e instanceof _0?_0.create(vu(e.unwrap())):e instanceof Ad?Ad.create(e.items.map(t=>vu(t))):e}class Zt extends Je{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=at.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==Le.object){const l=this._getOrReturnCtx(t);return be(l,{code:me.invalid_type,expected:Le.object,received:l.parsedType}),Ve}const{status:o,ctx:r}=this._processInputParams(t),{shape:a,keys:i}=this._getCached(),s=[];if(!(this._def.catchall instanceof Ci&&this._def.unknownKeys==="strip"))for(const l in r.data)i.includes(l)||s.push(l);const c=[];for(const l of i){const h=a[l],u=r.data[l];c.push({key:{status:"valid",value:l},value:h._parse(new Tr(r,u,r.path,l)),alwaysSet:l in r.data})}if(this._def.catchall instanceof Ci){const l=this._def.unknownKeys;if(l==="passthrough")for(const h of s)c.push({key:{status:"valid",value:h},value:{status:"valid",value:r.data[h]}});else if(l==="strict")s.length>0&&(be(r,{code:me.unrecognized_keys,keys:s}),o.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const h of s){const u=r.data[h];c.push({key:{status:"valid",value:h},value:l._parse(new Tr(r,u,r.path,h)),alwaysSet:h in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const l=[];for(const h of c){const u=await h.key,f=await h.value;l.push({key:u,value:f,alwaysSet:h.alwaysSet})}return l}).then(l=>In.mergeObjectSync(o,l)):In.mergeObjectSync(o,c)}get shape(){return this._def.shape()}strict(t){return Ne.errToObj,new Zt({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,o)=>{var a,i;const r=((i=(a=this._def).errorMap)==null?void 0:i.call(a,n,o).message)??o.defaultError;return n.code==="unrecognized_keys"?{message:Ne.errToObj(t).message??r}:{message:r}}}:{}})}strip(){return new Zt({...this._def,unknownKeys:"strip"})}passthrough(){return new Zt({...this._def,unknownKeys:"passthrough"})}extend(t){return new Zt({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Zt({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:qe.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new Zt({...this._def,catchall:t})}pick(t){const n={};for(const o of at.objectKeys(t))t[o]&&this.shape[o]&&(n[o]=this.shape[o]);return new Zt({...this._def,shape:()=>n})}omit(t){const n={};for(const o of at.objectKeys(this.shape))t[o]||(n[o]=this.shape[o]);return new Zt({...this._def,shape:()=>n})}deepPartial(){return vu(this)}partial(t){const n={};for(const o of at.objectKeys(this.shape)){const r=this.shape[o];t&&!t[o]?n[o]=r:n[o]=r.optional()}return new Zt({...this._def,shape:()=>n})}required(t){const n={};for(const o of at.objectKeys(this.shape))if(t&&!t[o])n[o]=this.shape[o];else{let a=this.shape[o];for(;a instanceof xi;)a=a._def.innerType;n[o]=a}return new Zt({...this._def,shape:()=>n})}keyof(){return aJ(at.objectKeys(this.shape))}}Zt.create=(e,t)=>new Zt({shape:()=>e,unknownKeys:"strip",catchall:Ci.create(),typeName:qe.ZodObject,...Xe(t)});Zt.strictCreate=(e,t)=>new Zt({shape:()=>e,unknownKeys:"strict",catchall:Ci.create(),typeName:qe.ZodObject,...Xe(t)});Zt.lazycreate=(e,t)=>new Zt({shape:e,unknownKeys:"strip",catchall:Ci.create(),typeName:qe.ZodObject,...Xe(t)});class WP extends Je{_parse(t){const{ctx:n}=this._processInputParams(t),o=this._def.options;function r(a){for(const s of a)if(s.result.status==="valid")return s.result;for(const s of a)if(s.result.status==="dirty")return n.common.issues.push(...s.ctx.common.issues),s.result;const i=a.map(s=>new Ma(s.ctx.common.issues));return be(n,{code:me.invalid_union,unionErrors:i}),Ve}if(n.common.async)return Promise.all(o.map(async a=>{const i={...n,common:{...n.common,issues:[]},parent:null};return{result:await a._parseAsync({data:n.data,path:n.path,parent:i}),ctx:i}})).then(r);{let a;const i=[];for(const c of o){const l={...n,common:{...n.common,issues:[]},parent:null},h=c._parseSync({data:n.data,path:n.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return n.common.issues.push(...a.ctx.common.issues),a.result;const s=i.map(c=>new Ma(c));return be(n,{code:me.invalid_union,unionErrors:s}),Ve}}get options(){return this._def.options}}WP.create=(e,t)=>new WP({options:e,typeName:qe.ZodUnion,...Xe(t)});function IH(e,t){const n=oi(e),o=oi(t);if(e===t)return{valid:!0,data:e};if(n===Le.object&&o===Le.object){const r=at.objectKeys(t),a=at.objectKeys(e).filter(s=>r.indexOf(s)!==-1),i={...e,...t};for(const s of a){const c=IH(e[s],t[s]);if(!c.valid)return{valid:!1};i[s]=c.data}return{valid:!0,data:i}}else if(n===Le.array&&o===Le.array){if(e.length!==t.length)return{valid:!1};const r=[];for(let a=0;a<e.length;a++){const i=e[a],s=t[a],c=IH(i,s);if(!c.valid)return{valid:!1};r.push(c.data)}return{valid:!0,data:r}}else return n===Le.date&&o===Le.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class GP extends Je{_parse(t){const{status:n,ctx:o}=this._processInputParams(t),r=(a,i)=>{if(OU(a)||OU(i))return Ve;const s=IH(a.value,i.value);return s.valid?((qU(a)||qU(i))&&n.dirty(),{status:n.value,value:s.data}):(be(o,{code:me.invalid_intersection_types}),Ve)};return o.common.async?Promise.all([this._def.left._parseAsync({data:o.data,path:o.path,parent:o}),this._def.right._parseAsync({data:o.data,path:o.path,parent:o})]).then(([a,i])=>r(a,i)):r(this._def.left._parseSync({data:o.data,path:o.path,parent:o}),this._def.right._parseSync({data:o.data,path:o.path,parent:o}))}}GP.create=(e,t,n)=>new GP({left:e,right:t,typeName:qe.ZodIntersection,...Xe(n)});class Ad extends Je{_parse(t){const{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==Le.array)return be(o,{code:me.invalid_type,expected:Le.array,received:o.parsedType}),Ve;if(o.data.length<this._def.items.length)return be(o,{code:me.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Ve;!this._def.rest&&o.data.length>this._def.items.length&&(be(o,{code:me.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const a=[...o.data].map((i,s)=>{const c=this._def.items[s]||this._def.rest;return c?c._parse(new Tr(o,i,o.path,s)):null}).filter(i=>!!i);return o.common.async?Promise.all(a).then(i=>In.mergeArray(n,i)):In.mergeArray(n,a)}get items(){return this._def.items}rest(t){return new Ad({...this._def,rest:t})}}Ad.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Ad({items:e,typeName:qe.ZodTuple,rest:null,...Xe(t)})};class ZP extends Je{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==Le.object)return be(o,{code:me.invalid_type,expected:Le.object,received:o.parsedType}),Ve;const r=[],a=this._def.keyType,i=this._def.valueType;for(const s in o.data)r.push({key:a._parse(new Tr(o,s,o.path,s)),value:i._parse(new Tr(o,o.data[s],o.path,s)),alwaysSet:s in o.data});return o.common.async?In.mergeObjectAsync(n,r):In.mergeObjectSync(n,r)}get element(){return this._def.valueType}static create(t,n,o){return n instanceof Je?new ZP({keyType:t,valueType:n,typeName:qe.ZodRecord,...Xe(o)}):new ZP({keyType:ya.create(),valueType:t,typeName:qe.ZodRecord,...Xe(n)})}}class ZU extends Je{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==Le.map)return be(o,{code:me.invalid_type,expected:Le.map,received:o.parsedType}),Ve;const r=this._def.keyType,a=this._def.valueType,i=[...o.data.entries()].map(([s,c],l)=>({key:r._parse(new Tr(o,s,o.path,[l,"key"])),value:a._parse(new Tr(o,c,o.path,[l,"value"]))}));if(o.common.async){const s=new Map;return Promise.resolve().then(async()=>{for(const c of i){const l=await c.key,h=await c.value;if(l.status==="aborted"||h.status==="aborted")return Ve;(l.status==="dirty"||h.status==="dirty")&&n.dirty(),s.set(l.value,h.value)}return{status:n.value,value:s}})}else{const s=new Map;for(const c of i){const l=c.key,h=c.value;if(l.status==="aborted"||h.status==="aborted")return Ve;(l.status==="dirty"||h.status==="dirty")&&n.dirty(),s.set(l.value,h.value)}return{status:n.value,value:s}}}}ZU.create=(e,t,n)=>new ZU({valueType:t,keyType:e,typeName:qe.ZodMap,...Xe(n)});class Fh extends Je{_parse(t){const{status:n,ctx:o}=this._processInputParams(t);if(o.parsedType!==Le.set)return be(o,{code:me.invalid_type,expected:Le.set,received:o.parsedType}),Ve;const r=this._def;r.minSize!==null&&o.data.size<r.minSize.value&&(be(o,{code:me.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),n.dirty()),r.maxSize!==null&&o.data.size>r.maxSize.value&&(be(o,{code:me.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),n.dirty());const a=this._def.valueType;function i(c){const l=new Set;for(const h of c){if(h.status==="aborted")return Ve;h.status==="dirty"&&n.dirty(),l.add(h.value)}return{status:n.value,value:l}}const s=[...o.data.values()].map((c,l)=>a._parse(new Tr(o,c,o.path,l)));return o.common.async?Promise.all(s).then(c=>i(c)):i(s)}min(t,n){return new Fh({...this._def,minSize:{value:t,message:Ne.toString(n)}})}max(t,n){return new Fh({...this._def,maxSize:{value:t,message:Ne.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}Fh.create=(e,t)=>new Fh({valueType:e,minSize:null,maxSize:null,typeName:qe.ZodSet,...Xe(t)});class XU extends Je{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}XU.create=(e,t)=>new XU({getter:e,typeName:qe.ZodLazy,...Xe(t)});class NH extends Je{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return be(n,{received:n.data,code:me.invalid_literal,expected:this._def.value}),Ve}return{status:"valid",value:t.data}}get value(){return this._def.value}}NH.create=(e,t)=>new NH({value:e,typeName:qe.ZodLiteral,...Xe(t)});function aJ(e,t){return new M0({values:e,typeName:qe.ZodEnum,...Xe(t)})}class M0 extends Je{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),o=this._def.values;return be(n,{expected:at.joinValues(o),received:n.parsedType,code:me.invalid_type}),Ve}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const n=this._getOrReturnCtx(t),o=this._def.values;return be(n,{received:n.data,code:me.invalid_enum_value,options:o}),Ve}return Io(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return M0.create(t,{...this._def,...n})}exclude(t,n=this._def){return M0.create(this.options.filter(o=>!t.includes(o)),{...this._def,...n})}}M0.create=aJ;class KU extends Je{_parse(t){const n=at.getValidEnumValues(this._def.values),o=this._getOrReturnCtx(t);if(o.parsedType!==Le.string&&o.parsedType!==Le.number){const r=at.objectValues(n);return be(o,{expected:at.joinValues(r),received:o.parsedType,code:me.invalid_type}),Ve}if(this._cache||(this._cache=new Set(at.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const r=at.objectValues(n);return be(o,{received:o.data,code:me.invalid_enum_value,options:r}),Ve}return Io(t.data)}get enum(){return this._def.values}}KU.create=(e,t)=>new KU({values:e,typeName:qe.ZodNativeEnum,...Xe(t)});class XP extends Je{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==Le.promise&&n.common.async===!1)return be(n,{code:me.invalid_type,expected:Le.promise,received:n.parsedType}),Ve;const o=n.parsedType===Le.promise?n.data:Promise.resolve(n.data);return Io(o.then(r=>this._def.type.parseAsync(r,{path:n.path,errorMap:n.common.contextualErrorMap})))}}XP.create=(e,t)=>new XP({type:e,typeName:qe.ZodPromise,...Xe(t)});class b0 extends Je{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===qe.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:o}=this._processInputParams(t),r=this._def.effect||null,a={addIssue:i=>{be(o,i),i.fatal?n.abort():n.dirty()},get path(){return o.path}};if(a.addIssue=a.addIssue.bind(a),r.type==="preprocess"){const i=r.transform(o.data,a);if(o.common.async)return Promise.resolve(i).then(async s=>{if(n.value==="aborted")return Ve;const c=await this._def.schema._parseAsync({data:s,path:o.path,parent:o});return c.status==="aborted"?Ve:c.status==="dirty"||n.value==="dirty"?C2(c.value):c});{if(n.value==="aborted")return Ve;const s=this._def.schema._parseSync({data:i,path:o.path,parent:o});return s.status==="aborted"?Ve:s.status==="dirty"||n.value==="dirty"?C2(s.value):s}}if(r.type==="refinement"){const i=s=>{const c=r.refinement(s,a);if(o.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(o.common.async===!1){const s=this._def.schema._parseSync({data:o.data,path:o.path,parent:o});return s.status==="aborted"?Ve:(s.status==="dirty"&&n.dirty(),i(s.value),{status:n.value,value:s.value})}else return this._def.schema._parseAsync({data:o.data,path:o.path,parent:o}).then(s=>s.status==="aborted"?Ve:(s.status==="dirty"&&n.dirty(),i(s.value).then(()=>({status:n.value,value:s.value}))))}if(r.type==="transform")if(o.common.async===!1){const i=this._def.schema._parseSync({data:o.data,path:o.path,parent:o});if(!x0(i))return Ve;const s=r.transform(i.value,a);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:s}}else return this._def.schema._parseAsync({data:o.data,path:o.path,parent:o}).then(i=>x0(i)?Promise.resolve(r.transform(i.value,a)).then(s=>({status:n.value,value:s})):Ve);at.assertNever(r)}}b0.create=(e,t,n)=>new b0({schema:e,typeName:qe.ZodEffects,effect:t,...Xe(n)});b0.createWithPreprocess=(e,t,n)=>new b0({schema:t,effect:{type:"preprocess",transform:e},typeName:qe.ZodEffects,...Xe(n)});class xi extends Je{_parse(t){return this._getType(t)===Le.undefined?Io(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}xi.create=(e,t)=>new xi({innerType:e,typeName:qe.ZodOptional,...Xe(t)});class _0 extends Je{_parse(t){return this._getType(t)===Le.null?Io(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}_0.create=(e,t)=>new _0({innerType:e,typeName:qe.ZodNullable,...Xe(t)});class AH extends Je{_parse(t){const{ctx:n}=this._processInputParams(t);let o=n.data;return n.parsedType===Le.undefined&&(o=this._def.defaultValue()),this._def.innerType._parse({data:o,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}AH.create=(e,t)=>new AH({innerType:e,typeName:qe.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Xe(t)});class EH extends Je{_parse(t){const{ctx:n}=this._processInputParams(t),o={...n,common:{...n.common,issues:[]}},r=this._def.innerType._parse({data:o.data,path:o.path,parent:{...o}});return BP(r)?r.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Ma(o.common.issues)},input:o.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new Ma(o.common.issues)},input:o.data})}}removeCatch(){return this._def.innerType}}EH.create=(e,t)=>new EH({innerType:e,typeName:qe.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Xe(t)});class YU extends Je{_parse(t){if(this._getType(t)!==Le.nan){const o=this._getOrReturnCtx(t);return be(o,{code:me.invalid_type,expected:Le.nan,received:o.parsedType}),Ve}return{status:"valid",value:t.data}}}YU.create=e=>new YU({typeName:qe.ZodNaN,...Xe(e)});class aHe extends Je{_parse(t){const{ctx:n}=this._processInputParams(t),o=n.data;return this._def.type._parse({data:o,path:n.path,parent:n})}unwrap(){return this._def.type}}class Pq extends Je{_parse(t){const{status:n,ctx:o}=this._processInputParams(t);if(o.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:o.data,path:o.path,parent:o});return a.status==="aborted"?Ve:a.status==="dirty"?(n.dirty(),C2(a.value)):this._def.out._parseAsync({data:a.value,path:o.path,parent:o})})();{const r=this._def.in._parseSync({data:o.data,path:o.path,parent:o});return r.status==="aborted"?Ve:r.status==="dirty"?(n.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:o.path,parent:o})}}static create(t,n){return new Pq({in:t,out:n,typeName:qe.ZodPipeline})}}class $H extends Je{_parse(t){const n=this._def.innerType._parse(t),o=r=>(x0(r)&&(r.value=Object.freeze(r.value)),r);return BP(n)?n.then(r=>o(r)):o(n)}unwrap(){return this._def.innerType}}$H.create=(e,t)=>new $H({innerType:e,typeName:qe.ZodReadonly,...Xe(t)});var qe;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(qe||(qe={}));const sn=ya.create,iJ=w0.create,iHe=SH.create,lh=LH.create;Ci.create;const ts=jr.create,rt=Zt.create,jH=WP.create;GP.create;Ad.create;const QU=ZP.create,up=NH.create,hp=M0.create;XP.create;xi.create;_0.create;const sHe=rt({$state:sn().min(1)}),sa=rt({$action:sn().min(1)}),cHe=rt({$cond:lh(),$then:lh(),$else:lh().optional()}),To=e=>jH([e,sHe,sa,cHe]),Ht=To(sn()),oa=To(iJ()),fp=To(iHe()),sJ={Card:rt({title:Ht.optional()}),Separator:rt({orientation:To(hp(["horizontal","vertical"])).optional()}),Tabs:rt({value:Ht.optional(),items:ts(rt({id:sn(),label:sn()})),onChange:sa.optional()}),Accordion:rt({items:ts(rt({id:sn(),title:sn(),content:sn()}))}),Badge:rt({label:Ht,variant:To(hp(["default","secondary","destructive","outline"])).optional()}),Avatar:rt({src:Ht.optional(),alt:Ht.optional(),fallback:Ht.optional()}),Progress:rt({value:oa}),Skeleton:rt({width:oa.optional(),height:oa.optional()}),Label:rt({text:Ht}),Heading:rt({level:To(jH([up(1),up(2),up(3),up(4)])).optional(),text:Ht}),Text:rt({text:Ht,muted:fp.optional()}),Icon:rt({name:Ht,size:oa.optional()}),Chart:rt({kind:To(hp(["bar","line","area","pie"])),data:To(ts(QU(sn(),lh()))),xKey:Ht.optional(),series:ts(rt({key:sn(),label:sn().optional()})).optional()}),Table:rt({columns:ts(rt({key:sn(),label:sn()})),rows:To(ts(QU(sn(),lh())))}),Metric:rt({label:Ht,value:To(jH([sn(),iJ()]))}),CodeBlock:rt({code:Ht,language:Ht.optional()}),Markdown:rt({content:Ht}),Button:rt({label:Ht,variant:To(hp(["default","destructive","outline","secondary","ghost","link"])).optional(),onClick:sa.optional(),disabled:fp.optional()}),Input:rt({value:Ht.optional(),placeholder:Ht.optional(),onChange:sa.optional()}),Checkbox:rt({checked:fp.optional(),onChange:sa.optional(),label:Ht.optional()}),Switch:rt({checked:fp.optional(),onChange:sa.optional()}),Select:rt({value:Ht.optional(),items:ts(rt({value:sn(),label:sn()})),onChange:sa.optional()}),Textarea:rt({value:Ht.optional(),placeholder:Ht.optional(),rows:oa.optional(),onChange:sa.optional()}),Slider:rt({value:oa.optional(),min:oa.optional(),max:oa.optional(),step:oa.optional(),onChange:sa.optional()})},cJ=Object.keys(sJ);Object.fromEntries(cJ.map(e=>[e,{props:sJ[e],description:e}]));function JU(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Dr(...e){return t=>{let n=!1;const o=e.map(r=>{const a=JU(r,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let r=0;r<o.length;r++){const a=o[r];typeof a=="function"?a():JU(e[r],null)}}}}function gt(...e){return m.useCallback(Dr(...e),e)}var lHe=Symbol.for("react.lazy"),KP=bO[" use ".trim().toString()];function dHe(e){return typeof e=="object"&&e!==null&&"then"in e}function lJ(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===lHe&&"_payload"in e&&dHe(e._payload)}function uHe(e){const t=fHe(e),n=m.forwardRef((o,r)=>{let{children:a,...i}=o;lJ(a)&&typeof KP=="function"&&(a=KP(a._payload));const s=m.Children.toArray(a),c=s.find(yHe);if(c){const l=c.props.children,h=s.map(u=>u===c?m.Children.count(l)>1?m.Children.only(null):m.isValidElement(l)?l.props.children:null:u);return p.jsx(t,{...i,ref:r,children:m.isValidElement(l)?m.cloneElement(l,void 0,h):null})}return p.jsx(t,{...i,ref:r,children:a})});return n.displayName=`${e}.Slot`,n}var hHe=uHe("Slot");function fHe(e){const t=m.forwardRef((n,o)=>{let{children:r,...a}=n;if(lJ(r)&&typeof KP=="function"&&(r=KP(r._payload)),m.isValidElement(r)){const i=gHe(r),s=mHe(a,r.props);return r.type!==m.Fragment&&(s.ref=o?Dr(o,i):i),m.cloneElement(r,s)}return m.Children.count(r)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var pHe=Symbol("radix.slottable");function yHe(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===pHe}function mHe(e,t){const n={...t};for(const o in t){const r=e[o],a=t[o];/^on[A-Z]/.test(o)?r&&a?n[o]=(...s)=>{const c=a(...s);return r(...s),c}:r&&(n[o]=r):o==="style"?n[o]={...r,...a}:o==="className"&&(n[o]=[r,a].filter(Boolean).join(" "))}return{...e,...n}}function gHe(e){var o,r;let t=(o=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(r=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}const eW=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,tW=QK,dJ=(e,t)=>n=>{var o;if((t==null?void 0:t.variants)==null)return tW(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:r,defaultVariants:a}=t,i=Object.keys(r).map(l=>{const h=n==null?void 0:n[l],u=a==null?void 0:a[l];if(h===null)return null;const f=eW(h)||eW(u);return r[l][f]}),s=n&&Object.entries(n).reduce((l,h)=>{let[u,f]=h;return f===void 0||(l[u]=f),l},{}),c=t==null||(o=t.compoundVariants)===null||o===void 0?void 0:o.reduce((l,h)=>{let{class:u,className:f,...y}=h;return Object.entries(y).every(g=>{let[k,x]=g;return Array.isArray(x)?x.includes({...a,...s}[k]):{...a,...s}[k]===x})?[...l,u,f]:l},[]);return tW(e,i,c,n==null?void 0:n.class,n==null?void 0:n.className)},kHe=dJ("sf:inline-flex sf:items-center sf:justify-center sf:whitespace-nowrap sf:rounded-md sf:text-sm sf:font-medium sf:ring-offset-background sf:transition-colors sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:focus-visible:ring-offset-2 sf:disabled:pointer-events-none sf:disabled:opacity-50",{variants:{variant:{default:"sf:bg-primary sf:text-primary-foreground sf:font-semibold sf:hover:bg-emerald-400",destructive:"sf:bg-destructive sf:text-destructive-foreground sf:hover:bg-destructive/90",outline:"sf:border sf:border-input sf:bg-background sf:hover:bg-secondary sf:hover:text-foreground",secondary:"sf:bg-secondary sf:text-secondary-foreground sf:hover:bg-secondary/80",ghost:"sf:text-muted-foreground sf:hover:bg-muted sf:hover:text-foreground",link:"sf:text-primary sf:underline-offset-4 sf:hover:underline"},size:{default:"sf:h-9 sf:px-4 sf:py-2",sm:"sf:h-8 sf:rounded-md sf:px-3",lg:"sf:h-11 sf:rounded-md sf:px-8",icon:"sf:h-9 sf:w-9"}},defaultVariants:{variant:"default",size:"default"}}),ut=m.forwardRef(({className:e,variant:t,size:n,asChild:o=!1,...r},a)=>{const i=o?hHe:"button";return p.jsx(i,{className:oe(kHe({variant:t,size:n,className:e})),ref:a,...r})});ut.displayName="Button";function uJ(e,[t,n]){return Math.min(n,Math.max(t,e))}function Ie(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e==null||e(r),n===!1||!r.defaultPrevented)return t==null?void 0:t(r)}}function vHe(e,t){const n=m.createContext(t),o=a=>{const{children:i,...s}=a,c=m.useMemo(()=>s,Object.values(s));return p.jsx(n.Provider,{value:c,children:i})};o.displayName=e+"Provider";function r(a){const i=m.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${a}\` must be used within \`${e}\``)}return[o,r]}function Qo(e,t=[]){let n=[];function o(a,i){const s=m.createContext(i),c=n.length;n=[...n,i];const l=u=>{var v;const{scope:f,children:y,...g}=u,k=((v=f==null?void 0:f[e])==null?void 0:v[c])||s,x=m.useMemo(()=>g,Object.values(g));return p.jsx(k.Provider,{value:x,children:y})};l.displayName=a+"Provider";function h(u,f){var k;const y=((k=f==null?void 0:f[e])==null?void 0:k[c])||s,g=m.useContext(y);if(g)return g;if(i!==void 0)return i;throw new Error(`\`${u}\` must be used within \`${a}\``)}return[l,h]}const r=()=>{const a=n.map(i=>m.createContext(i));return function(s){const c=(s==null?void 0:s[e])||a;return m.useMemo(()=>({[`__scope${e}`]:{...s,[e]:c}}),[s,c])}};return r.scopeName=e,[o,xHe(r,...t)]}function xHe(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const o=e.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(a){const i=o.reduce((s,{useScope:c,scopeName:l})=>{const u=c(a)[`__scope${l}`];return{...s,...u}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}var Si=globalThis!=null&&globalThis.document?m.useLayoutEffect:()=>{},wHe=bO[" useInsertionEffect ".trim().toString()]||Si;function Td({prop:e,defaultProp:t,onChange:n=()=>{},caller:o}){const[r,a,i]=MHe({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:r;{const h=m.useRef(e!==void 0);m.useEffect(()=>{const u=h.current;u!==s&&console.warn(`${o} is changing from ${u?"controlled":"uncontrolled"} to ${s?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),h.current=s},[s,o])}const l=m.useCallback(h=>{var u;if(s){const f=bHe(h)?h(e):h;f!==e&&((u=i.current)==null||u.call(i,f))}else a(h)},[s,e,a,i]);return[c,l]}function MHe({defaultProp:e,onChange:t}){const[n,o]=m.useState(e),r=m.useRef(n),a=m.useRef(t);return wHe(()=>{a.current=t},[t]),m.useEffect(()=>{var i;r.current!==n&&((i=a.current)==null||i.call(a,n),r.current=n)},[n,r]),[n,o,a]}function bHe(e){return typeof e=="function"}var _He=m.createContext(void 0);function Gz(e){const t=m.useContext(_He);return e||t||"ltr"}function CHe(e){const t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}function hJ(e){const[t,n]=m.useState(void 0);return Si(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const o=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;const a=r[0];let i,s;if("borderBoxSize"in a){const c=a.borderBoxSize,l=Array.isArray(c)?c[0]:c;i=l.inlineSize,s=l.blockSize}else i=e.offsetWidth,s=e.offsetHeight;n({width:i,height:s})});return o.observe(e,{box:"border-box"}),()=>o.unobserve(e)}else n(void 0)},[e]),t}function C0(e){const t=SHe(e),n=m.forwardRef((o,r)=>{const{children:a,...i}=o,s=m.Children.toArray(a),c=s.find(IHe);if(c){const l=c.props.children,h=s.map(u=>u===c?m.Children.count(l)>1?m.Children.only(null):m.isValidElement(l)?l.props.children:null:u);return p.jsx(t,{...i,ref:r,children:m.isValidElement(l)?m.cloneElement(l,void 0,h):null})}return p.jsx(t,{...i,ref:r,children:a})});return n.displayName=`${e}.Slot`,n}function SHe(e){const t=m.forwardRef((n,o)=>{const{children:r,...a}=n;if(m.isValidElement(r)){const i=AHe(r),s=NHe(a,r.props);return r.type!==m.Fragment&&(s.ref=o?Dr(o,i):i),m.cloneElement(r,s)}return m.Children.count(r)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var fJ=Symbol("radix.slottable");function LHe(e){const t=({children:n})=>p.jsx(p.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=fJ,t}function IHe(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===fJ}function NHe(e,t){const n={...t};for(const o in t){const r=e[o],a=t[o];/^on[A-Z]/.test(o)?r&&a?n[o]=(...s)=>{const c=a(...s);return r(...s),c}:r&&(n[o]=r):o==="style"?n[o]={...r,...a}:o==="className"&&(n[o]=[r,a].filter(Boolean).join(" "))}return{...e,...n}}function AHe(e){var o,r;let t=(o=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(r=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var EHe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],We=EHe.reduce((e,t)=>{const n=C0(`Primitive.${t}`),o=m.forwardRef((r,a)=>{const{asChild:i,...s}=r,c=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),p.jsx(c,{...s,ref:a})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function pJ(e,t){e&&P0.flushSync(()=>e.dispatchEvent(t))}function zq(e){const t=e+"CollectionProvider",[n,o]=Qo(t),[r,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=k=>{const{scope:x,children:v}=k,M=br.useRef(null),w=br.useRef(new Map).current;return p.jsx(r,{scope:x,itemMap:w,collectionRef:M,children:v})};i.displayName=t;const s=e+"CollectionSlot",c=C0(s),l=br.forwardRef((k,x)=>{const{scope:v,children:M}=k,w=a(s,v),b=gt(x,w.collectionRef);return p.jsx(c,{ref:b,children:M})});l.displayName=s;const h=e+"CollectionItemSlot",u="data-radix-collection-item",f=C0(h),y=br.forwardRef((k,x)=>{const{scope:v,children:M,...w}=k,b=br.useRef(null),C=gt(x,b),_=a(h,v);return br.useEffect(()=>(_.itemMap.set(b,{ref:b,...w}),()=>void _.itemMap.delete(b))),p.jsx(f,{[u]:"",ref:C,children:M})});y.displayName=h;function g(k){const x=a(e+"CollectionConsumer",k);return br.useCallback(()=>{const M=x.collectionRef.current;if(!M)return[];const w=Array.from(M.querySelectorAll(`[${u}]`));return Array.from(x.itemMap.values()).sort((_,S)=>w.indexOf(_.ref.current)-w.indexOf(S.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:l,ItemSlot:y},g,o]}var yJ=["PageUp","PageDown"],mJ=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],gJ={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},D0="Slider",[PH,$He,jHe]=zq(D0),[kJ]=Qo(D0,[jHe]),[PHe,Zz]=kJ(D0),vJ=m.forwardRef((e,t)=>{const{name:n,min:o=0,max:r=100,step:a=1,orientation:i="horizontal",disabled:s=!1,minStepsBetweenThumbs:c=0,defaultValue:l=[o],value:h,onValueChange:u=()=>{},onValueCommit:f=()=>{},inverted:y=!1,form:g,...k}=e,x=m.useRef(new Set),v=m.useRef(0),w=i==="horizontal"?zHe:RHe,[b=[],C]=Td({prop:h,defaultProp:l,onChange:N=>{var W;(W=[...x.current][v.current])==null||W.focus(),u(N)}}),_=m.useRef(b);function S(N){const R=qHe(b,N);A(N,R)}function j(N){A(N,v.current)}function P(){const N=_.current[v.current];b[v.current]!==N&&f(b)}function A(N,R,{commit:W}={commit:!1}){const $=UHe(a),H=WHe(Math.round((N-o)/a)*a+o,$),T=uJ(H,[o,r]);C((O=[])=>{const I=HHe(O,T,R);if(BHe(I,c*a)){v.current=I.indexOf(T);const z=String(I)!==String(O);return z&&W&&f(I),z?I:O}else return O})}return p.jsx(PHe,{scope:e.__scopeSlider,name:n,disabled:s,min:o,max:r,valueIndexToChangeRef:v,thumbs:x.current,values:b,orientation:i,form:g,children:p.jsx(PH.Provider,{scope:e.__scopeSlider,children:p.jsx(PH.Slot,{scope:e.__scopeSlider,children:p.jsx(w,{"aria-disabled":s,"data-disabled":s?"":void 0,...k,ref:t,onPointerDown:Ie(k.onPointerDown,()=>{s||(_.current=b)}),min:o,max:r,inverted:y,onSlideStart:s?void 0:S,onSlideMove:s?void 0:j,onSlideEnd:s?void 0:P,onHomeKeyDown:()=>!s&&A(o,0,{commit:!0}),onEndKeyDown:()=>!s&&A(r,b.length-1,{commit:!0}),onStepKeyDown:({event:N,direction:R})=>{if(!s){const H=yJ.includes(N.key)||N.shiftKey&&mJ.includes(N.key)?10:1,T=v.current,O=b[T],I=a*H*R;A(O+I,T,{commit:!0})}}})})})})});vJ.displayName=D0;var[xJ,wJ]=kJ(D0,{startEdge:"left",endEdge:"right",size:"width",direction:1}),zHe=m.forwardRef((e,t)=>{const{min:n,max:o,dir:r,inverted:a,onSlideStart:i,onSlideMove:s,onSlideEnd:c,onStepKeyDown:l,...h}=e,[u,f]=m.useState(null),y=gt(t,w=>f(w)),g=m.useRef(void 0),k=Gz(r),x=k==="ltr",v=x&&!a||!x&&a;function M(w){const b=g.current||u.getBoundingClientRect(),C=[0,b.width],S=Rq(C,v?[n,o]:[o,n]);return g.current=b,S(w-b.left)}return p.jsx(xJ,{scope:e.__scopeSlider,startEdge:v?"left":"right",endEdge:v?"right":"left",direction:v?1:-1,size:"width",children:p.jsx(MJ,{dir:k,"data-orientation":"horizontal",...h,ref:y,style:{...h.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:w=>{const b=M(w.clientX);i==null||i(b)},onSlideMove:w=>{const b=M(w.clientX);s==null||s(b)},onSlideEnd:()=>{g.current=void 0,c==null||c()},onStepKeyDown:w=>{const C=gJ[v?"from-left":"from-right"].includes(w.key);l==null||l({event:w,direction:C?-1:1})}})})}),RHe=m.forwardRef((e,t)=>{const{min:n,max:o,inverted:r,onSlideStart:a,onSlideMove:i,onSlideEnd:s,onStepKeyDown:c,...l}=e,h=m.useRef(null),u=gt(t,h),f=m.useRef(void 0),y=!r;function g(k){const x=f.current||h.current.getBoundingClientRect(),v=[0,x.height],w=Rq(v,y?[o,n]:[n,o]);return f.current=x,w(k-x.top)}return p.jsx(xJ,{scope:e.__scopeSlider,startEdge:y?"bottom":"top",endEdge:y?"top":"bottom",size:"height",direction:y?1:-1,children:p.jsx(MJ,{"data-orientation":"vertical",...l,ref:u,style:{...l.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:k=>{const x=g(k.clientY);a==null||a(x)},onSlideMove:k=>{const x=g(k.clientY);i==null||i(x)},onSlideEnd:()=>{f.current=void 0,s==null||s()},onStepKeyDown:k=>{const v=gJ[y?"from-bottom":"from-top"].includes(k.key);c==null||c({event:k,direction:v?-1:1})}})})}),MJ=m.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:o,onSlideMove:r,onSlideEnd:a,onHomeKeyDown:i,onEndKeyDown:s,onStepKeyDown:c,...l}=e,h=Zz(D0,n);return p.jsx(We.span,{...l,ref:t,onKeyDown:Ie(e.onKeyDown,u=>{u.key==="Home"?(i(u),u.preventDefault()):u.key==="End"?(s(u),u.preventDefault()):yJ.concat(mJ).includes(u.key)&&(c(u),u.preventDefault())}),onPointerDown:Ie(e.onPointerDown,u=>{const f=u.target;f.setPointerCapture(u.pointerId),u.preventDefault(),h.thumbs.has(f)?f.focus():o(u)}),onPointerMove:Ie(e.onPointerMove,u=>{u.target.hasPointerCapture(u.pointerId)&&r(u)}),onPointerUp:Ie(e.onPointerUp,u=>{const f=u.target;f.hasPointerCapture(u.pointerId)&&(f.releasePointerCapture(u.pointerId),a(u))})})}),bJ="SliderTrack",_J=m.forwardRef((e,t)=>{const{__scopeSlider:n,...o}=e,r=Zz(bJ,n);return p.jsx(We.span,{"data-disabled":r.disabled?"":void 0,"data-orientation":r.orientation,...o,ref:t})});_J.displayName=bJ;var zH="SliderRange",CJ=m.forwardRef((e,t)=>{const{__scopeSlider:n,...o}=e,r=Zz(zH,n),a=wJ(zH,n),i=m.useRef(null),s=gt(t,i),c=r.values.length,l=r.values.map(f=>IJ(f,r.min,r.max)),h=c>1?Math.min(...l):0,u=100-Math.max(...l);return p.jsx(We.span,{"data-orientation":r.orientation,"data-disabled":r.disabled?"":void 0,...o,ref:s,style:{...e.style,[a.startEdge]:h+"%",[a.endEdge]:u+"%"}})});CJ.displayName=zH;var RH="SliderThumb",SJ=m.forwardRef((e,t)=>{const n=$He(e.__scopeSlider),[o,r]=m.useState(null),a=gt(t,s=>r(s)),i=m.useMemo(()=>o?n().findIndex(s=>s.ref.current===o):-1,[n,o]);return p.jsx(THe,{...e,ref:a,index:i})}),THe=m.forwardRef((e,t)=>{const{__scopeSlider:n,index:o,name:r,...a}=e,i=Zz(RH,n),s=wJ(RH,n),[c,l]=m.useState(null),h=gt(t,M=>l(M)),u=c?i.form||!!c.closest("form"):!0,f=hJ(c),y=i.values[o],g=y===void 0?0:IJ(y,i.min,i.max),k=OHe(o,i.values.length),x=f==null?void 0:f[s.size],v=x?FHe(x,g,s.direction):0;return m.useEffect(()=>{if(c)return i.thumbs.add(c),()=>{i.thumbs.delete(c)}},[c,i.thumbs]),p.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[s.startEdge]:`calc(${g}% + ${v}px)`},children:[p.jsx(PH.ItemSlot,{scope:e.__scopeSlider,children:p.jsx(We.span,{role:"slider","aria-label":e["aria-label"]||k,"aria-valuemin":i.min,"aria-valuenow":y,"aria-valuemax":i.max,"aria-orientation":i.orientation,"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,tabIndex:i.disabled?void 0:0,...a,ref:h,style:y===void 0?{display:"none"}:e.style,onFocus:Ie(e.onFocus,()=>{i.valueIndexToChangeRef.current=o})})}),u&&p.jsx(LJ,{name:r??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:y},o)]})});SJ.displayName=RH;var DHe="RadioBubbleInput",LJ=m.forwardRef(({__scopeSlider:e,value:t,...n},o)=>{const r=m.useRef(null),a=gt(r,o),i=CHe(t);return m.useEffect(()=>{const s=r.current;if(!s)return;const c=window.HTMLInputElement.prototype,h=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&h){const u=new Event("input",{bubbles:!0});h.call(s,t),s.dispatchEvent(u)}},[i,t]),p.jsx(We.input,{style:{display:"none"},...n,ref:a,defaultValue:t})});LJ.displayName=DHe;function HHe(e=[],t,n){const o=[...e];return o[n]=t,o.sort((r,a)=>r-a)}function IJ(e,t,n){const a=100/(n-t)*(e-t);return uJ(a,[0,100])}function OHe(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function qHe(e,t){if(e.length===1)return 0;const n=e.map(r=>Math.abs(r-t)),o=Math.min(...n);return n.indexOf(o)}function FHe(e,t,n){const o=e/2,a=Rq([0,50],[0,o]);return(o-a(t)*n)*n}function VHe(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function BHe(e,t){if(t>0){const n=VHe(e);return Math.min(...n)>=t}return!0}function Rq(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const o=(t[1]-t[0])/(e[1]-e[0]);return t[0]+o*(n-e[0])}}function UHe(e){return(String(e).split(".")[1]||"").length}function WHe(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var NJ=vJ,GHe=_J,ZHe=CJ,XHe=SJ;const Tq=m.forwardRef(({className:e,...t},n)=>p.jsxs(NJ,{ref:n,className:oe("sf:relative sf:flex sf:w-full sf:touch-none sf:select-none sf:items-center",e),...t,children:[p.jsx(GHe,{className:"sf:relative sf:h-1.5 sf:w-full sf:grow sf:overflow-hidden sf:rounded-full sf:bg-secondary",children:p.jsx(ZHe,{className:"sf:absolute sf:h-full sf:bg-primary"})}),p.jsx(XHe,{className:"sf:block sf:h-4 sf:w-4 sf:rounded-full sf:border sf:border-primary/60 sf:bg-background sf:shadow-sm sf:transition-colors sf:hover:border-primary sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:disabled:pointer-events-none sf:disabled:opacity-50"})]}));Tq.displayName=NJ.displayName;const KHe={1:"sf:text-2xl sf:font-semibold sf:tracking-tight",2:"sf:text-xl sf:font-semibold sf:tracking-tight",3:"sf:text-lg sf:font-semibold",4:"sf:text-base sf:font-semibold"};function YHe({text:e,level:t=2}){const n=`h${t}`;return p.jsx(n,{className:oe(KHe[t]),children:e})}const AJ=m.createContext({custom:{}});function QHe({value:e,children:t}){return p.jsx(AJ.Provider,{value:e,children:t})}function JHe(){return m.useContext(AJ)}function S0({name:e,as:t,size:n=16,fallback:o=xNe,...r}){const a=JHe(),i=t??(e?a.custom[e]:void 0)??(e?l0[e]:void 0)??l0[o];return i?p.jsx(i,{size:n,...r}):null}function eOe({name:e,size:t=16}){return p.jsx(S0,{name:e,size:t,"aria-hidden":!0})}function tOe(e){return e==null?"":typeof e=="string"||typeof e=="number"?e:typeof e=="object"?JSON.stringify(e):String(e)}function nOe({label:e,value:t}){return p.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-1",children:[p.jsx("span",{className:"sf:text-muted-foreground sf:text-xs sf:uppercase sf:tracking-wide",children:e}),p.jsx("span",{className:"sf:font-semibold sf:text-2xl sf:tabular-nums",children:tOe(t)})]})}function oOe(e){return e==null?"":typeof e=="string"||typeof e=="number"?String(e):JSON.stringify(e)}function rOe({columns:e=[],rows:t=[]}){return p.jsx("div",{className:"sf:w-full sf:overflow-x-auto",children:p.jsxs("table",{className:"sf:w-full sf:text-left sf:text-sm",children:[p.jsx("thead",{className:"sf:border-b sf:bg-muted/50",children:p.jsx("tr",{children:e.map(n=>p.jsx("th",{scope:"col",className:"sf:px-3 sf:py-2 sf:font-medium sf:text-muted-foreground",children:n.label},n.key))})}),p.jsx("tbody",{children:t.map((n,o)=>p.jsx("tr",{className:"sf:border-b last:sf:border-0",children:e.map(r=>p.jsx("td",{className:"sf:px-3 sf:py-2",children:oOe(n[r.key])},r.key))},o))})]})})}function aOe({text:e,muted:t}){return p.jsx("p",{className:oe("sf:text-sm",t&&"sf:text-muted-foreground"),children:e})}function iOe({title:e,children:t}){return p.jsxs("div",{className:"sf:bg-card sf:p-4 sf:text-card-foreground sf:shadow-sm",children:[e!==void 0?p.jsx("div",{className:"sf:mb-3 sf:font-semibold sf:text-base sf:leading-tight",children:e}):null,p.jsx("div",{className:"sf:flex sf:flex-col sf:gap-3",children:t})]})}function sOe({orientation:e="horizontal"}){return p.jsx("div",{"aria-orientation":e,className:oe("sf:bg-border",e==="horizontal"?"sf:h-px sf:w-full":"sf:h-full sf:w-px")})}function cOe({value:e,items:t,onChange:n,children:o}){const r=t??[];return p.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-2",children:[p.jsx("div",{className:"sf:inline-flex sf:h-9 sf:items-center sf:justify-start sf:rounded-md sf:bg-muted sf:p-1 sf:text-muted-foreground",children:r.map(a=>p.jsx("button",{type:"button","data-state":e===a.id?"active":"inactive",onClick:()=>n==null?void 0:n({value:a.id}),className:"sf:inline-flex sf:items-center sf:justify-center sf:whitespace-nowrap sf:rounded-sm sf:px-3 sf:py-1 sf:text-xs sf:font-medium sf:transition-all sf:data-[state=active]:bg-background sf:data-[state=active]:text-foreground sf:data-[state=active]:shadow-sm",children:a.label},a.id))}),o]})}function lOe({items:e}){const t=e??[];return p.jsx("div",{className:"sf:flex sf:flex-col sf:divide-y sf:rounded-md sf:border",children:t.map(n=>p.jsxs("details",{className:"sf:group sf:px-3 sf:py-2",children:[p.jsx("summary",{className:"sf:cursor-pointer sf:py-1 sf:font-medium sf:text-sm",children:n.title}),p.jsx("div",{className:"sf:py-2 sf:text-muted-foreground sf:text-sm",children:n.content})]},n.id))})}const nW={default:"sf:bg-primary sf:text-primary-foreground",secondary:"sf:bg-secondary sf:text-secondary-foreground",destructive:"sf:bg-destructive sf:text-destructive-foreground",outline:"sf:border sf:border-border sf:text-foreground"};function dOe({label:e,variant:t="default"}){return p.jsx("span",{className:oe("sf:inline-flex sf:items-center sf:rounded-full sf:px-2.5 sf:py-0.5 sf:font-medium sf:text-xs",nW[t]??nW.default),children:e})}function uOe({src:e,alt:t,fallback:n}){return e?p.jsx("img",{src:e,alt:t??"",className:"sf:inline-block sf:h-9 sf:w-9 sf:rounded-full sf:object-cover"}):p.jsx("span",{className:"sf:inline-flex sf:h-9 sf:w-9 sf:items-center sf:justify-center sf:rounded-full sf:bg-muted sf:font-medium sf:text-muted-foreground sf:text-sm",children:n??"?"})}function hOe({value:e=0}){const t=Math.max(0,Math.min(100,e));return p.jsx("div",{"aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,className:"sf:relative sf:h-2 sf:w-full sf:overflow-hidden sf:rounded-full sf:bg-secondary",children:p.jsx("div",{className:"sf:h-full sf:bg-primary sf:transition-all",style:{width:`${t}%`}})})}function fOe({width:e,height:t}){return p.jsx("div",{className:"sf:animate-pulse sf:rounded-md sf:bg-muted",style:{width:e??"100%",height:t??16}})}function pOe({text:e}){return p.jsx("span",{className:"sf:font-medium sf:text-sm sf:leading-none",children:e})}function yOe({label:e,variant:t="default",onClick:n,disabled:o}){return p.jsx(ut,{variant:t,disabled:o,onClick:()=>n==null?void 0:n(),children:e})}const Dq="sf:flex sf:h-9 sf:w-full sf:rounded-md sf:border sf:border-input sf:bg-background sf:px-3 sf:py-1 sf:text-sm sf:shadow-sm sf:transition-colors sf:placeholder:text-muted-foreground sf:focus-visible:outline-hidden sf:focus-visible:ring-1 sf:focus-visible:ring-ring sf:disabled:cursor-not-allowed sf:disabled:opacity-50";function mOe({value:e,placeholder:t,onChange:n}){return p.jsx("input",{type:"text",value:e??"",placeholder:t,onChange:o=>n==null?void 0:n({value:o.target.value}),className:Dq})}function gOe({checked:e,onChange:t,label:n}){return p.jsxs("label",{className:"sf:inline-flex sf:items-center sf:gap-2 sf:text-sm",children:[p.jsx("input",{type:"checkbox",checked:e??!1,onChange:o=>t==null?void 0:t({checked:o.target.checked}),className:"sf:h-4 sf:w-4 sf:rounded sf:border sf:border-input sf:accent-primary"}),n]})}function kOe({checked:e,onChange:t}){return p.jsx("button",{type:"button",role:"switch","aria-checked":e??!1,onClick:()=>t==null?void 0:t({checked:!(e??!1)}),className:oe("sf:relative sf:inline-flex sf:h-5 sf:w-9 sf:shrink-0 sf:cursor-pointer sf:items-center sf:rounded-full sf:border-2 sf:border-transparent sf:transition-colors",e?"sf:bg-primary":"sf:bg-input"),children:p.jsx("span",{className:oe("sf:pointer-events-none sf:block sf:h-4 sf:w-4 sf:rounded-full sf:bg-background sf:shadow-lg sf:ring-0 sf:transition-transform",e?"sf:translate-x-4":"sf:translate-x-0")})})}function vOe({value:e,items:t,onChange:n}){return p.jsx("select",{value:e??"",onChange:o=>n==null?void 0:n({value:o.target.value}),className:Dq,children:(t??[]).map(o=>p.jsx("option",{value:o.value,children:o.label},o.value))})}function xOe({value:e,placeholder:t,rows:n,onChange:o}){return p.jsx("textarea",{value:e??"",placeholder:t,rows:n,onChange:r=>o==null?void 0:o({value:r.target.value}),className:oe(Dq,"sf:min-h-16 sf:py-2")})}function wOe({value:e,min:t=0,max:n=100,step:o=1,onChange:r}){return p.jsx(Tq,{value:e===void 0?void 0:[e],min:t,max:n,step:o,onValueChange:a=>{const[i]=a;typeof i=="number"&&(r==null||r({value:i}))}})}const MOe=m.lazy(()=>hf(()=>import("./chart-DF01veTJ.js"),__vite__mapDeps([0,1,2,3,4,5,6,7])));function bOe(e){return p.jsx(m.Suspense,{fallback:null,children:p.jsx(MOe,{...e})})}const _Oe=m.lazy(()=>hf(()=>import("./markdown-DK4rNWyg.js"),[]));function COe(e){return p.jsx(m.Suspense,{fallback:null,children:p.jsx(_Oe,{...e})})}const SOe=m.lazy(()=>hf(()=>import("./code-block-Dqo0Jd1G.js"),[]));function LOe(e){return p.jsx(m.Suspense,{fallback:null,children:p.jsx(SOe,{...e})})}const EJ={Card:iOe,Separator:sOe,Tabs:cOe,Accordion:lOe,Badge:dOe,Avatar:uOe,Progress:hOe,Skeleton:fOe,Label:pOe,Heading:YHe,Text:aOe,Icon:eOe,Chart:bOe,Table:rOe,Metric:nOe,CodeBlock:LOe,Markdown:COe,Button:yOe,Input:mOe,Checkbox:gOe,Switch:kOe,Select:vOe,Textarea:xOe,Slider:wOe},oW=cJ.filter(e=>EJ[e]===void 0);if(oW.length>0)throw new Error(`componentRegistry is missing impls for: ${oW.join(", ")}. Every catalog entry in COMPONENT_NAMES must have a matching component impl.`);const IOe={components:EJ};function NOe(e,t){return t.kind==="set"?{...e,[t.path]:t.value}:{...e,...t.partial}}function $J(e){return e===null||typeof e!="object"?!1:"$state"in e||"$action"in e||"$param"in e||"$cond"in e}function Jj(e,t,n,o){if(!$J(e))return e;if(typeof e.$state=="string")return t[e.$state];if(typeof e.$action=="string"){const r=e.$action;return o.has(r)?a=>n(r,a):void 0}if("$cond"in e){const r=Jj(e.$cond,t,n,o);return Jj(r?e.$then:e.$else,t,n,o)}return e}function AOe(e,t,n,o){if(!e)return{};const r={};for(const[a,i]of Object.entries(e))r[a]=Jj(i,t,n,o);return r}function rW({spec:e,nodeId:t,apiBaseUrl:n="/api",projectSlug:o,flowSlug:r}){const[a,i]=m.useReducer(NOe,e.state??{}),s=new Set(Object.keys(e.actions??{})),c=m.useCallback(async(l,h)=>{var y;const u=(y=e.actions)==null?void 0:y[l];if(!u)return;if(u.kind==="set"){const g=EOe(u.value,h,a);i({kind:"set",path:u.path,value:g});return}if(!o||!r)return;const f=`${n}/projects/${encodeURIComponent(o)}/flows/${encodeURIComponent(r)}/nodes/${encodeURIComponent(t)}/actions/${encodeURIComponent(l)}`;try{const g=await fetch(f,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(h??{})});if(!g.ok){const x=await g.text();i({kind:"set",path:`/__errors/${l}`,value:x});return}const k=await g.json();k!==null&&typeof k=="object"&&i({kind:"merge",partial:k})}catch(g){i({kind:"set",path:`/__errors/${l}`,value:g instanceof Error?g.message:String(g)})}},[e.actions,o,r,n,t,a]);return jJ(e.root,e,a,c,s)}function EOe(e,t,n){return $J(e)?typeof e.$param=="string"?t!==null&&typeof t=="object"?t[e.$param]:void 0:typeof e.$state=="string"?n[e.$state]:e:e}function jJ(e,t,n,o,r){const a=t.elements[e];if(!a)return null;const i=IOe.components[a.type];if(!i)return null;const s=AOe(a.props,n,o,r),l=(a.children??[]).map(h=>p.jsx($Oe,{children:jJ(h,t,n,o,r)},h));return p.jsx(i,{...s,children:l.length>0?l:void 0})}function $Oe({children:e}){return e}function Hr(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>{var o;return(o=t.current)==null?void 0:o.call(t,...n)},[])}function jOe(e,t=globalThis==null?void 0:globalThis.document){const n=Hr(e);m.useEffect(()=>{const o=r=>{r.key==="Escape"&&n(r)};return t.addEventListener("keydown",o,{capture:!0}),()=>t.removeEventListener("keydown",o,{capture:!0})},[n,t])}var POe="DismissableLayer",TH="dismissableLayer.update",zOe="dismissableLayer.pointerDownOutside",ROe="dismissableLayer.focusOutside",aW,PJ=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ff=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:o,onPointerDownOutside:r,onFocusOutside:a,onInteractOutside:i,onDismiss:s,...c}=e,l=m.useContext(PJ),[h,u]=m.useState(null),f=(h==null?void 0:h.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=m.useState({}),g=gt(t,S=>u(S)),k=Array.from(l.layers),[x]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),v=k.indexOf(x),M=h?k.indexOf(h):-1,w=l.layersWithOutsidePointerEventsDisabled.size>0,b=M>=v,C=HOe(S=>{const j=S.target,P=[...l.branches].some(A=>A.contains(j));!b||P||(r==null||r(S),i==null||i(S),S.defaultPrevented||s==null||s())},f),_=OOe(S=>{const j=S.target;[...l.branches].some(A=>A.contains(j))||(a==null||a(S),i==null||i(S),S.defaultPrevented||s==null||s())},f);return jOe(S=>{M===l.layers.size-1&&(o==null||o(S),!S.defaultPrevented&&s&&(S.preventDefault(),s()))},f),m.useEffect(()=>{if(h)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(aW=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(h)),l.layers.add(h),iW(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=aW)}},[h,f,n,l]),m.useEffect(()=>()=>{h&&(l.layers.delete(h),l.layersWithOutsidePointerEventsDisabled.delete(h),iW())},[h,l]),m.useEffect(()=>{const S=()=>y({});return document.addEventListener(TH,S),()=>document.removeEventListener(TH,S)},[]),p.jsx(We.div,{...c,ref:g,style:{pointerEvents:w?b?"auto":"none":void 0,...e.style},onFocusCapture:Ie(e.onFocusCapture,_.onFocusCapture),onBlurCapture:Ie(e.onBlurCapture,_.onBlurCapture),onPointerDownCapture:Ie(e.onPointerDownCapture,C.onPointerDownCapture)})});ff.displayName=POe;var TOe="DismissableLayerBranch",DOe=m.forwardRef((e,t)=>{const n=m.useContext(PJ),o=m.useRef(null),r=gt(t,o);return m.useEffect(()=>{const a=o.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),p.jsx(We.div,{...e,ref:r})});DOe.displayName=TOe;function HOe(e,t=globalThis==null?void 0:globalThis.document){const n=Hr(e),o=m.useRef(!1),r=m.useRef(()=>{});return m.useEffect(()=>{const a=s=>{if(s.target&&!o.current){let c=function(){zJ(zOe,n,l,{discrete:!0})};const l={originalEvent:s};s.pointerType==="touch"?(t.removeEventListener("click",r.current),r.current=c,t.addEventListener("click",r.current,{once:!0})):c()}else t.removeEventListener("click",r.current);o.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",a),t.removeEventListener("click",r.current)}},[t,n]),{onPointerDownCapture:()=>o.current=!0}}function OOe(e,t=globalThis==null?void 0:globalThis.document){const n=Hr(e),o=m.useRef(!1);return m.useEffect(()=>{const r=a=>{a.target&&!o.current&&zJ(ROe,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",r),()=>t.removeEventListener("focusin",r)},[t,n]),{onFocusCapture:()=>o.current=!0,onBlurCapture:()=>o.current=!1}}function iW(){const e=new CustomEvent(TH);document.dispatchEvent(e)}function zJ(e,t,n,{discrete:o}){const r=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&r.addEventListener(e,t,{once:!0}),o?pJ(r,a):r.dispatchEvent(a)}var _T=0;function Hq(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??sW()),document.body.insertAdjacentElement("beforeend",e[1]??sW()),_T++,()=>{_T===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),_T--}},[])}function sW(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var CT="focusScope.autoFocusOnMount",ST="focusScope.autoFocusOnUnmount",cW={bubbles:!1,cancelable:!0},qOe="FocusScope",Xz=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:o=!1,onMountAutoFocus:r,onUnmountAutoFocus:a,...i}=e,[s,c]=m.useState(null),l=Hr(r),h=Hr(a),u=m.useRef(null),f=gt(t,k=>c(k)),y=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(o){let k=function(w){if(y.paused||!s)return;const b=w.target;s.contains(b)?u.current=b:Ka(u.current,{select:!0})},x=function(w){if(y.paused||!s)return;const b=w.relatedTarget;b!==null&&(s.contains(b)||Ka(u.current,{select:!0}))},v=function(w){if(document.activeElement===document.body)for(const C of w)C.removedNodes.length>0&&Ka(s)};document.addEventListener("focusin",k),document.addEventListener("focusout",x);const M=new MutationObserver(v);return s&&M.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",k),document.removeEventListener("focusout",x),M.disconnect()}}},[o,s,y.paused]),m.useEffect(()=>{if(s){dW.add(y);const k=document.activeElement;if(!s.contains(k)){const v=new CustomEvent(CT,cW);s.addEventListener(CT,l),s.dispatchEvent(v),v.defaultPrevented||(FOe(GOe(RJ(s)),{select:!0}),document.activeElement===k&&Ka(s))}return()=>{s.removeEventListener(CT,l),setTimeout(()=>{const v=new CustomEvent(ST,cW);s.addEventListener(ST,h),s.dispatchEvent(v),v.defaultPrevented||Ka(k??document.body,{select:!0}),s.removeEventListener(ST,h),dW.remove(y)},0)}}},[s,l,h,y]);const g=m.useCallback(k=>{if(!n&&!o||y.paused)return;const x=k.key==="Tab"&&!k.altKey&&!k.ctrlKey&&!k.metaKey,v=document.activeElement;if(x&&v){const M=k.currentTarget,[w,b]=VOe(M);w&&b?!k.shiftKey&&v===b?(k.preventDefault(),n&&Ka(w,{select:!0})):k.shiftKey&&v===w&&(k.preventDefault(),n&&Ka(b,{select:!0})):v===M&&k.preventDefault()}},[n,o,y.paused]);return p.jsx(We.div,{tabIndex:-1,...i,ref:f,onKeyDown:g})});Xz.displayName=qOe;function FOe(e,{select:t=!1}={}){const n=document.activeElement;for(const o of e)if(Ka(o,{select:t}),document.activeElement!==n)return}function VOe(e){const t=RJ(e),n=lW(t,e),o=lW(t.reverse(),e);return[n,o]}function RJ(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{const r=o.tagName==="INPUT"&&o.type==="hidden";return o.disabled||o.hidden||r?NodeFilter.FILTER_SKIP:o.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function lW(e,t){for(const n of e)if(!BOe(n,{upTo:t}))return n}function BOe(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function UOe(e){return e instanceof HTMLInputElement&&"select"in e}function Ka(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&UOe(e)&&t&&e.select()}}var dW=WOe();function WOe(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=uW(e,t),e.unshift(t)},remove(t){var n;e=uW(e,t),(n=e[0])==null||n.resume()}}}function uW(e,t){const n=[...e],o=n.indexOf(t);return o!==-1&&n.splice(o,1),n}function GOe(e){return e.filter(t=>t.tagName!=="A")}var ZOe=bO[" useId ".trim().toString()]||(()=>{}),XOe=0;function Ln(e){const[t,n]=m.useState(ZOe());return Si(()=>{n(o=>o??String(XOe++))},[e]),e||(t?`radix-${t}`:"")}const KOe=["top","right","bottom","left"],Li=Math.min,Jn=Math.max,YP=Math.round,pp=Math.floor,Pr=e=>({x:e,y:e}),YOe={left:"right",right:"left",bottom:"top",top:"bottom"};function DH(e,t,n){return Jn(e,Li(t,n))}function ba(e,t){return typeof e=="function"?e(t):e}function _a(e){return e.split("-")[0]}function H0(e){return e.split("-")[1]}function Oq(e){return e==="x"?"y":"x"}function qq(e){return e==="y"?"height":"width"}function Ir(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Fq(e){return Oq(Ir(e))}function QOe(e,t,n){n===void 0&&(n=!1);const o=H0(e),r=Fq(e),a=qq(r);let i=r==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=QP(i)),[i,QP(i)]}function JOe(e){const t=QP(e);return[HH(e),t,HH(t)]}function HH(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const hW=["left","right"],fW=["right","left"],eqe=["top","bottom"],tqe=["bottom","top"];function nqe(e,t,n){switch(e){case"top":case"bottom":return n?t?fW:hW:t?hW:fW;case"left":case"right":return t?eqe:tqe;default:return[]}}function oqe(e,t,n,o){const r=H0(e);let a=nqe(_a(e),n==="start",o);return r&&(a=a.map(i=>i+"-"+r),t&&(a=a.concat(a.map(HH)))),a}function QP(e){const t=_a(e);return YOe[t]+e.slice(t.length)}function rqe(e){return{top:0,right:0,bottom:0,left:0,...e}}function TJ(e){return typeof e!="number"?rqe(e):{top:e,right:e,bottom:e,left:e}}function JP(e){const{x:t,y:n,width:o,height:r}=e;return{width:o,height:r,top:n,left:t,right:t+o,bottom:n+r,x:t,y:n}}function pW(e,t,n){let{reference:o,floating:r}=e;const a=Ir(t),i=Fq(t),s=qq(i),c=_a(t),l=a==="y",h=o.x+o.width/2-r.width/2,u=o.y+o.height/2-r.height/2,f=o[s]/2-r[s]/2;let y;switch(c){case"top":y={x:h,y:o.y-r.height};break;case"bottom":y={x:h,y:o.y+o.height};break;case"right":y={x:o.x+o.width,y:u};break;case"left":y={x:o.x-r.width,y:u};break;default:y={x:o.x,y:o.y}}switch(H0(t)){case"start":y[i]-=f*(n&&l?-1:1);break;case"end":y[i]+=f*(n&&l?-1:1);break}return y}async function aqe(e,t){var n;t===void 0&&(t={});const{x:o,y:r,platform:a,rects:i,elements:s,strategy:c}=e,{boundary:l="clippingAncestors",rootBoundary:h="viewport",elementContext:u="floating",altBoundary:f=!1,padding:y=0}=ba(t,e),g=TJ(y),x=s[f?u==="floating"?"reference":"floating":u],v=JP(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(x)))==null||n?x:x.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(s.floating)),boundary:l,rootBoundary:h,strategy:c})),M=u==="floating"?{x:o,y:r,width:i.floating.width,height:i.floating.height}:i.reference,w=await(a.getOffsetParent==null?void 0:a.getOffsetParent(s.floating)),b=await(a.isElement==null?void 0:a.isElement(w))?await(a.getScale==null?void 0:a.getScale(w))||{x:1,y:1}:{x:1,y:1},C=JP(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:M,offsetParent:w,strategy:c}):M);return{top:(v.top-C.top+g.top)/b.y,bottom:(C.bottom-v.bottom+g.bottom)/b.y,left:(v.left-C.left+g.left)/b.x,right:(C.right-v.right+g.right)/b.x}}const iqe=50,sqe=async(e,t,n)=>{const{placement:o="bottom",strategy:r="absolute",middleware:a=[],platform:i}=n,s=i.detectOverflow?i:{...i,detectOverflow:aqe},c=await(i.isRTL==null?void 0:i.isRTL(t));let l=await i.getElementRects({reference:e,floating:t,strategy:r}),{x:h,y:u}=pW(l,o,c),f=o,y=0;const g={};for(let k=0;k<a.length;k++){const x=a[k];if(!x)continue;const{name:v,fn:M}=x,{x:w,y:b,data:C,reset:_}=await M({x:h,y:u,initialPlacement:o,placement:f,strategy:r,middlewareData:g,rects:l,platform:s,elements:{reference:e,floating:t}});h=w??h,u=b??u,g[v]={...g[v],...C},_&&y<iqe&&(y++,typeof _=="object"&&(_.placement&&(f=_.placement),_.rects&&(l=_.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:r}):_.rects),{x:h,y:u}=pW(l,f,c)),k=-1)}return{x:h,y:u,placement:f,strategy:r,middlewareData:g}},cqe=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:o,placement:r,rects:a,platform:i,elements:s,middlewareData:c}=t,{element:l,padding:h=0}=ba(e,t)||{};if(l==null)return{};const u=TJ(h),f={x:n,y:o},y=Fq(r),g=qq(y),k=await i.getDimensions(l),x=y==="y",v=x?"top":"left",M=x?"bottom":"right",w=x?"clientHeight":"clientWidth",b=a.reference[g]+a.reference[y]-f[y]-a.floating[g],C=f[y]-a.reference[y],_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l));let S=_?_[w]:0;(!S||!await(i.isElement==null?void 0:i.isElement(_)))&&(S=s.floating[w]||a.floating[g]);const j=b/2-C/2,P=S/2-k[g]/2-1,A=Li(u[v],P),N=Li(u[M],P),R=A,W=S-k[g]-N,$=S/2-k[g]/2+j,H=DH(R,$,W),T=!c.arrow&&H0(r)!=null&&$!==H&&a.reference[g]/2-($<R?A:N)-k[g]/2<0,O=T?$<R?$-R:$-W:0;return{[y]:f[y]+O,data:{[y]:H,centerOffset:$-H-O,...T&&{alignmentOffset:O}},reset:T}}}),lqe=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,o;const{placement:r,middlewareData:a,rects:i,initialPlacement:s,platform:c,elements:l}=t,{mainAxis:h=!0,crossAxis:u=!0,fallbackPlacements:f,fallbackStrategy:y="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:k=!0,...x}=ba(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const v=_a(r),M=Ir(s),w=_a(s)===s,b=await(c.isRTL==null?void 0:c.isRTL(l.floating)),C=f||(w||!k?[QP(s)]:JOe(s)),_=g!=="none";!f&&_&&C.push(...oqe(s,k,g,b));const S=[s,...C],j=await c.detectOverflow(t,x),P=[];let A=((o=a.flip)==null?void 0:o.overflows)||[];if(h&&P.push(j[v]),u){const $=QOe(r,i,b);P.push(j[$[0]],j[$[1]])}if(A=[...A,{placement:r,overflows:P}],!P.every($=>$<=0)){var N,R;const $=(((N=a.flip)==null?void 0:N.index)||0)+1,H=S[$];if(H&&(!(u==="alignment"?M!==Ir(H):!1)||A.every(I=>Ir(I.placement)===M?I.overflows[0]>0:!0)))return{data:{index:$,overflows:A},reset:{placement:H}};let T=(R=A.filter(O=>O.overflows[0]<=0).sort((O,I)=>O.overflows[1]-I.overflows[1])[0])==null?void 0:R.placement;if(!T)switch(y){case"bestFit":{var W;const O=(W=A.filter(I=>{if(_){const z=Ir(I.placement);return z===M||z==="y"}return!0}).map(I=>[I.placement,I.overflows.filter(z=>z>0).reduce((z,L)=>z+L,0)]).sort((I,z)=>I[1]-z[1])[0])==null?void 0:W[0];O&&(T=O);break}case"initialPlacement":T=s;break}if(r!==T)return{reset:{placement:T}}}return{}}}};function yW(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function mW(e){return KOe.some(t=>e[t]>=0)}const dqe=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:o}=t,{strategy:r="referenceHidden",...a}=ba(e,t);switch(r){case"referenceHidden":{const i=await o.detectOverflow(t,{...a,elementContext:"reference"}),s=yW(i,n.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:mW(s)}}}case"escaped":{const i=await o.detectOverflow(t,{...a,altBoundary:!0}),s=yW(i,n.floating);return{data:{escapedOffsets:s,escaped:mW(s)}}}default:return{}}}}},DJ=new Set(["left","top"]);async function uqe(e,t){const{placement:n,platform:o,elements:r}=e,a=await(o.isRTL==null?void 0:o.isRTL(r.floating)),i=_a(n),s=H0(n),c=Ir(n)==="y",l=DJ.has(i)?-1:1,h=a&&c?-1:1,u=ba(t,e);let{mainAxis:f,crossAxis:y,alignmentAxis:g}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return s&&typeof g=="number"&&(y=s==="end"?g*-1:g),c?{x:y*h,y:f*l}:{x:f*l,y:y*h}}const hqe=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,o;const{x:r,y:a,placement:i,middlewareData:s}=t,c=await uqe(t,e);return i===((n=s.offset)==null?void 0:n.placement)&&(o=s.arrow)!=null&&o.alignmentOffset?{}:{x:r+c.x,y:a+c.y,data:{...c,placement:i}}}}},fqe=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:o,placement:r,platform:a}=t,{mainAxis:i=!0,crossAxis:s=!1,limiter:c={fn:v=>{let{x:M,y:w}=v;return{x:M,y:w}}},...l}=ba(e,t),h={x:n,y:o},u=await a.detectOverflow(t,l),f=Ir(_a(r)),y=Oq(f);let g=h[y],k=h[f];if(i){const v=y==="y"?"top":"left",M=y==="y"?"bottom":"right",w=g+u[v],b=g-u[M];g=DH(w,g,b)}if(s){const v=f==="y"?"top":"left",M=f==="y"?"bottom":"right",w=k+u[v],b=k-u[M];k=DH(w,k,b)}const x=c.fn({...t,[y]:g,[f]:k});return{...x,data:{x:x.x-n,y:x.y-o,enabled:{[y]:i,[f]:s}}}}}},pqe=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:o,placement:r,rects:a,middlewareData:i}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=ba(e,t),h={x:n,y:o},u=Ir(r),f=Oq(u);let y=h[f],g=h[u];const k=ba(s,t),x=typeof k=="number"?{mainAxis:k,crossAxis:0}:{mainAxis:0,crossAxis:0,...k};if(c){const w=f==="y"?"height":"width",b=a.reference[f]-a.floating[w]+x.mainAxis,C=a.reference[f]+a.reference[w]-x.mainAxis;y<b?y=b:y>C&&(y=C)}if(l){var v,M;const w=f==="y"?"width":"height",b=DJ.has(_a(r)),C=a.reference[u]-a.floating[w]+(b&&((v=i.offset)==null?void 0:v[u])||0)+(b?0:x.crossAxis),_=a.reference[u]+a.reference[w]+(b?0:((M=i.offset)==null?void 0:M[u])||0)-(b?x.crossAxis:0);g<C?g=C:g>_&&(g=_)}return{[f]:y,[u]:g}}}},yqe=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,o;const{placement:r,rects:a,platform:i,elements:s}=t,{apply:c=()=>{},...l}=ba(e,t),h=await i.detectOverflow(t,l),u=_a(r),f=H0(r),y=Ir(r)==="y",{width:g,height:k}=a.floating;let x,v;u==="top"||u==="bottom"?(x=u,v=f===(await(i.isRTL==null?void 0:i.isRTL(s.floating))?"start":"end")?"left":"right"):(v=u,x=f==="end"?"top":"bottom");const M=k-h.top-h.bottom,w=g-h.left-h.right,b=Li(k-h[x],M),C=Li(g-h[v],w),_=!t.middlewareData.shift;let S=b,j=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(j=w),(o=t.middlewareData.shift)!=null&&o.enabled.y&&(S=M),_&&!f){const A=Jn(h.left,0),N=Jn(h.right,0),R=Jn(h.top,0),W=Jn(h.bottom,0);y?j=g-2*(A!==0||N!==0?A+N:Jn(h.left,h.right)):S=k-2*(R!==0||W!==0?R+W:Jn(h.top,h.bottom))}await c({...t,availableWidth:j,availableHeight:S});const P=await i.getDimensions(s.floating);return g!==P.width||k!==P.height?{reset:{rects:!0}}:{}}}};function Kz(){return typeof window<"u"}function O0(e){return HJ(e)?(e.nodeName||"").toLowerCase():"#document"}function ro(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function qr(e){var t;return(t=(HJ(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function HJ(e){return Kz()?e instanceof Node||e instanceof ro(e).Node:!1}function Xo(e){return Kz()?e instanceof Element||e instanceof ro(e).Element:!1}function Na(e){return Kz()?e instanceof HTMLElement||e instanceof ro(e).HTMLElement:!1}function gW(e){return!Kz()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ro(e).ShadowRoot}function pf(e){const{overflow:t,overflowX:n,overflowY:o,display:r}=Ko(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&r!=="inline"&&r!=="contents"}function mqe(e){return/^(table|td|th)$/.test(O0(e))}function Yz(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const gqe=/transform|translate|scale|rotate|perspective|filter/,kqe=/paint|layout|strict|content/,ns=e=>!!e&&e!=="none";let LT;function Vq(e){const t=Xo(e)?Ko(e):e;return ns(t.transform)||ns(t.translate)||ns(t.scale)||ns(t.rotate)||ns(t.perspective)||!Bq()&&(ns(t.backdropFilter)||ns(t.filter))||gqe.test(t.willChange||"")||kqe.test(t.contain||"")}function vqe(e){let t=Ii(e);for(;Na(t)&&!L0(t);){if(Vq(t))return t;if(Yz(t))return null;t=Ii(t)}return null}function Bq(){return LT==null&&(LT=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),LT}function L0(e){return/^(html|body|#document)$/.test(O0(e))}function Ko(e){return ro(e).getComputedStyle(e)}function Qz(e){return Xo(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ii(e){if(O0(e)==="html")return e;const t=e.assignedSlot||e.parentNode||gW(e)&&e.host||qr(e);return gW(t)?t.host:t}function OJ(e){const t=Ii(e);return L0(t)?e.ownerDocument?e.ownerDocument.body:e.body:Na(t)&&pf(t)?t:OJ(t)}function Vh(e,t,n){var o;t===void 0&&(t=[]),n===void 0&&(n=!0);const r=OJ(e),a=r===((o=e.ownerDocument)==null?void 0:o.body),i=ro(r);if(a){const s=OH(i);return t.concat(i,i.visualViewport||[],pf(r)?r:[],s&&n?Vh(s):[])}else return t.concat(r,Vh(r,[],n))}function OH(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function qJ(e){const t=Ko(e);let n=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const r=Na(e),a=r?e.offsetWidth:n,i=r?e.offsetHeight:o,s=YP(n)!==a||YP(o)!==i;return s&&(n=a,o=i),{width:n,height:o,$:s}}function Uq(e){return Xo(e)?e:e.contextElement}function Ju(e){const t=Uq(e);if(!Na(t))return Pr(1);const n=t.getBoundingClientRect(),{width:o,height:r,$:a}=qJ(t);let i=(a?YP(n.width):n.width)/o,s=(a?YP(n.height):n.height)/r;return(!i||!Number.isFinite(i))&&(i=1),(!s||!Number.isFinite(s))&&(s=1),{x:i,y:s}}const xqe=Pr(0);function FJ(e){const t=ro(e);return!Bq()||!t.visualViewport?xqe:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function wqe(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ro(e)?!1:t}function Ed(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);const r=e.getBoundingClientRect(),a=Uq(e);let i=Pr(1);t&&(o?Xo(o)&&(i=Ju(o)):i=Ju(e));const s=wqe(a,n,o)?FJ(a):Pr(0);let c=(r.left+s.x)/i.x,l=(r.top+s.y)/i.y,h=r.width/i.x,u=r.height/i.y;if(a){const f=ro(a),y=o&&Xo(o)?ro(o):o;let g=f,k=OH(g);for(;k&&o&&y!==g;){const x=Ju(k),v=k.getBoundingClientRect(),M=Ko(k),w=v.left+(k.clientLeft+parseFloat(M.paddingLeft))*x.x,b=v.top+(k.clientTop+parseFloat(M.paddingTop))*x.y;c*=x.x,l*=x.y,h*=x.x,u*=x.y,c+=w,l+=b,g=ro(k),k=OH(g)}}return JP({width:h,height:u,x:c,y:l})}function Jz(e,t){const n=Qz(e).scrollLeft;return t?t.left+n:Ed(qr(e)).left+n}function VJ(e,t){const n=e.getBoundingClientRect(),o=n.left+t.scrollLeft-Jz(e,n),r=n.top+t.scrollTop;return{x:o,y:r}}function Mqe(e){let{elements:t,rect:n,offsetParent:o,strategy:r}=e;const a=r==="fixed",i=qr(o),s=t?Yz(t.floating):!1;if(o===i||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Pr(1);const h=Pr(0),u=Na(o);if((u||!u&&!a)&&((O0(o)!=="body"||pf(i))&&(c=Qz(o)),u)){const y=Ed(o);l=Ju(o),h.x=y.x+o.clientLeft,h.y=y.y+o.clientTop}const f=i&&!u&&!a?VJ(i,c):Pr(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+h.x+f.x,y:n.y*l.y-c.scrollTop*l.y+h.y+f.y}}function bqe(e){return Array.from(e.getClientRects())}function _qe(e){const t=qr(e),n=Qz(e),o=e.ownerDocument.body,r=Jn(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),a=Jn(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight);let i=-n.scrollLeft+Jz(e);const s=-n.scrollTop;return Ko(o).direction==="rtl"&&(i+=Jn(t.clientWidth,o.clientWidth)-r),{width:r,height:a,x:i,y:s}}const kW=25;function Cqe(e,t){const n=ro(e),o=qr(e),r=n.visualViewport;let a=o.clientWidth,i=o.clientHeight,s=0,c=0;if(r){a=r.width,i=r.height;const h=Bq();(!h||h&&t==="fixed")&&(s=r.offsetLeft,c=r.offsetTop)}const l=Jz(o);if(l<=0){const h=o.ownerDocument,u=h.body,f=getComputedStyle(u),y=h.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,g=Math.abs(o.clientWidth-u.clientWidth-y);g<=kW&&(a-=g)}else l<=kW&&(a+=l);return{width:a,height:i,x:s,y:c}}function Sqe(e,t){const n=Ed(e,!0,t==="fixed"),o=n.top+e.clientTop,r=n.left+e.clientLeft,a=Na(e)?Ju(e):Pr(1),i=e.clientWidth*a.x,s=e.clientHeight*a.y,c=r*a.x,l=o*a.y;return{width:i,height:s,x:c,y:l}}function vW(e,t,n){let o;if(t==="viewport")o=Cqe(e,n);else if(t==="document")o=_qe(qr(e));else if(Xo(t))o=Sqe(t,n);else{const r=FJ(e);o={x:t.x-r.x,y:t.y-r.y,width:t.width,height:t.height}}return JP(o)}function BJ(e,t){const n=Ii(e);return n===t||!Xo(n)||L0(n)?!1:Ko(n).position==="fixed"||BJ(n,t)}function Lqe(e,t){const n=t.get(e);if(n)return n;let o=Vh(e,[],!1).filter(s=>Xo(s)&&O0(s)!=="body"),r=null;const a=Ko(e).position==="fixed";let i=a?Ii(e):e;for(;Xo(i)&&!L0(i);){const s=Ko(i),c=Vq(i);!c&&s.position==="fixed"&&(r=null),(a?!c&&!r:!c&&s.position==="static"&&!!r&&(r.position==="absolute"||r.position==="fixed")||pf(i)&&!c&&BJ(e,i))?o=o.filter(h=>h!==i):r=s,i=Ii(i)}return t.set(e,o),o}function Iqe(e){let{element:t,boundary:n,rootBoundary:o,strategy:r}=e;const i=[...n==="clippingAncestors"?Yz(t)?[]:Lqe(t,this._c):[].concat(n),o],s=vW(t,i[0],r);let c=s.top,l=s.right,h=s.bottom,u=s.left;for(let f=1;f<i.length;f++){const y=vW(t,i[f],r);c=Jn(y.top,c),l=Li(y.right,l),h=Li(y.bottom,h),u=Jn(y.left,u)}return{width:l-u,height:h-c,x:u,y:c}}function Nqe(e){const{width:t,height:n}=qJ(e);return{width:t,height:n}}function Aqe(e,t,n){const o=Na(t),r=qr(t),a=n==="fixed",i=Ed(e,!0,a,t);let s={scrollLeft:0,scrollTop:0};const c=Pr(0);function l(){c.x=Jz(r)}if(o||!o&&!a)if((O0(t)!=="body"||pf(r))&&(s=Qz(t)),o){const y=Ed(t,!0,a,t);c.x=y.x+t.clientLeft,c.y=y.y+t.clientTop}else r&&l();a&&!o&&r&&l();const h=r&&!o&&!a?VJ(r,s):Pr(0),u=i.left+s.scrollLeft-c.x-h.x,f=i.top+s.scrollTop-c.y-h.y;return{x:u,y:f,width:i.width,height:i.height}}function IT(e){return Ko(e).position==="static"}function xW(e,t){if(!Na(e)||Ko(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return qr(e)===n&&(n=n.ownerDocument.body),n}function UJ(e,t){const n=ro(e);if(Yz(e))return n;if(!Na(e)){let r=Ii(e);for(;r&&!L0(r);){if(Xo(r)&&!IT(r))return r;r=Ii(r)}return n}let o=xW(e,t);for(;o&&mqe(o)&&IT(o);)o=xW(o,t);return o&&L0(o)&&IT(o)&&!Vq(o)?n:o||vqe(e)||n}const Eqe=async function(e){const t=this.getOffsetParent||UJ,n=this.getDimensions,o=await n(e.floating);return{reference:Aqe(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function $qe(e){return Ko(e).direction==="rtl"}const jqe={convertOffsetParentRelativeRectToViewportRelativeRect:Mqe,getDocumentElement:qr,getClippingRect:Iqe,getOffsetParent:UJ,getElementRects:Eqe,getClientRects:bqe,getDimensions:Nqe,getScale:Ju,isElement:Xo,isRTL:$qe};function WJ(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Pqe(e,t){let n=null,o;const r=qr(e);function a(){var s;clearTimeout(o),(s=n)==null||s.disconnect(),n=null}function i(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();const l=e.getBoundingClientRect(),{left:h,top:u,width:f,height:y}=l;if(s||t(),!f||!y)return;const g=pp(u),k=pp(r.clientWidth-(h+f)),x=pp(r.clientHeight-(u+y)),v=pp(h),w={rootMargin:-g+"px "+-k+"px "+-x+"px "+-v+"px",threshold:Jn(0,Li(1,c))||1};let b=!0;function C(_){const S=_[0].intersectionRatio;if(S!==c){if(!b)return i();S?i(!1,S):o=setTimeout(()=>{i(!1,1e-7)},1e3)}S===1&&!WJ(l,e.getBoundingClientRect())&&i(),b=!1}try{n=new IntersectionObserver(C,{...w,root:r.ownerDocument})}catch{n=new IntersectionObserver(C,w)}n.observe(e)}return i(!0),a}function zqe(e,t,n,o){o===void 0&&(o={});const{ancestorScroll:r=!0,ancestorResize:a=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:s=typeof IntersectionObserver=="function",animationFrame:c=!1}=o,l=Uq(e),h=r||a?[...l?Vh(l):[],...t?Vh(t):[]]:[];h.forEach(v=>{r&&v.addEventListener("scroll",n,{passive:!0}),a&&v.addEventListener("resize",n)});const u=l&&s?Pqe(l,n):null;let f=-1,y=null;i&&(y=new ResizeObserver(v=>{let[M]=v;M&&M.target===l&&y&&t&&(y.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var w;(w=y)==null||w.observe(t)})),n()}),l&&!c&&y.observe(l),t&&y.observe(t));let g,k=c?Ed(e):null;c&&x();function x(){const v=Ed(e);k&&!WJ(k,v)&&n(),k=v,g=requestAnimationFrame(x)}return n(),()=>{var v;h.forEach(M=>{r&&M.removeEventListener("scroll",n),a&&M.removeEventListener("resize",n)}),u==null||u(),(v=y)==null||v.disconnect(),y=null,c&&cancelAnimationFrame(g)}}const Rqe=hqe,Tqe=fqe,Dqe=lqe,Hqe=yqe,Oqe=dqe,wW=cqe,qqe=pqe,Fqe=(e,t,n)=>{const o=new Map,r={platform:jqe,...n},a={...r.platform,_c:o};return sqe(e,t,{...r,platform:a})};var Vqe=typeof document<"u",Bqe=function(){},eP=Vqe?m.useLayoutEffect:Bqe;function ez(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,o,r;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(o=n;o--!==0;)if(!ez(e[o],t[o]))return!1;return!0}if(r=Object.keys(e),n=r.length,n!==Object.keys(t).length)return!1;for(o=n;o--!==0;)if(!{}.hasOwnProperty.call(t,r[o]))return!1;for(o=n;o--!==0;){const a=r[o];if(!(a==="_owner"&&e.$$typeof)&&!ez(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function GJ(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function MW(e,t){const n=GJ(e);return Math.round(t*n)/n}function NT(e){const t=m.useRef(e);return eP(()=>{t.current=e}),t}function Uqe(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:o=[],platform:r,elements:{reference:a,floating:i}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[h,u]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,y]=m.useState(o);ez(f,o)||y(o);const[g,k]=m.useState(null),[x,v]=m.useState(null),M=m.useCallback(I=>{I!==_.current&&(_.current=I,k(I))},[]),w=m.useCallback(I=>{I!==S.current&&(S.current=I,v(I))},[]),b=a||g,C=i||x,_=m.useRef(null),S=m.useRef(null),j=m.useRef(h),P=c!=null,A=NT(c),N=NT(r),R=NT(l),W=m.useCallback(()=>{if(!_.current||!S.current)return;const I={placement:t,strategy:n,middleware:f};N.current&&(I.platform=N.current),Fqe(_.current,S.current,I).then(z=>{const L={...z,isPositioned:R.current!==!1};$.current&&!ez(j.current,L)&&(j.current=L,P0.flushSync(()=>{u(L)}))})},[f,t,n,N,R]);eP(()=>{l===!1&&j.current.isPositioned&&(j.current.isPositioned=!1,u(I=>({...I,isPositioned:!1})))},[l]);const $=m.useRef(!1);eP(()=>($.current=!0,()=>{$.current=!1}),[]),eP(()=>{if(b&&(_.current=b),C&&(S.current=C),b&&C){if(A.current)return A.current(b,C,W);W()}},[b,C,W,A,P]);const H=m.useMemo(()=>({reference:_,floating:S,setReference:M,setFloating:w}),[M,w]),T=m.useMemo(()=>({reference:b,floating:C}),[b,C]),O=m.useMemo(()=>{const I={position:n,left:0,top:0};if(!T.floating)return I;const z=MW(T.floating,h.x),L=MW(T.floating,h.y);return s?{...I,transform:"translate("+z+"px, "+L+"px)",...GJ(T.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:z,top:L}},[n,s,T.floating,h.x,h.y]);return m.useMemo(()=>({...h,update:W,refs:H,elements:T,floatingStyles:O}),[h,W,H,T,O])}const Wqe=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:o,padding:r}=typeof e=="function"?e(n):e;return o&&t(o)?o.current!=null?wW({element:o.current,padding:r}).fn(n):{}:o?wW({element:o,padding:r}).fn(n):{}}}},Gqe=(e,t)=>{const n=Rqe(e);return{name:n.name,fn:n.fn,options:[e,t]}},Zqe=(e,t)=>{const n=Tqe(e);return{name:n.name,fn:n.fn,options:[e,t]}},Xqe=(e,t)=>({fn:qqe(e).fn,options:[e,t]}),Kqe=(e,t)=>{const n=Dqe(e);return{name:n.name,fn:n.fn,options:[e,t]}},Yqe=(e,t)=>{const n=Hqe(e);return{name:n.name,fn:n.fn,options:[e,t]}},Qqe=(e,t)=>{const n=Oqe(e);return{name:n.name,fn:n.fn,options:[e,t]}},Jqe=(e,t)=>{const n=Wqe(e);return{name:n.name,fn:n.fn,options:[e,t]}};var eFe="Arrow",ZJ=m.forwardRef((e,t)=>{const{children:n,width:o=10,height:r=5,...a}=e;return p.jsx(We.svg,{...a,ref:t,width:o,height:r,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:p.jsx("polygon",{points:"0,0 30,0 15,10"})})});ZJ.displayName=eFe;var tFe=ZJ,Wq="Popper",[XJ,q0]=Qo(Wq),[nFe,KJ]=XJ(Wq),YJ=e=>{const{__scopePopper:t,children:n}=e,[o,r]=m.useState(null);return p.jsx(nFe,{scope:t,anchor:o,onAnchorChange:r,children:n})};YJ.displayName=Wq;var QJ="PopperAnchor",JJ=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:o,...r}=e,a=KJ(QJ,n),i=m.useRef(null),s=gt(t,i),c=m.useRef(null);return m.useEffect(()=>{const l=c.current;c.current=(o==null?void 0:o.current)||i.current,l!==c.current&&a.onAnchorChange(c.current)}),o?null:p.jsx(We.div,{...r,ref:s})});JJ.displayName=QJ;var Gq="PopperContent",[oFe,rFe]=XJ(Gq),eee=m.forwardRef((e,t)=>{var Q,te,ne,ie,ke,ge;const{__scopePopper:n,side:o="bottom",sideOffset:r=0,align:a="center",alignOffset:i=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:h=0,sticky:u="partial",hideWhenDetached:f=!1,updatePositionStrategy:y="optimized",onPlaced:g,...k}=e,x=KJ(Gq,n),[v,M]=m.useState(null),w=gt(t,ve=>M(ve)),[b,C]=m.useState(null),_=hJ(b),S=(_==null?void 0:_.width)??0,j=(_==null?void 0:_.height)??0,P=o+(a!=="center"?"-"+a:""),A=typeof h=="number"?h:{top:0,right:0,bottom:0,left:0,...h},N=Array.isArray(l)?l:[l],R=N.length>0,W={padding:A,boundary:N.filter(iFe),altBoundary:R},{refs:$,floatingStyles:H,placement:T,isPositioned:O,middlewareData:I}=Uqe({strategy:"fixed",placement:P,whileElementsMounted:(...ve)=>zqe(...ve,{animationFrame:y==="always"}),elements:{reference:x.anchor},middleware:[Gqe({mainAxis:r+j,alignmentAxis:i}),c&&Zqe({mainAxis:!0,crossAxis:!1,limiter:u==="partial"?Xqe():void 0,...W}),c&&Kqe({...W}),Yqe({...W,apply:({elements:ve,rects:ce,availableWidth:Ce,availableHeight:Re})=>{const{width:st,height:Vt}=ce.reference,It=ve.floating.style;It.setProperty("--radix-popper-available-width",`${Ce}px`),It.setProperty("--radix-popper-available-height",`${Re}px`),It.setProperty("--radix-popper-anchor-width",`${st}px`),It.setProperty("--radix-popper-anchor-height",`${Vt}px`)}}),b&&Jqe({element:b,padding:s}),sFe({arrowWidth:S,arrowHeight:j}),f&&Qqe({strategy:"referenceHidden",...W})]}),[z,L]=oee(T),F=Hr(g);Si(()=>{O&&(F==null||F())},[O,F]);const D=(Q=I.arrow)==null?void 0:Q.x,E=(te=I.arrow)==null?void 0:te.y,K=((ne=I.arrow)==null?void 0:ne.centerOffset)!==0,[X,Y]=m.useState();return Si(()=>{v&&Y(window.getComputedStyle(v).zIndex)},[v]),p.jsx("div",{ref:$.setFloating,"data-radix-popper-content-wrapper":"",style:{...H,transform:O?H.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:X,"--radix-popper-transform-origin":[(ie=I.transformOrigin)==null?void 0:ie.x,(ke=I.transformOrigin)==null?void 0:ke.y].join(" "),...((ge=I.hide)==null?void 0:ge.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:p.jsx(oFe,{scope:n,placedSide:z,onArrowChange:C,arrowX:D,arrowY:E,shouldHideArrow:K,children:p.jsx(We.div,{"data-side":z,"data-align":L,...k,ref:w,style:{...k.style,animation:O?void 0:"none"}})})})});eee.displayName=Gq;var tee="PopperArrow",aFe={top:"bottom",right:"left",bottom:"top",left:"right"},nee=m.forwardRef(function(t,n){const{__scopePopper:o,...r}=t,a=rFe(tee,o),i=aFe[a.placedSide];return p.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:p.jsx(tFe,{...r,ref:n,style:{...r.style,display:"block"}})})});nee.displayName=tee;function iFe(e){return e!==null}var sFe=e=>({name:"transformOrigin",options:e,fn(t){var x,v,M;const{placement:n,rects:o,middlewareData:r}=t,i=((x=r.arrow)==null?void 0:x.centerOffset)!==0,s=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[l,h]=oee(n),u={start:"0%",center:"50%",end:"100%"}[h],f=(((v=r.arrow)==null?void 0:v.x)??0)+s/2,y=(((M=r.arrow)==null?void 0:M.y)??0)+c/2;let g="",k="";return l==="bottom"?(g=i?u:`${f}px`,k=`${-c}px`):l==="top"?(g=i?u:`${f}px`,k=`${o.floating.height+c}px`):l==="right"?(g=`${-c}px`,k=i?u:`${y}px`):l==="left"&&(g=`${o.floating.width+c}px`,k=i?u:`${y}px`),{data:{x:g,y:k}}}});function oee(e){const[t,n="center"]=e.split("-");return[t,n]}var Zq=YJ,eR=JJ,Xq=eee,Kq=nee,cFe="Portal",yf=m.forwardRef((e,t)=>{var s;const{container:n,...o}=e,[r,a]=m.useState(!1);Si(()=>a(!0),[]);const i=n||r&&((s=globalThis==null?void 0:globalThis.document)==null?void 0:s.body);return i?ece.createPortal(p.jsx(We.div,{...o,ref:t}),i):null});yf.displayName=cFe;function lFe(e,t){return m.useReducer((n,o)=>t[n][o]??n,e)}var uo=e=>{const{present:t,children:n}=e,o=dFe(t),r=typeof n=="function"?n({present:o.isPresent}):m.Children.only(n),a=gt(o.ref,uFe(r));return typeof n=="function"||o.isPresent?m.cloneElement(r,{ref:a}):null};uo.displayName="Presence";function dFe(e){const[t,n]=m.useState(),o=m.useRef(null),r=m.useRef(e),a=m.useRef("none"),i=e?"mounted":"unmounted",[s,c]=lFe(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const l=yp(o.current);a.current=s==="mounted"?l:"none"},[s]),Si(()=>{const l=o.current,h=r.current;if(h!==e){const f=a.current,y=yp(l);e?c("MOUNT"):y==="none"||(l==null?void 0:l.display)==="none"?c("UNMOUNT"):c(h&&f!==y?"ANIMATION_OUT":"UNMOUNT"),r.current=e}},[e,c]),Si(()=>{if(t){let l;const h=t.ownerDocument.defaultView??window,u=y=>{const k=yp(o.current).includes(CSS.escape(y.animationName));if(y.target===t&&k&&(c("ANIMATION_END"),!r.current)){const x=t.style.animationFillMode;t.style.animationFillMode="forwards",l=h.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=x)})}},f=y=>{y.target===t&&(a.current=yp(o.current))};return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",u),t.addEventListener("animationend",u),()=>{h.clearTimeout(l),t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",u),t.removeEventListener("animationend",u)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:m.useCallback(l=>{o.current=l?getComputedStyle(l):null,n(l)},[])}}function yp(e){return(e==null?void 0:e.animationName)||"none"}function uFe(e){var o,r;let t=(o=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(r=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var hFe=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},du=new WeakMap,mp=new WeakMap,gp={},AT=0,ree=function(e){return e&&(e.host||ree(e.parentNode))},fFe=function(e,t){return t.map(function(n){if(e.contains(n))return n;var o=ree(n);return o&&e.contains(o)?o:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},pFe=function(e,t,n,o){var r=fFe(t,Array.isArray(e)?e:[e]);gp[n]||(gp[n]=new WeakMap);var a=gp[n],i=[],s=new Set,c=new Set(r),l=function(u){!u||s.has(u)||(s.add(u),l(u.parentNode))};r.forEach(l);var h=function(u){!u||c.has(u)||Array.prototype.forEach.call(u.children,function(f){if(s.has(f))h(f);else try{var y=f.getAttribute(o),g=y!==null&&y!=="false",k=(du.get(f)||0)+1,x=(a.get(f)||0)+1;du.set(f,k),a.set(f,x),i.push(f),k===1&&g&&mp.set(f,!0),x===1&&f.setAttribute(n,"true"),g||f.setAttribute(o,"true")}catch(v){console.error("aria-hidden: cannot operate on ",f,v)}})};return h(t),s.clear(),AT++,function(){i.forEach(function(u){var f=du.get(u)-1,y=a.get(u)-1;du.set(u,f),a.set(u,y),f||(mp.has(u)||u.removeAttribute(o),mp.delete(u)),y||u.removeAttribute(n)}),AT--,AT||(du=new WeakMap,du=new WeakMap,mp=new WeakMap,gp={})}},Yq=function(e,t,n){n===void 0&&(n="data-aria-hidden");var o=Array.from(Array.isArray(e)?e:[e]),r=hFe(e);return r?(o.push.apply(o,Array.from(r.querySelectorAll("[aria-live], script"))),pFe(o,r,n,"aria-hidden")):function(){return null}},Sr=function(){return Sr=Object.assign||function(t){for(var n,o=1,r=arguments.length;o<r;o++){n=arguments[o];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},Sr.apply(this,arguments)};function aee(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]]);return n}function yFe(e,t,n){if(n||arguments.length===2)for(var o=0,r=t.length,a;o<r;o++)(a||!(o in t))&&(a||(a=Array.prototype.slice.call(t,0,o)),a[o]=t[o]);return e.concat(a||Array.prototype.slice.call(t))}var tP="right-scroll-bar-position",nP="width-before-scroll-bar",mFe="with-scroll-bars-hidden",gFe="--removed-body-scroll-bar-size";function ET(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function kFe(e,t){var n=m.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(o){var r=n.value;r!==o&&(n.value=o,n.callback(o,r))}}}})[0];return n.callback=t,n.facade}var vFe=typeof window<"u"?m.useLayoutEffect:m.useEffect,bW=new WeakMap;function xFe(e,t){var n=kFe(null,function(o){return e.forEach(function(r){return ET(r,o)})});return vFe(function(){var o=bW.get(n);if(o){var r=new Set(o),a=new Set(e),i=n.current;r.forEach(function(s){a.has(s)||ET(s,null)}),a.forEach(function(s){r.has(s)||ET(s,i)})}bW.set(n,e)},[e]),n}function wFe(e){return e}function MFe(e,t){t===void 0&&(t=wFe);var n=[],o=!1,r={read:function(){if(o)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(a){var i=t(a,o);return n.push(i),function(){n=n.filter(function(s){return s!==i})}},assignSyncMedium:function(a){for(o=!0;n.length;){var i=n;n=[],i.forEach(a)}n={push:function(s){return a(s)},filter:function(){return n}}},assignMedium:function(a){o=!0;var i=[];if(n.length){var s=n;n=[],s.forEach(a),i=n}var c=function(){var h=i;i=[],h.forEach(a)},l=function(){return Promise.resolve().then(c)};l(),n={push:function(h){i.push(h),l()},filter:function(h){return i=i.filter(h),n}}}};return r}function bFe(e){e===void 0&&(e={});var t=MFe(null);return t.options=Sr({async:!0,ssr:!1},e),t}var iee=function(e){var t=e.sideCar,n=aee(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var o=t.read();if(!o)throw new Error("Sidecar medium not found");return m.createElement(o,Sr({},n))};iee.isSideCarExport=!0;function _Fe(e,t){return e.useMedium(t),iee}var see=bFe(),$T=function(){},tR=m.forwardRef(function(e,t){var n=m.useRef(null),o=m.useState({onScrollCapture:$T,onWheelCapture:$T,onTouchMoveCapture:$T}),r=o[0],a=o[1],i=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,h=e.enabled,u=e.shards,f=e.sideCar,y=e.noRelative,g=e.noIsolation,k=e.inert,x=e.allowPinchZoom,v=e.as,M=v===void 0?"div":v,w=e.gapMode,b=aee(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=f,_=xFe([n,t]),S=Sr(Sr({},b),r);return m.createElement(m.Fragment,null,h&&m.createElement(C,{sideCar:see,removeScrollBar:l,shards:u,noRelative:y,noIsolation:g,inert:k,setCallbacks:a,allowPinchZoom:!!x,lockRef:n,gapMode:w}),i?m.cloneElement(m.Children.only(s),Sr(Sr({},S),{ref:_})):m.createElement(M,Sr({},S,{className:c,ref:_}),s))});tR.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};tR.classNames={fullWidth:nP,zeroRight:tP};var CFe=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function SFe(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=CFe();return t&&e.setAttribute("nonce",t),e}function LFe(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function IFe(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var NFe=function(){var e=0,t=null;return{add:function(n){e==0&&(t=SFe())&&(LFe(t,n),IFe(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},AFe=function(){var e=NFe();return function(t,n){m.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},cee=function(){var e=AFe(),t=function(n){var o=n.styles,r=n.dynamic;return e(o,r),null};return t},EFe={left:0,top:0,right:0,gap:0},jT=function(e){return parseInt(e||"",10)||0},$Fe=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],o=t[e==="padding"?"paddingTop":"marginTop"],r=t[e==="padding"?"paddingRight":"marginRight"];return[jT(n),jT(o),jT(r)]},jFe=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return EFe;var t=$Fe(e),n=document.documentElement.clientWidth,o=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,o-n+t[2]-t[0])}},PFe=cee(),e0="data-scroll-locked",zFe=function(e,t,n,o){var r=e.left,a=e.top,i=e.right,s=e.gap;return n===void 0&&(n="margin"),`
|
|
8470
8470
|
.`.concat(mFe,` {
|
|
8471
8471
|
overflow: hidden `).concat(o,`;
|
|
8472
8472
|
padding-right: `).concat(s,"px ").concat(o,`;
|
|
@@ -8538,10 +8538,10 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
8538
8538
|
`))+1))}const i="#".repeat(r),s=n.enter("headingAtx"),c=n.enter("phrasing");a.move(i+" ");let l=n.containerPhrasing(e,{before:"# ",after:`
|
|
8539
8539
|
`,...a.current()});return/^[\t ]/.test(l)&&(l=Kh(l.charCodeAt(0))+l.slice(1)),l=l?i+" "+l:i,n.options.closeAtx&&(l+=" "+i),c(),s(),l}Uoe.peek=ZQe;function Uoe(e){return e.value||""}function ZQe(){return"<"}Woe.peek=XQe;function Woe(e,t,n,o){const r=HF(n),a=r==='"'?"Quote":"Apostrophe",i=n.enter("image");let s=n.enter("label");const c=n.createTracker(o);let l=c.move("![");return l+=c.move(n.safe(e.alt,{before:l,after:"]",...c.current()})),l+=c.move("]("),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter("destinationLiteral"),l+=c.move("<"),l+=c.move(n.safe(e.url,{before:l,after:">",...c.current()})),l+=c.move(">")):(s=n.enter("destinationRaw"),l+=c.move(n.safe(e.url,{before:l,after:e.title?" ":")",...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(" "+r),l+=c.move(n.safe(e.title,{before:l,after:r,...c.current()})),l+=c.move(r),s()),l+=c.move(")"),i(),l}function XQe(){return"!"}Goe.peek=KQe;function Goe(e,t,n,o){const r=e.referenceType,a=n.enter("imageReference");let i=n.enter("label");const s=n.createTracker(o);let c=s.move("![");const l=n.safe(e.alt,{before:c,after:"]",...s.current()});c+=s.move(l+"]["),i();const h=n.stack;n.stack=[],i=n.enter("reference");const u=n.safe(n.associationId(e),{before:c,after:"]",...s.current()});return i(),n.stack=h,a(),r==="full"||!l||l!==u?c+=s.move(u+"]"):r==="shortcut"?c=c.slice(0,-1):c+=s.move("]"),c}function KQe(){return"!"}Zoe.peek=YQe;function Zoe(e,t,n){let o=e.value||"",r="`",a=-1;for(;new RegExp("(^|[^`])"+r+"([^`]|$)").test(o);)r+="`";for(/[^ \r\n]/.test(o)&&(/^[ \r\n]/.test(o)&&/[ \r\n]$/.test(o)||/^`|`$/.test(o))&&(o=" "+o+" ");++a<n.unsafe.length;){const i=n.unsafe[a],s=n.compilePattern(i);let c;if(i.atBreak)for(;c=s.exec(o);){let l=c.index;o.charCodeAt(l)===10&&o.charCodeAt(l-1)===13&&l--,o=o.slice(0,l)+" "+o.slice(c.index+1)}}return r+o+r}function YQe(){return"`"}function Xoe(e,t){const n=AF(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}Koe.peek=QQe;function Koe(e,t,n,o){const r=HF(n),a=r==='"'?"Quote":"Apostrophe",i=n.createTracker(o);let s,c;if(Xoe(e,n)){const h=n.stack;n.stack=[],s=n.enter("autolink");let u=i.move("<");return u+=i.move(n.containerPhrasing(e,{before:u,after:">",...i.current()})),u+=i.move(">"),s(),n.stack=h,u}s=n.enter("link"),c=n.enter("label");let l=i.move("[");return l+=i.move(n.containerPhrasing(e,{before:l,after:"](",...i.current()})),l+=i.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),l+=i.move("<"),l+=i.move(n.safe(e.url,{before:l,after:">",...i.current()})),l+=i.move(">")):(c=n.enter("destinationRaw"),l+=i.move(n.safe(e.url,{before:l,after:e.title?" ":")",...i.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=i.move(" "+r),l+=i.move(n.safe(e.title,{before:l,after:r,...i.current()})),l+=i.move(r),c()),l+=i.move(")"),s(),l}function QQe(e,t,n){return Xoe(e,n)?"<":"["}Yoe.peek=JQe;function Yoe(e,t,n,o){const r=e.referenceType,a=n.enter("linkReference");let i=n.enter("label");const s=n.createTracker(o);let c=s.move("[");const l=n.containerPhrasing(e,{before:c,after:"]",...s.current()});c+=s.move(l+"]["),i();const h=n.stack;n.stack=[],i=n.enter("reference");const u=n.safe(n.associationId(e),{before:c,after:"]",...s.current()});return i(),n.stack=h,a(),r==="full"||!l||l!==u?c+=s.move(u+"]"):r==="shortcut"?c=c.slice(0,-1):c+=s.move("]"),c}function JQe(){return"["}function OF(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function eJe(e){const t=OF(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function tJe(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Qoe(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function nJe(e,t,n,o){const r=n.enter("list"),a=n.bulletCurrent;let i=e.ordered?tJe(n):OF(n);const s=e.ordered?i==="."?")":".":eJe(n);let c=t&&n.bulletLastUsed?i===n.bulletLastUsed:!1;if(!e.ordered){const h=e.children?e.children[0]:void 0;if((i==="*"||i==="-")&&h&&(!h.children||!h.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),Qoe(n)===i&&h){let u=-1;for(;++u<e.children.length;){const f=e.children[u];if(f&&f.type==="listItem"&&f.children&&f.children[0]&&f.children[0].type==="thematicBreak"){c=!0;break}}}}c&&(i=s),n.bulletCurrent=i;const l=n.containerFlow(e,o);return n.bulletLastUsed=i,n.bulletCurrent=a,r(),l}function oJe(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function rJe(e,t,n,o){const r=oJe(n);let a=n.bulletCurrent||OF(n);t&&t.type==="list"&&t.ordered&&(a=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let i=a.length+1;(r==="tab"||r==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(i=Math.ceil(i/4)*4);const s=n.createTracker(o);s.move(a+" ".repeat(i-a.length)),s.shift(i);const c=n.enter("listItem"),l=n.indentLines(n.containerFlow(e,s.current()),h);return c(),l;function h(u,f,y){return f?(y?"":" ".repeat(i))+u:(y?a:a+" ".repeat(i-a.length))+u}}function aJe(e,t,n,o){const r=n.enter("paragraph"),a=n.enter("phrasing"),i=n.containerPhrasing(e,o);return a(),r(),i}const iJe=_R(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function sJe(e,t,n,o){return(e.children.some(function(i){return iJe(i)})?n.containerPhrasing:n.containerFlow).call(n,e,o)}function cJe(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Joe.peek=lJe;function Joe(e,t,n,o){const r=cJe(n),a=n.enter("strong"),i=n.createTracker(o),s=i.move(r+r);let c=i.move(n.containerPhrasing(e,{after:r,before:s,...i.current()}));const l=c.charCodeAt(0),h=lz(o.before.charCodeAt(o.before.length-1),l,r);h.inside&&(c=Kh(l)+c.slice(1));const u=c.charCodeAt(c.length-1),f=lz(o.after.charCodeAt(0),u,r);f.inside&&(c=c.slice(0,-1)+Kh(u));const y=i.move(r+r);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:h.outside},s+c+y}function lJe(e,t,n){return n.options.strong||"*"}function dJe(e,t,n,o){return n.safe(e.value,o)}function uJe(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function hJe(e,t,n){const o=(Qoe(n)+(n.options.ruleSpaces?" ":"")).repeat(uJe(n));return n.options.ruleSpaces?o.slice(0,-1):o}const ere={blockquote:zQe,break:RG,code:qQe,definition:VQe,emphasis:Boe,hardBreak:RG,heading:GQe,html:Uoe,image:Woe,imageReference:Goe,inlineCode:Zoe,link:Koe,linkReference:Yoe,list:nJe,listItem:rJe,paragraph:aJe,root:sJe,strong:Joe,text:dJe,thematicBreak:hJe};function fJe(){return{enter:{table:pJe,tableData:TG,tableHeader:TG,tableRow:mJe},exit:{codeText:gJe,table:yJe,tableData:eD,tableHeader:eD,tableRow:eD}}}function pJe(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function yJe(e){this.exit(e),this.data.inTable=void 0}function mJe(e){this.enter({type:"tableRow",children:[]},e)}function eD(e){this.exit(e)}function TG(e){this.enter({type:"tableCell",children:[]},e)}function gJe(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,kJe));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function kJe(e,t){return t==="|"?t:e}function vJe(e){const t=e||{},n=t.tableCellPadding,o=t.tablePipeAlign,r=t.stringLength,a=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
8540
8540
|
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:f,table:i,tableCell:c,tableRow:s}};function i(y,g,k,x){return l(h(y,k,x),y.align)}function s(y,g,k,x){const v=u(y,k,x),M=l([v]);return M.slice(0,M.indexOf(`
|
|
8541
|
-
`))}function c(y,g,k,x){const v=k.enter("tableCell"),M=k.enter("phrasing"),w=k.containerPhrasing(y,{...x,before:a,after:a});return M(),v(),w}function l(y,g){return jQe(y,{align:g,alignDelimiters:o,padding:n,stringLength:r})}function h(y,g,k){const x=y.children;let v=-1;const M=[],w=g.enter("table");for(;++v<x.length;)M[v]=u(x[v],g,k);return w(),M}function u(y,g,k){const x=y.children;let v=-1;const M=[],w=g.enter("tableRow");for(;++v<x.length;)M[v]=c(x[v],y,g,k);return w(),M}function f(y,g,k){let x=ere.inlineCode(y,g,k);return k.stack.includes("tableCell")&&(x=x.replace(/\|/g,"\\$&")),x}}function xJe(){return{exit:{taskListCheckValueChecked:DG,taskListCheckValueUnchecked:DG,paragraph:MJe}}}function wJe(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:bJe}}}function DG(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function MJe(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const o=n.children[0];if(o&&o.type==="text"){const r=t.children;let a=-1,i;for(;++a<r.length;){const s=r[a];if(s.type==="paragraph"){i=s;break}}i===n&&(o.value=o.value.slice(1),o.value.length===0?n.children.shift():n.position&&o.position&&typeof o.position.start.offset=="number"&&(o.position.start.column++,o.position.start.offset++,n.position.start=Object.assign({},o.position.start)))}}this.exit(e)}function bJe(e,t,n,o){const r=e.children[0],a=typeof e.checked=="boolean"&&r&&r.type==="paragraph",i="["+(e.checked?"x":" ")+"] ",s=n.createTracker(o);a&&s.move(i);let c=ere.listItem(e,t,n,{...o,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(h){return h+i}}function _Je(){return[nQe(),bQe(),LQe(),fJe(),xJe()]}function CJe(e){return{extensions:[oQe(),_Qe(e),IQe(),vJe(e),wJe()]}}const SJe={tokenize:$Je,partial:!0},tre={tokenize:jJe,partial:!0},nre={tokenize:PJe,partial:!0},ore={tokenize:zJe,partial:!0},LJe={tokenize:RJe,partial:!0},rre={name:"wwwAutolink",tokenize:AJe,previous:ire},are={name:"protocolAutolink",tokenize:EJe,previous:sre},Aa={name:"emailAutolink",tokenize:NJe,previous:cre},Fr={};function IJe(){return{text:Fr}}let os=48;for(;os<123;)Fr[os]=Aa,os++,os===58?os=65:os===91&&(os=97);Fr[43]=Aa;Fr[45]=Aa;Fr[46]=Aa;Fr[95]=Aa;Fr[72]=[Aa,are];Fr[104]=[Aa,are];Fr[87]=[Aa,rre];Fr[119]=[Aa,rre];function NJe(e,t,n){const o=this;let r,a;return i;function i(u){return!cO(u)||!cre.call(o,o.previous)||qF(o.events)?n(u):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),s(u))}function s(u){return cO(u)?(e.consume(u),s):u===64?(e.consume(u),c):n(u)}function c(u){return u===46?e.check(LJe,h,l)(u):u===45||u===95||mn(u)?(a=!0,e.consume(u),c):h(u)}function l(u){return e.consume(u),r=!0,c}function h(u){return a&&r&&Cn(o.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(u)):n(u)}}function AJe(e,t,n){const o=this;return r;function r(i){return i!==87&&i!==119||!ire.call(o,o.previous)||qF(o.events)?n(i):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(SJe,e.attempt(tre,e.attempt(nre,a),n),n)(i))}function a(i){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(i)}}function EJe(e,t,n){const o=this;let r="",a=!1;return i;function i(u){return(u===72||u===104)&&sre.call(o,o.previous)&&!qF(o.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),r+=String.fromCodePoint(u),e.consume(u),s):n(u)}function s(u){if(Cn(u)&&r.length<5)return r+=String.fromCodePoint(u),e.consume(u),s;if(u===58){const f=r.toLowerCase();if(f==="http"||f==="https")return e.consume(u),c}return n(u)}function c(u){return u===47?(e.consume(u),a?l:(a=!0,c)):n(u)}function l(u){return u===null||iz(u)||mt(u)||Pd(u)||wR(u)?n(u):e.attempt(tre,e.attempt(nre,h),n)(u)}function h(u){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(u)}}function $Je(e,t,n){let o=0;return r;function r(i){return(i===87||i===119)&&o<3?(o++,e.consume(i),r):i===46&&o===3?(e.consume(i),a):n(i)}function a(i){return i===null?n(i):t(i)}}function jJe(e,t,n){let o,r,a;return i;function i(l){return l===46||l===95?e.check(ore,c,s)(l):l===null||mt(l)||Pd(l)||l!==45&&wR(l)?c(l):(a=!0,e.consume(l),i)}function s(l){return l===95?o=!0:(r=o,o=void 0),e.consume(l),i}function c(l){return r||o||!a?n(l):t(l)}}function PJe(e,t){let n=0,o=0;return r;function r(i){return i===40?(n++,e.consume(i),r):i===41&&o<n?a(i):i===33||i===34||i===38||i===39||i===41||i===42||i===44||i===46||i===58||i===59||i===60||i===63||i===93||i===95||i===126?e.check(ore,t,a)(i):i===null||mt(i)||Pd(i)?t(i):(e.consume(i),r)}function a(i){return i===41&&o++,e.consume(i),r}}function zJe(e,t,n){return o;function o(s){return s===33||s===34||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===63||s===95||s===126?(e.consume(s),o):s===38?(e.consume(s),a):s===93?(e.consume(s),r):s===60||s===null||mt(s)||Pd(s)?t(s):n(s)}function r(s){return s===null||s===40||s===91||mt(s)||Pd(s)?t(s):o(s)}function a(s){return Cn(s)?i(s):n(s)}function i(s){return s===59?(e.consume(s),o):Cn(s)?(e.consume(s),i):n(s)}}function RJe(e,t,n){return o;function o(a){return e.consume(a),r}function r(a){return mn(a)?n(a):t(a)}}function ire(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||mt(e)}function sre(e){return!Cn(e)}function cre(e){return!(e===47||cO(e))}function cO(e){return e===43||e===45||e===46||e===95||mn(e)}function qF(e){let t=e.length,n=!1;for(;t--;){const o=e[t][1];if((o.type==="labelLink"||o.type==="labelImage")&&!o._balanced){n=!0;break}if(o._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const TJe={tokenize:UJe,partial:!0};function DJe(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:FJe,continuation:{tokenize:VJe},exit:BJe}},text:{91:{name:"gfmFootnoteCall",tokenize:qJe},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:HJe,resolveTo:OJe}}}}function HJe(e,t,n){const o=this;let r=o.events.length;const a=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]);let i;for(;r--;){const c=o.events[r][1];if(c.type==="labelImage"){i=c;break}if(c.type==="gfmFootnoteCall"||c.type==="labelLink"||c.type==="label"||c.type==="image"||c.type==="link")break}return s;function s(c){if(!i||!i._balanced)return n(c);const l=Go(o.sliceSerialize({start:i.end,end:o.now()}));return l.codePointAt(0)!==94||!a.includes(l.slice(1))?n(c):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),t(c))}}function OJe(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const o={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},r={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};r.end.column++,r.end.offset++,r.end._bufferIndex++;const a={type:"gfmFootnoteCallString",start:Object.assign({},r.end),end:Object.assign({},e[e.length-1][1].start)},i={type:"chunkString",contentType:"string",start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],["enter",o,t],e[n+3],e[n+4],["enter",r,t],["exit",r,t],["enter",a,t],["enter",i,t],["exit",i,t],["exit",a,t],e[e.length-2],e[e.length-1],["exit",o,t]];return e.splice(n,e.length-n+1,...s),e}function qJe(e,t,n){const o=this,r=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]);let a=0,i;return s;function s(u){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(u),e.exit("gfmFootnoteCallLabelMarker"),c}function c(u){return u!==94?n(u):(e.enter("gfmFootnoteCallMarker"),e.consume(u),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",l)}function l(u){if(a>999||u===93&&!i||u===null||u===91||mt(u))return n(u);if(u===93){e.exit("chunkString");const f=e.exit("gfmFootnoteCallString");return r.includes(Go(o.sliceSerialize(f)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(u),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(u)}return mt(u)||(i=!0),a++,e.consume(u),u===92?h:l}function h(u){return u===91||u===92||u===93?(e.consume(u),a++,l):l(u)}}function FJe(e,t,n){const o=this,r=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]);let a,i=0,s;return c;function c(g){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),l}function l(g){return g===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",h):n(g)}function h(g){if(i>999||g===93&&!s||g===null||g===91||mt(g))return n(g);if(g===93){e.exit("chunkString");const k=e.exit("gfmFootnoteDefinitionLabelString");return a=Go(o.sliceSerialize(k)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),f}return mt(g)||(s=!0),i++,e.consume(g),g===92?u:h}function u(g){return g===91||g===92||g===93?(e.consume(g),i++,h):h(g)}function f(g){return g===58?(e.enter("definitionMarker"),e.consume(g),e.exit("definitionMarker"),r.includes(a)||r.push(a),tt(e,y,"gfmFootnoteDefinitionWhitespace")):n(g)}function y(g){return t(g)}}function VJe(e,t,n){return e.check(Sf,t,e.attempt(TJe,t,n))}function BJe(e){e.exit("gfmFootnoteDefinition")}function UJe(e,t,n){const o=this;return tt(e,r,"gfmFootnoteDefinitionIndent",5);function r(a){const i=o.events[o.events.length-1];return i&&i[1].type==="gfmFootnoteDefinitionIndent"&&i[2].sliceSerialize(i[1],!0).length===4?t(a):n(a)}}function WJe(e){let n=(e||{}).singleTilde;const o={name:"strikethrough",tokenize:a,resolveAll:r};return n==null&&(n=!0),{text:{126:o},insideSpan:{null:[o]},attentionMarkers:{null:[126]}};function r(i,s){let c=-1;for(;++c<i.length;)if(i[c][0]==="enter"&&i[c][1].type==="strikethroughSequenceTemporary"&&i[c][1]._close){let l=c;for(;l--;)if(i[l][0]==="exit"&&i[l][1].type==="strikethroughSequenceTemporary"&&i[l][1]._open&&i[c][1].end.offset-i[c][1].start.offset===i[l][1].end.offset-i[l][1].start.offset){i[c][1].type="strikethroughSequence",i[l][1].type="strikethroughSequence";const h={type:"strikethrough",start:Object.assign({},i[l][1].start),end:Object.assign({},i[c][1].end)},u={type:"strikethroughText",start:Object.assign({},i[l][1].end),end:Object.assign({},i[c][1].start)},f=[["enter",h,s],["enter",i[l][1],s],["exit",i[l][1],s],["enter",u,s]],y=s.parser.constructs.insideSpan.null;y&&ao(f,f.length,0,MR(y,i.slice(l+1,c),s)),ao(f,f.length,0,[["exit",u,s],["enter",i[c][1],s],["exit",i[c][1],s],["exit",h,s]]),ao(i,l-1,c-l+3,f),c=l+f.length-2;break}}for(c=-1;++c<i.length;)i[c][1].type==="strikethroughSequenceTemporary"&&(i[c][1].type="data");return i}function a(i,s,c){const l=this.previous,h=this.events;let u=0;return f;function f(g){return l===126&&h[h.length-1][1].type!=="characterEscape"?c(g):(i.enter("strikethroughSequenceTemporary"),y(g))}function y(g){const k=A0(l);if(g===126)return u>1?c(g):(i.consume(g),u++,y);if(u<2&&!n)return c(g);const x=i.exit("strikethroughSequenceTemporary"),v=A0(g);return x._open=!v||v===2&&!!k,x._close=!k||k===2&&!!v,s(g)}}}class GJe{constructor(){this.map=[]}add(t,n,o){ZJe(this,t,n,o)}consume(t){if(this.map.sort(function(a,i){return a[0]-i[0]}),this.map.length===0)return;let n=this.map.length;const o=[];for(;n>0;)n-=1,o.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];o.push(t.slice()),t.length=0;let r=o.pop();for(;r;){for(const a of r)t.push(a);r=o.pop()}this.map.length=0}}function ZJe(e,t,n,o){let r=0;if(!(n===0&&o.length===0)){for(;r<e.map.length;){if(e.map[r][0]===t){e.map[r][1]+=n,e.map[r][2].push(...o);return}r+=1}e.map.push([t,n,o])}}function XJe(e,t){let n=!1;const o=[];for(;t<e.length;){const r=e[t];if(n){if(r[0]==="enter")r[1].type==="tableContent"&&o.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(r[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const a=o.length-1;o[a]=o[a]==="left"?"center":"right"}}else if(r[1].type==="tableDelimiterRow")break}else r[0]==="enter"&&r[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return o}function KJe(){return{flow:{null:{name:"table",tokenize:YJe,resolveAll:QJe}}}}function YJe(e,t,n){const o=this;let r=0,a=0,i;return s;function s(A){let N=o.events.length-1;for(;N>-1;){const $=o.events[N][1].type;if($==="lineEnding"||$==="linePrefix")N--;else break}const R=N>-1?o.events[N][1].type:null,W=R==="tableHead"||R==="tableRow"?_:c;return W===_&&o.parser.lazy[o.now().line]?n(A):W(A)}function c(A){return e.enter("tableHead"),e.enter("tableRow"),l(A)}function l(A){return A===124||(i=!0,a+=1),h(A)}function h(A){return A===null?n(A):Pe(A)?a>1?(a=0,o.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),y):n(A):Ye(A)?tt(e,h,"whitespace")(A):(a+=1,i&&(i=!1,r+=1),A===124?(e.enter("tableCellDivider"),e.consume(A),e.exit("tableCellDivider"),i=!0,h):(e.enter("data"),u(A)))}function u(A){return A===null||A===124||mt(A)?(e.exit("data"),h(A)):(e.consume(A),A===92?f:u)}function f(A){return A===92||A===124?(e.consume(A),u):u(A)}function y(A){return o.interrupt=!1,o.parser.lazy[o.now().line]?n(A):(e.enter("tableDelimiterRow"),i=!1,Ye(A)?tt(e,g,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):g(A))}function g(A){return A===45||A===58?x(A):A===124?(i=!0,e.enter("tableCellDivider"),e.consume(A),e.exit("tableCellDivider"),k):C(A)}function k(A){return Ye(A)?tt(e,x,"whitespace")(A):x(A)}function x(A){return A===58?(a+=1,i=!0,e.enter("tableDelimiterMarker"),e.consume(A),e.exit("tableDelimiterMarker"),v):A===45?(a+=1,v(A)):A===null||Pe(A)?b(A):C(A)}function v(A){return A===45?(e.enter("tableDelimiterFiller"),M(A)):C(A)}function M(A){return A===45?(e.consume(A),M):A===58?(i=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(A),e.exit("tableDelimiterMarker"),w):(e.exit("tableDelimiterFiller"),w(A))}function w(A){return Ye(A)?tt(e,b,"whitespace")(A):b(A)}function b(A){return A===124?g(A):A===null||Pe(A)?!i||r!==a?C(A):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(A)):C(A)}function C(A){return n(A)}function _(A){return e.enter("tableRow"),S(A)}function S(A){return A===124?(e.enter("tableCellDivider"),e.consume(A),e.exit("tableCellDivider"),S):A===null||Pe(A)?(e.exit("tableRow"),t(A)):Ye(A)?tt(e,S,"whitespace")(A):(e.enter("data"),j(A))}function j(A){return A===null||A===124||mt(A)?(e.exit("data"),S(A)):(e.consume(A),A===92?P:j)}function P(A){return A===92||A===124?(e.consume(A),j):j(A)}}function QJe(e,t){let n=-1,o=!0,r=0,a=[0,0,0,0],i=[0,0,0,0],s=!1,c=0,l,h,u;const f=new GJe;for(;++n<e.length;){const y=e[n],g=y[1];y[0]==="enter"?g.type==="tableHead"?(s=!1,c!==0&&(HG(f,t,c,l,h),h=void 0,c=0),l={type:"table",start:Object.assign({},g.start),end:Object.assign({},g.end)},f.add(n,0,[["enter",l,t]])):g.type==="tableRow"||g.type==="tableDelimiterRow"?(o=!0,u=void 0,a=[0,0,0,0],i=[0,n+1,0,0],s&&(s=!1,h={type:"tableBody",start:Object.assign({},g.start),end:Object.assign({},g.end)},f.add(n,0,[["enter",h,t]])),r=g.type==="tableDelimiterRow"?2:h?3:1):r&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")?(o=!1,i[2]===0&&(a[1]!==0&&(i[0]=i[1],u=Ap(f,t,a,r,void 0,u),a=[0,0,0,0]),i[2]=n)):g.type==="tableCellDivider"&&(o?o=!1:(a[1]!==0&&(i[0]=i[1],u=Ap(f,t,a,r,void 0,u)),a=i,i=[a[1],n,0,0])):g.type==="tableHead"?(s=!0,c=n):g.type==="tableRow"||g.type==="tableDelimiterRow"?(c=n,a[1]!==0?(i[0]=i[1],u=Ap(f,t,a,r,n,u)):i[1]!==0&&(u=Ap(f,t,i,r,n,u)),r=0):r&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")&&(i[3]=n)}for(c!==0&&HG(f,t,c,l,h),f.consume(t.events),n=-1;++n<t.events.length;){const y=t.events[n];y[0]==="enter"&&y[1].type==="table"&&(y[1]._align=XJe(t.events,n))}return e}function Ap(e,t,n,o,r,a){const i=o===1?"tableHeader":o===2?"tableDelimiter":"tableData",s="tableContent";n[0]!==0&&(a.end=Object.assign({},Mu(t.events,n[0])),e.add(n[0],0,[["exit",a,t]]));const c=Mu(t.events,n[1]);if(a={type:i,start:Object.assign({},c),end:Object.assign({},c)},e.add(n[1],0,[["enter",a,t]]),n[2]!==0){const l=Mu(t.events,n[2]),h=Mu(t.events,n[3]),u={type:s,start:Object.assign({},l),end:Object.assign({},h)};if(e.add(n[2],0,[["enter",u,t]]),o!==2){const f=t.events[n[2]],y=t.events[n[3]];if(f[1].end=Object.assign({},y[1].end),f[1].type="chunkText",f[1].contentType="text",n[3]>n[2]+1){const g=n[2]+1,k=n[3]-n[2]-1;e.add(g,k,[])}}e.add(n[3]+1,0,[["exit",u,t]])}return r!==void 0&&(a.end=Object.assign({},Mu(t.events,r)),e.add(r,0,[["exit",a,t]]),a=void 0),a}function HG(e,t,n,o,r){const a=[],i=Mu(t.events,n);r&&(r.end=Object.assign({},i),a.push(["exit",r,t])),o.end=Object.assign({},i),a.push(["exit",o,t]),e.add(n+1,0,a)}function Mu(e,t){const n=e[t],o=n[0]==="enter"?"start":"end";return n[1][o]}const JJe={name:"tasklistCheck",tokenize:tet};function eet(){return{text:{91:JJe}}}function tet(e,t,n){const o=this;return r;function r(c){return o.previous!==null||!o._gfmTasklistFirstContentOfListItem?n(c):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),a)}function a(c){return mt(c)?(e.enter("taskListCheckValueUnchecked"),e.consume(c),e.exit("taskListCheckValueUnchecked"),i):c===88||c===120?(e.enter("taskListCheckValueChecked"),e.consume(c),e.exit("taskListCheckValueChecked"),i):n(c)}function i(c){return c===93?(e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),s):n(c)}function s(c){return Pe(c)?t(c):Ye(c)?e.check({tokenize:net},t,n)(c):n(c)}}function net(e,t,n){return tt(e,o,"whitespace");function o(r){return r===null?n(r):t(r)}}function oet(e){return koe([IJe(),DJe(),WJe(e),KJe(),eet()])}const ret={};function aet(e){const t=this,n=e||ret,o=t.data(),r=o.micromarkExtensions||(o.micromarkExtensions=[]),a=o.fromMarkdownExtensions||(o.fromMarkdownExtensions=[]),i=o.toMarkdownExtensions||(o.toMarkdownExtensions=[]);r.push(oet(n)),a.push(_Je()),i.push(CJe(n))}let Ep=null,iet=0;function set(){return Ep||(Ep=hf(()=>import("./mermaid.core-1G8gw6AK.js").then(e=>e.ak),__vite__mapDeps([8,9,1])).then(e=>{const t=e;return t.default??t}),Ep)}function OG(){var e;return typeof document>"u"?!1:document.documentElement.classList.contains("dark")||(e=document.body)!=null&&e.classList.contains("dark")?!0:!!document.querySelector(".dark")}function qG({code:e,className:t}){const n=m.useRef(null),o=m.useRef(`seeflow-mermaid-${++iet}`),[r,a]=m.useState(null),[i,s]=m.useState(()=>OG());return m.useEffect(()=>{if(typeof document>"u")return;const c=()=>s(OG()),l=new MutationObserver(c);return l.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),document.body&&l.observe(document.body,{attributes:!0,attributeFilter:["class"]}),()=>l.disconnect()},[]),m.useEffect(()=>{let c=!1;return a(null),set().then(async l=>{l.initialize({startOnLoad:!1,theme:i?"dark":"default",securityLevel:"strict",fontFamily:'"Inter", ui-sans-serif, system-ui, sans-serif'});const h=`${o.current}-${i?"d":"l"}`,u=await l.render(h,e);if(c)return;const f=n.current;f&&(f.innerHTML=u.svg)}).catch(l=>{c||a(l instanceof Error?l.message:String(l))}),()=>{c=!0}},[e,i]),r?p.jsx("pre",{"data-testid":"detail-panel-mermaid-fallback","data-mermaid-error":"true",title:r,className:oe("sf:mb-2 sf:overflow-x-auto sf:rounded sf:bg-muted/60 sf:px-2 sf:py-1 sf:font-mono sf:text-xs sf:text-foreground sf:last:mb-0",t),children:p.jsx("code",{children:e})}):p.jsx("div",{ref:n,"data-testid":"detail-panel-mermaid","data-mermaid-theme":i?"dark":"light",role:"img","aria-label":"Mermaid diagram",className:oe("sf:mb-2 sf:overflow-x-auto sf:rounded sf:bg-muted/30 sf:px-3 sf:py-2 sf:text-foreground sf:last:mb-0",t)})}function cet({flowId:e,node:t,connector:n,adapter:o,onNameChange:r,onDescriptionChange:a,onDetailChange:i,onIconChange:s,statusReport:c,onClose:l}){const h=(t==null?void 0:t.type)==="text",u=(t==null?void 0:t.type)==="ellipse"||(t==null?void 0:t.type)==="sticky",f=h?null:t,y=f!==null||n!==null,g=f&&"name"in f.data?f.data.name??"":"",k=(f==null?void 0:f.data.description)??"",x=(f==null?void 0:f.data.detail)??"",v=f!==null&&!u,M=f!==null&&(f.type==="rectangle"||f.type==="component"),w=M&&typeof s=="function",b=M&&f&&"icon"in f.data?f.data.icon??null:null,[C,_]=m.useState(()=>qTe()),S=P=>{P.preventDefault(),VTe(C,P.clientX,{onWidth:_,onCommit:FTe})},j={"--detail-panel-w":`${C}px`,borderLeftWidth:"var(--detail-panel-border-left)",boxShadow:"var(--detail-panel-shadow)"};return p.jsx(nGe,{open:y,modal:!1,onOpenChange:P=>{P||l()},children:p.jsxs(Vne,{side:"right",className:"sf:w-full! sf:max-w-full! sf:overflow-y-auto sf:bg-card/94 sf:backdrop-blur-[14px] sf:border-border sf:sm:w-(--detail-panel-w)! sf:sm:max-w-(--detail-panel-w)!",style:j,"data-testid":"detail-panel",onEscapeKeyDown:P=>{var N;const A=document.activeElement;(N=A==null?void 0:A.getAttribute("data-testid"))!=null&&N.endsWith("-editor")&&P.preventDefault()},onInteractOutside:P=>{var R;const A=document.activeElement;(R=A==null?void 0:A.getAttribute("data-testid"))!=null&&R.endsWith("-editor")&&A.blur();const N=P.target;N!=null&&N.closest(".react-flow__resize-control")&&P.preventDefault(),N!=null&&N.closest("[data-radix-popper-content-wrapper]")&&P.preventDefault(),N!=null&&N.closest('[data-testid="canvas-style-strip"]')&&P.preventDefault(),N!=null&&N.closest(".react-flow__node")&&P.preventDefault(),N!=null&&N.closest(".react-flow__edge")&&P.preventDefault()},children:[p.jsx("div",{"aria-label":"Resize detail panel",onPointerDown:S,"data-testid":"detail-panel-resize-handle",className:"sf:absolute sf:inset-y-0 sf:left-0 sf:z-10 sf:hidden sf:w-1.5 sf:cursor-col-resize sf:bg-transparent sf:transition-colors sf:hover:bg-border sf:sm:block"}),f?p.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-4",children:[p.jsxs("div",{className:"sf:-mx-6 sf:-mt-6 sf:flex sf:flex-col sf:border-b sf:border-border/60 sf:bg-card/60 sf:px-6 sf:pb-2.5 sf:pt-3 sf:pr-12",children:[v?p.jsx(rP,{"data-testid":"detail-panel-title",children:p.jsxs("div",{className:"sf:flex sf:items-center sf:gap-2",children:[w&&s?p.jsx(det,{nodeId:f.id,icon:b,onChange:s}):M&&b?p.jsx("span",{"data-testid":"detail-panel-icon-readonly","aria-hidden":!0,className:"sf:inline-flex sf:h-7 sf:w-7 sf:shrink-0 sf:items-center sf:justify-center sf:text-foreground/90",children:p.jsx(S0,{name:b,size:16})}):null,p.jsx("div",{className:"sf:min-w-0 sf:flex-1",children:p.jsx(tD,{nodeId:f.id,value:g,placeholder:"Name",multiline:!1,ariaLabel:"Name",testIdBase:"detail-panel-name",onSave:r,textClassName:"sf:text-lg sf:font-semibold sf:tracking-tight sf:text-foreground/95"})})]})}):p.jsx(rP,{"data-testid":"detail-panel-title",className:"sf:sr-only",children:f.id}),p.jsxs(XH,{className:"sf:sr-only",children:[f.id," · ",f.type]})]}),p.jsxs("div",{className:"sf:mt-0 sf:flex sf:flex-col sf:gap-3",children:[c?p.jsx(pet,{report:c}):null,p.jsx(tD,{nodeId:f.id,value:k,placeholder:"Short description shown on the node body",multiline:!0,ariaLabel:"Description",testIdBase:"detail-panel-description",onSave:a,textClassName:"sf:text-[13px] sf:leading-relaxed sf:text-muted-foreground sf:dark:text-zinc-400"}),p.jsx(tD,{nodeId:f.id,value:x,placeholder:"Long-form notes, context, anything…",multiline:!0,ariaLabel:"Detail",testIdBase:"detail-panel-detail",onSave:i,markdown:!0,textClassName:"sf:text-sm sf:leading-relaxed sf:text-foreground"}),f.type==="html"&&e?p.jsx(uet,{adapter:o,nodeId:f.id,htmlPath:"view.html"}):null]})]}):n?p.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-4",children:[p.jsxs("div",{className:"sf:-mx-6 sf:-mt-6 sf:flex sf:flex-col sf:border-b sf:border-border/60 sf:bg-card/60 sf:px-6 sf:pb-2.5 sf:pt-3 sf:pr-12",children:[p.jsx(rP,{"data-testid":"detail-panel-title",className:"sf:text-lg sf:font-semibold sf:tracking-tight sf:text-foreground/95",children:n.label??"Connector"}),p.jsx(XH,{className:"sf:sr-only",children:n.id})]}),p.jsx("div",{className:"sf:mt-0 sf:flex sf:flex-col sf:gap-3",children:p.jsx(met,{connector:n})})]}):null]})})}function tD({nodeId:e,value:t,placeholder:n,multiline:o,ariaLabel:r,testIdBase:a,onSave:i,textClassName:s,markdown:c=!1}){const[l,h]=m.useState(!1),u=m.useRef(null),f=m.useRef(!1);m.useEffect(()=>{if(!l)return;const C=u.current;if(!C)return;C.textContent=t,C.focus();const _=window.getSelection();if(_){const S=document.createRange();S.selectNodeContents(C),S.collapse(!1),_.removeAllRanges(),_.addRange(S)}},[l,t]);const y=t==="";if(!i)return p.jsx("div",{"data-testid":a,"aria-label":r,className:oe("sf:w-full sf:rounded-md sf:px-2 sf:py-1.5 sf:text-sm",y?"sf:italic sf:text-muted-foreground/50":"text-foreground",!c&&"sf:whitespace-pre-wrap sf:wrap-break-word",s),children:y?n:c?p.jsx(FG,{value:t}):t});const g=()=>{const C=u.current,_=C?o?C.innerText:C.textContent??"":t;i(e,_),h(!1)},k=()=>{h(!1)},x=C=>{if(C.stopPropagation(),C.nativeEvent.stopPropagation(),C.key==="Escape"){C.preventDefault(),f.current=!0,k();return}if(C.key==="Enter"){if(C.preventDefault(),C.shiftKey||!o){g();return}document.execCommand("insertText",!1,`
|
|
8541
|
+
`))}function c(y,g,k,x){const v=k.enter("tableCell"),M=k.enter("phrasing"),w=k.containerPhrasing(y,{...x,before:a,after:a});return M(),v(),w}function l(y,g){return jQe(y,{align:g,alignDelimiters:o,padding:n,stringLength:r})}function h(y,g,k){const x=y.children;let v=-1;const M=[],w=g.enter("table");for(;++v<x.length;)M[v]=u(x[v],g,k);return w(),M}function u(y,g,k){const x=y.children;let v=-1;const M=[],w=g.enter("tableRow");for(;++v<x.length;)M[v]=c(x[v],y,g,k);return w(),M}function f(y,g,k){let x=ere.inlineCode(y,g,k);return k.stack.includes("tableCell")&&(x=x.replace(/\|/g,"\\$&")),x}}function xJe(){return{exit:{taskListCheckValueChecked:DG,taskListCheckValueUnchecked:DG,paragraph:MJe}}}function wJe(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:bJe}}}function DG(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function MJe(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const o=n.children[0];if(o&&o.type==="text"){const r=t.children;let a=-1,i;for(;++a<r.length;){const s=r[a];if(s.type==="paragraph"){i=s;break}}i===n&&(o.value=o.value.slice(1),o.value.length===0?n.children.shift():n.position&&o.position&&typeof o.position.start.offset=="number"&&(o.position.start.column++,o.position.start.offset++,n.position.start=Object.assign({},o.position.start)))}}this.exit(e)}function bJe(e,t,n,o){const r=e.children[0],a=typeof e.checked=="boolean"&&r&&r.type==="paragraph",i="["+(e.checked?"x":" ")+"] ",s=n.createTracker(o);a&&s.move(i);let c=ere.listItem(e,t,n,{...o,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(h){return h+i}}function _Je(){return[nQe(),bQe(),LQe(),fJe(),xJe()]}function CJe(e){return{extensions:[oQe(),_Qe(e),IQe(),vJe(e),wJe()]}}const SJe={tokenize:$Je,partial:!0},tre={tokenize:jJe,partial:!0},nre={tokenize:PJe,partial:!0},ore={tokenize:zJe,partial:!0},LJe={tokenize:RJe,partial:!0},rre={name:"wwwAutolink",tokenize:AJe,previous:ire},are={name:"protocolAutolink",tokenize:EJe,previous:sre},Aa={name:"emailAutolink",tokenize:NJe,previous:cre},Fr={};function IJe(){return{text:Fr}}let os=48;for(;os<123;)Fr[os]=Aa,os++,os===58?os=65:os===91&&(os=97);Fr[43]=Aa;Fr[45]=Aa;Fr[46]=Aa;Fr[95]=Aa;Fr[72]=[Aa,are];Fr[104]=[Aa,are];Fr[87]=[Aa,rre];Fr[119]=[Aa,rre];function NJe(e,t,n){const o=this;let r,a;return i;function i(u){return!cO(u)||!cre.call(o,o.previous)||qF(o.events)?n(u):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),s(u))}function s(u){return cO(u)?(e.consume(u),s):u===64?(e.consume(u),c):n(u)}function c(u){return u===46?e.check(LJe,h,l)(u):u===45||u===95||mn(u)?(a=!0,e.consume(u),c):h(u)}function l(u){return e.consume(u),r=!0,c}function h(u){return a&&r&&Cn(o.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(u)):n(u)}}function AJe(e,t,n){const o=this;return r;function r(i){return i!==87&&i!==119||!ire.call(o,o.previous)||qF(o.events)?n(i):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(SJe,e.attempt(tre,e.attempt(nre,a),n),n)(i))}function a(i){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(i)}}function EJe(e,t,n){const o=this;let r="",a=!1;return i;function i(u){return(u===72||u===104)&&sre.call(o,o.previous)&&!qF(o.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),r+=String.fromCodePoint(u),e.consume(u),s):n(u)}function s(u){if(Cn(u)&&r.length<5)return r+=String.fromCodePoint(u),e.consume(u),s;if(u===58){const f=r.toLowerCase();if(f==="http"||f==="https")return e.consume(u),c}return n(u)}function c(u){return u===47?(e.consume(u),a?l:(a=!0,c)):n(u)}function l(u){return u===null||iz(u)||mt(u)||Pd(u)||wR(u)?n(u):e.attempt(tre,e.attempt(nre,h),n)(u)}function h(u){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(u)}}function $Je(e,t,n){let o=0;return r;function r(i){return(i===87||i===119)&&o<3?(o++,e.consume(i),r):i===46&&o===3?(e.consume(i),a):n(i)}function a(i){return i===null?n(i):t(i)}}function jJe(e,t,n){let o,r,a;return i;function i(l){return l===46||l===95?e.check(ore,c,s)(l):l===null||mt(l)||Pd(l)||l!==45&&wR(l)?c(l):(a=!0,e.consume(l),i)}function s(l){return l===95?o=!0:(r=o,o=void 0),e.consume(l),i}function c(l){return r||o||!a?n(l):t(l)}}function PJe(e,t){let n=0,o=0;return r;function r(i){return i===40?(n++,e.consume(i),r):i===41&&o<n?a(i):i===33||i===34||i===38||i===39||i===41||i===42||i===44||i===46||i===58||i===59||i===60||i===63||i===93||i===95||i===126?e.check(ore,t,a)(i):i===null||mt(i)||Pd(i)?t(i):(e.consume(i),r)}function a(i){return i===41&&o++,e.consume(i),r}}function zJe(e,t,n){return o;function o(s){return s===33||s===34||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===63||s===95||s===126?(e.consume(s),o):s===38?(e.consume(s),a):s===93?(e.consume(s),r):s===60||s===null||mt(s)||Pd(s)?t(s):n(s)}function r(s){return s===null||s===40||s===91||mt(s)||Pd(s)?t(s):o(s)}function a(s){return Cn(s)?i(s):n(s)}function i(s){return s===59?(e.consume(s),o):Cn(s)?(e.consume(s),i):n(s)}}function RJe(e,t,n){return o;function o(a){return e.consume(a),r}function r(a){return mn(a)?n(a):t(a)}}function ire(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||mt(e)}function sre(e){return!Cn(e)}function cre(e){return!(e===47||cO(e))}function cO(e){return e===43||e===45||e===46||e===95||mn(e)}function qF(e){let t=e.length,n=!1;for(;t--;){const o=e[t][1];if((o.type==="labelLink"||o.type==="labelImage")&&!o._balanced){n=!0;break}if(o._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const TJe={tokenize:UJe,partial:!0};function DJe(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:FJe,continuation:{tokenize:VJe},exit:BJe}},text:{91:{name:"gfmFootnoteCall",tokenize:qJe},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:HJe,resolveTo:OJe}}}}function HJe(e,t,n){const o=this;let r=o.events.length;const a=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]);let i;for(;r--;){const c=o.events[r][1];if(c.type==="labelImage"){i=c;break}if(c.type==="gfmFootnoteCall"||c.type==="labelLink"||c.type==="label"||c.type==="image"||c.type==="link")break}return s;function s(c){if(!i||!i._balanced)return n(c);const l=Go(o.sliceSerialize({start:i.end,end:o.now()}));return l.codePointAt(0)!==94||!a.includes(l.slice(1))?n(c):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),t(c))}}function OJe(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const o={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},r={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};r.end.column++,r.end.offset++,r.end._bufferIndex++;const a={type:"gfmFootnoteCallString",start:Object.assign({},r.end),end:Object.assign({},e[e.length-1][1].start)},i={type:"chunkString",contentType:"string",start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],["enter",o,t],e[n+3],e[n+4],["enter",r,t],["exit",r,t],["enter",a,t],["enter",i,t],["exit",i,t],["exit",a,t],e[e.length-2],e[e.length-1],["exit",o,t]];return e.splice(n,e.length-n+1,...s),e}function qJe(e,t,n){const o=this,r=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]);let a=0,i;return s;function s(u){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(u),e.exit("gfmFootnoteCallLabelMarker"),c}function c(u){return u!==94?n(u):(e.enter("gfmFootnoteCallMarker"),e.consume(u),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",l)}function l(u){if(a>999||u===93&&!i||u===null||u===91||mt(u))return n(u);if(u===93){e.exit("chunkString");const f=e.exit("gfmFootnoteCallString");return r.includes(Go(o.sliceSerialize(f)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(u),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(u)}return mt(u)||(i=!0),a++,e.consume(u),u===92?h:l}function h(u){return u===91||u===92||u===93?(e.consume(u),a++,l):l(u)}}function FJe(e,t,n){const o=this,r=o.parser.gfmFootnotes||(o.parser.gfmFootnotes=[]);let a,i=0,s;return c;function c(g){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),l}function l(g){return g===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",h):n(g)}function h(g){if(i>999||g===93&&!s||g===null||g===91||mt(g))return n(g);if(g===93){e.exit("chunkString");const k=e.exit("gfmFootnoteDefinitionLabelString");return a=Go(o.sliceSerialize(k)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),f}return mt(g)||(s=!0),i++,e.consume(g),g===92?u:h}function u(g){return g===91||g===92||g===93?(e.consume(g),i++,h):h(g)}function f(g){return g===58?(e.enter("definitionMarker"),e.consume(g),e.exit("definitionMarker"),r.includes(a)||r.push(a),tt(e,y,"gfmFootnoteDefinitionWhitespace")):n(g)}function y(g){return t(g)}}function VJe(e,t,n){return e.check(Sf,t,e.attempt(TJe,t,n))}function BJe(e){e.exit("gfmFootnoteDefinition")}function UJe(e,t,n){const o=this;return tt(e,r,"gfmFootnoteDefinitionIndent",5);function r(a){const i=o.events[o.events.length-1];return i&&i[1].type==="gfmFootnoteDefinitionIndent"&&i[2].sliceSerialize(i[1],!0).length===4?t(a):n(a)}}function WJe(e){let n=(e||{}).singleTilde;const o={name:"strikethrough",tokenize:a,resolveAll:r};return n==null&&(n=!0),{text:{126:o},insideSpan:{null:[o]},attentionMarkers:{null:[126]}};function r(i,s){let c=-1;for(;++c<i.length;)if(i[c][0]==="enter"&&i[c][1].type==="strikethroughSequenceTemporary"&&i[c][1]._close){let l=c;for(;l--;)if(i[l][0]==="exit"&&i[l][1].type==="strikethroughSequenceTemporary"&&i[l][1]._open&&i[c][1].end.offset-i[c][1].start.offset===i[l][1].end.offset-i[l][1].start.offset){i[c][1].type="strikethroughSequence",i[l][1].type="strikethroughSequence";const h={type:"strikethrough",start:Object.assign({},i[l][1].start),end:Object.assign({},i[c][1].end)},u={type:"strikethroughText",start:Object.assign({},i[l][1].end),end:Object.assign({},i[c][1].start)},f=[["enter",h,s],["enter",i[l][1],s],["exit",i[l][1],s],["enter",u,s]],y=s.parser.constructs.insideSpan.null;y&&ao(f,f.length,0,MR(y,i.slice(l+1,c),s)),ao(f,f.length,0,[["exit",u,s],["enter",i[c][1],s],["exit",i[c][1],s],["exit",h,s]]),ao(i,l-1,c-l+3,f),c=l+f.length-2;break}}for(c=-1;++c<i.length;)i[c][1].type==="strikethroughSequenceTemporary"&&(i[c][1].type="data");return i}function a(i,s,c){const l=this.previous,h=this.events;let u=0;return f;function f(g){return l===126&&h[h.length-1][1].type!=="characterEscape"?c(g):(i.enter("strikethroughSequenceTemporary"),y(g))}function y(g){const k=A0(l);if(g===126)return u>1?c(g):(i.consume(g),u++,y);if(u<2&&!n)return c(g);const x=i.exit("strikethroughSequenceTemporary"),v=A0(g);return x._open=!v||v===2&&!!k,x._close=!k||k===2&&!!v,s(g)}}}class GJe{constructor(){this.map=[]}add(t,n,o){ZJe(this,t,n,o)}consume(t){if(this.map.sort(function(a,i){return a[0]-i[0]}),this.map.length===0)return;let n=this.map.length;const o=[];for(;n>0;)n-=1,o.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];o.push(t.slice()),t.length=0;let r=o.pop();for(;r;){for(const a of r)t.push(a);r=o.pop()}this.map.length=0}}function ZJe(e,t,n,o){let r=0;if(!(n===0&&o.length===0)){for(;r<e.map.length;){if(e.map[r][0]===t){e.map[r][1]+=n,e.map[r][2].push(...o);return}r+=1}e.map.push([t,n,o])}}function XJe(e,t){let n=!1;const o=[];for(;t<e.length;){const r=e[t];if(n){if(r[0]==="enter")r[1].type==="tableContent"&&o.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(r[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const a=o.length-1;o[a]=o[a]==="left"?"center":"right"}}else if(r[1].type==="tableDelimiterRow")break}else r[0]==="enter"&&r[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return o}function KJe(){return{flow:{null:{name:"table",tokenize:YJe,resolveAll:QJe}}}}function YJe(e,t,n){const o=this;let r=0,a=0,i;return s;function s(A){let N=o.events.length-1;for(;N>-1;){const $=o.events[N][1].type;if($==="lineEnding"||$==="linePrefix")N--;else break}const R=N>-1?o.events[N][1].type:null,W=R==="tableHead"||R==="tableRow"?_:c;return W===_&&o.parser.lazy[o.now().line]?n(A):W(A)}function c(A){return e.enter("tableHead"),e.enter("tableRow"),l(A)}function l(A){return A===124||(i=!0,a+=1),h(A)}function h(A){return A===null?n(A):Pe(A)?a>1?(a=0,o.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),y):n(A):Ye(A)?tt(e,h,"whitespace")(A):(a+=1,i&&(i=!1,r+=1),A===124?(e.enter("tableCellDivider"),e.consume(A),e.exit("tableCellDivider"),i=!0,h):(e.enter("data"),u(A)))}function u(A){return A===null||A===124||mt(A)?(e.exit("data"),h(A)):(e.consume(A),A===92?f:u)}function f(A){return A===92||A===124?(e.consume(A),u):u(A)}function y(A){return o.interrupt=!1,o.parser.lazy[o.now().line]?n(A):(e.enter("tableDelimiterRow"),i=!1,Ye(A)?tt(e,g,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):g(A))}function g(A){return A===45||A===58?x(A):A===124?(i=!0,e.enter("tableCellDivider"),e.consume(A),e.exit("tableCellDivider"),k):C(A)}function k(A){return Ye(A)?tt(e,x,"whitespace")(A):x(A)}function x(A){return A===58?(a+=1,i=!0,e.enter("tableDelimiterMarker"),e.consume(A),e.exit("tableDelimiterMarker"),v):A===45?(a+=1,v(A)):A===null||Pe(A)?b(A):C(A)}function v(A){return A===45?(e.enter("tableDelimiterFiller"),M(A)):C(A)}function M(A){return A===45?(e.consume(A),M):A===58?(i=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(A),e.exit("tableDelimiterMarker"),w):(e.exit("tableDelimiterFiller"),w(A))}function w(A){return Ye(A)?tt(e,b,"whitespace")(A):b(A)}function b(A){return A===124?g(A):A===null||Pe(A)?!i||r!==a?C(A):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(A)):C(A)}function C(A){return n(A)}function _(A){return e.enter("tableRow"),S(A)}function S(A){return A===124?(e.enter("tableCellDivider"),e.consume(A),e.exit("tableCellDivider"),S):A===null||Pe(A)?(e.exit("tableRow"),t(A)):Ye(A)?tt(e,S,"whitespace")(A):(e.enter("data"),j(A))}function j(A){return A===null||A===124||mt(A)?(e.exit("data"),S(A)):(e.consume(A),A===92?P:j)}function P(A){return A===92||A===124?(e.consume(A),j):j(A)}}function QJe(e,t){let n=-1,o=!0,r=0,a=[0,0,0,0],i=[0,0,0,0],s=!1,c=0,l,h,u;const f=new GJe;for(;++n<e.length;){const y=e[n],g=y[1];y[0]==="enter"?g.type==="tableHead"?(s=!1,c!==0&&(HG(f,t,c,l,h),h=void 0,c=0),l={type:"table",start:Object.assign({},g.start),end:Object.assign({},g.end)},f.add(n,0,[["enter",l,t]])):g.type==="tableRow"||g.type==="tableDelimiterRow"?(o=!0,u=void 0,a=[0,0,0,0],i=[0,n+1,0,0],s&&(s=!1,h={type:"tableBody",start:Object.assign({},g.start),end:Object.assign({},g.end)},f.add(n,0,[["enter",h,t]])),r=g.type==="tableDelimiterRow"?2:h?3:1):r&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")?(o=!1,i[2]===0&&(a[1]!==0&&(i[0]=i[1],u=Ap(f,t,a,r,void 0,u),a=[0,0,0,0]),i[2]=n)):g.type==="tableCellDivider"&&(o?o=!1:(a[1]!==0&&(i[0]=i[1],u=Ap(f,t,a,r,void 0,u)),a=i,i=[a[1],n,0,0])):g.type==="tableHead"?(s=!0,c=n):g.type==="tableRow"||g.type==="tableDelimiterRow"?(c=n,a[1]!==0?(i[0]=i[1],u=Ap(f,t,a,r,n,u)):i[1]!==0&&(u=Ap(f,t,i,r,n,u)),r=0):r&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")&&(i[3]=n)}for(c!==0&&HG(f,t,c,l,h),f.consume(t.events),n=-1;++n<t.events.length;){const y=t.events[n];y[0]==="enter"&&y[1].type==="table"&&(y[1]._align=XJe(t.events,n))}return e}function Ap(e,t,n,o,r,a){const i=o===1?"tableHeader":o===2?"tableDelimiter":"tableData",s="tableContent";n[0]!==0&&(a.end=Object.assign({},Mu(t.events,n[0])),e.add(n[0],0,[["exit",a,t]]));const c=Mu(t.events,n[1]);if(a={type:i,start:Object.assign({},c),end:Object.assign({},c)},e.add(n[1],0,[["enter",a,t]]),n[2]!==0){const l=Mu(t.events,n[2]),h=Mu(t.events,n[3]),u={type:s,start:Object.assign({},l),end:Object.assign({},h)};if(e.add(n[2],0,[["enter",u,t]]),o!==2){const f=t.events[n[2]],y=t.events[n[3]];if(f[1].end=Object.assign({},y[1].end),f[1].type="chunkText",f[1].contentType="text",n[3]>n[2]+1){const g=n[2]+1,k=n[3]-n[2]-1;e.add(g,k,[])}}e.add(n[3]+1,0,[["exit",u,t]])}return r!==void 0&&(a.end=Object.assign({},Mu(t.events,r)),e.add(r,0,[["exit",a,t]]),a=void 0),a}function HG(e,t,n,o,r){const a=[],i=Mu(t.events,n);r&&(r.end=Object.assign({},i),a.push(["exit",r,t])),o.end=Object.assign({},i),a.push(["exit",o,t]),e.add(n+1,0,a)}function Mu(e,t){const n=e[t],o=n[0]==="enter"?"start":"end";return n[1][o]}const JJe={name:"tasklistCheck",tokenize:tet};function eet(){return{text:{91:JJe}}}function tet(e,t,n){const o=this;return r;function r(c){return o.previous!==null||!o._gfmTasklistFirstContentOfListItem?n(c):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),a)}function a(c){return mt(c)?(e.enter("taskListCheckValueUnchecked"),e.consume(c),e.exit("taskListCheckValueUnchecked"),i):c===88||c===120?(e.enter("taskListCheckValueChecked"),e.consume(c),e.exit("taskListCheckValueChecked"),i):n(c)}function i(c){return c===93?(e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),s):n(c)}function s(c){return Pe(c)?t(c):Ye(c)?e.check({tokenize:net},t,n)(c):n(c)}}function net(e,t,n){return tt(e,o,"whitespace");function o(r){return r===null?n(r):t(r)}}function oet(e){return koe([IJe(),DJe(),WJe(e),KJe(),eet()])}const ret={};function aet(e){const t=this,n=e||ret,o=t.data(),r=o.micromarkExtensions||(o.micromarkExtensions=[]),a=o.fromMarkdownExtensions||(o.fromMarkdownExtensions=[]),i=o.toMarkdownExtensions||(o.toMarkdownExtensions=[]);r.push(oet(n)),a.push(_Je()),i.push(CJe(n))}let Ep=null,iet=0;function set(){return Ep||(Ep=hf(()=>import("./mermaid.core-Q5Rkziel.js").then(e=>e.ak),__vite__mapDeps([8,9,1])).then(e=>{const t=e;return t.default??t}),Ep)}function OG(){var e;return typeof document>"u"?!1:document.documentElement.classList.contains("dark")||(e=document.body)!=null&&e.classList.contains("dark")?!0:!!document.querySelector(".dark")}function qG({code:e,className:t}){const n=m.useRef(null),o=m.useRef(`seeflow-mermaid-${++iet}`),[r,a]=m.useState(null),[i,s]=m.useState(()=>OG());return m.useEffect(()=>{if(typeof document>"u")return;const c=()=>s(OG()),l=new MutationObserver(c);return l.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),document.body&&l.observe(document.body,{attributes:!0,attributeFilter:["class"]}),()=>l.disconnect()},[]),m.useEffect(()=>{let c=!1;return a(null),set().then(async l=>{l.initialize({startOnLoad:!1,theme:i?"dark":"default",securityLevel:"strict",fontFamily:'"Inter", ui-sans-serif, system-ui, sans-serif'});const h=`${o.current}-${i?"d":"l"}`,u=await l.render(h,e);if(c)return;const f=n.current;f&&(f.innerHTML=u.svg)}).catch(l=>{c||a(l instanceof Error?l.message:String(l))}),()=>{c=!0}},[e,i]),r?p.jsx("pre",{"data-testid":"detail-panel-mermaid-fallback","data-mermaid-error":"true",title:r,className:oe("sf:mb-2 sf:overflow-x-auto sf:rounded sf:bg-muted/60 sf:px-2 sf:py-1 sf:font-mono sf:text-xs sf:text-foreground sf:last:mb-0",t),children:p.jsx("code",{children:e})}):p.jsx("div",{ref:n,"data-testid":"detail-panel-mermaid","data-mermaid-theme":i?"dark":"light",role:"img","aria-label":"Mermaid diagram",className:oe("sf:mb-2 sf:overflow-x-auto sf:rounded sf:bg-muted/30 sf:px-3 sf:py-2 sf:text-foreground sf:last:mb-0",t)})}function cet({flowId:e,node:t,connector:n,adapter:o,onNameChange:r,onDescriptionChange:a,onDetailChange:i,onIconChange:s,statusReport:c,onClose:l}){const h=(t==null?void 0:t.type)==="text",u=(t==null?void 0:t.type)==="ellipse"||(t==null?void 0:t.type)==="sticky",f=h?null:t,y=f!==null||n!==null,g=f&&"name"in f.data?f.data.name??"":"",k=(f==null?void 0:f.data.description)??"",x=(f==null?void 0:f.data.detail)??"",v=f!==null&&!u,M=f!==null&&(f.type==="rectangle"||f.type==="component"),w=M&&typeof s=="function",b=M&&f&&"icon"in f.data?f.data.icon??null:null,[C,_]=m.useState(()=>qTe()),S=P=>{P.preventDefault(),VTe(C,P.clientX,{onWidth:_,onCommit:FTe})},j={"--detail-panel-w":`${C}px`,borderLeftWidth:"var(--detail-panel-border-left)",boxShadow:"var(--detail-panel-shadow)"};return p.jsx(nGe,{open:y,modal:!1,onOpenChange:P=>{P||l()},children:p.jsxs(Vne,{side:"right",className:"sf:w-full! sf:max-w-full! sf:overflow-y-auto sf:bg-card/94 sf:backdrop-blur-[14px] sf:border-border sf:sm:w-(--detail-panel-w)! sf:sm:max-w-(--detail-panel-w)!",style:j,"data-testid":"detail-panel",onEscapeKeyDown:P=>{var N;const A=document.activeElement;(N=A==null?void 0:A.getAttribute("data-testid"))!=null&&N.endsWith("-editor")&&P.preventDefault()},onInteractOutside:P=>{var R;const A=document.activeElement;(R=A==null?void 0:A.getAttribute("data-testid"))!=null&&R.endsWith("-editor")&&A.blur();const N=P.target;N!=null&&N.closest(".react-flow__resize-control")&&P.preventDefault(),N!=null&&N.closest("[data-radix-popper-content-wrapper]")&&P.preventDefault(),N!=null&&N.closest('[data-testid="canvas-style-strip"]')&&P.preventDefault(),N!=null&&N.closest(".react-flow__node")&&P.preventDefault(),N!=null&&N.closest(".react-flow__edge")&&P.preventDefault()},children:[p.jsx("div",{"aria-label":"Resize detail panel",onPointerDown:S,"data-testid":"detail-panel-resize-handle",className:"sf:absolute sf:inset-y-0 sf:left-0 sf:z-10 sf:hidden sf:w-1.5 sf:cursor-col-resize sf:bg-transparent sf:transition-colors sf:hover:bg-border sf:sm:block"}),f?p.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-4",children:[p.jsxs("div",{className:"sf:-mx-6 sf:-mt-6 sf:flex sf:flex-col sf:border-b sf:border-border/60 sf:bg-card/60 sf:px-6 sf:pb-2.5 sf:pt-3 sf:pr-12",children:[v?p.jsx(rP,{"data-testid":"detail-panel-title",children:p.jsxs("div",{className:"sf:flex sf:items-center sf:gap-2",children:[w&&s?p.jsx(det,{nodeId:f.id,icon:b,onChange:s}):M&&b?p.jsx("span",{"data-testid":"detail-panel-icon-readonly","aria-hidden":!0,className:"sf:inline-flex sf:h-7 sf:w-7 sf:shrink-0 sf:items-center sf:justify-center sf:text-foreground/90",children:p.jsx(S0,{name:b,size:16})}):null,p.jsx("div",{className:"sf:min-w-0 sf:flex-1",children:p.jsx(tD,{nodeId:f.id,value:g,placeholder:"Name",multiline:!1,ariaLabel:"Name",testIdBase:"detail-panel-name",onSave:r,textClassName:"sf:text-lg sf:font-semibold sf:tracking-tight sf:text-foreground/95"})})]})}):p.jsx(rP,{"data-testid":"detail-panel-title",className:"sf:sr-only",children:f.id}),p.jsxs(XH,{className:"sf:sr-only",children:[f.id," · ",f.type]})]}),p.jsxs("div",{className:"sf:mt-0 sf:flex sf:flex-col sf:gap-3",children:[c?p.jsx(pet,{report:c}):null,p.jsx(tD,{nodeId:f.id,value:k,placeholder:"Short description shown on the node body",multiline:!0,ariaLabel:"Description",testIdBase:"detail-panel-description",onSave:a,textClassName:"sf:text-[13px] sf:leading-relaxed sf:text-muted-foreground sf:dark:text-zinc-400"}),p.jsx(tD,{nodeId:f.id,value:x,placeholder:"Long-form notes, context, anything…",multiline:!0,ariaLabel:"Detail",testIdBase:"detail-panel-detail",onSave:i,markdown:!0,textClassName:"sf:text-sm sf:leading-relaxed sf:text-foreground"}),f.type==="html"&&e?p.jsx(uet,{adapter:o,nodeId:f.id,htmlPath:"view.html"}):null]})]}):n?p.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-4",children:[p.jsxs("div",{className:"sf:-mx-6 sf:-mt-6 sf:flex sf:flex-col sf:border-b sf:border-border/60 sf:bg-card/60 sf:px-6 sf:pb-2.5 sf:pt-3 sf:pr-12",children:[p.jsx(rP,{"data-testid":"detail-panel-title",className:"sf:text-lg sf:font-semibold sf:tracking-tight sf:text-foreground/95",children:n.label??"Connector"}),p.jsx(XH,{className:"sf:sr-only",children:n.id})]}),p.jsx("div",{className:"sf:mt-0 sf:flex sf:flex-col sf:gap-3",children:p.jsx(met,{connector:n})})]}):null]})})}function tD({nodeId:e,value:t,placeholder:n,multiline:o,ariaLabel:r,testIdBase:a,onSave:i,textClassName:s,markdown:c=!1}){const[l,h]=m.useState(!1),u=m.useRef(null),f=m.useRef(!1);m.useEffect(()=>{if(!l)return;const C=u.current;if(!C)return;C.textContent=t,C.focus();const _=window.getSelection();if(_){const S=document.createRange();S.selectNodeContents(C),S.collapse(!1),_.removeAllRanges(),_.addRange(S)}},[l,t]);const y=t==="";if(!i)return p.jsx("div",{"data-testid":a,"aria-label":r,className:oe("sf:w-full sf:rounded-md sf:px-2 sf:py-1.5 sf:text-sm",y?"sf:italic sf:text-muted-foreground/50":"text-foreground",!c&&"sf:whitespace-pre-wrap sf:wrap-break-word",s),children:y?n:c?p.jsx(FG,{value:t}):t});const g=()=>{const C=u.current,_=C?o?C.innerText:C.textContent??"":t;i(e,_),h(!1)},k=()=>{h(!1)},x=C=>{if(C.stopPropagation(),C.nativeEvent.stopPropagation(),C.key==="Escape"){C.preventDefault(),f.current=!0,k();return}if(C.key==="Enter"){if(C.preventDefault(),C.shiftKey||!o){g();return}document.execCommand("insertText",!1,`
|
|
8542
8542
|
`)}},v=C=>{C.preventDefault();const _=C.clipboardData.getData("text/plain");document.execCommand("insertText",!1,_)},M=C=>{},w=()=>{if(f.current){f.current=!1;return}g()},b=()=>{l||h(!0)};return p.jsx("div",{className:"relative","data-testid":a,"data-editing":l?"true":"false",children:l?p.jsx("div",{ref:u,contentEditable:"plaintext-only",suppressContentEditableWarning:!0,spellCheck:!1,tabIndex:0,onKeyDown:x,onPaste:v,onInput:M,onBlur:w,"data-testid":`${a}-editor`,className:oe("sf:block sf:w-full sf:whitespace-pre-wrap sf:wrap-break-word sf:rounded-md sf:px-2 sf:py-1.5 sf:text-sm sf:outline-hidden",s),role:"textbox","aria-multiline":o?"true":"false","aria-label":r}):p.jsx("button",{type:"button",onClick:b,"aria-label":`Edit ${r.toLowerCase()}`,className:oe("sf:block sf:w-full sf:cursor-text sf:rounded-md sf:px-2 sf:py-1.5 sf:text-left sf:text-sm sf:transition-colors sf:hover:bg-muted/50",y?"sf:italic sf:text-muted-foreground/50":"text-foreground",!c&&"sf:whitespace-pre-wrap sf:wrap-break-word",s),children:y?n:c?p.jsx(FG,{value:t}):t})})}function det({nodeId:e,icon:t,onChange:n}){const[o,r]=m.useState(!1);return p.jsx(Jq,{open:o,onOpenChange:r,onPick:a=>{n(e,a),r(!1)},anchor:p.jsx("button",{type:"button","data-testid":"detail-panel-icon-trigger","aria-label":t?"Change icon":"Add icon","aria-pressed":o,className:oe("sf:inline-flex sf:h-7 sf:w-7 sf:shrink-0 sf:items-center sf:justify-center sf:rounded-md sf:text-foreground sf:transition-colors",t?"sf:hover:bg-muted":"sf:border sf:border-dashed sf:border-muted-foreground/40 sf:text-muted-foreground/60 sf:hover:border-muted-foreground sf:hover:text-foreground","sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:focus-visible:ring-offset-1"),children:t?p.jsx(S0,{name:t,size:16,"aria-hidden":!0}):p.jsx(G2,{className:"sf:h-4 sf:w-4","aria-hidden":!0})})})}function uet({adapter:e,nodeId:t,htmlPath:n}){const[o,r]=m.useState({kind:"idle"}),a=typeof(e==null?void 0:e.openFile)=="function",i=typeof(e==null?void 0:e.revealFile)=="function",s=`nodes/${t}/${n}`,c=async l=>{var h,u;r({kind:"pending"});try{l==="open"?await((h=e==null?void 0:e.openFile)==null?void 0:h.call(e,s)):await((u=e==null?void 0:e.revealFile)==null?void 0:u.call(e,s)),r({kind:"idle"})}catch(f){r({kind:"error",message:f instanceof Error?f.message:String(f)})}};return p.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-2 sf:rounded-md sf:border sf:bg-card sf:px-3 sf:py-2 sf:text-xs","data-testid":"detail-panel-html-node",children:[p.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-1",children:[p.jsx("span",{className:"sf:font-mono sf:text-[11px] sf:text-muted-foreground sf:uppercase sf:tracking-widest",children:"Path"}),p.jsx("code",{"data-testid":"detail-panel-html-path",className:"sf:block sf:break-all sf:rounded sf:bg-muted/40 sf:px-2 sf:py-1 sf:font-mono sf:text-[11px]",children:n})]}),a||i?p.jsxs("div",{className:"sf:flex sf:flex-wrap sf:items-center sf:gap-2",children:[a?p.jsxs(ut,{type:"button",size:"sm",variant:"outline",className:"sf:h-7 sf:gap-1.5 sf:px-2",onClick:()=>{c("open")},disabled:o.kind==="pending","data-testid":"detail-panel-html-open","aria-label":"Open in editor",children:[p.jsx(J2,{className:"sf:h-3.5 sf:w-3.5"}),"Open in editor"]}):null,i?p.jsxs(ut,{type:"button",size:"sm",variant:"outline",className:"sf:h-7 sf:gap-1.5 sf:px-2",onClick:()=>{c("reveal")},disabled:o.kind==="pending","data-testid":"detail-panel-html-reveal","aria-label":"Reveal in Finder/Explorer",children:[p.jsx(B2,{className:"sf:h-3.5 sf:w-3.5"}),"Reveal"]}):null]}):null,o.kind==="error"?p.jsx("div",{"data-testid":"detail-panel-html-status","data-status":o.kind,className:oe("sf:text-[11px] sf:text-destructive"),children:o.message??""}):null]})}function het(e,t){const n=Math.max(0,t-e);if(n<1e3)return"just now";const o=Math.floor(n/1e3);if(o<60)return`${o}s ago`;const r=Math.floor(o/60);if(r<60)return`${r}m ago`;const a=Math.floor(r/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function fet(e){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function pet({report:e,now:t=Date.now()}){const n=e.data?Object.entries(e.data):[];return p.jsxs("section",{className:"sf:flex sf:flex-col sf:gap-2 sf:rounded-md sf:border sf:bg-card sf:px-3 sf:py-2 sf:text-xs","data-testid":"detail-panel-status","data-state":e.state,children:[p.jsxs("div",{className:"sf:flex sf:items-center sf:justify-between sf:gap-2",children:[p.jsx(nF,{state:e.state,summary:e.summary,"data-testid":"detail-panel-status-badge"}),p.jsx("span",{className:"sf:shrink-0 sf:text-[10px] sf:text-muted-foreground","data-testid":"detail-panel-status-relative-time",children:`Last updated: ${het(e.ts,t)}`})]}),e.detail?p.jsx("div",{"data-testid":"detail-panel-status-detail",className:"sf:whitespace-pre-wrap sf:wrap-break-word sf:rounded sf:bg-muted/40 sf:px-2 sf:py-1 sf:text-[11px] sf:text-foreground",children:e.detail}):null,n.length>0?p.jsx("dl",{"data-testid":"detail-panel-status-data",className:"sf:grid sf:grid-cols-[auto_1fr] sf:gap-x-3 sf:gap-y-1 sf:text-[11px]",children:n.map(([o,r])=>p.jsxs("div",{className:"contents","data-testid":"detail-panel-status-data-row",children:[p.jsx("dt",{className:"sf:truncate sf:font-medium sf:text-muted-foreground",children:o}),p.jsx("dd",{className:"sf:break-all sf:font-mono sf:text-foreground",children:fet(r)})]},o))}):null]})}function lre(e){return typeof e=="string"?e.replace(/\n$/,""):Array.isArray(e)?e.map(t=>typeof t=="string"?t:"").join("").replace(/\n$/,""):String(e??"").replace(/\n$/,"")}function yet(e){if(!m.isValidElement(e))return null;const t=e.props;return!t||typeof t.className!="string"||!t.className.includes("language-mermaid")?null:lre(t.children)}function FG({value:e}){return p.jsx(WYe,{remarkPlugins:[aet],components:{h1:({children:t})=>p.jsx("h1",{className:"sf:mb-1 sf:text-base sf:font-bold sf:leading-snug",children:t}),h2:({children:t})=>p.jsx("h2",{className:"sf:mb-1 sf:text-sm sf:font-semibold sf:leading-snug",children:t}),h3:({children:t})=>p.jsx("h3",{className:"sf:mb-0.5 sf:text-sm sf:font-medium sf:leading-snug",children:t}),p:({children:t})=>p.jsx("p",{className:"sf:mb-2 sf:last:mb-0 sf:leading-relaxed",children:t}),ul:({children:t})=>p.jsx("ul",{className:"sf:mb-2 sf:list-disc sf:pl-4 sf:last:mb-0",children:t}),ol:({children:t})=>p.jsx("ol",{className:"sf:mb-2 sf:list-decimal sf:pl-4 sf:last:mb-0",children:t}),li:({children:t})=>p.jsx("li",{className:"mb-0.5",children:t}),code:({children:t,className:n})=>typeof n=="string"&&n.includes("language-mermaid")?p.jsx(qG,{code:lre(t)}):(n==null?void 0:n.includes("language-"))?p.jsx("code",{className:"sf:block sf:overflow-x-auto sf:rounded sf:bg-muted/60 sf:px-2 sf:py-1 sf:font-mono sf:text-xs",children:t}):p.jsx("code",{className:"sf:rounded sf:bg-muted/60 sf:px-1 sf:py-0.5 sf:font-mono sf:text-xs",children:t}),pre:({children:t})=>{const n=yet(t);return n!==null?p.jsx(qG,{code:n}):p.jsx("pre",{className:"sf:mb-2 sf:last:mb-0",children:t})},blockquote:({children:t})=>p.jsx("blockquote",{className:"sf:mb-2 sf:border-l-2 sf:border-muted-foreground/30 sf:pl-3 sf:italic sf:text-muted-foreground sf:last:mb-0",children:t}),a:({href:t,children:n})=>p.jsx("a",{href:t,target:"_blank",rel:"noreferrer",className:"sf:text-primary sf:underline sf:underline-offset-2",children:n}),strong:({children:t})=>p.jsx("strong",{className:"font-semibold",children:t}),em:({children:t})=>p.jsx("em",{className:"italic",children:t}),hr:()=>p.jsx("hr",{className:"sf:my-2 sf:border-border"}),table:({children:t})=>p.jsx("div",{className:"sf:mb-2 sf:overflow-x-auto sf:last:mb-0",children:p.jsx("table",{className:"sf:w-full sf:border-collapse sf:text-xs",children:t})}),th:({children:t})=>p.jsx("th",{className:"sf:border sf:border-border sf:bg-muted/40 sf:px-2 sf:py-1 sf:text-left sf:font-medium",children:t}),td:({children:t})=>p.jsx("td",{className:"sf:border sf:border-border sf:px-2 sf:py-1",children:t})},children:e})}function met({connector:e}){return p.jsx("div",{className:"sf:rounded-md sf:border sf:bg-card sf:px-3 sf:py-2 sf:text-xs",children:p.jsxs("dl",{className:"divide-y",children:[p.jsx(ra,{label:"Source",value:e.source}),p.jsx(ra,{label:"Target",value:e.target}),e.label?p.jsx(ra,{label:"Label",value:e.label}):null,e.style?p.jsx(ra,{label:"Style",value:e.style}):null,e.color?p.jsx(ra,{label:"Color",value:e.color}):null,e.direction?p.jsx(ra,{label:"Direction",value:e.direction}):null,e.url?p.jsx(ra,{label:"URL",value:`${e.method??"GET"} ${e.url}`}):null,e.eventName?p.jsx(ra,{label:"Event",value:e.eventName}):null,e.queueName?p.jsx(ra,{label:"Queue",value:e.queueName}):null]})})}function ra({label:e,value:t}){return p.jsxs("div",{className:"sf:flex sf:items-start sf:gap-3 sf:py-2 sf:first:pt-0 sf:last:pb-0",children:[p.jsx("dt",{className:"sf:w-20 sf:shrink-0 sf:font-medium sf:text-muted-foreground",children:e}),p.jsx("dd",{className:"sf:flex-1 sf:break-all sf:font-mono",children:t})]})}const get="https://seeflow.dev/embed",ket=(e,t)=>{const n=`${get}/${encodeURIComponent(e)}`;return t?`${n}?theme=${t}`:n},vet=e=>{var t,n;return(n=(t=e==null?void 0:e.documentElement)==null?void 0:t.classList)!=null&&n.contains("dark")?"dark":"light"},xet=e=>e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<"),wet=e=>[`<iframe src="${xet(e)}"`,' width="100%"',' height="600"',' style="border:0"',' allow="fullscreen"',' loading="lazy"></iframe>'].join(`
|
|
8543
8543
|
`),Met="Embed this canvas",bet="Paste this iframe into any page to embed the canvas.",_et="Copy snippet",Cet="Copied!",Let="Press ⌘C to copy",Iet="Close",Net="Theme",Aet=1500,Eet=[{value:"match",label:"Match my theme"},{value:"light",label:"Light"},{value:"dark",label:"Dark"}],$et=e=>e==="light"?"light":e==="dark"?"dark":vet(typeof document<"u"?document:null);function jet({open:e,onOpenChange:t,projectId:n}){const[o,r]=m.useState("idle"),[a,i]=m.useState("match"),s=m.useRef(null),c=m.useMemo(()=>wet(ket(n,$et(a))),[n,a]),l=m.useCallback(async()=>{try{await navigator.clipboard.writeText(c),r("copied"),setTimeout(()=>r("idle"),Aet)}catch{r("fallback");const h=s.current;h&&(h.focus(),h.select())}},[c]);return p.jsx(Ca,{open:e,onOpenChange:t,children:p.jsxs(Ri,{"data-testid":"embed-dialog-content",children:[p.jsxs(Ti,{children:[p.jsx(Di,{children:Met}),p.jsx(Hi,{children:bet})]}),p.jsxs("fieldset",{className:"sf:flex sf:flex-col sf:gap-2 sf:border-0 sf:p-0",children:[p.jsx("legend",{id:"embed-dialog-theme-label",className:"sf:mb-2 sf:text-xs sf:font-medium sf:text-foreground",children:Net}),p.jsx("div",{"data-testid":"embed-dialog-theme-group",className:"sf:inline-flex sf:self-start sf:rounded-md sf:border sf:border-input sf:bg-background sf:p-0.5",children:Eet.map(h=>{const u=a===h.value;return p.jsx("button",{type:"button","aria-pressed":u,"aria-label":h.label,"data-testid":`embed-dialog-theme-${h.value}`,"data-active":u,onClick:()=>i(h.value),className:oe("sf:rounded sf:px-3 sf:py-1 sf:text-xs sf:transition-colors sf:focus-visible:outline-hidden sf:focus-visible:ring-1 sf:focus-visible:ring-ring",u?"sf:bg-secondary sf:text-secondary-foreground sf:shadow-sm":"sf:text-muted-foreground sf:hover:bg-accent sf:hover:text-accent-foreground"),children:h.label},h.value)})})]}),p.jsx("textarea",{ref:s,"data-testid":"embed-dialog-snippet",readOnly:!0,rows:7,value:c,spellCheck:!1,onFocus:h=>h.currentTarget.select(),className:"sf:w-full sf:resize-none sf:rounded-md sf:border sf:border-border sf:bg-background sf:p-3 sf:font-mono sf:text-xs sf:leading-relaxed sf:text-foreground sf:focus:outline-hidden sf:focus:ring-2 sf:focus:ring-ring"}),o==="fallback"?p.jsx("p",{"data-testid":"embed-dialog-fallback-hint",className:"sf:text-xs sf:text-muted-foreground",children:Let}):null,p.jsxs(Sa,{children:[p.jsx(ut,{variant:"outline","data-testid":"embed-dialog-close",onClick:()=>t(!1),children:Iet}),p.jsx(ut,{"data-testid":"embed-dialog-copy",onClick:l,children:o==="copied"?Cet:_et})]})]})})}const VG="Share / download",Pet="Download PDF",zet="Download PNG",Ret="Embed",Tet="Export to seeflow.dev";function Det({mode:e,projectId:t,enableEmbed:n,onDownloadPdf:o,onDownloadPng:r,onExportToCloud:a,embedOpen:i,onEmbedOpenChange:s}){const[c,l]=m.useState(!1),[h,u]=m.useState(!1),[f,y]=m.useState(!1),g=i!==void 0,k=g?i:f,x=m.useCallback(S=>{g||y(S),s==null||s(S)},[g,s]),v=m.useCallback(()=>{!o||c||(l(!0),Promise.resolve(o()).finally(()=>l(!1)))},[o,c]),M=m.useCallback(()=>{!r||h||(u(!0),Promise.resolve(r()).finally(()=>u(!1)))},[r,h]),w=!!o,b=!!r,C=n&&typeof t=="string"&&t.length>0,_=e==="edit"&&!!a;return!w&&!b&&!C&&!_?null:p.jsxs(p.Fragment,{children:[p.jsxs(Cne,{children:[p.jsx(Sne,{asChild:!0,children:p.jsx("button",{type:"button","data-testid":"share-menu-trigger","aria-label":VG,title:VG,className:oe("sf:inline-flex sf:h-8 sf:w-8 sf:items-center sf:justify-center sf:rounded-md sf:border sf:border-border sf:bg-background/95 sf:text-muted-foreground sf:shadow-md sf:backdrop-blur-sm sf:transition-colors","sf:hover:bg-accent sf:hover:text-accent-foreground","sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring"),children:p.jsx(oh,{className:"sf:h-4 sf:w-4","aria-hidden":"true"})})}),p.jsxs(vF,{align:"end","data-testid":"share-menu-content",onCloseAutoFocus:S=>{S.preventDefault()},children:[w?p.jsxs(L2,{"data-testid":"share-menu-pdf",disabled:c,onSelect:S=>{S.preventDefault(),v()},children:[c?p.jsx(ua,{className:"sf:h-4 sf:w-4 sf:animate-spin","aria-hidden":"true"}):p.jsx(V2,{className:"sf:h-4 sf:w-4","aria-hidden":"true"}),p.jsx("span",{children:Pet})]}):null,b?p.jsxs(L2,{"data-testid":"share-menu-png",disabled:h,onSelect:S=>{S.preventDefault(),M()},children:[h?p.jsx(ua,{className:"sf:h-4 sf:w-4 sf:animate-spin","aria-hidden":"true"}):p.jsx(Z2,{className:"sf:h-4 sf:w-4","aria-hidden":"true"}),p.jsx("span",{children:zet})]}):null,C?p.jsxs(L2,{"data-testid":"share-menu-embed",onSelect:S=>{S.preventDefault(),x(!0)},children:[p.jsx(Uu,{className:"sf:h-4 sf:w-4","aria-hidden":"true"}),p.jsx("span",{children:Ret})]}):null,_?p.jsxs(L2,{"data-testid":"share-menu-export-cloud",onSelect:()=>{a==null||a()},children:[p.jsx(ah,{className:"sf:h-4 sf:w-4","aria-hidden":"true"}),p.jsx("span",{children:Tet})]}):null]})]}),C&&t?p.jsx(jet,{open:k,onOpenChange:x,projectId:t}):null]})}const Het=8;function Oet(e){let t=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,r=Number.NEGATIVE_INFINITY,a=!1;for(const i of e){const s=i.data.width,c=i.data.height;s===void 0||c===void 0||(a=!0,i.position.x<t&&(t=i.position.x),i.position.y<n&&(n=i.position.y),i.position.x+s>o&&(o=i.position.x+s),i.position.y+c>r&&(r=i.position.y+c))}return a?{x:t,y:n,width:o-t,height:r-n}:null}function qet(e){return e.length>=2}function Fet({selectedNodes:e,onMultiResize:t,paddingPx:n=Het}){Uz();const[o,r]=m.useState(null),[a,i]=m.useState(null);if(m.useRef(!1),m.useRef(null),!qet(e))return null;const s=Oet(e);if(!s)return null;const c=a??s;return c.x-n,c.y-n,c.width+n*2,c.height+n*2,null}const BG=22,UG=11,WG=3,GG=2,nD=8,oD=1,ZG=["none","white","slate","gray","red","orange","amber","yellow","lime","green","teal","cyan","sky","blue","indigo","violet","fuchsia","pink"],$p=[{value:"solid",icon:az,label:"Solid",testId:"style-tab-border-style-solid"},{value:"dashed",icon:Hne,label:"Dashed",testId:"style-tab-border-style-dashed"},{value:"dotted",icon:One,label:"Dotted",testId:"style-tab-border-style-dotted"}],XG=[{value:"solid",icon:az,label:"Solid",testId:"style-tab-edge-style-solid"},{value:"dashed",icon:Hne,label:"Dashed",testId:"style-tab-edge-style-dashed"},{value:"dotted",icon:One,label:"Dotted",testId:"style-tab-edge-style-dotted"}],KG=[{value:"curve",icon:qne,label:"Curve",testId:"style-tab-edge-path-curve"},{value:"step",icon:tGe,label:"Zigzag",testId:"style-tab-edge-path-step"}],Vet="center",Bet=[{value:"left",icon:zo,label:"Left",testId:"style-tab-text-align-left"},{value:"center",icon:ti,label:"Center",testId:"style-tab-text-align-center"},{value:"right",icon:ni,label:"Right",testId:"style-tab-text-align-right"}],YG=[{value:"none",icon:K2,label:"None",testId:"style-tab-direction-none"},{value:"backward",icon:Q2,label:"Backward",testId:"style-tab-direction-backward"},{value:"forward",icon:Bu,label:"Forward",testId:"style-tab-direction-forward"},{value:"both",icon:T2,label:"Both",testId:"style-tab-direction-both"}];function Uet({nodes:e,connectors:t,onStyleNode:n,onStyleNodePreview:o,onStyleNodes:r,onStyleNodesPreview:a,onStyleConnector:i,onStyleConnectorPreview:s,onRequestIconReplace:c}){const l=e.length>0,h=t.length>0;if(!l&&!h)return null;const u=l&&!h,f=!l&&h,y=e[0],g=t[0],k=e.filter(se=>se.type!=="icon"),x=k[0],v=u&&e.every(se=>se.type==="icon"),M=v?e.find(se=>se.type==="icon"):void 0,w=u&&e.every(se=>se.type==="image"),b=u&&(y==null?void 0:y.type)==="text",C=(f?g==null?void 0:g.color:b?x==null?void 0:x.data.borderColor:x==null?void 0:x.data.backgroundColor)??"default",_=(x==null?void 0:x.data.borderStyle)??"solid",S=(g==null?void 0:g.style)??"solid",j=(g==null?void 0:g.direction)??"forward",P=(g==null?void 0:g.path)??"curve",A=se=>{if(e.length>1&&r)r(e.map(we=>we.id),{borderColor:se,backgroundColor:se});else for(const we of e)n(we.id,{borderColor:se,backgroundColor:se});for(const we of t)i(we.id,{color:se})},N=se=>{for(const we of e)n(we.id,{borderStyle:se});for(const we of t)i(we.id,{style:se})},R=se=>{for(const we of e)n(we.id,{borderSize:se});for(const we of t)i(we.id,{borderSize:se})},W=se=>{for(const we of e)o==null||o(we.id,{borderSize:se});for(const we of t)s==null||s(we.id,{borderSize:se})},$=se=>{if(e.length>1&&r)r(e.map(we=>we.id),{fontSize:se});else for(const we of e)n(we.id,{fontSize:se})},H=se=>{if(e.length>1&&a)a(e.map(we=>we.id),{fontSize:se});else for(const we of e)o==null||o(we.id,{fontSize:se})},T=k.length>1&&new Set(k.map(se=>se.data.fontSize??BG)).size>1,O=se=>{if(e.length>1&&r)r(e.map(we=>we.id),{textAlign:se});else for(const we of e)n(we.id,{textAlign:se})},I=(x==null?void 0:x.data.textAlign)??Vet,z=se=>{for(const we of t)i(we.id,{fontSize:se})},L=se=>{for(const we of t)s==null||s(we.id,{fontSize:se})},F=t.length>1&&new Set(t.map(se=>se.fontSize??UG)).size>1,D=se=>{for(const we of e)n(we.id,{cornerRadius:se})},E=se=>{for(const we of e)o==null||o(we.id,{cornerRadius:se})},K=k.length>1&&new Set(k.map(se=>se.data.cornerRadius??nD)).size>1,X=se=>{for(const we of e)n(we.id,{shadow:se})},Y=se=>{for(const we of e)o==null||o(we.id,{shadow:se})},Q=k.length>1&&new Set(k.map(se=>se.data.shadow??oD)).size>1,te=se=>{for(const we of t)i(we.id,{path:se})},ne=se=>{for(const we of t)i(we.id,{direction:se})},ie=se=>{for(const we of e)n(we.id,{color:se})},ke=(M==null?void 0:M.data.color)??"default",ge=f?(g==null?void 0:g.borderSize)??GG:(x==null?void 0:x.data.borderSize)??WG,ve=f?GG:WG,ce=f?"edge":"border",Ce=f?"Connector color":"Color",Re=f?"connector color":"color",st="style-tab-color-trigger",Vt="style-tab-color";if(v){const se=!!c&&e.length===1&&!!M,we=()=>{M&&c&&c(M.id)};return p.jsx(dh,{delayDuration:300,children:p.jsxs("div",{"data-testid":"canvas-style-strip",className:"sf:pointer-events-auto sf:flex sf:flex-col sf:items-center sf:gap-1 sf:rounded-lg sf:border sf:border-border sf:bg-background/95 sf:p-1 sf:shadow-md sf:backdrop-blur",children:[p.jsx(Get,{testId:"style-strip-icon-color",tooltip:"Icon color",ariaLabel:"icon color",activeToken:ke,previewKind:"edge",tokenTestIdPrefix:"style-tab-icon-color",innerTestId:"style-tab-icon-color-trigger",allowNone:!1,onSelect:ie}),se?p.jsxs(gR,{children:[p.jsx(kR,{asChild:!0,children:p.jsx("button",{type:"button","data-testid":"style-strip-change-icon","aria-label":"change icon",title:"Change icon",onClick:we,className:oe("sf:inline-flex sf:h-8 sf:w-8 sf:items-center sf:justify-center sf:rounded-md sf:text-muted-foreground sf:transition-colors sf:hover:bg-accent sf:hover:text-accent-foreground","sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:focus-visible:ring-offset-1"),children:p.jsx(Gu,{className:"sf:h-4 sf:w-4"})})}),p.jsx(bf,{side:"right",className:"sf:px-2 sf:py-1 sf:text-xs",children:"Change icon"})]}):null]})})}if(w){const se=e[0],we=(se==null?void 0:se.data.borderColor)??"default",re=(se==null?void 0:se.data.borderStyle)??"solid",Be=(se==null?void 0:se.data.borderWidth)??1,an=xe=>{for(const Ae of e)n(Ae.id,{borderColor:xe})},J=xe=>{for(const Ae of e)n(Ae.id,{borderStyle:xe})},ue=xe=>{for(const Ae of e)n(Ae.id,{borderWidth:xe})},je=xe=>{for(const Ae of e)o==null||o(Ae.id,{borderWidth:xe})},Ue=xe=>{for(const Ae of e)n(Ae.id,{cornerRadius:xe})},Ke=xe=>{for(const Ae of e)o==null||o(Ae.id,{cornerRadius:xe})},Bt=xe=>{for(const Ae of e)n(Ae.id,{shadow:xe})},un=xe=>{for(const Ae of e)o==null||o(Ae.id,{shadow:xe})},Ut=()=>{const xe=we==="none";return p.jsx("span",{className:oe("sf:relative sf:h-5 sf:w-5 sf:rounded-full",xe&&"sf:bg-card"),style:xe?void 0:dz(we),children:xe?p.jsx(uz,{}):null})};return p.jsx(dh,{delayDuration:300,children:p.jsxs("div",{"data-testid":"canvas-style-strip",className:"sf:pointer-events-auto sf:flex sf:flex-col sf:items-center sf:gap-1 sf:rounded-lg sf:border sf:border-border sf:bg-background/95 sf:p-1 sf:shadow-md sf:backdrop-blur",children:[p.jsx(vo,{testId:"style-strip-image-border-color-button",tooltip:"Border color",ariaLabel:"image border color",renderIcon:Ut,children:p.jsx(lO,{testId:"style-strip-image-border-color",activeToken:we,previewKind:"border",tokenTestIdPrefix:"style-tab-image-border-color",innerTestId:"style-tab-image-border-color-trigger",ariaLabel:"image border color",onSelect:an})}),p.jsx(vo,{testId:"style-strip-image-corner-radius-button",tooltip:"Corners",ariaLabel:"image corners",renderIcon:()=>p.jsx(Wu,{className:"sf:h-4 sf:w-4"}),children:p.jsx("div",{"data-testid":"style-strip-image-corner-radius",children:p.jsx(rs,{value:se==null?void 0:se.data.cornerRadius,defaultValue:nD,min:0,max:32,suffix:"px",onPreview:Ke,onCommit:Ue,testId:"style-tab-image-corner-radius-slider"})})}),p.jsx(vo,{testId:"style-strip-image-shadow-button",tooltip:"Shadow",ariaLabel:"image shadow",renderIcon:()=>p.jsx(da,{className:"sf:h-4 sf:w-4"}),children:p.jsx("div",{"data-testid":"style-strip-image-shadow",children:p.jsx(rs,{value:se==null?void 0:se.data.shadow,defaultValue:oD,min:0,max:5,onPreview:un,onCommit:Bt,testId:"style-tab-image-shadow-slider"})})}),p.jsx(vo,{testId:"style-strip-image-border-style",tooltip:"Border style",ariaLabel:"image border style",renderIcon:()=>{var Ae;const xe=((Ae=$p.find(Tt=>Tt.value===re))==null?void 0:Ae.icon)??az;return p.jsx(xe,{className:"sf:h-4 sf:w-4"})},children:p.jsx(pu,{ariaLabel:"Border style",value:re,onChange:J,options:$p})}),p.jsx(vo,{testId:"style-strip-image-border-width",tooltip:"Border width",ariaLabel:"image border width",renderIcon:()=>p.jsx("span",{className:"sf:font-mono sf:text-[10px] sf:tabular-nums",children:Be}),children:p.jsx(rs,{value:se==null?void 0:se.data.borderWidth,defaultValue:1,min:0,max:8,suffix:"px",onPreview:je,onCommit:ue,testId:"style-tab-image-border-width-slider"})})]})})}const It=!b,pe=()=>{const se=C==="none";return p.jsx("span",{className:oe("sf:relative sf:h-5 sf:w-5 sf:rounded-full",se&&"sf:bg-card"),style:se?void 0:dz(C),children:se?p.jsx(uz,{}):null})};return p.jsx(dh,{delayDuration:300,children:p.jsxs("div",{"data-testid":"canvas-style-strip",className:"sf:pointer-events-auto sf:flex sf:flex-col sf:items-center sf:gap-1 sf:rounded-lg sf:border sf:border-border sf:bg-background/95 sf:p-1 sf:shadow-md sf:backdrop-blur",children:[p.jsx(vo,{testId:"style-strip-color-button",tooltip:Ce,ariaLabel:Re,renderIcon:pe,children:p.jsx(lO,{testId:"style-strip-color",activeToken:C,previewKind:ce,tokenTestIdPrefix:Vt,innerTestId:st,ariaLabel:Re,allowNone:!f,onSelect:A})}),l?p.jsx(vo,{testId:"style-strip-corner-radius-button",tooltip:"Corners",ariaLabel:"corners",renderIcon:()=>p.jsx(Wu,{className:"sf:h-4 sf:w-4"}),children:p.jsx("div",{"data-testid":"style-strip-corner-radius",children:p.jsx(rs,{value:x==null?void 0:x.data.cornerRadius,defaultValue:nD,min:0,max:32,suffix:"px",indeterminate:K,onPreview:E,onCommit:D,testId:"style-tab-corner-radius-slider"})})}):null,l?p.jsx(vo,{testId:"style-strip-shadow-button",tooltip:"Shadow",ariaLabel:"shadow",renderIcon:()=>p.jsx(da,{className:"sf:h-4 sf:w-4"}),children:p.jsx("div",{"data-testid":"style-strip-shadow",children:p.jsx(rs,{value:x==null?void 0:x.data.shadow,defaultValue:oD,min:0,max:5,indeterminate:Q,onPreview:Y,onCommit:X,testId:"style-tab-shadow-slider"})})}):null,It?p.jsx(vo,{testId:"style-strip-border",tooltip:f?"Connector":"Border",ariaLabel:f?"connector":"border",renderIcon:()=>{var we,re;const se=(f?(we=XG.find(Be=>Be.value===S))==null?void 0:we.icon:(re=$p.find(Be=>Be.value===_))==null?void 0:re.icon)??az;return p.jsx(se,{className:"sf:h-4 sf:w-4"})},children:p.jsxs("div",{className:"sf:flex sf:w-56 sf:flex-col sf:gap-3",children:[p.jsx(jp,{label:"Style",testId:"style-strip-border-style",children:f?p.jsx(pu,{ariaLabel:"Connector style",value:S,onChange:se=>N(se),options:XG}):p.jsx(pu,{ariaLabel:"Border style",value:_,onChange:se=>N(se),options:$p})}),p.jsx(jp,{label:"Width",testId:"style-strip-border-size",children:p.jsx(rs,{value:ge,defaultValue:ve,min:0,max:8,suffix:"px",onPreview:W,onCommit:R,testId:f?"style-tab-stroke-width-slider":"style-tab-border-size-slider"})})]})}):null,l||f?p.jsx(vo,{testId:"style-strip-text",tooltip:"Text",ariaLabel:"text",renderIcon:()=>p.jsx(Zu,{className:"sf:h-4 sf:w-4"}),children:p.jsxs("div",{className:"sf:flex sf:w-56 sf:flex-col sf:gap-3",children:[p.jsx(jp,{label:"Size",testId:f?"style-strip-connector-font-size":"style-strip-font-size",children:p.jsx(rs,{value:f?g==null?void 0:g.fontSize:x==null?void 0:x.data.fontSize,defaultValue:f?UG:BG,min:f?8:10,max:32,suffix:"px",indeterminate:f?F:T,onPreview:f?L:H,onCommit:f?z:$,testId:f?"style-tab-connector-font-size-slider":"style-tab-font-size-slider"})}),l?p.jsx(jp,{label:"Align",testId:"style-strip-text-align",children:p.jsx(pu,{ariaLabel:"Text alignment",value:I,onChange:O,options:Bet})}):null]})}):null,f?p.jsx(vo,{testId:"style-strip-path",tooltip:"Connector path",ariaLabel:"connector path",renderIcon:()=>{var we;const se=((we=KG.find(re=>re.value===P))==null?void 0:we.icon)??qne;return p.jsx(se,{className:"sf:h-4 sf:w-4"})},children:p.jsx(pu,{ariaLabel:"Connector path",value:P,onChange:te,options:KG})}):null,f?p.jsx(vo,{testId:"style-strip-direction",tooltip:"Direction",ariaLabel:"direction",renderIcon:()=>{var we;const se=((we=YG.find(re=>re.value===j))==null?void 0:we.icon)??Bu;return p.jsx(se,{className:"sf:h-4 sf:w-4"})},children:p.jsx(pu,{ariaLabel:"Connector direction",value:j,onChange:ne,options:YG})}):null]})})}function dz(e){return e==="default"?{backgroundColor:"hsl(var(--card))"}:{backgroundColor:lce[e].edge}}function uz(){return p.jsx("span",{"aria-hidden":"true",className:"sf:pointer-events-none sf:absolute sf:inset-0 sf:rounded-full",style:{backgroundImage:"linear-gradient(45deg, transparent 45%, hsl(0, 75%, 55%) 45%, hsl(0, 75%, 55%) 55%, transparent 55%)"}})}function Wet({token:e,isActive:t,onClick:n,testId:o,ariaLabel:r}){const a=e==="none",i=e==="white";return p.jsxs("button",{type:"button",onClick:n,"data-testid":o,"data-active":t,"aria-label":r,"aria-pressed":t,title:e,className:oe("sf:relative sf:flex sf:h-5 sf:w-5 sf:items-center sf:justify-center sf:rounded-full sf:transition-all",a&&"sf:border sf:border-border sf:bg-card",i&&"sf:border sf:border-border",t?"sf:ring-2 sf:ring-ring sf:ring-offset-1 sf:ring-offset-popover":"sf:hover:scale-110"),style:a?void 0:dz(e),children:[a?p.jsx(uz,{}):null,t&&!a?p.jsx(md,{className:"sf:h-2.5 sf:w-2.5 sf:drop-shadow-sm",style:{color:i?"hsl(0, 0%, 30%)":"hsl(var(--foreground))"}}):null]})}function Get({testId:e,tooltip:t,ariaLabel:n,activeToken:o,previewKind:r,tokenTestIdPrefix:a,innerTestId:i,allowNone:s,onSelect:c}){const[l,h]=m.useState(!1),u=o==="none";return p.jsxs(Dd,{open:l,onOpenChange:h,children:[p.jsxs(gR,{children:[p.jsx(kR,{asChild:!0,children:p.jsx(V0,{asChild:!0,children:p.jsx("button",{type:"button","data-testid":e,"data-active-token":o,"aria-label":`${n}: ${o}`,title:t,className:oe("sf:group sf:relative sf:inline-flex sf:h-8 sf:w-8 sf:items-center sf:justify-center sf:rounded-md sf:text-muted-foreground sf:transition-colors sf:hover:bg-accent sf:hover:text-accent-foreground","sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:focus-visible:ring-offset-1"),children:p.jsx("span",{"data-testid":i,className:oe("sf:relative sf:h-5 sf:w-5 sf:rounded-full",u&&"sf:bg-card"),style:u?void 0:dz(o),children:u?p.jsx(uz,{}):null})})})}),p.jsx(bf,{side:"right",className:"sf:px-2 sf:py-1 sf:text-xs",children:t})]}),p.jsx(zi,{side:"right",align:"start",className:"sf:w-auto sf:p-1.5","data-testid":`${i}-popover`,children:p.jsx(lO,{testId:`${a}-grid`,activeToken:o,previewKind:r,tokenTestIdPrefix:a,innerTestId:i,ariaLabel:n,allowNone:s,onSelect:f=>{c(f),h(!1)}})})]})}function lO({testId:e,activeToken:t,previewKind:n,tokenTestIdPrefix:o,innerTestId:r,ariaLabel:a,allowNone:i,onSelect:s}){const c=i===!1?ZG.filter(l=>l!=="none"):ZG;return p.jsx("div",{"data-testid":e,"data-active-token":t,"data-inner-testid":r,className:"sf:grid sf:grid-cols-6 sf:gap-2 sf:p-1",children:c.map(l=>p.jsx(Wet,{token:l,isActive:t===l,onClick:()=>s(l),testId:`${o}-${l}`,ariaLabel:`${a} ${l}`},l))})}function jp({label:e,testId:t,children:n}){return p.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-1.5","data-testid":t,children:[p.jsx("div",{className:"sf:text-[11px] sf:font-medium sf:uppercase sf:tracking-wide sf:text-muted-foreground",children:e}),n]})}function vo({testId:e,tooltip:t,ariaLabel:n,renderIcon:o,children:r}){const[a,i]=m.useState(!1);return p.jsxs(Dd,{open:a,onOpenChange:i,children:[p.jsxs(gR,{children:[p.jsx(kR,{asChild:!0,children:p.jsx(V0,{asChild:!0,children:p.jsx("button",{type:"button","data-testid":e,"aria-label":n,title:t,className:oe("sf:inline-flex sf:h-8 sf:w-8 sf:items-center sf:justify-center sf:rounded-md sf:text-muted-foreground sf:transition-colors sf:hover:bg-accent sf:hover:text-accent-foreground","sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:focus-visible:ring-offset-1"),children:o()})})}),p.jsx(bf,{side:"right",className:"sf:px-2 sf:py-1 sf:text-xs",children:t})]}),p.jsx(zi,{side:"right",align:"start",className:"sf:w-auto sf:p-3",children:r})]})}function rs({value:e,defaultValue:t,min:n,max:o,suffix:r,indeterminate:a,onPreview:i,onCommit:s,testId:c}){const l=e??t,[h,u]=m.useState(l),[f,y]=m.useState(!1);m.useEffect(()=>{u(l),y(!1)},[l]);const g=a&&!f;return p.jsxs("div",{className:"sf:flex sf:w-48 sf:items-center sf:gap-3",children:[p.jsx(Tq,{min:n,max:o,step:1,value:[h],onValueChange:([k])=>{const x=k??n;u(x),y(!0),i==null||i(x)},onValueCommit:([k])=>s(k??n),"data-testid":c,"data-indeterminate":g?"true":void 0,className:oe("sf:flex-1",g&&"sf:opacity-60")}),p.jsx("span",{"data-testid":`${c}-value`,className:"sf:w-12 sf:shrink-0 sf:text-right sf:text-xs sf:tabular-nums sf:text-muted-foreground",children:g?"Mixed":p.jsxs(p.Fragment,{children:[h,r]})})]})}function Zet(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;const n=document.implementation.createHTMLDocument(),o=n.createElement("base"),r=n.createElement("a");return n.head.appendChild(o),n.body.appendChild(r),t&&(o.href=t),r.href=e,r.href}const Xet=(()=>{let e=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function wi(e){const t=[];for(let n=0,o=e.length;n<o;n++)t.push(e[n]);return t}let mu=null;function dre(e={}){return mu||(e.includeStyleProperties?(mu=e.includeStyleProperties,mu):(mu=wi(window.getComputedStyle(document.documentElement)),mu))}function hz(e,t){const o=(e.ownerDocument.defaultView||window).getComputedStyle(e).getPropertyValue(t);return o?parseFloat(o.replace("px","")):0}function Ket(e){const t=hz(e,"border-left-width"),n=hz(e,"border-right-width");return e.clientWidth+t+n}function Yet(e){const t=hz(e,"border-top-width"),n=hz(e,"border-bottom-width");return e.clientHeight+t+n}function ure(e,t={}){const n=t.width||Ket(e),o=t.height||Yet(e);return{width:n,height:o}}function Qet(){let e,t;try{t=process}catch{}const n=t&&t.env?t.env.devicePixelRatio:null;return n&&(e=parseInt(n,10),Number.isNaN(e)&&(e=1)),e||window.devicePixelRatio||1}const Xn=16384;function Jet(e){(e.width>Xn||e.height>Xn)&&(e.width>Xn&&e.height>Xn?e.width>e.height?(e.height*=Xn/e.width,e.width=Xn):(e.width*=Xn/e.height,e.height=Xn):e.width>Xn?(e.height*=Xn/e.width,e.width=Xn):(e.width*=Xn/e.height,e.height=Xn))}function fz(e){return new Promise((t,n)=>{const o=new Image;o.onload=()=>{o.decode().then(()=>{requestAnimationFrame(()=>t(o))})},o.onerror=n,o.crossOrigin="anonymous",o.decoding="async",o.src=e})}async function ett(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function ttt(e,t,n){const o="http://www.w3.org/2000/svg",r=document.createElementNS(o,"svg"),a=document.createElementNS(o,"foreignObject");return r.setAttribute("width",`${t}`),r.setAttribute("height",`${n}`),r.setAttribute("viewBox",`0 0 ${t} ${n}`),a.setAttribute("width","100%"),a.setAttribute("height","100%"),a.setAttribute("x","0"),a.setAttribute("y","0"),a.setAttribute("externalResourcesRequired","true"),r.appendChild(a),a.appendChild(e),ett(r)}const Bn=(e,t)=>{if(e instanceof t)return!0;const n=Object.getPrototypeOf(e);return n===null?!1:n.constructor.name===t.name||Bn(n,t)};function ntt(e){const t=e.getPropertyValue("content");return`${e.cssText} content: '${t.replace(/'|"/g,"")}';`}function ott(e,t){return dre(t).map(n=>{const o=e.getPropertyValue(n),r=e.getPropertyPriority(n);return`${n}: ${o}${r?" !important":""};`}).join(" ")}function rtt(e,t,n,o){const r=`.${e}:${t}`,a=n.cssText?ntt(n):ott(n,o);return document.createTextNode(`${r}{${a}}`)}function QG(e,t,n,o){const r=window.getComputedStyle(e,n),a=r.getPropertyValue("content");if(a===""||a==="none")return;const i=Xet();try{t.className=`${t.className} ${i}`}catch{return}const s=document.createElement("style");s.appendChild(rtt(i,n,r,o)),t.appendChild(s)}function att(e,t,n){QG(e,t,":before",n),QG(e,t,":after",n)}const JG="application/font-woff",eZ="image/jpeg",itt={woff:JG,woff2:JG,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:eZ,jpeg:eZ,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function stt(e){const t=/\.([^./]*?)$/g.exec(e);return t?t[1]:""}function FF(e){const t=stt(e).toLowerCase();return itt[t]||""}function ctt(e){return e.split(/,/)[1]}function dO(e){return e.search(/^(data:)/)!==-1}function ltt(e,t){return`data:${t};base64,${e}`}async function hre(e,t,n){const o=await fetch(e,t);if(o.status===404)throw new Error(`Resource "${o.url}" not found`);const r=await o.blob();return new Promise((a,i)=>{const s=new FileReader;s.onerror=i,s.onloadend=()=>{try{a(n({res:o,result:s.result}))}catch(c){i(c)}},s.readAsDataURL(r)})}const rD={};function dtt(e,t,n){let o=e.replace(/\?.*/,"");return n&&(o=e),/ttf|otf|eot|woff2?/i.test(o)&&(o=o.replace(/.*\//,"")),t?`[${t}]${o}`:o}async function VF(e,t,n){const o=dtt(e,t,n.includeQueryParams);if(rD[o]!=null)return rD[o];n.cacheBust&&(e+=(/\?/.test(e)?"&":"?")+new Date().getTime());let r;try{const a=await hre(e,n.fetchRequestInit,({res:i,result:s})=>(t||(t=i.headers.get("Content-Type")||""),ctt(s)));r=ltt(a,t)}catch(a){r=n.imagePlaceholder||"";let i=`Failed to fetch resource: ${e}`;a&&(i=typeof a=="string"?a:a.message),i&&console.warn(i)}return rD[o]=r,r}async function utt(e){const t=e.toDataURL();return t==="data:,"?e.cloneNode(!1):fz(t)}async function htt(e,t){if(e.currentSrc){const a=document.createElement("canvas"),i=a.getContext("2d");a.width=e.clientWidth,a.height=e.clientHeight,i==null||i.drawImage(e,0,0,a.width,a.height);const s=a.toDataURL();return fz(s)}const n=e.poster,o=FF(n),r=await VF(n,o,t);return fz(r)}async function ftt(e,t){var n;try{if(!((n=e==null?void 0:e.contentDocument)===null||n===void 0)&&n.body)return await SR(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function ptt(e,t){return Bn(e,HTMLCanvasElement)?utt(e):Bn(e,HTMLVideoElement)?htt(e,t):Bn(e,HTMLIFrameElement)?ftt(e,t):e.cloneNode(fre(e))}const ytt=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SLOT",fre=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SVG";async function mtt(e,t,n){var o,r;if(fre(t))return t;let a=[];return ytt(e)&&e.assignedNodes?a=wi(e.assignedNodes()):Bn(e,HTMLIFrameElement)&&(!((o=e.contentDocument)===null||o===void 0)&&o.body)?a=wi(e.contentDocument.body.childNodes):a=wi(((r=e.shadowRoot)!==null&&r!==void 0?r:e).childNodes),a.length===0||Bn(e,HTMLVideoElement)||await a.reduce((i,s)=>i.then(()=>SR(s,n)).then(c=>{c&&t.appendChild(c)}),Promise.resolve()),t}function gtt(e,t,n){const o=t.style;if(!o)return;const r=window.getComputedStyle(e);r.cssText?(o.cssText=r.cssText,o.transformOrigin=r.transformOrigin):dre(n).forEach(a=>{let i=r.getPropertyValue(a);a==="font-size"&&i.endsWith("px")&&(i=`${Math.floor(parseFloat(i.substring(0,i.length-2)))-.1}px`),Bn(e,HTMLIFrameElement)&&a==="display"&&i==="inline"&&(i="block"),a==="d"&&t.getAttribute("d")&&(i=`path(${t.getAttribute("d")})`),o.setProperty(a,i,r.getPropertyPriority(a))})}function ktt(e,t){Bn(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),Bn(e,HTMLInputElement)&&t.setAttribute("value",e.value)}function vtt(e,t){if(Bn(e,HTMLSelectElement)){const n=t,o=Array.from(n.children).find(r=>e.value===r.getAttribute("value"));o&&o.setAttribute("selected","")}}function xtt(e,t,n){return Bn(t,Element)&&(gtt(e,t,n),att(e,t,n),ktt(e,t),vtt(e,t)),t}async function wtt(e,t){const n=e.querySelectorAll?e.querySelectorAll("use"):[];if(n.length===0)return e;const o={};for(let a=0;a<n.length;a++){const s=n[a].getAttribute("xlink:href");if(s){const c=e.querySelector(s),l=document.querySelector(s);!c&&l&&!o[s]&&(o[s]=await SR(l,t,!0))}}const r=Object.values(o);if(r.length){const a="http://www.w3.org/1999/xhtml",i=document.createElementNS(a,"svg");i.setAttribute("xmlns",a),i.style.position="absolute",i.style.width="0",i.style.height="0",i.style.overflow="hidden",i.style.display="none";const s=document.createElementNS(a,"defs");i.appendChild(s);for(let c=0;c<r.length;c++)s.appendChild(r[c]);e.appendChild(i)}return e}async function SR(e,t,n){return!n&&t.filter&&!t.filter(e)?null:Promise.resolve(e).then(o=>ptt(o,t)).then(o=>mtt(e,o,t)).then(o=>xtt(e,o,t)).then(o=>wtt(o,t))}const pre=/url\((['"]?)([^'"]+?)\1\)/g,Mtt=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,btt=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function _tt(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function Ctt(e){const t=[];return e.replace(pre,(n,o,r)=>(t.push(r),n)),t.filter(n=>!dO(n))}async function Stt(e,t,n,o,r){try{const a=n?Zet(t,n):t,i=FF(t);let s;return r||(s=await VF(a,i,o)),e.replace(_tt(t),`$1${s}$3`)}catch{}return e}function Ltt(e,{preferredFontFormat:t}){return t?e.replace(btt,n=>{for(;;){const[o,,r]=Mtt.exec(n)||[];if(!r)return"";if(r===t)return`src: ${o};`}}):e}function yre(e){return e.search(pre)!==-1}async function mre(e,t,n){if(!yre(e))return e;const o=Ltt(e,n);return Ctt(o).reduce((a,i)=>a.then(s=>Stt(s,i,t,n)),Promise.resolve(o))}async function gu(e,t,n){var o;const r=(o=t.style)===null||o===void 0?void 0:o.getPropertyValue(e);if(r){const a=await mre(r,null,n);return t.style.setProperty(e,a,t.style.getPropertyPriority(e)),!0}return!1}async function Itt(e,t){await gu("background",e,t)||await gu("background-image",e,t),await gu("mask",e,t)||await gu("-webkit-mask",e,t)||await gu("mask-image",e,t)||await gu("-webkit-mask-image",e,t)}async function Ntt(e,t){const n=Bn(e,HTMLImageElement);if(!(n&&!dO(e.src))&&!(Bn(e,SVGImageElement)&&!dO(e.href.baseVal)))return;const o=n?e.src:e.href.baseVal,r=await VF(o,FF(o),t);await new Promise((a,i)=>{e.onload=a,e.onerror=t.onImageErrorHandler?(...c)=>{try{a(t.onImageErrorHandler(...c))}catch(l){i(l)}}:i;const s=e;s.decode&&(s.decode=a),s.loading==="lazy"&&(s.loading="eager"),n?(e.srcset="",e.src=r):e.href.baseVal=r})}async function Att(e,t){const o=wi(e.childNodes).map(r=>gre(r,t));await Promise.all(o).then(()=>e)}async function gre(e,t){Bn(e,Element)&&(await Itt(e,t),await Ntt(e,t),await Att(e,t))}function Ett(e,t){const{style:n}=e;t.backgroundColor&&(n.backgroundColor=t.backgroundColor),t.width&&(n.width=`${t.width}px`),t.height&&(n.height=`${t.height}px`);const o=t.style;return o!=null&&Object.keys(o).forEach(r=>{n[r]=o[r]}),e}const tZ={};async function nZ(e){let t=tZ[e];if(t!=null)return t;const o=await(await fetch(e)).text();return t={url:e,cssText:o},tZ[e]=t,t}async function oZ(e,t){let n=e.cssText;const o=/url\(["']?([^"')]+)["']?\)/g,a=(n.match(/url\([^)]+\)/g)||[]).map(async i=>{let s=i.replace(o,"$1");return s.startsWith("https://")||(s=new URL(s,e.url).href),hre(s,t.fetchRequestInit,({result:c})=>(n=n.replace(i,`url(${c})`),[i,c]))});return Promise.all(a).then(()=>n)}function rZ(e){if(e==null)return[];const t=[],n=/(\/\*[\s\S]*?\*\/)/gi;let o=e.replace(n,"");const r=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const c=r.exec(o);if(c===null)break;t.push(c[0])}o=o.replace(r,"");const a=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,i="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",s=new RegExp(i,"gi");for(;;){let c=a.exec(o);if(c===null){if(c=s.exec(o),c===null)break;a.lastIndex=s.lastIndex}else s.lastIndex=a.lastIndex;t.push(c[0])}return t}async function $tt(e,t){const n=[],o=[];return e.forEach(r=>{if("cssRules"in r)try{wi(r.cssRules||[]).forEach((a,i)=>{if(a.type===CSSRule.IMPORT_RULE){let s=i+1;const c=a.href,l=nZ(c).then(h=>oZ(h,t)).then(h=>rZ(h).forEach(u=>{try{r.insertRule(u,u.startsWith("@import")?s+=1:r.cssRules.length)}catch(f){console.error("Error inserting rule from remote css",{rule:u,error:f})}})).catch(h=>{console.error("Error loading remote css",h.toString())});o.push(l)}})}catch(a){const i=e.find(s=>s.href==null)||document.styleSheets[0];r.href!=null&&o.push(nZ(r.href).then(s=>oZ(s,t)).then(s=>rZ(s).forEach(c=>{i.insertRule(c,i.cssRules.length)})).catch(s=>{console.error("Error loading remote stylesheet",s)})),console.error("Error inlining remote css file",a)}}),Promise.all(o).then(()=>(e.forEach(r=>{if("cssRules"in r)try{wi(r.cssRules||[]).forEach(a=>{n.push(a)})}catch(a){console.error(`Error while reading CSS rules from ${r.href}`,a)}}),n))}function jtt(e){return e.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>yre(t.style.getPropertyValue("src")))}async function Ptt(e,t){if(e.ownerDocument==null)throw new Error("Provided element is not within a Document");const n=wi(e.ownerDocument.styleSheets),o=await $tt(n,t);return jtt(o)}function kre(e){return e.trim().replace(/["']/g,"")}function ztt(e){const t=new Set;function n(o){(o.style.fontFamily||getComputedStyle(o).fontFamily).split(",").forEach(a=>{t.add(kre(a))}),Array.from(o.children).forEach(a=>{a instanceof HTMLElement&&n(a)})}return n(e),t}async function Rtt(e,t){const n=await Ptt(e,t),o=ztt(e);return(await Promise.all(n.filter(a=>o.has(kre(a.style.fontFamily))).map(a=>{const i=a.parentStyleSheet?a.parentStyleSheet.href:null;return mre(a.cssText,i,t)}))).join(`
|
|
8544
|
-
`)}async function Ttt(e,t){const n=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await Rtt(e,t);if(n){const o=document.createElement("style"),r=document.createTextNode(n);o.appendChild(r),e.firstChild?e.insertBefore(o,e.firstChild):e.appendChild(o)}}async function Dtt(e,t={}){const{width:n,height:o}=ure(e,t),r=await SR(e,t,!0);return await Ttt(r,t),await gre(r,t),Ett(r,t),await ttt(r,n,o)}async function Htt(e,t={}){const{width:n,height:o}=ure(e,t),r=await Dtt(e,t),a=await fz(r),i=document.createElement("canvas"),s=i.getContext("2d"),c=t.pixelRatio||Qet(),l=t.canvasWidth||n,h=t.canvasHeight||o;return i.width=l*c,i.height=h*c,t.skipAutoScale||Jet(i),i.style.width=`${l}`,i.style.height=`${h}`,t.backgroundColor&&(s.fillStyle=t.backgroundColor,s.fillRect(0,0,i.width,i.height)),s.drawImage(a,0,0,i.width,i.height),i}async function Ott(e,t={}){return(await Htt(e,t)).toDataURL()}const qtt=e=>e instanceof Element?!(e.classList.contains("react-flow__minimap")||e.classList.contains("react-flow__controls")||e.classList.contains("react-flow__panel")):!0,Ftt=e=>{var o;let t=e;for(;t&&!t.classList.contains("seeflow-canvas-root");)t=t.parentElement;if(t){const r=getComputedStyle(t).getPropertyValue("--bg-canvas").trim();if(r.length>0)return r}const n=(o=e.ownerDocument)==null?void 0:o.documentElement;return n!=null&&n.classList.contains("dark")?"#0a0a0c":"#fafafa"},Vtt=async e=>{const t=await Ott(e,{cacheBust:!0,filter:qtt,backgroundColor:Ftt(e)}),n=await new Promise((o,r)=>{const a=new Image;a.onload=()=>o({width:a.naturalWidth,height:a.naturalHeight}),a.onerror=()=>r(new Error("Failed to decode captured image")),a.src=t});return{dataUrl:t,...n}},Btt=(e,t)=>{const n=document.createElement("a");n.href=e,n.download=t,n.rel="noopener",document.body.appendChild(n),n.click(),n.remove()},Utt=e=>{const t=e.replace(/[^A-Za-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"");return t.length>0?t.slice(0,80):"canvas"},aZ=(e,t)=>`${Utt(e??"canvas")}.${t}`,Wtt=({projectId:e,getReactFlow:t})=>{const[n,o]=m.useState(null),r=m.useCallback(()=>o(null),[]),a=m.useCallback(async()=>{const l=t();if(!l)return null;const h=document.querySelector(".react-flow__viewport");if(!h)return null;const u=l.getViewport();try{return await l.fitView({duration:0,padding:.1}),await new Promise(f=>requestAnimationFrame(()=>f())),await Vtt(h)}finally{l.setViewport(u,{duration:0})}},[t]),i=m.useCallback(async()=>{o(null);try{const l=await a();if(!l)return;Btt(l.dataUrl,aZ(e,"png"))}catch(l){o(l instanceof Error?l.message:String(l))}},[a,e]),s=m.useCallback(async()=>{o(null);try{const l=await a();if(!l)return;const{jsPDF:h}=await hf(async()=>{const{jsPDF:y}=await import("./jspdf.es.min-C8_HZhlK.js").then(g=>g.j);return{jsPDF:y}},[]),u=l.width>l.height?"landscape":"portrait",f=new h({orientation:u,unit:"px",format:[l.width,l.height],hotfixes:["px_scaling"]});f.addImage(l.dataUrl,"PNG",0,0,l.width,l.height),f.save(aZ(e,"pdf"))}catch(l){o(l instanceof Error?l.message:String(l))}},[a,e]),c=m.useCallback(async()=>{const l=await a();return l==null?void 0:l.dataUrl},[a]);return{exportPdf:s,exportPng:i,capturePreview:c,lastError:n,clearError:r}},Gtt=12,Ztt=1200;function Xtt(e,t={}){const n=t.idleMs??Ztt;let o,r=null,a=null;const i=typeof requestAnimationFrame<"u",s=()=>{o!==void 0&&(clearTimeout(o),o=void 0)},c=()=>{a!==null&&typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(a),a=null},l=()=>{if(a=null,!r)return;const{clientX:y,clientY:g}=r;r=null;const k=e.getBoundingClientRect();e.style.setProperty("--mx",`${y-k.left}px`),e.style.setProperty("--my",`${g-k.top}px`),e.dataset.active="true",s(),o=setTimeout(()=>{e.dataset.active="false",o=void 0},n)};return{onMove:y=>{if(r={clientX:y.clientX,clientY:y.clientY},!i){l();return}a===null&&(a=requestAnimationFrame(l))},onLeave:()=>{c(),r=null,s(),e.dataset.active="false"},dispose:()=>{c(),r=null,s()}}}function Ktt(){const e=m.useRef(null),t=De(i=>i.transform,(i,s)=>i[0]===s[0]&&i[1]===s[1]&&i[2]===s[2]),[n,o,r]=t,a=Gtt*r;return m.useEffect(()=>{var u;const i=e.current;if(!i)return;const s=(u=i.parentElement)==null?void 0:u.querySelector(".react-flow__pane");if(!s)return;const{onMove:c,onLeave:l,dispose:h}=Xtt(i);return s.addEventListener("mousemove",c,{passive:!0}),s.addEventListener("mouseleave",l,{passive:!0}),()=>{s.removeEventListener("mousemove",c),s.removeEventListener("mouseleave",l),h()}},[]),p.jsx("div",{ref:e,className:"glow-overlay","data-active":"false","data-testid":"canvas-glow-overlay",style:{backgroundPosition:`${n}px ${o}px`,backgroundSize:`${a}px ${a}px`}})}const Ytt={showToolbar:!0,showStyleStrip:!0,showDetailPanel:!0,showStatusBadges:!0,showResizeHandles:!0,showControls:!0,showShareMenu:!0,showMiniMap:!0,enableKeyboard:!0,enableContextMenu:!0,enableDragDrop:!0,enableImageDrop:!0,enableZoom:!0,enablePan:!0,enableSelection:!0,enableNodeMove:!0,enableEmbed:!1},Qtt={showToolbar:!0,showStyleStrip:!1,showDetailPanel:!1,showStatusBadges:!0,showResizeHandles:!1,showControls:!0,showShareMenu:!0,showMiniMap:!0,enableKeyboard:!1,enableContextMenu:!1,enableDragDrop:!1,enableImageDrop:!1,enableZoom:!0,enablePan:!0,enableSelection:!0,enableNodeMove:!0,enableEmbed:!1},Jtt={showToolbar:!1,showStyleStrip:!1,showDetailPanel:!1,showStatusBadges:!1,showResizeHandles:!1,showControls:!1,showShareMenu:!1,showMiniMap:!1,enableKeyboard:!1,enableContextMenu:!1,enableDragDrop:!1,enableImageDrop:!1,enableZoom:!1,enablePan:!1,enableSelection:!1,enableNodeMove:!1,enableEmbed:!1};function ent(e){const t=e.mode==="edit"?Ytt:e.mode==="mini"?Jtt:Qtt;return{showToolbar:e.showToolbar??t.showToolbar,showStyleStrip:e.showStyleStrip??t.showStyleStrip,showDetailPanel:e.showDetailPanel??t.showDetailPanel,showStatusBadges:e.showStatusBadges??t.showStatusBadges,showResizeHandles:e.showResizeHandles??t.showResizeHandles,showControls:e.showControls??t.showControls,showShareMenu:e.showShareMenu??t.showShareMenu,showMiniMap:e.showMiniMap??t.showMiniMap,enableKeyboard:e.enableKeyboard??t.enableKeyboard,enableContextMenu:e.enableContextMenu??t.enableContextMenu,enableDragDrop:e.enableDragDrop??t.enableDragDrop,enableImageDrop:e.enableImageDrop??t.enableImageDrop,enableZoom:e.enableZoom??t.enableZoom,enablePan:e.enablePan??t.enablePan,enableSelection:e.enableSelection??t.enableSelection,enableNodeMove:e.enableNodeMove??t.enableNodeMove,enableEmbed:e.enableEmbed??t.enableEmbed}}const iZ=40,y2={padding:.15,duration:300,includeHiddenNodes:!1};function tnt(e){return e===void 0||e===!1?{onMount:!1,onExternalNodeChange:!1}:e===!0?{onMount:!0,onExternalNodeChange:!0}:{onMount:e.onMount??!0,onExternalNodeChange:e.onExternalNodeChange??!0}}const sZ=e=>{if("clientX"in e)return{clientX:e.clientX,clientY:e.clientY};const t=e.changedTouches[0]??e.touches[0];return t?{clientX:t.clientX,clientY:t.clientY}:null},nnt=(e,t)=>{var o;const n=document.elementsFromPoint(e,t);for(const r of n){const a=(o=r.closest)==null?void 0:o.call(r,".react-flow__node");if(a)return a}return null},vre=15,aD=(e,t,n)=>{const o=nnt(t,n);if(o)return o;if(!e)return null;let r=null,a=vre;const i=e.querySelectorAll(".react-flow__node");for(const s of i){const c=s.getBoundingClientRect();if(c.width===0||c.height===0)continue;const l=Math.max(c.left-t,0,t-c.right),h=Math.max(c.top-n,0,n-c.bottom),u=Math.hypot(l,h);u<=a&&(r=s,a=u)}return r};function cZ(e,t,n,o,r){if(e==="source"?(o==null?void 0:o.targetPin)!==void 0||(o==null?void 0:o.targetHandleAutoPicked)===!1:(o==null?void 0:o.sourcePin)!==void 0||(o==null?void 0:o.sourceHandleAutoPicked)===!1)return;const i=e==="source"?n:t,s=e==="source"?t:n,c=r(i),l=r(s);if(!c||!l)return;const h=c.measured.width??c.width??0,u=c.measured.height??c.height??0,f=l.measured.width??l.width??0,y=l.measured.height??l.height??0;if(h===0||u===0||f===0||y===0)return;const g={x:c.internals.positionAbsolute.x,y:c.internals.positionAbsolute.y,w:h,h:u},k={x:l.internals.positionAbsolute.x+f/2,y:l.internals.positionAbsolute.y+y/2};return UTe(g,FP(g,k))}function ont(e,t,n,o){if(o===null)return"no-op";const r=e==="source"?t:n;return o===(e==="source"?n:t)?"self-loop":o===r?"pin-own":"reconnect-and-pin"}const rnt=(e,t)=>{if(!t)return e;const n=t.data?{...e.data,...t.data}:e.data;return{...e,...t,data:n}},ant=(e,t)=>t?{...e,...t}:e,int={rectangle:lBe,ellipse:ur,sticky:ur,text:ur,database:ur,server:ur,user:ur,queue:ur,cloud:ur,diamond:ur,hexagon:ur,image:oBe,icon:nDe,html:QVe,component:xVe},snt={editableEdge:hBe},cnt={zIndex:0},lnt={hideAttribution:!0},dnt=8,lZ=(e,t)=>e?typeof e=="string"?`url('#${e}')`:`url('#${`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`}')`:void 0,unt=e=>function({fromX:n,fromY:o,toX:r,toY:a,fromPosition:i,toPosition:s,connectionLineStyle:c}){const l=De(F=>e.current?F.edges.find(D=>D.reconnectable===!0)??null:null),h=l==null?void 0:l.data,u=De(F=>{var E;const D=F.connection;return((E=D==null?void 0:D.fromHandle)==null?void 0:E.nodeId)??null}),f=De(F=>l!=null&&l.source?F.nodeLookup.get(l.source)??null:null),y=De(F=>l!=null&&l.target?F.nodeLookup.get(l.target)??null:null),g=De(F=>u?F.nodeLookup.get(u)??null:null),k=(l==null?void 0:l.source)===u,x=l?k?f:y:g,v=k?y:f,M=k?h==null?void 0:h.sourcePin:h==null?void 0:h.targetPin,w=k?h==null?void 0:h.sourceHandleAutoPicked:h==null?void 0:h.targetHandleAutoPicked;let b=n,C=o,_=i;if(x){const F=x.measured.width??x.width??0,D=x.measured.height??x.height??0;if(F>0&&D>0){const E={x:x.internals.positionAbsolute.x,y:x.internals.positionAbsolute.y,w:F,h:D};let K=null;if(M)K=VP(E,M);else if(w!==!1&&v){const X=v.measured.width??v.width??0,Y=v.measured.height??v.height??0;if(X>0&&Y>0){const Q={x:v.internals.positionAbsolute.x+X/2,y:v.internals.positionAbsolute.y+Y/2};K=FP(E,Q)}}K&&(b=K.x,C=K.y,_=dZ[K.side])}}const S=De(F=>F.transform[2]),j=De(F=>F.nodeLookup),P=De(F=>{var D;return((D=F.connection.toHandle)==null?void 0:D.nodeId)??null});let A=r,N=a,R=s;if(S>0){const F=vre/S,D=l?k?l.target:l.source:null;let E=null;if(P&&P!==D){const K=j.get(P)??null;K&&(E=K)}if(!E){let K=F;for(const X of j.values()){if(D&&X.id===D||x&&X.id===x.id)continue;const Y=X.measured.width??X.width??0,Q=X.measured.height??X.height??0;if(Y===0||Q===0)continue;const te=X.internals.positionAbsolute.x,ne=X.internals.positionAbsolute.y,ie=Math.max(te-r,0,r-(te+Y)),ke=Math.max(ne-a,0,a-(ne+Q)),ge=Math.hypot(ie,ke);ge<=K&&(K=ge,E=X)}}if(!E&&l&&x){const K=x.measured.width??x.width??0,X=x.measured.height??x.height??0;if(K>0&&X>0){const Y=x.internals.positionAbsolute.x,Q=x.internals.positionAbsolute.y,te=Math.max(Y-r,0,r-(Y+K)),ne=Math.max(Q-a,0,a-(Q+X));Math.hypot(te,ne)<=F&&(E=x)}}if(E){const K=E.measured.width??E.width??0,X=E.measured.height??E.height??0;if(K>0&&X>0){const Y=bH({x:E.internals.positionAbsolute.x,y:E.internals.positionAbsolute.y,w:K,h:X},{x:r,y:a}),Q=VP({x:E.internals.positionAbsolute.x,y:E.internals.positionAbsolute.y,w:K,h:X},Y);A=Q.x,N=Q.y,R=dZ[Q.side]}}}const W=(h==null?void 0:h.path)==="step",[$]=W?Hh({sourceX:b,sourceY:C,sourcePosition:_,targetX:A,targetY:N,targetPosition:R,borderRadius:dnt}):qz({sourceX:b,sourceY:C,sourcePosition:_,targetX:A,targetY:N,targetPosition:R}),H=(l==null?void 0:l.style)??c??void 0,T=De(F=>F.rfId),O=k?l==null?void 0:l.markerStart:l==null?void 0:l.markerEnd,I=k?l==null?void 0:l.markerEnd:l==null?void 0:l.markerStart,z=lZ(O,T),L=lZ(I,T);return p.jsx("path",{d:$,fill:"none",className:"react-flow__connection-path",style:H,markerStart:z,markerEnd:L})},dZ={top:ye.Top,right:ye.Right,bottom:ye.Bottom,left:ye.Left};function hnt({storeApiRef:e}){const t=wt();return m.useEffect(()=>(e.current=t,()=>{e.current===t&&(e.current=null)}),[t,e]),null}function fnt({wrapperRef:e}){const t=De(o=>o.transform[2]),n=e.current;return n&&n.style.setProperty("--rf-zoom",String(t)),null}const pnt=new Set(["INPUT","TEXTAREA","SELECT"]),uO=e=>e?pnt.has(e.tagName)?!0:e instanceof HTMLElement&&e.isContentEditable:!1;function ynt(e){const{event:t,selectedNodeIds:n,hasClipboard:o,activeElement:r,onCopySelection:a,onPasteSelection:i}=e;if(!(t.metaKey||t.ctrlKey)||t.shiftKey||t.altKey)return!1;const s=t.key.toLowerCase();return s!=="c"&&s!=="v"||uO(r)?!1:s==="c"?n.length===0||!a?!1:(t.preventDefault(),a([...n]),!0):!o||!i?!1:(t.preventDefault(),i(),!0)}const uZ=(e,t)=>{var n;return((n=e==null?void 0:e[t])==null?void 0:n.status)??"idle"},mnt=(e,t)=>{var n;return(n=e==null?void 0:e[t])==null?void 0:n.status},gnt=(e,t)=>{var n,o;return((n=e==null?void 0:e[t])==null?void 0:n.status)==="error"?(o=e[t])==null?void 0:o.error:void 0};function knt(e,t){var sV,cV;const{mode:n,adapter:o,topLeftSlot:r,topRightSlot:a,projectId:i,flowSlug:s,fileBaseUrl:c,apiBaseUrl:l="/api",nodes:h,connectors:u,selectedNodeIds:f,selectedConnectorIds:y,onSelectionChange:g,runtime:k,onPlayNode:x,onNodePositionChange:v,onNodePositionsChange:M,onNodeResize:w,onNodeResizeEnd:b,onHtmlNodeFitToContent:C,onComponentNodeFitToContent:_,onMultiResize:S,onNodeNameChange:j,onNodeDescriptionChange:P,onConnectorLabelChange:A,onCreateShapeNode:N,onCreateImageFromFile:R,onRetryImageUpload:W,onCreateHtmlNode:$,onCreateConnector:H,onReconnectConnector:T,onReorderNode:O,onDeleteNode:I,onCopyNode:z,onPasteAt:L,hasClipboard:F,onCopySelection:D,onPasteSelection:E,selectedNodes:K,selectedConnectors:X,onStyleNode:Y,onStyleNodePreview:Q,onStyleNodes:te,onStyleNodesPreview:ne,onStyleConnector:ie,onStyleConnectorPreview:ke,onRfInit:ge,onTidy:ve,onNodeClick:ce,onConnectorClick:Ce,onPaneClick:Re,onCreateAndConnectFromPane:st,pendingEditNodeId:Vt,iconPickerOpen:It,onOpenIconPicker:pe,onCloseIconPicker:se,onPickIcon:we,onRequestIconReplace:re,onPinEndpoint:Be,onUnpinEndpoint:an,canvasMode:J,onCanvasModeChange:ue,disableSidebar:je,statusReport:Ue,onNameChange:Ke,onDescriptionChange:Bt,onDetailChange:un,onIconChange:Ut,autoFitView:xe,autoFitViewSignal:Ae,customIcons:Tt,onExportToCloud:jn,onNodeDragStart:Nt,onNodeDragStop:ho,onViewportChange:Ea,history:Wt,showToolbar:Wd,showStyleStrip:Et,showDetailPanel:Yt,showStatusBadges:Gd,showResizeHandles:Zd,showControls:Xd,showShareMenu:Kd,showMiniMap:Yd,enableKeyboard:Qd,enableContextMenu:qi,enableDragDrop:Fi,enableImageDrop:Vi,enableZoom:Bi,enablePan:Vr,enableSelection:Br,enableNodeMove:Jd,enableEmbed:eu}=e,Te=m.useMemo(()=>ent({mode:n,showToolbar:Wd,showStyleStrip:Et,showDetailPanel:Yt,showStatusBadges:Gd,showResizeHandles:Zd,showControls:Xd,showShareMenu:Kd,showMiniMap:Yd,enableKeyboard:Qd,enableContextMenu:qi,enableDragDrop:Fi,enableImageDrop:Vi,enableZoom:Bi,enablePan:Vr,enableSelection:Br,enableNodeMove:Jd,enableEmbed:eu}),[n,Wd,Et,Yt,Gd,Zd,Xd,Kd,Yd,Qd,qi,Fi,Vi,Bi,Vr,Br,Jd,eu]),$t=n==="edit",Ur=m.useRef(Te);m.useEffect(()=>{Ur.current=Te},[Te]);const Ui=xe??(n==="mini"?!0:void 0),er=m.useMemo(()=>tnt(Ui),[Ui]),tr=k==null?void 0:k.runs,Wr=k==null?void 0:k.statuses,fo=(sV=k==null?void 0:k.pendingOverrides)==null?void 0:sV.nodes,Gn=(cV=k==null?void 0:k.pendingOverrides)==null?void 0:cV.connectors,hn=m.useRef(null),Qt=m.useRef(null),po=m.useRef(!1),Wi=m.useRef(!1),tu=m.useRef(!1),Ao=m.useRef(er);Ao.current=er,m.useEffect(()=>{if(po.current||!er.onMount||h.length===0)return;const B=Qt.current;B&&(B.fitView(y2),po.current=!0)},[h,er.onMount]);const Gi=m.useRef(null),kt=J.kind==="draw"?J.shape:null,yo=J.kind==="hand",$a=m.useRef(new Map),Zi=m.useCallback((B,Z)=>($a.current.set(B,Z),()=>{$a.current.get(B)===Z&&$a.current.delete(B)}),[]),[Gr,Zr]=m.useState(!1),nu=m.useRef(!1);m.useEffect(()=>{nu.current=Gr},[Gr]);const Xi=m.useRef(!1),nr=m.useRef(!1),Xr=m.useRef(!1),[vn,or]=m.useState(null),rr=m.useRef(null);m.useEffect(()=>{rr.current=vn},[vn]),m.useCallback(()=>{or(null)},[]);const Eo=m.useMemo(()=>unt(Xr),[]),xn=m.useRef(null),$o=m.useRef(null),ja=m.useCallback(B=>{const Z=hn.current;if(!Z){xn.current=B;return}const ae=xn.current;if(ae&&ae!==B){const le=Z.querySelector(`.react-flow__node[data-id="${CSS.escape(ae)}"]`);le==null||le.removeAttribute("data-connect-source")}if(B){const le=Z.querySelector(`.react-flow__node[data-id="${CSS.escape(B)}"]`);le==null||le.setAttribute("data-connect-source","true")}xn.current=B},[]),Pn=m.useCallback(B=>{const Z=hn.current,ae=$o.current;if(ae!==B){if(Z&&ae){const le=Z.querySelector(`.react-flow__node[data-id="${CSS.escape(ae)}"]`);le==null||le.removeAttribute("data-connect-target")}if(Z&&B){const le=Z.querySelector(`.react-flow__node[data-id="${CSS.escape(B)}"]`);le==null||le.setAttribute("data-connect-target","true")}$o.current=B}},[]),Pa=m.useCallback(()=>{ja(null),Pn(null)},[ja,Pn]);m.useEffect(()=>{if(!Gr){Pn(null);return}let B=null,Z=null;const ae=()=>{B=null;const de=Z;if(Z=null,!de)return;const $e=aD(hn.current,de.clientX,de.clientY),Me=($e==null?void 0:$e.getAttribute("data-id"))??null;if(Me&&Me===xn.current){Pn(null);return}Pn(Me)},le=de=>{Z={clientX:de.clientX,clientY:de.clientY},B===null&&(B=requestAnimationFrame(ae))};return document.addEventListener("pointermove",le,{passive:!0}),()=>{document.removeEventListener("pointermove",le),B!==null&&cancelAnimationFrame(B)}},[Gr,Pn]);const[ar,za]=m.useState(null),[ct,Ra]=m.useState(null),ir=m.useRef(null),mo=m.useRef(null),Kr=m.useRef(null),Ta=m.useRef(!1);m.useEffect(()=>{ir.current=kt},[kt]);const ou=m.useCallback(()=>{ue({kind:"select"}),za(null),Ra(null),ir.current=null,mo.current=null,Kr.current=null,Ta.current=!1},[ue]);m.useEffect(()=>{if(!Te.enableKeyboard)return;const B=Z=>{var de,$e;if(Z.key!=="Escape"||uO(document.activeElement))return;if(ir.current){Z.preventDefault(),ou();return}if(nu.current){Z.preventDefault(),Xi.current=!0,nr.current=!0;try{(de=Gi.current)==null||de.getState().cancelConnection()}catch{}document.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!0,button:0})),Zr(!1);return}if(rr.current){Z.preventDefault(),or(null);return}const ae=zn.current.size>0,le=ea.current.size>0;(ae||le)&&(Z.preventDefault(),($e=sr.current)==null||$e.call(sr,[],[]))};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[ou,Te.enableKeyboard]),m.useEffect(()=>{if(!Te.enableKeyboard)return;const B=Z=>{const ae=pDe(Z,{isEditableActive:uO(document.activeElement)});ae&&Wt&&(Z.preventDefault(),Z.stopPropagation(),ae==="undo"?Wt.undo():Wt.redo())};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[Wt,Te.enableKeyboard]),m.useEffect(()=>{if(!Te.enableKeyboard)return;const B=Z=>{ynt({event:Z,selectedNodeIds:f,hasClipboard:!!F,activeElement:document.activeElement,onCopySelection:D,onPasteSelection:E})};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[f,F,D,E,Te.enableKeyboard]);const Nf=m.useCallback(B=>{var le,de;if(!ir.current)return;const Z=B.target;if(!(Z!=null&&Z.classList.contains("react-flow__pane")))return;const ae={x:B.clientX,y:B.clientY};Ta.current=!0,mo.current=ae,Kr.current=ae,za(ae),Ra(ae);try{(de=(le=B.currentTarget).setPointerCapture)==null||de.call(le,B.pointerId)}catch{}B.preventDefault(),B.stopPropagation()},[]),NR=m.useCallback(B=>{if(!Ta.current)return;const Z={x:B.clientX,y:B.clientY};Kr.current=Z,Ra(Z)},[]),AR=m.useCallback(B=>{var lr,J0;if(!Ta.current)return;Ta.current=!1;try{(J0=(lr=B.currentTarget).releasePointerCapture)==null||J0.call(lr,B.pointerId)}catch{}const Z=mo.current,ae=Kr.current,le=ir.current,de=Qt.current;if(ou(),!Z||!ae||!le||!de)return;const $e=Math.min(Z.x,ae.x),Me=Math.min(Z.y,ae.y),Ee=Math.max(Z.x,ae.x),et=Math.max(Z.y,ae.y),lt=Ee-$e,pt=et-Me,ze=de.screenToFlowPosition({x:$e,y:Me}),Rn=de.screenToFlowPosition({x:Ee,y:et}),cr=Rn.x-ze.x,yt=Rn.y-ze.y,Se=lt<iZ||pt<iZ,Jt=Se?tz[le].width:cr,su=Se?tz[le].height:yt;N==null||N(le,ze,{width:Jt,height:su})},[ou,N]),Yr=m.useRef(!1),Ki=m.useRef(!1),G0=m.useRef(new Map),Da=m.useCallback(()=>{var B;Wi.current&&(Ki.current||Yr.current||(Wi.current=!1,(B=Qt.current)==null||B.fitView(y2)))},[]),Z0=m.useCallback(B=>{Ki.current=B,B||Da()},[Da]);m.useEffect(()=>{var B;if(!tu.current){tu.current=!0;return}if(Ao.current.onExternalNodeChange){if(Ki.current||Yr.current){Wi.current=!0;return}(B=Qt.current)==null||B.fitView(y2)}},[Ae]);const X0=!!O||!!I||!!z||!!L||!!an,[V,q]=m.useState(null),[U,G]=m.useState(!1),[ee,He]=m.useState(null),[it,ot]=m.useState(null),ft=m.useRef(null),Zn=m.useRef(null);m.useEffect(()=>{if(!V)return;const B=Zn.current;if(!B)return;const Z=new MouseEvent("contextmenu",{clientX:V.x,clientY:V.y,bubbles:!0,cancelable:!0,button:2,buttons:2});B.dispatchEvent(Z)},[V]);const Qr=m.useCallback(B=>{const Z=ft.current;!Z||!O||O(Z,B)},[O]),Oe=m.useCallback(()=>{const B=ft.current;!B||!I||I(B)},[I]),wn=m.useCallback(()=>{const B=ft.current;!B||!z||z(B)},[z]),ru=m.useCallback(()=>{const B=ft.current;!B||!re||re(B)},[re]);m.useCallback((B,Z,ae,le,de)=>{Ur.current.enableContextMenu&&(ft.current=null,G(!1),He(null),ot({connectorId:B,kind:Z,pinned:ae}),q({x:le,y:de}))},[]);const au=m.useCallback(()=>{const B=it;!B||!an||an(B.connectorId,B.kind)},[it,an]),iu=m.useCallback(()=>{if(!L)return;const B=V,Z=Qt.current;if(!B||!Z)return;const ae=Z.screenToFlowPosition({x:B.x,y:B.y});L(ae)},[V,L]),Af=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent||""),ER=Af?"⌘C":"Ctrl+C",Yi=Af?"⌘V":"Ctrl+V",Fe=m.useMemo(()=>new Set(f),[f]),Mt=m.useMemo(()=>new Set(y),[y]),Mn=m.useMemo(()=>{if(f.length<2)return[];const B=fo,Z=[];for(const ae of f){const le=h.find(Ee=>Ee.id===ae);if(!le)continue;const de=B==null?void 0:B[ae],$e=(de==null?void 0:de.data)??{},Me=le.data;Z.push({id:ae,position:(de==null?void 0:de.position)??le.position,data:{width:$e.width??Me.width,height:$e.height??Me.height}})}return Z},[h,fo,f]),go=K??[],Jr=m.useMemo(()=>{const B=de=>{const $e=$t?void 0:G0.current.get(de.id),Me={id:de.id,type:de.type,position:$e??de.position,data:{...de.data,projectId:i,fileBaseUrl:c,projectSlug:de.type==="component"?i:void 0,flowSlug:de.type==="component"?s:void 0,apiBaseUrl:de.type==="component"?l:void 0,onRetryUpload:W,status:mnt(tr,de.id),errorMessage:gnt(tr,de.id),statusReport:Wr==null?void 0:Wr[de.id],onPlay:x,onResize:w,onResizeEnd:b,setResizing:Z0,onFitToContent:de.type==="html"?C:de.type==="component"?_:void 0,onNameChange:(()=>{if($t&&de.type!=="ellipse")return j})(),onDescriptionChange:(()=>{if($t&&(de.type==="rectangle"||de.type==="ellipse"||de.type==="sticky"))return P})(),onIconChange:(()=>{if($t&&!(de.type!=="rectangle"&&de.type!=="component"))return Ut})(),autoEditOnMount:Vt===de.id?!0:void 0},selected:Fe.has(de.id)};return(!(de.data.autoSize===!0)||Ki.current)&&(de.data.width!==void 0&&(Me.width=de.data.width),de.data.height!==void 0&&(Me.height=de.data.height)),Fe.has(de.id)||(Me.connectable=!1),Me},Z=h.map(de=>B(rnt(de,fo==null?void 0:fo[de.id]))),ae=new Set(h.map(de=>de.id)),le=[];if(fo)for(const[de,$e]of Object.entries(fo)){if(ae.has(de))continue;const Me=$e;typeof Me.type!="string"||!Me.position||!Me.data||le.push(B({...Me,id:de}))}return[...Z,...le]},[i,s,c,l,h,Fe,tr,Wr,x,w,b,C,_,Z0,fo,j,P,Ut,W,Vt,$t]),[Qi,K0]=m.useState(Jr);m.useEffect(()=>{Yr.current||Ki.current||K0(Jr)},[Jr]),m.useEffect(()=>{Y0.current=Qi},[Qi]);const zn=m.useRef(Fe);m.useEffect(()=>{zn.current=Fe},[Fe]);const sr=m.useRef(g);m.useEffect(()=>{sr.current=g},[g]);const ea=m.useRef(Mt);m.useEffect(()=>{ea.current=Mt},[Mt]);const Y0=m.useRef(Jr),Ji=m.useRef(!1),Ef=m.useRef(new Set),$f=m.useRef(new Set),$R=m.useRef(new Set),jR=m.useRef(new Set),Ha=m.useRef(null),Gre=m.useCallback(B=>{var yt;const Z=Ji.current?$R.current:(yt=Ha.current)!=null&&yt.shift?Ha.current.nodeIds:null,ae=Z&&Z.size>0?B.filter(Se=>Se.type!=="select"?!0:!(Se.selected===!1&&Z.has(Se.id))):B,le=new Set;for(const Se of ae)Se.type==="select"&&le.add(Se.id);const de=vQ(ae,Y0.current),$e=new Set;if(Ki.current)for(const Se of ae)Se.type==="dimensions"&&$e.add(Se.id);const Me=$e.size===0?de:de.map(Se=>!$e.has(Se.id)||Se.width===void 0&&Se.height===void 0?Se:{...Se,data:{...Se.data,...Se.width!==void 0?{width:Se.width}:{},...Se.height!==void 0?{height:Se.height}:{}}}),Ee=zn.current,et=Ji.current||Ee.size===0?Me:Me.map(Se=>Ee.has(Se.id)&&!le.has(Se.id)&&!Se.selected?{...Se,selected:!0}:Se);if(Y0.current=et,K0(et),le.size===0)return;if(Ji.current){for(const Se of ae)Se.type==="select"&&(Se.selected?Ef.current.add(Se.id):Ef.current.delete(Se.id));return}const lt=sr.current;if(!lt)return;const pt=et.filter(Se=>Se.selected).map(Se=>Se.id),ze=zn.current;ze.size===pt.length&&pt.every(Se=>ze.has(Se))||(zn.current=new Set(pt),lt(pt,[...ea.current]))},[]),jf=m.useRef([]),Zre=m.useCallback(B=>{var pt;const Z=Ji.current?jR.current:(pt=Ha.current)!=null&&pt.shift?Ha.current.edgeIds:null,ae=Z&&Z.size>0?B.filter(ze=>ze.type!=="select"?!0:!(ze.selected===!1&&Z.has(ze.id))):B,le=new Set;for(const ze of ae)ze.type==="select"&&le.add(ze.id);if(le.size===0)return;if(Ji.current){for(const ze of ae)ze.type==="select"&&(ze.selected?$f.current.add(ze.id):$f.current.delete(ze.id));return}const de=sr.current;if(!de)return;const Me=xQ(ae,jf.current).filter(ze=>ze.selected).map(ze=>ze.id),Ee=ea.current;Ee.size===Me.length&&Me.every(ze=>Ee.has(ze))||(ea.current=new Set(Me),de([...zn.current],Me))},[]),Xre=m.useCallback(B=>{Ji.current=!0;const Z=Ha.current,ae=(Z==null?void 0:Z.shift)??(B.shiftKey||B.metaKey||B.ctrlKey);$R.current=ae?new Set((Z==null?void 0:Z.nodeIds)??zn.current):new Set,jR.current=ae?new Set((Z==null?void 0:Z.edgeIds)??ea.current):new Set,Ef.current=new Set($R.current),$f.current=new Set(jR.current)},[]),Kre=m.useCallback(()=>{Ji.current=!1,Ha.current=null;const B=sr.current;if(!B)return;const Z=[...Ef.current],ae=new Set(Z),le=new Set($f.current);for(const et of jf.current)ae.has(et.source)&&ae.has(et.target)&&le.add(et.id);const de=zn.current,$e=ea.current,Me=de.size===ae.size&&Z.every(et=>de.has(et)),Ee=$e.size===le.size&&[...le].every(et=>$e.has(et));Me&&Ee||(zn.current=new Set(Z),ea.current=new Set(le),B(Z,[...le]))},[]),Yre=m.useCallback(B=>{if(Ha.current=null,ir.current||B.button!==0)return;const Z=B.target;Z!=null&&Z.classList.contains("react-flow__pane")&&(Ha.current={shift:B.shiftKey||B.metaKey||B.ctrlKey,nodeIds:new Set(zn.current),edgeIds:new Set(ea.current)})},[]),Qre=m.useCallback(B=>{if(!Ur.current.enableContextMenu||zn.current.size<2)return;const ae=B.target;ae!==Zn.current&&(ae!=null&&ae.closest(".seeflow-connector-endpoint-dot")||(B.preventDefault(),B.stopPropagation(),ft.current=null,G(!0),He(null),ot(null),q({x:B.clientX,y:B.clientY})))},[]),Jre=m.useCallback(B=>{const Z=B.dataTransfer;if(!Z)return;const ae=Z.types?Array.from(Z.types):[],le=ae.includes("Files"),de=ae.includes(FW),$e=le&&!!R&&Te.enableImageDrop,Me=de&&!!$&&Te.enableDragDrop;if(!(!$e&&!Me)){B.preventDefault();try{Z.dropEffect="copy"}catch{}}},[R,$,Te.enableImageDrop,Te.enableDragDrop]),eae=m.useCallback(B=>{const Z=B.dataTransfer;if((Z!=null&&Z.types?Array.from(Z.types):[]).includes(FW)&&$&&Te.enableDragDrop){B.preventDefault();const $e=Qt.current;if(!$e)return;const Me=$e.screenToFlowPosition({x:B.clientX,y:B.clientY});$({position:Me});return}if(!R||!Te.enableImageDrop)return;const de={x:B.clientX,y:B.clientY};B.preventDefault(),ENe({dataTransfer:Z,clientPos:de,rfInstance:Qt.current,computeDims:$Ne,dispatch:R})},[R,$,Te.enableImageDrop,Te.enableDragDrop]),GF=!!T,ZF=Mt.size===1?[...Mt][0]:null,PR=m.useMemo(()=>{const B=Ee=>{const et=uZ(tr,Ee.source)==="running"||uZ(tr,Ee.target)==="running",lt=Mt.has(Ee.id),pt=HTe(Ee,et,lt);lt&&(pt.selected=!0);const ze=GF&&Ee.id===ZF,Rn=ze?{...pt,reconnectable:!0}:pt;return{...Rn,data:{...Rn.data,onLabelChange:$t?A:void 0,reconnectable:ze,registerEditHandle:Zi}}},Z=new Set(u.map(Ee=>Ee.id)),ae=u.map(Ee=>B(ant(Ee,Gn==null?void 0:Gn[Ee.id]))),le=[];if(Gn)for(const[Ee,et]of Object.entries(Gn)){if(Z.has(Ee))continue;const lt=et;typeof lt.source!="string"||typeof lt.target!="string"||le.push(B({...lt,id:Ee}))}const de=[...ae,...le],$e=[],Me=[];for(const Ee of de)Mt.has(Ee.id)?Me.push(Ee):$e.push(Ee);return[...$e,...Me]},[u,tr,Mt,ZF,Gn,A,GF,Zi,$t]);m.useEffect(()=>{jf.current=PR},[PR]);const Q0=e.adapter??null,tae=m.useMemo(()=>{if(Q0!=null&&Q0.computeLayout)return async()=>{const B=Qt.current,Z=Y0.current;if(Z.length<2)return;const ae=Z.map(yt=>{var J0;const Se=(J0=B==null?void 0:B.getInternalNode(yt.id))==null?void 0:J0.measured,Jt=yt.data,su=(Se==null?void 0:Se.width)??Jt.width??200,lr=(Se==null?void 0:Se.height)??Jt.height??120;return{id:yt.id,type:yt.type,width:su,height:lr}}),le=new Map;for(const yt of Z)le.set(yt.id,yt.position);const de=jf.current.map(yt=>({id:yt.id,source:yt.source,target:yt.target})),$e=Q0.computeLayout;if(!$e)return;const Me=await $e(ae,de),Ee=new Map;for(const[yt,Se]of Object.entries(Me.nodes))Ee.set(yt,Se.position);let et=Number.POSITIVE_INFINITY,lt=Number.POSITIVE_INFINITY,pt=Number.POSITIVE_INFINITY,ze=Number.POSITIVE_INFINITY;for(const yt of ae){const Se=le.get(yt.id);if(!Se)continue;Se.x<et&&(et=Se.x),Se.y<lt&&(lt=Se.y);const Jt=Ee.get(yt.id);Jt&&(Jt.x<pt&&(pt=Jt.x),Jt.y<ze&&(ze=Jt.y))}const Rn=Number.isFinite(et)&&Number.isFinite(pt)?et-pt:0,cr=Number.isFinite(lt)&&Number.isFinite(ze)?lt-ze:0;K0(yt=>yt.map(Se=>{const Jt=Ee.get(Se.id);return Jt?{...Se,position:{x:Jt.x+Rn,y:Jt.y+cr}}:Se}))}},[Q0]),Pf=ve??($t?void 0:tae),zf=m.useRef(!1),XF=m.useRef(null),nae=m.useCallback(B=>{var Ee;if(!$t||!H)return;const{source:Z,target:ae}=B;if(!Z||!ae||Z===ae)return;zf.current=!0;const le=((Ee=XF.current)==null?void 0:Ee.nodeId)??null,de=le!==null&&le===ae&&le!==Z;H(de?ae:Z,de?Z:ae)},[H,$t]),zR=m.useCallback(B=>{const Z=ae=>{if(!ae)return!1;const le=Y0.current.find(de=>de.id===ae);return le?le.type==="text":!1};return!Z(B.source)&&!Z(B.target)},[]),oae=m.useCallback((B,Z)=>{var pt;Zr(!1),Pa();const ae=zf.current;if(zf.current=!1,ae||Xr.current)return;if(Xi.current){Xi.current=!1;return}if(!H)return;const le=(pt=Z.fromNode)==null?void 0:pt.id,de=Z.fromHandle;if(!le||!de)return;const $e=sZ(B);if(!$e)return;const Me=aD(hn.current,$e.clientX,$e.clientY);if(!Me)return;const Ee=Me.getAttribute("data-id");if(!Ee||Ee===le||!zR({source:le,target:Ee,sourceHandle:null,targetHandle:null}))return;let et;const lt=Qt.current;if(lt){const ze=lt.getInternalNode(Ee);if(ze){const Rn=ze.measured.width??ze.width??0,cr=ze.measured.height??ze.height??0;if(Rn>0&&cr>0){const yt=lt.screenToFlowPosition({x:$e.clientX,y:$e.clientY});et=bH({x:ze.internals.positionAbsolute.x,y:ze.internals.positionAbsolute.y,w:Rn,h:cr},yt)}}}H(le,Ee,et?{targetPin:et}:void 0)},[H,Pa,zR]),Rf=m.useRef(!1),rae=m.useCallback((B,Z)=>{if(!T)return;const{source:ae,target:le,sourceHandle:de,targetHandle:$e}=Z;if(!ae||!le||ae===le)return;const Me={};if(ae!==B.source&&(Me.source=ae),le!==B.target&&(Me.target=le),typeof de=="string"&&de!==B.sourceHandle&&(Me.sourceHandle=de),typeof $e=="string"&&$e!==B.targetHandle&&(Me.targetHandle=$e),Me.source===void 0&&Me.target===void 0&&Me.sourceHandle===void 0&&Me.targetHandle===void 0)return;(Me.source!==void 0||Me.sourceHandle!==void 0)&&(Me.sourceHandleAutoPicked=!1),(Me.target!==void 0||Me.targetHandle!==void 0)&&(Me.targetHandleAutoPicked=!1);const Ee=Qt.current;if(!(Me.source===void 0&&Me.target===void 0)&&Ee){const lt=Me.source!==void 0?"source":"target",pt=cZ(lt,B.source,B.target,B.data,ze=>Ee.getInternalNode(ze)??null);pt&&(lt==="source"?Me.targetPin=pt:Me.sourcePin=pt)}Rf.current=!0,T(B.id,Me)},[T]),aae=m.useCallback((B,Z,ae,le)=>{var su;Zr(!1),Pa(),Xr.current=!1;const de=Rf.current;if(Rf.current=!1,de)return;if(nr.current){nr.current=!1;return}if(!T)return;const $e=sZ(B);let Me=((su=le.toNode)==null?void 0:su.id)??null;if(!Me&&$e){const lr=aD(hn.current,$e.clientX,$e.clientY);Me=(lr==null?void 0:lr.getAttribute("data-id"))??null}const Ee=ae==="source"?"target":"source",et=ont(Ee,Z.source,Z.target,Me);if(et==="no-op"||et==="self-loop"||!$e)return;const lt=Qt.current;if(!lt)return;const pt=et==="pin-own"?Ee==="source"?Z.source:Z.target:Me,ze=lt.getInternalNode(pt);if(!ze)return;const Rn=ze.measured.width??ze.width??0,cr=ze.measured.height??ze.height??0;if(Rn===0||cr===0)return;const yt=lt.screenToFlowPosition({x:$e.clientX,y:$e.clientY}),Se=bH({x:ze.internals.positionAbsolute.x,y:ze.internals.positionAbsolute.y,w:Rn,h:cr},yt);if(et==="pin-own"){if(!Be)return;Be(Z.id,Ee,Se);return}const Jt=cZ(Ee,Z.source,Z.target,Z.data,lr=>lt.getInternalNode(lr)??null);Ee==="source"?T(Z.id,{source:Me,sourceHandle:null,sourceHandleAutoPicked:!1,sourcePin:Se,...Jt?{targetPin:Jt}:{}}):T(Z.id,{target:Me,targetHandle:null,targetHandleAutoPicked:!1,targetPin:Se,...Jt?{sourcePin:Jt}:{}})},[T,Pa,Be]),es=m.useMemo(()=>{var Ee;if(!ar||!ct)return null;const B=(Ee=hn.current)==null?void 0:Ee.getBoundingClientRect(),Z=(B==null?void 0:B.left)??0,ae=(B==null?void 0:B.top)??0,le=Math.min(ar.x,ct.x),de=Math.min(ar.y,ct.y),$e=Math.abs(ct.x-ar.x),Me=Math.abs(ct.y-ar.y);return{left:le-Z,top:de-ae,width:$e,height:Me}},[ar,ct]),Oa=kt?_2(Xa).node:void 0,iae=kt?Iee(kt):"",sae=kt?Nee(kt,Oa):void 0,cae=kt==="text",[KF,YF]=m.useState(!1),[lae,Tf]=m.useState(!1),[dae,QF]=m.useState(!1),[JF,uae]=m.useState(()=>({canUndo:(Wt==null?void 0:Wt.canUndo)??!1,canRedo:(Wt==null?void 0:Wt.canRedo)??!1}));m.useEffect(()=>Wt?Wt.subscribe(uae):void 0,[Wt]);const hae=Wt?JF.canUndo:!1,fae=Wt?JF.canRedo:!1,qa=Wtt({projectId:i,getReactFlow:()=>Qt.current});m.useImperativeHandle(t,()=>({exportPdf:qa.exportPdf,exportPng:qa.exportPng,openEmbedDialog:()=>QF(!0),capturePreview:qa.capturePreview}),[qa.exportPdf,qa.exportPng,qa.capturePreview]),m.useEffect(()=>{if(!Te.enableKeyboard)return;const B=le=>{if(!le)return!1;const de=le.tagName;return de==="INPUT"||de==="TEXTAREA"||de==="SELECT"?!0:le instanceof HTMLElement&&le.isContentEditable},Z=le=>{le.code==="Space"&&(B(document.activeElement)||(le.preventDefault(),YF(!0)))},ae=le=>{le.code==="Space"&&(YF(!1),Tf(!1))};return window.addEventListener("keydown",Z),window.addEventListener("keyup",ae),()=>{window.removeEventListener("keydown",Z),window.removeEventListener("keyup",ae)}},[Te.enableKeyboard]);const Df=m.useCallback(B=>{if(B.length!==0){if(!$t){const Z=G0.current;for(const ae of B)Z.set(ae.id,{x:ae.position.x,y:ae.position.y});return}if(B.length===1){const Z=B[0];Z&&v&&v(Z.id,{x:Z.position.x,y:Z.position.y});return}if(M){M(B.map(Z=>({id:Z.id,position:{x:Z.position.x,y:Z.position.y}})));return}if(v)for(const Z of B)v(Z.id,{x:Z.position.x,y:Z.position.y})}},[v,M,$t]),eV=m.useCallback((B,Z,ae)=>{Yr.current=!1,Df(ae),Da()},[Df,Da]),tV=m.useCallback(()=>{Yr.current=!0},[]),nV=m.useCallback((B,Z)=>{Yr.current=!1,Df(Z),Da()},[Df,Da]),pae=m.useCallback((B,Z)=>{rr.current&&or(null);const ae=hn.current;ae&&ae.style.setProperty("--rf-zoom",String(Z.zoom)),Ea==null||Ea(Z)},[Ea]),yae=m.useCallback(()=>{Yr.current=!0,Nt==null||Nt()},[Nt]),mae=m.useCallback((B,Z,ae)=>{eV(B,Z,ae),ho==null||ho()},[eV,ho]),gae=m.useCallback(()=>{tV(),Nt==null||Nt()},[tV,Nt]),kae=m.useCallback((B,Z)=>{nV(B,Z),ho==null||ho()},[nV,ho]),vae=m.useCallback((B,Z)=>{var ae;(ae=$a.current.get(Z.id))==null||ae()},[]),xae=m.useCallback((B,Z)=>{ce==null||ce(Z.id)},[ce]),wae=m.useCallback(B=>{Re==null||Re()},[Re]),Mae=m.useCallback((B,Z)=>{Ce==null||Ce(Z.id)},[Ce]),oV=kt?"crosshair":yo||KF?lae?"grabbing":"grab":void 0,rV=f.length+y.length===1,aV=rV?f[0]:void 0,iV=rV?y[0]:void 0,bae=aV?h.find(B=>B.id===aV)??null:null,_ae=iV?u.find(B=>B.id===iV)??null:null,Cae=i??null,Sae=Te.showDetailPanel&&!je,Lae=m.useMemo(()=>({custom:Tt??{}}),[Tt]);return p.jsx(QHe,{value:Lae,children:p.jsx("div",{"data-testid":"seeflow-canvas","data-mode":n,"data-canvas-mode":J.kind,"data-can-undo":hae?"true":"false","data-can-redo":fae?"true":"false",ref:hn,className:"seeflow-canvas-root sf:relative sf:h-full sf:w-full",style:oV?{cursor:oV}:void 0,onPointerDownCapture:Yre,onPointerDown:B=>{KF&&Tf(!0),Nf(B)},onPointerMove:NR,onPointerUp:B=>{Tf(!1),AR(B)},onPointerCancel:()=>{Ta.current=!1,mo.current=null,Kr.current=null,za(null),Ra(null),Tf(!1)},onContextMenuCapture:Qre,onDragOver:Jre,onDrop:eae,children:p.jsxs(dVe,{containerRef:hn,children:[p.jsxs(nTe,{nodes:Qi,edges:PR,onNodesChange:Gre,nodeTypes:int,edgeTypes:snt,proOptions:lnt,fitView:!0,minZoom:n==="mini"?.05:.5,nodesDraggable:($t?!!v:!0)&&!kt&&!yo&&Te.enableNodeMove,nodesConnectable:$t&&!!H&&!kt&&!yo,deleteKeyCode:$t?["Backspace","Delete"]:null,zoomOnScroll:Te.enableZoom,zoomOnPinch:Te.enableZoom,className:Gr?"seeflow-connecting":void 0,onConnect:$t?nae:void 0,isValidConnection:zR,onConnectStart:(B,Z)=>{Zr(!0),zf.current=!1,XF.current={nodeId:Z.nodeId??null,handleType:Z.handleType??null},ja(Z.nodeId??null)},onConnectEnd:oae,onReconnect:$t&&T?rae:void 0,onReconnectStart:(B,Z,ae)=>{Zr(!0),Rf.current=!1,Xr.current=!0;const le=ae==="source"?Z.source:Z.target;ja(le)},onReconnectEnd:aae,connectionLineComponent:Eo,connectionLineStyle:{strokeWidth:2},connectionRadius:32,reconnectRadius:10,edgesReconnectable:!1,elevateNodesOnSelect:!1,elementsSelectable:!kt&&!yo&&Te.enableSelection,selectNodesOnDrag:!1,nodeClickDistance:5,selectionOnDrag:!kt&&!yo&&Te.enableSelection,panOnDrag:kt?!1:yo?[0,1,2]:Te.enablePan?[1,2]:!1,selectionMode:f0.Partial,selectionKeyCode:null,multiSelectionKeyCode:kt?null:["Meta","Shift"],panActivationKeyCode:kt?null:"Space",onSelectionStart:Xre,onSelectionEnd:Kre,defaultEdgeOptions:cnt,zoomOnDoubleClick:!1,onInit:B=>{Qt.current=B;const Z=hn.current;Z&&Z.style.setProperty("--rf-zoom",String(B.getZoom())),Z&&Z.setAttribute("data-canvas-ready","true"),!po.current&&er.onMount&&h.length>0&&(B.fitView(y2),po.current=!0),ge==null||ge(B)},onMove:pae,onEdgesChange:Zre,onNodeDragStart:yae,onNodeDragStop:mae,onSelectionDragStart:gae,onSelectionDragStop:kae,onNodeClick:xae,onEdgeClick:Mae,onEdgeDoubleClick:vae,onPaneClick:wae,onNodeContextMenu:Te.enableContextMenu&&X0?(B,Z)=>{B.preventDefault(),ft.current=Z.id,G(!0),He(Z.type??null),ot(null),q({x:B.clientX,y:B.clientY})}:void 0,onPaneContextMenu:Te.enableContextMenu&&L?B=>{B.preventDefault(),ft.current=null,G(!1),He(null),ot(null),q({x:B.clientX,y:B.clientY})}:void 0,children:[p.jsx(hnt,{storeApiRef:Gi}),p.jsx(fnt,{wrapperRef:hn}),p.jsx(uTe,{gap:12,size:.6}),n!=="mini"&&p.jsx(Ktt,{}),Te.showControls?p.jsxs(kTe,{showInteractive:!1,showFitView:!1,children:[p.jsx(Tu,{"data-testid":"controls-fit-view","aria-label":"Fit view",title:"Fit view",disabled:h.length===0,onClick:()=>{var B;(B=Qt.current)==null||B.fitView(y2)},children:p.jsx(gd,{className:"sf:h-3 sf:w-3","aria-hidden":"true"})}),p.jsx(Tu,{"data-testid":"controls-tidy","aria-label":"Tidy layout (⌘⇧L)",title:"Tidy layout (⌘⇧L)",disabled:!Pf,onClick:()=>Pf==null?void 0:Pf(),children:p.jsx(X2,{className:"sf:h-3 sf:w-3","aria-hidden":"true"})})]}):null,Te.showMiniMap?p.jsx(ETe,{className:"sf-canvas-minimap"}):null,Te.showResizeHandles?p.jsx(Fet,{selectedNodes:Mn,onMultiResize:S}):null,r||Te.showToolbar||Te.showStyleStrip&&Y&&ie?p.jsx(k0,{position:"top-left",children:p.jsxs("div",{className:"sf:flex sf:flex-col sf:items-start sf:gap-2",children:[r,Te.showToolbar?p.jsx(fGe,{mode:J,onModeChange:ue,iconPickerOpen:It??!1,onOpenIconPicker:pe,onCloseIconPicker:se,onPickIcon:we,showShapeTools:$t&&!!N}):null,Te.showStyleStrip&&Y&&ie?p.jsx(Uet,{nodes:go,connectors:X??[],onStyleNode:Y,onStyleNodePreview:Q,onStyleNodes:te,onStyleNodesPreview:ne,onStyleConnector:ie,onStyleConnectorPreview:ke,onRequestIconReplace:re}):null]})}):null,Te.showShareMenu||a?p.jsx(k0,{position:"top-right",children:p.jsxs("div",{className:"sf:flex sf:items-center sf:gap-1",children:[a,Te.showShareMenu?p.jsx(Det,{mode:n==="mini"?"view":n,projectId:i,enableEmbed:Te.enableEmbed,onDownloadPdf:qa.exportPdf,onDownloadPng:qa.exportPng,onExportToCloud:jn,embedOpen:dae,onEmbedOpenChange:QF}):null]})}):null]}),es?p.jsx("div",{"data-testid":"canvas-draw-ghost","data-ghost-shape":kt??void 0,"aria-hidden":!0,className:oe("sf:pointer-events-none sf:absolute sf:z-10",iae,cae?"sf:rounded-sm sf:border sf:border-dashed sf:border-muted-foreground/40":""),style:{...sae,left:es.left,top:es.top,width:es.width,height:es.height},children:(()=>{const B=kt?tF[kt]:void 0;if(!B)return null;const Z=Aee(Oa);return p.jsx(B,{width:es.width,height:es.height,borderColor:Z.borderColor,backgroundColor:Z.backgroundColor,borderSize:(Oa==null?void 0:Oa.borderSize)??jq,borderStyle:Oa==null?void 0:Oa.borderStyle})})()}):null,Te.enableContextMenu&&X0?p.jsxs(rWe,{onOpenChange:B=>{B||(q(null),ft.current=null,He(null),ot(null))},children:[p.jsx(aWe,{asChild:!0,children:p.jsx("div",{ref:Zn,"data-testid":"node-context-menu-trigger","aria-hidden":!0,className:"sf:pointer-events-none sf:fixed",style:{left:(V==null?void 0:V.x)??0,top:(V==null?void 0:V.y)??0,width:0,height:0}})}),p.jsxs(ine,{"data-testid":"node-context-menu",children:[it!=null&&it.pinned&&an?p.jsx(xr,{"data-testid":"connector-endpoint-context-menu-unpin",onSelect:au,children:"Unpin"}):null,U&&z?p.jsxs(xr,{"data-testid":"node-context-menu-copy",onSelect:wn,children:["Copy",p.jsx(WH,{children:ER})]}):null,L?p.jsxs(xr,{"data-testid":"node-context-menu-paste",disabled:!F,onSelect:iu,children:["Paste",p.jsx(WH,{children:Yi})]}):null,U&&(z||L)&&(ee==="icon"&&re||O||I)?p.jsx(oP,{}):null,U&&ee==="icon"&&re?p.jsx(xr,{"data-testid":"node-context-menu-change-icon",onSelect:ru,children:"Change icon"}):null,U&&ee==="icon"&&re&&(O||I)?p.jsx(oP,{}):null,U&&O?p.jsxs(p.Fragment,{children:[p.jsx(xr,{"data-testid":"node-context-menu-to-front",onSelect:()=>Qr({op:"toFront"}),children:"Bring to front"}),p.jsx(xr,{"data-testid":"node-context-menu-forward",onSelect:()=>Qr({op:"forward"}),children:"Bring forward"}),p.jsx(xr,{"data-testid":"node-context-menu-backward",onSelect:()=>Qr({op:"backward"}),children:"Send backward"}),p.jsx(xr,{"data-testid":"node-context-menu-to-back",onSelect:()=>Qr({op:"toBack"}),children:"Send to back"})]}):null,U&&O&&I?p.jsx(oP,{}):null,U&&I?p.jsx(xr,{"data-testid":"node-context-menu-delete",onSelect:Oe,children:"Delete"}):null]})]}):null,st?p.jsxs(Dd,{open:!!vn,onOpenChange:B=>{B||or(null)},children:[p.jsx(uVe,{asChild:!0,children:p.jsx("div",{"data-testid":"drop-popover-anchor","aria-hidden":!0,className:"sf:pointer-events-none sf:fixed",style:{left:(vn==null?void 0:vn.clientX)??0,top:(vn==null?void 0:vn.clientY)??0,width:0,height:0}})}),p.jsx(zi,{"data-testid":"drop-popover",align:"start",side:"bottom",sideOffset:4,className:"sf:w-auto sf:p-1",onOpenAutoFocus:B=>{B.preventDefault()},children:p.jsx("div",{role:"menu","aria-label":"Create connected node",className:"sf:flex sf:flex-col sf:gap-0.5",children:hGe.map(({shape:B,label:Z,Icon:ae})=>p.jsxs("button",{type:"button",role:"menuitem","data-testid":`drop-popover-shape-${B}`,onClick:()=>{const le=vn;le&&(st({sourceNodeId:le.sourceNodeId,position:{x:le.flowX,y:le.flowY},shape:B}),or(null))},className:oe("sf:flex sf:items-center sf:gap-2 sf:rounded-sm sf:px-2 sf:py-1.5 sf:text-left sf:text-sm","sf:hover:bg-accent sf:hover:text-accent-foreground","sf:focus:bg-accent sf:focus:text-accent-foreground sf:focus:outline-hidden"),children:[p.jsx(ae,{className:"sf:h-4 sf:w-4 sf:text-muted-foreground","aria-hidden":"true"}),p.jsx("span",{children:Z})]},B))})})]}):null,Sae?p.jsx(cet,{flowId:Cae,node:bae,connector:_ae,adapter:o??null,statusReport:Ue,onNameChange:Ke,onDescriptionChange:Bt,onDetailChange:un,onIconChange:Ut,onClose:()=>{var B;(B=sr.current)==null||B.call(sr,[],[])}}):null]})})})}const vnt=m.forwardRef(knt);function xnt({open:e,onOpenChange:t,onCreated:n}){const[o,r]=m.useState(""),[a,i]=m.useState(""),[s,c]=m.useState(""),[l,h]=m.useState(null),[u,f]=m.useState(!1);m.useEffect(()=>{e&&(r(""),i(""),c(""),h(null),f(!1))},[e]);const y=o.trim(),g=a.trim(),k=s.trim(),x=g.length>0&&!u,v=async M=>{if(M.preventDefault(),!!x){f(!0),h(null);try{const w=await ice({name:g,...y.length>0?{path:y}:{},...k.length>0?{description:k}:{}});n(w),t(!1)}catch(w){h(w instanceof Error?w.message:String(w)),f(!1)}}};return p.jsx(Ca,{open:e,onOpenChange:t,children:p.jsxs(Ri,{className:"sm:max-w-md","data-testid":"create-project-dialog",onOpenAutoFocus:M=>{M.preventDefault();const w=document.querySelector('[data-testid="create-project-name-input"]');w==null||w.focus()},children:[p.jsxs(Ti,{children:[p.jsx(Di,{children:"Create new project"}),p.jsx(Hi,{children:"Scaffold a new SeeFlow project. It's created in ~/.seeflow/projects/ unless you give a path."})]}),p.jsxs("form",{onSubmit:v,className:"flex flex-col gap-4",children:[p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Project name"}),p.jsx("input",{type:"text",required:!0,autoComplete:"off",spellCheck:!1,value:a,onChange:M=>i(M.target.value),"data-testid":"create-project-name-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"})]}),p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsxs("span",{className:"font-medium",children:["Project path ",p.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),p.jsx("input",{type:"text",autoComplete:"off",spellCheck:!1,placeholder:"/absolute/path/to/my-project",value:o,onChange:M=>r(M.target.value),"data-testid":"create-project-path-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"}),p.jsx("span",{className:"text-xs text-muted-foreground",children:"Leave blank to create it in ~/.seeflow/projects/"})]}),p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsxs("span",{className:"font-medium",children:["Description ",p.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),p.jsx("textarea",{rows:3,autoComplete:"off",spellCheck:!1,value:s,onChange:M=>c(M.target.value),"data-testid":"create-project-description-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"})]}),l?p.jsx("div",{role:"alert","data-testid":"create-project-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:l}):null,p.jsxs(Sa,{children:[p.jsx(ut,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:u,children:"Cancel"}),p.jsx(ut,{type:"submit",disabled:!x,"data-testid":"create-project-submit",children:u?"Creating…":"Create project"})]})]})]})})}const wnt="seeflow:last-flow:",xre=e=>`${wnt}${e}`,wre=e=>{if(typeof window>"u")return null;try{return window.localStorage.getItem(xre(e))}catch{return null}},Mnt=(e,t)=>{if(!(typeof window>"u"))try{window.localStorage.setItem(xre(e),t)}catch{}},bnt=(e,t)=>{var o;if(e.length===0)return null;if(t){const r=e.find(a=>a.flowSlug===t);if(r)return r.flowSlug}const n=e.find(r=>r.isDefault);return n?n.flowSlug:((o=e[0])==null?void 0:o.flowSlug)??null},hO="seeflow:navigate",_nt=e=>(window.addEventListener("popstate",e),window.addEventListener(hO,e),()=>{window.removeEventListener("popstate",e),window.removeEventListener(hO,e)}),hZ=()=>window.location.pathname,Cnt=()=>m.useSyncExternalStore(_nt,hZ,hZ),Nr=e=>{e!==window.location.pathname&&(window.history.pushState({},"",e),window.dispatchEvent(new Event(hO)))},di=(e,t)=>`/projects/${encodeURIComponent(e)}/flows/${encodeURIComponent(t)}`,Snt=e=>{const t=e.split("/").filter(Boolean);if(t.length!==4||t[0]!=="projects"||t[2]!=="flows")return null;const n=decodeURIComponent(t[1]??""),o=decodeURIComponent(t[3]??"");return!n||!o?null:{project:n,flow:o}},Mre=e=>{const t=e.indexOf("/");return t<0?di(e,""):di(e.slice(0,t),e.slice(t+1))},Lnt=e=>{const t=e.split("/").filter(Boolean);if(t.length!==2||t[0]!=="projects")return null;const n=decodeURIComponent(t[1]??"");return n?{project:n}:null};/**
|
|
8544
|
+
`)}async function Ttt(e,t){const n=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await Rtt(e,t);if(n){const o=document.createElement("style"),r=document.createTextNode(n);o.appendChild(r),e.firstChild?e.insertBefore(o,e.firstChild):e.appendChild(o)}}async function Dtt(e,t={}){const{width:n,height:o}=ure(e,t),r=await SR(e,t,!0);return await Ttt(r,t),await gre(r,t),Ett(r,t),await ttt(r,n,o)}async function Htt(e,t={}){const{width:n,height:o}=ure(e,t),r=await Dtt(e,t),a=await fz(r),i=document.createElement("canvas"),s=i.getContext("2d"),c=t.pixelRatio||Qet(),l=t.canvasWidth||n,h=t.canvasHeight||o;return i.width=l*c,i.height=h*c,t.skipAutoScale||Jet(i),i.style.width=`${l}`,i.style.height=`${h}`,t.backgroundColor&&(s.fillStyle=t.backgroundColor,s.fillRect(0,0,i.width,i.height)),s.drawImage(a,0,0,i.width,i.height),i}async function Ott(e,t={}){return(await Htt(e,t)).toDataURL()}const qtt=e=>e instanceof Element?!(e.classList.contains("react-flow__minimap")||e.classList.contains("react-flow__controls")||e.classList.contains("react-flow__panel")):!0,Ftt=e=>{var o;let t=e;for(;t&&!t.classList.contains("seeflow-canvas-root");)t=t.parentElement;if(t){const r=getComputedStyle(t).getPropertyValue("--bg-canvas").trim();if(r.length>0)return r}const n=(o=e.ownerDocument)==null?void 0:o.documentElement;return n!=null&&n.classList.contains("dark")?"#0a0a0c":"#fafafa"},Vtt=async e=>{const t=await Ott(e,{cacheBust:!0,filter:qtt,backgroundColor:Ftt(e)}),n=await new Promise((o,r)=>{const a=new Image;a.onload=()=>o({width:a.naturalWidth,height:a.naturalHeight}),a.onerror=()=>r(new Error("Failed to decode captured image")),a.src=t});return{dataUrl:t,...n}},Btt=(e,t)=>{const n=document.createElement("a");n.href=e,n.download=t,n.rel="noopener",document.body.appendChild(n),n.click(),n.remove()},Utt=e=>{const t=e.replace(/[^A-Za-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"");return t.length>0?t.slice(0,80):"canvas"},aZ=(e,t)=>`${Utt(e??"canvas")}.${t}`,Wtt=({projectId:e,getReactFlow:t})=>{const[n,o]=m.useState(null),r=m.useCallback(()=>o(null),[]),a=m.useCallback(async()=>{const l=t();if(!l)return null;const h=document.querySelector(".react-flow__viewport");if(!h)return null;const u=l.getViewport();try{return await l.fitView({duration:0,padding:.1}),await new Promise(f=>requestAnimationFrame(()=>f())),await Vtt(h)}finally{l.setViewport(u,{duration:0})}},[t]),i=m.useCallback(async()=>{o(null);try{const l=await a();if(!l)return;Btt(l.dataUrl,aZ(e,"png"))}catch(l){o(l instanceof Error?l.message:String(l))}},[a,e]),s=m.useCallback(async()=>{o(null);try{const l=await a();if(!l)return;const{jsPDF:h}=await hf(async()=>{const{jsPDF:y}=await import("./jspdf.es.min-DZwedYLb.js").then(g=>g.j);return{jsPDF:y}},[]),u=l.width>l.height?"landscape":"portrait",f=new h({orientation:u,unit:"px",format:[l.width,l.height],hotfixes:["px_scaling"]});f.addImage(l.dataUrl,"PNG",0,0,l.width,l.height),f.save(aZ(e,"pdf"))}catch(l){o(l instanceof Error?l.message:String(l))}},[a,e]),c=m.useCallback(async()=>{const l=await a();return l==null?void 0:l.dataUrl},[a]);return{exportPdf:s,exportPng:i,capturePreview:c,lastError:n,clearError:r}},Gtt=12,Ztt=1200;function Xtt(e,t={}){const n=t.idleMs??Ztt;let o,r=null,a=null;const i=typeof requestAnimationFrame<"u",s=()=>{o!==void 0&&(clearTimeout(o),o=void 0)},c=()=>{a!==null&&typeof cancelAnimationFrame<"u"&&cancelAnimationFrame(a),a=null},l=()=>{if(a=null,!r)return;const{clientX:y,clientY:g}=r;r=null;const k=e.getBoundingClientRect();e.style.setProperty("--mx",`${y-k.left}px`),e.style.setProperty("--my",`${g-k.top}px`),e.dataset.active="true",s(),o=setTimeout(()=>{e.dataset.active="false",o=void 0},n)};return{onMove:y=>{if(r={clientX:y.clientX,clientY:y.clientY},!i){l();return}a===null&&(a=requestAnimationFrame(l))},onLeave:()=>{c(),r=null,s(),e.dataset.active="false"},dispose:()=>{c(),r=null,s()}}}function Ktt(){const e=m.useRef(null),t=De(i=>i.transform,(i,s)=>i[0]===s[0]&&i[1]===s[1]&&i[2]===s[2]),[n,o,r]=t,a=Gtt*r;return m.useEffect(()=>{var u;const i=e.current;if(!i)return;const s=(u=i.parentElement)==null?void 0:u.querySelector(".react-flow__pane");if(!s)return;const{onMove:c,onLeave:l,dispose:h}=Xtt(i);return s.addEventListener("mousemove",c,{passive:!0}),s.addEventListener("mouseleave",l,{passive:!0}),()=>{s.removeEventListener("mousemove",c),s.removeEventListener("mouseleave",l),h()}},[]),p.jsx("div",{ref:e,className:"glow-overlay","data-active":"false","data-testid":"canvas-glow-overlay",style:{backgroundPosition:`${n}px ${o}px`,backgroundSize:`${a}px ${a}px`}})}const Ytt={showToolbar:!0,showStyleStrip:!0,showDetailPanel:!0,showStatusBadges:!0,showResizeHandles:!0,showControls:!0,showShareMenu:!0,showMiniMap:!0,enableKeyboard:!0,enableContextMenu:!0,enableDragDrop:!0,enableImageDrop:!0,enableZoom:!0,enablePan:!0,enableSelection:!0,enableNodeMove:!0,enableEmbed:!1},Qtt={showToolbar:!0,showStyleStrip:!1,showDetailPanel:!1,showStatusBadges:!0,showResizeHandles:!1,showControls:!0,showShareMenu:!0,showMiniMap:!0,enableKeyboard:!1,enableContextMenu:!1,enableDragDrop:!1,enableImageDrop:!1,enableZoom:!0,enablePan:!0,enableSelection:!0,enableNodeMove:!0,enableEmbed:!1},Jtt={showToolbar:!1,showStyleStrip:!1,showDetailPanel:!1,showStatusBadges:!1,showResizeHandles:!1,showControls:!1,showShareMenu:!1,showMiniMap:!1,enableKeyboard:!1,enableContextMenu:!1,enableDragDrop:!1,enableImageDrop:!1,enableZoom:!1,enablePan:!1,enableSelection:!1,enableNodeMove:!1,enableEmbed:!1};function ent(e){const t=e.mode==="edit"?Ytt:e.mode==="mini"?Jtt:Qtt;return{showToolbar:e.showToolbar??t.showToolbar,showStyleStrip:e.showStyleStrip??t.showStyleStrip,showDetailPanel:e.showDetailPanel??t.showDetailPanel,showStatusBadges:e.showStatusBadges??t.showStatusBadges,showResizeHandles:e.showResizeHandles??t.showResizeHandles,showControls:e.showControls??t.showControls,showShareMenu:e.showShareMenu??t.showShareMenu,showMiniMap:e.showMiniMap??t.showMiniMap,enableKeyboard:e.enableKeyboard??t.enableKeyboard,enableContextMenu:e.enableContextMenu??t.enableContextMenu,enableDragDrop:e.enableDragDrop??t.enableDragDrop,enableImageDrop:e.enableImageDrop??t.enableImageDrop,enableZoom:e.enableZoom??t.enableZoom,enablePan:e.enablePan??t.enablePan,enableSelection:e.enableSelection??t.enableSelection,enableNodeMove:e.enableNodeMove??t.enableNodeMove,enableEmbed:e.enableEmbed??t.enableEmbed}}const iZ=40,y2={padding:.15,duration:300,includeHiddenNodes:!1};function tnt(e){return e===void 0||e===!1?{onMount:!1,onExternalNodeChange:!1}:e===!0?{onMount:!0,onExternalNodeChange:!0}:{onMount:e.onMount??!0,onExternalNodeChange:e.onExternalNodeChange??!0}}const sZ=e=>{if("clientX"in e)return{clientX:e.clientX,clientY:e.clientY};const t=e.changedTouches[0]??e.touches[0];return t?{clientX:t.clientX,clientY:t.clientY}:null},nnt=(e,t)=>{var o;const n=document.elementsFromPoint(e,t);for(const r of n){const a=(o=r.closest)==null?void 0:o.call(r,".react-flow__node");if(a)return a}return null},vre=15,aD=(e,t,n)=>{const o=nnt(t,n);if(o)return o;if(!e)return null;let r=null,a=vre;const i=e.querySelectorAll(".react-flow__node");for(const s of i){const c=s.getBoundingClientRect();if(c.width===0||c.height===0)continue;const l=Math.max(c.left-t,0,t-c.right),h=Math.max(c.top-n,0,n-c.bottom),u=Math.hypot(l,h);u<=a&&(r=s,a=u)}return r};function cZ(e,t,n,o,r){if(e==="source"?(o==null?void 0:o.targetPin)!==void 0||(o==null?void 0:o.targetHandleAutoPicked)===!1:(o==null?void 0:o.sourcePin)!==void 0||(o==null?void 0:o.sourceHandleAutoPicked)===!1)return;const i=e==="source"?n:t,s=e==="source"?t:n,c=r(i),l=r(s);if(!c||!l)return;const h=c.measured.width??c.width??0,u=c.measured.height??c.height??0,f=l.measured.width??l.width??0,y=l.measured.height??l.height??0;if(h===0||u===0||f===0||y===0)return;const g={x:c.internals.positionAbsolute.x,y:c.internals.positionAbsolute.y,w:h,h:u},k={x:l.internals.positionAbsolute.x+f/2,y:l.internals.positionAbsolute.y+y/2};return UTe(g,FP(g,k))}function ont(e,t,n,o){if(o===null)return"no-op";const r=e==="source"?t:n;return o===(e==="source"?n:t)?"self-loop":o===r?"pin-own":"reconnect-and-pin"}const rnt=(e,t)=>{if(!t)return e;const n=t.data?{...e.data,...t.data}:e.data;return{...e,...t,data:n}},ant=(e,t)=>t?{...e,...t}:e,int={rectangle:lBe,ellipse:ur,sticky:ur,text:ur,database:ur,server:ur,user:ur,queue:ur,cloud:ur,diamond:ur,hexagon:ur,image:oBe,icon:nDe,html:QVe,component:xVe},snt={editableEdge:hBe},cnt={zIndex:0},lnt={hideAttribution:!0},dnt=8,lZ=(e,t)=>e?typeof e=="string"?`url('#${e}')`:`url('#${`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`}')`:void 0,unt=e=>function({fromX:n,fromY:o,toX:r,toY:a,fromPosition:i,toPosition:s,connectionLineStyle:c}){const l=De(F=>e.current?F.edges.find(D=>D.reconnectable===!0)??null:null),h=l==null?void 0:l.data,u=De(F=>{var E;const D=F.connection;return((E=D==null?void 0:D.fromHandle)==null?void 0:E.nodeId)??null}),f=De(F=>l!=null&&l.source?F.nodeLookup.get(l.source)??null:null),y=De(F=>l!=null&&l.target?F.nodeLookup.get(l.target)??null:null),g=De(F=>u?F.nodeLookup.get(u)??null:null),k=(l==null?void 0:l.source)===u,x=l?k?f:y:g,v=k?y:f,M=k?h==null?void 0:h.sourcePin:h==null?void 0:h.targetPin,w=k?h==null?void 0:h.sourceHandleAutoPicked:h==null?void 0:h.targetHandleAutoPicked;let b=n,C=o,_=i;if(x){const F=x.measured.width??x.width??0,D=x.measured.height??x.height??0;if(F>0&&D>0){const E={x:x.internals.positionAbsolute.x,y:x.internals.positionAbsolute.y,w:F,h:D};let K=null;if(M)K=VP(E,M);else if(w!==!1&&v){const X=v.measured.width??v.width??0,Y=v.measured.height??v.height??0;if(X>0&&Y>0){const Q={x:v.internals.positionAbsolute.x+X/2,y:v.internals.positionAbsolute.y+Y/2};K=FP(E,Q)}}K&&(b=K.x,C=K.y,_=dZ[K.side])}}const S=De(F=>F.transform[2]),j=De(F=>F.nodeLookup),P=De(F=>{var D;return((D=F.connection.toHandle)==null?void 0:D.nodeId)??null});let A=r,N=a,R=s;if(S>0){const F=vre/S,D=l?k?l.target:l.source:null;let E=null;if(P&&P!==D){const K=j.get(P)??null;K&&(E=K)}if(!E){let K=F;for(const X of j.values()){if(D&&X.id===D||x&&X.id===x.id)continue;const Y=X.measured.width??X.width??0,Q=X.measured.height??X.height??0;if(Y===0||Q===0)continue;const te=X.internals.positionAbsolute.x,ne=X.internals.positionAbsolute.y,ie=Math.max(te-r,0,r-(te+Y)),ke=Math.max(ne-a,0,a-(ne+Q)),ge=Math.hypot(ie,ke);ge<=K&&(K=ge,E=X)}}if(!E&&l&&x){const K=x.measured.width??x.width??0,X=x.measured.height??x.height??0;if(K>0&&X>0){const Y=x.internals.positionAbsolute.x,Q=x.internals.positionAbsolute.y,te=Math.max(Y-r,0,r-(Y+K)),ne=Math.max(Q-a,0,a-(Q+X));Math.hypot(te,ne)<=F&&(E=x)}}if(E){const K=E.measured.width??E.width??0,X=E.measured.height??E.height??0;if(K>0&&X>0){const Y=bH({x:E.internals.positionAbsolute.x,y:E.internals.positionAbsolute.y,w:K,h:X},{x:r,y:a}),Q=VP({x:E.internals.positionAbsolute.x,y:E.internals.positionAbsolute.y,w:K,h:X},Y);A=Q.x,N=Q.y,R=dZ[Q.side]}}}const W=(h==null?void 0:h.path)==="step",[$]=W?Hh({sourceX:b,sourceY:C,sourcePosition:_,targetX:A,targetY:N,targetPosition:R,borderRadius:dnt}):qz({sourceX:b,sourceY:C,sourcePosition:_,targetX:A,targetY:N,targetPosition:R}),H=(l==null?void 0:l.style)??c??void 0,T=De(F=>F.rfId),O=k?l==null?void 0:l.markerStart:l==null?void 0:l.markerEnd,I=k?l==null?void 0:l.markerEnd:l==null?void 0:l.markerStart,z=lZ(O,T),L=lZ(I,T);return p.jsx("path",{d:$,fill:"none",className:"react-flow__connection-path",style:H,markerStart:z,markerEnd:L})},dZ={top:ye.Top,right:ye.Right,bottom:ye.Bottom,left:ye.Left};function hnt({storeApiRef:e}){const t=wt();return m.useEffect(()=>(e.current=t,()=>{e.current===t&&(e.current=null)}),[t,e]),null}function fnt({wrapperRef:e}){const t=De(o=>o.transform[2]),n=e.current;return n&&n.style.setProperty("--rf-zoom",String(t)),null}const pnt=new Set(["INPUT","TEXTAREA","SELECT"]),uO=e=>e?pnt.has(e.tagName)?!0:e instanceof HTMLElement&&e.isContentEditable:!1;function ynt(e){const{event:t,selectedNodeIds:n,hasClipboard:o,activeElement:r,onCopySelection:a,onPasteSelection:i}=e;if(!(t.metaKey||t.ctrlKey)||t.shiftKey||t.altKey)return!1;const s=t.key.toLowerCase();return s!=="c"&&s!=="v"||uO(r)?!1:s==="c"?n.length===0||!a?!1:(t.preventDefault(),a([...n]),!0):!o||!i?!1:(t.preventDefault(),i(),!0)}const uZ=(e,t)=>{var n;return((n=e==null?void 0:e[t])==null?void 0:n.status)??"idle"},mnt=(e,t)=>{var n;return(n=e==null?void 0:e[t])==null?void 0:n.status},gnt=(e,t)=>{var n,o;return((n=e==null?void 0:e[t])==null?void 0:n.status)==="error"?(o=e[t])==null?void 0:o.error:void 0};function knt(e,t){var sV,cV;const{mode:n,adapter:o,topLeftSlot:r,topRightSlot:a,projectId:i,flowSlug:s,fileBaseUrl:c,apiBaseUrl:l="/api",nodes:h,connectors:u,selectedNodeIds:f,selectedConnectorIds:y,onSelectionChange:g,runtime:k,onPlayNode:x,onNodePositionChange:v,onNodePositionsChange:M,onNodeResize:w,onNodeResizeEnd:b,onHtmlNodeFitToContent:C,onComponentNodeFitToContent:_,onMultiResize:S,onNodeNameChange:j,onNodeDescriptionChange:P,onConnectorLabelChange:A,onCreateShapeNode:N,onCreateImageFromFile:R,onRetryImageUpload:W,onCreateHtmlNode:$,onCreateConnector:H,onReconnectConnector:T,onReorderNode:O,onDeleteNode:I,onCopyNode:z,onPasteAt:L,hasClipboard:F,onCopySelection:D,onPasteSelection:E,selectedNodes:K,selectedConnectors:X,onStyleNode:Y,onStyleNodePreview:Q,onStyleNodes:te,onStyleNodesPreview:ne,onStyleConnector:ie,onStyleConnectorPreview:ke,onRfInit:ge,onTidy:ve,onNodeClick:ce,onConnectorClick:Ce,onPaneClick:Re,onCreateAndConnectFromPane:st,pendingEditNodeId:Vt,iconPickerOpen:It,onOpenIconPicker:pe,onCloseIconPicker:se,onPickIcon:we,onRequestIconReplace:re,onPinEndpoint:Be,onUnpinEndpoint:an,canvasMode:J,onCanvasModeChange:ue,disableSidebar:je,statusReport:Ue,onNameChange:Ke,onDescriptionChange:Bt,onDetailChange:un,onIconChange:Ut,autoFitView:xe,autoFitViewSignal:Ae,customIcons:Tt,onExportToCloud:jn,onNodeDragStart:Nt,onNodeDragStop:ho,onViewportChange:Ea,history:Wt,showToolbar:Wd,showStyleStrip:Et,showDetailPanel:Yt,showStatusBadges:Gd,showResizeHandles:Zd,showControls:Xd,showShareMenu:Kd,showMiniMap:Yd,enableKeyboard:Qd,enableContextMenu:qi,enableDragDrop:Fi,enableImageDrop:Vi,enableZoom:Bi,enablePan:Vr,enableSelection:Br,enableNodeMove:Jd,enableEmbed:eu}=e,Te=m.useMemo(()=>ent({mode:n,showToolbar:Wd,showStyleStrip:Et,showDetailPanel:Yt,showStatusBadges:Gd,showResizeHandles:Zd,showControls:Xd,showShareMenu:Kd,showMiniMap:Yd,enableKeyboard:Qd,enableContextMenu:qi,enableDragDrop:Fi,enableImageDrop:Vi,enableZoom:Bi,enablePan:Vr,enableSelection:Br,enableNodeMove:Jd,enableEmbed:eu}),[n,Wd,Et,Yt,Gd,Zd,Xd,Kd,Yd,Qd,qi,Fi,Vi,Bi,Vr,Br,Jd,eu]),$t=n==="edit",Ur=m.useRef(Te);m.useEffect(()=>{Ur.current=Te},[Te]);const Ui=xe??(n==="mini"?!0:void 0),er=m.useMemo(()=>tnt(Ui),[Ui]),tr=k==null?void 0:k.runs,Wr=k==null?void 0:k.statuses,fo=(sV=k==null?void 0:k.pendingOverrides)==null?void 0:sV.nodes,Gn=(cV=k==null?void 0:k.pendingOverrides)==null?void 0:cV.connectors,hn=m.useRef(null),Qt=m.useRef(null),po=m.useRef(!1),Wi=m.useRef(!1),tu=m.useRef(!1),Ao=m.useRef(er);Ao.current=er,m.useEffect(()=>{if(po.current||!er.onMount||h.length===0)return;const B=Qt.current;B&&(B.fitView(y2),po.current=!0)},[h,er.onMount]);const Gi=m.useRef(null),kt=J.kind==="draw"?J.shape:null,yo=J.kind==="hand",$a=m.useRef(new Map),Zi=m.useCallback((B,Z)=>($a.current.set(B,Z),()=>{$a.current.get(B)===Z&&$a.current.delete(B)}),[]),[Gr,Zr]=m.useState(!1),nu=m.useRef(!1);m.useEffect(()=>{nu.current=Gr},[Gr]);const Xi=m.useRef(!1),nr=m.useRef(!1),Xr=m.useRef(!1),[vn,or]=m.useState(null),rr=m.useRef(null);m.useEffect(()=>{rr.current=vn},[vn]),m.useCallback(()=>{or(null)},[]);const Eo=m.useMemo(()=>unt(Xr),[]),xn=m.useRef(null),$o=m.useRef(null),ja=m.useCallback(B=>{const Z=hn.current;if(!Z){xn.current=B;return}const ae=xn.current;if(ae&&ae!==B){const le=Z.querySelector(`.react-flow__node[data-id="${CSS.escape(ae)}"]`);le==null||le.removeAttribute("data-connect-source")}if(B){const le=Z.querySelector(`.react-flow__node[data-id="${CSS.escape(B)}"]`);le==null||le.setAttribute("data-connect-source","true")}xn.current=B},[]),Pn=m.useCallback(B=>{const Z=hn.current,ae=$o.current;if(ae!==B){if(Z&&ae){const le=Z.querySelector(`.react-flow__node[data-id="${CSS.escape(ae)}"]`);le==null||le.removeAttribute("data-connect-target")}if(Z&&B){const le=Z.querySelector(`.react-flow__node[data-id="${CSS.escape(B)}"]`);le==null||le.setAttribute("data-connect-target","true")}$o.current=B}},[]),Pa=m.useCallback(()=>{ja(null),Pn(null)},[ja,Pn]);m.useEffect(()=>{if(!Gr){Pn(null);return}let B=null,Z=null;const ae=()=>{B=null;const de=Z;if(Z=null,!de)return;const $e=aD(hn.current,de.clientX,de.clientY),Me=($e==null?void 0:$e.getAttribute("data-id"))??null;if(Me&&Me===xn.current){Pn(null);return}Pn(Me)},le=de=>{Z={clientX:de.clientX,clientY:de.clientY},B===null&&(B=requestAnimationFrame(ae))};return document.addEventListener("pointermove",le,{passive:!0}),()=>{document.removeEventListener("pointermove",le),B!==null&&cancelAnimationFrame(B)}},[Gr,Pn]);const[ar,za]=m.useState(null),[ct,Ra]=m.useState(null),ir=m.useRef(null),mo=m.useRef(null),Kr=m.useRef(null),Ta=m.useRef(!1);m.useEffect(()=>{ir.current=kt},[kt]);const ou=m.useCallback(()=>{ue({kind:"select"}),za(null),Ra(null),ir.current=null,mo.current=null,Kr.current=null,Ta.current=!1},[ue]);m.useEffect(()=>{if(!Te.enableKeyboard)return;const B=Z=>{var de,$e;if(Z.key!=="Escape"||uO(document.activeElement))return;if(ir.current){Z.preventDefault(),ou();return}if(nu.current){Z.preventDefault(),Xi.current=!0,nr.current=!0;try{(de=Gi.current)==null||de.getState().cancelConnection()}catch{}document.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!0,button:0})),Zr(!1);return}if(rr.current){Z.preventDefault(),or(null);return}const ae=zn.current.size>0,le=ea.current.size>0;(ae||le)&&(Z.preventDefault(),($e=sr.current)==null||$e.call(sr,[],[]))};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[ou,Te.enableKeyboard]),m.useEffect(()=>{if(!Te.enableKeyboard)return;const B=Z=>{const ae=pDe(Z,{isEditableActive:uO(document.activeElement)});ae&&Wt&&(Z.preventDefault(),Z.stopPropagation(),ae==="undo"?Wt.undo():Wt.redo())};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[Wt,Te.enableKeyboard]),m.useEffect(()=>{if(!Te.enableKeyboard)return;const B=Z=>{ynt({event:Z,selectedNodeIds:f,hasClipboard:!!F,activeElement:document.activeElement,onCopySelection:D,onPasteSelection:E})};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[f,F,D,E,Te.enableKeyboard]);const Nf=m.useCallback(B=>{var le,de;if(!ir.current)return;const Z=B.target;if(!(Z!=null&&Z.classList.contains("react-flow__pane")))return;const ae={x:B.clientX,y:B.clientY};Ta.current=!0,mo.current=ae,Kr.current=ae,za(ae),Ra(ae);try{(de=(le=B.currentTarget).setPointerCapture)==null||de.call(le,B.pointerId)}catch{}B.preventDefault(),B.stopPropagation()},[]),NR=m.useCallback(B=>{if(!Ta.current)return;const Z={x:B.clientX,y:B.clientY};Kr.current=Z,Ra(Z)},[]),AR=m.useCallback(B=>{var lr,J0;if(!Ta.current)return;Ta.current=!1;try{(J0=(lr=B.currentTarget).releasePointerCapture)==null||J0.call(lr,B.pointerId)}catch{}const Z=mo.current,ae=Kr.current,le=ir.current,de=Qt.current;if(ou(),!Z||!ae||!le||!de)return;const $e=Math.min(Z.x,ae.x),Me=Math.min(Z.y,ae.y),Ee=Math.max(Z.x,ae.x),et=Math.max(Z.y,ae.y),lt=Ee-$e,pt=et-Me,ze=de.screenToFlowPosition({x:$e,y:Me}),Rn=de.screenToFlowPosition({x:Ee,y:et}),cr=Rn.x-ze.x,yt=Rn.y-ze.y,Se=lt<iZ||pt<iZ,Jt=Se?tz[le].width:cr,su=Se?tz[le].height:yt;N==null||N(le,ze,{width:Jt,height:su})},[ou,N]),Yr=m.useRef(!1),Ki=m.useRef(!1),G0=m.useRef(new Map),Da=m.useCallback(()=>{var B;Wi.current&&(Ki.current||Yr.current||(Wi.current=!1,(B=Qt.current)==null||B.fitView(y2)))},[]),Z0=m.useCallback(B=>{Ki.current=B,B||Da()},[Da]);m.useEffect(()=>{var B;if(!tu.current){tu.current=!0;return}if(Ao.current.onExternalNodeChange){if(Ki.current||Yr.current){Wi.current=!0;return}(B=Qt.current)==null||B.fitView(y2)}},[Ae]);const X0=!!O||!!I||!!z||!!L||!!an,[V,q]=m.useState(null),[U,G]=m.useState(!1),[ee,He]=m.useState(null),[it,ot]=m.useState(null),ft=m.useRef(null),Zn=m.useRef(null);m.useEffect(()=>{if(!V)return;const B=Zn.current;if(!B)return;const Z=new MouseEvent("contextmenu",{clientX:V.x,clientY:V.y,bubbles:!0,cancelable:!0,button:2,buttons:2});B.dispatchEvent(Z)},[V]);const Qr=m.useCallback(B=>{const Z=ft.current;!Z||!O||O(Z,B)},[O]),Oe=m.useCallback(()=>{const B=ft.current;!B||!I||I(B)},[I]),wn=m.useCallback(()=>{const B=ft.current;!B||!z||z(B)},[z]),ru=m.useCallback(()=>{const B=ft.current;!B||!re||re(B)},[re]);m.useCallback((B,Z,ae,le,de)=>{Ur.current.enableContextMenu&&(ft.current=null,G(!1),He(null),ot({connectorId:B,kind:Z,pinned:ae}),q({x:le,y:de}))},[]);const au=m.useCallback(()=>{const B=it;!B||!an||an(B.connectorId,B.kind)},[it,an]),iu=m.useCallback(()=>{if(!L)return;const B=V,Z=Qt.current;if(!B||!Z)return;const ae=Z.screenToFlowPosition({x:B.x,y:B.y});L(ae)},[V,L]),Af=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent||""),ER=Af?"⌘C":"Ctrl+C",Yi=Af?"⌘V":"Ctrl+V",Fe=m.useMemo(()=>new Set(f),[f]),Mt=m.useMemo(()=>new Set(y),[y]),Mn=m.useMemo(()=>{if(f.length<2)return[];const B=fo,Z=[];for(const ae of f){const le=h.find(Ee=>Ee.id===ae);if(!le)continue;const de=B==null?void 0:B[ae],$e=(de==null?void 0:de.data)??{},Me=le.data;Z.push({id:ae,position:(de==null?void 0:de.position)??le.position,data:{width:$e.width??Me.width,height:$e.height??Me.height}})}return Z},[h,fo,f]),go=K??[],Jr=m.useMemo(()=>{const B=de=>{const $e=$t?void 0:G0.current.get(de.id),Me={id:de.id,type:de.type,position:$e??de.position,data:{...de.data,projectId:i,fileBaseUrl:c,projectSlug:de.type==="component"?i:void 0,flowSlug:de.type==="component"?s:void 0,apiBaseUrl:de.type==="component"?l:void 0,onRetryUpload:W,status:mnt(tr,de.id),errorMessage:gnt(tr,de.id),statusReport:Wr==null?void 0:Wr[de.id],onPlay:x,onResize:w,onResizeEnd:b,setResizing:Z0,onFitToContent:de.type==="html"?C:de.type==="component"?_:void 0,onNameChange:(()=>{if($t&&de.type!=="ellipse")return j})(),onDescriptionChange:(()=>{if($t&&(de.type==="rectangle"||de.type==="ellipse"||de.type==="sticky"))return P})(),onIconChange:(()=>{if($t&&!(de.type!=="rectangle"&&de.type!=="component"))return Ut})(),autoEditOnMount:Vt===de.id?!0:void 0},selected:Fe.has(de.id)};return(!(de.data.autoSize===!0)||Ki.current)&&(de.data.width!==void 0&&(Me.width=de.data.width),de.data.height!==void 0&&(Me.height=de.data.height)),Fe.has(de.id)||(Me.connectable=!1),Me},Z=h.map(de=>B(rnt(de,fo==null?void 0:fo[de.id]))),ae=new Set(h.map(de=>de.id)),le=[];if(fo)for(const[de,$e]of Object.entries(fo)){if(ae.has(de))continue;const Me=$e;typeof Me.type!="string"||!Me.position||!Me.data||le.push(B({...Me,id:de}))}return[...Z,...le]},[i,s,c,l,h,Fe,tr,Wr,x,w,b,C,_,Z0,fo,j,P,Ut,W,Vt,$t]),[Qi,K0]=m.useState(Jr);m.useEffect(()=>{Yr.current||Ki.current||K0(Jr)},[Jr]),m.useEffect(()=>{Y0.current=Qi},[Qi]);const zn=m.useRef(Fe);m.useEffect(()=>{zn.current=Fe},[Fe]);const sr=m.useRef(g);m.useEffect(()=>{sr.current=g},[g]);const ea=m.useRef(Mt);m.useEffect(()=>{ea.current=Mt},[Mt]);const Y0=m.useRef(Jr),Ji=m.useRef(!1),Ef=m.useRef(new Set),$f=m.useRef(new Set),$R=m.useRef(new Set),jR=m.useRef(new Set),Ha=m.useRef(null),Gre=m.useCallback(B=>{var yt;const Z=Ji.current?$R.current:(yt=Ha.current)!=null&&yt.shift?Ha.current.nodeIds:null,ae=Z&&Z.size>0?B.filter(Se=>Se.type!=="select"?!0:!(Se.selected===!1&&Z.has(Se.id))):B,le=new Set;for(const Se of ae)Se.type==="select"&&le.add(Se.id);const de=vQ(ae,Y0.current),$e=new Set;if(Ki.current)for(const Se of ae)Se.type==="dimensions"&&$e.add(Se.id);const Me=$e.size===0?de:de.map(Se=>!$e.has(Se.id)||Se.width===void 0&&Se.height===void 0?Se:{...Se,data:{...Se.data,...Se.width!==void 0?{width:Se.width}:{},...Se.height!==void 0?{height:Se.height}:{}}}),Ee=zn.current,et=Ji.current||Ee.size===0?Me:Me.map(Se=>Ee.has(Se.id)&&!le.has(Se.id)&&!Se.selected?{...Se,selected:!0}:Se);if(Y0.current=et,K0(et),le.size===0)return;if(Ji.current){for(const Se of ae)Se.type==="select"&&(Se.selected?Ef.current.add(Se.id):Ef.current.delete(Se.id));return}const lt=sr.current;if(!lt)return;const pt=et.filter(Se=>Se.selected).map(Se=>Se.id),ze=zn.current;ze.size===pt.length&&pt.every(Se=>ze.has(Se))||(zn.current=new Set(pt),lt(pt,[...ea.current]))},[]),jf=m.useRef([]),Zre=m.useCallback(B=>{var pt;const Z=Ji.current?jR.current:(pt=Ha.current)!=null&&pt.shift?Ha.current.edgeIds:null,ae=Z&&Z.size>0?B.filter(ze=>ze.type!=="select"?!0:!(ze.selected===!1&&Z.has(ze.id))):B,le=new Set;for(const ze of ae)ze.type==="select"&&le.add(ze.id);if(le.size===0)return;if(Ji.current){for(const ze of ae)ze.type==="select"&&(ze.selected?$f.current.add(ze.id):$f.current.delete(ze.id));return}const de=sr.current;if(!de)return;const Me=xQ(ae,jf.current).filter(ze=>ze.selected).map(ze=>ze.id),Ee=ea.current;Ee.size===Me.length&&Me.every(ze=>Ee.has(ze))||(ea.current=new Set(Me),de([...zn.current],Me))},[]),Xre=m.useCallback(B=>{Ji.current=!0;const Z=Ha.current,ae=(Z==null?void 0:Z.shift)??(B.shiftKey||B.metaKey||B.ctrlKey);$R.current=ae?new Set((Z==null?void 0:Z.nodeIds)??zn.current):new Set,jR.current=ae?new Set((Z==null?void 0:Z.edgeIds)??ea.current):new Set,Ef.current=new Set($R.current),$f.current=new Set(jR.current)},[]),Kre=m.useCallback(()=>{Ji.current=!1,Ha.current=null;const B=sr.current;if(!B)return;const Z=[...Ef.current],ae=new Set(Z),le=new Set($f.current);for(const et of jf.current)ae.has(et.source)&&ae.has(et.target)&&le.add(et.id);const de=zn.current,$e=ea.current,Me=de.size===ae.size&&Z.every(et=>de.has(et)),Ee=$e.size===le.size&&[...le].every(et=>$e.has(et));Me&&Ee||(zn.current=new Set(Z),ea.current=new Set(le),B(Z,[...le]))},[]),Yre=m.useCallback(B=>{if(Ha.current=null,ir.current||B.button!==0)return;const Z=B.target;Z!=null&&Z.classList.contains("react-flow__pane")&&(Ha.current={shift:B.shiftKey||B.metaKey||B.ctrlKey,nodeIds:new Set(zn.current),edgeIds:new Set(ea.current)})},[]),Qre=m.useCallback(B=>{if(!Ur.current.enableContextMenu||zn.current.size<2)return;const ae=B.target;ae!==Zn.current&&(ae!=null&&ae.closest(".seeflow-connector-endpoint-dot")||(B.preventDefault(),B.stopPropagation(),ft.current=null,G(!0),He(null),ot(null),q({x:B.clientX,y:B.clientY})))},[]),Jre=m.useCallback(B=>{const Z=B.dataTransfer;if(!Z)return;const ae=Z.types?Array.from(Z.types):[],le=ae.includes("Files"),de=ae.includes(FW),$e=le&&!!R&&Te.enableImageDrop,Me=de&&!!$&&Te.enableDragDrop;if(!(!$e&&!Me)){B.preventDefault();try{Z.dropEffect="copy"}catch{}}},[R,$,Te.enableImageDrop,Te.enableDragDrop]),eae=m.useCallback(B=>{const Z=B.dataTransfer;if((Z!=null&&Z.types?Array.from(Z.types):[]).includes(FW)&&$&&Te.enableDragDrop){B.preventDefault();const $e=Qt.current;if(!$e)return;const Me=$e.screenToFlowPosition({x:B.clientX,y:B.clientY});$({position:Me});return}if(!R||!Te.enableImageDrop)return;const de={x:B.clientX,y:B.clientY};B.preventDefault(),ENe({dataTransfer:Z,clientPos:de,rfInstance:Qt.current,computeDims:$Ne,dispatch:R})},[R,$,Te.enableImageDrop,Te.enableDragDrop]),GF=!!T,ZF=Mt.size===1?[...Mt][0]:null,PR=m.useMemo(()=>{const B=Ee=>{const et=uZ(tr,Ee.source)==="running"||uZ(tr,Ee.target)==="running",lt=Mt.has(Ee.id),pt=HTe(Ee,et,lt);lt&&(pt.selected=!0);const ze=GF&&Ee.id===ZF,Rn=ze?{...pt,reconnectable:!0}:pt;return{...Rn,data:{...Rn.data,onLabelChange:$t?A:void 0,reconnectable:ze,registerEditHandle:Zi}}},Z=new Set(u.map(Ee=>Ee.id)),ae=u.map(Ee=>B(ant(Ee,Gn==null?void 0:Gn[Ee.id]))),le=[];if(Gn)for(const[Ee,et]of Object.entries(Gn)){if(Z.has(Ee))continue;const lt=et;typeof lt.source!="string"||typeof lt.target!="string"||le.push(B({...lt,id:Ee}))}const de=[...ae,...le],$e=[],Me=[];for(const Ee of de)Mt.has(Ee.id)?Me.push(Ee):$e.push(Ee);return[...$e,...Me]},[u,tr,Mt,ZF,Gn,A,GF,Zi,$t]);m.useEffect(()=>{jf.current=PR},[PR]);const Q0=e.adapter??null,tae=m.useMemo(()=>{if(Q0!=null&&Q0.computeLayout)return async()=>{const B=Qt.current,Z=Y0.current;if(Z.length<2)return;const ae=Z.map(yt=>{var J0;const Se=(J0=B==null?void 0:B.getInternalNode(yt.id))==null?void 0:J0.measured,Jt=yt.data,su=(Se==null?void 0:Se.width)??Jt.width??200,lr=(Se==null?void 0:Se.height)??Jt.height??120;return{id:yt.id,type:yt.type,width:su,height:lr}}),le=new Map;for(const yt of Z)le.set(yt.id,yt.position);const de=jf.current.map(yt=>({id:yt.id,source:yt.source,target:yt.target})),$e=Q0.computeLayout;if(!$e)return;const Me=await $e(ae,de),Ee=new Map;for(const[yt,Se]of Object.entries(Me.nodes))Ee.set(yt,Se.position);let et=Number.POSITIVE_INFINITY,lt=Number.POSITIVE_INFINITY,pt=Number.POSITIVE_INFINITY,ze=Number.POSITIVE_INFINITY;for(const yt of ae){const Se=le.get(yt.id);if(!Se)continue;Se.x<et&&(et=Se.x),Se.y<lt&&(lt=Se.y);const Jt=Ee.get(yt.id);Jt&&(Jt.x<pt&&(pt=Jt.x),Jt.y<ze&&(ze=Jt.y))}const Rn=Number.isFinite(et)&&Number.isFinite(pt)?et-pt:0,cr=Number.isFinite(lt)&&Number.isFinite(ze)?lt-ze:0;K0(yt=>yt.map(Se=>{const Jt=Ee.get(Se.id);return Jt?{...Se,position:{x:Jt.x+Rn,y:Jt.y+cr}}:Se}))}},[Q0]),Pf=ve??($t?void 0:tae),zf=m.useRef(!1),XF=m.useRef(null),nae=m.useCallback(B=>{var Ee;if(!$t||!H)return;const{source:Z,target:ae}=B;if(!Z||!ae||Z===ae)return;zf.current=!0;const le=((Ee=XF.current)==null?void 0:Ee.nodeId)??null,de=le!==null&&le===ae&&le!==Z;H(de?ae:Z,de?Z:ae)},[H,$t]),zR=m.useCallback(B=>{const Z=ae=>{if(!ae)return!1;const le=Y0.current.find(de=>de.id===ae);return le?le.type==="text":!1};return!Z(B.source)&&!Z(B.target)},[]),oae=m.useCallback((B,Z)=>{var pt;Zr(!1),Pa();const ae=zf.current;if(zf.current=!1,ae||Xr.current)return;if(Xi.current){Xi.current=!1;return}if(!H)return;const le=(pt=Z.fromNode)==null?void 0:pt.id,de=Z.fromHandle;if(!le||!de)return;const $e=sZ(B);if(!$e)return;const Me=aD(hn.current,$e.clientX,$e.clientY);if(!Me)return;const Ee=Me.getAttribute("data-id");if(!Ee||Ee===le||!zR({source:le,target:Ee,sourceHandle:null,targetHandle:null}))return;let et;const lt=Qt.current;if(lt){const ze=lt.getInternalNode(Ee);if(ze){const Rn=ze.measured.width??ze.width??0,cr=ze.measured.height??ze.height??0;if(Rn>0&&cr>0){const yt=lt.screenToFlowPosition({x:$e.clientX,y:$e.clientY});et=bH({x:ze.internals.positionAbsolute.x,y:ze.internals.positionAbsolute.y,w:Rn,h:cr},yt)}}}H(le,Ee,et?{targetPin:et}:void 0)},[H,Pa,zR]),Rf=m.useRef(!1),rae=m.useCallback((B,Z)=>{if(!T)return;const{source:ae,target:le,sourceHandle:de,targetHandle:$e}=Z;if(!ae||!le||ae===le)return;const Me={};if(ae!==B.source&&(Me.source=ae),le!==B.target&&(Me.target=le),typeof de=="string"&&de!==B.sourceHandle&&(Me.sourceHandle=de),typeof $e=="string"&&$e!==B.targetHandle&&(Me.targetHandle=$e),Me.source===void 0&&Me.target===void 0&&Me.sourceHandle===void 0&&Me.targetHandle===void 0)return;(Me.source!==void 0||Me.sourceHandle!==void 0)&&(Me.sourceHandleAutoPicked=!1),(Me.target!==void 0||Me.targetHandle!==void 0)&&(Me.targetHandleAutoPicked=!1);const Ee=Qt.current;if(!(Me.source===void 0&&Me.target===void 0)&&Ee){const lt=Me.source!==void 0?"source":"target",pt=cZ(lt,B.source,B.target,B.data,ze=>Ee.getInternalNode(ze)??null);pt&&(lt==="source"?Me.targetPin=pt:Me.sourcePin=pt)}Rf.current=!0,T(B.id,Me)},[T]),aae=m.useCallback((B,Z,ae,le)=>{var su;Zr(!1),Pa(),Xr.current=!1;const de=Rf.current;if(Rf.current=!1,de)return;if(nr.current){nr.current=!1;return}if(!T)return;const $e=sZ(B);let Me=((su=le.toNode)==null?void 0:su.id)??null;if(!Me&&$e){const lr=aD(hn.current,$e.clientX,$e.clientY);Me=(lr==null?void 0:lr.getAttribute("data-id"))??null}const Ee=ae==="source"?"target":"source",et=ont(Ee,Z.source,Z.target,Me);if(et==="no-op"||et==="self-loop"||!$e)return;const lt=Qt.current;if(!lt)return;const pt=et==="pin-own"?Ee==="source"?Z.source:Z.target:Me,ze=lt.getInternalNode(pt);if(!ze)return;const Rn=ze.measured.width??ze.width??0,cr=ze.measured.height??ze.height??0;if(Rn===0||cr===0)return;const yt=lt.screenToFlowPosition({x:$e.clientX,y:$e.clientY}),Se=bH({x:ze.internals.positionAbsolute.x,y:ze.internals.positionAbsolute.y,w:Rn,h:cr},yt);if(et==="pin-own"){if(!Be)return;Be(Z.id,Ee,Se);return}const Jt=cZ(Ee,Z.source,Z.target,Z.data,lr=>lt.getInternalNode(lr)??null);Ee==="source"?T(Z.id,{source:Me,sourceHandle:null,sourceHandleAutoPicked:!1,sourcePin:Se,...Jt?{targetPin:Jt}:{}}):T(Z.id,{target:Me,targetHandle:null,targetHandleAutoPicked:!1,targetPin:Se,...Jt?{sourcePin:Jt}:{}})},[T,Pa,Be]),es=m.useMemo(()=>{var Ee;if(!ar||!ct)return null;const B=(Ee=hn.current)==null?void 0:Ee.getBoundingClientRect(),Z=(B==null?void 0:B.left)??0,ae=(B==null?void 0:B.top)??0,le=Math.min(ar.x,ct.x),de=Math.min(ar.y,ct.y),$e=Math.abs(ct.x-ar.x),Me=Math.abs(ct.y-ar.y);return{left:le-Z,top:de-ae,width:$e,height:Me}},[ar,ct]),Oa=kt?_2(Xa).node:void 0,iae=kt?Iee(kt):"",sae=kt?Nee(kt,Oa):void 0,cae=kt==="text",[KF,YF]=m.useState(!1),[lae,Tf]=m.useState(!1),[dae,QF]=m.useState(!1),[JF,uae]=m.useState(()=>({canUndo:(Wt==null?void 0:Wt.canUndo)??!1,canRedo:(Wt==null?void 0:Wt.canRedo)??!1}));m.useEffect(()=>Wt?Wt.subscribe(uae):void 0,[Wt]);const hae=Wt?JF.canUndo:!1,fae=Wt?JF.canRedo:!1,qa=Wtt({projectId:i,getReactFlow:()=>Qt.current});m.useImperativeHandle(t,()=>({exportPdf:qa.exportPdf,exportPng:qa.exportPng,openEmbedDialog:()=>QF(!0),capturePreview:qa.capturePreview}),[qa.exportPdf,qa.exportPng,qa.capturePreview]),m.useEffect(()=>{if(!Te.enableKeyboard)return;const B=le=>{if(!le)return!1;const de=le.tagName;return de==="INPUT"||de==="TEXTAREA"||de==="SELECT"?!0:le instanceof HTMLElement&&le.isContentEditable},Z=le=>{le.code==="Space"&&(B(document.activeElement)||(le.preventDefault(),YF(!0)))},ae=le=>{le.code==="Space"&&(YF(!1),Tf(!1))};return window.addEventListener("keydown",Z),window.addEventListener("keyup",ae),()=>{window.removeEventListener("keydown",Z),window.removeEventListener("keyup",ae)}},[Te.enableKeyboard]);const Df=m.useCallback(B=>{if(B.length!==0){if(!$t){const Z=G0.current;for(const ae of B)Z.set(ae.id,{x:ae.position.x,y:ae.position.y});return}if(B.length===1){const Z=B[0];Z&&v&&v(Z.id,{x:Z.position.x,y:Z.position.y});return}if(M){M(B.map(Z=>({id:Z.id,position:{x:Z.position.x,y:Z.position.y}})));return}if(v)for(const Z of B)v(Z.id,{x:Z.position.x,y:Z.position.y})}},[v,M,$t]),eV=m.useCallback((B,Z,ae)=>{Yr.current=!1,Df(ae),Da()},[Df,Da]),tV=m.useCallback(()=>{Yr.current=!0},[]),nV=m.useCallback((B,Z)=>{Yr.current=!1,Df(Z),Da()},[Df,Da]),pae=m.useCallback((B,Z)=>{rr.current&&or(null);const ae=hn.current;ae&&ae.style.setProperty("--rf-zoom",String(Z.zoom)),Ea==null||Ea(Z)},[Ea]),yae=m.useCallback(()=>{Yr.current=!0,Nt==null||Nt()},[Nt]),mae=m.useCallback((B,Z,ae)=>{eV(B,Z,ae),ho==null||ho()},[eV,ho]),gae=m.useCallback(()=>{tV(),Nt==null||Nt()},[tV,Nt]),kae=m.useCallback((B,Z)=>{nV(B,Z),ho==null||ho()},[nV,ho]),vae=m.useCallback((B,Z)=>{var ae;(ae=$a.current.get(Z.id))==null||ae()},[]),xae=m.useCallback((B,Z)=>{ce==null||ce(Z.id)},[ce]),wae=m.useCallback(B=>{Re==null||Re()},[Re]),Mae=m.useCallback((B,Z)=>{Ce==null||Ce(Z.id)},[Ce]),oV=kt?"crosshair":yo||KF?lae?"grabbing":"grab":void 0,rV=f.length+y.length===1,aV=rV?f[0]:void 0,iV=rV?y[0]:void 0,bae=aV?h.find(B=>B.id===aV)??null:null,_ae=iV?u.find(B=>B.id===iV)??null:null,Cae=i??null,Sae=Te.showDetailPanel&&!je,Lae=m.useMemo(()=>({custom:Tt??{}}),[Tt]);return p.jsx(QHe,{value:Lae,children:p.jsx("div",{"data-testid":"seeflow-canvas","data-mode":n,"data-canvas-mode":J.kind,"data-can-undo":hae?"true":"false","data-can-redo":fae?"true":"false",ref:hn,className:"seeflow-canvas-root sf:relative sf:h-full sf:w-full",style:oV?{cursor:oV}:void 0,onPointerDownCapture:Yre,onPointerDown:B=>{KF&&Tf(!0),Nf(B)},onPointerMove:NR,onPointerUp:B=>{Tf(!1),AR(B)},onPointerCancel:()=>{Ta.current=!1,mo.current=null,Kr.current=null,za(null),Ra(null),Tf(!1)},onContextMenuCapture:Qre,onDragOver:Jre,onDrop:eae,children:p.jsxs(dVe,{containerRef:hn,children:[p.jsxs(nTe,{nodes:Qi,edges:PR,onNodesChange:Gre,nodeTypes:int,edgeTypes:snt,proOptions:lnt,fitView:!0,minZoom:n==="mini"?.05:.5,nodesDraggable:($t?!!v:!0)&&!kt&&!yo&&Te.enableNodeMove,nodesConnectable:$t&&!!H&&!kt&&!yo,deleteKeyCode:$t?["Backspace","Delete"]:null,zoomOnScroll:Te.enableZoom,zoomOnPinch:Te.enableZoom,className:Gr?"seeflow-connecting":void 0,onConnect:$t?nae:void 0,isValidConnection:zR,onConnectStart:(B,Z)=>{Zr(!0),zf.current=!1,XF.current={nodeId:Z.nodeId??null,handleType:Z.handleType??null},ja(Z.nodeId??null)},onConnectEnd:oae,onReconnect:$t&&T?rae:void 0,onReconnectStart:(B,Z,ae)=>{Zr(!0),Rf.current=!1,Xr.current=!0;const le=ae==="source"?Z.source:Z.target;ja(le)},onReconnectEnd:aae,connectionLineComponent:Eo,connectionLineStyle:{strokeWidth:2},connectionRadius:32,reconnectRadius:10,edgesReconnectable:!1,elevateNodesOnSelect:!1,elementsSelectable:!kt&&!yo&&Te.enableSelection,selectNodesOnDrag:!1,nodeClickDistance:5,selectionOnDrag:!kt&&!yo&&Te.enableSelection,panOnDrag:kt?!1:yo?[0,1,2]:Te.enablePan?[1,2]:!1,selectionMode:f0.Partial,selectionKeyCode:null,multiSelectionKeyCode:kt?null:["Meta","Shift"],panActivationKeyCode:kt?null:"Space",onSelectionStart:Xre,onSelectionEnd:Kre,defaultEdgeOptions:cnt,zoomOnDoubleClick:!1,onInit:B=>{Qt.current=B;const Z=hn.current;Z&&Z.style.setProperty("--rf-zoom",String(B.getZoom())),Z&&Z.setAttribute("data-canvas-ready","true"),!po.current&&er.onMount&&h.length>0&&(B.fitView(y2),po.current=!0),ge==null||ge(B)},onMove:pae,onEdgesChange:Zre,onNodeDragStart:yae,onNodeDragStop:mae,onSelectionDragStart:gae,onSelectionDragStop:kae,onNodeClick:xae,onEdgeClick:Mae,onEdgeDoubleClick:vae,onPaneClick:wae,onNodeContextMenu:Te.enableContextMenu&&X0?(B,Z)=>{B.preventDefault(),ft.current=Z.id,G(!0),He(Z.type??null),ot(null),q({x:B.clientX,y:B.clientY})}:void 0,onPaneContextMenu:Te.enableContextMenu&&L?B=>{B.preventDefault(),ft.current=null,G(!1),He(null),ot(null),q({x:B.clientX,y:B.clientY})}:void 0,children:[p.jsx(hnt,{storeApiRef:Gi}),p.jsx(fnt,{wrapperRef:hn}),p.jsx(uTe,{gap:12,size:.6}),n!=="mini"&&p.jsx(Ktt,{}),Te.showControls?p.jsxs(kTe,{showInteractive:!1,showFitView:!1,children:[p.jsx(Tu,{"data-testid":"controls-fit-view","aria-label":"Fit view",title:"Fit view",disabled:h.length===0,onClick:()=>{var B;(B=Qt.current)==null||B.fitView(y2)},children:p.jsx(gd,{className:"sf:h-3 sf:w-3","aria-hidden":"true"})}),p.jsx(Tu,{"data-testid":"controls-tidy","aria-label":"Tidy layout (⌘⇧L)",title:"Tidy layout (⌘⇧L)",disabled:!Pf,onClick:()=>Pf==null?void 0:Pf(),children:p.jsx(X2,{className:"sf:h-3 sf:w-3","aria-hidden":"true"})})]}):null,Te.showMiniMap?p.jsx(ETe,{className:"sf-canvas-minimap"}):null,Te.showResizeHandles?p.jsx(Fet,{selectedNodes:Mn,onMultiResize:S}):null,r||Te.showToolbar||Te.showStyleStrip&&Y&&ie?p.jsx(k0,{position:"top-left",children:p.jsxs("div",{className:"sf:flex sf:flex-col sf:items-start sf:gap-2",children:[r,Te.showToolbar?p.jsx(fGe,{mode:J,onModeChange:ue,iconPickerOpen:It??!1,onOpenIconPicker:pe,onCloseIconPicker:se,onPickIcon:we,showShapeTools:$t&&!!N}):null,Te.showStyleStrip&&Y&&ie?p.jsx(Uet,{nodes:go,connectors:X??[],onStyleNode:Y,onStyleNodePreview:Q,onStyleNodes:te,onStyleNodesPreview:ne,onStyleConnector:ie,onStyleConnectorPreview:ke,onRequestIconReplace:re}):null]})}):null,Te.showShareMenu||a?p.jsx(k0,{position:"top-right",children:p.jsxs("div",{className:"sf:flex sf:items-center sf:gap-1",children:[a,Te.showShareMenu?p.jsx(Det,{mode:n==="mini"?"view":n,projectId:i,enableEmbed:Te.enableEmbed,onDownloadPdf:qa.exportPdf,onDownloadPng:qa.exportPng,onExportToCloud:jn,embedOpen:dae,onEmbedOpenChange:QF}):null]})}):null]}),es?p.jsx("div",{"data-testid":"canvas-draw-ghost","data-ghost-shape":kt??void 0,"aria-hidden":!0,className:oe("sf:pointer-events-none sf:absolute sf:z-10",iae,cae?"sf:rounded-sm sf:border sf:border-dashed sf:border-muted-foreground/40":""),style:{...sae,left:es.left,top:es.top,width:es.width,height:es.height},children:(()=>{const B=kt?tF[kt]:void 0;if(!B)return null;const Z=Aee(Oa);return p.jsx(B,{width:es.width,height:es.height,borderColor:Z.borderColor,backgroundColor:Z.backgroundColor,borderSize:(Oa==null?void 0:Oa.borderSize)??jq,borderStyle:Oa==null?void 0:Oa.borderStyle})})()}):null,Te.enableContextMenu&&X0?p.jsxs(rWe,{onOpenChange:B=>{B||(q(null),ft.current=null,He(null),ot(null))},children:[p.jsx(aWe,{asChild:!0,children:p.jsx("div",{ref:Zn,"data-testid":"node-context-menu-trigger","aria-hidden":!0,className:"sf:pointer-events-none sf:fixed",style:{left:(V==null?void 0:V.x)??0,top:(V==null?void 0:V.y)??0,width:0,height:0}})}),p.jsxs(ine,{"data-testid":"node-context-menu",children:[it!=null&&it.pinned&&an?p.jsx(xr,{"data-testid":"connector-endpoint-context-menu-unpin",onSelect:au,children:"Unpin"}):null,U&&z?p.jsxs(xr,{"data-testid":"node-context-menu-copy",onSelect:wn,children:["Copy",p.jsx(WH,{children:ER})]}):null,L?p.jsxs(xr,{"data-testid":"node-context-menu-paste",disabled:!F,onSelect:iu,children:["Paste",p.jsx(WH,{children:Yi})]}):null,U&&(z||L)&&(ee==="icon"&&re||O||I)?p.jsx(oP,{}):null,U&&ee==="icon"&&re?p.jsx(xr,{"data-testid":"node-context-menu-change-icon",onSelect:ru,children:"Change icon"}):null,U&&ee==="icon"&&re&&(O||I)?p.jsx(oP,{}):null,U&&O?p.jsxs(p.Fragment,{children:[p.jsx(xr,{"data-testid":"node-context-menu-to-front",onSelect:()=>Qr({op:"toFront"}),children:"Bring to front"}),p.jsx(xr,{"data-testid":"node-context-menu-forward",onSelect:()=>Qr({op:"forward"}),children:"Bring forward"}),p.jsx(xr,{"data-testid":"node-context-menu-backward",onSelect:()=>Qr({op:"backward"}),children:"Send backward"}),p.jsx(xr,{"data-testid":"node-context-menu-to-back",onSelect:()=>Qr({op:"toBack"}),children:"Send to back"})]}):null,U&&O&&I?p.jsx(oP,{}):null,U&&I?p.jsx(xr,{"data-testid":"node-context-menu-delete",onSelect:Oe,children:"Delete"}):null]})]}):null,st?p.jsxs(Dd,{open:!!vn,onOpenChange:B=>{B||or(null)},children:[p.jsx(uVe,{asChild:!0,children:p.jsx("div",{"data-testid":"drop-popover-anchor","aria-hidden":!0,className:"sf:pointer-events-none sf:fixed",style:{left:(vn==null?void 0:vn.clientX)??0,top:(vn==null?void 0:vn.clientY)??0,width:0,height:0}})}),p.jsx(zi,{"data-testid":"drop-popover",align:"start",side:"bottom",sideOffset:4,className:"sf:w-auto sf:p-1",onOpenAutoFocus:B=>{B.preventDefault()},children:p.jsx("div",{role:"menu","aria-label":"Create connected node",className:"sf:flex sf:flex-col sf:gap-0.5",children:hGe.map(({shape:B,label:Z,Icon:ae})=>p.jsxs("button",{type:"button",role:"menuitem","data-testid":`drop-popover-shape-${B}`,onClick:()=>{const le=vn;le&&(st({sourceNodeId:le.sourceNodeId,position:{x:le.flowX,y:le.flowY},shape:B}),or(null))},className:oe("sf:flex sf:items-center sf:gap-2 sf:rounded-sm sf:px-2 sf:py-1.5 sf:text-left sf:text-sm","sf:hover:bg-accent sf:hover:text-accent-foreground","sf:focus:bg-accent sf:focus:text-accent-foreground sf:focus:outline-hidden"),children:[p.jsx(ae,{className:"sf:h-4 sf:w-4 sf:text-muted-foreground","aria-hidden":"true"}),p.jsx("span",{children:Z})]},B))})})]}):null,Sae?p.jsx(cet,{flowId:Cae,node:bae,connector:_ae,adapter:o??null,statusReport:Ue,onNameChange:Ke,onDescriptionChange:Bt,onDetailChange:un,onIconChange:Ut,onClose:()=>{var B;(B=sr.current)==null||B.call(sr,[],[])}}):null]})})})}const vnt=m.forwardRef(knt);function xnt({open:e,onOpenChange:t,onCreated:n}){const[o,r]=m.useState(""),[a,i]=m.useState(""),[s,c]=m.useState(""),[l,h]=m.useState(null),[u,f]=m.useState(!1);m.useEffect(()=>{e&&(r(""),i(""),c(""),h(null),f(!1))},[e]);const y=o.trim(),g=a.trim(),k=s.trim(),x=g.length>0&&!u,v=async M=>{if(M.preventDefault(),!!x){f(!0),h(null);try{const w=await ice({name:g,...y.length>0?{path:y}:{},...k.length>0?{description:k}:{}});n(w),t(!1)}catch(w){h(w instanceof Error?w.message:String(w)),f(!1)}}};return p.jsx(Ca,{open:e,onOpenChange:t,children:p.jsxs(Ri,{className:"sm:max-w-md","data-testid":"create-project-dialog",onOpenAutoFocus:M=>{M.preventDefault();const w=document.querySelector('[data-testid="create-project-name-input"]');w==null||w.focus()},children:[p.jsxs(Ti,{children:[p.jsx(Di,{children:"Create new project"}),p.jsx(Hi,{children:"Scaffold a new SeeFlow project. It's created in ~/.seeflow/projects/ unless you give a path."})]}),p.jsxs("form",{onSubmit:v,className:"flex flex-col gap-4",children:[p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Project name"}),p.jsx("input",{type:"text",required:!0,autoComplete:"off",spellCheck:!1,value:a,onChange:M=>i(M.target.value),"data-testid":"create-project-name-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"})]}),p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsxs("span",{className:"font-medium",children:["Project path ",p.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),p.jsx("input",{type:"text",autoComplete:"off",spellCheck:!1,placeholder:"/absolute/path/to/my-project",value:o,onChange:M=>r(M.target.value),"data-testid":"create-project-path-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"}),p.jsx("span",{className:"text-xs text-muted-foreground",children:"Leave blank to create it in ~/.seeflow/projects/"})]}),p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsxs("span",{className:"font-medium",children:["Description ",p.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),p.jsx("textarea",{rows:3,autoComplete:"off",spellCheck:!1,value:s,onChange:M=>c(M.target.value),"data-testid":"create-project-description-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"})]}),l?p.jsx("div",{role:"alert","data-testid":"create-project-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:l}):null,p.jsxs(Sa,{children:[p.jsx(ut,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:u,children:"Cancel"}),p.jsx(ut,{type:"submit",disabled:!x,"data-testid":"create-project-submit",children:u?"Creating…":"Create project"})]})]})]})})}const wnt="seeflow:last-flow:",xre=e=>`${wnt}${e}`,wre=e=>{if(typeof window>"u")return null;try{return window.localStorage.getItem(xre(e))}catch{return null}},Mnt=(e,t)=>{if(!(typeof window>"u"))try{window.localStorage.setItem(xre(e),t)}catch{}},bnt=(e,t)=>{var o;if(e.length===0)return null;if(t){const r=e.find(a=>a.flowSlug===t);if(r)return r.flowSlug}const n=e.find(r=>r.isDefault);return n?n.flowSlug:((o=e[0])==null?void 0:o.flowSlug)??null},hO="seeflow:navigate",_nt=e=>(window.addEventListener("popstate",e),window.addEventListener(hO,e),()=>{window.removeEventListener("popstate",e),window.removeEventListener(hO,e)}),hZ=()=>window.location.pathname,Cnt=()=>m.useSyncExternalStore(_nt,hZ,hZ),Nr=e=>{e!==window.location.pathname&&(window.history.pushState({},"",e),window.dispatchEvent(new Event(hO)))},di=(e,t)=>`/projects/${encodeURIComponent(e)}/flows/${encodeURIComponent(t)}`,Snt=e=>{const t=e.split("/").filter(Boolean);if(t.length!==4||t[0]!=="projects"||t[2]!=="flows")return null;const n=decodeURIComponent(t[1]??""),o=decodeURIComponent(t[3]??"");return!n||!o?null:{project:n,flow:o}},Mre=e=>{const t=e.indexOf("/");return t<0?di(e,""):di(e.slice(0,t),e.slice(t+1))},Lnt=e=>{const t=e.split("/").filter(Boolean);if(t.length!==2||t[0]!=="projects")return null;const n=decodeURIComponent(t[1]??"");return n?{project:n}:null};/**
|
|
8545
8545
|
* @license lucide-react v0.453.0 - ISC
|
|
8546
8546
|
*
|
|
8547
8547
|
* This source code is licensed under the ISC license.
|
|
@@ -8621,4 +8621,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
8621
8621
|
*
|
|
8622
8622
|
* This source code is licensed under the ISC license.
|
|
8623
8623
|
* See the LICENSE file in the root directory of this source tree.
|
|
8624
|
-
*/const Rnt=No("Workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]);function Tnt({projects:e,currentProjectSlug:t,onProjectCreated:n,onUnregisterProject:o}){const[r,a]=m.useState(!1),[i,s]=m.useState(!1),[c,l]=m.useState(null),[h,u]=m.useState(!1),[f,y]=m.useState(null);m.useEffect(()=>{const C=_=>{_.key==="k"&&(_.metaKey||_.ctrlKey)&&(_.preventDefault(),a(S=>!S))};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[]);const g=e.find(C=>C.projectSlug===t),k=C=>{const S=wre(C.projectSlug)??C.defaultFlow;Nr(di(C.projectSlug,S))},x=C=>{n==null||n(C)},v=C=>{l(C),y(null)},M=()=>{h||(l(null),y(null))},w=async()=>{if(c){u(!0),y(null);try{await(o==null?void 0:o(c.projectSlug)),l(null)}catch(C){y(C instanceof Error?C.message:String(C))}finally{u(!1)}}},b=(c==null?void 0:c.flowCount)??0;return p.jsxs(p.Fragment,{children:[p.jsxs(Dd,{open:r,onOpenChange:a,children:[p.jsx(V0,{asChild:!0,children:p.jsxs(ut,{type:"button",variant:"outline",size:"sm","aria-label":"Switch project","aria-expanded":r,className:"gap-2","data-testid":"project-switcher-trigger",children:[p.jsx("span",{className:"max-w-[180px] truncate text-sm",children:(g==null?void 0:g.name)??"Select project"}),p.jsx(ote,{children:"⌘K"}),p.jsx(Cre,{className:"h-3.5 w-3.5 opacity-60"})]})}),p.jsx(zi,{align:"end",sideOffset:6,className:"w-[320px] p-0","data-testid":"project-switcher-popover",children:p.jsxs(sF,{children:[p.jsx(nte,{placeholder:"Search projects..."}),p.jsxs(cF,{children:[p.jsx(lF,{children:"No projects."}),e.length>0?p.jsx(Bh,{heading:"Projects",children:e.map(C=>p.jsxs(Uh,{value:`${C.name} ${C.projectSlug}`,onSelect:()=>{a(!1),k(C)},"data-testid":`project-switcher-row-${C.projectSlug}`,className:"group flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-0.5",children:[p.jsx("span",{className:"font-medium",children:C.name}),C.repoPath?p.jsx("span",{className:"w-full truncate text-xs text-muted-foreground",children:C.repoPath}):null]}),p.jsx("button",{type:"button","aria-label":`Unregister ${C.name}`,"data-testid":`project-switcher-unregister-${C.projectSlug}`,className:"shrink-0 rounded p-0.5 opacity-0 transition-opacity hover:text-destructive group-hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring",onClick:_=>{_.stopPropagation(),a(!1),v(C)},children:p.jsx(Ire,{className:"h-3.5 w-3.5"})})]},C.projectSlug))}):null,e.length>0?p.jsx(dF,{}):null,p.jsx(Bh,{children:p.jsxs(Uh,{value:"+ create new project",onSelect:()=>{a(!1),s(!0)},"data-testid":"project-switcher-create",className:"flex items-center gap-2 text-sm",children:[p.jsx(Lre,{className:"h-4 w-4 opacity-70"}),p.jsx("span",{className:"font-medium",children:"Create new project"})]})})]})]})})]}),p.jsx(xnt,{open:i,onOpenChange:s,onCreated:x}),p.jsx(Ca,{open:c!==null,onOpenChange:C=>{C||M()},children:p.jsxs(Ri,{className:"sm:max-w-md","data-testid":"unregister-project-dialog",children:[p.jsxs(Ti,{children:[p.jsx(Di,{children:"Unregister project?"}),p.jsxs(Hi,{children:["This removes ",p.jsx("strong",{children:c==null?void 0:c.name})," from SeeFlow."," ",p.jsxs("strong",{children:["All ",b," ",b===1?"flow":"flows"]})," ","under this project will be unregistered.",c!=null&&c.repoPath?p.jsxs(p.Fragment,{children:[" ","Your files at ",p.jsx("code",{className:"text-xs",children:c.repoPath})," will not be deleted."]}):null]})]}),f?p.jsx("div",{role:"alert","data-testid":"unregister-project-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:f}):null,p.jsxs(Sa,{children:[p.jsx(ut,{type:"button",variant:"ghost",onClick:M,disabled:h,children:"Cancel"}),p.jsx(ut,{type:"button",variant:"destructive",onClick:w,disabled:h,"data-testid":"unregister-project-confirm",children:h?"Unregistering…":"Unregister"})]})]})})]})}const Nre="seeflow:theme",pZ="(prefers-color-scheme: dark)";function Dnt(e){return e==="light"||e==="dark"||e==="system"}function Hnt(e){try{const t=e.getItem(Nre);return Dnt(t)?t:"system"}catch{return"system"}}function Ont(e){try{const t=new URLSearchParams(e);if(!t.has("theme"))return null;const n=t.get("theme");return n==="light"||n==="dark"?n:"light"}catch{return null}}function qnt(e,t){try{e.setItem(Nre,t)}catch{}}function Fnt(e,t){return e==="system"?t?"dark":"light":e}function Vnt(e,t){t==="dark"?(e.classList.add("dark"),e.classList.remove("light")):(e.classList.add("light"),e.classList.remove("dark"))}function Bnt(e,t){var o;const n=r=>t(r.matches);return e.addEventListener?(e.addEventListener("change",n),()=>{var r;return(r=e.removeEventListener)==null?void 0:r.call(e,"change",n)}):((o=e.addListener)==null||o.call(e,n),()=>{var r;return(r=e.removeListener)==null?void 0:r.call(e,n)})}function Unt(){const[e,t]=m.useState(()=>{if(typeof window>"u")return"system";const i=Ont(window.location.search);return i||Hnt(window.localStorage)}),[n,o]=m.useState(()=>typeof window>"u"?!1:window.matchMedia(pZ).matches);m.useEffect(()=>{if(typeof window>"u")return;const i=window.matchMedia(pZ);return Bnt(i,o)},[]);const r=Fnt(e,n);m.useEffect(()=>{typeof document>"u"||Vnt(document.documentElement,r)},[r]);const a=m.useCallback(i=>{typeof window<"u"&&qnt(window.localStorage,i),t(i)},[]);return{theme:e,setTheme:a,resolvedTheme:r}}const Wnt=[{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"system",label:"System"}];function Gnt({projects:e,currentProjectSlug:t,onProjectCreated:n,onUnregisterProject:o}){const{theme:r,setTheme:a}=Unt();return p.jsxs("header",{className:"relative flex h-14 shrink-0 items-center justify-between bg-background/85 px-5 backdrop-blur-md shadow-[0_1px_3px_-1px_rgba(15,23,42,0.06),0_2px_8px_-4px_rgba(15,23,42,0.05)] dark:shadow-[0_4px_12px_-6px_rgba(0,0,0,0.6)]",children:[p.jsxs("button",{type:"button",onClick:()=>Nr("/"),className:"-ml-1.5 flex items-center gap-2 rounded-md px-1.5 py-1 text-base font-bold tracking-tight transition-colors hover:bg-muted/60",children:[p.jsx(Rnt,{size:18,strokeWidth:2.25,className:"text-emerald-400"}),"SeeFlow",p.jsxs("span",{className:"ml-1 text-[10px] font-normal tracking-normal text-muted-foreground/70",children:["v","0.1.97"]})]}),p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx(Tnt,{projects:e,currentProjectSlug:t,onProjectCreated:n,onUnregisterProject:o}),p.jsxs(Cne,{children:[p.jsx(Sne,{asChild:!0,children:p.jsx(ut,{type:"button",variant:"outline",size:"icon","aria-label":"Settings","data-testid":"settings-trigger",children:p.jsx(jnt,{className:"h-4 w-4"})})}),p.jsxs(vF,{align:"end",sideOffset:6,className:"w-44","data-testid":"settings-menu",children:[p.jsx(Lne,{children:"Theme"}),p.jsx(AWe,{value:r,onValueChange:i=>a(i),children:Wnt.map(i=>p.jsx(Ine,{value:i.value,"data-testid":`theme-${i.value}`,children:i.label},i.value))})]})]})]})]})}const Znt=(e,t)=>{const n=e!==null&&t!==null,[o,r]=m.useState(null),[a,i]=m.useState(n),[s,c]=m.useState(null),l=m.useCallback(()=>{!e||!t||(i(!0),oce(e,t).then(u=>{r(u),c(null)}).catch(u=>{console.error("[useDemoData] failed",u),c(String(u))}).finally(()=>i(!1)))},[e,t]),h=m.useCallback(u=>{r(u),c(null)},[]);return m.useEffect(()=>{if(!e||!t){r(null),i(!1);return}l()},[e,t,l]),{detail:o,loading:a,error:s,refresh:l,applyDetail:h}},Xnt=()=>{const[e,t]=m.useState(null),[n,o]=m.useState(null),r=m.useCallback(()=>tce().then(a=>{t(a),o(null)}).catch(a=>{console.error("[useDemos] failed",a),t([]),o(String(a))}),[]);return m.useEffect(()=>{r()},[r]),{demos:e,error:n,refresh:r}},Knt=5,Ynt={"node:running":"running","node:done":"done","node:error":"error"},Qnt=(e,t)=>{if(t.type==="reset")return{};const n=e[t.nodeId]??[],o=[t.entry,...n].slice(0,Knt);return{...e,[t.nodeId]:o}},Jnt=e=>{const[t,n]=m.useReducer(Qnt,{}),o=m.useRef(n);o.current=n,m.useEffect(()=>{o.current({type:"reset"})},[e]);const r=m.useCallback(i=>{const s=Ynt[i.type];if(!s)return;const c=typeof i.nodeId=="string"?i.nodeId:null;if(!c)return;const l=typeof i.runId=="string"?i.runId:void 0,h=typeof i.ts=="number"?i.ts:Date.now();o.current({type:"append",nodeId:c,entry:{status:s,ts:h,runId:l}})},[]),a=m.useCallback(()=>{o.current({type:"reset"})},[]);return{events:t,apply:r,reset:a}},eot=(e,t)=>{var n,o;switch(t.type){case"reset":return{};case"running":return{...e,[t.nodeId]:{status:"running",runId:t.runId,ts:t.ts??Date.now()}};case"done":return{...e,[t.nodeId]:{...e[t.nodeId],status:"done",runId:t.runId??((n=e[t.nodeId])==null?void 0:n.runId),responseStatus:t.responseStatus,body:t.body,ts:t.ts??Date.now()}};case"error":return{...e,[t.nodeId]:{...e[t.nodeId],status:"error",runId:t.runId??((o=e[t.nodeId])==null?void 0:o.runId),error:t.message,ts:t.ts??Date.now()}}}},tot=e=>{const[t,n]=m.useReducer(eot,{}),o=m.useRef(n);o.current=n,m.useEffect(()=>{o.current({type:"reset"})},[e]);const r=m.useCallback(i=>{const s=typeof i.nodeId=="string"?i.nodeId:null;if(!s)return;const c=typeof i.runId=="string"?i.runId:void 0;if(i.type==="node:running"){o.current({type:"running",nodeId:s,runId:c,ts:i.ts});return}if(i.type==="node:done"){const l=typeof i.status=="number"?i.status:void 0;o.current({type:"done",nodeId:s,runId:c,responseStatus:l,body:i.body,ts:i.ts});return}if(i.type==="node:error"){const l=typeof i.message=="string"?i.message:void 0;o.current({type:"error",nodeId:s,runId:c,message:l,ts:i.ts})}},[]),a=m.useCallback(()=>{o.current({type:"reset"})},[]);return{runs:t,apply:r,reset:a}},not=new Set(["ok","warn","error","pending"]),oot=(e,t)=>{if(t.type!=="node:status")return e;const n=typeof t.nodeId=="string"?t.nodeId:null;if(!n||typeof t.state!="string"||!not.has(t.state))return e;const o=typeof t.summary=="string"?t.summary:void 0,r=typeof t.detail=="string"?t.detail:void 0,a=t.data&&typeof t.data=="object"&&!Array.isArray(t.data)?t.data:void 0,i=typeof t.ts=="number"?t.ts:Date.now();return{...e,[n]:{state:t.state,summary:o,detail:r,data:a,ts:i}}},rot=(e,t)=>{switch(t.type){case"reset":return{};case"event":return oot(e,t.event)}},aot=e=>{const[t,n]=m.useReducer(rot,{}),o=m.useRef(n);o.current=n,m.useEffect(()=>{o.current({type:"reset"})},[e]);const r=m.useCallback(i=>{o.current({type:"event",event:i})},[]),a=m.useCallback(()=>{o.current({type:"reset"})},[]);return{statusByNode:t,apply:r,reset:a}},BF=e=>{const t=e!==null,[n,o]=m.useState(null),[r,a]=m.useState(t),[i,s]=m.useState(null),c=m.useCallback(()=>{e&&(a(!0),s(null),BK(e).then(f=>{o(f),s(null)}).catch(f=>{console.error("[useProjectFlows] failed",f),o([]),s(String(f))}).finally(()=>a(!1)))},[e]);m.useEffect(()=>{if(!e){o(null),a(!1),s(null);return}c()},[e,c]);const l=m.useCallback(async f=>{if(!e)throw new Error("no-project");const y=await rce(e,f);return c(),y},[e,c]),h=m.useCallback(async(f,y)=>{if(!e)throw new Error("no-project");const g=await ace(e,f,y);return c(),g},[e,c]),u=m.useCallback(async(f,y)=>{if(!e)throw new Error("no-project");const g=await UK(e,f,y);return c(),g},[e,c]);return{flows:n,loading:r,error:i,refresh:c,createFlow:l,renameFlow:h,deleteFlow:u}},iot=()=>{const[e,t]=m.useState(null),[n,o]=m.useState(!0),[r,a]=m.useState(null),i=m.useCallback(()=>(o(!0),nce().then(c=>{t(c),a(null)}).catch(c=>{console.error("[useProjects] failed",c),t([]),a(String(c))}).finally(()=>o(!1))),[]);m.useEffect(()=>{i()},[i]);const s=m.useCallback(async c=>{const h=[...await BK(c)].sort((u,f)=>u.isDefault===f.isDefault?0:u.isDefault?1:-1);for(const u of h)await UK(c,u.flowSlug);await i()},[i]);return{projects:e,loading:n,error:r,refresh:i,unregisterProject:s}},sot=(e={})=>{const[t,n]=m.useState(!1),{onRegistryReload:o,onHello:r}=e,a=m.useRef(o),i=m.useRef(r);return m.useEffect(()=>{a.current=o,i.current=r},[o,r]),m.useEffect(()=>{const s=new EventSource("/api/registry/events");return s.addEventListener("open",()=>n(!0)),s.addEventListener("error",()=>n(!1)),s.addEventListener("hello",()=>{var c;(c=i.current)==null||c.call(i)}),s.addEventListener("registry:reload",()=>{var c;(c=a.current)==null||c.call(a)}),()=>{s.close()}},[]),{connected:t}},cot=(e,t={})=>{const[n,o]=m.useState(!1),{onHello:r,onFlowReload:a,onEvent:i}=t,s=m.useRef(r),c=m.useRef(a),l=m.useRef(i);return m.useEffect(()=>{s.current=r,c.current=a,l.current=i},[r,a,i]),m.useEffect(()=>{if(!e){o(!1);return}const h=`/api/events?flowId=${encodeURIComponent(e)}`,u=new EventSource(h);u.addEventListener("open",()=>o(!0)),u.addEventListener("error",()=>o(!1)),u.addEventListener("hello",()=>{var f;(f=s.current)==null||f.call(s)}),u.addEventListener("flow:reload",f=>{var k,x;const y=yZ(f,"flow:reload");(k=l.current)==null||k.call(l,y);const g=lot(y);g&&((x=c.current)==null||x.call(c,g))});for(const f of["node:running","node:done","node:error","node:status"])u.addEventListener(f,y=>{var g;(g=l.current)==null||g.call(l,yZ(y,f))});return()=>{u.close()}},[e]),{connected:n}},yZ=(e,t)=>{try{const n=JSON.parse(e.data);return{type:t,ts:Date.now(),...n}}catch{return{type:t,ts:Date.now()}}},lot=e=>e.valid===!0&&e.flow&&typeof e.flow=="object"?{valid:!0,flow:e.flow}:e.valid===!1&&typeof e.error=="string"?{valid:!1,error:e.error}:null,Are="seeflow:last-project",dot=()=>{if(typeof window>"u")return null;try{return window.localStorage.getItem(Are)}catch{return null}},mZ=e=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Are,e)}catch{}},uot=(e,t)=>{if(e.length===0)return null;if(e.length===1)return e[0]??null;if(t){const n=e.find(o=>o.id===t);if(n)return n}return null},gZ=["File","Edit","View","Tools","Layout","Selection","Help"],Ere="seeflow:command-palette:recent",$re=5,jre=new Map(Eq.map(e=>[e.id,e])),hot=e=>typeof e=="string"&&jre.has(e),kZ=()=>{if(typeof window>"u")return[];try{const e=window.localStorage.getItem(Ere);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(hot).slice(0,$re):[]}catch{return[]}},fot=e=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Ere,JSON.stringify(e))}catch{}},vZ=(e,t)=>e.enabled?e.enabled(t):!0,pot=(e,t)=>t.length===0?!0:`${e.label} ${e.description??""}`.toLowerCase().includes(t);function yot({open:e,onOpenChange:t,runCommand:n,ctx:o}){const[r,a]=m.useState(""),[i,s]=m.useState(0),[c,l]=m.useState(()=>kZ()),h=m.useRef(null),u=m.useRef(null);m.useEffect(()=>{e&&(a(""),s(0),l(kZ()))},[e]);const{groups:f,flat:y}=m.useMemo(()=>{const b=r.trim().toLowerCase();if(b.length===0){if(c.length===0)return{groups:[],flat:[]};const P=[];for(const N of c){const R=jre.get(N);R&&P.push({cmd:R,enabled:vZ(R,o)})}return{groups:[{category:"Recent",rows:P}],flat:P}}const C=new Map;for(const P of Eq){if(!pot(P,b))continue;const A={cmd:P,enabled:vZ(P,o)},N=C.get(P.category);N?N.push(A):C.set(P.category,[A])}const S=[...gZ.filter(P=>C.has(P)),...Array.from(C.keys()).filter(P=>!gZ.includes(P))].map(P=>({category:P,rows:C.get(P)??[]})),j=S.flatMap(P=>P.rows);return{groups:S,flat:j}},[r,o,c]);m.useEffect(()=>{if(y.length===0){s(0);return}s(b=>{var _;let C=b;if(C>=y.length&&(C=0),!((_=y[C])!=null&&_.enabled)){const S=y.findIndex(j=>j.enabled);S!==-1&&(C=S)}return C})},[y]);const g=m.useCallback(b=>{y.length!==0&&s(C=>{var S;let _=C;for(let j=0;j<y.length;j++)if(_=(_+b+y.length)%y.length,(S=y[_])!=null&&S.enabled)return _;return C})},[y]),k=m.useCallback(b=>{l(C=>{const _=[b,...C.filter(S=>S!==b)].slice(0,$re);return fot(_),_})},[]),x=m.useCallback(b=>{const C=y[b];!C||!C.enabled||(k(C.cmd.id),n(C.cmd.id),t(!1))},[y,t,k,n]),v=m.useCallback(b=>{if(b.key==="ArrowDown"){b.preventDefault(),g(1);return}if(b.key==="ArrowUp"){b.preventDefault(),g(-1);return}b.key==="Enter"&&(b.preventDefault(),x(i))},[x,i,g]);m.useEffect(()=>{if(!e)return;const b=u.current;if(!b)return;const C=b.querySelector(`[data-command-row-index="${i}"]`);C&&typeof C.scrollIntoView=="function"&&C.scrollIntoView({block:"nearest"})},[i,e]);const w=r.trim().length>0;return p.jsx(aR,{open:e,onOpenChange:t,children:p.jsx(iR,{children:p.jsxs(B0,{className:oe("fixed left-0 right-0 top-[20%] z-50 mx-auto w-[480px] max-w-[90vw] border border-border bg-card shadow-lg duration-200","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","sm:rounded-lg"),"data-testid":"command-palette",onOpenAutoFocus:b=>{var C;b.preventDefault(),(C=h.current)==null||C.focus()},children:[p.jsx("div",{className:oe("border-b",y.length===0&&!w&&"border-b-0"),children:p.jsx("input",{ref:h,type:"text",value:r,onChange:b=>a(b.target.value),onKeyDown:v,placeholder:"Type a command…","data-testid":"command-palette-input","aria-label":"Search commands",autoComplete:"off",spellCheck:!1,className:"w-full bg-transparent px-4 py-3 text-sm outline-hidden placeholder:text-muted-foreground"})}),p.jsx("div",{ref:u,"data-testid":"command-palette-list","data-empty":y.length===0?"true":"false",className:oe("max-h-[50vh] overflow-y-auto",y.length>0?"py-1":"","seeflow-no-scrollbar"),children:y.length===0?w?p.jsxs("div",{"data-testid":"command-palette-empty",className:"px-4 py-6 text-center text-sm text-muted-foreground",children:['No commands match "',r,'"']}):null:(()=>{let b=-1;return f.map(C=>p.jsxs("div",{className:"py-1",children:[p.jsx("div",{className:"px-3 pb-1 pt-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:C.category}),C.rows.map(_=>{b+=1;const S=b,j=S===i;return p.jsxs("button",{type:"button","data-testid":`command-palette-row-${_.cmd.id}`,"data-command-row-index":S,"data-highlighted":j?"true":"false","aria-disabled":_.enabled?void 0:!0,disabled:!_.enabled,onMouseEnter:()=>{_.enabled&&s(S)},onClick:()=>x(S),className:oe("flex w-full items-center justify-between gap-3 px-3 py-2 text-left text-sm outline-hidden",_.enabled?"cursor-pointer text-foreground hover:bg-muted":"cursor-not-allowed text-muted-foreground/50",j&&_.enabled?"bg-muted":""),children:[p.jsxs("div",{className:"flex min-w-0 flex-col",children:[p.jsx("span",{className:"truncate font-medium",children:_.cmd.label}),_.cmd.description?p.jsx("span",{className:"truncate text-xs text-muted-foreground",children:_.cmd.description}):null]}),_.cmd.shortcut?p.jsx("kbd",{"data-testid":`command-palette-shortcut-${_.cmd.id}`,className:"shrink-0 rounded border bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:_.cmd.shortcut}):null]},_.cmd.id)})]},C.category))})()})]})})})}var qt=Uint8Array,no=Uint16Array,UF=Int32Array,LR=new qt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),IR=new qt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),fO=new qt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Pre=function(e,t){for(var n=new no(31),o=0;o<31;++o)n[o]=t+=1<<e[o-1];for(var r=new UF(n[30]),o=1;o<30;++o)for(var a=n[o];a<n[o+1];++a)r[a]=a-n[o]<<5|o;return{b:n,r}},zre=Pre(LR,2),Rre=zre.b,pO=zre.r;Rre[28]=258,pO[258]=28;var Tre=Pre(IR,0),mot=Tre.b,xZ=Tre.r,yO=new no(32768);for(var Ct=0;Ct<32768;++Ct){var Za=(Ct&43690)>>1|(Ct&21845)<<1;Za=(Za&52428)>>2|(Za&13107)<<2,Za=(Za&61680)>>4|(Za&3855)<<4,yO[Ct]=((Za&65280)>>8|(Za&255)<<8)>>1}var zr=function(e,t,n){for(var o=e.length,r=0,a=new no(t);r<o;++r)e[r]&&++a[e[r]-1];var i=new no(t);for(r=1;r<t;++r)i[r]=i[r-1]+a[r-1]<<1;var s;if(n){s=new no(1<<t);var c=15-t;for(r=0;r<o;++r)if(e[r])for(var l=r<<4|e[r],h=t-e[r],u=i[e[r]-1]++<<h,f=u|(1<<h)-1;u<=f;++u)s[yO[u]>>c]=l}else for(s=new no(o),r=0;r<o;++r)e[r]&&(s[r]=yO[i[e[r]-1]++]>>15-e[r]);return s},Ai=new qt(288);for(var Ct=0;Ct<144;++Ct)Ai[Ct]=8;for(var Ct=144;Ct<256;++Ct)Ai[Ct]=9;for(var Ct=256;Ct<280;++Ct)Ai[Ct]=7;for(var Ct=280;Ct<288;++Ct)Ai[Ct]=8;var Yh=new qt(32);for(var Ct=0;Ct<32;++Ct)Yh[Ct]=5;var got=zr(Ai,9,0),kot=zr(Ai,9,1),vot=zr(Yh,5,0),xot=zr(Yh,5,1),iD=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Po=function(e,t,n){var o=t/8|0;return(e[o]|e[o+1]<<8)>>(t&7)&n},sD=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},WF=function(e){return(e+7)/8|0},If=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new qt(e.subarray(t,n))},wot=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],_n=function(e,t,n){var o=new Error(t||wot[e]);if(o.code=e,Error.captureStackTrace&&Error.captureStackTrace(o,_n),!n)throw o;return o},Mot=function(e,t,n,o){var r=e.length,a=o?o.length:0;if(!r||t.f&&!t.l)return n||new qt(0);var i=!n,s=i||t.i!=2,c=t.i;i&&(n=new qt(r*3));var l=function(ke){var ge=n.length;if(ke>ge){var ve=new qt(Math.max(ge*2,ke));ve.set(n),n=ve}},h=t.f||0,u=t.p||0,f=t.b||0,y=t.l,g=t.d,k=t.m,x=t.n,v=r*8;do{if(!y){h=Po(e,u,1);var M=Po(e,u+1,3);if(u+=3,M)if(M==1)y=kot,g=xot,k=9,x=5;else if(M==2){var _=Po(e,u,31)+257,S=Po(e,u+10,15)+4,j=_+Po(e,u+5,31)+1;u+=14;for(var P=new qt(j),A=new qt(19),N=0;N<S;++N)A[fO[N]]=Po(e,u+N*3,7);u+=S*3;for(var R=iD(A),W=(1<<R)-1,$=zr(A,R,1),N=0;N<j;){var H=$[Po(e,u,W)];u+=H&15;var w=H>>4;if(w<16)P[N++]=w;else{var T=0,O=0;for(w==16?(O=3+Po(e,u,3),u+=2,T=P[N-1]):w==17?(O=3+Po(e,u,7),u+=3):w==18&&(O=11+Po(e,u,127),u+=7);O--;)P[N++]=T}}var I=P.subarray(0,_),z=P.subarray(_);k=iD(I),x=iD(z),y=zr(I,k,1),g=zr(z,x,1)}else _n(1);else{var w=WF(u)+4,b=e[w-4]|e[w-3]<<8,C=w+b;if(C>r){c&&_n(0);break}s&&l(f+b),n.set(e.subarray(w,C),f),t.b=f+=b,t.p=u=C*8,t.f=h;continue}if(u>v){c&&_n(0);break}}s&&l(f+131072);for(var L=(1<<k)-1,F=(1<<x)-1,D=u;;D=u){var T=y[sD(e,u)&L],E=T>>4;if(u+=T&15,u>v){c&&_n(0);break}if(T||_n(2),E<256)n[f++]=E;else if(E==256){D=u,y=null;break}else{var K=E-254;if(E>264){var N=E-257,X=LR[N];K=Po(e,u,(1<<X)-1)+Rre[N],u+=X}var Y=g[sD(e,u)&F],Q=Y>>4;Y||_n(3),u+=Y&15;var z=mot[Q];if(Q>3){var X=IR[Q];z+=sD(e,u)&(1<<X)-1,u+=X}if(u>v){c&&_n(0);break}s&&l(f+131072);var te=f+K;if(f<z){var ne=a-z,ie=Math.min(z,te);for(ne+f<0&&_n(3);f<ie;++f)n[f]=o[ne+f]}for(;f<te;++f)n[f]=n[f-z]}}t.l=y,t.p=D,t.b=f,t.f=h,y&&(h=1,t.m=k,t.d=g,t.n=x)}while(!h);return f!=n.length&&i?If(n,0,f):n.subarray(0,f)},aa=function(e,t,n){n<<=t&7;var o=t/8|0;e[o]|=n,e[o+1]|=n>>8},m2=function(e,t,n){n<<=t&7;var o=t/8|0;e[o]|=n,e[o+1]|=n>>8,e[o+2]|=n>>16},cD=function(e,t){for(var n=[],o=0;o<e.length;++o)e[o]&&n.push({s:o,f:e[o]});var r=n.length,a=n.slice();if(!r)return{t:Hre,l:0};if(r==1){var i=new qt(n[0].s+1);return i[n[0].s]=1,{t:i,l:1}}n.sort(function(C,_){return C.f-_.f}),n.push({s:-1,f:25001});var s=n[0],c=n[1],l=0,h=1,u=2;for(n[0]={s:-1,f:s.f+c.f,l:s,r:c};h!=r-1;)s=n[n[l].f<n[u].f?l++:u++],c=n[l!=h&&n[l].f<n[u].f?l++:u++],n[h++]={s:-1,f:s.f+c.f,l:s,r:c};for(var f=a[0].s,o=1;o<r;++o)a[o].s>f&&(f=a[o].s);var y=new no(f+1),g=mO(n[h-1],y,0);if(g>t){var o=0,k=0,x=g-t,v=1<<x;for(a.sort(function(_,S){return y[S.s]-y[_.s]||_.f-S.f});o<r;++o){var M=a[o].s;if(y[M]>t)k+=v-(1<<g-y[M]),y[M]=t;else break}for(k>>=x;k>0;){var w=a[o].s;y[w]<t?k-=1<<t-y[w]++-1:++o}for(;o>=0&&k;--o){var b=a[o].s;y[b]==t&&(--y[b],++k)}g=t}return{t:new qt(y),l:g}},mO=function(e,t,n){return e.s==-1?Math.max(mO(e.l,t,n+1),mO(e.r,t,n+1)):t[e.s]=n},wZ=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new no(++t),o=0,r=e[0],a=1,i=function(c){n[o++]=c},s=1;s<=t;++s)if(e[s]==r&&s!=t)++a;else{if(!r&&a>2){for(;a>138;a-=138)i(32754);a>2&&(i(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(i(r),--a;a>6;a-=6)i(8304);a>2&&(i(a-3<<5|8208),a=0)}for(;a--;)i(r);a=1,r=e[s]}return{c:n.subarray(0,o),n:t}},g2=function(e,t){for(var n=0,o=0;o<t.length;++o)n+=e[o]*t[o];return n},Dre=function(e,t,n){var o=n.length,r=WF(t+2);e[r]=o&255,e[r+1]=o>>8,e[r+2]=e[r]^255,e[r+3]=e[r+1]^255;for(var a=0;a<o;++a)e[r+a+4]=n[a];return(r+4+o)*8},MZ=function(e,t,n,o,r,a,i,s,c,l,h){aa(t,h++,n),++r[256];for(var u=cD(r,15),f=u.t,y=u.l,g=cD(a,15),k=g.t,x=g.l,v=wZ(f),M=v.c,w=v.n,b=wZ(k),C=b.c,_=b.n,S=new no(19),j=0;j<M.length;++j)++S[M[j]&31];for(var j=0;j<C.length;++j)++S[C[j]&31];for(var P=cD(S,7),A=P.t,N=P.l,R=19;R>4&&!A[fO[R-1]];--R);var W=l+5<<3,$=g2(r,Ai)+g2(a,Yh)+i,H=g2(r,f)+g2(a,k)+i+14+3*R+g2(S,A)+2*S[16]+3*S[17]+7*S[18];if(c>=0&&W<=$&&W<=H)return Dre(t,h,e.subarray(c,c+l));var T,O,I,z;if(aa(t,h,1+(H<$)),h+=2,H<$){T=zr(f,y,0),O=f,I=zr(k,x,0),z=k;var L=zr(A,N,0);aa(t,h,w-257),aa(t,h+5,_-1),aa(t,h+10,R-4),h+=14;for(var j=0;j<R;++j)aa(t,h+3*j,A[fO[j]]);h+=3*R;for(var F=[M,C],D=0;D<2;++D)for(var E=F[D],j=0;j<E.length;++j){var K=E[j]&31;aa(t,h,L[K]),h+=A[K],K>15&&(aa(t,h,E[j]>>5&127),h+=E[j]>>12)}}else T=got,O=Ai,I=vot,z=Yh;for(var j=0;j<s;++j){var X=o[j];if(X>255){var K=X>>18&31;m2(t,h,T[K+257]),h+=O[K+257],K>7&&(aa(t,h,X>>23&31),h+=LR[K]);var Y=X&31;m2(t,h,I[Y]),h+=z[Y],Y>3&&(m2(t,h,X>>5&8191),h+=IR[Y])}else m2(t,h,T[X]),h+=O[X]}return m2(t,h,T[256]),h+O[256]},bot=new UF([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Hre=new qt(0),_ot=function(e,t,n,o,r,a){var i=a.z||e.length,s=new qt(o+i+5*(1+Math.ceil(i/7e3))+r),c=s.subarray(o,s.length-r),l=a.l,h=(a.r||0)&7;if(t){h&&(c[0]=a.r>>3);for(var u=bot[t-1],f=u>>13,y=u&8191,g=(1<<n)-1,k=a.p||new no(32768),x=a.h||new no(g+1),v=Math.ceil(n/3),M=2*v,w=function(ce){return(e[ce]^e[ce+1]<<v^e[ce+2]<<M)&g},b=new UF(25e3),C=new no(288),_=new no(32),S=0,j=0,P=a.i||0,A=0,N=a.w||0,R=0;P+2<i;++P){var W=w(P),$=P&32767,H=x[W];if(k[$]=H,x[W]=$,N<=P){var T=i-P;if((S>7e3||A>24576)&&(T>423||!l)){h=MZ(e,c,0,b,C,_,j,A,R,P-R,h),A=S=j=0,R=P;for(var O=0;O<286;++O)C[O]=0;for(var O=0;O<30;++O)_[O]=0}var I=2,z=0,L=y,F=$-H&32767;if(T>2&&W==w(P-F))for(var D=Math.min(f,T)-1,E=Math.min(32767,P),K=Math.min(258,T);F<=E&&--L&&$!=H;){if(e[P+I]==e[P+I-F]){for(var X=0;X<K&&e[P+X]==e[P+X-F];++X);if(X>I){if(I=X,z=F,X>D)break;for(var Y=Math.min(F,X-2),Q=0,O=0;O<Y;++O){var te=P-F+O&32767,ne=k[te],ie=te-ne&32767;ie>Q&&(Q=ie,H=te)}}}$=H,H=k[$],F+=$-H&32767}if(z){b[A++]=268435456|pO[I]<<18|xZ[z];var ke=pO[I]&31,ge=xZ[z]&31;j+=LR[ke]+IR[ge],++C[257+ke],++_[ge],N=P+I,++S}else b[A++]=e[P],++C[e[P]]}}for(P=Math.max(P,N);P<i;++P)b[A++]=e[P],++C[e[P]];h=MZ(e,c,l,b,C,_,j,A,R,P-R,h),l||(a.r=h&7|c[h/8|0]<<3,h-=7,a.h=x,a.p=k,a.i=P,a.w=N)}else{for(var P=a.w||0;P<i+l;P+=65535){var ve=P+65535;ve>=i&&(c[h/8|0]=l,ve=i),h=Dre(c,h+1,e.subarray(P,ve))}a.i=i}return If(s,0,o+WF(h)+r)},Cot=function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var n=t,o=9;--o;)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e}(),Sot=function(){var e=-1;return{p:function(t){for(var n=e,o=0;o<t.length;++o)n=Cot[n&255^t[o]]^n>>>8;e=n},d:function(){return~e}}},Ore=function(){var e=1,t=0;return{p:function(n){for(var o=e,r=t,a=n.length|0,i=0;i!=a;){for(var s=Math.min(i+2655,a);i<s;++i)r+=o+=n[i];o=(o&65535)+15*(o>>16),r=(r&65535)+15*(r>>16)}e=o,t=r},d:function(){return e%=65521,t%=65521,(e&255)<<24|(e&65280)<<8|(t&255)<<8|t>>8}}},qre=function(e,t,n,o,r){if(!r&&(r={l:1},t.dictionary)){var a=t.dictionary.subarray(-32768),i=new qt(a.length+e.length);i.set(a),i.set(e,a.length),e=i,r.w=a.length}return _ot(e,t.level==null?6:t.level,t.mem==null?r.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,o,r)},Fre=function(e,t){var n={};for(var o in e)n[o]=e[o];for(var o in t)n[o]=t[o];return n},Lr=function(e,t){return e[t]|e[t+1]<<8},qo=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},lD=function(e,t){return qo(e,t)+qo(e,t+4)*4294967296},en=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8},Lot=function(e,t){var n=t.level,o=n==0?0:n<6?1:n==9?3:2;if(e[0]=120,e[1]=o<<6|(t.dictionary&&32),e[1]|=31-(e[0]<<8|e[1])%31,t.dictionary){var r=Ore();r.p(t.dictionary),en(e,2,r.d())}};function Iot(e,t){return qre(e,t||{},0,0)}function Not(e,t){return Mot(e,{i:2},t&&t.out,t&&t.dictionary)}function Mrt(e,t){t||(t={});var n=Ore();n.p(e);var o=qre(e,t,t.dictionary?6:2,4);return Lot(o,t),en(o,o.length-4,n.d()),o}var Vre=function(e,t,n,o){for(var r in e){var a=e[r],i=t+r,s=o;Array.isArray(a)&&(s=Fre(o,a[1]),a=a[0]),a instanceof qt?n[i]=[a,s]:(n[i+="/"]=[new qt(0),s],Vre(a,i,n,o))}},bZ=typeof TextEncoder<"u"&&new TextEncoder,gO=typeof TextDecoder<"u"&&new TextDecoder,Aot=0;try{gO.decode(Hre,{stream:!0}),Aot=1}catch{}var Eot=function(e){for(var t="",n=0;;){var o=e[n++],r=(o>127)+(o>223)+(o>239);if(n+r>e.length)return{s:t,r:If(e,n-1)};r?r==3?(o=((o&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,t+=String.fromCharCode(55296|o>>10,56320|o&1023)):r&1?t+=String.fromCharCode((o&31)<<6|e[n++]&63):t+=String.fromCharCode((o&15)<<12|(e[n++]&63)<<6|e[n++]&63):t+=String.fromCharCode(o)}};function pz(e,t){var n;if(bZ)return bZ.encode(e);for(var o=e.length,r=new qt(e.length+(e.length>>1)),a=0,i=function(l){r[a++]=l},n=0;n<o;++n){if(a+5>r.length){var s=new qt(a+8+(o-n<<1));s.set(r),r=s}var c=e.charCodeAt(n);c<128||t?i(c):c<2048?(i(192|c>>6),i(128|c&63)):c>55295&&c<57344?(c=65536+(c&1047552)|e.charCodeAt(++n)&1023,i(240|c>>18),i(128|c>>12&63),i(128|c>>6&63),i(128|c&63)):(i(224|c>>12),i(128|c>>6&63),i(128|c&63))}return If(r,0,a)}function $ot(e,t){if(t){for(var n="",o=0;o<e.length;o+=16384)n+=String.fromCharCode.apply(null,e.subarray(o,o+16384));return n}else{if(gO)return gO.decode(e);var r=Eot(e),a=r.s,n=r.r;return n.length&&_n(8),a}}var jot=function(e,t){return t+30+Lr(e,t+26)+Lr(e,t+28)},Pot=function(e,t,n){var o=Lr(e,t+28),r=$ot(e.subarray(t+46,t+46+o),!(Lr(e,t+8)&2048)),a=t+46+o,i=qo(e,t+20),s=n&&i==4294967295?zot(e,a):[i,qo(e,t+24),qo(e,t+42)],c=s[0],l=s[1],h=s[2];return[Lr(e,t+10),c,l,r,a+Lr(e,t+30)+Lr(e,t+32),h]},zot=function(e,t){for(;Lr(e,t)!=1;t+=4+Lr(e,t+2));return[lD(e,t+12),lD(e,t+4),lD(e,t+20)]},kO=function(e){var t=0;if(e)for(var n in e){var o=e[n].length;o>65535&&_n(9),t+=o+4}return t},_Z=function(e,t,n,o,r,a,i,s){var c=o.length,l=n.extra,h=s&&s.length,u=kO(l);en(e,t,i!=null?33639248:67324752),t+=4,i!=null&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(a<0&&8),e[t++]=r&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var f=new Date(n.mtime==null?Date.now():n.mtime),y=f.getFullYear()-1980;if((y<0||y>119)&&_n(10),en(e,t,y<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>1),t+=4,a!=-1&&(en(e,t,n.crc),en(e,t+4,a<0?-a-2:a),en(e,t+8,n.size)),en(e,t+12,c),en(e,t+14,u),t+=16,i!=null&&(en(e,t,h),en(e,t+6,n.attrs),en(e,t+10,i),t+=14),e.set(o,t),t+=c,u)for(var g in l){var k=l[g],x=k.length;en(e,t,+g),en(e,t+2,x),e.set(k,t+4),t+=4+x}return h&&(e.set(s,t),t+=h),t},Rot=function(e,t,n,o,r){en(e,t,101010256),en(e,t+8,n),en(e,t+10,n),en(e,t+12,o),en(e,t+16,r)};function Bre(e,t){t||(t={});var n={},o=[];Vre(e,"",n,t);var r=0,a=0;for(var i in n){var s=n[i],c=s[0],l=s[1],h=l.level==0?0:8,u=pz(i),f=u.length,y=l.comment,g=y&&pz(y),k=g&&g.length,x=kO(l.extra);f>65535&&_n(11);var v=h?Iot(c,l):c,M=v.length,w=Sot();w.p(c),o.push(Fre(l,{size:c.length,crc:w.d(),c:v,f:u,m:g,u:f!=i.length||g&&y.length!=k,o:r,compression:h})),r+=30+f+x+M,a+=76+2*(f+x)+(k||0)+M}for(var b=new qt(a+22),C=r,_=a-r,S=0;S<o.length;++S){var u=o[S];_Z(b,u.o,u,u.f,u.u,u.c.length);var j=30+u.f.length+kO(u.extra);b.set(u.c,u.o+j),_Z(b,r,u,u.f,u.u,u.c.length,u.o,u.m),r+=16+j+(u.m?u.m.length:0)}return Rot(b,r,o.length,_,C),b}function Tot(e,t){for(var n={},o=e.length-22;qo(e,o)!=101010256;--o)(!o||e.length-o>65558)&&_n(13);var r=Lr(e,o+8);if(!r)return{};var a=qo(e,o+16),i=a==4294967295||r==65535;if(i){var s=qo(e,o-12);i=qo(e,s)==101075792,i&&(r=qo(e,s+32),a=qo(e,s+48))}for(var c=0;c<r;++c){var l=Pot(e,a,i),h=l[0],u=l[1],f=l[2],y=l[3],g=l[4],k=l[5],x=jot(e,k);a=g,h?h==8?n[y]=Not(e.subarray(x,x+u),{out:new qt(f)}):_n(14,"unknown compression type "+h):n[y]=If(e,x,x+u)}return n}const Dot=2;function Hot(e){if(e.type!=="image")return;const t=e.data;return typeof(t==null?void 0:t.path)=="string"&&t.path.length>0?t.path:void 0}async function Oot({project:e,flows:t}){var h;const n=`/api/projects/${encodeURIComponent(e)}`,o=await fetch(n);if(!o.ok)throw new Error(`GET ${n} → ${o.status}`);const r=await o.json(),a=new Set(t.map(u=>u.flowSlug)),i=r.flows.filter(u=>a.has(u.flowSlug)),s=a.has(r.defaultFlow)?r.defaultFlow:((h=i[0])==null?void 0:h.flowSlug)??r.defaultFlow,c={version:1,name:r.name,defaultFlow:s,flows:i.map(u=>{const f={id:u.flowSlug,name:u.name};return u.icon!==void 0&&(f.icon=u.icon),f})};r.description!==void 0&&(c.description=r.description);const l={"seeflow.json":pz(JSON.stringify(c,null,2))};for(const{flowSlug:u}of t){const f=`/api/projects/${encodeURIComponent(e)}/flows/${encodeURIComponent(u)}`,y=await fetch(f);if(!y.ok)throw new Error(`GET ${f} → ${y.status}`);const{flow:g}=await y.json(),k={version:Dot,name:g.name,nodes:g.nodes,connectors:g.connectors};g.description!==void 0&&(k.description=g.description),l[`flows/${u}/flow.json`]=pz(JSON.stringify(k));const x=new Set;for(const v of g.nodes){const M=Hot(v);if(!M||x.has(M))continue;x.add(M);const w=`/api/projects/${encodeURIComponent(e)}/files/${M}`,b=await fetch(w);b.ok&&(l[`flows/${u}/files/${M}`]=new Uint8Array(await b.arrayBuffer()))}}return Bre(l)}const qot="https://seeflow.dev/api";async function Fot(e,t,n,o,r,a){let s=await Oot({project:e,flows:a.map(f=>({flowSlug:f}))});const c=r==null?void 0:r.split(",")[1];if(c){const f=Tot(s);f["preview.png"]=Uint8Array.from(atob(c),y=>y.charCodeAt(0)),s=Bre(f)}const l=`${qot}/projects?email=${encodeURIComponent(t)}&name=${encodeURIComponent(n)}&visibility=${encodeURIComponent(o)}`,h=await fetch(l,{method:"POST",headers:{"content-type":"application/zip"},body:s.buffer});if(!h.ok)throw new Error(`Export failed with status ${h.status}`);const u=await h.json();if(typeof u.url!="string")throw new Error("Invalid response from cloud API: missing url");return{shareUrl:u.url}}function Vot(e){return m.useCallback((t,n,o,r,a)=>Fot(e,t,n,o,r,a??[]),[e])}const CZ="seeflow.export.email",SZ="seeflow.export.name",LZ="seeflow.export.visibility";function Bot({open:e,onOpenChange:t,project:n,flowName:o,onCapturePreview:r}){const[a,i]=m.useState(""),[s,c]=m.useState(""),[l,h]=m.useState("public"),[u,f]=m.useState({kind:"idle"}),[y,g]=m.useState(!1),[k,x]=m.useState(new Set),v=Vot(n),M=BF(e?n:null),w=M.flows;m.useEffect(()=>{e&&(i(localStorage.getItem(CZ)??""),c(o??localStorage.getItem(SZ)??""),h(localStorage.getItem(LZ)??"public"),f({kind:"idle"}),g(!1))},[e,o]),m.useEffect(()=>{e&&w&&x(new Set(w.map($=>$.flowSlug)))},[e,w]);const b=m.useCallback(async()=>{f({kind:"loading"});try{const $=await(r==null?void 0:r()),{shareUrl:H}=await v(a.trim(),s.trim(),l,$,Array.from(k));localStorage.setItem(CZ,a.trim()),localStorage.setItem(SZ,s.trim()),localStorage.setItem(LZ,l),f({kind:"done",shareUrl:H})}catch($){f({kind:"error",message:$ instanceof Error?$.message:String($)})}},[v,a,s,l,r,k]),C=m.useCallback($=>{x(H=>{const T=new Set(H);return T.has($)?T.delete($):T.add($),T})},[]),_=m.useCallback(()=>{w&&x($=>$.size===w.length?new Set:new Set(w.map(H=>H.flowSlug)))},[w]),S=m.useCallback(async()=>{if(u.kind==="done")try{await navigator.clipboard.writeText(u.shareUrl),g(!0),setTimeout(()=>g(!1),2e3)}catch($){console.error("Failed to copy to clipboard:",$)}},[u]),j=u.kind==="loading",P=a.trim().length>0&&s.trim().length>0&&w!==null&&M.error===null&&k.size>0,A=((w==null?void 0:w.length)??0)>=2,N=M.loading,R=M.error!==null,W=w!==null&&k.size===w.length;return p.jsx(Ca,{open:e,onOpenChange:t,children:p.jsxs(Ri,{className:"sm:max-w-md","data-testid":"export-dialog",onOpenAutoFocus:$=>{$.preventDefault();const H=document.querySelector('[data-testid="export-email-input"]');H==null||H.focus()},children:[p.jsxs(Ti,{children:[p.jsx(Di,{children:"Export project to seeflow.dev"}),p.jsx(Hi,{children:"Upload this project to the cloud and get a shareable link."})]}),u.kind!=="done"?p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Email"}),p.jsx("input",{type:"email",required:!0,autoComplete:"email",value:a,onChange:$=>i($.target.value),disabled:j,"data-testid":"export-email-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"}),p.jsx("span",{className:"text-xs text-muted-foreground",children:"We'll use this to let you manage your flows in the future."})]}),p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Flow Name"}),p.jsx("input",{type:"text",required:!0,value:s,onChange:$=>c($.target.value),disabled:j,"data-testid":"export-name-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"})]}),p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Visibility"}),p.jsxs("select",{value:l,onChange:$=>h($.target.value),disabled:j,"data-testid":"export-visibility-select",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",children:[p.jsx("option",{value:"public",children:"Public — anyone can discover it"}),p.jsx("option",{value:"link",children:"Anyone with the link"})]})]}),N?p.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground","data-testid":"export-flows-loading",children:[p.jsx(fZ,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}),p.jsx("span",{children:"Loading flows…"})]}):null,R?p.jsxs("div",{role:"alert","data-testid":"export-flows-error",className:"flex items-center justify-between gap-3 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[p.jsx("span",{children:"Couldn't load flows."}),p.jsx("button",{type:"button",onClick:()=>M.refresh(),disabled:j,"data-testid":"export-flows-retry",className:"shrink-0 font-medium underline-offset-2 hover:underline disabled:cursor-not-allowed disabled:opacity-50",children:"Retry"})]}):null,A&&w?p.jsxs("div",{className:"flex flex-col gap-1.5 text-sm","data-testid":"export-flows-section",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"font-medium",children:"Flows"}),p.jsx("button",{type:"button",onClick:_,disabled:j,"data-testid":"export-flows-toggle-all",className:"text-xs text-muted-foreground underline-offset-2 hover:text-foreground hover:underline disabled:cursor-not-allowed disabled:opacity-50",children:W?"Clear":"Select all"})]}),p.jsx("ul",{className:"flex max-h-48 flex-col gap-1 overflow-y-auto rounded-md border bg-background p-2",children:w.map($=>p.jsx("li",{children:p.jsxs("label",{className:"flex items-center gap-2 rounded px-2 py-1 hover:bg-muted",children:[p.jsx("input",{type:"checkbox",checked:k.has($.flowSlug),onChange:()=>C($.flowSlug),disabled:j,"data-testid":`export-flow-checkbox-${$.flowSlug}`}),p.jsx("span",{className:"flex-1 truncate",children:$.name}),$.isDefault?p.jsx(Pnt,{className:"h-3.5 w-3.5 text-muted-foreground","aria-label":"default flow","data-testid":`export-flow-default-${$.flowSlug}`}):null]})},$.flowSlug))})]}):null,u.kind==="error"?p.jsx("div",{role:"alert","data-testid":"export-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:u.message}):null]}),p.jsx(Sa,{children:u.kind==="error"?p.jsxs(p.Fragment,{children:[p.jsx(ut,{type:"button",variant:"ghost",onClick:()=>t(!1),"data-testid":"export-cancel",children:"Cancel"}),p.jsx(ut,{type:"button",onClick:()=>f({kind:"idle"}),"data-testid":"export-retry",children:"Try again"})]}):p.jsxs(p.Fragment,{children:[p.jsx(ut,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:j,"data-testid":"export-cancel",children:"Cancel"}),p.jsx(ut,{type:"button",onClick:b,disabled:j||!P,"data-testid":"export-submit",children:j?p.jsxs(p.Fragment,{children:[p.jsx(fZ,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}),p.jsx("span",{children:"Uploading…"})]}):"Export"})]})})]}):p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex flex-col gap-3",children:[p.jsx("p",{className:"text-sm text-muted-foreground",children:"Your diagram is live. Share this link:"}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{type:"text",readOnly:!0,value:u.shareUrl,"data-testid":"export-share-url",className:"min-w-0 flex-1 rounded-md border bg-muted px-3 py-2 text-sm outline-hidden"}),p.jsx(ut,{type:"button",variant:"outline",size:"icon",onClick:S,"aria-label":"Copy link","data-testid":"export-copy",children:y?p.jsx(_re,{className:"h-4 w-4","aria-hidden":"true"}):p.jsx(Sre,{className:"h-4 w-4","aria-hidden":"true"})}),p.jsx(ut,{type:"button",variant:"outline",size:"icon",onClick:()=>window.open(u.shareUrl,"_blank"),"aria-label":"View in new tab","data-testid":"export-view",children:p.jsx(Ent,{className:"h-4 w-4","aria-hidden":"true"})})]})]}),p.jsx(Sa,{children:p.jsx(ut,{type:"button",onClick:()=>t(!1),"data-testid":"export-done",children:"Done"})})]})]})})}function Uot(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}const Wot=/^[a-z0-9][a-z0-9-]*$/,Got={"--tw-enter-translate-x":"-50%","--tw-enter-translate-y":"-50%","--tw-exit-translate-x":"-50%","--tw-exit-translate-y":"-50%","--tw-enter-scale":"1","--tw-exit-scale":"1"};function Zot({open:e,onOpenChange:t,onCreate:n,onCreated:o}){const[r,a]=m.useState(""),[i,s]=m.useState(""),[c,l]=m.useState(!1),[h,u]=m.useState(null),[f,y]=m.useState(!1);m.useEffect(()=>{e&&(a(""),s(""),l(!1),u(null),y(!1))},[e]);const g=C=>{a(C),c||s(Uot(C))},k=C=>{s(C),c||l(!0)},x=i.trim(),v=r.trim(),M=x.length>0&&Wot.test(x),w=M&&v.length>0&&!f,b=async C=>{if(C.preventDefault(),!w){!M&&x.length>0&&u("Flow id must match /^[a-z0-9][a-z0-9-]*$/");return}y(!0),u(null);try{const S=await n({id:x,name:v});o==null||o(S),t(!1)}catch(_){u(_ instanceof Error?_.message:String(_)),y(!1)}};return p.jsx(Ca,{open:e,onOpenChange:t,children:p.jsxs(Ri,{className:"sm:max-w-md",style:Got,"data-testid":"flow-create-dialog",onOpenAutoFocus:C=>{C.preventDefault();const _=document.querySelector('[data-testid="flow-create-name-input"]');_==null||_.focus()},children:[p.jsxs(Ti,{children:[p.jsx(Di,{children:"Create new flow"}),p.jsx(Hi,{children:"A new flow folder is scaffolded under flows/<id>/ in your project."})]}),p.jsxs("form",{onSubmit:b,className:"flex flex-col gap-4",children:[p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Display name"}),p.jsx("input",{type:"text",required:!0,autoComplete:"off",spellCheck:!1,value:r,onChange:C=>g(C.target.value),"data-testid":"flow-create-name-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"})]}),p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Flow id"}),p.jsx("input",{type:"text",required:!0,autoComplete:"off",spellCheck:!1,placeholder:"my-retry-flow",value:i,onChange:C=>k(C.target.value),"data-testid":"flow-create-id-input",className:"rounded-md border bg-background px-3 py-2 font-mono text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"}),p.jsx("span",{className:"text-xs text-muted-foreground",children:"Auto-filled from the display name. Lowercase letters, digits, and dashes; must start with a letter or digit."})]}),h?p.jsx("div",{role:"alert","data-testid":"flow-create-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:h}):null,p.jsxs(Sa,{children:[p.jsx(ut,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:f,children:"Cancel"}),p.jsx(ut,{type:"submit",disabled:!w,"data-testid":"flow-create-submit",children:f?"Creating…":"Create flow"})]})]})]})})}function Xot({open:e,onOpenChange:t,flow:n,flows:o,onDelete:r,onDeleted:a}){var M;const i=m.useMemo(()=>o.filter(w=>w.flowSlug!==(n==null?void 0:n.flowSlug)),[o,n==null?void 0:n.flowSlug]),s=((M=i[0])==null?void 0:M.flowSlug)??"",[c,l]=m.useState(s),[h,u]=m.useState(null),[f,y]=m.useState(!1);if(m.useEffect(()=>{e&&(l(s),u(null),y(!1))},[e,s]),!n)return p.jsx(Ca,{open:!1,onOpenChange:t});const g=n.isDefault,k=c.length>0,x=(!g||k)&&!f,v=async w=>{if(w.preventDefault(),!!x){y(!0),u(null);try{const b=g?{newDefault:c}:void 0;await r(n.flowSlug,b),a==null||a(n.flowSlug,b==null?void 0:b.newDefault),t(!1)}catch(b){u(b instanceof Error?b.message:String(b)),y(!1)}}};return p.jsx(Ca,{open:e,onOpenChange:t,children:p.jsxs(Ri,{className:"sm:max-w-md","data-testid":"flow-delete-dialog",children:[p.jsxs(Ti,{children:[p.jsx(Di,{children:"Delete flow"}),p.jsxs(Hi,{children:["This removes flows/",n.flowSlug,"/ from disk and updates seeflow.json. The action cannot be undone."]})]}),p.jsxs("form",{onSubmit:v,className:"flex flex-col gap-4",children:[p.jsxs("p",{className:"text-sm",children:["Delete ",p.jsx("span",{className:"font-medium",children:n.name})," ",p.jsxs("span",{className:"font-mono text-muted-foreground",children:["(",n.flowSlug,")"]}),"?"]}),g?p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsx("span",{className:"font-medium",children:"New default flow"}),p.jsx("select",{value:c,onChange:w=>l(w.target.value),"data-testid":"flow-delete-new-default-select",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:i.map(w=>p.jsxs("option",{value:w.flowSlug,children:[w.name," (",w.flowSlug,")"]},w.flowSlug))}),p.jsxs("span",{className:"text-xs text-muted-foreground",children:[n.name," is the project default — pick a replacement before deleting."]})]}):null,h?p.jsx("div",{role:"alert","data-testid":"flow-delete-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:h}):null,p.jsxs(Sa,{children:[p.jsx(ut,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:f,children:"Cancel"}),p.jsx(ut,{type:"submit",variant:"destructive",disabled:!x,"data-testid":"flow-delete-submit",children:f?"Deleting…":"Delete"})]})]})]})})}function Kot({open:e,onOpenChange:t,flow:n,onRename:o,onRenamed:r}){const[a,i]=m.useState(""),[s,c]=m.useState(null),[l,h]=m.useState(!1);if(m.useEffect(()=>{e&&n&&(i(n.name),c(null),h(!1))},[e,n]),!n)return p.jsx(Ca,{open:!1,onOpenChange:t});const u=a.trim(),f=u!==n.name,y=u.length>0&&f&&!l,g=async k=>{if(k.preventDefault(),!!y){h(!0),c(null);try{const x={name:u},v=await o(n.flowSlug,x);r==null||r(v,n.flowSlug),t(!1)}catch(x){c(x instanceof Error?x.message:String(x)),h(!1)}}};return p.jsx(Ca,{open:e,onOpenChange:t,children:p.jsxs(Ri,{className:"sm:max-w-md","data-testid":"flow-rename-dialog",onOpenAutoFocus:k=>{k.preventDefault();const x=document.querySelector('[data-testid="flow-rename-name-input"]');x==null||x.focus(),x==null||x.select()},children:[p.jsxs(Ti,{children:[p.jsx(Di,{children:"Rename flow"}),p.jsx(Hi,{children:"Update the display name. The flow id is fixed once created."})]}),p.jsxs("form",{onSubmit:g,className:"flex flex-col gap-4",children:[p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Flow id"}),p.jsx("input",{type:"text",readOnly:!0,disabled:!0,autoComplete:"off",spellCheck:!1,value:n.flowSlug,"data-testid":"flow-rename-id-input",className:"cursor-not-allowed rounded-md border bg-muted px-3 py-2 font-mono text-sm text-muted-foreground"})]}),p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Display name"}),p.jsx("input",{type:"text",required:!0,autoComplete:"off",spellCheck:!1,value:a,onChange:k=>i(k.target.value),"data-testid":"flow-rename-name-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"})]}),s?p.jsx("div",{role:"alert","data-testid":"flow-rename-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:s}):null,p.jsxs(Sa,{children:[p.jsx(ut,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:l,children:"Cancel"}),p.jsx(ut,{type:"submit",disabled:!y,"data-testid":"flow-rename-submit",children:l?"Saving…":"Save"})]})]})]})})}function Yot({project:e,activeFlow:t,flows:n,onSelect:o,onCreate:r,onRename:a,onDelete:i}){const[s,c]=m.useState(!1),l=n.find(h=>h.flowSlug===t);return p.jsxs(Dd,{open:s,onOpenChange:c,children:[p.jsx(V0,{asChild:!0,children:p.jsxs(ut,{type:"button",variant:"outline",size:"sm","aria-label":`Switch flow for ${e}`,"aria-expanded":s,className:"gap-2","data-testid":"flow-switcher-trigger",children:[p.jsx("span",{className:"max-w-[180px] truncate text-sm",children:(l==null?void 0:l.name)??t}),p.jsx(Cre,{className:"h-3.5 w-3.5 opacity-60"})]})}),p.jsx(zi,{align:"start",sideOffset:6,className:"w-[260px] p-0","data-testid":"flow-switcher-popover",children:p.jsx(sF,{children:p.jsxs(cF,{children:[p.jsx(lF,{children:"No flows."}),n.length>0?p.jsx(Bh,{heading:"Flows",children:n.map(h=>{const u=h.flowSlug===t;return p.jsxs(Uh,{value:`${h.name} ${h.flowSlug}`,"aria-current":u?"true":void 0,"data-testid":`flow-switcher-row-${h.flowSlug}`,"data-active":u?"true":void 0,onSelect:()=>{c(!1),o==null||o(h.flowSlug)},className:oe("group flex items-center justify-between gap-2",u&&"bg-accent text-accent-foreground"),children:[p.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[h.icon?p.jsx("span",{"aria-hidden":"true",className:"text-xs opacity-70",children:h.icon}):null,p.jsx("span",{className:"truncate font-medium",children:h.name}),h.isDefault?p.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:"default"}):null]}),p.jsxs("div",{className:"flex shrink-0 items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100",children:[p.jsx("button",{type:"button","aria-label":`Rename ${h.name}`,"data-testid":`flow-switcher-rename-${h.flowSlug}`,className:"rounded p-0.5 hover:text-foreground focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring",onClick:f=>{f.stopPropagation(),c(!1),a==null||a(h.flowSlug)},children:p.jsx($nt,{className:"h-3.5 w-3.5"})}),p.jsx("button",{type:"button","aria-label":`Delete ${h.name}`,"data-testid":`flow-switcher-delete-${h.flowSlug}`,className:"rounded p-0.5 hover:text-destructive focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring",onClick:f=>{f.stopPropagation(),c(!1),i==null||i(h.flowSlug)},children:p.jsx(Ire,{className:"h-3.5 w-3.5"})})]})]},h.flowSlug)})}):null,n.length>0?p.jsx(dF,{}):null,p.jsx(Bh,{children:p.jsxs(Uh,{value:"+ new flow","data-testid":"flow-switcher-create",onSelect:()=>{c(!1),r==null||r()},className:"flex items-center gap-2 text-sm",children:[p.jsx(Lre,{className:"h-4 w-4 opacity-70"}),p.jsx("span",{className:"font-medium",children:"New flow"})]})})]})})})]})}const Qot=(e,t)=>{if(e.has(t))return e;const n=new Set(e);return n.add(t),n},Jot=(e,t)=>{if(t.length===0)return e;let n=!1;const o=new Set(e);for(const r of t)o.has(r)||(o.add(r),n=!0);return n?o:e},ert=(e,t)=>{if(!e.has(t))return e;const n=new Set(e);return n.delete(t),n},trt=(e,t)=>{if(t.length===0)return e;let n=!1;const o=new Set(e);for(const r of t)o.has(r)&&(o.delete(r),n=!0);return n?o:e},nrt=(e,t)=>{if(e.size===0)return e;const n=new Set(t.map(a=>a.id));let o=!1;const r=new Set(e);for(const a of r)n.has(a)||(r.delete(a),o=!0);return o?r:e},IZ=()=>{const[e,t]=m.useState(()=>new Set),n=m.useCallback(c=>{t(l=>Qot(l,c))},[]),o=m.useCallback(c=>{t(l=>Jot(l,c))},[]),r=m.useCallback(c=>{t(l=>ert(l,c))},[]),a=m.useCallback(c=>{t(l=>trt(l,c))},[]),i=m.useCallback(c=>{t(l=>nrt(l,c))},[]),s=m.useCallback(()=>t(new Set),[]);return{ids:e,mark:n,markMany:o,unmark:r,unmarkMany:a,pruneAgainst:i,reset:s}},dD=(e,t)=>e===t?!0:e==null||t==null||typeof e!=typeof t||typeof e!="object"?!1:JSON.stringify(e)===JSON.stringify(t),ort=(e,t,n)=>({...e,[t]:{...e[t],...n}}),rrt=(e,t)=>{if(!(t in e))return e;const n={...e};return delete n[t],n},NZ=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),art=(e,t)=>{const n=Object.entries(e);if(n.length===0)return e;const o=new Map(t.map(i=>[i.id,i]));let r=!1;const a={...e};for(const[i,s]of n){const c=o.get(i);if(!c)continue;const l={},h=l;let u=!1;for(const f of Object.keys(s)){const y=s[f],g=c[f];if(f==="data"&&NZ(y)&&NZ(g)){const k={};let x=!1;for(const v of Object.keys(y))dD(y[v],g[v])||(k[v]=y[v],x=!0);x&&(h[f]=k,u=!0)}else dD(y,g)||(h[f]=y,u=!0)}u?dD(l,s)||(a[i]=l,r=!0):(delete a[i],r=!0)}return r?a:e},AZ=()=>{const[e,t]=m.useState({}),n=m.useCallback((i,s)=>{t(c=>ort(c,i,s))},[]),o=m.useCallback(i=>{t(s=>rrt(s,i))},[]),r=m.useCallback(i=>{t(s=>art(s,i))},[]),a=m.useCallback(()=>t({}),[]);return{overrides:e,setOverride:n,dropOverride:o,pruneAgainst:r,reset:a}};function irt({nodes:e,connectors:t,flowPos:n,nodeIdGen:o,connectorIdGen:r,defaultOffset:a={x:24,y:24}}){const i=new Map;for(const y of e)i.set(y.id,o(y.id));let s=Number.POSITIVE_INFINITY,c=Number.POSITIVE_INFINITY;for(const y of e)y.position.x<s&&(s=y.position.x),y.position.y<c&&(c=y.position.y);Number.isFinite(s)||(s=0),Number.isFinite(c)||(c=0);const l=n?n.x-s:a.x,h=n?n.y-c:a.y,u=e.map(y=>{const g=i.get(y.id);if(g===void 0)throw new Error(`paste id missing for ${y.id}`);return{...y,id:g,position:{x:y.position.x+l,y:y.position.y+h}}}),f=t.map(y=>{const g=r(y.id);return{...y,id:g,source:i.get(y.source)??y.source,target:i.get(y.target)??y.target}});return{newNodes:u,newConnectors:f,idMap:i}}const srt=e=>({type:"image",position:e.position,data:{path:"",alt:e.originalFilename,width:e.dims.width,height:e.dims.height,_uploading:!0}}),crt=e=>({type:"image",data:Ure(e)}),lrt=e=>({type:"image",position:e.position,data:{path:"",alt:e.originalFilename,width:e.dims.width,height:e.dims.height,_uploadError:e.message}}),Ure=e=>({...wDe(e.path,e.dims,e.lastUsed),alt:e.originalFilename}),drt=async(e,t)=>{const{nodeId:n,flowId:o,file:r,originalFilename:a,position:i,dims:s,lastUsed:c}=e;t.rememberRetry(n,{file:r,originalFilename:a,position:i,dims:s}),t.setOverride(n,srt({position:i,dims:s,originalFilename:a}));const l=async()=>{let h;try{h=(await t.upload(o,n,r,a)).path}catch(y){const g=y instanceof Error?y.message:String(y);throw t.setOverride(n,lrt({position:i,dims:s,originalFilename:a,message:g})),y}t.setOverride(n,crt({path:h,dims:s,originalFilename:a,lastUsed:c}));const u=Ure({path:h,dims:s,originalFilename:a,lastUsed:c}),f={id:n,type:"image",position:i,data:u};await t.createNode(o,f),t.forgetRetry(n)};if(t.history){await t.history.batch("insert-image",l);return}await l()},urt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",hrt=248;function ia(e=10){let t="";const n=new Uint8Array(e*2);for(;t.length<e;){crypto.getRandomValues(n);for(let o=0;o<n.length&&t.length<e;o++){const r=n[o];r<hrt&&(t+=urt[r%62])}}return t}const frt=new Set(["INPUT","TEXTAREA","SELECT"]),hr=e=>e?frt.has(e.tagName)?!0:e instanceof HTMLElement&&e.isContentEditable:!1,prt=(e,t,n)=>{const o=e.indexOf(t);if(o<0)return null;const r=e.length,a=[...e];switch(n.op){case"forward":{if(o>=r-1)return null;const i=a[o],s=a[o+1];return i===void 0||s===void 0?null:(a[o]=s,a[o+1]=i,a)}case"backward":{if(o<=0)return null;const i=a[o],s=a[o-1];return i===void 0||s===void 0?null:(a[o]=s,a[o-1]=i,a)}case"toFront":{if(o===r-1)return null;const[i]=a.splice(o,1);return i===void 0?null:(a.push(i),a)}case"toBack":{if(o===0)return null;const[i]=a.splice(o,1);return i===void 0?null:(a.unshift(i),a)}case"toIndex":{const i=Math.min(Math.max(n.index,0),r-1);if(i===o)return null;const[s]=a.splice(o,1);return s===void 0?null:(a.splice(i,0,s),a)}}};function yrt({project:e,flow:t,slug:n,demos:o,detail:r,loading:a,runs:i,nodeEvents:s,statusByNode:c,externalReloadSignal:l,onPlayNode:h,refreshFlows:u}){var Z0,X0;const f=o.find(V=>V.slug===n),{flows:y,createFlow:g,renameFlow:k,deleteFlow:x}=BF(e),[v,M]=m.useState([]),[w,b]=m.useState([]),[C,_]=m.useState(null),S=m.useRef(v),j=m.useRef(w);m.useEffect(()=>{S.current=v},[v]),m.useEffect(()=>{j.current=w},[w]);const P=m.useRef(null),A=m.useRef(null),N=AZ(),R=AZ(),W=IZ(),$=IZ(),[H,T]=m.useState(null),[O,I]=m.useState(null),[z,L]=m.useState({kind:"select"}),F=m.useRef({kind:"select"});m.useEffect(()=>{F.current=z},[z]);const[D,E]=m.useState(!1),K=m.useRef(new Set),X=`${e}/${t}`,Y=!K.current.has(X);m.useEffect(()=>{K.current.add(X)},[X]);const Q=m.useRef(null),te=m.useCallback(V=>{Q.current=V},[]),{reset:ne}=N,{reset:ie}=R,{reset:ke}=W,{reset:ge}=$;m.useEffect(()=>{M([]),b([]),_(null),ne(),ie(),ke(),ge(),T(null),I(null),nr.current=null,vn(!1),Gn.current.clear()},[r==null?void 0:r.id]);const ve=m.useCallback((V,q)=>{M(V),b(q)},[]),ce=(Z0=r==null?void 0:r.flow)==null?void 0:Z0.nodes,Ce=(X0=r==null?void 0:r.flow)==null?void 0:X0.connectors,{pruneAgainst:Re}=N,{pruneAgainst:st}=R,{pruneAgainst:Vt}=W,{pruneAgainst:It}=$;m.useEffect(()=>{if(!(!ce||!H)&&ce.length===H.length){for(let V=0;V<ce.length;V++){const q=ce[V],U=H[V];if(!q||q.id!==U)return}T(null)}},[ce,H]);const pe=(r==null?void 0:r.id)??null,se=m.useMemo(()=>MDe({baseUrl:"",project:e,flow:t}),[e,t]),we=m.useRef({nodes:[],connectors:[]});m.useEffect(()=>{we.current={nodes:ce??[],connectors:Ce??[]}},[ce,Ce]);const{adapter:re,history:Be}=m.useMemo(()=>EDe(se,()=>we.current),[se,pe]);m.useEffect(()=>{ce&&(Re(ce),Vt(ce))},[ce,Re,Vt]),m.useEffect(()=>{Ce&&(st(Ce),It(Ce))},[Ce,st,It]);const an=m.useRef(!1);m.useEffect(()=>{if(!an.current){an.current=!0;return}Be.markExternalChange()},[l,Be]);const[J,ue]=m.useState(!1),[je,Ue]=m.useState(!1),[Ke,Bt]=m.useState(null),[un,Ut]=m.useState(null),{setOverride:xe,dropOverride:Ae}=N,Tt=m.useRef(N.overrides);m.useEffect(()=>{Tt.current=N.overrides},[N.overrides]);const jn=m.useCallback((V,q)=>{!pe||!re||(xe(V,{position:q}),I(null),re.updateNodePosition(V,q).catch(U=>{Ae(V),I(U instanceof Error?U.message:String(U)),console.error("updateNodePosition failed",U)}))},[pe,re,xe,Ae]),Nt=m.useCallback(V=>{if(!pe||!re||V.length===0)return;const q=V.map(U=>(ce==null?void 0:ce.find(ee=>ee.id===U.id))?{id:U.id,next:U.position}:null).filter(U=>U!==null);if(q.length!==0){for(const U of q)xe(U.id,{position:U.next});I(null),Be.batch("move-nodes",async()=>{for(const U of q)await re.updateNodePosition(U.id,U.next)}).catch(U=>{for(const G of q)Ae(G.id);I(U instanceof Error?U.message:String(U)),console.error("updateNodePosition batch failed",U)})}},[pe,re,Be,ce,xe,Ae]),ho=m.useCallback((V,q)=>{xe(V,{position:{x:q.x,y:q.y},data:{width:q.width,height:q.height}})},[xe]),Ea=m.useCallback((V,q)=>{if(!pe||!re)return;const U={width:q.width,height:q.height,position:{x:q.x,y:q.y}};xe(V,{position:U.position,data:{width:U.width,height:U.height}}),I(null),re.updateNode(V,U).catch(G=>{Ae(V),I(G instanceof Error?G.message:String(G)),console.error("updateNode resize failed",G)})},[pe,re,xe,Ae]),Wt=m.useCallback(V=>{if(!pe||!re)return;const q={autoSize:!0};xe(V,{data:{autoSize:!0,width:void 0,height:void 0}}),I(null),re.updateNode(V,q).catch(U=>{Ae(V),I(U instanceof Error?U.message:String(U)),console.error("updateNode (fit-to-content) failed",U)})},[pe,re,xe,Ae]),Wd=m.useCallback(V=>{if(!pe||!re||V.length===0)return;const q=[];for(const G of V){if(!(ce==null?void 0:ce.find(it=>it.id===G.id)))continue;const He={position:G.position};G.width!==void 0&&(He.width=G.width),G.height!==void 0&&(He.height=G.height),q.push({id:G.id,next:He})}if(q.length===0)return;for(const G of q){const ee={};G.next.width!==void 0&&(ee.width=G.next.width),G.next.height!==void 0&&(ee.height=G.next.height),xe(G.id,{position:G.next.position,...Object.keys(ee).length>0?{data:ee}:{}})}I(null);const U=q.map(G=>G.id).slice().sort().join(",");Be.batch("multi-resize",async()=>{for(const G of q)await re.updateNode(G.id,G.next)},{coalesceKey:`multi:resize:${U}`}).catch(G=>{for(const ee of q)Ae(ee.id);I(G instanceof Error?G.message:String(G)),console.error("updateNode multi-resize batch failed",G)})},[pe,re,Be,ce,xe,Ae]),{setOverride:Et,dropOverride:Yt}=R,Gd=m.useCallback((V,q)=>{xe(V,{data:q})},[xe]),Zd=m.useCallback((V,q)=>{for(const U of V)xe(U,{data:q})},[xe]),Xd=m.useCallback((V,q)=>{Et(V,q)},[Et]),Kd=m.useCallback((V,q)=>{!pe||!re||(jU(Xa,q),xe(V,{data:q}),I(null),re.updateNode(V,q).catch(U=>{Ae(V),I(U instanceof Error?U.message:String(U)),console.error("updateNode style failed",U)}))},[pe,re,xe,Ae]),Yd=m.useCallback((V,q)=>{if(!pe||!re||V.length===0)return;jU(Xa,q);const U=V.filter(G=>ce==null?void 0:ce.some(ee=>ee.id===G));if(U.length!==0){for(const G of U)xe(G,{data:q});I(null),Be.batch("style-nodes",async()=>{for(const G of U)await re.updateNode(G,q)}).catch(G=>{for(const ee of U)Ae(ee);I(G instanceof Error?G.message:String(G)),console.error("updateNode style-nodes batch failed",G)})}},[pe,re,Be,ce,xe,Ae]),Qd=m.useCallback((V,q)=>{!pe||!re||(mDe(Xa,q),Et(V,q),I(null),re.updateConnector(V,q).catch(U=>{Yt(V),I(U instanceof Error?U.message:String(U)),console.error("updateConnector failed",U)}))},[pe,re,Et,Yt]),{mark:qi,markMany:Fi,unmark:Vi,unmarkMany:Bi}=W,{markMany:Vr,unmarkMany:Br}=$,Jd=m.useCallback(V=>{if(!pe||!re||!(ce==null?void 0:ce.find(ee=>ee.id===V)))return;const U=(Ce??[]).filter(ee=>ee.source===V||ee.target===V).map(ee=>ee.id),G=new Set(U);I(null),qi(V),U.length>0&&Vr(U),M(ee=>ee.filter(He=>He!==V)),b(ee=>ee.filter(He=>!G.has(He))),re.deleteNode(V).catch(ee=>{Vi(V),U.length>0&&Br(U),I(ee instanceof Error?ee.message:String(ee)),console.error("deleteNode failed",ee)})},[pe,re,ce,Ce,qi,Vr,Vi,Br]),eu=m.useCallback((V,q)=>{if(!pe||!re||!ce)return;const U=H??ce.map(ee=>ee.id),G=prt(U,V,q);G&&(T(G),I(null),re.reorderNode(V,q).catch(ee=>{T(null),I(ee instanceof Error?ee.message:String(ee)),console.error("reorderNode failed",ee)}))},[pe,re,ce,H]),Te=m.useCallback((V,q)=>{if(!pe||!re||V.length===0&&q.length===0)return;const U=new Set(V),G=V.map(Oe=>ce==null?void 0:ce.find(wn=>wn.id===Oe)).filter(Oe=>!!Oe),ee=(Ce??[]).filter(Oe=>U.has(Oe.source)||U.has(Oe.target)),He=new Set(ee.map(Oe=>Oe.id)),it=q.map(Oe=>Ce==null?void 0:Ce.find(wn=>wn.id===Oe)).filter(Oe=>!!Oe).filter(Oe=>!He.has(Oe.id));if(G.length===0&&ee.length===0&&it.length===0)return;I(null);const ot=G.map(Oe=>Oe.id),ft=[...ee.map(Oe=>Oe.id),...it.map(Oe=>Oe.id)];ot.length>0&&Fi(ot),ft.length>0&&Vr(ft);const Zn=G;M(Oe=>Oe.filter(wn=>!U.has(wn)));const Qr=new Set(it.map(Oe=>Oe.id));b(Oe=>Oe.filter(wn=>!Qr.has(wn)&&!He.has(wn))),Be.batch("delete-selection",async()=>{for(const Oe of Zn)await re.deleteNode(Oe.id);await Promise.all(it.map(Oe=>re.deleteConnector(Oe.id)))}).catch(Oe=>{ot.length>0&&Bi(ot),ft.length>0&&Br(ft),I(Oe instanceof Error?Oe.message:String(Oe)),console.error("deleteSelection batch failed",Oe)})},[pe,re,Be,ce,Ce,Fi,Vr,Bi,Br]);m.useEffect(()=>{P.current=Te},[Te]),m.useEffect(()=>{const V=q=>{if(q.key!=="Delete"&&q.key!=="Backspace"||hr(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const U=S.current,G=j.current;U.length===0&&G.length===0||(q.preventDefault(),Te(U,G))};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[Te]);const $t=m.useCallback((V,q)=>{!pe||!re||(xe(V,{data:{name:q}}),I(null),re.updateNode(V,{name:q}).catch(U=>{I(U instanceof Error?U.message:String(U)),console.error("updateNode name failed",U)}))},[pe,re,xe]),Ur=m.useCallback((V,q)=>{!pe||!re||(xe(V,{data:{description:q}}),I(null),re.updateNode(V,{description:q}).catch(U=>{I(U instanceof Error?U.message:String(U)),console.error("updateNode description failed",U)}))},[pe,re,xe]),Ui=m.useCallback((V,q)=>{!pe||!re||(xe(V,{data:{detail:q}}),I(null),re.updateNode(V,{detail:q}).catch(U=>{I(U instanceof Error?U.message:String(U)),console.error("updateNode detail failed",U)}))},[pe,re,xe]),er=m.useCallback((V,q)=>{!pe||!re||(xe(V,{data:{icon:q??void 0}}),I(null),re.updateNode(V,{icon:q}).catch(U=>{I(U instanceof Error?U.message:String(U)),console.error("updateNode icon failed",U)}))},[pe,re,xe]),tr=m.useCallback((V,q,U)=>{if(!pe||!re)return;I(null);const G=`node-${ia()}`,ee=zU(V,U,_2(Xa).node),He={id:G,type:V,position:q,data:ee};xe(G,{id:G,type:V,position:q,data:ee}),re.createNode(He).catch(ot=>{Ae(G),I(ot instanceof Error?ot.message:String(ot)),console.error("createNode failed",ot)})},[pe,re,xe,Ae]),Wr=m.useCallback((V,q)=>{if(!pe||!re)return;I(null);const U=`node-${ia()}`,G={icon:V,width:v0.width,height:v0.height},ee={id:U,type:"icon",position:q,data:G};xe(U,{id:U,type:"icon",position:q,data:G}),M([U]),re.createNode(ee).catch(it=>{Ae(U),I(it instanceof Error?it.message:String(it)),console.error("createNode (icon) failed",it)})},[pe,re,xe,Ae]),fo=m.useCallback(V=>{if(!pe||!re)return;I(null);const q=`node-${ia()}`,U={id:q,type:"html",position:V.position,data:{}},G={id:q,type:"html",position:V.position,data:{}};xe(q,G),M([q]),re.createNode(U).catch(ee=>{Ae(q),I(ee instanceof Error?ee.message:String(ee)),console.error("createNode (type:'html') failed",ee)})},[pe,re,xe,Ae]),Gn=m.useRef(new Map),hn=m.useCallback((V,q)=>{Gn.current.set(V,q)},[]),Qt=m.useCallback(V=>{Gn.current.delete(V)},[]),po=m.useCallback(V=>{!pe||!re||(I(null),drt({...V,flowId:pe,lastUsed:_2(Xa).node},{upload:async(q,U,G,ee)=>re.uploadImage(U,await zNe(G),ee),createNode:async(q,U)=>{const{id:G}=await re.createNode(U);return{id:G}},setOverride:xe,history:Be,rememberRetry:hn,forgetRetry:Qt}).catch(q=>{console.error("image-upload-flow failed",q)}))},[pe,re,Be,xe,hn,Qt]),Wi=m.useCallback(V=>{if(!pe||!re)return;const q=`node-${ia()}`;po({nodeId:q,...V})},[pe,re,po]),tu=m.useCallback(V=>{const q=Gn.current.get(V);q&&po({nodeId:V,...q})},[po]),[Ao,Gi]=m.useState({open:!1,mode:"insert"}),kt=m.useCallback((V,q)=>{Gi({open:!0,mode:V,nodeId:q})},[]),yo=m.useCallback(()=>{Gi(V=>({...V,open:!1}))},[]),$a=m.useCallback(()=>{kt("insert")},[kt]),Zi=m.useCallback(V=>kt("replace",V),[kt]),Gr=m.useCallback(V=>{if(aDe(V),Ao.mode==="replace"&&Ao.nodeId){if(pe&&re){const q=Ao.nodeId;xe(q,{data:{icon:V}}),I(null),re.updateNode(q,{icon:V}).catch(U=>{Ae(q),I(U instanceof Error?U.message:String(U)),console.error("updateNode (icon replace) failed",U)})}}else{const q=Q.current;if(q&&pe){const U=oDe(q,{width:window.innerWidth,height:window.innerHeight});Wr(V,U)}}yo()},[Ao.mode,Ao.nodeId,pe,re,xe,Ae,Wr,yo]),Zr=m.useCallback((V,q)=>{!pe||!re||(Et(V,{label:q}),I(null),re.updateConnector(V,{label:q}).catch(U=>{I(U instanceof Error?U.message:String(U)),console.error("updateConnector label failed",U)}))},[pe,re,Et]),nu=m.useCallback((V,q,U)=>{if(!pe||!re)return;const G=`conn-${ia()}`,ee=U==null?void 0:U.targetPin,He=_2(Xa).connector,it={id:G,source:V,target:q,sourceHandleAutoPicked:!0,targetHandleAutoPicked:!0,...ee?{targetPin:ee}:{},...He},ot={id:G,source:V,target:q,sourceHandleAutoPicked:!0,targetHandleAutoPicked:!0,...ee?{targetPin:ee}:{},...He};Et(G,it),I(null),re.createConnector(ot).catch(ft=>{Yt(G),I(ft instanceof Error?ft.message:String(ft)),console.error("createConnector failed",ft)})},[pe,re,Et,Yt]),Xi=m.useCallback(({sourceNodeId:V,position:q,shape:U})=>{if(!pe||!re)return;I(null);const G=`node-${ia()}`,ee=`conn-${ia()}`,He=tz[U],it=_2(Xa),ot=zU(U,He,it.node),ft={id:G,type:U,position:q,data:ot},Zn={id:ee,source:V,target:G,sourceHandleAutoPicked:!0,targetHandleAutoPicked:!0,...it.connector};xe(G,{id:G,type:U,position:q,data:ot}),Et(ee,Zn),_(G),Be.batch("create-and-connect",async()=>{await re.createNode(ft),await re.createConnector(Zn)}).catch(Oe=>{Ae(G),Yt(ee),I(Oe instanceof Error?Oe.message:String(Oe)),console.error("createAndConnectFromPane failed",Oe)})},[pe,re,Be,xe,Ae,Et,Yt]),nr=m.useRef(null),[Xr,vn]=m.useState(!1),[or,rr]=m.useState(()=>({canUndo:Be.canUndo,canRedo:Be.canRedo}));m.useEffect(()=>Be.subscribe(rr),[Be]);const Eo=m.useCallback(V=>{if(!ce)return;const q=new Set(V),U=ce.filter(ee=>q.has(ee.id));if(U.length===0)return;const G=(Ce??[]).filter(ee=>q.has(ee.source)&&q.has(ee.target));nr.current=JSON.parse(JSON.stringify({nodes:U,connectors:G})),vn(!0)},[ce,Ce]),xn=m.useCallback(V=>{if(!pe||!re)return;const q=nr.current;if(!q||q.nodes.length===0)return;const{newNodes:U,newConnectors:G}=irt({nodes:q.nodes,connectors:q.connectors,flowPos:V,nodeIdGen:()=>`node-${ia()}`,connectorIdGen:()=>`conn-${ia()}`});for(const ee of U)xe(ee.id,ee);for(const ee of G)Et(ee.id,ee);M(U.map(ee=>ee.id)),b(G.map(ee=>ee.id)),I(null),Be.batch("paste",async()=>{for(const ee of U)await re.createNode({id:ee.id,type:ee.type,position:ee.position,data:ee.data});for(const ee of G)await re.createConnector(ee)}).catch(ee=>{for(const He of U)Ae(He.id);for(const He of G)Yt(He.id);I(ee instanceof Error?ee.message:String(ee)),console.error("paste failed",ee)})},[pe,re,Be,xe,Ae,Et,Yt]);m.useEffect(()=>{const V=q=>{const U=fDe({event:q,isEditableActive:hr(document.activeElement),hasNodes:!!ce&&ce.length>0,hasConnectors:!!Ce&&Ce.length>0,selectedIds:S.current,hasClipboard:!!nr.current});if(U.type!=="noop"&&!(U.type==="copy"||U.type==="paste")){if(q.preventDefault(),U.type==="selectAll"){M((ce??[]).map(G=>G.id)),b((Ce??[]).map(G=>G.id));return}Eo([...U.ids]),xn(null)}};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[ce,Ce,Eo,xn]),m.useEffect(()=>{const V=q=>{const U=dDe(q);if(!U||hr(document.activeElement))return;const G=S.current;if(G.length===0)return;const ee=N.overrides,He=(ce??[]).map(ot=>{var Zn;const ft=((Zn=ee[ot.id])==null?void 0:Zn.position)??ot.position;return{id:ot.id,position:ft}}),it=hDe(U,G,He);if(it.length!==0)if(q.preventDefault(),it.length===1){const ot=it[0];ot&&jn(ot.id,ot.position)}else Nt(it)};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[ce,N.overrides,jn,Nt]),m.useEffect(()=>{const V=q=>{const U=uDe(q);if(!U||hr(document.activeElement))return;q.preventDefault();const G=Q.current;G&&(U==="fit"?G.fitView({padding:.2,duration:200}):U==="in"?G.zoomIn({duration:150}):G.zoomOut({duration:150}))};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[]);const $o=m.useCallback(async V=>{if(!pe||!re||!ce||!re.computeLayout)return;const q=N.overrides,U=Q.current,G=V==="selection"?new Set(S.current):null,ee=G?ce.filter(Fe=>G.has(Fe.id)):ce;if(ee.length<2)return;const He=new Set(ee.map(Fe=>Fe.id)),it=(Ce??[]).filter(Fe=>He.has(Fe.source)&&He.has(Fe.target)),ot=new Map,ft=ee.map(Fe=>{var zn;const Mt=((zn=q[Fe.id])==null?void 0:zn.position)??Fe.position;ot.set(Fe.id,Mt);const Mn=U==null?void 0:U.getInternalNode(Fe.id),go=Mn==null?void 0:Mn.measured,Jr=Fe.data,Qi=(go==null?void 0:go.width)??Jr.width??200,K0=(go==null?void 0:go.height)??Jr.height??120;return{id:Fe.id,type:Fe.type,width:Qi,height:K0}}),Zn=it.map(Fe=>({id:Fe.id,source:Fe.source,target:Fe.target})),Qr=await re.computeLayout(ft,Zn),Oe=new Map;for(const[Fe,Mt]of Object.entries(Qr.nodes))Oe.set(Fe,Mt.position);let wn=Number.POSITIVE_INFINITY,ru=Number.POSITIVE_INFINITY,au=Number.POSITIVE_INFINITY,iu=Number.POSITIVE_INFINITY;for(const Fe of ft){const Mt=ot.get(Fe.id);if(!Mt)continue;Mt.x<wn&&(wn=Mt.x),Mt.y<ru&&(ru=Mt.y);const Mn=Oe.get(Fe.id);Mn&&(Mn.x<au&&(au=Mn.x),Mn.y<iu&&(iu=Mn.y))}const Af=Number.isFinite(wn)&&Number.isFinite(au)?wn-au:0,ER=Number.isFinite(ru)&&Number.isFinite(iu)?ru-iu:0,Yi=[];for(const Fe of ft){const Mt=ot.get(Fe.id),Mn=Oe.get(Fe.id);if(!Mt||!Mn)continue;const go={x:Mn.x+Af,y:Mn.y+ER},Jr=go.x-Mt.x,Qi=go.y-Mt.y;Math.abs(Jr)<1&&Math.abs(Qi)<1||Yi.push({id:Fe.id,prev:Mt,next:go})}if(Yi.length!==0){I(null);for(const Fe of Yi)xe(Fe.id,{position:Fe.next});Be.batch("tidy",async()=>{for(const Fe of Yi)await re.updateNodePosition(Fe.id,Fe.next)}).catch(Fe=>{for(const Mt of Yi)Ae(Mt.id);I(Fe instanceof Error?Fe.message:String(Fe)),console.error("Tidy batch failed",Fe)})}},[pe,re,Be,ce,Ce,N.overrides,xe,Ae]);m.useEffect(()=>{const V=q=>{if(!(q.metaKey||q.ctrlKey)||!q.shiftKey||q.altKey||q.key.toLowerCase()!=="l"||hr(document.activeElement))return;q.preventDefault();const U=S.current.length>0?"selection":"all";$o(U)};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[$o]);const ja=m.useCallback(()=>{const V=S.current.length>0?"selection":"all";$o(V)},[$o]);m.useEffect(()=>{const V=q=>{if(hr(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const U=yDe(q);if(U===null)return;const G=F.current;if(U==="select"){G.kind!=="select"&&L({kind:"select"});return}if(U==="hand"){L(G.kind==="hand"?{kind:"select"}:{kind:"hand"});return}if(G.kind==="draw"&&G.shape===U){L({kind:"select"});return}L({kind:"draw",shape:U})};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[]),m.useEffect(()=>{const V=q=>{if(q.key!=="Escape"||hr(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;if(F.current.kind!=="select"){L({kind:"select"});return}S.current.length>0&&M([]),j.current.length>0&&b([])};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[]),m.useEffect(()=>{const V=q=>{if(q.key.toLowerCase()!=="f"||q.metaKey||q.ctrlKey||q.shiftKey||q.altKey||hr(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const U=S.current;if(U.length===0)return;const G=Q.current;G&&G.fitView({nodes:U.map(ee=>({id:ee})),padding:.2,duration:200})};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[]),m.useEffect(()=>{const V=q=>{if(q.key!=="1"||q.metaKey||q.ctrlKey||q.shiftKey||q.altKey||hr(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const U=Q.current;if(!U)return;const{x:G,y:ee}=U.getViewport();U.setViewport({x:G,y:ee,zoom:1},{duration:150})};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[]);const Pn=m.useCallback(V=>{var q,U;switch(V){case"tool.select":L({kind:"select"});return;case"tool.hand":L({kind:"hand"});return;case"tool.rectangle":L({kind:"draw",shape:"rectangle"});return;case"tool.ellipse":L({kind:"draw",shape:"ellipse"});return;case"tool.text":L({kind:"draw",shape:"text"});return;case"tool.sticky":L({kind:"draw",shape:"sticky"});return;case"tool.database":L({kind:"draw",shape:"database"});return;case"edit.undo":{if(!Be.canUndo)return;Be.undo().catch(G=>{I(G instanceof Error?G.message:String(G)),console.error("undo failed",G)});return}case"edit.redo":{if(!Be.canRedo)return;Be.redo().catch(G=>{I(G instanceof Error?G.message:String(G)),console.error("redo failed",G)});return}case"edit.copy":{const G=S.current;if(G.length===0)return;Eo([...G]);return}case"edit.paste":xn(null);return;case"edit.duplicate":{const G=S.current;if(G.length===0)return;Eo([...G]),xn(null);return}case"edit.delete":{const G=S.current,ee=j.current;if(G.length===0&&ee.length===0)return;Te([...G],[...ee]);return}case"edit.selectAll":M((ce??[]).map(G=>G.id)),b((Ce??[]).map(G=>G.id));return;case"view.fit":{const G=Q.current;if(!G)return;G.fitView({padding:.2,duration:200});return}case"view.zoomIn":{const G=Q.current;if(!G)return;G.zoomIn({duration:150});return}case"view.zoomOut":{const G=Q.current;if(!G)return;G.zoomOut({duration:150});return}case"view.zoom100":{const G=Q.current;if(!G)return;const{x:ee,y:He}=G.getViewport();G.setViewport({x:ee,y:He,zoom:1},{duration:150});return}case"view.zoomToSelection":{const G=S.current;if(G.length===0)return;const ee=Q.current;if(!ee)return;ee.fitView({nodes:G.map(He=>({id:He})),padding:.2,duration:200});return}case"layout.tidy":{const G=S.current.length>0?"selection":"all";$o(G);return}case"selection.deselect":S.current.length>0&&M([]),j.current.length>0&&b([]),F.current.kind!=="select"&&L({kind:"select"});return;case"help.commandPalette":E(!0);return;case"export.pdf":{(q=A.current)==null||q.exportPdf();return}case"export.png":{(U=A.current)==null||U.exportPng();return}}},[Be,Eo,xn,Te,ce,Ce,$o]);m.useEffect(()=>{const V=q=>{(q.metaKey||q.ctrlKey)&&(q.shiftKey||q.altKey||q.key.toLowerCase()==="p"&&(q.preventDefault(),!hr(document.activeElement)&&Pn("help.commandPalette")))};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[Pn]);const Pa=m.useCallback((V,q)=>{if(!pe||!re)return;const U={...q.source!==void 0?{source:q.source}:{},...q.target!==void 0?{target:q.target}:{},...q.sourceHandle!==void 0?{sourceHandle:q.sourceHandle===null?void 0:q.sourceHandle}:{},...q.targetHandle!==void 0?{targetHandle:q.targetHandle===null?void 0:q.targetHandle}:{},...q.sourceHandleAutoPicked!==void 0?{sourceHandleAutoPicked:q.sourceHandleAutoPicked}:{},...q.targetHandleAutoPicked!==void 0?{targetHandleAutoPicked:q.targetHandleAutoPicked}:{},...q.sourcePin!==void 0?{sourcePin:q.sourcePin===null?void 0:q.sourcePin}:{},...q.targetPin!==void 0?{targetPin:q.targetPin===null?void 0:q.targetPin}:{}};Et(V,U),I(null),re.updateConnector(V,q).catch(G=>{Yt(V),I(G instanceof Error?G.message:String(G)),console.error("updateConnector reconnect failed",G)})},[pe,re,Et,Yt]),ar=m.useCallback((V,q,U)=>{if(!pe||!re)return;const G=q==="source"?"sourcePin":"targetPin";Et(V,{[G]:U}),I(null),re.updateConnector(V,{[G]:U}).catch(ee=>{Yt(V),I(ee instanceof Error?ee.message:String(ee)),console.error("updateConnector pin failed",ee)})},[pe,re,Et,Yt]),za=m.useCallback((V,q)=>{if(!pe||!re)return;const U=Ce==null?void 0:Ce.find(He=>He.id===V);if(!(U?q==="source"?U.sourcePin:U.targetPin:void 0))return;const ee=q==="source"?"sourcePin":"targetPin";Et(V,{[ee]:void 0}),I(null),re.updateConnector(V,{[ee]:null}).catch(He=>{Yt(V),I(He instanceof Error?He.message:String(He)),console.error("updateConnector unpin failed",He)})},[pe,re,Ce,Et,Yt]),ct=r==null?void 0:r.flow,Ra=N.overrides,ir=R.overrides,mo=W.ids,Kr=$.ids,Ta=m.useMemo(()=>{if(!ct||v.length===0)return[];const V=new Map(ct.nodes.map(U=>[U.id,U])),q=[];for(const U of v){const G=V.get(U);if(!G)continue;const ee=Ra[U];if(!ee){q.push(G);continue}const He=ee.data?{...G.data,...ee.data}:G.data;q.push({...G,...ee,data:He})}return q},[ct,v,Ra]),ou=m.useMemo(()=>{if(!ct||w.length===0)return[];const V=new Map(ct.connectors.map(U=>[U.id,U])),q=[];for(const U of w){const G=V.get(U);if(!G)continue;const ee=ir[U];q.push(ee?{...G,...ee}:G)}return q},[ct,w,ir]),Nf=m.useMemo(()=>{if(!ct)return null;if(!H)return ct.nodes;const V=new Map(ct.nodes.map(G=>[G.id,G])),q=[],U=new Set;for(const G of H){const ee=V.get(G);ee&&(q.push(ee),U.add(G))}for(const G of ct.nodes)U.has(G.id)||q.push(G);return q},[ct,H]),NR=m.useMemo(()=>{const V=Nf??(ct==null?void 0:ct.nodes)??null;return V?mo.size===0?V:V.filter(q=>!mo.has(q.id)):null},[Nf,ct,mo]),AR=m.useMemo(()=>{const V=(ct==null?void 0:ct.connectors)??null;return V?Kr.size===0&&mo.size===0?V:V.filter(q=>!Kr.has(q.id)&&!mo.has(q.source)&&!mo.has(q.target)):null},[ct,Kr,mo]),Yr=(y==null?void 0:y.some(V=>V.flowSlug===t))??!1;if(!f&&!Yr&&!(y===null))return p.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[p.jsxs("p",{className:"text-sm font-medium",children:["Unknown demo: ",n]}),p.jsx("p",{className:"text-xs text-muted-foreground",children:"The slug may have been removed. Re-register from the project repo to bring it back."})]});if(!f||a&&!r)return p.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:"Loading demo…"});const G0=v[0],Da=G0?c[G0]:void 0;return p.jsxs("div",{className:"relative h-full w-full",children:[r&&!r.valid?p.jsxs("div",{"data-testid":"demo-error-banner",className:"absolute inset-x-0 top-0 z-10 border-b border-rose-500/40 bg-rose-50 px-4 py-2 text-xs text-rose-900 shadow-xs dark:bg-rose-950/40 dark:text-rose-100",children:[p.jsx("span",{className:"font-medium uppercase tracking-wide",children:"Invalid demo: "}),p.jsx("span",{className:"font-mono",children:r.error})]}):null,p.jsx(Zot,{open:je,onOpenChange:Ue,onCreate:g,onCreated:async V=>{await u(),K.current.add(`${e}/${V.flowSlug}`),Nr(di(e,V.flowSlug))}}),p.jsx(Kot,{open:Ke!==null,onOpenChange:V=>{V||Bt(null)},flow:Ke,onRename:k,onRenamed:async(V,q)=>{await u(),V.flowSlug!==q&&(K.current.add(`${e}/${V.flowSlug}`),Nr(di(e,V.flowSlug)))}}),p.jsx(Xot,{open:un!==null,onOpenChange:V=>{V||Ut(null)},flow:un,flows:y??[],onDelete:x,onDeleted:async(V,q)=>{var G;if(await u(),V!==t)return;const U=q??((G=y==null?void 0:y.find(ee=>ee.isDefault&&ee.flowSlug!==V))==null?void 0:G.flowSlug);U&&Nr(di(e,U))}}),ct&&re?p.jsx(vnt,{ref:A,mode:"edit",adapter:re,history:Be,topRightSlot:p.jsx(Yot,{project:e,activeFlow:t,flows:y??[],onSelect:V=>{V!==t&&Nr(di(e,V))},onCreate:()=>Ue(!0),onRename:V=>{const q=y==null?void 0:y.find(U=>U.flowSlug===V);q&&Bt({flowSlug:q.flowSlug,name:q.name,icon:q.icon})},onDelete:V=>{const q=y==null?void 0:y.find(U=>U.flowSlug===V);q&&Ut({flowSlug:q.flowSlug,name:q.name,isDefault:q.isDefault})}}),projectId:e,flowSlug:t,enableEmbed:!1,onExportToCloud:pe?()=>ue(!0):void 0,nodes:NR??ct.nodes,connectors:AR??ct.connectors,selectedNodeIds:v,selectedConnectorIds:w,onSelectionChange:ve,runtime:{runs:i,statuses:c,pendingOverrides:{nodes:Ra,connectors:ir}},onPlayNode:h,onNodePositionChange:jn,onNodePositionsChange:Nt,onNodeResize:ho,onNodeResizeEnd:Ea,onHtmlNodeFitToContent:Wt,onComponentNodeFitToContent:Wt,onMultiResize:Wd,onNodeNameChange:$t,onNodeDescriptionChange:Ur,onConnectorLabelChange:Zr,onCreateShapeNode:tr,onCreateImageFromFile:pe?Wi:void 0,onRetryImageUpload:pe?tu:void 0,onCreateHtmlNode:pe?fo:void 0,iconPickerOpen:Ao.open,onOpenIconPicker:pe?$a:void 0,onCloseIconPicker:pe?yo:void 0,onPickIcon:pe?Gr:void 0,onRequestIconReplace:pe?Zi:void 0,onCreateConnector:nu,onReconnectConnector:Pa,onPinEndpoint:pe?ar:void 0,onUnpinEndpoint:pe?za:void 0,onReorderNode:eu,onDeleteNode:Jd,onCopyNode:V=>Eo([V]),onPasteAt:xn,onCopySelection:pe?Eo:void 0,onPasteSelection:pe?()=>xn(null):void 0,hasClipboard:Xr,selectedNodes:Ta,selectedConnectors:ou,onStyleNode:Kd,onStyleNodePreview:Gd,onStyleNodes:Yd,onStyleNodesPreview:Zd,onStyleConnector:Qd,onStyleConnectorPreview:Xd,onRfInit:te,onTidy:ce?ja:void 0,onCreateAndConnectFromPane:Xi,pendingEditNodeId:C,canvasMode:z,onCanvasModeChange:L,statusReport:Da,onNameChange:$t,onDescriptionChange:Ur,onDetailChange:Ui,onIconChange:er,autoFitView:Y},`${e}/${t}`):p.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:"No demo data yet."}),O?p.jsxs("div",{"data-testid":"edit-error-banner",className:"absolute inset-x-0 bottom-4 z-20 mx-auto w-fit max-w-[80%] rounded-md border border-rose-500/50 bg-rose-50 px-3 py-2 text-xs text-rose-900 shadow-md dark:bg-rose-950/60 dark:text-rose-100",children:[p.jsx("span",{className:"font-medium",children:"Couldn't save change: "}),p.jsx("span",{className:"font-mono",children:O}),p.jsx("button",{type:"button",className:"ml-3 underline underline-offset-2",onClick:()=>I(null),children:"Dismiss"})]}):null,p.jsx(yot,{open:D,onOpenChange:E,runCommand:Pn,ctx:{hasSelection:v.length>0||w.length>0,canUndo:or.canUndo,canRedo:or.canRedo,hasClipboard:Xr,canExportDemo:!!pe}}),pe?p.jsx(Bot,{open:J,onOpenChange:ue,project:e,flowName:(r==null?void 0:r.name)??f.name,onCapturePreview:()=>{var V;return((V=A.current)==null?void 0:V.capturePreview())??Promise.resolve(void 0)}}):null]})}const EZ="npx seeflow register --path .";function mrt(){const[e,t]=m.useState(!1),n=async()=>{try{await navigator.clipboard.writeText(EZ),t(!0),setTimeout(()=>t(!1),1200)}catch(o){console.error("[empty-state] copy failed",o)}};return p.jsx("div",{"data-testid":"seeflow-empty-state",className:"flex h-full w-full items-center justify-center bg-background p-6",children:p.jsxs("div",{className:"flex max-w-lg flex-col items-center gap-6 text-center",children:[p.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-muted",children:p.jsx(znt,{className:"h-6 w-6 text-muted-foreground"})}),p.jsxs("div",{className:"space-y-2",children:[p.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-foreground",children:"No demos registered yet"}),p.jsxs("p",{className:"text-sm text-muted-foreground",children:["Point SeeFlow at any folder containing a"," ",p.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 text-xs",children:"flow.json"})," file and it'll appear here."]})]}),p.jsxs("div",{className:"flex w-full items-center gap-2 rounded-md border border-border bg-card px-3 py-2 font-mono text-sm",children:[p.jsx("span",{className:"text-muted-foreground select-none",children:"$"}),p.jsx("code",{className:"flex-1 truncate text-left",children:EZ}),p.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:n,"aria-label":"Copy register command",children:e?p.jsx(_re,{className:"h-4 w-4"}):p.jsx(Sre,{className:"h-4 w-4"})})]})]})})}function grt({demos:e}){return e.length===0?p.jsx(mrt,{}):p.jsx("div",{className:"flex h-full w-full items-start justify-center overflow-y-auto bg-background p-8",children:p.jsxs("div",{"data-testid":"studio-home-picker",className:"flex w-full max-w-2xl flex-col gap-6 pt-8",children:[p.jsxs("div",{className:"space-y-1",children:[p.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Open a demo"}),p.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.length," demos registered — pick one to load its canvas."]})]}),p.jsx("ul",{className:"flex flex-col gap-2",children:e.map(t=>p.jsx("li",{children:p.jsxs("button",{type:"button",onClick:()=>Nr(Mre(t.slug)),"data-testid":`studio-home-demo-${t.slug}`,className:"flex w-full flex-col items-start gap-0.5 rounded-lg border border-border bg-card px-4 py-3 text-left transition-colors hover:border-input",style:{boxShadow:"var(--shadow-card)"},children:[p.jsx("span",{className:"text-sm font-medium",children:t.name}),p.jsx("span",{className:"truncate text-xs text-muted-foreground",children:t.repoPath})]})},t.id))})]})})}function krt(){const e=Cnt(),{demos:t,refresh:n}=Xnt(),{projects:o,refresh:r,unregisterProject:a}=iot(),i=Snt(e),s=(i==null?void 0:i.project)??null,c=(i==null?void 0:i.flow)??null,l=Lnt(e),h=(l==null?void 0:l.project)??null,{flows:u}=BF(h);sot({onRegistryReload:()=>{n(),r()}});const f=i?`${i.project}/${i.flow}`:null,y=f?(t??[]).find(I=>I.slug===f):void 0,g=(y==null?void 0:y.id)??null;m.useEffect(()=>{f&&t!==null&&(y||n())},[f,t,y,n]);const{detail:k,loading:x,refresh:v,applyDetail:M}=Znt(s,c),[w,b]=m.useState(0),{runs:C,apply:_}=tot(g),{events:S,apply:j}=Jnt(g),{statusByNode:P,apply:A,reset:N}=aot(g),R=m.useCallback(()=>{N(),v(),n()},[v,n,N]),W=m.useCallback(I=>{if(!g||!y)return;const z={id:g,slug:y.slug,filePath:""},L=I.valid?{...z,name:I.flow.name??y.name,flow:I.flow,valid:!0,error:null}:{...z,name:y.name,flow:null,valid:!1,error:I.error};M(L),b(F=>F+1)},[g,y,M]),$=m.useCallback(I=>{_(I),j(I),A(I)},[_,j,A]);cot(g,{onHello:R,onFlowReload:W,onEvent:$});const H=m.useCallback(I=>{mZ(I.id),n(),r()},[n,r]),T=m.useCallback(async I=>{await a(I),await n(),s===I&&Nr("/")},[a,n,s]);m.useEffect(()=>{if(e!=="/"||t===null)return;const I=uot(t,dot());I&&Nr(Mre(I.slug))},[e,t]),m.useEffect(()=>{y&&mZ(y.id)},[y]),m.useEffect(()=>{s&&c&&Mnt(s,c)},[s,c]),m.useEffect(()=>{if(!h||!u)return;const I=bnt(u,wre(h));I&&Nr(di(h,I))},[h,u]);const O=m.useCallback(I=>{!s||!c||sce(s,c,I).catch(z=>{_({type:"node:error",nodeId:I,message:z instanceof Error?z.message:String(z),ts:Date.now()})})},[s,c,_]);return t===null?p.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background text-sm text-muted-foreground",children:"Loading…"}):p.jsx(dh,{delayDuration:150,children:p.jsxs("div",{className:"flex h-full w-full flex-col bg-background text-foreground",children:[p.jsx(Gnt,{projects:o??[],currentProjectSlug:s??void 0,onProjectCreated:H,onUnregisterProject:T}),p.jsx("main",{className:"min-h-0 flex-1",children:s&&c&&f?p.jsx(yrt,{project:s,flow:c,slug:f,demos:t,detail:k,loading:x,runs:C,nodeEvents:S,statusByNode:P,externalReloadSignal:w,onPlayNode:O,refreshFlows:n}):p.jsx(grt,{demos:t})})]})})}const Wre=document.getElementById("root");if(!Wre)throw new Error("Root element #root not found");uD.createRoot(Wre).render(p.jsx(br.StrictMode,{children:p.jsx(krt,{})}));export{af as C,WYe as M,br as R,hf as _,On as a,QK as b,jG as c,sP as d,gq as e,vY as f,SGe as g,Qh as h,NGe as i,vrt as j,sh as k,_r as l,p as m,MY as n,aet as o,d$e as p,pGe as q,m as r,eo as s,AGe as t,_F as u,vGe as w,Mrt as z};
|
|
8624
|
+
*/const Rnt=No("Workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]);function Tnt({projects:e,currentProjectSlug:t,onProjectCreated:n,onUnregisterProject:o}){const[r,a]=m.useState(!1),[i,s]=m.useState(!1),[c,l]=m.useState(null),[h,u]=m.useState(!1),[f,y]=m.useState(null);m.useEffect(()=>{const C=_=>{_.key==="k"&&(_.metaKey||_.ctrlKey)&&(_.preventDefault(),a(S=>!S))};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[]);const g=e.find(C=>C.projectSlug===t),k=C=>{const S=wre(C.projectSlug)??C.defaultFlow;Nr(di(C.projectSlug,S))},x=C=>{n==null||n(C)},v=C=>{l(C),y(null)},M=()=>{h||(l(null),y(null))},w=async()=>{if(c){u(!0),y(null);try{await(o==null?void 0:o(c.projectSlug)),l(null)}catch(C){y(C instanceof Error?C.message:String(C))}finally{u(!1)}}},b=(c==null?void 0:c.flowCount)??0;return p.jsxs(p.Fragment,{children:[p.jsxs(Dd,{open:r,onOpenChange:a,children:[p.jsx(V0,{asChild:!0,children:p.jsxs(ut,{type:"button",variant:"outline",size:"sm","aria-label":"Switch project","aria-expanded":r,className:"gap-2","data-testid":"project-switcher-trigger",children:[p.jsx("span",{className:"max-w-[180px] truncate text-sm",children:(g==null?void 0:g.name)??"Select project"}),p.jsx(ote,{children:"⌘K"}),p.jsx(Cre,{className:"h-3.5 w-3.5 opacity-60"})]})}),p.jsx(zi,{align:"end",sideOffset:6,className:"w-[320px] p-0","data-testid":"project-switcher-popover",children:p.jsxs(sF,{children:[p.jsx(nte,{placeholder:"Search projects..."}),p.jsxs(cF,{children:[p.jsx(lF,{children:"No projects."}),e.length>0?p.jsx(Bh,{heading:"Projects",children:e.map(C=>p.jsxs(Uh,{value:`${C.name} ${C.projectSlug}`,onSelect:()=>{a(!1),k(C)},"data-testid":`project-switcher-row-${C.projectSlug}`,className:"group flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-0.5",children:[p.jsx("span",{className:"font-medium",children:C.name}),C.repoPath?p.jsx("span",{className:"w-full truncate text-xs text-muted-foreground",children:C.repoPath}):null]}),p.jsx("button",{type:"button","aria-label":`Unregister ${C.name}`,"data-testid":`project-switcher-unregister-${C.projectSlug}`,className:"shrink-0 rounded p-0.5 opacity-0 transition-opacity hover:text-destructive group-hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring",onClick:_=>{_.stopPropagation(),a(!1),v(C)},children:p.jsx(Ire,{className:"h-3.5 w-3.5"})})]},C.projectSlug))}):null,e.length>0?p.jsx(dF,{}):null,p.jsx(Bh,{children:p.jsxs(Uh,{value:"+ create new project",onSelect:()=>{a(!1),s(!0)},"data-testid":"project-switcher-create",className:"flex items-center gap-2 text-sm",children:[p.jsx(Lre,{className:"h-4 w-4 opacity-70"}),p.jsx("span",{className:"font-medium",children:"Create new project"})]})})]})]})})]}),p.jsx(xnt,{open:i,onOpenChange:s,onCreated:x}),p.jsx(Ca,{open:c!==null,onOpenChange:C=>{C||M()},children:p.jsxs(Ri,{className:"sm:max-w-md","data-testid":"unregister-project-dialog",children:[p.jsxs(Ti,{children:[p.jsx(Di,{children:"Unregister project?"}),p.jsxs(Hi,{children:["This removes ",p.jsx("strong",{children:c==null?void 0:c.name})," from SeeFlow."," ",p.jsxs("strong",{children:["All ",b," ",b===1?"flow":"flows"]})," ","under this project will be unregistered.",c!=null&&c.repoPath?p.jsxs(p.Fragment,{children:[" ","Your files at ",p.jsx("code",{className:"text-xs",children:c.repoPath})," will not be deleted."]}):null]})]}),f?p.jsx("div",{role:"alert","data-testid":"unregister-project-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:f}):null,p.jsxs(Sa,{children:[p.jsx(ut,{type:"button",variant:"ghost",onClick:M,disabled:h,children:"Cancel"}),p.jsx(ut,{type:"button",variant:"destructive",onClick:w,disabled:h,"data-testid":"unregister-project-confirm",children:h?"Unregistering…":"Unregister"})]})]})})]})}const Nre="seeflow:theme",pZ="(prefers-color-scheme: dark)";function Dnt(e){return e==="light"||e==="dark"||e==="system"}function Hnt(e){try{const t=e.getItem(Nre);return Dnt(t)?t:"system"}catch{return"system"}}function Ont(e){try{const t=new URLSearchParams(e);if(!t.has("theme"))return null;const n=t.get("theme");return n==="light"||n==="dark"?n:"light"}catch{return null}}function qnt(e,t){try{e.setItem(Nre,t)}catch{}}function Fnt(e,t){return e==="system"?t?"dark":"light":e}function Vnt(e,t){t==="dark"?(e.classList.add("dark"),e.classList.remove("light")):(e.classList.add("light"),e.classList.remove("dark"))}function Bnt(e,t){var o;const n=r=>t(r.matches);return e.addEventListener?(e.addEventListener("change",n),()=>{var r;return(r=e.removeEventListener)==null?void 0:r.call(e,"change",n)}):((o=e.addListener)==null||o.call(e,n),()=>{var r;return(r=e.removeListener)==null?void 0:r.call(e,n)})}function Unt(){const[e,t]=m.useState(()=>{if(typeof window>"u")return"system";const i=Ont(window.location.search);return i||Hnt(window.localStorage)}),[n,o]=m.useState(()=>typeof window>"u"?!1:window.matchMedia(pZ).matches);m.useEffect(()=>{if(typeof window>"u")return;const i=window.matchMedia(pZ);return Bnt(i,o)},[]);const r=Fnt(e,n);m.useEffect(()=>{typeof document>"u"||Vnt(document.documentElement,r)},[r]);const a=m.useCallback(i=>{typeof window<"u"&&qnt(window.localStorage,i),t(i)},[]);return{theme:e,setTheme:a,resolvedTheme:r}}const Wnt=[{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"system",label:"System"}];function Gnt({projects:e,currentProjectSlug:t,onProjectCreated:n,onUnregisterProject:o}){const{theme:r,setTheme:a}=Unt();return p.jsxs("header",{className:"relative flex h-14 shrink-0 items-center justify-between bg-background/85 px-5 backdrop-blur-md shadow-[0_1px_3px_-1px_rgba(15,23,42,0.06),0_2px_8px_-4px_rgba(15,23,42,0.05)] dark:shadow-[0_4px_12px_-6px_rgba(0,0,0,0.6)]",children:[p.jsxs("button",{type:"button",onClick:()=>Nr("/"),className:"-ml-1.5 flex items-center gap-2 rounded-md px-1.5 py-1 text-base font-bold tracking-tight transition-colors hover:bg-muted/60",children:[p.jsx(Rnt,{size:18,strokeWidth:2.25,className:"text-emerald-400"}),"SeeFlow",p.jsxs("span",{className:"ml-1 text-[10px] font-normal tracking-normal text-muted-foreground/70",children:["v","0.1.98"]})]}),p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx(Tnt,{projects:e,currentProjectSlug:t,onProjectCreated:n,onUnregisterProject:o}),p.jsxs(Cne,{children:[p.jsx(Sne,{asChild:!0,children:p.jsx(ut,{type:"button",variant:"outline",size:"icon","aria-label":"Settings","data-testid":"settings-trigger",children:p.jsx(jnt,{className:"h-4 w-4"})})}),p.jsxs(vF,{align:"end",sideOffset:6,className:"w-44","data-testid":"settings-menu",children:[p.jsx(Lne,{children:"Theme"}),p.jsx(AWe,{value:r,onValueChange:i=>a(i),children:Wnt.map(i=>p.jsx(Ine,{value:i.value,"data-testid":`theme-${i.value}`,children:i.label},i.value))})]})]})]})]})}const Znt=(e,t)=>{const n=e!==null&&t!==null,[o,r]=m.useState(null),[a,i]=m.useState(n),[s,c]=m.useState(null),l=m.useCallback(()=>{!e||!t||(i(!0),oce(e,t).then(u=>{r(u),c(null)}).catch(u=>{console.error("[useDemoData] failed",u),c(String(u))}).finally(()=>i(!1)))},[e,t]),h=m.useCallback(u=>{r(u),c(null)},[]);return m.useEffect(()=>{if(!e||!t){r(null),i(!1);return}l()},[e,t,l]),{detail:o,loading:a,error:s,refresh:l,applyDetail:h}},Xnt=()=>{const[e,t]=m.useState(null),[n,o]=m.useState(null),r=m.useCallback(()=>tce().then(a=>{t(a),o(null)}).catch(a=>{console.error("[useDemos] failed",a),t([]),o(String(a))}),[]);return m.useEffect(()=>{r()},[r]),{demos:e,error:n,refresh:r}},Knt=5,Ynt={"node:running":"running","node:done":"done","node:error":"error"},Qnt=(e,t)=>{if(t.type==="reset")return{};const n=e[t.nodeId]??[],o=[t.entry,...n].slice(0,Knt);return{...e,[t.nodeId]:o}},Jnt=e=>{const[t,n]=m.useReducer(Qnt,{}),o=m.useRef(n);o.current=n,m.useEffect(()=>{o.current({type:"reset"})},[e]);const r=m.useCallback(i=>{const s=Ynt[i.type];if(!s)return;const c=typeof i.nodeId=="string"?i.nodeId:null;if(!c)return;const l=typeof i.runId=="string"?i.runId:void 0,h=typeof i.ts=="number"?i.ts:Date.now();o.current({type:"append",nodeId:c,entry:{status:s,ts:h,runId:l}})},[]),a=m.useCallback(()=>{o.current({type:"reset"})},[]);return{events:t,apply:r,reset:a}},eot=(e,t)=>{var n,o;switch(t.type){case"reset":return{};case"running":return{...e,[t.nodeId]:{status:"running",runId:t.runId,ts:t.ts??Date.now()}};case"done":return{...e,[t.nodeId]:{...e[t.nodeId],status:"done",runId:t.runId??((n=e[t.nodeId])==null?void 0:n.runId),responseStatus:t.responseStatus,body:t.body,ts:t.ts??Date.now()}};case"error":return{...e,[t.nodeId]:{...e[t.nodeId],status:"error",runId:t.runId??((o=e[t.nodeId])==null?void 0:o.runId),error:t.message,ts:t.ts??Date.now()}}}},tot=e=>{const[t,n]=m.useReducer(eot,{}),o=m.useRef(n);o.current=n,m.useEffect(()=>{o.current({type:"reset"})},[e]);const r=m.useCallback(i=>{const s=typeof i.nodeId=="string"?i.nodeId:null;if(!s)return;const c=typeof i.runId=="string"?i.runId:void 0;if(i.type==="node:running"){o.current({type:"running",nodeId:s,runId:c,ts:i.ts});return}if(i.type==="node:done"){const l=typeof i.status=="number"?i.status:void 0;o.current({type:"done",nodeId:s,runId:c,responseStatus:l,body:i.body,ts:i.ts});return}if(i.type==="node:error"){const l=typeof i.message=="string"?i.message:void 0;o.current({type:"error",nodeId:s,runId:c,message:l,ts:i.ts})}},[]),a=m.useCallback(()=>{o.current({type:"reset"})},[]);return{runs:t,apply:r,reset:a}},not=new Set(["ok","warn","error","pending"]),oot=(e,t)=>{if(t.type!=="node:status")return e;const n=typeof t.nodeId=="string"?t.nodeId:null;if(!n||typeof t.state!="string"||!not.has(t.state))return e;const o=typeof t.summary=="string"?t.summary:void 0,r=typeof t.detail=="string"?t.detail:void 0,a=t.data&&typeof t.data=="object"&&!Array.isArray(t.data)?t.data:void 0,i=typeof t.ts=="number"?t.ts:Date.now();return{...e,[n]:{state:t.state,summary:o,detail:r,data:a,ts:i}}},rot=(e,t)=>{switch(t.type){case"reset":return{};case"event":return oot(e,t.event)}},aot=e=>{const[t,n]=m.useReducer(rot,{}),o=m.useRef(n);o.current=n,m.useEffect(()=>{o.current({type:"reset"})},[e]);const r=m.useCallback(i=>{o.current({type:"event",event:i})},[]),a=m.useCallback(()=>{o.current({type:"reset"})},[]);return{statusByNode:t,apply:r,reset:a}},BF=e=>{const t=e!==null,[n,o]=m.useState(null),[r,a]=m.useState(t),[i,s]=m.useState(null),c=m.useCallback(()=>{e&&(a(!0),s(null),BK(e).then(f=>{o(f),s(null)}).catch(f=>{console.error("[useProjectFlows] failed",f),o([]),s(String(f))}).finally(()=>a(!1)))},[e]);m.useEffect(()=>{if(!e){o(null),a(!1),s(null);return}c()},[e,c]);const l=m.useCallback(async f=>{if(!e)throw new Error("no-project");const y=await rce(e,f);return c(),y},[e,c]),h=m.useCallback(async(f,y)=>{if(!e)throw new Error("no-project");const g=await ace(e,f,y);return c(),g},[e,c]),u=m.useCallback(async(f,y)=>{if(!e)throw new Error("no-project");const g=await UK(e,f,y);return c(),g},[e,c]);return{flows:n,loading:r,error:i,refresh:c,createFlow:l,renameFlow:h,deleteFlow:u}},iot=()=>{const[e,t]=m.useState(null),[n,o]=m.useState(!0),[r,a]=m.useState(null),i=m.useCallback(()=>(o(!0),nce().then(c=>{t(c),a(null)}).catch(c=>{console.error("[useProjects] failed",c),t([]),a(String(c))}).finally(()=>o(!1))),[]);m.useEffect(()=>{i()},[i]);const s=m.useCallback(async c=>{const h=[...await BK(c)].sort((u,f)=>u.isDefault===f.isDefault?0:u.isDefault?1:-1);for(const u of h)await UK(c,u.flowSlug);await i()},[i]);return{projects:e,loading:n,error:r,refresh:i,unregisterProject:s}},sot=(e={})=>{const[t,n]=m.useState(!1),{onRegistryReload:o,onHello:r}=e,a=m.useRef(o),i=m.useRef(r);return m.useEffect(()=>{a.current=o,i.current=r},[o,r]),m.useEffect(()=>{const s=new EventSource("/api/registry/events");return s.addEventListener("open",()=>n(!0)),s.addEventListener("error",()=>n(!1)),s.addEventListener("hello",()=>{var c;(c=i.current)==null||c.call(i)}),s.addEventListener("registry:reload",()=>{var c;(c=a.current)==null||c.call(a)}),()=>{s.close()}},[]),{connected:t}},cot=(e,t={})=>{const[n,o]=m.useState(!1),{onHello:r,onFlowReload:a,onEvent:i}=t,s=m.useRef(r),c=m.useRef(a),l=m.useRef(i);return m.useEffect(()=>{s.current=r,c.current=a,l.current=i},[r,a,i]),m.useEffect(()=>{if(!e){o(!1);return}const h=`/api/events?flowId=${encodeURIComponent(e)}`,u=new EventSource(h);u.addEventListener("open",()=>o(!0)),u.addEventListener("error",()=>o(!1)),u.addEventListener("hello",()=>{var f;(f=s.current)==null||f.call(s)}),u.addEventListener("flow:reload",f=>{var k,x;const y=yZ(f,"flow:reload");(k=l.current)==null||k.call(l,y);const g=lot(y);g&&((x=c.current)==null||x.call(c,g))});for(const f of["node:running","node:done","node:error","node:status"])u.addEventListener(f,y=>{var g;(g=l.current)==null||g.call(l,yZ(y,f))});return()=>{u.close()}},[e]),{connected:n}},yZ=(e,t)=>{try{const n=JSON.parse(e.data);return{type:t,ts:Date.now(),...n}}catch{return{type:t,ts:Date.now()}}},lot=e=>e.valid===!0&&e.flow&&typeof e.flow=="object"?{valid:!0,flow:e.flow}:e.valid===!1&&typeof e.error=="string"?{valid:!1,error:e.error}:null,Are="seeflow:last-project",dot=()=>{if(typeof window>"u")return null;try{return window.localStorage.getItem(Are)}catch{return null}},mZ=e=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Are,e)}catch{}},uot=(e,t)=>{if(e.length===0)return null;if(e.length===1)return e[0]??null;if(t){const n=e.find(o=>o.id===t);if(n)return n}return null},gZ=["File","Edit","View","Tools","Layout","Selection","Help"],Ere="seeflow:command-palette:recent",$re=5,jre=new Map(Eq.map(e=>[e.id,e])),hot=e=>typeof e=="string"&&jre.has(e),kZ=()=>{if(typeof window>"u")return[];try{const e=window.localStorage.getItem(Ere);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(hot).slice(0,$re):[]}catch{return[]}},fot=e=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Ere,JSON.stringify(e))}catch{}},vZ=(e,t)=>e.enabled?e.enabled(t):!0,pot=(e,t)=>t.length===0?!0:`${e.label} ${e.description??""}`.toLowerCase().includes(t);function yot({open:e,onOpenChange:t,runCommand:n,ctx:o}){const[r,a]=m.useState(""),[i,s]=m.useState(0),[c,l]=m.useState(()=>kZ()),h=m.useRef(null),u=m.useRef(null);m.useEffect(()=>{e&&(a(""),s(0),l(kZ()))},[e]);const{groups:f,flat:y}=m.useMemo(()=>{const b=r.trim().toLowerCase();if(b.length===0){if(c.length===0)return{groups:[],flat:[]};const P=[];for(const N of c){const R=jre.get(N);R&&P.push({cmd:R,enabled:vZ(R,o)})}return{groups:[{category:"Recent",rows:P}],flat:P}}const C=new Map;for(const P of Eq){if(!pot(P,b))continue;const A={cmd:P,enabled:vZ(P,o)},N=C.get(P.category);N?N.push(A):C.set(P.category,[A])}const S=[...gZ.filter(P=>C.has(P)),...Array.from(C.keys()).filter(P=>!gZ.includes(P))].map(P=>({category:P,rows:C.get(P)??[]})),j=S.flatMap(P=>P.rows);return{groups:S,flat:j}},[r,o,c]);m.useEffect(()=>{if(y.length===0){s(0);return}s(b=>{var _;let C=b;if(C>=y.length&&(C=0),!((_=y[C])!=null&&_.enabled)){const S=y.findIndex(j=>j.enabled);S!==-1&&(C=S)}return C})},[y]);const g=m.useCallback(b=>{y.length!==0&&s(C=>{var S;let _=C;for(let j=0;j<y.length;j++)if(_=(_+b+y.length)%y.length,(S=y[_])!=null&&S.enabled)return _;return C})},[y]),k=m.useCallback(b=>{l(C=>{const _=[b,...C.filter(S=>S!==b)].slice(0,$re);return fot(_),_})},[]),x=m.useCallback(b=>{const C=y[b];!C||!C.enabled||(k(C.cmd.id),n(C.cmd.id),t(!1))},[y,t,k,n]),v=m.useCallback(b=>{if(b.key==="ArrowDown"){b.preventDefault(),g(1);return}if(b.key==="ArrowUp"){b.preventDefault(),g(-1);return}b.key==="Enter"&&(b.preventDefault(),x(i))},[x,i,g]);m.useEffect(()=>{if(!e)return;const b=u.current;if(!b)return;const C=b.querySelector(`[data-command-row-index="${i}"]`);C&&typeof C.scrollIntoView=="function"&&C.scrollIntoView({block:"nearest"})},[i,e]);const w=r.trim().length>0;return p.jsx(aR,{open:e,onOpenChange:t,children:p.jsx(iR,{children:p.jsxs(B0,{className:oe("fixed left-0 right-0 top-[20%] z-50 mx-auto w-[480px] max-w-[90vw] border border-border bg-card shadow-lg duration-200","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","sm:rounded-lg"),"data-testid":"command-palette",onOpenAutoFocus:b=>{var C;b.preventDefault(),(C=h.current)==null||C.focus()},children:[p.jsx("div",{className:oe("border-b",y.length===0&&!w&&"border-b-0"),children:p.jsx("input",{ref:h,type:"text",value:r,onChange:b=>a(b.target.value),onKeyDown:v,placeholder:"Type a command…","data-testid":"command-palette-input","aria-label":"Search commands",autoComplete:"off",spellCheck:!1,className:"w-full bg-transparent px-4 py-3 text-sm outline-hidden placeholder:text-muted-foreground"})}),p.jsx("div",{ref:u,"data-testid":"command-palette-list","data-empty":y.length===0?"true":"false",className:oe("max-h-[50vh] overflow-y-auto",y.length>0?"py-1":"","seeflow-no-scrollbar"),children:y.length===0?w?p.jsxs("div",{"data-testid":"command-palette-empty",className:"px-4 py-6 text-center text-sm text-muted-foreground",children:['No commands match "',r,'"']}):null:(()=>{let b=-1;return f.map(C=>p.jsxs("div",{className:"py-1",children:[p.jsx("div",{className:"px-3 pb-1 pt-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:C.category}),C.rows.map(_=>{b+=1;const S=b,j=S===i;return p.jsxs("button",{type:"button","data-testid":`command-palette-row-${_.cmd.id}`,"data-command-row-index":S,"data-highlighted":j?"true":"false","aria-disabled":_.enabled?void 0:!0,disabled:!_.enabled,onMouseEnter:()=>{_.enabled&&s(S)},onClick:()=>x(S),className:oe("flex w-full items-center justify-between gap-3 px-3 py-2 text-left text-sm outline-hidden",_.enabled?"cursor-pointer text-foreground hover:bg-muted":"cursor-not-allowed text-muted-foreground/50",j&&_.enabled?"bg-muted":""),children:[p.jsxs("div",{className:"flex min-w-0 flex-col",children:[p.jsx("span",{className:"truncate font-medium",children:_.cmd.label}),_.cmd.description?p.jsx("span",{className:"truncate text-xs text-muted-foreground",children:_.cmd.description}):null]}),_.cmd.shortcut?p.jsx("kbd",{"data-testid":`command-palette-shortcut-${_.cmd.id}`,className:"shrink-0 rounded border bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:_.cmd.shortcut}):null]},_.cmd.id)})]},C.category))})()})]})})})}var qt=Uint8Array,no=Uint16Array,UF=Int32Array,LR=new qt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),IR=new qt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),fO=new qt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Pre=function(e,t){for(var n=new no(31),o=0;o<31;++o)n[o]=t+=1<<e[o-1];for(var r=new UF(n[30]),o=1;o<30;++o)for(var a=n[o];a<n[o+1];++a)r[a]=a-n[o]<<5|o;return{b:n,r}},zre=Pre(LR,2),Rre=zre.b,pO=zre.r;Rre[28]=258,pO[258]=28;var Tre=Pre(IR,0),mot=Tre.b,xZ=Tre.r,yO=new no(32768);for(var Ct=0;Ct<32768;++Ct){var Za=(Ct&43690)>>1|(Ct&21845)<<1;Za=(Za&52428)>>2|(Za&13107)<<2,Za=(Za&61680)>>4|(Za&3855)<<4,yO[Ct]=((Za&65280)>>8|(Za&255)<<8)>>1}var zr=function(e,t,n){for(var o=e.length,r=0,a=new no(t);r<o;++r)e[r]&&++a[e[r]-1];var i=new no(t);for(r=1;r<t;++r)i[r]=i[r-1]+a[r-1]<<1;var s;if(n){s=new no(1<<t);var c=15-t;for(r=0;r<o;++r)if(e[r])for(var l=r<<4|e[r],h=t-e[r],u=i[e[r]-1]++<<h,f=u|(1<<h)-1;u<=f;++u)s[yO[u]>>c]=l}else for(s=new no(o),r=0;r<o;++r)e[r]&&(s[r]=yO[i[e[r]-1]++]>>15-e[r]);return s},Ai=new qt(288);for(var Ct=0;Ct<144;++Ct)Ai[Ct]=8;for(var Ct=144;Ct<256;++Ct)Ai[Ct]=9;for(var Ct=256;Ct<280;++Ct)Ai[Ct]=7;for(var Ct=280;Ct<288;++Ct)Ai[Ct]=8;var Yh=new qt(32);for(var Ct=0;Ct<32;++Ct)Yh[Ct]=5;var got=zr(Ai,9,0),kot=zr(Ai,9,1),vot=zr(Yh,5,0),xot=zr(Yh,5,1),iD=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Po=function(e,t,n){var o=t/8|0;return(e[o]|e[o+1]<<8)>>(t&7)&n},sD=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},WF=function(e){return(e+7)/8|0},If=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new qt(e.subarray(t,n))},wot=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],_n=function(e,t,n){var o=new Error(t||wot[e]);if(o.code=e,Error.captureStackTrace&&Error.captureStackTrace(o,_n),!n)throw o;return o},Mot=function(e,t,n,o){var r=e.length,a=o?o.length:0;if(!r||t.f&&!t.l)return n||new qt(0);var i=!n,s=i||t.i!=2,c=t.i;i&&(n=new qt(r*3));var l=function(ke){var ge=n.length;if(ke>ge){var ve=new qt(Math.max(ge*2,ke));ve.set(n),n=ve}},h=t.f||0,u=t.p||0,f=t.b||0,y=t.l,g=t.d,k=t.m,x=t.n,v=r*8;do{if(!y){h=Po(e,u,1);var M=Po(e,u+1,3);if(u+=3,M)if(M==1)y=kot,g=xot,k=9,x=5;else if(M==2){var _=Po(e,u,31)+257,S=Po(e,u+10,15)+4,j=_+Po(e,u+5,31)+1;u+=14;for(var P=new qt(j),A=new qt(19),N=0;N<S;++N)A[fO[N]]=Po(e,u+N*3,7);u+=S*3;for(var R=iD(A),W=(1<<R)-1,$=zr(A,R,1),N=0;N<j;){var H=$[Po(e,u,W)];u+=H&15;var w=H>>4;if(w<16)P[N++]=w;else{var T=0,O=0;for(w==16?(O=3+Po(e,u,3),u+=2,T=P[N-1]):w==17?(O=3+Po(e,u,7),u+=3):w==18&&(O=11+Po(e,u,127),u+=7);O--;)P[N++]=T}}var I=P.subarray(0,_),z=P.subarray(_);k=iD(I),x=iD(z),y=zr(I,k,1),g=zr(z,x,1)}else _n(1);else{var w=WF(u)+4,b=e[w-4]|e[w-3]<<8,C=w+b;if(C>r){c&&_n(0);break}s&&l(f+b),n.set(e.subarray(w,C),f),t.b=f+=b,t.p=u=C*8,t.f=h;continue}if(u>v){c&&_n(0);break}}s&&l(f+131072);for(var L=(1<<k)-1,F=(1<<x)-1,D=u;;D=u){var T=y[sD(e,u)&L],E=T>>4;if(u+=T&15,u>v){c&&_n(0);break}if(T||_n(2),E<256)n[f++]=E;else if(E==256){D=u,y=null;break}else{var K=E-254;if(E>264){var N=E-257,X=LR[N];K=Po(e,u,(1<<X)-1)+Rre[N],u+=X}var Y=g[sD(e,u)&F],Q=Y>>4;Y||_n(3),u+=Y&15;var z=mot[Q];if(Q>3){var X=IR[Q];z+=sD(e,u)&(1<<X)-1,u+=X}if(u>v){c&&_n(0);break}s&&l(f+131072);var te=f+K;if(f<z){var ne=a-z,ie=Math.min(z,te);for(ne+f<0&&_n(3);f<ie;++f)n[f]=o[ne+f]}for(;f<te;++f)n[f]=n[f-z]}}t.l=y,t.p=D,t.b=f,t.f=h,y&&(h=1,t.m=k,t.d=g,t.n=x)}while(!h);return f!=n.length&&i?If(n,0,f):n.subarray(0,f)},aa=function(e,t,n){n<<=t&7;var o=t/8|0;e[o]|=n,e[o+1]|=n>>8},m2=function(e,t,n){n<<=t&7;var o=t/8|0;e[o]|=n,e[o+1]|=n>>8,e[o+2]|=n>>16},cD=function(e,t){for(var n=[],o=0;o<e.length;++o)e[o]&&n.push({s:o,f:e[o]});var r=n.length,a=n.slice();if(!r)return{t:Hre,l:0};if(r==1){var i=new qt(n[0].s+1);return i[n[0].s]=1,{t:i,l:1}}n.sort(function(C,_){return C.f-_.f}),n.push({s:-1,f:25001});var s=n[0],c=n[1],l=0,h=1,u=2;for(n[0]={s:-1,f:s.f+c.f,l:s,r:c};h!=r-1;)s=n[n[l].f<n[u].f?l++:u++],c=n[l!=h&&n[l].f<n[u].f?l++:u++],n[h++]={s:-1,f:s.f+c.f,l:s,r:c};for(var f=a[0].s,o=1;o<r;++o)a[o].s>f&&(f=a[o].s);var y=new no(f+1),g=mO(n[h-1],y,0);if(g>t){var o=0,k=0,x=g-t,v=1<<x;for(a.sort(function(_,S){return y[S.s]-y[_.s]||_.f-S.f});o<r;++o){var M=a[o].s;if(y[M]>t)k+=v-(1<<g-y[M]),y[M]=t;else break}for(k>>=x;k>0;){var w=a[o].s;y[w]<t?k-=1<<t-y[w]++-1:++o}for(;o>=0&&k;--o){var b=a[o].s;y[b]==t&&(--y[b],++k)}g=t}return{t:new qt(y),l:g}},mO=function(e,t,n){return e.s==-1?Math.max(mO(e.l,t,n+1),mO(e.r,t,n+1)):t[e.s]=n},wZ=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new no(++t),o=0,r=e[0],a=1,i=function(c){n[o++]=c},s=1;s<=t;++s)if(e[s]==r&&s!=t)++a;else{if(!r&&a>2){for(;a>138;a-=138)i(32754);a>2&&(i(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(i(r),--a;a>6;a-=6)i(8304);a>2&&(i(a-3<<5|8208),a=0)}for(;a--;)i(r);a=1,r=e[s]}return{c:n.subarray(0,o),n:t}},g2=function(e,t){for(var n=0,o=0;o<t.length;++o)n+=e[o]*t[o];return n},Dre=function(e,t,n){var o=n.length,r=WF(t+2);e[r]=o&255,e[r+1]=o>>8,e[r+2]=e[r]^255,e[r+3]=e[r+1]^255;for(var a=0;a<o;++a)e[r+a+4]=n[a];return(r+4+o)*8},MZ=function(e,t,n,o,r,a,i,s,c,l,h){aa(t,h++,n),++r[256];for(var u=cD(r,15),f=u.t,y=u.l,g=cD(a,15),k=g.t,x=g.l,v=wZ(f),M=v.c,w=v.n,b=wZ(k),C=b.c,_=b.n,S=new no(19),j=0;j<M.length;++j)++S[M[j]&31];for(var j=0;j<C.length;++j)++S[C[j]&31];for(var P=cD(S,7),A=P.t,N=P.l,R=19;R>4&&!A[fO[R-1]];--R);var W=l+5<<3,$=g2(r,Ai)+g2(a,Yh)+i,H=g2(r,f)+g2(a,k)+i+14+3*R+g2(S,A)+2*S[16]+3*S[17]+7*S[18];if(c>=0&&W<=$&&W<=H)return Dre(t,h,e.subarray(c,c+l));var T,O,I,z;if(aa(t,h,1+(H<$)),h+=2,H<$){T=zr(f,y,0),O=f,I=zr(k,x,0),z=k;var L=zr(A,N,0);aa(t,h,w-257),aa(t,h+5,_-1),aa(t,h+10,R-4),h+=14;for(var j=0;j<R;++j)aa(t,h+3*j,A[fO[j]]);h+=3*R;for(var F=[M,C],D=0;D<2;++D)for(var E=F[D],j=0;j<E.length;++j){var K=E[j]&31;aa(t,h,L[K]),h+=A[K],K>15&&(aa(t,h,E[j]>>5&127),h+=E[j]>>12)}}else T=got,O=Ai,I=vot,z=Yh;for(var j=0;j<s;++j){var X=o[j];if(X>255){var K=X>>18&31;m2(t,h,T[K+257]),h+=O[K+257],K>7&&(aa(t,h,X>>23&31),h+=LR[K]);var Y=X&31;m2(t,h,I[Y]),h+=z[Y],Y>3&&(m2(t,h,X>>5&8191),h+=IR[Y])}else m2(t,h,T[X]),h+=O[X]}return m2(t,h,T[256]),h+O[256]},bot=new UF([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Hre=new qt(0),_ot=function(e,t,n,o,r,a){var i=a.z||e.length,s=new qt(o+i+5*(1+Math.ceil(i/7e3))+r),c=s.subarray(o,s.length-r),l=a.l,h=(a.r||0)&7;if(t){h&&(c[0]=a.r>>3);for(var u=bot[t-1],f=u>>13,y=u&8191,g=(1<<n)-1,k=a.p||new no(32768),x=a.h||new no(g+1),v=Math.ceil(n/3),M=2*v,w=function(ce){return(e[ce]^e[ce+1]<<v^e[ce+2]<<M)&g},b=new UF(25e3),C=new no(288),_=new no(32),S=0,j=0,P=a.i||0,A=0,N=a.w||0,R=0;P+2<i;++P){var W=w(P),$=P&32767,H=x[W];if(k[$]=H,x[W]=$,N<=P){var T=i-P;if((S>7e3||A>24576)&&(T>423||!l)){h=MZ(e,c,0,b,C,_,j,A,R,P-R,h),A=S=j=0,R=P;for(var O=0;O<286;++O)C[O]=0;for(var O=0;O<30;++O)_[O]=0}var I=2,z=0,L=y,F=$-H&32767;if(T>2&&W==w(P-F))for(var D=Math.min(f,T)-1,E=Math.min(32767,P),K=Math.min(258,T);F<=E&&--L&&$!=H;){if(e[P+I]==e[P+I-F]){for(var X=0;X<K&&e[P+X]==e[P+X-F];++X);if(X>I){if(I=X,z=F,X>D)break;for(var Y=Math.min(F,X-2),Q=0,O=0;O<Y;++O){var te=P-F+O&32767,ne=k[te],ie=te-ne&32767;ie>Q&&(Q=ie,H=te)}}}$=H,H=k[$],F+=$-H&32767}if(z){b[A++]=268435456|pO[I]<<18|xZ[z];var ke=pO[I]&31,ge=xZ[z]&31;j+=LR[ke]+IR[ge],++C[257+ke],++_[ge],N=P+I,++S}else b[A++]=e[P],++C[e[P]]}}for(P=Math.max(P,N);P<i;++P)b[A++]=e[P],++C[e[P]];h=MZ(e,c,l,b,C,_,j,A,R,P-R,h),l||(a.r=h&7|c[h/8|0]<<3,h-=7,a.h=x,a.p=k,a.i=P,a.w=N)}else{for(var P=a.w||0;P<i+l;P+=65535){var ve=P+65535;ve>=i&&(c[h/8|0]=l,ve=i),h=Dre(c,h+1,e.subarray(P,ve))}a.i=i}return If(s,0,o+WF(h)+r)},Cot=function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var n=t,o=9;--o;)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e}(),Sot=function(){var e=-1;return{p:function(t){for(var n=e,o=0;o<t.length;++o)n=Cot[n&255^t[o]]^n>>>8;e=n},d:function(){return~e}}},Ore=function(){var e=1,t=0;return{p:function(n){for(var o=e,r=t,a=n.length|0,i=0;i!=a;){for(var s=Math.min(i+2655,a);i<s;++i)r+=o+=n[i];o=(o&65535)+15*(o>>16),r=(r&65535)+15*(r>>16)}e=o,t=r},d:function(){return e%=65521,t%=65521,(e&255)<<24|(e&65280)<<8|(t&255)<<8|t>>8}}},qre=function(e,t,n,o,r){if(!r&&(r={l:1},t.dictionary)){var a=t.dictionary.subarray(-32768),i=new qt(a.length+e.length);i.set(a),i.set(e,a.length),e=i,r.w=a.length}return _ot(e,t.level==null?6:t.level,t.mem==null?r.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,o,r)},Fre=function(e,t){var n={};for(var o in e)n[o]=e[o];for(var o in t)n[o]=t[o];return n},Lr=function(e,t){return e[t]|e[t+1]<<8},qo=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},lD=function(e,t){return qo(e,t)+qo(e,t+4)*4294967296},en=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8},Lot=function(e,t){var n=t.level,o=n==0?0:n<6?1:n==9?3:2;if(e[0]=120,e[1]=o<<6|(t.dictionary&&32),e[1]|=31-(e[0]<<8|e[1])%31,t.dictionary){var r=Ore();r.p(t.dictionary),en(e,2,r.d())}};function Iot(e,t){return qre(e,t||{},0,0)}function Not(e,t){return Mot(e,{i:2},t&&t.out,t&&t.dictionary)}function Mrt(e,t){t||(t={});var n=Ore();n.p(e);var o=qre(e,t,t.dictionary?6:2,4);return Lot(o,t),en(o,o.length-4,n.d()),o}var Vre=function(e,t,n,o){for(var r in e){var a=e[r],i=t+r,s=o;Array.isArray(a)&&(s=Fre(o,a[1]),a=a[0]),a instanceof qt?n[i]=[a,s]:(n[i+="/"]=[new qt(0),s],Vre(a,i,n,o))}},bZ=typeof TextEncoder<"u"&&new TextEncoder,gO=typeof TextDecoder<"u"&&new TextDecoder,Aot=0;try{gO.decode(Hre,{stream:!0}),Aot=1}catch{}var Eot=function(e){for(var t="",n=0;;){var o=e[n++],r=(o>127)+(o>223)+(o>239);if(n+r>e.length)return{s:t,r:If(e,n-1)};r?r==3?(o=((o&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,t+=String.fromCharCode(55296|o>>10,56320|o&1023)):r&1?t+=String.fromCharCode((o&31)<<6|e[n++]&63):t+=String.fromCharCode((o&15)<<12|(e[n++]&63)<<6|e[n++]&63):t+=String.fromCharCode(o)}};function pz(e,t){var n;if(bZ)return bZ.encode(e);for(var o=e.length,r=new qt(e.length+(e.length>>1)),a=0,i=function(l){r[a++]=l},n=0;n<o;++n){if(a+5>r.length){var s=new qt(a+8+(o-n<<1));s.set(r),r=s}var c=e.charCodeAt(n);c<128||t?i(c):c<2048?(i(192|c>>6),i(128|c&63)):c>55295&&c<57344?(c=65536+(c&1047552)|e.charCodeAt(++n)&1023,i(240|c>>18),i(128|c>>12&63),i(128|c>>6&63),i(128|c&63)):(i(224|c>>12),i(128|c>>6&63),i(128|c&63))}return If(r,0,a)}function $ot(e,t){if(t){for(var n="",o=0;o<e.length;o+=16384)n+=String.fromCharCode.apply(null,e.subarray(o,o+16384));return n}else{if(gO)return gO.decode(e);var r=Eot(e),a=r.s,n=r.r;return n.length&&_n(8),a}}var jot=function(e,t){return t+30+Lr(e,t+26)+Lr(e,t+28)},Pot=function(e,t,n){var o=Lr(e,t+28),r=$ot(e.subarray(t+46,t+46+o),!(Lr(e,t+8)&2048)),a=t+46+o,i=qo(e,t+20),s=n&&i==4294967295?zot(e,a):[i,qo(e,t+24),qo(e,t+42)],c=s[0],l=s[1],h=s[2];return[Lr(e,t+10),c,l,r,a+Lr(e,t+30)+Lr(e,t+32),h]},zot=function(e,t){for(;Lr(e,t)!=1;t+=4+Lr(e,t+2));return[lD(e,t+12),lD(e,t+4),lD(e,t+20)]},kO=function(e){var t=0;if(e)for(var n in e){var o=e[n].length;o>65535&&_n(9),t+=o+4}return t},_Z=function(e,t,n,o,r,a,i,s){var c=o.length,l=n.extra,h=s&&s.length,u=kO(l);en(e,t,i!=null?33639248:67324752),t+=4,i!=null&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(a<0&&8),e[t++]=r&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var f=new Date(n.mtime==null?Date.now():n.mtime),y=f.getFullYear()-1980;if((y<0||y>119)&&_n(10),en(e,t,y<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>1),t+=4,a!=-1&&(en(e,t,n.crc),en(e,t+4,a<0?-a-2:a),en(e,t+8,n.size)),en(e,t+12,c),en(e,t+14,u),t+=16,i!=null&&(en(e,t,h),en(e,t+6,n.attrs),en(e,t+10,i),t+=14),e.set(o,t),t+=c,u)for(var g in l){var k=l[g],x=k.length;en(e,t,+g),en(e,t+2,x),e.set(k,t+4),t+=4+x}return h&&(e.set(s,t),t+=h),t},Rot=function(e,t,n,o,r){en(e,t,101010256),en(e,t+8,n),en(e,t+10,n),en(e,t+12,o),en(e,t+16,r)};function Bre(e,t){t||(t={});var n={},o=[];Vre(e,"",n,t);var r=0,a=0;for(var i in n){var s=n[i],c=s[0],l=s[1],h=l.level==0?0:8,u=pz(i),f=u.length,y=l.comment,g=y&&pz(y),k=g&&g.length,x=kO(l.extra);f>65535&&_n(11);var v=h?Iot(c,l):c,M=v.length,w=Sot();w.p(c),o.push(Fre(l,{size:c.length,crc:w.d(),c:v,f:u,m:g,u:f!=i.length||g&&y.length!=k,o:r,compression:h})),r+=30+f+x+M,a+=76+2*(f+x)+(k||0)+M}for(var b=new qt(a+22),C=r,_=a-r,S=0;S<o.length;++S){var u=o[S];_Z(b,u.o,u,u.f,u.u,u.c.length);var j=30+u.f.length+kO(u.extra);b.set(u.c,u.o+j),_Z(b,r,u,u.f,u.u,u.c.length,u.o,u.m),r+=16+j+(u.m?u.m.length:0)}return Rot(b,r,o.length,_,C),b}function Tot(e,t){for(var n={},o=e.length-22;qo(e,o)!=101010256;--o)(!o||e.length-o>65558)&&_n(13);var r=Lr(e,o+8);if(!r)return{};var a=qo(e,o+16),i=a==4294967295||r==65535;if(i){var s=qo(e,o-12);i=qo(e,s)==101075792,i&&(r=qo(e,s+32),a=qo(e,s+48))}for(var c=0;c<r;++c){var l=Pot(e,a,i),h=l[0],u=l[1],f=l[2],y=l[3],g=l[4],k=l[5],x=jot(e,k);a=g,h?h==8?n[y]=Not(e.subarray(x,x+u),{out:new qt(f)}):_n(14,"unknown compression type "+h):n[y]=If(e,x,x+u)}return n}const Dot=2;function Hot(e){if(e.type!=="image")return;const t=e.data;return typeof(t==null?void 0:t.path)=="string"&&t.path.length>0?t.path:void 0}async function Oot({project:e,flows:t}){var h;const n=`/api/projects/${encodeURIComponent(e)}`,o=await fetch(n);if(!o.ok)throw new Error(`GET ${n} → ${o.status}`);const r=await o.json(),a=new Set(t.map(u=>u.flowSlug)),i=r.flows.filter(u=>a.has(u.flowSlug)),s=a.has(r.defaultFlow)?r.defaultFlow:((h=i[0])==null?void 0:h.flowSlug)??r.defaultFlow,c={version:1,name:r.name,defaultFlow:s,flows:i.map(u=>{const f={id:u.flowSlug,name:u.name};return u.icon!==void 0&&(f.icon=u.icon),f})};r.description!==void 0&&(c.description=r.description);const l={"seeflow.json":pz(JSON.stringify(c,null,2))};for(const{flowSlug:u}of t){const f=`/api/projects/${encodeURIComponent(e)}/flows/${encodeURIComponent(u)}`,y=await fetch(f);if(!y.ok)throw new Error(`GET ${f} → ${y.status}`);const{flow:g}=await y.json(),k={version:Dot,name:g.name,nodes:g.nodes,connectors:g.connectors};g.description!==void 0&&(k.description=g.description),l[`flows/${u}/flow.json`]=pz(JSON.stringify(k));const x=new Set;for(const v of g.nodes){const M=Hot(v);if(!M||x.has(M))continue;x.add(M);const w=`/api/projects/${encodeURIComponent(e)}/files/${M}`,b=await fetch(w);b.ok&&(l[`flows/${u}/files/${M}`]=new Uint8Array(await b.arrayBuffer()))}}return Bre(l)}const qot="https://seeflow.dev/api";async function Fot(e,t,n,o,r,a){let s=await Oot({project:e,flows:a.map(f=>({flowSlug:f}))});const c=r==null?void 0:r.split(",")[1];if(c){const f=Tot(s);f["preview.png"]=Uint8Array.from(atob(c),y=>y.charCodeAt(0)),s=Bre(f)}const l=`${qot}/projects?email=${encodeURIComponent(t)}&name=${encodeURIComponent(n)}&visibility=${encodeURIComponent(o)}`,h=await fetch(l,{method:"POST",headers:{"content-type":"application/zip"},body:s.buffer});if(!h.ok)throw new Error(`Export failed with status ${h.status}`);const u=await h.json();if(typeof u.url!="string")throw new Error("Invalid response from cloud API: missing url");return{shareUrl:u.url}}function Vot(e){return m.useCallback((t,n,o,r,a)=>Fot(e,t,n,o,r,a??[]),[e])}const CZ="seeflow.export.email",SZ="seeflow.export.name",LZ="seeflow.export.visibility";function Bot({open:e,onOpenChange:t,project:n,flowName:o,onCapturePreview:r}){const[a,i]=m.useState(""),[s,c]=m.useState(""),[l,h]=m.useState("public"),[u,f]=m.useState({kind:"idle"}),[y,g]=m.useState(!1),[k,x]=m.useState(new Set),v=Vot(n),M=BF(e?n:null),w=M.flows;m.useEffect(()=>{e&&(i(localStorage.getItem(CZ)??""),c(o??localStorage.getItem(SZ)??""),h(localStorage.getItem(LZ)??"public"),f({kind:"idle"}),g(!1))},[e,o]),m.useEffect(()=>{e&&w&&x(new Set(w.map($=>$.flowSlug)))},[e,w]);const b=m.useCallback(async()=>{f({kind:"loading"});try{const $=await(r==null?void 0:r()),{shareUrl:H}=await v(a.trim(),s.trim(),l,$,Array.from(k));localStorage.setItem(CZ,a.trim()),localStorage.setItem(SZ,s.trim()),localStorage.setItem(LZ,l),f({kind:"done",shareUrl:H})}catch($){f({kind:"error",message:$ instanceof Error?$.message:String($)})}},[v,a,s,l,r,k]),C=m.useCallback($=>{x(H=>{const T=new Set(H);return T.has($)?T.delete($):T.add($),T})},[]),_=m.useCallback(()=>{w&&x($=>$.size===w.length?new Set:new Set(w.map(H=>H.flowSlug)))},[w]),S=m.useCallback(async()=>{if(u.kind==="done")try{await navigator.clipboard.writeText(u.shareUrl),g(!0),setTimeout(()=>g(!1),2e3)}catch($){console.error("Failed to copy to clipboard:",$)}},[u]),j=u.kind==="loading",P=a.trim().length>0&&s.trim().length>0&&w!==null&&M.error===null&&k.size>0,A=((w==null?void 0:w.length)??0)>=2,N=M.loading,R=M.error!==null,W=w!==null&&k.size===w.length;return p.jsx(Ca,{open:e,onOpenChange:t,children:p.jsxs(Ri,{className:"sm:max-w-md","data-testid":"export-dialog",onOpenAutoFocus:$=>{$.preventDefault();const H=document.querySelector('[data-testid="export-email-input"]');H==null||H.focus()},children:[p.jsxs(Ti,{children:[p.jsx(Di,{children:"Export project to seeflow.dev"}),p.jsx(Hi,{children:"Upload this project to the cloud and get a shareable link."})]}),u.kind!=="done"?p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Email"}),p.jsx("input",{type:"email",required:!0,autoComplete:"email",value:a,onChange:$=>i($.target.value),disabled:j,"data-testid":"export-email-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"}),p.jsx("span",{className:"text-xs text-muted-foreground",children:"We'll use this to let you manage your flows in the future."})]}),p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Flow Name"}),p.jsx("input",{type:"text",required:!0,value:s,onChange:$=>c($.target.value),disabled:j,"data-testid":"export-name-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"})]}),p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Visibility"}),p.jsxs("select",{value:l,onChange:$=>h($.target.value),disabled:j,"data-testid":"export-visibility-select",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",children:[p.jsx("option",{value:"public",children:"Public — anyone can discover it"}),p.jsx("option",{value:"link",children:"Anyone with the link"})]})]}),N?p.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground","data-testid":"export-flows-loading",children:[p.jsx(fZ,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}),p.jsx("span",{children:"Loading flows…"})]}):null,R?p.jsxs("div",{role:"alert","data-testid":"export-flows-error",className:"flex items-center justify-between gap-3 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:[p.jsx("span",{children:"Couldn't load flows."}),p.jsx("button",{type:"button",onClick:()=>M.refresh(),disabled:j,"data-testid":"export-flows-retry",className:"shrink-0 font-medium underline-offset-2 hover:underline disabled:cursor-not-allowed disabled:opacity-50",children:"Retry"})]}):null,A&&w?p.jsxs("div",{className:"flex flex-col gap-1.5 text-sm","data-testid":"export-flows-section",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"font-medium",children:"Flows"}),p.jsx("button",{type:"button",onClick:_,disabled:j,"data-testid":"export-flows-toggle-all",className:"text-xs text-muted-foreground underline-offset-2 hover:text-foreground hover:underline disabled:cursor-not-allowed disabled:opacity-50",children:W?"Clear":"Select all"})]}),p.jsx("ul",{className:"flex max-h-48 flex-col gap-1 overflow-y-auto rounded-md border bg-background p-2",children:w.map($=>p.jsx("li",{children:p.jsxs("label",{className:"flex items-center gap-2 rounded px-2 py-1 hover:bg-muted",children:[p.jsx("input",{type:"checkbox",checked:k.has($.flowSlug),onChange:()=>C($.flowSlug),disabled:j,"data-testid":`export-flow-checkbox-${$.flowSlug}`}),p.jsx("span",{className:"flex-1 truncate",children:$.name}),$.isDefault?p.jsx(Pnt,{className:"h-3.5 w-3.5 text-muted-foreground","aria-label":"default flow","data-testid":`export-flow-default-${$.flowSlug}`}):null]})},$.flowSlug))})]}):null,u.kind==="error"?p.jsx("div",{role:"alert","data-testid":"export-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:u.message}):null]}),p.jsx(Sa,{children:u.kind==="error"?p.jsxs(p.Fragment,{children:[p.jsx(ut,{type:"button",variant:"ghost",onClick:()=>t(!1),"data-testid":"export-cancel",children:"Cancel"}),p.jsx(ut,{type:"button",onClick:()=>f({kind:"idle"}),"data-testid":"export-retry",children:"Try again"})]}):p.jsxs(p.Fragment,{children:[p.jsx(ut,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:j,"data-testid":"export-cancel",children:"Cancel"}),p.jsx(ut,{type:"button",onClick:b,disabled:j||!P,"data-testid":"export-submit",children:j?p.jsxs(p.Fragment,{children:[p.jsx(fZ,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}),p.jsx("span",{children:"Uploading…"})]}):"Export"})]})})]}):p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex flex-col gap-3",children:[p.jsx("p",{className:"text-sm text-muted-foreground",children:"Your diagram is live. Share this link:"}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{type:"text",readOnly:!0,value:u.shareUrl,"data-testid":"export-share-url",className:"min-w-0 flex-1 rounded-md border bg-muted px-3 py-2 text-sm outline-hidden"}),p.jsx(ut,{type:"button",variant:"outline",size:"icon",onClick:S,"aria-label":"Copy link","data-testid":"export-copy",children:y?p.jsx(_re,{className:"h-4 w-4","aria-hidden":"true"}):p.jsx(Sre,{className:"h-4 w-4","aria-hidden":"true"})}),p.jsx(ut,{type:"button",variant:"outline",size:"icon",onClick:()=>window.open(u.shareUrl,"_blank"),"aria-label":"View in new tab","data-testid":"export-view",children:p.jsx(Ent,{className:"h-4 w-4","aria-hidden":"true"})})]})]}),p.jsx(Sa,{children:p.jsx(ut,{type:"button",onClick:()=>t(!1),"data-testid":"export-done",children:"Done"})})]})]})})}function Uot(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}const Wot=/^[a-z0-9][a-z0-9-]*$/,Got={"--tw-enter-translate-x":"-50%","--tw-enter-translate-y":"-50%","--tw-exit-translate-x":"-50%","--tw-exit-translate-y":"-50%","--tw-enter-scale":"1","--tw-exit-scale":"1"};function Zot({open:e,onOpenChange:t,onCreate:n,onCreated:o}){const[r,a]=m.useState(""),[i,s]=m.useState(""),[c,l]=m.useState(!1),[h,u]=m.useState(null),[f,y]=m.useState(!1);m.useEffect(()=>{e&&(a(""),s(""),l(!1),u(null),y(!1))},[e]);const g=C=>{a(C),c||s(Uot(C))},k=C=>{s(C),c||l(!0)},x=i.trim(),v=r.trim(),M=x.length>0&&Wot.test(x),w=M&&v.length>0&&!f,b=async C=>{if(C.preventDefault(),!w){!M&&x.length>0&&u("Flow id must match /^[a-z0-9][a-z0-9-]*$/");return}y(!0),u(null);try{const S=await n({id:x,name:v});o==null||o(S),t(!1)}catch(_){u(_ instanceof Error?_.message:String(_)),y(!1)}};return p.jsx(Ca,{open:e,onOpenChange:t,children:p.jsxs(Ri,{className:"sm:max-w-md",style:Got,"data-testid":"flow-create-dialog",onOpenAutoFocus:C=>{C.preventDefault();const _=document.querySelector('[data-testid="flow-create-name-input"]');_==null||_.focus()},children:[p.jsxs(Ti,{children:[p.jsx(Di,{children:"Create new flow"}),p.jsx(Hi,{children:"A new flow folder is scaffolded under flows/<id>/ in your project."})]}),p.jsxs("form",{onSubmit:b,className:"flex flex-col gap-4",children:[p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Display name"}),p.jsx("input",{type:"text",required:!0,autoComplete:"off",spellCheck:!1,value:r,onChange:C=>g(C.target.value),"data-testid":"flow-create-name-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"})]}),p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Flow id"}),p.jsx("input",{type:"text",required:!0,autoComplete:"off",spellCheck:!1,placeholder:"my-retry-flow",value:i,onChange:C=>k(C.target.value),"data-testid":"flow-create-id-input",className:"rounded-md border bg-background px-3 py-2 font-mono text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"}),p.jsx("span",{className:"text-xs text-muted-foreground",children:"Auto-filled from the display name. Lowercase letters, digits, and dashes; must start with a letter or digit."})]}),h?p.jsx("div",{role:"alert","data-testid":"flow-create-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:h}):null,p.jsxs(Sa,{children:[p.jsx(ut,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:f,children:"Cancel"}),p.jsx(ut,{type:"submit",disabled:!w,"data-testid":"flow-create-submit",children:f?"Creating…":"Create flow"})]})]})]})})}function Xot({open:e,onOpenChange:t,flow:n,flows:o,onDelete:r,onDeleted:a}){var M;const i=m.useMemo(()=>o.filter(w=>w.flowSlug!==(n==null?void 0:n.flowSlug)),[o,n==null?void 0:n.flowSlug]),s=((M=i[0])==null?void 0:M.flowSlug)??"",[c,l]=m.useState(s),[h,u]=m.useState(null),[f,y]=m.useState(!1);if(m.useEffect(()=>{e&&(l(s),u(null),y(!1))},[e,s]),!n)return p.jsx(Ca,{open:!1,onOpenChange:t});const g=n.isDefault,k=c.length>0,x=(!g||k)&&!f,v=async w=>{if(w.preventDefault(),!!x){y(!0),u(null);try{const b=g?{newDefault:c}:void 0;await r(n.flowSlug,b),a==null||a(n.flowSlug,b==null?void 0:b.newDefault),t(!1)}catch(b){u(b instanceof Error?b.message:String(b)),y(!1)}}};return p.jsx(Ca,{open:e,onOpenChange:t,children:p.jsxs(Ri,{className:"sm:max-w-md","data-testid":"flow-delete-dialog",children:[p.jsxs(Ti,{children:[p.jsx(Di,{children:"Delete flow"}),p.jsxs(Hi,{children:["This removes flows/",n.flowSlug,"/ from disk and updates seeflow.json. The action cannot be undone."]})]}),p.jsxs("form",{onSubmit:v,className:"flex flex-col gap-4",children:[p.jsxs("p",{className:"text-sm",children:["Delete ",p.jsx("span",{className:"font-medium",children:n.name})," ",p.jsxs("span",{className:"font-mono text-muted-foreground",children:["(",n.flowSlug,")"]}),"?"]}),g?p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsx("span",{className:"font-medium",children:"New default flow"}),p.jsx("select",{value:c,onChange:w=>l(w.target.value),"data-testid":"flow-delete-new-default-select",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:i.map(w=>p.jsxs("option",{value:w.flowSlug,children:[w.name," (",w.flowSlug,")"]},w.flowSlug))}),p.jsxs("span",{className:"text-xs text-muted-foreground",children:[n.name," is the project default — pick a replacement before deleting."]})]}):null,h?p.jsx("div",{role:"alert","data-testid":"flow-delete-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:h}):null,p.jsxs(Sa,{children:[p.jsx(ut,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:f,children:"Cancel"}),p.jsx(ut,{type:"submit",variant:"destructive",disabled:!x,"data-testid":"flow-delete-submit",children:f?"Deleting…":"Delete"})]})]})]})})}function Kot({open:e,onOpenChange:t,flow:n,onRename:o,onRenamed:r}){const[a,i]=m.useState(""),[s,c]=m.useState(null),[l,h]=m.useState(!1);if(m.useEffect(()=>{e&&n&&(i(n.name),c(null),h(!1))},[e,n]),!n)return p.jsx(Ca,{open:!1,onOpenChange:t});const u=a.trim(),f=u!==n.name,y=u.length>0&&f&&!l,g=async k=>{if(k.preventDefault(),!!y){h(!0),c(null);try{const x={name:u},v=await o(n.flowSlug,x);r==null||r(v,n.flowSlug),t(!1)}catch(x){c(x instanceof Error?x.message:String(x)),h(!1)}}};return p.jsx(Ca,{open:e,onOpenChange:t,children:p.jsxs(Ri,{className:"sm:max-w-md","data-testid":"flow-rename-dialog",onOpenAutoFocus:k=>{k.preventDefault();const x=document.querySelector('[data-testid="flow-rename-name-input"]');x==null||x.focus(),x==null||x.select()},children:[p.jsxs(Ti,{children:[p.jsx(Di,{children:"Rename flow"}),p.jsx(Hi,{children:"Update the display name. The flow id is fixed once created."})]}),p.jsxs("form",{onSubmit:g,className:"flex flex-col gap-4",children:[p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Flow id"}),p.jsx("input",{type:"text",readOnly:!0,disabled:!0,autoComplete:"off",spellCheck:!1,value:n.flowSlug,"data-testid":"flow-rename-id-input",className:"cursor-not-allowed rounded-md border bg-muted px-3 py-2 font-mono text-sm text-muted-foreground"})]}),p.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Display name"}),p.jsx("input",{type:"text",required:!0,autoComplete:"off",spellCheck:!1,value:a,onChange:k=>i(k.target.value),"data-testid":"flow-rename-name-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"})]}),s?p.jsx("div",{role:"alert","data-testid":"flow-rename-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:s}):null,p.jsxs(Sa,{children:[p.jsx(ut,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:l,children:"Cancel"}),p.jsx(ut,{type:"submit",disabled:!y,"data-testid":"flow-rename-submit",children:l?"Saving…":"Save"})]})]})]})})}function Yot({project:e,activeFlow:t,flows:n,onSelect:o,onCreate:r,onRename:a,onDelete:i}){const[s,c]=m.useState(!1),l=n.find(h=>h.flowSlug===t);return p.jsxs(Dd,{open:s,onOpenChange:c,children:[p.jsx(V0,{asChild:!0,children:p.jsxs(ut,{type:"button",variant:"outline",size:"sm","aria-label":`Switch flow for ${e}`,"aria-expanded":s,className:"gap-2","data-testid":"flow-switcher-trigger",children:[p.jsx("span",{className:"max-w-[180px] truncate text-sm",children:(l==null?void 0:l.name)??t}),p.jsx(Cre,{className:"h-3.5 w-3.5 opacity-60"})]})}),p.jsx(zi,{align:"start",sideOffset:6,className:"w-[260px] p-0","data-testid":"flow-switcher-popover",children:p.jsx(sF,{children:p.jsxs(cF,{children:[p.jsx(lF,{children:"No flows."}),n.length>0?p.jsx(Bh,{heading:"Flows",children:n.map(h=>{const u=h.flowSlug===t;return p.jsxs(Uh,{value:`${h.name} ${h.flowSlug}`,"aria-current":u?"true":void 0,"data-testid":`flow-switcher-row-${h.flowSlug}`,"data-active":u?"true":void 0,onSelect:()=>{c(!1),o==null||o(h.flowSlug)},className:oe("group flex items-center justify-between gap-2",u&&"bg-accent text-accent-foreground"),children:[p.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[h.icon?p.jsx("span",{"aria-hidden":"true",className:"text-xs opacity-70",children:h.icon}):null,p.jsx("span",{className:"truncate font-medium",children:h.name}),h.isDefault?p.jsx("span",{className:"shrink-0 rounded bg-muted px-1.5 py-0.5 text-[10px] uppercase tracking-wide text-muted-foreground",children:"default"}):null]}),p.jsxs("div",{className:"flex shrink-0 items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100",children:[p.jsx("button",{type:"button","aria-label":`Rename ${h.name}`,"data-testid":`flow-switcher-rename-${h.flowSlug}`,className:"rounded p-0.5 hover:text-foreground focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring",onClick:f=>{f.stopPropagation(),c(!1),a==null||a(h.flowSlug)},children:p.jsx($nt,{className:"h-3.5 w-3.5"})}),p.jsx("button",{type:"button","aria-label":`Delete ${h.name}`,"data-testid":`flow-switcher-delete-${h.flowSlug}`,className:"rounded p-0.5 hover:text-destructive focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring",onClick:f=>{f.stopPropagation(),c(!1),i==null||i(h.flowSlug)},children:p.jsx(Ire,{className:"h-3.5 w-3.5"})})]})]},h.flowSlug)})}):null,n.length>0?p.jsx(dF,{}):null,p.jsx(Bh,{children:p.jsxs(Uh,{value:"+ new flow","data-testid":"flow-switcher-create",onSelect:()=>{c(!1),r==null||r()},className:"flex items-center gap-2 text-sm",children:[p.jsx(Lre,{className:"h-4 w-4 opacity-70"}),p.jsx("span",{className:"font-medium",children:"New flow"})]})})]})})})]})}const Qot=(e,t)=>{if(e.has(t))return e;const n=new Set(e);return n.add(t),n},Jot=(e,t)=>{if(t.length===0)return e;let n=!1;const o=new Set(e);for(const r of t)o.has(r)||(o.add(r),n=!0);return n?o:e},ert=(e,t)=>{if(!e.has(t))return e;const n=new Set(e);return n.delete(t),n},trt=(e,t)=>{if(t.length===0)return e;let n=!1;const o=new Set(e);for(const r of t)o.has(r)&&(o.delete(r),n=!0);return n?o:e},nrt=(e,t)=>{if(e.size===0)return e;const n=new Set(t.map(a=>a.id));let o=!1;const r=new Set(e);for(const a of r)n.has(a)||(r.delete(a),o=!0);return o?r:e},IZ=()=>{const[e,t]=m.useState(()=>new Set),n=m.useCallback(c=>{t(l=>Qot(l,c))},[]),o=m.useCallback(c=>{t(l=>Jot(l,c))},[]),r=m.useCallback(c=>{t(l=>ert(l,c))},[]),a=m.useCallback(c=>{t(l=>trt(l,c))},[]),i=m.useCallback(c=>{t(l=>nrt(l,c))},[]),s=m.useCallback(()=>t(new Set),[]);return{ids:e,mark:n,markMany:o,unmark:r,unmarkMany:a,pruneAgainst:i,reset:s}},dD=(e,t)=>e===t?!0:e==null||t==null||typeof e!=typeof t||typeof e!="object"?!1:JSON.stringify(e)===JSON.stringify(t),ort=(e,t,n)=>({...e,[t]:{...e[t],...n}}),rrt=(e,t)=>{if(!(t in e))return e;const n={...e};return delete n[t],n},NZ=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),art=(e,t)=>{const n=Object.entries(e);if(n.length===0)return e;const o=new Map(t.map(i=>[i.id,i]));let r=!1;const a={...e};for(const[i,s]of n){const c=o.get(i);if(!c)continue;const l={},h=l;let u=!1;for(const f of Object.keys(s)){const y=s[f],g=c[f];if(f==="data"&&NZ(y)&&NZ(g)){const k={};let x=!1;for(const v of Object.keys(y))dD(y[v],g[v])||(k[v]=y[v],x=!0);x&&(h[f]=k,u=!0)}else dD(y,g)||(h[f]=y,u=!0)}u?dD(l,s)||(a[i]=l,r=!0):(delete a[i],r=!0)}return r?a:e},AZ=()=>{const[e,t]=m.useState({}),n=m.useCallback((i,s)=>{t(c=>ort(c,i,s))},[]),o=m.useCallback(i=>{t(s=>rrt(s,i))},[]),r=m.useCallback(i=>{t(s=>art(s,i))},[]),a=m.useCallback(()=>t({}),[]);return{overrides:e,setOverride:n,dropOverride:o,pruneAgainst:r,reset:a}};function irt({nodes:e,connectors:t,flowPos:n,nodeIdGen:o,connectorIdGen:r,defaultOffset:a={x:24,y:24}}){const i=new Map;for(const y of e)i.set(y.id,o(y.id));let s=Number.POSITIVE_INFINITY,c=Number.POSITIVE_INFINITY;for(const y of e)y.position.x<s&&(s=y.position.x),y.position.y<c&&(c=y.position.y);Number.isFinite(s)||(s=0),Number.isFinite(c)||(c=0);const l=n?n.x-s:a.x,h=n?n.y-c:a.y,u=e.map(y=>{const g=i.get(y.id);if(g===void 0)throw new Error(`paste id missing for ${y.id}`);return{...y,id:g,position:{x:y.position.x+l,y:y.position.y+h}}}),f=t.map(y=>{const g=r(y.id);return{...y,id:g,source:i.get(y.source)??y.source,target:i.get(y.target)??y.target}});return{newNodes:u,newConnectors:f,idMap:i}}const srt=e=>({type:"image",position:e.position,data:{path:"",alt:e.originalFilename,width:e.dims.width,height:e.dims.height,_uploading:!0}}),crt=e=>({type:"image",data:Ure(e)}),lrt=e=>({type:"image",position:e.position,data:{path:"",alt:e.originalFilename,width:e.dims.width,height:e.dims.height,_uploadError:e.message}}),Ure=e=>({...wDe(e.path,e.dims,e.lastUsed),alt:e.originalFilename}),drt=async(e,t)=>{const{nodeId:n,flowId:o,file:r,originalFilename:a,position:i,dims:s,lastUsed:c}=e;t.rememberRetry(n,{file:r,originalFilename:a,position:i,dims:s}),t.setOverride(n,srt({position:i,dims:s,originalFilename:a}));const l=async()=>{let h;try{h=(await t.upload(o,n,r,a)).path}catch(y){const g=y instanceof Error?y.message:String(y);throw t.setOverride(n,lrt({position:i,dims:s,originalFilename:a,message:g})),y}t.setOverride(n,crt({path:h,dims:s,originalFilename:a,lastUsed:c}));const u=Ure({path:h,dims:s,originalFilename:a,lastUsed:c}),f={id:n,type:"image",position:i,data:u};await t.createNode(o,f),t.forgetRetry(n)};if(t.history){await t.history.batch("insert-image",l);return}await l()},urt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",hrt=248;function ia(e=10){let t="";const n=new Uint8Array(e*2);for(;t.length<e;){crypto.getRandomValues(n);for(let o=0;o<n.length&&t.length<e;o++){const r=n[o];r<hrt&&(t+=urt[r%62])}}return t}const frt=new Set(["INPUT","TEXTAREA","SELECT"]),hr=e=>e?frt.has(e.tagName)?!0:e instanceof HTMLElement&&e.isContentEditable:!1,prt=(e,t,n)=>{const o=e.indexOf(t);if(o<0)return null;const r=e.length,a=[...e];switch(n.op){case"forward":{if(o>=r-1)return null;const i=a[o],s=a[o+1];return i===void 0||s===void 0?null:(a[o]=s,a[o+1]=i,a)}case"backward":{if(o<=0)return null;const i=a[o],s=a[o-1];return i===void 0||s===void 0?null:(a[o]=s,a[o-1]=i,a)}case"toFront":{if(o===r-1)return null;const[i]=a.splice(o,1);return i===void 0?null:(a.push(i),a)}case"toBack":{if(o===0)return null;const[i]=a.splice(o,1);return i===void 0?null:(a.unshift(i),a)}case"toIndex":{const i=Math.min(Math.max(n.index,0),r-1);if(i===o)return null;const[s]=a.splice(o,1);return s===void 0?null:(a.splice(i,0,s),a)}}};function yrt({project:e,flow:t,slug:n,demos:o,detail:r,loading:a,runs:i,nodeEvents:s,statusByNode:c,externalReloadSignal:l,onPlayNode:h,refreshFlows:u}){var Z0,X0;const f=o.find(V=>V.slug===n),{flows:y,createFlow:g,renameFlow:k,deleteFlow:x}=BF(e),[v,M]=m.useState([]),[w,b]=m.useState([]),[C,_]=m.useState(null),S=m.useRef(v),j=m.useRef(w);m.useEffect(()=>{S.current=v},[v]),m.useEffect(()=>{j.current=w},[w]);const P=m.useRef(null),A=m.useRef(null),N=AZ(),R=AZ(),W=IZ(),$=IZ(),[H,T]=m.useState(null),[O,I]=m.useState(null),[z,L]=m.useState({kind:"select"}),F=m.useRef({kind:"select"});m.useEffect(()=>{F.current=z},[z]);const[D,E]=m.useState(!1),K=m.useRef(new Set),X=`${e}/${t}`,Y=!K.current.has(X);m.useEffect(()=>{K.current.add(X)},[X]);const Q=m.useRef(null),te=m.useCallback(V=>{Q.current=V},[]),{reset:ne}=N,{reset:ie}=R,{reset:ke}=W,{reset:ge}=$;m.useEffect(()=>{M([]),b([]),_(null),ne(),ie(),ke(),ge(),T(null),I(null),nr.current=null,vn(!1),Gn.current.clear()},[r==null?void 0:r.id]);const ve=m.useCallback((V,q)=>{M(V),b(q)},[]),ce=(Z0=r==null?void 0:r.flow)==null?void 0:Z0.nodes,Ce=(X0=r==null?void 0:r.flow)==null?void 0:X0.connectors,{pruneAgainst:Re}=N,{pruneAgainst:st}=R,{pruneAgainst:Vt}=W,{pruneAgainst:It}=$;m.useEffect(()=>{if(!(!ce||!H)&&ce.length===H.length){for(let V=0;V<ce.length;V++){const q=ce[V],U=H[V];if(!q||q.id!==U)return}T(null)}},[ce,H]);const pe=(r==null?void 0:r.id)??null,se=m.useMemo(()=>MDe({baseUrl:"",project:e,flow:t}),[e,t]),we=m.useRef({nodes:[],connectors:[]});m.useEffect(()=>{we.current={nodes:ce??[],connectors:Ce??[]}},[ce,Ce]);const{adapter:re,history:Be}=m.useMemo(()=>EDe(se,()=>we.current),[se,pe]);m.useEffect(()=>{ce&&(Re(ce),Vt(ce))},[ce,Re,Vt]),m.useEffect(()=>{Ce&&(st(Ce),It(Ce))},[Ce,st,It]);const an=m.useRef(!1);m.useEffect(()=>{if(!an.current){an.current=!0;return}Be.markExternalChange()},[l,Be]);const[J,ue]=m.useState(!1),[je,Ue]=m.useState(!1),[Ke,Bt]=m.useState(null),[un,Ut]=m.useState(null),{setOverride:xe,dropOverride:Ae}=N,Tt=m.useRef(N.overrides);m.useEffect(()=>{Tt.current=N.overrides},[N.overrides]);const jn=m.useCallback((V,q)=>{!pe||!re||(xe(V,{position:q}),I(null),re.updateNodePosition(V,q).catch(U=>{Ae(V),I(U instanceof Error?U.message:String(U)),console.error("updateNodePosition failed",U)}))},[pe,re,xe,Ae]),Nt=m.useCallback(V=>{if(!pe||!re||V.length===0)return;const q=V.map(U=>(ce==null?void 0:ce.find(ee=>ee.id===U.id))?{id:U.id,next:U.position}:null).filter(U=>U!==null);if(q.length!==0){for(const U of q)xe(U.id,{position:U.next});I(null),Be.batch("move-nodes",async()=>{for(const U of q)await re.updateNodePosition(U.id,U.next)}).catch(U=>{for(const G of q)Ae(G.id);I(U instanceof Error?U.message:String(U)),console.error("updateNodePosition batch failed",U)})}},[pe,re,Be,ce,xe,Ae]),ho=m.useCallback((V,q)=>{xe(V,{position:{x:q.x,y:q.y},data:{width:q.width,height:q.height}})},[xe]),Ea=m.useCallback((V,q)=>{if(!pe||!re)return;const U={width:q.width,height:q.height,position:{x:q.x,y:q.y}};xe(V,{position:U.position,data:{width:U.width,height:U.height}}),I(null),re.updateNode(V,U).catch(G=>{Ae(V),I(G instanceof Error?G.message:String(G)),console.error("updateNode resize failed",G)})},[pe,re,xe,Ae]),Wt=m.useCallback(V=>{if(!pe||!re)return;const q={autoSize:!0};xe(V,{data:{autoSize:!0,width:void 0,height:void 0}}),I(null),re.updateNode(V,q).catch(U=>{Ae(V),I(U instanceof Error?U.message:String(U)),console.error("updateNode (fit-to-content) failed",U)})},[pe,re,xe,Ae]),Wd=m.useCallback(V=>{if(!pe||!re||V.length===0)return;const q=[];for(const G of V){if(!(ce==null?void 0:ce.find(it=>it.id===G.id)))continue;const He={position:G.position};G.width!==void 0&&(He.width=G.width),G.height!==void 0&&(He.height=G.height),q.push({id:G.id,next:He})}if(q.length===0)return;for(const G of q){const ee={};G.next.width!==void 0&&(ee.width=G.next.width),G.next.height!==void 0&&(ee.height=G.next.height),xe(G.id,{position:G.next.position,...Object.keys(ee).length>0?{data:ee}:{}})}I(null);const U=q.map(G=>G.id).slice().sort().join(",");Be.batch("multi-resize",async()=>{for(const G of q)await re.updateNode(G.id,G.next)},{coalesceKey:`multi:resize:${U}`}).catch(G=>{for(const ee of q)Ae(ee.id);I(G instanceof Error?G.message:String(G)),console.error("updateNode multi-resize batch failed",G)})},[pe,re,Be,ce,xe,Ae]),{setOverride:Et,dropOverride:Yt}=R,Gd=m.useCallback((V,q)=>{xe(V,{data:q})},[xe]),Zd=m.useCallback((V,q)=>{for(const U of V)xe(U,{data:q})},[xe]),Xd=m.useCallback((V,q)=>{Et(V,q)},[Et]),Kd=m.useCallback((V,q)=>{!pe||!re||(jU(Xa,q),xe(V,{data:q}),I(null),re.updateNode(V,q).catch(U=>{Ae(V),I(U instanceof Error?U.message:String(U)),console.error("updateNode style failed",U)}))},[pe,re,xe,Ae]),Yd=m.useCallback((V,q)=>{if(!pe||!re||V.length===0)return;jU(Xa,q);const U=V.filter(G=>ce==null?void 0:ce.some(ee=>ee.id===G));if(U.length!==0){for(const G of U)xe(G,{data:q});I(null),Be.batch("style-nodes",async()=>{for(const G of U)await re.updateNode(G,q)}).catch(G=>{for(const ee of U)Ae(ee);I(G instanceof Error?G.message:String(G)),console.error("updateNode style-nodes batch failed",G)})}},[pe,re,Be,ce,xe,Ae]),Qd=m.useCallback((V,q)=>{!pe||!re||(mDe(Xa,q),Et(V,q),I(null),re.updateConnector(V,q).catch(U=>{Yt(V),I(U instanceof Error?U.message:String(U)),console.error("updateConnector failed",U)}))},[pe,re,Et,Yt]),{mark:qi,markMany:Fi,unmark:Vi,unmarkMany:Bi}=W,{markMany:Vr,unmarkMany:Br}=$,Jd=m.useCallback(V=>{if(!pe||!re||!(ce==null?void 0:ce.find(ee=>ee.id===V)))return;const U=(Ce??[]).filter(ee=>ee.source===V||ee.target===V).map(ee=>ee.id),G=new Set(U);I(null),qi(V),U.length>0&&Vr(U),M(ee=>ee.filter(He=>He!==V)),b(ee=>ee.filter(He=>!G.has(He))),re.deleteNode(V).catch(ee=>{Vi(V),U.length>0&&Br(U),I(ee instanceof Error?ee.message:String(ee)),console.error("deleteNode failed",ee)})},[pe,re,ce,Ce,qi,Vr,Vi,Br]),eu=m.useCallback((V,q)=>{if(!pe||!re||!ce)return;const U=H??ce.map(ee=>ee.id),G=prt(U,V,q);G&&(T(G),I(null),re.reorderNode(V,q).catch(ee=>{T(null),I(ee instanceof Error?ee.message:String(ee)),console.error("reorderNode failed",ee)}))},[pe,re,ce,H]),Te=m.useCallback((V,q)=>{if(!pe||!re||V.length===0&&q.length===0)return;const U=new Set(V),G=V.map(Oe=>ce==null?void 0:ce.find(wn=>wn.id===Oe)).filter(Oe=>!!Oe),ee=(Ce??[]).filter(Oe=>U.has(Oe.source)||U.has(Oe.target)),He=new Set(ee.map(Oe=>Oe.id)),it=q.map(Oe=>Ce==null?void 0:Ce.find(wn=>wn.id===Oe)).filter(Oe=>!!Oe).filter(Oe=>!He.has(Oe.id));if(G.length===0&&ee.length===0&&it.length===0)return;I(null);const ot=G.map(Oe=>Oe.id),ft=[...ee.map(Oe=>Oe.id),...it.map(Oe=>Oe.id)];ot.length>0&&Fi(ot),ft.length>0&&Vr(ft);const Zn=G;M(Oe=>Oe.filter(wn=>!U.has(wn)));const Qr=new Set(it.map(Oe=>Oe.id));b(Oe=>Oe.filter(wn=>!Qr.has(wn)&&!He.has(wn))),Be.batch("delete-selection",async()=>{for(const Oe of Zn)await re.deleteNode(Oe.id);await Promise.all(it.map(Oe=>re.deleteConnector(Oe.id)))}).catch(Oe=>{ot.length>0&&Bi(ot),ft.length>0&&Br(ft),I(Oe instanceof Error?Oe.message:String(Oe)),console.error("deleteSelection batch failed",Oe)})},[pe,re,Be,ce,Ce,Fi,Vr,Bi,Br]);m.useEffect(()=>{P.current=Te},[Te]),m.useEffect(()=>{const V=q=>{if(q.key!=="Delete"&&q.key!=="Backspace"||hr(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const U=S.current,G=j.current;U.length===0&&G.length===0||(q.preventDefault(),Te(U,G))};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[Te]);const $t=m.useCallback((V,q)=>{!pe||!re||(xe(V,{data:{name:q}}),I(null),re.updateNode(V,{name:q}).catch(U=>{I(U instanceof Error?U.message:String(U)),console.error("updateNode name failed",U)}))},[pe,re,xe]),Ur=m.useCallback((V,q)=>{!pe||!re||(xe(V,{data:{description:q}}),I(null),re.updateNode(V,{description:q}).catch(U=>{I(U instanceof Error?U.message:String(U)),console.error("updateNode description failed",U)}))},[pe,re,xe]),Ui=m.useCallback((V,q)=>{!pe||!re||(xe(V,{data:{detail:q}}),I(null),re.updateNode(V,{detail:q}).catch(U=>{I(U instanceof Error?U.message:String(U)),console.error("updateNode detail failed",U)}))},[pe,re,xe]),er=m.useCallback((V,q)=>{!pe||!re||(xe(V,{data:{icon:q??void 0}}),I(null),re.updateNode(V,{icon:q}).catch(U=>{I(U instanceof Error?U.message:String(U)),console.error("updateNode icon failed",U)}))},[pe,re,xe]),tr=m.useCallback((V,q,U)=>{if(!pe||!re)return;I(null);const G=`node-${ia()}`,ee=zU(V,U,_2(Xa).node),He={id:G,type:V,position:q,data:ee};xe(G,{id:G,type:V,position:q,data:ee}),re.createNode(He).catch(ot=>{Ae(G),I(ot instanceof Error?ot.message:String(ot)),console.error("createNode failed",ot)})},[pe,re,xe,Ae]),Wr=m.useCallback((V,q)=>{if(!pe||!re)return;I(null);const U=`node-${ia()}`,G={icon:V,width:v0.width,height:v0.height},ee={id:U,type:"icon",position:q,data:G};xe(U,{id:U,type:"icon",position:q,data:G}),M([U]),re.createNode(ee).catch(it=>{Ae(U),I(it instanceof Error?it.message:String(it)),console.error("createNode (icon) failed",it)})},[pe,re,xe,Ae]),fo=m.useCallback(V=>{if(!pe||!re)return;I(null);const q=`node-${ia()}`,U={id:q,type:"html",position:V.position,data:{}},G={id:q,type:"html",position:V.position,data:{}};xe(q,G),M([q]),re.createNode(U).catch(ee=>{Ae(q),I(ee instanceof Error?ee.message:String(ee)),console.error("createNode (type:'html') failed",ee)})},[pe,re,xe,Ae]),Gn=m.useRef(new Map),hn=m.useCallback((V,q)=>{Gn.current.set(V,q)},[]),Qt=m.useCallback(V=>{Gn.current.delete(V)},[]),po=m.useCallback(V=>{!pe||!re||(I(null),drt({...V,flowId:pe,lastUsed:_2(Xa).node},{upload:async(q,U,G,ee)=>re.uploadImage(U,await zNe(G),ee),createNode:async(q,U)=>{const{id:G}=await re.createNode(U);return{id:G}},setOverride:xe,history:Be,rememberRetry:hn,forgetRetry:Qt}).catch(q=>{console.error("image-upload-flow failed",q)}))},[pe,re,Be,xe,hn,Qt]),Wi=m.useCallback(V=>{if(!pe||!re)return;const q=`node-${ia()}`;po({nodeId:q,...V})},[pe,re,po]),tu=m.useCallback(V=>{const q=Gn.current.get(V);q&&po({nodeId:V,...q})},[po]),[Ao,Gi]=m.useState({open:!1,mode:"insert"}),kt=m.useCallback((V,q)=>{Gi({open:!0,mode:V,nodeId:q})},[]),yo=m.useCallback(()=>{Gi(V=>({...V,open:!1}))},[]),$a=m.useCallback(()=>{kt("insert")},[kt]),Zi=m.useCallback(V=>kt("replace",V),[kt]),Gr=m.useCallback(V=>{if(aDe(V),Ao.mode==="replace"&&Ao.nodeId){if(pe&&re){const q=Ao.nodeId;xe(q,{data:{icon:V}}),I(null),re.updateNode(q,{icon:V}).catch(U=>{Ae(q),I(U instanceof Error?U.message:String(U)),console.error("updateNode (icon replace) failed",U)})}}else{const q=Q.current;if(q&&pe){const U=oDe(q,{width:window.innerWidth,height:window.innerHeight});Wr(V,U)}}yo()},[Ao.mode,Ao.nodeId,pe,re,xe,Ae,Wr,yo]),Zr=m.useCallback((V,q)=>{!pe||!re||(Et(V,{label:q}),I(null),re.updateConnector(V,{label:q}).catch(U=>{I(U instanceof Error?U.message:String(U)),console.error("updateConnector label failed",U)}))},[pe,re,Et]),nu=m.useCallback((V,q,U)=>{if(!pe||!re)return;const G=`conn-${ia()}`,ee=U==null?void 0:U.targetPin,He=_2(Xa).connector,it={id:G,source:V,target:q,sourceHandleAutoPicked:!0,targetHandleAutoPicked:!0,...ee?{targetPin:ee}:{},...He},ot={id:G,source:V,target:q,sourceHandleAutoPicked:!0,targetHandleAutoPicked:!0,...ee?{targetPin:ee}:{},...He};Et(G,it),I(null),re.createConnector(ot).catch(ft=>{Yt(G),I(ft instanceof Error?ft.message:String(ft)),console.error("createConnector failed",ft)})},[pe,re,Et,Yt]),Xi=m.useCallback(({sourceNodeId:V,position:q,shape:U})=>{if(!pe||!re)return;I(null);const G=`node-${ia()}`,ee=`conn-${ia()}`,He=tz[U],it=_2(Xa),ot=zU(U,He,it.node),ft={id:G,type:U,position:q,data:ot},Zn={id:ee,source:V,target:G,sourceHandleAutoPicked:!0,targetHandleAutoPicked:!0,...it.connector};xe(G,{id:G,type:U,position:q,data:ot}),Et(ee,Zn),_(G),Be.batch("create-and-connect",async()=>{await re.createNode(ft),await re.createConnector(Zn)}).catch(Oe=>{Ae(G),Yt(ee),I(Oe instanceof Error?Oe.message:String(Oe)),console.error("createAndConnectFromPane failed",Oe)})},[pe,re,Be,xe,Ae,Et,Yt]),nr=m.useRef(null),[Xr,vn]=m.useState(!1),[or,rr]=m.useState(()=>({canUndo:Be.canUndo,canRedo:Be.canRedo}));m.useEffect(()=>Be.subscribe(rr),[Be]);const Eo=m.useCallback(V=>{if(!ce)return;const q=new Set(V),U=ce.filter(ee=>q.has(ee.id));if(U.length===0)return;const G=(Ce??[]).filter(ee=>q.has(ee.source)&&q.has(ee.target));nr.current=JSON.parse(JSON.stringify({nodes:U,connectors:G})),vn(!0)},[ce,Ce]),xn=m.useCallback(V=>{if(!pe||!re)return;const q=nr.current;if(!q||q.nodes.length===0)return;const{newNodes:U,newConnectors:G}=irt({nodes:q.nodes,connectors:q.connectors,flowPos:V,nodeIdGen:()=>`node-${ia()}`,connectorIdGen:()=>`conn-${ia()}`});for(const ee of U)xe(ee.id,ee);for(const ee of G)Et(ee.id,ee);M(U.map(ee=>ee.id)),b(G.map(ee=>ee.id)),I(null),Be.batch("paste",async()=>{for(const ee of U)await re.createNode({id:ee.id,type:ee.type,position:ee.position,data:ee.data});for(const ee of G)await re.createConnector(ee)}).catch(ee=>{for(const He of U)Ae(He.id);for(const He of G)Yt(He.id);I(ee instanceof Error?ee.message:String(ee)),console.error("paste failed",ee)})},[pe,re,Be,xe,Ae,Et,Yt]);m.useEffect(()=>{const V=q=>{const U=fDe({event:q,isEditableActive:hr(document.activeElement),hasNodes:!!ce&&ce.length>0,hasConnectors:!!Ce&&Ce.length>0,selectedIds:S.current,hasClipboard:!!nr.current});if(U.type!=="noop"&&!(U.type==="copy"||U.type==="paste")){if(q.preventDefault(),U.type==="selectAll"){M((ce??[]).map(G=>G.id)),b((Ce??[]).map(G=>G.id));return}Eo([...U.ids]),xn(null)}};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[ce,Ce,Eo,xn]),m.useEffect(()=>{const V=q=>{const U=dDe(q);if(!U||hr(document.activeElement))return;const G=S.current;if(G.length===0)return;const ee=N.overrides,He=(ce??[]).map(ot=>{var Zn;const ft=((Zn=ee[ot.id])==null?void 0:Zn.position)??ot.position;return{id:ot.id,position:ft}}),it=hDe(U,G,He);if(it.length!==0)if(q.preventDefault(),it.length===1){const ot=it[0];ot&&jn(ot.id,ot.position)}else Nt(it)};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[ce,N.overrides,jn,Nt]),m.useEffect(()=>{const V=q=>{const U=uDe(q);if(!U||hr(document.activeElement))return;q.preventDefault();const G=Q.current;G&&(U==="fit"?G.fitView({padding:.2,duration:200}):U==="in"?G.zoomIn({duration:150}):G.zoomOut({duration:150}))};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[]);const $o=m.useCallback(async V=>{if(!pe||!re||!ce||!re.computeLayout)return;const q=N.overrides,U=Q.current,G=V==="selection"?new Set(S.current):null,ee=G?ce.filter(Fe=>G.has(Fe.id)):ce;if(ee.length<2)return;const He=new Set(ee.map(Fe=>Fe.id)),it=(Ce??[]).filter(Fe=>He.has(Fe.source)&&He.has(Fe.target)),ot=new Map,ft=ee.map(Fe=>{var zn;const Mt=((zn=q[Fe.id])==null?void 0:zn.position)??Fe.position;ot.set(Fe.id,Mt);const Mn=U==null?void 0:U.getInternalNode(Fe.id),go=Mn==null?void 0:Mn.measured,Jr=Fe.data,Qi=(go==null?void 0:go.width)??Jr.width??200,K0=(go==null?void 0:go.height)??Jr.height??120;return{id:Fe.id,type:Fe.type,width:Qi,height:K0}}),Zn=it.map(Fe=>({id:Fe.id,source:Fe.source,target:Fe.target})),Qr=await re.computeLayout(ft,Zn),Oe=new Map;for(const[Fe,Mt]of Object.entries(Qr.nodes))Oe.set(Fe,Mt.position);let wn=Number.POSITIVE_INFINITY,ru=Number.POSITIVE_INFINITY,au=Number.POSITIVE_INFINITY,iu=Number.POSITIVE_INFINITY;for(const Fe of ft){const Mt=ot.get(Fe.id);if(!Mt)continue;Mt.x<wn&&(wn=Mt.x),Mt.y<ru&&(ru=Mt.y);const Mn=Oe.get(Fe.id);Mn&&(Mn.x<au&&(au=Mn.x),Mn.y<iu&&(iu=Mn.y))}const Af=Number.isFinite(wn)&&Number.isFinite(au)?wn-au:0,ER=Number.isFinite(ru)&&Number.isFinite(iu)?ru-iu:0,Yi=[];for(const Fe of ft){const Mt=ot.get(Fe.id),Mn=Oe.get(Fe.id);if(!Mt||!Mn)continue;const go={x:Mn.x+Af,y:Mn.y+ER},Jr=go.x-Mt.x,Qi=go.y-Mt.y;Math.abs(Jr)<1&&Math.abs(Qi)<1||Yi.push({id:Fe.id,prev:Mt,next:go})}if(Yi.length!==0){I(null);for(const Fe of Yi)xe(Fe.id,{position:Fe.next});Be.batch("tidy",async()=>{for(const Fe of Yi)await re.updateNodePosition(Fe.id,Fe.next)}).catch(Fe=>{for(const Mt of Yi)Ae(Mt.id);I(Fe instanceof Error?Fe.message:String(Fe)),console.error("Tidy batch failed",Fe)})}},[pe,re,Be,ce,Ce,N.overrides,xe,Ae]);m.useEffect(()=>{const V=q=>{if(!(q.metaKey||q.ctrlKey)||!q.shiftKey||q.altKey||q.key.toLowerCase()!=="l"||hr(document.activeElement))return;q.preventDefault();const U=S.current.length>0?"selection":"all";$o(U)};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[$o]);const ja=m.useCallback(()=>{const V=S.current.length>0?"selection":"all";$o(V)},[$o]);m.useEffect(()=>{const V=q=>{if(hr(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const U=yDe(q);if(U===null)return;const G=F.current;if(U==="select"){G.kind!=="select"&&L({kind:"select"});return}if(U==="hand"){L(G.kind==="hand"?{kind:"select"}:{kind:"hand"});return}if(G.kind==="draw"&&G.shape===U){L({kind:"select"});return}L({kind:"draw",shape:U})};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[]),m.useEffect(()=>{const V=q=>{if(q.key!=="Escape"||hr(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;if(F.current.kind!=="select"){L({kind:"select"});return}S.current.length>0&&M([]),j.current.length>0&&b([])};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[]),m.useEffect(()=>{const V=q=>{if(q.key.toLowerCase()!=="f"||q.metaKey||q.ctrlKey||q.shiftKey||q.altKey||hr(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const U=S.current;if(U.length===0)return;const G=Q.current;G&&G.fitView({nodes:U.map(ee=>({id:ee})),padding:.2,duration:200})};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[]),m.useEffect(()=>{const V=q=>{if(q.key!=="1"||q.metaKey||q.ctrlKey||q.shiftKey||q.altKey||hr(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const U=Q.current;if(!U)return;const{x:G,y:ee}=U.getViewport();U.setViewport({x:G,y:ee,zoom:1},{duration:150})};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[]);const Pn=m.useCallback(V=>{var q,U;switch(V){case"tool.select":L({kind:"select"});return;case"tool.hand":L({kind:"hand"});return;case"tool.rectangle":L({kind:"draw",shape:"rectangle"});return;case"tool.ellipse":L({kind:"draw",shape:"ellipse"});return;case"tool.text":L({kind:"draw",shape:"text"});return;case"tool.sticky":L({kind:"draw",shape:"sticky"});return;case"tool.database":L({kind:"draw",shape:"database"});return;case"edit.undo":{if(!Be.canUndo)return;Be.undo().catch(G=>{I(G instanceof Error?G.message:String(G)),console.error("undo failed",G)});return}case"edit.redo":{if(!Be.canRedo)return;Be.redo().catch(G=>{I(G instanceof Error?G.message:String(G)),console.error("redo failed",G)});return}case"edit.copy":{const G=S.current;if(G.length===0)return;Eo([...G]);return}case"edit.paste":xn(null);return;case"edit.duplicate":{const G=S.current;if(G.length===0)return;Eo([...G]),xn(null);return}case"edit.delete":{const G=S.current,ee=j.current;if(G.length===0&&ee.length===0)return;Te([...G],[...ee]);return}case"edit.selectAll":M((ce??[]).map(G=>G.id)),b((Ce??[]).map(G=>G.id));return;case"view.fit":{const G=Q.current;if(!G)return;G.fitView({padding:.2,duration:200});return}case"view.zoomIn":{const G=Q.current;if(!G)return;G.zoomIn({duration:150});return}case"view.zoomOut":{const G=Q.current;if(!G)return;G.zoomOut({duration:150});return}case"view.zoom100":{const G=Q.current;if(!G)return;const{x:ee,y:He}=G.getViewport();G.setViewport({x:ee,y:He,zoom:1},{duration:150});return}case"view.zoomToSelection":{const G=S.current;if(G.length===0)return;const ee=Q.current;if(!ee)return;ee.fitView({nodes:G.map(He=>({id:He})),padding:.2,duration:200});return}case"layout.tidy":{const G=S.current.length>0?"selection":"all";$o(G);return}case"selection.deselect":S.current.length>0&&M([]),j.current.length>0&&b([]),F.current.kind!=="select"&&L({kind:"select"});return;case"help.commandPalette":E(!0);return;case"export.pdf":{(q=A.current)==null||q.exportPdf();return}case"export.png":{(U=A.current)==null||U.exportPng();return}}},[Be,Eo,xn,Te,ce,Ce,$o]);m.useEffect(()=>{const V=q=>{(q.metaKey||q.ctrlKey)&&(q.shiftKey||q.altKey||q.key.toLowerCase()==="p"&&(q.preventDefault(),!hr(document.activeElement)&&Pn("help.commandPalette")))};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[Pn]);const Pa=m.useCallback((V,q)=>{if(!pe||!re)return;const U={...q.source!==void 0?{source:q.source}:{},...q.target!==void 0?{target:q.target}:{},...q.sourceHandle!==void 0?{sourceHandle:q.sourceHandle===null?void 0:q.sourceHandle}:{},...q.targetHandle!==void 0?{targetHandle:q.targetHandle===null?void 0:q.targetHandle}:{},...q.sourceHandleAutoPicked!==void 0?{sourceHandleAutoPicked:q.sourceHandleAutoPicked}:{},...q.targetHandleAutoPicked!==void 0?{targetHandleAutoPicked:q.targetHandleAutoPicked}:{},...q.sourcePin!==void 0?{sourcePin:q.sourcePin===null?void 0:q.sourcePin}:{},...q.targetPin!==void 0?{targetPin:q.targetPin===null?void 0:q.targetPin}:{}};Et(V,U),I(null),re.updateConnector(V,q).catch(G=>{Yt(V),I(G instanceof Error?G.message:String(G)),console.error("updateConnector reconnect failed",G)})},[pe,re,Et,Yt]),ar=m.useCallback((V,q,U)=>{if(!pe||!re)return;const G=q==="source"?"sourcePin":"targetPin";Et(V,{[G]:U}),I(null),re.updateConnector(V,{[G]:U}).catch(ee=>{Yt(V),I(ee instanceof Error?ee.message:String(ee)),console.error("updateConnector pin failed",ee)})},[pe,re,Et,Yt]),za=m.useCallback((V,q)=>{if(!pe||!re)return;const U=Ce==null?void 0:Ce.find(He=>He.id===V);if(!(U?q==="source"?U.sourcePin:U.targetPin:void 0))return;const ee=q==="source"?"sourcePin":"targetPin";Et(V,{[ee]:void 0}),I(null),re.updateConnector(V,{[ee]:null}).catch(He=>{Yt(V),I(He instanceof Error?He.message:String(He)),console.error("updateConnector unpin failed",He)})},[pe,re,Ce,Et,Yt]),ct=r==null?void 0:r.flow,Ra=N.overrides,ir=R.overrides,mo=W.ids,Kr=$.ids,Ta=m.useMemo(()=>{if(!ct||v.length===0)return[];const V=new Map(ct.nodes.map(U=>[U.id,U])),q=[];for(const U of v){const G=V.get(U);if(!G)continue;const ee=Ra[U];if(!ee){q.push(G);continue}const He=ee.data?{...G.data,...ee.data}:G.data;q.push({...G,...ee,data:He})}return q},[ct,v,Ra]),ou=m.useMemo(()=>{if(!ct||w.length===0)return[];const V=new Map(ct.connectors.map(U=>[U.id,U])),q=[];for(const U of w){const G=V.get(U);if(!G)continue;const ee=ir[U];q.push(ee?{...G,...ee}:G)}return q},[ct,w,ir]),Nf=m.useMemo(()=>{if(!ct)return null;if(!H)return ct.nodes;const V=new Map(ct.nodes.map(G=>[G.id,G])),q=[],U=new Set;for(const G of H){const ee=V.get(G);ee&&(q.push(ee),U.add(G))}for(const G of ct.nodes)U.has(G.id)||q.push(G);return q},[ct,H]),NR=m.useMemo(()=>{const V=Nf??(ct==null?void 0:ct.nodes)??null;return V?mo.size===0?V:V.filter(q=>!mo.has(q.id)):null},[Nf,ct,mo]),AR=m.useMemo(()=>{const V=(ct==null?void 0:ct.connectors)??null;return V?Kr.size===0&&mo.size===0?V:V.filter(q=>!Kr.has(q.id)&&!mo.has(q.source)&&!mo.has(q.target)):null},[ct,Kr,mo]),Yr=(y==null?void 0:y.some(V=>V.flowSlug===t))??!1;if(!f&&!Yr&&!(y===null))return p.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[p.jsxs("p",{className:"text-sm font-medium",children:["Unknown demo: ",n]}),p.jsx("p",{className:"text-xs text-muted-foreground",children:"The slug may have been removed. Re-register from the project repo to bring it back."})]});if(!f||a&&!r)return p.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:"Loading demo…"});const G0=v[0],Da=G0?c[G0]:void 0;return p.jsxs("div",{className:"relative h-full w-full",children:[r&&!r.valid?p.jsxs("div",{"data-testid":"demo-error-banner",className:"absolute inset-x-0 top-0 z-10 border-b border-rose-500/40 bg-rose-50 px-4 py-2 text-xs text-rose-900 shadow-xs dark:bg-rose-950/40 dark:text-rose-100",children:[p.jsx("span",{className:"font-medium uppercase tracking-wide",children:"Invalid demo: "}),p.jsx("span",{className:"font-mono",children:r.error})]}):null,p.jsx(Zot,{open:je,onOpenChange:Ue,onCreate:g,onCreated:async V=>{await u(),K.current.add(`${e}/${V.flowSlug}`),Nr(di(e,V.flowSlug))}}),p.jsx(Kot,{open:Ke!==null,onOpenChange:V=>{V||Bt(null)},flow:Ke,onRename:k,onRenamed:async(V,q)=>{await u(),V.flowSlug!==q&&(K.current.add(`${e}/${V.flowSlug}`),Nr(di(e,V.flowSlug)))}}),p.jsx(Xot,{open:un!==null,onOpenChange:V=>{V||Ut(null)},flow:un,flows:y??[],onDelete:x,onDeleted:async(V,q)=>{var G;if(await u(),V!==t)return;const U=q??((G=y==null?void 0:y.find(ee=>ee.isDefault&&ee.flowSlug!==V))==null?void 0:G.flowSlug);U&&Nr(di(e,U))}}),ct&&re?p.jsx(vnt,{ref:A,mode:"edit",adapter:re,history:Be,topRightSlot:p.jsx(Yot,{project:e,activeFlow:t,flows:y??[],onSelect:V=>{V!==t&&Nr(di(e,V))},onCreate:()=>Ue(!0),onRename:V=>{const q=y==null?void 0:y.find(U=>U.flowSlug===V);q&&Bt({flowSlug:q.flowSlug,name:q.name,icon:q.icon})},onDelete:V=>{const q=y==null?void 0:y.find(U=>U.flowSlug===V);q&&Ut({flowSlug:q.flowSlug,name:q.name,isDefault:q.isDefault})}}),projectId:e,flowSlug:t,enableEmbed:!1,onExportToCloud:pe?()=>ue(!0):void 0,nodes:NR??ct.nodes,connectors:AR??ct.connectors,selectedNodeIds:v,selectedConnectorIds:w,onSelectionChange:ve,runtime:{runs:i,statuses:c,pendingOverrides:{nodes:Ra,connectors:ir}},onPlayNode:h,onNodePositionChange:jn,onNodePositionsChange:Nt,onNodeResize:ho,onNodeResizeEnd:Ea,onHtmlNodeFitToContent:Wt,onComponentNodeFitToContent:Wt,onMultiResize:Wd,onNodeNameChange:$t,onNodeDescriptionChange:Ur,onConnectorLabelChange:Zr,onCreateShapeNode:tr,onCreateImageFromFile:pe?Wi:void 0,onRetryImageUpload:pe?tu:void 0,onCreateHtmlNode:pe?fo:void 0,iconPickerOpen:Ao.open,onOpenIconPicker:pe?$a:void 0,onCloseIconPicker:pe?yo:void 0,onPickIcon:pe?Gr:void 0,onRequestIconReplace:pe?Zi:void 0,onCreateConnector:nu,onReconnectConnector:Pa,onPinEndpoint:pe?ar:void 0,onUnpinEndpoint:pe?za:void 0,onReorderNode:eu,onDeleteNode:Jd,onCopyNode:V=>Eo([V]),onPasteAt:xn,onCopySelection:pe?Eo:void 0,onPasteSelection:pe?()=>xn(null):void 0,hasClipboard:Xr,selectedNodes:Ta,selectedConnectors:ou,onStyleNode:Kd,onStyleNodePreview:Gd,onStyleNodes:Yd,onStyleNodesPreview:Zd,onStyleConnector:Qd,onStyleConnectorPreview:Xd,onRfInit:te,onTidy:ce?ja:void 0,onCreateAndConnectFromPane:Xi,pendingEditNodeId:C,canvasMode:z,onCanvasModeChange:L,statusReport:Da,onNameChange:$t,onDescriptionChange:Ur,onDetailChange:Ui,onIconChange:er,autoFitView:Y},`${e}/${t}`):p.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:"No demo data yet."}),O?p.jsxs("div",{"data-testid":"edit-error-banner",className:"absolute inset-x-0 bottom-4 z-20 mx-auto w-fit max-w-[80%] rounded-md border border-rose-500/50 bg-rose-50 px-3 py-2 text-xs text-rose-900 shadow-md dark:bg-rose-950/60 dark:text-rose-100",children:[p.jsx("span",{className:"font-medium",children:"Couldn't save change: "}),p.jsx("span",{className:"font-mono",children:O}),p.jsx("button",{type:"button",className:"ml-3 underline underline-offset-2",onClick:()=>I(null),children:"Dismiss"})]}):null,p.jsx(yot,{open:D,onOpenChange:E,runCommand:Pn,ctx:{hasSelection:v.length>0||w.length>0,canUndo:or.canUndo,canRedo:or.canRedo,hasClipboard:Xr,canExportDemo:!!pe}}),pe?p.jsx(Bot,{open:J,onOpenChange:ue,project:e,flowName:(r==null?void 0:r.name)??f.name,onCapturePreview:()=>{var V;return((V=A.current)==null?void 0:V.capturePreview())??Promise.resolve(void 0)}}):null]})}const EZ="npx seeflow register --path .";function mrt(){const[e,t]=m.useState(!1),n=async()=>{try{await navigator.clipboard.writeText(EZ),t(!0),setTimeout(()=>t(!1),1200)}catch(o){console.error("[empty-state] copy failed",o)}};return p.jsx("div",{"data-testid":"seeflow-empty-state",className:"flex h-full w-full items-center justify-center bg-background p-6",children:p.jsxs("div",{className:"flex max-w-lg flex-col items-center gap-6 text-center",children:[p.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-muted",children:p.jsx(znt,{className:"h-6 w-6 text-muted-foreground"})}),p.jsxs("div",{className:"space-y-2",children:[p.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-foreground",children:"No demos registered yet"}),p.jsxs("p",{className:"text-sm text-muted-foreground",children:["Point SeeFlow at any folder containing a"," ",p.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 text-xs",children:"flow.json"})," file and it'll appear here."]})]}),p.jsxs("div",{className:"flex w-full items-center gap-2 rounded-md border border-border bg-card px-3 py-2 font-mono text-sm",children:[p.jsx("span",{className:"text-muted-foreground select-none",children:"$"}),p.jsx("code",{className:"flex-1 truncate text-left",children:EZ}),p.jsx(ut,{type:"button",variant:"ghost",size:"sm",onClick:n,"aria-label":"Copy register command",children:e?p.jsx(_re,{className:"h-4 w-4"}):p.jsx(Sre,{className:"h-4 w-4"})})]})]})})}function grt({demos:e}){return e.length===0?p.jsx(mrt,{}):p.jsx("div",{className:"flex h-full w-full items-start justify-center overflow-y-auto bg-background p-8",children:p.jsxs("div",{"data-testid":"studio-home-picker",className:"flex w-full max-w-2xl flex-col gap-6 pt-8",children:[p.jsxs("div",{className:"space-y-1",children:[p.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Open a demo"}),p.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.length," demos registered — pick one to load its canvas."]})]}),p.jsx("ul",{className:"flex flex-col gap-2",children:e.map(t=>p.jsx("li",{children:p.jsxs("button",{type:"button",onClick:()=>Nr(Mre(t.slug)),"data-testid":`studio-home-demo-${t.slug}`,className:"flex w-full flex-col items-start gap-0.5 rounded-lg border border-border bg-card px-4 py-3 text-left transition-colors hover:border-input",style:{boxShadow:"var(--shadow-card)"},children:[p.jsx("span",{className:"text-sm font-medium",children:t.name}),p.jsx("span",{className:"truncate text-xs text-muted-foreground",children:t.repoPath})]})},t.id))})]})})}function krt(){const e=Cnt(),{demos:t,refresh:n}=Xnt(),{projects:o,refresh:r,unregisterProject:a}=iot(),i=Snt(e),s=(i==null?void 0:i.project)??null,c=(i==null?void 0:i.flow)??null,l=Lnt(e),h=(l==null?void 0:l.project)??null,{flows:u}=BF(h);sot({onRegistryReload:()=>{n(),r()}});const f=i?`${i.project}/${i.flow}`:null,y=f?(t??[]).find(I=>I.slug===f):void 0,g=(y==null?void 0:y.id)??null;m.useEffect(()=>{f&&t!==null&&(y||n())},[f,t,y,n]);const{detail:k,loading:x,refresh:v,applyDetail:M}=Znt(s,c),[w,b]=m.useState(0),{runs:C,apply:_}=tot(g),{events:S,apply:j}=Jnt(g),{statusByNode:P,apply:A,reset:N}=aot(g),R=m.useCallback(()=>{N(),v(),n()},[v,n,N]),W=m.useCallback(I=>{if(!g||!y)return;const z={id:g,slug:y.slug,filePath:""},L=I.valid?{...z,name:I.flow.name??y.name,flow:I.flow,valid:!0,error:null}:{...z,name:y.name,flow:null,valid:!1,error:I.error};M(L),b(F=>F+1)},[g,y,M]),$=m.useCallback(I=>{_(I),j(I),A(I)},[_,j,A]);cot(g,{onHello:R,onFlowReload:W,onEvent:$});const H=m.useCallback(I=>{mZ(I.id),n(),r()},[n,r]),T=m.useCallback(async I=>{await a(I),await n(),s===I&&Nr("/")},[a,n,s]);m.useEffect(()=>{if(e!=="/"||t===null)return;const I=uot(t,dot());I&&Nr(Mre(I.slug))},[e,t]),m.useEffect(()=>{y&&mZ(y.id)},[y]),m.useEffect(()=>{s&&c&&Mnt(s,c)},[s,c]),m.useEffect(()=>{if(!h||!u)return;const I=bnt(u,wre(h));I&&Nr(di(h,I))},[h,u]);const O=m.useCallback(I=>{!s||!c||sce(s,c,I).catch(z=>{_({type:"node:error",nodeId:I,message:z instanceof Error?z.message:String(z),ts:Date.now()})})},[s,c,_]);return t===null?p.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background text-sm text-muted-foreground",children:"Loading…"}):p.jsx(dh,{delayDuration:150,children:p.jsxs("div",{className:"flex h-full w-full flex-col bg-background text-foreground",children:[p.jsx(Gnt,{projects:o??[],currentProjectSlug:s??void 0,onProjectCreated:H,onUnregisterProject:T}),p.jsx("main",{className:"min-h-0 flex-1",children:s&&c&&f?p.jsx(yrt,{project:s,flow:c,slug:f,demos:t,detail:k,loading:x,runs:C,nodeEvents:S,statusByNode:P,externalReloadSignal:w,onPlayNode:O,refreshFlows:n}):p.jsx(grt,{demos:t})})]})})}const Wre=document.getElementById("root");if(!Wre)throw new Error("Root element #root not found");uD.createRoot(Wre).render(p.jsx(br.StrictMode,{children:p.jsx(krt,{})}));export{af as C,WYe as M,br as R,hf as _,On as a,QK as b,jG as c,sP as d,gq as e,vY as f,SGe as g,Qh as h,NGe as i,vrt as j,sh as k,_r as l,p as m,MY as n,aet as o,d$e as p,pGe as q,m as r,eo as s,AGe as t,_F as u,vGe as w,Mrt as z};
|