teodor-new-chat-ui 4.3.9 → 4.3.10

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/index.esm.js CHANGED
@@ -15096,7 +15096,7 @@ function Ki({
15096
15096
  ] }),
15097
15097
  x && Q.length > 0 && /* @__PURE__ */ c.jsxs("div", { className: "flex-shrink-0 flex items-center gap-2 px-4 py-2 border-b border-border bg-muted/60 text-xs dark:bg-muted/50", children: [
15098
15098
  /* @__PURE__ */ c.jsx("span", { className: "opacity-70", children: "Checkpoint:" }),
15099
- /* @__PURE__ */ c.jsxs(
15099
+ /* @__PURE__ */ c.jsx(
15100
15100
  "select",
15101
15101
  {
15102
15102
  className: "border border-border rounded px-2 py-1 text-xs bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring dark:bg-secondary",
@@ -15105,13 +15105,10 @@ function Ki({
15105
15105
  const Ce = se.target.value || null;
15106
15106
  ir(Ce);
15107
15107
  },
15108
- children: [
15109
- /* @__PURE__ */ c.jsx("option", { value: "", children: "Latest" }),
15110
- Q.map((se) => /* @__PURE__ */ c.jsxs("option", { value: se.checkpointId, children: [
15111
- Tn(se.createdAt),
15112
- se.preview ? ` — ${se.preview.slice(0, 40)}` : ""
15113
- ] }, se.checkpointId))
15114
- ]
15108
+ children: Q.map((se) => /* @__PURE__ */ c.jsxs("option", { value: se.checkpointId, children: [
15109
+ Tn(se.createdAt),
15110
+ se.preview ? ` ${se.preview.slice(0, 40)}` : ""
15111
+ ] }, se.checkpointId))
15115
15112
  }
15116
15113
  )
15117
15114
  ] }),
package/dist/index.umd.js CHANGED
@@ -137,4 +137,4 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
137
137
  `).replace(/<ul>/gi,"").replace(/<\/ul>/gi,`
138
138
  `).replace(/<ol>/gi,"").replace(/<\/ol>/gi,`
139
139
  `).replace(/<li>(.*?)<\/li>/gi,`- $1
140
- `).trim():n.replace(/</g,"&lt;").replace(/>/g,"&gt;").trim()}function gw(e,t=Os){if(!e||typeof e!="string")throw new Error("Invalid content: must be a non-empty string");if(e.length>t)throw new Error(`Message exceeds maximum length of ${t} characters`);return e}function xw(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),gw(t),mw(t)}function Pa(e){const t=e+"CollectionProvider",[n,r]=Sn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=x=>{const{scope:g,children:y}=x,b=w.useRef(null),S=w.useRef(new Map).current;return c.jsx(o,{scope:g,itemMap:S,collectionRef:b,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=rr.createSlot(a),u=w.forwardRef((x,g)=>{const{scope:y,children:b}=x,S=s(a,y),I=qe(g,S.collectionRef);return c.jsx(l,{ref:I,children:b})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=rr.createSlot(d),p=w.forwardRef((x,g)=>{const{scope:y,children:b,...S}=x,I=w.useRef(null),C=qe(g,I),T=s(d,y);return w.useEffect(()=>(T.itemMap.set(I,{ref:I,...S}),()=>void T.itemMap.delete(I))),c.jsx(h,{[f]:"",ref:C,children:b})});p.displayName=d;function v(x){const g=s(e+"CollectionConsumer",x);return w.useCallback(()=>{const b=g.collectionRef.current;if(!b)return[];const S=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(g.itemMap.values()).sort((T,E)=>S.indexOf(T.ref.current)-S.indexOf(E.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:u,ItemSlot:p},v,r]}var yw=m.createContext(void 0);function Ms(e){const t=m.useContext(yw);return e||t||"ltr"}const vw=["top","right","bottom","left"],Xn=Math.min,Vt=Math.max,Ds=Math.round,Ls=Math.floor,kn=e=>({x:e,y:e}),bw={left:"right",right:"left",bottom:"top",top:"bottom"},ww={start:"end",end:"start"};function Oa(e,t,n){return Vt(e,Xn(t,n))}function $n(e,t){return typeof e=="function"?e(t):e}function Fn(e){return e.split("-")[0]}function Fr(e){return e.split("-")[1]}function Ma(e){return e==="x"?"y":"x"}function Da(e){return e==="y"?"height":"width"}const Sw=new Set(["top","bottom"]);function En(e){return Sw.has(Fn(e))?"y":"x"}function La(e){return Ma(En(e))}function Cw(e,t,n){n===void 0&&(n=!1);const r=Fr(e),o=La(e),s=Da(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=$s(i)),[i,$s(i)]}function Tw(e){const t=$s(e);return[$a(e),t,$a(t)]}function $a(e){return e.replace(/start|end/g,t=>ww[t])}const cf=["left","right"],uf=["right","left"],kw=["top","bottom"],Ew=["bottom","top"];function Iw(e,t,n){switch(e){case"top":case"bottom":return n?t?uf:cf:t?cf:uf;case"left":case"right":return t?kw:Ew;default:return[]}}function Nw(e,t,n,r){const o=Fr(e);let s=Iw(Fn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map($a)))),s}function $s(e){return e.replace(/left|right|bottom|top/g,t=>bw[t])}function Aw(e){return{top:0,right:0,bottom:0,left:0,...e}}function df(e){return typeof e!="number"?Aw(e):{top:e,right:e,bottom:e,left:e}}function Fs(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function ff(e,t,n){let{reference:r,floating:o}=e;const s=En(t),i=La(t),a=Da(i),l=Fn(t),u=s==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,h=r[a]/2-o[a]/2;let p;switch(l){case"top":p={x:d,y:r.y-o.height};break;case"bottom":p={x:d,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch(Fr(t)){case"start":p[i]-=h*(n&&u?-1:1);break;case"end":p[i]+=h*(n&&u?-1:1);break}return p}const _w=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=ff(u,r,l),h=r,p={},v=0;for(let x=0;x<a.length;x++){const{name:g,fn:y}=a[x],{x:b,y:S,data:I,reset:C}=await y({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:u,platform:i,elements:{reference:e,floating:t}});d=b??d,f=S??f,p={...p,[g]:{...p[g],...I}},C&&v<=50&&(v++,typeof C=="object"&&(C.placement&&(h=C.placement),C.rects&&(u=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:f}=ff(u,h,l)),x=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:p}};async function yo(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=$n(t,e),v=df(p),g=a[h?f==="floating"?"reference":"floating":f],y=Fs(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(g)))==null||n?g:g.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:d,strategy:l})),b=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),I=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=Fs(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:S,strategy:l}):b);return{top:(y.top-C.top+v.top)/I.y,bottom:(C.bottom-y.bottom+v.bottom)/I.y,left:(y.left-C.left+v.left)/I.x,right:(C.right-y.right+v.right)/I.x}}const jw=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:u,padding:d=0}=$n(e,t)||{};if(u==null)return{};const f=df(d),h={x:n,y:r},p=La(o),v=Da(p),x=await i.getDimensions(u),g=p==="y",y=g?"top":"left",b=g?"bottom":"right",S=g?"clientHeight":"clientWidth",I=s.reference[v]+s.reference[p]-h[p]-s.floating[v],C=h[p]-s.reference[p],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let E=T?T[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(T)))&&(E=a.floating[S]||s.floating[v]);const A=I/2-C/2,j=E/2-x[v]/2-1,P=Xn(f[y],j),D=Xn(f[b],j),L=P,V=E-x[v]-D,M=E/2-x[v]/2+A,G=Oa(L,M,V),K=!l.arrow&&Fr(o)!=null&&M!==G&&s.reference[v]/2-(M<L?P:D)-x[v]/2<0,U=K?M<L?M-L:M-V:0;return{[p]:h[p]+U,data:{[p]:G,centerOffset:M-G-U,...K&&{alignmentOffset:U}},reset:K}}}),Rw=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:x=!0,...g}=$n(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=Fn(o),b=En(a),S=Fn(a)===a,I=await(l.isRTL==null?void 0:l.isRTL(u.floating)),C=h||(S||!x?[$s(a)]:Tw(a)),T=v!=="none";!h&&T&&C.push(...Nw(a,x,v,I));const E=[a,...C],A=await yo(t,g),j=[];let P=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&j.push(A[y]),f){const M=Cw(o,i,I);j.push(A[M[0]],A[M[1]])}if(P=[...P,{placement:o,overflows:j}],!j.every(M=>M<=0)){var D,L;const M=(((D=s.flip)==null?void 0:D.index)||0)+1,G=E[M];if(G&&(!(f==="alignment"?b!==En(G):!1)||P.every(z=>En(z.placement)===b?z.overflows[0]>0:!0)))return{data:{index:M,overflows:P},reset:{placement:G}};let K=(L=P.filter(U=>U.overflows[0]<=0).sort((U,z)=>U.overflows[1]-z.overflows[1])[0])==null?void 0:L.placement;if(!K)switch(p){case"bestFit":{var V;const U=(V=P.filter(z=>{if(T){const F=En(z.placement);return F===b||F==="y"}return!0}).map(z=>[z.placement,z.overflows.filter(F=>F>0).reduce((F,de)=>F+de,0)]).sort((z,F)=>z[1]-F[1])[0])==null?void 0:V[0];U&&(K=U);break}case"initialPlacement":K=a;break}if(o!==K)return{reset:{placement:K}}}return{}}}};function hf(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function pf(e){return vw.some(t=>e[t]>=0)}const Pw=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=$n(e,t);switch(r){case"referenceHidden":{const s=await yo(t,{...o,elementContext:"reference"}),i=hf(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:pf(i)}}}case"escaped":{const s=await yo(t,{...o,altBoundary:!0}),i=hf(s,n.floating);return{data:{escapedOffsets:i,escaped:pf(i)}}}default:return{}}}}},mf=new Set(["left","top"]);async function Ow(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Fn(n),a=Fr(n),l=En(n)==="y",u=mf.has(i)?-1:1,d=s&&l?-1:1,f=$n(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:v}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof v=="number"&&(p=a==="end"?v*-1:v),l?{x:p*d,y:h*u}:{x:h*u,y:p*d}}const Mw=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,l=await Ow(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},Dw=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:g=>{let{x:y,y:b}=g;return{x:y,y:b}}},...l}=$n(e,t),u={x:n,y:r},d=await yo(t,l),f=En(Fn(o)),h=Ma(f);let p=u[h],v=u[f];if(s){const g=h==="y"?"top":"left",y=h==="y"?"bottom":"right",b=p+d[g],S=p-d[y];p=Oa(b,p,S)}if(i){const g=f==="y"?"top":"left",y=f==="y"?"bottom":"right",b=v+d[g],S=v-d[y];v=Oa(b,v,S)}const x=a.fn({...t,[h]:p,[f]:v});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[h]:s,[f]:i}}}}}},Lw=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:u=!0}=$n(e,t),d={x:n,y:r},f=En(o),h=Ma(f);let p=d[h],v=d[f];const x=$n(a,t),g=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(l){const S=h==="y"?"height":"width",I=s.reference[h]-s.floating[S]+g.mainAxis,C=s.reference[h]+s.reference[S]-g.mainAxis;p<I?p=I:p>C&&(p=C)}if(u){var y,b;const S=h==="y"?"width":"height",I=mf.has(Fn(o)),C=s.reference[f]-s.floating[S]+(I&&((y=i.offset)==null?void 0:y[f])||0)+(I?0:g.crossAxis),T=s.reference[f]+s.reference[S]+(I?0:((b=i.offset)==null?void 0:b[f])||0)-(I?g.crossAxis:0);v<C?v=C:v>T&&(v=T)}return{[h]:p,[f]:v}}}},$w=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...u}=$n(e,t),d=await yo(t,u),f=Fn(o),h=Fr(o),p=En(o)==="y",{width:v,height:x}=s.floating;let g,y;f==="top"||f==="bottom"?(g=f,y=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=f,g=h==="end"?"top":"bottom");const b=x-d.top-d.bottom,S=v-d.left-d.right,I=Xn(x-d[g],b),C=Xn(v-d[y],S),T=!t.middlewareData.shift;let E=I,A=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),T&&!h){const P=Vt(d.left,0),D=Vt(d.right,0),L=Vt(d.top,0),V=Vt(d.bottom,0);p?A=v-2*(P!==0||D!==0?P+D:Vt(d.left,d.right)):E=x-2*(L!==0||V!==0?L+V:Vt(d.top,d.bottom))}await l({...t,availableWidth:A,availableHeight:E});const j=await i.getDimensions(a.floating);return v!==j.width||x!==j.height?{reset:{rects:!0}}:{}}}};function zs(){return typeof window<"u"}function zr(e){return gf(e)?(e.nodeName||"").toLowerCase():"#document"}function Kt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function In(e){var t;return(t=(gf(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function gf(e){return zs()?e instanceof Node||e instanceof Kt(e).Node:!1}function dn(e){return zs()?e instanceof Element||e instanceof Kt(e).Element:!1}function Nn(e){return zs()?e instanceof HTMLElement||e instanceof Kt(e).HTMLElement:!1}function xf(e){return!zs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Kt(e).ShadowRoot}const Fw=new Set(["inline","contents"]);function vo(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=fn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Fw.has(o)}const zw=new Set(["table","td","th"]);function Bw(e){return zw.has(zr(e))}const Hw=[":popover-open",":modal"];function Bs(e){return Hw.some(t=>{try{return e.matches(t)}catch{return!1}})}const Uw=["transform","translate","scale","rotate","perspective"],Ww=["transform","translate","scale","rotate","perspective","filter"],Vw=["paint","layout","strict","content"];function Fa(e){const t=za(),n=dn(e)?fn(e):e;return Uw.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||Ww.some(r=>(n.willChange||"").includes(r))||Vw.some(r=>(n.contain||"").includes(r))}function Kw(e){let t=Jn(e);for(;Nn(t)&&!Br(t);){if(Fa(t))return t;if(Bs(t))return null;t=Jn(t)}return null}function za(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const qw=new Set(["html","body","#document"]);function Br(e){return qw.has(zr(e))}function fn(e){return Kt(e).getComputedStyle(e)}function Hs(e){return dn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Jn(e){if(zr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||xf(e)&&e.host||In(e);return xf(t)?t.host:t}function yf(e){const t=Jn(e);return Br(t)?e.ownerDocument?e.ownerDocument.body:e.body:Nn(t)&&vo(t)?t:yf(t)}function bo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=yf(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Kt(o);if(s){const a=Ba(i);return t.concat(i,i.visualViewport||[],vo(o)?o:[],a&&n?bo(a):[])}return t.concat(o,bo(o,[],n))}function Ba(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function vf(e){const t=fn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Nn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Ds(n)!==s||Ds(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Ha(e){return dn(e)?e:e.contextElement}function Hr(e){const t=Ha(e);if(!Nn(t))return kn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=vf(t);let i=(s?Ds(n.width):n.width)/r,a=(s?Ds(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Gw=kn(0);function bf(e){const t=Kt(e);return!za()||!t.visualViewport?Gw:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Yw(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Kt(e)?!1:t}function xr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Ha(e);let i=kn(1);t&&(r?dn(r)&&(i=Hr(r)):i=Hr(e));const a=Yw(s,n,r)?bf(s):kn(0);let l=(o.left+a.x)/i.x,u=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const h=Kt(s),p=r&&dn(r)?Kt(r):r;let v=h,x=Ba(v);for(;x&&r&&p!==v;){const g=Hr(x),y=x.getBoundingClientRect(),b=fn(x),S=y.left+(x.clientLeft+parseFloat(b.paddingLeft))*g.x,I=y.top+(x.clientTop+parseFloat(b.paddingTop))*g.y;l*=g.x,u*=g.y,d*=g.x,f*=g.y,l+=S,u+=I,v=Kt(x),x=Ba(v)}}return Fs({width:d,height:f,x:l,y:u})}function Us(e,t){const n=Hs(e).scrollLeft;return t?t.left+n:xr(In(e)).left+n}function wf(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Us(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Xw(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=In(r),a=t?Bs(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},u=kn(1);const d=kn(0),f=Nn(r);if((f||!f&&!s)&&((zr(r)!=="body"||vo(i))&&(l=Hs(r)),Nn(r))){const p=xr(r);u=Hr(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const h=i&&!f&&!s?wf(i,l):kn(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-l.scrollTop*u.y+d.y+h.y}}function Jw(e){return Array.from(e.getClientRects())}function Zw(e){const t=In(e),n=Hs(e),r=e.ownerDocument.body,o=Vt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Vt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Us(e);const a=-n.scrollTop;return fn(r).direction==="rtl"&&(i+=Vt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Sf=25;function Qw(e,t){const n=Kt(e),r=In(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const d=za();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const u=Us(r);if(u<=0){const d=r.ownerDocument,f=d.body,h=getComputedStyle(f),p=d.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,v=Math.abs(r.clientWidth-f.clientWidth-p);v<=Sf&&(s-=v)}else u<=Sf&&(s+=u);return{width:s,height:i,x:a,y:l}}const e0=new Set(["absolute","fixed"]);function t0(e,t){const n=xr(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Nn(e)?Hr(e):kn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,u=r*s.y;return{width:i,height:a,x:l,y:u}}function Cf(e,t,n){let r;if(t==="viewport")r=Qw(e,n);else if(t==="document")r=Zw(In(e));else if(dn(t))r=t0(t,n);else{const o=bf(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Fs(r)}function Tf(e,t){const n=Jn(e);return n===t||!dn(n)||Br(n)?!1:fn(n).position==="fixed"||Tf(n,t)}function n0(e,t){const n=t.get(e);if(n)return n;let r=bo(e,[],!1).filter(a=>dn(a)&&zr(a)!=="body"),o=null;const s=fn(e).position==="fixed";let i=s?Jn(e):e;for(;dn(i)&&!Br(i);){const a=fn(i),l=Fa(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&e0.has(o.position)||vo(i)&&!l&&Tf(e,i))?r=r.filter(d=>d!==i):o=a,i=Jn(i)}return t.set(e,r),r}function r0(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Bs(t)?[]:n0(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((u,d)=>{const f=Cf(t,d,o);return u.top=Vt(f.top,u.top),u.right=Xn(f.right,u.right),u.bottom=Xn(f.bottom,u.bottom),u.left=Vt(f.left,u.left),u},Cf(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function o0(e){const{width:t,height:n}=vf(e);return{width:t,height:n}}function s0(e,t,n){const r=Nn(t),o=In(t),s=n==="fixed",i=xr(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=kn(0);function u(){l.x=Us(o)}if(r||!r&&!s)if((zr(t)!=="body"||vo(o))&&(a=Hs(t)),r){const p=xr(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&u();s&&!r&&o&&u();const d=o&&!r&&!s?wf(o,a):kn(0),f=i.left+a.scrollLeft-l.x-d.x,h=i.top+a.scrollTop-l.y-d.y;return{x:f,y:h,width:i.width,height:i.height}}function Ua(e){return fn(e).position==="static"}function kf(e,t){if(!Nn(e)||fn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return In(e)===n&&(n=n.ownerDocument.body),n}function Ef(e,t){const n=Kt(e);if(Bs(e))return n;if(!Nn(e)){let o=Jn(e);for(;o&&!Br(o);){if(dn(o)&&!Ua(o))return o;o=Jn(o)}return n}let r=kf(e,t);for(;r&&Bw(r)&&Ua(r);)r=kf(r,t);return r&&Br(r)&&Ua(r)&&!Fa(r)?n:r||Kw(e)||n}const i0=async function(e){const t=this.getOffsetParent||Ef,n=this.getDimensions,r=await n(e.floating);return{reference:s0(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function a0(e){return fn(e).direction==="rtl"}const l0={convertOffsetParentRelativeRectToViewportRelativeRect:Xw,getDocumentElement:In,getClippingRect:r0,getOffsetParent:Ef,getElementRects:i0,getClientRects:Jw,getDimensions:o0,getScale:Hr,isElement:dn,isRTL:a0};function If(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function c0(e,t){let n=null,r;const o=In(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const u=e.getBoundingClientRect(),{left:d,top:f,width:h,height:p}=u;if(a||t(),!h||!p)return;const v=Ls(f),x=Ls(o.clientWidth-(d+h)),g=Ls(o.clientHeight-(f+p)),y=Ls(d),S={rootMargin:-v+"px "+-x+"px "+-g+"px "+-y+"px",threshold:Vt(0,Xn(1,l))||1};let I=!0;function C(T){const E=T[0].intersectionRatio;if(E!==l){if(!I)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!If(u,e.getBoundingClientRect())&&i(),I=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return i(!0),s}function u0(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,u=Ha(e),d=o||s?[...u?bo(u):[],...bo(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const f=u&&a?c0(u,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(y=>{let[b]=y;b&&b.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var S;(S=p)==null||S.observe(t)})),n()}),u&&!l&&p.observe(u),p.observe(t));let v,x=l?xr(e):null;l&&g();function g(){const y=xr(e);x&&!If(x,y)&&n(),x=y,v=requestAnimationFrame(g)}return n(),()=>{var y;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),f==null||f(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(v)}}const d0=Mw,f0=Dw,h0=Rw,p0=$w,m0=Pw,Nf=jw,g0=Lw,x0=(e,t,n)=>{const r=new Map,o={platform:l0,...n},s={...o.platform,_c:r};return _w(e,t,{...o,platform:s})};var y0=typeof document<"u",v0=function(){},Ws=y0?w.useLayoutEffect:v0;function Vs(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,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Vs(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!Vs(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Af(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function _f(e,t){const n=Af(e);return Math.round(t*n)/n}function Wa(e){const t=m.useRef(e);return Ws(()=>{t.current=e}),t}function b0(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:u}=e,[d,f]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=m.useState(r);Vs(h,r)||p(r);const[v,x]=m.useState(null),[g,y]=m.useState(null),b=m.useCallback(z=>{z!==T.current&&(T.current=z,x(z))},[]),S=m.useCallback(z=>{z!==E.current&&(E.current=z,y(z))},[]),I=s||v,C=i||g,T=m.useRef(null),E=m.useRef(null),A=m.useRef(d),j=l!=null,P=Wa(l),D=Wa(o),L=Wa(u),V=m.useCallback(()=>{if(!T.current||!E.current)return;const z={placement:t,strategy:n,middleware:h};D.current&&(z.platform=D.current),x0(T.current,E.current,z).then(F=>{const de={...F,isPositioned:L.current!==!1};M.current&&!Vs(A.current,de)&&(A.current=de,jo.flushSync(()=>{f(de)}))})},[h,t,n,D,L]);Ws(()=>{u===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,f(z=>({...z,isPositioned:!1})))},[u]);const M=m.useRef(!1);Ws(()=>(M.current=!0,()=>{M.current=!1}),[]),Ws(()=>{if(I&&(T.current=I),C&&(E.current=C),I&&C){if(P.current)return P.current(I,C,V);V()}},[I,C,V,P,j]);const G=m.useMemo(()=>({reference:T,floating:E,setReference:b,setFloating:S}),[b,S]),K=m.useMemo(()=>({reference:I,floating:C}),[I,C]),U=m.useMemo(()=>{const z={position:n,left:0,top:0};if(!K.floating)return z;const F=_f(K.floating,d.x),de=_f(K.floating,d.y);return a?{...z,transform:"translate("+F+"px, "+de+"px)",...Af(K.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:F,top:de}},[n,a,K.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:V,refs:G,elements:K,floatingStyles:U}),[d,V,G,K,U])}const w0=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?Nf({element:r.current,padding:o}).fn(n):{}:r?Nf({element:r,padding:o}).fn(n):{}}}},S0=(e,t)=>({...d0(e),options:[e,t]}),C0=(e,t)=>({...f0(e),options:[e,t]}),T0=(e,t)=>({...g0(e),options:[e,t]}),k0=(e,t)=>({...h0(e),options:[e,t]}),E0=(e,t)=>({...p0(e),options:[e,t]}),I0=(e,t)=>({...m0(e),options:[e,t]}),N0=(e,t)=>({...w0(e),options:[e,t]});var A0="Arrow",jf=m.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return c.jsx(_e.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:c.jsx("polygon",{points:"0,0 30,0 15,10"})})});jf.displayName=A0;var _0=jf;function Rf(e){const[t,n]=m.useState(void 0);return Tt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,u=Array.isArray(l)?l[0]:l;i=u.inlineSize,a=u.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Va="Popper",[Pf,Ks]=Sn(Va),[j0,Of]=Pf(Va),Mf=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return c.jsx(j0,{scope:t,anchor:r,onAnchorChange:o,children:n})};Mf.displayName=Va;var Df="PopperAnchor",Lf=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Of(Df,n),i=m.useRef(null),a=qe(t,i),l=m.useRef(null);return m.useEffect(()=>{const u=l.current;l.current=(r==null?void 0:r.current)||i.current,u!==l.current&&s.onAnchorChange(l.current)}),r?null:c.jsx(_e.div,{...o,ref:a})});Lf.displayName=Df;var Ka="PopperContent",[R0,P0]=Pf(Ka),$f=m.forwardRef((e,t)=>{var q,O,Z,ne,pe,ie;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:v,...x}=e,g=Of(Ka,n),[y,b]=m.useState(null),S=qe(t,me=>b(me)),[I,C]=m.useState(null),T=Rf(I),E=(T==null?void 0:T.width)??0,A=(T==null?void 0:T.height)??0,j=r+(s!=="center"?"-"+s:""),P=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},D=Array.isArray(u)?u:[u],L=D.length>0,V={padding:P,boundary:D.filter(M0),altBoundary:L},{refs:M,floatingStyles:G,placement:K,isPositioned:U,middlewareData:z}=b0({strategy:"fixed",placement:j,whileElementsMounted:(...me)=>u0(...me,{animationFrame:p==="always"}),elements:{reference:g.anchor},middleware:[S0({mainAxis:o+A,alignmentAxis:i}),l&&C0({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?T0():void 0,...V}),l&&k0({...V}),E0({...V,apply:({elements:me,rects:et,availableWidth:tt,availableHeight:Me})=>{const{width:We,height:ut}=et.reference,nt=me.floating.style;nt.setProperty("--radix-popper-available-width",`${tt}px`),nt.setProperty("--radix-popper-available-height",`${Me}px`),nt.setProperty("--radix-popper-anchor-width",`${We}px`),nt.setProperty("--radix-popper-anchor-height",`${ut}px`)}}),I&&N0({element:I,padding:a}),D0({arrowWidth:E,arrowHeight:A}),h&&I0({strategy:"referenceHidden",...V})]}),[F,de]=Bf(K),$=Et(v);Tt(()=>{U&&($==null||$())},[U,$]);const te=(q=z.arrow)==null?void 0:q.x,he=(O=z.arrow)==null?void 0:O.y,ve=((Z=z.arrow)==null?void 0:Z.centerOffset)!==0,[be,we]=m.useState();return Tt(()=>{y&&we(window.getComputedStyle(y).zIndex)},[y]),c.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...G,transform:U?G.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:be,"--radix-popper-transform-origin":[(ne=z.transformOrigin)==null?void 0:ne.x,(pe=z.transformOrigin)==null?void 0:pe.y].join(" "),...((ie=z.hide)==null?void 0:ie.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(R0,{scope:n,placedSide:F,onArrowChange:C,arrowX:te,arrowY:he,shouldHideArrow:ve,children:c.jsx(_e.div,{"data-side":F,"data-align":de,...x,ref:S,style:{...x.style,animation:U?void 0:"none"}})})})});$f.displayName=Ka;var Ff="PopperArrow",O0={top:"bottom",right:"left",bottom:"top",left:"right"},zf=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=P0(Ff,r),i=O0[s.placedSide];return c.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:c.jsx(_0,{...o,ref:n,style:{...o.style,display:"block"}})})});zf.displayName=Ff;function M0(e){return e!==null}var D0=e=>({name:"transformOrigin",options:e,fn(t){var g,y,b;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[u,d]=Bf(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,p=(((b=o.arrow)==null?void 0:b.y)??0)+l/2;let v="",x="";return u==="bottom"?(v=i?f:`${h}px`,x=`${-l}px`):u==="top"?(v=i?f:`${h}px`,x=`${r.floating.height+l}px`):u==="right"?(v=`${-l}px`,x=i?f:`${p}px`):u==="left"&&(v=`${r.floating.width+l}px`,x=i?f:`${p}px`),{data:{x:v,y:x}}}});function Bf(e){const[t,n="center"]=e.split("-");return[t,n]}var Hf=Mf,Uf=Lf,Wf=$f,Vf=zf,qa="rovingFocusGroup.onEntryFocus",L0={bubbles:!1,cancelable:!0},wo="RovingFocusGroup",[Ga,Kf,$0]=Pa(wo),[F0,qf]=Sn(wo,[$0]),[z0,B0]=F0(wo),Gf=m.forwardRef((e,t)=>c.jsx(Ga.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Ga.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(H0,{...e,ref:t})})}));Gf.displayName=wo;var H0=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,h=m.useRef(null),p=qe(t,h),v=Ms(s),[x,g]=fr({prop:i,defaultProp:a??null,onChange:l,caller:wo}),[y,b]=m.useState(!1),S=Et(u),I=Kf(n),C=m.useRef(!1),[T,E]=m.useState(0);return m.useEffect(()=>{const A=h.current;if(A)return A.addEventListener(qa,S),()=>A.removeEventListener(qa,S)},[S]),c.jsx(z0,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:x,onItemFocus:m.useCallback(A=>g(A),[g]),onItemShiftTab:m.useCallback(()=>b(!0),[]),onFocusableItemAdd:m.useCallback(()=>E(A=>A+1),[]),onFocusableItemRemove:m.useCallback(()=>E(A=>A-1),[]),children:c.jsx(_e.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:fe(e.onMouseDown,()=>{C.current=!0}),onFocus:fe(e.onFocus,A=>{const j=!C.current;if(A.target===A.currentTarget&&j&&!y){const P=new CustomEvent(qa,L0);if(A.currentTarget.dispatchEvent(P),!P.defaultPrevented){const D=I().filter(K=>K.focusable),L=D.find(K=>K.active),V=D.find(K=>K.id===x),G=[L,V,...D].filter(Boolean).map(K=>K.ref.current);Jf(G,d)}}C.current=!1}),onBlur:fe(e.onBlur,()=>b(!1))})})}),Yf="RovingFocusGroupItem",Xf=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=Cn(),u=s||l,d=B0(Yf,n),f=d.currentTabStopId===u,h=Kf(n),{onFocusableItemAdd:p,onFocusableItemRemove:v,currentTabStopId:x}=d;return m.useEffect(()=>{if(r)return p(),()=>v()},[r,p,v]),c.jsx(Ga.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:c.jsx(_e.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:fe(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:fe(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:fe(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const y=V0(g,d.orientation,d.dir);if(y!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let S=h().filter(I=>I.focusable).map(I=>I.ref.current);if(y==="last")S.reverse();else if(y==="prev"||y==="next"){y==="prev"&&S.reverse();const I=S.indexOf(g.currentTarget);S=d.loop?K0(S,I+1):S.slice(I+1)}setTimeout(()=>Jf(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:x!=null}):i})})});Xf.displayName=Yf;var U0={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function W0(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function V0(e,t,n){const r=W0(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return U0[r]}function Jf(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function K0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var q0=Gf,G0=Xf,Ya=["Enter"," "],Y0=["ArrowDown","PageUp","Home"],Zf=["ArrowUp","PageDown","End"],X0=[...Y0,...Zf],J0={ltr:[...Ya,"ArrowRight"],rtl:[...Ya,"ArrowLeft"]},Z0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},So="Menu",[Co,Q0,eS]=Pa(So),[yr,Qf]=Sn(So,[eS,Ks,qf]),qs=Ks(),eh=qf(),[tS,vr]=yr(So),[nS,To]=yr(So),th=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=qs(t),[l,u]=m.useState(null),d=m.useRef(!1),f=Et(s),h=Ms(o);return m.useEffect(()=>{const p=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),c.jsx(Hf,{...a,children:c.jsx(tS,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:u,children:c.jsx(nS,{scope:t,onClose:m.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};th.displayName=So;var rS="MenuAnchor",Xa=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=qs(n);return c.jsx(Uf,{...o,...r,ref:t})});Xa.displayName=rS;var Ja="MenuPortal",[oS,nh]=yr(Ja,{forceMount:void 0}),rh=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=vr(Ja,t);return c.jsx(oS,{scope:t,forceMount:n,children:c.jsx(Wt,{present:n||s.open,children:c.jsx(vs,{asChild:!0,container:o,children:r})})})};rh.displayName=Ja;var Jt="MenuContent",[sS,Za]=yr(Jt),oh=m.forwardRef((e,t)=>{const n=nh(Jt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=vr(Jt,e.__scopeMenu),i=To(Jt,e.__scopeMenu);return c.jsx(Co.Provider,{scope:e.__scopeMenu,children:c.jsx(Wt,{present:r||s.open,children:c.jsx(Co.Slot,{scope:e.__scopeMenu,children:i.modal?c.jsx(iS,{...o,ref:t}):c.jsx(aS,{...o,ref:t})})})})}),iS=m.forwardRef((e,t)=>{const n=vr(Jt,e.__scopeMenu),r=m.useRef(null),o=qe(t,r);return m.useEffect(()=>{const s=r.current;if(s)return Ia(s)},[]),c.jsx(Qa,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:fe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),aS=m.forwardRef((e,t)=>{const n=vr(Jt,e.__scopeMenu);return c.jsx(Qa,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),lS=rr.createSlot("MenuContent.ScrollLock"),Qa=m.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,disableOutsideScroll:v,...x}=e,g=vr(Jt,n),y=To(Jt,n),b=qs(n),S=eh(n),I=Q0(n),[C,T]=m.useState(null),E=m.useRef(null),A=qe(t,E,g.onContentChange),j=m.useRef(0),P=m.useRef(""),D=m.useRef(0),L=m.useRef(null),V=m.useRef("right"),M=m.useRef(0),G=v?ks:m.Fragment,K=v?{as:lS,allowPinchZoom:!0}:void 0,U=F=>{var q,O;const de=P.current+F,$=I().filter(Z=>!Z.disabled),te=document.activeElement,he=(q=$.find(Z=>Z.ref.current===te))==null?void 0:q.textValue,ve=$.map(Z=>Z.textValue),be=bS(ve,de,he),we=(O=$.find(Z=>Z.textValue===be))==null?void 0:O.ref.current;(function Z(ne){P.current=ne,window.clearTimeout(j.current),ne!==""&&(j.current=window.setTimeout(()=>Z(""),1e3))})(de),we&&setTimeout(()=>we.focus())};m.useEffect(()=>()=>window.clearTimeout(j.current),[]),wa();const z=m.useCallback(F=>{var $,te;return V.current===(($=L.current)==null?void 0:$.side)&&SS(F,(te=L.current)==null?void 0:te.area)},[]);return c.jsx(sS,{scope:n,searchRef:P,onItemEnter:m.useCallback(F=>{z(F)&&F.preventDefault()},[z]),onItemLeave:m.useCallback(F=>{var de;z(F)||((de=E.current)==null||de.focus(),T(null))},[z]),onTriggerLeave:m.useCallback(F=>{z(F)&&F.preventDefault()},[z]),pointerGraceTimerRef:D,onPointerGraceIntentChange:m.useCallback(F=>{L.current=F},[]),children:c.jsx(G,{...K,children:c.jsx(ys,{asChild:!0,trapped:o,onMountAutoFocus:fe(s,F=>{var de;F.preventDefault(),(de=E.current)==null||de.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:c.jsx(xs,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,children:c.jsx(q0,{asChild:!0,...S,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:fe(l,F=>{y.isUsingKeyboardRef.current||F.preventDefault()}),preventScrollOnEntryFocus:!0,children:c.jsx(Wf,{role:"menu","aria-orientation":"vertical","data-state":wh(g.open),"data-radix-menu-content":"",dir:y.dir,...b,...x,ref:A,style:{outline:"none",...x.style},onKeyDown:fe(x.onKeyDown,F=>{const $=F.target.closest("[data-radix-menu-content]")===F.currentTarget,te=F.ctrlKey||F.altKey||F.metaKey,he=F.key.length===1;$&&(F.key==="Tab"&&F.preventDefault(),!te&&he&&U(F.key));const ve=E.current;if(F.target!==ve||!X0.includes(F.key))return;F.preventDefault();const we=I().filter(q=>!q.disabled).map(q=>q.ref.current);Zf.includes(F.key)&&we.reverse(),yS(we)}),onBlur:fe(e.onBlur,F=>{F.currentTarget.contains(F.target)||(window.clearTimeout(j.current),P.current="")}),onPointerMove:fe(e.onPointerMove,Eo(F=>{const de=F.target,$=M.current!==F.clientX;if(F.currentTarget.contains(de)&&$){const te=F.clientX>M.current?"right":"left";V.current=te,M.current=F.clientX}}))})})})})})})});oh.displayName=Jt;var cS="MenuGroup",el=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(_e.div,{role:"group",...r,ref:t})});el.displayName=cS;var uS="MenuLabel",sh=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(_e.div,{...r,ref:t})});sh.displayName=uS;var Gs="MenuItem",ih="menu.itemSelect",Ys=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=m.useRef(null),i=To(Gs,e.__scopeMenu),a=Za(Gs,e.__scopeMenu),l=qe(t,s),u=m.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(ih,{bubbles:!0,cancelable:!0});f.addEventListener(ih,p=>r==null?void 0:r(p),{once:!0}),zu(f,h),h.defaultPrevented?u.current=!1:i.onClose()}};return c.jsx(ah,{...o,ref:l,disabled:n,onClick:fe(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),u.current=!0},onPointerUp:fe(e.onPointerUp,f=>{var h;u.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:fe(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||Ya.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});Ys.displayName=Gs;var ah=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Za(Gs,n),a=eh(n),l=m.useRef(null),u=qe(t,l),[d,f]=m.useState(!1),[h,p]=m.useState("");return m.useEffect(()=>{const v=l.current;v&&p((v.textContent??"").trim())},[s.children]),c.jsx(Co.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:c.jsx(G0,{asChild:!0,...a,focusable:!r,children:c.jsx(_e.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:fe(e.onPointerMove,Eo(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:fe(e.onPointerLeave,Eo(v=>i.onItemLeave(v))),onFocus:fe(e.onFocus,()=>f(!0)),onBlur:fe(e.onBlur,()=>f(!1))})})})}),dS="MenuCheckboxItem",lh=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return c.jsx(hh,{scope:e.__scopeMenu,checked:n,children:c.jsx(Ys,{role:"menuitemcheckbox","aria-checked":Xs(n)?"mixed":n,...o,ref:t,"data-state":nl(n),onSelect:fe(o.onSelect,()=>r==null?void 0:r(Xs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});lh.displayName=dS;var ch="MenuRadioGroup",[fS,hS]=yr(ch,{value:void 0,onValueChange:()=>{}}),uh=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=Et(r);return c.jsx(fS,{scope:e.__scopeMenu,value:n,onValueChange:s,children:c.jsx(el,{...o,ref:t})})});uh.displayName=ch;var dh="MenuRadioItem",fh=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=hS(dh,e.__scopeMenu),s=n===o.value;return c.jsx(hh,{scope:e.__scopeMenu,checked:s,children:c.jsx(Ys,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":nl(s),onSelect:fe(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});fh.displayName=dh;var tl="MenuItemIndicator",[hh,pS]=yr(tl,{checked:!1}),ph=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=pS(tl,n);return c.jsx(Wt,{present:r||Xs(s.checked)||s.checked===!0,children:c.jsx(_e.span,{...o,ref:t,"data-state":nl(s.checked)})})});ph.displayName=tl;var mS="MenuSeparator",mh=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(_e.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});mh.displayName=mS;var gS="MenuArrow",gh=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=qs(n);return c.jsx(Vf,{...o,...r,ref:t})});gh.displayName=gS;var xS="MenuSub",[ek,xh]=yr(xS),ko="MenuSubTrigger",yh=m.forwardRef((e,t)=>{const n=vr(ko,e.__scopeMenu),r=To(ko,e.__scopeMenu),o=xh(ko,e.__scopeMenu),s=Za(ko,e.__scopeMenu),i=m.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,u={__scopeMenu:e.__scopeMenu},d=m.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return m.useEffect(()=>d,[d]),m.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),c.jsx(Xa,{asChild:!0,...u,children:c.jsx(ah,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":wh(n.open),...e,ref:aa(t,o.onTriggerChange),onClick:f=>{var h;(h=e.onClick)==null||h.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:fe(e.onPointerMove,Eo(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:fe(e.onPointerLeave,Eo(f=>{var p,v;d();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const x=(v=n.content)==null?void 0:v.dataset.side,g=x==="right",y=g?-5:5,b=h[g?"left":"right"],S=h[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+y,y:f.clientY},{x:b,y:h.top},{x:S,y:h.top},{x:S,y:h.bottom},{x:b,y:h.bottom}],side:x}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:fe(e.onKeyDown,f=>{var p;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||J0[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});yh.displayName=ko;var vh="MenuSubContent",bh=m.forwardRef((e,t)=>{const n=nh(Jt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=vr(Jt,e.__scopeMenu),i=To(Jt,e.__scopeMenu),a=xh(vh,e.__scopeMenu),l=m.useRef(null),u=qe(t,l);return c.jsx(Co.Provider,{scope:e.__scopeMenu,children:c.jsx(Wt,{present:r||s.open,children:c.jsx(Co.Slot,{scope:e.__scopeMenu,children:c.jsx(Qa,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:u,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var f;i.isUsingKeyboardRef.current&&((f=l.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:fe(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:fe(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:fe(e.onKeyDown,d=>{var p;const f=d.currentTarget.contains(d.target),h=Z0[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});bh.displayName=vh;function wh(e){return e?"open":"closed"}function Xs(e){return e==="indeterminate"}function nl(e){return Xs(e)?"indeterminate":e?"checked":"unchecked"}function yS(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function vS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function bS(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=vS(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function wS(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],u=a.x,d=a.y,f=l.x,h=l.y;d>r!=h>r&&n<(f-u)*(r-d)/(h-d)+u&&(o=!o)}return o}function SS(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return wS(n,t)}function Eo(e){return t=>t.pointerType==="mouse"?e(t):void 0}var CS=th,TS=Xa,kS=rh,ES=oh,IS=el,NS=sh,AS=Ys,_S=lh,jS=uh,RS=fh,PS=ph,OS=mh,MS=gh,DS=yh,LS=bh,Js="DropdownMenu",[$S,tk]=Sn(Js,[Qf]),Mt=Qf(),[FS,Sh]=$S(Js),Ch=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Mt(t),u=m.useRef(null),[d,f]=fr({prop:o,defaultProp:s??!1,onChange:i,caller:Js});return c.jsx(FS,{scope:t,triggerId:Cn(),triggerRef:u,contentId:Cn(),open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(h=>!h),[f]),modal:a,children:c.jsx(CS,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};Ch.displayName=Js;var Th="DropdownMenuTrigger",kh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Sh(Th,n),i=Mt(n);return c.jsx(TS,{asChild:!0,...i,children:c.jsx(_e.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:aa(t,s.triggerRef),onPointerDown:fe(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:fe(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});kh.displayName=Th;var zS="DropdownMenuPortal",Eh=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Mt(t);return c.jsx(kS,{...r,...n})};Eh.displayName=zS;var Ih="DropdownMenuContent",Nh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Sh(Ih,n),s=Mt(n),i=m.useRef(!1);return c.jsx(ES,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:fe(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:fe(e.onInteractOutside,a=>{const l=a.detail.originalEvent,u=l.button===0&&l.ctrlKey===!0,d=l.button===2||u;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Nh.displayName=Ih;var BS="DropdownMenuGroup",HS=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mt(n);return c.jsx(IS,{...o,...r,ref:t})});HS.displayName=BS;var US="DropdownMenuLabel",Ah=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mt(n);return c.jsx(NS,{...o,...r,ref:t})});Ah.displayName=US;var WS="DropdownMenuItem",_h=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mt(n);return c.jsx(AS,{...o,...r,ref:t})});_h.displayName=WS;var VS="DropdownMenuCheckboxItem",jh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mt(n);return c.jsx(_S,{...o,...r,ref:t})});jh.displayName=VS;var KS="DropdownMenuRadioGroup",qS=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mt(n);return c.jsx(jS,{...o,...r,ref:t})});qS.displayName=KS;var GS="DropdownMenuRadioItem",Rh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mt(n);return c.jsx(RS,{...o,...r,ref:t})});Rh.displayName=GS;var YS="DropdownMenuItemIndicator",Ph=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mt(n);return c.jsx(PS,{...o,...r,ref:t})});Ph.displayName=YS;var XS="DropdownMenuSeparator",Oh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mt(n);return c.jsx(OS,{...o,...r,ref:t})});Oh.displayName=XS;var JS="DropdownMenuArrow",ZS=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mt(n);return c.jsx(MS,{...o,...r,ref:t})});ZS.displayName=JS;var QS="DropdownMenuSubTrigger",Mh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mt(n);return c.jsx(DS,{...o,...r,ref:t})});Mh.displayName=QS;var eC="DropdownMenuSubContent",Dh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mt(n);return c.jsx(LS,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Dh.displayName=eC;var tC=Ch,nC=kh,rC=Eh,Lh=Nh,$h=Ah,Fh=_h,zh=jh,Bh=Rh,Hh=Ph,Uh=Oh,Wh=Mh,Vh=Dh;const oC=tC,sC=nC,iC=m.forwardRef(({className:e,inset:t,children:n,...r},o)=>c.jsxs(Wh,{ref:o,className:ee("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,c.jsx(le.ChevronRight,{className:"ml-auto h-4 w-4"})]}));iC.displayName=Wh.displayName;const aC=m.forwardRef(({className:e,...t},n)=>c.jsx(Vh,{ref:n,className:ee("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));aC.displayName=Vh.displayName;const Kh=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(rC,{children:c.jsx(Lh,{ref:r,sideOffset:t,className:ee("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));Kh.displayName=Lh.displayName;const rl=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Fh,{ref:r,className:ee("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));rl.displayName=Fh.displayName;const lC=m.forwardRef(({className:e,children:t,checked:n,...r},o)=>c.jsxs(zh,{ref:o,className:ee("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Hh,{children:c.jsx(le.Check,{className:"h-4 w-4"})})}),t]}));lC.displayName=zh.displayName;const cC=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Bh,{ref:r,className:ee("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Hh,{children:c.jsx(le.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));cC.displayName=Bh.displayName;const uC=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx($h,{ref:r,className:ee("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));uC.displayName=$h.displayName;const dC=m.forwardRef(({className:e,...t},n)=>c.jsx(Uh,{ref:n,className:ee("-mx-1 my-1 h-px bg-muted",e),...t}));dC.displayName=Uh.displayName;function Zs({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:u=!0,customStyles:d={},onMessageSent:f,onExcelUploadSuccess:h,onError:p}){const{api:v}=ki(),{currentThreadId:x}=Ko(),{threadId:g,messages:y,hasMore:b,isHistoryLoading:S,isLoading:I,loadOlder:C,listCheckpoints:T,navigateToCheckpoint:E,returnToLatest:A,checkpoint:j,respondToInterrupt:P,metadata:D}=qo(),{isStreaming:L,error:V,submit:M,stop:G}=Fc(),K=g??x??null,U=(j==null?void 0:j.id)??null,z=(j==null?void 0:j.namespace)??null,F=(D==null?void 0:D.assemblingMessageId)??null,[de,$]=w.useState(null),[te,he]=w.useState(""),[ve,be]=w.useState(null),[we,q]=w.useState([]),[O,Z]=w.useState(0),[ne,pe]=w.useState(0),[ie,me]=w.useState(!1),[et,tt]=w.useState(null),[Me,We]=w.useState(null),[ut,nt]=w.useState(!1),[Ve,yt]=w.useState(null),[Q,ae]=w.useState([]),[ge,Se]=w.useState(null),[xe,Oe]=w.useState(null),[at,De]=w.useState(!1),st=w.useRef(null),ft=w.useRef(null),It=w.useRef(null),_n=w.useCallback(()=>{st.current&&(st.current.value=""),ft.current&&(ft.current.value=""),Z(se=>se+1),pe(se=>se+1)},[]),pn=w.useRef(!1);w.useEffect(()=>{pn.current&&!L&&(q([]),_n()),pn.current=L},[L,_n]);const[en,jn]=w.useState("desktop");w.useEffect(()=>{const se=()=>{const Ce=window.innerWidth;jn(Ce<640?"phone":Ce<1024?"tablet":"desktop")};return se(),window.addEventListener("resize",se),()=>window.removeEventListener("resize",se)},[]),w.useEffect(()=>{let se=!1;if(!K){ae([]),Se(null),Oe(null),It.current=null;return}const Ce={threadId:K,checkpointId:U??null,checkpointNs:z??null},Ke=It.current;if(!(Ke&&Ke.threadId===Ce.threadId&&Ke.checkpointId===Ce.checkpointId&&Ke.checkpointNs===Ce.checkpointNs))return T(K).then(it=>{var Ee;if(se)return;const Dt=((it==null?void 0:it.checkpoints)??[]).slice().sort((ze,Xe)=>new Date(Xe.createdAt).getTime()-new Date(ze.createdAt).getTime());ae(Dt);const k=ge,B=k&&Dt.some(ze=>ze.checkpointId===k)?k:((Ee=Dt[0])==null?void 0:Ee.checkpointId)??null;let re=null;if(B){const ze=Dt.find(Xe=>Xe.checkpointId===B);re=(ze==null?void 0:ze.checkpointNs)??null}Se(B),Oe(re),It.current=Ce}).catch(it=>{console.error("ChatInterface - listCheckpoints error:",it),se||(ae([]),It.current=null)}),()=>{se=!0}},[K,U,z,ge,T]),w.useEffect(()=>{U&&(Se(U),Oe(z??null))},[U,z]);const Rn=w.useCallback(async()=>{if(!(!b||S))try{await C()}catch(se){console.warn("loadOlder failed",se)}},[b,S,C]);w.useEffect(()=>{(async()=>{if(!v.baseUrl){yt(null);return}try{const Ce=await v.getAgent("default");yt(Ce.uiDefaultMessage||null)}catch(Ce){console.warn("Failed to fetch default message:",Ce),yt(null)}})()},[v]),w.useEffect(()=>{V&&!ut&&(p==null||p(V))},[V,ut,p]);const tr=se=>{if(se.length>Os)return`Message too long (${se.length}/${Os} characters)`;try{return xw(se),null}catch(Ce){return(Ce==null?void 0:Ce.message)||"Invalid message"}},No=async se=>{const Ce=se.trim();if(!(!Ce&&we.length===0)){if(Ce){const Ke=tr(Ce);if(Ke){be(Ke);return}}try{await M({text:Ce||"",attachments:we,payload:de?{edit:!0,originalMessageId:de}:void 0},{checkpointId:ge??U??void 0,checkpointNs:xe??z??void 0}),f==null||f(Ce),be(null),q([]),_n(),$(null),he("")}catch(Ke){const it=(Ke==null?void 0:Ke.message)||"Failed to send message";be(it),p==null||p(it)}}},mn=w.useCallback((se,Ce)=>{u&&($(se),he(Ce),be(null))},[u]),gn=w.useCallback(()=>{$(null),he(""),be(null)},[]),Nt=w.useCallback((se,Ce)=>{mn(se,Ce)},[mn]),Kr=w.useCallback(se=>{const Ce=Ke=>{const it=Ke.content||[],Dt=it.filter(k=>k.type==="text").map(k=>k.text).join("");if(Dt)return Dt;try{return JSON.stringify(it,null,2)}catch{return String(it)}};for(let Ke=se-1;Ke>=0;Ke--)if(y[Ke].role==="user"){const it=Ce(y[Ke]);it&&M({text:it},{checkpointId:ge??U??void 0,checkpointNs:xe??z??void 0});break}},[y,M,ge,xe,U,z]),Cr=se=>{const Ce=Array.from(se.target.files||[]);q(Ke=>[...Ke,...Ce]),se.target.value=""},wt=se=>{q(Ce=>{const Ke=Ce.filter((it,Dt)=>se!==Dt);return Ke.length===0&&_n(),Ke})},Pn=async se=>{const Ce=(se.target.files||[])[0];if(Ce){tt(null),We(null),me(!0);try{await M({attachments:[Ce]},{checkpointId:ge??U??void 0,checkpointNs:xe??z??void 0});const Ke=`Uploaded ${Ce.name} - processing through chat stream`;We(Ke)}catch(Ke){const it=Ke instanceof Error?Ke.message:"Failed to upload Excel file";console.error("Excel upload failed",Ke),tt(it),p==null||p(it)}finally{me(!1),se.target.value="",_n()}}},On=se=>{if(!se)return"Unknown";const Ce=Date.parse(se);return Number.isNaN(Ce)?se:new Date(Ce).toLocaleString()},Tr=async se=>{if(x){De(!0);try{if(!se){await A(),Se(null),Oe(null);return}const Ce=Q.find(it=>it.checkpointId===se),Ke=(Ce==null?void 0:Ce.checkpointNs)??null;await E(se,Ke),Se(se),Oe(Ke)}finally{De(!1)}}},tn=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${d.container||""}`,kr=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${d.messagesArea||""}`,xn=`flex-shrink-0 w-full border-t p-4 bg-transparent ${d.inputArea||""}`;return c.jsxs("div",{className:tn,children:[!!V&&!ut&&c.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[c.jsx("span",{children:V}),c.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>nt(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:c.jsx(le.X,{size:16})})]}),x&&Q.length>0&&c.jsxs("div",{className:"flex-shrink-0 flex items-center gap-2 px-4 py-2 border-b border-border bg-muted/60 text-xs dark:bg-muted/50",children:[c.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),c.jsxs("select",{className:"border border-border rounded px-2 py-1 text-xs bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring dark:bg-secondary",value:ge??"",onChange:se=>{const Ce=se.target.value||null;Tr(Ce)},children:[c.jsx("option",{value:"",children:"Latest"}),Q.map(se=>c.jsxs("option",{value:se.checkpointId,children:[On(se.createdAt),se.preview?` — ${se.preview.slice(0,40)}`:""]},se.checkpointId))]})]}),c.jsxs("div",{className:`relative ${kr}`,style:r?{maxHeight:r}:void 0,children:[c.jsx(Ra,{className:"h-full",style:{height:"100%"},messages:y,isStreaming:L,streamingAssistantId:F,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:en,enableMessageEditing:u,editingMessageId:de,onStartReached:()=>{Rn()},onEdit:Nt,onRegenerate:Kr,onCancelEdit:gn,emptyMessage:Ve??void 0,isNavigatingCheckpoint:at}),I&&c.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[c.jsx(le.Loader2,{className:"h-6 w-6 animate-spin"}),c.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]})]}),c.jsxs("div",{className:xn,children:[de&&c.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(le.Edit3,{size:16,className:"text-blue-600"}),c.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),c.jsx(Je,{variant:"ghost",size:"sm",onClick:gn,className:"text-blue-600 hover:bg-blue-100",children:c.jsx(le.X,{size:16})})]})}),(a||l)&&c.jsxs("div",{className:"mb-3 space-y-3",children:[a&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:st,type:"file",multiple:!0,onChange:se=>Cr(se),className:"hidden"},O),we.length>0&&c.jsx("div",{className:"flex flex-wrap gap-2",children:we.map((se,Ce)=>c.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[c.jsx(le.Paperclip,{size:14}),c.jsx("span",{className:"truncate max-w-[150px]",children:se.name}),c.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>wt(Ce),className:"h-4 w-4 p-0 text-gray-500 dark:text-gray-400 hover:text-red-500 dark:hover:text-red-400","aria-label":`Remove ${se.name}`,children:c.jsx(le.X,{size:12})})]},Ce))})]}),l&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:ft,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Pn,className:"hidden"},ne),ie&&c.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[c.jsx(le.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),Me&&!ie&&c.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:Me}),et&&!ie&&c.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:et})]})]}),ve&&c.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:ve}),c.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&c.jsxs(oC,{children:[c.jsx(sC,{asChild:!0,children:c.jsx(Je,{type:"button",size:"icon",variant:"outline",disabled:L,title:"More input actions",className:d.moreButton||"",children:c.jsx(le.Plus,{size:16})})}),c.jsxs(Kh,{align:"start",sideOffset:6,className:"w-52",children:[a&&c.jsxs(rl,{onClick:()=>{var se;return(se=st.current)==null?void 0:se.click()},className:"cursor-pointer",children:[c.jsx(le.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&c.jsxs(rl,{onClick:()=>{var se;ie||(se=ft.current)==null||se.click()},className:`cursor-pointer ${ie?"opacity-60 pointer-events-none":""}`,children:[c.jsx(le.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),c.jsx("div",{className:"flex-1",children:c.jsx(_x,{initialValue:te,editingMessageId:de,placeholder:de?"Edit your message...":t,isStreaming:L,disabled:!1,maxLength:Os,onSend:No,onCancelEdit:gn,onStop:G,allowEmptySend:we.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${de?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${ve?"border-red-400":""} ${d.textarea||""}`})})]})]})]})}const Qs=m.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{type:t,className:ee("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));Qs.displayName="Input";function ol(e,[t,n]){return Math.min(n,Math.max(t,e))}function fC(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var sl="ScrollArea",[qh,nk]=Sn(sl),[hC,Zt]=qh(sl),Gh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=m.useState(null),[u,d]=m.useState(null),[f,h]=m.useState(null),[p,v]=m.useState(null),[x,g]=m.useState(null),[y,b]=m.useState(0),[S,I]=m.useState(0),[C,T]=m.useState(!1),[E,A]=m.useState(!1),j=qe(t,D=>l(D)),P=Ms(o);return c.jsx(hC,{scope:n,type:r,dir:P,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:v,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:x,onScrollbarYChange:g,scrollbarYEnabled:E,onScrollbarYEnabledChange:A,onCornerWidthChange:b,onCornerHeightChange:I,children:c.jsx(_e.div,{dir:P,...i,ref:j,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Gh.displayName=sl;var Yh="ScrollAreaViewport",Xh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=Zt(Yh,n),a=m.useRef(null),l=qe(t,a,i.onViewportChange);return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),c.jsx(_e.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:c.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Xh.displayName=Yh;var An="ScrollAreaScrollbar",il=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Zt(An,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return m.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?c.jsx(pC,{...r,ref:t,forceMount:n}):o.type==="scroll"?c.jsx(mC,{...r,ref:t,forceMount:n}):o.type==="auto"?c.jsx(Jh,{...r,ref:t,forceMount:n}):o.type==="always"?c.jsx(al,{...r,ref:t}):null});il.displayName=An;var pC=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Zt(An,e.__scopeScrollArea),[s,i]=m.useState(!1);return m.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const u=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),c.jsx(Wt,{present:n||s,children:c.jsx(Jh,{"data-state":s?"visible":"hidden",...r,ref:t})})}),mC=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Zt(An,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ri(()=>l("SCROLL_END"),100),[a,l]=fC("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return m.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,l]),m.useEffect(()=>{const u=o.viewport,d=s?"scrollLeft":"scrollTop";if(u){let f=u[d];const h=()=>{const p=u[d];f!==p&&(l("SCROLL"),i()),f=p};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[o.viewport,s,l,i]),c.jsx(Wt,{present:n||a!=="hidden",children:c.jsx(al,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:fe(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:fe(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Jh=m.forwardRef((e,t)=>{const n=Zt(An,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=m.useState(!1),a=e.orientation==="horizontal",l=ri(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?u:d)}},10);return Ur(n.viewport,l),Ur(n.content,l),c.jsx(Wt,{present:r||s,children:c.jsx(al,{"data-state":s?"visible":"hidden",...o,ref:t})})}),al=m.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Zt(An,e.__scopeScrollArea),s=m.useRef(null),i=m.useRef(0),[a,l]=m.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=np(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:u>0&&u<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function f(h,p){return wC(h,i.current,a,p)}return n==="horizontal"?c.jsx(gC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=rp(h,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=f(h,o.dir))}}):n==="vertical"?c.jsx(xC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=rp(h,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),gC=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Zt(An,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=qe(t,l,s.onScrollbarXChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(Qh,{"data-orientation":"horizontal",...o,ref:u,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":ni(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(s.viewport){const h=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(h),sp(h,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:ti(i.paddingLeft),paddingEnd:ti(i.paddingRight)}})}})}),xC=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Zt(An,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=qe(t,l,s.onScrollbarYChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(Qh,{"data-orientation":"vertical",...o,ref:u,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":ni(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(s.viewport){const h=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(h),sp(h,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:ti(i.paddingTop),paddingEnd:ti(i.paddingBottom)}})}})}),[yC,Zh]=qh(An),Qh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:u,onWheelScroll:d,onResize:f,...h}=e,p=Zt(An,n),[v,x]=m.useState(null),g=qe(t,j=>x(j)),y=m.useRef(null),b=m.useRef(""),S=p.viewport,I=r.content-r.viewport,C=Et(d),T=Et(l),E=ri(f,10);function A(j){if(y.current){const P=j.clientX-y.current.left,D=j.clientY-y.current.top;u({x:P,y:D})}}return m.useEffect(()=>{const j=P=>{const D=P.target;(v==null?void 0:v.contains(D))&&C(P,I)};return document.addEventListener("wheel",j,{passive:!1}),()=>document.removeEventListener("wheel",j,{passive:!1})},[S,v,I,C]),m.useEffect(T,[r,T]),Ur(v,E),Ur(p.content,E),c.jsx(yC,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:Et(s),onThumbPointerUp:Et(i),onThumbPositionChange:T,onThumbPointerDown:Et(a),children:c.jsx(_e.div,{...h,ref:g,style:{position:"absolute",...h.style},onPointerDown:fe(e.onPointerDown,j=>{j.button===0&&(j.target.setPointerCapture(j.pointerId),y.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),A(j))}),onPointerMove:fe(e.onPointerMove,A),onPointerUp:fe(e.onPointerUp,j=>{const P=j.target;P.hasPointerCapture(j.pointerId)&&P.releasePointerCapture(j.pointerId),document.body.style.webkitUserSelect=b.current,p.viewport&&(p.viewport.style.scrollBehavior=""),y.current=null})})})}),ei="ScrollAreaThumb",ep=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Zh(ei,e.__scopeScrollArea);return c.jsx(Wt,{present:n||o.hasThumb,children:c.jsx(vC,{ref:t,...r})})}),vC=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=Zt(ei,n),i=Zh(ei,n),{onThumbPositionChange:a}=i,l=qe(t,f=>i.onThumbChange(f)),u=m.useRef(void 0),d=ri(()=>{u.current&&(u.current(),u.current=void 0)},100);return m.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(d(),!u.current){const p=SC(f,a);u.current=p,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,d,a]),c.jsx(_e.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:fe(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),v=f.clientX-p.left,x=f.clientY-p.top;i.onThumbPointerDown({x:v,y:x})}),onPointerUp:fe(e.onPointerUp,i.onThumbPointerUp)})});ep.displayName=ei;var ll="ScrollAreaCorner",tp=m.forwardRef((e,t)=>{const n=Zt(ll,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?c.jsx(bC,{...e,ref:t}):null});tp.displayName=ll;var bC=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Zt(ll,n),[s,i]=m.useState(0),[a,l]=m.useState(0),u=!!(s&&a);return Ur(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Ur(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),u?c.jsx(_e.div,{...r,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function ti(e){return e?parseInt(e,10):0}function np(e,t){const n=e/t;return isNaN(n)?0:n}function ni(e){const t=np(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function wC(e,t,n,r="ltr"){const o=ni(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,u=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return op([l,u],f)(e)}function rp(e,t,n="ltr"){const r=ni(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],u=ol(e,l);return op([0,i],[0,a])(u)}function op(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function sp(e,t){return e>0&&e<t}var SC=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function ri(e,t){const n=Et(e),r=m.useRef(0);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),m.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Ur(e,t){const n=Et(t);Tt(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var ip=Gh,CC=Xh,TC=tp;const ap=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(ip,{ref:r,className:ee("relative overflow-hidden",e),...n,children:[c.jsx(CC,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),c.jsx(lp,{}),c.jsx(TC,{})]}));ap.displayName=ip.displayName;const lp=m.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(il,{ref:r,orientation:t,className:ee("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:c.jsx(ep,{className:"relative flex-1 rounded-full bg-border"})}));lp.displayName=il.displayName;function cl({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:u,onThreadDelete:d}){const{threads:f,currentThreadId:h,isLoading:p,actions:v}=Ko(),{loadThread:x}=qo(),{createThread:g,deleteThread:y,renameThread:b}=v,[S,I]=w.useState(Array.isArray(f)?f:[]),C=w.useRef(S.length>0),[T,E]=w.useState(null),[A,j]=w.useState(""),[P,D]=w.useState(!1);w.useEffect(()=>{const $=Array.isArray(f)?f:[];if($.length>0){C.current=!0,I($);return}p||(C.current=!1,I($))},[f,p]);const L=async $=>{try{await x($),a==null||a($),l==null||l($)}catch(te){console.error("Failed to select thread:",te)}},V=async()=>{try{D(!0);const $=await g();u==null||u($),a==null||a($)}catch($){console.error("Failed to create thread:",$)}finally{D(!1)}},M=async($,te)=>{if(te.stopPropagation(),!!confirm("Delete this thread?"))try{await y($),d==null||d($)}catch(he){console.error("Failed to delete thread:",he)}},G=($,te)=>{te.stopPropagation(),E($.threadId),j($.title||`Thread ${$.threadId.slice(0,8)}`)},K=async $=>{if(A.trim())try{await b($,A.trim()),E(null),j("")}catch(te){console.error("Failed to update title:",te)}},U=()=>{E(null),j("")},z=($,te)=>{$.key==="Enter"?K(te):$.key==="Escape"&&U()},F=$=>{if(!$)return"";try{const te=new Date($),ve=new Date().getTime()-te.getTime(),be=Math.floor(ve/(1e3*60*60*24));return be===0?te.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):be===1?"Yesterday":be<7?`${be} days ago`:te.toLocaleDateString()}catch{return""}},de=$=>$.title||`Thread ${$.threadId.slice(0,8)}`;return c.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&c.jsx("div",{className:s.header||"flex-shrink-0 p-2 border-b bg-slate-800 border-slate-700 text-slate-100 flex justify-end",children:c.jsx(Je,{onClick:V,disabled:P||p,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:P?"Creating...":"New Chat",children:c.jsx(le.MessageSquarePlus,{size:20})})}),c.jsx(ap,{className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:c.jsx("div",{className:"p-2 space-y-1 pb-4",children:p?c.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[c.jsx(le.Loader2,{className:"h-5 w-5 animate-spin"}),c.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):S.length===0?c.jsxs("div",{className:"text-center py-8 text-slate-400",children:[c.jsx(le.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),c.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):S.slice().sort(($,te)=>new Date(te.updatedAt||te.createdAt||"").getTime()-new Date($.updatedAt||$.createdAt||"").getTime()).map($=>c.jsxs("div",{onClick:()=>L($.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??h)===$.threadId?`${s.activeThread||"bg-slate-600 border-slate-500"} `:`${s.threadItem||"bg-slate-700 border-slate-600 hover:bg-slate-600 text-gray-900 dark:text-slate-100"}`} ${s.threadItem||""} text-gray-900 dark:text-slate-100`,children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"flex-1 min-w-0",children:T===$.threadId?c.jsxs("div",{className:"flex items-center gap-2",onClick:te=>te.stopPropagation(),children:[c.jsx(Qs,{value:A,onChange:te=>j(te.target.value),onKeyDown:te=>z(te,$.threadId),className:"h-6 text-sm",autoFocus:!0}),c.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>K($.threadId),className:"h-6 w-6 p-0",children:c.jsx(le.Check,{size:12})}),c.jsx(Je,{variant:"ghost",size:"sm",onClick:U,className:"h-6 w-6 p-0",children:c.jsx(le.X,{size:12})})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:de($)}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[c.jsx(le.Calendar,{size:10}),c.jsx("span",{children:F($.updatedAt||$.createdAt)})]})]})}),c.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&T!==$.threadId&&c.jsx(Je,{variant:"ghost",size:"sm",onClick:te=>G($,te),className:"h-6 w-6 p-0",title:"Edit title",children:c.jsx(le.Edit3,{size:12})}),n&&c.jsx(Je,{variant:"ghost",size:"sm",onClick:te=>M($.threadId,te),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:c.jsx(le.Trash2,{size:12})})]})]}),i===$.threadId&&c.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},$.threadId))})})]})}function Wr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function kC(e){if(typeof e!="string")return;const t=e.trim();if(t)return Dn(t)}function cp(){const e=[Wr("__API_BASE_URL__"),Wr("__CHAT_API_BASE_URL__"),Wr("__CHAT_API_URL__")];for(const t of e){const n=kC(t);if(n)return n}}function up(){const e=[Wr("__API_AUTH_TOKEN__"),Wr("__CHAT_API_KEY__"),Wr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function dp(...e){for(const t of e)if(typeof t=="string"&&t.trim())return Dn(t);return Dn()}function fp(){const e={},t=cp(),n=up();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function hp(){const e=fp(),t=Hn.getAuthToken(),n=cp();return{apiBaseUrl:dp(e.baseUrl,Hn.baseUrl,n),apiKey:t||e.apiKey||up()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const pp="chat-settings";function EC(){try{const e=localStorage.getItem(pp);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function IC(e){try{const t={...e,apiBaseUrl:Dn(e.apiBaseUrl)};localStorage.setItem(pp,JSON.stringify(t)),t.apiKey&&Hn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function NC(){const e=hp(),t=EC(),n=Hn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:dp(Hn.baseUrl,r,e.apiBaseUrl)}}function AC(e){Hn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),IC(e)}var _C="Label",mp=m.forwardRef((e,t)=>c.jsx(_e.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));mp.displayName=_C;var gp=mp;const jC=_o.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Qt=m.forwardRef(({className:e,...t},n)=>c.jsx(gp,{ref:n,className:ee(jC(),e),...t}));Qt.displayName=gp.displayName;function xp(e){const t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var oi="Switch",[RC,rk]=Sn(oi),[PC,OC]=RC(oi),yp=m.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:u,form:d,...f}=e,[h,p]=m.useState(null),v=qe(t,S=>p(S)),x=m.useRef(!1),g=h?d||!!h.closest("form"):!0,[y,b]=fr({prop:o,defaultProp:s??!1,onChange:u,caller:oi});return c.jsxs(PC,{scope:n,checked:y,disabled:a,children:[c.jsx(_e.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":Sp(y),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:v,onClick:fe(e.onClick,S=>{b(I=>!I),g&&(x.current=S.isPropagationStopped(),x.current||S.stopPropagation())})}),g&&c.jsx(wp,{control:h,bubbles:!x.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});yp.displayName=oi;var vp="SwitchThumb",bp=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=OC(vp,n);return c.jsx(_e.span,{"data-state":Sp(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});bp.displayName=vp;var MC="SwitchBubbleInput",wp=m.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=m.useRef(null),a=qe(i,s),l=xp(n),u=Rf(t);return m.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const v=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(v)}},[l,n,r]),c.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});wp.displayName=MC;function Sp(e){return e?"checked":"unchecked"}var Cp=yp,DC=bp;const Zn=m.forwardRef(({className:e,...t},n)=>c.jsx(Cp,{className:ee("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:c.jsx(DC,{className:ee("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));Zn.displayName=Cp.displayName;var Tp=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),LC="VisuallyHidden",$C=m.forwardRef((e,t)=>c.jsx(_e.span,{...e,ref:t,style:{...Tp,...e.style}}));$C.displayName=LC;var FC=[" ","Enter","ArrowUp","ArrowDown"],zC=[" ","Enter"],br="Select",[si,ii,BC]=Pa(br),[Vr,ok]=Sn(br,[BC,Ks]),ai=Ks(),[HC,Qn]=Vr(br),[UC,WC]=Vr(br),kp=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:u,name:d,autoComplete:f,disabled:h,required:p,form:v}=e,x=ai(t),[g,y]=m.useState(null),[b,S]=m.useState(null),[I,C]=m.useState(!1),T=Ms(u),[E,A]=fr({prop:r,defaultProp:o??!1,onChange:s,caller:br}),[j,P]=fr({prop:i,defaultProp:a,onChange:l,caller:br}),D=m.useRef(null),L=g?v||!!g.closest("form"):!0,[V,M]=m.useState(new Set),G=Array.from(V).map(K=>K.props.value).join(";");return c.jsx(Hf,{...x,children:c.jsxs(HC,{required:p,scope:t,trigger:g,onTriggerChange:y,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:I,onValueNodeHasChildrenChange:C,contentId:Cn(),value:j,onValueChange:P,open:E,onOpenChange:A,dir:T,triggerPointerDownPosRef:D,disabled:h,children:[c.jsx(si.Provider,{scope:t,children:c.jsx(UC,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback(K=>{M(U=>new Set(U).add(K))},[]),onNativeOptionRemove:m.useCallback(K=>{M(U=>{const z=new Set(U);return z.delete(K),z})},[]),children:n})}),L?c.jsxs(Yp,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:j,onChange:K=>P(K.target.value),disabled:h,form:v,children:[j===void 0?c.jsx("option",{value:""}):null,Array.from(V)]},G):null]})})};kp.displayName=br;var Ep="SelectTrigger",Ip=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=ai(n),i=Qn(Ep,n),a=i.disabled||r,l=qe(t,i.onTriggerChange),u=ii(n),d=m.useRef("touch"),[f,h,p]=Jp(x=>{const g=u().filter(S=>!S.disabled),y=g.find(S=>S.value===i.value),b=Zp(g,x,y);b!==void 0&&i.onValueChange(b.value)}),v=x=>{a||(i.onOpenChange(!0),p()),x&&(i.triggerPointerDownPosRef.current={x:Math.round(x.pageX),y:Math.round(x.pageY)})};return c.jsx(Uf,{asChild:!0,...s,children:c.jsx(_e.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":Xp(i.value)?"":void 0,...o,ref:l,onClick:fe(o.onClick,x=>{x.currentTarget.focus(),d.current!=="mouse"&&v(x)}),onPointerDown:fe(o.onPointerDown,x=>{d.current=x.pointerType;const g=x.target;g.hasPointerCapture(x.pointerId)&&g.releasePointerCapture(x.pointerId),x.button===0&&x.ctrlKey===!1&&x.pointerType==="mouse"&&(v(x),x.preventDefault())}),onKeyDown:fe(o.onKeyDown,x=>{const g=f.current!=="";!(x.ctrlKey||x.altKey||x.metaKey)&&x.key.length===1&&h(x.key),!(g&&x.key===" ")&&FC.includes(x.key)&&(v(),x.preventDefault())})})})});Ip.displayName=Ep;var Np="SelectValue",Ap=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Qn(Np,n),{onValueNodeHasChildrenChange:u}=l,d=s!==void 0,f=qe(t,l.onValueNodeChange);return Tt(()=>{u(d)},[u,d]),c.jsx(_e.span,{...a,ref:f,style:{pointerEvents:"none"},children:Xp(l.value)?c.jsx(c.Fragment,{children:i}):s})});Ap.displayName=Np;var VC="SelectIcon",_p=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return c.jsx(_e.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});_p.displayName=VC;var KC="SelectPortal",jp=e=>c.jsx(vs,{asChild:!0,...e});jp.displayName=KC;var wr="SelectContent",Rp=m.forwardRef((e,t)=>{const n=Qn(wr,e.__scopeSelect),[r,o]=m.useState();if(Tt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?jo.createPortal(c.jsx(Pp,{scope:e.__scopeSelect,children:c.jsx(si.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),s):null}return c.jsx(Op,{...e,ref:t})});Rp.displayName=wr;var hn=10,[Pp,er]=Vr(wr),qC="SelectContentImpl",GC=rr.createSlot("SelectContent.RemoveScroll"),Op=m.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:v,hideWhenDetached:x,avoidCollisions:g,...y}=e,b=Qn(wr,n),[S,I]=m.useState(null),[C,T]=m.useState(null),E=qe(t,q=>I(q)),[A,j]=m.useState(null),[P,D]=m.useState(null),L=ii(n),[V,M]=m.useState(!1),G=m.useRef(!1);m.useEffect(()=>{if(S)return Ia(S)},[S]),wa();const K=m.useCallback(q=>{const[O,...Z]=L().map(ie=>ie.ref.current),[ne]=Z.slice(-1),pe=document.activeElement;for(const ie of q)if(ie===pe||(ie==null||ie.scrollIntoView({block:"nearest"}),ie===O&&C&&(C.scrollTop=0),ie===ne&&C&&(C.scrollTop=C.scrollHeight),ie==null||ie.focus(),document.activeElement!==pe))return},[L,C]),U=m.useCallback(()=>K([A,S]),[K,A,S]);m.useEffect(()=>{V&&U()},[V,U]);const{onOpenChange:z,triggerPointerDownPosRef:F}=b;m.useEffect(()=>{if(S){let q={x:0,y:0};const O=ne=>{var pe,ie;q={x:Math.abs(Math.round(ne.pageX)-(((pe=F.current)==null?void 0:pe.x)??0)),y:Math.abs(Math.round(ne.pageY)-(((ie=F.current)==null?void 0:ie.y)??0))}},Z=ne=>{q.x<=10&&q.y<=10?ne.preventDefault():S.contains(ne.target)||z(!1),document.removeEventListener("pointermove",O),F.current=null};return F.current!==null&&(document.addEventListener("pointermove",O),document.addEventListener("pointerup",Z,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",O),document.removeEventListener("pointerup",Z,{capture:!0})}}},[S,z,F]),m.useEffect(()=>{const q=()=>z(!1);return window.addEventListener("blur",q),window.addEventListener("resize",q),()=>{window.removeEventListener("blur",q),window.removeEventListener("resize",q)}},[z]);const[de,$]=Jp(q=>{const O=L().filter(pe=>!pe.disabled),Z=O.find(pe=>pe.ref.current===document.activeElement),ne=Zp(O,q,Z);ne&&setTimeout(()=>ne.ref.current.focus())}),te=m.useCallback((q,O,Z)=>{const ne=!G.current&&!Z;(b.value!==void 0&&b.value===O||ne)&&(j(q),ne&&(G.current=!0))},[b.value]),he=m.useCallback(()=>S==null?void 0:S.focus(),[S]),ve=m.useCallback((q,O,Z)=>{const ne=!G.current&&!Z;(b.value!==void 0&&b.value===O||ne)&&D(q)},[b.value]),be=r==="popper"?ul:Mp,we=be===ul?{side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:v,hideWhenDetached:x,avoidCollisions:g}:{};return c.jsx(Pp,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:te,selectedItem:A,onItemLeave:he,itemTextRefCallback:ve,focusSelectedItem:U,selectedItemText:P,position:r,isPositioned:V,searchRef:de,children:c.jsx(ks,{as:GC,allowPinchZoom:!0,children:c.jsx(ys,{asChild:!0,trapped:b.open,onMountAutoFocus:q=>{q.preventDefault()},onUnmountAutoFocus:fe(o,q=>{var O;(O=b.trigger)==null||O.focus({preventScroll:!0}),q.preventDefault()}),children:c.jsx(xs,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:q=>q.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:c.jsx(be,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:q=>q.preventDefault(),...y,...we,onPlaced:()=>M(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:fe(y.onKeyDown,q=>{const O=q.ctrlKey||q.altKey||q.metaKey;if(q.key==="Tab"&&q.preventDefault(),!O&&q.key.length===1&&$(q.key),["ArrowUp","ArrowDown","Home","End"].includes(q.key)){let ne=L().filter(pe=>!pe.disabled).map(pe=>pe.ref.current);if(["ArrowUp","End"].includes(q.key)&&(ne=ne.slice().reverse()),["ArrowUp","ArrowDown"].includes(q.key)){const pe=q.target,ie=ne.indexOf(pe);ne=ne.slice(ie+1)}setTimeout(()=>K(ne)),q.preventDefault()}})})})})})})});Op.displayName=qC;var YC="SelectItemAlignedPosition",Mp=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Qn(wr,n),i=er(wr,n),[a,l]=m.useState(null),[u,d]=m.useState(null),f=qe(t,E=>d(E)),h=ii(n),p=m.useRef(!1),v=m.useRef(!0),{viewport:x,selectedItem:g,selectedItemText:y,focusSelectedItem:b}=i,S=m.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&x&&g&&y){const E=s.trigger.getBoundingClientRect(),A=u.getBoundingClientRect(),j=s.valueNode.getBoundingClientRect(),P=y.getBoundingClientRect();if(s.dir!=="rtl"){const pe=P.left-A.left,ie=j.left-pe,me=E.left-ie,et=E.width+me,tt=Math.max(et,A.width),Me=window.innerWidth-hn,We=ol(ie,[hn,Math.max(hn,Me-tt)]);a.style.minWidth=et+"px",a.style.left=We+"px"}else{const pe=A.right-P.right,ie=window.innerWidth-j.right-pe,me=window.innerWidth-E.right-ie,et=E.width+me,tt=Math.max(et,A.width),Me=window.innerWidth-hn,We=ol(ie,[hn,Math.max(hn,Me-tt)]);a.style.minWidth=et+"px",a.style.right=We+"px"}const D=h(),L=window.innerHeight-hn*2,V=x.scrollHeight,M=window.getComputedStyle(u),G=parseInt(M.borderTopWidth,10),K=parseInt(M.paddingTop,10),U=parseInt(M.borderBottomWidth,10),z=parseInt(M.paddingBottom,10),F=G+K+V+z+U,de=Math.min(g.offsetHeight*5,F),$=window.getComputedStyle(x),te=parseInt($.paddingTop,10),he=parseInt($.paddingBottom,10),ve=E.top+E.height/2-hn,be=L-ve,we=g.offsetHeight/2,q=g.offsetTop+we,O=G+K+q,Z=F-O;if(O<=ve){const pe=D.length>0&&g===D[D.length-1].ref.current;a.style.bottom="0px";const ie=u.clientHeight-x.offsetTop-x.offsetHeight,me=Math.max(be,we+(pe?he:0)+ie+U),et=O+me;a.style.height=et+"px"}else{const pe=D.length>0&&g===D[0].ref.current;a.style.top="0px";const me=Math.max(ve,G+x.offsetTop+(pe?te:0)+we)+Z;a.style.height=me+"px",x.scrollTop=O-ve+x.offsetTop}a.style.margin=`${hn}px 0`,a.style.minHeight=de+"px",a.style.maxHeight=L+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,u,x,g,y,s.dir,r]);Tt(()=>S(),[S]);const[I,C]=m.useState();Tt(()=>{u&&C(window.getComputedStyle(u).zIndex)},[u]);const T=m.useCallback(E=>{E&&v.current===!0&&(S(),b==null||b(),v.current=!1)},[S,b]);return c.jsx(JC,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:T,children:c.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:I},children:c.jsx(_e.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Mp.displayName=YC;var XC="SelectPopperPosition",ul=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=hn,...s}=e,i=ai(n);return c.jsx(Wf,{...i,...s,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});ul.displayName=XC;var[JC,dl]=Vr(wr,{}),fl="SelectViewport",Dp=m.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=er(fl,n),i=dl(fl,n),a=qe(t,s.onViewportChange),l=m.useRef(0);return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),c.jsx(si.Slot,{scope:n,children:c.jsx(_e.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:fe(o.onScroll,u=>{const d=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const p=Math.abs(l.current-d.scrollTop);if(p>0){const v=window.innerHeight-hn*2,x=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),y=Math.max(x,g);if(y<v){const b=y+p,S=Math.min(v,b),I=b-S;f.style.height=S+"px",f.style.bottom==="0px"&&(d.scrollTop=I>0?I:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Dp.displayName=fl;var Lp="SelectGroup",[ZC,QC]=Vr(Lp),eT=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Cn();return c.jsx(ZC,{scope:n,id:o,children:c.jsx(_e.div,{role:"group","aria-labelledby":o,...r,ref:t})})});eT.displayName=Lp;var $p="SelectLabel",Fp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=QC($p,n);return c.jsx(_e.div,{id:o.id,...r,ref:t})});Fp.displayName=$p;var li="SelectItem",[tT,zp]=Vr(li),Bp=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Qn(li,n),l=er(li,n),u=a.value===r,[d,f]=m.useState(s??""),[h,p]=m.useState(!1),v=qe(t,b=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,b,r,o)}),x=Cn(),g=m.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return c.jsx(tT,{scope:n,value:r,disabled:o,textId:x,isSelected:u,onItemTextChange:m.useCallback(b=>{f(S=>S||((b==null?void 0:b.textContent)??"").trim())},[]),children:c.jsx(si.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:c.jsx(_e.div,{role:"option","aria-labelledby":x,"data-highlighted":h?"":void 0,"aria-selected":u&&h,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:v,onFocus:fe(i.onFocus,()=>p(!0)),onBlur:fe(i.onBlur,()=>p(!1)),onClick:fe(i.onClick,()=>{g.current!=="mouse"&&y()}),onPointerUp:fe(i.onPointerUp,()=>{g.current==="mouse"&&y()}),onPointerDown:fe(i.onPointerDown,b=>{g.current=b.pointerType}),onPointerMove:fe(i.onPointerMove,b=>{var S;g.current=b.pointerType,o?(S=l.onItemLeave)==null||S.call(l):g.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:fe(i.onPointerLeave,b=>{var S;b.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:fe(i.onKeyDown,b=>{var I;((I=l.searchRef)==null?void 0:I.current)!==""&&b.key===" "||(zC.includes(b.key)&&y(),b.key===" "&&b.preventDefault())})})})})});Bp.displayName=li;var Io="SelectItemText",Hp=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Qn(Io,n),a=er(Io,n),l=zp(Io,n),u=WC(Io,n),[d,f]=m.useState(null),h=qe(t,y=>f(y),l.onItemTextChange,y=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,y,l.value,l.disabled)}),p=d==null?void 0:d.textContent,v=m.useMemo(()=>c.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:x,onNativeOptionRemove:g}=u;return Tt(()=>(x(v),()=>g(v)),[x,g,v]),c.jsxs(c.Fragment,{children:[c.jsx(_e.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?jo.createPortal(s.children,i.valueNode):null]})});Hp.displayName=Io;var Up="SelectItemIndicator",Wp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return zp(Up,n).isSelected?c.jsx(_e.span,{"aria-hidden":!0,...r,ref:t}):null});Wp.displayName=Up;var hl="SelectScrollUpButton",Vp=m.forwardRef((e,t)=>{const n=er(hl,e.__scopeSelect),r=dl(hl,e.__scopeSelect),[o,s]=m.useState(!1),i=qe(t,r.onScrollButtonChange);return Tt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollTop>0;s(u)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(qp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Vp.displayName=hl;var pl="SelectScrollDownButton",Kp=m.forwardRef((e,t)=>{const n=er(pl,e.__scopeSelect),r=dl(pl,e.__scopeSelect),[o,s]=m.useState(!1),i=qe(t,r.onScrollButtonChange);return Tt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<u;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(qp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Kp.displayName=pl;var qp=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=er("SelectScrollButton",n),i=m.useRef(null),a=ii(n),l=m.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return m.useEffect(()=>()=>l(),[l]),Tt(()=>{var d;const u=a().find(f=>f.ref.current===document.activeElement);(d=u==null?void 0:u.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),c.jsx(_e.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:fe(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:fe(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:fe(o.onPointerLeave,()=>{l()})})}),nT="SelectSeparator",Gp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return c.jsx(_e.div,{"aria-hidden":!0,...r,ref:t})});Gp.displayName=nT;var ml="SelectArrow",rT=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ai(n),s=Qn(ml,n),i=er(ml,n);return s.open&&i.position==="popper"?c.jsx(Vf,{...o,...r,ref:t}):null});rT.displayName=ml;var oT="SelectBubbleInput",Yp=m.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=m.useRef(null),s=qe(r,o),i=xp(t);return m.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),c.jsx(_e.select,{...n,style:{...Tp,...n.style},ref:s,defaultValue:t})});Yp.displayName=oT;function Xp(e){return e===""||e===void 0}function Jp(e){const t=Et(e),n=m.useRef(""),r=m.useRef(0),o=m.useCallback(i=>{const a=n.current+i;t(a),function l(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=m.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Zp(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=sT(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function sT(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var iT=kp,Qp=Ip,aT=Ap,lT=_p,cT=jp,em=Rp,uT=Dp,tm=Fp,nm=Bp,dT=Hp,fT=Wp,rm=Vp,om=Kp,sm=Gp;const im=iT,am=aT,gl=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Qp,{ref:r,className:ee("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,c.jsx(lT,{asChild:!0,children:c.jsx(le.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));gl.displayName=Qp.displayName;const lm=m.forwardRef(({className:e,...t},n)=>c.jsx(rm,{ref:n,className:ee("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(le.ChevronUp,{className:"h-4 w-4"})}));lm.displayName=rm.displayName;const cm=m.forwardRef(({className:e,...t},n)=>c.jsx(om,{ref:n,className:ee("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(le.ChevronDown,{className:"h-4 w-4"})}));cm.displayName=om.displayName;const xl=m.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>c.jsx(cT,{children:c.jsxs(em,{ref:o,className:ee("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[c.jsx(lm,{}),c.jsx(uT,{className:ee("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),c.jsx(cm,{})]})}));xl.displayName=em.displayName;const hT=m.forwardRef(({className:e,...t},n)=>c.jsx(tm,{ref:n,className:ee("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));hT.displayName=tm.displayName;const Sr=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(nm,{ref:r,className:ee("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(fT,{children:c.jsx(le.Check,{className:"h-4 w-4"})})}),c.jsx(dT,{children:t})]}));Sr.displayName=nm.displayName;const pT=m.forwardRef(({className:e,...t},n)=>c.jsx(sm,{ref:n,className:ee("-mx-1 my-1 h-px bg-muted",e),...t}));pT.displayName=sm.displayName;var mT="Separator",um="horizontal",gT=["horizontal","vertical"],dm=m.forwardRef((e,t)=>{const{decorative:n,orientation:r=um,...o}=e,s=xT(r)?r:um,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return c.jsx(_e.div,{"data-orientation":s,...a,...o,ref:t})});dm.displayName=mT;function xT(e){return gT.includes(e)}var fm=dm;const hm=m.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>c.jsx(fm,{ref:o,decorative:n,orientation:t,className:ee("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));hm.displayName=fm.displayName;const yT=Yd,vT=Zb,bT=Xd,pm=m.forwardRef(({className:e,...t},n)=>c.jsx(_s,{className:ee("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));pm.displayName=_s.displayName;const wT=_o.cva("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),mm=m.forwardRef(({side:e="right",className:t,children:n,...r},o)=>c.jsxs(bT,{children:[c.jsx(pm,{}),c.jsxs(js,{ref:o,className:ee(wT({side:e}),t),...r,children:[n,c.jsxs(Jd,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[c.jsx(le.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));mm.displayName=js.displayName;const gm=({className:e,...t})=>c.jsx("div",{className:ee("flex flex-col space-y-2 text-center sm:text-left",e),...t});gm.displayName="SheetHeader";const xm=m.forwardRef(({className:e,...t},n)=>c.jsx(mr,{ref:n,className:ee("text-lg font-semibold text-foreground",e),...t}));xm.displayName=mr.displayName;const ym=m.forwardRef(({className:e,...t},n)=>c.jsx(Rs,{ref:n,className:ee("text-sm text-muted-foreground",e),...t}));ym.displayName=Rs.displayName;const ST={api:{baseUrl:"http://localhost:8000/api",authToken:"",enableAuth:!1},ui:{layout:"sidebar",theme:"light",showTimestamps:!0,showAgentNames:!0,compactMessages:!1},behavior:{autoSave:!0,enableStreaming:!0,showTypingIndicator:!0}};function CT({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=w.useState(!1),[s,i]=w.useState(!1),[a,l]=w.useState(e),[u,d]=w.useState(!1),{toast:f}=ga();w.useEffect(()=>{const g=JSON.stringify(a)!==JSON.stringify(e);d(g)},[a,e]),w.useEffect(()=>{l(e)},[e]);const h=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},p=()=>{l(ST),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},v=()=>{l(e),d(!1),o(!1)},x=async()=>{try{const y=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${y.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return c.jsxs(yT,{open:r,onOpenChange:o,children:[c.jsx(vT,{asChild:!0,children:c.jsxs(Je,{variant:"outline",size:"sm",className:n,children:[c.jsx(le.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&c.jsx(ia,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),c.jsxs(mm,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[c.jsxs(gm,{children:[c.jsx(xm,{children:"Chat Settings"}),c.jsx(ym,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),c.jsxs("div",{className:"space-y-6 py-6",children:[c.jsxs(ho,{children:[c.jsx(po,{className:"pb-3",children:c.jsxs(mo,{className:"text-lg flex items-center gap-2",children:[c.jsx(le.Server,{className:"h-5 w-5"}),"API Configuration"]})}),c.jsxs(us,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Qt,{htmlFor:"api-url",children:"API Base URL"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Qs,{id:"api-url",value:a.api.baseUrl,onChange:g=>l(y=>({...y,api:{...y.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),c.jsx(Je,{variant:"outline",onClick:x,children:"Test"})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Qt,{htmlFor:"enable-auth",children:"Enable Authentication"}),c.jsx(Zn,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>l(y=>({...y,api:{...y.api,enableAuth:g}}))})]}),a.api.enableAuth&&c.jsxs("div",{className:"space-y-2",children:[c.jsx(Qt,{htmlFor:"auth-token",children:"Authentication Token"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Qs,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>l(y=>({...y,api:{...y.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),c.jsx(Je,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?c.jsx(le.EyeOff,{className:"h-4 w-4"}):c.jsx(le.Eye,{className:"h-4 w-4"})})]})]})]})]}),c.jsxs(ho,{children:[c.jsx(po,{className:"pb-3",children:c.jsxs(mo,{className:"text-lg flex items-center gap-2",children:[c.jsx(le.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),c.jsxs(us,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Qt,{htmlFor:"layout",children:"Layout Style"}),c.jsxs(im,{value:a.ui.layout,onValueChange:g=>l(y=>({...y,ui:{...y.ui,layout:g}})),children:[c.jsx(gl,{children:c.jsx(am,{})}),c.jsxs(xl,{children:[c.jsx(Sr,{value:"sidebar",children:"Sidebar Layout"}),c.jsx(Sr,{value:"fullscreen",children:"Fullscreen"}),c.jsx(Sr,{value:"tabs",children:"Tabbed Interface"})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Qt,{htmlFor:"theme",children:"Theme"}),c.jsxs(im,{value:a.ui.theme,onValueChange:g=>l(y=>({...y,ui:{...y.ui,theme:g}})),children:[c.jsx(gl,{children:c.jsx(am,{})}),c.jsxs(xl,{children:[c.jsx(Sr,{value:"light",children:"Light"}),c.jsx(Sr,{value:"dark",children:"Dark"}),c.jsx(Sr,{value:"system",children:"System"})]})]})]}),c.jsx(hm,{}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Qt,{htmlFor:"show-timestamps",children:"Show Timestamps"}),c.jsx(Zn,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>l(y=>({...y,ui:{...y.ui,showTimestamps:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Qt,{htmlFor:"show-agent-names",children:"Show Agent Names"}),c.jsx(Zn,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>l(y=>({...y,ui:{...y.ui,showAgentNames:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Qt,{htmlFor:"compact-messages",children:"Compact Messages"}),c.jsx(Zn,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>l(y=>({...y,ui:{...y.ui,compactMessages:g}}))})]})]})]})]}),c.jsxs(ho,{children:[c.jsx(po,{className:"pb-3",children:c.jsxs(mo,{className:"text-lg flex items-center gap-2",children:[c.jsx(le.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),c.jsxs(us,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Qt,{htmlFor:"auto-save",children:"Auto-save Conversations"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),c.jsx(Zn,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:g=>l(y=>({...y,behavior:{...y.behavior,autoSave:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Qt,{htmlFor:"enable-streaming",children:"Enable Streaming"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),c.jsx(Zn,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:g=>l(y=>({...y,behavior:{...y.behavior,enableStreaming:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Qt,{htmlFor:"typing-indicator",children:"Typing Indicator"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),c.jsx(Zn,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:g=>l(y=>({...y,behavior:{...y.behavior,showTypingIndicator:g}}))})]})]})]})]}),c.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[c.jsxs(Je,{variant:"outline",onClick:p,children:[c.jsx(le.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Je,{variant:"outline",onClick:v,children:"Cancel"}),c.jsxs(Je,{onClick:h,disabled:!u,children:[c.jsx(le.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function TT({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=u=>{const d="h-full";switch(u){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=u=>({"--chat-sidebar-width":u==="phone"?"100%":u==="tablet"?"280px":u==="half-screen"?"240px":"320px","--chat-message-max-width":u==="phone"?"95%":u==="tablet"?"90%":u==="half-screen"?"85%":"80%","--chat-input-height":u==="phone"?"120px":"100px"}),l=w.useCallback(u=>{var d;(d=s.onThreadChange)==null||d.call(s,u)},[s]);return e==="fullscreen"?c.jsx(Go,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsx(Zs,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?c.jsx(Go,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&c.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(cl,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),c.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:c.jsx(Zs,{onError:s.onError,enableFileUpload:!0})})]})})}):c.jsx(Go,{...s,onThreadChange:l,children:c.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&c.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(cl,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),c.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:c.jsx(Zs,{onError:s.onError,enableFileUpload:!0})})]})})}Re.ChatApi=mc,Re.ChatInterface=Zs,Re.ChatProviders=Go,Re.ChatSettings=CT,Re.MarkdownContent=ha,Re.MessageComponent=af,Re.MessageList=Ra,Re.ThreadManager=cl,Re.applySettings=AC,Re.chatApiClient=Hn,Re.default=TT,Re.del=pc,Re.get=sn,Re.getChatToken=dc,Re.getCurrentSettings=NC,Re.getDefaultApiConfig=fp,Re.getDefaultChatSettings=hp,Re.onChatTokenChanged=fc,Re.post=Ti,Re.put=hc,Re.setChatToken=Ci,Re.useApi=ki,Re.useChatStream=jc,Re.useMessagesReducer=Sc,Re.useStream=Fc,Re.useThreadState=qo,Re.useThreads=Ko,Object.defineProperties(Re,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
140
+ `).trim():n.replace(/</g,"&lt;").replace(/>/g,"&gt;").trim()}function gw(e,t=Os){if(!e||typeof e!="string")throw new Error("Invalid content: must be a non-empty string");if(e.length>t)throw new Error(`Message exceeds maximum length of ${t} characters`);return e}function xw(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),gw(t),mw(t)}function Pa(e){const t=e+"CollectionProvider",[n,r]=Sn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=x=>{const{scope:g,children:y}=x,b=w.useRef(null),S=w.useRef(new Map).current;return c.jsx(o,{scope:g,itemMap:S,collectionRef:b,children:y})};i.displayName=t;const a=e+"CollectionSlot",l=rr.createSlot(a),u=w.forwardRef((x,g)=>{const{scope:y,children:b}=x,S=s(a,y),I=qe(g,S.collectionRef);return c.jsx(l,{ref:I,children:b})});u.displayName=a;const d=e+"CollectionItemSlot",f="data-radix-collection-item",h=rr.createSlot(d),p=w.forwardRef((x,g)=>{const{scope:y,children:b,...S}=x,I=w.useRef(null),C=qe(g,I),T=s(d,y);return w.useEffect(()=>(T.itemMap.set(I,{ref:I,...S}),()=>void T.itemMap.delete(I))),c.jsx(h,{[f]:"",ref:C,children:b})});p.displayName=d;function v(x){const g=s(e+"CollectionConsumer",x);return w.useCallback(()=>{const b=g.collectionRef.current;if(!b)return[];const S=Array.from(b.querySelectorAll(`[${f}]`));return Array.from(g.itemMap.values()).sort((T,E)=>S.indexOf(T.ref.current)-S.indexOf(E.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:u,ItemSlot:p},v,r]}var yw=m.createContext(void 0);function Ms(e){const t=m.useContext(yw);return e||t||"ltr"}const vw=["top","right","bottom","left"],Xn=Math.min,Vt=Math.max,Ds=Math.round,Ls=Math.floor,kn=e=>({x:e,y:e}),bw={left:"right",right:"left",bottom:"top",top:"bottom"},ww={start:"end",end:"start"};function Oa(e,t,n){return Vt(e,Xn(t,n))}function $n(e,t){return typeof e=="function"?e(t):e}function Fn(e){return e.split("-")[0]}function Fr(e){return e.split("-")[1]}function Ma(e){return e==="x"?"y":"x"}function Da(e){return e==="y"?"height":"width"}const Sw=new Set(["top","bottom"]);function En(e){return Sw.has(Fn(e))?"y":"x"}function La(e){return Ma(En(e))}function Cw(e,t,n){n===void 0&&(n=!1);const r=Fr(e),o=La(e),s=Da(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=$s(i)),[i,$s(i)]}function Tw(e){const t=$s(e);return[$a(e),t,$a(t)]}function $a(e){return e.replace(/start|end/g,t=>ww[t])}const cf=["left","right"],uf=["right","left"],kw=["top","bottom"],Ew=["bottom","top"];function Iw(e,t,n){switch(e){case"top":case"bottom":return n?t?uf:cf:t?cf:uf;case"left":case"right":return t?kw:Ew;default:return[]}}function Nw(e,t,n,r){const o=Fr(e);let s=Iw(Fn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map($a)))),s}function $s(e){return e.replace(/left|right|bottom|top/g,t=>bw[t])}function Aw(e){return{top:0,right:0,bottom:0,left:0,...e}}function df(e){return typeof e!="number"?Aw(e):{top:e,right:e,bottom:e,left:e}}function Fs(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function ff(e,t,n){let{reference:r,floating:o}=e;const s=En(t),i=La(t),a=Da(i),l=Fn(t),u=s==="y",d=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,h=r[a]/2-o[a]/2;let p;switch(l){case"top":p={x:d,y:r.y-o.height};break;case"bottom":p={x:d,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:f};break;case"left":p={x:r.x-o.width,y:f};break;default:p={x:r.x,y:r.y}}switch(Fr(t)){case"start":p[i]-=h*(n&&u?-1:1);break;case"end":p[i]+=h*(n&&u?-1:1);break}return p}const _w=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),l=await(i.isRTL==null?void 0:i.isRTL(t));let u=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:d,y:f}=ff(u,r,l),h=r,p={},v=0;for(let x=0;x<a.length;x++){const{name:g,fn:y}=a[x],{x:b,y:S,data:I,reset:C}=await y({x:d,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:u,platform:i,elements:{reference:e,floating:t}});d=b??d,f=S??f,p={...p,[g]:{...p[g],...I}},C&&v<=50&&(v++,typeof C=="object"&&(C.placement&&(h=C.placement),C.rects&&(u=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:d,y:f}=ff(u,h,l)),x=-1)}return{x:d,y:f,placement:h,strategy:o,middlewareData:p}};async function yo(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=$n(t,e),v=df(p),g=a[h?f==="floating"?"reference":"floating":f],y=Fs(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(g)))==null||n?g:g.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:d,strategy:l})),b=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),I=await(s.isElement==null?void 0:s.isElement(S))?await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1}:{x:1,y:1},C=Fs(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:b,offsetParent:S,strategy:l}):b);return{top:(y.top-C.top+v.top)/I.y,bottom:(C.bottom-y.bottom+v.bottom)/I.y,left:(y.left-C.left+v.left)/I.x,right:(C.right-y.right+v.right)/I.x}}const jw=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=t,{element:u,padding:d=0}=$n(e,t)||{};if(u==null)return{};const f=df(d),h={x:n,y:r},p=La(o),v=Da(p),x=await i.getDimensions(u),g=p==="y",y=g?"top":"left",b=g?"bottom":"right",S=g?"clientHeight":"clientWidth",I=s.reference[v]+s.reference[p]-h[p]-s.floating[v],C=h[p]-s.reference[p],T=await(i.getOffsetParent==null?void 0:i.getOffsetParent(u));let E=T?T[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(T)))&&(E=a.floating[S]||s.floating[v]);const A=I/2-C/2,j=E/2-x[v]/2-1,P=Xn(f[y],j),D=Xn(f[b],j),L=P,V=E-x[v]-D,M=E/2-x[v]/2+A,G=Oa(L,M,V),K=!l.arrow&&Fr(o)!=null&&M!==G&&s.reference[v]/2-(M<L?P:D)-x[v]/2<0,U=K?M<L?M-L:M-V:0;return{[p]:h[p]+U,data:{[p]:G,centerOffset:M-G-U,...K&&{alignmentOffset:U}},reset:K}}}),Rw=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:u}=t,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:x=!0,...g}=$n(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const y=Fn(o),b=En(a),S=Fn(a)===a,I=await(l.isRTL==null?void 0:l.isRTL(u.floating)),C=h||(S||!x?[$s(a)]:Tw(a)),T=v!=="none";!h&&T&&C.push(...Nw(a,x,v,I));const E=[a,...C],A=await yo(t,g),j=[];let P=((r=s.flip)==null?void 0:r.overflows)||[];if(d&&j.push(A[y]),f){const M=Cw(o,i,I);j.push(A[M[0]],A[M[1]])}if(P=[...P,{placement:o,overflows:j}],!j.every(M=>M<=0)){var D,L;const M=(((D=s.flip)==null?void 0:D.index)||0)+1,G=E[M];if(G&&(!(f==="alignment"?b!==En(G):!1)||P.every(z=>En(z.placement)===b?z.overflows[0]>0:!0)))return{data:{index:M,overflows:P},reset:{placement:G}};let K=(L=P.filter(U=>U.overflows[0]<=0).sort((U,z)=>U.overflows[1]-z.overflows[1])[0])==null?void 0:L.placement;if(!K)switch(p){case"bestFit":{var V;const U=(V=P.filter(z=>{if(T){const F=En(z.placement);return F===b||F==="y"}return!0}).map(z=>[z.placement,z.overflows.filter(F=>F>0).reduce((F,de)=>F+de,0)]).sort((z,F)=>z[1]-F[1])[0])==null?void 0:V[0];U&&(K=U);break}case"initialPlacement":K=a;break}if(o!==K)return{reset:{placement:K}}}return{}}}};function hf(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function pf(e){return vw.some(t=>e[t]>=0)}const Pw=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=$n(e,t);switch(r){case"referenceHidden":{const s=await yo(t,{...o,elementContext:"reference"}),i=hf(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:pf(i)}}}case"escaped":{const s=await yo(t,{...o,altBoundary:!0}),i=hf(s,n.floating);return{data:{escapedOffsets:i,escaped:pf(i)}}}default:return{}}}}},mf=new Set(["left","top"]);async function Ow(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Fn(n),a=Fr(n),l=En(n)==="y",u=mf.has(i)?-1:1,d=s&&l?-1:1,f=$n(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:v}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof v=="number"&&(p=a==="end"?v*-1:v),l?{x:p*d,y:h*u}:{x:h*u,y:p*d}}const Mw=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=t,l=await Ow(t,e);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},Dw=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o}=t,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:g=>{let{x:y,y:b}=g;return{x:y,y:b}}},...l}=$n(e,t),u={x:n,y:r},d=await yo(t,l),f=En(Fn(o)),h=Ma(f);let p=u[h],v=u[f];if(s){const g=h==="y"?"top":"left",y=h==="y"?"bottom":"right",b=p+d[g],S=p-d[y];p=Oa(b,p,S)}if(i){const g=f==="y"?"top":"left",y=f==="y"?"bottom":"right",b=v+d[g],S=v-d[y];v=Oa(b,v,S)}const x=a.fn({...t,[h]:p,[f]:v});return{...x,data:{x:x.x-n,y:x.y-r,enabled:{[h]:s,[f]:i}}}}}},Lw=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=t,{offset:a=0,mainAxis:l=!0,crossAxis:u=!0}=$n(e,t),d={x:n,y:r},f=En(o),h=Ma(f);let p=d[h],v=d[f];const x=$n(a,t),g=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(l){const S=h==="y"?"height":"width",I=s.reference[h]-s.floating[S]+g.mainAxis,C=s.reference[h]+s.reference[S]-g.mainAxis;p<I?p=I:p>C&&(p=C)}if(u){var y,b;const S=h==="y"?"width":"height",I=mf.has(Fn(o)),C=s.reference[f]-s.floating[S]+(I&&((y=i.offset)==null?void 0:y[f])||0)+(I?0:g.crossAxis),T=s.reference[f]+s.reference[S]+(I?0:((b=i.offset)==null?void 0:b[f])||0)-(I?g.crossAxis:0);v<C?v=C:v>T&&(v=T)}return{[h]:p,[f]:v}}}},$w=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:s,platform:i,elements:a}=t,{apply:l=()=>{},...u}=$n(e,t),d=await yo(t,u),f=Fn(o),h=Fr(o),p=En(o)==="y",{width:v,height:x}=s.floating;let g,y;f==="top"||f==="bottom"?(g=f,y=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(y=f,g=h==="end"?"top":"bottom");const b=x-d.top-d.bottom,S=v-d.left-d.right,I=Xn(x-d[g],b),C=Xn(v-d[y],S),T=!t.middlewareData.shift;let E=I,A=C;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=b),T&&!h){const P=Vt(d.left,0),D=Vt(d.right,0),L=Vt(d.top,0),V=Vt(d.bottom,0);p?A=v-2*(P!==0||D!==0?P+D:Vt(d.left,d.right)):E=x-2*(L!==0||V!==0?L+V:Vt(d.top,d.bottom))}await l({...t,availableWidth:A,availableHeight:E});const j=await i.getDimensions(a.floating);return v!==j.width||x!==j.height?{reset:{rects:!0}}:{}}}};function zs(){return typeof window<"u"}function zr(e){return gf(e)?(e.nodeName||"").toLowerCase():"#document"}function Kt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function In(e){var t;return(t=(gf(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function gf(e){return zs()?e instanceof Node||e instanceof Kt(e).Node:!1}function dn(e){return zs()?e instanceof Element||e instanceof Kt(e).Element:!1}function Nn(e){return zs()?e instanceof HTMLElement||e instanceof Kt(e).HTMLElement:!1}function xf(e){return!zs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Kt(e).ShadowRoot}const Fw=new Set(["inline","contents"]);function vo(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=fn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!Fw.has(o)}const zw=new Set(["table","td","th"]);function Bw(e){return zw.has(zr(e))}const Hw=[":popover-open",":modal"];function Bs(e){return Hw.some(t=>{try{return e.matches(t)}catch{return!1}})}const Uw=["transform","translate","scale","rotate","perspective"],Ww=["transform","translate","scale","rotate","perspective","filter"],Vw=["paint","layout","strict","content"];function Fa(e){const t=za(),n=dn(e)?fn(e):e;return Uw.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||Ww.some(r=>(n.willChange||"").includes(r))||Vw.some(r=>(n.contain||"").includes(r))}function Kw(e){let t=Jn(e);for(;Nn(t)&&!Br(t);){if(Fa(t))return t;if(Bs(t))return null;t=Jn(t)}return null}function za(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const qw=new Set(["html","body","#document"]);function Br(e){return qw.has(zr(e))}function fn(e){return Kt(e).getComputedStyle(e)}function Hs(e){return dn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Jn(e){if(zr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||xf(e)&&e.host||In(e);return xf(t)?t.host:t}function yf(e){const t=Jn(e);return Br(t)?e.ownerDocument?e.ownerDocument.body:e.body:Nn(t)&&vo(t)?t:yf(t)}function bo(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=yf(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=Kt(o);if(s){const a=Ba(i);return t.concat(i,i.visualViewport||[],vo(o)?o:[],a&&n?bo(a):[])}return t.concat(o,bo(o,[],n))}function Ba(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function vf(e){const t=fn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Nn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Ds(n)!==s||Ds(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Ha(e){return dn(e)?e:e.contextElement}function Hr(e){const t=Ha(e);if(!Nn(t))return kn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=vf(t);let i=(s?Ds(n.width):n.width)/r,a=(s?Ds(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const Gw=kn(0);function bf(e){const t=Kt(e);return!za()||!t.visualViewport?Gw:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Yw(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Kt(e)?!1:t}function xr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=Ha(e);let i=kn(1);t&&(r?dn(r)&&(i=Hr(r)):i=Hr(e));const a=Yw(s,n,r)?bf(s):kn(0);let l=(o.left+a.x)/i.x,u=(o.top+a.y)/i.y,d=o.width/i.x,f=o.height/i.y;if(s){const h=Kt(s),p=r&&dn(r)?Kt(r):r;let v=h,x=Ba(v);for(;x&&r&&p!==v;){const g=Hr(x),y=x.getBoundingClientRect(),b=fn(x),S=y.left+(x.clientLeft+parseFloat(b.paddingLeft))*g.x,I=y.top+(x.clientTop+parseFloat(b.paddingTop))*g.y;l*=g.x,u*=g.y,d*=g.x,f*=g.y,l+=S,u+=I,v=Kt(x),x=Ba(v)}}return Fs({width:d,height:f,x:l,y:u})}function Us(e,t){const n=Hs(e).scrollLeft;return t?t.left+n:xr(In(e)).left+n}function wf(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Us(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Xw(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=In(r),a=t?Bs(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},u=kn(1);const d=kn(0),f=Nn(r);if((f||!f&&!s)&&((zr(r)!=="body"||vo(i))&&(l=Hs(r)),Nn(r))){const p=xr(r);u=Hr(r),d.x=p.x+r.clientLeft,d.y=p.y+r.clientTop}const h=i&&!f&&!s?wf(i,l):kn(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+d.x+h.x,y:n.y*u.y-l.scrollTop*u.y+d.y+h.y}}function Jw(e){return Array.from(e.getClientRects())}function Zw(e){const t=In(e),n=Hs(e),r=e.ownerDocument.body,o=Vt(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Vt(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Us(e);const a=-n.scrollTop;return fn(r).direction==="rtl"&&(i+=Vt(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const Sf=25;function Qw(e,t){const n=Kt(e),r=In(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const d=za();(!d||d&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const u=Us(r);if(u<=0){const d=r.ownerDocument,f=d.body,h=getComputedStyle(f),p=d.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,v=Math.abs(r.clientWidth-f.clientWidth-p);v<=Sf&&(s-=v)}else u<=Sf&&(s+=u);return{width:s,height:i,x:a,y:l}}const e0=new Set(["absolute","fixed"]);function t0(e,t){const n=xr(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Nn(e)?Hr(e):kn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,u=r*s.y;return{width:i,height:a,x:l,y:u}}function Cf(e,t,n){let r;if(t==="viewport")r=Qw(e,n);else if(t==="document")r=Zw(In(e));else if(dn(t))r=t0(t,n);else{const o=bf(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Fs(r)}function Tf(e,t){const n=Jn(e);return n===t||!dn(n)||Br(n)?!1:fn(n).position==="fixed"||Tf(n,t)}function n0(e,t){const n=t.get(e);if(n)return n;let r=bo(e,[],!1).filter(a=>dn(a)&&zr(a)!=="body"),o=null;const s=fn(e).position==="fixed";let i=s?Jn(e):e;for(;dn(i)&&!Br(i);){const a=fn(i),l=Fa(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&e0.has(o.position)||vo(i)&&!l&&Tf(e,i))?r=r.filter(d=>d!==i):o=a,i=Jn(i)}return t.set(e,r),r}function r0(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?Bs(t)?[]:n0(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((u,d)=>{const f=Cf(t,d,o);return u.top=Vt(f.top,u.top),u.right=Xn(f.right,u.right),u.bottom=Xn(f.bottom,u.bottom),u.left=Vt(f.left,u.left),u},Cf(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function o0(e){const{width:t,height:n}=vf(e);return{width:t,height:n}}function s0(e,t,n){const r=Nn(t),o=In(t),s=n==="fixed",i=xr(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=kn(0);function u(){l.x=Us(o)}if(r||!r&&!s)if((zr(t)!=="body"||vo(o))&&(a=Hs(t)),r){const p=xr(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&u();s&&!r&&o&&u();const d=o&&!r&&!s?wf(o,a):kn(0),f=i.left+a.scrollLeft-l.x-d.x,h=i.top+a.scrollTop-l.y-d.y;return{x:f,y:h,width:i.width,height:i.height}}function Ua(e){return fn(e).position==="static"}function kf(e,t){if(!Nn(e)||fn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return In(e)===n&&(n=n.ownerDocument.body),n}function Ef(e,t){const n=Kt(e);if(Bs(e))return n;if(!Nn(e)){let o=Jn(e);for(;o&&!Br(o);){if(dn(o)&&!Ua(o))return o;o=Jn(o)}return n}let r=kf(e,t);for(;r&&Bw(r)&&Ua(r);)r=kf(r,t);return r&&Br(r)&&Ua(r)&&!Fa(r)?n:r||Kw(e)||n}const i0=async function(e){const t=this.getOffsetParent||Ef,n=this.getDimensions,r=await n(e.floating);return{reference:s0(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function a0(e){return fn(e).direction==="rtl"}const l0={convertOffsetParentRelativeRectToViewportRelativeRect:Xw,getDocumentElement:In,getClippingRect:r0,getOffsetParent:Ef,getElementRects:i0,getClientRects:Jw,getDimensions:o0,getScale:Hr,isElement:dn,isRTL:a0};function If(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function c0(e,t){let n=null,r;const o=In(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const u=e.getBoundingClientRect(),{left:d,top:f,width:h,height:p}=u;if(a||t(),!h||!p)return;const v=Ls(f),x=Ls(o.clientWidth-(d+h)),g=Ls(o.clientHeight-(f+p)),y=Ls(d),S={rootMargin:-v+"px "+-x+"px "+-g+"px "+-y+"px",threshold:Vt(0,Xn(1,l))||1};let I=!0;function C(T){const E=T[0].intersectionRatio;if(E!==l){if(!I)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!If(u,e.getBoundingClientRect())&&i(),I=!1}try{n=new IntersectionObserver(C,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(C,S)}n.observe(e)}return i(!0),s}function u0(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,u=Ha(e),d=o||s?[...u?bo(u):[],...bo(t)]:[];d.forEach(y=>{o&&y.addEventListener("scroll",n,{passive:!0}),s&&y.addEventListener("resize",n)});const f=u&&a?c0(u,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(y=>{let[b]=y;b&&b.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var S;(S=p)==null||S.observe(t)})),n()}),u&&!l&&p.observe(u),p.observe(t));let v,x=l?xr(e):null;l&&g();function g(){const y=xr(e);x&&!If(x,y)&&n(),x=y,v=requestAnimationFrame(g)}return n(),()=>{var y;d.forEach(b=>{o&&b.removeEventListener("scroll",n),s&&b.removeEventListener("resize",n)}),f==null||f(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(v)}}const d0=Mw,f0=Dw,h0=Rw,p0=$w,m0=Pw,Nf=jw,g0=Lw,x0=(e,t,n)=>{const r=new Map,o={platform:l0,...n},s={...o.platform,_c:r};return _w(e,t,{...o,platform:s})};var y0=typeof document<"u",v0=function(){},Ws=y0?w.useLayoutEffect:v0;function Vs(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,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Vs(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&e.$$typeof)&&!Vs(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Af(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function _f(e,t){const n=Af(e);return Math.round(t*n)/n}function Wa(e){const t=m.useRef(e);return Ws(()=>{t.current=e}),t}function b0(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:u}=e,[d,f]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=m.useState(r);Vs(h,r)||p(r);const[v,x]=m.useState(null),[g,y]=m.useState(null),b=m.useCallback(z=>{z!==T.current&&(T.current=z,x(z))},[]),S=m.useCallback(z=>{z!==E.current&&(E.current=z,y(z))},[]),I=s||v,C=i||g,T=m.useRef(null),E=m.useRef(null),A=m.useRef(d),j=l!=null,P=Wa(l),D=Wa(o),L=Wa(u),V=m.useCallback(()=>{if(!T.current||!E.current)return;const z={placement:t,strategy:n,middleware:h};D.current&&(z.platform=D.current),x0(T.current,E.current,z).then(F=>{const de={...F,isPositioned:L.current!==!1};M.current&&!Vs(A.current,de)&&(A.current=de,jo.flushSync(()=>{f(de)}))})},[h,t,n,D,L]);Ws(()=>{u===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,f(z=>({...z,isPositioned:!1})))},[u]);const M=m.useRef(!1);Ws(()=>(M.current=!0,()=>{M.current=!1}),[]),Ws(()=>{if(I&&(T.current=I),C&&(E.current=C),I&&C){if(P.current)return P.current(I,C,V);V()}},[I,C,V,P,j]);const G=m.useMemo(()=>({reference:T,floating:E,setReference:b,setFloating:S}),[b,S]),K=m.useMemo(()=>({reference:I,floating:C}),[I,C]),U=m.useMemo(()=>{const z={position:n,left:0,top:0};if(!K.floating)return z;const F=_f(K.floating,d.x),de=_f(K.floating,d.y);return a?{...z,transform:"translate("+F+"px, "+de+"px)",...Af(K.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:F,top:de}},[n,a,K.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:V,refs:G,elements:K,floatingStyles:U}),[d,V,G,K,U])}const w0=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?Nf({element:r.current,padding:o}).fn(n):{}:r?Nf({element:r,padding:o}).fn(n):{}}}},S0=(e,t)=>({...d0(e),options:[e,t]}),C0=(e,t)=>({...f0(e),options:[e,t]}),T0=(e,t)=>({...g0(e),options:[e,t]}),k0=(e,t)=>({...h0(e),options:[e,t]}),E0=(e,t)=>({...p0(e),options:[e,t]}),I0=(e,t)=>({...m0(e),options:[e,t]}),N0=(e,t)=>({...w0(e),options:[e,t]});var A0="Arrow",jf=m.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return c.jsx(_e.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:c.jsx("polygon",{points:"0,0 30,0 15,10"})})});jf.displayName=A0;var _0=jf;function Rf(e){const[t,n]=m.useState(void 0);return Tt(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,u=Array.isArray(l)?l[0]:l;i=u.inlineSize,a=u.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var Va="Popper",[Pf,Ks]=Sn(Va),[j0,Of]=Pf(Va),Mf=e=>{const{__scopePopper:t,children:n}=e,[r,o]=m.useState(null);return c.jsx(j0,{scope:t,anchor:r,onAnchorChange:o,children:n})};Mf.displayName=Va;var Df="PopperAnchor",Lf=m.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Of(Df,n),i=m.useRef(null),a=qe(t,i),l=m.useRef(null);return m.useEffect(()=>{const u=l.current;l.current=(r==null?void 0:r.current)||i.current,u!==l.current&&s.onAnchorChange(l.current)}),r?null:c.jsx(_e.div,{...o,ref:a})});Lf.displayName=Df;var Ka="PopperContent",[R0,P0]=Pf(Ka),$f=m.forwardRef((e,t)=>{var q,O,Z,ne,pe,ie;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:d=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:v,...x}=e,g=Of(Ka,n),[y,b]=m.useState(null),S=qe(t,me=>b(me)),[I,C]=m.useState(null),T=Rf(I),E=(T==null?void 0:T.width)??0,A=(T==null?void 0:T.height)??0,j=r+(s!=="center"?"-"+s:""),P=typeof d=="number"?d:{top:0,right:0,bottom:0,left:0,...d},D=Array.isArray(u)?u:[u],L=D.length>0,V={padding:P,boundary:D.filter(M0),altBoundary:L},{refs:M,floatingStyles:G,placement:K,isPositioned:U,middlewareData:z}=b0({strategy:"fixed",placement:j,whileElementsMounted:(...me)=>u0(...me,{animationFrame:p==="always"}),elements:{reference:g.anchor},middleware:[S0({mainAxis:o+A,alignmentAxis:i}),l&&C0({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?T0():void 0,...V}),l&&k0({...V}),E0({...V,apply:({elements:me,rects:et,availableWidth:tt,availableHeight:Me})=>{const{width:We,height:ut}=et.reference,nt=me.floating.style;nt.setProperty("--radix-popper-available-width",`${tt}px`),nt.setProperty("--radix-popper-available-height",`${Me}px`),nt.setProperty("--radix-popper-anchor-width",`${We}px`),nt.setProperty("--radix-popper-anchor-height",`${ut}px`)}}),I&&N0({element:I,padding:a}),D0({arrowWidth:E,arrowHeight:A}),h&&I0({strategy:"referenceHidden",...V})]}),[F,de]=Bf(K),$=Et(v);Tt(()=>{U&&($==null||$())},[U,$]);const te=(q=z.arrow)==null?void 0:q.x,he=(O=z.arrow)==null?void 0:O.y,ve=((Z=z.arrow)==null?void 0:Z.centerOffset)!==0,[be,we]=m.useState();return Tt(()=>{y&&we(window.getComputedStyle(y).zIndex)},[y]),c.jsx("div",{ref:M.setFloating,"data-radix-popper-content-wrapper":"",style:{...G,transform:U?G.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:be,"--radix-popper-transform-origin":[(ne=z.transformOrigin)==null?void 0:ne.x,(pe=z.transformOrigin)==null?void 0:pe.y].join(" "),...((ie=z.hide)==null?void 0:ie.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:c.jsx(R0,{scope:n,placedSide:F,onArrowChange:C,arrowX:te,arrowY:he,shouldHideArrow:ve,children:c.jsx(_e.div,{"data-side":F,"data-align":de,...x,ref:S,style:{...x.style,animation:U?void 0:"none"}})})})});$f.displayName=Ka;var Ff="PopperArrow",O0={top:"bottom",right:"left",bottom:"top",left:"right"},zf=m.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=P0(Ff,r),i=O0[s.placedSide];return c.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:c.jsx(_0,{...o,ref:n,style:{...o.style,display:"block"}})})});zf.displayName=Ff;function M0(e){return e!==null}var D0=e=>({name:"transformOrigin",options:e,fn(t){var g,y,b;const{placement:n,rects:r,middlewareData:o}=t,i=((g=o.arrow)==null?void 0:g.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[u,d]=Bf(n),f={start:"0%",center:"50%",end:"100%"}[d],h=(((y=o.arrow)==null?void 0:y.x)??0)+a/2,p=(((b=o.arrow)==null?void 0:b.y)??0)+l/2;let v="",x="";return u==="bottom"?(v=i?f:`${h}px`,x=`${-l}px`):u==="top"?(v=i?f:`${h}px`,x=`${r.floating.height+l}px`):u==="right"?(v=`${-l}px`,x=i?f:`${p}px`):u==="left"&&(v=`${r.floating.width+l}px`,x=i?f:`${p}px`),{data:{x:v,y:x}}}});function Bf(e){const[t,n="center"]=e.split("-");return[t,n]}var Hf=Mf,Uf=Lf,Wf=$f,Vf=zf,qa="rovingFocusGroup.onEntryFocus",L0={bubbles:!1,cancelable:!0},wo="RovingFocusGroup",[Ga,Kf,$0]=Pa(wo),[F0,qf]=Sn(wo,[$0]),[z0,B0]=F0(wo),Gf=m.forwardRef((e,t)=>c.jsx(Ga.Provider,{scope:e.__scopeRovingFocusGroup,children:c.jsx(Ga.Slot,{scope:e.__scopeRovingFocusGroup,children:c.jsx(H0,{...e,ref:t})})}));Gf.displayName=wo;var H0=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:d=!1,...f}=e,h=m.useRef(null),p=qe(t,h),v=Ms(s),[x,g]=fr({prop:i,defaultProp:a??null,onChange:l,caller:wo}),[y,b]=m.useState(!1),S=Et(u),I=Kf(n),C=m.useRef(!1),[T,E]=m.useState(0);return m.useEffect(()=>{const A=h.current;if(A)return A.addEventListener(qa,S),()=>A.removeEventListener(qa,S)},[S]),c.jsx(z0,{scope:n,orientation:r,dir:v,loop:o,currentTabStopId:x,onItemFocus:m.useCallback(A=>g(A),[g]),onItemShiftTab:m.useCallback(()=>b(!0),[]),onFocusableItemAdd:m.useCallback(()=>E(A=>A+1),[]),onFocusableItemRemove:m.useCallback(()=>E(A=>A-1),[]),children:c.jsx(_e.div,{tabIndex:y||T===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:fe(e.onMouseDown,()=>{C.current=!0}),onFocus:fe(e.onFocus,A=>{const j=!C.current;if(A.target===A.currentTarget&&j&&!y){const P=new CustomEvent(qa,L0);if(A.currentTarget.dispatchEvent(P),!P.defaultPrevented){const D=I().filter(K=>K.focusable),L=D.find(K=>K.active),V=D.find(K=>K.id===x),G=[L,V,...D].filter(Boolean).map(K=>K.ref.current);Jf(G,d)}}C.current=!1}),onBlur:fe(e.onBlur,()=>b(!1))})})}),Yf="RovingFocusGroupItem",Xf=m.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=Cn(),u=s||l,d=B0(Yf,n),f=d.currentTabStopId===u,h=Kf(n),{onFocusableItemAdd:p,onFocusableItemRemove:v,currentTabStopId:x}=d;return m.useEffect(()=>{if(r)return p(),()=>v()},[r,p,v]),c.jsx(Ga.ItemSlot,{scope:n,id:u,focusable:r,active:o,children:c.jsx(_e.span,{tabIndex:f?0:-1,"data-orientation":d.orientation,...a,ref:t,onMouseDown:fe(e.onMouseDown,g=>{r?d.onItemFocus(u):g.preventDefault()}),onFocus:fe(e.onFocus,()=>d.onItemFocus(u)),onKeyDown:fe(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){d.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const y=V0(g,d.orientation,d.dir);if(y!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let S=h().filter(I=>I.focusable).map(I=>I.ref.current);if(y==="last")S.reverse();else if(y==="prev"||y==="next"){y==="prev"&&S.reverse();const I=S.indexOf(g.currentTarget);S=d.loop?K0(S,I+1):S.slice(I+1)}setTimeout(()=>Jf(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:x!=null}):i})})});Xf.displayName=Yf;var U0={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function W0(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function V0(e,t,n){const r=W0(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return U0[r]}function Jf(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function K0(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var q0=Gf,G0=Xf,Ya=["Enter"," "],Y0=["ArrowDown","PageUp","Home"],Zf=["ArrowUp","PageDown","End"],X0=[...Y0,...Zf],J0={ltr:[...Ya,"ArrowRight"],rtl:[...Ya,"ArrowLeft"]},Z0={ltr:["ArrowLeft"],rtl:["ArrowRight"]},So="Menu",[Co,Q0,eS]=Pa(So),[yr,Qf]=Sn(So,[eS,Ks,qf]),qs=Ks(),eh=qf(),[tS,vr]=yr(So),[nS,To]=yr(So),th=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=qs(t),[l,u]=m.useState(null),d=m.useRef(!1),f=Et(s),h=Ms(o);return m.useEffect(()=>{const p=()=>{d.current=!0,document.addEventListener("pointerdown",v,{capture:!0,once:!0}),document.addEventListener("pointermove",v,{capture:!0,once:!0})},v=()=>d.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",v,{capture:!0}),document.removeEventListener("pointermove",v,{capture:!0})}},[]),c.jsx(Hf,{...a,children:c.jsx(tS,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:u,children:c.jsx(nS,{scope:t,onClose:m.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:d,dir:h,modal:i,children:r})})})};th.displayName=So;var rS="MenuAnchor",Xa=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=qs(n);return c.jsx(Uf,{...o,...r,ref:t})});Xa.displayName=rS;var Ja="MenuPortal",[oS,nh]=yr(Ja,{forceMount:void 0}),rh=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=vr(Ja,t);return c.jsx(oS,{scope:t,forceMount:n,children:c.jsx(Wt,{present:n||s.open,children:c.jsx(vs,{asChild:!0,container:o,children:r})})})};rh.displayName=Ja;var Jt="MenuContent",[sS,Za]=yr(Jt),oh=m.forwardRef((e,t)=>{const n=nh(Jt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=vr(Jt,e.__scopeMenu),i=To(Jt,e.__scopeMenu);return c.jsx(Co.Provider,{scope:e.__scopeMenu,children:c.jsx(Wt,{present:r||s.open,children:c.jsx(Co.Slot,{scope:e.__scopeMenu,children:i.modal?c.jsx(iS,{...o,ref:t}):c.jsx(aS,{...o,ref:t})})})})}),iS=m.forwardRef((e,t)=>{const n=vr(Jt,e.__scopeMenu),r=m.useRef(null),o=qe(t,r);return m.useEffect(()=>{const s=r.current;if(s)return Ia(s)},[]),c.jsx(Qa,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:fe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),aS=m.forwardRef((e,t)=>{const n=vr(Jt,e.__scopeMenu);return c.jsx(Qa,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),lS=rr.createSlot("MenuContent.ScrollLock"),Qa=m.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,disableOutsideScroll:v,...x}=e,g=vr(Jt,n),y=To(Jt,n),b=qs(n),S=eh(n),I=Q0(n),[C,T]=m.useState(null),E=m.useRef(null),A=qe(t,E,g.onContentChange),j=m.useRef(0),P=m.useRef(""),D=m.useRef(0),L=m.useRef(null),V=m.useRef("right"),M=m.useRef(0),G=v?ks:m.Fragment,K=v?{as:lS,allowPinchZoom:!0}:void 0,U=F=>{var q,O;const de=P.current+F,$=I().filter(Z=>!Z.disabled),te=document.activeElement,he=(q=$.find(Z=>Z.ref.current===te))==null?void 0:q.textValue,ve=$.map(Z=>Z.textValue),be=bS(ve,de,he),we=(O=$.find(Z=>Z.textValue===be))==null?void 0:O.ref.current;(function Z(ne){P.current=ne,window.clearTimeout(j.current),ne!==""&&(j.current=window.setTimeout(()=>Z(""),1e3))})(de),we&&setTimeout(()=>we.focus())};m.useEffect(()=>()=>window.clearTimeout(j.current),[]),wa();const z=m.useCallback(F=>{var $,te;return V.current===(($=L.current)==null?void 0:$.side)&&SS(F,(te=L.current)==null?void 0:te.area)},[]);return c.jsx(sS,{scope:n,searchRef:P,onItemEnter:m.useCallback(F=>{z(F)&&F.preventDefault()},[z]),onItemLeave:m.useCallback(F=>{var de;z(F)||((de=E.current)==null||de.focus(),T(null))},[z]),onTriggerLeave:m.useCallback(F=>{z(F)&&F.preventDefault()},[z]),pointerGraceTimerRef:D,onPointerGraceIntentChange:m.useCallback(F=>{L.current=F},[]),children:c.jsx(G,{...K,children:c.jsx(ys,{asChild:!0,trapped:o,onMountAutoFocus:fe(s,F=>{var de;F.preventDefault(),(de=E.current)==null||de.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:c.jsx(xs,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,onDismiss:p,children:c.jsx(q0,{asChild:!0,...S,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:T,onEntryFocus:fe(l,F=>{y.isUsingKeyboardRef.current||F.preventDefault()}),preventScrollOnEntryFocus:!0,children:c.jsx(Wf,{role:"menu","aria-orientation":"vertical","data-state":wh(g.open),"data-radix-menu-content":"",dir:y.dir,...b,...x,ref:A,style:{outline:"none",...x.style},onKeyDown:fe(x.onKeyDown,F=>{const $=F.target.closest("[data-radix-menu-content]")===F.currentTarget,te=F.ctrlKey||F.altKey||F.metaKey,he=F.key.length===1;$&&(F.key==="Tab"&&F.preventDefault(),!te&&he&&U(F.key));const ve=E.current;if(F.target!==ve||!X0.includes(F.key))return;F.preventDefault();const we=I().filter(q=>!q.disabled).map(q=>q.ref.current);Zf.includes(F.key)&&we.reverse(),yS(we)}),onBlur:fe(e.onBlur,F=>{F.currentTarget.contains(F.target)||(window.clearTimeout(j.current),P.current="")}),onPointerMove:fe(e.onPointerMove,Eo(F=>{const de=F.target,$=M.current!==F.clientX;if(F.currentTarget.contains(de)&&$){const te=F.clientX>M.current?"right":"left";V.current=te,M.current=F.clientX}}))})})})})})})});oh.displayName=Jt;var cS="MenuGroup",el=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(_e.div,{role:"group",...r,ref:t})});el.displayName=cS;var uS="MenuLabel",sh=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(_e.div,{...r,ref:t})});sh.displayName=uS;var Gs="MenuItem",ih="menu.itemSelect",Ys=m.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=m.useRef(null),i=To(Gs,e.__scopeMenu),a=Za(Gs,e.__scopeMenu),l=qe(t,s),u=m.useRef(!1),d=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(ih,{bubbles:!0,cancelable:!0});f.addEventListener(ih,p=>r==null?void 0:r(p),{once:!0}),zu(f,h),h.defaultPrevented?u.current=!1:i.onClose()}};return c.jsx(ah,{...o,ref:l,disabled:n,onClick:fe(e.onClick,d),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),u.current=!0},onPointerUp:fe(e.onPointerUp,f=>{var h;u.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:fe(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||Ya.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});Ys.displayName=Gs;var ah=m.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=Za(Gs,n),a=eh(n),l=m.useRef(null),u=qe(t,l),[d,f]=m.useState(!1),[h,p]=m.useState("");return m.useEffect(()=>{const v=l.current;v&&p((v.textContent??"").trim())},[s.children]),c.jsx(Co.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:c.jsx(G0,{asChild:!0,...a,focusable:!r,children:c.jsx(_e.div,{role:"menuitem","data-highlighted":d?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:u,onPointerMove:fe(e.onPointerMove,Eo(v=>{r?i.onItemLeave(v):(i.onItemEnter(v),v.defaultPrevented||v.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:fe(e.onPointerLeave,Eo(v=>i.onItemLeave(v))),onFocus:fe(e.onFocus,()=>f(!0)),onBlur:fe(e.onBlur,()=>f(!1))})})})}),dS="MenuCheckboxItem",lh=m.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return c.jsx(hh,{scope:e.__scopeMenu,checked:n,children:c.jsx(Ys,{role:"menuitemcheckbox","aria-checked":Xs(n)?"mixed":n,...o,ref:t,"data-state":nl(n),onSelect:fe(o.onSelect,()=>r==null?void 0:r(Xs(n)?!0:!n),{checkForDefaultPrevented:!1})})})});lh.displayName=dS;var ch="MenuRadioGroup",[fS,hS]=yr(ch,{value:void 0,onValueChange:()=>{}}),uh=m.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=Et(r);return c.jsx(fS,{scope:e.__scopeMenu,value:n,onValueChange:s,children:c.jsx(el,{...o,ref:t})})});uh.displayName=ch;var dh="MenuRadioItem",fh=m.forwardRef((e,t)=>{const{value:n,...r}=e,o=hS(dh,e.__scopeMenu),s=n===o.value;return c.jsx(hh,{scope:e.__scopeMenu,checked:s,children:c.jsx(Ys,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":nl(s),onSelect:fe(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});fh.displayName=dh;var tl="MenuItemIndicator",[hh,pS]=yr(tl,{checked:!1}),ph=m.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=pS(tl,n);return c.jsx(Wt,{present:r||Xs(s.checked)||s.checked===!0,children:c.jsx(_e.span,{...o,ref:t,"data-state":nl(s.checked)})})});ph.displayName=tl;var mS="MenuSeparator",mh=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return c.jsx(_e.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});mh.displayName=mS;var gS="MenuArrow",gh=m.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=qs(n);return c.jsx(Vf,{...o,...r,ref:t})});gh.displayName=gS;var xS="MenuSub",[ek,xh]=yr(xS),ko="MenuSubTrigger",yh=m.forwardRef((e,t)=>{const n=vr(ko,e.__scopeMenu),r=To(ko,e.__scopeMenu),o=xh(ko,e.__scopeMenu),s=Za(ko,e.__scopeMenu),i=m.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,u={__scopeMenu:e.__scopeMenu},d=m.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return m.useEffect(()=>d,[d]),m.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),c.jsx(Xa,{asChild:!0,...u,children:c.jsx(ah,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":wh(n.open),...e,ref:aa(t,o.onTriggerChange),onClick:f=>{var h;(h=e.onClick)==null||h.call(e,f),!(e.disabled||f.defaultPrevented)&&(f.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:fe(e.onPointerMove,Eo(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),d()},100))})),onPointerLeave:fe(e.onPointerLeave,Eo(f=>{var p,v;d();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const x=(v=n.content)==null?void 0:v.dataset.side,g=x==="right",y=g?-5:5,b=h[g?"left":"right"],S=h[g?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+y,y:f.clientY},{x:b,y:h.top},{x:S,y:h.top},{x:S,y:h.bottom},{x:b,y:h.bottom}],side:x}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:fe(e.onKeyDown,f=>{var p;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||J0[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});yh.displayName=ko;var vh="MenuSubContent",bh=m.forwardRef((e,t)=>{const n=nh(Jt,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=vr(Jt,e.__scopeMenu),i=To(Jt,e.__scopeMenu),a=xh(vh,e.__scopeMenu),l=m.useRef(null),u=qe(t,l);return c.jsx(Co.Provider,{scope:e.__scopeMenu,children:c.jsx(Wt,{present:r||s.open,children:c.jsx(Co.Slot,{scope:e.__scopeMenu,children:c.jsx(Qa,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:u,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:d=>{var f;i.isUsingKeyboardRef.current&&((f=l.current)==null||f.focus()),d.preventDefault()},onCloseAutoFocus:d=>d.preventDefault(),onFocusOutside:fe(e.onFocusOutside,d=>{d.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:fe(e.onEscapeKeyDown,d=>{i.onClose(),d.preventDefault()}),onKeyDown:fe(e.onKeyDown,d=>{var p;const f=d.currentTarget.contains(d.target),h=Z0[i.dir].includes(d.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),d.preventDefault())})})})})})});bh.displayName=vh;function wh(e){return e?"open":"closed"}function Xs(e){return e==="indeterminate"}function nl(e){return Xs(e)?"indeterminate":e?"checked":"unchecked"}function yS(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function vS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function bS(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=vS(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function wS(e,t){const{x:n,y:r}=e;let o=!1;for(let s=0,i=t.length-1;s<t.length;i=s++){const a=t[s],l=t[i],u=a.x,d=a.y,f=l.x,h=l.y;d>r!=h>r&&n<(f-u)*(r-d)/(h-d)+u&&(o=!o)}return o}function SS(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return wS(n,t)}function Eo(e){return t=>t.pointerType==="mouse"?e(t):void 0}var CS=th,TS=Xa,kS=rh,ES=oh,IS=el,NS=sh,AS=Ys,_S=lh,jS=uh,RS=fh,PS=ph,OS=mh,MS=gh,DS=yh,LS=bh,Js="DropdownMenu",[$S,tk]=Sn(Js,[Qf]),Mt=Qf(),[FS,Sh]=$S(Js),Ch=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Mt(t),u=m.useRef(null),[d,f]=fr({prop:o,defaultProp:s??!1,onChange:i,caller:Js});return c.jsx(FS,{scope:t,triggerId:Cn(),triggerRef:u,contentId:Cn(),open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(h=>!h),[f]),modal:a,children:c.jsx(CS,{...l,open:d,onOpenChange:f,dir:r,modal:a,children:n})})};Ch.displayName=Js;var Th="DropdownMenuTrigger",kh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=Sh(Th,n),i=Mt(n);return c.jsx(TS,{asChild:!0,...i,children:c.jsx(_e.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:aa(t,s.triggerRef),onPointerDown:fe(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:fe(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});kh.displayName=Th;var zS="DropdownMenuPortal",Eh=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Mt(t);return c.jsx(kS,{...r,...n})};Eh.displayName=zS;var Ih="DropdownMenuContent",Nh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Sh(Ih,n),s=Mt(n),i=m.useRef(!1);return c.jsx(ES,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:fe(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:fe(e.onInteractOutside,a=>{const l=a.detail.originalEvent,u=l.button===0&&l.ctrlKey===!0,d=l.button===2||u;(!o.modal||d)&&(i.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Nh.displayName=Ih;var BS="DropdownMenuGroup",HS=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mt(n);return c.jsx(IS,{...o,...r,ref:t})});HS.displayName=BS;var US="DropdownMenuLabel",Ah=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mt(n);return c.jsx(NS,{...o,...r,ref:t})});Ah.displayName=US;var WS="DropdownMenuItem",_h=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mt(n);return c.jsx(AS,{...o,...r,ref:t})});_h.displayName=WS;var VS="DropdownMenuCheckboxItem",jh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mt(n);return c.jsx(_S,{...o,...r,ref:t})});jh.displayName=VS;var KS="DropdownMenuRadioGroup",qS=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mt(n);return c.jsx(jS,{...o,...r,ref:t})});qS.displayName=KS;var GS="DropdownMenuRadioItem",Rh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mt(n);return c.jsx(RS,{...o,...r,ref:t})});Rh.displayName=GS;var YS="DropdownMenuItemIndicator",Ph=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mt(n);return c.jsx(PS,{...o,...r,ref:t})});Ph.displayName=YS;var XS="DropdownMenuSeparator",Oh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mt(n);return c.jsx(OS,{...o,...r,ref:t})});Oh.displayName=XS;var JS="DropdownMenuArrow",ZS=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mt(n);return c.jsx(MS,{...o,...r,ref:t})});ZS.displayName=JS;var QS="DropdownMenuSubTrigger",Mh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mt(n);return c.jsx(DS,{...o,...r,ref:t})});Mh.displayName=QS;var eC="DropdownMenuSubContent",Dh=m.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Mt(n);return c.jsx(LS,{...o,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Dh.displayName=eC;var tC=Ch,nC=kh,rC=Eh,Lh=Nh,$h=Ah,Fh=_h,zh=jh,Bh=Rh,Hh=Ph,Uh=Oh,Wh=Mh,Vh=Dh;const oC=tC,sC=nC,iC=m.forwardRef(({className:e,inset:t,children:n,...r},o)=>c.jsxs(Wh,{ref:o,className:ee("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...r,children:[n,c.jsx(le.ChevronRight,{className:"ml-auto h-4 w-4"})]}));iC.displayName=Wh.displayName;const aC=m.forwardRef(({className:e,...t},n)=>c.jsx(Vh,{ref:n,className:ee("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));aC.displayName=Vh.displayName;const Kh=m.forwardRef(({className:e,sideOffset:t=4,...n},r)=>c.jsx(rC,{children:c.jsx(Lh,{ref:r,sideOffset:t,className:ee("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...n})}));Kh.displayName=Lh.displayName;const rl=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx(Fh,{ref:r,className:ee("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));rl.displayName=Fh.displayName;const lC=m.forwardRef(({className:e,children:t,checked:n,...r},o)=>c.jsxs(zh,{ref:o,className:ee("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:n,...r,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Hh,{children:c.jsx(le.Check,{className:"h-4 w-4"})})}),t]}));lC.displayName=zh.displayName;const cC=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Bh,{ref:r,className:ee("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(Hh,{children:c.jsx(le.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));cC.displayName=Bh.displayName;const uC=m.forwardRef(({className:e,inset:t,...n},r)=>c.jsx($h,{ref:r,className:ee("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));uC.displayName=$h.displayName;const dC=m.forwardRef(({className:e,...t},n)=>c.jsx(Uh,{ref:n,className:ee("-mx-1 my-1 h-px bg-muted",e),...t}));dC.displayName=Uh.displayName;function Zs({className:e="",placeholder:t="Type your message...",autoFocus:n=!0,maxHeight:r=void 0,streamingDebounceMs:o=500,streamingThrottleMs:s,followNewMessages:i=!0,enableFileUpload:a=!0,enableExcelUpload:l=!1,enableMessageEditing:u=!0,customStyles:d={},onMessageSent:f,onExcelUploadSuccess:h,onError:p}){const{api:v}=ki(),{currentThreadId:x}=Ko(),{threadId:g,messages:y,hasMore:b,isHistoryLoading:S,isLoading:I,loadOlder:C,listCheckpoints:T,navigateToCheckpoint:E,returnToLatest:A,checkpoint:j,respondToInterrupt:P,metadata:D}=qo(),{isStreaming:L,error:V,submit:M,stop:G}=Fc(),K=g??x??null,U=(j==null?void 0:j.id)??null,z=(j==null?void 0:j.namespace)??null,F=(D==null?void 0:D.assemblingMessageId)??null,[de,$]=w.useState(null),[te,he]=w.useState(""),[ve,be]=w.useState(null),[we,q]=w.useState([]),[O,Z]=w.useState(0),[ne,pe]=w.useState(0),[ie,me]=w.useState(!1),[et,tt]=w.useState(null),[Me,We]=w.useState(null),[ut,nt]=w.useState(!1),[Ve,yt]=w.useState(null),[Q,ae]=w.useState([]),[ge,Se]=w.useState(null),[xe,Oe]=w.useState(null),[at,De]=w.useState(!1),st=w.useRef(null),ft=w.useRef(null),It=w.useRef(null),_n=w.useCallback(()=>{st.current&&(st.current.value=""),ft.current&&(ft.current.value=""),Z(se=>se+1),pe(se=>se+1)},[]),pn=w.useRef(!1);w.useEffect(()=>{pn.current&&!L&&(q([]),_n()),pn.current=L},[L,_n]);const[en,jn]=w.useState("desktop");w.useEffect(()=>{const se=()=>{const Ce=window.innerWidth;jn(Ce<640?"phone":Ce<1024?"tablet":"desktop")};return se(),window.addEventListener("resize",se),()=>window.removeEventListener("resize",se)},[]),w.useEffect(()=>{let se=!1;if(!K){ae([]),Se(null),Oe(null),It.current=null;return}const Ce={threadId:K,checkpointId:U??null,checkpointNs:z??null},Ke=It.current;if(!(Ke&&Ke.threadId===Ce.threadId&&Ke.checkpointId===Ce.checkpointId&&Ke.checkpointNs===Ce.checkpointNs))return T(K).then(it=>{var Ee;if(se)return;const Dt=((it==null?void 0:it.checkpoints)??[]).slice().sort((ze,Xe)=>new Date(Xe.createdAt).getTime()-new Date(ze.createdAt).getTime());ae(Dt);const k=ge,B=k&&Dt.some(ze=>ze.checkpointId===k)?k:((Ee=Dt[0])==null?void 0:Ee.checkpointId)??null;let re=null;if(B){const ze=Dt.find(Xe=>Xe.checkpointId===B);re=(ze==null?void 0:ze.checkpointNs)??null}Se(B),Oe(re),It.current=Ce}).catch(it=>{console.error("ChatInterface - listCheckpoints error:",it),se||(ae([]),It.current=null)}),()=>{se=!0}},[K,U,z,ge,T]),w.useEffect(()=>{U&&(Se(U),Oe(z??null))},[U,z]);const Rn=w.useCallback(async()=>{if(!(!b||S))try{await C()}catch(se){console.warn("loadOlder failed",se)}},[b,S,C]);w.useEffect(()=>{(async()=>{if(!v.baseUrl){yt(null);return}try{const Ce=await v.getAgent("default");yt(Ce.uiDefaultMessage||null)}catch(Ce){console.warn("Failed to fetch default message:",Ce),yt(null)}})()},[v]),w.useEffect(()=>{V&&!ut&&(p==null||p(V))},[V,ut,p]);const tr=se=>{if(se.length>Os)return`Message too long (${se.length}/${Os} characters)`;try{return xw(se),null}catch(Ce){return(Ce==null?void 0:Ce.message)||"Invalid message"}},No=async se=>{const Ce=se.trim();if(!(!Ce&&we.length===0)){if(Ce){const Ke=tr(Ce);if(Ke){be(Ke);return}}try{await M({text:Ce||"",attachments:we,payload:de?{edit:!0,originalMessageId:de}:void 0},{checkpointId:ge??U??void 0,checkpointNs:xe??z??void 0}),f==null||f(Ce),be(null),q([]),_n(),$(null),he("")}catch(Ke){const it=(Ke==null?void 0:Ke.message)||"Failed to send message";be(it),p==null||p(it)}}},mn=w.useCallback((se,Ce)=>{u&&($(se),he(Ce),be(null))},[u]),gn=w.useCallback(()=>{$(null),he(""),be(null)},[]),Nt=w.useCallback((se,Ce)=>{mn(se,Ce)},[mn]),Kr=w.useCallback(se=>{const Ce=Ke=>{const it=Ke.content||[],Dt=it.filter(k=>k.type==="text").map(k=>k.text).join("");if(Dt)return Dt;try{return JSON.stringify(it,null,2)}catch{return String(it)}};for(let Ke=se-1;Ke>=0;Ke--)if(y[Ke].role==="user"){const it=Ce(y[Ke]);it&&M({text:it},{checkpointId:ge??U??void 0,checkpointNs:xe??z??void 0});break}},[y,M,ge,xe,U,z]),Cr=se=>{const Ce=Array.from(se.target.files||[]);q(Ke=>[...Ke,...Ce]),se.target.value=""},wt=se=>{q(Ce=>{const Ke=Ce.filter((it,Dt)=>se!==Dt);return Ke.length===0&&_n(),Ke})},Pn=async se=>{const Ce=(se.target.files||[])[0];if(Ce){tt(null),We(null),me(!0);try{await M({attachments:[Ce]},{checkpointId:ge??U??void 0,checkpointNs:xe??z??void 0});const Ke=`Uploaded ${Ce.name} - processing through chat stream`;We(Ke)}catch(Ke){const it=Ke instanceof Error?Ke.message:"Failed to upload Excel file";console.error("Excel upload failed",Ke),tt(it),p==null||p(it)}finally{me(!1),se.target.value="",_n()}}},On=se=>{if(!se)return"Unknown";const Ce=Date.parse(se);return Number.isNaN(Ce)?se:new Date(Ce).toLocaleString()},Tr=async se=>{if(x){De(!0);try{if(!se){await A(),Se(null),Oe(null);return}const Ce=Q.find(it=>it.checkpointId===se),Ke=(Ce==null?void 0:Ce.checkpointNs)??null;await E(se,Ke),Se(se),Oe(Ke)}finally{De(!1)}}},tn=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${d.container||""}`,kr=`flex-1 min-h-0 min-w-0 max-h-full w-full overflow-hidden overscroll-contain break-words break-anywhere p-4 bg-transparent ${d.messagesArea||""}`,xn=`flex-shrink-0 w-full border-t p-4 bg-transparent ${d.inputArea||""}`;return c.jsxs("div",{className:tn,children:[!!V&&!ut&&c.jsxs("div",{className:"flex-shrink-0 bg-red-50 border border-red-200 text-red-800 px-4 py-2 text-sm flex items-center justify-between",children:[c.jsx("span",{children:V}),c.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>nt(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:c.jsx(le.X,{size:16})})]}),x&&Q.length>0&&c.jsxs("div",{className:"flex-shrink-0 flex items-center gap-2 px-4 py-2 border-b border-border bg-muted/60 text-xs dark:bg-muted/50",children:[c.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),c.jsx("select",{className:"border border-border rounded px-2 py-1 text-xs bg-card text-foreground focus:outline-none focus:ring-1 focus:ring-ring dark:bg-secondary",value:ge??"",onChange:se=>{const Ce=se.target.value||null;Tr(Ce)},children:Q.map(se=>c.jsxs("option",{value:se.checkpointId,children:[On(se.createdAt),se.preview?` — ${se.preview.slice(0,40)}`:""]},se.checkpointId))})]}),c.jsxs("div",{className:`relative ${kr}`,style:r?{maxHeight:r}:void 0,children:[c.jsx(Ra,{className:"h-full",style:{height:"100%"},messages:y,isStreaming:L,streamingAssistantId:F,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:en,enableMessageEditing:u,editingMessageId:de,onStartReached:()=>{Rn()},onEdit:Nt,onRegenerate:Kr,onCancelEdit:gn,emptyMessage:Ve??void 0,isNavigatingCheckpoint:at}),I&&c.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-background/80 backdrop-blur-sm text-muted-foreground",children:[c.jsx(le.Loader2,{className:"h-6 w-6 animate-spin"}),c.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]})]}),c.jsxs("div",{className:xn,children:[de&&c.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(le.Edit3,{size:16,className:"text-blue-600"}),c.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),c.jsx(Je,{variant:"ghost",size:"sm",onClick:gn,className:"text-blue-600 hover:bg-blue-100",children:c.jsx(le.X,{size:16})})]})}),(a||l)&&c.jsxs("div",{className:"mb-3 space-y-3",children:[a&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:st,type:"file",multiple:!0,onChange:se=>Cr(se),className:"hidden"},O),we.length>0&&c.jsx("div",{className:"flex flex-wrap gap-2",children:we.map((se,Ce)=>c.jsxs("div",{className:"flex items-center gap-2 bg-gray-100 dark:bg-gray-800 rounded-lg px-3 py-2 text-sm text-gray-900 dark:text-gray-100",children:[c.jsx(le.Paperclip,{size:14}),c.jsx("span",{className:"truncate max-w-[150px]",children:se.name}),c.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>wt(Ce),className:"h-4 w-4 p-0 text-gray-500 dark:text-gray-400 hover:text-red-500 dark:hover:text-red-400","aria-label":`Remove ${se.name}`,children:c.jsx(le.X,{size:12})})]},Ce))})]}),l&&c.jsxs(c.Fragment,{children:[c.jsx("input",{ref:ft,type:"file",accept:".xls,.xlsx,.xlsm",onChange:Pn,className:"hidden"},ne),ie&&c.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[c.jsx(le.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),Me&&!ie&&c.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:Me}),et&&!ie&&c.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:et})]})]}),ve&&c.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:ve}),c.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&c.jsxs(oC,{children:[c.jsx(sC,{asChild:!0,children:c.jsx(Je,{type:"button",size:"icon",variant:"outline",disabled:L,title:"More input actions",className:d.moreButton||"",children:c.jsx(le.Plus,{size:16})})}),c.jsxs(Kh,{align:"start",sideOffset:6,className:"w-52",children:[a&&c.jsxs(rl,{onClick:()=>{var se;return(se=st.current)==null?void 0:se.click()},className:"cursor-pointer",children:[c.jsx(le.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&c.jsxs(rl,{onClick:()=>{var se;ie||(se=ft.current)==null||se.click()},className:`cursor-pointer ${ie?"opacity-60 pointer-events-none":""}`,children:[c.jsx(le.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),c.jsx("div",{className:"flex-1",children:c.jsx(_x,{initialValue:te,editingMessageId:de,placeholder:de?"Edit your message...":t,isStreaming:L,disabled:!1,maxLength:Os,onSend:No,onCancelEdit:gn,onStop:G,allowEmptySend:we.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${de?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${ve?"border-red-400":""} ${d.textarea||""}`})})]})]})]})}const Qs=m.forwardRef(({className:e,type:t,...n},r)=>c.jsx("input",{type:t,className:ee("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:r,...n}));Qs.displayName="Input";function ol(e,[t,n]){return Math.min(n,Math.max(t,e))}function fC(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var sl="ScrollArea",[qh,nk]=Sn(sl),[hC,Zt]=qh(sl),Gh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=m.useState(null),[u,d]=m.useState(null),[f,h]=m.useState(null),[p,v]=m.useState(null),[x,g]=m.useState(null),[y,b]=m.useState(0),[S,I]=m.useState(0),[C,T]=m.useState(!1),[E,A]=m.useState(!1),j=qe(t,D=>l(D)),P=Ms(o);return c.jsx(hC,{scope:n,type:r,dir:P,scrollHideDelay:s,scrollArea:a,viewport:u,onViewportChange:d,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:v,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:x,onScrollbarYChange:g,scrollbarYEnabled:E,onScrollbarYEnabledChange:A,onCornerWidthChange:b,onCornerHeightChange:I,children:c.jsx(_e.div,{dir:P,...i,ref:j,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});Gh.displayName=sl;var Yh="ScrollAreaViewport",Xh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=Zt(Yh,n),a=m.useRef(null),l=qe(t,a,i.onViewportChange);return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:o}),c.jsx(_e.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:c.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});Xh.displayName=Yh;var An="ScrollAreaScrollbar",il=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Zt(An,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return m.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?c.jsx(pC,{...r,ref:t,forceMount:n}):o.type==="scroll"?c.jsx(mC,{...r,ref:t,forceMount:n}):o.type==="auto"?c.jsx(Jh,{...r,ref:t,forceMount:n}):o.type==="always"?c.jsx(al,{...r,ref:t}):null});il.displayName=An;var pC=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Zt(An,e.__scopeScrollArea),[s,i]=m.useState(!1);return m.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const u=()=>{window.clearTimeout(l),i(!0)},d=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",u),a.addEventListener("pointerleave",d),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",u),a.removeEventListener("pointerleave",d)}}},[o.scrollArea,o.scrollHideDelay]),c.jsx(Wt,{present:n||s,children:c.jsx(Jh,{"data-state":s?"visible":"hidden",...r,ref:t})})}),mC=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Zt(An,e.__scopeScrollArea),s=e.orientation==="horizontal",i=ri(()=>l("SCROLL_END"),100),[a,l]=fC("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return m.useEffect(()=>{if(a==="idle"){const u=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(u)}},[a,o.scrollHideDelay,l]),m.useEffect(()=>{const u=o.viewport,d=s?"scrollLeft":"scrollTop";if(u){let f=u[d];const h=()=>{const p=u[d];f!==p&&(l("SCROLL"),i()),f=p};return u.addEventListener("scroll",h),()=>u.removeEventListener("scroll",h)}},[o.viewport,s,l,i]),c.jsx(Wt,{present:n||a!=="hidden",children:c.jsx(al,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:fe(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:fe(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Jh=m.forwardRef((e,t)=>{const n=Zt(An,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=m.useState(!1),a=e.orientation==="horizontal",l=ri(()=>{if(n.viewport){const u=n.viewport.offsetWidth<n.viewport.scrollWidth,d=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?u:d)}},10);return Ur(n.viewport,l),Ur(n.content,l),c.jsx(Wt,{present:r||s,children:c.jsx(al,{"data-state":s?"visible":"hidden",...o,ref:t})})}),al=m.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=Zt(An,e.__scopeScrollArea),s=m.useRef(null),i=m.useRef(0),[a,l]=m.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=np(a.viewport,a.content),d={...r,sizes:a,onSizesChange:l,hasThumb:u>0&&u<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function f(h,p){return wC(h,i.current,a,p)}return n==="horizontal"?c.jsx(gC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=rp(h,a,o.dir);s.current.style.transform=`translate3d(${p}px, 0, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollLeft=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollLeft=f(h,o.dir))}}):n==="vertical"?c.jsx(xC,{...d,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=rp(h,a);s.current.style.transform=`translate3d(0, ${p}px, 0)`}},onWheelScroll:h=>{o.viewport&&(o.viewport.scrollTop=h)},onDragScroll:h=>{o.viewport&&(o.viewport.scrollTop=f(h))}}):null}),gC=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Zt(An,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=qe(t,l,s.onScrollbarXChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(Qh,{"data-orientation":"horizontal",...o,ref:u,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":ni(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.x),onDragScroll:d=>e.onDragScroll(d.x),onWheelScroll:(d,f)=>{if(s.viewport){const h=s.viewport.scrollLeft+d.deltaX;e.onWheelScroll(h),sp(h,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:ti(i.paddingLeft),paddingEnd:ti(i.paddingRight)}})}})}),xC=m.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=Zt(An,e.__scopeScrollArea),[i,a]=m.useState(),l=m.useRef(null),u=qe(t,l,s.onScrollbarYChange);return m.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),c.jsx(Qh,{"data-orientation":"vertical",...o,ref:u,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":ni(n)+"px",...e.style},onThumbPointerDown:d=>e.onThumbPointerDown(d.y),onDragScroll:d=>e.onDragScroll(d.y),onWheelScroll:(d,f)=>{if(s.viewport){const h=s.viewport.scrollTop+d.deltaY;e.onWheelScroll(h),sp(h,f)&&d.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:ti(i.paddingTop),paddingEnd:ti(i.paddingBottom)}})}})}),[yC,Zh]=qh(An),Qh=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:u,onWheelScroll:d,onResize:f,...h}=e,p=Zt(An,n),[v,x]=m.useState(null),g=qe(t,j=>x(j)),y=m.useRef(null),b=m.useRef(""),S=p.viewport,I=r.content-r.viewport,C=Et(d),T=Et(l),E=ri(f,10);function A(j){if(y.current){const P=j.clientX-y.current.left,D=j.clientY-y.current.top;u({x:P,y:D})}}return m.useEffect(()=>{const j=P=>{const D=P.target;(v==null?void 0:v.contains(D))&&C(P,I)};return document.addEventListener("wheel",j,{passive:!1}),()=>document.removeEventListener("wheel",j,{passive:!1})},[S,v,I,C]),m.useEffect(T,[r,T]),Ur(v,E),Ur(p.content,E),c.jsx(yC,{scope:n,scrollbar:v,hasThumb:o,onThumbChange:Et(s),onThumbPointerUp:Et(i),onThumbPositionChange:T,onThumbPointerDown:Et(a),children:c.jsx(_e.div,{...h,ref:g,style:{position:"absolute",...h.style},onPointerDown:fe(e.onPointerDown,j=>{j.button===0&&(j.target.setPointerCapture(j.pointerId),y.current=v.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),A(j))}),onPointerMove:fe(e.onPointerMove,A),onPointerUp:fe(e.onPointerUp,j=>{const P=j.target;P.hasPointerCapture(j.pointerId)&&P.releasePointerCapture(j.pointerId),document.body.style.webkitUserSelect=b.current,p.viewport&&(p.viewport.style.scrollBehavior=""),y.current=null})})})}),ei="ScrollAreaThumb",ep=m.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=Zh(ei,e.__scopeScrollArea);return c.jsx(Wt,{present:n||o.hasThumb,children:c.jsx(vC,{ref:t,...r})})}),vC=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=Zt(ei,n),i=Zh(ei,n),{onThumbPositionChange:a}=i,l=qe(t,f=>i.onThumbChange(f)),u=m.useRef(void 0),d=ri(()=>{u.current&&(u.current(),u.current=void 0)},100);return m.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(d(),!u.current){const p=SC(f,a);u.current=p,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,d,a]),c.jsx(_e.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:fe(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),v=f.clientX-p.left,x=f.clientY-p.top;i.onThumbPointerDown({x:v,y:x})}),onPointerUp:fe(e.onPointerUp,i.onThumbPointerUp)})});ep.displayName=ei;var ll="ScrollAreaCorner",tp=m.forwardRef((e,t)=>{const n=Zt(ll,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?c.jsx(bC,{...e,ref:t}):null});tp.displayName=ll;var bC=m.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=Zt(ll,n),[s,i]=m.useState(0),[a,l]=m.useState(0),u=!!(s&&a);return Ur(o.scrollbarX,()=>{var f;const d=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(d),l(d)}),Ur(o.scrollbarY,()=>{var f;const d=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(d),i(d)}),u?c.jsx(_e.div,{...r,ref:t,style:{width:s,height:a,position:"absolute",right:o.dir==="ltr"?0:void 0,left:o.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function ti(e){return e?parseInt(e,10):0}function np(e,t){const n=e/t;return isNaN(n)?0:n}function ni(e){const t=np(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function wC(e,t,n,r="ltr"){const o=ni(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,u=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,f=r==="ltr"?[0,d]:[d*-1,0];return op([l,u],f)(e)}function rp(e,t,n="ltr"){const r=ni(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=n==="ltr"?[0,i]:[i*-1,0],u=ol(e,l);return op([0,i],[0,a])(u)}function op(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function sp(e,t){return e>0&&e<t}var SC=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function ri(e,t){const n=Et(e),r=m.useRef(0);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),m.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function Ur(e,t){const n=Et(t);Tt(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,n])}var ip=Gh,CC=Xh,TC=tp;const ap=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(ip,{ref:r,className:ee("relative overflow-hidden",e),...n,children:[c.jsx(CC,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),c.jsx(lp,{}),c.jsx(TC,{})]}));ap.displayName=ip.displayName;const lp=m.forwardRef(({className:e,orientation:t="vertical",...n},r)=>c.jsx(il,{ref:r,orientation:t,className:ee("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:c.jsx(ep,{className:"relative flex-1 rounded-full bg-border"})}));lp.displayName=il.displayName;function cl({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:u,onThreadDelete:d}){const{threads:f,currentThreadId:h,isLoading:p,actions:v}=Ko(),{loadThread:x}=qo(),{createThread:g,deleteThread:y,renameThread:b}=v,[S,I]=w.useState(Array.isArray(f)?f:[]),C=w.useRef(S.length>0),[T,E]=w.useState(null),[A,j]=w.useState(""),[P,D]=w.useState(!1);w.useEffect(()=>{const $=Array.isArray(f)?f:[];if($.length>0){C.current=!0,I($);return}p||(C.current=!1,I($))},[f,p]);const L=async $=>{try{await x($),a==null||a($),l==null||l($)}catch(te){console.error("Failed to select thread:",te)}},V=async()=>{try{D(!0);const $=await g();u==null||u($),a==null||a($)}catch($){console.error("Failed to create thread:",$)}finally{D(!1)}},M=async($,te)=>{if(te.stopPropagation(),!!confirm("Delete this thread?"))try{await y($),d==null||d($)}catch(he){console.error("Failed to delete thread:",he)}},G=($,te)=>{te.stopPropagation(),E($.threadId),j($.title||`Thread ${$.threadId.slice(0,8)}`)},K=async $=>{if(A.trim())try{await b($,A.trim()),E(null),j("")}catch(te){console.error("Failed to update title:",te)}},U=()=>{E(null),j("")},z=($,te)=>{$.key==="Enter"?K(te):$.key==="Escape"&&U()},F=$=>{if(!$)return"";try{const te=new Date($),ve=new Date().getTime()-te.getTime(),be=Math.floor(ve/(1e3*60*60*24));return be===0?te.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):be===1?"Yesterday":be<7?`${be} days ago`:te.toLocaleDateString()}catch{return""}},de=$=>$.title||`Thread ${$.threadId.slice(0,8)}`;return c.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&c.jsx("div",{className:s.header||"flex-shrink-0 p-2 border-b bg-slate-800 border-slate-700 text-slate-100 flex justify-end",children:c.jsx(Je,{onClick:V,disabled:P||p,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:P?"Creating...":"New Chat",children:c.jsx(le.MessageSquarePlus,{size:20})})}),c.jsx(ap,{className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:c.jsx("div",{className:"p-2 space-y-1 pb-4",children:p?c.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[c.jsx(le.Loader2,{className:"h-5 w-5 animate-spin"}),c.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):S.length===0?c.jsxs("div",{className:"text-center py-8 text-slate-400",children:[c.jsx(le.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),c.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):S.slice().sort(($,te)=>new Date(te.updatedAt||te.createdAt||"").getTime()-new Date($.updatedAt||$.createdAt||"").getTime()).map($=>c.jsxs("div",{onClick:()=>L($.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??h)===$.threadId?`${s.activeThread||"bg-slate-600 border-slate-500"} `:`${s.threadItem||"bg-slate-700 border-slate-600 hover:bg-slate-600 text-gray-900 dark:text-slate-100"}`} ${s.threadItem||""} text-gray-900 dark:text-slate-100`,children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"flex-1 min-w-0",children:T===$.threadId?c.jsxs("div",{className:"flex items-center gap-2",onClick:te=>te.stopPropagation(),children:[c.jsx(Qs,{value:A,onChange:te=>j(te.target.value),onKeyDown:te=>z(te,$.threadId),className:"h-6 text-sm",autoFocus:!0}),c.jsx(Je,{variant:"ghost",size:"sm",onClick:()=>K($.threadId),className:"h-6 w-6 p-0",children:c.jsx(le.Check,{size:12})}),c.jsx(Je,{variant:"ghost",size:"sm",onClick:U,className:"h-6 w-6 p-0",children:c.jsx(le.X,{size:12})})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:de($)}),c.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[c.jsx(le.Calendar,{size:10}),c.jsx("span",{children:F($.updatedAt||$.createdAt)})]})]})}),c.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&T!==$.threadId&&c.jsx(Je,{variant:"ghost",size:"sm",onClick:te=>G($,te),className:"h-6 w-6 p-0",title:"Edit title",children:c.jsx(le.Edit3,{size:12})}),n&&c.jsx(Je,{variant:"ghost",size:"sm",onClick:te=>M($.threadId,te),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:c.jsx(le.Trash2,{size:12})})]})]}),i===$.threadId&&c.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},$.threadId))})})]})}function Wr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function kC(e){if(typeof e!="string")return;const t=e.trim();if(t)return Dn(t)}function cp(){const e=[Wr("__API_BASE_URL__"),Wr("__CHAT_API_BASE_URL__"),Wr("__CHAT_API_URL__")];for(const t of e){const n=kC(t);if(n)return n}}function up(){const e=[Wr("__API_AUTH_TOKEN__"),Wr("__CHAT_API_KEY__"),Wr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function dp(...e){for(const t of e)if(typeof t=="string"&&t.trim())return Dn(t);return Dn()}function fp(){const e={},t=cp(),n=up();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function hp(){const e=fp(),t=Hn.getAuthToken(),n=cp();return{apiBaseUrl:dp(e.baseUrl,Hn.baseUrl,n),apiKey:t||e.apiKey||up()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,truncateToolMessages:!0,toolMessagePreviewLength:200,darkMode:!1,enableSound:!1,messageHistory:100}}const pp="chat-settings";function EC(){try{const e=localStorage.getItem(pp);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function IC(e){try{const t={...e,apiBaseUrl:Dn(e.apiBaseUrl)};localStorage.setItem(pp,JSON.stringify(t)),t.apiKey&&Hn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function NC(){const e=hp(),t=EC(),n=Hn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:dp(Hn.baseUrl,r,e.apiBaseUrl)}}function AC(e){Hn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),IC(e)}var _C="Label",mp=m.forwardRef((e,t)=>c.jsx(_e.label,{...e,ref:t,onMouseDown:n=>{var o;n.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));mp.displayName=_C;var gp=mp;const jC=_o.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Qt=m.forwardRef(({className:e,...t},n)=>c.jsx(gp,{ref:n,className:ee(jC(),e),...t}));Qt.displayName=gp.displayName;function xp(e){const t=m.useRef({value:e,previous:e});return m.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var oi="Switch",[RC,rk]=Sn(oi),[PC,OC]=RC(oi),yp=m.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:u,form:d,...f}=e,[h,p]=m.useState(null),v=qe(t,S=>p(S)),x=m.useRef(!1),g=h?d||!!h.closest("form"):!0,[y,b]=fr({prop:o,defaultProp:s??!1,onChange:u,caller:oi});return c.jsxs(PC,{scope:n,checked:y,disabled:a,children:[c.jsx(_e.button,{type:"button",role:"switch","aria-checked":y,"aria-required":i,"data-state":Sp(y),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:v,onClick:fe(e.onClick,S=>{b(I=>!I),g&&(x.current=S.isPropagationStopped(),x.current||S.stopPropagation())})}),g&&c.jsx(wp,{control:h,bubbles:!x.current,name:r,value:l,checked:y,required:i,disabled:a,form:d,style:{transform:"translateX(-100%)"}})]})});yp.displayName=oi;var vp="SwitchThumb",bp=m.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=OC(vp,n);return c.jsx(_e.span,{"data-state":Sp(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});bp.displayName=vp;var MC="SwitchBubbleInput",wp=m.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=m.useRef(null),a=qe(i,s),l=xp(n),u=Rf(t);return m.useEffect(()=>{const d=i.current;if(!d)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const v=new Event("click",{bubbles:r});p.call(d,n),d.dispatchEvent(v)}},[l,n,r]),c.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});wp.displayName=MC;function Sp(e){return e?"checked":"unchecked"}var Cp=yp,DC=bp;const Zn=m.forwardRef(({className:e,...t},n)=>c.jsx(Cp,{className:ee("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:c.jsx(DC,{className:ee("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));Zn.displayName=Cp.displayName;var Tp=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),LC="VisuallyHidden",$C=m.forwardRef((e,t)=>c.jsx(_e.span,{...e,ref:t,style:{...Tp,...e.style}}));$C.displayName=LC;var FC=[" ","Enter","ArrowUp","ArrowDown"],zC=[" ","Enter"],br="Select",[si,ii,BC]=Pa(br),[Vr,ok]=Sn(br,[BC,Ks]),ai=Ks(),[HC,Qn]=Vr(br),[UC,WC]=Vr(br),kp=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:u,name:d,autoComplete:f,disabled:h,required:p,form:v}=e,x=ai(t),[g,y]=m.useState(null),[b,S]=m.useState(null),[I,C]=m.useState(!1),T=Ms(u),[E,A]=fr({prop:r,defaultProp:o??!1,onChange:s,caller:br}),[j,P]=fr({prop:i,defaultProp:a,onChange:l,caller:br}),D=m.useRef(null),L=g?v||!!g.closest("form"):!0,[V,M]=m.useState(new Set),G=Array.from(V).map(K=>K.props.value).join(";");return c.jsx(Hf,{...x,children:c.jsxs(HC,{required:p,scope:t,trigger:g,onTriggerChange:y,valueNode:b,onValueNodeChange:S,valueNodeHasChildren:I,onValueNodeHasChildrenChange:C,contentId:Cn(),value:j,onValueChange:P,open:E,onOpenChange:A,dir:T,triggerPointerDownPosRef:D,disabled:h,children:[c.jsx(si.Provider,{scope:t,children:c.jsx(UC,{scope:e.__scopeSelect,onNativeOptionAdd:m.useCallback(K=>{M(U=>new Set(U).add(K))},[]),onNativeOptionRemove:m.useCallback(K=>{M(U=>{const z=new Set(U);return z.delete(K),z})},[]),children:n})}),L?c.jsxs(Yp,{"aria-hidden":!0,required:p,tabIndex:-1,name:d,autoComplete:f,value:j,onChange:K=>P(K.target.value),disabled:h,form:v,children:[j===void 0?c.jsx("option",{value:""}):null,Array.from(V)]},G):null]})})};kp.displayName=br;var Ep="SelectTrigger",Ip=m.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=ai(n),i=Qn(Ep,n),a=i.disabled||r,l=qe(t,i.onTriggerChange),u=ii(n),d=m.useRef("touch"),[f,h,p]=Jp(x=>{const g=u().filter(S=>!S.disabled),y=g.find(S=>S.value===i.value),b=Zp(g,x,y);b!==void 0&&i.onValueChange(b.value)}),v=x=>{a||(i.onOpenChange(!0),p()),x&&(i.triggerPointerDownPosRef.current={x:Math.round(x.pageX),y:Math.round(x.pageY)})};return c.jsx(Uf,{asChild:!0,...s,children:c.jsx(_e.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":Xp(i.value)?"":void 0,...o,ref:l,onClick:fe(o.onClick,x=>{x.currentTarget.focus(),d.current!=="mouse"&&v(x)}),onPointerDown:fe(o.onPointerDown,x=>{d.current=x.pointerType;const g=x.target;g.hasPointerCapture(x.pointerId)&&g.releasePointerCapture(x.pointerId),x.button===0&&x.ctrlKey===!1&&x.pointerType==="mouse"&&(v(x),x.preventDefault())}),onKeyDown:fe(o.onKeyDown,x=>{const g=f.current!=="";!(x.ctrlKey||x.altKey||x.metaKey)&&x.key.length===1&&h(x.key),!(g&&x.key===" ")&&FC.includes(x.key)&&(v(),x.preventDefault())})})})});Ip.displayName=Ep;var Np="SelectValue",Ap=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=Qn(Np,n),{onValueNodeHasChildrenChange:u}=l,d=s!==void 0,f=qe(t,l.onValueNodeChange);return Tt(()=>{u(d)},[u,d]),c.jsx(_e.span,{...a,ref:f,style:{pointerEvents:"none"},children:Xp(l.value)?c.jsx(c.Fragment,{children:i}):s})});Ap.displayName=Np;var VC="SelectIcon",_p=m.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return c.jsx(_e.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});_p.displayName=VC;var KC="SelectPortal",jp=e=>c.jsx(vs,{asChild:!0,...e});jp.displayName=KC;var wr="SelectContent",Rp=m.forwardRef((e,t)=>{const n=Qn(wr,e.__scopeSelect),[r,o]=m.useState();if(Tt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?jo.createPortal(c.jsx(Pp,{scope:e.__scopeSelect,children:c.jsx(si.Slot,{scope:e.__scopeSelect,children:c.jsx("div",{children:e.children})})}),s):null}return c.jsx(Op,{...e,ref:t})});Rp.displayName=wr;var hn=10,[Pp,er]=Vr(wr),qC="SelectContentImpl",GC=rr.createSlot("SelectContent.RemoveScroll"),Op=m.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:v,hideWhenDetached:x,avoidCollisions:g,...y}=e,b=Qn(wr,n),[S,I]=m.useState(null),[C,T]=m.useState(null),E=qe(t,q=>I(q)),[A,j]=m.useState(null),[P,D]=m.useState(null),L=ii(n),[V,M]=m.useState(!1),G=m.useRef(!1);m.useEffect(()=>{if(S)return Ia(S)},[S]),wa();const K=m.useCallback(q=>{const[O,...Z]=L().map(ie=>ie.ref.current),[ne]=Z.slice(-1),pe=document.activeElement;for(const ie of q)if(ie===pe||(ie==null||ie.scrollIntoView({block:"nearest"}),ie===O&&C&&(C.scrollTop=0),ie===ne&&C&&(C.scrollTop=C.scrollHeight),ie==null||ie.focus(),document.activeElement!==pe))return},[L,C]),U=m.useCallback(()=>K([A,S]),[K,A,S]);m.useEffect(()=>{V&&U()},[V,U]);const{onOpenChange:z,triggerPointerDownPosRef:F}=b;m.useEffect(()=>{if(S){let q={x:0,y:0};const O=ne=>{var pe,ie;q={x:Math.abs(Math.round(ne.pageX)-(((pe=F.current)==null?void 0:pe.x)??0)),y:Math.abs(Math.round(ne.pageY)-(((ie=F.current)==null?void 0:ie.y)??0))}},Z=ne=>{q.x<=10&&q.y<=10?ne.preventDefault():S.contains(ne.target)||z(!1),document.removeEventListener("pointermove",O),F.current=null};return F.current!==null&&(document.addEventListener("pointermove",O),document.addEventListener("pointerup",Z,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",O),document.removeEventListener("pointerup",Z,{capture:!0})}}},[S,z,F]),m.useEffect(()=>{const q=()=>z(!1);return window.addEventListener("blur",q),window.addEventListener("resize",q),()=>{window.removeEventListener("blur",q),window.removeEventListener("resize",q)}},[z]);const[de,$]=Jp(q=>{const O=L().filter(pe=>!pe.disabled),Z=O.find(pe=>pe.ref.current===document.activeElement),ne=Zp(O,q,Z);ne&&setTimeout(()=>ne.ref.current.focus())}),te=m.useCallback((q,O,Z)=>{const ne=!G.current&&!Z;(b.value!==void 0&&b.value===O||ne)&&(j(q),ne&&(G.current=!0))},[b.value]),he=m.useCallback(()=>S==null?void 0:S.focus(),[S]),ve=m.useCallback((q,O,Z)=>{const ne=!G.current&&!Z;(b.value!==void 0&&b.value===O||ne)&&D(q)},[b.value]),be=r==="popper"?ul:Mp,we=be===ul?{side:a,sideOffset:l,align:u,alignOffset:d,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:v,hideWhenDetached:x,avoidCollisions:g}:{};return c.jsx(Pp,{scope:n,content:S,viewport:C,onViewportChange:T,itemRefCallback:te,selectedItem:A,onItemLeave:he,itemTextRefCallback:ve,focusSelectedItem:U,selectedItemText:P,position:r,isPositioned:V,searchRef:de,children:c.jsx(ks,{as:GC,allowPinchZoom:!0,children:c.jsx(ys,{asChild:!0,trapped:b.open,onMountAutoFocus:q=>{q.preventDefault()},onUnmountAutoFocus:fe(o,q=>{var O;(O=b.trigger)==null||O.focus({preventScroll:!0}),q.preventDefault()}),children:c.jsx(xs,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:q=>q.preventDefault(),onDismiss:()=>b.onOpenChange(!1),children:c.jsx(be,{role:"listbox",id:b.contentId,"data-state":b.open?"open":"closed",dir:b.dir,onContextMenu:q=>q.preventDefault(),...y,...we,onPlaced:()=>M(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:fe(y.onKeyDown,q=>{const O=q.ctrlKey||q.altKey||q.metaKey;if(q.key==="Tab"&&q.preventDefault(),!O&&q.key.length===1&&$(q.key),["ArrowUp","ArrowDown","Home","End"].includes(q.key)){let ne=L().filter(pe=>!pe.disabled).map(pe=>pe.ref.current);if(["ArrowUp","End"].includes(q.key)&&(ne=ne.slice().reverse()),["ArrowUp","ArrowDown"].includes(q.key)){const pe=q.target,ie=ne.indexOf(pe);ne=ne.slice(ie+1)}setTimeout(()=>K(ne)),q.preventDefault()}})})})})})})});Op.displayName=qC;var YC="SelectItemAlignedPosition",Mp=m.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=Qn(wr,n),i=er(wr,n),[a,l]=m.useState(null),[u,d]=m.useState(null),f=qe(t,E=>d(E)),h=ii(n),p=m.useRef(!1),v=m.useRef(!0),{viewport:x,selectedItem:g,selectedItemText:y,focusSelectedItem:b}=i,S=m.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&u&&x&&g&&y){const E=s.trigger.getBoundingClientRect(),A=u.getBoundingClientRect(),j=s.valueNode.getBoundingClientRect(),P=y.getBoundingClientRect();if(s.dir!=="rtl"){const pe=P.left-A.left,ie=j.left-pe,me=E.left-ie,et=E.width+me,tt=Math.max(et,A.width),Me=window.innerWidth-hn,We=ol(ie,[hn,Math.max(hn,Me-tt)]);a.style.minWidth=et+"px",a.style.left=We+"px"}else{const pe=A.right-P.right,ie=window.innerWidth-j.right-pe,me=window.innerWidth-E.right-ie,et=E.width+me,tt=Math.max(et,A.width),Me=window.innerWidth-hn,We=ol(ie,[hn,Math.max(hn,Me-tt)]);a.style.minWidth=et+"px",a.style.right=We+"px"}const D=h(),L=window.innerHeight-hn*2,V=x.scrollHeight,M=window.getComputedStyle(u),G=parseInt(M.borderTopWidth,10),K=parseInt(M.paddingTop,10),U=parseInt(M.borderBottomWidth,10),z=parseInt(M.paddingBottom,10),F=G+K+V+z+U,de=Math.min(g.offsetHeight*5,F),$=window.getComputedStyle(x),te=parseInt($.paddingTop,10),he=parseInt($.paddingBottom,10),ve=E.top+E.height/2-hn,be=L-ve,we=g.offsetHeight/2,q=g.offsetTop+we,O=G+K+q,Z=F-O;if(O<=ve){const pe=D.length>0&&g===D[D.length-1].ref.current;a.style.bottom="0px";const ie=u.clientHeight-x.offsetTop-x.offsetHeight,me=Math.max(be,we+(pe?he:0)+ie+U),et=O+me;a.style.height=et+"px"}else{const pe=D.length>0&&g===D[0].ref.current;a.style.top="0px";const me=Math.max(ve,G+x.offsetTop+(pe?te:0)+we)+Z;a.style.height=me+"px",x.scrollTop=O-ve+x.offsetTop}a.style.margin=`${hn}px 0`,a.style.minHeight=de+"px",a.style.maxHeight=L+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,u,x,g,y,s.dir,r]);Tt(()=>S(),[S]);const[I,C]=m.useState();Tt(()=>{u&&C(window.getComputedStyle(u).zIndex)},[u]);const T=m.useCallback(E=>{E&&v.current===!0&&(S(),b==null||b(),v.current=!1)},[S,b]);return c.jsx(JC,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:T,children:c.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:I},children:c.jsx(_e.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Mp.displayName=YC;var XC="SelectPopperPosition",ul=m.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=hn,...s}=e,i=ai(n);return c.jsx(Wf,{...i,...s,ref:t,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});ul.displayName=XC;var[JC,dl]=Vr(wr,{}),fl="SelectViewport",Dp=m.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=er(fl,n),i=dl(fl,n),a=qe(t,s.onViewportChange),l=m.useRef(0);return c.jsxs(c.Fragment,{children:[c.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),c.jsx(si.Slot,{scope:n,children:c.jsx(_e.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:fe(o.onScroll,u=>{const d=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const p=Math.abs(l.current-d.scrollTop);if(p>0){const v=window.innerHeight-hn*2,x=parseFloat(f.style.minHeight),g=parseFloat(f.style.height),y=Math.max(x,g);if(y<v){const b=y+p,S=Math.min(v,b),I=b-S;f.style.height=S+"px",f.style.bottom==="0px"&&(d.scrollTop=I>0?I:0,f.style.justifyContent="flex-end")}}}l.current=d.scrollTop})})})]})});Dp.displayName=fl;var Lp="SelectGroup",[ZC,QC]=Vr(Lp),eT=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Cn();return c.jsx(ZC,{scope:n,id:o,children:c.jsx(_e.div,{role:"group","aria-labelledby":o,...r,ref:t})})});eT.displayName=Lp;var $p="SelectLabel",Fp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=QC($p,n);return c.jsx(_e.div,{id:o.id,...r,ref:t})});Fp.displayName=$p;var li="SelectItem",[tT,zp]=Vr(li),Bp=m.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=Qn(li,n),l=er(li,n),u=a.value===r,[d,f]=m.useState(s??""),[h,p]=m.useState(!1),v=qe(t,b=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,b,r,o)}),x=Cn(),g=m.useRef("touch"),y=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return c.jsx(tT,{scope:n,value:r,disabled:o,textId:x,isSelected:u,onItemTextChange:m.useCallback(b=>{f(S=>S||((b==null?void 0:b.textContent)??"").trim())},[]),children:c.jsx(si.ItemSlot,{scope:n,value:r,disabled:o,textValue:d,children:c.jsx(_e.div,{role:"option","aria-labelledby":x,"data-highlighted":h?"":void 0,"aria-selected":u&&h,"data-state":u?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:v,onFocus:fe(i.onFocus,()=>p(!0)),onBlur:fe(i.onBlur,()=>p(!1)),onClick:fe(i.onClick,()=>{g.current!=="mouse"&&y()}),onPointerUp:fe(i.onPointerUp,()=>{g.current==="mouse"&&y()}),onPointerDown:fe(i.onPointerDown,b=>{g.current=b.pointerType}),onPointerMove:fe(i.onPointerMove,b=>{var S;g.current=b.pointerType,o?(S=l.onItemLeave)==null||S.call(l):g.current==="mouse"&&b.currentTarget.focus({preventScroll:!0})}),onPointerLeave:fe(i.onPointerLeave,b=>{var S;b.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:fe(i.onKeyDown,b=>{var I;((I=l.searchRef)==null?void 0:I.current)!==""&&b.key===" "||(zC.includes(b.key)&&y(),b.key===" "&&b.preventDefault())})})})})});Bp.displayName=li;var Io="SelectItemText",Hp=m.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=Qn(Io,n),a=er(Io,n),l=zp(Io,n),u=WC(Io,n),[d,f]=m.useState(null),h=qe(t,y=>f(y),l.onItemTextChange,y=>{var b;return(b=a.itemTextRefCallback)==null?void 0:b.call(a,y,l.value,l.disabled)}),p=d==null?void 0:d.textContent,v=m.useMemo(()=>c.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:x,onNativeOptionRemove:g}=u;return Tt(()=>(x(v),()=>g(v)),[x,g,v]),c.jsxs(c.Fragment,{children:[c.jsx(_e.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?jo.createPortal(s.children,i.valueNode):null]})});Hp.displayName=Io;var Up="SelectItemIndicator",Wp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return zp(Up,n).isSelected?c.jsx(_e.span,{"aria-hidden":!0,...r,ref:t}):null});Wp.displayName=Up;var hl="SelectScrollUpButton",Vp=m.forwardRef((e,t)=>{const n=er(hl,e.__scopeSelect),r=dl(hl,e.__scopeSelect),[o,s]=m.useState(!1),i=qe(t,r.onScrollButtonChange);return Tt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollTop>0;s(u)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(qp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});Vp.displayName=hl;var pl="SelectScrollDownButton",Kp=m.forwardRef((e,t)=>{const n=er(pl,e.__scopeSelect),r=dl(pl,e.__scopeSelect),[o,s]=m.useState(!1),i=qe(t,r.onScrollButtonChange);return Tt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const u=l.scrollHeight-l.clientHeight,d=Math.ceil(l.scrollTop)<u;s(d)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?c.jsx(qp,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});Kp.displayName=pl;var qp=m.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=er("SelectScrollButton",n),i=m.useRef(null),a=ii(n),l=m.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return m.useEffect(()=>()=>l(),[l]),Tt(()=>{var d;const u=a().find(f=>f.ref.current===document.activeElement);(d=u==null?void 0:u.ref.current)==null||d.scrollIntoView({block:"nearest"})},[a]),c.jsx(_e.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:fe(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:fe(o.onPointerMove,()=>{var u;(u=s.onItemLeave)==null||u.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:fe(o.onPointerLeave,()=>{l()})})}),nT="SelectSeparator",Gp=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return c.jsx(_e.div,{"aria-hidden":!0,...r,ref:t})});Gp.displayName=nT;var ml="SelectArrow",rT=m.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=ai(n),s=Qn(ml,n),i=er(ml,n);return s.open&&i.position==="popper"?c.jsx(Vf,{...o,...r,ref:t}):null});rT.displayName=ml;var oT="SelectBubbleInput",Yp=m.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=m.useRef(null),s=qe(r,o),i=xp(t);return m.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,d=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&d){const f=new Event("change",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),c.jsx(_e.select,{...n,style:{...Tp,...n.style},ref:s,defaultValue:t})});Yp.displayName=oT;function Xp(e){return e===""||e===void 0}function Jp(e){const t=Et(e),n=m.useRef(""),r=m.useRef(0),o=m.useCallback(i=>{const a=n.current+i;t(a),function l(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=m.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return m.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function Zp(e,t,n){const o=t.length>1&&Array.from(t).every(u=>u===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=sT(e,Math.max(s,0));o.length===1&&(i=i.filter(u=>u!==n));const l=i.find(u=>u.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function sT(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var iT=kp,Qp=Ip,aT=Ap,lT=_p,cT=jp,em=Rp,uT=Dp,tm=Fp,nm=Bp,dT=Hp,fT=Wp,rm=Vp,om=Kp,sm=Gp;const im=iT,am=aT,gl=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(Qp,{ref:r,className:ee("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,c.jsx(lT,{asChild:!0,children:c.jsx(le.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));gl.displayName=Qp.displayName;const lm=m.forwardRef(({className:e,...t},n)=>c.jsx(rm,{ref:n,className:ee("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(le.ChevronUp,{className:"h-4 w-4"})}));lm.displayName=rm.displayName;const cm=m.forwardRef(({className:e,...t},n)=>c.jsx(om,{ref:n,className:ee("flex cursor-default items-center justify-center py-1",e),...t,children:c.jsx(le.ChevronDown,{className:"h-4 w-4"})}));cm.displayName=om.displayName;const xl=m.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>c.jsx(cT,{children:c.jsxs(em,{ref:o,className:ee("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[c.jsx(lm,{}),c.jsx(uT,{className:ee("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),c.jsx(cm,{})]})}));xl.displayName=em.displayName;const hT=m.forwardRef(({className:e,...t},n)=>c.jsx(tm,{ref:n,className:ee("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));hT.displayName=tm.displayName;const Sr=m.forwardRef(({className:e,children:t,...n},r)=>c.jsxs(nm,{ref:r,className:ee("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...n,children:[c.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:c.jsx(fT,{children:c.jsx(le.Check,{className:"h-4 w-4"})})}),c.jsx(dT,{children:t})]}));Sr.displayName=nm.displayName;const pT=m.forwardRef(({className:e,...t},n)=>c.jsx(sm,{ref:n,className:ee("-mx-1 my-1 h-px bg-muted",e),...t}));pT.displayName=sm.displayName;var mT="Separator",um="horizontal",gT=["horizontal","vertical"],dm=m.forwardRef((e,t)=>{const{decorative:n,orientation:r=um,...o}=e,s=xT(r)?r:um,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return c.jsx(_e.div,{"data-orientation":s,...a,...o,ref:t})});dm.displayName=mT;function xT(e){return gT.includes(e)}var fm=dm;const hm=m.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>c.jsx(fm,{ref:o,decorative:n,orientation:t,className:ee("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));hm.displayName=fm.displayName;const yT=Yd,vT=Zb,bT=Xd,pm=m.forwardRef(({className:e,...t},n)=>c.jsx(_s,{className:ee("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));pm.displayName=_s.displayName;const wT=_o.cva("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),mm=m.forwardRef(({side:e="right",className:t,children:n,...r},o)=>c.jsxs(bT,{children:[c.jsx(pm,{}),c.jsxs(js,{ref:o,className:ee(wT({side:e}),t),...r,children:[n,c.jsxs(Jd,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary",children:[c.jsx(le.X,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));mm.displayName=js.displayName;const gm=({className:e,...t})=>c.jsx("div",{className:ee("flex flex-col space-y-2 text-center sm:text-left",e),...t});gm.displayName="SheetHeader";const xm=m.forwardRef(({className:e,...t},n)=>c.jsx(mr,{ref:n,className:ee("text-lg font-semibold text-foreground",e),...t}));xm.displayName=mr.displayName;const ym=m.forwardRef(({className:e,...t},n)=>c.jsx(Rs,{ref:n,className:ee("text-sm text-muted-foreground",e),...t}));ym.displayName=Rs.displayName;const ST={api:{baseUrl:"http://localhost:8000/api",authToken:"",enableAuth:!1},ui:{layout:"sidebar",theme:"light",showTimestamps:!0,showAgentNames:!0,compactMessages:!1},behavior:{autoSave:!0,enableStreaming:!0,showTypingIndicator:!0}};function CT({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=w.useState(!1),[s,i]=w.useState(!1),[a,l]=w.useState(e),[u,d]=w.useState(!1),{toast:f}=ga();w.useEffect(()=>{const g=JSON.stringify(a)!==JSON.stringify(e);d(g)},[a,e]),w.useEffect(()=>{l(e)},[e]);const h=()=>{t(a),d(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},p=()=>{l(ST),d(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},v=()=>{l(e),d(!1),o(!1)},x=async()=>{try{const y=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${y.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return c.jsxs(yT,{open:r,onOpenChange:o,children:[c.jsx(vT,{asChild:!0,children:c.jsxs(Je,{variant:"outline",size:"sm",className:n,children:[c.jsx(le.Settings,{className:"h-4 w-4 mr-2"}),"Settings",u&&c.jsx(ia,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),c.jsxs(mm,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[c.jsxs(gm,{children:[c.jsx(xm,{children:"Chat Settings"}),c.jsx(ym,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),c.jsxs("div",{className:"space-y-6 py-6",children:[c.jsxs(ho,{children:[c.jsx(po,{className:"pb-3",children:c.jsxs(mo,{className:"text-lg flex items-center gap-2",children:[c.jsx(le.Server,{className:"h-5 w-5"}),"API Configuration"]})}),c.jsxs(us,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Qt,{htmlFor:"api-url",children:"API Base URL"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Qs,{id:"api-url",value:a.api.baseUrl,onChange:g=>l(y=>({...y,api:{...y.api,baseUrl:g.target.value}})),placeholder:"http://localhost:8000/api"}),c.jsx(Je,{variant:"outline",onClick:x,children:"Test"})]})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Qt,{htmlFor:"enable-auth",children:"Enable Authentication"}),c.jsx(Zn,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:g=>l(y=>({...y,api:{...y.api,enableAuth:g}}))})]}),a.api.enableAuth&&c.jsxs("div",{className:"space-y-2",children:[c.jsx(Qt,{htmlFor:"auth-token",children:"Authentication Token"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Qs,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:g=>l(y=>({...y,api:{...y.api,authToken:g.target.value}})),placeholder:"Enter your Bearer token"}),c.jsx(Je,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?c.jsx(le.EyeOff,{className:"h-4 w-4"}):c.jsx(le.Eye,{className:"h-4 w-4"})})]})]})]})]}),c.jsxs(ho,{children:[c.jsx(po,{className:"pb-3",children:c.jsxs(mo,{className:"text-lg flex items-center gap-2",children:[c.jsx(le.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),c.jsxs(us,{className:"space-y-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Qt,{htmlFor:"layout",children:"Layout Style"}),c.jsxs(im,{value:a.ui.layout,onValueChange:g=>l(y=>({...y,ui:{...y.ui,layout:g}})),children:[c.jsx(gl,{children:c.jsx(am,{})}),c.jsxs(xl,{children:[c.jsx(Sr,{value:"sidebar",children:"Sidebar Layout"}),c.jsx(Sr,{value:"fullscreen",children:"Fullscreen"}),c.jsx(Sr,{value:"tabs",children:"Tabbed Interface"})]})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Qt,{htmlFor:"theme",children:"Theme"}),c.jsxs(im,{value:a.ui.theme,onValueChange:g=>l(y=>({...y,ui:{...y.ui,theme:g}})),children:[c.jsx(gl,{children:c.jsx(am,{})}),c.jsxs(xl,{children:[c.jsx(Sr,{value:"light",children:"Light"}),c.jsx(Sr,{value:"dark",children:"Dark"}),c.jsx(Sr,{value:"system",children:"System"})]})]})]}),c.jsx(hm,{}),c.jsxs("div",{className:"space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Qt,{htmlFor:"show-timestamps",children:"Show Timestamps"}),c.jsx(Zn,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:g=>l(y=>({...y,ui:{...y.ui,showTimestamps:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Qt,{htmlFor:"show-agent-names",children:"Show Agent Names"}),c.jsx(Zn,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:g=>l(y=>({...y,ui:{...y.ui,showAgentNames:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Qt,{htmlFor:"compact-messages",children:"Compact Messages"}),c.jsx(Zn,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:g=>l(y=>({...y,ui:{...y.ui,compactMessages:g}}))})]})]})]})]}),c.jsxs(ho,{children:[c.jsx(po,{className:"pb-3",children:c.jsxs(mo,{className:"text-lg flex items-center gap-2",children:[c.jsx(le.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),c.jsxs(us,{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Qt,{htmlFor:"auto-save",children:"Auto-save Conversations"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),c.jsx(Zn,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:g=>l(y=>({...y,behavior:{...y.behavior,autoSave:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Qt,{htmlFor:"enable-streaming",children:"Enable Streaming"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),c.jsx(Zn,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:g=>l(y=>({...y,behavior:{...y.behavior,enableStreaming:g}}))})]}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsxs("div",{children:[c.jsx(Qt,{htmlFor:"typing-indicator",children:"Typing Indicator"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),c.jsx(Zn,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:g=>l(y=>({...y,behavior:{...y.behavior,showTypingIndicator:g}}))})]})]})]})]}),c.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[c.jsxs(Je,{variant:"outline",onClick:p,children:[c.jsx(le.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Je,{variant:"outline",onClick:v,children:"Cancel"}),c.jsxs(Je,{onClick:h,disabled:!u,children:[c.jsx(le.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function TT({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=u=>{const d="h-full";switch(u){case"phone":return`${d} max-w-none`;case"tablet":return`${d} max-w-4xl mx-auto`;case"half-screen":return`${d} max-w-2xl`;case"desktop":default:return`${d} max-w-7xl mx-auto`}},a=u=>({"--chat-sidebar-width":u==="phone"?"100%":u==="tablet"?"280px":u==="half-screen"?"240px":"320px","--chat-message-max-width":u==="phone"?"95%":u==="tablet"?"90%":u==="half-screen"?"85%":"80%","--chat-input-height":u==="phone"?"120px":"100px"}),l=w.useCallback(u=>{var d;(d=s.onThreadChange)==null||d.call(s,u)},[s]);return e==="fullscreen"?c.jsx(Go,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsx(Zs,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?c.jsx(Go,{...s,onThreadChange:l,children:c.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:c.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&c.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(cl,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),c.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:c.jsx(Zs,{onError:s.onError,enableFileUpload:!0})})]})})}):c.jsx(Go,{...s,onThreadChange:l,children:c.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&c.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:c.jsx(cl,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),c.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:c.jsx(Zs,{onError:s.onError,enableFileUpload:!0})})]})})}Re.ChatApi=mc,Re.ChatInterface=Zs,Re.ChatProviders=Go,Re.ChatSettings=CT,Re.MarkdownContent=ha,Re.MessageComponent=af,Re.MessageList=Ra,Re.ThreadManager=cl,Re.applySettings=AC,Re.chatApiClient=Hn,Re.default=TT,Re.del=pc,Re.get=sn,Re.getChatToken=dc,Re.getCurrentSettings=NC,Re.getDefaultApiConfig=fp,Re.getDefaultChatSettings=hp,Re.onChatTokenChanged=fc,Re.post=Ti,Re.put=hc,Re.setChatToken=Ci,Re.useApi=ki,Re.useChatStream=jc,Re.useMessagesReducer=Sc,Re.useStream=Fc,Re.useThreadState=qo,Re.useThreads=Ko,Object.defineProperties(Re,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teodor-new-chat-ui",
3
- "version": "4.3.9",
3
+ "version": "4.3.10",
4
4
  "description": "React chat UI components with streaming support, tool calls, and modern design",
5
5
  "main": "dist/index.umd.js",
6
6
  "module": "dist/index.esm.js",