teodor-new-chat-ui 3.0.58 → 3.0.59
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 +1 -1
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -6846,7 +6846,7 @@ function ea(e) {
|
|
|
6846
6846
|
return e ? "open" : "closed";
|
|
6847
6847
|
}
|
|
6848
6848
|
var Yx = Nu;
|
|
6849
|
-
const Ol = Yx, Ml = Au, ku = new URL("data:video/mp2t;base64,
|
|
6849
|
+
const Ol = Yx, Ml = Au, ku = new URL("data:video/mp2t;base64,aW1wb3J0IHsgcGFyc2UgfSBmcm9tICdtYXJrZWQnOwoKY29uc3Qgc2NvcGUgPSBzZWxmOwoKY29uc29sZS5sb2coJ1tNYXJrZG93bldvcmtlcl0gd29ya2VyIHNjcmlwdCBsb2FkZWQnKTsKLy8gU2lnbmFsIHRvIHRoZSBtYWluIHRocmVhZCB0aGF0IHRoZSB3b3JrZXIgaXMgcmVhZHkgdG8gcmVjZWl2ZSB3b3JrLgovLyBUaGlzIGhlbHBzIGNhbGxlcnMgYXZvaWQgcG9zdGluZyBtZXNzYWdlcyBiZWZvcmUgdGhlIHdvcmtlciBoYXMgZmluaXNoZWQgaW5pdGlhbGl6aW5nLgpzY29wZS5wb3N0TWVzc2FnZT8uKHsgX193b3JrZXJfcmVhZHk6IHRydWUgfSk7CgpzY29wZS5hZGRFdmVudExpc3RlbmVyKCdtZXNzYWdlJywgKGV2ZW50KSA9PiB7CiAgY29uc3QgcGF5bG9hZCA9IGV2ZW50Py5kYXRhID8/IHt9OwogIGNvbnN0IGlkID0gdHlwZW9mIHBheWxvYWQuaWQgPT09ICdzdHJpbmcnID8gcGF5bG9hZC5pZCA6IHVuZGVmaW5lZDsKICBjb25zdCBzb3VyY2UgPSB0eXBlb2YgcGF5bG9hZC5zb3VyY2UgPT09ICdzdHJpbmcnID8gcGF5bG9hZC5zb3VyY2UgOiB1bmRlZmluZWQ7CiAgaWYgKCFpZCB8fCB0eXBlb2Ygc291cmNlICE9PSAnc3RyaW5nJykgewogICAgcmV0dXJuOwogIH0KICB0cnkgewogICAgY29uc29sZS5sb2coJ1tNYXJrZG93bldvcmtlcl0gcmVjZWl2ZWQgd29yaycsIGlkLCAnc291cmNlTGVuJywgc291cmNlPy5sZW5ndGggPz8gMCk7CiAgICBjb25zdCBodG1sID0gcGFyc2Uoc291cmNlKTsKICAgIGNvbnNvbGUubG9nKCdbTWFya2Rvd25Xb3JrZXJdIHBhcnNlZCBodG1sIGxlbmd0aCcsIGh0bWw/Lmxlbmd0aCA/PyAwLCAnZm9yJywgaWQpOwogICAgLy8gUmV0dXJuIHRoZSBnZW5lcmF0ZWQgSFRNTCBmb3IgdGhlIGNhbGxlciB0byBjYWNoZSBhbmQgcmVuZGVyCiAgICAvLyBLZWVwIHRoZSBwYXlsb2FkIHNtYWxsOiBzZW5kIGlkICsgaHRtbAogICAgLy8gTWFya2VkIG91dHB1dCBzaG91bGQgYmUgc2FmZS1lbm91Z2ggZm9yIGludGVybmFsIFVJczsgY2FsbGVycyBtYXkgZnVydGhlciBzYW5pdGl6ZSBpZiByZXF1aXJlZC4KICAgIHNjb3BlLnBvc3RNZXNzYWdlKHsgaWQsIGh0bWwgfSk7CiAgfSBjYXRjaCAoZXJyKSB7CiAgICBjb25zb2xlLmVycm9yKCdbTWFya2Rvd25Xb3JrZXJdIHJlbmRlciBlcnJvcicsIGVycik7CiAgICBzY29wZS5wb3N0TWVzc2FnZSh7IGlkLCBodG1sOiBgPHByZT5FcnJvciByZW5kZXJpbmcgbWFya2Rvd246ICR7U3RyaW5nKGVycil9PC9wcmU+YCB9KTsKICB9Cn0pOwo=", import.meta.url), lo = ku.toString();
|
|
6850
6850
|
console.log("[MarkdownContent] worker url", lo);
|
|
6851
6851
|
const fi = [];
|
|
6852
6852
|
let hi = !1;
|
package/dist/index.umd.js
CHANGED
|
@@ -30,7 +30,7 @@ Check the top-level render call using <`+ue+">.")}return J}}function Yu(A,J){{if
|
|
|
30
30
|
`+i):r.stack=i}catch{}}throw r}}_request(e,n){typeof e=="string"?(n=n||{},n.url=e):n=e||{},n=Mn(this.defaults,n);const{transitional:r,paramsSerializer:a,headers:i}=n;r!==void 0&&Sa.assertOptions(r,{silentJSONParsing:Zt.transitional(Zt.boolean),forcedJSONParsing:Zt.transitional(Zt.boolean),clarifyTimeoutError:Zt.transitional(Zt.boolean)},!1),a!=null&&(B.isFunction(a)?n.paramsSerializer={serialize:a}:Sa.assertOptions(a,{encode:Zt.function,serialize:Zt.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Sa.assertOptions(n,{baseUrl:Zt.spelling("baseURL"),withXsrfToken:Zt.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let o=i&&B.merge(i.common,i[n.method]);i&&B.forEach(["delete","get","head","post","put","patch","common"],g=>{delete i[g]}),n.headers=Rt.concat(o,i);const s=[];let l=!0;this.interceptors.request.forEach(function(f){typeof f.runWhen=="function"&&f.runWhen(n)===!1||(l=l&&f.synchronous,s.unshift(f.fulfilled,f.rejected))});const c=[];this.interceptors.response.forEach(function(f){c.push(f.fulfilled,f.rejected)});let d,_=0,p;if(!l){const g=[x_.bind(this),void 0];for(g.unshift(...s),g.push(...c),p=g.length,d=Promise.resolve(n);_<p;)d=d.then(g[_++],g[_++]);return d}p=s.length;let m=n;for(;_<p;){const g=s[_++],f=s[_++];try{m=g(m)}catch(E){f.call(this,E);break}}try{d=x_.call(this,m)}catch(g){return Promise.reject(g)}for(_=0,p=c.length;_<p;)d=d.then(c[_++],c[_++]);return d}getUri(e){e=Mn(this.defaults,e);const n=b_(e.baseURL,e.url,e.allowAbsoluteUrls);return d_(n,e.params,e.paramsSerializer)}};B.forEach(["delete","get","head","options"],function(e){Ln.prototype[e]=function(n,r){return this.request(Mn(r||{},{method:e,url:n,data:(r||{}).data}))}}),B.forEach(["post","put","patch"],function(e){function n(r){return function(i,o,s){return this.request(Mn(s||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}Ln.prototype[e]=n(),Ln.prototype[e+"Form"]=n(!0)});let Tv=class QC{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(i){n=i});const r=this;this.promise.then(a=>{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](a);r._listeners=null}),this.promise.then=a=>{let i;const o=new Promise(s=>{r.subscribe(s),i=s}).then(a);return o.cancel=function(){r.unsubscribe(i)},o},e(function(i,o,s){r.reason||(r.reason=new er(i,o,s),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const n=this._listeners.indexOf(e);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const e=new AbortController,n=r=>{e.abort(r)};return this.subscribe(n),e.signal.unsubscribe=()=>this.unsubscribe(n),e.signal}static source(){let e;return{token:new QC(function(a){e=a}),cancel:e}}};function hv(t){return function(n){return t.apply(null,n)}}function Cv(t){return B.isObject(t)&&t.isAxiosError===!0}const ao={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(ao).forEach(([t,e])=>{ao[e]=t});function M_(t){const e=new Ln(t),n=Qu(Ln.prototype.request,e);return B.extend(n,Ln.prototype,e,{allOwnKeys:!0}),B.extend(n,e,null,{allOwnKeys:!0}),n.create=function(a){return M_(Mn(t,a))},n}const st=M_(yr);st.Axios=Ln,st.CanceledError=er,st.CancelToken=Tv,st.isCancel=g_,st.VERSION=D_,st.toFormData=pa,st.AxiosError=we,st.Cancel=st.CanceledError,st.all=function(e){return Promise.all(e)},st.spread=hv,st.isAxiosError=Cv,st.mergeConfig=Mn,st.AxiosHeaders=Rt,st.formToJSON=t=>p_(B.isHTMLForm(t)?new FormData(t):t),st.getAdapter=A_.getAdapter,st.HttpStatusCode=ao,st.default=st;const{Axios:v0,AxiosError:N0,CanceledError:O0,isCancel:y0,CancelToken:I0,VERSION:A0,all:x0,Cancel:D0,isAxiosError:w0,spread:M0,toFormData:L0,AxiosHeaders:P0,HttpStatusCode:k0,formToJSON:U0,getAdapter:F0,mergeConfig:B0}=st,io={};function L_(){var t;try{return typeof window<"u"&&((t=window.localStorage)==null?void 0:t.getItem("chat-debug"))==="1"}catch{return!1}}const Rv=io==null?void 0:io.VITE_API_BASE_URL,vv=typeof window<"u"?window.__API_BASE_URL__:void 0,P_=Rv??vv,oo=P_?P_.replace(/\/+$/,""):void 0;!oo&&typeof window<"u"&&console.warn("VITE_API_BASE_URL is not set. The API client will need to be configured via apiConfig prop.");let ba=null;const so=new Set;function k_(){return ba}function lo(t){ba=t,so.forEach(e=>e(t))}function U_(t){return so.add(t),()=>so.delete(t)}const Pt=st.create({...oo?{baseURL:oo}:{},timeout:3e4,withCredentials:!0});Pt.interceptors.request.use(t=>(ba&&(t.headers.Authorization=`Bearer ${ba}`),t)),Pt.interceptors.response.use(t=>t,t=>Promise.reject(t));async function kt(t,e){return Pt.defaults.baseURL?(await Pt.get(t,e)).data:Promise.reject(new Error("API base URL is not configured"))}async function co(t,e,n){return Pt.defaults.baseURL?(await Pt.post(t,e,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function F_(t,e,n){return Pt.defaults.baseURL?(await Pt.put(t,e,n)).data:Promise.reject(new Error("API base URL is not configured"))}async function B_(t,e){return Pt.defaults.baseURL?(await Pt.delete(t,e)).data:Promise.reject(new Error("API base URL is not configured"))}function It(t){return t&&typeof t=="object"&&"data"in t?t.data:t}class Ta{get baseUrl(){const e=Pt.defaults.baseURL||"";return String(e).replace(/\/+$|^\s+|\s+$/g,"")}updateConfig(e){e.baseUrl&&(Pt.defaults.baseURL=String(e.baseUrl).replace(/\/+$/g,"")),e.authToken!==void 0&&lo(e.authToken)}getAuthToken(){return k_()}setAuthToken(e){lo(e)}onTokenChange(e){return U_(e)}async listThreads(){const e=await kt("/chat/threads"),n=It(e);return(n==null?void 0:n.items)??(e==null?void 0:e.items)??[]}async createThread(e){const r=await co("/chat/threads",e?{title:e}:void 0);return It(r)}async updateThread(e,n){const r=await F_(`/chat/threads/${e}`,{title:n});return It(r)}async deleteThread(e){const n=await B_(`/chat/threads/${e}`);return It(n)}async threadInfo(e){const n=await kt(`/chat/threads/${e}/info`);return It(n)}async listAgents(){const e=await kt("/chat/agents"),n=It(e);return(n==null?void 0:n.items)??[]}async getAgent(e){const n=await kt(`/chat/agents/${e}`);return It(n)}async getAgentSchema(e){const n=await kt(`/chat/agents/${e}/schema`);return It(n)}async getMessages(e){const n=await kt(`/chat/threads/${e.threadId}/messages`,{params:{thread_id:e.threadId,checkpoint_id:e.checkpointId,checkpoint_ns:e.checkpointNs,limit:e.limit,before_id:e.beforeId??void 0}});return It(n)}async getState(e){const n=await kt(`/chat/threads/${e.threadId}/state`,{params:{thread_id:e.threadId,checkpoint_id:e.checkpointId,checkpoint_ns:e.checkpointNs}});return It(n)}async getStateHistory(e){const n=await kt(`/chat/threads/${e.threadId}/state/history`,{params:{thread_id:e.threadId,checkpoint_id:e.checkpointId,checkpoint_ns:e.checkpointNs}});return It(n)}async listCheckpoints(e){const n=await kt(`/chat/threads/${e}/checkpoints`,{params:{thread_id:e}});return It(n)}async uploadExcel(e,n="/upload_excel",r={}){const a=new FormData,i=e.name.replace(/\.[^.]+$/,"").toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`excel_${Date.now()}`,o=(r.tableName??i).trim();a.append("file",e,e.name),a.append("table_name",o),r.sheetName&&a.append("sheet_name",r.sheetName),L_()&&console.debug("[api.uploadExcel] ->",n,{name:e.name,size:e.size,tableName:o,sheetName:r.sheetName});const s=await co(n,a,{headers:{Accept:"application/json"},maxBodyLength:1/0}),l=It(s);return L_()&&console.debug("[api.uploadExcel] <-",l),l}}const dn=new Ta;function G_(t={}){const e=t.baseUrl??"/api/chat",n=t.streamPath??"/runs/stream",[r,a]=y.useState(t.token??null),i=y.useRef(t.headers??{}),[o,s]=y.useState(!1),[l,c]=y.useState(null),[d,_]=y.useState(""),[p,m]=y.useState(null),g=y.useRef(null),f=y.useCallback(h=>{a(h)},[]),E=y.useCallback(()=>{var h;(h=g.current)==null||h.abort(),g.current=null,s(!1)},[]),S=y.useCallback(()=>{_(""),m(null),c(null)},[]),T=y.useCallback((h,v,C)=>{g.current&&(g.current.abort(),g.current=null),s(!0),c(null),t.autoAppendAssistant!==!1&&_("");const R=new AbortController;return g.current=R,(async()=>{var D,w,L,H,z;const N=(()=>{var P;try{return typeof window<"u"&&((P=window.localStorage)==null?void 0:P.getItem("chat-debug"))==="1"}catch{return!1}})(),O=P=>{var G;try{const I=JSON.parse(JSON.stringify(P));return(G=I==null?void 0:I.payload)!=null&&G.files_info&&Array.isArray(I.payload.files_info)&&(I.payload.files_info=I.payload.files_info.map(U=>({...U,data:U!=null&&U.data?`<base64 ${String(U.data).length} chars>`:U==null?void 0:U.data}))),I}catch{return P}};try{let P={};try{if(r)P={Authorization:`Bearer ${r}`};else if(typeof window<"u"){const Y=window.__AUTH_TOKEN__,W=((D=window.localStorage)==null?void 0:D.getItem("authToken"))||null;let re=null;try{const j=(w=window.localStorage)==null?void 0:w.getItem("chat-settings");j&&(re=((L=JSON.parse(j))==null?void 0:L.apiKey)||null)}catch{}const q=Y||W||re||null;q&&(P={Authorization:`Bearer ${q}`})}}catch{}N&&console.debug("[use-chat] POST",e+n,O(h));const G=await fetch(e+n,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream",...P,...i.current},body:JSON.stringify(h),signal:R.signal});if(!G.ok||!G.body){const k=await G.text().catch(()=>"");throw N&&console.debug("[use-chat] non-OK response",G.status,k==null?void 0:k.slice(0,500)),new Error(`stream ${G.status}${k?": "+k:""}`)}try{const k=G.headers.get("X-Thread-Id")||G.headers.get("x-thread-id"),Y=G.headers.get("X-Thread-Created")||G.headers.get("x-thread-created"),W=k??null,re=String(Y??"").toLowerCase()==="true";try{(H=C==null?void 0:C.onOpen)==null||H.call(C,{threadId:W,created:re})}catch(q){N&&console.debug("[use-chat] onOpen handler threw:",q)}}catch(k){N&&console.debug("[use-chat] failed to read headers:",k)}const I=G.body.getReader(),U=new TextDecoder;let M="";for(;;){const{value:k,done:Y}=await I.read();if(Y)break;M+=U.decode(k,{stream:!0});let W;for(;(W=M.indexOf(`
|
|
31
31
|
|
|
32
32
|
`))>=0;){const re=M.slice(0,W);M=M.slice(W+2);const q=Ov(re);if(!q)continue;let j;try{j=JSON.parse(q)}catch{N&&console.debug("[use-chat] skip malformed SSE data:",q==null?void 0:q.slice(0,200));continue}const se=Nv(j)?j.data:j;if(N&&console.debug("[use-chat] event:",se==null?void 0:se.type,se),v==null||v(se),se.type==="token")t.autoAppendAssistant!==!1&&_(Ee=>Ee+se.content);else if(se.type==="message_delta"){const Ee=se.delta.filter(V=>V.type==="text").map(V=>V.text).join("");Ee&&t.autoAppendAssistant!==!1&&_(V=>V+Ee)}else se.type==="checkpoint"?m(se.checkpointId):se.type==="error"&&c(se.message)}}}catch(P){if((P==null?void 0:P.name)==="AbortError")return;const G=(P==null?void 0:P.message)||String(P);N&&console.debug("[use-chat] error:",G),c(G),(z=C==null?void 0:C.onError)==null||z.call(C,G)}finally{s(!1),g.current=null}})(),{close:()=>R.abort()}},[e,r,t.autoAppendAssistant]);return y.useEffect(()=>()=>{var h;return(h=g.current)==null?void 0:h.abort()},[]),{isStreaming:o,error:l,assistantText:d,lastCheckpointId:p,stream:T,stop:E,clear:S,setToken:f}}function Nv(t){return!!t&&typeof t=="object"&&t.protocolVersion==="v1"&&"data"in t}function Ov(t){const e=t.split(/\r?\n/),n=[];for(const r of e)if(r&&!r.startsWith(":")&&r.startsWith("data:")){const a=r.slice(5);n.push(a.startsWith(" ")?a.slice(1):a)}return n.length===0?null:n.join(`
|
|
33
|
-
`)}const yv={messages:[],assemblingId:null,lastCheckpointId:null,toolIndex:{},lastBranch:null};function Iv(t,e){var n,r;switch(e.type){case"reset":return{messages:uo(((n=e.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,toolIndex:{},lastBranch:null};case"seed":return{...t,messages:uo(e.payload.messages)};case"prepend":{const a=uo(e.payload.messages);if(!a.length)return t;const i=new Set(t.messages.map(s=>s.id)),o=a.filter(s=>!i.has(s.id));return o.length?{...t,messages:[...o,...t.messages]}:t}case"user_message":{const a=e.payload.message;if(t.assemblingId){const i=t.messages.findIndex(o=>o.id===t.assemblingId&&o.role==="assistant");if(i>=0){const o=t.messages.slice(0,i),s=t.messages.slice(i);return{...t,messages:[...o,a,...s]}}}return{...t,messages:[...t.messages,a]}}case"event":{const a=e.payload.ev;if(a.type==="message_start"&&a.role==="assistant"){const i=a.id,o=wv(a.model),s={id:i,role:"assistant",name:o||void 0,model:a.model,createdAt:new Date().toISOString(),content:[]};return{...t,assemblingId:i,messages:[...t.messages,s]}}if(a.type==="token"){const i=t.assemblingId??_o(t.messages);return i?{...t,messages:Av(t.messages,i,a.content)}:t}if(a.type==="message_delta"){const i=t.assemblingId??_o(t.messages);return i?{...t,messages:H_(t.messages,i,a.delta)}:t}if(a.type==="message_end"){const i=t.assemblingId??_o(t.messages);if(!i)return{...t,assemblingId:null};const o=t.messages,s=o.findIndex(l=>l.id===i&&l.role==="assistant");if(s>=0&&!((r=o[s].content)==null?void 0:r.some(d=>{var _;return(d==null?void 0:d.type)==="text"&&((_=d.text)==null?void 0:_.trim())}))){const d=[...o.slice(0,s),...o.slice(s+1)];return{...t,assemblingId:null,messages:d}}return{...t,assemblingId:null}}if(a.type==="tool_start"){const i=`tool-${a.id}`,o={type:"tool_call",id:a.id,name:a.name,args:a.args},s={id:i,role:"tool",name:a.name,createdAt:new Date().toISOString(),content:[o]};return{...t,messages:[...t.messages,s],toolIndex:{...t.toolIndex,[a.id]:i}}}if(a.type==="tool_result"){const i=t.toolIndex[a.id]??`tool-${a.id}`,o={type:"tool_result",toolCallId:a.id,output:a.output,error:a.error},s=t.messages.find(d=>d.id===i),l={id:i,role:"tool",content:[o],createdAt:new Date().toISOString()},c=s?H_(t.messages,i,[o]):[...t.messages,l];return{...t,messages:c}}if(a.type==="checkpoint"){const i=Dv(t.messages,a.checkpointId);return{...t,lastCheckpointId:a.checkpointId,messages:i}}if(a.type==="branch"){const i=a.checkpointId??t.lastCheckpointId;return{...t,lastBranch:a,lastCheckpointId:i??null}}if(a.type==="error"){const i={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${a.message}`}],createdAt:new Date().toISOString()};return{...t,messages:[...t.messages,i]}}return t}default:return t}}function Y_(t=[]){const[e,n]=y.useReducer(Iv,{...yv,messages:t}),r=y.useCallback(i=>{n({type:"event",payload:{ev:i}})},[]),a=y.useMemo(()=>({reset:i=>n({type:"reset",payload:{messages:i}}),seed:i=>n({type:"seed",payload:{messages:i}}),prepend:i=>n({type:"prepend",payload:{messages:i}}),pushUser:i=>n({type:"user_message",payload:{message:i}}),onEvent:r}),[r]);return{state:e,dispatch:n,...a}}function uo(t){return t.filter(e=>{if(e.role!=="assistant")return!0;const n=(e.content||[]).some(a=>{var i;return a&&a.type==="text"&&((i=a.text)==null?void 0:i.trim())}),r=(e.content||[]).some(a=>a&&a.type==="image_url");return!!(n||r)})}function _o(t){for(let e=t.length-1;e>=0;e--)if(t[e].role==="assistant")return t[e].id;return null}function Av(t,e,n){return t.map(r=>{if(r.id!==e)return r;const a=r.content.slice(),i=a[a.length-1];return i&&i.type==="text"?i.text+=n:a.push({type:"text",text:n}),{...r,content:a}})}function H_(t,e,n){return t.map(r=>r.id===e?{...r,content:xv(r.content,n)}:r)}function xv(t,e){const n=t.slice();for(const r of e)if(r.type==="text"){const a=n[n.length-1];(a==null?void 0:a.type)==="text"?a.text+=r.text:n.push({type:"text",text:r.text})}else n.push(r);return n}function Dv(t,e){for(let n=t.length-1;n>=0;n--)if(t[n].role==="assistant"){const a={...t[n],checkpointId:e};return[...t.slice(0,n),a,...t.slice(n+1)]}return t}function wv(t){if(!t)return null;const e=t.split("/");return e[e.length-1]||null}function Mv(t,e){const n=t==null?void 0:t.checkpoints,r=Array.isArray(n)?n.slice():n?Object.values(n):[],a=o=>o&&typeof o=="object"&&typeof o.checkpointId=="string"&&typeof o.createdAt=="string",i=r.filter(a).map(o=>({checkpointId:o.checkpointId,checkpointNs:o.checkpointNs??"",createdAt:o.createdAt,messagesLen:o.messagesLen??0,preview:o.preview??"",role:o.role??null,parentId:o.parentId??null,editedMessageId:o.editedMessageId??null,branchLabel:o.branchLabel??null}));return{threadId:(t==null?void 0:t.threadId)??e??null,checkpoints:i}}async function po(t){return await new Promise((e,n)=>{const r=new FileReader;r.onload=()=>e(String(r.result)),r.onerror=a=>n(a),r.readAsDataURL(t)})}async function Lv(t){return await new Promise((e,n)=>{const r=new FileReader;r.onload=()=>{try{const a=r.result,i=new Uint8Array(a);let o="";const s=i.byteLength;for(let l=0;l<s;l++)o+=String.fromCharCode(i[l]);e(btoa(o))}catch(a){n(a)}},r.onerror=a=>n(a),r.readAsArrayBuffer(t)})}async function Pv(t,e,n){try{return await po(e)}catch{return null}}async function kv(t,e=[],n,r,a,i){const o=[],s=[];for(const l of e){let c=null;try{c=await Pv(t,l,i)}catch{c=null}if(l.type&&l.type.startsWith("image/"))if(c){const d={type:"image_url",url:c,mimeType:l.type,alt:l.name};o.push(d)}else try{const d=await po(l),_={type:"image_url",url:String(d),mimeType:l.type,alt:l.name};o.push(_)}catch{}else if(c){const d={type:"file",url:c,mimeType:l.type||void 0,name:l.name,size:l.size,sourceType:"base64"};o.push(d)}else try{const d=await po(l),_={type:"file",url:String(d),mimeType:l.type||void 0,name:l.name,size:l.size,sourceType:"base64"};o.push(_)}catch{}try{const d=await Lv(l);s.push({filename:l.name,data:d,mime_type:l.type||"application/octet-stream"})}catch{}}return{contentParts:o,filesInfo:s}}const q_=y.createContext(null);function Ar({children:t,apiConfig:e,onError:n,onThreadChange:r,initialThreadId:a=null,historyPageSize:i,autoLoadInitial:o=!0,enableFileAgentRouting:s=!1,fileAgentId:l="invoice_reader"}){const c=dn;y.useEffect(()=>{e&&c.updateConfig({baseUrl:e.baseUrl,authToken:e.apiKey})},[c,e]);const{isStreaming:d,error:_,stream:p,stop:m,setToken:g}=G_({baseUrl:c.baseUrl,token:null,headers:e==null?void 0:e.headers,streamPath:"/chat/runs/stream"}),[f,E]=y.useState(()=>typeof c.getAuthToken=="function"?c.getAuthToken():null);y.useEffect(()=>{g(typeof c.getAuthToken=="function"?c.getAuthToken():null);const K=c.onTokenChange(ie=>{E(ie),g(ie)});return()=>{K()}},[c,g]);const S=y.useCallback(K=>{c.setAuthToken(K)},[c]),{state:T,seed:h,prepend:v,pushUser:C,onEvent:R,reset:N}=Y_(),O=i&&i>0?i:6,[D,w]=y.useState(!1),[L,H]=y.useState(!1),[z,P]=y.useState(null),[G,I]=y.useState(void 0),U=y.useCallback((K,ie)=>{const he=Array.isArray(K==null?void 0:K.messages)?K.messages:[];ie==="replace"?h(he):ie==="prepend"&&he.length&&v(he),P((K==null?void 0:K.nextCursor)??null),w(!!(K!=null&&K.hasMore)),I(nt=>(K==null?void 0:K.checkpointId)??nt??void 0)},[h,v]),[M,k]=y.useState([]),[Y,W]=y.useState(null),re=y.useCallback(async()=>{const K=await c.listThreads();k(K)},[c]),[q,j]=y.useState(!1),se=y.useCallback(async K=>{const ie=(K==null?void 0:K.maxAttempts)??5,he=(K==null?void 0:K.baseDelayMs)??500,nt=(K==null?void 0:K.timeoutMs)??2e3;if(!c.baseUrl)return!1;const Ze=c.baseUrl.replace(/\/+$/,""),at=["/health","/api/health","/","/api/v2/health","/api/v2/chat/health"],Ke=async ae=>{try{const be=new AbortController,Ce=setTimeout(()=>be.abort(),nt),Be=await fetch(ae,{method:"GET",signal:be.signal});return clearTimeout(Ce),Be.ok}catch{return!1}},Z=async ae=>{try{const be=new AbortController,Ce=setTimeout(()=>be.abort(),nt),Be=await fetch(ae,{method:"HEAD",signal:be.signal});return clearTimeout(Ce),Be.ok}catch{return!1}};for(let ae=0;ae<ie;ae++){console.debug(`[ChatProvider] health-check attempt ${ae+1}/${ie}`);for(const Ce of at){let Be=Ce;Ze.endsWith("/api")&&Ce.startsWith("/api")&&(Be=Ce.replace(/^\/api/,"")||"/");const it=Be==="/"?Ze+"/":Ze+Be;if(console.debug(`[ChatProvider] checking ${it}`),await Ke(it)||Ce==="/"&&await Z(Ze+"/"))return j(!0),!0}const be=he*Math.pow(2,ae);await new Promise(Ce=>setTimeout(Ce,be))}return j(!1),!1},[c.baseUrl]);y.useEffect(()=>{let K=!0;if(!c.baseUrl){console.debug("[ChatProvider] skipping initial refreshThreads: api.baseUrl not configured");return}return(async()=>{try{const ie=await se();if(!K)return;ie?re().catch(()=>{}):console.warn("[ChatProvider] backend health-check failed — skipping initial loads")}catch{}})(),()=>{K=!1}},[re,c.baseUrl,se]),y.useEffect(()=>{r==null||r(Y)},[Y,r]);const Ee=y.useRef(null);y.useEffect(()=>{if(a&&o){if(!c.baseUrl){console.debug("[ChatProvider] skipping initial load: api.baseUrl not configured");return}if(!q){console.debug("[ChatProvider] deferring initial load until backend health-check passes");return}Ee.current!==a&&(Ee.current=a,F(a).catch(()=>{}))}},[a,o,c.baseUrl,q]);const V=y.useRef(null),F=y.useCallback(async(K,ie,he)=>{if(!c.baseUrl){console.debug("[ChatProvider] skipping loadThread: api.baseUrl not configured");return}if(V.current!==K){V.current=K;try{w(!1),P(null),I(void 0);const nt=await c.getMessages({threadId:K,checkpointId:ie,checkpointNs:he,limit:O});W(K),U(nt,"replace")}finally{V.current=null}}},[c,U]),Q=y.useCallback(async K=>{const ie=await c.listCheckpoints(K);return Mv(ie,K)},[c]),te=y.useCallback(async K=>{if(!Y)throw new Error("No active thread");w(!1),P(null),I(void 0);const ie=await c.getMessages({threadId:Y,checkpointId:K,limit:O});U(ie,"replace")},[c,Y,U,O]),ce=y.useCallback(async()=>{if(!Y)throw new Error("No active thread");await F(Y)},[Y,F]),oe=y.useRef(!1);y.useEffect(()=>{const K=oe.current;if(oe.current=d,K&&!d&&Y){const ie=T.lastCheckpointId??void 0;(async()=>{try{const he=await c.getMessages({threadId:Y,checkpointId:ie,limit:O});U(he,"replace")}catch{}try{await re()}catch{}})()}},[d,Y,T.lastCheckpointId,c,U,re]);const xe=y.useCallback(async K=>{const ie=await c.createThread(K);return await re(),await F(ie.threadId),ie.threadId},[c,re,F]),Ve=y.useCallback(async K=>{await c.deleteThread(K),await re(),Y===K&&(W(null),N([]),w(!1),P(null),I(void 0))},[c,re,Y,N]),Le=y.useCallback(async(K,ie)=>{await c.updateThread(K,ie),await re()},[c,re]),fe=y.useCallback(async(K,ie)=>{var Xt;const he=(ie==null?void 0:ie.attachments)||[],{contentParts:nt,filesInfo:Ze}=await kv(c,he,e==null?void 0:e.uploadPath,s,l,Y),at=[];K&&at.push({type:"text",text:K});for(const Je of nt)at.push(Je);const Ke={id:((Xt=crypto.randomUUID)==null?void 0:Xt.call(crypto))||`user-${Date.now()}`,role:"user",content:at,createdAt:new Date().toISOString(),checkpointId:(ie==null?void 0:ie.checkpointId)??T.lastCheckpointId??void 0};C(Ke);const Z={...Ke,content:Ke.content.filter(Je=>Je.type==="text"||Je.type==="image_url"||Je.type==="file")},ae={...(ie==null?void 0:ie.payloadExtras)??{}},be=!!ae.edit,Ce=ae.originalMessageId,Be=typeof Ce=="string"?Ce:void 0,it=he&&he.length>0,Mt={...Y?{threadId:Y}:{},payload:{messages:[Z],attachments:Ke.content.filter(Je=>Je.type==="file").map(Je=>({type:"file",url:Je.url,mimeType:Je.mimeType,name:Je.name,size:Je.size})),files_info:Ze,...s&&it&&l?{active_agent:l}:{},...ae},checkpointId:(ie==null?void 0:ie.checkpointId)??T.lastCheckpointId??void 0,checkpointNs:ie==null?void 0:ie.checkpointNs,nodeFilter:ie==null?void 0:ie.nodeFilter,config:ie==null?void 0:ie.config,edit:be,originalMessageId:Be};p(Mt,Je=>R(Je),{onError:Je=>console.warn("stream error",Je),onOpen:({threadId:Je,created:Dn})=>{!Y&&Je&&(W(Je),Dn&&re().catch(()=>{}))}})},[Y,C,p,R,T.lastCheckpointId,c,e==null?void 0:e.uploadPath,re,W,s,l]),ke=y.useCallback(async K=>{if(!Y)throw new Error("No active thread");if(L||!D)return;const ie=z;if(ie){H(!0);try{const he=await c.getMessages({threadId:Y,checkpointId:G,limit:(K==null?void 0:K.limit)??O,beforeId:ie});U(he,"prepend")}finally{H(!1)}}},[c,Y,G,z,D,L,U]),ee={baseUrl:c.baseUrl,token:f,setToken:S,api:c,threads:M,currentThreadId:Y,setCurrentThreadId:W,messages:T.messages,isStreaming:d,error:_,lastCheckpointId:T.lastCheckpointId,streamingAssistantId:T.assemblingId,hasMoreHistory:D,isLoadingHistory:L,loadOlderMessages:ke,historyPageSize:O,listCheckpoints:Q,navigateToCheckpoint:te,returnToLatest:ce,refreshThreads:re,createThread:xe,deleteThread:Ve,renameThread:Le,loadThread:F,send:fe,stop:m};return u.jsx(q_.Provider,{value:ee,children:t})}function ha(){const t=y.useContext(q_);if(!t)throw new Error("useChat must be used within ChatProvider");return t}const Ca=0,fn=1,tr=2,V_=4;function z_(t){return()=>t}function Uv(t){t()}function $_(t,e){return n=>t(e(n))}function W_(t,e){return()=>t(e)}function Fv(t,e){return n=>t(e,n)}function mo(t){return t!==void 0}function Bv(...t){return()=>{t.map(Uv)}}function nr(){}function Ra(t,e){return e(t),t}function Gv(t,e){return e(t)}function et(...t){return t}function We(t,e){return t(fn,e)}function Me(t,e){t(Ca,e)}function go(t){t(tr)}function lt(t){return t(V_)}function Te(t,e){return We(t,Fv(e,Ca))}function qt(t,e){const n=t(fn,r=>{n(),e(r)});return n}function K_(t){let e,n;return r=>a=>{e=a,n&&clearTimeout(n),n=setTimeout(()=>{r(e)},t)}}function Q_(t,e){return t===e}function tt(t=Q_){let e;return n=>r=>{t(e,r)||(e=r,n(r))}}function ye(t){return e=>n=>{t(n)&&e(n)}}function pe(t){return e=>$_(e,t)}function Jt(t){return e=>()=>{e(t)}}function X(t,...e){const n=Yv(...e);return(r,a)=>{switch(r){case tr:go(t);return;case fn:return We(t,n(a))}}}function en(t,e){return n=>r=>{n(e=t(e,r))}}function Pn(t){return e=>n=>{t>0?t--:e(n)}}function un(t){let e=null,n;return r=>a=>{e=a,!n&&(n=setTimeout(()=>{n=void 0,r(e)},t))}}function Pe(...t){const e=new Array(t.length);let n=0,r=null;const a=Math.pow(2,t.length)-1;return t.forEach((i,o)=>{const s=Math.pow(2,o);We(i,l=>{const c=n;n=n|s,e[o]=l,c!==a&&n===a&&r&&(r(),r=null)})}),i=>o=>{const s=()=>{i([o].concat(e))};n===a?s():r=s}}function Yv(...t){return e=>t.reduceRight(Gv,e)}function Hv(t){let e,n;const r=()=>e==null?void 0:e();return function(a,i){switch(a){case fn:return i?n===i?void 0:(r(),n=i,e=We(t,i),e):(r(),nr);case tr:r(),n=null;return}}}function ne(t){let e=t;const n=Ye();return(r,a)=>{switch(r){case Ca:e=a;break;case fn:{a(e);break}case V_:return e}return n(r,a)}}function Et(t,e){return Ra(ne(e),n=>Te(t,n))}function Ye(){const t=[];return(e,n)=>{switch(e){case Ca:t.slice().forEach(r=>{r(n)});return;case tr:t.splice(0,t.length);return;case fn:return t.push(n),()=>{const r=t.indexOf(n);r>-1&&t.splice(r,1)}}}}function At(t){return Ra(Ye(),e=>Te(t,e))}function qe(t,e=[],{singleton:n}={singleton:!0}){return{constructor:t,dependencies:e,id:qv(),singleton:n}}const qv=()=>Symbol();function Vv(t){const e=new Map,n=({constructor:r,dependencies:a,id:i,singleton:o})=>{if(o&&e.has(i))return e.get(i);const s=r(a.map(l=>n(l)));return o&&e.set(i,s),s};return n(t)}function dt(...t){const e=Ye(),n=new Array(t.length);let r=0;const a=Math.pow(2,t.length)-1;return t.forEach((i,o)=>{const s=Math.pow(2,o);We(i,l=>{n[o]=l,r=r|s,r===a&&Me(e,n)})}),function(i,o){switch(i){case tr:{go(e);return}case fn:return r===a&&o(n),We(e,o)}}}function Ne(t,e=Q_){return X(t,tt(e))}function Eo(...t){return function(e,n){switch(e){case tr:return;case fn:return Bv(...t.map(r=>We(r,n)))}}}var vt=(t=>(t[t.DEBUG=0]="DEBUG",t[t.INFO=1]="INFO",t[t.WARN=2]="WARN",t[t.ERROR=3]="ERROR",t))(vt||{});const zv={0:"debug",3:"error",1:"log",2:"warn"},$v=()=>typeof globalThis>"u"?window:globalThis,Sn=qe(()=>{const t=ne(3);return{log:ne((e,n,r=1)=>{var a;const i=(a=$v().VIRTUOSO_LOG_LEVEL)!=null?a:lt(t);r>=i&&console[zv[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",e,n)}),logLevel:t}},[],{singleton:!0});function kn(t,e,n){return fo(t,e,n).callbackRef}function fo(t,e,n){const r=y.useRef(null);let a=o=>{};const i=y.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(o=>{const s=()=>{const l=o[0].target;l.offsetParent!==null&&t(l)};n?s():requestAnimationFrame(s)}):null,[t,n]);return a=o=>{o&&e?(i==null||i.observe(o),r.current=o):(r.current&&(i==null||i.unobserve(r.current)),r.current=null)},{callbackRef:a,ref:r}}function Wv(t,e,n,r,a,i,o,s,l){const c=y.useCallback(d=>{const _=Kv(d.children,e,s?"offsetWidth":"offsetHeight",a);let p=d.parentElement;for(;!p.dataset.virtuosoScroller;)p=p.parentElement;const m=p.lastElementChild.dataset.viewportType==="window";let g;m&&(g=p.ownerDocument.defaultView);const f=o?s?o.scrollLeft:o.scrollTop:m?s?g.scrollX||g.document.documentElement.scrollLeft:g.scrollY||g.document.documentElement.scrollTop:s?p.scrollLeft:p.scrollTop,E=o?s?o.scrollWidth:o.scrollHeight:m?s?g.document.documentElement.scrollWidth:g.document.documentElement.scrollHeight:s?p.scrollWidth:p.scrollHeight,S=o?s?o.offsetWidth:o.offsetHeight:m?s?g.innerWidth:g.innerHeight:s?p.offsetWidth:p.offsetHeight;r({scrollHeight:E,scrollTop:Math.max(f,0),viewportHeight:S}),i==null||i(s?j_("column-gap",getComputedStyle(d).columnGap,a):j_("row-gap",getComputedStyle(d).rowGap,a)),_!==null&&t(_)},[t,e,a,i,o,r,s]);return fo(c,n,l)}function Kv(t,e,n,r){const a=t.length;if(a===0)return null;const i=[];for(let o=0;o<a;o++){const s=t.item(o);if(s.dataset.index===void 0)continue;const l=parseInt(s.dataset.index),c=parseFloat(s.dataset.knownSize),d=e(s,n);if(d===0&&r("Zero-sized element, this should not happen",{child:s},vt.ERROR),d===c)continue;const _=i[i.length-1];i.length===0||_.size!==d||_.endIndex!==l-1?i.push({endIndex:l,size:d,startIndex:l}):i[i.length-1].endIndex++}return i}function j_(t,e,n){return e!=="normal"&&!(e!=null&&e.endsWith("px"))&&n(`${t} was not resolved to pixel value correctly`,e,vt.WARN),e==="normal"?0:parseInt(e??"0",10)}function X_(t,e,n){const r=y.useRef(null),a=y.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const c=l.getBoundingClientRect(),d=c.width;let _,p;if(e){const m=e.getBoundingClientRect(),g=c.top-m.top;p=m.height-Math.max(0,g),_=g+e.scrollTop}else{const m=o.current.ownerDocument.defaultView;p=m.innerHeight-Math.max(0,c.top),_=c.top+m.scrollY}r.current={offsetTop:_,visibleHeight:p,visibleWidth:d},t(r.current)},[t,e]),{callbackRef:i,ref:o}=fo(a,!0,n),s=y.useCallback(()=>{a(o.current)},[a,o]);return y.useEffect(()=>{var l;if(e){e.addEventListener("scroll",s);const c=new ResizeObserver(()=>{requestAnimationFrame(s)});return c.observe(e),()=>{e.removeEventListener("scroll",s),c.unobserve(e)}}else{const c=(l=o.current)==null?void 0:l.ownerDocument.defaultView;return c==null||c.addEventListener("scroll",s),c==null||c.addEventListener("resize",s),()=>{c==null||c.removeEventListener("scroll",s),c==null||c.removeEventListener("resize",s)}}},[s,e,o]),i}const Tt=qe(()=>{const t=Ye(),e=Ye(),n=ne(0),r=Ye(),a=ne(0),i=Ye(),o=Ye(),s=ne(0),l=ne(0),c=ne(0),d=ne(0),_=Ye(),p=Ye(),m=ne(!1),g=ne(!1),f=ne(!1);return Te(X(t,pe(({scrollTop:E})=>E)),e),Te(X(t,pe(({scrollHeight:E})=>E)),o),Te(e,a),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:s,horizontalDirection:g,scrollBy:p,scrollContainerState:t,scrollHeight:o,scrollingInProgress:m,scrollTo:_,scrollTop:e,skipAnimationFrameInResizeObserver:f,smoothScrollTargetReached:r,statefulScrollTop:a,viewportHeight:i}},[],{singleton:!0}),xr={lvl:0};function Z_(t,e){const n=t.length;if(n===0)return[];let{index:r,value:a}=e(t[0]);const i=[];for(let o=1;o<n;o++){const{index:s,value:l}=e(t[o]);i.push({end:s-1,start:r,value:a}),r=s,a=l}return i.push({end:1/0,start:r,value:a}),i}function je(t){return t===xr}function Dr(t,e){if(!je(t))return e===t.k?t.v:e<t.k?Dr(t.l,e):Dr(t.r,e)}function Vt(t,e,n="k"){if(je(t))return[-1/0,void 0];if(Number(t[n])===e)return[t.k,t.v];if(Number(t[n])<e){const r=Vt(t.r,e,n);return r[0]===-1/0?[t.k,t.v]:r}return Vt(t.l,e,n)}function xt(t,e,n){return je(t)?tp(e,n,1):e===t.k?ut(t,{k:e,v:n}):e<t.k?np(ut(t,{l:xt(t.l,e,n)})):np(ut(t,{r:xt(t.r,e,n)}))}function rr(){return xr}function va(t,e,n){if(je(t))return[];const r=Vt(t,e)[0];return Qv(bo(t,r,n))}function So(t,e){if(je(t))return xr;const{k:n,l:r,r:a}=t;if(e===n){if(je(r))return a;if(je(a))return r;{const[i,o]=ep(r);return Na(ut(t,{k:i,l:J_(r),v:o}))}}else return e<n?Na(ut(t,{l:So(r,e)})):Na(ut(t,{r:So(a,e)}))}function Un(t){return je(t)?[]:[...Un(t.l),{k:t.k,v:t.v},...Un(t.r)]}function bo(t,e,n){if(je(t))return[];const{k:r,l:a,r:i,v:o}=t;let s=[];return r>e&&(s=s.concat(bo(a,e,n))),r>=e&&r<=n&&s.push({k:r,v:o}),r<=n&&(s=s.concat(bo(i,e,n))),s}function Na(t){const{l:e,lvl:n,r}=t;if(r.lvl>=n-1&&e.lvl>=n-1)return t;if(n>r.lvl+1){if(To(e))return rp(ut(t,{lvl:n-1}));if(!je(e)&&!je(e.r))return ut(e.r,{l:ut(e,{r:e.r.l}),lvl:n,r:ut(t,{l:e.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(To(t))return ho(ut(t,{lvl:n-1}));if(!je(r)&&!je(r.l)){const a=r.l,i=To(a)?r.lvl-1:r.lvl;return ut(a,{l:ut(t,{lvl:n-1,r:a.l}),lvl:a.lvl+1,r:ho(ut(r,{l:a.r,lvl:i}))})}else throw new Error("Unexpected empty nodes")}}function ut(t,e){return tp(e.k!==void 0?e.k:t.k,e.v!==void 0?e.v:t.v,e.lvl!==void 0?e.lvl:t.lvl,e.l!==void 0?e.l:t.l,e.r!==void 0?e.r:t.r)}function J_(t){return je(t.r)?t.l:Na(ut(t,{r:J_(t.r)}))}function To(t){return je(t)||t.lvl>t.r.lvl}function ep(t){return je(t.r)?[t.k,t.v]:ep(t.r)}function tp(t,e,n,r=xr,a=xr){return{k:t,l:r,lvl:n,r:a,v:e}}function np(t){return ho(rp(t))}function rp(t){const{l:e}=t;return!je(e)&&e.lvl===t.lvl?ut(e,{r:ut(t,{l:e.r})}):t}function ho(t){const{lvl:e,r:n}=t;return!je(n)&&!je(n.r)&&n.lvl===e&&n.r.lvl===e?ut(n,{l:ut(t,{r:n.l}),lvl:e+1}):t}function Qv(t){return Z_(t,({k:e,v:n})=>({index:e,value:n}))}function ap(t,e){return!!(t&&t.startIndex===e.startIndex&&t.endIndex===e.endIndex)}function wr(t,e){return!!(t&&t[0]===e[0]&&t[1]===e[1])}const Co=qe(()=>({recalcInProgress:ne(!1)}),[],{singleton:!0});function ip(t,e,n){return t[Oa(t,e,n)]}function Oa(t,e,n,r=0){let a=t.length-1;for(;r<=a;){const i=Math.floor((r+a)/2),o=t[i],s=n(o,e);if(s===0)return i;if(s===-1){if(a-r<2)return i-1;a=i-1}else{if(a===r)return i;r=i+1}}throw new Error(`Failed binary finding record in array - ${t.join(",")}, searched for ${e}`)}function jv(t,e,n,r){const a=Oa(t,e,r),i=Oa(t,n,r,a);return t.slice(a,i+1)}function bn(t,e){return Math.round(t.getBoundingClientRect()[e])}function ya(t){return!je(t.groupOffsetTree)}function Ro({index:t},e){return e===t?0:e<t?-1:1}function Xv(){return{groupIndices:[],groupOffsetTree:rr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:rr()}}function Zv(t,e){let n=je(t)?0:1/0;for(const r of e){const{endIndex:a,size:i,startIndex:o}=r;if(n=Math.min(n,o),je(t)){t=xt(t,0,i);continue}const s=va(t,o-1,a+1);if(s.some(iN(r)))continue;let l=!1,c=!1;for(const{end:d,start:_,value:p}of s)l?(a>=_||i===p)&&(t=So(t,_)):(c=p!==i,l=!0),d>a&&a>=_&&p!==i&&(t=xt(t,a+1,p));c&&(t=xt(t,o,i))}return[t,n]}function Jv(t){return typeof t.groupIndex<"u"}function eN({offset:t},e){return e===t?0:e<t?-1:1}function Mr(t,e,n){if(e.length===0)return 0;const{index:r,offset:a,size:i}=ip(e,t,Ro),o=t-r,s=i*o+(o-1)*n+a;return s>0?s+n:s}function op(t,e){if(!ya(e))return t;let n=0;for(;e.groupIndices[n]<=t+n;)n++;return t+n}function sp(t,e,n){if(Jv(t))return e.groupIndices[t.groupIndex]+1;{const r=t.index==="LAST"?n:t.index;let a=op(r,e);return a=Math.max(0,a,Math.min(n,a)),a}}function tN(t,e,n,r=0){return r>0&&(e=Math.max(e,ip(t,r,Ro).offset)),Z_(jv(t,e,n,eN),aN)}function nN(t,[e,n,r,a]){e.length>0&&r("received item sizes",e,vt.DEBUG);const i=t.sizeTree;let o=i,s=0;if(n.length>0&&je(i)&&e.length===2){const p=e[0].size,m=e[1].size;o=n.reduce((g,f)=>xt(xt(g,f,p),f+1,m),o)}else[o,s]=Zv(o,e);if(o===i)return t;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:_}=vo(t.offsetTree,s,o,a);return{groupIndices:n,groupOffsetTree:n.reduce((p,m)=>xt(p,m,Mr(m,_,a)),rr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:_,sizeTree:o}}function rN(t){return Un(t).map(({k:e,v:n},r,a)=>{const i=a[r+1];return{endIndex:i?i.k-1:1/0,size:n,startIndex:e}})}function lp(t,e){let n=0,r=0;for(;n<t;)n+=e[r+1]-e[r]-1,r++;return r-(n===t?0:1)}function vo(t,e,n,r){let a=t,i=0,o=0,s=0,l=0;if(e!==0){l=Oa(a,e-1,Ro),s=a[l].offset;const c=Vt(n,e-1);i=c[0],o=c[1],a.length&&a[l].size===Vt(n,e)[1]&&(l-=1),a=a.slice(0,l+1)}else a=[];for(const{start:c,value:d}of va(n,e,1/0)){const _=c-i,p=_*o+s+_*r;a.push({index:c,offset:p,size:d}),i=c,s=p,o=d}return{lastIndex:i,lastOffset:s,lastSize:o,offsetTree:a}}function aN(t){return{index:t.index,value:t}}function iN(t){const{endIndex:e,size:n,startIndex:r}=t;return a=>a.start===r&&(a.end===e||a.end===1/0)&&a.value===n}const oN={offsetHeight:"height",offsetWidth:"width"},tn=qe(([{log:t},{recalcInProgress:e}])=>{const n=Ye(),r=Ye(),a=Et(r,0),i=Ye(),o=Ye(),s=ne(0),l=ne([]),c=ne(void 0),d=ne(void 0),_=ne((C,R)=>bn(C,oN[R])),p=ne(void 0),m=ne(0),g=Xv(),f=Et(X(n,Pe(l,t,m),en(nN,g),tt()),g),E=Et(X(l,tt(),en((C,R)=>({current:R,prev:C.current}),{current:[],prev:[]}),pe(({prev:C})=>C)),[]);Te(X(l,ye(C=>C.length>0),Pe(f,m),pe(([C,R,N])=>{const O=C.reduce((D,w,L)=>xt(D,w,Mr(w,R.offsetTree,N)||L),rr());return{...R,groupIndices:C,groupOffsetTree:O}})),f),Te(X(r,Pe(f),ye(([C,{lastIndex:R}])=>C<R),pe(([C,{lastIndex:R,lastSize:N}])=>[{endIndex:R,size:N,startIndex:C}])),n),Te(c,d);const S=Et(X(c,pe(C=>C===void 0)),!0);Te(X(d,ye(C=>C!==void 0&&je(lt(f).sizeTree)),pe(C=>[{endIndex:0,size:C,startIndex:0}])),n);const T=At(X(n,Pe(f),en(({sizes:C},[R,N])=>({changed:N!==C,sizes:N}),{changed:!1,sizes:g}),pe(C=>C.changed)));We(X(s,en((C,R)=>({diff:C.prev-R,prev:R}),{diff:0,prev:0}),pe(C=>C.diff)),C=>{const{groupIndices:R}=lt(f);if(C>0)Me(e,!0),Me(i,C+lp(C,R));else if(C<0){const N=lt(E);N.length>0&&(C-=lp(-C,N)),Me(o,C)}}),We(X(s,Pe(t)),([C,R])=>{C<0&&R("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:s},vt.ERROR)});const h=At(i);Te(X(i,Pe(f),pe(([C,R])=>{const N=R.groupIndices.length>0,O=[],D=R.lastSize;if(N){const w=Dr(R.sizeTree,0);let L=0,H=0;for(;L<C;){const P=R.groupIndices[H],G=R.groupIndices.length===H+1?1/0:R.groupIndices[H+1]-P-1;O.push({endIndex:P,size:w,startIndex:P}),O.push({endIndex:P+1+G-1,size:D,startIndex:P+1}),H++,L+=G+1}const z=Un(R.sizeTree);return L!==C&&z.shift(),z.reduce((P,{k:G,v:I})=>{let U=P.ranges;return P.prevSize!==0&&(U=[...P.ranges,{endIndex:G+C-1,size:P.prevSize,startIndex:P.prevIndex}]),{prevIndex:G+C,prevSize:I,ranges:U}},{prevIndex:C,prevSize:0,ranges:O}).ranges}return Un(R.sizeTree).reduce((w,{k:L,v:H})=>({prevIndex:L+C,prevSize:H,ranges:[...w.ranges,{endIndex:L+C-1,size:w.prevSize,startIndex:w.prevIndex}]}),{prevIndex:0,prevSize:D,ranges:[]}).ranges})),n);const v=At(X(o,Pe(f,m),pe(([C,{offsetTree:R},N])=>{const O=-C;return Mr(O,R,N)})));return Te(X(o,Pe(f,m),pe(([C,R,N])=>{if(R.groupIndices.length>0){if(je(R.sizeTree))return R;let O=rr();const D=lt(E);let w=0,L=0,H=0;for(;w<-C;){H=D[L];const z=D[L+1]-H-1;L++,w+=z+1}if(O=Un(R.sizeTree).reduce((z,{k:P,v:G})=>xt(z,Math.max(0,P+C),G),O),w!==-C){const z=Dr(R.sizeTree,H);O=xt(O,0,z);const P=Vt(R.sizeTree,-C+1)[1];O=xt(O,1,P)}return{...R,sizeTree:O,...vo(R.offsetTree,0,O,N)}}else{const O=Un(R.sizeTree).reduce((D,{k:w,v:L})=>xt(D,Math.max(0,w+C),L),rr());return{...R,sizeTree:O,...vo(R.offsetTree,0,O,N)}}})),f),{beforeUnshiftWith:h,data:p,defaultItemSize:d,firstItemIndex:s,fixedItemSize:c,gap:m,groupIndices:l,itemSize:_,listRefresh:T,shiftWith:o,shiftWithOffset:v,sizeRanges:n,sizes:f,statefulTotalCount:a,totalCount:r,trackItemSizes:S,unshiftWith:i}},et(Sn,Co),{singleton:!0});function sN(t){return t.reduce((e,n)=>(e.groupIndices.push(e.totalCount),e.totalCount+=n+1,e),{groupIndices:[],totalCount:0})}const cp=qe(([{groupIndices:t,sizes:e,totalCount:n},{headerHeight:r,scrollTop:a}])=>{const i=Ye(),o=Ye(),s=At(X(i,pe(sN)));return Te(X(s,pe(l=>l.totalCount)),n),Te(X(s,pe(l=>l.groupIndices)),t),Te(X(dt(a,e,r),ye(([l,c])=>ya(c)),pe(([l,c,d])=>Vt(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),tt(),pe(l=>[l])),o),{groupCounts:i,topItemsIndexes:o}},et(tn,Tt)),Tn=qe(([{log:t}])=>{const e=ne(!1),n=At(X(e,ye(r=>r),tt()));return We(e,r=>{r&<(t)("props updated",{},vt.DEBUG)}),{didMount:n,propsReady:e}},et(Sn),{singleton:!0}),lN=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function dp(t){const e=typeof t=="number"?{index:t}:t;return e.align||(e.align="start"),(!e.behavior||!lN)&&(e.behavior="auto"),e.offset||(e.offset=0),e}const Lr=qe(([{gap:t,listRefresh:e,sizes:n,totalCount:r},{fixedFooterHeight:a,fixedHeaderHeight:i,footerHeight:o,headerHeight:s,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:_},{log:p}])=>{const m=Ye(),g=Ye(),f=ne(0);let E=null,S=null,T=null;function h(){E&&(E(),E=null),T&&(T(),T=null),S&&(clearTimeout(S),S=null),Me(l,!1)}return Te(X(m,Pe(n,_,r,f,s,o,p),Pe(t,i,a),pe(([[v,C,R,N,O,D,w,L],H,z,P])=>{const G=dp(v),{align:I,behavior:U,offset:M}=G,k=N-1,Y=sp(G,C,k);let W=Mr(Y,C.offsetTree,H)+D;I==="end"?(W+=z+Vt(C.sizeTree,Y)[1]-R+P,Y===k&&(W+=w)):I==="center"?W+=(z+Vt(C.sizeTree,Y)[1]-R+P)/2:W-=O,M&&(W+=M);const re=q=>{h(),q?(L("retrying to scroll to",{location:v},vt.DEBUG),Me(m,v)):(Me(g,!0),L("list did not change, scroll successful",{},vt.DEBUG))};if(h(),U==="smooth"){let q=!1;T=We(e,j=>{q=q||j}),E=qt(d,()=>{re(q)})}else E=qt(X(e,cN(150)),re);return S=setTimeout(()=>{h()},1200),Me(l,!0),L("scrolling from index to",{behavior:U,index:Y,top:W},vt.DEBUG),{behavior:U,top:W}})),c),{scrollTargetReached:g,scrollToIndex:m,topListHeight:f}},et(tn,Tt,Sn),{singleton:!0});function cN(t){return e=>{const n=setTimeout(()=>{e(!1)},t);return r=>{r&&(e(!0),clearTimeout(n))}}}function No(t,e){t==0?e():requestAnimationFrame(()=>{No(t-1,e)})}function Oo(t,e){const n=e-1;return typeof t=="number"?t:t.index==="LAST"?n:t.index}const Pr=qe(([{defaultItemSize:t,listRefresh:e,sizes:n},{scrollTop:r},{scrollTargetReached:a,scrollToIndex:i},{didMount:o}])=>{const s=ne(!0),l=ne(0),c=ne(!0);return Te(X(o,Pe(l),ye(([d,_])=>!!_),Jt(!1)),s),Te(X(o,Pe(l),ye(([d,_])=>!!_),Jt(!1)),c),We(X(dt(e,o),Pe(s,n,t,c),ye(([[,d],_,{sizeTree:p},m,g])=>d&&(!je(p)||mo(m))&&!_&&!g),Pe(l)),([,d])=>{qt(a,()=>{Me(c,!0)}),No(4,()=>{qt(r,()=>{Me(s,!0)}),Me(i,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:s}},et(tn,Tt,Lr,Tn),{singleton:!0});function up(t,e){return Math.abs(t-e)<1.01}const kr="up",Ur="down",dN="none",uN={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},_N=0,Fr=qe(([{footerHeight:t,headerHeight:e,scrollBy:n,scrollContainerState:r,scrollTop:a,viewportHeight:i}])=>{const o=ne(!1),s=ne(!0),l=Ye(),c=Ye(),d=ne(4),_=ne(_N),p=Et(X(Eo(X(Ne(a),Pn(1),Jt(!0)),X(Ne(a),Pn(1),Jt(!1),K_(100))),tt()),!1),m=Et(X(Eo(X(n,Jt(!0)),X(n,Jt(!1),K_(200))),tt()),!1);Te(X(dt(Ne(a),Ne(_)),pe(([T,h])=>T<=h),tt()),s),Te(X(s,un(50)),c);const g=At(X(dt(r,Ne(i),Ne(e),Ne(t),Ne(d)),en((T,[{scrollHeight:h,scrollTop:v},C,R,N,O])=>{const D=v+C-h>-O,w={scrollHeight:h,scrollTop:v,viewportHeight:C};if(D){let H,z;return v>T.state.scrollTop?(H="SCROLLED_DOWN",z=T.state.scrollTop-v):(H="SIZE_DECREASED",z=T.state.scrollTop-v||T.scrollTopDelta),{atBottom:!0,atBottomBecause:H,scrollTopDelta:z,state:w}}let L;return w.scrollHeight>T.state.scrollHeight?L="SIZE_INCREASED":C<T.state.viewportHeight?L="VIEWPORT_HEIGHT_DECREASING":v<T.state.scrollTop?L="SCROLLING_UPWARDS":L="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:L,state:w}},uN),tt((T,h)=>T&&T.atBottom===h.atBottom))),f=Et(X(r,en((T,{scrollHeight:h,scrollTop:v,viewportHeight:C})=>{if(up(T.scrollHeight,h))return{changed:!1,jump:0,scrollHeight:h,scrollTop:v};{const R=h-(v+C)<1;return T.scrollTop!==v&&R?{changed:!0,jump:T.scrollTop-v,scrollHeight:h,scrollTop:v}:{changed:!0,jump:0,scrollHeight:h,scrollTop:v}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),ye(T=>T.changed),pe(T=>T.jump)),0);Te(X(g,pe(T=>T.atBottom)),o),Te(X(o,un(50)),l);const E=ne(Ur);Te(X(r,pe(({scrollTop:T})=>T),tt(),en((T,h)=>lt(m)?{direction:T.direction,prevScrollTop:h}:{direction:h<T.prevScrollTop?kr:Ur,prevScrollTop:h},{direction:Ur,prevScrollTop:0}),pe(T=>T.direction)),E),Te(X(r,un(50),Jt(dN)),E);const S=ne(0);return Te(X(p,ye(T=>!T),Jt(0)),S),Te(X(a,un(100),Pe(p),ye(([T,h])=>!!h),en(([T,h],[v])=>[h,v],[0,0]),pe(([T,h])=>h-T)),S),{atBottomState:g,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:_,isAtBottom:o,isAtTop:s,isScrolling:p,lastJumpDueToItemResize:f,scrollDirection:E,scrollVelocity:S}},et(Tt)),Ia="top",Aa="bottom",_p="none";function pp(t,e,n){return typeof t=="number"?n===kr&&e===Ia||n===Ur&&e===Aa?t:0:n===kr?e===Ia?t.main:t.reverse:e===Aa?t.main:t.reverse}function mp(t,e){var n;return typeof t=="number"?t:(n=t[e])!=null?n:0}const yo=qe(([{deviation:t,fixedHeaderHeight:e,headerHeight:n,scrollTop:r,viewportHeight:a}])=>{const i=Ye(),o=ne(0),s=ne(0),l=ne(0),c=Et(X(dt(Ne(r),Ne(a),Ne(n),Ne(i,wr),Ne(l),Ne(o),Ne(e),Ne(t),Ne(s)),pe(([d,_,p,[m,g],f,E,S,T,h])=>{const v=d-T,C=E+S,R=Math.max(p-v,0);let N=_p;const O=mp(h,Ia),D=mp(h,Aa);return m-=T,m+=p+S,g+=p+S,g-=T,m>d+C-O&&(N=kr),g<d-R+_+D&&(N=Ur),N!==_p?[Math.max(v-p-pp(f,Ia,N)-O,0),v-R-S+_+pp(f,Aa,N)+D]:null}),ye(d=>d!=null),tt(wr)),[0,0]);return{increaseViewportBy:s,listBoundary:i,overscan:l,topListHeight:o,visibleRange:c}},et(Tt),{singleton:!0});function pN(t,e,n){if(ya(e)){const r=op(t,e);return[{index:Vt(e.groupOffsetTree,r)[0],offset:0,size:0},{data:n==null?void 0:n[0],index:r,offset:0,size:0}]}return[{data:n==null?void 0:n[0],index:t,offset:0,size:0}]}const Io={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function xa(t,e,n,r,a,i){const{lastIndex:o,lastOffset:s,lastSize:l}=a;let c=0,d=0;if(t.length>0){c=t[0].offset;const f=t[t.length-1];d=f.offset+f.size}const _=n-o,p=s+_*l+(_-1)*r,m=c,g=p-d;return{bottom:d,firstItemIndex:i,items:Ep(t,a,i),offsetBottom:g,offsetTop:c,top:m,topItems:Ep(e,a,i),topListHeight:e.reduce((f,E)=>E.size+f,0),totalCount:n}}function gp(t,e,n,r,a,i){let o=0;if(n.groupIndices.length>0)for(const d of n.groupIndices){if(d-o>=t)break;o++}const s=t+o,l=Oo(e,s),c=Array.from({length:s}).map((d,_)=>({data:i[_+l],index:_+l,offset:0,size:0}));return xa(c,[],s,a,n,r)}function Ep(t,e,n){if(t.length===0)return[];if(!ya(e))return t.map(c=>({...c,index:c.index+n,originalIndex:c.index}));const r=t[0].index,a=t[t.length-1].index,i=[],o=va(e.groupOffsetTree,r,a);let s,l=0;for(const c of t){(!s||s.end<c.index)&&(s=o.shift(),l=e.groupIndices.indexOf(s.start));let d;c.index===s.start?d={index:l,type:"group"}:d={groupIndex:l,index:c.index-(l+1)+n},i.push({...d,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return i}const Fn=qe(([{data:t,firstItemIndex:e,gap:n,sizes:r,totalCount:a},i,{listBoundary:o,topListHeight:s,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:_},p,{didMount:m},{recalcInProgress:g}])=>{const f=ne([]),E=ne(0),S=Ye();Te(i.topItemsIndexes,f);const T=Et(X(dt(m,g,Ne(l,wr),Ne(a),Ne(r),Ne(c),d,Ne(f),Ne(e),Ne(n),t),ye(([R,N,,O,,,,,,,D])=>{const w=D&&D.length!==O;return R&&!N&&!w}),pe(([,,[R,N],O,D,w,L,H,z,P,G])=>{const I=D,{offsetTree:U,sizeTree:M}=I,k=lt(E);if(O===0)return{...Io,totalCount:O};if(R===0&&N===0)return k===0?{...Io,totalCount:O}:gp(k,w,D,z,P,G||[]);if(je(M))return k>0?null:xa(pN(Oo(w,O),I,G),[],O,P,I,z);const Y=[];if(H.length>0){const se=H[0],Ee=H[H.length-1];let V=0;for(const F of va(M,se,Ee)){const Q=F.value,te=Math.max(F.start,se),ce=Math.min(F.end,Ee);for(let oe=te;oe<=ce;oe++)Y.push({data:G==null?void 0:G[oe],index:oe,offset:V,size:Q}),V+=Q}}if(!L)return xa([],Y,O,P,I,z);const W=H.length>0?H[H.length-1]+1:0,re=tN(U,R,N,W);if(re.length===0)return null;const q=O-1,j=Ra([],se=>{for(const Ee of re){const V=Ee.value;let F=V.offset,Q=Ee.start;const te=V.size;if(V.offset<R){Q+=Math.floor((R-V.offset+P)/(te+P));const oe=Q-Ee.start;F+=oe*te+oe*P}Q<W&&(F+=(W-Q)*te,Q=W);const ce=Math.min(Ee.end,q);for(let oe=Q;oe<=ce&&!(F>=N);oe++)se.push({data:G==null?void 0:G[oe],index:oe,offset:F,size:te}),F+=te+P}});return xa(j,Y,O,P,I,z)}),ye(R=>R!==null),tt()),Io);Te(X(t,ye(mo),pe(R=>R==null?void 0:R.length)),a),Te(X(T,pe(R=>R.topListHeight)),_),Te(_,s),Te(X(T,pe(R=>[R.top,R.bottom])),o),Te(X(T,pe(R=>R.items)),S);const h=At(X(T,ye(({items:R})=>R.length>0),Pe(a,t),ye(([{items:R},N])=>R[R.length-1].originalIndex===N-1),pe(([,R,N])=>[R-1,N]),tt(wr),pe(([R])=>R))),v=At(X(T,un(200),ye(({items:R,topItems:N})=>R.length>0&&R[0].originalIndex===N.length),pe(({items:R})=>R[0].index),tt())),C=At(X(T,ye(({items:R})=>R.length>0),pe(({items:R})=>{let N=0,O=R.length-1;for(;R[N].type==="group"&&N<O;)N++;for(;R[O].type==="group"&&O>N;)O--;return{endIndex:R[O].index,startIndex:R[N].index}}),tt(ap)));return{endReached:h,initialItemCount:E,itemsRendered:S,listState:T,rangeChanged:C,startReached:v,topItemsIndexes:f,...p}},et(tn,cp,yo,Pr,Lr,Fr,Tn,Co),{singleton:!0}),fp=qe(([{fixedFooterHeight:t,fixedHeaderHeight:e,footerHeight:n,headerHeight:r},{listState:a}])=>{const i=Ye(),o=Et(X(dt(n,t,r,e,a),pe(([s,l,c,d,_])=>s+l+c+d+_.offsetBottom+_.bottom)),0);return Te(Ne(o),i),{totalListHeight:o,totalListHeightChanged:i}},et(Tt,Fn),{singleton:!0}),mN=qe(([{viewportHeight:t},{totalListHeight:e}])=>{const n=ne(!1),r=Et(X(dt(n,t,e),ye(([a])=>a),pe(([,a,i])=>Math.max(0,a-i)),un(0),tt()),0);return{alignToBottom:n,paddingTopAddition:r}},et(Tt,fp),{singleton:!0}),Sp=qe(()=>({context:ne(null)})),gN=({itemBottom:t,itemTop:e,locationParams:{align:n,behavior:r,...a},viewportBottom:i,viewportTop:o})=>e<o?{...a,align:n??"start",behavior:r}:t>i?{...a,align:n??"end",behavior:r}:null,bp=qe(([{gap:t,sizes:e,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:a,headerHeight:i,scrollingInProgress:o,scrollTop:s,viewportHeight:l},{scrollToIndex:c}])=>{const d=Ye();return Te(X(d,Pe(e,l,n,i,a,r,s),Pe(t),pe(([[_,p,m,g,f,E,S,T],h])=>{const{align:v,behavior:C,calculateViewLocation:R=gN,done:N,...O}=_,D=sp(_,p,g-1),w=Mr(D,p.offsetTree,h)+f+E,L=w+Vt(p.sizeTree,D)[1],H=T+E,z=T+m-S,P=R({itemBottom:L,itemTop:w,locationParams:{align:v,behavior:C,...O},viewportBottom:z,viewportTop:H});return P?N&&qt(X(o,ye(G=>!G),Pn(lt(o)?1:2)),N):N&&N(),P}),ye(_=>_!==null)),c),{scrollIntoView:d}},et(tn,Tt,Lr,Fn,Sn),{singleton:!0});function Tp(t){return t?t==="smooth"?"smooth":"auto":!1}const EN=(t,e)=>typeof t=="function"?Tp(t(e)):e&&Tp(t),fN=qe(([{listRefresh:t,totalCount:e,fixedItemSize:n,data:r},{atBottomState:a,isAtBottom:i},{scrollToIndex:o},{scrolledToInitialItem:s},{didMount:l,propsReady:c},{log:d},{scrollingInProgress:_},{context:p},{scrollIntoView:m}])=>{const g=ne(!1),f=Ye();let E=null;function S(C){Me(o,{align:"end",behavior:C,index:"LAST"})}We(X(dt(X(Ne(e),Pn(1)),l),Pe(Ne(g),i,s,_),pe(([[C,R],N,O,D,w])=>{let L=R&&D,H="auto";return L&&(H=EN(N,O||w),L=L&&!!H),{followOutputBehavior:H,shouldFollow:L,totalCount:C}}),ye(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:R})=>{E&&(E(),E=null),lt(n)?requestAnimationFrame(()=>{lt(d)("following output to ",{totalCount:R},vt.DEBUG),S(C)}):E=qt(t,()=>{lt(d)("following output to ",{totalCount:R},vt.DEBUG),S(C),E=null})});function T(C){const R=qt(a,N=>{C&&!N.atBottom&&N.notAtBottomBecause==="SIZE_INCREASED"&&!E&&(lt(d)("scrolling to bottom due to increased size",{},vt.DEBUG),S("auto"))});setTimeout(R,100)}We(X(dt(Ne(g),e,c),ye(([C,,R])=>C&&R),en(({value:C},[,R])=>({refreshed:C===R,value:R}),{refreshed:!1,value:0}),ye(({refreshed:C})=>C),Pe(g,e)),([,C])=>{lt(s)&&T(C!==!1)}),We(f,()=>{T(lt(g)!==!1)}),We(dt(Ne(g),a),([C,R])=>{C&&!R.atBottom&&R.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&S("auto")});const h=ne(null),v=Ye();return Te(Eo(X(Ne(r),pe(C=>{var R;return(R=C==null?void 0:C.length)!=null?R:0})),X(Ne(e))),v),We(X(dt(X(v,Pn(1)),l),Pe(Ne(h),s,_,p),pe(([[C,R],N,O,D,w])=>R&&O&&(N==null?void 0:N({context:w,totalCount:C,scrollingInProgress:D}))),ye(C=>!!C),un(0)),C=>{E&&(E(),E=null),lt(n)?requestAnimationFrame(()=>{lt(d)("scrolling into view",{}),Me(m,C)}):E=qt(t,()=>{lt(d)("scrolling into view",{}),Me(m,C),E=null})}),{autoscrollToBottom:f,followOutput:g,scrollIntoViewOnChange:h}},et(tn,Fr,Lr,Pr,Tn,Sn,Tt,Sp,bp)),SN=qe(([{data:t,firstItemIndex:e,gap:n,sizes:r},{initialTopMostItemIndex:a},{initialItemCount:i,listState:o},{didMount:s}])=>(Te(X(s,Pe(i),ye(([,l])=>l!==0),Pe(a,r,e,n,t),pe(([[,l],c,d,_,p,m=[]])=>gp(l,c,d,_,p,m))),o),{}),et(tn,Pr,Fn,Tn),{singleton:!0}),bN=qe(([{didMount:t},{scrollTo:e},{listState:n}])=>{const r=ne(0);return We(X(t,Pe(r),ye(([,a])=>a!==0),pe(([,a])=>({top:a}))),a=>{qt(X(n,Pn(1),ye(i=>i.items.length>1)),()=>{requestAnimationFrame(()=>{Me(e,a)})})}),{initialScrollTop:r}},et(Tn,Tt,Fn),{singleton:!0}),hp=qe(([{scrollVelocity:t}])=>{const e=ne(!1),n=Ye(),r=ne(!1);return Te(X(t,Pe(r,e,n),ye(([a,i])=>!!i),pe(([a,i,o,s])=>{const{enter:l,exit:c}=i;if(o){if(c(a,s))return!1}else if(l(a,s))return!0;return o}),tt()),e),We(X(dt(e,t,n),Pe(r)),([[a,i,o],s])=>{a&&s&&s.change&&s.change(i,o)}),{isSeeking:e,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:t}},et(Fr),{singleton:!0}),Ao=qe(([{scrollContainerState:t,scrollTo:e}])=>{const n=Ye(),r=Ye(),a=Ye(),i=ne(!1),o=ne(void 0);return Te(X(dt(n,r),pe(([{scrollHeight:s,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:s,scrollTop:Math.max(0,l-d),viewportHeight:c}))),t),Te(X(e,Pe(r),pe(([s,{offsetTop:l}])=>({...s,top:s.top+l}))),a),{customScrollParent:o,useWindowScroll:i,windowScrollContainerState:n,windowScrollTo:a,windowViewportRect:r}},et(Tt)),TN=qe(([{sizeRanges:t,sizes:e},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:a},{didMount:i},{useWindowScroll:o,windowScrollContainerState:s,windowViewportRect:l}])=>{const c=Ye(),d=ne(void 0),_=ne(null),p=ne(null);return Te(s,_),Te(l,p),We(X(c,Pe(e,r,o,_,p,n)),([m,g,f,E,S,T,h])=>{const v=rN(g.sizeTree);E&&S!==null&&T!==null&&(f=S.scrollTop-T.offsetTop),f-=h,m({ranges:v,scrollTop:f})}),Te(X(d,ye(mo),pe(hN)),a),Te(X(i,Pe(d),ye(([,m])=>m!==void 0),tt(),pe(([,m])=>m.ranges)),t),{getState:c,restoreStateFrom:d}},et(tn,Tt,Pr,Tn,Ao));function hN(t){return{align:"start",index:0,offset:t.scrollTop}}const CN=qe(([{topItemsIndexes:t}])=>{const e=ne(0);return Te(X(e,ye(n=>n>=0),pe(n=>Array.from({length:n}).map((r,a)=>a))),t),{topItemCount:e}},et(Fn));function Cp(t){let e=!1,n;return()=>(e||(e=!0,n=t()),n)}const RN=Cp(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),vN=qe(([{deviation:t,scrollBy:e,scrollingInProgress:n,scrollTop:r},{isAtBottom:a,isScrolling:i,lastJumpDueToItemResize:o,scrollDirection:s},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:_,sizes:p},{log:m},{recalcInProgress:g}])=>{const f=At(X(l,Pe(o),en(([,S,T,h],[{bottom:v,items:C,offsetBottom:R,totalCount:N},O])=>{const D=v+R;let w=0;return T===N&&S.length>0&&C.length>0&&(C[0].originalIndex===0&&S[0].originalIndex===0||(w=D-h,w!==0&&(w+=O))),[w,C,N,D]},[0,[],0,0]),ye(([S])=>S!==0),Pe(r,s,n,a,m,g),ye(([,S,T,h,,,v])=>!v&&!h&&S!==0&&T===kr),pe(([[S],,,,,T])=>(T("Upward scrolling compensation",{amount:S},vt.DEBUG),S))));function E(S){S>0?(Me(e,{behavior:"auto",top:-S}),Me(t,0)):(Me(t,0),Me(e,{behavior:"auto",top:-S}))}return We(X(f,Pe(t,i)),([S,T,h])=>{h&&RN()?Me(t,T-S):E(-S)}),We(X(dt(Et(i,!1),t,g),ye(([S,T,h])=>!S&&!h&&T!==0),pe(([S,T])=>T),un(1)),E),Te(X(_,pe(S=>({top:-S}))),e),We(X(c,Pe(p,d),pe(([S,{groupIndices:T,lastSize:h,sizeTree:v},C])=>{function R(N){return N*(h+C)}if(T.length===0)return R(S);{let N=0;const O=Dr(v,0);let D=0,w=0;for(;D<S;){D++,N+=O;let L=T.length===w+1?1/0:T[w+1]-T[w]-1;D+L>S&&(N-=O,L=S-D+1),D+=L,N+=R(L),w++}return N}})),S=>{Me(t,S),requestAnimationFrame(()=>{Me(e,{top:S}),requestAnimationFrame(()=>{Me(t,0),Me(g,!1)})})}),{deviation:t}},et(Tt,Fr,Fn,tn,Sn,Co)),NN=qe(([t,e,n,r,a,i,o,s,l,c,d])=>({...t,...e,...n,...r,...a,...i,...o,...s,...l,...c,...d}),et(yo,SN,Tn,hp,fp,bN,mN,Ao,bp,Sn,Sp)),Rp=qe(([{data:t,defaultItemSize:e,firstItemIndex:n,fixedItemSize:r,gap:a,groupIndices:i,itemSize:o,sizeRanges:s,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:_},{initialItemFinalLocationReached:p,initialTopMostItemIndex:m,scrolledToInitialItem:g},f,E,S,{listState:T,topItemsIndexes:h,...v},{scrollToIndex:C},R,{topItemCount:N},{groupCounts:O},D])=>(Te(v.rangeChanged,D.scrollSeekRangeChanged),Te(X(D.windowViewportRect,pe(w=>w.visibleHeight)),f.viewportHeight),{data:t,defaultItemHeight:e,firstItemIndex:n,fixedItemHeight:r,gap:a,groupCounts:O,initialItemFinalLocationReached:p,initialTopMostItemIndex:m,scrolledToInitialItem:g,sizeRanges:s,topItemCount:N,topItemsIndexes:h,totalCount:d,...S,groupIndices:i,itemSize:o,listState:T,scrollToIndex:C,statefulTotalCount:c,trackItemSizes:_,...v,...D,...f,sizes:l,...E}),et(tn,Pr,Tt,TN,fN,Fn,Lr,vN,CN,cp,NN));function ON(t,e){const n={},r={};let a=0;const i=t.length;for(;a<i;)r[t[a]]=1,a+=1;for(const o in e)Object.hasOwn(r,o)||(n[o]=e[o]);return n}const Da=typeof document<"u"?y.useLayoutEffect:y.useEffect;function vp(t,e,n){const r=Object.keys(e.required||{}),a=Object.keys(e.optional||{}),i=Object.keys(e.methods||{}),o=Object.keys(e.events||{}),s=y.createContext({});function l(E,S){E.propsReady&&Me(E.propsReady,!1);for(const T of r){const h=E[e.required[T]];Me(h,S[T])}for(const T of a)if(T in S){const h=E[e.optional[T]];Me(h,S[T])}E.propsReady&&Me(E.propsReady,!0)}function c(E){return i.reduce((S,T)=>(S[T]=h=>{const v=E[e.methods[T]];Me(v,h)},S),{})}function d(E){return o.reduce((S,T)=>(S[T]=Hv(E[e.events[T]]),S),{})}const _=y.forwardRef((E,S)=>{const{children:T,...h}=E,[v]=y.useState(()=>Ra(Vv(t),N=>{l(N,h)})),[C]=y.useState(W_(d,v));Da(()=>{for(const N of o)N in h&&We(C[N],h[N]);return()=>{Object.values(C).map(go)}},[h,C,v]),Da(()=>{l(v,h)}),y.useImperativeHandle(S,z_(c(v)));const R=n;return u.jsx(s.Provider,{value:v,children:n?u.jsx(R,{...ON([...r,...a,...o],h),children:T}):T})}),p=E=>{const S=y.useContext(s);return y.useCallback(T=>{Me(S[E],T)},[S,E])},m=E=>{const S=y.useContext(s)[E],T=y.useCallback(h=>We(S,h),[S]);return y.useSyncExternalStore(T,()=>lt(S),()=>lt(S))},g=E=>{const S=y.useContext(s)[E],[T,h]=y.useState(W_(lt,S));return Da(()=>We(S,v=>{v!==T&&h(z_(v))}),[S,T]),T},f=y.version.startsWith("18")?m:g;return{Component:_,useEmitter:(E,S)=>{const T=y.useContext(s)[E];Da(()=>We(T,S),[S,T])},useEmitterValue:f,usePublisher:p}}const Np=y.createContext(void 0),Op=y.createContext(void 0),yp=typeof document<"u"?y.useLayoutEffect:y.useEffect;function xo(t){return"self"in t}function yN(t){return"body"in t}function Ip(t,e,n,r=nr,a,i){const o=y.useRef(null),s=y.useRef(null),l=y.useRef(null),c=y.useCallback(p=>{let m,g,f;const E=p.target;if(yN(E)||xo(E)){const T=xo(E)?E:E.defaultView;f=i?T.scrollX:T.scrollY,m=i?T.document.documentElement.scrollWidth:T.document.documentElement.scrollHeight,g=i?T.innerWidth:T.innerHeight}else f=i?E.scrollLeft:E.scrollTop,m=i?E.scrollWidth:E.scrollHeight,g=i?E.offsetWidth:E.offsetHeight;const S=()=>{t({scrollHeight:m,scrollTop:Math.max(f,0),viewportHeight:g})};p.suppressFlushSync?S():En.flushSync(S),s.current!==null&&(f===s.current||f<=0||f===m-g)&&(s.current=null,e(!0),l.current&&(clearTimeout(l.current),l.current=null))},[t,e,i]);y.useEffect(()=>{const p=a||o.current;return r(a||o.current),c({suppressFlushSync:!0,target:p}),p.addEventListener("scroll",c,{passive:!0}),()=>{r(null),p.removeEventListener("scroll",c)}},[o,c,n,r,a]);function d(p){const m=o.current;if(!m||(i?"offsetWidth"in m&&m.offsetWidth===0:"offsetHeight"in m&&m.offsetHeight===0))return;const g=p.behavior==="smooth";let f,E,S;xo(m)?(E=Math.max(bn(m.document.documentElement,i?"width":"height"),i?m.document.documentElement.scrollWidth:m.document.documentElement.scrollHeight),f=i?m.innerWidth:m.innerHeight,S=i?window.scrollX:window.scrollY):(E=m[i?"scrollWidth":"scrollHeight"],f=bn(m,i?"width":"height"),S=m[i?"scrollLeft":"scrollTop"]);const T=E-f;if(p.top=Math.ceil(Math.max(Math.min(T,p.top),0)),up(f,E)||p.top===S){t({scrollHeight:E,scrollTop:S,viewportHeight:f}),g&&e(!0);return}g?(s.current=p.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,s.current=null,e(!0)},1e3)):s.current=null,i&&(p={behavior:p.behavior,left:p.top}),m.scrollTo(p)}function _(p){i&&(p={behavior:p.behavior,left:p.top}),o.current.scrollBy(p)}return{scrollByCallback:_,scrollerRef:o,scrollToCallback:d}}const Do="-webkit-sticky",Ap="sticky",wo=Cp(()=>{if(typeof document>"u")return Ap;const t=document.createElement("div");return t.style.position=Do,t.style.position===Do?Do:Ap});function Mo(t){return t}const IN=qe(()=>{const t=ne(s=>`Item ${s}`),e=ne(s=>`Group ${s}`),n=ne({}),r=ne(Mo),a=ne("div"),i=ne(nr),o=(s,l=null)=>Et(X(n,pe(c=>c[s]),tt()),l);return{components:n,computeItemKey:r,EmptyPlaceholder:o("EmptyPlaceholder"),FooterComponent:o("Footer"),GroupComponent:o("Group","div"),groupContent:e,HeaderComponent:o("Header"),HeaderFooterTag:a,ItemComponent:o("Item","div"),itemContent:t,ListComponent:o("List","div"),ScrollerComponent:o("Scroller","div"),scrollerRef:i,ScrollSeekPlaceholder:o("ScrollSeekPlaceholder"),TopItemListComponent:o("TopItemList")}}),AN=qe(([t,e])=>({...t,...e}),et(Rp,IN)),xN=({height:t})=>u.jsx("div",{style:{height:t}}),DN={overflowAnchor:"none",position:wo(),zIndex:1},xp={overflowAnchor:"none"},wN={...xp,display:"inline-block",height:"100%"},Dp=y.memo(function({showTopList:t=!1}){const e=De("listState"),n=Ut("sizeRanges"),r=De("useWindowScroll"),a=De("customScrollParent"),i=Ut("windowScrollContainerState"),o=Ut("scrollContainerState"),s=a||r?i:o,l=De("itemContent"),c=De("context"),d=De("groupContent"),_=De("trackItemSizes"),p=De("itemSize"),m=De("log"),g=Ut("gap"),f=De("horizontalDirection"),{callbackRef:E}=Wv(n,p,_,t?nr:s,m,g,a,f,De("skipAnimationFrameInResizeObserver")),[S,T]=y.useState(0);Lo("deviation",P=>{S!==P&&T(P)});const h=De("EmptyPlaceholder"),v=De("ScrollSeekPlaceholder")||xN,C=De("ListComponent"),R=De("ItemComponent"),N=De("GroupComponent"),O=De("computeItemKey"),D=De("isSeeking"),w=De("groupIndices").length>0,L=De("alignToBottom"),H=De("initialItemFinalLocationReached"),z=t?{}:{boxSizing:"border-box",...f?{display:"inline-block",height:"100%",marginLeft:S!==0?S:L?"auto":0,paddingLeft:e.offsetTop,paddingRight:e.offsetBottom,whiteSpace:"nowrap"}:{marginTop:S!==0?S:L?"auto":0,paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},...H?{}:{visibility:"hidden"}};return!t&&e.totalCount===0&&h?u.jsx(h,{...ft(h,c)}):u.jsx(C,{...ft(C,c),"data-testid":t?"virtuoso-top-item-list":"virtuoso-item-list",ref:E,style:z,children:(t?e.topItems:e.items).map(P=>{const G=P.originalIndex,I=O(G+e.firstItemIndex,P.data,c);return D?y.createElement(v,{...ft(v,c),height:P.size,index:P.index,key:I,type:P.type||"item",...P.type==="group"?{}:{groupIndex:P.groupIndex}}):P.type==="group"?y.createElement(N,{...ft(N,c),"data-index":G,"data-item-index":P.index,"data-known-size":P.size,key:I,style:DN},d(P.index,c)):y.createElement(R,{...ft(R,c),...kN(R,P.data),"data-index":G,"data-item-group-index":P.groupIndex,"data-item-index":P.index,"data-known-size":P.size,key:I,style:f?wN:xp},w?l(P.index,P.groupIndex,P.data,c):l(P.index,P.data,c))})})}),MN={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},LN={outline:"none",overflowX:"auto",position:"relative"},wa=t=>({height:"100%",position:"absolute",top:0,width:"100%",...t?{display:"flex",flexDirection:"column"}:{}}),PN={position:wo(),top:0,width:"100%",zIndex:1};function ft(t,e){if(typeof t!="string")return{context:e}}function kN(t,e){return{item:typeof t=="string"?void 0:e}}const UN=y.memo(function(){const t=De("HeaderComponent"),e=Ut("headerHeight"),n=De("HeaderFooterTag"),r=kn(y.useMemo(()=>i=>{e(bn(i,"height"))},[e]),!0,De("skipAnimationFrameInResizeObserver")),a=De("context");return t?u.jsx(n,{ref:r,children:u.jsx(t,{...ft(t,a)})}):null}),FN=y.memo(function(){const t=De("FooterComponent"),e=Ut("footerHeight"),n=De("HeaderFooterTag"),r=kn(y.useMemo(()=>i=>{e(bn(i,"height"))},[e]),!0,De("skipAnimationFrameInResizeObserver")),a=De("context");return t?u.jsx(n,{ref:r,children:u.jsx(t,{...ft(t,a)})}):null});function wp({useEmitter:t,useEmitterValue:e,usePublisher:n}){return y.memo(function({children:r,style:a,context:i,...o}){const s=n("scrollContainerState"),l=e("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=e("scrollerRef"),_=e("horizontalDirection")||!1,{scrollByCallback:p,scrollerRef:m,scrollToCallback:g}=Ip(s,c,l,d,void 0,_);return t("scrollTo",g),t("scrollBy",p),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:m,style:{..._?LN:MN,...a},tabIndex:0,...o,...ft(l,i),children:r})})}function Mp({useEmitter:t,useEmitterValue:e,usePublisher:n}){return y.memo(function({children:r,style:a,context:i,...o}){const s=n("windowScrollContainerState"),l=e("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=e("totalListHeight"),_=e("deviation"),p=e("customScrollParent"),m=y.useRef(null),g=e("scrollerRef"),{scrollByCallback:f,scrollerRef:E,scrollToCallback:S}=Ip(s,c,l,g,p);return yp(()=>{var T;return E.current=p||((T=m.current)==null?void 0:T.ownerDocument.defaultView),()=>{E.current=null}},[E,p]),t("windowScrollTo",S),t("scrollBy",f),u.jsx(l,{ref:m,"data-virtuoso-scroller":!0,style:{position:"relative",...a,...d!==0?{height:d+_}:{}},...o,...ft(l,i),children:r})})}const BN=({children:t})=>{const e=y.useContext(Np),n=Ut("viewportHeight"),r=Ut("fixedItemHeight"),a=De("alignToBottom"),i=De("horizontalDirection"),o=y.useMemo(()=>$_(n,l=>bn(l,i?"width":"height")),[n,i]),s=kn(o,!0,De("skipAnimationFrameInResizeObserver"));return y.useEffect(()=>{e&&(n(e.viewportHeight),r(e.itemHeight))},[e,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:s,style:wa(a),children:t})},GN=({children:t})=>{const e=y.useContext(Np),n=Ut("windowViewportRect"),r=Ut("fixedItemHeight"),a=De("customScrollParent"),i=X_(n,a,De("skipAnimationFrameInResizeObserver")),o=De("alignToBottom");return y.useEffect(()=>{e&&(r(e.itemHeight),n({offsetTop:0,visibleHeight:e.viewportHeight,visibleWidth:100}))},[e,n,r]),u.jsx("div",{"data-viewport-type":"window",ref:i,style:wa(o),children:t})},YN=({children:t})=>{const e=De("TopItemListComponent")||"div",n=De("headerHeight"),r={...PN,marginTop:`${n}px`},a=De("context");return u.jsx(e,{style:r,...ft(e,a),children:t})},HN=y.memo(function(t){const e=De("useWindowScroll"),n=De("topItemsIndexes").length>0,r=De("customScrollParent"),a=De("context");return u.jsxs(r||e?zN:VN,{...t,context:a,children:[n&&u.jsx(YN,{children:u.jsx(Dp,{showTopList:!0})}),u.jsxs(r||e?GN:BN,{children:[u.jsx(UN,{}),u.jsx(Dp,{}),u.jsx(FN,{})]})]})}),{Component:qN,useEmitter:Lo,useEmitterValue:De,usePublisher:Ut}=vp(AN,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},HN),VN=wp({useEmitter:Lo,useEmitterValue:De,usePublisher:Ut}),zN=Mp({useEmitter:Lo,useEmitterValue:De,usePublisher:Ut}),$N=qN;et(Rp,qe(()=>{const t=ne(c=>u.jsxs("td",{children:["Item $",c]})),e=ne(null),n=ne(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=ne(null),a=ne(null),i=ne({}),o=ne(Mo),s=ne(nr),l=(c,d=null)=>Et(X(i,pe(_=>_[c]),tt()),d);return{components:i,computeItemKey:o,context:e,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:a,fixedHeaderContent:r,itemContent:t,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}})),wo();const Lp={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},WN={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Pp,floor:Ma,max:Br,min:Po,round:kp}=Math;function Up(t,e,n){return Array.from({length:e-t+1}).map((r,a)=>({data:n===null?null:n[a+t],index:a+t}))}function KN(t){return{...WN,items:t}}function La(t,e){return t&&t.width===e.width&&t.height===e.height}function QN(t,e){return t&&t.column===e.column&&t.row===e.row}const jN=qe(([{increaseViewportBy:t,listBoundary:e,overscan:n,visibleRange:r},{footerHeight:a,headerHeight:i,scrollBy:o,scrollContainerState:s,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:_},p,m,{didMount:g,propsReady:f},{customScrollParent:E,useWindowScroll:S,windowScrollContainerState:T,windowScrollTo:h,windowViewportRect:v},C])=>{const R=ne(0),N=ne(0),O=ne(Lp),D=ne({height:0,width:0}),w=ne({height:0,width:0}),L=Ye(),H=Ye(),z=ne(0),P=ne(null),G=ne({column:0,row:0}),I=Ye(),U=Ye(),M=ne(!1),k=ne(0),Y=ne(!0),W=ne(!1),re=ne(!1);We(X(g,Pe(k),ye(([F,Q])=>!!Q)),()=>{Me(Y,!1)}),We(X(dt(g,Y,w,D,k,W),ye(([F,Q,te,ce,,oe])=>F&&!Q&&te.height!==0&&ce.height!==0&&!oe)),([,,,,F])=>{Me(W,!0),No(1,()=>{Me(L,F)}),qt(X(c),()=>{Me(e,[0,0]),Me(Y,!0)})}),Te(X(U,ye(F=>F!=null&&F.scrollTop>0),Jt(0)),N),We(X(g,Pe(U),ye(([,F])=>F!=null)),([,F])=>{F&&(Me(D,F.viewport),Me(w,F.item),Me(G,F.gap),F.scrollTop>0&&(Me(M,!0),qt(X(c,Pn(1)),Q=>{Me(M,!1)}),Me(l,{top:F.scrollTop})))}),Te(X(D,pe(({height:F})=>F)),_),Te(X(dt(Ne(D,La),Ne(w,La),Ne(G,(F,Q)=>F&&F.column===Q.column&&F.row===Q.row),Ne(c)),pe(([F,Q,te,ce])=>({gap:te,item:Q,scrollTop:ce,viewport:F}))),I),Te(X(dt(Ne(R),r,Ne(G,QN),Ne(w,La),Ne(D,La),Ne(P),Ne(N),Ne(M),Ne(Y),Ne(k)),ye(([,,,,,,,F])=>!F),pe(([F,[Q,te],ce,oe,xe,Ve,Le,,fe,ke])=>{const{column:ee,row:K}=ce,{height:ie,width:he}=oe,{width:nt}=xe;if(Le===0&&(F===0||nt===0))return Lp;if(he===0){const it=Oo(ke,F),Mt=it+Math.max(Le-1,0);return KN(Up(it,Mt,Ve))}const Ze=Fp(nt,he,ee);let at,Ke;fe?Q===0&&te===0&&Le>0?(at=0,Ke=Le-1):(at=Ze*Ma((Q+K)/(ie+K)),Ke=Ze*Pp((te+K)/(ie+K))-1,Ke=Po(F-1,Br(Ke,Ze-1)),at=Po(Ke,Br(0,at))):(at=0,Ke=-1);const Z=Up(at,Ke,Ve),{bottom:ae,top:be}=Bp(xe,ce,oe,Z),Ce=Pp(F/Ze),Be=Ce*ie+(Ce-1)*K-ae;return{bottom:ae,itemHeight:ie,items:Z,itemWidth:he,offsetBottom:Be,offsetTop:be,top:be}})),O),Te(X(P,ye(F=>F!==null),pe(F=>F.length)),R),Te(X(dt(D,w,O,G),ye(([F,Q,{items:te}])=>te.length>0&&Q.height!==0&&F.height!==0),pe(([F,Q,{items:te},ce])=>{const{bottom:oe,top:xe}=Bp(F,ce,Q,te);return[xe,oe]}),tt(wr)),e);const q=ne(!1);Te(X(c,Pe(q),pe(([F,Q])=>Q||F!==0)),q);const j=At(X(dt(O,R),ye(([{items:F}])=>F.length>0),Pe(q),ye(([[F,Q],te])=>{const ce=F.items[F.items.length-1].index===Q-1;return(te||F.bottom>0&&F.itemHeight>0&&F.offsetBottom===0&&F.items.length===Q)&&ce}),pe(([[,F]])=>F-1),tt())),se=At(X(Ne(O),ye(({items:F})=>F.length>0&&F[0].index===0),Jt(0),tt())),Ee=At(X(Ne(O),Pe(M),ye(([{items:F},Q])=>F.length>0&&!Q),pe(([{items:F}])=>({endIndex:F[F.length-1].index,startIndex:F[0].index})),tt(ap),un(0)));Te(Ee,m.scrollSeekRangeChanged),Te(X(L,Pe(D,w,R,G),pe(([F,Q,te,ce,oe])=>{const xe=dp(F),{align:Ve,behavior:Le,offset:fe}=xe;let ke=xe.index;ke==="LAST"&&(ke=ce-1),ke=Br(0,ke,Po(ce-1,ke));let ee=ko(Q,oe,te,ke);return Ve==="end"?ee=kp(ee-Q.height+te.height):Ve==="center"&&(ee=kp(ee-Q.height/2+te.height/2)),fe&&(ee+=fe),{behavior:Le,top:ee}})),l);const V=Et(X(O,pe(F=>F.offsetBottom+F.bottom)),0);return Te(X(v,pe(F=>({height:F.visibleHeight,width:F.visibleWidth}))),D),{customScrollParent:E,data:P,deviation:z,footerHeight:a,gap:G,headerHeight:i,increaseViewportBy:t,initialItemCount:N,itemDimensions:w,overscan:n,restoreStateFrom:U,scrollBy:o,scrollContainerState:s,scrollHeight:H,scrollTo:l,scrollToIndex:L,scrollTop:c,smoothScrollTargetReached:d,totalCount:R,useWindowScroll:S,viewportDimensions:D,windowScrollContainerState:T,windowScrollTo:h,windowViewportRect:v,...m,gridState:O,horizontalDirection:re,initialTopMostItemIndex:k,totalListHeight:V,...p,endReached:j,propsReady:f,rangeChanged:Ee,startReached:se,stateChanged:I,stateRestoreInProgress:M,...C}},et(yo,Tt,Fr,hp,Tn,Ao,Sn));function Fp(t,e,n){return Br(1,Ma((t+n)/(Ma(e)+n)))}function Bp(t,e,n,r){const{height:a}=n;if(a===void 0||r.length===0)return{bottom:0,top:0};const i=ko(t,e,n,r[0].index);return{bottom:ko(t,e,n,r[r.length-1].index)+a,top:i}}function ko(t,e,n,r){const a=Fp(t.width,n.width,e.column),i=Ma(r/a),o=i*n.height+Br(0,i-1)*e.row;return o>0?o+e.row:o}const XN=qe(()=>{const t=ne(_=>`Item ${_}`),e=ne({}),n=ne(null),r=ne("virtuoso-grid-item"),a=ne("virtuoso-grid-list"),i=ne(Mo),o=ne("div"),s=ne(nr),l=(_,p=null)=>Et(X(e,pe(m=>m[_]),tt()),p),c=ne(!1),d=ne(!1);return Te(Ne(d),c),{components:e,computeItemKey:i,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:o,itemClassName:r,ItemComponent:l("Item","div"),itemContent:t,listClassName:a,ListComponent:l("List","div"),readyStateChanged:c,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),ZN=qe(([t,e])=>({...t,...e}),et(jN,XN)),JN=y.memo(function(){const t=rt("gridState"),e=rt("listClassName"),n=rt("itemClassName"),r=rt("itemContent"),a=rt("computeItemKey"),i=rt("isSeeking"),o=Ft("scrollHeight"),s=rt("ItemComponent"),l=rt("ListComponent"),c=rt("ScrollSeekPlaceholder"),d=rt("context"),_=Ft("itemDimensions"),p=Ft("gap"),m=rt("log"),g=rt("stateRestoreInProgress"),f=Ft("reportReadyState"),E=kn(y.useMemo(()=>S=>{const T=S.parentElement.parentElement.scrollHeight;o(T);const h=S.firstChild;if(h){const{height:v,width:C}=h.getBoundingClientRect();_({height:v,width:C})}p({column:Yp("column-gap",getComputedStyle(S).columnGap,m),row:Yp("row-gap",getComputedStyle(S).rowGap,m)})},[o,_,p,m]),!0,!1);return yp(()=>{t.itemHeight>0&&t.itemWidth>0&&f(!0)},[t]),g?null:u.jsx(l,{className:e,ref:E,...ft(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},children:t.items.map(S=>{const T=a(S.index,S.data,d);return i?u.jsx(c,{...ft(c,d),height:t.itemHeight,index:S.index,width:t.itemWidth},T):y.createElement(s,{...ft(s,d),className:n,"data-index":S.index,key:T},r(S.index,S.data,d))})})}),eO=y.memo(function(){const t=rt("HeaderComponent"),e=Ft("headerHeight"),n=rt("headerFooterTag"),r=kn(y.useMemo(()=>i=>{e(bn(i,"height"))},[e]),!0,!1),a=rt("context");return t?u.jsx(n,{ref:r,children:u.jsx(t,{...ft(t,a)})}):null}),tO=y.memo(function(){const t=rt("FooterComponent"),e=Ft("footerHeight"),n=rt("headerFooterTag"),r=kn(y.useMemo(()=>i=>{e(bn(i,"height"))},[e]),!0,!1),a=rt("context");return t?u.jsx(n,{ref:r,children:u.jsx(t,{...ft(t,a)})}):null}),nO=({children:t})=>{const e=y.useContext(Op),n=Ft("itemDimensions"),r=Ft("viewportDimensions"),a=kn(y.useMemo(()=>i=>{r(i.getBoundingClientRect())},[r]),!0,!1);return y.useEffect(()=>{e&&(r({height:e.viewportHeight,width:e.viewportWidth}),n({height:e.itemHeight,width:e.itemWidth}))},[e,r,n]),u.jsx("div",{ref:a,style:wa(!1),children:t})},rO=({children:t})=>{const e=y.useContext(Op),n=Ft("windowViewportRect"),r=Ft("itemDimensions"),a=rt("customScrollParent"),i=X_(n,a,!1);return y.useEffect(()=>{e&&(r({height:e.itemHeight,width:e.itemWidth}),n({offsetTop:0,visibleHeight:e.viewportHeight,visibleWidth:e.viewportWidth}))},[e,n,r]),u.jsx("div",{ref:i,style:wa(!1),children:t})},aO=y.memo(function({...t}){const e=rt("useWindowScroll"),n=rt("customScrollParent"),r=n||e?oO:iO,a=n||e?rO:nO,i=rt("context");return u.jsx(r,{...t,...ft(r,i),children:u.jsxs(a,{children:[u.jsx(eO,{}),u.jsx(JN,{}),u.jsx(tO,{})]})})}),{useEmitter:Gp,useEmitterValue:rt,usePublisher:Ft}=vp(ZN,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},aO),iO=wp({useEmitter:Gp,useEmitterValue:rt,usePublisher:Ft}),oO=Mp({useEmitter:Gp,useEmitterValue:rt,usePublisher:Ft});function Yp(t,e,n){return e!=="normal"&&!(e!=null&&e.endsWith("px"))&&n(`${t} was not resolved to pixel value correctly`,e,vt.WARN),e==="normal"?0:parseInt(e??"0",10)}function $(...t){return XC.twMerge(jC.clsx(t))}const sO=hr.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),ze=b.forwardRef(({className:t,variant:e,size:n,asChild:r=!1,...a},i)=>{const o=r?yt.Slot:"button";return u.jsx(o,{className:$(sO({variant:e,size:n,className:t})),ref:i,...a})});ze.displayName="Button";const Hp=b.forwardRef(({className:t,...e},n)=>u.jsx("textarea",{className:$("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background 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",t),ref:n,...e}));Hp.displayName="Textarea";function lO({initialValue:t="",editingMessageId:e=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:a=!1,maxLength:i=2e4,onSend:o,onCancelEdit:s,onStop:l,className:c="",textareaClassName:d="",allowEmptySend:_=!1}){const[p,m]=y.useState(t),[g,f]=y.useTransition(),E=y.useRef(null);y.useEffect(()=>{m(t??""),E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`)},[t,e]);const S=y.useCallback(()=>{const O=E.current;O&&(O.style.height="auto",O.style.height=`${O.scrollHeight}px`)},[]);y.useEffect(()=>{S()},[S]);const T=y.useCallback(async O=>{O&&O.preventDefault();const D=(p??"").trim();!D&&!_||f(()=>{try{const w=o(D);w&&typeof w.then=="function"?w.then(()=>{m(""),E.current&&(E.current.style.height="auto")}).catch(()=>{}):(m(""),E.current&&(E.current.style.height="auto"))}catch{}})},[p,o,_]),h=y.useCallback(O=>{m(O.target.value),E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`)},[]),v=y.useCallback(O=>{O.key==="Enter"&&!O.shiftKey?(O.preventDefault(),T()):O.key==="Escape"&&e&&(O.preventDefault(),s==null||s())},[T,e,s]),N=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${e?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${d}`;return u.jsx("form",{onSubmit:O=>void T(O),className:`w-full ${c}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsx("div",{className:"flex-1",children:u.jsx(Hp,{ref:E,value:p,onChange:h,onKeyDown:v,placeholder:e?"Edit your message...":n,className:N,disabled:a,maxLength:i,rows:1,spellCheck:!1,autoCorrect:"off"})}),u.jsx("div",{children:r?u.jsx(ze,{type:"button",onClick:()=>{l==null||l()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:a||!l,children:u.jsx(Se.Square,{size:16})}):u.jsx(ze,{type:"submit",size:"icon",className:"shrink-0",title:e?"Save changes":"Send message",disabled:a||!p.trim()&&!_||g,children:u.jsx(Se.Send,{size:16})})})]})})}const cO=y.memo(lO),dO=hr.cva("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function qp({className:t,variant:e,...n}){return u.jsx("div",{className:$(dO({variant:e}),t),...n})}function de(t,e,{checkForDefaultPrevented:n=!0}={}){return function(a){if(t==null||t(a),n===!1||!a.defaultPrevented)return e==null?void 0:e(a)}}function uO(t,e){const n=b.createContext(e),r=i=>{const{children:o,...s}=i,l=b.useMemo(()=>s,Object.values(s));return u.jsx(n.Provider,{value:l,children:o})};r.displayName=t+"Provider";function a(i){const o=b.useContext(n);if(o)return o;if(e!==void 0)return e;throw new Error(`\`${i}\` must be used within \`${t}\``)}return[r,a]}function zt(t,e=[]){let n=[];function r(i,o){const s=b.createContext(o),l=n.length;n=[...n,o];const c=_=>{var S;const{scope:p,children:m,...g}=_,f=((S=p==null?void 0:p[t])==null?void 0:S[l])||s,E=b.useMemo(()=>g,Object.values(g));return u.jsx(f.Provider,{value:E,children:m})};c.displayName=i+"Provider";function d(_,p){var f;const m=((f=p==null?void 0:p[t])==null?void 0:f[l])||s,g=b.useContext(m);if(g)return g;if(o!==void 0)return o;throw new Error(`\`${_}\` must be used within \`${i}\``)}return[c,d]}const a=()=>{const i=n.map(o=>b.createContext(o));return function(s){const l=(s==null?void 0:s[t])||i;return b.useMemo(()=>({[`__scope${t}`]:{...s,[t]:l}}),[s,l])}};return a.scopeName=t,[r,_O(a,...e)]}function _O(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=r.reduce((s,{useScope:l,scopeName:c})=>{const _=l(i)[`__scope${c}`];return{...s,..._}},{});return b.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}var _t=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},pO=b[" useInsertionEffect ".trim().toString()]||_t;function hn({prop:t,defaultProp:e,onChange:n=()=>{},caller:r}){const[a,i,o]=mO({defaultProp:e,onChange:n}),s=t!==void 0,l=s?t:a;{const d=b.useRef(t!==void 0);b.useEffect(()=>{const _=d.current;_!==s&&console.warn(`${r} is changing from ${_?"controlled":"uncontrolled"} to ${s?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=s},[s,r])}const c=b.useCallback(d=>{var _;if(s){const p=gO(d)?d(t):d;p!==t&&((_=o.current)==null||_.call(o,p))}else i(d)},[s,t,i,o]);return[l,c]}function mO({defaultProp:t,onChange:e}){const[n,r]=b.useState(t),a=b.useRef(n),i=b.useRef(e);return pO(()=>{i.current=e},[e]),b.useEffect(()=>{var o;a.current!==n&&((o=i.current)==null||o.call(i,n),a.current=n)},[n,a]),[n,r,i]}function gO(t){return typeof t=="function"}function Vp(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Uo(...t){return e=>{let n=!1;const r=t.map(a=>{const i=Vp(a,e);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let a=0;a<r.length;a++){const i=r[a];typeof i=="function"?i():Vp(t[a],null)}}}}function Fe(...t){return b.useCallback(Uo(...t),t)}var EO=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ie=EO.reduce((t,e)=>{const n=yt.createSlot(`Primitive.${e}`),r=b.forwardRef((a,i)=>{const{asChild:o,...s}=a,l=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...s,ref:i})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function zp(t,e){t&&la.flushSync(()=>t.dispatchEvent(e))}function fO(t,e){return b.useReducer((n,r)=>e[n][r]??n,t)}var Nt=t=>{const{present:e,children:n}=t,r=SO(e),a=typeof n=="function"?n({present:r.isPresent}):b.Children.only(n),i=Fe(r.ref,bO(a));return typeof n=="function"||r.isPresent?b.cloneElement(a,{ref:i}):null};Nt.displayName="Presence";function SO(t){const[e,n]=b.useState(),r=b.useRef(null),a=b.useRef(t),i=b.useRef("none"),o=t?"mounted":"unmounted",[s,l]=fO(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return b.useEffect(()=>{const c=Pa(r.current);i.current=s==="mounted"?c:"none"},[s]),_t(()=>{const c=r.current,d=a.current;if(d!==t){const p=i.current,m=Pa(c);t?l("MOUNT"):m==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&p!==m?"ANIMATION_OUT":"UNMOUNT"),a.current=t}},[t,l]),_t(()=>{if(e){let c;const d=e.ownerDocument.defaultView??window,_=m=>{const f=Pa(r.current).includes(CSS.escape(m.animationName));if(m.target===e&&f&&(l("ANIMATION_END"),!a.current)){const E=e.style.animationFillMode;e.style.animationFillMode="forwards",c=d.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=E)})}},p=m=>{m.target===e&&(i.current=Pa(r.current))};return e.addEventListener("animationstart",p),e.addEventListener("animationcancel",_),e.addEventListener("animationend",_),()=>{d.clearTimeout(c),e.removeEventListener("animationstart",p),e.removeEventListener("animationcancel",_),e.removeEventListener("animationend",_)}}else l("ANIMATION_END")},[e,l]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:b.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function Pa(t){return(t==null?void 0:t.animationName)||"none"}function bO(t){var r,a;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var TO=b[" useId ".trim().toString()]||(()=>{}),hO=0;function $t(t){const[e,n]=b.useState(TO());return _t(()=>{n(r=>r??String(hO++))},[t]),t||(e?`radix-${e}`:"")}var ka="Collapsible",[CO,Y0]=zt(ka),[RO,Fo]=CO(ka),$p=b.forwardRef((t,e)=>{const{__scopeCollapsible:n,open:r,defaultOpen:a,disabled:i,onOpenChange:o,...s}=t,[l,c]=hn({prop:r,defaultProp:a??!1,onChange:o,caller:ka});return u.jsx(RO,{scope:n,disabled:i,contentId:$t(),open:l,onOpenToggle:b.useCallback(()=>c(d=>!d),[c]),children:u.jsx(Ie.div,{"data-state":Go(l),"data-disabled":i?"":void 0,...s,ref:e})})});$p.displayName=ka;var Wp="CollapsibleTrigger",Kp=b.forwardRef((t,e)=>{const{__scopeCollapsible:n,...r}=t,a=Fo(Wp,n);return u.jsx(Ie.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":Go(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...r,ref:e,onClick:de(t.onClick,a.onOpenToggle)})});Kp.displayName=Wp;var Bo="CollapsibleContent",vO=b.forwardRef((t,e)=>{const{forceMount:n,...r}=t,a=Fo(Bo,t.__scopeCollapsible);return u.jsx(Nt,{present:n||a.open,children:({present:i})=>u.jsx(NO,{...r,ref:e,present:i})})});vO.displayName=Bo;var NO=b.forwardRef((t,e)=>{const{__scopeCollapsible:n,present:r,children:a,...i}=t,o=Fo(Bo,n),[s,l]=b.useState(r),c=b.useRef(null),d=Fe(e,c),_=b.useRef(0),p=_.current,m=b.useRef(0),g=m.current,f=o.open||s,E=b.useRef(f),S=b.useRef(void 0);return b.useEffect(()=>{const T=requestAnimationFrame(()=>E.current=!1);return()=>cancelAnimationFrame(T)},[]),_t(()=>{const T=c.current;if(T){S.current=S.current||{transitionDuration:T.style.transitionDuration,animationName:T.style.animationName},T.style.transitionDuration="0s",T.style.animationName="none";const h=T.getBoundingClientRect();_.current=h.height,m.current=h.width,E.current||(T.style.transitionDuration=S.current.transitionDuration,T.style.animationName=S.current.animationName),l(r)}},[o.open,r]),u.jsx(Ie.div,{"data-state":Go(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!f,...i,ref:d,style:{"--radix-collapsible-content-height":p?`${p}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...t.style},children:f&&a})});function Go(t){return t?"open":"closed"}var OO=$p;const Qp=OO,jp=Kp,Xp=new URL("data:video/mp2t;base64,aW1wb3J0IHsgcGFyc2UgfSBmcm9tICdtYXJrZWQnOwoKY29uc3Qgc2NvcGUgPSBzZWxmOwoKY29uc29sZS5sb2coJ1tNYXJrZG93bldvcmtlcl0gd29ya2VyIHNjcmlwdCBsb2FkZWQnKTsKLy8gU2lnbmFsIHRvIHRoZSBtYWluIHRocmVhZCB0aGF0IHRoZSB3b3JrZXIgaXMgcmVhZHkgdG8gcmVjZWl2ZSB3b3JrLgovLyBUaGlzIGhlbHBzIGNhbGxlcnMgYXZvaWQgcG9zdGluZyBtZXNzYWdlcyBiZWZvcmUgdGhlIHdvcmtlciBoYXMgZmluaXNoZWQgaW5pdGlhbGl6aW5nLgpzY29wZS5wb3N0TWVzc2FnZT8uKHsgX193b3JrZXJfcmVhZHk6IHRydWUgfSk7CgpzY29wZS5hZGRFdmVudExpc3RlbmVyKCdtZXNzYWdlJywgKGV2ZW50OiBNZXNzYWdlRXZlbnQpID0+IHsKICBjb25zdCBwYXlsb2FkOiBhbnkgPSBldmVudD8uZGF0YSA/PyB7fTsKICBjb25zdCBpZCA9IHR5cGVvZiBwYXlsb2FkLmlkID09PSAnc3RyaW5nJyA/IHBheWxvYWQuaWQgOiB1bmRlZmluZWQ7CiAgY29uc3Qgc291cmNlID0gdHlwZW9mIHBheWxvYWQuc291cmNlID09PSAnc3RyaW5nJyA/IHBheWxvYWQuc291cmNlIDogdW5kZWZpbmVkOwogIGlmICghaWQgfHwgdHlwZW9mIHNvdXJjZSAhPT0gJ3N0cmluZycpIHsKICAgIHJldHVybjsKICB9CiAgdHJ5IHsKICAgIGNvbnNvbGUubG9nKCdbTWFya2Rvd25Xb3JrZXJdIHJlY2VpdmVkIHdvcmsnLCBpZCwgJ3NvdXJjZUxlbicsIHNvdXJjZT8ubGVuZ3RoID8/IDApOwogICAgY29uc3QgaHRtbCA9IHBhcnNlKHNvdXJjZSk7CiAgICBjb25zb2xlLmxvZygnW01hcmtkb3duV29ya2VyXSBwYXJzZWQgaHRtbCBsZW5ndGgnLCBodG1sPy5sZW5ndGggPz8gMCwgJ2ZvcicsIGlkKTsKICAgIC8vIFJldHVybiB0aGUgZ2VuZXJhdGVkIEhUTUwgZm9yIHRoZSBjYWxsZXIgdG8gY2FjaGUgYW5kIHJlbmRlcgogICAgLy8gS2VlcCB0aGUgcGF5bG9hZCBzbWFsbDogc2VuZCBpZCArIGh0bWwKICAgIC8vIE1hcmtlZCBvdXRwdXQgc2hvdWxkIGJlIHNhZmUtZW5vdWdoIGZvciBpbnRlcm5hbCBVSXM7IGNhbGxlcnMgbWF5IGZ1cnRoZXIgc2FuaXRpemUgaWYgcmVxdWlyZWQuCiAgICBzY29wZS5wb3N0TWVzc2FnZSh7IGlkLCBodG1sIH0pOwogIH0gY2F0Y2ggKGVycikgewogICAgY29uc29sZS5lcnJvcignW01hcmtkb3duV29ya2VyXSByZW5kZXIgZXJyb3InLCBlcnIpOwogICAgc2NvcGUucG9zdE1lc3NhZ2UoeyBpZCwgaHRtbDogYDxwcmU+RXJyb3IgcmVuZGVyaW5nIG1hcmtkb3duOiAke1N0cmluZyhlcnIpfTwvcHJlPmAgfSk7CiAgfQp9KTsK",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Xn&&Xn.tagName.toUpperCase()==="SCRIPT"&&Xn.src||new URL("index.umd.js",document.baseURI).href),Ua=Xp.toString();console.log("[MarkdownContent] worker url",Ua);const Yo=[];let Ho=!1;const Zp={addEventListener:()=>{},removeEventListener:()=>{},postMessage:()=>{},terminate:()=>{}};let Cn=Zp;const Jp=t=>{console.error("[MarkdownContent] worker error",t)};function qo(t){if(Cn&&Cn!==Zp)try{Cn.removeEventListener("error",Jp)}catch{}Cn=t,Ho=!0;try{Cn.addEventListener("error",Jp)}catch(e){console.warn("[MarkdownContent] failed to register worker error handler",e)}try{for(;Yo.length;){const e=Yo.shift();try{e&&e()}catch{}}}catch(e){console.warn("[MarkdownContent] markWorkerOnline notify failed",e)}}function yO(t){const e=t.indexOf("data:");if(e===-1)return null;const r=t.slice(e).match(/^data:[^;]+;base64,(.*)$/);if(!r)return null;try{const a=r[1],i=atob(a),o=Uint8Array.from(i,c=>c.charCodeAt(0)),s=new Blob([o],{type:"application/javascript"}),l=URL.createObjectURL(s);try{const c=new Worker(l,{type:"module"});return URL.revokeObjectURL(l),c}catch(c){return URL.revokeObjectURL(l),console.error("[MarkdownContent] failed to initialize worker from data URI blob",c),null}}catch(a){return console.warn("[MarkdownContent] failed to decode embedded data URI",a),null}}async function IO(t){try{let e="";const n=await fetch(t);if(e=await n.text(),n.ok||console.warn("[MarkdownContent] fetch worker non-ok",n.status,n.statusText),!e){console.warn("[MarkdownContent] worker fetch returned empty content; aborting worker init.");return}if(e.trim().startsWith("<")){console.warn("[MarkdownContent] worker fetch returned HTML; dev server may be redirecting. Aborting worker init.");return}const r=new Blob([e],{type:"application/javascript"}),a=URL.createObjectURL(r);try{const i=new Worker(a,{type:"module"});qo(i)}catch(i){console.error("[MarkdownContent] failed to initialize worker from blob",i)}finally{URL.revokeObjectURL(a)}}catch(e){console.error("[MarkdownContent] fetch worker failed",e)}}(()=>{if(Ua.includes("data:")){const t=yO(Ua);if(t){qo(t);return}console.warn("[MarkdownContent] data URI bootstrap failed; worker will remain offline until fallback succeeds");return}try{const t=new Worker(Xp,{type:"module"});qo(t)}catch(t){console.warn("[MarkdownContent] worker constructor failed, will try fetch+blob fallback",t),IO(Ua)}})();const Gr=new Map;function AO(t){const e=t.slice(0,64),n=t.length>64?t.slice(-64):"";return`${t.length}:${e}:${n}`}function Yr({content:t,className:e="",fallback:n=u.jsx("div",{"aria-busy":!0,children:"Rendering…"})}){const r=AO(t),[a,i]=y.useState(()=>Gr.get(r)??null);y.useEffect(()=>{if(Gr.has(r)){const g=Gr.get(r)??null;i(g);return}let s=!0,l=!1;const c=g=>{const f=g.data;if(!f||f.id!==r||!s)return;l=!0;const E=f.html??"";Gr.set(r,E),i(E)};Cn.addEventListener("message",c);const d=()=>{try{Cn.postMessage({id:r,source:t})}catch(g){console.error("[MarkdownContent] worker.postMessage threw",g)}};Ho?d():Yo.push(d);const p=((g,f)=>f?g>2e4?1e4:g>8e3?5e3:g>2e3?2e3:600:Math.min(1e4,1e3+Math.floor(g*.5)))(t.length,Ho),m=window.setTimeout(async()=>{if(!l){console.warn("[MarkdownContent] worker timeout (ms="+p+"), falling back to main-thread parse for",r);try{const g=await Promise.resolve().then(()=>kM),f=g&&(g.parse||g.default&&g.default.parse),E=f?f(t):"";Gr.set(r,E),s&&i(E)}catch(g){console.error("[MarkdownContent] fallback parse failed",g)}}},p);return()=>{s=!1,clearTimeout(m),Cn.removeEventListener("message",c)}},[t,r]);const o=y.useRef(null);return y.useEffect(()=>{if(!a)return;const s=o.current;if(!s)return;const l=Array.from(s.querySelectorAll("pre code"));if(!l.length)return;let c=null,d=!1;const _=(m,g)=>{for(const f of m){if(!f.isIntersecting)continue;const E=f.target;if(!c)Promise.resolve().then(()=>o0).then(S=>{if(!d){c=S.default||S;try{l.forEach(T=>{s.contains(T)&&c.highlightElement(T)})}catch{}}}).catch(()=>{});else try{c.highlightElement(E)}catch{}g.unobserve(E)}},p=new IntersectionObserver(_,{root:s,threshold:.1});return l.forEach(m=>p.observe(m)),()=>{d=!0,p.disconnect()}},[a]),a?u.jsx("div",{ref:o,className:$("markdown prose max-w-none break-words dark:prose-invert",e),dangerouslySetInnerHTML:{__html:a}}):u.jsx("div",{className:$("markdown prose max-w-none break-words dark:prose-invert",e),children:n})}async function em(t,e){return await kt(t,{responseType:"blob",onDownloadProgress:r=>{try{e&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function tm(t,e){return await(await em(`/chat/files/${t}/view`,e)).text()}async function xO(t,e){const n=await em(`/chat/files/${t}/download`,e),r=URL.createObjectURL(n);let a=`file_${t}`;try{const o=await kt(`/chat/files/${t}`);a=(o==null?void 0:o.filename)??a}catch{}const i=document.createElement("a");i.href=r,i.download=a,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}const DO=1,wO=1e6;let Vo=0;function MO(){return Vo=(Vo+1)%Number.MAX_SAFE_INTEGER,Vo.toString()}const zo=new Map,nm=t=>{if(zo.has(t))return;const e=setTimeout(()=>{zo.delete(t),Hr({type:"REMOVE_TOAST",toastId:t})},wO);zo.set(t,e)},LO=(t,e)=>{switch(e.type){case"ADD_TOAST":return{...t,toasts:[e.toast,...t.toasts].slice(0,DO)};case"UPDATE_TOAST":return{...t,toasts:t.toasts.map(n=>n.id===e.toast.id?{...n,...e.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=e;return n?nm(n):t.toasts.forEach(r=>{nm(r.id)}),{...t,toasts:t.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return e.toastId===void 0?{...t,toasts:[]}:{...t,toasts:t.toasts.filter(n=>n.id!==e.toastId)}}},Fa=[];let Ba={toasts:[]};function Hr(t){Ba=LO(Ba,t),Fa.forEach(e=>{e(Ba)})}function PO({...t}){const e=MO(),n=a=>Hr({type:"UPDATE_TOAST",toast:{...a,id:e}}),r=()=>Hr({type:"DISMISS_TOAST",toastId:e});return Hr({type:"ADD_TOAST",toast:{...t,id:e,open:!0,onOpenChange:a=>{a||r()}}}),{id:e,dismiss:r,update:n}}function $o(){const[t,e]=b.useState(Ba);return b.useEffect(()=>(Fa.push(e),()=>{const n=Fa.indexOf(e);n>-1&&Fa.splice(n,1)}),[t]),{...t,toast:PO,dismiss:n=>Hr({type:"DISMISS_TOAST",toastId:n})}}function mt(t){const e=b.useRef(t);return b.useEffect(()=>{e.current=t}),b.useMemo(()=>(...n)=>{var r;return(r=e.current)==null?void 0:r.call(e,...n)},[])}function kO(t,e=globalThis==null?void 0:globalThis.document){const n=mt(t);b.useEffect(()=>{const r=a=>{a.key==="Escape"&&n(a)};return e.addEventListener("keydown",r,{capture:!0}),()=>e.removeEventListener("keydown",r,{capture:!0})},[n,e])}var UO="DismissableLayer",Wo="dismissableLayer.update",FO="dismissableLayer.pointerDownOutside",BO="dismissableLayer.focusOutside",rm,am=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),qr=b.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:o,onDismiss:s,...l}=t,c=b.useContext(am),[d,_]=b.useState(null),p=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,m]=b.useState({}),g=Fe(e,N=>_(N)),f=Array.from(c.layers),[E]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),S=f.indexOf(E),T=d?f.indexOf(d):-1,h=c.layersWithOutsidePointerEventsDisabled.size>0,v=T>=S,C=HO(N=>{const O=N.target,D=[...c.branches].some(w=>w.contains(O));!v||D||(a==null||a(N),o==null||o(N),N.defaultPrevented||s==null||s())},p),R=qO(N=>{const O=N.target;[...c.branches].some(w=>w.contains(O))||(i==null||i(N),o==null||o(N),N.defaultPrevented||s==null||s())},p);return kO(N=>{T===c.layers.size-1&&(r==null||r(N),!N.defaultPrevented&&s&&(N.preventDefault(),s()))},p),b.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(rm=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),im(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=rm)}},[d,p,n,c]),b.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),im())},[d,c]),b.useEffect(()=>{const N=()=>m({});return document.addEventListener(Wo,N),()=>document.removeEventListener(Wo,N)},[]),u.jsx(Ie.div,{...l,ref:g,style:{pointerEvents:h?v?"auto":"none":void 0,...t.style},onFocusCapture:de(t.onFocusCapture,R.onFocusCapture),onBlurCapture:de(t.onBlurCapture,R.onBlurCapture),onPointerDownCapture:de(t.onPointerDownCapture,C.onPointerDownCapture)})});qr.displayName=UO;var GO="DismissableLayerBranch",YO=b.forwardRef((t,e)=>{const n=b.useContext(am),r=b.useRef(null),a=Fe(e,r);return b.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),u.jsx(Ie.div,{...t,ref:a})});YO.displayName=GO;function HO(t,e=globalThis==null?void 0:globalThis.document){const n=mt(t),r=b.useRef(!1),a=b.useRef(()=>{});return b.useEffect(()=>{const i=s=>{if(s.target&&!r.current){let l=function(){om(FO,n,c,{discrete:!0})};const c={originalEvent:s};s.pointerType==="touch"?(e.removeEventListener("click",a.current),a.current=l,e.addEventListener("click",a.current,{once:!0})):l()}else e.removeEventListener("click",a.current);r.current=!1},o=window.setTimeout(()=>{e.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(o),e.removeEventListener("pointerdown",i),e.removeEventListener("click",a.current)}},[e,n]),{onPointerDownCapture:()=>r.current=!0}}function qO(t,e=globalThis==null?void 0:globalThis.document){const n=mt(t),r=b.useRef(!1);return b.useEffect(()=>{const a=i=>{i.target&&!r.current&&om(BO,n,{originalEvent:i},{discrete:!1})};return e.addEventListener("focusin",a),()=>e.removeEventListener("focusin",a)},[e,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function im(){const t=new CustomEvent(Wo);document.dispatchEvent(t)}function om(t,e,n,{discrete:r}){const a=n.originalEvent.target,i=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&a.addEventListener(t,e,{once:!0}),r?zp(a,i):a.dispatchEvent(i)}var Ko="focusScope.autoFocusOnMount",Qo="focusScope.autoFocusOnUnmount",sm={bubbles:!1,cancelable:!0},VO="FocusScope",Ga=b.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...o}=t,[s,l]=b.useState(null),c=mt(a),d=mt(i),_=b.useRef(null),p=Fe(e,f=>l(f)),m=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(r){let f=function(h){if(m.paused||!s)return;const v=h.target;s.contains(v)?_.current=v:Rn(_.current,{select:!0})},E=function(h){if(m.paused||!s)return;const v=h.relatedTarget;v!==null&&(s.contains(v)||Rn(_.current,{select:!0}))},S=function(h){if(document.activeElement===document.body)for(const C of h)C.removedNodes.length>0&&Rn(s)};document.addEventListener("focusin",f),document.addEventListener("focusout",E);const T=new MutationObserver(S);return s&&T.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",f),document.removeEventListener("focusout",E),T.disconnect()}}},[r,s,m.paused]),b.useEffect(()=>{if(s){dm.add(m);const f=document.activeElement;if(!s.contains(f)){const S=new CustomEvent(Ko,sm);s.addEventListener(Ko,c),s.dispatchEvent(S),S.defaultPrevented||(zO(jO(lm(s)),{select:!0}),document.activeElement===f&&Rn(s))}return()=>{s.removeEventListener(Ko,c),setTimeout(()=>{const S=new CustomEvent(Qo,sm);s.addEventListener(Qo,d),s.dispatchEvent(S),S.defaultPrevented||Rn(f??document.body,{select:!0}),s.removeEventListener(Qo,d),dm.remove(m)},0)}}},[s,c,d,m]);const g=b.useCallback(f=>{if(!n&&!r||m.paused)return;const E=f.key==="Tab"&&!f.altKey&&!f.ctrlKey&&!f.metaKey,S=document.activeElement;if(E&&S){const T=f.currentTarget,[h,v]=$O(T);h&&v?!f.shiftKey&&S===v?(f.preventDefault(),n&&Rn(h,{select:!0})):f.shiftKey&&S===h&&(f.preventDefault(),n&&Rn(v,{select:!0})):S===T&&f.preventDefault()}},[n,r,m.paused]);return u.jsx(Ie.div,{tabIndex:-1,...o,ref:p,onKeyDown:g})});Ga.displayName=VO;function zO(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(Rn(r,{select:e}),document.activeElement!==n)return}function $O(t){const e=lm(t),n=cm(e,t),r=cm(e.reverse(),t);return[n,r]}function lm(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const a=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||a?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function cm(t,e){for(const n of t)if(!WO(n,{upTo:e}))return n}function WO(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function KO(t){return t instanceof HTMLInputElement&&"select"in t}function Rn(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&KO(t)&&e&&t.select()}}var dm=QO();function QO(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=um(t,e),t.unshift(e)},remove(e){var n;t=um(t,e),(n=t[0])==null||n.resume()}}}function um(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function jO(t){return t.filter(e=>e.tagName!=="A")}var XO="Portal",Ya=b.forwardRef((t,e)=>{var s;const{container:n,...r}=t,[a,i]=b.useState(!1);_t(()=>i(!0),[]);const o=n||a&&((s=globalThis==null?void 0:globalThis.document)==null?void 0:s.body);return o?En.createPortal(u.jsx(Ie.div,{...r,ref:e}),o):null});Ya.displayName=XO;var jo=0;function Xo(){b.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??_m()),document.body.insertAdjacentElement("beforeend",t[1]??_m()),jo++,()=>{jo===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),jo--}},[])}function _m(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var nn=function(){return nn=Object.assign||function(e){for(var n,r=1,a=arguments.length;r<a;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},nn.apply(this,arguments)};function pm(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,r=Object.getOwnPropertySymbols(t);a<r.length;a++)e.indexOf(r[a])<0&&Object.prototype.propertyIsEnumerable.call(t,r[a])&&(n[r[a]]=t[r[a]]);return n}function ZO(t,e,n){if(n||arguments.length===2)for(var r=0,a=e.length,i;r<a;r++)(i||!(r in e))&&(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return t.concat(i||Array.prototype.slice.call(e))}typeof SuppressedError=="function"&&SuppressedError;var Ha="right-scroll-bar-position",qa="width-before-scroll-bar",JO="with-scroll-bars-hidden",ey="--removed-body-scroll-bar-size";function Zo(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function ty(t,e){var n=y.useState(function(){return{value:t,callback:e,facade:{get current(){return n.value},set current(r){var a=n.value;a!==r&&(n.value=r,n.callback(r,a))}}}})[0];return n.callback=e,n.facade}var ny=typeof window<"u"?b.useLayoutEffect:b.useEffect,mm=new WeakMap;function ry(t,e){var n=ty(null,function(r){return t.forEach(function(a){return Zo(a,r)})});return ny(function(){var r=mm.get(n);if(r){var a=new Set(r),i=new Set(t),o=n.current;a.forEach(function(s){i.has(s)||Zo(s,null)}),i.forEach(function(s){a.has(s)||Zo(s,o)})}mm.set(n,t)},[t]),n}function ay(t){return t}function iy(t,e){e===void 0&&(e=ay);var n=[],r=!1,a={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:t},useMedium:function(i){var o=e(i,r);return n.push(o),function(){n=n.filter(function(s){return s!==o})}},assignSyncMedium:function(i){for(r=!0;n.length;){var o=n;n=[],o.forEach(i)}n={push:function(s){return i(s)},filter:function(){return n}}},assignMedium:function(i){r=!0;var o=[];if(n.length){var s=n;n=[],s.forEach(i),o=n}var l=function(){var d=o;o=[],d.forEach(i)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(d){o.push(d),c()},filter:function(d){return o=o.filter(d),n}}}};return a}function oy(t){t===void 0&&(t={});var e=iy(null);return e.options=nn({async:!0,ssr:!1},t),e}var gm=function(t){var e=t.sideCar,n=pm(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=e.read();if(!r)throw new Error("Sidecar medium not found");return b.createElement(r,nn({},n))};gm.isSideCarExport=!0;function sy(t,e){return t.useMedium(e),gm}var Em=oy(),Jo=function(){},Va=b.forwardRef(function(t,e){var n=b.useRef(null),r=b.useState({onScrollCapture:Jo,onWheelCapture:Jo,onTouchMoveCapture:Jo}),a=r[0],i=r[1],o=t.forwardProps,s=t.children,l=t.className,c=t.removeScrollBar,d=t.enabled,_=t.shards,p=t.sideCar,m=t.noRelative,g=t.noIsolation,f=t.inert,E=t.allowPinchZoom,S=t.as,T=S===void 0?"div":S,h=t.gapMode,v=pm(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=p,R=ry([n,e]),N=nn(nn({},v),a);return b.createElement(b.Fragment,null,d&&b.createElement(C,{sideCar:Em,removeScrollBar:c,shards:_,noRelative:m,noIsolation:g,inert:f,setCallbacks:i,allowPinchZoom:!!E,lockRef:n,gapMode:h}),o?b.cloneElement(b.Children.only(s),nn(nn({},N),{ref:R})):b.createElement(T,nn({},N,{className:l,ref:R}),s))});Va.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Va.classNames={fullWidth:qa,zeroRight:Ha};var ly=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function cy(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=ly();return e&&t.setAttribute("nonce",e),t}function dy(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function uy(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var _y=function(){var t=0,e=null;return{add:function(n){t==0&&(e=cy())&&(dy(e,n),uy(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},py=function(){var t=_y();return function(e,n){b.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&n])}},fm=function(){var t=py(),e=function(n){var r=n.styles,a=n.dynamic;return t(r,a),null};return e},my={left:0,top:0,right:0,gap:0},es=function(t){return parseInt(t||"",10)||0},gy=function(t){var e=window.getComputedStyle(document.body),n=e[t==="padding"?"paddingLeft":"marginLeft"],r=e[t==="padding"?"paddingTop":"marginTop"],a=e[t==="padding"?"paddingRight":"marginRight"];return[es(n),es(r),es(a)]},Ey=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return my;var e=gy(t),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-n+e[2]-e[0])}},fy=fm(),ar="data-scroll-locked",Sy=function(t,e,n,r){var a=t.left,i=t.top,o=t.right,s=t.gap;return n===void 0&&(n="margin"),`
|
|
33
|
+
`)}const yv={messages:[],assemblingId:null,lastCheckpointId:null,toolIndex:{},lastBranch:null};function Iv(t,e){var n,r;switch(e.type){case"reset":return{messages:uo(((n=e.payload)==null?void 0:n.messages)??[]),assemblingId:null,lastCheckpointId:null,toolIndex:{},lastBranch:null};case"seed":return{...t,messages:uo(e.payload.messages)};case"prepend":{const a=uo(e.payload.messages);if(!a.length)return t;const i=new Set(t.messages.map(s=>s.id)),o=a.filter(s=>!i.has(s.id));return o.length?{...t,messages:[...o,...t.messages]}:t}case"user_message":{const a=e.payload.message;if(t.assemblingId){const i=t.messages.findIndex(o=>o.id===t.assemblingId&&o.role==="assistant");if(i>=0){const o=t.messages.slice(0,i),s=t.messages.slice(i);return{...t,messages:[...o,a,...s]}}}return{...t,messages:[...t.messages,a]}}case"event":{const a=e.payload.ev;if(a.type==="message_start"&&a.role==="assistant"){const i=a.id,o=wv(a.model),s={id:i,role:"assistant",name:o||void 0,model:a.model,createdAt:new Date().toISOString(),content:[]};return{...t,assemblingId:i,messages:[...t.messages,s]}}if(a.type==="token"){const i=t.assemblingId??_o(t.messages);return i?{...t,messages:Av(t.messages,i,a.content)}:t}if(a.type==="message_delta"){const i=t.assemblingId??_o(t.messages);return i?{...t,messages:H_(t.messages,i,a.delta)}:t}if(a.type==="message_end"){const i=t.assemblingId??_o(t.messages);if(!i)return{...t,assemblingId:null};const o=t.messages,s=o.findIndex(l=>l.id===i&&l.role==="assistant");if(s>=0&&!((r=o[s].content)==null?void 0:r.some(d=>{var _;return(d==null?void 0:d.type)==="text"&&((_=d.text)==null?void 0:_.trim())}))){const d=[...o.slice(0,s),...o.slice(s+1)];return{...t,assemblingId:null,messages:d}}return{...t,assemblingId:null}}if(a.type==="tool_start"){const i=`tool-${a.id}`,o={type:"tool_call",id:a.id,name:a.name,args:a.args},s={id:i,role:"tool",name:a.name,createdAt:new Date().toISOString(),content:[o]};return{...t,messages:[...t.messages,s],toolIndex:{...t.toolIndex,[a.id]:i}}}if(a.type==="tool_result"){const i=t.toolIndex[a.id]??`tool-${a.id}`,o={type:"tool_result",toolCallId:a.id,output:a.output,error:a.error},s=t.messages.find(d=>d.id===i),l={id:i,role:"tool",content:[o],createdAt:new Date().toISOString()},c=s?H_(t.messages,i,[o]):[...t.messages,l];return{...t,messages:c}}if(a.type==="checkpoint"){const i=Dv(t.messages,a.checkpointId);return{...t,lastCheckpointId:a.checkpointId,messages:i}}if(a.type==="branch"){const i=a.checkpointId??t.lastCheckpointId;return{...t,lastBranch:a,lastCheckpointId:i??null}}if(a.type==="error"){const i={id:`err-${Date.now()}`,role:"system",content:[{type:"text",text:`Error: ${a.message}`}],createdAt:new Date().toISOString()};return{...t,messages:[...t.messages,i]}}return t}default:return t}}function Y_(t=[]){const[e,n]=y.useReducer(Iv,{...yv,messages:t}),r=y.useCallback(i=>{n({type:"event",payload:{ev:i}})},[]),a=y.useMemo(()=>({reset:i=>n({type:"reset",payload:{messages:i}}),seed:i=>n({type:"seed",payload:{messages:i}}),prepend:i=>n({type:"prepend",payload:{messages:i}}),pushUser:i=>n({type:"user_message",payload:{message:i}}),onEvent:r}),[r]);return{state:e,dispatch:n,...a}}function uo(t){return t.filter(e=>{if(e.role!=="assistant")return!0;const n=(e.content||[]).some(a=>{var i;return a&&a.type==="text"&&((i=a.text)==null?void 0:i.trim())}),r=(e.content||[]).some(a=>a&&a.type==="image_url");return!!(n||r)})}function _o(t){for(let e=t.length-1;e>=0;e--)if(t[e].role==="assistant")return t[e].id;return null}function Av(t,e,n){return t.map(r=>{if(r.id!==e)return r;const a=r.content.slice(),i=a[a.length-1];return i&&i.type==="text"?i.text+=n:a.push({type:"text",text:n}),{...r,content:a}})}function H_(t,e,n){return t.map(r=>r.id===e?{...r,content:xv(r.content,n)}:r)}function xv(t,e){const n=t.slice();for(const r of e)if(r.type==="text"){const a=n[n.length-1];(a==null?void 0:a.type)==="text"?a.text+=r.text:n.push({type:"text",text:r.text})}else n.push(r);return n}function Dv(t,e){for(let n=t.length-1;n>=0;n--)if(t[n].role==="assistant"){const a={...t[n],checkpointId:e};return[...t.slice(0,n),a,...t.slice(n+1)]}return t}function wv(t){if(!t)return null;const e=t.split("/");return e[e.length-1]||null}function Mv(t,e){const n=t==null?void 0:t.checkpoints,r=Array.isArray(n)?n.slice():n?Object.values(n):[],a=o=>o&&typeof o=="object"&&typeof o.checkpointId=="string"&&typeof o.createdAt=="string",i=r.filter(a).map(o=>({checkpointId:o.checkpointId,checkpointNs:o.checkpointNs??"",createdAt:o.createdAt,messagesLen:o.messagesLen??0,preview:o.preview??"",role:o.role??null,parentId:o.parentId??null,editedMessageId:o.editedMessageId??null,branchLabel:o.branchLabel??null}));return{threadId:(t==null?void 0:t.threadId)??e??null,checkpoints:i}}async function po(t){return await new Promise((e,n)=>{const r=new FileReader;r.onload=()=>e(String(r.result)),r.onerror=a=>n(a),r.readAsDataURL(t)})}async function Lv(t){return await new Promise((e,n)=>{const r=new FileReader;r.onload=()=>{try{const a=r.result,i=new Uint8Array(a);let o="";const s=i.byteLength;for(let l=0;l<s;l++)o+=String.fromCharCode(i[l]);e(btoa(o))}catch(a){n(a)}},r.onerror=a=>n(a),r.readAsArrayBuffer(t)})}async function Pv(t,e,n){try{return await po(e)}catch{return null}}async function kv(t,e=[],n,r,a,i){const o=[],s=[];for(const l of e){let c=null;try{c=await Pv(t,l,i)}catch{c=null}if(l.type&&l.type.startsWith("image/"))if(c){const d={type:"image_url",url:c,mimeType:l.type,alt:l.name};o.push(d)}else try{const d=await po(l),_={type:"image_url",url:String(d),mimeType:l.type,alt:l.name};o.push(_)}catch{}else if(c){const d={type:"file",url:c,mimeType:l.type||void 0,name:l.name,size:l.size,sourceType:"base64"};o.push(d)}else try{const d=await po(l),_={type:"file",url:String(d),mimeType:l.type||void 0,name:l.name,size:l.size,sourceType:"base64"};o.push(_)}catch{}try{const d=await Lv(l);s.push({filename:l.name,data:d,mime_type:l.type||"application/octet-stream"})}catch{}}return{contentParts:o,filesInfo:s}}const q_=y.createContext(null);function Ar({children:t,apiConfig:e,onError:n,onThreadChange:r,initialThreadId:a=null,historyPageSize:i,autoLoadInitial:o=!0,enableFileAgentRouting:s=!1,fileAgentId:l="invoice_reader"}){const c=dn;y.useEffect(()=>{e&&c.updateConfig({baseUrl:e.baseUrl,authToken:e.apiKey})},[c,e]);const{isStreaming:d,error:_,stream:p,stop:m,setToken:g}=G_({baseUrl:c.baseUrl,token:null,headers:e==null?void 0:e.headers,streamPath:"/chat/runs/stream"}),[f,E]=y.useState(()=>typeof c.getAuthToken=="function"?c.getAuthToken():null);y.useEffect(()=>{g(typeof c.getAuthToken=="function"?c.getAuthToken():null);const K=c.onTokenChange(ie=>{E(ie),g(ie)});return()=>{K()}},[c,g]);const S=y.useCallback(K=>{c.setAuthToken(K)},[c]),{state:T,seed:h,prepend:v,pushUser:C,onEvent:R,reset:N}=Y_(),O=i&&i>0?i:6,[D,w]=y.useState(!1),[L,H]=y.useState(!1),[z,P]=y.useState(null),[G,I]=y.useState(void 0),U=y.useCallback((K,ie)=>{const he=Array.isArray(K==null?void 0:K.messages)?K.messages:[];ie==="replace"?h(he):ie==="prepend"&&he.length&&v(he),P((K==null?void 0:K.nextCursor)??null),w(!!(K!=null&&K.hasMore)),I(nt=>(K==null?void 0:K.checkpointId)??nt??void 0)},[h,v]),[M,k]=y.useState([]),[Y,W]=y.useState(null),re=y.useCallback(async()=>{const K=await c.listThreads();k(K)},[c]),[q,j]=y.useState(!1),se=y.useCallback(async K=>{const ie=(K==null?void 0:K.maxAttempts)??5,he=(K==null?void 0:K.baseDelayMs)??500,nt=(K==null?void 0:K.timeoutMs)??2e3;if(!c.baseUrl)return!1;const Ze=c.baseUrl.replace(/\/+$/,""),at=["/health","/api/health","/","/api/v2/health","/api/v2/chat/health"],Ke=async ae=>{try{const be=new AbortController,Ce=setTimeout(()=>be.abort(),nt),Be=await fetch(ae,{method:"GET",signal:be.signal});return clearTimeout(Ce),Be.ok}catch{return!1}},Z=async ae=>{try{const be=new AbortController,Ce=setTimeout(()=>be.abort(),nt),Be=await fetch(ae,{method:"HEAD",signal:be.signal});return clearTimeout(Ce),Be.ok}catch{return!1}};for(let ae=0;ae<ie;ae++){console.debug(`[ChatProvider] health-check attempt ${ae+1}/${ie}`);for(const Ce of at){let Be=Ce;Ze.endsWith("/api")&&Ce.startsWith("/api")&&(Be=Ce.replace(/^\/api/,"")||"/");const it=Be==="/"?Ze+"/":Ze+Be;if(console.debug(`[ChatProvider] checking ${it}`),await Ke(it)||Ce==="/"&&await Z(Ze+"/"))return j(!0),!0}const be=he*Math.pow(2,ae);await new Promise(Ce=>setTimeout(Ce,be))}return j(!1),!1},[c.baseUrl]);y.useEffect(()=>{let K=!0;if(!c.baseUrl){console.debug("[ChatProvider] skipping initial refreshThreads: api.baseUrl not configured");return}return(async()=>{try{const ie=await se();if(!K)return;ie?re().catch(()=>{}):console.warn("[ChatProvider] backend health-check failed — skipping initial loads")}catch{}})(),()=>{K=!1}},[re,c.baseUrl,se]),y.useEffect(()=>{r==null||r(Y)},[Y,r]);const Ee=y.useRef(null);y.useEffect(()=>{if(a&&o){if(!c.baseUrl){console.debug("[ChatProvider] skipping initial load: api.baseUrl not configured");return}if(!q){console.debug("[ChatProvider] deferring initial load until backend health-check passes");return}Ee.current!==a&&(Ee.current=a,F(a).catch(()=>{}))}},[a,o,c.baseUrl,q]);const V=y.useRef(null),F=y.useCallback(async(K,ie,he)=>{if(!c.baseUrl){console.debug("[ChatProvider] skipping loadThread: api.baseUrl not configured");return}if(V.current!==K){V.current=K;try{w(!1),P(null),I(void 0);const nt=await c.getMessages({threadId:K,checkpointId:ie,checkpointNs:he,limit:O});W(K),U(nt,"replace")}finally{V.current=null}}},[c,U]),Q=y.useCallback(async K=>{const ie=await c.listCheckpoints(K);return Mv(ie,K)},[c]),te=y.useCallback(async K=>{if(!Y)throw new Error("No active thread");w(!1),P(null),I(void 0);const ie=await c.getMessages({threadId:Y,checkpointId:K,limit:O});U(ie,"replace")},[c,Y,U,O]),ce=y.useCallback(async()=>{if(!Y)throw new Error("No active thread");await F(Y)},[Y,F]),oe=y.useRef(!1);y.useEffect(()=>{const K=oe.current;if(oe.current=d,K&&!d&&Y){const ie=T.lastCheckpointId??void 0;(async()=>{try{const he=await c.getMessages({threadId:Y,checkpointId:ie,limit:O});U(he,"replace")}catch{}try{await re()}catch{}})()}},[d,Y,T.lastCheckpointId,c,U,re]);const xe=y.useCallback(async K=>{const ie=await c.createThread(K);return await re(),await F(ie.threadId),ie.threadId},[c,re,F]),Ve=y.useCallback(async K=>{await c.deleteThread(K),await re(),Y===K&&(W(null),N([]),w(!1),P(null),I(void 0))},[c,re,Y,N]),Le=y.useCallback(async(K,ie)=>{await c.updateThread(K,ie),await re()},[c,re]),fe=y.useCallback(async(K,ie)=>{var Xt;const he=(ie==null?void 0:ie.attachments)||[],{contentParts:nt,filesInfo:Ze}=await kv(c,he,e==null?void 0:e.uploadPath,s,l,Y),at=[];K&&at.push({type:"text",text:K});for(const Je of nt)at.push(Je);const Ke={id:((Xt=crypto.randomUUID)==null?void 0:Xt.call(crypto))||`user-${Date.now()}`,role:"user",content:at,createdAt:new Date().toISOString(),checkpointId:(ie==null?void 0:ie.checkpointId)??T.lastCheckpointId??void 0};C(Ke);const Z={...Ke,content:Ke.content.filter(Je=>Je.type==="text"||Je.type==="image_url"||Je.type==="file")},ae={...(ie==null?void 0:ie.payloadExtras)??{}},be=!!ae.edit,Ce=ae.originalMessageId,Be=typeof Ce=="string"?Ce:void 0,it=he&&he.length>0,Mt={...Y?{threadId:Y}:{},payload:{messages:[Z],attachments:Ke.content.filter(Je=>Je.type==="file").map(Je=>({type:"file",url:Je.url,mimeType:Je.mimeType,name:Je.name,size:Je.size})),files_info:Ze,...s&&it&&l?{active_agent:l}:{},...ae},checkpointId:(ie==null?void 0:ie.checkpointId)??T.lastCheckpointId??void 0,checkpointNs:ie==null?void 0:ie.checkpointNs,nodeFilter:ie==null?void 0:ie.nodeFilter,config:ie==null?void 0:ie.config,edit:be,originalMessageId:Be};p(Mt,Je=>R(Je),{onError:Je=>console.warn("stream error",Je),onOpen:({threadId:Je,created:Dn})=>{!Y&&Je&&(W(Je),Dn&&re().catch(()=>{}))}})},[Y,C,p,R,T.lastCheckpointId,c,e==null?void 0:e.uploadPath,re,W,s,l]),ke=y.useCallback(async K=>{if(!Y)throw new Error("No active thread");if(L||!D)return;const ie=z;if(ie){H(!0);try{const he=await c.getMessages({threadId:Y,checkpointId:G,limit:(K==null?void 0:K.limit)??O,beforeId:ie});U(he,"prepend")}finally{H(!1)}}},[c,Y,G,z,D,L,U]),ee={baseUrl:c.baseUrl,token:f,setToken:S,api:c,threads:M,currentThreadId:Y,setCurrentThreadId:W,messages:T.messages,isStreaming:d,error:_,lastCheckpointId:T.lastCheckpointId,streamingAssistantId:T.assemblingId,hasMoreHistory:D,isLoadingHistory:L,loadOlderMessages:ke,historyPageSize:O,listCheckpoints:Q,navigateToCheckpoint:te,returnToLatest:ce,refreshThreads:re,createThread:xe,deleteThread:Ve,renameThread:Le,loadThread:F,send:fe,stop:m};return u.jsx(q_.Provider,{value:ee,children:t})}function ha(){const t=y.useContext(q_);if(!t)throw new Error("useChat must be used within ChatProvider");return t}const Ca=0,fn=1,tr=2,V_=4;function z_(t){return()=>t}function Uv(t){t()}function $_(t,e){return n=>t(e(n))}function W_(t,e){return()=>t(e)}function Fv(t,e){return n=>t(e,n)}function mo(t){return t!==void 0}function Bv(...t){return()=>{t.map(Uv)}}function nr(){}function Ra(t,e){return e(t),t}function Gv(t,e){return e(t)}function et(...t){return t}function We(t,e){return t(fn,e)}function Me(t,e){t(Ca,e)}function go(t){t(tr)}function lt(t){return t(V_)}function Te(t,e){return We(t,Fv(e,Ca))}function qt(t,e){const n=t(fn,r=>{n(),e(r)});return n}function K_(t){let e,n;return r=>a=>{e=a,n&&clearTimeout(n),n=setTimeout(()=>{r(e)},t)}}function Q_(t,e){return t===e}function tt(t=Q_){let e;return n=>r=>{t(e,r)||(e=r,n(r))}}function ye(t){return e=>n=>{t(n)&&e(n)}}function pe(t){return e=>$_(e,t)}function Jt(t){return e=>()=>{e(t)}}function X(t,...e){const n=Yv(...e);return(r,a)=>{switch(r){case tr:go(t);return;case fn:return We(t,n(a))}}}function en(t,e){return n=>r=>{n(e=t(e,r))}}function Pn(t){return e=>n=>{t>0?t--:e(n)}}function un(t){let e=null,n;return r=>a=>{e=a,!n&&(n=setTimeout(()=>{n=void 0,r(e)},t))}}function Pe(...t){const e=new Array(t.length);let n=0,r=null;const a=Math.pow(2,t.length)-1;return t.forEach((i,o)=>{const s=Math.pow(2,o);We(i,l=>{const c=n;n=n|s,e[o]=l,c!==a&&n===a&&r&&(r(),r=null)})}),i=>o=>{const s=()=>{i([o].concat(e))};n===a?s():r=s}}function Yv(...t){return e=>t.reduceRight(Gv,e)}function Hv(t){let e,n;const r=()=>e==null?void 0:e();return function(a,i){switch(a){case fn:return i?n===i?void 0:(r(),n=i,e=We(t,i),e):(r(),nr);case tr:r(),n=null;return}}}function ne(t){let e=t;const n=Ye();return(r,a)=>{switch(r){case Ca:e=a;break;case fn:{a(e);break}case V_:return e}return n(r,a)}}function Et(t,e){return Ra(ne(e),n=>Te(t,n))}function Ye(){const t=[];return(e,n)=>{switch(e){case Ca:t.slice().forEach(r=>{r(n)});return;case tr:t.splice(0,t.length);return;case fn:return t.push(n),()=>{const r=t.indexOf(n);r>-1&&t.splice(r,1)}}}}function At(t){return Ra(Ye(),e=>Te(t,e))}function qe(t,e=[],{singleton:n}={singleton:!0}){return{constructor:t,dependencies:e,id:qv(),singleton:n}}const qv=()=>Symbol();function Vv(t){const e=new Map,n=({constructor:r,dependencies:a,id:i,singleton:o})=>{if(o&&e.has(i))return e.get(i);const s=r(a.map(l=>n(l)));return o&&e.set(i,s),s};return n(t)}function dt(...t){const e=Ye(),n=new Array(t.length);let r=0;const a=Math.pow(2,t.length)-1;return t.forEach((i,o)=>{const s=Math.pow(2,o);We(i,l=>{n[o]=l,r=r|s,r===a&&Me(e,n)})}),function(i,o){switch(i){case tr:{go(e);return}case fn:return r===a&&o(n),We(e,o)}}}function Ne(t,e=Q_){return X(t,tt(e))}function Eo(...t){return function(e,n){switch(e){case tr:return;case fn:return Bv(...t.map(r=>We(r,n)))}}}var vt=(t=>(t[t.DEBUG=0]="DEBUG",t[t.INFO=1]="INFO",t[t.WARN=2]="WARN",t[t.ERROR=3]="ERROR",t))(vt||{});const zv={0:"debug",3:"error",1:"log",2:"warn"},$v=()=>typeof globalThis>"u"?window:globalThis,Sn=qe(()=>{const t=ne(3);return{log:ne((e,n,r=1)=>{var a;const i=(a=$v().VIRTUOSO_LOG_LEVEL)!=null?a:lt(t);r>=i&&console[zv[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",e,n)}),logLevel:t}},[],{singleton:!0});function kn(t,e,n){return fo(t,e,n).callbackRef}function fo(t,e,n){const r=y.useRef(null);let a=o=>{};const i=y.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(o=>{const s=()=>{const l=o[0].target;l.offsetParent!==null&&t(l)};n?s():requestAnimationFrame(s)}):null,[t,n]);return a=o=>{o&&e?(i==null||i.observe(o),r.current=o):(r.current&&(i==null||i.unobserve(r.current)),r.current=null)},{callbackRef:a,ref:r}}function Wv(t,e,n,r,a,i,o,s,l){const c=y.useCallback(d=>{const _=Kv(d.children,e,s?"offsetWidth":"offsetHeight",a);let p=d.parentElement;for(;!p.dataset.virtuosoScroller;)p=p.parentElement;const m=p.lastElementChild.dataset.viewportType==="window";let g;m&&(g=p.ownerDocument.defaultView);const f=o?s?o.scrollLeft:o.scrollTop:m?s?g.scrollX||g.document.documentElement.scrollLeft:g.scrollY||g.document.documentElement.scrollTop:s?p.scrollLeft:p.scrollTop,E=o?s?o.scrollWidth:o.scrollHeight:m?s?g.document.documentElement.scrollWidth:g.document.documentElement.scrollHeight:s?p.scrollWidth:p.scrollHeight,S=o?s?o.offsetWidth:o.offsetHeight:m?s?g.innerWidth:g.innerHeight:s?p.offsetWidth:p.offsetHeight;r({scrollHeight:E,scrollTop:Math.max(f,0),viewportHeight:S}),i==null||i(s?j_("column-gap",getComputedStyle(d).columnGap,a):j_("row-gap",getComputedStyle(d).rowGap,a)),_!==null&&t(_)},[t,e,a,i,o,r,s]);return fo(c,n,l)}function Kv(t,e,n,r){const a=t.length;if(a===0)return null;const i=[];for(let o=0;o<a;o++){const s=t.item(o);if(s.dataset.index===void 0)continue;const l=parseInt(s.dataset.index),c=parseFloat(s.dataset.knownSize),d=e(s,n);if(d===0&&r("Zero-sized element, this should not happen",{child:s},vt.ERROR),d===c)continue;const _=i[i.length-1];i.length===0||_.size!==d||_.endIndex!==l-1?i.push({endIndex:l,size:d,startIndex:l}):i[i.length-1].endIndex++}return i}function j_(t,e,n){return e!=="normal"&&!(e!=null&&e.endsWith("px"))&&n(`${t} was not resolved to pixel value correctly`,e,vt.WARN),e==="normal"?0:parseInt(e??"0",10)}function X_(t,e,n){const r=y.useRef(null),a=y.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const c=l.getBoundingClientRect(),d=c.width;let _,p;if(e){const m=e.getBoundingClientRect(),g=c.top-m.top;p=m.height-Math.max(0,g),_=g+e.scrollTop}else{const m=o.current.ownerDocument.defaultView;p=m.innerHeight-Math.max(0,c.top),_=c.top+m.scrollY}r.current={offsetTop:_,visibleHeight:p,visibleWidth:d},t(r.current)},[t,e]),{callbackRef:i,ref:o}=fo(a,!0,n),s=y.useCallback(()=>{a(o.current)},[a,o]);return y.useEffect(()=>{var l;if(e){e.addEventListener("scroll",s);const c=new ResizeObserver(()=>{requestAnimationFrame(s)});return c.observe(e),()=>{e.removeEventListener("scroll",s),c.unobserve(e)}}else{const c=(l=o.current)==null?void 0:l.ownerDocument.defaultView;return c==null||c.addEventListener("scroll",s),c==null||c.addEventListener("resize",s),()=>{c==null||c.removeEventListener("scroll",s),c==null||c.removeEventListener("resize",s)}}},[s,e,o]),i}const Tt=qe(()=>{const t=Ye(),e=Ye(),n=ne(0),r=Ye(),a=ne(0),i=Ye(),o=Ye(),s=ne(0),l=ne(0),c=ne(0),d=ne(0),_=Ye(),p=Ye(),m=ne(!1),g=ne(!1),f=ne(!1);return Te(X(t,pe(({scrollTop:E})=>E)),e),Te(X(t,pe(({scrollHeight:E})=>E)),o),Te(e,a),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:d,headerHeight:s,horizontalDirection:g,scrollBy:p,scrollContainerState:t,scrollHeight:o,scrollingInProgress:m,scrollTo:_,scrollTop:e,skipAnimationFrameInResizeObserver:f,smoothScrollTargetReached:r,statefulScrollTop:a,viewportHeight:i}},[],{singleton:!0}),xr={lvl:0};function Z_(t,e){const n=t.length;if(n===0)return[];let{index:r,value:a}=e(t[0]);const i=[];for(let o=1;o<n;o++){const{index:s,value:l}=e(t[o]);i.push({end:s-1,start:r,value:a}),r=s,a=l}return i.push({end:1/0,start:r,value:a}),i}function je(t){return t===xr}function Dr(t,e){if(!je(t))return e===t.k?t.v:e<t.k?Dr(t.l,e):Dr(t.r,e)}function Vt(t,e,n="k"){if(je(t))return[-1/0,void 0];if(Number(t[n])===e)return[t.k,t.v];if(Number(t[n])<e){const r=Vt(t.r,e,n);return r[0]===-1/0?[t.k,t.v]:r}return Vt(t.l,e,n)}function xt(t,e,n){return je(t)?tp(e,n,1):e===t.k?ut(t,{k:e,v:n}):e<t.k?np(ut(t,{l:xt(t.l,e,n)})):np(ut(t,{r:xt(t.r,e,n)}))}function rr(){return xr}function va(t,e,n){if(je(t))return[];const r=Vt(t,e)[0];return Qv(bo(t,r,n))}function So(t,e){if(je(t))return xr;const{k:n,l:r,r:a}=t;if(e===n){if(je(r))return a;if(je(a))return r;{const[i,o]=ep(r);return Na(ut(t,{k:i,l:J_(r),v:o}))}}else return e<n?Na(ut(t,{l:So(r,e)})):Na(ut(t,{r:So(a,e)}))}function Un(t){return je(t)?[]:[...Un(t.l),{k:t.k,v:t.v},...Un(t.r)]}function bo(t,e,n){if(je(t))return[];const{k:r,l:a,r:i,v:o}=t;let s=[];return r>e&&(s=s.concat(bo(a,e,n))),r>=e&&r<=n&&s.push({k:r,v:o}),r<=n&&(s=s.concat(bo(i,e,n))),s}function Na(t){const{l:e,lvl:n,r}=t;if(r.lvl>=n-1&&e.lvl>=n-1)return t;if(n>r.lvl+1){if(To(e))return rp(ut(t,{lvl:n-1}));if(!je(e)&&!je(e.r))return ut(e.r,{l:ut(e,{r:e.r.l}),lvl:n,r:ut(t,{l:e.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}else{if(To(t))return ho(ut(t,{lvl:n-1}));if(!je(r)&&!je(r.l)){const a=r.l,i=To(a)?r.lvl-1:r.lvl;return ut(a,{l:ut(t,{lvl:n-1,r:a.l}),lvl:a.lvl+1,r:ho(ut(r,{l:a.r,lvl:i}))})}else throw new Error("Unexpected empty nodes")}}function ut(t,e){return tp(e.k!==void 0?e.k:t.k,e.v!==void 0?e.v:t.v,e.lvl!==void 0?e.lvl:t.lvl,e.l!==void 0?e.l:t.l,e.r!==void 0?e.r:t.r)}function J_(t){return je(t.r)?t.l:Na(ut(t,{r:J_(t.r)}))}function To(t){return je(t)||t.lvl>t.r.lvl}function ep(t){return je(t.r)?[t.k,t.v]:ep(t.r)}function tp(t,e,n,r=xr,a=xr){return{k:t,l:r,lvl:n,r:a,v:e}}function np(t){return ho(rp(t))}function rp(t){const{l:e}=t;return!je(e)&&e.lvl===t.lvl?ut(e,{r:ut(t,{l:e.r})}):t}function ho(t){const{lvl:e,r:n}=t;return!je(n)&&!je(n.r)&&n.lvl===e&&n.r.lvl===e?ut(n,{l:ut(t,{r:n.l}),lvl:e+1}):t}function Qv(t){return Z_(t,({k:e,v:n})=>({index:e,value:n}))}function ap(t,e){return!!(t&&t.startIndex===e.startIndex&&t.endIndex===e.endIndex)}function wr(t,e){return!!(t&&t[0]===e[0]&&t[1]===e[1])}const Co=qe(()=>({recalcInProgress:ne(!1)}),[],{singleton:!0});function ip(t,e,n){return t[Oa(t,e,n)]}function Oa(t,e,n,r=0){let a=t.length-1;for(;r<=a;){const i=Math.floor((r+a)/2),o=t[i],s=n(o,e);if(s===0)return i;if(s===-1){if(a-r<2)return i-1;a=i-1}else{if(a===r)return i;r=i+1}}throw new Error(`Failed binary finding record in array - ${t.join(",")}, searched for ${e}`)}function jv(t,e,n,r){const a=Oa(t,e,r),i=Oa(t,n,r,a);return t.slice(a,i+1)}function bn(t,e){return Math.round(t.getBoundingClientRect()[e])}function ya(t){return!je(t.groupOffsetTree)}function Ro({index:t},e){return e===t?0:e<t?-1:1}function Xv(){return{groupIndices:[],groupOffsetTree:rr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:rr()}}function Zv(t,e){let n=je(t)?0:1/0;for(const r of e){const{endIndex:a,size:i,startIndex:o}=r;if(n=Math.min(n,o),je(t)){t=xt(t,0,i);continue}const s=va(t,o-1,a+1);if(s.some(iN(r)))continue;let l=!1,c=!1;for(const{end:d,start:_,value:p}of s)l?(a>=_||i===p)&&(t=So(t,_)):(c=p!==i,l=!0),d>a&&a>=_&&p!==i&&(t=xt(t,a+1,p));c&&(t=xt(t,o,i))}return[t,n]}function Jv(t){return typeof t.groupIndex<"u"}function eN({offset:t},e){return e===t?0:e<t?-1:1}function Mr(t,e,n){if(e.length===0)return 0;const{index:r,offset:a,size:i}=ip(e,t,Ro),o=t-r,s=i*o+(o-1)*n+a;return s>0?s+n:s}function op(t,e){if(!ya(e))return t;let n=0;for(;e.groupIndices[n]<=t+n;)n++;return t+n}function sp(t,e,n){if(Jv(t))return e.groupIndices[t.groupIndex]+1;{const r=t.index==="LAST"?n:t.index;let a=op(r,e);return a=Math.max(0,a,Math.min(n,a)),a}}function tN(t,e,n,r=0){return r>0&&(e=Math.max(e,ip(t,r,Ro).offset)),Z_(jv(t,e,n,eN),aN)}function nN(t,[e,n,r,a]){e.length>0&&r("received item sizes",e,vt.DEBUG);const i=t.sizeTree;let o=i,s=0;if(n.length>0&&je(i)&&e.length===2){const p=e[0].size,m=e[1].size;o=n.reduce((g,f)=>xt(xt(g,f,p),f+1,m),o)}else[o,s]=Zv(o,e);if(o===i)return t;const{lastIndex:l,lastOffset:c,lastSize:d,offsetTree:_}=vo(t.offsetTree,s,o,a);return{groupIndices:n,groupOffsetTree:n.reduce((p,m)=>xt(p,m,Mr(m,_,a)),rr()),lastIndex:l,lastOffset:c,lastSize:d,offsetTree:_,sizeTree:o}}function rN(t){return Un(t).map(({k:e,v:n},r,a)=>{const i=a[r+1];return{endIndex:i?i.k-1:1/0,size:n,startIndex:e}})}function lp(t,e){let n=0,r=0;for(;n<t;)n+=e[r+1]-e[r]-1,r++;return r-(n===t?0:1)}function vo(t,e,n,r){let a=t,i=0,o=0,s=0,l=0;if(e!==0){l=Oa(a,e-1,Ro),s=a[l].offset;const c=Vt(n,e-1);i=c[0],o=c[1],a.length&&a[l].size===Vt(n,e)[1]&&(l-=1),a=a.slice(0,l+1)}else a=[];for(const{start:c,value:d}of va(n,e,1/0)){const _=c-i,p=_*o+s+_*r;a.push({index:c,offset:p,size:d}),i=c,s=p,o=d}return{lastIndex:i,lastOffset:s,lastSize:o,offsetTree:a}}function aN(t){return{index:t.index,value:t}}function iN(t){const{endIndex:e,size:n,startIndex:r}=t;return a=>a.start===r&&(a.end===e||a.end===1/0)&&a.value===n}const oN={offsetHeight:"height",offsetWidth:"width"},tn=qe(([{log:t},{recalcInProgress:e}])=>{const n=Ye(),r=Ye(),a=Et(r,0),i=Ye(),o=Ye(),s=ne(0),l=ne([]),c=ne(void 0),d=ne(void 0),_=ne((C,R)=>bn(C,oN[R])),p=ne(void 0),m=ne(0),g=Xv(),f=Et(X(n,Pe(l,t,m),en(nN,g),tt()),g),E=Et(X(l,tt(),en((C,R)=>({current:R,prev:C.current}),{current:[],prev:[]}),pe(({prev:C})=>C)),[]);Te(X(l,ye(C=>C.length>0),Pe(f,m),pe(([C,R,N])=>{const O=C.reduce((D,w,L)=>xt(D,w,Mr(w,R.offsetTree,N)||L),rr());return{...R,groupIndices:C,groupOffsetTree:O}})),f),Te(X(r,Pe(f),ye(([C,{lastIndex:R}])=>C<R),pe(([C,{lastIndex:R,lastSize:N}])=>[{endIndex:R,size:N,startIndex:C}])),n),Te(c,d);const S=Et(X(c,pe(C=>C===void 0)),!0);Te(X(d,ye(C=>C!==void 0&&je(lt(f).sizeTree)),pe(C=>[{endIndex:0,size:C,startIndex:0}])),n);const T=At(X(n,Pe(f),en(({sizes:C},[R,N])=>({changed:N!==C,sizes:N}),{changed:!1,sizes:g}),pe(C=>C.changed)));We(X(s,en((C,R)=>({diff:C.prev-R,prev:R}),{diff:0,prev:0}),pe(C=>C.diff)),C=>{const{groupIndices:R}=lt(f);if(C>0)Me(e,!0),Me(i,C+lp(C,R));else if(C<0){const N=lt(E);N.length>0&&(C-=lp(-C,N)),Me(o,C)}}),We(X(s,Pe(t)),([C,R])=>{C<0&&R("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:s},vt.ERROR)});const h=At(i);Te(X(i,Pe(f),pe(([C,R])=>{const N=R.groupIndices.length>0,O=[],D=R.lastSize;if(N){const w=Dr(R.sizeTree,0);let L=0,H=0;for(;L<C;){const P=R.groupIndices[H],G=R.groupIndices.length===H+1?1/0:R.groupIndices[H+1]-P-1;O.push({endIndex:P,size:w,startIndex:P}),O.push({endIndex:P+1+G-1,size:D,startIndex:P+1}),H++,L+=G+1}const z=Un(R.sizeTree);return L!==C&&z.shift(),z.reduce((P,{k:G,v:I})=>{let U=P.ranges;return P.prevSize!==0&&(U=[...P.ranges,{endIndex:G+C-1,size:P.prevSize,startIndex:P.prevIndex}]),{prevIndex:G+C,prevSize:I,ranges:U}},{prevIndex:C,prevSize:0,ranges:O}).ranges}return Un(R.sizeTree).reduce((w,{k:L,v:H})=>({prevIndex:L+C,prevSize:H,ranges:[...w.ranges,{endIndex:L+C-1,size:w.prevSize,startIndex:w.prevIndex}]}),{prevIndex:0,prevSize:D,ranges:[]}).ranges})),n);const v=At(X(o,Pe(f,m),pe(([C,{offsetTree:R},N])=>{const O=-C;return Mr(O,R,N)})));return Te(X(o,Pe(f,m),pe(([C,R,N])=>{if(R.groupIndices.length>0){if(je(R.sizeTree))return R;let O=rr();const D=lt(E);let w=0,L=0,H=0;for(;w<-C;){H=D[L];const z=D[L+1]-H-1;L++,w+=z+1}if(O=Un(R.sizeTree).reduce((z,{k:P,v:G})=>xt(z,Math.max(0,P+C),G),O),w!==-C){const z=Dr(R.sizeTree,H);O=xt(O,0,z);const P=Vt(R.sizeTree,-C+1)[1];O=xt(O,1,P)}return{...R,sizeTree:O,...vo(R.offsetTree,0,O,N)}}else{const O=Un(R.sizeTree).reduce((D,{k:w,v:L})=>xt(D,Math.max(0,w+C),L),rr());return{...R,sizeTree:O,...vo(R.offsetTree,0,O,N)}}})),f),{beforeUnshiftWith:h,data:p,defaultItemSize:d,firstItemIndex:s,fixedItemSize:c,gap:m,groupIndices:l,itemSize:_,listRefresh:T,shiftWith:o,shiftWithOffset:v,sizeRanges:n,sizes:f,statefulTotalCount:a,totalCount:r,trackItemSizes:S,unshiftWith:i}},et(Sn,Co),{singleton:!0});function sN(t){return t.reduce((e,n)=>(e.groupIndices.push(e.totalCount),e.totalCount+=n+1,e),{groupIndices:[],totalCount:0})}const cp=qe(([{groupIndices:t,sizes:e,totalCount:n},{headerHeight:r,scrollTop:a}])=>{const i=Ye(),o=Ye(),s=At(X(i,pe(sN)));return Te(X(s,pe(l=>l.totalCount)),n),Te(X(s,pe(l=>l.groupIndices)),t),Te(X(dt(a,e,r),ye(([l,c])=>ya(c)),pe(([l,c,d])=>Vt(c.groupOffsetTree,Math.max(l-d,0),"v")[0]),tt(),pe(l=>[l])),o),{groupCounts:i,topItemsIndexes:o}},et(tn,Tt)),Tn=qe(([{log:t}])=>{const e=ne(!1),n=At(X(e,ye(r=>r),tt()));return We(e,r=>{r&<(t)("props updated",{},vt.DEBUG)}),{didMount:n,propsReady:e}},et(Sn),{singleton:!0}),lN=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function dp(t){const e=typeof t=="number"?{index:t}:t;return e.align||(e.align="start"),(!e.behavior||!lN)&&(e.behavior="auto"),e.offset||(e.offset=0),e}const Lr=qe(([{gap:t,listRefresh:e,sizes:n,totalCount:r},{fixedFooterHeight:a,fixedHeaderHeight:i,footerHeight:o,headerHeight:s,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:d,viewportHeight:_},{log:p}])=>{const m=Ye(),g=Ye(),f=ne(0);let E=null,S=null,T=null;function h(){E&&(E(),E=null),T&&(T(),T=null),S&&(clearTimeout(S),S=null),Me(l,!1)}return Te(X(m,Pe(n,_,r,f,s,o,p),Pe(t,i,a),pe(([[v,C,R,N,O,D,w,L],H,z,P])=>{const G=dp(v),{align:I,behavior:U,offset:M}=G,k=N-1,Y=sp(G,C,k);let W=Mr(Y,C.offsetTree,H)+D;I==="end"?(W+=z+Vt(C.sizeTree,Y)[1]-R+P,Y===k&&(W+=w)):I==="center"?W+=(z+Vt(C.sizeTree,Y)[1]-R+P)/2:W-=O,M&&(W+=M);const re=q=>{h(),q?(L("retrying to scroll to",{location:v},vt.DEBUG),Me(m,v)):(Me(g,!0),L("list did not change, scroll successful",{},vt.DEBUG))};if(h(),U==="smooth"){let q=!1;T=We(e,j=>{q=q||j}),E=qt(d,()=>{re(q)})}else E=qt(X(e,cN(150)),re);return S=setTimeout(()=>{h()},1200),Me(l,!0),L("scrolling from index to",{behavior:U,index:Y,top:W},vt.DEBUG),{behavior:U,top:W}})),c),{scrollTargetReached:g,scrollToIndex:m,topListHeight:f}},et(tn,Tt,Sn),{singleton:!0});function cN(t){return e=>{const n=setTimeout(()=>{e(!1)},t);return r=>{r&&(e(!0),clearTimeout(n))}}}function No(t,e){t==0?e():requestAnimationFrame(()=>{No(t-1,e)})}function Oo(t,e){const n=e-1;return typeof t=="number"?t:t.index==="LAST"?n:t.index}const Pr=qe(([{defaultItemSize:t,listRefresh:e,sizes:n},{scrollTop:r},{scrollTargetReached:a,scrollToIndex:i},{didMount:o}])=>{const s=ne(!0),l=ne(0),c=ne(!0);return Te(X(o,Pe(l),ye(([d,_])=>!!_),Jt(!1)),s),Te(X(o,Pe(l),ye(([d,_])=>!!_),Jt(!1)),c),We(X(dt(e,o),Pe(s,n,t,c),ye(([[,d],_,{sizeTree:p},m,g])=>d&&(!je(p)||mo(m))&&!_&&!g),Pe(l)),([,d])=>{qt(a,()=>{Me(c,!0)}),No(4,()=>{qt(r,()=>{Me(s,!0)}),Me(i,d)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:s}},et(tn,Tt,Lr,Tn),{singleton:!0});function up(t,e){return Math.abs(t-e)<1.01}const kr="up",Ur="down",dN="none",uN={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},_N=0,Fr=qe(([{footerHeight:t,headerHeight:e,scrollBy:n,scrollContainerState:r,scrollTop:a,viewportHeight:i}])=>{const o=ne(!1),s=ne(!0),l=Ye(),c=Ye(),d=ne(4),_=ne(_N),p=Et(X(Eo(X(Ne(a),Pn(1),Jt(!0)),X(Ne(a),Pn(1),Jt(!1),K_(100))),tt()),!1),m=Et(X(Eo(X(n,Jt(!0)),X(n,Jt(!1),K_(200))),tt()),!1);Te(X(dt(Ne(a),Ne(_)),pe(([T,h])=>T<=h),tt()),s),Te(X(s,un(50)),c);const g=At(X(dt(r,Ne(i),Ne(e),Ne(t),Ne(d)),en((T,[{scrollHeight:h,scrollTop:v},C,R,N,O])=>{const D=v+C-h>-O,w={scrollHeight:h,scrollTop:v,viewportHeight:C};if(D){let H,z;return v>T.state.scrollTop?(H="SCROLLED_DOWN",z=T.state.scrollTop-v):(H="SIZE_DECREASED",z=T.state.scrollTop-v||T.scrollTopDelta),{atBottom:!0,atBottomBecause:H,scrollTopDelta:z,state:w}}let L;return w.scrollHeight>T.state.scrollHeight?L="SIZE_INCREASED":C<T.state.viewportHeight?L="VIEWPORT_HEIGHT_DECREASING":v<T.state.scrollTop?L="SCROLLING_UPWARDS":L="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:L,state:w}},uN),tt((T,h)=>T&&T.atBottom===h.atBottom))),f=Et(X(r,en((T,{scrollHeight:h,scrollTop:v,viewportHeight:C})=>{if(up(T.scrollHeight,h))return{changed:!1,jump:0,scrollHeight:h,scrollTop:v};{const R=h-(v+C)<1;return T.scrollTop!==v&&R?{changed:!0,jump:T.scrollTop-v,scrollHeight:h,scrollTop:v}:{changed:!0,jump:0,scrollHeight:h,scrollTop:v}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),ye(T=>T.changed),pe(T=>T.jump)),0);Te(X(g,pe(T=>T.atBottom)),o),Te(X(o,un(50)),l);const E=ne(Ur);Te(X(r,pe(({scrollTop:T})=>T),tt(),en((T,h)=>lt(m)?{direction:T.direction,prevScrollTop:h}:{direction:h<T.prevScrollTop?kr:Ur,prevScrollTop:h},{direction:Ur,prevScrollTop:0}),pe(T=>T.direction)),E),Te(X(r,un(50),Jt(dN)),E);const S=ne(0);return Te(X(p,ye(T=>!T),Jt(0)),S),Te(X(a,un(100),Pe(p),ye(([T,h])=>!!h),en(([T,h],[v])=>[h,v],[0,0]),pe(([T,h])=>h-T)),S),{atBottomState:g,atBottomStateChange:l,atBottomThreshold:d,atTopStateChange:c,atTopThreshold:_,isAtBottom:o,isAtTop:s,isScrolling:p,lastJumpDueToItemResize:f,scrollDirection:E,scrollVelocity:S}},et(Tt)),Ia="top",Aa="bottom",_p="none";function pp(t,e,n){return typeof t=="number"?n===kr&&e===Ia||n===Ur&&e===Aa?t:0:n===kr?e===Ia?t.main:t.reverse:e===Aa?t.main:t.reverse}function mp(t,e){var n;return typeof t=="number"?t:(n=t[e])!=null?n:0}const yo=qe(([{deviation:t,fixedHeaderHeight:e,headerHeight:n,scrollTop:r,viewportHeight:a}])=>{const i=Ye(),o=ne(0),s=ne(0),l=ne(0),c=Et(X(dt(Ne(r),Ne(a),Ne(n),Ne(i,wr),Ne(l),Ne(o),Ne(e),Ne(t),Ne(s)),pe(([d,_,p,[m,g],f,E,S,T,h])=>{const v=d-T,C=E+S,R=Math.max(p-v,0);let N=_p;const O=mp(h,Ia),D=mp(h,Aa);return m-=T,m+=p+S,g+=p+S,g-=T,m>d+C-O&&(N=kr),g<d-R+_+D&&(N=Ur),N!==_p?[Math.max(v-p-pp(f,Ia,N)-O,0),v-R-S+_+pp(f,Aa,N)+D]:null}),ye(d=>d!=null),tt(wr)),[0,0]);return{increaseViewportBy:s,listBoundary:i,overscan:l,topListHeight:o,visibleRange:c}},et(Tt),{singleton:!0});function pN(t,e,n){if(ya(e)){const r=op(t,e);return[{index:Vt(e.groupOffsetTree,r)[0],offset:0,size:0},{data:n==null?void 0:n[0],index:r,offset:0,size:0}]}return[{data:n==null?void 0:n[0],index:t,offset:0,size:0}]}const Io={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function xa(t,e,n,r,a,i){const{lastIndex:o,lastOffset:s,lastSize:l}=a;let c=0,d=0;if(t.length>0){c=t[0].offset;const f=t[t.length-1];d=f.offset+f.size}const _=n-o,p=s+_*l+(_-1)*r,m=c,g=p-d;return{bottom:d,firstItemIndex:i,items:Ep(t,a,i),offsetBottom:g,offsetTop:c,top:m,topItems:Ep(e,a,i),topListHeight:e.reduce((f,E)=>E.size+f,0),totalCount:n}}function gp(t,e,n,r,a,i){let o=0;if(n.groupIndices.length>0)for(const d of n.groupIndices){if(d-o>=t)break;o++}const s=t+o,l=Oo(e,s),c=Array.from({length:s}).map((d,_)=>({data:i[_+l],index:_+l,offset:0,size:0}));return xa(c,[],s,a,n,r)}function Ep(t,e,n){if(t.length===0)return[];if(!ya(e))return t.map(c=>({...c,index:c.index+n,originalIndex:c.index}));const r=t[0].index,a=t[t.length-1].index,i=[],o=va(e.groupOffsetTree,r,a);let s,l=0;for(const c of t){(!s||s.end<c.index)&&(s=o.shift(),l=e.groupIndices.indexOf(s.start));let d;c.index===s.start?d={index:l,type:"group"}:d={groupIndex:l,index:c.index-(l+1)+n},i.push({...d,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return i}const Fn=qe(([{data:t,firstItemIndex:e,gap:n,sizes:r,totalCount:a},i,{listBoundary:o,topListHeight:s,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:d},{topListHeight:_},p,{didMount:m},{recalcInProgress:g}])=>{const f=ne([]),E=ne(0),S=Ye();Te(i.topItemsIndexes,f);const T=Et(X(dt(m,g,Ne(l,wr),Ne(a),Ne(r),Ne(c),d,Ne(f),Ne(e),Ne(n),t),ye(([R,N,,O,,,,,,,D])=>{const w=D&&D.length!==O;return R&&!N&&!w}),pe(([,,[R,N],O,D,w,L,H,z,P,G])=>{const I=D,{offsetTree:U,sizeTree:M}=I,k=lt(E);if(O===0)return{...Io,totalCount:O};if(R===0&&N===0)return k===0?{...Io,totalCount:O}:gp(k,w,D,z,P,G||[]);if(je(M))return k>0?null:xa(pN(Oo(w,O),I,G),[],O,P,I,z);const Y=[];if(H.length>0){const se=H[0],Ee=H[H.length-1];let V=0;for(const F of va(M,se,Ee)){const Q=F.value,te=Math.max(F.start,se),ce=Math.min(F.end,Ee);for(let oe=te;oe<=ce;oe++)Y.push({data:G==null?void 0:G[oe],index:oe,offset:V,size:Q}),V+=Q}}if(!L)return xa([],Y,O,P,I,z);const W=H.length>0?H[H.length-1]+1:0,re=tN(U,R,N,W);if(re.length===0)return null;const q=O-1,j=Ra([],se=>{for(const Ee of re){const V=Ee.value;let F=V.offset,Q=Ee.start;const te=V.size;if(V.offset<R){Q+=Math.floor((R-V.offset+P)/(te+P));const oe=Q-Ee.start;F+=oe*te+oe*P}Q<W&&(F+=(W-Q)*te,Q=W);const ce=Math.min(Ee.end,q);for(let oe=Q;oe<=ce&&!(F>=N);oe++)se.push({data:G==null?void 0:G[oe],index:oe,offset:F,size:te}),F+=te+P}});return xa(j,Y,O,P,I,z)}),ye(R=>R!==null),tt()),Io);Te(X(t,ye(mo),pe(R=>R==null?void 0:R.length)),a),Te(X(T,pe(R=>R.topListHeight)),_),Te(_,s),Te(X(T,pe(R=>[R.top,R.bottom])),o),Te(X(T,pe(R=>R.items)),S);const h=At(X(T,ye(({items:R})=>R.length>0),Pe(a,t),ye(([{items:R},N])=>R[R.length-1].originalIndex===N-1),pe(([,R,N])=>[R-1,N]),tt(wr),pe(([R])=>R))),v=At(X(T,un(200),ye(({items:R,topItems:N})=>R.length>0&&R[0].originalIndex===N.length),pe(({items:R})=>R[0].index),tt())),C=At(X(T,ye(({items:R})=>R.length>0),pe(({items:R})=>{let N=0,O=R.length-1;for(;R[N].type==="group"&&N<O;)N++;for(;R[O].type==="group"&&O>N;)O--;return{endIndex:R[O].index,startIndex:R[N].index}}),tt(ap)));return{endReached:h,initialItemCount:E,itemsRendered:S,listState:T,rangeChanged:C,startReached:v,topItemsIndexes:f,...p}},et(tn,cp,yo,Pr,Lr,Fr,Tn,Co),{singleton:!0}),fp=qe(([{fixedFooterHeight:t,fixedHeaderHeight:e,footerHeight:n,headerHeight:r},{listState:a}])=>{const i=Ye(),o=Et(X(dt(n,t,r,e,a),pe(([s,l,c,d,_])=>s+l+c+d+_.offsetBottom+_.bottom)),0);return Te(Ne(o),i),{totalListHeight:o,totalListHeightChanged:i}},et(Tt,Fn),{singleton:!0}),mN=qe(([{viewportHeight:t},{totalListHeight:e}])=>{const n=ne(!1),r=Et(X(dt(n,t,e),ye(([a])=>a),pe(([,a,i])=>Math.max(0,a-i)),un(0),tt()),0);return{alignToBottom:n,paddingTopAddition:r}},et(Tt,fp),{singleton:!0}),Sp=qe(()=>({context:ne(null)})),gN=({itemBottom:t,itemTop:e,locationParams:{align:n,behavior:r,...a},viewportBottom:i,viewportTop:o})=>e<o?{...a,align:n??"start",behavior:r}:t>i?{...a,align:n??"end",behavior:r}:null,bp=qe(([{gap:t,sizes:e,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:a,headerHeight:i,scrollingInProgress:o,scrollTop:s,viewportHeight:l},{scrollToIndex:c}])=>{const d=Ye();return Te(X(d,Pe(e,l,n,i,a,r,s),Pe(t),pe(([[_,p,m,g,f,E,S,T],h])=>{const{align:v,behavior:C,calculateViewLocation:R=gN,done:N,...O}=_,D=sp(_,p,g-1),w=Mr(D,p.offsetTree,h)+f+E,L=w+Vt(p.sizeTree,D)[1],H=T+E,z=T+m-S,P=R({itemBottom:L,itemTop:w,locationParams:{align:v,behavior:C,...O},viewportBottom:z,viewportTop:H});return P?N&&qt(X(o,ye(G=>!G),Pn(lt(o)?1:2)),N):N&&N(),P}),ye(_=>_!==null)),c),{scrollIntoView:d}},et(tn,Tt,Lr,Fn,Sn),{singleton:!0});function Tp(t){return t?t==="smooth"?"smooth":"auto":!1}const EN=(t,e)=>typeof t=="function"?Tp(t(e)):e&&Tp(t),fN=qe(([{listRefresh:t,totalCount:e,fixedItemSize:n,data:r},{atBottomState:a,isAtBottom:i},{scrollToIndex:o},{scrolledToInitialItem:s},{didMount:l,propsReady:c},{log:d},{scrollingInProgress:_},{context:p},{scrollIntoView:m}])=>{const g=ne(!1),f=Ye();let E=null;function S(C){Me(o,{align:"end",behavior:C,index:"LAST"})}We(X(dt(X(Ne(e),Pn(1)),l),Pe(Ne(g),i,s,_),pe(([[C,R],N,O,D,w])=>{let L=R&&D,H="auto";return L&&(H=EN(N,O||w),L=L&&!!H),{followOutputBehavior:H,shouldFollow:L,totalCount:C}}),ye(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:R})=>{E&&(E(),E=null),lt(n)?requestAnimationFrame(()=>{lt(d)("following output to ",{totalCount:R},vt.DEBUG),S(C)}):E=qt(t,()=>{lt(d)("following output to ",{totalCount:R},vt.DEBUG),S(C),E=null})});function T(C){const R=qt(a,N=>{C&&!N.atBottom&&N.notAtBottomBecause==="SIZE_INCREASED"&&!E&&(lt(d)("scrolling to bottom due to increased size",{},vt.DEBUG),S("auto"))});setTimeout(R,100)}We(X(dt(Ne(g),e,c),ye(([C,,R])=>C&&R),en(({value:C},[,R])=>({refreshed:C===R,value:R}),{refreshed:!1,value:0}),ye(({refreshed:C})=>C),Pe(g,e)),([,C])=>{lt(s)&&T(C!==!1)}),We(f,()=>{T(lt(g)!==!1)}),We(dt(Ne(g),a),([C,R])=>{C&&!R.atBottom&&R.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&S("auto")});const h=ne(null),v=Ye();return Te(Eo(X(Ne(r),pe(C=>{var R;return(R=C==null?void 0:C.length)!=null?R:0})),X(Ne(e))),v),We(X(dt(X(v,Pn(1)),l),Pe(Ne(h),s,_,p),pe(([[C,R],N,O,D,w])=>R&&O&&(N==null?void 0:N({context:w,totalCount:C,scrollingInProgress:D}))),ye(C=>!!C),un(0)),C=>{E&&(E(),E=null),lt(n)?requestAnimationFrame(()=>{lt(d)("scrolling into view",{}),Me(m,C)}):E=qt(t,()=>{lt(d)("scrolling into view",{}),Me(m,C),E=null})}),{autoscrollToBottom:f,followOutput:g,scrollIntoViewOnChange:h}},et(tn,Fr,Lr,Pr,Tn,Sn,Tt,Sp,bp)),SN=qe(([{data:t,firstItemIndex:e,gap:n,sizes:r},{initialTopMostItemIndex:a},{initialItemCount:i,listState:o},{didMount:s}])=>(Te(X(s,Pe(i),ye(([,l])=>l!==0),Pe(a,r,e,n,t),pe(([[,l],c,d,_,p,m=[]])=>gp(l,c,d,_,p,m))),o),{}),et(tn,Pr,Fn,Tn),{singleton:!0}),bN=qe(([{didMount:t},{scrollTo:e},{listState:n}])=>{const r=ne(0);return We(X(t,Pe(r),ye(([,a])=>a!==0),pe(([,a])=>({top:a}))),a=>{qt(X(n,Pn(1),ye(i=>i.items.length>1)),()=>{requestAnimationFrame(()=>{Me(e,a)})})}),{initialScrollTop:r}},et(Tn,Tt,Fn),{singleton:!0}),hp=qe(([{scrollVelocity:t}])=>{const e=ne(!1),n=Ye(),r=ne(!1);return Te(X(t,Pe(r,e,n),ye(([a,i])=>!!i),pe(([a,i,o,s])=>{const{enter:l,exit:c}=i;if(o){if(c(a,s))return!1}else if(l(a,s))return!0;return o}),tt()),e),We(X(dt(e,t,n),Pe(r)),([[a,i,o],s])=>{a&&s&&s.change&&s.change(i,o)}),{isSeeking:e,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:t}},et(Fr),{singleton:!0}),Ao=qe(([{scrollContainerState:t,scrollTo:e}])=>{const n=Ye(),r=Ye(),a=Ye(),i=ne(!1),o=ne(void 0);return Te(X(dt(n,r),pe(([{scrollHeight:s,scrollTop:l,viewportHeight:c},{offsetTop:d}])=>({scrollHeight:s,scrollTop:Math.max(0,l-d),viewportHeight:c}))),t),Te(X(e,Pe(r),pe(([s,{offsetTop:l}])=>({...s,top:s.top+l}))),a),{customScrollParent:o,useWindowScroll:i,windowScrollContainerState:n,windowScrollTo:a,windowViewportRect:r}},et(Tt)),TN=qe(([{sizeRanges:t,sizes:e},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:a},{didMount:i},{useWindowScroll:o,windowScrollContainerState:s,windowViewportRect:l}])=>{const c=Ye(),d=ne(void 0),_=ne(null),p=ne(null);return Te(s,_),Te(l,p),We(X(c,Pe(e,r,o,_,p,n)),([m,g,f,E,S,T,h])=>{const v=rN(g.sizeTree);E&&S!==null&&T!==null&&(f=S.scrollTop-T.offsetTop),f-=h,m({ranges:v,scrollTop:f})}),Te(X(d,ye(mo),pe(hN)),a),Te(X(i,Pe(d),ye(([,m])=>m!==void 0),tt(),pe(([,m])=>m.ranges)),t),{getState:c,restoreStateFrom:d}},et(tn,Tt,Pr,Tn,Ao));function hN(t){return{align:"start",index:0,offset:t.scrollTop}}const CN=qe(([{topItemsIndexes:t}])=>{const e=ne(0);return Te(X(e,ye(n=>n>=0),pe(n=>Array.from({length:n}).map((r,a)=>a))),t),{topItemCount:e}},et(Fn));function Cp(t){let e=!1,n;return()=>(e||(e=!0,n=t()),n)}const RN=Cp(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),vN=qe(([{deviation:t,scrollBy:e,scrollingInProgress:n,scrollTop:r},{isAtBottom:a,isScrolling:i,lastJumpDueToItemResize:o,scrollDirection:s},{listState:l},{beforeUnshiftWith:c,gap:d,shiftWithOffset:_,sizes:p},{log:m},{recalcInProgress:g}])=>{const f=At(X(l,Pe(o),en(([,S,T,h],[{bottom:v,items:C,offsetBottom:R,totalCount:N},O])=>{const D=v+R;let w=0;return T===N&&S.length>0&&C.length>0&&(C[0].originalIndex===0&&S[0].originalIndex===0||(w=D-h,w!==0&&(w+=O))),[w,C,N,D]},[0,[],0,0]),ye(([S])=>S!==0),Pe(r,s,n,a,m,g),ye(([,S,T,h,,,v])=>!v&&!h&&S!==0&&T===kr),pe(([[S],,,,,T])=>(T("Upward scrolling compensation",{amount:S},vt.DEBUG),S))));function E(S){S>0?(Me(e,{behavior:"auto",top:-S}),Me(t,0)):(Me(t,0),Me(e,{behavior:"auto",top:-S}))}return We(X(f,Pe(t,i)),([S,T,h])=>{h&&RN()?Me(t,T-S):E(-S)}),We(X(dt(Et(i,!1),t,g),ye(([S,T,h])=>!S&&!h&&T!==0),pe(([S,T])=>T),un(1)),E),Te(X(_,pe(S=>({top:-S}))),e),We(X(c,Pe(p,d),pe(([S,{groupIndices:T,lastSize:h,sizeTree:v},C])=>{function R(N){return N*(h+C)}if(T.length===0)return R(S);{let N=0;const O=Dr(v,0);let D=0,w=0;for(;D<S;){D++,N+=O;let L=T.length===w+1?1/0:T[w+1]-T[w]-1;D+L>S&&(N-=O,L=S-D+1),D+=L,N+=R(L),w++}return N}})),S=>{Me(t,S),requestAnimationFrame(()=>{Me(e,{top:S}),requestAnimationFrame(()=>{Me(t,0),Me(g,!1)})})}),{deviation:t}},et(Tt,Fr,Fn,tn,Sn,Co)),NN=qe(([t,e,n,r,a,i,o,s,l,c,d])=>({...t,...e,...n,...r,...a,...i,...o,...s,...l,...c,...d}),et(yo,SN,Tn,hp,fp,bN,mN,Ao,bp,Sn,Sp)),Rp=qe(([{data:t,defaultItemSize:e,firstItemIndex:n,fixedItemSize:r,gap:a,groupIndices:i,itemSize:o,sizeRanges:s,sizes:l,statefulTotalCount:c,totalCount:d,trackItemSizes:_},{initialItemFinalLocationReached:p,initialTopMostItemIndex:m,scrolledToInitialItem:g},f,E,S,{listState:T,topItemsIndexes:h,...v},{scrollToIndex:C},R,{topItemCount:N},{groupCounts:O},D])=>(Te(v.rangeChanged,D.scrollSeekRangeChanged),Te(X(D.windowViewportRect,pe(w=>w.visibleHeight)),f.viewportHeight),{data:t,defaultItemHeight:e,firstItemIndex:n,fixedItemHeight:r,gap:a,groupCounts:O,initialItemFinalLocationReached:p,initialTopMostItemIndex:m,scrolledToInitialItem:g,sizeRanges:s,topItemCount:N,topItemsIndexes:h,totalCount:d,...S,groupIndices:i,itemSize:o,listState:T,scrollToIndex:C,statefulTotalCount:c,trackItemSizes:_,...v,...D,...f,sizes:l,...E}),et(tn,Pr,Tt,TN,fN,Fn,Lr,vN,CN,cp,NN));function ON(t,e){const n={},r={};let a=0;const i=t.length;for(;a<i;)r[t[a]]=1,a+=1;for(const o in e)Object.hasOwn(r,o)||(n[o]=e[o]);return n}const Da=typeof document<"u"?y.useLayoutEffect:y.useEffect;function vp(t,e,n){const r=Object.keys(e.required||{}),a=Object.keys(e.optional||{}),i=Object.keys(e.methods||{}),o=Object.keys(e.events||{}),s=y.createContext({});function l(E,S){E.propsReady&&Me(E.propsReady,!1);for(const T of r){const h=E[e.required[T]];Me(h,S[T])}for(const T of a)if(T in S){const h=E[e.optional[T]];Me(h,S[T])}E.propsReady&&Me(E.propsReady,!0)}function c(E){return i.reduce((S,T)=>(S[T]=h=>{const v=E[e.methods[T]];Me(v,h)},S),{})}function d(E){return o.reduce((S,T)=>(S[T]=Hv(E[e.events[T]]),S),{})}const _=y.forwardRef((E,S)=>{const{children:T,...h}=E,[v]=y.useState(()=>Ra(Vv(t),N=>{l(N,h)})),[C]=y.useState(W_(d,v));Da(()=>{for(const N of o)N in h&&We(C[N],h[N]);return()=>{Object.values(C).map(go)}},[h,C,v]),Da(()=>{l(v,h)}),y.useImperativeHandle(S,z_(c(v)));const R=n;return u.jsx(s.Provider,{value:v,children:n?u.jsx(R,{...ON([...r,...a,...o],h),children:T}):T})}),p=E=>{const S=y.useContext(s);return y.useCallback(T=>{Me(S[E],T)},[S,E])},m=E=>{const S=y.useContext(s)[E],T=y.useCallback(h=>We(S,h),[S]);return y.useSyncExternalStore(T,()=>lt(S),()=>lt(S))},g=E=>{const S=y.useContext(s)[E],[T,h]=y.useState(W_(lt,S));return Da(()=>We(S,v=>{v!==T&&h(z_(v))}),[S,T]),T},f=y.version.startsWith("18")?m:g;return{Component:_,useEmitter:(E,S)=>{const T=y.useContext(s)[E];Da(()=>We(T,S),[S,T])},useEmitterValue:f,usePublisher:p}}const Np=y.createContext(void 0),Op=y.createContext(void 0),yp=typeof document<"u"?y.useLayoutEffect:y.useEffect;function xo(t){return"self"in t}function yN(t){return"body"in t}function Ip(t,e,n,r=nr,a,i){const o=y.useRef(null),s=y.useRef(null),l=y.useRef(null),c=y.useCallback(p=>{let m,g,f;const E=p.target;if(yN(E)||xo(E)){const T=xo(E)?E:E.defaultView;f=i?T.scrollX:T.scrollY,m=i?T.document.documentElement.scrollWidth:T.document.documentElement.scrollHeight,g=i?T.innerWidth:T.innerHeight}else f=i?E.scrollLeft:E.scrollTop,m=i?E.scrollWidth:E.scrollHeight,g=i?E.offsetWidth:E.offsetHeight;const S=()=>{t({scrollHeight:m,scrollTop:Math.max(f,0),viewportHeight:g})};p.suppressFlushSync?S():En.flushSync(S),s.current!==null&&(f===s.current||f<=0||f===m-g)&&(s.current=null,e(!0),l.current&&(clearTimeout(l.current),l.current=null))},[t,e,i]);y.useEffect(()=>{const p=a||o.current;return r(a||o.current),c({suppressFlushSync:!0,target:p}),p.addEventListener("scroll",c,{passive:!0}),()=>{r(null),p.removeEventListener("scroll",c)}},[o,c,n,r,a]);function d(p){const m=o.current;if(!m||(i?"offsetWidth"in m&&m.offsetWidth===0:"offsetHeight"in m&&m.offsetHeight===0))return;const g=p.behavior==="smooth";let f,E,S;xo(m)?(E=Math.max(bn(m.document.documentElement,i?"width":"height"),i?m.document.documentElement.scrollWidth:m.document.documentElement.scrollHeight),f=i?m.innerWidth:m.innerHeight,S=i?window.scrollX:window.scrollY):(E=m[i?"scrollWidth":"scrollHeight"],f=bn(m,i?"width":"height"),S=m[i?"scrollLeft":"scrollTop"]);const T=E-f;if(p.top=Math.ceil(Math.max(Math.min(T,p.top),0)),up(f,E)||p.top===S){t({scrollHeight:E,scrollTop:S,viewportHeight:f}),g&&e(!0);return}g?(s.current=p.top,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,s.current=null,e(!0)},1e3)):s.current=null,i&&(p={behavior:p.behavior,left:p.top}),m.scrollTo(p)}function _(p){i&&(p={behavior:p.behavior,left:p.top}),o.current.scrollBy(p)}return{scrollByCallback:_,scrollerRef:o,scrollToCallback:d}}const Do="-webkit-sticky",Ap="sticky",wo=Cp(()=>{if(typeof document>"u")return Ap;const t=document.createElement("div");return t.style.position=Do,t.style.position===Do?Do:Ap});function Mo(t){return t}const IN=qe(()=>{const t=ne(s=>`Item ${s}`),e=ne(s=>`Group ${s}`),n=ne({}),r=ne(Mo),a=ne("div"),i=ne(nr),o=(s,l=null)=>Et(X(n,pe(c=>c[s]),tt()),l);return{components:n,computeItemKey:r,EmptyPlaceholder:o("EmptyPlaceholder"),FooterComponent:o("Footer"),GroupComponent:o("Group","div"),groupContent:e,HeaderComponent:o("Header"),HeaderFooterTag:a,ItemComponent:o("Item","div"),itemContent:t,ListComponent:o("List","div"),ScrollerComponent:o("Scroller","div"),scrollerRef:i,ScrollSeekPlaceholder:o("ScrollSeekPlaceholder"),TopItemListComponent:o("TopItemList")}}),AN=qe(([t,e])=>({...t,...e}),et(Rp,IN)),xN=({height:t})=>u.jsx("div",{style:{height:t}}),DN={overflowAnchor:"none",position:wo(),zIndex:1},xp={overflowAnchor:"none"},wN={...xp,display:"inline-block",height:"100%"},Dp=y.memo(function({showTopList:t=!1}){const e=De("listState"),n=Ut("sizeRanges"),r=De("useWindowScroll"),a=De("customScrollParent"),i=Ut("windowScrollContainerState"),o=Ut("scrollContainerState"),s=a||r?i:o,l=De("itemContent"),c=De("context"),d=De("groupContent"),_=De("trackItemSizes"),p=De("itemSize"),m=De("log"),g=Ut("gap"),f=De("horizontalDirection"),{callbackRef:E}=Wv(n,p,_,t?nr:s,m,g,a,f,De("skipAnimationFrameInResizeObserver")),[S,T]=y.useState(0);Lo("deviation",P=>{S!==P&&T(P)});const h=De("EmptyPlaceholder"),v=De("ScrollSeekPlaceholder")||xN,C=De("ListComponent"),R=De("ItemComponent"),N=De("GroupComponent"),O=De("computeItemKey"),D=De("isSeeking"),w=De("groupIndices").length>0,L=De("alignToBottom"),H=De("initialItemFinalLocationReached"),z=t?{}:{boxSizing:"border-box",...f?{display:"inline-block",height:"100%",marginLeft:S!==0?S:L?"auto":0,paddingLeft:e.offsetTop,paddingRight:e.offsetBottom,whiteSpace:"nowrap"}:{marginTop:S!==0?S:L?"auto":0,paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},...H?{}:{visibility:"hidden"}};return!t&&e.totalCount===0&&h?u.jsx(h,{...ft(h,c)}):u.jsx(C,{...ft(C,c),"data-testid":t?"virtuoso-top-item-list":"virtuoso-item-list",ref:E,style:z,children:(t?e.topItems:e.items).map(P=>{const G=P.originalIndex,I=O(G+e.firstItemIndex,P.data,c);return D?y.createElement(v,{...ft(v,c),height:P.size,index:P.index,key:I,type:P.type||"item",...P.type==="group"?{}:{groupIndex:P.groupIndex}}):P.type==="group"?y.createElement(N,{...ft(N,c),"data-index":G,"data-item-index":P.index,"data-known-size":P.size,key:I,style:DN},d(P.index,c)):y.createElement(R,{...ft(R,c),...kN(R,P.data),"data-index":G,"data-item-group-index":P.groupIndex,"data-item-index":P.index,"data-known-size":P.size,key:I,style:f?wN:xp},w?l(P.index,P.groupIndex,P.data,c):l(P.index,P.data,c))})})}),MN={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},LN={outline:"none",overflowX:"auto",position:"relative"},wa=t=>({height:"100%",position:"absolute",top:0,width:"100%",...t?{display:"flex",flexDirection:"column"}:{}}),PN={position:wo(),top:0,width:"100%",zIndex:1};function ft(t,e){if(typeof t!="string")return{context:e}}function kN(t,e){return{item:typeof t=="string"?void 0:e}}const UN=y.memo(function(){const t=De("HeaderComponent"),e=Ut("headerHeight"),n=De("HeaderFooterTag"),r=kn(y.useMemo(()=>i=>{e(bn(i,"height"))},[e]),!0,De("skipAnimationFrameInResizeObserver")),a=De("context");return t?u.jsx(n,{ref:r,children:u.jsx(t,{...ft(t,a)})}):null}),FN=y.memo(function(){const t=De("FooterComponent"),e=Ut("footerHeight"),n=De("HeaderFooterTag"),r=kn(y.useMemo(()=>i=>{e(bn(i,"height"))},[e]),!0,De("skipAnimationFrameInResizeObserver")),a=De("context");return t?u.jsx(n,{ref:r,children:u.jsx(t,{...ft(t,a)})}):null});function wp({useEmitter:t,useEmitterValue:e,usePublisher:n}){return y.memo(function({children:r,style:a,context:i,...o}){const s=n("scrollContainerState"),l=e("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=e("scrollerRef"),_=e("horizontalDirection")||!1,{scrollByCallback:p,scrollerRef:m,scrollToCallback:g}=Ip(s,c,l,d,void 0,_);return t("scrollTo",g),t("scrollBy",p),u.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:m,style:{..._?LN:MN,...a},tabIndex:0,...o,...ft(l,i),children:r})})}function Mp({useEmitter:t,useEmitterValue:e,usePublisher:n}){return y.memo(function({children:r,style:a,context:i,...o}){const s=n("windowScrollContainerState"),l=e("ScrollerComponent"),c=n("smoothScrollTargetReached"),d=e("totalListHeight"),_=e("deviation"),p=e("customScrollParent"),m=y.useRef(null),g=e("scrollerRef"),{scrollByCallback:f,scrollerRef:E,scrollToCallback:S}=Ip(s,c,l,g,p);return yp(()=>{var T;return E.current=p||((T=m.current)==null?void 0:T.ownerDocument.defaultView),()=>{E.current=null}},[E,p]),t("windowScrollTo",S),t("scrollBy",f),u.jsx(l,{ref:m,"data-virtuoso-scroller":!0,style:{position:"relative",...a,...d!==0?{height:d+_}:{}},...o,...ft(l,i),children:r})})}const BN=({children:t})=>{const e=y.useContext(Np),n=Ut("viewportHeight"),r=Ut("fixedItemHeight"),a=De("alignToBottom"),i=De("horizontalDirection"),o=y.useMemo(()=>$_(n,l=>bn(l,i?"width":"height")),[n,i]),s=kn(o,!0,De("skipAnimationFrameInResizeObserver"));return y.useEffect(()=>{e&&(n(e.viewportHeight),r(e.itemHeight))},[e,n,r]),u.jsx("div",{"data-viewport-type":"element",ref:s,style:wa(a),children:t})},GN=({children:t})=>{const e=y.useContext(Np),n=Ut("windowViewportRect"),r=Ut("fixedItemHeight"),a=De("customScrollParent"),i=X_(n,a,De("skipAnimationFrameInResizeObserver")),o=De("alignToBottom");return y.useEffect(()=>{e&&(r(e.itemHeight),n({offsetTop:0,visibleHeight:e.viewportHeight,visibleWidth:100}))},[e,n,r]),u.jsx("div",{"data-viewport-type":"window",ref:i,style:wa(o),children:t})},YN=({children:t})=>{const e=De("TopItemListComponent")||"div",n=De("headerHeight"),r={...PN,marginTop:`${n}px`},a=De("context");return u.jsx(e,{style:r,...ft(e,a),children:t})},HN=y.memo(function(t){const e=De("useWindowScroll"),n=De("topItemsIndexes").length>0,r=De("customScrollParent"),a=De("context");return u.jsxs(r||e?zN:VN,{...t,context:a,children:[n&&u.jsx(YN,{children:u.jsx(Dp,{showTopList:!0})}),u.jsxs(r||e?GN:BN,{children:[u.jsx(UN,{}),u.jsx(Dp,{}),u.jsx(FN,{})]})]})}),{Component:qN,useEmitter:Lo,useEmitterValue:De,usePublisher:Ut}=vp(AN,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},HN),VN=wp({useEmitter:Lo,useEmitterValue:De,usePublisher:Ut}),zN=Mp({useEmitter:Lo,useEmitterValue:De,usePublisher:Ut}),$N=qN;et(Rp,qe(()=>{const t=ne(c=>u.jsxs("td",{children:["Item $",c]})),e=ne(null),n=ne(c=>u.jsxs("td",{colSpan:1e3,children:["Group ",c]})),r=ne(null),a=ne(null),i=ne({}),o=ne(Mo),s=ne(nr),l=(c,d=null)=>Et(X(i,pe(_=>_[c]),tt()),d);return{components:i,computeItemKey:o,context:e,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:a,fixedHeaderContent:r,itemContent:t,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}})),wo();const Lp={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},WN={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:Pp,floor:Ma,max:Br,min:Po,round:kp}=Math;function Up(t,e,n){return Array.from({length:e-t+1}).map((r,a)=>({data:n===null?null:n[a+t],index:a+t}))}function KN(t){return{...WN,items:t}}function La(t,e){return t&&t.width===e.width&&t.height===e.height}function QN(t,e){return t&&t.column===e.column&&t.row===e.row}const jN=qe(([{increaseViewportBy:t,listBoundary:e,overscan:n,visibleRange:r},{footerHeight:a,headerHeight:i,scrollBy:o,scrollContainerState:s,scrollTo:l,scrollTop:c,smoothScrollTargetReached:d,viewportHeight:_},p,m,{didMount:g,propsReady:f},{customScrollParent:E,useWindowScroll:S,windowScrollContainerState:T,windowScrollTo:h,windowViewportRect:v},C])=>{const R=ne(0),N=ne(0),O=ne(Lp),D=ne({height:0,width:0}),w=ne({height:0,width:0}),L=Ye(),H=Ye(),z=ne(0),P=ne(null),G=ne({column:0,row:0}),I=Ye(),U=Ye(),M=ne(!1),k=ne(0),Y=ne(!0),W=ne(!1),re=ne(!1);We(X(g,Pe(k),ye(([F,Q])=>!!Q)),()=>{Me(Y,!1)}),We(X(dt(g,Y,w,D,k,W),ye(([F,Q,te,ce,,oe])=>F&&!Q&&te.height!==0&&ce.height!==0&&!oe)),([,,,,F])=>{Me(W,!0),No(1,()=>{Me(L,F)}),qt(X(c),()=>{Me(e,[0,0]),Me(Y,!0)})}),Te(X(U,ye(F=>F!=null&&F.scrollTop>0),Jt(0)),N),We(X(g,Pe(U),ye(([,F])=>F!=null)),([,F])=>{F&&(Me(D,F.viewport),Me(w,F.item),Me(G,F.gap),F.scrollTop>0&&(Me(M,!0),qt(X(c,Pn(1)),Q=>{Me(M,!1)}),Me(l,{top:F.scrollTop})))}),Te(X(D,pe(({height:F})=>F)),_),Te(X(dt(Ne(D,La),Ne(w,La),Ne(G,(F,Q)=>F&&F.column===Q.column&&F.row===Q.row),Ne(c)),pe(([F,Q,te,ce])=>({gap:te,item:Q,scrollTop:ce,viewport:F}))),I),Te(X(dt(Ne(R),r,Ne(G,QN),Ne(w,La),Ne(D,La),Ne(P),Ne(N),Ne(M),Ne(Y),Ne(k)),ye(([,,,,,,,F])=>!F),pe(([F,[Q,te],ce,oe,xe,Ve,Le,,fe,ke])=>{const{column:ee,row:K}=ce,{height:ie,width:he}=oe,{width:nt}=xe;if(Le===0&&(F===0||nt===0))return Lp;if(he===0){const it=Oo(ke,F),Mt=it+Math.max(Le-1,0);return KN(Up(it,Mt,Ve))}const Ze=Fp(nt,he,ee);let at,Ke;fe?Q===0&&te===0&&Le>0?(at=0,Ke=Le-1):(at=Ze*Ma((Q+K)/(ie+K)),Ke=Ze*Pp((te+K)/(ie+K))-1,Ke=Po(F-1,Br(Ke,Ze-1)),at=Po(Ke,Br(0,at))):(at=0,Ke=-1);const Z=Up(at,Ke,Ve),{bottom:ae,top:be}=Bp(xe,ce,oe,Z),Ce=Pp(F/Ze),Be=Ce*ie+(Ce-1)*K-ae;return{bottom:ae,itemHeight:ie,items:Z,itemWidth:he,offsetBottom:Be,offsetTop:be,top:be}})),O),Te(X(P,ye(F=>F!==null),pe(F=>F.length)),R),Te(X(dt(D,w,O,G),ye(([F,Q,{items:te}])=>te.length>0&&Q.height!==0&&F.height!==0),pe(([F,Q,{items:te},ce])=>{const{bottom:oe,top:xe}=Bp(F,ce,Q,te);return[xe,oe]}),tt(wr)),e);const q=ne(!1);Te(X(c,Pe(q),pe(([F,Q])=>Q||F!==0)),q);const j=At(X(dt(O,R),ye(([{items:F}])=>F.length>0),Pe(q),ye(([[F,Q],te])=>{const ce=F.items[F.items.length-1].index===Q-1;return(te||F.bottom>0&&F.itemHeight>0&&F.offsetBottom===0&&F.items.length===Q)&&ce}),pe(([[,F]])=>F-1),tt())),se=At(X(Ne(O),ye(({items:F})=>F.length>0&&F[0].index===0),Jt(0),tt())),Ee=At(X(Ne(O),Pe(M),ye(([{items:F},Q])=>F.length>0&&!Q),pe(([{items:F}])=>({endIndex:F[F.length-1].index,startIndex:F[0].index})),tt(ap),un(0)));Te(Ee,m.scrollSeekRangeChanged),Te(X(L,Pe(D,w,R,G),pe(([F,Q,te,ce,oe])=>{const xe=dp(F),{align:Ve,behavior:Le,offset:fe}=xe;let ke=xe.index;ke==="LAST"&&(ke=ce-1),ke=Br(0,ke,Po(ce-1,ke));let ee=ko(Q,oe,te,ke);return Ve==="end"?ee=kp(ee-Q.height+te.height):Ve==="center"&&(ee=kp(ee-Q.height/2+te.height/2)),fe&&(ee+=fe),{behavior:Le,top:ee}})),l);const V=Et(X(O,pe(F=>F.offsetBottom+F.bottom)),0);return Te(X(v,pe(F=>({height:F.visibleHeight,width:F.visibleWidth}))),D),{customScrollParent:E,data:P,deviation:z,footerHeight:a,gap:G,headerHeight:i,increaseViewportBy:t,initialItemCount:N,itemDimensions:w,overscan:n,restoreStateFrom:U,scrollBy:o,scrollContainerState:s,scrollHeight:H,scrollTo:l,scrollToIndex:L,scrollTop:c,smoothScrollTargetReached:d,totalCount:R,useWindowScroll:S,viewportDimensions:D,windowScrollContainerState:T,windowScrollTo:h,windowViewportRect:v,...m,gridState:O,horizontalDirection:re,initialTopMostItemIndex:k,totalListHeight:V,...p,endReached:j,propsReady:f,rangeChanged:Ee,startReached:se,stateChanged:I,stateRestoreInProgress:M,...C}},et(yo,Tt,Fr,hp,Tn,Ao,Sn));function Fp(t,e,n){return Br(1,Ma((t+n)/(Ma(e)+n)))}function Bp(t,e,n,r){const{height:a}=n;if(a===void 0||r.length===0)return{bottom:0,top:0};const i=ko(t,e,n,r[0].index);return{bottom:ko(t,e,n,r[r.length-1].index)+a,top:i}}function ko(t,e,n,r){const a=Fp(t.width,n.width,e.column),i=Ma(r/a),o=i*n.height+Br(0,i-1)*e.row;return o>0?o+e.row:o}const XN=qe(()=>{const t=ne(_=>`Item ${_}`),e=ne({}),n=ne(null),r=ne("virtuoso-grid-item"),a=ne("virtuoso-grid-list"),i=ne(Mo),o=ne("div"),s=ne(nr),l=(_,p=null)=>Et(X(e,pe(m=>m[_]),tt()),p),c=ne(!1),d=ne(!1);return Te(Ne(d),c),{components:e,computeItemKey:i,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:o,itemClassName:r,ItemComponent:l("Item","div"),itemContent:t,listClassName:a,ListComponent:l("List","div"),readyStateChanged:c,reportReadyState:d,ScrollerComponent:l("Scroller","div"),scrollerRef:s,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),ZN=qe(([t,e])=>({...t,...e}),et(jN,XN)),JN=y.memo(function(){const t=rt("gridState"),e=rt("listClassName"),n=rt("itemClassName"),r=rt("itemContent"),a=rt("computeItemKey"),i=rt("isSeeking"),o=Ft("scrollHeight"),s=rt("ItemComponent"),l=rt("ListComponent"),c=rt("ScrollSeekPlaceholder"),d=rt("context"),_=Ft("itemDimensions"),p=Ft("gap"),m=rt("log"),g=rt("stateRestoreInProgress"),f=Ft("reportReadyState"),E=kn(y.useMemo(()=>S=>{const T=S.parentElement.parentElement.scrollHeight;o(T);const h=S.firstChild;if(h){const{height:v,width:C}=h.getBoundingClientRect();_({height:v,width:C})}p({column:Yp("column-gap",getComputedStyle(S).columnGap,m),row:Yp("row-gap",getComputedStyle(S).rowGap,m)})},[o,_,p,m]),!0,!1);return yp(()=>{t.itemHeight>0&&t.itemWidth>0&&f(!0)},[t]),g?null:u.jsx(l,{className:e,ref:E,...ft(l,d),"data-testid":"virtuoso-item-list",style:{paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},children:t.items.map(S=>{const T=a(S.index,S.data,d);return i?u.jsx(c,{...ft(c,d),height:t.itemHeight,index:S.index,width:t.itemWidth},T):y.createElement(s,{...ft(s,d),className:n,"data-index":S.index,key:T},r(S.index,S.data,d))})})}),eO=y.memo(function(){const t=rt("HeaderComponent"),e=Ft("headerHeight"),n=rt("headerFooterTag"),r=kn(y.useMemo(()=>i=>{e(bn(i,"height"))},[e]),!0,!1),a=rt("context");return t?u.jsx(n,{ref:r,children:u.jsx(t,{...ft(t,a)})}):null}),tO=y.memo(function(){const t=rt("FooterComponent"),e=Ft("footerHeight"),n=rt("headerFooterTag"),r=kn(y.useMemo(()=>i=>{e(bn(i,"height"))},[e]),!0,!1),a=rt("context");return t?u.jsx(n,{ref:r,children:u.jsx(t,{...ft(t,a)})}):null}),nO=({children:t})=>{const e=y.useContext(Op),n=Ft("itemDimensions"),r=Ft("viewportDimensions"),a=kn(y.useMemo(()=>i=>{r(i.getBoundingClientRect())},[r]),!0,!1);return y.useEffect(()=>{e&&(r({height:e.viewportHeight,width:e.viewportWidth}),n({height:e.itemHeight,width:e.itemWidth}))},[e,r,n]),u.jsx("div",{ref:a,style:wa(!1),children:t})},rO=({children:t})=>{const e=y.useContext(Op),n=Ft("windowViewportRect"),r=Ft("itemDimensions"),a=rt("customScrollParent"),i=X_(n,a,!1);return y.useEffect(()=>{e&&(r({height:e.itemHeight,width:e.itemWidth}),n({offsetTop:0,visibleHeight:e.viewportHeight,visibleWidth:e.viewportWidth}))},[e,n,r]),u.jsx("div",{ref:i,style:wa(!1),children:t})},aO=y.memo(function({...t}){const e=rt("useWindowScroll"),n=rt("customScrollParent"),r=n||e?oO:iO,a=n||e?rO:nO,i=rt("context");return u.jsx(r,{...t,...ft(r,i),children:u.jsxs(a,{children:[u.jsx(eO,{}),u.jsx(JN,{}),u.jsx(tO,{})]})})}),{useEmitter:Gp,useEmitterValue:rt,usePublisher:Ft}=vp(ZN,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},aO),iO=wp({useEmitter:Gp,useEmitterValue:rt,usePublisher:Ft}),oO=Mp({useEmitter:Gp,useEmitterValue:rt,usePublisher:Ft});function Yp(t,e,n){return e!=="normal"&&!(e!=null&&e.endsWith("px"))&&n(`${t} was not resolved to pixel value correctly`,e,vt.WARN),e==="normal"?0:parseInt(e??"0",10)}function $(...t){return XC.twMerge(jC.clsx(t))}const sO=hr.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),ze=b.forwardRef(({className:t,variant:e,size:n,asChild:r=!1,...a},i)=>{const o=r?yt.Slot:"button";return u.jsx(o,{className:$(sO({variant:e,size:n,className:t})),ref:i,...a})});ze.displayName="Button";const Hp=b.forwardRef(({className:t,...e},n)=>u.jsx("textarea",{className:$("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background 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",t),ref:n,...e}));Hp.displayName="Textarea";function lO({initialValue:t="",editingMessageId:e=null,placeholder:n="Type your message...",isStreaming:r=!1,disabled:a=!1,maxLength:i=2e4,onSend:o,onCancelEdit:s,onStop:l,className:c="",textareaClassName:d="",allowEmptySend:_=!1}){const[p,m]=y.useState(t),[g,f]=y.useTransition(),E=y.useRef(null);y.useEffect(()=>{m(t??""),E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`)},[t,e]);const S=y.useCallback(()=>{const O=E.current;O&&(O.style.height="auto",O.style.height=`${O.scrollHeight}px`)},[]);y.useEffect(()=>{S()},[S]);const T=y.useCallback(async O=>{O&&O.preventDefault();const D=(p??"").trim();!D&&!_||f(()=>{try{const w=o(D);w&&typeof w.then=="function"?w.then(()=>{m(""),E.current&&(E.current.style.height="auto")}).catch(()=>{}):(m(""),E.current&&(E.current.style.height="auto"))}catch{}})},[p,o,_]),h=y.useCallback(O=>{m(O.target.value),E.current&&(E.current.style.height="auto",E.current.style.height=`${E.current.scrollHeight}px`)},[]),v=y.useCallback(O=>{O.key==="Enter"&&!O.shiftKey?(O.preventDefault(),T()):O.key==="Escape"&&e&&(O.preventDefault(),s==null||s())},[T,e,s]),N=`resize-none min-h-[44px] max-h-[20rem] w-full transition-colors ${e?"border-[hsl(var(--ring))] bg-[hsl(var(--card))] text-[hsl(var(--card-foreground))] dark:bg-[hsl(var(--card))] dark:text-[hsl(var(--card-foreground))]":""} ${d}`;return u.jsx("form",{onSubmit:O=>void T(O),className:`w-full ${c}`,children:u.jsxs("div",{className:"flex items-end gap-2",children:[u.jsx("div",{className:"flex-1",children:u.jsx(Hp,{ref:E,value:p,onChange:h,onKeyDown:v,placeholder:e?"Edit your message...":n,className:N,disabled:a,maxLength:i,rows:1,spellCheck:!1,autoCorrect:"off"})}),u.jsx("div",{children:r?u.jsx(ze,{type:"button",onClick:()=>{l==null||l()},size:"icon",variant:"outline",className:"shrink-0",title:"Stop generating",disabled:a||!l,children:u.jsx(Se.Square,{size:16})}):u.jsx(ze,{type:"submit",size:"icon",className:"shrink-0",title:e?"Save changes":"Send message",disabled:a||!p.trim()&&!_||g,children:u.jsx(Se.Send,{size:16})})})]})})}const cO=y.memo(lO),dO=hr.cva("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function qp({className:t,variant:e,...n}){return u.jsx("div",{className:$(dO({variant:e}),t),...n})}function de(t,e,{checkForDefaultPrevented:n=!0}={}){return function(a){if(t==null||t(a),n===!1||!a.defaultPrevented)return e==null?void 0:e(a)}}function uO(t,e){const n=b.createContext(e),r=i=>{const{children:o,...s}=i,l=b.useMemo(()=>s,Object.values(s));return u.jsx(n.Provider,{value:l,children:o})};r.displayName=t+"Provider";function a(i){const o=b.useContext(n);if(o)return o;if(e!==void 0)return e;throw new Error(`\`${i}\` must be used within \`${t}\``)}return[r,a]}function zt(t,e=[]){let n=[];function r(i,o){const s=b.createContext(o),l=n.length;n=[...n,o];const c=_=>{var S;const{scope:p,children:m,...g}=_,f=((S=p==null?void 0:p[t])==null?void 0:S[l])||s,E=b.useMemo(()=>g,Object.values(g));return u.jsx(f.Provider,{value:E,children:m})};c.displayName=i+"Provider";function d(_,p){var f;const m=((f=p==null?void 0:p[t])==null?void 0:f[l])||s,g=b.useContext(m);if(g)return g;if(o!==void 0)return o;throw new Error(`\`${_}\` must be used within \`${i}\``)}return[c,d]}const a=()=>{const i=n.map(o=>b.createContext(o));return function(s){const l=(s==null?void 0:s[t])||i;return b.useMemo(()=>({[`__scope${t}`]:{...s,[t]:l}}),[s,l])}};return a.scopeName=t,[r,_O(a,...e)]}function _O(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=r.reduce((s,{useScope:l,scopeName:c})=>{const _=l(i)[`__scope${c}`];return{...s,..._}},{});return b.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}var _t=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},pO=b[" useInsertionEffect ".trim().toString()]||_t;function hn({prop:t,defaultProp:e,onChange:n=()=>{},caller:r}){const[a,i,o]=mO({defaultProp:e,onChange:n}),s=t!==void 0,l=s?t:a;{const d=b.useRef(t!==void 0);b.useEffect(()=>{const _=d.current;_!==s&&console.warn(`${r} is changing from ${_?"controlled":"uncontrolled"} to ${s?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),d.current=s},[s,r])}const c=b.useCallback(d=>{var _;if(s){const p=gO(d)?d(t):d;p!==t&&((_=o.current)==null||_.call(o,p))}else i(d)},[s,t,i,o]);return[l,c]}function mO({defaultProp:t,onChange:e}){const[n,r]=b.useState(t),a=b.useRef(n),i=b.useRef(e);return pO(()=>{i.current=e},[e]),b.useEffect(()=>{var o;a.current!==n&&((o=i.current)==null||o.call(i,n),a.current=n)},[n,a]),[n,r,i]}function gO(t){return typeof t=="function"}function Vp(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function Uo(...t){return e=>{let n=!1;const r=t.map(a=>{const i=Vp(a,e);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let a=0;a<r.length;a++){const i=r[a];typeof i=="function"?i():Vp(t[a],null)}}}}function Fe(...t){return b.useCallback(Uo(...t),t)}var EO=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ie=EO.reduce((t,e)=>{const n=yt.createSlot(`Primitive.${e}`),r=b.forwardRef((a,i)=>{const{asChild:o,...s}=a,l=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),u.jsx(l,{...s,ref:i})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function zp(t,e){t&&la.flushSync(()=>t.dispatchEvent(e))}function fO(t,e){return b.useReducer((n,r)=>e[n][r]??n,t)}var Nt=t=>{const{present:e,children:n}=t,r=SO(e),a=typeof n=="function"?n({present:r.isPresent}):b.Children.only(n),i=Fe(r.ref,bO(a));return typeof n=="function"||r.isPresent?b.cloneElement(a,{ref:i}):null};Nt.displayName="Presence";function SO(t){const[e,n]=b.useState(),r=b.useRef(null),a=b.useRef(t),i=b.useRef("none"),o=t?"mounted":"unmounted",[s,l]=fO(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return b.useEffect(()=>{const c=Pa(r.current);i.current=s==="mounted"?c:"none"},[s]),_t(()=>{const c=r.current,d=a.current;if(d!==t){const p=i.current,m=Pa(c);t?l("MOUNT"):m==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(d&&p!==m?"ANIMATION_OUT":"UNMOUNT"),a.current=t}},[t,l]),_t(()=>{if(e){let c;const d=e.ownerDocument.defaultView??window,_=m=>{const f=Pa(r.current).includes(CSS.escape(m.animationName));if(m.target===e&&f&&(l("ANIMATION_END"),!a.current)){const E=e.style.animationFillMode;e.style.animationFillMode="forwards",c=d.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=E)})}},p=m=>{m.target===e&&(i.current=Pa(r.current))};return e.addEventListener("animationstart",p),e.addEventListener("animationcancel",_),e.addEventListener("animationend",_),()=>{d.clearTimeout(c),e.removeEventListener("animationstart",p),e.removeEventListener("animationcancel",_),e.removeEventListener("animationend",_)}}else l("ANIMATION_END")},[e,l]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:b.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function Pa(t){return(t==null?void 0:t.animationName)||"none"}function bO(t){var r,a;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(a=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:a.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var TO=b[" useId ".trim().toString()]||(()=>{}),hO=0;function $t(t){const[e,n]=b.useState(TO());return _t(()=>{n(r=>r??String(hO++))},[t]),t||(e?`radix-${e}`:"")}var ka="Collapsible",[CO,Y0]=zt(ka),[RO,Fo]=CO(ka),$p=b.forwardRef((t,e)=>{const{__scopeCollapsible:n,open:r,defaultOpen:a,disabled:i,onOpenChange:o,...s}=t,[l,c]=hn({prop:r,defaultProp:a??!1,onChange:o,caller:ka});return u.jsx(RO,{scope:n,disabled:i,contentId:$t(),open:l,onOpenToggle:b.useCallback(()=>c(d=>!d),[c]),children:u.jsx(Ie.div,{"data-state":Go(l),"data-disabled":i?"":void 0,...s,ref:e})})});$p.displayName=ka;var Wp="CollapsibleTrigger",Kp=b.forwardRef((t,e)=>{const{__scopeCollapsible:n,...r}=t,a=Fo(Wp,n);return u.jsx(Ie.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":Go(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...r,ref:e,onClick:de(t.onClick,a.onOpenToggle)})});Kp.displayName=Wp;var Bo="CollapsibleContent",vO=b.forwardRef((t,e)=>{const{forceMount:n,...r}=t,a=Fo(Bo,t.__scopeCollapsible);return u.jsx(Nt,{present:n||a.open,children:({present:i})=>u.jsx(NO,{...r,ref:e,present:i})})});vO.displayName=Bo;var NO=b.forwardRef((t,e)=>{const{__scopeCollapsible:n,present:r,children:a,...i}=t,o=Fo(Bo,n),[s,l]=b.useState(r),c=b.useRef(null),d=Fe(e,c),_=b.useRef(0),p=_.current,m=b.useRef(0),g=m.current,f=o.open||s,E=b.useRef(f),S=b.useRef(void 0);return b.useEffect(()=>{const T=requestAnimationFrame(()=>E.current=!1);return()=>cancelAnimationFrame(T)},[]),_t(()=>{const T=c.current;if(T){S.current=S.current||{transitionDuration:T.style.transitionDuration,animationName:T.style.animationName},T.style.transitionDuration="0s",T.style.animationName="none";const h=T.getBoundingClientRect();_.current=h.height,m.current=h.width,E.current||(T.style.transitionDuration=S.current.transitionDuration,T.style.animationName=S.current.animationName),l(r)}},[o.open,r]),u.jsx(Ie.div,{"data-state":Go(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!f,...i,ref:d,style:{"--radix-collapsible-content-height":p?`${p}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...t.style},children:f&&a})});function Go(t){return t?"open":"closed"}var OO=$p;const Qp=OO,jp=Kp,Xp=new URL("data:video/mp2t;base64,aW1wb3J0IHsgcGFyc2UgfSBmcm9tICdtYXJrZWQnOwoKY29uc3Qgc2NvcGUgPSBzZWxmOwoKY29uc29sZS5sb2coJ1tNYXJrZG93bldvcmtlcl0gd29ya2VyIHNjcmlwdCBsb2FkZWQnKTsKLy8gU2lnbmFsIHRvIHRoZSBtYWluIHRocmVhZCB0aGF0IHRoZSB3b3JrZXIgaXMgcmVhZHkgdG8gcmVjZWl2ZSB3b3JrLgovLyBUaGlzIGhlbHBzIGNhbGxlcnMgYXZvaWQgcG9zdGluZyBtZXNzYWdlcyBiZWZvcmUgdGhlIHdvcmtlciBoYXMgZmluaXNoZWQgaW5pdGlhbGl6aW5nLgpzY29wZS5wb3N0TWVzc2FnZT8uKHsgX193b3JrZXJfcmVhZHk6IHRydWUgfSk7CgpzY29wZS5hZGRFdmVudExpc3RlbmVyKCdtZXNzYWdlJywgKGV2ZW50KSA9PiB7CiAgY29uc3QgcGF5bG9hZCA9IGV2ZW50Py5kYXRhID8/IHt9OwogIGNvbnN0IGlkID0gdHlwZW9mIHBheWxvYWQuaWQgPT09ICdzdHJpbmcnID8gcGF5bG9hZC5pZCA6IHVuZGVmaW5lZDsKICBjb25zdCBzb3VyY2UgPSB0eXBlb2YgcGF5bG9hZC5zb3VyY2UgPT09ICdzdHJpbmcnID8gcGF5bG9hZC5zb3VyY2UgOiB1bmRlZmluZWQ7CiAgaWYgKCFpZCB8fCB0eXBlb2Ygc291cmNlICE9PSAnc3RyaW5nJykgewogICAgcmV0dXJuOwogIH0KICB0cnkgewogICAgY29uc29sZS5sb2coJ1tNYXJrZG93bldvcmtlcl0gcmVjZWl2ZWQgd29yaycsIGlkLCAnc291cmNlTGVuJywgc291cmNlPy5sZW5ndGggPz8gMCk7CiAgICBjb25zdCBodG1sID0gcGFyc2Uoc291cmNlKTsKICAgIGNvbnNvbGUubG9nKCdbTWFya2Rvd25Xb3JrZXJdIHBhcnNlZCBodG1sIGxlbmd0aCcsIGh0bWw/Lmxlbmd0aCA/PyAwLCAnZm9yJywgaWQpOwogICAgLy8gUmV0dXJuIHRoZSBnZW5lcmF0ZWQgSFRNTCBmb3IgdGhlIGNhbGxlciB0byBjYWNoZSBhbmQgcmVuZGVyCiAgICAvLyBLZWVwIHRoZSBwYXlsb2FkIHNtYWxsOiBzZW5kIGlkICsgaHRtbAogICAgLy8gTWFya2VkIG91dHB1dCBzaG91bGQgYmUgc2FmZS1lbm91Z2ggZm9yIGludGVybmFsIFVJczsgY2FsbGVycyBtYXkgZnVydGhlciBzYW5pdGl6ZSBpZiByZXF1aXJlZC4KICAgIHNjb3BlLnBvc3RNZXNzYWdlKHsgaWQsIGh0bWwgfSk7CiAgfSBjYXRjaCAoZXJyKSB7CiAgICBjb25zb2xlLmVycm9yKCdbTWFya2Rvd25Xb3JrZXJdIHJlbmRlciBlcnJvcicsIGVycik7CiAgICBzY29wZS5wb3N0TWVzc2FnZSh7IGlkLCBodG1sOiBgPHByZT5FcnJvciByZW5kZXJpbmcgbWFya2Rvd246ICR7U3RyaW5nKGVycil9PC9wcmU+YCB9KTsKICB9Cn0pOwo=",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Xn&&Xn.tagName.toUpperCase()==="SCRIPT"&&Xn.src||new URL("index.umd.js",document.baseURI).href),Ua=Xp.toString();console.log("[MarkdownContent] worker url",Ua);const Yo=[];let Ho=!1;const Zp={addEventListener:()=>{},removeEventListener:()=>{},postMessage:()=>{},terminate:()=>{}};let Cn=Zp;const Jp=t=>{console.error("[MarkdownContent] worker error",t)};function qo(t){if(Cn&&Cn!==Zp)try{Cn.removeEventListener("error",Jp)}catch{}Cn=t,Ho=!0;try{Cn.addEventListener("error",Jp)}catch(e){console.warn("[MarkdownContent] failed to register worker error handler",e)}try{for(;Yo.length;){const e=Yo.shift();try{e&&e()}catch{}}}catch(e){console.warn("[MarkdownContent] markWorkerOnline notify failed",e)}}function yO(t){const e=t.indexOf("data:");if(e===-1)return null;const r=t.slice(e).match(/^data:[^;]+;base64,(.*)$/);if(!r)return null;try{const a=r[1],i=atob(a),o=Uint8Array.from(i,c=>c.charCodeAt(0)),s=new Blob([o],{type:"application/javascript"}),l=URL.createObjectURL(s);try{const c=new Worker(l,{type:"module"});return URL.revokeObjectURL(l),c}catch(c){return URL.revokeObjectURL(l),console.error("[MarkdownContent] failed to initialize worker from data URI blob",c),null}}catch(a){return console.warn("[MarkdownContent] failed to decode embedded data URI",a),null}}async function IO(t){try{let e="";const n=await fetch(t);if(e=await n.text(),n.ok||console.warn("[MarkdownContent] fetch worker non-ok",n.status,n.statusText),!e){console.warn("[MarkdownContent] worker fetch returned empty content; aborting worker init.");return}if(e.trim().startsWith("<")){console.warn("[MarkdownContent] worker fetch returned HTML; dev server may be redirecting. Aborting worker init.");return}const r=new Blob([e],{type:"application/javascript"}),a=URL.createObjectURL(r);try{const i=new Worker(a,{type:"module"});qo(i)}catch(i){console.error("[MarkdownContent] failed to initialize worker from blob",i)}finally{URL.revokeObjectURL(a)}}catch(e){console.error("[MarkdownContent] fetch worker failed",e)}}(()=>{if(Ua.includes("data:")){const t=yO(Ua);if(t){qo(t);return}console.warn("[MarkdownContent] data URI bootstrap failed; worker will remain offline until fallback succeeds");return}try{const t=new Worker(Xp,{type:"module"});qo(t)}catch(t){console.warn("[MarkdownContent] worker constructor failed, will try fetch+blob fallback",t),IO(Ua)}})();const Gr=new Map;function AO(t){const e=t.slice(0,64),n=t.length>64?t.slice(-64):"";return`${t.length}:${e}:${n}`}function Yr({content:t,className:e="",fallback:n=u.jsx("div",{"aria-busy":!0,children:"Rendering…"})}){const r=AO(t),[a,i]=y.useState(()=>Gr.get(r)??null);y.useEffect(()=>{if(Gr.has(r)){const g=Gr.get(r)??null;i(g);return}let s=!0,l=!1;const c=g=>{const f=g.data;if(!f||f.id!==r||!s)return;l=!0;const E=f.html??"";Gr.set(r,E),i(E)};Cn.addEventListener("message",c);const d=()=>{try{Cn.postMessage({id:r,source:t})}catch(g){console.error("[MarkdownContent] worker.postMessage threw",g)}};Ho?d():Yo.push(d);const p=((g,f)=>f?g>2e4?1e4:g>8e3?5e3:g>2e3?2e3:600:Math.min(1e4,1e3+Math.floor(g*.5)))(t.length,Ho),m=window.setTimeout(async()=>{if(!l){console.warn("[MarkdownContent] worker timeout (ms="+p+"), falling back to main-thread parse for",r);try{const g=await Promise.resolve().then(()=>kM),f=g&&(g.parse||g.default&&g.default.parse),E=f?f(t):"";Gr.set(r,E),s&&i(E)}catch(g){console.error("[MarkdownContent] fallback parse failed",g)}}},p);return()=>{s=!1,clearTimeout(m),Cn.removeEventListener("message",c)}},[t,r]);const o=y.useRef(null);return y.useEffect(()=>{if(!a)return;const s=o.current;if(!s)return;const l=Array.from(s.querySelectorAll("pre code"));if(!l.length)return;let c=null,d=!1;const _=(m,g)=>{for(const f of m){if(!f.isIntersecting)continue;const E=f.target;if(!c)Promise.resolve().then(()=>o0).then(S=>{if(!d){c=S.default||S;try{l.forEach(T=>{s.contains(T)&&c.highlightElement(T)})}catch{}}}).catch(()=>{});else try{c.highlightElement(E)}catch{}g.unobserve(E)}},p=new IntersectionObserver(_,{root:s,threshold:.1});return l.forEach(m=>p.observe(m)),()=>{d=!0,p.disconnect()}},[a]),a?u.jsx("div",{ref:o,className:$("markdown prose max-w-none break-words dark:prose-invert",e),dangerouslySetInnerHTML:{__html:a}}):u.jsx("div",{className:$("markdown prose max-w-none break-words dark:prose-invert",e),children:n})}async function em(t,e){return await kt(t,{responseType:"blob",onDownloadProgress:r=>{try{e&&r.lengthComputable}catch{}},maxBodyLength:1/0})}async function tm(t,e){return await(await em(`/chat/files/${t}/view`,e)).text()}async function xO(t,e){const n=await em(`/chat/files/${t}/download`,e),r=URL.createObjectURL(n);let a=`file_${t}`;try{const o=await kt(`/chat/files/${t}`);a=(o==null?void 0:o.filename)??a}catch{}const i=document.createElement("a");i.href=r,i.download=a,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(r),6e4)}const DO=1,wO=1e6;let Vo=0;function MO(){return Vo=(Vo+1)%Number.MAX_SAFE_INTEGER,Vo.toString()}const zo=new Map,nm=t=>{if(zo.has(t))return;const e=setTimeout(()=>{zo.delete(t),Hr({type:"REMOVE_TOAST",toastId:t})},wO);zo.set(t,e)},LO=(t,e)=>{switch(e.type){case"ADD_TOAST":return{...t,toasts:[e.toast,...t.toasts].slice(0,DO)};case"UPDATE_TOAST":return{...t,toasts:t.toasts.map(n=>n.id===e.toast.id?{...n,...e.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=e;return n?nm(n):t.toasts.forEach(r=>{nm(r.id)}),{...t,toasts:t.toasts.map(r=>r.id===n||n===void 0?{...r,open:!1}:r)}}case"REMOVE_TOAST":return e.toastId===void 0?{...t,toasts:[]}:{...t,toasts:t.toasts.filter(n=>n.id!==e.toastId)}}},Fa=[];let Ba={toasts:[]};function Hr(t){Ba=LO(Ba,t),Fa.forEach(e=>{e(Ba)})}function PO({...t}){const e=MO(),n=a=>Hr({type:"UPDATE_TOAST",toast:{...a,id:e}}),r=()=>Hr({type:"DISMISS_TOAST",toastId:e});return Hr({type:"ADD_TOAST",toast:{...t,id:e,open:!0,onOpenChange:a=>{a||r()}}}),{id:e,dismiss:r,update:n}}function $o(){const[t,e]=b.useState(Ba);return b.useEffect(()=>(Fa.push(e),()=>{const n=Fa.indexOf(e);n>-1&&Fa.splice(n,1)}),[t]),{...t,toast:PO,dismiss:n=>Hr({type:"DISMISS_TOAST",toastId:n})}}function mt(t){const e=b.useRef(t);return b.useEffect(()=>{e.current=t}),b.useMemo(()=>(...n)=>{var r;return(r=e.current)==null?void 0:r.call(e,...n)},[])}function kO(t,e=globalThis==null?void 0:globalThis.document){const n=mt(t);b.useEffect(()=>{const r=a=>{a.key==="Escape"&&n(a)};return e.addEventListener("keydown",r,{capture:!0}),()=>e.removeEventListener("keydown",r,{capture:!0})},[n,e])}var UO="DismissableLayer",Wo="dismissableLayer.update",FO="dismissableLayer.pointerDownOutside",BO="dismissableLayer.focusOutside",rm,am=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),qr=b.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:o,onDismiss:s,...l}=t,c=b.useContext(am),[d,_]=b.useState(null),p=(d==null?void 0:d.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,m]=b.useState({}),g=Fe(e,N=>_(N)),f=Array.from(c.layers),[E]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),S=f.indexOf(E),T=d?f.indexOf(d):-1,h=c.layersWithOutsidePointerEventsDisabled.size>0,v=T>=S,C=HO(N=>{const O=N.target,D=[...c.branches].some(w=>w.contains(O));!v||D||(a==null||a(N),o==null||o(N),N.defaultPrevented||s==null||s())},p),R=qO(N=>{const O=N.target;[...c.branches].some(w=>w.contains(O))||(i==null||i(N),o==null||o(N),N.defaultPrevented||s==null||s())},p);return kO(N=>{T===c.layers.size-1&&(r==null||r(N),!N.defaultPrevented&&s&&(N.preventDefault(),s()))},p),b.useEffect(()=>{if(d)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(rm=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(d)),c.layers.add(d),im(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=rm)}},[d,p,n,c]),b.useEffect(()=>()=>{d&&(c.layers.delete(d),c.layersWithOutsidePointerEventsDisabled.delete(d),im())},[d,c]),b.useEffect(()=>{const N=()=>m({});return document.addEventListener(Wo,N),()=>document.removeEventListener(Wo,N)},[]),u.jsx(Ie.div,{...l,ref:g,style:{pointerEvents:h?v?"auto":"none":void 0,...t.style},onFocusCapture:de(t.onFocusCapture,R.onFocusCapture),onBlurCapture:de(t.onBlurCapture,R.onBlurCapture),onPointerDownCapture:de(t.onPointerDownCapture,C.onPointerDownCapture)})});qr.displayName=UO;var GO="DismissableLayerBranch",YO=b.forwardRef((t,e)=>{const n=b.useContext(am),r=b.useRef(null),a=Fe(e,r);return b.useEffect(()=>{const i=r.current;if(i)return n.branches.add(i),()=>{n.branches.delete(i)}},[n.branches]),u.jsx(Ie.div,{...t,ref:a})});YO.displayName=GO;function HO(t,e=globalThis==null?void 0:globalThis.document){const n=mt(t),r=b.useRef(!1),a=b.useRef(()=>{});return b.useEffect(()=>{const i=s=>{if(s.target&&!r.current){let l=function(){om(FO,n,c,{discrete:!0})};const c={originalEvent:s};s.pointerType==="touch"?(e.removeEventListener("click",a.current),a.current=l,e.addEventListener("click",a.current,{once:!0})):l()}else e.removeEventListener("click",a.current);r.current=!1},o=window.setTimeout(()=>{e.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(o),e.removeEventListener("pointerdown",i),e.removeEventListener("click",a.current)}},[e,n]),{onPointerDownCapture:()=>r.current=!0}}function qO(t,e=globalThis==null?void 0:globalThis.document){const n=mt(t),r=b.useRef(!1);return b.useEffect(()=>{const a=i=>{i.target&&!r.current&&om(BO,n,{originalEvent:i},{discrete:!1})};return e.addEventListener("focusin",a),()=>e.removeEventListener("focusin",a)},[e,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function im(){const t=new CustomEvent(Wo);document.dispatchEvent(t)}function om(t,e,n,{discrete:r}){const a=n.originalEvent.target,i=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&a.addEventListener(t,e,{once:!0}),r?zp(a,i):a.dispatchEvent(i)}var Ko="focusScope.autoFocusOnMount",Qo="focusScope.autoFocusOnUnmount",sm={bubbles:!1,cancelable:!0},VO="FocusScope",Ga=b.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...o}=t,[s,l]=b.useState(null),c=mt(a),d=mt(i),_=b.useRef(null),p=Fe(e,f=>l(f)),m=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(r){let f=function(h){if(m.paused||!s)return;const v=h.target;s.contains(v)?_.current=v:Rn(_.current,{select:!0})},E=function(h){if(m.paused||!s)return;const v=h.relatedTarget;v!==null&&(s.contains(v)||Rn(_.current,{select:!0}))},S=function(h){if(document.activeElement===document.body)for(const C of h)C.removedNodes.length>0&&Rn(s)};document.addEventListener("focusin",f),document.addEventListener("focusout",E);const T=new MutationObserver(S);return s&&T.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",f),document.removeEventListener("focusout",E),T.disconnect()}}},[r,s,m.paused]),b.useEffect(()=>{if(s){dm.add(m);const f=document.activeElement;if(!s.contains(f)){const S=new CustomEvent(Ko,sm);s.addEventListener(Ko,c),s.dispatchEvent(S),S.defaultPrevented||(zO(jO(lm(s)),{select:!0}),document.activeElement===f&&Rn(s))}return()=>{s.removeEventListener(Ko,c),setTimeout(()=>{const S=new CustomEvent(Qo,sm);s.addEventListener(Qo,d),s.dispatchEvent(S),S.defaultPrevented||Rn(f??document.body,{select:!0}),s.removeEventListener(Qo,d),dm.remove(m)},0)}}},[s,c,d,m]);const g=b.useCallback(f=>{if(!n&&!r||m.paused)return;const E=f.key==="Tab"&&!f.altKey&&!f.ctrlKey&&!f.metaKey,S=document.activeElement;if(E&&S){const T=f.currentTarget,[h,v]=$O(T);h&&v?!f.shiftKey&&S===v?(f.preventDefault(),n&&Rn(h,{select:!0})):f.shiftKey&&S===h&&(f.preventDefault(),n&&Rn(v,{select:!0})):S===T&&f.preventDefault()}},[n,r,m.paused]);return u.jsx(Ie.div,{tabIndex:-1,...o,ref:p,onKeyDown:g})});Ga.displayName=VO;function zO(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(Rn(r,{select:e}),document.activeElement!==n)return}function $O(t){const e=lm(t),n=cm(e,t),r=cm(e.reverse(),t);return[n,r]}function lm(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const a=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||a?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function cm(t,e){for(const n of t)if(!WO(n,{upTo:e}))return n}function WO(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function KO(t){return t instanceof HTMLInputElement&&"select"in t}function Rn(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&KO(t)&&e&&t.select()}}var dm=QO();function QO(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=um(t,e),t.unshift(e)},remove(e){var n;t=um(t,e),(n=t[0])==null||n.resume()}}}function um(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function jO(t){return t.filter(e=>e.tagName!=="A")}var XO="Portal",Ya=b.forwardRef((t,e)=>{var s;const{container:n,...r}=t,[a,i]=b.useState(!1);_t(()=>i(!0),[]);const o=n||a&&((s=globalThis==null?void 0:globalThis.document)==null?void 0:s.body);return o?En.createPortal(u.jsx(Ie.div,{...r,ref:e}),o):null});Ya.displayName=XO;var jo=0;function Xo(){b.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??_m()),document.body.insertAdjacentElement("beforeend",t[1]??_m()),jo++,()=>{jo===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),jo--}},[])}function _m(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var nn=function(){return nn=Object.assign||function(e){for(var n,r=1,a=arguments.length;r<a;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},nn.apply(this,arguments)};function pm(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,r=Object.getOwnPropertySymbols(t);a<r.length;a++)e.indexOf(r[a])<0&&Object.prototype.propertyIsEnumerable.call(t,r[a])&&(n[r[a]]=t[r[a]]);return n}function ZO(t,e,n){if(n||arguments.length===2)for(var r=0,a=e.length,i;r<a;r++)(i||!(r in e))&&(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return t.concat(i||Array.prototype.slice.call(e))}typeof SuppressedError=="function"&&SuppressedError;var Ha="right-scroll-bar-position",qa="width-before-scroll-bar",JO="with-scroll-bars-hidden",ey="--removed-body-scroll-bar-size";function Zo(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function ty(t,e){var n=y.useState(function(){return{value:t,callback:e,facade:{get current(){return n.value},set current(r){var a=n.value;a!==r&&(n.value=r,n.callback(r,a))}}}})[0];return n.callback=e,n.facade}var ny=typeof window<"u"?b.useLayoutEffect:b.useEffect,mm=new WeakMap;function ry(t,e){var n=ty(null,function(r){return t.forEach(function(a){return Zo(a,r)})});return ny(function(){var r=mm.get(n);if(r){var a=new Set(r),i=new Set(t),o=n.current;a.forEach(function(s){i.has(s)||Zo(s,null)}),i.forEach(function(s){a.has(s)||Zo(s,o)})}mm.set(n,t)},[t]),n}function ay(t){return t}function iy(t,e){e===void 0&&(e=ay);var n=[],r=!1,a={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:t},useMedium:function(i){var o=e(i,r);return n.push(o),function(){n=n.filter(function(s){return s!==o})}},assignSyncMedium:function(i){for(r=!0;n.length;){var o=n;n=[],o.forEach(i)}n={push:function(s){return i(s)},filter:function(){return n}}},assignMedium:function(i){r=!0;var o=[];if(n.length){var s=n;n=[],s.forEach(i),o=n}var l=function(){var d=o;o=[],d.forEach(i)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(d){o.push(d),c()},filter:function(d){return o=o.filter(d),n}}}};return a}function oy(t){t===void 0&&(t={});var e=iy(null);return e.options=nn({async:!0,ssr:!1},t),e}var gm=function(t){var e=t.sideCar,n=pm(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=e.read();if(!r)throw new Error("Sidecar medium not found");return b.createElement(r,nn({},n))};gm.isSideCarExport=!0;function sy(t,e){return t.useMedium(e),gm}var Em=oy(),Jo=function(){},Va=b.forwardRef(function(t,e){var n=b.useRef(null),r=b.useState({onScrollCapture:Jo,onWheelCapture:Jo,onTouchMoveCapture:Jo}),a=r[0],i=r[1],o=t.forwardProps,s=t.children,l=t.className,c=t.removeScrollBar,d=t.enabled,_=t.shards,p=t.sideCar,m=t.noRelative,g=t.noIsolation,f=t.inert,E=t.allowPinchZoom,S=t.as,T=S===void 0?"div":S,h=t.gapMode,v=pm(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=p,R=ry([n,e]),N=nn(nn({},v),a);return b.createElement(b.Fragment,null,d&&b.createElement(C,{sideCar:Em,removeScrollBar:c,shards:_,noRelative:m,noIsolation:g,inert:f,setCallbacks:i,allowPinchZoom:!!E,lockRef:n,gapMode:h}),o?b.cloneElement(b.Children.only(s),nn(nn({},N),{ref:R})):b.createElement(T,nn({},N,{className:l,ref:R}),s))});Va.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Va.classNames={fullWidth:qa,zeroRight:Ha};var ly=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function cy(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=ly();return e&&t.setAttribute("nonce",e),t}function dy(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function uy(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var _y=function(){var t=0,e=null;return{add:function(n){t==0&&(e=cy())&&(dy(e,n),uy(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},py=function(){var t=_y();return function(e,n){b.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&n])}},fm=function(){var t=py(),e=function(n){var r=n.styles,a=n.dynamic;return t(r,a),null};return e},my={left:0,top:0,right:0,gap:0},es=function(t){return parseInt(t||"",10)||0},gy=function(t){var e=window.getComputedStyle(document.body),n=e[t==="padding"?"paddingLeft":"marginLeft"],r=e[t==="padding"?"paddingTop":"marginTop"],a=e[t==="padding"?"paddingRight":"marginRight"];return[es(n),es(r),es(a)]},Ey=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return my;var e=gy(t),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-n+e[2]-e[0])}},fy=fm(),ar="data-scroll-locked",Sy=function(t,e,n,r){var a=t.left,i=t.top,o=t.right,s=t.gap;return n===void 0&&(n="margin"),`
|
|
34
34
|
.`.concat(JO,` {
|
|
35
35
|
overflow: hidden `).concat(r,`;
|
|
36
36
|
padding-right: `).concat(s,"px ").concat(r,`;
|
package/package.json
CHANGED