@botpress/adk-cli 1.19.0-beta.3 → 1.19.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/assets/ui-dist/assets/{index-CSTz-oTK.js → index-B3b7PPgV.js} +4 -4
  2. package/{dist/index-DNqXHLNi-27nvpkee.js → assets/ui-dist/assets/index-BESZeTO5.js} +2 -2
  3. package/{dist/index-DAztRXeA-vr85xnxs.css → assets/ui-dist/assets/index-DIFGtVmI.css} +1 -1
  4. package/{dist/index-DfjXY3Oo-szsanhnt.js → assets/ui-dist/assets/index-a3ZL0_Jr.js} +2 -2
  5. package/assets/ui-dist/index.html +2 -2
  6. package/dist/{README-wjb7z7f0.md → README-824wa4jj.md} +1 -1
  7. package/dist/SKILL-75ym6tcj.md +257 -0
  8. package/dist/SKILL-chnwzmt1.md +548 -0
  9. package/dist/SKILL-d4bs53y3.md +244 -0
  10. package/dist/SKILL-h4b2f1n9.md +114 -0
  11. package/dist/SKILL-hbw5nt95.md +111 -0
  12. package/dist/actions-h7hxxvxr.md +823 -0
  13. package/dist/adk-build-emhwd0tg.md +39 -0
  14. package/dist/adk-debug-yrrdtpmb.md +23 -0
  15. package/dist/adk-dev-console-7z9rtjpy.md +17 -0
  16. package/dist/adk-document-ras6zzzh.md +68 -0
  17. package/dist/adk-eval-vx76dwq0.md +17 -0
  18. package/dist/adk-explain-fcsaw852.md +22 -0
  19. package/dist/adk-init-9kmxmbbe.md +30 -0
  20. package/dist/adk-ship-dybzn884.md +29 -0
  21. package/dist/adk-test-xq67savs.md +27 -0
  22. package/dist/adk-validate-1p4skv4m.md +31 -0
  23. package/dist/advanced-patterns-z86m9h1a.md +669 -0
  24. package/dist/agent-config-1aqvkrgf.md +450 -0
  25. package/dist/agent-steps-zj4c1n9t.md +115 -0
  26. package/dist/agent0-assets/skills/adk/SKILL.md +5 -5
  27. package/dist/agent0-assets/skills/adk/references/cli.md +265 -24
  28. package/dist/agent0-assets/skills/adk-debugger/SKILL.md +5 -5
  29. package/dist/agent0-assets/skills/adk-debugger/references/common-failures.md +1 -1
  30. package/dist/agent0-assets/skills/adk-debugger/references/debug-workflow.md +3 -3
  31. package/dist/agent0-assets/skills/adk-debugger/references/traces-and-logs.md +15 -7
  32. package/dist/assets-q7jt8r2q.md +237 -0
  33. package/dist/autonomous-execution-fymc12e5.md +747 -0
  34. package/dist/cli-c31e06yr.md +1334 -0
  35. package/dist/cli.js +963 -548
  36. package/dist/commands.json +24 -3
  37. package/dist/common-failures-ht29w2db.md +231 -0
  38. package/dist/component-registry-bbpw0see.md +43 -0
  39. package/dist/context-api-760cvh0h.md +461 -0
  40. package/dist/conversation-analysis-8ka4nrm4.md +420 -0
  41. package/dist/conversation-lifecycle-4seqqjc1.md +311 -0
  42. package/dist/conversations-gwfvxaee.md +1111 -0
  43. package/dist/custom-components-y5wdgpey.md +167 -0
  44. package/dist/debug-workflow-vz84q80v.md +239 -0
  45. package/dist/desk-k54ktvsd.md +852 -0
  46. package/dist/doc-standards-ck6ax2jd.md +124 -0
  47. package/dist/eval-format-7n9brja4.md +354 -0
  48. package/dist/evals-y1zcr1mc.md +11 -0
  49. package/dist/explain-config-1yaq3zzd.md +424 -0
  50. package/dist/files-dzt0wxn3.md +918 -0
  51. package/dist/{index-gqxgqnyz.html → index-3t354nbw.html} +2 -2
  52. package/dist/{index-CSTz-oTK-mdfh47r8.js → index-B3b7PPgV-zetkb01w.js} +4 -4
  53. package/{assets/ui-dist/assets/index-DNqXHLNi.js → dist/index-BESZeTO5-2rpmcefa.js} +2 -2
  54. package/{assets/ui-dist/assets/index-DAztRXeA.css → dist/index-DIFGtVmI-d4dhjg97.css} +1 -1
  55. package/{assets/ui-dist/assets/index-DfjXY3Oo.js → dist/index-a3ZL0_Jr-q145h35p.js} +2 -2
  56. package/dist/integration-actions-xang7tma.md +659 -0
  57. package/dist/integrations-k5ss07f4.md +266 -0
  58. package/dist/interfaces-6t0bpxs4.md +97 -0
  59. package/dist/knowledge-bases-20rg8p5c.md +456 -0
  60. package/dist/llm-debugging-76ng8rzm.md +209 -0
  61. package/dist/mcp-server-n1asyzhv.md +112 -0
  62. package/dist/messages-gkkg0b54.md +769 -0
  63. package/dist/model-configuration-f273kgd0.md +201 -0
  64. package/dist/multi-agent-dashboard-1mdfjdts.md +70 -0
  65. package/dist/pages-xn18xn73.md +273 -0
  66. package/dist/patterns-mistakes-5vb99dhf.md +469 -0
  67. package/dist/plugins-ttnx8f49.md +280 -0
  68. package/dist/tables-x45t36dd.md +1136 -0
  69. package/dist/tags-46td3qrg.md +516 -0
  70. package/dist/test-patterns-hj47w4nc.md +355 -0
  71. package/dist/testing-workflow-2vkp932f.md +225 -0
  72. package/dist/tools-wk7bq24z.md +581 -0
  73. package/dist/trace-summarization-hdyx1c2e.md +313 -0
  74. package/dist/traces-and-logs-f2kjfh19.md +203 -0
  75. package/dist/triggers-4j2cc86x.md +719 -0
  76. package/dist/ui-server-entry.js +977 -162
  77. package/dist/workflow-steps-mrdrf1c5.md +851 -0
  78. package/dist/workflows-gadx3s69.md +1408 -0
  79. package/dist/zai-agent-reference-e6644aad.md +454 -0
  80. package/dist/zai-complete-guide-mnna5d6f.md +1408 -0
  81. package/package.json +4 -4
@@ -1135,7 +1135,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),Bo=kt,ts=At),En===void
1135
1135
  `)[0]?.trim();if(!t)return null;const n=t.match(/^\*\*([^*]+?):?\*\*:?$/);if(n)return n[1].trim();const r=t.match(/^#+\s+(.+?):?$/);return r?r[1].trim():null}function nJt(e){const{state:t}=e;if(t.status!=="running"&&t.status!=="pending")return null;const n=q5(e.toolId,t),r="title"in t&&t.title?String(t.title):null,s=n??r??void 0;return{label:N5e(e.toolId,t.status),detail:s,detailKind:n?"code":"text",key:`tool:${e.id}:${t.status}:${s??""}`}}function rJt(e){for(let t=e.length-1;t>=0;t--){const n=e[t];if(n.role==="assistant")for(let r=n.parts.length-1;r>=0;r--){const s=n.parts[r];if(s.type==="tool"&&s.toolId&&s.state){const o=nJt(s);if(o)return o}}}for(let t=e.length-1;t>=0;t--){const n=e[t];if(n.role==="assistant")for(let r=n.parts.length-1;r>=0;r--){const s=n.parts[r];if(s.type==="reasoning"){const o=tJt(s.text);if(o)return{label:"Thinking",detail:o,detailKind:"text",key:`reasoning:${s.id}:${o}`}}}}return null}function sJt(e){const t=e/1e3;if(t<10)return`${t.toFixed(1)}s`;if(t<60)return`${Math.round(t)}s`;const n=Math.floor(t/60),r=Math.round(t%60);return r?`${n}m ${r}s`:`${n}m`}const oJt={spinning:{rotate:[45,45,135,135,225],borderRadius:["0%","50%","50%","0%","0%"],transition:{duration:2.5,times:[0,.25,.5,.75,1],repeat:1/0,ease:"easeInOut"}},resting:{borderRadius:"50%",transition:{duration:.6,ease:"easeOut"}}};function aJt({active:e,completedDurationMs:t,className:n,messages:r}){const s=Vt(x=>x.messages),o=r??s,[a,i]=b.useState(null),[c,l]=b.useState(!1),d=b.useRef(null);b.useEffect(()=>{e?(d.current=Date.now(),l(!0),i(null)):d.current!==null&&(i(Date.now()-d.current),d.current=null)},[e]),b.useEffect(()=>{o.length===0&&(l(!1),i(null),d.current=null)},[o.length]);const f=b.useMemo(()=>rJt(o),[o]),p=!e&&typeof t=="number"&&t>=0?t:null,g=e||!e&&c&&a===null,y=a??p,E=g?`active:${f?.key??"working"}`:y!==null?"rest":"hidden";return!g&&y===null?null:u.jsxs("div",{className:me("flex items-center gap-2 min-w-0",n),children:[u.jsxs("div",{className:"relative size-3 shrink-0",children:[u.jsx(Qi,{children:e&&u.jsx(or.div,{"aria-hidden":!0,className:"absolute inset-0 rounded-full border border-blue-500/60",initial:{scale:1,opacity:.55},animate:{scale:2.8,opacity:0},exit:{opacity:0},transition:{duration:.7,ease:"easeOut"}},"ripple")}),u.jsx(or.div,{className:me("size-3 transition-colors duration-300",g?"bg-blue-500":"bg-foreground"),variants:oJt,initial:"resting",animate:g?"spinning":"resting"})]}),u.jsx("span",{className:"relative inline-grid min-w-0 max-w-full text-[11px]",children:u.jsx(Qi,{initial:!1,children:u.jsx(or.span,{initial:{opacity:0,y:-1,filter:"blur(2px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},exit:{opacity:0,y:1,filter:"blur(2px)"},transition:{duration:.34,ease:"easeOut"},className:"col-start-1 row-start-1 inline-block min-w-0 truncate",children:g?f?u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"thinking-shimmer",children:f.label}),f.detail&&u.jsxs("span",{className:me("text-muted-foreground/60",f.detailKind==="code"&&"font-mono text-muted-foreground/45"),children:[" ",f.detail]})]}):u.jsx("span",{className:"thinking-shimmer",children:"working"}):y!==null?u.jsxs("span",{className:"text-muted-foreground/45",children:["worked for ",sJt(y)]}):null},E)})})]})}function GFe(e){return e.stableId??e.id}function iJt({turn:e,settings:t,restoredMessageIds:n,showWorkingIndicator:r}){const s=o=>{const a=GFe(o);return u.jsx(eJt,{msg:o,settings:t,isRestored:n.has(a)},a)};return u.jsxs("div",{className:"flex flex-col gap-4","data-turn-id":e.id,"data-turn-active":e.active?"true":void 0,"data-turn-status":e.status,children:[e.user&&s(e.user),e.assistantMessages.map(s),r&&u.jsx(aJt,{active:e.active,completedDurationMs:e.durationMs,messages:e.messages,className:"mt-[-0.25rem] text-muted-foreground"})]})}function lJt({heroEmptyState:e,headline:t}){const n=Vt(p=>p.messages),r=Vt(p=>p.settings),s=Vt(p=>p.pendingQuestion),o=Vt(p=>p.sessionStatus),a=Vt(yI),i=CBt({active:a,contentVersion:n}),c=b.useRef(new Set),l=b.useRef(!1);if(!l.current){if(n.some(p=>p.role==="assistant"))for(const p of n)c.current.add(GFe(p));l.current=!0}const d=b.useMemo(()=>jO(n,{sessionStatus:o,settings:r}),[n,o,r]),f=n.length===0&&!a&&!s;return u.jsx("div",{className:"relative flex-1 min-h-0",children:u.jsxs("div",{ref:i.scrollRef,onScroll:i.handleScroll,onClick:i.handleInteraction,className:"absolute inset-0 overflow-y-auto overflow-x-hidden",children:[f?u.jsx("div",{ref:i.contentRef,children:u.jsx(kBt,{hero:e,headline:t})}):u.jsx("div",{ref:i.contentRef,className:"flex flex-col gap-4 px-3 py-3",children:d.map((p,h)=>u.jsx(iJt,{turn:p,settings:r,restoredMessageIds:c.current,showWorkingIndicator:h===d.length-1},p.id))}),i.showJump&&u.jsx("button",{type:"button",onClick:i.resume,className:"sticky bottom-2 left-1/2 -translate-x-1/2 z-10 flex items-center justify-center size-7 rounded-full bg-background border border-border/40 hover:bg-accent transition-colors",children:u.jsx(Dr,{className:"size-4 text-muted-foreground"})})]})})}const cJt={chat:"Chat","agent-map":"Agent Map",actions:"Actions",workflows:"Workflows",traces:"Traces",evals:"Evals",conversations:"Conversations",tables:"Tables",files:"Files",search:"Search",knowledge:"Knowledge",triggers:"Triggers",integrations:"Integrations",logs:"Logs",settings:"Settings"},uJt={map:"Agent Map",chat:"Chat (webchat + agent steps)"};function dJt(e){if(e==="/new/guided-setup")return"Guided Setup";if(e.startsWith("/new"))return"Create Project";const t=e.split("/").filter(Boolean),n=t[0];if(!n)return"Home";const r=cJt[n]??n;return t.length>1?`${r} → ${t.slice(1).join("/")}`:r}function fJt(e,t,n){const r=new URLSearchParams(t),s=r.get("selected"),o=[];for(const[c,l]of r.entries())c!=="selected"&&o.push([c,l]);const a=e==="/new/guided-setup",i=["<dev_console_context>",a?"The developer is in the Guided Setup view.":"The developer is using the ADK Dev Console."];if(n&&i.push(`- Agent: ${n}`),i.push(`- Page: ${dJt(e)}`),a){const c=r.get("tab")||"map";i.push(`- Right panel tab: ${uJt[c]??c}`)}return i.push(`- URL: ${e+(t||"")}`),s&&i.push(`- Selected entity: ${s}`),o.length>0&&i.push(`- Filters: ${o.map(([c,l])=>`${c}=${l}`).join(", ")}`),i.push("</dev_console_context>"),i.join(`
1136
1136
  `)}function pJt(){const e=ui(),t=ds(r=>r.agent?.name??r.bot?.name??null);return{contextText:b.useMemo(()=>fJt(e.pathname,e.search,t),[e.pathname,e.search,t])}}function hJt(e,t){return e}function WFe(e){return e==="guided"?"guided":void 0}function mJt(e){if(!e)return;const t=e.indexOf("/");if(!(t<=0))return{providerId:e.slice(0,t),modelId:e.slice(t+1)}}function gJt(e){return typeof e=="object"&&e!==null}function yJt(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;if(gJt(e)){if(typeof e.message=="string")return e.message;if(typeof e.error=="string")return e.error;try{return JSON.stringify(e)}catch{return String(e)}}return String(e)}function bJt(e,t){const n=Vt.getState();n.removeMessage(e),n.upsertMessage(t.id,t.role,{completed:t.completed});for(const r of t.parts)n.upsertPart(t.id,r)}function vJt(e,t,n){const r=Vt(yI),s=Vt(h=>h.addUserMessage),o=Vt(h=>h.selectedModel),{contextText:a}=pJt(),{track:i}=lf(),c=b.useRef(!1),l=b.useCallback(async()=>{const h=Vt.getState().sessionId;if(h)return h;if(!t)return null;const g=await t();return g?(await new Promise(y=>{const E=()=>Vt.getState().sseStatus==="connected";if(E()){y();return}const x=Vt.subscribe(()=>{E()&&(x(),y())});setTimeout(()=>{x(),y()},5e3)}),g):null},[t]),d=b.useCallback(async({analytics:h,execute:g,optimisticText:y})=>{if(!e||r||c.current)return;c.current=!0;let E=null;try{const x=await l();if(!x)return;E=`optimistic-${crypto.randomUUID()}`,i("agent0.message_sent",h()),s(E,y);const w=mJt(o),S=WFe(n),T=await g(e,x,{...w?{model:w}:{},...S?{mode:S}:{}});bJt(E,T)}catch(x){const w=Vt.getState(),S=yJt(x);E&&w.removeMessage(E),aPe(x)&&console.debug("[agent0] Backend temporarily unavailable while sending message:",x),w.upsertMessage(`err-${crypto.randomUUID()}`,"assistant",{error:S,completed:!0}),i("agent0.error",{error_type:"send_failed",error_message:S.slice(0,500)})}finally{c.current=!1}},[e,r,l,i,s,o,n]),f=b.useCallback(async(h,g)=>{if(h.length===0)return;const E=h.filter(w=>w.type==="text").map(w=>"text"in w?w.text:"").join(`
1137
1137
  `),x=a?[{type:"text",text:a,synthetic:!0},...h]:h;await d({analytics:()=>({has_context:!!a,has_attachments:h.some(w=>w.type==="file"),is_command:!1,message_content:xW(E.slice(0,2e3)),message_length:E.length,message_index:Vt.getState().messages.filter(w=>w.role==="user").length}),execute:(w,S,T)=>w.sendMessage(S,{parts:x,...T}),optimisticText:g||"(message)"})},[a,d]),p=b.useCallback(async(h,g,y)=>{await d({analytics:()=>({has_context:!1,has_attachments:!1,is_command:!0,command_name:h,message_content:xW(`/${h} ${g}`.trim().slice(0,2e3)),message_length:g.length,message_index:Vt.getState().messages.filter(E=>E.role==="user").length}),execute:(E,x,w)=>E.runCommand(x,{command:h,arguments:g,...w}),optimisticText:y})},[d]);return{sendMessage:f,sendCommand:p,isSending:c}}const xJt=[{name:"clear",description:"Start a new session",hints:[],local:!0}];function EJt(e){const[t,n]=b.useState([]);b.useEffect(()=>{if(!e)return;let s=!1;return e.listCommands().then(o=>{s||n([...o,...xJt])}).catch(()=>{}),()=>{s=!0}},[e]);const r=b.useCallback(s=>{if(!s.startsWith("/"))return[];const o=s.slice(1),a=o.indexOf(" "),i=a===-1?o.toLowerCase():o.slice(0,a).toLowerCase();return a!==-1&&t.some(c=>c.name===i)?[]:t.filter(c=>c.name.toLowerCase().startsWith(i))},[t]);return{commands:t,matchCommands:r}}function wJt(e){const t=e.match(/^\/([a-zA-Z0-9_-]+)\s*(.*)$/);return t?{name:t[1],args:t[2]?.trim()||""}:null}const SJt=b.memo(function({items:t,selectedIndex:n,onSelect:r,onHover:s,query:o}){const a=b.useRef(null);return b.useEffect(()=>{a.current?.scrollIntoView({block:"nearest"})},[n]),t.length===0?u.jsx("div",{className:"text-muted-foreground px-2 py-1 text-[11px]",children:o?u.jsxs(u.Fragment,{children:["No commands match “",o,"”"]}):"No commands available"}):u.jsx("div",{className:"max-h-[240px] overflow-y-auto",children:t.map((i,c)=>{const l=c===n;return u.jsxs("button",{ref:l?a:void 0,onMouseDown:d=>{d.preventDefault(),r(i.id)},onMouseEnter:()=>s(c),className:me("flex w-full items-center gap-2 rounded-md px-2 py-1 text-left text-[11px]",l&&"bg-accent"),children:[u.jsx("span",{className:"text-foreground whitespace-nowrap",children:i.label}),i.description&&u.jsx("span",{className:"text-muted-foreground truncate",children:i.description})]},i.id)})})});var G0e=1,_Jt=.9,TJt=.8,AJt=.17,Nz=.1,Iz=.999,kJt=.9999,CJt=.99,NJt=/[\\\/_+.#"@\[\(\{&]/,IJt=/[\\\/_+.#"@\[\(\{&]/g,RJt=/[\s-]/,KFe=/[\s-]/g;function DK(e,t,n,r,s,o,a){if(o===t.length)return s===e.length?G0e:CJt;var i=`${s},${o}`;if(a[i]!==void 0)return a[i];for(var c=r.charAt(o),l=n.indexOf(c,s),d=0,f,p,h,g;l>=0;)f=DK(e,t,n,r,l+1,o+1,a),f>d&&(l===s?f*=G0e:NJt.test(e.charAt(l-1))?(f*=TJt,h=e.slice(s,l-1).match(IJt),h&&s>0&&(f*=Math.pow(Iz,h.length))):RJt.test(e.charAt(l-1))?(f*=_Jt,g=e.slice(s,l-1).match(KFe),g&&s>0&&(f*=Math.pow(Iz,g.length))):(f*=AJt,s>0&&(f*=Math.pow(Iz,l-s))),e.charAt(l)!==t.charAt(o)&&(f*=kJt)),(f<Nz&&n.charAt(l-1)===r.charAt(o+1)||r.charAt(o+1)===r.charAt(o)&&n.charAt(l-1)!==r.charAt(o))&&(p=DK(e,t,n,r,l+1,o+2,a),p*Nz>f&&(f=p*Nz)),f>d&&(d=f),l=n.indexOf(c,l+1);return a[i]=d,d}function W0e(e){return e.toLowerCase().replace(KFe," ")}function jJt(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,DK(e,t,W0e(e),W0e(t),0,0,{})}var DJt=Symbol.for("react.lazy"),BP=sd[" use ".trim().toString()];function OJt(e){return typeof e=="object"&&e!==null&&"then"in e}function ZFe(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===DJt&&"_payload"in e&&OJt(e._payload)}function MJt(e){const t=PJt(e),n=b.forwardRef((r,s)=>{let{children:o,...a}=r;ZFe(o)&&typeof BP=="function"&&(o=BP(o._payload));const i=b.Children.toArray(o),c=i.find(LJt);if(c){const l=c.props.children,d=i.map(f=>f===c?b.Children.count(l)>1?b.Children.only(null):b.isValidElement(l)?l.props.children:null:f);return u.jsx(t,{...a,ref:s,children:b.isValidElement(l)?b.cloneElement(l,void 0,d):null})}return u.jsx(t,{...a,ref:s,children:o})});return n.displayName=`${e}.Slot`,n}function PJt(e){const t=b.forwardRef((n,r)=>{let{children:s,...o}=n;if(ZFe(s)&&typeof BP=="function"&&(s=BP(s._payload)),b.isValidElement(s)){const a=BJt(s),i=FJt(o,s.props);return s.type!==b.Fragment&&(i.ref=r?Zd(r,a):a),b.cloneElement(s,i)}return b.Children.count(s)>1?b.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var $Jt=Symbol("radix.slottable");function LJt(e){return b.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===$Jt}function FJt(e,t){const n={...t};for(const r in t){const s=e[r],o=t[r];/^on[A-Z]/.test(r)?s&&o?n[r]=(...i)=>{const c=o(...i);return s(...i),c}:s&&(n[r]=s):r==="style"?n[r]={...s,...o}:r==="className"&&(n[r]=[s,o].filter(Boolean).join(" "))}return{...e,...n}}function BJt(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var qJt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Zy=qJt.reduce((e,t)=>{const n=MJt(`Primitive.${t}`),r=b.forwardRef((s,o)=>{const{asChild:a,...i}=s,c=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(c,{...i,ref:o})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),kT='[cmdk-group=""]',Rz='[cmdk-group-items=""]',UJt='[cmdk-group-heading=""]',YFe='[cmdk-item=""]',K0e=`${YFe}:not([aria-disabled="true"])`,OK="cmdk-item-select",z1="data-value",zJt=(e,t,n)=>jJt(e,t,n),QFe=b.createContext(void 0),MI=()=>b.useContext(QFe),XFe=b.createContext(void 0),_ee=()=>b.useContext(XFe),JFe=b.createContext(void 0),e3e=b.forwardRef((e,t)=>{let n=H1(()=>{var V,I;return{search:"",value:(I=(V=e.value)!=null?V:e.defaultValue)!=null?I:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=H1(()=>new Set),s=H1(()=>new Map),o=H1(()=>new Map),a=H1(()=>new Set),i=t3e(e),{label:c,children:l,value:d,onValueChange:f,filter:p,shouldFilter:h,loop:g,disablePointerSelection:y=!1,vimBindings:E=!0,...x}=e,w=ci(),S=ci(),T=ci(),k=b.useRef(null),A=e7t();ev(()=>{if(d!==void 0){let V=d.trim();n.current.value=V,N.emit()}},[d]),ev(()=>{A(6,B)},[]);let N=b.useMemo(()=>({subscribe:V=>(a.current.add(V),()=>a.current.delete(V)),snapshot:()=>n.current,setState:(V,I,J)=>{var te,X,ne,re;if(!Object.is(n.current[V],I)){if(n.current[V]=I,V==="search")U(),D(),A(1,L);else if(V==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let se=document.getElementById(T);se?se.focus():(te=document.getElementById(w))==null||te.focus()}if(A(7,()=>{var se;n.current.selectedItemId=(se=M())==null?void 0:se.id,N.emit()}),J||A(5,B),((X=i.current)==null?void 0:X.value)!==void 0){let se=I??"";(re=(ne=i.current).onValueChange)==null||re.call(ne,se);return}}N.emit()}},emit:()=>{a.current.forEach(V=>V())}}),[]),j=b.useMemo(()=>({value:(V,I,J)=>{var te;I!==((te=o.current.get(V))==null?void 0:te.value)&&(o.current.set(V,{value:I,keywords:J}),n.current.filtered.items.set(V,O(I,J)),A(2,()=>{D(),N.emit()}))},item:(V,I)=>(r.current.add(V),I&&(s.current.has(I)?s.current.get(I).add(V):s.current.set(I,new Set([V]))),A(3,()=>{U(),D(),n.current.value||L(),N.emit()}),()=>{o.current.delete(V),r.current.delete(V),n.current.filtered.items.delete(V);let J=M();A(4,()=>{U(),J?.getAttribute("id")===V&&L(),N.emit()})}),group:V=>(s.current.has(V)||s.current.set(V,new Set),()=>{o.current.delete(V),s.current.delete(V)}),filter:()=>i.current.shouldFilter,label:c||e["aria-label"],getDisablePointerSelection:()=>i.current.disablePointerSelection,listId:w,inputId:T,labelId:S,listInnerRef:k}),[]);function O(V,I){var J,te;let X=(te=(J=i.current)==null?void 0:J.filter)!=null?te:zJt;return V?X(V,n.current.search,I):0}function D(){if(!n.current.search||i.current.shouldFilter===!1)return;let V=n.current.filtered.items,I=[];n.current.filtered.groups.forEach(te=>{let X=s.current.get(te),ne=0;X.forEach(re=>{let se=V.get(re);ne=Math.max(se,ne)}),I.push([te,ne])});let J=k.current;$().sort((te,X)=>{var ne,re;let se=te.getAttribute("id"),ce=X.getAttribute("id");return((ne=V.get(ce))!=null?ne:0)-((re=V.get(se))!=null?re:0)}).forEach(te=>{let X=te.closest(Rz);X?X.appendChild(te.parentElement===X?te:te.closest(`${Rz} > *`)):J.appendChild(te.parentElement===J?te:te.closest(`${Rz} > *`))}),I.sort((te,X)=>X[1]-te[1]).forEach(te=>{var X;let ne=(X=k.current)==null?void 0:X.querySelector(`${kT}[${z1}="${encodeURIComponent(te[0])}"]`);ne?.parentElement.appendChild(ne)})}function L(){let V=$().find(J=>J.getAttribute("aria-disabled")!=="true"),I=V?.getAttribute(z1);N.setState("value",I||void 0)}function U(){var V,I,J,te;if(!n.current.search||i.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let X=0;for(let ne of r.current){let re=(I=(V=o.current.get(ne))==null?void 0:V.value)!=null?I:"",se=(te=(J=o.current.get(ne))==null?void 0:J.keywords)!=null?te:[],ce=O(re,se);n.current.filtered.items.set(ne,ce),ce>0&&X++}for(let[ne,re]of s.current)for(let se of re)if(n.current.filtered.items.get(se)>0){n.current.filtered.groups.add(ne);break}n.current.filtered.count=X}function B(){var V,I,J;let te=M();te&&(((V=te.parentElement)==null?void 0:V.firstChild)===te&&((J=(I=te.closest(kT))==null?void 0:I.querySelector(UJt))==null||J.scrollIntoView({block:"nearest"})),te.scrollIntoView({block:"nearest"}))}function M(){var V;return(V=k.current)==null?void 0:V.querySelector(`${YFe}[aria-selected="true"]`)}function $(){var V;return Array.from(((V=k.current)==null?void 0:V.querySelectorAll(K0e))||[])}function P(V){let I=$()[V];I&&N.setState("value",I.getAttribute(z1))}function q(V){var I;let J=M(),te=$(),X=te.findIndex(re=>re===J),ne=te[X+V];(I=i.current)!=null&&I.loop&&(ne=X+V<0?te[te.length-1]:X+V===te.length?te[0]:te[X+V]),ne&&N.setState("value",ne.getAttribute(z1))}function z(V){let I=M(),J=I?.closest(kT),te;for(;J&&!te;)J=V>0?XJt(J,kT):JJt(J,kT),te=J?.querySelector(K0e);te?N.setState("value",te.getAttribute(z1)):q(V)}let G=()=>P($().length-1),R=V=>{V.preventDefault(),V.metaKey?G():V.altKey?z(1):q(1)},W=V=>{V.preventDefault(),V.metaKey?P(0):V.altKey?z(-1):q(-1)};return b.createElement(Zy.div,{ref:t,tabIndex:-1,...x,"cmdk-root":"",onKeyDown:V=>{var I;(I=x.onKeyDown)==null||I.call(x,V);let J=V.nativeEvent.isComposing||V.keyCode===229;if(!(V.defaultPrevented||J))switch(V.key){case"n":case"j":{E&&V.ctrlKey&&R(V);break}case"ArrowDown":{R(V);break}case"p":case"k":{E&&V.ctrlKey&&W(V);break}case"ArrowUp":{W(V);break}case"Home":{V.preventDefault(),P(0);break}case"End":{V.preventDefault(),G();break}case"Enter":{V.preventDefault();let te=M();if(te){let X=new Event(OK);te.dispatchEvent(X)}}}}},b.createElement("label",{"cmdk-label":"",htmlFor:j.inputId,id:j.labelId,style:n7t},c),X5(e,V=>b.createElement(XFe.Provider,{value:N},b.createElement(QFe.Provider,{value:j},V))))}),HJt=b.forwardRef((e,t)=>{var n,r;let s=ci(),o=b.useRef(null),a=b.useContext(JFe),i=MI(),c=t3e(e),l=(r=(n=c.current)==null?void 0:n.forceMount)!=null?r:a?.forceMount;ev(()=>{if(!l)return i.item(s,a?.id)},[l]);let d=n3e(s,o,[e.value,e.children,o],e.keywords),f=_ee(),p=Sy(A=>A.value&&A.value===d.current),h=Sy(A=>l||i.filter()===!1?!0:A.search?A.filtered.items.get(s)>0:!0);b.useEffect(()=>{let A=o.current;if(!(!A||e.disabled))return A.addEventListener(OK,g),()=>A.removeEventListener(OK,g)},[h,e.onSelect,e.disabled]);function g(){var A,N;y(),(N=(A=c.current).onSelect)==null||N.call(A,d.current)}function y(){f.setState("value",d.current,!0)}if(!h)return null;let{disabled:E,value:x,onSelect:w,forceMount:S,keywords:T,...k}=e;return b.createElement(Zy.div,{ref:Zd(o,t),...k,id:s,"cmdk-item":"",role:"option","aria-disabled":!!E,"aria-selected":!!p,"data-disabled":!!E,"data-selected":!!p,onPointerMove:E||i.getDisablePointerSelection()?void 0:y,onClick:E?void 0:g},e.children)}),VJt=b.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:s,...o}=e,a=ci(),i=b.useRef(null),c=b.useRef(null),l=ci(),d=MI(),f=Sy(h=>s||d.filter()===!1?!0:h.search?h.filtered.groups.has(a):!0);ev(()=>d.group(a),[]),n3e(a,i,[e.value,e.heading,c]);let p=b.useMemo(()=>({id:a,forceMount:s}),[s]);return b.createElement(Zy.div,{ref:Zd(i,t),...o,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},n&&b.createElement("div",{ref:c,"cmdk-group-heading":"","aria-hidden":!0,id:l},n),X5(e,h=>b.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?l:void 0},b.createElement(JFe.Provider,{value:p},h))))}),GJt=b.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,s=b.useRef(null),o=Sy(a=>!a.search);return!n&&!o?null:b.createElement(Zy.div,{ref:Zd(s,t),...r,"cmdk-separator":"",role:"separator"})}),WJt=b.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,s=e.value!=null,o=_ee(),a=Sy(l=>l.search),i=Sy(l=>l.selectedItemId),c=MI();return b.useEffect(()=>{e.value!=null&&o.setState("search",e.value)},[e.value]),b.createElement(Zy.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":i,id:c.inputId,type:"text",value:s?e.value:a,onChange:l=>{s||o.setState("search",l.target.value),n?.(l.target.value)}})}),KJt=b.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...s}=e,o=b.useRef(null),a=b.useRef(null),i=Sy(l=>l.selectedItemId),c=MI();return b.useEffect(()=>{if(a.current&&o.current){let l=a.current,d=o.current,f,p=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let h=l.offsetHeight;d.style.setProperty("--cmdk-list-height",h.toFixed(1)+"px")})});return p.observe(l),()=>{cancelAnimationFrame(f),p.unobserve(l)}}},[]),b.createElement(Zy.div,{ref:Zd(o,t),...s,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":i,"aria-label":r,id:c.listId},X5(e,l=>b.createElement("div",{ref:Zd(a,c.listInnerRef),"cmdk-list-sizer":""},l)))}),ZJt=b.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:s,contentClassName:o,container:a,...i}=e;return b.createElement(g5,{open:n,onOpenChange:r},b.createElement(y5,{container:a},b.createElement(iI,{"cmdk-overlay":"",className:s}),b.createElement(lI,{"aria-label":e.label,"cmdk-dialog":"",className:o},b.createElement(e3e,{ref:t,...i}))))}),YJt=b.forwardRef((e,t)=>Sy(n=>n.filtered.count===0)?b.createElement(Zy.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),QJt=b.forwardRef((e,t)=>{let{progress:n,children:r,label:s="Loading...",...o}=e;return b.createElement(Zy.div,{ref:t,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":s},X5(e,a=>b.createElement("div",{"aria-hidden":!0},a)))}),Gv=Object.assign(e3e,{List:KJt,Item:HJt,Input:WJt,Group:VJt,Separator:GJt,Dialog:ZJt,Empty:YJt,Loading:QJt});function XJt(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function JJt(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function t3e(e){let t=b.useRef(e);return ev(()=>{t.current=e}),t}var ev=typeof window>"u"?b.useEffect:b.useLayoutEffect;function H1(e){let t=b.useRef();return t.current===void 0&&(t.current=e()),t}function Sy(e){let t=_ee(),n=()=>e(t.snapshot());return b.useSyncExternalStore(t.subscribe,n,n)}function n3e(e,t,n,r=[]){let s=b.useRef(),o=MI();return ev(()=>{var a;let i=(()=>{var l;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(l=d.current.textContent)==null?void 0:l.trim():s.current}})(),c=r.map(l=>l.trim());o.value(e,i,c),(a=t.current)==null||a.setAttribute(z1,i),s.current=i}),s}var e7t=()=>{let[e,t]=b.useState(),n=H1(()=>new Map);return ev(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,s)=>{n.current.set(r,s),t({})}};function t7t(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function X5({asChild:e,children:t},n){return e&&b.isValidElement(t)?b.cloneElement(t7t(t),{ref:t.ref},n(t.props.children)):n(t)}var n7t={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function r3e(e){return Vn({queryKey:["agent0-sessions"],queryFn:async()=>e?(await e.listSessions()).slice(0,20):[],enabled:!!e,staleTime:3e4,retry:1})}function r7t(e){return Vn({queryKey:["agent0-model"],queryFn:async()=>null,enabled:!!e,staleTime:6e4,retry:1})}function s3e(e){const{apiUrl:t}=wn(),n=bt(r=>r.selectedAgentPath);return Vn({queryKey:["agent0-available-models",n,e?"runtime":"catalog"],queryFn:async()=>{let r;if(e)r=await e.listModels();else{const a=await fetch(t("/api/agent0/models"));if(!a.ok)throw new Error("Failed to fetch agent0 models");r=(await a.json()).models}const s=[],o=new Map;for(const a of r){s.push({id:`${a.providerId}/${a.modelId}`,providerId:a.providerId,name:a.name||a.modelId});const i=o.get(a.providerId);i?i.modelCount+=1:o.set(a.providerId,{id:a.providerId,name:a.providerName||a.providerId,modelCount:1})}return{models:s,providers:[...o.values()],connected:[...o.keys()],defaultModel:s[0]?.id??null}},enabled:!!e||!!n,staleTime:6e4,retry:1})}const Cg=od((e,t)=>({value:0,quota:0,period:"",lastFetched:null,status:"idle",error:null,_fetchVersion:0,fetch:async n=>{if(!n.workspaceId)return;const r=t()._fetchVersion;e({status:t().lastFetched?"ready":"loading"});try{const s=await sS({token:n.token,botId:n.devBotId??"",apiUrl:n.apiUrl,workspaceId:n.workspaceId}),{usage:o}=await s.getUsage({id:n.workspaceId,type:"ai_spend"});if(t()._fetchVersion!==r)return;e({value:o.value/1e9,quota:o.quota/1e9,period:o.period,lastFetched:Date.now(),status:"ready",error:null})}catch(s){if(t()._fetchVersion!==r)return;e({status:"error",error:s instanceof Error?s.message:String(s)})}},reset:()=>e(n=>({value:0,quota:0,period:"",lastFetched:null,status:"idle",error:null,_fetchVersion:n._fetchVersion+1}))})),s7t=3e4;function o7t(e){b.useEffect(()=>{if(!e?.workspaceId||!e?.token)return;Cg.getState().fetch(e);const n=setInterval(()=>Cg.getState().fetch(e),s7t);return()=>{clearInterval(n),Cg.getState().reset()}},[e?.workspaceId,e?.token])}const MK=15.5,kk=2*Math.PI*MK,Z0e="w-72 rounded-lg border border-muted-foreground/15 bg-popover p-1 text-popover-foreground shadow-xl",Y0e=16;function a7t(e){return e>=.9?"var(--color-red-500)":e>=.75?"var(--color-orange-500)":"var(--color-blue-500)"}function i7t(e){const[t,n]=e.split("-").map(Number);if(!t||!n||n<1||n>12)return e;const r=new Date(t,n,1);return r.toLocaleDateString(void 0,{month:"short",day:"numeric",...r.getFullYear()===new Date().getFullYear()?{}:{year:"numeric"}})}function jz({pct:e,offset:t,color:n,className:r="size-3",state:s="ready"}){return u.jsxs("svg",{viewBox:"0 0 36 36",className:r,children:[u.jsx("circle",{cx:"18",cy:"18",r:MK,fill:"none",className:"stroke-muted-foreground/15",strokeWidth:"6"}),e>0&&u.jsx("circle",{cx:"18",cy:"18",r:MK,fill:"none",stroke:n,strokeWidth:"6",strokeLinecap:"round",strokeDasharray:kk,strokeDashoffset:t??kk*(1-e),transform:"rotate(-90 18 18)",style:{transition:"stroke-dashoffset 600ms ease-out"}}),s==="error"&&u.jsx("circle",{cx:"18",cy:"18",r:"3.5",className:"fill-red-500/70"})]})}function l7t({resolvedModel:e}){const t=Cg(x=>x.value),n=Cg(x=>x.quota),r=Cg(x=>x.period),s=Cg(x=>x.status),o=Cg(x=>x.error),a=e?.startsWith("cognitive/")??!1,[i,c]=b.useState(kk),l=n>0?Math.min(t/n,1):0,d=kk*(1-l),f=a7t(l);if(b.useEffect(()=>{if(s!=="ready"||t<=0){c(kk);return}const x=requestAnimationFrame(()=>c(d));return()=>cancelAnimationFrame(x)},[s,t,d]),!a)return null;if(s!=="ready"){const x=s==="error",w=x?"Workspace usage unavailable":"Loading workspace usage",S=x?o??"Usage could not be loaded.":"Monthly workspace usage is loading.";return u.jsxs(vn,{children:[u.jsx(xn,{asChild:!0,children:u.jsx("div",{className:`flex size-6 shrink-0 cursor-default items-center justify-center rounded-full transition-colors hover:bg-muted-foreground/10 ${x?"":"animate-pulse"}`,children:u.jsx(jz,{pct:0,color:x?"var(--color-red-500)":"var(--muted-foreground)",className:"size-3.5",state:x?"error":"loading"})})}),u.jsxs(yn,{side:"top",sideOffset:8,collisionPadding:Y0e,hideArrow:!0,className:Z0e,children:[u.jsx("div",{className:"px-1 pb-1 select-none",children:u.jsx("span",{className:"text-[10px] font-medium text-muted-foreground/50",children:"Workspace AI usage"})}),u.jsxs("div",{className:"rounded-md bg-muted-foreground/10 px-2.5 py-2",children:[u.jsx("div",{className:"text-[13px] font-semibold text-foreground",children:w}),u.jsx("div",{className:"mt-0.5 text-[11px] text-muted-foreground/65",children:S})]})]})]})}const p=n>0?Math.round(l*100):null,h=p!=null?Math.max(100-p,0):null,g=r?i7t(r):null,y=[h!=null?`${h}% remaining`:null,g?`resets ${g}`:null].filter(Boolean),E=y.length>0?y.join(", "):"Monthly usage";return u.jsxs(vn,{children:[u.jsx(xn,{asChild:!0,children:u.jsx("div",{className:"flex size-6 shrink-0 cursor-default items-center justify-center rounded-full transition-colors hover:bg-muted-foreground/10",children:u.jsx(jz,{pct:l,offset:i,color:f,className:"size-3.5"})})}),u.jsxs(yn,{side:"top",sideOffset:8,collisionPadding:Y0e,hideArrow:!0,className:Z0e,children:[u.jsx("div",{className:"px-1 pb-1 select-none",children:u.jsx("span",{className:"text-[10px] font-medium text-muted-foreground/50",children:"Workspace AI usage"})}),u.jsx("div",{className:"rounded-md bg-muted-foreground/10 px-2.5 py-2",children:u.jsxs("div",{className:"flex items-center gap-2.5",children:[u.jsx("div",{className:"flex size-8 shrink-0 items-center justify-center",children:u.jsx(jz,{pct:l,color:f,className:"size-8"})}),u.jsxs("div",{className:"min-w-0 flex-1",children:[u.jsx("div",{className:"truncate text-[14px] font-semibold tabular-nums text-foreground",children:p!=null?`${p}% used`:"Usage tracked"}),u.jsx("div",{className:"mt-0.5 truncate text-[11px] text-muted-foreground/65",children:E})]})]})})]})]})}function c7t({className:e}){const t=Vt(a=>a.messages),n=Vt(a=>a.settings.showTokens),r=Vt(a=>a.settings.showCost),s=b.useMemo(()=>{let a=0,i=0;for(const c of t)c.role==="assistant"&&(c.tokens&&(a+=c.tokens.input+c.tokens.output),c.cost&&(i+=c.cost));return{totalTokens:a,totalCost:i}},[t]);return n&&s.totalTokens>0||r&&s.totalCost>0?u.jsxs("div",{className:me("min-w-0 shrink truncate text-right text-[10px] tabular-nums text-muted-foreground/40",e),children:[n&&s.totalTokens>0&&u.jsxs("span",{children:[IBt(s.totalTokens)," tokens"]}),n&&s.totalTokens>0&&r&&s.totalCost>0&&u.jsx("span",{className:"mx-1.5",children:"·"}),r&&s.totalCost>0&&u.jsxs("span",{children:["$",s.totalCost.toFixed(4)]})]}):null}function o3e({className:e,...t}){return u.jsx(Gv,{"data-slot":"command",className:me("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t})}function u7t({className:e,...t}){return u.jsx("div",{"data-slot":"command-input-wrapper",className:"flex h-9 items-center border-b px-3",children:u.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[u.jsx(ea,{className:"size-4 shrink-0 opacity-50"}),u.jsx(Gv.Input,{"data-slot":"command-input",className:me("flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]})})}function a3e({className:e,...t}){return u.jsx(Gv.List,{"data-slot":"command-list",className:me("max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",e),...t})}function i3e({...e}){return u.jsx(Gv.Empty,{"data-slot":"command-empty",className:"py-6 text-center text-sm",...e})}function _A({className:e,...t}){return u.jsx(Gv.Group,{"data-slot":"command-group",className:me("overflow-hidden p-1 text-foreground **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground",e),...t})}function TA({className:e,...t}){return u.jsx(Gv.Item,{"data-slot":"command-item",className:me("relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground",e),...t})}function d7t(e){return e.split("/").pop()||e}function l3e({client:e,disabled:t=!1,modelId:n,modelLabel:r,showUsage:s=!0}){const[o,a]=b.useState(!1),i=b.useRef(null),c=Vt(B=>B.messages),l=Vt(B=>B.selectedModel),d=Vt(B=>B.setSelectedModel),f=Vt(B=>B.setProvidersDialogOpen),{data:p}=r7t(e),{data:h,isLoading:g}=s3e(e),y=b.useMemo(()=>{for(let B=c.length-1;B>=0;B--)if(c[B].role==="assistant"&&c[B].modelId)return c[B].modelId;return null},[c]),E=h?.defaultModel??null,x=n||l||p||E||y,w=b.useMemo(()=>x?h?.models?.find(B=>B.id===x||B.id.endsWith(`/${x}`))??null:null,[x,h?.models]),S=b.useMemo(()=>x?r&&x===n?r:w?.name||d7t(x):null,[n,r,x,w]),T=w?.providerId??(x?.includes("/")?x.split("/")[0]:null),k=h?.providers??[],A=h?.models??[],N=new Map(k.map(B=>[B.id,B])),j=T?N.get(T)??{id:T,name:T,modelCount:0}:null,O=B=>{t||(d(B),L(!1))},D=()=>{L(!1),f(!0)},L=B=>{t||a(B)};if(b.useEffect(()=>{if(!o)return;const B=window.setTimeout(()=>{i.current?.scrollIntoView({block:"center"})},0);return()=>window.clearTimeout(B)},[o,x]),!S)return null;const U=u.jsxs("button",{type:"button",className:me("flex items-center gap-1 rounded-full border border-border/30 bg-muted/30 px-2 py-0.5 text-[10px] text-muted-foreground/60 transition-colors duration-150",t?"cursor-not-allowed opacity-70":"hover:bg-muted/50 hover:text-muted-foreground"),disabled:t,"aria-label":t?`${S} model locked`:void 0,children:[j&&u.jsx(PC,{provider:j,className:"size-3.5 p-0.5 ring-border/40"}),u.jsx("span",{className:"truncate max-w-[120px]",children:S}),!t&&u.jsx(Dr,{className:me("size-2.5 shrink-0 transition-transform duration-200",o&&"rotate-180")})]});return u.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s&&!t&&u.jsx(c7t,{className:"max-w-[150px]"}),s&&!t&&u.jsx(l7t,{resolvedModel:x}),t?U:u.jsxs(Fv,{open:o,onOpenChange:L,children:[u.jsx(mS,{asChild:!0,children:U}),u.jsx(zy,{side:"top",align:"end",sideOffset:8,className:"w-80 p-0",children:u.jsxs(o3e,{children:[u.jsxs("div",{className:"flex h-8 items-center gap-2 border-b border-muted-foreground/15 px-3",children:[u.jsx(ea,{className:"size-3.5 shrink-0 text-muted-foreground/50"}),u.jsx(Gv.Input,{placeholder:"Search models",className:"flex h-full min-w-0 flex-1 bg-transparent text-[11px] outline-hidden placeholder:text-muted-foreground/50"}),u.jsxs("button",{type:"button",onClick:D,className:"-mr-1 flex shrink-0 items-center gap-1 rounded-sm px-1.5 py-1 text-[10px] text-muted-foreground/55 transition-colors hover:bg-muted/50 hover:text-foreground","aria-label":"Manage providers",children:[u.jsx(kJ,{className:"size-3"}),u.jsx("span",{children:"Manage"})]})]}),u.jsxs(a3e,{className:"max-h-[260px]",children:[u.jsx(i3e,{className:"text-[11px] text-muted-foreground/60 py-4 text-center",children:g?"Loading models...":"No models found."}),u.jsx(_A,{children:A.map(B=>{const M=B.id===x,$=N.get(B.providerId)??{id:B.providerId,name:B.providerId,modelCount:0};return u.jsxs(TA,{ref:M?i:void 0,value:`${B.name} ${B.id} ${$.name}`,onSelect:()=>O(B.id),className:"flex items-center justify-between gap-2 text-[11px]",children:[u.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[u.jsx(PC,{provider:$,className:"size-4 p-0.5 ring-border/40"}),u.jsx("span",{className:"min-w-0 flex-1 truncate",children:B.name}),u.jsx("span",{className:"shrink-0 text-[10px] text-muted-foreground/45",children:$.name})]}),M&&u.jsx(Xr,{className:"size-3 text-primary shrink-0"})]},B.id)})})]})]})})]})]})}function Q0e({label:e,checked:t,onChange:n}){const r=b.useId();return u.jsxs("div",{className:"flex h-8 items-center justify-between gap-3 rounded-sm px-2 text-[11px] text-muted-foreground transition-colors hover:bg-muted/35 hover:text-foreground",children:[u.jsx("span",{id:r,children:e}),u.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-labelledby":r,onClick:()=>n(!t),className:me("relative h-5 w-9 rounded-full transition-colors",t?"bg-blue-600":"bg-muted"),children:u.jsx("span",{className:me("absolute left-0.5 top-0.5 size-4 rounded-full bg-white transition-transform",t&&"translate-x-4")})})]})}function f7t(){const[e,t]=b.useState(!1),n=Vt(o=>o.settings),r=Vt(o=>o.updateSettings),s=n.showTokens||n.showCost;return u.jsxs(Fv,{open:e,onOpenChange:t,children:[u.jsxs(vn,{children:[u.jsx(xn,{asChild:!0,children:u.jsx(mS,{asChild:!0,children:u.jsx("button",{type:"button","aria-label":"Display settings",className:me("rounded-sm p-1 text-muted-foreground/45 transition-all duration-150 hover:scale-110 hover:text-muted-foreground active:scale-95",e&&"text-muted-foreground"),children:u.jsx(CJ,{className:"size-3.5"})})})}),u.jsx(yn,{children:"Display settings"})]}),u.jsxs(zy,{side:"top",align:"end",sideOffset:8,className:"w-48 p-1.5",children:[u.jsx("div",{className:"px-2 pb-1 pt-1 text-[10px] font-medium uppercase tracking-wider text-muted-foreground/45",children:"Display"}),u.jsx(Q0e,{label:"Show thinking",checked:n.showThinking,onChange:o=>r({showThinking:o})}),u.jsx(Q0e,{label:"Show usage",checked:s,onChange:o=>r({showTokens:o,showCost:o})})]})]})}function p7t({label:e,description:t,selected:n,onClick:r}){return u.jsx("button",{onClick:r,className:me("w-full text-left px-3 py-2 rounded-md text-[11px] transition-all duration-150",n?"bg-primary/10 ring-1 ring-primary/30 text-foreground":"bg-muted/20 hover:bg-muted/40 text-muted-foreground hover:text-foreground"),children:u.jsxs("div",{className:"flex items-start gap-2",children:[u.jsx("div",{className:me("size-3 rounded-full mt-0.5 shrink-0 flex items-center justify-center transition-colors",n?"bg-primary":"border border-muted-foreground/30"),children:n&&u.jsx(Xr,{className:"size-2 text-primary-foreground",strokeWidth:3})}),u.jsxs("div",{className:"min-w-0 flex-1",children:[u.jsx("div",{className:"font-medium",children:e}),t&&u.jsx("div",{className:"text-muted-foreground/70 mt-0.5",children:t})]})]})})}function h7t({current:e,total:t,header:n}){const r=t>1;return u.jsxs("div",{className:"flex items-center justify-between gap-3",children:[u.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] uppercase tracking-wider text-muted-foreground/55 font-medium min-w-0",children:[u.jsx(ADe,{className:"size-3 shrink-0"}),r&&u.jsxs("span",{className:"shrink-0",children:[e+1," of ",t]}),r&&n&&u.jsx("span",{className:"text-muted-foreground/30 shrink-0",children:"·"}),n&&u.jsx("span",{className:"truncate",children:n})]}),r&&u.jsx("div",{className:"flex items-center gap-1 shrink-0",children:Array.from({length:t}).map((s,o)=>u.jsx("div",{className:me("h-1 rounded-full transition-all duration-300",o===e?"w-3 bg-primary":o<e?"w-1 bg-primary/50":"w-1 bg-muted-foreground/20")},o))})]})}function m7t({question:e,selected:t,onSelect:n}){const r=s=>{e.multiple?n(t.includes(s)?t.filter(o=>o!==s):[...t,s]):n([s])};return u.jsxs("div",{className:"space-y-2",children:[u.jsx("div",{className:"text-[12px] text-foreground leading-relaxed",children:e.question}),u.jsx("div",{className:"space-y-1.5",children:e.options.map(s=>u.jsx(p7t,{label:s.label,description:s.description,selected:t.includes(s.label),onClick:()=>r(s.label)},s.label))})]})}const g7t={enter:e=>({opacity:0,x:e*16}),center:{opacity:1,x:0},exit:e=>({opacity:0,x:-e*16})};function y7t({request:e,client:t}){const[n,r]=b.useState(new Map),[s,o]=b.useState(0),[a,i]=b.useState(1),[c,l]=b.useState(!1),d=Vt(N=>N.setPendingQuestion),f=e.questions.length,p=e.questions[s];if(!p)return null;const h=s===f-1,g=n.get(s)??[],y=async N=>{if(!t||c)return;l(!0);const j=e.questions.map((O,D)=>N.get(D)||[]);try{await t.replyQuestion(e.sessionId,e.id,j),d(null)}catch(O){console.warn("[Agent0] Failed to submit answer:",O),l(!1)}},E=N=>{h?y(N):(i(1),o(j=>j+1))},x=N=>{const j=new Map(n).set(s,N);r(j),p.multiple||E(j)},w=()=>{s!==0&&(i(-1),o(N=>N-1))},S=()=>E(n),T=async()=>{if(!(!t||c))try{await t.rejectQuestion(e.sessionId,e.id),d(null)}catch(N){console.warn("[Agent0] Failed to reject question:",N)}},k=p.multiple,A=g.length>0&&!c;return u.jsxs("div",{className:"px-3 py-2.5 space-y-3",children:[u.jsx(h7t,{current:s,total:f,header:p.header}),u.jsx(Qi,{mode:"wait",custom:a,initial:!1,children:u.jsx(or.div,{custom:a,variants:g7t,initial:"enter",animate:"center",exit:"exit",transition:{duration:.25,ease:[.16,1,.3,1]},children:u.jsx(m7t,{question:p,selected:g,onSelect:x})},s)}),u.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[u.jsx("button",{onClick:T,className:"text-[11px] text-muted-foreground/50 hover:text-muted-foreground transition-colors shrink-0",children:"Skip"}),u.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s>0&&u.jsxs("button",{onClick:w,className:"flex items-center gap-1 px-2 h-6 rounded-full text-[11px] text-muted-foreground/70 hover:text-foreground hover:bg-muted/40 transition-colors",children:[u.jsx(dp,{className:"size-3"}),"Back"]}),k&&u.jsxs("button",{onClick:S,disabled:!A,className:me("flex items-center gap-1 px-2.5 h-6 rounded-full text-[11px] transition-all duration-150",A?"bg-primary text-primary-foreground hover:bg-primary/90 hover:scale-105 active:scale-95":"bg-muted-foreground/15 text-muted-foreground/40 cursor-not-allowed"),children:[u.jsx("span",{children:h?"Send":"Continue"}),h?u.jsx(Wu,{className:"size-3"}):u.jsx(Rv,{className:"size-3"})]})]})]})]})}function b7t(e,t){const n=e.trim(),r=[];n&&r.push({type:"text",text:n});for(const s of t)r.push({type:"file",mime:s.mime,url:s.url,filename:s.name});return r}function v7t(e){return e?typeof e=="string"?{text:e}:e:null}function Dz({client:e,ensureSession:t,placeholder:n,initialValue:r,initialAttachments:s,agent:o,shellStyle:a,disabled:i,size:c="sm",actionRow:l,onSubmit:d,canSubmit:f,containerClassName:p,shellClassName:h,rows:g=1}){const y=Vt(se=>se.sessionId),E=Vt(yI),x=Vt(se=>se.queuedPrompt),w=Vt(se=>se.setQueuedPrompt),S=Vt(se=>se.clearMessages),T=Vt(se=>se.pendingQuestion),k=Vt(se=>se.setSelectedModel),{sendMessage:A,sendCommand:N,isSending:j}=vJt(e,t,o),{commands:O,matchCommands:D}=EJt(e),[L,U]=b.useState(r??""),[B,M]=b.useState(s??[]),[$,P]=b.useState(0),[q,z]=b.useState(!1),G=b.useRef(null),R=b.useCallback(async(se,ce)=>{if(!se.trim()&&ce.length===0||j.current||f&&!f(se,ce))return;const ie=se.trim();if(d){j.current=!0;try{await d(ie,ce)}finally{j.current=!1}return}U(""),M([]),z(!1);const le=wJt(ie);if(le&&ce.length===0){if(le.name==="model"){const oe=le.args.trim();if(!oe)return;k(oe);return}if(le.name==="clear"){S();return}if(!O.some(oe=>oe.name===le.name)){Vt.getState().upsertMessage(`err-${crypto.randomUUID()}`,"assistant",{error:`Unknown command: /${le.name}`,completed:!0});return}await N(le.name,le.args,ie);return}await A(b7t(ie,ce),ie||"(attached files)")},[A,N,S,O,j,k,d,f]),W=b.useCallback(async()=>{await R(L,B)},[L,B,R]);b.useEffect(()=>{if(i)return;const se=Vt.getState().queuedPrompt;if(!se||se!==x)return;const ce=v7t(se);if(!ce||!e||E||j.current)return;const ie=(ce.attachments??[]).map(le=>({id:crypto.randomUUID(),name:le.name,mime:le.mime,url:le.url}));if(!ce.text.trim()&&ie.length===0){w(null);return}w(null),R(ce.text,ie)},[x,e,E,w,R,j,i]);const V=b.useCallback(async()=>{if(!(!e||!y))try{await e.abortSession(y)}catch(se){console.warn("[Agent0] Failed to abort session:",se)}},[e,y]),I=b.useMemo(()=>q?D(L).map(se=>({id:se.name,label:`/${se.name}`,description:se.description,local:se.local===!0})):[],[q,D,L]),J=b.useCallback(se=>{const ce=se.match(/^\/([a-zA-Z0-9_-]+)\s/);return!!ce&&O.some(ie=>ie.name===ce[1])},[O]),te=b.useMemo(()=>{if(!L.startsWith("/"))return"";const se=L.slice(1),ce=se.indexOf(" ");return ce===-1?se:se.slice(0,ce)},[L]),X=b.useCallback(se=>{U(`/${se} `),P(0),z(!1),requestAnimationFrame(()=>G.current?.focus())},[]),ne=b.useCallback(se=>{U(se),P(0),z(se.startsWith("/")&&!J(se))},[J]),re=T?u.jsx(y7t,{request:T,client:e}):void 0;return u.jsx(B7,{value:L,onChange:ne,attachments:B,onAttachmentsChange:M,placeholder:n,onSubmit:()=>W(),canSubmit:f,disabled:i,size:c,rows:g,containerClassName:p,shellClassName:h,shellStyle:a,actionRow:l,leftSlot:i?void 0:u.jsx(f7t,{}),modelSlot:i?void 0:u.jsx(l3e,{client:e}),pendingView:re,busy:E,onAbort:V,textareaRef:G,popupOpen:q&&!T,onPopupOpenChange:z,popupContent:u.jsx(SJt,{items:I,selectedIndex:$,onSelect:X,onHover:P,query:te}),onTextareaKeyDown:(se,ce)=>{if(I.length>0){if(se.key==="ArrowDown"){se.preventDefault(),P(ie=>Math.min(ie+1,I.length-1));return}if(se.key==="ArrowUp"){se.preventDefault(),P(ie=>Math.max(ie-1,0));return}if(se.key==="Enter"||se.key==="Tab"){se.preventDefault();const ie=I[$];ie&&X(ie.id);return}if(se.key==="Escape"){se.preventDefault(),se.stopPropagation(),z(!1);return}}se.key==="Enter"&&!se.shiftKey&&(se.preventDefault(),ce.submit())},onTextareaBlur:()=>{setTimeout(()=>{document.activeElement!==G.current&&z(!1)},0)},onTextareaFocus:()=>{L.startsWith("/")&&!J(L)&&z(!0)}})}function x7t({client:e,onNew:t,hasMessages:n=!0,agentPath:r}){const[s,o]=b.useState(!1),a=Vt(y=>y.setSessionId),i=Vt(y=>y.clearMessages),c=Vt(y=>y.trackSession),l=Vt(y=>r?y.agent0SessionIds[r]:void 0),{data:d=[],isLoading:f,refetch:p}=r3e(e),h=l?d.filter(y=>l.includes(y.id)):d,g=b.useCallback(y=>{i(),a(y),r&&c(r,y),o(!1)},[r,i,a,c]);return u.jsxs(Fv,{open:s,onOpenChange:y=>{o(y),y&&p()},children:[u.jsxs(vn,{children:[u.jsx(xn,{asChild:!0,children:u.jsx(mS,{asChild:!0,children:u.jsx("button",{className:"p-1 rounded-sm text-muted-foreground/50 hover:text-foreground hover:scale-110 active:scale-95 transition-all duration-150",children:u.jsx(id,{className:"size-3.5"})})})}),u.jsx(yn,{children:"Session history"})]}),u.jsxs(zy,{align:"end",className:"w-56 p-2",children:[u.jsxs("button",{onClick:()=>{t(),o(!1)},disabled:!n,className:"w-full flex items-center gap-1.5 px-2 py-1.5 text-[11px] rounded hover:bg-muted transition-colors text-muted-foreground disabled:opacity-30 disabled:pointer-events-none cursor-pointer",children:[u.jsx(ld,{className:"size-3"}),"New session"]}),f?u.jsx("div",{className:"flex items-center justify-center py-4",children:u.jsx(nn,{className:"size-3.5 animate-spin text-muted-foreground"})}):u.jsx("div",{className:"max-h-[200px] overflow-y-auto mt-1 space-y-0.5",children:h.map(y=>u.jsx("button",{onClick:()=>g(y.id),className:"w-full text-left px-2 py-1.5 text-[11px] rounded hover:bg-muted transition-colors truncate text-muted-foreground cursor-pointer",children:y.title||y.id.slice(0,12)},y.id))})]})]})}function E7t(e){let t=0;for(const n of e)for(const r of n.parts)r.type==="tool"&&t++;return t}function Oz(e){let t=0,n=0,r=0,s=0,o,a=!1;for(const i of e)i.role==="assistant"&&(i.tokens&&(t+=i.tokens.input,n+=i.tokens.output,r+=i.tokens.reasoning),i.cost&&(s+=i.cost),i.modelId&&(o=i.modelId),i.error&&(a=!0));return{tokensInput:t,tokensOutput:n,tokensReasoning:r,cost:s,modelId:o,hasError:a}}function w7t(e){const{track:t}=lf(),n=b.useRef(Vt.getState().sessionStatus),r=b.useRef(null);b.useEffect(()=>{e!==void 0&&!r.current&&(r.current={startedAt:e,lastModelId:void 0,hadErrors:!1})},[e]),b.useEffect(()=>{const s=Vt.subscribe((o,a)=>{const i=n.current,c=o.sessionStatus;if(n.current=c,(i==="busy"||i==="retry")&&c==="idle"){const l=jO(o.messages),d=l[l.length-1];if(!d)return;const f=Oz(d.assistantMessages),p=E7t(d.assistantMessages);t("agent0.turn_completed",{turn_index:l.length-1,duration_ms:d.durationMs,model_id:f.modelId,tokens_input:f.tokensInput||void 0,tokens_output:f.tokensOutput||void 0,tokens_reasoning:f.tokensReasoning||void 0,cost:f.cost||void 0,tool_call_count:p,has_error:f.hasError}),r.current?(f.modelId&&(r.current.lastModelId=f.modelId),f.hasError&&(r.current.hadErrors=!0)):r.current={startedAt:Date.now(),lastModelId:f.modelId,hadErrors:f.hasError}}if(a.messages.length>0&&o.messages.length===0&&r.current){const l=r.current,d=Oz(a.messages),f=jO(a.messages),p=a.messages.filter(h=>h.role==="user").length;t("agent0.session_summary",{turn_count:f.length,message_count:p,total_tokens:d.tokensInput+d.tokensOutput+d.tokensReasoning,total_cost:d.cost,duration_ms:Date.now()-l.startedAt,model_id:l.lastModelId,had_errors:l.hadErrors}),r.current=null}});return()=>{s();const o=r.current;if(!o)return;const{messages:a}=Vt.getState();if(a.length===0)return;const i=Oz(a),c=jO(a),l=a.filter(d=>d.role==="user").length;t("agent0.session_summary",{turn_count:c.length,message_count:l,total_tokens:i.tokensInput+i.tokensOutput+i.tokensReasoning,total_cost:i.cost,duration_ms:Date.now()-o.startedAt,model_id:o.lastModelId,had_errors:o.hadErrors}),r.current=null}},[t])}function S7t({client:e,runtimeReady:t,agentPath:n,agent:r}){const s=Vt($=>$.sessionId),o=Vt($=>$.setSessionId),a=Vt(yI),i=Vt($=>$.sseStatus),c=Vt($=>$.messages.length),l=Vt($=>$.clearMessages),d=Vt($=>$.trackSession),f=Vt($=>$.switchAgent),p=Vt($=>$.clearAgentSession),{track:h}=lf(),[g,y]=b.useState(void 0);w7t(g);const E=ds($=>$.credentials);o7t(E);const[x,w]=b.useState(null),[S,T]=b.useState(!1),{data:k,isLoading:A}=lc(),N=k,j=t??!!e,O=n??N?.agentPath??null,D=hJt(O);b.useEffect(()=>{if(j||A){T(!1);return}const $=setTimeout(()=>T(!0),6e3);return()=>clearTimeout($)},[j,A]);const L=b.useRef(null),U=b.useRef(D);U.current=D,b.useEffect(()=>{const $=L.current;$!==D&&(L.current=D,f($,D),w(null))},[D,f]);const B=b.useCallback(async()=>{if(!e)return null;const $=Vt.getState().messages.length>0,P=U.current,q=WFe(r);try{const z=await e.createSession({...q?{mode:q}:{}});return U.current!==P?null:z?.id?(o(z.id),P&&d(P,z.id),w(null),y(Date.now()),h("agent0.session_created",{has_existing_session:$,model_id:Vt.getState().selectedModel??void 0}),z.id):(w("Failed to create session"),null)}catch(z){if(U.current!==P)return null;const G=z instanceof Error?z.message:String(z);return aPe(z)?(console.debug("[agent0] Backend temporarily unavailable while creating session:",z),h("agent0.error",{error_type:"session_create_failed",error_message:G.slice(0,500)}),null):(w(`Connection failed: ${G}`),h("agent0.error",{error_type:"session_create_failed",error_message:G.slice(0,500)}),null)}},[r,e,o,d,h]),M=b.useCallback(()=>{l(),D&&p(D)},[l,D,p]);return b.useEffect(()=>{if(!s||!e||c!==0)return;const $=new AbortController,P=D;return(async()=>{try{const q=await QLe(e,s);if($.signal.aborted||!q)return;XLe(q)}catch{if($.signal.aborted)return;l(!0),P&&p(P)}})(),()=>$.abort()},[s,e,c,l,D,p]),{createSession:B,error:x,handleNewSession:M,isBusy:a,messageCount:c,sessionScope:D,sseStatus:i,waitedForPort:S}}function _7t({client:e,sseStatus:t}){const[n,r]=b.useState(!1);return u.jsxs("span",{className:"text-[11px] font-mono text-muted-foreground/50 flex-1 flex items-center gap-1.5 cursor-default",onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[u.jsx(xy,{className:"size-3.5",hovered:n,shape:"circle"}),u.jsx("span",{className:n?"thinking-shimmer":"",children:"agent0"}),e&&t==="disconnected"&&u.jsx("span",{className:"text-[9px] text-red-400/70 ml-1",children:"disconnected"}),e&&t==="reconnecting"&&u.jsx("span",{className:"text-[9px] text-orange-400/70 ml-1",children:"reconnecting"})]})}function CT({className:e}){return u.jsx("div",{className:me("rounded-md overflow-hidden relative",e),children:u.jsx("div",{className:"absolute inset-0 animate-shimmer"})})}function T7t(e){const t=new Date(e).getTime();if(Number.isNaN(t))return"";const n=Math.max(1,Math.floor((Date.now()-t)/6e4));if(n<60)return`${n}m`;const r=Math.floor(n/60);if(r<24)return`${r}h`;const s=Math.floor(r/24);if(s<30)return`${s}d`;const o=Math.floor(s/30);return o<12?`${o}mo`:`${Math.floor(o/12)}y`}function A7t({client:e,agentPath:t}){const[n,r]=b.useState(!1),s=Vt(p=>p.setSessionId),o=Vt(p=>p.clearMessages),a=Vt(p=>p.trackSession),i=Vt(p=>p.sessionId),c=Vt(p=>t?p.agent0SessionIds[t]:void 0),{data:l=[]}=r3e(e),d=(c?l.filter(p=>c.includes(p.id)):l).filter(p=>p.id!==i).map(p=>({id:p.id,title:p.title?.trim(),age:T7t(p.updatedAt)})).filter(p=>!!p.title);if(d.length===0)return null;const f=n?d:d.slice(0,3);return u.jsxs("section",{className:"mx-auto w-full max-w-2xl border-t border-muted-foreground/10 px-3 pb-5 pt-5",children:[u.jsxs("div",{className:"mb-2 flex items-baseline justify-between gap-4 px-2.5",children:[u.jsx("h2",{className:"h3",children:"Recent"}),d.length>3&&u.jsx("button",{type:"button",onClick:()=>r(p=>!p),className:"small text-muted-foreground/60 transition-colors hover:text-foreground",children:n?"Show less":"View all"})]}),u.jsx("div",{className:"grid gap-0.5",children:f.map(p=>u.jsxs("button",{type:"button","aria-label":p.age?`${p.title}, last active ${p.age} ago`:p.title,title:p.age?`${p.title} - last active ${p.age} ago`:p.title,onClick:()=>{o(),s(p.id),t&&a(t,p.id)},className:"body group grid grid-cols-[minmax(0,1fr)_auto] items-center gap-4 rounded-md px-2.5 py-1.5 text-left text-foreground/85 transition-colors hover:bg-accent hover:text-foreground",children:[u.jsx("span",{className:"truncate",children:p.title}),p.age&&u.jsx("span",{className:"small font-mono tabular-nums text-muted-foreground/50 transition-colors group-hover:text-muted-foreground/75",children:p.age})]},p.id))})]})}function k7t({client:e,error:t,waitedForPort:n,heroEmptyState:r,messageCount:s,isBusy:o,onRetry:a,ensureSession:i,agent:c,heroHeadline:l,heroSubhead:d,composerPlaceholder:f,composerInitialValue:p,composerInitialAttachments:h,composerShellStyle:g,composerPosition:y,composerRows:E,composerSize:x,sessionScope:w}){return!e&&n?u.jsx(ABt,{}):!e&&!t?r?u.jsxs("div",{className:"flex-1 flex flex-col justify-center px-6 max-w-2xl mx-auto w-full",children:[u.jsxs("div",{className:"mb-6 flex flex-col items-center gap-4",children:[u.jsx(CT,{className:"size-11 rounded-full bg-muted/30"}),u.jsx(CT,{className:"h-5 w-32 bg-muted/30"})]}),u.jsx(CT,{className:"h-20 rounded-lg bg-muted/20"})]}):u.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 px-6",children:[u.jsx(CT,{className:"size-11 rounded-full bg-muted/30"}),u.jsx(CT,{className:"h-3 w-28 bg-muted/30"})]}):t?u.jsx("div",{className:"flex-1 flex items-center justify-center p-4",children:u.jsxs("div",{className:"flex flex-col items-center gap-2",children:[u.jsx("div",{className:"size-3 animate-morph-pulse bg-red-500/60"}),u.jsx("p",{className:"text-[11px] text-red-400",children:t}),u.jsx(Pt,{variant:"ghost",size:"sm",className:"text-[11px] h-7",onClick:a,children:"Retry"})]})}):s===0&&!o?y==="bottom"?u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"relative flex-1 min-h-0",children:u.jsxs("div",{className:"min-h-full flex flex-col items-center justify-center px-6 animate-float-in",children:[u.jsx(uK,{hero:r,headline:l}),d!==null&&u.jsx("p",{className:"body mt-3 px-6 text-center leading-relaxed text-muted-foreground/55",children:d})]})}),u.jsx(Dz,{client:e,ensureSession:i,agent:c,placeholder:f,initialValue:p,initialAttachments:h,shellStyle:g,rows:E,size:x})]}):u.jsxs("div",{className:me("flex-1 flex flex-col w-full animate-float-in",r?"px-6 max-w-2xl mx-auto":"px-0"),children:[u.jsxs("div",{className:"flex flex-1 flex-col justify-center",children:[u.jsxs("div",{className:"mb-5",children:[u.jsx(uK,{hero:r,headline:l}),d!==null&&u.jsx("p",{className:"body mt-3 px-6 text-center leading-relaxed text-muted-foreground/55",children:d})]}),u.jsx(Dz,{client:e,ensureSession:i,agent:c,placeholder:f,initialValue:p,initialAttachments:h,shellStyle:g,rows:E,size:x})]}),u.jsx(A7t,{client:e,agentPath:w})]}):u.jsxs(u.Fragment,{children:[u.jsx(lJt,{heroEmptyState:r,headline:l}),u.jsx(Dz,{client:e,ensureSession:i,agent:c,placeholder:f,shellStyle:g,rows:E,size:x})]})}function c3e({client:e,showHeader:t=!0,heroEmptyState:n,runtimeReady:r,agentPath:s,agent:o,heroHeadline:a,heroSubhead:i,composerPlaceholder:c,composerInitialValue:l,composerInitialAttachments:d,composerShellStyle:f,composerPosition:p,composerRows:h,composerSize:g}){const{createSession:y,error:E,handleNewSession:x,isBusy:w,messageCount:S,sessionScope:T,sseStatus:k,waitedForPort:A}=S7t({agent:o,agentPath:s,client:e,runtimeReady:r});return u.jsxs("div",{className:"flex flex-col h-full min-h-0 relative",children:[t&&u.jsxs("div",{className:"flex items-center h-10 px-3 shrink-0",children:[u.jsx(_7t,{client:e,sseStatus:k}),u.jsxs("div",{className:"flex items-center gap-1",children:[u.jsxs(vn,{children:[u.jsx(xn,{asChild:!0,children:u.jsx("button",{type:"button",onClick:x,disabled:S===0,className:"p-1 rounded-sm text-muted-foreground/50 hover:text-foreground hover:scale-110 active:scale-95 transition-all duration-150 disabled:opacity-30 disabled:pointer-events-none",children:u.jsx(ld,{className:"size-3.5"})})}),u.jsx(yn,{children:"New session"})]}),u.jsx(x7t,{client:e,onNew:x,hasMessages:S>0,agentPath:T})]})]}),u.jsx(k7t,{client:e,error:E,waitedForPort:A,heroEmptyState:n,messageCount:S,isBusy:w,onRetry:y,ensureSession:y,agent:o,heroHeadline:a,heroSubhead:i,composerPlaceholder:c,composerInitialValue:l,composerInitialAttachments:d,composerShellStyle:f,composerPosition:p,composerRows:h,composerSize:g,sessionScope:T})]})}function C7t(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;const n=document.implementation.createHTMLDocument(),r=n.createElement("base"),s=n.createElement("a");return n.head.appendChild(r),n.body.appendChild(s),t&&(r.href=t),s.href=e,s.href}const N7t=(()=>{let e=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function Zg(e){const t=[];for(let n=0,r=e.length;n<r;n++)t.push(e[n]);return t}let r1=null;function u3e(e={}){return r1||(e.includeStyleProperties?(r1=e.includeStyleProperties,r1):(r1=Zg(window.getComputedStyle(document.documentElement)),r1))}function qP(e,t){const r=(e.ownerDocument.defaultView||window).getComputedStyle(e).getPropertyValue(t);return r?parseFloat(r.replace("px","")):0}function I7t(e){const t=qP(e,"border-left-width"),n=qP(e,"border-right-width");return e.clientWidth+t+n}function R7t(e){const t=qP(e,"border-top-width"),n=qP(e,"border-bottom-width");return e.clientHeight+t+n}function d3e(e,t={}){const n=t.width||I7t(e),r=t.height||R7t(e);return{width:n,height:r}}function j7t(){let e,t;try{t=process}catch{}const n=t&&t.env?t.env.devicePixelRatio:null;return n&&(e=parseInt(n,10),Number.isNaN(e)&&(e=1)),e||window.devicePixelRatio||1}const Yc=16384;function D7t(e){(e.width>Yc||e.height>Yc)&&(e.width>Yc&&e.height>Yc?e.width>e.height?(e.height*=Yc/e.width,e.width=Yc):(e.width*=Yc/e.height,e.height=Yc):e.width>Yc?(e.height*=Yc/e.width,e.width=Yc):(e.width*=Yc/e.height,e.height=Yc))}function UP(e){return new Promise((t,n)=>{const r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=n,r.crossOrigin="anonymous",r.decoding="async",r.src=e})}async function O7t(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function M7t(e,t,n){const r="http://www.w3.org/2000/svg",s=document.createElementNS(r,"svg"),o=document.createElementNS(r,"foreignObject");return s.setAttribute("width",`${t}`),s.setAttribute("height",`${n}`),s.setAttribute("viewBox",`0 0 ${t} ${n}`),o.setAttribute("width","100%"),o.setAttribute("height","100%"),o.setAttribute("x","0"),o.setAttribute("y","0"),o.setAttribute("externalResourcesRequired","true"),s.appendChild(o),o.appendChild(e),O7t(s)}const jc=(e,t)=>{if(e instanceof t)return!0;const n=Object.getPrototypeOf(e);return n===null?!1:n.constructor.name===t.name||jc(n,t)};function P7t(e){const t=e.getPropertyValue("content");return`${e.cssText} content: '${t.replace(/'|"/g,"")}';`}function $7t(e,t){return u3e(t).map(n=>{const r=e.getPropertyValue(n),s=e.getPropertyPriority(n);return`${n}: ${r}${s?" !important":""};`}).join(" ")}function L7t(e,t,n,r){const s=`.${e}:${t}`,o=n.cssText?P7t(n):$7t(n,r);return document.createTextNode(`${s}{${o}}`)}function X0e(e,t,n,r){const s=window.getComputedStyle(e,n),o=s.getPropertyValue("content");if(o===""||o==="none")return;const a=N7t();try{t.className=`${t.className} ${a}`}catch{return}const i=document.createElement("style");i.appendChild(L7t(a,n,s,r)),t.appendChild(i)}function F7t(e,t,n){X0e(e,t,":before",n),X0e(e,t,":after",n)}const J0e="application/font-woff",ebe="image/jpeg",B7t={woff:J0e,woff2:J0e,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:ebe,jpeg:ebe,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function q7t(e){const t=/\.([^./]*?)$/g.exec(e);return t?t[1]:""}function Tee(e){const t=q7t(e).toLowerCase();return B7t[t]||""}function U7t(e){return e.split(/,/)[1]}function PK(e){return e.search(/^(data:)/)!==-1}function z7t(e,t){return`data:${t};base64,${e}`}async function f3e(e,t,n){const r=await fetch(e,t);if(r.status===404)throw new Error(`Resource "${r.url}" not found`);const s=await r.blob();return new Promise((o,a)=>{const i=new FileReader;i.onerror=a,i.onloadend=()=>{try{o(n({res:r,result:i.result}))}catch(c){a(c)}},i.readAsDataURL(s)})}const Mz={};function H7t(e,t,n){let r=e.replace(/\?.*/,"");return n&&(r=e),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,"")),t?`[${t}]${r}`:r}async function Aee(e,t,n){const r=H7t(e,t,n.includeQueryParams);if(Mz[r]!=null)return Mz[r];n.cacheBust&&(e+=(/\?/.test(e)?"&":"?")+new Date().getTime());let s;try{const o=await f3e(e,n.fetchRequestInit,({res:a,result:i})=>(t||(t=a.headers.get("Content-Type")||""),U7t(i)));s=z7t(o,t)}catch(o){s=n.imagePlaceholder||"";let a=`Failed to fetch resource: ${e}`;o&&(a=typeof o=="string"?o:o.message),a&&console.warn(a)}return Mz[r]=s,s}async function V7t(e){const t=e.toDataURL();return t==="data:,"?e.cloneNode(!1):UP(t)}async function G7t(e,t){if(e.currentSrc){const o=document.createElement("canvas"),a=o.getContext("2d");o.width=e.clientWidth,o.height=e.clientHeight,a?.drawImage(e,0,0,o.width,o.height);const i=o.toDataURL();return UP(i)}const n=e.poster,r=Tee(n),s=await Aee(n,r,t);return UP(s)}async function W7t(e,t){var n;try{if(!((n=e?.contentDocument)===null||n===void 0)&&n.body)return await J5(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function K7t(e,t){return jc(e,HTMLCanvasElement)?V7t(e):jc(e,HTMLVideoElement)?G7t(e,t):jc(e,HTMLIFrameElement)?W7t(e,t):e.cloneNode(p3e(e))}const Z7t=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SLOT",p3e=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SVG";async function Y7t(e,t,n){var r,s;if(p3e(t))return t;let o=[];return Z7t(e)&&e.assignedNodes?o=Zg(e.assignedNodes()):jc(e,HTMLIFrameElement)&&(!((r=e.contentDocument)===null||r===void 0)&&r.body)?o=Zg(e.contentDocument.body.childNodes):o=Zg(((s=e.shadowRoot)!==null&&s!==void 0?s:e).childNodes),o.length===0||jc(e,HTMLVideoElement)||await o.reduce((a,i)=>a.then(()=>J5(i,n)).then(c=>{c&&t.appendChild(c)}),Promise.resolve()),t}function Q7t(e,t,n){const r=t.style;if(!r)return;const s=window.getComputedStyle(e);s.cssText?(r.cssText=s.cssText,r.transformOrigin=s.transformOrigin):u3e(n).forEach(o=>{let a=s.getPropertyValue(o);o==="font-size"&&a.endsWith("px")&&(a=`${Math.floor(parseFloat(a.substring(0,a.length-2)))-.1}px`),jc(e,HTMLIFrameElement)&&o==="display"&&a==="inline"&&(a="block"),o==="d"&&t.getAttribute("d")&&(a=`path(${t.getAttribute("d")})`),r.setProperty(o,a,s.getPropertyPriority(o))})}function X7t(e,t){jc(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),jc(e,HTMLInputElement)&&t.setAttribute("value",e.value)}function J7t(e,t){if(jc(e,HTMLSelectElement)){const n=t,r=Array.from(n.children).find(s=>e.value===s.getAttribute("value"));r&&r.setAttribute("selected","")}}function een(e,t,n){return jc(t,Element)&&(Q7t(e,t,n),F7t(e,t,n),X7t(e,t),J7t(e,t)),t}async function ten(e,t){const n=e.querySelectorAll?e.querySelectorAll("use"):[];if(n.length===0)return e;const r={};for(let o=0;o<n.length;o++){const i=n[o].getAttribute("xlink:href");if(i){const c=e.querySelector(i),l=document.querySelector(i);!c&&l&&!r[i]&&(r[i]=await J5(l,t,!0))}}const s=Object.values(r);if(s.length){const o="http://www.w3.org/1999/xhtml",a=document.createElementNS(o,"svg");a.setAttribute("xmlns",o),a.style.position="absolute",a.style.width="0",a.style.height="0",a.style.overflow="hidden",a.style.display="none";const i=document.createElementNS(o,"defs");a.appendChild(i);for(let c=0;c<s.length;c++)i.appendChild(s[c]);e.appendChild(a)}return e}async function J5(e,t,n){return!n&&t.filter&&!t.filter(e)?null:Promise.resolve(e).then(r=>K7t(r,t)).then(r=>Y7t(e,r,t)).then(r=>een(e,r,t)).then(r=>ten(r,t))}const h3e=/url\((['"]?)([^'"]+?)\1\)/g,nen=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,ren=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function sen(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function oen(e){const t=[];return e.replace(h3e,(n,r,s)=>(t.push(s),n)),t.filter(n=>!PK(n))}async function aen(e,t,n,r,s){try{const o=n?C7t(t,n):t,a=Tee(t);let i;return s||(i=await Aee(o,a,r)),e.replace(sen(t),`$1${i}$3`)}catch{}return e}function ien(e,{preferredFontFormat:t}){return t?e.replace(ren,n=>{for(;;){const[r,,s]=nen.exec(n)||[];if(!s)return"";if(s===t)return`src: ${r};`}}):e}function m3e(e){return e.search(h3e)!==-1}async function g3e(e,t,n){if(!m3e(e))return e;const r=ien(e,n);return oen(r).reduce((o,a)=>o.then(i=>aen(i,a,t,n)),Promise.resolve(r))}async function s1(e,t,n){var r;const s=(r=t.style)===null||r===void 0?void 0:r.getPropertyValue(e);if(s){const o=await g3e(s,null,n);return t.style.setProperty(e,o,t.style.getPropertyPriority(e)),!0}return!1}async function len(e,t){await s1("background",e,t)||await s1("background-image",e,t),await s1("mask",e,t)||await s1("-webkit-mask",e,t)||await s1("mask-image",e,t)||await s1("-webkit-mask-image",e,t)}async function cen(e,t){const n=jc(e,HTMLImageElement);if(!(n&&!PK(e.src))&&!(jc(e,SVGImageElement)&&!PK(e.href.baseVal)))return;const r=n?e.src:e.href.baseVal,s=await Aee(r,Tee(r),t);await new Promise((o,a)=>{e.onload=o,e.onerror=t.onImageErrorHandler?(...c)=>{try{o(t.onImageErrorHandler(...c))}catch(l){a(l)}}:a;const i=e;i.decode&&(i.decode=o),i.loading==="lazy"&&(i.loading="eager"),n?(e.srcset="",e.src=s):e.href.baseVal=s})}async function uen(e,t){const r=Zg(e.childNodes).map(s=>y3e(s,t));await Promise.all(r).then(()=>e)}async function y3e(e,t){jc(e,Element)&&(await len(e,t),await cen(e,t),await uen(e,t))}function den(e,t){const{style:n}=e;t.backgroundColor&&(n.backgroundColor=t.backgroundColor),t.width&&(n.width=`${t.width}px`),t.height&&(n.height=`${t.height}px`);const r=t.style;return r!=null&&Object.keys(r).forEach(s=>{n[s]=r[s]}),e}const tbe={};async function nbe(e){let t=tbe[e];if(t!=null)return t;const r=await(await fetch(e)).text();return t={url:e,cssText:r},tbe[e]=t,t}async function rbe(e,t){let n=e.cssText;const r=/url\(["']?([^"')]+)["']?\)/g,o=(n.match(/url\([^)]+\)/g)||[]).map(async a=>{let i=a.replace(r,"$1");return i.startsWith("https://")||(i=new URL(i,e.url).href),f3e(i,t.fetchRequestInit,({result:c})=>(n=n.replace(a,`url(${c})`),[a,c]))});return Promise.all(o).then(()=>n)}function sbe(e){if(e==null)return[];const t=[],n=/(\/\*[\s\S]*?\*\/)/gi;let r=e.replace(n,"");const s=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const c=s.exec(r);if(c===null)break;t.push(c[0])}r=r.replace(s,"");const o=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,a="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",i=new RegExp(a,"gi");for(;;){let c=o.exec(r);if(c===null){if(c=i.exec(r),c===null)break;o.lastIndex=i.lastIndex}else i.lastIndex=o.lastIndex;t.push(c[0])}return t}async function fen(e,t){const n=[],r=[];return e.forEach(s=>{if("cssRules"in s)try{Zg(s.cssRules||[]).forEach((o,a)=>{if(o.type===CSSRule.IMPORT_RULE){let i=a+1;const c=o.href,l=nbe(c).then(d=>rbe(d,t)).then(d=>sbe(d).forEach(f=>{try{s.insertRule(f,f.startsWith("@import")?i+=1:s.cssRules.length)}catch(p){console.error("Error inserting rule from remote css",{rule:f,error:p})}})).catch(d=>{console.error("Error loading remote css",d.toString())});r.push(l)}})}catch(o){const a=e.find(i=>i.href==null)||document.styleSheets[0];s.href!=null&&r.push(nbe(s.href).then(i=>rbe(i,t)).then(i=>sbe(i).forEach(c=>{a.insertRule(c,a.cssRules.length)})).catch(i=>{console.error("Error loading remote stylesheet",i)})),console.error("Error inlining remote css file",o)}}),Promise.all(r).then(()=>(e.forEach(s=>{if("cssRules"in s)try{Zg(s.cssRules||[]).forEach(o=>{n.push(o)})}catch(o){console.error(`Error while reading CSS rules from ${s.href}`,o)}}),n))}function pen(e){return e.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>m3e(t.style.getPropertyValue("src")))}async function hen(e,t){if(e.ownerDocument==null)throw new Error("Provided element is not within a Document");const n=Zg(e.ownerDocument.styleSheets),r=await fen(n,t);return pen(r)}function b3e(e){return e.trim().replace(/["']/g,"")}function men(e){const t=new Set;function n(r){(r.style.fontFamily||getComputedStyle(r).fontFamily).split(",").forEach(o=>{t.add(b3e(o))}),Array.from(r.children).forEach(o=>{o instanceof HTMLElement&&n(o)})}return n(e),t}async function gen(e,t){const n=await hen(e,t),r=men(e);return(await Promise.all(n.filter(o=>r.has(b3e(o.style.fontFamily))).map(o=>{const a=o.parentStyleSheet?o.parentStyleSheet.href:null;return g3e(o.cssText,a,t)}))).join(`
1138
- `)}async function yen(e,t){const n=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await gen(e,t);if(n){const r=document.createElement("style"),s=document.createTextNode(n);r.appendChild(s),e.firstChild?e.insertBefore(r,e.firstChild):e.appendChild(r)}}async function ben(e,t={}){const{width:n,height:r}=d3e(e,t),s=await J5(e,t,!0);return await yen(s,t),await y3e(s,t),den(s,t),await M7t(s,n,r)}async function ven(e,t={}){const{width:n,height:r}=d3e(e,t),s=await ben(e,t),o=await UP(s),a=document.createElement("canvas"),i=a.getContext("2d"),c=t.pixelRatio||j7t(),l=t.canvasWidth||n,d=t.canvasHeight||r;return a.width=l*c,a.height=d*c,t.skipAutoScale||D7t(a),a.style.width=`${l}`,a.style.height=`${d}`,t.backgroundColor&&(i.fillStyle=t.backgroundColor,i.fillRect(0,0,a.width,a.height)),i.drawImage(o,0,0,a.width,a.height),a}async function xen(e,t={}){return(await ven(e,t)).toDataURL()}function v3e(){const{apiUrl:e,isReady:t}=wn(),n=bt(r=>r.selectedAgentPath);b.useEffect(()=>{if(!t)return;let r=null;const s=async c=>{try{const l=await xen(document.documentElement,{cacheBust:!0,pixelRatio:1});await fetch(e("/api/agent0/screenshot-result"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:c,dataUrl:l,mimeType:"image/png"})})}catch(l){await fetch(e("/api/agent0/screenshot-result"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:c,error:l instanceof Error?l.message:"Capture failed"})}).catch(()=>{})}},o=()=>{r||(r=new EventSource(e("/api/agent0/events")),r.addEventListener("take_screenshot",c=>{try{const{requestId:l}=JSON.parse(c.data);l&&s(l)}catch{}}),r.addEventListener("error",()=>{r?.close(),r=null}))},a=()=>{r?.close(),r=null},i=()=>{document.visibilityState==="visible"&&o()};return o(),document.addEventListener("visibilitychange",i),()=>{document.removeEventListener("visibilitychange",i),a()}},[e,t,n])}function obe(){const e=Vt(d=>d.isOpen),t=Vt(d=>d.settings),n=Vt(d=>d.updateSettings),{client:r,agentPath:s}=e5e(e),o=b.useRef(!1),a=b.useRef(null),i=b.useRef(t.panelWidth),c=Vt(d=>d.sessionId);JLe(r,c,e),v3e(),b.useEffect(()=>{const d=f=>{if(f.key==="Escape"&&e){const p=f.target;(p.tagName==="TEXTAREA"||p.tagName==="INPUT")&&p.blur()}};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[e]),b.useEffect(()=>()=>a.current?.(),[]),b.useEffect(()=>{i.current=t.panelWidth},[t.panelWidth]);const l=b.useCallback(d=>{d.preventDefault(),o.current=!0;const f=d.clientX,p=i.current,h=d.target.closest("[data-agent0-panel]"),g=h?.style.transition??"";h&&(h.style.transition="none");const y=x=>{if(!o.current)return;const w=Math.max(300,Math.min(700,p+(f-x.clientX)));i.current=w,h&&(h.style.width=`${w}px`)},E=()=>{o.current=!1,document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",E),document.body.style.cursor="",document.body.style.userSelect="",a.current=null,h&&(h.style.transition=g),n({panelWidth:i.current})};a.current=E,document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",y),document.addEventListener("mouseup",E)},[n]);return u.jsxs("div",{"data-agent0-panel":!0,className:"relative h-full shrink-0 transition-[width] duration-enter ease-ease-out-quart",style:{width:e?t.panelWidth:0},children:[e&&u.jsx("div",{onMouseDown:l,className:"group/resize absolute left-0 top-0 bottom-0 w-4 -translate-x-full cursor-col-resize z-10 flex items-center justify-center",children:u.jsx("div",{className:"h-8 w-1 rounded-full bg-muted-foreground/15 transition-all duration-150 group-hover/resize:h-16 group-hover/resize:bg-muted-foreground/30"})}),u.jsx("div",{inert:!e||void 0,className:"relative h-full w-full pr-2 pb-2 pl-2",children:u.jsx("div",{className:"h-full rounded-xl bg-background flex flex-col overflow-hidden relative",children:u.jsx("div",{className:"flex-1 min-h-0 overflow-hidden relative",children:u.jsx(c3e,{client:r,agentPath:s,heroHeadline:"What are we working on?",heroSubhead:"agent0 can inspect your project, explain how things work, debug issues, and build with you.",composerPlaceholder:"Ask a question or / for commands"})})})})]})}const x3e="adk:prod-badge-position",o1=16;function Een(){if(typeof window>"u")return null;try{const e=localStorage.getItem(x3e);if(!e)return null;const t=JSON.parse(e);if((t.side==="left"||t.side==="right")&&typeof t.y=="number")return{side:t.side,y:t.y}}catch{}return null}function wen(e){try{localStorage.setItem(x3e,JSON.stringify(e))}catch{}}function Sen({active:e}){const[t,n]=b.useState(Een),[r,s]=b.useState(null),[o,a]=b.useState(null),[i,c]=b.useState(!1),l=b.useRef(null);b.useEffect(()=>{if(!r)return;const g=E=>{a({x:E.clientX-r.x,y:E.clientY-r.y})},y=E=>{const x=l.current?.getBoundingClientRect(),w=x?.width??28,S=x?.height??28,T=E.clientX-r.x,k=E.clientY-r.y,A=window.innerWidth/2,N=T+w/2<A?"left":"right",j=Math.max(o1,Math.min(window.innerHeight-S-o1,k)),O={side:N,y:j};n(O),wen(O),s(null),a(null)};return window.addEventListener("pointermove",g),window.addEventListener("pointerup",y),()=>{window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",y)}},[r]);const d=g=>{if(!e)return;const y=g.currentTarget.getBoundingClientRect();s({x:g.clientX-y.left,y:g.clientY-y.top}),a({x:y.left,y:y.top}),g.preventDefault()},f=!!r&&!!o,p=t?.side??"right";let h;return f&&o?h={left:o.x,top:o.y,right:"auto",bottom:"auto"}:t?h=t.side==="right"?{right:o1,top:t.y,left:"auto",bottom:"auto"}:{left:o1,top:t.y,right:"auto",bottom:"auto"}:h={right:o1,bottom:o1,left:"auto",top:"auto"},u.jsxs("div",{ref:l,role:"status","aria-label":"Production Mode","aria-hidden":!e,onPointerDown:d,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),style:h,className:me("fixed z-50 flex select-none items-center overflow-hidden rounded-md bg-purple-500 text-white shadow-lg ring-1 ring-purple-400/40","transition-all duration-300 ease-out motion-reduce:transition-none",f?"cursor-grabbing !transition-none":"cursor-grab",p==="right"?"flex-row-reverse":"flex-row",e?"opacity-100":"pointer-events-none translate-y-2 opacity-0"),children:[u.jsx("div",{className:"flex size-7 shrink-0 items-center justify-center",children:u.jsx("svg",{className:"size-4",viewBox:"55 50 140 160",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor","aria-hidden":!0,children:u.jsx("path",{d:"M192 93.6C192 96.4 190.4 98.8 188.4 100L178.4 105.6L168.4 111.2C166 112.8 163.2 112.8 160.8 111.2L150.8 105.6H150.4L161.2 90L142.4 100.8L112 118V138L142.4 155.2L151.2 150.4L161.2 144.8C163.2 143.2 166.4 143.2 168.8 144.8L178.8 150.4L188.8 156C191.2 157.2 192.8 160 192.4 162.4V185.2C192.4 188 190.8 190.4 188.8 191.6L178.8 197.2L168.8 202.8C166.4 204.4 163.6 204.4 161.2 202.8L151.2 197.2L141.2 191.6C138.8 190.4 137.2 187.6 137.6 185.2V164L90.8 137.6L100 150.8L88.4 157.2C86 158.8 83.2 158.8 80.8 157.2L70.8 151.6L60.8 146C58.4 144.8 57.2 142.4 57.2 139.6V116.8C57.2 114 58.8 111.6 60.8 110.4L70.8 104.8L80.8 99.2C83.2 97.6 86 97.6 88.4 99.2L98.4 104.8L107.2 109.6L137.6 92.4V71.2C137.6 68.4 139.2 66 141.2 64.8L151.2 59.2L161.2 53.6C163.6 52 166.4 52 168.8 53.6L178.8 59.2L188.8 64.8C191.2 66 192.8 68.8 192.4 71.2V94L192 93.6Z"})})}),u.jsx("div",{className:me("overflow-hidden transition-[max-width] duration-200 ease-out",i||f?"max-w-[8rem]":"max-w-0"),children:u.jsx("span",{className:me("block whitespace-nowrap text-xs font-medium",p==="right"?"pl-3 pr-1":"pl-1 pr-3"),children:"Production Mode"})})]})}function _en({status:e,className:t}){const n=e==="ready"?"text-green-400":e==="error"?"text-red-400":"text-orange-400";return u.jsx(Ly,{className:me("h-2 w-2 fill-current",n,t)})}function E3e({onOpenAbout:e,onClose:t,onCreateProject:n,onDeploy:r}){const s=bt(q=>q.selectedAgentPath),o=bt(q=>q.setSelectedAgentPath),a=bt(q=>q.agents),i=xs(q=>q.targetEnvironment),c=xs(q=>q.setTargetEnvironmentAndSync),{data:l}=lc(),{apiUrl:d}=wn(),f=l?.credentials?.prodBotId??null,p=Lc(),h=i==="dev"?"prod":"dev",g=h==="dev"||!!f,{terminateAgent:y,closingAgents:E}=DJ(),[x,w]=b.useState([]),[S]=b.useState(q7),T=a.find(q=>q.agentPath===s),k=T?.consoleMode==="cloud",A=q=>{const z=k?T?.agentPath:null;o(q),z&&fetch(d("/api/cloud-console/clear"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentPath:z})}).catch(()=>{})},{pickAndOpenProject:N,openProjectPath:j,isOpening:O,openingName:D,openError:L,clearError:U}=nI({onSuccess:q=>{A(q.agentPath),t?.()}});b.useEffect(()=>{fetch(d("/api/projects/recent"),{signal:AbortSignal.timeout(2e3)}).then(q=>q.ok?q.json():null).then(q=>w(q?.projects??[])).catch(()=>{})},[d]);const B=async q=>{await y(q,{waitForRemoval:!0})},M=async(q,z)=>{try{const G=await fetch(d("/api/cloud-console/select-prod-bot"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceId:q.id,botId:z.id,botName:z.name}),signal:AbortSignal.timeout(5e3)});if(!G.ok)return;const R=await G.json();q.name&&GLe({botId:z.id,botName:z.name,workspaceId:q.id,workspaceName:q.name});const W=await fetch(d("/api/agents"),{signal:AbortSignal.timeout(2e3)});if(W.ok){const V=await W.json();bt.getState().setAgents(V.agents??[])}o(R.agentPath),t?.()}catch{}},$="flex w-full items-center justify-start gap-2 px-2.5 py-1.5 rounded-sm cursor-pointer text-[11px] text-muted-foreground hover:text-foreground focus:bg-muted-foreground/10";if(k){const q=S.slice(0,3);return u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"h-64",children:u.jsx(J$e,{onSelect:(z,G)=>void M(z,G)})}),q.length>0&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"px-1 pt-1 pb-0.5 select-none",children:u.jsx("span",{className:"text-[10px] font-medium text-muted-foreground/50",children:"Recent"})}),q.map(z=>u.jsxs(wr,{onSelect:G=>{G.preventDefault(),M({id:z.workspaceId,name:z.workspaceName},{id:z.botId,name:z.botName})},className:"flex items-center gap-2.5 px-2.5 py-1.5 rounded-sm cursor-pointer text-muted-foreground hover:text-foreground focus:bg-muted-foreground/10",children:[u.jsx(ew,{name:z.botName,className:"size-4"}),u.jsx("span",{className:"text-xs truncate",children:z.botName}),u.jsx("span",{className:"text-[10px] truncate text-muted-foreground/50",children:z.workspaceName})]},z.botId))]}),e&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"my-px h-px bg-muted-foreground/10"}),u.jsx("div",{className:"px-1 pb-0.5 select-none",children:u.jsx("span",{className:"text-[10px] font-medium text-muted-foreground/50",children:"Actions"})}),u.jsxs("div",{className:"flex flex-col gap-0.5",children:[u.jsxs(wr,{onSelect:e,className:$,children:[u.jsx(SW,{className:"size-3.5"}),"About this agent"]}),u.jsxs(wr,{onSelect:()=>p("/"),className:$,children:[u.jsx(wW,{className:"size-3.5"}),"Back to home"]})]})]})]})}const P=a.filter(q=>q.consoleMode!=="cloud");return u.jsxs(u.Fragment,{children:[P.length>0&&u.jsx("div",{className:"px-1 pb-0.5 select-none",children:u.jsx("span",{className:"text-[10px] font-medium text-muted-foreground/50",children:"Active"})}),P.map(q=>{const z=q.agentPath===s,G=!!E[q.agentPath];return u.jsxs("div",{className:me("group flex items-center gap-1 rounded-sm","hover:bg-muted-foreground/10",z&&"bg-muted-foreground/10"),children:[u.jsxs(wr,{disabled:G,onSelect:()=>!G&&A(q.agentPath),className:"flex min-w-0 flex-1 items-center gap-2.5 px-2.5 py-2 rounded-sm cursor-pointer text-foreground focus:bg-transparent",children:[u.jsx(_en,{status:q.status,className:"shrink-0"}),u.jsx("span",{className:"max-w-32 shrink-0 truncate text-xs font-medium text-foreground",children:q.name}),u.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[10px] text-muted-foreground/50",style:{direction:"rtl",textAlign:"left"},title:q.agentPath,children:"‎"+q.agentPath})]}),u.jsx("button",{type:"button",title:"Stop project",disabled:G,onClick:R=>{R.stopPropagation(),B(q.agentPath)},className:me("mr-1 inline-flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-sm text-destructive/75 transition-all hover:bg-destructive/10 hover:text-destructive disabled:cursor-not-allowed disabled:opacity-60",G?"opacity-100":"opacity-0 group-hover:opacity-100"),children:G?u.jsx(nn,{className:"size-3 animate-spin"}):u.jsx(i5,{className:"size-3",strokeWidth:1.75})})]},q.agentPath)}),D&&!a.some(q=>q.name===D)&&u.jsxs("div",{className:"flex items-center gap-2.5 px-2.5 py-2 text-muted-foreground",children:[u.jsx(nn,{className:"size-2 animate-spin shrink-0 ml-[1px]"}),u.jsxs("span",{className:"text-xs",children:["Opening ",D,"…"]})]}),u.jsx(z7,{error:L,onDismiss:U}),(()=>{const q=new Set(P.map(G=>G.agentPath)),z=x.filter(G=>!q.has(G.path)).slice(0,5);return z.length===0?null:u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"my-px h-px bg-muted-foreground/10"}),u.jsx("div",{className:"px-1 pb-0.5 select-none",children:u.jsx("span",{className:"text-[10px] font-medium text-muted-foreground/50",children:"Recent"})}),z.map(G=>u.jsxs(wr,{disabled:O,onSelect:R=>{R.preventDefault(),j(G.path,{path:G.path,name:G.name,lastOpenedAt:""})},className:"flex items-center gap-2.5 px-2.5 py-1.5 rounded-sm cursor-pointer text-muted-foreground hover:text-foreground focus:bg-muted-foreground/10",children:[u.jsx(nc,{className:"size-3 shrink-0",strokeWidth:1.75}),u.jsx("span",{className:"text-xs truncate",children:G.name})]},G.path))]})})(),u.jsx("div",{className:"my-px h-px bg-muted-foreground/10"}),u.jsx("div",{className:"px-1 pb-0.5 select-none",children:u.jsx("span",{className:"text-[10px] font-medium text-muted-foreground/50",children:"Actions"})}),u.jsxs("div",{className:"flex flex-col gap-0.5",children:[u.jsxs(wr,{onSelect:q=>{q.preventDefault(),t?.(),n?.()},className:$,children:[u.jsx(ld,{className:"size-3.5"}),"Create project"]}),u.jsxs(wr,{disabled:O,onSelect:q=>{q.preventDefault(),N()},className:$,children:[O?u.jsx(nn,{className:"size-3.5 animate-spin"}):u.jsx(nc,{className:"size-3.5"}),"Open project"]}),e&&u.jsxs(u.Fragment,{children:[u.jsxs(wr,{disabled:!g,onSelect:()=>void c(h),className:$,children:[u.jsx(nP,{className:"size-3.5"}),"Switch to ",h]}),u.jsxs(wr,{disabled:!T||i==="prod",onSelect:()=>r?.(),className:$,children:[u.jsx(RDe,{className:"size-3.5"}),"Deploy"]}),u.jsxs(wr,{onSelect:e,className:$,children:[u.jsx(SW,{className:"size-3.5"}),"About this agent"]}),u.jsxs(wr,{onSelect:()=>p("/"),className:$,children:[u.jsx(wW,{className:"size-3.5"}),"Back to home"]})]})]})]})}const Ten="https://api.botpress.cloud",Aen="app.botpress.dev",ken="app.botpress.cloud",Cen="https://webhook.botpress.dev",Nen="https://webhook.botpress.cloud";function e4(){const{credentials:e}=$o(),t=e?.apiUrl;return b.useMemo(()=>{const n=!!t?.includes(".dev"),r=n?Aen:ken;return{apiUrl:t||Ten,isStaging:n,appHost:r,webhookUrl:n?Cen:Nen,botUrl:(i,c)=>c?`https://${r}/workspaces/${c}/bots/${i}`:null}},[t])}function t4({active:e,className:t,...n}){return u.jsx("span",{className:me("built-agent-logo relative block shrink-0 overflow-hidden rounded-full",t),"data-changing":e?"true":void 0,"aria-hidden":"true",...n})}function Ien(e){return typeof e=="object"&&e!==null}function Ren(e){return e?e.flatMap(t=>{if(!Ien(t)||typeof t.name!="string")return[];const n=Array.isArray(t.events)?t.events.filter(r=>typeof r=="string"):[];return[{source:"trigger",key:t.name,name:t.name,label:t.name,description:typeof t.description=="string"?t.description:void 0,events:n,eventCount:n.length}]}):[]}function jen(e){if(!e)return[];const t=[];for(const n of e){if(!n.enabled)continue;const r=n.definition?.title||n.name||n.alias,s=n.definition?.events||{};for(const[o,a]of Object.entries(s)){const i=`${n.alias}:${o}`;t.push({source:"integration-event",key:i,name:i,label:a.title||o,description:a.description,events:[i],eventCount:1,integrationAlias:n.alias,integrationName:r,integrationIconUrl:n.definition?.iconUrl,eventName:o,eventTitle:a.title,eventSchema:a.schema})}}return t}function kee(e,t){return[...Ren(e),...jen(t)]}function Den(e,t){return kee(e,t).length}const Oen=[{key:"actions",to:"/actions",label:"Actions",icon:Wg},{key:"workflows",to:"/workflows",label:"Workflows",icon:Mh},{key:"conversations",to:"/conversations",label:"Conversations",icon:r5},{key:"triggers",to:"/triggers",label:"Triggers",icon:Sa},{key:"tables",to:"/tables",label:"Tables",icon:ml},{key:"knowledge",to:"/knowledge",label:"Knowledge",icon:nc}];function zP({open:e,onOpenChange:t}){const{agent:n,bot:r}=ds(),{data:s}=xRt(),{data:o}=lc(),{data:a}=u5(r?.id),{data:i}=vRt(),c=bt(O=>O.selectedAgentPath),l=bt(O=>O.agents),[d,f]=b.useState(null);jv(),cm();const p=a||[],h=Den(n?.triggers,a),g=o?.credentials?.devBotId,y=o?.credentials?.workspaceId,{botUrl:E}=e4(),x=O=>E(O,y),w=o?.credentials?.prodBotId,T=l.find(O=>O.agentPath===c)?.consoleMode==="cloud"||c?.startsWith("prod:"),k=n?.name||r?.name||"Agent",A={actions:n?.actions?.length||0,workflows:n?.workflows?.length||0,conversations:n?.conversations?.length||0,triggers:h,tables:n?.tables?.length||0,knowledge:n?.knowledge?.length||0},N=[{label:"Bot ID",value:g},{label:"Workspace",value:y},{label:"Path",value:n?.path}].filter(O=>O.value),j=(O,D)=>{navigator.clipboard.writeText(O),f(D),setTimeout(()=>f(null),1500)};return u.jsx(fi,{open:e,onOpenChange:t,children:u.jsxs(Ci,{className:"sm:max-w-[680px] p-0 gap-0 rounded-md border-0 overflow-hidden [&>button:last-child]:hidden shadow-2xl",children:[u.jsx("div",{className:"absolute top-[45%] left-[90px] -translate-x-1/2 -translate-y-1/2 size-56 rounded-full blur-[100px] opacity-15 pointer-events-none",style:{background:"radial-gradient(circle at 32% 28%, hsl(220 100% 78%) 0%, hsl(265 85% 60%) 38%, hsl(320 80% 50%) 80%)"}}),u.jsxs("div",{className:"relative flex max-h-[80vh]",children:[u.jsx("div",{className:"relative w-[200px] shrink-0 flex flex-col items-center justify-center py-10",children:u.jsxs("div",{className:"relative flex flex-col items-center text-center",children:[u.jsx(t4,{className:"mb-5 size-10"}),u.jsx("p",{className:"text-[14px] font-semibold tracking-tight text-foreground",children:k}),u.jsx(Ni,{className:"sr-only",children:k}),u.jsxs("div",{className:"flex items-center gap-1.5 mt-3",children:[g&&x(g)&&u.jsxs("a",{href:x(g),target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-md border border-muted-foreground/10 px-2 py-0.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors",children:[u.jsx("img",{src:"/bp_logo_dev.svg",alt:"",className:"size-3 rounded-sm"}),"Dev"]}),w&&x(w)&&u.jsxs("a",{href:x(w),target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-md border border-muted-foreground/10 px-2 py-0.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors",children:[u.jsx("img",{src:"/bp_logo_prod.svg",alt:"",className:"size-3 rounded-sm dark:invert"}),"Prod"]})]})]})}),u.jsxs("div",{className:"relative flex-1 flex flex-col bg-background-deep",children:[u.jsxs("div",{className:"flex-1 overflow-y-auto py-10",children:[u.jsx("h2",{className:"px-5 text-xs font-medium mb-6",children:"Agent Details"}),u.jsx("div",{className:"px-5 space-y-2",children:N.map(O=>u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"text-[10px] font-medium w-[60px] shrink-0 text-muted-foreground/40",children:O.label}),u.jsx("span",{className:"text-[10px] font-mono text-muted-foreground/60 truncate",children:O.value}),u.jsx("button",{onClick:()=>j(O.value,O.label),className:"text-muted-foreground/30 hover:text-muted-foreground shrink-0 transition-colors cursor-pointer ml-auto",children:d===O.label?u.jsx(Xr,{className:"size-2.5"}):u.jsx(li,{className:"size-2.5"})})]},O.label))}),u.jsx("div",{className:"mx-5 my-5 h-px bg-muted-foreground/10"}),u.jsx("div",{className:"px-4",children:u.jsx("div",{className:"grid grid-cols-2 gap-x-2 gap-y-1.5",children:[...Oen.map(O=>({label:O.label,count:A[O.key],to:O.to,icon:O.icon})),{label:"Integrations",count:p.length,to:"/integrations",icon:_C}].map(O=>u.jsxs(Fc,{to:O.to,onClick:()=>t(!1),className:"icon-hover flex items-center gap-1.5 py-1 px-1.5 rounded-sm text-xs text-muted-foreground hover:text-foreground hover:bg-muted-foreground/5 transition-colors",children:[u.jsx(O.icon,{className:"size-3 shrink-0 text-muted-foreground/40"}),u.jsx("span",{className:"flex-1 truncate",children:O.label}),u.jsx("span",{className:"text-[10px] font-mono text-muted-foreground/25",children:O.count})]},O.label))})}),!T&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"mx-5 my-5 h-px bg-muted-foreground/10"}),u.jsxs("div",{className:"px-5 flex items-center gap-6",children:[u.jsxs("div",{className:"flex items-baseline gap-1.5",children:[u.jsx("span",{className:"text-[10px] text-muted-foreground/40",children:"Workers"}),u.jsx("span",{className:me("text-xs font-semibold font-mono",i?.busy>0&&"text-blue-400"),children:i?.busy??"--"}),u.jsxs("span",{className:"text-[10px] text-muted-foreground/25 font-mono",children:["/ ",i?.total??"--"]})]}),u.jsxs("div",{className:"flex items-baseline gap-1.5",children:[u.jsx("span",{className:"text-[10px] text-muted-foreground/40",children:"Queue"}),u.jsx("span",{className:me("text-xs font-semibold font-mono",i?.queueSize>0&&"text-orange-400"),children:i?.queueSize??"--"})]})]})]})]}),u.jsxs("div",{className:"shrink-0 flex items-center justify-center gap-1.5 py-2 border-t border-muted-foreground/5",children:[u.jsx("span",{className:"text-[10px] text-muted-foreground/25",children:"Powered by"}),u.jsx("div",{className:"size-3 rounded-sm bg-sidebar-primary flex items-center justify-center p-px",children:u.jsx("img",{src:"/ADK.svg",alt:"ADK",className:"size-full invert"})}),s?.adkVersion&&s.adkVersion!=="unknown"&&u.jsxs("span",{className:"text-[10px] font-mono text-muted-foreground/20",children:["v",s.adkVersion]})]})]})]})]})})}const Men=o7("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors duration-standard focus:outline-hidden focus:ring-1 focus:ring-ring",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Sr({className:e,variant:t,...n}){return u.jsx("div",{className:me(Men({variant:t}),e),...n})}function PI(e){const t=b.useRef({value:e,previous:e});return b.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var n4="Checkbox",[Pen]=di(n4),[$en,Cee]=Pen(n4);function Len(e){const{__scopeCheckbox:t,checked:n,children:r,defaultChecked:s,disabled:o,form:a,name:i,onCheckedChange:c,required:l,value:d="on",internal_do_not_use_render:f}=e,[p,h]=rc({prop:n,defaultProp:s??!1,onChange:c,caller:n4}),[g,y]=b.useState(null),[E,x]=b.useState(null),w=b.useRef(!1),S=g?!!a||!!g.closest("form"):!0,T={checked:p,disabled:o,setChecked:h,control:g,setControl:y,name:i,form:a,value:d,hasConsumerStoppedPropagationRef:w,required:l,defaultChecked:Yg(s)?!1:s,isFormControl:S,bubbleInput:E,setBubbleInput:x};return u.jsx($en,{scope:t,...T,children:Fen(f)?f(T):r})}var w3e="CheckboxTrigger",S3e=b.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},s)=>{const{control:o,value:a,disabled:i,checked:c,required:l,setControl:d,setChecked:f,hasConsumerStoppedPropagationRef:p,isFormControl:h,bubbleInput:g}=Cee(w3e,e),y=Cn(s,d),E=b.useRef(c);return b.useEffect(()=>{const x=o?.form;if(x){const w=()=>f(E.current);return x.addEventListener("reset",w),()=>x.removeEventListener("reset",w)}},[o,f]),u.jsx(dn.button,{type:"button",role:"checkbox","aria-checked":Yg(c)?"mixed":c,"aria-required":l,"data-state":C3e(c),"data-disabled":i?"":void 0,disabled:i,value:a,...r,ref:y,onKeyDown:Rt(t,x=>{x.key==="Enter"&&x.preventDefault()}),onClick:Rt(n,x=>{f(w=>Yg(w)?!0:!w),g&&h&&(p.current=x.isPropagationStopped(),p.current||x.stopPropagation())})})});S3e.displayName=w3e;var Nee=b.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:s,defaultChecked:o,required:a,disabled:i,value:c,onCheckedChange:l,form:d,...f}=e;return u.jsx(Len,{__scopeCheckbox:n,checked:s,defaultChecked:o,disabled:i,required:a,onCheckedChange:l,name:r,form:d,value:c,internal_do_not_use_render:({isFormControl:p})=>u.jsxs(u.Fragment,{children:[u.jsx(S3e,{...f,ref:t,__scopeCheckbox:n}),p&&u.jsx(k3e,{__scopeCheckbox:n})]})})});Nee.displayName=n4;var _3e="CheckboxIndicator",T3e=b.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...s}=e,o=Cee(_3e,n);return u.jsx(Ha,{present:r||Yg(o.checked)||o.checked===!0,children:u.jsx(dn.span,{"data-state":C3e(o.checked),"data-disabled":o.disabled?"":void 0,...s,ref:t,style:{pointerEvents:"none",...e.style}})})});T3e.displayName=_3e;var A3e="CheckboxBubbleInput",k3e=b.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:r,hasConsumerStoppedPropagationRef:s,checked:o,defaultChecked:a,required:i,disabled:c,name:l,value:d,form:f,bubbleInput:p,setBubbleInput:h}=Cee(A3e,e),g=Cn(n,h),y=PI(o),E=uI(r);b.useEffect(()=>{const w=p;if(!w)return;const S=window.HTMLInputElement.prototype,k=Object.getOwnPropertyDescriptor(S,"checked").set,A=!s.current;if(y!==o&&k){const N=new Event("click",{bubbles:A});w.indeterminate=Yg(o),k.call(w,Yg(o)?!1:o),w.dispatchEvent(N)}},[p,y,o,s]);const x=b.useRef(Yg(o)?!1:o);return u.jsx(dn.input,{type:"checkbox","aria-hidden":!0,defaultChecked:a??x.current,required:i,disabled:c,name:l,value:d,form:f,...t,tabIndex:-1,ref:g,style:{...t.style,...E,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});k3e.displayName=A3e;function Fen(e){return typeof e=="function"}function Yg(e){return e==="indeterminate"}function C3e(e){return Yg(e)?"indeterminate":e?"checked":"unchecked"}const ow=b.forwardRef(({className:e,...t},n)=>u.jsx(Nee,{ref:n,className:me("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow-sm focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:u.jsx(T3e,{className:me("flex items-center justify-center text-current"),children:u.jsx(Xr,{className:"h-4 w-4"})})}));ow.displayName=Nee.displayName;var Ben="Label",N3e=b.forwardRef((e,t)=>u.jsx(dn.label,{...e,ref:t,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(e.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));N3e.displayName=Ben;var I3e=N3e;const qen=o7("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),tv=b.forwardRef(({className:e,...t},n)=>u.jsx(I3e,{ref:n,className:me(qen(),e),...t}));tv.displayName=I3e.displayName;const Uen=[{id:"secrets",label:"Saving secrets"},{id:"preflight",label:"Applying config changes"},{id:"deploy",label:"Deploying to Botpress"},{id:"manifest",label:"Publishing metadata"},{id:"kb-sync",label:"Syncing knowledge bases",formatDetail:e=>{const t=[];return e.synced&&t.push(`${e.synced} synced`),e.skipped&&t.push(`${e.skipped} skipped`),e.failed&&t.push(`${e.failed} failed`),t.join(", ")}},{id:"tables",label:"Syncing tables",formatDetail:e=>{const t=[];return e.created&&t.push(`${e.created} created`),e.updated&&t.push(`${e.updated} updated`),e.deleted&&t.push(`${e.deleted} deleted`),t.join(", ")}},{id:"assets",label:"Syncing assets",formatDetail:e=>{const t=[];return e.created&&t.push(`${e.created} uploaded`),e.updated&&t.push(`${e.updated} updated`),e.deleted&&t.push(`${e.deleted} deleted`),t.join(", ")}}];function zen(e,t){return Uen.filter(n=>{switch(n.id){case"secrets":return t;case"preflight":return e.preflight.hasChanges;case"deploy":return!0;case"manifest":return!0;case"kb-sync":return e.knowledgeBases?.hasChanges||e.knowledgeBases?.orphanedKBs&&e.knowledgeBases.orphanedKBs.length>0;case"tables":return e.tables?.hasChanges;case"assets":return e.assets?.hasChanges;default:return!1}})}function R3e({open:e,onOpenChange:t}){const{apiUrl:n}=wn(),[r,s]=b.useState("planning"),[o,a]=b.useState(null),[i,c]=b.useState(null),[l,d]=b.useState({}),[f,p]=b.useState(!1),[h,g]=b.useState({}),[y,E]=b.useState(null),[x,w]=b.useState(null),S=b.useRef(null),T=b.useRef(null),k=b.useCallback(()=>{s("planning"),a(null),c(null),d({}),p(!1),g({}),E(null),w(null)},[]),A=b.useCallback(()=>{T.current&&(clearInterval(T.current),T.current=null)},[]),N=b.useCallback(()=>{A(),T.current=setInterval(async()=>{try{const q=await fetch(n("/api/deploy/status"));if(!q.ok)return;const z=await q.json();g(z.stages),z.done&&z.result&&(A(),w({success:z.result.success,botId:z.result.botId??""}),!z.result.success&&z.result.error&&E(z.result.error),s("complete"))}catch{}},500)},[n,A]);b.useEffect(()=>{if(!e)return;k();const q=new AbortController;return S.current=q,(async()=>{await fetch(n("/api/deploy/cancel"),{method:"POST",signal:q.signal}).catch(()=>{});try{const G=await fetch(n("/api/deploy/plan"),{method:"POST",signal:q.signal}),R=await G.json();if(!G.ok)throw new Error(R.message||R.error||"Failed to compute deploy plan");if(R.cancelled)return;a(R),s("review")}catch(G){if(q.signal.aborted)return;c(G instanceof Error?G.message:String(G)),s("error")}})(),()=>{S.current?.abort(),A(),fetch(n("/api/deploy/cancel"),{method:"POST"}).catch(()=>{})}},[e,n,k,A]);const j=b.useCallback(()=>{A(),fetch(n("/api/deploy/cancel"),{method:"POST"}).catch(()=>{}),t(!1)},[n,t,A]),O=Object.values(l).some(q=>q.trim().length>0),D=!(!o||!o.configValid||o.secrets.missingRequired.filter(z=>!l[z]?.trim()).length>0||o.hasDestructiveStorageChanges&&!f);b.useEffect(()=>()=>{T.current&&clearInterval(T.current)},[]);const L=b.useCallback(async()=>{if(!o)return;s("deploying"),E(null);const q={};for(const[z,G]of Object.entries(l))G.trim()&&(q[z]=G.trim());try{const z=await fetch(n("/api/deploy/execute"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({confirmStorageChanges:f,secrets:Object.keys(q).length>0?q:void 0})});if(!z.ok){const G=await z.json().catch(()=>null);throw new Error(G?.message||"Failed to start deploy")}N()}catch(z){s("error"),E(z instanceof Error?z.message:String(z))}},[o,n,l,f,N]),U={planning:0,review:1,deploying:2,complete:3,error:3},B=U[r],M=q=>me("transition-all duration-300 ease-in-out",r===q?"relative translate-x-0 opacity-100":"absolute inset-x-0 top-0 pointer-events-none",r!==q&&U[q]<B&&"-translate-x-12 opacity-0",r!==q&&U[q]>B&&"translate-x-12 opacity-0",r!==q&&U[q]===B&&"opacity-0"),$=b.useCallback(()=>{S.current?.abort(),k();const q=new AbortController;S.current=q,(async()=>{await fetch(n("/api/deploy/cancel"),{method:"POST",signal:q.signal}).catch(()=>{});try{const z=await fetch(n("/api/deploy/plan"),{method:"POST",signal:q.signal}),G=await z.json();if(!z.ok)throw new Error(G.message||"Failed to compute deploy plan");if(G.cancelled)return;a(G),s("review")}catch(z){if(q.signal.aborted)return;c(z instanceof Error?z.message:String(z)),s("error")}})()},[n,k]),P=b.useCallback(()=>{fetch(n("/api/deploy/cancel"),{method:"POST"}),t(!1)},[n,t]);return u.jsx(fi,{open:e,onOpenChange:j,children:u.jsx(Ci,{className:"sm:max-w-lg overflow-hidden h-[420px]",children:u.jsxs("div",{className:"flex flex-col gap-4 h-full",children:[u.jsxs(uf,{children:[u.jsx(Ni,{className:"text-sm",children:"Deploy to Production"}),u.jsx(Yen,{phase:r})]}),u.jsxs("div",{className:"relative flex-1 min-h-0",children:[u.jsx("div",{"aria-hidden":r!=="planning",className:me(M("planning"),"h-full"),children:u.jsx(Hen,{})}),u.jsx("div",{"aria-hidden":r!=="review",className:me(M("review"),"h-full"),children:o&&u.jsx(Ven,{plan:o,secretValues:l,onSecretChange:(q,z)=>d(G=>({...G,[q]:z})),confirmDestructive:f,onConfirmDestructiveChange:p,canDeploy:D,onDeploy:()=>void L(),onCancel:j})}),u.jsx("div",{"aria-hidden":r!=="deploying"&&r!=="complete",className:me(M(r==="complete"?"complete":"deploying"),"h-full"),children:o&&u.jsx(Gen,{plan:o,stages:h,hasNewSecrets:O,isDone:r==="complete"||r==="error",result:x,error:y,onClose:()=>t(!1),onSwitchToProd:()=>{xs.getState().setTargetEnvironment("prod"),t(!1)}})}),u.jsx("div",{"aria-hidden":r!=="error",className:me(M("error"),"h-full"),children:u.jsx(Zen,{error:i||y||"Unknown error",onRetry:$,onClose:P})})]})]})})})}function Hen(){return u.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-sm text-muted-foreground",children:[u.jsx(nn,{className:"size-4 animate-spin"}),"Building project and computing changes..."]})}function Ven({plan:e,secretValues:t,onSecretChange:n,confirmDestructive:r,onConfirmDestructiveChange:s,canDeploy:o,onDeploy:a,onCancel:i}){return u.jsxs("div",{className:"flex h-full flex-col gap-3",children:[e.hasAnyChanges&&u.jsxs("p",{className:"text-xs text-muted-foreground shrink-0",children:["Review changes before deploying ",u.jsx("span",{className:"font-medium text-foreground",children:e.botName})]}),u.jsxs("div",{className:"flex-1 min-h-0 space-y-3 overflow-auto",children:[!e.configValid&&e.configErrors.length>0&&u.jsxs("div",{className:"rounded-md border border-red-500/20 bg-red-500/5 p-3 space-y-1",children:[u.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-red-400",children:[u.jsx(yl,{className:"size-3.5 shrink-0"}),"Configuration errors"]}),e.configErrors.map((c,l)=>u.jsx("p",{className:"text-xs text-red-400/80 pl-5.5",children:c},l))]}),!e.hasAnyChanges&&e.configValid&&e.secrets.missingRequired.length===0&&u.jsxs("div",{className:"flex items-center gap-2 py-2 text-xs text-muted-foreground",children:[u.jsx(Ms,{className:"size-3.5 text-green-500"}),"No resource changes detected. Code will be redeployed."]}),e.preflight.hasChanges&&e.preflight.agentConfig.length>0&&u.jsx(Oj,{title:"Agent Config",children:e.preflight.agentConfig.map(c=>u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsxs("span",{className:"text-muted-foreground",children:[c.field,":"]}),u.jsx("span",{className:"text-red-400 line-through",children:String(c.oldValue)}),u.jsx(Rv,{className:"size-3 text-muted-foreground/50"}),u.jsx("span",{className:"text-green-400",children:String(c.newValue)})]},c.field))}),e.tables?.hasChanges&&u.jsx(Oj,{title:"Tables",children:u.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.tables.totalCreate>0&&u.jsxs(Sr,{variant:"outline",className:"h-5 text-[10px] text-green-500",children:["+",e.tables.totalCreate," create"]}),e.tables.totalUpdate>0&&u.jsxs(Sr,{variant:"outline",className:"h-5 text-[10px] text-blue-500",children:["~",e.tables.totalUpdate," update"]}),e.tables.totalDelete>0&&u.jsxs(Sr,{variant:"outline",className:"h-5 text-[10px] text-red-500",children:["-",e.tables.totalDelete," delete"]})]})}),e.knowledgeBases?.hasChanges&&u.jsxs(Oj,{title:"Knowledge Bases",children:[u.jsxs("div",{className:"space-y-1 text-xs",children:[u.jsxs("span",{className:"text-muted-foreground",children:[e.knowledgeBases.toSync," to sync, ",e.knowledgeBases.toSkip," up to date"]}),e.knowledgeBases.orphanedSourcesToDelete>0&&u.jsxs("p",{className:"text-red-400",children:[e.knowledgeBases.orphanedSourcesToDelete," orphaned sources to remove"]})]}),e.knowledgeBases.orphanedKBs.length>0&&u.jsx("div",{className:"mt-1 space-y-0.5",children:e.knowledgeBases.orphanedKBs.map(c=>u.jsxs("p",{className:"text-[10px] text-red-400",children:["Orphaned: ",c.name]},c.name))})]}),e.assets?.hasChanges&&u.jsx(Oj,{title:"Assets",children:u.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.assets.totalCreate>0&&u.jsxs(Sr,{variant:"outline",className:"h-5 text-[10px] text-green-500",children:["+",e.assets.totalCreate," upload"]}),e.assets.totalUpdate>0&&u.jsxs(Sr,{variant:"outline",className:"h-5 text-[10px] text-blue-500",children:["~",e.assets.totalUpdate," update"]}),e.assets.totalDelete>0&&u.jsxs(Sr,{variant:"outline",className:"h-5 text-[10px] text-red-500",children:["-",e.assets.totalDelete," delete"]})]})}),e.hasDestructiveStorageChanges&&u.jsxs("div",{className:"rounded-md border border-amber-500/20 bg-amber-500/5 p-3",children:[u.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-amber-400",children:[u.jsx(As,{className:"size-3.5 shrink-0"}),"Destructive changes"]}),u.jsx("p",{className:"mt-1 text-xs text-amber-400/80 pl-5.5",children:"This deploy will delete tables, knowledge bases, or assets."}),u.jsxs("div",{className:"mt-2 flex items-center gap-2 pl-5.5",children:[u.jsx(ow,{id:"confirm-destructive",checked:r,onCheckedChange:c=>s(c===!0)}),u.jsx(tv,{htmlFor:"confirm-destructive",className:"text-xs text-amber-400 cursor-pointer",children:"I confirm the destructive changes"})]})]}),e.secrets.missing.length>0&&u.jsxs("div",{className:"rounded-md border border-muted-foreground/10 p-3 space-y-2.5",children:[u.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium",children:[u.jsx(eI,{className:"size-3.5 text-muted-foreground/50 shrink-0"}),"Production Secrets"]}),e.secrets.missing.map(c=>u.jsxs("div",{className:"space-y-1 pl-5.5",children:[u.jsxs(tv,{htmlFor:`secret-${c.name}`,className:"text-xs",children:[c.name,c.optional&&u.jsx("span",{className:"text-muted-foreground/50 ml-1",children:"(optional)"}),!c.optional&&u.jsx("span",{className:"text-red-400 ml-0.5",children:"*"})]}),c.description&&u.jsx("p",{className:"text-[10px] text-muted-foreground/60",children:c.description}),u.jsx("input",{id:`secret-${c.name}`,type:"password",value:t[c.name]??"",onChange:l=>n(c.name,l.target.value),placeholder:`Enter ${c.name}`,className:"w-full rounded-md border border-muted-foreground/15 bg-background px-2.5 py-1.5 text-xs text-foreground placeholder:text-muted-foreground/40 focus:border-muted-foreground/30 focus:outline-none"})]},c.name)),u.jsx("p",{className:"text-[10px] text-muted-foreground/50 pl-5.5",children:"Secrets will be saved for future deploys."})]})]}),u.jsxs(df,{className:"mt-auto gap-2 sm:gap-0 shrink-0",children:[u.jsx(Pt,{variant:"ghost",size:"sm",onClick:i,className:"text-xs",children:"Cancel"}),u.jsxs(Pt,{size:"sm",onClick:a,disabled:!o,className:"text-xs",children:[u.jsx(RDe,{className:"size-3 mr-1.5"}),"Deploy"]})]})]})}function Gen({plan:e,stages:t,hasNewSecrets:n,isDone:r,result:s,error:o,onClose:a,onSwitchToProd:i}){const c=zen(e,n);return u.jsxs("div",{className:"flex h-full flex-col gap-4",children:[u.jsx("div",{className:"space-y-1",children:c.map((l,d)=>{const f=t[l.id];return u.jsx(or.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.25,delay:d*.04},children:u.jsx(Wen,{step:l,state:f})},l.id)})}),u.jsxs(Qi,{children:[r&&s?.success&&u.jsxs(or.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.3,delay:.1},className:"flex items-center gap-2 rounded-md border border-green-500/20 bg-green-500/5 py-3 px-3",children:[u.jsx(Ms,{className:"size-4 text-green-500 shrink-0"}),u.jsx("p",{className:"text-xs font-medium text-green-400",children:"Agent deployed successfully"})]}),r&&o&&u.jsxs(or.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.3,delay:.1},className:"flex items-start gap-2 rounded-md border border-red-500/20 bg-red-500/5 py-3 px-3",children:[u.jsx(yl,{className:"size-4 text-red-500 shrink-0 mt-0.5"}),u.jsx("p",{className:"text-xs text-red-400 break-words",children:o})]})]}),r&&u.jsxs(df,{className:"mt-auto gap-2 sm:gap-0",children:[u.jsx(Pt,{variant:"ghost",size:"sm",onClick:a,className:"text-xs",children:"Close"}),s?.success&&u.jsx(Pt,{size:"sm",onClick:i,className:"text-xs",children:"Switch to prod"})]})]})}function Wen({step:e,state:t}){const n=t?.status??"pending",r=t?.detail;return u.jsxs(or.div,{className:"flex items-center gap-3 py-0.5",animate:{opacity:n==="pending"?.5:1,x:n==="running"?2:0},transition:{duration:.2},children:[u.jsx(Ken,{status:n}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx(or.span,{className:me("text-xs inline-block",n==="complete"&&"text-muted-foreground",n==="running"&&"text-foreground font-medium",n==="error"&&"text-red-400",n==="pending"&&"text-muted-foreground/50"),layout:!0,children:e.label}),u.jsx(Qi,{children:r&&n==="complete"&&e.formatDetail&&u.jsx(or.span,{initial:{opacity:0,x:-4},animate:{opacity:1,x:0},className:"ml-1.5 text-[10px] text-muted-foreground/60",children:e.formatDetail(r)})}),u.jsx(Qi,{children:r&&n==="error"&&typeof r.message=="string"&&u.jsx(or.p,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},className:"text-[10px] text-red-400/80 truncate",children:r.message})})]})]})}function Ken({status:e}){return u.jsx("div",{className:"relative size-3.5 shrink-0",children:u.jsx(Qi,{mode:"popLayout",children:u.jsxs(or.div,{className:"absolute inset-0",initial:{scale:.5,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.5,opacity:0},transition:{duration:.2,ease:[.25,1,.5,1]},children:[e==="complete"&&u.jsx(Ms,{className:"size-3.5 text-green-500"}),e==="running"&&u.jsx(nn,{className:"size-3.5 animate-spin text-foreground"}),e==="error"&&u.jsx(yl,{className:"size-3.5 text-red-500"}),e==="pending"&&u.jsx(Ly,{className:"size-3.5 text-muted-foreground/30"})]},e)})})}function Zen({error:e,onRetry:t,onClose:n}){return u.jsxs("div",{className:"flex h-full flex-col gap-3",children:[u.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-red-500/20 bg-red-500/5 py-3 px-3",children:[u.jsx(yl,{className:"size-4 text-red-500 shrink-0 mt-0.5"}),u.jsx("p",{className:"text-xs text-red-400 break-words",children:e})]}),u.jsxs(df,{className:"mt-auto gap-2 sm:gap-0",children:[u.jsx(Pt,{variant:"ghost",size:"sm",onClick:n,className:"text-xs",children:"Close"}),u.jsx(Pt,{variant:"outline",size:"sm",onClick:t,className:"text-xs",children:"Retry"})]})]})}const abe=[{phase:"planning",label:"Build"},{phase:"review",label:"Review"},{phase:"deploying",label:"Deploy"},{phase:"complete",label:"Done"}];function Yen({phase:e}){const t={planning:0,review:1,deploying:2,complete:3,error:3},n=t[e],r=abe;return u.jsx("p",{className:"text-xs text-muted-foreground",children:r.map((s,o)=>{const a=t[s.phase];return u.jsxs("span",{children:[u.jsx("span",{className:me(a===n?"text-foreground":a<n?"text-muted-foreground/60":"text-muted-foreground/30"),children:s.label}),o<r.length-1&&u.jsx("span",{className:"mx-1.5 text-muted-foreground/20",children:"·"})]},s.phase)})})}function Oj({title:e,children:t}){return u.jsxs("div",{className:"rounded-md border border-muted-foreground/10 p-3 space-y-1.5",children:[u.jsx("h4",{className:"text-xs font-medium",children:e}),t]})}function Qen(){const e=bt(T=>T.selectedAgentPath),t=bt(T=>T.agents),n=ds(T=>T.connectionStatus),r=ds(T=>T.agent?.name||T.bot?.name),s=xs(T=>T.targetEnvironment),[o,a]=b.useState(!1),[i,c]=b.useState(!1),[l,d]=b.useState(!1),[f,p]=b.useState(!1),h=t.find(T=>T.agentPath===e),g=h?.consoleMode==="cloud",y=h?.name??r??"Agent",E=h?.status,x=_I({lifecycle:E,connectionStatus:n}),w=x.label!=="Connected",S=U7({consoleMode:h?.consoleMode,environment:s});return t.length===0?u.jsxs("span",{className:"flex items-center gap-1.5 px-1.5 py-0.5 text-[11px] font-medium text-foreground select-none",children:[u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx(LC,{status:x,className:"size-1.5"}),w&&u.jsx(AP,{status:x,className:"text-[10px] font-medium"})]}),u.jsx("span",{children:y}),S&&u.jsx(lK,{label:S})]}):u.jsxs(ul,{open:i,onOpenChange:c,children:[u.jsx(dl,{asChild:!0,children:u.jsxs("button",{className:me("flex items-center gap-1.5 px-2 py-0.5 rounded-sm cursor-pointer text-[11px] font-medium text-foreground","bg-muted-foreground/5 hover:bg-muted-foreground/15 data-[state=open]:bg-muted-foreground/15","focus:outline-none focus-visible:outline-none","transition-colors"),children:[u.jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[u.jsx(LC,{status:x,className:"size-1.5 shrink-0"}),w&&u.jsx(AP,{status:x,className:"text-[10px] font-medium"})]}),u.jsx("span",{className:"truncate max-w-[180px]",children:y}),S&&u.jsx(lK,{label:S}),u.jsx(Dr,{className:"size-3 text-muted-foreground/70",strokeWidth:2})]})}),u.jsx(Ki,{align:"center",sideOffset:8,className:me("bg-sidebar border-muted-foreground/10 p-1",g?"w-[480px]":"min-w-[260px] max-w-md"),children:u.jsx(E3e,{onOpenAbout:()=>a(!0),onClose:()=>c(!1),onCreateProject:()=>d(!0),onDeploy:()=>p(!0)})}),u.jsx(R3e,{open:f,onOpenChange:p}),u.jsx(zP,{open:o,onOpenChange:a}),u.jsx(fi,{open:l,onOpenChange:d,children:u.jsxs(Ci,{className:"max-w-3xl [&>button:last-child]:hidden",children:[u.jsx(wI,{children:u.jsx(Ni,{children:"Create project"})}),u.jsx($5,{onCancel:()=>d(!1)})]})})]})}const Qh=od()(VQ(e=>({mode:"topbar",sidebarCollapsed:!1,collapsedGroups:{},setMode:t=>e({mode:t}),toggleMode:()=>e(t=>({mode:t.mode==="topbar"?"sidebar":"topbar"})),setSidebarCollapsed:t=>e({sidebarCollapsed:t}),toggleSidebarCollapsed:()=>e(t=>({sidebarCollapsed:!t.sidebarCollapsed})),toggleGroupCollapsed:t=>e(n=>({collapsedGroups:{...n.collapsedGroups,[t]:!n.collapsedGroups[t]}}))}),{name:"adk-layout",partialize:e=>({mode:e.mode,sidebarCollapsed:e.sidebarCollapsed,collapsedGroups:e.collapsedGroups})})),r4=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.userAgent),$I=r4?"⌘":"Ctrl";function Iee(){document.dispatchEvent(new KeyboardEvent("keydown",{key:"k",metaKey:!0,ctrlKey:!0}))}function hp({children:e,className:t}){return u.jsx("kbd",{className:me("inline-flex h-4 min-w-4 items-center justify-center rounded-sm border border-current/25 bg-current/10 px-1 font-mono text-[9px]",t),children:e})}const j3e="adk-command-recents",Xen=4;function D3e(){try{return JSON.parse(localStorage.getItem(j3e)||"[]")}catch{return[]}}function ibe(e){const t=D3e().filter(n=>n!==e);t.unshift(e),localStorage.setItem(j3e,JSON.stringify(t.slice(0,Xen)))}function Jen(){return rI.flatMap(e=>e.items.map(t=>({title:t.title,url:t.url,icon:t.icon,group:e.items.length>1||e.title!==t.title?e.title:void 0,featureFlag:t.featureFlag??e.featureFlag,devOnly:t.devOnly})))}const etn=[{title:"Dev Console Home",url:"/",icon:wW,group:"General"},...Jen(),{title:"Workflow Runs",url:"/workflows/runs",icon:tc,group:"Workflows"}],ttn=[{title:"Settings Overview",url:"/settings?section=overview",icon:tI,group:"Agent Config"},{title:"Configuration Variables",url:"/settings?section=config-variables",icon:$De,group:"Agent Config"},{title:"Secrets",url:"/settings?section=secrets",icon:eI,group:"Agent Config"},{title:"LLM Config",url:"/settings?section=models",icon:CJ,group:"Agent Config"}],ntn=["**:[[cmdk-group-heading]]:text-[11px] **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground/30 **:[[cmdk-group-heading]]:normal-case **:[[cmdk-group-heading]]:tracking-normal **:[[cmdk-group-heading]]:px-3 **:[[cmdk-group-heading]]:py-2","**:[[cmdk-item]]:py-1.5 **:[[cmdk-item]]:px-3 **:[[cmdk-item]]:text-[13px] **:[[cmdk-item]]:rounded-sm **:[[cmdk-item]]:mx-1","**:[[cmdk-item]]:transition-all **:[[cmdk-item]]:duration-150 **:[[cmdk-item]]:ease-out","**:data-[slot=command-input-wrapper]:h-auto **:data-[slot=command-input-wrapper]:p-2 **:data-[slot=command-input-wrapper]:border-0","[&_[data-slot=command-input-wrapper]>div]:bg-muted [&_[data-slot=command-input-wrapper]>div]:rounded-md [&_[data-slot=command-input-wrapper]>div]:px-3 [&_[data-slot=command-input-wrapper]>div]:py-px","**:[[cmdk-list]]:transition-[height] **:[[cmdk-list]]:duration-100 **:[[cmdk-list]]:ease-out","[&_[cmdk-item][data-selected=true]]:bg-muted-foreground/8","**:[[cmdk-input]]:text-[13px]","[&_[cmdk-group]+[cmdk-group]]:border-t [&_[cmdk-group]+[cmdk-group]]:border-muted-foreground/8"].join(" ");function rtn(){const[e,t]=b.useState(!1),[n,r]=b.useState(""),[s,o]=b.useState(!1),[a,i]=b.useState(!1),c=Lc(),l=ui(),{theme:d,setTheme:f}=Oy(),p=Vt(ue=>ue.toggle),h=Vt(ue=>ue.isOpen),g=Vt(ue=>ue.clearMessages),y=Vt(ue=>ue.setQueuedPrompt),E=Vt(ue=>ue.setOpen),x=Vt(ue=>ue.setProvidersDialogOpen),{track:w}=lf(),S=Qh(ue=>ue.mode),T=Qh(ue=>ue.setMode),[k,A]=b.useState([]),{data:N}=pS(),j=N?.flags,O=hS("enable_agent_0"),{environment:D,isCloudConsoleMode:L}=Bc(),U=xs(ue=>ue.setTargetEnvironmentAndSync),B=bt(ue=>ue.setSelectedAgentPath),M=O&&D!=="prod"&&!L,$=b.useCallback(ue=>{B(ue.agentPath)},[B]),{pickAndOpenProject:P,isOpening:q,openingName:z,openError:G,clearError:R}=nI({onSuccess:$}),W=b.useMemo(()=>ttn.filter(ue=>!((D==="prod"||L)&&ue.url.endsWith("section=models")||L&&ue.url.endsWith("section=secrets"))),[D,L]),V=b.useMemo(()=>[...etn,...W].filter(ue=>!ue.featureFlag||j?.[ue.featureFlag]),[W,j]),I=b.useMemo(()=>Object.fromEntries(V.map(ue=>[ue.url,ue])),[V]);b.useEffect(()=>{e&&A(D3e())},[e]),b.useEffect(()=>{l.pathname!=="/"&&ibe(`${l.pathname}${l.search}`)},[l.pathname,l.search]);const{data:J}=cm(),{data:te}=lc(),X=te?.credentials,ne=D==="dev"?"prod":"dev",re=!L&&(ne==="dev"||!!X?.prodBotId),{botUrl:se}=e4(),ce=b.useCallback(ue=>se(ue,X?.workspaceId),[se,X?.workspaceId]),ie=b.useCallback(ue=>{g(),y(ue),E(!0)},[g,y,E]),le=b.useCallback(async(ue,Ie)=>{try{await navigator.clipboard.writeText(ue),qn.success(`${Ie} copied to clipboard`)}catch{qn.error(`Failed to copy ${Ie.toLowerCase()}`)}},[]),oe=b.useMemo(()=>k.map(ue=>I[ue]).filter(Boolean),[k,I]),be=b.useMemo(()=>[{id:"toggle-theme",title:d==="dark"?"Switch to light mode":"Switch to dark mode",icon:d==="dark"?DDe:CDe,action:()=>f(d==="dark"?"light":"dark")},...d!=="system"?[{id:"use-system-theme",title:"Use system theme",icon:kDe,action:()=>f("system")}]:[],{id:"switch-layout",title:S==="topbar"?"Switch to sidebar layout":"Switch to topbar layout",icon:S==="topbar"?TJ:NDe,action:()=>T(S==="topbar"?"sidebar":"topbar")},...re?[{id:"switch-environment",title:`Switch to ${ne==="prod"?"production":"development"}`,icon:nP,action:()=>void U(ne)}]:[],...L?[]:[{id:"create-project",title:"Create project",icon:ld,action:()=>i(!0)},{id:"open-project",title:z?`Opening ${z}...`:"Open project",icon:nc,action:()=>void P(),disabled:q}],{id:"about-agent",title:"About this agent",icon:SW,action:()=>o(!0)},...M?[{id:"toggle-agent0",title:"Toggle agent0",agent0Logo:!0,action:()=>{h||w("agent0.panel_opened",{source:"command_palette"}),p()}},{id:"configure-agent0",title:"Manage agent0 providers",agent0Logo:!0,action:()=>x(!0)}]:[],...X?.devBotId&&X?.workspaceId?[{id:"open-dev-bot",title:"Open dev bot in Botpress",icon:YE,action:()=>window.open(ce(X.devBotId),"_blank")}]:[],...X?.prodBotId&&X?.workspaceId?[{id:"open-prod-bot",title:"Open prod bot in Botpress",icon:YE,action:()=>window.open(ce(X.prodBotId),"_blank")}]:[],...J?.path?[{id:"copy-project-path",title:"Copy project path",icon:li,action:()=>le(J.path,"Project path")}]:[],...X?.devBotId?[{id:"copy-dev-bot-id",title:"Copy dev bot ID",icon:li,action:()=>le(X.devBotId,"Dev bot ID")}]:[],...X?.prodBotId?[{id:"copy-prod-bot-id",title:"Copy prod bot ID",icon:li,action:()=>le(X.prodBotId,"Prod bot ID")}]:[],...X?.workspaceId?[{id:"copy-workspace-id",title:"Copy workspace ID",icon:li,action:()=>le(X.workspaceId,"Workspace ID")}]:[]],[d,f,S,T,re,ne,U,L,i,z,P,q,o,p,h,w,M,x,X,J,ce,le]),Ee=b.useCallback(ue=>{t(!1),ue()},[t]),xe=b.useCallback(ue=>{ibe(ue),Ee(()=>c(ue))},[c,Ee]);b.useEffect(()=>{e||r("")},[e]),b.useEffect(()=>{const ue=Ie=>{(r4?Ie.metaKey:Ie.ctrlKey)&&Ie.key==="k"&&(Ie.preventDefault(),t(Be=>!Be))};return document.addEventListener("keydown",ue),()=>document.removeEventListener("keydown",ue)},[]);let we=0;return u.jsxs(g5,{open:e,onOpenChange:t,children:[u.jsxs(y5,{children:[u.jsx(iI,{className:"fixed inset-0 z-50 bg-black/60 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"}),u.jsxs(lI,{className:me("fixed left-1/2 top-[18%] z-50 w-full max-w-[440px] -translate-x-1/2 outline-hidden","rounded-lg border border-muted-foreground/15 bg-sidebar text-popover-foreground shadow-2xl","data-[state=open]:animate-command-palette-in data-[state=closed]:animate-command-palette-out"),children:[u.jsx(b5,{className:"sr-only",children:"Command palette"}),u.jsx(v5,{className:"sr-only",children:"Search for pages and commands"}),u.jsxs(o3e,{className:ntn,filter:(ue,Ie)=>ue==="ask-agent0"?M?1:0:ue.toLowerCase().includes(Ie.toLowerCase())?1:0,children:[u.jsx(u7t,{placeholder:"Search...",value:n,onValueChange:r}),u.jsxs(a3e,{className:"max-h-[min(360px,50vh)]",children:[u.jsx(i3e,{children:u.jsx("span",{className:"text-muted-foreground/40",children:"No results found."})}),oe.length>0&&!n&&u.jsx(_A,{heading:"Recent",children:oe.map(ue=>{const Ie=we++,Be=D==="prod"&&ue.devOnly;return u.jsx(or.div,{initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.15,delay:Ie*.02,ease:[.25,1,.5,1]},children:u.jsxs(TA,{value:`recent-${ue.title}`,disabled:Be,onSelect:Be?void 0:()=>xe(ue.url),children:[u.jsx(ue.icon,{className:me("size-4",Be&&"opacity-30")}),u.jsx("span",{className:Be?"text-muted-foreground/30":void 0,children:ue.title}),ue.group&&u.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground/20",children:ue.group})]})},`recent-${ue.url}`)})}),u.jsx(_A,{heading:"Pages",children:V.map(ue=>{const Ie=we++,Be=D==="prod"&&ue.devOnly;return u.jsx(or.div,{initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.15,delay:Ie*.02,ease:[.25,1,.5,1]},children:u.jsxs(TA,{disabled:Be,onSelect:Be?void 0:()=>xe(ue.url),children:[u.jsx(ue.icon,{className:me("size-4",Be&&"opacity-30")}),u.jsx("span",{className:Be?"text-muted-foreground/30":void 0,children:ue.title}),ue.group&&u.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground/20",children:ue.group})]})},ue.url)})}),u.jsx(_A,{heading:"Commands",children:be.map(ue=>{const Ie=we++;return u.jsx(or.div,{initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.15,delay:Ie*.02,ease:[.25,1,.5,1]},children:u.jsxs(TA,{disabled:ue.disabled,onSelect:ue.disabled?void 0:()=>Ee(ue.action),children:[ue.agent0Logo?u.jsx(xy,{className:me("size-4",ue.disabled&&"opacity-30"),active:ue.id==="toggle-agent0"&&h,animation:"shimmer",muted:ue.id!=="toggle-agent0"||!h,shape:"circle"}):ue.icon&&u.jsx(ue.icon,{className:me("size-4",ue.disabled&&"opacity-30")}),u.jsx("span",{className:ue.disabled?"text-muted-foreground/30":void 0,children:ue.title})]})},ue.id)})}),M&&n.trim().length>0&&u.jsx(_A,{heading:"agent0",forceMount:!0,children:u.jsxs(TA,{value:"ask-agent0",onSelect:()=>Ee(()=>ie(n.trim())),className:"agent0-glow",children:[u.jsx(xy,{className:"size-4",active:!0,animation:"shimmer",shape:"circle"}),u.jsxs("span",{className:"truncate",children:["Ask agent0 ",u.jsxs("span",{className:"text-muted-foreground/40",children:["“",n.trim(),"”"]})]})]})})]}),u.jsxs("div",{className:"flex items-center gap-3 px-3 py-1.5 bg-muted",children:[u.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground/50",children:[u.jsx(Wu,{className:"size-2.5"}),u.jsx(Gu,{className:"size-2.5"}),u.jsx("span",{className:"text-[10px]",children:"navigate"})]}),u.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground/50",children:[u.jsx(LCt,{className:"size-2.5"}),u.jsx("span",{className:"text-[10px]",children:"select"})]}),u.jsx("span",{className:"flex items-center gap-1 text-muted-foreground/50",children:u.jsx("span",{className:"text-[10px]",children:"esc close"})}),u.jsxs("span",{className:"ml-auto flex items-center gap-0.5",children:[u.jsx(hp,{children:$I}),u.jsx(hp,{children:"K"})]})]})]})]})]}),u.jsx(zP,{open:s,onOpenChange:o}),u.jsx(fi,{open:a,onOpenChange:i,children:u.jsxs(Ci,{className:"max-w-3xl [&>button:last-child]:hidden",children:[u.jsx(wI,{children:u.jsx(Ni,{children:"Create project"})}),u.jsx($5,{onCancel:()=>i(!1)})]})}),u.jsx(z7,{error:G,onDismiss:R})]})}function $K({tooltipSide:e="right",buttonClassName:t,iconClassName:n}){const r=hS("enable_agent_0"),s=xs(c=>c.targetEnvironment),o=Vt(c=>c.isOpen),a=Vt(c=>c.toggle),{track:i}=lf();return r?s==="prod"?u.jsxs(vn,{delayDuration:300,children:[u.jsx(xn,{asChild:!0,children:u.jsx("span",{className:me("size-8 flex items-center justify-center rounded-md text-muted-foreground/20 cursor-not-allowed",t),children:u.jsx(xy,{className:me("size-4",n),muted:!0,shape:"circle"})})}),u.jsx(yn,{side:e,sideOffset:8,className:"text-xs",children:"agent0 is not available in production"})]}):u.jsxs(vn,{delayDuration:300,children:[u.jsx(xn,{asChild:!0,children:u.jsx("button",{type:"button",onClick:()=>{o||i("agent0.panel_opened",{source:"toggle_button"}),a()},"aria-label":o?"Close agent0":"Open agent0","aria-pressed":o,className:me("size-8 flex items-center justify-center rounded-md transition-colors cursor-pointer","text-muted-foreground/60 hover:text-foreground",t),children:u.jsx(xy,{className:me("size-4",n),active:o,animation:"shimmer",muted:!o,shape:"circle"})})}),u.jsxs(yn,{side:e,sideOffset:8,className:"text-xs flex items-center gap-1.5",children:[o?"Close agent0":"Open agent0",u.jsxs("span",{className:"flex items-center gap-0.5",children:[u.jsx(hp,{className:"h-3.5 min-w-3.5 px-0.5 text-[9px]",children:$I}),u.jsx(hp,{className:"h-3.5 min-w-3.5 px-0.5 text-[9px]",children:"]"})]})]})]}):null}const stn=80,otn=200,O3e={};function atn({item:e,isActive:t,isDisabled:n,activeSubItem:r,onHoverStart:s,onHoverEnd:o,onClick:a,buttonRef:i}){r&&(O3e[e.title]=r);const c=e.title;return u.jsx("div",{onMouseEnter:n?void 0:s,onMouseLeave:n?void 0:o,children:u.jsxs("button",{ref:i,onClick:n?void 0:a,className:me("relative px-2 py-0.5 rounded-sm text-[11px] font-medium transition-colors",n?"text-muted-foreground/30 cursor-not-allowed":t?"text-foreground cursor-pointer":"text-muted-foreground hover:text-foreground cursor-pointer"),children:[t&&!n&&u.jsx(or.div,{layoutId:"nav-pill",className:"absolute inset-0 bg-muted-foreground/10 rounded-sm",transition:{type:"spring",stiffness:500,damping:35}}),u.jsx("span",{className:"relative z-10",children:c})]})})}function itn({item:e,activeSubItem:t,left:n,environment:r,onHoverStart:s,onHoverEnd:o,onNavigate:a}){return u.jsx(or.div,{layout:!0,initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.15,ease:[.25,1,.5,1]},className:"fixed top-[calc(var(--header-height)+2px)] z-50 overflow-hidden bg-sidebar rounded-md border border-muted-foreground/10 shadow-lg",onMouseEnter:s,onMouseLeave:o,style:{left:n},children:u.jsx("div",{className:"py-1 px-1 whitespace-nowrap",children:u.jsx(Qi,{mode:"wait",children:u.jsx(or.div,{initial:{opacity:0,x:-4},animate:{opacity:1,x:0},exit:{opacity:0,x:4},transition:{duration:.1,ease:"easeOut"},children:e.items.map(i=>{const c=t?.url===i.url;return r==="prod"&&i.devOnly?u.jsxs("span",{className:"icon-hover flex items-center gap-1.5 rounded-sm px-2 py-1 text-[11px] text-muted-foreground/30 cursor-not-allowed",children:[u.jsx(i.icon,{className:"size-3.5"}),i.title]},i.url):u.jsxs(Fc,{to:i.url,onClick:a,className:me("icon-hover flex items-center gap-1.5 rounded-sm px-2 py-1 text-[11px] transition-colors",c?"text-foreground bg-muted-foreground/10":"text-muted-foreground hover:text-foreground"),children:[u.jsx(i.icon,{className:"size-3.5"}),i.title]},i.url)})},e.title)})})})}function ltn({items:e,pathname:t,environment:n}){const r=Lc(),[s,o]=b.useState(null),a=b.useRef({}),i=b.useRef(null),c=b.useRef(null),l=b.useRef(!1),d=e.filter(w=>w.kind==="group"),f=b.useCallback(w=>{l.current||(c.current&&clearTimeout(c.current),i.current=setTimeout(()=>o(w),stn))},[]),p=b.useCallback(()=>{l.current=!1,i.current&&clearTimeout(i.current),c.current=setTimeout(()=>o(null),otn)},[]),h=b.useCallback(w=>{l.current=!0,i.current&&clearTimeout(i.current),o(null);const S=hk(w.items,t),T=O3e[w.title],k=T&&w.items.some(N=>N.url===T.url)?T:void 0,A=S??k??w.items[0];r(A.url)},[r,t]),g=b.useCallback(()=>{l.current=!0,o(null)},[]);b.useEffect(()=>()=>{i.current&&clearTimeout(i.current),c.current&&clearTimeout(c.current)},[]);const y=d.find(w=>w.title===s),E=s?a.current[s]?.getBoundingClientRect().left??0:0,x=y?hk(y.items,t):void 0;return u.jsxs(u.Fragment,{children:[u.jsx("nav",{className:"flex items-center gap-0.5",children:u.jsx(Y5t,{children:d.map(w=>{const S=hk(w.items,t),T=n==="prod"&&w.items.every(k=>k.devOnly);return u.jsx(atn,{item:w,isActive:!!S,isDisabled:T,activeSubItem:S,onHoverStart:()=>f(w.title),onHoverEnd:p,onClick:()=>h(w),buttonRef:k=>{a.current[w.title]=k}},w.title)})})}),u.jsx(Qi,{children:y&&u.jsx(itn,{item:y,activeSubItem:x,left:E,environment:n,onHoverStart:()=>f(y.title),onHoverEnd:p,onNavigate:g},"shared-dropdown")})]})}function ctn(){const e=xs(o=>o.targetEnvironment),t=ui(),{data:n}=pS(),r=n?.flags,s=OJ(rI,r);return u.jsxs("header",{className:"shrink-0 h-(--header-height) bg-sidebar flex items-center px-2 relative z-50",children:[u.jsx(ltn,{items:s,pathname:t.pathname,environment:e}),u.jsx("div",{className:"absolute left-1/2 -translate-x-1/2",children:u.jsx(Qen,{})}),u.jsx("div",{className:"flex-1"}),u.jsxs("div",{className:"flex items-center gap-0.5",children:[u.jsxs(vn,{delayDuration:0,children:[u.jsx(xn,{asChild:!0,children:u.jsx("button",{type:"button",onClick:Iee,"aria-label":"Search",className:"size-7 flex items-center justify-center rounded-md text-muted-foreground/60 hover:text-foreground transition-colors cursor-pointer",children:u.jsx(ea,{className:"size-3.5"})})}),u.jsxs(yn,{side:"bottom",sideOffset:6,className:"text-xs flex items-center gap-1.5",children:["Search",u.jsxs("span",{className:"flex items-center gap-0.5",children:[u.jsx(hp,{className:"h-3.5 min-w-3.5 text-[9px] px-0.5",children:$I}),u.jsx(hp,{className:"h-3.5 min-w-3.5 text-[9px] px-0.5",children:"K"})]})]})]}),u.jsx($K,{tooltipSide:"bottom",buttonClassName:"size-7",iconClassName:"size-3.5"})]})]})}const lbe=["#3B82F6","#8B5CF6","#EC4899","#F97316","#10B981","#06B6D4","#6366F1","#F43F5E","#14B8A6","#A855F7"];function utn(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t);return lbe[Math.abs(t)%lbe.length]}function cbe({groupId:e,value:t,onChange:n,options:r}){return u.jsx("div",{className:"relative flex items-center gap-0.5 rounded-md bg-muted/50 p-0.5",children:r.map(s=>{const o=s.value===t,a=s.icon;return u.jsxs("button",{type:"button",onClick:()=>n(s.value),"aria-label":s.label,"aria-pressed":o,className:me("relative flex items-center justify-center size-6 rounded-sm transition-colors cursor-pointer",o?"text-foreground":"text-muted-foreground/60 hover:text-foreground"),children:[o&&u.jsx(or.span,{layoutId:`segmented-active-${e}`,className:"absolute inset-0 bg-background rounded-sm shadow-sm",transition:{type:"spring",stiffness:500,damping:35}}),u.jsx(or.span,{className:"relative z-10 flex",initial:!1,animate:o?{scale:1.05,rotate:0}:{scale:1,rotate:0},whileHover:{scale:1.15,rotate:o?0:-8},whileTap:{scale:.9},transition:{type:"spring",stiffness:600,damping:20},children:u.jsx(a,{className:"size-3.5"})})]},s.value)})})}function LK({side:e="bottom",align:t="end",triggerClassName:n}){const{theme:r,setTheme:s}=Oy(),o=Qh(B=>B.mode),a=Qh(B=>B.setMode),{agent:i,bot:c,connectionStatus:l}=ds(),d=xs(B=>B.targetEnvironment),{data:f}=lc(),{track:p,isEnabled:h}=lf(),[g,y]=b.useState(!1),[E,x]=b.useState(!1),w=i?.name||c?.name||"Agent",S=f?.identity,T=S?.displayName||S?.email,k=S?.email,A=T||w,N=A.charAt(0).toUpperCase(),j=utn(A),O=d==="prod",D=_I({connectionStatus:l}),L=O?"bg-purple-500":D.dotClassName,U=r==="light"||r==="dark"||r==="system"?r:"dark";return u.jsxs(u.Fragment,{children:[u.jsxs(Fv,{open:g,onOpenChange:y,children:[u.jsx(mS,{asChild:!0,children:u.jsxs("button",{type:"button","aria-label":"Profile menu",className:me("relative flex items-center justify-center rounded-full transition-opacity hover:opacity-90 cursor-pointer",n),children:[u.jsx("span",{className:"flex items-center justify-center size-6 rounded-full text-[11px] font-semibold text-white",style:{backgroundColor:j},children:N}),u.jsx("span",{className:me("absolute -bottom-0.5 -right-0.5 size-2 rounded-full ring-2 ring-sidebar",L)})]})}),u.jsxs(zy,{side:e,align:t,sideOffset:8,className:"w-60 p-0 bg-popover border-muted-foreground/15",children:[u.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5",children:[u.jsx("span",{className:"flex items-center justify-center size-7 rounded-full text-[12px] font-semibold text-white shrink-0",style:{backgroundColor:j},children:N}),u.jsx("div",{className:"flex-1 min-w-0",children:T?u.jsxs(u.Fragment,{children:[u.jsx("p",{className:"text-[12px] font-semibold text-foreground truncate",children:T}),k&&k!==T&&u.jsx("p",{className:"text-[10px] text-muted-foreground/70 truncate",children:k})]}):u.jsx("p",{className:"text-[12px] font-semibold text-foreground truncate",children:w})})]}),u.jsx("div",{className:"h-px bg-muted-foreground/15"}),u.jsx("div",{className:"px-3 pt-2 pb-1 text-[10px] font-medium text-muted-foreground/50 select-none",children:"Preferences"}),u.jsxs("div",{className:"px-3 pb-2 flex flex-col gap-1",children:[u.jsxs("div",{className:"flex items-center justify-between h-7",children:[u.jsx("span",{className:"text-[11px] text-muted-foreground",children:"Theme"}),u.jsx(cbe,{groupId:"theme",value:U,onChange:B=>s(B),options:[{value:"light",icon:DDe,label:"Light"},{value:"dark",icon:CDe,label:"Dark"},{value:"system",icon:kDe,label:"System"}]})]}),u.jsxs("div",{className:"flex items-center justify-between h-7",children:[u.jsx("span",{className:"text-[11px] text-muted-foreground",children:"Layout"}),u.jsx(cbe,{groupId:"layout",value:o,onChange:B=>a(B),options:[{value:"topbar",icon:NDe,label:"Topbar"},{value:"sidebar",icon:TJ,label:"Sidebar"}]})]})]}),u.jsx("div",{className:"h-px bg-muted-foreground/15"}),h&&u.jsxs("button",{type:"button",onClick:()=>{y(!1),p("feedback.opened",{source:"profile_menu"})},className:"w-full flex items-center gap-2 px-3 h-9 text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted/40 transition-colors cursor-pointer",children:[u.jsx(n5,{className:"size-3.5 text-muted-foreground/60"}),"Send feedback"]}),u.jsx("div",{className:"h-px bg-muted-foreground/15"}),u.jsxs("button",{type:"button",onClick:()=>{y(!1),x(!0)},className:"w-full flex items-center gap-2 px-3 h-9 text-[11px] text-muted-foreground hover:text-destructive hover:bg-muted/40 transition-colors cursor-pointer",children:[u.jsx(_J,{className:"size-3.5 text-muted-foreground/60"}),"Sign out"]})]})]}),u.jsx($Oe,{open:E,onOpenChange:x})]})}function dtn(e,t){for(const n of e)if(hk(n.items,t))return n;return null}function ftn({item:e,isActive:t,isDisabled:n,index:r}){const s=e.icon;return u.jsx(or.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{duration:.18,delay:r*.06,ease:[.25,1,.5,1]},children:u.jsxs(vn,{delayDuration:0,children:[u.jsx(xn,{asChild:!0,children:n?u.jsx("span",{className:"flex items-center justify-center size-8 rounded-md text-muted-foreground/20 cursor-not-allowed",children:u.jsx(s,{className:"size-4"})}):u.jsx(Fc,{to:e.url,className:me("flex items-center justify-center size-8 rounded-md transition-colors",t?"text-foreground bg-muted-foreground/10":"text-muted-foreground/50 hover:text-foreground"),children:u.jsx(s,{className:"size-4"})})}),u.jsx(yn,{side:"right",sideOffset:8,className:"text-xs",children:e.title})]})})}function ptn({group:e,pathname:t,environment:n}){return u.jsx(u.Fragment,{children:e.items.map((r,s)=>u.jsx(ftn,{item:r,isActive:d5(t,r.url),isDisabled:n==="prod"&&!!r.devOnly,index:s},r.url))})}function htn(){const{pathname:e}=ui(),{data:t}=pS(),n=t?.flags,r=xs(i=>i.targetEnvironment),o=OJ(rI,n).filter(i=>i.kind==="group"),a=dtn(o,e);return u.jsxs("nav",{className:"shrink-0 w-[44px] flex flex-col items-center bg-sidebar",children:[u.jsx(Fc,{to:"/","aria-label":"Dev Console home",className:"size-8 flex items-center justify-center cursor-pointer shrink-0 my-1.5",children:u.jsx("span",{className:"size-7 rounded-sm bg-sidebar-primary flex items-center justify-center p-1.5",children:u.jsx("img",{src:"/ADK.svg",alt:"ADK",className:"size-full invert"})})}),u.jsx("div",{className:"w-5 h-px bg-muted-foreground/15 shrink-0 mb-2"}),u.jsx("div",{className:"flex flex-col items-center gap-1",children:a&&u.jsx(ptn,{group:a,pathname:e,environment:r},a.title)}),u.jsx("div",{className:"flex-1"}),u.jsx("div",{className:"flex flex-col items-center gap-2 pb-3",children:u.jsx(LK,{side:"right",align:"end"})})]})}function M3e(){const e=bt(s=>s.baseUrl),t=bt(s=>s.setAgents),n=e??(typeof window<"u"?window.location.origin:null),r=Vn({queryKey:["agents",n],queryFn:async()=>{if(!n)throw new Error("No base URL configured");const s=await fetch(`${n}/api/agents`,{signal:AbortSignal.timeout(2e3)});if(!s.ok)throw new Error("Failed to fetch agents");return s.json()},refetchInterval:3e3,enabled:n!==null});return b.useEffect(()=>{r.data?.agents&&t(r.data.agents)},[r.data,t]),r}function mtn({onOpenAbout:e}){const[t,n]=b.useState(!1),[r,s]=b.useState(!1),[o,a]=b.useState(!1),i=bt(w=>w.selectedAgentPath),c=bt(w=>w.agents),l=ds(w=>w.agent?.name||w.bot?.name),d=ds(w=>w.connectionStatus),f=xs(w=>w.targetEnvironment),p=c.find(w=>w.agentPath===i),h=p?.name??l??"Agent",g=p?.status,y=p?.consoleMode==="cloud",E=_I({lifecycle:g,connectionStatus:d}),x=U7({consoleMode:p?.consoleMode,environment:f});return u.jsxs(ul,{open:t,onOpenChange:n,children:[u.jsx(dl,{asChild:!0,children:u.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-2 h-9 rounded-md hover:bg-muted-foreground/5 data-[state=open]:bg-muted-foreground/5 transition-colors cursor-pointer text-left",children:[u.jsx("span",{className:"size-7 rounded-sm bg-sidebar-primary flex items-center justify-center p-1.5 shrink-0",children:u.jsx("img",{src:"/ADK.svg",alt:"ADK",className:"size-full invert"})}),u.jsxs("span",{className:"flex-1 min-w-0",children:[u.jsxs("span",{className:"flex items-center gap-1 min-w-0",children:[u.jsx("span",{className:"min-w-0 truncate text-[12px] font-medium text-foreground",children:h}),x&&u.jsx(lK,{label:x,className:"shrink-0"})]}),u.jsxs("span",{className:"flex items-center gap-1 min-w-0",children:[u.jsx(LC,{status:E,className:"size-1.5 shrink-0"}),u.jsx(AP,{status:E,className:"block text-[10px] truncate"})]})]}),u.jsx(Dr,{className:"size-3.5 text-muted-foreground/60 shrink-0",strokeWidth:2})]})}),u.jsx(Ki,{side:"bottom",align:"start",sideOffset:6,className:me("bg-sidebar border-muted-foreground/10 p-1",y?"w-[480px]":"min-w-[260px] max-w-[420px]"),children:u.jsx(E3e,{onOpenAbout:e,onClose:()=>n(!1),onCreateProject:()=>s(!0),onDeploy:()=>a(!0)})}),u.jsx(R3e,{open:o,onOpenChange:a}),u.jsx(fi,{open:r,onOpenChange:s,children:u.jsxs(Ci,{className:"max-w-3xl [&>button:last-child]:hidden",children:[u.jsx(wI,{children:u.jsx(Ni,{children:"Create project"})}),u.jsx($5,{onCancel:()=>s(!1)})]})})]})}function P3e({sub:e,pathname:t,environment:n}){const r=d5(t,e.url),s=n==="prod"&&!!e.devOnly,o=e.icon;return s?u.jsxs("span",{"aria-disabled":"true",className:"flex items-center gap-2 h-7 px-2 rounded-md text-[11px] text-muted-foreground/25 cursor-not-allowed",children:[u.jsx(o,{className:"size-3.5 shrink-0"}),u.jsx("span",{className:"truncate",children:e.title})]}):u.jsxs(Fc,{to:e.url,className:me("flex items-center gap-2 h-7 px-2 rounded-md text-[11px] transition-colors",r?"bg-muted-foreground/10 text-foreground":"text-muted-foreground hover:text-foreground hover:bg-muted-foreground/5"),children:[u.jsx(o,{className:"size-3.5 shrink-0 text-muted-foreground/60"}),u.jsx("span",{className:"truncate",children:e.title})]})}function gtn({group:e,pathname:t,environment:n}){const r=Qh(a=>a.collapsedGroups[e.title]??!1),s=Qh(a=>a.toggleGroupCollapsed),o=!r;return u.jsxs("div",{className:"flex flex-col",children:[u.jsxs("button",{type:"button",onClick:()=>s(e.title),"aria-expanded":o,className:"group/label flex items-center gap-2 h-7 px-2 text-[10px] font-medium text-muted-foreground/50 hover:text-muted-foreground transition-colors select-none cursor-pointer",children:[u.jsx("span",{className:"flex-1 text-left truncate",children:e.title}),u.jsx(Dr,{className:me("size-3 text-muted-foreground/40 transition-transform duration-200",!o&&"-rotate-90")})]}),u.jsx("div",{className:me("grid transition-[grid-template-rows] duration-200 ease-out",o?"grid-rows-[1fr]":"grid-rows-[0fr]"),children:u.jsx("div",{className:"overflow-hidden",children:u.jsx("div",{className:"flex flex-col gap-0.5 pb-1",children:e.items.map(a=>u.jsx(P3e,{sub:a,pathname:t,environment:n},a.url))})})})]})}function ytn(){return u.jsxs("button",{type:"button",onClick:Iee,className:"w-full flex items-center gap-2 h-7 px-2 rounded-md text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted-foreground/5 transition-colors cursor-pointer",children:[u.jsx(ea,{className:"size-3.5 shrink-0 text-muted-foreground/60"}),u.jsx("span",{className:"flex-1 text-left",children:"Search"}),u.jsxs("span",{className:"flex items-center gap-0.5",children:[u.jsx(hp,{className:"h-3.5 min-w-3.5 text-[9px] px-0.5",children:$I}),u.jsx(hp,{className:"h-3.5 min-w-3.5 text-[9px] px-0.5",children:"K"})]})]})}function btn({sub:e,pathname:t,environment:n}){const r=d5(t,e.url),s=n==="prod"&&!!e.devOnly,o=e.icon;return u.jsxs(vn,{delayDuration:0,children:[u.jsx(xn,{asChild:!0,children:s?u.jsx("span",{className:"flex items-center justify-center size-8 rounded-md text-muted-foreground/20 cursor-not-allowed",children:u.jsx(o,{className:"size-4"})}):u.jsx(Fc,{to:e.url,className:me("flex items-center justify-center size-8 rounded-md transition-colors",r?"bg-muted-foreground/10 text-foreground":"text-muted-foreground/60 hover:text-foreground hover:bg-muted-foreground/5"),children:u.jsx(o,{className:"size-4"})})}),u.jsx(yn,{side:"right",sideOffset:8,className:"text-xs",children:e.title})]})}function vtn(){const{pathname:e}=ui(),[t,n]=b.useState(!1);M3e();const{data:r}=pS(),s=r?.flags,o=xs(w=>w.targetEnvironment),{connectionStatus:a}=ds(),i=bt(w=>w.selectedAgentPath),c=bt(w=>w.agents),l=Qh(w=>w.sidebarCollapsed),d=Qh(w=>w.toggleSidebarCollapsed),p=OJ(rI,s).filter(w=>w.kind==="group"),h=c.find(w=>w.agentPath===i),g=h?.status,y=_I({lifecycle:g,connectionStatus:a}),E=U7({consoleMode:h?.consoleMode,environment:o}),x=E?`${E} - ${y.label}`:y.label;return l?u.jsxs("nav",{"aria-label":"Main",className:"shrink-0 w-[44px] flex flex-col items-center bg-sidebar",children:[u.jsxs(vn,{delayDuration:0,children:[u.jsx(xn,{asChild:!0,children:u.jsx(Fc,{to:"/","aria-label":`Dev Console home, ${x}`,className:"size-8 flex items-center justify-center cursor-pointer shrink-0 mt-1.5 mb-1.5",children:u.jsxs("span",{className:"relative size-7 rounded-sm bg-sidebar-primary flex items-center justify-center p-1.5",children:[u.jsx("img",{src:"/ADK.svg",alt:"ADK",className:"size-full invert"}),E&&u.jsx("span",{className:"absolute -top-0.5 -right-1 flex h-3 min-w-3 items-center justify-center rounded-sm bg-purple-500 px-[2px] text-[7px] font-semibold leading-3 text-white ring-2 ring-sidebar",children:E[0]}),u.jsx(LC,{status:y,className:"absolute -bottom-0.5 -right-0.5 size-2",ringClassName:"ring-2 ring-sidebar"})]})})}),u.jsxs(yn,{side:"right",sideOffset:8,className:"text-xs",children:["Dev Console home - ",x]})]}),u.jsx("div",{className:"w-5 h-px bg-muted-foreground/15 shrink-0 mb-2"}),u.jsxs(vn,{delayDuration:0,children:[u.jsx(xn,{asChild:!0,children:u.jsx("button",{type:"button",onClick:Iee,"aria-label":"Search",className:"flex items-center justify-center size-8 rounded-md text-muted-foreground/60 hover:text-foreground hover:bg-muted-foreground/5 transition-colors cursor-pointer",children:u.jsx(ea,{className:"size-4"})})}),u.jsxs(yn,{side:"right",sideOffset:8,className:"text-xs flex items-center gap-1.5",children:["Search",u.jsxs("span",{className:"flex items-center gap-0.5",children:[u.jsx(hp,{className:"h-3.5 min-w-3.5 text-[9px] px-0.5",children:$I}),u.jsx(hp,{className:"h-3.5 min-w-3.5 text-[9px] px-0.5",children:"K"})]})]})]}),u.jsx("div",{className:"flex-1 overflow-y-auto overflow-x-hidden flex flex-col items-center gap-1 mt-2 pb-2 w-full",children:p.map((w,S)=>u.jsxs("div",{className:"flex flex-col items-center gap-1 w-full",children:[S>0&&w.title!=="Chat"&&u.jsx("div",{className:"w-5 h-px bg-muted-foreground/10 shrink-0 my-1"}),w.items.map(T=>u.jsx(btn,{sub:T,pathname:e,environment:o},T.url))]},w.title))}),u.jsxs("div",{className:"shrink-0 flex flex-col items-center gap-1 pb-2",children:[u.jsx($K,{tooltipSide:"right"}),u.jsxs(vn,{delayDuration:0,children:[u.jsx(xn,{asChild:!0,children:u.jsx("button",{type:"button",onClick:d,"aria-label":"Expand sidebar",className:"flex items-center justify-center size-8 rounded-md text-muted-foreground/60 hover:text-foreground hover:bg-muted-foreground/5 transition-colors cursor-pointer",children:u.jsx(TJ,{className:"size-4"})})}),u.jsx(yn,{side:"right",sideOffset:8,className:"text-xs",children:"Expand sidebar"})]}),u.jsx(LK,{side:"right",align:"end"})]}),u.jsx(zP,{open:t,onOpenChange:n})]}):u.jsxs("nav",{"aria-label":"Main",className:"shrink-0 w-[224px] flex flex-col bg-sidebar",children:[u.jsx("div",{className:"shrink-0 px-2 pb-2",children:u.jsx(mtn,{onOpenAbout:()=>n(!0)})}),u.jsxs("div",{className:"flex-1 overflow-auto px-2 pt-2 pb-2 flex flex-col gap-0.5",children:[u.jsx(ytn,{}),p.map(w=>w.items.length===1?u.jsx(P3e,{sub:w.items[0],pathname:e,environment:o},w.title):u.jsx(gtn,{group:w,pathname:e,environment:o},w.title))]}),u.jsxs("div",{className:"shrink-0 flex items-center px-3 py-2",children:[u.jsx(LK,{side:"top",align:"start"}),u.jsx("div",{className:"flex-1"}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx($K,{tooltipSide:"top",buttonClassName:"size-7"}),u.jsxs(vn,{delayDuration:300,children:[u.jsx(xn,{asChild:!0,children:u.jsx("button",{type:"button",onClick:d,"aria-label":"Collapse sidebar",className:"size-7 flex items-center justify-center rounded-md text-muted-foreground/60 hover:text-foreground hover:bg-muted-foreground/5 transition-colors cursor-pointer",children:u.jsx(gIt,{className:"size-3.5"})})}),u.jsx(yn,{side:"top",sideOffset:6,className:"text-xs",children:"Collapse sidebar"})]})]})]}),u.jsx(zP,{open:t,onOpenChange:n})]})}function xtn(){return u.jsx("svg",{className:"absolute size-0","aria-hidden":!0,children:u.jsxs("filter",{id:"liquid-glass-distortion",x:"0%",y:"0%",width:"100%",height:"100%",filterUnits:"objectBoundingBox",children:[u.jsx("feTurbulence",{type:"fractalNoise",baseFrequency:"0.01 0.01",numOctaves:"1",seed:"5",result:"turbulence"}),u.jsx("feGaussianBlur",{in:"turbulence",stdDeviation:"3",result:"softMap"}),u.jsx("feDisplacementMap",{in:"SourceGraphic",in2:"softMap",scale:"80",xChannelSelector:"R",yChannelSelector:"G"})]})})}const Etn=({...e})=>{const{theme:t="system"}=Oy();return u.jsx(vBt,{theme:t,className:"toaster group",position:"bottom-right",toastOptions:{unstyled:!0,classNames:{toast:"group toast flex w-full items-start gap-3 rounded-sm border-transparent bg-blue-600 px-5 py-4 text-white shadow-lg data-[type=error]:bg-red-600 data-[type=warning]:bg-amber-600",title:"text-sm font-normal leading-snug",description:"text-sm leading-snug text-white/90",content:"flex-1 min-w-0",actionButton:"rounded-md bg-neutral-100 px-3 py-1.5 text-sm font-medium text-neutral-900 hover:bg-white transition-colors",cancelButton:"rounded-md bg-transparent px-3 py-1.5 text-sm font-medium text-white hover:bg-white/10 transition-colors",closeButton:"bg-transparent border-transparent text-white/70 hover:text-white"}},...e})};function wtn(){const e=hS("enable_agent_0"),t=xs(o=>o.targetEnvironment),n=Vt(o=>o.isOpen),r=Vt(o=>o.toggle),{track:s}=lf();b.useEffect(()=>{const o=a=>{!((r4?a.metaKey:a.ctrlKey)&&!a.shiftKey&&!a.altKey&&a.key==="]")||a.repeat||!e||t==="prod"||(a.preventDefault(),n||s("agent0.panel_opened",{source:"keyboard_shortcut"}),r())};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[e,n,t,r,s])}function Stn(){const e=xs(s=>s.targetEnvironment),t=xs(s=>s.setTargetEnvironmentAndSync),{data:n}=lc(),r=!n?.credentials?.prodBotId;b.useEffect(()=>{const s=o=>{if(o.shiftKey&&(r4?o.metaKey:o.ctrlKey)&&o.key.toLowerCase()==="e"){o.preventDefault();const a=e==="dev"?"prod":"dev";if(a==="prod"&&r)return;t(a)}};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[e,r,t])}function _tn({canSwitchToDev:e,onSwitchToDev:t}){return u.jsx("div",{className:"flex h-full min-h-[420px] items-center justify-center p-4",children:u.jsxs("div",{className:"max-w-md rounded-md border border-dashed bg-card p-8 text-center",children:[u.jsx("div",{className:"mx-auto mb-4 flex size-10 items-center justify-center rounded-sm bg-muted",children:u.jsx(CCt,{className:"size-5 text-muted-foreground"})}),u.jsx("p",{className:"h2",children:"Production target not deployed"}),u.jsx("p",{className:"small mt-2 text-muted-foreground",children:"Deploy this agent to publish the prod target. Until then, prod views do not have deployed metadata to load."}),e&&u.jsxs(Pt,{type:"button",variant:"outline",className:"mt-5",onClick:t,children:[u.jsx(lIt,{}),"Switch to Dev"]})]})})}class Ttn extends b.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t,n){try{j1.capture("error.ui",{page:this.props.page,error_type:t.name||"UnknownError",error_message:xW(t.message)||void 0,component:n.componentStack?.split(`
1138
+ `)}async function yen(e,t){const n=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await gen(e,t);if(n){const r=document.createElement("style"),s=document.createTextNode(n);r.appendChild(s),e.firstChild?e.insertBefore(r,e.firstChild):e.appendChild(r)}}async function ben(e,t={}){const{width:n,height:r}=d3e(e,t),s=await J5(e,t,!0);return await yen(s,t),await y3e(s,t),den(s,t),await M7t(s,n,r)}async function ven(e,t={}){const{width:n,height:r}=d3e(e,t),s=await ben(e,t),o=await UP(s),a=document.createElement("canvas"),i=a.getContext("2d"),c=t.pixelRatio||j7t(),l=t.canvasWidth||n,d=t.canvasHeight||r;return a.width=l*c,a.height=d*c,t.skipAutoScale||D7t(a),a.style.width=`${l}`,a.style.height=`${d}`,t.backgroundColor&&(i.fillStyle=t.backgroundColor,i.fillRect(0,0,a.width,a.height)),i.drawImage(o,0,0,a.width,a.height),a}async function xen(e,t={}){return(await ven(e,t)).toDataURL()}function v3e(){const{apiUrl:e,isReady:t}=wn(),n=bt(r=>r.selectedAgentPath);b.useEffect(()=>{if(!t)return;let r=null;const s=async c=>{try{const l=await xen(document.documentElement,{cacheBust:!0,pixelRatio:1});await fetch(e("/api/agent0/screenshot-result"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:c,dataUrl:l,mimeType:"image/png"})})}catch(l){await fetch(e("/api/agent0/screenshot-result"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:c,error:l instanceof Error?l.message:"Capture failed"})}).catch(()=>{})}},o=()=>{r||(r=new EventSource(e("/api/agent0/events")),r.addEventListener("take_screenshot",c=>{try{const{requestId:l}=JSON.parse(c.data);l&&s(l)}catch{}}),r.addEventListener("error",()=>{r?.close(),r=null}))},a=()=>{r?.close(),r=null},i=()=>{document.visibilityState==="visible"&&o()};return o(),document.addEventListener("visibilitychange",i),()=>{document.removeEventListener("visibilitychange",i),a()}},[e,t,n])}function obe(){const e=Vt(d=>d.isOpen),t=Vt(d=>d.settings),n=Vt(d=>d.updateSettings),{client:r,agentPath:s}=e5e(e),o=b.useRef(!1),a=b.useRef(null),i=b.useRef(t.panelWidth),c=Vt(d=>d.sessionId);JLe(r,c,e),v3e(),b.useEffect(()=>{const d=f=>{if(f.key==="Escape"&&e){const p=f.target;(p.tagName==="TEXTAREA"||p.tagName==="INPUT")&&p.blur()}};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[e]),b.useEffect(()=>()=>a.current?.(),[]),b.useEffect(()=>{i.current=t.panelWidth},[t.panelWidth]);const l=b.useCallback(d=>{d.preventDefault(),o.current=!0;const f=d.clientX,p=i.current,h=d.target.closest("[data-agent0-panel]"),g=h?.style.transition??"";h&&(h.style.transition="none");const y=x=>{if(!o.current)return;const w=Math.max(300,Math.min(700,p+(f-x.clientX)));i.current=w,h&&(h.style.width=`${w}px`)},E=()=>{o.current=!1,document.removeEventListener("mousemove",y),document.removeEventListener("mouseup",E),document.body.style.cursor="",document.body.style.userSelect="",a.current=null,h&&(h.style.transition=g),n({panelWidth:i.current})};a.current=E,document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",y),document.addEventListener("mouseup",E)},[n]);return u.jsxs("div",{"data-agent0-panel":!0,className:"relative h-full shrink-0 transition-[width] duration-enter ease-ease-out-quart",style:{width:e?t.panelWidth:0},children:[e&&u.jsx("div",{onMouseDown:l,className:"group/resize absolute left-0 top-0 bottom-0 w-4 -translate-x-full cursor-col-resize z-10 flex items-center justify-center",children:u.jsx("div",{className:"h-8 w-1 rounded-full bg-muted-foreground/15 transition-all duration-150 group-hover/resize:h-16 group-hover/resize:bg-muted-foreground/30"})}),u.jsx("div",{inert:!e||void 0,className:"relative h-full w-full pr-2 pb-2 pl-2",children:u.jsx("div",{className:"h-full rounded-xl bg-background flex flex-col overflow-hidden relative",children:u.jsx("div",{className:"flex-1 min-h-0 overflow-hidden relative",children:u.jsx(c3e,{client:r,agentPath:s,heroHeadline:"What are we working on?",heroSubhead:"agent0 can inspect your project, explain how things work, debug issues, and build with you.",composerPlaceholder:"Ask a question or / for commands"})})})})]})}const x3e="adk:prod-badge-position",o1=16;function Een(){if(typeof window>"u")return null;try{const e=localStorage.getItem(x3e);if(!e)return null;const t=JSON.parse(e);if((t.side==="left"||t.side==="right")&&typeof t.y=="number")return{side:t.side,y:t.y}}catch{}return null}function wen(e){try{localStorage.setItem(x3e,JSON.stringify(e))}catch{}}function Sen({active:e}){const[t,n]=b.useState(Een),[r,s]=b.useState(null),[o,a]=b.useState(null),[i,c]=b.useState(!1),l=b.useRef(null);b.useEffect(()=>{if(!r)return;const g=E=>{a({x:E.clientX-r.x,y:E.clientY-r.y})},y=E=>{const x=l.current?.getBoundingClientRect(),w=x?.width??28,S=x?.height??28,T=E.clientX-r.x,k=E.clientY-r.y,A=window.innerWidth/2,N=T+w/2<A?"left":"right",j=Math.max(o1,Math.min(window.innerHeight-S-o1,k)),O={side:N,y:j};n(O),wen(O),s(null),a(null)};return window.addEventListener("pointermove",g),window.addEventListener("pointerup",y),()=>{window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",y)}},[r]);const d=g=>{if(!e)return;const y=g.currentTarget.getBoundingClientRect();s({x:g.clientX-y.left,y:g.clientY-y.top}),a({x:y.left,y:y.top}),g.preventDefault()},f=!!r&&!!o,p=t?.side??"right";let h;return f&&o?h={left:o.x,top:o.y,right:"auto",bottom:"auto"}:t?h=t.side==="right"?{right:o1,top:t.y,left:"auto",bottom:"auto"}:{left:o1,top:t.y,right:"auto",bottom:"auto"}:h={right:o1,bottom:o1,left:"auto",top:"auto"},u.jsxs("div",{ref:l,role:"status","aria-label":"Production Mode","aria-hidden":!e,onPointerDown:d,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),style:h,className:me("fixed z-50 flex select-none items-center overflow-hidden rounded-md bg-purple-500 text-white shadow-lg ring-1 ring-purple-400/40","transition-all duration-300 ease-out motion-reduce:transition-none",f?"cursor-grabbing !transition-none":"cursor-grab",p==="right"?"flex-row-reverse":"flex-row",e?"opacity-100":"pointer-events-none translate-y-2 opacity-0"),children:[u.jsx("div",{className:"flex size-7 shrink-0 items-center justify-center",children:u.jsx("svg",{className:"size-4",viewBox:"55 50 140 160",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor","aria-hidden":!0,children:u.jsx("path",{d:"M192 93.6C192 96.4 190.4 98.8 188.4 100L178.4 105.6L168.4 111.2C166 112.8 163.2 112.8 160.8 111.2L150.8 105.6H150.4L161.2 90L142.4 100.8L112 118V138L142.4 155.2L151.2 150.4L161.2 144.8C163.2 143.2 166.4 143.2 168.8 144.8L178.8 150.4L188.8 156C191.2 157.2 192.8 160 192.4 162.4V185.2C192.4 188 190.8 190.4 188.8 191.6L178.8 197.2L168.8 202.8C166.4 204.4 163.6 204.4 161.2 202.8L151.2 197.2L141.2 191.6C138.8 190.4 137.2 187.6 137.6 185.2V164L90.8 137.6L100 150.8L88.4 157.2C86 158.8 83.2 158.8 80.8 157.2L70.8 151.6L60.8 146C58.4 144.8 57.2 142.4 57.2 139.6V116.8C57.2 114 58.8 111.6 60.8 110.4L70.8 104.8L80.8 99.2C83.2 97.6 86 97.6 88.4 99.2L98.4 104.8L107.2 109.6L137.6 92.4V71.2C137.6 68.4 139.2 66 141.2 64.8L151.2 59.2L161.2 53.6C163.6 52 166.4 52 168.8 53.6L178.8 59.2L188.8 64.8C191.2 66 192.8 68.8 192.4 71.2V94L192 93.6Z"})})}),u.jsx("div",{className:me("overflow-hidden transition-[max-width] duration-200 ease-out",i||f?"max-w-[8rem]":"max-w-0"),children:u.jsx("span",{className:me("block whitespace-nowrap text-xs font-medium",p==="right"?"pl-3 pr-1":"pl-1 pr-3"),children:"Production Mode"})})]})}function _en({status:e,className:t}){const n=e==="ready"?"text-green-400":e==="error"?"text-red-400":"text-orange-400";return u.jsx(Ly,{className:me("h-2 w-2 fill-current",n,t)})}function E3e({onOpenAbout:e,onClose:t,onCreateProject:n,onDeploy:r}){const s=bt(q=>q.selectedAgentPath),o=bt(q=>q.setSelectedAgentPath),a=bt(q=>q.agents),i=xs(q=>q.targetEnvironment),c=xs(q=>q.setTargetEnvironmentAndSync),{data:l}=lc(),{apiUrl:d}=wn(),f=l?.credentials?.prodBotId??null,p=Lc(),h=i==="dev"?"prod":"dev",g=h==="dev"||!!f,{terminateAgent:y,closingAgents:E}=DJ(),[x,w]=b.useState([]),[S]=b.useState(q7),T=a.find(q=>q.agentPath===s),k=T?.consoleMode==="cloud",A=q=>{const z=k?T?.agentPath:null;o(q),z&&fetch(d("/api/cloud-console/clear"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentPath:z})}).catch(()=>{})},{pickAndOpenProject:N,openProjectPath:j,isOpening:O,openingName:D,openError:L,clearError:U}=nI({onSuccess:q=>{A(q.agentPath),t?.()}});b.useEffect(()=>{fetch(d("/api/projects/recent"),{signal:AbortSignal.timeout(2e3)}).then(q=>q.ok?q.json():null).then(q=>w(q?.projects??[])).catch(()=>{})},[d]);const B=async q=>{await y(q,{waitForRemoval:!0})},M=async(q,z)=>{try{const G=await fetch(d("/api/cloud-console/select-prod-bot"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaceId:q.id,botId:z.id,botName:z.name}),signal:AbortSignal.timeout(5e3)});if(!G.ok)return;const R=await G.json();q.name&&GLe({botId:z.id,botName:z.name,workspaceId:q.id,workspaceName:q.name});const W=await fetch(d("/api/agents"),{signal:AbortSignal.timeout(2e3)});if(W.ok){const V=await W.json();bt.getState().setAgents(V.agents??[])}o(R.agentPath),t?.()}catch{}},$="flex w-full items-center justify-start gap-2 px-2.5 py-1.5 rounded-sm cursor-pointer text-[11px] text-muted-foreground hover:text-foreground focus:bg-muted-foreground/10";if(k){const q=S.slice(0,3);return u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"h-64",children:u.jsx(J$e,{onSelect:(z,G)=>void M(z,G)})}),q.length>0&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"px-1 pt-1 pb-0.5 select-none",children:u.jsx("span",{className:"text-[10px] font-medium text-muted-foreground/50",children:"Recent"})}),q.map(z=>u.jsxs(wr,{onSelect:G=>{G.preventDefault(),M({id:z.workspaceId,name:z.workspaceName},{id:z.botId,name:z.botName})},className:"flex items-center gap-2.5 px-2.5 py-1.5 rounded-sm cursor-pointer text-muted-foreground hover:text-foreground focus:bg-muted-foreground/10",children:[u.jsx(ew,{name:z.botName,className:"size-4"}),u.jsx("span",{className:"text-xs truncate",children:z.botName}),u.jsx("span",{className:"text-[10px] truncate text-muted-foreground/50",children:z.workspaceName})]},z.botId))]}),e&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"my-px h-px bg-muted-foreground/10"}),u.jsx("div",{className:"px-1 pb-0.5 select-none",children:u.jsx("span",{className:"text-[10px] font-medium text-muted-foreground/50",children:"Actions"})}),u.jsxs("div",{className:"flex flex-col gap-0.5",children:[u.jsxs(wr,{onSelect:e,className:$,children:[u.jsx(SW,{className:"size-3.5"}),"About this agent"]}),u.jsxs(wr,{onSelect:()=>p("/"),className:$,children:[u.jsx(wW,{className:"size-3.5"}),"Back to home"]})]})]})]})}const P=a.filter(q=>q.consoleMode!=="cloud");return u.jsxs(u.Fragment,{children:[P.length>0&&u.jsx("div",{className:"px-1 pb-0.5 select-none",children:u.jsx("span",{className:"text-[10px] font-medium text-muted-foreground/50",children:"Active"})}),P.map(q=>{const z=q.agentPath===s,G=!!E[q.agentPath];return u.jsxs("div",{className:me("group flex items-center gap-1 rounded-sm","hover:bg-muted-foreground/10",z&&"bg-muted-foreground/10"),children:[u.jsxs(wr,{disabled:G,onSelect:()=>!G&&A(q.agentPath),className:"flex min-w-0 flex-1 items-center gap-2.5 px-2.5 py-2 rounded-sm cursor-pointer text-foreground focus:bg-transparent",children:[u.jsx(_en,{status:q.status,className:"shrink-0"}),u.jsx("span",{className:"max-w-32 shrink-0 truncate text-xs font-medium text-foreground",children:q.name}),u.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[10px] text-muted-foreground/50",style:{direction:"rtl",textAlign:"left"},title:q.agentPath,children:"‎"+q.agentPath})]}),u.jsx("button",{type:"button",title:"Stop project",disabled:G,onClick:R=>{R.stopPropagation(),B(q.agentPath)},className:me("mr-1 inline-flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-sm text-destructive/75 transition-all hover:bg-destructive/10 hover:text-destructive disabled:cursor-not-allowed disabled:opacity-60",G?"opacity-100":"opacity-0 group-hover:opacity-100"),children:G?u.jsx(nn,{className:"size-3 animate-spin"}):u.jsx(i5,{className:"size-3",strokeWidth:1.75})})]},q.agentPath)}),D&&!a.some(q=>q.name===D)&&u.jsxs("div",{className:"flex items-center gap-2.5 px-2.5 py-2 text-muted-foreground",children:[u.jsx(nn,{className:"size-2 animate-spin shrink-0 ml-[1px]"}),u.jsxs("span",{className:"text-xs",children:["Opening ",D,"…"]})]}),u.jsx(z7,{error:L,onDismiss:U}),(()=>{const q=new Set(P.map(G=>G.agentPath)),z=x.filter(G=>!q.has(G.path)).slice(0,5);return z.length===0?null:u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"my-px h-px bg-muted-foreground/10"}),u.jsx("div",{className:"px-1 pb-0.5 select-none",children:u.jsx("span",{className:"text-[10px] font-medium text-muted-foreground/50",children:"Recent"})}),z.map(G=>u.jsxs(wr,{disabled:O,onSelect:R=>{R.preventDefault(),j(G.path,{path:G.path,name:G.name,lastOpenedAt:""})},className:"flex items-center gap-2.5 px-2.5 py-1.5 rounded-sm cursor-pointer text-muted-foreground hover:text-foreground focus:bg-muted-foreground/10",children:[u.jsx(nc,{className:"size-3 shrink-0",strokeWidth:1.75}),u.jsx("span",{className:"text-xs truncate",children:G.name})]},G.path))]})})(),u.jsx("div",{className:"my-px h-px bg-muted-foreground/10"}),u.jsx("div",{className:"px-1 pb-0.5 select-none",children:u.jsx("span",{className:"text-[10px] font-medium text-muted-foreground/50",children:"Actions"})}),u.jsxs("div",{className:"flex flex-col gap-0.5",children:[u.jsxs(wr,{onSelect:q=>{q.preventDefault(),t?.(),n?.()},className:$,children:[u.jsx(ld,{className:"size-3.5"}),"Create project"]}),u.jsxs(wr,{disabled:O,onSelect:q=>{q.preventDefault(),N()},className:$,children:[O?u.jsx(nn,{className:"size-3.5 animate-spin"}):u.jsx(nc,{className:"size-3.5"}),"Open project"]}),e&&u.jsxs(u.Fragment,{children:[u.jsxs(wr,{disabled:!g,onSelect:()=>void c(h),className:$,children:[u.jsx(nP,{className:"size-3.5"}),"Switch to ",h]}),u.jsxs(wr,{disabled:!T||i==="prod",onSelect:()=>r?.(),className:$,children:[u.jsx(RDe,{className:"size-3.5"}),"Deploy"]}),u.jsxs(wr,{onSelect:e,className:$,children:[u.jsx(SW,{className:"size-3.5"}),"About this agent"]}),u.jsxs(wr,{onSelect:()=>p("/"),className:$,children:[u.jsx(wW,{className:"size-3.5"}),"Back to home"]})]})]})]})}const Ten="https://api.botpress.cloud",Aen="app.botpress.dev",ken="app.botpress.cloud",Cen="https://webhook.botpress.dev",Nen="https://webhook.botpress.cloud";function e4(){const{credentials:e}=$o(),t=e?.apiUrl;return b.useMemo(()=>{const n=!!t?.includes(".dev"),r=n?Aen:ken;return{apiUrl:t||Ten,isStaging:n,appHost:r,webhookUrl:n?Cen:Nen,botUrl:(i,c)=>c?`https://${r}/workspaces/${c}/bots/${i}`:null}},[t])}function t4({active:e,className:t,...n}){return u.jsx("span",{className:me("built-agent-logo relative block shrink-0 overflow-hidden rounded-full",t),"data-changing":e?"true":void 0,"aria-hidden":"true",...n})}function Ien(e){return typeof e=="object"&&e!==null}function Ren(e){return e?e.flatMap(t=>{if(!Ien(t)||typeof t.name!="string")return[];const n=Array.isArray(t.events)?t.events.filter(r=>typeof r=="string"):[];return[{source:"trigger",key:t.name,name:t.name,label:t.name,description:typeof t.description=="string"?t.description:void 0,events:n,eventCount:n.length}]}):[]}function jen(e){if(!e)return[];const t=[];for(const n of e){if(!n.enabled)continue;const r=n.definition?.title||n.name||n.alias,s=n.definition?.events||{};for(const[o,a]of Object.entries(s)){const i=`${n.alias}:${o}`;t.push({source:"integration-event",key:i,name:i,label:a.title||o,description:a.description,events:[i],eventCount:1,integrationAlias:n.alias,integrationName:r,integrationIconUrl:n.definition?.iconUrl,eventName:o,eventTitle:a.title,eventSchema:a.schema})}}return t}function kee(e,t){return[...Ren(e),...jen(t)]}function Den(e,t){return kee(e,t).length}const Oen=[{key:"actions",to:"/actions",label:"Actions",icon:Wg},{key:"workflows",to:"/workflows",label:"Workflows",icon:Mh},{key:"conversations",to:"/conversations",label:"Conversations",icon:r5},{key:"triggers",to:"/triggers",label:"Triggers",icon:Sa},{key:"tables",to:"/tables",label:"Tables",icon:ml},{key:"knowledge",to:"/knowledge",label:"Knowledge",icon:nc}];function zP({open:e,onOpenChange:t}){const{agent:n,bot:r}=ds(),{data:s}=xRt(),{data:o}=lc(),{data:a}=u5(r?.id),{data:i}=vRt(),c=bt(O=>O.selectedAgentPath),l=bt(O=>O.agents),[d,f]=b.useState(null);jv(),cm();const p=a||[],h=Den(n?.triggers,a),g=o?.credentials?.devBotId,y=o?.credentials?.workspaceId,{botUrl:E}=e4(),x=O=>E(O,y),w=o?.credentials?.prodBotId,T=l.find(O=>O.agentPath===c)?.consoleMode==="cloud"||c?.startsWith("prod:"),k=n?.name||r?.name||"Agent",A={actions:n?.actions?.length||0,workflows:n?.workflows?.length||0,conversations:n?.conversations?.length||0,triggers:h,tables:n?.tables?.length||0,knowledge:n?.knowledge?.length||0},N=[{label:"Bot ID",value:g},{label:"Workspace",value:y},{label:"Path",value:n?.path}].filter(O=>O.value),j=(O,D)=>{navigator.clipboard.writeText(O),f(D),setTimeout(()=>f(null),1500)};return u.jsx(fi,{open:e,onOpenChange:t,children:u.jsxs(Ci,{className:"sm:max-w-[680px] p-0 gap-0 rounded-md border-0 overflow-hidden [&>button:last-child]:hidden shadow-2xl",children:[u.jsx("div",{className:"absolute top-[45%] left-[90px] -translate-x-1/2 -translate-y-1/2 size-56 rounded-full blur-[100px] opacity-15 pointer-events-none",style:{background:"radial-gradient(circle at 32% 28%, hsl(220 100% 78%) 0%, hsl(265 85% 60%) 38%, hsl(320 80% 50%) 80%)"}}),u.jsxs("div",{className:"relative flex max-h-[80vh]",children:[u.jsx("div",{className:"relative w-[200px] shrink-0 flex flex-col items-center justify-center py-10",children:u.jsxs("div",{className:"relative flex flex-col items-center text-center",children:[u.jsx(t4,{className:"mb-5 size-10"}),u.jsx("p",{className:"text-[14px] font-semibold tracking-tight text-foreground",children:k}),u.jsx(Ni,{className:"sr-only",children:k}),u.jsxs("div",{className:"flex items-center gap-1.5 mt-3",children:[g&&x(g)&&u.jsxs("a",{href:x(g),target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-md border border-muted-foreground/10 px-2 py-0.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors",children:[u.jsx("img",{src:"/bp_logo_dev.svg",alt:"",className:"size-3 rounded-sm"}),"Dev"]}),w&&x(w)&&u.jsxs("a",{href:x(w),target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-md border border-muted-foreground/10 px-2 py-0.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors",children:[u.jsx("img",{src:"/bp_logo_prod.svg",alt:"",className:"size-3 rounded-sm dark:invert"}),"Prod"]})]})]})}),u.jsxs("div",{className:"relative flex-1 flex flex-col bg-background-deep",children:[u.jsxs("div",{className:"flex-1 overflow-y-auto py-10",children:[u.jsx("h2",{className:"px-5 text-xs font-medium mb-6",children:"Agent Details"}),u.jsx("div",{className:"px-5 space-y-2",children:N.map(O=>u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"text-[10px] font-medium w-[60px] shrink-0 text-muted-foreground/40",children:O.label}),u.jsx("span",{className:"text-[10px] font-mono text-muted-foreground/60 truncate",children:O.value}),u.jsx("button",{onClick:()=>j(O.value,O.label),className:"text-muted-foreground/30 hover:text-muted-foreground shrink-0 transition-colors cursor-pointer ml-auto",children:d===O.label?u.jsx(Xr,{className:"size-2.5"}):u.jsx(li,{className:"size-2.5"})})]},O.label))}),u.jsx("div",{className:"mx-5 my-5 h-px bg-muted-foreground/10"}),u.jsx("div",{className:"px-4",children:u.jsx("div",{className:"grid grid-cols-2 gap-x-2 gap-y-1.5",children:[...Oen.map(O=>({label:O.label,count:A[O.key],to:O.to,icon:O.icon})),{label:"Integrations",count:p.length,to:"/integrations",icon:_C}].map(O=>u.jsxs(Fc,{to:O.to,onClick:()=>t(!1),className:"icon-hover flex items-center gap-1.5 py-1 px-1.5 rounded-sm text-xs text-muted-foreground hover:text-foreground hover:bg-muted-foreground/5 transition-colors",children:[u.jsx(O.icon,{className:"size-3 shrink-0 text-muted-foreground/40"}),u.jsx("span",{className:"flex-1 truncate",children:O.label}),u.jsx("span",{className:"text-[10px] font-mono text-muted-foreground/25",children:O.count})]},O.label))})}),!T&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"mx-5 my-5 h-px bg-muted-foreground/10"}),u.jsxs("div",{className:"px-5 flex items-center gap-6",children:[u.jsxs("div",{className:"flex items-baseline gap-1.5",children:[u.jsx("span",{className:"text-[10px] text-muted-foreground/40",children:"Workers"}),u.jsx("span",{className:me("text-xs font-semibold font-mono",i?.busy>0&&"text-blue-400"),children:i?.busy??"--"}),u.jsxs("span",{className:"text-[10px] text-muted-foreground/25 font-mono",children:["/ ",i?.total??"--"]})]}),u.jsxs("div",{className:"flex items-baseline gap-1.5",children:[u.jsx("span",{className:"text-[10px] text-muted-foreground/40",children:"Queue"}),u.jsx("span",{className:me("text-xs font-semibold font-mono",i?.queueSize>0&&"text-orange-400"),children:i?.queueSize??"--"})]})]})]})]}),u.jsxs("div",{className:"shrink-0 flex items-center justify-center gap-1.5 py-2 border-t border-muted-foreground/5",children:[u.jsx("span",{className:"text-[10px] text-muted-foreground/25",children:"Powered by"}),u.jsx("div",{className:"size-3 rounded-sm bg-sidebar-primary flex items-center justify-center p-px",children:u.jsx("img",{src:"/ADK.svg",alt:"ADK",className:"size-full invert"})}),s?.adkVersion&&s.adkVersion!=="unknown"&&u.jsxs("span",{className:"text-[10px] font-mono text-muted-foreground/20",children:["v",s.adkVersion]})]})]})]})]})})}const Men=o7("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors duration-standard focus:outline-hidden focus:ring-1 focus:ring-ring",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Sr({className:e,variant:t,...n}){return u.jsx("div",{className:me(Men({variant:t}),e),...n})}function PI(e){const t=b.useRef({value:e,previous:e});return b.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var n4="Checkbox",[Pen]=di(n4),[$en,Cee]=Pen(n4);function Len(e){const{__scopeCheckbox:t,checked:n,children:r,defaultChecked:s,disabled:o,form:a,name:i,onCheckedChange:c,required:l,value:d="on",internal_do_not_use_render:f}=e,[p,h]=rc({prop:n,defaultProp:s??!1,onChange:c,caller:n4}),[g,y]=b.useState(null),[E,x]=b.useState(null),w=b.useRef(!1),S=g?!!a||!!g.closest("form"):!0,T={checked:p,disabled:o,setChecked:h,control:g,setControl:y,name:i,form:a,value:d,hasConsumerStoppedPropagationRef:w,required:l,defaultChecked:Yg(s)?!1:s,isFormControl:S,bubbleInput:E,setBubbleInput:x};return u.jsx($en,{scope:t,...T,children:Fen(f)?f(T):r})}var w3e="CheckboxTrigger",S3e=b.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},s)=>{const{control:o,value:a,disabled:i,checked:c,required:l,setControl:d,setChecked:f,hasConsumerStoppedPropagationRef:p,isFormControl:h,bubbleInput:g}=Cee(w3e,e),y=Cn(s,d),E=b.useRef(c);return b.useEffect(()=>{const x=o?.form;if(x){const w=()=>f(E.current);return x.addEventListener("reset",w),()=>x.removeEventListener("reset",w)}},[o,f]),u.jsx(dn.button,{type:"button",role:"checkbox","aria-checked":Yg(c)?"mixed":c,"aria-required":l,"data-state":C3e(c),"data-disabled":i?"":void 0,disabled:i,value:a,...r,ref:y,onKeyDown:Rt(t,x=>{x.key==="Enter"&&x.preventDefault()}),onClick:Rt(n,x=>{f(w=>Yg(w)?!0:!w),g&&h&&(p.current=x.isPropagationStopped(),p.current||x.stopPropagation())})})});S3e.displayName=w3e;var Nee=b.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:s,defaultChecked:o,required:a,disabled:i,value:c,onCheckedChange:l,form:d,...f}=e;return u.jsx(Len,{__scopeCheckbox:n,checked:s,defaultChecked:o,disabled:i,required:a,onCheckedChange:l,name:r,form:d,value:c,internal_do_not_use_render:({isFormControl:p})=>u.jsxs(u.Fragment,{children:[u.jsx(S3e,{...f,ref:t,__scopeCheckbox:n}),p&&u.jsx(k3e,{__scopeCheckbox:n})]})})});Nee.displayName=n4;var _3e="CheckboxIndicator",T3e=b.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...s}=e,o=Cee(_3e,n);return u.jsx(Ha,{present:r||Yg(o.checked)||o.checked===!0,children:u.jsx(dn.span,{"data-state":C3e(o.checked),"data-disabled":o.disabled?"":void 0,...s,ref:t,style:{pointerEvents:"none",...e.style}})})});T3e.displayName=_3e;var A3e="CheckboxBubbleInput",k3e=b.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:r,hasConsumerStoppedPropagationRef:s,checked:o,defaultChecked:a,required:i,disabled:c,name:l,value:d,form:f,bubbleInput:p,setBubbleInput:h}=Cee(A3e,e),g=Cn(n,h),y=PI(o),E=uI(r);b.useEffect(()=>{const w=p;if(!w)return;const S=window.HTMLInputElement.prototype,k=Object.getOwnPropertyDescriptor(S,"checked").set,A=!s.current;if(y!==o&&k){const N=new Event("click",{bubbles:A});w.indeterminate=Yg(o),k.call(w,Yg(o)?!1:o),w.dispatchEvent(N)}},[p,y,o,s]);const x=b.useRef(Yg(o)?!1:o);return u.jsx(dn.input,{type:"checkbox","aria-hidden":!0,defaultChecked:a??x.current,required:i,disabled:c,name:l,value:d,form:f,...t,tabIndex:-1,ref:g,style:{...t.style,...E,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});k3e.displayName=A3e;function Fen(e){return typeof e=="function"}function Yg(e){return e==="indeterminate"}function C3e(e){return Yg(e)?"indeterminate":e?"checked":"unchecked"}const ow=b.forwardRef(({className:e,...t},n)=>u.jsx(Nee,{ref:n,className:me("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow-sm focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:u.jsx(T3e,{className:me("flex items-center justify-center text-current"),children:u.jsx(Xr,{className:"h-4 w-4"})})}));ow.displayName=Nee.displayName;var Ben="Label",N3e=b.forwardRef((e,t)=>u.jsx(dn.label,{...e,ref:t,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(e.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));N3e.displayName=Ben;var I3e=N3e;const qen=o7("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),tv=b.forwardRef(({className:e,...t},n)=>u.jsx(I3e,{ref:n,className:me(qen(),e),...t}));tv.displayName=I3e.displayName;const Uen=[{id:"secrets",label:"Saving secrets"},{id:"preflight",label:"Applying config changes"},{id:"deploy",label:"Deploying to Botpress"},{id:"manifest",label:"Publishing metadata"},{id:"kb-sync",label:"Syncing knowledge bases",formatDetail:e=>{const t=[];return e.synced&&t.push(`${e.synced} synced`),e.skipped&&t.push(`${e.skipped} skipped`),e.failed&&t.push(`${e.failed} failed`),t.join(", ")}},{id:"tables",label:"Syncing tables",formatDetail:e=>{const t=[];return e.created&&t.push(`${e.created} created`),e.updated&&t.push(`${e.updated} updated`),e.deleted&&t.push(`${e.deleted} deleted`),t.join(", ")}},{id:"assets",label:"Syncing assets",formatDetail:e=>{const t=[];return e.created&&t.push(`${e.created} uploaded`),e.updated&&t.push(`${e.updated} updated`),e.deleted&&t.push(`${e.deleted} deleted`),t.join(", ")}}];function zen(e,t){return Uen.filter(n=>{switch(n.id){case"secrets":return t;case"preflight":return e.preflight.hasChanges;case"deploy":return!0;case"manifest":return!0;case"kb-sync":return e.knowledgeBases?.hasChanges||e.knowledgeBases?.orphanedKBs&&e.knowledgeBases.orphanedKBs.length>0;case"tables":return e.tables?.hasChanges;case"assets":return e.assets?.hasChanges;default:return!1}})}function R3e({open:e,onOpenChange:t}){const{apiUrl:n}=wn(),[r,s]=b.useState("planning"),[o,a]=b.useState(null),[i,c]=b.useState(null),[l,d]=b.useState({}),[f,p]=b.useState(!1),[h,g]=b.useState({}),[y,E]=b.useState(null),[x,w]=b.useState(null),S=b.useRef(null),T=b.useRef(null),k=b.useCallback(()=>{s("planning"),a(null),c(null),d({}),p(!1),g({}),E(null),w(null)},[]),A=b.useCallback(()=>{T.current&&(clearInterval(T.current),T.current=null)},[]),N=b.useCallback(()=>{A(),T.current=setInterval(async()=>{try{const q=await fetch(n("/api/deploy/status"));if(!q.ok)return;const z=await q.json();g(z.stages),z.done&&z.result&&(A(),w({success:z.result.success,botId:z.result.botId??""}),!z.result.success&&z.result.error&&E(z.result.error),s("complete"))}catch{}},500)},[n,A]);b.useEffect(()=>{if(!e)return;k();const q=new AbortController;return S.current=q,(async()=>{await fetch(n("/api/deploy/cancel"),{method:"POST",signal:q.signal}).catch(()=>{});try{const G=await fetch(n("/api/deploy/plan"),{method:"POST",signal:q.signal}),R=await G.json();if(!G.ok)throw new Error(R.message||R.error||"Failed to compute deploy plan");if(R.cancelled)return;a(R),s("review")}catch(G){if(q.signal.aborted)return;c(G instanceof Error?G.message:String(G)),s("error")}})(),()=>{S.current?.abort(),A(),fetch(n("/api/deploy/cancel"),{method:"POST"}).catch(()=>{})}},[e,n,k,A]);const j=b.useCallback(()=>{A(),fetch(n("/api/deploy/cancel"),{method:"POST"}).catch(()=>{}),t(!1)},[n,t,A]),O=Object.values(l).some(q=>q.trim().length>0),D=!(!o||!o.configValid||o.secrets.missingRequired.filter(z=>!l[z]?.trim()).length>0||o.hasDestructiveStorageChanges&&!f);b.useEffect(()=>()=>{T.current&&clearInterval(T.current)},[]);const L=b.useCallback(async()=>{if(!o)return;s("deploying"),E(null);const q={};for(const[z,G]of Object.entries(l))G.trim()&&(q[z]=G.trim());try{const z=await fetch(n("/api/deploy/execute"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({confirmStorageChanges:f,secrets:Object.keys(q).length>0?q:void 0})});if(!z.ok){const G=await z.json().catch(()=>null);throw new Error(G?.message||"Failed to start deploy")}N()}catch(z){s("error"),E(z instanceof Error?z.message:String(z))}},[o,n,l,f,N]),U={planning:0,review:1,deploying:2,complete:3,error:3},B=U[r],M=q=>me("transition-all duration-300 ease-in-out",r===q?"relative translate-x-0 opacity-100":"absolute inset-x-0 top-0 pointer-events-none",r!==q&&U[q]<B&&"-translate-x-12 opacity-0",r!==q&&U[q]>B&&"translate-x-12 opacity-0",r!==q&&U[q]===B&&"opacity-0"),$=b.useCallback(()=>{S.current?.abort(),k();const q=new AbortController;S.current=q,(async()=>{await fetch(n("/api/deploy/cancel"),{method:"POST",signal:q.signal}).catch(()=>{});try{const z=await fetch(n("/api/deploy/plan"),{method:"POST",signal:q.signal}),G=await z.json();if(!z.ok)throw new Error(G.message||"Failed to compute deploy plan");if(G.cancelled)return;a(G),s("review")}catch(z){if(q.signal.aborted)return;c(z instanceof Error?z.message:String(z)),s("error")}})()},[n,k]),P=b.useCallback(()=>{fetch(n("/api/deploy/cancel"),{method:"POST"}),t(!1)},[n,t]);return u.jsx(fi,{open:e,onOpenChange:j,children:u.jsx(Ci,{className:"sm:max-w-lg overflow-hidden h-[420px]",children:u.jsxs("div",{className:"flex flex-col gap-4 h-full",children:[u.jsxs(uf,{children:[u.jsx(Ni,{className:"text-sm",children:"Deploy to Production"}),u.jsx(Yen,{phase:r})]}),u.jsxs("div",{className:"relative flex-1 min-h-0",children:[u.jsx("div",{"aria-hidden":r!=="planning",className:me(M("planning"),"h-full"),children:u.jsx(Hen,{})}),u.jsx("div",{"aria-hidden":r!=="review",className:me(M("review"),"h-full"),children:o&&u.jsx(Ven,{plan:o,secretValues:l,onSecretChange:(q,z)=>d(G=>({...G,[q]:z})),confirmDestructive:f,onConfirmDestructiveChange:p,canDeploy:D,onDeploy:()=>void L(),onCancel:j})}),u.jsx("div",{"aria-hidden":r!=="deploying"&&r!=="complete",className:me(M(r==="complete"?"complete":"deploying"),"h-full"),children:o&&u.jsx(Gen,{plan:o,stages:h,hasNewSecrets:O,isDone:r==="complete"||r==="error",result:x,error:y,onClose:()=>t(!1),onSwitchToProd:()=>{xs.getState().setTargetEnvironment("prod"),t(!1)}})}),u.jsx("div",{"aria-hidden":r!=="error",className:me(M("error"),"h-full"),children:u.jsx(Zen,{error:i||y||"Unknown error",onRetry:$,onClose:P})})]})]})})})}function Hen(){return u.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-sm text-muted-foreground",children:[u.jsx(nn,{className:"size-4 animate-spin"}),"Building project and computing changes..."]})}function Ven({plan:e,secretValues:t,onSecretChange:n,confirmDestructive:r,onConfirmDestructiveChange:s,canDeploy:o,onDeploy:a,onCancel:i}){return u.jsxs("div",{className:"flex h-full flex-col gap-3",children:[e.hasAnyChanges&&u.jsxs("p",{className:"text-xs text-muted-foreground shrink-0",children:["Review changes before deploying ",u.jsx("span",{className:"font-medium text-foreground",children:e.botName})]}),u.jsxs("div",{className:"flex-1 min-h-0 space-y-3 overflow-auto",children:[!e.configValid&&e.configErrors.length>0&&u.jsxs("div",{className:"rounded-md border border-red-500/20 bg-red-500/5 p-3 space-y-1",children:[u.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-red-400",children:[u.jsx(yl,{className:"size-3.5 shrink-0"}),"Configuration errors"]}),e.configErrors.map((c,l)=>u.jsx("p",{className:"text-xs text-red-400/80 pl-5.5",children:c},l))]}),!e.hasAnyChanges&&e.configValid&&e.secrets.missingRequired.length===0&&u.jsxs("div",{className:"flex items-center gap-2 py-2 text-xs text-muted-foreground",children:[u.jsx(Ms,{className:"size-3.5 text-green-500"}),"No resource changes detected. Code will be redeployed."]}),e.preflight.hasChanges&&e.preflight.agentConfig.length>0&&u.jsx(Oj,{title:"Agent Config",children:e.preflight.agentConfig.map(c=>u.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[u.jsxs("span",{className:"text-muted-foreground",children:[c.field,":"]}),u.jsx("span",{className:"text-red-400 line-through",children:String(c.oldValue)}),u.jsx(Rv,{className:"size-3 text-muted-foreground/50"}),u.jsx("span",{className:"text-green-400",children:String(c.newValue)})]},c.field))}),e.tables?.hasChanges&&u.jsx(Oj,{title:"Tables",children:u.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.tables.totalCreate>0&&u.jsxs(Sr,{variant:"outline",className:"h-5 text-[10px] text-green-500",children:["+",e.tables.totalCreate," create"]}),e.tables.totalUpdate>0&&u.jsxs(Sr,{variant:"outline",className:"h-5 text-[10px] text-blue-500",children:["~",e.tables.totalUpdate," update"]}),e.tables.totalDelete>0&&u.jsxs(Sr,{variant:"outline",className:"h-5 text-[10px] text-red-500",children:["-",e.tables.totalDelete," delete"]})]})}),e.knowledgeBases?.hasChanges&&u.jsxs(Oj,{title:"Knowledge Bases",children:[u.jsxs("div",{className:"space-y-1 text-xs",children:[u.jsxs("span",{className:"text-muted-foreground",children:[e.knowledgeBases.toSync," to sync, ",e.knowledgeBases.toSkip," up to date"]}),e.knowledgeBases.orphanedSourcesToDelete>0&&u.jsxs("p",{className:"text-red-400",children:[e.knowledgeBases.orphanedSourcesToDelete," orphaned sources to remove"]})]}),e.knowledgeBases.orphanedKBs.length>0&&u.jsx("div",{className:"mt-1 space-y-0.5",children:e.knowledgeBases.orphanedKBs.map(c=>u.jsxs("p",{className:"text-[10px] text-red-400",children:["Orphaned: ",c.name]},c.name))})]}),e.assets?.hasChanges&&u.jsx(Oj,{title:"Assets",children:u.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.assets.totalCreate>0&&u.jsxs(Sr,{variant:"outline",className:"h-5 text-[10px] text-green-500",children:["+",e.assets.totalCreate," upload"]}),e.assets.totalUpdate>0&&u.jsxs(Sr,{variant:"outline",className:"h-5 text-[10px] text-blue-500",children:["~",e.assets.totalUpdate," update"]}),e.assets.totalDelete>0&&u.jsxs(Sr,{variant:"outline",className:"h-5 text-[10px] text-red-500",children:["-",e.assets.totalDelete," delete"]})]})}),e.hasDestructiveStorageChanges&&u.jsxs("div",{className:"rounded-md border border-amber-500/20 bg-amber-500/5 p-3",children:[u.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-amber-400",children:[u.jsx(As,{className:"size-3.5 shrink-0"}),"Destructive changes"]}),u.jsx("p",{className:"mt-1 text-xs text-amber-400/80 pl-5.5",children:"This deploy will delete tables, knowledge bases, or assets."}),u.jsxs("div",{className:"mt-2 flex items-center gap-2 pl-5.5",children:[u.jsx(ow,{id:"confirm-destructive",checked:r,onCheckedChange:c=>s(c===!0)}),u.jsx(tv,{htmlFor:"confirm-destructive",className:"text-xs text-amber-400 cursor-pointer",children:"I confirm the destructive changes"})]})]}),e.secrets.missing.length>0&&u.jsxs("div",{className:"rounded-md border border-muted-foreground/10 p-3 space-y-2.5",children:[u.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium",children:[u.jsx(eI,{className:"size-3.5 text-muted-foreground/50 shrink-0"}),"Production Secrets"]}),e.secrets.missing.map(c=>u.jsxs("div",{className:"space-y-1 pl-5.5",children:[u.jsxs(tv,{htmlFor:`secret-${c.name}`,className:"text-xs",children:[c.name,c.optional&&u.jsx("span",{className:"text-muted-foreground/50 ml-1",children:"(optional)"}),!c.optional&&u.jsx("span",{className:"text-red-400 ml-0.5",children:"*"})]}),c.description&&u.jsx("p",{className:"text-[10px] text-muted-foreground/60",children:c.description}),u.jsx("input",{id:`secret-${c.name}`,type:"password",value:t[c.name]??"",onChange:l=>n(c.name,l.target.value),placeholder:`Enter ${c.name}`,className:"w-full rounded-md border border-muted-foreground/15 bg-background px-2.5 py-1.5 text-xs text-foreground placeholder:text-muted-foreground/40 focus:border-muted-foreground/30 focus:outline-none"})]},c.name)),u.jsx("p",{className:"text-[10px] text-muted-foreground/50 pl-5.5",children:"Secrets will be saved for future deploys."})]})]}),u.jsxs(df,{className:"mt-auto gap-2 sm:gap-0 shrink-0",children:[u.jsx(Pt,{variant:"ghost",size:"sm",onClick:i,className:"text-xs",children:"Cancel"}),u.jsxs(Pt,{size:"sm",onClick:a,disabled:!o,className:"text-xs",children:[u.jsx(RDe,{className:"size-3 mr-1.5"}),"Deploy"]})]})]})}function Gen({plan:e,stages:t,hasNewSecrets:n,isDone:r,result:s,error:o,onClose:a,onSwitchToProd:i}){const c=zen(e,n);return u.jsxs("div",{className:"flex h-full flex-col gap-4",children:[u.jsx("div",{className:"space-y-1",children:c.map((l,d)=>{const f=t[l.id];return u.jsx(or.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.25,delay:d*.04},children:u.jsx(Wen,{step:l,state:f})},l.id)})}),u.jsxs(Qi,{children:[r&&s?.success&&u.jsxs(or.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.3,delay:.1},className:"flex items-center gap-2 rounded-md border border-green-500/20 bg-green-500/5 py-3 px-3",children:[u.jsx(Ms,{className:"size-4 text-green-500 shrink-0"}),u.jsx("p",{className:"text-xs font-medium text-green-400",children:"Agent deployed successfully"})]}),r&&o&&u.jsxs(or.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{duration:.3,delay:.1},className:"flex items-start gap-2 rounded-md border border-red-500/20 bg-red-500/5 py-3 px-3",children:[u.jsx(yl,{className:"size-4 text-red-500 shrink-0 mt-0.5"}),u.jsx("p",{className:"text-xs text-red-400 break-words",children:o})]})]}),r&&u.jsxs(df,{className:"mt-auto gap-2 sm:gap-0",children:[u.jsx(Pt,{variant:"ghost",size:"sm",onClick:a,className:"text-xs",children:"Close"}),s?.success&&u.jsx(Pt,{size:"sm",onClick:i,className:"text-xs",children:"Switch to prod"})]})]})}function Wen({step:e,state:t}){const n=t?.status??"pending",r=t?.detail;return u.jsxs(or.div,{className:"flex items-center gap-3 py-0.5",animate:{opacity:n==="pending"?.5:1,x:n==="running"?2:0},transition:{duration:.2},children:[u.jsx(Ken,{status:n}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx(or.span,{className:me("text-xs inline-block",n==="complete"&&"text-muted-foreground",n==="running"&&"text-foreground font-medium",n==="error"&&"text-red-400",n==="pending"&&"text-muted-foreground/50"),layout:!0,children:e.label}),u.jsx(Qi,{children:r&&n==="complete"&&e.formatDetail&&u.jsx(or.span,{initial:{opacity:0,x:-4},animate:{opacity:1,x:0},className:"ml-1.5 text-[10px] text-muted-foreground/60",children:e.formatDetail(r)})}),u.jsx(Qi,{children:r&&n==="error"&&typeof r.message=="string"&&u.jsx(or.p,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},className:"text-[10px] text-red-400/80 truncate",children:r.message})})]})]})}function Ken({status:e}){return u.jsx("div",{className:"relative size-3.5 shrink-0",children:u.jsx(Qi,{mode:"popLayout",children:u.jsxs(or.div,{className:"absolute inset-0",initial:{scale:.5,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.5,opacity:0},transition:{duration:.2,ease:[.25,1,.5,1]},children:[e==="complete"&&u.jsx(Ms,{className:"size-3.5 text-green-500"}),e==="running"&&u.jsx(nn,{className:"size-3.5 animate-spin text-foreground"}),e==="error"&&u.jsx(yl,{className:"size-3.5 text-red-500"}),e==="pending"&&u.jsx(Ly,{className:"size-3.5 text-muted-foreground/30"})]},e)})})}function Zen({error:e,onRetry:t,onClose:n}){return u.jsxs("div",{className:"flex h-full flex-col gap-3",children:[u.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-red-500/20 bg-red-500/5 py-3 px-3",children:[u.jsx(yl,{className:"size-4 text-red-500 shrink-0 mt-0.5"}),u.jsx("p",{className:"text-xs text-red-400 break-words",children:e})]}),u.jsxs(df,{className:"mt-auto gap-2 sm:gap-0",children:[u.jsx(Pt,{variant:"ghost",size:"sm",onClick:n,className:"text-xs",children:"Close"}),u.jsx(Pt,{variant:"outline",size:"sm",onClick:t,className:"text-xs",children:"Retry"})]})]})}const abe=[{phase:"planning",label:"Build"},{phase:"review",label:"Review"},{phase:"deploying",label:"Deploy"},{phase:"complete",label:"Done"}];function Yen({phase:e}){const t={planning:0,review:1,deploying:2,complete:3,error:3},n=t[e],r=abe;return u.jsx("p",{className:"text-xs text-muted-foreground",children:r.map((s,o)=>{const a=t[s.phase];return u.jsxs("span",{children:[u.jsx("span",{className:me(a===n?"text-foreground":a<n?"text-muted-foreground/60":"text-muted-foreground/30"),children:s.label}),o<r.length-1&&u.jsx("span",{className:"mx-1.5 text-muted-foreground/20",children:"·"})]},s.phase)})})}function Oj({title:e,children:t}){return u.jsxs("div",{className:"rounded-md border border-muted-foreground/10 p-3 space-y-1.5",children:[u.jsx("h4",{className:"text-xs font-medium",children:e}),t]})}function Qen(){const e=bt(T=>T.selectedAgentPath),t=bt(T=>T.agents),n=ds(T=>T.connectionStatus),r=ds(T=>T.agent?.name||T.bot?.name),s=xs(T=>T.targetEnvironment),[o,a]=b.useState(!1),[i,c]=b.useState(!1),[l,d]=b.useState(!1),[f,p]=b.useState(!1),h=t.find(T=>T.agentPath===e),g=h?.consoleMode==="cloud",y=h?.name??r??"Agent",E=h?.status,x=_I({lifecycle:E,connectionStatus:n}),w=x.label!=="Connected",S=U7({consoleMode:h?.consoleMode,environment:s});return t.length===0?u.jsxs("span",{className:"flex items-center gap-1.5 px-1.5 py-0.5 text-[11px] font-medium text-foreground select-none",children:[u.jsxs("span",{className:"flex items-center gap-1",children:[u.jsx(LC,{status:x,className:"size-1.5"}),w&&u.jsx(AP,{status:x,className:"text-[10px] font-medium"})]}),u.jsx("span",{children:y}),S&&u.jsx(lK,{label:S})]}):u.jsxs(ul,{open:i,onOpenChange:c,children:[u.jsx(dl,{asChild:!0,children:u.jsxs("button",{className:me("flex items-center gap-1.5 px-2 py-0.5 rounded-sm cursor-pointer text-[11px] font-medium text-foreground","bg-muted-foreground/5 hover:bg-muted-foreground/15 data-[state=open]:bg-muted-foreground/15","focus:outline-none focus-visible:outline-none","transition-colors"),children:[u.jsxs("span",{className:"flex items-center gap-1 shrink-0",children:[u.jsx(LC,{status:x,className:"size-1.5 shrink-0"}),w&&u.jsx(AP,{status:x,className:"text-[10px] font-medium"})]}),u.jsx("span",{className:"truncate max-w-[180px]",children:y}),S&&u.jsx(lK,{label:S}),u.jsx(Dr,{className:"size-3 text-muted-foreground/70",strokeWidth:2})]})}),u.jsx(Ki,{align:"center",sideOffset:8,className:me("bg-sidebar border-muted-foreground/10 p-1",g?"w-[480px]":"min-w-[260px] max-w-md"),children:u.jsx(E3e,{onOpenAbout:()=>a(!0),onClose:()=>c(!1),onCreateProject:()=>d(!0),onDeploy:()=>p(!0)})}),u.jsx(R3e,{open:f,onOpenChange:p}),u.jsx(zP,{open:o,onOpenChange:a}),u.jsx(fi,{open:l,onOpenChange:d,children:u.jsxs(Ci,{className:"max-w-3xl [&>button:last-child]:hidden",children:[u.jsx(wI,{children:u.jsx(Ni,{children:"Create project"})}),u.jsx($5,{onCancel:()=>d(!1)})]})})]})}const Qh=od()(VQ(e=>({mode:"topbar",sidebarCollapsed:!1,collapsedGroups:{},setMode:t=>e({mode:t}),toggleMode:()=>e(t=>({mode:t.mode==="topbar"?"sidebar":"topbar"})),setSidebarCollapsed:t=>e({sidebarCollapsed:t}),toggleSidebarCollapsed:()=>e(t=>({sidebarCollapsed:!t.sidebarCollapsed})),toggleGroupCollapsed:t=>e(n=>({collapsedGroups:{...n.collapsedGroups,[t]:!n.collapsedGroups[t]}}))}),{name:"adk-layout",partialize:e=>({mode:e.mode,sidebarCollapsed:e.sidebarCollapsed,collapsedGroups:e.collapsedGroups})})),r4=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.userAgent),$I=r4?"⌘":"Ctrl";function Iee(){document.dispatchEvent(new KeyboardEvent("keydown",{key:"k",metaKey:!0,ctrlKey:!0}))}function hp({children:e,className:t}){return u.jsx("kbd",{className:me("inline-flex h-4 min-w-4 items-center justify-center rounded-sm border border-current/25 bg-current/10 px-1 font-mono text-[9px]",t),children:e})}const j3e="adk-command-recents",Xen=4;function D3e(){try{return JSON.parse(localStorage.getItem(j3e)||"[]")}catch{return[]}}function ibe(e){const t=D3e().filter(n=>n!==e);t.unshift(e),localStorage.setItem(j3e,JSON.stringify(t.slice(0,Xen)))}function Jen(){return rI.flatMap(e=>e.items.map(t=>({title:t.title,url:t.url,icon:t.icon,group:e.items.length>1||e.title!==t.title?e.title:void 0,featureFlag:t.featureFlag??e.featureFlag,devOnly:t.devOnly})))}const etn=[{title:"Dev Console Home",url:"/",icon:wW,group:"General"},...Jen(),{title:"Workflow Runs",url:"/workflows/runs",icon:tc,group:"Workflows"}],ttn=[{title:"Settings Overview",url:"/settings?section=overview",icon:tI,group:"Agent Config"},{title:"Configuration Variables",url:"/settings?section=config-variables",icon:$De,group:"Agent Config"},{title:"Secrets",url:"/settings?section=secrets",icon:eI,group:"Agent Config"},{title:"LLM Config",url:"/settings?section=models",icon:CJ,group:"Agent Config"}],ntn=["**:[[cmdk-group-heading]]:text-[11px] **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground/30 **:[[cmdk-group-heading]]:normal-case **:[[cmdk-group-heading]]:tracking-normal **:[[cmdk-group-heading]]:px-3 **:[[cmdk-group-heading]]:py-2","**:[[cmdk-item]]:py-1.5 **:[[cmdk-item]]:px-3 **:[[cmdk-item]]:text-[13px] **:[[cmdk-item]]:rounded-sm **:[[cmdk-item]]:mx-1","**:[[cmdk-item]]:transition-all **:[[cmdk-item]]:duration-150 **:[[cmdk-item]]:ease-out","**:data-[slot=command-input-wrapper]:h-auto **:data-[slot=command-input-wrapper]:p-2 **:data-[slot=command-input-wrapper]:border-0","[&_[data-slot=command-input-wrapper]>div]:bg-muted [&_[data-slot=command-input-wrapper]>div]:rounded-md [&_[data-slot=command-input-wrapper]>div]:px-3 [&_[data-slot=command-input-wrapper]>div]:py-px","**:[[cmdk-list]]:transition-[height] **:[[cmdk-list]]:duration-100 **:[[cmdk-list]]:ease-out","[&_[cmdk-item][data-selected=true]]:bg-muted-foreground/8","**:[[cmdk-input]]:text-[13px]","[&_[cmdk-group]+[cmdk-group]]:border-t [&_[cmdk-group]+[cmdk-group]]:border-muted-foreground/8"].join(" ");function rtn(){const[e,t]=b.useState(!1),[n,r]=b.useState(""),[s,o]=b.useState(!1),[a,i]=b.useState(!1),c=Lc(),l=ui(),{theme:d,setTheme:f}=Oy(),p=Vt(ue=>ue.toggle),h=Vt(ue=>ue.isOpen),g=Vt(ue=>ue.clearMessages),y=Vt(ue=>ue.setQueuedPrompt),E=Vt(ue=>ue.setOpen),x=Vt(ue=>ue.setProvidersDialogOpen),{track:w}=lf(),S=Qh(ue=>ue.mode),T=Qh(ue=>ue.setMode),[k,A]=b.useState([]),{data:N}=pS(),j=N?.flags,O=hS("enable_agent_0"),{environment:D,isCloudConsoleMode:L}=Bc(),U=xs(ue=>ue.setTargetEnvironmentAndSync),B=bt(ue=>ue.setSelectedAgentPath),M=O&&D!=="prod"&&!L,$=b.useCallback(ue=>{B(ue.agentPath)},[B]),{pickAndOpenProject:P,isOpening:q,openingName:z,openError:G,clearError:R}=nI({onSuccess:$}),W=b.useMemo(()=>ttn.filter(ue=>!((D==="prod"||L)&&ue.url.endsWith("section=models")||L&&ue.url.endsWith("section=secrets"))),[D,L]),V=b.useMemo(()=>[...etn,...W].filter(ue=>!ue.featureFlag||j?.[ue.featureFlag]),[W,j]),I=b.useMemo(()=>Object.fromEntries(V.map(ue=>[ue.url,ue])),[V]);b.useEffect(()=>{e&&A(D3e())},[e]),b.useEffect(()=>{l.pathname!=="/"&&ibe(`${l.pathname}${l.search}`)},[l.pathname,l.search]);const{data:J}=cm(),{data:te}=lc(),X=te?.credentials,ne=D==="dev"?"prod":"dev",re=!L&&(ne==="dev"||!!X?.prodBotId),{botUrl:se}=e4(),ce=b.useCallback(ue=>se(ue,X?.workspaceId),[se,X?.workspaceId]),ie=b.useCallback(ue=>{g(),y(ue),E(!0)},[g,y,E]),le=b.useCallback(async(ue,Ie)=>{try{await navigator.clipboard.writeText(ue),qn.success(`${Ie} copied to clipboard`)}catch{qn.error(`Failed to copy ${Ie.toLowerCase()}`)}},[]),oe=b.useMemo(()=>k.map(ue=>I[ue]).filter(Boolean),[k,I]),be=b.useMemo(()=>[{id:"toggle-theme",title:d==="dark"?"Switch to light mode":"Switch to dark mode",icon:d==="dark"?DDe:CDe,action:()=>f(d==="dark"?"light":"dark")},...d!=="system"?[{id:"use-system-theme",title:"Use system theme",icon:kDe,action:()=>f("system")}]:[],{id:"switch-layout",title:S==="topbar"?"Switch to sidebar layout":"Switch to topbar layout",icon:S==="topbar"?TJ:NDe,action:()=>T(S==="topbar"?"sidebar":"topbar")},...re?[{id:"switch-environment",title:`Switch to ${ne==="prod"?"production":"development"}`,icon:nP,action:()=>void U(ne)}]:[],...L?[]:[{id:"create-project",title:"Create project",icon:ld,action:()=>i(!0)},{id:"open-project",title:z?`Opening ${z}...`:"Open project",icon:nc,action:()=>void P(),disabled:q}],{id:"about-agent",title:"About this agent",icon:SW,action:()=>o(!0)},...M?[{id:"toggle-agent0",title:"Toggle agent0",agent0Logo:!0,action:()=>{h||w("agent0.panel_opened",{source:"command_palette"}),p()}},{id:"configure-agent0",title:"Manage agent0 providers",agent0Logo:!0,action:()=>x(!0)}]:[],...X?.devBotId&&X?.workspaceId?[{id:"open-dev-bot",title:"Open dev bot in Botpress",icon:YE,action:()=>window.open(ce(X.devBotId),"_blank")}]:[],...X?.prodBotId&&X?.workspaceId?[{id:"open-prod-bot",title:"Open prod bot in Botpress",icon:YE,action:()=>window.open(ce(X.prodBotId),"_blank")}]:[],...J?.path?[{id:"copy-project-path",title:"Copy project path",icon:li,action:()=>le(J.path,"Project path")}]:[],...X?.devBotId?[{id:"copy-dev-bot-id",title:"Copy dev bot ID",icon:li,action:()=>le(X.devBotId,"Dev bot ID")}]:[],...X?.prodBotId?[{id:"copy-prod-bot-id",title:"Copy prod bot ID",icon:li,action:()=>le(X.prodBotId,"Prod bot ID")}]:[],...X?.workspaceId?[{id:"copy-workspace-id",title:"Copy workspace ID",icon:li,action:()=>le(X.workspaceId,"Workspace ID")}]:[]],[d,f,S,T,re,ne,U,L,i,z,P,q,o,p,h,w,M,x,X,J,ce,le]),Ee=b.useCallback(ue=>{t(!1),ue()},[t]),xe=b.useCallback(ue=>{ibe(ue),Ee(()=>c(ue))},[c,Ee]);b.useEffect(()=>{e||r("")},[e]),b.useEffect(()=>{const ue=Ie=>{(r4?Ie.metaKey:Ie.ctrlKey)&&Ie.key==="k"&&(Ie.preventDefault(),t(Be=>!Be))};return document.addEventListener("keydown",ue),()=>document.removeEventListener("keydown",ue)},[]);let we=0;return u.jsxs(g5,{open:e,onOpenChange:t,children:[u.jsxs(y5,{children:[u.jsx(iI,{className:"fixed inset-0 z-50 bg-black/60 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"}),u.jsxs(lI,{className:me("fixed left-1/2 top-[18%] z-50 w-full max-w-[440px] -translate-x-1/2 outline-hidden","rounded-lg border border-muted-foreground/15 bg-sidebar text-popover-foreground shadow-2xl","data-[state=open]:animate-command-palette-in data-[state=closed]:animate-command-palette-out"),children:[u.jsx(b5,{className:"sr-only",children:"Command palette"}),u.jsx(v5,{className:"sr-only",children:"Search for pages and commands"}),u.jsxs(o3e,{className:ntn,filter:(ue,Ie)=>ue==="ask-agent0"?M?1:0:ue.toLowerCase().includes(Ie.toLowerCase())?1:0,children:[u.jsx(u7t,{placeholder:"Search...",value:n,onValueChange:r}),u.jsxs(a3e,{className:"max-h-[min(360px,50vh)]",children:[u.jsx(i3e,{children:u.jsx("span",{className:"text-muted-foreground/40",children:"No results found."})}),oe.length>0&&!n&&u.jsx(_A,{heading:"Recent",children:oe.map(ue=>{const Ie=we++,Be=D==="prod"&&ue.devOnly;return u.jsx(or.div,{initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.15,delay:Ie*.02,ease:[.25,1,.5,1]},children:u.jsxs(TA,{value:`recent-${ue.title}`,disabled:Be,onSelect:Be?void 0:()=>xe(ue.url),children:[u.jsx(ue.icon,{className:me("size-4",Be&&"opacity-30")}),u.jsx("span",{className:Be?"text-muted-foreground/30":void 0,children:ue.title}),ue.group&&u.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground/20",children:ue.group})]})},`recent-${ue.url}`)})}),u.jsx(_A,{heading:"Pages",children:V.map(ue=>{const Ie=we++,Be=D==="prod"&&ue.devOnly;return u.jsx(or.div,{initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.15,delay:Ie*.02,ease:[.25,1,.5,1]},children:u.jsxs(TA,{disabled:Be,onSelect:Be?void 0:()=>xe(ue.url),children:[u.jsx(ue.icon,{className:me("size-4",Be&&"opacity-30")}),u.jsx("span",{className:Be?"text-muted-foreground/30":void 0,children:ue.title}),ue.group&&u.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground/20",children:ue.group})]})},ue.url)})}),u.jsx(_A,{heading:"Commands",children:be.map(ue=>{const Ie=we++;return u.jsx(or.div,{initial:{opacity:0,x:-6},animate:{opacity:1,x:0},transition:{duration:.15,delay:Ie*.02,ease:[.25,1,.5,1]},children:u.jsxs(TA,{disabled:ue.disabled,onSelect:ue.disabled?void 0:()=>Ee(ue.action),children:[ue.agent0Logo?u.jsx(xy,{className:me("size-4",ue.disabled&&"opacity-30"),active:ue.id==="toggle-agent0"&&h,animation:"shimmer",muted:ue.id!=="toggle-agent0"||!h,shape:"circle"}):ue.icon&&u.jsx(ue.icon,{className:me("size-4",ue.disabled&&"opacity-30")}),u.jsx("span",{className:ue.disabled?"text-muted-foreground/30":void 0,children:ue.title})]})},ue.id)})}),M&&n.trim().length>0&&u.jsx(_A,{heading:"agent0",forceMount:!0,children:u.jsxs(TA,{value:"ask-agent0",onSelect:()=>Ee(()=>ie(n.trim())),className:"agent0-glow",children:[u.jsx(xy,{className:"size-4",active:!0,animation:"shimmer",shape:"circle"}),u.jsxs("span",{className:"truncate",children:["Ask agent0 ",u.jsxs("span",{className:"text-muted-foreground/40",children:["“",n.trim(),"”"]})]})]})})]}),u.jsxs("div",{className:"flex items-center gap-3 px-3 py-1.5 bg-muted",children:[u.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground/50",children:[u.jsx(Wu,{className:"size-2.5"}),u.jsx(Gu,{className:"size-2.5"}),u.jsx("span",{className:"text-[10px]",children:"navigate"})]}),u.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground/50",children:[u.jsx(LCt,{className:"size-2.5"}),u.jsx("span",{className:"text-[10px]",children:"select"})]}),u.jsx("span",{className:"flex items-center gap-1 text-muted-foreground/50",children:u.jsx("span",{className:"text-[10px]",children:"esc close"})}),u.jsxs("span",{className:"ml-auto flex items-center gap-0.5",children:[u.jsx(hp,{children:$I}),u.jsx(hp,{children:"K"})]})]})]})]})]}),u.jsx(zP,{open:s,onOpenChange:o}),u.jsx(fi,{open:a,onOpenChange:i,children:u.jsxs(Ci,{className:"max-w-3xl [&>button:last-child]:hidden",children:[u.jsx(wI,{children:u.jsx(Ni,{children:"Create project"})}),u.jsx($5,{onCancel:()=>i(!1)})]})}),u.jsx(z7,{error:G,onDismiss:R})]})}function $K({tooltipSide:e="right",label:t,buttonClassName:n,iconClassName:r}){const s=hS("enable_agent_0"),o=xs(l=>l.targetEnvironment),a=Vt(l=>l.isOpen),i=Vt(l=>l.toggle),{track:c}=lf();return s?o==="prod"?u.jsxs(vn,{delayDuration:300,children:[u.jsx(xn,{asChild:!0,children:u.jsxs("span",{className:me("flex items-center justify-center rounded-md text-muted-foreground/20 cursor-not-allowed",t?"h-6 w-auto gap-1.5 px-2 border border-muted-foreground/10 bg-muted-foreground/5":"size-8",n),children:[u.jsx(xy,{className:me("size-4",r),muted:!0,shape:"circle"}),t&&u.jsx("span",{className:"small font-medium leading-none text-current",children:t})]})}),u.jsx(yn,{side:e,sideOffset:8,className:"text-xs",children:"agent0 is not available in production"})]}):u.jsxs(vn,{delayDuration:300,children:[u.jsx(xn,{asChild:!0,children:u.jsxs("button",{type:"button",onClick:()=>{a||c("agent0.panel_opened",{source:"toggle_button"}),i()},"aria-label":a?"Close agent0":"Open agent0","aria-pressed":a,className:me("flex items-center justify-center rounded-md transition-colors cursor-pointer",t?me("h-6 w-auto gap-1.5 px-2 border border-muted-foreground/15 bg-muted-foreground/[0.06]","text-muted-foreground/80 hover:border-muted-foreground/25 hover:bg-muted-foreground/10 hover:text-foreground",a&&"border-muted-foreground/25 bg-background-elevated text-foreground"):"size-8 text-muted-foreground/60 hover:text-foreground",n),children:[u.jsx(xy,{className:me("size-4",r),active:a,animation:"shimmer",muted:!a,shape:"circle"}),t&&u.jsx("span",{className:"small font-medium leading-none text-current",children:t})]})}),u.jsxs(yn,{side:e,sideOffset:8,className:"text-xs flex items-center gap-1.5",children:[a?"Close agent0":"Open agent0",u.jsxs("span",{className:"flex items-center gap-0.5",children:[u.jsx(hp,{className:"h-3.5 min-w-3.5 px-0.5 text-[9px]",children:$I}),u.jsx(hp,{className:"h-3.5 min-w-3.5 px-0.5 text-[9px]",children:"]"})]})]})]}):null}const stn=80,otn=200,O3e={};function atn({item:e,isActive:t,isDisabled:n,activeSubItem:r,onHoverStart:s,onHoverEnd:o,onClick:a,buttonRef:i}){r&&(O3e[e.title]=r);const c=e.title;return u.jsx("div",{onMouseEnter:n?void 0:s,onMouseLeave:n?void 0:o,children:u.jsxs("button",{ref:i,onClick:n?void 0:a,className:me("relative px-2 py-0.5 rounded-sm text-[11px] font-medium transition-colors",n?"text-muted-foreground/30 cursor-not-allowed":t?"text-foreground cursor-pointer":"text-muted-foreground hover:text-foreground cursor-pointer"),children:[t&&!n&&u.jsx(or.div,{layoutId:"nav-pill",className:"absolute inset-0 bg-muted-foreground/10 rounded-sm",transition:{type:"spring",stiffness:500,damping:35}}),u.jsx("span",{className:"relative z-10",children:c})]})})}function itn({item:e,activeSubItem:t,left:n,environment:r,onHoverStart:s,onHoverEnd:o,onNavigate:a}){return u.jsx(or.div,{layout:!0,initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.15,ease:[.25,1,.5,1]},className:"fixed top-[calc(var(--header-height)+2px)] z-50 overflow-hidden bg-sidebar rounded-md border border-muted-foreground/10 shadow-lg",onMouseEnter:s,onMouseLeave:o,style:{left:n},children:u.jsx("div",{className:"py-1 px-1 whitespace-nowrap",children:u.jsx(Qi,{mode:"wait",children:u.jsx(or.div,{initial:{opacity:0,x:-4},animate:{opacity:1,x:0},exit:{opacity:0,x:4},transition:{duration:.1,ease:"easeOut"},children:e.items.map(i=>{const c=t?.url===i.url;return r==="prod"&&i.devOnly?u.jsxs("span",{className:"icon-hover flex items-center gap-1.5 rounded-sm px-2 py-1 text-[11px] text-muted-foreground/30 cursor-not-allowed",children:[u.jsx(i.icon,{className:"size-3.5"}),i.title]},i.url):u.jsxs(Fc,{to:i.url,onClick:a,className:me("icon-hover flex items-center gap-1.5 rounded-sm px-2 py-1 text-[11px] transition-colors",c?"text-foreground bg-muted-foreground/10":"text-muted-foreground hover:text-foreground"),children:[u.jsx(i.icon,{className:"size-3.5"}),i.title]},i.url)})},e.title)})})})}function ltn({items:e,pathname:t,environment:n}){const r=Lc(),[s,o]=b.useState(null),a=b.useRef({}),i=b.useRef(null),c=b.useRef(null),l=b.useRef(!1),d=e.filter(w=>w.kind==="group"),f=b.useCallback(w=>{l.current||(c.current&&clearTimeout(c.current),i.current=setTimeout(()=>o(w),stn))},[]),p=b.useCallback(()=>{l.current=!1,i.current&&clearTimeout(i.current),c.current=setTimeout(()=>o(null),otn)},[]),h=b.useCallback(w=>{l.current=!0,i.current&&clearTimeout(i.current),o(null);const S=hk(w.items,t),T=O3e[w.title],k=T&&w.items.some(N=>N.url===T.url)?T:void 0,A=S??k??w.items[0];r(A.url)},[r,t]),g=b.useCallback(()=>{l.current=!0,o(null)},[]);b.useEffect(()=>()=>{i.current&&clearTimeout(i.current),c.current&&clearTimeout(c.current)},[]);const y=d.find(w=>w.title===s),E=s?a.current[s]?.getBoundingClientRect().left??0:0,x=y?hk(y.items,t):void 0;return u.jsxs(u.Fragment,{children:[u.jsx("nav",{className:"flex items-center gap-0.5",children:u.jsx(Y5t,{children:d.map(w=>{const S=hk(w.items,t),T=n==="prod"&&w.items.every(k=>k.devOnly);return u.jsx(atn,{item:w,isActive:!!S,isDisabled:T,activeSubItem:S,onHoverStart:()=>f(w.title),onHoverEnd:p,onClick:()=>h(w),buttonRef:k=>{a.current[w.title]=k}},w.title)})})}),u.jsx(Qi,{children:y&&u.jsx(itn,{item:y,activeSubItem:x,left:E,environment:n,onHoverStart:()=>f(y.title),onHoverEnd:p,onNavigate:g},"shared-dropdown")})]})}function ctn(){const e=xs(o=>o.targetEnvironment),t=ui(),{data:n}=pS(),r=n?.flags,s=OJ(rI,r);return u.jsxs("header",{className:"shrink-0 h-(--header-height) bg-sidebar flex items-center px-2 relative z-50",children:[u.jsx(ltn,{items:s,pathname:t.pathname,environment:e}),u.jsx("div",{className:"absolute left-1/2 -translate-x-1/2",children:u.jsx(Qen,{})}),u.jsx("div",{className:"flex-1"}),u.jsxs("div",{className:"flex items-center gap-0.5",children:[u.jsxs(vn,{delayDuration:0,children:[u.jsx(xn,{asChild:!0,children:u.jsx("button",{type:"button",onClick:Iee,"aria-label":"Search",className:"size-7 flex items-center justify-center rounded-md text-muted-foreground/60 hover:text-foreground transition-colors cursor-pointer",children:u.jsx(ea,{className:"size-3.5"})})}),u.jsxs(yn,{side:"bottom",sideOffset:6,className:"text-xs flex items-center gap-1.5",children:["Search",u.jsxs("span",{className:"flex items-center gap-0.5",children:[u.jsx(hp,{className:"h-3.5 min-w-3.5 text-[9px] px-0.5",children:$I}),u.jsx(hp,{className:"h-3.5 min-w-3.5 text-[9px] px-0.5",children:"K"})]})]})]}),u.jsx($K,{tooltipSide:"bottom",label:"Ask 0",iconClassName:"size-3.5"})]})]})}const lbe=["#3B82F6","#8B5CF6","#EC4899","#F97316","#10B981","#06B6D4","#6366F1","#F43F5E","#14B8A6","#A855F7"];function utn(e){let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t);return lbe[Math.abs(t)%lbe.length]}function cbe({groupId:e,value:t,onChange:n,options:r}){return u.jsx("div",{className:"relative flex items-center gap-0.5 rounded-md bg-muted/50 p-0.5",children:r.map(s=>{const o=s.value===t,a=s.icon;return u.jsxs("button",{type:"button",onClick:()=>n(s.value),"aria-label":s.label,"aria-pressed":o,className:me("relative flex items-center justify-center size-6 rounded-sm transition-colors cursor-pointer",o?"text-foreground":"text-muted-foreground/60 hover:text-foreground"),children:[o&&u.jsx(or.span,{layoutId:`segmented-active-${e}`,className:"absolute inset-0 bg-background rounded-sm shadow-sm",transition:{type:"spring",stiffness:500,damping:35}}),u.jsx(or.span,{className:"relative z-10 flex",initial:!1,animate:o?{scale:1.05,rotate:0}:{scale:1,rotate:0},whileHover:{scale:1.15,rotate:o?0:-8},whileTap:{scale:.9},transition:{type:"spring",stiffness:600,damping:20},children:u.jsx(a,{className:"size-3.5"})})]},s.value)})})}function LK({side:e="bottom",align:t="end",triggerClassName:n}){const{theme:r,setTheme:s}=Oy(),o=Qh(B=>B.mode),a=Qh(B=>B.setMode),{agent:i,bot:c,connectionStatus:l}=ds(),d=xs(B=>B.targetEnvironment),{data:f}=lc(),{track:p,isEnabled:h}=lf(),[g,y]=b.useState(!1),[E,x]=b.useState(!1),w=i?.name||c?.name||"Agent",S=f?.identity,T=S?.displayName||S?.email,k=S?.email,A=T||w,N=A.charAt(0).toUpperCase(),j=utn(A),O=d==="prod",D=_I({connectionStatus:l}),L=O?"bg-purple-500":D.dotClassName,U=r==="light"||r==="dark"||r==="system"?r:"dark";return u.jsxs(u.Fragment,{children:[u.jsxs(Fv,{open:g,onOpenChange:y,children:[u.jsx(mS,{asChild:!0,children:u.jsxs("button",{type:"button","aria-label":"Profile menu",className:me("relative flex items-center justify-center rounded-full transition-opacity hover:opacity-90 cursor-pointer",n),children:[u.jsx("span",{className:"flex items-center justify-center size-6 rounded-full text-[11px] font-semibold text-white",style:{backgroundColor:j},children:N}),u.jsx("span",{className:me("absolute -bottom-0.5 -right-0.5 size-2 rounded-full ring-2 ring-sidebar",L)})]})}),u.jsxs(zy,{side:e,align:t,sideOffset:8,className:"w-60 p-0 bg-popover border-muted-foreground/15",children:[u.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2.5",children:[u.jsx("span",{className:"flex items-center justify-center size-7 rounded-full text-[12px] font-semibold text-white shrink-0",style:{backgroundColor:j},children:N}),u.jsx("div",{className:"flex-1 min-w-0",children:T?u.jsxs(u.Fragment,{children:[u.jsx("p",{className:"text-[12px] font-semibold text-foreground truncate",children:T}),k&&k!==T&&u.jsx("p",{className:"text-[10px] text-muted-foreground/70 truncate",children:k})]}):u.jsx("p",{className:"text-[12px] font-semibold text-foreground truncate",children:w})})]}),u.jsx("div",{className:"h-px bg-muted-foreground/15"}),u.jsx("div",{className:"px-3 pt-2 pb-1 text-[10px] font-medium text-muted-foreground/50 select-none",children:"Preferences"}),u.jsxs("div",{className:"px-3 pb-2 flex flex-col gap-1",children:[u.jsxs("div",{className:"flex items-center justify-between h-7",children:[u.jsx("span",{className:"text-[11px] text-muted-foreground",children:"Theme"}),u.jsx(cbe,{groupId:"theme",value:U,onChange:B=>s(B),options:[{value:"light",icon:DDe,label:"Light"},{value:"dark",icon:CDe,label:"Dark"},{value:"system",icon:kDe,label:"System"}]})]}),u.jsxs("div",{className:"flex items-center justify-between h-7",children:[u.jsx("span",{className:"text-[11px] text-muted-foreground",children:"Layout"}),u.jsx(cbe,{groupId:"layout",value:o,onChange:B=>a(B),options:[{value:"topbar",icon:NDe,label:"Topbar"},{value:"sidebar",icon:TJ,label:"Sidebar"}]})]})]}),u.jsx("div",{className:"h-px bg-muted-foreground/15"}),h&&u.jsxs("button",{type:"button",onClick:()=>{y(!1),p("feedback.opened",{source:"profile_menu"})},className:"w-full flex items-center gap-2 px-3 h-9 text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted/40 transition-colors cursor-pointer",children:[u.jsx(n5,{className:"size-3.5 text-muted-foreground/60"}),"Send feedback"]}),u.jsx("div",{className:"h-px bg-muted-foreground/15"}),u.jsxs("button",{type:"button",onClick:()=>{y(!1),x(!0)},className:"w-full flex items-center gap-2 px-3 h-9 text-[11px] text-muted-foreground hover:text-destructive hover:bg-muted/40 transition-colors cursor-pointer",children:[u.jsx(_J,{className:"size-3.5 text-muted-foreground/60"}),"Sign out"]})]})]}),u.jsx($Oe,{open:E,onOpenChange:x})]})}function dtn(e,t){for(const n of e)if(hk(n.items,t))return n;return null}function ftn({item:e,isActive:t,isDisabled:n,index:r}){const s=e.icon;return u.jsx(or.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{duration:.18,delay:r*.06,ease:[.25,1,.5,1]},children:u.jsxs(vn,{delayDuration:0,children:[u.jsx(xn,{asChild:!0,children:n?u.jsx("span",{className:"flex items-center justify-center size-8 rounded-md text-muted-foreground/20 cursor-not-allowed",children:u.jsx(s,{className:"size-4"})}):u.jsx(Fc,{to:e.url,className:me("flex items-center justify-center size-8 rounded-md transition-colors",t?"text-foreground bg-muted-foreground/10":"text-muted-foreground/50 hover:text-foreground"),children:u.jsx(s,{className:"size-4"})})}),u.jsx(yn,{side:"right",sideOffset:8,className:"text-xs",children:e.title})]})})}function ptn({group:e,pathname:t,environment:n}){return u.jsx(u.Fragment,{children:e.items.map((r,s)=>u.jsx(ftn,{item:r,isActive:d5(t,r.url),isDisabled:n==="prod"&&!!r.devOnly,index:s},r.url))})}function htn(){const{pathname:e}=ui(),{data:t}=pS(),n=t?.flags,r=xs(i=>i.targetEnvironment),o=OJ(rI,n).filter(i=>i.kind==="group"),a=dtn(o,e);return u.jsxs("nav",{className:"shrink-0 w-[44px] flex flex-col items-center bg-sidebar",children:[u.jsx(Fc,{to:"/","aria-label":"Dev Console home",className:"size-8 flex items-center justify-center cursor-pointer shrink-0 my-1.5",children:u.jsx("span",{className:"size-7 rounded-sm bg-sidebar-primary flex items-center justify-center p-1.5",children:u.jsx("img",{src:"/ADK.svg",alt:"ADK",className:"size-full invert"})})}),u.jsx("div",{className:"w-5 h-px bg-muted-foreground/15 shrink-0 mb-2"}),u.jsx("div",{className:"flex flex-col items-center gap-1",children:a&&u.jsx(ptn,{group:a,pathname:e,environment:r},a.title)}),u.jsx("div",{className:"flex-1"}),u.jsx("div",{className:"flex flex-col items-center gap-2 pb-3",children:u.jsx(LK,{side:"right",align:"end"})})]})}function M3e(){const e=bt(s=>s.baseUrl),t=bt(s=>s.setAgents),n=e??(typeof window<"u"?window.location.origin:null),r=Vn({queryKey:["agents",n],queryFn:async()=>{if(!n)throw new Error("No base URL configured");const s=await fetch(`${n}/api/agents`,{signal:AbortSignal.timeout(2e3)});if(!s.ok)throw new Error("Failed to fetch agents");return s.json()},refetchInterval:3e3,enabled:n!==null});return b.useEffect(()=>{r.data?.agents&&t(r.data.agents)},[r.data,t]),r}function mtn({onOpenAbout:e}){const[t,n]=b.useState(!1),[r,s]=b.useState(!1),[o,a]=b.useState(!1),i=bt(w=>w.selectedAgentPath),c=bt(w=>w.agents),l=ds(w=>w.agent?.name||w.bot?.name),d=ds(w=>w.connectionStatus),f=xs(w=>w.targetEnvironment),p=c.find(w=>w.agentPath===i),h=p?.name??l??"Agent",g=p?.status,y=p?.consoleMode==="cloud",E=_I({lifecycle:g,connectionStatus:d}),x=U7({consoleMode:p?.consoleMode,environment:f});return u.jsxs(ul,{open:t,onOpenChange:n,children:[u.jsx(dl,{asChild:!0,children:u.jsxs("button",{type:"button",className:"w-full flex items-center gap-2 px-2 h-9 rounded-md hover:bg-muted-foreground/5 data-[state=open]:bg-muted-foreground/5 transition-colors cursor-pointer text-left",children:[u.jsx("span",{className:"size-7 rounded-sm bg-sidebar-primary flex items-center justify-center p-1.5 shrink-0",children:u.jsx("img",{src:"/ADK.svg",alt:"ADK",className:"size-full invert"})}),u.jsxs("span",{className:"flex-1 min-w-0",children:[u.jsxs("span",{className:"flex items-center gap-1 min-w-0",children:[u.jsx("span",{className:"min-w-0 truncate text-[12px] font-medium text-foreground",children:h}),x&&u.jsx(lK,{label:x,className:"shrink-0"})]}),u.jsxs("span",{className:"flex items-center gap-1 min-w-0",children:[u.jsx(LC,{status:E,className:"size-1.5 shrink-0"}),u.jsx(AP,{status:E,className:"block text-[10px] truncate"})]})]}),u.jsx(Dr,{className:"size-3.5 text-muted-foreground/60 shrink-0",strokeWidth:2})]})}),u.jsx(Ki,{side:"bottom",align:"start",sideOffset:6,className:me("bg-sidebar border-muted-foreground/10 p-1",y?"w-[480px]":"min-w-[260px] max-w-[420px]"),children:u.jsx(E3e,{onOpenAbout:e,onClose:()=>n(!1),onCreateProject:()=>s(!0),onDeploy:()=>a(!0)})}),u.jsx(R3e,{open:o,onOpenChange:a}),u.jsx(fi,{open:r,onOpenChange:s,children:u.jsxs(Ci,{className:"max-w-3xl [&>button:last-child]:hidden",children:[u.jsx(wI,{children:u.jsx(Ni,{children:"Create project"})}),u.jsx($5,{onCancel:()=>s(!1)})]})})]})}function P3e({sub:e,pathname:t,environment:n}){const r=d5(t,e.url),s=n==="prod"&&!!e.devOnly,o=e.icon;return s?u.jsxs("span",{"aria-disabled":"true",className:"flex items-center gap-2 h-7 px-2 rounded-md text-[11px] text-muted-foreground/25 cursor-not-allowed",children:[u.jsx(o,{className:"size-3.5 shrink-0"}),u.jsx("span",{className:"truncate",children:e.title})]}):u.jsxs(Fc,{to:e.url,className:me("flex items-center gap-2 h-7 px-2 rounded-md text-[11px] transition-colors",r?"bg-muted-foreground/10 text-foreground":"text-muted-foreground hover:text-foreground hover:bg-muted-foreground/5"),children:[u.jsx(o,{className:"size-3.5 shrink-0 text-muted-foreground/60"}),u.jsx("span",{className:"truncate",children:e.title})]})}function gtn({group:e,pathname:t,environment:n}){const r=Qh(a=>a.collapsedGroups[e.title]??!1),s=Qh(a=>a.toggleGroupCollapsed),o=!r;return u.jsxs("div",{className:"flex flex-col",children:[u.jsxs("button",{type:"button",onClick:()=>s(e.title),"aria-expanded":o,className:"group/label flex items-center gap-2 h-7 px-2 text-[10px] font-medium text-muted-foreground/50 hover:text-muted-foreground transition-colors select-none cursor-pointer",children:[u.jsx("span",{className:"flex-1 text-left truncate",children:e.title}),u.jsx(Dr,{className:me("size-3 text-muted-foreground/40 transition-transform duration-200",!o&&"-rotate-90")})]}),u.jsx("div",{className:me("grid transition-[grid-template-rows] duration-200 ease-out",o?"grid-rows-[1fr]":"grid-rows-[0fr]"),children:u.jsx("div",{className:"overflow-hidden",children:u.jsx("div",{className:"flex flex-col gap-0.5 pb-1",children:e.items.map(a=>u.jsx(P3e,{sub:a,pathname:t,environment:n},a.url))})})})]})}function ytn(){return u.jsxs("button",{type:"button",onClick:Iee,className:"w-full flex items-center gap-2 h-7 px-2 rounded-md text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted-foreground/5 transition-colors cursor-pointer",children:[u.jsx(ea,{className:"size-3.5 shrink-0 text-muted-foreground/60"}),u.jsx("span",{className:"flex-1 text-left",children:"Search"}),u.jsxs("span",{className:"flex items-center gap-0.5",children:[u.jsx(hp,{className:"h-3.5 min-w-3.5 text-[9px] px-0.5",children:$I}),u.jsx(hp,{className:"h-3.5 min-w-3.5 text-[9px] px-0.5",children:"K"})]})]})}function btn({sub:e,pathname:t,environment:n}){const r=d5(t,e.url),s=n==="prod"&&!!e.devOnly,o=e.icon;return u.jsxs(vn,{delayDuration:0,children:[u.jsx(xn,{asChild:!0,children:s?u.jsx("span",{className:"flex items-center justify-center size-8 rounded-md text-muted-foreground/20 cursor-not-allowed",children:u.jsx(o,{className:"size-4"})}):u.jsx(Fc,{to:e.url,className:me("flex items-center justify-center size-8 rounded-md transition-colors",r?"bg-muted-foreground/10 text-foreground":"text-muted-foreground/60 hover:text-foreground hover:bg-muted-foreground/5"),children:u.jsx(o,{className:"size-4"})})}),u.jsx(yn,{side:"right",sideOffset:8,className:"text-xs",children:e.title})]})}function vtn(){const{pathname:e}=ui(),[t,n]=b.useState(!1);M3e();const{data:r}=pS(),s=r?.flags,o=xs(w=>w.targetEnvironment),{connectionStatus:a}=ds(),i=bt(w=>w.selectedAgentPath),c=bt(w=>w.agents),l=Qh(w=>w.sidebarCollapsed),d=Qh(w=>w.toggleSidebarCollapsed),p=OJ(rI,s).filter(w=>w.kind==="group"),h=c.find(w=>w.agentPath===i),g=h?.status,y=_I({lifecycle:g,connectionStatus:a}),E=U7({consoleMode:h?.consoleMode,environment:o}),x=E?`${E} - ${y.label}`:y.label;return l?u.jsxs("nav",{"aria-label":"Main",className:"shrink-0 w-[44px] flex flex-col items-center bg-sidebar",children:[u.jsxs(vn,{delayDuration:0,children:[u.jsx(xn,{asChild:!0,children:u.jsx(Fc,{to:"/","aria-label":`Dev Console home, ${x}`,className:"size-8 flex items-center justify-center cursor-pointer shrink-0 mt-1.5 mb-1.5",children:u.jsxs("span",{className:"relative size-7 rounded-sm bg-sidebar-primary flex items-center justify-center p-1.5",children:[u.jsx("img",{src:"/ADK.svg",alt:"ADK",className:"size-full invert"}),E&&u.jsx("span",{className:"absolute -top-0.5 -right-1 flex h-3 min-w-3 items-center justify-center rounded-sm bg-purple-500 px-[2px] text-[7px] font-semibold leading-3 text-white ring-2 ring-sidebar",children:E[0]}),u.jsx(LC,{status:y,className:"absolute -bottom-0.5 -right-0.5 size-2",ringClassName:"ring-2 ring-sidebar"})]})})}),u.jsxs(yn,{side:"right",sideOffset:8,className:"text-xs",children:["Dev Console home - ",x]})]}),u.jsx("div",{className:"w-5 h-px bg-muted-foreground/15 shrink-0 mb-2"}),u.jsxs(vn,{delayDuration:0,children:[u.jsx(xn,{asChild:!0,children:u.jsx("button",{type:"button",onClick:Iee,"aria-label":"Search",className:"flex items-center justify-center size-8 rounded-md text-muted-foreground/60 hover:text-foreground hover:bg-muted-foreground/5 transition-colors cursor-pointer",children:u.jsx(ea,{className:"size-4"})})}),u.jsxs(yn,{side:"right",sideOffset:8,className:"text-xs flex items-center gap-1.5",children:["Search",u.jsxs("span",{className:"flex items-center gap-0.5",children:[u.jsx(hp,{className:"h-3.5 min-w-3.5 text-[9px] px-0.5",children:$I}),u.jsx(hp,{className:"h-3.5 min-w-3.5 text-[9px] px-0.5",children:"K"})]})]})]}),u.jsx("div",{className:"flex-1 overflow-y-auto overflow-x-hidden flex flex-col items-center gap-1 mt-2 pb-2 w-full",children:p.map((w,S)=>u.jsxs("div",{className:"flex flex-col items-center gap-1 w-full",children:[S>0&&w.title!=="Chat"&&u.jsx("div",{className:"w-5 h-px bg-muted-foreground/10 shrink-0 my-1"}),w.items.map(T=>u.jsx(btn,{sub:T,pathname:e,environment:o},T.url))]},w.title))}),u.jsxs("div",{className:"shrink-0 flex flex-col items-center gap-1 pb-2",children:[u.jsx($K,{tooltipSide:"right"}),u.jsxs(vn,{delayDuration:0,children:[u.jsx(xn,{asChild:!0,children:u.jsx("button",{type:"button",onClick:d,"aria-label":"Expand sidebar",className:"flex items-center justify-center size-8 rounded-md text-muted-foreground/60 hover:text-foreground hover:bg-muted-foreground/5 transition-colors cursor-pointer",children:u.jsx(TJ,{className:"size-4"})})}),u.jsx(yn,{side:"right",sideOffset:8,className:"text-xs",children:"Expand sidebar"})]}),u.jsx(LK,{side:"right",align:"end"})]}),u.jsx(zP,{open:t,onOpenChange:n})]}):u.jsxs("nav",{"aria-label":"Main",className:"shrink-0 w-[224px] flex flex-col bg-sidebar",children:[u.jsx("div",{className:"shrink-0 px-2 pb-2",children:u.jsx(mtn,{onOpenAbout:()=>n(!0)})}),u.jsxs("div",{className:"flex-1 overflow-auto px-2 pt-2 pb-2 flex flex-col gap-0.5",children:[u.jsx(ytn,{}),p.map(w=>w.items.length===1?u.jsx(P3e,{sub:w.items[0],pathname:e,environment:o},w.title):u.jsx(gtn,{group:w,pathname:e,environment:o},w.title))]}),u.jsxs("div",{className:"shrink-0 flex items-center px-3 py-2",children:[u.jsx(LK,{side:"top",align:"start"}),u.jsx("div",{className:"flex-1"}),u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx($K,{tooltipSide:"top",label:"Ask 0"}),u.jsxs(vn,{delayDuration:300,children:[u.jsx(xn,{asChild:!0,children:u.jsx("button",{type:"button",onClick:d,"aria-label":"Collapse sidebar",className:"size-7 flex items-center justify-center rounded-md text-muted-foreground/60 hover:text-foreground hover:bg-muted-foreground/5 transition-colors cursor-pointer",children:u.jsx(gIt,{className:"size-3.5"})})}),u.jsx(yn,{side:"top",sideOffset:6,className:"text-xs",children:"Collapse sidebar"})]})]})]}),u.jsx(zP,{open:t,onOpenChange:n})]})}function xtn(){return u.jsx("svg",{className:"absolute size-0","aria-hidden":!0,children:u.jsxs("filter",{id:"liquid-glass-distortion",x:"0%",y:"0%",width:"100%",height:"100%",filterUnits:"objectBoundingBox",children:[u.jsx("feTurbulence",{type:"fractalNoise",baseFrequency:"0.01 0.01",numOctaves:"1",seed:"5",result:"turbulence"}),u.jsx("feGaussianBlur",{in:"turbulence",stdDeviation:"3",result:"softMap"}),u.jsx("feDisplacementMap",{in:"SourceGraphic",in2:"softMap",scale:"80",xChannelSelector:"R",yChannelSelector:"G"})]})})}const Etn=({...e})=>{const{theme:t="system"}=Oy();return u.jsx(vBt,{theme:t,className:"toaster group",position:"bottom-right",toastOptions:{unstyled:!0,classNames:{toast:"group toast flex w-full items-start gap-3 rounded-sm border-transparent bg-blue-600 px-5 py-4 text-white shadow-lg data-[type=error]:bg-red-600 data-[type=warning]:bg-amber-600",title:"text-sm font-normal leading-snug",description:"text-sm leading-snug text-white/90",content:"flex-1 min-w-0",actionButton:"rounded-md bg-neutral-100 px-3 py-1.5 text-sm font-medium text-neutral-900 hover:bg-white transition-colors",cancelButton:"rounded-md bg-transparent px-3 py-1.5 text-sm font-medium text-white hover:bg-white/10 transition-colors",closeButton:"bg-transparent border-transparent text-white/70 hover:text-white"}},...e})};function wtn(){const e=hS("enable_agent_0"),t=xs(o=>o.targetEnvironment),n=Vt(o=>o.isOpen),r=Vt(o=>o.toggle),{track:s}=lf();b.useEffect(()=>{const o=a=>{!((r4?a.metaKey:a.ctrlKey)&&!a.shiftKey&&!a.altKey&&a.key==="]")||a.repeat||!e||t==="prod"||(a.preventDefault(),n||s("agent0.panel_opened",{source:"keyboard_shortcut"}),r())};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[e,n,t,r,s])}function Stn(){const e=xs(s=>s.targetEnvironment),t=xs(s=>s.setTargetEnvironmentAndSync),{data:n}=lc(),r=!n?.credentials?.prodBotId;b.useEffect(()=>{const s=o=>{if(o.shiftKey&&(r4?o.metaKey:o.ctrlKey)&&o.key.toLowerCase()==="e"){o.preventDefault();const a=e==="dev"?"prod":"dev";if(a==="prod"&&r)return;t(a)}};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[e,r,t])}function _tn({canSwitchToDev:e,onSwitchToDev:t}){return u.jsx("div",{className:"flex h-full min-h-[420px] items-center justify-center p-4",children:u.jsxs("div",{className:"max-w-md rounded-md border border-dashed bg-card p-8 text-center",children:[u.jsx("div",{className:"mx-auto mb-4 flex size-10 items-center justify-center rounded-sm bg-muted",children:u.jsx(CCt,{className:"size-5 text-muted-foreground"})}),u.jsx("p",{className:"h2",children:"Production target not deployed"}),u.jsx("p",{className:"small mt-2 text-muted-foreground",children:"Deploy this agent to publish the prod target. Until then, prod views do not have deployed metadata to load."}),e&&u.jsxs(Pt,{type:"button",variant:"outline",className:"mt-5",onClick:t,children:[u.jsx(lIt,{}),"Switch to Dev"]})]})})}class Ttn extends b.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t,n){try{j1.capture("error.ui",{page:this.props.page,error_type:t.name||"UnknownError",error_message:xW(t.message)||void 0,component:n.componentStack?.split(`
1139
1139
  `)[1]?.trim()||void 0})}catch{}}render(){return this.state.hasError?u.jsx("div",{className:"flex items-center justify-center h-full",children:u.jsxs("div",{className:"text-center space-y-3",children:[u.jsx("p",{className:"text-sm text-muted-foreground",children:"Something went wrong on this page."}),u.jsx("button",{onClick:()=>{this.setState({hasError:!1}),window.location.reload()},className:"px-3 py-1.5 text-xs bg-primary text-primary-foreground rounded-md hover:bg-primary/90",children:"Reload"})]})}):this.props.children}}function Atn({children:e,isCloudConsoleMode:t}){const n=xs(d=>d.targetEnvironment),r=xs(d=>d.setTargetEnvironmentAndSync),{data:s}=lc(),{error:o}=cm();if(n!=="prod")return u.jsx(u.Fragment,{children:e});const a=s!==void 0,i=!!s?.credentials?.prodBotId,c=a&&!i,l=iP(o);return!c&&!l?u.jsx(u.Fragment,{children:e}):u.jsx(_tn,{canSwitchToDev:!t,onSwitchToDev:()=>void r("dev")})}function ktn(){const e=ui(),t=Lc(),n=Vt(w=>w.isOpen),r=Vt(w=>w.setOpen),s=xs(w=>w.targetEnvironment),o=bt(w=>w.selectedAgentPath),i=bt(w=>w.agents).find(w=>w.agentPath===o),c=s==="prod",l=i?.consoleMode==="cloud",{isLoading:d}=pS(),f=hS("enable_agent_0"),h=Qh(w=>w.mode)==="sidebar",g=e.pathname.startsWith("/agent-map"),y=b.useRef(null);wtn(),Stn(),b.useEffect(()=>{!d&&(c||!f)&&n&&r(!1)},[c,f,d,n,r]),b.useEffect(()=>{if(!(c&&HRt(e.pathname))){y.current=null;return}y.current!==e.pathname&&(y.current=e.pathname,qn("View unavailable in production",{description:"This view is only available in local dev. Opening Agent Map instead."}),t(AC,{replace:!0}))},[c,e.pathname,t]);const E=!c&&f&&n,x=u.jsx(Ttn,{page:e.pathname,children:u.jsx(Atn,{isCloudConsoleMode:l,children:u.jsx(kit,{})})});return u.jsx(Lv,{delayDuration:0,children:u.jsxs("div",{className:me("h-screen overflow-hidden bg-sidebar flex flex-col",h?"[--header-height:8px]":"[--header-height:2rem]"),children:[h&&u.jsx("div",{className:"h-2 shrink-0 bg-sidebar"}),u.jsx("div",{className:"flex flex-1 min-h-0",children:h?u.jsxs(u.Fragment,{children:[u.jsx(vtn,{}),u.jsx("main",{className:me("flex-1 flex flex-col min-w-0 min-h-0 bg-background transition-[border-radius] duration-200",g?"overflow-hidden":"overflow-auto pt-4 px-4","rounded-tl-xl",E&&"rounded-tr-xl"),children:x}),!c&&f&&u.jsx(obe,{})]}):u.jsxs(u.Fragment,{children:[u.jsx(htn,{}),u.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[u.jsx(ctn,{}),u.jsxs("div",{className:"flex flex-1 min-h-0",children:[u.jsx("main",{className:me("flex-1 flex flex-col min-w-0 min-h-0 bg-background transition-[border-radius] duration-200",g?"overflow-hidden":"overflow-auto pt-4 px-4","rounded-tl-xl",E&&"rounded-tr-xl"),children:x}),!c&&f&&u.jsx(obe,{})]})]})]})}),u.jsx(rtn,{}),f&&u.jsx(P7,{}),u.jsx(xtn,{}),u.jsx(Sen,{active:c}),u.jsx(Etn,{})]})})}const Ctn="selected";function Yy(e,t){const[n,r]=BN(),s=bt(h=>h.selectedAgentPath),o=sC(h=>h.setSelection),a=sC(h=>h.getSelection),i=b.useRef(!1),c=b.useRef(s),l=t?.param??Ctn,d=n.get(l),f=d??(i.current?null:a(s,e));b.useEffect(()=>{if(!i.current)if(i.current=!0,d!==null)o(s,e,d);else{const h=a(s,e);h!==null&&r(g=>{const y=new URLSearchParams(g);return y.set(l,h),y},{replace:!0})}},[a,e,l,s,r,o,d]),b.useEffect(()=>{if(!i.current||c.current===s)return;c.current=s;const h=a(s,e);r(g=>{const y=new URLSearchParams(g);return h!==null?y.set(l,h):y.delete(l),y},{replace:!0})},[s,a,e,l,r]);const p=b.useCallback(h=>{o(s,e,h),r(g=>{const y=new URLSearchParams(g);return h===null?y.delete(l):y.set(l,h),y},{replace:!0})},[e,l,s,r,o]);return[f,p]}function Wt({className:e,...t}){return u.jsx("div",{className:me("animate-pulse rounded-md bg-muted",e),...t})}const Ntn={expandAll:!1,interactive:!0},$3e=b.createContext(Ntn);function L3e(e,t=30){if(e==null||typeof e!="object")return 1;const n=Array.isArray(e)?e:Object.values(e);let r=n.length;for(const s of n){if(r>=t)return t;r+=L3e(s,t-r)}return Math.min(r,t)}const Itn=[{prefix:"conv_",label:"Conversation",color:"text-cyan-600 dark:text-cyan-400"},{prefix:"user_",label:"User",color:"text-indigo-600 dark:text-indigo-400"},{prefix:"wrkflow_",label:"Workflow",color:"text-pink-600 dark:text-pink-400"},{prefix:"evt_",label:"Event",color:"text-amber-600 dark:text-amber-400"}],Rtn=e=>/^[0-9A-HJKMNP-TV-Z]{26}$/i.test(e);function jtn(e){for(const t of Itn)if(e.startsWith(t.prefix)){const n=e.substring(t.prefix.length);if(Rtn(n))return t}return null}const vg=({label:e,depth:t,children:n})=>u.jsxs("div",{className:"flex items-baseline gap-1",style:{paddingLeft:`${t*14+12}px`},children:[e!==void 0&&u.jsxs(u.Fragment,{children:[u.jsxs("span",{className:"text-purple-600 dark:text-purple-400",children:['"',e,'"']}),":"," "]}),n]}),Ree=({label:e,value:t,depth:n,parentWeight:r})=>{const{expandAll:s,interactive:o}=b.useContext($3e),a=typeof t=="object"&&t!==null?L3e(t):1,i=s||n===0||a<20&&r<25,[c,l]=b.useState(i);if(t===null)return u.jsx(vg,{label:e,depth:n,children:u.jsx("span",{className:"text-orange-500",children:"null"})});if(t===void 0)return u.jsx(vg,{label:e,depth:n,children:u.jsx("span",{className:"text-orange-500",children:"undefined"})});if(typeof t=="boolean")return u.jsx(vg,{label:e,depth:n,children:u.jsx("span",{className:"text-orange-500",children:String(t)})});if(typeof t=="number")return u.jsx(vg,{label:e,depth:n,children:u.jsx("span",{className:"text-blue-500",children:t})});if(typeof t=="string"){const E=jtn(t);return E?u.jsx(vg,{label:e,depth:n,children:u.jsxs("span",{className:me("break-all",E.color),children:['"',t,'"']})}):t.length<=120?u.jsx(vg,{label:e,depth:n,children:u.jsxs("span",{className:"text-green-600 dark:text-green-400 break-all",children:['"',t,'"']})}):u.jsx(Dtn,{label:e,depth:n,value:t})}const d=Array.isArray(t),f=d?t.map((E,x)=>[x,E]):Object.entries(t),p=d?"[":"{",h=d?"]":"}",g=d?`${t.length} items`:`${f.length} keys`;if(f.length===0)return u.jsx(vg,{label:e,depth:n,children:u.jsxs("span",{className:"text-muted-foreground",children:[p,h]})});const y=o&&!s;return u.jsxs("div",{children:[u.jsxs("div",{className:me("flex items-center gap-1 rounded -ml-1 pl-1",y&&"cursor-pointer hover:bg-accent/50"),style:{paddingLeft:`${n*14}px`},onClick:y?()=>l(!c):void 0,children:[y?c?u.jsx(Dr,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):u.jsx(cs,{className:"h-3 w-3 shrink-0 text-muted-foreground"}):u.jsx("div",{className:"w-3 shrink-0"}),e!==void 0&&u.jsxs(u.Fragment,{children:[u.jsxs("span",{className:"text-purple-600 dark:text-purple-400",children:['"',e,'"']}),":"," "]}),!c&&u.jsxs("span",{className:"text-muted-foreground",children:[p," ",g," ",h]}),c&&u.jsx("span",{className:"text-muted-foreground",children:p})]}),c&&u.jsxs(u.Fragment,{children:[f.map(E=>{const x=E[0],w=E[1];return u.jsx(Ree,{label:d?void 0:String(x),value:w,depth:n+1,parentWeight:a},String(x))}),u.jsx("div",{style:{paddingLeft:`${n*14+12}px`},className:"text-muted-foreground",children:h})]})]})};function Dtn({label:e,depth:t,value:n}){const[r,s]=b.useState(!1),o=b.useMemo(()=>{try{const a=JSON.parse(n);return typeof a=="object"&&a!==null?a:null}catch{return null}},[n]);return r&&o?u.jsx(Ree,{label:e,value:o,depth:t,parentWeight:0}):u.jsx("div",{children:u.jsx(vg,{label:e,depth:t,children:u.jsx("span",{className:"text-green-600 dark:text-green-400 break-all cursor-pointer hover:underline decoration-green-600/30",onClick:a=>{a.stopPropagation(),s(!r)},children:r?`"${n}"`:`"${n.substring(0,120)}..."`})})})}const Oo=({data:e,className:t,expandAll:n=!1,interactive:r=!0,maxLines:s})=>{const[o,a]=b.useState(!1),[i,c]=b.useState(!1),[l,d]=b.useState(!1),f=b.useRef(null),p=s?s*1.65:0;b.useEffect(()=>{if(!s||!f.current)return;const y=f.current,E=parseFloat(getComputedStyle(y).fontSize);d(y.scrollHeight>p*E+2)},[e,s,p]);const h=async()=>{try{await navigator.clipboard.writeText(JSON.stringify(e,null,2)),a(!0),setTimeout(()=>a(!1),2e3)}catch{}},g=l&&!i;return u.jsx($3e.Provider,{value:{expandAll:n,interactive:r},children:u.jsxs("div",{className:me("relative group",g&&"cursor-pointer",t),onClick:g?y=>{y.stopPropagation(),c(!0)}:void 0,children:[u.jsxs(vn,{children:[u.jsx(xn,{asChild:!0,children:u.jsx("button",{onClick:y=>{y.stopPropagation(),h()},className:me("absolute top-0.5 right-0.5 p-1 rounded-sm text-[10px] flex items-center gap-0.5 transition-all duration-quick z-10","opacity-0 group-hover:opacity-100",o?"bg-green-500/10 text-green-600":"bg-muted hover:bg-accent text-muted-foreground hover:text-foreground"),children:o?u.jsx(Xr,{className:"h-3 w-3"}):u.jsx(li,{className:"h-3 w-3"})})}),u.jsx(yn,{children:"Copy as JSON"})]}),u.jsx("div",{ref:f,className:me("code leading-relaxed",g&&"overflow-hidden"),style:g?{maxHeight:`${p}em`}:void 0,children:u.jsx(Ree,{value:e,depth:0,parentWeight:0})}),g&&u.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-6 bg-linear-to-t from-muted to-transparent pointer-events-none"})]})})};function aw({schema:e}){if(!e)return u.jsx(AA,{children:"No schema defined"});const t=_y(e);if(t===!0)return u.jsx(AA,{children:"Any value"});if(t===!1)return u.jsx(AA,{children:"No valid value"});if(!uu(t))return u.jsx(Oo,{data:e,expandAll:!0,interactive:!1});const n=HP(t);if(n)return Object.entries(n).length===0?u.jsx(AA,{children:"No fields"}):u.jsx(ube,{schema:t,properties:n});const r=B3e(t),s=r?HP(r):void 0;return r&&s?u.jsxs("div",{className:"space-y-3",children:[u.jsx(dbe,{label:"Array",type:Lg(t),description:FK(t)}),u.jsx(ube,{schema:r,properties:s,level:1})]}):u.jsx(dbe,{label:"Value",type:Lg(t),description:FK(t),emptyFallback:"No fields"})}function ube({schema:e,properties:t,level:n=0}){const r=q3e(e),s=Object.entries(t).flatMap(([o,a])=>F3e(o,a,r.has(o),n));return u.jsx("div",{className:me("-mb-1 overflow-x-auto",n>0&&"border-l border-muted-foreground/10 pl-3"),children:u.jsxs("table",{className:"w-full min-w-[560px] table-fixed border-collapse",children:[u.jsx("thead",{children:u.jsxs("tr",{className:"caption text-left [&>th]:border-b [&>th]:border-muted-foreground/20",children:[u.jsx("th",{className:"w-[28%] pb-2.5 font-medium text-muted-foreground",children:"Parameter"}),u.jsx("th",{className:"w-[16%] pb-2.5 font-medium text-muted-foreground",children:"Type"}),u.jsx("th",{className:"w-[14%] pb-2.5 font-medium text-muted-foreground",children:"Required"}),u.jsx("th",{className:"pb-2.5 font-medium text-muted-foreground",children:"Description"})]})}),u.jsx("tbody",{children:s.map((o,a)=>u.jsx(Otn,{row:o,isFirst:a===0},o.path))})]})})}function Otn({row:e,isFirst:t}){const n=FK(e.schema),r=Lg(e.schema);return u.jsxs("tr",{className:me(!t&&"[&>td]:border-t [&>td]:border-muted-foreground/10"),children:[u.jsx("td",{className:"py-2 pr-4 align-top",children:u.jsx("div",{className:"min-w-0",children:u.jsx("span",{className:"code inline-block max-w-full truncate rounded-sm bg-muted/60 px-1.5 py-0.5 text-foreground/90",children:e.path})})}),u.jsx("td",{className:"py-2 pr-4 align-top",children:u.jsx("span",{className:"code text-muted-foreground",children:r})}),u.jsx("td",{className:"py-2 pr-4 align-top",children:e.required?u.jsx("span",{className:"small rounded-sm bg-muted px-1.5 py-0.5 font-medium text-foreground/85 ring-1 ring-muted-foreground/15",children:"required"}):u.jsx("span",{className:"small text-muted-foreground/55",children:"optional"})}),u.jsx("td",{className:"body py-2 align-top leading-relaxed text-muted-foreground",children:n||u.jsx("span",{className:"text-muted-foreground/40",children:"-"})})]})}function F3e(e,t,n,r,s){const o=s?`${s}.${e}`:e,a=_y(t),i=[{name:e,path:o,schema:a,required:n,depth:r}],c=Ptn(a);if(c&&r<2){const l=q3e(c.schema);for(const[d,f]of Object.entries(c.properties))i.push(...F3e(d,f,l.has(d),r+1,o))}return i}function dbe({label:e,type:t,description:n,emptyFallback:r}){return r&&t==="object"&&!n?u.jsx(AA,{children:r}):u.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-start gap-3",children:[u.jsxs("div",{className:"min-w-0",children:[u.jsx("span",{className:"caption text-foreground/80",children:e}),n&&u.jsx("p",{className:"small mt-1 max-w-prose whitespace-pre-wrap leading-snug",children:n})]}),u.jsx(Mtn,{children:t})]})}function Mtn({children:e}){return u.jsx("span",{className:"code max-w-[220px] truncate rounded-sm bg-background/70 px-1.5 py-0.5 text-[11px] leading-4 text-muted-foreground/85 ring-1 ring-muted-foreground/10",children:e})}function AA({children:e}){return u.jsx("p",{className:"small text-muted-foreground/50",children:e})}function Ptn(e){const t=_y(e);if(!uu(t))return null;const n=HP(t);if(n&&Object.keys(n).length>0)return{schema:t,properties:n};const r=B3e(t);if(!r)return null;const s=HP(r);return!s||Object.keys(s).length===0?null:{schema:r,properties:s}}function HP(e){const t=_y(e);if(uu(t))return uu(t.properties)?t.properties:void 0}function B3e(e){if(!Ftn(e,"array"))return;const t=_y(e.items);return uu(t)?t:void 0}function q3e(e){return Array.isArray(e.required)?new Set(e.required.filter(t=>typeof t=="string")):new Set}function FK(e){const t=_y(e);if(uu(t))return typeof t.description=="string"&&t.description.trim()?t.description.trim():void 0}function Lg(e){const t=_y(e);if(t===!0)return"any";if(t===!1)return"never";if(!uu(t))return"unknown";if("const"in t)return U3e(t.const);if(Array.isArray(t.enum))return $tn(t.enum);const n=fbe(t.anyOf)??fbe(t.oneOf);if(n)return n;if(Array.isArray(t.allOf)&&t.allOf.length>0)return t.allOf.map(Lg).join(" & ");const r=Ltn(t);if(r==="array"){const s=_y(t.items);return`${Lg(s)}[]`}if(r==="object"){const s=t.additionalProperties;return uu(s)||typeof s=="boolean"?`record<string, ${Lg(s)}>`:"object"}if(r){const s=typeof t.format=="string"?t.format:void 0;return s?`${r} · ${s}`:r}return uu(t.properties)?"object":uu(t.items)?`${Lg(t.items)}[]`:"unknown"}function fbe(e){if(!Array.isArray(e)||e.length===0)return;const t=e.map(Lg),n=Array.from(new Set(t));return n.length===1?n[0]:n.join(" | ")}function $tn(e){return e.length===0?"enum":e.length>4?`enum (${e.length})`:e.map(U3e).join(" | ")}function U3e(e){return typeof e=="string"?`"${e}"`:e===null?"null":typeof e=="number"||typeof e=="boolean"?String(e):"literal"}function Ltn(e){if(typeof e.type=="string")return e.type;if(Array.isArray(e.type)){const t=e.type.filter(n=>typeof n=="string");if(t.length>0)return t.join(" | ")}}function Ftn(e,t){return e.type===t?!0:Array.isArray(e.type)&&e.type.includes(t)}function _y(e){if(!uu(e))return e;const t=Array.isArray(e.anyOf)?e.anyOf:void 0,n=Array.isArray(e.oneOf)?e.oneOf:void 0,r=t??n;if(!r)return e;const s=r.find(o=>uu(o)&&uu(o.properties));return s||e}function uu(e){return typeof e=="object"&&e!==null}var Btn=/[\u1680\u2000-\u200A\u202F\u205F\u3000]/,qtn=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,Utn=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/,Pz={Space_Separator:Btn,ID_Start:qtn,ID_Continue:Utn},ga={isSpaceSeparator(e){return typeof e=="string"&&Pz.Space_Separator.test(e)},isIdStartChar(e){return typeof e=="string"&&(e>="a"&&e<="z"||e>="A"&&e<="Z"||e==="$"||e==="_"||Pz.ID_Start.test(e))},isIdContinueChar(e){return typeof e=="string"&&(e>="a"&&e<="z"||e>="A"&&e<="Z"||e>="0"&&e<="9"||e==="$"||e==="_"||e==="‌"||e==="‍"||Pz.ID_Continue.test(e))},isDigit(e){return typeof e=="string"&&/[0-9]/.test(e)},isHexDigit(e){return typeof e=="string"&&/[0-9A-Fa-f]/.test(e)}};let BK,Kl,Sh,VP,Ty,qd,xi,jee,Ck;var ztn=function(t,n){BK=String(t),Kl="start",Sh=[],VP=0,Ty=1,qd=0,xi=void 0,jee=void 0,Ck=void 0;do xi=Htn(),Wtn[Kl]();while(xi.type!=="eof");return typeof n=="function"?qK({"":Ck},"",n):Ck};function qK(e,t,n){const r=e[t];if(r!=null&&typeof r=="object")if(Array.isArray(r))for(let s=0;s<r.length;s++){const o=String(s),a=qK(r,o,n);a===void 0?delete r[o]:Object.defineProperty(r,o,{value:a,writable:!0,enumerable:!0,configurable:!0})}else for(const s in r){const o=qK(r,s,n);o===void 0?delete r[s]:Object.defineProperty(r,s,{value:o,writable:!0,enumerable:!0,configurable:!0})}return n.call(e,t,r)}let mr,sr,kA,ph,Wr;function Htn(){for(mr="default",sr="",kA=!1,ph=1;;){Wr=Ph();const e=z3e[mr]();if(e)return e}}function Ph(){if(BK[VP])return String.fromCodePoint(BK.codePointAt(VP))}function Tt(){const e=Ph();return e===`
1140
1140
  `?(Ty++,qd=0):e?qd+=e.length:qd++,e&&(VP+=e.length),e}const z3e={default(){switch(Wr){case" ":case"\v":case"\f":case" ":case" ":case"\uFEFF":case`
1141
1141
  `:case"\r":case"\u2028":case"\u2029":Tt();return;case"/":Tt(),mr="comment";return;case void 0:return Tt(),go("eof")}if(ga.isSpaceSeparator(Wr)){Tt();return}return z3e[Kl]()},comment(){switch(Wr){case"*":Tt(),mr="multiLineComment";return;case"/":Tt(),mr="singleLineComment";return}throw bo(Tt())},multiLineComment(){switch(Wr){case"*":Tt(),mr="multiLineCommentAsterisk";return;case void 0:throw bo(Tt())}Tt()},multiLineCommentAsterisk(){switch(Wr){case"*":Tt();return;case"/":Tt(),mr="default";return;case void 0:throw bo(Tt())}Tt(),mr="multiLineComment"},singleLineComment(){switch(Wr){case`
@@ -1613,7 +1613,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1613
1613
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
1614
1614
 
1615
1615
  For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return b.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},n3n="DialogDescriptionWarning",r3n=({contentRef:e,descriptionId:t})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${AGe(n3n).contentName}}.`;return b.useEffect(()=>{var r;const s=(r=e.current)==null?void 0:r.getAttribute("aria-describedby");t&&s&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},s3n=hGe,o3n=gGe,a3n=bGe,i3n=xGe,l3n=wGe,c3n=_Ge;function vN({open:e,onOpenChange:t,children:n}){const{modal:r}=vr;return u.jsxs(s3n,{open:e,modal:!1,onOpenChange:t,children:[e&&u.jsx("div",{...r?.overlay}),n]})}function u3n({title:e,description:t,onConfirm:n,onCancel:r,confirmButtonText:s,cancelButtonText:o,children:a}){const{modal:i}=vr;return u.jsx(u.Fragment,{children:u.jsxs(a3n,{...i.dialog.container,children:[u.jsx(i3n,{...i.dialog.title,children:e}),u.jsx(l3n,{...i.dialog.description,children:t}),u.jsx("div",{...i.dialog.content.container,children:a}),u.jsxs("div",{...i.dialog.button.container,children:[s&&u.jsx("button",{...i.dialog.button.confirm,type:"button",onClick:n,children:s}),o&&u.jsx("button",{...i.dialog.button.cancel,type:"button",onClick:r,children:o})]})]})})}vN.Button=o3n;vN.Close=c3n;vN.Content=u3n;const d3n=b.forwardRef(({children:e,onClick:t,avatarUrl:n,botName:r,description:s,onClose:o,...a},i)=>{const{messagePreview:c}=vr,{container:l,closeButton:d,message:f,avatar:p,description:h}=c??{};return u.jsxs("div",{...a,...l,ref:i,onClick:t,children:[u.jsx(xw,{src:n,...p,children:r||"Bot"}),u.jsx("p",{...f,children:e}),u.jsx("p",{...h,children:s}),u.jsx(JHe,{...d,onClick:g=>{g.stopPropagation(),o?.()}})]})});d3n.displayName="MessagePreview";const f3n=[500,1e3,5e3,1e4],vY=1e3;function BA(e){return!e&&e!==0?"-":e<1?`${(e*1e3).toFixed(1)}μs`:e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(2)}s`}function p3n(e){return new Date(e).toLocaleTimeString()+`.${(e%1e3).toFixed(0).padStart(3,"0")}`}function sy(e){return{concise:"high",standard:"medium",verbose:"low"}[e.tier]??"low"}const xH=[.001,.002,.005,.01,.02,.05,.1,.2,.5,1,2,5,10,20,50,100,200,500,1e3,2e3,5e3,1e4,15e3,3e4,6e4,12e4,3e5,6e5,18e5,36e5,72e5,144e5,216e5,432e5,864e5];function h3n(e,t){const n=e/t;for(const r of xH)if(r>=n)return r;return xH[xH.length-1]}function m3n(e){if(e===0)return"0";if(e<1)return`${(e*1e3).toFixed(0)}μs`;if(e<1e3)return`${Math.round(e)}ms`;const t=e/1e3;if(t<60)return`${t%1===0?t.toFixed(0):t.toFixed(1)}s`;const n=t/60;return n<60?`${n%1===0?n.toFixed(0):n.toFixed(1)}m`:`${(n/60).toFixed(1)}h`}function g3n(e,t=8){const n=e.maxTime-e.minTime;if(n<=0)return[];const r=h3n(n,t),s=[],o=1.5;for(let a=0;a<=n;a+=r){const i=e.minTime+a,{leftPercent:c}=kGe(i,i,e);s.length>0&&c-s[s.length-1].percent<o||s.push({label:m3n(a),percent:c})}return s}const y3n=1.5,b3n=(100-y3n)/100;function hE(e){return e*b3n}function R$(e){const t=e.span,n=t.status!=="running",r=t.name;return!!(r==="request.incoming"&&n&&e.children.length>0||r==="handler.workflow"&&n&&e.children.length>0||r==="handler.workflow.step"&&n&&e.children.length>0||r==="cognitive.request"&&e.children.length>0||r==="handler.action"&&e.children.length>0)}function qne(e){return e.span.tier==="concise"?!0:e.children.some(qne)}function kGe(e,t,n){if(!n.segments){const f=n.maxTime-n.minTime;if(f<=0)return{leftPercent:0,widthPercent:100};const p=Math.max(0,Math.min(1,(e-n.minTime)/f)),h=Math.max(0,Math.min(1,(t-n.minTime)/f)),g=p*100,y=h*100;return{leftPercent:hE(g),widthPercent:hE(Math.max(0,y-g))}}const r=n.segments,s=1;let o=0,a=0;for(const f of r)f.isGap?a++:o+=f.end-f.start;if(o<=0)return{leftPercent:0,widthPercent:100};const i=100-a*s,c=f=>{let p=0;for(const h of r)if(h.isGap){if(f<=h.start)return p;if(f<h.end){const g=(f-h.start)/(h.end-h.start);return p+g*s}p+=s}else{const g=h.end-h.start,y=g/o*i;if(f<=h.start)return p;if(f<=h.end){const E=g>0?(f-h.start)/g:0;return p+E*y}p+=y}return p},l=c(e),d=c(t);return{leftPercent:hE(Math.max(0,Math.min(100,l))),widthPercent:hE(Math.max(0,d-l))}}const v3n=6e4;function x3n(e){if(e.length===0)return{minTime:0,maxTime:0};const t=1e4,n=1e4,r=E=>E.span.status==="running"?!0:E.children.some(x=>r(x)),s=E=>{const x=E.span.timing.startedAt||0;if(r(E))return Date.now();const w=E.span.timing.endedAt||x+(E.span.timing.duration||0),S=E.children.map(T=>s(T));return Math.max(w,...S)},o=[];e.forEach(E=>{const x=E.span.timing.startedAt||0,w=s(E);o.push({start:x,end:w})});const a=o.filter((E,x)=>!Une(e[x])),i=a.length>0?a:o;i.sort((E,x)=>E.start-x.start);let c=i[0].start,l=Math.max(...i.map(E=>E.end)),d=l-c;if(d<t)l=c+t,d=t;else{const x=Math.ceil(d/n)*n;x>d&&(l=c+x)}if(i.length===1)return{minTime:c,maxTime:l};const f=[],p=5e3;let h=0;for(let E=0;E<i.length;E++){const x=i[E];if(f.push({start:x.start,end:x.end}),E<i.length-1){const w=i[E+1].start-x.end;w>p&&(f.push({start:x.end,end:i[E+1].start,isGap:!0}),h+=w)}}const g=l-c,y=h>g*.5;return{minTime:c,maxTime:l,segments:y?f:void 0}}function Une(e){if(!oy(e)||e.children.length>0&&e.children.some(s=>oy(s)))return!1;const t=e.span.timing.startedAt||0;if(t===0)return!1;const n=Date.now()-t,r=e.span.name;return r==="request.incoming"||r==="handler.workflow"?!1:n>v3n}function oy(e){return e.span.status==="running"?!0:e.children.some(t=>oy(t))}function CGe(e){if(e.length===0)return[];const t=[];let n=[],r=[],s=null;const o=()=>{r.length>5&&s?t.push({type:"group",name:s,children:r,groupId:`${r[0].span.id.span}-group`}):t.push(...r),r=[],s=null},a=()=>{n.length>2?t.push({type:"group",name:"handler.workflow.step",displayLabel:`${n.length} items done`,children:n,groupId:`${n[0].span.id.span}-map-done`}):t.push(...n),n=[]};for(const i of e){const c=i.span.name??null,l=i.span.data||{},d=oy(i);if((l["workflow.step.type"]==="map-item"||i.span.name==="handler.workflow.step"&&l["workflow.step"]&&/-i\d+$/.test(String(l["workflow.step"])))&&!d){o(),n.push(i);continue}n.length>0&&a(),d||c!==s?(o(),d?t.push(i):(r=[i],s=c)):r.push(i)}return n.length>0&&a(),o(),t}function E3n(e,t,n){const r=[],s=o=>{r.push(o);const i=sy(o.span)==="high",c=R$(o);if((i&&!c?!t.has(`collapsed-${o.span.id.span}`):t.has(o.span.id.span))&&o.children.length>0){const f=CGe(o.children);for(const p of f)"type"in p&&p.type==="group"?n?.has(p.groupId)&&p.children.forEach(s):s(p)}};return e.forEach(s),r}function w3n(e,t,n){const r=new Set(n),s=(a,i,c=[])=>{for(const l of a){if(l.span.id.span===i)return c;const d=s(l.children,i,[...c,l.span.id.span]);if(d)return d}return null},o=s(t,e);if(o)for(const a of o){const i=xN(t,a);if(i){const l=sy(i.span)==="high",d=R$(i);l&&!d?r.delete(`collapsed-${a}`):r.add(a)}}return r}function xN(e,t){for(const n of e){if(n.span.id.span===t)return n;const r=xN(n.children,t);if(r)return r}return null}function Mf(e,t){const n=t.current;if(!n)return;const r=document.querySelector(`[data-span-id="${e}"]`);if(!r)return;const s=n.getBoundingClientRect(),o=r.getBoundingClientRect(),a=o.top<s.top,i=o.bottom>s.bottom;if(a||i){const c=o.top-s.top+n.scrollTop;let l;a?l=c-8:l=c-s.height+o.height+8,l=Math.max(0,Math.min(l,n.scrollHeight-s.height)),n.scrollTop=l}}function yo(e,t){return e.data?.[t]}function Ml(e,t){const n=yo(e,t);return typeof n=="string"?n:void 0}function Af(e,t){const n=yo(e,t);if(typeof n=="number")return n;if(typeof n=="string"){const r=Number(n);return Number.isFinite(r)?r:void 0}}const Pl=e=>e.status==="error",S3n={pending:"Running",generation_error:"Generation Error",execution_error:"Execution Error",invalid_code_error:"Invalid Code",thinking_requested:"Thinking",callback_requested:"Callback",exit_success:"Success",exit_error:"Error",aborted:"Aborted"},Kn={error:"text-red-700 dark:text-red-500 bg-red-500/15 dark:bg-red-500/10",warning:"text-yellow-700 dark:text-yellow-500 bg-yellow-500/15 dark:bg-yellow-500/10",success:"text-green-700 dark:text-green-500 bg-green-500/15 dark:bg-green-500/10",pending:"text-gray-600 dark:text-gray-500 bg-gray-500/15 dark:bg-gray-500/10",handler:"text-purple-700 dark:text-purple-500 bg-purple-500/15 dark:bg-purple-500/10",workflow:"text-purple-700 dark:text-purple-500 bg-purple-500/15 dark:bg-purple-500/10",action:"text-indigo-700 dark:text-indigo-500 bg-indigo-500/15 dark:bg-indigo-500/10",tool:"text-pink-700 dark:text-pink-500 bg-pink-500/15 dark:bg-pink-500/10",listen:"text-blue-700 dark:text-blue-500 bg-blue-500/15 dark:bg-blue-500/10",message:"text-pink-700 dark:text-pink-500 bg-pink-500/15 dark:bg-pink-500/10",llmz:"text-blue-700 dark:text-blue-500 bg-blue-500/15 dark:bg-blue-500/10",cognitive:"text-emerald-700 dark:text-emerald-500 bg-emerald-500/15 dark:bg-emerald-500/10",state:"text-neutral-600 dark:text-neutral-500 bg-neutral-400/15 dark:bg-neutral-400/10",client:"text-cyan-700 dark:text-cyan-500 bg-cyan-500/15 dark:bg-cyan-500/10",transcript:"text-neutral-600 dark:text-neutral-500 bg-neutral-500/15 dark:bg-neutral-500/10"},EH=[{matcher:e=>e.name==="request.incoming",icon:_kt,getLabel:e=>{const t=yo(e,"request.operation"),n=yo(e,"request.type"),r=yo(e,"request.method");return t==="event_received"&&n?`${n}`:t==="action_triggered"?"Action Triggered":t==="register"?"Bot Registration":t==="ping"?"Ping":`${r||"POST"} Request`},getColor:e=>Pl(e)?Kn.error:"text-blue-600 bg-blue-600/10"},{matcher:e=>e.name==="cognitive.request",icon:NJ,getLabel:e=>{const t=yo(e,"ai.model")||"AI",n=yo(e,"ai.provider"),r=yo(e,"ai.temperature");let s="LLM Call";return n?s+=` ${n}/${t}`:s+=` ${t}`,r!==void 0&&(s+=` temperature=${r}`),s},getColor:e=>Pl(e)?Kn.error:yo(e,"ai.cached")?Kn.success:Kn.cognitive},{matcher:e=>e.name==="botpress.client",icon:_W,getLabel:e=>{const t=Ml(e,"botpress.method")||"HTTP",n=Ml(e,"botpress.url")||"",r=Af(e,"botpress.status_code");if(n.startsWith("/v1/chat/conversations"))return n.includes("/messages")?`${t} Message${r?` (${r})`:""}`:n.includes("/participants")?`${t} Participants${r?` (${r})`:""}`:n.includes("/events")?`${t} Event${r?` (${r})`:""}`:`${t} Conversation${r?` (${r})`:""}`;if(n.startsWith("/v1/chat/messages"))return`${t} Message${r?` (${r})`:""}`;if(n.startsWith("/v1/chat/users"))return`${t} User${r?` (${r})`:""}`;if(n.startsWith("/v1/chat/events"))return`${t} Event${r?` (${r})`:""}`;if(n.startsWith("/v1/chat/states"))return`${t} State${r?` (${r})`:""}`;if(n.startsWith("/v1/chat/workflows"))return`${t} Workflow${r?` (${r})`:""}`;if(n.startsWith("/v1/chat/actions"))return`Call ${Ml(e,"action.name")||"Action"}${r?` (${r})`:""}`;if(n.startsWith("/v1/tables")){const o=n.match(/\/tables\/([^/]+)/)?.[1];return o?`${t} Table:${o}${r?` (${r})`:""}`:`${t} Tables${r?` (${r})`:""}`}let s=n;return s.length>30&&(s="..."+s.slice(-27)),`${t} ${s}${r?` (${r})`:""}`},getColor:e=>{const t=Af(e,"botpress.status_code")??0;return t>=500?Kn.error:t>=400?Kn.warning:Pl(e)?Kn.error:Kn.client}},{matcher:e=>e.name==="http.client",icon:Zf,getLabel:e=>{const t=Ml(e,"http.method")||"GET",n=Ml(e,"http.url"),r=Af(e,"http.status_code");let s=`${t}`;if(n)try{const o=new URL(n);s+=` ${o.pathname}`}catch{s+=` ${n.substring(0,50)}`}return r&&(s+=` (${r})`),s},getColor:e=>{const t=Af(e,"http.status_code")??0;return t>=500?Kn.error:t>=400?Kn.warning:Pl(e)?Kn.error:Kn.client}},{matcher:e=>e.name==="handler.conversation",icon:eIt,getLabel:e=>{const t=e.context.integration,n=e.context.channel;let r="Conversation";return t&&(r+=` [${t}`),n&&(r+=`/${n}`),t&&(r+="]"),r},getColor:e=>Pl(e)?Kn.error:Kn.handler},{matcher:e=>e.name==="handler.trigger",icon:Sa,getLabel:e=>{const t=yo(e,"trigger.name"),n=yo(e,"event.type");return t&&n?`Trigger: ${t} (${n})`:t?`Trigger: ${t}`:n?`Trigger: ${n}`:"Trigger"},getColor:e=>Pl(e)?Kn.error:Kn.handler},{matcher:e=>e.name==="handler.workflow",icon:Mh,getLabel:e=>{const t=Ml(e,"workflow.name"),n=Ml(e,"workflow.status.final");return t?n==="continue"?`${t} → Continue`:n==="completed"?`${t} → Completed`:n==="failed"?`${t} → Failed`:t:"Workflow"},getColor:e=>Pl(e)?Kn.error:Kn.workflow},{matcher:e=>e.name==="handler.workflow.step",icon:hNt,getLabel:(e,t)=>{const n=Ml(e,"workflow.step"),r=Ml(e,"workflow.step.type"),s=Af(e,"workflow.step.attempt"),o=Af(e,"workflow.step.max_attempts");if(!n)return"Step";let a=n;const i=r==="map"||t&&t.children.length>1&&t.children.some(c=>{const l=Ml(c.span,"workflow.step");return l!==void 0&&l.startsWith(`${n}-i`)});if(r==="listen")a=`Listen: ${n}`;else if(r==="sleep")a=`Sleep: ${n}`;else if(r==="progress")a=`Progress: ${n}`;else if(r==="notify")a=`Notify: ${n}`;else if(r==="fail")a=`Fail: ${n}`;else if(i){const c=Af(e,"workflow.map.total")??t?.children.length,l=Af(e,"workflow.map.concurrency");let d=0;if(t?.children)for(const f of t.children)f.span.status==="ok"&&d++;if(a=n,c!==void 0&&c>0){const f=Math.round(d/c*100);a+=` (${d}/${c} — ${f}%)`,l!==void 0&&l>1&&(a+=` [×${l}]`)}}else if(r==="map-item"){const c=Af(e,"workflow.map.item_index");c!==void 0&&(a=`Item ${c}`)}if(s!==void 0&&s>0){const c=o!==void 0?` (attempt ${s+1}/${o})`:` (attempt ${s+1})`;a+=c}return a},getColor:e=>{const t=yo(e,"workflow.step.type");return Pl(e)||t==="fail"?Kn.error:t==="listen"?Kn.listen:t==="notify"?Kn.message:t==="progress"||e.status==="ok"?Kn.success:Kn.workflow}},{matcher:e=>e.name==="handler.action",icon:Sa,getLabel:e=>Ml(e,"action.name")||"Action",getColor:e=>Pl(e)?Kn.error:Kn.action},{matcher:e=>e.name==="autonomous.execution",icon:Kkt,getLabel:e=>yo(e,"autonomous.mode")==="chat"?"LLMz [Chat]":"LLMz [Worker]",getColor:e=>Pl(e)?Kn.error:Kn.llmz},{matcher:e=>e.name==="autonomous.iteration",icon:_De,getLabel:e=>{const t=Af(e,"autonomous.iteration"),n=Ml(e,"autonomous.exit.name"),r=Ml(e,"autonomous.status"),s=t!==void 0?t+1:1;let o="";return n?o=n.charAt(0).toUpperCase()+n.slice(1):r&&(o=S3n[r]||r),o?`Loop ${s}: ${o}`:`Loop ${s}`},getColor:e=>{const t=yo(e,"autonomous.status");return t==="generation_error"||t==="execution_error"||t==="invalid_code_error"||t==="exit_error"?Kn.error:t==="aborted"?Kn.warning:Kn.llmz}},{matcher:e=>e.name==="autonomous.tool",icon:rS,getLabel:e=>{const t=Ml(e,"autonomous.tool.name"),n=Ml(e,"autonomous.tool.status");return t?n==="think"?`${t} [thinking]`:t:"Tool"},getColor:e=>{const t=yo(e,"autonomous.tool.status");return t==="error"?Kn.error:t==="success"?Kn.success:Kn.tool}},{matcher:e=>e.name==="interruption.check",icon:EDe,getLabel:e=>{const t=yo(e,"interruption.detected"),n=yo(e,"interruption.events_count");return t&&n?`Interruption Detected (${n} events)`:"Check Interruptions"},getColor:e=>yo(e,"interruption.detected")?Kn.warning:"text-neutral-500 bg-neutral-500/10"},{matcher:e=>e.name==="state.load"||e.name==="state.loadAll",icon:_Nt,getLabel:e=>{const t=e.name||"",n=yo(e,"type"),r=yo(e,"name");if(t==="state.loadAll")return"Load All States";if(t==="state.load"){let s="Load State";return n&&(s+=` [${n}`),r&&(s+=`/${r}`),n&&(s+="]"),s}return t==="TrackedState.loadAll"?"Load All States":t==="TrackedState.load"?"Load State":t.replace("TrackedState.","").replace("state.","")},getColor:e=>Pl(e)?Kn.error:Kn.state},{matcher:e=>e.name==="state.save"||e.name==="state.saveAllDirty",icon:ANt,getLabel:e=>{const t=e.name||"",n=yo(e,"type"),r=yo(e,"name"),s=yo(e,"swapped_to_file");if(t==="state.save"){let o="Save State";n&&(o+=` [${n}`),r&&(o+=`/${r}`),n&&(o+="]"),s&&(o+=" → File");const a=yo(e,"state.changed_keys");return Array.isArray(a)&&a.length>0&&(o+=`, ${a.length} key${a.length>1?"s":""} changed`),o}if(t==="state.saveAllDirty"){const o=yo(e,"states_count");return o?`Save ${o} Dirty States`:"Save Dirty States"}return t==="TrackedState.save"?"Save State":t==="TrackedState.saveAllDirty"?"Save Dirty States":t.replace("TrackedState.","").replace("state.","")},getColor:e=>Pl(e)?Kn.error:Kn.state},{matcher:e=>e.name==="chat.sendMessage",icon:a5,getLabel:()=>"Send Message",getColor:e=>Pl(e)?Kn.error:Kn.message},{matcher:e=>e.name==="chat.saveTranscript"||e.name==="chat.fetchTranscript",icon:Uh,getLabel:e=>{const t=e.name||"";return t==="chat.saveTranscript"?"Save Transcript":t==="chat.fetchTranscript"?"Fetch Transcript":t.replace("chat.","")},getColor:e=>Pl(e)?Kn.error:Kn.transcript},{matcher:()=>!0,icon:tc,getLabel:e=>e.name||e.id.span.substring(0,8)+"...",getColor:e=>Pl(e)?Kn.error:Kn.pending}],ewe=new Set(["handler.conversation","handler.trigger","handler.workflow","handler.workflow.step","handler.action"]);function NGe(e){if(ewe.has(e))return"developer";for(const t of ewe)if(e.startsWith(t+"."))return"developer";return"system"}function xY(e){return EH.find(t=>t.matcher(e))||EH[EH.length-1]}function twe(e,t,n,r){if(r)return u.jsx(hy,{className:"h-3 w-3 text-yellow-500"});if(t)return u.jsx(nn,{className:`h-3 w-3 animate-spin ${n?"text-orange-500":"text-blue-500"}`});if(!e)return u.jsx(id,{className:"h-3 w-3 text-gray-400"});switch(e){case"ok":return u.jsx(Ms,{className:"h-3 w-3 text-green-500"});case"error":return u.jsx(yl,{className:"h-3 w-3 text-red-500"});case"running":return u.jsx(nn,{className:"h-3 w-3 animate-spin text-blue-500"});default:return u.jsx(hy,{className:"h-3 w-3 text-yellow-500"})}}function IGe(e){const{filters:t,timeRange:n="all",traceCount:r=vY,hideUnimportant:s=!0,hideSystemSpans:o=!1,autoRefresh:a=!0}=e,{workflowId:i,messageId:c,conversationId:l,userId:d,eventId:f,attributeName:p,attributeValue:h}=t,[g,y]=b.useState([]),{apiUrl:E}=wn(),x=bt(N=>N.selectedAgentPath),w=b.useRef(r);b.useEffect(()=>{w.current=r},[r]);const[S,T]=b.useState(Date.now());b.useEffect(()=>{if(n==="all")return;const N=setInterval(()=>T(Date.now()),3e4);return()=>clearInterval(N)},[n]);const k=b.useMemo(()=>{const N=new URLSearchParams;N.append("count",r.toString());let j=null,O=null;if(i?(j="workflowId",O=i):c?(j="messageId",O=c):l?(j="conversationId",O=l):d?(j="userId",O=d):f?(j="eventId",O=f):p&&h&&(j=p,O=h),j&&O&&(N.append("attributeName",j),N.append("attributeValue",O)),n!=="all"){const D=parseInt(n);if(!isNaN(D)){const L=Date.now()-D*60*1e3;N.append("startTs",L.toString())}}return N.toString()},[i,c,l,d,f,p,h,r,n]);b.useEffect(()=>{if(!a||typeof EventSource>"u")return;y([]);const N=E(`/api/traces/stream?${k}`),j=new EventSource(N);let O=Date.now(),D=!1;const L=()=>{D||(D=!0,y(B=>B.map(M=>{if(M.status!=="running")return M;const $=M.timing.endedAt??Date.now();return{...M,status:"error",error:"Process terminated",timing:{...M.timing,endedAt:$,duration:$-M.timing.startedAt}}})))};j.addEventListener("snapshot",B=>{try{O=Date.now(),D=!1;const P=(JSON.parse(B.data).spans||[]).sort((q,z)=>{const G=q.timing.startedAt||0;return(z.timing.startedAt||0)-G});y(P.slice(0,w.current))}catch(M){console.error("Failed to parse snapshot:",M)}}),j.addEventListener("update",B=>{try{O=Date.now(),D=!1;const $=JSON.parse(B.data).span;y(P=>{const q=[...P],z=q.findIndex(G=>G.id.span===$.id.span&&G.id.trace===$.id.trace);if(z>=0)q[z]=$;else return q.push($),q.sort((G,R)=>{const W=G.timing.startedAt||0;return(R.timing.startedAt||0)-W}),q.slice(0,w.current);return q})}catch(M){console.error("Failed to parse update:",M)}}),j.addEventListener("keepalive",()=>{O=Date.now(),D=!1});let U;return j.onerror=()=>{console.warn("[traces] SSE connection error — stale detection watchdog is active");const B=5e3;U||(U=setTimeout(()=>{U=null,Date.now()-O>B&&L()},B))},()=>{U&&clearTimeout(U),j.close()}},[a,E,k,x]);const A=b.useMemo(()=>{let N=g;if(n!=="all"){const R=parseInt(n);if(!isNaN(R)){const W=S-R*60*1e3;N=g.filter(V=>V.timing.startedAt>=W)}}const j={concise:3,standard:2,verbose:1},O=new Map,D=[],L=new Map,U=[...N].sort((R,W)=>{const V=R.timing.startedAt||0,I=W.timing.startedAt||0;return V-I}),B=new Map;for(const R of U){const W=`${R.id.trace}-${R.id.span}`;B.set(W,R)}const M=new Set;for(const R of U)if(R.id.parent){const W=`${R.id.trace}-${R.id.parent}`;M.add(W)}const $=(R,W)=>{if(o&&NGe(W.name)==="system")return!1;const V=j[W.tier]??1;if(V>=3)return!0;if(!s){if(V<2)return!1;const I=W.timing.duration??0;return!(I<5&&I>0&&!M.has(R))}return!(V<2)},P=new Set,q=new Map;for(const R of U){const W=`${R.id.trace}-${R.id.span}`;$(W,R)&&(P.add(W),q.set(W,R))}const z=R=>{let W=R.id.parent,V=R.id.trace;for(;W;){const I=`${V}-${W}`;if(P.has(I))return I;const J=B.get(I);if(!J)break;W=J.id.parent}return null};for(const[R,W]of q.entries()){const V={span:W,children:[]};if(O.set(R,V),L.has(R)){const J=L.get(R);V.children.push(...J),L.delete(R)}const I=z(W);if(!I)D.push(V);else{const J=O.get(I);J?J.children.push(V):(L.has(I)||L.set(I,[]),L.get(I).push(V))}}for(const R of L.values())D.push(...R);const G=R=>{R.children.sort((W,V)=>{const I=W.span.timing.startedAt||0,J=V.span.timing.startedAt||0;return I-J}),R.children.forEach(G)};if(D.forEach(G),D.sort((R,W)=>{const V=R.span.timing.startedAt||0,I=W.span.timing.startedAt||0;return V-I}),s){const R=W=>W.filter(V=>(j[V.span.tier]??1)>=3||qne(V)).map(V=>({...V,children:R(V.children)}));return R(D)}return D},[g,s,o,S,n]);return{traces:g,traceTree:A}}const _3n=me("[&_code]:[counter-reset:line]","[&_code]:[counter-increment:line_0]","[&_.line]:before:content-[counter(line)]","[&_.line]:before:inline-block","[&_.line]:before:[counter-increment:line]","[&_.line]:before:w-4","[&_.line]:before:mr-4","[&_.line]:before:text-[13px]","[&_.line]:before:text-right","[&_.line]:before:text-muted-foreground/50","[&_.line]:before:font-mono","[&_.line]:before:select-none"),T3n=me("dark:[&_.shiki]:text-(--shiki-dark)!","dark:[&_.shiki]:bg-(--shiki-dark-bg)!","dark:[&_.shiki]:[font-style:var(--shiki-dark-font-style)]!","dark:[&_.shiki]:font-(--shiki-dark-font-weight)!","dark:[&_.shiki]:[text-decoration:var(--shiki-dark-text-decoration)]!","dark:[&_.shiki_span]:text-(--shiki-dark)!","dark:[&_.shiki_span]:[font-style:var(--shiki-dark-font-style)]!","dark:[&_.shiki_span]:font-(--shiki-dark-font-weight)!","dark:[&_.shiki_span]:[text-decoration:var(--shiki-dark-text-decoration)]!"),A3n=me("[&_.line.highlighted]:bg-blue-50","[&_.line.highlighted]:after:bg-blue-500","[&_.line.highlighted]:after:absolute","[&_.line.highlighted]:after:left-0","[&_.line.highlighted]:after:top-0","[&_.line.highlighted]:after:bottom-0","[&_.line.highlighted]:after:w-0.5","dark:[&_.line.highlighted]:bg-blue-500/10!"),k3n=me("[&_.line.diff]:after:absolute","[&_.line.diff]:after:left-0","[&_.line.diff]:after:top-0","[&_.line.diff]:after:bottom-0","[&_.line.diff]:after:w-0.5","[&_.line.diff.add]:bg-emerald-50","[&_.line.diff.add]:after:bg-emerald-500","[&_.line.diff.remove]:bg-rose-50","[&_.line.diff.remove]:after:bg-rose-500","dark:[&_.line.diff.add]:bg-emerald-500/10!","dark:[&_.line.diff.remove]:bg-rose-500/10!"),C3n=me("[&_code:has(.focused)_.line]:blur-[2px]","[&_code:has(.focused)_.line.focused]:blur-none"),N3n=me("[&_.highlighted-word]:bg-blue-50","dark:[&_.highlighted-word]:bg-blue-500/10!"),I3n=me("mt-0 bg-background text-sm","[&_pre]:py-4","[&_.shiki]:bg-(--shiki-bg)!","[&_code]:w-full","[&_code]:grid","[&_code]:overflow-x-auto","[&_code]:bg-transparent","[&_.line]:px-4","[&_.line]:w-full","[&_.line]:relative"),zne=b.createContext({value:void 0,onValueChange:void 0,data:[]}),Hne=({value:e,onValueChange:t,defaultValue:n,className:r,data:s,...o})=>{const[a,i]=rc({defaultProp:n??"",prop:e,onChange:t});return u.jsx(zne.Provider,{value:{value:a,onValueChange:i,data:s},children:u.jsx("div",{className:me("size-full overflow-hidden rounded-md border",r),...o})})},R3n=({children:e,...t})=>u.jsx("div",{...t,children:u.jsx("pre",{className:"w-full",children:u.jsx("code",{children:e?.toString().split(`
1616
- `).map((n,r)=>u.jsx("span",{className:"line",children:n},r))})})}),Vne=({children:e,...t})=>{const{data:n}=b.useContext(zne);return u.jsx("div",{...t,children:n.map(e)})},Gne=({children:e,lineNumbers:t=!0,className:n,value:r,...s})=>{const{value:o}=b.useContext(zne);return r!==o?null:u.jsx("div",{className:me(I3n,A3n,k3n,C3n,N3n,T3n,t&&_3n,n),...s,children:e})},Wne=({children:e,themes:t={light:"vitesse-light",dark:"vitesse-dark"},language:n="typescript",syntaxHighlighting:r=!0,...s})=>{const[o,a]=b.useState(""),[i,c]=b.useState(r);return b.useEffect(()=>{if(!r){c(!1);return}(async()=>{try{const{codeToHtml:d}=await c5(async()=>{const{codeToHtml:p}=await import("./index-DNqXHLNi.js");return{codeToHtml:p}},[]),f=await d(e,{lang:n,themes:{light:t.light,dark:t.dark}});a(f),c(!1)}catch(d){console.error(`Failed to highlight code for language "${n}":`,d),c(!1)}})()},[e,n,t,r]),!r||i?u.jsx(R3n,{...s,children:e}):u.jsx("div",{dangerouslySetInnerHTML:{__html:o},...s})},sF=b.createContext(null);sF.displayName="PanelGroupContext";const la={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},Kne=10,Fb=b.useLayoutEffect,nwe=sd.useId,j3n=typeof nwe=="function"?nwe:()=>null;let D3n=0;function Zne(e=null){const t=j3n(),n=b.useRef(e||t||null);return n.current===null&&(n.current=""+D3n++),e??n.current}function RGe({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:s,forwardedRef:o,id:a,maxSize:i,minSize:c,onCollapse:l,onExpand:d,onResize:f,order:p,style:h,tagName:g="div",...y}){const E=b.useContext(sF);if(E===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:x,expandPanel:w,getPanelSize:S,getPanelStyle:T,groupId:k,isPanelCollapsed:A,reevaluatePanelConstraints:N,registerPanel:j,resizePanel:O,unregisterPanel:D}=E,L=Zne(a),U=b.useRef({callbacks:{onCollapse:l,onExpand:d,onResize:f},constraints:{collapsedSize:n,collapsible:r,defaultSize:s,maxSize:i,minSize:c},id:L,idIsFromProps:a!==void 0,order:p});b.useRef({didLogMissingDefaultSizeWarning:!1}),Fb(()=>{const{callbacks:M,constraints:$}=U.current,P={...$};U.current.id=L,U.current.idIsFromProps=a!==void 0,U.current.order=p,M.onCollapse=l,M.onExpand=d,M.onResize=f,$.collapsedSize=n,$.collapsible=r,$.defaultSize=s,$.maxSize=i,$.minSize=c,(P.collapsedSize!==$.collapsedSize||P.collapsible!==$.collapsible||P.maxSize!==$.maxSize||P.minSize!==$.minSize)&&N(U.current,P)}),Fb(()=>{const M=U.current;return j(M),()=>{D(M)}},[p,L,j,D]),b.useImperativeHandle(o,()=>({collapse:()=>{x(U.current)},expand:M=>{w(U.current,M)},getId(){return L},getSize(){return S(U.current)},isCollapsed(){return A(U.current)},isExpanded(){return!A(U.current)},resize:M=>{O(U.current,M)}}),[x,w,S,A,L,O]);const B=T(U.current,s);return b.createElement(g,{...y,children:e,className:t,id:L,style:{...B,...h},[la.groupId]:k,[la.panel]:"",[la.panelCollapsible]:r||void 0,[la.panelId]:L,[la.panelSize]:parseFloat(""+B.flexGrow).toFixed(1)})}const jGe=b.forwardRef((e,t)=>b.createElement(RGe,{...e,forwardedRef:t}));RGe.displayName="Panel";jGe.displayName="forwardRef(Panel)";let EY=null,rM=-1,Dg=null;function O3n(e,t,n){const r=(t&$Ge)!==0,s=(t&LGe)!==0,o=(t&FGe)!==0,a=(t&BGe)!==0;if(t){if(r)return o?"se-resize":a?"ne-resize":"e-resize";if(s)return o?"sw-resize":a?"nw-resize":"w-resize";if(o)return"s-resize";if(a)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function M3n(){Dg!==null&&(document.head.removeChild(Dg),EY=null,Dg=null,rM=-1)}function wH(e,t,n){var r,s;const o=O3n(e,t);if(EY!==o){if(EY=o,Dg===null&&(Dg=document.createElement("style"),document.head.appendChild(Dg)),rM>=0){var a;(a=Dg.sheet)===null||a===void 0||a.removeRule(rM)}rM=(r=(s=Dg.sheet)===null||s===void 0?void 0:s.insertRule(`*{cursor: ${o} !important;}`))!==null&&r!==void 0?r:-1}}function DGe(e){return e.type==="keydown"}function OGe(e){return e.type.startsWith("pointer")}function MGe(e){return e.type.startsWith("mouse")}function oF(e){if(OGe(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(MGe(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function P3n(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function $3n(e,t,n){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function L3n(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:owe(e),b:owe(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;br(r,"Stacking order can only be calculated for elements with a common ancestor");const s={a:swe(rwe(n.a)),b:swe(rwe(n.b))};if(s.a===s.b){const o=r.childNodes,a={a:n.a.at(-1),b:n.b.at(-1)};let i=o.length;for(;i--;){const c=o[i];if(c===a.a)return 1;if(c===a.b)return-1}}return Math.sign(s.a-s.b)}const F3n=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function B3n(e){var t;const n=getComputedStyle((t=PGe(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function q3n(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||B3n(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||F3n.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function rwe(e){let t=e.length;for(;t--;){const n=e[t];if(br(n,"Missing node"),q3n(n))return n}return null}function swe(e){return e&&Number(getComputedStyle(e).zIndex)||0}function owe(e){const t=[];for(;e;)t.push(e),e=PGe(e);return t}function PGe(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const $Ge=1,LGe=2,FGe=4,BGe=8,U3n=P3n()==="coarse";let Vd=[],PE=!1,Og=new Map,aF=new Map;const EN=new Set;function z3n(e,t,n,r,s){var o;const{ownerDocument:a}=t,i={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:s},c=(o=Og.get(a))!==null&&o!==void 0?o:0;return Og.set(a,c+1),EN.add(i),j$(),function(){var d;aF.delete(e),EN.delete(i);const f=(d=Og.get(a))!==null&&d!==void 0?d:1;if(Og.set(a,f-1),j$(),f===1&&Og.delete(a),Vd.includes(i)){const p=Vd.indexOf(i);p>=0&&Vd.splice(p,1),iF(),s("up",!0,null)}}}function H3n(e){const{target:t}=e,{x:n,y:r}=oF(e);PE=!0,Yne({target:t,x:n,y:r}),j$(),Vd.length>0&&(D$("down",e),iF(),e.preventDefault(),qGe(t)||e.stopImmediatePropagation())}function SH(e){const{x:t,y:n}=oF(e);if(PE&&e.type!=="pointerleave"&&e.buttons===0&&(PE=!1,D$("up",e)),!PE){const{target:r}=e;Yne({target:r,x:t,y:n})}D$("move",e),iF(),Vd.length>0&&e.preventDefault()}function _H(e){const{target:t}=e,{x:n,y:r}=oF(e);aF.clear(),PE=!1,Vd.length>0&&(e.preventDefault(),qGe(t)||e.stopImmediatePropagation()),D$("up",e),Yne({target:t,x:n,y:r}),iF(),j$()}function qGe(e){let t=e;for(;t;){if(t.hasAttribute(la.resizeHandle))return!0;t=t.parentElement}return!1}function Yne({target:e,x:t,y:n}){Vd.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),EN.forEach(s=>{const{element:o,hitAreaMargins:a}=s,i=o.getBoundingClientRect(),{bottom:c,left:l,right:d,top:f}=i,p=U3n?a.coarse:a.fine;if(t>=l-p&&t<=d+p&&n>=f-p&&n<=c+p){if(r!==null&&document.contains(r)&&o!==r&&!o.contains(r)&&!r.contains(o)&&L3n(r,o)>0){let g=r,y=!1;for(;g&&!g.contains(o);){if($3n(g.getBoundingClientRect(),i)){y=!0;break}g=g.parentElement}if(y)return}Vd.push(s)}})}function TH(e,t){aF.set(e,t)}function iF(){let e=!1,t=!1;Vd.forEach(r=>{const{direction:s}=r;s==="horizontal"?e=!0:t=!0});let n=0;aF.forEach(r=>{n|=r}),e&&t?wH("intersection",n):e?wH("horizontal",n):t?wH("vertical",n):M3n()}let AH;function j$(){var e;(e=AH)===null||e===void 0||e.abort(),AH=new AbortController;const t={capture:!0,signal:AH.signal};EN.size&&(PE?(Vd.length>0&&Og.forEach((n,r)=>{const{body:s}=r;n>0&&(s.addEventListener("contextmenu",_H,t),s.addEventListener("pointerleave",SH,t),s.addEventListener("pointermove",SH,t))}),Og.forEach((n,r)=>{const{body:s}=r;s.addEventListener("pointerup",_H,t),s.addEventListener("pointercancel",_H,t)})):Og.forEach((n,r)=>{const{body:s}=r;n>0&&(s.addEventListener("pointerdown",H3n,t),s.addEventListener("pointermove",SH,t))}))}function D$(e,t){EN.forEach(n=>{const{setResizeHandlerState:r}=n,s=Vd.includes(n);r(e,s,t)})}function V3n(){const[e,t]=b.useState(0);return b.useCallback(()=>t(n=>n+1),[])}function br(e,t){if(!e)throw console.error(t),Error(t)}function hv(e,t,n=Kne){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function Th(e,t,n=Kne){return hv(e,t,n)===0}function ru(e,t,n){return hv(e,t,n)===0}function G3n(e,t,n){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){const s=e[r],o=t[r];if(!ru(s,o,n))return!1}return!0}function mE({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];br(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:s=0,collapsible:o,maxSize:a=100,minSize:i=0}=r;if(hv(n,i)<0)if(o){const c=(s+i)/2;hv(n,c)<0?n=s:n=i}else n=i;return n=Math.min(a,n),n=parseFloat(n.toFixed(Kne)),n}function qA({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:s,trigger:o}){if(ru(e,0))return t;const a=[...t],[i,c]=r;br(i!=null,"Invalid first pivot index"),br(c!=null,"Invalid second pivot index");let l=0;if(o==="keyboard"){{const f=e<0?c:i,p=n[f];br(p,`Panel constraints not found for index ${f}`);const{collapsedSize:h=0,collapsible:g,minSize:y=0}=p;if(g){const E=t[f];if(br(E!=null,`Previous layout not found for panel index ${f}`),ru(E,h)){const x=y-E;hv(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}{const f=e<0?i:c,p=n[f];br(p,`No panel constraints found for index ${f}`);const{collapsedSize:h=0,collapsible:g,minSize:y=0}=p;if(g){const E=t[f];if(br(E!=null,`Previous layout not found for panel index ${f}`),ru(E,y)){const x=E-h;hv(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}}{const f=e<0?1:-1;let p=e<0?c:i,h=0;for(;;){const y=t[p];br(y!=null,`Previous layout not found for panel index ${p}`);const x=mE({panelConstraints:n,panelIndex:p,size:100})-y;if(h+=x,p+=f,p<0||p>=n.length)break}const g=Math.min(Math.abs(e),Math.abs(h));e=e<0?0-g:g}{let p=e<0?i:c;for(;p>=0&&p<n.length;){const h=Math.abs(e)-Math.abs(l),g=t[p];br(g!=null,`Previous layout not found for panel index ${p}`);const y=g-h,E=mE({panelConstraints:n,panelIndex:p,size:y});if(!ru(g,E)&&(l+=g-E,a[p]=E,l.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?p--:p++}}if(G3n(s,a))return s;{const f=e<0?c:i,p=t[f];br(p!=null,`Previous layout not found for panel index ${f}`);const h=p+l,g=mE({panelConstraints:n,panelIndex:f,size:h});if(a[f]=g,!ru(g,h)){let y=h-g,x=e<0?c:i;for(;x>=0&&x<n.length;){const w=a[x];br(w!=null,`Previous layout not found for panel index ${x}`);const S=w+y,T=mE({panelConstraints:n,panelIndex:x,size:S});if(ru(w,T)||(y-=T-w,a[x]=T),ru(y,0))break;e>0?x--:x++}}}const d=a.reduce((f,p)=>p+f,0);return ru(d,100)?a:s}function W3n({layout:e,panelsArray:t,pivotIndices:n}){let r=0,s=100,o=0,a=0;const i=n[0];br(i!=null,"No pivot index found"),t.forEach((f,p)=>{const{constraints:h}=f,{maxSize:g=100,minSize:y=0}=h;p===i?(r=y,s=g):(o+=y,a+=g)});const c=Math.min(s,100-o),l=Math.max(r,100-a),d=e[i];return{valueMax:c,valueMin:l,valueNow:d}}function wN(e,t=document){return Array.from(t.querySelectorAll(`[${la.resizeHandleId}][data-panel-group-id="${e}"]`))}function UGe(e,t,n=document){const s=wN(e,n).findIndex(o=>o.getAttribute(la.resizeHandleId)===t);return s??null}function zGe(e,t,n){const r=UGe(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function K3n(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function HGe(e,t=document){if(K3n(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function lF(e,t=document){const n=t.querySelector(`[${la.resizeHandleId}="${e}"]`);return n||null}function Z3n(e,t,n,r=document){var s,o,a,i;const c=lF(t,r),l=wN(e,r),d=c?l.indexOf(c):-1,f=(s=(o=n[d])===null||o===void 0?void 0:o.id)!==null&&s!==void 0?s:null,p=(a=(i=n[d+1])===null||i===void 0?void 0:i.id)!==null&&a!==void 0?a:null;return[f,p]}function Y3n({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:s,panelGroupElement:o,setLayout:a}){b.useRef({didWarnAboutMissingResizeHandle:!1}),Fb(()=>{if(!o)return;const i=wN(n,o);for(let c=0;c<s.length-1;c++){const{valueMax:l,valueMin:d,valueNow:f}=W3n({layout:r,panelsArray:s,pivotIndices:[c,c+1]}),p=i[c];if(p!=null){const h=s[c];br(h,`No panel data found for index "${c}"`),p.setAttribute("aria-controls",h.id),p.setAttribute("aria-valuemax",""+Math.round(l)),p.setAttribute("aria-valuemin",""+Math.round(d)),p.setAttribute("aria-valuenow",f!=null?""+Math.round(f):"")}}return()=>{i.forEach((c,l)=>{c.removeAttribute("aria-controls"),c.removeAttribute("aria-valuemax"),c.removeAttribute("aria-valuemin"),c.removeAttribute("aria-valuenow")})}},[n,r,s,o]),b.useEffect(()=>{if(!o)return;const i=t.current;br(i,"Eager values not found");const{panelDataArray:c}=i,l=HGe(n,o);br(l!=null,`No group found for id "${n}"`);const d=wN(n,o);br(d,`No resize handles found for group id "${n}"`);const f=d.map(p=>{const h=p.getAttribute(la.resizeHandleId);br(h,"Resize handle element has no handle id attribute");const[g,y]=Z3n(n,h,c,o);if(g==null||y==null)return()=>{};const E=x=>{if(!x.defaultPrevented)switch(x.key){case"Enter":{x.preventDefault();const w=c.findIndex(S=>S.id===g);if(w>=0){const S=c[w];br(S,`No panel data found for index ${w}`);const T=r[w],{collapsedSize:k=0,collapsible:A,minSize:N=0}=S.constraints;if(T!=null&&A){const j=qA({delta:ru(T,k)?N-k:k-T,initialLayout:r,panelConstraints:c.map(O=>O.constraints),pivotIndices:zGe(n,h,o),prevLayout:r,trigger:"keyboard"});r!==j&&a(j)}}break}}};return p.addEventListener("keydown",E),()=>{p.removeEventListener("keydown",E)}});return()=>{f.forEach(p=>p())}},[o,e,t,n,r,s,a])}function awe(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function VGe(e,t){const n=e==="horizontal",{x:r,y:s}=oF(t);return n?r:s}function Q3n(e,t,n,r,s){const o=n==="horizontal",a=lF(t,s);br(a,`No resize handle element found for id "${t}"`);const i=a.getAttribute(la.groupId);br(i,"Resize handle element has no group id attribute");let{initialCursorPosition:c}=r;const l=VGe(n,e),d=HGe(i,s);br(d,`No group element found for id "${i}"`);const f=d.getBoundingClientRect(),p=o?f.width:f.height;return(l-c)/p*100}function X3n(e,t,n,r,s,o){if(DGe(e)){const a=n==="horizontal";let i=0;e.shiftKey?i=100:s!=null?i=s:i=10;let c=0;switch(e.key){case"ArrowDown":c=a?0:i;break;case"ArrowLeft":c=a?-i:0;break;case"ArrowRight":c=a?i:0;break;case"ArrowUp":c=a?0:-i;break;case"End":c=100;break;case"Home":c=-100;break}return c}else return r==null?0:Q3n(e,t,n,r,o)}function J3n({panelDataArray:e}){const t=Array(e.length),n=e.map(o=>o.constraints);let r=0,s=100;for(let o=0;o<e.length;o++){const a=n[o];br(a,`Panel constraints not found for index ${o}`);const{defaultSize:i}=a;i!=null&&(r++,t[o]=i,s-=i)}for(let o=0;o<e.length;o++){const a=n[o];br(a,`Panel constraints not found for index ${o}`);const{defaultSize:i}=a;if(i!=null)continue;const c=e.length-r,l=s/c;r++,t[o]=l,s-=l}return t}function y1(e,t,n){t.forEach((r,s)=>{const o=e[s];br(o,`Panel data not found for index ${s}`);const{callbacks:a,constraints:i,id:c}=o,{collapsedSize:l=0,collapsible:d}=i,f=n[c];if(f==null||r!==f){n[c]=r;const{onCollapse:p,onExpand:h,onResize:g}=a;g&&g(r,f),d&&(p||h)&&(h&&(f==null||Th(f,l))&&!Th(r,l)&&h(),p&&(f==null||!Th(f,l))&&Th(r,l)&&p())}})}function vD(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function eBn({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:s,precision:o=3}){const a=n[s];let i;return a==null?i=e!=null?e.toFixed(o):"1":r.length===1?i="1":i=a.toFixed(o),{flexBasis:0,flexGrow:i,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function tBn(e,t=10){let n=null;return(...s)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...s)},t)}}function iwe(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,n)=>{localStorage.setItem(t,n)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function GGe(e){return`react-resizable-panels:${e}`}function WGe(e){return e.map(t=>{const{constraints:n,id:r,idIsFromProps:s,order:o}=t;return s?r:o?`${o}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function KGe(e,t){try{const n=GGe(e),r=t.getItem(n);if(r){const s=JSON.parse(r);if(typeof s=="object"&&s!=null)return s}}catch{}return null}function nBn(e,t,n){var r,s;const o=(r=KGe(e,n))!==null&&r!==void 0?r:{},a=WGe(t);return(s=o[a])!==null&&s!==void 0?s:null}function rBn(e,t,n,r,s){var o;const a=GGe(e),i=WGe(t),c=(o=KGe(e,s))!==null&&o!==void 0?o:{};c[i]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{s.setItem(a,JSON.stringify(c))}catch(l){console.error(l)}}function lwe({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((o,a)=>o+a,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(o=>`${o}%`).join(", ")}`);if(!ru(r,100)&&n.length>0)for(let o=0;o<t.length;o++){const a=n[o];br(a!=null,`No layout data found for index ${o}`);const i=100/r*a;n[o]=i}let s=0;for(let o=0;o<t.length;o++){const a=n[o];br(a!=null,`No layout data found for index ${o}`);const i=mE({panelConstraints:t,panelIndex:o,size:a});a!=i&&(s+=a-i,n[o]=i)}if(!ru(s,0))for(let o=0;o<t.length;o++){const a=n[o];br(a!=null,`No layout data found for index ${o}`);const i=a+s,c=mE({panelConstraints:t,panelIndex:o,size:i});if(a!==c&&(s-=c-a,n[o]=c,ru(s,0)))break}return n}const sBn=100,UA={getItem:e=>(iwe(UA),UA.getItem(e)),setItem:(e,t)=>{iwe(UA),UA.setItem(e,t)}},cwe={};function ZGe({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:s,id:o=null,onLayout:a=null,keyboardResizeBy:i=null,storage:c=UA,style:l,tagName:d="div",...f}){const p=Zne(o),h=b.useRef(null),[g,y]=b.useState(null),[E,x]=b.useState([]),w=V3n(),S=b.useRef({}),T=b.useRef(new Map),k=b.useRef(0),A=b.useRef({autoSaveId:e,direction:r,dragState:g,id:p,keyboardResizeBy:i,onLayout:a,storage:c}),N=b.useRef({layout:E,panelDataArray:[],panelDataArrayChanged:!1});b.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),b.useImperativeHandle(s,()=>({getId:()=>A.current.id,getLayout:()=>{const{layout:I}=N.current;return I},setLayout:I=>{const{onLayout:J}=A.current,{layout:te,panelDataArray:X}=N.current,ne=lwe({layout:I,panelConstraints:X.map(re=>re.constraints)});awe(te,ne)||(x(ne),N.current.layout=ne,J&&J(ne),y1(X,ne,S.current))}}),[]),Fb(()=>{A.current.autoSaveId=e,A.current.direction=r,A.current.dragState=g,A.current.id=p,A.current.onLayout=a,A.current.storage=c}),Y3n({committedValuesRef:A,eagerValuesRef:N,groupId:p,layout:E,panelDataArray:N.current.panelDataArray,setLayout:x,panelGroupElement:h.current}),b.useEffect(()=>{const{panelDataArray:I}=N.current;if(e){if(E.length===0||E.length!==I.length)return;let J=cwe[e];J==null&&(J=tBn(rBn,sBn),cwe[e]=J);const te=[...I],X=new Map(T.current);J(e,te,X,E,c)}},[e,E,c]),b.useEffect(()=>{});const j=b.useCallback(I=>{const{onLayout:J}=A.current,{layout:te,panelDataArray:X}=N.current;if(I.constraints.collapsible){const ne=X.map(ie=>ie.constraints),{collapsedSize:re=0,panelSize:se,pivotIndices:ce}=B0(X,I,te);if(br(se!=null,`Panel size not found for panel "${I.id}"`),!Th(se,re)){T.current.set(I.id,se);const le=Y1(X,I)===X.length-1?se-re:re-se,oe=qA({delta:le,initialLayout:te,panelConstraints:ne,pivotIndices:ce,prevLayout:te,trigger:"imperative-api"});vD(te,oe)||(x(oe),N.current.layout=oe,J&&J(oe),y1(X,oe,S.current))}}},[]),O=b.useCallback((I,J)=>{const{onLayout:te}=A.current,{layout:X,panelDataArray:ne}=N.current;if(I.constraints.collapsible){const re=ne.map(be=>be.constraints),{collapsedSize:se=0,panelSize:ce=0,minSize:ie=0,pivotIndices:le}=B0(ne,I,X),oe=J??ie;if(Th(ce,se)){const be=T.current.get(I.id),Ee=be!=null&&be>=oe?be:oe,we=Y1(ne,I)===ne.length-1?ce-Ee:Ee-ce,ue=qA({delta:we,initialLayout:X,panelConstraints:re,pivotIndices:le,prevLayout:X,trigger:"imperative-api"});vD(X,ue)||(x(ue),N.current.layout=ue,te&&te(ue),y1(ne,ue,S.current))}}},[]),D=b.useCallback(I=>{const{layout:J,panelDataArray:te}=N.current,{panelSize:X}=B0(te,I,J);return br(X!=null,`Panel size not found for panel "${I.id}"`),X},[]),L=b.useCallback((I,J)=>{const{panelDataArray:te}=N.current,X=Y1(te,I);return eBn({defaultSize:J,dragState:g,layout:E,panelData:te,panelIndex:X})},[g,E]),U=b.useCallback(I=>{const{layout:J,panelDataArray:te}=N.current,{collapsedSize:X=0,collapsible:ne,panelSize:re}=B0(te,I,J);return br(re!=null,`Panel size not found for panel "${I.id}"`),ne===!0&&Th(re,X)},[]),B=b.useCallback(I=>{const{layout:J,panelDataArray:te}=N.current,{collapsedSize:X=0,collapsible:ne,panelSize:re}=B0(te,I,J);return br(re!=null,`Panel size not found for panel "${I.id}"`),!ne||hv(re,X)>0},[]),M=b.useCallback(I=>{const{panelDataArray:J}=N.current;J.push(I),J.sort((te,X)=>{const ne=te.order,re=X.order;return ne==null&&re==null?0:ne==null?-1:re==null?1:ne-re}),N.current.panelDataArrayChanged=!0,w()},[w]);Fb(()=>{if(N.current.panelDataArrayChanged){N.current.panelDataArrayChanged=!1;const{autoSaveId:I,onLayout:J,storage:te}=A.current,{layout:X,panelDataArray:ne}=N.current;let re=null;if(I){const ce=nBn(I,ne,te);ce&&(T.current=new Map(Object.entries(ce.expandToSizes)),re=ce.layout)}re==null&&(re=J3n({panelDataArray:ne}));const se=lwe({layout:re,panelConstraints:ne.map(ce=>ce.constraints)});awe(X,se)||(x(se),N.current.layout=se,J&&J(se),y1(ne,se,S.current))}}),Fb(()=>{const I=N.current;return()=>{I.layout=[]}},[]);const $=b.useCallback(I=>{let J=!1;const te=h.current;return te&&window.getComputedStyle(te,null).getPropertyValue("direction")==="rtl"&&(J=!0),function(ne){ne.preventDefault();const re=h.current;if(!re)return()=>null;const{direction:se,dragState:ce,id:ie,keyboardResizeBy:le,onLayout:oe}=A.current,{layout:be,panelDataArray:Ee}=N.current,{initialLayout:xe}=ce??{},we=zGe(ie,I,re);let ue=X3n(ne,I,se,ce,le,re);const Ie=se==="horizontal";Ie&&J&&(ue=-ue);const Be=Ee.map(Pe=>Pe.constraints),Re=qA({delta:ue,initialLayout:xe??be,panelConstraints:Be,pivotIndices:we,prevLayout:be,trigger:DGe(ne)?"keyboard":"mouse-or-touch"}),Ue=!vD(be,Re);(OGe(ne)||MGe(ne))&&k.current!=ue&&(k.current=ue,!Ue&&ue!==0?Ie?TH(I,ue<0?$Ge:LGe):TH(I,ue<0?FGe:BGe):TH(I,0)),Ue&&(x(Re),N.current.layout=Re,oe&&oe(Re),y1(Ee,Re,S.current))}},[]),P=b.useCallback((I,J)=>{const{onLayout:te}=A.current,{layout:X,panelDataArray:ne}=N.current,re=ne.map(be=>be.constraints),{panelSize:se,pivotIndices:ce}=B0(ne,I,X);br(se!=null,`Panel size not found for panel "${I.id}"`);const le=Y1(ne,I)===ne.length-1?se-J:J-se,oe=qA({delta:le,initialLayout:X,panelConstraints:re,pivotIndices:ce,prevLayout:X,trigger:"imperative-api"});vD(X,oe)||(x(oe),N.current.layout=oe,te&&te(oe),y1(ne,oe,S.current))},[]),q=b.useCallback((I,J)=>{const{layout:te,panelDataArray:X}=N.current,{collapsedSize:ne=0,collapsible:re}=J,{collapsedSize:se=0,collapsible:ce,maxSize:ie=100,minSize:le=0}=I.constraints,{panelSize:oe}=B0(X,I,te);oe!=null&&(re&&ce&&Th(oe,ne)?Th(ne,se)||P(I,se):oe<le?P(I,le):oe>ie&&P(I,ie))},[P]),z=b.useCallback((I,J)=>{const{direction:te}=A.current,{layout:X}=N.current;if(!h.current)return;const ne=lF(I,h.current);br(ne,`Drag handle element not found for id "${I}"`);const re=VGe(te,J);y({dragHandleId:I,dragHandleRect:ne.getBoundingClientRect(),initialCursorPosition:re,initialLayout:X})},[]),G=b.useCallback(()=>{y(null)},[]),R=b.useCallback(I=>{const{panelDataArray:J}=N.current,te=Y1(J,I);te>=0&&(J.splice(te,1),delete S.current[I.id],N.current.panelDataArrayChanged=!0,w())},[w]),W=b.useMemo(()=>({collapsePanel:j,direction:r,dragState:g,expandPanel:O,getPanelSize:D,getPanelStyle:L,groupId:p,isPanelCollapsed:U,isPanelExpanded:B,reevaluatePanelConstraints:q,registerPanel:M,registerResizeHandle:$,resizePanel:P,startDragging:z,stopDragging:G,unregisterPanel:R,panelGroupElement:h.current}),[j,g,r,O,D,L,p,U,B,q,M,$,P,z,G,R]),V={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return b.createElement(sF.Provider,{value:W},b.createElement(d,{...f,children:t,className:n,id:o,ref:h,style:{...V,...l},[la.group]:"",[la.groupDirection]:r,[la.groupId]:p}))}const YGe=b.forwardRef((e,t)=>b.createElement(ZGe,{...e,forwardedRef:t}));ZGe.displayName="PanelGroup";YGe.displayName="forwardRef(PanelGroup)";function Y1(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function B0(e,t,n){const r=Y1(e,t),o=r===e.length-1?[r-1,r]:[r,r+1],a=n[r];return{...t.constraints,panelSize:a,pivotIndices:o}}function oBn({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){b.useEffect(()=>{if(e||n==null||r==null)return;const s=lF(t,r);if(s==null)return;const o=a=>{if(!a.defaultPrevented)switch(a.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{a.preventDefault(),n(a);break}case"F6":{a.preventDefault();const i=s.getAttribute(la.groupId);br(i,`No group element found for id "${i}"`);const c=wN(i,r),l=UGe(i,t,r);br(l!==null,`No resize element found for id "${t}"`);const d=a.shiftKey?l>0?l-1:c.length-1:l+1<c.length?l+1:0;c[d].focus();break}}};return s.addEventListener("keydown",o),()=>{s.removeEventListener("keydown",o)}},[r,e,t,n])}function QGe({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:s,onBlur:o,onClick:a,onDragging:i,onFocus:c,onPointerDown:l,onPointerUp:d,style:f={},tabIndex:p=0,tagName:h="div",...g}){var y,E;const x=b.useRef(null),w=b.useRef({onClick:a,onDragging:i,onPointerDown:l,onPointerUp:d});b.useEffect(()=>{w.current.onClick=a,w.current.onDragging=i,w.current.onPointerDown=l,w.current.onPointerUp=d});const S=b.useContext(sF);if(S===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:T,groupId:k,registerResizeHandle:A,startDragging:N,stopDragging:j,panelGroupElement:O}=S,D=Zne(s),[L,U]=b.useState("inactive"),[B,M]=b.useState(!1),[$,P]=b.useState(null),q=b.useRef({state:L});Fb(()=>{q.current.state=L}),b.useEffect(()=>{if(n)P(null);else{const W=A(D);P(()=>W)}},[n,D,A]);const z=(y=r?.coarse)!==null&&y!==void 0?y:15,G=(E=r?.fine)!==null&&E!==void 0?E:5;b.useEffect(()=>{if(n||$==null)return;const W=x.current;br(W,"Element ref not attached");let V=!1;return z3n(D,W,T,{coarse:z,fine:G},(J,te,X)=>{if(!te){U("inactive");return}switch(J){case"down":{U("drag"),V=!1,br(X,'Expected event to be defined for "down" action'),N(D,X);const{onDragging:ne,onPointerDown:re}=w.current;ne?.(!0),re?.();break}case"move":{const{state:ne}=q.current;V=!0,ne!=="drag"&&U("hover"),br(X,'Expected event to be defined for "move" action'),$(X);break}case"up":{U("hover"),j();const{onClick:ne,onDragging:re,onPointerUp:se}=w.current;re?.(!1),se?.(),V||ne?.();break}}})},[z,T,n,G,A,D,$,N,j]),oBn({disabled:n,handleId:D,resizeHandler:$,panelGroupElement:O});const R={touchAction:"none",userSelect:"none"};return b.createElement(h,{...g,children:e,className:t,id:s,onBlur:()=>{M(!1),o?.()},onFocus:()=>{M(!0),c?.()},ref:x,role:"separator",style:{...R,...f},tabIndex:p,[la.groupDirection]:T,[la.groupId]:k,[la.resizeHandle]:"",[la.resizeHandleActive]:L==="drag"?"pointer":B?"keyboard":void 0,[la.resizeHandleEnabled]:!n,[la.resizeHandleId]:D,[la.resizeHandleState]:L})}QGe.displayName="PanelResizeHandle";const cF=({className:e,...t})=>u.jsx(YGe,{className:me("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t}),rp=jGe,kw=({className:e,...t})=>u.jsx(QGe,{className:me("group/handle relative flex w-4 items-center justify-center shrink-0 focus-visible:outline-hidden",e),...t,children:u.jsx("div",{className:"h-8 w-1 rounded-full bg-muted-foreground/15 transition-all duration-150 group-hover/handle:h-16 group-hover/handle:bg-muted-foreground/30 group-data-[resize-handle-state=drag]/handle:h-16 group-data-[resize-handle-state=drag]/handle:bg-muted-foreground/50"})}),XGe={lifecycleNudge:"Conversation Nudge",lifecycleExpire:"Conversation Expired"};function hR(e){return typeof e=="string"&&e in XGe}function JGe(e){return hR(e)?XGe[e]:"Lifecycle Event"}function aBn(e){const t=new Map;for(const s of e)if(s.id.parent){const o=t.get(s.id.parent)??[];o.push(s),t.set(s.id.parent,o)}for(const s of t.values())s.sort((o,a)=>o.timing.startedAt-a.timing.startedAt);const n=new Map;for(const s of e){const o=n.get(s.id.trace)??[];o.push(s),n.set(s.id.trace,o)}const r=[];for(const[s,o]of n){const a=o.find(A=>A.name==="request.incoming"),i=o.filter(A=>A.name==="handler.conversation"||A.name==="handler.event"||A.name==="handler.trigger"),c=i.find(A=>A.name==="handler.trigger"),l=i.find(A=>A.name==="handler.conversation"),d=i.find(A=>A.name==="handler.event"),f=c??l??d,p=a?String(a.data["message.preview"]??""):void 0,h=d?String(d.data["event.type"]||"unknown event"):void 0,g=hR(h),y=c?String(c.data["trigger.name"]||c.data["event.type"]||"Trigger"):void 0,E=[],x=[],w=[],S=A=>{const N=t.get(A)??[];for(const j of N)if(j.name==="autonomous.iteration")E.push(j);else if(j.name==="autonomous.execution")S(j.id.span);else if(j.name==="chat.sendMessage")x.push(j);else if(j.name==="state.saveAllDirty"){const O=t.get(j.id.span)??[];for(const D of O)if(D.name==="state.save"){const U=D.data["state.changed_keys"];U&&U.length>0&&w.push(D)}}};for(const A of i)S(A.id.span);a&&S(a.id.span);const T=[];let k=0;for(const A of E){const N=t.get(A.id.span)??[],j=N.filter(L=>L.name==="autonomous.tool"),O=N.filter(L=>L.name==="chat.sendMessage"),D=N.find(L=>L.name==="cognitive.request");if(D){const L=D.data["ai.cost"];L&&(k+=Number(L))}T.push({iteration:A,tools:j,messages:O,cognitive:D})}f?.name==="handler.event"&&!c&&!l&&!p&&!g||r.push({traceId:s,userMessage:p,eventType:h,triggerName:y,handler:f,steps:T,directMessages:x,stateMutations:w,totalCost:k})}return r.sort((s,o)=>{const a=s.handler?.timing.startedAt??s.steps[0]?.iteration.timing.startedAt??0,i=o.handler?.timing.startedAt??o.steps[0]?.iteration.timing.startedAt??0;return a-i}),r}function iBn(e,t){if(!e)return null;if(e.type==="step"){for(const n of t){const r=n.steps.find(s=>s.iteration.id.span===e.iterationSpanId);if(r)return{type:"step",step:r}}return null}for(const n of t){if(n.handler?.id.span!==e.spanId)continue;if(n.handler.name==="handler.trigger")return{type:"trigger",span:n.handler};const r=n.handler.data["event.type"];if(n.handler.name==="handler.event"&&hR(r))return{type:"lifecycle",span:n.handler}}return null}function eWe({conversationId:e,className:t}){const n=e.trim().length>0,{traces:r}=IGe({filters:{conversationId:n?e:void 0},autoRefresh:n,hideUnimportant:!1}),s=b.useMemo(()=>aBn(r),[r]),[o,a]=b.useState(()=>{try{const N=localStorage.getItem("agent-steps-collapsed-cards");return N?new Set(JSON.parse(N)):new Set}catch{return new Set}}),i=b.useCallback(N=>{a(j=>{const O=new Set(j);O.has(N)?O.delete(N):O.add(N);try{localStorage.setItem("agent-steps-collapsed-cards",JSON.stringify([...O]))}catch{}return O})},[]),c=b.useMemo(()=>{const N=[];for(const j of s){if((j.userMessage||j.eventType)&&N.push(`user-${j.traceId}`),j.handler){const O=j.handler.data["event.type"],D=j.handler.name==="handler.trigger",L=j.handler.name==="handler.event"&&hR(O);D||L?N.push(j.handler.id.span):N.push(`bot-${j.handler.id.span}`)}for(const O of j.steps)N.push(O.iteration.id.span);for(const O of j.directMessages)N.push(O.id.span);for(const O of j.stateMutations)N.push(O.id.span)}return N},[s]),l=b.useCallback(()=>{const N=new Set(c);a(N);try{localStorage.setItem("agent-steps-collapsed-cards",JSON.stringify([...N]))}catch{}},[c]),d=b.useCallback(()=>{a(new Set);try{localStorage.removeItem("agent-steps-collapsed-cards")}catch{}},[]),[f,p]=b.useState(null),h=b.useMemo(()=>iBn(f,s),[f,s]),[g,y]=b.useState(!1),E=b.useRef(null),x=b.useCallback(N=>{f&&(N.type==="step"&&f.type==="step"&&N.iterationSpanId===f.iterationSpanId||N.type==="span"&&f.type==="span"&&N.spanId===f.spanId)?p(null):(f&&(y(!0),setTimeout(()=>y(!1),200)),p(N),T.current=N.type==="step"?N.iterationSpanId:N.spanId)},[f]);b.useEffect(()=>{const N=E.current;if(N)if(h){if(N.isCollapsed()){let j=35;try{const O=Number(localStorage.getItem("agent-steps-detail-size"));O>=20&&O<=50&&(j=O)}catch{}N.resize(j)}}else N.isExpanded()&&N.collapse()},[h]);const w=b.useRef(null),S=b.useRef(null),T=b.useRef(null),k=b.useRef(new Set),A=w.current;return A&&(S.current={scrollTop:A.scrollTop,scrollHeight:A.scrollHeight,clientHeight:A.clientHeight}),b.useEffect(()=>{const N=S.current;!N||!(N.scrollHeight-N.scrollTop-N.clientHeight<1)||requestAnimationFrame(()=>{const O=w.current;O&&(O.scrollTop=O.scrollHeight)})},[r]),b.useEffect(()=>{const N=T.current;N&&(T.current=null,requestAnimationFrame(()=>{const j=w.current,O=j?.querySelector(`[data-span-id="${N}"]`);if(j&&O){const D=O.getBoundingClientRect(),L=j.getBoundingClientRect();let U=0;for(const B of j.querySelectorAll(".sticky"))U=Math.max(U,B.offsetHeight);j.scrollTop+=D.top-L.top-U}}))},[f]),u.jsxs("div",{className:me("flex flex-col h-full",t),children:[u.jsx(lBn,{conversationId:e,turns:s,onCollapseAll:l,onExpandAll:d,isAllCollapsed:c.length>0&&c.every(N=>o.has(N))}),s.length===0?u.jsx("div",{className:"flex-1 flex items-center justify-center",children:u.jsx("span",{className:"small",children:"Waiting for agent activity..."})}):u.jsx(u.Fragment,{children:u.jsxs(cF,{direction:"horizontal",className:"flex-1 min-h-0",children:[u.jsx(rp,{order:1,minSize:30,children:u.jsx("div",{ref:w,className:"h-full overflow-y-auto text-sm",children:u.jsx("div",{className:"px-4 py-3 space-y-4",children:s.map(N=>u.jsx(hBn,{turn:N,onSelect:x,collapsedCards:o,toggleCard:i,seenSpans:k.current},N.traceId))})})}),u.jsx(kw,{className:"w-0 after:w-2!"}),u.jsx(rp,{ref:E,order:2,defaultSize:0,minSize:20,maxSize:50,collapsible:!0,collapsedSize:0,className:me(g&&"animate-detail-flash"),onResize:()=>{const N=E.current;if(N&&!N.isCollapsed())try{localStorage.setItem("agent-steps-detail-size",String(N.getSize()))}catch{}},children:h&&u.jsx("div",{className:"h-full overflow-y-auto bg-background-elevated rounded-md m-2 ml-0",children:u.jsx(TBn,{detail:h,onClose:()=>p(null)})})})]})})]})}function lBn({conversationId:e,turns:t,onCollapseAll:n,onExpandAll:r,isAllCollapsed:s}){const o=t.reduce((c,l)=>c+l.totalCost,0),a=t.reduce((c,l)=>{for(const d of l.steps)if(d.cognitive){const f=d.cognitive.data["ai.tokens"];f&&(c+=Number(f))}return c},0),i=t.reduce((c,l)=>c+l.directMessages.length+l.steps.reduce((d,f)=>d+f.messages.length,0)+(l.userMessage?1:0),0);return u.jsxs("div",{className:"shrink-0 px-4 pt-0 pb-2",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("span",{className:"text-sm font-medium text-foreground",children:"Agent Steps"}),u.jsx("div",{className:"flex-1"}),t.length>0&&u.jsxs(vn,{children:[u.jsx(xn,{asChild:!0,children:u.jsx("button",{type:"button",className:"p-1 rounded-sm text-muted-foreground/40 hover:text-muted-foreground hover:bg-muted transition-colors",onClick:s?r:n,children:s?u.jsx(cCt,{className:"size-3.5"}):u.jsx(iCt,{className:"size-3.5"})})}),u.jsx(yn,{children:s?"Expand all":"Collapse all"})]}),e&&u.jsxs(Fc,{to:`/traces?conversationId=${encodeURIComponent(e)}`,className:"inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md border border-muted-foreground/15 text-xs text-muted-foreground hover:text-foreground hover:border-muted-foreground/30 transition-colors",children:[u.jsx(tc,{className:"size-3"}),"Open conversation traces"]})]}),(i>0||a>0||o>0)&&u.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[i>0&&u.jsxs("span",{className:"small text-muted-foreground/50",children:[i," message",i!==1?"s":""]}),a>0&&u.jsxs("span",{className:"small text-muted-foreground/50",children:[a.toLocaleString()," tokens"]}),o>0&&u.jsxs("span",{className:"small text-muted-foreground/50",children:["$",o.toFixed(4)]})]})]})}function cBn({value:e,className:t}){const[n,r]=b.useState(!1);return u.jsx("button",{type:"button",className:me("p-1 rounded-sm hover:bg-muted transition-colors text-muted-foreground/50 hover:text-foreground",t),onClick:s=>{s.stopPropagation(),navigator.clipboard.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),1500)}).catch(()=>{})},children:n?u.jsx(Xr,{className:"size-3 text-green-500"}):u.jsx(li,{className:"size-3"})})}function uBn(){const[e,t]=b.useState(()=>{try{const r=localStorage.getItem("step-detail-collapsed");return r?new Set(JSON.parse(r)):new Set}catch{return new Set}}),n=b.useCallback(r=>{t(s=>{const o=new Set(s);o.has(r)?o.delete(r):o.add(r);try{localStorage.setItem("step-detail-collapsed",JSON.stringify([...o]))}catch{}return o})},[]);return{collapsed:e,toggle:n}}function r0({status:e}){switch(e){case"ok":return u.jsx(Ms,{className:"size-3 text-green-500 shrink-0"});case"error":return u.jsx(yl,{className:"size-3 text-red-500 shrink-0"});case"running":return u.jsx(nn,{className:"size-3 text-blue-500 animate-spin shrink-0"});default:return u.jsx(id,{className:"size-3 text-muted-foreground/50 shrink-0"})}}function mf({span:e}){return e.status==="running"?u.jsx(dBn,{startedAt:e.timing.startedAt}):u.jsxs("span",{className:"flex items-center gap-0.5 small text-muted-foreground/50",children:[u.jsx(id,{className:"size-2.5"}),RBn(e)]})}function dBn({startedAt:e}){const[,t]=b.useState(0);b.useEffect(()=>{const s=setInterval(()=>t(o=>o+1),100);return()=>clearInterval(s)},[]);const n=Date.now()-e,r=n<1e3?`${Math.round(n)}ms`:`${(n/1e3).toFixed(1)}s`;return u.jsxs("span",{className:"flex items-center gap-0.5 small text-blue-500 tabular-nums",children:[u.jsx(id,{className:"size-2.5"}),r]})}function tWe({status:e}){return u.jsx("span",{className:me("caption px-1.5 py-0.5 rounded-sm",e==="ok"?"bg-green-500/10 text-green-400":e==="error"?"bg-red-500/10 text-red-400":e==="running"?"bg-blue-500/10 text-blue-400":"bg-muted text-muted-foreground"),children:e})}function nWe(){return u.jsxs("div",{className:"relative overflow-hidden bg-background-elevated p-2 rounded-md",children:[u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("div",{className:"h-3 w-full rounded-sm bg-muted-foreground/10"}),u.jsx("div",{className:"h-3 w-2/3 rounded-sm bg-muted-foreground/10"})]}),u.jsx("div",{className:"absolute inset-0 -translate-x-full animate-shimmer bg-linear-to-r from-transparent via-muted-foreground/5 to-transparent"})]})}function rWe(){return u.jsxs("div",{className:"relative overflow-hidden py-0.5",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx("div",{className:"h-3 w-full rounded-sm bg-muted-foreground/10"}),u.jsx("div",{className:"h-3 w-5/6 rounded-sm bg-muted-foreground/10"}),u.jsx("div",{className:"h-3 w-2/3 rounded-sm bg-muted-foreground/10"})]}),u.jsx("div",{className:"absolute inset-0 -translate-x-full animate-shimmer bg-linear-to-r from-transparent via-muted-foreground/5 to-transparent"})]})}function fBn(){return u.jsxs("div",{className:"relative overflow-hidden",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("div",{className:"size-5 rounded-sm bg-muted-foreground/10 shrink-0"}),u.jsx("div",{className:"h-3 w-28 rounded-sm bg-muted-foreground/10"}),u.jsx("div",{className:"flex-1"}),u.jsx("div",{className:"h-3 w-12 rounded-sm bg-muted-foreground/10"})]}),u.jsx("div",{className:"absolute inset-0 -translate-x-full animate-shimmer bg-linear-to-r from-transparent via-muted-foreground/5 to-transparent"})]})}function pBn({cognitive:e}){if(!e)return null;const t=e.data,n=t["ai.input_tokens"],r=t["ai.output_tokens"],s=t["ai.cost"];return e.status==="running"?u.jsx("span",{className:"small text-muted-foreground/30 thinking-shimmer",children:"thinking..."}):!n&&!r&&s==null?null:u.jsxs("span",{className:"small flex items-center gap-1.5 text-muted-foreground/50",children:[(n!=null||r!=null)&&u.jsxs("span",{children:[String(n??"?")," in → ",String(r??"?")," out"]}),s!=null&&u.jsxs("span",{children:["$",Number(s).toFixed(4)]})]})}function sp({isLast:e=!1,children:t}){return u.jsxs("div",{className:"relative pl-5 pb-3",children:[!e&&u.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-[1.5px] bg-[hsl(var(--tree-line))]"}),u.jsx("div",{className:"absolute left-0 top-0 h-4 w-5 border-l-[1.5px] border-b-[1.5px] border-[hsl(var(--tree-line))] rounded-bl-md"}),u.jsx("div",{className:"pt-2",children:t})]})}function rx({open:e,children:t}){return u.jsx("div",{className:"accordion-body","data-open":e,children:u.jsx("div",{children:t})})}function US(e,t){if(!e.has(t))return e.add(t),"animate-slide-in"}function hBn({turn:e,onSelect:t,collapsedCards:n,toggleCard:r,seenSpans:s}){const o=e.handler?.name==="handler.trigger",a=e.handler?String(e.handler.data["event.type"]||""):"",i=e.handler?.name==="handler.event"&&hR(a);return u.jsx("div",{className:"space-y-3",children:o?u.jsx(mBn,{turn:e,onSelect:t,collapsedCards:n,toggleCard:r,seenSpans:s}):i?u.jsx(gBn,{turn:e,onSelect:t,collapsedCards:n,toggleCard:r,seenSpans:s}):u.jsxs(u.Fragment,{children:[e.userMessage?u.jsx(uwe,{message:e.userMessage,collapseId:`user-${e.traceId}`,collapsedCards:n,toggleCard:r,seenSpans:s}):e.eventType?u.jsx(uwe,{message:e.eventType,isEvent:!0,eventLabel:e.eventType==="workflowNotify"?"Workflow Progress":"User Triggered Event",collapseId:`user-${e.traceId}`,collapsedCards:n,toggleCard:r,seenSpans:s}):null,e.handler&&u.jsx(yBn,{handler:e.handler,steps:e.steps,directMessages:e.directMessages,stateMutations:e.stateMutations,totalCost:e.totalCost,onSelect:t,collapsedCards:n,toggleCard:r,seenSpans:s})]})})}function uwe({message:e,isEvent:t,eventLabel:n,collapseId:r,collapsedCards:s,toggleCard:o}){const a=s.has(r);return u.jsxs("div",{children:[u.jsxs("div",{className:me("flex items-center gap-2",a&&"cursor-pointer hover:opacity-80 transition-opacity duration-quick"),onClick:a?()=>o(r):void 0,children:[u.jsx("div",{className:"size-5 rounded-md bg-slate-500 flex items-center justify-center shrink-0 ring-[3px] ring-[hsl(var(--tree-line))]",children:u.jsx(IJ,{className:"size-3 text-background"})}),u.jsx("span",{className:"caption",children:t?n||"User Triggered Event":"User"}),a&&u.jsx("span",{className:"small text-muted-foreground/50 truncate",children:e.length>60?e.slice(0,60)+"...":e}),u.jsx("button",{type:"button",className:"text-muted-foreground/50 hover:text-foreground shrink-0",onClick:i=>{i.stopPropagation(),o(r)},children:a?u.jsx(cs,{className:"size-3"}):u.jsx(Dr,{className:"size-3"})})]}),u.jsx(rx,{open:!a,children:u.jsx("div",{className:"ml-[9px]",children:u.jsx(sp,{isLast:!0,children:u.jsx(bBn,{message:e,isEvent:t})})})})]})}function mBn({turn:e,onSelect:t,collapsedCards:n,toggleCard:r,seenSpans:s}){const o=e.handler,a=o.data,i=e.triggerName||"Trigger",c=String(a["event.type"]||""),l=e.steps.length>0||e.directMessages.length>0||e.stateMutations.length>0,d=n.has(o.id.span);return u.jsxs("div",{"data-span-id":o.id.span,className:US(s,o.id.span),children:[u.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1.5 bg-amber-500/10 rounded-md cursor-pointer hover:bg-amber-500/15 transition-colors duration-quick",onClick:()=>{if(d&&l){r(o.id.span);return}t({type:"span",spanId:o.id.span})},children:[u.jsx("div",{className:"size-5 rounded-md bg-amber-500/20 flex items-center justify-center shrink-0",children:u.jsx(Sa,{className:"size-3 text-amber-500"})}),u.jsx("span",{className:"caption text-foreground font-semibold",children:i}),c&&c!==i&&u.jsx("span",{className:"small text-muted-foreground/50",children:c}),l&&u.jsx("button",{type:"button",className:"text-muted-foreground/50 hover:text-foreground shrink-0",onClick:f=>{f.stopPropagation(),r(o.id.span)},children:d?u.jsx(cs,{className:"size-3"}):u.jsx(Dr,{className:"size-3"})}),u.jsx("div",{className:"flex-1"}),u.jsx(mf,{span:o}),u.jsx(r0,{status:o.status})]}),u.jsx(rx,{open:!d,children:l?u.jsxs("div",{className:"ml-[9px]",children:[e.directMessages.map((f,p)=>u.jsx(sp,{isLast:e.steps.length===0&&e.stateMutations.length===0&&p===e.directMessages.length-1,children:u.jsx(Xne,{span:f,collapsedCards:n,toggleCard:r,seenSpans:s})},f.id.span)),e.steps.map((f,p)=>u.jsx(sp,{isLast:p===e.steps.length-1&&e.stateMutations.length===0,children:u.jsx(Qne,{step:f,onSelect:t,collapsedCards:n,toggleCard:r,seenSpans:s})},f.iteration.id.span)),e.stateMutations.map((f,p)=>u.jsx(sp,{isLast:p===e.stateMutations.length-1,children:u.jsx(Jne,{span:f,collapsedCards:n,toggleCard:r,seenSpans:s})},f.id.span))]}):u.jsx("div",{className:"px-2.5 py-1.5",children:o.status==="running"?u.jsx("span",{className:"small thinking-shimmer",children:"Evaluating trigger..."}):o.status==="error"?u.jsx("span",{className:"small text-red-400",children:"Trigger failed"}):u.jsx("span",{className:"small text-muted-foreground/50",children:"Trigger evaluated"})})})]})}function gBn({turn:e,onSelect:t,collapsedCards:n,toggleCard:r,seenSpans:s}){const o=e.handler,a=o.data,i=String(a["event.type"]||""),c=JGe(i),l=e.steps.length>0||e.directMessages.length>0||e.stateMutations.length>0,d=n.has(o.id.span);return u.jsxs("div",{"data-span-id":o.id.span,className:US(s,o.id.span),children:[u.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1.5 bg-purple-500/10 rounded-md cursor-pointer hover:bg-purple-500/15 transition-colors duration-quick",onClick:()=>{if(d&&l){r(o.id.span);return}t({type:"span",spanId:o.id.span})},children:[u.jsx("div",{className:"size-5 rounded-md bg-purple-500/20 flex items-center justify-center shrink-0",children:u.jsx(id,{className:"size-3 text-purple-400"})}),u.jsx("span",{className:"caption text-foreground font-semibold",children:c}),i&&u.jsx("span",{className:"small text-muted-foreground/50",children:i}),l&&u.jsx("button",{type:"button",className:"text-muted-foreground/50 hover:text-foreground shrink-0",onClick:f=>{f.stopPropagation(),r(o.id.span)},children:d?u.jsx(cs,{className:"size-3"}):u.jsx(Dr,{className:"size-3"})}),u.jsx("div",{className:"flex-1"}),u.jsx(mf,{span:o}),u.jsx(r0,{status:o.status})]}),u.jsx(rx,{open:!d,children:l?u.jsxs("div",{className:"ml-[9px]",children:[e.directMessages.map((f,p)=>u.jsx(sp,{isLast:e.steps.length===0&&e.stateMutations.length===0&&p===e.directMessages.length-1,children:u.jsx(Xne,{span:f,collapsedCards:n,toggleCard:r,seenSpans:s})},f.id.span)),e.steps.map((f,p)=>u.jsx(sp,{isLast:p===e.steps.length-1&&e.stateMutations.length===0,children:u.jsx(Qne,{step:f,onSelect:t,collapsedCards:n,toggleCard:r,seenSpans:s})},f.iteration.id.span)),e.stateMutations.map((f,p)=>u.jsx(sp,{isLast:p===e.stateMutations.length-1,children:u.jsx(Jne,{span:f,collapsedCards:n,toggleCard:r,seenSpans:s})},f.id.span))]}):u.jsx("div",{className:"px-2.5 py-1.5",children:o.status==="running"?u.jsx("span",{className:"small thinking-shimmer",children:"Handling lifecycle event..."}):o.status==="error"?u.jsx("span",{className:"small text-red-400",children:"Lifecycle event failed"}):u.jsx("span",{className:"small text-muted-foreground/50",children:"Lifecycle event handled"})})})]})}function yBn({handler:e,steps:t,directMessages:n,stateMutations:r,totalCost:s,onSelect:o,collapsedCards:a,toggleCard:i,seenSpans:c}){const l=t.length>0||n.length>0||r.length>0,d=`bot-${e.id.span}`,f=a.has(d);return u.jsxs("div",{className:US(c,e.id.span),children:[u.jsxs("div",{className:"flex items-center gap-2 cursor-pointer hover:opacity-80 transition-opacity duration-quick sticky top-0 z-10 bg-background",onClick:()=>{if(f){i(d);return}const p=t[t.length-1];p&&o({type:"step",iterationSpanId:p.iteration.id.span})},children:[u.jsx("div",{className:"size-5 rounded-md bg-sidebar-primary flex items-center justify-center shrink-0 p-1 ring-[3px] ring-[hsl(var(--tree-line))]",children:u.jsx("img",{src:"/ADK.svg",alt:"ADK",className:"size-full invert"})}),u.jsx("span",{className:"caption",children:"Bot"}),s>0&&u.jsxs("span",{className:"small text-muted-foreground/50",children:["$",s.toFixed(4)]}),u.jsx(mf,{span:e}),f&&u.jsxs("span",{className:"small text-muted-foreground/50",children:[t.length," iteration",t.length!==1?"s":""]}),u.jsx("button",{type:"button",className:"text-muted-foreground/50 hover:text-foreground shrink-0",onClick:p=>{p.stopPropagation(),i(d)},children:f?u.jsx(cs,{className:"size-3"}):u.jsx(Dr,{className:"size-3"})})]}),u.jsx(rx,{open:!f,children:l?u.jsxs("div",{className:"ml-[9px]",children:[n.map((p,h)=>u.jsx(sp,{isLast:t.length===0&&r.length===0&&h===n.length-1,children:u.jsx(Xne,{span:p,collapsedCards:a,toggleCard:i,seenSpans:c})},p.id.span)),t.map((p,h)=>u.jsx(sp,{isLast:h===t.length-1&&r.length===0,children:u.jsx(Qne,{step:p,onSelect:o,collapsedCards:a,toggleCard:i,seenSpans:c})},p.iteration.id.span)),r.map((p,h)=>u.jsx(sp,{isLast:h===r.length-1,children:u.jsx(Jne,{span:p,collapsedCards:a,toggleCard:i,seenSpans:c})},p.id.span))]}):u.jsx("div",{className:"ml-3 pl-5 py-1",children:e.status==="running"?u.jsx("span",{className:"small thinking-shimmer",children:"Processing..."}):u.jsx("span",{className:"small text-muted-foreground/50",children:"No steps"})})})]})}function bBn({message:e,isEvent:t}){return u.jsxs("div",{className:"border border-blue-500/20 rounded-md px-3 py-2 bg-blue-500/10 body leading-relaxed text-foreground",children:[t&&u.jsx("span",{className:"code text-muted-foreground/50 block mb-1",children:"event"}),e]})}function Qne({step:e,onSelect:t,collapsedCards:n,toggleCard:r,seenSpans:s}){const o=e.iteration.data,a=o["autonomous.iteration"],i=o["autonomous.exit.name"],c=e.iteration.status==="running",l=e.iteration.status==="error"?"errored":i||"continued",d=!n.has(e.iteration.id.span),f=e.tools.length>0||e.messages.length>0;return u.jsxs("div",{"data-span-id":e.iteration.id.span,className:me("border rounded-md overflow-hidden cursor-pointer transition-colors duration-quick",US(s,e.iteration.id.span),c?"border-blue-500/40":"border-border/50 hover:border-border hover:bg-background-elevated"),onClick:()=>{if(!d){r(e.iteration.id.span);return}t({type:"step",iterationSpanId:e.iteration.id.span})},children:[u.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1.5 bg-muted/20",children:[u.jsxs("span",{className:me("caption text-foreground font-semibold",c&&"thinking-shimmer"),children:["LLM Iteration",a!=null?` ${Number(a)+1}`:""]}),!c&&u.jsx("span",{className:"small text-muted-foreground/50",children:l}),f&&u.jsx("button",{type:"button",className:"text-muted-foreground/50 hover:text-foreground shrink-0",onClick:p=>{p.stopPropagation(),r(e.iteration.id.span)},children:d?u.jsx(Dr,{className:"size-3"}):u.jsx(cs,{className:"size-3"})}),u.jsx("div",{className:"flex-1"}),u.jsx(pBn,{cognitive:e.cognitive}),u.jsx(mf,{span:e.iteration}),u.jsx(r0,{status:e.iteration.status})]}),u.jsx(rx,{open:d,children:u.jsxs("div",{className:"divide-y divide-border/30",children:[e.tools.map(p=>u.jsx(vBn,{span:p},p.id.span)),e.messages.map(p=>u.jsx("div",{className:"px-2.5 py-2 bg-blue-500/10 animate-fade-in",children:u.jsx(wBn,{span:p})},p.id.span)),c&&!f&&u.jsx("div",{className:"px-2.5 py-2",children:u.jsx(fBn,{})})]})})]})}function Xne({span:e,collapsedCards:t,toggleCard:n,seenSpans:r}){const s=t.has(e.id.span),o=e.data,a=o["message.preview"]!=null,i=e.status==="running",[c,l]=b.useState(!1),d=a&&String(o["message.preview"]).length>aWe;return u.jsxs("div",{className:me("rounded-md bg-blue-500/10",US(r,e.id.span)),children:[u.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-2",children:[u.jsx("div",{className:"size-5 rounded-sm flex items-center justify-center shrink-0 bg-blue-500/20 text-blue-500",children:u.jsx(a5,{className:"size-3"})}),u.jsx("span",{className:me("caption text-foreground font-semibold",i&&!a&&"thinking-shimmer"),children:"Bot Message"}),a&&u.jsx("button",{type:"button",className:"text-muted-foreground/50 hover:text-foreground shrink-0",onClick:()=>n(e.id.span),children:s?u.jsx(cs,{className:"size-3"}):u.jsx(Dr,{className:"size-3"})}),u.jsx("div",{className:"flex-1"}),u.jsx(mf,{span:e}),u.jsx(r0,{status:e.status})]}),a?u.jsx(rx,{open:!s,children:u.jsxs("div",{className:me("px-2.5 pb-2 pl-10 relative animate-fade-in",d&&"cursor-pointer"),onClick:d?f=>{f.stopPropagation(),l(!c)}:void 0,children:[u.jsx("div",{className:me(d&&!c&&"overflow-hidden"),style:d&&!c?{maxHeight:"8.25em"}:void 0,children:u.jsx(Ky,{content:String(o["message.preview"])})}),d&&!c&&u.jsx("div",{className:"absolute bottom-0 left-10 right-0 h-6 bg-linear-to-t from-blue-500/10 to-transparent pointer-events-none"})]})}):i?u.jsx("div",{className:"px-2.5 pb-2 pl-10",children:u.jsx(rWe,{})}):null]})}function Jne({span:e,collapsedCards:t,toggleCard:n,seenSpans:r}){const s=e.data,o=String(s.type||"unknown"),a=s["state.previous_value"],i=s["state.value"],c=a!=null?O$(a):void 0,l=i!=null?O$(i):void 0,d=s["state.changed_keys"],f=t.has(e.id.span),p=c!==void 0||l!==void 0,[h,g]=b.useState(!1),y=!!(d?.length&&typeof c=="object"&&c!==null&&!Array.isArray(c)),E=b.useMemo(()=>{if(!y)return c;const k={};for(const A of d)A in c&&(k[A]=c[A]);return k},[c,d,y]),x=b.useMemo(()=>{if(!y||typeof l!="object"||l===null||Array.isArray(l))return l;const k={};for(const A of d)A in l&&(k[A]=l[A]);return k},[l,d,y]),w=y&&(()=>{const k=Object.keys(c),A=typeof l=="object"&&l!==null&&!Array.isArray(l)?Object.keys(l):[],N=new Set(d);return k.some(j=>!N.has(j))||A.some(j=>!N.has(j))})(),S=h||!w?c:E,T=h||!w?l:x;return u.jsxs("div",{className:me("border border-teal-600/15 rounded-md px-2.5 py-2 bg-teal-600/5",US(r,e.id.span)),children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("div",{className:"size-5 rounded-sm flex items-center justify-center shrink-0 bg-teal-600/15 text-teal-600/70",children:u.jsx(ml,{className:"size-3"})}),u.jsxs("span",{className:"caption text-foreground font-semibold",children:[o," state mutation"]}),p&&u.jsx("button",{type:"button",className:"text-muted-foreground/50 hover:text-foreground shrink-0",onClick:()=>n(e.id.span),children:f?u.jsx(cs,{className:"size-3"}):u.jsx(Dr,{className:"size-3"})}),u.jsx("div",{className:"flex-1"}),!f&&w&&u.jsxs(vn,{children:[u.jsx(xn,{asChild:!0,children:u.jsx("button",{type:"button",className:"p-0.5 rounded-sm text-muted-foreground/50 hover:text-teal-500 hover:bg-teal-500/10 transition-colors duration-quick",onClick:k=>{k.stopPropagation(),g(!h)},children:h?u.jsx(aIt,{className:"size-3"}):u.jsx(KNt,{className:"size-3"})})}),u.jsx(yn,{children:h?"Show changes only":"Show full state"})]}),u.jsx(r0,{status:e.status}),u.jsx(mf,{span:e})]}),p&&u.jsx(rx,{open:!f,children:u.jsxs("div",{className:"mt-1.5 pl-8 grid grid-cols-2 gap-3",children:[u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[u.jsx(bJ,{className:"size-3 shrink-0 text-teal-600/50"}),u.jsx("span",{className:"h3",children:"Before"})]}),S!==void 0&&u.jsx("div",{className:"bg-background-elevated p-2 rounded-md overflow-hidden",children:u.jsx(Oo,{data:S,expandAll:!0})})]}),u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[u.jsx(yJ,{className:"size-3 shrink-0 text-teal-600/50"}),u.jsx("span",{className:"h3",children:"After"})]}),T!==void 0&&u.jsx("div",{className:"bg-background-elevated p-2 rounded-md overflow-hidden",children:u.jsx(Oo,{data:T,expandAll:!0})})]})]})})]})}function sWe(e){return String(e.data["autonomous.tool.name"]||"Tool")}function oWe(e){const t=e.data;return{input:t["autonomous.tool.input"],output:t["autonomous.tool.output"]}}function vBn({span:e}){const n=sWe(e)==="search_knowledge";return u.jsx("div",{className:me("px-2.5 py-2",n?"bg-green-500/10":"bg-violet-500/10"),children:n?u.jsx(xBn,{span:e}):u.jsx(EBn,{span:e})})}function xBn({span:e}){const{input:t,output:n}=oWe(e),r=e.status==="running",s=t?typeof t=="string"?t:t?.query??JSON.stringify(t):void 0;return u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("div",{className:"size-5 rounded-sm flex items-center justify-center shrink-0 bg-green-500/20 text-green-500",children:u.jsx(zkt,{className:"size-3"})}),u.jsx("span",{className:"caption text-foreground font-semibold flex-1",children:"search_knowledge"}),u.jsx(mf,{span:e}),u.jsx(r0,{status:e.status})]}),(s!=null||n!=null||r)&&u.jsxs("div",{className:"mt-1.5 pl-8 grid grid-cols-2 gap-3",children:[u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[u.jsx(bJ,{className:"size-3 shrink-0 text-green-500/50"}),u.jsx("span",{className:"h3",children:"Input"})]}),s!=null&&u.jsx("div",{className:"bg-background-elevated p-2 rounded-md overflow-hidden",children:u.jsx("span",{className:"small",children:String(s)})})]}),u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[u.jsx(yJ,{className:"size-3 shrink-0 text-green-500/50"}),u.jsx("span",{className:"h3",children:"Result"})]}),n!=null?u.jsxs("div",{className:"group relative bg-background-elevated p-2 rounded-md animate-fade-in",children:[u.jsx(cBn,{value:String(n),className:"absolute top-1 right-1 opacity-0 group-hover:opacity-100"}),u.jsx(Ky,{content:String(n)})]}):r?u.jsx(nWe,{}):null]})]})]})}function O$(e){if(typeof e=="string")try{return JSON.parse(e)}catch{return e}return e}function EBn({span:e}){const t=sWe(e),n=e.status==="running",{input:r,output:s}=oWe(e),o=r!=null?O$(r):void 0,a=s!=null?O$(s):void 0;return u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("div",{className:"size-5 rounded-sm flex items-center justify-center shrink-0 bg-violet-500/20 text-violet-500",children:u.jsx(rS,{className:"size-3"})}),u.jsx("span",{className:"caption text-foreground font-semibold flex-1",children:t}),u.jsx(mf,{span:e}),u.jsx(r0,{status:e.status})]}),(o!==void 0||a!==void 0||n)&&u.jsxs("div",{className:"mt-1.5 pl-8 grid grid-cols-2 gap-3",children:[u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[u.jsx(bJ,{className:"size-3 shrink-0 text-violet-500/50"}),u.jsx("span",{className:"h3",children:"Input"})]}),o!==void 0&&u.jsx("div",{className:"bg-background-elevated p-2 rounded-md overflow-hidden",children:u.jsx(Oo,{data:o,expandAll:!0})})]}),u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[u.jsx(yJ,{className:"size-3 shrink-0 text-violet-500/50"}),u.jsx("span",{className:"h3",children:"Output"})]}),a!==void 0?u.jsx("div",{className:"bg-background-elevated p-2 rounded-md overflow-hidden animate-fade-in",children:u.jsx(Oo,{data:a,expandAll:!0,maxLines:5})}):n?u.jsx(nWe,{}):null]})]})]})}const aWe=300;function wBn({span:e}){const n=e.data["message.preview"],[r,s]=b.useState(!1),o=n!=null&&String(n).length>aWe;return u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("div",{className:"size-5 rounded-sm flex items-center justify-center shrink-0 bg-blue-500/20 text-blue-500",children:u.jsx(a5,{className:"size-3"})}),u.jsx("span",{className:"caption text-foreground font-semibold flex-1",children:"Bot Message"}),u.jsx(mf,{span:e}),u.jsx(r0,{status:e.status})]}),n!=null?u.jsxs("div",{className:me("mt-1.5 pl-8 relative animate-fade-in",o&&"cursor-pointer"),onClick:o?a=>{a.stopPropagation(),s(!r)}:void 0,children:[u.jsx("div",{className:me(o&&!r&&"overflow-hidden"),style:o&&!r?{maxHeight:"8.25em"}:void 0,children:u.jsx(Ky,{content:String(n)})}),o&&!r&&u.jsx("div",{className:"absolute bottom-0 left-8 right-0 h-6 bg-linear-to-t from-blue-500/10 to-transparent pointer-events-none"})]}):e.status==="running"?u.jsx("div",{className:"mt-1.5 pl-8",children:u.jsx(rWe,{})}):null]})}const SBn="[&_pre]:text-xs [&_.shiki]:text-xs! [&_code]:text-xs! [&_pre]:whitespace-pre-wrap! [&_pre]:wrap-break-word! [&_code]:whitespace-pre-wrap! [&_code]:wrap-break-word! [&_.line]:before:content-none!";function ere({icon:e,iconBg:t,iconText:n,label:r,span:s}){return u.jsxs("div",{className:"px-4 py-3 space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("div",{className:me("size-5 rounded-sm flex items-center justify-center shrink-0",t),children:u.jsx(e,{className:me("size-3",n)})}),u.jsx("span",{className:"caption text-foreground font-semibold flex-1",children:r}),u.jsx(tWe,{status:s.status})]}),u.jsx("div",{className:"flex items-center gap-3",children:u.jsx(mf,{span:s})}),s.error&&u.jsx("div",{className:"bg-red-500/10 border border-red-500/20 rounded-md px-3 py-2",children:u.jsx("p",{className:"small text-red-400 wrap-break-word whitespace-pre-wrap",children:s.error})})]})}function db({label:e,children:t,collapsible:n,collapsed:r,onToggle:s}){return n?u.jsxs("div",{className:"mx-3 my-2 px-3 py-3 bg-muted/50 rounded-md",children:[u.jsxs("button",{type:"button",className:"h3 mb-2 flex items-center gap-1 hover:text-foreground transition-colors w-full text-left",onClick:s,children:[r?u.jsx(cs,{className:"size-3"}):u.jsx(Dr,{className:"size-3"}),e]}),!r&&t]}):u.jsxs("div",{className:"mx-3 my-2 px-3 py-3 bg-muted/50 rounded-md",children:[u.jsx("span",{className:"h3 mb-2 block",children:e}),t]})}function mR({children:e}){return u.jsx("div",{className:"bg-muted/50 p-3 rounded-md",children:e})}function _Bn({text:e,maxLines:t=5}){const[n,r]=b.useState(!1),s=e.split(`
1616
+ `).map((n,r)=>u.jsx("span",{className:"line",children:n},r))})})}),Vne=({children:e,...t})=>{const{data:n}=b.useContext(zne);return u.jsx("div",{...t,children:n.map(e)})},Gne=({children:e,lineNumbers:t=!0,className:n,value:r,...s})=>{const{value:o}=b.useContext(zne);return r!==o?null:u.jsx("div",{className:me(I3n,A3n,k3n,C3n,N3n,T3n,t&&_3n,n),...s,children:e})},Wne=({children:e,themes:t={light:"vitesse-light",dark:"vitesse-dark"},language:n="typescript",syntaxHighlighting:r=!0,...s})=>{const[o,a]=b.useState(""),[i,c]=b.useState(r);return b.useEffect(()=>{if(!r){c(!1);return}(async()=>{try{const{codeToHtml:d}=await c5(async()=>{const{codeToHtml:p}=await import("./index-BESZeTO5.js");return{codeToHtml:p}},[]),f=await d(e,{lang:n,themes:{light:t.light,dark:t.dark}});a(f),c(!1)}catch(d){console.error(`Failed to highlight code for language "${n}":`,d),c(!1)}})()},[e,n,t,r]),!r||i?u.jsx(R3n,{...s,children:e}):u.jsx("div",{dangerouslySetInnerHTML:{__html:o},...s})},sF=b.createContext(null);sF.displayName="PanelGroupContext";const la={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},Kne=10,Fb=b.useLayoutEffect,nwe=sd.useId,j3n=typeof nwe=="function"?nwe:()=>null;let D3n=0;function Zne(e=null){const t=j3n(),n=b.useRef(e||t||null);return n.current===null&&(n.current=""+D3n++),e??n.current}function RGe({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:s,forwardedRef:o,id:a,maxSize:i,minSize:c,onCollapse:l,onExpand:d,onResize:f,order:p,style:h,tagName:g="div",...y}){const E=b.useContext(sF);if(E===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:x,expandPanel:w,getPanelSize:S,getPanelStyle:T,groupId:k,isPanelCollapsed:A,reevaluatePanelConstraints:N,registerPanel:j,resizePanel:O,unregisterPanel:D}=E,L=Zne(a),U=b.useRef({callbacks:{onCollapse:l,onExpand:d,onResize:f},constraints:{collapsedSize:n,collapsible:r,defaultSize:s,maxSize:i,minSize:c},id:L,idIsFromProps:a!==void 0,order:p});b.useRef({didLogMissingDefaultSizeWarning:!1}),Fb(()=>{const{callbacks:M,constraints:$}=U.current,P={...$};U.current.id=L,U.current.idIsFromProps=a!==void 0,U.current.order=p,M.onCollapse=l,M.onExpand=d,M.onResize=f,$.collapsedSize=n,$.collapsible=r,$.defaultSize=s,$.maxSize=i,$.minSize=c,(P.collapsedSize!==$.collapsedSize||P.collapsible!==$.collapsible||P.maxSize!==$.maxSize||P.minSize!==$.minSize)&&N(U.current,P)}),Fb(()=>{const M=U.current;return j(M),()=>{D(M)}},[p,L,j,D]),b.useImperativeHandle(o,()=>({collapse:()=>{x(U.current)},expand:M=>{w(U.current,M)},getId(){return L},getSize(){return S(U.current)},isCollapsed(){return A(U.current)},isExpanded(){return!A(U.current)},resize:M=>{O(U.current,M)}}),[x,w,S,A,L,O]);const B=T(U.current,s);return b.createElement(g,{...y,children:e,className:t,id:L,style:{...B,...h},[la.groupId]:k,[la.panel]:"",[la.panelCollapsible]:r||void 0,[la.panelId]:L,[la.panelSize]:parseFloat(""+B.flexGrow).toFixed(1)})}const jGe=b.forwardRef((e,t)=>b.createElement(RGe,{...e,forwardedRef:t}));RGe.displayName="Panel";jGe.displayName="forwardRef(Panel)";let EY=null,rM=-1,Dg=null;function O3n(e,t,n){const r=(t&$Ge)!==0,s=(t&LGe)!==0,o=(t&FGe)!==0,a=(t&BGe)!==0;if(t){if(r)return o?"se-resize":a?"ne-resize":"e-resize";if(s)return o?"sw-resize":a?"nw-resize":"w-resize";if(o)return"s-resize";if(a)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function M3n(){Dg!==null&&(document.head.removeChild(Dg),EY=null,Dg=null,rM=-1)}function wH(e,t,n){var r,s;const o=O3n(e,t);if(EY!==o){if(EY=o,Dg===null&&(Dg=document.createElement("style"),document.head.appendChild(Dg)),rM>=0){var a;(a=Dg.sheet)===null||a===void 0||a.removeRule(rM)}rM=(r=(s=Dg.sheet)===null||s===void 0?void 0:s.insertRule(`*{cursor: ${o} !important;}`))!==null&&r!==void 0?r:-1}}function DGe(e){return e.type==="keydown"}function OGe(e){return e.type.startsWith("pointer")}function MGe(e){return e.type.startsWith("mouse")}function oF(e){if(OGe(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(MGe(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function P3n(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function $3n(e,t,n){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function L3n(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:owe(e),b:owe(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;br(r,"Stacking order can only be calculated for elements with a common ancestor");const s={a:swe(rwe(n.a)),b:swe(rwe(n.b))};if(s.a===s.b){const o=r.childNodes,a={a:n.a.at(-1),b:n.b.at(-1)};let i=o.length;for(;i--;){const c=o[i];if(c===a.a)return 1;if(c===a.b)return-1}}return Math.sign(s.a-s.b)}const F3n=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function B3n(e){var t;const n=getComputedStyle((t=PGe(e))!==null&&t!==void 0?t:e).display;return n==="flex"||n==="inline-flex"}function q3n(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||B3n(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||F3n.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function rwe(e){let t=e.length;for(;t--;){const n=e[t];if(br(n,"Missing node"),q3n(n))return n}return null}function swe(e){return e&&Number(getComputedStyle(e).zIndex)||0}function owe(e){const t=[];for(;e;)t.push(e),e=PGe(e);return t}function PGe(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const $Ge=1,LGe=2,FGe=4,BGe=8,U3n=P3n()==="coarse";let Vd=[],PE=!1,Og=new Map,aF=new Map;const EN=new Set;function z3n(e,t,n,r,s){var o;const{ownerDocument:a}=t,i={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:s},c=(o=Og.get(a))!==null&&o!==void 0?o:0;return Og.set(a,c+1),EN.add(i),j$(),function(){var d;aF.delete(e),EN.delete(i);const f=(d=Og.get(a))!==null&&d!==void 0?d:1;if(Og.set(a,f-1),j$(),f===1&&Og.delete(a),Vd.includes(i)){const p=Vd.indexOf(i);p>=0&&Vd.splice(p,1),iF(),s("up",!0,null)}}}function H3n(e){const{target:t}=e,{x:n,y:r}=oF(e);PE=!0,Yne({target:t,x:n,y:r}),j$(),Vd.length>0&&(D$("down",e),iF(),e.preventDefault(),qGe(t)||e.stopImmediatePropagation())}function SH(e){const{x:t,y:n}=oF(e);if(PE&&e.type!=="pointerleave"&&e.buttons===0&&(PE=!1,D$("up",e)),!PE){const{target:r}=e;Yne({target:r,x:t,y:n})}D$("move",e),iF(),Vd.length>0&&e.preventDefault()}function _H(e){const{target:t}=e,{x:n,y:r}=oF(e);aF.clear(),PE=!1,Vd.length>0&&(e.preventDefault(),qGe(t)||e.stopImmediatePropagation()),D$("up",e),Yne({target:t,x:n,y:r}),iF(),j$()}function qGe(e){let t=e;for(;t;){if(t.hasAttribute(la.resizeHandle))return!0;t=t.parentElement}return!1}function Yne({target:e,x:t,y:n}){Vd.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),EN.forEach(s=>{const{element:o,hitAreaMargins:a}=s,i=o.getBoundingClientRect(),{bottom:c,left:l,right:d,top:f}=i,p=U3n?a.coarse:a.fine;if(t>=l-p&&t<=d+p&&n>=f-p&&n<=c+p){if(r!==null&&document.contains(r)&&o!==r&&!o.contains(r)&&!r.contains(o)&&L3n(r,o)>0){let g=r,y=!1;for(;g&&!g.contains(o);){if($3n(g.getBoundingClientRect(),i)){y=!0;break}g=g.parentElement}if(y)return}Vd.push(s)}})}function TH(e,t){aF.set(e,t)}function iF(){let e=!1,t=!1;Vd.forEach(r=>{const{direction:s}=r;s==="horizontal"?e=!0:t=!0});let n=0;aF.forEach(r=>{n|=r}),e&&t?wH("intersection",n):e?wH("horizontal",n):t?wH("vertical",n):M3n()}let AH;function j$(){var e;(e=AH)===null||e===void 0||e.abort(),AH=new AbortController;const t={capture:!0,signal:AH.signal};EN.size&&(PE?(Vd.length>0&&Og.forEach((n,r)=>{const{body:s}=r;n>0&&(s.addEventListener("contextmenu",_H,t),s.addEventListener("pointerleave",SH,t),s.addEventListener("pointermove",SH,t))}),Og.forEach((n,r)=>{const{body:s}=r;s.addEventListener("pointerup",_H,t),s.addEventListener("pointercancel",_H,t)})):Og.forEach((n,r)=>{const{body:s}=r;n>0&&(s.addEventListener("pointerdown",H3n,t),s.addEventListener("pointermove",SH,t))}))}function D$(e,t){EN.forEach(n=>{const{setResizeHandlerState:r}=n,s=Vd.includes(n);r(e,s,t)})}function V3n(){const[e,t]=b.useState(0);return b.useCallback(()=>t(n=>n+1),[])}function br(e,t){if(!e)throw console.error(t),Error(t)}function hv(e,t,n=Kne){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function Th(e,t,n=Kne){return hv(e,t,n)===0}function ru(e,t,n){return hv(e,t,n)===0}function G3n(e,t,n){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++){const s=e[r],o=t[r];if(!ru(s,o,n))return!1}return!0}function mE({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];br(r!=null,`Panel constraints not found for index ${t}`);let{collapsedSize:s=0,collapsible:o,maxSize:a=100,minSize:i=0}=r;if(hv(n,i)<0)if(o){const c=(s+i)/2;hv(n,c)<0?n=s:n=i}else n=i;return n=Math.min(a,n),n=parseFloat(n.toFixed(Kne)),n}function qA({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:s,trigger:o}){if(ru(e,0))return t;const a=[...t],[i,c]=r;br(i!=null,"Invalid first pivot index"),br(c!=null,"Invalid second pivot index");let l=0;if(o==="keyboard"){{const f=e<0?c:i,p=n[f];br(p,`Panel constraints not found for index ${f}`);const{collapsedSize:h=0,collapsible:g,minSize:y=0}=p;if(g){const E=t[f];if(br(E!=null,`Previous layout not found for panel index ${f}`),ru(E,h)){const x=y-E;hv(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}{const f=e<0?i:c,p=n[f];br(p,`No panel constraints found for index ${f}`);const{collapsedSize:h=0,collapsible:g,minSize:y=0}=p;if(g){const E=t[f];if(br(E!=null,`Previous layout not found for panel index ${f}`),ru(E,y)){const x=E-h;hv(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}}{const f=e<0?1:-1;let p=e<0?c:i,h=0;for(;;){const y=t[p];br(y!=null,`Previous layout not found for panel index ${p}`);const x=mE({panelConstraints:n,panelIndex:p,size:100})-y;if(h+=x,p+=f,p<0||p>=n.length)break}const g=Math.min(Math.abs(e),Math.abs(h));e=e<0?0-g:g}{let p=e<0?i:c;for(;p>=0&&p<n.length;){const h=Math.abs(e)-Math.abs(l),g=t[p];br(g!=null,`Previous layout not found for panel index ${p}`);const y=g-h,E=mE({panelConstraints:n,panelIndex:p,size:y});if(!ru(g,E)&&(l+=g-E,a[p]=E,l.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?p--:p++}}if(G3n(s,a))return s;{const f=e<0?c:i,p=t[f];br(p!=null,`Previous layout not found for panel index ${f}`);const h=p+l,g=mE({panelConstraints:n,panelIndex:f,size:h});if(a[f]=g,!ru(g,h)){let y=h-g,x=e<0?c:i;for(;x>=0&&x<n.length;){const w=a[x];br(w!=null,`Previous layout not found for panel index ${x}`);const S=w+y,T=mE({panelConstraints:n,panelIndex:x,size:S});if(ru(w,T)||(y-=T-w,a[x]=T),ru(y,0))break;e>0?x--:x++}}}const d=a.reduce((f,p)=>p+f,0);return ru(d,100)?a:s}function W3n({layout:e,panelsArray:t,pivotIndices:n}){let r=0,s=100,o=0,a=0;const i=n[0];br(i!=null,"No pivot index found"),t.forEach((f,p)=>{const{constraints:h}=f,{maxSize:g=100,minSize:y=0}=h;p===i?(r=y,s=g):(o+=y,a+=g)});const c=Math.min(s,100-o),l=Math.max(r,100-a),d=e[i];return{valueMax:c,valueMin:l,valueNow:d}}function wN(e,t=document){return Array.from(t.querySelectorAll(`[${la.resizeHandleId}][data-panel-group-id="${e}"]`))}function UGe(e,t,n=document){const s=wN(e,n).findIndex(o=>o.getAttribute(la.resizeHandleId)===t);return s??null}function zGe(e,t,n){const r=UGe(e,t,n);return r!=null?[r,r+1]:[-1,-1]}function K3n(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function HGe(e,t=document){if(K3n(t)&&t.dataset.panelGroupId==e)return t;const n=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function lF(e,t=document){const n=t.querySelector(`[${la.resizeHandleId}="${e}"]`);return n||null}function Z3n(e,t,n,r=document){var s,o,a,i;const c=lF(t,r),l=wN(e,r),d=c?l.indexOf(c):-1,f=(s=(o=n[d])===null||o===void 0?void 0:o.id)!==null&&s!==void 0?s:null,p=(a=(i=n[d+1])===null||i===void 0?void 0:i.id)!==null&&a!==void 0?a:null;return[f,p]}function Y3n({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:s,panelGroupElement:o,setLayout:a}){b.useRef({didWarnAboutMissingResizeHandle:!1}),Fb(()=>{if(!o)return;const i=wN(n,o);for(let c=0;c<s.length-1;c++){const{valueMax:l,valueMin:d,valueNow:f}=W3n({layout:r,panelsArray:s,pivotIndices:[c,c+1]}),p=i[c];if(p!=null){const h=s[c];br(h,`No panel data found for index "${c}"`),p.setAttribute("aria-controls",h.id),p.setAttribute("aria-valuemax",""+Math.round(l)),p.setAttribute("aria-valuemin",""+Math.round(d)),p.setAttribute("aria-valuenow",f!=null?""+Math.round(f):"")}}return()=>{i.forEach((c,l)=>{c.removeAttribute("aria-controls"),c.removeAttribute("aria-valuemax"),c.removeAttribute("aria-valuemin"),c.removeAttribute("aria-valuenow")})}},[n,r,s,o]),b.useEffect(()=>{if(!o)return;const i=t.current;br(i,"Eager values not found");const{panelDataArray:c}=i,l=HGe(n,o);br(l!=null,`No group found for id "${n}"`);const d=wN(n,o);br(d,`No resize handles found for group id "${n}"`);const f=d.map(p=>{const h=p.getAttribute(la.resizeHandleId);br(h,"Resize handle element has no handle id attribute");const[g,y]=Z3n(n,h,c,o);if(g==null||y==null)return()=>{};const E=x=>{if(!x.defaultPrevented)switch(x.key){case"Enter":{x.preventDefault();const w=c.findIndex(S=>S.id===g);if(w>=0){const S=c[w];br(S,`No panel data found for index ${w}`);const T=r[w],{collapsedSize:k=0,collapsible:A,minSize:N=0}=S.constraints;if(T!=null&&A){const j=qA({delta:ru(T,k)?N-k:k-T,initialLayout:r,panelConstraints:c.map(O=>O.constraints),pivotIndices:zGe(n,h,o),prevLayout:r,trigger:"keyboard"});r!==j&&a(j)}}break}}};return p.addEventListener("keydown",E),()=>{p.removeEventListener("keydown",E)}});return()=>{f.forEach(p=>p())}},[o,e,t,n,r,s,a])}function awe(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function VGe(e,t){const n=e==="horizontal",{x:r,y:s}=oF(t);return n?r:s}function Q3n(e,t,n,r,s){const o=n==="horizontal",a=lF(t,s);br(a,`No resize handle element found for id "${t}"`);const i=a.getAttribute(la.groupId);br(i,"Resize handle element has no group id attribute");let{initialCursorPosition:c}=r;const l=VGe(n,e),d=HGe(i,s);br(d,`No group element found for id "${i}"`);const f=d.getBoundingClientRect(),p=o?f.width:f.height;return(l-c)/p*100}function X3n(e,t,n,r,s,o){if(DGe(e)){const a=n==="horizontal";let i=0;e.shiftKey?i=100:s!=null?i=s:i=10;let c=0;switch(e.key){case"ArrowDown":c=a?0:i;break;case"ArrowLeft":c=a?-i:0;break;case"ArrowRight":c=a?i:0;break;case"ArrowUp":c=a?0:-i;break;case"End":c=100;break;case"Home":c=-100;break}return c}else return r==null?0:Q3n(e,t,n,r,o)}function J3n({panelDataArray:e}){const t=Array(e.length),n=e.map(o=>o.constraints);let r=0,s=100;for(let o=0;o<e.length;o++){const a=n[o];br(a,`Panel constraints not found for index ${o}`);const{defaultSize:i}=a;i!=null&&(r++,t[o]=i,s-=i)}for(let o=0;o<e.length;o++){const a=n[o];br(a,`Panel constraints not found for index ${o}`);const{defaultSize:i}=a;if(i!=null)continue;const c=e.length-r,l=s/c;r++,t[o]=l,s-=l}return t}function y1(e,t,n){t.forEach((r,s)=>{const o=e[s];br(o,`Panel data not found for index ${s}`);const{callbacks:a,constraints:i,id:c}=o,{collapsedSize:l=0,collapsible:d}=i,f=n[c];if(f==null||r!==f){n[c]=r;const{onCollapse:p,onExpand:h,onResize:g}=a;g&&g(r,f),d&&(p||h)&&(h&&(f==null||Th(f,l))&&!Th(r,l)&&h(),p&&(f==null||!Th(f,l))&&Th(r,l)&&p())}})}function vD(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function eBn({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:s,precision:o=3}){const a=n[s];let i;return a==null?i=e!=null?e.toFixed(o):"1":r.length===1?i="1":i=a.toFixed(o),{flexBasis:0,flexGrow:i,flexShrink:1,overflow:"hidden",pointerEvents:t!==null?"none":void 0}}function tBn(e,t=10){let n=null;return(...s)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...s)},t)}}function iwe(e){try{if(typeof localStorage<"u")e.getItem=t=>localStorage.getItem(t),e.setItem=(t,n)=>{localStorage.setItem(t,n)};else throw new Error("localStorage not supported in this environment")}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function GGe(e){return`react-resizable-panels:${e}`}function WGe(e){return e.map(t=>{const{constraints:n,id:r,idIsFromProps:s,order:o}=t;return s?r:o?`${o}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((t,n)=>t.localeCompare(n)).join(",")}function KGe(e,t){try{const n=GGe(e),r=t.getItem(n);if(r){const s=JSON.parse(r);if(typeof s=="object"&&s!=null)return s}}catch{}return null}function nBn(e,t,n){var r,s;const o=(r=KGe(e,n))!==null&&r!==void 0?r:{},a=WGe(t);return(s=o[a])!==null&&s!==void 0?s:null}function rBn(e,t,n,r,s){var o;const a=GGe(e),i=WGe(t),c=(o=KGe(e,s))!==null&&o!==void 0?o:{};c[i]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{s.setItem(a,JSON.stringify(c))}catch(l){console.error(l)}}function lwe({layout:e,panelConstraints:t}){const n=[...e],r=n.reduce((o,a)=>o+a,0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map(o=>`${o}%`).join(", ")}`);if(!ru(r,100)&&n.length>0)for(let o=0;o<t.length;o++){const a=n[o];br(a!=null,`No layout data found for index ${o}`);const i=100/r*a;n[o]=i}let s=0;for(let o=0;o<t.length;o++){const a=n[o];br(a!=null,`No layout data found for index ${o}`);const i=mE({panelConstraints:t,panelIndex:o,size:a});a!=i&&(s+=a-i,n[o]=i)}if(!ru(s,0))for(let o=0;o<t.length;o++){const a=n[o];br(a!=null,`No layout data found for index ${o}`);const i=a+s,c=mE({panelConstraints:t,panelIndex:o,size:i});if(a!==c&&(s-=c-a,n[o]=c,ru(s,0)))break}return n}const sBn=100,UA={getItem:e=>(iwe(UA),UA.getItem(e)),setItem:(e,t)=>{iwe(UA),UA.setItem(e,t)}},cwe={};function ZGe({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:s,id:o=null,onLayout:a=null,keyboardResizeBy:i=null,storage:c=UA,style:l,tagName:d="div",...f}){const p=Zne(o),h=b.useRef(null),[g,y]=b.useState(null),[E,x]=b.useState([]),w=V3n(),S=b.useRef({}),T=b.useRef(new Map),k=b.useRef(0),A=b.useRef({autoSaveId:e,direction:r,dragState:g,id:p,keyboardResizeBy:i,onLayout:a,storage:c}),N=b.useRef({layout:E,panelDataArray:[],panelDataArrayChanged:!1});b.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),b.useImperativeHandle(s,()=>({getId:()=>A.current.id,getLayout:()=>{const{layout:I}=N.current;return I},setLayout:I=>{const{onLayout:J}=A.current,{layout:te,panelDataArray:X}=N.current,ne=lwe({layout:I,panelConstraints:X.map(re=>re.constraints)});awe(te,ne)||(x(ne),N.current.layout=ne,J&&J(ne),y1(X,ne,S.current))}}),[]),Fb(()=>{A.current.autoSaveId=e,A.current.direction=r,A.current.dragState=g,A.current.id=p,A.current.onLayout=a,A.current.storage=c}),Y3n({committedValuesRef:A,eagerValuesRef:N,groupId:p,layout:E,panelDataArray:N.current.panelDataArray,setLayout:x,panelGroupElement:h.current}),b.useEffect(()=>{const{panelDataArray:I}=N.current;if(e){if(E.length===0||E.length!==I.length)return;let J=cwe[e];J==null&&(J=tBn(rBn,sBn),cwe[e]=J);const te=[...I],X=new Map(T.current);J(e,te,X,E,c)}},[e,E,c]),b.useEffect(()=>{});const j=b.useCallback(I=>{const{onLayout:J}=A.current,{layout:te,panelDataArray:X}=N.current;if(I.constraints.collapsible){const ne=X.map(ie=>ie.constraints),{collapsedSize:re=0,panelSize:se,pivotIndices:ce}=B0(X,I,te);if(br(se!=null,`Panel size not found for panel "${I.id}"`),!Th(se,re)){T.current.set(I.id,se);const le=Y1(X,I)===X.length-1?se-re:re-se,oe=qA({delta:le,initialLayout:te,panelConstraints:ne,pivotIndices:ce,prevLayout:te,trigger:"imperative-api"});vD(te,oe)||(x(oe),N.current.layout=oe,J&&J(oe),y1(X,oe,S.current))}}},[]),O=b.useCallback((I,J)=>{const{onLayout:te}=A.current,{layout:X,panelDataArray:ne}=N.current;if(I.constraints.collapsible){const re=ne.map(be=>be.constraints),{collapsedSize:se=0,panelSize:ce=0,minSize:ie=0,pivotIndices:le}=B0(ne,I,X),oe=J??ie;if(Th(ce,se)){const be=T.current.get(I.id),Ee=be!=null&&be>=oe?be:oe,we=Y1(ne,I)===ne.length-1?ce-Ee:Ee-ce,ue=qA({delta:we,initialLayout:X,panelConstraints:re,pivotIndices:le,prevLayout:X,trigger:"imperative-api"});vD(X,ue)||(x(ue),N.current.layout=ue,te&&te(ue),y1(ne,ue,S.current))}}},[]),D=b.useCallback(I=>{const{layout:J,panelDataArray:te}=N.current,{panelSize:X}=B0(te,I,J);return br(X!=null,`Panel size not found for panel "${I.id}"`),X},[]),L=b.useCallback((I,J)=>{const{panelDataArray:te}=N.current,X=Y1(te,I);return eBn({defaultSize:J,dragState:g,layout:E,panelData:te,panelIndex:X})},[g,E]),U=b.useCallback(I=>{const{layout:J,panelDataArray:te}=N.current,{collapsedSize:X=0,collapsible:ne,panelSize:re}=B0(te,I,J);return br(re!=null,`Panel size not found for panel "${I.id}"`),ne===!0&&Th(re,X)},[]),B=b.useCallback(I=>{const{layout:J,panelDataArray:te}=N.current,{collapsedSize:X=0,collapsible:ne,panelSize:re}=B0(te,I,J);return br(re!=null,`Panel size not found for panel "${I.id}"`),!ne||hv(re,X)>0},[]),M=b.useCallback(I=>{const{panelDataArray:J}=N.current;J.push(I),J.sort((te,X)=>{const ne=te.order,re=X.order;return ne==null&&re==null?0:ne==null?-1:re==null?1:ne-re}),N.current.panelDataArrayChanged=!0,w()},[w]);Fb(()=>{if(N.current.panelDataArrayChanged){N.current.panelDataArrayChanged=!1;const{autoSaveId:I,onLayout:J,storage:te}=A.current,{layout:X,panelDataArray:ne}=N.current;let re=null;if(I){const ce=nBn(I,ne,te);ce&&(T.current=new Map(Object.entries(ce.expandToSizes)),re=ce.layout)}re==null&&(re=J3n({panelDataArray:ne}));const se=lwe({layout:re,panelConstraints:ne.map(ce=>ce.constraints)});awe(X,se)||(x(se),N.current.layout=se,J&&J(se),y1(ne,se,S.current))}}),Fb(()=>{const I=N.current;return()=>{I.layout=[]}},[]);const $=b.useCallback(I=>{let J=!1;const te=h.current;return te&&window.getComputedStyle(te,null).getPropertyValue("direction")==="rtl"&&(J=!0),function(ne){ne.preventDefault();const re=h.current;if(!re)return()=>null;const{direction:se,dragState:ce,id:ie,keyboardResizeBy:le,onLayout:oe}=A.current,{layout:be,panelDataArray:Ee}=N.current,{initialLayout:xe}=ce??{},we=zGe(ie,I,re);let ue=X3n(ne,I,se,ce,le,re);const Ie=se==="horizontal";Ie&&J&&(ue=-ue);const Be=Ee.map(Pe=>Pe.constraints),Re=qA({delta:ue,initialLayout:xe??be,panelConstraints:Be,pivotIndices:we,prevLayout:be,trigger:DGe(ne)?"keyboard":"mouse-or-touch"}),Ue=!vD(be,Re);(OGe(ne)||MGe(ne))&&k.current!=ue&&(k.current=ue,!Ue&&ue!==0?Ie?TH(I,ue<0?$Ge:LGe):TH(I,ue<0?FGe:BGe):TH(I,0)),Ue&&(x(Re),N.current.layout=Re,oe&&oe(Re),y1(Ee,Re,S.current))}},[]),P=b.useCallback((I,J)=>{const{onLayout:te}=A.current,{layout:X,panelDataArray:ne}=N.current,re=ne.map(be=>be.constraints),{panelSize:se,pivotIndices:ce}=B0(ne,I,X);br(se!=null,`Panel size not found for panel "${I.id}"`);const le=Y1(ne,I)===ne.length-1?se-J:J-se,oe=qA({delta:le,initialLayout:X,panelConstraints:re,pivotIndices:ce,prevLayout:X,trigger:"imperative-api"});vD(X,oe)||(x(oe),N.current.layout=oe,te&&te(oe),y1(ne,oe,S.current))},[]),q=b.useCallback((I,J)=>{const{layout:te,panelDataArray:X}=N.current,{collapsedSize:ne=0,collapsible:re}=J,{collapsedSize:se=0,collapsible:ce,maxSize:ie=100,minSize:le=0}=I.constraints,{panelSize:oe}=B0(X,I,te);oe!=null&&(re&&ce&&Th(oe,ne)?Th(ne,se)||P(I,se):oe<le?P(I,le):oe>ie&&P(I,ie))},[P]),z=b.useCallback((I,J)=>{const{direction:te}=A.current,{layout:X}=N.current;if(!h.current)return;const ne=lF(I,h.current);br(ne,`Drag handle element not found for id "${I}"`);const re=VGe(te,J);y({dragHandleId:I,dragHandleRect:ne.getBoundingClientRect(),initialCursorPosition:re,initialLayout:X})},[]),G=b.useCallback(()=>{y(null)},[]),R=b.useCallback(I=>{const{panelDataArray:J}=N.current,te=Y1(J,I);te>=0&&(J.splice(te,1),delete S.current[I.id],N.current.panelDataArrayChanged=!0,w())},[w]),W=b.useMemo(()=>({collapsePanel:j,direction:r,dragState:g,expandPanel:O,getPanelSize:D,getPanelStyle:L,groupId:p,isPanelCollapsed:U,isPanelExpanded:B,reevaluatePanelConstraints:q,registerPanel:M,registerResizeHandle:$,resizePanel:P,startDragging:z,stopDragging:G,unregisterPanel:R,panelGroupElement:h.current}),[j,g,r,O,D,L,p,U,B,q,M,$,P,z,G,R]),V={display:"flex",flexDirection:r==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return b.createElement(sF.Provider,{value:W},b.createElement(d,{...f,children:t,className:n,id:o,ref:h,style:{...V,...l},[la.group]:"",[la.groupDirection]:r,[la.groupId]:p}))}const YGe=b.forwardRef((e,t)=>b.createElement(ZGe,{...e,forwardedRef:t}));ZGe.displayName="PanelGroup";YGe.displayName="forwardRef(PanelGroup)";function Y1(e,t){return e.findIndex(n=>n===t||n.id===t.id)}function B0(e,t,n){const r=Y1(e,t),o=r===e.length-1?[r-1,r]:[r,r+1],a=n[r];return{...t.constraints,panelSize:a,pivotIndices:o}}function oBn({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){b.useEffect(()=>{if(e||n==null||r==null)return;const s=lF(t,r);if(s==null)return;const o=a=>{if(!a.defaultPrevented)switch(a.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{a.preventDefault(),n(a);break}case"F6":{a.preventDefault();const i=s.getAttribute(la.groupId);br(i,`No group element found for id "${i}"`);const c=wN(i,r),l=UGe(i,t,r);br(l!==null,`No resize element found for id "${t}"`);const d=a.shiftKey?l>0?l-1:c.length-1:l+1<c.length?l+1:0;c[d].focus();break}}};return s.addEventListener("keydown",o),()=>{s.removeEventListener("keydown",o)}},[r,e,t,n])}function QGe({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:s,onBlur:o,onClick:a,onDragging:i,onFocus:c,onPointerDown:l,onPointerUp:d,style:f={},tabIndex:p=0,tagName:h="div",...g}){var y,E;const x=b.useRef(null),w=b.useRef({onClick:a,onDragging:i,onPointerDown:l,onPointerUp:d});b.useEffect(()=>{w.current.onClick=a,w.current.onDragging=i,w.current.onPointerDown=l,w.current.onPointerUp=d});const S=b.useContext(sF);if(S===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:T,groupId:k,registerResizeHandle:A,startDragging:N,stopDragging:j,panelGroupElement:O}=S,D=Zne(s),[L,U]=b.useState("inactive"),[B,M]=b.useState(!1),[$,P]=b.useState(null),q=b.useRef({state:L});Fb(()=>{q.current.state=L}),b.useEffect(()=>{if(n)P(null);else{const W=A(D);P(()=>W)}},[n,D,A]);const z=(y=r?.coarse)!==null&&y!==void 0?y:15,G=(E=r?.fine)!==null&&E!==void 0?E:5;b.useEffect(()=>{if(n||$==null)return;const W=x.current;br(W,"Element ref not attached");let V=!1;return z3n(D,W,T,{coarse:z,fine:G},(J,te,X)=>{if(!te){U("inactive");return}switch(J){case"down":{U("drag"),V=!1,br(X,'Expected event to be defined for "down" action'),N(D,X);const{onDragging:ne,onPointerDown:re}=w.current;ne?.(!0),re?.();break}case"move":{const{state:ne}=q.current;V=!0,ne!=="drag"&&U("hover"),br(X,'Expected event to be defined for "move" action'),$(X);break}case"up":{U("hover"),j();const{onClick:ne,onDragging:re,onPointerUp:se}=w.current;re?.(!1),se?.(),V||ne?.();break}}})},[z,T,n,G,A,D,$,N,j]),oBn({disabled:n,handleId:D,resizeHandler:$,panelGroupElement:O});const R={touchAction:"none",userSelect:"none"};return b.createElement(h,{...g,children:e,className:t,id:s,onBlur:()=>{M(!1),o?.()},onFocus:()=>{M(!0),c?.()},ref:x,role:"separator",style:{...R,...f},tabIndex:p,[la.groupDirection]:T,[la.groupId]:k,[la.resizeHandle]:"",[la.resizeHandleActive]:L==="drag"?"pointer":B?"keyboard":void 0,[la.resizeHandleEnabled]:!n,[la.resizeHandleId]:D,[la.resizeHandleState]:L})}QGe.displayName="PanelResizeHandle";const cF=({className:e,...t})=>u.jsx(YGe,{className:me("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...t}),rp=jGe,kw=({className:e,...t})=>u.jsx(QGe,{className:me("group/handle relative flex w-4 items-center justify-center shrink-0 focus-visible:outline-hidden",e),...t,children:u.jsx("div",{className:"h-8 w-1 rounded-full bg-muted-foreground/15 transition-all duration-150 group-hover/handle:h-16 group-hover/handle:bg-muted-foreground/30 group-data-[resize-handle-state=drag]/handle:h-16 group-data-[resize-handle-state=drag]/handle:bg-muted-foreground/50"})}),XGe={lifecycleNudge:"Conversation Nudge",lifecycleExpire:"Conversation Expired"};function hR(e){return typeof e=="string"&&e in XGe}function JGe(e){return hR(e)?XGe[e]:"Lifecycle Event"}function aBn(e){const t=new Map;for(const s of e)if(s.id.parent){const o=t.get(s.id.parent)??[];o.push(s),t.set(s.id.parent,o)}for(const s of t.values())s.sort((o,a)=>o.timing.startedAt-a.timing.startedAt);const n=new Map;for(const s of e){const o=n.get(s.id.trace)??[];o.push(s),n.set(s.id.trace,o)}const r=[];for(const[s,o]of n){const a=o.find(A=>A.name==="request.incoming"),i=o.filter(A=>A.name==="handler.conversation"||A.name==="handler.event"||A.name==="handler.trigger"),c=i.find(A=>A.name==="handler.trigger"),l=i.find(A=>A.name==="handler.conversation"),d=i.find(A=>A.name==="handler.event"),f=c??l??d,p=a?String(a.data["message.preview"]??""):void 0,h=d?String(d.data["event.type"]||"unknown event"):void 0,g=hR(h),y=c?String(c.data["trigger.name"]||c.data["event.type"]||"Trigger"):void 0,E=[],x=[],w=[],S=A=>{const N=t.get(A)??[];for(const j of N)if(j.name==="autonomous.iteration")E.push(j);else if(j.name==="autonomous.execution")S(j.id.span);else if(j.name==="chat.sendMessage")x.push(j);else if(j.name==="state.saveAllDirty"){const O=t.get(j.id.span)??[];for(const D of O)if(D.name==="state.save"){const U=D.data["state.changed_keys"];U&&U.length>0&&w.push(D)}}};for(const A of i)S(A.id.span);a&&S(a.id.span);const T=[];let k=0;for(const A of E){const N=t.get(A.id.span)??[],j=N.filter(L=>L.name==="autonomous.tool"),O=N.filter(L=>L.name==="chat.sendMessage"),D=N.find(L=>L.name==="cognitive.request");if(D){const L=D.data["ai.cost"];L&&(k+=Number(L))}T.push({iteration:A,tools:j,messages:O,cognitive:D})}f?.name==="handler.event"&&!c&&!l&&!p&&!g||r.push({traceId:s,userMessage:p,eventType:h,triggerName:y,handler:f,steps:T,directMessages:x,stateMutations:w,totalCost:k})}return r.sort((s,o)=>{const a=s.handler?.timing.startedAt??s.steps[0]?.iteration.timing.startedAt??0,i=o.handler?.timing.startedAt??o.steps[0]?.iteration.timing.startedAt??0;return a-i}),r}function iBn(e,t){if(!e)return null;if(e.type==="step"){for(const n of t){const r=n.steps.find(s=>s.iteration.id.span===e.iterationSpanId);if(r)return{type:"step",step:r}}return null}for(const n of t){if(n.handler?.id.span!==e.spanId)continue;if(n.handler.name==="handler.trigger")return{type:"trigger",span:n.handler};const r=n.handler.data["event.type"];if(n.handler.name==="handler.event"&&hR(r))return{type:"lifecycle",span:n.handler}}return null}function eWe({conversationId:e,className:t}){const n=e.trim().length>0,{traces:r}=IGe({filters:{conversationId:n?e:void 0},autoRefresh:n,hideUnimportant:!1}),s=b.useMemo(()=>aBn(r),[r]),[o,a]=b.useState(()=>{try{const N=localStorage.getItem("agent-steps-collapsed-cards");return N?new Set(JSON.parse(N)):new Set}catch{return new Set}}),i=b.useCallback(N=>{a(j=>{const O=new Set(j);O.has(N)?O.delete(N):O.add(N);try{localStorage.setItem("agent-steps-collapsed-cards",JSON.stringify([...O]))}catch{}return O})},[]),c=b.useMemo(()=>{const N=[];for(const j of s){if((j.userMessage||j.eventType)&&N.push(`user-${j.traceId}`),j.handler){const O=j.handler.data["event.type"],D=j.handler.name==="handler.trigger",L=j.handler.name==="handler.event"&&hR(O);D||L?N.push(j.handler.id.span):N.push(`bot-${j.handler.id.span}`)}for(const O of j.steps)N.push(O.iteration.id.span);for(const O of j.directMessages)N.push(O.id.span);for(const O of j.stateMutations)N.push(O.id.span)}return N},[s]),l=b.useCallback(()=>{const N=new Set(c);a(N);try{localStorage.setItem("agent-steps-collapsed-cards",JSON.stringify([...N]))}catch{}},[c]),d=b.useCallback(()=>{a(new Set);try{localStorage.removeItem("agent-steps-collapsed-cards")}catch{}},[]),[f,p]=b.useState(null),h=b.useMemo(()=>iBn(f,s),[f,s]),[g,y]=b.useState(!1),E=b.useRef(null),x=b.useCallback(N=>{f&&(N.type==="step"&&f.type==="step"&&N.iterationSpanId===f.iterationSpanId||N.type==="span"&&f.type==="span"&&N.spanId===f.spanId)?p(null):(f&&(y(!0),setTimeout(()=>y(!1),200)),p(N),T.current=N.type==="step"?N.iterationSpanId:N.spanId)},[f]);b.useEffect(()=>{const N=E.current;if(N)if(h){if(N.isCollapsed()){let j=35;try{const O=Number(localStorage.getItem("agent-steps-detail-size"));O>=20&&O<=50&&(j=O)}catch{}N.resize(j)}}else N.isExpanded()&&N.collapse()},[h]);const w=b.useRef(null),S=b.useRef(null),T=b.useRef(null),k=b.useRef(new Set),A=w.current;return A&&(S.current={scrollTop:A.scrollTop,scrollHeight:A.scrollHeight,clientHeight:A.clientHeight}),b.useEffect(()=>{const N=S.current;!N||!(N.scrollHeight-N.scrollTop-N.clientHeight<1)||requestAnimationFrame(()=>{const O=w.current;O&&(O.scrollTop=O.scrollHeight)})},[r]),b.useEffect(()=>{const N=T.current;N&&(T.current=null,requestAnimationFrame(()=>{const j=w.current,O=j?.querySelector(`[data-span-id="${N}"]`);if(j&&O){const D=O.getBoundingClientRect(),L=j.getBoundingClientRect();let U=0;for(const B of j.querySelectorAll(".sticky"))U=Math.max(U,B.offsetHeight);j.scrollTop+=D.top-L.top-U}}))},[f]),u.jsxs("div",{className:me("flex flex-col h-full",t),children:[u.jsx(lBn,{conversationId:e,turns:s,onCollapseAll:l,onExpandAll:d,isAllCollapsed:c.length>0&&c.every(N=>o.has(N))}),s.length===0?u.jsx("div",{className:"flex-1 flex items-center justify-center",children:u.jsx("span",{className:"small",children:"Waiting for agent activity..."})}):u.jsx(u.Fragment,{children:u.jsxs(cF,{direction:"horizontal",className:"flex-1 min-h-0",children:[u.jsx(rp,{order:1,minSize:30,children:u.jsx("div",{ref:w,className:"h-full overflow-y-auto text-sm",children:u.jsx("div",{className:"px-4 py-3 space-y-4",children:s.map(N=>u.jsx(hBn,{turn:N,onSelect:x,collapsedCards:o,toggleCard:i,seenSpans:k.current},N.traceId))})})}),u.jsx(kw,{className:"w-0 after:w-2!"}),u.jsx(rp,{ref:E,order:2,defaultSize:0,minSize:20,maxSize:50,collapsible:!0,collapsedSize:0,className:me(g&&"animate-detail-flash"),onResize:()=>{const N=E.current;if(N&&!N.isCollapsed())try{localStorage.setItem("agent-steps-detail-size",String(N.getSize()))}catch{}},children:h&&u.jsx("div",{className:"h-full overflow-y-auto bg-background-elevated rounded-md m-2 ml-0",children:u.jsx(TBn,{detail:h,onClose:()=>p(null)})})})]})})]})}function lBn({conversationId:e,turns:t,onCollapseAll:n,onExpandAll:r,isAllCollapsed:s}){const o=t.reduce((c,l)=>c+l.totalCost,0),a=t.reduce((c,l)=>{for(const d of l.steps)if(d.cognitive){const f=d.cognitive.data["ai.tokens"];f&&(c+=Number(f))}return c},0),i=t.reduce((c,l)=>c+l.directMessages.length+l.steps.reduce((d,f)=>d+f.messages.length,0)+(l.userMessage?1:0),0);return u.jsxs("div",{className:"shrink-0 px-4 pt-0 pb-2",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("span",{className:"text-sm font-medium text-foreground",children:"Agent Steps"}),u.jsx("div",{className:"flex-1"}),t.length>0&&u.jsxs(vn,{children:[u.jsx(xn,{asChild:!0,children:u.jsx("button",{type:"button",className:"p-1 rounded-sm text-muted-foreground/40 hover:text-muted-foreground hover:bg-muted transition-colors",onClick:s?r:n,children:s?u.jsx(cCt,{className:"size-3.5"}):u.jsx(iCt,{className:"size-3.5"})})}),u.jsx(yn,{children:s?"Expand all":"Collapse all"})]}),e&&u.jsxs(Fc,{to:`/traces?conversationId=${encodeURIComponent(e)}`,className:"inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md border border-muted-foreground/15 text-xs text-muted-foreground hover:text-foreground hover:border-muted-foreground/30 transition-colors",children:[u.jsx(tc,{className:"size-3"}),"Open conversation traces"]})]}),(i>0||a>0||o>0)&&u.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[i>0&&u.jsxs("span",{className:"small text-muted-foreground/50",children:[i," message",i!==1?"s":""]}),a>0&&u.jsxs("span",{className:"small text-muted-foreground/50",children:[a.toLocaleString()," tokens"]}),o>0&&u.jsxs("span",{className:"small text-muted-foreground/50",children:["$",o.toFixed(4)]})]})]})}function cBn({value:e,className:t}){const[n,r]=b.useState(!1);return u.jsx("button",{type:"button",className:me("p-1 rounded-sm hover:bg-muted transition-colors text-muted-foreground/50 hover:text-foreground",t),onClick:s=>{s.stopPropagation(),navigator.clipboard.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),1500)}).catch(()=>{})},children:n?u.jsx(Xr,{className:"size-3 text-green-500"}):u.jsx(li,{className:"size-3"})})}function uBn(){const[e,t]=b.useState(()=>{try{const r=localStorage.getItem("step-detail-collapsed");return r?new Set(JSON.parse(r)):new Set}catch{return new Set}}),n=b.useCallback(r=>{t(s=>{const o=new Set(s);o.has(r)?o.delete(r):o.add(r);try{localStorage.setItem("step-detail-collapsed",JSON.stringify([...o]))}catch{}return o})},[]);return{collapsed:e,toggle:n}}function r0({status:e}){switch(e){case"ok":return u.jsx(Ms,{className:"size-3 text-green-500 shrink-0"});case"error":return u.jsx(yl,{className:"size-3 text-red-500 shrink-0"});case"running":return u.jsx(nn,{className:"size-3 text-blue-500 animate-spin shrink-0"});default:return u.jsx(id,{className:"size-3 text-muted-foreground/50 shrink-0"})}}function mf({span:e}){return e.status==="running"?u.jsx(dBn,{startedAt:e.timing.startedAt}):u.jsxs("span",{className:"flex items-center gap-0.5 small text-muted-foreground/50",children:[u.jsx(id,{className:"size-2.5"}),RBn(e)]})}function dBn({startedAt:e}){const[,t]=b.useState(0);b.useEffect(()=>{const s=setInterval(()=>t(o=>o+1),100);return()=>clearInterval(s)},[]);const n=Date.now()-e,r=n<1e3?`${Math.round(n)}ms`:`${(n/1e3).toFixed(1)}s`;return u.jsxs("span",{className:"flex items-center gap-0.5 small text-blue-500 tabular-nums",children:[u.jsx(id,{className:"size-2.5"}),r]})}function tWe({status:e}){return u.jsx("span",{className:me("caption px-1.5 py-0.5 rounded-sm",e==="ok"?"bg-green-500/10 text-green-400":e==="error"?"bg-red-500/10 text-red-400":e==="running"?"bg-blue-500/10 text-blue-400":"bg-muted text-muted-foreground"),children:e})}function nWe(){return u.jsxs("div",{className:"relative overflow-hidden bg-background-elevated p-2 rounded-md",children:[u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("div",{className:"h-3 w-full rounded-sm bg-muted-foreground/10"}),u.jsx("div",{className:"h-3 w-2/3 rounded-sm bg-muted-foreground/10"})]}),u.jsx("div",{className:"absolute inset-0 -translate-x-full animate-shimmer bg-linear-to-r from-transparent via-muted-foreground/5 to-transparent"})]})}function rWe(){return u.jsxs("div",{className:"relative overflow-hidden py-0.5",children:[u.jsxs("div",{className:"space-y-2",children:[u.jsx("div",{className:"h-3 w-full rounded-sm bg-muted-foreground/10"}),u.jsx("div",{className:"h-3 w-5/6 rounded-sm bg-muted-foreground/10"}),u.jsx("div",{className:"h-3 w-2/3 rounded-sm bg-muted-foreground/10"})]}),u.jsx("div",{className:"absolute inset-0 -translate-x-full animate-shimmer bg-linear-to-r from-transparent via-muted-foreground/5 to-transparent"})]})}function fBn(){return u.jsxs("div",{className:"relative overflow-hidden",children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("div",{className:"size-5 rounded-sm bg-muted-foreground/10 shrink-0"}),u.jsx("div",{className:"h-3 w-28 rounded-sm bg-muted-foreground/10"}),u.jsx("div",{className:"flex-1"}),u.jsx("div",{className:"h-3 w-12 rounded-sm bg-muted-foreground/10"})]}),u.jsx("div",{className:"absolute inset-0 -translate-x-full animate-shimmer bg-linear-to-r from-transparent via-muted-foreground/5 to-transparent"})]})}function pBn({cognitive:e}){if(!e)return null;const t=e.data,n=t["ai.input_tokens"],r=t["ai.output_tokens"],s=t["ai.cost"];return e.status==="running"?u.jsx("span",{className:"small text-muted-foreground/30 thinking-shimmer",children:"thinking..."}):!n&&!r&&s==null?null:u.jsxs("span",{className:"small flex items-center gap-1.5 text-muted-foreground/50",children:[(n!=null||r!=null)&&u.jsxs("span",{children:[String(n??"?")," in → ",String(r??"?")," out"]}),s!=null&&u.jsxs("span",{children:["$",Number(s).toFixed(4)]})]})}function sp({isLast:e=!1,children:t}){return u.jsxs("div",{className:"relative pl-5 pb-3",children:[!e&&u.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-[1.5px] bg-[hsl(var(--tree-line))]"}),u.jsx("div",{className:"absolute left-0 top-0 h-4 w-5 border-l-[1.5px] border-b-[1.5px] border-[hsl(var(--tree-line))] rounded-bl-md"}),u.jsx("div",{className:"pt-2",children:t})]})}function rx({open:e,children:t}){return u.jsx("div",{className:"accordion-body","data-open":e,children:u.jsx("div",{children:t})})}function US(e,t){if(!e.has(t))return e.add(t),"animate-slide-in"}function hBn({turn:e,onSelect:t,collapsedCards:n,toggleCard:r,seenSpans:s}){const o=e.handler?.name==="handler.trigger",a=e.handler?String(e.handler.data["event.type"]||""):"",i=e.handler?.name==="handler.event"&&hR(a);return u.jsx("div",{className:"space-y-3",children:o?u.jsx(mBn,{turn:e,onSelect:t,collapsedCards:n,toggleCard:r,seenSpans:s}):i?u.jsx(gBn,{turn:e,onSelect:t,collapsedCards:n,toggleCard:r,seenSpans:s}):u.jsxs(u.Fragment,{children:[e.userMessage?u.jsx(uwe,{message:e.userMessage,collapseId:`user-${e.traceId}`,collapsedCards:n,toggleCard:r,seenSpans:s}):e.eventType?u.jsx(uwe,{message:e.eventType,isEvent:!0,eventLabel:e.eventType==="workflowNotify"?"Workflow Progress":"User Triggered Event",collapseId:`user-${e.traceId}`,collapsedCards:n,toggleCard:r,seenSpans:s}):null,e.handler&&u.jsx(yBn,{handler:e.handler,steps:e.steps,directMessages:e.directMessages,stateMutations:e.stateMutations,totalCost:e.totalCost,onSelect:t,collapsedCards:n,toggleCard:r,seenSpans:s})]})})}function uwe({message:e,isEvent:t,eventLabel:n,collapseId:r,collapsedCards:s,toggleCard:o}){const a=s.has(r);return u.jsxs("div",{children:[u.jsxs("div",{className:me("flex items-center gap-2",a&&"cursor-pointer hover:opacity-80 transition-opacity duration-quick"),onClick:a?()=>o(r):void 0,children:[u.jsx("div",{className:"size-5 rounded-md bg-slate-500 flex items-center justify-center shrink-0 ring-[3px] ring-[hsl(var(--tree-line))]",children:u.jsx(IJ,{className:"size-3 text-background"})}),u.jsx("span",{className:"caption",children:t?n||"User Triggered Event":"User"}),a&&u.jsx("span",{className:"small text-muted-foreground/50 truncate",children:e.length>60?e.slice(0,60)+"...":e}),u.jsx("button",{type:"button",className:"text-muted-foreground/50 hover:text-foreground shrink-0",onClick:i=>{i.stopPropagation(),o(r)},children:a?u.jsx(cs,{className:"size-3"}):u.jsx(Dr,{className:"size-3"})})]}),u.jsx(rx,{open:!a,children:u.jsx("div",{className:"ml-[9px]",children:u.jsx(sp,{isLast:!0,children:u.jsx(bBn,{message:e,isEvent:t})})})})]})}function mBn({turn:e,onSelect:t,collapsedCards:n,toggleCard:r,seenSpans:s}){const o=e.handler,a=o.data,i=e.triggerName||"Trigger",c=String(a["event.type"]||""),l=e.steps.length>0||e.directMessages.length>0||e.stateMutations.length>0,d=n.has(o.id.span);return u.jsxs("div",{"data-span-id":o.id.span,className:US(s,o.id.span),children:[u.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1.5 bg-amber-500/10 rounded-md cursor-pointer hover:bg-amber-500/15 transition-colors duration-quick",onClick:()=>{if(d&&l){r(o.id.span);return}t({type:"span",spanId:o.id.span})},children:[u.jsx("div",{className:"size-5 rounded-md bg-amber-500/20 flex items-center justify-center shrink-0",children:u.jsx(Sa,{className:"size-3 text-amber-500"})}),u.jsx("span",{className:"caption text-foreground font-semibold",children:i}),c&&c!==i&&u.jsx("span",{className:"small text-muted-foreground/50",children:c}),l&&u.jsx("button",{type:"button",className:"text-muted-foreground/50 hover:text-foreground shrink-0",onClick:f=>{f.stopPropagation(),r(o.id.span)},children:d?u.jsx(cs,{className:"size-3"}):u.jsx(Dr,{className:"size-3"})}),u.jsx("div",{className:"flex-1"}),u.jsx(mf,{span:o}),u.jsx(r0,{status:o.status})]}),u.jsx(rx,{open:!d,children:l?u.jsxs("div",{className:"ml-[9px]",children:[e.directMessages.map((f,p)=>u.jsx(sp,{isLast:e.steps.length===0&&e.stateMutations.length===0&&p===e.directMessages.length-1,children:u.jsx(Xne,{span:f,collapsedCards:n,toggleCard:r,seenSpans:s})},f.id.span)),e.steps.map((f,p)=>u.jsx(sp,{isLast:p===e.steps.length-1&&e.stateMutations.length===0,children:u.jsx(Qne,{step:f,onSelect:t,collapsedCards:n,toggleCard:r,seenSpans:s})},f.iteration.id.span)),e.stateMutations.map((f,p)=>u.jsx(sp,{isLast:p===e.stateMutations.length-1,children:u.jsx(Jne,{span:f,collapsedCards:n,toggleCard:r,seenSpans:s})},f.id.span))]}):u.jsx("div",{className:"px-2.5 py-1.5",children:o.status==="running"?u.jsx("span",{className:"small thinking-shimmer",children:"Evaluating trigger..."}):o.status==="error"?u.jsx("span",{className:"small text-red-400",children:"Trigger failed"}):u.jsx("span",{className:"small text-muted-foreground/50",children:"Trigger evaluated"})})})]})}function gBn({turn:e,onSelect:t,collapsedCards:n,toggleCard:r,seenSpans:s}){const o=e.handler,a=o.data,i=String(a["event.type"]||""),c=JGe(i),l=e.steps.length>0||e.directMessages.length>0||e.stateMutations.length>0,d=n.has(o.id.span);return u.jsxs("div",{"data-span-id":o.id.span,className:US(s,o.id.span),children:[u.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1.5 bg-purple-500/10 rounded-md cursor-pointer hover:bg-purple-500/15 transition-colors duration-quick",onClick:()=>{if(d&&l){r(o.id.span);return}t({type:"span",spanId:o.id.span})},children:[u.jsx("div",{className:"size-5 rounded-md bg-purple-500/20 flex items-center justify-center shrink-0",children:u.jsx(id,{className:"size-3 text-purple-400"})}),u.jsx("span",{className:"caption text-foreground font-semibold",children:c}),i&&u.jsx("span",{className:"small text-muted-foreground/50",children:i}),l&&u.jsx("button",{type:"button",className:"text-muted-foreground/50 hover:text-foreground shrink-0",onClick:f=>{f.stopPropagation(),r(o.id.span)},children:d?u.jsx(cs,{className:"size-3"}):u.jsx(Dr,{className:"size-3"})}),u.jsx("div",{className:"flex-1"}),u.jsx(mf,{span:o}),u.jsx(r0,{status:o.status})]}),u.jsx(rx,{open:!d,children:l?u.jsxs("div",{className:"ml-[9px]",children:[e.directMessages.map((f,p)=>u.jsx(sp,{isLast:e.steps.length===0&&e.stateMutations.length===0&&p===e.directMessages.length-1,children:u.jsx(Xne,{span:f,collapsedCards:n,toggleCard:r,seenSpans:s})},f.id.span)),e.steps.map((f,p)=>u.jsx(sp,{isLast:p===e.steps.length-1&&e.stateMutations.length===0,children:u.jsx(Qne,{step:f,onSelect:t,collapsedCards:n,toggleCard:r,seenSpans:s})},f.iteration.id.span)),e.stateMutations.map((f,p)=>u.jsx(sp,{isLast:p===e.stateMutations.length-1,children:u.jsx(Jne,{span:f,collapsedCards:n,toggleCard:r,seenSpans:s})},f.id.span))]}):u.jsx("div",{className:"px-2.5 py-1.5",children:o.status==="running"?u.jsx("span",{className:"small thinking-shimmer",children:"Handling lifecycle event..."}):o.status==="error"?u.jsx("span",{className:"small text-red-400",children:"Lifecycle event failed"}):u.jsx("span",{className:"small text-muted-foreground/50",children:"Lifecycle event handled"})})})]})}function yBn({handler:e,steps:t,directMessages:n,stateMutations:r,totalCost:s,onSelect:o,collapsedCards:a,toggleCard:i,seenSpans:c}){const l=t.length>0||n.length>0||r.length>0,d=`bot-${e.id.span}`,f=a.has(d);return u.jsxs("div",{className:US(c,e.id.span),children:[u.jsxs("div",{className:"flex items-center gap-2 cursor-pointer hover:opacity-80 transition-opacity duration-quick sticky top-0 z-10 bg-background",onClick:()=>{if(f){i(d);return}const p=t[t.length-1];p&&o({type:"step",iterationSpanId:p.iteration.id.span})},children:[u.jsx("div",{className:"size-5 rounded-md bg-sidebar-primary flex items-center justify-center shrink-0 p-1 ring-[3px] ring-[hsl(var(--tree-line))]",children:u.jsx("img",{src:"/ADK.svg",alt:"ADK",className:"size-full invert"})}),u.jsx("span",{className:"caption",children:"Bot"}),s>0&&u.jsxs("span",{className:"small text-muted-foreground/50",children:["$",s.toFixed(4)]}),u.jsx(mf,{span:e}),f&&u.jsxs("span",{className:"small text-muted-foreground/50",children:[t.length," iteration",t.length!==1?"s":""]}),u.jsx("button",{type:"button",className:"text-muted-foreground/50 hover:text-foreground shrink-0",onClick:p=>{p.stopPropagation(),i(d)},children:f?u.jsx(cs,{className:"size-3"}):u.jsx(Dr,{className:"size-3"})})]}),u.jsx(rx,{open:!f,children:l?u.jsxs("div",{className:"ml-[9px]",children:[n.map((p,h)=>u.jsx(sp,{isLast:t.length===0&&r.length===0&&h===n.length-1,children:u.jsx(Xne,{span:p,collapsedCards:a,toggleCard:i,seenSpans:c})},p.id.span)),t.map((p,h)=>u.jsx(sp,{isLast:h===t.length-1&&r.length===0,children:u.jsx(Qne,{step:p,onSelect:o,collapsedCards:a,toggleCard:i,seenSpans:c})},p.iteration.id.span)),r.map((p,h)=>u.jsx(sp,{isLast:h===r.length-1,children:u.jsx(Jne,{span:p,collapsedCards:a,toggleCard:i,seenSpans:c})},p.id.span))]}):u.jsx("div",{className:"ml-3 pl-5 py-1",children:e.status==="running"?u.jsx("span",{className:"small thinking-shimmer",children:"Processing..."}):u.jsx("span",{className:"small text-muted-foreground/50",children:"No steps"})})})]})}function bBn({message:e,isEvent:t}){return u.jsxs("div",{className:"border border-blue-500/20 rounded-md px-3 py-2 bg-blue-500/10 body leading-relaxed text-foreground",children:[t&&u.jsx("span",{className:"code text-muted-foreground/50 block mb-1",children:"event"}),e]})}function Qne({step:e,onSelect:t,collapsedCards:n,toggleCard:r,seenSpans:s}){const o=e.iteration.data,a=o["autonomous.iteration"],i=o["autonomous.exit.name"],c=e.iteration.status==="running",l=e.iteration.status==="error"?"errored":i||"continued",d=!n.has(e.iteration.id.span),f=e.tools.length>0||e.messages.length>0;return u.jsxs("div",{"data-span-id":e.iteration.id.span,className:me("border rounded-md overflow-hidden cursor-pointer transition-colors duration-quick",US(s,e.iteration.id.span),c?"border-blue-500/40":"border-border/50 hover:border-border hover:bg-background-elevated"),onClick:()=>{if(!d){r(e.iteration.id.span);return}t({type:"step",iterationSpanId:e.iteration.id.span})},children:[u.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1.5 bg-muted/20",children:[u.jsxs("span",{className:me("caption text-foreground font-semibold",c&&"thinking-shimmer"),children:["LLM Iteration",a!=null?` ${Number(a)+1}`:""]}),!c&&u.jsx("span",{className:"small text-muted-foreground/50",children:l}),f&&u.jsx("button",{type:"button",className:"text-muted-foreground/50 hover:text-foreground shrink-0",onClick:p=>{p.stopPropagation(),r(e.iteration.id.span)},children:d?u.jsx(Dr,{className:"size-3"}):u.jsx(cs,{className:"size-3"})}),u.jsx("div",{className:"flex-1"}),u.jsx(pBn,{cognitive:e.cognitive}),u.jsx(mf,{span:e.iteration}),u.jsx(r0,{status:e.iteration.status})]}),u.jsx(rx,{open:d,children:u.jsxs("div",{className:"divide-y divide-border/30",children:[e.tools.map(p=>u.jsx(vBn,{span:p},p.id.span)),e.messages.map(p=>u.jsx("div",{className:"px-2.5 py-2 bg-blue-500/10 animate-fade-in",children:u.jsx(wBn,{span:p})},p.id.span)),c&&!f&&u.jsx("div",{className:"px-2.5 py-2",children:u.jsx(fBn,{})})]})})]})}function Xne({span:e,collapsedCards:t,toggleCard:n,seenSpans:r}){const s=t.has(e.id.span),o=e.data,a=o["message.preview"]!=null,i=e.status==="running",[c,l]=b.useState(!1),d=a&&String(o["message.preview"]).length>aWe;return u.jsxs("div",{className:me("rounded-md bg-blue-500/10",US(r,e.id.span)),children:[u.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-2",children:[u.jsx("div",{className:"size-5 rounded-sm flex items-center justify-center shrink-0 bg-blue-500/20 text-blue-500",children:u.jsx(a5,{className:"size-3"})}),u.jsx("span",{className:me("caption text-foreground font-semibold",i&&!a&&"thinking-shimmer"),children:"Bot Message"}),a&&u.jsx("button",{type:"button",className:"text-muted-foreground/50 hover:text-foreground shrink-0",onClick:()=>n(e.id.span),children:s?u.jsx(cs,{className:"size-3"}):u.jsx(Dr,{className:"size-3"})}),u.jsx("div",{className:"flex-1"}),u.jsx(mf,{span:e}),u.jsx(r0,{status:e.status})]}),a?u.jsx(rx,{open:!s,children:u.jsxs("div",{className:me("px-2.5 pb-2 pl-10 relative animate-fade-in",d&&"cursor-pointer"),onClick:d?f=>{f.stopPropagation(),l(!c)}:void 0,children:[u.jsx("div",{className:me(d&&!c&&"overflow-hidden"),style:d&&!c?{maxHeight:"8.25em"}:void 0,children:u.jsx(Ky,{content:String(o["message.preview"])})}),d&&!c&&u.jsx("div",{className:"absolute bottom-0 left-10 right-0 h-6 bg-linear-to-t from-blue-500/10 to-transparent pointer-events-none"})]})}):i?u.jsx("div",{className:"px-2.5 pb-2 pl-10",children:u.jsx(rWe,{})}):null]})}function Jne({span:e,collapsedCards:t,toggleCard:n,seenSpans:r}){const s=e.data,o=String(s.type||"unknown"),a=s["state.previous_value"],i=s["state.value"],c=a!=null?O$(a):void 0,l=i!=null?O$(i):void 0,d=s["state.changed_keys"],f=t.has(e.id.span),p=c!==void 0||l!==void 0,[h,g]=b.useState(!1),y=!!(d?.length&&typeof c=="object"&&c!==null&&!Array.isArray(c)),E=b.useMemo(()=>{if(!y)return c;const k={};for(const A of d)A in c&&(k[A]=c[A]);return k},[c,d,y]),x=b.useMemo(()=>{if(!y||typeof l!="object"||l===null||Array.isArray(l))return l;const k={};for(const A of d)A in l&&(k[A]=l[A]);return k},[l,d,y]),w=y&&(()=>{const k=Object.keys(c),A=typeof l=="object"&&l!==null&&!Array.isArray(l)?Object.keys(l):[],N=new Set(d);return k.some(j=>!N.has(j))||A.some(j=>!N.has(j))})(),S=h||!w?c:E,T=h||!w?l:x;return u.jsxs("div",{className:me("border border-teal-600/15 rounded-md px-2.5 py-2 bg-teal-600/5",US(r,e.id.span)),children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("div",{className:"size-5 rounded-sm flex items-center justify-center shrink-0 bg-teal-600/15 text-teal-600/70",children:u.jsx(ml,{className:"size-3"})}),u.jsxs("span",{className:"caption text-foreground font-semibold",children:[o," state mutation"]}),p&&u.jsx("button",{type:"button",className:"text-muted-foreground/50 hover:text-foreground shrink-0",onClick:()=>n(e.id.span),children:f?u.jsx(cs,{className:"size-3"}):u.jsx(Dr,{className:"size-3"})}),u.jsx("div",{className:"flex-1"}),!f&&w&&u.jsxs(vn,{children:[u.jsx(xn,{asChild:!0,children:u.jsx("button",{type:"button",className:"p-0.5 rounded-sm text-muted-foreground/50 hover:text-teal-500 hover:bg-teal-500/10 transition-colors duration-quick",onClick:k=>{k.stopPropagation(),g(!h)},children:h?u.jsx(aIt,{className:"size-3"}):u.jsx(KNt,{className:"size-3"})})}),u.jsx(yn,{children:h?"Show changes only":"Show full state"})]}),u.jsx(r0,{status:e.status}),u.jsx(mf,{span:e})]}),p&&u.jsx(rx,{open:!f,children:u.jsxs("div",{className:"mt-1.5 pl-8 grid grid-cols-2 gap-3",children:[u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[u.jsx(bJ,{className:"size-3 shrink-0 text-teal-600/50"}),u.jsx("span",{className:"h3",children:"Before"})]}),S!==void 0&&u.jsx("div",{className:"bg-background-elevated p-2 rounded-md overflow-hidden",children:u.jsx(Oo,{data:S,expandAll:!0})})]}),u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[u.jsx(yJ,{className:"size-3 shrink-0 text-teal-600/50"}),u.jsx("span",{className:"h3",children:"After"})]}),T!==void 0&&u.jsx("div",{className:"bg-background-elevated p-2 rounded-md overflow-hidden",children:u.jsx(Oo,{data:T,expandAll:!0})})]})]})})]})}function sWe(e){return String(e.data["autonomous.tool.name"]||"Tool")}function oWe(e){const t=e.data;return{input:t["autonomous.tool.input"],output:t["autonomous.tool.output"]}}function vBn({span:e}){const n=sWe(e)==="search_knowledge";return u.jsx("div",{className:me("px-2.5 py-2",n?"bg-green-500/10":"bg-violet-500/10"),children:n?u.jsx(xBn,{span:e}):u.jsx(EBn,{span:e})})}function xBn({span:e}){const{input:t,output:n}=oWe(e),r=e.status==="running",s=t?typeof t=="string"?t:t?.query??JSON.stringify(t):void 0;return u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("div",{className:"size-5 rounded-sm flex items-center justify-center shrink-0 bg-green-500/20 text-green-500",children:u.jsx(zkt,{className:"size-3"})}),u.jsx("span",{className:"caption text-foreground font-semibold flex-1",children:"search_knowledge"}),u.jsx(mf,{span:e}),u.jsx(r0,{status:e.status})]}),(s!=null||n!=null||r)&&u.jsxs("div",{className:"mt-1.5 pl-8 grid grid-cols-2 gap-3",children:[u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[u.jsx(bJ,{className:"size-3 shrink-0 text-green-500/50"}),u.jsx("span",{className:"h3",children:"Input"})]}),s!=null&&u.jsx("div",{className:"bg-background-elevated p-2 rounded-md overflow-hidden",children:u.jsx("span",{className:"small",children:String(s)})})]}),u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[u.jsx(yJ,{className:"size-3 shrink-0 text-green-500/50"}),u.jsx("span",{className:"h3",children:"Result"})]}),n!=null?u.jsxs("div",{className:"group relative bg-background-elevated p-2 rounded-md animate-fade-in",children:[u.jsx(cBn,{value:String(n),className:"absolute top-1 right-1 opacity-0 group-hover:opacity-100"}),u.jsx(Ky,{content:String(n)})]}):r?u.jsx(nWe,{}):null]})]})]})}function O$(e){if(typeof e=="string")try{return JSON.parse(e)}catch{return e}return e}function EBn({span:e}){const t=sWe(e),n=e.status==="running",{input:r,output:s}=oWe(e),o=r!=null?O$(r):void 0,a=s!=null?O$(s):void 0;return u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("div",{className:"size-5 rounded-sm flex items-center justify-center shrink-0 bg-violet-500/20 text-violet-500",children:u.jsx(rS,{className:"size-3"})}),u.jsx("span",{className:"caption text-foreground font-semibold flex-1",children:t}),u.jsx(mf,{span:e}),u.jsx(r0,{status:e.status})]}),(o!==void 0||a!==void 0||n)&&u.jsxs("div",{className:"mt-1.5 pl-8 grid grid-cols-2 gap-3",children:[u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[u.jsx(bJ,{className:"size-3 shrink-0 text-violet-500/50"}),u.jsx("span",{className:"h3",children:"Input"})]}),o!==void 0&&u.jsx("div",{className:"bg-background-elevated p-2 rounded-md overflow-hidden",children:u.jsx(Oo,{data:o,expandAll:!0})})]}),u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[u.jsx(yJ,{className:"size-3 shrink-0 text-violet-500/50"}),u.jsx("span",{className:"h3",children:"Output"})]}),a!==void 0?u.jsx("div",{className:"bg-background-elevated p-2 rounded-md overflow-hidden animate-fade-in",children:u.jsx(Oo,{data:a,expandAll:!0,maxLines:5})}):n?u.jsx(nWe,{}):null]})]})]})}const aWe=300;function wBn({span:e}){const n=e.data["message.preview"],[r,s]=b.useState(!1),o=n!=null&&String(n).length>aWe;return u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx("div",{className:"size-5 rounded-sm flex items-center justify-center shrink-0 bg-blue-500/20 text-blue-500",children:u.jsx(a5,{className:"size-3"})}),u.jsx("span",{className:"caption text-foreground font-semibold flex-1",children:"Bot Message"}),u.jsx(mf,{span:e}),u.jsx(r0,{status:e.status})]}),n!=null?u.jsxs("div",{className:me("mt-1.5 pl-8 relative animate-fade-in",o&&"cursor-pointer"),onClick:o?a=>{a.stopPropagation(),s(!r)}:void 0,children:[u.jsx("div",{className:me(o&&!r&&"overflow-hidden"),style:o&&!r?{maxHeight:"8.25em"}:void 0,children:u.jsx(Ky,{content:String(n)})}),o&&!r&&u.jsx("div",{className:"absolute bottom-0 left-8 right-0 h-6 bg-linear-to-t from-blue-500/10 to-transparent pointer-events-none"})]}):e.status==="running"?u.jsx("div",{className:"mt-1.5 pl-8",children:u.jsx(rWe,{})}):null]})}const SBn="[&_pre]:text-xs [&_.shiki]:text-xs! [&_code]:text-xs! [&_pre]:whitespace-pre-wrap! [&_pre]:wrap-break-word! [&_code]:whitespace-pre-wrap! [&_code]:wrap-break-word! [&_.line]:before:content-none!";function ere({icon:e,iconBg:t,iconText:n,label:r,span:s}){return u.jsxs("div",{className:"px-4 py-3 space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("div",{className:me("size-5 rounded-sm flex items-center justify-center shrink-0",t),children:u.jsx(e,{className:me("size-3",n)})}),u.jsx("span",{className:"caption text-foreground font-semibold flex-1",children:r}),u.jsx(tWe,{status:s.status})]}),u.jsx("div",{className:"flex items-center gap-3",children:u.jsx(mf,{span:s})}),s.error&&u.jsx("div",{className:"bg-red-500/10 border border-red-500/20 rounded-md px-3 py-2",children:u.jsx("p",{className:"small text-red-400 wrap-break-word whitespace-pre-wrap",children:s.error})})]})}function db({label:e,children:t,collapsible:n,collapsed:r,onToggle:s}){return n?u.jsxs("div",{className:"mx-3 my-2 px-3 py-3 bg-muted/50 rounded-md",children:[u.jsxs("button",{type:"button",className:"h3 mb-2 flex items-center gap-1 hover:text-foreground transition-colors w-full text-left",onClick:s,children:[r?u.jsx(cs,{className:"size-3"}):u.jsx(Dr,{className:"size-3"}),e]}),!r&&t]}):u.jsxs("div",{className:"mx-3 my-2 px-3 py-3 bg-muted/50 rounded-md",children:[u.jsx("span",{className:"h3 mb-2 block",children:e}),t]})}function mR({children:e}){return u.jsx("div",{className:"bg-muted/50 p-3 rounded-md",children:e})}function _Bn({text:e,maxLines:t=5}){const[n,r]=b.useState(!1),s=e.split(`
1617
1617
  `),o=s.length>t,a=n||!o?s:s.slice(0,t);return u.jsxs(mR,{children:[u.jsx("pre",{className:"code whitespace-pre-wrap wrap-break-word",children:a.join(`
1618
1618
  `)}),o&&!n&&u.jsxs("button",{type:"button",onClick:()=>r(!0),className:"mt-2 small text-blue-500 hover:underline flex items-center gap-1",children:[u.jsx(Dr,{className:"size-3"}),"Show ",s.length-t," more lines"]}),o&&n&&u.jsxs("button",{type:"button",onClick:()=>r(!1),className:"mt-2 small text-blue-500 hover:underline flex items-center gap-1",children:[u.jsx(XN,{className:"size-3"}),"Collapse"]})]})}function TBn({detail:e,onClose:t}){return u.jsxs("div",{className:"flex flex-col h-full",children:[u.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5",children:[u.jsx("span",{className:"caption text-foreground font-semibold",children:e.type==="step"?"Step Details":e.type==="lifecycle"?"Lifecycle Details":"Trigger Details"}),u.jsx("button",{type:"button",onClick:t,className:"text-muted-foreground hover:text-foreground transition-colors p-1 rounded-sm hover:bg-muted",children:u.jsx(ca,{className:"size-4"})})]}),u.jsxs("div",{className:"flex-1 overflow-y-auto text-sm",children:[e.type==="step"&&u.jsx(CBn,{step:e.step}),e.type==="trigger"&&u.jsx(kBn,{span:e.span}),e.type==="lifecycle"&&u.jsx(ABn,{span:e.span})]})]})}function ABn({span:e}){const t=e.data,n=t["event.type"],r=JGe(n),s=t.integration,o=t.channel,a=t.conversationId,i=t.userId,c=t.eventId;return u.jsxs("div",{className:"space-y-3",children:[u.jsx(ere,{icon:id,iconBg:"bg-purple-500/20",iconText:"text-purple-400",label:r,span:e}),u.jsx(db,{label:"Lifecycle Info",children:u.jsx(mR,{children:u.jsxs("div",{className:"space-y-1.5",children:[n&&u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"small text-muted-foreground/50",children:"Event Type"}),u.jsx("span",{className:"code",children:n})]}),s&&u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"small text-muted-foreground/50",children:"Integration"}),u.jsx("span",{className:"code",children:s})]}),o&&u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"small text-muted-foreground/50",children:"Channel"}),u.jsx("span",{className:"code",children:o})]}),a&&u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"small text-muted-foreground/50",children:"Conversation"}),u.jsx("span",{className:"code text-muted-foreground/50",children:a})]}),i&&u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"small text-muted-foreground/50",children:"User"}),u.jsx("span",{className:"code text-muted-foreground/50",children:i})]}),c&&u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"small text-muted-foreground/50",children:"Event ID"}),u.jsx("span",{className:"code text-muted-foreground/50",children:c})]})]})})})]})}function kBn({span:e}){const t=e.data,n=String(t["trigger.name"]||"Trigger"),r=t["event.type"],s=t.integration,o=t.channel,a=t.conversationId,i=t.userId,c=t.eventId;return u.jsxs("div",{className:"space-y-3",children:[u.jsx(ere,{icon:Sa,iconBg:"bg-amber-500/20",iconText:"text-amber-500",label:n,span:e}),u.jsx(db,{label:"Trigger Info",children:u.jsx(mR,{children:u.jsxs("div",{className:"space-y-1.5",children:[r&&u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"small text-muted-foreground/50",children:"Event Type"}),u.jsx("span",{className:"code",children:r})]}),s&&u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"small text-muted-foreground/50",children:"Integration"}),u.jsx("span",{className:"code",children:s})]}),o&&u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"small text-muted-foreground/50",children:"Channel"}),u.jsx("span",{className:"code",children:o})]}),a&&u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"small text-muted-foreground/50",children:"Conversation"}),u.jsx("span",{className:"code text-muted-foreground/50",children:a})]}),i&&u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"small text-muted-foreground/50",children:"User"}),u.jsx("span",{className:"code text-muted-foreground/50",children:i})]}),c&&u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("span",{className:"small text-muted-foreground/50",children:"Event ID"}),u.jsx("span",{className:"code text-muted-foreground/50",children:c})]})]})})})]})}function CBn({step:e}){const t=e.iteration.data,n=t["autonomous.iteration"],r=`LLM Iteration${n!=null?` ${Number(n)+1}`:""}`,s=t["ai.model"],o=t["ai.tokens"],a=t["ai.cost"],i=t["autonomous.code"],c=t["autonomous.instructions"],l=t["autonomous.tools"],d=typeof l=="string"?l.split(",").map(S=>S.trim()).filter(Boolean):Array.isArray(l)?l.map(S=>S.name||String(S)):[],f=t["autonomous.status"],p=e.cognitive?.data,h=p?.["ai.input_tokens"],g=p?.["ai.output_tokens"],y=p?.["ai.cost_input"],E=p?.["ai.cost_output"],{collapsed:x,toggle:w}=uBn();return u.jsxs("div",{className:"space-y-3",children:[u.jsx(ere,{icon:tc,iconBg:"bg-muted",iconText:"text-foreground",label:r,span:e.iteration}),i!=null&&u.jsx(db,{label:"Generated Code",collapsible:!0,collapsed:x.has("generated-code"),onToggle:()=>w("generated-code"),children:u.jsx(Hne,{data:[{language:"typescript",filename:"generated.ts",code:i}],defaultValue:"typescript",className:SBn,children:u.jsx(Vne,{className:"[&_pre]:p-1!",children:S=>u.jsx(Gne,{value:S.language,children:u.jsx(Wne,{language:S.language,children:S.code})},S.language)})})}),(s||o!=null||a!=null)&&u.jsx(db,{label:"AI Metrics",children:u.jsx(mR,{children:u.jsxs("div",{className:"space-y-2",children:[u.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s&&u.jsxs(vn,{children:[u.jsx(xn,{asChild:!0,children:u.jsx("span",{className:"text-xs font-medium px-1.5 py-0.5 rounded-sm bg-muted border border-border/50 cursor-default",children:IBn(s)})}),u.jsx(yn,{children:u.jsx("span",{className:"code text-xs",children:s})})]}),f&&f!=="exit_success"&&f!=="pending"&&u.jsx("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-sm bg-red-500/10 text-red-400 border border-red-500/20",children:f.replace(/_/g," ")})]}),(h!=null||g!=null)&&u.jsxs("div",{className:"space-y-1",children:[u.jsxs("div",{className:"flex items-center gap-3 text-xs",children:[h!=null&&u.jsxs("span",{className:"code",children:[h.toLocaleString(),u.jsx("span",{className:"text-muted-foreground/50",children:" in"}),y!=null&&u.jsxs("span",{className:"text-muted-foreground/30 ml-1",children:["$",y.toFixed(4)]})]}),g!=null&&u.jsxs("span",{className:"code",children:[g.toLocaleString(),u.jsx("span",{className:"text-muted-foreground/50",children:" out"}),E!=null&&u.jsxs("span",{className:"text-muted-foreground/30 ml-1",children:["$",E.toFixed(4)]})]}),a!=null&&y==null&&u.jsxs("span",{className:"code text-muted-foreground/50",children:["$",Number(a).toFixed(4)]})]}),h!=null&&g!=null&&u.jsxs("div",{className:"flex h-1.5 rounded-full overflow-hidden bg-muted",children:[u.jsx("div",{className:"bg-muted-foreground/30 h-full",style:{width:`${h/(h+g)*100}%`}}),u.jsx("div",{className:"bg-accent h-full flex-1"})]}),a!=null&&y!=null&&u.jsx("div",{className:"flex items-center gap-1 text-xs",children:u.jsxs("span",{className:"code text-muted-foreground/50",children:["total $",Number(a).toFixed(4)]})})]}),h==null&&g==null&&o!=null&&u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("span",{className:"code",children:[Number(o).toLocaleString(),u.jsx("span",{className:"text-muted-foreground/50",children:" tokens"})]}),a!=null&&u.jsxs("span",{className:"code text-muted-foreground/50",children:["$",Number(a).toFixed(4)]})]})]})})}),d.length>0&&u.jsx(db,{label:"Available Tools",collapsible:!0,collapsed:x.has("available-tools"),onToggle:()=>w("available-tools"),children:u.jsx("div",{className:"flex flex-wrap gap-1",children:d.map(S=>u.jsx(Sr,{variant:"outline",className:"text-violet-400 border-violet-400/30 text-[10px] px-1.5 py-0 h-5 rounded-sm",children:S},S))})}),c!=null&&u.jsx(db,{label:"Instructions",collapsible:!0,collapsed:x.has("instructions"),onToggle:()=>w("instructions"),children:u.jsx(_Bn,{text:c})}),e.cognitive&&u.jsx(db,{label:"LLM Call",collapsible:!0,collapsed:x.has("llm-call"),onToggle:()=>w("llm-call"),children:u.jsx(NBn,{span:e.cognitive})})]})}function NBn({span:e}){const t=e.data,n=t["ai.model"],r=t["ai.input_tokens"],s=t["ai.output_tokens"],o=t["ai.cost"];return u.jsx(mR,{children:u.jsxs("div",{className:"space-y-1.5",children:[u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsx(tWe,{status:e.status}),u.jsx(mf,{span:e})]}),n&&u.jsx("div",{className:"small text-foreground",children:n}),(r!=null||s!=null||o!=null)&&u.jsxs("div",{className:"flex items-center gap-3",children:[r!=null&&u.jsxs("span",{className:"code",children:[r.toLocaleString(),u.jsx("span",{className:"text-muted-foreground/50",children:" in"})]}),s!=null&&u.jsxs("span",{className:"code",children:[s.toLocaleString(),u.jsx("span",{className:"text-muted-foreground/50",children:" out"})]}),o!=null&&u.jsxs("span",{className:"code text-muted-foreground/50",children:["$",o.toFixed(4)]})]})]})})}function IBn(e){const t=e.split(":");let n=t[t.length-1];return n=n.replace(/-\d{4}-\d{2}-\d{2}$/,""),n.startsWith("gpt-")?n.replace("gpt-","GPT-"):n.startsWith("claude-")?n.replace("claude-","Claude "):n.startsWith("o1")?n.toUpperCase():n}function RBn(e){const t=e.timing.duration??(e.timing.endedAt?e.timing.endedAt-e.timing.startedAt:0);return t<1?"<1ms":t<1e3?`${Math.round(t)}ms`:`${(t/1e3).toFixed(1)}s`}function wY(e){const n=new Date().getTime()-e.getTime(),r=Math.max(0,Math.floor(n/1e3)),s=Math.floor(r/60),o=Math.floor(s/60),a=Math.floor(o/24);if(r<60)return`${r}s ago`;if(s<60)return`${s}m ago`;if(o<24)return`${o}h ago`;if(a<30)return`${a}d ago`;const i=Math.floor(a/30);return i<12?`${i}mo ago`:`${Math.floor(i/12)}y ago`}function iWe(e){const t=new Date,n=t.getTime()-e.getTime(),r=Math.max(0,Math.floor(n/1e3)),s=Math.floor(r/60);if(r<60)return"Just now";if(s<60)return`${s} minute${s===1?"":"s"} ago`;const o=e.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}),a=new Date(t.getFullYear(),t.getMonth(),t.getDate()),i=new Date(e.getFullYear(),e.getMonth(),e.getDate()),c=Math.round((a.getTime()-i.getTime())/864e5);if(c===0)return`Today at ${o}`;if(c===1)return`Yesterday at ${o}`;if(c>1&&c<7)return`${e.toLocaleDateString([],{weekday:"long"})} at ${o}`;const l=e.getFullYear()===t.getFullYear();return`${e.toLocaleDateString([],{month:"short",day:"numeric",year:l?void 0:"numeric"})} at ${o}`}function lWe({env:e,left:t,right:n}){return e==="dev"&&n!==void 0?u.jsxs(cF,{direction:"horizontal",className:"h-full min-h-0 mb-4",children:[u.jsx(rp,{defaultSize:30,minSize:20,maxSize:50,children:t}),u.jsx(kw,{}),u.jsx(rp,{defaultSize:70,minSize:30,children:n})]}):u.jsxs("div",{className:"flex h-full min-h-0 mb-4",children:[u.jsx("div",{className:"basis-[30%] min-w-[20rem] max-w-[50%] min-h-0",children:t}),u.jsx("div",{className:"flex-1"})]})}function jBn({env:e,clientId:t,botId:n,conversations:r,conversationsLoading:s,onSwitchConversation:o,onRefreshConversations:a,storageKey:i}){const{conversationId:c,messages:l,participants:d,sendMessage:f,uploadFile:p,saveMessageFeedback:h,status:g,error:y,isTyping:E,isAwaitingResponse:x}=u4n(),{openConversation:w,listConversations:S}=d4n(),{userCredentials:T}=c4n(),{resolvedTheme:k}=Oy(),{apiUrl:A}=wn(),{track:N}=lf(),j=b.useCallback((...B)=>(N("control_panel.feature_used",{feature:"chat_send"}),f(...B)),[f,N]);b.useEffect(()=>{!c||!T?.userToken||fetch(A("/api/conversations/user-token"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({botId:n,conversationId:c,userToken:T.userToken})}).catch(()=>{})},[c,T?.userToken,n,A]);const[O,D]=b.useState(!1),L=r.filter(B=>B.integration==="webchat"&&B.channel==="channel"),U=u.jsxs("div",{className:"h-full flex flex-col overflow-hidden bg-background-elevated rounded-lg border border-muted-foreground/15",children:[u.jsxs("div",{className:"flex items-center gap-2 px-3 h-10 shrink-0 min-w-0",children:[u.jsxs(ul,{open:O,onOpenChange:B=>{D(B),B&&a()},children:[u.jsx(dl,{asChild:!0,children:u.jsxs("button",{className:me("flex items-center gap-1 px-2 py-1 rounded-md text-xs text-muted-foreground transition-colors duration-standard min-w-0",O?"bg-accent":"hover:bg-accent/50"),children:[u.jsx("span",{className:"code truncate min-w-0",children:c||"New"}),u.jsx(Dr,{className:me("size-3 shrink-0 transition-transform duration-standard",O&&"rotate-180")})]})}),u.jsxs(Ki,{align:"start",sideOffset:4,className:"w-96 max-h-[50vh] overflow-y-auto",children:[s&&L.length===0?Array.from({length:4}).map((B,M)=>u.jsxs("div",{className:"px-3 py-2.5",children:[u.jsx(Wt,{className:"h-3 w-2/3 mb-1.5"}),u.jsxs("div",{className:"flex items-center gap-1.5",children:[u.jsx(Wt,{className:"h-2.5 w-2/5"}),u.jsx(Wt,{className:"h-2.5 w-12"})]})]},M)):null,L.map(B=>{const M=B.id===c;return u.jsxs(wr,{className:me("flex items-start py-2.5",M&&"bg-accent"),onClick:()=>{M||o(B.id)},children:[u.jsxs("div",{className:"flex-1 min-w-0",children:[B.preview?u.jsx("p",{className:"text-xs text-foreground truncate",children:B.preview}):u.jsx("p",{className:"small italic text-muted-foreground/50",children:"No user messages"}),u.jsxs("div",{className:"flex items-center gap-1.5 mt-1",children:[u.jsx("span",{className:"code text-muted-foreground/50 truncate",children:B.id}),B.lastMessageAt&&u.jsx("span",{className:"small text-muted-foreground/50 shrink-0",children:wY(new Date(B.lastMessageAt))})]})]}),M&&u.jsx(Xr,{className:"size-3 text-green-500 shrink-0 mt-0.5"})]},B.id)}),L.length===0&&!s&&u.jsx("div",{className:"px-3 py-6 text-center",children:u.jsx("span",{className:"small text-muted-foreground/50",children:"No conversations yet. Send a message to get started."})})]})]}),u.jsx("div",{className:"flex-1"}),u.jsxs(vn,{children:[u.jsx(xn,{asChild:!0,children:u.jsx("button",{onClick:()=>w(void 0),className:"text-muted-foreground/50 hover:text-muted-foreground transition-colors duration-standard p-1 rounded-md hover:bg-accent/50 shrink-0",children:u.jsx(o5,{className:"size-3.5"})})}),u.jsx(yn,{children:"New conversation"})]})]}),u.jsx("div",{className:"webchat-embed flex-1 min-h-0 overflow-hidden [&>div]:h-full! [&>div]:max-h-full! [&>div]:rounded-none! [&>div]:border-0! [&>div]:shadow-none!",style:{"--bpFontSize-scale":"0.8"},children:u.jsx(G4n,{configuration:{themeMode:k==="dark"?"dark":"light",color:"#3276ea",allowFileUpload:!0},clientId:t,messages:l,participants:d,sendMessage:j,uploadFile:p,addMessageFeedback:h,listConversations:S,restartConversation:()=>w(void 0),user:T,isLoading:g==="connecting",isTyping:E,connected:g==="connected"?!0:g==="disconnected"?!1:void 0,error:y,disableSendButton:x,conversationId:c,storageKey:i})})]});return u.jsx(lWe,{env:e,left:U,right:e==="dev"?u.jsx(eWe,{conversationId:c||"",className:"h-full"},c||"empty"):void 0})}function DBn({onInstalled:e}){const[t,n]=b.useState("idle"),[r,s]=b.useState(""),{apiUrl:o}=wn(),a=async()=>{n("installing"),s("");try{const i=await fetch(o("/api/integrations/add"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"webchat"})});if(!i.ok){const c=await i.json().catch(()=>null);throw new Error(c?.message||"Failed to add webchat integration")}e(),n("idle")}catch(i){n("error"),s(i instanceof Error?i.message:"Unknown error")}};return u.jsx("div",{className:"flex h-full items-center justify-center",children:u.jsxs("div",{className:"rounded-md border border-dashed bg-card p-8 flex flex-col items-center gap-3 text-center max-w-md",children:[u.jsx(n5,{className:"size-8 text-muted-foreground/30"}),u.jsxs("div",{children:[u.jsx("p",{className:"text-sm font-semibold",children:"No webchat integration"}),u.jsx("p",{className:"small mt-1",children:"Install webchat to start chatting with your agent."})]}),u.jsx("button",{onClick:a,disabled:t==="installing",className:"inline-flex items-center gap-2 px-3 py-1.5 text-sm font-medium rounded-sm bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors",children:t==="installing"?u.jsxs(u.Fragment,{children:[u.jsx(nn,{className:"size-3.5 animate-spin"}),"Installing..."]}):u.jsxs(u.Fragment,{children:[u.jsx(nS,{className:"size-3.5"}),"Install webchat"]})}),t==="error"&&u.jsx("p",{className:"text-sm text-red-500",children:r})]})})}function OBn({binding:e}){switch(e.status){case"loading":return u.jsx("div",{className:"flex h-full items-center justify-center",children:u.jsx(Wt,{className:"h-4 w-48"})});case"no-prod-bot":return u.jsx(b1,{title:"Production target not deployed",body:"Deploy this agent to publish the prod target before opening chat in Prod."});case"no-webchat-integration":return e.env==="dev"?u.jsx(DBn,{onInstalled:e.refetchBot}):u.jsx(b1,{title:"No webchat integration",body:"Install the webchat integration in dev mode first, then deploy."});case"webchat-disabled":return u.jsx(b1,{title:"Webchat integration is disabled",body:"Enable and configure it to start chatting.",children:u.jsx(Fc,{to:"/integrations",className:"inline-flex items-center gap-2 px-3 py-1.5 text-sm font-medium rounded-sm bg-primary text-primary-foreground hover:bg-primary/90 transition-colors",children:"Go to Integrations"})});case"not-deployed":return e.env==="prod"?u.jsx(b1,{title:"Production target not deployed",body:"Deploy this agent to publish the prod target before opening chat in Prod."}):u.jsx(b1,{title:"Webchat is not ready",body:"Finish installing and configuring webchat to start chatting."});case"no-handler":return u.jsx(b1,{title:"No conversation handler",children:u.jsxs("p",{className:"small mt-1",children:["Create a handler in ",u.jsx("code",{className:"code bg-muted px-1 py-0.5 rounded",children:"src/conversations/"})]})});case"error":return u.jsx("div",{className:"flex h-full items-center justify-center",children:u.jsx("p",{className:"body",children:e.message})})}}function b1({title:e,body:t,children:n}){return u.jsx("div",{className:"flex h-full items-center justify-center",children:u.jsxs("div",{className:"rounded-md border border-dashed bg-card p-8 flex flex-col items-center gap-3 text-center max-w-md",children:[u.jsx(n5,{className:"size-8 text-muted-foreground/30"}),u.jsxs("div",{children:[u.jsx("p",{className:"text-sm font-semibold",children:e}),t&&u.jsx("p",{className:"small mt-1",children:t})]}),n]})})}function MBn(){const e=xs(w=>w.targetEnvironment),t=bt(w=>w.selectedAgentPath),{data:n}=lc(),{data:r,isLoading:s,error:o}=cm(),a=!!t&&r?.path===t,i=n?.credentials?.devBotId,c=n?.credentials?.prodBotId??null,l=a?r?.agentInfo?.devId??i:i??null,d=a?r?.agentInfo?.botId??c:c,f=e==="prod"?d:l,{data:p,isLoading:h,refetch:g}=jv(f);if(e==="prod"&&!n)return{status:"loading"};if(e==="prod"&&!d)return{status:"no-prod-bot"};if(e==="prod"&&iP(o))return{status:"not-deployed",env:e,botId:d};if(s||!a)return{status:"loading"};if(h||!f)return{status:"loading"};const y=p?.integrations?.webchat;if(!y)return{status:"no-webchat-integration",env:e,botId:f,refetchBot:()=>void g()};if(y.enabled===!1)return{status:"webchat-disabled",env:e,botId:f};const E=y.webhookUrl?.replace(/\/$/,"").split("/").pop()||void 0;if(!E)return{status:"not-deployed",env:e,botId:f};if(e==="dev"&&r?.conversations?.length===0)return{status:"no-handler",env:e,botId:f};const x=y.configuration?.adminSecret||void 0;return{status:"ready",env:e,botId:f,clientId:E,adminSecret:x}}function PBn(e,t){const{apiUrl:n}=wn(),s=`${bt(i=>i.selectedAgentPath)??""}:${t??""}:${e??""}`,[o,a]=b.useState({key:"",status:"pending"});if(b.useEffect(()=>{if(!e||!t)return;const i=new AbortController,c=new URLSearchParams({botId:t,conversationId:e});return a({key:s,status:"pending"}),fetch(n(`/api/conversations/user-token?${c.toString()}`),{signal:i.signal}).then(l=>l.ok?l.json():null).then(l=>{l?.userToken?a({key:s,status:"ready",conversationId:e,userToken:l.userToken}):a({key:s,status:"error",conversationId:e,message:"User token not found for this conversation"})}).catch(l=>{$Bn(l)||a({key:s,status:"error",conversationId:e,message:"Failed to fetch user token"})}),()=>i.abort()},[e,t,n,s]),!t)return{status:"pending"};if(!e)return{status:"ready",conversationId:null};if(o.key!==s)return{status:"pending"};switch(o.status){case"pending":return{status:"pending"};case"ready":return{status:"ready",conversationId:o.conversationId,userToken:o.userToken};case"error":return{status:"error",conversationId:o.conversationId,message:o.message}}}function $Bn(e){return typeof e=="object"&&e!==null&&"name"in e&&e.name==="AbortError"}function LBn({clientId:e,botId:t,env:n,targetConversationId:r}){const s=e&&t?`bp-webchat-${e}-${t}`:null;return s&&n==="prod"&&!r&&FBn(s),s}function FBn(e){try{const t=`${e}-client`,n=localStorage.getItem(t);if(!n)return;const r=JSON.parse(n);if(typeof r.state=="object"&&r.state!==null){const s=r.state;if(!("conversationId"in s))return;const{conversationId:o,...a}=s;localStorage.setItem(t,JSON.stringify({...r,state:a}));return}if("conversationId"in r){const{conversationId:s,...o}=r;localStorage.setItem(t,JSON.stringify(o))}}catch{}}function BBn(e,t){const{getClient:n,credentials:r,isReady:s}=$o(),o=ds(y=>y.isAuthenticated),a=bt(y=>y.selectedAgentPath),[i,c]=b.useState([]),[l,d]=b.useState(!1),f=`${a??""}:${e}:${t??""}`,p=b.useRef(f);p.current=f;const h=b.useRef(void 0),g=b.useCallback(async()=>{const y=f;if(!t||!o||!s||!r?.token||r.token==="hasToken"){p.current===y&&d(!1);return}d(!0);try{const E=await n(e),x=[];let w=await E.listConversations({});for(x.push(...w.conversations||[]);w.meta?.nextToken&&x.length<50;)w=await E.listConversations({nextToken:w.meta.nextToken}),x.push(...w.conversations||[]);const S=x.slice(0,30),T=5,k=5,A=[];for(let j=0;j<S.length;j+=k){const O=S.slice(j,j+k),D=await Promise.allSettled(O.map(async L=>{let U=await E.listMessages({conversationId:L.id}),B=[...U.messages||[]],M=1;for(;U.meta?.nextToken&&M<T;)U=await E.listMessages({conversationId:L.id,nextToken:U.meta.nextToken}),B.push(...U.messages||[]),M++;B.sort((q,z)=>new Date(q.createdAt).getTime()-new Date(z.createdAt).getTime());const $=B[B.length-1],P=[...B].reverse().find(q=>q.direction==="incoming");return{id:L.id,integration:L.integration||"unknown",channel:L.channel||"unknown",lastMessageAt:$?.createdAt??L.updatedAt,preview:P?.payload?.text}}));A.push(...D)}const N=A.filter(j=>j.status==="fulfilled").map(j=>j.value);N.sort((j,O)=>{const D=j.lastMessageAt?new Date(j.lastMessageAt).getTime():0;return(O.lastMessageAt?new Date(O.lastMessageAt).getTime():0)-D}),p.current===y&&c(N)}catch(E){console.error("[useConversationsList] Failed to fetch:",E)}finally{p.current===y&&d(!1)}},[e,t,f,n,r,o,s]);return h.current=g,b.useEffect(()=>{c([]),d(!1)},[f]),{list:i,loading:l,refresh:()=>void h.current?.()}}function qBn(){const e=xs(x=>x.targetEnvironment),t=bt(x=>x.selectedAgentPath),n=MBn(),r=ui(),s=Lc(),o=r.state,a=typeof o?.conversationId=="string"?o.conversationId:void 0,i=e==="dev"?a:void 0,[c,l]=b.useState(void 0),d=c??i,f=UBn(n),p=`${t??""}:${e}:${f??""}`,h=b.useRef(null);b.useEffect(()=>{if(h.current===p)return;const x=h.current;!x&&!f||(h.current=p,l(void 0),x&&a&&s({pathname:r.pathname,search:r.search,hash:r.hash},{replace:!0,state:null}))},[p,a,s,r.pathname,r.search,r.hash]);const g=PBn(d,f),y=LBn({clientId:n.status==="ready"?n.clientId:null,botId:f,env:e,targetConversationId:d}),E=BBn(e,f);return n.status!=="ready"?n.status==="no-webchat-integration"?{status:"no-webchat-integration",env:n.env,refetchBot:n.refetchBot}:n.status==="not-deployed"?{status:"not-deployed",env:n.env}:{status:n.status}:g.status==="pending"||!y?{status:"loading"}:g.status==="error"?{status:"error",message:g.message,conversationId:g.conversationId}:{status:"ready",env:n.env,botId:n.botId,clientId:n.clientId,adminSecret:n.adminSecret,storageKey:y,conversationId:g.conversationId,userToken:g.userToken,conversations:E.list,conversationsLoading:E.loading,switchConversation:l,refreshConversations:E.refresh}}function UBn(e){switch(e.status){case"ready":case"no-webchat-integration":case"webchat-disabled":case"not-deployed":case"no-handler":return e.botId;case"loading":case"no-prod-bot":return null}}function cWe(){const e=xs(r=>r.targetEnvironment),t=qBn();if(t.status!=="ready")return u.jsx("div",{className:"flex flex-col h-full min-h-0",children:u.jsx(lWe,{env:e,left:u.jsx("div",{className:"h-full bg-background-elevated rounded-lg border border-muted-foreground/15",children:u.jsx(OBn,{binding:t})}),right:e==="dev"?u.jsx(eWe,{conversationId:"",className:"h-full"},"empty"):void 0})});const n={clientId:t.clientId,adminSecret:t.adminSecret};return t.conversationId&&(n.conversationId=t.conversationId),t.userToken&&(n.userCredentials={userToken:t.userToken}),u.jsx("div",{className:"flex flex-col h-full min-h-0",children:u.jsx(w5n,{clientId:t.clientId,storageKey:t.storageKey,...n,children:u.jsx(jBn,{env:t.env,clientId:t.clientId,botId:t.botId,conversations:t.conversations,conversationsLoading:t.conversationsLoading,onSwitchConversation:t.switchConversation,onRefreshConversations:t.refreshConversations,storageKey:t.storageKey})},`${t.env}-${t.storageKey}-${t.conversationId??"default"}`)})}class tre extends b.Component{state={hasError:!1,message:null,resetKey:this.props.resetKey};static getDerivedStateFromError(t){return{hasError:!0,message:t instanceof Error?t.message:String(t)}}static getDerivedStateFromProps(t,n){return t.resetKey!==n.resetKey?{hasError:!1,message:null,resetKey:t.resetKey}:null}componentDidCatch(t){console.error(`[Registry] Failed to render ${this.props.name}:`,t)}render(){return this.state.hasError?u.jsxs("div",{className:"rounded-md border border-red-500/30 bg-red-500/5 p-3 text-red-300",children:[u.jsx("div",{className:"caption text-red-200",children:"Failed to render"}),u.jsx("div",{className:"code mt-0.5 text-xs text-red-300/80",children:this.props.name}),this.state.message?u.jsx("pre",{className:"code mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-words rounded-sm bg-red-500/10 p-2 text-xs text-red-200/90",children:this.state.message}):null]}):this.props.children}}const zBn="SHA-384",dwe="sha384-";function uWe(e){const t=e.trim();if(!t.startsWith(dwe))return null;const n=t.slice(dwe.length);return n?{expected:n}:null}function v1(e){return typeof e=="string"&&uWe(e)!==null}function HBn(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}async function VBn(e){const t=await crypto.subtle.digest(zBn,e);return HBn(new Uint8Array(t))}async function dWe(e,t,n){const r=uWe(t);if(!r)throw new Error(`Registry asset has no valid sha384 integrity hash: "${t}" (${e})`);const s=await fetch(e,n);if(!s.ok)throw new Error(`Registry asset fetch failed: ${s.status} ${s.statusText} (${e})`);const o=await s.arrayBuffer();if(await VBn(o)!==r.expected)throw new Error(`Registry asset failed integrity check: ${e}`);return o}async function fWe(e,t,n){await dWe(e,t,n)}async function pWe(e,t,n){const r=await dWe(e,t,n);return new TextDecoder("utf-8").decode(r)}const kH=new Map;function GBn(e,t){let n=kH.get(e);return n||(n=fWe(e,t),n.catch(()=>kH.delete(e)),kH.set(e,n)),n}async function WBn(e,t){const n=await fetch(e,{signal:t,cache:"no-store"});if(!n.ok)throw new Error(`Registry metadata fetch failed: ${n.status} ${n.statusText}`);const r=await n.json();if(typeof r?.version!="string")throw new Error("Registry metadata is malformed: `version` is not a string");if(typeof r?.stylesUrl!="string")throw new Error("Registry metadata is malformed: `stylesUrl` is missing");if(!v1(r?.stylesIntegrity))throw new Error("Registry metadata is malformed: `stylesIntegrity` is missing or not a valid SRI hash");if(!Array.isArray(r?.components))throw new Error("Registry metadata is malformed: `components` is not an array");if(!Array.isArray(r?.sharedChunks))throw new Error("Registry metadata is malformed: `sharedChunks` is not an array");for(const s of r.sharedChunks)if(typeof s?.url!="string"||!v1(s?.integrity))throw new Error(`Registry metadata is malformed: shared chunk is missing a valid SRI integrity hash (${s?.url})`);for(const s of r.components){if(typeof s?.url!="string"||!v1(s?.integrity))throw new Error(`Registry metadata is malformed: component "${s?.name}" is missing a valid SRI integrity hash`);const o=s?.sources;if(!o||typeof o!="object")throw new Error(`Registry metadata is malformed: component "${s?.name}" is missing \`sources\``);if(typeof o.component?.url!="string"||!v1(o.component?.integrity))throw new Error(`Registry metadata is malformed: component "${s?.name}" is missing a valid sources.component integrity hash`);if(typeof o.types?.url!="string"||!v1(o.types?.integrity))throw new Error(`Registry metadata is malformed: component "${s?.name}" is missing a valid sources.types integrity hash`);if(o.css!==void 0&&(typeof o.css?.url!="string"||!v1(o.css?.integrity)))throw new Error(`Registry metadata is malformed: component "${s?.name}" has sources.css but is missing a valid integrity hash`)}return r}const CH=new Map;async function KBn(e,t){let n=CH.get(e.name);return n||(n=(async()=>{await Promise.all([fWe(e.url,e.integrity),...t.map(a=>GBn(a.url,a.integrity))]);const r=await import(e.url),s=e.exports.component,o=r[s];if(typeof o!="function"){const a=Object.keys(r).join(", ")||"(no exports)";throw new Error(`Registry component ${e.name} has no \`${s}\` export (saw: ${a})`)}return o})(),n.catch(()=>CH.delete(e.name)),CH.set(e.name,n)),n}const fwe="https://adk.botpresscontent.cloud/manifests/latest.json";function uF(){return Vn({queryKey:["registry","manifest",fwe],queryFn:({signal:e})=>WBn(fwe,e),staleTime:Number.POSITIVE_INFINITY})}function ZBn(e){const{data:t}=uF(),n=t?.sharedChunks;return Vn({queryKey:["registry","component",e?.name,t?.version],queryFn:()=>KBn(e,n),enabled:!!e&&!!n,staleTime:Number.POSITIVE_INFINITY,retry:!1})}const YBn=()=>{};function hWe({entry:e}){const{data:t,isLoading:n,error:r}=ZBn(e);if(n)return u.jsx(Wt,{className:"h-full min-h-[300px] w-full"});if(r||!t)throw r??new Error(`Failed to load registry component: ${e.name}`);const s=t,o=e.sampleProps??{},a=Object.fromEntries((e.callbackProps??[]).map(i=>[i,YBn]));return u.jsx(s,{...o,...a})}let NH=null,pwe=null;async function mWe(e,t){const r=(await pWe(e,t)).replace(/(^|[^\w-]):root\b/g,"$1:host"),s=new CSSStyleSheet;return s.replaceSync(r),s}function QBn(e,t){const[n,r]=b.useState(null);return b.useEffect(()=>{if(!e||!t)return;(pwe!==e||!NH)&&(pwe=e,NH=mWe(e,t));const s=NH;let o=!1;return s.then(a=>{o||r(a)}),()=>{o=!0}},[e,t]),n}const IH=new Map;function XBn(e,t){const[n,r]=b.useState(null);return b.useEffect(()=>{if(!e||!t){r(null);return}let s=IH.get(e);s||(s=mWe(e,t),IH.set(e,s),s.catch(()=>IH.delete(e)));let o=!1;return s.then(a=>{o||r(a)}),()=>{o=!0}},[e,t]),n}const JBn=`
1619
1619
  :host { display: block; width: 100%; }
@@ -1781,7 +1781,7 @@ lodash-es/lodash.js:
1781
1781
  `});return f(),d(),p+`
1782
1782
  `+(s===1?"=":"-").repeat(p.length-(Math.max(p.lastIndexOf("\r"),p.lastIndexOf(`
1783
1783
  `))+1))}const a="#".repeat(s),i=n.enter("headingAtx"),c=n.enter("phrasing");o.move(a+" ");let l=n.containerPhrasing(e,{before:"# ",after:`
1784
- `,...o.current()});return/^[\t ]/.test(l)&&(l="&#x"+l.charCodeAt(0).toString(16).toUpperCase()+";"+l.slice(1)),l=l?a+" "+l:a,n.options.closeAtx&&(l+=" "+a),c(),i(),l}ptt.peek=Uor;function ptt(e){return e.value||""}function Uor(){return"<"}htt.peek=zor;function htt(e,t,n,r){const s=Hse(n),o=s==='"'?"Quote":"Apostrophe",a=n.enter("image");let i=n.enter("label");const c=n.createTracker(r);let l=c.move("![");return l+=c.move(n.safe(e.alt,{before:l,after:"]",...c.current()})),l+=c.move("]("),i(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(i=n.enter("destinationLiteral"),l+=c.move("<"),l+=c.move(n.safe(e.url,{before:l,after:">",...c.current()})),l+=c.move(">")):(i=n.enter("destinationRaw"),l+=c.move(n.safe(e.url,{before:l,after:e.title?" ":")",...c.current()}))),i(),e.title&&(i=n.enter(`title${o}`),l+=c.move(" "+s),l+=c.move(n.safe(e.title,{before:l,after:s,...c.current()})),l+=c.move(s),i()),l+=c.move(")"),a(),l}function zor(){return"!"}mtt.peek=Hor;function mtt(e,t,n,r){const s=e.referenceType,o=n.enter("imageReference");let a=n.enter("label");const i=n.createTracker(r);let c=i.move("![");const l=n.safe(e.alt,{before:c,after:"]",...i.current()});c+=i.move(l+"]["),a();const d=n.stack;n.stack=[],a=n.enter("reference");const f=n.safe(n.associationId(e),{before:c,after:"]",...i.current()});return a(),n.stack=d,o(),s==="full"||!l||l!==f?c+=i.move(f+"]"):s==="shortcut"?c=c.slice(0,-1):c+=i.move("]"),c}function Hor(){return"!"}gtt.peek=Vor;function gtt(e,t,n){let r=e.value||"",s="`",o=-1;for(;new RegExp("(^|[^`])"+s+"([^`]|$)").test(r);)s+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++o<n.unsafe.length;){const a=n.unsafe[o],i=n.compilePattern(a);let c;if(a.atBreak)for(;c=i.exec(r);){let l=c.index;r.charCodeAt(l)===10&&r.charCodeAt(l-1)===13&&l--,r=r.slice(0,l)+" "+r.slice(c.index+1)}}return s+r+s}function Vor(){return"`"}function ytt(e,t){const n=SR(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}btt.peek=Gor;function btt(e,t,n,r){const s=Hse(n),o=s==='"'?"Quote":"Apostrophe",a=n.createTracker(r);let i,c;if(ytt(e,n)){const d=n.stack;n.stack=[],i=n.enter("autolink");let f=a.move("<");return f+=a.move(n.containerPhrasing(e,{before:f,after:">",...a.current()})),f+=a.move(">"),i(),n.stack=d,f}i=n.enter("link"),c=n.enter("label");let l=a.move("[");return l+=a.move(n.containerPhrasing(e,{before:l,after:"](",...a.current()})),l+=a.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),l+=a.move("<"),l+=a.move(n.safe(e.url,{before:l,after:">",...a.current()})),l+=a.move(">")):(c=n.enter("destinationRaw"),l+=a.move(n.safe(e.url,{before:l,after:e.title?" ":")",...a.current()}))),c(),e.title&&(c=n.enter(`title${o}`),l+=a.move(" "+s),l+=a.move(n.safe(e.title,{before:l,after:s,...a.current()})),l+=a.move(s),c()),l+=a.move(")"),i(),l}function Gor(e,t,n){return ytt(e,n)?"<":"["}vtt.peek=Wor;function vtt(e,t,n,r){const s=e.referenceType,o=n.enter("linkReference");let a=n.enter("label");const i=n.createTracker(r);let c=i.move("[");const l=n.containerPhrasing(e,{before:c,after:"]",...i.current()});c+=i.move(l+"]["),a();const d=n.stack;n.stack=[],a=n.enter("reference");const f=n.safe(n.associationId(e),{before:c,after:"]",...i.current()});return a(),n.stack=d,o(),s==="full"||!l||l!==f?c+=i.move(f+"]"):s==="shortcut"?c=c.slice(0,-1):c+=i.move("]"),c}function Wor(){return"["}function Vse(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Kor(e){const t=Vse(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Zor(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function xtt(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function Yor(e,t,n,r){const s=n.enter("list"),o=n.bulletCurrent;let a=e.ordered?Zor(n):Vse(n);const i=e.ordered?a==="."?")":".":Kor(n);let c=t&&n.bulletLastUsed?a===n.bulletLastUsed:!1;if(!e.ordered){const d=e.children?e.children[0]:void 0;if((a==="*"||a==="-")&&d&&(!d.children||!d.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),xtt(n)===a&&d){let f=-1;for(;++f<e.children.length;){const p=e.children[f];if(p&&p.type==="listItem"&&p.children&&p.children[0]&&p.children[0].type==="thematicBreak"){c=!0;break}}}}c&&(a=i),n.bulletCurrent=a;const l=n.containerFlow(e,r);return n.bulletLastUsed=a,n.bulletCurrent=o,s(),l}function Qor(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function Xor(e,t,n,r){const s=Qor(n);let o=n.bulletCurrent||Vse(n);t&&t.type==="list"&&t.ordered&&(o=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let a=o.length+1;(s==="tab"||s==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(a=Math.ceil(a/4)*4);const i=n.createTracker(r);i.move(o+" ".repeat(a-o.length)),i.shift(a);const c=n.enter("listItem"),l=n.indentLines(n.containerFlow(e,i.current()),d);return c(),l;function d(f,p,h){return p?(h?"":" ".repeat(a))+f:(h?o:o+" ".repeat(a-o.length))+f}}function Jor(e,t,n,r){const s=n.enter("paragraph"),o=n.enter("phrasing"),a=n.containerPhrasing(e,r);return o(),s(),a}function ear(e,t,n,r){return(e.children.some(function(s){return utt(s)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function tar(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Ett.peek=nar;function Ett(e,t,n,r){const s=tar(n),o=n.enter("strong"),a=n.createTracker(r);let i=a.move(s+s);return i+=a.move(n.containerPhrasing(e,{before:i,after:s,...a.current()})),i+=a.move(s+s),o(),i}function nar(e,t,n){return n.options.strong||"*"}function rar(e,t,n,r){return n.safe(e.value,r)}function sar(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function oar(e,t,n){const r=(xtt(n)+(n.options.ruleSpaces?" ":"")).repeat(sar(n));return n.options.ruleSpaces?r.slice(0,-1):r}const aar={blockquote:Ior,break:hTe,code:Mor,definition:$or,emphasis:ftt,hardBreak:hTe,heading:qor,html:ptt,image:htt,imageReference:mtt,inlineCode:gtt,link:btt,linkReference:vtt,list:Yor,listItem:Xor,paragraph:Jor,root:ear,strong:Ett,text:rar,thematicBreak:oar};function iar(){return{exit:{taskListCheckValueChecked:mTe,taskListCheckValueUnchecked:mTe,paragraph:car}}}function lar(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:uar}}}function mTe(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function car(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const s=t.children;let o=-1,a;for(;++o<s.length;){const i=s[o];if(i.type==="paragraph"){a=i;break}}a===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function uar(e,t,n,r){const s=e.children[0],o=typeof e.checked=="boolean"&&s&&s.type==="paragraph",a="["+(e.checked?"x":" ")+"] ",i=n.createTracker(r);o&&i.move(a);let c=aar.listItem(e,t,n,{...r,...i.current()});return o&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(d){return d+a}}function dar(){return[dsr(),Ssr(),$sr(),Sor(),iar()]}function far(e){return{extensions:[fsr(),_sr(),Lsr(),Nor(e),lar()]}}const par={tokenize:xar,partial:!0},wtt={tokenize:Ear,partial:!0},Stt={tokenize:war,partial:!0},_tt={tokenize:Sar,partial:!0},har={tokenize:_ar,partial:!0},Ttt={name:"wwwAutolink",tokenize:yar,previous:ktt},Att={name:"protocolAutolink",tokenize:bar,previous:Ctt},xm={name:"emailAutolink",tokenize:gar,previous:Ntt},Lp={};function mar(){return{text:Lp}}let H0=48;for(;H0<123;)Lp[H0]=xm,H0++,H0===58?H0=65:H0===91&&(H0=97);Lp[43]=xm;Lp[45]=xm;Lp[46]=xm;Lp[95]=xm;Lp[72]=[xm,Att];Lp[104]=[xm,Att];Lp[87]=[xm,Ttt];Lp[119]=[xm,Ttt];function gar(e,t,n){const r=this;let s,o;return a;function a(f){return!vQ(f)||!Ntt.call(r,r.previous)||Gse(r.events)?n(f):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),i(f))}function i(f){return vQ(f)?(e.consume(f),i):f===64?(e.consume(f),c):n(f)}function c(f){return f===46?e.check(har,d,l)(f):f===45||f===95||hl(f)?(o=!0,e.consume(f),c):d(f)}function l(f){return e.consume(f),s=!0,c}function d(f){return o&&s&&Yl(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(f)):n(f)}}function yar(e,t,n){const r=this;return s;function s(a){return a!==87&&a!==119||!ktt.call(r,r.previous)||Gse(r.events)?n(a):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(par,e.attempt(wtt,e.attempt(Stt,o),n),n)(a))}function o(a){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(a)}}function bar(e,t,n){const r=this;let s="",o=!1;return a;function a(f){return(f===72||f===104)&&Ctt.call(r,r.previous)&&!Gse(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),s+=String.fromCodePoint(f),e.consume(f),i):n(f)}function i(f){if(Yl(f)&&s.length<5)return s+=String.fromCodePoint(f),e.consume(f),i;if(f===58){const p=s.toLowerCase();if(p==="http"||p==="https")return e.consume(f),c}return n(f)}function c(f){return f===47?(e.consume(f),o?l:(o=!0,c)):n(f)}function l(f){return f===null||J$(f)||Ys(f)||bv(f)||GF(f)?n(f):e.attempt(wtt,e.attempt(Stt,d),n)(f)}function d(f){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(f)}}function xar(e,t,n){let r=0;return s;function s(a){return(a===87||a===119)&&r<3?(r++,e.consume(a),s):a===46&&r===3?(e.consume(a),o):n(a)}function o(a){return a===null?n(a):t(a)}}function Ear(e,t,n){let r,s,o;return a;function a(l){return l===46||l===95?e.check(_tt,c,i)(l):l===null||Ys(l)||bv(l)||l!==45&&GF(l)?c(l):(o=!0,e.consume(l),a)}function i(l){return l===95?r=!0:(s=r,r=void 0),e.consume(l),a}function c(l){return s||r||!o?n(l):t(l)}}function war(e,t){let n=0,r=0;return s;function s(a){return a===40?(n++,e.consume(a),s):a===41&&r<n?o(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?e.check(_tt,t,o)(a):a===null||Ys(a)||bv(a)?t(a):(e.consume(a),s)}function o(a){return a===41&&r++,e.consume(a),s}}function Sar(e,t,n){return r;function r(i){return i===33||i===34||i===39||i===41||i===42||i===44||i===46||i===58||i===59||i===63||i===95||i===126?(e.consume(i),r):i===38?(e.consume(i),o):i===93?(e.consume(i),s):i===60||i===null||Ys(i)||bv(i)?t(i):n(i)}function s(i){return i===null||i===40||i===91||Ys(i)||bv(i)?t(i):r(i)}function o(i){return Yl(i)?a(i):n(i)}function a(i){return i===59?(e.consume(i),r):Yl(i)?(e.consume(i),a):n(i)}}function _ar(e,t,n){return r;function r(o){return e.consume(o),s}function s(o){return hl(o)?n(o):t(o)}}function ktt(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Ys(e)}function Ctt(e){return!Yl(e)}function Ntt(e){return!(e===47||vQ(e))}function vQ(e){return e===43||e===45||e===46||e===95||hl(e)}function Gse(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const Tar={tokenize:Dar,partial:!0};function Aar(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:Iar,continuation:{tokenize:Rar},exit:jar}},text:{91:{name:"gfmFootnoteCall",tokenize:Nar},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:kar,resolveTo:Car}}}}function kar(e,t,n){const r=this;let s=r.events.length;const o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a;for(;s--;){const c=r.events[s][1];if(c.type==="labelImage"){a=c;break}if(c.type==="gfmFootnoteCall"||c.type==="labelLink"||c.type==="label"||c.type==="image"||c.type==="link")break}return i;function i(c){if(!a||!a._balanced)return n(c);const l=Wd(r.sliceSerialize({start:a.end,end:r.now()}));return l.codePointAt(0)!==94||!o.includes(l.slice(1))?n(c):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),t(c))}}function Car(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},s={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};s.end.column++,s.end.offset++,s.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},s.end),end:Object.assign({},e[e.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},i=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",s,t],["exit",s,t],["enter",o,t],["enter",a,t],["exit",a,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...i),e}function Nar(e,t,n){const r=this,s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o=0,a;return i;function i(f){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),c}function c(f){return f!==94?n(f):(e.enter("gfmFootnoteCallMarker"),e.consume(f),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",l)}function l(f){if(o>999||f===93&&!a||f===null||f===91||Ys(f))return n(f);if(f===93){e.exit("chunkString");const p=e.exit("gfmFootnoteCallString");return s.includes(Wd(r.sliceSerialize(p)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(f)}return Ys(f)||(a=!0),o++,e.consume(f),f===92?d:l}function d(f){return f===91||f===92||f===93?(e.consume(f),o++,l):l(f)}}function Iar(e,t,n){const r=this,s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o,a=0,i;return c;function c(g){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),l}function l(g){return g===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",d):n(g)}function d(g){if(a>999||g===93&&!i||g===null||g===91||Ys(g))return n(g);if(g===93){e.exit("chunkString");const y=e.exit("gfmFootnoteDefinitionLabelString");return o=Wd(r.sliceSerialize(y)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),p}return Ys(g)||(i=!0),a++,e.consume(g),g===92?f:d}function f(g){return g===91||g===92||g===93?(e.consume(g),a++,d):d(g)}function p(g){return g===58?(e.enter("definitionMarker"),e.consume(g),e.exit("definitionMarker"),s.includes(o)||s.push(o),ls(e,h,"gfmFootnoteDefinitionWhitespace")):n(g)}function h(g){return t(g)}}function Rar(e,t,n){return e.check(_R,t,e.attempt(Tar,t,n))}function jar(e){e.exit("gfmFootnoteDefinition")}function Dar(e,t,n){const r=this;return ls(e,s,"gfmFootnoteDefinitionIndent",5);function s(o){const a=r.events[r.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?t(o):n(o)}}function Oar(e){let t=(e||{}).singleTilde;const n={name:"strikethrough",tokenize:s,resolveAll:r};return t==null&&(t=!0),{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(o,a){let i=-1;for(;++i<o.length;)if(o[i][0]==="enter"&&o[i][1].type==="strikethroughSequenceTemporary"&&o[i][1]._close){let c=i;for(;c--;)if(o[c][0]==="exit"&&o[c][1].type==="strikethroughSequenceTemporary"&&o[c][1]._open&&o[i][1].end.offset-o[i][1].start.offset===o[c][1].end.offset-o[c][1].start.offset){o[i][1].type="strikethroughSequence",o[c][1].type="strikethroughSequence";const l={type:"strikethrough",start:Object.assign({},o[c][1].start),end:Object.assign({},o[i][1].end)},d={type:"strikethroughText",start:Object.assign({},o[c][1].end),end:Object.assign({},o[i][1].start)},f=[["enter",l,a],["enter",o[c][1],a],["exit",o[c][1],a],["enter",d,a]],p=a.parser.constructs.insideSpan.null;p&&td(f,f.length,0,WF(p,o.slice(c+1,i),a)),td(f,f.length,0,[["exit",d,a],["enter",o[i][1],a],["exit",o[i][1],a],["exit",l,a]]),td(o,c-1,i-c+3,f),i=c+f.length-2;break}}for(i=-1;++i<o.length;)o[i][1].type==="strikethroughSequenceTemporary"&&(o[i][1].type="data");return o}function s(o,a,i){const c=this.previous,l=this.events;let d=0;return f;function f(h){return c===126&&l[l.length-1][1].type!=="characterEscape"?i(h):(o.enter("strikethroughSequenceTemporary"),p(h))}function p(h){const g=Lw(c);if(h===126)return d>1?i(h):(o.consume(h),d++,p);if(d<2&&!t)return i(h);const y=o.exit("strikethroughSequenceTemporary"),E=Lw(h);return y._open=!E||E===2&&!!g,y._close=!g||g===2&&!!E,a(h)}}}class Mar{constructor(){this.map=[]}add(t,n,r){Par(this,t,n,r)}consume(t){if(this.map.sort(function(o,a){return o[0]-a[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push([...t]),t.length=0;let s=r.pop();for(;s;)t.push(...s),s=r.pop();this.map.length=0}}function Par(e,t,n,r){let s=0;if(!(n===0&&r.length===0)){for(;s<e.map.length;){if(e.map[s][0]===t){e.map[s][1]+=n,e.map[s][2].push(...r);return}s+=1}e.map.push([t,n,r])}}function $ar(e,t){let n=!1;const r=[];for(;t<e.length;){const s=e[t];if(n){if(s[0]==="enter")s[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(s[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const o=r.length-1;r[o]=r[o]==="left"?"center":"right"}}else if(s[1].type==="tableDelimiterRow")break}else s[0]==="enter"&&s[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function Lar(){return{flow:{null:{name:"table",tokenize:Far,resolveAll:Bar}}}}function Far(e,t,n){const r=this;let s=0,o=0,a;return i;function i(D){let L=r.events.length-1;for(;L>-1;){const M=r.events[L][1].type;if(M==="lineEnding"||M==="linePrefix")L--;else break}const U=L>-1?r.events[L][1].type:null,B=U==="tableHead"||U==="tableRow"?A:c;return B===A&&r.parser.lazy[r.now().line]?n(D):B(D)}function c(D){return e.enter("tableHead"),e.enter("tableRow"),l(D)}function l(D){return D===124||(a=!0,o+=1),d(D)}function d(D){return D===null?n(D):On(D)?o>1?(o=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(D),e.exit("lineEnding"),h):n(D):zr(D)?ls(e,d,"whitespace")(D):(o+=1,a&&(a=!1,s+=1),D===124?(e.enter("tableCellDivider"),e.consume(D),e.exit("tableCellDivider"),a=!0,d):(e.enter("data"),f(D)))}function f(D){return D===null||D===124||Ys(D)?(e.exit("data"),d(D)):(e.consume(D),D===92?p:f)}function p(D){return D===92||D===124?(e.consume(D),f):f(D)}function h(D){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(D):(e.enter("tableDelimiterRow"),a=!1,zr(D)?ls(e,g,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):g(D))}function g(D){return D===45||D===58?E(D):D===124?(a=!0,e.enter("tableCellDivider"),e.consume(D),e.exit("tableCellDivider"),y):k(D)}function y(D){return zr(D)?ls(e,E,"whitespace")(D):E(D)}function E(D){return D===58?(o+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(D),e.exit("tableDelimiterMarker"),x):D===45?(o+=1,x(D)):D===null||On(D)?T(D):k(D)}function x(D){return D===45?(e.enter("tableDelimiterFiller"),w(D)):k(D)}function w(D){return D===45?(e.consume(D),w):D===58?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(D),e.exit("tableDelimiterMarker"),S):(e.exit("tableDelimiterFiller"),S(D))}function S(D){return zr(D)?ls(e,T,"whitespace")(D):T(D)}function T(D){return D===124?g(D):D===null||On(D)?!a||s!==o?k(D):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(D)):k(D)}function k(D){return n(D)}function A(D){return e.enter("tableRow"),N(D)}function N(D){return D===124?(e.enter("tableCellDivider"),e.consume(D),e.exit("tableCellDivider"),N):D===null||On(D)?(e.exit("tableRow"),t(D)):zr(D)?ls(e,N,"whitespace")(D):(e.enter("data"),j(D))}function j(D){return D===null||D===124||Ys(D)?(e.exit("data"),N(D)):(e.consume(D),D===92?O:j)}function O(D){return D===92||D===124?(e.consume(D),j):j(D)}}function Bar(e,t){let n=-1,r=!0,s=0,o=[0,0,0,0],a=[0,0,0,0],i=!1,c=0,l,d,f;const p=new Mar;for(;++n<e.length;){const h=e[n],g=h[1];h[0]==="enter"?g.type==="tableHead"?(i=!1,c!==0&&(gTe(p,t,c,l,d),d=void 0,c=0),l={type:"table",start:Object.assign({},g.start),end:Object.assign({},g.end)},p.add(n,0,[["enter",l,t]])):g.type==="tableRow"||g.type==="tableDelimiterRow"?(r=!0,f=void 0,o=[0,0,0,0],a=[0,n+1,0,0],i&&(i=!1,d={type:"tableBody",start:Object.assign({},g.start),end:Object.assign({},g.end)},p.add(n,0,[["enter",d,t]])),s=g.type==="tableDelimiterRow"?2:d?3:1):s&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")?(r=!1,a[2]===0&&(o[1]!==0&&(a[0]=a[1],f=zD(p,t,o,s,void 0,f),o=[0,0,0,0]),a[2]=n)):g.type==="tableCellDivider"&&(r?r=!1:(o[1]!==0&&(a[0]=a[1],f=zD(p,t,o,s,void 0,f)),o=a,a=[o[1],n,0,0])):g.type==="tableHead"?(i=!0,c=n):g.type==="tableRow"||g.type==="tableDelimiterRow"?(c=n,o[1]!==0?(a[0]=a[1],f=zD(p,t,o,s,n,f)):a[1]!==0&&(f=zD(p,t,a,s,n,f)),s=0):s&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")&&(a[3]=n)}for(c!==0&&gTe(p,t,c,l,d),p.consume(t.events),n=-1;++n<t.events.length;){const h=t.events[n];h[0]==="enter"&&h[1].type==="table"&&(h[1]._align=$ar(t.events,n))}return e}function zD(e,t,n,r,s,o){const a=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",i="tableContent";n[0]!==0&&(o.end=Object.assign({},nE(t.events,n[0])),e.add(n[0],0,[["exit",o,t]]));const c=nE(t.events,n[1]);if(o={type:a,start:Object.assign({},c),end:Object.assign({},c)},e.add(n[1],0,[["enter",o,t]]),n[2]!==0){const l=nE(t.events,n[2]),d=nE(t.events,n[3]),f={type:i,start:Object.assign({},l),end:Object.assign({},d)};if(e.add(n[2],0,[["enter",f,t]]),r!==2){const p=t.events[n[2]],h=t.events[n[3]];if(p[1].end=Object.assign({},h[1].end),p[1].type="chunkText",p[1].contentType="text",n[3]>n[2]+1){const g=n[2]+1,y=n[3]-n[2]-1;e.add(g,y,[])}}e.add(n[3]+1,0,[["exit",f,t]])}return s!==void 0&&(o.end=Object.assign({},nE(t.events,s)),e.add(s,0,[["exit",o,t]]),o=void 0),o}function gTe(e,t,n,r,s){const o=[],a=nE(t.events,n);s&&(s.end=Object.assign({},a),o.push(["exit",s,t])),r.end=Object.assign({},a),o.push(["exit",r,t]),e.add(n+1,0,o)}function nE(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const qar={name:"tasklistCheck",tokenize:zar};function Uar(){return{text:{91:qar}}}function zar(e,t,n){const r=this;return s;function s(c){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(c):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),o)}function o(c){return Ys(c)?(e.enter("taskListCheckValueUnchecked"),e.consume(c),e.exit("taskListCheckValueUnchecked"),a):c===88||c===120?(e.enter("taskListCheckValueChecked"),e.consume(c),e.exit("taskListCheckValueChecked"),a):n(c)}function a(c){return c===93?(e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),i):n(c)}function i(c){return On(c)?t(c):zr(c)?e.check({tokenize:Har},t,n)(c):n(c)}}function Har(e,t,n){return ls(e,r,"whitespace");function r(s){return s===null?n(s):t(s)}}function Var(e){return U7e([mar(),Aar(),Oar(e),Lar(),Uar()])}const Gar={};function War(e){const t=this,n=e||Gar,r=t.data(),s=r.micromarkExtensions||(r.micromarkExtensions=[]),o=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);s.push(Var(n)),o.push(dar()),a.push(far(n))}const Kar=e=>e.startsWith("https://www.youtube.com/")||e.startsWith("https://youtube.com/")||e.startsWith("https://www.youtube-nocookie.com/"),Zar=e=>{if(!e)return;const t=e.trim();if(/^https?:\/\//i.test(t))return t},Yar={...eC,tagNames:[...eC.tagNames??[],"iframe"],attributes:{...eC.attributes??{},iframe:["src","title","width","height","allow","allowFullScreen","referrerPolicy"]}},Qar={iframe:({src:e,...t})=>!e||!Kar(e)?null:u.jsx("iframe",{src:e,width:"100%",height:400,title:t.title??"Embedded content",className:"w-full rounded-lg border border-[var(--gray-a4)] bg-black",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",referrerPolicy:"strict-origin-when-cross-origin",allowFullScreen:!0}),h1:e=>u.jsx("h1",{className:"text-2xl font-semibold text-[var(--gray-12)]",...e}),h2:e=>u.jsx("h2",{className:"text-xl font-semibold text-[var(--gray-12)]",...e}),h3:e=>u.jsx("h3",{className:"text-lg font-semibold text-[var(--gray-12)]",...e}),p:e=>u.jsx("p",{className:"text-sm leading-6 text-[var(--gray-11)] whitespace-pre-wrap",...e}),ul:e=>u.jsx("ul",{className:"list-disc pl-6 text-sm text-[var(--gray-11)]",...e}),ol:e=>u.jsx("ol",{className:"list-decimal pl-6 text-sm text-[var(--gray-11)]",...e}),li:e=>u.jsx("li",{className:"leading-6",...e}),a:({href:e,children:t,rel:n,target:r,className:s,...o})=>{const a=Zar(e);return a?u.jsx("a",{...o,href:a,target:"_blank",rel:"noopener noreferrer",className:jr("text-[var(--blue-11)] hover:underline break-all",s),children:t}):u.jsx("span",{className:"text-[var(--gray-11)] break-all",children:t})},pre:e=>u.jsx("pre",{className:"overflow-x-auto rounded-lg border border-[var(--gray-a4)] bg-[var(--gray-1)] p-3 text-xs text-[var(--gray-11)]",...e}),code:e=>u.jsx("code",{className:"font-mono text-xs",...e}),hr:e=>u.jsx("hr",{className:"border-[var(--gray-a4)]",...e})},Xar=e=>{const[t,n]=b.useState(void 0),[r,s]=b.useState(void 0);return b.useEffect(()=>{const o=new AbortController;let a=!1;return n(void 0),s(void 0),e?(fetch(e,{signal:o.signal}).then(async i=>{var c;if(!i.ok)return;const l=await i.text();(((c=i.headers.get("content-type"))==null?void 0:c.toLowerCase())??"").includes("text/html")&&/<html[\s>]/i.test(l.slice(0,512))||!a&&!o.signal.aborted&&n(l)}).catch(i=>{i instanceof DOMException&&i.name}).finally(()=>{!a&&!o.signal.aborted&&s(e)}),()=>{a=!0,o.abort()}):()=>{a=!0,o.abort()}},[e]),{readme:t,isLoading:!!e&&r!==e}},Jar=({readme:e,isLoading:t=!1,className:n,loadingContent:r,emptyContent:s})=>t?r??u.jsx("div",{className:"flex items-center justify-center py-16",children:u.jsx(nn,{className:"h-6 w-6 animate-spin text-[var(--gray-9)]"})}):e?u.jsx("div",{className:jr("flex flex-col gap-4",n),children:u.jsx(Per,{remarkPlugins:[War],rehypePlugins:[Zrr,[osr,Yar]],components:Qar,children:e})}):s??u.jsx("p",{className:"text-sm text-[var(--gray-11)]",children:"No additional integration documentation is available."}),eir=e=>e.startsWith("http")?e:`https://${e}`,tir=e=>"Source Code",nir=e=>"Documentation",rir=({version:e,githubUrl:t,guideUrl:n,onAboutClick:r,aboutLabel:s="About Integration",formatGithubLabel:o=tir,formatGuideLabel:a=nir})=>u.jsxs("div",{className:"flex items-start gap-12 px-6 py-4 rounded-lg border border-[var(--gray-a4)] bg-[var(--gray-a2)]",children:[u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("span",{className:"text-xs text-[var(--gray-11)]",children:"Version"}),u.jsx("span",{className:"text-sm font-medium text-[var(--gray-12)]",children:e})]}),t&&u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("span",{className:"text-xs text-[var(--gray-11)]",children:"GitHub"}),u.jsxs("a",{href:eir(t),target:"_blank",rel:"noopener noreferrer",className:"inline-flex w-fit items-center gap-1 text-sm font-medium text-[var(--blue-11)] hover:underline",children:[o(t),u.jsx(EW,{className:"h-3.5 w-3.5"})]})]}),n&&u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("span",{className:"text-xs text-[var(--gray-11)]",children:"Documentation"}),u.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"inline-flex w-fit items-center gap-1 text-sm font-medium text-[var(--blue-11)] hover:underline",children:[a(n),u.jsx(EW,{className:"h-3.5 w-3.5"})]})]}),r&&u.jsx("button",{type:"button",onClick:r,className:"ml-auto text-sm text-[var(--gray-11)] hover:text-[var(--gray-12)] p-0 h-auto cursor-pointer mt-2.5 border-0 bg-transparent",children:s})]}),TM=jr("relative px-3 py-3 text-sm font-medium cursor-pointer rounded-none flex-none border-none","text-[var(--gray-11)] hover:text-[var(--gray-12)] data-active:text-[var(--gray-12)]",'after:content-[""] after:absolute after:bottom-0 after:left-0 after:right-0 after:h-0.5 after:rounded-full after:bg-transparent data-active:after:bg-[var(--gray-12)]'),yTe=jr(TM,"px-12 py-4","after:inset-x-6"),sir=({hasConnectionStep:e,hasConfigurationStep:t})=>e?"connections":t?"configuration":"capabilities",oir=({integrationTitle:e,isFullyConfigured:t,hasConnectionStep:n,hasConfigurationStep:r,useSetupStepTabs:s=!1,configuredTab:o,onConfiguredTabChange:a,setupTab:i,onSetupTabChange:c,onCancelSetup:l,metadata:d,connectionsContent:f,configurationContent:p,capabilitiesContent:h,setupEmptyContent:g})=>{const y=n,E=r,x=sir({hasConnectionStep:n,hasConfigurationStep:r}),w=o==="connections"&&!y||o==="configuration"&&!E?x:o;return u.jsxs("div",{className:"flex flex-col gap-6 mt-6",children:[d,t?u.jsxs("div",{className:"flex flex-col",children:[u.jsxs("div",{className:"flex items-center border-b border-[var(--gray-a4)]",role:"tablist","aria-label":"Integration sections",children:[y&&u.jsx("button",{type:"button",id:"integration-configured-tab-connections",role:"tab","aria-selected":w==="connections","aria-controls":"integration-configured-panel-connections",className:TM,"data-active":w==="connections"?"true":void 0,onClick:()=>a("connections"),children:"Connections"}),E&&u.jsx("button",{type:"button",id:"integration-configured-tab-configuration",role:"tab","aria-selected":w==="configuration","aria-controls":"integration-configured-panel-configuration",className:TM,"data-active":w==="configuration"?"true":void 0,onClick:()=>a("configuration"),children:"Configuration"}),u.jsx("button",{type:"button",id:"integration-configured-tab-capabilities",role:"tab","aria-selected":w==="capabilities","aria-controls":"integration-configured-panel-capabilities",className:TM,"data-active":w==="capabilities"?"true":void 0,onClick:()=>a("capabilities"),children:"Capabilities"})]}),w==="connections"&&u.jsx("div",{className:"pt-4",role:"tabpanel",id:"integration-configured-panel-connections","aria-labelledby":"integration-configured-tab-connections",children:f}),w==="configuration"&&u.jsx("div",{className:"pt-4",role:"tabpanel",id:"integration-configured-panel-configuration","aria-labelledby":"integration-configured-tab-configuration",children:p}),w==="capabilities"&&u.jsx("div",{className:"pt-4",role:"tabpanel",id:"integration-configured-panel-capabilities","aria-labelledby":"integration-configured-tab-capabilities",children:h})]}):u.jsxs("div",{className:"rounded-lg border border-[var(--gray-a4)] bg-[var(--gray-a2)] overflow-hidden",children:[u.jsxs("div",{className:"flex items-center border-b border-[var(--gray-a4)] justify-between px-6 py-4",children:[u.jsxs("h3",{className:"text-base font-semibold text-[var(--gray-12)]",children:["Set Up ",e," Integration"]}),u.jsx("button",{type:"button",onClick:l,className:"text-sm text-[var(--gray-11)] hover:text-[var(--gray-12)] p-0 h-auto cursor-pointer",children:"Cancel"})]}),s&&n&&r?u.jsxs("div",{className:"flex flex-col",children:[u.jsxs("div",{className:"flex items-center px-6 border-b border-[var(--gray-a4)]",role:"tablist","aria-label":"Setup steps",children:[u.jsx("button",{type:"button",id:"integration-setup-tab-connections",role:"tab","aria-selected":i==="connections","aria-controls":"integration-setup-panel-connections",className:yTe,"data-active":i==="connections"?"true":void 0,onClick:()=>c("connections"),children:"1. Connections"}),u.jsx("button",{type:"button",id:"integration-setup-tab-configuration",role:"tab","aria-selected":i==="configuration","aria-controls":"integration-setup-panel-configuration",className:yTe,"data-active":i==="configuration"?"true":void 0,onClick:()=>c("configuration"),children:"2. Configuration"})]}),i==="connections"&&u.jsx("div",{className:"p-6",role:"tabpanel",id:"integration-setup-panel-connections","aria-labelledby":"integration-setup-tab-connections",children:f}),i==="configuration"&&u.jsx("div",{className:"p-6",role:"tabpanel",id:"integration-setup-panel-configuration","aria-labelledby":"integration-setup-tab-configuration",children:p})]}):n?u.jsx("div",{className:"p-6",children:f}):r?u.jsx("div",{className:"p-6",children:p}):u.jsx("div",{className:"flex items-center justify-center p-6 py-12",children:g??u.jsx("p",{className:"text-sm text-[var(--gray-11)]",children:"This integration is ready to use."})})]})]})},air="flex items-center gap-2 px-3 py-2 text-sm rounded-md cursor-pointer text-left whitespace-normal break-words",iir=({options:e,value:t,onChange:n,disabled:r=!1})=>{var s;if(e.length<=1)return null;const o=((s=e.find(a=>a.value===t))==null?void 0:s.label)??String(t??"");return u.jsxs(_se,{children:[u.jsxs(v7e,{disabled:r,className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-[var(--gray-a3)] text-sm text-[var(--gray-12)] hover:bg-[var(--gray-a4)] cursor-pointer border-none outline-none w-[165px] disabled:opacity-60 disabled:cursor-not-allowed",children:[u.jsx("span",{className:"truncate flex-1 text-left",children:o}),u.jsx(Dr,{className:"w-4 h-4 shrink-0"})]}),u.jsx(d7e,{children:u.jsx(h7e,{className:"isolate z-50 outline-none",align:"end",side:"bottom",sideOffset:6,children:u.jsx(c7e,{role:"menu",className:"bg-[var(--gray-2)] rounded-lg p-1 shadow-lg w-(--anchor-width) overflow-hidden",children:e.map(a=>u.jsx(dJe,{onClick:()=>n(a.value),className:jr(air,t===a.value?"text-[var(--gray-12)] bg-[var(--gray-a3)]":"text-[var(--gray-11)] hover:bg-[var(--gray-a3)]"),children:a.label},a.value??"__default"))})})})]})},lir=({integrationName:e,canAuthorize:t,isAuthorizing:n=!1,isAuthorized:r=!1,disabled:s=!1,showInstallHint:o=!1,onClick:a})=>{const i=s||!t||n;return u.jsxs("div",{className:"flex flex-col items-end gap-2",children:[u.jsx("button",{type:"button",disabled:i,onClick:a,className:jr("inline-flex flex-row items-center gap-2 rounded-md px-4 py-2 h-auto text-sm font-medium transition-opacity","border-none bg-[var(--gray-12)] text-[var(--gray-1)]",i?"cursor-not-allowed opacity-60":"cursor-pointer hover:opacity-90"),children:n?u.jsx(za,{className:"h-4 w-4 animate-spin"}):r?u.jsxs(u.Fragment,{children:[u.jsx(Ms,{className:"h-4 w-4 text-green-500"}),"Re-authorize ",e]}):u.jsxs(u.Fragment,{children:[u.jsx(TC,{className:"h-4 w-4"}),"Connect with OAuth"]})}),o&&u.jsx("p",{className:"text-xs text-[var(--gray-11)]",children:"Install the integration first to start OAuth authorization."})]})},cir="A unique endpoint that external services can POST data to, allowing the integration to receive events, messages, or other updates from external services.",iL=({webhookUrl:e,title:t="Webhook",titleClassName:n="text-sm font-bold text-[var(--gray-12)]",helpText:r=cir})=>{const[s,o]=b.useState(!1),a=b.useRef(null);if(b.useEffect(()=>()=>{a.current&&window.clearTimeout(a.current)},[]),!e)return null;const i=async()=>{try{await navigator.clipboard.writeText(e),o(!0),a.current&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>o(!1),1500)}catch{o(!1)}};return u.jsxs("div",{className:"flex flex-col gap-3",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("h5",{className:n,children:t}),u.jsxs("div",{className:"relative group",children:[u.jsx("button",{type:"button",className:"inline-flex items-center justify-center w-5 h-5 rounded-full text-[var(--gray-a8)] hover:text-[var(--gray-10)] focus-visible:outline-2 focus-visible:outline-[var(--accent-9)]","aria-label":"Webhook information",children:u.jsx(xCt,{size:16,className:"text-[var(--gray-a8)] cursor-help"})}),u.jsxs("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 hidden group-hover:block w-[280px] p-3 rounded-lg bg-[var(--gray-12)] text-[var(--gray-1)] text-xs leading-relaxed z-50",role:"tooltip",children:[r,u.jsx("div",{className:"absolute top-full left-1/2 -translate-x-1/2 border-[6px] border-transparent border-t-[var(--gray-12)]"})]})]})]}),u.jsx("button",{type:"button",onClick:()=>void i(),"aria-label":"Copy webhook URL",className:jr("w-full cursor-pointer rounded-md border border-[var(--gray-5)] p-1.5 text-left transition-colors",s?"border-[var(--grass-5)] bg-[var(--grass-3)]":"hover:border-[var(--gray-7)] hover:bg-[var(--gray-2)]"),children:u.jsxs("div",{className:"flex items-center justify-between overflow-hidden gap-4",children:[u.jsx("code",{className:"truncate rounded-sm bg-[var(--gray-a4)] px-1.5 py-0.5 font-mono text-xs leading-5 text-[var(--gray-11)]",children:e}),u.jsx("span",{className:"shrink-0",children:s?u.jsx(Xr,{className:"w-4 h-4 text-[var(--grass-10)]"}):u.jsx(li,{className:"w-4 h-4 text-[var(--gray-10)]"})})]})})]})},uir=({title:e="Configuration",webhookUrl:t,isBlocked:n=!1,blockedMessage:r="Complete the connection step first to configure this integration.",children:s})=>n?u.jsx("div",{className:"flex flex-col items-center justify-center py-12 text-[var(--gray-11)]",children:u.jsx("p",{className:"text-sm",children:r})}):u.jsxs("div",{className:"flex flex-col gap-6",children:[u.jsx("h4",{className:"text-base font-bold text-[var(--gray-12)]",children:e}),u.jsx(iL,{webhookUrl:t}),s]}),dir={action:{icon:tI,bg:"bg-teal-50",color:"text-teal-600",disabledBg:"bg-teal-50",disabledColor:"text-teal-600"},event:{icon:Sa,bg:"bg-purple-50",color:"text-purple-600",disabledBg:"bg-[var(--gray-a3)]",disabledColor:"text-[var(--gray-9)]"},channel:{icon:Kb,bg:"bg-blue-50",color:"text-blue-500",disabledBg:"bg-blue-50",disabledColor:"text-blue-500"}},fir=(e,t)=>!!(e&&e.key===t.key&&e.type===t.type),P9=({title:e,subtitle:t,cards:n,selectedCard:r,onCardSelect:s})=>n.length?u.jsxs("div",{className:"flex flex-col",children:[u.jsx("h3",{className:"text-sm font-semibold text-[var(--gray-12)] mb-3",children:e}),u.jsx("p",{className:"text-xs text-[var(--gray-11)]",children:t}),u.jsx("div",{className:"grid grid-cols-3 gap-x-8 gap-y-6 mt-4",children:n.map(o=>{const a=dir[o.type],i=a.icon,c=fir(r,o),l=o.enabled??!0;return u.jsxs("button",{type:"button",onClick:()=>s?.(c?null:o),className:jr("flex gap-3 p-3 h-auto rounded-lg border cursor-pointer transition-colors text-left",o.description?"items-start":"items-center",c?"border-[var(--blue-8)] bg-[var(--blue-a2)]":"border-[var(--gray-a4)] bg-[var(--gray-a2)] hover:bg-[var(--gray-a3)]"),children:[u.jsx("div",{className:jr("flex items-center justify-center w-8 h-8 rounded-lg shrink-0",l?a.bg:a.disabledBg),children:u.jsx(i,{className:jr("w-4 h-4",l?a.color:a.disabledColor)})}),u.jsxs("div",{className:"min-w-0 flex-1",children:[u.jsx("div",{className:"text-sm font-medium text-[var(--gray-12)] truncate",children:o.name}),o.description&&u.jsx("div",{className:"text-xs text-[var(--gray-11)] truncate",children:o.description})]}),o.type==="event"&&u.jsx(NIt,{className:jr("w-4 h-4 shrink-0",l?"text-green-500":"text-[var(--gray-9)]")}),o.billable&&u.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-[var(--gray-a4)] text-[var(--gray-11)] shrink-0",children:"Billable"})]},`${o.type}:${o.key}`)})})]}):null,pir=({actionCards:e=[],eventCards:t=[],channelCards:n=[],selectedCard:r,onCardSelect:s,title:o="Cards"})=>e.length>0||t.length>0||n.length>0?u.jsxs("div",{className:"flex flex-col gap-4",children:[u.jsx("h4",{className:"text-base font-bold text-[var(--gray-12)]",children:o}),u.jsxs("div",{className:"flex flex-col gap-6",children:[P9({title:"Action Cards",subtitle:"Cards to perform specific operations within a workflow",cards:e,selectedCard:r,onCardSelect:s}),P9({title:"Trigger Cards",subtitle:"Cards that listen for specific events to start a workflow",cards:t,selectedCard:r,onCardSelect:s}),P9({title:"Channel Cards",subtitle:"Cards related to channel communication events and actions",cards:n,selectedCard:r,onCardSelect:s})]})]}):null,hir=e=>{e.editor.defineTheme("bp-hub-light",{base:"vs",inherit:!0,rules:[],colors:{"editor.background":"#00000000","editorGutter.background":"#00000000"}}),e.editor.defineTheme("bp-hub-dark",{base:"vs-dark",inherit:!0,rules:[],colors:{"editor.background":"#00000000","editorGutter.background":"#00000000"}})},mir=async()=>(await c5(async()=>{const{transforms:e}=await import("./index-C72JGlc0.js");return{transforms:e}},[])).transforms,$9=(e,t)=>{const[n,r]=b.useState("");return b.useEffect(()=>{if(!e){r("");return}let s=!1;return mir().then(o=>{const a=o.fromJSONSchemaLegacy(e);return o.toTypescriptType(a,{declaration:!1,includeClosingTags:!0})}).then(o=>{s||r(`type ${t} = ${o}`)}).catch(()=>{s||r("")}),()=>{s=!0}},[e,t]),n},gir=()=>typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"vs-dark":"vs",yir=e=>{const[t,n]=b.useState(gir);return b.useEffect(()=>{if(e||typeof window>"u")return;const r=window.matchMedia("(prefers-color-scheme: dark)"),s=o=>n(o.matches?"vs-dark":"vs");return r.addEventListener("change",s),()=>r.removeEventListener("change",s)},[e]),e??t},bir=()=>{const[e,t]=b.useState(null);return b.useEffect(()=>{let n=!1;return c5(()=>import("./index-DfjXY3Oo.js"),[]).then(r=>{n||t(()=>r.default)}).catch(()=>{}),()=>{n=!0}},[]),e},vir=({definition:e,selected:t,integrationName:n,enabledEvents:r,onToggleEvent:s,isEventToggleDisabled:o,monacoTheme:a})=>{var i,c,l,d;const f=yir(a),p=t.type==="action"?(i=e.actions)==null?void 0:i[t.key]:void 0,h=t.type==="event"?(c=e.events)==null?void 0:c[t.key]:void 0,g=$9((l=p?.input)==null?void 0:l.schema,"Input"),y=$9((d=p?.output)==null?void 0:d.schema,"Output"),E=$9(h?.schema,"Event"),[x,w]=b.useState("input"),S=t.type==="action"?x==="input"?g:y:E;if(t.type==="channel")return u.jsxs("div",{className:"flex h-full flex-col items-center justify-center p-6 text-center",children:[u.jsx("p",{className:"text-sm text-[var(--gray-11)]",children:"Schema preview is not available for channels."}),u.jsx("p",{className:"mt-1 text-xs text-[var(--gray-10)]",children:"Channels expose a set of message types rather than a single request/response schema."})]});const T=r?.has(t.key)??!1;return u.jsxs("div",{className:"flex h-full flex-col",children:[t.type==="event"&&s&&u.jsxs("div",{className:"mx-3 mt-3 rounded-lg border border-[var(--gray-a4)] bg-[var(--gray-a2)] p-4",children:[u.jsxs("div",{className:"flex w-full flex-row items-center",children:[u.jsx("span",{className:"whitespace-nowrap text-sm font-medium text-[var(--gray-12)]",children:"Enable Trigger"}),u.jsx("div",{className:"ml-auto shrink-0",children:u.jsx(Sir,{checked:T,disabled:o,onChange:k=>void s(t.key,k)})})]}),u.jsxs("div",{className:"mt-1 text-xs text-[var(--gray-11)]",children:[t.key," trigger for this integration"]})]}),u.jsxs("div",{className:"flex items-center gap-2 p-3",children:[t.type==="action"?u.jsxs("div",{className:"flex flex-1 rounded-lg bg-[var(--gray-a3)] p-1",children:[u.jsx(bTe,{active:x==="input",onClick:()=>w("input"),children:"Input"}),u.jsx(bTe,{active:x==="output",onClick:()=>w("output"),children:"Output"})]}):u.jsx("div",{className:"flex flex-1 rounded-lg bg-[var(--gray-a3)] p-1",children:u.jsx("div",{className:"flex-1 rounded-md bg-[var(--color-background,var(--gray-1))] px-3 py-2 text-center text-sm font-medium text-[var(--gray-12)] shadow-sm",children:"Event"})}),u.jsx(wir,{schemaTs:S})]}),u.jsx(xir,{children:u.jsx(Eir,{schemaTs:S,title:t.type==="action"?x==="input"?"Input":"Output":"Event",integrationName:n,cardKey:t.key,monacoTheme:f})})]})},xir=({children:e})=>u.jsx("div",{className:"mx-3 mb-3 min-h-0 flex-1 overflow-auto rounded-lg bg-[var(--gray-3)]",style:{minHeight:280},children:e}),Eir=({schemaTs:e,title:t,integrationName:n,cardKey:r,monacoTheme:s})=>{const o=bir();return e?o?u.jsx("div",{style:{height:"100%",minHeight:280},children:u.jsx(o,{value:e,language:"typescript",height:"100%",theme:s==="vs-dark"?"bp-hub-dark":s==="vs"?"bp-hub-light":s,beforeMount:hir,options:{readOnly:!0,domReadOnly:!0,lineNumbers:"on",lineNumbersMinChars:3,minimap:{enabled:!1},scrollBeyondLastLine:!1,scrollbar:{vertical:"hidden",horizontal:"hidden",handleMouseWheel:!1},wordWrap:"on",renderLineHighlight:"none",showFoldingControls:"never"}})}):u.jsx("pre",{className:"m-0 h-full overflow-auto p-4 text-xs leading-5 text-[var(--gray-12)]","data-file-name":`${n}-${r}-${t.toLowerCase()}.ts`,children:u.jsx("code",{className:"font-mono whitespace-pre-wrap",children:e})}):null},bTe=({active:e,onClick:t,children:n})=>u.jsx("button",{type:"button",onClick:t,className:jr("flex-1 cursor-pointer rounded-md px-3 py-2 text-center text-sm font-medium transition-colors",e?"bg-[var(--color-background,var(--gray-1))] text-[var(--gray-12)] shadow-sm":"text-[var(--gray-11)] hover:text-[var(--gray-12)]"),children:n}),wir=({schemaTs:e})=>{const[t,n]=b.useState(!1),r=async()=>{if(e)try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),2e3)}catch{n(!1)}};return u.jsx("button",{type:"button",onClick:()=>void r(),disabled:!e,"aria-label":"Copy schema",className:jr("inline-flex h-auto w-auto shrink-0 cursor-pointer items-center justify-center rounded-lg border border-[var(--gray-a4)] p-2 transition-colors hover:bg-[var(--gray-a3)]",!e&&"cursor-not-allowed opacity-50"),children:t?u.jsx(Xr,{className:"h-4 w-4"}):u.jsx(_Ct,{className:"h-4 w-4"})})},Sir=({checked:e,disabled:t,onChange:n})=>u.jsx("button",{type:"button",role:"switch","aria-checked":e,disabled:t,onClick:()=>n(!e),className:jr("relative inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full transition-colors",e?"bg-[var(--accent-9,var(--gray-12))]":"bg-[var(--gray-a5)]",t&&"cursor-not-allowed opacity-60"),children:u.jsx("span",{className:jr("inline-block h-4 w-4 transform rounded-full bg-white transition-transform",e?"translate-x-[18px]":"translate-x-0.5")})}),_ir="hitl",dy="sandbox",Tir=e=>Object.values(e.interfaces).some(t=>t.name===_ir);var Air=Object.defineProperty,lL=Object.getOwnPropertySymbols,Itt=Object.prototype.hasOwnProperty,Rtt=Object.prototype.propertyIsEnumerable,vTe=(e,t,n)=>t in e?Air(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,xQ=(e,t)=>{for(var n in t||(t={}))Itt.call(t,n)&&vTe(e,n,t[n]);if(lL)for(var n of lL(t))Rtt.call(t,n)&&vTe(e,n,t[n]);return e},EQ=(e,t)=>{var n={};for(var r in e)Itt.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&lL)for(var r of lL(e))t.indexOf(r)<0&&Rtt.call(e,r)&&(n[r]=e[r]);return n};/**
1784
+ `,...o.current()});return/^[\t ]/.test(l)&&(l="&#x"+l.charCodeAt(0).toString(16).toUpperCase()+";"+l.slice(1)),l=l?a+" "+l:a,n.options.closeAtx&&(l+=" "+a),c(),i(),l}ptt.peek=Uor;function ptt(e){return e.value||""}function Uor(){return"<"}htt.peek=zor;function htt(e,t,n,r){const s=Hse(n),o=s==='"'?"Quote":"Apostrophe",a=n.enter("image");let i=n.enter("label");const c=n.createTracker(r);let l=c.move("![");return l+=c.move(n.safe(e.alt,{before:l,after:"]",...c.current()})),l+=c.move("]("),i(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(i=n.enter("destinationLiteral"),l+=c.move("<"),l+=c.move(n.safe(e.url,{before:l,after:">",...c.current()})),l+=c.move(">")):(i=n.enter("destinationRaw"),l+=c.move(n.safe(e.url,{before:l,after:e.title?" ":")",...c.current()}))),i(),e.title&&(i=n.enter(`title${o}`),l+=c.move(" "+s),l+=c.move(n.safe(e.title,{before:l,after:s,...c.current()})),l+=c.move(s),i()),l+=c.move(")"),a(),l}function zor(){return"!"}mtt.peek=Hor;function mtt(e,t,n,r){const s=e.referenceType,o=n.enter("imageReference");let a=n.enter("label");const i=n.createTracker(r);let c=i.move("![");const l=n.safe(e.alt,{before:c,after:"]",...i.current()});c+=i.move(l+"]["),a();const d=n.stack;n.stack=[],a=n.enter("reference");const f=n.safe(n.associationId(e),{before:c,after:"]",...i.current()});return a(),n.stack=d,o(),s==="full"||!l||l!==f?c+=i.move(f+"]"):s==="shortcut"?c=c.slice(0,-1):c+=i.move("]"),c}function Hor(){return"!"}gtt.peek=Vor;function gtt(e,t,n){let r=e.value||"",s="`",o=-1;for(;new RegExp("(^|[^`])"+s+"([^`]|$)").test(r);)s+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++o<n.unsafe.length;){const a=n.unsafe[o],i=n.compilePattern(a);let c;if(a.atBreak)for(;c=i.exec(r);){let l=c.index;r.charCodeAt(l)===10&&r.charCodeAt(l-1)===13&&l--,r=r.slice(0,l)+" "+r.slice(c.index+1)}}return s+r+s}function Vor(){return"`"}function ytt(e,t){const n=SR(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}btt.peek=Gor;function btt(e,t,n,r){const s=Hse(n),o=s==='"'?"Quote":"Apostrophe",a=n.createTracker(r);let i,c;if(ytt(e,n)){const d=n.stack;n.stack=[],i=n.enter("autolink");let f=a.move("<");return f+=a.move(n.containerPhrasing(e,{before:f,after:">",...a.current()})),f+=a.move(">"),i(),n.stack=d,f}i=n.enter("link"),c=n.enter("label");let l=a.move("[");return l+=a.move(n.containerPhrasing(e,{before:l,after:"](",...a.current()})),l+=a.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),l+=a.move("<"),l+=a.move(n.safe(e.url,{before:l,after:">",...a.current()})),l+=a.move(">")):(c=n.enter("destinationRaw"),l+=a.move(n.safe(e.url,{before:l,after:e.title?" ":")",...a.current()}))),c(),e.title&&(c=n.enter(`title${o}`),l+=a.move(" "+s),l+=a.move(n.safe(e.title,{before:l,after:s,...a.current()})),l+=a.move(s),c()),l+=a.move(")"),i(),l}function Gor(e,t,n){return ytt(e,n)?"<":"["}vtt.peek=Wor;function vtt(e,t,n,r){const s=e.referenceType,o=n.enter("linkReference");let a=n.enter("label");const i=n.createTracker(r);let c=i.move("[");const l=n.containerPhrasing(e,{before:c,after:"]",...i.current()});c+=i.move(l+"]["),a();const d=n.stack;n.stack=[],a=n.enter("reference");const f=n.safe(n.associationId(e),{before:c,after:"]",...i.current()});return a(),n.stack=d,o(),s==="full"||!l||l!==f?c+=i.move(f+"]"):s==="shortcut"?c=c.slice(0,-1):c+=i.move("]"),c}function Wor(){return"["}function Vse(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Kor(e){const t=Vse(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Zor(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function xtt(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function Yor(e,t,n,r){const s=n.enter("list"),o=n.bulletCurrent;let a=e.ordered?Zor(n):Vse(n);const i=e.ordered?a==="."?")":".":Kor(n);let c=t&&n.bulletLastUsed?a===n.bulletLastUsed:!1;if(!e.ordered){const d=e.children?e.children[0]:void 0;if((a==="*"||a==="-")&&d&&(!d.children||!d.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),xtt(n)===a&&d){let f=-1;for(;++f<e.children.length;){const p=e.children[f];if(p&&p.type==="listItem"&&p.children&&p.children[0]&&p.children[0].type==="thematicBreak"){c=!0;break}}}}c&&(a=i),n.bulletCurrent=a;const l=n.containerFlow(e,r);return n.bulletLastUsed=a,n.bulletCurrent=o,s(),l}function Qor(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function Xor(e,t,n,r){const s=Qor(n);let o=n.bulletCurrent||Vse(n);t&&t.type==="list"&&t.ordered&&(o=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let a=o.length+1;(s==="tab"||s==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(a=Math.ceil(a/4)*4);const i=n.createTracker(r);i.move(o+" ".repeat(a-o.length)),i.shift(a);const c=n.enter("listItem"),l=n.indentLines(n.containerFlow(e,i.current()),d);return c(),l;function d(f,p,h){return p?(h?"":" ".repeat(a))+f:(h?o:o+" ".repeat(a-o.length))+f}}function Jor(e,t,n,r){const s=n.enter("paragraph"),o=n.enter("phrasing"),a=n.containerPhrasing(e,r);return o(),s(),a}function ear(e,t,n,r){return(e.children.some(function(s){return utt(s)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function tar(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Ett.peek=nar;function Ett(e,t,n,r){const s=tar(n),o=n.enter("strong"),a=n.createTracker(r);let i=a.move(s+s);return i+=a.move(n.containerPhrasing(e,{before:i,after:s,...a.current()})),i+=a.move(s+s),o(),i}function nar(e,t,n){return n.options.strong||"*"}function rar(e,t,n,r){return n.safe(e.value,r)}function sar(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function oar(e,t,n){const r=(xtt(n)+(n.options.ruleSpaces?" ":"")).repeat(sar(n));return n.options.ruleSpaces?r.slice(0,-1):r}const aar={blockquote:Ior,break:hTe,code:Mor,definition:$or,emphasis:ftt,hardBreak:hTe,heading:qor,html:ptt,image:htt,imageReference:mtt,inlineCode:gtt,link:btt,linkReference:vtt,list:Yor,listItem:Xor,paragraph:Jor,root:ear,strong:Ett,text:rar,thematicBreak:oar};function iar(){return{exit:{taskListCheckValueChecked:mTe,taskListCheckValueUnchecked:mTe,paragraph:car}}}function lar(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:uar}}}function mTe(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function car(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const s=t.children;let o=-1,a;for(;++o<s.length;){const i=s[o];if(i.type==="paragraph"){a=i;break}}a===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function uar(e,t,n,r){const s=e.children[0],o=typeof e.checked=="boolean"&&s&&s.type==="paragraph",a="["+(e.checked?"x":" ")+"] ",i=n.createTracker(r);o&&i.move(a);let c=aar.listItem(e,t,n,{...r,...i.current()});return o&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(d){return d+a}}function dar(){return[dsr(),Ssr(),$sr(),Sor(),iar()]}function far(e){return{extensions:[fsr(),_sr(),Lsr(),Nor(e),lar()]}}const par={tokenize:xar,partial:!0},wtt={tokenize:Ear,partial:!0},Stt={tokenize:war,partial:!0},_tt={tokenize:Sar,partial:!0},har={tokenize:_ar,partial:!0},Ttt={name:"wwwAutolink",tokenize:yar,previous:ktt},Att={name:"protocolAutolink",tokenize:bar,previous:Ctt},xm={name:"emailAutolink",tokenize:gar,previous:Ntt},Lp={};function mar(){return{text:Lp}}let H0=48;for(;H0<123;)Lp[H0]=xm,H0++,H0===58?H0=65:H0===91&&(H0=97);Lp[43]=xm;Lp[45]=xm;Lp[46]=xm;Lp[95]=xm;Lp[72]=[xm,Att];Lp[104]=[xm,Att];Lp[87]=[xm,Ttt];Lp[119]=[xm,Ttt];function gar(e,t,n){const r=this;let s,o;return a;function a(f){return!vQ(f)||!Ntt.call(r,r.previous)||Gse(r.events)?n(f):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),i(f))}function i(f){return vQ(f)?(e.consume(f),i):f===64?(e.consume(f),c):n(f)}function c(f){return f===46?e.check(har,d,l)(f):f===45||f===95||hl(f)?(o=!0,e.consume(f),c):d(f)}function l(f){return e.consume(f),s=!0,c}function d(f){return o&&s&&Yl(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(f)):n(f)}}function yar(e,t,n){const r=this;return s;function s(a){return a!==87&&a!==119||!ktt.call(r,r.previous)||Gse(r.events)?n(a):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(par,e.attempt(wtt,e.attempt(Stt,o),n),n)(a))}function o(a){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(a)}}function bar(e,t,n){const r=this;let s="",o=!1;return a;function a(f){return(f===72||f===104)&&Ctt.call(r,r.previous)&&!Gse(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),s+=String.fromCodePoint(f),e.consume(f),i):n(f)}function i(f){if(Yl(f)&&s.length<5)return s+=String.fromCodePoint(f),e.consume(f),i;if(f===58){const p=s.toLowerCase();if(p==="http"||p==="https")return e.consume(f),c}return n(f)}function c(f){return f===47?(e.consume(f),o?l:(o=!0,c)):n(f)}function l(f){return f===null||J$(f)||Ys(f)||bv(f)||GF(f)?n(f):e.attempt(wtt,e.attempt(Stt,d),n)(f)}function d(f){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(f)}}function xar(e,t,n){let r=0;return s;function s(a){return(a===87||a===119)&&r<3?(r++,e.consume(a),s):a===46&&r===3?(e.consume(a),o):n(a)}function o(a){return a===null?n(a):t(a)}}function Ear(e,t,n){let r,s,o;return a;function a(l){return l===46||l===95?e.check(_tt,c,i)(l):l===null||Ys(l)||bv(l)||l!==45&&GF(l)?c(l):(o=!0,e.consume(l),a)}function i(l){return l===95?r=!0:(s=r,r=void 0),e.consume(l),a}function c(l){return s||r||!o?n(l):t(l)}}function war(e,t){let n=0,r=0;return s;function s(a){return a===40?(n++,e.consume(a),s):a===41&&r<n?o(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?e.check(_tt,t,o)(a):a===null||Ys(a)||bv(a)?t(a):(e.consume(a),s)}function o(a){return a===41&&r++,e.consume(a),s}}function Sar(e,t,n){return r;function r(i){return i===33||i===34||i===39||i===41||i===42||i===44||i===46||i===58||i===59||i===63||i===95||i===126?(e.consume(i),r):i===38?(e.consume(i),o):i===93?(e.consume(i),s):i===60||i===null||Ys(i)||bv(i)?t(i):n(i)}function s(i){return i===null||i===40||i===91||Ys(i)||bv(i)?t(i):r(i)}function o(i){return Yl(i)?a(i):n(i)}function a(i){return i===59?(e.consume(i),r):Yl(i)?(e.consume(i),a):n(i)}}function _ar(e,t,n){return r;function r(o){return e.consume(o),s}function s(o){return hl(o)?n(o):t(o)}}function ktt(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Ys(e)}function Ctt(e){return!Yl(e)}function Ntt(e){return!(e===47||vQ(e))}function vQ(e){return e===43||e===45||e===46||e===95||hl(e)}function Gse(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const Tar={tokenize:Dar,partial:!0};function Aar(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:Iar,continuation:{tokenize:Rar},exit:jar}},text:{91:{name:"gfmFootnoteCall",tokenize:Nar},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:kar,resolveTo:Car}}}}function kar(e,t,n){const r=this;let s=r.events.length;const o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a;for(;s--;){const c=r.events[s][1];if(c.type==="labelImage"){a=c;break}if(c.type==="gfmFootnoteCall"||c.type==="labelLink"||c.type==="label"||c.type==="image"||c.type==="link")break}return i;function i(c){if(!a||!a._balanced)return n(c);const l=Wd(r.sliceSerialize({start:a.end,end:r.now()}));return l.codePointAt(0)!==94||!o.includes(l.slice(1))?n(c):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),t(c))}}function Car(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},s={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};s.end.column++,s.end.offset++,s.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},s.end),end:Object.assign({},e[e.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},i=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",s,t],["exit",s,t],["enter",o,t],["enter",a,t],["exit",a,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...i),e}function Nar(e,t,n){const r=this,s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o=0,a;return i;function i(f){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),c}function c(f){return f!==94?n(f):(e.enter("gfmFootnoteCallMarker"),e.consume(f),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",l)}function l(f){if(o>999||f===93&&!a||f===null||f===91||Ys(f))return n(f);if(f===93){e.exit("chunkString");const p=e.exit("gfmFootnoteCallString");return s.includes(Wd(r.sliceSerialize(p)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(f),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(f)}return Ys(f)||(a=!0),o++,e.consume(f),f===92?d:l}function d(f){return f===91||f===92||f===93?(e.consume(f),o++,l):l(f)}}function Iar(e,t,n){const r=this,s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o,a=0,i;return c;function c(g){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),l}function l(g){return g===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",d):n(g)}function d(g){if(a>999||g===93&&!i||g===null||g===91||Ys(g))return n(g);if(g===93){e.exit("chunkString");const y=e.exit("gfmFootnoteDefinitionLabelString");return o=Wd(r.sliceSerialize(y)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),p}return Ys(g)||(i=!0),a++,e.consume(g),g===92?f:d}function f(g){return g===91||g===92||g===93?(e.consume(g),a++,d):d(g)}function p(g){return g===58?(e.enter("definitionMarker"),e.consume(g),e.exit("definitionMarker"),s.includes(o)||s.push(o),ls(e,h,"gfmFootnoteDefinitionWhitespace")):n(g)}function h(g){return t(g)}}function Rar(e,t,n){return e.check(_R,t,e.attempt(Tar,t,n))}function jar(e){e.exit("gfmFootnoteDefinition")}function Dar(e,t,n){const r=this;return ls(e,s,"gfmFootnoteDefinitionIndent",5);function s(o){const a=r.events[r.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?t(o):n(o)}}function Oar(e){let t=(e||{}).singleTilde;const n={name:"strikethrough",tokenize:s,resolveAll:r};return t==null&&(t=!0),{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(o,a){let i=-1;for(;++i<o.length;)if(o[i][0]==="enter"&&o[i][1].type==="strikethroughSequenceTemporary"&&o[i][1]._close){let c=i;for(;c--;)if(o[c][0]==="exit"&&o[c][1].type==="strikethroughSequenceTemporary"&&o[c][1]._open&&o[i][1].end.offset-o[i][1].start.offset===o[c][1].end.offset-o[c][1].start.offset){o[i][1].type="strikethroughSequence",o[c][1].type="strikethroughSequence";const l={type:"strikethrough",start:Object.assign({},o[c][1].start),end:Object.assign({},o[i][1].end)},d={type:"strikethroughText",start:Object.assign({},o[c][1].end),end:Object.assign({},o[i][1].start)},f=[["enter",l,a],["enter",o[c][1],a],["exit",o[c][1],a],["enter",d,a]],p=a.parser.constructs.insideSpan.null;p&&td(f,f.length,0,WF(p,o.slice(c+1,i),a)),td(f,f.length,0,[["exit",d,a],["enter",o[i][1],a],["exit",o[i][1],a],["exit",l,a]]),td(o,c-1,i-c+3,f),i=c+f.length-2;break}}for(i=-1;++i<o.length;)o[i][1].type==="strikethroughSequenceTemporary"&&(o[i][1].type="data");return o}function s(o,a,i){const c=this.previous,l=this.events;let d=0;return f;function f(h){return c===126&&l[l.length-1][1].type!=="characterEscape"?i(h):(o.enter("strikethroughSequenceTemporary"),p(h))}function p(h){const g=Lw(c);if(h===126)return d>1?i(h):(o.consume(h),d++,p);if(d<2&&!t)return i(h);const y=o.exit("strikethroughSequenceTemporary"),E=Lw(h);return y._open=!E||E===2&&!!g,y._close=!g||g===2&&!!E,a(h)}}}class Mar{constructor(){this.map=[]}add(t,n,r){Par(this,t,n,r)}consume(t){if(this.map.sort(function(o,a){return o[0]-a[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push([...t]),t.length=0;let s=r.pop();for(;s;)t.push(...s),s=r.pop();this.map.length=0}}function Par(e,t,n,r){let s=0;if(!(n===0&&r.length===0)){for(;s<e.map.length;){if(e.map[s][0]===t){e.map[s][1]+=n,e.map[s][2].push(...r);return}s+=1}e.map.push([t,n,r])}}function $ar(e,t){let n=!1;const r=[];for(;t<e.length;){const s=e[t];if(n){if(s[0]==="enter")s[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(s[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const o=r.length-1;r[o]=r[o]==="left"?"center":"right"}}else if(s[1].type==="tableDelimiterRow")break}else s[0]==="enter"&&s[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function Lar(){return{flow:{null:{name:"table",tokenize:Far,resolveAll:Bar}}}}function Far(e,t,n){const r=this;let s=0,o=0,a;return i;function i(D){let L=r.events.length-1;for(;L>-1;){const M=r.events[L][1].type;if(M==="lineEnding"||M==="linePrefix")L--;else break}const U=L>-1?r.events[L][1].type:null,B=U==="tableHead"||U==="tableRow"?A:c;return B===A&&r.parser.lazy[r.now().line]?n(D):B(D)}function c(D){return e.enter("tableHead"),e.enter("tableRow"),l(D)}function l(D){return D===124||(a=!0,o+=1),d(D)}function d(D){return D===null?n(D):On(D)?o>1?(o=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(D),e.exit("lineEnding"),h):n(D):zr(D)?ls(e,d,"whitespace")(D):(o+=1,a&&(a=!1,s+=1),D===124?(e.enter("tableCellDivider"),e.consume(D),e.exit("tableCellDivider"),a=!0,d):(e.enter("data"),f(D)))}function f(D){return D===null||D===124||Ys(D)?(e.exit("data"),d(D)):(e.consume(D),D===92?p:f)}function p(D){return D===92||D===124?(e.consume(D),f):f(D)}function h(D){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(D):(e.enter("tableDelimiterRow"),a=!1,zr(D)?ls(e,g,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):g(D))}function g(D){return D===45||D===58?E(D):D===124?(a=!0,e.enter("tableCellDivider"),e.consume(D),e.exit("tableCellDivider"),y):k(D)}function y(D){return zr(D)?ls(e,E,"whitespace")(D):E(D)}function E(D){return D===58?(o+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(D),e.exit("tableDelimiterMarker"),x):D===45?(o+=1,x(D)):D===null||On(D)?T(D):k(D)}function x(D){return D===45?(e.enter("tableDelimiterFiller"),w(D)):k(D)}function w(D){return D===45?(e.consume(D),w):D===58?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(D),e.exit("tableDelimiterMarker"),S):(e.exit("tableDelimiterFiller"),S(D))}function S(D){return zr(D)?ls(e,T,"whitespace")(D):T(D)}function T(D){return D===124?g(D):D===null||On(D)?!a||s!==o?k(D):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(D)):k(D)}function k(D){return n(D)}function A(D){return e.enter("tableRow"),N(D)}function N(D){return D===124?(e.enter("tableCellDivider"),e.consume(D),e.exit("tableCellDivider"),N):D===null||On(D)?(e.exit("tableRow"),t(D)):zr(D)?ls(e,N,"whitespace")(D):(e.enter("data"),j(D))}function j(D){return D===null||D===124||Ys(D)?(e.exit("data"),N(D)):(e.consume(D),D===92?O:j)}function O(D){return D===92||D===124?(e.consume(D),j):j(D)}}function Bar(e,t){let n=-1,r=!0,s=0,o=[0,0,0,0],a=[0,0,0,0],i=!1,c=0,l,d,f;const p=new Mar;for(;++n<e.length;){const h=e[n],g=h[1];h[0]==="enter"?g.type==="tableHead"?(i=!1,c!==0&&(gTe(p,t,c,l,d),d=void 0,c=0),l={type:"table",start:Object.assign({},g.start),end:Object.assign({},g.end)},p.add(n,0,[["enter",l,t]])):g.type==="tableRow"||g.type==="tableDelimiterRow"?(r=!0,f=void 0,o=[0,0,0,0],a=[0,n+1,0,0],i&&(i=!1,d={type:"tableBody",start:Object.assign({},g.start),end:Object.assign({},g.end)},p.add(n,0,[["enter",d,t]])),s=g.type==="tableDelimiterRow"?2:d?3:1):s&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")?(r=!1,a[2]===0&&(o[1]!==0&&(a[0]=a[1],f=zD(p,t,o,s,void 0,f),o=[0,0,0,0]),a[2]=n)):g.type==="tableCellDivider"&&(r?r=!1:(o[1]!==0&&(a[0]=a[1],f=zD(p,t,o,s,void 0,f)),o=a,a=[o[1],n,0,0])):g.type==="tableHead"?(i=!0,c=n):g.type==="tableRow"||g.type==="tableDelimiterRow"?(c=n,o[1]!==0?(a[0]=a[1],f=zD(p,t,o,s,n,f)):a[1]!==0&&(f=zD(p,t,a,s,n,f)),s=0):s&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")&&(a[3]=n)}for(c!==0&&gTe(p,t,c,l,d),p.consume(t.events),n=-1;++n<t.events.length;){const h=t.events[n];h[0]==="enter"&&h[1].type==="table"&&(h[1]._align=$ar(t.events,n))}return e}function zD(e,t,n,r,s,o){const a=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",i="tableContent";n[0]!==0&&(o.end=Object.assign({},nE(t.events,n[0])),e.add(n[0],0,[["exit",o,t]]));const c=nE(t.events,n[1]);if(o={type:a,start:Object.assign({},c),end:Object.assign({},c)},e.add(n[1],0,[["enter",o,t]]),n[2]!==0){const l=nE(t.events,n[2]),d=nE(t.events,n[3]),f={type:i,start:Object.assign({},l),end:Object.assign({},d)};if(e.add(n[2],0,[["enter",f,t]]),r!==2){const p=t.events[n[2]],h=t.events[n[3]];if(p[1].end=Object.assign({},h[1].end),p[1].type="chunkText",p[1].contentType="text",n[3]>n[2]+1){const g=n[2]+1,y=n[3]-n[2]-1;e.add(g,y,[])}}e.add(n[3]+1,0,[["exit",f,t]])}return s!==void 0&&(o.end=Object.assign({},nE(t.events,s)),e.add(s,0,[["exit",o,t]]),o=void 0),o}function gTe(e,t,n,r,s){const o=[],a=nE(t.events,n);s&&(s.end=Object.assign({},a),o.push(["exit",s,t])),r.end=Object.assign({},a),o.push(["exit",r,t]),e.add(n+1,0,o)}function nE(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const qar={name:"tasklistCheck",tokenize:zar};function Uar(){return{text:{91:qar}}}function zar(e,t,n){const r=this;return s;function s(c){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(c):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),o)}function o(c){return Ys(c)?(e.enter("taskListCheckValueUnchecked"),e.consume(c),e.exit("taskListCheckValueUnchecked"),a):c===88||c===120?(e.enter("taskListCheckValueChecked"),e.consume(c),e.exit("taskListCheckValueChecked"),a):n(c)}function a(c){return c===93?(e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),i):n(c)}function i(c){return On(c)?t(c):zr(c)?e.check({tokenize:Har},t,n)(c):n(c)}}function Har(e,t,n){return ls(e,r,"whitespace");function r(s){return s===null?n(s):t(s)}}function Var(e){return U7e([mar(),Aar(),Oar(e),Lar(),Uar()])}const Gar={};function War(e){const t=this,n=e||Gar,r=t.data(),s=r.micromarkExtensions||(r.micromarkExtensions=[]),o=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),a=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);s.push(Var(n)),o.push(dar()),a.push(far(n))}const Kar=e=>e.startsWith("https://www.youtube.com/")||e.startsWith("https://youtube.com/")||e.startsWith("https://www.youtube-nocookie.com/"),Zar=e=>{if(!e)return;const t=e.trim();if(/^https?:\/\//i.test(t))return t},Yar={...eC,tagNames:[...eC.tagNames??[],"iframe"],attributes:{...eC.attributes??{},iframe:["src","title","width","height","allow","allowFullScreen","referrerPolicy"]}},Qar={iframe:({src:e,...t})=>!e||!Kar(e)?null:u.jsx("iframe",{src:e,width:"100%",height:400,title:t.title??"Embedded content",className:"w-full rounded-lg border border-[var(--gray-a4)] bg-black",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",referrerPolicy:"strict-origin-when-cross-origin",allowFullScreen:!0}),h1:e=>u.jsx("h1",{className:"text-2xl font-semibold text-[var(--gray-12)]",...e}),h2:e=>u.jsx("h2",{className:"text-xl font-semibold text-[var(--gray-12)]",...e}),h3:e=>u.jsx("h3",{className:"text-lg font-semibold text-[var(--gray-12)]",...e}),p:e=>u.jsx("p",{className:"text-sm leading-6 text-[var(--gray-11)] whitespace-pre-wrap",...e}),ul:e=>u.jsx("ul",{className:"list-disc pl-6 text-sm text-[var(--gray-11)]",...e}),ol:e=>u.jsx("ol",{className:"list-decimal pl-6 text-sm text-[var(--gray-11)]",...e}),li:e=>u.jsx("li",{className:"leading-6",...e}),a:({href:e,children:t,rel:n,target:r,className:s,...o})=>{const a=Zar(e);return a?u.jsx("a",{...o,href:a,target:"_blank",rel:"noopener noreferrer",className:jr("text-[var(--blue-11)] hover:underline break-all",s),children:t}):u.jsx("span",{className:"text-[var(--gray-11)] break-all",children:t})},pre:e=>u.jsx("pre",{className:"overflow-x-auto rounded-lg border border-[var(--gray-a4)] bg-[var(--gray-1)] p-3 text-xs text-[var(--gray-11)]",...e}),code:e=>u.jsx("code",{className:"font-mono text-xs",...e}),hr:e=>u.jsx("hr",{className:"border-[var(--gray-a4)]",...e})},Xar=e=>{const[t,n]=b.useState(void 0),[r,s]=b.useState(void 0);return b.useEffect(()=>{const o=new AbortController;let a=!1;return n(void 0),s(void 0),e?(fetch(e,{signal:o.signal}).then(async i=>{var c;if(!i.ok)return;const l=await i.text();(((c=i.headers.get("content-type"))==null?void 0:c.toLowerCase())??"").includes("text/html")&&/<html[\s>]/i.test(l.slice(0,512))||!a&&!o.signal.aborted&&n(l)}).catch(i=>{i instanceof DOMException&&i.name}).finally(()=>{!a&&!o.signal.aborted&&s(e)}),()=>{a=!0,o.abort()}):()=>{a=!0,o.abort()}},[e]),{readme:t,isLoading:!!e&&r!==e}},Jar=({readme:e,isLoading:t=!1,className:n,loadingContent:r,emptyContent:s})=>t?r??u.jsx("div",{className:"flex items-center justify-center py-16",children:u.jsx(nn,{className:"h-6 w-6 animate-spin text-[var(--gray-9)]"})}):e?u.jsx("div",{className:jr("flex flex-col gap-4",n),children:u.jsx(Per,{remarkPlugins:[War],rehypePlugins:[Zrr,[osr,Yar]],components:Qar,children:e})}):s??u.jsx("p",{className:"text-sm text-[var(--gray-11)]",children:"No additional integration documentation is available."}),eir=e=>e.startsWith("http")?e:`https://${e}`,tir=e=>"Source Code",nir=e=>"Documentation",rir=({version:e,githubUrl:t,guideUrl:n,onAboutClick:r,aboutLabel:s="About Integration",formatGithubLabel:o=tir,formatGuideLabel:a=nir})=>u.jsxs("div",{className:"flex items-start gap-12 px-6 py-4 rounded-lg border border-[var(--gray-a4)] bg-[var(--gray-a2)]",children:[u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("span",{className:"text-xs text-[var(--gray-11)]",children:"Version"}),u.jsx("span",{className:"text-sm font-medium text-[var(--gray-12)]",children:e})]}),t&&u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("span",{className:"text-xs text-[var(--gray-11)]",children:"GitHub"}),u.jsxs("a",{href:eir(t),target:"_blank",rel:"noopener noreferrer",className:"inline-flex w-fit items-center gap-1 text-sm font-medium text-[var(--blue-11)] hover:underline",children:[o(t),u.jsx(EW,{className:"h-3.5 w-3.5"})]})]}),n&&u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("span",{className:"text-xs text-[var(--gray-11)]",children:"Documentation"}),u.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"inline-flex w-fit items-center gap-1 text-sm font-medium text-[var(--blue-11)] hover:underline",children:[a(n),u.jsx(EW,{className:"h-3.5 w-3.5"})]})]}),r&&u.jsx("button",{type:"button",onClick:r,className:"ml-auto text-sm text-[var(--gray-11)] hover:text-[var(--gray-12)] p-0 h-auto cursor-pointer mt-2.5 border-0 bg-transparent",children:s})]}),TM=jr("relative px-3 py-3 text-sm font-medium cursor-pointer rounded-none flex-none border-none","text-[var(--gray-11)] hover:text-[var(--gray-12)] data-active:text-[var(--gray-12)]",'after:content-[""] after:absolute after:bottom-0 after:left-0 after:right-0 after:h-0.5 after:rounded-full after:bg-transparent data-active:after:bg-[var(--gray-12)]'),yTe=jr(TM,"px-12 py-4","after:inset-x-6"),sir=({hasConnectionStep:e,hasConfigurationStep:t})=>e?"connections":t?"configuration":"capabilities",oir=({integrationTitle:e,isFullyConfigured:t,hasConnectionStep:n,hasConfigurationStep:r,useSetupStepTabs:s=!1,configuredTab:o,onConfiguredTabChange:a,setupTab:i,onSetupTabChange:c,onCancelSetup:l,metadata:d,connectionsContent:f,configurationContent:p,capabilitiesContent:h,setupEmptyContent:g})=>{const y=n,E=r,x=sir({hasConnectionStep:n,hasConfigurationStep:r}),w=o==="connections"&&!y||o==="configuration"&&!E?x:o;return u.jsxs("div",{className:"flex flex-col gap-6 mt-6",children:[d,t?u.jsxs("div",{className:"flex flex-col",children:[u.jsxs("div",{className:"flex items-center border-b border-[var(--gray-a4)]",role:"tablist","aria-label":"Integration sections",children:[y&&u.jsx("button",{type:"button",id:"integration-configured-tab-connections",role:"tab","aria-selected":w==="connections","aria-controls":"integration-configured-panel-connections",className:TM,"data-active":w==="connections"?"true":void 0,onClick:()=>a("connections"),children:"Connections"}),E&&u.jsx("button",{type:"button",id:"integration-configured-tab-configuration",role:"tab","aria-selected":w==="configuration","aria-controls":"integration-configured-panel-configuration",className:TM,"data-active":w==="configuration"?"true":void 0,onClick:()=>a("configuration"),children:"Configuration"}),u.jsx("button",{type:"button",id:"integration-configured-tab-capabilities",role:"tab","aria-selected":w==="capabilities","aria-controls":"integration-configured-panel-capabilities",className:TM,"data-active":w==="capabilities"?"true":void 0,onClick:()=>a("capabilities"),children:"Capabilities"})]}),w==="connections"&&u.jsx("div",{className:"pt-4",role:"tabpanel",id:"integration-configured-panel-connections","aria-labelledby":"integration-configured-tab-connections",children:f}),w==="configuration"&&u.jsx("div",{className:"pt-4",role:"tabpanel",id:"integration-configured-panel-configuration","aria-labelledby":"integration-configured-tab-configuration",children:p}),w==="capabilities"&&u.jsx("div",{className:"pt-4",role:"tabpanel",id:"integration-configured-panel-capabilities","aria-labelledby":"integration-configured-tab-capabilities",children:h})]}):u.jsxs("div",{className:"rounded-lg border border-[var(--gray-a4)] bg-[var(--gray-a2)] overflow-hidden",children:[u.jsxs("div",{className:"flex items-center border-b border-[var(--gray-a4)] justify-between px-6 py-4",children:[u.jsxs("h3",{className:"text-base font-semibold text-[var(--gray-12)]",children:["Set Up ",e," Integration"]}),u.jsx("button",{type:"button",onClick:l,className:"text-sm text-[var(--gray-11)] hover:text-[var(--gray-12)] p-0 h-auto cursor-pointer",children:"Cancel"})]}),s&&n&&r?u.jsxs("div",{className:"flex flex-col",children:[u.jsxs("div",{className:"flex items-center px-6 border-b border-[var(--gray-a4)]",role:"tablist","aria-label":"Setup steps",children:[u.jsx("button",{type:"button",id:"integration-setup-tab-connections",role:"tab","aria-selected":i==="connections","aria-controls":"integration-setup-panel-connections",className:yTe,"data-active":i==="connections"?"true":void 0,onClick:()=>c("connections"),children:"1. Connections"}),u.jsx("button",{type:"button",id:"integration-setup-tab-configuration",role:"tab","aria-selected":i==="configuration","aria-controls":"integration-setup-panel-configuration",className:yTe,"data-active":i==="configuration"?"true":void 0,onClick:()=>c("configuration"),children:"2. Configuration"})]}),i==="connections"&&u.jsx("div",{className:"p-6",role:"tabpanel",id:"integration-setup-panel-connections","aria-labelledby":"integration-setup-tab-connections",children:f}),i==="configuration"&&u.jsx("div",{className:"p-6",role:"tabpanel",id:"integration-setup-panel-configuration","aria-labelledby":"integration-setup-tab-configuration",children:p})]}):n?u.jsx("div",{className:"p-6",children:f}):r?u.jsx("div",{className:"p-6",children:p}):u.jsx("div",{className:"flex items-center justify-center p-6 py-12",children:g??u.jsx("p",{className:"text-sm text-[var(--gray-11)]",children:"This integration is ready to use."})})]})]})},air="flex items-center gap-2 px-3 py-2 text-sm rounded-md cursor-pointer text-left whitespace-normal break-words",iir=({options:e,value:t,onChange:n,disabled:r=!1})=>{var s;if(e.length<=1)return null;const o=((s=e.find(a=>a.value===t))==null?void 0:s.label)??String(t??"");return u.jsxs(_se,{children:[u.jsxs(v7e,{disabled:r,className:"flex items-center gap-2 px-4 py-2 rounded-lg bg-[var(--gray-a3)] text-sm text-[var(--gray-12)] hover:bg-[var(--gray-a4)] cursor-pointer border-none outline-none w-[165px] disabled:opacity-60 disabled:cursor-not-allowed",children:[u.jsx("span",{className:"truncate flex-1 text-left",children:o}),u.jsx(Dr,{className:"w-4 h-4 shrink-0"})]}),u.jsx(d7e,{children:u.jsx(h7e,{className:"isolate z-50 outline-none",align:"end",side:"bottom",sideOffset:6,children:u.jsx(c7e,{role:"menu",className:"bg-[var(--gray-2)] rounded-lg p-1 shadow-lg w-(--anchor-width) overflow-hidden",children:e.map(a=>u.jsx(dJe,{onClick:()=>n(a.value),className:jr(air,t===a.value?"text-[var(--gray-12)] bg-[var(--gray-a3)]":"text-[var(--gray-11)] hover:bg-[var(--gray-a3)]"),children:a.label},a.value??"__default"))})})})]})},lir=({integrationName:e,canAuthorize:t,isAuthorizing:n=!1,isAuthorized:r=!1,disabled:s=!1,showInstallHint:o=!1,onClick:a})=>{const i=s||!t||n;return u.jsxs("div",{className:"flex flex-col items-end gap-2",children:[u.jsx("button",{type:"button",disabled:i,onClick:a,className:jr("inline-flex flex-row items-center gap-2 rounded-md px-4 py-2 h-auto text-sm font-medium transition-opacity","border-none bg-[var(--gray-12)] text-[var(--gray-1)]",i?"cursor-not-allowed opacity-60":"cursor-pointer hover:opacity-90"),children:n?u.jsx(za,{className:"h-4 w-4 animate-spin"}):r?u.jsxs(u.Fragment,{children:[u.jsx(Ms,{className:"h-4 w-4 text-green-500"}),"Re-authorize ",e]}):u.jsxs(u.Fragment,{children:[u.jsx(TC,{className:"h-4 w-4"}),"Connect with OAuth"]})}),o&&u.jsx("p",{className:"text-xs text-[var(--gray-11)]",children:"Install the integration first to start OAuth authorization."})]})},cir="A unique endpoint that external services can POST data to, allowing the integration to receive events, messages, or other updates from external services.",iL=({webhookUrl:e,title:t="Webhook",titleClassName:n="text-sm font-bold text-[var(--gray-12)]",helpText:r=cir})=>{const[s,o]=b.useState(!1),a=b.useRef(null);if(b.useEffect(()=>()=>{a.current&&window.clearTimeout(a.current)},[]),!e)return null;const i=async()=>{try{await navigator.clipboard.writeText(e),o(!0),a.current&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>o(!1),1500)}catch{o(!1)}};return u.jsxs("div",{className:"flex flex-col gap-3",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("h5",{className:n,children:t}),u.jsxs("div",{className:"relative group",children:[u.jsx("button",{type:"button",className:"inline-flex items-center justify-center w-5 h-5 rounded-full text-[var(--gray-a8)] hover:text-[var(--gray-10)] focus-visible:outline-2 focus-visible:outline-[var(--accent-9)]","aria-label":"Webhook information",children:u.jsx(xCt,{size:16,className:"text-[var(--gray-a8)] cursor-help"})}),u.jsxs("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 hidden group-hover:block w-[280px] p-3 rounded-lg bg-[var(--gray-12)] text-[var(--gray-1)] text-xs leading-relaxed z-50",role:"tooltip",children:[r,u.jsx("div",{className:"absolute top-full left-1/2 -translate-x-1/2 border-[6px] border-transparent border-t-[var(--gray-12)]"})]})]})]}),u.jsx("button",{type:"button",onClick:()=>void i(),"aria-label":"Copy webhook URL",className:jr("w-full cursor-pointer rounded-md border border-[var(--gray-5)] p-1.5 text-left transition-colors",s?"border-[var(--grass-5)] bg-[var(--grass-3)]":"hover:border-[var(--gray-7)] hover:bg-[var(--gray-2)]"),children:u.jsxs("div",{className:"flex items-center justify-between overflow-hidden gap-4",children:[u.jsx("code",{className:"truncate rounded-sm bg-[var(--gray-a4)] px-1.5 py-0.5 font-mono text-xs leading-5 text-[var(--gray-11)]",children:e}),u.jsx("span",{className:"shrink-0",children:s?u.jsx(Xr,{className:"w-4 h-4 text-[var(--grass-10)]"}):u.jsx(li,{className:"w-4 h-4 text-[var(--gray-10)]"})})]})})]})},uir=({title:e="Configuration",webhookUrl:t,isBlocked:n=!1,blockedMessage:r="Complete the connection step first to configure this integration.",children:s})=>n?u.jsx("div",{className:"flex flex-col items-center justify-center py-12 text-[var(--gray-11)]",children:u.jsx("p",{className:"text-sm",children:r})}):u.jsxs("div",{className:"flex flex-col gap-6",children:[u.jsx("h4",{className:"text-base font-bold text-[var(--gray-12)]",children:e}),u.jsx(iL,{webhookUrl:t}),s]}),dir={action:{icon:tI,bg:"bg-teal-50",color:"text-teal-600",disabledBg:"bg-teal-50",disabledColor:"text-teal-600"},event:{icon:Sa,bg:"bg-purple-50",color:"text-purple-600",disabledBg:"bg-[var(--gray-a3)]",disabledColor:"text-[var(--gray-9)]"},channel:{icon:Kb,bg:"bg-blue-50",color:"text-blue-500",disabledBg:"bg-blue-50",disabledColor:"text-blue-500"}},fir=(e,t)=>!!(e&&e.key===t.key&&e.type===t.type),P9=({title:e,subtitle:t,cards:n,selectedCard:r,onCardSelect:s})=>n.length?u.jsxs("div",{className:"flex flex-col",children:[u.jsx("h3",{className:"text-sm font-semibold text-[var(--gray-12)] mb-3",children:e}),u.jsx("p",{className:"text-xs text-[var(--gray-11)]",children:t}),u.jsx("div",{className:"grid grid-cols-3 gap-x-8 gap-y-6 mt-4",children:n.map(o=>{const a=dir[o.type],i=a.icon,c=fir(r,o),l=o.enabled??!0;return u.jsxs("button",{type:"button",onClick:()=>s?.(c?null:o),className:jr("flex gap-3 p-3 h-auto rounded-lg border cursor-pointer transition-colors text-left",o.description?"items-start":"items-center",c?"border-[var(--blue-8)] bg-[var(--blue-a2)]":"border-[var(--gray-a4)] bg-[var(--gray-a2)] hover:bg-[var(--gray-a3)]"),children:[u.jsx("div",{className:jr("flex items-center justify-center w-8 h-8 rounded-lg shrink-0",l?a.bg:a.disabledBg),children:u.jsx(i,{className:jr("w-4 h-4",l?a.color:a.disabledColor)})}),u.jsxs("div",{className:"min-w-0 flex-1",children:[u.jsx("div",{className:"text-sm font-medium text-[var(--gray-12)] truncate",children:o.name}),o.description&&u.jsx("div",{className:"text-xs text-[var(--gray-11)] truncate",children:o.description})]}),o.type==="event"&&u.jsx(NIt,{className:jr("w-4 h-4 shrink-0",l?"text-green-500":"text-[var(--gray-9)]")}),o.billable&&u.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-[var(--gray-a4)] text-[var(--gray-11)] shrink-0",children:"Billable"})]},`${o.type}:${o.key}`)})})]}):null,pir=({actionCards:e=[],eventCards:t=[],channelCards:n=[],selectedCard:r,onCardSelect:s,title:o="Cards"})=>e.length>0||t.length>0||n.length>0?u.jsxs("div",{className:"flex flex-col gap-4",children:[u.jsx("h4",{className:"text-base font-bold text-[var(--gray-12)]",children:o}),u.jsxs("div",{className:"flex flex-col gap-6",children:[P9({title:"Action Cards",subtitle:"Cards to perform specific operations within a workflow",cards:e,selectedCard:r,onCardSelect:s}),P9({title:"Trigger Cards",subtitle:"Cards that listen for specific events to start a workflow",cards:t,selectedCard:r,onCardSelect:s}),P9({title:"Channel Cards",subtitle:"Cards related to channel communication events and actions",cards:n,selectedCard:r,onCardSelect:s})]})]}):null,hir=e=>{e.editor.defineTheme("bp-hub-light",{base:"vs",inherit:!0,rules:[],colors:{"editor.background":"#00000000","editorGutter.background":"#00000000"}}),e.editor.defineTheme("bp-hub-dark",{base:"vs-dark",inherit:!0,rules:[],colors:{"editor.background":"#00000000","editorGutter.background":"#00000000"}})},mir=async()=>(await c5(async()=>{const{transforms:e}=await import("./index-C72JGlc0.js");return{transforms:e}},[])).transforms,$9=(e,t)=>{const[n,r]=b.useState("");return b.useEffect(()=>{if(!e){r("");return}let s=!1;return mir().then(o=>{const a=o.fromJSONSchemaLegacy(e);return o.toTypescriptType(a,{declaration:!1,includeClosingTags:!0})}).then(o=>{s||r(`type ${t} = ${o}`)}).catch(()=>{s||r("")}),()=>{s=!0}},[e,t]),n},gir=()=>typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"vs-dark":"vs",yir=e=>{const[t,n]=b.useState(gir);return b.useEffect(()=>{if(e||typeof window>"u")return;const r=window.matchMedia("(prefers-color-scheme: dark)"),s=o=>n(o.matches?"vs-dark":"vs");return r.addEventListener("change",s),()=>r.removeEventListener("change",s)},[e]),e??t},bir=()=>{const[e,t]=b.useState(null);return b.useEffect(()=>{let n=!1;return c5(()=>import("./index-a3ZL0_Jr.js"),[]).then(r=>{n||t(()=>r.default)}).catch(()=>{}),()=>{n=!0}},[]),e},vir=({definition:e,selected:t,integrationName:n,enabledEvents:r,onToggleEvent:s,isEventToggleDisabled:o,monacoTheme:a})=>{var i,c,l,d;const f=yir(a),p=t.type==="action"?(i=e.actions)==null?void 0:i[t.key]:void 0,h=t.type==="event"?(c=e.events)==null?void 0:c[t.key]:void 0,g=$9((l=p?.input)==null?void 0:l.schema,"Input"),y=$9((d=p?.output)==null?void 0:d.schema,"Output"),E=$9(h?.schema,"Event"),[x,w]=b.useState("input"),S=t.type==="action"?x==="input"?g:y:E;if(t.type==="channel")return u.jsxs("div",{className:"flex h-full flex-col items-center justify-center p-6 text-center",children:[u.jsx("p",{className:"text-sm text-[var(--gray-11)]",children:"Schema preview is not available for channels."}),u.jsx("p",{className:"mt-1 text-xs text-[var(--gray-10)]",children:"Channels expose a set of message types rather than a single request/response schema."})]});const T=r?.has(t.key)??!1;return u.jsxs("div",{className:"flex h-full flex-col",children:[t.type==="event"&&s&&u.jsxs("div",{className:"mx-3 mt-3 rounded-lg border border-[var(--gray-a4)] bg-[var(--gray-a2)] p-4",children:[u.jsxs("div",{className:"flex w-full flex-row items-center",children:[u.jsx("span",{className:"whitespace-nowrap text-sm font-medium text-[var(--gray-12)]",children:"Enable Trigger"}),u.jsx("div",{className:"ml-auto shrink-0",children:u.jsx(Sir,{checked:T,disabled:o,onChange:k=>void s(t.key,k)})})]}),u.jsxs("div",{className:"mt-1 text-xs text-[var(--gray-11)]",children:[t.key," trigger for this integration"]})]}),u.jsxs("div",{className:"flex items-center gap-2 p-3",children:[t.type==="action"?u.jsxs("div",{className:"flex flex-1 rounded-lg bg-[var(--gray-a3)] p-1",children:[u.jsx(bTe,{active:x==="input",onClick:()=>w("input"),children:"Input"}),u.jsx(bTe,{active:x==="output",onClick:()=>w("output"),children:"Output"})]}):u.jsx("div",{className:"flex flex-1 rounded-lg bg-[var(--gray-a3)] p-1",children:u.jsx("div",{className:"flex-1 rounded-md bg-[var(--color-background,var(--gray-1))] px-3 py-2 text-center text-sm font-medium text-[var(--gray-12)] shadow-sm",children:"Event"})}),u.jsx(wir,{schemaTs:S})]}),u.jsx(xir,{children:u.jsx(Eir,{schemaTs:S,title:t.type==="action"?x==="input"?"Input":"Output":"Event",integrationName:n,cardKey:t.key,monacoTheme:f})})]})},xir=({children:e})=>u.jsx("div",{className:"mx-3 mb-3 min-h-0 flex-1 overflow-auto rounded-lg bg-[var(--gray-3)]",style:{minHeight:280},children:e}),Eir=({schemaTs:e,title:t,integrationName:n,cardKey:r,monacoTheme:s})=>{const o=bir();return e?o?u.jsx("div",{style:{height:"100%",minHeight:280},children:u.jsx(o,{value:e,language:"typescript",height:"100%",theme:s==="vs-dark"?"bp-hub-dark":s==="vs"?"bp-hub-light":s,beforeMount:hir,options:{readOnly:!0,domReadOnly:!0,lineNumbers:"on",lineNumbersMinChars:3,minimap:{enabled:!1},scrollBeyondLastLine:!1,scrollbar:{vertical:"hidden",horizontal:"hidden",handleMouseWheel:!1},wordWrap:"on",renderLineHighlight:"none",showFoldingControls:"never"}})}):u.jsx("pre",{className:"m-0 h-full overflow-auto p-4 text-xs leading-5 text-[var(--gray-12)]","data-file-name":`${n}-${r}-${t.toLowerCase()}.ts`,children:u.jsx("code",{className:"font-mono whitespace-pre-wrap",children:e})}):null},bTe=({active:e,onClick:t,children:n})=>u.jsx("button",{type:"button",onClick:t,className:jr("flex-1 cursor-pointer rounded-md px-3 py-2 text-center text-sm font-medium transition-colors",e?"bg-[var(--color-background,var(--gray-1))] text-[var(--gray-12)] shadow-sm":"text-[var(--gray-11)] hover:text-[var(--gray-12)]"),children:n}),wir=({schemaTs:e})=>{const[t,n]=b.useState(!1),r=async()=>{if(e)try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),2e3)}catch{n(!1)}};return u.jsx("button",{type:"button",onClick:()=>void r(),disabled:!e,"aria-label":"Copy schema",className:jr("inline-flex h-auto w-auto shrink-0 cursor-pointer items-center justify-center rounded-lg border border-[var(--gray-a4)] p-2 transition-colors hover:bg-[var(--gray-a3)]",!e&&"cursor-not-allowed opacity-50"),children:t?u.jsx(Xr,{className:"h-4 w-4"}):u.jsx(_Ct,{className:"h-4 w-4"})})},Sir=({checked:e,disabled:t,onChange:n})=>u.jsx("button",{type:"button",role:"switch","aria-checked":e,disabled:t,onClick:()=>n(!e),className:jr("relative inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full transition-colors",e?"bg-[var(--accent-9,var(--gray-12))]":"bg-[var(--gray-a5)]",t&&"cursor-not-allowed opacity-60"),children:u.jsx("span",{className:jr("inline-block h-4 w-4 transform rounded-full bg-white transition-transform",e?"translate-x-[18px]":"translate-x-0.5")})}),_ir="hitl",dy="sandbox",Tir=e=>Object.values(e.interfaces).some(t=>t.name===_ir);var Air=Object.defineProperty,lL=Object.getOwnPropertySymbols,Itt=Object.prototype.hasOwnProperty,Rtt=Object.prototype.propertyIsEnumerable,vTe=(e,t,n)=>t in e?Air(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,xQ=(e,t)=>{for(var n in t||(t={}))Itt.call(t,n)&&vTe(e,n,t[n]);if(lL)for(var n of lL(t))Rtt.call(t,n)&&vTe(e,n,t[n]);return e},EQ=(e,t)=>{var n={};for(var r in e)Itt.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&lL)for(var r of lL(e))t.indexOf(r)<0&&Rtt.call(e,r)&&(n[r]=e[r]);return n};/**
1785
1785
  * @license QR Code generator library (TypeScript)
1786
1786
  * Copyright (c) Project Nayuki.
1787
1787
  * SPDX-License-Identifier: MIT
@@ -1834,4 +1834,4 @@ ${t.text}
1834
1834
  \`\`\``;case"blockquote":return t.text.split(`
1835
1835
  `).map(n=>`> ${n}`).join(`
1836
1836
  `);case"list":case"table":case"paragraph":default:return t.text}}*getNodes(){for(const t of this._sortedChunks)yield{id:t.id,type:t.type,content:t.text,level:t.level,position:t.position,sourceUrl:t.sourceUrl,breadcrumb:t.breadcrumb}}get favicon(){return this._metadata.dsType==="web-page"&&this._metadata.favicon||null}get title(){return this._metadata.title?this._metadata.title:this._metadata.dsType==="web-page"?this._metadata.url:this._metadata.dsType==="document"?this._metadata.relPath:this._fileKey}get size(){let t=0;for(const n of this._chunks.values())t+=new TextEncoder().encode(n.text).length;return t}get mimeType(){const t=this._metadata.contentType;if(t)return t.split(";")[0].trim();switch(this._metadata.dsType){case"web-page":return"text/html";case"document":return"application/octet-stream";case"rich-text":return"text/plain";default:return"application/octet-stream"}}get chunks(){return this._chunks.size}get kb(){return this._kbInfo}get indexedAt(){return this._indexedAt}get lastmod(){if(this._metadata.dsType==="web-page"){const t=this._metadata.lastmod;return t?new Date(t):null}return null}get url(){return this._metadata.dsType==="web-page"?this._metadata.url:null}get score(){return this._passageScores.reduce((t,n)=>t+n,0)}get searches(){return Array.from(this._searches)}get fileId(){return this._fileId}get fileKey(){return this._fileKey}get metadata(){return this._metadata}get passageCount(){return this._passageScores.length}}function $Gr({query:e,limit:t=15,contextDepth:n=4,consolidate:r=!1,kbFilter:s=null,environment:o="dev"}){const{getClient:a,isReady:i}=$o(),c=bt(g=>g.selectedAgentPath),{data:l,isLoading:d,error:f}=Vn({queryKey:["searchFiles",c,e,t,n,r,s,o],queryFn:async()=>{const g=performance.now(),y=await a(o),E={source:"knowledge-base"};s&&(E.kbName=s);const x=await y.searchFiles({query:e,limit:t,contextDepth:n,consolidate:r,tags:E,withContext:!0,includeBreadcrumb:!0}),w=performance.now()-g;return{passages:x.passages??x.files??[],duration:w}},enabled:!!e&&i,staleTime:6e4,gcTime:5*6e4}),p=b.useMemo(()=>l?.passages.length?uoe.fromSearches([{search:e,passages:l.passages}]):[],[l?.passages,e]),h=b.useMemo(()=>{if(!p.length)return[];const g=rGr(p);return NQ(g)},[p]);return{documents:p,passages:l?.passages??[],treeNodes:h,isSearching:d,error:f,duration:l?.duration??null}}function LGr({mimeType:e}){return e.includes("html")?u.jsx(Zf,{className:"size-3 text-muted-foreground"}):e.includes("pdf")||e.includes("document")||e.includes("text")?u.jsx(Uh,{className:"size-3 text-muted-foreground"}):u.jsx(JN,{className:"size-3 text-muted-foreground"})}function FGr(e){try{const t=new URL(e),n=[t.hostname],r=t.pathname.split("/").filter(Boolean);return n.push(...r.slice(0,3)),n}catch{return[e]}}const BGr=b.memo(function({document:t,onClick:n}){const s=Array.from(t.getNodes()).filter(i=>i.type==="paragraph"||i.type==="list").slice(0,3).map(i=>i.content).join(" ").slice(0,280).trim(),o=t.url?FGr(t.url):null,a=t.passageCount>0?t.score/t.passageCount*100:0;return u.jsxs("div",{className:"group cursor-pointer rounded-md bg-muted/30 p-4 hover:border-muted-foreground/20 transition-colors",onClick:n,children:[u.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[t.favicon?u.jsx("img",{src:t.favicon,alt:"",className:"size-4 rounded-full shrink-0",onError:i=>{i.currentTarget.style.display="none"}}):u.jsx("div",{className:"size-4 rounded-full bg-muted flex items-center justify-center shrink-0",children:u.jsx(LGr,{mimeType:t.mimeType})}),o&&u.jsx("div",{className:"small flex items-center gap-0.5 min-w-0 flex-1",children:o.map((i,c)=>u.jsxs("span",{className:"flex items-center",children:[c>0&&u.jsx(cs,{className:"size-3 mx-0.5 text-muted-foreground/30"}),u.jsx("span",{className:"truncate max-w-[150px]",children:i})]},c))}),!o&&u.jsx("div",{className:"flex-1"}),u.jsxs("span",{className:"small text-muted-foreground/50 shrink-0 ml-auto tabular-nums",children:[t.passageCount," passage",t.passageCount!==1?"s":""," · score ",a.toFixed(0),"%"]})]}),u.jsx("h3",{className:"text-sm text-foreground font-medium group-hover:underline leading-snug mb-1.5",children:t.title}),s&&u.jsx("div",{className:"line-clamp-2",children:u.jsx(Ky,{content:s,className:"text-muted-foreground/70"})})]})}),qGr={limit:15,contextDepth:4};function UGr(){const{query:e,kbFilter:t,setQuery:n,setKbFilter:r}=PGr(),s=xs(z=>z.targetEnvironment),o=ds(z=>z.agent),[a,i]=b.useState(qGr),c=bt(z=>z.selectedAgentPath),l=sC(z=>z.getSelection),d=sC(z=>z.setSelection),[f,p]=b.useState(e??l(c,"search")),[h,g]=b.useState(null),[y,E]=b.useState(null),x=b.useRef(null),w=b.useRef(null),S=b.useRef(null),T=b.useMemo(()=>o?.knowledge?o.knowledge.map(z=>({name:z.name})):[],[o?.knowledge]),k=b.useMemo(()=>t&&T.some(z=>z.name===t)?t:null,[t,T]),{documents:A,treeNodes:N,isSearching:j,error:O}=$Gr({query:f,limit:a.limit,contextDepth:a.contextDepth,consolidate:!1,kbFilter:k,environment:s});b.useEffect(()=>{e&&!f&&p(e)},[e,f]);const D=b.useMemo(()=>{if(!h)return A;const z=Ert(h),G=new Set(z.map(R=>R.fileId));return A.filter(R=>G.has(R.fileId))},[A,h]),L=b.useCallback(z=>{n(z),p(z),d(c,"search",z),g(null),E(null)},[n,d,c]),U=b.useCallback(()=>{if(f){const z=f;p(null),queueMicrotask(()=>p(z))}},[f]),B=b.useCallback(z=>{g(z)},[]),M=b.useCallback(z=>{x.current=document.activeElement,E(z)},[]),$=b.useCallback(()=>{E(null),x.current&&(x.current.focus(),x.current=null)},[]);b.useEffect(()=>{g(null),E(null)},[s]);const P=O&&f?"error":j?"loading":f&&!j&&!O?"results":"idle",q=P==="results"&&A.length>0;return b.useEffect(()=>{const z=S.current;z&&(q?z.isCollapsed()&&z.expand():z.isCollapsed()||z.collapse())},[q]),b.useEffect(()=>{const z=w.current;z&&(y?z.isCollapsed()&&z.expand():z.isCollapsed()||z.collapse())},[y]),u.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[u.jsx("div",{className:"shrink-0 pb-2",children:u.jsx(jGr,{activeQuery:f,kbFilter:k,onSearch:L,isSearching:j,onKbFilterChange:r,knowledgeBases:T,advancedSettings:a,onAdvancedSettingsChange:i})}),P==="idle"&&u.jsx("div",{className:"flex-1 min-h-0 flex items-center justify-center",children:u.jsxs("div",{className:"flex flex-col items-center gap-3 max-w-sm text-center",children:[u.jsx("div",{className:"flex items-center justify-center size-10 rounded-lg bg-muted/40",children:u.jsx(wDe,{className:"size-5 text-muted-foreground/50"})}),u.jsx("p",{className:"body",children:"Search across all your knowledge bases using semantic retrieval."}),u.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground/40 mt-1",children:[u.jsx("kbd",{className:"code px-1.5 py-0.5 rounded bg-muted/40 text-[10px]",children:"Enter"}),u.jsx("span",{className:"small",children:"to search"})]})]})}),P!=="idle"&&u.jsxs("div",{className:"shrink-0 flex items-center pb-2 mb-0 pl-1",children:[P==="loading"&&u.jsx("p",{className:"small",children:"Searching..."}),P==="error"&&u.jsx("p",{className:"small text-red-400",children:"Search failed"}),P==="results"&&u.jsxs("p",{className:"small",children:["Found ",D.length," document",D.length!==1?"s":""," ·"," ",D.reduce((z,G)=>z+G.passageCount,0)," passage",D.reduce((z,G)=>z+G.passageCount,0)!==1?"s":""]})]}),P!=="idle"&&u.jsxs(cF,{direction:"horizontal",className:"flex-1 min-h-0",id:"search-panels",children:[u.jsx(rp,{id:"search-sidebar",ref:S,defaultSize:0,minSize:15,maxSize:35,collapsible:!0,collapsedSize:0,order:1,children:u.jsx(fGr,{treeNodes:N,selectedNodeId:h?.id??null,onNodeSelect:B,onDocumentClick:M})}),u.jsx(kw,{className:q?"":"hidden"}),u.jsx(rp,{id:"search-results",defaultSize:100,minSize:30,order:2,children:u.jsx("div",{className:"flex flex-col min-w-0 h-full overflow-hidden pl-6",children:u.jsxs("div",{className:"flex-1 overflow-auto",children:[P==="loading"&&u.jsx("div",{className:"py-4",children:u.jsx("div",{className:"flex flex-col gap-5",children:Array.from({length:5},(z,G)=>u.jsxs("div",{className:"flex flex-col gap-2 pb-5",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Wt,{className:"h-4 w-4 rounded-full"}),u.jsx(Wt,{className:"h-3 w-36"})]}),u.jsx(Wt,{className:"h-5 w-3/4"}),u.jsx(Wt,{className:"h-3.5 w-full"}),u.jsx(Wt,{className:"h-3.5 w-5/6"})]},G))})}),P==="error"&&O&&u.jsx("div",{className:"px-6 py-8",children:u.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-md border border-red-500/20 bg-red-500/10",children:[u.jsx(hy,{className:"size-5 text-red-400 shrink-0 mt-0.5"}),u.jsxs("div",{className:"flex flex-col gap-2",children:[u.jsx("p",{className:"h2 text-foreground",children:"Search failed"}),u.jsx("p",{className:"body",children:O.message}),u.jsxs(Pt,{variant:"outline",size:"sm",className:"w-fit rounded-md",onClick:U,children:[u.jsx(jDe,{className:"size-3.5 mr-1.5"}),"Retry"]})]})]})}),P==="results"&&!j&&u.jsx(u.Fragment,{children:A.length===0||D.length===0?u.jsxs("div",{className:"flex flex-col items-center justify-center py-20 px-6",children:[u.jsxs("h2",{className:"h2 text-foreground mb-2",children:["No results for “",f,"”"]}),u.jsx("p",{className:"body text-center max-w-md",children:"Try a different search term, remove the KB filter, or check that your knowledge base has been indexed."})]}):u.jsx("div",{className:"py-4",children:u.jsx("div",{className:"flex-1 min-w-0",children:u.jsx("div",{className:"flex flex-col gap-3",children:D.map(z=>u.jsx(BGr,{document:z,onClick:()=>M(z)},z.fileId))})})})})]})})}),u.jsx(kw,{className:y?"":"hidden"}),u.jsx(rp,{id:"search-drawer",ref:w,defaultSize:0,minSize:20,maxSize:55,collapsible:!0,collapsedSize:0,order:3,onCollapse:()=>E(null),children:u.jsx("div",{className:"h-full",children:u.jsx(MGr,{document:y,onClose:$})})})]})]})}function gAe(){const e=bt.getState().selectedAgentPath,{credentials:t,credentialsAgentPath:n,devBotId:r,prodBotId:s}=ds.getState(),o=!!e&&n===e,a=o&&!!t?.token&&t.token!=="hasToken";return{credentials:o?t:null,devBotId:o?r:null,prodBotId:o?s:null,hasCredentials:a}}const $rt=od((e,t)=>({runs:[],isLoading:!1,error:null,lastFetch:null,pollTimeout:null,isPolling:!1,currentFilter:void 0,currentEnvironment:void 0,fetchRuns:async n=>{e({error:null});try{const{credentials:r,devBotId:s,prodBotId:o,hasCredentials:a}=gAe();if(!a||!r){e({runs:[],isLoading:!1,error:"Credentials required"});return}const c=await(await RJ(r,n.environment,{devBotId:s,prodBotId:o})).list.workflows({name:n.workflowName,statuses:n.statuses}).collect({limit:50}),l=t();if(l.isPolling&&(l.currentFilter!==n.workflowName||l.currentEnvironment!==n.environment))return;e({runs:c,isLoading:!1,lastFetch:new Date})}catch(r){console.error("Failed to fetch workflow runs:",r),e({error:r instanceof Error?r.message:"Failed to fetch workflow runs",isLoading:!1})}},startPolling:n=>{const{stopPolling:r,fetchRuns:s}=t(),{hasCredentials:o}=gAe();if(!o){console.log("Not polling: credentials required"),e({error:"Credentials required",isLoading:!1,isPolling:!1});return}r(),e({isLoading:!0,isPolling:!0,currentFilter:n.workflowName,currentEnvironment:n.environment});const a=async()=>{if(!t().isPolling)return;await s({workflowName:n.workflowName,statuses:n.statuses,environment:n.environment});const c=t();if(!c.isPolling||c.currentFilter!==n.workflowName||c.currentEnvironment!==n.environment)return;const l=setTimeout(a,1e3);e({pollTimeout:l})};a()},stopPolling:()=>{const{pollTimeout:n}=t();n&&clearTimeout(n),e({pollTimeout:null,isPolling:!1,currentFilter:void 0,currentEnvironment:void 0})}})),OQ=["pending","in_progress","paused","listening"];function zGr(e){return OQ.includes(e)}function HGr(e){switch(e){case"in_progress":return"In progress";case"completed":return"Completed";case"failed":return"Failed";case"timedout":return"Timed out";case"paused":return"Paused";case"listening":return"Listening";case"cancelled":return"Cancelled";case"pending":return"Pending";default:return e}}function VGr({status:e,className:t}){const n=me("size-4 shrink-0",t);switch(e){case"completed":return u.jsx(Ms,{className:me(n,"text-green-400")});case"failed":return u.jsx(yl,{className:me(n,"text-red-400")});case"timedout":return u.jsx(As,{className:me(n,"text-orange-400")});case"in_progress":case"pending":return u.jsx(nn,{className:me(n,"animate-spin text-blue-400")});case"paused":case"listening":return u.jsx(id,{className:me(n,"text-orange-400")});case"cancelled":return u.jsx(pk,{className:me(n,"text-muted-foreground/50")});default:return u.jsx(pk,{className:me(n,"text-muted-foreground/50")})}}function GGr(e){const t=new Date(e.createdAt).getTime(),n=zGr(e.status)?Date.now():new Date(e.updatedAt).getTime();return Math.max(0,n-t)}function yAe(e){return e?new Date(e).toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):"-"}function XD({label:e,value:t}){return u.jsxs("div",{className:"min-w-0",children:[u.jsx("div",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground/50",children:e}),u.jsx("div",{className:"code mt-1 truncate text-foreground/85",children:t})]})}function J9(e){if(e==null)return"-";const t=Math.floor(e/1e3),n=Math.floor(t/60);return n>0?`${n}m ${t%60}s`:`${t}s`}function Lrt(e){let t=Object.keys(e).length;for(const n of Object.values(e))n.steps&&(t+=Lrt(n.steps));return t}const AM=({name:e,step:t,depth:n})=>{const r=!!t.finishedAt,s=!!t.error,o=!r&&!s,a=t.steps&&Object.keys(t.steps).length>0,i=t.steps?Object.entries(t.steps):[],c=i.length>1&&i.some(([N])=>/^.*-i\d+$/.test(N)),l=t.steps?Lrt(t.steps):0,d=c?!1:o||!r&&!s||l<=5,[f,p]=b.useState(d),[h,g]=b.useState(!1),y=r&&t.output!==void 0||s,E=N=>`${(N/1e3).toFixed(1)}s`;let x=0;const w=t.mapTotal??0;let S=0,T=0,k="";if(c){let N=0,j=0;for(const[,D]of i)if(D.finishedAt&&!D.error){x++;const L=new Date(D.finishedAt).getTime()-new Date(D.startedAt).getTime();L>0&&(N+=L,j++)}else D.error?T++:S++;const O=w>0?w-x-T:0;if(O>0&&j>0){const D=N/j,L=t.mapConcurrency??1,U=D*O/L;k=`~${E(U)} left`}}const A=t.finishedAt?new Date(t.finishedAt).getTime()-new Date(t.startedAt).getTime():Date.now()-new Date(t.startedAt).getTime();return u.jsxs("div",{children:[u.jsxs("div",{className:me("group/step flex items-center gap-2 rounded-sm px-2.5 py-2 small transition-colors",(a||y)&&"cursor-pointer hover:bg-background-hover/70",o&&"bg-blue-500/5",h&&"bg-background-hover"),style:{paddingLeft:`${n*14+10}px`},onClick:a?()=>p(!f):y?()=>g(!h):void 0,children:[a&&u.jsx("div",{className:"flex size-4 shrink-0 items-center justify-center",children:f?u.jsx(Dr,{className:"size-3 text-muted-foreground/60"}):u.jsx(cs,{className:"size-3 text-muted-foreground/60"})}),o?u.jsx(nn,{className:"size-4 shrink-0 animate-spin text-blue-400"}):s?u.jsx(As,{className:"size-4 shrink-0 text-red-400"}):u.jsx(Ms,{className:"size-4 shrink-0 text-green-400"}),u.jsx("span",{className:me("truncate font-medium text-foreground/90",o&&"text-blue-400"),children:e}),c&&u.jsxs("span",{className:"shrink-0 rounded-sm bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground/70",children:[".map",t.mapConcurrency&&t.mapConcurrency>1?` ×${t.mapConcurrency}`:""]}),c&&u.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:u.jsxs("div",{className:"flex items-center gap-1.5",children:[w>0&&u.jsx("div",{className:"h-1.5 w-20 overflow-hidden rounded-full bg-muted",children:u.jsx("div",{className:me("h-full rounded-full transition-all",T>0?"bg-red-500":"bg-green-500"),style:{width:`${(x+T)/w*100}%`}})}),u.jsxs("span",{className:"whitespace-nowrap tabular-nums text-muted-foreground/70",children:[x,"/",w>0?w:"?"]}),k&&u.jsx("span",{className:"whitespace-nowrap text-blue-400",children:k})]})}),t.attempts>0&&u.jsxs("span",{className:"flex shrink-0 items-center gap-0.5 text-orange-400",children:[u.jsx(_De,{className:"size-3"}),u.jsxs("span",{children:["attempt ",t.attempts+1,t.maxAttempts?`/${t.maxAttempts}`:""]})]}),s&&u.jsx("span",{className:"text-red-500 truncate max-w-[200px]",title:t.error.message,children:t.error.message}),!c&&u.jsx("span",{className:me("ml-auto shrink-0 tabular-nums text-muted-foreground/70",o&&"text-blue-400"),children:E(A)})]}),c&&!f&&S>0&&u.jsx("div",{className:"px-2 pb-1",style:{paddingLeft:`${n*14+38}px`},children:u.jsxs("div",{className:"small text-muted-foreground/60",children:[x," done, ",S," processing",T>0&&`, ${T} failed`]})}),f&&a&&u.jsx(WGr,{entries:i,depth:n+1}),h&&y&&u.jsx("div",{className:"mt-1.5 mb-2 max-h-40 overflow-auto rounded-md border border-muted-foreground/10 bg-background-elevated p-2.5 text-xs",style:{marginLeft:`${n*14}px`},children:s?u.jsxs("div",{children:[u.jsxs("div",{className:"mb-1 font-medium text-red-400",children:["Error",t.error.maxAttemptsReached?" (max attempts)":""]}),u.jsx("pre",{className:"whitespace-pre-wrap wrap-break-word text-red-400",children:t.error.message})]}):u.jsx(Oo,{data:t.output})})]})},JD=3,WGr=({entries:e,depth:t})=>{const n=e.filter(([,d])=>d.finishedAt&&!d.error),r=e.filter(([,d])=>d.error),s=e.filter(([,d])=>!d.finishedAt&&!d.error),[o,a]=b.useState(!1),i=n.length>JD+2,c=i&&!o?n.slice(0,-JD):[],l=i&&!o?n.slice(-JD):n;return u.jsxs("div",{children:[c.length>0&&u.jsxs("div",{className:"flex cursor-pointer items-center gap-2 rounded-sm px-2.5 py-1.5 small text-muted-foreground/70 hover:bg-background-hover/70",style:{paddingLeft:`${t*14+10}px`},onClick:()=>a(!0),children:[u.jsx(cs,{className:"size-3 text-muted-foreground/60"}),u.jsx(Ms,{className:"size-4 text-green-400"}),u.jsxs("span",{children:[c.length," items completed"]})]}),o&&i&&u.jsxs("div",{className:"flex cursor-pointer items-center gap-2 rounded-sm px-2.5 py-1.5 small text-muted-foreground/70 hover:bg-background-hover/70",style:{paddingLeft:`${t*14+10}px`},onClick:()=>a(!1),children:[u.jsx(Dr,{className:"size-3 text-muted-foreground/60"}),u.jsxs("span",{children:["Collapse ",n.length-JD," items"]})]}),(o?n:l).map(([d,f])=>u.jsx(AM,{name:d,step:f,depth:t},d)),r.map(([d,f])=>u.jsx(AM,{name:d,step:f,depth:t},d)),s.map(([d,f])=>u.jsx(AM,{name:d,step:f,depth:t},d))]})},KGr=({stepsData:e,runStatus:t})=>{const n=["pending","in_progress","listening"].includes(t),r=e&&typeof e=="object"?e:null,o=(r?.value&&typeof r.value=="object"?r.value:null)??r;if(!o||!o.steps&&!o.executionCount)return u.jsx("div",{className:"min-h-[80px] py-6 flex items-center justify-center text-muted-foreground text-xs",children:n?u.jsxs("div",{className:"flex flex-col items-center gap-2",children:[u.jsx(nn,{className:"h-5 w-5 animate-spin text-blue-500"}),u.jsx("div",{children:"Waiting for first step to complete..."}),u.jsx("div",{className:"text-xs text-muted-foreground/60",children:"Steps appear after they finish executing"})]}):"No steps data available"});const a=o.executionCount??0,i=o.steps??{},c=Object.entries(i),l=c.filter(([,p])=>p.finishedAt&&!p.error),d=c.filter(([,p])=>p.error),f=c.filter(([,p])=>!p.finishedAt&&!p.error);return u.jsxs("div",{className:"flex max-h-[500px] flex-col",children:[u.jsxs("div",{className:"grid grid-cols-2 gap-2 border-b border-muted-foreground/10 px-3 py-3",children:[u.jsxs("div",{className:"rounded-sm bg-background/60 px-2.5 py-2",children:[u.jsx("div",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground/50",children:"Invocations"}),u.jsx("div",{className:"metric mt-1 text-foreground",children:a})]}),u.jsxs("div",{className:"rounded-sm bg-background/60 px-2.5 py-2",children:[u.jsxs("div",{className:"flex items-center justify-between gap-2",children:[u.jsx("div",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground/50",children:"Steps"}),n&&u.jsx(nn,{className:"size-3 animate-spin text-blue-400"})]}),u.jsxs("div",{className:"small mt-1 text-foreground",children:[u.jsx("span",{className:"font-medium tabular-nums",children:l.length})," done",d.length>0&&u.jsxs("span",{className:"text-red-400",children:[" · ",d.length," failed"]}),f.length>0&&u.jsxs("span",{className:"text-blue-400",children:[" · ",f.length," running"]})]})]})]}),u.jsx(ud,{className:"flex-1",children:u.jsx("div",{className:"space-y-0.5 px-2 py-2",children:c.length===0?u.jsx("div",{className:"flex items-center justify-center h-32 text-muted-foreground text-xs",children:n?u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(nn,{className:"h-4 w-4 animate-spin"}),"Waiting for first step..."]}):"No steps recorded"}):c.map(([p,h])=>u.jsx(AM,{name:p,step:h,depth:0},p))})})]})};function ZGr({run:e,isExpanded:t,onToggle:n,showWorkflowName:r=!1,workflowFilter:s,environment:o}){const[a,i]=b.useState("workflow"),[c,l]=b.useState({}),[d,f]=b.useState(!1),p=b.useRef(null),[h,g]=b.useState(null),[y,E]=b.useState(null),[x,w]=b.useState(void 0),{getClient:S,credentials:T,isReady:k}=$o(),{agent:A}=ds(),{fetchRuns:N}=$rt(),j=o==="prod",O=async()=>{if(!(!k||!T?.token||T.token==="hasToken")){f(!0);try{const M=await S(o),[$,P]=await Promise.all([M.getState({name:"workflowState",id:e.id,type:"workflow"}).catch(()=>null),M.getState({name:"workflowSteps",id:e.id,type:"workflow"}).catch(()=>null)]),q=async R=>{if(!R||typeof R!="object")return R;const W=R;if(W.location?.type==="file"&&W.location.key)try{const{file:V}=await M.getFile({id:W.location.key});return{value:await(await fetch(V.url)).json(),location:W.location}}catch(V){return console.error("Failed to fetch swapped state file:",V),R}return R},[z,G]=await Promise.all([q($?.state?.payload),q(P?.state?.payload)]);l(R=>{const W={workflowState:z,workflowSteps:G,lastFetch:new Date};return JSON.stringify(R.workflowState)!==JSON.stringify(W.workflowState)||JSON.stringify(R.workflowSteps)!==JSON.stringify(W.workflowSteps)?W:R})}catch(M){console.error(`Failed to fetch state for workflow ${e.id}:`,M)}finally{f(!1)}}};b.useEffect(()=>{if(!t){p.current&&(clearInterval(p.current),p.current=null);return}return O(),["in_progress","pending","listening","paused"].includes(e.status)&&(p.current=setInterval(O,2e3)),()=>{p.current&&(clearInterval(p.current),p.current=null)}},[o,t,e.status]);const D=GGr(e),L=iWe(new Date(e.createdAt)),U=HGr(e.status),B=!["completed","failed","cancelled","timedout"].includes(e.status);return u.jsxs("article",{className:me("group/run overflow-hidden rounded-md border transition-colors",t?"border-muted-foreground/15 bg-background":"border-transparent bg-background/55 hover:bg-background-hover/80"),children:[u.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":t,onClick:n,onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),n())},className:"flex cursor-pointer items-center gap-3 px-3 py-3 text-left outline-none focus-visible:ring-1 focus-visible:ring-muted-foreground/35",children:[u.jsx("div",{className:"flex size-7 shrink-0 items-center justify-center rounded-sm bg-background-elevated",children:u.jsx(VGr,{status:e.status})}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("div",{className:"flex min-w-0 items-center gap-2",children:u.jsx("div",{className:"caption truncate text-foreground",children:r?e.name:L})}),u.jsxs("div",{className:"small mt-1 flex flex-wrap items-center gap-x-1.5 gap-y-0.5 text-muted-foreground/70",children:[r&&u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"truncate",children:L}),u.jsx("span",{className:"text-muted-foreground/30",children:"·"})]}),u.jsx("span",{children:U}),u.jsx("span",{className:"text-muted-foreground/30",children:"·"}),u.jsx("span",{children:J9(D)})]})]}),!j&&u.jsxs(vn,{children:[u.jsx(xn,{asChild:!0,children:u.jsx(Fc,{to:`/traces?workflowId=${e.id}`,onClick:M=>M.stopPropagation(),className:"flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground/70 opacity-70 transition-colors hover:bg-muted hover:text-foreground group-hover/run:opacity-100","aria-label":"View traces",children:u.jsx(tc,{className:"size-3.5"})})}),u.jsx(yn,{side:"top",children:"Traces"})]}),u.jsx(cs,{className:me("size-3.5 shrink-0 text-muted-foreground/30 transition-transform",t&&"rotate-90")})]}),t&&u.jsx("div",{className:"border-t border-muted-foreground/10 bg-background/70",children:u.jsxs(RF,{value:a,onValueChange:i,className:"w-full",children:[u.jsxs("div",{className:"flex items-center justify-between gap-3 px-3 py-2",children:[u.jsxs("div",{className:"min-w-0 flex-1",children:[u.jsx("div",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground/50",children:"Run ID"}),u.jsx("code",{className:"code mt-1 block truncate text-foreground/80",children:e.id})]}),u.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[u.jsxs(vn,{children:[u.jsx(xn,{asChild:!0,children:u.jsx(Pt,{type:"button",variant:"ghost",size:"icon",className:"size-7 text-muted-foreground hover:text-foreground",onClick:M=>{M.stopPropagation(),navigator.clipboard.writeText(e.id).catch(()=>{})},"aria-label":"Copy run ID",children:u.jsx(li,{className:"size-3.5"})})}),u.jsx(yn,{side:"top",children:"Copy run ID"})]}),u.jsxs(vn,{children:[u.jsx(xn,{asChild:!0,children:u.jsx(Pt,{type:"button",variant:"ghost",size:"icon",className:"size-7 text-muted-foreground hover:text-foreground",onClick:M=>{M.stopPropagation();const $=A?.workflows?.find(P=>P.name===e.name)||{name:e.name||"workflow",description:"Replay workflow execution",timeout:3e5};g($),E(e.input),w({userId:e.userId,conversationId:e.conversationId,parentWorkflowId:e.parentWorkflowId,tags:e.tags})},"aria-label":"Replay workflow",children:u.jsx(o5,{className:"size-3.5"})})}),u.jsx(yn,{side:"top",children:"Replay"})]}),u.jsxs(vn,{children:[u.jsx(xn,{asChild:!0,children:u.jsx(Pt,{type:"button",variant:"ghost",size:"icon",className:"size-7 text-muted-foreground hover:text-foreground",disabled:e.status!=="listening",onClick:async M=>{if(M.stopPropagation(),!(!k||!T))try{await(await S(o)).createEvent({type:"workflowContinue",workflowId:e.id,payload:{}})}catch($){console.error("Failed to continue workflow:",$)}},"aria-label":"Continue workflow",children:u.jsx(lm,{className:"size-3.5"})})}),u.jsx(yn,{side:"top",children:"Continue"})]}),u.jsxs(vn,{children:[u.jsx(xn,{asChild:!0,children:u.jsx(Pt,{type:"button",variant:"ghost",size:"icon",className:me("size-7",B?"text-red-400 hover:bg-red-500/10 hover:text-red-400":"text-muted-foreground"),disabled:!B,onClick:async M=>{if(M.stopPropagation(),!(!k||!T))try{await(await S(o)).updateWorkflow({id:e.id,status:"cancelled"}),N({workflowName:s,environment:o})}catch($){console.error("Failed to cancel workflow:",$)}},"aria-label":"Cancel workflow",children:u.jsx(yl,{className:"size-3.5"})})}),u.jsx(yn,{side:"top",children:"Cancel"})]})]})]}),u.jsx("div",{className:"border-t border-muted-foreground/10 px-3 py-2",children:u.jsxs(jF,{variant:"ghost",className:"h-7",children:[u.jsx(iy,{value:"workflow",children:"Workflow"}),u.jsx(iy,{value:"steps",children:"Steps"}),u.jsx(iy,{value:"state",children:"State"})]})}),u.jsx(ly,{value:"steps",className:"m-0 focus-visible:ring-0 focus-visible:ring-offset-0",children:u.jsx(KGr,{stepsData:c.workflowSteps,runStatus:e.status})}),u.jsx(ly,{value:"workflow",className:"m-0 focus-visible:ring-0 focus-visible:ring-offset-0",children:u.jsxs("div",{className:"space-y-4 px-3 pb-3",children:[u.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-4",children:[u.jsx(XD,{label:"Started",value:yAe(e.createdAt)}),u.jsx(XD,{label:"Ended",value:yAe(e.updatedAt)}),u.jsx(XD,{label:"Timeout",value:e.timeoutAt?J9(new Date(e.timeoutAt).getTime()-new Date(e.createdAt).getTime()):"-"}),u.jsx(XD,{label:"Duration",value:J9(D)})]}),u.jsxs("div",{className:"space-y-3",children:[u.jsxs("div",{children:[u.jsx("div",{className:"caption mb-2",children:"Input"}),u.jsx("div",{className:"rounded-md border border-muted-foreground/10 bg-background-elevated p-3",children:u.jsx(Oo,{data:e.input??{}})})]}),u.jsxs("div",{children:[u.jsx("div",{className:"caption mb-2",children:e.status==="failed"?"Error":"Output"}),e.status==="in_progress"||e.status==="pending"?u.jsx("div",{className:"flex min-h-32 items-center justify-center rounded-md border border-muted-foreground/10 bg-background-elevated text-muted-foreground",children:u.jsxs("div",{className:"text-center",children:[u.jsx(za,{className:"h-6 w-6 animate-spin mx-auto mb-2"}),u.jsx("div",{className:"text-xs",children:"Workflow in progress..."})]})}):u.jsx("div",{className:"rounded-md border border-muted-foreground/10 bg-background-elevated p-3",children:e.status==="failed"?u.jsx("pre",{className:"text-xs font-mono whitespace-pre-wrap wrap-break-word text-red-500",children:e.failureReason}):u.jsx(Oo,{data:e.output})})]})]})]})}),u.jsx(ly,{value:"state",className:"m-0 focus-visible:ring-0 focus-visible:ring-offset-0",children:c.workflowState||c.workflowSteps?u.jsxs("div",{className:"space-y-3 px-3 pb-3",children:[(()=>{const M=c.workflowState,$=M?.location?.type==="file",P=M?.value??M;return u.jsxs("div",{children:[u.jsxs("div",{className:"flex items-center justify-between mb-3",children:[u.jsxs("div",{className:"caption",children:["State",$?" (swap)":M?.location?" (state)":""]}),d&&u.jsx(za,{className:"h-3 w-3 animate-spin text-muted-foreground"})]}),u.jsx("div",{className:"rounded-md border border-muted-foreground/10 bg-background-elevated p-3",children:P?u.jsx(Oo,{data:P}):u.jsx("div",{className:"small",children:"// No state data"})})]})})(),(()=>{const M=c.workflowSteps,$=M?.location?.type==="file",P=M?.value??M;return u.jsxs("div",{children:[u.jsxs("div",{className:"caption mb-3",children:["Steps",$?" (swap)":M?.location?" (state)":""]}),u.jsx("div",{className:"rounded-md border border-muted-foreground/10 bg-background-elevated p-3",children:P?u.jsx(Oo,{data:P}):u.jsx("div",{className:"small",children:"// No steps data"})})]})})()]}):u.jsx("div",{className:"p-8 text-center text-muted-foreground",children:u.jsx("div",{className:"text-xs",children:"No state or steps data available"})})})]})}),u.jsx(vte,{workflow:h,initialInput:y,initialAdvanced:x,onClose:()=>{g(null),E(null),w(void 0)}})]})}function Frt({workflowName:e,showWorkflowName:t=!1}){const[n,r]=b.useState(null),{runs:s,isLoading:o,startPolling:a,stopPolling:i}=$rt(),c=xs(x=>x.targetEnvironment),l=ds(x=>x.credentials),d=ds(x=>x.credentialsAgentPath),f=bt(x=>x.selectedAgentPath),h=!!f&&d===f&&!!l?.token&&l.token!=="hasToken";if(b.useEffect(()=>(h?a({workflowName:e,environment:c}):i(),()=>i()),[h,c,e,a,i]),!h)return u.jsx("div",{className:"py-8 text-center",children:u.jsx("p",{className:"text-xs text-muted-foreground/50",children:"Connect credentials to view workflow runs"})});if(o&&s.length===0)return u.jsxs("div",{className:"py-8 text-center text-muted-foreground",children:[u.jsx(za,{className:"h-5 w-5 animate-spin mx-auto mb-2"}),u.jsx("p",{className:"text-xs",children:"Loading runs..."})]});if(s.length===0)return u.jsx("div",{className:"py-8 text-center",children:u.jsx("p",{className:"text-xs text-muted-foreground/50",children:"No runs yet"})});const g=s.filter(x=>OQ.includes(x.status)),y=s.filter(x=>!OQ.includes(x.status)),E=x=>u.jsx(ZGr,{run:x,isExpanded:n===x.id,onToggle:()=>r(n===x.id?null:x.id),showWorkflowName:t,workflowFilter:e,environment:c},x.id);return u.jsxs("div",{children:[g.length>0&&u.jsxs("section",{children:[u.jsxs("h3",{className:"small mb-2 font-semibold uppercase tracking-wide",children:["Active ",u.jsxs("span",{className:"text-muted-foreground/50",children:["· ",g.length]})]}),u.jsx("div",{className:"flex flex-col gap-2",children:g.map(E)})]}),y.length>0&&u.jsxs("section",{className:me(g.length>0&&"-mx-4 mt-3 border-t border-muted-foreground/10 px-4 pt-3"),children:[u.jsxs("h3",{className:"small mb-2 font-semibold uppercase tracking-wide",children:["Past ",u.jsxs("span",{className:"text-muted-foreground/50",children:["· ",y.length]})]}),u.jsx("div",{className:"flex flex-col gap-2",children:y.map(E)})]})]})}function YGr(e){const t=Math.floor(e/1e3),n=Math.floor(t/60),r=Math.floor(n/60);return r>0?`${r}h`:n>0?`${n}m`:`${t}s`}const fg="__all_runs__";function QGr({workflow:e,runsPanelOpen:t,onOpenRuns:n,onCloseRuns:r}){const[s,o]=b.useState(null),{isReady:a}=$o(),{track:i}=lf();return u.jsxs("div",{className:"flex h-full gap-6 overflow-hidden",children:[u.jsxs("div",{className:"flex-1 min-w-0 overflow-auto",children:[u.jsxs("div",{className:"pb-4",children:[u.jsxs("div",{className:"flex items-start justify-between gap-4",children:[u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("h1",{className:"h2 truncate",children:e.name}),e.path&&u.jsxs("p",{className:"code text-muted-foreground/40 mt-1",children:[e.path,e.export&&` (${e.export})`]}),e.description&&u.jsx("p",{className:"body mt-2 leading-relaxed",children:e.description})]}),u.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[!t&&u.jsxs(Pt,{variant:"outline",onClick:n,children:[u.jsx(tc,{}),"Runs"]}),u.jsxs(Pt,{onClick:()=>{i("control_panel.feature_used",{feature:"workflow_inspect"}),o(e)},disabled:!a,children:[u.jsx(lm,{}),"Invoke workflow"]})]})]}),u.jsx("div",{className:"flex flex-wrap gap-1.5 mt-3",children:u.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-border/50 bg-muted/30 px-2 py-0.5 text-xs",children:[u.jsx(id,{className:"size-3 text-muted-foreground/50"}),u.jsx("span",{className:"text-muted-foreground/50",children:"timeout"}),u.jsx("span",{className:"font-medium",children:YGr(e.timeout)})]})})]}),u.jsx("div",{className:"py-4",children:u.jsxs("div",{className:"space-y-4",children:[u.jsxs("div",{children:[u.jsx("div",{className:"h3 mb-2",children:"Input"}),u.jsx("div",{className:"rounded-md border border-border/50 bg-muted/20 p-3",children:u.jsx(aw,{schema:e.input})})]}),u.jsxs("div",{children:[u.jsx("div",{className:"h3 mb-2",children:"Output"}),u.jsx("div",{className:"rounded-md border border-border/50 bg-muted/20 p-3",children:u.jsx(aw,{schema:e.output})})]})]})}),u.jsx(vte,{workflow:s,onClose:()=>o(null)})]}),t&&u.jsxs("aside",{className:"flex h-full w-[min(380px,34vw)] min-w-72 shrink-0 flex-col overflow-hidden rounded-md bg-background-elevated",children:[u.jsxs("header",{className:"flex items-start justify-between gap-3 border-b border-muted-foreground/15 px-4 py-3",children:[u.jsxs("div",{className:"min-w-0",children:[u.jsx("h2",{className:"caption truncate text-foreground",children:"Runs"}),u.jsx("p",{className:"small mt-0.5 truncate text-muted-foreground/60",children:e.name})]}),u.jsxs(vn,{children:[u.jsx(xn,{asChild:!0,children:u.jsx("button",{type:"button",onClick:r,className:"flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground","aria-label":"Close runs panel",children:u.jsx(ca,{className:"size-3.5"})})}),u.jsx(yn,{side:"bottom",sideOffset:6,className:"text-xs",children:"Close"})]})]}),u.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-3 pb-3 pt-3",children:u.jsx(Frt,{workflowName:e.name})})]})]})}function XGr(){return u.jsxs("div",{className:"h-full overflow-auto",children:[u.jsx("div",{className:"pb-3",children:u.jsxs("div",{className:"flex items-center gap-2.5",children:[u.jsx("div",{className:"size-7 rounded flex items-center justify-center shrink-0 bg-muted",children:u.jsx(tc,{className:"size-3.5 text-muted-foreground"})}),u.jsx("h1",{className:"h2",children:"All Runs"})]})}),u.jsx("div",{className:"pb-4",children:u.jsx("div",{className:"rounded-md bg-background-elevated p-3",children:u.jsx(Frt,{showWorkflowName:!0})})})]})}function JGr(){return u.jsxs("div",{className:"flex h-full",children:[u.jsxs("div",{className:"w-[280px] shrink-0 bg-background",children:[u.jsx("div",{className:"px-4 py-3 border-b border-border/50",children:u.jsx(Wt,{className:"h-3 w-20"})}),u.jsx("div",{className:"px-4 py-2.5",children:u.jsx(Wt,{className:"h-4 w-16"})}),u.jsx("div",{className:"mx-4 my-1 border-b border-border/30"}),[1,2,3].map(e=>u.jsx("div",{className:"px-4 py-2.5",children:u.jsx(Wt,{className:"h-4 w-28"})},e))]}),u.jsxs("div",{className:"flex-1 pt-5",children:[u.jsxs("div",{className:"flex items-center gap-2.5 mb-3",children:[u.jsx(Wt,{className:"size-7 rounded"}),u.jsx(Wt,{className:"h-5 w-36"})]}),u.jsx(Wt,{className:"h-4 w-72 mb-6"}),u.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[u.jsx(Wt,{className:"h-24"}),u.jsx(Wt,{className:"h-24"})]})]})]})}function eWr(){const{data:e,isLoading:t,error:n}=cm(),r=ui(),s=Lc(),o=b.useMemo(()=>e?.workflows||[],[e?.workflows]),[a,i]=Yy("workflows"),[c,l]=b.useState(""),[d,f]=b.useState(!0),p=r.pathname==="/workflows/runs",h=p?fg:a,g=b.useMemo(()=>{if(!c)return o;const T=c.toLowerCase();return o.filter(k=>k.name.toLowerCase().includes(T)||k.description?.toLowerCase().includes(T))},[o,c]),y=o[0]?.name,E=b.useCallback(T=>{i(T),r.pathname!=="/workflows"&&s(`/workflows?selected=${encodeURIComponent(T)}`,{replace:!0})},[r.pathname,s,i]),x=b.useCallback(()=>{s("/workflows/runs",{replace:!0})},[s]);b.useEffect(()=>{p||a===null&&y&&i(y)},[y,p,a,i]),b.useEffect(()=>{p||!a||a===fg||o.find(T=>T.name===a)||i(o[0]?.name??null)},[p,o,a,i]),b.useEffect(()=>{const T=k=>{if(k.target instanceof HTMLTextAreaElement||k.target instanceof HTMLInputElement)return;const A=[fg,...g.map(j=>j.name)];if(A.length===0)return;const N=A.findIndex(j=>j===h);if(k.key==="ArrowDown"||k.key==="j"){k.preventDefault();const j=Math.min(N+1,A.length-1),O=A[j];O===fg?x():E(O)}else if(k.key==="ArrowUp"||k.key==="k"){k.preventDefault();const j=Math.max(N-1,0),O=A[j];O===fg?x():E(O)}};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[h,g,x,E]);const w=b.useMemo(()=>h&&h!==fg?o.find(T=>T.name===h)??null:null,[o,h]),S=w?.name;return b.useEffect(()=>{S&&f(!0)},[S]),t?u.jsx(JGr,{}):n?u.jsx("div",{className:"flex h-full items-center justify-center",children:u.jsxs("div",{className:"rounded-md border border-dashed bg-card p-8 flex flex-col items-center gap-3 text-center",children:[u.jsx(Mh,{className:"size-8 text-muted-foreground/30"}),u.jsxs("div",{children:[u.jsx("p",{className:"h2",children:"Failed to load workflows"}),u.jsx("p",{className:"small mt-1",children:n instanceof Error?n.message:"An unexpected error occurred"})]})]})}):o.length===0?u.jsx("div",{className:"flex h-full items-center justify-center",children:u.jsxs("div",{className:"rounded-md border border-dashed bg-card p-8 flex flex-col items-center gap-3 text-center",children:[u.jsx(Mh,{className:"size-8 text-muted-foreground/30"}),u.jsxs("div",{children:[u.jsx("p",{className:"h2",children:"No workflows"}),u.jsxs("p",{className:"small mt-1",children:["Create a workflow in ",u.jsx("code",{className:"code bg-muted px-1 py-0.5 rounded",children:"src/workflows/"})]})]})]})}):u.jsx("div",{className:"flex flex-col h-full overflow-hidden",children:u.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden gap-6",children:[u.jsxs(SS,{children:[u.jsx(Wv,{value:c,onChange:l}),u.jsxs(_S,{children:[u.jsx(Jg,{label:e?.name||"Bot",count:g.length,collapsible:!0,children:g.map(T=>u.jsxs($h,{isSelected:T.name===h,onClick:()=>E(T.name),children:[u.jsx(Mh,{className:"size-3.5 text-muted-foreground/50"}),u.jsx("span",{className:"truncate text-foreground/80",children:T.name})]},T.name))}),u.jsx(Jg,{label:"Runs",collapsible:!0,children:u.jsxs($h,{isSelected:h===fg,onClick:x,children:[u.jsx(tc,{className:"size-3.5 text-muted-foreground/50"}),u.jsx("span",{className:"text-foreground/80",children:"All Runs"})]})})]})]}),u.jsx("div",{className:"flex-1 min-w-0",children:h===fg?u.jsx(XGr,{}):w?u.jsx(QGr,{workflow:w,runsPanelOpen:d,onOpenRuns:()=>f(!0),onCloseRuns:()=>f(!1)}):u.jsx("div",{className:"h-full flex items-center justify-center",children:u.jsx("p",{className:"body text-muted-foreground/40",children:"Select a workflow"})})})]})})}function bAe(){return u.jsx(eWr,{})}function tWr(){M3e();const e=ds(f=>f.setAgent),t=ds(f=>f.setCredentials),n=ds(f=>f.reset),r=ds(f=>f.agent?.name||f.bot?.name),s=xs(f=>f.syncWithServer),{apiUrl:o}=wn(),a=ui(),i=bt(f=>f.selectedAgentPath),c=bt(f=>f.agents),l=hS("enable_guided_setup");return b.useEffect(()=>{document.title=r||"ADK Dev Console"},[r]),b.useEffect(()=>{if(!i){n();return}const f=i,p=new AbortController,h=()=>!p.signal.aborted&&bt.getState().selectedAgentPath===f;return(async()=>{try{const[y,E]=await Promise.all([fetch(o("/api/agent"),{signal:p.signal}),fetch(o("/api/config"),{signal:p.signal}),s()]);if(!h())return;if(y.ok){const x=await y.json();if(!h())return;console.log("Agent:",x),e(x,f)}if(E.ok){const x=await E.json();if(!h())return;x?.credentials&&(console.log("Config:",x),t(x.credentials,f))}}catch(y){if(p.signal.aborted)return;console.error("Failed to fetch initial data:",y)}})(),()=>p.abort()},[o,i,e,t,n,s]),a.pathname==="/"||a.pathname==="/signin"||a.pathname.startsWith("/new")&&a.pathname!=="/new/guided-setup"?u.jsx(Lge,{}):c.length===0&&!(l&&a.pathname==="/new/guided-setup")?u.jsx(Lge,{}):u.jsxs(Nit,{children:[u.jsx(Oa,{path:"/new/guided-setup",element:l?u.jsx(eGr,{}):u.jsx(Ait,{to:"/",replace:!0})}),u.jsxs(Oa,{path:"/",element:u.jsx(ktn,{}),children:[u.jsx(Oa,{path:"agent-map",element:u.jsx(_ze,{})}),u.jsx(Oa,{path:"chat",element:u.jsx(cWe,{})}),u.jsx(Oa,{path:"actions",element:u.jsx(Wnn,{})}),u.jsx(Oa,{path:"components",element:u.jsx(QVn,{})}),u.jsx(Oa,{path:"workflows",element:u.jsx(bAe,{})}),u.jsx(Oa,{path:"workflows/runs",element:u.jsx(bAe,{})}),u.jsx(Oa,{path:"traces",element:u.jsx("div",{className:"h-full",children:u.jsx(p9r,{})})}),u.jsx(Oa,{path:"evals",element:u.jsx(LVr,{})}),u.jsx(Oa,{path:"conversations",element:u.jsx(GGn,{})}),u.jsx(Oa,{path:"tables",element:u.jsx($Hr,{})}),u.jsx(Oa,{path:"files",element:u.jsx(QHr,{})}),u.jsx(Oa,{path:"search",element:u.jsx(UGr,{})}),u.jsx(Oa,{path:"knowledge",element:u.jsx(Ccr,{})}),u.jsx(Oa,{path:"triggers",element:u.jsx(w9r,{})}),u.jsx(Oa,{path:"integrations",element:u.jsx(Qlr,{})}),u.jsx(Oa,{path:"logs",element:u.jsx(i8r,{})}),u.jsx(Oa,{path:"settings",element:u.jsx(P8r,{})})]})]})}function nWr(){window.__HOST_REACT__=sd,window.__HOST_REACT_JSX_RUNTIME__=Vot,window.__HOST_REACT_DOM__=Oat,window.__HOST_REACT_DOM_CLIENT__=Xot}const rWr=new Eat({defaultOptions:{queries:{staleTime:1e3*60*5,retry:1}}});nWr();EAe.createRoot(document.getElementById("root")).render(u.jsx(pt.StrictMode,{children:u.jsx(Hit,{attribute:"class",defaultTheme:"dark",enableSystem:!1,children:u.jsx(wat,{client:rWr,children:u.jsx($it,{children:u.jsx(gkt,{children:u.jsx(ilt,{children:u.jsx(tWr,{})})})})})})}));export{pt as W,c5 as _,j5e as a,B5e as b,s0e as c,IWt as d,U5 as f,kI as h,b as r,Gy as s,GUt as w,v4e as z};
1837
- //# sourceMappingURL=index-CSTz-oTK.js.map
1837
+ //# sourceMappingURL=index-B3b7PPgV.js.map