@sentry/junior-dashboard 0.162.0 → 0.163.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.js CHANGED
@@ -94,7 +94,7 @@ status ${t.status}`:t.type==="structured_event"?[t.presentation.title,t.presenta
94
94
  `)}var wi=C(E(),1),rge={query:"",normalizedQuery:"",active:!1},zO=(0,fC.createContext)(rge);function YO({children:e,query:t}){let n=t.trim().toLowerCase();return(0,wi.jsx)(zO.Provider,{value:{query:t,normalizedQuery:n,active:n.length>0},children:e})}function vn(){return(0,fC.useContext)(zO)}function Me({text:e}){let{normalizedQuery:t,active:n}=vn();if(!n||!e)return(0,wi.jsx)(wi.Fragment,{children:e});let o=e.toLowerCase();if(!o.includes(t))return(0,wi.jsx)(wi.Fragment,{children:e});let a=[],r=0,i=o.indexOf(t),A=0;for(;i!==-1;)i>r&&a.push(e.slice(r,i)),a.push((0,wi.jsx)("mark",{className:"rounded-[2px] bg-amber-400/20 px-0.5 text-inherit not-italic",children:e.slice(i,i+t.length)},A++)),r=i+t.length,i=o.indexOf(t,r);return r<e.length&&a.push(e.slice(r)),(0,wi.jsx)(wi.Fragment,{children:a})}function KO(e,t){if(!t||!e)return[];let n=e.toLowerCase(),o=[],a=n.indexOf(t);for(;a!==-1;)o.push({end:a+t.length,properties:{class:"search-match"},start:a,tagName:"mark"}),a=n.indexOf(t,a+t.length);return o}function J8(e,t){if(!t)return!0;if(e.kind==="message")return Xo(e.message.eventType,t)||Xo(Vo(e.message),t);if(e.kind==="failure")return Xo(e.outcome==="delivery_failed"?"message delivery failed":"agent response failed error",t);if(e.kind==="tool")return[e.part.name,e.part.status,Zo(e.part.input),Zo(e.part.output)].some(n=>Xo(n,t));if(e.kind==="reasoning")return Xo(e.part.redacted?"reasoning redacted":e.part.text,t);if(e.kind==="subagent")return Xo(e.part.subagentKind,t)||Xo(e.part.status,t);if(e.kind==="structured_event"){let n=e.part.presentation;return[n.title,n.preview,...(n.details??[]).flatMap(o=>[o.title,o.description,o.content,...o.metadata??[]])].some(o=>Xo(o,t))}if(e.kind==="attachments_delivered")return e.part.attachments.some(n=>Xo(n.filename,t)||Xo(n.contentType,t));if(e.kind==="context"){let n=e.part.event;return n.type==="handoff"?["model handoff",n.modelProfile,n.modelId,n.reasoningLevel,n.summary].some(o=>Xo(o,t)):["context compacted",n.summary].some(o=>Xo(o,t))}return!1}function Xo(e,t){return e?e.toLowerCase().includes(t):!1}var al=C(E(),1);function Qs(e){let t=vn(),n=t.active?t.normalizedQuery:void 0,o=ze({queryKey:["highlight",e.language,e.code,n],queryFn:async()=>{let a=n?KO(e.code,n):[];return await bO(e.code,{decorations:a.length?a:void 0,lang:e.language,theme:"github-dark"})},staleTime:1/0});return o.data?(0,al.jsx)(Age,{html:o.data}):(0,al.jsx)(ige,{children:e.code})}function ige(e){return(0,al.jsx)("pre",{className:_("m-0 min-w-0 whitespace-pre-wrap break-words bg-transparent p-0 text-dashboard-text",e.variant==="prose"?"font-display text-base leading-7":"font-mono text-sm leading-relaxed"),children:(0,al.jsx)("code",{children:e.children})})}function Age(e){return(0,al.jsx)("div",{className:_("min-w-0 overflow-hidden [&_.line]:block [&_.line]:max-w-full [&_.line]:whitespace-pre-wrap [&_.line]:break-words [&_.line]:[overflow-wrap:anywhere] [&_code]:block [&_code]:max-w-full [&_code]:whitespace-normal [&_code]:break-words [&_code]:[overflow-wrap:anywhere] [&_pre]:!m-0 [&_pre]:!max-w-full [&_pre]:!overflow-hidden [&_pre]:!bg-transparent [&_pre]:!p-0 [&_pre]:whitespace-normal [&_pre]:break-words [&_pre]:[overflow-wrap:anywhere] [&_span]:whitespace-pre-wrap [&_span]:break-words [&_span]:[overflow-wrap:anywhere] [&_mark.search-match]:bg-amber-400/20 [&_mark.search-match]:rounded-[2px] [&_mark.search-match]:text-inherit [&_mark.search-match]:not-italic",e.variant==="prose"?"[&_pre]:font-display [&_pre]:text-base [&_pre]:leading-7":"[&_pre]:font-mono [&_pre]:text-sm [&_pre]:leading-relaxed"),dangerouslySetInnerHTML:{__html:e.html}})}var WO="font-medium text-cyan-100 underline decoration-cyan-300/35 underline-offset-2 transition-colors hover:text-dashboard-text hover:decoration-white";function ZO(e){let t=gge(e),n=uge(e,t),o=sge(e,t),a=dge(e,JO([...t,...n])),r=JO([...t,...n,...a]);return[...o,...a,...pge(e,r)].sort((i,A)=>i.start-A.start||i.end-A.end)}function sge(e,t){let n=[],o=0;for(;o<e.length;){let a=cge(e,o,t);if(!a)break;n.push(a),o=a.end}return n}function cge(e,t,n){for(let o=e.indexOf("[",t);o>=0;o=e.indexOf("[",o+1)){if(bC(o,n)||ol(e,o))continue;let a=e.indexOf("]",o+1);if(a<0)return;if(e[a+1]!=="(")continue;let r=e.slice(o+1,a);if(!VO(r))continue;let i=W8(e,a+2);if(!i)continue;let A=hge(i.href);if(A)return{end:i.end,href:A,label:r,start:o}}}function uge(e,t){let n=[];for(let o=e.indexOf("[");o>=0;o=e.indexOf("[",o+1)){if(bC(o,t)||ol(e,o))continue;let a=e.indexOf("]",o+1);if(a<0||e[a+1]!=="(")continue;let r=e.slice(o+1,a);if(!VO(r))continue;let i=W8(e,a+2);i&&n.push({start:o,end:i.end})}return n}function VO(e){return!!e&&!e.includes(`
95
95
  `)&&!e.includes("[")}function W8(e,t){let n=0;for(let o=t;o<e.length;o+=1){let a=e[o];if(a==="\\"){o+=1;continue}if(a==="("){n+=1;continue}if(a!==")")continue;if(n>0){n-=1;continue}let r=e.slice(t,o);return r?{end:o+1,href:r}:void 0}}function dge(e,t){let n=[],o=/<(https?:\/\/[^<>\s]+|mailto:[^<>\s]+)>/gi,a;for(;a=o.exec(e);){if(bC(a.index,t)||ol(e,a.index))continue;let r=Z8(a[1]??"");r&&n.push({end:a.index+a[0].length,href:r,label:r,start:a.index})}return n}function lge(e,t,n){let o=/(https?:\/\/[^\s<>"'*]+|mailto:[^\s<>"'*]+)/gi;o.lastIndex=t;let a;for(;a=o.exec(e);){if(bC(a.index,n))continue;let r=yge(a[0]),i=Z8(r);if(i)return{end:a.index+r.length,href:i,label:i,start:a.index}}}function pge(e,t){let n=[],o=0;for(;o<e.length;){let a=lge(e,o,t);if(!a)break;n.push(a),o=a.end}return n}function gge(e){return[...mge(e),...bge(e)].filter(t=>t.end>t.start).sort((t,n)=>t.start-n.start||t.end-n.end)}function mge(e){let t=[];for(let n=0;n<e.length;n+=1){if(e[n]!=="`"||ol(e,n))continue;let o=XO(e,n,"`"),a=fge(e,n+o,o);if(a<0){n+=o-1;continue}t.push({start:n,end:a+o}),n=a+o-1}return t}function fge(e,t,n){for(let o=t;o<e.length;o+=1){if(e[o]!=="`"||ol(e,o))continue;let a=XO(e,o,"`");if(a===n)return o;o+=a-1}return-1}function bge(e){let t=[];for(let n=e.indexOf("[");n>=0;n=e.indexOf("[",n+1)){if(!ol(e,n))continue;let o=e.indexOf("]",n+1);if(o<0||e[o+1]!=="(")continue;let a=W8(e,o+2);a&&t.push({start:n,end:a.end})}return t}function bC(e,t){for(let n of t){if(e<n.start)return!1;if(e>=n.start&&e<n.end)return!0}return!1}function ol(e,t){let n=0;for(let o=t-1;o>=0&&e[o]==="\\";o-=1)n+=1;return n%2===1}function XO(e,t,n){let o=0;for(let a=t;a<e.length&&e[a]===n;a+=1)o+=1;return o}function hge(e){let t=Bge(e);return t?Z8(t):void 0}function Bge(e){let t=e.trim(),o=/^(<[^>\n]+>|[^\s]+)(?:\s+(?:"[^"]*"|'[^']*'|\([^)]*\)))?$/.exec(t)?.[1];if(o)return o.startsWith("<")&&o.endsWith(">")?o.slice(1,-1):o}function Z8(e){let t=e.trim(),n=[...t].some(o=>{let a=o.charCodeAt(0);return a<32||a===127});if(!(!t||n||/\s/.test(t)))try{let o=new URL(t);return o.protocol==="http:"||o.protocol==="https:"||o.protocol==="mailto:"?t:void 0}catch{return}}function yge(e){let t=e;for(;Cge(t);)t=t.slice(0,-1);return t}function Cge(e){let t=e.at(-1);return t?/[.,;:!?]/.test(t)?!0:t===")"&&wge(e):!1}function wge(e){let t=0;for(let n of e)n==="("&&(t+=1),n===")"&&(t-=1);return t<0}function JO(e){let t=e.filter(o=>o.end>o.start).sort((o,a)=>o.start-a.start||o.end-a.end),n=[];for(let o of t){let a=n.at(-1);if(!a||o.start>a.end){n.push({...o});continue}a.end=Math.max(a.end,o.end)}return n}var mt=C(E(),1);function Om(e){let t=kge(e.text);return t.length===0?null:(0,mt.jsx)("div",{className:_("min-w-0 break-words text-dashboard-text [overflow-wrap:anywhere]",e.compact?"font-sans text-sm leading-6":"font-sans text-sm leading-6 md:leading-7"),children:(0,mt.jsx)("div",{className:"grid min-w-0 gap-2",children:t.map((n,o)=>(0,mt.jsx)(Ege,{block:n},o))})})}function Ege(e){switch(e.block.type){case"heading":{let t=_("m-0 min-w-0 font-semibold tracking-[-0.01em] text-dashboard-text",e.block.level<=2?"text-[1.05em]":"text-[1em]"),n=e2(e.block.text);switch(e.block.level){case 1:return(0,mt.jsx)("h1",{className:t,children:n});case 2:return(0,mt.jsx)("h2",{className:t,children:n});case 3:return(0,mt.jsx)("h3",{className:t,children:n});case 4:return(0,mt.jsx)("h4",{className:t,children:n});case 5:return(0,mt.jsx)("h5",{className:t,children:n});default:return(0,mt.jsx)("h6",{className:t,children:n})}}case"list":{let t=e.block.ordered?"ol":"ul";return(0,mt.jsx)(t,{className:_("m-0 grid min-w-0 list-outside gap-1 pl-5 text-dashboard-text",e.block.ordered?"list-decimal":"list-disc"),children:e.block.items.map((n,o)=>(0,mt.jsx)("li",{className:"min-w-0 pl-1",children:e2(n)},o))})}case"paragraph":return(0,mt.jsx)("p",{className:"m-0 min-w-0 whitespace-normal text-dashboard-text",children:e.block.lines.map((t,n)=>(0,mt.jsxs)("span",{children:[n>0?(0,mt.jsx)("br",{}):null,e2(t)]},n))})}}function kge(e){let t=e.replace(/\r\n?/g,`
96
96
  `).replace(/^\n+|\n+$/g,"");if(!t)return[];let n=[];for(let o of t.split(/\n{2,}/)){let a=o.split(`
97
- `),r=0;for(;r<a.length;){let i=a[r]??"",A=eq(i);if(A){n.push(A),r+=1;continue}let s=X8(i),c=V8(i);if(s||c){let l=[];for(;r<a.length&&(s?X8(a[r]??""):V8(a[r]??""));)l.push((a[r]??"").replace(s?/^\s*\d+\.\s+/:/^\s*[-*+]\s+/,"")),r+=1;n.push({items:l,ordered:s,type:"list"});continue}let d=[];for(;r<a.length&&!eq(a[r]??"")&&!X8(a[r]??"")&&!V8(a[r]??"");)d.push(a[r]??""),r+=1;n.push({lines:d,type:"paragraph"})}}return n}function eq(e){let t=/^(#{1,6})\s+(.+)$/.exec(e);if(t)return{level:t[1].length,text:t[2].trimEnd(),type:"heading"}}function V8(e){return/^\s*[-*+]\s+\S/.test(e)}function X8(e){return/^\s*\d+\.\s+\S/.test(e)}function e2(e){return Qge(e,0)}function Qge(e,t){if(!e)return[];let n=[],o=/(`+)([^`]+?)\1/g,a=0,r,i=0;for(;r=o.exec(e);)r.index>a&&n.push(...tq(e.slice(a,r.index),`${t}-${i++}`)),n.push((0,mt.jsx)("code",{className:"rounded-[0.25rem] bg-white/[0.08] px-1 py-0.5 font-mono text-[0.9em] text-cyan-50",children:(0,mt.jsx)(Me,{text:r[2]??""})},`code-${t}-${i++}`)),a=r.index+r[0].length;return a<e.length&&n.push(...tq(e.slice(a),`${t}-${i}`)),n}function tq(e,t){if(!e)return[];let n=[],o=/(\*\*|__)(.+?)\1|\*([^*]+?)\*/g,a=0,r,i=0;for(;r=o.exec(e);)r.index>a&&n.push(...hC(e.slice(a,r.index),`${t}-t-${i++}`)),n.push(r[1]?(0,mt.jsx)("strong",{className:"font-semibold text-dashboard-text",children:hC(r[2]??"",`${t}-bc-${i}`)},`${t}-b-${i++}`):(0,mt.jsx)("em",{className:"italic text-dashboard-text",children:hC(r[3]??"",`${t}-ic-${i}`)},`${t}-i-${i++}`)),a=r.index+r[0].length;return a<e.length&&n.push(...hC(e.slice(a),`${t}-t-${i}`)),n}function hC(e,t){if(!e)return[];let n=ZO(e),o=[],a=0,r=0;for(let i of n)i.start>a&&o.push((0,mt.jsx)(Me,{text:e.slice(a,i.start)},`${t}-s-${r++}`)),o.push((0,mt.jsx)(_ge,{href:i.href,children:(0,mt.jsx)(Ige,{href:i.href,label:i.label})},`${t}-a-${i.start}`)),a=i.end;return a<e.length&&o.push((0,mt.jsx)(Me,{text:e.slice(a)},`${t}-s-${r}`)),o}function Ige(e){let t=vn(),n=t.active&&e.href.toLowerCase().includes(t.normalizedQuery),o=e.label.toLowerCase().includes(t.normalizedQuery);return n&&!o?(0,mt.jsx)("mark",{className:"rounded-[2px] bg-amber-400/20 px-0.5 text-inherit not-italic",title:`Matched URL: ${e.href}`,children:e.label}):(0,mt.jsx)(Me,{text:e.label})}function _ge(e){let t=/^https?:/i.test(e.href);return(0,mt.jsx)("a",{className:WO,href:e.href,rel:t?"noreferrer":void 0,target:t?"_blank":void 0,children:e.children})}var BC=C(E(),1);function er(e){let t=Hc(e.role??""),n=RO(e.text);return(0,BC.jsx)("div",{className:"grid min-w-0 gap-2",children:n.map((o,a)=>o.language==="markdown"&&!o.fenced?(0,BC.jsx)(Om,{compact:t==="assistant"||t==="user",text:o.code},a):(0,BC.jsx)(Qs,{code:o.code,language:o.language},a))})}var xt=C(E(),1);function aq(e){let t=e.record?.id;if((0,nq.useEffect)(()=>{t&&e.action.reset()},[t]),!e.record)return null;let{record:n}=e,o=qm(n,"Type"),a=qm(n,"Learned"),r=qm(n,"Remembered"),i=qm(n,"Source"),A=qm(n,"Visibility"),s=A==="Public",c=a==="Automatic"?`Junior learned this from a ${i} conversation on ${zm(r)}.`:a==="Explicit"?s?`Someone asked Junior to remember this on ${zm(r)}.`:`You asked Junior to remember this on ${zm(r)}.`:`Junior recorded this on ${zm(r)}.`,d=s?`It is stored as workspace ${o.toLowerCase()} for future channels.`:`It is stored as a ${o.toLowerCase()} for future conversations.`,l=(n.metadata??[]).filter(m=>!["Learned","Source","Memory ID"].includes(m.label)),g=n.actions?.find(m=>m.tone==="danger"),p="memory-details-drawer-title";return(0,xt.jsx)(ks,{closeLabel:"Close memory details",dismissLabel:"Dismiss memory details",header:(0,xt.jsxs)(xt.Fragment,{children:[(0,xt.jsx)("h2",{className:"m-0 font-display text-lg font-medium tracking-normal text-dashboard-text",id:p,children:"What Junior remembers"}),(0,xt.jsxs)("div",{className:"mt-1 break-words font-mono text-xs leading-snug text-dashboard-text-muted",children:[o," \xB7 ",A," \xB7 ",zm(r)]})]}),onClose:e.onClose,openKey:n.id,titleId:p,children:(0,xt.jsxs)("section",{className:"grid gap-5",children:[(0,xt.jsxs)("div",{children:[(0,xt.jsx)("div",{className:"mb-2 font-mono text-xs uppercase tracking-[0.12em] text-dashboard-text-muted",children:"Memory"}),(0,xt.jsx)(er,{text:n.title}),n.description?(0,xt.jsx)("div",{className:"mt-3",children:(0,xt.jsx)(er,{text:n.description})}):null]}),(0,xt.jsxs)("div",{className:"flex items-start gap-3 rounded border border-cyan-300/12 bg-cyan-300/[0.035] p-3",children:[(0,xt.jsx)(dA,{"aria-hidden":"true",className:"mt-0.5 shrink-0 text-cyan-200/70",size:15}),(0,xt.jsxs)("div",{children:[(0,xt.jsx)("div",{className:"font-mono text-xs uppercase tracking-[0.12em] text-cyan-200/65",children:"Why Junior remembers this"}),(0,xt.jsxs)("div",{className:"mt-1 font-mono text-xs leading-relaxed text-dashboard-text",children:[c," ",d]})]})]}),l.length?(0,xt.jsx)(mC,{children:l.map(m=>(0,xt.jsx)(Yc,{label:m.label,valueClassName:"font-mono",children:m.value},m.label))}):null,g?(0,xt.jsxs)("button",{className:"inline-flex w-fit cursor-pointer items-center gap-2 rounded border border-rose-300/15 bg-rose-300/[0.035] px-3 py-2 font-mono text-xs uppercase tracking-[0.08em] text-rose-200/75 transition-colors hover:border-rose-300/30 hover:bg-rose-300/[0.07] hover:text-rose-100",disabled:e.action.isPending,onClick:()=>{g.confirmation&&!window.confirm(g.confirmation)||(e.onClose(),e.onAction({...g,confirmation:void 0}))},type:"button",children:[(0,xt.jsx)(Ir,{"aria-hidden":"true",size:13}),"Forget this memory"]}):s?(0,xt.jsxs)("div",{className:"inline-flex w-fit items-center gap-2 rounded border border-white/[0.08] px-3 py-2 font-mono text-xs uppercase tracking-[0.08em] text-dashboard-text-muted",children:[(0,xt.jsx)(Wn,{"aria-hidden":"true",size:13}),"View only \xB7 public memories can't be deleted"]}):null]})})}function qm(e,t){return e.metadata?.find(n=>n.label===t)?.value??"\u2014"}function zm(e){return e.split(",").slice(0,2).join(",")}var Rr=C(z(),1);var jn=C(E(),1);function Bn(e,t){let n=t?.width??960,o=t?.left??56,a=t?.right??18,r=t?.top??24,i=t?.bottom??36;return{bottom:i,height:e,left:o,plotHeight:e-r-i,plotWidth:n-o-a,right:a,top:r,width:n}}function We(e){return new Date(`${e}T00:00:00.000Z`).toLocaleDateString(void 0,{day:"numeric",month:"short",timeZone:"UTC"})}function oq(e){return[...new Set([0,Math.floor((e-1)/2),e-1])].filter(t=>t>=0)}var rq=11,t2=(0,Rr.createContext)(1),vge="fill-white/50 font-mono leading-none text-dashboard-text-muted";function Ym(e){let{children:t,...n}=e,o=(0,Rr.useContext)(t2);return(0,jn.jsx)("text",{className:vge,fontSize:rq/o,...n,children:t})}function iq(e){return(0,jn.jsx)("span",{className:_("font-mono text-2xs leading-none text-dashboard-text-muted",e.className),style:e.style,children:e.children})}function yn(e){let t=(0,Rr.useRef)(null),[n,o]=(0,Rr.useState)(1);return(0,Rr.useLayoutEffect)(()=>{let a=t.current;if(!a)return;let r=()=>{let A=a.getScreenCTM(),s=A?Math.hypot(A.a,A.b):1;o(s>0?s:1)};r();let i=new ResizeObserver(r);return i.observe(a),()=>i.disconnect()},[]),(0,jn.jsx)(t2,{value:n,children:(0,jn.jsx)("svg",{"aria-label":e["aria-label"],className:_("block h-auto w-full",e.className),ref:t,role:"img",viewBox:`0 0 ${e.layout.width} ${e.layout.height}`,children:e.children})})}function Pn(e){let t=e.format??(n=>String(Math.round(n)));return[0,.5,1].map(n=>{let o=e.layout.top+n*e.layout.plotHeight;return(0,jn.jsxs)("g",{children:[(0,jn.jsx)("line",{stroke:"rgba(255,255,255,0.07)",strokeDasharray:"3 5",x1:e.layout.left,x2:e.layout.width-e.layout.right,y1:o,y2:o}),(0,jn.jsx)(Ym,{textAnchor:"end",x:e.layout.left-8,y:o+3,children:t(e.maximum*(1-n))})]},n)})}function Gn(e){let t=e.formatDate??We;return oq(e.dates.length).map(n=>{let o=e.dates[n];return o?(0,jn.jsx)(Ym,{textAnchor:n===0?"start":n===e.dates.length-1?"end":"middle",x:e.xPosition(n),y:e.layout.height-8,children:t(o)},o):null})}function Aq(e){let t=e.formatLabel??(n=>n);return oq(e.categories.length).map(n=>{let o=e.categories[n];return o?(0,jn.jsx)(Ym,{textAnchor:"middle",x:e.xPosition(n),y:e.layout.height-8,children:t(o.label)},o.id):null})}function tr(e){return e.length===0?0:e.reduce((t,n)=>t+n,0)/e.length}var xge="fill-white font-mono leading-none",Dge="rgba(9, 12, 14, 0.92)";function nr(e){let t=(0,Rr.useContext)(t2);if(!(e.average>0)||!(e.maximum>0))return null;let n=e.unit??"day",o=e.format(e.average).trim();if(!o||/^\$?0(?:\.0+)?(?:ms)?$/i.test(o))return null;let a=e.layout.top+e.layout.plotHeight-e.average/e.maximum*e.layout.plotHeight,r=e.layout.left,i=e.layout.width-e.layout.right,A=`${o} / ${n}`,s=rq/t,c=Math.max(52,A.length*s*.68),d=5,g=s+3*2,p=c+d*2,m=i-p,B=a-e.layout.top>g+4?a-g-3:a+4,f=B+g/2+s*.35,b=Math.max(r,m-6);return(0,jn.jsxs)("g",{"aria-label":`average ${A}`,pointerEvents:"none",children:[(0,jn.jsx)("line",{stroke:e.stroke??"rgba(255,255,255,0.55)",strokeDasharray:"4 4",strokeOpacity:.85,strokeWidth:1.25,x1:r,x2:b,y1:a,y2:a}),(0,jn.jsx)("rect",{fill:Dge,height:g,rx:3,width:p,x:m,y:B}),(0,jn.jsx)("text",{className:xge,fill:"#ffffff",fontSize:s,textAnchor:"middle",x:m+p/2,y:f,children:A})]})}function Cn(e){return(0,jn.jsx)("div",{className:"grid grid-cols-[auto_auto] gap-x-4 gap-y-0.5",children:e.rows.flatMap(([t,n],o)=>[(0,jn.jsx)("span",{className:"text-dashboard-text-muted",children:t},`${o}-label`),(0,jn.jsx)("span",{className:"text-right text-dashboard-text",children:n},`${o}-value`)])})}var Ei=C(E(),1);function ma(e){return(0,Ei.jsx)("ul",{"aria-label":e.ariaLabel,className:_("m-0 flex list-none flex-wrap gap-x-4 gap-y-1 p-0 font-mono text-2xs text-dashboard-text-muted",!e.inline&&"mt-4"),children:e.items.map(t=>(0,Ei.jsxs)("li",{className:"flex items-center whitespace-nowrap",children:[(0,Ei.jsx)("i",{"aria-hidden":"true",className:"mr-1.5 block size-2 shrink-0 rounded-full",style:{backgroundColor:t.color}}),(0,Ei.jsxs)("span",{children:[t.label,t.value!==void 0?(0,Ei.jsxs)(Ei.Fragment,{children:[" ",(0,Ei.jsx)("span",{"aria-hidden":"true",children:"\xB7"})," ",t.value]}):null]})]},t.key))})}var sn=C(z(),1);var Fge=Object.defineProperty,rl=(e,t)=>Fge(e,"name",{value:t,configurable:!0}),sq=!!(typeof window<"u"&&window.document&&window.document.createElement);function Ra(e,t,{checkForDefaultPrevented:n=!0}={}){return rl(function(a){if(e?.(a),n===!1||!a||!a.defaultPrevented)return t?.(a)},"handleEvent")}rl(Ra,"composeEventHandlers");function Sge(e){if(!sq)throw new Error("Cannot access window outside of the DOM");return e?.ownerDocument?.defaultView??window}rl(Sge,"getOwnerWindow");function n2(e){if(!sq)throw new Error("Cannot access document outside of the DOM");return e?.ownerDocument??document}rl(n2,"getOwnerDocument");function cq(e,t=!1){let{activeElement:n}=n2(e);if(!n?.nodeName)return null;if(uq(n)&&n.contentDocument)return cq(n.contentDocument.body,t);if(t){let o=n.getAttribute("aria-activedescendant");if(o){let a=n2(n).getElementById(o);if(a)return a}}return n}rl(cq,"getActiveElement");function uq(e){return e.tagName==="IFRAME"}rl(uq,"isFrame");var or=C(z(),1),a2=C(E(),1),Lge=Object.defineProperty,ar=(e,t)=>Lge(e,"name",{value:t,configurable:!0});function Rge(e,t){let n=or.createContext(t);n.displayName=e+"Context";let o=ar(r=>{let{children:i,...A}=r,s=or.useMemo(()=>A,Object.values(A));return(0,a2.jsx)(n.Provider,{value:s,children:i})},"Provider");o.displayName=e+"Provider";function a(r,i={}){let{optional:A=!1}=i,s=or.useContext(n);if(s)return s;if(t!==void 0)return t;if(!A)throw new Error(`\`${r}\` must be used within \`${e}\``)}return ar(a,"useContext"),[o,a]}ar(Rge,"createContext");function Km(e,t=[]){let n=[];function o(r,i){let A=or.createContext(i);A.displayName=r+"Context";let s=n.length;n=[...n,i];let c=ar(l=>{let{scope:g,children:p,...m}=l,h=g?.[e]?.[s]||A,B=or.useMemo(()=>m,Object.values(m));return(0,a2.jsx)(h.Provider,{value:B,children:p})},"Provider");c.displayName=r+"Provider";function d(l,g,p={}){let{optional:m=!1}=p,h=g?.[e]?.[s]||A,B=or.useContext(h);if(B)return B;if(i!==void 0)return i;if(!m)throw new Error(`\`${l}\` must be used within \`${r}\``)}return ar(d,"useContext"),[c,d]}ar(o,"createContext");let a=ar(()=>{let r=n.map(i=>or.createContext(i));return ar(function(A){let s=A?.[e]||r;return or.useMemo(()=>({[`__scope${e}`]:{...A,[e]:s}}),[A,s])},"useScope")},"createScope");return a.scopeName=e,[o,dq(a,...t)]}ar(Km,"createContextScope");function dq(...e){let t=e[0];if(e.length===1)return t;let n=ar(()=>{let o=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return ar(function(r){let i=o.reduce((A,{useScope:s,scopeName:c})=>{let l=s(r)[`__scope${c}`];return{...A,...l}},{});return or.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])},"useComposedScopes")},"createScope");return n.scopeName=t.scopeName,n}ar(dq,"composeContextScopes");var rr=C(z(),1);var yC=!1;var lq=C(z(),1),Na=globalThis?.document?lq.useLayoutEffect:()=>{};var Nr=C(z(),1);var il=C(z(),1),Nge=Object.defineProperty,$ge=(e,t)=>Nge(e,"name",{value:t,configurable:!0}),pq=il[" useEffectEvent ".trim().toString()],gq=il[" useInsertionEffect ".trim().toString()];function o2(e){if(typeof pq=="function")return pq(e);let t=il.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof gq=="function"?gq(()=>{t.current=e}):Na(()=>{t.current=e}),il.useMemo(()=>((...n)=>t.current?.(...n)),[])}$ge(o2,"useEffectEvent");var Mge=Object.defineProperty,Jm=(e,t)=>Mge(e,"name",{value:t,configurable:!0}),jge=rr[" useInsertionEffect ".trim().toString()]||Na;function r2({prop:e,defaultProp:t,onChange:n=Jm(()=>{},"onChange"),caller:o}){let[a,r,i]=fq({defaultProp:t,onChange:n}),A=e!==void 0,s=A?e:a;if(yC){let d=rr.useRef(e!==void 0);rr.useEffect(()=>{let l=d.current;l!==A&&console.warn(`${o} is changing from ${l?"controlled":"uncontrolled"} to ${A?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=A},[A,o])}let c=rr.useCallback(d=>{if(A){let l=bq(d)?d(e):d;l!==e&&i.current?.(l)}else r(d)},[A,e,r,i]);return[s,c]}Jm(r2,"useControllableState");function fq({defaultProp:e,onChange:t}){let[n,o]=rr.useState(e),a=rr.useRef(n),r=rr.useRef(t);return jge(()=>{r.current=t},[t]),rr.useEffect(()=>{a.current!==n&&(r.current?.(n),a.current=n)},[n,a]),[n,o,r]}Jm(fq,"useUncontrolledState");function bq(e){return typeof e=="function"}Jm(bq,"isFunction");var mq=Symbol("RADIX:SYNC_STATE");function Pge(e,t,n,o){let{prop:a,defaultProp:r,onChange:i,caller:A}=t,s=a!==void 0,c=o2(i);if(yC){let B=Nr.useRef(a!==void 0);Nr.useEffect(()=>{let f=B.current;f!==s&&console.warn(`${A} is changing from ${f?"controlled":"uncontrolled"} to ${s?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),B.current=s},[s,A])}let d=[{...n,state:r}];o&&d.push(o);let[l,g]=Nr.useReducer((B,f)=>{if(f.type===mq)return{...B,state:f.state};let b=e(B,f);return s&&!Object.is(b.state,B.state)&&c(b.state),b},...d),p=l.state,m=Nr.useRef(p);Nr.useEffect(()=>{m.current!==p&&(m.current=p,s||c(p))},[p,m,s]);let h=Nr.useMemo(()=>a!==void 0?{...l,state:a}:l,[l,a]);return Nr.useEffect(()=>{s&&!Object.is(a,l.state)&&g({type:mq,state:a})},[a,l.state,s]),[h,g]}Jm(Pge,"useControllableStateReducer");var hq=C(z(),1),Gge=Object.defineProperty,A2=(e,t)=>Gge(e,"name",{value:t,configurable:!0});function i2(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}A2(i2,"setRef");function Bq(...e){return t=>{let n=!1,o=e.map(a=>{let r=i2(a,t);return!n&&typeof r=="function"&&(n=!0),r});if(n)return()=>{for(let a=0;a<o.length;a++){let r=o[a];typeof r=="function"?r():i2(e[a],null)}}}}A2(Bq,"composeRefs");function ki(...e){return hq.useCallback(Bq(...e),e)}A2(ki,"useComposedRefs");var fa=C(z(),1);var wq=["top","right","bottom","left"];var Qi=Math.min,$r=Math.max,Zm=Math.round,Vm=Math.floor,Ii=e=>({x:e,y:e}),Hge={left:"right",right:"left",bottom:"top",top:"bottom"};function s2(e,t,n){return $r(e,Qi(t,n))}function _i(e,t){return typeof e=="function"?e(t):e}function hA(e){return e.split("-")[0]}function Kc(e){return e.split("-")[1]}function wC(e){return e==="x"?"y":"x"}function EC(e){return e==="y"?"height":"width"}function Mr(e){let t=e[0];return t==="t"||t==="b"?"y":"x"}function kC(e){return wC(Mr(e))}function Eq(e,t,n){n===void 0&&(n=!1);let o=Kc(e),a=kC(e),r=EC(a),i=a==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[r]>t.floating[r]&&(i=Wm(i)),[i,Wm(i)]}function kq(e){let t=Wm(e);return[CC(e),t,CC(t)]}function CC(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}var yq=["left","right"],Cq=["right","left"],Tge=["top","bottom"],Uge=["bottom","top"];function Oge(e,t,n){switch(e){case"top":case"bottom":return n?t?Cq:yq:t?yq:Cq;case"left":case"right":return t?Tge:Uge;default:return[]}}function Qq(e,t,n,o){let a=Kc(e),r=Oge(hA(e),n==="start",o);return a&&(r=r.map(i=>i+"-"+a),t&&(r=r.concat(r.map(CC)))),r}function Wm(e){let t=hA(e);return Hge[t]+e.slice(t.length)}function qge(e){var t,n,o,a;return{top:(t=e.top)!=null?t:0,right:(n=e.right)!=null?n:0,bottom:(o=e.bottom)!=null?o:0,left:(a=e.left)!=null?a:0}}function c2(e){return typeof e!="number"?qge(e):{top:e,right:e,bottom:e,left:e}}function Jc(e){let{x:t,y:n,width:o,height:a}=e;return{width:o,height:a,top:n,left:t,right:t+o,bottom:n+a,x:t,y:n}}function Iq(e,t,n){let{reference:o,floating:a}=e,r=Mr(t),i=kC(t),A=EC(i),s=hA(t),c=r==="y",d=o.x+o.width/2-a.width/2,l=o.y+o.height/2-a.height/2,g=o[A]/2-a[A]/2,p;switch(s){case"top":p={x:d,y:o.y-a.height};break;case"bottom":p={x:d,y:o.y+o.height};break;case"right":p={x:o.x+o.width,y:l};break;case"left":p={x:o.x-a.width,y:l};break;default:p={x:o.x,y:o.y}}let m=Kc(t);return m&&(p[i]+=g*(m==="end"?1:-1)*(n&&c?-1:1)),p}async function xq(e,t){var n;t===void 0&&(t={});let{x:o,y:a,platform:r,rects:i,elements:A,strategy:s}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:l="floating",altBoundary:g=!1,padding:p=0}=_i(t,e),m=c2(p),B=A[g?l==="floating"?"reference":"floating":l],f=Jc(await r.getClippingRect({element:(n=await(r.isElement==null?void 0:r.isElement(B)))==null||n?B:B.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(A.floating)),boundary:c,rootBoundary:d,strategy:s})),b=l==="floating"?{x:o,y:a,width:i.floating.width,height:i.floating.height}:i.reference,y=await(r.getOffsetParent==null?void 0:r.getOffsetParent(A.floating)),w=await(r.isElement==null?void 0:r.isElement(y))&&await(r.getScale==null?void 0:r.getScale(y))||{x:1,y:1},Q=Jc(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:A,rect:b,offsetParent:y,strategy:s}):b);return{top:(f.top-Q.top+m.top)/w.y,bottom:(Q.bottom-f.bottom+m.bottom)/w.y,left:(f.left-Q.left+m.left)/w.x,right:(Q.right-f.right+m.right)/w.x}}var zge=50,Dq=async(e,t,n)=>{let{placement:o="bottom",strategy:a="absolute",middleware:r=[],platform:i}=n,A=i.detectOverflow?i:{...i,detectOverflow:xq},s=await(i.isRTL==null?void 0:i.isRTL(t)),c=await i.getElementRects({reference:e,floating:t,strategy:a}),{x:d,y:l}=Iq(c,o,s),g=o,p=0,m={};for(let h=0;h<r.length;h++){let B=r[h];if(!B)continue;let{name:f,fn:b}=B,{x:y,y:w,data:Q,reset:R}=await b({x:d,y:l,initialPlacement:o,placement:g,strategy:a,middlewareData:m,rects:c,platform:A,elements:{reference:e,floating:t}});d=y??d,l=w??l,m[f]={...m[f],...Q},R&&p<zge&&(p++,typeof R=="object"&&(R.placement&&(g=R.placement),R.rects&&(c=R.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:a}):R.rects),{x:d,y:l}=Iq(c,g,s)),h=-1)}return{x:d,y:l,placement:g,strategy:a,middlewareData:m}},Fq=e=>({name:"arrow",options:e,async fn(t){let{x:n,y:o,placement:a,rects:r,platform:i,elements:A,middlewareData:s}=t,{element:c,padding:d=0}=_i(e,t)||{};if(c==null)return{};let l=c2(d),g={x:n,y:o},p=kC(a),m=EC(p),h=await i.getDimensions(c),B=p==="y",f=B?"top":"left",b=B?"bottom":"right",y=B?"clientHeight":"clientWidth",w=r.reference[m]+r.reference[p]-g[p]-r.floating[m],Q=g[p]-r.reference[p],R=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c)),D=R?R[y]:0;(!D||!await(i.isElement==null?void 0:i.isElement(R)))&&(D=A.floating[y]||r.floating[m]);let F=w/2-Q/2,T=D/2-h[m]/2-1,O=Qi(l[f],T),ue=Qi(l[b],T),oe=D-h[m]-ue,Be=D/2-h[m]/2+F,ge=s2(O,Be,oe),ee=!s.arrow&&Kc(a)!=null&&Be!==ge&&r.reference[m]/2-(Be<O?O:ue)-h[m]/2<0,bt=ee?Be<O?Be-O:Be-oe:0;return{[p]:g[p]+bt,data:{[p]:ge,centerOffset:Be-ge-bt,...ee&&{alignmentOffset:bt}},reset:ee}}});var Sq=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,o;let{placement:a,middlewareData:r,rects:i,initialPlacement:A,platform:s,elements:c}=t,{mainAxis:d=!0,crossAxis:l=!0,fallbackPlacements:g,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:h=!0,...B}=_i(e,t);if((n=r.arrow)!=null&&n.alignmentOffset)return{};let f=hA(a),b=Mr(A),y=hA(A)===A,w=await(s.isRTL==null?void 0:s.isRTL(c.floating)),Q=g||(y||!h?[Wm(A)]:kq(A)),R=m!=="none";!g&&R&&Q.push(...Qq(A,h,m,w));let D=[A,...Q],F=await s.detectOverflow(t,B),T=[],O=((o=r.flip)==null?void 0:o.overflows)||[];if(d&&T.push(F[f]),l){let ge=Eq(a,i,w);T.push(F[ge[0]],F[ge[1]])}if(O=[...O,{placement:a,overflows:T}],!T.every(ge=>ge<=0)){var ue,oe;let ge=(((ue=r.flip)==null?void 0:ue.index)||0)+1,ee=D[ge];if(ee&&(!(l==="alignment"?b!==Mr(ee):!1)||O.every(je=>Mr(je.placement)===b?je.overflows[0]>0:!0)))return{data:{index:ge,overflows:O},reset:{placement:ee}};let bt=(oe=O.filter(Ga=>Ga.overflows[0]<=0).sort((Ga,je)=>Ga.overflows[1]-je.overflows[1])[0])==null?void 0:oe.placement;if(!bt)switch(p){case"bestFit":{var Be;let Ga=(Be=O.filter(je=>{if(R){let pn=Mr(je.placement);return pn===b||pn==="y"}return!0}).map(je=>[je.placement,je.overflows.filter(pn=>pn>0).reduce((pn,Do)=>pn+Do,0)]).sort((je,pn)=>je[1]-pn[1])[0])==null?void 0:Be[0];Ga&&(bt=Ga);break}case"initialPlacement":bt=A;break}if(a!==bt)return{reset:{placement:bt}}}return{}}}};function _q(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function vq(e){return wq.some(t=>e[t]>=0)}var Lq=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){let{rects:n,platform:o}=t,{strategy:a="referenceHidden",...r}=_i(e,t);switch(a){case"referenceHidden":{let i=await o.detectOverflow(t,{...r,elementContext:"reference"}),A=_q(i,n.reference);return{data:{referenceHiddenOffsets:A,referenceHidden:vq(A)}}}case"escaped":{let i=await o.detectOverflow(t,{...r,altBoundary:!0}),A=_q(i,n.floating);return{data:{escapedOffsets:A,escaped:vq(A)}}}default:return{}}}}};var Rq=new Set(["left","top"]);async function Yge(e,t){let{placement:n,platform:o,elements:a}=e,r=await(o.isRTL==null?void 0:o.isRTL(a.floating)),i=hA(n),A=Kc(n),s=Mr(n)==="y",c=Rq.has(i)?-1:1,d=r&&s?-1:1,l=_i(t,e),{mainAxis:g,crossAxis:p,alignmentAxis:m}=typeof l=="number"?{mainAxis:l,crossAxis:0,alignmentAxis:null}:{mainAxis:l.mainAxis||0,crossAxis:l.crossAxis||0,alignmentAxis:l.alignmentAxis};return A&&typeof m=="number"&&(p=A==="end"?m*-1:m),s?{x:p*d,y:g*c}:{x:g*c,y:p*d}}var Nq=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,o;let{x:a,y:r,placement:i,middlewareData:A}=t,s=await Yge(t,e);return i===((n=A.offset)==null?void 0:n.placement)&&(o=A.arrow)!=null&&o.alignmentOffset?{}:{x:a+s.x,y:r+s.y,data:{...s,placement:i}}}}},$q=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){let{x:n,y:o,placement:a,platform:r}=t,{mainAxis:i=!0,crossAxis:A=!1,limiter:s={fn:b=>{let{x:y,y:w}=b;return{x:y,y:w}}},...c}=_i(e,t),d={x:n,y:o},l=await r.detectOverflow(t,c),g=Mr(a),p=wC(g),m=d[p],h=d[g],B=(b,y)=>s2(y+l[b==="y"?"top":"left"],y,y-l[b==="y"?"bottom":"right"]);i&&(m=B(p,m)),A&&(h=B(g,h));let f=s.fn({...t,[p]:m,[g]:h});return{...f,data:{x:f.x-n,y:f.y-o,enabled:{[p]:i,[g]:A}}}}}},Mq=function(e){return e===void 0&&(e={}),{options:e,fn(t){var n,o;let{x:a,y:r,placement:i,rects:A,middlewareData:s}=t,{offset:c=0,mainAxis:d=!0,crossAxis:l=!0}=_i(e,t),g={x:a,y:r},p=Mr(i),m=wC(p),h=g[m],B=g[p],f=_i(c,t),b=typeof f=="number"?{mainAxis:f,crossAxis:0}:{mainAxis:(n=f.mainAxis)!=null?n:0,crossAxis:(o=f.crossAxis)!=null?o:0};if(d){let Q=m==="y"?"height":"width",R=A.reference[m]-A.floating[Q]+b.mainAxis,D=A.reference[m]+A.reference[Q]-b.mainAxis;h<R?h=R:h>D&&(h=D)}if(l){var y,w;let Q=m==="y"?"width":"height",R=Rq.has(hA(i)),D=A.reference[p]-A.floating[Q]+(R&&((y=s.offset)==null?void 0:y[p])||0)+(R?0:b.crossAxis),F=A.reference[p]+A.reference[Q]+(R?0:((w=s.offset)==null?void 0:w[p])||0)-(R?b.crossAxis:0);B<D?B=D:B>F&&(B=F)}return{[m]:h,[p]:B}}}},jq=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){let{placement:n,rects:o,platform:a,elements:r}=t,{apply:i=()=>{},...A}=_i(e,t),s=await a.detectOverflow(t,A),c=hA(n),d=Kc(n),l=Mr(n)==="y",{width:g,height:p}=o.floating,m,h;c==="top"||c==="bottom"?(m=c,h=d===(await(a.isRTL==null?void 0:a.isRTL(r.floating))?"start":"end")?"left":"right"):(h=c,m=d==="end"?"top":"bottom");let B=p-s.top-s.bottom,f=g-s.left-s.right,b=Qi(p-s[m],B),y=Qi(g-s[h],f),w=t.middlewareData.shift,Q=!w,R=b,D=y;w!=null&&w.enabled.x&&(D=f),w!=null&&w.enabled.y&&(R=B),Q&&!d&&(l?D=g-2*$r(s.left,s.right):R=p-2*$r(s.top,s.bottom)),await i({...t,availableWidth:D,availableHeight:R});let F=await a.getDimensions(r.floating);return g!==F.width||p!==F.height?{reset:{rects:!0}}:{}}}};function QC(){return typeof window<"u"}function Vc(e){return Gq(e)?(e.nodeName||"").toLowerCase():"#document"}function $a(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function vi(e){var t;return(t=(Gq(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Gq(e){return QC()?e instanceof Node||e instanceof $a(e).Node:!1}function jr(e){return QC()?e instanceof Element||e instanceof $a(e).Element:!1}function BA(e){return QC()?e instanceof HTMLElement||e instanceof $a(e).HTMLElement:!1}function Pq(e){return!QC()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof $a(e).ShadowRoot}function Xm(e){let{overflow:t,overflowX:n,overflowY:o,display:a}=Pr(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&a!=="inline"&&a!=="contents"}function Hq(e){return/^(table|td|th)$/.test(Vc(e))}function ef(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}var Kge=/transform|translate|scale|rotate|perspective|filter/,Jge=/paint|layout|strict|content/,Wc=e=>!!e&&e!=="none",u2;function IC(e){let t=jr(e)?Pr(e):e;return Wc(t.transform)||Wc(t.translate)||Wc(t.scale)||Wc(t.rotate)||Wc(t.perspective)||!_C()&&(Wc(t.backdropFilter)||Wc(t.filter))||Kge.test(t.willChange||"")||Jge.test(t.contain||"")}function Tq(e){let t=Is(e);for(;BA(t)&&!Al(t);){if(IC(t))return t;if(ef(t))return null;t=Is(t)}return null}function _C(){return u2==null&&(u2=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),u2}function Al(e){return/^(html|body|#document)$/.test(Vc(e))}function Pr(e){return $a(e).getComputedStyle(e)}function tf(e){return jr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Is(e){if(Vc(e)==="html")return e;let t=e.assignedSlot||e.parentNode||Pq(e)&&e.host||vi(e);return Pq(t)?t.host:t}function Uq(e){let t=Is(e);return Al(t)?(e.ownerDocument||e).body:BA(t)&&Xm(t)?t:Uq(t)}function Zc(e,t,n){var o;t===void 0&&(t=[]),n===void 0&&(n=!0);let a=Uq(e),r=a===((o=e.ownerDocument)==null?void 0:o.body),i=$a(a);if(r){let A=vC(i);return t.concat(i,i.visualViewport||[],Xm(a)?a:[],A&&n?Zc(A):[])}else return t.concat(a,Zc(a,[],n))}function vC(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function zq(e){let t=Pr(e),n=parseFloat(t.width)||0,o=parseFloat(t.height)||0,a=BA(e),r=a?e.offsetWidth:n,i=a?e.offsetHeight:o,A=Zm(n)!==r||Zm(o)!==i;return A&&(n=r,o=i),{width:n,height:o,$:A}}function l2(e){return jr(e)?e:e.contextElement}function sl(e){let t=l2(e);if(!BA(t))return Ii(1);let n=t.getBoundingClientRect(),{width:o,height:a,$:r}=zq(t),i=(r?Zm(n.width):n.width)/o,A=(r?Zm(n.height):n.height)/a;return(!i||!Number.isFinite(i))&&(i=1),(!A||!Number.isFinite(A))&&(A=1),{x:i,y:A}}var Wge=Ii(0);function Yq(e){let t=$a(e);return!_C()||!t.visualViewport?Wge:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Zge(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===$a(e)}function Xc(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);let a=e.getBoundingClientRect(),r=l2(e),i=Ii(1);t&&(o?jr(o)&&(i=sl(o)):i=sl(e));let A=Zge(r,n,o)?Yq(r):Ii(0),s=(a.left+A.x)/i.x,c=(a.top+A.y)/i.y,d=a.width/i.x,l=a.height/i.y;if(r&&o){let g=$a(r),p=jr(o)?$a(o):o,m=g,h=vC(m);for(;h&&p!==m;){let B=sl(h),f=h.getBoundingClientRect(),b=Pr(h),y=f.left+(h.clientLeft+parseFloat(b.paddingLeft))*B.x,w=f.top+(h.clientTop+parseFloat(b.paddingTop))*B.y;s*=B.x,c*=B.y,d*=B.x,l*=B.y,s+=y,c+=w,m=$a(h),h=vC(m)}}return Jc({width:d,height:l,x:s,y:c})}function xC(e,t){let n=tf(e).scrollLeft;return t?t.left+n:Xc(vi(e)).left+n}function Kq(e,t){let n=e.getBoundingClientRect(),o=n.left+t.scrollLeft-xC(e,n),a=n.top+t.scrollTop;return{x:o,y:a}}function Vge(e){let{elements:t,rect:n,offsetParent:o,strategy:a}=e,r=a==="fixed",i=vi(o),A=t?ef(t.floating):!1;if(o===i||A&&r)return n;let s={scrollLeft:0,scrollTop:0},c=Ii(1),d=Ii(0),l=BA(o);if((l||!r)&&((Vc(o)!=="body"||Xm(i))&&(s=tf(o)),l)){let p=Xc(o);c=sl(o),d.x=p.x+o.clientLeft,d.y=p.y+o.clientTop}let g=i&&!l&&!r?Kq(i,s):Ii(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-s.scrollLeft*c.x+d.x+g.x,y:n.y*c.y-s.scrollTop*c.y+d.y+g.y}}function Xge(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function eme(e){let t=tf(e),n=e.ownerDocument.body,o=$r(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),a=$r(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),r=-t.scrollLeft+xC(e),i=-t.scrollTop;return Pr(n).direction==="rtl"&&(r+=$r(e.clientWidth,n.clientWidth)-o),{width:o,height:a,x:r,y:i}}var tme=25;function nme(e,t,n){n===void 0&&(n="viewport");let o=n==="layoutViewport",a=$a(e),r=vi(e),i=a.visualViewport,A=r.clientWidth,s=r.clientHeight,c=0,d=0;if(i){let g=!_C()||t==="fixed";o?g||(c=-i.offsetLeft,d=-i.offsetTop):(A=i.width,s=i.height,g&&(c=i.offsetLeft,d=i.offsetTop))}if(xC(r)<=0){let g=r.ownerDocument,p=g.body,m=getComputedStyle(p),h=g.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,B=Math.abs(r.clientWidth-p.clientWidth-h),f=getComputedStyle(r).scrollbarGutter==="stable both-edges"?B/2:B;f<=tme&&(A-=f)}return{width:A,height:s,x:c,y:d}}function ame(e,t){let n=Xc(e,!0,t==="fixed"),o=n.top+e.clientTop,a=n.left+e.clientLeft,r=sl(e),i=e.clientWidth*r.x,A=e.clientHeight*r.y,s=a*r.x,c=o*r.y;return{width:i,height:A,x:s,y:c}}function Oq(e,t,n){let o;if(t==="viewport"||t==="layoutViewport")o=nme(e,n,t);else if(t==="document")o=eme(vi(e));else if(jr(t))o=ame(t,n);else{let a=Yq(e);o={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return Jc(o)}function ome(e,t){let n=t.get(e);if(n)return n;let o=Zc(e,[],!1).filter(A=>jr(A)&&Vc(A)!=="body"),a=null,r=Pr(e).position==="fixed",i=r?Is(e):e;for(;jr(i)&&!Al(i);){let A=Pr(i),s=IC(i),c=a?a.position:r?"fixed":"";!s&&(c==="fixed"||c==="absolute"&&A.position==="static")?o=o.filter(l=>l!==i):a=A,i=Is(i)}return t.set(e,o),o}function rme(e){let{element:t,boundary:n,rootBoundary:o,strategy:a}=e,i=[...n==="clippingAncestors"?ef(t)?[]:ome(t,this._c):[].concat(n),o],A=Oq(t,i[0],a),s=A.top,c=A.right,d=A.bottom,l=A.left;for(let g=1;g<i.length;g++){let p=Oq(t,i[g],a);s=$r(p.top,s),c=Qi(p.right,c),d=Qi(p.bottom,d),l=$r(p.left,l)}return{width:c-l,height:d-s,x:l,y:s}}function ime(e){let{width:t,height:n}=zq(e);return{width:t,height:n}}function Ame(e,t,n){let o=BA(t),a=vi(t),r=n==="fixed",i=Xc(e,!0,r,t),A={scrollLeft:0,scrollTop:0},s=Ii(0);if((o||!r)&&((Vc(t)!=="body"||Xm(a))&&(A=tf(t)),o)){let g=Xc(t,!0,r,t);s.x=g.x+t.clientLeft,s.y=g.y+t.clientTop}!o&&a&&(s.x=xC(a));let c=a&&!o&&!r?Kq(a,A):Ii(0),d=i.left+A.scrollLeft-s.x-c.x,l=i.top+A.scrollTop-s.y-c.y;return{x:d,y:l,width:i.width,height:i.height}}function d2(e){return Pr(e).position==="static"}function qq(e,t){if(!BA(e)||Pr(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return vi(e)===n&&(n=n.ownerDocument.body),n}function Jq(e,t){let n=$a(e);if(ef(e))return n;if(!BA(e)){let a=Is(e);for(;a&&!Al(a);){if(jr(a)&&!d2(a))return a;a=Is(a)}return n}let o=qq(e,t);for(;o&&Hq(o)&&d2(o);)o=qq(o,t);return o&&Al(o)&&d2(o)&&!IC(o)?n:o||Tq(e)||n}var sme=async function(e){let t=this.getOffsetParent||Jq,n=this.getDimensions,o=await n(e.floating);return{reference:Ame(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function cme(e){return Pr(e).direction==="rtl"}var Wq={convertOffsetParentRelativeRectToViewportRelativeRect:Vge,getDocumentElement:vi,getClippingRect:rme,getOffsetParent:Jq,getElementRects:sme,getClientRects:Xge,getDimensions:ime,getScale:sl,isElement:jr,isRTL:cme};function Zq(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function ume(e,t,n){let o=null,a,r=vi(e);function i(){var d;clearTimeout(a),(d=o)==null||d.disconnect(),o=null}function A(d,l){d===void 0&&(d=!1),l===void 0&&(l=1),i();let g=e.getBoundingClientRect(),{left:p,top:m,width:h,height:B}=g;if(d||t(),!h||!B)return;let f=Vm(m),b=Vm(r.clientWidth-(p+h)),y=Vm(r.clientHeight-(m+B)),w=Vm(p),R={rootMargin:-f+"px "+-b+"px "+-y+"px "+-w+"px",threshold:$r(0,Qi(1,l))||1},D=!0;function F(T){let O=T[0].intersectionRatio;if(!Zq(g,e.getBoundingClientRect()))return A();if(O!==l){if(!D)return A();O?A(!1,O):a=setTimeout(()=>{A(!1,1e-7)},1e3)}D=!1}try{o=new IntersectionObserver(F,{...R,root:r.ownerDocument})}catch{o=new IntersectionObserver(F,R)}o.observe(e)}let s=$a(e),c=()=>A(n);return s.addEventListener("resize",c),A(!0),()=>{s.removeEventListener("resize",c),i()}}function p2(e,t,n,o){o===void 0&&(o={});let{ancestorScroll:a=!0,ancestorResize:r=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:A=typeof IntersectionObserver=="function",animationFrame:s=!1}=o,c=l2(e),d=a||r?[...c?Zc(c):[],...t?Zc(t):[]]:[];d.forEach(f=>{a&&f.addEventListener("scroll",n),r&&f.addEventListener("resize",n)});let l=c&&A?ume(c,n,r):null,g=-1,p=null;i&&(p=new ResizeObserver(f=>{let[b]=f;b&&b.target===c&&p&&t&&(p.unobserve(t),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var y;(y=p)==null||y.observe(t)})),n()}),c&&!s&&p.observe(c),t&&p.observe(t));let m,h=s?Xc(e):null;s&&B();function B(){let f=Xc(e);h&&!Zq(h,f)&&n(),h=f,m=requestAnimationFrame(B)}return n(),()=>{var f;d.forEach(b=>{a&&b.removeEventListener("scroll",n),r&&b.removeEventListener("resize",n)}),l?.(),(f=p)==null||f.disconnect(),p=null,s&&cancelAnimationFrame(m)}}var Vq=Nq;var Xq=$q,ez=Sq,tz=jq,nz=Lq,g2=Fq;var az=Mq,m2=(e,t,n)=>{let o=new Map,a=n??{},r={...Wq,...a.platform,_c:o};return Dq(e,t,{...a,platform:r})};var wn=C(z(),1),rz=C(z(),1),iz=C(yu(),1),dme=typeof document<"u",lme=function(){},DC=dme?rz.useLayoutEffect:lme;function FC(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,o,a;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(o=n;o--!==0;)if(!FC(e[o],t[o]))return!1;return!0}if(a=Object.keys(e),n=a.length,n!==Object.keys(t).length)return!1;for(o=n;o--!==0;)if(!{}.hasOwnProperty.call(t,a[o]))return!1;for(o=n;o--!==0;){let r=a[o];if(!(r==="_owner"&&e.$$typeof)&&!FC(e[r],t[r]))return!1}return!0}return e!==e&&t!==t}function Az(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function oz(e,t){let n=Az(e);return Math.round(t*n)/n}function f2(e){let t=wn.useRef(e);return DC(()=>{t.current=e}),t}function sz(e){e===void 0&&(e={});let{placement:t="bottom",strategy:n="absolute",middleware:o=[],platform:a,elements:{reference:r,floating:i}={},transform:A=!0,whileElementsMounted:s,open:c}=e,[d,l]=wn.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[g,p]=wn.useState(o);FC(g,o)||p(o);let[m,h]=wn.useState(null),[B,f]=wn.useState(null),b=wn.useCallback(je=>{je!==R.current&&(R.current=je,h(je))},[]),y=wn.useCallback(je=>{je!==D.current&&(D.current=je,f(je))},[]),w=r||m,Q=i||B,R=wn.useRef(null),D=wn.useRef(null),F=wn.useRef(d),T=s!=null,O=f2(s),ue=f2(a),oe=f2(c),Be=wn.useCallback(()=>{if(!R.current||!D.current)return;let je={placement:t,strategy:n,middleware:g};ue.current&&(je.platform=ue.current),m2(R.current,D.current,je).then(pn=>{let Do={...pn,isPositioned:oe.current!==!1};ge.current&&!FC(F.current,Do)&&(F.current=Do,iz.flushSync(()=>{l(Do)}))})},[g,t,n,ue,oe]);DC(()=>{c===!1&&F.current.isPositioned&&(F.current.isPositioned=!1,l(je=>({...je,isPositioned:!1})))},[c]);let ge=wn.useRef(!1);DC(()=>(ge.current=!0,()=>{ge.current=!1}),[]),DC(()=>{if(w&&(R.current=w),Q&&(D.current=Q),w&&Q){if(O.current)return O.current(w,Q,Be);Be()}},[w,Q,Be,O,T]);let ee=wn.useMemo(()=>({reference:R,floating:D,setReference:b,setFloating:y}),[b,y]),bt=wn.useMemo(()=>({reference:w,floating:Q}),[w,Q]),Ga=wn.useMemo(()=>{let je={position:n,left:0,top:0};if(!bt.floating)return je;let pn=oz(bt.floating,d.x),Do=oz(bt.floating,d.y);return A?{...je,transform:"translate("+pn+"px, "+Do+"px)",...Az(bt.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:pn,top:Do}},[n,A,bt.floating,d.x,d.y]);return wn.useMemo(()=>({...d,update:Be,refs:ee,elements:bt,floatingStyles:Ga}),[d,Be,ee,bt,Ga])}var pme=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){let{element:o,padding:a}=typeof e=="function"?e(n):e;return o&&t(o)?o.current!=null?g2({element:o.current,padding:a}).fn(n):{}:o?g2({element:o,padding:a}).fn(n):{}}}},cz=(e,t)=>{let n=Vq(e);return{name:n.name,fn:n.fn,options:[e,t]}},uz=(e,t)=>{let n=Xq(e);return{name:n.name,fn:n.fn,options:[e,t]}},dz=(e,t)=>({fn:az(e).fn,options:[e,t]}),lz=(e,t)=>{let n=ez(e);return{name:n.name,fn:n.fn,options:[e,t]}},pz=(e,t)=>{let n=tz(e);return{name:n.name,fn:n.fn,options:[e,t]}};var gz=(e,t)=>{let n=nz(e);return{name:n.name,fn:n.fn,options:[e,t]}};var mz=(e,t)=>{let n=pme(e);return{name:n.name,fn:n.fn,options:[e,t]}};var Cz=C(z(),1),wz=C(yu(),1);var ea=C(z(),1);var gme=Object.defineProperty,Gr=(e,t)=>gme(e,"name",{value:t,configurable:!0});function h2(e){let t=ea.forwardRef((n,o)=>{let{children:a,...r}=n,i=null,A=!1,s=[];b2(a)&&typeof SC=="function"&&(a=SC(a._payload)),ea.Children.forEach(a,g=>{if(Bz(g)){A=!0;let p=g,m="child"in p.props?p.props.child:p.props.children;b2(m)&&typeof SC=="function"&&(m=SC(m._payload)),i=fme(p,m),s.push(i?.props?.children)}else s.push(g)}),i?i=ea.cloneElement(i,void 0,s):!A&&ea.Children.count(a)===1&&ea.isValidElement(a)&&(i=a);let c=i?hz(i):void 0,d=ki(o,c);if(!i){if(a||a===0)throw new Error(A?Bme(e):hme(e));return a}let l=bz(r,i.props??{});return i.type!==ea.Fragment&&(l.ref=o?d:c),ea.cloneElement(i,l)});return t.displayName=`${e}.Slot`,t}Gr(h2,"createSlot");var fz=Symbol.for("radix.slottable");function mme(e){let t=Gr(n=>"child"in n?n.children(n.child):n.children,"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=fz,t}Gr(mme,"createSlottable");var fme=Gr((e,t)=>{if("child"in e.props){let n=e.props.child;return ea.isValidElement(n)?ea.cloneElement(n,void 0,e.props.children(n.props.children)):null}return ea.isValidElement(t)?t:null},"getSlottableElementFromSlottable");function bz(e,t){let n={...t};for(let o in t){let a=e[o],r=t[o];/^on[A-Z]/.test(o)?a&&r?n[o]=(...A)=>{let s=r(...A);return a(...A),s}:a&&(n[o]=a):o==="style"?n[o]={...a,...r}:o==="className"&&(n[o]=[a,r].filter(Boolean).join(" "))}return{...e,...n}}Gr(bz,"mergeProps");function hz(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)}Gr(hz,"getElementRef");function Bz(e){return ea.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===fz}Gr(Bz,"isSlottable");var bme=Symbol.for("react.lazy");function b2(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===bme&&"_payload"in e&&yz(e._payload)}Gr(b2,"isLazyComponent");function yz(e){return typeof e=="object"&&e!==null&&"then"in e}Gr(yz,"isPromiseLike");var hme=Gr(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),Bme=Gr(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),SC=ea[" use ".trim().toString()];var Ez=C(E(),1),yme=Object.defineProperty,Cme=(e,t)=>yme(e,"name",{value:t,configurable:!0}),wme=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],yA=wme.reduce((e,t)=>{let n=h2(`Primitive.${t}`),o=Cz.forwardRef((a,r)=>{let{asChild:i,...A}=a,s=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),(0,Ez.jsx)(s,{...A,ref:r})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function B2(e,t){e&&wz.flushSync(()=>e.dispatchEvent(t))}Cme(B2,"dispatchDiscreteCustomEvent");var cl=C(z(),1),Eme=Object.defineProperty,kme=(e,t)=>Eme(e,"name",{value:t,configurable:!0});function eu(e){let t=cl.useRef(e);return cl.useEffect(()=>{t.current=e}),cl.useMemo(()=>((...n)=>t.current?.(...n)),[])}kme(eu,"useCallbackRef");var kz=C(z(),1);var Qme=Object.defineProperty,Ime=(e,t)=>Qme(e,"name",{value:t,configurable:!0});function y2(e){let[t,n]=kz.useState(void 0);return Na(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let o=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;let r=a[0],i,A;if("borderBoxSize"in r){let s=r.borderBoxSize,c=Array.isArray(s)?s[0]:s;i=c.inlineSize,A=c.blockSize}else i=e.offsetWidth,A=e.offsetHeight;n({width:i,height:A})});return o.observe(e,{box:"border-box"}),()=>o.unobserve(e)}else n(void 0)},[e]),t}Ime(y2,"useSize");var ul=C(E(),1),_me=Object.defineProperty,_s=(e,t)=>_me(e,"name",{value:t,configurable:!0});var Qz="Popper",[Iz,C2]=Km(Qz),[vme,_z]=Iz(Qz),xme=_s(e=>{let{__scopePopper:t,children:n}=e,[o,a]=fa.useState(null),[r,i]=fa.useState(void 0);return(0,ul.jsx)(vme,{scope:t,anchor:o,onAnchorChange:a,placementState:r,setPlacementState:i,children:n})},"Popper"),Dme="PopperAnchor",Fme=fa.forwardRef(_s(function(t,n){let{__scopePopper:o,virtualRef:a,...r}=t,i=_z(Dme,o),A=fa.useRef(null),s=i.onAnchorChange,c=fa.useCallback(h=>{A.current=h,h&&s(h)},[s]),d=ki(n,c),l=fa.useRef(null);fa.useEffect(()=>{if(!a)return;let h=l.current;l.current=a.current,h!==l.current&&s(l.current)});let g=i.placementState&&LC(i.placementState),p=g?.[0],m=g?.[1];return a?null:(0,ul.jsx)(yA.div,{"data-radix-popper-side":p,"data-radix-popper-align":m,...r,ref:d})},"PopperAnchor")),vz="PopperContent",[Sme,hMe]=Iz(vz),Lme=fa.forwardRef(_s(function(t,n){let{__scopePopper:o,side:a="bottom",sideOffset:r=0,align:i="center",alignOffset:A=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:d=[],collisionPadding:l=0,sticky:g="partial",hideWhenDetached:p=!1,updatePositionStrategy:m="optimized",onPlaced:h,...B}=t,f=_z(vz,o),[b,y]=fa.useState(null),w=ki(n,y),[Q,R]=fa.useState(null),D=y2(Q),F=D?.width??0,T=D?.height??0,O=a+(i!=="center"?"-"+i:""),ue=typeof l=="number"?l:{top:0,right:0,bottom:0,left:0,...l},oe=Array.isArray(d)?d:[d],Be=oe.length>0,ge={padding:ue,boundary:oe.filter(xz),altBoundary:Be},{refs:ee,floatingStyles:bt,placement:Ga,isPositioned:je,middlewareData:pn}=sz({strategy:"fixed",placement:O,whileElementsMounted:_s((...Sw)=>p2(...Sw,{animationFrame:m==="always"}),"whileElementsMounted"),elements:{reference:f.anchor},middleware:[cz({mainAxis:r+T,alignmentAxis:A}),c&&uz({mainAxis:!0,crossAxis:!1,limiter:g==="partial"?dz():void 0,...ge}),c&&lz({...ge}),pz({...ge,apply:_s(({elements:Sw,rects:QS,availableWidth:XJ,availableHeight:eW})=>{let{width:tW,height:nW}=QS.reference,ff=Sw.floating.style;ff.setProperty("--radix-popper-available-width",`${XJ}px`),ff.setProperty("--radix-popper-available-height",`${eW}px`),ff.setProperty("--radix-popper-anchor-width",`${tW}px`),ff.setProperty("--radix-popper-anchor-height",`${nW}px`)},"apply")}),Q&&mz({element:Q,padding:s}),Rme({arrowWidth:F,arrowHeight:T}),p&&gz({strategy:"referenceHidden",...ge,boundary:Be?ge.boundary:void 0})]}),Do=f.setPlacementState;Na(()=>(Do(Ga),()=>{Do(void 0)}),[Ga,Do]);let[wS,ES]=LC(Ga),kS=eu(h);Na(()=>{je&&kS?.()},[je,kS]);let KJ=pn.arrow?.x,JJ=pn.arrow?.y,WJ=pn.arrow?.centerOffset!==0,[ZJ,VJ]=fa.useState();return Na(()=>{b&&VJ(window.getComputedStyle(b).zIndex)},[b]),(0,ul.jsx)("div",{ref:ee.setFloating,"data-radix-popper-content-wrapper":"",style:{...bt,transform:je?bt.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ZJ,"--radix-popper-transform-origin":[pn.transformOrigin?.x,pn.transformOrigin?.y].join(" "),...pn.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:(0,ul.jsx)(Sme,{scope:o,placedSide:wS,placedAlign:ES,onArrowChange:R,arrowX:KJ,arrowY:JJ,shouldHideArrow:WJ,children:(0,ul.jsx)(yA.div,{"data-side":wS,"data-align":ES,...B,ref:w,style:{...B.style,animation:je?B.style?.animation:"none"}})})})},"PopperContent"));function xz(e){return e!==null}_s(xz,"isNotNull");var Rme=_s(e=>({name:"transformOrigin",options:e,fn(t){let{placement:n,rects:o,middlewareData:a}=t,i=a.arrow?.centerOffset!==0,A=i?0:e.arrowWidth,s=i?0:e.arrowHeight,[c,d]=LC(n),l={start:"0%",center:"50%",end:"100%"}[d],g=(a.arrow?.x??0)+A/2,p=(a.arrow?.y??0)+s/2,m="",h="";return c==="bottom"?(m=i?l:`${g}px`,h=`${-s}px`):c==="top"?(m=i?l:`${g}px`,h=`${o.floating.height+s}px`):c==="right"?(m=`${-s}px`,h=i?l:`${p}px`):c==="left"&&(m=`${o.floating.width+s}px`,h=i?l:`${p}px`),{data:{x:m,y:h}}}}),"transformOrigin");function LC(e){let[t,n="center"]=e.split("-");return[t,n]}_s(LC,"getSideAndAlignFromPlacement");var Dz=xme,Fz=Fme,Sz=Lme;var RC=C(z(),1),Lz=C(yu(),1);var Rz=C(E(),1),$me=Object.defineProperty,Mme=(e,t)=>$me(e,"name",{value:t,configurable:!0}),Nz=RC.forwardRef(Mme(function(t,n){let{container:o,...a}=t,[r,i]=RC.useState(!1);Na(()=>i(!0),[]);let A=o||r&&globalThis?.document?.body;return A?Lz.createPortal((0,Rz.jsx)(yA.div,{...a,ref:n}),A):null},"Portal"));var ta=C(z(),1);var $z=C(z(),1),jme=Object.defineProperty,CA=(e,t)=>jme(e,"name",{value:t,configurable:!0});function Mz(e,t){return $z.useReducer((n,o)=>t[n][o]??n,e)}CA(Mz,"useStateMachine");var E2=CA(e=>{let{present:t,children:n}=e,o=jz(t),a=typeof n=="function"?n({present:o.isPresent}):ta.Children.only(n),r=Pz(o.ref,Gz(a));return typeof n=="function"||o.isPresent?ta.cloneElement(a,{ref:r}):null},"Presence");function jz(e){let[t,n]=ta.useState(),o=ta.useRef(null),a=ta.useRef(e),r=ta.useRef("none"),i=ta.useRef(void 0),A=e?"mounted":"unmounted",[s,c]=Mz(A,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return ta.useEffect(()=>{s==="mounted"?(r.current=i.current??dl(o.current),i.current=void 0):r.current="none"},[s]),Na(()=>{let d=o.current,l=a.current;if(l!==e){let p=r.current,m=dl(d);e?(i.current=m,c("MOUNT")):m==="none"||d?.display==="none"?c("UNMOUNT"):c(l&&p!==m?"ANIMATION_OUT":"UNMOUNT"),a.current=e}},[e,c]),Na(()=>{if(t){let d,l=t.ownerDocument.defaultView??window,g=CA(m=>{let B=dl(o.current).includes(CSS.escape(m.animationName));if(m.target===t&&B&&(c("ANIMATION_END"),!a.current)){let f=t.style.animationFillMode;t.style.animationFillMode="forwards",d=l.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=f)})}},"handleAnimationEnd"),p=CA(m=>{m.target===t&&(r.current=dl(o.current))},"handleAnimationStart");return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",g),t.addEventListener("animationend",g),()=>{l.clearTimeout(d),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",g),t.removeEventListener("animationend",g)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:ta.useCallback(d=>{if(d){let l=getComputedStyle(d);o.current=l,i.current=dl(l)}else o.current=null;n(d)},[])}}CA(jz,"usePresence");function w2(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}CA(w2,"setRef");function Pz(...e){let t=ta.useRef(e);return t.current=e,ta.useCallback(n=>{let o=t.current,a=!1,r=o.map(i=>{let A=w2(i,n);return!a&&typeof A=="function"&&(a=!0),A});if(a)return()=>{for(let i=0;i<r.length;i++){let A=r[i];typeof A=="function"?A():w2(o[i],null)}}},[])}CA(Pz,"useStableComposedRefs");function dl(e){return e?.animationName||"none"}CA(dl,"getAnimationName");function Gz(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)}CA(Gz,"getElementRef");var ct=C(z(),1);var Tz=C(E(),1),Pme=Object.defineProperty,Hn=(e,t)=>Pme(e,"name",{value:t,configurable:!0}),k2="dismissableLayer.update",Gme="dismissableLayer.pointerDownOutside",Hme="dismissableLayer.focusOutside",Hz,Uz=ct.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Oz=ct.forwardRef(Hn(function(t,n){let{disableOutsidePointerEvents:o=!1,deferPointerDownOutside:a=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:A,onInteractOutside:s,onDismiss:c,...d}=t,l=ct.useContext(Uz),[g,p]=ct.useState(null),m=g?.ownerDocument??globalThis?.document,[,h]=ct.useState({}),B=ki(n,p),f=Array.from(l.layers),[b]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),y=b?f.indexOf(b):-1,w=g?f.indexOf(g):-1,Q=l.layersWithOutsidePointerEventsDisabled.size>0,R=w>=y,D=ct.useRef(!1),F=qz(oe=>{i?.(oe),s?.(oe),oe.defaultPrevented||c?.()},{ownerDocument:m,deferPointerDownOutside:a,isDeferredPointerDownOutsideRef:D,dismissableSurfaces:l.dismissableSurfaces,shouldHandlePointerDownOutside:ct.useCallback(oe=>{if(!(oe instanceof Node))return!1;let Be=[...l.branches].some(ge=>ge.contains(oe));return R&&!Be},[l.branches,R])}),T=zz(oe=>{if(a&&D.current)return;let Be=oe.target;[...l.branches].some(ee=>ee.contains(Be))||(A?.(oe),s?.(oe),oe.defaultPrevented||c?.())},m),O=g?w===f.length-1:!1,ue=eu(oe=>{oe.key==="Escape"&&(r?.(oe),!oe.defaultPrevented&&c&&(oe.preventDefault(),c()))});return ct.useEffect(()=>{if(O)return m.addEventListener("keydown",ue,{capture:!0}),()=>m.removeEventListener("keydown",ue,{capture:!0})},[m,O,ue]),ct.useEffect(()=>{if(g)return o&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(Hz=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(g)),l.layers.add(g),Q2(),()=>{o&&(l.layersWithOutsidePointerEventsDisabled.delete(g),l.layersWithOutsidePointerEventsDisabled.size===0&&(m.body.style.pointerEvents=Hz))}},[g,m,o,l]),ct.useEffect(()=>()=>{g&&(l.layers.delete(g),l.layersWithOutsidePointerEventsDisabled.delete(g),Q2())},[g,l]),ct.useEffect(()=>{let oe=Hn(()=>h({}),"handleUpdate");return document.addEventListener(k2,oe),()=>document.removeEventListener(k2,oe)},[]),(0,Tz.jsx)(yA.div,{...d,ref:B,style:{pointerEvents:Q?R?"auto":"none":void 0,...t.style},onFocusCapture:Ra(t.onFocusCapture,T.onFocusCapture),onBlurCapture:Ra(t.onBlurCapture,T.onBlurCapture),onPointerDownCapture:Ra(t.onPointerDownCapture,F.onPointerDownCapture)})},"DismissableLayer"));function Tme(){let e=ct.useContext(Uz),[t,n]=ct.useState(null);return ct.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}Hn(Tme,"useDismissableLayerSurface");var Ume=Hn(()=>!0,"IS_TRUE");function qz(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:o=!1,isDeferredPointerDownOutsideRef:a,dismissableSurfaces:r,shouldHandlePointerDownOutside:i=Ume}=t,A=eu(e),s=ct.useRef(!1),c=ct.useRef(!1),d=ct.useRef(new Map),l=ct.useRef(()=>{});return ct.useEffect(()=>{function g(){c.current=!1,a.current=!1,d.current.clear()}Hn(g,"resetOutsideInteraction");function p(){return Array.from(d.current.values()).some(Boolean)}Hn(p,"isOutsideInteractionIntercepted");function m(y){if(!c.current)return;let w=y.target;w instanceof Node&&[...r].some(R=>R.contains(w))||d.current.set(y.type,!0),y.type==="click"&&window.setTimeout(()=>{c.current&&l.current()},0)}Hn(m,"handleInteractionCapture");function h(y){c.current&&d.current.set(y.type,!1)}Hn(h,"handleInteractionBubble");let B=Hn(y=>{if(y.target&&!s.current){let Q=function(){n.removeEventListener("click",l.current);let D=p();g(),D||I2(Gme,A,R,{discrete:!0})};var w=Q;if(Hn(Q,"handleAndDispatchPointerDownOutsideEvent"),!i(y.target)){n.removeEventListener("click",l.current),g(),s.current=!1;return}let R={originalEvent:y};c.current=!0,a.current=o&&y.button===0,d.current.clear(),!o||y.button!==0?Q():(n.removeEventListener("click",l.current),l.current=Q,n.addEventListener("click",l.current,{once:!0}))}else n.removeEventListener("click",l.current),g();s.current=!1},"handlePointerDown"),f=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(let y of f)n.addEventListener(y,m,!0),n.addEventListener(y,h);let b=window.setTimeout(()=>{n.addEventListener("pointerdown",B)},0);return()=>{window.clearTimeout(b),n.removeEventListener("pointerdown",B),n.removeEventListener("click",l.current);for(let y of f)n.removeEventListener(y,m,!0),n.removeEventListener(y,h)}},[n,A,o,a,r,i]),{onPointerDownCapture:Hn(()=>s.current=!0,"onPointerDownCapture")}}Hn(qz,"usePointerDownOutside");function zz(e,t=globalThis?.document){let n=eu(e),o=ct.useRef(!1);return ct.useEffect(()=>{let a=Hn(r=>{r.target&&!o.current&&I2(Hme,n,{originalEvent:r},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",a),()=>t.removeEventListener("focusin",a)},[t,n]),{onFocusCapture:Hn(()=>o.current=!0,"onFocusCapture"),onBlurCapture:Hn(()=>o.current=!1,"onBlurCapture")}}Hn(zz,"useFocusOutside");function Q2(){let e=new CustomEvent(k2);document.dispatchEvent(e)}Hn(Q2,"dispatchUpdate");function I2(e,t,n,{discrete:o}){let a=n.originalEvent.target,r=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&a.addEventListener(e,t,{once:!0}),o?B2(a,r):a.dispatchEvent(r)}Hn(I2,"handleAndDispatchCustomEvent");var ir=C(E(),1),Ome=Object.defineProperty,wA=(e,t)=>Ome(e,"name",{value:t,configurable:!0}),_2,x2="HoverCard",[Yz,PMe]=Km(x2,[C2]),D2=C2(),[qme,NC]=Yz(x2),zme=wA(e=>{let{__scopeHoverCard:t,children:n,open:o,defaultOpen:a,onOpenChange:r,openDelay:i=700,closeDelay:A=300}=e,s=D2(t),c=sn.useRef(0),d=sn.useRef(0),l=sn.useRef(!1),g=sn.useRef(!1),[p,m]=r2({prop:o,defaultProp:a??!1,onChange:r,caller:x2}),h=sn.useCallback(()=>{clearTimeout(d.current),c.current=window.setTimeout(()=>m(!0),i)},[i,m]),B=sn.useCallback(()=>{clearTimeout(c.current),!l.current&&!g.current&&(d.current=window.setTimeout(()=>m(!1),A))},[A,m]),f=sn.useCallback(()=>m(!1),[m]);return sn.useEffect(()=>()=>{clearTimeout(c.current),clearTimeout(d.current)},[]),(0,ir.jsx)(qme,{scope:t,open:p,onOpenChange:m,onOpen:h,onClose:B,onDismiss:f,hasSelectionRef:l,isPointerDownOnContentRef:g,children:(0,ir.jsx)(Dz,{...s,children:n})})},"HoverCard"),Yme="HoverCardTrigger",Kme=sn.forwardRef(wA(function(t,n){let{__scopeHoverCard:o,...a}=t,r=NC(Yme,o),i=D2(o);return(0,ir.jsx)(Fz,{asChild:!0,...i,children:(0,ir.jsx)(yA.a,{"data-state":r.open?"open":"closed",...a,ref:n,onPointerEnter:Ra(t.onPointerEnter,nf(r.onOpen)),onPointerLeave:Ra(t.onPointerLeave,nf(r.onClose)),onFocus:Ra(t.onFocus,r.onOpen),onBlur:Ra(t.onBlur,r.onClose),onTouchStart:Ra(t.onTouchStart,A=>A.preventDefault())})})},"HoverCardTrigger")),Kz="HoverCardPortal",[Jme,Wme]=Yz(Kz,{forceMount:void 0}),Zme=wA(e=>{let{__scopeHoverCard:t,forceMount:n,children:o,container:a}=e,r=NC(Kz,t);return(0,ir.jsx)(Jme,{scope:t,forceMount:n,children:(0,ir.jsx)(E2,{present:n||r.open,children:(0,ir.jsx)(Nz,{asChild:!0,container:a,children:o})})})},"HoverCardPortal"),v2="HoverCardContent",Vme=sn.forwardRef(wA(function(t,n){let o=Wme(v2,t.__scopeHoverCard),{forceMount:a=o.forceMount,...r}=t,i=NC(v2,t.__scopeHoverCard);return(0,ir.jsx)(E2,{present:a||i.open,children:(0,ir.jsx)(Xme,{"data-state":i.open?"open":"closed",...r,onPointerEnter:Ra(t.onPointerEnter,nf(i.onOpen)),onPointerLeave:Ra(t.onPointerLeave,nf(i.onClose)),ref:n})})},"HoverCardContent")),Xme=sn.forwardRef(wA(function(t,n){let{__scopeHoverCard:o,onEscapeKeyDown:a,onPointerDownOutside:r,onFocusOutside:i,onInteractOutside:A,...s}=t,c=NC(v2,o),d=D2(o),l=sn.useRef(null),g=ki(n,l),[p,m]=sn.useState(!1);return sn.useEffect(()=>{if(p){let h=document.body;return _2=h.style.userSelect||h.style.webkitUserSelect,h.style.userSelect="none",h.style.webkitUserSelect="none",()=>{h.style.userSelect=_2,h.style.webkitUserSelect=_2}}},[p]),sn.useEffect(()=>{if(l.current){let h=wA(()=>{m(!1),c.isPointerDownOnContentRef.current=!1,setTimeout(()=>{document.getSelection()?.toString()!==""&&(c.hasSelectionRef.current=!0)})},"handlePointerUp");return document.addEventListener("pointerup",h),()=>{document.removeEventListener("pointerup",h),c.hasSelectionRef.current=!1,c.isPointerDownOnContentRef.current=!1}}},[c.isPointerDownOnContentRef,c.hasSelectionRef]),sn.useEffect(()=>{l.current&&Jz(l.current).forEach(B=>B.setAttribute("tabindex","-1"))}),(0,ir.jsx)(Oz,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:A,onEscapeKeyDown:a,onPointerDownOutside:r,onFocusOutside:Ra(i,h=>{h.preventDefault()}),onDismiss:c.onDismiss,children:(0,ir.jsx)(Sz,{...d,...s,onPointerDown:Ra(s.onPointerDown,h=>{h.currentTarget.contains(h.target)&&m(!0),c.hasSelectionRef.current=!1,c.isPointerDownOnContentRef.current=!0}),ref:g,style:{...s.style,userSelect:p?"text":void 0,WebkitUserSelect:p?"text":void 0,"--radix-hover-card-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-hover-card-content-available-width":"var(--radix-popper-available-width)","--radix-hover-card-content-available-height":"var(--radix-popper-available-height)","--radix-hover-card-trigger-width":"var(--radix-popper-anchor-width)","--radix-hover-card-trigger-height":"var(--radix-popper-anchor-height)"}})})},"HoverCardContentImpl"));function nf(e){return t=>t.pointerType==="touch"?void 0:e()}wA(nf,"excludeTouch");function Jz(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:wA(o=>o.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP,"acceptNode")});for(;n.nextNode();)t.push(n.currentNode);return t}wA(Jz,"getTabbableNodes");var Wz=zme,Zz=Kme,Vz=Zme,Xz=Vme;var Ar=C(z(),1);var Hr=C(E(),1),tfe=8,nfe=10,F2=150,eY="(min-width: 768px) and (hover: hover) and (pointer: fine)",afe=new Set(["circle","ellipse","g","line","path","polygon","polyline","rect","svg","text"]);function ofe(e){return typeof e.type=="string"&&afe.has(e.type)}function Se({align:e="center",children:t,className:n,content:o,label:a,placement:r="above",triggerClassName:i}){let A=(0,Ar.useId)(),s=(0,Ar.useRef)(null),c=(0,Ar.useRef)(null),d=(0,Ar.useRef)(0),[l,g]=(0,Ar.useState)(!1),[p,m]=(0,Ar.useState)(()=>typeof window>"u"?!1:window.matchMedia(eY).matches),h=ofe(t);if((0,Ar.useEffect)(()=>{let f=window.matchMedia(eY),b=()=>{m(f.matches),f.matches||g(!1)};return b(),f.addEventListener("change",b),()=>f.removeEventListener("change",b)},[]),(0,Ar.useEffect)(()=>{if(!l)return;let f=b=>{let y=s.current,w=b.target;!(w instanceof Node)||y?.contains(w)||document.getElementById(A)?.contains(w)||(d.current=performance.now()+F2+50,g(!1))};return document.addEventListener("pointerdown",f,!0),()=>{document.removeEventListener("pointerdown",f,!0)}},[l,A]),!p)return h?t:(0,Hr.jsx)("span",{className:_("inline-flex",i),children:t});let B=(0,Hr.jsxs)(Wz,{closeDelay:F2,onOpenChange:f=>{f&&performance.now()<d.current||g(f)},open:l,openDelay:0,children:[(0,Hr.jsx)(Zz,{"aria-describedby":l?A:void 0,asChild:!0,onPointerCancel:()=>{c.current=null},onPointerDown:f=>{f.pointerType==="touch"&&(c.current=l)},onPointerUp:f=>{if(f.pointerType!=="touch"||c.current===null)return;let b=!c.current;b||(d.current=performance.now()+F2+50),g(b),c.current=null},ref:h?f=>{s.current=f}:void 0,children:t}),(0,Hr.jsx)(Vz,{children:(0,Hr.jsxs)(Xz,{align:e==="left"?"start":e==="right"?"end":"center",className:_("z-50 select-text outline-none",n??"min-w-36 max-w-64 rounded-md border border-white/15 bg-dashboard-surface-raised px-3 py-2 font-mono text-xs leading-relaxed text-dashboard-text-muted shadow-2xl shadow-black/70"),collisionPadding:tfe,hideWhenDetached:!0,id:A,role:"tooltip",side:r==="above"?"top":"bottom",sideOffset:nfe,children:[a?(0,Hr.jsx)("div",{className:"mb-1 font-semibold uppercase tracking-[0.1em] text-dashboard-text-muted",children:a}):null,o]})})]});return h?B:(0,Hr.jsx)("span",{className:_("inline-flex",i),ref:s,children:B})}function ll(e){return(0,Hr.jsx)(Se,{className:"min-w-0 rounded-md border border-white/15 bg-dashboard-surface-raised px-2.5 py-1.5 font-sans text-xs leading-none text-dashboard-text shadow-2xl shadow-black/70",content:e.label,placement:e.placement??"above",children:(0,Hr.jsx)("span",{className:"inline-flex",children:e.children})})}var na=C(E(),1),tY=[{color:"#67e8f9",key:"personal",label:"Personal"},{color:"#6ee7b7",key:"public",label:"Public"}];function nY(e){let t=e.days.slice(-e.range),n=Bn(200),o=t.length>0?n.plotWidth/t.length:n.plotWidth,a=Math.max(2,Math.min(13,o*.68)),r=t.map(s=>s.personal+s.public),i=Math.max(1,...r),A=r.some(s=>s>0);return(0,na.jsxs)(q,{className:"min-h-[17rem] p-4 sm:p-5",children:[(0,na.jsxs)("div",{children:[(0,na.jsx)("h2",{className:"m-0 font-display text-xl font-medium text-dashboard-text",children:"Activity over time"}),(0,na.jsx)("p",{className:"mt-1 mb-0 font-mono text-xs leading-relaxed text-dashboard-text-muted",children:"Stacked personal + public memories created each day."})]}),(0,na.jsx)(ma,{ariaLabel:"Memory visibility legend",items:tY}),(0,na.jsxs)("div",{className:"relative mt-3 overflow-hidden",children:[(0,na.jsxs)(yn,{"aria-label":`Memories learned during the last ${e.range} days`,className:"min-h-40",layout:n,children:[(0,na.jsx)(Pn,{layout:n,maximum:i}),t.map((s,c)=>{let d=0,l=n.left+c*o+(o-a)/2,g=r[c]??0;return(0,na.jsx)(Se,{content:(0,na.jsx)(Cn,{rows:[["personal",s.personal],["public",s.public],["total",g]]}),label:We(s.date),children:(0,na.jsxs)("g",{"aria-label":`${We(s.date)}: ${s.personal} personal, ${s.public} public, ${g} total memories`,tabIndex:0,children:[tY.map(p=>{let h=s[p.key]/i*n.plotHeight;return d+=h,(0,na.jsx)("rect",{fill:p.color,height:h,opacity:.82,rx:"1",width:a,x:l,y:n.top+n.plotHeight-d},p.key)}),(0,na.jsx)("rect",{fill:"transparent",height:n.plotHeight,width:Math.max(a,8),x:l-(Math.max(a,8)-a)/2,y:n.top})]})},s.date)}),(0,na.jsx)(Gn,{dates:t.map(s=>s.date),layout:n,xPosition:s=>n.left+s*o+o/2})]}),A?null:(0,na.jsx)("div",{className:"pointer-events-none absolute inset-0 grid place-items-center pt-12 font-mono text-xs text-dashboard-text-muted",children:"No memories were learned in this period."})]})]})}var xn=C(E(),1);function aY(e){let t=new Map(e.recallDays.map(p=>[p.date,p])),n=e.extractionDays.slice(-e.range).map(p=>({date:p.date,extraction:p,recall:t.get(p.date)??{costUsd:0,date:p.date,events:0}})),o=n.reduce((p,m)=>p+m.extraction.costUsd,0),a=n.reduce((p,m)=>p+m.recall.costUsd,0),r=o+a,i=n.reduce((p,m)=>p+m.extraction.events+m.recall.events,0),A=n.map(p=>p.extraction.costUsd+p.recall.costUsd),s=Math.max(.01,...A),c=tr(A),d=Bn(200,{left:112}),l=n.length>0?d.plotWidth/n.length:d.plotWidth,g=Math.max(2,Math.min(13,l*.68));return(0,xn.jsxs)(q,{className:"min-h-[17rem] p-4 sm:p-5",children:[(0,xn.jsxs)("div",{children:[(0,xn.jsx)("h2",{className:"m-0 font-display text-xl font-medium text-dashboard-text",children:Je({total:r})}),(0,xn.jsxs)("p",{className:"mt-1 mb-0 font-mono text-xs leading-relaxed text-dashboard-text-muted",children:["System-wide estimate across ",af(i)," spanning extraction and recall."]}),(0,xn.jsx)(ma,{ariaLabel:"Memory cost legend",items:[{color:"#67e8f9",key:"extraction",label:"Extraction",value:Je({total:o})},{color:"#e879f9",key:"recall",label:"Recall",value:Je({total:a})}]})]}),(0,xn.jsxs)("div",{className:"relative mt-4 overflow-hidden",children:[(0,xn.jsxs)(yn,{"aria-label":`Memory extraction and recall cost during the last ${e.range} days`,className:"min-h-40",layout:d,children:[(0,xn.jsx)(Pn,{format:p=>Je({total:p}),layout:d,maximum:s}),n.map((p,m)=>{let h=p.extraction.costUsd/s*d.plotHeight,B=p.recall.costUsd/s*d.plotHeight,f=d.left+m*l+(l-g)/2,b=p.extraction.costUsd+p.recall.costUsd;return(0,xn.jsx)(Se,{content:(0,xn.jsx)(Cn,{rows:[["extraction",`${Je({total:p.extraction.costUsd})} \xB7 ${af(p.extraction.events)}`],["recall",`${Je({total:p.recall.costUsd})} \xB7 ${af(p.recall.events)}`],["total",Je({total:b})]]}),label:We(p.date),children:(0,xn.jsxs)("g",{"aria-label":`${We(p.date)}: extraction ${Je({total:p.extraction.costUsd})}, ${af(p.extraction.events)}; recall ${Je({total:p.recall.costUsd})}, ${af(p.recall.events)}`,tabIndex:0,children:[(0,xn.jsx)("rect",{fill:"#67e8f9",height:h,opacity:p.extraction.costUsd>0?.82:.1,rx:"1",width:g,x:f,y:d.top+d.plotHeight-h}),(0,xn.jsx)("rect",{fill:"#e879f9",height:B,opacity:p.recall.costUsd>0?.82:.1,rx:"1",width:g,x:f,y:d.top+d.plotHeight-h-B}),(0,xn.jsx)("rect",{fill:"transparent",height:d.plotHeight,width:Math.max(g,8),x:f-(Math.max(g,8)-g)/2,y:d.top})]})},p.date)}),(0,xn.jsx)(nr,{average:c,format:p=>Je({total:p}),layout:d,maximum:s,stroke:"#e2e8f0"}),(0,xn.jsx)(Gn,{dates:n.map(p=>p.date),layout:d,xPosition:p=>d.left+p*l+l/2})]}),i===0?(0,xn.jsx)("div",{className:"pointer-events-none absolute inset-0 grid place-items-center pt-12 font-mono text-xs text-dashboard-text-muted",children:"No memory extraction or recall ran in this period."}):null]})]})}function af(e){return`${e.toLocaleString()} ${e===1?"run":"runs"}`}var rfe=u.object({content:u.string().min(1),createdAt:u.iso.datetime(),expiresAt:u.iso.datetime().optional(),id:u.string().min(1),kind:u.enum(["preference","procedure","knowledge"]),observedAt:u.iso.datetime(),origin:u.enum(["automatic","explicit","other"]),sourcePlatform:u.enum(["local","slack","web"]),visibility:u.enum(["private","public"])}).strict();function S2(e){return e.charAt(0).toUpperCase()+e.slice(1)}function L2(e){return new Intl.DateTimeFormat("en-US",{dateStyle:"medium",timeStyle:"short",timeZone:"UTC"}).format(new Date(e))}function ife(e){let t=e.origin==="automatic"?"Automatic":e.origin==="explicit"?"Explicit":"Other";return{actions:e.visibility==="private"?[{confirmation:"Forget this memory?",href:`/api/plugins/memory/memories/${encodeURIComponent(e.id)}`,label:"Forget",method:"DELETE",tone:"danger"}]:[],id:e.id,metadata:[{label:"Type",value:S2(e.kind)},{label:"Learned",value:t},{label:"Source",value:S2(e.sourcePlatform)},{label:"Visibility",value:S2(e.visibility)},{label:"Remembered",value:L2(e.createdAt)},{label:"Observed",value:L2(e.observedAt)},{label:"Expires",value:e.expiresAt?L2(e.expiresAt):"Never"}],title:e.content}}function oY(e){return ze({enabled:!!e,queryFn:async({signal:t})=>ife(await Ke(rfe,`/api/plugins/memory/memories/${encodeURIComponent(e)}`,t)),queryKey:["dashboard","plugin-user-page","memory","record",e],retry:!1})}var G=C(E(),1);function iY(e){let[t,n]=(0,MC.useState)(30),o=yt(),{memoryId:a}=ua(),r="/memories",i=`${r}/library`,A=o.pathname===r,s=o.pathname===i||!!a;if(!A&&!s)return(0,G.jsx)(Ct,{replace:!0,to:r});let c=Bi(i,o.search);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(el,{ariaLabel:"Memory navigation",items:[{end:!0,label:"Overview",to:r},{label:"Memories",to:c}]}),(0,G.jsxs)(Es,{className:"gap-6 sm:gap-8",children:[(0,G.jsx)(vt,{description:e.page.description,...A?{onRangeChange:n,range:t}:{},title:e.page.label}),A?(0,G.jsx)(Afe,{range:t}):(0,G.jsx)(sfe,{libraryPath:i,page:e.page})]})]})}function Afe(e){let t=Y8();return t.error?(0,G.jsxs)(q,{className:"flex items-center gap-3 border-rose-300/20 p-5 text-sm text-rose-200",children:[(0,G.jsx)(xa,{"aria-hidden":"true",size:18}),"Memory history is temporarily unavailable."]}):t.data?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)("section",{className:"grid gap-4 xl:grid-cols-2",children:[(0,G.jsx)(nY,{days:t.data.days,range:e.range}),(0,G.jsx)(aY,{extractionDays:t.data.extractionDays,range:e.range,recallDays:t.data.recallDays})]}),(0,G.jsx)(ufe,{data:t.data}),(0,G.jsxs)("section",{className:"grid gap-4 md:grid-cols-2",children:[(0,G.jsx)(dfe,{data:t.data}),(0,G.jsx)(lfe,{data:t.data})]})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(q,{className:"min-h-64 animate-pulse",children:(0,G.jsx)("span",{className:"sr-only",children:"Loading memory history"})}),(0,G.jsx)("div",{className:"h-24 animate-pulse border-y border-white/[0.06]",children:(0,G.jsx)("span",{className:"sr-only",children:"Loading memory summary"})})]})}function sfe(e){let{action:t,content:n,filter:o,query:a,records:r,runAction:i,searchQuery:A,searchText:s,setFilter:c,setSearchText:d}=gC(e.page),l=Y8(),g=Wa(),p=yt(),{memoryId:m}=ua(),h=oY(m),B=h.data??r.find(b=>b.id===m),f=b=>Bi(b,p.search);return(0,MC.useEffect)(()=>{!m||B||h.isFetching||h.isPending||(h.isError||h.isFetched)&&g(Bi(e.libraryPath,p.search),{replace:!0})},[p.search,m,h.isError,h.isFetched,h.isFetching,h.isPending,g,e.libraryPath,B]),!a.data&&!a.error?(0,G.jsx)(be,{label:"Loading memories"}):(0,G.jsxs)("section",{className:"grid gap-4","aria-labelledby":"memory-library-title",children:[(0,G.jsxs)("div",{className:"flex flex-wrap items-end justify-between gap-4",children:[(0,G.jsx)("div",{children:(0,G.jsx)("h2",{className:"m-0 font-display text-xl font-medium tracking-[-0.02em] text-dashboard-text",id:"memory-library-title",children:A?"Search results":"What Junior remembers"})}),n?.searchPlaceholder?(0,G.jsx)(ga,{className:"w-full max-w-md sm:w-auto",label:n.searchPlaceholder,onChange:d,placeholder:n.searchPlaceholder,size:"default",value:s}):null]}),(0,G.jsx)(jO,{ariaLabel:"Memory collections",items:[{count:l.data?.stats?.active,label:"All",value:""},{count:l.data?.stats?.personal,label:"Private",value:"private"},{count:l.data?.stats?.public,label:"Public",value:"public"}],onChange:c,value:o}),a.error?(0,G.jsxs)(q,{className:"flex items-center gap-3 border-rose-300/20 p-5 text-sm text-rose-200",children:[(0,G.jsx)(xa,{"aria-hidden":"true",size:18}),a.error.message]}):r.length===0?(0,G.jsx)(q,{className:"grid min-h-56 place-items-center p-8 text-center",children:(0,G.jsxs)("div",{children:[(0,G.jsx)(ms,{"aria-hidden":"true",className:"mx-auto text-dashboard-text-muted",size:26}),(0,G.jsx)("p",{className:"mt-4 mb-0 text-sm text-dashboard-text-muted",children:n?.emptyText??"No memories yet."})]})}):(0,G.jsxs)("div",{className:"grid gap-3",children:[(0,G.jsxs)(q,{padding:"none",children:[(0,G.jsx)(cfe,{}),r.map((b,y)=>(0,G.jsx)(pfe,{first:y===0,onSelect:()=>g(f(m===b.id?e.libraryPath:`/memories/${encodeURIComponent(b.id)}`)),record:b,selected:b.id===m},b.id))]}),(0,G.jsx)(oC,{className:"mt-2",hasMore:!a.isPlaceholderData&&!!a.hasNextPage,loading:a.isFetchingNextPage,onLoadMore:()=>{a.fetchNextPage()}}),t.error?(0,G.jsx)("p",{className:"m-0 text-center text-sm text-rose-300",children:"Could not complete this action. Try again."}):null]}),(0,G.jsx)(aq,{action:t,onAction:i,onClose:()=>g(f(e.libraryPath)),record:B})]})}function cfe(){return(0,G.jsxs)("div",{"aria-hidden":"true",className:"hidden grid-cols-[minmax(0,1fr)_7rem_7rem_9rem_auto] items-center gap-3 border-b border-white/[0.07] px-4 py-2.5 text-left font-mono text-xs uppercase tracking-[0.12em] text-dashboard-text-muted sm:grid",children:[(0,G.jsx)("span",{children:"Memory"}),(0,G.jsx)("span",{children:"Visibility"}),(0,G.jsx)("span",{children:"Type"}),(0,G.jsx)("span",{children:"Learned"}),(0,G.jsx)("span",{"aria-hidden":"true",className:"size-4"})]})}function ufe(e){let{stats:t}=e.data,n=[{detail:"personal + public",label:"Total active",value:t.active.toLocaleString("en-US")},{detail:"private to you",label:"Personal",value:t.personal.toLocaleString("en-US")},{detail:"workspace shareable",label:"Public",tone:"text-cyan-100",value:t.public.toLocaleString("en-US")},{detail:"in the last 30 days",label:"Added \xB7 30d",value:`+${t.createdThirtyDays.toLocaleString("en-US")}`}];return(0,G.jsx)("section",{"aria-label":"Memory summary",className:"grid grid-cols-2 gap-px border-y border-white/[0.06] bg-white/[0.06] lg:grid-cols-4",children:n.map(o=>(0,G.jsxs)("div",{className:"bg-[#050507] px-4 py-4 sm:px-5",children:[(0,G.jsx)("div",{className:"font-mono text-xs uppercase tracking-[0.12em] text-dashboard-text-muted",children:o.label}),(0,G.jsx)("div",{className:_("mt-2 font-display text-3xl font-light tracking-[-0.04em] text-dashboard-text",o.tone),children:o.value}),(0,G.jsx)("div",{className:"mt-1 font-mono text-xs leading-relaxed text-dashboard-text-muted",children:o.detail})]},o.label))})}function dfe(e){let{stats:t}=e.data;return(0,G.jsxs)(q,{className:"p-5 sm:p-6",children:[(0,G.jsx)("h2",{className:"m-0 font-display text-xl font-medium text-dashboard-text",children:"What Junior remembers"}),(0,G.jsx)("p",{className:"mt-1 mb-0 font-mono text-xs leading-relaxed text-dashboard-text-muted",children:"Across personal and public scopes."}),(0,G.jsxs)("div",{className:"mt-5 grid gap-px overflow-hidden rounded border border-white/[0.06] bg-white/[0.055]",children:[(0,G.jsx)(pl,{detail:"Almost entirely personal",icon:Fa,label:"Preferences",value:t.preference}),(0,G.jsx)(pl,{detail:"How work should get done",icon:ms,label:"Procedures",value:t.procedure}),(0,G.jsx)(pl,{detail:"Facts and durable context",icon:dA,label:"Knowledge",value:t.knowledge})]})]})}function lfe(e){let{stats:t}=e.data,n=Math.max(0,t.active-t.automatic-t.explicit);return(0,G.jsxs)(q,{className:"p-5 sm:p-6",children:[(0,G.jsx)("h2",{className:"m-0 font-display text-xl font-medium text-dashboard-text",children:"How they got here"}),(0,G.jsx)("p",{className:"mt-1 mb-0 font-mono text-xs leading-relaxed text-dashboard-text-muted",children:"Same totals, split by how they were written."}),(0,G.jsxs)("div",{className:"mt-5 grid gap-px overflow-hidden rounded border border-white/[0.06] bg-white/[0.055]",children:[(0,G.jsx)(pl,{detail:"Passive extraction after runs",icon:la,label:"Learned by Junior",value:t.automatic}),(0,G.jsx)(pl,{detail:"Someone asked to remember it",icon:Sg,label:"Saved explicitly",value:t.explicit}),(0,G.jsx)(pl,{detail:"Before origin tracking",icon:dA,label:"Older records",value:n})]})]})}function pl(e){let t=e.icon;return(0,G.jsxs)("div",{className:"flex items-center gap-3 bg-[#09090b] px-3 py-3",children:[(0,G.jsx)("div",{className:"grid size-9 shrink-0 place-items-center rounded border border-white/[0.07] bg-white/[0.025] text-dashboard-text-muted",children:(0,G.jsx)(t,{"aria-hidden":"true",size:15})}),(0,G.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,G.jsx)("div",{className:"font-display text-base font-medium text-dashboard-text",children:e.label}),(0,G.jsx)("div",{className:"mt-0.5 font-mono text-xs leading-relaxed text-dashboard-text-muted",children:e.detail})]}),(0,G.jsx)("div",{className:"font-display text-2xl font-light text-dashboard-text",children:e.value.toLocaleString("en-US")})]})}function pfe(e){let t=$C(e.record,"Type"),n=$C(e.record,"Remembered"),o=$C(e.record,"Source"),a=$C(e.record,"Visibility"),r=a==="Public";return(0,G.jsx)(dC,{className:_("flex items-stretch",!e.first&&"border-t border-white/[0.055]"),onSelect:e.onSelect,selected:e.selected,children:(0,G.jsxs)("button",{"aria-expanded":e.selected,"aria-label":`View memory details: ${e.record.title}`,className:"grid min-w-0 flex-1 cursor-pointer grid-cols-[minmax(0,1fr)_auto] items-center gap-3 border-0 bg-transparent px-4 py-3 text-left sm:grid-cols-[minmax(0,1fr)_7rem_7rem_9rem_auto]",onClick:e.onSelect,type:"button",children:[(0,G.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,G.jsx)("div",{className:_("grid size-8 shrink-0 place-items-center rounded border",e.selected?"border-cyan-300/20 bg-cyan-300/10 text-cyan-100":"border-white/10 bg-white/[0.025] text-dashboard-text-muted"),children:(0,G.jsx)(dA,{"aria-hidden":"true",size:15})}),(0,G.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,G.jsx)("h3",{className:"m-0 truncate font-display text-base font-medium leading-snug text-dashboard-text",children:e.record.title}),(0,G.jsxs)("div",{className:"mt-1.5 flex min-w-0 items-center gap-x-2 font-mono text-xs text-dashboard-text-muted",children:[(0,G.jsxs)("span",{className:"truncate",children:["Source: ",o]}),(0,G.jsx)("span",{"aria-hidden":"true",className:"text-dashboard-text-muted opacity-30 sm:hidden",children:"\xB7"}),(0,G.jsxs)("span",{className:"truncate sm:hidden",children:[t," \xB7 ",a," \xB7 ",rY(n)]})]})]})]}),(0,G.jsxs)("span",{className:_("hidden items-center gap-1.5 rounded border px-2 py-1 font-mono text-2xs uppercase tracking-[0.08em] sm:inline-flex",r?"border-emerald-300/20 bg-emerald-300/[0.07] text-emerald-100":"border-white/[0.08] bg-white/[0.025] text-dashboard-text-muted"),children:[r?(0,G.jsx)(Wn,{"aria-hidden":"true",size:11}):(0,G.jsx)(Zn,{"aria-hidden":"true",size:11}),a]}),(0,G.jsx)("span",{className:_("hidden w-fit rounded border px-2 py-1 font-mono text-2xs uppercase tracking-[0.08em] sm:block",gfe(t)),children:t}),(0,G.jsx)("span",{className:"hidden truncate font-mono text-xs text-dashboard-text sm:block",children:rY(n)}),(0,G.jsx)(va,{"aria-hidden":"true",className:_("shrink-0 transition-transform",e.selected?"translate-x-0.5 text-cyan-200":"text-dashboard-text-muted group-hover:text-dashboard-text"),size:16})]})})}function $C(e,t){return e.metadata?.find(n=>n.label===t)?.value??"\u2014"}function rY(e){return e.split(",").slice(0,2).join(",")}function gfe(e){return e==="Preference"?"border-cyan-300/20 bg-cyan-300/[0.07] text-cyan-100":e==="Procedure"?"border-amber-300/20 bg-amber-300/[0.07] text-amber-100":"border-violet-300/20 bg-violet-300/[0.07] text-violet-100"}var _e=C(E(),1);function jC(e,t){return e==="memory"&&t==="memories"?"/memories":`/plugins/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}function R2(e){let t=e.pages.find(n=>n.pluginName==="memory"&&n.id==="memories");return t?(0,_e.jsx)(iY,{page:t}):(0,_e.jsx)(Ct,{replace:!0,to:"/"})}function AY(e){let t=yt(),{"*":n,pageId:o,pluginName:a}=ua(),r=e.pages.find(i=>i.pluginName===a&&i.id===o);if(!r)return(0,_e.jsx)(Ct,{replace:!0,to:"/"});if(r.pluginName==="memory"&&r.id==="memories"){let i=n?`/${n}`:"";return(0,_e.jsx)(Ct,{replace:!0,to:Bi(`/memories${i}`,t.search)})}return(0,_e.jsx)(mfe,{page:r})}function mfe(e){let{action:t,content:n,query:o,records:a,runAction:r,searchText:i,setSearchText:A}=gC(e.page);return!o.data&&!o.error?(0,_e.jsx)(be,{label:`Loading ${e.page.label}`}):(0,_e.jsx)("div",{className:`${Nn} px-4 py-8 md:px-8`,children:(0,_e.jsxs)("section",{className:"mx-auto grid w-full max-w-3xl gap-6",children:[(0,_e.jsx)(vt,{description:e.page.description,title:e.page.label}),n?.metrics?.length?(0,_e.jsx)("section",{"aria-label":`${e.page.label} overview`,className:"grid gap-3 sm:grid-cols-2",children:n.metrics.map(s=>(0,_e.jsxs)(q,{className:"p-4",children:[(0,_e.jsx)("div",{className:"font-mono text-xs uppercase tracking-[0.12em] text-dashboard-text-muted",children:s.label}),(0,_e.jsx)("div",{className:"mt-3 font-display text-2xl font-light text-dashboard-text",children:s.value}),s.detail?(0,_e.jsx)("div",{className:"mt-1 font-mono text-xs text-dashboard-text-muted",children:s.detail}):null]},s.label))}):null,n?.searchPlaceholder?(0,_e.jsx)(ga,{className:"w-full",label:n.searchPlaceholder,onChange:A,placeholder:n.searchPlaceholder,size:"default",value:i}):null,o.error?(0,_e.jsx)(q,{padding:"md",children:(0,_e.jsxs)("p",{className:"m-0 text-sm text-rose-300",children:["Could not load ",e.page.label.toLowerCase(),". Try again."]})}):a.length===0?(0,_e.jsx)(q,{padding:"md",children:(0,_e.jsxs)("div",{className:"flex items-center gap-4",children:[(0,_e.jsx)("div",{className:"grid size-10 shrink-0 place-items-center rounded border border-white/[0.07] bg-white/[0.025] text-dashboard-text-muted",children:(0,_e.jsx)(wo,{"aria-hidden":"true",size:17})}),(0,_e.jsx)("p",{className:"m-0 text-sm text-dashboard-text-muted",children:n?.emptyText??`No ${e.page.label.toLowerCase()}.`})]})}):(0,_e.jsxs)("div",{className:"grid gap-3",children:[a.map(s=>(0,_e.jsxs)(q,{padding:"md",children:[(0,_e.jsxs)("div",{className:"flex items-start gap-3",children:[(0,_e.jsx)("h2",{className:"m-0 min-w-0 flex-1 font-display text-base font-medium text-dashboard-text",children:s.title}),s.actions?.map(c=>(0,_e.jsx)("button",{"aria-label":`${c.label}: ${s.title}`,className:`cursor-pointer border-0 bg-transparent p-1 text-dashboard-text-muted transition-colors ${c.tone==="danger"?"hover:text-rose-300":"hover:text-dashboard-text"}`,disabled:t.isPending,onClick:()=>r(c),title:c.label,type:"button",children:c.tone==="danger"?(0,_e.jsx)(Ir,{"aria-hidden":"true",size:16}):c.label},`${c.method}:${c.href}`))]}),s.description?(0,_e.jsx)("p",{className:"mt-2 mb-0 text-sm text-dashboard-text-muted",children:s.description}):null,s.metadata?.length?(0,_e.jsx)("dl",{className:"mt-4 flex flex-wrap gap-x-6 gap-y-2",children:s.metadata.map(c=>(0,_e.jsxs)("div",{children:[(0,_e.jsx)("dt",{className:"font-mono text-xs uppercase tracking-[0.12em] text-dashboard-text-muted",children:c.label}),(0,_e.jsx)("dd",{className:"mt-1 ml-0 font-mono text-xs text-dashboard-text-muted",children:c.value})]},c.label))}):null]},s.id)),(0,_e.jsx)(oC,{hasMore:!o.isPlaceholderData&&!!o.hasNextPage,loading:o.isFetchingNextPage,onLoadMore:()=>{o.fetchNextPage()}}),t.error?(0,_e.jsx)("p",{className:"m-0 text-center text-sm text-rose-300",children:"Could not complete this action. Try again."}):null]})]})})}var ut=C(E(),1),ffe=80,bfe=140;function hfe(e,t){let n=e?.trim().split(/\s+/).filter(Boolean)??[];return n.length>0?n.slice(0,2).map(o=>o[0]).join("").toUpperCase():t.slice(0,1).toUpperCase()}function sY({identity:e,onSignOut:t,spend:n,userPages:o}){let[a,r]=(0,xi.useState)(!1),i=(0,xi.useRef)(null),A=(0,xi.useRef)(null),s=(0,xi.useRef)(void 0),c=(0,xi.useRef)(void 0),d=e.user.email,l=e.user.name?.trim()||d,g=n?Je({total:n.sevenDaysUsd}):"\u2014",p=n?Je({total:n.thirtyDaysUsd}):"\u2014";function m(){s.current&&clearTimeout(s.current),c.current&&clearTimeout(c.current),s.current=void 0,c.current=void 0}function h(f){f.pointerType==="mouse"&&(m(),s.current=setTimeout(()=>r(!0),ffe))}function B(f){f.pointerType==="mouse"&&(m(),c.current=setTimeout(()=>r(!1),bfe))}return(0,xi.useEffect)(()=>m,[]),(0,xi.useEffect)(()=>{if(!a)return;function f(y){i.current?.contains(y.target)||r(!1)}function b(y){y.key==="Escape"&&(r(!1),A.current?.focus())}return document.addEventListener("pointerdown",f),document.addEventListener("keydown",b),()=>{document.removeEventListener("pointerdown",f),document.removeEventListener("keydown",b)}},[a]),(0,ut.jsxs)("div",{className:"relative",onBlurCapture:f=>{f.currentTarget.contains(f.relatedTarget)||r(!1)},onPointerEnter:h,onPointerLeave:B,ref:i,children:[(0,ut.jsxs)("button",{"aria-controls":"profile-popover","aria-expanded":a,"aria-haspopup":"true","aria-label":`${a?"Close":"Open"} profile menu for ${l}. Personal model spend: 7 days ${g}, 30 days ${p}.`,className:_("group flex h-10 cursor-pointer items-center gap-2 rounded-lg border-0 bg-transparent px-1.5 text-dashboard-text transition-colors hover:bg-white/[0.06] hover:text-dashboard-text focus-visible:outline focus-visible:outline-2 focus-visible:outline-[#beaaff]/70",a&&"bg-white/[0.08] text-dashboard-text"),onClick:f=>{m(),r(f.detail===0?b=>!b:!0)},ref:A,type:"button",children:[(0,ut.jsxs)("span",{className:"hidden items-center gap-2 md:flex",children:[(0,ut.jsxs)("span",{className:"flex items-baseline gap-1 whitespace-nowrap tabular-nums",children:[(0,ut.jsx)("span",{className:"text-xs font-medium tracking-[0.08em] text-dashboard-text-muted",children:"7d"}),(0,ut.jsx)("span",{className:"text-xs font-semibold text-dashboard-text",children:g})]}),(0,ut.jsx)("span",{"aria-hidden":"true",className:"h-3 w-px bg-white/10"}),(0,ut.jsxs)("span",{className:"flex items-baseline gap-1 whitespace-nowrap tabular-nums",children:[(0,ut.jsx)("span",{className:"text-xs font-medium tracking-[0.08em] text-dashboard-text-muted",children:"30d"}),(0,ut.jsx)("span",{className:"text-xs font-semibold text-dashboard-text",children:p})]})]}),(0,ut.jsx)("span",{"aria-hidden":"true",className:"grid size-7 place-items-center rounded-full bg-[#beaaff] text-xs font-bold tracking-wide text-black shadow-sm shadow-black/40",children:hfe(e.user.name,d)}),(0,ut.jsx)(Ng,{"aria-hidden":"true",className:_("hidden text-dashboard-text-muted transition-[color,transform] group-hover:text-dashboard-text md:block",a&&"rotate-180 text-dashboard-text"),size:14,strokeWidth:2})]}),a?(0,ut.jsxs)("div",{className:"absolute right-0 top-[calc(100%+0.5rem)] z-40 w-64 rounded-xl bg-dashboard-surface-raised/95 p-1.5 shadow-2xl shadow-black/75 backdrop-blur-xl",id:"profile-popover",children:[(0,ut.jsxs)("div",{className:"border-b border-white/10 px-2.5 py-2.5",children:[(0,ut.jsx)("p",{className:"m-0 truncate text-sm font-semibold text-dashboard-text",children:l}),l!==d?(0,ut.jsx)("p",{className:"mt-1 mb-0 truncate text-xs text-dashboard-text-muted",children:d}):null]}),(0,ut.jsxs)(ye,{className:"mt-1 flex items-center gap-2.5 rounded-md px-2.5 py-2 text-sm font-semibold text-dashboard-text no-underline transition-colors hover:bg-white/10 hover:text-dashboard-text focus-visible:bg-white/10 focus-visible:text-dashboard-text focus-visible:outline-none",onClick:()=>r(!1),to:hi(d),children:[(0,ut.jsx)(Fa,{"aria-hidden":"true",size:16,strokeWidth:2}),"My profile"]}),(0,ut.jsxs)(ye,{className:"flex items-center gap-2.5 rounded-md px-2.5 py-2 text-sm font-semibold text-dashboard-text no-underline transition-colors hover:bg-white/10 hover:text-dashboard-text focus-visible:bg-white/10 focus-visible:text-dashboard-text focus-visible:outline-none",onClick:()=>r(!1),to:"/settings",children:[(0,ut.jsx)(im,{"aria-hidden":"true",size:16,strokeWidth:2}),"Settings"]}),(0,ut.jsxs)(ye,{className:"flex items-center gap-2.5 rounded-md px-2.5 py-2 text-sm font-semibold text-dashboard-text no-underline transition-colors hover:bg-white/10 hover:text-dashboard-text focus-visible:bg-white/10 focus-visible:text-dashboard-text focus-visible:outline-none",onClick:()=>r(!1),to:"/settings/api-tokens",children:[(0,ut.jsx)(Qr,{"aria-hidden":"true",size:16,strokeWidth:2}),"API tokens"]}),o.filter(f=>f.navigation==="profile").map(f=>(0,ut.jsxs)(ye,{className:"flex items-center gap-2.5 rounded-md px-2.5 py-2 text-sm font-semibold text-dashboard-text no-underline transition-colors hover:bg-white/10 hover:text-dashboard-text focus-visible:bg-white/10 focus-visible:text-dashboard-text focus-visible:outline-none",onClick:()=>r(!1),to:jC(f.pluginName,f.id),children:[(0,ut.jsx)(wo,{"aria-hidden":"true",size:16,strokeWidth:2}),f.label]},`${f.pluginName}:${f.id}`)),(0,ut.jsxs)("button",{className:"flex w-full cursor-pointer items-center gap-2.5 rounded-md border-0 bg-transparent px-2.5 py-2 text-left text-sm font-semibold text-dashboard-text transition-colors hover:bg-white/10 hover:text-dashboard-text focus-visible:bg-white/10 focus-visible:text-dashboard-text focus-visible:outline-none",onClick:()=>{r(!1),t()},type:"button",children:[(0,ut.jsx)(Zg,{"aria-hidden":"true",size:16,strokeWidth:2}),"Log out"]})]}):null]})}var tu=C(z(),1);var Nt=C(E(),1),Bfe=["a[href]","button:not([disabled])","input:not([disabled]):not([type='hidden'])","select:not([disabled])","textarea:not([disabled])","[tabindex]:not([tabindex='-1'])"].join(",");function cY(e){let t=(0,tu.useRef)(null),n=(0,tu.useRef)(null),o=(0,tu.useRef)(void 0),a=(0,tu.useRef)(e.onMobileNavigationOpenChange);a.current=e.onMobileNavigationOpenChange;let r=({isActive:A})=>_("shrink-0 whitespace-nowrap rounded-md px-2.5 py-2 font-mono text-xs font-medium tracking-normal no-underline transition-colors",A?"bg-cyan-300/[0.1] text-cyan-50":_("hover:bg-white/[0.035]",ui)),i=({isActive:A})=>_("rounded-lg px-3 py-3 font-mono text-sm font-medium tracking-normal no-underline transition-colors",A?"bg-cyan-300/[0.1] text-cyan-50":_("hover:bg-white/[0.035]",ui));return(0,tu.useEffect)(()=>{if(!e.mobileNavigationOpen)return;let A=window.matchMedia("(max-width: 767px)"),s=()=>{A.matches||a.current(!1)};s(),A.addEventListener("change",s),o.current=document.activeElement instanceof HTMLElement?document.activeElement:n.current??void 0;let c=document.body.style.overflow;document.body.style.overflow="hidden";let d=requestAnimationFrame(()=>{t.current?.querySelector("[data-mobile-nav-close]")?.focus()}),l=g=>{if(g.key!=="Tab")return;let p=t.current,m=Array.from(p?.querySelectorAll(Bfe)??[]).filter(b=>b.tabIndex>=0&&b.getClientRects().length>0),h=m.at(0),B=m.at(-1);if(!p||!h||!B){g.preventDefault();return}let f=document.activeElement;g.shiftKey&&(f===h||!p.contains(f))?(g.preventDefault(),B.focus()):!g.shiftKey&&(f===B||!p.contains(f))&&(g.preventDefault(),h.focus())};return window.addEventListener("keydown",l),()=>{cancelAnimationFrame(d),A.removeEventListener("change",s),window.removeEventListener("keydown",l),document.body.style.overflow=c;let g=o.current;o.current=void 0,g?.isConnected&&g.focus()}},[e.mobileNavigationOpen]),(0,Nt.jsxs)("header",{className:"relative border-b border-white/[0.05]",children:[(0,Nt.jsxs)("div",{className:_(Nn,"grid grid-cols-[2.5rem_minmax(0,1fr)_2.5rem] items-center gap-x-2 px-3 py-2 md:gap-x-5 md:gap-y-3 md:px-4 md:py-4",e.profile?"md:grid-cols-[auto_minmax(0,1fr)_auto]":"md:grid-cols-[auto_minmax(0,1fr)]",e.compact?"md:px-4":"md:px-8"),children:[(0,Nt.jsx)("button",{"aria-controls":"mobile-navigation","aria-expanded":e.mobileNavigationOpen,"aria-hidden":e.mobileNavigationOpen||void 0,"aria-label":"Open navigation",className:"grid size-10 cursor-pointer place-items-center rounded-lg border-0 bg-transparent text-dashboard-text transition-colors hover:bg-white/[0.06] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[#beaaff]/70 md:hidden",onClick:()=>e.onMobileNavigationOpenChange(!0),ref:n,tabIndex:e.mobileNavigationOpen?-1:void 0,type:"button",children:(0,Nt.jsx)(Xg,{"aria-hidden":"true",size:20,strokeWidth:2})}),(0,Nt.jsx)(ye,{"aria-label":`${nt()} home`,className:"flex min-w-0 max-w-full items-center justify-self-center text-inherit no-underline md:justify-self-start",to:"/",children:(0,Nt.jsx)(vg,{})}),(0,Nt.jsxs)("nav",{"aria-label":"Primary",className:"hidden min-w-0 items-center gap-1 md:col-start-2 md:flex md:justify-self-start",children:[(0,Nt.jsx)(ye,{"aria-current":e.workspaceActive?"page":void 0,className:r({isActive:e.workspaceActive}),to:"/",children:"Conversations"}),e.navItems.map(A=>(0,Nt.jsx)(ts,{className:r,to:A.to,children:A.label},A.key))]}),e.profile?(0,Nt.jsx)("div",{className:"col-start-3 justify-self-end",children:e.profile}):null]}),e.mobileNavigationOpen?(0,Nt.jsxs)("div",{"aria-label":"Navigation","aria-modal":"true",className:"fixed inset-0 z-50 flex flex-col bg-[#070707] md:hidden",id:"mobile-navigation",onClick:A=>{A.target instanceof Element&&A.target.closest("a[href]")&&a.current(!1)},ref:t,role:"dialog",children:[(0,Nt.jsxs)("div",{className:"flex items-center justify-between gap-3 border-b border-white/[0.07] bg-dashboard-surface-raised px-3 py-2 pt-[max(0.5rem,env(safe-area-inset-top))]",children:[(0,Nt.jsx)(ye,{"aria-label":`${nt()} home`,className:"flex min-w-0 items-center text-inherit no-underline",to:"/",children:(0,Nt.jsx)(vg,{})}),(0,Nt.jsx)("button",{"aria-label":"Close navigation",className:"grid size-10 cursor-pointer place-items-center rounded-lg border-0 bg-transparent text-dashboard-text transition-colors hover:bg-white/[0.06] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[#beaaff]/70","data-mobile-nav-close":!0,onClick:()=>e.onMobileNavigationOpenChange(!1),type:"button",children:(0,Nt.jsx)(ko,{"aria-hidden":"true",size:20,strokeWidth:2})})]}),(0,Nt.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain p-3",children:[(0,Nt.jsxs)("nav",{"aria-label":"Primary",className:"grid gap-1",children:[(0,Nt.jsx)(ye,{"aria-current":e.workspaceActive?"page":void 0,className:i({isActive:e.workspaceActive}),to:"/",children:"Conversations"}),e.navItems.map(A=>(0,Nt.jsx)(ts,{className:i,to:A.to,children:A.label},A.key))]}),(0,Nt.jsx)(UO,{})]}),e.version?(0,Nt.jsxs)("p",{className:"m-0 border-t border-white/[0.07] px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] font-mono text-xs text-dashboard-text-muted",children:["junior version ",e.version]}):null]}):null]})}var Ur=C(z(),1);var nu=C(z(),1);var xs=C(z(),1);function PC(e){return["conversation",e,"outbox"]}function uY(e){return{createdAt:e.now??new Date().toISOString(),idempotencyKey:e.idempotencyKey,message:e.message,messageId:`client:${e.idempotencyKey}`,status:"sending"}}function yfe(e){return{clientStatus:e.status,createdAt:e.createdAt,delivery:"defer",idempotencyKey:e.idempotencyKey,inboundMessageId:e.messageId,messageId:e.messageId,receivedAt:e.createdAt,role:"user",source:"web",text:e.message}}function dY(e,t){let n=e??[],o=t??[];if(o.length===0)return[...n];let a=new Set(n.map(i=>i.messageId)),r=o.filter(i=>!a.has(i.messageId)).map(yfe);return r.length===0?[...n]:[...n,...r]}function lY(e,t){let n=e??[],o=n.findIndex(r=>r.idempotencyKey===t.idempotencyKey);if(o<0)return[...n,t];let a=n.slice();return a[o]=t,a}function pY(e,t){return(e??[]).filter(n=>n.idempotencyKey!==t)}function gY(e,t){return(e??[]).map(n=>n.idempotencyKey===t?{...n,status:"failed"}:n)}function N2(e,t){if(e.eventHistory.status!=="available")return mY(e);let n=t.find(o=>o.eventHistory.status!=="available");return n?mY({...e,eventHistory:n.eventHistory,events:n.events,previousCursor:n.previousCursor}):{...e,events:wfe([...t.flatMap(o=>o.events),...e.events]),previousCursor:GC(e.previousCursor,t)??(t.length?CY(t):e.previousCursor)}}async function fY(e){let t=new Map(e.historyPages.map(r=>[r.requestedBefore,r])),n=[],o=new Set,a=e.detail.previousCursor;for(;a;){if(o.has(a))throw new Error("Conversation history cursor did not advance");o.add(a);let r=t.get(a)??{...await e.readPage(a),requestedBefore:a};n.push(r),a=r.previousCursor}return N2(e.detail,n)}function bY(e){let t=yY(e);return t===void 0?"empty":String(t)}function hY(e,t){return GC(e,t)??CY(t)}function GC(e,t){if(!e)return;let n=new Map(t.map(i=>[i.requestedBefore,i])),o=new Set,a=new Set,r=e;for(;r;){if(a.has(r))return;a.add(r);let i=n.get(r);if(!i)return o.size>0&&o.size===t.length?void 0:r;o.add(i);let A=yY(o),s=Cfe(t.filter(c=>!o.has(c)));if(A!==void 0&&s!==void 0&&A<=s+1)return;r=i.previousCursor}}function BY(e,t){return t.some(n=>n.eventHistory.status!==e.eventHistory.status)}function yY(e){let t;for(let n of e){let o=n.events[0]?.seq;o!==void 0&&(t===void 0||o<t)&&(t=o)}return t}function Cfe(e){let t;for(let n of e){let o=n.events.at(-1)?.seq;o!==void 0&&(t===void 0||o>t)&&(t=o)}return t}function CY(e){let t;for(let n of e){let o=n.events[0]?.seq,a=t?.events[0]?.seq;o!==void 0&&(a===void 0||o<a)&&(t=n)}return t?.previousCursor}function wfe(e){return[...new Map(e.map(t=>[t.seq,t])).values()].sort((t,n)=>t.seq-n.seq)}function mY(e){let{modelUsage:t,...n}=e;return n}function of(e){return["conversation",e,"detail"]}function wY(e){return["dashboard","archived-conversation",e]}var kY=["dashboard","archive-conversation"];function QY(){return tE({filters:{mutationKey:kY,status:"pending"},select:e=>{let t=e.state.variables,n=e.state.context,o=e.options.mutationKey?.[2];return{archived:t.archived,conversation:n?.archivedSnapshot?.conversation,conversationId:typeof o=="string"?o:""}}})}function vs(e){return["conversation",e,"pending-messages"]}function Efe(e){return{enabled:!!e,queryKey:of(e),queryFn:({signal:t})=>Ife(e,t),refetchInterval:t=>t.state.data?.status==="active"?2e3:!1,retry:!1}}function kfe(e,t){return{enabled:!!e,queryKey:vs(e),queryFn:({signal:n})=>_fe(e,n),refetchInterval:n=>t?.activeConversation||n.state.data?.messages.length||n.state.data?.authorization?2e3:!1,retry:!1}}function IY(){let e=Xt();return ya({mutationFn:t=>_g(ry,"/api/conversations",t),onSuccess:t=>{e.invalidateQueries({queryKey:["dashboard","conversations"]}),e.invalidateQueries({exact:!0,queryKey:vs(t.conversationId)})}})}function _Y(e){let t=Xt(),n=PC(e);return ya({mutationFn:o=>_g(ry,`/api/conversations/${encodeURIComponent(e)}/messages`,o),onMutate:async o=>{let a=uY(o);t.setQueryData(n,r=>lY(r,a))},onError:(o,a)=>{t.setQueryData(n,r=>gY(r,a.idempotencyKey))},onSuccess:(o,a)=>{t.setQueryData(n,r=>pY(r,a.idempotencyKey)),t.invalidateQueries({queryKey:["dashboard","conversations"]}),t.invalidateQueries({exact:!0,queryKey:of(e)}),t.invalidateQueries({exact:!0,queryKey:vs(e)})}})}function vY(e){let t=Xt();return ya({mutationFn:n=>H7(nF,`/api/conversations/${encodeURIComponent(e)}/pending-messages`,n),onMutate:async n=>{await t.cancelQueries({exact:!0,queryKey:vs(e)});let o=t.getQueryData(vs(e));return o&&t.setQueryData(vs(e),{...o,messages:o.messages.filter(a=>!n.inboundMessageIds.includes(a.inboundMessageId))}),{previousPending:o}},onError:(n,o,a)=>{a?.previousPending&&t.setQueryData(vs(e),a.previousPending)},onSettled:async()=>{await Promise.all([t.invalidateQueries({queryKey:["dashboard","conversations"]}),t.invalidateQueries({exact:!0,queryKey:of(e)}),t.invalidateQueries({exact:!0,queryKey:vs(e)})])}})}function rf(e,t){let n=Xt();return ya({mutationKey:[...kY,e],mutationFn:o=>cy(eF,`/api/conversations/${encodeURIComponent(e)}/archive`,o),onMutate:async o=>{let a={queryKey:["dashboard","conversations"]},r=of(e),i=wY(e);await Promise.all([n.cancelQueries(a),n.cancelQueries({queryKey:r})]);let A=n.getQueriesData(a),s=n.getQueryData(r),c=n.getQueryData(i),d=o.archived?new Date().toISOString():void 0,l=o.archived?Qfe(A,e)??c:c;return A.forEach(([g,p])=>{if(!p)return;let m=p.conversations.some(f=>f.conversationId===e),B=!o.archived&&!m&&!!l?.feedQueryHashes.includes(JSON.stringify(g))?[...p.conversations,{...l.conversation,archivedAt:void 0}].sort((f,b)=>b.lastSeenAt.localeCompare(f.lastSeenAt)):p.conversations.map(f=>f.conversationId===e?{...f,archivedAt:d}:f);n.setQueryData(g,{...p,conversations:B})}),n.setQueryData(r,g=>g&&{...g,archivedAt:d}),l&&n.setQueryData(i,l),{archivedQueryKey:i,archivedSnapshot:l,detailQueryKey:r,previousArchivedSnapshot:c,previousDetail:s,previousFeeds:A}},onError:(o,a,r)=>{r?.previousFeeds.forEach(([i,A])=>{n.setQueryData(i,A)}),r&&(n.setQueryData(r.detailQueryKey,r.previousDetail),r.previousArchivedSnapshot?n.setQueryData(r.archivedQueryKey,r.previousArchivedSnapshot):n.removeQueries({exact:!0,queryKey:r.archivedQueryKey})),t?.onError?.()},onSuccess:(o,a)=>{a.archived||n.removeQueries({exact:!0,queryKey:wY(e)}),t?.onSuccess?.(a.archived)},onSettled:async()=>{await Promise.all([n.invalidateQueries({queryKey:["dashboard","conversations"]}),n.invalidateQueries({queryKey:["dashboard","locations"]}),n.invalidateQueries({queryKey:["dashboard","people"]}),n.invalidateQueries({exact:!0,queryKey:of(e)})])}})}function Qfe(e,t){let n,o=[];for(let[a,r]of e){let i=r?.conversations.find(A=>A.conversationId===t);i&&(n??=i,o.push(JSON.stringify(a)))}return n?{conversation:n,feedQueryHashes:o}:void 0}function HC(e){let t=Xt(),n=ze(Efe(e)),o=ze(kfe(e,{activeConversation:n.data?.status==="active"})),a=n.data?.eventHistory.status,r=(0,xs.useMemo)(()=>["conversation",e,"history",a],[e,a]),i=Ll({enabled:!1,queryKey:r,queryFn:async({pageParam:b,signal:y})=>({...await EY(e,b,y),requestedBefore:b}),initialPageParam:n.data?.previousCursor??"",getNextPageParam:(b,y)=>hY(n.data?.previousCursor,y),retry:!1}),A=i.data?.pages,s=(0,xs.useMemo)(()=>n.data?N2(n.data,A??[]):void 0,[n.data,A]),c=ze({enabled:!!e,queryFn:async()=>t.getQueryData(PC(e))??[],queryKey:PC(e),initialData:[],staleTime:1/0,gcTime:1/0}),d=(0,xs.useMemo)(()=>dY(o.data?.messages,c.data),[c.data,o.data?.messages]),l=vfe(i.error),g=!!(n.data&&(BY(n.data,A??[])||l)),p=l?null:i.error,m=!!(n.data?.previousCursor&&i.data&&GC(n.data.previousCursor,i.data.pages)&&!g&&!i.error&&!i.isFetchingNextPage),h=i.isFetchingNextPage||m,B=n.refetch;(0,xs.useEffect)(()=>{g&&B()},[B,g]),(0,xs.useEffect)(()=>{l&&t.resetQueries({exact:!0,queryKey:r})},[r,l,t]);let f=i.fetchNextPage;return(0,xs.useEffect)(()=>{m&&f()},[f,m]),{data:s,error:n.error,historyError:p,historyVersion:bY(A??[]),hasPreviousPage:i.data?i.hasNextPage:!!n.data?.previousCursor,isPending:n.isPending,isLoadingPreviousPage:h,pendingAuthorization:o.data?.authorization,pendingGeneratedAt:o.data?.generatedAt,pendingMessages:d,loadCompleteTranscript:()=>{if(!e||!n.data)throw new Error("Cannot load a conversation without an id");return fY({detail:n.data,historyPages:i.data?.pages??[],readPage:b=>EY(e,b)})},loadPreviousPage:()=>{let b=i.data?i.hasNextPage:!!n.data?.previousCursor;e&&b&&!i.isFetchingNextPage&&i.fetchNextPage()}}}function Ife(e,t){return Ke(rF,`/api/conversations/${encodeURIComponent(e)}`,t)}function _fe(e,t){return Ke(tF,`/api/conversations/${encodeURIComponent(e)}/pending-messages`,t)}function EY(e,t,n){let o=new URLSearchParams({before:t});return Ke(iF,`/api/conversations/${encodeURIComponent(e)}/events?${o}`,n).then(a=>{if(a.previousCursor===t)throw new Error("Conversation history cursor did not advance");return a})}function vfe(e){return e instanceof qo&&e.status===400}var DY=C(E(),1);function xY(e){return(0,DY.jsx)("span",{"aria-hidden":"true",className:_("shrink-0 rounded-full bg-emerald-300 shadow-[0_0_10px_rgba(110,231,183,0.55)] animate-[junior-active-indicator_1.8s_ease-in-out_infinite] motion-reduce:animate-none",e.className)})}var Di=C(E(),1);function $2({action:e,children:t,detail:n,icon:o,title:a,tone:r="default"}){let i=r==="error";return(0,Di.jsxs)("div",{className:_("overflow-hidden rounded-xl shadow-[0_16px_40px_rgba(0,0,0,0.5)]",i?"bg-[#1f1216]":"bg-[#111719]"),children:[(0,Di.jsxs)("div",{className:"flex min-w-0 items-center gap-3 px-3 py-3",children:[o?(0,Di.jsx)("div",{className:_("grid size-8 shrink-0 place-items-center rounded-lg",i?"bg-rose-300/15 text-rose-100":"bg-cyan-300/10 text-cyan-100/80"),children:(0,Di.jsx)(o,{"aria-hidden":"true",size:16})}):null,(0,Di.jsxs)("div",{className:"min-w-0 flex-1",role:i?"alert":"status",children:[(0,Di.jsxs)("div",{className:_("font-display text-sm font-medium leading-snug",i?"text-rose-50":"text-dashboard-text"),children:[a,n?" ":null]}),n?(0,Di.jsx)("div",{className:_("mt-0.5 truncate font-mono text-xs",i?"text-rose-100/70":"text-dashboard-text-muted"),children:n}):null]}),e]}),t]})}function M2({className:e,tone:t="default",type:n="button",...o}){let a=t==="error";return(0,Di.jsx)("button",{...o,className:_("shrink-0 cursor-pointer px-3 py-1.5 text-xs transition focus:outline-none focus:ring-2 disabled:cursor-not-allowed disabled:opacity-40",a?"focus:ring-rose-300/40":"focus:ring-cyan-300/35",a?"rounded-lg bg-rose-200/15 font-display font-medium text-rose-50 hover:bg-rose-200/25":"rounded-lg bg-cyan-200/10 font-display font-medium text-cyan-100 hover:bg-cyan-200/20",e),type:n})}var Io=C(z(),1);var Af=C(E(),1);function SY(e){let t=Ffe(),n=t?0:e.durationMs??180,[o,a]=(0,Io.useState)(()=>e.items.map(s=>({item:s,key:e.getKey(s),state:"present"}))),r=(0,Io.useRef)(e.items.length>0),i=o.some(s=>s.state==="exiting"),A=(0,Io.useCallback)(s=>{a(c=>c.filter(d=>d.key!==s))},[]);return(0,Io.useLayoutEffect)(()=>{a(s=>xfe(s,e.items,e.getKey,r.current)),e.items.length>0&&(r.current=!0)},[e.getKey,e.items]),(0,Io.useEffect)(()=>{if(!o.some(c=>c.state==="entering"))return;if(t){a(c=>FY(c));return}let s=window.requestAnimationFrame(()=>{a(c=>FY(c))});return()=>window.cancelAnimationFrame(s)},[o,t]),(0,Af.jsx)("div",{"aria-label":o.length>0?e.ariaLabel:void 0,className:_(e.className,i&&"pointer-events-none"),role:o.length>0?e.role:void 0,children:o.length>0?o.map(s=>(0,Af.jsx)(Dfe,{animatedItem:s,durationMs:n,onExited:A,renderItem:e.renderItem},s.key)):e.empty})}function xfe(e,t,n,o){let a=new Map(e.map(A=>[A.key,A])),r=new Set(t.map(n)),i=t.map(A=>{let s=n(A),c=a.get(s);return{item:A,key:s,state:c?.state==="exiting"?"entering":c?.state??(o?"entering":"present")}});return e.forEach((A,s)=>{r.has(A.key)||i.splice(Math.min(s,i.length),0,{...A,state:"exiting"})}),i}function Dfe(e){let{animatedItem:t,durationMs:n,onExited:o}=e;return(0,Io.useEffect)(()=>{if(t.state!=="exiting")return;let a=window.setTimeout(()=>o(t.key),n);return()=>window.clearTimeout(a)},[t.key,t.state,n,o]),(0,Af.jsx)("div",{"aria-hidden":t.state==="exiting"?!0:void 0,className:_("grid min-w-0 origin-center transition-[grid-template-rows,opacity,transform] motion-reduce:transition-none",t.state==="present"?"grid-rows-[1fr] translate-x-0 scale-100 opacity-100":"pointer-events-none grid-rows-[0fr] translate-x-2 scale-[0.98] opacity-0"),"data-presence":t.state,inert:t.state==="exiting"?!0:void 0,style:{transitionDuration:`${e.durationMs}ms`,transitionTimingFunction:"cubic-bezier(0.2, 0.8, 0.2, 1)"},children:(0,Af.jsx)("div",{className:"min-h-0 min-w-0 overflow-hidden",children:e.renderItem(t.item)})})}function FY(e){return e.map(t=>t.state==="entering"?{...t,state:"present"}:t)}function Ffe(){let[e,t]=(0,Io.useState)(!1);return(0,Io.useEffect)(()=>{let n=window.matchMedia("(prefers-reduced-motion: reduce)"),o=()=>t(n.matches);return o(),n.addEventListener("change",o),()=>n.removeEventListener("change",o)},[]),e}var j2=["priority","today","yesterday","last-week","2-weeks","3-weeks","older"];function RY(e,t){let n=NY(t.nowMs,t.timeZone),o=new Map,a=[...e].sort((r,i)=>P2(i)-P2(r));for(let r of a){let i=P2(r),A=Sfe(r,i,n,t.timeZone),s=o.get(A.key);s?s.conversations.push(r):o.set(A.key,{...A,conversations:[r]})}return[...o.values()].sort((r,i)=>LY(r.key)-LY(i.key))}function P2(e){let t=Date.parse(e.lastSeenAt);return Number.isFinite(t)?t:Number.NEGATIVE_INFINITY}function Sfe(e,t,n,o){if(!Number.isFinite(t))return{key:"older",label:"Older"};if(e.isPriority)return{key:"priority",label:"Priority"};let a=NY(t,o),r=Math.max(0,Math.floor((n-a)/864e5));return r===0?{key:"today",label:"Today"}:r===1?{key:"yesterday",label:"Yesterday"}:r<7?{key:`day-${a}`,label:new Intl.DateTimeFormat("en-US",{timeZone:o,weekday:"long"}).format(t)}:r<14?{key:"last-week",label:"Last week"}:r<21?{key:"2-weeks",label:"2 weeks ago"}:r<28?{key:"3-weeks",label:"3 weeks ago"}:{key:"older",label:"Older"}}function LY(e){let t=j2.indexOf(e);return t>=0?t:e.startsWith("day-")?j2.indexOf("yesterday")+.5:j2.length}function NY(e,t){let n=new Intl.DateTimeFormat("en-US",{day:"numeric",month:"numeric",timeZone:t,year:"numeric"}).formatToParts(e),o=new Map(n.map(a=>[a.type,Number(a.value)]));return Date.UTC(o.get("year")??0,(o.get("month")??1)-1,o.get("day")??1)}var $Y=C(E(),1);function cn(e){return(0,$Y.jsx)("div",{className:"min-w-0 rounded-lg border border-white/10 bg-[#050505] px-4 py-3 text-base leading-relaxed text-dashboard-text-muted",children:e.children})}var UY=C(z(),1);var G2=C(E(),1),Lfe="animate-[junior-text-shimmer_1.6s_linear_infinite] bg-[linear-gradient(90deg,#777_0%,#d6d6d6_40%,#fff_50%,#d6d6d6_60%,#777_100%)] bg-[length:200%_100%] bg-clip-text text-transparent motion-reduce:animate-none";function Fi(e){if(!e.active&&!e.className&&!e["aria-label"])return e.children;let t=_(e.active&&Lfe,e.className);return e.as==="strong"?(0,G2.jsx)("strong",{"aria-label":e["aria-label"],className:t,children:e.children}):(0,G2.jsx)("span",{"aria-label":e["aria-label"],className:t,children:e.children})}var jt=C(E(),1);function MY(e){return(0,jt.jsx)("span",{className:"grid min-w-0 self-start grid-cols-[minmax(0,1fr)_auto] content-start gap-x-3 gap-y-1.5",children:e.lines.map((t,n)=>(0,jt.jsxs)("span",{className:t.label?"contents":_("col-span-2 block min-w-0 break-words text-dashboard-text",t.valueStyle==="heading"&&"font-mono font-semibold text-dashboard-text",t.valueStyle==="heading"&&n>0&&"mt-1 border-t border-white/10 pt-2"),children:[t.label?(0,jt.jsx)("span",{className:_("min-w-0 break-words font-medium text-dashboard-text-muted",t.labelStyle==="code"&&"break-all font-mono text-xs text-dashboard-text"),children:t.label}):null,t.label?(0,jt.jsx)("span",{className:"whitespace-nowrap text-right text-dashboard-text",children:t.value}):(0,jt.jsxs)(jt.Fragment,{children:[t.value,t.live?(0,jt.jsxs)("span",{className:"ml-2 inline-flex items-center gap-1.5 font-sans text-xs font-normal tracking-wide text-dashboard-text-muted",children:[(0,jt.jsx)("span",{"aria-hidden":"true",children:"\xB7"}),(0,jt.jsx)(Fi,{active:!0,children:"in progress"})]}):null]})]},`${n}-${t.label??""}-${t.value}-${t.live?"live":""}`))})}function Ds(e){let t=e.tooltip?.filter(a=>a.value.trim()),n=e.tooltipColumns?.map(a=>a.filter(r=>r.value.trim())).filter(a=>a.length),o=!!n?.length;return!t?.length&&!n?.length?(0,jt.jsx)("span",{className:e.className,children:e.children}):(0,jt.jsx)(Se,{align:e.align,className:_("w-[calc(100vw-2rem)] rounded-lg border border-white/15 bg-[#050505] px-3 py-2 text-left text-xs font-normal leading-relaxed text-dashboard-text-muted shadow-xl shadow-black/35",o?"max-w-[32.5rem]":"max-w-80"),content:n?.length?(0,jt.jsx)("span",{className:"grid max-h-72 grid-cols-1 items-start gap-4 overflow-y-auto sm:grid-cols-2 sm:gap-6",children:n.map((a,r)=>(0,jt.jsx)(MY,{lines:a},r))}):t?(0,jt.jsx)("span",{className:"block max-h-72 overflow-y-auto",children:(0,jt.jsx)(MY,{lines:t})}):null,placement:e.tooltipPlacement??"below",children:(0,jt.jsx)("span",{className:_("inline-flex border-b border-dotted border-white/20 outline-none transition-colors hover:border-white/45 focus-visible:border-white/45",e.className),tabIndex:0,children:e.children})})}function TC(e){return(0,jt.jsx)("div",{className:_("flex flex-wrap items-center gap-x-1.5 gap-y-1",e.className),children:e.items.map((t,n)=>(0,jt.jsxs)("span",{className:"inline-flex min-w-0 items-center gap-x-1.5",children:[n>0?(0,jt.jsx)("span",{className:"text-dashboard-text-muted",children:"\xB7"}):null,(0,jt.jsx)("span",{className:"min-w-0",children:t.content})]},t.key))})}var gl=C(E(),1);function H2(e){return!!e}function jY(e){return[e.inputTokens!==void 0?{label:"input",value:V(e.inputTokens)}:void 0,e.outputTokens!==void 0?{label:"output",value:V(e.outputTokens)}:void 0,e.cachedInputTokens!==void 0?{label:"cached",value:V(e.cachedInputTokens)}:void 0,e.cacheCreationTokens!==void 0?{label:"cache write",value:V(e.cacheCreationTokens)}:void 0,e.reasoningTokens!==void 0?{label:"reasoning",value:V(e.reasoningTokens)}:void 0,e.providerTotalTokens!==void 0?{label:"provider",value:V(e.providerTotalTokens)}:void 0]}function Rfe(e){return e.split("/").at(-1)??e}function sf(e,t){return{live:e===t,value:Rfe(e),valueStyle:"heading"}}function Nfe(e,t,n,o){let a=[n?{label:"compactions",value:V(n)}:void 0];t?.length||a.push(...jY(e));let r=!1;for(let i of t??[]){let A=Pm(i.usage);A&&(r||=i.modelId===o,a.push(sf(i.modelId,o),...jY(A).map(s=>s?.label?{...s,label:`\u2022 ${s.label}`}:s)))}return o&&!r&&a.push(sf(o,o)),a.filter(H2)}function UC(e){return[{label:"total",value:bi(e)},e.input!==void 0?{label:"input",value:bi({total:e.input})}:void 0,e.output!==void 0?{label:"output",value:bi({total:e.output})}:void 0,e.cacheRead!==void 0?{label:"cache read",value:bi({total:e.cacheRead})}:void 0,e.cacheWrite!==void 0?{label:"cache write",value:bi({total:e.cacheWrite})}:void 0].filter(H2)}function $fe(e,t,n,o){let a=eC(e,n),r=(t??[]).flatMap(c=>{let d=Gm(c.usage);return d?[{modelId:c.modelId,summary:d}]:[]}),i=o&&!r.some(c=>c.modelId===o)?[sf(o,o)]:[];if(!a)return{tooltip:i};if(!n)return r.length?{tooltip:[...r.flatMap(c=>[sf(c.modelId,o),...UC(c.summary).map(d=>({...d,label:`\u2022 ${d.label}`}))]),...i]}:{tooltip:[...e?UC(e):[],...i]};let A=[{value:"Conversation",valueStyle:"heading"},{label:"total",value:bi(a)}];if(e)if(A.push({label:"agent",value:bi(e)}),!r.length)A.push(...UC(e).filter(c=>c.label!=="total").map(c=>({...c,label:`\u2022 ${c.label}`})));else for(let c of r)A.push(sf(c.modelId,o),...UC(c.summary).map(d=>({...d,label:`\u2022 ${d.label}`})));A.push(...i);let s=[{value:"Auxiliary",valueStyle:"heading"},{label:"total",value:bi({total:n.costUsd})}];for(let c of n.operations)s.push({label:`${Mfe(c)} (${V(c.events)})`,value:bi({total:c.costUsd})});return{tooltipColumns:[A,s]}}function Mfe(e){let t={"junior/guardian_action_reviewed":"Guardian","junior/passive_reply_routed":"Passive reply routing","junior/turn_routed":"Thinking routing","memory/memories_captured":"Memory extraction","memory/memories_recalled":"Memory recall"},n=`${e.namespace}/${e.name}`;return t[n]??`${e.namespace} \xB7 ${e.name.replaceAll("_"," ")}`}function PY(e){let t=eC(e.summary,e.auxiliaryCosts);if(!t&&!e.live)return null;let n=!!e.live,o=t?`${Je(t)}${n?"+":""}`:"$\u2026";return(0,gl.jsx)(Ds,{align:e.align,tooltipPlacement:"above",...$fe(e.summary,e.modelUsage,e.auxiliaryCosts,e.liveModelId),children:(0,gl.jsx)(Fi,{active:n,children:o})})}function GY(e){return e.summary?(0,gl.jsx)(Ds,{align:e.align,tooltip:Nfe(e.summary,e.modelUsage,e.compactionCount,e.liveModelId),children:(0,gl.jsx)(Fi,{active:e.live,children:U8(e.summary)})}):null}function HY(e){if(!e.label||e.label==="none")return null;let n=[e.startedAt?{label:"started",value:Xn(e.startedAt)}:void 0,e.endedAt?{label:"ended",value:Xn(e.endedAt)}:void 0].filter(H2);return(0,gl.jsx)(Ds,{align:e.align,tooltip:n,children:e.label})}var W=C(E(),1),TY="(max-width: 767px)";function OY(e){return(0,W.jsxs)("div",{className:"mb-2 rounded-lg border border-cyan-300/20 bg-cyan-300/[0.07] px-3 py-2.5 font-sans text-sm text-dashboard-text",children:[(0,W.jsx)("a",{className:"font-medium text-cyan-200 underline decoration-cyan-300/40 underline-offset-2 hover:text-cyan-100",href:e.authorization.authorizationUrl,rel:"noreferrer",target:"_blank",children:e.authorization.label}),(0,W.jsx)("p",{className:"mb-0 mt-1 text-xs text-dashboard-text-muted",children:e.authorization.completionText})]})}function qY(e){if(!e.visibility)return null;let t=e.visibility==="public",n=t?Wn:Zn,o=t?"Public":"Private",a=t?"Public conversation":"Private conversation",r=t?"Anyone in this workspace can see this transcript.":"Only members of this conversation can see this transcript.";return(0,W.jsxs)("span",{className:t?"inline-flex max-w-full items-center gap-1 rounded-full border border-emerald-300/20 bg-emerald-300/[0.08] px-2 py-0.5 font-sans text-2xs font-medium text-emerald-50/85":"inline-flex max-w-full items-center gap-1 rounded-full border border-white/[0.1] bg-white/[0.04] px-2 py-0.5 font-sans text-2xs font-medium text-dashboard-text-muted",role:"note",title:`${a}. ${r}`,children:[(0,W.jsx)(n,{"aria-hidden":"true",className:"size-3 shrink-0"}),(0,W.jsx)("span",{"aria-hidden":"true",className:"truncate",children:o}),(0,W.jsxs)("span",{className:"sr-only",children:[a,". ",r]})]})}function zY(e){return!!e?.some(t=>t.kind==="resource_link")}function YY(e){let t=e.annotations,n=Gfe();if(!t?.length)return null;let o=t.map(r=>Tfe(r)),a=Hfe(t);return(0,W.jsx)(Se,{align:"left",content:(0,W.jsx)("ul",{className:"m-0 list-none space-y-1 p-0",children:t.map((r,i)=>(0,W.jsxs)("li",{className:"flex min-w-0 items-center gap-1.5",children:[r.icon?(0,W.jsx)(OC,{icon:r.icon}):null,(0,W.jsx)("span",{className:"min-w-0 truncate",children:o[i]})]},`${r.key}:${i}`))}),label:"Linked work",triggerClassName:"min-w-0",children:(0,W.jsx)("span",{"aria-label":`Linked work, newest first: ${o.join(", ")}`,className:"inline-flex min-w-0 max-w-full items-center",children:n?(0,W.jsx)(jfe,{annotations:a,cutoutColor:"var(--color-dashboard-surface-panel)"}):a.length<=2?(0,W.jsx)("span",{className:"inline-flex min-w-0 items-center gap-1",children:a.map(r=>(0,W.jsx)(KY,{annotation:r},r.key))}):(0,W.jsx)(Pfe,{annotations:a})})})}function jfe(e){return(0,W.jsx)("span",{className:_("relative isolate inline-flex h-[18px] items-center pr-0.5",e.className),children:e.annotations.map((t,n)=>(0,W.jsx)(JY,{annotation:t,cutoutColor:e.cutoutColor,stacked:n>0,zIndex:n+1},t.key))})}function Pfe(e){let[t,...n]=e.annotations;return!t||n.length===0?null:(0,W.jsxs)("span",{className:"isolate inline-flex h-5 min-w-0 items-center pr-0.5",children:[(0,W.jsx)(KY,{annotation:t}),n.map((o,a)=>(0,W.jsx)(JY,{annotation:o,cutoutColor:"var(--color-dashboard-surface-panel)",stacked:!0,zIndex:a+1},o.key)),(0,W.jsxs)("span",{className:"relative -ml-1.5 inline-flex h-5 min-w-7 shrink-0 items-center justify-center rounded-full border border-white/12 bg-dashboard-control px-1.5 font-mono text-2xs leading-none text-dashboard-text-muted",style:{boxShadow:"0 0 0 2px var(--color-dashboard-surface-panel)",zIndex:n.length+1},children:["+",n.length]})]})}function KY(e){return(0,W.jsxs)("span",{className:"inline-flex h-5 min-w-0 max-w-28 shrink-0 items-center gap-1 truncate rounded-full border border-white/10 bg-dashboard-control px-1.5 font-sans text-2xs leading-none text-dashboard-text-muted",children:[e.annotation.icon?(0,W.jsx)(OC,{decorative:!0,icon:e.annotation.icon,size:11}):null,(0,W.jsx)("span",{className:"min-w-0 truncate whitespace-nowrap",children:e.annotation.label})]})}function JY(e){let t=e.annotation.icon?WY[e.annotation.icon]:void 0;return(0,W.jsx)("span",{"aria-hidden":"true",className:_("relative box-border inline-flex size-[18px] shrink-0 items-center justify-center rounded-full border border-white/12 bg-dashboard-control",e.stacked&&"-ml-2"),style:{boxShadow:`0 0 0 2px ${e.cutoutColor}`,zIndex:e.zIndex},title:t?.label,children:e.annotation.icon?(0,W.jsx)(OC,{decorative:!0,icon:e.annotation.icon,size:11}):(0,W.jsx)("span",{className:"font-sans text-2xs font-semibold leading-none text-dashboard-text-muted",children:e.annotation.label.slice(0,1)})})}function Gfe(){return(0,UY.useSyncExternalStore)(e=>{if(typeof window>"u")return()=>{};let t=window.matchMedia(TY);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)},()=>typeof window<"u"&&window.matchMedia(TY).matches,()=>!1)}function Hfe(e){let t=new Set;return e.filter(n=>t.has(n.label)?!1:(t.add(n.label),!0))}function Tfe(e){return e.key.includes("/")||e.key.includes("#")?e.key:e.label}var WY={"circle-dot":{className:"text-[#3fb950]",Icon:Pg,label:"Open"},"circle-dashed":{className:"text-[#8c959f]",Icon:Mg,label:"Draft"},"circle-x":{className:"text-[#f85149]",Icon:gs,label:"Closed"},"git-merge":{className:"text-[#a371f7]",Icon:Og,label:"Merged"},"git-pull-request":{className:"text-[#3fb950]",Icon:qg,label:"Open pull request"},"triangle-alert":{className:"text-[#d29922]",Icon:to,label:"Needs attention"}};function OC(e){let t=WY[e.icon],n=e.size??11;return(0,W.jsxs)("span",{"aria-hidden":e.decorative?!0:void 0,className:_("inline-flex shrink-0 items-center justify-center leading-none",t.className),style:{width:n,height:n},title:e.decorative?void 0:t.label,children:[(0,W.jsx)(t.Icon,{"aria-hidden":"true",className:"block",size:n,strokeWidth:2.25}),e.decorative?null:(0,W.jsx)("span",{className:"sr-only",children:t.label})]})}function ZY(e){let t=e.detail?.annotations?.filter(n=>n.kind==="resource_link")??[];return t.length===0?null:(0,W.jsx)("div",{className:"flex flex-wrap gap-1.5",children:t.map(n=>(0,W.jsxs)("a",{className:"inline-flex items-center gap-1.5 rounded border border-cyan-300/15 bg-cyan-300/[0.055] px-2 py-0.5 font-sans text-2xs leading-snug text-cyan-50 no-underline",href:n.url,rel:"noreferrer",target:"_blank",title:Ufe(n),children:[n.status?(0,W.jsx)(Yfe,{status:n.status,url:n.url}):null,(0,W.jsx)("span",{children:n.label})]},`${n.plugin}:${n.key}`))})}function Ufe(e){let t=e.status?{open:"Open",draft:"Draft",closed:"Closed",merged:"Merged",warning:"Needs attention"}[e.status]:void 0;return[e.label,e.plugin,t,e.description].filter(Boolean).join(" \xB7 ")}var Ofe={open:"circle-dot",draft:"circle-dashed",closed:"circle-x",merged:"git-merge",warning:"triangle-alert"};function qfe(e){try{return/^\/[^/]+\/[^/]+\/pull\/\d+(?:\/|$)/.test(new URL(e).pathname)}catch{return!1}}function zfe(e,t){return e==="open"&&qfe(t)?"git-pull-request":Ofe[e]}function Yfe(e){return(0,W.jsx)(OC,{icon:zfe(e.status,e.url),size:12})}function qC(e){let t=e.variant??"full",n=tC(e.conversation);if(t==="compact")return!!n;let o=e.conversationId??e.conversation?.id;return!!(n||o||e.detail?.sentryConversationUrl)}function T2(e){if(!qC(e))return null;let t=e.variant??"full",n=e.conversation?.actorIdentity?.email?.trim(),o=tC(e.conversation),a=e.conversationId??e.conversation?.id,r=o?n?(0,W.jsx)(ye,{className:"font-semibold text-dashboard-text underline decoration-white/20 underline-offset-2 transition-colors hover:text-dashboard-text hover:decoration-white/60",to:hi(n),children:o}):o:null;if(t==="compact")return(0,W.jsx)("span",{className:"inline-flex min-w-0 max-w-full items-center",children:(0,W.jsx)("span",{className:"min-w-0 max-w-full truncate",children:r})});let i=e.detail?.sentryConversationUrl?(0,W.jsx)("a",{className:"text-dashboard-text no-underline hover:underline",href:e.detail.sentryConversationUrl,rel:"noreferrer",target:"_blank",children:"View in Sentry"}):null;return(0,W.jsxs)("span",{className:"inline-flex min-w-0 max-w-full flex-wrap items-center gap-x-1.5 gap-y-1",children:[r?(0,W.jsx)("span",{className:"min-w-0 max-w-full truncate",children:r}):null,a?(0,W.jsxs)("span",{className:"inline-flex min-w-0 items-center gap-x-1.5",title:a,children:[r?(0,W.jsx)("span",{className:"text-dashboard-text-muted/50",children:"\xB7"}):null,(0,W.jsx)("span",{className:"min-w-0 max-w-[18rem] truncate",children:a})]}):null,i?(0,W.jsxs)("span",{className:"inline-flex min-w-0 items-center gap-x-1.5",children:[r||a?(0,W.jsx)("span",{className:"text-dashboard-text-muted/50",children:"\xB7"}):null,i]}):null]})}function Kfe(e){return e.sourceUrl?(0,W.jsx)("a",{className:"text-dashboard-text underline decoration-white/20 underline-offset-2 transition-colors hover:decoration-white/60",href:e.sourceUrl,rel:"noreferrer",target:"_blank",children:e.label}):e.label}function Jfe(e){let t=e.sourceTask.kind==="scheduled"?"Scheduled Task":"Event Task",n=e.sourceTask.label?.trim(),o=e.sourceTask.id?.trim(),a=e.sourceTask.title?.trim(),r=o?(0,W.jsxs)(ye,{className:"text-dashboard-text underline decoration-white/20 underline-offset-2 transition-colors hover:decoration-white/60",to:DO(o),children:["Triggered by ",t]}):(0,W.jsxs)("span",{children:["Triggered by ",t]});return!n&&!a?r:(0,W.jsx)(Se,{align:"left",content:(0,W.jsxs)("span",{className:"grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1",children:[a?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)("span",{children:"Title"}),(0,W.jsx)("span",{className:"text-dashboard-text",children:a})]}):null,n?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)("span",{children:"Instruction"}),(0,W.jsx)("span",{className:"text-dashboard-text",children:n})]}):null,o?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)("span",{children:"ID"}),(0,W.jsx)("span",{className:"break-all text-dashboard-text",children:o})]}):null]}),children:r})}function VY(e){if(!e)return;let t=new Set,n;for(let o of e.events){let a=o.data;if(a.type==="turn_lifecycle"){a.state==="started"?t.add(a.turnId):t.delete(a.turnId),t.size===0&&(n=void 0);continue}if(t.size!==0){if(a.type==="turn_routed"&&t.has(a.turnId)){n=a.modelId;continue}a.type==="handoff"&&(n=a.modelId)}}return t.size>0?n:void 0}function U2(e){return XY(e).length>0}function O2(e){let t=XY(e);return t.length===0?null:(0,W.jsx)(TC,{className:"break-words text-xs leading-[1.45] text-dashboard-text-muted",items:t})}function XY(e){if(!e.conversation)return[];let t=e.variant??"full",n=e.detail?.previousCursor?void 0:e.detail,o=e.detail?.cumulativeUsage??e.conversation.cumulativeUsage,a=Pm(o),r=Gm(o),i=Tc(e.conversation,{includeId:!1}),A=e.detail?.sourceUrl??e.conversation.sourceUrl,s=vO(e.conversation),c=(e.detail?.status??e.conversation.status)==="active",d=VY(e.detail),l=e.detail?.sourceTask;return[t==="full"&&i?{content:(0,W.jsx)(Kfe,{label:i,sourceUrl:A}),key:"location"}:void 0,t==="full"&&l?{content:(0,W.jsx)(Jfe,{sourceTask:l}),key:"source-task"}:void 0,s!=="none"?{content:(0,W.jsx)(HY,{endedAt:e.conversation.lastSeenAt,label:s,startedAt:e.conversation.startedAt}),key:"duration"}:void 0,a?{content:(0,W.jsx)(GY,{compactionCount:n?n.events.filter(p=>p.data.type==="compaction").length:void 0,live:c,liveModelId:d,modelUsage:e.detail?.modelUsage,summary:a}),key:"tokens"}:void 0,r||e.detail?.auxiliaryCosts||e.conversation.auxiliaryCosts||c?{content:(0,W.jsx)(PY,{auxiliaryCosts:e.detail?.auxiliaryCosts??e.conversation.auxiliaryCosts,live:c,liveModelId:d,modelUsage:e.detail?.modelUsage,summary:r}),key:"cost"}:void 0].filter(p=>p!==void 0)}var ke=C(E(),1),Wfe=e=>e.key;function eK(e){let[t,n]=(0,nu.useState)(),[o,a]=(0,nu.useState)(),r=(0,nu.useCallback)(()=>n(void 0),[]),i=Zfe(RY(e.conversations,{nowMs:Date.now(),timeZone:e.timeZone}));return(0,ke.jsxs)("aside",{className:"relative grid h-full min-h-0 min-w-0 grid-rows-[auto_auto_minmax(0,1fr)] overflow-hidden border-r border-white/[0.07] bg-white/[0.02]",children:[(0,ke.jsx)("div",{className:"px-3 pb-2 pt-3",children:(0,ke.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,ke.jsx)("h2",{className:"m-0 font-display text-lg font-medium leading-tight text-dashboard-text",children:"Conversations"}),(0,ke.jsx)("button",{"aria-label":"New conversation",className:"grid size-7 cursor-pointer place-items-center rounded-md text-dashboard-text-muted transition hover:bg-white/[0.05] hover:text-dashboard-text focus:outline-none focus:ring-2 focus:ring-cyan-300/35",onClick:e.onNewConversation,title:"New conversation",type:"button",children:(0,ke.jsx)(eo,{"aria-hidden":"true",size:15})})]})}),(0,ke.jsx)("div",{className:"px-2 pb-2",children:(0,ke.jsx)(ga,{label:"Search your conversations",onChange:e.onQueryChange,placeholder:"Search conversations\u2026",size:"compact",value:e.query})}),(0,ke.jsx)("div",{className:"min-h-0 overflow-y-auto overscroll-contain px-1.5 pb-[max(0.5rem,env(safe-area-inset-bottom))]",children:e.error?(0,ke.jsx)("div",{className:"p-2",children:(0,ke.jsx)(cn,{children:e.error})}):(0,ke.jsx)(SY,{ariaLabel:"Your conversations",className:"grid gap-0.5",empty:e.loading?void 0:(0,ke.jsx)("div",{className:"p-2",children:(0,ke.jsx)(cn,{children:"No conversations match this view."})}),getKey:Wfe,items:i,renderItem:A=>A.kind==="section"?(0,ke.jsx)("h3",{className:_("m-0 px-2.5 pb-0.5 font-display text-2xs font-semibold uppercase tracking-[0.08em] text-dashboard-text-muted/55",A.first?"pt-1.5":"pt-4"),children:A.label}):(0,ke.jsx)(Vfe,{conversation:A.conversation,onArchiveError:a,onArchived:s=>{a(c=>c?.id===s.id?void 0:c),n(s)},selected:A.conversation.id===e.selectedId}),role:"navigation"})}),t||o?(0,ke.jsxs)("div",{className:"absolute bottom-[max(0.75rem,env(safe-area-inset-bottom))] left-3 right-3 z-20 grid gap-2",children:[o?(0,ke.jsx)(Xfe,{conversation:o,onDismiss:()=>a(void 0)}):null,t?(0,ke.jsx)(ebe,{conversation:t,onRestored:r},t.id):null]}):null]})}function Zfe(e){return e.flatMap((t,n)=>[{first:n===0,key:`section-${t.key}`,kind:"section",label:t.label},...t.conversations.map(o=>({conversation:o,key:`conversation-${o.id}`,kind:"conversation"}))])}function Vfe(e){let t=rf(e.conversation.id,{onError:()=>e.onArchiveError(e.conversation),onSuccess:s=>{s&&e.onArchived(e.conversation)}}),n=nC(e.conversation),o=Tc(e.conversation,{includeId:!1}),a=Cs(e.conversation),r=!!e.conversation.sidebarAnnotations?.length,i=!!o&&!r,A=i||e.conversation.visibility==="private"||r;return(0,ke.jsxs)("div",{className:"group relative min-w-0",children:[(0,ke.jsxs)(ye,{"aria-current":e.selected?"page":void 0,className:_("block min-w-0 rounded-md px-2.5 py-1.5 text-inherit no-underline transition-colors hover:bg-white/[0.04]",e.selected&&"bg-white/[0.06]"),to:Wo(e.conversation.id),children:[(0,ke.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",children:[n==="active"?(0,ke.jsx)(xY,{className:"size-1.5"}):(0,ke.jsx)("span",{"aria-hidden":"true",className:_("size-1.5 shrink-0 rounded-full",n==="failed"&&"bg-rose-300",n==="idle"&&"bg-white/25")}),(0,ke.jsx)("div",{className:"truncate font-display text-sm font-medium leading-snug text-dashboard-text",children:a})]}),A?(0,ke.jsxs)("div",{className:"ml-3 mt-0.5 flex min-w-0 items-center gap-1.5 font-mono text-2xs leading-tight text-dashboard-text-muted",children:[e.conversation.visibility==="private"?(0,ke.jsx)(Zn,{"aria-label":"Private conversation",className:"size-3 shrink-0"}):null,i?(0,ke.jsx)("span",{className:"truncate",children:o}):null,(0,ke.jsx)(YY,{annotations:e.conversation.sidebarAnnotations})]}):null]}),(0,ke.jsx)("button",{"aria-label":`Archive ${a}`,className:"pointer-events-none absolute right-1.5 top-1/2 z-10 grid size-7 -translate-y-1/2 cursor-pointer place-items-center rounded-md bg-[#111719] text-dashboard-text-muted opacity-0 shadow-[-8px_0_12px_rgba(9,12,14,0.8)] transition hover:text-dashboard-text focus:pointer-events-auto focus:opacity-100 focus:outline-none focus:ring-2 focus:ring-cyan-300/35 group-focus-within:pointer-events-auto group-focus-within:opacity-100 group-hover:pointer-events-auto group-hover:opacity-100 disabled:cursor-not-allowed",disabled:t.isPending,onClick:()=>t.mutate({archived:!0,lastSeenAt:e.conversation.lastSeenAt}),title:`Archive ${a}`,type:"button",children:(0,ke.jsx)(hc,{"aria-hidden":"true",size:14})})]})}function Xfe(e){let t=Cs(e.conversation);return(0,ke.jsx)($2,{action:(0,ke.jsx)(M2,{onClick:e.onDismiss,title:"Dismiss",tone:"error",children:"Dismiss"}),detail:t,icon:xa,title:"Could not archive",tone:"error"})}function ebe(e){let t=rf(e.conversation.id,{onSuccess:o=>{o||e.onRestored()}}),n=Cs(e.conversation);return(0,nu.useEffect)(()=>{if(t.isPending||t.error)return;let o=window.setTimeout(e.onRestored,6e3);return()=>window.clearTimeout(o)},[e.conversation.id,e.onRestored,t.error,t.isPending]),(0,ke.jsx)($2,{action:(0,ke.jsx)(M2,{"aria-label":`Undo archive for ${n}`,disabled:t.isPending,onClick:()=>t.mutate({archived:!1,lastSeenAt:e.conversation.lastSeenAt}),title:`Undo archive for ${n}`,children:t.isPending?"Restoring\u2026":"Undo"}),detail:n,icon:bc,title:"Conversation archived",children:t.error?(0,ke.jsx)("div",{className:"border-t border-rose-300/25 bg-rose-400/[0.12] px-3 py-2 font-mono text-xs text-rose-50/85",role:"alert",children:"Could not restore the conversation."}):null})}var aa=C(z(),1);var sr=C(E(),1),tbe=112,tK="(min-width: 768px)",nbe="junior:dashboard:conversation-draft:",abe=250;function obe(e,t){return t===e.lastSubmittedText?e:{idempotencyKey:crypto.randomUUID(),lastSubmittedText:t}}var KC=(0,aa.memo)(function(t){let n=`${nbe}${encodeURIComponent(t.draftId)}`,[o,a]=(0,aa.useState)(()=>rbe(n)),[r,i]=(0,aa.useState)(!1),A=dy(),s=o.text,c=(0,aa.useId)(),d=(0,aa.useRef)(null),l=(0,aa.useRef)(o),g=(0,aa.useRef)({idempotencyKey:o.idempotencyKey,lastSubmittedText:o.lastSubmittedText}),p=(0,aa.useRef)(!1),m=(0,aa.useRef)(0),h=!!t.disabled||t.restoreDraftOnError&&r;l.current=o,(0,aa.useEffect)(()=>{let b=window.setTimeout(()=>{zC(n,l.current)},abe);return()=>window.clearTimeout(b)},[o,n]),(0,aa.useEffect)(()=>()=>{zC(n,l.current)},[n]),(0,aa.useEffect)(()=>{let b=d.current;if(!b)return;let y=()=>{if(window.matchMedia(tK).matches){b.style.height&&(b.style.height="");return}let Q=b.style.height;b.style.height="auto";let D=`${Math.min(b.scrollHeight,tbe)}px`;if(Q===D){b.style.height=Q;return}b.style.height=D};y();let w=window.matchMedia(tK);return w.addEventListener("change",y),()=>w.removeEventListener("change",y)},[s]);let B=async b=>{b?.preventDefault();let y=s.trim();if(!y||!A||p.current||h)return;let w=obe(g.current,y);g.current=w;let Q=++m.current,R={...w,text:y},D=YC(),F={...D,text:""};l.current=F,a(F),zC(n,F),g.current=D,p.current=!0,t.restoreDraftOnError&&i(!0),t.onSubmitStart?.(),d.current?.focus({preventScroll:!0}),t.restoreDraftOnError||queueMicrotask(()=>{p.current=!1});try{await t.onSubmit(y,w.idempotencyKey)}catch{if(!t.restoreDraftOnError||Q!==m.current||l.current.text)return;l.current=R,g.current=w,a(R),zC(n,R)}finally{t.restoreDraftOnError&&Q===m.current&&(p.current=!1,i(!1))}},f=b=>{b.key==="Enter"&&!b.shiftKey&&(b.preventDefault(),B())};return(0,sr.jsxs)("div",{className:"grid min-w-0 gap-1.5",children:[!A||t.error?(0,sr.jsx)("div",{"aria-live":"polite",className:A?"min-w-0 font-mono text-xs leading-relaxed text-red-300/80":"min-w-0 font-mono text-xs leading-relaxed text-amber-100/80",children:A?t.error:"Connect to send. Your draft is saved."}):null,(0,sr.jsxs)("form",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-end overflow-hidden rounded-lg border border-white/[0.09] bg-white/[0.035] focus-within:border-cyan-300/35 focus-within:ring-1 focus-within:ring-cyan-300/25 md:block",onSubmit:B,children:[(0,sr.jsx)("label",{className:"sr-only",htmlFor:c,children:t.label}),(0,sr.jsx)("textarea",{className:"min-h-11 max-h-28 w-full resize-none overflow-y-auto border-0 bg-transparent px-3 py-2.5 font-mono text-sm leading-relaxed text-dashboard-text outline-none placeholder:text-dashboard-text-muted/65 md:min-h-24 md:max-h-none md:resize-y md:overflow-visible md:px-3.5 md:py-3",id:c,maxLength:32e3,onChange:b=>{let y=b.target.value;a(w=>{if(w.text===y)return w;let Q={...w,text:y};return l.current=Q,Q})},onFocus:t.onFocus,onKeyDown:f,placeholder:"Message Junior\u2026",ref:d,rows:1,value:s}),(0,sr.jsxs)("div",{className:"flex min-w-0 items-center justify-end gap-3 border-l border-white/[0.07] bg-black/15 px-2 py-1.5 md:justify-between md:border-l-0 md:border-t md:px-3 md:py-2",children:[(0,sr.jsx)("div",{className:"hidden min-w-0 font-mono text-xs leading-relaxed text-dashboard-text-muted md:block",children:"Enter to send \xB7 Shift+Enter for a new line"}),(0,sr.jsxs)(wt,{"aria-label":h?"Sending message":t.submitLabel,disabled:!s.trim()||!A||h,title:A?h?"Sending message":t.submitLabel:"Connect to send",type:"submit",children:[(0,sr.jsx)(Ic,{"aria-hidden":"true",size:14}),(0,sr.jsx)("span",{className:"hidden md:inline",children:h?"Sending\u2026":t.submitLabel})]})]})]})]})});function YC(){return{idempotencyKey:crypto.randomUUID(),lastSubmittedText:"",text:""}}function rbe(e){if(typeof window>"u")return YC();try{let t=window.localStorage.getItem(e);if(!t)return YC();let n=JSON.parse(t);if(typeof n=="object"&&n!==null&&"idempotencyKey"in n&&typeof n.idempotencyKey=="string"&&"text"in n&&typeof n.text=="string"){let o=n.text.slice(0,32e3),a="lastSubmittedText"in n&&typeof n.lastSubmittedText=="string"?n.lastSubmittedText:o.trim();return{idempotencyKey:n.idempotencyKey,lastSubmittedText:a,text:o}}}catch{}return YC()}function zC(e,t){if(!(typeof window>"u"))try{t.text?window.localStorage.setItem(e,JSON.stringify(t)):window.localStorage.removeItem(e)}catch{}}var oa=C(z(),1);var ibe=u.object({memories:u.array(u.object({id:u.string(),content:u.string(),observedAtMs:u.number(),scope:u.enum(["personal","conversation"]),kind:u.enum(["preference","procedure","knowledge"])}).strict())}).strict();function JC(e){if(e.pluginName!=="memory"||e.kind!=="recall"||e.version!==1)return;let t=ibe.safeParse(e.content);return t.success?t.data:void 0}function WC(e,t){if(e.previousCursor)throw new Error("Cannot export a partial conversation transcript");let n=[];return n.push(`# ${ml(fbe(e,t))}`,""),Pt(n,"Conversation ID",oK(e.conversationId)),Pt(n,"Generated",e.generatedAt),Pt(n,"Actor",bbe(t,e)),Pt(n,"Location",hbe(t,e)),Pt(n,"Usage",[QO(e.cumulativeUsage),_O(e.cumulativeUsage,e.auxiliaryCosts)].filter(Boolean).join(" \xB7 ")),Pt(n,"Sentry conversation",e.sentryConversationUrl),n.push("","## Transcript"),Abe(n,e),Cbe(n)}function Abe(e,t){let n=fA(t);if(t.eventHistory.status==="available"){q2(e,t,n,!1);return}if(t.eventHistory.status==="redacted"&&n.length){e.push("","Transcript hidden because this conversation is not public."),q2(e,t,n,!0);return}if(n.length){q2(e,t,n,!1);return}e.push("",aC(t))}function q2(e,t,n,o){for(let a of Um(n)){if(a.kind==="message"){a.message.eventType?dbe(e,t,a.message,o):a.message.context?lbe(e,t,a.message,o):pbe(e,t,a.message,o);continue}if(a.kind==="failure"){cbe(e,t,a.outcome,a.timestamp);continue}if(a.kind==="subagent"){gbe(e,t,a.part,a.timestamp);continue}if(a.kind==="context"){ube(e,t,a.part,a.timestamp);continue}if(a.kind==="reasoning"){sbe(e,t,a.part,a.timestamp);continue}if(a.kind==="structured_event"){e.push("",`### ${a.part.presentation.title}`),Si(e,t,a.timestamp),a.part.presentation.preview&&e.push("",a.part.presentation.preview);for(let r of a.part.presentation.details??[])e.push("",`- ${r.title}`),r.description&&e.push(` ${r.description}`),r.content&&e.push("",z2(r.content,"md")),r.metadata?.length&&e.push(` ${r.metadata.join(" \xB7 ")}`);continue}if(a.kind==="attachments_delivered"){let r=a.part.attachments.length;e.push("",`### ${r===1?"1 file delivered":`${r} files delivered`}`),Si(e,t,a.timestamp);for(let i of a.part.attachments)e.push("",`- ${i.filename} (${i.contentType}, ${i.bytes} bytes)`);continue}mbe(e,t,a.part,a.timestamp)}}function sbe(e,t,n,o){e.push("","### Reasoning"),Si(e,t,o),e.push("",n.redacted?"<redacted>":n.text)}function cbe(e,t,n,o){e.push("",n==="delivery_failed"?"### Message delivery failed":"### Agent response failed"),Si(e,t,o),e.push("",n==="delivery_failed"?`${nt()} could not deliver this message to its destination.`:`The model response ended before ${nt()} could complete this turn.`)}function ube(e,t,n,o){let a=n.event;e.push("",a.type==="handoff"?"### Model handoff":"### Context compacted"),Si(e,t,o),a.type==="handoff"?(Pt(e,"Profile",a.modelProfile),Pt(e,"Model",a.modelId),Pt(e,"Reasoning",a.reasoningLevel)):(Pt(e,"Profile",a.modelProfile),Pt(e,"Model",a.modelId),a.details&&(Pt(e,"Estimated input tokens",String(a.details.estimatedInputTokens)),a.details.replacementInputTokens!==void 0&&Pt(e,"Replacement input tokens",String(a.details.replacementInputTokens)),Pt(e,"Compaction trigger",String(a.details.triggerTokens)),Pt(e,"Input limit",String(a.details.inputLimitTokens)),Pt(e,"Input messages",String(a.details.inputMessageCount)),Pt(e,"Retained messages",String(a.details.retainedMessageCount)),Pt(e,"Summary characters",String(a.details.summaryChars)))),a.summary&&e.push("","#### Continuation summary","",a.summary)}function dbe(e,t,n,o){if(e.push("",`### Event: ${ml(n.eventType??"")}`),Si(e,t,n.timestamp),o){e.push("","- <redacted>");return}let a=Vo(n);e.push("",a.trim().length?a:"_No content._")}function lbe(e,t,n,o){e.push("",`### Context from ${aK(n,t)}`),Si(e,t,n.timestamp),e.push("",o?"<redacted>":Vo(n)),o||nK(e,n.contexts)}function pbe(e,t,n,o){if(e.push("",`### ${aK(n,t)}`),Si(e,t,n.timestamp),o){e.push("",...n.parts.map(()=>"- <redacted>"));return}let a=Vo(n);e.push("",a.trim().length?a:"_No content._"),nK(e,n.contexts)}function nK(e,t){for(let n of t??[]){let o=JC(n);if(e.push("",o?"#### Recalled memories":`#### ${ml(n.kind)} context`),Pt(e,"Plugin",n.pluginName),Pt(e,"Loaded",n.loadedAt),!o){e.push("","```json",JSON.stringify(n.content,null,2),"```");continue}for(let a of o.memories)e.push("",`- ${a.content}`,` - ID: ${oK(a.id)}`,` - Observed: ${new Date(a.observedAtMs).toISOString()}`,` - Scope: ${a.scope}`,` - Kind: ${a.kind}`)}}function gbe(e,t,n,o){e.push("",`### Subagent: ${ml(n.subagentKind)}`),Si(e,t,o),Pt(e,"Status",n.status)}function mbe(e,t,n,o){e.push("",`### Tool: ${ml(n.name)}`),Si(e,t,o),Pt(e,"Status",n.status),Pt(e,"Duration",Xy(o,n.resultTimestamp)),n.input!==void 0&&e.push("","#### Arguments","",z2(Zo(n.input),"json")),n.output!==void 0&&e.push("","#### Result","",z2(Zo(n.output),"json"))}function Si(e,t,n){let o=[Bbe(n),ybe(t,n)].filter(wbe);o.length&&e.push("",`_${o.join(" - ")}_`)}function fbe(e,t){let n=e.displayTitle.trim();return n||(t?Cs(t):"Conversation")}function bbe(e,t){return Mm(e?.actorIdentity??t?.actorIdentity)??""}function hbe(e,t){return e?Tc(e)??"":t?Tc(t)??"":""}function aK(e,t){return ml(ys(t,e))}function Bbe(e){return typeof e!="number"||!Number.isFinite(e)?"":new Date(e).toISOString()}function ybe(e,t){if(typeof t!="number"||!Number.isFinite(t))return"";let n=Date.parse(e.startedAt);return!Number.isFinite(n)||t<n?"":`+${jm(t-n)}`}function Pt(e,t,n){n&&e.push(`- ${t}: ${n}`)}function ml(e){return e.replace(/\s+/g," ").trim()||"Untitled"}function oK(e){let t=e.includes("`")?"``":"`";return`${t}${e}${t}`}function z2(e,t){let n=[...e.matchAll(/`+/g)].reduce((a,r)=>Math.max(a,r[0].length),0),o="`".repeat(Math.max(3,n+1));return`${o}${t}
97
+ `),r=0;for(;r<a.length;){let i=a[r]??"",A=eq(i);if(A){n.push(A),r+=1;continue}let s=X8(i),c=V8(i);if(s||c){let l=[];for(;r<a.length&&(s?X8(a[r]??""):V8(a[r]??""));)l.push((a[r]??"").replace(s?/^\s*\d+\.\s+/:/^\s*[-*+]\s+/,"")),r+=1;n.push({items:l,ordered:s,type:"list"});continue}let d=[];for(;r<a.length&&!eq(a[r]??"")&&!X8(a[r]??"")&&!V8(a[r]??"");)d.push(a[r]??""),r+=1;n.push({lines:d,type:"paragraph"})}}return n}function eq(e){let t=/^(#{1,6})\s+(.+)$/.exec(e);if(t)return{level:t[1].length,text:t[2].trimEnd(),type:"heading"}}function V8(e){return/^\s*[-*+]\s+\S/.test(e)}function X8(e){return/^\s*\d+\.\s+\S/.test(e)}function e2(e){return Qge(e,0)}function Qge(e,t){if(!e)return[];let n=[],o=/(`+)([^`]+?)\1/g,a=0,r,i=0;for(;r=o.exec(e);)r.index>a&&n.push(...tq(e.slice(a,r.index),`${t}-${i++}`)),n.push((0,mt.jsx)("code",{className:"rounded-[0.25rem] bg-white/[0.08] px-1 py-0.5 font-mono text-[0.9em] text-cyan-50",children:(0,mt.jsx)(Me,{text:r[2]??""})},`code-${t}-${i++}`)),a=r.index+r[0].length;return a<e.length&&n.push(...tq(e.slice(a),`${t}-${i}`)),n}function tq(e,t){if(!e)return[];let n=[],o=/(\*\*|__)(.+?)\1|\*([^*]+?)\*/g,a=0,r,i=0;for(;r=o.exec(e);)r.index>a&&n.push(...hC(e.slice(a,r.index),`${t}-t-${i++}`)),n.push(r[1]?(0,mt.jsx)("strong",{className:"font-semibold text-dashboard-text",children:hC(r[2]??"",`${t}-bc-${i}`)},`${t}-b-${i++}`):(0,mt.jsx)("em",{className:"italic text-dashboard-text",children:hC(r[3]??"",`${t}-ic-${i}`)},`${t}-i-${i++}`)),a=r.index+r[0].length;return a<e.length&&n.push(...hC(e.slice(a),`${t}-t-${i}`)),n}function hC(e,t){if(!e)return[];let n=ZO(e),o=[],a=0,r=0;for(let i of n)i.start>a&&o.push((0,mt.jsx)(Me,{text:e.slice(a,i.start)},`${t}-s-${r++}`)),o.push((0,mt.jsx)(_ge,{href:i.href,children:(0,mt.jsx)(Ige,{href:i.href,label:i.label})},`${t}-a-${i.start}`)),a=i.end;return a<e.length&&o.push((0,mt.jsx)(Me,{text:e.slice(a)},`${t}-s-${r}`)),o}function Ige(e){let t=vn(),n=t.active&&e.href.toLowerCase().includes(t.normalizedQuery),o=e.label.toLowerCase().includes(t.normalizedQuery);return n&&!o?(0,mt.jsx)("mark",{className:"rounded-[2px] bg-amber-400/20 px-0.5 text-inherit not-italic",title:`Matched URL: ${e.href}`,children:e.label}):(0,mt.jsx)(Me,{text:e.label})}function _ge(e){let t=/^https?:/i.test(e.href);return(0,mt.jsx)("a",{className:WO,href:e.href,rel:t?"noreferrer":void 0,target:t?"_blank":void 0,children:e.children})}var BC=C(E(),1);function er(e){let t=Hc(e.role??""),n=RO(e.text);return(0,BC.jsx)("div",{className:"grid min-w-0 gap-2",children:n.map((o,a)=>o.language==="markdown"&&!o.fenced?(0,BC.jsx)(Om,{compact:t==="assistant"||t==="user",text:o.code},a):(0,BC.jsx)(Qs,{code:o.code,language:o.language},a))})}var xt=C(E(),1);function aq(e){let t=e.record?.id;if((0,nq.useEffect)(()=>{t&&e.action.reset()},[t]),!e.record)return null;let{record:n}=e,o=qm(n,"Type"),a=qm(n,"Learned"),r=qm(n,"Remembered"),i=qm(n,"Source"),A=qm(n,"Visibility"),s=A==="Public",c=a==="Automatic"?`Junior learned this from a ${i} conversation on ${zm(r)}.`:a==="Explicit"?s?`Someone asked Junior to remember this on ${zm(r)}.`:`You asked Junior to remember this on ${zm(r)}.`:`Junior recorded this on ${zm(r)}.`,d=s?`It is stored as workspace ${o.toLowerCase()} for future channels.`:`It is stored as a ${o.toLowerCase()} for future conversations.`,l=(n.metadata??[]).filter(m=>!["Learned","Source","Memory ID"].includes(m.label)),g=n.actions?.find(m=>m.tone==="danger"),p="memory-details-drawer-title";return(0,xt.jsx)(ks,{closeLabel:"Close memory details",dismissLabel:"Dismiss memory details",header:(0,xt.jsxs)(xt.Fragment,{children:[(0,xt.jsx)("h2",{className:"m-0 font-display text-lg font-medium tracking-normal text-dashboard-text",id:p,children:"What Junior remembers"}),(0,xt.jsxs)("div",{className:"mt-1 break-words font-mono text-xs leading-snug text-dashboard-text-muted",children:[o," \xB7 ",A," \xB7 ",zm(r)]})]}),onClose:e.onClose,openKey:n.id,titleId:p,children:(0,xt.jsxs)("section",{className:"grid gap-5",children:[(0,xt.jsxs)("div",{children:[(0,xt.jsx)("div",{className:"mb-2 font-mono text-xs uppercase tracking-[0.12em] text-dashboard-text-muted",children:"Memory"}),(0,xt.jsx)(er,{text:n.title}),n.description?(0,xt.jsx)("div",{className:"mt-3",children:(0,xt.jsx)(er,{text:n.description})}):null]}),(0,xt.jsxs)("div",{className:"flex items-start gap-3 rounded border border-cyan-300/12 bg-cyan-300/[0.035] p-3",children:[(0,xt.jsx)(dA,{"aria-hidden":"true",className:"mt-0.5 shrink-0 text-cyan-200/70",size:15}),(0,xt.jsxs)("div",{children:[(0,xt.jsx)("div",{className:"font-mono text-xs uppercase tracking-[0.12em] text-cyan-200/65",children:"Why Junior remembers this"}),(0,xt.jsxs)("div",{className:"mt-1 font-mono text-xs leading-relaxed text-dashboard-text",children:[c," ",d]})]})]}),l.length?(0,xt.jsx)(mC,{children:l.map(m=>(0,xt.jsx)(Yc,{label:m.label,valueClassName:"font-mono",children:m.value},m.label))}):null,g?(0,xt.jsxs)("button",{className:"inline-flex w-fit cursor-pointer items-center gap-2 rounded border border-rose-300/15 bg-rose-300/[0.035] px-3 py-2 font-mono text-xs uppercase tracking-[0.08em] text-rose-200/75 transition-colors hover:border-rose-300/30 hover:bg-rose-300/[0.07] hover:text-rose-100",disabled:e.action.isPending,onClick:()=>{g.confirmation&&!window.confirm(g.confirmation)||(e.onClose(),e.onAction({...g,confirmation:void 0}))},type:"button",children:[(0,xt.jsx)(Ir,{"aria-hidden":"true",size:13}),"Forget this memory"]}):s?(0,xt.jsxs)("div",{className:"inline-flex w-fit items-center gap-2 rounded border border-white/[0.08] px-3 py-2 font-mono text-xs uppercase tracking-[0.08em] text-dashboard-text-muted",children:[(0,xt.jsx)(Wn,{"aria-hidden":"true",size:13}),"View only \xB7 public memories can't be deleted"]}):null]})})}function qm(e,t){return e.metadata?.find(n=>n.label===t)?.value??"\u2014"}function zm(e){return e.split(",").slice(0,2).join(",")}var Rr=C(z(),1);var jn=C(E(),1);function Bn(e,t){let n=t?.width??960,o=t?.left??56,a=t?.right??18,r=t?.top??24,i=t?.bottom??36;return{bottom:i,height:e,left:o,plotHeight:e-r-i,plotWidth:n-o-a,right:a,top:r,width:n}}function We(e){return new Date(`${e}T00:00:00.000Z`).toLocaleDateString(void 0,{day:"numeric",month:"short",timeZone:"UTC"})}function oq(e){return[...new Set([0,Math.floor((e-1)/2),e-1])].filter(t=>t>=0)}var rq=11,t2=(0,Rr.createContext)(1),vge="fill-white/50 font-mono leading-none text-dashboard-text-muted";function Ym(e){let{children:t,...n}=e,o=(0,Rr.useContext)(t2);return(0,jn.jsx)("text",{className:vge,fontSize:rq/o,...n,children:t})}function iq(e){return(0,jn.jsx)("span",{className:_("font-mono text-2xs leading-none text-dashboard-text-muted",e.className),style:e.style,children:e.children})}function yn(e){let t=(0,Rr.useRef)(null),[n,o]=(0,Rr.useState)(1);return(0,Rr.useLayoutEffect)(()=>{let a=t.current;if(!a)return;let r=()=>{let A=a.getScreenCTM(),s=A?Math.hypot(A.a,A.b):1;o(s>0?s:1)};r();let i=new ResizeObserver(r);return i.observe(a),()=>i.disconnect()},[]),(0,jn.jsx)(t2,{value:n,children:(0,jn.jsx)("svg",{"aria-label":e["aria-label"],className:_("block h-auto w-full",e.className),ref:t,role:"img",viewBox:`0 0 ${e.layout.width} ${e.layout.height}`,children:e.children})})}function Pn(e){let t=e.format??(n=>String(Math.round(n)));return[0,.5,1].map(n=>{let o=e.layout.top+n*e.layout.plotHeight;return(0,jn.jsxs)("g",{children:[(0,jn.jsx)("line",{stroke:"rgba(255,255,255,0.07)",strokeDasharray:"3 5",x1:e.layout.left,x2:e.layout.width-e.layout.right,y1:o,y2:o}),(0,jn.jsx)(Ym,{textAnchor:"end",x:e.layout.left-8,y:o+3,children:t(e.maximum*(1-n))})]},n)})}function Gn(e){let t=e.formatDate??We;return oq(e.dates.length).map(n=>{let o=e.dates[n];return o?(0,jn.jsx)(Ym,{textAnchor:n===0?"start":n===e.dates.length-1?"end":"middle",x:e.xPosition(n),y:e.layout.height-8,children:t(o)},o):null})}function Aq(e){let t=e.formatLabel??(n=>n);return oq(e.categories.length).map(n=>{let o=e.categories[n];return o?(0,jn.jsx)(Ym,{textAnchor:"middle",x:e.xPosition(n),y:e.layout.height-8,children:t(o.label)},o.id):null})}function tr(e){return e.length===0?0:e.reduce((t,n)=>t+n,0)/e.length}var xge="fill-white font-mono leading-none",Dge="rgba(9, 12, 14, 0.92)";function nr(e){let t=(0,Rr.useContext)(t2);if(!(e.average>0)||!(e.maximum>0))return null;let n=e.unit??"day",o=e.format(e.average).trim();if(!o||/^\$?0(?:\.0+)?(?:ms)?$/i.test(o))return null;let a=e.layout.top+e.layout.plotHeight-e.average/e.maximum*e.layout.plotHeight,r=e.layout.left,i=e.layout.width-e.layout.right,A=`${o} / ${n}`,s=rq/t,c=Math.max(52,A.length*s*.68),d=5,g=s+3*2,p=c+d*2,m=i-p,B=a-e.layout.top>g+4?a-g-3:a+4,f=B+g/2+s*.35,b=Math.max(r,m-6);return(0,jn.jsxs)("g",{"aria-label":`average ${A}`,pointerEvents:"none",children:[(0,jn.jsx)("line",{stroke:e.stroke??"rgba(255,255,255,0.55)",strokeDasharray:"4 4",strokeOpacity:.85,strokeWidth:1.25,x1:r,x2:b,y1:a,y2:a}),(0,jn.jsx)("rect",{fill:Dge,height:g,rx:3,width:p,x:m,y:B}),(0,jn.jsx)("text",{className:xge,fill:"#ffffff",fontSize:s,textAnchor:"middle",x:m+p/2,y:f,children:A})]})}function Cn(e){return(0,jn.jsx)("div",{className:"grid grid-cols-[auto_auto] gap-x-4 gap-y-0.5",children:e.rows.flatMap(([t,n],o)=>[(0,jn.jsx)("span",{className:"text-dashboard-text-muted",children:t},`${o}-label`),(0,jn.jsx)("span",{className:"text-right text-dashboard-text",children:n},`${o}-value`)])})}var Ei=C(E(),1);function ma(e){return(0,Ei.jsx)("ul",{"aria-label":e.ariaLabel,className:_("m-0 flex list-none flex-wrap gap-x-4 gap-y-1 p-0 font-mono text-2xs text-dashboard-text-muted",!e.inline&&"mt-4"),children:e.items.map(t=>(0,Ei.jsxs)("li",{className:"flex items-center whitespace-nowrap",children:[(0,Ei.jsx)("i",{"aria-hidden":"true",className:"mr-1.5 block size-2 shrink-0 rounded-full",style:{backgroundColor:t.color}}),(0,Ei.jsxs)("span",{children:[t.label,t.value!==void 0?(0,Ei.jsxs)(Ei.Fragment,{children:[" ",(0,Ei.jsx)("span",{"aria-hidden":"true",children:"\xB7"})," ",t.value]}):null]})]},t.key))})}var sn=C(z(),1);var Fge=Object.defineProperty,rl=(e,t)=>Fge(e,"name",{value:t,configurable:!0}),sq=!!(typeof window<"u"&&window.document&&window.document.createElement);function Ra(e,t,{checkForDefaultPrevented:n=!0}={}){return rl(function(a){if(e?.(a),n===!1||!a||!a.defaultPrevented)return t?.(a)},"handleEvent")}rl(Ra,"composeEventHandlers");function Sge(e){if(!sq)throw new Error("Cannot access window outside of the DOM");return e?.ownerDocument?.defaultView??window}rl(Sge,"getOwnerWindow");function n2(e){if(!sq)throw new Error("Cannot access document outside of the DOM");return e?.ownerDocument??document}rl(n2,"getOwnerDocument");function cq(e,t=!1){let{activeElement:n}=n2(e);if(!n?.nodeName)return null;if(uq(n)&&n.contentDocument)return cq(n.contentDocument.body,t);if(t){let o=n.getAttribute("aria-activedescendant");if(o){let a=n2(n).getElementById(o);if(a)return a}}return n}rl(cq,"getActiveElement");function uq(e){return e.tagName==="IFRAME"}rl(uq,"isFrame");var or=C(z(),1),a2=C(E(),1),Lge=Object.defineProperty,ar=(e,t)=>Lge(e,"name",{value:t,configurable:!0});function Rge(e,t){let n=or.createContext(t);n.displayName=e+"Context";let o=ar(r=>{let{children:i,...A}=r,s=or.useMemo(()=>A,Object.values(A));return(0,a2.jsx)(n.Provider,{value:s,children:i})},"Provider");o.displayName=e+"Provider";function a(r,i={}){let{optional:A=!1}=i,s=or.useContext(n);if(s)return s;if(t!==void 0)return t;if(!A)throw new Error(`\`${r}\` must be used within \`${e}\``)}return ar(a,"useContext"),[o,a]}ar(Rge,"createContext");function Km(e,t=[]){let n=[];function o(r,i){let A=or.createContext(i);A.displayName=r+"Context";let s=n.length;n=[...n,i];let c=ar(l=>{let{scope:g,children:p,...m}=l,h=g?.[e]?.[s]||A,B=or.useMemo(()=>m,Object.values(m));return(0,a2.jsx)(h.Provider,{value:B,children:p})},"Provider");c.displayName=r+"Provider";function d(l,g,p={}){let{optional:m=!1}=p,h=g?.[e]?.[s]||A,B=or.useContext(h);if(B)return B;if(i!==void 0)return i;if(!m)throw new Error(`\`${l}\` must be used within \`${r}\``)}return ar(d,"useContext"),[c,d]}ar(o,"createContext");let a=ar(()=>{let r=n.map(i=>or.createContext(i));return ar(function(A){let s=A?.[e]||r;return or.useMemo(()=>({[`__scope${e}`]:{...A,[e]:s}}),[A,s])},"useScope")},"createScope");return a.scopeName=e,[o,dq(a,...t)]}ar(Km,"createContextScope");function dq(...e){let t=e[0];if(e.length===1)return t;let n=ar(()=>{let o=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return ar(function(r){let i=o.reduce((A,{useScope:s,scopeName:c})=>{let l=s(r)[`__scope${c}`];return{...A,...l}},{});return or.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])},"useComposedScopes")},"createScope");return n.scopeName=t.scopeName,n}ar(dq,"composeContextScopes");var rr=C(z(),1);var yC=!1;var lq=C(z(),1),Na=globalThis?.document?lq.useLayoutEffect:()=>{};var Nr=C(z(),1);var il=C(z(),1),Nge=Object.defineProperty,$ge=(e,t)=>Nge(e,"name",{value:t,configurable:!0}),pq=il[" useEffectEvent ".trim().toString()],gq=il[" useInsertionEffect ".trim().toString()];function o2(e){if(typeof pq=="function")return pq(e);let t=il.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof gq=="function"?gq(()=>{t.current=e}):Na(()=>{t.current=e}),il.useMemo(()=>((...n)=>t.current?.(...n)),[])}$ge(o2,"useEffectEvent");var Mge=Object.defineProperty,Jm=(e,t)=>Mge(e,"name",{value:t,configurable:!0}),jge=rr[" useInsertionEffect ".trim().toString()]||Na;function r2({prop:e,defaultProp:t,onChange:n=Jm(()=>{},"onChange"),caller:o}){let[a,r,i]=fq({defaultProp:t,onChange:n}),A=e!==void 0,s=A?e:a;if(yC){let d=rr.useRef(e!==void 0);rr.useEffect(()=>{let l=d.current;l!==A&&console.warn(`${o} is changing from ${l?"controlled":"uncontrolled"} to ${A?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=A},[A,o])}let c=rr.useCallback(d=>{if(A){let l=bq(d)?d(e):d;l!==e&&i.current?.(l)}else r(d)},[A,e,r,i]);return[s,c]}Jm(r2,"useControllableState");function fq({defaultProp:e,onChange:t}){let[n,o]=rr.useState(e),a=rr.useRef(n),r=rr.useRef(t);return jge(()=>{r.current=t},[t]),rr.useEffect(()=>{a.current!==n&&(r.current?.(n),a.current=n)},[n,a]),[n,o,r]}Jm(fq,"useUncontrolledState");function bq(e){return typeof e=="function"}Jm(bq,"isFunction");var mq=Symbol("RADIX:SYNC_STATE");function Pge(e,t,n,o){let{prop:a,defaultProp:r,onChange:i,caller:A}=t,s=a!==void 0,c=o2(i);if(yC){let B=Nr.useRef(a!==void 0);Nr.useEffect(()=>{let f=B.current;f!==s&&console.warn(`${A} is changing from ${f?"controlled":"uncontrolled"} to ${s?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),B.current=s},[s,A])}let d=[{...n,state:r}];o&&d.push(o);let[l,g]=Nr.useReducer((B,f)=>{if(f.type===mq)return{...B,state:f.state};let b=e(B,f);return s&&!Object.is(b.state,B.state)&&c(b.state),b},...d),p=l.state,m=Nr.useRef(p);Nr.useEffect(()=>{m.current!==p&&(m.current=p,s||c(p))},[p,m,s]);let h=Nr.useMemo(()=>a!==void 0?{...l,state:a}:l,[l,a]);return Nr.useEffect(()=>{s&&!Object.is(a,l.state)&&g({type:mq,state:a})},[a,l.state,s]),[h,g]}Jm(Pge,"useControllableStateReducer");var hq=C(z(),1),Gge=Object.defineProperty,A2=(e,t)=>Gge(e,"name",{value:t,configurable:!0});function i2(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}A2(i2,"setRef");function Bq(...e){return t=>{let n=!1,o=e.map(a=>{let r=i2(a,t);return!n&&typeof r=="function"&&(n=!0),r});if(n)return()=>{for(let a=0;a<o.length;a++){let r=o[a];typeof r=="function"?r():i2(e[a],null)}}}}A2(Bq,"composeRefs");function ki(...e){return hq.useCallback(Bq(...e),e)}A2(ki,"useComposedRefs");var fa=C(z(),1);var wq=["top","right","bottom","left"];var Qi=Math.min,$r=Math.max,Zm=Math.round,Vm=Math.floor,Ii=e=>({x:e,y:e}),Hge={left:"right",right:"left",bottom:"top",top:"bottom"};function s2(e,t,n){return $r(e,Qi(t,n))}function _i(e,t){return typeof e=="function"?e(t):e}function hA(e){return e.split("-")[0]}function Kc(e){return e.split("-")[1]}function wC(e){return e==="x"?"y":"x"}function EC(e){return e==="y"?"height":"width"}function Mr(e){let t=e[0];return t==="t"||t==="b"?"y":"x"}function kC(e){return wC(Mr(e))}function Eq(e,t,n){n===void 0&&(n=!1);let o=Kc(e),a=kC(e),r=EC(a),i=a==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[r]>t.floating[r]&&(i=Wm(i)),[i,Wm(i)]}function kq(e){let t=Wm(e);return[CC(e),t,CC(t)]}function CC(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}var yq=["left","right"],Cq=["right","left"],Tge=["top","bottom"],Uge=["bottom","top"];function Oge(e,t,n){switch(e){case"top":case"bottom":return n?t?Cq:yq:t?yq:Cq;case"left":case"right":return t?Tge:Uge;default:return[]}}function Qq(e,t,n,o){let a=Kc(e),r=Oge(hA(e),n==="start",o);return a&&(r=r.map(i=>i+"-"+a),t&&(r=r.concat(r.map(CC)))),r}function Wm(e){let t=hA(e);return Hge[t]+e.slice(t.length)}function qge(e){var t,n,o,a;return{top:(t=e.top)!=null?t:0,right:(n=e.right)!=null?n:0,bottom:(o=e.bottom)!=null?o:0,left:(a=e.left)!=null?a:0}}function c2(e){return typeof e!="number"?qge(e):{top:e,right:e,bottom:e,left:e}}function Jc(e){let{x:t,y:n,width:o,height:a}=e;return{width:o,height:a,top:n,left:t,right:t+o,bottom:n+a,x:t,y:n}}function Iq(e,t,n){let{reference:o,floating:a}=e,r=Mr(t),i=kC(t),A=EC(i),s=hA(t),c=r==="y",d=o.x+o.width/2-a.width/2,l=o.y+o.height/2-a.height/2,g=o[A]/2-a[A]/2,p;switch(s){case"top":p={x:d,y:o.y-a.height};break;case"bottom":p={x:d,y:o.y+o.height};break;case"right":p={x:o.x+o.width,y:l};break;case"left":p={x:o.x-a.width,y:l};break;default:p={x:o.x,y:o.y}}let m=Kc(t);return m&&(p[i]+=g*(m==="end"?1:-1)*(n&&c?-1:1)),p}async function xq(e,t){var n;t===void 0&&(t={});let{x:o,y:a,platform:r,rects:i,elements:A,strategy:s}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:l="floating",altBoundary:g=!1,padding:p=0}=_i(t,e),m=c2(p),B=A[g?l==="floating"?"reference":"floating":l],f=Jc(await r.getClippingRect({element:(n=await(r.isElement==null?void 0:r.isElement(B)))==null||n?B:B.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(A.floating)),boundary:c,rootBoundary:d,strategy:s})),b=l==="floating"?{x:o,y:a,width:i.floating.width,height:i.floating.height}:i.reference,y=await(r.getOffsetParent==null?void 0:r.getOffsetParent(A.floating)),w=await(r.isElement==null?void 0:r.isElement(y))&&await(r.getScale==null?void 0:r.getScale(y))||{x:1,y:1},Q=Jc(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:A,rect:b,offsetParent:y,strategy:s}):b);return{top:(f.top-Q.top+m.top)/w.y,bottom:(Q.bottom-f.bottom+m.bottom)/w.y,left:(f.left-Q.left+m.left)/w.x,right:(Q.right-f.right+m.right)/w.x}}var zge=50,Dq=async(e,t,n)=>{let{placement:o="bottom",strategy:a="absolute",middleware:r=[],platform:i}=n,A=i.detectOverflow?i:{...i,detectOverflow:xq},s=await(i.isRTL==null?void 0:i.isRTL(t)),c=await i.getElementRects({reference:e,floating:t,strategy:a}),{x:d,y:l}=Iq(c,o,s),g=o,p=0,m={};for(let h=0;h<r.length;h++){let B=r[h];if(!B)continue;let{name:f,fn:b}=B,{x:y,y:w,data:Q,reset:R}=await b({x:d,y:l,initialPlacement:o,placement:g,strategy:a,middlewareData:m,rects:c,platform:A,elements:{reference:e,floating:t}});d=y??d,l=w??l,m[f]={...m[f],...Q},R&&p<zge&&(p++,typeof R=="object"&&(R.placement&&(g=R.placement),R.rects&&(c=R.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:a}):R.rects),{x:d,y:l}=Iq(c,g,s)),h=-1)}return{x:d,y:l,placement:g,strategy:a,middlewareData:m}},Fq=e=>({name:"arrow",options:e,async fn(t){let{x:n,y:o,placement:a,rects:r,platform:i,elements:A,middlewareData:s}=t,{element:c,padding:d=0}=_i(e,t)||{};if(c==null)return{};let l=c2(d),g={x:n,y:o},p=kC(a),m=EC(p),h=await i.getDimensions(c),B=p==="y",f=B?"top":"left",b=B?"bottom":"right",y=B?"clientHeight":"clientWidth",w=r.reference[m]+r.reference[p]-g[p]-r.floating[m],Q=g[p]-r.reference[p],R=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c)),D=R?R[y]:0;(!D||!await(i.isElement==null?void 0:i.isElement(R)))&&(D=A.floating[y]||r.floating[m]);let F=w/2-Q/2,T=D/2-h[m]/2-1,O=Qi(l[f],T),ue=Qi(l[b],T),oe=D-h[m]-ue,Be=D/2-h[m]/2+F,ge=s2(O,Be,oe),ee=!s.arrow&&Kc(a)!=null&&Be!==ge&&r.reference[m]/2-(Be<O?O:ue)-h[m]/2<0,bt=ee?Be<O?Be-O:Be-oe:0;return{[p]:g[p]+bt,data:{[p]:ge,centerOffset:Be-ge-bt,...ee&&{alignmentOffset:bt}},reset:ee}}});var Sq=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,o;let{placement:a,middlewareData:r,rects:i,initialPlacement:A,platform:s,elements:c}=t,{mainAxis:d=!0,crossAxis:l=!0,fallbackPlacements:g,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:h=!0,...B}=_i(e,t);if((n=r.arrow)!=null&&n.alignmentOffset)return{};let f=hA(a),b=Mr(A),y=hA(A)===A,w=await(s.isRTL==null?void 0:s.isRTL(c.floating)),Q=g||(y||!h?[Wm(A)]:kq(A)),R=m!=="none";!g&&R&&Q.push(...Qq(A,h,m,w));let D=[A,...Q],F=await s.detectOverflow(t,B),T=[],O=((o=r.flip)==null?void 0:o.overflows)||[];if(d&&T.push(F[f]),l){let ge=Eq(a,i,w);T.push(F[ge[0]],F[ge[1]])}if(O=[...O,{placement:a,overflows:T}],!T.every(ge=>ge<=0)){var ue,oe;let ge=(((ue=r.flip)==null?void 0:ue.index)||0)+1,ee=D[ge];if(ee&&(!(l==="alignment"?b!==Mr(ee):!1)||O.every(je=>Mr(je.placement)===b?je.overflows[0]>0:!0)))return{data:{index:ge,overflows:O},reset:{placement:ee}};let bt=(oe=O.filter(Ga=>Ga.overflows[0]<=0).sort((Ga,je)=>Ga.overflows[1]-je.overflows[1])[0])==null?void 0:oe.placement;if(!bt)switch(p){case"bestFit":{var Be;let Ga=(Be=O.filter(je=>{if(R){let pn=Mr(je.placement);return pn===b||pn==="y"}return!0}).map(je=>[je.placement,je.overflows.filter(pn=>pn>0).reduce((pn,Do)=>pn+Do,0)]).sort((je,pn)=>je[1]-pn[1])[0])==null?void 0:Be[0];Ga&&(bt=Ga);break}case"initialPlacement":bt=A;break}if(a!==bt)return{reset:{placement:bt}}}return{}}}};function _q(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function vq(e){return wq.some(t=>e[t]>=0)}var Lq=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){let{rects:n,platform:o}=t,{strategy:a="referenceHidden",...r}=_i(e,t);switch(a){case"referenceHidden":{let i=await o.detectOverflow(t,{...r,elementContext:"reference"}),A=_q(i,n.reference);return{data:{referenceHiddenOffsets:A,referenceHidden:vq(A)}}}case"escaped":{let i=await o.detectOverflow(t,{...r,altBoundary:!0}),A=_q(i,n.floating);return{data:{escapedOffsets:A,escaped:vq(A)}}}default:return{}}}}};var Rq=new Set(["left","top"]);async function Yge(e,t){let{placement:n,platform:o,elements:a}=e,r=await(o.isRTL==null?void 0:o.isRTL(a.floating)),i=hA(n),A=Kc(n),s=Mr(n)==="y",c=Rq.has(i)?-1:1,d=r&&s?-1:1,l=_i(t,e),{mainAxis:g,crossAxis:p,alignmentAxis:m}=typeof l=="number"?{mainAxis:l,crossAxis:0,alignmentAxis:null}:{mainAxis:l.mainAxis||0,crossAxis:l.crossAxis||0,alignmentAxis:l.alignmentAxis};return A&&typeof m=="number"&&(p=A==="end"?m*-1:m),s?{x:p*d,y:g*c}:{x:g*c,y:p*d}}var Nq=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,o;let{x:a,y:r,placement:i,middlewareData:A}=t,s=await Yge(t,e);return i===((n=A.offset)==null?void 0:n.placement)&&(o=A.arrow)!=null&&o.alignmentOffset?{}:{x:a+s.x,y:r+s.y,data:{...s,placement:i}}}}},$q=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){let{x:n,y:o,placement:a,platform:r}=t,{mainAxis:i=!0,crossAxis:A=!1,limiter:s={fn:b=>{let{x:y,y:w}=b;return{x:y,y:w}}},...c}=_i(e,t),d={x:n,y:o},l=await r.detectOverflow(t,c),g=Mr(a),p=wC(g),m=d[p],h=d[g],B=(b,y)=>s2(y+l[b==="y"?"top":"left"],y,y-l[b==="y"?"bottom":"right"]);i&&(m=B(p,m)),A&&(h=B(g,h));let f=s.fn({...t,[p]:m,[g]:h});return{...f,data:{x:f.x-n,y:f.y-o,enabled:{[p]:i,[g]:A}}}}}},Mq=function(e){return e===void 0&&(e={}),{options:e,fn(t){var n,o;let{x:a,y:r,placement:i,rects:A,middlewareData:s}=t,{offset:c=0,mainAxis:d=!0,crossAxis:l=!0}=_i(e,t),g={x:a,y:r},p=Mr(i),m=wC(p),h=g[m],B=g[p],f=_i(c,t),b=typeof f=="number"?{mainAxis:f,crossAxis:0}:{mainAxis:(n=f.mainAxis)!=null?n:0,crossAxis:(o=f.crossAxis)!=null?o:0};if(d){let Q=m==="y"?"height":"width",R=A.reference[m]-A.floating[Q]+b.mainAxis,D=A.reference[m]+A.reference[Q]-b.mainAxis;h<R?h=R:h>D&&(h=D)}if(l){var y,w;let Q=m==="y"?"width":"height",R=Rq.has(hA(i)),D=A.reference[p]-A.floating[Q]+(R&&((y=s.offset)==null?void 0:y[p])||0)+(R?0:b.crossAxis),F=A.reference[p]+A.reference[Q]+(R?0:((w=s.offset)==null?void 0:w[p])||0)-(R?b.crossAxis:0);B<D?B=D:B>F&&(B=F)}return{[m]:h,[p]:B}}}},jq=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){let{placement:n,rects:o,platform:a,elements:r}=t,{apply:i=()=>{},...A}=_i(e,t),s=await a.detectOverflow(t,A),c=hA(n),d=Kc(n),l=Mr(n)==="y",{width:g,height:p}=o.floating,m,h;c==="top"||c==="bottom"?(m=c,h=d===(await(a.isRTL==null?void 0:a.isRTL(r.floating))?"start":"end")?"left":"right"):(h=c,m=d==="end"?"top":"bottom");let B=p-s.top-s.bottom,f=g-s.left-s.right,b=Qi(p-s[m],B),y=Qi(g-s[h],f),w=t.middlewareData.shift,Q=!w,R=b,D=y;w!=null&&w.enabled.x&&(D=f),w!=null&&w.enabled.y&&(R=B),Q&&!d&&(l?D=g-2*$r(s.left,s.right):R=p-2*$r(s.top,s.bottom)),await i({...t,availableWidth:D,availableHeight:R});let F=await a.getDimensions(r.floating);return g!==F.width||p!==F.height?{reset:{rects:!0}}:{}}}};function QC(){return typeof window<"u"}function Vc(e){return Gq(e)?(e.nodeName||"").toLowerCase():"#document"}function $a(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function vi(e){var t;return(t=(Gq(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Gq(e){return QC()?e instanceof Node||e instanceof $a(e).Node:!1}function jr(e){return QC()?e instanceof Element||e instanceof $a(e).Element:!1}function BA(e){return QC()?e instanceof HTMLElement||e instanceof $a(e).HTMLElement:!1}function Pq(e){return!QC()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof $a(e).ShadowRoot}function Xm(e){let{overflow:t,overflowX:n,overflowY:o,display:a}=Pr(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+n)&&a!=="inline"&&a!=="contents"}function Hq(e){return/^(table|td|th)$/.test(Vc(e))}function ef(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}var Kge=/transform|translate|scale|rotate|perspective|filter/,Jge=/paint|layout|strict|content/,Wc=e=>!!e&&e!=="none",u2;function IC(e){let t=jr(e)?Pr(e):e;return Wc(t.transform)||Wc(t.translate)||Wc(t.scale)||Wc(t.rotate)||Wc(t.perspective)||!_C()&&(Wc(t.backdropFilter)||Wc(t.filter))||Kge.test(t.willChange||"")||Jge.test(t.contain||"")}function Tq(e){let t=Is(e);for(;BA(t)&&!Al(t);){if(IC(t))return t;if(ef(t))return null;t=Is(t)}return null}function _C(){return u2==null&&(u2=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),u2}function Al(e){return/^(html|body|#document)$/.test(Vc(e))}function Pr(e){return $a(e).getComputedStyle(e)}function tf(e){return jr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Is(e){if(Vc(e)==="html")return e;let t=e.assignedSlot||e.parentNode||Pq(e)&&e.host||vi(e);return Pq(t)?t.host:t}function Uq(e){let t=Is(e);return Al(t)?(e.ownerDocument||e).body:BA(t)&&Xm(t)?t:Uq(t)}function Zc(e,t,n){var o;t===void 0&&(t=[]),n===void 0&&(n=!0);let a=Uq(e),r=a===((o=e.ownerDocument)==null?void 0:o.body),i=$a(a);if(r){let A=vC(i);return t.concat(i,i.visualViewport||[],Xm(a)?a:[],A&&n?Zc(A):[])}else return t.concat(a,Zc(a,[],n))}function vC(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function zq(e){let t=Pr(e),n=parseFloat(t.width)||0,o=parseFloat(t.height)||0,a=BA(e),r=a?e.offsetWidth:n,i=a?e.offsetHeight:o,A=Zm(n)!==r||Zm(o)!==i;return A&&(n=r,o=i),{width:n,height:o,$:A}}function l2(e){return jr(e)?e:e.contextElement}function sl(e){let t=l2(e);if(!BA(t))return Ii(1);let n=t.getBoundingClientRect(),{width:o,height:a,$:r}=zq(t),i=(r?Zm(n.width):n.width)/o,A=(r?Zm(n.height):n.height)/a;return(!i||!Number.isFinite(i))&&(i=1),(!A||!Number.isFinite(A))&&(A=1),{x:i,y:A}}var Wge=Ii(0);function Yq(e){let t=$a(e);return!_C()||!t.visualViewport?Wge:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Zge(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===$a(e)}function Xc(e,t,n,o){t===void 0&&(t=!1),n===void 0&&(n=!1);let a=e.getBoundingClientRect(),r=l2(e),i=Ii(1);t&&(o?jr(o)&&(i=sl(o)):i=sl(e));let A=Zge(r,n,o)?Yq(r):Ii(0),s=(a.left+A.x)/i.x,c=(a.top+A.y)/i.y,d=a.width/i.x,l=a.height/i.y;if(r&&o){let g=$a(r),p=jr(o)?$a(o):o,m=g,h=vC(m);for(;h&&p!==m;){let B=sl(h),f=h.getBoundingClientRect(),b=Pr(h),y=f.left+(h.clientLeft+parseFloat(b.paddingLeft))*B.x,w=f.top+(h.clientTop+parseFloat(b.paddingTop))*B.y;s*=B.x,c*=B.y,d*=B.x,l*=B.y,s+=y,c+=w,m=$a(h),h=vC(m)}}return Jc({width:d,height:l,x:s,y:c})}function xC(e,t){let n=tf(e).scrollLeft;return t?t.left+n:Xc(vi(e)).left+n}function Kq(e,t){let n=e.getBoundingClientRect(),o=n.left+t.scrollLeft-xC(e,n),a=n.top+t.scrollTop;return{x:o,y:a}}function Vge(e){let{elements:t,rect:n,offsetParent:o,strategy:a}=e,r=a==="fixed",i=vi(o),A=t?ef(t.floating):!1;if(o===i||A&&r)return n;let s={scrollLeft:0,scrollTop:0},c=Ii(1),d=Ii(0),l=BA(o);if((l||!r)&&((Vc(o)!=="body"||Xm(i))&&(s=tf(o)),l)){let p=Xc(o);c=sl(o),d.x=p.x+o.clientLeft,d.y=p.y+o.clientTop}let g=i&&!l&&!r?Kq(i,s):Ii(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-s.scrollLeft*c.x+d.x+g.x,y:n.y*c.y-s.scrollTop*c.y+d.y+g.y}}function Xge(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function eme(e){let t=tf(e),n=e.ownerDocument.body,o=$r(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),a=$r(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),r=-t.scrollLeft+xC(e),i=-t.scrollTop;return Pr(n).direction==="rtl"&&(r+=$r(e.clientWidth,n.clientWidth)-o),{width:o,height:a,x:r,y:i}}var tme=25;function nme(e,t,n){n===void 0&&(n="viewport");let o=n==="layoutViewport",a=$a(e),r=vi(e),i=a.visualViewport,A=r.clientWidth,s=r.clientHeight,c=0,d=0;if(i){let g=!_C()||t==="fixed";o?g||(c=-i.offsetLeft,d=-i.offsetTop):(A=i.width,s=i.height,g&&(c=i.offsetLeft,d=i.offsetTop))}if(xC(r)<=0){let g=r.ownerDocument,p=g.body,m=getComputedStyle(p),h=g.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,B=Math.abs(r.clientWidth-p.clientWidth-h),f=getComputedStyle(r).scrollbarGutter==="stable both-edges"?B/2:B;f<=tme&&(A-=f)}return{width:A,height:s,x:c,y:d}}function ame(e,t){let n=Xc(e,!0,t==="fixed"),o=n.top+e.clientTop,a=n.left+e.clientLeft,r=sl(e),i=e.clientWidth*r.x,A=e.clientHeight*r.y,s=a*r.x,c=o*r.y;return{width:i,height:A,x:s,y:c}}function Oq(e,t,n){let o;if(t==="viewport"||t==="layoutViewport")o=nme(e,n,t);else if(t==="document")o=eme(vi(e));else if(jr(t))o=ame(t,n);else{let a=Yq(e);o={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return Jc(o)}function ome(e,t){let n=t.get(e);if(n)return n;let o=Zc(e,[],!1).filter(A=>jr(A)&&Vc(A)!=="body"),a=null,r=Pr(e).position==="fixed",i=r?Is(e):e;for(;jr(i)&&!Al(i);){let A=Pr(i),s=IC(i),c=a?a.position:r?"fixed":"";!s&&(c==="fixed"||c==="absolute"&&A.position==="static")?o=o.filter(l=>l!==i):a=A,i=Is(i)}return t.set(e,o),o}function rme(e){let{element:t,boundary:n,rootBoundary:o,strategy:a}=e,i=[...n==="clippingAncestors"?ef(t)?[]:ome(t,this._c):[].concat(n),o],A=Oq(t,i[0],a),s=A.top,c=A.right,d=A.bottom,l=A.left;for(let g=1;g<i.length;g++){let p=Oq(t,i[g],a);s=$r(p.top,s),c=Qi(p.right,c),d=Qi(p.bottom,d),l=$r(p.left,l)}return{width:c-l,height:d-s,x:l,y:s}}function ime(e){let{width:t,height:n}=zq(e);return{width:t,height:n}}function Ame(e,t,n){let o=BA(t),a=vi(t),r=n==="fixed",i=Xc(e,!0,r,t),A={scrollLeft:0,scrollTop:0},s=Ii(0);if((o||!r)&&((Vc(t)!=="body"||Xm(a))&&(A=tf(t)),o)){let g=Xc(t,!0,r,t);s.x=g.x+t.clientLeft,s.y=g.y+t.clientTop}!o&&a&&(s.x=xC(a));let c=a&&!o&&!r?Kq(a,A):Ii(0),d=i.left+A.scrollLeft-s.x-c.x,l=i.top+A.scrollTop-s.y-c.y;return{x:d,y:l,width:i.width,height:i.height}}function d2(e){return Pr(e).position==="static"}function qq(e,t){if(!BA(e)||Pr(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return vi(e)===n&&(n=n.ownerDocument.body),n}function Jq(e,t){let n=$a(e);if(ef(e))return n;if(!BA(e)){let a=Is(e);for(;a&&!Al(a);){if(jr(a)&&!d2(a))return a;a=Is(a)}return n}let o=qq(e,t);for(;o&&Hq(o)&&d2(o);)o=qq(o,t);return o&&Al(o)&&d2(o)&&!IC(o)?n:o||Tq(e)||n}var sme=async function(e){let t=this.getOffsetParent||Jq,n=this.getDimensions,o=await n(e.floating);return{reference:Ame(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function cme(e){return Pr(e).direction==="rtl"}var Wq={convertOffsetParentRelativeRectToViewportRelativeRect:Vge,getDocumentElement:vi,getClippingRect:rme,getOffsetParent:Jq,getElementRects:sme,getClientRects:Xge,getDimensions:ime,getScale:sl,isElement:jr,isRTL:cme};function Zq(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function ume(e,t,n){let o=null,a,r=vi(e);function i(){var d;clearTimeout(a),(d=o)==null||d.disconnect(),o=null}function A(d,l){d===void 0&&(d=!1),l===void 0&&(l=1),i();let g=e.getBoundingClientRect(),{left:p,top:m,width:h,height:B}=g;if(d||t(),!h||!B)return;let f=Vm(m),b=Vm(r.clientWidth-(p+h)),y=Vm(r.clientHeight-(m+B)),w=Vm(p),R={rootMargin:-f+"px "+-b+"px "+-y+"px "+-w+"px",threshold:$r(0,Qi(1,l))||1},D=!0;function F(T){let O=T[0].intersectionRatio;if(!Zq(g,e.getBoundingClientRect()))return A();if(O!==l){if(!D)return A();O?A(!1,O):a=setTimeout(()=>{A(!1,1e-7)},1e3)}D=!1}try{o=new IntersectionObserver(F,{...R,root:r.ownerDocument})}catch{o=new IntersectionObserver(F,R)}o.observe(e)}let s=$a(e),c=()=>A(n);return s.addEventListener("resize",c),A(!0),()=>{s.removeEventListener("resize",c),i()}}function p2(e,t,n,o){o===void 0&&(o={});let{ancestorScroll:a=!0,ancestorResize:r=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:A=typeof IntersectionObserver=="function",animationFrame:s=!1}=o,c=l2(e),d=a||r?[...c?Zc(c):[],...t?Zc(t):[]]:[];d.forEach(f=>{a&&f.addEventListener("scroll",n),r&&f.addEventListener("resize",n)});let l=c&&A?ume(c,n,r):null,g=-1,p=null;i&&(p=new ResizeObserver(f=>{let[b]=f;b&&b.target===c&&p&&t&&(p.unobserve(t),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var y;(y=p)==null||y.observe(t)})),n()}),c&&!s&&p.observe(c),t&&p.observe(t));let m,h=s?Xc(e):null;s&&B();function B(){let f=Xc(e);h&&!Zq(h,f)&&n(),h=f,m=requestAnimationFrame(B)}return n(),()=>{var f;d.forEach(b=>{a&&b.removeEventListener("scroll",n),r&&b.removeEventListener("resize",n)}),l?.(),(f=p)==null||f.disconnect(),p=null,s&&cancelAnimationFrame(m)}}var Vq=Nq;var Xq=$q,ez=Sq,tz=jq,nz=Lq,g2=Fq;var az=Mq,m2=(e,t,n)=>{let o=new Map,a=n??{},r={...Wq,...a.platform,_c:o};return Dq(e,t,{...a,platform:r})};var wn=C(z(),1),rz=C(z(),1),iz=C(yu(),1),dme=typeof document<"u",lme=function(){},DC=dme?rz.useLayoutEffect:lme;function FC(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,o,a;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(o=n;o--!==0;)if(!FC(e[o],t[o]))return!1;return!0}if(a=Object.keys(e),n=a.length,n!==Object.keys(t).length)return!1;for(o=n;o--!==0;)if(!{}.hasOwnProperty.call(t,a[o]))return!1;for(o=n;o--!==0;){let r=a[o];if(!(r==="_owner"&&e.$$typeof)&&!FC(e[r],t[r]))return!1}return!0}return e!==e&&t!==t}function Az(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function oz(e,t){let n=Az(e);return Math.round(t*n)/n}function f2(e){let t=wn.useRef(e);return DC(()=>{t.current=e}),t}function sz(e){e===void 0&&(e={});let{placement:t="bottom",strategy:n="absolute",middleware:o=[],platform:a,elements:{reference:r,floating:i}={},transform:A=!0,whileElementsMounted:s,open:c}=e,[d,l]=wn.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[g,p]=wn.useState(o);FC(g,o)||p(o);let[m,h]=wn.useState(null),[B,f]=wn.useState(null),b=wn.useCallback(je=>{je!==R.current&&(R.current=je,h(je))},[]),y=wn.useCallback(je=>{je!==D.current&&(D.current=je,f(je))},[]),w=r||m,Q=i||B,R=wn.useRef(null),D=wn.useRef(null),F=wn.useRef(d),T=s!=null,O=f2(s),ue=f2(a),oe=f2(c),Be=wn.useCallback(()=>{if(!R.current||!D.current)return;let je={placement:t,strategy:n,middleware:g};ue.current&&(je.platform=ue.current),m2(R.current,D.current,je).then(pn=>{let Do={...pn,isPositioned:oe.current!==!1};ge.current&&!FC(F.current,Do)&&(F.current=Do,iz.flushSync(()=>{l(Do)}))})},[g,t,n,ue,oe]);DC(()=>{c===!1&&F.current.isPositioned&&(F.current.isPositioned=!1,l(je=>({...je,isPositioned:!1})))},[c]);let ge=wn.useRef(!1);DC(()=>(ge.current=!0,()=>{ge.current=!1}),[]),DC(()=>{if(w&&(R.current=w),Q&&(D.current=Q),w&&Q){if(O.current)return O.current(w,Q,Be);Be()}},[w,Q,Be,O,T]);let ee=wn.useMemo(()=>({reference:R,floating:D,setReference:b,setFloating:y}),[b,y]),bt=wn.useMemo(()=>({reference:w,floating:Q}),[w,Q]),Ga=wn.useMemo(()=>{let je={position:n,left:0,top:0};if(!bt.floating)return je;let pn=oz(bt.floating,d.x),Do=oz(bt.floating,d.y);return A?{...je,transform:"translate("+pn+"px, "+Do+"px)",...Az(bt.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:pn,top:Do}},[n,A,bt.floating,d.x,d.y]);return wn.useMemo(()=>({...d,update:Be,refs:ee,elements:bt,floatingStyles:Ga}),[d,Be,ee,bt,Ga])}var pme=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){let{element:o,padding:a}=typeof e=="function"?e(n):e;return o&&t(o)?o.current!=null?g2({element:o.current,padding:a}).fn(n):{}:o?g2({element:o,padding:a}).fn(n):{}}}},cz=(e,t)=>{let n=Vq(e);return{name:n.name,fn:n.fn,options:[e,t]}},uz=(e,t)=>{let n=Xq(e);return{name:n.name,fn:n.fn,options:[e,t]}},dz=(e,t)=>({fn:az(e).fn,options:[e,t]}),lz=(e,t)=>{let n=ez(e);return{name:n.name,fn:n.fn,options:[e,t]}},pz=(e,t)=>{let n=tz(e);return{name:n.name,fn:n.fn,options:[e,t]}};var gz=(e,t)=>{let n=nz(e);return{name:n.name,fn:n.fn,options:[e,t]}};var mz=(e,t)=>{let n=pme(e);return{name:n.name,fn:n.fn,options:[e,t]}};var Cz=C(z(),1),wz=C(yu(),1);var ea=C(z(),1);var gme=Object.defineProperty,Gr=(e,t)=>gme(e,"name",{value:t,configurable:!0});function h2(e){let t=ea.forwardRef((n,o)=>{let{children:a,...r}=n,i=null,A=!1,s=[];b2(a)&&typeof SC=="function"&&(a=SC(a._payload)),ea.Children.forEach(a,g=>{if(Bz(g)){A=!0;let p=g,m="child"in p.props?p.props.child:p.props.children;b2(m)&&typeof SC=="function"&&(m=SC(m._payload)),i=fme(p,m),s.push(i?.props?.children)}else s.push(g)}),i?i=ea.cloneElement(i,void 0,s):!A&&ea.Children.count(a)===1&&ea.isValidElement(a)&&(i=a);let c=i?hz(i):void 0,d=ki(o,c);if(!i){if(a||a===0)throw new Error(A?Bme(e):hme(e));return a}let l=bz(r,i.props??{});return i.type!==ea.Fragment&&(l.ref=o?d:c),ea.cloneElement(i,l)});return t.displayName=`${e}.Slot`,t}Gr(h2,"createSlot");var fz=Symbol.for("radix.slottable");function mme(e){let t=Gr(n=>"child"in n?n.children(n.child):n.children,"Slottable");return t.displayName=`${e}.Slottable`,t.__radixId=fz,t}Gr(mme,"createSlottable");var fme=Gr((e,t)=>{if("child"in e.props){let n=e.props.child;return ea.isValidElement(n)?ea.cloneElement(n,void 0,e.props.children(n.props.children)):null}return ea.isValidElement(t)?t:null},"getSlottableElementFromSlottable");function bz(e,t){let n={...t};for(let o in t){let a=e[o],r=t[o];/^on[A-Z]/.test(o)?a&&r?n[o]=(...A)=>{let s=r(...A);return a(...A),s}:a&&(n[o]=a):o==="style"?n[o]={...a,...r}:o==="className"&&(n[o]=[a,r].filter(Boolean).join(" "))}return{...e,...n}}Gr(bz,"mergeProps");function hz(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)}Gr(hz,"getElementRef");function Bz(e){return ea.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===fz}Gr(Bz,"isSlottable");var bme=Symbol.for("react.lazy");function b2(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===bme&&"_payload"in e&&yz(e._payload)}Gr(b2,"isLazyComponent");function yz(e){return typeof e=="object"&&e!==null&&"then"in e}Gr(yz,"isPromiseLike");var hme=Gr(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),Bme=Gr(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),SC=ea[" use ".trim().toString()];var Ez=C(E(),1),yme=Object.defineProperty,Cme=(e,t)=>yme(e,"name",{value:t,configurable:!0}),wme=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],yA=wme.reduce((e,t)=>{let n=h2(`Primitive.${t}`),o=Cz.forwardRef((a,r)=>{let{asChild:i,...A}=a,s=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),(0,Ez.jsx)(s,{...A,ref:r})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function B2(e,t){e&&wz.flushSync(()=>e.dispatchEvent(t))}Cme(B2,"dispatchDiscreteCustomEvent");var cl=C(z(),1),Eme=Object.defineProperty,kme=(e,t)=>Eme(e,"name",{value:t,configurable:!0});function eu(e){let t=cl.useRef(e);return cl.useEffect(()=>{t.current=e}),cl.useMemo(()=>((...n)=>t.current?.(...n)),[])}kme(eu,"useCallbackRef");var kz=C(z(),1);var Qme=Object.defineProperty,Ime=(e,t)=>Qme(e,"name",{value:t,configurable:!0});function y2(e){let[t,n]=kz.useState(void 0);return Na(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let o=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;let r=a[0],i,A;if("borderBoxSize"in r){let s=r.borderBoxSize,c=Array.isArray(s)?s[0]:s;i=c.inlineSize,A=c.blockSize}else i=e.offsetWidth,A=e.offsetHeight;n({width:i,height:A})});return o.observe(e,{box:"border-box"}),()=>o.unobserve(e)}else n(void 0)},[e]),t}Ime(y2,"useSize");var ul=C(E(),1),_me=Object.defineProperty,_s=(e,t)=>_me(e,"name",{value:t,configurable:!0});var Qz="Popper",[Iz,C2]=Km(Qz),[vme,_z]=Iz(Qz),xme=_s(e=>{let{__scopePopper:t,children:n}=e,[o,a]=fa.useState(null),[r,i]=fa.useState(void 0);return(0,ul.jsx)(vme,{scope:t,anchor:o,onAnchorChange:a,placementState:r,setPlacementState:i,children:n})},"Popper"),Dme="PopperAnchor",Fme=fa.forwardRef(_s(function(t,n){let{__scopePopper:o,virtualRef:a,...r}=t,i=_z(Dme,o),A=fa.useRef(null),s=i.onAnchorChange,c=fa.useCallback(h=>{A.current=h,h&&s(h)},[s]),d=ki(n,c),l=fa.useRef(null);fa.useEffect(()=>{if(!a)return;let h=l.current;l.current=a.current,h!==l.current&&s(l.current)});let g=i.placementState&&LC(i.placementState),p=g?.[0],m=g?.[1];return a?null:(0,ul.jsx)(yA.div,{"data-radix-popper-side":p,"data-radix-popper-align":m,...r,ref:d})},"PopperAnchor")),vz="PopperContent",[Sme,hMe]=Iz(vz),Lme=fa.forwardRef(_s(function(t,n){let{__scopePopper:o,side:a="bottom",sideOffset:r=0,align:i="center",alignOffset:A=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:d=[],collisionPadding:l=0,sticky:g="partial",hideWhenDetached:p=!1,updatePositionStrategy:m="optimized",onPlaced:h,...B}=t,f=_z(vz,o),[b,y]=fa.useState(null),w=ki(n,y),[Q,R]=fa.useState(null),D=y2(Q),F=D?.width??0,T=D?.height??0,O=a+(i!=="center"?"-"+i:""),ue=typeof l=="number"?l:{top:0,right:0,bottom:0,left:0,...l},oe=Array.isArray(d)?d:[d],Be=oe.length>0,ge={padding:ue,boundary:oe.filter(xz),altBoundary:Be},{refs:ee,floatingStyles:bt,placement:Ga,isPositioned:je,middlewareData:pn}=sz({strategy:"fixed",placement:O,whileElementsMounted:_s((...Sw)=>p2(...Sw,{animationFrame:m==="always"}),"whileElementsMounted"),elements:{reference:f.anchor},middleware:[cz({mainAxis:r+T,alignmentAxis:A}),c&&uz({mainAxis:!0,crossAxis:!1,limiter:g==="partial"?dz():void 0,...ge}),c&&lz({...ge}),pz({...ge,apply:_s(({elements:Sw,rects:QS,availableWidth:XJ,availableHeight:eW})=>{let{width:tW,height:nW}=QS.reference,ff=Sw.floating.style;ff.setProperty("--radix-popper-available-width",`${XJ}px`),ff.setProperty("--radix-popper-available-height",`${eW}px`),ff.setProperty("--radix-popper-anchor-width",`${tW}px`),ff.setProperty("--radix-popper-anchor-height",`${nW}px`)},"apply")}),Q&&mz({element:Q,padding:s}),Rme({arrowWidth:F,arrowHeight:T}),p&&gz({strategy:"referenceHidden",...ge,boundary:Be?ge.boundary:void 0})]}),Do=f.setPlacementState;Na(()=>(Do(Ga),()=>{Do(void 0)}),[Ga,Do]);let[wS,ES]=LC(Ga),kS=eu(h);Na(()=>{je&&kS?.()},[je,kS]);let KJ=pn.arrow?.x,JJ=pn.arrow?.y,WJ=pn.arrow?.centerOffset!==0,[ZJ,VJ]=fa.useState();return Na(()=>{b&&VJ(window.getComputedStyle(b).zIndex)},[b]),(0,ul.jsx)("div",{ref:ee.setFloating,"data-radix-popper-content-wrapper":"",style:{...bt,transform:je?bt.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ZJ,"--radix-popper-transform-origin":[pn.transformOrigin?.x,pn.transformOrigin?.y].join(" "),...pn.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:(0,ul.jsx)(Sme,{scope:o,placedSide:wS,placedAlign:ES,onArrowChange:R,arrowX:KJ,arrowY:JJ,shouldHideArrow:WJ,children:(0,ul.jsx)(yA.div,{"data-side":wS,"data-align":ES,...B,ref:w,style:{...B.style,animation:je?B.style?.animation:"none"}})})})},"PopperContent"));function xz(e){return e!==null}_s(xz,"isNotNull");var Rme=_s(e=>({name:"transformOrigin",options:e,fn(t){let{placement:n,rects:o,middlewareData:a}=t,i=a.arrow?.centerOffset!==0,A=i?0:e.arrowWidth,s=i?0:e.arrowHeight,[c,d]=LC(n),l={start:"0%",center:"50%",end:"100%"}[d],g=(a.arrow?.x??0)+A/2,p=(a.arrow?.y??0)+s/2,m="",h="";return c==="bottom"?(m=i?l:`${g}px`,h=`${-s}px`):c==="top"?(m=i?l:`${g}px`,h=`${o.floating.height+s}px`):c==="right"?(m=`${-s}px`,h=i?l:`${p}px`):c==="left"&&(m=`${o.floating.width+s}px`,h=i?l:`${p}px`),{data:{x:m,y:h}}}}),"transformOrigin");function LC(e){let[t,n="center"]=e.split("-");return[t,n]}_s(LC,"getSideAndAlignFromPlacement");var Dz=xme,Fz=Fme,Sz=Lme;var RC=C(z(),1),Lz=C(yu(),1);var Rz=C(E(),1),$me=Object.defineProperty,Mme=(e,t)=>$me(e,"name",{value:t,configurable:!0}),Nz=RC.forwardRef(Mme(function(t,n){let{container:o,...a}=t,[r,i]=RC.useState(!1);Na(()=>i(!0),[]);let A=o||r&&globalThis?.document?.body;return A?Lz.createPortal((0,Rz.jsx)(yA.div,{...a,ref:n}),A):null},"Portal"));var ta=C(z(),1);var $z=C(z(),1),jme=Object.defineProperty,CA=(e,t)=>jme(e,"name",{value:t,configurable:!0});function Mz(e,t){return $z.useReducer((n,o)=>t[n][o]??n,e)}CA(Mz,"useStateMachine");var E2=CA(e=>{let{present:t,children:n}=e,o=jz(t),a=typeof n=="function"?n({present:o.isPresent}):ta.Children.only(n),r=Pz(o.ref,Gz(a));return typeof n=="function"||o.isPresent?ta.cloneElement(a,{ref:r}):null},"Presence");function jz(e){let[t,n]=ta.useState(),o=ta.useRef(null),a=ta.useRef(e),r=ta.useRef("none"),i=ta.useRef(void 0),A=e?"mounted":"unmounted",[s,c]=Mz(A,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return ta.useEffect(()=>{s==="mounted"?(r.current=i.current??dl(o.current),i.current=void 0):r.current="none"},[s]),Na(()=>{let d=o.current,l=a.current;if(l!==e){let p=r.current,m=dl(d);e?(i.current=m,c("MOUNT")):m==="none"||d?.display==="none"?c("UNMOUNT"):c(l&&p!==m?"ANIMATION_OUT":"UNMOUNT"),a.current=e}},[e,c]),Na(()=>{if(t){let d,l=t.ownerDocument.defaultView??window,g=CA(m=>{let B=dl(o.current).includes(CSS.escape(m.animationName));if(m.target===t&&B&&(c("ANIMATION_END"),!a.current)){let f=t.style.animationFillMode;t.style.animationFillMode="forwards",d=l.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=f)})}},"handleAnimationEnd"),p=CA(m=>{m.target===t&&(r.current=dl(o.current))},"handleAnimationStart");return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",g),t.addEventListener("animationend",g),()=>{l.clearTimeout(d),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",g),t.removeEventListener("animationend",g)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:ta.useCallback(d=>{if(d){let l=getComputedStyle(d);o.current=l,i.current=dl(l)}else o.current=null;n(d)},[])}}CA(jz,"usePresence");function w2(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}CA(w2,"setRef");function Pz(...e){let t=ta.useRef(e);return t.current=e,ta.useCallback(n=>{let o=t.current,a=!1,r=o.map(i=>{let A=w2(i,n);return!a&&typeof A=="function"&&(a=!0),A});if(a)return()=>{for(let i=0;i<r.length;i++){let A=r[i];typeof A=="function"?A():w2(o[i],null)}}},[])}CA(Pz,"useStableComposedRefs");function dl(e){return e?.animationName||"none"}CA(dl,"getAnimationName");function Gz(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)}CA(Gz,"getElementRef");var ct=C(z(),1);var Tz=C(E(),1),Pme=Object.defineProperty,Hn=(e,t)=>Pme(e,"name",{value:t,configurable:!0}),k2="dismissableLayer.update",Gme="dismissableLayer.pointerDownOutside",Hme="dismissableLayer.focusOutside",Hz,Uz=ct.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Oz=ct.forwardRef(Hn(function(t,n){let{disableOutsidePointerEvents:o=!1,deferPointerDownOutside:a=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:A,onInteractOutside:s,onDismiss:c,...d}=t,l=ct.useContext(Uz),[g,p]=ct.useState(null),m=g?.ownerDocument??globalThis?.document,[,h]=ct.useState({}),B=ki(n,p),f=Array.from(l.layers),[b]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),y=b?f.indexOf(b):-1,w=g?f.indexOf(g):-1,Q=l.layersWithOutsidePointerEventsDisabled.size>0,R=w>=y,D=ct.useRef(!1),F=qz(oe=>{i?.(oe),s?.(oe),oe.defaultPrevented||c?.()},{ownerDocument:m,deferPointerDownOutside:a,isDeferredPointerDownOutsideRef:D,dismissableSurfaces:l.dismissableSurfaces,shouldHandlePointerDownOutside:ct.useCallback(oe=>{if(!(oe instanceof Node))return!1;let Be=[...l.branches].some(ge=>ge.contains(oe));return R&&!Be},[l.branches,R])}),T=zz(oe=>{if(a&&D.current)return;let Be=oe.target;[...l.branches].some(ee=>ee.contains(Be))||(A?.(oe),s?.(oe),oe.defaultPrevented||c?.())},m),O=g?w===f.length-1:!1,ue=eu(oe=>{oe.key==="Escape"&&(r?.(oe),!oe.defaultPrevented&&c&&(oe.preventDefault(),c()))});return ct.useEffect(()=>{if(O)return m.addEventListener("keydown",ue,{capture:!0}),()=>m.removeEventListener("keydown",ue,{capture:!0})},[m,O,ue]),ct.useEffect(()=>{if(g)return o&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(Hz=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(g)),l.layers.add(g),Q2(),()=>{o&&(l.layersWithOutsidePointerEventsDisabled.delete(g),l.layersWithOutsidePointerEventsDisabled.size===0&&(m.body.style.pointerEvents=Hz))}},[g,m,o,l]),ct.useEffect(()=>()=>{g&&(l.layers.delete(g),l.layersWithOutsidePointerEventsDisabled.delete(g),Q2())},[g,l]),ct.useEffect(()=>{let oe=Hn(()=>h({}),"handleUpdate");return document.addEventListener(k2,oe),()=>document.removeEventListener(k2,oe)},[]),(0,Tz.jsx)(yA.div,{...d,ref:B,style:{pointerEvents:Q?R?"auto":"none":void 0,...t.style},onFocusCapture:Ra(t.onFocusCapture,T.onFocusCapture),onBlurCapture:Ra(t.onBlurCapture,T.onBlurCapture),onPointerDownCapture:Ra(t.onPointerDownCapture,F.onPointerDownCapture)})},"DismissableLayer"));function Tme(){let e=ct.useContext(Uz),[t,n]=ct.useState(null);return ct.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}Hn(Tme,"useDismissableLayerSurface");var Ume=Hn(()=>!0,"IS_TRUE");function qz(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:o=!1,isDeferredPointerDownOutsideRef:a,dismissableSurfaces:r,shouldHandlePointerDownOutside:i=Ume}=t,A=eu(e),s=ct.useRef(!1),c=ct.useRef(!1),d=ct.useRef(new Map),l=ct.useRef(()=>{});return ct.useEffect(()=>{function g(){c.current=!1,a.current=!1,d.current.clear()}Hn(g,"resetOutsideInteraction");function p(){return Array.from(d.current.values()).some(Boolean)}Hn(p,"isOutsideInteractionIntercepted");function m(y){if(!c.current)return;let w=y.target;w instanceof Node&&[...r].some(R=>R.contains(w))||d.current.set(y.type,!0),y.type==="click"&&window.setTimeout(()=>{c.current&&l.current()},0)}Hn(m,"handleInteractionCapture");function h(y){c.current&&d.current.set(y.type,!1)}Hn(h,"handleInteractionBubble");let B=Hn(y=>{if(y.target&&!s.current){let Q=function(){n.removeEventListener("click",l.current);let D=p();g(),D||I2(Gme,A,R,{discrete:!0})};var w=Q;if(Hn(Q,"handleAndDispatchPointerDownOutsideEvent"),!i(y.target)){n.removeEventListener("click",l.current),g(),s.current=!1;return}let R={originalEvent:y};c.current=!0,a.current=o&&y.button===0,d.current.clear(),!o||y.button!==0?Q():(n.removeEventListener("click",l.current),l.current=Q,n.addEventListener("click",l.current,{once:!0}))}else n.removeEventListener("click",l.current),g();s.current=!1},"handlePointerDown"),f=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(let y of f)n.addEventListener(y,m,!0),n.addEventListener(y,h);let b=window.setTimeout(()=>{n.addEventListener("pointerdown",B)},0);return()=>{window.clearTimeout(b),n.removeEventListener("pointerdown",B),n.removeEventListener("click",l.current);for(let y of f)n.removeEventListener(y,m,!0),n.removeEventListener(y,h)}},[n,A,o,a,r,i]),{onPointerDownCapture:Hn(()=>s.current=!0,"onPointerDownCapture")}}Hn(qz,"usePointerDownOutside");function zz(e,t=globalThis?.document){let n=eu(e),o=ct.useRef(!1);return ct.useEffect(()=>{let a=Hn(r=>{r.target&&!o.current&&I2(Hme,n,{originalEvent:r},{discrete:!1})},"handleFocus");return t.addEventListener("focusin",a),()=>t.removeEventListener("focusin",a)},[t,n]),{onFocusCapture:Hn(()=>o.current=!0,"onFocusCapture"),onBlurCapture:Hn(()=>o.current=!1,"onBlurCapture")}}Hn(zz,"useFocusOutside");function Q2(){let e=new CustomEvent(k2);document.dispatchEvent(e)}Hn(Q2,"dispatchUpdate");function I2(e,t,n,{discrete:o}){let a=n.originalEvent.target,r=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&a.addEventListener(e,t,{once:!0}),o?B2(a,r):a.dispatchEvent(r)}Hn(I2,"handleAndDispatchCustomEvent");var ir=C(E(),1),Ome=Object.defineProperty,wA=(e,t)=>Ome(e,"name",{value:t,configurable:!0}),_2,x2="HoverCard",[Yz,PMe]=Km(x2,[C2]),D2=C2(),[qme,NC]=Yz(x2),zme=wA(e=>{let{__scopeHoverCard:t,children:n,open:o,defaultOpen:a,onOpenChange:r,openDelay:i=700,closeDelay:A=300}=e,s=D2(t),c=sn.useRef(0),d=sn.useRef(0),l=sn.useRef(!1),g=sn.useRef(!1),[p,m]=r2({prop:o,defaultProp:a??!1,onChange:r,caller:x2}),h=sn.useCallback(()=>{clearTimeout(d.current),c.current=window.setTimeout(()=>m(!0),i)},[i,m]),B=sn.useCallback(()=>{clearTimeout(c.current),!l.current&&!g.current&&(d.current=window.setTimeout(()=>m(!1),A))},[A,m]),f=sn.useCallback(()=>m(!1),[m]);return sn.useEffect(()=>()=>{clearTimeout(c.current),clearTimeout(d.current)},[]),(0,ir.jsx)(qme,{scope:t,open:p,onOpenChange:m,onOpen:h,onClose:B,onDismiss:f,hasSelectionRef:l,isPointerDownOnContentRef:g,children:(0,ir.jsx)(Dz,{...s,children:n})})},"HoverCard"),Yme="HoverCardTrigger",Kme=sn.forwardRef(wA(function(t,n){let{__scopeHoverCard:o,...a}=t,r=NC(Yme,o),i=D2(o);return(0,ir.jsx)(Fz,{asChild:!0,...i,children:(0,ir.jsx)(yA.a,{"data-state":r.open?"open":"closed",...a,ref:n,onPointerEnter:Ra(t.onPointerEnter,nf(r.onOpen)),onPointerLeave:Ra(t.onPointerLeave,nf(r.onClose)),onFocus:Ra(t.onFocus,r.onOpen),onBlur:Ra(t.onBlur,r.onClose),onTouchStart:Ra(t.onTouchStart,A=>A.preventDefault())})})},"HoverCardTrigger")),Kz="HoverCardPortal",[Jme,Wme]=Yz(Kz,{forceMount:void 0}),Zme=wA(e=>{let{__scopeHoverCard:t,forceMount:n,children:o,container:a}=e,r=NC(Kz,t);return(0,ir.jsx)(Jme,{scope:t,forceMount:n,children:(0,ir.jsx)(E2,{present:n||r.open,children:(0,ir.jsx)(Nz,{asChild:!0,container:a,children:o})})})},"HoverCardPortal"),v2="HoverCardContent",Vme=sn.forwardRef(wA(function(t,n){let o=Wme(v2,t.__scopeHoverCard),{forceMount:a=o.forceMount,...r}=t,i=NC(v2,t.__scopeHoverCard);return(0,ir.jsx)(E2,{present:a||i.open,children:(0,ir.jsx)(Xme,{"data-state":i.open?"open":"closed",...r,onPointerEnter:Ra(t.onPointerEnter,nf(i.onOpen)),onPointerLeave:Ra(t.onPointerLeave,nf(i.onClose)),ref:n})})},"HoverCardContent")),Xme=sn.forwardRef(wA(function(t,n){let{__scopeHoverCard:o,onEscapeKeyDown:a,onPointerDownOutside:r,onFocusOutside:i,onInteractOutside:A,...s}=t,c=NC(v2,o),d=D2(o),l=sn.useRef(null),g=ki(n,l),[p,m]=sn.useState(!1);return sn.useEffect(()=>{if(p){let h=document.body;return _2=h.style.userSelect||h.style.webkitUserSelect,h.style.userSelect="none",h.style.webkitUserSelect="none",()=>{h.style.userSelect=_2,h.style.webkitUserSelect=_2}}},[p]),sn.useEffect(()=>{if(l.current){let h=wA(()=>{m(!1),c.isPointerDownOnContentRef.current=!1,setTimeout(()=>{document.getSelection()?.toString()!==""&&(c.hasSelectionRef.current=!0)})},"handlePointerUp");return document.addEventListener("pointerup",h),()=>{document.removeEventListener("pointerup",h),c.hasSelectionRef.current=!1,c.isPointerDownOnContentRef.current=!1}}},[c.isPointerDownOnContentRef,c.hasSelectionRef]),sn.useEffect(()=>{l.current&&Jz(l.current).forEach(B=>B.setAttribute("tabindex","-1"))}),(0,ir.jsx)(Oz,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:A,onEscapeKeyDown:a,onPointerDownOutside:r,onFocusOutside:Ra(i,h=>{h.preventDefault()}),onDismiss:c.onDismiss,children:(0,ir.jsx)(Sz,{...d,...s,onPointerDown:Ra(s.onPointerDown,h=>{h.currentTarget.contains(h.target)&&m(!0),c.hasSelectionRef.current=!1,c.isPointerDownOnContentRef.current=!0}),ref:g,style:{...s.style,userSelect:p?"text":void 0,WebkitUserSelect:p?"text":void 0,"--radix-hover-card-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-hover-card-content-available-width":"var(--radix-popper-available-width)","--radix-hover-card-content-available-height":"var(--radix-popper-available-height)","--radix-hover-card-trigger-width":"var(--radix-popper-anchor-width)","--radix-hover-card-trigger-height":"var(--radix-popper-anchor-height)"}})})},"HoverCardContentImpl"));function nf(e){return t=>t.pointerType==="touch"?void 0:e()}wA(nf,"excludeTouch");function Jz(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:wA(o=>o.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP,"acceptNode")});for(;n.nextNode();)t.push(n.currentNode);return t}wA(Jz,"getTabbableNodes");var Wz=zme,Zz=Kme,Vz=Zme,Xz=Vme;var Ar=C(z(),1);var Hr=C(E(),1),tfe=8,nfe=10,F2=150,eY="(min-width: 768px) and (hover: hover) and (pointer: fine)",afe=new Set(["circle","ellipse","g","line","path","polygon","polyline","rect","svg","text"]);function ofe(e){return typeof e.type=="string"&&afe.has(e.type)}function Se({align:e="center",children:t,className:n,content:o,label:a,placement:r="above",triggerClassName:i}){let A=(0,Ar.useId)(),s=(0,Ar.useRef)(null),c=(0,Ar.useRef)(null),d=(0,Ar.useRef)(0),[l,g]=(0,Ar.useState)(!1),[p,m]=(0,Ar.useState)(()=>typeof window>"u"?!1:window.matchMedia(eY).matches),h=ofe(t);if((0,Ar.useEffect)(()=>{let f=window.matchMedia(eY),b=()=>{m(f.matches),f.matches||g(!1)};return b(),f.addEventListener("change",b),()=>f.removeEventListener("change",b)},[]),(0,Ar.useEffect)(()=>{if(!l)return;let f=b=>{let y=s.current,w=b.target;!(w instanceof Node)||y?.contains(w)||document.getElementById(A)?.contains(w)||(d.current=performance.now()+F2+50,g(!1))};return document.addEventListener("pointerdown",f,!0),()=>{document.removeEventListener("pointerdown",f,!0)}},[l,A]),!p)return h?t:(0,Hr.jsx)("span",{className:_("inline-flex",i),children:t});let B=(0,Hr.jsxs)(Wz,{closeDelay:F2,onOpenChange:f=>{f&&performance.now()<d.current||g(f)},open:l,openDelay:0,children:[(0,Hr.jsx)(Zz,{"aria-describedby":l?A:void 0,asChild:!0,onPointerCancel:()=>{c.current=null},onPointerDown:f=>{f.pointerType==="touch"&&(c.current=l)},onPointerUp:f=>{if(f.pointerType!=="touch"||c.current===null)return;let b=!c.current;b||(d.current=performance.now()+F2+50),g(b),c.current=null},ref:h?f=>{s.current=f}:void 0,children:t}),(0,Hr.jsx)(Vz,{children:(0,Hr.jsxs)(Xz,{align:e==="left"?"start":e==="right"?"end":"center",className:_("z-50 select-text outline-none",n??"min-w-36 max-w-64 rounded-md border border-white/15 bg-dashboard-surface-raised px-3 py-2 font-mono text-xs leading-relaxed text-dashboard-text-muted shadow-2xl shadow-black/70"),collisionPadding:tfe,hideWhenDetached:!0,id:A,role:"tooltip",side:r==="above"?"top":"bottom",sideOffset:nfe,children:[a?(0,Hr.jsx)("div",{className:"mb-1 font-semibold uppercase tracking-[0.1em] text-dashboard-text-muted",children:a}):null,o]})})]});return h?B:(0,Hr.jsx)("span",{className:_("inline-flex",i),ref:s,children:B})}function ll(e){return(0,Hr.jsx)(Se,{className:"min-w-0 rounded-md border border-white/15 bg-dashboard-surface-raised px-2.5 py-1.5 font-sans text-xs leading-none text-dashboard-text shadow-2xl shadow-black/70",content:e.label,placement:e.placement??"above",children:(0,Hr.jsx)("span",{className:"inline-flex",children:e.children})})}var na=C(E(),1),tY=[{color:"#67e8f9",key:"personal",label:"Personal"},{color:"#6ee7b7",key:"public",label:"Public"}];function nY(e){let t=e.days.slice(-e.range),n=Bn(200),o=t.length>0?n.plotWidth/t.length:n.plotWidth,a=Math.max(2,Math.min(13,o*.68)),r=t.map(s=>s.personal+s.public),i=Math.max(1,...r),A=r.some(s=>s>0);return(0,na.jsxs)(q,{className:"min-h-[17rem] p-4 sm:p-5",children:[(0,na.jsxs)("div",{children:[(0,na.jsx)("h2",{className:"m-0 font-display text-xl font-medium text-dashboard-text",children:"Activity over time"}),(0,na.jsx)("p",{className:"mt-1 mb-0 font-mono text-xs leading-relaxed text-dashboard-text-muted",children:"Stacked personal + public memories created each day."})]}),(0,na.jsx)(ma,{ariaLabel:"Memory visibility legend",items:tY}),(0,na.jsxs)("div",{className:"relative mt-3 overflow-hidden",children:[(0,na.jsxs)(yn,{"aria-label":`Memories learned during the last ${e.range} days`,className:"min-h-40",layout:n,children:[(0,na.jsx)(Pn,{layout:n,maximum:i}),t.map((s,c)=>{let d=0,l=n.left+c*o+(o-a)/2,g=r[c]??0;return(0,na.jsx)(Se,{content:(0,na.jsx)(Cn,{rows:[["personal",s.personal],["public",s.public],["total",g]]}),label:We(s.date),children:(0,na.jsxs)("g",{"aria-label":`${We(s.date)}: ${s.personal} personal, ${s.public} public, ${g} total memories`,tabIndex:0,children:[tY.map(p=>{let h=s[p.key]/i*n.plotHeight;return d+=h,(0,na.jsx)("rect",{fill:p.color,height:h,opacity:.82,rx:"1",width:a,x:l,y:n.top+n.plotHeight-d},p.key)}),(0,na.jsx)("rect",{fill:"transparent",height:n.plotHeight,width:Math.max(a,8),x:l-(Math.max(a,8)-a)/2,y:n.top})]})},s.date)}),(0,na.jsx)(Gn,{dates:t.map(s=>s.date),layout:n,xPosition:s=>n.left+s*o+o/2})]}),A?null:(0,na.jsx)("div",{className:"pointer-events-none absolute inset-0 grid place-items-center pt-12 font-mono text-xs text-dashboard-text-muted",children:"No memories were learned in this period."})]})]})}var xn=C(E(),1);function aY(e){let t=new Map(e.recallDays.map(p=>[p.date,p])),n=e.extractionDays.slice(-e.range).map(p=>({date:p.date,extraction:p,recall:t.get(p.date)??{costUsd:0,date:p.date,events:0}})),o=n.reduce((p,m)=>p+m.extraction.costUsd,0),a=n.reduce((p,m)=>p+m.recall.costUsd,0),r=o+a,i=n.reduce((p,m)=>p+m.extraction.events+m.recall.events,0),A=n.map(p=>p.extraction.costUsd+p.recall.costUsd),s=Math.max(.01,...A),c=tr(A),d=Bn(200,{left:112}),l=n.length>0?d.plotWidth/n.length:d.plotWidth,g=Math.max(2,Math.min(13,l*.68));return(0,xn.jsxs)(q,{className:"min-h-[17rem] p-4 sm:p-5",children:[(0,xn.jsxs)("div",{children:[(0,xn.jsx)("h2",{className:"m-0 font-display text-xl font-medium text-dashboard-text",children:Je({total:r})}),(0,xn.jsxs)("p",{className:"mt-1 mb-0 font-mono text-xs leading-relaxed text-dashboard-text-muted",children:["System-wide estimate across ",af(i)," spanning extraction and recall."]}),(0,xn.jsx)(ma,{ariaLabel:"Memory cost legend",items:[{color:"#67e8f9",key:"extraction",label:"Extraction",value:Je({total:o})},{color:"#e879f9",key:"recall",label:"Recall",value:Je({total:a})}]})]}),(0,xn.jsxs)("div",{className:"relative mt-4 overflow-hidden",children:[(0,xn.jsxs)(yn,{"aria-label":`Memory extraction and recall cost during the last ${e.range} days`,className:"min-h-40",layout:d,children:[(0,xn.jsx)(Pn,{format:p=>Je({total:p}),layout:d,maximum:s}),n.map((p,m)=>{let h=p.extraction.costUsd/s*d.plotHeight,B=p.recall.costUsd/s*d.plotHeight,f=d.left+m*l+(l-g)/2,b=p.extraction.costUsd+p.recall.costUsd;return(0,xn.jsx)(Se,{content:(0,xn.jsx)(Cn,{rows:[["extraction",`${Je({total:p.extraction.costUsd})} \xB7 ${af(p.extraction.events)}`],["recall",`${Je({total:p.recall.costUsd})} \xB7 ${af(p.recall.events)}`],["total",Je({total:b})]]}),label:We(p.date),children:(0,xn.jsxs)("g",{"aria-label":`${We(p.date)}: extraction ${Je({total:p.extraction.costUsd})}, ${af(p.extraction.events)}; recall ${Je({total:p.recall.costUsd})}, ${af(p.recall.events)}`,tabIndex:0,children:[(0,xn.jsx)("rect",{fill:"#67e8f9",height:h,opacity:p.extraction.costUsd>0?.82:.1,rx:"1",width:g,x:f,y:d.top+d.plotHeight-h}),(0,xn.jsx)("rect",{fill:"#e879f9",height:B,opacity:p.recall.costUsd>0?.82:.1,rx:"1",width:g,x:f,y:d.top+d.plotHeight-h-B}),(0,xn.jsx)("rect",{fill:"transparent",height:d.plotHeight,width:Math.max(g,8),x:f-(Math.max(g,8)-g)/2,y:d.top})]})},p.date)}),(0,xn.jsx)(nr,{average:c,format:p=>Je({total:p}),layout:d,maximum:s,stroke:"#e2e8f0"}),(0,xn.jsx)(Gn,{dates:n.map(p=>p.date),layout:d,xPosition:p=>d.left+p*l+l/2})]}),i===0?(0,xn.jsx)("div",{className:"pointer-events-none absolute inset-0 grid place-items-center pt-12 font-mono text-xs text-dashboard-text-muted",children:"No memory extraction or recall ran in this period."}):null]})]})}function af(e){return`${e.toLocaleString()} ${e===1?"run":"runs"}`}var rfe=u.object({content:u.string().min(1),createdAt:u.iso.datetime(),expiresAt:u.iso.datetime().optional(),id:u.string().min(1),kind:u.enum(["preference","procedure","knowledge"]),observedAt:u.iso.datetime(),origin:u.enum(["automatic","explicit","other"]),sourcePlatform:u.enum(["local","slack","web"]),visibility:u.enum(["private","public"])}).strict();function S2(e){return e.charAt(0).toUpperCase()+e.slice(1)}function L2(e){return new Intl.DateTimeFormat("en-US",{dateStyle:"medium",timeStyle:"short",timeZone:"UTC"}).format(new Date(e))}function ife(e){let t=e.origin==="automatic"?"Automatic":e.origin==="explicit"?"Explicit":"Other";return{actions:e.visibility==="private"?[{confirmation:"Forget this memory?",href:`/api/plugins/memory/memories/${encodeURIComponent(e.id)}`,label:"Forget",method:"DELETE",tone:"danger"}]:[],id:e.id,metadata:[{label:"Type",value:S2(e.kind)},{label:"Learned",value:t},{label:"Source",value:S2(e.sourcePlatform)},{label:"Visibility",value:S2(e.visibility)},{label:"Remembered",value:L2(e.createdAt)},{label:"Observed",value:L2(e.observedAt)},{label:"Expires",value:e.expiresAt?L2(e.expiresAt):"Never"}],title:e.content}}function oY(e){return ze({enabled:!!e,queryFn:async({signal:t})=>ife(await Ke(rfe,`/api/plugins/memory/memories/${encodeURIComponent(e)}`,t)),queryKey:["dashboard","plugin-user-page","memory","record",e],retry:!1})}var G=C(E(),1);function iY(e){let[t,n]=(0,MC.useState)(30),o=yt(),{memoryId:a}=ua(),r="/memories",i=`${r}/library`,A=o.pathname===r,s=o.pathname===i||!!a;if(!A&&!s)return(0,G.jsx)(Ct,{replace:!0,to:r});let c=Bi(i,o.search);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(el,{ariaLabel:"Memory navigation",items:[{end:!0,label:"Overview",to:r},{label:"Memories",to:c}]}),(0,G.jsxs)(Es,{className:"gap-6 sm:gap-8",children:[(0,G.jsx)(vt,{description:e.page.description,...A?{onRangeChange:n,range:t}:{},title:e.page.label}),A?(0,G.jsx)(Afe,{range:t}):(0,G.jsx)(sfe,{libraryPath:i,page:e.page})]})]})}function Afe(e){let t=Y8();return t.error?(0,G.jsxs)(q,{className:"flex items-center gap-3 border-rose-300/20 p-5 text-sm text-rose-200",children:[(0,G.jsx)(xa,{"aria-hidden":"true",size:18}),"Memory history is temporarily unavailable."]}):t.data?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)("section",{className:"grid gap-4 xl:grid-cols-2",children:[(0,G.jsx)(nY,{days:t.data.days,range:e.range}),(0,G.jsx)(aY,{extractionDays:t.data.extractionDays,range:e.range,recallDays:t.data.recallDays})]}),(0,G.jsx)(ufe,{data:t.data}),(0,G.jsxs)("section",{className:"grid gap-4 md:grid-cols-2",children:[(0,G.jsx)(dfe,{data:t.data}),(0,G.jsx)(lfe,{data:t.data})]})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(q,{className:"min-h-64 animate-pulse",children:(0,G.jsx)("span",{className:"sr-only",children:"Loading memory history"})}),(0,G.jsx)("div",{className:"h-24 animate-pulse border-y border-white/[0.06]",children:(0,G.jsx)("span",{className:"sr-only",children:"Loading memory summary"})})]})}function sfe(e){let{action:t,content:n,filter:o,query:a,records:r,runAction:i,searchQuery:A,searchText:s,setFilter:c,setSearchText:d}=gC(e.page),l=Y8(),g=Wa(),p=yt(),{memoryId:m}=ua(),h=oY(m),B=h.data??r.find(b=>b.id===m),f=b=>Bi(b,p.search);return(0,MC.useEffect)(()=>{!m||B||h.isFetching||h.isPending||(h.isError||h.isFetched)&&g(Bi(e.libraryPath,p.search),{replace:!0})},[p.search,m,h.isError,h.isFetched,h.isFetching,h.isPending,g,e.libraryPath,B]),!a.data&&!a.error?(0,G.jsx)(be,{label:"Loading memories"}):(0,G.jsxs)("section",{className:"grid gap-4","aria-labelledby":"memory-library-title",children:[(0,G.jsxs)("div",{className:"flex flex-wrap items-end justify-between gap-4",children:[(0,G.jsx)("div",{children:(0,G.jsx)("h2",{className:"m-0 font-display text-xl font-medium tracking-[-0.02em] text-dashboard-text",id:"memory-library-title",children:A?"Search results":"What Junior remembers"})}),n?.searchPlaceholder?(0,G.jsx)(ga,{className:"w-full max-w-md sm:w-auto",label:n.searchPlaceholder,onChange:d,placeholder:n.searchPlaceholder,size:"default",value:s}):null]}),(0,G.jsx)(jO,{ariaLabel:"Memory collections",items:[{count:l.data?.stats?.active,label:"All",value:""},{count:l.data?.stats?.personal,label:"Private",value:"private"},{count:l.data?.stats?.public,label:"Public",value:"public"}],onChange:c,value:o}),a.error?(0,G.jsxs)(q,{className:"flex items-center gap-3 border-rose-300/20 p-5 text-sm text-rose-200",children:[(0,G.jsx)(xa,{"aria-hidden":"true",size:18}),a.error.message]}):r.length===0?(0,G.jsx)(q,{className:"grid min-h-56 place-items-center p-8 text-center",children:(0,G.jsxs)("div",{children:[(0,G.jsx)(ms,{"aria-hidden":"true",className:"mx-auto text-dashboard-text-muted",size:26}),(0,G.jsx)("p",{className:"mt-4 mb-0 text-sm text-dashboard-text-muted",children:n?.emptyText??"No memories yet."})]})}):(0,G.jsxs)("div",{className:"grid gap-3",children:[(0,G.jsxs)(q,{padding:"none",children:[(0,G.jsx)(cfe,{}),r.map((b,y)=>(0,G.jsx)(pfe,{first:y===0,onSelect:()=>g(f(m===b.id?e.libraryPath:`/memories/${encodeURIComponent(b.id)}`)),record:b,selected:b.id===m},b.id))]}),(0,G.jsx)(oC,{className:"mt-2",hasMore:!a.isPlaceholderData&&!!a.hasNextPage,loading:a.isFetchingNextPage,onLoadMore:()=>{a.fetchNextPage()}}),t.error?(0,G.jsx)("p",{className:"m-0 text-center text-sm text-rose-300",children:"Could not complete this action. Try again."}):null]}),(0,G.jsx)(aq,{action:t,onAction:i,onClose:()=>g(f(e.libraryPath)),record:B})]})}function cfe(){return(0,G.jsxs)("div",{"aria-hidden":"true",className:"hidden grid-cols-[minmax(0,1fr)_7rem_7rem_9rem_auto] items-center gap-3 border-b border-white/[0.07] px-4 py-2.5 text-left font-mono text-xs uppercase tracking-[0.12em] text-dashboard-text-muted sm:grid",children:[(0,G.jsx)("span",{children:"Memory"}),(0,G.jsx)("span",{children:"Visibility"}),(0,G.jsx)("span",{children:"Type"}),(0,G.jsx)("span",{children:"Learned"}),(0,G.jsx)("span",{"aria-hidden":"true",className:"size-4"})]})}function ufe(e){let{stats:t}=e.data,n=[{detail:"personal + public",label:"Total active",value:t.active.toLocaleString("en-US")},{detail:"private to you",label:"Personal",value:t.personal.toLocaleString("en-US")},{detail:"workspace shareable",label:"Public",tone:"text-cyan-100",value:t.public.toLocaleString("en-US")},{detail:"in the last 30 days",label:"Added \xB7 30d",value:`+${t.createdThirtyDays.toLocaleString("en-US")}`}];return(0,G.jsx)("section",{"aria-label":"Memory summary",className:"grid grid-cols-2 gap-px border-y border-white/[0.06] bg-white/[0.06] lg:grid-cols-4",children:n.map(o=>(0,G.jsxs)("div",{className:"bg-[#050507] px-4 py-4 sm:px-5",children:[(0,G.jsx)("div",{className:"font-mono text-xs uppercase tracking-[0.12em] text-dashboard-text-muted",children:o.label}),(0,G.jsx)("div",{className:_("mt-2 font-display text-3xl font-light tracking-[-0.04em] text-dashboard-text",o.tone),children:o.value}),(0,G.jsx)("div",{className:"mt-1 font-mono text-xs leading-relaxed text-dashboard-text-muted",children:o.detail})]},o.label))})}function dfe(e){let{stats:t}=e.data;return(0,G.jsxs)(q,{className:"p-5 sm:p-6",children:[(0,G.jsx)("h2",{className:"m-0 font-display text-xl font-medium text-dashboard-text",children:"What Junior remembers"}),(0,G.jsx)("p",{className:"mt-1 mb-0 font-mono text-xs leading-relaxed text-dashboard-text-muted",children:"Across personal and public scopes."}),(0,G.jsxs)("div",{className:"mt-5 grid gap-px overflow-hidden rounded border border-white/[0.06] bg-white/[0.055]",children:[(0,G.jsx)(pl,{detail:"Almost entirely personal",icon:Fa,label:"Preferences",value:t.preference}),(0,G.jsx)(pl,{detail:"How work should get done",icon:ms,label:"Procedures",value:t.procedure}),(0,G.jsx)(pl,{detail:"Facts and durable context",icon:dA,label:"Knowledge",value:t.knowledge})]})]})}function lfe(e){let{stats:t}=e.data,n=Math.max(0,t.active-t.automatic-t.explicit);return(0,G.jsxs)(q,{className:"p-5 sm:p-6",children:[(0,G.jsx)("h2",{className:"m-0 font-display text-xl font-medium text-dashboard-text",children:"How they got here"}),(0,G.jsx)("p",{className:"mt-1 mb-0 font-mono text-xs leading-relaxed text-dashboard-text-muted",children:"Same totals, split by how they were written."}),(0,G.jsxs)("div",{className:"mt-5 grid gap-px overflow-hidden rounded border border-white/[0.06] bg-white/[0.055]",children:[(0,G.jsx)(pl,{detail:"Passive extraction after runs",icon:la,label:"Learned by Junior",value:t.automatic}),(0,G.jsx)(pl,{detail:"Someone asked to remember it",icon:Sg,label:"Saved explicitly",value:t.explicit}),(0,G.jsx)(pl,{detail:"Before origin tracking",icon:dA,label:"Older records",value:n})]})]})}function pl(e){let t=e.icon;return(0,G.jsxs)("div",{className:"flex items-center gap-3 bg-[#09090b] px-3 py-3",children:[(0,G.jsx)("div",{className:"grid size-9 shrink-0 place-items-center rounded border border-white/[0.07] bg-white/[0.025] text-dashboard-text-muted",children:(0,G.jsx)(t,{"aria-hidden":"true",size:15})}),(0,G.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,G.jsx)("div",{className:"font-display text-base font-medium text-dashboard-text",children:e.label}),(0,G.jsx)("div",{className:"mt-0.5 font-mono text-xs leading-relaxed text-dashboard-text-muted",children:e.detail})]}),(0,G.jsx)("div",{className:"font-display text-2xl font-light text-dashboard-text",children:e.value.toLocaleString("en-US")})]})}function pfe(e){let t=$C(e.record,"Type"),n=$C(e.record,"Remembered"),o=$C(e.record,"Source"),a=$C(e.record,"Visibility"),r=a==="Public";return(0,G.jsx)(dC,{className:_("flex items-stretch",!e.first&&"border-t border-white/[0.055]"),onSelect:e.onSelect,selected:e.selected,children:(0,G.jsxs)("button",{"aria-expanded":e.selected,"aria-label":`View memory details: ${e.record.title}`,className:"grid min-w-0 flex-1 cursor-pointer grid-cols-[minmax(0,1fr)_auto] items-center gap-3 border-0 bg-transparent px-4 py-3 text-left sm:grid-cols-[minmax(0,1fr)_7rem_7rem_9rem_auto]",onClick:e.onSelect,type:"button",children:[(0,G.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[(0,G.jsx)("div",{className:_("grid size-8 shrink-0 place-items-center rounded border",e.selected?"border-cyan-300/20 bg-cyan-300/10 text-cyan-100":"border-white/10 bg-white/[0.025] text-dashboard-text-muted"),children:(0,G.jsx)(dA,{"aria-hidden":"true",size:15})}),(0,G.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,G.jsx)("h3",{className:"m-0 truncate font-display text-base font-medium leading-snug text-dashboard-text",children:e.record.title}),(0,G.jsxs)("div",{className:"mt-1.5 flex min-w-0 items-center gap-x-2 font-mono text-xs text-dashboard-text-muted",children:[(0,G.jsxs)("span",{className:"truncate",children:["Source: ",o]}),(0,G.jsx)("span",{"aria-hidden":"true",className:"text-dashboard-text-muted opacity-30 sm:hidden",children:"\xB7"}),(0,G.jsxs)("span",{className:"truncate sm:hidden",children:[t," \xB7 ",a," \xB7 ",rY(n)]})]})]})]}),(0,G.jsxs)("span",{className:_("hidden items-center gap-1.5 rounded border px-2 py-1 font-mono text-2xs uppercase tracking-[0.08em] sm:inline-flex",r?"border-emerald-300/20 bg-emerald-300/[0.07] text-emerald-100":"border-white/[0.08] bg-white/[0.025] text-dashboard-text-muted"),children:[r?(0,G.jsx)(Wn,{"aria-hidden":"true",size:11}):(0,G.jsx)(Zn,{"aria-hidden":"true",size:11}),a]}),(0,G.jsx)("span",{className:_("hidden w-fit rounded border px-2 py-1 font-mono text-2xs uppercase tracking-[0.08em] sm:block",gfe(t)),children:t}),(0,G.jsx)("span",{className:"hidden truncate font-mono text-xs text-dashboard-text sm:block",children:rY(n)}),(0,G.jsx)(va,{"aria-hidden":"true",className:_("shrink-0 transition-transform",e.selected?"translate-x-0.5 text-cyan-200":"text-dashboard-text-muted group-hover:text-dashboard-text"),size:16})]})})}function $C(e,t){return e.metadata?.find(n=>n.label===t)?.value??"\u2014"}function rY(e){return e.split(",").slice(0,2).join(",")}function gfe(e){return e==="Preference"?"border-cyan-300/20 bg-cyan-300/[0.07] text-cyan-100":e==="Procedure"?"border-amber-300/20 bg-amber-300/[0.07] text-amber-100":"border-violet-300/20 bg-violet-300/[0.07] text-violet-100"}var _e=C(E(),1);function jC(e,t){return e==="memory"&&t==="memories"?"/memories":`/plugins/${encodeURIComponent(e)}/${encodeURIComponent(t)}`}function R2(e){let t=e.pages.find(n=>n.pluginName==="memory"&&n.id==="memories");return t?(0,_e.jsx)(iY,{page:t}):(0,_e.jsx)(Ct,{replace:!0,to:"/"})}function AY(e){let t=yt(),{"*":n,pageId:o,pluginName:a}=ua(),r=e.pages.find(i=>i.pluginName===a&&i.id===o);if(!r)return(0,_e.jsx)(Ct,{replace:!0,to:"/"});if(r.pluginName==="memory"&&r.id==="memories"){let i=n?`/${n}`:"";return(0,_e.jsx)(Ct,{replace:!0,to:Bi(`/memories${i}`,t.search)})}return(0,_e.jsx)(mfe,{page:r})}function mfe(e){let{action:t,content:n,query:o,records:a,runAction:r,searchText:i,setSearchText:A}=gC(e.page);return!o.data&&!o.error?(0,_e.jsx)(be,{label:`Loading ${e.page.label}`}):(0,_e.jsx)("div",{className:`${Nn} px-4 py-8 md:px-8`,children:(0,_e.jsxs)("section",{className:"mx-auto grid w-full max-w-3xl gap-6",children:[(0,_e.jsx)(vt,{description:e.page.description,title:e.page.label}),n?.metrics?.length?(0,_e.jsx)("section",{"aria-label":`${e.page.label} overview`,className:"grid gap-3 sm:grid-cols-2",children:n.metrics.map(s=>(0,_e.jsxs)(q,{className:"p-4",children:[(0,_e.jsx)("div",{className:"font-mono text-xs uppercase tracking-[0.12em] text-dashboard-text-muted",children:s.label}),(0,_e.jsx)("div",{className:"mt-3 font-display text-2xl font-light text-dashboard-text",children:s.value}),s.detail?(0,_e.jsx)("div",{className:"mt-1 font-mono text-xs text-dashboard-text-muted",children:s.detail}):null]},s.label))}):null,n?.searchPlaceholder?(0,_e.jsx)(ga,{className:"w-full",label:n.searchPlaceholder,onChange:A,placeholder:n.searchPlaceholder,size:"default",value:i}):null,o.error?(0,_e.jsx)(q,{padding:"md",children:(0,_e.jsxs)("p",{className:"m-0 text-sm text-rose-300",children:["Could not load ",e.page.label.toLowerCase(),". Try again."]})}):a.length===0?(0,_e.jsx)(q,{padding:"md",children:(0,_e.jsxs)("div",{className:"flex items-center gap-4",children:[(0,_e.jsx)("div",{className:"grid size-10 shrink-0 place-items-center rounded border border-white/[0.07] bg-white/[0.025] text-dashboard-text-muted",children:(0,_e.jsx)(wo,{"aria-hidden":"true",size:17})}),(0,_e.jsx)("p",{className:"m-0 text-sm text-dashboard-text-muted",children:n?.emptyText??`No ${e.page.label.toLowerCase()}.`})]})}):(0,_e.jsxs)("div",{className:"grid gap-3",children:[a.map(s=>(0,_e.jsxs)(q,{padding:"md",children:[(0,_e.jsxs)("div",{className:"flex items-start gap-3",children:[(0,_e.jsx)("h2",{className:"m-0 min-w-0 flex-1 font-display text-base font-medium text-dashboard-text",children:s.title}),s.actions?.map(c=>(0,_e.jsx)("button",{"aria-label":`${c.label}: ${s.title}`,className:`cursor-pointer border-0 bg-transparent p-1 text-dashboard-text-muted transition-colors ${c.tone==="danger"?"hover:text-rose-300":"hover:text-dashboard-text"}`,disabled:t.isPending,onClick:()=>r(c),title:c.label,type:"button",children:c.tone==="danger"?(0,_e.jsx)(Ir,{"aria-hidden":"true",size:16}):c.label},`${c.method}:${c.href}`))]}),s.description?(0,_e.jsx)("p",{className:"mt-2 mb-0 text-sm text-dashboard-text-muted",children:s.description}):null,s.metadata?.length?(0,_e.jsx)("dl",{className:"mt-4 flex flex-wrap gap-x-6 gap-y-2",children:s.metadata.map(c=>(0,_e.jsxs)("div",{children:[(0,_e.jsx)("dt",{className:"font-mono text-xs uppercase tracking-[0.12em] text-dashboard-text-muted",children:c.label}),(0,_e.jsx)("dd",{className:"mt-1 ml-0 font-mono text-xs text-dashboard-text-muted",children:c.value})]},c.label))}):null]},s.id)),(0,_e.jsx)(oC,{hasMore:!o.isPlaceholderData&&!!o.hasNextPage,loading:o.isFetchingNextPage,onLoadMore:()=>{o.fetchNextPage()}}),t.error?(0,_e.jsx)("p",{className:"m-0 text-center text-sm text-rose-300",children:"Could not complete this action. Try again."}):null]})]})})}var ut=C(E(),1),ffe=80,bfe=140;function hfe(e,t){let n=e?.trim().split(/\s+/).filter(Boolean)??[];return n.length>0?n.slice(0,2).map(o=>o[0]).join("").toUpperCase():t.slice(0,1).toUpperCase()}function sY({identity:e,onSignOut:t,spend:n,userPages:o}){let[a,r]=(0,xi.useState)(!1),i=(0,xi.useRef)(null),A=(0,xi.useRef)(null),s=(0,xi.useRef)(void 0),c=(0,xi.useRef)(void 0),d=e.user.email,l=e.user.name?.trim()||d,g=n?Je({total:n.sevenDaysUsd}):"\u2014",p=n?Je({total:n.thirtyDaysUsd}):"\u2014";function m(){s.current&&clearTimeout(s.current),c.current&&clearTimeout(c.current),s.current=void 0,c.current=void 0}function h(f){f.pointerType==="mouse"&&(m(),s.current=setTimeout(()=>r(!0),ffe))}function B(f){f.pointerType==="mouse"&&(m(),c.current=setTimeout(()=>r(!1),bfe))}return(0,xi.useEffect)(()=>m,[]),(0,xi.useEffect)(()=>{if(!a)return;function f(y){i.current?.contains(y.target)||r(!1)}function b(y){y.key==="Escape"&&(r(!1),A.current?.focus())}return document.addEventListener("pointerdown",f),document.addEventListener("keydown",b),()=>{document.removeEventListener("pointerdown",f),document.removeEventListener("keydown",b)}},[a]),(0,ut.jsxs)("div",{className:"relative",onBlurCapture:f=>{f.currentTarget.contains(f.relatedTarget)||r(!1)},onPointerEnter:h,onPointerLeave:B,ref:i,children:[(0,ut.jsxs)("button",{"aria-controls":"profile-popover","aria-expanded":a,"aria-haspopup":"true","aria-label":`${a?"Close":"Open"} profile menu for ${l}. Personal model spend: 7 days ${g}, 30 days ${p}.`,className:_("group flex h-10 cursor-pointer items-center gap-2 rounded-lg border-0 bg-transparent px-1.5 text-dashboard-text transition-colors hover:bg-white/[0.06] hover:text-dashboard-text focus-visible:outline focus-visible:outline-2 focus-visible:outline-[#beaaff]/70",a&&"bg-white/[0.08] text-dashboard-text"),onClick:f=>{m(),r(f.detail===0?b=>!b:!0)},ref:A,type:"button",children:[(0,ut.jsxs)("span",{className:"hidden items-center gap-2 md:flex",children:[(0,ut.jsxs)("span",{className:"flex items-baseline gap-1 whitespace-nowrap tabular-nums",children:[(0,ut.jsx)("span",{className:"text-xs font-medium tracking-[0.08em] text-dashboard-text-muted",children:"7d"}),(0,ut.jsx)("span",{className:"text-xs font-semibold text-dashboard-text",children:g})]}),(0,ut.jsx)("span",{"aria-hidden":"true",className:"h-3 w-px bg-white/10"}),(0,ut.jsxs)("span",{className:"flex items-baseline gap-1 whitespace-nowrap tabular-nums",children:[(0,ut.jsx)("span",{className:"text-xs font-medium tracking-[0.08em] text-dashboard-text-muted",children:"30d"}),(0,ut.jsx)("span",{className:"text-xs font-semibold text-dashboard-text",children:p})]})]}),(0,ut.jsx)("span",{"aria-hidden":"true",className:"grid size-7 place-items-center rounded-full bg-[#beaaff] text-xs font-bold tracking-wide text-black shadow-sm shadow-black/40",children:hfe(e.user.name,d)}),(0,ut.jsx)(Ng,{"aria-hidden":"true",className:_("hidden text-dashboard-text-muted transition-[color,transform] group-hover:text-dashboard-text md:block",a&&"rotate-180 text-dashboard-text"),size:14,strokeWidth:2})]}),a?(0,ut.jsxs)("div",{className:"absolute right-0 top-[calc(100%+0.5rem)] z-40 w-64 rounded-xl bg-dashboard-surface-raised/95 p-1.5 shadow-2xl shadow-black/75 backdrop-blur-xl",id:"profile-popover",children:[(0,ut.jsxs)("div",{className:"border-b border-white/10 px-2.5 py-2.5",children:[(0,ut.jsx)("p",{className:"m-0 truncate text-sm font-semibold text-dashboard-text",children:l}),l!==d?(0,ut.jsx)("p",{className:"mt-1 mb-0 truncate text-xs text-dashboard-text-muted",children:d}):null]}),(0,ut.jsxs)(ye,{className:"mt-1 flex items-center gap-2.5 rounded-md px-2.5 py-2 text-sm font-semibold text-dashboard-text no-underline transition-colors hover:bg-white/10 hover:text-dashboard-text focus-visible:bg-white/10 focus-visible:text-dashboard-text focus-visible:outline-none",onClick:()=>r(!1),to:hi(d),children:[(0,ut.jsx)(Fa,{"aria-hidden":"true",size:16,strokeWidth:2}),"My profile"]}),(0,ut.jsxs)(ye,{className:"flex items-center gap-2.5 rounded-md px-2.5 py-2 text-sm font-semibold text-dashboard-text no-underline transition-colors hover:bg-white/10 hover:text-dashboard-text focus-visible:bg-white/10 focus-visible:text-dashboard-text focus-visible:outline-none",onClick:()=>r(!1),to:"/settings",children:[(0,ut.jsx)(im,{"aria-hidden":"true",size:16,strokeWidth:2}),"Settings"]}),(0,ut.jsxs)(ye,{className:"flex items-center gap-2.5 rounded-md px-2.5 py-2 text-sm font-semibold text-dashboard-text no-underline transition-colors hover:bg-white/10 hover:text-dashboard-text focus-visible:bg-white/10 focus-visible:text-dashboard-text focus-visible:outline-none",onClick:()=>r(!1),to:"/settings/api-tokens",children:[(0,ut.jsx)(Qr,{"aria-hidden":"true",size:16,strokeWidth:2}),"API tokens"]}),o.filter(f=>f.navigation==="profile").map(f=>(0,ut.jsxs)(ye,{className:"flex items-center gap-2.5 rounded-md px-2.5 py-2 text-sm font-semibold text-dashboard-text no-underline transition-colors hover:bg-white/10 hover:text-dashboard-text focus-visible:bg-white/10 focus-visible:text-dashboard-text focus-visible:outline-none",onClick:()=>r(!1),to:jC(f.pluginName,f.id),children:[(0,ut.jsx)(wo,{"aria-hidden":"true",size:16,strokeWidth:2}),f.label]},`${f.pluginName}:${f.id}`)),(0,ut.jsxs)("button",{className:"flex w-full cursor-pointer items-center gap-2.5 rounded-md border-0 bg-transparent px-2.5 py-2 text-left text-sm font-semibold text-dashboard-text transition-colors hover:bg-white/10 hover:text-dashboard-text focus-visible:bg-white/10 focus-visible:text-dashboard-text focus-visible:outline-none",onClick:()=>{r(!1),t()},type:"button",children:[(0,ut.jsx)(Zg,{"aria-hidden":"true",size:16,strokeWidth:2}),"Log out"]})]}):null]})}var tu=C(z(),1);var Nt=C(E(),1),Bfe=["a[href]","button:not([disabled])","input:not([disabled]):not([type='hidden'])","select:not([disabled])","textarea:not([disabled])","[tabindex]:not([tabindex='-1'])"].join(",");function cY(e){let t=(0,tu.useRef)(null),n=(0,tu.useRef)(null),o=(0,tu.useRef)(void 0),a=(0,tu.useRef)(e.onMobileNavigationOpenChange);a.current=e.onMobileNavigationOpenChange;let r=({isActive:A})=>_("shrink-0 whitespace-nowrap rounded-md px-2.5 py-2 font-mono text-xs font-medium tracking-normal no-underline transition-colors",A?"bg-cyan-300/[0.1] text-cyan-50":_("hover:bg-white/[0.035]",ui)),i=({isActive:A})=>_("rounded-lg px-3 py-3 font-mono text-sm font-medium tracking-normal no-underline transition-colors",A?"bg-cyan-300/[0.1] text-cyan-50":_("hover:bg-white/[0.035]",ui));return(0,tu.useEffect)(()=>{if(!e.mobileNavigationOpen)return;let A=window.matchMedia("(max-width: 767px)"),s=()=>{A.matches||a.current(!1)};s(),A.addEventListener("change",s),o.current=document.activeElement instanceof HTMLElement?document.activeElement:n.current??void 0;let c=document.body.style.overflow;document.body.style.overflow="hidden";let d=requestAnimationFrame(()=>{t.current?.querySelector("[data-mobile-nav-close]")?.focus()}),l=g=>{if(g.key!=="Tab")return;let p=t.current,m=Array.from(p?.querySelectorAll(Bfe)??[]).filter(b=>b.tabIndex>=0&&b.getClientRects().length>0),h=m.at(0),B=m.at(-1);if(!p||!h||!B){g.preventDefault();return}let f=document.activeElement;g.shiftKey&&(f===h||!p.contains(f))?(g.preventDefault(),B.focus()):!g.shiftKey&&(f===B||!p.contains(f))&&(g.preventDefault(),h.focus())};return window.addEventListener("keydown",l),()=>{cancelAnimationFrame(d),A.removeEventListener("change",s),window.removeEventListener("keydown",l),document.body.style.overflow=c;let g=o.current;o.current=void 0,g?.isConnected&&g.focus()}},[e.mobileNavigationOpen]),(0,Nt.jsxs)("header",{className:"relative border-b border-white/[0.05]",children:[(0,Nt.jsxs)("div",{className:_(Nn,"grid grid-cols-[2.5rem_minmax(0,1fr)_2.5rem] items-center gap-x-2 px-3 py-2 md:gap-x-5 md:gap-y-3 md:px-4 md:py-4",e.profile?"md:grid-cols-[auto_minmax(0,1fr)_auto]":"md:grid-cols-[auto_minmax(0,1fr)]",e.compact?"md:px-4":"md:px-8"),children:[(0,Nt.jsx)("button",{"aria-controls":"mobile-navigation","aria-expanded":e.mobileNavigationOpen,"aria-hidden":e.mobileNavigationOpen||void 0,"aria-label":"Open navigation",className:"grid size-10 cursor-pointer place-items-center rounded-lg border-0 bg-transparent text-dashboard-text transition-colors hover:bg-white/[0.06] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[#beaaff]/70 md:hidden",onClick:()=>e.onMobileNavigationOpenChange(!0),ref:n,tabIndex:e.mobileNavigationOpen?-1:void 0,type:"button",children:(0,Nt.jsx)(Xg,{"aria-hidden":"true",size:20,strokeWidth:2})}),(0,Nt.jsx)(ye,{"aria-label":`${nt()} home`,className:"flex min-w-0 max-w-full items-center justify-self-center text-inherit no-underline md:justify-self-start",to:"/",children:(0,Nt.jsx)(vg,{})}),(0,Nt.jsxs)("nav",{"aria-label":"Primary",className:"hidden min-w-0 items-center gap-1 md:col-start-2 md:flex md:justify-self-start",children:[(0,Nt.jsx)(ye,{"aria-current":e.workspaceActive?"page":void 0,className:r({isActive:e.workspaceActive}),to:"/",children:"Conversations"}),e.navItems.map(A=>(0,Nt.jsx)(ts,{className:r,to:A.to,children:A.label},A.key))]}),e.profile?(0,Nt.jsx)("div",{className:"col-start-3 justify-self-end",children:e.profile}):null]}),e.mobileNavigationOpen?(0,Nt.jsxs)("div",{"aria-label":"Navigation","aria-modal":"true",className:"fixed inset-0 z-50 flex flex-col bg-[#070707] md:hidden",id:"mobile-navigation",onClick:A=>{A.target instanceof Element&&A.target.closest("a[href]")&&a.current(!1)},ref:t,role:"dialog",children:[(0,Nt.jsxs)("div",{className:"flex items-center justify-between gap-3 border-b border-white/[0.07] bg-dashboard-surface-raised px-3 py-2 pt-[max(0.5rem,env(safe-area-inset-top))]",children:[(0,Nt.jsx)(ye,{"aria-label":`${nt()} home`,className:"flex min-w-0 items-center text-inherit no-underline",to:"/",children:(0,Nt.jsx)(vg,{})}),(0,Nt.jsx)("button",{"aria-label":"Close navigation",className:"grid size-10 cursor-pointer place-items-center rounded-lg border-0 bg-transparent text-dashboard-text transition-colors hover:bg-white/[0.06] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[#beaaff]/70","data-mobile-nav-close":!0,onClick:()=>e.onMobileNavigationOpenChange(!1),type:"button",children:(0,Nt.jsx)(ko,{"aria-hidden":"true",size:20,strokeWidth:2})})]}),(0,Nt.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain p-3",children:[(0,Nt.jsxs)("nav",{"aria-label":"Primary",className:"grid gap-1",children:[(0,Nt.jsx)(ye,{"aria-current":e.workspaceActive?"page":void 0,className:i({isActive:e.workspaceActive}),to:"/",children:"Conversations"}),e.navItems.map(A=>(0,Nt.jsx)(ts,{className:i,to:A.to,children:A.label},A.key))]}),(0,Nt.jsx)(UO,{})]}),e.version?(0,Nt.jsxs)("p",{className:"m-0 border-t border-white/[0.07] px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] font-mono text-xs text-dashboard-text-muted",children:["junior version ",e.version]}):null]}):null]})}var Ur=C(z(),1);var nu=C(z(),1);var xs=C(z(),1);function PC(e){return["conversation",e,"outbox"]}function uY(e){return{createdAt:e.now??new Date().toISOString(),idempotencyKey:e.idempotencyKey,message:e.message,messageId:`client:${e.idempotencyKey}`,status:"sending"}}function yfe(e){return{clientStatus:e.status,createdAt:e.createdAt,delivery:"defer",idempotencyKey:e.idempotencyKey,inboundMessageId:e.messageId,messageId:e.messageId,receivedAt:e.createdAt,role:"user",source:"web",text:e.message}}function dY(e,t){let n=e??[],o=t??[];if(o.length===0)return[...n];let a=new Set(n.map(i=>i.messageId)),r=o.filter(i=>!a.has(i.messageId)).map(yfe);return r.length===0?[...n]:[...n,...r]}function lY(e,t){let n=e??[],o=n.findIndex(r=>r.idempotencyKey===t.idempotencyKey);if(o<0)return[...n,t];let a=n.slice();return a[o]=t,a}function pY(e,t){return(e??[]).filter(n=>n.idempotencyKey!==t)}function gY(e,t){return(e??[]).map(n=>n.idempotencyKey===t?{...n,status:"failed"}:n)}function N2(e,t){if(e.eventHistory.status!=="available")return mY(e);let n=t.find(o=>o.eventHistory.status!=="available");return n?mY({...e,eventHistory:n.eventHistory,events:n.events,previousCursor:n.previousCursor}):{...e,events:wfe([...t.flatMap(o=>o.events),...e.events]),previousCursor:GC(e.previousCursor,t)??(t.length?CY(t):e.previousCursor)}}async function fY(e){let t=new Map(e.historyPages.map(r=>[r.requestedBefore,r])),n=[],o=new Set,a=e.detail.previousCursor;for(;a;){if(o.has(a))throw new Error("Conversation history cursor did not advance");o.add(a);let r=t.get(a)??{...await e.readPage(a),requestedBefore:a};n.push(r),a=r.previousCursor}return N2(e.detail,n)}function bY(e){let t=yY(e);return t===void 0?"empty":String(t)}function hY(e,t){return GC(e,t)??CY(t)}function GC(e,t){if(!e)return;let n=new Map(t.map(i=>[i.requestedBefore,i])),o=new Set,a=new Set,r=e;for(;r;){if(a.has(r))return;a.add(r);let i=n.get(r);if(!i)return o.size>0&&o.size===t.length?void 0:r;o.add(i);let A=yY(o),s=Cfe(t.filter(c=>!o.has(c)));if(A!==void 0&&s!==void 0&&A<=s+1)return;r=i.previousCursor}}function BY(e,t){return t.some(n=>n.eventHistory.status!==e.eventHistory.status)}function yY(e){let t;for(let n of e){let o=n.events[0]?.seq;o!==void 0&&(t===void 0||o<t)&&(t=o)}return t}function Cfe(e){let t;for(let n of e){let o=n.events.at(-1)?.seq;o!==void 0&&(t===void 0||o>t)&&(t=o)}return t}function CY(e){let t;for(let n of e){let o=n.events[0]?.seq,a=t?.events[0]?.seq;o!==void 0&&(a===void 0||o<a)&&(t=n)}return t?.previousCursor}function wfe(e){return[...new Map(e.map(t=>[t.seq,t])).values()].sort((t,n)=>t.seq-n.seq)}function mY(e){let{modelUsage:t,...n}=e;return n}function of(e){return["conversation",e,"detail"]}function wY(e){return["dashboard","archived-conversation",e]}var kY=["dashboard","archive-conversation"];function QY(){return tE({filters:{mutationKey:kY,status:"pending"},select:e=>{let t=e.state.variables,n=e.state.context,o=e.options.mutationKey?.[2];return{archived:t.archived,conversation:n?.archivedSnapshot?.conversation,conversationId:typeof o=="string"?o:""}}})}function vs(e){return["conversation",e,"pending-messages"]}function Efe(e){return{enabled:!!e,queryKey:of(e),queryFn:({signal:t})=>Ife(e,t),refetchInterval:t=>t.state.data?.status==="active"?2e3:!1,retry:!1}}function kfe(e,t){return{enabled:!!e,queryKey:vs(e),queryFn:({signal:n})=>_fe(e,n),refetchInterval:n=>t?.activeConversation||n.state.data?.messages.length||n.state.data?.authorization?2e3:!1,retry:!1}}function IY(){let e=Xt();return ya({mutationFn:t=>_g(ry,"/api/conversations",t),onSuccess:t=>{e.invalidateQueries({queryKey:["dashboard","conversations"]}),e.invalidateQueries({exact:!0,queryKey:vs(t.conversationId)})}})}function _Y(e){let t=Xt(),n=PC(e);return ya({mutationFn:o=>_g(ry,`/api/conversations/${encodeURIComponent(e)}/messages`,o),onMutate:async o=>{let a=uY(o);t.setQueryData(n,r=>lY(r,a))},onError:(o,a)=>{t.setQueryData(n,r=>gY(r,a.idempotencyKey))},onSuccess:(o,a)=>{t.setQueryData(n,r=>pY(r,a.idempotencyKey)),t.invalidateQueries({queryKey:["dashboard","conversations"]}),t.invalidateQueries({exact:!0,queryKey:of(e)}),t.invalidateQueries({exact:!0,queryKey:vs(e)})}})}function vY(e){let t=Xt();return ya({mutationFn:n=>H7(nF,`/api/conversations/${encodeURIComponent(e)}/pending-messages`,n),onMutate:async n=>{await t.cancelQueries({exact:!0,queryKey:vs(e)});let o=t.getQueryData(vs(e));return o&&t.setQueryData(vs(e),{...o,messages:o.messages.filter(a=>!n.inboundMessageIds.includes(a.inboundMessageId))}),{previousPending:o}},onError:(n,o,a)=>{a?.previousPending&&t.setQueryData(vs(e),a.previousPending)},onSettled:async()=>{await Promise.all([t.invalidateQueries({queryKey:["dashboard","conversations"]}),t.invalidateQueries({exact:!0,queryKey:of(e)}),t.invalidateQueries({exact:!0,queryKey:vs(e)})])}})}function rf(e,t){let n=Xt();return ya({mutationKey:[...kY,e],mutationFn:o=>cy(eF,`/api/conversations/${encodeURIComponent(e)}/archive`,o),onMutate:async o=>{let a={queryKey:["dashboard","conversations"]},r=of(e),i=wY(e);await Promise.all([n.cancelQueries(a),n.cancelQueries({queryKey:r})]);let A=n.getQueriesData(a),s=n.getQueryData(r),c=n.getQueryData(i),d=o.archived?new Date().toISOString():void 0,l=o.archived?Qfe(A,e)??c:c;return A.forEach(([g,p])=>{if(!p)return;let m=p.conversations.some(f=>f.conversationId===e),B=!o.archived&&!m&&!!l?.feedQueryHashes.includes(JSON.stringify(g))?[...p.conversations,{...l.conversation,archivedAt:void 0}].sort((f,b)=>b.lastSeenAt.localeCompare(f.lastSeenAt)):p.conversations.map(f=>f.conversationId===e?{...f,archivedAt:d}:f);n.setQueryData(g,{...p,conversations:B})}),n.setQueryData(r,g=>g&&{...g,archivedAt:d}),l&&n.setQueryData(i,l),{archivedQueryKey:i,archivedSnapshot:l,detailQueryKey:r,previousArchivedSnapshot:c,previousDetail:s,previousFeeds:A}},onError:(o,a,r)=>{r?.previousFeeds.forEach(([i,A])=>{n.setQueryData(i,A)}),r&&(n.setQueryData(r.detailQueryKey,r.previousDetail),r.previousArchivedSnapshot?n.setQueryData(r.archivedQueryKey,r.previousArchivedSnapshot):n.removeQueries({exact:!0,queryKey:r.archivedQueryKey})),t?.onError?.()},onSuccess:(o,a)=>{a.archived||n.removeQueries({exact:!0,queryKey:wY(e)}),t?.onSuccess?.(a.archived)},onSettled:async()=>{await Promise.all([n.invalidateQueries({queryKey:["dashboard","conversations"]}),n.invalidateQueries({queryKey:["dashboard","locations"]}),n.invalidateQueries({queryKey:["dashboard","people"]}),n.invalidateQueries({exact:!0,queryKey:of(e)})])}})}function Qfe(e,t){let n,o=[];for(let[a,r]of e){let i=r?.conversations.find(A=>A.conversationId===t);i&&(n??=i,o.push(JSON.stringify(a)))}return n?{conversation:n,feedQueryHashes:o}:void 0}function HC(e){let t=Xt(),n=ze(Efe(e)),o=ze(kfe(e,{activeConversation:n.data?.status==="active"})),a=n.data?.eventHistory.status,r=(0,xs.useMemo)(()=>["conversation",e,"history",a],[e,a]),i=Ll({enabled:!1,queryKey:r,queryFn:async({pageParam:b,signal:y})=>({...await EY(e,b,y),requestedBefore:b}),initialPageParam:n.data?.previousCursor??"",getNextPageParam:(b,y)=>hY(n.data?.previousCursor,y),retry:!1}),A=i.data?.pages,s=(0,xs.useMemo)(()=>n.data?N2(n.data,A??[]):void 0,[n.data,A]),c=ze({enabled:!!e,queryFn:async()=>t.getQueryData(PC(e))??[],queryKey:PC(e),initialData:[],staleTime:1/0,gcTime:1/0}),d=(0,xs.useMemo)(()=>dY(o.data?.messages,c.data),[c.data,o.data?.messages]),l=vfe(i.error),g=!!(n.data&&(BY(n.data,A??[])||l)),p=l?null:i.error,m=!!(n.data?.previousCursor&&i.data&&GC(n.data.previousCursor,i.data.pages)&&!g&&!i.error&&!i.isFetchingNextPage),h=i.isFetchingNextPage||m,B=n.refetch;(0,xs.useEffect)(()=>{g&&B()},[B,g]),(0,xs.useEffect)(()=>{l&&t.resetQueries({exact:!0,queryKey:r})},[r,l,t]);let f=i.fetchNextPage;return(0,xs.useEffect)(()=>{m&&f()},[f,m]),{data:s,error:n.error,historyError:p,historyVersion:bY(A??[]),hasPreviousPage:i.data?i.hasNextPage:!!n.data?.previousCursor,isPending:n.isPending,isLoadingPreviousPage:h,pendingAuthorization:o.data?.authorization,pendingGeneratedAt:o.data?.generatedAt,pendingMessages:d,loadCompleteTranscript:()=>{if(!e||!n.data)throw new Error("Cannot load a conversation without an id");return fY({detail:n.data,historyPages:i.data?.pages??[],readPage:b=>EY(e,b)})},loadPreviousPage:()=>{let b=i.data?i.hasNextPage:!!n.data?.previousCursor;e&&b&&!i.isFetchingNextPage&&i.fetchNextPage()}}}function Ife(e,t){return Ke(rF,`/api/conversations/${encodeURIComponent(e)}`,t)}function _fe(e,t){return Ke(tF,`/api/conversations/${encodeURIComponent(e)}/pending-messages`,t)}function EY(e,t,n){let o=new URLSearchParams({before:t});return Ke(iF,`/api/conversations/${encodeURIComponent(e)}/events?${o}`,n).then(a=>{if(a.previousCursor===t)throw new Error("Conversation history cursor did not advance");return a})}function vfe(e){return e instanceof qo&&e.status===400}var DY=C(E(),1);function xY(e){return(0,DY.jsx)("span",{"aria-hidden":"true",className:_("shrink-0 rounded-full bg-emerald-300 shadow-[0_0_10px_rgba(110,231,183,0.55)] animate-[junior-active-indicator_1.8s_ease-in-out_infinite] motion-reduce:animate-none",e.className)})}var Di=C(E(),1);function $2({action:e,children:t,detail:n,icon:o,title:a,tone:r="default"}){let i=r==="error";return(0,Di.jsxs)("div",{className:_("overflow-hidden rounded-xl shadow-[0_16px_40px_rgba(0,0,0,0.5)]",i?"bg-[#1f1216]":"bg-[#111719]"),children:[(0,Di.jsxs)("div",{className:"flex min-w-0 items-center gap-3 px-3 py-3",children:[o?(0,Di.jsx)("div",{className:_("grid size-8 shrink-0 place-items-center rounded-lg",i?"bg-rose-300/15 text-rose-100":"bg-cyan-300/10 text-cyan-100/80"),children:(0,Di.jsx)(o,{"aria-hidden":"true",size:16})}):null,(0,Di.jsxs)("div",{className:"min-w-0 flex-1",role:i?"alert":"status",children:[(0,Di.jsxs)("div",{className:_("font-display text-sm font-medium leading-snug",i?"text-rose-50":"text-dashboard-text"),children:[a,n?" ":null]}),n?(0,Di.jsx)("div",{className:_("mt-0.5 truncate font-mono text-xs",i?"text-rose-100/70":"text-dashboard-text-muted"),children:n}):null]}),e]}),t]})}function M2({className:e,tone:t="default",type:n="button",...o}){let a=t==="error";return(0,Di.jsx)("button",{...o,className:_("shrink-0 cursor-pointer px-3 py-1.5 text-xs transition focus:outline-none focus:ring-2 disabled:cursor-not-allowed disabled:opacity-40",a?"focus:ring-rose-300/40":"focus:ring-cyan-300/35",a?"rounded-lg bg-rose-200/15 font-display font-medium text-rose-50 hover:bg-rose-200/25":"rounded-lg bg-cyan-200/10 font-display font-medium text-cyan-100 hover:bg-cyan-200/20",e),type:n})}var Io=C(z(),1);var Af=C(E(),1);function SY(e){let t=Ffe(),n=t?0:e.durationMs??180,[o,a]=(0,Io.useState)(()=>e.items.map(s=>({item:s,key:e.getKey(s),state:"present"}))),r=(0,Io.useRef)(e.items.length>0),i=o.some(s=>s.state==="exiting"),A=(0,Io.useCallback)(s=>{a(c=>c.filter(d=>d.key!==s))},[]);return(0,Io.useLayoutEffect)(()=>{a(s=>xfe(s,e.items,e.getKey,r.current)),e.items.length>0&&(r.current=!0)},[e.getKey,e.items]),(0,Io.useEffect)(()=>{if(!o.some(c=>c.state==="entering"))return;if(t){a(c=>FY(c));return}let s=window.requestAnimationFrame(()=>{a(c=>FY(c))});return()=>window.cancelAnimationFrame(s)},[o,t]),(0,Af.jsx)("div",{"aria-label":o.length>0?e.ariaLabel:void 0,className:_(e.className,i&&"pointer-events-none"),role:o.length>0?e.role:void 0,children:o.length>0?o.map(s=>(0,Af.jsx)(Dfe,{animatedItem:s,durationMs:n,onExited:A,renderItem:e.renderItem},s.key)):e.empty})}function xfe(e,t,n,o){let a=new Map(e.map(A=>[A.key,A])),r=new Set(t.map(n)),i=t.map(A=>{let s=n(A),c=a.get(s);return{item:A,key:s,state:c?.state==="exiting"?"entering":c?.state??(o?"entering":"present")}});return e.forEach((A,s)=>{r.has(A.key)||i.splice(Math.min(s,i.length),0,{...A,state:"exiting"})}),i}function Dfe(e){let{animatedItem:t,durationMs:n,onExited:o}=e;return(0,Io.useEffect)(()=>{if(t.state!=="exiting")return;let a=window.setTimeout(()=>o(t.key),n);return()=>window.clearTimeout(a)},[t.key,t.state,n,o]),(0,Af.jsx)("div",{"aria-hidden":t.state==="exiting"?!0:void 0,className:_("grid min-w-0 origin-center transition-[grid-template-rows,opacity,transform] motion-reduce:transition-none",t.state==="present"?"grid-rows-[1fr] translate-x-0 scale-100 opacity-100":"pointer-events-none grid-rows-[0fr] translate-x-2 scale-[0.98] opacity-0"),"data-presence":t.state,inert:t.state==="exiting"?!0:void 0,style:{transitionDuration:`${e.durationMs}ms`,transitionTimingFunction:"cubic-bezier(0.2, 0.8, 0.2, 1)"},children:(0,Af.jsx)("div",{className:"min-h-0 min-w-0 overflow-hidden",children:e.renderItem(t.item)})})}function FY(e){return e.map(t=>t.state==="entering"?{...t,state:"present"}:t)}function Ffe(){let[e,t]=(0,Io.useState)(!1);return(0,Io.useEffect)(()=>{let n=window.matchMedia("(prefers-reduced-motion: reduce)"),o=()=>t(n.matches);return o(),n.addEventListener("change",o),()=>n.removeEventListener("change",o)},[]),e}var j2=["priority","today","yesterday","last-week","2-weeks","3-weeks","older"];function RY(e,t){let n=NY(t.nowMs,t.timeZone),o=new Map,a=[...e].sort((r,i)=>P2(i)-P2(r));for(let r of a){let i=P2(r),A=Sfe(r,i,n,t.timeZone),s=o.get(A.key);s?s.conversations.push(r):o.set(A.key,{...A,conversations:[r]})}return[...o.values()].sort((r,i)=>LY(r.key)-LY(i.key))}function P2(e){let t=Date.parse(e.lastSeenAt);return Number.isFinite(t)?t:Number.NEGATIVE_INFINITY}function Sfe(e,t,n,o){if(!Number.isFinite(t))return{key:"older",label:"Older"};if(e.isPriority)return{key:"priority",label:"Priority"};let a=NY(t,o),r=Math.max(0,Math.floor((n-a)/864e5));return r===0?{key:"today",label:"Today"}:r===1?{key:"yesterday",label:"Yesterday"}:r<7?{key:`day-${a}`,label:new Intl.DateTimeFormat("en-US",{timeZone:o,weekday:"long"}).format(t)}:r<14?{key:"last-week",label:"Last week"}:r<21?{key:"2-weeks",label:"2 weeks ago"}:r<28?{key:"3-weeks",label:"3 weeks ago"}:{key:"older",label:"Older"}}function LY(e){let t=j2.indexOf(e);return t>=0?t:e.startsWith("day-")?j2.indexOf("yesterday")+.5:j2.length}function NY(e,t){let n=new Intl.DateTimeFormat("en-US",{day:"numeric",month:"numeric",timeZone:t,year:"numeric"}).formatToParts(e),o=new Map(n.map(a=>[a.type,Number(a.value)]));return Date.UTC(o.get("year")??0,(o.get("month")??1)-1,o.get("day")??1)}var $Y=C(E(),1);function cn(e){return(0,$Y.jsx)("div",{className:"min-w-0 rounded-lg border border-white/10 bg-[#050505] px-4 py-3 text-base leading-relaxed text-dashboard-text-muted",children:e.children})}var UY=C(z(),1);var G2=C(E(),1),Lfe="animate-[junior-text-shimmer_1.6s_linear_infinite] bg-[linear-gradient(90deg,#777_0%,#d6d6d6_40%,#fff_50%,#d6d6d6_60%,#777_100%)] bg-[length:200%_100%] bg-clip-text text-transparent motion-reduce:animate-none";function Fi(e){if(!e.active&&!e.className&&!e["aria-label"])return e.children;let t=_(e.active&&Lfe,e.className);return e.as==="strong"?(0,G2.jsx)("strong",{"aria-label":e["aria-label"],className:t,children:e.children}):(0,G2.jsx)("span",{"aria-label":e["aria-label"],className:t,children:e.children})}var jt=C(E(),1);function MY(e){return(0,jt.jsx)("span",{className:"grid min-w-0 self-start grid-cols-[minmax(0,1fr)_auto] content-start gap-x-3 gap-y-1.5",children:e.lines.map((t,n)=>(0,jt.jsxs)("span",{className:t.label?"contents":_("col-span-2 block min-w-0 break-words text-dashboard-text",t.valueStyle==="heading"&&"font-mono font-semibold text-dashboard-text",t.valueStyle==="heading"&&n>0&&"mt-1 border-t border-white/10 pt-2"),children:[t.label?(0,jt.jsx)("span",{className:_("min-w-0 break-words font-medium text-dashboard-text-muted",t.labelStyle==="code"&&"break-all font-mono text-xs text-dashboard-text"),children:t.label}):null,t.label?(0,jt.jsx)("span",{className:"whitespace-nowrap text-right text-dashboard-text",children:t.value}):(0,jt.jsxs)(jt.Fragment,{children:[t.value,t.live?(0,jt.jsxs)("span",{className:"ml-2 inline-flex items-center gap-1.5 font-sans text-xs font-normal tracking-wide text-dashboard-text-muted",children:[(0,jt.jsx)("span",{"aria-hidden":"true",children:"\xB7"}),(0,jt.jsx)(Fi,{active:!0,children:"in progress"})]}):null]})]},`${n}-${t.label??""}-${t.value}-${t.live?"live":""}`))})}function Ds(e){let t=e.tooltip?.filter(a=>a.value.trim()),n=e.tooltipColumns?.map(a=>a.filter(r=>r.value.trim())).filter(a=>a.length),o=!!n?.length;return!t?.length&&!n?.length?(0,jt.jsx)("span",{className:e.className,children:e.children}):(0,jt.jsx)(Se,{align:e.align,className:_("w-[calc(100vw-2rem)] rounded-lg border border-white/15 bg-[#050505] px-3 py-2 text-left text-xs font-normal leading-relaxed text-dashboard-text-muted shadow-xl shadow-black/35",o?"max-w-[32.5rem]":"max-w-80"),content:n?.length?(0,jt.jsx)("span",{className:"grid max-h-72 grid-cols-1 items-start gap-4 overflow-y-auto sm:grid-cols-2 sm:gap-6",children:n.map((a,r)=>(0,jt.jsx)(MY,{lines:a},r))}):t?(0,jt.jsx)("span",{className:"block max-h-72 overflow-y-auto",children:(0,jt.jsx)(MY,{lines:t})}):null,placement:e.tooltipPlacement??"below",children:(0,jt.jsx)("span",{className:_("inline-flex border-b border-dotted border-white/20 outline-none transition-colors hover:border-white/45 focus-visible:border-white/45",e.className),tabIndex:0,children:e.children})})}function TC(e){return(0,jt.jsx)("div",{className:_("flex flex-wrap items-center gap-x-1.5 gap-y-1",e.className),children:e.items.map((t,n)=>(0,jt.jsxs)("span",{className:"inline-flex min-w-0 items-center gap-x-1.5",children:[n>0?(0,jt.jsx)("span",{className:"text-dashboard-text-muted",children:"\xB7"}):null,(0,jt.jsx)("span",{className:"min-w-0",children:t.content})]},t.key))})}var gl=C(E(),1);function H2(e){return!!e}function jY(e){return[e.inputTokens!==void 0?{label:"input",value:V(e.inputTokens)}:void 0,e.outputTokens!==void 0?{label:"output",value:V(e.outputTokens)}:void 0,e.cachedInputTokens!==void 0?{label:"cached",value:V(e.cachedInputTokens)}:void 0,e.cacheCreationTokens!==void 0?{label:"cache write",value:V(e.cacheCreationTokens)}:void 0,e.reasoningTokens!==void 0?{label:"reasoning",value:V(e.reasoningTokens)}:void 0,e.providerTotalTokens!==void 0?{label:"provider",value:V(e.providerTotalTokens)}:void 0]}function Rfe(e){return e.split("/").at(-1)??e}function sf(e,t){return{live:e===t,value:Rfe(e),valueStyle:"heading"}}function Nfe(e,t,n,o){let a=[n?{label:"compactions",value:V(n)}:void 0];t?.length||a.push(...jY(e));let r=!1;for(let i of t??[]){let A=Pm(i.usage);A&&(r||=i.modelId===o,a.push(sf(i.modelId,o),...jY(A).map(s=>s?.label?{...s,label:`\u2022 ${s.label}`}:s)))}return o&&!r&&a.push(sf(o,o)),a.filter(H2)}function UC(e){return[{label:"total",value:bi(e)},e.input!==void 0?{label:"input",value:bi({total:e.input})}:void 0,e.output!==void 0?{label:"output",value:bi({total:e.output})}:void 0,e.cacheRead!==void 0?{label:"cache read",value:bi({total:e.cacheRead})}:void 0,e.cacheWrite!==void 0?{label:"cache write",value:bi({total:e.cacheWrite})}:void 0].filter(H2)}function $fe(e,t,n,o){let a=eC(e,n),r=(t??[]).flatMap(c=>{let d=Gm(c.usage);return d?[{modelId:c.modelId,summary:d}]:[]}),i=o&&!r.some(c=>c.modelId===o)?[sf(o,o)]:[];if(!a)return{tooltip:i};if(!n)return r.length?{tooltip:[...r.flatMap(c=>[sf(c.modelId,o),...UC(c.summary).map(d=>({...d,label:`\u2022 ${d.label}`}))]),...i]}:{tooltip:[...e?UC(e):[],...i]};let A=[{value:"Conversation",valueStyle:"heading"},{label:"total",value:bi(a)}];if(e)if(A.push({label:"agent",value:bi(e)}),!r.length)A.push(...UC(e).filter(c=>c.label!=="total").map(c=>({...c,label:`\u2022 ${c.label}`})));else for(let c of r)A.push(sf(c.modelId,o),...UC(c.summary).map(d=>({...d,label:`\u2022 ${d.label}`})));A.push(...i);let s=[{value:"Auxiliary",valueStyle:"heading"},{label:"total",value:bi({total:n.costUsd})}];for(let c of n.operations)s.push({label:`${Mfe(c)} (${V(c.events)})`,value:bi({total:c.costUsd})});return{tooltipColumns:[A,s]}}function Mfe(e){let t={"junior/guardian_action_reviewed":"Guardian","junior/passive_reply_routed":"Passive reply routing","junior/turn_routed":"Thinking routing","memory/memories_captured":"Memory extraction","memory/memories_recalled":"Memory recall"},n=`${e.namespace}/${e.name}`;return t[n]??`${e.namespace} \xB7 ${e.name.replaceAll("_"," ")}`}function PY(e){let t=eC(e.summary,e.auxiliaryCosts);if(!t&&!e.live)return null;let n=!!e.live,o=t?`${Je(t)}${n?"+":""}`:"$\u2026";return(0,gl.jsx)(Ds,{align:e.align,tooltipPlacement:"above",...$fe(e.summary,e.modelUsage,e.auxiliaryCosts,e.liveModelId),children:(0,gl.jsx)(Fi,{active:n,children:o})})}function GY(e){return e.summary?(0,gl.jsx)(Ds,{align:e.align,tooltip:Nfe(e.summary,e.modelUsage,e.compactionCount,e.liveModelId),children:(0,gl.jsx)(Fi,{active:e.live,children:U8(e.summary)})}):null}function HY(e){if(!e.label||e.label==="none")return null;let n=[e.startedAt?{label:"started",value:Xn(e.startedAt)}:void 0,e.endedAt?{label:"ended",value:Xn(e.endedAt)}:void 0].filter(H2);return(0,gl.jsx)(Ds,{align:e.align,tooltip:n,children:e.label})}var W=C(E(),1),TY="(max-width: 767px)";function OY(e){return(0,W.jsxs)("div",{className:"mb-2 rounded-lg border border-cyan-300/20 bg-cyan-300/[0.07] px-3 py-2.5 font-sans text-sm text-dashboard-text",children:[(0,W.jsx)("a",{className:"font-medium text-cyan-200 underline decoration-cyan-300/40 underline-offset-2 hover:text-cyan-100",href:e.authorization.authorizationUrl,rel:"noreferrer",target:"_blank",children:e.authorization.label}),(0,W.jsx)("p",{className:"mb-0 mt-1 text-xs text-dashboard-text-muted",children:e.authorization.completionText})]})}function qY(e){if(!e.visibility)return null;let t=e.visibility==="public",n=t?Wn:Zn,o=t?"Public":"Private",a=t?"Public conversation":"Private conversation",r=t?"Anyone in this workspace can see this transcript.":"Only members of this conversation can see this transcript.";return(0,W.jsxs)("span",{className:t?"inline-flex max-w-full items-center gap-1 rounded-full border border-emerald-300/20 bg-emerald-300/[0.08] px-2 py-0.5 font-sans text-2xs font-medium text-emerald-50/85":"inline-flex max-w-full items-center gap-1 rounded-full border border-white/[0.1] bg-white/[0.04] px-2 py-0.5 font-sans text-2xs font-medium text-dashboard-text-muted",role:"note",title:`${a}. ${r}`,children:[(0,W.jsx)(n,{"aria-hidden":"true",className:"size-3 shrink-0"}),(0,W.jsx)("span",{"aria-hidden":"true",className:"truncate",children:o}),(0,W.jsxs)("span",{className:"sr-only",children:[a,". ",r]})]})}function zY(e){return!!e?.some(t=>t.kind==="resource_link")}function YY(e){let t=e.annotations,n=Gfe();if(!t?.length)return null;let o=t.map(r=>Tfe(r)),a=Hfe(t);return(0,W.jsx)(Se,{align:"left",content:(0,W.jsx)("ul",{className:"m-0 list-none space-y-1 p-0",children:t.map((r,i)=>(0,W.jsxs)("li",{className:"flex min-w-0 items-center gap-1.5",children:[r.icon?(0,W.jsx)(OC,{icon:r.icon}):null,(0,W.jsx)("span",{className:"min-w-0 truncate",children:o[i]})]},`${r.key}:${i}`))}),label:"Linked work",triggerClassName:"min-w-0",children:(0,W.jsx)("span",{"aria-label":`Linked work, newest first: ${o.join(", ")}`,className:"inline-flex min-w-0 max-w-full items-center",children:n?(0,W.jsx)(jfe,{annotations:a,cutoutColor:"var(--color-dashboard-surface-panel)"}):a.length<=2?(0,W.jsx)("span",{className:"inline-flex min-w-0 items-center gap-1",children:a.map(r=>(0,W.jsx)(KY,{annotation:r},r.key))}):(0,W.jsx)(Pfe,{annotations:a})})})}function jfe(e){return(0,W.jsx)("span",{className:_("relative isolate inline-flex h-[18px] items-center pr-0.5",e.className),children:e.annotations.map((t,n)=>(0,W.jsx)(JY,{annotation:t,cutoutColor:e.cutoutColor,stacked:n>0,zIndex:n+1},t.key))})}function Pfe(e){let[t,...n]=e.annotations;return!t||n.length===0?null:(0,W.jsxs)("span",{className:"isolate inline-flex h-5 min-w-0 items-center pr-0.5",children:[(0,W.jsx)(KY,{annotation:t}),n.map((o,a)=>(0,W.jsx)(JY,{annotation:o,cutoutColor:"var(--color-dashboard-surface-panel)",stacked:!0,zIndex:a+1},o.key)),(0,W.jsxs)("span",{className:"relative -ml-1.5 inline-flex h-5 min-w-7 shrink-0 items-center justify-center rounded-full border border-white/12 bg-dashboard-control px-1.5 font-mono text-2xs leading-none text-dashboard-text-muted",style:{boxShadow:"0 0 0 2px var(--color-dashboard-surface-panel)",zIndex:n.length+1},children:["+",n.length]})]})}function KY(e){return(0,W.jsxs)("span",{className:"inline-flex h-5 min-w-0 max-w-28 shrink-0 items-center gap-1 truncate rounded-full border border-white/10 bg-dashboard-control px-1.5 font-sans text-2xs leading-none text-dashboard-text-muted",children:[e.annotation.icon?(0,W.jsx)(OC,{decorative:!0,icon:e.annotation.icon,size:11}):null,(0,W.jsx)("span",{className:"min-w-0 truncate whitespace-nowrap",children:e.annotation.label})]})}function JY(e){let t=e.annotation.icon?WY[e.annotation.icon]:void 0;return(0,W.jsx)("span",{"aria-hidden":"true",className:_("relative box-border inline-flex size-[18px] shrink-0 items-center justify-center rounded-full border border-white/12 bg-dashboard-control",e.stacked&&"-ml-2"),style:{boxShadow:`0 0 0 2px ${e.cutoutColor}`,zIndex:e.zIndex},title:t?.label,children:e.annotation.icon?(0,W.jsx)(OC,{decorative:!0,icon:e.annotation.icon,size:11}):(0,W.jsx)("span",{className:"font-sans text-2xs font-semibold leading-none text-dashboard-text-muted",children:e.annotation.label.slice(0,1)})})}function Gfe(){return(0,UY.useSyncExternalStore)(e=>{if(typeof window>"u")return()=>{};let t=window.matchMedia(TY);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)},()=>typeof window<"u"&&window.matchMedia(TY).matches,()=>!1)}function Hfe(e){let t=new Set;return e.filter(n=>t.has(n.label)?!1:(t.add(n.label),!0))}function Tfe(e){return e.key.includes("/")||e.key.includes("#")?e.key:e.label}var WY={"circle-dot":{className:"text-[#3fb950]",Icon:Pg,label:"Open"},"circle-dashed":{className:"text-[#8c959f]",Icon:Mg,label:"Draft"},"circle-x":{className:"text-[#f85149]",Icon:gs,label:"Closed"},"git-merge":{className:"text-[#a371f7]",Icon:Og,label:"Merged"},"git-pull-request":{className:"text-[#3fb950]",Icon:qg,label:"Open pull request"},"triangle-alert":{className:"text-[#d29922]",Icon:to,label:"Needs attention"}};function OC(e){let t=WY[e.icon],n=e.size??11;return(0,W.jsxs)("span",{"aria-hidden":e.decorative?!0:void 0,className:_("inline-flex shrink-0 items-center justify-center leading-none",t.className),style:{width:n,height:n},title:e.decorative?void 0:t.label,children:[(0,W.jsx)(t.Icon,{"aria-hidden":"true",className:"block",size:n,strokeWidth:2.25}),e.decorative?null:(0,W.jsx)("span",{className:"sr-only",children:t.label})]})}function ZY(e){let t=e.detail?.annotations?.filter(n=>n.kind==="resource_link")??[];return t.length===0?null:(0,W.jsx)("div",{className:"flex flex-wrap gap-1.5",children:t.map(n=>(0,W.jsxs)("a",{className:"inline-flex items-center gap-1.5 rounded border border-cyan-300/15 bg-cyan-300/[0.055] px-2 py-0.5 font-sans text-2xs leading-snug text-cyan-50 no-underline",href:n.url,rel:"noreferrer",target:"_blank",title:Ufe(n),children:[n.status?(0,W.jsx)(Yfe,{status:n.status,url:n.url}):null,(0,W.jsx)("span",{children:n.label})]},`${n.plugin}:${n.key}`))})}function Ufe(e){let t=e.status?{open:"Open",draft:"Draft",closed:"Closed",merged:"Merged",warning:"Needs attention"}[e.status]:void 0;return[e.label,e.plugin,t,e.description].filter(Boolean).join(" \xB7 ")}var Ofe={open:"circle-dot",draft:"circle-dashed",closed:"circle-x",merged:"git-merge",warning:"triangle-alert"};function qfe(e){try{return/^\/[^/]+\/[^/]+\/pull\/\d+(?:\/|$)/.test(new URL(e).pathname)}catch{return!1}}function zfe(e,t){return e==="open"&&qfe(t)?"git-pull-request":Ofe[e]}function Yfe(e){return(0,W.jsx)(OC,{icon:zfe(e.status,e.url),size:12})}function qC(e){let t=e.variant??"full",n=tC(e.conversation);if(t==="compact")return!!n;let o=e.conversationId??e.conversation?.id;return!!(n||o||e.detail?.sentryConversationUrl)}function T2(e){if(!qC(e))return null;let t=e.variant??"full",n=e.conversation?.actorIdentity?.email?.trim(),o=tC(e.conversation),a=e.conversationId??e.conversation?.id,r=o?n?(0,W.jsx)(ye,{className:"font-semibold text-dashboard-text underline decoration-white/20 underline-offset-2 transition-colors hover:text-dashboard-text hover:decoration-white/60",to:hi(n),children:o}):o:null;if(t==="compact")return(0,W.jsx)("span",{className:"inline-flex min-w-0 max-w-full items-center",children:(0,W.jsx)("span",{className:"min-w-0 max-w-full truncate",children:r})});let i=e.detail?.sentryConversationUrl?(0,W.jsx)("a",{className:"text-dashboard-text no-underline hover:underline",href:e.detail.sentryConversationUrl,rel:"noreferrer",target:"_blank",children:"View in Sentry"}):null;return(0,W.jsxs)("span",{className:"inline-flex min-w-0 max-w-full flex-wrap items-center gap-x-1.5 gap-y-1",children:[r?(0,W.jsx)("span",{className:"min-w-0 max-w-full truncate",children:r}):null,a?(0,W.jsxs)("span",{className:"inline-flex min-w-0 items-center gap-x-1.5",title:a,children:[r?(0,W.jsx)("span",{className:"text-dashboard-text-muted/50",children:"\xB7"}):null,(0,W.jsx)("span",{className:"min-w-0 max-w-[18rem] truncate",children:a})]}):null,i?(0,W.jsxs)("span",{className:"inline-flex min-w-0 items-center gap-x-1.5",children:[r||a?(0,W.jsx)("span",{className:"text-dashboard-text-muted/50",children:"\xB7"}):null,i]}):null]})}function Kfe(e){return e.sourceUrl?(0,W.jsx)("a",{className:"text-dashboard-text underline decoration-white/20 underline-offset-2 transition-colors hover:decoration-white/60",href:e.sourceUrl,rel:"noreferrer",target:"_blank",children:e.label}):e.label}function Jfe(e){let t=e.sourceTask.kind==="scheduled"?"Scheduled Task":"Event Task",n=e.sourceTask.label?.trim(),o=e.sourceTask.id?.trim(),a=e.sourceTask.title?.trim(),r=o?(0,W.jsxs)(ye,{className:"text-dashboard-text underline decoration-white/20 underline-offset-2 transition-colors hover:decoration-white/60",to:DO(o),children:["Triggered by ",t]}):(0,W.jsxs)("span",{children:["Triggered by ",t]});return!n&&!a?r:(0,W.jsx)(Se,{align:"left",content:(0,W.jsxs)("span",{className:"grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1",children:[a?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)("span",{children:"Title"}),(0,W.jsx)("span",{className:"text-dashboard-text",children:a})]}):null,n?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)("span",{children:"Instruction"}),(0,W.jsx)("span",{className:"text-dashboard-text",children:n})]}):null,o?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)("span",{children:"ID"}),(0,W.jsx)("span",{className:"break-all text-dashboard-text",children:o})]}):null]}),children:r})}function VY(e){if(!e)return;let t=new Set,n;for(let o of e.events){let a=o.data;if(a.type==="turn_lifecycle"){a.state==="started"?t.add(a.turnId):t.delete(a.turnId),t.size===0&&(n=void 0);continue}if(t.size!==0){if(a.type==="turn_routed"&&t.has(a.turnId)){n=a.modelId;continue}a.type==="handoff"&&(n=a.modelId)}}return t.size>0?n:void 0}function U2(e){return XY(e).length>0}function O2(e){let t=XY(e);return t.length===0?null:(0,W.jsx)(TC,{className:"break-words text-xs leading-[1.45] text-dashboard-text-muted",items:t})}function XY(e){if(!e.conversation)return[];let t=e.variant??"full",n=e.detail?.previousCursor?void 0:e.detail,o=e.detail?.cumulativeUsage??e.conversation.cumulativeUsage,a=Pm(o),r=Gm(o),i=Tc(e.conversation,{includeId:!1}),A=e.detail?.sourceUrl??e.conversation.sourceUrl,s=vO(e.conversation),c=(e.detail?.status??e.conversation.status)==="active",d=VY(e.detail),l=e.detail?.sourceTask;return[t==="full"&&i?{content:(0,W.jsx)(Kfe,{label:i,sourceUrl:A}),key:"location"}:void 0,t==="full"&&l?{content:(0,W.jsx)(Jfe,{sourceTask:l}),key:"source-task"}:void 0,s!=="none"?{content:(0,W.jsx)(HY,{endedAt:e.conversation.lastSeenAt,label:s,startedAt:e.conversation.startedAt}),key:"duration"}:void 0,a?{content:(0,W.jsx)(GY,{compactionCount:n?n.events.filter(p=>p.data.type==="compaction").length:void 0,live:c,liveModelId:d,modelUsage:e.detail?.modelUsage,summary:a}),key:"tokens"}:void 0,r||e.detail?.auxiliaryCosts||e.conversation.auxiliaryCosts||c?{content:(0,W.jsx)(PY,{auxiliaryCosts:e.detail?.auxiliaryCosts??e.conversation.auxiliaryCosts,live:c,liveModelId:d,modelUsage:e.detail?.modelUsage,summary:r}),key:"cost"}:void 0].filter(p=>p!==void 0)}var ke=C(E(),1),Wfe=e=>e.key;function eK(e){let[t,n]=(0,nu.useState)(),[o,a]=(0,nu.useState)(),r=(0,nu.useCallback)(()=>n(void 0),[]),i=Zfe(RY(e.conversations,{nowMs:Date.now(),timeZone:e.timeZone}));return(0,ke.jsxs)("aside",{className:"relative grid h-full min-h-0 min-w-0 grid-rows-[auto_auto_minmax(0,1fr)] overflow-hidden border-r border-white/[0.07] bg-white/[0.02]",children:[(0,ke.jsx)("div",{className:"px-3 pb-2 pt-3",children:(0,ke.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,ke.jsx)("h2",{className:"m-0 font-display text-lg font-medium leading-tight text-dashboard-text",children:"Conversations"}),(0,ke.jsx)("button",{"aria-label":"New conversation",className:"grid size-7 cursor-pointer place-items-center rounded-md text-dashboard-text-muted transition hover:bg-white/[0.05] hover:text-dashboard-text focus:outline-none focus:ring-2 focus:ring-cyan-300/35",onClick:e.onNewConversation,title:"New conversation",type:"button",children:(0,ke.jsx)(eo,{"aria-hidden":"true",size:15})})]})}),(0,ke.jsx)("div",{className:"px-2 pb-2",children:(0,ke.jsx)(ga,{label:"Search your conversations",onChange:e.onQueryChange,placeholder:"Search conversations\u2026",size:"compact",value:e.query})}),(0,ke.jsx)("div",{className:"min-h-0 overflow-y-auto overscroll-contain px-1.5 pb-[max(0.5rem,env(safe-area-inset-bottom))]",children:e.error?(0,ke.jsx)("div",{className:"p-2",children:(0,ke.jsx)(cn,{children:e.error})}):(0,ke.jsx)(SY,{ariaLabel:"Your conversations",className:"grid gap-0.5",empty:e.loading?void 0:(0,ke.jsx)("div",{className:"p-2",children:(0,ke.jsx)(cn,{children:"No conversations match this view."})}),getKey:Wfe,items:i,renderItem:A=>A.kind==="section"?(0,ke.jsx)("h3",{className:_("m-0 px-2.5 pb-0.5 font-display text-2xs font-semibold uppercase tracking-[0.08em] text-dashboard-text-muted/55",A.first?"pt-1.5":"pt-4"),children:A.label}):(0,ke.jsx)(Vfe,{conversation:A.conversation,onArchiveError:a,onArchived:s=>{a(c=>c?.id===s.id?void 0:c),n(s)},selected:A.conversation.id===e.selectedId}),role:"navigation"})}),t||o?(0,ke.jsxs)("div",{className:"absolute bottom-[max(0.75rem,env(safe-area-inset-bottom))] left-3 right-3 z-20 grid gap-2",children:[o?(0,ke.jsx)(Xfe,{conversation:o,onDismiss:()=>a(void 0)}):null,t?(0,ke.jsx)(ebe,{conversation:t,onRestored:r},t.id):null]}):null]})}function Zfe(e){return e.flatMap((t,n)=>[{first:n===0,key:`section-${t.key}`,kind:"section",label:t.label},...t.conversations.map(o=>({conversation:o,key:`conversation-${o.id}`,kind:"conversation"}))])}function Vfe(e){let t=rf(e.conversation.id,{onError:()=>e.onArchiveError(e.conversation),onSuccess:s=>{s&&e.onArchived(e.conversation)}}),n=nC(e.conversation),o=Tc(e.conversation,{includeId:!1}),a=Cs(e.conversation),r=!!e.conversation.sidebarAnnotations?.length,i=!!o&&!r,A=i||e.conversation.visibility==="private"||r;return(0,ke.jsxs)("div",{className:"group relative min-w-0",children:[(0,ke.jsxs)(ye,{"aria-current":e.selected?"page":void 0,className:_("block min-w-0 rounded-md px-2.5 py-1.5 text-inherit no-underline transition-colors hover:bg-white/[0.04]",e.selected&&"bg-white/[0.06]"),to:Wo(e.conversation.id),children:[(0,ke.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",children:[n==="active"?(0,ke.jsx)(xY,{className:"size-1.5"}):(0,ke.jsx)("span",{"aria-hidden":"true",className:_("size-1.5 shrink-0 rounded-full",n==="failed"&&"bg-rose-300",n==="idle"&&"bg-white/25")}),(0,ke.jsx)("div",{className:"truncate font-display text-sm font-medium leading-snug text-dashboard-text",children:a})]}),A?(0,ke.jsxs)("div",{className:"ml-3 mt-0.5 flex min-w-0 items-center gap-1.5 font-mono text-2xs leading-tight text-dashboard-text-muted",children:[e.conversation.visibility==="private"?(0,ke.jsx)(Zn,{"aria-label":"Private conversation",className:"size-3 shrink-0"}):null,i?(0,ke.jsx)("span",{className:"truncate",children:o}):null,(0,ke.jsx)(YY,{annotations:e.conversation.sidebarAnnotations})]}):null]}),(0,ke.jsx)("button",{"aria-label":`Archive ${a}`,className:"pointer-events-none absolute right-1.5 top-1/2 z-10 grid size-7 -translate-y-1/2 cursor-pointer place-items-center rounded-md bg-[#111719] text-dashboard-text-muted opacity-0 shadow-[-8px_0_12px_rgba(9,12,14,0.8)] transition hover:text-dashboard-text focus:pointer-events-auto focus:opacity-100 focus:outline-none focus:ring-2 focus:ring-cyan-300/35 group-focus-within:pointer-events-auto group-focus-within:opacity-100 group-hover:pointer-events-auto group-hover:opacity-100 disabled:cursor-not-allowed",disabled:t.isPending,onClick:()=>t.mutate({archived:!0,lastSeenAt:e.conversation.lastSeenAt}),title:`Archive ${a}`,type:"button",children:(0,ke.jsx)(hc,{"aria-hidden":"true",size:14})})]})}function Xfe(e){let t=Cs(e.conversation);return(0,ke.jsx)($2,{action:(0,ke.jsx)(M2,{onClick:e.onDismiss,title:"Dismiss",tone:"error",children:"Dismiss"}),detail:t,icon:xa,title:"Could not archive",tone:"error"})}function ebe(e){let t=rf(e.conversation.id,{onSuccess:o=>{o||e.onRestored()}}),n=Cs(e.conversation);return(0,nu.useEffect)(()=>{if(t.isPending||t.error)return;let o=window.setTimeout(e.onRestored,6e3);return()=>window.clearTimeout(o)},[e.conversation.id,e.onRestored,t.error,t.isPending]),(0,ke.jsx)($2,{action:(0,ke.jsx)(M2,{"aria-label":`Undo archive for ${n}`,disabled:t.isPending,onClick:()=>t.mutate({archived:!1,lastSeenAt:e.conversation.lastSeenAt}),title:`Undo archive for ${n}`,children:t.isPending?"Restoring\u2026":"Undo"}),detail:n,icon:bc,title:"Conversation archived",children:t.error?(0,ke.jsx)("div",{className:"border-t border-rose-300/25 bg-rose-400/[0.12] px-3 py-2 font-mono text-xs text-rose-50/85",role:"alert",children:"Could not restore the conversation."}):null})}var aa=C(z(),1);var sr=C(E(),1),tbe=112,tK="(min-width: 768px)",nbe="junior:dashboard:conversation-draft:",abe=250;function obe(e,t){return t===e.lastSubmittedText?e:{idempotencyKey:crypto.randomUUID(),lastSubmittedText:t}}var KC=(0,aa.memo)(function(t){let n=`${nbe}${encodeURIComponent(t.draftId)}`,[o,a]=(0,aa.useState)(()=>rbe(n)),[r,i]=(0,aa.useState)(!1),A=dy(),s=o.text,c=(0,aa.useId)(),d=(0,aa.useRef)(null),l=(0,aa.useRef)(o),g=(0,aa.useRef)({idempotencyKey:o.idempotencyKey,lastSubmittedText:o.lastSubmittedText}),p=(0,aa.useRef)(!1),m=(0,aa.useRef)(0),h=!!t.disabled||t.restoreDraftOnError&&r;l.current=o,(0,aa.useEffect)(()=>{let b=window.setTimeout(()=>{zC(n,l.current)},abe);return()=>window.clearTimeout(b)},[o,n]),(0,aa.useEffect)(()=>()=>{zC(n,l.current)},[n]),(0,aa.useEffect)(()=>{let b=d.current;if(!b)return;let y=()=>{if(window.matchMedia(tK).matches){b.style.height&&(b.style.height="");return}let Q=b.style.height;b.style.height="auto";let D=`${Math.min(b.scrollHeight,tbe)}px`;if(Q===D){b.style.height=Q;return}b.style.height=D};y();let w=window.matchMedia(tK);return w.addEventListener("change",y),()=>w.removeEventListener("change",y)},[s]);let B=async b=>{b?.preventDefault();let y=s.trim();if(!y||!A||p.current||h)return;let w=obe(g.current,y);g.current=w;let Q=++m.current,R={...w,text:y},D=YC(),F={...D,text:""};l.current=F,a(F),zC(n,F),g.current=D,p.current=!0,t.restoreDraftOnError&&i(!0),t.onSubmitStart?.(),d.current?.focus({preventScroll:!0}),t.restoreDraftOnError||queueMicrotask(()=>{p.current=!1});try{await t.onSubmit(y,w.idempotencyKey)}catch{if(!t.restoreDraftOnError||Q!==m.current||l.current.text)return;l.current=R,g.current=w,a(R),zC(n,R)}finally{t.restoreDraftOnError&&Q===m.current&&(p.current=!1,i(!1))}},f=b=>{b.key==="Enter"&&!b.shiftKey&&(b.preventDefault(),B())};return(0,sr.jsxs)("div",{className:"grid min-w-0 gap-1.5",children:[!A||t.error?(0,sr.jsx)("div",{"aria-live":"polite",className:A?"min-w-0 font-mono text-xs leading-relaxed text-red-300/80":"min-w-0 font-mono text-xs leading-relaxed text-amber-100/80",children:A?t.error:"Connect to send. Your draft is saved."}):null,(0,sr.jsxs)("form",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-end overflow-hidden rounded-lg border border-white/[0.09] bg-white/[0.035] focus-within:border-cyan-300/35 focus-within:ring-1 focus-within:ring-cyan-300/25 md:block",onSubmit:B,children:[(0,sr.jsx)("label",{className:"sr-only",htmlFor:c,children:t.label}),(0,sr.jsx)("textarea",{autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",className:"min-h-11 max-h-28 w-full resize-none overflow-y-auto border-0 bg-transparent px-3 py-2.5 font-mono text-sm leading-relaxed text-dashboard-text outline-none placeholder:text-dashboard-text-muted/65 md:min-h-24 md:max-h-none md:resize-y md:overflow-visible md:px-3.5 md:py-3",enterKeyHint:"send",id:c,inputMode:"text",maxLength:32e3,onChange:b=>{let y=b.target.value;a(w=>{if(w.text===y)return w;let Q={...w,text:y};return l.current=Q,Q})},onFocus:t.onFocus,onKeyDown:f,placeholder:"Message Junior\u2026",ref:d,rows:1,spellCheck:!1,value:s}),(0,sr.jsxs)("div",{className:"flex min-w-0 items-center justify-end gap-3 border-l border-white/[0.07] bg-black/15 px-2 py-1.5 md:justify-between md:border-l-0 md:border-t md:px-3 md:py-2",children:[(0,sr.jsx)("div",{className:"hidden min-w-0 font-mono text-xs leading-relaxed text-dashboard-text-muted md:block",children:"Enter to send \xB7 Shift+Enter for a new line"}),(0,sr.jsxs)(wt,{"aria-label":h?"Sending message":t.submitLabel,disabled:!s.trim()||!A||h,title:A?h?"Sending message":t.submitLabel:"Connect to send",type:"submit",children:[(0,sr.jsx)(Ic,{"aria-hidden":"true",size:14}),(0,sr.jsx)("span",{className:"hidden md:inline",children:h?"Sending\u2026":t.submitLabel})]})]})]})]})});function YC(){return{idempotencyKey:crypto.randomUUID(),lastSubmittedText:"",text:""}}function rbe(e){if(typeof window>"u")return YC();try{let t=window.localStorage.getItem(e);if(!t)return YC();let n=JSON.parse(t);if(typeof n=="object"&&n!==null&&"idempotencyKey"in n&&typeof n.idempotencyKey=="string"&&"text"in n&&typeof n.text=="string"){let o=n.text.slice(0,32e3),a="lastSubmittedText"in n&&typeof n.lastSubmittedText=="string"?n.lastSubmittedText:o.trim();return{idempotencyKey:n.idempotencyKey,lastSubmittedText:a,text:o}}}catch{}return YC()}function zC(e,t){if(!(typeof window>"u"))try{t.text?window.localStorage.setItem(e,JSON.stringify(t)):window.localStorage.removeItem(e)}catch{}}var oa=C(z(),1);var ibe=u.object({memories:u.array(u.object({id:u.string(),content:u.string(),observedAtMs:u.number(),scope:u.enum(["personal","conversation"]),kind:u.enum(["preference","procedure","knowledge"])}).strict())}).strict();function JC(e){if(e.pluginName!=="memory"||e.kind!=="recall"||e.version!==1)return;let t=ibe.safeParse(e.content);return t.success?t.data:void 0}function WC(e,t){if(e.previousCursor)throw new Error("Cannot export a partial conversation transcript");let n=[];return n.push(`# ${ml(fbe(e,t))}`,""),Pt(n,"Conversation ID",oK(e.conversationId)),Pt(n,"Generated",e.generatedAt),Pt(n,"Actor",bbe(t,e)),Pt(n,"Location",hbe(t,e)),Pt(n,"Usage",[QO(e.cumulativeUsage),_O(e.cumulativeUsage,e.auxiliaryCosts)].filter(Boolean).join(" \xB7 ")),Pt(n,"Sentry conversation",e.sentryConversationUrl),n.push("","## Transcript"),Abe(n,e),Cbe(n)}function Abe(e,t){let n=fA(t);if(t.eventHistory.status==="available"){q2(e,t,n,!1);return}if(t.eventHistory.status==="redacted"&&n.length){e.push("","Transcript hidden because this conversation is not public."),q2(e,t,n,!0);return}if(n.length){q2(e,t,n,!1);return}e.push("",aC(t))}function q2(e,t,n,o){for(let a of Um(n)){if(a.kind==="message"){a.message.eventType?dbe(e,t,a.message,o):a.message.context?lbe(e,t,a.message,o):pbe(e,t,a.message,o);continue}if(a.kind==="failure"){cbe(e,t,a.outcome,a.timestamp);continue}if(a.kind==="subagent"){gbe(e,t,a.part,a.timestamp);continue}if(a.kind==="context"){ube(e,t,a.part,a.timestamp);continue}if(a.kind==="reasoning"){sbe(e,t,a.part,a.timestamp);continue}if(a.kind==="structured_event"){e.push("",`### ${a.part.presentation.title}`),Si(e,t,a.timestamp),a.part.presentation.preview&&e.push("",a.part.presentation.preview);for(let r of a.part.presentation.details??[])e.push("",`- ${r.title}`),r.description&&e.push(` ${r.description}`),r.content&&e.push("",z2(r.content,"md")),r.metadata?.length&&e.push(` ${r.metadata.join(" \xB7 ")}`);continue}if(a.kind==="attachments_delivered"){let r=a.part.attachments.length;e.push("",`### ${r===1?"1 file delivered":`${r} files delivered`}`),Si(e,t,a.timestamp);for(let i of a.part.attachments)e.push("",`- ${i.filename} (${i.contentType}, ${i.bytes} bytes)`);continue}mbe(e,t,a.part,a.timestamp)}}function sbe(e,t,n,o){e.push("","### Reasoning"),Si(e,t,o),e.push("",n.redacted?"<redacted>":n.text)}function cbe(e,t,n,o){e.push("",n==="delivery_failed"?"### Message delivery failed":"### Agent response failed"),Si(e,t,o),e.push("",n==="delivery_failed"?`${nt()} could not deliver this message to its destination.`:`The model response ended before ${nt()} could complete this turn.`)}function ube(e,t,n,o){let a=n.event;e.push("",a.type==="handoff"?"### Model handoff":"### Context compacted"),Si(e,t,o),a.type==="handoff"?(Pt(e,"Profile",a.modelProfile),Pt(e,"Model",a.modelId),Pt(e,"Reasoning",a.reasoningLevel)):(Pt(e,"Profile",a.modelProfile),Pt(e,"Model",a.modelId),a.details&&(Pt(e,"Estimated input tokens",String(a.details.estimatedInputTokens)),a.details.replacementInputTokens!==void 0&&Pt(e,"Replacement input tokens",String(a.details.replacementInputTokens)),Pt(e,"Compaction trigger",String(a.details.triggerTokens)),Pt(e,"Input limit",String(a.details.inputLimitTokens)),Pt(e,"Input messages",String(a.details.inputMessageCount)),Pt(e,"Retained messages",String(a.details.retainedMessageCount)),Pt(e,"Summary characters",String(a.details.summaryChars)))),a.summary&&e.push("","#### Continuation summary","",a.summary)}function dbe(e,t,n,o){if(e.push("",`### Event: ${ml(n.eventType??"")}`),Si(e,t,n.timestamp),o){e.push("","- <redacted>");return}let a=Vo(n);e.push("",a.trim().length?a:"_No content._")}function lbe(e,t,n,o){e.push("",`### Context from ${aK(n,t)}`),Si(e,t,n.timestamp),e.push("",o?"<redacted>":Vo(n)),o||nK(e,n.contexts)}function pbe(e,t,n,o){if(e.push("",`### ${aK(n,t)}`),Si(e,t,n.timestamp),o){e.push("",...n.parts.map(()=>"- <redacted>"));return}let a=Vo(n);e.push("",a.trim().length?a:"_No content._"),nK(e,n.contexts)}function nK(e,t){for(let n of t??[]){let o=JC(n);if(e.push("",o?"#### Recalled memories":`#### ${ml(n.kind)} context`),Pt(e,"Plugin",n.pluginName),Pt(e,"Loaded",n.loadedAt),!o){e.push("","```json",JSON.stringify(n.content,null,2),"```");continue}for(let a of o.memories)e.push("",`- ${a.content}`,` - ID: ${oK(a.id)}`,` - Observed: ${new Date(a.observedAtMs).toISOString()}`,` - Scope: ${a.scope}`,` - Kind: ${a.kind}`)}}function gbe(e,t,n,o){e.push("",`### Subagent: ${ml(n.subagentKind)}`),Si(e,t,o),Pt(e,"Status",n.status)}function mbe(e,t,n,o){e.push("",`### Tool: ${ml(n.name)}`),Si(e,t,o),Pt(e,"Status",n.status),Pt(e,"Duration",Xy(o,n.resultTimestamp)),n.input!==void 0&&e.push("","#### Arguments","",z2(Zo(n.input),"json")),n.output!==void 0&&e.push("","#### Result","",z2(Zo(n.output),"json"))}function Si(e,t,n){let o=[Bbe(n),ybe(t,n)].filter(wbe);o.length&&e.push("",`_${o.join(" - ")}_`)}function fbe(e,t){let n=e.displayTitle.trim();return n||(t?Cs(t):"Conversation")}function bbe(e,t){return Mm(e?.actorIdentity??t?.actorIdentity)??""}function hbe(e,t){return e?Tc(e)??"":t?Tc(t)??"":""}function aK(e,t){return ml(ys(t,e))}function Bbe(e){return typeof e!="number"||!Number.isFinite(e)?"":new Date(e).toISOString()}function ybe(e,t){if(typeof t!="number"||!Number.isFinite(t))return"";let n=Date.parse(e.startedAt);return!Number.isFinite(n)||t<n?"":`+${jm(t-n)}`}function Pt(e,t,n){n&&e.push(`- ${t}: ${n}`)}function ml(e){return e.replace(/\s+/g," ").trim()||"Untitled"}function oK(e){let t=e.includes("`")?"``":"`";return`${t}${e}${t}`}function z2(e,t){let n=[...e.matchAll(/`+/g)].reduce((a,r)=>Math.max(a,r[0].length),0),o="`".repeat(Math.max(3,n+1));return`${o}${t}
98
98
  ${e}
99
99
  ${o}`}function Cbe(e){return`${e.join(`
100
100
  `)}