r.name));for(const r of e)if(r.is_computed&&r.depends_on&&r.depends_on.length>0){const i=r.depends_on.filter(o=>n.has(o));i.length>0&&a.set(r.name,i)}const t=new Map;for(const[r,i]of a)for(const o of i){const s=t.get(o)||[];s.push(r),t.set(o,s)}return{upstream:a,downstream:t}}function ib(e){if(!e||e.length===0)return{nodes:[],edges:[],sourceCount:0,computedCount:0};const{upstream:a,downstream:n}=ab(e),t=new Set;for(const c of e)c.is_computed&&t.add(c.name);for(const c of a.values())for(const d of c)t.add(d);const r=e.filter(c=>t.has(c.name));if(r.length===0)return{nodes:[],edges:[],sourceCount:0,computedCount:0};const i=[];for(const[c,d]of a)for(const f of d)t.has(f)&&i.push({id:`${f}→${c}`,source:f,target:c,type:"columnEdge"});const o=r.map(c=>({id:c.name,type:"columnNode",position:{x:0,y:0},data:{name:c.name,type:c.type,isComputed:c.is_computed,computeExpression:c.computed_with,funcName:c.func_name,funcType:c.func_type,errorCount:c.error_count,upstreamColumns:a.get(c.name)||[],downstreamColumns:n.get(c.name)||[],comment:c.comment}})),s=r.filter(c=>!c.is_computed).length,u=r.filter(c=>c.is_computed).length;return{nodes:o,edges:i,sourceCount:s,computedCount:u}}function sb(e,a){if(e.length===0)return e;const n=new Df.graphlib.Graph;n.setDefaultEdgeLabel(()=>({})),n.setGraph(nb);for(const t of e)n.setNode(t.id,{...Us});for(const t of a)n.setEdge(t.source,t.target);return Df.layout(n),e.map(t=>{const r=n.node(t.id);return{...t,position:{x:r.x-Us.width/2,y:r.y-Us.height/2}}})}function ob(e,a){return e.map(n=>{if(!a)return{...n,animated:!1,data:{...n.data,highlight:"default"}};const t=n.source===a||n.target===a;return{...n,animated:t,data:{...n.data,highlight:t?"active":"dimmed"}}})}const ub=[{test:e=>e.includes("string")||e.includes("text"),icon:_p},{test:e=>e.includes("int")||e.includes("float")||e.includes("number"),icon:wp},{test:e=>e.includes("image"),icon:Uf},{test:e=>e.includes("video"),icon:Zf},{test:e=>e.includes("audio"),icon:Xf},{test:e=>e.includes("document"),icon:Qf},{test:e=>e.includes("array")||e.includes("json"),icon:Vs},{test:e=>e.includes("embedding")||e.includes("vector"),icon:we}];function ep(e){const a=e.toLowerCase();return ub.find(n=>n.test(a))?.icon??Ep}function cb(e){return e.startsWith("Required[")&&e.endsWith("]")&&(e=e.slice(9,-1)),e.split("[")[0]}const rp={builtin:{text:"text-muted-foreground/80",bg:"bg-muted/40",label:"built-in"},custom_udf:{text:"text-k-yellow/90",bg:"bg-k-yellow/10",label:"UDF"},query:{text:"text-blue-400/90",bg:"bg-blue-400/10",label:"query"},unknown:{text:"text-muted-foreground/60",bg:"bg-muted/30",label:"fn"}};function db({id:e,sourceX:a,sourceY:n,targetX:t,targetY:r,sourcePosition:i,targetPosition:o,data:s}){const[u]=Yf({sourceX:a,sourceY:n,targetX:t,targetY:r,sourcePosition:i,targetPosition:o,borderRadius:12}),c=s?.highlight,d=M.useMemo(()=>c==="active"?{stroke:"rgba(241, 174, 3, 0.7)",strokeWidth:2.5}:c==="dimmed"?{stroke:"rgba(100, 100, 100, 0.12)",strokeWidth:1}:{stroke:"rgba(100, 100, 100, 0.35)",strokeWidth:1.5},[c]);return l.jsx(Jf,{id:e,path:u,style:d})}const lb={columnEdge:db};function fb({data:e,selected:a}){const n=e.funcType?rp[e.funcType]:null;return l.jsxs("div",{className:G("min-w-[200px] max-w-[240px] transition-all duration-150",a&&"scale-[1.02]"),children:[e.upstreamColumns.length>0&&l.jsx(er,{type:"target",position:rr.Left,className:G("!w-2 !h-2 !border-2 !border-background transition-colors",e.isComputed?"!bg-k-yellow":"!bg-muted-foreground/50")}),e.downstreamColumns.length>0&&l.jsx(er,{type:"source",position:rr.Right,className:"!w-2 !h-2 !bg-muted-foreground/50 !border-2 !border-background"}),l.jsxs("div",{className:G("border bg-card rounded-lg shadow-sm overflow-hidden transition-all duration-150",e.isComputed?"border-k-yellow/30":"border-border/60",e.errorCount>0&&"border-destructive/40",a&&"ring-1 ring-k-yellow/50 shadow-md border-k-yellow/50"),children:[l.jsxs("div",{className:G("px-3 py-2 flex items-center gap-2",e.isComputed?"bg-k-yellow/5":""),children:[l.jsx("div",{className:G("w-5 h-5 rounded flex items-center justify-center shrink-0",e.isComputed?"bg-k-yellow/15":"bg-muted/40"),children:M.createElement(ep(e.type),{className:G("h-3 w-3",e.isComputed?"text-k-yellow":"text-muted-foreground")})}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("span",{className:"text-[11px] font-semibold text-foreground truncate block leading-tight",children:e.name}),l.jsx("span",{className:G("text-[9px] font-mono leading-tight",e.isComputed?"text-k-yellow/60":"text-muted-foreground/50"),children:cb(e.type)})]}),e.isComputed&&l.jsx(we,{className:"h-2.5 w-2.5 text-k-yellow/60 shrink-0"})]}),e.isComputed&&(e.funcName||n)&&l.jsx("div",{className:"px-3 py-1 border-t border-border/30",children:l.jsxs("div",{className:"flex items-center gap-1.5",children:[n&&l.jsx("span",{className:G("text-[8px] font-semibold uppercase tracking-wider px-1 py-0.5 rounded",n.bg,n.text),children:n.label}),e.funcName&&l.jsxs("code",{className:"text-[9px] font-mono text-muted-foreground/60 truncate",children:[e.funcName.length>24?`${e.funcName.slice(0,22)}…`:e.funcName,"()"]})]})})]})]})}const hb={columnNode:fb};function pb({node:e,onClose:a,onNavigate:n}){const[t,r]=M.useState(!1),i=e.funcType?rp[e.funcType]:null,o=M.useCallback(async()=>{if(e.computeExpression)try{await navigator.clipboard.writeText(e.computeExpression),r(!0),setTimeout(()=>r(!1),2e3)}catch{}},[e.computeExpression]);return l.jsxs("div",{className:"absolute right-0 top-0 bottom-0 w-[280px] bg-card border-l border-border overflow-y-auto shadow-xl z-50",onClick:s=>s.stopPropagation(),children:[l.jsx("div",{className:"sticky top-0 bg-card/95 backdrop-blur-sm px-4 py-3 border-b border-border z-[51]",children:l.jsxs("div",{className:"flex items-start justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[l.jsx("div",{className:G("w-6 h-6 rounded flex items-center justify-center shrink-0",e.isComputed?"bg-k-yellow/15":"bg-muted/40"),children:M.createElement(ep(e.type),{className:G("h-3.5 w-3.5",e.isComputed?"text-k-yellow":"text-muted-foreground")})}),l.jsxs("div",{className:"min-w-0",children:[l.jsx("h3",{className:"text-xs font-semibold truncate",children:e.name}),l.jsx("div",{className:"text-[10px] font-mono text-muted-foreground/60",children:e.type})]})]}),l.jsx("button",{onClick:a,className:"text-muted-foreground hover:text-foreground p-1 rounded hover:bg-accent transition-colors -mr-1 -mt-1",children:l.jsx(Ve,{className:"h-3.5 w-3.5"})})]})}),l.jsxs("div",{className:"px-4 py-2.5 border-b border-border/50",children:[l.jsx("div",{className:"text-[9px] text-muted-foreground/60 uppercase tracking-wider mb-1",children:"Kind"}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[e.isComputed&&i?l.jsx("span",{className:G("text-[10px] font-semibold px-1.5 py-0.5 rounded",i.bg,i.text),children:i.label}):l.jsx("span",{className:"text-[10px] text-muted-foreground/60 bg-muted/30 px-1.5 py-0.5 rounded",children:"Source"}),e.errorCount>0&&l.jsxs("span",{className:"text-[10px] text-destructive bg-destructive/10 px-1.5 py-0.5 rounded",children:[e.errorCount," errors"]})]})]}),e.computeExpression&&l.jsxs("div",{className:"px-4 py-2.5 border-b border-border/50",children:[l.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[l.jsx("div",{className:"text-[9px] text-muted-foreground/60 uppercase tracking-wider",children:"Expression"}),l.jsx("button",{onClick:o,className:"p-0.5 text-muted-foreground/40 hover:text-foreground transition-colors rounded hover:bg-muted/50",children:t?l.jsx(gp,{className:"h-3 w-3 text-green-500"}):l.jsx(bp,{className:"h-3 w-3"})})]}),l.jsx("pre",{className:"text-[10px] font-mono text-muted-foreground bg-accent/50 rounded px-2.5 py-2 whitespace-pre-wrap break-all leading-relaxed max-h-32 overflow-y-auto",children:e.computeExpression})]}),e.comment&&l.jsxs("div",{className:"px-4 py-2.5 border-b border-border/50",children:[l.jsx("div",{className:"text-[9px] text-muted-foreground/60 uppercase tracking-wider mb-1",children:"Note"}),l.jsx("p",{className:"text-[10px] text-muted-foreground/80 italic",children:e.comment})]}),e.upstreamColumns.length>0&&l.jsxs("div",{className:"px-4 py-2.5 border-b border-border/50",children:[l.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[l.jsx(Ie,{className:"h-3 w-3 text-muted-foreground/50"}),l.jsxs("div",{className:"text-[9px] text-muted-foreground/60 uppercase tracking-wider",children:["Depends On (",e.upstreamColumns.length,")"]})]}),l.jsx("div",{className:"space-y-px",children:e.upstreamColumns.map(s=>l.jsxs("button",{onClick:()=>n(s),className:"w-full flex items-center gap-2 px-2 py-1.5 rounded text-left hover:bg-accent/50 transition-colors group",children:[l.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-muted-foreground/30 group-hover:bg-k-yellow transition-colors"}),l.jsx("span",{className:"text-[10px] text-foreground/80 font-medium truncate",children:s}),l.jsx(tr,{className:"h-2.5 w-2.5 text-muted-foreground/30 ml-auto group-hover:text-foreground transition-colors"})]},s))})]}),e.downstreamColumns.length>0&&l.jsxs("div",{className:"px-4 py-2.5 border-b border-border/50",children:[l.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[l.jsx(we,{className:"h-3 w-3 text-k-yellow/60"}),l.jsxs("div",{className:"text-[9px] text-muted-foreground/60 uppercase tracking-wider",children:["Used By (",e.downstreamColumns.length,")"]})]}),l.jsx("div",{className:"space-y-px",children:e.downstreamColumns.map(s=>l.jsxs("button",{onClick:()=>n(s),className:"w-full flex items-center gap-2 px-2 py-1.5 rounded text-left hover:bg-accent/50 transition-colors group",children:[l.jsx(we,{className:"h-2.5 w-2.5 text-k-yellow/30 group-hover:text-k-yellow transition-colors"}),l.jsx("span",{className:"text-[10px] text-foreground/80 font-medium truncate",children:s}),l.jsx(tr,{className:"h-2.5 w-2.5 text-muted-foreground/30 ml-auto group-hover:text-foreground transition-colors"})]},s))})]}),!e.isComputed&&e.downstreamColumns.length===0&&l.jsx("div",{className:"px-4 py-6 text-center",children:l.jsx("p",{className:"text-[10px] text-muted-foreground/40",children:"This source column is not referenced by any computed columns."})})]})}function vb(){return l.jsxs("div",{className:"h-40 border border-border/40 rounded-lg bg-accent/20 flex flex-col items-center justify-center text-center p-6",children:[l.jsx(mp,{className:"h-5 w-5 text-muted-foreground/30 mb-2"}),l.jsx("p",{className:"text-[10px] text-muted-foreground/50 max-w-[200px]",children:"No column dependencies to visualize. Add computed columns that reference other columns."})]})}function mb({columns:e}){const{layoutedNodes:a,layoutedEdges:n,sourceCount:t,computedCount:r}=M.useMemo(()=>{const{nodes:p,edges:m,sourceCount:g,computedCount:b}=ib(e);return{layoutedNodes:sb(p,m),layoutedEdges:m,sourceCount:g,computedCount:b}},[e]),[i,,o]=Hf(a),[s,,u]=Kf(n),[c,d]=M.useState(null),f=M.useRef(!1),h=M.useCallback((p,m)=>{f.current=!0,d(g=>m.id===g?null:m.id)},[]),v=M.useCallback(()=>{if(f.current){f.current=!1;return}d(null)},[]),y=M.useMemo(()=>ob(s,c),[s,c]),x=M.useMemo(()=>c?i.find(p=>p.id===c)?.data??null:null,[i,c]);return n.length===0?l.jsx(vb,{}):l.jsxs("div",{className:"relative h-full w-full overflow-hidden bg-card",children:[l.jsx("div",{className:G("h-full transition-all duration-200",x?"pr-[280px]":""),children:l.jsxs(zf,{nodes:i,edges:y,onNodesChange:o,onEdgesChange:u,onNodeClick:h,onPaneClick:v,nodeTypes:hb,edgeTypes:lb,fitView:!0,fitViewOptions:{padding:.3,duration:300},nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,selectNodesOnDrag:!1,minZoom:.3,maxZoom:1.5,proOptions:{hideAttribution:!0},children:[l.jsx(Wf,{variant:pp.Dots,gap:20,size:1,color:"#1a1a1a"}),l.jsx(mo,{position:"top-left",children:l.jsx("div",{className:"bg-card/90 backdrop-blur-sm border border-border/40 rounded px-2.5 py-1.5 flex items-center gap-2.5",children:l.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground",children:[l.jsx("span",{className:"font-semibold text-foreground",children:t})," source",l.jsx("span",{className:"text-muted-foreground/30",children:"→"}),l.jsx("span",{className:"font-semibold text-k-yellow",children:r})," computed"]})})}),l.jsx(mo,{position:"top-right",children:l.jsxs("div",{className:"bg-card/90 backdrop-blur-sm border border-border/40 rounded px-2.5 py-1.5 space-y-1",children:[l.jsx("div",{className:"text-[8px] text-muted-foreground/50 uppercase tracking-wider font-semibold",children:"Legend"}),l.jsxs("div",{className:"flex items-center gap-1.5 text-[9px] text-muted-foreground/60",children:[l.jsx("div",{className:"w-2.5 h-2.5 rounded-sm border border-border/60 bg-card"}),"Source Column"]}),l.jsxs("div",{className:"flex items-center gap-1.5 text-[9px] text-muted-foreground/60",children:[l.jsx("div",{className:"w-2.5 h-2.5 rounded-sm border border-k-yellow/40 bg-k-yellow/10"}),"Computed Column"]})]})}),l.jsx($f,{showInteractive:!1,className:"!bg-card !border-border/40 !rounded-lg [&>button]:!bg-card [&>button]:!border-border/40 [&>button]:!text-muted-foreground [&>button:hover]:!bg-accent"})]})}),x&&l.jsx(pb,{node:x,onClose:()=>d(null),onNavigate:p=>d(p)})]})}function gb({columns:e}){const a=e.map(n=>n.name).join("|");return l.jsx(hp,{children:l.jsx(mb,{columns:e},a)})}const tp={builtin:{text:"text-muted-foreground/70",label:"built-in"},custom_udf:{text:"text-k-yellow/80",label:"UDF"},query:{text:"text-blue-400/80",label:"query"},unknown:{text:"text-muted-foreground/50",label:"fn"}};function bb({id:e,sourceX:a,sourceY:n,targetX:t,targetY:r,sourcePosition:i,targetPosition:o,data:s,markerEnd:u}){const[c,d,f]=Yf({sourceX:a,sourceY:n,targetX:t,targetY:r,sourcePosition:i,targetPosition:o,borderRadius:16}),h=s,v=h?.label,y=h?.edgeType==="query";return l.jsxs(l.Fragment,{children:[l.jsx(Jf,{id:e,path:c,markerEnd:u,style:{stroke:y?"#888":"#333",strokeWidth:y?1:1.5,strokeDasharray:y?"5 3":void 0,opacity:y?.5:.8}}),v&&l.jsx(vp,{children:l.jsx("div",{style:{transform:`translate(-50%, -50%) translate(${d}px, ${f}px)`},className:G("absolute pointer-events-all px-1.5 py-0.5 rounded border text-[8px] font-mono",y?"bg-card border-border/40 text-muted-foreground/60":"bg-card border-border/60 text-muted-foreground"),children:v})})]})}const xb={labeled:bb};function yb({data:e}){const a=e.total_errors>0,n=e.columns.filter(r=>r.is_computed),t=e.columns.filter(r=>!r.is_computed);return l.jsxs("div",{className:G("rounded-lg border bg-card shadow-sm min-w-[200px] max-w-[240px] cursor-pointer transition-all",a?"border-destructive/30":"border-border/60",e.isSelected&&"ring-1 ring-k-yellow/50 border-k-yellow/30"),onClick:()=>e.onSelect(e.path),children:[e.hasIncoming&&l.jsx(er,{type:"target",position:rr.Top,className:"!bg-border !w-2 !h-2 !-top-1"}),l.jsxs("div",{className:"px-3 py-2 border-b border-border/40",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[e.is_view?l.jsx(Ae,{className:"h-3 w-3 text-muted-foreground/60 shrink-0"}):l.jsx(qe,{className:"h-3 w-3 text-muted-foreground/60 shrink-0"}),l.jsx("span",{className:"text-[11px] font-semibold text-foreground truncate",children:e.name})]}),l.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[l.jsxs("span",{className:"text-[9px] text-muted-foreground/50 tabular-nums",children:[e.row_count.toLocaleString()," rows"]}),l.jsxs("span",{className:"text-[9px] text-muted-foreground/40",children:["v",e.version]}),e.indexes.length>0&&l.jsxs("span",{className:"text-[9px] text-muted-foreground/50 flex items-center gap-0.5",children:[l.jsx(He,{className:"h-2 w-2"}),e.indexes.length]}),a&&l.jsxs("span",{className:"text-[9px] text-destructive flex items-center gap-0.5",children:[l.jsx(ar,{className:"h-2 w-2"}),e.total_errors]}),e.iterator_type&&l.jsx("span",{className:"text-[8px] px-1 rounded bg-accent text-muted-foreground font-mono",children:e.iterator_type})]})]}),l.jsxs("div",{className:"px-2.5 py-1.5 space-y-px",children:[t.slice(0,3).map(r=>l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("div",{className:"w-1 h-1 rounded-full bg-muted-foreground/20 shrink-0"}),l.jsx("span",{className:"text-[9px] text-muted-foreground/40 truncate",children:r.name})]},r.name)),t.length>3&&l.jsxs("div",{className:"text-[8px] text-muted-foreground/25 pl-2.5",children:["+",t.length-3," more"]}),n.length>0&&l.jsxs(l.Fragment,{children:[t.length>0&&l.jsx("div",{className:"border-t border-border/30 my-1"}),n.slice(0,4).map(r=>{const i=r.func_type?tp[r.func_type]:null;return l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(we,{className:G("h-2 w-2 shrink-0",r.error_count>0?"text-destructive":"text-k-yellow/50")}),l.jsx("span",{className:G("text-[9px] truncate",r.error_count>0?"text-destructive/80":"text-foreground/70"),children:r.name}),r.func_name&&i&&l.jsx("span",{className:G("text-[7px] shrink-0 font-mono",i.text),children:r.func_name})]},r.name)}),n.length>4&&l.jsxs("div",{className:"text-[8px] text-muted-foreground/25 pl-2.5",children:["+",n.length-4," more"]})]})]}),e.hasOutgoing&&l.jsx(er,{type:"source",position:rr.Bottom,className:"!bg-border !w-2 !h-2 !-bottom-1"})]})}const _b={tableNode:yb};function wb({node:e,onClose:a,onShowColumnFlow:n}){const[t,r]=M.useState(!1),i=e.columns.some(u=>u.depends_on&&u.depends_on.length>0),o=e.columns.filter(u=>u.is_computed),s=e.columns.filter(u=>!u.is_computed);return l.jsxs("div",{className:"w-[360px] shrink-0 border-l border-border bg-card overflow-y-auto",children:[l.jsxs("div",{className:"px-5 py-4 border-b border-border flex items-start justify-between sticky top-0 bg-card z-10",children:[l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[e.is_view?l.jsx(Ae,{className:"h-4 w-4 text-muted-foreground shrink-0"}):l.jsx(qe,{className:"h-4 w-4 text-muted-foreground shrink-0"}),l.jsx("h3",{className:"text-sm font-semibold truncate",children:e.name})]}),l.jsxs("div",{className:"flex items-center gap-2 mt-1 ml-6",children:[l.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:e.path}),e.iterator_type&&l.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-accent text-muted-foreground font-mono",children:e.iterator_type})]})]}),l.jsx("button",{onClick:a,className:"text-muted-foreground hover:text-foreground transition-colors p-1 -mr-1 -mt-1 rounded hover:bg-accent",children:l.jsx(Ve,{className:"h-4 w-4"})})]}),l.jsx("div",{className:"grid grid-cols-4 px-5 py-3 border-b border-border",children:[{label:"Rows",value:e.row_count.toLocaleString(),isError:!1},{label:"Version",value:`v${e.version}`,isError:!1},{label:"Computed",value:String(e.computed_count),isError:!1},{label:"Errors",value:String(e.total_errors),isError:e.total_errors>0}].map(u=>l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:G("text-sm font-semibold tabular-nums",u.isError?"text-destructive":"text-foreground"),children:u.value}),l.jsx("div",{className:"text-[10px] text-muted-foreground mt-0.5",children:u.label})]},u.label))}),i&&l.jsx("div",{className:"px-5 py-3 border-b border-border",children:l.jsxs("button",{onClick:n,className:"w-full flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-k-yellow/20 bg-k-yellow/5 hover:bg-k-yellow/10 transition-colors text-left group",children:[l.jsx(Ie,{className:"h-4 w-4 text-k-yellow/70 shrink-0"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"text-[11px] font-semibold text-foreground",children:"Column Data Flow"}),l.jsx("div",{className:"text-[10px] text-muted-foreground/60",children:"Visualize column dependencies"})]}),l.jsx(nr,{className:"h-3.5 w-3.5 text-muted-foreground/40 -rotate-90 group-hover:text-k-yellow/70 transition-colors shrink-0"})]})}),e.base&&l.jsxs("div",{className:"px-5 py-3 border-b border-border flex items-center gap-2",children:[l.jsx(Ie,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),l.jsx("span",{className:"text-xs text-muted-foreground",children:"Derived from"}),l.jsx("span",{className:"text-xs text-foreground font-mono font-medium",children:e.base})]}),e.indexes.length>0&&l.jsxs("div",{className:"px-5 py-3 border-b border-border",children:[l.jsx(Xe,{children:"Embedding Indices"}),l.jsx("div",{className:"space-y-2",children:e.indexes.map(u=>l.jsxs("div",{className:"flex items-start gap-2",children:[l.jsx(He,{className:"h-3.5 w-3.5 text-muted-foreground mt-0.5 shrink-0"}),l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-xs text-foreground",children:u.columns.join(", ")}),l.jsx("p",{className:"text-[11px] text-muted-foreground break-words leading-relaxed mt-0.5",children:u.embedding})]})]},u.name))})]}),s.length>0&&l.jsxs("div",{className:"px-5 py-3 border-b border-border",children:[l.jsxs(Xe,{children:["Insertable Columns (",s.length,")"]}),l.jsx("div",{className:"space-y-1",children:s.map(u=>l.jsxs("div",{className:"flex items-baseline gap-2 text-xs min-h-[20px]",children:[l.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-muted-foreground/20 shrink-0 mt-[5px]"}),l.jsx("span",{className:"text-foreground/80 shrink-0",children:u.name}),u.defined_in&&!u.defined_in_self&&l.jsxs("span",{className:"text-[10px] text-muted-foreground/50 italic shrink-0",children:["from ",u.defined_in]}),l.jsx("span",{className:"text-muted-foreground/40 ml-auto text-[11px] font-mono text-right shrink-0",children:u.type})]},u.name))})]}),o.length>0&&l.jsxs("div",{className:"px-5 py-3 border-b border-border",children:[l.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[l.jsx(we,{className:"h-3 w-3 text-k-yellow/60"}),l.jsxs(Xe,{className:"mb-0",children:["Computed Pipeline (",o.length,")"]})]}),l.jsx("div",{className:"space-y-1.5",children:o.map((u,c)=>l.jsx(qb,{col:u,step:c+1},u.name))})]}),e.versions.length>0&&l.jsxs("div",{className:"px-5 py-3",children:[l.jsxs("button",{onClick:()=>r(!t),className:"flex items-center gap-1.5 mb-2 hover:text-foreground transition-colors",children:[l.jsx(nr,{className:G("h-3 w-3 text-muted-foreground transition-transform",t&&"rotate-180")}),l.jsxs(Xe,{className:"mb-0",children:["Version History (",e.versions.length,")"]})]}),t&&l.jsx("div",{className:"space-y-1 ml-1",children:e.versions.map(u=>l.jsxs("div",{className:"flex items-center gap-3 text-xs",children:[l.jsxs("span",{className:"text-muted-foreground w-6 text-right tabular-nums",children:["v",u.version]}),l.jsx("span",{className:G("px-1.5 py-0.5 rounded text-[10px] min-w-[50px] text-center",u.change_type==="schema"?"bg-accent text-muted-foreground":"bg-accent/50 text-muted-foreground/70"),children:u.change_type}),l.jsxs("span",{className:"text-muted-foreground tabular-nums",children:["+",u.inserts]}),u.updates>0&&l.jsxs("span",{className:"text-muted-foreground tabular-nums",children:["~",u.updates]}),u.deletes>0&&l.jsxs("span",{className:"text-muted-foreground tabular-nums",children:["-",u.deletes]}),u.errors>0&&l.jsxs("span",{className:"text-destructive tabular-nums",children:["err:",u.errors]})]},u.version))})]})]})}function Xe({children:e,className:a}){return l.jsx("div",{className:G("text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-2",a),children:e})}function qb({col:e,step:a}){const[n,t]=M.useState(!1),r=e.func_type?tp[e.func_type]:null;return l.jsxs("div",{className:"rounded-md border border-border overflow-hidden",children:[l.jsxs("button",{className:"w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-accent/50 transition-colors",onClick:()=>t(!n),children:[l.jsxs("span",{className:"text-[10px] text-muted-foreground w-5 shrink-0 tabular-nums",children:["#",a]}),l.jsx("span",{className:G("text-xs font-medium truncate",e.error_count>0?"text-destructive":"text-foreground"),children:e.name}),r&&l.jsx("span",{className:G("text-[10px] px-1.5 py-0.5 rounded bg-accent font-mono shrink-0",r.text),children:r.label}),l.jsx(nr,{className:G("h-3 w-3 text-muted-foreground transition-transform shrink-0 ml-auto",n&&"rotate-180")})]}),n&&l.jsxs("div",{className:"px-3 pb-3 pt-2 space-y-2 border-t border-border",children:[e.func_name&&l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("span",{className:G("text-xs font-mono font-medium",r?.text??"text-muted-foreground"),children:[e.func_name,"()"]}),r&&l.jsx("span",{className:"text-[10px] text-muted-foreground",children:e.func_type==="builtin"?"pixeltable built-in":e.func_type==="custom_udf"?"@pxt.udf":e.func_type==="query"?"@pxt.query":""})]}),e.computed_with&&l.jsx("pre",{className:"text-[11px] text-muted-foreground font-mono leading-relaxed bg-accent rounded-md px-3 py-2 whitespace-pre-wrap break-all",children:e.computed_with}),e.depends_on&&e.depends_on.length>0&&l.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[l.jsx(Ie,{className:"h-3 w-3 text-muted-foreground shrink-0"}),e.depends_on.map(i=>l.jsx("span",{className:"text-[10px] bg-accent text-muted-foreground px-1.5 py-0.5 rounded",children:i},i))]}),e.comment&&l.jsx("div",{className:"text-[10px] text-muted-foreground/70 italic",children:e.comment}),e.custom_metadata&&Object.keys(e.custom_metadata).length>0&&l.jsxs("div",{className:"text-[10px] text-muted-foreground/60",children:[l.jsx("span",{className:"font-medium",children:"Metadata:"})," ",Object.entries(e.custom_metadata).map(([i,o])=>l.jsxs("span",{className:"bg-accent px-1.5 py-0.5 rounded mr-1",children:[i,"=",String(o)]},i))]}),e.error_count>0&&l.jsxs("div",{className:"text-xs text-destructive flex items-center gap-1.5",children:[l.jsx(ar,{className:"h-3 w-3"}),e.error_count," errors in sampled rows"]})]})]})}function Nb(e,a){const n=new Map,t=new Map;for(const m of a)m.type==="view"&&(n.has(m.source)||n.set(m.source,[]),n.get(m.source).push(m.target),t.set(m.target,m.source));const r=new Map(e.map(m=>[m.path,m])),i=e.filter(m=>!t.has(m.path)&&n.has(m.path)),o=e.filter(m=>!t.has(m.path)&&!n.has(m.path)),s=240,u=100,c=40,d=100,f=new Map;let h=0;function v(m){const g=r.get(m);return g?u+Math.min(g.columns.length,10)*14:u}function y(m){const g=n.get(m)||[];if(g.length===0)return s;const b=g.map(y);return Math.max(s,b.reduce((_,w)=>_+w+c,-c))}function x(m,g,b){if(f.has(m))return;f.set(m,{x:g,y:b});const _=n.get(m)||[];if(_.length===0)return;const w=y(m);let N=g-w/2+s/2;for(const q of _){const k=y(q),j=N+k/2-s/2;x(q,j,b+v(m)+d),N+=k+c}}for(const m of i){const g=y(m.path);x(m.path,h+g/2-s/2,0),h+=g+c*2}const p=0;for(const m of o)f.set(m.path,{x:h,y:p}),h+=s+c;return e.map(m=>({id:m.path,type:"tableNode",position:f.get(m.path)||{x:0,y:0},data:m}))}function jb(){const[e,a]=M.useState(null),[n,t]=M.useState(!0),[r,i]=M.useState(null),[o,s]=M.useState(null),[u,c]=M.useState(null),[d,f,h]=Hf([]),[v,y,x]=Kf([]),p=M.useCallback(b=>{s(_=>{const w=_===b?null:b;return f(N=>N.map(q=>({...q,data:{...q.data,isSelected:q.id===w}}))),w})},[f]);Vf(()=>{cp().then(b=>{a(b);const _=new Set(b.edges.map(j=>j.target)),w=new Set(b.edges.map(j=>j.source)),N=b.nodes.map(j=>({...j,isSelected:!1,onSelect:p,hasIncoming:_.has(j.path),hasOutgoing:w.has(j.path)})),q=Nb(b.nodes,b.edges).map(j=>({...j,data:{...N.find(R=>R.path===j.id)}})),k=b.edges.map((j,R)=>({id:`e-${R}`,source:j.source,target:j.target,type:"labeled",animated:j.type==="view",data:{label:j.label,edgeType:j.type}}));f(q),y(k),t(!1)}).catch(b=>{i(b instanceof Error?b.message:"Failed to load pipeline"),t(!1)})});const m=M.useMemo(()=>e?.nodes.find(b=>b.path===o)??null,[e,o]),g=M.useMemo(()=>{if(!e)return null;const b=e.nodes.filter(j=>!j.is_view).length,_=e.nodes.filter(j=>j.is_view).length,w=e.nodes.reduce((j,R)=>j+R.row_count,0),N=e.nodes.reduce((j,R)=>j+R.computed_count,0),q=e.nodes.reduce((j,R)=>j+R.total_errors,0),k=e.nodes.reduce((j,R)=>j+R.indexes.length,0);return{tables:b,views:_,totalRows:w,totalComputed:N,totalErrors:q,totalIndices:k}},[e]);return n?l.jsx("div",{className:"flex-1 flex items-center justify-center",children:l.jsx(Ue,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):r?l.jsx("div",{className:"flex-1 flex items-center justify-center",children:l.jsxs("div",{className:"text-center space-y-2",children:[l.jsx(ar,{className:"h-6 w-6 text-destructive mx-auto"}),l.jsx("p",{className:"text-xs text-muted-foreground",children:r})]})}):u?l.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[l.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b border-border/40 shrink-0",children:[l.jsxs("button",{onClick:()=>c(null),className:"flex items-center gap-1.5 text-[11px] text-muted-foreground hover:text-foreground transition-colors rounded-md px-2 py-1 hover:bg-accent",children:[l.jsx(xp,{className:"h-3.5 w-3.5"}),"Pipeline"]}),l.jsx("span",{className:"text-muted-foreground/30 text-[11px]",children:"/"}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[u.is_view?l.jsx(Ae,{className:"h-3 w-3 text-muted-foreground/50"}):l.jsx(qe,{className:"h-3 w-3 text-muted-foreground/50"}),l.jsx("span",{className:"text-[11px] font-semibold text-foreground",children:u.name})]}),l.jsx("span",{className:"text-muted-foreground/30 text-[11px]",children:"/"}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(Ie,{className:"h-3 w-3 text-k-yellow/60"}),l.jsx("span",{className:"text-[11px] font-medium text-k-yellow/80",children:"Column Data Flow"})]})]}),l.jsx("div",{className:"flex-1 min-h-0",children:l.jsx(gb,{columns:u.columns})})]}):l.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[g&&l.jsxs("div",{className:"flex items-center gap-4 px-4 py-2 border-b border-border/40 shrink-0",children:[[{icon:qe,value:g.tables,label:"tables"},{icon:Ae,value:g.views,label:"views"},{icon:eh,value:g.totalRows.toLocaleString(),label:"rows"},{icon:we,value:g.totalComputed,label:"computed"},{icon:He,value:g.totalIndices,label:"indices"}].map(b=>l.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[l.jsx(b.icon,{className:"h-3 w-3 text-muted-foreground/50"}),l.jsx("span",{className:"tabular-nums",children:b.value}),l.jsx("span",{className:"text-muted-foreground/50",children:b.label})]},b.label)),g.totalErrors>0&&l.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-destructive",children:[l.jsx(ar,{className:"h-3 w-3"}),l.jsxs("span",{children:[g.totalErrors," errors"]})]})]}),l.jsxs("div",{className:"flex-1 flex min-h-0",children:[l.jsx("div",{className:"flex-1 relative min-h-0",children:l.jsxs(zf,{nodes:d,edges:v,onNodesChange:h,onEdgesChange:x,nodeTypes:_b,edgeTypes:xb,fitView:!0,fitViewOptions:{padding:.2},minZoom:.2,maxZoom:1.5,proOptions:{hideAttribution:!0},children:[l.jsx(Wf,{color:"#1a1a1a",gap:24,size:1}),l.jsx($f,{className:"!bg-card !border-border !rounded-lg [&>button]:!bg-card [&>button]:!border-border/60 [&>button]:!text-muted-foreground [&>button:hover]:!bg-accent"})]})}),m&&l.jsx(wb,{node:m,onClose:()=>s(null),onShowColumnFlow:()=>c(m)})]})]})}const Cb=[{label:"Agent Pipeline",icon:op,color:"text-blue-400",match:e=>["tools","chat_history","collection"].includes(e)},{label:"Documents",icon:Qf,color:"text-amber-400",match:e=>e==="chunks"},{label:"Images",icon:Uf,color:"text-emerald-400",match:e=>e==="images"},{label:"Videos",icon:Zf,color:"text-rose-400",match:e=>["videos","video_frames","video_audio_chunks","video_transcript_sentences"].includes(e)},{label:"Audio",icon:Xf,color:"text-orange-400",match:e=>["audios","audio_chunks","audio_transcript_sentences"].includes(e)},{label:"Generation",icon:Cp,color:"text-pink-400",match:e=>e.includes("generation_tasks")||e==="speech_tasks"},{label:"Memory & Config",icon:up,color:"text-purple-400",match:e=>["memory_bank","user_personas"].includes(e)},{label:"Data Tables",icon:Dp,color:"text-cyan-400",match:e=>e.startsWith("csv_")}];function Ke(e){return e.replace(/^agents\//,"")}function Rb(e){const a=Cb.map(t=>({group:t,tables:[],views:[]})),n=[];for(const t of e){const r=Ke(t.path);let i=!1;for(const o of a)if(o.group.match(r,t)){t.type==="view"?o.views.push(t):o.tables.push(t),i=!0;break}i||n.push(t)}return n.length>0&&a.push({group:{label:"Other",icon:Mp,color:"text-muted-foreground",match:()=>!1},tables:n.filter(t=>t.type!=="view"),views:n.filter(t=>t.type==="view")}),a.filter(t=>t.tables.length+t.views.length>0)}function ex(){const{addToast:e}=sp(),[a,n]=M.useState([]),[t,r]=M.useState(!0),[i,o]=M.useState(null),[s,u]=M.useState(null),[c,d]=M.useState(!1),[f,h]=M.useState(new Set),[v,y]=M.useState(""),[x,p]=M.useState(""),[m,g]=M.useState(!1),[b,_]=M.useState(""),[w,N]=M.useState(""),[q,k]=M.useState(""),[j,R]=M.useState(""),[T,O]=M.useState("inner"),[P,F]=M.useState(null),[U,$]=M.useState(!1),[H,ne]=M.useState(null),[xe,Ee]=M.useState(!1),Se=M.useMemo(()=>{if(!v.trim())return a;const S=v.toLowerCase();return a.filter(L=>L.path.toLowerCase().includes(S))},[a,v]),ye=M.useMemo(()=>Rb(Se),[Se]),se=M.useMemo(()=>{if(!s||!x.trim())return s?.rows??[];const S=x.toLowerCase();return s.rows.filter(L=>s.columns.some(Y=>{const oe=L[Y];return oe==null?!1:String(oe).toLowerCase().includes(S)}))},[s,x]),C=M.useCallback(()=>{if(!s||!i)return;const S=x.trim()?se:s.rows;if(S.length===0){e("No rows to download","info");return}const L=s.columns,Y=[L.map(Bf).join(",")];for(const V of S)Y.push(L.map(ue=>Bf(Hs(V[ue]))).join(","));const oe=new Blob([Y.join(` +import{c as he,e as Ze,g as ip,j as l,r as M,a as G,G as Ie,I as Uf,D as Vs,b as sp,M as op,B as up}from"./index-BKlAZSPs.js";import{u as Vf,L as Ue}from"./use-mount-effect-CEqzESrx.js";import{I as po}from"./input-DEyNLzjf.js";import{B as qr}from"./badge-B_CNDVZh.js";import{a5 as cp,a6 as dp,a7 as vo,a8 as lp,a9 as fp}from"./api-qB_zxs57.js";import{R as hp,u as Hf,a as Kf,i as zf,B as Wf,b as pp,P as mo,C as $f,g as Yf,d as Jf,H as er,c as rr,E as vp}from"./style-CUPaVTH9.js";import{L as mp}from"./layers-6fEVoVKq.js";import{Z as we}from"./zap-BvSjcoQz.js";import{X as Ve}from"./x-B99eDFz6.js";import{C as gp}from"./check-D-roFugH.js";import{C as bp}from"./copy-DR0TH8ar.js";import{a as tr,A as xp,E as Ae,C as yp}from"./eye-D_Cs7pQZ.js";import{T as _p}from"./type-DH9mEbj2.js";import{H as wp}from"./hash-D9LrbLcr.js";import{F as Zf}from"./film-BB-YPpGv.js";import{M as Xf}from"./music-Seq8oTV1.js";import{F as Qf}from"./file-text-BKu2-OuI.js";import{T as qe}from"./table-2-KM3JqDhH.js";import{S as He}from"./search-BHgUFHtw.js";import{C as nr}from"./chevron-down-9h0aHSqT.js";import{T as qp}from"./terminal-BeReSiBq.js";import{D as Np}from"./download-gDnOKy-4.js";import{C as jp}from"./cpu-DmZE95NP.js";import{S as Cp}from"./sparkles-BwOhbqOy.js";import"./index-B8obv054.js";const Rp=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],Ep=he("box",Rp);const Sp=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],kp=he("columns-3",Sp);const Tp=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],Ip=he("funnel",Tp);const Ap=[["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}],["path",{d:"M12 2v10.3a4 4 0 0 1-1.172 2.872L4 22",key:"1hyw0i"}],["path",{d:"m20 22-5-5",key:"1m27yz"}]],Qe=he("merge",Ap);const Op=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]],eh=he("rows-3",Op);const Pp=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Mp=he("settings-2",Pp);const Lp=[["path",{d:"m18 14 4 4-4 4",key:"10pe0f"}],["path",{d:"m18 2 4 4-4 4",key:"pucp1d"}],["path",{d:"M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22",key:"1ailkh"}],["path",{d:"M2 6h1.972a4 4 0 0 1 3.6 2.2",key:"km57vx"}],["path",{d:"M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45",key:"os18l9"}]],go=he("shuffle",Lp);const Fp=[["path",{d:"M15 3v18",key:"14nvp0"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]],Dp=he("table-properties",Fp);const Gp=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],ar=he("triangle-alert",Gp);function Ks(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Nr,bo;function Bp(){if(bo)return Nr;bo=1;function e(){this.__data__=[],this.size=0}return Nr=e,Nr}var jr,xo;function Oe(){if(xo)return jr;xo=1;function e(a,n){return a===n||a!==a&&n!==n}return jr=e,jr}var Cr,yo;function sr(){if(yo)return Cr;yo=1;var e=Oe();function a(n,t){for(var r=n.length;r--;)if(e(n[r][0],t))return r;return-1}return Cr=a,Cr}var Rr,_o;function Up(){if(_o)return Rr;_o=1;var e=sr(),a=Array.prototype,n=a.splice;function t(r){var i=this.__data__,o=e(i,r);if(o<0)return!1;var s=i.length-1;return o==s?i.pop():n.call(i,o,1),--this.size,!0}return Rr=t,Rr}var Er,wo;function Vp(){if(wo)return Er;wo=1;var e=sr();function a(n){var t=this.__data__,r=e(t,n);return r<0?void 0:t[r][1]}return Er=a,Er}var Sr,qo;function Hp(){if(qo)return Sr;qo=1;var e=sr();function a(n){return e(this.__data__,n)>-1}return Sr=a,Sr}var kr,No;function Kp(){if(No)return kr;No=1;var e=sr();function a(n,t){var r=this.__data__,i=e(r,n);return i<0?(++this.size,r.push([n,t])):r[i][1]=t,this}return kr=a,kr}var Tr,jo;function or(){if(jo)return Tr;jo=1;var e=Bp(),a=Up(),n=Vp(),t=Hp(),r=Kp();function i(o){var s=-1,u=o==null?0:o.length;for(this.clear();++s-1&&t%1==0&&t-1&&n%1==0&&n<=e}return Ct=a,Ct}var Rt,wu;function bv(){if(wu)return Rt;wu=1;var e=Ne(),a=Ys(),n=le(),t="[object Arguments]",r="[object Array]",i="[object Boolean]",o="[object Date]",s="[object Error]",u="[object Function]",c="[object Map]",d="[object Number]",f="[object Object]",h="[object RegExp]",v="[object Set]",y="[object String]",x="[object WeakMap]",p="[object ArrayBuffer]",m="[object DataView]",g="[object Float32Array]",b="[object Float64Array]",_="[object Int8Array]",w="[object Int16Array]",N="[object Int32Array]",q="[object Uint8Array]",k="[object Uint8ClampedArray]",j="[object Uint16Array]",R="[object Uint32Array]",T={};T[g]=T[b]=T[_]=T[w]=T[N]=T[q]=T[k]=T[j]=T[R]=!0,T[t]=T[r]=T[p]=T[i]=T[m]=T[o]=T[s]=T[u]=T[c]=T[d]=T[f]=T[h]=T[v]=T[y]=T[x]=!1;function O(P){return n(P)&&a(P.length)&&!!T[e(P)]}return Rt=O,Rt}var Et,qu;function pr(){if(qu)return Et;qu=1;function e(a){return function(n){return a(n)}}return Et=e,Et}var Ge={exports:{}};Ge.exports;var Nu;function Js(){return Nu||(Nu=1,(function(e,a){var n=rh(),t=a&&!a.nodeType&&a,r=t&&!0&&e&&!e.nodeType&&e,i=r&&r.exports===t,o=i&&n.process,s=(function(){try{var u=r&&r.require&&r.require("util").types;return u||o&&o.binding&&o.binding("util")}catch{}})();e.exports=s})(Ge,Ge.exports)),Ge.exports}var St,ju;function Ye(){if(ju)return St;ju=1;var e=bv(),a=pr(),n=Js(),t=n&&n.isTypedArray,r=t?a(t):e;return St=r,St}var kt,Cu;function ah(){if(Cu)return kt;Cu=1;var e=vv(),a=$e(),n=J(),t=Me(),r=hr(),i=Ye(),o=Object.prototype,s=o.hasOwnProperty;function u(c,d){var f=n(c),h=!f&&a(c),v=!f&&!h&&t(c),y=!f&&!h&&!v&&i(c),x=f||h||v||y,p=x?e(c.length,String):[],m=p.length;for(var g in c)(d||s.call(c,g))&&!(x&&(g=="length"||v&&(g=="offset"||g=="parent")||y&&(g=="buffer"||g=="byteLength"||g=="byteOffset")||r(g,m)))&&p.push(g);return p}return kt=u,kt}var Tt,Ru;function vr(){if(Ru)return Tt;Ru=1;var e=Object.prototype;function a(n){var t=n&&n.constructor,r=typeof t=="function"&&t.prototype||e;return n===r}return Tt=a,Tt}var It,Eu;function ih(){if(Eu)return It;Eu=1;function e(a,n){return function(t){return a(n(t))}}return It=e,It}var At,Su;function xv(){if(Su)return At;Su=1;var e=ih(),a=e(Object.keys,Object);return At=a,At}var Ot,ku;function Zs(){if(ku)return Ot;ku=1;var e=vr(),a=xv(),n=Object.prototype,t=n.hasOwnProperty;function r(i){if(!e(i))return a(i);var o=[];for(var s in Object(i))t.call(i,s)&&s!="constructor"&&o.push(s);return o}return Ot=r,Ot}var Pt,Tu;function pe(){if(Tu)return Pt;Tu=1;var e=ze(),a=Ys();function n(t){return t!=null&&a(t.length)&&!e(t)}return Pt=n,Pt}var Mt,Iu;function be(){if(Iu)return Mt;Iu=1;var e=ah(),a=Zs(),n=pe();function t(r){return n(r)?e(r):a(r)}return Mt=t,Mt}var Lt,Au;function yv(){if(Au)return Lt;Au=1;var e=We(),a=be();function n(t,r){return t&&e(r,a(r),t)}return Lt=n,Lt}var Ft,Ou;function _v(){if(Ou)return Ft;Ou=1;function e(a){var n=[];if(a!=null)for(var t in Object(a))n.push(t);return n}return Ft=e,Ft}var Dt,Pu;function wv(){if(Pu)return Dt;Pu=1;var e=ae(),a=vr(),n=_v(),t=Object.prototype,r=t.hasOwnProperty;function i(o){if(!e(o))return n(o);var s=a(o),u=[];for(var c in o)c=="constructor"&&(s||!r.call(o,c))||u.push(c);return u}return Dt=i,Dt}var Gt,Mu;function Ce(){if(Mu)return Gt;Mu=1;var e=ah(),a=wv(),n=pe();function t(r){return n(r)?e(r,!0):a(r)}return Gt=t,Gt}var Bt,Lu;function qv(){if(Lu)return Bt;Lu=1;var e=We(),a=Ce();function n(t,r){return t&&e(r,a(r),t)}return Bt=n,Bt}var Be={exports:{}};Be.exports;var Fu;function sh(){return Fu||(Fu=1,(function(e,a){var n=de(),t=a&&!a.nodeType&&a,r=t&&!0&&e&&!e.nodeType&&e,i=r&&r.exports===t,o=i?n.Buffer:void 0,s=o?o.allocUnsafe:void 0;function u(c,d){if(d)return c.slice();var f=c.length,h=s?s(f):new c.constructor(f);return c.copy(h),h}e.exports=u})(Be,Be.exports)),Be.exports}var Ut,Du;function oh(){if(Du)return Ut;Du=1;function e(a,n){var t=-1,r=a.length;for(n||(n=Array(r));++t v))return!1;var x=f.get(o),p=f.get(s);if(x&&p)return x==s&&p==o;var m=-1,g=!0,b=u&r?new e:void 0;for(f.set(o,s),f.set(s,o);++m 0&&i(d)?r>1?n(d,r-1,i,o,s):e(s,d):o||(s[s.length]=d)}return s}return Oa=n,Oa}var Pa,Td;function ym(){if(Td)return Pa;Td=1;function e(a,n,t){switch(t.length){case 0:return a.call(n);case 1:return a.call(n,t[0]);case 2:return a.call(n,t[0],t[1]);case 3:return a.call(n,t[0],t[1],t[2])}return a.apply(n,t)}return Pa=e,Pa}var Ma,Id;function Fh(){if(Id)return Ma;Id=1;var e=ym(),a=Math.max;function n(t,r,i){return r=a(r===void 0?t.length-1:r,0),function(){for(var o=arguments,s=-1,u=a(o.length-r,0),c=Array(u);++s0){if(++i>=e)return arguments[0]}else i=0;return r.apply(void 0,arguments)}}return Fa=t,Fa}var Da,Pd;function Dh(){if(Pd)return Da;Pd=1;var e=_m(),a=wm(),n=a(e);return Da=n,Da}var Ga,Md;function _r(){if(Md)return Ga;Md=1;var e=Re(),a=Fh(),n=Dh();function t(r,i){return n(a(r,i,e),r+"")}return Ga=t,Ga}var Ba,Ld;function Gh(){if(Ld)return Ba;Ld=1;function e(a,n,t,r){for(var i=a.length,o=t+(r?1:-1);r?o--:++o-1}return Ka=a,Ka}var za,Ud;function Rm(){if(Ud)return za;Ud=1;function e(a,n,t){for(var r=-1,i=a==null?0:a.length;++r=o){var m=c?null:r(u);if(m)return i(m);y=!1,h=t,p=new e}else p=c?[]:x;e:for(;++f 1?v.setNode(y,f):v.setNode(y)}),this},r.prototype.setNode=function(d,f){return e.has(this._nodes,d)?(arguments.length>1&&(this._nodes[d]=f),this):(this._nodes[d]=arguments.length>1?f:this._defaultNodeLabelFn(d),this._isCompound&&(this._parent[d]=n,this._children[d]={},this._children[n][d]=!0),this._in[d]={},this._preds[d]={},this._out[d]={},this._sucs[d]={},++this._nodeCount,this)},r.prototype.node=function(d){return this._nodes[d]},r.prototype.hasNode=function(d){return e.has(this._nodes,d)},r.prototype.removeNode=function(d){var f=this;if(e.has(this._nodes,d)){var h=function(v){f.removeEdge(f._edgeObjs[v])};delete this._nodes[d],this._isCompound&&(this._removeFromParentsChildList(d),delete this._parent[d],e.each(this.children(d),function(v){f.setParent(v)}),delete this._children[d]),e.each(e.keys(this._in[d]),h),delete this._in[d],delete this._preds[d],e.each(e.keys(this._out[d]),h),delete this._out[d],delete this._sucs[d],--this._nodeCount}return this},r.prototype.setParent=function(d,f){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(f))f=n;else{f+="";for(var h=f;!e.isUndefined(h);h=this.parent(h))if(h===d)throw new Error("Setting "+f+" as parent of "+d+" would create a cycle");this.setNode(f)}return this.setNode(d),this._removeFromParentsChildList(d),this._parent[d]=f,this._children[f][d]=!0,this},r.prototype._removeFromParentsChildList=function(d){delete this._children[this._parent[d]][d]},r.prototype.parent=function(d){if(this._isCompound){var f=this._parent[d];if(f!==n)return f}},r.prototype.children=function(d){if(e.isUndefined(d)&&(d=n),this._isCompound){var f=this._children[d];if(f)return e.keys(f)}else{if(d===n)return this.nodes();if(this.hasNode(d))return[]}},r.prototype.predecessors=function(d){var f=this._preds[d];if(f)return e.keys(f)},r.prototype.successors=function(d){var f=this._sucs[d];if(f)return e.keys(f)},r.prototype.neighbors=function(d){var f=this.predecessors(d);if(f)return e.union(f,this.successors(d))},r.prototype.isLeaf=function(d){var f;return this.isDirected()?f=this.successors(d):f=this.neighbors(d),f.length===0},r.prototype.filterNodes=function(d){var f=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});f.setGraph(this.graph());var h=this;e.each(this._nodes,function(x,p){d(p)&&f.setNode(p,x)}),e.each(this._edgeObjs,function(x){f.hasNode(x.v)&&f.hasNode(x.w)&&f.setEdge(x,h.edge(x))});var v={};function y(x){var p=h.parent(x);return p===void 0||f.hasNode(p)?(v[x]=p,p):p in v?v[p]:y(p)}return this._isCompound&&e.each(f.nodes(),function(x){f.setParent(x,y(x))}),f},r.prototype.setDefaultEdgeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultEdgeLabelFn=d,this},r.prototype.edgeCount=function(){return this._edgeCount},r.prototype.edges=function(){return e.values(this._edgeObjs)},r.prototype.setPath=function(d,f){var h=this,v=arguments;return e.reduce(d,function(y,x){return v.length>1?h.setEdge(y,x,f):h.setEdge(y,x),x}),this},r.prototype.setEdge=function(){var d,f,h,v,y=!1,x=arguments[0];typeof x=="object"&&x!==null&&"v"in x?(d=x.v,f=x.w,h=x.name,arguments.length===2&&(v=arguments[1],y=!0)):(d=x,f=arguments[1],h=arguments[3],arguments.length>2&&(v=arguments[2],y=!0)),d=""+d,f=""+f,e.isUndefined(h)||(h=""+h);var p=s(this._isDirected,d,f,h);if(e.has(this._edgeLabels,p))return y&&(this._edgeLabels[p]=v),this;if(!e.isUndefined(h)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(d),this.setNode(f),this._edgeLabels[p]=y?v:this._defaultEdgeLabelFn(d,f,h);var m=u(this._isDirected,d,f,h);return d=m.v,f=m.w,Object.freeze(m),this._edgeObjs[p]=m,i(this._preds[f],d),i(this._sucs[d],f),this._in[f][p]=m,this._out[d][p]=m,this._edgeCount++,this},r.prototype.edge=function(d,f,h){var v=arguments.length===1?c(this._isDirected,arguments[0]):s(this._isDirected,d,f,h);return this._edgeLabels[v]},r.prototype.hasEdge=function(d,f,h){var v=arguments.length===1?c(this._isDirected,arguments[0]):s(this._isDirected,d,f,h);return e.has(this._edgeLabels,v)},r.prototype.removeEdge=function(d,f,h){var v=arguments.length===1?c(this._isDirected,arguments[0]):s(this._isDirected,d,f,h),y=this._edgeObjs[v];return y&&(d=y.v,f=y.w,delete this._edgeLabels[v],delete this._edgeObjs[v],o(this._preds[f],d),o(this._sucs[d],f),delete this._in[f][v],delete this._out[d][v],this._edgeCount--),this},r.prototype.inEdges=function(d,f){var h=this._in[d];if(h){var v=e.values(h);return f?e.filter(v,function(y){return y.v===f}):v}},r.prototype.outEdges=function(d,f){var h=this._out[d];if(h){var v=e.values(h);return f?e.filter(v,function(y){return y.w===f}):v}},r.prototype.nodeEdges=function(d,f){var h=this.inEdges(d,f);if(h)return h.concat(this.outEdges(d,f))};function i(d,f){d[f]?d[f]++:d[f]=1}function o(d,f){--d[f]||delete d[f]}function s(d,f,h,v){var y=""+f,x=""+h;if(!d&&y>x){var p=y;y=x,x=p}return y+t+x+t+(e.isUndefined(v)?a:v)}function u(d,f,h,v){var y=""+f,x=""+h;if(!d&&y>x){var p=y;y=x,x=p}var m={v:y,w:x};return v&&(m.name=v),m}function c(d,f){return s(d,f.v,f.w,f.name)}return ri}var ti,Xd;function Am(){return Xd||(Xd=1,ti="2.1.8"),ti}var ni,Qd;function Om(){return Qd||(Qd=1,ni={Graph:oo(),version:Am()}),ni}var ai,el;function Pm(){if(el)return ai;el=1;var e=ie(),a=oo();ai={write:n,read:i};function n(o){var s={options:{directed:o.isDirected(),multigraph:o.isMultigraph(),compound:o.isCompound()},nodes:t(o),edges:r(o)};return e.isUndefined(o.graph())||(s.value=e.clone(o.graph())),s}function t(o){return e.map(o.nodes(),function(s){var u=o.node(s),c=o.parent(s),d={v:s};return e.isUndefined(u)||(d.value=u),e.isUndefined(c)||(d.parent=c),d})}function r(o){return e.map(o.edges(),function(s){var u=o.edge(s),c={v:s.v,w:s.w};return e.isUndefined(s.name)||(c.name=s.name),e.isUndefined(u)||(c.value=u),c})}function i(o){var s=new a(o.options).setGraph(o.value);return e.each(o.nodes,function(u){s.setNode(u.v,u.value),u.parent&&s.setParent(u.v,u.parent)}),e.each(o.edges,function(u){s.setEdge({v:u.v,w:u.w,name:u.name},u.value)}),s}return ai}var ii,rl;function Mm(){if(rl)return ii;rl=1;var e=ie();ii=a;function a(n){var t={},r=[],i;function o(s){e.has(t,s)||(t[s]=!0,i.push(s),e.each(n.successors(s),o),e.each(n.predecessors(s),o))}return e.each(n.nodes(),function(s){i=[],o(s),i.length&&r.push(i)}),r}return ii}var si,tl;function Vh(){if(tl)return si;tl=1;var e=ie();si=a;function a(){this._arr=[],this._keyIndices={}}return a.prototype.size=function(){return this._arr.length},a.prototype.keys=function(){return this._arr.map(function(n){return n.key})},a.prototype.has=function(n){return e.has(this._keyIndices,n)},a.prototype.priority=function(n){var t=this._keyIndices[n];if(t!==void 0)return this._arr[t].priority},a.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},a.prototype.add=function(n,t){var r=this._keyIndices;if(n=String(n),!e.has(r,n)){var i=this._arr,o=i.length;return r[n]=o,i.push({key:n,priority:t}),this._decrease(o),!0}return!1},a.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var n=this._arr.pop();return delete this._keyIndices[n.key],this._heapify(0),n.key},a.prototype.decrease=function(n,t){var r=this._keyIndices[n];if(t>this._arr[r].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[r].priority+" New: "+t);this._arr[r].priority=t,this._decrease(r)},a.prototype._heapify=function(n){var t=this._arr,r=2*n,i=r+1,o=n;r >1,!(t[i].priority 0&&(f=d.removeMin(),h=c[f],h.distance!==Number.POSITIVE_INFINITY);)u(f).forEach(v);return c}return oi}var ui,al;function Lm(){if(al)return ui;al=1;var e=Hh(),a=ie();ui=n;function n(t,r,i){return a.transform(t.nodes(),function(o,s){o[s]=e(t,s,r,i)},{})}return ui}var ci,il;function Kh(){if(il)return ci;il=1;var e=ie();ci=a;function a(n){var t=0,r=[],i={},o=[];function s(u){var c=i[u]={onStack:!0,lowlink:t,index:t++};if(r.push(u),n.successors(u).forEach(function(h){e.has(i,h)?i[h].onStack&&(c.lowlink=Math.min(c.lowlink,i[h].index)):(s(h),c.lowlink=Math.min(c.lowlink,i[h].lowlink))}),c.lowlink===c.index){var d=[],f;do f=r.pop(),i[f].onStack=!1,d.push(f);while(u!==f);o.push(d)}}return n.nodes().forEach(function(u){e.has(i,u)||s(u)}),o}return ci}var di,sl;function Fm(){if(sl)return di;sl=1;var e=ie(),a=Kh();di=n;function n(t){return e.filter(a(t),function(r){return r.length>1||r.length===1&&t.hasEdge(r[0],r[0])})}return di}var li,ol;function Dm(){if(ol)return li;ol=1;var e=ie();li=n;var a=e.constant(1);function n(r,i,o){return t(r,i||a,o||function(s){return r.outEdges(s)})}function t(r,i,o){var s={},u=r.nodes();return u.forEach(function(c){s[c]={},s[c][c]={distance:0},u.forEach(function(d){c!==d&&(s[c][d]={distance:Number.POSITIVE_INFINITY})}),o(c).forEach(function(d){var f=d.v===c?d.w:d.v,h=i(d);s[c][f]={distance:h,predecessor:c}})}),u.forEach(function(c){var d=s[c];u.forEach(function(f){var h=s[f];u.forEach(function(v){var y=h[c],x=d[v],p=h[v],m=y.distance+x.distance;m 0;){if(c=u.removeMin(),e.has(s,c))o.setEdge(c,s[c]);else{if(f)throw new Error("Input graph is not connected: "+r);f=!0}r.nodeEdges(c).forEach(d)}return o}return gi}var bi,pl;function Hm(){return pl||(pl=1,bi={components:Mm(),dijkstra:Hh(),dijkstraAll:Lm(),findCycles:Fm(),floydWarshall:Dm(),isAcyclic:Gm(),postorder:Bm(),preorder:Um(),prim:Vm(),tarjan:Kh(),topsort:zh()}),bi}var xi,vl;function Km(){if(vl)return xi;vl=1;var e=Om();return xi={Graph:e.Graph,json:Pm(),alg:Hm(),version:e.version},xi}var yi,ml;function ce(){if(ml)return yi;ml=1;var e;if(typeof Ks=="function")try{e=Km()}catch{}return e||(e=window.graphlib),yi=e,yi}var _i,gl;function zm(){if(gl)return _i;gl=1;var e=bh(),a=1,n=4;function t(r){return e(r,a|n)}return _i=t,_i}var wi,bl;function wr(){if(bl)return wi;bl=1;var e=Oe(),a=pe(),n=hr(),t=ae();function r(i,o,s){if(!t(s))return!1;var u=typeof o;return(u=="number"?a(s)&&n(o,s.length):u=="string"&&o in s)?e(s[o],i):!1}return wi=r,wi}var qi,xl;function Wm(){if(xl)return qi;xl=1;var e=_r(),a=Oe(),n=wr(),t=Ce(),r=Object.prototype,i=r.hasOwnProperty,o=e(function(s,u){s=Object(s);var c=-1,d=u.length,f=d>2?u[2]:void 0;for(f&&n(u[0],u[1],f)&&(d=1);++c -1?u[c?i[d]:d]:void 0}}return Ni=t,Ni}var ji,_l;function Ym(){if(_l)return ji;_l=1;var e=/\s/;function a(n){for(var t=n.length;t--&&e.test(n.charAt(t)););return t}return ji=a,ji}var Ci,wl;function Jm(){if(wl)return Ci;wl=1;var e=Ym(),a=/^\s+/;function n(t){return t&&t.slice(0,e(t)+1).replace(a,"")}return Ci=n,Ci}var Ri,ql;function Zm(){if(ql)return Ri;ql=1;var e=Jm(),a=ae(),n=Fe(),t=NaN,r=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,o=/^0o[0-7]+$/i,s=parseInt;function u(c){if(typeof c=="number")return c;if(n(c))return t;if(a(c)){var d=typeof c.valueOf=="function"?c.valueOf():c;c=a(d)?d+"":d}if(typeof c!="string")return c===0?c:+c;c=e(c);var f=i.test(c);return f||o.test(c)?s(c.slice(2),f?2:8):r.test(c)?t:+c}return Ri=u,Ri}var Ei,Nl;function $h(){if(Nl)return Ei;Nl=1;var e=Zm(),a=1/0,n=17976931348623157e292;function t(r){if(!r)return r===0?r:0;if(r=e(r),r===a||r===-a){var i=r<0?-1:1;return i*n}return r===r?r:0}return Ei=t,Ei}var Si,jl;function Xm(){if(jl)return Si;jl=1;var e=$h();function a(n){var t=e(n),r=t%1;return t===t?r?t-r:t:0}return Si=a,Si}var ki,Cl;function Qm(){if(Cl)return ki;Cl=1;var e=Gh(),a=ve(),n=Xm(),t=Math.max;function r(i,o,s){var u=i==null?0:i.length;if(!u)return-1;var c=s==null?0:n(s);return c<0&&(c=t(u+c,0)),e(i,a(o,3),c)}return ki=r,ki}var Ti,Rl;function eg(){if(Rl)return Ti;Rl=1;var e=$m(),a=Qm(),n=e(a);return Ti=n,Ti}var Ii,El;function Yh(){if(El)return Ii;El=1;var e=so();function a(n){var t=n==null?0:n.length;return t?e(n,1):[]}return Ii=a,Ii}var Ai,Sl;function rg(){if(Sl)return Ai;Sl=1;var e=to(),a=xh(),n=Ce();function t(r,i){return r==null?r:e(r,a(i),n)}return Ai=t,Ai}var Oi,kl;function tg(){if(kl)return Oi;kl=1;function e(a){var n=a==null?0:a.length;return n?a[n-1]:void 0}return Oi=e,Oi}var Pi,Tl;function ng(){if(Tl)return Pi;Tl=1;var e=lr(),a=no(),n=ve();function t(r,i){var o={};return i=n(i,3),a(r,function(s,u,c){e(o,u,i(s,u,c))}),o}return Pi=t,Pi}var Mi,Il;function uo(){if(Il)return Mi;Il=1;var e=Fe();function a(n,t,r){for(var i=-1,o=n.length;++i n}return Li=e,Li}var Fi,Ol;function ig(){if(Ol)return Fi;Ol=1;var e=uo(),a=ag(),n=Re();function t(r){return r&&r.length?e(r,n,a):void 0}return Fi=t,Fi}var Di,Pl;function Jh(){if(Pl)return Di;Pl=1;var e=lr(),a=Oe();function n(t,r,i){(i!==void 0&&!a(t[r],i)||i===void 0&&!(r in t))&&e(t,r,i)}return Di=n,Di}var Gi,Ml;function sg(){if(Ml)return Gi;Ml=1;var e=Ne(),a=mr(),n=le(),t="[object Object]",r=Function.prototype,i=Object.prototype,o=r.toString,s=i.hasOwnProperty,u=o.call(Object);function c(d){if(!n(d)||e(d)!=t)return!1;var f=a(d);if(f===null)return!0;var h=s.call(f,"constructor")&&f.constructor;return typeof h=="function"&&h instanceof h&&o.call(h)==u}return Gi=c,Gi}var Bi,Ll;function Zh(){if(Ll)return Bi;Ll=1;function e(a,n){if(!(n==="constructor"&&typeof a[n]=="function")&&n!="__proto__")return a[n]}return Bi=e,Bi}var Ui,Fl;function og(){if(Fl)return Ui;Fl=1;var e=We(),a=Ce();function n(t){return e(t,a(t))}return Ui=n,Ui}var Vi,Dl;function ug(){if(Dl)return Vi;Dl=1;var e=Jh(),a=sh(),n=vh(),t=oh(),r=gh(),i=$e(),o=J(),s=Bh(),u=Me(),c=ze(),d=ae(),f=sg(),h=Ye(),v=Zh(),y=og();function x(p,m,g,b,_,w,N){var q=v(p,g),k=v(m,g),j=N.get(k);if(j){e(p,g,j);return}var R=w?w(q,k,g+"",p,m,N):void 0,T=R===void 0;if(T){var O=o(k),P=!O&&u(k),F=!O&&!P&&h(k);R=k,O||P||F?o(q)?R=q:s(q)?R=t(q):P?(T=!1,R=a(k,!0)):F?(T=!1,R=n(k,!0)):R=[]:f(k)||i(k)?(R=q,i(q)?R=y(q):(!d(q)||c(q))&&(R=r(k))):T=!1}T&&(N.set(k,R),_(R,k,b,w,N),N.delete(k)),e(p,g,R)}return Vi=x,Vi}var Hi,Gl;function cg(){if(Gl)return Hi;Gl=1;var e=dr(),a=Jh(),n=to(),t=ug(),r=ae(),i=Ce(),o=Zh();function s(u,c,d,f,h){u!==c&&n(c,function(v,y){if(h||(h=new e),r(v))t(u,c,y,d,s,f,h);else{var x=f?f(o(u,y),v,y+"",u,c,h):void 0;x===void 0&&(x=v),a(u,y,x)}},i)}return Hi=s,Hi}var Ki,Bl;function dg(){if(Bl)return Ki;Bl=1;var e=_r(),a=wr();function n(t){return e(function(r,i){var o=-1,s=i.length,u=s>1?i[s-1]:void 0,c=s>2?i[2]:void 0;for(u=t.length>3&&typeof u=="function"?(s--,u):void 0,c&&a(i[0],i[1],c)&&(u=s<3?void 0:u,s=1),r=Object(r);++o t||s&&u&&d&&!c&&!f||i&&u&&d||!r&&d||!o)return 1;if(!i&&!s&&!f&&n=c)return d;var f=r[i];return d*(f=="desc"?-1:1)}}return n.index-t.index}return os=a,os}var us,af;function Cg(){if(af)return us;af=1;var e=br(),a=yr(),n=ve(),t=Ph(),r=qg(),i=pr(),o=jg(),s=Re(),u=J();function c(d,f,h){f.length?f=e(f,function(x){return u(x)?function(p){return a(p,x.length===1?x[0]:x)}:x}):f=[s];var v=-1;f=e(f,i(n));var y=t(d,function(x,p,m){var g=e(f,function(b){return b(x)});return{criteria:g,index:++v,value:x}});return r(y,function(x,p){return o(x,p,h)})}return us=c,us}var cs,sf;function Rg(){if(sf)return cs;sf=1;var e=so(),a=Cg(),n=_r(),t=wr(),r=n(function(i,o){if(i==null)return[];var s=o.length;return s>1&&t(i,o[0],o[1])?o=[]:s>2&&t(o[0],o[1],o[2])&&(o=[o[0]]),a(i,e(o,1),[])});return cs=r,cs}var ds,of;function Eg(){if(of)return ds;of=1;var e=Eh(),a=0;function n(t){var r=++a;return e(t)+r}return ds=n,ds}var ls,uf;function Sg(){if(uf)return ls;uf=1;function e(a,n,t){for(var r=-1,i=a.length,o=n.length,s={};++r0;--p)if(x=d[p].dequeue(),x){h=h.concat(o(c,d,f,x,!0));break}}}return h}function o(c,d,f,h,v){var y=v?[]:void 0;return e.forEach(c.inEdges(h.v),function(x){var p=c.edge(x),m=c.node(x.v);v&&y.push({v:x.v,w:x.w}),m.out-=p,u(d,f,m)}),e.forEach(c.outEdges(h.v),function(x){var p=c.edge(x),m=x.w,g=c.node(m);g.in-=p,u(d,f,g)}),c.removeNode(h.v),y}function s(c,d){var f=new a,h=0,v=0;e.forEach(c.nodes(),function(p){f.setNode(p,{v:p,in:0,out:0})}),e.forEach(c.edges(),function(p){var m=f.edge(p.v,p.w)||0,g=d(p),b=m+g;f.setEdge(p.v,p.w,b),v=Math.max(v,f.node(p.v).out+=g),h=Math.max(h,f.node(p.w).in+=g)});var y=e.range(v+h+3).map(function(){return new n}),x=h+1;return e.forEach(f.nodes(),function(p){u(y,x,f.node(p))}),{graph:f,buckets:y,zeroIdx:x}}function u(c,d,f){f.out?f.in?c[f.out-f.in+d].enqueue(f):c[c.length-1].enqueue(f):c[0].enqueue(f)}return vs}var ms,hf;function Ag(){if(hf)return ms;hf=1;var e=z(),a=Ig();ms={run:n,undo:r};function n(i){var o=i.graph().acyclicer==="greedy"?a(i,s(i)):t(i);e.forEach(o,function(u){var c=i.edge(u);i.removeEdge(u),c.forwardName=u.name,c.reversed=!0,i.setEdge(u.w,u.v,c,e.uniqueId("rev"))});function s(u){return function(c){return u.edge(c).weight}}}function t(i){var o=[],s={},u={};function c(d){e.has(u,d)||(u[d]=!0,s[d]=!0,e.forEach(i.outEdges(d),function(f){e.has(s,f.w)?o.push(f):c(f.w)}),delete s[d])}return e.forEach(i.nodes(),c),o}function r(i){e.forEach(i.edges(),function(o){var s=i.edge(o);if(s.reversed){i.removeEdge(o);var u=s.forwardName;delete s.reversed,delete s.forwardName,i.setEdge(o.w,o.v,s,u)}})}return ms}var gs,pf;function te(){if(pf)return gs;pf=1;var e=z(),a=ce().Graph;gs={addDummyNode:n,simplify:t,asNonCompoundGraph:r,successorWeights:i,predecessorWeights:o,intersectRect:s,buildLayerMatrix:u,normalizeRanks:c,removeEmptyRanks:d,addBorderNode:f,maxRank:h,partition:v,time:y,notime:x};function n(p,m,g,b){var _;do _=e.uniqueId(b);while(p.hasNode(_));return g.dummy=m,p.setNode(_,g),_}function t(p){var m=new a().setGraph(p.graph());return e.forEach(p.nodes(),function(g){m.setNode(g,p.node(g))}),e.forEach(p.edges(),function(g){var b=m.edge(g.v,g.w)||{weight:0,minlen:1},_=p.edge(g);m.setEdge(g.v,g.w,{weight:b.weight+_.weight,minlen:Math.max(b.minlen,_.minlen)})}),m}function r(p){var m=new a({multigraph:p.isMultigraph()}).setGraph(p.graph());return e.forEach(p.nodes(),function(g){p.children(g).length||m.setNode(g,p.node(g))}),e.forEach(p.edges(),function(g){m.setEdge(g,p.edge(g))}),m}function i(p){var m=e.map(p.nodes(),function(g){var b={};return e.forEach(p.outEdges(g),function(_){b[_.w]=(b[_.w]||0)+p.edge(_).weight}),b});return e.zipObject(p.nodes(),m)}function o(p){var m=e.map(p.nodes(),function(g){var b={};return e.forEach(p.inEdges(g),function(_){b[_.v]=(b[_.v]||0)+p.edge(_).weight}),b});return e.zipObject(p.nodes(),m)}function s(p,m){var g=p.x,b=p.y,_=m.x-g,w=m.y-b,N=p.width/2,q=p.height/2;if(!_&&!w)throw new Error("Not possible to find intersection inside of the rectangle");var k,j;return Math.abs(w)*N>Math.abs(_)*q?(w<0&&(q=-q),k=q*_/w,j=q):(_<0&&(N=-N),k=N,j=N*w/_),{x:g+k,y:b+j}}function u(p){var m=e.map(e.range(h(p)+1),function(){return[]});return e.forEach(p.nodes(),function(g){var b=p.node(g),_=b.rank;e.isUndefined(_)||(m[_][b.order]=g)}),m}function c(p){var m=e.min(e.map(p.nodes(),function(g){return p.node(g).rank}));e.forEach(p.nodes(),function(g){var b=p.node(g);e.has(b,"rank")&&(b.rank-=m)})}function d(p){var m=e.min(e.map(p.nodes(),function(w){return p.node(w).rank})),g=[];e.forEach(p.nodes(),function(w){var N=p.node(w).rank-m;g[N]||(g[N]=[]),g[N].push(w)});var b=0,_=p.graph().nodeRankFactor;e.forEach(g,function(w,N){e.isUndefined(w)&&N%_!==0?--b:b&&e.forEach(w,function(q){p.node(q).rank+=b})})}function f(p,m,g,b){var _={width:0,height:0};return arguments.length>=4&&(_.rank=g,_.order=b),n(p,"border",_,m)}function h(p){return e.max(e.map(p.nodes(),function(m){var g=p.node(m).rank;if(!e.isUndefined(g))return g}))}function v(p,m){var g={lhs:[],rhs:[]};return e.forEach(p,function(b){m(b)?g.lhs.push(b):g.rhs.push(b)}),g}function y(p,m){var g=e.now();try{return m()}finally{console.log(p+" time: "+(e.now()-g)+"ms")}}function x(p,m){return m()}return gs}var bs,vf;function Og(){if(vf)return bs;vf=1;var e=z(),a=te();bs={run:n,undo:r};function n(i){i.graph().dummyChains=[],e.forEach(i.edges(),function(o){t(i,o)})}function t(i,o){var s=o.v,u=i.node(s).rank,c=o.w,d=i.node(c).rank,f=o.name,h=i.edge(o),v=h.labelRank;if(d!==u+1){i.removeEdge(o);var y,x,p;for(p=0,++u;u j.lim&&(R=j,T=!0);var O=e.filter(_.edges(),function(P){return T===g(b,b.node(P.v),R)&&T!==g(b,b.node(P.w),R)});return e.minBy(O,function(P){return n(_,P)})}function x(b,_,w,N){var q=w.v,k=w.w;b.removeEdge(q,k),b.setEdge(N.v,N.w,{}),f(b),u(b,_),p(b,_)}function p(b,_){var w=e.find(b.nodes(),function(q){return!_.node(q).parent}),N=r(b,w);N=N.slice(1),e.forEach(N,function(q){var k=b.node(q).parent,j=_.edge(q,k),R=!1;j||(j=_.edge(k,q),R=!0),_.node(q).rank=_.node(k).rank+(R?j.minlen:-j.minlen)})}function m(b,_,w){return b.hasEdge(_,w)}function g(b,_,w){return w.low<=_.lim&&_.lim<=w.lim}return _s}var ws,xf;function Mg(){if(xf)return ws;xf=1;var e=ir(),a=e.longestPath,n=Qh(),t=Pg();ws=r;function r(u){switch(u.graph().ranker){case"network-simplex":s(u);break;case"tight-tree":o(u);break;case"longest-path":i(u);break;default:s(u)}}var i=a;function o(u){a(u),n(u)}function s(u){t(u)}return ws}var qs,yf;function Lg(){if(yf)return qs;yf=1;var e=z();qs=a;function a(r){var i=t(r);e.forEach(r.graph().dummyChains,function(o){for(var s=r.node(o),u=s.edgeObj,c=n(r,i,u.v,u.w),d=c.path,f=c.lca,h=0,v=d[h],y=!0;o!==u.w;){if(s=r.node(o),y){for(;(v=d[h])!==f&&r.node(v).maxRank d||f>i[h].lim));for(v=h,h=s;(h=r.parent(h))!==v;)c.push(h);return{path:u.concat(c.reverse()),lca:v}}function t(r){var i={},o=0;function s(u){var c=o;e.forEach(r.children(u),s),i[u]={low:c,lim:o++}}return e.forEach(r.children(),s),i}return qs}var Ns,_f;function Fg(){if(_f)return Ns;_f=1;var e=z(),a=te();Ns={run:n,cleanup:o};function n(s){var u=a.addDummyNode(s,"root",{},"_root"),c=r(s),d=e.max(e.values(c))-1,f=2*d+1;s.graph().nestingRoot=u,e.forEach(s.edges(),function(v){s.edge(v).minlen*=f});var h=i(s)+1;e.forEach(s.children(),function(v){t(s,u,f,h,d,c,v)}),s.graph().nodeRankFactor=f}function t(s,u,c,d,f,h,v){var y=s.children(v);if(!y.length){v!==u&&s.setEdge(u,v,{weight:0,minlen:c});return}var x=a.addBorderNode(s,"_bt"),p=a.addBorderNode(s,"_bb"),m=s.node(v);s.setParent(x,v),m.borderTop=x,s.setParent(p,v),m.borderBottom=p,e.forEach(y,function(g){t(s,u,c,d,f,h,g);var b=s.node(g),_=b.borderTop?b.borderTop:g,w=b.borderBottom?b.borderBottom:g,N=b.borderTop?d:2*d,q=_!==w?1:f-h[v]+1;s.setEdge(x,_,{weight:N,minlen:q,nestingEdge:!0}),s.setEdge(w,p,{weight:N,minlen:q,nestingEdge:!0})}),s.parent(v)||s.setEdge(u,x,{weight:0,minlen:f+h[v]})}function r(s){var u={};function c(d,f){var h=s.children(d);h&&h.length&&e.forEach(h,function(v){c(v,f+1)}),u[d]=f}return e.forEach(s.children(),function(d){c(d,1)}),u}function i(s){return e.reduce(s.edges(),function(u,c){return u+s.edge(c).weight},0)}function o(s){var u=s.graph();s.removeNode(u.nestingRoot),delete u.nestingRoot,e.forEach(s.edges(),function(c){var d=s.edge(c);d.nestingEdge&&s.removeEdge(c)})}return Ns}var js,wf;function Dg(){if(wf)return js;wf=1;var e=z(),a=te();js=n;function n(r){function i(o){var s=r.children(o),u=r.node(o);if(s.length&&e.forEach(s,i),e.has(u,"minRank")){u.borderLeft=[],u.borderRight=[];for(var c=u.minRank,d=u.maxRank+1;c 0;)v%2&&(y+=d[v+1]),v=v-1>>1,d[v]+=h.weight;f+=h.weight*y})),f}return Es}var Ss,Cf;function Vg(){if(Cf)return Ss;Cf=1;var e=z();Ss=a;function a(n,t){return e.map(t,function(r){var i=n.inEdges(r);if(i.length){var o=e.reduce(i,function(s,u){var c=n.edge(u),d=n.node(u.v);return{sum:s.sum+c.weight*d.order,weight:s.weight+c.weight}},{sum:0,weight:0});return{v:r,barycenter:o.sum/o.weight,weight:o.weight}}else return{v:r}})}return Ss}var ks,Rf;function Hg(){if(Rf)return ks;Rf=1;var e=z();ks=a;function a(r,i){var o={};e.forEach(r,function(u,c){var d=o[u.v]={indegree:0,in:[],out:[],vs:[u.v],i:c};e.isUndefined(u.barycenter)||(d.barycenter=u.barycenter,d.weight=u.weight)}),e.forEach(i.edges(),function(u){var c=o[u.v],d=o[u.w];!e.isUndefined(c)&&!e.isUndefined(d)&&(d.indegree++,c.out.push(o[u.w]))});var s=e.filter(o,function(u){return!u.indegree});return n(s)}function n(r){var i=[];function o(c){return function(d){d.merged||(e.isUndefined(d.barycenter)||e.isUndefined(c.barycenter)||d.barycenter>=c.barycenter)&&t(c,d)}}function s(c){return function(d){d.in.push(c),--d.indegree===0&&r.push(d)}}for(;r.length;){var u=r.pop();i.push(u),e.forEach(u.in.reverse(),o(u)),e.forEach(u.out,s(u))}return e.map(e.filter(i,function(c){return!c.merged}),function(c){return e.pick(c,["vs","i","barycenter","weight"])})}function t(r,i){var o=0,s=0;r.weight&&(o+=r.barycenter*r.weight,s+=r.weight),i.weight&&(o+=i.barycenter*i.weight,s+=i.weight),r.vs=i.vs.concat(r.vs),r.barycenter=o/s,r.weight=s,r.i=Math.min(i.i,r.i),i.merged=!0}return ks}var Ts,Ef;function Kg(){if(Ef)return Ts;Ef=1;var e=z(),a=te();Ts=n;function n(i,o){var s=a.partition(i,function(x){return e.has(x,"barycenter")}),u=s.lhs,c=e.sortBy(s.rhs,function(x){return-x.i}),d=[],f=0,h=0,v=0;u.sort(r(!!o)),v=t(d,c,v),e.forEach(u,function(x){v+=x.vs.length,d.push(x.vs),f+=x.barycenter*x.weight,h+=x.weight,v=t(d,c,v)});var y={vs:e.flatten(d,!0)};return h&&(y.barycenter=f/h,y.weight=h),y}function t(i,o,s){for(var u;o.length&&(u=e.last(o)).i<=s;)o.pop(),i.push(u.vs),s++;return s}function r(i){return function(o,s){return o.barycenter s.barycenter?1:i?s.i-o.i:o.i-s.i}}return Ts}var Is,Sf;function zg(){if(Sf)return Is;Sf=1;var e=z(),a=Vg(),n=Hg(),t=Kg();Is=r;function r(s,u,c,d){var f=s.children(u),h=s.node(u),v=h?h.borderLeft:void 0,y=h?h.borderRight:void 0,x={};v&&(f=e.filter(f,function(w){return w!==v&&w!==y}));var p=a(s,f);e.forEach(p,function(w){if(s.children(w.v).length){var N=r(s,w.v,c,d);x[w.v]=N,e.has(N,"barycenter")&&o(w,N)}});var m=n(p,c);i(m,x);var g=t(m,d);if(v&&(g.vs=e.flatten([v,g.vs,y],!0),s.predecessors(v).length)){var b=s.node(s.predecessors(v)[0]),_=s.node(s.predecessors(y)[0]);e.has(g,"barycenter")||(g.barycenter=0,g.weight=0),g.barycenter=(g.barycenter*g.weight+b.order+_.order)/(g.weight+2),g.weight+=2}return g}function i(s,u){e.forEach(s,function(c){c.vs=e.flatten(c.vs.map(function(d){return u[d]?u[d].vs:d}),!0)})}function o(s,u){e.isUndefined(s.barycenter)?(s.barycenter=u.barycenter,s.weight=u.weight):(s.barycenter=(s.barycenter*s.weight+u.barycenter*u.weight)/(s.weight+u.weight),s.weight+=u.weight)}return Is}var As,kf;function Wg(){if(kf)return As;kf=1;var e=z(),a=ce().Graph;As=n;function n(r,i,o){var s=t(r),u=new a({compound:!0}).setGraph({root:s}).setDefaultNodeLabel(function(c){return r.node(c)});return e.forEach(r.nodes(),function(c){var d=r.node(c),f=r.parent(c);(d.rank===i||d.minRank<=i&&i<=d.maxRank)&&(u.setNode(c),u.setParent(c,f||s),e.forEach(r[o](c),function(h){var v=h.v===c?h.w:h.v,y=u.edge(v,c),x=e.isUndefined(y)?0:y.weight;u.setEdge(v,c,{weight:r.edge(h).weight+x})}),e.has(d,"minRank")&&u.setNode(c,{borderLeft:d.borderLeft[i],borderRight:d.borderRight[i]}))}),u}function t(r){for(var i;r.hasNode(i=e.uniqueId("_root")););return i}return As}var Os,Tf;function $g(){if(Tf)return Os;Tf=1;var e=z();Os=a;function a(n,t,r){var i={},o;e.forEach(r,function(s){for(var u=n.parent(s),c,d;u;){if(c=n.parent(u),c?(d=i[c],i[c]=u):(d=o,o=u),d&&d!==u){t.setEdge(d,u);return}u=c}})}return Os}var Ps,If;function Yg(){if(If)return Ps;If=1;var e=z(),a=Bg(),n=Ug(),t=zg(),r=Wg(),i=$g(),o=ce().Graph,s=te();Ps=u;function u(h){var v=s.maxRank(h),y=c(h,e.range(1,v+1),"inEdges"),x=c(h,e.range(v-1,-1,-1),"outEdges"),p=a(h);f(h,p);for(var m=Number.POSITIVE_INFINITY,g,b=0,_=0;_<4;++b,++_){d(b%2?y:x,b%4>=2),p=s.buildLayerMatrix(h);var w=n(h,p);w R)&&o(b,P,T)})})}function w(N,q){var k=-1,j,R=0;return e.forEach(q,function(T,O){if(m.node(T).dummy==="border"){var P=m.predecessors(T);P.length&&(j=m.node(P[0]).order,_(q,R,O,k,j),R=O,k=j)}_(q,R,q.length,j,N.length)}),q}return e.reduce(g,w),b}function i(m,g){if(m.node(g).dummy)return e.find(m.predecessors(g),function(b){return m.node(b).dummy})}function o(m,g,b){if(g>b){var _=g;g=b,b=_}var w=m[g];w||(m[g]=w={}),w[b]=!0}function s(m,g,b){if(g>b){var _=g;g=b,b=_}return e.has(m[g],b)}function u(m,g,b,_){var w={},N={},q={};return e.forEach(g,function(k){e.forEach(k,function(j,R){w[j]=j,N[j]=j,q[j]=R})}),e.forEach(g,function(k){var j=-1;e.forEach(k,function(R){var T=_(R);if(T.length){T=e.sortBy(T,function($){return q[$]});for(var O=(T.length-1)/2,P=Math.floor(O),F=Math.ceil(O);P<=F;++P){var U=T[P];N[R]===R&&j r.name));for(const r of e)if(r.is_computed&&r.depends_on&&r.depends_on.length>0){const i=r.depends_on.filter(o=>n.has(o));i.length>0&&a.set(r.name,i)}const t=new Map;for(const[r,i]of a)for(const o of i){const s=t.get(o)||[];s.push(r),t.set(o,s)}return{upstream:a,downstream:t}}function ib(e){if(!e||e.length===0)return{nodes:[],edges:[],sourceCount:0,computedCount:0};const{upstream:a,downstream:n}=ab(e),t=new Set;for(const c of e)c.is_computed&&t.add(c.name);for(const c of a.values())for(const d of c)t.add(d);const r=e.filter(c=>t.has(c.name));if(r.length===0)return{nodes:[],edges:[],sourceCount:0,computedCount:0};const i=[];for(const[c,d]of a)for(const f of d)t.has(f)&&i.push({id:`${f}→${c}`,source:f,target:c,type:"columnEdge"});const o=r.map(c=>({id:c.name,type:"columnNode",position:{x:0,y:0},data:{name:c.name,type:c.type,isComputed:c.is_computed,computeExpression:c.computed_with,funcName:c.func_name,funcType:c.func_type,errorCount:c.error_count,upstreamColumns:a.get(c.name)||[],downstreamColumns:n.get(c.name)||[],comment:c.comment}})),s=r.filter(c=>!c.is_computed).length,u=r.filter(c=>c.is_computed).length;return{nodes:o,edges:i,sourceCount:s,computedCount:u}}function sb(e,a){if(e.length===0)return e;const n=new Df.graphlib.Graph;n.setDefaultEdgeLabel(()=>({})),n.setGraph(nb);for(const t of e)n.setNode(t.id,{...Us});for(const t of a)n.setEdge(t.source,t.target);return Df.layout(n),e.map(t=>{const r=n.node(t.id);return{...t,position:{x:r.x-Us.width/2,y:r.y-Us.height/2}}})}function ob(e,a){return e.map(n=>{if(!a)return{...n,animated:!1,data:{...n.data,highlight:"default"}};const t=n.source===a||n.target===a;return{...n,animated:t,data:{...n.data,highlight:t?"active":"dimmed"}}})}const ub=[{test:e=>e.includes("string")||e.includes("text"),icon:_p},{test:e=>e.includes("int")||e.includes("float")||e.includes("number"),icon:wp},{test:e=>e.includes("image"),icon:Uf},{test:e=>e.includes("video"),icon:Zf},{test:e=>e.includes("audio"),icon:Xf},{test:e=>e.includes("document"),icon:Qf},{test:e=>e.includes("array")||e.includes("json"),icon:Vs},{test:e=>e.includes("embedding")||e.includes("vector"),icon:we}];function ep(e){const a=e.toLowerCase();return ub.find(n=>n.test(a))?.icon??Ep}function cb(e){return e.startsWith("Required[")&&e.endsWith("]")&&(e=e.slice(9,-1)),e.split("[")[0]}const rp={builtin:{text:"text-muted-foreground/80",bg:"bg-muted/40",label:"built-in"},custom_udf:{text:"text-k-yellow/90",bg:"bg-k-yellow/10",label:"UDF"},query:{text:"text-blue-400/90",bg:"bg-blue-400/10",label:"query"},unknown:{text:"text-muted-foreground/60",bg:"bg-muted/30",label:"fn"}};function db({id:e,sourceX:a,sourceY:n,targetX:t,targetY:r,sourcePosition:i,targetPosition:o,data:s}){const[u]=Yf({sourceX:a,sourceY:n,targetX:t,targetY:r,sourcePosition:i,targetPosition:o,borderRadius:12}),c=s?.highlight,d=M.useMemo(()=>c==="active"?{stroke:"rgba(241, 174, 3, 0.7)",strokeWidth:2.5}:c==="dimmed"?{stroke:"rgba(100, 100, 100, 0.12)",strokeWidth:1}:{stroke:"rgba(100, 100, 100, 0.35)",strokeWidth:1.5},[c]);return l.jsx(Jf,{id:e,path:u,style:d})}const lb={columnEdge:db};function fb({data:e,selected:a}){const n=e.funcType?rp[e.funcType]:null;return l.jsxs("div",{className:G("min-w-[200px] max-w-[240px] transition-all duration-150",a&&"scale-[1.02]"),children:[e.upstreamColumns.length>0&&l.jsx(er,{type:"target",position:rr.Left,className:G("!w-2 !h-2 !border-2 !border-background transition-colors",e.isComputed?"!bg-k-yellow":"!bg-muted-foreground/50")}),e.downstreamColumns.length>0&&l.jsx(er,{type:"source",position:rr.Right,className:"!w-2 !h-2 !bg-muted-foreground/50 !border-2 !border-background"}),l.jsxs("div",{className:G("border bg-card rounded-lg shadow-sm overflow-hidden transition-all duration-150",e.isComputed?"border-k-yellow/30":"border-border/60",e.errorCount>0&&"border-destructive/40",a&&"ring-1 ring-k-yellow/50 shadow-md border-k-yellow/50"),children:[l.jsxs("div",{className:G("px-3 py-2 flex items-center gap-2",e.isComputed?"bg-k-yellow/5":""),children:[l.jsx("div",{className:G("w-5 h-5 rounded flex items-center justify-center shrink-0",e.isComputed?"bg-k-yellow/15":"bg-muted/40"),children:M.createElement(ep(e.type),{className:G("h-3 w-3",e.isComputed?"text-k-yellow":"text-muted-foreground")})}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("span",{className:"text-[11px] font-semibold text-foreground truncate block leading-tight",children:e.name}),l.jsx("span",{className:G("text-[9px] font-mono leading-tight",e.isComputed?"text-k-yellow/60":"text-muted-foreground/50"),children:cb(e.type)})]}),e.isComputed&&l.jsx(we,{className:"h-2.5 w-2.5 text-k-yellow/60 shrink-0"})]}),e.isComputed&&(e.funcName||n)&&l.jsx("div",{className:"px-3 py-1 border-t border-border/30",children:l.jsxs("div",{className:"flex items-center gap-1.5",children:[n&&l.jsx("span",{className:G("text-[8px] font-semibold uppercase tracking-wider px-1 py-0.5 rounded",n.bg,n.text),children:n.label}),e.funcName&&l.jsxs("code",{className:"text-[9px] font-mono text-muted-foreground/60 truncate",children:[e.funcName.length>24?`${e.funcName.slice(0,22)}…`:e.funcName,"()"]})]})})]})]})}const hb={columnNode:fb};function pb({node:e,onClose:a,onNavigate:n}){const[t,r]=M.useState(!1),i=e.funcType?rp[e.funcType]:null,o=M.useCallback(async()=>{if(e.computeExpression)try{await navigator.clipboard.writeText(e.computeExpression),r(!0),setTimeout(()=>r(!1),2e3)}catch{}},[e.computeExpression]);return l.jsxs("div",{className:"absolute right-0 top-0 bottom-0 w-[280px] bg-card border-l border-border overflow-y-auto shadow-xl z-50",onClick:s=>s.stopPropagation(),children:[l.jsx("div",{className:"sticky top-0 bg-card/95 backdrop-blur-sm px-4 py-3 border-b border-border z-[51]",children:l.jsxs("div",{className:"flex items-start justify-between",children:[l.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[l.jsx("div",{className:G("w-6 h-6 rounded flex items-center justify-center shrink-0",e.isComputed?"bg-k-yellow/15":"bg-muted/40"),children:M.createElement(ep(e.type),{className:G("h-3.5 w-3.5",e.isComputed?"text-k-yellow":"text-muted-foreground")})}),l.jsxs("div",{className:"min-w-0",children:[l.jsx("h3",{className:"text-xs font-semibold truncate",children:e.name}),l.jsx("div",{className:"text-[10px] font-mono text-muted-foreground/60",children:e.type})]})]}),l.jsx("button",{onClick:a,className:"text-muted-foreground hover:text-foreground p-1 rounded hover:bg-accent transition-colors -mr-1 -mt-1",children:l.jsx(Ve,{className:"h-3.5 w-3.5"})})]})}),l.jsxs("div",{className:"px-4 py-2.5 border-b border-border/50",children:[l.jsx("div",{className:"text-[9px] text-muted-foreground/60 uppercase tracking-wider mb-1",children:"Kind"}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[e.isComputed&&i?l.jsx("span",{className:G("text-[10px] font-semibold px-1.5 py-0.5 rounded",i.bg,i.text),children:i.label}):l.jsx("span",{className:"text-[10px] text-muted-foreground/60 bg-muted/30 px-1.5 py-0.5 rounded",children:"Source"}),e.errorCount>0&&l.jsxs("span",{className:"text-[10px] text-destructive bg-destructive/10 px-1.5 py-0.5 rounded",children:[e.errorCount," errors"]})]})]}),e.computeExpression&&l.jsxs("div",{className:"px-4 py-2.5 border-b border-border/50",children:[l.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[l.jsx("div",{className:"text-[9px] text-muted-foreground/60 uppercase tracking-wider",children:"Expression"}),l.jsx("button",{onClick:o,className:"p-0.5 text-muted-foreground/40 hover:text-foreground transition-colors rounded hover:bg-muted/50",children:t?l.jsx(gp,{className:"h-3 w-3 text-green-500"}):l.jsx(bp,{className:"h-3 w-3"})})]}),l.jsx("pre",{className:"text-[10px] font-mono text-muted-foreground bg-accent/50 rounded px-2.5 py-2 whitespace-pre-wrap break-all leading-relaxed max-h-32 overflow-y-auto",children:e.computeExpression})]}),e.comment&&l.jsxs("div",{className:"px-4 py-2.5 border-b border-border/50",children:[l.jsx("div",{className:"text-[9px] text-muted-foreground/60 uppercase tracking-wider mb-1",children:"Note"}),l.jsx("p",{className:"text-[10px] text-muted-foreground/80 italic",children:e.comment})]}),e.upstreamColumns.length>0&&l.jsxs("div",{className:"px-4 py-2.5 border-b border-border/50",children:[l.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[l.jsx(Ie,{className:"h-3 w-3 text-muted-foreground/50"}),l.jsxs("div",{className:"text-[9px] text-muted-foreground/60 uppercase tracking-wider",children:["Depends On (",e.upstreamColumns.length,")"]})]}),l.jsx("div",{className:"space-y-px",children:e.upstreamColumns.map(s=>l.jsxs("button",{onClick:()=>n(s),className:"w-full flex items-center gap-2 px-2 py-1.5 rounded text-left hover:bg-accent/50 transition-colors group",children:[l.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-muted-foreground/30 group-hover:bg-k-yellow transition-colors"}),l.jsx("span",{className:"text-[10px] text-foreground/80 font-medium truncate",children:s}),l.jsx(tr,{className:"h-2.5 w-2.5 text-muted-foreground/30 ml-auto group-hover:text-foreground transition-colors"})]},s))})]}),e.downstreamColumns.length>0&&l.jsxs("div",{className:"px-4 py-2.5 border-b border-border/50",children:[l.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[l.jsx(we,{className:"h-3 w-3 text-k-yellow/60"}),l.jsxs("div",{className:"text-[9px] text-muted-foreground/60 uppercase tracking-wider",children:["Used By (",e.downstreamColumns.length,")"]})]}),l.jsx("div",{className:"space-y-px",children:e.downstreamColumns.map(s=>l.jsxs("button",{onClick:()=>n(s),className:"w-full flex items-center gap-2 px-2 py-1.5 rounded text-left hover:bg-accent/50 transition-colors group",children:[l.jsx(we,{className:"h-2.5 w-2.5 text-k-yellow/30 group-hover:text-k-yellow transition-colors"}),l.jsx("span",{className:"text-[10px] text-foreground/80 font-medium truncate",children:s}),l.jsx(tr,{className:"h-2.5 w-2.5 text-muted-foreground/30 ml-auto group-hover:text-foreground transition-colors"})]},s))})]}),!e.isComputed&&e.downstreamColumns.length===0&&l.jsx("div",{className:"px-4 py-6 text-center",children:l.jsx("p",{className:"text-[10px] text-muted-foreground/40",children:"This source column is not referenced by any computed columns."})})]})}function vb(){return l.jsxs("div",{className:"h-40 border border-border/40 rounded-lg bg-accent/20 flex flex-col items-center justify-center text-center p-6",children:[l.jsx(mp,{className:"h-5 w-5 text-muted-foreground/30 mb-2"}),l.jsx("p",{className:"text-[10px] text-muted-foreground/50 max-w-[200px]",children:"No column dependencies to visualize. Add computed columns that reference other columns."})]})}function mb({columns:e}){const{layoutedNodes:a,layoutedEdges:n,sourceCount:t,computedCount:r}=M.useMemo(()=>{const{nodes:p,edges:m,sourceCount:g,computedCount:b}=ib(e);return{layoutedNodes:sb(p,m),layoutedEdges:m,sourceCount:g,computedCount:b}},[e]),[i,,o]=Hf(a),[s,,u]=Kf(n),[c,d]=M.useState(null),f=M.useRef(!1),h=M.useCallback((p,m)=>{f.current=!0,d(g=>m.id===g?null:m.id)},[]),v=M.useCallback(()=>{if(f.current){f.current=!1;return}d(null)},[]),y=M.useMemo(()=>ob(s,c),[s,c]),x=M.useMemo(()=>c?i.find(p=>p.id===c)?.data??null:null,[i,c]);return n.length===0?l.jsx(vb,{}):l.jsxs("div",{className:"relative h-full w-full overflow-hidden bg-card",children:[l.jsx("div",{className:G("h-full transition-all duration-200",x?"pr-[280px]":""),children:l.jsxs(zf,{nodes:i,edges:y,onNodesChange:o,onEdgesChange:u,onNodeClick:h,onPaneClick:v,nodeTypes:hb,edgeTypes:lb,fitView:!0,fitViewOptions:{padding:.3,duration:300},nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,selectNodesOnDrag:!1,minZoom:.3,maxZoom:1.5,proOptions:{hideAttribution:!0},children:[l.jsx(Wf,{variant:pp.Dots,gap:20,size:1,color:"#1a1a1a"}),l.jsx(mo,{position:"top-left",children:l.jsx("div",{className:"bg-card/90 backdrop-blur-sm border border-border/40 rounded px-2.5 py-1.5 flex items-center gap-2.5",children:l.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground",children:[l.jsx("span",{className:"font-semibold text-foreground",children:t})," source",l.jsx("span",{className:"text-muted-foreground/30",children:"→"}),l.jsx("span",{className:"font-semibold text-k-yellow",children:r})," computed"]})})}),l.jsx(mo,{position:"top-right",children:l.jsxs("div",{className:"bg-card/90 backdrop-blur-sm border border-border/40 rounded px-2.5 py-1.5 space-y-1",children:[l.jsx("div",{className:"text-[8px] text-muted-foreground/50 uppercase tracking-wider font-semibold",children:"Legend"}),l.jsxs("div",{className:"flex items-center gap-1.5 text-[9px] text-muted-foreground/60",children:[l.jsx("div",{className:"w-2.5 h-2.5 rounded-sm border border-border/60 bg-card"}),"Source Column"]}),l.jsxs("div",{className:"flex items-center gap-1.5 text-[9px] text-muted-foreground/60",children:[l.jsx("div",{className:"w-2.5 h-2.5 rounded-sm border border-k-yellow/40 bg-k-yellow/10"}),"Computed Column"]})]})}),l.jsx($f,{showInteractive:!1,className:"!bg-card !border-border/40 !rounded-lg [&>button]:!bg-card [&>button]:!border-border/40 [&>button]:!text-muted-foreground [&>button:hover]:!bg-accent"})]})}),x&&l.jsx(pb,{node:x,onClose:()=>d(null),onNavigate:p=>d(p)})]})}function gb({columns:e}){const a=e.map(n=>n.name).join("|");return l.jsx(hp,{children:l.jsx(mb,{columns:e},a)})}const tp={builtin:{text:"text-muted-foreground/70",label:"built-in"},custom_udf:{text:"text-k-yellow/80",label:"UDF"},query:{text:"text-blue-400/80",label:"query"},unknown:{text:"text-muted-foreground/50",label:"fn"}};function bb({id:e,sourceX:a,sourceY:n,targetX:t,targetY:r,sourcePosition:i,targetPosition:o,data:s,markerEnd:u}){const[c,d,f]=Yf({sourceX:a,sourceY:n,targetX:t,targetY:r,sourcePosition:i,targetPosition:o,borderRadius:16}),h=s,v=h?.label,y=h?.edgeType==="query";return l.jsxs(l.Fragment,{children:[l.jsx(Jf,{id:e,path:c,markerEnd:u,style:{stroke:y?"#888":"#333",strokeWidth:y?1:1.5,strokeDasharray:y?"5 3":void 0,opacity:y?.5:.8}}),v&&l.jsx(vp,{children:l.jsx("div",{style:{transform:`translate(-50%, -50%) translate(${d}px, ${f}px)`},className:G("absolute pointer-events-all px-1.5 py-0.5 rounded border text-[8px] font-mono",y?"bg-card border-border/40 text-muted-foreground/60":"bg-card border-border/60 text-muted-foreground"),children:v})})]})}const xb={labeled:bb};function yb({data:e}){const a=e.total_errors>0,n=e.columns.filter(r=>r.is_computed),t=e.columns.filter(r=>!r.is_computed);return l.jsxs("div",{className:G("rounded-lg border bg-card shadow-sm min-w-[200px] max-w-[240px] cursor-pointer transition-all",a?"border-destructive/30":"border-border/60",e.isSelected&&"ring-1 ring-k-yellow/50 border-k-yellow/30"),onClick:()=>e.onSelect(e.path),children:[e.hasIncoming&&l.jsx(er,{type:"target",position:rr.Top,className:"!bg-border !w-2 !h-2 !-top-1"}),l.jsxs("div",{className:"px-3 py-2 border-b border-border/40",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[e.is_view?l.jsx(Ae,{className:"h-3 w-3 text-muted-foreground/60 shrink-0"}):l.jsx(qe,{className:"h-3 w-3 text-muted-foreground/60 shrink-0"}),l.jsx("span",{className:"text-[11px] font-semibold text-foreground truncate",children:e.name})]}),l.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[l.jsxs("span",{className:"text-[9px] text-muted-foreground/50 tabular-nums",children:[e.row_count.toLocaleString()," rows"]}),l.jsxs("span",{className:"text-[9px] text-muted-foreground/40",children:["v",e.version]}),e.indexes.length>0&&l.jsxs("span",{className:"text-[9px] text-muted-foreground/50 flex items-center gap-0.5",children:[l.jsx(He,{className:"h-2 w-2"}),e.indexes.length]}),a&&l.jsxs("span",{className:"text-[9px] text-destructive flex items-center gap-0.5",children:[l.jsx(ar,{className:"h-2 w-2"}),e.total_errors]}),e.iterator_type&&l.jsx("span",{className:"text-[8px] px-1 rounded bg-accent text-muted-foreground font-mono",children:e.iterator_type})]})]}),l.jsxs("div",{className:"px-2.5 py-1.5 space-y-px",children:[t.slice(0,3).map(r=>l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("div",{className:"w-1 h-1 rounded-full bg-muted-foreground/20 shrink-0"}),l.jsx("span",{className:"text-[9px] text-muted-foreground/40 truncate",children:r.name})]},r.name)),t.length>3&&l.jsxs("div",{className:"text-[8px] text-muted-foreground/25 pl-2.5",children:["+",t.length-3," more"]}),n.length>0&&l.jsxs(l.Fragment,{children:[t.length>0&&l.jsx("div",{className:"border-t border-border/30 my-1"}),n.slice(0,4).map(r=>{const i=r.func_type?tp[r.func_type]:null;return l.jsxs("div",{className:"flex items-center gap-1",children:[l.jsx(we,{className:G("h-2 w-2 shrink-0",r.error_count>0?"text-destructive":"text-k-yellow/50")}),l.jsx("span",{className:G("text-[9px] truncate",r.error_count>0?"text-destructive/80":"text-foreground/70"),children:r.name}),r.func_name&&i&&l.jsx("span",{className:G("text-[7px] shrink-0 font-mono",i.text),children:r.func_name})]},r.name)}),n.length>4&&l.jsxs("div",{className:"text-[8px] text-muted-foreground/25 pl-2.5",children:["+",n.length-4," more"]})]})]}),e.hasOutgoing&&l.jsx(er,{type:"source",position:rr.Bottom,className:"!bg-border !w-2 !h-2 !-bottom-1"})]})}const _b={tableNode:yb};function wb({node:e,onClose:a,onShowColumnFlow:n}){const[t,r]=M.useState(!1),i=e.columns.some(u=>u.depends_on&&u.depends_on.length>0),o=e.columns.filter(u=>u.is_computed),s=e.columns.filter(u=>!u.is_computed);return l.jsxs("div",{className:"w-[360px] shrink-0 border-l border-border bg-card overflow-y-auto",children:[l.jsxs("div",{className:"px-5 py-4 border-b border-border flex items-start justify-between sticky top-0 bg-card z-10",children:[l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[e.is_view?l.jsx(Ae,{className:"h-4 w-4 text-muted-foreground shrink-0"}):l.jsx(qe,{className:"h-4 w-4 text-muted-foreground shrink-0"}),l.jsx("h3",{className:"text-sm font-semibold truncate",children:e.name})]}),l.jsxs("div",{className:"flex items-center gap-2 mt-1 ml-6",children:[l.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:e.path}),e.iterator_type&&l.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-accent text-muted-foreground font-mono",children:e.iterator_type})]})]}),l.jsx("button",{onClick:a,className:"text-muted-foreground hover:text-foreground transition-colors p-1 -mr-1 -mt-1 rounded hover:bg-accent",children:l.jsx(Ve,{className:"h-4 w-4"})})]}),l.jsx("div",{className:"grid grid-cols-4 px-5 py-3 border-b border-border",children:[{label:"Rows",value:e.row_count.toLocaleString(),isError:!1},{label:"Version",value:`v${e.version}`,isError:!1},{label:"Computed",value:String(e.computed_count),isError:!1},{label:"Errors",value:String(e.total_errors),isError:e.total_errors>0}].map(u=>l.jsxs("div",{className:"text-center",children:[l.jsx("div",{className:G("text-sm font-semibold tabular-nums",u.isError?"text-destructive":"text-foreground"),children:u.value}),l.jsx("div",{className:"text-[10px] text-muted-foreground mt-0.5",children:u.label})]},u.label))}),i&&l.jsx("div",{className:"px-5 py-3 border-b border-border",children:l.jsxs("button",{onClick:n,className:"w-full flex items-center gap-2.5 px-3 py-2.5 rounded-lg border border-k-yellow/20 bg-k-yellow/5 hover:bg-k-yellow/10 transition-colors text-left group",children:[l.jsx(Ie,{className:"h-4 w-4 text-k-yellow/70 shrink-0"}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("div",{className:"text-[11px] font-semibold text-foreground",children:"Column Data Flow"}),l.jsx("div",{className:"text-[10px] text-muted-foreground/60",children:"Visualize column dependencies"})]}),l.jsx(nr,{className:"h-3.5 w-3.5 text-muted-foreground/40 -rotate-90 group-hover:text-k-yellow/70 transition-colors shrink-0"})]})}),e.base&&l.jsxs("div",{className:"px-5 py-3 border-b border-border flex items-center gap-2",children:[l.jsx(Ie,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),l.jsx("span",{className:"text-xs text-muted-foreground",children:"Derived from"}),l.jsx("span",{className:"text-xs text-foreground font-mono font-medium",children:e.base})]}),e.indexes.length>0&&l.jsxs("div",{className:"px-5 py-3 border-b border-border",children:[l.jsx(Xe,{children:"Embedding Indices"}),l.jsx("div",{className:"space-y-2",children:e.indexes.map(u=>l.jsxs("div",{className:"flex items-start gap-2",children:[l.jsx(He,{className:"h-3.5 w-3.5 text-muted-foreground mt-0.5 shrink-0"}),l.jsxs("div",{className:"min-w-0",children:[l.jsx("div",{className:"text-xs text-foreground",children:u.columns.join(", ")}),l.jsx("p",{className:"text-[11px] text-muted-foreground break-words leading-relaxed mt-0.5",children:u.embedding})]})]},u.name))})]}),s.length>0&&l.jsxs("div",{className:"px-5 py-3 border-b border-border",children:[l.jsxs(Xe,{children:["Insertable Columns (",s.length,")"]}),l.jsx("div",{className:"space-y-1",children:s.map(u=>l.jsxs("div",{className:"flex items-baseline gap-2 text-xs min-h-[20px]",children:[l.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-muted-foreground/20 shrink-0 mt-[5px]"}),l.jsx("span",{className:"text-foreground/80 shrink-0",children:u.name}),u.defined_in&&!u.defined_in_self&&l.jsxs("span",{className:"text-[10px] text-muted-foreground/50 italic shrink-0",children:["from ",u.defined_in]}),l.jsx("span",{className:"text-muted-foreground/40 ml-auto text-[11px] font-mono text-right shrink-0",children:u.type})]},u.name))})]}),o.length>0&&l.jsxs("div",{className:"px-5 py-3 border-b border-border",children:[l.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[l.jsx(we,{className:"h-3 w-3 text-k-yellow/60"}),l.jsxs(Xe,{className:"mb-0",children:["Computed Pipeline (",o.length,")"]})]}),l.jsx("div",{className:"space-y-1.5",children:o.map((u,c)=>l.jsx(qb,{col:u,step:c+1},u.name))})]}),e.versions.length>0&&l.jsxs("div",{className:"px-5 py-3",children:[l.jsxs("button",{onClick:()=>r(!t),className:"flex items-center gap-1.5 mb-2 hover:text-foreground transition-colors",children:[l.jsx(nr,{className:G("h-3 w-3 text-muted-foreground transition-transform",t&&"rotate-180")}),l.jsxs(Xe,{className:"mb-0",children:["Version History (",e.versions.length,")"]})]}),t&&l.jsx("div",{className:"space-y-1 ml-1",children:e.versions.map(u=>l.jsxs("div",{className:"flex items-center gap-3 text-xs",children:[l.jsxs("span",{className:"text-muted-foreground w-6 text-right tabular-nums",children:["v",u.version]}),l.jsx("span",{className:G("px-1.5 py-0.5 rounded text-[10px] min-w-[50px] text-center",u.change_type==="schema"?"bg-accent text-muted-foreground":"bg-accent/50 text-muted-foreground/70"),children:u.change_type}),l.jsxs("span",{className:"text-muted-foreground tabular-nums",children:["+",u.inserts]}),u.updates>0&&l.jsxs("span",{className:"text-muted-foreground tabular-nums",children:["~",u.updates]}),u.deletes>0&&l.jsxs("span",{className:"text-muted-foreground tabular-nums",children:["-",u.deletes]}),u.errors>0&&l.jsxs("span",{className:"text-destructive tabular-nums",children:["err:",u.errors]})]},u.version))})]})]})}function Xe({children:e,className:a}){return l.jsx("div",{className:G("text-[10px] font-medium text-muted-foreground uppercase tracking-wider mb-2",a),children:e})}function qb({col:e,step:a}){const[n,t]=M.useState(!1),r=e.func_type?tp[e.func_type]:null;return l.jsxs("div",{className:"rounded-md border border-border overflow-hidden",children:[l.jsxs("button",{className:"w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-accent/50 transition-colors",onClick:()=>t(!n),children:[l.jsxs("span",{className:"text-[10px] text-muted-foreground w-5 shrink-0 tabular-nums",children:["#",a]}),l.jsx("span",{className:G("text-xs font-medium truncate",e.error_count>0?"text-destructive":"text-foreground"),children:e.name}),r&&l.jsx("span",{className:G("text-[10px] px-1.5 py-0.5 rounded bg-accent font-mono shrink-0",r.text),children:r.label}),l.jsx(nr,{className:G("h-3 w-3 text-muted-foreground transition-transform shrink-0 ml-auto",n&&"rotate-180")})]}),n&&l.jsxs("div",{className:"px-3 pb-3 pt-2 space-y-2 border-t border-border",children:[e.func_name&&l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs("span",{className:G("text-xs font-mono font-medium",r?.text??"text-muted-foreground"),children:[e.func_name,"()"]}),r&&l.jsx("span",{className:"text-[10px] text-muted-foreground",children:e.func_type==="builtin"?"pixeltable built-in":e.func_type==="custom_udf"?"@pxt.udf":e.func_type==="query"?"@pxt.query":""})]}),e.computed_with&&l.jsx("pre",{className:"text-[11px] text-muted-foreground font-mono leading-relaxed bg-accent rounded-md px-3 py-2 whitespace-pre-wrap break-all",children:e.computed_with}),e.depends_on&&e.depends_on.length>0&&l.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[l.jsx(Ie,{className:"h-3 w-3 text-muted-foreground shrink-0"}),e.depends_on.map(i=>l.jsx("span",{className:"text-[10px] bg-accent text-muted-foreground px-1.5 py-0.5 rounded",children:i},i))]}),e.comment&&l.jsx("div",{className:"text-[10px] text-muted-foreground/70 italic",children:e.comment}),e.custom_metadata&&Object.keys(e.custom_metadata).length>0&&l.jsxs("div",{className:"text-[10px] text-muted-foreground/60",children:[l.jsx("span",{className:"font-medium",children:"Metadata:"})," ",Object.entries(e.custom_metadata).map(([i,o])=>l.jsxs("span",{className:"bg-accent px-1.5 py-0.5 rounded mr-1",children:[i,"=",String(o)]},i))]}),e.error_count>0&&l.jsxs("div",{className:"text-xs text-destructive flex items-center gap-1.5",children:[l.jsx(ar,{className:"h-3 w-3"}),e.error_count," errors in sampled rows"]})]})]})}function Nb(e,a){const n=new Map,t=new Map;for(const m of a)m.type==="view"&&(n.has(m.source)||n.set(m.source,[]),n.get(m.source).push(m.target),t.set(m.target,m.source));const r=new Map(e.map(m=>[m.path,m])),i=e.filter(m=>!t.has(m.path)&&n.has(m.path)),o=e.filter(m=>!t.has(m.path)&&!n.has(m.path)),s=240,u=100,c=40,d=100,f=new Map;let h=0;function v(m){const g=r.get(m);return g?u+Math.min(g.columns.length,10)*14:u}function y(m){const g=n.get(m)||[];if(g.length===0)return s;const b=g.map(y);return Math.max(s,b.reduce((_,w)=>_+w+c,-c))}function x(m,g,b){if(f.has(m))return;f.set(m,{x:g,y:b});const _=n.get(m)||[];if(_.length===0)return;const w=y(m);let N=g-w/2+s/2;for(const q of _){const k=y(q),j=N+k/2-s/2;x(q,j,b+v(m)+d),N+=k+c}}for(const m of i){const g=y(m.path);x(m.path,h+g/2-s/2,0),h+=g+c*2}const p=0;for(const m of o)f.set(m.path,{x:h,y:p}),h+=s+c;return e.map(m=>({id:m.path,type:"tableNode",position:f.get(m.path)||{x:0,y:0},data:m}))}function jb(){const[e,a]=M.useState(null),[n,t]=M.useState(!0),[r,i]=M.useState(null),[o,s]=M.useState(null),[u,c]=M.useState(null),[d,f,h]=Hf([]),[v,y,x]=Kf([]),p=M.useCallback(b=>{s(_=>{const w=_===b?null:b;return f(N=>N.map(q=>({...q,data:{...q.data,isSelected:q.id===w}}))),w})},[f]);Vf(()=>{cp().then(b=>{a(b);const _=new Set(b.edges.map(j=>j.target)),w=new Set(b.edges.map(j=>j.source)),N=b.nodes.map(j=>({...j,isSelected:!1,onSelect:p,hasIncoming:_.has(j.path),hasOutgoing:w.has(j.path)})),q=Nb(b.nodes,b.edges).map(j=>({...j,data:{...N.find(R=>R.path===j.id)}})),k=b.edges.map((j,R)=>({id:`e-${R}`,source:j.source,target:j.target,type:"labeled",animated:j.type==="view",data:{label:j.label,edgeType:j.type}}));f(q),y(k),t(!1)}).catch(b=>{i(b instanceof Error?b.message:"Failed to load pipeline"),t(!1)})});const m=M.useMemo(()=>e?.nodes.find(b=>b.path===o)??null,[e,o]),g=M.useMemo(()=>{if(!e)return null;const b=e.nodes.filter(j=>!j.is_view).length,_=e.nodes.filter(j=>j.is_view).length,w=e.nodes.reduce((j,R)=>j+R.row_count,0),N=e.nodes.reduce((j,R)=>j+R.computed_count,0),q=e.nodes.reduce((j,R)=>j+R.total_errors,0),k=e.nodes.reduce((j,R)=>j+R.indexes.length,0);return{tables:b,views:_,totalRows:w,totalComputed:N,totalErrors:q,totalIndices:k}},[e]);return n?l.jsx("div",{className:"flex-1 flex items-center justify-center",children:l.jsx(Ue,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):r?l.jsx("div",{className:"flex-1 flex items-center justify-center",children:l.jsxs("div",{className:"text-center space-y-2",children:[l.jsx(ar,{className:"h-6 w-6 text-destructive mx-auto"}),l.jsx("p",{className:"text-xs text-muted-foreground",children:r})]})}):u?l.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[l.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b border-border/40 shrink-0",children:[l.jsxs("button",{onClick:()=>c(null),className:"flex items-center gap-1.5 text-[11px] text-muted-foreground hover:text-foreground transition-colors rounded-md px-2 py-1 hover:bg-accent",children:[l.jsx(xp,{className:"h-3.5 w-3.5"}),"Pipeline"]}),l.jsx("span",{className:"text-muted-foreground/30 text-[11px]",children:"/"}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[u.is_view?l.jsx(Ae,{className:"h-3 w-3 text-muted-foreground/50"}):l.jsx(qe,{className:"h-3 w-3 text-muted-foreground/50"}),l.jsx("span",{className:"text-[11px] font-semibold text-foreground",children:u.name})]}),l.jsx("span",{className:"text-muted-foreground/30 text-[11px]",children:"/"}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(Ie,{className:"h-3 w-3 text-k-yellow/60"}),l.jsx("span",{className:"text-[11px] font-medium text-k-yellow/80",children:"Column Data Flow"})]})]}),l.jsx("div",{className:"flex-1 min-h-0",children:l.jsx(gb,{columns:u.columns})})]}):l.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[g&&l.jsxs("div",{className:"flex items-center gap-4 px-4 py-2 border-b border-border/40 shrink-0",children:[[{icon:qe,value:g.tables,label:"tables"},{icon:Ae,value:g.views,label:"views"},{icon:eh,value:g.totalRows.toLocaleString(),label:"rows"},{icon:we,value:g.totalComputed,label:"computed"},{icon:He,value:g.totalIndices,label:"indices"}].map(b=>l.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[l.jsx(b.icon,{className:"h-3 w-3 text-muted-foreground/50"}),l.jsx("span",{className:"tabular-nums",children:b.value}),l.jsx("span",{className:"text-muted-foreground/50",children:b.label})]},b.label)),g.totalErrors>0&&l.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-destructive",children:[l.jsx(ar,{className:"h-3 w-3"}),l.jsxs("span",{children:[g.totalErrors," errors"]})]})]}),l.jsxs("div",{className:"flex-1 flex min-h-0",children:[l.jsx("div",{className:"flex-1 relative min-h-0",children:l.jsxs(zf,{nodes:d,edges:v,onNodesChange:h,onEdgesChange:x,nodeTypes:_b,edgeTypes:xb,fitView:!0,fitViewOptions:{padding:.2},minZoom:.2,maxZoom:1.5,proOptions:{hideAttribution:!0},children:[l.jsx(Wf,{color:"#1a1a1a",gap:24,size:1}),l.jsx($f,{className:"!bg-card !border-border !rounded-lg [&>button]:!bg-card [&>button]:!border-border/60 [&>button]:!text-muted-foreground [&>button:hover]:!bg-accent"})]})}),m&&l.jsx(wb,{node:m,onClose:()=>s(null),onShowColumnFlow:()=>c(m)})]})]})}const Cb=[{label:"Agent Pipeline",icon:op,color:"text-blue-400",match:e=>["tools","chat_history","collection"].includes(e)},{label:"Documents",icon:Qf,color:"text-amber-400",match:e=>e==="chunks"},{label:"Images",icon:Uf,color:"text-emerald-400",match:e=>e==="images"},{label:"Videos",icon:Zf,color:"text-rose-400",match:e=>["videos","video_frames","video_audio_chunks"].includes(e)},{label:"Audio",icon:Xf,color:"text-orange-400",match:e=>["audios","audio_chunks"].includes(e)},{label:"Generation",icon:Cp,color:"text-pink-400",match:e=>e.includes("generation_tasks")||e==="speech_tasks"},{label:"Memory & Config",icon:up,color:"text-purple-400",match:e=>["memory_bank","user_personas"].includes(e)},{label:"Data Tables",icon:Dp,color:"text-cyan-400",match:e=>e.startsWith("csv_")}];function Ke(e){return e.replace(/^agents\//,"")}function Rb(e){const a=Cb.map(t=>({group:t,tables:[],views:[]})),n=[];for(const t of e){const r=Ke(t.path);let i=!1;for(const o of a)if(o.group.match(r,t)){t.type==="view"?o.views.push(t):o.tables.push(t),i=!0;break}i||n.push(t)}return n.length>0&&a.push({group:{label:"Other",icon:Mp,color:"text-muted-foreground",match:()=>!1},tables:n.filter(t=>t.type!=="view"),views:n.filter(t=>t.type==="view")}),a.filter(t=>t.tables.length+t.views.length>0)}function ex(){const{addToast:e}=sp(),[a,n]=M.useState([]),[t,r]=M.useState(!0),[i,o]=M.useState(null),[s,u]=M.useState(null),[c,d]=M.useState(!1),[f,h]=M.useState(new Set),[v,y]=M.useState(""),[x,p]=M.useState(""),[m,g]=M.useState(!1),[b,_]=M.useState(""),[w,N]=M.useState(""),[q,k]=M.useState(""),[j,R]=M.useState(""),[T,O]=M.useState("inner"),[P,F]=M.useState(null),[U,$]=M.useState(!1),[H,ne]=M.useState(null),[xe,Ee]=M.useState(!1),Se=M.useMemo(()=>{if(!v.trim())return a;const S=v.toLowerCase();return a.filter(L=>L.path.toLowerCase().includes(S))},[a,v]),ye=M.useMemo(()=>Rb(Se),[Se]),se=M.useMemo(()=>{if(!s||!x.trim())return s?.rows??[];const S=x.toLowerCase();return s.rows.filter(L=>s.columns.some(Y=>{const oe=L[Y];return oe==null?!1:String(oe).toLowerCase().includes(S)}))},[s,x]),C=M.useCallback(()=>{if(!s||!i)return;const S=x.trim()?se:s.rows;if(S.length===0){e("No rows to download","info");return}const L=s.columns,Y=[L.map(Bf).join(",")];for(const V of S)Y.push(L.map(ue=>Bf(Hs(V[ue]))).join(","));const oe=new Blob([Y.join(` `)],{type:"text/csv;charset=utf-8;"}),re=URL.createObjectURL(oe),X=document.createElement("a");X.href=re,X.download=`${Ke(i.path)}.csv`,X.click(),URL.revokeObjectURL(re)},[s,i,se,x,e]),E=M.useCallback(async(S=.1)=>{if(i){Ee(!0),ne(null);try{const L=await dp({path:i.path,fraction:S,seed:42,limit:100});ne(L),e(`Sampled ${L.sample_count} of ${L.total} rows (${Math.round(S*100)}%)`,"success")}catch(L){e(L instanceof Error?L.message:"Sampling failed","error")}Ee(!1)}},[i,e]);Vf(()=>{async function S(){try{const L=await fp();n(L.tables)}catch(L){e(L instanceof Error?L.message:"Failed to load tables","error")}finally{r(!1)}}S()});const I=M.useCallback(async S=>{o(S),d(!0),u(null),p(""),ne(null);try{const L=await vo(S.path,50,0);u(L)}catch(L){e(L instanceof Error?L.message:"Failed to load rows","error")}finally{d(!1)}},[e]),A=M.useCallback(async S=>{if(i){d(!0);try{const L=await vo(i.path,50,S);u(L)}catch(L){e(L instanceof Error?L.message:"Failed to load rows","error")}finally{d(!1)}}},[i,e]),D=M.useMemo(()=>a.find(S=>S.path===b),[a,b]),K=M.useMemo(()=>a.find(S=>S.path===w),[a,w]),W=M.useCallback(async()=>{if(!(!b||!w||!q&&T!=="cross"||!j&&T!=="cross")){$(!0),F(null);try{const S=await lp({left_table:b,right_table:w,left_column:q,right_column:j,join_type:T,limit:50});F(S)}catch(S){e(S instanceof Error?S.message:"Join failed","error")}finally{$(!1)}}},[b,w,q,j,T,e]),Q=M.useCallback(S=>{h(L=>{const Y=new Set(L);return Y.has(S)?Y.delete(S):Y.add(S),Y})},[]),[me,ee]=M.useState("tables"),Z=a.reduce((S,L)=>S+L.row_count,0),B=a.filter(S=>S.type==="table").length,fe=a.filter(S=>S.type==="view").length;return l.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[l.jsxs("div",{className:"flex items-center gap-1 px-4 pt-3 pb-2 shrink-0",children:[l.jsxs("h2",{className:"text-sm font-semibold text-foreground flex items-center gap-2 mr-4",children:[l.jsx(Vs,{className:"h-4 w-4 text-k-yellow"}),"Database"]}),["tables","pipeline"].map(S=>l.jsxs("button",{onClick:()=>ee(S),className:G("flex items-center gap-1.5 px-3 py-1 rounded-md text-[11px] font-medium transition-colors",me===S?"bg-accent text-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),children:[S==="tables"?l.jsx(qe,{className:"h-3 w-3"}):l.jsx(Ie,{className:"h-3 w-3"}),S==="tables"?"Tables":"Pipeline"]},S))]}),me==="tables"&&l.jsxs("div",{className:"mx-4 mb-2 flex items-start gap-2 rounded-lg border border-border bg-muted/30 px-3 py-2 text-[10px] text-muted-foreground",children:[l.jsx(qp,{className:"mt-0.5 h-3 w-3 shrink-0 text-k-yellow"}),l.jsxs("div",{children:["Schema changes live in ",l.jsx("code",{children:"pixelbot/app.py"}),". Use ",l.jsx("code",{children:"pxt schema diff pixelbot/app.py pixelbot_v3"}),", ",l.jsx("code",{children:"pxt errors pixelbot_v3/TABLE"}),", and ",l.jsx("code",{children:"pxt recompute pixelbot_v3/TABLE COLUMN --errors-only -f"}),"."]})]}),me==="pipeline"?l.jsx(jb,{}):l.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[l.jsxs("div",{className:"w-72 shrink-0 border-r border-border/60 flex flex-col bg-card/20",children:[l.jsx("div",{className:"px-4 pt-2 pb-3",children:l.jsxs("p",{className:"text-[10px] text-muted-foreground",children:[a.length," objects · ",Z.toLocaleString()," total rows"]})}),l.jsxs("div",{className:"flex gap-2 px-4 pb-2",children:[l.jsxs(qr,{variant:"secondary",className:"text-[9px]",children:[l.jsx(qe,{className:"h-2.5 w-2.5 mr-1"}),B," tables"]}),l.jsxs(qr,{variant:"secondary",className:"text-[9px]",children:[l.jsx(Ae,{className:"h-2.5 w-2.5 mr-1"}),fe," views"]}),l.jsxs("button",{className:G("ml-auto flex items-center gap-1 rounded-md px-2 py-0.5 text-[9px] font-medium transition-colors",m?"bg-k-yellow/10 text-k-yellow":"text-muted-foreground hover:bg-accent hover:text-foreground"),onClick:()=>g(!m),children:[l.jsx(Qe,{className:"h-2.5 w-2.5"}),"Join"]})]}),l.jsx("div",{className:"px-3 pb-2",children:l.jsxs("div",{className:"relative",children:[l.jsx(He,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3 w-3 text-muted-foreground/50"}),l.jsx(po,{placeholder:"Filter tables...",value:v,onChange:S=>y(S.target.value),className:"h-7 pl-7 pr-7 text-[11px] rounded-md"}),v&&l.jsx("button",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground/50 hover:text-foreground transition-colors",onClick:()=>y(""),children:l.jsx(Ve,{className:"h-3 w-3"})})]})}),l.jsx("div",{className:"flex-1 overflow-y-auto px-2 pb-2",children:t?l.jsx("div",{className:"flex items-center justify-center py-12",children:l.jsx(Ue,{className:"h-5 w-5 animate-spin text-k-yellow"})}):l.jsx("div",{className:"space-y-1",children:ye.map(({group:S,tables:L,views:Y})=>{const oe=S.icon,re=f.has(S.label),X=L.length+Y.length;return l.jsxs("div",{children:[l.jsxs("button",{className:"flex items-center gap-2 w-full rounded-lg px-2.5 py-1.5 text-left hover:bg-accent/30 transition-colors",onClick:()=>Q(S.label),children:[l.jsx(nr,{className:G("h-3 w-3 shrink-0 text-muted-foreground/50 transition-transform duration-150",re&&"-rotate-90")}),l.jsx(oe,{className:G("h-3.5 w-3.5 shrink-0",S.color)}),l.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground flex-1",children:S.label}),l.jsx("span",{className:"text-[9px] text-muted-foreground/40 tabular-nums",children:X})]}),!re&&l.jsxs("div",{className:"ml-3 pl-2.5 border-l border-border/30 space-y-px mt-0.5 mb-1",children:[L.map(V=>l.jsx(Gf,{table:V,isSelected:i?.path===V.path,onClick:()=>I(V)},V.path)),Y.length>0&&L.length>0&&l.jsx("div",{className:"py-0.5"}),Y.map(V=>l.jsx(Gf,{table:V,isSelected:i?.path===V.path,onClick:()=>I(V)},V.path))]})]},S.label)})})})]}),l.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:m?l.jsx(Eb,{tables:a,joinLeft:b,joinRight:w,joinLeftCol:q,joinRightCol:j,joinType:T,joinResult:P,isJoining:U,leftTableInfo:D??null,rightTableInfo:K??null,onLeftChange:S=>{_(S),k(""),F(null)},onRightChange:S=>{N(S),R(""),F(null)},onLeftColChange:k,onRightColChange:R,onTypeChange:O,onJoin:W}):i?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"px-5 pt-4 pb-3 border-b border-border/60 shrink-0",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[l.jsx("h3",{className:"text-sm font-semibold text-foreground font-mono flex-1 min-w-0 truncate",children:i.path}),l.jsx(qr,{variant:"outline",className:G("text-[9px] shrink-0",i.type==="view"?"text-blue-400 border-blue-400/30":"text-emerald-400 border-emerald-400/30"),children:i.type}),i.base_table&&l.jsxs("span",{className:"text-[10px] text-muted-foreground/60 shrink-0",children:["from ",i.base_table]}),l.jsxs("button",{className:G("flex items-center gap-1.5 rounded-lg border border-border px-2.5 py-1 text-[10px] font-medium shrink-0","text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",(!s||s.rows.length===0)&&"opacity-30 pointer-events-none"),onClick:C,disabled:!s||s.rows.length===0,title:"Download visible rows as CSV",children:[l.jsx(Np,{className:"h-3 w-3"}),"CSV"]}),l.jsxs("button",{className:G("flex items-center gap-1.5 rounded-lg border border-border px-2.5 py-1 text-[10px] font-medium shrink-0","text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",H&&"border-k-yellow/40 bg-k-yellow/5 text-k-yellow",(!s||s.total===0)&&"opacity-30 pointer-events-none"),onClick:()=>H?ne(null):E(.1),disabled:xe||!s||s.total===0,title:H?"Clear sample — show all rows":"Sample 10% of rows (query.sample)",children:[xe?l.jsx(Ue,{className:"h-3 w-3 animate-spin"}):l.jsx(go,{className:"h-3 w-3"}),H?`Sample (${H.sample_count})`:"Sample"]})]}),l.jsx("div",{className:"flex flex-wrap gap-1.5",children:i.columns.map(S=>l.jsxs("div",{className:G("flex items-center gap-1 rounded-md px-2 py-0.5 text-[10px] border",S.is_computed?"border-amber-500/20 bg-amber-500/5 text-amber-400":"border-border bg-muted/30 text-muted-foreground"),title:S.comment||void 0,children:[S.is_computed?l.jsx(jp,{className:"h-2.5 w-2.5"}):l.jsx(kp,{className:"h-2.5 w-2.5"}),l.jsx("span",{className:"font-mono font-medium",children:S.name}),l.jsx("span",{className:"text-[8px] opacity-60",children:S.type}),S.comment&&l.jsx("span",{className:"text-[8px] opacity-40 italic max-w-[120px] truncate",children:S.comment})]},S.name))}),s&&s.rows.length>0&&l.jsxs("div",{className:"relative mt-2.5",children:[l.jsx(Ip,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3 w-3 text-muted-foreground/50"}),l.jsx(po,{placeholder:"Filter rows...",value:x,onChange:S=>p(S.target.value),className:"h-7 pl-7 pr-7 text-[11px] rounded-md"}),x&&l.jsx("button",{className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground/50 hover:text-foreground transition-colors",onClick:()=>p(""),children:l.jsx(Ve,{className:"h-3 w-3"})})]})]}),H&&l.jsxs("div",{className:"flex items-center gap-2 px-5 py-1.5 bg-k-yellow/5 border-b border-k-yellow/20 text-[10px]",children:[l.jsx(go,{className:"h-3 w-3 text-k-yellow"}),l.jsxs("span",{className:"text-k-yellow font-medium",children:["Sample: ",H.sample_count," of ",H.total," rows (",H.params.fraction!=null?`${Math.round(H.params.fraction*100)}%`:`n=${H.params.n}`,H.params.seed!=null?`, seed=${H.params.seed}`:"",")"]}),l.jsx("span",{className:"text-muted-foreground/60",children:"via query.sample()"}),l.jsx("button",{className:"ml-auto text-muted-foreground hover:text-foreground transition-colors",onClick:()=>ne(null),children:l.jsx(Ve,{className:"h-3 w-3"})})]}),(()=>{const S=H?H.columns:s?.columns??[],L=H?H.rows:se,Y=!H&&(!s||s.rows.length===0),oe=!H&&se.length===0&&s&&s.rows.length>0;return l.jsx("div",{className:"flex-1 overflow-auto",children:c||xe?l.jsx("div",{className:"flex items-center justify-center h-full",children:l.jsx(Ue,{className:"h-5 w-5 animate-spin text-k-yellow"})}):Y?l.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2",children:[l.jsx(eh,{className:"h-8 w-8 text-muted-foreground/15"}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"No rows in this table"})]}):oe?l.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2",children:[l.jsx(He,{className:"h-8 w-8 text-muted-foreground/15"}),l.jsxs("p",{className:"text-xs text-muted-foreground",children:['No rows match "',x,'"']}),l.jsx("button",{className:"text-[10px] text-k-yellow hover:underline",onClick:()=>p(""),children:"Clear filter"})]}):L.length>0?l.jsx("div",{className:"min-w-full",children:l.jsxs("table",{className:"w-full text-[11px]",children:[l.jsx("thead",{className:"sticky top-0 bg-card/90 backdrop-blur-sm z-10",children:l.jsxs("tr",{className:"border-b border-border",children:[l.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground/60 text-[9px] w-10",children:"#"}),S.map(re=>l.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground font-mono whitespace-nowrap",children:re},re))]})}),l.jsx("tbody",{children:L.map((re,X)=>l.jsxs("tr",{className:"border-b border-border/30 hover:bg-accent/30 transition-colors",children:[l.jsx("td",{className:"px-3 py-1.5 text-muted-foreground/40 tabular-nums",children:H||x?X+1:(s?.offset??0)+X+1}),S.map(V=>{const ue=re[V],ke=Hs(ue);return l.jsx("td",{className:"px-3 py-1.5 text-foreground/80 max-w-[300px] truncate font-mono",title:typeof ue=="string"?ue:JSON.stringify(ue),children:ke},V)})]},X))})]})}):null})})(),s&&(s.total>s.limit||x)&&l.jsxs("div",{className:"flex items-center justify-between px-5 py-2 border-t border-border/60 shrink-0",children:[l.jsx("span",{className:"text-[10px] text-muted-foreground",children:x?`${se.length} of ${s.rows.length} rows match`:`${s.total.toLocaleString()} rows total`}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("button",{className:"h-6 w-6 rounded flex items-center justify-center hover:bg-accent disabled:opacity-30 transition-colors",onClick:()=>A(Math.max(0,s.offset-s.limit)),disabled:s.offset===0||c,children:l.jsx(yp,{className:"h-3.5 w-3.5"})}),l.jsxs("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:[Math.floor(s.offset/s.limit)+1," /"," ",Math.ceil(s.total/s.limit)]}),l.jsx("button",{className:"h-6 w-6 rounded flex items-center justify-center hover:bg-accent disabled:opacity-30 transition-colors",onClick:()=>A(s.offset+s.limit),disabled:s.offset+s.limit>=s.total||c,children:l.jsx(tr,{className:"h-3.5 w-3.5"})})]})]})]}):l.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3",children:[l.jsx(Vs,{className:"h-12 w-12 text-muted-foreground/15"}),l.jsxs("div",{className:"text-center",children:[l.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"Select a table"}),l.jsx("p",{className:"text-xs text-muted-foreground/60 mt-1",children:"Browse the Pixeltable catalog and inspect data"})]})]})})]})]})}function Gf({table:e,isSelected:a,onClick:n}){const t=Ke(e.path),r=e.type==="view";return l.jsxs("button",{className:G("flex items-center gap-2 w-full rounded-md px-2 py-1.5 text-left transition-colors group",a?"bg-primary/10 text-foreground":"text-muted-foreground hover:bg-accent hover:text-foreground"),onClick:n,children:[r?l.jsx(Ae,{className:"h-3 w-3 shrink-0 text-blue-400/70"}):l.jsx(qe,{className:"h-3 w-3 shrink-0 text-emerald-400/70"}),l.jsx("div",{className:"flex-1 min-w-0",children:l.jsx("p",{className:"text-[11px] font-medium truncate",children:t})}),l.jsx("span",{className:"text-[9px] text-muted-foreground/40 tabular-nums shrink-0",children:e.row_count.toLocaleString()}),l.jsx(tr,{className:G("h-2.5 w-2.5 shrink-0 transition-opacity",a?"opacity-100":"opacity-0 group-hover:opacity-50")})]})}function Hs(e){if(e==null)return"—";if(typeof e=="string")return e.startsWith("120?e.slice(0,120)+"...":e;if(typeof e=="number")return String(e);if(typeof e=="boolean")return e?"true":"false";if(Array.isArray(e))return`[${e.length} items]`;if(typeof e=="object"){const a=JSON.stringify(e);return a.length>120?a.slice(0,120)+"...":a}return String(e)}function Bf(e){return e.includes(",")||e.includes('"')||e.includes(` `)?`"${e.replace(/"/g,'""')}"`:e}function Eb({tables:e,joinLeft:a,joinRight:n,joinLeftCol:t,joinRightCol:r,joinType:i,joinResult:o,isJoining:s,leftTableInfo:u,rightTableInfo:c,onLeftChange:d,onRightChange:f,onLeftColChange:h,onRightColChange:v,onTypeChange:y,onJoin:x}){return l.jsxs("div",{className:"flex flex-col h-full",children:[l.jsxs("div",{className:"px-5 pt-4 pb-3 border-b border-border/60 shrink-0 space-y-3",children:[l.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[l.jsx(Qe,{className:"h-4 w-4 text-k-yellow"}),l.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Cross-Table Join"})]}),l.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[l.jsxs("div",{className:"space-y-1.5",children:[l.jsx("label",{className:"text-[10px] font-medium text-muted-foreground",children:"Left Table"}),l.jsxs("select",{className:"w-full rounded-lg border border-border bg-card px-2.5 py-1.5 text-[11px] font-mono text-foreground focus:outline-none focus:ring-1 focus:ring-k-yellow/40",value:a,onChange:p=>d(p.target.value),children:[l.jsx("option",{value:"",children:"Select table..."}),e.map(p=>l.jsxs("option",{value:p.path,children:[Ke(p.path)," (",p.row_count,")"]},p.path))]}),u&&l.jsxs("select",{className:"w-full rounded-lg border border-border bg-card px-2.5 py-1.5 text-[11px] font-mono text-foreground focus:outline-none focus:ring-1 focus:ring-k-yellow/40",value:t,onChange:p=>h(p.target.value),children:[l.jsx("option",{value:"",children:"Join column..."}),u.columns.map(p=>l.jsxs("option",{value:p.name,children:[p.name," (",p.type,")"]},p.name))]})]}),l.jsxs("div",{className:"space-y-1.5",children:[l.jsx("label",{className:"text-[10px] font-medium text-muted-foreground",children:"Right Table"}),l.jsxs("select",{className:"w-full rounded-lg border border-border bg-card px-2.5 py-1.5 text-[11px] font-mono text-foreground focus:outline-none focus:ring-1 focus:ring-k-yellow/40",value:n,onChange:p=>f(p.target.value),children:[l.jsx("option",{value:"",children:"Select table..."}),e.map(p=>l.jsxs("option",{value:p.path,children:[Ke(p.path)," (",p.row_count,")"]},p.path))]}),c&&l.jsxs("select",{className:"w-full rounded-lg border border-border bg-card px-2.5 py-1.5 text-[11px] font-mono text-foreground focus:outline-none focus:ring-1 focus:ring-k-yellow/40",value:r,onChange:p=>v(p.target.value),children:[l.jsx("option",{value:"",children:"Join column..."}),c.columns.map(p=>l.jsxs("option",{value:p.name,children:[p.name," (",p.type,")"]},p.name))]})]})]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:"flex rounded-lg border border-border overflow-hidden",children:["inner","left","cross"].map(p=>l.jsx("button",{className:G("px-2.5 py-1 text-[10px] font-medium transition-colors",i===p?"bg-k-yellow/10 text-k-yellow":"text-muted-foreground hover:bg-accent"),onClick:()=>y(p),children:p.toUpperCase()},p))}),l.jsxs("button",{className:G("flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-medium transition-all ml-auto","bg-k-yellow text-black hover:bg-k-yellow-hover",(s||!a||!n)&&"opacity-50 pointer-events-none"),onClick:x,disabled:s||!a||!n,children:[s?l.jsx(Ue,{className:"h-3 w-3 animate-spin"}):l.jsx(Qe,{className:"h-3 w-3"}),s?"Joining...":"Run Join"]})]})]}),l.jsx("div",{className:"flex-1 overflow-auto",children:o?l.jsxs("div",{className:"min-w-full",children:[l.jsxs("div",{className:"px-5 py-2 border-b border-border/40 text-[10px] text-muted-foreground",children:[o.count," rows · ",o.join_type.toUpperCase()," JOIN on"," ",l.jsx("span",{className:"font-mono text-foreground",children:o.left_column})," ="," ",l.jsx("span",{className:"font-mono text-foreground",children:o.right_column})]}),l.jsxs("table",{className:"w-full text-[11px]",children:[l.jsx("thead",{className:"sticky top-0 bg-card/90 backdrop-blur-sm z-10",children:l.jsxs("tr",{className:"border-b border-border",children:[l.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground/60 text-[9px] w-10",children:"#"}),o.columns.map(p=>l.jsx("th",{className:"px-3 py-2 text-left font-medium text-muted-foreground font-mono whitespace-nowrap",children:p},p))]})}),l.jsx("tbody",{children:o.rows.map((p,m)=>l.jsxs("tr",{className:"border-b border-border/30 hover:bg-accent/30 transition-colors",children:[l.jsx("td",{className:"px-3 py-1.5 text-muted-foreground/40 tabular-nums",children:m+1}),o.columns.map(g=>l.jsx("td",{className:"px-3 py-1.5 text-foreground/80 max-w-[300px] truncate font-mono",title:String(p[g]??""),children:Hs(p[g])},g))]},m))})]})]}):l.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-2",children:[l.jsx(Qe,{className:"h-8 w-8 text-muted-foreground/15"}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"Select two tables and run a join"}),l.jsx("p",{className:"text-[10px] text-muted-foreground/50 max-w-xs text-center",children:"Combine data from any two Pixeltable tables using inner, left, or cross join"})]})})]})}export{ex as DatabasePage}; diff --git a/backend/pixelbot/static/assets/developer-page-Cel5aU2N.js b/backend/pixelbot/static/assets/developer-page-C2fklkD5.js similarity index 98% rename from backend/pixelbot/static/assets/developer-page-Cel5aU2N.js rename to backend/pixelbot/static/assets/developer-page-C2fklkD5.js index 39a9351..dbd35a4 100644 --- a/backend/pixelbot/static/assets/developer-page-Cel5aU2N.js +++ b/backend/pixelbot/static/assets/developer-page-C2fklkD5.js @@ -1,4 +1,4 @@ -import{c as k,r as c,j as e,a as C,b as Y,C as X,P as D,D as Ne}from"./index-bcIN4R_6.js";import{u as Te,L as Ce}from"./use-mount-effect-Dj1RN52i.js";import{B as E}from"./badge-BIO9r-az.js";import{I as Pe}from"./input-B5vinQUU.js";import{P as S,c as j,e as Q,u as Ie,g as W}from"./index-PhySa8BR.js";import{c as Se}from"./index-FUXQzuGM.js";import{u as Z}from"./index-BBsWTzq-.js";import{u as Ee,P as ke}from"./index-B57p4poT.js";import{u as ee}from"./index-XhUYjquv.js";import{D as te}from"./download-s6JlUMMe.js";import{T as J}from"./terminal-DMddRtTc.js";import{C as z}from"./copy-BlKAoc_U.js";import{T as Ae}from"./table-2-Di1d8bNw.js";import{C as Fe}from"./chevron-down-DT2TrmF4.js";import{C as oe}from"./check-EY4MJcH5.js";import"./index-BUPn8X34.js";const Re=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],Le=k("book-open",Re);const Oe=[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]],U=k("braces",Oe);const Me=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],F=k("external-link",Me);const Ge=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]],ae=k("file-braces",Ge);const De=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]],qe=k("file-spreadsheet",De);var q="rovingFocusGroup.onEntryFocus",$e={bubbles:!1,cancelable:!0},A="RovingFocusGroup",[V,re,Ue]=Se(A),[Ve,se]=Q(A,[Ue]),[ze,He]=Ve(A),ne=c.forwardRef((t,o)=>e.jsx(V.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(V.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(Ke,{...t,ref:o})})}));ne.displayName=A;var Ke=c.forwardRef((t,o)=>{const{__scopeRovingFocusGroup:l,orientation:a,loop:s=!1,dir:i,currentTabStopId:n,defaultCurrentTabStopId:x,onCurrentTabStopIdChange:f,onEntryFocus:g,preventScrollOnEntryFocus:d=!1,...m}=t,h=c.useRef(null),_=Ie(o,h),w=W(i),[P,u]=ee({prop:n,defaultProp:x??null,onChange:f,caller:A}),[b,N]=c.useState(!1),r=Ee(g),p=re(l),y=c.useRef(!1),[I,K]=c.useState(0);return c.useEffect(()=>{const v=h.current;if(v)return v.addEventListener(q,r),()=>v.removeEventListener(q,r)},[r]),e.jsx(ze,{scope:l,orientation:a,dir:w,loop:s,currentTabStopId:P,onItemFocus:c.useCallback(v=>u(v),[u]),onItemShiftTab:c.useCallback(()=>N(!0),[]),onFocusableItemAdd:c.useCallback(()=>K(v=>v+1),[]),onFocusableItemRemove:c.useCallback(()=>K(v=>v-1),[]),children:e.jsx(S.div,{tabIndex:b||I===0?-1:0,"data-orientation":a,...m,ref:_,style:{outline:"none",...t.style},onMouseDown:j(t.onMouseDown,()=>{y.current=!0}),onFocus:j(t.onFocus,v=>{const ye=!y.current;if(v.target===v.currentTarget&&ye&&!b){const B=new CustomEvent(q,$e);if(v.currentTarget.dispatchEvent(B),!B.defaultPrevented){const G=p().filter(T=>T.focusable),je=G.find(T=>T.active),we=G.find(T=>T.id===P),_e=[je,we,...G].filter(Boolean).map(T=>T.ref.current);ce(_e,d)}}y.current=!1}),onBlur:j(t.onBlur,()=>N(!1))})})}),le="RovingFocusGroupItem",ie=c.forwardRef((t,o)=>{const{__scopeRovingFocusGroup:l,focusable:a=!0,active:s=!1,tabStopId:i,children:n,...x}=t,f=Z(),g=i||f,d=He(le,l),m=d.currentTabStopId===g,h=re(l),{onFocusableItemAdd:_,onFocusableItemRemove:w,currentTabStopId:P}=d;return c.useEffect(()=>{if(a)return _(),()=>w()},[a,_,w]),e.jsx(V.ItemSlot,{scope:l,id:g,focusable:a,active:s,children:e.jsx(S.span,{tabIndex:m?0:-1,"data-orientation":d.orientation,...x,ref:o,onMouseDown:j(t.onMouseDown,u=>{a?d.onItemFocus(g):u.preventDefault()}),onFocus:j(t.onFocus,()=>d.onItemFocus(g)),onKeyDown:j(t.onKeyDown,u=>{if(u.key==="Tab"&&u.shiftKey){d.onItemShiftTab();return}if(u.target!==u.currentTarget)return;const b=Je(u,d.orientation,d.dir);if(b!==void 0){if(u.metaKey||u.ctrlKey||u.altKey||u.shiftKey)return;u.preventDefault();let r=h().filter(p=>p.focusable).map(p=>p.ref.current);if(b==="last")r.reverse();else if(b==="prev"||b==="next"){b==="prev"&&r.reverse();const p=r.indexOf(u.currentTarget);r=d.loop?Ye(r,p+1):r.slice(p+1)}setTimeout(()=>ce(r))}}),children:typeof n=="function"?n({isCurrentTabStop:m,hasTabStop:P!=null}):n})})});ie.displayName=le;var Be={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Xe(t,o){return o!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function Je(t,o,l){const a=Xe(t.key,l);if(!(o==="vertical"&&["ArrowLeft","ArrowRight"].includes(a))&&!(o==="horizontal"&&["ArrowUp","ArrowDown"].includes(a)))return Be[a]}function ce(t,o=!1){const l=document.activeElement;for(const a of t)if(a===l||(a.focus({preventScroll:o}),document.activeElement!==l))return}function Ye(t,o){return t.map((l,a)=>t[(o+a)%t.length])}var Qe=ne,We=ie,M="Tabs",[Ze]=Q(M,[se]),de=se(),[et,H]=Ze(M),pe=c.forwardRef((t,o)=>{const{__scopeTabs:l,value:a,onValueChange:s,defaultValue:i,orientation:n="horizontal",dir:x,activationMode:f="automatic",...g}=t,d=W(x),[m,h]=ee({prop:a,onChange:s,defaultProp:i??"",caller:M});return e.jsx(et,{scope:l,baseId:Z(),value:m,onValueChange:h,orientation:n,dir:d,activationMode:f,children:e.jsx(S.div,{dir:d,"data-orientation":n,...g,ref:o})})});pe.displayName=M;var me="TabsList",ue=c.forwardRef((t,o)=>{const{__scopeTabs:l,loop:a=!0,...s}=t,i=H(me,l),n=de(l);return e.jsx(Qe,{asChild:!0,...n,orientation:i.orientation,dir:i.dir,loop:a,children:e.jsx(S.div,{role:"tablist","aria-orientation":i.orientation,...s,ref:o})})});ue.displayName=me;var xe="TabsTrigger",he=c.forwardRef((t,o)=>{const{__scopeTabs:l,value:a,disabled:s=!1,...i}=t,n=H(xe,l),x=de(l),f=ge(n.baseId,a),g=ve(n.baseId,a),d=a===n.value;return e.jsx(We,{asChild:!0,...x,focusable:!s,active:d,children:e.jsx(S.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":g,"data-state":d?"active":"inactive","data-disabled":s?"":void 0,disabled:s,id:f,...i,ref:o,onMouseDown:j(t.onMouseDown,m=>{!s&&m.button===0&&m.ctrlKey===!1?n.onValueChange(a):m.preventDefault()}),onKeyDown:j(t.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&n.onValueChange(a)}),onFocus:j(t.onFocus,()=>{const m=n.activationMode!=="manual";!d&&!s&&m&&n.onValueChange(a)})})})});he.displayName=xe;var be="TabsContent",fe=c.forwardRef((t,o)=>{const{__scopeTabs:l,value:a,forceMount:s,children:i,...n}=t,x=H(be,l),f=ge(x.baseId,a),g=ve(x.baseId,a),d=a===x.value,m=c.useRef(d);return c.useEffect(()=>{const h=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(h)},[]),e.jsx(ke,{present:s||d,children:({present:h})=>e.jsx(S.div,{"data-state":d?"active":"inactive","data-orientation":x.orientation,role:"tabpanel","aria-labelledby":f,hidden:!h,id:g,tabIndex:0,...n,ref:o,style:{...t.style,animationDuration:m.current?"0s":void 0},children:h&&i})})});fe.displayName=be;function ge(t,o){return`${t}-trigger-${o}`}function ve(t,o){return`${t}-content-${o}`}var tt=pe,ot=ue,at=he,rt=fe;const st=tt;function nt({className:t,...o}){return e.jsx(ot,{className:C("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...o})}function R({className:t,...o}){return e.jsx(at,{className:C("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium","ring-offset-background transition-all","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","disabled:pointer-events-none disabled:opacity-50","data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",t),...o})}function L({className:t,...o}){return e.jsx(rt,{className:C("mt-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",t),...o})}const $="/api",lt=[{label:"Chat & Agent",endpoints:[{method:"POST",path:"/api/query",description:"Run a query through the multimodal AI agent",curl:`curl -X POST http://localhost:8000/api/query \\ +import{c as k,r as c,j as e,a as C,b as Y,C as X,P as D,D as Ne}from"./index-BKlAZSPs.js";import{u as Te,L as Ce}from"./use-mount-effect-CEqzESrx.js";import{B as E}from"./badge-B_CNDVZh.js";import{I as Pe}from"./input-DEyNLzjf.js";import{P as S,c as j,e as Q,u as Ie,g as W}from"./index-KbvIRwKr.js";import{c as Se}from"./index-hR8PON02.js";import{u as Z}from"./index-BidtQh_T.js";import{u as Ee,P as ke}from"./index-Dr3YzRu6.js";import{u as ee}from"./index-oUe0EePc.js";import{D as te}from"./download-gDnOKy-4.js";import{T as J}from"./terminal-BeReSiBq.js";import{C as z}from"./copy-DR0TH8ar.js";import{T as Ae}from"./table-2-KM3JqDhH.js";import{C as Fe}from"./chevron-down-9h0aHSqT.js";import{C as oe}from"./check-D-roFugH.js";import"./index-B8obv054.js";const Re=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],Le=k("book-open",Re);const Oe=[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]],U=k("braces",Oe);const Me=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],F=k("external-link",Me);const Ge=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]],ae=k("file-braces",Ge);const De=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]],qe=k("file-spreadsheet",De);var q="rovingFocusGroup.onEntryFocus",$e={bubbles:!1,cancelable:!0},A="RovingFocusGroup",[V,re,Ue]=Se(A),[Ve,se]=Q(A,[Ue]),[ze,He]=Ve(A),ne=c.forwardRef((t,o)=>e.jsx(V.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(V.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(Ke,{...t,ref:o})})}));ne.displayName=A;var Ke=c.forwardRef((t,o)=>{const{__scopeRovingFocusGroup:l,orientation:a,loop:s=!1,dir:i,currentTabStopId:n,defaultCurrentTabStopId:x,onCurrentTabStopIdChange:f,onEntryFocus:g,preventScrollOnEntryFocus:d=!1,...m}=t,h=c.useRef(null),_=Ie(o,h),w=W(i),[P,u]=ee({prop:n,defaultProp:x??null,onChange:f,caller:A}),[b,N]=c.useState(!1),r=Ee(g),p=re(l),y=c.useRef(!1),[I,K]=c.useState(0);return c.useEffect(()=>{const v=h.current;if(v)return v.addEventListener(q,r),()=>v.removeEventListener(q,r)},[r]),e.jsx(ze,{scope:l,orientation:a,dir:w,loop:s,currentTabStopId:P,onItemFocus:c.useCallback(v=>u(v),[u]),onItemShiftTab:c.useCallback(()=>N(!0),[]),onFocusableItemAdd:c.useCallback(()=>K(v=>v+1),[]),onFocusableItemRemove:c.useCallback(()=>K(v=>v-1),[]),children:e.jsx(S.div,{tabIndex:b||I===0?-1:0,"data-orientation":a,...m,ref:_,style:{outline:"none",...t.style},onMouseDown:j(t.onMouseDown,()=>{y.current=!0}),onFocus:j(t.onFocus,v=>{const ye=!y.current;if(v.target===v.currentTarget&&ye&&!b){const B=new CustomEvent(q,$e);if(v.currentTarget.dispatchEvent(B),!B.defaultPrevented){const G=p().filter(T=>T.focusable),je=G.find(T=>T.active),we=G.find(T=>T.id===P),_e=[je,we,...G].filter(Boolean).map(T=>T.ref.current);ce(_e,d)}}y.current=!1}),onBlur:j(t.onBlur,()=>N(!1))})})}),le="RovingFocusGroupItem",ie=c.forwardRef((t,o)=>{const{__scopeRovingFocusGroup:l,focusable:a=!0,active:s=!1,tabStopId:i,children:n,...x}=t,f=Z(),g=i||f,d=He(le,l),m=d.currentTabStopId===g,h=re(l),{onFocusableItemAdd:_,onFocusableItemRemove:w,currentTabStopId:P}=d;return c.useEffect(()=>{if(a)return _(),()=>w()},[a,_,w]),e.jsx(V.ItemSlot,{scope:l,id:g,focusable:a,active:s,children:e.jsx(S.span,{tabIndex:m?0:-1,"data-orientation":d.orientation,...x,ref:o,onMouseDown:j(t.onMouseDown,u=>{a?d.onItemFocus(g):u.preventDefault()}),onFocus:j(t.onFocus,()=>d.onItemFocus(g)),onKeyDown:j(t.onKeyDown,u=>{if(u.key==="Tab"&&u.shiftKey){d.onItemShiftTab();return}if(u.target!==u.currentTarget)return;const b=Je(u,d.orientation,d.dir);if(b!==void 0){if(u.metaKey||u.ctrlKey||u.altKey||u.shiftKey)return;u.preventDefault();let r=h().filter(p=>p.focusable).map(p=>p.ref.current);if(b==="last")r.reverse();else if(b==="prev"||b==="next"){b==="prev"&&r.reverse();const p=r.indexOf(u.currentTarget);r=d.loop?Ye(r,p+1):r.slice(p+1)}setTimeout(()=>ce(r))}}),children:typeof n=="function"?n({isCurrentTabStop:m,hasTabStop:P!=null}):n})})});ie.displayName=le;var Be={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Xe(t,o){return o!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function Je(t,o,l){const a=Xe(t.key,l);if(!(o==="vertical"&&["ArrowLeft","ArrowRight"].includes(a))&&!(o==="horizontal"&&["ArrowUp","ArrowDown"].includes(a)))return Be[a]}function ce(t,o=!1){const l=document.activeElement;for(const a of t)if(a===l||(a.focus({preventScroll:o}),document.activeElement!==l))return}function Ye(t,o){return t.map((l,a)=>t[(o+a)%t.length])}var Qe=ne,We=ie,M="Tabs",[Ze]=Q(M,[se]),de=se(),[et,H]=Ze(M),pe=c.forwardRef((t,o)=>{const{__scopeTabs:l,value:a,onValueChange:s,defaultValue:i,orientation:n="horizontal",dir:x,activationMode:f="automatic",...g}=t,d=W(x),[m,h]=ee({prop:a,onChange:s,defaultProp:i??"",caller:M});return e.jsx(et,{scope:l,baseId:Z(),value:m,onValueChange:h,orientation:n,dir:d,activationMode:f,children:e.jsx(S.div,{dir:d,"data-orientation":n,...g,ref:o})})});pe.displayName=M;var me="TabsList",ue=c.forwardRef((t,o)=>{const{__scopeTabs:l,loop:a=!0,...s}=t,i=H(me,l),n=de(l);return e.jsx(Qe,{asChild:!0,...n,orientation:i.orientation,dir:i.dir,loop:a,children:e.jsx(S.div,{role:"tablist","aria-orientation":i.orientation,...s,ref:o})})});ue.displayName=me;var xe="TabsTrigger",he=c.forwardRef((t,o)=>{const{__scopeTabs:l,value:a,disabled:s=!1,...i}=t,n=H(xe,l),x=de(l),f=ge(n.baseId,a),g=ve(n.baseId,a),d=a===n.value;return e.jsx(We,{asChild:!0,...x,focusable:!s,active:d,children:e.jsx(S.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":g,"data-state":d?"active":"inactive","data-disabled":s?"":void 0,disabled:s,id:f,...i,ref:o,onMouseDown:j(t.onMouseDown,m=>{!s&&m.button===0&&m.ctrlKey===!1?n.onValueChange(a):m.preventDefault()}),onKeyDown:j(t.onKeyDown,m=>{[" ","Enter"].includes(m.key)&&n.onValueChange(a)}),onFocus:j(t.onFocus,()=>{const m=n.activationMode!=="manual";!d&&!s&&m&&n.onValueChange(a)})})})});he.displayName=xe;var be="TabsContent",fe=c.forwardRef((t,o)=>{const{__scopeTabs:l,value:a,forceMount:s,children:i,...n}=t,x=H(be,l),f=ge(x.baseId,a),g=ve(x.baseId,a),d=a===x.value,m=c.useRef(d);return c.useEffect(()=>{const h=requestAnimationFrame(()=>m.current=!1);return()=>cancelAnimationFrame(h)},[]),e.jsx(ke,{present:s||d,children:({present:h})=>e.jsx(S.div,{"data-state":d?"active":"inactive","data-orientation":x.orientation,role:"tabpanel","aria-labelledby":f,hidden:!h,id:g,tabIndex:0,...n,ref:o,style:{...t.style,animationDuration:m.current?"0s":void 0},children:h&&i})})});fe.displayName=be;function ge(t,o){return`${t}-trigger-${o}`}function ve(t,o){return`${t}-content-${o}`}var tt=pe,ot=ue,at=he,rt=fe;const st=tt;function nt({className:t,...o}){return e.jsx(ot,{className:C("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",t),...o})}function R({className:t,...o}){return e.jsx(at,{className:C("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium","ring-offset-background transition-all","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","disabled:pointer-events-none disabled:opacity-50","data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",t),...o})}function L({className:t,...o}){return e.jsx(rt,{className:C("mt-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",t),...o})}const $="/api",lt=[{label:"Chat & Agent",endpoints:[{method:"POST",path:"/api/query",description:"Run a query through the multimodal AI agent",curl:`curl -X POST http://localhost:8000/api/query \\ -H "Content-Type: application/json" \\ -d '{"query": "What documents do I have?"}'`}]},{label:"Files",endpoints:[{method:"POST",path:"/api/upload",description:"Upload a file (document, image, video, audio, CSV)",curl:`curl -X POST http://localhost:8000/api/upload \\ -F "file=@document.pdf"`},{method:"POST",path:"/api/add_url",description:"Import a file from URL",curl:`curl -X POST http://localhost:8000/api/add_url \\ diff --git a/backend/pixelbot/static/assets/dialog-DdsFnGPg.js b/backend/pixelbot/static/assets/dialog-C0z6ZEzu.js similarity index 98% rename from backend/pixelbot/static/assets/dialog-DdsFnGPg.js rename to backend/pixelbot/static/assets/dialog-C0z6ZEzu.js index 68c9231..b653adf 100644 --- a/backend/pixelbot/static/assets/dialog-DdsFnGPg.js +++ b/backend/pixelbot/static/assets/dialog-C0z6ZEzu.js @@ -1,4 +1,4 @@ -import{r as i,j as d,a as z}from"./index-bcIN4R_6.js";import{u as j,P as O,c as T,d as tt,a as nt,b as rt,e as ot,f as at}from"./index-PhySa8BR.js";import{u as Q}from"./index-BBsWTzq-.js";import{u as it}from"./index-XhUYjquv.js";import{u as B,P as ce}from"./index-B57p4poT.js";import{R as st}from"./index-BUPn8X34.js";import{X as ct}from"./x-DjdZKBVk.js";function ut(e,t=globalThis?.document){const n=B(e);i.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var lt="DismissableLayer",ie="dismissableLayer.update",dt="dismissableLayer.pointerDownOutside",ft="dismissableLayer.focusOutside",ve,Re=i.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),xe=i.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:u,onDismiss:s,...p}=e,l=i.useContext(Re),[f,v]=i.useState(null),m=f?.ownerDocument??globalThis?.document,[,E]=i.useState({}),D=j(t,y=>v(y)),c=Array.from(l.layers),[h]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),g=c.indexOf(h),b=f?c.indexOf(f):-1,C=l.layersWithOutsidePointerEventsDisabled.size>0,S=b>=g,w=pt(y=>{const A=y.target,L=[...l.branches].some(W=>W.contains(A));!S||L||(o?.(y),u?.(y),y.defaultPrevented||s?.())},m),R=mt(y=>{const A=y.target;[...l.branches].some(W=>W.contains(A))||(a?.(y),u?.(y),y.defaultPrevented||s?.())},m);return ut(y=>{b===l.layers.size-1&&(r?.(y),!y.defaultPrevented&&s&&(y.preventDefault(),s()))},m),i.useEffect(()=>{if(f)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(ve=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(f)),l.layers.add(f),he(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=ve)}},[f,m,n,l]),i.useEffect(()=>()=>{f&&(l.layers.delete(f),l.layersWithOutsidePointerEventsDisabled.delete(f),he())},[f,l]),i.useEffect(()=>{const y=()=>E({});return document.addEventListener(ie,y),()=>document.removeEventListener(ie,y)},[]),d.jsx(O.div,{...p,ref:D,style:{pointerEvents:C?S?"auto":"none":void 0,...e.style},onFocusCapture:T(e.onFocusCapture,R.onFocusCapture),onBlurCapture:T(e.onBlurCapture,R.onBlurCapture),onPointerDownCapture:T(e.onPointerDownCapture,w.onPointerDownCapture)})});xe.displayName=lt;var vt="DismissableLayerBranch",ht=i.forwardRef((e,t)=>{const n=i.useContext(Re),r=i.useRef(null),o=j(t,r);return i.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),d.jsx(O.div,{...e,ref:o})});ht.displayName=vt;function pt(e,t=globalThis?.document){const n=B(e),r=i.useRef(!1),o=i.useRef(()=>{});return i.useEffect(()=>{const a=s=>{if(s.target&&!r.current){let p=function(){Pe(dt,n,l,{discrete:!0})};const l={originalEvent:s};s.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=p,t.addEventListener("click",o.current,{once:!0})):p()}else t.removeEventListener("click",o.current);r.current=!1},u=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(u),t.removeEventListener("pointerdown",a),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function mt(e,t=globalThis?.document){const n=B(e),r=i.useRef(!1);return i.useEffect(()=>{const o=a=>{a.target&&!r.current&&Pe(ft,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function he(){const e=new CustomEvent(ie);document.dispatchEvent(e)}function Pe(e,t,n,{discrete:r}){const o=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?tt(o,a):o.dispatchEvent(a)}var J="focusScope.autoFocusOnMount",ee="focusScope.autoFocusOnUnmount",pe={bubbles:!1,cancelable:!0},gt="FocusScope",Oe=i.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...u}=e,[s,p]=i.useState(null),l=B(o),f=B(a),v=i.useRef(null),m=j(t,c=>p(c)),E=i.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;i.useEffect(()=>{if(r){let c=function(C){if(E.paused||!s)return;const S=C.target;s.contains(S)?v.current=S:N(v.current,{select:!0})},h=function(C){if(E.paused||!s)return;const S=C.relatedTarget;S!==null&&(s.contains(S)||N(v.current,{select:!0}))},g=function(C){if(document.activeElement===document.body)for(const w of C)w.removedNodes.length>0&&N(s)};document.addEventListener("focusin",c),document.addEventListener("focusout",h);const b=new MutationObserver(g);return s&&b.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",c),document.removeEventListener("focusout",h),b.disconnect()}}},[r,s,E.paused]),i.useEffect(()=>{if(s){ge.add(E);const c=document.activeElement;if(!s.contains(c)){const g=new CustomEvent(J,pe);s.addEventListener(J,l),s.dispatchEvent(g),g.defaultPrevented||(yt(wt(Ne(s)),{select:!0}),document.activeElement===c&&N(s))}return()=>{s.removeEventListener(J,l),setTimeout(()=>{const g=new CustomEvent(ee,pe);s.addEventListener(ee,f),s.dispatchEvent(g),g.defaultPrevented||N(c??document.body,{select:!0}),s.removeEventListener(ee,f),ge.remove(E)},0)}}},[s,l,f,E]);const D=i.useCallback(c=>{if(!n&&!r||E.paused)return;const h=c.key==="Tab"&&!c.altKey&&!c.ctrlKey&&!c.metaKey,g=document.activeElement;if(h&&g){const b=c.currentTarget,[C,S]=Et(b);C&&S?!c.shiftKey&&g===S?(c.preventDefault(),n&&N(C,{select:!0})):c.shiftKey&&g===C&&(c.preventDefault(),n&&N(S,{select:!0})):g===b&&c.preventDefault()}},[n,r,E.paused]);return d.jsx(O.div,{tabIndex:-1,...u,ref:m,onKeyDown:D})});Oe.displayName=gt;function yt(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(N(r,{select:t}),document.activeElement!==n)return}function Et(e){const t=Ne(e),n=me(t,e),r=me(t.reverse(),e);return[n,r]}function Ne(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function me(e,t){for(const n of e)if(!bt(n,{upTo:t}))return n}function bt(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 Ct(e){return e instanceof HTMLInputElement&&"select"in e}function N(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Ct(e)&&t&&e.select()}}var ge=St();function St(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=ye(e,t),e.unshift(t)},remove(t){e=ye(e,t),e[0]?.resume()}}}function ye(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function wt(e){return e.filter(t=>t.tagName!=="A")}var Dt="Portal",Te=i.forwardRef((e,t)=>{const{container:n,...r}=e,[o,a]=i.useState(!1);nt(()=>a(!0),[]);const u=n||o&&globalThis?.document?.body;return u?st.createPortal(d.jsx(O.div,{...r,ref:t}),u):null});Te.displayName=Dt;var te=0;function Rt(){i.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Ee()),document.body.insertAdjacentElement("beforeend",e[1]??Ee()),te++,()=>{te===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),te--}},[])}function Ee(){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 P=function(){return P=Object.assign||function(t){for(var n,r=1,o=arguments.length;r "u")return Ht;var t=Vt(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},$t=Fe(),k="data-scroll-locked",Gt=function(e,t,n,r){var o=e.left,a=e.top,u=e.right,s=e.gap;return n===void 0&&(n="margin"),` +import{r as i,j as d,a as z}from"./index-BKlAZSPs.js";import{u as j,P as O,c as T,d as tt,a as nt,b as rt,e as ot,f as at}from"./index-KbvIRwKr.js";import{u as Q}from"./index-BidtQh_T.js";import{u as it}from"./index-oUe0EePc.js";import{u as B,P as ce}from"./index-Dr3YzRu6.js";import{R as st}from"./index-B8obv054.js";import{X as ct}from"./x-B99eDFz6.js";function ut(e,t=globalThis?.document){const n=B(e);i.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var lt="DismissableLayer",ie="dismissableLayer.update",dt="dismissableLayer.pointerDownOutside",ft="dismissableLayer.focusOutside",ve,Re=i.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),xe=i.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:u,onDismiss:s,...p}=e,l=i.useContext(Re),[f,v]=i.useState(null),m=f?.ownerDocument??globalThis?.document,[,E]=i.useState({}),D=j(t,y=>v(y)),c=Array.from(l.layers),[h]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),g=c.indexOf(h),b=f?c.indexOf(f):-1,C=l.layersWithOutsidePointerEventsDisabled.size>0,S=b>=g,w=pt(y=>{const A=y.target,L=[...l.branches].some(W=>W.contains(A));!S||L||(o?.(y),u?.(y),y.defaultPrevented||s?.())},m),R=mt(y=>{const A=y.target;[...l.branches].some(W=>W.contains(A))||(a?.(y),u?.(y),y.defaultPrevented||s?.())},m);return ut(y=>{b===l.layers.size-1&&(r?.(y),!y.defaultPrevented&&s&&(y.preventDefault(),s()))},m),i.useEffect(()=>{if(f)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(ve=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(f)),l.layers.add(f),he(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=ve)}},[f,m,n,l]),i.useEffect(()=>()=>{f&&(l.layers.delete(f),l.layersWithOutsidePointerEventsDisabled.delete(f),he())},[f,l]),i.useEffect(()=>{const y=()=>E({});return document.addEventListener(ie,y),()=>document.removeEventListener(ie,y)},[]),d.jsx(O.div,{...p,ref:D,style:{pointerEvents:C?S?"auto":"none":void 0,...e.style},onFocusCapture:T(e.onFocusCapture,R.onFocusCapture),onBlurCapture:T(e.onBlurCapture,R.onBlurCapture),onPointerDownCapture:T(e.onPointerDownCapture,w.onPointerDownCapture)})});xe.displayName=lt;var vt="DismissableLayerBranch",ht=i.forwardRef((e,t)=>{const n=i.useContext(Re),r=i.useRef(null),o=j(t,r);return i.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),d.jsx(O.div,{...e,ref:o})});ht.displayName=vt;function pt(e,t=globalThis?.document){const n=B(e),r=i.useRef(!1),o=i.useRef(()=>{});return i.useEffect(()=>{const a=s=>{if(s.target&&!r.current){let p=function(){Pe(dt,n,l,{discrete:!0})};const l={originalEvent:s};s.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=p,t.addEventListener("click",o.current,{once:!0})):p()}else t.removeEventListener("click",o.current);r.current=!1},u=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(u),t.removeEventListener("pointerdown",a),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function mt(e,t=globalThis?.document){const n=B(e),r=i.useRef(!1);return i.useEffect(()=>{const o=a=>{a.target&&!r.current&&Pe(ft,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function he(){const e=new CustomEvent(ie);document.dispatchEvent(e)}function Pe(e,t,n,{discrete:r}){const o=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?tt(o,a):o.dispatchEvent(a)}var J="focusScope.autoFocusOnMount",ee="focusScope.autoFocusOnUnmount",pe={bubbles:!1,cancelable:!0},gt="FocusScope",Oe=i.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...u}=e,[s,p]=i.useState(null),l=B(o),f=B(a),v=i.useRef(null),m=j(t,c=>p(c)),E=i.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;i.useEffect(()=>{if(r){let c=function(C){if(E.paused||!s)return;const S=C.target;s.contains(S)?v.current=S:N(v.current,{select:!0})},h=function(C){if(E.paused||!s)return;const S=C.relatedTarget;S!==null&&(s.contains(S)||N(v.current,{select:!0}))},g=function(C){if(document.activeElement===document.body)for(const w of C)w.removedNodes.length>0&&N(s)};document.addEventListener("focusin",c),document.addEventListener("focusout",h);const b=new MutationObserver(g);return s&&b.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",c),document.removeEventListener("focusout",h),b.disconnect()}}},[r,s,E.paused]),i.useEffect(()=>{if(s){ge.add(E);const c=document.activeElement;if(!s.contains(c)){const g=new CustomEvent(J,pe);s.addEventListener(J,l),s.dispatchEvent(g),g.defaultPrevented||(yt(wt(Ne(s)),{select:!0}),document.activeElement===c&&N(s))}return()=>{s.removeEventListener(J,l),setTimeout(()=>{const g=new CustomEvent(ee,pe);s.addEventListener(ee,f),s.dispatchEvent(g),g.defaultPrevented||N(c??document.body,{select:!0}),s.removeEventListener(ee,f),ge.remove(E)},0)}}},[s,l,f,E]);const D=i.useCallback(c=>{if(!n&&!r||E.paused)return;const h=c.key==="Tab"&&!c.altKey&&!c.ctrlKey&&!c.metaKey,g=document.activeElement;if(h&&g){const b=c.currentTarget,[C,S]=Et(b);C&&S?!c.shiftKey&&g===S?(c.preventDefault(),n&&N(C,{select:!0})):c.shiftKey&&g===C&&(c.preventDefault(),n&&N(S,{select:!0})):g===b&&c.preventDefault()}},[n,r,E.paused]);return d.jsx(O.div,{tabIndex:-1,...u,ref:m,onKeyDown:D})});Oe.displayName=gt;function yt(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(N(r,{select:t}),document.activeElement!==n)return}function Et(e){const t=Ne(e),n=me(t,e),r=me(t.reverse(),e);return[n,r]}function Ne(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function me(e,t){for(const n of e)if(!bt(n,{upTo:t}))return n}function bt(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 Ct(e){return e instanceof HTMLInputElement&&"select"in e}function N(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Ct(e)&&t&&e.select()}}var ge=St();function St(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=ye(e,t),e.unshift(t)},remove(t){e=ye(e,t),e[0]?.resume()}}}function ye(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function wt(e){return e.filter(t=>t.tagName!=="A")}var Dt="Portal",Te=i.forwardRef((e,t)=>{const{container:n,...r}=e,[o,a]=i.useState(!1);nt(()=>a(!0),[]);const u=n||o&&globalThis?.document?.body;return u?st.createPortal(d.jsx(O.div,{...r,ref:t}),u):null});Te.displayName=Dt;var te=0;function Rt(){i.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Ee()),document.body.insertAdjacentElement("beforeend",e[1]??Ee()),te++,()=>{te===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),te--}},[])}function Ee(){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 P=function(){return P=Object.assign||function(t){for(var n,r=1,o=arguments.length;r "u")return Ht;var t=Vt(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},$t=Fe(),k="data-scroll-locked",Gt=function(e,t,n,r){var o=e.left,a=e.top,u=e.right,s=e.gap;return n===void 0&&(n="margin"),` .`.concat(Pt,` { overflow: hidden `).concat(r,`; padding-right: `).concat(s,"px ").concat(r,`; diff --git a/backend/pixelbot/static/assets/download-s6JlUMMe.js b/backend/pixelbot/static/assets/download-gDnOKy-4.js similarity index 72% rename from backend/pixelbot/static/assets/download-s6JlUMMe.js rename to backend/pixelbot/static/assets/download-gDnOKy-4.js index 830f4f3..2b2beaa 100644 --- a/backend/pixelbot/static/assets/download-s6JlUMMe.js +++ b/backend/pixelbot/static/assets/download-gDnOKy-4.js @@ -1 +1 @@ -import{c as o}from"./index-bcIN4R_6.js";const a=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],e=o("download",a);export{e as D}; +import{c as o}from"./index-BKlAZSPs.js";const a=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],e=o("download",a);export{e as D}; diff --git a/backend/pixelbot/static/assets/experiments-page-CBKaAHyH.js b/backend/pixelbot/static/assets/experiments-page-VnavNQMR.js similarity index 95% rename from backend/pixelbot/static/assets/experiments-page-CBKaAHyH.js rename to backend/pixelbot/static/assets/experiments-page-VnavNQMR.js index 40a2586..443bb9f 100644 --- a/backend/pixelbot/static/assets/experiments-page-CBKaAHyH.js +++ b/backend/pixelbot/static/assets/experiments-page-VnavNQMR.js @@ -1 +1 @@ -import{c as Z,b as pe,r as a,j as e,F as L,a as p,H as Y}from"./index-bcIN4R_6.js";import{u as ue,L as X}from"./use-mount-effect-Dj1RN52i.js";import{B as F}from"./badge-BIO9r-az.js";import{I as A}from"./input-B5vinQUU.js";import{T as J}from"./textarea-CDFZlXW-.js";import{S as K}from"./slider-DxmNq9ng.js";import{aa as he,ab as fe,ac as ge,ad as je,ae as be}from"./api-qB_zxs57.js";import{C as ee}from"./check-EY4MJcH5.js";import{P as Ne}from"./pencil-BXDLPx3O.js";import{X as ve}from"./x-DjdZKBVk.js";import{P as ye}from"./plus-BwqCou7I.js";import{P as we}from"./play-tsVcgKvS.js";import{S as Q}from"./sparkles-0UKh7vY0.js";import{C as se}from"./clock-pUwGegUT.js";import{T as ke}from"./trash-2-Dwdv-GS6.js";import{C as _e}from"./copy-BlKAoc_U.js";import{T as Ce}from"./type-GzMp4Pkc.js";import{H as Se}from"./hash-ByqwwcTl.js";import"./index-BdQq_4o_.js";import"./index-PhySa8BR.js";import"./index-BUPn8X34.js";import"./index-XhUYjquv.js";import"./index-FUXQzuGM.js";const Me=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],Pe=Z("circle-alert",Me);const Ee=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],Re=Z("rotate-ccw",Ee),Te={anthropic:"Anthropic",google:"Google",mistral:"Mistral",openai:"OpenAI"};function S(r){return Te[r]??r}function as(){const{addToast:r}=pe(),[d,c]=a.useState(""),[i,o]=a.useState("You are a helpful assistant."),[x,H]=a.useState(""),[m,v]=a.useState([]),[g,D]=a.useState({}),[re,I]=a.useState(null),[j,M]=a.useState(""),[O,ae]=a.useState("openai"),[oe,P]=a.useState(!1),[y,B]=a.useState(.7),[w,U]=a.useState(1024),[u,z]=a.useState([]),[b,G]=a.useState(!1),[l,k]=a.useState(null),[_,V]=a.useState([]),[h,E]=a.useState("results"),[ne,q]=a.useState(null),R=a.useCallback(async()=>{try{const s=await he();V(s)}catch{}},[]);ue(()=>{be().then(s=>{z(s);const t=s.filter(n=>n.available).map(n=>n.id);t.length>0&&v(t.slice(0,2))}).catch(s=>{console.error("Failed to load models:",s)}),R()});const le=a.useCallback(s=>{v(t=>t.includes(s)?t.filter(n=>n!==s):[...t,s])},[]),W=a.useCallback(()=>m.map(s=>{const t=g[s],n=u.find(f=>f.id===s);return{model_id:t||s,provider:n?.provider??void 0,display_name:t?`${n?.name??s} (${t})`:void 0}}),[m,g,u]),T=a.useCallback(async()=>{if(!x.trim()){r("Enter a user prompt first","error");return}if(m.length===0){r("Select at least one model","error");return}G(!0),k(null);try{const s=await fe({task:d||"Untitled",system_prompt:i,user_prompt:x,models:W(),temperature:y,max_tokens:w});k(s),R(),r("Experiment complete","success")}catch(s){r(`Experiment failed: ${s instanceof Error?s.message:"Unknown error"}`,"error")}finally{G(!1)}},[d,i,x,m,y,w,r,R,W]),de=a.useCallback(async s=>{try{const t=await ge(s);k(t),c(t.task),o(t.system_prompt),H(t.user_prompt),B(t.temperature),U(t.max_tokens),v(t.results.map(n=>n.model_id)),E("results")}catch{r("Failed to load experiment","error")}},[r]),ie=a.useCallback(async s=>{try{await je(s),V(t=>t.filter(n=>n.experiment_id!==s)),l?.experiment_id===s&&k(null),r("Experiment deleted","success")}catch{r("Failed to delete","error")}},[l,r]),ce=a.useCallback((s,t)=>{navigator.clipboard.writeText(s),q(t),setTimeout(()=>q(null),2e3)},[]),xe=a.useCallback(()=>{T()},[T]),me=a.useMemo(()=>{if(!l)return 0;const s=l.results.filter(t=>!t.error&&t.response_time_ms>0).map(t=>t.response_time_ms);return s.length>0?Math.min(...s):0},[l]);return e.jsxs("div",{className:"flex h-full",children:[e.jsxs("div",{className:"w-[360px] shrink-0 border-r border-border/60 flex flex-col overflow-y-auto bg-card/20",children:[e.jsx("div",{className:"px-5 pt-5 pb-4 border-b border-border/40",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-k-yellow/10",children:e.jsx(L,{className:"h-4 w-4 text-k-yellow"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-[15px] font-semibold text-foreground",children:"Prompt Lab"}),e.jsx("p",{className:"text-[11px] text-muted-foreground/60",children:"Compare models side-by-side"})]})]})}),e.jsxs("div",{className:"flex-1 px-5 py-4 space-y-5",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground/50",children:"Task Label"}),e.jsx(A,{placeholder:"e.g. Summarization, Code Gen...",value:d,onChange:s=>c(s.target.value),className:"h-8 text-[12px]"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground/50",children:"System Prompt"}),e.jsx(J,{placeholder:"You are a helpful assistant...",value:i,onChange:s=>o(s.target.value),className:"min-h-[72px] text-[12px] resize-y"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground/50",children:"User Prompt"}),e.jsx(J,{placeholder:"Enter your prompt to test...",value:x,onChange:s=>H(s.target.value),className:"min-h-[100px] text-[12px] resize-y"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground/50",children:"Models"}),e.jsxs("div",{className:"space-y-1",children:[u.map(s=>{const t=m.includes(s.id),n=re===s.id,f=!!g[s.id];return e.jsxs("div",{children:[e.jsxs("button",{className:p("flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-left transition-all","border",t?"border-k-yellow/30 bg-k-yellow/5":"border-transparent hover:bg-accent/30",!s.available&&"opacity-40 cursor-not-allowed"),onClick:()=>s.available&&le(s.id),disabled:!s.available,children:[e.jsx("div",{className:p("h-3.5 w-3.5 rounded border-2 shrink-0 transition-colors",t?"border-k-yellow bg-k-yellow":"border-muted-foreground/30"),children:t&&e.jsx(ee,{className:"h-2.5 w-2.5 text-background",style:{margin:"-1px"}})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:p("text-[12px] font-medium",t?"text-foreground":"text-foreground/80"),children:s.name}),f&&e.jsx("span",{className:"block text-[9px] text-muted-foreground/50 font-mono truncate",children:g[s.id]})]}),e.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:S(s.provider)}),!s.available&&e.jsx("span",{className:"text-[9px] text-muted-foreground/50",children:"no key"}),t&&s.available&&e.jsx(Ne,{className:"h-2.5 w-2.5 text-muted-foreground/40 hover:text-foreground shrink-0",onClick:N=>{N.stopPropagation(),I(n?null:s.id)}})]}),n&&t&&e.jsxs("div",{className:"ml-8 mt-1 mb-1 flex items-center gap-1.5",children:[e.jsx(A,{placeholder:s.id,value:g[s.id]??"",onChange:N=>D(C=>({...C,[s.id]:N.target.value})),className:"h-6 text-[10px] font-mono flex-1"}),f&&e.jsx("button",{className:"text-muted-foreground/40 hover:text-foreground",onClick:()=>{D(N=>{const C={...N};return delete C[s.id],C}),I(null)},title:"Reset to default",children:e.jsx(ve,{className:"h-3 w-3"})})]})]},s.id)}),oe?e.jsxs("div",{className:"rounded-lg border border-dashed border-border/60 p-2.5 space-y-1.5",children:[e.jsx(A,{placeholder:"Model ID (e.g. claude-3.5-haiku)",value:j,onChange:s=>M(s.target.value),className:"h-7 text-[11px] font-mono",autoFocus:!0}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("select",{className:"h-6 flex-1 rounded border border-input bg-transparent px-2 text-[10px]",value:O,onChange:s=>ae(s.target.value),children:[e.jsx("option",{value:"anthropic",children:"Anthropic"}),e.jsx("option",{value:"google",children:"Google"}),e.jsx("option",{value:"mistral",children:"Mistral"}),e.jsx("option",{value:"openai",children:"OpenAI"})]}),e.jsx("button",{className:"h-6 rounded bg-k-yellow px-2.5 text-[10px] font-medium text-primary-foreground hover:bg-k-yellow-hover disabled:opacity-40",disabled:!j.trim(),onClick:()=>{if(!j.trim())return;const s={id:j.trim(),name:j.trim(),provider:O,available:!0};z(t=>[...t,s]),v(t=>[...t,s.id]),M(""),P(!1)},children:"Add"}),e.jsx("button",{className:"h-6 rounded border border-border px-2 text-[10px] text-muted-foreground hover:text-foreground",onClick:()=>{P(!1),M("")},children:"Cancel"})]})]}):e.jsxs("button",{className:"flex w-full items-center gap-2 rounded-lg border border-dashed border-border/40 px-3 py-2 text-[11px] text-muted-foreground/50 hover:text-muted-foreground hover:border-border/60 transition-colors",onClick:()=>P(!0),children:[e.jsx(ye,{className:"h-3 w-3"}),"Add custom model"]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground/50",children:"Parameters"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[11px] text-muted-foreground",children:"Temperature"}),e.jsx("span",{className:"text-[11px] font-mono text-foreground",children:y.toFixed(1)})]}),e.jsx(K,{value:[y],onValueChange:([s])=>B(s),min:0,max:1,step:.1})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[11px] text-muted-foreground",children:"Max Tokens"}),e.jsx("span",{className:"text-[11px] font-mono text-foreground",children:w})]}),e.jsx(K,{value:[w],onValueChange:([s])=>U(s),min:64,max:4096,step:64})]})]})]}),e.jsx("div",{className:"px-5 py-4 border-t border-border/40",children:e.jsx("button",{className:p("flex w-full items-center justify-center gap-2 rounded-lg px-4 py-2.5 text-[13px] font-semibold transition-all","bg-k-yellow text-primary-foreground hover:bg-k-yellow-hover active:bg-k-yellow-hover","disabled:opacity-50 disabled:cursor-not-allowed"),onClick:T,disabled:b||!x.trim()||m.length===0,children:b?e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"h-3.5 w-3.5 animate-spin"}),"Running ",m.length," model",m.length>1?"s":"","..."]}):e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"h-3.5 w-3.5"}),"Run Experiment"]})})})]}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-0 border-b border-border/60 bg-card/20 shrink-0",children:[e.jsxs("button",{className:p("flex items-center gap-1.5 px-5 py-3 text-[12px] font-medium transition-colors relative",h==="results"?"text-foreground":"text-muted-foreground/60 hover:text-muted-foreground"),onClick:()=>E("results"),children:[e.jsx(Q,{className:"h-3.5 w-3.5"}),"Results",h==="results"&&e.jsx("span",{className:"absolute bottom-0 left-4 right-4 h-[2px] bg-k-yellow rounded-full"})]}),e.jsxs("button",{className:p("flex items-center gap-1.5 px-5 py-3 text-[12px] font-medium transition-colors relative",h==="history"?"text-foreground":"text-muted-foreground/60 hover:text-muted-foreground"),onClick:()=>E("history"),children:[e.jsx(Y,{className:"h-3.5 w-3.5"}),"History",_.length>0&&e.jsx(F,{variant:"secondary",className:"text-[9px] px-1.5 py-0 ml-1",children:_.length}),h==="history"&&e.jsx("span",{className:"absolute bottom-0 left-4 right-4 h-[2px] bg-k-yellow rounded-full"})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[h==="results"&&e.jsxs(e.Fragment,{children:[b&&!l&&e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-6",children:[e.jsx(Q,{className:"h-4 w-4 text-k-yellow animate-pulse"}),e.jsx("h2",{className:"text-[14px] font-semibold text-foreground",children:"Running experiment..."})]}),m.map(s=>{const t=u.find(n=>n.id===s);return e.jsxs("div",{className:"rounded-xl border border-border/40 bg-card/30 p-5 animate-pulse",children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-3",children:[e.jsx(X,{className:"h-3.5 w-3.5 animate-spin text-k-yellow"}),e.jsx("span",{className:"text-[13px] font-semibold text-foreground",children:t?.name??s}),e.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:S(t?.provider??"")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-3 rounded bg-foreground/5 w-full"}),e.jsx("div",{className:"h-3 rounded bg-foreground/5 w-4/5"}),e.jsx("div",{className:"h-3 rounded bg-foreground/5 w-3/5"})]})]},s)})]}),l&&!b&&e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(L,{className:"h-4 w-4 text-k-yellow"}),e.jsx("h2",{className:"text-[14px] font-semibold text-foreground",children:l.task})]}),e.jsx(F,{variant:"outline",className:"text-[9px] px-2 py-0 font-mono",children:l.experiment_id}),e.jsx("span",{className:"text-[10px] text-muted-foreground/50 ml-auto",children:new Date(l.timestamp).toLocaleString()}),e.jsxs("button",{className:"flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground transition-colors",onClick:xe,title:"Re-run experiment",children:[e.jsx(Re,{className:"h-3 w-3"}),"Re-run"]})]}),e.jsxs("div",{className:"rounded-lg border border-border/40 bg-card/30 px-4 py-3 mb-4",children:[e.jsx("p",{className:"text-[11px] text-muted-foreground/50 uppercase tracking-wider font-semibold mb-1",children:"Prompt"}),e.jsx("p",{className:"text-[12px] text-foreground/80 line-clamp-3",children:l.user_prompt})]}),e.jsx("div",{className:"space-y-4",children:l.results.map(s=>e.jsx(Le,{result:s,fastestTime:me,copiedId:ne,onCopy:ce},s.model_id))}),l.results.length>1&&e.jsx(Fe,{results:l.results})]}),!l&&!b&&e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center max-w-md",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("div",{className:"h-16 w-16 rounded-2xl bg-k-yellow/10 flex items-center justify-center",children:e.jsx(L,{className:"h-8 w-8 text-k-yellow/60"})})}),e.jsx("h3",{className:"text-[15px] font-semibold text-foreground mb-2",children:"Prompt Engineering Lab"}),e.jsx("p",{className:"text-[12px] text-muted-foreground/60 leading-relaxed mb-4",children:"Compare how different LLMs respond to the same prompt. Adjust parameters, iterate on prompts, and track every experiment with Pixeltable's automatic versioning."}),e.jsx("div",{className:"flex flex-wrap justify-center gap-2",children:u.filter(s=>s.available).map(s=>e.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-muted text-muted-foreground",children:s.name},s.id))})]})})]}),h==="history"&&e.jsx("div",{className:"h-full",children:_.length===0?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-3",children:e.jsx("div",{className:"h-12 w-12 rounded-xl bg-muted flex items-center justify-center",children:e.jsx(Y,{className:"h-6 w-6 text-muted-foreground/30"})})}),e.jsx("p",{className:"text-[12px] text-muted-foreground/60",children:"No experiments yet"}),e.jsx("p",{className:"text-[11px] text-muted-foreground/40 mt-1",children:"Run one to start tracking"})]})}):e.jsx("div",{className:"divide-y divide-border/30",children:_.map(s=>e.jsxs("div",{className:p("px-5 py-4 flex items-center gap-3 hover:bg-accent/30 transition-colors cursor-pointer group",l?.experiment_id===s.experiment_id&&"bg-k-yellow/5 border-l-2 border-l-k-yellow"),onClick:()=>de(s.experiment_id),children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-[13px] font-medium text-foreground truncate",children:s.task}),e.jsx(F,{variant:"outline",className:"text-[8px] px-1.5 py-0 font-mono shrink-0",children:s.experiment_id})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground/60 truncate mb-1.5",children:s.user_prompt}),e.jsxs("div",{className:"flex items-center gap-2",children:[s.model_ids.map(t=>{const n=u.find(f=>f.id===t);return e.jsx("span",{className:"text-[8px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:n?.name??t},t)}),e.jsxs("span",{className:"text-[10px] text-muted-foreground/40 ml-auto flex items-center gap-1",children:[e.jsx(se,{className:"h-2.5 w-2.5"}),new Date(s.timestamp).toLocaleString()]})]})]}),e.jsx("button",{className:"opacity-0 group-hover:opacity-100 text-muted-foreground/40 hover:text-destructive transition-all shrink-0",onClick:t=>{t.stopPropagation(),ie(s.experiment_id)},title:"Delete experiment",children:e.jsx(ke,{className:"h-3.5 w-3.5"})})]},s.experiment_id))})})]})]})]})}function Le({result:r,fastestTime:d,copiedId:c,onCopy:i}){const o=r.response_time_ms>0&&r.response_time_ms===d;return r.error?e.jsxs("div",{className:"rounded-xl border border-destructive/30 bg-destructive/5 p-5",children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-3",children:[e.jsx(Pe,{className:"h-3.5 w-3.5 text-destructive"}),e.jsx("span",{className:"text-[13px] font-semibold text-foreground",children:r.model_name}),e.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:S(r.provider)})]}),e.jsx("p",{className:"text-[12px] text-destructive/80 font-mono",children:r.error})]}):e.jsxs("div",{className:"rounded-xl border border-border/40 bg-card/40 hover:bg-card/60 p-5 transition-all",children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-3",children:[e.jsx("span",{className:"text-[13px] font-semibold text-foreground",children:r.model_name}),e.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:S(r.provider)}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{className:"text-muted-foreground/40 hover:text-foreground transition-colors",onClick:()=>r.response&&i(r.response,r.model_id),title:"Copy response",children:c===r.model_id?e.jsx(ee,{className:"h-3.5 w-3.5 text-emerald-400"}):e.jsx(_e,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{className:"text-[12px] text-foreground/80 leading-relaxed whitespace-pre-wrap mb-4 max-h-[300px] overflow-y-auto",children:r.response}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx($,{icon:se,label:te(r.response_time_ms),highlight:o,highlightColor:"text-k-yellow"}),e.jsx($,{icon:Ce,label:`${r.word_count} words`}),e.jsx($,{icon:Se,label:`${r.char_count} chars`}),o&&e.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-k-yellow/10 text-k-yellow font-medium",children:"Fastest"})]})]})}function Fe({results:r}){const d=r.filter(o=>!o.error&&o.response_time_ms>0);if(d.length<2)return null;const c=Math.max(...d.map(o=>o.response_time_ms)),i=Math.max(...d.map(o=>o.word_count));return e.jsxs("div",{className:"rounded-xl border border-border/40 bg-card/30 p-5 mt-4",children:[e.jsx("h3",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground/50 mb-4",children:"Comparison"}),e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:"Response Time"}),d.map(o=>{const x=c>0?o.response_time_ms/c*100:0;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] font-medium w-28 shrink-0 truncate text-foreground/80",children:o.model_name}),e.jsx("div",{className:"flex-1 h-2 rounded-full bg-foreground/5 overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-k-yellow/60 transition-all",style:{width:`${x}%`}})}),e.jsx("span",{className:"text-[9px] font-mono text-muted-foreground w-16 text-right shrink-0",children:te(o.response_time_ms)})]},`time-${o.model_id}`)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:"Word Count"}),d.map(o=>{const x=i>0?o.word_count/i*100:0;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] font-medium w-28 shrink-0 truncate text-foreground/80",children:o.model_name}),e.jsx("div",{className:"flex-1 h-2 rounded-full bg-foreground/5 overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-foreground/20 transition-all",style:{width:`${x}%`}})}),e.jsx("span",{className:"text-[9px] font-mono text-muted-foreground w-16 text-right shrink-0",children:o.word_count})]},`words-${o.model_id}`)})]})]})}function $({icon:r,label:d,highlight:c,highlightColor:i}){return e.jsxs("div",{className:p("flex items-center gap-1 text-[10px]",c&&i?i:"text-muted-foreground/60"),children:[e.jsx(r,{className:"h-3 w-3"}),e.jsx("span",{className:"font-mono",children:d})]})}function te(r){return r<1e3?`${Math.round(r)}ms`:`${(r/1e3).toFixed(1)}s`}export{as as ExperimentsPage}; +import{c as Z,b as pe,r as a,j as e,F as L,a as p,H as Y}from"./index-BKlAZSPs.js";import{u as ue,L as X}from"./use-mount-effect-CEqzESrx.js";import{B as F}from"./badge-B_CNDVZh.js";import{I as A}from"./input-DEyNLzjf.js";import{T as J}from"./textarea-DsI0XwJn.js";import{S as K}from"./slider-Twfzc0LC.js";import{aa as he,ab as fe,ac as ge,ad as je,ae as be}from"./api-qB_zxs57.js";import{C as ee}from"./check-D-roFugH.js";import{P as Ne}from"./pencil-DH9VG1hT.js";import{X as ve}from"./x-B99eDFz6.js";import{P as ye}from"./plus-CFgJREI2.js";import{P as we}from"./play-BXh2-cUU.js";import{S as Q}from"./sparkles-BwOhbqOy.js";import{C as se}from"./clock-CN2-2vC4.js";import{T as ke}from"./trash-2-sY6rixAj.js";import{C as _e}from"./copy-DR0TH8ar.js";import{T as Ce}from"./type-DH9mEbj2.js";import{H as Se}from"./hash-D9LrbLcr.js";import"./index-BdQq_4o_.js";import"./index-KbvIRwKr.js";import"./index-B8obv054.js";import"./index-oUe0EePc.js";import"./index-hR8PON02.js";const Me=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],Pe=Z("circle-alert",Me);const Ee=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],Re=Z("rotate-ccw",Ee),Te={anthropic:"Anthropic",google:"Google",mistral:"Mistral",openai:"OpenAI"};function S(r){return Te[r]??r}function as(){const{addToast:r}=pe(),[d,c]=a.useState(""),[i,o]=a.useState("You are a helpful assistant."),[x,H]=a.useState(""),[m,v]=a.useState([]),[g,D]=a.useState({}),[re,I]=a.useState(null),[j,M]=a.useState(""),[O,ae]=a.useState("openai"),[oe,P]=a.useState(!1),[y,B]=a.useState(.7),[w,U]=a.useState(1024),[u,z]=a.useState([]),[b,G]=a.useState(!1),[l,k]=a.useState(null),[_,V]=a.useState([]),[h,E]=a.useState("results"),[ne,q]=a.useState(null),R=a.useCallback(async()=>{try{const s=await he();V(s)}catch{}},[]);ue(()=>{be().then(s=>{z(s);const t=s.filter(n=>n.available).map(n=>n.id);t.length>0&&v(t.slice(0,2))}).catch(s=>{console.error("Failed to load models:",s)}),R()});const le=a.useCallback(s=>{v(t=>t.includes(s)?t.filter(n=>n!==s):[...t,s])},[]),W=a.useCallback(()=>m.map(s=>{const t=g[s],n=u.find(f=>f.id===s);return{model_id:t||s,provider:n?.provider??void 0,display_name:t?`${n?.name??s} (${t})`:void 0}}),[m,g,u]),T=a.useCallback(async()=>{if(!x.trim()){r("Enter a user prompt first","error");return}if(m.length===0){r("Select at least one model","error");return}G(!0),k(null);try{const s=await fe({task:d||"Untitled",system_prompt:i,user_prompt:x,models:W(),temperature:y,max_tokens:w});k(s),R(),r("Experiment complete","success")}catch(s){r(`Experiment failed: ${s instanceof Error?s.message:"Unknown error"}`,"error")}finally{G(!1)}},[d,i,x,m,y,w,r,R,W]),de=a.useCallback(async s=>{try{const t=await ge(s);k(t),c(t.task),o(t.system_prompt),H(t.user_prompt),B(t.temperature),U(t.max_tokens),v(t.results.map(n=>n.model_id)),E("results")}catch{r("Failed to load experiment","error")}},[r]),ie=a.useCallback(async s=>{try{await je(s),V(t=>t.filter(n=>n.experiment_id!==s)),l?.experiment_id===s&&k(null),r("Experiment deleted","success")}catch{r("Failed to delete","error")}},[l,r]),ce=a.useCallback((s,t)=>{navigator.clipboard.writeText(s),q(t),setTimeout(()=>q(null),2e3)},[]),xe=a.useCallback(()=>{T()},[T]),me=a.useMemo(()=>{if(!l)return 0;const s=l.results.filter(t=>!t.error&&t.response_time_ms>0).map(t=>t.response_time_ms);return s.length>0?Math.min(...s):0},[l]);return e.jsxs("div",{className:"flex h-full",children:[e.jsxs("div",{className:"w-[360px] shrink-0 border-r border-border/60 flex flex-col overflow-y-auto bg-card/20",children:[e.jsx("div",{className:"px-5 pt-5 pb-4 border-b border-border/40",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-k-yellow/10",children:e.jsx(L,{className:"h-4 w-4 text-k-yellow"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-[15px] font-semibold text-foreground",children:"Prompt Lab"}),e.jsx("p",{className:"text-[11px] text-muted-foreground/60",children:"Compare models side-by-side"})]})]})}),e.jsxs("div",{className:"flex-1 px-5 py-4 space-y-5",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground/50",children:"Task Label"}),e.jsx(A,{placeholder:"e.g. Summarization, Code Gen...",value:d,onChange:s=>c(s.target.value),className:"h-8 text-[12px]"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground/50",children:"System Prompt"}),e.jsx(J,{placeholder:"You are a helpful assistant...",value:i,onChange:s=>o(s.target.value),className:"min-h-[72px] text-[12px] resize-y"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground/50",children:"User Prompt"}),e.jsx(J,{placeholder:"Enter your prompt to test...",value:x,onChange:s=>H(s.target.value),className:"min-h-[100px] text-[12px] resize-y"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground/50",children:"Models"}),e.jsxs("div",{className:"space-y-1",children:[u.map(s=>{const t=m.includes(s.id),n=re===s.id,f=!!g[s.id];return e.jsxs("div",{children:[e.jsxs("button",{className:p("flex w-full items-center gap-2.5 rounded-lg px-3 py-2 text-left transition-all","border",t?"border-k-yellow/30 bg-k-yellow/5":"border-transparent hover:bg-accent/30",!s.available&&"opacity-40 cursor-not-allowed"),onClick:()=>s.available&&le(s.id),disabled:!s.available,children:[e.jsx("div",{className:p("h-3.5 w-3.5 rounded border-2 shrink-0 transition-colors",t?"border-k-yellow bg-k-yellow":"border-muted-foreground/30"),children:t&&e.jsx(ee,{className:"h-2.5 w-2.5 text-background",style:{margin:"-1px"}})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:p("text-[12px] font-medium",t?"text-foreground":"text-foreground/80"),children:s.name}),f&&e.jsx("span",{className:"block text-[9px] text-muted-foreground/50 font-mono truncate",children:g[s.id]})]}),e.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:S(s.provider)}),!s.available&&e.jsx("span",{className:"text-[9px] text-muted-foreground/50",children:"no key"}),t&&s.available&&e.jsx(Ne,{className:"h-2.5 w-2.5 text-muted-foreground/40 hover:text-foreground shrink-0",onClick:N=>{N.stopPropagation(),I(n?null:s.id)}})]}),n&&t&&e.jsxs("div",{className:"ml-8 mt-1 mb-1 flex items-center gap-1.5",children:[e.jsx(A,{placeholder:s.id,value:g[s.id]??"",onChange:N=>D(C=>({...C,[s.id]:N.target.value})),className:"h-6 text-[10px] font-mono flex-1"}),f&&e.jsx("button",{className:"text-muted-foreground/40 hover:text-foreground",onClick:()=>{D(N=>{const C={...N};return delete C[s.id],C}),I(null)},title:"Reset to default",children:e.jsx(ve,{className:"h-3 w-3"})})]})]},s.id)}),oe?e.jsxs("div",{className:"rounded-lg border border-dashed border-border/60 p-2.5 space-y-1.5",children:[e.jsx(A,{placeholder:"Model ID (e.g. claude-3.5-haiku)",value:j,onChange:s=>M(s.target.value),className:"h-7 text-[11px] font-mono",autoFocus:!0}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("select",{className:"h-6 flex-1 rounded border border-input bg-transparent px-2 text-[10px]",value:O,onChange:s=>ae(s.target.value),children:[e.jsx("option",{value:"anthropic",children:"Anthropic"}),e.jsx("option",{value:"google",children:"Google"}),e.jsx("option",{value:"mistral",children:"Mistral"}),e.jsx("option",{value:"openai",children:"OpenAI"})]}),e.jsx("button",{className:"h-6 rounded bg-k-yellow px-2.5 text-[10px] font-medium text-primary-foreground hover:bg-k-yellow-hover disabled:opacity-40",disabled:!j.trim(),onClick:()=>{if(!j.trim())return;const s={id:j.trim(),name:j.trim(),provider:O,available:!0};z(t=>[...t,s]),v(t=>[...t,s.id]),M(""),P(!1)},children:"Add"}),e.jsx("button",{className:"h-6 rounded border border-border px-2 text-[10px] text-muted-foreground hover:text-foreground",onClick:()=>{P(!1),M("")},children:"Cancel"})]})]}):e.jsxs("button",{className:"flex w-full items-center gap-2 rounded-lg border border-dashed border-border/40 px-3 py-2 text-[11px] text-muted-foreground/50 hover:text-muted-foreground hover:border-border/60 transition-colors",onClick:()=>P(!0),children:[e.jsx(ye,{className:"h-3 w-3"}),"Add custom model"]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground/50",children:"Parameters"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[11px] text-muted-foreground",children:"Temperature"}),e.jsx("span",{className:"text-[11px] font-mono text-foreground",children:y.toFixed(1)})]}),e.jsx(K,{value:[y],onValueChange:([s])=>B(s),min:0,max:1,step:.1})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[11px] text-muted-foreground",children:"Max Tokens"}),e.jsx("span",{className:"text-[11px] font-mono text-foreground",children:w})]}),e.jsx(K,{value:[w],onValueChange:([s])=>U(s),min:64,max:4096,step:64})]})]})]}),e.jsx("div",{className:"px-5 py-4 border-t border-border/40",children:e.jsx("button",{className:p("flex w-full items-center justify-center gap-2 rounded-lg px-4 py-2.5 text-[13px] font-semibold transition-all","bg-k-yellow text-primary-foreground hover:bg-k-yellow-hover active:bg-k-yellow-hover","disabled:opacity-50 disabled:cursor-not-allowed"),onClick:T,disabled:b||!x.trim()||m.length===0,children:b?e.jsxs(e.Fragment,{children:[e.jsx(X,{className:"h-3.5 w-3.5 animate-spin"}),"Running ",m.length," model",m.length>1?"s":"","..."]}):e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"h-3.5 w-3.5"}),"Run Experiment"]})})})]}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-0 border-b border-border/60 bg-card/20 shrink-0",children:[e.jsxs("button",{className:p("flex items-center gap-1.5 px-5 py-3 text-[12px] font-medium transition-colors relative",h==="results"?"text-foreground":"text-muted-foreground/60 hover:text-muted-foreground"),onClick:()=>E("results"),children:[e.jsx(Q,{className:"h-3.5 w-3.5"}),"Results",h==="results"&&e.jsx("span",{className:"absolute bottom-0 left-4 right-4 h-[2px] bg-k-yellow rounded-full"})]}),e.jsxs("button",{className:p("flex items-center gap-1.5 px-5 py-3 text-[12px] font-medium transition-colors relative",h==="history"?"text-foreground":"text-muted-foreground/60 hover:text-muted-foreground"),onClick:()=>E("history"),children:[e.jsx(Y,{className:"h-3.5 w-3.5"}),"History",_.length>0&&e.jsx(F,{variant:"secondary",className:"text-[9px] px-1.5 py-0 ml-1",children:_.length}),h==="history"&&e.jsx("span",{className:"absolute bottom-0 left-4 right-4 h-[2px] bg-k-yellow rounded-full"})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[h==="results"&&e.jsxs(e.Fragment,{children:[b&&!l&&e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-6",children:[e.jsx(Q,{className:"h-4 w-4 text-k-yellow animate-pulse"}),e.jsx("h2",{className:"text-[14px] font-semibold text-foreground",children:"Running experiment..."})]}),m.map(s=>{const t=u.find(n=>n.id===s);return e.jsxs("div",{className:"rounded-xl border border-border/40 bg-card/30 p-5 animate-pulse",children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-3",children:[e.jsx(X,{className:"h-3.5 w-3.5 animate-spin text-k-yellow"}),e.jsx("span",{className:"text-[13px] font-semibold text-foreground",children:t?.name??s}),e.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:S(t?.provider??"")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-3 rounded bg-foreground/5 w-full"}),e.jsx("div",{className:"h-3 rounded bg-foreground/5 w-4/5"}),e.jsx("div",{className:"h-3 rounded bg-foreground/5 w-3/5"})]})]},s)})]}),l&&!b&&e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(L,{className:"h-4 w-4 text-k-yellow"}),e.jsx("h2",{className:"text-[14px] font-semibold text-foreground",children:l.task})]}),e.jsx(F,{variant:"outline",className:"text-[9px] px-2 py-0 font-mono",children:l.experiment_id}),e.jsx("span",{className:"text-[10px] text-muted-foreground/50 ml-auto",children:new Date(l.timestamp).toLocaleString()}),e.jsxs("button",{className:"flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground transition-colors",onClick:xe,title:"Re-run experiment",children:[e.jsx(Re,{className:"h-3 w-3"}),"Re-run"]})]}),e.jsxs("div",{className:"rounded-lg border border-border/40 bg-card/30 px-4 py-3 mb-4",children:[e.jsx("p",{className:"text-[11px] text-muted-foreground/50 uppercase tracking-wider font-semibold mb-1",children:"Prompt"}),e.jsx("p",{className:"text-[12px] text-foreground/80 line-clamp-3",children:l.user_prompt})]}),e.jsx("div",{className:"space-y-4",children:l.results.map(s=>e.jsx(Le,{result:s,fastestTime:me,copiedId:ne,onCopy:ce},s.model_id))}),l.results.length>1&&e.jsx(Fe,{results:l.results})]}),!l&&!b&&e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center max-w-md",children:[e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx("div",{className:"h-16 w-16 rounded-2xl bg-k-yellow/10 flex items-center justify-center",children:e.jsx(L,{className:"h-8 w-8 text-k-yellow/60"})})}),e.jsx("h3",{className:"text-[15px] font-semibold text-foreground mb-2",children:"Prompt Engineering Lab"}),e.jsx("p",{className:"text-[12px] text-muted-foreground/60 leading-relaxed mb-4",children:"Compare how different LLMs respond to the same prompt. Adjust parameters, iterate on prompts, and track every experiment with Pixeltable's automatic versioning."}),e.jsx("div",{className:"flex flex-wrap justify-center gap-2",children:u.filter(s=>s.available).map(s=>e.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-muted text-muted-foreground",children:s.name},s.id))})]})})]}),h==="history"&&e.jsx("div",{className:"h-full",children:_.length===0?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-3",children:e.jsx("div",{className:"h-12 w-12 rounded-xl bg-muted flex items-center justify-center",children:e.jsx(Y,{className:"h-6 w-6 text-muted-foreground/30"})})}),e.jsx("p",{className:"text-[12px] text-muted-foreground/60",children:"No experiments yet"}),e.jsx("p",{className:"text-[11px] text-muted-foreground/40 mt-1",children:"Run one to start tracking"})]})}):e.jsx("div",{className:"divide-y divide-border/30",children:_.map(s=>e.jsxs("div",{className:p("px-5 py-4 flex items-center gap-3 hover:bg-accent/30 transition-colors cursor-pointer group",l?.experiment_id===s.experiment_id&&"bg-k-yellow/5 border-l-2 border-l-k-yellow"),onClick:()=>de(s.experiment_id),children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-[13px] font-medium text-foreground truncate",children:s.task}),e.jsx(F,{variant:"outline",className:"text-[8px] px-1.5 py-0 font-mono shrink-0",children:s.experiment_id})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground/60 truncate mb-1.5",children:s.user_prompt}),e.jsxs("div",{className:"flex items-center gap-2",children:[s.model_ids.map(t=>{const n=u.find(f=>f.id===t);return e.jsx("span",{className:"text-[8px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:n?.name??t},t)}),e.jsxs("span",{className:"text-[10px] text-muted-foreground/40 ml-auto flex items-center gap-1",children:[e.jsx(se,{className:"h-2.5 w-2.5"}),new Date(s.timestamp).toLocaleString()]})]})]}),e.jsx("button",{className:"opacity-0 group-hover:opacity-100 text-muted-foreground/40 hover:text-destructive transition-all shrink-0",onClick:t=>{t.stopPropagation(),ie(s.experiment_id)},title:"Delete experiment",children:e.jsx(ke,{className:"h-3.5 w-3.5"})})]},s.experiment_id))})})]})]})]})}function Le({result:r,fastestTime:d,copiedId:c,onCopy:i}){const o=r.response_time_ms>0&&r.response_time_ms===d;return r.error?e.jsxs("div",{className:"rounded-xl border border-destructive/30 bg-destructive/5 p-5",children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-3",children:[e.jsx(Pe,{className:"h-3.5 w-3.5 text-destructive"}),e.jsx("span",{className:"text-[13px] font-semibold text-foreground",children:r.model_name}),e.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:S(r.provider)})]}),e.jsx("p",{className:"text-[12px] text-destructive/80 font-mono",children:r.error})]}):e.jsxs("div",{className:"rounded-xl border border-border/40 bg-card/40 hover:bg-card/60 p-5 transition-all",children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-3",children:[e.jsx("span",{className:"text-[13px] font-semibold text-foreground",children:r.model_name}),e.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:S(r.provider)}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{className:"text-muted-foreground/40 hover:text-foreground transition-colors",onClick:()=>r.response&&i(r.response,r.model_id),title:"Copy response",children:c===r.model_id?e.jsx(ee,{className:"h-3.5 w-3.5 text-emerald-400"}):e.jsx(_e,{className:"h-3.5 w-3.5"})})]}),e.jsx("div",{className:"text-[12px] text-foreground/80 leading-relaxed whitespace-pre-wrap mb-4 max-h-[300px] overflow-y-auto",children:r.response}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx($,{icon:se,label:te(r.response_time_ms),highlight:o,highlightColor:"text-k-yellow"}),e.jsx($,{icon:Ce,label:`${r.word_count} words`}),e.jsx($,{icon:Se,label:`${r.char_count} chars`}),o&&e.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-k-yellow/10 text-k-yellow font-medium",children:"Fastest"})]})]})}function Fe({results:r}){const d=r.filter(o=>!o.error&&o.response_time_ms>0);if(d.length<2)return null;const c=Math.max(...d.map(o=>o.response_time_ms)),i=Math.max(...d.map(o=>o.word_count));return e.jsxs("div",{className:"rounded-xl border border-border/40 bg-card/30 p-5 mt-4",children:[e.jsx("h3",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground/50 mb-4",children:"Comparison"}),e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:"Response Time"}),d.map(o=>{const x=c>0?o.response_time_ms/c*100:0;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] font-medium w-28 shrink-0 truncate text-foreground/80",children:o.model_name}),e.jsx("div",{className:"flex-1 h-2 rounded-full bg-foreground/5 overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-k-yellow/60 transition-all",style:{width:`${x}%`}})}),e.jsx("span",{className:"text-[9px] font-mono text-muted-foreground w-16 text-right shrink-0",children:te(o.response_time_ms)})]},`time-${o.model_id}`)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:"Word Count"}),d.map(o=>{const x=i>0?o.word_count/i*100:0;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] font-medium w-28 shrink-0 truncate text-foreground/80",children:o.model_name}),e.jsx("div",{className:"flex-1 h-2 rounded-full bg-foreground/5 overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-foreground/20 transition-all",style:{width:`${x}%`}})}),e.jsx("span",{className:"text-[9px] font-mono text-muted-foreground w-16 text-right shrink-0",children:o.word_count})]},`words-${o.model_id}`)})]})]})}function $({icon:r,label:d,highlight:c,highlightColor:i}){return e.jsxs("div",{className:p("flex items-center gap-1 text-[10px]",c&&i?i:"text-muted-foreground/60"),children:[e.jsx(r,{className:"h-3 w-3"}),e.jsx("span",{className:"font-mono",children:d})]})}function te(r){return r<1e3?`${Math.round(r)}ms`:`${(r/1e3).toFixed(1)}s`}export{as as ExperimentsPage}; diff --git a/backend/pixelbot/static/assets/eye-CE1wBT5v.js b/backend/pixelbot/static/assets/eye-D_Cs7pQZ.js similarity index 88% rename from backend/pixelbot/static/assets/eye-CE1wBT5v.js rename to backend/pixelbot/static/assets/eye-D_Cs7pQZ.js index c212b8e..1dd4b8f 100644 --- a/backend/pixelbot/static/assets/eye-CE1wBT5v.js +++ b/backend/pixelbot/static/assets/eye-D_Cs7pQZ.js @@ -1 +1 @@ -import{c as e}from"./index-bcIN4R_6.js";const o=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],a=e("arrow-left",o);const c=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],h=e("chevron-left",c);const t=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],s=e("chevron-right",t);const n=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],d=e("eye",n);export{a as A,h as C,d as E,s as a}; +import{c as e}from"./index-BKlAZSPs.js";const o=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],a=e("arrow-left",o);const c=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],h=e("chevron-left",c);const t=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],s=e("chevron-right",t);const n=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],d=e("eye",n);export{a as A,h as C,d as E,s as a}; diff --git a/backend/pixelbot/static/assets/file-text-CaGMG4i0.js b/backend/pixelbot/static/assets/file-text-BKu2-OuI.js similarity index 83% rename from backend/pixelbot/static/assets/file-text-CaGMG4i0.js rename to backend/pixelbot/static/assets/file-text-BKu2-OuI.js index 87f735e..bb9fe3e 100644 --- a/backend/pixelbot/static/assets/file-text-CaGMG4i0.js +++ b/backend/pixelbot/static/assets/file-text-BKu2-OuI.js @@ -1 +1 @@ -import{c as e}from"./index-bcIN4R_6.js";const a=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],o=e("file-text",a);export{o as F}; +import{c as e}from"./index-BKlAZSPs.js";const a=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],o=e("file-text",a);export{o as F}; diff --git a/backend/pixelbot/static/assets/film-D0A7CDhQ.js b/backend/pixelbot/static/assets/film-BB-YPpGv.js similarity index 84% rename from backend/pixelbot/static/assets/film-D0A7CDhQ.js rename to backend/pixelbot/static/assets/film-BB-YPpGv.js index e8f6893..c9c0e14 100644 --- a/backend/pixelbot/static/assets/film-D0A7CDhQ.js +++ b/backend/pixelbot/static/assets/film-BB-YPpGv.js @@ -1 +1 @@ -import{c as t}from"./index-bcIN4R_6.js";const e=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]],a=t("film",e);export{a as F}; +import{c as t}from"./index-BKlAZSPs.js";const e=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]],a=t("film",e);export{a as F}; diff --git a/backend/pixelbot/static/assets/hash-ByqwwcTl.js b/backend/pixelbot/static/assets/hash-D9LrbLcr.js similarity index 78% rename from backend/pixelbot/static/assets/hash-ByqwwcTl.js rename to backend/pixelbot/static/assets/hash-D9LrbLcr.js index 326096e..e52515d 100644 --- a/backend/pixelbot/static/assets/hash-ByqwwcTl.js +++ b/backend/pixelbot/static/assets/hash-D9LrbLcr.js @@ -1 +1 @@ -import{c as e}from"./index-bcIN4R_6.js";const y=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],o=e("hash",y);export{o as H}; +import{c as e}from"./index-BKlAZSPs.js";const y=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],o=e("hash",y);export{o as H}; diff --git a/backend/pixelbot/static/assets/history-page-CM_mrz-I.js b/backend/pixelbot/static/assets/history-page-C6Kikg4C.js similarity index 91% rename from backend/pixelbot/static/assets/history-page-CM_mrz-I.js rename to backend/pixelbot/static/assets/history-page-C6Kikg4C.js index 5b3acce..a45377a 100644 --- a/backend/pixelbot/static/assets/history-page-CM_mrz-I.js +++ b/backend/pixelbot/static/assets/history-page-C6Kikg4C.js @@ -1 +1 @@ -import{c as T,b as U,d as I,r,j as e,M as d,a as h,W as O,I as R,B as V,D as F}from"./index-bcIN4R_6.js";import{u as P,L as w}from"./use-mount-effect-Dj1RN52i.js";import{I as A}from"./input-B5vinQUU.js";import{S as B}from"./scroll-area-C83pY0Er.js";import{B as G}from"./badge-BIO9r-az.js";import{L as H,M as $,N as q,O as z,P as Q}from"./api-qB_zxs57.js";import{C as g}from"./clock-pUwGegUT.js";import{D as W}from"./download-s6JlUMMe.js";import{S as K}from"./search-D7pTrHQu.js";import{A as J}from"./arrow-right-B3HaW9QC.js";import{T as X}from"./trash-2-Dwdv-GS6.js";import{U as Y}from"./user-DyEtYY9s.js";import{U as Z}from"./upload-Cpl8BuNe.js";import{S as ee}from"./sparkles-0UKh7vY0.js";import{M as te}from"./music-BkTgGpyj.js";import{F as se}from"./film-D0A7CDhQ.js";import{F as ae}from"./file-text-CaGMG4i0.js";import"./index-PhySa8BR.js";import"./index-BUPn8X34.js";import"./index-B57p4poT.js";import"./index-BdQq_4o_.js";const re=[["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z",key:"uouzyp"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M21 21a4 4 0 0 0-3.81-4",key:"1b0z45"}],["path",{d:"M21 5a4 4 0 0 1-3.55 3.97",key:"5cxbf6"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M3 21a4 4 0 0 1 3.81-4",key:"1fjd4g"}],["path",{d:"M3 5a4 4 0 0 0 3.55 3.97",key:"1d7oge"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13",key:"1vgav8"}]],oe=T("bug",re);function Me(){const{addToast:a}=U(),x=I(),[n,c]=r.useState("conversations"),[l,o]=r.useState([]),[m,f]=r.useState(""),[u,p]=r.useState(!0),[k,C]=r.useState([]),[S,j]=r.useState(!1),L=r.useCallback(async()=>{p(!0);try{const t=await H();o(t)}catch{a("Failed to load conversations","error")}finally{p(!1)}},[a]);P(()=>{L()});const b=r.useCallback(async()=>{j(!0);try{const t=await $(200);C(t.events)}catch(t){a(t instanceof Error?t.message:"Failed to load timeline","error")}finally{j(!1)}},[a]),v=r.useCallback(t=>{c(t),t==="timeline"&&b()},[b]),y=r.useCallback(t=>{x(`/?c=${t}`)},[x]),D=r.useCallback(async(t,i)=>{t.stopPropagation();try{await q(i),a("Conversation deleted","success"),o(s=>s.filter(_=>_.conversation_id!==i)),window.dispatchEvent(new Event("conversations-changed"))}catch(s){a(s instanceof Error?s.message:"Delete failed","error")}},[a]),E=r.useCallback(async()=>{try{const t=await z(),i=URL.createObjectURL(t),s=document.createElement("a");s.href=i,s.download="chat_history_full.json",s.click(),URL.revokeObjectURL(i)}catch{a("Download failed","error")}},[a]),M=r.useCallback(async()=>{try{const t=await Q(),i=URL.createObjectURL(t),s=document.createElement("a");s.href=i,s.download="agents_tools_debug_export.json",s.click(),URL.revokeObjectURL(i),a("Debug export downloaded","success")}catch{a("Debug export failed","error")}},[a]),N=l.filter(t=>!m||t.title.toLowerCase().includes(m.toLowerCase()));return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold tracking-tight",children:"History"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[l.length," conversation",l.length!==1?"s":""]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex rounded-lg border border-border overflow-hidden",children:[e.jsxs("button",{className:h("px-2.5 py-1 text-[10px] font-medium transition-colors",n==="conversations"?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>v("conversations"),children:[e.jsx(d,{className:"h-3 w-3 inline mr-1"}),"Conversations"]}),e.jsxs("button",{className:h("px-2.5 py-1 text-[10px] font-medium transition-colors border-l border-border",n==="timeline"?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>v("timeline"),children:[e.jsx(g,{className:"h-3 w-3 inline mr-1"}),"Timeline"]})]}),n==="conversations"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",onClick:M,title:"Export full pixelbot_v3.tools table with all columns for debugging",children:[e.jsx(oe,{className:"h-3 w-3"})," Debug Export"]}),e.jsxs("button",{className:"flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",onClick:E,children:[e.jsx(W,{className:"h-3 w-3"})," Export"]})]})]})]}),n==="timeline"&&e.jsx(le,{events:k,isLoading:S}),n==="conversations"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-6 py-3",children:e.jsxs("div",{className:"relative",children:[e.jsx(K,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(A,{placeholder:"Search conversations...",value:m,onChange:t=>f(t.target.value),className:"pl-9 h-9 rounded-lg text-sm"})]})}),e.jsx(B,{className:"flex-1 px-6",children:u?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(w,{className:"h-6 w-6 animate-spin text-k-yellow mb-2"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Loading conversations..."})]}):N.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(d,{className:"h-10 w-10 text-muted-foreground/20 mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No conversations yet"})]}):e.jsx("div",{className:"space-y-1.5 pb-4",children:N.map((t,i)=>e.jsxs("div",{className:"flex items-center gap-3 rounded-xl border border-border/50 p-3 hover:bg-card hover:border-border transition-all group cursor-pointer animate-fade-in",style:{animationDelay:`${i*30}ms`},onClick:()=>y(t.conversation_id),children:[e.jsx("div",{className:"h-9 w-9 rounded-lg bg-muted flex items-center justify-center shrink-0",children:e.jsx(d,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:t.title||"New conversation"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1.5",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-muted-foreground/70",children:[e.jsx(g,{className:"h-2.5 w-2.5"}),new Date(t.updated_at).toLocaleString()]}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-muted-foreground/50",children:[e.jsx(d,{className:"h-2.5 w-2.5"}),t.message_count," messages"]})]})]}),e.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{className:"h-7 w-7 flex items-center justify-center rounded-md hover:bg-accent transition-colors",onClick:s=>{s.stopPropagation(),y(t.conversation_id)},title:"Open conversation",children:e.jsx(J,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("button",{className:"h-7 w-7 flex items-center justify-center rounded-md hover:bg-destructive/10 transition-colors",onClick:s=>D(s,t.conversation_id),title:"Delete conversation",children:e.jsx(X,{className:"h-3.5 w-3.5 text-destructive"})})]})]},t.conversation_id))})})]})]})}const ne={Query:d,Chat:d,Memory:V,Document:ae,Image:R,Video:se,Audio:te,ImageGen:ee,VideoGen:O,CSV:Z,Persona:Y},ie={Query:"text-blue-400",Chat:"text-sky-400",Memory:"text-purple-400",Document:"text-amber-400",Image:"text-emerald-400",Video:"text-rose-400",Audio:"text-orange-400",ImageGen:"text-pink-400",VideoGen:"text-red-400",CSV:"text-cyan-400",Persona:"text-indigo-400"};function le({events:a,isLoading:x}){if(x)return e.jsx("div",{className:"flex items-center justify-center flex-1",children:e.jsx(w,{className:"h-5 w-5 animate-spin text-k-yellow"})});if(a.length===0)return e.jsxs("div",{className:"flex flex-col items-center justify-center flex-1 gap-2",children:[e.jsx(g,{className:"h-10 w-10 text-muted-foreground/15"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No activity yet"})]});const n={};for(const c of a){const l=c.timestamp?new Date(c.timestamp).toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric"}):"Unknown date";n[l]||(n[l]=[]),n[l].push(c)}return e.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4 w-full",children:Object.entries(n).map(([c,l])=>e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("div",{className:"h-px flex-1 bg-border"}),e.jsx("span",{className:"text-[10px] font-medium text-muted-foreground/60 uppercase tracking-wider shrink-0",children:c}),e.jsx("div",{className:"h-px flex-1 bg-border"})]}),e.jsx("div",{className:"space-y-1",children:l.map((o,m)=>{const f=ne[o.type]??F,u=ie[o.type]??"text-muted-foreground",p=o.timestamp?new Date(o.timestamp).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}):"";return e.jsxs("div",{className:"flex items-start gap-3 rounded-lg px-3 py-2 hover:bg-accent/30 transition-colors",children:[e.jsx("div",{className:h("mt-0.5 shrink-0",u),children:e.jsx(f,{className:"h-3.5 w-3.5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(G,{variant:"outline",className:h("text-[8px] shrink-0",u),children:o.type}),o.role&&e.jsx("span",{className:"text-[9px] text-muted-foreground/50",children:o.role})]}),e.jsx("p",{className:"text-[11px] text-foreground/80 mt-0.5 line-clamp-2",children:o.label})]}),e.jsx("span",{className:"text-[9px] text-muted-foreground/40 tabular-nums shrink-0 mt-0.5",children:p})]},`${o.table}-${m}`)})})]},c))})}export{Me as HistoryPage}; +import{c as T,b as U,d as I,r,j as e,M as d,a as h,W as O,I as R,B as V,D as F}from"./index-BKlAZSPs.js";import{u as P,L as w}from"./use-mount-effect-CEqzESrx.js";import{I as A}from"./input-DEyNLzjf.js";import{S as B}from"./scroll-area-DW6yccR3.js";import{B as G}from"./badge-B_CNDVZh.js";import{L as H,M as $,N as q,O as z,P as Q}from"./api-qB_zxs57.js";import{C as g}from"./clock-CN2-2vC4.js";import{D as W}from"./download-gDnOKy-4.js";import{S as K}from"./search-BHgUFHtw.js";import{A as J}from"./arrow-right-DbPzFz_k.js";import{T as X}from"./trash-2-sY6rixAj.js";import{U as Y}from"./user-xoeV7n22.js";import{U as Z}from"./upload-LUlCBhqv.js";import{S as ee}from"./sparkles-BwOhbqOy.js";import{M as te}from"./music-Seq8oTV1.js";import{F as se}from"./film-BB-YPpGv.js";import{F as ae}from"./file-text-BKu2-OuI.js";import"./index-KbvIRwKr.js";import"./index-B8obv054.js";import"./index-Dr3YzRu6.js";import"./index-BdQq_4o_.js";const re=[["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z",key:"uouzyp"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M21 21a4 4 0 0 0-3.81-4",key:"1b0z45"}],["path",{d:"M21 5a4 4 0 0 1-3.55 3.97",key:"5cxbf6"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M3 21a4 4 0 0 1 3.81-4",key:"1fjd4g"}],["path",{d:"M3 5a4 4 0 0 0 3.55 3.97",key:"1d7oge"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13",key:"1vgav8"}]],oe=T("bug",re);function Me(){const{addToast:a}=U(),x=I(),[n,c]=r.useState("conversations"),[l,o]=r.useState([]),[m,f]=r.useState(""),[u,p]=r.useState(!0),[k,C]=r.useState([]),[S,j]=r.useState(!1),L=r.useCallback(async()=>{p(!0);try{const t=await H();o(t)}catch{a("Failed to load conversations","error")}finally{p(!1)}},[a]);P(()=>{L()});const b=r.useCallback(async()=>{j(!0);try{const t=await $(200);C(t.events)}catch(t){a(t instanceof Error?t.message:"Failed to load timeline","error")}finally{j(!1)}},[a]),v=r.useCallback(t=>{c(t),t==="timeline"&&b()},[b]),y=r.useCallback(t=>{x(`/?c=${t}`)},[x]),D=r.useCallback(async(t,i)=>{t.stopPropagation();try{await q(i),a("Conversation deleted","success"),o(s=>s.filter(_=>_.conversation_id!==i)),window.dispatchEvent(new Event("conversations-changed"))}catch(s){a(s instanceof Error?s.message:"Delete failed","error")}},[a]),E=r.useCallback(async()=>{try{const t=await z(),i=URL.createObjectURL(t),s=document.createElement("a");s.href=i,s.download="chat_history_full.json",s.click(),URL.revokeObjectURL(i)}catch{a("Download failed","error")}},[a]),M=r.useCallback(async()=>{try{const t=await Q(),i=URL.createObjectURL(t),s=document.createElement("a");s.href=i,s.download="agents_tools_debug_export.json",s.click(),URL.revokeObjectURL(i),a("Debug export downloaded","success")}catch{a("Debug export failed","error")}},[a]),N=l.filter(t=>!m||t.title.toLowerCase().includes(m.toLowerCase()));return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold tracking-tight",children:"History"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[l.length," conversation",l.length!==1?"s":""]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex rounded-lg border border-border overflow-hidden",children:[e.jsxs("button",{className:h("px-2.5 py-1 text-[10px] font-medium transition-colors",n==="conversations"?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>v("conversations"),children:[e.jsx(d,{className:"h-3 w-3 inline mr-1"}),"Conversations"]}),e.jsxs("button",{className:h("px-2.5 py-1 text-[10px] font-medium transition-colors border-l border-border",n==="timeline"?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>v("timeline"),children:[e.jsx(g,{className:"h-3 w-3 inline mr-1"}),"Timeline"]})]}),n==="conversations"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",onClick:M,title:"Export full pixelbot_v3.tools table with all columns for debugging",children:[e.jsx(oe,{className:"h-3 w-3"})," Debug Export"]}),e.jsxs("button",{className:"flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",onClick:E,children:[e.jsx(W,{className:"h-3 w-3"})," Export"]})]})]})]}),n==="timeline"&&e.jsx(le,{events:k,isLoading:S}),n==="conversations"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-6 py-3",children:e.jsxs("div",{className:"relative",children:[e.jsx(K,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(A,{placeholder:"Search conversations...",value:m,onChange:t=>f(t.target.value),className:"pl-9 h-9 rounded-lg text-sm"})]})}),e.jsx(B,{className:"flex-1 px-6",children:u?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(w,{className:"h-6 w-6 animate-spin text-k-yellow mb-2"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Loading conversations..."})]}):N.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(d,{className:"h-10 w-10 text-muted-foreground/20 mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No conversations yet"})]}):e.jsx("div",{className:"space-y-1.5 pb-4",children:N.map((t,i)=>e.jsxs("div",{className:"flex items-center gap-3 rounded-xl border border-border/50 p-3 hover:bg-card hover:border-border transition-all group cursor-pointer animate-fade-in",style:{animationDelay:`${i*30}ms`},onClick:()=>y(t.conversation_id),children:[e.jsx("div",{className:"h-9 w-9 rounded-lg bg-muted flex items-center justify-center shrink-0",children:e.jsx(d,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:t.title||"New conversation"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1.5",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-muted-foreground/70",children:[e.jsx(g,{className:"h-2.5 w-2.5"}),new Date(t.updated_at).toLocaleString()]}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-muted-foreground/50",children:[e.jsx(d,{className:"h-2.5 w-2.5"}),t.message_count," messages"]})]})]}),e.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{className:"h-7 w-7 flex items-center justify-center rounded-md hover:bg-accent transition-colors",onClick:s=>{s.stopPropagation(),y(t.conversation_id)},title:"Open conversation",children:e.jsx(J,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("button",{className:"h-7 w-7 flex items-center justify-center rounded-md hover:bg-destructive/10 transition-colors",onClick:s=>D(s,t.conversation_id),title:"Delete conversation",children:e.jsx(X,{className:"h-3.5 w-3.5 text-destructive"})})]})]},t.conversation_id))})})]})]})}const ne={Query:d,Chat:d,Memory:V,Document:ae,Image:R,Video:se,Audio:te,ImageGen:ee,VideoGen:O,CSV:Z,Persona:Y},ie={Query:"text-blue-400",Chat:"text-sky-400",Memory:"text-purple-400",Document:"text-amber-400",Image:"text-emerald-400",Video:"text-rose-400",Audio:"text-orange-400",ImageGen:"text-pink-400",VideoGen:"text-red-400",CSV:"text-cyan-400",Persona:"text-indigo-400"};function le({events:a,isLoading:x}){if(x)return e.jsx("div",{className:"flex items-center justify-center flex-1",children:e.jsx(w,{className:"h-5 w-5 animate-spin text-k-yellow"})});if(a.length===0)return e.jsxs("div",{className:"flex flex-col items-center justify-center flex-1 gap-2",children:[e.jsx(g,{className:"h-10 w-10 text-muted-foreground/15"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No activity yet"})]});const n={};for(const c of a){const l=c.timestamp?new Date(c.timestamp).toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric"}):"Unknown date";n[l]||(n[l]=[]),n[l].push(c)}return e.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-4 w-full",children:Object.entries(n).map(([c,l])=>e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("div",{className:"h-px flex-1 bg-border"}),e.jsx("span",{className:"text-[10px] font-medium text-muted-foreground/60 uppercase tracking-wider shrink-0",children:c}),e.jsx("div",{className:"h-px flex-1 bg-border"})]}),e.jsx("div",{className:"space-y-1",children:l.map((o,m)=>{const f=ne[o.type]??F,u=ie[o.type]??"text-muted-foreground",p=o.timestamp?new Date(o.timestamp).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"}):"";return e.jsxs("div",{className:"flex items-start gap-3 rounded-lg px-3 py-2 hover:bg-accent/30 transition-colors",children:[e.jsx("div",{className:h("mt-0.5 shrink-0",u),children:e.jsx(f,{className:"h-3.5 w-3.5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(G,{variant:"outline",className:h("text-[8px] shrink-0",u),children:o.type}),o.role&&e.jsx("span",{className:"text-[9px] text-muted-foreground/50",children:o.role})]}),e.jsx("p",{className:"text-[11px] text-foreground/80 mt-0.5 line-clamp-2",children:o.label})]}),e.jsx("span",{className:"text-[9px] text-muted-foreground/40 tabular-nums shrink-0 mt-0.5",children:p})]},`${o.table}-${m}`)})})]},c))})}export{Me as HistoryPage}; diff --git a/backend/pixelbot/static/assets/images-page-BXkG9yIo.js b/backend/pixelbot/static/assets/images-page-DYBRGVW-.js similarity index 94% rename from backend/pixelbot/static/assets/images-page-BXkG9yIo.js rename to backend/pixelbot/static/assets/images-page-DYBRGVW-.js index 9c51bb9..2ac78e9 100644 --- a/backend/pixelbot/static/assets/images-page-BXkG9yIo.js +++ b/backend/pixelbot/static/assets/images-page-DYBRGVW-.js @@ -1 +1 @@ -import{c as Le,b as Ve,r as s,j as e,I as q,a as d}from"./index-bcIN4R_6.js";import{u as z,L as v}from"./use-mount-effect-Dj1RN52i.js";import{I as De}from"./input-B5vinQUU.js";import{S as Te}from"./scroll-area-C83pY0Er.js";import{D as O,a as Q,b as W,c as Y,d as J}from"./dialog-DdsFnGPg.js";import{B as j}from"./badge-BIO9r-az.js";import{Q as Fe,R as Ge,S as Ee,T as Me,U as _e,V as Pe,d as G,W as He,X as Ue,Y as Ae,Z as Re}from"./api-qB_zxs57.js";import{Z as Xe}from"./zap-DHWYuVbn.js";import{P as ae}from"./palette-BeKv7zaI.js";import{F as g}from"./film-D0A7CDhQ.js";import{S as Ze}from"./search-D7pTrHQu.js";import{C as E}from"./check-EY4MJcH5.js";import{D as K}from"./download-s6JlUMMe.js";import{T as ee}from"./trash-2-Dwdv-GS6.js";import{P as $e}from"./pencil-BXDLPx3O.js";import{C as oe}from"./clock-pUwGegUT.js";import"./index-PhySa8BR.js";import"./index-BUPn8X34.js";import"./index-B57p4poT.js";import"./index-BdQq_4o_.js";import"./index-BBsWTzq-.js";import"./index-XhUYjquv.js";import"./x-DjdZKBVk.js";const Be=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],te=Le("folder-plus",Be);function pt(){const{addToast:a}=Ve(),[p,f]=s.useState(null),[o,b]=s.useState("images"),[l,k]=s.useState([]),[x,re]=s.useState(""),[le,M]=s.useState(!0),[i,y]=s.useState(null),[_,ne]=s.useState([]),[S,ie]=s.useState(""),[ce,P]=s.useState(!1),[H,de]=s.useState(!1),[w,C]=s.useState(!1),[m,I]=s.useState([]),[U,A]=s.useState(!1),[L,me]=s.useState([]),[V,xe]=s.useState(""),[ue,R]=s.useState(!1),[X,he]=s.useState(!1),[c,D]=s.useState(null),[n,N]=s.useState(!1),[u,Z]=s.useState(new Set);z(()=>{Re().then(f).catch(()=>{})});const T=s.useCallback(async()=>{M(!0);try{const t=await Fe();k(t)}catch{a("Failed to load images","error")}finally{M(!1)}},[a]),$=s.useCallback(async()=>{P(!0);try{const t=await Ge();ne(t),de(!0)}catch{a("Failed to load FLUX images","error")}finally{P(!1)}},[a]),h=s.useCallback(async()=>{R(!0);try{const t=await Ee();me(t),he(!0)}catch{a("Failed to load videos","error")}finally{R(!1)}},[a]);z(()=>{T()});const F=s.useCallback(t=>{b(t),t==="flux"&&!H?$():t==="videos"&&!X&&h()},[H,X,$,h]),ge=s.useCallback(async t=>{try{await Me(t),a("Image deleted","success"),y(null),await T()}catch(r){a(r instanceof Error?r.message:"Delete failed","error")}},[a,T]),pe=s.useCallback(async t=>{try{await _e(t),a("Video deleted","success"),D(null),await h()}catch(r){a(r instanceof Error?r.message:"Delete failed","error")}},[a,h]),fe=s.useCallback(t=>{const r=document.createElement("a");r.href=t.full_image,r.download=`${t.prompt.slice(0,30).replace(/[^a-z0-9]/gi,"_").toLowerCase()}.png`,r.click()},[]),be=s.useCallback(async()=>{if(!(m.length<2)){A(!0);try{a("Generating slideshow... this may take a moment","info"),await Pe(m),a("Slideshow generated successfully! Check the Videos tab.","success"),C(!1),I([]),h()}catch(t){a(t instanceof Error?t.message:"Slideshow generation failed","error")}finally{A(!0)}}},[m,a,h]),B=s.useCallback(t=>{I(r=>r.includes(t.timestamp)?r.filter(Ie=>Ie!==t.timestamp):[...r,t.timestamp])},[]),we=s.useCallback(t=>{const r=document.createElement("a");r.href=G(t.video_path),r.download=`pixelbot_${t.timestamp}.mp4`,r.click()},[]),ve=s.useCallback(async t=>{if(!(n||u.has(t))){N(!0);try{o==="flux"?await He(t):await Ue(t),Z(r=>new Set(r).add(t)),a("Image saved to collection — CLIP embedding & RAG indexing started","success")}catch(r){a(r instanceof Error?r.message:"Failed to save to collection","error")}finally{N(!1)}}},[n,u,a,o]),je=s.useCallback(async t=>{if(!(n||u.has(t))){N(!0);try{await Ae(t),Z(r=>new Set(r).add(t)),a("Video saved to collection — keyframe extraction & transcription started","success")}catch(r){a(r instanceof Error?r.message:"Failed to save to collection","error")}finally{N(!1)}}},[n,u,a]),ye=s.useCallback(()=>{a("Video editing coming soon — RunwayML integration","info")},[a]),Ne=l.filter(t=>!x||t.prompt.toLowerCase().includes(x.toLowerCase())),ke=_.filter(t=>!S||t.prompt.toLowerCase().includes(S.toLowerCase())),Se=L.filter(t=>!V||t.prompt.toLowerCase().includes(V.toLowerCase())),Ce=o==="images"?"Gemini Imagen":o==="flux"?"BFL FLUX":"Gemini Veo";return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold tracking-tight",children:"Media Library"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:[l.length," imagen · ",_.length," flux ·"," ",L.length," video",L.length!==1?"s":""]}),p&&e.jsxs(j,{variant:"secondary",className:"text-[9px] px-1.5 py-0 gap-1",children:[e.jsx(Xe,{className:"h-2.5 w-2.5"}),Ce]})]})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsxs("button",{className:d("flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-medium transition-all",o==="images"?"bg-k-yellow/10 text-k-yellow ring-1 ring-k-yellow/20":"text-muted-foreground hover:bg-accent hover:text-foreground"),onClick:()=>F("images"),children:[e.jsx(q,{className:"h-3 w-3"}),"Images"]}),e.jsxs("button",{className:d("flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-medium transition-all",o==="flux"?"bg-orange-500/10 text-orange-400 ring-1 ring-orange-500/20":"text-muted-foreground hover:bg-accent hover:text-foreground"),onClick:()=>F("flux"),children:[e.jsx(ae,{className:"h-3 w-3"}),"FLUX"]}),e.jsxs("button",{className:d("flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-medium transition-all",o==="videos"?"bg-k-yellow/10 text-k-yellow ring-1 ring-k-yellow/20":"text-muted-foreground hover:bg-accent hover:text-foreground"),onClick:()=>F("videos"),children:[e.jsx(g,{className:"h-3 w-3"}),"Videos"]})]})]}),e.jsxs("div",{className:"px-6 py-3 flex gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Ze,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by prompt...",value:o==="images"?x:o==="flux"?S:V,onChange:t=>o==="images"?re(t.target.value):o==="flux"?ie(t.target.value):xe(t.target.value),className:"pl-9 h-9 rounded-lg text-sm"})]}),(o==="images"||o==="flux")&&(w?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{className:"px-3 py-1.5 text-xs font-medium border border-border text-foreground hover:bg-accent rounded-lg transition-colors",onClick:()=>{C(!1),I([])},children:"Cancel"}),e.jsxs("button",{disabled:m.length<2||U,className:"px-3 py-1.5 text-xs font-medium bg-k-yellow text-background hover:bg-yellow-400 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",onClick:be,children:[U?e.jsx(v,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(g,{className:"h-3.5 w-3.5"}),"Generate Video (",m.length,")"]})]}):e.jsxs("button",{className:"px-3 py-1.5 text-xs font-medium border border-border text-foreground hover:bg-accent rounded-lg flex items-center gap-2 transition-colors",onClick:()=>C(!0),children:[e.jsx(g,{className:"h-3.5 w-3.5"}),"Slideshow Mode"]}))]}),e.jsx(Te,{className:"flex-1 px-6",children:o==="images"?e.jsx(se,{images:Ne,isLoading:le,onSelect:w?B:y,selectableMode:w,selectedTimestamps:m}):o==="flux"?e.jsx(se,{images:ke,isLoading:ce,onSelect:w?B:y,selectableMode:w,selectedTimestamps:m}):e.jsx(qe,{videos:Se,isLoading:ue,onSelect:D})}),e.jsx(O,{open:!!i,onOpenChange:t=>!t&&y(null),children:e.jsxs(Q,{className:"max-w-2xl",children:[e.jsxs(W,{children:[e.jsxs(Y,{className:"flex items-center gap-2",children:[e.jsx(q,{className:"h-4 w-4 text-k-yellow"}),"Generated Image",i?.provider&&e.jsx(j,{variant:"secondary",className:"text-[9px] ml-1",children:i.provider})]}),e.jsx(J,{className:"text-sm",children:i?.prompt})]}),i&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("img",{src:i.full_image,alt:i.prompt,className:"w-full rounded-xl border border-border"}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[u.has(i.timestamp)?e.jsxs("button",{className:"flex items-center gap-1.5 rounded-lg border border-emerald-500/30 px-3 py-1.5 text-xs font-medium text-emerald-500 cursor-default",disabled:!0,children:[e.jsx(E,{className:"h-3 w-3"})," Saved to Collection"]}):e.jsxs("button",{className:d("flex items-center gap-1.5 rounded-lg border border-k-yellow/30 px-3 py-1.5 text-xs font-medium text-k-yellow hover:bg-k-yellow/10 transition-colors",n&&"opacity-50 pointer-events-none"),onClick:()=>ve(i.timestamp),disabled:n,children:[n?e.jsx(v,{className:"h-3 w-3 animate-spin"}):e.jsx(te,{className:"h-3 w-3"}),n?"Saving...":"Save to Collection"]}),e.jsxs("button",{className:"flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",onClick:()=>fe(i),children:[e.jsx(K,{className:"h-3 w-3"})," Download"]}),e.jsxs("button",{className:"flex items-center gap-1.5 rounded-lg border border-destructive/30 px-3 py-1.5 text-xs font-medium text-destructive hover:bg-destructive/10 transition-colors",onClick:()=>ge(i.timestamp),children:[e.jsx(ee,{className:"h-3 w-3"})," Delete"]})]})]})]})}),e.jsx(O,{open:!!c,onOpenChange:t=>!t&&D(null),children:e.jsxs(Q,{className:"max-w-2xl",children:[e.jsxs(W,{children:[e.jsxs(Y,{className:"flex items-center gap-2",children:[e.jsx(g,{className:"h-4 w-4 text-k-yellow"}),"Generated Video",c?.provider&&e.jsx(j,{variant:"secondary",className:"text-[9px] ml-1",children:c.provider})]}),e.jsx(J,{className:"text-sm",children:c?.prompt})]}),c&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("video",{src:G(c.video_path),controls:!0,className:"w-full rounded-xl border border-border"}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[u.has(c.timestamp)?e.jsxs("button",{className:"flex items-center gap-1.5 rounded-lg border border-emerald-500/30 px-3 py-1.5 text-xs font-medium text-emerald-500 cursor-default",disabled:!0,children:[e.jsx(E,{className:"h-3 w-3"})," Saved to Collection"]}):e.jsxs("button",{className:d("flex items-center gap-1.5 rounded-lg border border-k-yellow/30 px-3 py-1.5 text-xs font-medium text-k-yellow hover:bg-k-yellow/10 transition-colors",n&&"opacity-50 pointer-events-none"),onClick:()=>je(c.timestamp),disabled:n,children:[n?e.jsx(v,{className:"h-3 w-3 animate-spin"}):e.jsx(te,{className:"h-3 w-3"}),n?"Saving...":"Save to Collection"]}),e.jsxs("button",{className:"flex items-center gap-1.5 rounded-lg border border-violet-500/30 px-3 py-1.5 text-xs font-medium text-violet-400 hover:bg-violet-500/10 transition-colors",onClick:ye,children:[e.jsx($e,{className:"h-3 w-3"})," Edit"]}),e.jsxs("button",{className:"flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",onClick:()=>we(c),children:[e.jsx(K,{className:"h-3 w-3"})," Download"]}),e.jsxs("button",{className:"flex items-center gap-1.5 rounded-lg border border-destructive/30 px-3 py-1.5 text-xs font-medium text-destructive hover:bg-destructive/10 transition-colors",onClick:()=>pe(c.timestamp),children:[e.jsx(ee,{className:"h-3 w-3"})," Delete"]})]})]})]})})]})}function se({images:a,isLoading:p,onSelect:f,selectableMode:o=!1,selectedTimestamps:b=[]}){return p?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(v,{className:"h-6 w-6 animate-spin text-k-yellow mb-2"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Loading gallery..."})]}):a.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[e.jsx("div",{className:"h-16 w-16 rounded-2xl bg-muted flex items-center justify-center mb-4",children:e.jsx(ae,{className:"h-8 w-8 text-muted-foreground/30"})}),e.jsx("p",{className:"text-sm text-muted-foreground font-medium",children:"No images yet"}),e.jsx("p",{className:"text-xs text-muted-foreground/60 mt-1 max-w-xs",children:"Generate images from Chat using the Image mode toggle, then manage them here."})]}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-3 pb-6",children:a.map((l,k)=>{const x=b.includes(l.timestamp);return e.jsxs("div",{className:d("group relative rounded-xl border overflow-hidden cursor-pointer","transition-all animate-fade-in",o&&x?"border-k-yellow ring-2 ring-k-yellow/50 shadow-md transform scale-[0.98]":"border-border hover:border-k-yellow/50 hover:shadow-lg hover:shadow-k-yellow/5"),style:{animationDelay:`${k*40}ms`},onClick:()=>f(l),children:[e.jsx("img",{src:l.thumbnail_image,alt:l.prompt,className:"w-full aspect-square object-cover"}),o&&e.jsx("div",{className:"absolute top-2 right-2 flex items-center justify-center w-6 h-6 rounded-full border border-white bg-black/40 shadow-sm overflow-hidden z-10 transition-colors",children:x&&e.jsx("div",{className:"w-full h-full bg-k-yellow flex items-center justify-center",children:e.jsx(E,{className:"h-3.5 w-3.5 text-black"})})}),e.jsx("div",{className:d("absolute inset-0 bg-gradient-to-t from-black/70 via-black/0 to-transparent transition-opacity duration-200",o?"opacity-100":"opacity-0 group-hover:opacity-100"),children:e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 p-3",children:[e.jsx("p",{className:"text-white text-xs truncate font-medium",children:l.prompt}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(oe,{className:"h-2.5 w-2.5 text-white/50"}),e.jsx("span",{className:"text-[10px] text-white/50",children:new Date(l.timestamp).toLocaleDateString()}),l.provider&&e.jsx(j,{variant:"secondary",className:"text-[8px] px-1 py-0 bg-white/10 text-white/60 border-0",children:l.provider})]})]})})]},l.timestamp)})})}function qe({videos:a,isLoading:p,onSelect:f}){return p?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(v,{className:"h-6 w-6 animate-spin text-k-yellow mb-2"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Loading videos..."})]}):a.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[e.jsx("div",{className:"h-16 w-16 rounded-2xl bg-muted flex items-center justify-center mb-4",children:e.jsx(g,{className:"h-8 w-8 text-muted-foreground/30"})}),e.jsx("p",{className:"text-sm text-muted-foreground font-medium",children:"No videos yet"}),e.jsx("p",{className:"text-xs text-muted-foreground/60 mt-1 max-w-xs",children:"Generate videos from Chat using the Video mode toggle, then manage them here."})]}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3 pb-6",children:a.map((o,b)=>e.jsxs("div",{className:d("group relative rounded-xl border border-border overflow-hidden cursor-pointer","hover:border-k-yellow/50 hover:shadow-lg hover:shadow-k-yellow/5 transition-all animate-fade-in"),style:{animationDelay:`${b*40}ms`},onClick:()=>f(o),children:[e.jsx("video",{src:G(o.video_path),muted:!0,className:"w-full aspect-video object-cover",onMouseEnter:l=>l.currentTarget.play(),onMouseLeave:l=>{l.currentTarget.pause(),l.currentTarget.currentTime=0}}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/70 via-black/0 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 p-3",children:[e.jsx("p",{className:"text-white text-xs truncate font-medium",children:o.prompt}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(oe,{className:"h-2.5 w-2.5 text-white/50"}),e.jsx("span",{className:"text-[10px] text-white/50",children:new Date(o.timestamp).toLocaleDateString()}),o.provider&&e.jsx(j,{variant:"secondary",className:"text-[8px] px-1 py-0 bg-white/10 text-white/60 border-0",children:o.provider})]})]})}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none group-hover:opacity-0 transition-opacity",children:e.jsx("div",{className:"h-10 w-10 rounded-full bg-black/50 flex items-center justify-center",children:e.jsx(g,{className:"h-4 w-4 text-white"})})})]},o.timestamp))})}export{pt as ImagesPage}; +import{c as Le,b as Ve,r as s,j as e,I as q,a as d}from"./index-BKlAZSPs.js";import{u as z,L as v}from"./use-mount-effect-CEqzESrx.js";import{I as De}from"./input-DEyNLzjf.js";import{S as Te}from"./scroll-area-DW6yccR3.js";import{D as O,a as Q,b as W,c as Y,d as J}from"./dialog-C0z6ZEzu.js";import{B as j}from"./badge-B_CNDVZh.js";import{Q as Fe,R as Ge,S as Ee,T as Me,U as _e,V as Pe,d as G,W as He,X as Ue,Y as Ae,Z as Re}from"./api-qB_zxs57.js";import{Z as Xe}from"./zap-BvSjcoQz.js";import{P as ae}from"./palette-CTN9E14x.js";import{F as g}from"./film-BB-YPpGv.js";import{S as Ze}from"./search-BHgUFHtw.js";import{C as E}from"./check-D-roFugH.js";import{D as K}from"./download-gDnOKy-4.js";import{T as ee}from"./trash-2-sY6rixAj.js";import{P as $e}from"./pencil-DH9VG1hT.js";import{C as oe}from"./clock-CN2-2vC4.js";import"./index-KbvIRwKr.js";import"./index-B8obv054.js";import"./index-Dr3YzRu6.js";import"./index-BdQq_4o_.js";import"./index-BidtQh_T.js";import"./index-oUe0EePc.js";import"./x-B99eDFz6.js";const Be=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],te=Le("folder-plus",Be);function pt(){const{addToast:a}=Ve(),[p,f]=s.useState(null),[o,b]=s.useState("images"),[l,k]=s.useState([]),[x,re]=s.useState(""),[le,M]=s.useState(!0),[i,y]=s.useState(null),[_,ne]=s.useState([]),[S,ie]=s.useState(""),[ce,P]=s.useState(!1),[H,de]=s.useState(!1),[w,C]=s.useState(!1),[m,I]=s.useState([]),[U,A]=s.useState(!1),[L,me]=s.useState([]),[V,xe]=s.useState(""),[ue,R]=s.useState(!1),[X,he]=s.useState(!1),[c,D]=s.useState(null),[n,N]=s.useState(!1),[u,Z]=s.useState(new Set);z(()=>{Re().then(f).catch(()=>{})});const T=s.useCallback(async()=>{M(!0);try{const t=await Fe();k(t)}catch{a("Failed to load images","error")}finally{M(!1)}},[a]),$=s.useCallback(async()=>{P(!0);try{const t=await Ge();ne(t),de(!0)}catch{a("Failed to load FLUX images","error")}finally{P(!1)}},[a]),h=s.useCallback(async()=>{R(!0);try{const t=await Ee();me(t),he(!0)}catch{a("Failed to load videos","error")}finally{R(!1)}},[a]);z(()=>{T()});const F=s.useCallback(t=>{b(t),t==="flux"&&!H?$():t==="videos"&&!X&&h()},[H,X,$,h]),ge=s.useCallback(async t=>{try{await Me(t),a("Image deleted","success"),y(null),await T()}catch(r){a(r instanceof Error?r.message:"Delete failed","error")}},[a,T]),pe=s.useCallback(async t=>{try{await _e(t),a("Video deleted","success"),D(null),await h()}catch(r){a(r instanceof Error?r.message:"Delete failed","error")}},[a,h]),fe=s.useCallback(t=>{const r=document.createElement("a");r.href=t.full_image,r.download=`${t.prompt.slice(0,30).replace(/[^a-z0-9]/gi,"_").toLowerCase()}.png`,r.click()},[]),be=s.useCallback(async()=>{if(!(m.length<2)){A(!0);try{a("Generating slideshow... this may take a moment","info"),await Pe(m),a("Slideshow generated successfully! Check the Videos tab.","success"),C(!1),I([]),h()}catch(t){a(t instanceof Error?t.message:"Slideshow generation failed","error")}finally{A(!0)}}},[m,a,h]),B=s.useCallback(t=>{I(r=>r.includes(t.timestamp)?r.filter(Ie=>Ie!==t.timestamp):[...r,t.timestamp])},[]),we=s.useCallback(t=>{const r=document.createElement("a");r.href=G(t.video_path),r.download=`pixelbot_${t.timestamp}.mp4`,r.click()},[]),ve=s.useCallback(async t=>{if(!(n||u.has(t))){N(!0);try{o==="flux"?await He(t):await Ue(t),Z(r=>new Set(r).add(t)),a("Image saved to collection — CLIP embedding & RAG indexing started","success")}catch(r){a(r instanceof Error?r.message:"Failed to save to collection","error")}finally{N(!1)}}},[n,u,a,o]),je=s.useCallback(async t=>{if(!(n||u.has(t))){N(!0);try{await Ae(t),Z(r=>new Set(r).add(t)),a("Video saved to collection — keyframe extraction & transcription started","success")}catch(r){a(r instanceof Error?r.message:"Failed to save to collection","error")}finally{N(!1)}}},[n,u,a]),ye=s.useCallback(()=>{a("Video editing coming soon — RunwayML integration","info")},[a]),Ne=l.filter(t=>!x||t.prompt.toLowerCase().includes(x.toLowerCase())),ke=_.filter(t=>!S||t.prompt.toLowerCase().includes(S.toLowerCase())),Se=L.filter(t=>!V||t.prompt.toLowerCase().includes(V.toLowerCase())),Ce=o==="images"?"Gemini Imagen":o==="flux"?"BFL FLUX":"Gemini Veo";return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold tracking-tight",children:"Media Library"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:[l.length," imagen · ",_.length," flux ·"," ",L.length," video",L.length!==1?"s":""]}),p&&e.jsxs(j,{variant:"secondary",className:"text-[9px] px-1.5 py-0 gap-1",children:[e.jsx(Xe,{className:"h-2.5 w-2.5"}),Ce]})]})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsxs("button",{className:d("flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-medium transition-all",o==="images"?"bg-k-yellow/10 text-k-yellow ring-1 ring-k-yellow/20":"text-muted-foreground hover:bg-accent hover:text-foreground"),onClick:()=>F("images"),children:[e.jsx(q,{className:"h-3 w-3"}),"Images"]}),e.jsxs("button",{className:d("flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-medium transition-all",o==="flux"?"bg-orange-500/10 text-orange-400 ring-1 ring-orange-500/20":"text-muted-foreground hover:bg-accent hover:text-foreground"),onClick:()=>F("flux"),children:[e.jsx(ae,{className:"h-3 w-3"}),"FLUX"]}),e.jsxs("button",{className:d("flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-medium transition-all",o==="videos"?"bg-k-yellow/10 text-k-yellow ring-1 ring-k-yellow/20":"text-muted-foreground hover:bg-accent hover:text-foreground"),onClick:()=>F("videos"),children:[e.jsx(g,{className:"h-3 w-3"}),"Videos"]})]})]}),e.jsxs("div",{className:"px-6 py-3 flex gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Ze,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(De,{placeholder:"Search by prompt...",value:o==="images"?x:o==="flux"?S:V,onChange:t=>o==="images"?re(t.target.value):o==="flux"?ie(t.target.value):xe(t.target.value),className:"pl-9 h-9 rounded-lg text-sm"})]}),(o==="images"||o==="flux")&&(w?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{className:"px-3 py-1.5 text-xs font-medium border border-border text-foreground hover:bg-accent rounded-lg transition-colors",onClick:()=>{C(!1),I([])},children:"Cancel"}),e.jsxs("button",{disabled:m.length<2||U,className:"px-3 py-1.5 text-xs font-medium bg-k-yellow text-background hover:bg-yellow-400 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",onClick:be,children:[U?e.jsx(v,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(g,{className:"h-3.5 w-3.5"}),"Generate Video (",m.length,")"]})]}):e.jsxs("button",{className:"px-3 py-1.5 text-xs font-medium border border-border text-foreground hover:bg-accent rounded-lg flex items-center gap-2 transition-colors",onClick:()=>C(!0),children:[e.jsx(g,{className:"h-3.5 w-3.5"}),"Slideshow Mode"]}))]}),e.jsx(Te,{className:"flex-1 px-6",children:o==="images"?e.jsx(se,{images:Ne,isLoading:le,onSelect:w?B:y,selectableMode:w,selectedTimestamps:m}):o==="flux"?e.jsx(se,{images:ke,isLoading:ce,onSelect:w?B:y,selectableMode:w,selectedTimestamps:m}):e.jsx(qe,{videos:Se,isLoading:ue,onSelect:D})}),e.jsx(O,{open:!!i,onOpenChange:t=>!t&&y(null),children:e.jsxs(Q,{className:"max-w-2xl",children:[e.jsxs(W,{children:[e.jsxs(Y,{className:"flex items-center gap-2",children:[e.jsx(q,{className:"h-4 w-4 text-k-yellow"}),"Generated Image",i?.provider&&e.jsx(j,{variant:"secondary",className:"text-[9px] ml-1",children:i.provider})]}),e.jsx(J,{className:"text-sm",children:i?.prompt})]}),i&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("img",{src:i.full_image,alt:i.prompt,className:"w-full rounded-xl border border-border"}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[u.has(i.timestamp)?e.jsxs("button",{className:"flex items-center gap-1.5 rounded-lg border border-emerald-500/30 px-3 py-1.5 text-xs font-medium text-emerald-500 cursor-default",disabled:!0,children:[e.jsx(E,{className:"h-3 w-3"})," Saved to Collection"]}):e.jsxs("button",{className:d("flex items-center gap-1.5 rounded-lg border border-k-yellow/30 px-3 py-1.5 text-xs font-medium text-k-yellow hover:bg-k-yellow/10 transition-colors",n&&"opacity-50 pointer-events-none"),onClick:()=>ve(i.timestamp),disabled:n,children:[n?e.jsx(v,{className:"h-3 w-3 animate-spin"}):e.jsx(te,{className:"h-3 w-3"}),n?"Saving...":"Save to Collection"]}),e.jsxs("button",{className:"flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",onClick:()=>fe(i),children:[e.jsx(K,{className:"h-3 w-3"})," Download"]}),e.jsxs("button",{className:"flex items-center gap-1.5 rounded-lg border border-destructive/30 px-3 py-1.5 text-xs font-medium text-destructive hover:bg-destructive/10 transition-colors",onClick:()=>ge(i.timestamp),children:[e.jsx(ee,{className:"h-3 w-3"})," Delete"]})]})]})]})}),e.jsx(O,{open:!!c,onOpenChange:t=>!t&&D(null),children:e.jsxs(Q,{className:"max-w-2xl",children:[e.jsxs(W,{children:[e.jsxs(Y,{className:"flex items-center gap-2",children:[e.jsx(g,{className:"h-4 w-4 text-k-yellow"}),"Generated Video",c?.provider&&e.jsx(j,{variant:"secondary",className:"text-[9px] ml-1",children:c.provider})]}),e.jsx(J,{className:"text-sm",children:c?.prompt})]}),c&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("video",{src:G(c.video_path),controls:!0,className:"w-full rounded-xl border border-border"}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[u.has(c.timestamp)?e.jsxs("button",{className:"flex items-center gap-1.5 rounded-lg border border-emerald-500/30 px-3 py-1.5 text-xs font-medium text-emerald-500 cursor-default",disabled:!0,children:[e.jsx(E,{className:"h-3 w-3"})," Saved to Collection"]}):e.jsxs("button",{className:d("flex items-center gap-1.5 rounded-lg border border-k-yellow/30 px-3 py-1.5 text-xs font-medium text-k-yellow hover:bg-k-yellow/10 transition-colors",n&&"opacity-50 pointer-events-none"),onClick:()=>je(c.timestamp),disabled:n,children:[n?e.jsx(v,{className:"h-3 w-3 animate-spin"}):e.jsx(te,{className:"h-3 w-3"}),n?"Saving...":"Save to Collection"]}),e.jsxs("button",{className:"flex items-center gap-1.5 rounded-lg border border-violet-500/30 px-3 py-1.5 text-xs font-medium text-violet-400 hover:bg-violet-500/10 transition-colors",onClick:ye,children:[e.jsx($e,{className:"h-3 w-3"})," Edit"]}),e.jsxs("button",{className:"flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",onClick:()=>we(c),children:[e.jsx(K,{className:"h-3 w-3"})," Download"]}),e.jsxs("button",{className:"flex items-center gap-1.5 rounded-lg border border-destructive/30 px-3 py-1.5 text-xs font-medium text-destructive hover:bg-destructive/10 transition-colors",onClick:()=>pe(c.timestamp),children:[e.jsx(ee,{className:"h-3 w-3"})," Delete"]})]})]})]})})]})}function se({images:a,isLoading:p,onSelect:f,selectableMode:o=!1,selectedTimestamps:b=[]}){return p?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(v,{className:"h-6 w-6 animate-spin text-k-yellow mb-2"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Loading gallery..."})]}):a.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[e.jsx("div",{className:"h-16 w-16 rounded-2xl bg-muted flex items-center justify-center mb-4",children:e.jsx(ae,{className:"h-8 w-8 text-muted-foreground/30"})}),e.jsx("p",{className:"text-sm text-muted-foreground font-medium",children:"No images yet"}),e.jsx("p",{className:"text-xs text-muted-foreground/60 mt-1 max-w-xs",children:"Generate images from Chat using the Image mode toggle, then manage them here."})]}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-3 pb-6",children:a.map((l,k)=>{const x=b.includes(l.timestamp);return e.jsxs("div",{className:d("group relative rounded-xl border overflow-hidden cursor-pointer","transition-all animate-fade-in",o&&x?"border-k-yellow ring-2 ring-k-yellow/50 shadow-md transform scale-[0.98]":"border-border hover:border-k-yellow/50 hover:shadow-lg hover:shadow-k-yellow/5"),style:{animationDelay:`${k*40}ms`},onClick:()=>f(l),children:[e.jsx("img",{src:l.thumbnail_image,alt:l.prompt,className:"w-full aspect-square object-cover"}),o&&e.jsx("div",{className:"absolute top-2 right-2 flex items-center justify-center w-6 h-6 rounded-full border border-white bg-black/40 shadow-sm overflow-hidden z-10 transition-colors",children:x&&e.jsx("div",{className:"w-full h-full bg-k-yellow flex items-center justify-center",children:e.jsx(E,{className:"h-3.5 w-3.5 text-black"})})}),e.jsx("div",{className:d("absolute inset-0 bg-gradient-to-t from-black/70 via-black/0 to-transparent transition-opacity duration-200",o?"opacity-100":"opacity-0 group-hover:opacity-100"),children:e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 p-3",children:[e.jsx("p",{className:"text-white text-xs truncate font-medium",children:l.prompt}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(oe,{className:"h-2.5 w-2.5 text-white/50"}),e.jsx("span",{className:"text-[10px] text-white/50",children:new Date(l.timestamp).toLocaleDateString()}),l.provider&&e.jsx(j,{variant:"secondary",className:"text-[8px] px-1 py-0 bg-white/10 text-white/60 border-0",children:l.provider})]})]})})]},l.timestamp)})})}function qe({videos:a,isLoading:p,onSelect:f}){return p?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(v,{className:"h-6 w-6 animate-spin text-k-yellow mb-2"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Loading videos..."})]}):a.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[e.jsx("div",{className:"h-16 w-16 rounded-2xl bg-muted flex items-center justify-center mb-4",children:e.jsx(g,{className:"h-8 w-8 text-muted-foreground/30"})}),e.jsx("p",{className:"text-sm text-muted-foreground font-medium",children:"No videos yet"}),e.jsx("p",{className:"text-xs text-muted-foreground/60 mt-1 max-w-xs",children:"Generate videos from Chat using the Video mode toggle, then manage them here."})]}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3 pb-6",children:a.map((o,b)=>e.jsxs("div",{className:d("group relative rounded-xl border border-border overflow-hidden cursor-pointer","hover:border-k-yellow/50 hover:shadow-lg hover:shadow-k-yellow/5 transition-all animate-fade-in"),style:{animationDelay:`${b*40}ms`},onClick:()=>f(o),children:[e.jsx("video",{src:G(o.video_path),muted:!0,className:"w-full aspect-video object-cover",onMouseEnter:l=>l.currentTarget.play(),onMouseLeave:l=>{l.currentTarget.pause(),l.currentTarget.currentTime=0}}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/70 via-black/0 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 p-3",children:[e.jsx("p",{className:"text-white text-xs truncate font-medium",children:o.prompt}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(oe,{className:"h-2.5 w-2.5 text-white/50"}),e.jsx("span",{className:"text-[10px] text-white/50",children:new Date(o.timestamp).toLocaleDateString()}),o.provider&&e.jsx(j,{variant:"secondary",className:"text-[8px] px-1 py-0 bg-white/10 text-white/60 border-0",children:o.provider})]})]})}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none group-hover:opacity-0 transition-opacity",children:e.jsx("div",{className:"h-10 w-10 rounded-full bg-black/50 flex items-center justify-center",children:e.jsx(g,{className:"h-4 w-4 text-white"})})})]},o.timestamp))})}export{pt as ImagesPage}; diff --git a/backend/pixelbot/static/assets/index-B8obv054.js b/backend/pixelbot/static/assets/index-B8obv054.js new file mode 100644 index 0000000..9025ae8 --- /dev/null +++ b/backend/pixelbot/static/assets/index-B8obv054.js @@ -0,0 +1 @@ +import{g as r,i as t}from"./index-BKlAZSPs.js";var a=t();const e=r(a);export{e as R,a as r}; diff --git a/backend/pixelbot/static/assets/index-bcIN4R_6.js b/backend/pixelbot/static/assets/index-BKlAZSPs.js similarity index 99% rename from backend/pixelbot/static/assets/index-bcIN4R_6.js rename to backend/pixelbot/static/assets/index-BKlAZSPs.js index 9547a83..c241abe 100644 --- a/backend/pixelbot/static/assets/index-bcIN4R_6.js +++ b/backend/pixelbot/static/assets/index-BKlAZSPs.js @@ -1,4 +1,4 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/chat-page-Bwm8Jjrk.js","assets/use-mount-effect-Dj1RN52i.js","assets/scroll-area-C83pY0Er.js","assets/index-PhySa8BR.js","assets/index-BUPn8X34.js","assets/index-B57p4poT.js","assets/index-BdQq_4o_.js","assets/textarea-CDFZlXW-.js","assets/api-qB_zxs57.js","assets/zap-DHWYuVbn.js","assets/file-text-CaGMG4i0.js","assets/cpu-DfPRd009.js","assets/sparkles-0UKh7vY0.js","assets/send-BGbQhIFd.js","assets/film-D0A7CDhQ.js","assets/search-D7pTrHQu.js","assets/x-DjdZKBVk.js","assets/chevron-down-DT2TrmF4.js","assets/mic-CJfv0bPT.js","assets/user-DyEtYY9s.js","assets/arrow-right-B3HaW9QC.js","assets/copy-BlKAoc_U.js","assets/clock-pUwGegUT.js","assets/check-EY4MJcH5.js","assets/music-BkTgGpyj.js","assets/studio-page-BkDrOW1x.js","assets/input-B5vinQUU.js","assets/slider-DxmNq9ng.js","assets/index-XhUYjquv.js","assets/index-FUXQzuGM.js","assets/badge-BIO9r-az.js","assets/type-GzMp4Pkc.js","assets/layers-OUyQGJkv.js","assets/eye-CE1wBT5v.js","assets/upload-Cpl8BuNe.js","assets/table-2-Di1d8bNw.js","assets/trash-2-Dwdv-GS6.js","assets/palette-BeKv7zaI.js","assets/play-tsVcgKvS.js","assets/save-Dy0Z_5IX.js","assets/download-s6JlUMMe.js","assets/plus-BwqCou7I.js","assets/history-page-CM_mrz-I.js","assets/images-page-BXkG9yIo.js","assets/dialog-DdsFnGPg.js","assets/index-BBsWTzq-.js","assets/pencil-BXDLPx3O.js","assets/memory-page-Bo-DGdJz.js","assets/settings-page-DTfP5wqc.js","assets/architecture-page-CSg8ielq.js","assets/style-RLw9hIeQ.js","assets/style-BZV40eAE.css","assets/database-page-AGKAY0iy.js","assets/hash-ByqwwcTl.js","assets/terminal-DMddRtTc.js","assets/experiments-page-CBKaAHyH.js","assets/developer-page-Cel5aU2N.js","assets/integrations-page-WpsEGi1z.js"])))=>i.map(i=>d[i]); +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/chat-page-B-yWKMNQ.js","assets/use-mount-effect-CEqzESrx.js","assets/scroll-area-DW6yccR3.js","assets/index-KbvIRwKr.js","assets/index-B8obv054.js","assets/index-Dr3YzRu6.js","assets/index-BdQq_4o_.js","assets/textarea-DsI0XwJn.js","assets/api-qB_zxs57.js","assets/zap-BvSjcoQz.js","assets/file-text-BKu2-OuI.js","assets/cpu-DmZE95NP.js","assets/sparkles-BwOhbqOy.js","assets/send-BwyFpxiP.js","assets/film-BB-YPpGv.js","assets/search-BHgUFHtw.js","assets/x-B99eDFz6.js","assets/chevron-down-9h0aHSqT.js","assets/mic-Dpr0Iaa8.js","assets/user-xoeV7n22.js","assets/arrow-right-DbPzFz_k.js","assets/copy-DR0TH8ar.js","assets/clock-CN2-2vC4.js","assets/check-D-roFugH.js","assets/music-Seq8oTV1.js","assets/studio-page-By8KQc9u.js","assets/input-DEyNLzjf.js","assets/slider-Twfzc0LC.js","assets/index-oUe0EePc.js","assets/index-hR8PON02.js","assets/badge-B_CNDVZh.js","assets/type-DH9mEbj2.js","assets/layers-6fEVoVKq.js","assets/eye-D_Cs7pQZ.js","assets/upload-LUlCBhqv.js","assets/table-2-KM3JqDhH.js","assets/trash-2-sY6rixAj.js","assets/palette-CTN9E14x.js","assets/play-BXh2-cUU.js","assets/save-DeZNrtZP.js","assets/download-gDnOKy-4.js","assets/plus-CFgJREI2.js","assets/history-page-C6Kikg4C.js","assets/images-page-DYBRGVW-.js","assets/dialog-C0z6ZEzu.js","assets/index-BidtQh_T.js","assets/pencil-DH9VG1hT.js","assets/memory-page-A8CuwM8K.js","assets/settings-page-Dul6J7Ze.js","assets/architecture-page-C1BtszIY.js","assets/style-CUPaVTH9.js","assets/style-BZV40eAE.css","assets/database-page-nf0J0N1f.js","assets/hash-D9LrbLcr.js","assets/terminal-BeReSiBq.js","assets/experiments-page-VnavNQMR.js","assets/developer-page-C2fklkD5.js","assets/integrations-page-D4IP2asc.js"])))=>i.map(i=>d[i]); function Z0(i,o){for(var r=0;r f[d]})}}}return Object.freeze(Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}))}(function(){const o=document.createElement("link").relList;if(o&&o.supports&&o.supports("modulepreload"))return;for(const d of document.querySelectorAll('link[rel="modulepreload"]'))f(d);new MutationObserver(d=>{for(const m of d)if(m.type==="childList")for(const h of m.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&f(h)}).observe(document,{childList:!0,subtree:!0});function r(d){const m={};return d.integrity&&(m.integrity=d.integrity),d.referrerPolicy&&(m.referrerPolicy=d.referrerPolicy),d.crossOrigin==="use-credentials"?m.credentials="include":d.crossOrigin==="anonymous"?m.credentials="omit":m.credentials="same-origin",m}function f(d){if(d.ep)return;d.ep=!0;const m=r(d);fetch(d.href,m)}})();var A1=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function k0(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Qf={exports:{}},Zn={};var ym;function K0(){if(ym)return Zn;ym=1;var i=Symbol.for("react.transitional.element"),o=Symbol.for("react.fragment");function r(f,d,m){var h=null;if(m!==void 0&&(h=""+m),d.key!==void 0&&(h=""+d.key),"key"in d){m={};for(var E in d)E!=="key"&&(m[E]=d[E])}else m=d;return d=m.ref,{$$typeof:i,type:f,key:h,ref:d!==void 0?d:null,props:m}}return Zn.Fragment=o,Zn.jsx=r,Zn.jsxs=r,Zn}var vm;function J0(){return vm||(vm=1,Qf.exports=K0()),Qf.exports}var Y=J0(),Vf={exports:{}},at={};var gm;function $0(){if(gm)return at;gm=1;var i=Symbol.for("react.transitional.element"),o=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),f=Symbol.for("react.strict_mode"),d=Symbol.for("react.profiler"),m=Symbol.for("react.consumer"),h=Symbol.for("react.context"),E=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),M=Symbol.for("react.lazy"),T=Symbol.for("react.activity"),H=Symbol.iterator;function X(b){return b===null||typeof b!="object"?null:(b=H&&b[H]||b["@@iterator"],typeof b=="function"?b:null)}var W={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},G=Object.assign,q={};function J(b,N,j){this.props=b,this.context=N,this.refs=q,this.updater=j||W}J.prototype.isReactComponent={},J.prototype.setState=function(b,N){if(typeof b!="object"&&typeof b!="function"&&b!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,b,N,"setState")},J.prototype.forceUpdate=function(b){this.updater.enqueueForceUpdate(this,b,"forceUpdate")};function Q(){}Q.prototype=J.prototype;function F(b,N,j){this.props=b,this.context=N,this.refs=q,this.updater=j||W}var ht=F.prototype=new Q;ht.constructor=F,G(ht,J.prototype),ht.isPureReactComponent=!0;var mt=Array.isArray;function bt(){}var tt={H:null,A:null,T:null,S:null},Z=Object.prototype.hasOwnProperty;function _t(b,N,j){var L=j.ref;return{$$typeof:i,type:b,key:N,ref:L!==void 0?L:null,props:j}}function te(b,N){return _t(b.type,N,b.props)}function re(b){return typeof b=="object"&&b!==null&&b.$$typeof===i}function Gt(b){var N={"=":"=0",":":"=2"};return"$"+b.replace(/[=:]/g,function(j){return N[j]})}var qe=/\/+/g;function se(b,N){return typeof b=="object"&&b!==null&&b.key!=null?Gt(""+b.key):N.toString(36)}function Vt(b){switch(b.status){case"fulfilled":return b.value;case"rejected":throw b.reason;default:switch(typeof b.status=="string"?b.then(bt,bt):(b.status="pending",b.then(function(N){b.status==="pending"&&(b.status="fulfilled",b.value=N)},function(N){b.status==="pending"&&(b.status="rejected",b.reason=N)})),b.status){case"fulfilled":return b.value;case"rejected":throw b.reason}}throw b}function O(b,N,j,L,lt){var it=typeof b;(it==="undefined"||it==="boolean")&&(b=null);var et=!1;if(b===null)et=!0;else switch(it){case"bigint":case"string":case"number":et=!0;break;case"object":switch(b.$$typeof){case i:case o:et=!0;break;case M:return et=b._init,O(et(b._payload),N,j,L,lt)}}if(et)return lt=lt(b),et=L===""?"."+se(b,0):L,mt(lt)?(j="",et!=null&&(j=et.replace(qe,"$&/")+"/"),O(lt,N,j,"",function(Ye){return Ye})):lt!=null&&(re(lt)&&(lt=te(lt,j+(lt.key==null||b&&b.key===lt.key?"":(""+lt.key).replace(qe,"$&/")+"/")+et)),N.push(lt)),1;et=0;var Zt=L===""?".":L+":";if(mt(b))for(var Mt=0;Mt >>1,St=O[gt];if(0 >>1;gtd(j,w))L d(lt,j)?(O[gt]=lt,O[L]=w,gt=L):(O[gt]=j,O[N]=w,gt=N);else if(L d(lt,w))O[gt]=lt,O[L]=w,gt=L;else break t}}return B}function d(O,B){var w=O.sortIndex-B.sortIndex;return w!==0?w:O.id-B.id}if(i.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var m=performance;i.unstable_now=function(){return m.now()}}else{var h=Date,E=h.now();i.unstable_now=function(){return h.now()-E}}var g=[],y=[],M=1,T=null,H=3,X=!1,W=!1,G=!1,q=!1,J=typeof setTimeout=="function"?setTimeout:null,Q=typeof clearTimeout=="function"?clearTimeout:null,F=typeof setImmediate<"u"?setImmediate:null;function ht(O){for(var B=r(y);B!==null;){if(B.callback===null)f(y);else if(B.startTime<=O)f(y),B.sortIndex=B.expirationTime,o(g,B);else break;B=r(y)}}function mt(O){if(G=!1,ht(O),!W)if(r(g)!==null)W=!0,bt||(bt=!0,Gt());else{var B=r(y);B!==null&&Vt(mt,B.startTime-O)}}var bt=!1,tt=-1,Z=5,_t=-1;function te(){return q?!0:!(i.unstable_now()-_t O&&te());){var gt=T.callback;if(typeof gt=="function"){T.callback=null,H=T.priorityLevel;var St=gt(T.expirationTime<=O);if(O=i.unstable_now(),typeof St=="function"){T.callback=St,ht(O),B=!0;break e}T===r(g)&&f(g),ht(O)}else f(g);T=r(g)}if(T!==null)B=!0;else{var b=r(y);b!==null&&Vt(mt,b.startTime-O),B=!1}}break t}finally{T=null,H=w,X=!1}B=void 0}}finally{B?Gt():bt=!1}}}var Gt;if(typeof F=="function")Gt=function(){F(re)};else if(typeof MessageChannel<"u"){var qe=new MessageChannel,se=qe.port2;qe.port1.onmessage=re,Gt=function(){se.postMessage(null)}}else Gt=function(){J(re,0)};function Vt(O,B){tt=J(function(){O(i.unstable_now())},B)}i.unstable_IdlePriority=5,i.unstable_ImmediatePriority=1,i.unstable_LowPriority=4,i.unstable_NormalPriority=3,i.unstable_Profiling=null,i.unstable_UserBlockingPriority=2,i.unstable_cancelCallback=function(O){O.callback=null},i.unstable_forceFrameRate=function(O){0>O||125 gt?(O.sortIndex=w,o(y,O),r(g)===null&&O===r(y)&&(G?(Q(tt),tt=-1):G=!0,Vt(mt,w-gt))):(O.sortIndex=St,o(g,O),W||X||(W=!0,bt||(bt=!0,Gt()))),O},i.unstable_shouldYield=te,i.unstable_wrapCallback=function(O){var B=H;return function(){var w=H;H=B;try{return O.apply(this,arguments)}finally{H=w}}}})(Kf)),Kf}var Sm;function P0(){return Sm||(Sm=1,kf.exports=F0()),kf.exports}var Jf={exports:{}},It={};var Em;function I0(){if(Em)return It;Em=1;var i=no();function o(g){var y="https://react.dev/errors/"+g;if(1 "u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(o){console.error(o)}}return i(),Jf.exports=I0(),Jf.exports}var zm;function ev(){if(zm)return kn;zm=1;var i=P0(),o=no(),r=tv();function f(t){var e="https://react.dev/errors/"+t;if(1 St||(t.current=gt[St],gt[St]=null,St--)}function j(t,e){St++,gt[St]=t.current,t.current=e}var L=b(null),lt=b(null),it=b(null),et=b(null);function Zt(t,e){switch(j(it,e),j(lt,t),j(L,null),e.nodeType){case 9:case 11:t=(t=e.documentElement)&&(t=t.namespaceURI)?Ld(t):0;break;default:if(t=e.tagName,e=e.namespaceURI)e=Ld(e),t=qd(e,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}N(L),j(L,t)}function Mt(){N(L),N(lt),N(it)}function Ye(t){t.memoizedState!==null&&j(et,t);var e=L.current,l=qd(e,t.type);e!==l&&(j(lt,t),j(L,l))}function hl(t){lt.current===t&&(N(L),N(lt)),et.current===t&&(N(et),Gn._currentValue=w)}var yl,ho;function Vl(t){if(yl===void 0)try{throw Error()}catch(l){var e=l.stack.trim().match(/\n( *(at )?)/);yl=e&&e[1]||"",ho=-1 )":-1 >>=0,t===0?32:31-(Oh(t)/Ch|0)|0}var tu=256,eu=262144,lu=4194304;function Zl(t){var e=t&42;if(e!==0)return e;switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return t&261888;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function au(t,e,l){var a=t.pendingLanes;if(a===0)return 0;var n=0,u=t.suspendedLanes,c=t.pingedLanes;t=t.warmLanes;var s=a&134217727;return s!==0?(a=s&~u,a!==0?n=Zl(a):(c&=s,c!==0?n=Zl(c):l||(l=s&~t,l!==0&&(n=Zl(l))))):(s=a&~u,s!==0?n=Zl(s):c!==0?n=Zl(c):l||(l=a&~t,l!==0&&(n=Zl(l)))),n===0?0:e!==0&&e!==n&&(e&u)===0&&(u=n&-n,l=e&-e,u>=l||u===32&&(l&4194048)!==0)?e:n}function Ia(t,e){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&e)===0}function Nh(t,e){switch(t){case 1:case 2:case 4:case 8:case 64:return e+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function bo(){var t=lu;return lu<<=1,(lu&62914560)===0&&(lu=4194304),t}function Ci(t){for(var e=[],l=0;31>l;l++)e.push(t);return e}function tn(t,e){t.pendingLanes|=e,e!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function Uh(t,e,l,a,n,u){var c=t.pendingLanes;t.pendingLanes=l,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=l,t.entangledLanes&=l,t.errorRecoveryDisabledLanes&=l,t.shellSuspendCounter=0;var s=t.entanglements,v=t.expirationTimes,z=t.hiddenUpdates;for(l=c&~l;0 "u")return null;try{return t.activeElement||t.body}catch{return t.body}}var qh=/[\n"\\]/g;function Te(t){return t.replace(qh,function(e){return"\\"+e.charCodeAt(0).toString(16)+" "})}function ji(t,e,l,a,n,u,c,s){t.name="",c!=null&&typeof c!="function"&&typeof c!="symbol"&&typeof c!="boolean"?t.type=c:t.removeAttribute("type"),e!=null?c==="number"?(e===0&&t.value===""||t.value!=e)&&(t.value=""+ze(e)):t.value!==""+ze(e)&&(t.value=""+ze(e)):c!=="submit"&&c!=="reset"||t.removeAttribute("value"),e!=null?Bi(t,c,ze(e)):l!=null?Bi(t,c,ze(l)):a!=null&&t.removeAttribute("value"),n==null&&u!=null&&(t.defaultChecked=!!u),n!=null&&(t.checked=n&&typeof n!="function"&&typeof n!="symbol"),s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"?t.name=""+ze(s):t.removeAttribute("name")}function No(t,e,l,a,n,u,c,s){if(u!=null&&typeof u!="function"&&typeof u!="symbol"&&typeof u!="boolean"&&(t.type=u),e!=null||l!=null){if(!(u!=="submit"&&u!=="reset"||e!=null)){Hi(t);return}l=l!=null?""+ze(l):"",e=e!=null?""+ze(e):l,s||e===t.value||(t.value=e),t.defaultValue=e}a=a??n,a=typeof a!="function"&&typeof a!="symbol"&&!!a,t.checked=s?t.checked:!!a,t.defaultChecked=!!a,c!=null&&typeof c!="function"&&typeof c!="symbol"&&typeof c!="boolean"&&(t.name=c),Hi(t)}function Bi(t,e,l){e==="number"&&iu(t.ownerDocument)===t||t.defaultValue===""+l||(t.defaultValue=""+l)}function va(t,e,l,a){if(t=t.options,e){e={};for(var n=0;n "u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Xi=!1;if(Je)try{var nn={};Object.defineProperty(nn,"passive",{get:function(){Xi=!0}}),window.addEventListener("test",nn,nn),window.removeEventListener("test",nn,nn)}catch{Xi=!1}var pl=null,Qi=null,fu=null;function qo(){if(fu)return fu;var t,e=Qi,l=e.length,a,n="value"in pl?pl.value:pl.textContent,u=n.length;for(t=0;t =fn),Zo=" ",ko=!1;function Ko(t,e){switch(t){case"keyup":return my.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Jo(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Sa=!1;function yy(t,e){switch(t){case"compositionend":return Jo(e);case"keypress":return e.which!==32?null:(ko=!0,Zo);case"textInput":return t=e.data,t===Zo&&ko?null:t;default:return null}}function vy(t,e){if(Sa)return t==="compositionend"||!Ji&&Ko(t,e)?(t=qo(),fu=Qi=pl=null,Sa=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1 =e)return{node:l,offset:e-t};t=a}t:{for(;l;){if(l.nextSibling){l=l.nextSibling;break t}l=l.parentNode}l=void 0}l=lr(l)}}function nr(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?nr(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function ur(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var e=iu(t.document);e instanceof t.HTMLIFrameElement;){try{var l=typeof e.contentWindow.location.href=="string"}catch{l=!1}if(l)t=e.contentWindow;else break;e=iu(t.document)}return e}function Fi(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}var Ty=Je&&"documentMode"in document&&11>=document.documentMode,Ea=null,Pi=null,dn=null,Ii=!1;function ir(t,e,l){var a=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Ii||Ea==null||Ea!==iu(a)||(a=Ea,"selectionStart"in a&&Fi(a)?a={start:a.selectionStart,end:a.selectionEnd}:(a=(a.ownerDocument&&a.ownerDocument.defaultView||window).getSelection(),a={anchorNode:a.anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset}),dn&&sn(dn,a)||(dn=a,a=ei(Pi,"onSelect"),0 >=c,n-=c,Ge=1<<32-he(e)+n|l< ut?(st=$,$=null):st=$.sibling;var vt=A(S,$,x[ut],D);if(vt===null){$===null&&($=st);break}t&&$&&vt.alternate===null&&e(S,$),p=u(vt,p,ut),yt===null?P=vt:yt.sibling=vt,yt=vt,$=st}if(ut===x.length)return l(S,$),dt&&We(S,ut),P;if($===null){for(;ut ut?(st=$,$=null):st=$.sibling;var Yl=A(S,$,vt.value,D);if(Yl===null){$===null&&($=st);break}t&&$&&Yl.alternate===null&&e(S,$),p=u(Yl,p,ut),yt===null?P=Yl:yt.sibling=Yl,yt=Yl,$=st}if(vt.done)return l(S,$),dt&&We(S,ut),P;if($===null){for(;!vt.done;ut++,vt=x.next())vt=U(S,vt.value,D),vt!==null&&(p=u(vt,p,ut),yt===null?P=vt:yt.sibling=vt,yt=vt);return dt&&We(S,ut),P}for($=a($);!vt.done;ut++,vt=x.next())vt=R($,S,ut,vt.value,D),vt!==null&&(t&&vt.alternate!==null&&$.delete(vt.key===null?ut:vt.key),p=u(vt,p,ut),yt===null?P=vt:yt.sibling=vt,yt=vt);return t&&$.forEach(function(V0){return e(S,V0)}),dt&&We(S,ut),P}function At(S,p,x,D){if(typeof x=="object"&&x!==null&&x.type===G&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case X:t:{for(var P=x.key;p!==null;){if(p.key===P){if(P=x.type,P===G){if(p.tag===7){l(S,p.sibling),D=n(p,x.props.children),D.return=S,S=D;break t}}else if(p.elementType===P||typeof P=="object"&&P!==null&&P.$$typeof===Z&&la(P)===p.type){l(S,p.sibling),D=n(p,x.props),pn(D,x),D.return=S,S=D;break t}l(S,p);break}else e(S,p);p=p.sibling}x.type===G?(D=Fl(x.props.children,S.mode,D,x.key),D.return=S,S=D):(D=pu(x.type,x.key,x.props,null,S.mode,D),pn(D,x),D.return=S,S=D)}return c(S);case W:t:{for(P=x.key;p!==null;){if(p.key===P)if(p.tag===4&&p.stateNode.containerInfo===x.containerInfo&&p.stateNode.implementation===x.implementation){l(S,p.sibling),D=n(p,x.children||[]),D.return=S,S=D;break t}else{l(S,p);break}else e(S,p);p=p.sibling}D=ic(x,S.mode,D),D.return=S,S=D}return c(S);case Z:return x=la(x),At(S,p,x,D)}if(Vt(x))return V(S,p,x,D);if(Gt(x)){if(P=Gt(x),typeof P!="function")throw Error(f(150));return x=P.call(x),I(S,p,x,D)}if(typeof x.then=="function")return At(S,p,Au(x),D);if(x.$$typeof===F)return At(S,p,Eu(S,x),D);_u(S,x)}return typeof x=="string"&&x!==""||typeof x=="number"||typeof x=="bigint"?(x=""+x,p!==null&&p.tag===6?(l(S,p.sibling),D=n(p,x),D.return=S,S=D):(l(S,p),D=uc(x,S.mode,D),D.return=S,S=D),c(S)):l(S,p)}return function(S,p,x,D){try{gn=0;var P=At(S,p,x,D);return Na=null,P}catch($){if($===Da||$===zu)throw $;var yt=ve(29,$,null,S.mode);return yt.lanes=D,yt.return=S,yt}}}var na=Or(!0),Cr=Or(!1),zl=!1;function pc(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function bc(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function Tl(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function Al(t,e,l){var a=t.updateQueue;if(a===null)return null;if(a=a.shared,(pt&2)!==0){var n=a.pending;return n===null?e.next=e:(e.next=n.next,n.next=e),a.pending=e,e=gu(t),mr(t,null,l),e}return vu(t,a,e,l),gu(t)}function bn(t,e,l){if(e=e.updateQueue,e!==null&&(e=e.shared,(l&4194048)!==0)){var a=e.lanes;a&=t.pendingLanes,l|=a,e.lanes=l,Eo(t,l)}}function Sc(t,e){var l=t.updateQueue,a=t.alternate;if(a!==null&&(a=a.updateQueue,l===a)){var n=null,u=null;if(l=l.firstBaseUpdate,l!==null){do{var c={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};u===null?n=u=c:u=u.next=c,l=l.next}while(l!==null);u===null?n=u=e:u=u.next=e}else n=u=e;l={baseState:a.baseState,firstBaseUpdate:n,lastBaseUpdate:u,shared:a.shared,callbacks:a.callbacks},t.updateQueue=l;return}t=l.lastBaseUpdate,t===null?l.firstBaseUpdate=e:t.next=e,l.lastBaseUpdate=e}var Ec=!1;function Sn(){if(Ec){var t=Ca;if(t!==null)throw t}}function En(t,e,l,a){Ec=!1;var n=t.updateQueue;zl=!1;var u=n.firstBaseUpdate,c=n.lastBaseUpdate,s=n.shared.pending;if(s!==null){n.shared.pending=null;var v=s,z=v.next;v.next=null,c===null?u=z:c.next=z,c=v;var C=t.alternate;C!==null&&(C=C.updateQueue,s=C.lastBaseUpdate,s!==c&&(s===null?C.firstBaseUpdate=z:s.next=z,C.lastBaseUpdate=v))}if(u!==null){var U=n.baseState;c=0,C=z=v=null,s=u;do{var A=s.lane&-536870913,R=A!==s.lane;if(R?(rt&A)===A:(a&A)===A){A!==0&&A===Oa&&(Ec=!0),C!==null&&(C=C.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});t:{var V=t,I=s;A=e;var At=l;switch(I.tag){case 1:if(V=I.payload,typeof V=="function"){U=V.call(At,U,A);break t}U=V;break t;case 3:V.flags=V.flags&-65537|128;case 0:if(V=I.payload,A=typeof V=="function"?V.call(At,U,A):V,A==null)break t;U=T({},U,A);break t;case 2:zl=!0}}A=s.callback,A!==null&&(t.flags|=64,R&&(t.flags|=8192),R=n.callbacks,R===null?n.callbacks=[A]:R.push(A))}else R={lane:A,tag:s.tag,payload:s.payload,callback:s.callback,next:null},C===null?(z=C=R,v=U):C=C.next=R,c|=A;if(s=s.next,s===null){if(s=n.shared.pending,s===null)break;R=s,s=R.next,R.next=null,n.lastBaseUpdate=R,n.shared.pending=null}}while(!0);C===null&&(v=U),n.baseState=v,n.firstBaseUpdate=z,n.lastBaseUpdate=C,u===null&&(n.shared.lanes=0),Cl|=c,t.lanes=c,t.memoizedState=U}}function Dr(t,e){if(typeof t!="function")throw Error(f(191,t));t.call(e)}function Nr(t,e){var l=t.callbacks;if(l!==null)for(t.callbacks=null,t=0;t u?u:8;var c=O.T,s={};O.T=s,Yc(t,!1,e,l);try{var v=n(),z=O.S;if(z!==null&&z(s,v),v!==null&&typeof v=="object"&&typeof v.then=="function"){var C=Uy(v,a);Tn(t,e,C,Ee(t))}else Tn(t,e,a,Ee(t))}catch(U){Tn(t,e,{then:function(){},status:"rejected",reason:U},Ee())}finally{B.p=u,c!==null&&s.types!==null&&(c.types=s.types),O.T=c}}function qy(){}function Lc(t,e,l,a){if(t.tag!==5)throw Error(f(476));var n=rs(t).queue;os(t,n,e,w,l===null?qy:function(){return ss(t),l(a)})}function rs(t){var e=t.memoizedState;if(e!==null)return e;e={memoizedState:w,baseState:w,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:tl,lastRenderedState:w},next:null};var l={};return e.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:tl,lastRenderedState:l},next:null},t.memoizedState=e,t=t.alternate,t!==null&&(t.memoizedState=e),e}function ss(t){var e=rs(t);e.next===null&&(e=t.alternate.memoizedState),Tn(t,e.next.queue,{},Ee())}function qc(){return Wt(Gn)}function ds(){return jt().memoizedState}function ms(){return jt().memoizedState}function Yy(t){for(var e=t.return;e!==null;){switch(e.tag){case 24:case 3:var l=Ee();t=Tl(l);var a=Al(e,t,l);a!==null&&(fe(a,e,l),bn(a,e,l)),e={cache:hc()},t.payload=e;return}e=e.return}}function Gy(t,e,l){var a=Ee();l={lane:a,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},ju(t)?ys(e,l):(l=ac(t,e,l,a),l!==null&&(fe(l,t,a),vs(l,e,a)))}function hs(t,e,l){var a=Ee();Tn(t,e,l,a)}function Tn(t,e,l,a){var n={lane:a,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(ju(t))ys(e,n);else{var u=t.alternate;if(t.lanes===0&&(u===null||u.lanes===0)&&(u=e.lastRenderedReducer,u!==null))try{var c=e.lastRenderedState,s=u(c,l);if(n.hasEagerState=!0,n.eagerState=s,ye(s,c))return vu(t,e,n,0),Rt===null&&yu(),!1}catch{}if(l=ac(t,e,n,a),l!==null)return fe(l,t,a),vs(l,e,a),!0}return!1}function Yc(t,e,l,a){if(a={lane:2,revertLane:bf(),gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},ju(t)){if(e)throw Error(f(479))}else e=ac(t,l,a,2),e!==null&&fe(e,t,2)}function ju(t){var e=t.alternate;return t===nt||e!==null&&e===nt}function ys(t,e){wa=Ou=!0;var l=t.pending;l===null?e.next=e:(e.next=l.next,l.next=e),t.pending=e}function vs(t,e,l){if((l&4194048)!==0){var a=e.lanes;a&=t.pendingLanes,l|=a,e.lanes=l,Eo(t,l)}}var An={readContext:Wt,use:Nu,useCallback:Ut,useContext:Ut,useEffect:Ut,useImperativeHandle:Ut,useLayoutEffect:Ut,useInsertionEffect:Ut,useMemo:Ut,useReducer:Ut,useRef:Ut,useState:Ut,useDebugValue:Ut,useDeferredValue:Ut,useTransition:Ut,useSyncExternalStore:Ut,useId:Ut,useHostTransitionStatus:Ut,useFormState:Ut,useActionState:Ut,useOptimistic:Ut,useMemoCache:Ut,useCacheRefresh:Ut};An.useEffectEvent=Ut;var gs={readContext:Wt,use:Nu,useCallback:function(t,e){return ee().memoizedState=[t,e===void 0?null:e],t},useContext:Wt,useEffect:ts,useImperativeHandle:function(t,e,l){l=l!=null?l.concat([t]):null,wu(4194308,4,ns.bind(null,e,t),l)},useLayoutEffect:function(t,e){return wu(4194308,4,t,e)},useInsertionEffect:function(t,e){wu(4,2,t,e)},useMemo:function(t,e){var l=ee();e=e===void 0?null:e;var a=t();if(ua){vl(!0);try{t()}finally{vl(!1)}}return l.memoizedState=[a,e],a},useReducer:function(t,e,l){var a=ee();if(l!==void 0){var n=l(e);if(ua){vl(!0);try{l(e)}finally{vl(!1)}}}else n=e;return a.memoizedState=a.baseState=n,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:n},a.queue=t,t=t.dispatch=Gy.bind(null,nt,t),[a.memoizedState,t]},useRef:function(t){var e=ee();return t={current:t},e.memoizedState=t},useState:function(t){t=Uc(t);var e=t.queue,l=hs.bind(null,nt,e);return e.dispatch=l,[t.memoizedState,l]},useDebugValue:jc,useDeferredValue:function(t,e){var l=ee();return Bc(l,t,e)},useTransition:function(){var t=Uc(!1);return t=os.bind(null,nt,t.queue,!0,!1),ee().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,e,l){var a=nt,n=ee();if(dt){if(l===void 0)throw Error(f(407));l=l()}else{if(l=e(),Rt===null)throw Error(f(349));(rt&127)!==0||Lr(a,e,l)}n.memoizedState=l;var u={value:l,getSnapshot:e};return n.queue=u,ts(Yr.bind(null,a,u,t),[t]),a.flags|=2048,ja(9,{destroy:void 0},qr.bind(null,a,u,l,e),null),l},useId:function(){var t=ee(),e=Rt.identifierPrefix;if(dt){var l=Xe,a=Ge;l=(a&~(1<<32-he(a)-1)).toString(32)+l,e="_"+e+"R_"+l,l=Cu++,0 <\/script>",u=u.removeChild(u.firstChild);break;case"select":u=typeof a.is=="string"?c.createElement("select",{is:a.is}):c.createElement("select"),a.multiple?u.multiple=!0:a.size&&(u.size=a.size);break;default:u=typeof a.is=="string"?c.createElement(n,{is:a.is}):c.createElement(n)}}u[Jt]=e,u[le]=a;t:for(c=e.child;c!==null;){if(c.tag===5||c.tag===6)u.appendChild(c.stateNode);else if(c.tag!==4&&c.tag!==27&&c.child!==null){c.child.return=c,c=c.child;continue}if(c===e)break t;for(;c.sibling===null;){if(c.return===null||c.return===e)break t;c=c.return}c.sibling.return=c.return,c=c.sibling}e.stateNode=u;t:switch(Pt(u,n,a),n){case"button":case"input":case"select":case"textarea":a=!!a.autoFocus;break t;case"img":a=!0;break t;default:a=!1}a&&ll(e)}}return Ct(e),tf(e,e.type,t===null?null:t.memoizedProps,e.pendingProps,l),null;case 6:if(t&&e.stateNode!=null)t.memoizedProps!==a&&ll(e);else{if(typeof a!="string"&&e.stateNode===null)throw Error(f(166));if(t=it.current,Ra(e)){if(t=e.stateNode,l=e.memoizedProps,a=null,n=$t,n!==null)switch(n.tag){case 27:case 5:a=n.memoizedProps}t[Jt]=e,t=!!(t.nodeValue===l||a!==null&&a.suppressHydrationWarning===!0||jd(t.nodeValue,l)),t||El(e,!0)}else t=li(t).createTextNode(a),t[Jt]=e,e.stateNode=t}return Ct(e),null;case 31:if(l=e.memoizedState,t===null||t.memoizedState!==null){if(a=Ra(e),l!==null){if(t===null){if(!a)throw Error(f(318));if(t=e.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(f(557));t[Jt]=e}else Pl(),(e.flags&128)===0&&(e.memoizedState=null),e.flags|=4;Ct(e),t=!1}else l=rc(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=l),t=!0;if(!t)return e.flags&256?(pe(e),e):(pe(e),null);if((e.flags&128)!==0)throw Error(f(558))}return Ct(e),null;case 13:if(a=e.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(n=Ra(e),a!==null&&a.dehydrated!==null){if(t===null){if(!n)throw Error(f(318));if(n=e.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(f(317));n[Jt]=e}else Pl(),(e.flags&128)===0&&(e.memoizedState=null),e.flags|=4;Ct(e),n=!1}else n=rc(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=n),n=!0;if(!n)return e.flags&256?(pe(e),e):(pe(e),null)}return pe(e),(e.flags&128)!==0?(e.lanes=l,e):(l=a!==null,t=t!==null&&t.memoizedState!==null,l&&(a=e.child,n=null,a.alternate!==null&&a.alternate.memoizedState!==null&&a.alternate.memoizedState.cachePool!==null&&(n=a.alternate.memoizedState.cachePool.pool),u=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(u=a.memoizedState.cachePool.pool),u!==n&&(a.flags|=2048)),l!==t&&l&&(e.child.flags|=8192),Gu(e,e.updateQueue),Ct(e),null);case 4:return Mt(),t===null&&zf(e.stateNode.containerInfo),Ct(e),null;case 10:return Pe(e.type),Ct(e),null;case 19:if(N(Ht),a=e.memoizedState,a===null)return Ct(e),null;if(n=(e.flags&128)!==0,u=a.rendering,u===null)if(n)Rn(a,!1);else{if(wt!==0||t!==null&&(t.flags&128)!==0)for(t=e.child;t!==null;){if(u=Mu(t),u!==null){for(e.flags|=128,Rn(a,!1),t=u.updateQueue,e.updateQueue=t,Gu(e,t),e.subtreeFlags=0,t=l,l=e.child;l!==null;)hr(l,t),l=l.sibling;return j(Ht,Ht.current&1|2),dt&&We(e,a.treeForkCount),e.child}t=t.sibling}a.tail!==null&&de()>ku&&(e.flags|=128,n=!0,Rn(a,!1),e.lanes=4194304)}else{if(!n)if(t=Mu(u),t!==null){if(e.flags|=128,n=!0,t=t.updateQueue,e.updateQueue=t,Gu(e,t),Rn(a,!0),a.tail===null&&a.tailMode==="hidden"&&!u.alternate&&!dt)return Ct(e),null}else 2*de()-a.renderingStartTime>ku&&l!==536870912&&(e.flags|=128,n=!0,Rn(a,!1),e.lanes=4194304);a.isBackwards?(u.sibling=e.child,e.child=u):(t=a.last,t!==null?t.sibling=u:e.child=u,a.last=u)}return a.tail!==null?(t=a.tail,a.rendering=t,a.tail=t.sibling,a.renderingStartTime=de(),t.sibling=null,l=Ht.current,j(Ht,n?l&1|2:l&1),dt&&We(e,a.treeForkCount),t):(Ct(e),null);case 22:case 23:return pe(e),zc(),a=e.memoizedState!==null,t!==null?t.memoizedState!==null!==a&&(e.flags|=8192):a&&(e.flags|=8192),a?(l&536870912)!==0&&(e.flags&128)===0&&(Ct(e),e.subtreeFlags&6&&(e.flags|=8192)):Ct(e),l=e.updateQueue,l!==null&&Gu(e,l.retryQueue),l=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(l=t.memoizedState.cachePool.pool),a=null,e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),a!==l&&(e.flags|=2048),t!==null&&N(ea),null;case 24:return l=null,t!==null&&(l=t.memoizedState.cache),e.memoizedState.cache!==l&&(e.flags|=2048),Pe(Bt),Ct(e),null;case 25:return null;case 30:return null}throw Error(f(156,e.tag))}function ky(t,e){switch(fc(e),e.tag){case 1:return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Pe(Bt),Mt(),t=e.flags,(t&65536)!==0&&(t&128)===0?(e.flags=t&-65537|128,e):null;case 26:case 27:case 5:return hl(e),null;case 31:if(e.memoizedState!==null){if(pe(e),e.alternate===null)throw Error(f(340));Pl()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 13:if(pe(e),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(f(340));Pl()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return N(Ht),null;case 4:return Mt(),null;case 10:return Pe(e.type),null;case 22:case 23:return pe(e),zc(),t!==null&&N(ea),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 24:return Pe(Bt),null;case 25:return null;default:return null}}function Gs(t,e){switch(fc(e),e.tag){case 3:Pe(Bt),Mt();break;case 26:case 27:case 5:hl(e);break;case 4:Mt();break;case 31:e.memoizedState!==null&&pe(e);break;case 13:pe(e);break;case 19:N(Ht);break;case 10:Pe(e.type);break;case 22:case 23:pe(e),zc(),t!==null&&N(ea);break;case 24:Pe(Bt)}}function Mn(t,e){try{var l=e.updateQueue,a=l!==null?l.lastEffect:null;if(a!==null){var n=a.next;l=n;do{if((l.tag&t)===t){a=void 0;var u=l.create,c=l.inst;a=u(),c.destroy=a}l=l.next}while(l!==n)}}catch(s){xt(e,e.return,s)}}function Ml(t,e,l){try{var a=e.updateQueue,n=a!==null?a.lastEffect:null;if(n!==null){var u=n.next;a=u;do{if((a.tag&t)===t){var c=a.inst,s=c.destroy;if(s!==void 0){c.destroy=void 0,n=e;var v=l,z=s;try{z()}catch(C){xt(n,v,C)}}}a=a.next}while(a!==u)}}catch(C){xt(e,e.return,C)}}function Xs(t){var e=t.updateQueue;if(e!==null){var l=t.stateNode;try{Nr(e,l)}catch(a){xt(t,t.return,a)}}}function Qs(t,e,l){l.props=ia(t.type,t.memoizedProps),l.state=t.memoizedState;try{l.componentWillUnmount()}catch(a){xt(t,e,a)}}function On(t,e){try{var l=t.ref;if(l!==null){switch(t.tag){case 26:case 27:case 5:var a=t.stateNode;break;case 30:a=t.stateNode;break;default:a=t.stateNode}typeof l=="function"?t.refCleanup=l(a):l.current=a}}catch(n){xt(t,e,n)}}function Qe(t,e){var l=t.ref,a=t.refCleanup;if(l!==null)if(typeof a=="function")try{a()}catch(n){xt(t,e,n)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(n){xt(t,e,n)}else l.current=null}function Vs(t){var e=t.type,l=t.memoizedProps,a=t.stateNode;try{t:switch(e){case"button":case"input":case"select":case"textarea":l.autoFocus&&a.focus();break t;case"img":l.src?a.src=l.src:l.srcSet&&(a.srcset=l.srcSet)}}catch(n){xt(t,t.return,n)}}function ef(t,e,l){try{var a=t.stateNode;h0(a,t.type,l,e),a[le]=e}catch(n){xt(t,t.return,n)}}function Zs(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&Hl(t.type)||t.tag===4}function lf(t){t:for(;;){for(;t.sibling===null;){if(t.return===null||Zs(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.tag===27&&Hl(t.type)||t.flags&2||t.child===null||t.tag===4)continue t;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function af(t,e,l){var a=t.tag;if(a===5||a===6)t=t.stateNode,e?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(t,e):(e=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,e.appendChild(t),l=l._reactRootContainer,l!=null||e.onclick!==null||(e.onclick=Ke));else if(a!==4&&(a===27&&Hl(t.type)&&(l=t.stateNode,e=null),t=t.child,t!==null))for(af(t,e,l),t=t.sibling;t!==null;)af(t,e,l),t=t.sibling}function Xu(t,e,l){var a=t.tag;if(a===5||a===6)t=t.stateNode,e?l.insertBefore(t,e):l.appendChild(t);else if(a!==4&&(a===27&&Hl(t.type)&&(l=t.stateNode),t=t.child,t!==null))for(Xu(t,e,l),t=t.sibling;t!==null;)Xu(t,e,l),t=t.sibling}function ks(t){var e=t.stateNode,l=t.memoizedProps;try{for(var a=t.type,n=e.attributes;n.length;)e.removeAttributeNode(n[0]);Pt(e,a,l),e[Jt]=t,e[le]=l}catch(u){xt(t,t.return,u)}}var al=!1,Yt=!1,nf=!1,Ks=typeof WeakSet=="function"?WeakSet:Set,Kt=null;function Ky(t,e){if(t=t.containerInfo,_f=oi,t=ur(t),Fi(t)){if("selectionStart"in t)var l={start:t.selectionStart,end:t.selectionEnd};else t:{l=(l=t.ownerDocument)&&l.defaultView||window;var a=l.getSelection&&l.getSelection();if(a&&a.rangeCount!==0){l=a.anchorNode;var n=a.anchorOffset,u=a.focusNode;a=a.focusOffset;try{l.nodeType,u.nodeType}catch{l=null;break t}var c=0,s=-1,v=-1,z=0,C=0,U=t,A=null;e:for(;;){for(var R;U!==l||n!==0&&U.nodeType!==3||(s=c+n),U!==u||a!==0&&U.nodeType!==3||(v=c+a),U.nodeType===3&&(c+=U.nodeValue.length),(R=U.firstChild)!==null;)A=U,U=R;for(;;){if(U===t)break e;if(A===l&&++z===n&&(s=c),A===u&&++C===a&&(v=c),(R=U.nextSibling)!==null)break;U=A,A=U.parentNode}U=R}l=s===-1||v===-1?null:{start:s,end:v}}else l=null}l=l||{start:0,end:0}}else l=null;for(Rf={focusedElem:t,selectionRange:l},oi=!1,Kt=e;Kt!==null;)if(e=Kt,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,Kt=t;else for(;Kt!==null;){switch(e=Kt,u=e.alternate,t=e.flags,e.tag){case 0:if((t&4)!==0&&(t=e.updateQueue,t=t!==null?t.events:null,t!==null))for(l=0;l title"))),Pt(u,a,l),u[Jt]=t,kt(u),a=u;break t;case"link":var c=Id("link","href",n).get(a+(l.href||""));if(c){for(var s=0;s At&&(c=At,At=I,I=c);var S=ar(s,I),p=ar(s,At);if(S&&p&&(R.rangeCount!==1||R.anchorNode!==S.node||R.anchorOffset!==S.offset||R.focusNode!==p.node||R.focusOffset!==p.offset)){var x=U.createRange();x.setStart(S.node,S.offset),R.removeAllRanges(),I>At?(R.addRange(x),R.extend(p.node,p.offset)):(x.setEnd(p.node,p.offset),R.addRange(x))}}}}for(U=[],R=s;R=R.parentNode;)R.nodeType===1&&U.push({element:R,left:R.scrollLeft,top:R.scrollTop});for(typeof s.focus=="function"&&s.focus(),s=0;s l?32:l,O.T=null,l=df,df=null;var u=Nl,c=fl;if(Xt=0,Ga=Nl=null,fl=0,(pt&6)!==0)throw Error(f(331));var s=pt;if(pt|=4,nd(u.current),ed(u,u.current,c,l),pt=s,Hn(0,!1),me&&typeof me.onPostCommitFiberRoot=="function")try{me.onPostCommitFiberRoot(Pa,u)}catch{}return!0}finally{B.p=n,O.T=a,xd(t,e)}}function Td(t,e,l){e=_e(l,e),e=Vc(t.stateNode,e,2),t=Al(t,e,2),t!==null&&(tn(t,2),Ve(t))}function xt(t,e,l){if(t.tag===3)Td(t,t,l);else for(;e!==null;){if(e.tag===3){Td(e,t,l);break}else if(e.tag===1){var a=e.stateNode;if(typeof e.type.getDerivedStateFromError=="function"||typeof a.componentDidCatch=="function"&&(Dl===null||!Dl.has(a))){t=_e(l,t),l=As(2),a=Al(e,l,2),a!==null&&(_s(l,a,e,t),tn(a,2),Ve(a));break}}e=e.return}}function vf(t,e,l){var a=t.pingCache;if(a===null){a=t.pingCache=new Wy;var n=new Set;a.set(e,n)}else n=a.get(e),n===void 0&&(n=new Set,a.set(e,n));n.has(l)||(ff=!0,n.add(l),t=e0.bind(null,t,e,l),e.then(t,t))}function e0(t,e,l){var a=t.pingCache;a!==null&&a.delete(e),t.pingedLanes|=t.suspendedLanes&l,t.warmLanes&=~l,Rt===t&&(rt&l)===l&&(wt===4||wt===3&&(rt&62914560)===rt&&300>de()-Zu?(pt&2)===0&&Xa(t,0):of|=l,Ya===rt&&(Ya=0)),Ve(t)}function Ad(t,e){e===0&&(e=bo()),t=Wl(t,e),t!==null&&(tn(t,e),Ve(t))}function l0(t){var e=t.memoizedState,l=0;e!==null&&(l=e.retryLane),Ad(t,l)}function a0(t,e){var l=0;switch(t.tag){case 31:case 13:var a=t.stateNode,n=t.memoizedState;n!==null&&(l=n.retryLane);break;case 19:a=t.stateNode;break;case 22:a=t.stateNode._retryCache;break;default:throw Error(f(314))}a!==null&&a.delete(e),Ad(t,l)}function n0(t,e){return Mi(t,e)}var Pu=null,Va=null,gf=!1,Iu=!1,pf=!1,wl=0;function Ve(t){t!==Va&&t.next===null&&(Va===null?Pu=Va=t:Va=Va.next=t),Iu=!0,gf||(gf=!0,i0())}function Hn(t,e){if(!pf&&Iu){pf=!0;do for(var l=!1,a=Pu;a!==null;){if(t!==0){var n=a.pendingLanes;if(n===0)var u=0;else{var c=a.suspendedLanes,s=a.pingedLanes;u=(1<<31-he(42|t)+1)-1,u&=n&~(c&~s),u=u&201326741?u&201326741|1:u?u|2:0}u!==0&&(l=!0,Od(a,u))}else u=rt,u=au(a,a===Rt?u:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),(u&3)===0||Ia(a,u)||(l=!0,Od(a,u));a=a.next}while(l);pf=!1}}function u0(){_d()}function _d(){Iu=gf=!1;var t=0;wl!==0&&v0()&&(t=wl);for(var e=de(),l=null,a=Pu;a!==null;){var n=a.next,u=Rd(a,e);u===0?(a.next=null,l===null?Pu=n:l.next=n,n===null&&(Va=l)):(l=a,(t!==0||(u&3)!==0)&&(Iu=!0)),a=n}Xt!==0&&Xt!==5||Hn(t),wl!==0&&(wl=0)}function Rd(t,e){for(var l=t.suspendedLanes,a=t.pingedLanes,n=t.expirationTimes,u=t.pendingLanes&-62914561;0s)break;var C=v.transferSize,U=v.initiatorType;C&&Bd(U)&&(v=v.responseEnd,c+=C*(v "u"?null:document;function $d(t,e,l){var a=Za;if(a&&typeof e=="string"&&e){var n=Te(e);n='link[rel="'+t+'"][href="'+n+'"]',typeof l=="string"&&(n+='[crossorigin="'+l+'"]'),Jd.has(n)||(Jd.add(n),t={rel:t,crossOrigin:l,href:e},a.querySelector(n)===null&&(e=a.createElement("link"),Pt(e,"link",t),kt(e),a.head.appendChild(e)))}}function A0(t){ol.D(t),$d("dns-prefetch",t,null)}function _0(t,e){ol.C(t,e),$d("preconnect",t,e)}function R0(t,e,l){ol.L(t,e,l);var a=Za;if(a&&t&&e){var n='link[rel="preload"][as="'+Te(e)+'"]';e==="image"&&l&&l.imageSrcSet?(n+='[imagesrcset="'+Te(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(n+='[imagesizes="'+Te(l.imageSizes)+'"]')):n+='[href="'+Te(t)+'"]';var u=n;switch(e){case"style":u=ka(t);break;case"script":u=Ka(t)}Ne.has(u)||(t=T({rel:"preload",href:e==="image"&&l&&l.imageSrcSet?void 0:t,as:e},l),Ne.set(u,t),a.querySelector(n)!==null||e==="style"&&a.querySelector(qn(u))||e==="script"&&a.querySelector(Yn(u))||(e=a.createElement("link"),Pt(e,"link",t),kt(e),a.head.appendChild(e)))}}function M0(t,e){ol.m(t,e);var l=Za;if(l&&t){var a=e&&typeof e.as=="string"?e.as:"script",n='link[rel="modulepreload"][as="'+Te(a)+'"][href="'+Te(t)+'"]',u=n;switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":u=Ka(t)}if(!Ne.has(u)&&(t=T({rel:"modulepreload",href:t},e),Ne.set(u,t),l.querySelector(n)===null)){switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(Yn(u)))return}a=l.createElement("link"),Pt(a,"link",t),kt(a),l.head.appendChild(a)}}}function O0(t,e,l){ol.S(t,e,l);var a=Za;if(a&&t){var n=ha(a).hoistableStyles,u=ka(t);e=e||"default";var c=n.get(u);if(!c){var s={loading:0,preload:null};if(c=a.querySelector(qn(u)))s.loading=5;else{t=T({rel:"stylesheet",href:t,"data-precedence":e},l),(l=Ne.get(u))&&wf(t,l);var v=c=a.createElement("link");kt(v),Pt(v,"link",t),v._p=new Promise(function(z,C){v.onload=z,v.onerror=C}),v.addEventListener("load",function(){s.loading|=1}),v.addEventListener("error",function(){s.loading|=2}),s.loading|=4,ni(c,e,a)}c={type:"stylesheet",instance:c,count:1,state:s},n.set(u,c)}}}function C0(t,e){ol.X(t,e);var l=Za;if(l&&t){var a=ha(l).hoistableScripts,n=Ka(t),u=a.get(n);u||(u=l.querySelector(Yn(n)),u||(t=T({src:t,async:!0},e),(e=Ne.get(n))&&Hf(t,e),u=l.createElement("script"),kt(u),Pt(u,"link",t),l.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},a.set(n,u))}}function D0(t,e){ol.M(t,e);var l=Za;if(l&&t){var a=ha(l).hoistableScripts,n=Ka(t),u=a.get(n);u||(u=l.querySelector(Yn(n)),u||(t=T({src:t,async:!0,type:"module"},e),(e=Ne.get(n))&&Hf(t,e),u=l.createElement("script"),kt(u),Pt(u,"link",t),l.head.appendChild(u)),u={type:"script",instance:u,count:1,state:null},a.set(n,u))}}function Wd(t,e,l,a){var n=(n=it.current)?ai(n):null;if(!n)throw Error(f(446));switch(t){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(e=ka(l.href),l=ha(n).hoistableStyles,a=l.get(e),a||(a={type:"style",instance:null,count:0,state:null},l.set(e,a)),a):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){t=ka(l.href);var u=ha(n).hoistableStyles,c=u.get(t);if(c||(n=n.ownerDocument||n,c={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},u.set(t,c),(u=n.querySelector(qn(t)))&&!u._p&&(c.instance=u,c.state.loading=5),Ne.has(t)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},Ne.set(t,l),u||N0(n,t,l,c.state))),e&&a===null)throw Error(f(528,""));return c}if(e&&a!==null)throw Error(f(529,""));return null;case"script":return e=l.async,l=l.src,typeof l=="string"&&e&&typeof e!="function"&&typeof e!="symbol"?(e=Ka(l),l=ha(n).hoistableScripts,a=l.get(e),a||(a={type:"script",instance:null,count:0,state:null},l.set(e,a)),a):{type:"void",instance:null,count:0,state:null};default:throw Error(f(444,t))}}function ka(t){return'href="'+Te(t)+'"'}function qn(t){return'link[rel="stylesheet"]['+t+"]"}function Fd(t){return T({},t,{"data-precedence":t.precedence,precedence:null})}function N0(t,e,l,a){t.querySelector('link[rel="preload"][as="style"]['+e+"]")?a.loading=1:(e=t.createElement("link"),a.preload=e,e.addEventListener("load",function(){return a.loading|=1}),e.addEventListener("error",function(){return a.loading|=2}),Pt(e,"link",l),kt(e),t.head.appendChild(e))}function Ka(t){return'[src="'+Te(t)+'"]'}function Yn(t){return"script[async]"+t}function Pd(t,e,l){if(e.count++,e.instance===null)switch(e.type){case"style":var a=t.querySelector('style[data-href~="'+Te(l.href)+'"]');if(a)return e.instance=a,kt(a),a;var n=T({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return a=(t.ownerDocument||t).createElement("style"),kt(a),Pt(a,"style",n),ni(a,l.precedence,t),e.instance=a;case"stylesheet":n=ka(l.href);var u=t.querySelector(qn(n));if(u)return e.state.loading|=4,e.instance=u,kt(u),u;a=Fd(l),(n=Ne.get(n))&&wf(a,n),u=(t.ownerDocument||t).createElement("link"),kt(u);var c=u;return c._p=new Promise(function(s,v){c.onload=s,c.onerror=v}),Pt(u,"link",a),e.state.loading|=4,ni(u,l.precedence,t),e.instance=u;case"script":return u=Ka(l.src),(n=t.querySelector(Yn(u)))?(e.instance=n,kt(n),n):(a=l,(n=Ne.get(u))&&(a=T({},l),Hf(a,n)),t=t.ownerDocument||t,n=t.createElement("script"),kt(n),Pt(n,"link",a),t.head.appendChild(n),e.instance=n);case"void":return null;default:throw Error(f(443,e.type))}else e.type==="stylesheet"&&(e.state.loading&4)===0&&(a=e.instance,e.state.loading|=4,ni(a,l.precedence,t));return e.instance}function ni(t,e,l){for(var a=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),n=a.length?a[a.length-1]:null,u=n,c=0;ctitle"):null)}function U0(t,e,l){if(l===1||e.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof e.precedence!="string"||typeof e.href!="string"||e.href==="")break;return!0;case"link":if(typeof e.rel!="string"||typeof e.href!="string"||e.href===""||e.onLoad||e.onError)break;return e.rel==="stylesheet"?(t=e.disabled,typeof e.precedence=="string"&&t==null):!0;case"script":if(e.async&&typeof e.async!="function"&&typeof e.async!="symbol"&&!e.onLoad&&!e.onError&&e.src&&typeof e.src=="string")return!0}return!1}function em(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function w0(t,e,l,a){if(l.type==="stylesheet"&&(typeof a.media!="string"||matchMedia(a.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var n=ka(a.href),u=e.querySelector(qn(n));if(u){e=u._p,e!==null&&typeof e=="object"&&typeof e.then=="function"&&(t.count++,t=ii.bind(t),e.then(t,t)),l.state.loading|=4,l.instance=u,kt(u);return}u=e.ownerDocument||e,a=Fd(a),(n=Ne.get(n))&&wf(a,n),u=u.createElement("link"),kt(u);var c=u;c._p=new Promise(function(s,v){c.onload=s,c.onerror=v}),Pt(u,"link",a),l.instance=u}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(l,e),(e=l.state.preload)&&(l.state.loading&3)===0&&(t.count++,l=ii.bind(t),e.addEventListener("load",l),e.addEventListener("error",l))}}var jf=0;function H0(t,e){return t.stylesheets&&t.count===0&&fi(t,t.stylesheets),0 jf?50:800)+e);return t.unsuspend=l,function(){t.unsuspend=null,clearTimeout(a),clearTimeout(n)}}:null}function ii(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)fi(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var ci=null;function fi(t,e){t.stylesheets=null,t.unsuspend!==null&&(t.count++,ci=new Map,e.forEach(j0,t),ci=null,ii.call(t))}function j0(t,e){if(!(e.state.loading&4)){var l=ci.get(t);if(l)var a=l.get(null);else{l=new Map,ci.set(t,l);for(var n=t.querySelectorAll("link[data-precedence],style[data-precedence]"),u=0;u "u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(i)}catch(o){console.error(o)}}return i(),Zf.exports=ev(),Zf.exports}var av=lv();const nv="modulepreload",uv=function(i){return"/"+i},Am={},Le=function(o,r,f){let d=Promise.resolve();if(r&&r.length>0){let g=function(y){return Promise.all(y.map(M=>Promise.resolve(M).then(T=>({status:"fulfilled",value:T}),T=>({status:"rejected",reason:T}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),E=h?.nonce||h?.getAttribute("nonce");d=g(r.map(y=>{if(y=uv(y),y in Am)return;Am[y]=!0;const M=y.endsWith(".css"),T=M?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${y}"]${T}`))return;const H=document.createElement("link");if(H.rel=M?"stylesheet":nv,M||(H.as="script"),H.crossOrigin="",H.href=y,E&&H.setAttribute("nonce",E),document.head.appendChild(H),M)return new Promise((X,W)=>{H.addEventListener("load",X),H.addEventListener("error",()=>W(new Error(`Unable to preload CSS for ${y}`)))})}))}function m(h){const E=new Event("vite:preloadError",{cancelable:!0});if(E.payload=h,window.dispatchEvent(E),!E.defaultPrevented)throw h}return d.then(h=>{for(const E of h||[])E.status==="rejected"&&m(E.reason);return o().catch(m)})};var _m="popstate";function iv(i={}){function o(f,d){let{pathname:m,search:h,hash:E}=f.location;return If("",{pathname:m,search:h,hash:E},d.state&&d.state.usr||null,d.state&&d.state.key||"default")}function r(f,d){return typeof d=="string"?d:$n(d)}return fv(o,r,null,i)}function Nt(i,o){if(i===!1||i===null||typeof i>"u")throw new Error(o)}function Be(i,o){if(!i){typeof console<"u"&&console.warn(o);try{throw new Error(o)}catch{}}}function cv(){return Math.random().toString(36).substring(2,10)}function Rm(i,o){return{usr:i.state,key:i.key,idx:o}}function If(i,o,r=null,f){return{pathname:typeof i=="string"?i:i.pathname,search:"",hash:"",...typeof o=="string"?Wa(o):o,state:r,key:o&&o.key||f||cv()}}function $n({pathname:i="/",search:o="",hash:r=""}){return o&&o!=="?"&&(i+=o.charAt(0)==="?"?o:"?"+o),r&&r!=="#"&&(i+=r.charAt(0)==="#"?r:"#"+r),i}function Wa(i){let o={};if(i){let r=i.indexOf("#");r>=0&&(o.hash=i.substring(r),i=i.substring(0,r));let f=i.indexOf("?");f>=0&&(o.search=i.substring(f),i=i.substring(0,f)),i&&(o.pathname=i)}return o}function fv(i,o,r,f={}){let{window:d=document.defaultView,v5Compat:m=!1}=f,h=d.history,E="POP",g=null,y=M();y==null&&(y=0,h.replaceState({...h.state,idx:y},""));function M(){return(h.state||{idx:null}).idx}function T(){E="POP";let q=M(),J=q==null?null:q-y;y=q,g&&g({action:E,location:G.location,delta:J})}function H(q,J){E="PUSH";let Q=If(G.location,q,J);y=M()+1;let F=Rm(Q,y),ht=G.createHref(Q);try{h.pushState(F,"",ht)}catch(mt){if(mt instanceof DOMException&&mt.name==="DataCloneError")throw mt;d.location.assign(ht)}m&&g&&g({action:E,location:G.location,delta:1})}function X(q,J){E="REPLACE";let Q=If(G.location,q,J);y=M();let F=Rm(Q,y),ht=G.createHref(Q);h.replaceState(F,"",ht),m&&g&&g({action:E,location:G.location,delta:0})}function W(q){return ov(q)}let G={get action(){return E},get location(){return i(d,h)},listen(q){if(g)throw new Error("A history only accepts one active listener");return d.addEventListener(_m,T),g=q,()=>{d.removeEventListener(_m,T),g=null}},createHref(q){return o(d,q)},createURL:W,encodeLocation(q){let J=W(q);return{pathname:J.pathname,search:J.search,hash:J.hash}},push:H,replace:X,go(q){return h.go(q)}};return G}function ov(i,o=!1){let r="http://localhost";typeof window<"u"&&(r=window.location.origin!=="null"?window.location.origin:window.location.href),Nt(r,"No window.location.(origin|href) available to create URL");let f=typeof i=="string"?i:$n(i);return f=f.replace(/ $/,"%20"),!o&&f.startsWith("//")&&(f=r+f),new URL(f,r)}function qm(i,o,r="/"){return rv(i,o,r,!1)}function rv(i,o,r,f){let d=typeof o=="string"?Wa(o):o,m=ml(d.pathname||"/",r);if(m==null)return null;let h=Ym(i);sv(h);let E=null;for(let g=0;E==null&&g {let M={relativePath:y===void 0?h.path||"":y,caseSensitive:h.caseSensitive===!0,childrenIndex:E,route:h};if(M.relativePath.startsWith("/")){if(!M.relativePath.startsWith(f)&&g)return;Nt(M.relativePath.startsWith(f),`Absolute route path "${M.relativePath}" nested under path "${f}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),M.relativePath=M.relativePath.slice(f.length)}let T=dl([f,M.relativePath]),H=r.concat(M);h.children&&h.children.length>0&&(Nt(h.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${T}".`),Ym(h.children,o,H,T,g)),!(h.path==null&&!h.index)&&o.push({path:T,score:pv(T,h.index),routesMeta:H})};return i.forEach((h,E)=>{if(h.path===""||!h.path?.includes("?"))m(h,E);else for(let g of Gm(h.path))m(h,E,!0,g)}),o}function Gm(i){let o=i.split("/");if(o.length===0)return[];let[r,...f]=o,d=r.endsWith("?"),m=r.replace(/\?$/,"");if(f.length===0)return d?[m,""]:[m];let h=Gm(f.join("/")),E=[];return E.push(...h.map(g=>g===""?m:[m,g].join("/"))),d&&E.push(...h),E.map(g=>i.startsWith("/")&&g===""?"/":g)}function sv(i){i.sort((o,r)=>o.score!==r.score?r.score-o.score:bv(o.routesMeta.map(f=>f.childrenIndex),r.routesMeta.map(f=>f.childrenIndex)))}var dv=/^:[\w-]+$/,mv=3,hv=2,yv=1,vv=10,gv=-2,Mm=i=>i==="*";function pv(i,o){let r=i.split("/"),f=r.length;return r.some(Mm)&&(f+=gv),o&&(f+=hv),r.filter(d=>!Mm(d)).reduce((d,m)=>d+(dv.test(m)?mv:m===""?yv:vv),f)}function bv(i,o){return i.length===o.length&&i.slice(0,-1).every((f,d)=>f===o[d])?i[i.length-1]-o[o.length-1]:0}function Sv(i,o,r=!1){let{routesMeta:f}=i,d={},m="/",h=[];for(let E=0;E {if(M==="*"){let W=E[H]||"";h=m.slice(0,m.length-W.length).replace(/(.)\/+$/,"$1")}const X=E[H];return T&&!X?y[M]=void 0:y[M]=(X||"").replace(/%2F/g,"/"),y},{}),pathname:m,pathnameBase:h,pattern:i}}function Ev(i,o=!1,r=!0){Be(i==="*"||!i.endsWith("*")||i.endsWith("/*"),`Route path "${i}" will be treated as if it were "${i.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${i.replace(/\*$/,"/*")}".`);let f=[],d="^"+i.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(h,E,g)=>(f.push({paramName:E,isOptional:g!=null}),g?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return i.endsWith("*")?(f.push({paramName:"*"}),d+=i==="*"||i==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?d+="\\/*$":i!==""&&i!=="/"&&(d+="(?:(?=\\/|$))"),[new RegExp(d,o?void 0:"i"),f]}function xv(i){try{return i.split("/").map(o=>decodeURIComponent(o).replace(/\//g,"%2F")).join("/")}catch(o){return Be(!1,`The URL path "${i}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${o}).`),i}}function ml(i,o){if(o==="/")return i;if(!i.toLowerCase().startsWith(o.toLowerCase()))return null;let r=o.endsWith("/")?o.length-1:o.length,f=i.charAt(r);return f&&f!=="/"?null:i.slice(r)||"/"}var zv=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Tv(i,o="/"){let{pathname:r,search:f="",hash:d=""}=typeof i=="string"?Wa(i):i,m;return r?(r=r.replace(/\/\/+/g,"/"),r.startsWith("/")?m=Om(r.substring(1),"/"):m=Om(r,o)):m=o,{pathname:m,search:Rv(f),hash:Mv(d)}}function Om(i,o){let r=o.replace(/\/+$/,"").split("/");return i.split("/").forEach(d=>{d===".."?r.length>1&&r.pop():d!=="."&&r.push(d)}),r.length>1?r.join("/"):"/"}function $f(i,o,r,f){return`Cannot include a '${i}' character in a manually specified \`to.${o}\` field [${JSON.stringify(f)}]. Please separate it out to the \`to.${r}\` field. Alternatively you may provide the full path as a string in and the router will parse it for you.`}function Av(i){return i.filter((o,r)=>r===0||o.route.path&&o.route.path.length>0)}function Xm(i){let o=Av(i);return o.map((r,f)=>f===o.length-1?r.pathname:r.pathnameBase)}function Qm(i,o,r,f=!1){let d;typeof i=="string"?d=Wa(i):(d={...i},Nt(!d.pathname||!d.pathname.includes("?"),$f("?","pathname","search",d)),Nt(!d.pathname||!d.pathname.includes("#"),$f("#","pathname","hash",d)),Nt(!d.search||!d.search.includes("#"),$f("#","search","hash",d)));let m=i===""||d.pathname==="",h=m?"/":d.pathname,E;if(h==null)E=r;else{let T=o.length-1;if(!f&&h.startsWith("..")){let H=h.split("/");for(;H[0]==="..";)H.shift(),T-=1;d.pathname=H.join("/")}E=T>=0?o[T]:"/"}let g=Tv(d,E),y=h&&h!=="/"&&h.endsWith("/"),M=(m||h===".")&&r.endsWith("/");return!g.pathname.endsWith("/")&&(y||M)&&(g.pathname+="/"),g}var dl=i=>i.join("/").replace(/\/\/+/g,"/"),_v=i=>i.replace(/\/+$/,"").replace(/^\/*/,"/"),Rv=i=>!i||i==="?"?"":i.startsWith("?")?i:"?"+i,Mv=i=>!i||i==="#"?"":i.startsWith("#")?i:"#"+i,Ov=class{constructor(i,o,r,f=!1){this.status=i,this.statusText=o||"",this.internal=f,r instanceof Error?(this.data=r.toString(),this.error=r):this.data=r}};function Cv(i){return i!=null&&typeof i.status=="number"&&typeof i.statusText=="string"&&typeof i.internal=="boolean"&&"data"in i}function Dv(i){return i.map(o=>o.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var Vm=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Zm(i,o){let r=i;if(typeof r!="string"||!zv.test(r))return{absoluteURL:void 0,isExternal:!1,to:r};let f=r,d=!1;if(Vm)try{let m=new URL(window.location.href),h=r.startsWith("//")?new URL(m.protocol+r):new URL(r),E=ml(h.pathname,o);h.origin===m.origin&&E!=null?r=E+h.search+h.hash:d=!0}catch{Be(!1,` contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:f,isExternal:d,to:r}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var km=["POST","PUT","PATCH","DELETE"];new Set(km);var Nv=["GET",...km];new Set(Nv);var Fa=_.createContext(null);Fa.displayName="DataRouter";var zi=_.createContext(null);zi.displayName="DataRouterState";var Uv=_.createContext(!1),Km=_.createContext({isTransitioning:!1});Km.displayName="ViewTransition";var wv=_.createContext(new Map);wv.displayName="Fetchers";var Hv=_.createContext(null);Hv.displayName="Await";var Ue=_.createContext(null);Ue.displayName="Navigation";var Wn=_.createContext(null);Wn.displayName="Location";var Ze=_.createContext({outlet:null,matches:[],isDataRoute:!1});Ze.displayName="Route";var uo=_.createContext(null);uo.displayName="RouteError";var Jm="REACT_ROUTER_ERROR",jv="REDIRECT",Bv="ROUTE_ERROR_RESPONSE";function Lv(i){if(i.startsWith(`${Jm}:${jv}:{`))try{let o=JSON.parse(i.slice(28));if(typeof o=="object"&&o&&typeof o.status=="number"&&typeof o.statusText=="string"&&typeof o.location=="string"&&typeof o.reloadDocument=="boolean"&&typeof o.replace=="boolean")return o}catch{}}function qv(i){if(i.startsWith(`${Jm}:${Bv}:{`))try{let o=JSON.parse(i.slice(40));if(typeof o=="object"&&o&&typeof o.status=="number"&&typeof o.statusText=="string")return new Ov(o.status,o.statusText,o.data)}catch{}}function Yv(i,{relative:o}={}){Nt(Fn(),"useHref() may be used only in the context of a component.");let{basename:r,navigator:f}=_.useContext(Ue),{hash:d,pathname:m,search:h}=Pn(i,{relative:o}),E=m;return r!=="/"&&(E=m==="/"?r:dl([r,m])),f.createHref({pathname:E,search:h,hash:d})}function Fn(){return _.useContext(Wn)!=null}function Xl(){return Nt(Fn(),"useLocation() may be used only in the context of a component."),_.useContext(Wn).location}var $m="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Wm(i){_.useContext(Ue).static||_.useLayoutEffect(i)}function io(){let{isDataRoute:i}=_.useContext(Ze);return i?eg():Gv()}function Gv(){Nt(Fn(),"useNavigate() may be used only in the context of a component.");let i=_.useContext(Fa),{basename:o,navigator:r}=_.useContext(Ue),{matches:f}=_.useContext(Ze),{pathname:d}=Xl(),m=JSON.stringify(Xm(f)),h=_.useRef(!1);return Wm(()=>{h.current=!0}),_.useCallback((g,y={})=>{if(Be(h.current,$m),!h.current)return;if(typeof g=="number"){r.go(g);return}let M=Qm(g,JSON.parse(m),d,y.relative==="path");i==null&&o!=="/"&&(M.pathname=M.pathname==="/"?o:dl([o,M.pathname])),(y.replace?r.replace:r.push)(M,y.state,y)},[o,r,m,d,i])}var Xv=_.createContext(null);function Qv(i){let o=_.useContext(Ze).outlet;return _.useMemo(()=>o&&_.createElement(Xv.Provider,{value:i},o),[o,i])}function Pn(i,{relative:o}={}){let{matches:r}=_.useContext(Ze),{pathname:f}=Xl(),d=JSON.stringify(Xm(r));return _.useMemo(()=>Qm(i,JSON.parse(d),f,o==="path"),[i,d,f,o])}function Vv(i,o){return Fm(i,o)}function Fm(i,o,r,f,d){Nt(Fn(),"useRoutes() may be used only in the context of a component.");let{navigator:m}=_.useContext(Ue),{matches:h}=_.useContext(Ze),E=h[h.length-1],g=E?E.params:{},y=E?E.pathname:"/",M=E?E.pathnameBase:"/",T=E&&E.route;{let Q=T&&T.path||"";Im(y,!T||Q.endsWith("*")||Q.endsWith("*?"),`You rendered descendant (or called \`useRoutes()\`) at "${y}" (under ) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render. -Please change the parent to .`)}let H=Xl(),X;if(o){let Q=typeof o=="string"?Wa(o):o;Nt(M==="/"||Q.pathname?.startsWith(M),`When overriding the location using \` \` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${M}" but pathname "${Q.pathname}" was given in the \`location\` prop.`),X=Q}else X=H;let W=X.pathname||"/",G=W;if(M!=="/"){let Q=M.replace(/^\//,"").split("/");G="/"+W.replace(/^\//,"").split("/").slice(Q.length).join("/")}let q=qm(i,{pathname:G});Be(T||q!=null,`No routes matched location "${X.pathname}${X.search}${X.hash}" `),Be(q==null||q[q.length-1].route.element!==void 0||q[q.length-1].route.Component!==void 0||q[q.length-1].route.lazy!==void 0,`Matched leaf route at location "${X.pathname}${X.search}${X.hash}" does not have an element or Component. This means it will render an with a null value by default resulting in an "empty" page.`);let J=$v(q&&q.map(Q=>Object.assign({},Q,{params:Object.assign({},g,Q.params),pathname:dl([M,m.encodeLocation?m.encodeLocation(Q.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:Q.pathname]),pathnameBase:Q.pathnameBase==="/"?M:dl([M,m.encodeLocation?m.encodeLocation(Q.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:Q.pathnameBase])})),h,r,f,d);return o&&J?_.createElement(Wn.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...X},navigationType:"POP"}},J):J}function Zv(){let i=tg(),o=Cv(i)?`${i.status} ${i.statusText}`:i instanceof Error?i.message:JSON.stringify(i),r=i instanceof Error?i.stack:null,f="rgba(200,200,200, 0.5)",d={padding:"0.5rem",backgroundColor:f},m={padding:"2px 4px",backgroundColor:f},h=null;return console.error("Error handled by React Router default ErrorBoundary:",i),h=_.createElement(_.Fragment,null,_.createElement("p",null,"💿 Hey developer 👋"),_.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",_.createElement("code",{style:m},"ErrorBoundary")," or"," ",_.createElement("code",{style:m},"errorElement")," prop on your route.")),_.createElement(_.Fragment,null,_.createElement("h2",null,"Unexpected Application Error!"),_.createElement("h3",{style:{fontStyle:"italic"}},o),r?_.createElement("pre",{style:d},r):null,h)}var kv=_.createElement(Zv,null),Pm=class extends _.Component{constructor(i){super(i),this.state={location:i.location,revalidation:i.revalidation,error:i.error}}static getDerivedStateFromError(i){return{error:i}}static getDerivedStateFromProps(i,o){return o.location!==i.location||o.revalidation!=="idle"&&i.revalidation==="idle"?{error:i.error,location:i.location,revalidation:i.revalidation}:{error:i.error!==void 0?i.error:o.error,location:o.location,revalidation:i.revalidation||o.revalidation}}componentDidCatch(i,o){this.props.onError?this.props.onError(i,o):console.error("React Router caught the following error during render",i)}render(){let i=this.state.error;if(this.context&&typeof i=="object"&&i&&"digest"in i&&typeof i.digest=="string"){const r=qv(i.digest);r&&(i=r)}let o=i!==void 0?_.createElement(Ze.Provider,{value:this.props.routeContext},_.createElement(uo.Provider,{value:i,children:this.props.component})):this.props.children;return this.context?_.createElement(Kv,{error:i},o):o}};Pm.contextType=Uv;var Wf=new WeakMap;function Kv({children:i,error:o}){let{basename:r}=_.useContext(Ue);if(typeof o=="object"&&o&&"digest"in o&&typeof o.digest=="string"){let f=Lv(o.digest);if(f){let d=Wf.get(o);if(d)throw d;let m=Zm(f.location,r);if(Vm&&!Wf.get(o))if(m.isExternal||f.reloadDocument)window.location.href=m.absoluteURL||m.to;else{const h=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(m.to,{replace:f.replace}));throw Wf.set(o,h),h}return _.createElement("meta",{httpEquiv:"refresh",content:`0;url=${m.absoluteURL||m.to}`})}}return i}function Jv({routeContext:i,match:o,children:r}){let f=_.useContext(Fa);return f&&f.static&&f.staticContext&&(o.route.errorElement||o.route.ErrorBoundary)&&(f.staticContext._deepestRenderedBoundaryId=o.route.id),_.createElement(Ze.Provider,{value:i},r)}function $v(i,o=[],r=null,f=null,d=null){if(i==null){if(!r)return null;if(r.errors)i=r.matches;else if(o.length===0&&!r.initialized&&r.matches.length>0)i=r.matches;else return null}let m=i,h=r?.errors;if(h!=null){let M=m.findIndex(T=>T.route.id&&h?.[T.route.id]!==void 0);Nt(M>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(h).join(",")}`),m=m.slice(0,Math.min(m.length,M+1))}let E=!1,g=-1;if(r)for(let M=0;M =0?m=m.slice(0,g+1):m=[m[0]];break}}}let y=r&&f?(M,T)=>{f(M,{location:r.location,params:r.matches?.[0]?.params??{},unstable_pattern:Dv(r.matches),errorInfo:T})}:void 0;return m.reduceRight((M,T,H)=>{let X,W=!1,G=null,q=null;r&&(X=h&&T.route.id?h[T.route.id]:void 0,G=T.route.errorElement||kv,E&&(g<0&&H===0?(Im("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),W=!0,q=null):g===H&&(W=!0,q=T.route.hydrateFallbackElement||null)));let J=o.concat(m.slice(0,H+1)),Q=()=>{let F;return X?F=G:W?F=q:T.route.Component?F=_.createElement(T.route.Component,null):T.route.element?F=T.route.element:F=M,_.createElement(Jv,{match:T,routeContext:{outlet:M,matches:J,isDataRoute:r!=null},children:F})};return r&&(T.route.ErrorBoundary||T.route.errorElement||H===0)?_.createElement(Pm,{location:r.location,revalidation:r.revalidation,component:G,error:X,children:Q(),routeContext:{outlet:null,matches:J,isDataRoute:!0},onError:y}):Q()},null)}function co(i){return`${i} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Wv(i){let o=_.useContext(Fa);return Nt(o,co(i)),o}function Fv(i){let o=_.useContext(zi);return Nt(o,co(i)),o}function Pv(i){let o=_.useContext(Ze);return Nt(o,co(i)),o}function fo(i){let o=Pv(i),r=o.matches[o.matches.length-1];return Nt(r.route.id,`${i} can only be used on routes that contain a unique "id"`),r.route.id}function Iv(){return fo("useRouteId")}function tg(){let i=_.useContext(uo),o=Fv("useRouteError"),r=fo("useRouteError");return i!==void 0?i:o.errors?.[r]}function eg(){let{router:i}=Wv("useNavigate"),o=fo("useNavigate"),r=_.useRef(!1);return Wm(()=>{r.current=!0}),_.useCallback(async(d,m={})=>{Be(r.current,$m),r.current&&(typeof d=="number"?await i.navigate(d):await i.navigate(d,{fromRouteId:o,...m}))},[i,o])}var Cm={};function Im(i,o,r){!o&&!Cm[i]&&(Cm[i]=!0,Be(!1,r))}_.memo(lg);function lg({routes:i,future:o,state:r,onError:f}){return Fm(i,void 0,r,f,o)}function ag(i){return Qv(i.context)}function xe(i){Nt(!1,"A is only ever to be used as the child of element, never rendered directly. Please wrap your in a .")}function ng({basename:i="/",children:o=null,location:r,navigationType:f="POP",navigator:d,static:m=!1,unstable_useTransitions:h}){Nt(!Fn(),"You cannot render a inside another . You should never have more than one in your app.");let E=i.replace(/^\/*/,"/"),g=_.useMemo(()=>({basename:E,navigator:d,static:m,unstable_useTransitions:h,future:{}}),[E,d,m,h]);typeof r=="string"&&(r=Wa(r));let{pathname:y="/",search:M="",hash:T="",state:H=null,key:X="default"}=r,W=_.useMemo(()=>{let G=ml(y,E);return G==null?null:{location:{pathname:G,search:M,hash:T,state:H,key:X},navigationType:f}},[E,y,M,T,H,X,f]);return Be(W!=null,` is not able to match the URL "${y}${M}${T}" because it does not start with the basename, so the won't render anything.`),W==null?null:_.createElement(Ue.Provider,{value:g},_.createElement(Wn.Provider,{children:o,value:W}))}function ug({children:i,location:o}){return Vv(to(i),o)}function to(i,o=[]){let r=[];return _.Children.forEach(i,(f,d)=>{if(!_.isValidElement(f))return;let m=[...o,d];if(f.type===_.Fragment){r.push.apply(r,to(f.props.children,m));return}Nt(f.type===xe,`[${typeof f.type=="string"?f.type:f.type.name}] is not a component. All component children of must be a or `),Nt(!f.props.index||!f.props.children,"An index route cannot have child routes.");let h={id:f.props.id||m.join("-"),caseSensitive:f.props.caseSensitive,element:f.props.element,Component:f.props.Component,index:f.props.index,path:f.props.path,middleware:f.props.middleware,loader:f.props.loader,action:f.props.action,hydrateFallbackElement:f.props.hydrateFallbackElement,HydrateFallback:f.props.HydrateFallback,errorElement:f.props.errorElement,ErrorBoundary:f.props.ErrorBoundary,hasErrorBoundary:f.props.hasErrorBoundary===!0||f.props.ErrorBoundary!=null||f.props.errorElement!=null,shouldRevalidate:f.props.shouldRevalidate,handle:f.props.handle,lazy:f.props.lazy};f.props.children&&(h.children=to(f.props.children,m)),r.push(h)}),r}var bi="get",Si="application/x-www-form-urlencoded";function Ti(i){return typeof HTMLElement<"u"&&i instanceof HTMLElement}function ig(i){return Ti(i)&&i.tagName.toLowerCase()==="button"}function cg(i){return Ti(i)&&i.tagName.toLowerCase()==="form"}function fg(i){return Ti(i)&&i.tagName.toLowerCase()==="input"}function og(i){return!!(i.metaKey||i.altKey||i.ctrlKey||i.shiftKey)}function rg(i,o){return i.button===0&&(!o||o==="_self")&&!og(i)}function eo(i=""){return new URLSearchParams(typeof i=="string"||Array.isArray(i)||i instanceof URLSearchParams?i:Object.keys(i).reduce((o,r)=>{let f=i[r];return o.concat(Array.isArray(f)?f.map(d=>[r,d]):[[r,f]])},[]))}function sg(i,o){let r=eo(i);return o&&o.forEach((f,d)=>{r.has(d)||o.getAll(d).forEach(m=>{r.append(d,m)})}),r}var vi=null;function dg(){if(vi===null)try{new FormData(document.createElement("form"),0),vi=!1}catch{vi=!0}return vi}var mg=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Ff(i){return i!=null&&!mg.has(i)?(Be(!1,`"${i}" is not a valid \`encType\` for \`