teodor-new-chat-ui 4.3.105 → 4.3.106

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
@@ -15569,7 +15569,7 @@ function sa({
15569
15569
  {
15570
15570
  text: de || "",
15571
15571
  attachments: ue,
15572
- payload: O ? { edit: !0, originalMessageId: O } : void 0
15572
+ payload: O ? { additional_kwargs: { edit: !0, originalMessageId: O } } : void 0
15573
15573
  },
15574
15574
  {
15575
15575
  checkpointId: L ?? void 0,
package/dist/index.umd.js CHANGED
@@ -134,4 +134,4 @@ Please report this to https://github.com/markedjs/marked.`,e){const o="<p>An err
134
134
  `).replace(/<ul>/gi,"").replace(/<\/ul>/gi,`
135
135
  `).replace(/<ol>/gi,"").replace(/<\/ol>/gi,`
136
136
  `).replace(/<li>(.*?)<\/li>/gi,`- $1
137
- `).trim():n.replace(/</g,"&lt;").replace(/>/g,"&gt;").trim()}function Vb(e,t=qs){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 Kb(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),Vb(t),Wb(t)}function Ka(e){const t=e+"CollectionProvider",[n,r]=Wn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=y=>{const{scope:x,children:m}=y,w=b.useRef(null),S=b.useRef(new Map).current;return d.jsx(o,{scope:x,itemMap:S,collectionRef:w,children:m})};i.displayName=t;const a=e+"CollectionSlot",l=dr.createSlot(a),c=b.forwardRef((y,x)=>{const{scope:m,children:w}=y,S=s(a,m),T=Xe(x,S.collectionRef);return d.jsx(l,{ref:T,children:w})});c.displayName=a;const u=e+"CollectionItemSlot",f="data-radix-collection-item",h=dr.createSlot(u),p=b.forwardRef((y,x)=>{const{scope:m,children:w,...S}=y,T=b.useRef(null),k=Xe(x,T),C=s(u,m);return b.useEffect(()=>(C.itemMap.set(T,{ref:T,...S}),()=>void C.itemMap.delete(T))),d.jsx(h,{[f]:"",ref:k,children:w})});p.displayName=u;function g(y){const x=s(e+"CollectionConsumer",y);return b.useCallback(()=>{const w=x.collectionRef.current;if(!w)return[];const S=Array.from(w.querySelectorAll(`[${f}]`));return Array.from(x.itemMap.values()).sort((C,E)=>S.indexOf(C.ref.current)-S.indexOf(E.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:c,ItemSlot:p},g,r]}var qb=v.createContext(void 0);function Gs(e){const t=v.useContext(qb);return e||t||"ltr"}const Gb=["top","right","bottom","left"],nr=Math.min,an=Math.max,Ys=Math.round,Xs=Math.floor,Rn=e=>({x:e,y:e}),Yb={left:"right",right:"left",bottom:"top",top:"bottom"},Xb={start:"end",end:"start"};function qa(e,t,n){return an(e,nr(t,n))}function Kn(e,t){return typeof e=="function"?e(t):e}function qn(e){return e.split("-")[0]}function Ur(e){return e.split("-")[1]}function Ga(e){return e==="x"?"y":"x"}function Ya(e){return e==="y"?"height":"width"}const Jb=new Set(["top","bottom"]);function Pn(e){return Jb.has(qn(e))?"y":"x"}function Xa(e){return Ga(Pn(e))}function Zb(e,t,n){n===void 0&&(n=!1);const r=Ur(e),o=Xa(e),s=Ya(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Js(i)),[i,Js(i)]}function Qb(e){const t=Js(e);return[Ja(e),t,Ja(t)]}function Ja(e){return e.replace(/start|end/g,t=>Xb[t])}const yf=["left","right"],xf=["right","left"],e0=["top","bottom"],t0=["bottom","top"];function n0(e,t,n){switch(e){case"top":case"bottom":return n?t?xf:yf:t?yf:xf;case"left":case"right":return t?e0:t0;default:return[]}}function r0(e,t,n,r){const o=Ur(e);let s=n0(qn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ja)))),s}function Js(e){return e.replace(/left|right|bottom|top/g,t=>Yb[t])}function o0(e){return{top:0,right:0,bottom:0,left:0,...e}}function vf(e){return typeof e!="number"?o0(e):{top:e,right:e,bottom:e,left:e}}function Zs(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 wf(e,t,n){let{reference:r,floating:o}=e;const s=Pn(t),i=Xa(t),a=Ya(i),l=qn(t),c=s==="y",u=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:u,y:r.y-o.height};break;case"bottom":p={x:u,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(Ur(t)){case"start":p[i]-=h*(n&&c?-1:1);break;case"end":p[i]+=h*(n&&c?-1:1);break}return p}const s0=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 c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:f}=wf(c,r,l),h=r,p={},g=0;for(let y=0;y<a.length;y++){const{name:x,fn:m}=a[y],{x:w,y:S,data:T,reset:k}=await m({x:u,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:c,platform:i,elements:{reference:e,floating:t}});u=w??u,f=S??f,p={...p,[x]:{...p[x],...T}},k&&g<=50&&(g++,typeof k=="object"&&(k.placement&&(h=k.placement),k.rects&&(c=k.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):k.rects),{x:u,y:f}=wf(c,h,l)),y=-1)}return{x:u,y:f,placement:h,strategy:o,middlewareData:p}};async function To(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=Kn(t,e),g=vf(p),x=a[h?f==="floating"?"reference":"floating":f],m=Zs(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(x)))==null||n?x:x.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),w=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)),T=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},k=Zs(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:S,strategy:l}):w);return{top:(m.top-k.top+g.top)/T.y,bottom:(k.bottom-m.bottom+g.bottom)/T.y,left:(m.left-k.left+g.left)/T.x,right:(k.right-m.right+g.right)/T.x}}const i0=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:c,padding:u=0}=Kn(e,t)||{};if(c==null)return{};const f=vf(u),h={x:n,y:r},p=Xa(o),g=Ya(p),y=await i.getDimensions(c),x=p==="y",m=x?"top":"left",w=x?"bottom":"right",S=x?"clientHeight":"clientWidth",T=s.reference[g]+s.reference[p]-h[p]-s.floating[g],k=h[p]-s.reference[p],C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=C?C[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(C)))&&(E=a.floating[S]||s.floating[g]);const j=T/2-k/2,_=E/2-y[g]/2-1,R=nr(f[m],_),L=nr(f[w],_),z=R,W=E-y[g]-L,O=E/2-y[g]/2+j,B=qa(z,O,W),P=!l.arrow&&Ur(o)!=null&&O!==B&&s.reference[g]/2-(O<z?R:L)-y[g]/2<0,U=P?O<z?O-z:O-W:0;return{[p]:h[p]+U,data:{[p]:B,centerOffset:O-B-U,...P&&{alignmentOffset:U}},reset:P}}}),a0=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:c}=t,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:y=!0,...x}=Kn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const m=qn(o),w=Pn(a),S=qn(a)===a,T=await(l.isRTL==null?void 0:l.isRTL(c.floating)),k=h||(S||!y?[Js(a)]:Qb(a)),C=g!=="none";!h&&C&&k.push(...r0(a,y,g,T));const E=[a,...k],j=await To(t,x),_=[];let R=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&_.push(j[m]),f){const O=Zb(o,i,T);_.push(j[O[0]],j[O[1]])}if(R=[...R,{placement:o,overflows:_}],!_.every(O=>O<=0)){var L,z;const O=(((L=s.flip)==null?void 0:L.index)||0)+1,B=E[O];if(B&&(!(f==="alignment"?w!==Pn(B):!1)||R.every($=>Pn($.placement)===w?$.overflows[0]>0:!0)))return{data:{index:O,overflows:R},reset:{placement:B}};let P=(z=R.filter(U=>U.overflows[0]<=0).sort((U,$)=>U.overflows[1]-$.overflows[1])[0])==null?void 0:z.placement;if(!P)switch(p){case"bestFit":{var W;const U=(W=R.filter($=>{if(C){const F=Pn($.placement);return F===w||F==="y"}return!0}).map($=>[$.placement,$.overflows.filter(F=>F>0).reduce((F,ne)=>F+ne,0)]).sort(($,F)=>$[1]-F[1])[0])==null?void 0:W[0];U&&(P=U);break}case"initialPlacement":P=a;break}if(o!==P)return{reset:{placement:P}}}return{}}}};function bf(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Sf(e){return Gb.some(t=>e[t]>=0)}const l0=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=Kn(e,t);switch(r){case"referenceHidden":{const s=await To(t,{...o,elementContext:"reference"}),i=bf(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Sf(i)}}}case"escaped":{const s=await To(t,{...o,altBoundary:!0}),i=bf(s,n.floating);return{data:{escapedOffsets:i,escaped:Sf(i)}}}default:return{}}}}},Cf=new Set(["left","top"]);async function c0(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=qn(n),a=Ur(n),l=Pn(n)==="y",c=Cf.has(i)?-1:1,u=s&&l?-1:1,f=Kn(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:g}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof g=="number"&&(p=a==="end"?g*-1:g),l?{x:p*u,y:h*c}:{x:h*c,y:p*u}}const u0=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 c0(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}}}}},d0=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:x=>{let{x:m,y:w}=x;return{x:m,y:w}}},...l}=Kn(e,t),c={x:n,y:r},u=await To(t,l),f=Pn(qn(o)),h=Ga(f);let p=c[h],g=c[f];if(s){const x=h==="y"?"top":"left",m=h==="y"?"bottom":"right",w=p+u[x],S=p-u[m];p=qa(w,p,S)}if(i){const x=f==="y"?"top":"left",m=f==="y"?"bottom":"right",w=g+u[x],S=g-u[m];g=qa(w,g,S)}const y=a.fn({...t,[h]:p,[f]:g});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[h]:s,[f]:i}}}}}},f0=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:c=!0}=Kn(e,t),u={x:n,y:r},f=Pn(o),h=Ga(f);let p=u[h],g=u[f];const y=Kn(a,t),x=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(l){const S=h==="y"?"height":"width",T=s.reference[h]-s.floating[S]+x.mainAxis,k=s.reference[h]+s.reference[S]-x.mainAxis;p<T?p=T:p>k&&(p=k)}if(c){var m,w;const S=h==="y"?"width":"height",T=Cf.has(qn(o)),k=s.reference[f]-s.floating[S]+(T&&((m=i.offset)==null?void 0:m[f])||0)+(T?0:x.crossAxis),C=s.reference[f]+s.reference[S]+(T?0:((w=i.offset)==null?void 0:w[f])||0)-(T?x.crossAxis:0);g<k?g=k:g>C&&(g=C)}return{[h]:p,[f]:g}}}},h0=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=()=>{},...c}=Kn(e,t),u=await To(t,c),f=qn(o),h=Ur(o),p=Pn(o)==="y",{width:g,height:y}=s.floating;let x,m;f==="top"||f==="bottom"?(x=f,m=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(m=f,x=h==="end"?"top":"bottom");const w=y-u.top-u.bottom,S=g-u.left-u.right,T=nr(y-u[x],w),k=nr(g-u[m],S),C=!t.middlewareData.shift;let E=T,j=k;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(j=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=w),C&&!h){const R=an(u.left,0),L=an(u.right,0),z=an(u.top,0),W=an(u.bottom,0);p?j=g-2*(R!==0||L!==0?R+L:an(u.left,u.right)):E=y-2*(z!==0||W!==0?z+W:an(u.top,u.bottom))}await l({...t,availableWidth:j,availableHeight:E});const _=await i.getDimensions(a.floating);return g!==_.width||y!==_.height?{reset:{rects:!0}}:{}}}};function Qs(){return typeof window<"u"}function Wr(e){return kf(e)?(e.nodeName||"").toLowerCase():"#document"}function ln(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function On(e){var t;return(t=(kf(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function kf(e){return Qs()?e instanceof Node||e instanceof ln(e).Node:!1}function Cn(e){return Qs()?e instanceof Element||e instanceof ln(e).Element:!1}function Mn(e){return Qs()?e instanceof HTMLElement||e instanceof ln(e).HTMLElement:!1}function Tf(e){return!Qs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ln(e).ShadowRoot}const p0=new Set(["inline","contents"]);function Eo(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=kn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!p0.has(o)}const m0=new Set(["table","td","th"]);function g0(e){return m0.has(Wr(e))}const y0=[":popover-open",":modal"];function ei(e){return y0.some(t=>{try{return e.matches(t)}catch{return!1}})}const x0=["transform","translate","scale","rotate","perspective"],v0=["transform","translate","scale","rotate","perspective","filter"],w0=["paint","layout","strict","content"];function Za(e){const t=Qa(),n=Cn(e)?kn(e):e;return x0.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)||v0.some(r=>(n.willChange||"").includes(r))||w0.some(r=>(n.contain||"").includes(r))}function b0(e){let t=rr(e);for(;Mn(t)&&!Vr(t);){if(Za(t))return t;if(ei(t))return null;t=rr(t)}return null}function Qa(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const S0=new Set(["html","body","#document"]);function Vr(e){return S0.has(Wr(e))}function kn(e){return ln(e).getComputedStyle(e)}function ti(e){return Cn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function rr(e){if(Wr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Tf(e)&&e.host||On(e);return Tf(t)?t.host:t}function Ef(e){const t=rr(e);return Vr(t)?e.ownerDocument?e.ownerDocument.body:e.body:Mn(t)&&Eo(t)?t:Ef(t)}function Io(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Ef(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=ln(o);if(s){const a=el(i);return t.concat(i,i.visualViewport||[],Eo(o)?o:[],a&&n?Io(a):[])}return t.concat(o,Io(o,[],n))}function el(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function If(e){const t=kn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Mn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Ys(n)!==s||Ys(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function tl(e){return Cn(e)?e:e.contextElement}function Kr(e){const t=tl(e);if(!Mn(t))return Rn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=If(t);let i=(s?Ys(n.width):n.width)/r,a=(s?Ys(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const C0=Rn(0);function Nf(e){const t=ln(e);return!Qa()||!t.visualViewport?C0:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function k0(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ln(e)?!1:t}function Cr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=tl(e);let i=Rn(1);t&&(r?Cn(r)&&(i=Kr(r)):i=Kr(e));const a=k0(s,n,r)?Nf(s):Rn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,u=o.width/i.x,f=o.height/i.y;if(s){const h=ln(s),p=r&&Cn(r)?ln(r):r;let g=h,y=el(g);for(;y&&r&&p!==g;){const x=Kr(y),m=y.getBoundingClientRect(),w=kn(y),S=m.left+(y.clientLeft+parseFloat(w.paddingLeft))*x.x,T=m.top+(y.clientTop+parseFloat(w.paddingTop))*x.y;l*=x.x,c*=x.y,u*=x.x,f*=x.y,l+=S,c+=T,g=ln(y),y=el(g)}}return Zs({width:u,height:f,x:l,y:c})}function ni(e,t){const n=ti(e).scrollLeft;return t?t.left+n:Cr(On(e)).left+n}function Af(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-ni(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function T0(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=On(r),a=t?ei(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=Rn(1);const u=Rn(0),f=Mn(r);if((f||!f&&!s)&&((Wr(r)!=="body"||Eo(i))&&(l=ti(r)),Mn(r))){const p=Cr(r);c=Kr(r),u.x=p.x+r.clientLeft,u.y=p.y+r.clientTop}const h=i&&!f&&!s?Af(i,l):Rn(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+h.x,y:n.y*c.y-l.scrollTop*c.y+u.y+h.y}}function E0(e){return Array.from(e.getClientRects())}function I0(e){const t=On(e),n=ti(e),r=e.ownerDocument.body,o=an(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=an(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ni(e);const a=-n.scrollTop;return kn(r).direction==="rtl"&&(i+=an(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const _f=25;function N0(e,t){const n=ln(e),r=On(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const u=Qa();(!u||u&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=ni(r);if(c<=0){const u=r.ownerDocument,f=u.body,h=getComputedStyle(f),p=u.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,g=Math.abs(r.clientWidth-f.clientWidth-p);g<=_f&&(s-=g)}else c<=_f&&(s+=c);return{width:s,height:i,x:a,y:l}}const A0=new Set(["absolute","fixed"]);function _0(e,t){const n=Cr(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Mn(e)?Kr(e):Rn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function jf(e,t,n){let r;if(t==="viewport")r=N0(e,n);else if(t==="document")r=I0(On(e));else if(Cn(t))r=_0(t,n);else{const o=Nf(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Zs(r)}function Rf(e,t){const n=rr(e);return n===t||!Cn(n)||Vr(n)?!1:kn(n).position==="fixed"||Rf(n,t)}function j0(e,t){const n=t.get(e);if(n)return n;let r=Io(e,[],!1).filter(a=>Cn(a)&&Wr(a)!=="body"),o=null;const s=kn(e).position==="fixed";let i=s?rr(e):e;for(;Cn(i)&&!Vr(i);){const a=kn(i),l=Za(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&A0.has(o.position)||Eo(i)&&!l&&Rf(e,i))?r=r.filter(u=>u!==i):o=a,i=rr(i)}return t.set(e,r),r}function R0(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?ei(t)?[]:j0(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,u)=>{const f=jf(t,u,o);return c.top=an(f.top,c.top),c.right=nr(f.right,c.right),c.bottom=nr(f.bottom,c.bottom),c.left=an(f.left,c.left),c},jf(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function P0(e){const{width:t,height:n}=If(e);return{width:t,height:n}}function O0(e,t,n){const r=Mn(t),o=On(t),s=n==="fixed",i=Cr(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=Rn(0);function c(){l.x=ni(o)}if(r||!r&&!s)if((Wr(t)!=="body"||Eo(o))&&(a=ti(t)),r){const p=Cr(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&c();s&&!r&&o&&c();const u=o&&!r&&!s?Af(o,a):Rn(0),f=i.left+a.scrollLeft-l.x-u.x,h=i.top+a.scrollTop-l.y-u.y;return{x:f,y:h,width:i.width,height:i.height}}function nl(e){return kn(e).position==="static"}function Pf(e,t){if(!Mn(e)||kn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return On(e)===n&&(n=n.ownerDocument.body),n}function Of(e,t){const n=ln(e);if(ei(e))return n;if(!Mn(e)){let o=rr(e);for(;o&&!Vr(o);){if(Cn(o)&&!nl(o))return o;o=rr(o)}return n}let r=Pf(e,t);for(;r&&g0(r)&&nl(r);)r=Pf(r,t);return r&&Vr(r)&&nl(r)&&!Za(r)?n:r||b0(e)||n}const M0=async function(e){const t=this.getOffsetParent||Of,n=this.getDimensions,r=await n(e.floating);return{reference:O0(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function D0(e){return kn(e).direction==="rtl"}const L0={convertOffsetParentRelativeRectToViewportRelativeRect:T0,getDocumentElement:On,getClippingRect:R0,getOffsetParent:Of,getElementRects:M0,getClientRects:E0,getDimensions:P0,getScale:Kr,isElement:Cn,isRTL:D0};function Mf(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function F0(e,t){let n=null,r;const o=On(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 c=e.getBoundingClientRect(),{left:u,top:f,width:h,height:p}=c;if(a||t(),!h||!p)return;const g=Xs(f),y=Xs(o.clientWidth-(u+h)),x=Xs(o.clientHeight-(f+p)),m=Xs(u),S={rootMargin:-g+"px "+-y+"px "+-x+"px "+-m+"px",threshold:an(0,nr(1,l))||1};let T=!0;function k(C){const E=C[0].intersectionRatio;if(E!==l){if(!T)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!Mf(c,e.getBoundingClientRect())&&i(),T=!1}try{n=new IntersectionObserver(k,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(k,S)}n.observe(e)}return i(!0),s}function $0(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,c=tl(e),u=o||s?[...c?Io(c):[],...Io(t)]:[];u.forEach(m=>{o&&m.addEventListener("scroll",n,{passive:!0}),s&&m.addEventListener("resize",n)});const f=c&&a?F0(c,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(m=>{let[w]=m;w&&w.target===c&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var S;(S=p)==null||S.observe(t)})),n()}),c&&!l&&p.observe(c),p.observe(t));let g,y=l?Cr(e):null;l&&x();function x(){const m=Cr(e);y&&!Mf(y,m)&&n(),y=m,g=requestAnimationFrame(x)}return n(),()=>{var m;u.forEach(w=>{o&&w.removeEventListener("scroll",n),s&&w.removeEventListener("resize",n)}),f==null||f(),(m=p)==null||m.disconnect(),p=null,l&&cancelAnimationFrame(g)}}const z0=u0,B0=d0,H0=a0,U0=h0,W0=l0,Df=i0,V0=f0,K0=(e,t,n)=>{const r=new Map,o={platform:L0,...n},s={...o.platform,_c:r};return s0(e,t,{...o,platform:s})};var q0=typeof document<"u",G0=function(){},ri=q0?b.useLayoutEffect:G0;function oi(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(!oi(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)&&!oi(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Lf(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ff(e,t){const n=Lf(e);return Math.round(t*n)/n}function rl(e){const t=v.useRef(e);return ri(()=>{t.current=e}),t}function Y0(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:c}=e,[u,f]=v.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=v.useState(r);oi(h,r)||p(r);const[g,y]=v.useState(null),[x,m]=v.useState(null),w=v.useCallback($=>{$!==C.current&&(C.current=$,y($))},[]),S=v.useCallback($=>{$!==E.current&&(E.current=$,m($))},[]),T=s||g,k=i||x,C=v.useRef(null),E=v.useRef(null),j=v.useRef(u),_=l!=null,R=rl(l),L=rl(o),z=rl(c),W=v.useCallback(()=>{if(!C.current||!E.current)return;const $={placement:t,strategy:n,middleware:h};L.current&&($.platform=L.current),K0(C.current,E.current,$).then(F=>{const ne={...F,isPositioned:z.current!==!1};O.current&&!oi(j.current,ne)&&(j.current=ne,Bo.flushSync(()=>{f(ne)}))})},[h,t,n,L,z]);ri(()=>{c===!1&&j.current.isPositioned&&(j.current.isPositioned=!1,f($=>({...$,isPositioned:!1})))},[c]);const O=v.useRef(!1);ri(()=>(O.current=!0,()=>{O.current=!1}),[]),ri(()=>{if(T&&(C.current=T),k&&(E.current=k),T&&k){if(R.current)return R.current(T,k,W);W()}},[T,k,W,R,_]);const B=v.useMemo(()=>({reference:C,floating:E,setReference:w,setFloating:S}),[w,S]),P=v.useMemo(()=>({reference:T,floating:k}),[T,k]),U=v.useMemo(()=>{const $={position:n,left:0,top:0};if(!P.floating)return $;const F=Ff(P.floating,u.x),ne=Ff(P.floating,u.y);return a?{...$,transform:"translate("+F+"px, "+ne+"px)",...Lf(P.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:F,top:ne}},[n,a,P.floating,u.x,u.y]);return v.useMemo(()=>({...u,update:W,refs:B,elements:P,floatingStyles:U}),[u,W,B,P,U])}const X0=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?Df({element:r.current,padding:o}).fn(n):{}:r?Df({element:r,padding:o}).fn(n):{}}}},J0=(e,t)=>({...z0(e),options:[e,t]}),Z0=(e,t)=>({...B0(e),options:[e,t]}),Q0=(e,t)=>({...V0(e),options:[e,t]}),eS=(e,t)=>({...H0(e),options:[e,t]}),tS=(e,t)=>({...U0(e),options:[e,t]}),nS=(e,t)=>({...W0(e),options:[e,t]}),rS=(e,t)=>({...X0(e),options:[e,t]});var oS="Arrow",$f=v.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return d.jsx(Oe.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:d.jsx("polygon",{points:"0,0 30,0 15,10"})})});$f.displayName=oS;var sS=$f;function zf(e){const[t,n]=v.useState(void 0);return Bt(()=>{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,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.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 ol="Popper",[Bf,si]=Wn(ol),[iS,Hf]=Bf(ol),Uf=e=>{const{__scopePopper:t,children:n}=e,[r,o]=v.useState(null);return d.jsx(iS,{scope:t,anchor:r,onAnchorChange:o,children:n})};Uf.displayName=ol;var Wf="PopperAnchor",Vf=v.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Hf(Wf,n),i=v.useRef(null),a=Xe(t,i),l=v.useRef(null);return v.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:d.jsx(Oe.div,{...o,ref:a})});Vf.displayName=Wf;var sl="PopperContent",[aS,lS]=Bf(sl),Kf=v.forwardRef((e,t)=>{var Q,D,G,se,ie,ce;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:u=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:g,...y}=e,x=Hf(sl,n),[m,w]=v.useState(null),S=Xe(t,je=>w(je)),[T,k]=v.useState(null),C=zf(T),E=(C==null?void 0:C.width)??0,j=(C==null?void 0:C.height)??0,_=r+(s!=="center"?"-"+s:""),R=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},L=Array.isArray(c)?c:[c],z=L.length>0,W={padding:R,boundary:L.filter(uS),altBoundary:z},{refs:O,floatingStyles:B,placement:P,isPositioned:U,middlewareData:$}=Y0({strategy:"fixed",placement:_,whileElementsMounted:(...je)=>$0(...je,{animationFrame:p==="always"}),elements:{reference:x.anchor},middleware:[J0({mainAxis:o+j,alignmentAxis:i}),l&&Z0({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?Q0():void 0,...W}),l&&eS({...W}),tS({...W,apply:({elements:je,rects:ue,availableWidth:Ze,availableHeight:Je})=>{const{width:Ve,height:lt}=ue.reference,ct=je.floating.style;ct.setProperty("--radix-popper-available-width",`${Ze}px`),ct.setProperty("--radix-popper-available-height",`${Je}px`),ct.setProperty("--radix-popper-anchor-width",`${Ve}px`),ct.setProperty("--radix-popper-anchor-height",`${lt}px`)}}),T&&rS({element:T,padding:a}),dS({arrowWidth:E,arrowHeight:j}),h&&nS({strategy:"referenceHidden",...W})]}),[F,ne]=Yf(P),re=Ht(g);Bt(()=>{U&&(re==null||re())},[U,re]);const ve=(Q=$.arrow)==null?void 0:Q.x,Ie=(D=$.arrow)==null?void 0:D.y,Z=((G=$.arrow)==null?void 0:G.centerOffset)!==0,[q,he]=v.useState();return Bt(()=>{m&&he(window.getComputedStyle(m).zIndex)},[m]),d.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...B,transform:U?B.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:q,"--radix-popper-transform-origin":[(se=$.transformOrigin)==null?void 0:se.x,(ie=$.transformOrigin)==null?void 0:ie.y].join(" "),...((ce=$.hide)==null?void 0:ce.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:d.jsx(aS,{scope:n,placedSide:F,onArrowChange:k,arrowX:ve,arrowY:Ie,shouldHideArrow:Z,children:d.jsx(Oe.div,{"data-side":F,"data-align":ne,...y,ref:S,style:{...y.style,animation:U?void 0:"none"}})})})});Kf.displayName=sl;var qf="PopperArrow",cS={top:"bottom",right:"left",bottom:"top",left:"right"},Gf=v.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=lS(qf,r),i=cS[s.placedSide];return d.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:d.jsx(sS,{...o,ref:n,style:{...o.style,display:"block"}})})});Gf.displayName=qf;function uS(e){return e!==null}var dS=e=>({name:"transformOrigin",options:e,fn(t){var x,m,w;const{placement:n,rects:r,middlewareData:o}=t,i=((x=o.arrow)==null?void 0:x.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[c,u]=Yf(n),f={start:"0%",center:"50%",end:"100%"}[u],h=(((m=o.arrow)==null?void 0:m.x)??0)+a/2,p=(((w=o.arrow)==null?void 0:w.y)??0)+l/2;let g="",y="";return c==="bottom"?(g=i?f:`${h}px`,y=`${-l}px`):c==="top"?(g=i?f:`${h}px`,y=`${r.floating.height+l}px`):c==="right"?(g=`${-l}px`,y=i?f:`${p}px`):c==="left"&&(g=`${r.floating.width+l}px`,y=i?f:`${p}px`),{data:{x:g,y}}}});function Yf(e){const[t,n="center"]=e.split("-");return[t,n]}var Xf=Uf,Jf=Vf,Zf=Kf,Qf=Gf,il="rovingFocusGroup.onEntryFocus",fS={bubbles:!1,cancelable:!0},No="RovingFocusGroup",[al,eh,hS]=Ka(No),[pS,th]=Wn(No,[hS]),[mS,gS]=pS(No),nh=v.forwardRef((e,t)=>d.jsx(al.Provider,{scope:e.__scopeRovingFocusGroup,children:d.jsx(al.Slot,{scope:e.__scopeRovingFocusGroup,children:d.jsx(yS,{...e,ref:t})})}));nh.displayName=No;var yS=v.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:u=!1,...f}=e,h=v.useRef(null),p=Xe(t,h),g=Gs(s),[y,x]=Fr({prop:i,defaultProp:a??null,onChange:l,caller:No}),[m,w]=v.useState(!1),S=Ht(c),T=eh(n),k=v.useRef(!1),[C,E]=v.useState(0);return v.useEffect(()=>{const j=h.current;if(j)return j.addEventListener(il,S),()=>j.removeEventListener(il,S)},[S]),d.jsx(mS,{scope:n,orientation:r,dir:g,loop:o,currentTabStopId:y,onItemFocus:v.useCallback(j=>x(j),[x]),onItemShiftTab:v.useCallback(()=>w(!0),[]),onFocusableItemAdd:v.useCallback(()=>E(j=>j+1),[]),onFocusableItemRemove:v.useCallback(()=>E(j=>j-1),[]),children:d.jsx(Oe.div,{tabIndex:m||C===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:ye(e.onMouseDown,()=>{k.current=!0}),onFocus:ye(e.onFocus,j=>{const _=!k.current;if(j.target===j.currentTarget&&_&&!m){const R=new CustomEvent(il,fS);if(j.currentTarget.dispatchEvent(R),!R.defaultPrevented){const L=T().filter(P=>P.focusable),z=L.find(P=>P.active),W=L.find(P=>P.id===y),B=[z,W,...L].filter(Boolean).map(P=>P.ref.current);sh(B,u)}}k.current=!1}),onBlur:ye(e.onBlur,()=>w(!1))})})}),rh="RovingFocusGroupItem",oh=v.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=Vn(),c=s||l,u=gS(rh,n),f=u.currentTabStopId===c,h=eh(n),{onFocusableItemAdd:p,onFocusableItemRemove:g,currentTabStopId:y}=u;return v.useEffect(()=>{if(r)return p(),()=>g()},[r,p,g]),d.jsx(al.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:d.jsx(Oe.span,{tabIndex:f?0:-1,"data-orientation":u.orientation,...a,ref:t,onMouseDown:ye(e.onMouseDown,x=>{r?u.onItemFocus(c):x.preventDefault()}),onFocus:ye(e.onFocus,()=>u.onItemFocus(c)),onKeyDown:ye(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){u.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const m=wS(x,u.orientation,u.dir);if(m!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let S=h().filter(T=>T.focusable).map(T=>T.ref.current);if(m==="last")S.reverse();else if(m==="prev"||m==="next"){m==="prev"&&S.reverse();const T=S.indexOf(x.currentTarget);S=u.loop?bS(S,T+1):S.slice(T+1)}setTimeout(()=>sh(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:y!=null}):i})})});oh.displayName=rh;var xS={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function vS(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function wS(e,t,n){const r=vS(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return xS[r]}function sh(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function bS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var SS=nh,CS=oh,ll=["Enter"," "],kS=["ArrowDown","PageUp","Home"],ih=["ArrowUp","PageDown","End"],TS=[...kS,...ih],ES={ltr:[...ll,"ArrowRight"],rtl:[...ll,"ArrowLeft"]},IS={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Ao="Menu",[_o,NS,AS]=Ka(Ao),[kr,ah]=Wn(Ao,[AS,si,th]),ii=si(),lh=th(),[_S,Tr]=kr(Ao),[jS,jo]=kr(Ao),ch=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=ii(t),[l,c]=v.useState(null),u=v.useRef(!1),f=Ht(s),h=Gs(o);return v.useEffect(()=>{const p=()=>{u.current=!0,document.addEventListener("pointerdown",g,{capture:!0,once:!0}),document.addEventListener("pointermove",g,{capture:!0,once:!0})},g=()=>u.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",g,{capture:!0}),document.removeEventListener("pointermove",g,{capture:!0})}},[]),d.jsx(Xf,{...a,children:d.jsx(_S,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:c,children:d.jsx(jS,{scope:t,onClose:v.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:u,dir:h,modal:i,children:r})})})};ch.displayName=Ao;var RS="MenuAnchor",cl=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ii(n);return d.jsx(Jf,{...o,...r,ref:t})});cl.displayName=RS;var ul="MenuPortal",[PS,uh]=kr(ul,{forceMount:void 0}),dh=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=Tr(ul,t);return d.jsx(PS,{scope:t,forceMount:n,children:d.jsx(hn,{present:n||s.open,children:d.jsx(Is,{asChild:!0,container:o,children:r})})})};dh.displayName=ul;var pn="MenuContent",[OS,dl]=kr(pn),fh=v.forwardRef((e,t)=>{const n=uh(pn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Tr(pn,e.__scopeMenu),i=jo(pn,e.__scopeMenu);return d.jsx(_o.Provider,{scope:e.__scopeMenu,children:d.jsx(hn,{present:r||s.open,children:d.jsx(_o.Slot,{scope:e.__scopeMenu,children:i.modal?d.jsx(MS,{...o,ref:t}):d.jsx(DS,{...o,ref:t})})})})}),MS=v.forwardRef((e,t)=>{const n=Tr(pn,e.__scopeMenu),r=v.useRef(null),o=Xe(t,r);return v.useEffect(()=>{const s=r.current;if(s)return Fa(s)},[]),d.jsx(fl,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ye(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),DS=v.forwardRef((e,t)=>{const n=Tr(pn,e.__scopeMenu);return d.jsx(fl,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),LS=dr.createSlot("MenuContent.ScrollLock"),fl=v.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:f,onInteractOutside:h,onDismiss:p,disableOutsideScroll:g,...y}=e,x=Tr(pn,n),m=jo(pn,n),w=ii(n),S=lh(n),T=NS(n),[k,C]=v.useState(null),E=v.useRef(null),j=Xe(t,E,x.onContentChange),_=v.useRef(0),R=v.useRef(""),L=v.useRef(0),z=v.useRef(null),W=v.useRef("right"),O=v.useRef(0),B=g?Os:v.Fragment,P=g?{as:LS,allowPinchZoom:!0}:void 0,U=F=>{var Q,D;const ne=R.current+F,re=T().filter(G=>!G.disabled),ve=document.activeElement,Ie=(Q=re.find(G=>G.ref.current===ve))==null?void 0:Q.textValue,Z=re.map(G=>G.textValue),q=YS(Z,ne,Ie),he=(D=re.find(G=>G.textValue===q))==null?void 0:D.ref.current;(function G(se){R.current=se,window.clearTimeout(_.current),se!==""&&(_.current=window.setTimeout(()=>G(""),1e3))})(ne),he&&setTimeout(()=>he.focus())};v.useEffect(()=>()=>window.clearTimeout(_.current),[]),Ra();const $=v.useCallback(F=>{var re,ve;return W.current===((re=z.current)==null?void 0:re.side)&&JS(F,(ve=z.current)==null?void 0:ve.area)},[]);return d.jsx(OS,{scope:n,searchRef:R,onItemEnter:v.useCallback(F=>{$(F)&&F.preventDefault()},[$]),onItemLeave:v.useCallback(F=>{var ne;$(F)||((ne=E.current)==null||ne.focus(),C(null))},[$]),onTriggerLeave:v.useCallback(F=>{$(F)&&F.preventDefault()},[$]),pointerGraceTimerRef:L,onPointerGraceIntentChange:v.useCallback(F=>{z.current=F},[]),children:d.jsx(B,{...P,children:d.jsx(Es,{asChild:!0,trapped:o,onMountAutoFocus:ye(s,F=>{var ne;F.preventDefault(),(ne=E.current)==null||ne.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:d.jsx(Ts,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:f,onInteractOutside:h,onDismiss:p,children:d.jsx(SS,{asChild:!0,...S,dir:m.dir,orientation:"vertical",loop:r,currentTabStopId:k,onCurrentTabStopIdChange:C,onEntryFocus:ye(l,F=>{m.isUsingKeyboardRef.current||F.preventDefault()}),preventScrollOnEntryFocus:!0,children:d.jsx(Zf,{role:"menu","aria-orientation":"vertical","data-state":Ah(x.open),"data-radix-menu-content":"",dir:m.dir,...w,...y,ref:j,style:{outline:"none",...y.style},onKeyDown:ye(y.onKeyDown,F=>{const re=F.target.closest("[data-radix-menu-content]")===F.currentTarget,ve=F.ctrlKey||F.altKey||F.metaKey,Ie=F.key.length===1;re&&(F.key==="Tab"&&F.preventDefault(),!ve&&Ie&&U(F.key));const Z=E.current;if(F.target!==Z||!TS.includes(F.key))return;F.preventDefault();const he=T().filter(Q=>!Q.disabled).map(Q=>Q.ref.current);ih.includes(F.key)&&he.reverse(),qS(he)}),onBlur:ye(e.onBlur,F=>{F.currentTarget.contains(F.target)||(window.clearTimeout(_.current),R.current="")}),onPointerMove:ye(e.onPointerMove,Po(F=>{const ne=F.target,re=O.current!==F.clientX;if(F.currentTarget.contains(ne)&&re){const ve=F.clientX>O.current?"right":"left";W.current=ve,O.current=F.clientX}}))})})})})})})});fh.displayName=pn;var FS="MenuGroup",hl=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return d.jsx(Oe.div,{role:"group",...r,ref:t})});hl.displayName=FS;var $S="MenuLabel",hh=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return d.jsx(Oe.div,{...r,ref:t})});hh.displayName=$S;var ai="MenuItem",ph="menu.itemSelect",li=v.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=v.useRef(null),i=jo(ai,e.__scopeMenu),a=dl(ai,e.__scopeMenu),l=Xe(t,s),c=v.useRef(!1),u=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(ph,{bubbles:!0,cancelable:!0});f.addEventListener(ph,p=>r==null?void 0:r(p),{once:!0}),id(f,h),h.defaultPrevented?c.current=!1:i.onClose()}};return d.jsx(mh,{...o,ref:l,disabled:n,onClick:ye(e.onClick,u),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),c.current=!0},onPointerUp:ye(e.onPointerUp,f=>{var h;c.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:ye(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||ll.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});li.displayName=ai;var mh=v.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=dl(ai,n),a=lh(n),l=v.useRef(null),c=Xe(t,l),[u,f]=v.useState(!1),[h,p]=v.useState("");return v.useEffect(()=>{const g=l.current;g&&p((g.textContent??"").trim())},[s.children]),d.jsx(_o.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:d.jsx(CS,{asChild:!0,...a,focusable:!r,children:d.jsx(Oe.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:ye(e.onPointerMove,Po(g=>{r?i.onItemLeave(g):(i.onItemEnter(g),g.defaultPrevented||g.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ye(e.onPointerLeave,Po(g=>i.onItemLeave(g))),onFocus:ye(e.onFocus,()=>f(!0)),onBlur:ye(e.onBlur,()=>f(!1))})})})}),zS="MenuCheckboxItem",gh=v.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return d.jsx(bh,{scope:e.__scopeMenu,checked:n,children:d.jsx(li,{role:"menuitemcheckbox","aria-checked":ci(n)?"mixed":n,...o,ref:t,"data-state":ml(n),onSelect:ye(o.onSelect,()=>r==null?void 0:r(ci(n)?!0:!n),{checkForDefaultPrevented:!1})})})});gh.displayName=zS;var yh="MenuRadioGroup",[BS,HS]=kr(yh,{value:void 0,onValueChange:()=>{}}),xh=v.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=Ht(r);return d.jsx(BS,{scope:e.__scopeMenu,value:n,onValueChange:s,children:d.jsx(hl,{...o,ref:t})})});xh.displayName=yh;var vh="MenuRadioItem",wh=v.forwardRef((e,t)=>{const{value:n,...r}=e,o=HS(vh,e.__scopeMenu),s=n===o.value;return d.jsx(bh,{scope:e.__scopeMenu,checked:s,children:d.jsx(li,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":ml(s),onSelect:ye(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});wh.displayName=vh;var pl="MenuItemIndicator",[bh,US]=kr(pl,{checked:!1}),Sh=v.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=US(pl,n);return d.jsx(hn,{present:r||ci(s.checked)||s.checked===!0,children:d.jsx(Oe.span,{...o,ref:t,"data-state":ml(s.checked)})})});Sh.displayName=pl;var WS="MenuSeparator",Ch=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return d.jsx(Oe.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Ch.displayName=WS;var VS="MenuArrow",kh=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ii(n);return d.jsx(Qf,{...o,...r,ref:t})});kh.displayName=VS;var KS="MenuSub",[_T,Th]=kr(KS),Ro="MenuSubTrigger",Eh=v.forwardRef((e,t)=>{const n=Tr(Ro,e.__scopeMenu),r=jo(Ro,e.__scopeMenu),o=Th(Ro,e.__scopeMenu),s=dl(Ro,e.__scopeMenu),i=v.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},u=v.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return v.useEffect(()=>u,[u]),v.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),d.jsx(cl,{asChild:!0,...c,children:d.jsx(mh,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Ah(n.open),...e,ref:Ia(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:ye(e.onPointerMove,Po(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:ye(e.onPointerLeave,Po(f=>{var p,g;u();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const y=(g=n.content)==null?void 0:g.dataset.side,x=y==="right",m=x?-5:5,w=h[x?"left":"right"],S=h[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+m,y:f.clientY},{x:w,y:h.top},{x:S,y:h.top},{x:S,y:h.bottom},{x:w,y:h.bottom}],side:y}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ye(e.onKeyDown,f=>{var p;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||ES[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});Eh.displayName=Ro;var Ih="MenuSubContent",Nh=v.forwardRef((e,t)=>{const n=uh(pn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Tr(pn,e.__scopeMenu),i=jo(pn,e.__scopeMenu),a=Th(Ih,e.__scopeMenu),l=v.useRef(null),c=Xe(t,l);return d.jsx(_o.Provider,{scope:e.__scopeMenu,children:d.jsx(hn,{present:r||s.open,children:d.jsx(_o.Slot,{scope:e.__scopeMenu,children:d.jsx(fl,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var f;i.isUsingKeyboardRef.current&&((f=l.current)==null||f.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:ye(e.onFocusOutside,u=>{u.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ye(e.onEscapeKeyDown,u=>{i.onClose(),u.preventDefault()}),onKeyDown:ye(e.onKeyDown,u=>{var p;const f=u.currentTarget.contains(u.target),h=IS[i.dir].includes(u.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),u.preventDefault())})})})})})});Nh.displayName=Ih;function Ah(e){return e?"open":"closed"}function ci(e){return e==="indeterminate"}function ml(e){return ci(e)?"indeterminate":e?"checked":"unchecked"}function qS(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function GS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function YS(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=GS(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function XS(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],c=a.x,u=a.y,f=l.x,h=l.y;u>r!=h>r&&n<(f-c)*(r-u)/(h-u)+c&&(o=!o)}return o}function JS(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return XS(n,t)}function Po(e){return t=>t.pointerType==="mouse"?e(t):void 0}var ZS=ch,QS=cl,eC=dh,tC=fh,nC=hl,rC=hh,oC=li,sC=gh,iC=xh,aC=wh,lC=Sh,cC=Ch,uC=kh,dC=Eh,fC=Nh,ui="DropdownMenu",[hC,jT]=Wn(ui,[ah]),Qt=ah(),[pC,_h]=hC(ui),jh=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Qt(t),c=v.useRef(null),[u,f]=Fr({prop:o,defaultProp:s??!1,onChange:i,caller:ui});return d.jsx(pC,{scope:t,triggerId:Vn(),triggerRef:c,contentId:Vn(),open:u,onOpenChange:f,onOpenToggle:v.useCallback(()=>f(h=>!h),[f]),modal:a,children:d.jsx(ZS,{...l,open:u,onOpenChange:f,dir:r,modal:a,children:n})})};jh.displayName=ui;var Rh="DropdownMenuTrigger",Ph=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=_h(Rh,n),i=Qt(n);return d.jsx(QS,{asChild:!0,...i,children:d.jsx(Oe.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:Ia(t,s.triggerRef),onPointerDown:ye(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ye(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Ph.displayName=Rh;var mC="DropdownMenuPortal",Oh=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Qt(t);return d.jsx(eC,{...r,...n})};Oh.displayName=mC;var Mh="DropdownMenuContent",Dh=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=_h(Mh,n),s=Qt(n),i=v.useRef(!1);return d.jsx(tC,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ye(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ye(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;(!o.modal||u)&&(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)"}})});Dh.displayName=Mh;var gC="DropdownMenuGroup",yC=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qt(n);return d.jsx(nC,{...o,...r,ref:t})});yC.displayName=gC;var xC="DropdownMenuLabel",Lh=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qt(n);return d.jsx(rC,{...o,...r,ref:t})});Lh.displayName=xC;var vC="DropdownMenuItem",Fh=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qt(n);return d.jsx(oC,{...o,...r,ref:t})});Fh.displayName=vC;var wC="DropdownMenuCheckboxItem",$h=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qt(n);return d.jsx(sC,{...o,...r,ref:t})});$h.displayName=wC;var bC="DropdownMenuRadioGroup",SC=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qt(n);return d.jsx(iC,{...o,...r,ref:t})});SC.displayName=bC;var CC="DropdownMenuRadioItem",zh=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qt(n);return d.jsx(aC,{...o,...r,ref:t})});zh.displayName=CC;var kC="DropdownMenuItemIndicator",Bh=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qt(n);return d.jsx(lC,{...o,...r,ref:t})});Bh.displayName=kC;var TC="DropdownMenuSeparator",Hh=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qt(n);return d.jsx(cC,{...o,...r,ref:t})});Hh.displayName=TC;var EC="DropdownMenuArrow",IC=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qt(n);return d.jsx(uC,{...o,...r,ref:t})});IC.displayName=EC;var NC="DropdownMenuSubTrigger",Uh=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qt(n);return d.jsx(dC,{...o,...r,ref:t})});Uh.displayName=NC;var AC="DropdownMenuSubContent",Wh=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qt(n);return d.jsx(fC,{...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)"}})});Wh.displayName=AC;var _C=jh,jC=Ph,RC=Oh,Vh=Dh,Kh=Lh,qh=Fh,Gh=$h,Yh=zh,Xh=Bh,Jh=Hh,Zh=Uh,Qh=Wh;const PC=_C,OC=jC,MC=v.forwardRef(({className:e,inset:t,children:n,...r},o)=>d.jsxs(Zh,{ref:o,className:oe("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,d.jsx(fe.ChevronRight,{className:"ml-auto h-4 w-4"})]}));MC.displayName=Zh.displayName;const DC=v.forwardRef(({className:e,...t},n)=>d.jsx(Qh,{ref:n,className:oe("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}));DC.displayName=Qh.displayName;const ep=v.forwardRef(({className:e,sideOffset:t=4,...n},r)=>d.jsx(RC,{children:d.jsx(Vh,{ref:r,sideOffset:t,className:oe("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})}));ep.displayName=Vh.displayName;const gl=v.forwardRef(({className:e,inset:t,...n},r)=>d.jsx(qh,{ref:r,className:oe("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}));gl.displayName=qh.displayName;const LC=v.forwardRef(({className:e,children:t,checked:n,...r},o)=>d.jsxs(Gh,{ref:o,className:oe("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:[d.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:d.jsx(Xh,{children:d.jsx(fe.Check,{className:"h-4 w-4"})})}),t]}));LC.displayName=Gh.displayName;const FC=v.forwardRef(({className:e,children:t,...n},r)=>d.jsxs(Yh,{ref:r,className:oe("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:[d.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:d.jsx(Xh,{children:d.jsx(fe.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));FC.displayName=Yh.displayName;const $C=v.forwardRef(({className:e,inset:t,...n},r)=>d.jsx(Kh,{ref:r,className:oe("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));$C.displayName=Kh.displayName;const zC=v.forwardRef(({className:e,...t},n)=>d.jsx(Jh,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));zC.displayName=Jh.displayName;const tp={value:""};function di({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:c=!0,showToolMessages:u=!0,customStyles:f={},onMessageSent:h,onExcelUploadSuccess:p,onError:g}){const{api:y}=Fi(),{currentThreadId:x}=is(),{threadId:m,messages:w,hasMore:S,isHistoryLoading:T,isLoading:k,loadOlder:C,navigateToCheckpoint:E,returnToLatest:j,checkpoint:_,checkpoints:R,interrupt:L,metadata:z}=as(),{isStreaming:W,error:O,connectionState:B,submit:P,stop:U}=Zc(),$=m??x??null,F=(_==null?void 0:_.id)??null,ne=(_==null?void 0:_.namespace)??null,re=(z==null?void 0:z.assemblingMessageId)??null,ve=L,[Ie,Z]=b.useState(!1);b.useEffect(()=>{ve||Z(!1)},[ve]);const q=b.useCallback(()=>{Z(!0)},[]),he=b.useCallback(()=>{Z(!1)},[]),Q=!!ve||Ie,[D,G]=b.useState(null),[se,ie]=b.useState(""),[ce,je]=b.useState(null),[ue,Ze]=b.useState([]),[Je,Ve]=b.useState(0),[lt,ct]=b.useState(0),[Qe,be]=b.useState(!1),[ut,dt]=b.useState(null),[nt,rt]=b.useState(null),[Tt,wt]=b.useState(!1),[Lt,_t]=b.useState(null),[bt,Ge]=b.useState(!1),jt=b.useRef(!1),[Et,Xt]=b.useState(()=>tp.value),En=b.useRef(Et),Ke=b.useRef(null),Ee=b.useCallback(X=>{tp.value=X,Xt(X)},[]),[$t,Ft]=b.useState(!1),V=b.useCallback((X,de)=>{if(!X||typeof X!="object")return null;const xe=X[de];return typeof xe=="number"?xe:null},[]),Ce=b.useCallback((X,de)=>{if(!X||typeof X!="object")return null;const xe=X[de];return typeof xe=="string"&&xe.trim()?xe:null},[]),ge=b.useMemo(()=>{const X=Array.isArray(R)?[...R]:[];return X.some(xe=>V(xe.metadata,"step")!==null)&&X.sort((xe,He)=>{const Ct=V(xe.metadata,"step"),Jt=V(He.metadata,"step");if(Ct!==null||Jt!==null)return(Jt??Number.NEGATIVE_INFINITY)-(Ct??Number.NEGATIVE_INFINITY);const Fn=Date.parse(xe.createdAt??""),jr=Date.parse(He.createdAt??"");return Number.isNaN(Fn)||Number.isNaN(jr)?0:jr-Fn}),X},[R,V]),{checkpointMetaById:gt,checkpointIndexByKey:St}=b.useMemo(()=>{const X=new Map,de=new Map;for(const xe of ge){const He=xe.checkpointId??null;if(!He)continue;const Ct=V(xe.metadata,"step"),Jt=Ce(xe.metadata,"source"),Fn={id:He,step:Ct,source:Jt,createdAt:xe.createdAt??null,namespace:xe.checkpointNs??null,parentId:xe.parentId??null};if(X.set(He,Fn),Ct!==null&&Jt){const jr=`${Ct}:${Jt}`,Mo=de.get(jr)??[];Mo.push(Fn),de.set(jr,Mo)}}for(const xe of de.values())xe.sort((He,Ct)=>{const Jt=He.createdAt??"";return(Ct.createdAt??"").localeCompare(Jt)});return{checkpointMetaById:X,checkpointIndexByKey:de}},[ge,V,Ce]),it=b.useRef(null),Pe=b.useRef(null),Mt=b.useCallback(()=>{it.current&&(it.current.value=""),Pe.current&&(Pe.current.value=""),Ve(X=>X+1),ct(X=>X+1)},[]),De=b.useCallback(X=>{Ee(X)},[Ee]),ft=b.useRef(!1);b.useEffect(()=>{ft.current&&!W&&(Ze([]),Mt()),ft.current=W},[W,Mt]);const[ar,Xr]=b.useState("desktop");b.useEffect(()=>{const X=()=>{const de=window.innerWidth;Xr(de<640?"phone":de<1024?"tablet":"desktop")};return X(),window.addEventListener("resize",X),()=>window.removeEventListener("resize",X)},[]),b.useEffect(()=>{Ge(!1),jt.current=!1},[$]),b.useEffect(()=>{En.current=Et},[Et]),b.useEffect(()=>{if(!D){Ke.current=null;return}Ke.current===null&&(Ke.current=En.current),Ee(se??"")},[se,D,Ee]);const lr=b.useCallback(async()=>{if(!(!S||T||!bt))try{await C()}catch(X){console.warn("loadOlder failed",X)}},[S,bt,T,C]);b.useEffect(()=>{(async()=>{if(!y.baseUrl){_t(null);return}try{const xe=(await y.getAgent("default")).uiDefaultMessage||"";_t(xe||null)}catch(de){console.warn("Failed to fetch default message:",de),_t(null)}})()},[y.baseUrl]),b.useEffect(()=>{O&&!Tt&&(g==null||g(O))},[O,Tt,g]);const Ar=X=>{if(X.length>qs)return`Message too long (${X.length}/${qs} characters)`;try{return Kb(X),null}catch(de){return(de==null?void 0:de.message)||"Invalid message"}},_r=async X=>{const de=X.trim();if(!(!de&&ue.length===0)){if(de){const xe=Ar(de);if(xe){je(xe);return}}try{await P({text:de||"",attachments:ue,payload:D?{edit:!0,originalMessageId:D}:void 0},{checkpointId:F??void 0,checkpointNs:ne??void 0}),h==null||h(de),Ee(""),je(null),Ze([]),Mt(),G(null),ie("")}catch(xe){const He=(xe==null?void 0:xe.message)||"Failed to send message";je(He),g==null||g(He)}}},Ln=b.useCallback((X,de)=>{c&&(Ke.current=Et,G(X),ie(de),Ee(de),je(null))},[Et,c,Ee]),cr=b.useCallback(()=>{G(null),ie(""),je(null),Ee(Ke.current??Et),Ke.current=null},[Et,Ee]),I=b.useCallback((X,de)=>{Ln(X,de)},[Ln]),Y=b.useCallback(X=>{for(let de=X-1;de>=0;de--)if(w[de].role==="user"){const xe=w[de].content||[],Ct=xe.filter(Jt=>Jt.type==="text").map(Jt=>Jt.text).join("")||(()=>{try{return JSON.stringify(xe,null,2)}catch{return String(xe)}})();Ct&&P({text:Ct},{checkpointId:F??void 0,checkpointNs:ne??void 0});break}},[w,P,F,ne]),le=X=>{const de=Array.from(X.target.files||[]);Ze(xe=>[...xe,...de]),X.target.value=""},Se=X=>{Ze(de=>{const xe=de.filter((He,Ct)=>X!==Ct);return xe.length===0&&Mt(),xe})},We=async X=>{const de=(X.target.files||[])[0];if(de){dt(null),rt(null),be(!0);try{await P({attachments:[de]},{checkpointId:F??void 0,checkpointNs:ne??void 0});const xe=`Uploaded ${de.name} - processing through chat stream`;rt(xe)}catch(xe){const He=xe instanceof Error?xe.message:"Failed to upload Excel file";console.error("Excel upload failed",xe),dt(He),g==null||g(He)}finally{be(!1),X.target.value="",Mt()}}},et=async X=>{if(x){Ft(!0);try{if(!X){await j();return}const de=ge.find(He=>He.checkpointId===X),xe=(de==null?void 0:de.checkpointNs)??null;await E(X,xe)}finally{Ft(!1)}}},Be=b.useCallback(async X=>{await et(X)},[et]),Fe=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${f.container||""}`,It=`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 ${f.messagesArea||""}`,yt=`flex-shrink-0 w-full border-t p-4 bg-transparent ${f.inputArea||""}`,ht=b.useCallback(X=>{if(!X)return"Latest";const de=[];X.step!==null&&de.push(`Step ${X.step}`),X.source&&de.push(X.source);const xe=X.createdAt?new Date(X.createdAt):null,He=xe&&!Number.isNaN(xe.getTime())?xe.toLocaleString():X.createdAt??X.id,Ct=de.length?` — ${de.join(" • ")}`:"";return`${He}${Ct}`},[]);return d.jsxs("div",{className:Fe,children:[!!O&&!Tt&&d.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:[d.jsx("span",{children:O}),d.jsx(ot,{variant:"ghost",size:"sm",onClick:()=>wt(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:d.jsx(fe.X,{size:16})})]}),x&&ge.length>0&&d.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:[d.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),d.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:F??"",onChange:X=>{const de=X.target.value||null;et(de)},children:[d.jsx("option",{value:"",children:"Latest"}),ge.map(X=>{const de=gt.get(X.checkpointId??"")??null;return d.jsx("option",{value:X.checkpointId??void 0,children:ht(de)},X.checkpointId)})]})]}),d.jsxs("div",{className:`relative ${It}`,style:r?{maxHeight:r}:void 0,children:[d.jsx(Va,{className:"h-full",style:{height:"100%"},messages:w,isStreaming:W,streamingAssistantId:re,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:ar,enableMessageEditing:c,editingMessageId:D,onStartReached:()=>{bt&&lr()},onScrollAway:X=>{if(!jt.current){jt.current=!0;return}X&&Ge(!0)},onEdit:I,onRegenerate:Y,onCancelEdit:cr,emptyMessage:Lt??void 0,isNavigatingCheckpoint:$t,activeInterrupt:ve,disableInterruptActions:Ie,onInterruptActionStart:q,onInterruptActionEnd:he,showToolMessages:u,checkpointMetaById:gt,checkpointIndexByKey:St,activeCheckpointId:F,onSelectCheckpoint:Be}),(B==="reconnecting"||B==="connecting")&&d.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:d.jsxs("span",{className:"flex items-center gap-2",children:[d.jsx(fe.Loader2,{className:"h-3 w-3 animate-spin"}),B==="reconnecting"?"Reconnecting…":"Connecting…"]})}),B==="error"&&d.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),k&&d.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:[d.jsx(fe.Loader2,{className:"h-6 w-6 animate-spin"}),d.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]})]}),d.jsxs("div",{className:yt,children:[D&&d.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(fe.Edit3,{size:16,className:"text-blue-600"}),d.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),d.jsx(ot,{variant:"ghost",size:"sm",onClick:cr,className:"text-blue-600 hover:bg-blue-100",children:d.jsx(fe.X,{size:16})})]})}),(a||l)&&d.jsxs("div",{className:"mb-3 space-y-3",children:[a&&d.jsxs(d.Fragment,{children:[d.jsx("input",{ref:it,type:"file",multiple:!0,onChange:X=>le(X),className:"hidden"},Je),ue.length>0&&d.jsx("div",{className:"flex flex-wrap gap-2",children:ue.map((X,de)=>d.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:[d.jsx(fe.Paperclip,{size:14}),d.jsx("span",{className:"truncate max-w-[150px]",children:X.name}),d.jsx(ot,{variant:"ghost",size:"sm",onClick:()=>Se(de),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 ${X.name}`,children:d.jsx(fe.X,{size:12})})]},de))})]}),l&&d.jsxs(d.Fragment,{children:[d.jsx("input",{ref:Pe,type:"file",accept:".xls,.xlsx,.xlsm",onChange:We,className:"hidden"},lt),Qe&&d.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[d.jsx(fe.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),nt&&!Qe&&d.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:nt}),ut&&!Qe&&d.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:ut})]})]}),ce&&d.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:ce}),d.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&d.jsxs(PC,{children:[d.jsx(OC,{asChild:!0,children:d.jsx(ot,{type:"button",size:"icon",variant:"outline",disabled:W||Q,title:"More input actions",className:f.moreButton||"",children:d.jsx(fe.Plus,{size:16})})}),d.jsxs(ep,{align:"start",sideOffset:6,className:"w-52",children:[a&&d.jsxs(gl,{onClick:()=>{var X;return(X=it.current)==null?void 0:X.click()},className:"cursor-pointer",children:[d.jsx(fe.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&d.jsxs(gl,{onClick:()=>{var X;Qe||(X=Pe.current)==null||X.click()},className:`cursor-pointer ${Qe?"opacity-60 pointer-events-none":""}`,children:[d.jsx(fe.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),d.jsx("div",{className:"flex-1",children:d.jsx(dx,{initialValue:se,editingMessageId:D,value:Et,onValueChange:De,placeholder:D?"Edit your message...":t,isStreaming:W,disabled:Q,maxLength:qs,onSend:_r,onCancelEdit:cr,onStop:U,allowEmptySend:ue.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${D?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${ce?"border-red-400":""} ${f.textarea||""}`})})]})]})]})}const fi=v.forwardRef(({className:e,type:t,...n},r)=>d.jsx("input",{type:t,className:oe("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}));fi.displayName="Input";function yl(e,[t,n]){return Math.min(n,Math.max(t,e))}function BC(e,t){return v.useReducer((n,r)=>t[n][r]??n,e)}var xl="ScrollArea",[np,RT]=Wn(xl),[HC,mn]=np(xl),rp=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=v.useState(null),[c,u]=v.useState(null),[f,h]=v.useState(null),[p,g]=v.useState(null),[y,x]=v.useState(null),[m,w]=v.useState(0),[S,T]=v.useState(0),[k,C]=v.useState(!1),[E,j]=v.useState(!1),_=Xe(t,L=>l(L)),R=Gs(o);return d.jsx(HC,{scope:n,type:r,dir:R,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:u,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:g,scrollbarXEnabled:k,onScrollbarXEnabledChange:C,scrollbarY:y,onScrollbarYChange:x,scrollbarYEnabled:E,onScrollbarYEnabledChange:j,onCornerWidthChange:w,onCornerHeightChange:T,children:d.jsx(Oe.div,{dir:R,...i,ref:_,style:{position:"relative","--radix-scroll-area-corner-width":m+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});rp.displayName=xl;var op="ScrollAreaViewport",sp=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=mn(op,n),a=v.useRef(null),l=Xe(t,a,i.onViewportChange);return d.jsxs(d.Fragment,{children:[d.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}),d.jsx(Oe.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:d.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});sp.displayName=op;var Dn="ScrollAreaScrollbar",vl=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=mn(Dn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return v.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?d.jsx(UC,{...r,ref:t,forceMount:n}):o.type==="scroll"?d.jsx(WC,{...r,ref:t,forceMount:n}):o.type==="auto"?d.jsx(ip,{...r,ref:t,forceMount:n}):o.type==="always"?d.jsx(wl,{...r,ref:t}):null});vl.displayName=Dn;var UC=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=mn(Dn,e.__scopeScrollArea),[s,i]=v.useState(!1);return v.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},u=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",u),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",u)}}},[o.scrollArea,o.scrollHideDelay]),d.jsx(hn,{present:n||s,children:d.jsx(ip,{"data-state":s?"visible":"hidden",...r,ref:t})})}),WC=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=mn(Dn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=gi(()=>l("SCROLL_END"),100),[a,l]=BC("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 v.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),v.useEffect(()=>{const c=o.viewport,u=s?"scrollLeft":"scrollTop";if(c){let f=c[u];const h=()=>{const p=c[u];f!==p&&(l("SCROLL"),i()),f=p};return c.addEventListener("scroll",h),()=>c.removeEventListener("scroll",h)}},[o.viewport,s,l,i]),d.jsx(hn,{present:n||a!=="hidden",children:d.jsx(wl,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ye(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ye(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),ip=v.forwardRef((e,t)=>{const n=mn(Dn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=v.useState(!1),a=e.orientation==="horizontal",l=gi(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,u=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:u)}},10);return qr(n.viewport,l),qr(n.content,l),d.jsx(hn,{present:r||s,children:d.jsx(wl,{"data-state":s?"visible":"hidden",...o,ref:t})})}),wl=v.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=mn(Dn,e.__scopeScrollArea),s=v.useRef(null),i=v.useRef(0),[a,l]=v.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=dp(a.viewport,a.content),u={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function f(h,p){return XC(h,i.current,a,p)}return n==="horizontal"?d.jsx(VC,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=fp(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"?d.jsx(KC,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=fp(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}),VC=v.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=mn(Dn,e.__scopeScrollArea),[i,a]=v.useState(),l=v.useRef(null),c=Xe(t,l,s.onScrollbarXChange);return v.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),d.jsx(lp,{"data-orientation":"horizontal",...o,ref:c,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":mi(n)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.x),onDragScroll:u=>e.onDragScroll(u.x),onWheelScroll:(u,f)=>{if(s.viewport){const h=s.viewport.scrollLeft+u.deltaX;e.onWheelScroll(h),pp(h,f)&&u.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:pi(i.paddingLeft),paddingEnd:pi(i.paddingRight)}})}})}),KC=v.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=mn(Dn,e.__scopeScrollArea),[i,a]=v.useState(),l=v.useRef(null),c=Xe(t,l,s.onScrollbarYChange);return v.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),d.jsx(lp,{"data-orientation":"vertical",...o,ref:c,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":mi(n)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.y),onDragScroll:u=>e.onDragScroll(u.y),onWheelScroll:(u,f)=>{if(s.viewport){const h=s.viewport.scrollTop+u.deltaY;e.onWheelScroll(h),pp(h,f)&&u.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:pi(i.paddingTop),paddingEnd:pi(i.paddingBottom)}})}})}),[qC,ap]=np(Dn),lp=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:u,onResize:f,...h}=e,p=mn(Dn,n),[g,y]=v.useState(null),x=Xe(t,_=>y(_)),m=v.useRef(null),w=v.useRef(""),S=p.viewport,T=r.content-r.viewport,k=Ht(u),C=Ht(l),E=gi(f,10);function j(_){if(m.current){const R=_.clientX-m.current.left,L=_.clientY-m.current.top;c({x:R,y:L})}}return v.useEffect(()=>{const _=R=>{const L=R.target;(g==null?void 0:g.contains(L))&&k(R,T)};return document.addEventListener("wheel",_,{passive:!1}),()=>document.removeEventListener("wheel",_,{passive:!1})},[S,g,T,k]),v.useEffect(C,[r,C]),qr(g,E),qr(p.content,E),d.jsx(qC,{scope:n,scrollbar:g,hasThumb:o,onThumbChange:Ht(s),onThumbPointerUp:Ht(i),onThumbPositionChange:C,onThumbPointerDown:Ht(a),children:d.jsx(Oe.div,{...h,ref:x,style:{position:"absolute",...h.style},onPointerDown:ye(e.onPointerDown,_=>{_.button===0&&(_.target.setPointerCapture(_.pointerId),m.current=g.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),j(_))}),onPointerMove:ye(e.onPointerMove,j),onPointerUp:ye(e.onPointerUp,_=>{const R=_.target;R.hasPointerCapture(_.pointerId)&&R.releasePointerCapture(_.pointerId),document.body.style.webkitUserSelect=w.current,p.viewport&&(p.viewport.style.scrollBehavior=""),m.current=null})})})}),hi="ScrollAreaThumb",cp=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=ap(hi,e.__scopeScrollArea);return d.jsx(hn,{present:n||o.hasThumb,children:d.jsx(GC,{ref:t,...r})})}),GC=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=mn(hi,n),i=ap(hi,n),{onThumbPositionChange:a}=i,l=Xe(t,f=>i.onThumbChange(f)),c=v.useRef(void 0),u=gi(()=>{c.current&&(c.current(),c.current=void 0)},100);return v.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(u(),!c.current){const p=JC(f,a);c.current=p,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,u,a]),d.jsx(Oe.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:ye(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),g=f.clientX-p.left,y=f.clientY-p.top;i.onThumbPointerDown({x:g,y})}),onPointerUp:ye(e.onPointerUp,i.onThumbPointerUp)})});cp.displayName=hi;var bl="ScrollAreaCorner",up=v.forwardRef((e,t)=>{const n=mn(bl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?d.jsx(YC,{...e,ref:t}):null});up.displayName=bl;var YC=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=mn(bl,n),[s,i]=v.useState(0),[a,l]=v.useState(0),c=!!(s&&a);return qr(o.scrollbarX,()=>{var f;const u=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(u),l(u)}),qr(o.scrollbarY,()=>{var f;const u=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(u),i(u)}),c?d.jsx(Oe.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 pi(e){return e?parseInt(e,10):0}function dp(e,t){const n=e/t;return isNaN(n)?0:n}function mi(e){const t=dp(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function XC(e,t,n,r="ltr"){const o=mi(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,u=n.content-n.viewport,f=r==="ltr"?[0,u]:[u*-1,0];return hp([l,c],f)(e)}function fp(e,t,n="ltr"){const r=mi(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],c=yl(e,l);return hp([0,i],[0,a])(c)}function hp(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 pp(e,t){return e>0&&e<t}var JC=(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 gi(e,t){const n=Ht(e),r=v.useRef(0);return v.useEffect(()=>()=>window.clearTimeout(r.current),[]),v.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function qr(e,t){const n=Ht(t);Bt(()=>{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 mp=rp,ZC=sp,QC=up;const gp=v.forwardRef(({className:e,children:t,...n},r)=>d.jsxs(mp,{ref:r,className:oe("relative overflow-hidden",e),...n,children:[d.jsx(ZC,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),d.jsx(yp,{}),d.jsx(QC,{})]}));gp.displayName=mp.displayName;const yp=v.forwardRef(({className:e,orientation:t="vertical",...n},r)=>d.jsx(vl,{ref:r,orientation:t,className:oe("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:d.jsx(cp,{className:"relative flex-1 rounded-full bg-border"})}));yp.displayName=vl.displayName;const xp=25;function Sl({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:u}){const{threads:f,currentThreadId:h,isLoading:p,actions:g}=is(),{loadThread:y}=as(),{createThread:x,deleteThread:m,renameThread:w}=g,[S,T]=b.useState(Array.isArray(f)?f:[]),k=b.useRef(S.length>0),C=b.useRef(null),E=b.useRef(0),[j,_]=b.useState(null),[R,L]=b.useState(""),[z,W]=b.useState(!1);b.useEffect(()=>{const Z=Array.isArray(f)?f:[];if(Z.length>0){k.current=!0,T(Z);return}p||(k.current=!1,T(Z))},[f,p]),b.useEffect(()=>{if(!C.current)return;const Z=C.current.querySelector("[data-radix-scroll-area-viewport]");if(!Z)return;let q=null,he=null;return q=requestAnimationFrame(()=>{he=requestAnimationFrame(()=>{Z.scrollTop=E.current})}),()=>{q!==null&&cancelAnimationFrame(q),he!==null&&cancelAnimationFrame(he)}},[S]);const O=async Z=>{try{await y(Z),a==null||a(Z),l==null||l(Z)}catch(q){console.error("Failed to select thread:",q)}},B=async()=>{try{W(!0);const Z=await x();c==null||c(Z),a==null||a(Z)}catch(Z){console.error("Failed to create thread:",Z)}finally{W(!1)}},P=async(Z,q)=>{if(q.stopPropagation(),!!confirm("Delete this thread?")){if(C.current){const he=C.current.querySelector("[data-radix-scroll-area-viewport]");he&&(E.current=he.scrollTop)}try{await m(Z),u==null||u(Z)}catch(he){console.error("Failed to delete thread:",he)}}},U=(Z,q)=>{q.stopPropagation(),_(Z.threadId),L(Z.title||`Thread ${Z.threadId.slice(0,8)}`)},$=async Z=>{if(R.trim())try{await w(Z,R.trim()),_(null),L("")}catch(q){console.error("Failed to update title:",q)}},F=()=>{_(null),L("")},ne=(Z,q)=>{Z.key==="Enter"?$(q):Z.key==="Escape"&&F()},re=Z=>{if(!Z)return"";try{const q=new Date(Z),Q=new Date().getTime()-q.getTime(),D=Math.floor(Q/(1e3*60*60*24));return D===0?q.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):D===1?"Yesterday":D<7?`${D} days ago`:q.toLocaleDateString()}catch{return""}},ve=Z=>Z.title||`Thread ${Z.threadId.slice(0,8)}`,Ie=Z=>{const q=ve(Z);return q.length<=xp?q:`${q.slice(0,xp)}...`};return d.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&d.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:d.jsx(ot,{onClick:B,disabled:z||p,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:z?"Creating...":"New Chat",children:d.jsx(fe.MessageSquarePlus,{size:20})})}),d.jsx(gp,{ref:C,className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:d.jsx("div",{className:"p-2 space-y-1 pb-4",children:p?d.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[d.jsx(fe.Loader2,{className:"h-5 w-5 animate-spin"}),d.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):S.length===0?d.jsxs("div",{className:"text-center py-8 text-slate-400",children:[d.jsx(fe.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),d.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):S.slice().sort((Z,q)=>new Date(q.updatedAt||q.createdAt||"").getTime()-new Date(Z.updatedAt||Z.createdAt||"").getTime()).map(Z=>d.jsxs("div",{onClick:()=>O(Z.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??h)===Z.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:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("div",{className:"flex-1 min-w-0",children:j===Z.threadId?d.jsxs("div",{className:"flex items-center gap-2",onClick:q=>q.stopPropagation(),children:[d.jsx(fi,{value:R,onChange:q=>L(q.target.value),onKeyDown:q=>ne(q,Z.threadId),className:"h-6 text-sm",autoFocus:!0}),d.jsx(ot,{variant:"ghost",size:"sm",onClick:()=>$(Z.threadId),className:"h-6 w-6 p-0",children:d.jsx(fe.Check,{size:12})}),d.jsx(ot,{variant:"ghost",size:"sm",onClick:F,className:"h-6 w-6 p-0",children:d.jsx(fe.X,{size:12})})]}):d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:Ie(Z)}),d.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[d.jsx(fe.Calendar,{size:10}),d.jsx("span",{children:re(Z.updatedAt||Z.createdAt)})]})]})}),d.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&j!==Z.threadId&&d.jsx(ot,{variant:"ghost",size:"sm",onClick:q=>U(Z,q),className:"h-6 w-6 p-0",title:"Edit title",children:d.jsx(fe.Edit3,{size:12})}),n&&d.jsx(ot,{variant:"ghost",size:"sm",onClick:q=>P(Z.threadId,q),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:d.jsx(fe.Trash2,{size:12})})]})]}),i===Z.threadId&&d.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},Z.threadId))})})]})}function Gr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function ek(e){if(typeof e!="string")return;const t=e.trim();if(t)return Hn(t)}function vp(){const e=[Gr("__API_BASE_URL__"),Gr("__CHAT_API_BASE_URL__"),Gr("__CHAT_API_URL__")];for(const t of e){const n=ek(t);if(n)return n}}function wp(){const e=[Gr("__API_AUTH_TOKEN__"),Gr("__CHAT_API_KEY__"),Gr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function bp(...e){for(const t of e)if(typeof t=="string"&&t.trim())return Hn(t);return Hn()}function Sp(){const e={},t=vp(),n=wp();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Cp(){const e=Sp(),t=Gn.getAuthToken(),n=vp();return{apiBaseUrl:bp(e.baseUrl,Gn.baseUrl,n),apiKey:t||e.apiKey||wp()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const kp="chat-settings";function tk(){try{const e=localStorage.getItem(kp);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function nk(e){try{const t={...e,apiBaseUrl:Hn(e.apiBaseUrl)};localStorage.setItem(kp,JSON.stringify(t)),t.apiKey&&Gn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function rk(){const e=Cp(),t=tk(),n=Gn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:bp(Gn.baseUrl,r,e.apiBaseUrl)}}function ok(e){Gn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),nk(e)}var sk="Label",Tp=v.forwardRef((e,t)=>d.jsx(Oe.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())}}));Tp.displayName=sk;var Ep=Tp;const ik=zo.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),gn=v.forwardRef(({className:e,...t},n)=>d.jsx(Ep,{ref:n,className:oe(ik(),e),...t}));gn.displayName=Ep.displayName;function Ip(e){const t=v.useRef({value:e,previous:e});return v.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var yi="Switch",[ak,PT]=Wn(yi),[lk,ck]=ak(yi),Np=v.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:u,...f}=e,[h,p]=v.useState(null),g=Xe(t,S=>p(S)),y=v.useRef(!1),x=h?u||!!h.closest("form"):!0,[m,w]=Fr({prop:o,defaultProp:s??!1,onChange:c,caller:yi});return d.jsxs(lk,{scope:n,checked:m,disabled:a,children:[d.jsx(Oe.button,{type:"button",role:"switch","aria-checked":m,"aria-required":i,"data-state":Rp(m),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:g,onClick:ye(e.onClick,S=>{w(T=>!T),x&&(y.current=S.isPropagationStopped(),y.current||S.stopPropagation())})}),x&&d.jsx(jp,{control:h,bubbles:!y.current,name:r,value:l,checked:m,required:i,disabled:a,form:u,style:{transform:"translateX(-100%)"}})]})});Np.displayName=yi;var Ap="SwitchThumb",_p=v.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=ck(Ap,n);return d.jsx(Oe.span,{"data-state":Rp(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});_p.displayName=Ap;var uk="SwitchBubbleInput",jp=v.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=v.useRef(null),a=Xe(i,s),l=Ip(n),c=zf(t);return v.useEffect(()=>{const u=i.current;if(!u)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const g=new Event("click",{bubbles:r});p.call(u,n),u.dispatchEvent(g)}},[l,n,r]),d.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});jp.displayName=uk;function Rp(e){return e?"checked":"unchecked"}var Pp=Np,dk=_p;const or=v.forwardRef(({className:e,...t},n)=>d.jsx(Pp,{className:oe("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:d.jsx(dk,{className:oe("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")})}));or.displayName=Pp.displayName;var Op=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"}),fk="VisuallyHidden",hk=v.forwardRef((e,t)=>d.jsx(Oe.span,{...e,ref:t,style:{...Op,...e.style}}));hk.displayName=fk;var pk=[" ","Enter","ArrowUp","ArrowDown"],mk=[" ","Enter"],Er="Select",[xi,vi,gk]=Ka(Er),[Yr,OT]=Wn(Er,[gk,si]),wi=si(),[yk,sr]=Yr(Er),[xk,vk]=Yr(Er),Mp=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:u,autoComplete:f,disabled:h,required:p,form:g}=e,y=wi(t),[x,m]=v.useState(null),[w,S]=v.useState(null),[T,k]=v.useState(!1),C=Gs(c),[E,j]=Fr({prop:r,defaultProp:o??!1,onChange:s,caller:Er}),[_,R]=Fr({prop:i,defaultProp:a,onChange:l,caller:Er}),L=v.useRef(null),z=x?g||!!x.closest("form"):!0,[W,O]=v.useState(new Set),B=Array.from(W).map(P=>P.props.value).join(";");return d.jsx(Xf,{...y,children:d.jsxs(yk,{required:p,scope:t,trigger:x,onTriggerChange:m,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:T,onValueNodeHasChildrenChange:k,contentId:Vn(),value:_,onValueChange:R,open:E,onOpenChange:j,dir:C,triggerPointerDownPosRef:L,disabled:h,children:[d.jsx(xi.Provider,{scope:t,children:d.jsx(xk,{scope:e.__scopeSelect,onNativeOptionAdd:v.useCallback(P=>{O(U=>new Set(U).add(P))},[]),onNativeOptionRemove:v.useCallback(P=>{O(U=>{const $=new Set(U);return $.delete(P),$})},[]),children:n})}),z?d.jsxs(sm,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:f,value:_,onChange:P=>R(P.target.value),disabled:h,form:g,children:[_===void 0?d.jsx("option",{value:""}):null,Array.from(W)]},B):null]})})};Mp.displayName=Er;var Dp="SelectTrigger",Lp=v.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=wi(n),i=sr(Dp,n),a=i.disabled||r,l=Xe(t,i.onTriggerChange),c=vi(n),u=v.useRef("touch"),[f,h,p]=am(y=>{const x=c().filter(S=>!S.disabled),m=x.find(S=>S.value===i.value),w=lm(x,y,m);w!==void 0&&i.onValueChange(w.value)}),g=y=>{a||(i.onOpenChange(!0),p()),y&&(i.triggerPointerDownPosRef.current={x:Math.round(y.pageX),y:Math.round(y.pageY)})};return d.jsx(Jf,{asChild:!0,...s,children:d.jsx(Oe.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":im(i.value)?"":void 0,...o,ref:l,onClick:ye(o.onClick,y=>{y.currentTarget.focus(),u.current!=="mouse"&&g(y)}),onPointerDown:ye(o.onPointerDown,y=>{u.current=y.pointerType;const x=y.target;x.hasPointerCapture(y.pointerId)&&x.releasePointerCapture(y.pointerId),y.button===0&&y.ctrlKey===!1&&y.pointerType==="mouse"&&(g(y),y.preventDefault())}),onKeyDown:ye(o.onKeyDown,y=>{const x=f.current!=="";!(y.ctrlKey||y.altKey||y.metaKey)&&y.key.length===1&&h(y.key),!(x&&y.key===" ")&&pk.includes(y.key)&&(g(),y.preventDefault())})})})});Lp.displayName=Dp;var Fp="SelectValue",$p=v.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=sr(Fp,n),{onValueNodeHasChildrenChange:c}=l,u=s!==void 0,f=Xe(t,l.onValueNodeChange);return Bt(()=>{c(u)},[c,u]),d.jsx(Oe.span,{...a,ref:f,style:{pointerEvents:"none"},children:im(l.value)?d.jsx(d.Fragment,{children:i}):s})});$p.displayName=Fp;var wk="SelectIcon",zp=v.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return d.jsx(Oe.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});zp.displayName=wk;var bk="SelectPortal",Bp=e=>d.jsx(Is,{asChild:!0,...e});Bp.displayName=bk;var Ir="SelectContent",Hp=v.forwardRef((e,t)=>{const n=sr(Ir,e.__scopeSelect),[r,o]=v.useState();if(Bt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Bo.createPortal(d.jsx(Up,{scope:e.__scopeSelect,children:d.jsx(xi.Slot,{scope:e.__scopeSelect,children:d.jsx("div",{children:e.children})})}),s):null}return d.jsx(Wp,{...e,ref:t})});Hp.displayName=Ir;var Tn=10,[Up,ir]=Yr(Ir),Sk="SelectContentImpl",Ck=dr.createSlot("SelectContent.RemoveScroll"),Wp=v.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:u,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:g,hideWhenDetached:y,avoidCollisions:x,...m}=e,w=sr(Ir,n),[S,T]=v.useState(null),[k,C]=v.useState(null),E=Xe(t,Q=>T(Q)),[j,_]=v.useState(null),[R,L]=v.useState(null),z=vi(n),[W,O]=v.useState(!1),B=v.useRef(!1);v.useEffect(()=>{if(S)return Fa(S)},[S]),Ra();const P=v.useCallback(Q=>{const[D,...G]=z().map(ce=>ce.ref.current),[se]=G.slice(-1),ie=document.activeElement;for(const ce of Q)if(ce===ie||(ce==null||ce.scrollIntoView({block:"nearest"}),ce===D&&k&&(k.scrollTop=0),ce===se&&k&&(k.scrollTop=k.scrollHeight),ce==null||ce.focus(),document.activeElement!==ie))return},[z,k]),U=v.useCallback(()=>P([j,S]),[P,j,S]);v.useEffect(()=>{W&&U()},[W,U]);const{onOpenChange:$,triggerPointerDownPosRef:F}=w;v.useEffect(()=>{if(S){let Q={x:0,y:0};const D=se=>{var ie,ce;Q={x:Math.abs(Math.round(se.pageX)-(((ie=F.current)==null?void 0:ie.x)??0)),y:Math.abs(Math.round(se.pageY)-(((ce=F.current)==null?void 0:ce.y)??0))}},G=se=>{Q.x<=10&&Q.y<=10?se.preventDefault():S.contains(se.target)||$(!1),document.removeEventListener("pointermove",D),F.current=null};return F.current!==null&&(document.addEventListener("pointermove",D),document.addEventListener("pointerup",G,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",G,{capture:!0})}}},[S,$,F]),v.useEffect(()=>{const Q=()=>$(!1);return window.addEventListener("blur",Q),window.addEventListener("resize",Q),()=>{window.removeEventListener("blur",Q),window.removeEventListener("resize",Q)}},[$]);const[ne,re]=am(Q=>{const D=z().filter(ie=>!ie.disabled),G=D.find(ie=>ie.ref.current===document.activeElement),se=lm(D,Q,G);se&&setTimeout(()=>se.ref.current.focus())}),ve=v.useCallback((Q,D,G)=>{const se=!B.current&&!G;(w.value!==void 0&&w.value===D||se)&&(_(Q),se&&(B.current=!0))},[w.value]),Ie=v.useCallback(()=>S==null?void 0:S.focus(),[S]),Z=v.useCallback((Q,D,G)=>{const se=!B.current&&!G;(w.value!==void 0&&w.value===D||se)&&L(Q)},[w.value]),q=r==="popper"?Cl:Vp,he=q===Cl?{side:a,sideOffset:l,align:c,alignOffset:u,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:g,hideWhenDetached:y,avoidCollisions:x}:{};return d.jsx(Up,{scope:n,content:S,viewport:k,onViewportChange:C,itemRefCallback:ve,selectedItem:j,onItemLeave:Ie,itemTextRefCallback:Z,focusSelectedItem:U,selectedItemText:R,position:r,isPositioned:W,searchRef:ne,children:d.jsx(Os,{as:Ck,allowPinchZoom:!0,children:d.jsx(Es,{asChild:!0,trapped:w.open,onMountAutoFocus:Q=>{Q.preventDefault()},onUnmountAutoFocus:ye(o,Q=>{var D;(D=w.trigger)==null||D.focus({preventScroll:!0}),Q.preventDefault()}),children:d.jsx(Ts,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:Q=>Q.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:d.jsx(q,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:Q=>Q.preventDefault(),...m,...he,onPlaced:()=>O(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...m.style},onKeyDown:ye(m.onKeyDown,Q=>{const D=Q.ctrlKey||Q.altKey||Q.metaKey;if(Q.key==="Tab"&&Q.preventDefault(),!D&&Q.key.length===1&&re(Q.key),["ArrowUp","ArrowDown","Home","End"].includes(Q.key)){let se=z().filter(ie=>!ie.disabled).map(ie=>ie.ref.current);if(["ArrowUp","End"].includes(Q.key)&&(se=se.slice().reverse()),["ArrowUp","ArrowDown"].includes(Q.key)){const ie=Q.target,ce=se.indexOf(ie);se=se.slice(ce+1)}setTimeout(()=>P(se)),Q.preventDefault()}})})})})})})});Wp.displayName=Sk;var kk="SelectItemAlignedPosition",Vp=v.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=sr(Ir,n),i=ir(Ir,n),[a,l]=v.useState(null),[c,u]=v.useState(null),f=Xe(t,E=>u(E)),h=vi(n),p=v.useRef(!1),g=v.useRef(!0),{viewport:y,selectedItem:x,selectedItemText:m,focusSelectedItem:w}=i,S=v.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&y&&x&&m){const E=s.trigger.getBoundingClientRect(),j=c.getBoundingClientRect(),_=s.valueNode.getBoundingClientRect(),R=m.getBoundingClientRect();if(s.dir!=="rtl"){const ie=R.left-j.left,ce=_.left-ie,je=E.left-ce,ue=E.width+je,Ze=Math.max(ue,j.width),Je=window.innerWidth-Tn,Ve=yl(ce,[Tn,Math.max(Tn,Je-Ze)]);a.style.minWidth=ue+"px",a.style.left=Ve+"px"}else{const ie=j.right-R.right,ce=window.innerWidth-_.right-ie,je=window.innerWidth-E.right-ce,ue=E.width+je,Ze=Math.max(ue,j.width),Je=window.innerWidth-Tn,Ve=yl(ce,[Tn,Math.max(Tn,Je-Ze)]);a.style.minWidth=ue+"px",a.style.right=Ve+"px"}const L=h(),z=window.innerHeight-Tn*2,W=y.scrollHeight,O=window.getComputedStyle(c),B=parseInt(O.borderTopWidth,10),P=parseInt(O.paddingTop,10),U=parseInt(O.borderBottomWidth,10),$=parseInt(O.paddingBottom,10),F=B+P+W+$+U,ne=Math.min(x.offsetHeight*5,F),re=window.getComputedStyle(y),ve=parseInt(re.paddingTop,10),Ie=parseInt(re.paddingBottom,10),Z=E.top+E.height/2-Tn,q=z-Z,he=x.offsetHeight/2,Q=x.offsetTop+he,D=B+P+Q,G=F-D;if(D<=Z){const ie=L.length>0&&x===L[L.length-1].ref.current;a.style.bottom="0px";const ce=c.clientHeight-y.offsetTop-y.offsetHeight,je=Math.max(q,he+(ie?Ie:0)+ce+U),ue=D+je;a.style.height=ue+"px"}else{const ie=L.length>0&&x===L[0].ref.current;a.style.top="0px";const je=Math.max(Z,B+y.offsetTop+(ie?ve:0)+he)+G;a.style.height=je+"px",y.scrollTop=D-Z+y.offsetTop}a.style.margin=`${Tn}px 0`,a.style.minHeight=ne+"px",a.style.maxHeight=z+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,c,y,x,m,s.dir,r]);Bt(()=>S(),[S]);const[T,k]=v.useState();Bt(()=>{c&&k(window.getComputedStyle(c).zIndex)},[c]);const C=v.useCallback(E=>{E&&g.current===!0&&(S(),w==null||w(),g.current=!1)},[S,w]);return d.jsx(Ek,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:C,children:d.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:T},children:d.jsx(Oe.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Vp.displayName=kk;var Tk="SelectPopperPosition",Cl=v.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Tn,...s}=e,i=wi(n);return d.jsx(Zf,{...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)"}})});Cl.displayName=Tk;var[Ek,kl]=Yr(Ir,{}),Tl="SelectViewport",Kp=v.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=ir(Tl,n),i=kl(Tl,n),a=Xe(t,s.onViewportChange),l=v.useRef(0);return d.jsxs(d.Fragment,{children:[d.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}),d.jsx(xi.Slot,{scope:n,children:d.jsx(Oe.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ye(o.onScroll,c=>{const u=c.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const p=Math.abs(l.current-u.scrollTop);if(p>0){const g=window.innerHeight-Tn*2,y=parseFloat(f.style.minHeight),x=parseFloat(f.style.height),m=Math.max(y,x);if(m<g){const w=m+p,S=Math.min(g,w),T=w-S;f.style.height=S+"px",f.style.bottom==="0px"&&(u.scrollTop=T>0?T:0,f.style.justifyContent="flex-end")}}}l.current=u.scrollTop})})})]})});Kp.displayName=Tl;var qp="SelectGroup",[Ik,Nk]=Yr(qp),Ak=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Vn();return d.jsx(Ik,{scope:n,id:o,children:d.jsx(Oe.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Ak.displayName=qp;var Gp="SelectLabel",Yp=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Nk(Gp,n);return d.jsx(Oe.div,{id:o.id,...r,ref:t})});Yp.displayName=Gp;var bi="SelectItem",[_k,Xp]=Yr(bi),Jp=v.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=sr(bi,n),l=ir(bi,n),c=a.value===r,[u,f]=v.useState(s??""),[h,p]=v.useState(!1),g=Xe(t,w=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,w,r,o)}),y=Vn(),x=v.useRef("touch"),m=()=>{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 d.jsx(_k,{scope:n,value:r,disabled:o,textId:y,isSelected:c,onItemTextChange:v.useCallback(w=>{f(S=>S||((w==null?void 0:w.textContent)??"").trim())},[]),children:d.jsx(xi.ItemSlot,{scope:n,value:r,disabled:o,textValue:u,children:d.jsx(Oe.div,{role:"option","aria-labelledby":y,"data-highlighted":h?"":void 0,"aria-selected":c&&h,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:g,onFocus:ye(i.onFocus,()=>p(!0)),onBlur:ye(i.onBlur,()=>p(!1)),onClick:ye(i.onClick,()=>{x.current!=="mouse"&&m()}),onPointerUp:ye(i.onPointerUp,()=>{x.current==="mouse"&&m()}),onPointerDown:ye(i.onPointerDown,w=>{x.current=w.pointerType}),onPointerMove:ye(i.onPointerMove,w=>{var S;x.current=w.pointerType,o?(S=l.onItemLeave)==null||S.call(l):x.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ye(i.onPointerLeave,w=>{var S;w.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:ye(i.onKeyDown,w=>{var T;((T=l.searchRef)==null?void 0:T.current)!==""&&w.key===" "||(mk.includes(w.key)&&m(),w.key===" "&&w.preventDefault())})})})})});Jp.displayName=bi;var Oo="SelectItemText",Zp=v.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=sr(Oo,n),a=ir(Oo,n),l=Xp(Oo,n),c=vk(Oo,n),[u,f]=v.useState(null),h=Xe(t,m=>f(m),l.onItemTextChange,m=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.call(a,m,l.value,l.disabled)}),p=u==null?void 0:u.textContent,g=v.useMemo(()=>d.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:y,onNativeOptionRemove:x}=c;return Bt(()=>(y(g),()=>x(g)),[y,x,g]),d.jsxs(d.Fragment,{children:[d.jsx(Oe.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Bo.createPortal(s.children,i.valueNode):null]})});Zp.displayName=Oo;var Qp="SelectItemIndicator",em=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Xp(Qp,n).isSelected?d.jsx(Oe.span,{"aria-hidden":!0,...r,ref:t}):null});em.displayName=Qp;var El="SelectScrollUpButton",tm=v.forwardRef((e,t)=>{const n=ir(El,e.__scopeSelect),r=kl(El,e.__scopeSelect),[o,s]=v.useState(!1),i=Xe(t,r.onScrollButtonChange);return Bt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?d.jsx(rm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});tm.displayName=El;var Il="SelectScrollDownButton",nm=v.forwardRef((e,t)=>{const n=ir(Il,e.__scopeSelect),r=kl(Il,e.__scopeSelect),[o,s]=v.useState(!1),i=Xe(t,r.onScrollButtonChange);return Bt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,u=Math.ceil(l.scrollTop)<c;s(u)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?d.jsx(rm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});nm.displayName=Il;var rm=v.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=ir("SelectScrollButton",n),i=v.useRef(null),a=vi(n),l=v.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return v.useEffect(()=>()=>l(),[l]),Bt(()=>{var u;const c=a().find(f=>f.ref.current===document.activeElement);(u=c==null?void 0:c.ref.current)==null||u.scrollIntoView({block:"nearest"})},[a]),d.jsx(Oe.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ye(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ye(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ye(o.onPointerLeave,()=>{l()})})}),jk="SelectSeparator",om=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return d.jsx(Oe.div,{"aria-hidden":!0,...r,ref:t})});om.displayName=jk;var Nl="SelectArrow",Rk=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=wi(n),s=sr(Nl,n),i=ir(Nl,n);return s.open&&i.position==="popper"?d.jsx(Qf,{...o,...r,ref:t}):null});Rk.displayName=Nl;var Pk="SelectBubbleInput",sm=v.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=v.useRef(null),s=Xe(r,o),i=Ip(t);return v.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,u=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&u){const f=new Event("change",{bubbles:!0});u.call(a,t),a.dispatchEvent(f)}},[i,t]),d.jsx(Oe.select,{...n,style:{...Op,...n.style},ref:s,defaultValue:t})});sm.displayName=Pk;function im(e){return e===""||e===void 0}function am(e){const t=Ht(e),n=v.useRef(""),r=v.useRef(0),o=v.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=v.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return v.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function lm(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=Ok(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function Ok(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Mk=Mp,cm=Lp,Dk=$p,Lk=zp,Fk=Bp,um=Hp,$k=Kp,dm=Yp,fm=Jp,zk=Zp,Bk=em,hm=tm,pm=nm,mm=om;const gm=Mk,ym=Dk,Al=v.forwardRef(({className:e,children:t,...n},r)=>d.jsxs(cm,{ref:r,className:oe("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,d.jsx(Lk,{asChild:!0,children:d.jsx(fe.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Al.displayName=cm.displayName;const xm=v.forwardRef(({className:e,...t},n)=>d.jsx(hm,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:d.jsx(fe.ChevronUp,{className:"h-4 w-4"})}));xm.displayName=hm.displayName;const vm=v.forwardRef(({className:e,...t},n)=>d.jsx(pm,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:d.jsx(fe.ChevronDown,{className:"h-4 w-4"})}));vm.displayName=pm.displayName;const _l=v.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>d.jsx(Fk,{children:d.jsxs(um,{ref:o,className:oe("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:[d.jsx(xm,{}),d.jsx($k,{className:oe("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),d.jsx(vm,{})]})}));_l.displayName=um.displayName;const Hk=v.forwardRef(({className:e,...t},n)=>d.jsx(dm,{ref:n,className:oe("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Hk.displayName=dm.displayName;const Nr=v.forwardRef(({className:e,children:t,...n},r)=>d.jsxs(fm,{ref:r,className:oe("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:[d.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:d.jsx(Bk,{children:d.jsx(fe.Check,{className:"h-4 w-4"})})}),d.jsx(zk,{children:t})]}));Nr.displayName=fm.displayName;const Uk=v.forwardRef(({className:e,...t},n)=>d.jsx(mm,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));Uk.displayName=mm.displayName;var Wk="Separator",wm="horizontal",Vk=["horizontal","vertical"],bm=v.forwardRef((e,t)=>{const{decorative:n,orientation:r=wm,...o}=e,s=Kk(r)?r:wm,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return d.jsx(Oe.div,{"data-orientation":s,...a,...o,ref:t})});bm.displayName=Wk;function Kk(e){return Vk.includes(e)}var Sm=bm;const Cm=v.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>d.jsx(Sm,{ref:o,decorative:n,orientation:t,className:oe("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Cm.displayName=Sm.displayName;const qk=Kd,Gk=hb,Yk=qd,km=v.forwardRef(({className:e,...t},n)=>d.jsx($s,{className:oe("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}));km.displayName=$s.displayName;const Xk=zo.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"}}),Tm=v.forwardRef(({side:e="right",className:t,children:n,...r},o)=>d.jsxs(Yk,{children:[d.jsx(km,{}),d.jsxs(zs,{ref:o,className:oe(Xk({side:e}),t),...r,children:[n,d.jsxs(Gd,{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:[d.jsx(fe.X,{className:"h-4 w-4"}),d.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Tm.displayName=zs.displayName;const Em=({className:e,...t})=>d.jsx("div",{className:oe("flex flex-col space-y-2 text-center sm:text-left",e),...t});Em.displayName="SheetHeader";const Im=v.forwardRef(({className:e,...t},n)=>d.jsx(br,{ref:n,className:oe("text-lg font-semibold text-foreground",e),...t}));Im.displayName=br.displayName;const Nm=v.forwardRef(({className:e,...t},n)=>d.jsx(Bs,{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));Nm.displayName=Bs.displayName;const Jk={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 Zk({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=b.useState(!1),[s,i]=b.useState(!1),[a,l]=b.useState(e),[c,u]=b.useState(!1),{toast:f}=Ta();b.useEffect(()=>{const x=JSON.stringify(a)!==JSON.stringify(e);u(x)},[a,e]),b.useEffect(()=>{l(e)},[e]);const h=()=>{t(a),u(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},p=()=>{l(Jk),u(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},g=()=>{l(e),u(!1),o(!1)},y=async()=>{try{const m=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${m.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return d.jsxs(qk,{open:r,onOpenChange:o,children:[d.jsx(Gk,{asChild:!0,children:d.jsxs(ot,{variant:"outline",size:"sm",className:n,children:[d.jsx(fe.Settings,{className:"h-4 w-4 mr-2"}),"Settings",c&&d.jsx(Zu,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),d.jsxs(Tm,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[d.jsxs(Em,{children:[d.jsx(Im,{children:"Chat Settings"}),d.jsx(Nm,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),d.jsxs("div",{className:"space-y-6 py-6",children:[d.jsxs(yo,{children:[d.jsx(xo,{className:"pb-3",children:d.jsxs(vo,{className:"text-lg flex items-center gap-2",children:[d.jsx(fe.Server,{className:"h-5 w-5"}),"API Configuration"]})}),d.jsxs(wo,{className:"space-y-4",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(gn,{htmlFor:"api-url",children:"API Base URL"}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx(fi,{id:"api-url",value:a.api.baseUrl,onChange:x=>l(m=>({...m,api:{...m.api,baseUrl:x.target.value}})),placeholder:"http://localhost:8000/api"}),d.jsx(ot,{variant:"outline",onClick:y,children:"Test"})]})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx(gn,{htmlFor:"enable-auth",children:"Enable Authentication"}),d.jsx(or,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:x=>l(m=>({...m,api:{...m.api,enableAuth:x}}))})]}),a.api.enableAuth&&d.jsxs("div",{className:"space-y-2",children:[d.jsx(gn,{htmlFor:"auth-token",children:"Authentication Token"}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx(fi,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:x=>l(m=>({...m,api:{...m.api,authToken:x.target.value}})),placeholder:"Enter your Bearer token"}),d.jsx(ot,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?d.jsx(fe.EyeOff,{className:"h-4 w-4"}):d.jsx(fe.Eye,{className:"h-4 w-4"})})]})]})]})]}),d.jsxs(yo,{children:[d.jsx(xo,{className:"pb-3",children:d.jsxs(vo,{className:"text-lg flex items-center gap-2",children:[d.jsx(fe.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),d.jsxs(wo,{className:"space-y-4",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(gn,{htmlFor:"layout",children:"Layout Style"}),d.jsxs(gm,{value:a.ui.layout,onValueChange:x=>l(m=>({...m,ui:{...m.ui,layout:x}})),children:[d.jsx(Al,{children:d.jsx(ym,{})}),d.jsxs(_l,{children:[d.jsx(Nr,{value:"sidebar",children:"Sidebar Layout"}),d.jsx(Nr,{value:"fullscreen",children:"Fullscreen"}),d.jsx(Nr,{value:"tabs",children:"Tabbed Interface"})]})]})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(gn,{htmlFor:"theme",children:"Theme"}),d.jsxs(gm,{value:a.ui.theme,onValueChange:x=>l(m=>({...m,ui:{...m.ui,theme:x}})),children:[d.jsx(Al,{children:d.jsx(ym,{})}),d.jsxs(_l,{children:[d.jsx(Nr,{value:"light",children:"Light"}),d.jsx(Nr,{value:"dark",children:"Dark"}),d.jsx(Nr,{value:"system",children:"System"})]})]})]}),d.jsx(Cm,{}),d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx(gn,{htmlFor:"show-timestamps",children:"Show Timestamps"}),d.jsx(or,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:x=>l(m=>({...m,ui:{...m.ui,showTimestamps:x}}))})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx(gn,{htmlFor:"show-agent-names",children:"Show Agent Names"}),d.jsx(or,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:x=>l(m=>({...m,ui:{...m.ui,showAgentNames:x}}))})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx(gn,{htmlFor:"compact-messages",children:"Compact Messages"}),d.jsx(or,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:x=>l(m=>({...m,ui:{...m.ui,compactMessages:x}}))})]})]})]})]}),d.jsxs(yo,{children:[d.jsx(xo,{className:"pb-3",children:d.jsxs(vo,{className:"text-lg flex items-center gap-2",children:[d.jsx(fe.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),d.jsxs(wo,{className:"space-y-4",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{children:[d.jsx(gn,{htmlFor:"auto-save",children:"Auto-save Conversations"}),d.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),d.jsx(or,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:x=>l(m=>({...m,behavior:{...m.behavior,autoSave:x}}))})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{children:[d.jsx(gn,{htmlFor:"enable-streaming",children:"Enable Streaming"}),d.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),d.jsx(or,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:x=>l(m=>({...m,behavior:{...m.behavior,enableStreaming:x}}))})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{children:[d.jsx(gn,{htmlFor:"typing-indicator",children:"Typing Indicator"}),d.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),d.jsx(or,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:x=>l(m=>({...m,behavior:{...m.behavior,showTypingIndicator:x}}))})]})]})]})]}),d.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[d.jsxs(ot,{variant:"outline",onClick:p,children:[d.jsx(fe.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx(ot,{variant:"outline",onClick:g,children:"Cancel"}),d.jsxs(ot,{onClick:h,disabled:!c,children:[d.jsx(fe.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function Qk({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=c=>{const u="h-full";switch(c){case"phone":return`${u} max-w-none`;case"tablet":return`${u} max-w-4xl mx-auto`;case"half-screen":return`${u} max-w-2xl`;case"desktop":default:return`${u} max-w-7xl mx-auto`}},a=c=>({"--chat-sidebar-width":c==="phone"?"100%":c==="tablet"?"280px":c==="half-screen"?"240px":"320px","--chat-message-max-width":c==="phone"?"95%":c==="tablet"?"90%":c==="half-screen"?"85%":"80%","--chat-input-height":c==="phone"?"120px":"100px"}),l=b.useCallback(c=>{var u;(u=s.onThreadChange)==null||u.call(s,c)},[s]);return e==="fullscreen"?d.jsx(ls,{...s,onThreadChange:l,children:d.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:d.jsx(di,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?d.jsx(ls,{...s,onThreadChange:l,children:d.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:d.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&d.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:d.jsx(Sl,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),d.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:d.jsx(di,{onError:s.onError,enableFileUpload:!0})})]})})}):d.jsx(ls,{...s,onThreadChange:l,children:d.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&d.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:d.jsx(Sl,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),d.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:d.jsx(di,{onError:s.onError,enableFileUpload:!0})})]})})}_e.ChatApi=Ic,_e.ChatInterface=di,_e.ChatProviders=ls,_e.ChatSettings=Zk,_e.MarkdownContent=ko,_e.MessageComponent=Wa,_e.MessageList=Va,_e.ThreadManager=Sl,_e.applySettings=ok,_e.chatApiClient=Gn,_e.default=Qk,_e.del=Ec,_e.get=xn,_e.getChatToken=Cc,_e.getCurrentSettings=rk,_e.getDefaultApiConfig=Sp,_e.getDefaultChatSettings=Cp,_e.onChatTokenChanged=kc,_e.post=Li,_e.put=Tc,_e.setChatToken=Di,_e.useApi=Fi,_e.useChatStream=Hc,_e.useMessagesReducer=Oc,_e.useStream=Zc,_e.useThreadState=as,_e.useThreads=is,Object.defineProperties(_e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
137
+ `).trim():n.replace(/</g,"&lt;").replace(/>/g,"&gt;").trim()}function Vb(e,t=qs){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 Kb(e){let t;return typeof e=="string"?t=e:typeof e=="object"&&e!==null?t=JSON.stringify(e):t=String(e),Vb(t),Wb(t)}function Ka(e){const t=e+"CollectionProvider",[n,r]=Wn(t),[o,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),i=y=>{const{scope:x,children:m}=y,w=b.useRef(null),S=b.useRef(new Map).current;return d.jsx(o,{scope:x,itemMap:S,collectionRef:w,children:m})};i.displayName=t;const a=e+"CollectionSlot",l=dr.createSlot(a),c=b.forwardRef((y,x)=>{const{scope:m,children:w}=y,S=s(a,m),T=Xe(x,S.collectionRef);return d.jsx(l,{ref:T,children:w})});c.displayName=a;const u=e+"CollectionItemSlot",f="data-radix-collection-item",h=dr.createSlot(u),p=b.forwardRef((y,x)=>{const{scope:m,children:w,...S}=y,T=b.useRef(null),k=Xe(x,T),C=s(u,m);return b.useEffect(()=>(C.itemMap.set(T,{ref:T,...S}),()=>void C.itemMap.delete(T))),d.jsx(h,{[f]:"",ref:k,children:w})});p.displayName=u;function g(y){const x=s(e+"CollectionConsumer",y);return b.useCallback(()=>{const w=x.collectionRef.current;if(!w)return[];const S=Array.from(w.querySelectorAll(`[${f}]`));return Array.from(x.itemMap.values()).sort((C,E)=>S.indexOf(C.ref.current)-S.indexOf(E.ref.current))},[x.collectionRef,x.itemMap])}return[{Provider:i,Slot:c,ItemSlot:p},g,r]}var qb=v.createContext(void 0);function Gs(e){const t=v.useContext(qb);return e||t||"ltr"}const Gb=["top","right","bottom","left"],nr=Math.min,an=Math.max,Ys=Math.round,Xs=Math.floor,Rn=e=>({x:e,y:e}),Yb={left:"right",right:"left",bottom:"top",top:"bottom"},Xb={start:"end",end:"start"};function qa(e,t,n){return an(e,nr(t,n))}function Kn(e,t){return typeof e=="function"?e(t):e}function qn(e){return e.split("-")[0]}function Ur(e){return e.split("-")[1]}function Ga(e){return e==="x"?"y":"x"}function Ya(e){return e==="y"?"height":"width"}const Jb=new Set(["top","bottom"]);function Pn(e){return Jb.has(qn(e))?"y":"x"}function Xa(e){return Ga(Pn(e))}function Zb(e,t,n){n===void 0&&(n=!1);const r=Ur(e),o=Xa(e),s=Ya(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(i=Js(i)),[i,Js(i)]}function Qb(e){const t=Js(e);return[Ja(e),t,Ja(t)]}function Ja(e){return e.replace(/start|end/g,t=>Xb[t])}const yf=["left","right"],xf=["right","left"],e0=["top","bottom"],t0=["bottom","top"];function n0(e,t,n){switch(e){case"top":case"bottom":return n?t?xf:yf:t?yf:xf;case"left":case"right":return t?e0:t0;default:return[]}}function r0(e,t,n,r){const o=Ur(e);let s=n0(qn(e),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),t&&(s=s.concat(s.map(Ja)))),s}function Js(e){return e.replace(/left|right|bottom|top/g,t=>Yb[t])}function o0(e){return{top:0,right:0,bottom:0,left:0,...e}}function vf(e){return typeof e!="number"?o0(e):{top:e,right:e,bottom:e,left:e}}function Zs(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 wf(e,t,n){let{reference:r,floating:o}=e;const s=Pn(t),i=Xa(t),a=Ya(i),l=qn(t),c=s==="y",u=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:u,y:r.y-o.height};break;case"bottom":p={x:u,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(Ur(t)){case"start":p[i]-=h*(n&&c?-1:1);break;case"end":p[i]+=h*(n&&c?-1:1);break}return p}const s0=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 c=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:f}=wf(c,r,l),h=r,p={},g=0;for(let y=0;y<a.length;y++){const{name:x,fn:m}=a[y],{x:w,y:S,data:T,reset:k}=await m({x:u,y:f,initialPlacement:r,placement:h,strategy:o,middlewareData:p,rects:c,platform:i,elements:{reference:e,floating:t}});u=w??u,f=S??f,p={...p,[x]:{...p[x],...T}},k&&g<=50&&(g++,typeof k=="object"&&(k.placement&&(h=k.placement),k.rects&&(c=k.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):k.rects),{x:u,y:f}=wf(c,h,l)),y=-1)}return{x:u,y:f,placement:h,strategy:o,middlewareData:p}};async function To(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:h=!1,padding:p=0}=Kn(t,e),g=vf(p),x=a[h?f==="floating"?"reference":"floating":f],m=Zs(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(x)))==null||n?x:x.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),w=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)),T=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},k=Zs(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:S,strategy:l}):w);return{top:(m.top-k.top+g.top)/T.y,bottom:(k.bottom-m.bottom+g.bottom)/T.y,left:(m.left-k.left+g.left)/T.x,right:(k.right-m.right+g.right)/T.x}}const i0=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:c,padding:u=0}=Kn(e,t)||{};if(c==null)return{};const f=vf(u),h={x:n,y:r},p=Xa(o),g=Ya(p),y=await i.getDimensions(c),x=p==="y",m=x?"top":"left",w=x?"bottom":"right",S=x?"clientHeight":"clientWidth",T=s.reference[g]+s.reference[p]-h[p]-s.floating[g],k=h[p]-s.reference[p],C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=C?C[S]:0;(!E||!await(i.isElement==null?void 0:i.isElement(C)))&&(E=a.floating[S]||s.floating[g]);const j=T/2-k/2,_=E/2-y[g]/2-1,R=nr(f[m],_),L=nr(f[w],_),z=R,W=E-y[g]-L,O=E/2-y[g]/2+j,B=qa(z,O,W),P=!l.arrow&&Ur(o)!=null&&O!==B&&s.reference[g]/2-(O<z?R:L)-y[g]/2<0,U=P?O<z?O-z:O-W:0;return{[p]:h[p]+U,data:{[p]:B,centerOffset:O-B-U,...P&&{alignmentOffset:U}},reset:P}}}),a0=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:c}=t,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:y=!0,...x}=Kn(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const m=qn(o),w=Pn(a),S=qn(a)===a,T=await(l.isRTL==null?void 0:l.isRTL(c.floating)),k=h||(S||!y?[Js(a)]:Qb(a)),C=g!=="none";!h&&C&&k.push(...r0(a,y,g,T));const E=[a,...k],j=await To(t,x),_=[];let R=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&_.push(j[m]),f){const O=Zb(o,i,T);_.push(j[O[0]],j[O[1]])}if(R=[...R,{placement:o,overflows:_}],!_.every(O=>O<=0)){var L,z;const O=(((L=s.flip)==null?void 0:L.index)||0)+1,B=E[O];if(B&&(!(f==="alignment"?w!==Pn(B):!1)||R.every($=>Pn($.placement)===w?$.overflows[0]>0:!0)))return{data:{index:O,overflows:R},reset:{placement:B}};let P=(z=R.filter(U=>U.overflows[0]<=0).sort((U,$)=>U.overflows[1]-$.overflows[1])[0])==null?void 0:z.placement;if(!P)switch(p){case"bestFit":{var W;const U=(W=R.filter($=>{if(C){const F=Pn($.placement);return F===w||F==="y"}return!0}).map($=>[$.placement,$.overflows.filter(F=>F>0).reduce((F,ne)=>F+ne,0)]).sort(($,F)=>$[1]-F[1])[0])==null?void 0:W[0];U&&(P=U);break}case"initialPlacement":P=a;break}if(o!==P)return{reset:{placement:P}}}return{}}}};function bf(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Sf(e){return Gb.some(t=>e[t]>=0)}const l0=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n}=t,{strategy:r="referenceHidden",...o}=Kn(e,t);switch(r){case"referenceHidden":{const s=await To(t,{...o,elementContext:"reference"}),i=bf(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:Sf(i)}}}case"escaped":{const s=await To(t,{...o,altBoundary:!0}),i=bf(s,n.floating);return{data:{escapedOffsets:i,escaped:Sf(i)}}}default:return{}}}}},Cf=new Set(["left","top"]);async function c0(e,t){const{placement:n,platform:r,elements:o}=e,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=qn(n),a=Ur(n),l=Pn(n)==="y",c=Cf.has(i)?-1:1,u=s&&l?-1:1,f=Kn(t,e);let{mainAxis:h,crossAxis:p,alignmentAxis:g}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof g=="number"&&(p=a==="end"?g*-1:g),l?{x:p*u,y:h*c}:{x:h*c,y:p*u}}const u0=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 c0(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}}}}},d0=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:x=>{let{x:m,y:w}=x;return{x:m,y:w}}},...l}=Kn(e,t),c={x:n,y:r},u=await To(t,l),f=Pn(qn(o)),h=Ga(f);let p=c[h],g=c[f];if(s){const x=h==="y"?"top":"left",m=h==="y"?"bottom":"right",w=p+u[x],S=p-u[m];p=qa(w,p,S)}if(i){const x=f==="y"?"top":"left",m=f==="y"?"bottom":"right",w=g+u[x],S=g-u[m];g=qa(w,g,S)}const y=a.fn({...t,[h]:p,[f]:g});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[h]:s,[f]:i}}}}}},f0=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:c=!0}=Kn(e,t),u={x:n,y:r},f=Pn(o),h=Ga(f);let p=u[h],g=u[f];const y=Kn(a,t),x=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:0,crossAxis:0,...y};if(l){const S=h==="y"?"height":"width",T=s.reference[h]-s.floating[S]+x.mainAxis,k=s.reference[h]+s.reference[S]-x.mainAxis;p<T?p=T:p>k&&(p=k)}if(c){var m,w;const S=h==="y"?"width":"height",T=Cf.has(qn(o)),k=s.reference[f]-s.floating[S]+(T&&((m=i.offset)==null?void 0:m[f])||0)+(T?0:x.crossAxis),C=s.reference[f]+s.reference[S]+(T?0:((w=i.offset)==null?void 0:w[f])||0)-(T?x.crossAxis:0);g<k?g=k:g>C&&(g=C)}return{[h]:p,[f]:g}}}},h0=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=()=>{},...c}=Kn(e,t),u=await To(t,c),f=qn(o),h=Ur(o),p=Pn(o)==="y",{width:g,height:y}=s.floating;let x,m;f==="top"||f==="bottom"?(x=f,m=h===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(m=f,x=h==="end"?"top":"bottom");const w=y-u.top-u.bottom,S=g-u.left-u.right,T=nr(y-u[x],w),k=nr(g-u[m],S),C=!t.middlewareData.shift;let E=T,j=k;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(j=S),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(E=w),C&&!h){const R=an(u.left,0),L=an(u.right,0),z=an(u.top,0),W=an(u.bottom,0);p?j=g-2*(R!==0||L!==0?R+L:an(u.left,u.right)):E=y-2*(z!==0||W!==0?z+W:an(u.top,u.bottom))}await l({...t,availableWidth:j,availableHeight:E});const _=await i.getDimensions(a.floating);return g!==_.width||y!==_.height?{reset:{rects:!0}}:{}}}};function Qs(){return typeof window<"u"}function Wr(e){return kf(e)?(e.nodeName||"").toLowerCase():"#document"}function ln(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function On(e){var t;return(t=(kf(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function kf(e){return Qs()?e instanceof Node||e instanceof ln(e).Node:!1}function Cn(e){return Qs()?e instanceof Element||e instanceof ln(e).Element:!1}function Mn(e){return Qs()?e instanceof HTMLElement||e instanceof ln(e).HTMLElement:!1}function Tf(e){return!Qs()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ln(e).ShadowRoot}const p0=new Set(["inline","contents"]);function Eo(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=kn(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!p0.has(o)}const m0=new Set(["table","td","th"]);function g0(e){return m0.has(Wr(e))}const y0=[":popover-open",":modal"];function ei(e){return y0.some(t=>{try{return e.matches(t)}catch{return!1}})}const x0=["transform","translate","scale","rotate","perspective"],v0=["transform","translate","scale","rotate","perspective","filter"],w0=["paint","layout","strict","content"];function Za(e){const t=Qa(),n=Cn(e)?kn(e):e;return x0.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)||v0.some(r=>(n.willChange||"").includes(r))||w0.some(r=>(n.contain||"").includes(r))}function b0(e){let t=rr(e);for(;Mn(t)&&!Vr(t);){if(Za(t))return t;if(ei(t))return null;t=rr(t)}return null}function Qa(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const S0=new Set(["html","body","#document"]);function Vr(e){return S0.has(Wr(e))}function kn(e){return ln(e).getComputedStyle(e)}function ti(e){return Cn(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function rr(e){if(Wr(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Tf(e)&&e.host||On(e);return Tf(t)?t.host:t}function Ef(e){const t=rr(e);return Vr(t)?e.ownerDocument?e.ownerDocument.body:e.body:Mn(t)&&Eo(t)?t:Ef(t)}function Io(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=Ef(e),s=o===((r=e.ownerDocument)==null?void 0:r.body),i=ln(o);if(s){const a=el(i);return t.concat(i,i.visualViewport||[],Eo(o)?o:[],a&&n?Io(a):[])}return t.concat(o,Io(o,[],n))}function el(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function If(e){const t=kn(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=Mn(e),s=o?e.offsetWidth:n,i=o?e.offsetHeight:r,a=Ys(n)!==s||Ys(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function tl(e){return Cn(e)?e:e.contextElement}function Kr(e){const t=tl(e);if(!Mn(t))return Rn(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:s}=If(t);let i=(s?Ys(n.width):n.width)/r,a=(s?Ys(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const C0=Rn(0);function Nf(e){const t=ln(e);return!Qa()||!t.visualViewport?C0:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function k0(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ln(e)?!1:t}function Cr(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),s=tl(e);let i=Rn(1);t&&(r?Cn(r)&&(i=Kr(r)):i=Kr(e));const a=k0(s,n,r)?Nf(s):Rn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,u=o.width/i.x,f=o.height/i.y;if(s){const h=ln(s),p=r&&Cn(r)?ln(r):r;let g=h,y=el(g);for(;y&&r&&p!==g;){const x=Kr(y),m=y.getBoundingClientRect(),w=kn(y),S=m.left+(y.clientLeft+parseFloat(w.paddingLeft))*x.x,T=m.top+(y.clientTop+parseFloat(w.paddingTop))*x.y;l*=x.x,c*=x.y,u*=x.x,f*=x.y,l+=S,c+=T,g=ln(y),y=el(g)}}return Zs({width:u,height:f,x:l,y:c})}function ni(e,t){const n=ti(e).scrollLeft;return t?t.left+n:Cr(On(e)).left+n}function Af(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-ni(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function T0(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const s=o==="fixed",i=On(r),a=t?ei(t.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=Rn(1);const u=Rn(0),f=Mn(r);if((f||!f&&!s)&&((Wr(r)!=="body"||Eo(i))&&(l=ti(r)),Mn(r))){const p=Cr(r);c=Kr(r),u.x=p.x+r.clientLeft,u.y=p.y+r.clientTop}const h=i&&!f&&!s?Af(i,l):Rn(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+h.x,y:n.y*c.y-l.scrollTop*c.y+u.y+h.y}}function E0(e){return Array.from(e.getClientRects())}function I0(e){const t=On(e),n=ti(e),r=e.ownerDocument.body,o=an(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=an(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+ni(e);const a=-n.scrollTop;return kn(r).direction==="rtl"&&(i+=an(t.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const _f=25;function N0(e,t){const n=ln(e),r=On(e),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const u=Qa();(!u||u&&t==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=ni(r);if(c<=0){const u=r.ownerDocument,f=u.body,h=getComputedStyle(f),p=u.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,g=Math.abs(r.clientWidth-f.clientWidth-p);g<=_f&&(s-=g)}else c<=_f&&(s+=c);return{width:s,height:i,x:a,y:l}}const A0=new Set(["absolute","fixed"]);function _0(e,t){const n=Cr(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,s=Mn(e)?Kr(e):Rn(1),i=e.clientWidth*s.x,a=e.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function jf(e,t,n){let r;if(t==="viewport")r=N0(e,n);else if(t==="document")r=I0(On(e));else if(Cn(t))r=_0(t,n);else{const o=Nf(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return Zs(r)}function Rf(e,t){const n=rr(e);return n===t||!Cn(n)||Vr(n)?!1:kn(n).position==="fixed"||Rf(n,t)}function j0(e,t){const n=t.get(e);if(n)return n;let r=Io(e,[],!1).filter(a=>Cn(a)&&Wr(a)!=="body"),o=null;const s=kn(e).position==="fixed";let i=s?rr(e):e;for(;Cn(i)&&!Vr(i);){const a=kn(i),l=Za(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&A0.has(o.position)||Eo(i)&&!l&&Rf(e,i))?r=r.filter(u=>u!==i):o=a,i=rr(i)}return t.set(e,r),r}function R0(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?ei(t)?[]:j0(t,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,u)=>{const f=jf(t,u,o);return c.top=an(f.top,c.top),c.right=nr(f.right,c.right),c.bottom=nr(f.bottom,c.bottom),c.left=an(f.left,c.left),c},jf(t,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function P0(e){const{width:t,height:n}=If(e);return{width:t,height:n}}function O0(e,t,n){const r=Mn(t),o=On(t),s=n==="fixed",i=Cr(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=Rn(0);function c(){l.x=ni(o)}if(r||!r&&!s)if((Wr(t)!=="body"||Eo(o))&&(a=ti(t)),r){const p=Cr(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else o&&c();s&&!r&&o&&c();const u=o&&!r&&!s?Af(o,a):Rn(0),f=i.left+a.scrollLeft-l.x-u.x,h=i.top+a.scrollTop-l.y-u.y;return{x:f,y:h,width:i.width,height:i.height}}function nl(e){return kn(e).position==="static"}function Pf(e,t){if(!Mn(e)||kn(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return On(e)===n&&(n=n.ownerDocument.body),n}function Of(e,t){const n=ln(e);if(ei(e))return n;if(!Mn(e)){let o=rr(e);for(;o&&!Vr(o);){if(Cn(o)&&!nl(o))return o;o=rr(o)}return n}let r=Pf(e,t);for(;r&&g0(r)&&nl(r);)r=Pf(r,t);return r&&Vr(r)&&nl(r)&&!Za(r)?n:r||b0(e)||n}const M0=async function(e){const t=this.getOffsetParent||Of,n=this.getDimensions,r=await n(e.floating);return{reference:O0(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function D0(e){return kn(e).direction==="rtl"}const L0={convertOffsetParentRelativeRectToViewportRelativeRect:T0,getDocumentElement:On,getClippingRect:R0,getOffsetParent:Of,getElementRects:M0,getClientRects:E0,getDimensions:P0,getScale:Kr,isElement:Cn,isRTL:D0};function Mf(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function F0(e,t){let n=null,r;const o=On(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 c=e.getBoundingClientRect(),{left:u,top:f,width:h,height:p}=c;if(a||t(),!h||!p)return;const g=Xs(f),y=Xs(o.clientWidth-(u+h)),x=Xs(o.clientHeight-(f+p)),m=Xs(u),S={rootMargin:-g+"px "+-y+"px "+-x+"px "+-m+"px",threshold:an(0,nr(1,l))||1};let T=!0;function k(C){const E=C[0].intersectionRatio;if(E!==l){if(!T)return i();E?i(!1,E):r=setTimeout(()=>{i(!1,1e-7)},1e3)}E===1&&!Mf(c,e.getBoundingClientRect())&&i(),T=!1}try{n=new IntersectionObserver(k,{...S,root:o.ownerDocument})}catch{n=new IntersectionObserver(k,S)}n.observe(e)}return i(!0),s}function $0(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,c=tl(e),u=o||s?[...c?Io(c):[],...Io(t)]:[];u.forEach(m=>{o&&m.addEventListener("scroll",n,{passive:!0}),s&&m.addEventListener("resize",n)});const f=c&&a?F0(c,n):null;let h=-1,p=null;i&&(p=new ResizeObserver(m=>{let[w]=m;w&&w.target===c&&p&&(p.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var S;(S=p)==null||S.observe(t)})),n()}),c&&!l&&p.observe(c),p.observe(t));let g,y=l?Cr(e):null;l&&x();function x(){const m=Cr(e);y&&!Mf(y,m)&&n(),y=m,g=requestAnimationFrame(x)}return n(),()=>{var m;u.forEach(w=>{o&&w.removeEventListener("scroll",n),s&&w.removeEventListener("resize",n)}),f==null||f(),(m=p)==null||m.disconnect(),p=null,l&&cancelAnimationFrame(g)}}const z0=u0,B0=d0,H0=a0,U0=h0,W0=l0,Df=i0,V0=f0,K0=(e,t,n)=>{const r=new Map,o={platform:L0,...n},s={...o.platform,_c:r};return s0(e,t,{...o,platform:s})};var q0=typeof document<"u",G0=function(){},ri=q0?b.useLayoutEffect:G0;function oi(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(!oi(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)&&!oi(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function Lf(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ff(e,t){const n=Lf(e);return Math.round(t*n)/n}function rl(e){const t=v.useRef(e);return ri(()=>{t.current=e}),t}function Y0(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:c}=e,[u,f]=v.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,p]=v.useState(r);oi(h,r)||p(r);const[g,y]=v.useState(null),[x,m]=v.useState(null),w=v.useCallback($=>{$!==C.current&&(C.current=$,y($))},[]),S=v.useCallback($=>{$!==E.current&&(E.current=$,m($))},[]),T=s||g,k=i||x,C=v.useRef(null),E=v.useRef(null),j=v.useRef(u),_=l!=null,R=rl(l),L=rl(o),z=rl(c),W=v.useCallback(()=>{if(!C.current||!E.current)return;const $={placement:t,strategy:n,middleware:h};L.current&&($.platform=L.current),K0(C.current,E.current,$).then(F=>{const ne={...F,isPositioned:z.current!==!1};O.current&&!oi(j.current,ne)&&(j.current=ne,Bo.flushSync(()=>{f(ne)}))})},[h,t,n,L,z]);ri(()=>{c===!1&&j.current.isPositioned&&(j.current.isPositioned=!1,f($=>({...$,isPositioned:!1})))},[c]);const O=v.useRef(!1);ri(()=>(O.current=!0,()=>{O.current=!1}),[]),ri(()=>{if(T&&(C.current=T),k&&(E.current=k),T&&k){if(R.current)return R.current(T,k,W);W()}},[T,k,W,R,_]);const B=v.useMemo(()=>({reference:C,floating:E,setReference:w,setFloating:S}),[w,S]),P=v.useMemo(()=>({reference:T,floating:k}),[T,k]),U=v.useMemo(()=>{const $={position:n,left:0,top:0};if(!P.floating)return $;const F=Ff(P.floating,u.x),ne=Ff(P.floating,u.y);return a?{...$,transform:"translate("+F+"px, "+ne+"px)",...Lf(P.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:F,top:ne}},[n,a,P.floating,u.x,u.y]);return v.useMemo(()=>({...u,update:W,refs:B,elements:P,floatingStyles:U}),[u,W,B,P,U])}const X0=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?Df({element:r.current,padding:o}).fn(n):{}:r?Df({element:r,padding:o}).fn(n):{}}}},J0=(e,t)=>({...z0(e),options:[e,t]}),Z0=(e,t)=>({...B0(e),options:[e,t]}),Q0=(e,t)=>({...V0(e),options:[e,t]}),eS=(e,t)=>({...H0(e),options:[e,t]}),tS=(e,t)=>({...U0(e),options:[e,t]}),nS=(e,t)=>({...W0(e),options:[e,t]}),rS=(e,t)=>({...X0(e),options:[e,t]});var oS="Arrow",$f=v.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...s}=e;return d.jsx(Oe.svg,{...s,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:d.jsx("polygon",{points:"0,0 30,0 15,10"})})});$f.displayName=oS;var sS=$f;function zf(e){const[t,n]=v.useState(void 0);return Bt(()=>{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,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.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 ol="Popper",[Bf,si]=Wn(ol),[iS,Hf]=Bf(ol),Uf=e=>{const{__scopePopper:t,children:n}=e,[r,o]=v.useState(null);return d.jsx(iS,{scope:t,anchor:r,onAnchorChange:o,children:n})};Uf.displayName=ol;var Wf="PopperAnchor",Vf=v.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,s=Hf(Wf,n),i=v.useRef(null),a=Xe(t,i),l=v.useRef(null);return v.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:d.jsx(Oe.div,{...o,ref:a})});Vf.displayName=Wf;var sl="PopperContent",[aS,lS]=Bf(sl),Kf=v.forwardRef((e,t)=>{var Q,D,G,se,ie,ce;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:u=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:p="optimized",onPlaced:g,...y}=e,x=Hf(sl,n),[m,w]=v.useState(null),S=Xe(t,je=>w(je)),[T,k]=v.useState(null),C=zf(T),E=(C==null?void 0:C.width)??0,j=(C==null?void 0:C.height)??0,_=r+(s!=="center"?"-"+s:""),R=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},L=Array.isArray(c)?c:[c],z=L.length>0,W={padding:R,boundary:L.filter(uS),altBoundary:z},{refs:O,floatingStyles:B,placement:P,isPositioned:U,middlewareData:$}=Y0({strategy:"fixed",placement:_,whileElementsMounted:(...je)=>$0(...je,{animationFrame:p==="always"}),elements:{reference:x.anchor},middleware:[J0({mainAxis:o+j,alignmentAxis:i}),l&&Z0({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?Q0():void 0,...W}),l&&eS({...W}),tS({...W,apply:({elements:je,rects:ue,availableWidth:Ze,availableHeight:Je})=>{const{width:Ve,height:lt}=ue.reference,ct=je.floating.style;ct.setProperty("--radix-popper-available-width",`${Ze}px`),ct.setProperty("--radix-popper-available-height",`${Je}px`),ct.setProperty("--radix-popper-anchor-width",`${Ve}px`),ct.setProperty("--radix-popper-anchor-height",`${lt}px`)}}),T&&rS({element:T,padding:a}),dS({arrowWidth:E,arrowHeight:j}),h&&nS({strategy:"referenceHidden",...W})]}),[F,ne]=Yf(P),re=Ht(g);Bt(()=>{U&&(re==null||re())},[U,re]);const ve=(Q=$.arrow)==null?void 0:Q.x,Ie=(D=$.arrow)==null?void 0:D.y,Z=((G=$.arrow)==null?void 0:G.centerOffset)!==0,[q,he]=v.useState();return Bt(()=>{m&&he(window.getComputedStyle(m).zIndex)},[m]),d.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...B,transform:U?B.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:q,"--radix-popper-transform-origin":[(se=$.transformOrigin)==null?void 0:se.x,(ie=$.transformOrigin)==null?void 0:ie.y].join(" "),...((ce=$.hide)==null?void 0:ce.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:d.jsx(aS,{scope:n,placedSide:F,onArrowChange:k,arrowX:ve,arrowY:Ie,shouldHideArrow:Z,children:d.jsx(Oe.div,{"data-side":F,"data-align":ne,...y,ref:S,style:{...y.style,animation:U?void 0:"none"}})})})});Kf.displayName=sl;var qf="PopperArrow",cS={top:"bottom",right:"left",bottom:"top",left:"right"},Gf=v.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,s=lS(qf,r),i=cS[s.placedSide];return d.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:d.jsx(sS,{...o,ref:n,style:{...o.style,display:"block"}})})});Gf.displayName=qf;function uS(e){return e!==null}var dS=e=>({name:"transformOrigin",options:e,fn(t){var x,m,w;const{placement:n,rects:r,middlewareData:o}=t,i=((x=o.arrow)==null?void 0:x.centerOffset)!==0,a=i?0:e.arrowWidth,l=i?0:e.arrowHeight,[c,u]=Yf(n),f={start:"0%",center:"50%",end:"100%"}[u],h=(((m=o.arrow)==null?void 0:m.x)??0)+a/2,p=(((w=o.arrow)==null?void 0:w.y)??0)+l/2;let g="",y="";return c==="bottom"?(g=i?f:`${h}px`,y=`${-l}px`):c==="top"?(g=i?f:`${h}px`,y=`${r.floating.height+l}px`):c==="right"?(g=`${-l}px`,y=i?f:`${p}px`):c==="left"&&(g=`${r.floating.width+l}px`,y=i?f:`${p}px`),{data:{x:g,y}}}});function Yf(e){const[t,n="center"]=e.split("-");return[t,n]}var Xf=Uf,Jf=Vf,Zf=Kf,Qf=Gf,il="rovingFocusGroup.onEntryFocus",fS={bubbles:!1,cancelable:!0},No="RovingFocusGroup",[al,eh,hS]=Ka(No),[pS,th]=Wn(No,[hS]),[mS,gS]=pS(No),nh=v.forwardRef((e,t)=>d.jsx(al.Provider,{scope:e.__scopeRovingFocusGroup,children:d.jsx(al.Slot,{scope:e.__scopeRovingFocusGroup,children:d.jsx(yS,{...e,ref:t})})}));nh.displayName=No;var yS=v.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:u=!1,...f}=e,h=v.useRef(null),p=Xe(t,h),g=Gs(s),[y,x]=Fr({prop:i,defaultProp:a??null,onChange:l,caller:No}),[m,w]=v.useState(!1),S=Ht(c),T=eh(n),k=v.useRef(!1),[C,E]=v.useState(0);return v.useEffect(()=>{const j=h.current;if(j)return j.addEventListener(il,S),()=>j.removeEventListener(il,S)},[S]),d.jsx(mS,{scope:n,orientation:r,dir:g,loop:o,currentTabStopId:y,onItemFocus:v.useCallback(j=>x(j),[x]),onItemShiftTab:v.useCallback(()=>w(!0),[]),onFocusableItemAdd:v.useCallback(()=>E(j=>j+1),[]),onFocusableItemRemove:v.useCallback(()=>E(j=>j-1),[]),children:d.jsx(Oe.div,{tabIndex:m||C===0?-1:0,"data-orientation":r,...f,ref:p,style:{outline:"none",...e.style},onMouseDown:ye(e.onMouseDown,()=>{k.current=!0}),onFocus:ye(e.onFocus,j=>{const _=!k.current;if(j.target===j.currentTarget&&_&&!m){const R=new CustomEvent(il,fS);if(j.currentTarget.dispatchEvent(R),!R.defaultPrevented){const L=T().filter(P=>P.focusable),z=L.find(P=>P.active),W=L.find(P=>P.id===y),B=[z,W,...L].filter(Boolean).map(P=>P.ref.current);sh(B,u)}}k.current=!1}),onBlur:ye(e.onBlur,()=>w(!1))})})}),rh="RovingFocusGroupItem",oh=v.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=e,l=Vn(),c=s||l,u=gS(rh,n),f=u.currentTabStopId===c,h=eh(n),{onFocusableItemAdd:p,onFocusableItemRemove:g,currentTabStopId:y}=u;return v.useEffect(()=>{if(r)return p(),()=>g()},[r,p,g]),d.jsx(al.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:d.jsx(Oe.span,{tabIndex:f?0:-1,"data-orientation":u.orientation,...a,ref:t,onMouseDown:ye(e.onMouseDown,x=>{r?u.onItemFocus(c):x.preventDefault()}),onFocus:ye(e.onFocus,()=>u.onItemFocus(c)),onKeyDown:ye(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){u.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const m=wS(x,u.orientation,u.dir);if(m!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let S=h().filter(T=>T.focusable).map(T=>T.ref.current);if(m==="last")S.reverse();else if(m==="prev"||m==="next"){m==="prev"&&S.reverse();const T=S.indexOf(x.currentTarget);S=u.loop?bS(S,T+1):S.slice(T+1)}setTimeout(()=>sh(S))}}),children:typeof i=="function"?i({isCurrentTabStop:f,hasTabStop:y!=null}):i})})});oh.displayName=rh;var xS={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function vS(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function wS(e,t,n){const r=vS(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return xS[r]}function sh(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function bS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var SS=nh,CS=oh,ll=["Enter"," "],kS=["ArrowDown","PageUp","Home"],ih=["ArrowUp","PageDown","End"],TS=[...kS,...ih],ES={ltr:[...ll,"ArrowRight"],rtl:[...ll,"ArrowLeft"]},IS={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Ao="Menu",[_o,NS,AS]=Ka(Ao),[kr,ah]=Wn(Ao,[AS,si,th]),ii=si(),lh=th(),[_S,Tr]=kr(Ao),[jS,jo]=kr(Ao),ch=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=e,a=ii(t),[l,c]=v.useState(null),u=v.useRef(!1),f=Ht(s),h=Gs(o);return v.useEffect(()=>{const p=()=>{u.current=!0,document.addEventListener("pointerdown",g,{capture:!0,once:!0}),document.addEventListener("pointermove",g,{capture:!0,once:!0})},g=()=>u.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",g,{capture:!0}),document.removeEventListener("pointermove",g,{capture:!0})}},[]),d.jsx(Xf,{...a,children:d.jsx(_S,{scope:t,open:n,onOpenChange:f,content:l,onContentChange:c,children:d.jsx(jS,{scope:t,onClose:v.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:u,dir:h,modal:i,children:r})})})};ch.displayName=Ao;var RS="MenuAnchor",cl=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ii(n);return d.jsx(Jf,{...o,...r,ref:t})});cl.displayName=RS;var ul="MenuPortal",[PS,uh]=kr(ul,{forceMount:void 0}),dh=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:o}=e,s=Tr(ul,t);return d.jsx(PS,{scope:t,forceMount:n,children:d.jsx(hn,{present:n||s.open,children:d.jsx(Is,{asChild:!0,container:o,children:r})})})};dh.displayName=ul;var pn="MenuContent",[OS,dl]=kr(pn),fh=v.forwardRef((e,t)=>{const n=uh(pn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Tr(pn,e.__scopeMenu),i=jo(pn,e.__scopeMenu);return d.jsx(_o.Provider,{scope:e.__scopeMenu,children:d.jsx(hn,{present:r||s.open,children:d.jsx(_o.Slot,{scope:e.__scopeMenu,children:i.modal?d.jsx(MS,{...o,ref:t}):d.jsx(DS,{...o,ref:t})})})})}),MS=v.forwardRef((e,t)=>{const n=Tr(pn,e.__scopeMenu),r=v.useRef(null),o=Xe(t,r);return v.useEffect(()=>{const s=r.current;if(s)return Fa(s)},[]),d.jsx(fl,{...e,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ye(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),DS=v.forwardRef((e,t)=>{const n=Tr(pn,e.__scopeMenu);return d.jsx(fl,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),LS=dr.createSlot("MenuContent.ScrollLock"),fl=v.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:f,onInteractOutside:h,onDismiss:p,disableOutsideScroll:g,...y}=e,x=Tr(pn,n),m=jo(pn,n),w=ii(n),S=lh(n),T=NS(n),[k,C]=v.useState(null),E=v.useRef(null),j=Xe(t,E,x.onContentChange),_=v.useRef(0),R=v.useRef(""),L=v.useRef(0),z=v.useRef(null),W=v.useRef("right"),O=v.useRef(0),B=g?Os:v.Fragment,P=g?{as:LS,allowPinchZoom:!0}:void 0,U=F=>{var Q,D;const ne=R.current+F,re=T().filter(G=>!G.disabled),ve=document.activeElement,Ie=(Q=re.find(G=>G.ref.current===ve))==null?void 0:Q.textValue,Z=re.map(G=>G.textValue),q=YS(Z,ne,Ie),he=(D=re.find(G=>G.textValue===q))==null?void 0:D.ref.current;(function G(se){R.current=se,window.clearTimeout(_.current),se!==""&&(_.current=window.setTimeout(()=>G(""),1e3))})(ne),he&&setTimeout(()=>he.focus())};v.useEffect(()=>()=>window.clearTimeout(_.current),[]),Ra();const $=v.useCallback(F=>{var re,ve;return W.current===((re=z.current)==null?void 0:re.side)&&JS(F,(ve=z.current)==null?void 0:ve.area)},[]);return d.jsx(OS,{scope:n,searchRef:R,onItemEnter:v.useCallback(F=>{$(F)&&F.preventDefault()},[$]),onItemLeave:v.useCallback(F=>{var ne;$(F)||((ne=E.current)==null||ne.focus(),C(null))},[$]),onTriggerLeave:v.useCallback(F=>{$(F)&&F.preventDefault()},[$]),pointerGraceTimerRef:L,onPointerGraceIntentChange:v.useCallback(F=>{z.current=F},[]),children:d.jsx(B,{...P,children:d.jsx(Es,{asChild:!0,trapped:o,onMountAutoFocus:ye(s,F=>{var ne;F.preventDefault(),(ne=E.current)==null||ne.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:d.jsx(Ts,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:f,onInteractOutside:h,onDismiss:p,children:d.jsx(SS,{asChild:!0,...S,dir:m.dir,orientation:"vertical",loop:r,currentTabStopId:k,onCurrentTabStopIdChange:C,onEntryFocus:ye(l,F=>{m.isUsingKeyboardRef.current||F.preventDefault()}),preventScrollOnEntryFocus:!0,children:d.jsx(Zf,{role:"menu","aria-orientation":"vertical","data-state":Ah(x.open),"data-radix-menu-content":"",dir:m.dir,...w,...y,ref:j,style:{outline:"none",...y.style},onKeyDown:ye(y.onKeyDown,F=>{const re=F.target.closest("[data-radix-menu-content]")===F.currentTarget,ve=F.ctrlKey||F.altKey||F.metaKey,Ie=F.key.length===1;re&&(F.key==="Tab"&&F.preventDefault(),!ve&&Ie&&U(F.key));const Z=E.current;if(F.target!==Z||!TS.includes(F.key))return;F.preventDefault();const he=T().filter(Q=>!Q.disabled).map(Q=>Q.ref.current);ih.includes(F.key)&&he.reverse(),qS(he)}),onBlur:ye(e.onBlur,F=>{F.currentTarget.contains(F.target)||(window.clearTimeout(_.current),R.current="")}),onPointerMove:ye(e.onPointerMove,Po(F=>{const ne=F.target,re=O.current!==F.clientX;if(F.currentTarget.contains(ne)&&re){const ve=F.clientX>O.current?"right":"left";W.current=ve,O.current=F.clientX}}))})})})})})})});fh.displayName=pn;var FS="MenuGroup",hl=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return d.jsx(Oe.div,{role:"group",...r,ref:t})});hl.displayName=FS;var $S="MenuLabel",hh=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return d.jsx(Oe.div,{...r,ref:t})});hh.displayName=$S;var ai="MenuItem",ph="menu.itemSelect",li=v.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...o}=e,s=v.useRef(null),i=jo(ai,e.__scopeMenu),a=dl(ai,e.__scopeMenu),l=Xe(t,s),c=v.useRef(!1),u=()=>{const f=s.current;if(!n&&f){const h=new CustomEvent(ph,{bubbles:!0,cancelable:!0});f.addEventListener(ph,p=>r==null?void 0:r(p),{once:!0}),id(f,h),h.defaultPrevented?c.current=!1:i.onClose()}};return d.jsx(mh,{...o,ref:l,disabled:n,onClick:ye(e.onClick,u),onPointerDown:f=>{var h;(h=e.onPointerDown)==null||h.call(e,f),c.current=!0},onPointerUp:ye(e.onPointerUp,f=>{var h;c.current||(h=f.currentTarget)==null||h.click()}),onKeyDown:ye(e.onKeyDown,f=>{const h=a.searchRef.current!=="";n||h&&f.key===" "||ll.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});li.displayName=ai;var mh=v.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=e,i=dl(ai,n),a=lh(n),l=v.useRef(null),c=Xe(t,l),[u,f]=v.useState(!1),[h,p]=v.useState("");return v.useEffect(()=>{const g=l.current;g&&p((g.textContent??"").trim())},[s.children]),d.jsx(_o.ItemSlot,{scope:n,disabled:r,textValue:o??h,children:d.jsx(CS,{asChild:!0,...a,focusable:!r,children:d.jsx(Oe.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:ye(e.onPointerMove,Po(g=>{r?i.onItemLeave(g):(i.onItemEnter(g),g.defaultPrevented||g.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ye(e.onPointerLeave,Po(g=>i.onItemLeave(g))),onFocus:ye(e.onFocus,()=>f(!0)),onBlur:ye(e.onBlur,()=>f(!1))})})})}),zS="MenuCheckboxItem",gh=v.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...o}=e;return d.jsx(bh,{scope:e.__scopeMenu,checked:n,children:d.jsx(li,{role:"menuitemcheckbox","aria-checked":ci(n)?"mixed":n,...o,ref:t,"data-state":ml(n),onSelect:ye(o.onSelect,()=>r==null?void 0:r(ci(n)?!0:!n),{checkForDefaultPrevented:!1})})})});gh.displayName=zS;var yh="MenuRadioGroup",[BS,HS]=kr(yh,{value:void 0,onValueChange:()=>{}}),xh=v.forwardRef((e,t)=>{const{value:n,onValueChange:r,...o}=e,s=Ht(r);return d.jsx(BS,{scope:e.__scopeMenu,value:n,onValueChange:s,children:d.jsx(hl,{...o,ref:t})})});xh.displayName=yh;var vh="MenuRadioItem",wh=v.forwardRef((e,t)=>{const{value:n,...r}=e,o=HS(vh,e.__scopeMenu),s=n===o.value;return d.jsx(bh,{scope:e.__scopeMenu,checked:s,children:d.jsx(li,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":ml(s),onSelect:ye(r.onSelect,()=>{var i;return(i=o.onValueChange)==null?void 0:i.call(o,n)},{checkForDefaultPrevented:!1})})})});wh.displayName=vh;var pl="MenuItemIndicator",[bh,US]=kr(pl,{checked:!1}),Sh=v.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...o}=e,s=US(pl,n);return d.jsx(hn,{present:r||ci(s.checked)||s.checked===!0,children:d.jsx(Oe.span,{...o,ref:t,"data-state":ml(s.checked)})})});Sh.displayName=pl;var WS="MenuSeparator",Ch=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return d.jsx(Oe.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});Ch.displayName=WS;var VS="MenuArrow",kh=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,o=ii(n);return d.jsx(Qf,{...o,...r,ref:t})});kh.displayName=VS;var KS="MenuSub",[_T,Th]=kr(KS),Ro="MenuSubTrigger",Eh=v.forwardRef((e,t)=>{const n=Tr(Ro,e.__scopeMenu),r=jo(Ro,e.__scopeMenu),o=Th(Ro,e.__scopeMenu),s=dl(Ro,e.__scopeMenu),i=v.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},u=v.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return v.useEffect(()=>u,[u]),v.useEffect(()=>{const f=a.current;return()=>{window.clearTimeout(f),l(null)}},[a,l]),d.jsx(cl,{asChild:!0,...c,children:d.jsx(mh,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":Ah(n.open),...e,ref:Ia(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:ye(e.onPointerMove,Po(f=>{s.onItemEnter(f),!f.defaultPrevented&&!e.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:ye(e.onPointerLeave,Po(f=>{var p,g;u();const h=(p=n.content)==null?void 0:p.getBoundingClientRect();if(h){const y=(g=n.content)==null?void 0:g.dataset.side,x=y==="right",m=x?-5:5,w=h[x?"left":"right"],S=h[x?"right":"left"];s.onPointerGraceIntentChange({area:[{x:f.clientX+m,y:f.clientY},{x:w,y:h.top},{x:S,y:h.top},{x:S,y:h.bottom},{x:w,y:h.bottom}],side:y}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(f),f.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ye(e.onKeyDown,f=>{var p;const h=s.searchRef.current!=="";e.disabled||h&&f.key===" "||ES[r.dir].includes(f.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),f.preventDefault())})})})});Eh.displayName=Ro;var Ih="MenuSubContent",Nh=v.forwardRef((e,t)=>{const n=uh(pn,e.__scopeMenu),{forceMount:r=n.forceMount,...o}=e,s=Tr(pn,e.__scopeMenu),i=jo(pn,e.__scopeMenu),a=Th(Ih,e.__scopeMenu),l=v.useRef(null),c=Xe(t,l);return d.jsx(_o.Provider,{scope:e.__scopeMenu,children:d.jsx(hn,{present:r||s.open,children:d.jsx(_o.Slot,{scope:e.__scopeMenu,children:d.jsx(fl,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var f;i.isUsingKeyboardRef.current&&((f=l.current)==null||f.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:ye(e.onFocusOutside,u=>{u.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ye(e.onEscapeKeyDown,u=>{i.onClose(),u.preventDefault()}),onKeyDown:ye(e.onKeyDown,u=>{var p;const f=u.currentTarget.contains(u.target),h=IS[i.dir].includes(u.key);f&&h&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),u.preventDefault())})})})})})});Nh.displayName=Ih;function Ah(e){return e?"open":"closed"}function ci(e){return e==="indeterminate"}function ml(e){return ci(e)?"indeterminate":e?"checked":"unchecked"}function qS(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function GS(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function YS(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=GS(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function XS(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],c=a.x,u=a.y,f=l.x,h=l.y;u>r!=h>r&&n<(f-c)*(r-u)/(h-u)+c&&(o=!o)}return o}function JS(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return XS(n,t)}function Po(e){return t=>t.pointerType==="mouse"?e(t):void 0}var ZS=ch,QS=cl,eC=dh,tC=fh,nC=hl,rC=hh,oC=li,sC=gh,iC=xh,aC=wh,lC=Sh,cC=Ch,uC=kh,dC=Eh,fC=Nh,ui="DropdownMenu",[hC,jT]=Wn(ui,[ah]),Qt=ah(),[pC,_h]=hC(ui),jh=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=e,l=Qt(t),c=v.useRef(null),[u,f]=Fr({prop:o,defaultProp:s??!1,onChange:i,caller:ui});return d.jsx(pC,{scope:t,triggerId:Vn(),triggerRef:c,contentId:Vn(),open:u,onOpenChange:f,onOpenToggle:v.useCallback(()=>f(h=>!h),[f]),modal:a,children:d.jsx(ZS,{...l,open:u,onOpenChange:f,dir:r,modal:a,children:n})})};jh.displayName=ui;var Rh="DropdownMenuTrigger",Ph=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=e,s=_h(Rh,n),i=Qt(n);return d.jsx(QS,{asChild:!0,...i,children:d.jsx(Oe.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:Ia(t,s.triggerRef),onPointerDown:ye(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ye(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});Ph.displayName=Rh;var mC="DropdownMenuPortal",Oh=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Qt(t);return d.jsx(eC,{...r,...n})};Oh.displayName=mC;var Mh="DropdownMenuContent",Dh=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=_h(Mh,n),s=Qt(n),i=v.useRef(!1);return d.jsx(tC,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:t,onCloseAutoFocus:ye(e.onCloseAutoFocus,a=>{var l;i.current||(l=o.triggerRef.current)==null||l.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ye(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;(!o.modal||u)&&(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)"}})});Dh.displayName=Mh;var gC="DropdownMenuGroup",yC=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qt(n);return d.jsx(nC,{...o,...r,ref:t})});yC.displayName=gC;var xC="DropdownMenuLabel",Lh=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qt(n);return d.jsx(rC,{...o,...r,ref:t})});Lh.displayName=xC;var vC="DropdownMenuItem",Fh=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qt(n);return d.jsx(oC,{...o,...r,ref:t})});Fh.displayName=vC;var wC="DropdownMenuCheckboxItem",$h=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qt(n);return d.jsx(sC,{...o,...r,ref:t})});$h.displayName=wC;var bC="DropdownMenuRadioGroup",SC=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qt(n);return d.jsx(iC,{...o,...r,ref:t})});SC.displayName=bC;var CC="DropdownMenuRadioItem",zh=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qt(n);return d.jsx(aC,{...o,...r,ref:t})});zh.displayName=CC;var kC="DropdownMenuItemIndicator",Bh=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qt(n);return d.jsx(lC,{...o,...r,ref:t})});Bh.displayName=kC;var TC="DropdownMenuSeparator",Hh=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qt(n);return d.jsx(cC,{...o,...r,ref:t})});Hh.displayName=TC;var EC="DropdownMenuArrow",IC=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qt(n);return d.jsx(uC,{...o,...r,ref:t})});IC.displayName=EC;var NC="DropdownMenuSubTrigger",Uh=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qt(n);return d.jsx(dC,{...o,...r,ref:t})});Uh.displayName=NC;var AC="DropdownMenuSubContent",Wh=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,o=Qt(n);return d.jsx(fC,{...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)"}})});Wh.displayName=AC;var _C=jh,jC=Ph,RC=Oh,Vh=Dh,Kh=Lh,qh=Fh,Gh=$h,Yh=zh,Xh=Bh,Jh=Hh,Zh=Uh,Qh=Wh;const PC=_C,OC=jC,MC=v.forwardRef(({className:e,inset:t,children:n,...r},o)=>d.jsxs(Zh,{ref:o,className:oe("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,d.jsx(fe.ChevronRight,{className:"ml-auto h-4 w-4"})]}));MC.displayName=Zh.displayName;const DC=v.forwardRef(({className:e,...t},n)=>d.jsx(Qh,{ref:n,className:oe("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}));DC.displayName=Qh.displayName;const ep=v.forwardRef(({className:e,sideOffset:t=4,...n},r)=>d.jsx(RC,{children:d.jsx(Vh,{ref:r,sideOffset:t,className:oe("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})}));ep.displayName=Vh.displayName;const gl=v.forwardRef(({className:e,inset:t,...n},r)=>d.jsx(qh,{ref:r,className:oe("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}));gl.displayName=qh.displayName;const LC=v.forwardRef(({className:e,children:t,checked:n,...r},o)=>d.jsxs(Gh,{ref:o,className:oe("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:[d.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:d.jsx(Xh,{children:d.jsx(fe.Check,{className:"h-4 w-4"})})}),t]}));LC.displayName=Gh.displayName;const FC=v.forwardRef(({className:e,children:t,...n},r)=>d.jsxs(Yh,{ref:r,className:oe("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:[d.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:d.jsx(Xh,{children:d.jsx(fe.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));FC.displayName=Yh.displayName;const $C=v.forwardRef(({className:e,inset:t,...n},r)=>d.jsx(Kh,{ref:r,className:oe("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));$C.displayName=Kh.displayName;const zC=v.forwardRef(({className:e,...t},n)=>d.jsx(Jh,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));zC.displayName=Jh.displayName;const tp={value:""};function di({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:c=!0,showToolMessages:u=!0,customStyles:f={},onMessageSent:h,onExcelUploadSuccess:p,onError:g}){const{api:y}=Fi(),{currentThreadId:x}=is(),{threadId:m,messages:w,hasMore:S,isHistoryLoading:T,isLoading:k,loadOlder:C,navigateToCheckpoint:E,returnToLatest:j,checkpoint:_,checkpoints:R,interrupt:L,metadata:z}=as(),{isStreaming:W,error:O,connectionState:B,submit:P,stop:U}=Zc(),$=m??x??null,F=(_==null?void 0:_.id)??null,ne=(_==null?void 0:_.namespace)??null,re=(z==null?void 0:z.assemblingMessageId)??null,ve=L,[Ie,Z]=b.useState(!1);b.useEffect(()=>{ve||Z(!1)},[ve]);const q=b.useCallback(()=>{Z(!0)},[]),he=b.useCallback(()=>{Z(!1)},[]),Q=!!ve||Ie,[D,G]=b.useState(null),[se,ie]=b.useState(""),[ce,je]=b.useState(null),[ue,Ze]=b.useState([]),[Je,Ve]=b.useState(0),[lt,ct]=b.useState(0),[Qe,be]=b.useState(!1),[ut,dt]=b.useState(null),[nt,rt]=b.useState(null),[Tt,wt]=b.useState(!1),[Lt,_t]=b.useState(null),[bt,Ge]=b.useState(!1),jt=b.useRef(!1),[Et,Xt]=b.useState(()=>tp.value),En=b.useRef(Et),Ke=b.useRef(null),Ee=b.useCallback(X=>{tp.value=X,Xt(X)},[]),[$t,Ft]=b.useState(!1),V=b.useCallback((X,de)=>{if(!X||typeof X!="object")return null;const xe=X[de];return typeof xe=="number"?xe:null},[]),Ce=b.useCallback((X,de)=>{if(!X||typeof X!="object")return null;const xe=X[de];return typeof xe=="string"&&xe.trim()?xe:null},[]),ge=b.useMemo(()=>{const X=Array.isArray(R)?[...R]:[];return X.some(xe=>V(xe.metadata,"step")!==null)&&X.sort((xe,He)=>{const Ct=V(xe.metadata,"step"),Jt=V(He.metadata,"step");if(Ct!==null||Jt!==null)return(Jt??Number.NEGATIVE_INFINITY)-(Ct??Number.NEGATIVE_INFINITY);const Fn=Date.parse(xe.createdAt??""),jr=Date.parse(He.createdAt??"");return Number.isNaN(Fn)||Number.isNaN(jr)?0:jr-Fn}),X},[R,V]),{checkpointMetaById:gt,checkpointIndexByKey:St}=b.useMemo(()=>{const X=new Map,de=new Map;for(const xe of ge){const He=xe.checkpointId??null;if(!He)continue;const Ct=V(xe.metadata,"step"),Jt=Ce(xe.metadata,"source"),Fn={id:He,step:Ct,source:Jt,createdAt:xe.createdAt??null,namespace:xe.checkpointNs??null,parentId:xe.parentId??null};if(X.set(He,Fn),Ct!==null&&Jt){const jr=`${Ct}:${Jt}`,Mo=de.get(jr)??[];Mo.push(Fn),de.set(jr,Mo)}}for(const xe of de.values())xe.sort((He,Ct)=>{const Jt=He.createdAt??"";return(Ct.createdAt??"").localeCompare(Jt)});return{checkpointMetaById:X,checkpointIndexByKey:de}},[ge,V,Ce]),it=b.useRef(null),Pe=b.useRef(null),Mt=b.useCallback(()=>{it.current&&(it.current.value=""),Pe.current&&(Pe.current.value=""),Ve(X=>X+1),ct(X=>X+1)},[]),De=b.useCallback(X=>{Ee(X)},[Ee]),ft=b.useRef(!1);b.useEffect(()=>{ft.current&&!W&&(Ze([]),Mt()),ft.current=W},[W,Mt]);const[ar,Xr]=b.useState("desktop");b.useEffect(()=>{const X=()=>{const de=window.innerWidth;Xr(de<640?"phone":de<1024?"tablet":"desktop")};return X(),window.addEventListener("resize",X),()=>window.removeEventListener("resize",X)},[]),b.useEffect(()=>{Ge(!1),jt.current=!1},[$]),b.useEffect(()=>{En.current=Et},[Et]),b.useEffect(()=>{if(!D){Ke.current=null;return}Ke.current===null&&(Ke.current=En.current),Ee(se??"")},[se,D,Ee]);const lr=b.useCallback(async()=>{if(!(!S||T||!bt))try{await C()}catch(X){console.warn("loadOlder failed",X)}},[S,bt,T,C]);b.useEffect(()=>{(async()=>{if(!y.baseUrl){_t(null);return}try{const xe=(await y.getAgent("default")).uiDefaultMessage||"";_t(xe||null)}catch(de){console.warn("Failed to fetch default message:",de),_t(null)}})()},[y.baseUrl]),b.useEffect(()=>{O&&!Tt&&(g==null||g(O))},[O,Tt,g]);const Ar=X=>{if(X.length>qs)return`Message too long (${X.length}/${qs} characters)`;try{return Kb(X),null}catch(de){return(de==null?void 0:de.message)||"Invalid message"}},_r=async X=>{const de=X.trim();if(!(!de&&ue.length===0)){if(de){const xe=Ar(de);if(xe){je(xe);return}}try{await P({text:de||"",attachments:ue,payload:D?{additional_kwargs:{edit:!0,originalMessageId:D}}:void 0},{checkpointId:F??void 0,checkpointNs:ne??void 0}),h==null||h(de),Ee(""),je(null),Ze([]),Mt(),G(null),ie("")}catch(xe){const He=(xe==null?void 0:xe.message)||"Failed to send message";je(He),g==null||g(He)}}},Ln=b.useCallback((X,de)=>{c&&(Ke.current=Et,G(X),ie(de),Ee(de),je(null))},[Et,c,Ee]),cr=b.useCallback(()=>{G(null),ie(""),je(null),Ee(Ke.current??Et),Ke.current=null},[Et,Ee]),I=b.useCallback((X,de)=>{Ln(X,de)},[Ln]),Y=b.useCallback(X=>{for(let de=X-1;de>=0;de--)if(w[de].role==="user"){const xe=w[de].content||[],Ct=xe.filter(Jt=>Jt.type==="text").map(Jt=>Jt.text).join("")||(()=>{try{return JSON.stringify(xe,null,2)}catch{return String(xe)}})();Ct&&P({text:Ct},{checkpointId:F??void 0,checkpointNs:ne??void 0});break}},[w,P,F,ne]),le=X=>{const de=Array.from(X.target.files||[]);Ze(xe=>[...xe,...de]),X.target.value=""},Se=X=>{Ze(de=>{const xe=de.filter((He,Ct)=>X!==Ct);return xe.length===0&&Mt(),xe})},We=async X=>{const de=(X.target.files||[])[0];if(de){dt(null),rt(null),be(!0);try{await P({attachments:[de]},{checkpointId:F??void 0,checkpointNs:ne??void 0});const xe=`Uploaded ${de.name} - processing through chat stream`;rt(xe)}catch(xe){const He=xe instanceof Error?xe.message:"Failed to upload Excel file";console.error("Excel upload failed",xe),dt(He),g==null||g(He)}finally{be(!1),X.target.value="",Mt()}}},et=async X=>{if(x){Ft(!0);try{if(!X){await j();return}const de=ge.find(He=>He.checkpointId===X),xe=(de==null?void 0:de.checkpointNs)??null;await E(X,xe)}finally{Ft(!1)}}},Be=b.useCallback(async X=>{await et(X)},[et]),Fe=`flex flex-1 w-full flex-col min-h-0 min-w-0 max-h-full overflow-hidden bg-transparent ${e} ${f.container||""}`,It=`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 ${f.messagesArea||""}`,yt=`flex-shrink-0 w-full border-t p-4 bg-transparent ${f.inputArea||""}`,ht=b.useCallback(X=>{if(!X)return"Latest";const de=[];X.step!==null&&de.push(`Step ${X.step}`),X.source&&de.push(X.source);const xe=X.createdAt?new Date(X.createdAt):null,He=xe&&!Number.isNaN(xe.getTime())?xe.toLocaleString():X.createdAt??X.id,Ct=de.length?` — ${de.join(" • ")}`:"";return`${He}${Ct}`},[]);return d.jsxs("div",{className:Fe,children:[!!O&&!Tt&&d.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:[d.jsx("span",{children:O}),d.jsx(ot,{variant:"ghost",size:"sm",onClick:()=>wt(!0),className:"text-red-800 hover:bg-red-100","aria-label":"Dismiss error",children:d.jsx(fe.X,{size:16})})]}),x&&ge.length>0&&d.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:[d.jsx("span",{className:"opacity-70",children:"Checkpoint:"}),d.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:F??"",onChange:X=>{const de=X.target.value||null;et(de)},children:[d.jsx("option",{value:"",children:"Latest"}),ge.map(X=>{const de=gt.get(X.checkpointId??"")??null;return d.jsx("option",{value:X.checkpointId??void 0,children:ht(de)},X.checkpointId)})]})]}),d.jsxs("div",{className:`relative ${It}`,style:r?{maxHeight:r}:void 0,children:[d.jsx(Va,{className:"h-full",style:{height:"100%"},messages:w,isStreaming:W,streamingAssistantId:re,streamingDebounceMs:typeof s=="number"?s:o,followNewMessages:i,layoutSize:ar,enableMessageEditing:c,editingMessageId:D,onStartReached:()=>{bt&&lr()},onScrollAway:X=>{if(!jt.current){jt.current=!0;return}X&&Ge(!0)},onEdit:I,onRegenerate:Y,onCancelEdit:cr,emptyMessage:Lt??void 0,isNavigatingCheckpoint:$t,activeInterrupt:ve,disableInterruptActions:Ie,onInterruptActionStart:q,onInterruptActionEnd:he,showToolMessages:u,checkpointMetaById:gt,checkpointIndexByKey:St,activeCheckpointId:F,onSelectCheckpoint:Be}),(B==="reconnecting"||B==="connecting")&&d.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-muted/80 px-3 py-1 text-xs font-medium text-foreground shadow-sm backdrop-blur-sm dark:bg-muted/60",children:d.jsxs("span",{className:"flex items-center gap-2",children:[d.jsx(fe.Loader2,{className:"h-3 w-3 animate-spin"}),B==="reconnecting"?"Reconnecting…":"Connecting…"]})}),B==="error"&&d.jsx("div",{className:"pointer-events-none absolute top-3 right-3 z-20 rounded-full bg-destructive/10 px-3 py-1 text-xs font-semibold text-destructive shadow-sm",children:"Connection lost"}),k&&d.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:[d.jsx(fe.Loader2,{className:"h-6 w-6 animate-spin"}),d.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Loading messages…"})]})]}),d.jsxs("div",{className:yt,children:[D&&d.jsx("div",{className:"mb-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(fe.Edit3,{size:16,className:"text-blue-600"}),d.jsx("span",{className:"text-sm font-medium text-blue-800",children:"Editing message"})]}),d.jsx(ot,{variant:"ghost",size:"sm",onClick:cr,className:"text-blue-600 hover:bg-blue-100",children:d.jsx(fe.X,{size:16})})]})}),(a||l)&&d.jsxs("div",{className:"mb-3 space-y-3",children:[a&&d.jsxs(d.Fragment,{children:[d.jsx("input",{ref:it,type:"file",multiple:!0,onChange:X=>le(X),className:"hidden"},Je),ue.length>0&&d.jsx("div",{className:"flex flex-wrap gap-2",children:ue.map((X,de)=>d.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:[d.jsx(fe.Paperclip,{size:14}),d.jsx("span",{className:"truncate max-w-[150px]",children:X.name}),d.jsx(ot,{variant:"ghost",size:"sm",onClick:()=>Se(de),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 ${X.name}`,children:d.jsx(fe.X,{size:12})})]},de))})]}),l&&d.jsxs(d.Fragment,{children:[d.jsx("input",{ref:Pe,type:"file",accept:".xls,.xlsx,.xlsm",onChange:We,className:"hidden"},lt),Qe&&d.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[d.jsx(fe.Loader2,{className:"h-4 w-4 animate-spin"})," Uploading Excel file..."]}),nt&&!Qe&&d.jsx("div",{className:"text-sm rounded border border-emerald-200 bg-emerald-50 px-3 py-2 text-emerald-700",children:nt}),ut&&!Qe&&d.jsx("div",{className:"text-sm rounded border border-red-200 bg-red-50 px-3 py-2 text-red-600",children:ut})]})]}),ce&&d.jsx("div",{className:"mb-3 text-sm text-red-600 bg-red-50 border border-red-200 rounded px-3 py-2",children:ce}),d.jsxs("div",{className:"flex items-end gap-2",children:[(a||l)&&d.jsxs(PC,{children:[d.jsx(OC,{asChild:!0,children:d.jsx(ot,{type:"button",size:"icon",variant:"outline",disabled:W||Q,title:"More input actions",className:f.moreButton||"",children:d.jsx(fe.Plus,{size:16})})}),d.jsxs(ep,{align:"start",sideOffset:6,className:"w-52",children:[a&&d.jsxs(gl,{onClick:()=>{var X;return(X=it.current)==null?void 0:X.click()},className:"cursor-pointer",children:[d.jsx(fe.Paperclip,{className:"h-4 w-4 mr-2"})," Attach files or images"]}),l&&d.jsxs(gl,{onClick:()=>{var X;Qe||(X=Pe.current)==null||X.click()},className:`cursor-pointer ${Qe?"opacity-60 pointer-events-none":""}`,children:[d.jsx(fe.FileSpreadsheet,{className:"h-4 w-4 mr-2"})," Upload Excel file"]})]})]}),d.jsx("div",{className:"flex-1",children:d.jsx(dx,{initialValue:se,editingMessageId:D,value:Et,onValueChange:De,placeholder:D?"Edit your message...":t,isStreaming:W,disabled:Q,maxLength:qs,onSend:_r,onCancelEdit:cr,onStop:U,allowEmptySend:ue.length>0,textareaClassName:`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${D?"border-blue-400 bg-blue-50 text-blue-900 dark:border-blue-500 dark:bg-blue-950/60 dark:text-blue-50":""} ${ce?"border-red-400":""} ${f.textarea||""}`})})]})]})]})}const fi=v.forwardRef(({className:e,type:t,...n},r)=>d.jsx("input",{type:t,className:oe("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}));fi.displayName="Input";function yl(e,[t,n]){return Math.min(n,Math.max(t,e))}function BC(e,t){return v.useReducer((n,r)=>t[n][r]??n,e)}var xl="ScrollArea",[np,RT]=Wn(xl),[HC,mn]=np(xl),rp=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,l]=v.useState(null),[c,u]=v.useState(null),[f,h]=v.useState(null),[p,g]=v.useState(null),[y,x]=v.useState(null),[m,w]=v.useState(0),[S,T]=v.useState(0),[k,C]=v.useState(!1),[E,j]=v.useState(!1),_=Xe(t,L=>l(L)),R=Gs(o);return d.jsx(HC,{scope:n,type:r,dir:R,scrollHideDelay:s,scrollArea:a,viewport:c,onViewportChange:u,content:f,onContentChange:h,scrollbarX:p,onScrollbarXChange:g,scrollbarXEnabled:k,onScrollbarXEnabledChange:C,scrollbarY:y,onScrollbarYChange:x,scrollbarYEnabled:E,onScrollbarYEnabledChange:j,onCornerWidthChange:w,onCornerHeightChange:T,children:d.jsx(Oe.div,{dir:R,...i,ref:_,style:{position:"relative","--radix-scroll-area-corner-width":m+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});rp.displayName=xl;var op="ScrollAreaViewport",sp=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=mn(op,n),a=v.useRef(null),l=Xe(t,a,i.onViewportChange);return d.jsxs(d.Fragment,{children:[d.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}),d.jsx(Oe.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:d.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});sp.displayName=op;var Dn="ScrollAreaScrollbar",vl=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=mn(Dn,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a=e.orientation==="horizontal";return v.useEffect(()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)}),[a,s,i]),o.type==="hover"?d.jsx(UC,{...r,ref:t,forceMount:n}):o.type==="scroll"?d.jsx(WC,{...r,ref:t,forceMount:n}):o.type==="auto"?d.jsx(ip,{...r,ref:t,forceMount:n}):o.type==="always"?d.jsx(wl,{...r,ref:t}):null});vl.displayName=Dn;var UC=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=mn(Dn,e.__scopeScrollArea),[s,i]=v.useState(!1);return v.useEffect(()=>{const a=o.scrollArea;let l=0;if(a){const c=()=>{window.clearTimeout(l),i(!0)},u=()=>{l=window.setTimeout(()=>i(!1),o.scrollHideDelay)};return a.addEventListener("pointerenter",c),a.addEventListener("pointerleave",u),()=>{window.clearTimeout(l),a.removeEventListener("pointerenter",c),a.removeEventListener("pointerleave",u)}}},[o.scrollArea,o.scrollHideDelay]),d.jsx(hn,{present:n||s,children:d.jsx(ip,{"data-state":s?"visible":"hidden",...r,ref:t})})}),WC=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=mn(Dn,e.__scopeScrollArea),s=e.orientation==="horizontal",i=gi(()=>l("SCROLL_END"),100),[a,l]=BC("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 v.useEffect(()=>{if(a==="idle"){const c=window.setTimeout(()=>l("HIDE"),o.scrollHideDelay);return()=>window.clearTimeout(c)}},[a,o.scrollHideDelay,l]),v.useEffect(()=>{const c=o.viewport,u=s?"scrollLeft":"scrollTop";if(c){let f=c[u];const h=()=>{const p=c[u];f!==p&&(l("SCROLL"),i()),f=p};return c.addEventListener("scroll",h),()=>c.removeEventListener("scroll",h)}},[o.viewport,s,l,i]),d.jsx(hn,{present:n||a!=="hidden",children:d.jsx(wl,{"data-state":a==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:ye(e.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:ye(e.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),ip=v.forwardRef((e,t)=>{const n=mn(Dn,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=v.useState(!1),a=e.orientation==="horizontal",l=gi(()=>{if(n.viewport){const c=n.viewport.offsetWidth<n.viewport.scrollWidth,u=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?c:u)}},10);return qr(n.viewport,l),qr(n.content,l),d.jsx(hn,{present:r||s,children:d.jsx(wl,{"data-state":s?"visible":"hidden",...o,ref:t})})}),wl=v.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,o=mn(Dn,e.__scopeScrollArea),s=v.useRef(null),i=v.useRef(0),[a,l]=v.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),c=dp(a.viewport,a.content),u={...r,sizes:a,onSizesChange:l,hasThumb:c>0&&c<1,onThumbChange:h=>s.current=h,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:h=>i.current=h};function f(h,p){return XC(h,i.current,a,p)}return n==="horizontal"?d.jsx(VC,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollLeft,p=fp(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"?d.jsx(KC,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const h=o.viewport.scrollTop,p=fp(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}),VC=v.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=mn(Dn,e.__scopeScrollArea),[i,a]=v.useState(),l=v.useRef(null),c=Xe(t,l,s.onScrollbarXChange);return v.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),d.jsx(lp,{"data-orientation":"horizontal",...o,ref:c,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":mi(n)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.x),onDragScroll:u=>e.onDragScroll(u.x),onWheelScroll:(u,f)=>{if(s.viewport){const h=s.viewport.scrollLeft+u.deltaX;e.onWheelScroll(h),pp(h,f)&&u.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:pi(i.paddingLeft),paddingEnd:pi(i.paddingRight)}})}})}),KC=v.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=mn(Dn,e.__scopeScrollArea),[i,a]=v.useState(),l=v.useRef(null),c=Xe(t,l,s.onScrollbarYChange);return v.useEffect(()=>{l.current&&a(getComputedStyle(l.current))},[l]),d.jsx(lp,{"data-orientation":"vertical",...o,ref:c,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":mi(n)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.y),onDragScroll:u=>e.onDragScroll(u.y),onWheelScroll:(u,f)=>{if(s.viewport){const h=s.viewport.scrollTop+u.deltaY;e.onWheelScroll(h),pp(h,f)&&u.preventDefault()}},onResize:()=>{l.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:pi(i.paddingTop),paddingEnd:pi(i.paddingBottom)}})}})}),[qC,ap]=np(Dn),lp=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:l,onDragScroll:c,onWheelScroll:u,onResize:f,...h}=e,p=mn(Dn,n),[g,y]=v.useState(null),x=Xe(t,_=>y(_)),m=v.useRef(null),w=v.useRef(""),S=p.viewport,T=r.content-r.viewport,k=Ht(u),C=Ht(l),E=gi(f,10);function j(_){if(m.current){const R=_.clientX-m.current.left,L=_.clientY-m.current.top;c({x:R,y:L})}}return v.useEffect(()=>{const _=R=>{const L=R.target;(g==null?void 0:g.contains(L))&&k(R,T)};return document.addEventListener("wheel",_,{passive:!1}),()=>document.removeEventListener("wheel",_,{passive:!1})},[S,g,T,k]),v.useEffect(C,[r,C]),qr(g,E),qr(p.content,E),d.jsx(qC,{scope:n,scrollbar:g,hasThumb:o,onThumbChange:Ht(s),onThumbPointerUp:Ht(i),onThumbPositionChange:C,onThumbPointerDown:Ht(a),children:d.jsx(Oe.div,{...h,ref:x,style:{position:"absolute",...h.style},onPointerDown:ye(e.onPointerDown,_=>{_.button===0&&(_.target.setPointerCapture(_.pointerId),m.current=g.getBoundingClientRect(),w.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",p.viewport&&(p.viewport.style.scrollBehavior="auto"),j(_))}),onPointerMove:ye(e.onPointerMove,j),onPointerUp:ye(e.onPointerUp,_=>{const R=_.target;R.hasPointerCapture(_.pointerId)&&R.releasePointerCapture(_.pointerId),document.body.style.webkitUserSelect=w.current,p.viewport&&(p.viewport.style.scrollBehavior=""),m.current=null})})})}),hi="ScrollAreaThumb",cp=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=ap(hi,e.__scopeScrollArea);return d.jsx(hn,{present:n||o.hasThumb,children:d.jsx(GC,{ref:t,...r})})}),GC=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=mn(hi,n),i=ap(hi,n),{onThumbPositionChange:a}=i,l=Xe(t,f=>i.onThumbChange(f)),c=v.useRef(void 0),u=gi(()=>{c.current&&(c.current(),c.current=void 0)},100);return v.useEffect(()=>{const f=s.viewport;if(f){const h=()=>{if(u(),!c.current){const p=JC(f,a);c.current=p,a()}};return a(),f.addEventListener("scroll",h),()=>f.removeEventListener("scroll",h)}},[s.viewport,u,a]),d.jsx(Oe.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:ye(e.onPointerDownCapture,f=>{const p=f.target.getBoundingClientRect(),g=f.clientX-p.left,y=f.clientY-p.top;i.onThumbPointerDown({x:g,y})}),onPointerUp:ye(e.onPointerUp,i.onThumbPointerUp)})});cp.displayName=hi;var bl="ScrollAreaCorner",up=v.forwardRef((e,t)=>{const n=mn(bl,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?d.jsx(YC,{...e,ref:t}):null});up.displayName=bl;var YC=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=mn(bl,n),[s,i]=v.useState(0),[a,l]=v.useState(0),c=!!(s&&a);return qr(o.scrollbarX,()=>{var f;const u=((f=o.scrollbarX)==null?void 0:f.offsetHeight)||0;o.onCornerHeightChange(u),l(u)}),qr(o.scrollbarY,()=>{var f;const u=((f=o.scrollbarY)==null?void 0:f.offsetWidth)||0;o.onCornerWidthChange(u),i(u)}),c?d.jsx(Oe.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 pi(e){return e?parseInt(e,10):0}function dp(e,t){const n=e/t;return isNaN(n)?0:n}function mi(e){const t=dp(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function XC(e,t,n,r="ltr"){const o=mi(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,u=n.content-n.viewport,f=r==="ltr"?[0,u]:[u*-1,0];return hp([l,c],f)(e)}function fp(e,t,n="ltr"){const r=mi(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],c=yl(e,l);return hp([0,i],[0,a])(c)}function hp(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 pp(e,t){return e>0&&e<t}var JC=(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 gi(e,t){const n=Ht(e),r=v.useRef(0);return v.useEffect(()=>()=>window.clearTimeout(r.current),[]),v.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function qr(e,t){const n=Ht(t);Bt(()=>{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 mp=rp,ZC=sp,QC=up;const gp=v.forwardRef(({className:e,children:t,...n},r)=>d.jsxs(mp,{ref:r,className:oe("relative overflow-hidden",e),...n,children:[d.jsx(ZC,{className:"h-full w-full rounded-[inherit] overflow-auto",children:t}),d.jsx(yp,{}),d.jsx(QC,{})]}));gp.displayName=mp.displayName;const yp=v.forwardRef(({className:e,orientation:t="vertical",...n},r)=>d.jsx(vl,{ref:r,orientation:t,className:oe("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:d.jsx(cp,{className:"relative flex-1 rounded-full bg-border"})}));yp.displayName=vl.displayName;const xp=25;function Sl({className:e="",showCreateButton:t=!0,showDeleteButton:n=!0,showEditTitle:r=!0,maxHeight:o="400px",customStyles:s={},currentThreadId:i=null,navigateToThread:a,onThreadSelect:l,onThreadCreate:c,onThreadDelete:u}){const{threads:f,currentThreadId:h,isLoading:p,actions:g}=is(),{loadThread:y}=as(),{createThread:x,deleteThread:m,renameThread:w}=g,[S,T]=b.useState(Array.isArray(f)?f:[]),k=b.useRef(S.length>0),C=b.useRef(null),E=b.useRef(0),[j,_]=b.useState(null),[R,L]=b.useState(""),[z,W]=b.useState(!1);b.useEffect(()=>{const Z=Array.isArray(f)?f:[];if(Z.length>0){k.current=!0,T(Z);return}p||(k.current=!1,T(Z))},[f,p]),b.useEffect(()=>{if(!C.current)return;const Z=C.current.querySelector("[data-radix-scroll-area-viewport]");if(!Z)return;let q=null,he=null;return q=requestAnimationFrame(()=>{he=requestAnimationFrame(()=>{Z.scrollTop=E.current})}),()=>{q!==null&&cancelAnimationFrame(q),he!==null&&cancelAnimationFrame(he)}},[S]);const O=async Z=>{try{await y(Z),a==null||a(Z),l==null||l(Z)}catch(q){console.error("Failed to select thread:",q)}},B=async()=>{try{W(!0);const Z=await x();c==null||c(Z),a==null||a(Z)}catch(Z){console.error("Failed to create thread:",Z)}finally{W(!1)}},P=async(Z,q)=>{if(q.stopPropagation(),!!confirm("Delete this thread?")){if(C.current){const he=C.current.querySelector("[data-radix-scroll-area-viewport]");he&&(E.current=he.scrollTop)}try{await m(Z),u==null||u(Z)}catch(he){console.error("Failed to delete thread:",he)}}},U=(Z,q)=>{q.stopPropagation(),_(Z.threadId),L(Z.title||`Thread ${Z.threadId.slice(0,8)}`)},$=async Z=>{if(R.trim())try{await w(Z,R.trim()),_(null),L("")}catch(q){console.error("Failed to update title:",q)}},F=()=>{_(null),L("")},ne=(Z,q)=>{Z.key==="Enter"?$(q):Z.key==="Escape"&&F()},re=Z=>{if(!Z)return"";try{const q=new Date(Z),Q=new Date().getTime()-q.getTime(),D=Math.floor(Q/(1e3*60*60*24));return D===0?q.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):D===1?"Yesterday":D<7?`${D} days ago`:q.toLocaleDateString()}catch{return""}},ve=Z=>Z.title||`Thread ${Z.threadId.slice(0,8)}`,Ie=Z=>{const q=ve(Z);return q.length<=xp?q:`${q.slice(0,xp)}...`};return d.jsxs("div",{className:`flex flex-col h-full ${e} ${s.container||""}`,children:[t&&d.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:d.jsx(ot,{onClick:B,disabled:z||p,className:s.createButton||"p-2",size:"sm",variant:"ghost",title:z?"Creating...":"New Chat",children:d.jsx(fe.MessageSquarePlus,{size:20})})}),d.jsx(gp,{ref:C,className:`flex-1 min-h-0 ${s.threadList||""}`,style:o?{maxHeight:o}:void 0,children:d.jsx("div",{className:"p-2 space-y-1 pb-4",children:p?d.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-8 text-slate-400",children:[d.jsx(fe.Loader2,{className:"h-5 w-5 animate-spin"}),d.jsx("span",{className:"text-sm",children:"Loading threads…"})]}):S.length===0?d.jsxs("div",{className:"text-center py-8 text-slate-400",children:[d.jsx(fe.MessageSquare,{className:"w-8 h-8 mx-auto mb-2 opacity-40 text-slate-500"}),d.jsx("p",{className:"text-sm text-slate-500",children:"No conversations yet"})]}):S.slice().sort((Z,q)=>new Date(q.updatedAt||q.createdAt||"").getTime()-new Date(Z.updatedAt||Z.createdAt||"").getTime()).map(Z=>d.jsxs("div",{onClick:()=>O(Z.threadId),className:`group relative p-3 rounded-lg cursor-pointer transition-colors border ${(i??h)===Z.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:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("div",{className:"flex-1 min-w-0",children:j===Z.threadId?d.jsxs("div",{className:"flex items-center gap-2",onClick:q=>q.stopPropagation(),children:[d.jsx(fi,{value:R,onChange:q=>L(q.target.value),onKeyDown:q=>ne(q,Z.threadId),className:"h-6 text-sm",autoFocus:!0}),d.jsx(ot,{variant:"ghost",size:"sm",onClick:()=>$(Z.threadId),className:"h-6 w-6 p-0",children:d.jsx(fe.Check,{size:12})}),d.jsx(ot,{variant:"ghost",size:"sm",onClick:F,className:"h-6 w-6 p-0",children:d.jsx(fe.X,{size:12})})]}):d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"font-medium text-sm truncate text-gray-900 dark:text-slate-100",children:Ie(Z)}),d.jsxs("div",{className:"flex items-center gap-2 text-xs text-gray-500 dark:text-slate-400 mt-1",children:[d.jsx(fe.Calendar,{size:10}),d.jsx("span",{children:re(Z.updatedAt||Z.createdAt)})]})]})}),d.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity ml-2",children:[r&&j!==Z.threadId&&d.jsx(ot,{variant:"ghost",size:"sm",onClick:q=>U(Z,q),className:"h-6 w-6 p-0",title:"Edit title",children:d.jsx(fe.Edit3,{size:12})}),n&&d.jsx(ot,{variant:"ghost",size:"sm",onClick:q=>P(Z.threadId,q),className:"h-6 w-6 p-0 text-red-400 hover:text-red-300 hover:bg-red-900/20",title:"Delete thread",children:d.jsx(fe.Trash2,{size:12})})]})]}),i===Z.threadId&&d.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-8 bg-blue-400 rounded-r"})]},Z.threadId))})})]})}function Gr(e){if(!(typeof globalThis>"u"))return globalThis[e]}function ek(e){if(typeof e!="string")return;const t=e.trim();if(t)return Hn(t)}function vp(){const e=[Gr("__API_BASE_URL__"),Gr("__CHAT_API_BASE_URL__"),Gr("__CHAT_API_URL__")];for(const t of e){const n=ek(t);if(n)return n}}function wp(){const e=[Gr("__API_AUTH_TOKEN__"),Gr("__CHAT_API_KEY__"),Gr("__CHAT_AUTH_TOKEN__")];for(const t of e)if(typeof t=="string"&&t.trim())return t.trim()}function bp(...e){for(const t of e)if(typeof t=="string"&&t.trim())return Hn(t);return Hn()}function Sp(){const e={},t=vp(),n=wp();return t&&(e.baseUrl=t),n&&(e.apiKey=n),e}function Cp(){const e=Sp(),t=Gn.getAuthToken(),n=vp();return{apiBaseUrl:bp(e.baseUrl,Gn.baseUrl,n),apiKey:t||e.apiKey||wp()||"",model:"gpt-4",temperature:.7,maxTokens:4096,layoutSize:"desktop",showThreads:!0,autoScrollMessages:!0,darkMode:!1,enableSound:!1,messageHistory:100}}const kp="chat-settings";function tk(){try{const e=localStorage.getItem(kp);return e?JSON.parse(e):{}}catch(e){return console.error("Failed to parse stored settings:",e),{}}}function nk(e){try{const t={...e,apiBaseUrl:Hn(e.apiBaseUrl)};localStorage.setItem(kp,JSON.stringify(t)),t.apiKey&&Gn.setAuthToken(t.apiKey)}catch(t){console.error("Failed to save settings:",t)}}function rk(){const e=Cp(),t=tk(),n=Gn.getAuthToken(),r=typeof t.apiBaseUrl=="string"?t.apiBaseUrl:void 0;return{...e,...t,apiKey:n||t.apiKey||e.apiKey,apiBaseUrl:bp(Gn.baseUrl,r,e.apiBaseUrl)}}function ok(e){Gn.updateConfig({baseUrl:e.apiBaseUrl,authToken:e.apiKey??void 0}),nk(e)}var sk="Label",Tp=v.forwardRef((e,t)=>d.jsx(Oe.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())}}));Tp.displayName=sk;var Ep=Tp;const ik=zo.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),gn=v.forwardRef(({className:e,...t},n)=>d.jsx(Ep,{ref:n,className:oe(ik(),e),...t}));gn.displayName=Ep.displayName;function Ip(e){const t=v.useRef({value:e,previous:e});return v.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var yi="Switch",[ak,PT]=Wn(yi),[lk,ck]=ak(yi),Np=v.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:u,...f}=e,[h,p]=v.useState(null),g=Xe(t,S=>p(S)),y=v.useRef(!1),x=h?u||!!h.closest("form"):!0,[m,w]=Fr({prop:o,defaultProp:s??!1,onChange:c,caller:yi});return d.jsxs(lk,{scope:n,checked:m,disabled:a,children:[d.jsx(Oe.button,{type:"button",role:"switch","aria-checked":m,"aria-required":i,"data-state":Rp(m),"data-disabled":a?"":void 0,disabled:a,value:l,...f,ref:g,onClick:ye(e.onClick,S=>{w(T=>!T),x&&(y.current=S.isPropagationStopped(),y.current||S.stopPropagation())})}),x&&d.jsx(jp,{control:h,bubbles:!y.current,name:r,value:l,checked:m,required:i,disabled:a,form:u,style:{transform:"translateX(-100%)"}})]})});Np.displayName=yi;var Ap="SwitchThumb",_p=v.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,o=ck(Ap,n);return d.jsx(Oe.span,{"data-state":Rp(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:t})});_p.displayName=Ap;var uk="SwitchBubbleInput",jp=v.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...o},s)=>{const i=v.useRef(null),a=Xe(i,s),l=Ip(n),c=zf(t);return v.useEffect(()=>{const u=i.current;if(!u)return;const f=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(f,"checked").set;if(l!==n&&p){const g=new Event("click",{bubbles:r});p.call(u,n),u.dispatchEvent(g)}},[l,n,r]),d.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});jp.displayName=uk;function Rp(e){return e?"checked":"unchecked"}var Pp=Np,dk=_p;const or=v.forwardRef(({className:e,...t},n)=>d.jsx(Pp,{className:oe("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:d.jsx(dk,{className:oe("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")})}));or.displayName=Pp.displayName;var Op=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"}),fk="VisuallyHidden",hk=v.forwardRef((e,t)=>d.jsx(Oe.span,{...e,ref:t,style:{...Op,...e.style}}));hk.displayName=fk;var pk=[" ","Enter","ArrowUp","ArrowDown"],mk=[" ","Enter"],Er="Select",[xi,vi,gk]=Ka(Er),[Yr,OT]=Wn(Er,[gk,si]),wi=si(),[yk,sr]=Yr(Er),[xk,vk]=Yr(Er),Mp=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:u,autoComplete:f,disabled:h,required:p,form:g}=e,y=wi(t),[x,m]=v.useState(null),[w,S]=v.useState(null),[T,k]=v.useState(!1),C=Gs(c),[E,j]=Fr({prop:r,defaultProp:o??!1,onChange:s,caller:Er}),[_,R]=Fr({prop:i,defaultProp:a,onChange:l,caller:Er}),L=v.useRef(null),z=x?g||!!x.closest("form"):!0,[W,O]=v.useState(new Set),B=Array.from(W).map(P=>P.props.value).join(";");return d.jsx(Xf,{...y,children:d.jsxs(yk,{required:p,scope:t,trigger:x,onTriggerChange:m,valueNode:w,onValueNodeChange:S,valueNodeHasChildren:T,onValueNodeHasChildrenChange:k,contentId:Vn(),value:_,onValueChange:R,open:E,onOpenChange:j,dir:C,triggerPointerDownPosRef:L,disabled:h,children:[d.jsx(xi.Provider,{scope:t,children:d.jsx(xk,{scope:e.__scopeSelect,onNativeOptionAdd:v.useCallback(P=>{O(U=>new Set(U).add(P))},[]),onNativeOptionRemove:v.useCallback(P=>{O(U=>{const $=new Set(U);return $.delete(P),$})},[]),children:n})}),z?d.jsxs(sm,{"aria-hidden":!0,required:p,tabIndex:-1,name:u,autoComplete:f,value:_,onChange:P=>R(P.target.value),disabled:h,form:g,children:[_===void 0?d.jsx("option",{value:""}):null,Array.from(W)]},B):null]})})};Mp.displayName=Er;var Dp="SelectTrigger",Lp=v.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...o}=e,s=wi(n),i=sr(Dp,n),a=i.disabled||r,l=Xe(t,i.onTriggerChange),c=vi(n),u=v.useRef("touch"),[f,h,p]=am(y=>{const x=c().filter(S=>!S.disabled),m=x.find(S=>S.value===i.value),w=lm(x,y,m);w!==void 0&&i.onValueChange(w.value)}),g=y=>{a||(i.onOpenChange(!0),p()),y&&(i.triggerPointerDownPosRef.current={x:Math.round(y.pageX),y:Math.round(y.pageY)})};return d.jsx(Jf,{asChild:!0,...s,children:d.jsx(Oe.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":im(i.value)?"":void 0,...o,ref:l,onClick:ye(o.onClick,y=>{y.currentTarget.focus(),u.current!=="mouse"&&g(y)}),onPointerDown:ye(o.onPointerDown,y=>{u.current=y.pointerType;const x=y.target;x.hasPointerCapture(y.pointerId)&&x.releasePointerCapture(y.pointerId),y.button===0&&y.ctrlKey===!1&&y.pointerType==="mouse"&&(g(y),y.preventDefault())}),onKeyDown:ye(o.onKeyDown,y=>{const x=f.current!=="";!(y.ctrlKey||y.altKey||y.metaKey)&&y.key.length===1&&h(y.key),!(x&&y.key===" ")&&pk.includes(y.key)&&(g(),y.preventDefault())})})})});Lp.displayName=Dp;var Fp="SelectValue",$p=v.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=e,l=sr(Fp,n),{onValueNodeHasChildrenChange:c}=l,u=s!==void 0,f=Xe(t,l.onValueNodeChange);return Bt(()=>{c(u)},[c,u]),d.jsx(Oe.span,{...a,ref:f,style:{pointerEvents:"none"},children:im(l.value)?d.jsx(d.Fragment,{children:i}):s})});$p.displayName=Fp;var wk="SelectIcon",zp=v.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...o}=e;return d.jsx(Oe.span,{"aria-hidden":!0,...o,ref:t,children:r||"▼"})});zp.displayName=wk;var bk="SelectPortal",Bp=e=>d.jsx(Is,{asChild:!0,...e});Bp.displayName=bk;var Ir="SelectContent",Hp=v.forwardRef((e,t)=>{const n=sr(Ir,e.__scopeSelect),[r,o]=v.useState();if(Bt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?Bo.createPortal(d.jsx(Up,{scope:e.__scopeSelect,children:d.jsx(xi.Slot,{scope:e.__scopeSelect,children:d.jsx("div",{children:e.children})})}),s):null}return d.jsx(Wp,{...e,ref:t})});Hp.displayName=Ir;var Tn=10,[Up,ir]=Yr(Ir),Sk="SelectContentImpl",Ck=dr.createSlot("SelectContent.RemoveScroll"),Wp=v.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:u,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:g,hideWhenDetached:y,avoidCollisions:x,...m}=e,w=sr(Ir,n),[S,T]=v.useState(null),[k,C]=v.useState(null),E=Xe(t,Q=>T(Q)),[j,_]=v.useState(null),[R,L]=v.useState(null),z=vi(n),[W,O]=v.useState(!1),B=v.useRef(!1);v.useEffect(()=>{if(S)return Fa(S)},[S]),Ra();const P=v.useCallback(Q=>{const[D,...G]=z().map(ce=>ce.ref.current),[se]=G.slice(-1),ie=document.activeElement;for(const ce of Q)if(ce===ie||(ce==null||ce.scrollIntoView({block:"nearest"}),ce===D&&k&&(k.scrollTop=0),ce===se&&k&&(k.scrollTop=k.scrollHeight),ce==null||ce.focus(),document.activeElement!==ie))return},[z,k]),U=v.useCallback(()=>P([j,S]),[P,j,S]);v.useEffect(()=>{W&&U()},[W,U]);const{onOpenChange:$,triggerPointerDownPosRef:F}=w;v.useEffect(()=>{if(S){let Q={x:0,y:0};const D=se=>{var ie,ce;Q={x:Math.abs(Math.round(se.pageX)-(((ie=F.current)==null?void 0:ie.x)??0)),y:Math.abs(Math.round(se.pageY)-(((ce=F.current)==null?void 0:ce.y)??0))}},G=se=>{Q.x<=10&&Q.y<=10?se.preventDefault():S.contains(se.target)||$(!1),document.removeEventListener("pointermove",D),F.current=null};return F.current!==null&&(document.addEventListener("pointermove",D),document.addEventListener("pointerup",G,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",G,{capture:!0})}}},[S,$,F]),v.useEffect(()=>{const Q=()=>$(!1);return window.addEventListener("blur",Q),window.addEventListener("resize",Q),()=>{window.removeEventListener("blur",Q),window.removeEventListener("resize",Q)}},[$]);const[ne,re]=am(Q=>{const D=z().filter(ie=>!ie.disabled),G=D.find(ie=>ie.ref.current===document.activeElement),se=lm(D,Q,G);se&&setTimeout(()=>se.ref.current.focus())}),ve=v.useCallback((Q,D,G)=>{const se=!B.current&&!G;(w.value!==void 0&&w.value===D||se)&&(_(Q),se&&(B.current=!0))},[w.value]),Ie=v.useCallback(()=>S==null?void 0:S.focus(),[S]),Z=v.useCallback((Q,D,G)=>{const se=!B.current&&!G;(w.value!==void 0&&w.value===D||se)&&L(Q)},[w.value]),q=r==="popper"?Cl:Vp,he=q===Cl?{side:a,sideOffset:l,align:c,alignOffset:u,arrowPadding:f,collisionBoundary:h,collisionPadding:p,sticky:g,hideWhenDetached:y,avoidCollisions:x}:{};return d.jsx(Up,{scope:n,content:S,viewport:k,onViewportChange:C,itemRefCallback:ve,selectedItem:j,onItemLeave:Ie,itemTextRefCallback:Z,focusSelectedItem:U,selectedItemText:R,position:r,isPositioned:W,searchRef:ne,children:d.jsx(Os,{as:Ck,allowPinchZoom:!0,children:d.jsx(Es,{asChild:!0,trapped:w.open,onMountAutoFocus:Q=>{Q.preventDefault()},onUnmountAutoFocus:ye(o,Q=>{var D;(D=w.trigger)==null||D.focus({preventScroll:!0}),Q.preventDefault()}),children:d.jsx(Ts,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:Q=>Q.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:d.jsx(q,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:Q=>Q.preventDefault(),...m,...he,onPlaced:()=>O(!0),ref:E,style:{display:"flex",flexDirection:"column",outline:"none",...m.style},onKeyDown:ye(m.onKeyDown,Q=>{const D=Q.ctrlKey||Q.altKey||Q.metaKey;if(Q.key==="Tab"&&Q.preventDefault(),!D&&Q.key.length===1&&re(Q.key),["ArrowUp","ArrowDown","Home","End"].includes(Q.key)){let se=z().filter(ie=>!ie.disabled).map(ie=>ie.ref.current);if(["ArrowUp","End"].includes(Q.key)&&(se=se.slice().reverse()),["ArrowUp","ArrowDown"].includes(Q.key)){const ie=Q.target,ce=se.indexOf(ie);se=se.slice(ce+1)}setTimeout(()=>P(se)),Q.preventDefault()}})})})})})})});Wp.displayName=Sk;var kk="SelectItemAlignedPosition",Vp=v.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...o}=e,s=sr(Ir,n),i=ir(Ir,n),[a,l]=v.useState(null),[c,u]=v.useState(null),f=Xe(t,E=>u(E)),h=vi(n),p=v.useRef(!1),g=v.useRef(!0),{viewport:y,selectedItem:x,selectedItemText:m,focusSelectedItem:w}=i,S=v.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&y&&x&&m){const E=s.trigger.getBoundingClientRect(),j=c.getBoundingClientRect(),_=s.valueNode.getBoundingClientRect(),R=m.getBoundingClientRect();if(s.dir!=="rtl"){const ie=R.left-j.left,ce=_.left-ie,je=E.left-ce,ue=E.width+je,Ze=Math.max(ue,j.width),Je=window.innerWidth-Tn,Ve=yl(ce,[Tn,Math.max(Tn,Je-Ze)]);a.style.minWidth=ue+"px",a.style.left=Ve+"px"}else{const ie=j.right-R.right,ce=window.innerWidth-_.right-ie,je=window.innerWidth-E.right-ce,ue=E.width+je,Ze=Math.max(ue,j.width),Je=window.innerWidth-Tn,Ve=yl(ce,[Tn,Math.max(Tn,Je-Ze)]);a.style.minWidth=ue+"px",a.style.right=Ve+"px"}const L=h(),z=window.innerHeight-Tn*2,W=y.scrollHeight,O=window.getComputedStyle(c),B=parseInt(O.borderTopWidth,10),P=parseInt(O.paddingTop,10),U=parseInt(O.borderBottomWidth,10),$=parseInt(O.paddingBottom,10),F=B+P+W+$+U,ne=Math.min(x.offsetHeight*5,F),re=window.getComputedStyle(y),ve=parseInt(re.paddingTop,10),Ie=parseInt(re.paddingBottom,10),Z=E.top+E.height/2-Tn,q=z-Z,he=x.offsetHeight/2,Q=x.offsetTop+he,D=B+P+Q,G=F-D;if(D<=Z){const ie=L.length>0&&x===L[L.length-1].ref.current;a.style.bottom="0px";const ce=c.clientHeight-y.offsetTop-y.offsetHeight,je=Math.max(q,he+(ie?Ie:0)+ce+U),ue=D+je;a.style.height=ue+"px"}else{const ie=L.length>0&&x===L[0].ref.current;a.style.top="0px";const je=Math.max(Z,B+y.offsetTop+(ie?ve:0)+he)+G;a.style.height=je+"px",y.scrollTop=D-Z+y.offsetTop}a.style.margin=`${Tn}px 0`,a.style.minHeight=ne+"px",a.style.maxHeight=z+"px",r==null||r(),requestAnimationFrame(()=>p.current=!0)}},[h,s.trigger,s.valueNode,a,c,y,x,m,s.dir,r]);Bt(()=>S(),[S]);const[T,k]=v.useState();Bt(()=>{c&&k(window.getComputedStyle(c).zIndex)},[c]);const C=v.useCallback(E=>{E&&g.current===!0&&(S(),w==null||w(),g.current=!1)},[S,w]);return d.jsx(Ek,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:p,onScrollButtonChange:C,children:d.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:T},children:d.jsx(Oe.div,{...o,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Vp.displayName=kk;var Tk="SelectPopperPosition",Cl=v.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Tn,...s}=e,i=wi(n);return d.jsx(Zf,{...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)"}})});Cl.displayName=Tk;var[Ek,kl]=Yr(Ir,{}),Tl="SelectViewport",Kp=v.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...o}=e,s=ir(Tl,n),i=kl(Tl,n),a=Xe(t,s.onViewportChange),l=v.useRef(0);return d.jsxs(d.Fragment,{children:[d.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}),d.jsx(xi.Slot,{scope:n,children:d.jsx(Oe.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ye(o.onScroll,c=>{const u=c.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:h}=i;if(h!=null&&h.current&&f){const p=Math.abs(l.current-u.scrollTop);if(p>0){const g=window.innerHeight-Tn*2,y=parseFloat(f.style.minHeight),x=parseFloat(f.style.height),m=Math.max(y,x);if(m<g){const w=m+p,S=Math.min(g,w),T=w-S;f.style.height=S+"px",f.style.bottom==="0px"&&(u.scrollTop=T>0?T:0,f.style.justifyContent="flex-end")}}}l.current=u.scrollTop})})})]})});Kp.displayName=Tl;var qp="SelectGroup",[Ik,Nk]=Yr(qp),Ak=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Vn();return d.jsx(Ik,{scope:n,id:o,children:d.jsx(Oe.div,{role:"group","aria-labelledby":o,...r,ref:t})})});Ak.displayName=qp;var Gp="SelectLabel",Yp=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=Nk(Gp,n);return d.jsx(Oe.div,{id:o.id,...r,ref:t})});Yp.displayName=Gp;var bi="SelectItem",[_k,Xp]=Yr(bi),Jp=v.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=e,a=sr(bi,n),l=ir(bi,n),c=a.value===r,[u,f]=v.useState(s??""),[h,p]=v.useState(!1),g=Xe(t,w=>{var S;return(S=l.itemRefCallback)==null?void 0:S.call(l,w,r,o)}),y=Vn(),x=v.useRef("touch"),m=()=>{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 d.jsx(_k,{scope:n,value:r,disabled:o,textId:y,isSelected:c,onItemTextChange:v.useCallback(w=>{f(S=>S||((w==null?void 0:w.textContent)??"").trim())},[]),children:d.jsx(xi.ItemSlot,{scope:n,value:r,disabled:o,textValue:u,children:d.jsx(Oe.div,{role:"option","aria-labelledby":y,"data-highlighted":h?"":void 0,"aria-selected":c&&h,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:g,onFocus:ye(i.onFocus,()=>p(!0)),onBlur:ye(i.onBlur,()=>p(!1)),onClick:ye(i.onClick,()=>{x.current!=="mouse"&&m()}),onPointerUp:ye(i.onPointerUp,()=>{x.current==="mouse"&&m()}),onPointerDown:ye(i.onPointerDown,w=>{x.current=w.pointerType}),onPointerMove:ye(i.onPointerMove,w=>{var S;x.current=w.pointerType,o?(S=l.onItemLeave)==null||S.call(l):x.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ye(i.onPointerLeave,w=>{var S;w.currentTarget===document.activeElement&&((S=l.onItemLeave)==null||S.call(l))}),onKeyDown:ye(i.onKeyDown,w=>{var T;((T=l.searchRef)==null?void 0:T.current)!==""&&w.key===" "||(mk.includes(w.key)&&m(),w.key===" "&&w.preventDefault())})})})})});Jp.displayName=bi;var Oo="SelectItemText",Zp=v.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:o,...s}=e,i=sr(Oo,n),a=ir(Oo,n),l=Xp(Oo,n),c=vk(Oo,n),[u,f]=v.useState(null),h=Xe(t,m=>f(m),l.onItemTextChange,m=>{var w;return(w=a.itemTextRefCallback)==null?void 0:w.call(a,m,l.value,l.disabled)}),p=u==null?void 0:u.textContent,g=v.useMemo(()=>d.jsx("option",{value:l.value,disabled:l.disabled,children:p},l.value),[l.disabled,l.value,p]),{onNativeOptionAdd:y,onNativeOptionRemove:x}=c;return Bt(()=>(y(g),()=>x(g)),[y,x,g]),d.jsxs(d.Fragment,{children:[d.jsx(Oe.span,{id:l.textId,...s,ref:h}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?Bo.createPortal(s.children,i.valueNode):null]})});Zp.displayName=Oo;var Qp="SelectItemIndicator",em=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return Xp(Qp,n).isSelected?d.jsx(Oe.span,{"aria-hidden":!0,...r,ref:t}):null});em.displayName=Qp;var El="SelectScrollUpButton",tm=v.forwardRef((e,t)=>{const n=ir(El,e.__scopeSelect),r=kl(El,e.__scopeSelect),[o,s]=v.useState(!1),i=Xe(t,r.onScrollButtonChange);return Bt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?d.jsx(rm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});tm.displayName=El;var Il="SelectScrollDownButton",nm=v.forwardRef((e,t)=>{const n=ir(Il,e.__scopeSelect),r=kl(Il,e.__scopeSelect),[o,s]=v.useState(!1),i=Xe(t,r.onScrollButtonChange);return Bt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,u=Math.ceil(l.scrollTop)<c;s(u)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?d.jsx(rm,{...e,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});nm.displayName=Il;var rm=v.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=e,s=ir("SelectScrollButton",n),i=v.useRef(null),a=vi(n),l=v.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return v.useEffect(()=>()=>l(),[l]),Bt(()=>{var u;const c=a().find(f=>f.ref.current===document.activeElement);(u=c==null?void 0:c.ref.current)==null||u.scrollIntoView({block:"nearest"})},[a]),d.jsx(Oe.div,{"aria-hidden":!0,...o,ref:t,style:{flexShrink:0,...o.style},onPointerDown:ye(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ye(o.onPointerMove,()=>{var c;(c=s.onItemLeave)==null||c.call(s),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ye(o.onPointerLeave,()=>{l()})})}),jk="SelectSeparator",om=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return d.jsx(Oe.div,{"aria-hidden":!0,...r,ref:t})});om.displayName=jk;var Nl="SelectArrow",Rk=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,o=wi(n),s=sr(Nl,n),i=ir(Nl,n);return s.open&&i.position==="popper"?d.jsx(Qf,{...o,...r,ref:t}):null});Rk.displayName=Nl;var Pk="SelectBubbleInput",sm=v.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const o=v.useRef(null),s=Xe(r,o),i=Ip(t);return v.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,u=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==t&&u){const f=new Event("change",{bubbles:!0});u.call(a,t),a.dispatchEvent(f)}},[i,t]),d.jsx(Oe.select,{...n,style:{...Op,...n.style},ref:s,defaultValue:t})});sm.displayName=Pk;function im(e){return e===""||e===void 0}function am(e){const t=Ht(e),n=v.useRef(""),r=v.useRef(0),o=v.useCallback(i=>{const a=n.current+i;t(a),function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),s=v.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return v.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function lm(e,t,n){const o=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let i=Ok(e,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function Ok(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Mk=Mp,cm=Lp,Dk=$p,Lk=zp,Fk=Bp,um=Hp,$k=Kp,dm=Yp,fm=Jp,zk=Zp,Bk=em,hm=tm,pm=nm,mm=om;const gm=Mk,ym=Dk,Al=v.forwardRef(({className:e,children:t,...n},r)=>d.jsxs(cm,{ref:r,className:oe("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,d.jsx(Lk,{asChild:!0,children:d.jsx(fe.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));Al.displayName=cm.displayName;const xm=v.forwardRef(({className:e,...t},n)=>d.jsx(hm,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:d.jsx(fe.ChevronUp,{className:"h-4 w-4"})}));xm.displayName=hm.displayName;const vm=v.forwardRef(({className:e,...t},n)=>d.jsx(pm,{ref:n,className:oe("flex cursor-default items-center justify-center py-1",e),...t,children:d.jsx(fe.ChevronDown,{className:"h-4 w-4"})}));vm.displayName=pm.displayName;const _l=v.forwardRef(({className:e,children:t,position:n="popper",...r},o)=>d.jsx(Fk,{children:d.jsxs(um,{ref:o,className:oe("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:[d.jsx(xm,{}),d.jsx($k,{className:oe("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),d.jsx(vm,{})]})}));_l.displayName=um.displayName;const Hk=v.forwardRef(({className:e,...t},n)=>d.jsx(dm,{ref:n,className:oe("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Hk.displayName=dm.displayName;const Nr=v.forwardRef(({className:e,children:t,...n},r)=>d.jsxs(fm,{ref:r,className:oe("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:[d.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:d.jsx(Bk,{children:d.jsx(fe.Check,{className:"h-4 w-4"})})}),d.jsx(zk,{children:t})]}));Nr.displayName=fm.displayName;const Uk=v.forwardRef(({className:e,...t},n)=>d.jsx(mm,{ref:n,className:oe("-mx-1 my-1 h-px bg-muted",e),...t}));Uk.displayName=mm.displayName;var Wk="Separator",wm="horizontal",Vk=["horizontal","vertical"],bm=v.forwardRef((e,t)=>{const{decorative:n,orientation:r=wm,...o}=e,s=Kk(r)?r:wm,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return d.jsx(Oe.div,{"data-orientation":s,...a,...o,ref:t})});bm.displayName=Wk;function Kk(e){return Vk.includes(e)}var Sm=bm;const Cm=v.forwardRef(({className:e,orientation:t="horizontal",decorative:n=!0,...r},o)=>d.jsx(Sm,{ref:o,decorative:n,orientation:t,className:oe("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...r}));Cm.displayName=Sm.displayName;const qk=Kd,Gk=hb,Yk=qd,km=v.forwardRef(({className:e,...t},n)=>d.jsx($s,{className:oe("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}));km.displayName=$s.displayName;const Xk=zo.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"}}),Tm=v.forwardRef(({side:e="right",className:t,children:n,...r},o)=>d.jsxs(Yk,{children:[d.jsx(km,{}),d.jsxs(zs,{ref:o,className:oe(Xk({side:e}),t),...r,children:[n,d.jsxs(Gd,{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:[d.jsx(fe.X,{className:"h-4 w-4"}),d.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Tm.displayName=zs.displayName;const Em=({className:e,...t})=>d.jsx("div",{className:oe("flex flex-col space-y-2 text-center sm:text-left",e),...t});Em.displayName="SheetHeader";const Im=v.forwardRef(({className:e,...t},n)=>d.jsx(br,{ref:n,className:oe("text-lg font-semibold text-foreground",e),...t}));Im.displayName=br.displayName;const Nm=v.forwardRef(({className:e,...t},n)=>d.jsx(Bs,{ref:n,className:oe("text-sm text-muted-foreground",e),...t}));Nm.displayName=Bs.displayName;const Jk={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 Zk({settings:e,onSettingsChange:t,className:n=""}){const[r,o]=b.useState(!1),[s,i]=b.useState(!1),[a,l]=b.useState(e),[c,u]=b.useState(!1),{toast:f}=Ta();b.useEffect(()=>{const x=JSON.stringify(a)!==JSON.stringify(e);u(x)},[a,e]),b.useEffect(()=>{l(e)},[e]);const h=()=>{t(a),u(!1),f({title:"Settings saved",description:"Your chat configuration has been updated successfully."})},p=()=>{l(Jk),u(!0),f({title:"Settings reset",description:"Configuration has been reset to defaults."})},g=()=>{l(e),u(!1),o(!1)},y=async()=>{try{const m=await(await fetch(`${a.api.baseUrl}/health`)).json();f({title:"Connection successful",description:`API is ${m.status||"healthy"}`})}catch{f({title:"Connection failed",description:"Unable to connect to the API endpoint.",variant:"destructive"})}};return d.jsxs(qk,{open:r,onOpenChange:o,children:[d.jsx(Gk,{asChild:!0,children:d.jsxs(ot,{variant:"outline",size:"sm",className:n,children:[d.jsx(fe.Settings,{className:"h-4 w-4 mr-2"}),"Settings",c&&d.jsx(Zu,{variant:"destructive",className:"ml-2 h-4 w-4 p-0"})]})}),d.jsxs(Tm,{className:"w-[500px] sm:w-[600px] overflow-y-auto",children:[d.jsxs(Em,{children:[d.jsx(Im,{children:"Chat Settings"}),d.jsx(Nm,{children:"Configure your chat interface, API connection, and behavior preferences."})]}),d.jsxs("div",{className:"space-y-6 py-6",children:[d.jsxs(yo,{children:[d.jsx(xo,{className:"pb-3",children:d.jsxs(vo,{className:"text-lg flex items-center gap-2",children:[d.jsx(fe.Server,{className:"h-5 w-5"}),"API Configuration"]})}),d.jsxs(wo,{className:"space-y-4",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(gn,{htmlFor:"api-url",children:"API Base URL"}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx(fi,{id:"api-url",value:a.api.baseUrl,onChange:x=>l(m=>({...m,api:{...m.api,baseUrl:x.target.value}})),placeholder:"http://localhost:8000/api"}),d.jsx(ot,{variant:"outline",onClick:y,children:"Test"})]})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx(gn,{htmlFor:"enable-auth",children:"Enable Authentication"}),d.jsx(or,{id:"enable-auth",checked:a.api.enableAuth,onCheckedChange:x=>l(m=>({...m,api:{...m.api,enableAuth:x}}))})]}),a.api.enableAuth&&d.jsxs("div",{className:"space-y-2",children:[d.jsx(gn,{htmlFor:"auth-token",children:"Authentication Token"}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx(fi,{id:"auth-token",type:s?"text":"password",value:a.api.authToken,onChange:x=>l(m=>({...m,api:{...m.api,authToken:x.target.value}})),placeholder:"Enter your Bearer token"}),d.jsx(ot,{variant:"outline",size:"icon",onClick:()=>i(!s),children:s?d.jsx(fe.EyeOff,{className:"h-4 w-4"}):d.jsx(fe.Eye,{className:"h-4 w-4"})})]})]})]})]}),d.jsxs(yo,{children:[d.jsx(xo,{className:"pb-3",children:d.jsxs(vo,{className:"text-lg flex items-center gap-2",children:[d.jsx(fe.Layout,{className:"h-5 w-5"}),"Interface Settings"]})}),d.jsxs(wo,{className:"space-y-4",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(gn,{htmlFor:"layout",children:"Layout Style"}),d.jsxs(gm,{value:a.ui.layout,onValueChange:x=>l(m=>({...m,ui:{...m.ui,layout:x}})),children:[d.jsx(Al,{children:d.jsx(ym,{})}),d.jsxs(_l,{children:[d.jsx(Nr,{value:"sidebar",children:"Sidebar Layout"}),d.jsx(Nr,{value:"fullscreen",children:"Fullscreen"}),d.jsx(Nr,{value:"tabs",children:"Tabbed Interface"})]})]})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(gn,{htmlFor:"theme",children:"Theme"}),d.jsxs(gm,{value:a.ui.theme,onValueChange:x=>l(m=>({...m,ui:{...m.ui,theme:x}})),children:[d.jsx(Al,{children:d.jsx(ym,{})}),d.jsxs(_l,{children:[d.jsx(Nr,{value:"light",children:"Light"}),d.jsx(Nr,{value:"dark",children:"Dark"}),d.jsx(Nr,{value:"system",children:"System"})]})]})]}),d.jsx(Cm,{}),d.jsxs("div",{className:"space-y-3",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx(gn,{htmlFor:"show-timestamps",children:"Show Timestamps"}),d.jsx(or,{id:"show-timestamps",checked:a.ui.showTimestamps,onCheckedChange:x=>l(m=>({...m,ui:{...m.ui,showTimestamps:x}}))})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx(gn,{htmlFor:"show-agent-names",children:"Show Agent Names"}),d.jsx(or,{id:"show-agent-names",checked:a.ui.showAgentNames,onCheckedChange:x=>l(m=>({...m,ui:{...m.ui,showAgentNames:x}}))})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx(gn,{htmlFor:"compact-messages",children:"Compact Messages"}),d.jsx(or,{id:"compact-messages",checked:a.ui.compactMessages,onCheckedChange:x=>l(m=>({...m,ui:{...m.ui,compactMessages:x}}))})]})]})]})]}),d.jsxs(yo,{children:[d.jsx(xo,{className:"pb-3",children:d.jsxs(vo,{className:"text-lg flex items-center gap-2",children:[d.jsx(fe.MessageCircle,{className:"h-5 w-5"}),"Behavior Settings"]})}),d.jsxs(wo,{className:"space-y-4",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{children:[d.jsx(gn,{htmlFor:"auto-save",children:"Auto-save Conversations"}),d.jsx("p",{className:"text-sm text-muted-foreground",children:"Automatically save messages to threads"})]}),d.jsx(or,{id:"auto-save",checked:a.behavior.autoSave,onCheckedChange:x=>l(m=>({...m,behavior:{...m.behavior,autoSave:x}}))})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{children:[d.jsx(gn,{htmlFor:"enable-streaming",children:"Enable Streaming"}),d.jsx("p",{className:"text-sm text-muted-foreground",children:"Stream responses in real-time"})]}),d.jsx(or,{id:"enable-streaming",checked:a.behavior.enableStreaming,onCheckedChange:x=>l(m=>({...m,behavior:{...m.behavior,enableStreaming:x}}))})]}),d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{children:[d.jsx(gn,{htmlFor:"typing-indicator",children:"Typing Indicator"}),d.jsx("p",{className:"text-sm text-muted-foreground",children:"Show typing indicator during responses"})]}),d.jsx(or,{id:"typing-indicator",checked:a.behavior.showTypingIndicator,onCheckedChange:x=>l(m=>({...m,behavior:{...m.behavior,showTypingIndicator:x}}))})]})]})]})]}),d.jsxs("div",{className:"flex items-center justify-between pt-6 border-t",children:[d.jsxs(ot,{variant:"outline",onClick:p,children:[d.jsx(fe.RotateCcw,{className:"h-4 w-4 mr-2"}),"Reset"]}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx(ot,{variant:"outline",onClick:g,children:"Cancel"}),d.jsxs(ot,{onClick:h,disabled:!c,children:[d.jsx(fe.Save,{className:"h-4 w-4 mr-2"}),"Save Changes"]})]})]})]})]})}function Qk({layout:e="sidebar",layoutSize:t="desktop",showThreads:n=!0,className:r="",customStyles:o={},...s}){const i=c=>{const u="h-full";switch(c){case"phone":return`${u} max-w-none`;case"tablet":return`${u} max-w-4xl mx-auto`;case"half-screen":return`${u} max-w-2xl`;case"desktop":default:return`${u} max-w-7xl mx-auto`}},a=c=>({"--chat-sidebar-width":c==="phone"?"100%":c==="tablet"?"280px":c==="half-screen"?"240px":"320px","--chat-message-max-width":c==="phone"?"95%":c==="tablet"?"90%":c==="half-screen"?"85%":"80%","--chat-input-height":c==="phone"?"120px":"100px"}),l=b.useCallback(c=>{var u;(u=s.onThreadChange)==null||u.call(s,c)},[s]);return e==="fullscreen"?d.jsx(ls,{...s,onThreadChange:l,children:d.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:d.jsx(di,{className:"flex-1",onError:s.onError,enableFileUpload:!0})})}):e==="tabs"?d.jsx(ls,{...s,onThreadChange:l,children:d.jsx("div",{className:`${i(t)} flex flex-col overflow-hidden ${r} ${o.container||""}`,style:a(t),children:d.jsxs("div",{className:"flex-1 flex min-h-0 overflow-hidden",children:[n&&d.jsx("div",{className:`w-80 border-r flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:d.jsx(Sl,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),d.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:d.jsx(di,{onError:s.onError,enableFileUpload:!0})})]})})}):d.jsx(ls,{...s,onThreadChange:l,children:d.jsxs("div",{className:`${i(t)} flex overflow-hidden ${r} ${o.container||""}`,style:a(t),children:[n&&d.jsx("div",{className:`w-80 border-r bg-gray-50 flex-shrink-0 overflow-hidden ${o.sidebar||""}`,children:d.jsx(Sl,{showCreateButton:!0,showDeleteButton:!0,showEditTitle:!0,className:"h-full"})}),d.jsx("div",{className:`flex-1 min-w-0 overflow-hidden ${o.chatArea||""}`,children:d.jsx(di,{onError:s.onError,enableFileUpload:!0})})]})})}_e.ChatApi=Ic,_e.ChatInterface=di,_e.ChatProviders=ls,_e.ChatSettings=Zk,_e.MarkdownContent=ko,_e.MessageComponent=Wa,_e.MessageList=Va,_e.ThreadManager=Sl,_e.applySettings=ok,_e.chatApiClient=Gn,_e.default=Qk,_e.del=Ec,_e.get=xn,_e.getChatToken=Cc,_e.getCurrentSettings=rk,_e.getDefaultApiConfig=Sp,_e.getDefaultChatSettings=Cp,_e.onChatTokenChanged=kc,_e.post=Li,_e.put=Tc,_e.setChatToken=Di,_e.useApi=Fi,_e.useChatStream=Hc,_e.useMessagesReducer=Oc,_e.useStream=Zc,_e.useThreadState=as,_e.useThreads=is,Object.defineProperties(_e,{__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.105",
3
+ "version": "4.3.106",
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",