@cuadra-ai/uikit 0.1.15 → 0.1.17

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.
@@ -1,48 +1,40 @@
1
- (function(pt,yt){typeof exports=="object"&&typeof module!="undefined"?yt(exports):typeof define=="function"&&define.amd?define(["exports"],yt):(pt=typeof globalThis!="undefined"?globalThis:pt||self,yt(pt.CuadraUIKit={}))})(this,(function(pt){"use strict";var fO=Object.defineProperty,dO=Object.defineProperties;var hO=Object.getOwnPropertyDescriptors;var Ju=Object.getOwnPropertySymbols;var yS=Object.prototype.hasOwnProperty,bS=Object.prototype.propertyIsEnumerable;var Kd=(pt,yt)=>(yt=Symbol[pt])?yt:Symbol.for("Symbol."+pt),vS=pt=>{throw TypeError(pt)},xS=Math.pow,Jd=(pt,yt,At)=>yt in pt?fO(pt,yt,{enumerable:!0,configurable:!0,writable:!0,value:At}):pt[yt]=At,_=(pt,yt)=>{for(var At in yt||(yt={}))yS.call(yt,At)&&Jd(pt,At,yt[At]);if(Ju)for(var At of Ju(yt))bS.call(yt,At)&&Jd(pt,At,yt[At]);return pt},G=(pt,yt)=>dO(pt,hO(yt));var gt=(pt,yt)=>{var At={};for(var Kt in pt)yS.call(pt,Kt)&&yt.indexOf(Kt)<0&&(At[Kt]=pt[Kt]);if(pt!=null&&Ju)for(var Kt of Ju(pt))yt.indexOf(Kt)<0&&bS.call(pt,Kt)&&(At[Kt]=pt[Kt]);return At};var Y=(pt,yt,At)=>Jd(pt,typeof yt!="symbol"?yt+"":yt,At),SS=(pt,yt,At)=>yt.has(pt)||vS("Cannot "+At);var pn=(pt,yt,At)=>(SS(pt,yt,"read from private field"),At?At.call(pt):yt.get(pt)),ki=(pt,yt,At)=>yt.has(pt)?vS("Cannot add the same private member more than once"):yt instanceof WeakSet?yt.add(pt):yt.set(pt,At),Ri=(pt,yt,At,Kt)=>(SS(pt,yt,"write to private field"),Kt?Kt.call(pt,At):yt.set(pt,At),At);var W=(pt,yt,At)=>new Promise((Kt,We)=>{var Ee=ve=>{try{Ie(At.next(ve))}catch(en){We(en)}},tn=ve=>{try{Ie(At.throw(ve))}catch(en){We(en)}},Ie=ve=>ve.done?Kt(ve.value):Promise.resolve(ve.value).then(Ee,tn);Ie((At=At.apply(pt,yt)).next())}),gr=function(pt,yt){this[0]=pt,this[1]=yt},Kl=(pt,yt,At)=>{var Kt=(tn,Ie,ve,en)=>{try{var E=At[tn](Ie),Sa=(Ie=E.value)instanceof gr,Ct=E.done;Promise.resolve(Sa?Ie[0]:Ie).then(kn=>Sa?Kt(tn==="return"?tn:"next",Ie[1]?{done:kn.done,value:kn.value}:kn,ve,en):ve({value:kn,done:Ct})).catch(kn=>Kt("throw",kn,ve,en))}catch(kn){en(kn)}},We=tn=>Ee[tn]=Ie=>new Promise((ve,en)=>Kt(tn,Ie,ve,en)),Ee={};return At=At.apply(pt,yt),Ee[Kd("asyncIterator")]=()=>Ee,We("next"),We("throw"),We("return"),Ee};var xa=(pt,yt,At)=>(yt=pt[Kd("asyncIterator")])?yt.call(pt):(pt=pt[Kd("iterator")](),yt={},At=(Kt,We)=>(We=pt[Kt])&&(yt[Kt]=Ee=>new Promise((tn,Ie,ve)=>(Ee=We.call(pt,Ee),ve=Ee.done,Promise.resolve(Ee.value).then(en=>tn({value:en,done:ve}),Ie)))),At("next"),At("return"),yt);var Nn,ta,gn,yy,tl,by,el,nl,rl,vy,xy;var yt=typeof document!="undefined"?document.currentScript:null;function At(t,n){for(var a=0;a<n.length;a++){const i=n[a];if(typeof i!="string"&&!Array.isArray(i)){for(const s in i)if(s!=="default"&&!(s in t)){const o=Object.getOwnPropertyDescriptor(i,s);o&&Object.defineProperty(t,s,o.get?o:{enumerable:!0,get:()=>i[s]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}function Kt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var We={exports:{}},Ee={};var tn;function Ie(){if(tn)return Ee;tn=1;var t=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function a(i,s,o){var c=null;if(o!==void 0&&(c=""+o),s.key!==void 0&&(c=""+s.key),"key"in s){o={};for(var d in s)d!=="key"&&(o[d]=s[d])}else o=s;return s=o.ref,{$$typeof:t,type:i,key:c,ref:s!==void 0?s:null,props:o}}return Ee.Fragment=n,Ee.jsx=a,Ee.jsxs=a,Ee}var ve;function en(){return ve||(ve=1,We.exports=Ie()),We.exports}var E=en(),Sa={exports:{}},Ct={};var kn;function _S(){if(kn)return Ct;kn=1;var t=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),o=Symbol.for("react.consumer"),c=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),v=Symbol.iterator;function x(M){return M===null||typeof M!="object"?null:(M=v&&M[v]||M["@@iterator"],typeof M=="function"?M:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},z=Object.assign,D={};function k(M,P,T){this.props=M,this.context=P,this.refs=D,this.updater=T||w}k.prototype.isReactComponent={},k.prototype.setState=function(M,P){if(typeof M!="object"&&typeof M!="function"&&M!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,M,P,"setState")},k.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function q(){}q.prototype=k.prototype;function I(M,P,T){this.props=M,this.context=P,this.refs=D,this.updater=T||w}var at=I.prototype=new q;at.constructor=I,z(at,k.prototype),at.isPureReactComponent=!0;var lt=Array.isArray;function L(){}var J={H:null,A:null,T:null,S:null},st=Object.prototype.hasOwnProperty;function ct(M,P,T){var ut=T.ref;return{$$typeof:t,type:M,key:P,ref:ut!==void 0?ut:null,props:T}}function j(M,P){return ct(M.type,P,M.props)}function tt(M){return typeof M=="object"&&M!==null&&M.$$typeof===t}function $(M){var P={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(T){return P[T]})}var bt=/\/+/g;function ot(M,P){return typeof M=="object"&&M!==null&&M.key!=null?$(""+M.key):P.toString(36)}function nt(M){switch(M.status){case"fulfilled":return M.value;case"rejected":throw M.reason;default:switch(typeof M.status=="string"?M.then(L,L):(M.status="pending",M.then(function(P){M.status==="pending"&&(M.status="fulfilled",M.value=P)},function(P){M.status==="pending"&&(M.status="rejected",M.reason=P)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function H(M,P,T,ut,vt){var mt=typeof M;(mt==="undefined"||mt==="boolean")&&(M=null);var Ot=!1;if(M===null)Ot=!0;else switch(mt){case"bigint":case"string":case"number":Ot=!0;break;case"object":switch(M.$$typeof){case t:case n:Ot=!0;break;case y:return Ot=M._init,H(Ot(M._payload),P,T,ut,vt)}}if(Ot)return vt=vt(M),Ot=ut===""?"."+ot(M,0):ut,lt(vt)?(T="",Ot!=null&&(T=Ot.replace(bt,"$&/")+"/"),H(vt,P,T,"",function(re){return re})):vt!=null&&(tt(vt)&&(vt=j(vt,T+(vt.key==null||M&&M.key===vt.key?"":(""+vt.key).replace(bt,"$&/")+"/")+Ot)),P.push(vt)),1;Ot=0;var _t=ut===""?".":ut+":";if(lt(M))for(var Ht=0;Ht<M.length;Ht++)ut=M[Ht],mt=_t+ot(ut,Ht),Ot+=H(ut,P,T,mt,vt);else if(Ht=x(M),typeof Ht=="function")for(M=Ht.call(M),Ht=0;!(ut=M.next()).done;)ut=ut.value,mt=_t+ot(ut,Ht++),Ot+=H(ut,P,T,mt,vt);else if(mt==="object"){if(typeof M.then=="function")return H(nt(M),P,T,ut,vt);throw P=String(M),Error("Objects are not valid as a React child (found: "+(P==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":P)+"). If you meant to render a collection of children, use an array instead.")}return Ot}function et(M,P,T){if(M==null)return M;var ut=[],vt=0;return H(M,ut,"","",function(mt){return P.call(T,mt,vt++)}),ut}function ft(M){if(M._status===-1){var P=M._result;P=P(),P.then(function(T){(M._status===0||M._status===-1)&&(M._status=1,M._result=T)},function(T){(M._status===0||M._status===-1)&&(M._status=2,M._result=T)}),M._status===-1&&(M._status=0,M._result=P)}if(M._status===1)return M._result.default;throw M._result}var Tt=typeof reportError=="function"?reportError:function(M){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var P=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof M=="object"&&M!==null&&typeof M.message=="string"?String(M.message):String(M),error:M});if(!window.dispatchEvent(P))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",M);return}console.error(M)},C={map:et,forEach:function(M,P,T){et(M,function(){P.apply(this,arguments)},T)},count:function(M){var P=0;return et(M,function(){P++}),P},toArray:function(M){return et(M,function(P){return P})||[]},only:function(M){if(!tt(M))throw Error("React.Children.only expected to receive a single React element child.");return M}};return Ct.Activity=g,Ct.Children=C,Ct.Component=k,Ct.Fragment=a,Ct.Profiler=s,Ct.PureComponent=I,Ct.StrictMode=i,Ct.Suspense=h,Ct.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=J,Ct.__COMPILER_RUNTIME={__proto__:null,c:function(M){return J.H.useMemoCache(M)}},Ct.cache=function(M){return function(){return M.apply(null,arguments)}},Ct.cacheSignal=function(){return null},Ct.cloneElement=function(M,P,T){if(M==null)throw Error("The argument must be a React element, but you passed "+M+".");var ut=z({},M.props),vt=M.key;if(P!=null)for(mt in P.key!==void 0&&(vt=""+P.key),P)!st.call(P,mt)||mt==="key"||mt==="__self"||mt==="__source"||mt==="ref"&&P.ref===void 0||(ut[mt]=P[mt]);var mt=arguments.length-2;if(mt===1)ut.children=T;else if(1<mt){for(var Ot=Array(mt),_t=0;_t<mt;_t++)Ot[_t]=arguments[_t+2];ut.children=Ot}return ct(M.type,vt,ut)},Ct.createContext=function(M){return M={$$typeof:c,_currentValue:M,_currentValue2:M,_threadCount:0,Provider:null,Consumer:null},M.Provider=M,M.Consumer={$$typeof:o,_context:M},M},Ct.createElement=function(M,P,T){var ut,vt={},mt=null;if(P!=null)for(ut in P.key!==void 0&&(mt=""+P.key),P)st.call(P,ut)&&ut!=="key"&&ut!=="__self"&&ut!=="__source"&&(vt[ut]=P[ut]);var Ot=arguments.length-2;if(Ot===1)vt.children=T;else if(1<Ot){for(var _t=Array(Ot),Ht=0;Ht<Ot;Ht++)_t[Ht]=arguments[Ht+2];vt.children=_t}if(M&&M.defaultProps)for(ut in Ot=M.defaultProps,Ot)vt[ut]===void 0&&(vt[ut]=Ot[ut]);return ct(M,mt,vt)},Ct.createRef=function(){return{current:null}},Ct.forwardRef=function(M){return{$$typeof:d,render:M}},Ct.isValidElement=tt,Ct.lazy=function(M){return{$$typeof:y,_payload:{_status:-1,_result:M},_init:ft}},Ct.memo=function(M,P){return{$$typeof:m,type:M,compare:P===void 0?null:P}},Ct.startTransition=function(M){var P=J.T,T={};J.T=T;try{var ut=M(),vt=J.S;vt!==null&&vt(T,ut),typeof ut=="object"&&ut!==null&&typeof ut.then=="function"&&ut.then(L,Tt)}catch(mt){Tt(mt)}finally{P!==null&&T.types!==null&&(P.types=T.types),J.T=P}},Ct.unstable_useCacheRefresh=function(){return J.H.useCacheRefresh()},Ct.use=function(M){return J.H.use(M)},Ct.useActionState=function(M,P,T){return J.H.useActionState(M,P,T)},Ct.useCallback=function(M,P){return J.H.useCallback(M,P)},Ct.useContext=function(M){return J.H.useContext(M)},Ct.useDebugValue=function(){},Ct.useDeferredValue=function(M,P){return J.H.useDeferredValue(M,P)},Ct.useEffect=function(M,P){return J.H.useEffect(M,P)},Ct.useEffectEvent=function(M){return J.H.useEffectEvent(M)},Ct.useId=function(){return J.H.useId()},Ct.useImperativeHandle=function(M,P,T){return J.H.useImperativeHandle(M,P,T)},Ct.useInsertionEffect=function(M,P){return J.H.useInsertionEffect(M,P)},Ct.useLayoutEffect=function(M,P){return J.H.useLayoutEffect(M,P)},Ct.useMemo=function(M,P){return J.H.useMemo(M,P)},Ct.useOptimistic=function(M,P){return J.H.useOptimistic(M,P)},Ct.useReducer=function(M,P,T){return J.H.useReducer(M,P,T)},Ct.useRef=function(M){return J.H.useRef(M)},Ct.useState=function(M){return J.H.useState(M)},Ct.useSyncExternalStore=function(M,P,T){return J.H.useSyncExternalStore(M,P,T)},Ct.useTransition=function(){return J.H.useTransition()},Ct.version="19.2.1",Ct}var Wd;function to(){return Wd||(Wd=1,Sa.exports=_S()),Sa.exports}var R=to();const nn=Kt(R),TS=At({__proto__:null,default:nn},[R]);var eo={exports:{}},Mi={},no={exports:{}},ro={};var th;function ES(){return th||(th=1,(function(t){function n(H,et){var ft=H.length;H.push(et);t:for(;0<ft;){var Tt=ft-1>>>1,C=H[Tt];if(0<s(C,et))H[Tt]=et,H[ft]=C,ft=Tt;else break t}}function a(H){return H.length===0?null:H[0]}function i(H){if(H.length===0)return null;var et=H[0],ft=H.pop();if(ft!==et){H[0]=ft;t:for(var Tt=0,C=H.length,M=C>>>1;Tt<M;){var P=2*(Tt+1)-1,T=H[P],ut=P+1,vt=H[ut];if(0>s(T,ft))ut<C&&0>s(vt,T)?(H[Tt]=vt,H[ut]=ft,Tt=ut):(H[Tt]=T,H[P]=ft,Tt=P);else if(ut<C&&0>s(vt,ft))H[Tt]=vt,H[ut]=ft,Tt=ut;else break t}}return et}function s(H,et){var ft=H.sortIndex-et.sortIndex;return ft!==0?ft:H.id-et.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var o=performance;t.unstable_now=function(){return o.now()}}else{var c=Date,d=c.now();t.unstable_now=function(){return c.now()-d}}var h=[],m=[],y=1,g=null,v=3,x=!1,w=!1,z=!1,D=!1,k=typeof setTimeout=="function"?setTimeout:null,q=typeof clearTimeout=="function"?clearTimeout:null,I=typeof setImmediate!="undefined"?setImmediate:null;function at(H){for(var et=a(m);et!==null;){if(et.callback===null)i(m);else if(et.startTime<=H)i(m),et.sortIndex=et.expirationTime,n(h,et);else break;et=a(m)}}function lt(H){if(z=!1,at(H),!w)if(a(h)!==null)w=!0,L||(L=!0,$());else{var et=a(m);et!==null&&nt(lt,et.startTime-H)}}var L=!1,J=-1,st=5,ct=-1;function j(){return D?!0:!(t.unstable_now()-ct<st)}function tt(){if(D=!1,L){var H=t.unstable_now();ct=H;var et=!0;try{t:{w=!1,z&&(z=!1,q(J),J=-1),x=!0;var ft=v;try{e:{for(at(H),g=a(h);g!==null&&!(g.expirationTime>H&&j());){var Tt=g.callback;if(typeof Tt=="function"){g.callback=null,v=g.priorityLevel;var C=Tt(g.expirationTime<=H);if(H=t.unstable_now(),typeof C=="function"){g.callback=C,at(H),et=!0;break e}g===a(h)&&i(h),at(H)}else i(h);g=a(h)}if(g!==null)et=!0;else{var M=a(m);M!==null&&nt(lt,M.startTime-H),et=!1}}break t}finally{g=null,v=ft,x=!1}et=void 0}}finally{et?$():L=!1}}}var $;if(typeof I=="function")$=function(){I(tt)};else if(typeof MessageChannel!="undefined"){var bt=new MessageChannel,ot=bt.port2;bt.port1.onmessage=tt,$=function(){ot.postMessage(null)}}else $=function(){k(tt,0)};function nt(H,et){J=k(function(){H(t.unstable_now())},et)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(H){H.callback=null},t.unstable_forceFrameRate=function(H){0>H||125<H?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):st=0<H?Math.floor(1e3/H):5},t.unstable_getCurrentPriorityLevel=function(){return v},t.unstable_next=function(H){switch(v){case 1:case 2:case 3:var et=3;break;default:et=v}var ft=v;v=et;try{return H()}finally{v=ft}},t.unstable_requestPaint=function(){D=!0},t.unstable_runWithPriority=function(H,et){switch(H){case 1:case 2:case 3:case 4:case 5:break;default:H=3}var ft=v;v=H;try{return et()}finally{v=ft}},t.unstable_scheduleCallback=function(H,et,ft){var Tt=t.unstable_now();switch(typeof ft=="object"&&ft!==null?(ft=ft.delay,ft=typeof ft=="number"&&0<ft?Tt+ft:Tt):ft=Tt,H){case 1:var C=-1;break;case 2:C=250;break;case 5:C=1073741823;break;case 4:C=1e4;break;default:C=5e3}return C=ft+C,H={id:y++,callback:et,priorityLevel:H,startTime:ft,expirationTime:C,sortIndex:-1},ft>Tt?(H.sortIndex=ft,n(m,H),a(h)===null&&H===a(m)&&(z?(q(J),J=-1):z=!0,nt(lt,ft-Tt))):(H.sortIndex=C,n(h,H),w||x||(w=!0,L||(L=!0,$()))),H},t.unstable_shouldYield=j,t.unstable_wrapCallback=function(H){var et=v;return function(){var ft=v;v=et;try{return H.apply(this,arguments)}finally{v=ft}}}})(ro)),ro}var eh;function CS(){return eh||(eh=1,no.exports=ES()),no.exports}var ao={exports:{}},ze={};var nh;function AS(){if(nh)return ze;nh=1;var t=to();function n(h){var m="https://react.dev/errors/"+h;if(1<arguments.length){m+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)m+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+h+"; visit "+m+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(){}var i={d:{f:a,r:function(){throw Error(n(522))},D:a,C:a,L:a,m:a,X:a,S:a,M:a},p:0,findDOMNode:null},s=Symbol.for("react.portal");function o(h,m,y){var g=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:s,key:g==null?null:""+g,children:h,containerInfo:m,implementation:y}}var c=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(h,m){if(h==="font")return"";if(typeof m=="string")return m==="use-credentials"?m:""}return ze.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,ze.createPortal=function(h,m){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!m||m.nodeType!==1&&m.nodeType!==9&&m.nodeType!==11)throw Error(n(299));return o(h,m,null,y)},ze.flushSync=function(h){var m=c.T,y=i.p;try{if(c.T=null,i.p=2,h)return h()}finally{c.T=m,i.p=y,i.d.f()}},ze.preconnect=function(h,m){typeof h=="string"&&(m?(m=m.crossOrigin,m=typeof m=="string"?m==="use-credentials"?m:"":void 0):m=null,i.d.C(h,m))},ze.prefetchDNS=function(h){typeof h=="string"&&i.d.D(h)},ze.preinit=function(h,m){if(typeof h=="string"&&m&&typeof m.as=="string"){var y=m.as,g=d(y,m.crossOrigin),v=typeof m.integrity=="string"?m.integrity:void 0,x=typeof m.fetchPriority=="string"?m.fetchPriority:void 0;y==="style"?i.d.S(h,typeof m.precedence=="string"?m.precedence:void 0,{crossOrigin:g,integrity:v,fetchPriority:x}):y==="script"&&i.d.X(h,{crossOrigin:g,integrity:v,fetchPriority:x,nonce:typeof m.nonce=="string"?m.nonce:void 0})}},ze.preinitModule=function(h,m){if(typeof h=="string")if(typeof m=="object"&&m!==null){if(m.as==null||m.as==="script"){var y=d(m.as,m.crossOrigin);i.d.M(h,{crossOrigin:y,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0})}}else m==null&&i.d.M(h)},ze.preload=function(h,m){if(typeof h=="string"&&typeof m=="object"&&m!==null&&typeof m.as=="string"){var y=m.as,g=d(y,m.crossOrigin);i.d.L(h,y,{crossOrigin:g,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0,type:typeof m.type=="string"?m.type:void 0,fetchPriority:typeof m.fetchPriority=="string"?m.fetchPriority:void 0,referrerPolicy:typeof m.referrerPolicy=="string"?m.referrerPolicy:void 0,imageSrcSet:typeof m.imageSrcSet=="string"?m.imageSrcSet:void 0,imageSizes:typeof m.imageSizes=="string"?m.imageSizes:void 0,media:typeof m.media=="string"?m.media:void 0})}},ze.preloadModule=function(h,m){if(typeof h=="string")if(m){var y=d(m.as,m.crossOrigin);i.d.m(h,{as:typeof m.as=="string"&&m.as!=="script"?m.as:void 0,crossOrigin:y,integrity:typeof m.integrity=="string"?m.integrity:void 0})}else i.d.m(h)},ze.requestFormReset=function(h){i.d.r(h)},ze.unstable_batchedUpdates=function(h,m){return h(m)},ze.useFormState=function(h,m,y){return c.H.useFormState(h,m,y)},ze.useFormStatus=function(){return c.H.useHostTransitionStatus()},ze.version="19.2.1",ze}var rh;function ah(){if(rh)return ao.exports;rh=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__=="undefined"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(n){console.error(n)}}return t(),ao.exports=AS(),ao.exports}var ih;function kS(){if(ih)return Mi;ih=1;var t=CS(),n=to(),a=ah();function i(e){var r="https://react.dev/errors/"+e;if(1<arguments.length){r+="?args[]="+encodeURIComponent(arguments[1]);for(var l=2;l<arguments.length;l++)r+="&args[]="+encodeURIComponent(arguments[l])}return"Minified React error #"+e+"; visit "+r+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var r=e,l=e;if(e.alternate)for(;r.return;)r=r.return;else{e=r;do r=e,(r.flags&4098)!==0&&(l=r.return),e=r.return;while(e)}return r.tag===3?l:null}function c(e){if(e.tag===13){var r=e.memoizedState;if(r===null&&(e=e.alternate,e!==null&&(r=e.memoizedState)),r!==null)return r.dehydrated}return null}function d(e){if(e.tag===31){var r=e.memoizedState;if(r===null&&(e=e.alternate,e!==null&&(r=e.memoizedState)),r!==null)return r.dehydrated}return null}function h(e){if(o(e)!==e)throw Error(i(188))}function m(e){var r=e.alternate;if(!r){if(r=o(e),r===null)throw Error(i(188));return r!==e?null:e}for(var l=e,u=r;;){var f=l.return;if(f===null)break;var p=f.alternate;if(p===null){if(u=f.return,u!==null){l=u;continue}break}if(f.child===p.child){for(p=f.child;p;){if(p===l)return h(f),e;if(p===u)return h(f),r;p=p.sibling}throw Error(i(188))}if(l.return!==u.return)l=f,u=p;else{for(var b=!1,S=f.child;S;){if(S===l){b=!0,l=f,u=p;break}if(S===u){b=!0,u=f,l=p;break}S=S.sibling}if(!b){for(S=p.child;S;){if(S===l){b=!0,l=p,u=f;break}if(S===u){b=!0,u=p,l=f;break}S=S.sibling}if(!b)throw Error(i(189))}}if(l.alternate!==u)throw Error(i(190))}if(l.tag!==3)throw Error(i(188));return l.stateNode.current===l?e:r}function y(e){var r=e.tag;if(r===5||r===26||r===27||r===6)return e;for(e=e.child;e!==null;){if(r=y(e),r!==null)return r;e=e.sibling}return null}var g=Object.assign,v=Symbol.for("react.element"),x=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),z=Symbol.for("react.fragment"),D=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),q=Symbol.for("react.consumer"),I=Symbol.for("react.context"),at=Symbol.for("react.forward_ref"),lt=Symbol.for("react.suspense"),L=Symbol.for("react.suspense_list"),J=Symbol.for("react.memo"),st=Symbol.for("react.lazy"),ct=Symbol.for("react.activity"),j=Symbol.for("react.memo_cache_sentinel"),tt=Symbol.iterator;function $(e){return e===null||typeof e!="object"?null:(e=tt&&e[tt]||e["@@iterator"],typeof e=="function"?e:null)}var bt=Symbol.for("react.client.reference");function ot(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===bt?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case z:return"Fragment";case k:return"Profiler";case D:return"StrictMode";case lt:return"Suspense";case L:return"SuspenseList";case ct:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case w:return"Portal";case I:return e.displayName||"Context";case q:return(e._context.displayName||"Context")+".Consumer";case at:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case J:return r=e.displayName||null,r!==null?r:ot(e.type)||"Memo";case st:r=e._payload,e=e._init;try{return ot(e(r))}catch(l){}}return null}var nt=Array.isArray,H=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,et=a.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ft={pending:!1,data:null,method:null,action:null},Tt=[],C=-1;function M(e){return{current:e}}function P(e){0>C||(e.current=Tt[C],Tt[C]=null,C--)}function T(e,r){C++,Tt[C]=e.current,e.current=r}var ut=M(null),vt=M(null),mt=M(null),Ot=M(null);function _t(e,r){switch(T(mt,r),T(vt,e),T(ut,null),r.nodeType){case 9:case 11:e=(e=r.documentElement)&&(e=e.namespaceURI)?Hx(e):0;break;default:if(e=r.tagName,r=r.namespaceURI)r=Hx(r),e=qx(r,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}P(ut),T(ut,e)}function Ht(){P(ut),P(vt),P(mt)}function re(e){e.memoizedState!==null&&T(Ot,e);var r=ut.current,l=qx(r,e.type);r!==l&&(T(vt,e),T(ut,l))}function yn(e){vt.current===e&&(P(ut),P(vt)),Ot.current===e&&(P(Ot),Pl._currentValue=ft)}var xr,ea;function Kn(e){if(xr===void 0)try{throw Error()}catch(l){var r=l.stack.trim().match(/\n( *(at )?)/);xr=r&&r[1]||"",ea=-1<l.stack.indexOf(`
2
- at`)?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return`
3
- `+xr+e+ea}var Ha=!1;function qa(e,r){if(!e||Ha)return"";Ha=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var u={DetermineComponentFrameRoot:function(){try{if(r){var K=function(){throw Error()};if(Object.defineProperty(K.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(K,[])}catch(F){var V=F}Reflect.construct(e,[],K)}else{try{K.call()}catch(F){V=F}e.call(K.prototype)}}else{try{throw Error()}catch(F){V=F}(K=e())&&typeof K.catch=="function"&&K.catch(function(){})}}catch(F){if(F&&V&&typeof F.stack=="string")return[F.stack,V.stack]}return[null,null]}};u.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var f=Object.getOwnPropertyDescriptor(u.DetermineComponentFrameRoot,"name");f&&f.configurable&&Object.defineProperty(u.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var p=u.DetermineComponentFrameRoot(),b=p[0],S=p[1];if(b&&S){var A=b.split(`
4
- `),U=S.split(`
5
- `);for(f=u=0;u<A.length&&!A[u].includes("DetermineComponentFrameRoot");)u++;for(;f<U.length&&!U[f].includes("DetermineComponentFrameRoot");)f++;if(u===A.length||f===U.length)for(u=A.length-1,f=U.length-1;1<=u&&0<=f&&A[u]!==U[f];)f--;for(;1<=u&&0<=f;u--,f--)if(A[u]!==U[f]){if(u!==1||f!==1)do if(u--,f--,0>f||A[u]!==U[f]){var X=`
6
- `+A[u].replace(" at new "," at ");return e.displayName&&X.includes("<anonymous>")&&(X=X.replace("<anonymous>",e.displayName)),X}while(1<=u&&0<=f);break}}}finally{Ha=!1,Error.prepareStackTrace=l}return(l=e?e.displayName||e.name:"")?Kn(l):""}function Ds(e,r){switch(e.tag){case 26:case 27:case 5:return Kn(e.type);case 16:return Kn("Lazy");case 13:return e.child!==r&&r!==null?Kn("Suspense Fallback"):Kn("Suspense");case 19:return Kn("SuspenseList");case 0:case 15:return qa(e.type,!1);case 11:return qa(e.type.render,!1);case 1:return qa(e.type,!0);case 31:return Kn("Activity");default:return""}}function Ns(e){try{var r="",l=null;do r+=Ds(e,l),l=e,e=e.return;while(e);return r}catch(u){return`
7
- Error generating stack: `+u.message+`
8
- `+u.stack}}var Va=Object.prototype.hasOwnProperty,Ya=t.unstable_scheduleCallback,al=t.unstable_cancelCallback,Nc=t.unstable_shouldYield,Ic=t.unstable_requestPaint,He=t.unstable_now,jc=t.unstable_getCurrentPriorityLevel,Q=t.unstable_ImmediatePriority,it=t.unstable_UserBlockingPriority,Et=t.unstable_NormalPriority,Dt=t.unstable_LowPriority,Ft=t.unstable_IdlePriority,ln=t.log,Jn=t.unstable_setDisableYieldValue,qe=null,Se=null;function Ge(e){if(typeof ln=="function"&&Jn(e),Se&&typeof Se.setStrictMode=="function")try{Se.setStrictMode(qe,e)}catch(r){}}var Wt=Math.clz32?Math.clz32:J2,Sr=Math.log,In=Math.LN2;function J2(e){return e>>>=0,e===0?32:31-(Sr(e)/In|0)|0}var Is=256,js=262144,Ls=4194304;function na(e){var r=e&42;if(r!==0)return r;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Bs(e,r,l){var u=e.pendingLanes;if(u===0)return 0;var f=0,p=e.suspendedLanes,b=e.pingedLanes;e=e.warmLanes;var S=u&134217727;return S!==0?(u=S&~p,u!==0?f=na(u):(b&=S,b!==0?f=na(b):l||(l=S&~e,l!==0&&(f=na(l))))):(S=u&~p,S!==0?f=na(S):b!==0?f=na(b):l||(l=u&~e,l!==0&&(f=na(l)))),f===0?0:r!==0&&r!==f&&(r&p)===0&&(p=f&-f,l=r&-r,p>=l||p===32&&(l&4194048)!==0)?r:f}function il(e,r){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&r)===0}function $2(e,r){switch(e){case 1:case 2:case 4:case 8:case 64:return r+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return r+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Sy(){var e=Ls;return Ls<<=1,(Ls&62914560)===0&&(Ls=4194304),e}function Lc(e){for(var r=[],l=0;31>l;l++)r.push(e);return r}function ll(e,r){e.pendingLanes|=r,r!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function W2(e,r,l,u,f,p){var b=e.pendingLanes;e.pendingLanes=l,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=l,e.entangledLanes&=l,e.errorRecoveryDisabledLanes&=l,e.shellSuspendCounter=0;var S=e.entanglements,A=e.expirationTimes,U=e.hiddenUpdates;for(l=b&~l;0<l;){var X=31-Wt(l),K=1<<X;S[X]=0,A[X]=-1;var V=U[X];if(V!==null)for(U[X]=null,X=0;X<V.length;X++){var F=V[X];F!==null&&(F.lane&=-536870913)}l&=~K}u!==0&&wy(e,u,0),p!==0&&f===0&&e.tag!==0&&(e.suspendedLanes|=p&~(b&~r))}function wy(e,r,l){e.pendingLanes|=r,e.suspendedLanes&=~r;var u=31-Wt(r);e.entangledLanes|=r,e.entanglements[u]=e.entanglements[u]|1073741824|l&261930}function _y(e,r){var l=e.entangledLanes|=r;for(e=e.entanglements;l;){var u=31-Wt(l),f=1<<u;f&r|e[u]&r&&(e[u]|=r),l&=~f}}function Ty(e,r){var l=r&-r;return l=(l&42)!==0?1:Bc(l),(l&(e.suspendedLanes|r))!==0?0:l}function Bc(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Uc(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function Ey(){var e=et.p;return e!==0?e:(e=window.event,e===void 0?32:cS(e.type))}function Cy(e,r){var l=et.p;try{return et.p=e,r()}finally{et.p=l}}var wr=Math.random().toString(36).slice(2),Ce="__reactFiber$"+wr,Pe="__reactProps$"+wr,Fa="__reactContainer$"+wr,Hc="__reactEvents$"+wr,tM="__reactListeners$"+wr,eM="__reactHandles$"+wr,Ay="__reactResources$"+wr,sl="__reactMarker$"+wr;function qc(e){delete e[Ce],delete e[Pe],delete e[Hc],delete e[tM],delete e[eM]}function Ga(e){var r=e[Ce];if(r)return r;for(var l=e.parentNode;l;){if(r=l[Fa]||l[Ce]){if(l=r.alternate,r.child!==null||l!==null&&l.child!==null)for(e=Qx(e);e!==null;){if(l=e[Ce])return l;e=Qx(e)}return r}e=l,l=e.parentNode}return null}function Pa(e){if(e=e[Ce]||e[Fa]){var r=e.tag;if(r===5||r===6||r===13||r===31||r===26||r===27||r===3)return e}return null}function ul(e){var r=e.tag;if(r===5||r===26||r===27||r===6)return e.stateNode;throw Error(i(33))}function Xa(e){var r=e[Ay];return r||(r=e[Ay]={hoistableStyles:new Map,hoistableScripts:new Map}),r}function _e(e){e[sl]=!0}var ky=new Set,Ry={};function ra(e,r){Qa(e,r),Qa(e+"Capture",r)}function Qa(e,r){for(Ry[e]=r,e=0;e<r.length;e++)ky.add(r[e])}var nM=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),My={},zy={};function rM(e){return Va.call(zy,e)?!0:Va.call(My,e)?!1:nM.test(e)?zy[e]=!0:(My[e]=!0,!1)}function Us(e,r,l){if(rM(r))if(l===null)e.removeAttribute(r);else{switch(typeof l){case"undefined":case"function":case"symbol":e.removeAttribute(r);return;case"boolean":var u=r.toLowerCase().slice(0,5);if(u!=="data-"&&u!=="aria-"){e.removeAttribute(r);return}}e.setAttribute(r,""+l)}}function Hs(e,r,l){if(l===null)e.removeAttribute(r);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(r);return}e.setAttribute(r,""+l)}}function $n(e,r,l,u){if(u===null)e.removeAttribute(l);else{switch(typeof u){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(l);return}e.setAttributeNS(r,l,""+u)}}function bn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Oy(e){var r=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(r==="checkbox"||r==="radio")}function aM(e,r,l){var u=Object.getOwnPropertyDescriptor(e.constructor.prototype,r);if(!e.hasOwnProperty(r)&&typeof u!="undefined"&&typeof u.get=="function"&&typeof u.set=="function"){var f=u.get,p=u.set;return Object.defineProperty(e,r,{configurable:!0,get:function(){return f.call(this)},set:function(b){l=""+b,p.call(this,b)}}),Object.defineProperty(e,r,{enumerable:u.enumerable}),{getValue:function(){return l},setValue:function(b){l=""+b},stopTracking:function(){e._valueTracker=null,delete e[r]}}}}function Vc(e){if(!e._valueTracker){var r=Oy(e)?"checked":"value";e._valueTracker=aM(e,r,""+e[r])}}function Dy(e){if(!e)return!1;var r=e._valueTracker;if(!r)return!0;var l=r.getValue(),u="";return e&&(u=Oy(e)?e.checked?"true":"false":e.value),e=u,e!==l?(r.setValue(e),!0):!1}function qs(e){if(e=e||(typeof document!="undefined"?document:void 0),typeof e=="undefined")return null;try{return e.activeElement||e.body}catch(r){return e.body}}var iM=/[\n"\\]/g;function vn(e){return e.replace(iM,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function Yc(e,r,l,u,f,p,b,S){e.name="",b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"?e.type=b:e.removeAttribute("type"),r!=null?b==="number"?(r===0&&e.value===""||e.value!=r)&&(e.value=""+bn(r)):e.value!==""+bn(r)&&(e.value=""+bn(r)):b!=="submit"&&b!=="reset"||e.removeAttribute("value"),r!=null?Fc(e,b,bn(r)):l!=null?Fc(e,b,bn(l)):u!=null&&e.removeAttribute("value"),f==null&&p!=null&&(e.defaultChecked=!!p),f!=null&&(e.checked=f&&typeof f!="function"&&typeof f!="symbol"),S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?e.name=""+bn(S):e.removeAttribute("name")}function Ny(e,r,l,u,f,p,b,S){if(p!=null&&typeof p!="function"&&typeof p!="symbol"&&typeof p!="boolean"&&(e.type=p),r!=null||l!=null){if(!(p!=="submit"&&p!=="reset"||r!=null)){Vc(e);return}l=l!=null?""+bn(l):"",r=r!=null?""+bn(r):l,S||r===e.value||(e.value=r),e.defaultValue=r}u=u!=null?u:f,u=typeof u!="function"&&typeof u!="symbol"&&!!u,e.checked=S?e.checked:!!u,e.defaultChecked=!!u,b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"&&(e.name=b),Vc(e)}function Fc(e,r,l){r==="number"&&qs(e.ownerDocument)===e||e.defaultValue===""+l||(e.defaultValue=""+l)}function Za(e,r,l,u){if(e=e.options,r){r={};for(var f=0;f<l.length;f++)r["$"+l[f]]=!0;for(l=0;l<e.length;l++)f=r.hasOwnProperty("$"+e[l].value),e[l].selected!==f&&(e[l].selected=f),f&&u&&(e[l].defaultSelected=!0)}else{for(l=""+bn(l),r=null,f=0;f<e.length;f++){if(e[f].value===l){e[f].selected=!0,u&&(e[f].defaultSelected=!0);return}r!==null||e[f].disabled||(r=e[f])}r!==null&&(r.selected=!0)}}function Iy(e,r,l){if(r!=null&&(r=""+bn(r),r!==e.value&&(e.value=r),l==null)){e.defaultValue!==r&&(e.defaultValue=r);return}e.defaultValue=l!=null?""+bn(l):""}function jy(e,r,l,u){if(r==null){if(u!=null){if(l!=null)throw Error(i(92));if(nt(u)){if(1<u.length)throw Error(i(93));u=u[0]}l=u}l==null&&(l=""),r=l}l=bn(r),e.defaultValue=l,u=e.textContent,u===l&&u!==""&&u!==null&&(e.value=u),Vc(e)}function Ka(e,r){if(r){var l=e.firstChild;if(l&&l===e.lastChild&&l.nodeType===3){l.nodeValue=r;return}}e.textContent=r}var lM=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function Ly(e,r,l){var u=r.indexOf("--")===0;l==null||typeof l=="boolean"||l===""?u?e.setProperty(r,""):r==="float"?e.cssFloat="":e[r]="":u?e.setProperty(r,l):typeof l!="number"||l===0||lM.has(r)?r==="float"?e.cssFloat=l:e[r]=(""+l).trim():e[r]=l+"px"}function By(e,r,l){if(r!=null&&typeof r!="object")throw Error(i(62));if(e=e.style,l!=null){for(var u in l)!l.hasOwnProperty(u)||r!=null&&r.hasOwnProperty(u)||(u.indexOf("--")===0?e.setProperty(u,""):u==="float"?e.cssFloat="":e[u]="");for(var f in r)u=r[f],r.hasOwnProperty(f)&&l[f]!==u&&Ly(e,f,u)}else for(var p in r)r.hasOwnProperty(p)&&Ly(e,p,r[p])}function Gc(e){if(e.indexOf("-")===-1)return!1;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var sM=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),uM=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Vs(e){return uM.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function Wn(){}var Pc=null;function Xc(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ja=null,$a=null;function Uy(e){var r=Pa(e);if(r&&(e=r.stateNode)){var l=e[Pe]||null;t:switch(e=r.stateNode,r.type){case"input":if(Yc(e,l.value,l.defaultValue,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name),r=l.name,l.type==="radio"&&r!=null){for(l=e;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll('input[name="'+vn(""+r)+'"][type="radio"]'),r=0;r<l.length;r++){var u=l[r];if(u!==e&&u.form===e.form){var f=u[Pe]||null;if(!f)throw Error(i(90));Yc(u,f.value,f.defaultValue,f.defaultValue,f.checked,f.defaultChecked,f.type,f.name)}}for(r=0;r<l.length;r++)u=l[r],u.form===e.form&&Dy(u)}break t;case"textarea":Iy(e,l.value,l.defaultValue);break t;case"select":r=l.value,r!=null&&Za(e,!!l.multiple,r,!1)}}}var Qc=!1;function Hy(e,r,l){if(Qc)return e(r,l);Qc=!0;try{var u=e(r);return u}finally{if(Qc=!1,(Ja!==null||$a!==null)&&(Ru(),Ja&&(r=Ja,e=$a,$a=Ja=null,Uy(r),e)))for(r=0;r<e.length;r++)Uy(e[r])}}function ol(e,r){var l=e.stateNode;if(l===null)return null;var u=l[Pe]||null;if(u===null)return null;l=u[r];t:switch(r){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(u=!u.disabled)||(e=e.type,u=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!u;break t;default:e=!1}if(e)return null;if(l&&typeof l!="function")throw Error(i(231,r,typeof l));return l}var tr=!(typeof window=="undefined"||typeof window.document=="undefined"||typeof window.document.createElement=="undefined"),Zc=!1;if(tr)try{var cl={};Object.defineProperty(cl,"passive",{get:function(){Zc=!0}}),window.addEventListener("test",cl,cl),window.removeEventListener("test",cl,cl)}catch(e){Zc=!1}var _r=null,Kc=null,Ys=null;function qy(){if(Ys)return Ys;var e,r=Kc,l=r.length,u,f="value"in _r?_r.value:_r.textContent,p=f.length;for(e=0;e<l&&r[e]===f[e];e++);var b=l-e;for(u=1;u<=b&&r[l-u]===f[p-u];u++);return Ys=f.slice(e,1<u?1-u:void 0)}function Fs(e){var r=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&r===13&&(e=13)):e=r,e===10&&(e=13),32<=e||e===13?e:0}function Gs(){return!0}function Vy(){return!1}function Xe(e){function r(l,u,f,p,b){this._reactName=l,this._targetInst=f,this.type=u,this.nativeEvent=p,this.target=b,this.currentTarget=null;for(var S in e)e.hasOwnProperty(S)&&(l=e[S],this[S]=l?l(p):p[S]);return this.isDefaultPrevented=(p.defaultPrevented!=null?p.defaultPrevented:p.returnValue===!1)?Gs:Vy,this.isPropagationStopped=Vy,this}return g(r.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=Gs)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=Gs)},persist:function(){},isPersistent:Gs}),r}var aa={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ps=Xe(aa),fl=g({},aa,{view:0,detail:0}),oM=Xe(fl),Jc,$c,dl,Xs=g({},fl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:tf,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==dl&&(dl&&e.type==="mousemove"?(Jc=e.screenX-dl.screenX,$c=e.screenY-dl.screenY):$c=Jc=0,dl=e),Jc)},movementY:function(e){return"movementY"in e?e.movementY:$c}}),Yy=Xe(Xs),cM=g({},Xs,{dataTransfer:0}),fM=Xe(cM),dM=g({},fl,{relatedTarget:0}),Wc=Xe(dM),hM=g({},aa,{animationName:0,elapsedTime:0,pseudoElement:0}),pM=Xe(hM),mM=g({},aa,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),gM=Xe(mM),yM=g({},aa,{data:0}),Fy=Xe(yM),bM={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},vM={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},xM={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function SM(e){var r=this.nativeEvent;return r.getModifierState?r.getModifierState(e):(e=xM[e])?!!r[e]:!1}function tf(){return SM}var wM=g({},fl,{key:function(e){if(e.key){var r=bM[e.key]||e.key;if(r!=="Unidentified")return r}return e.type==="keypress"?(e=Fs(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?vM[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:tf,charCode:function(e){return e.type==="keypress"?Fs(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Fs(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),_M=Xe(wM),TM=g({},Xs,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Gy=Xe(TM),EM=g({},fl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:tf}),CM=Xe(EM),AM=g({},aa,{propertyName:0,elapsedTime:0,pseudoElement:0}),kM=Xe(AM),RM=g({},Xs,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),MM=Xe(RM),zM=g({},aa,{newState:0,oldState:0}),OM=Xe(zM),DM=[9,13,27,32],ef=tr&&"CompositionEvent"in window,hl=null;tr&&"documentMode"in document&&(hl=document.documentMode);var NM=tr&&"TextEvent"in window&&!hl,Py=tr&&(!ef||hl&&8<hl&&11>=hl),Xy=" ",Qy=!1;function Zy(e,r){switch(e){case"keyup":return DM.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ky(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Wa=!1;function IM(e,r){switch(e){case"compositionend":return Ky(r);case"keypress":return r.which!==32?null:(Qy=!0,Xy);case"textInput":return e=r.data,e===Xy&&Qy?null:e;default:return null}}function jM(e,r){if(Wa)return e==="compositionend"||!ef&&Zy(e,r)?(e=qy(),Ys=Kc=_r=null,Wa=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1<r.char.length)return r.char;if(r.which)return String.fromCharCode(r.which)}return null;case"compositionend":return Py&&r.locale!=="ko"?null:r.data;default:return null}}var LM={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Jy(e){var r=e&&e.nodeName&&e.nodeName.toLowerCase();return r==="input"?!!LM[e.type]:r==="textarea"}function $y(e,r,l,u){Ja?$a?$a.push(u):$a=[u]:Ja=u,r=ju(r,"onChange"),0<r.length&&(l=new Ps("onChange","change",null,l,u),e.push({event:l,listeners:r}))}var pl=null,ml=null;function BM(e){Nx(e,0)}function Qs(e){var r=ul(e);if(Dy(r))return e}function Wy(e,r){if(e==="change")return r}var tb=!1;if(tr){var nf;if(tr){var rf="oninput"in document;if(!rf){var eb=document.createElement("div");eb.setAttribute("oninput","return;"),rf=typeof eb.oninput=="function"}nf=rf}else nf=!1;tb=nf&&(!document.documentMode||9<document.documentMode)}function nb(){pl&&(pl.detachEvent("onpropertychange",rb),ml=pl=null)}function rb(e){if(e.propertyName==="value"&&Qs(ml)){var r=[];$y(r,ml,e,Xc(e)),Hy(BM,r)}}function UM(e,r,l){e==="focusin"?(nb(),pl=r,ml=l,pl.attachEvent("onpropertychange",rb)):e==="focusout"&&nb()}function HM(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Qs(ml)}function qM(e,r){if(e==="click")return Qs(r)}function VM(e,r){if(e==="input"||e==="change")return Qs(r)}function YM(e,r){return e===r&&(e!==0||1/e===1/r)||e!==e&&r!==r}var sn=typeof Object.is=="function"?Object.is:YM;function gl(e,r){if(sn(e,r))return!0;if(typeof e!="object"||e===null||typeof r!="object"||r===null)return!1;var l=Object.keys(e),u=Object.keys(r);if(l.length!==u.length)return!1;for(u=0;u<l.length;u++){var f=l[u];if(!Va.call(r,f)||!sn(e[f],r[f]))return!1}return!0}function ab(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function ib(e,r){var l=ab(e);e=0;for(var u;l;){if(l.nodeType===3){if(u=e+l.textContent.length,e<=r&&u>=r)return{node:l,offset:r-e};e=u}t:{for(;l;){if(l.nextSibling){l=l.nextSibling;break t}l=l.parentNode}l=void 0}l=ab(l)}}function lb(e,r){return e&&r?e===r?!0:e&&e.nodeType===3?!1:r&&r.nodeType===3?lb(e,r.parentNode):"contains"in e?e.contains(r):e.compareDocumentPosition?!!(e.compareDocumentPosition(r)&16):!1:!1}function sb(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var r=qs(e.document);r instanceof e.HTMLIFrameElement;){try{var l=typeof r.contentWindow.location.href=="string"}catch(u){l=!1}if(l)e=r.contentWindow;else break;r=qs(e.document)}return r}function af(e){var r=e&&e.nodeName&&e.nodeName.toLowerCase();return r&&(r==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||r==="textarea"||e.contentEditable==="true")}var FM=tr&&"documentMode"in document&&11>=document.documentMode,ti=null,lf=null,yl=null,sf=!1;function ub(e,r,l){var u=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;sf||ti==null||ti!==qs(u)||(u=ti,"selectionStart"in u&&af(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),yl&&gl(yl,u)||(yl=u,u=ju(lf,"onSelect"),0<u.length&&(r=new Ps("onSelect","select",null,r,l),e.push({event:r,listeners:u}),r.target=ti)))}function ia(e,r){var l={};return l[e.toLowerCase()]=r.toLowerCase(),l["Webkit"+e]="webkit"+r,l["Moz"+e]="moz"+r,l}var ei={animationend:ia("Animation","AnimationEnd"),animationiteration:ia("Animation","AnimationIteration"),animationstart:ia("Animation","AnimationStart"),transitionrun:ia("Transition","TransitionRun"),transitionstart:ia("Transition","TransitionStart"),transitioncancel:ia("Transition","TransitionCancel"),transitionend:ia("Transition","TransitionEnd")},uf={},ob={};tr&&(ob=document.createElement("div").style,"AnimationEvent"in window||(delete ei.animationend.animation,delete ei.animationiteration.animation,delete ei.animationstart.animation),"TransitionEvent"in window||delete ei.transitionend.transition);function la(e){if(uf[e])return uf[e];if(!ei[e])return e;var r=ei[e],l;for(l in r)if(r.hasOwnProperty(l)&&l in ob)return uf[e]=r[l];return e}var cb=la("animationend"),fb=la("animationiteration"),db=la("animationstart"),GM=la("transitionrun"),PM=la("transitionstart"),XM=la("transitioncancel"),hb=la("transitionend"),pb=new Map,of="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");of.push("scrollEnd");function jn(e,r){pb.set(e,r),ra(r,[e])}var Zs=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var r=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(r))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},xn=[],ni=0,cf=0;function Ks(){for(var e=ni,r=cf=ni=0;r<e;){var l=xn[r];xn[r++]=null;var u=xn[r];xn[r++]=null;var f=xn[r];xn[r++]=null;var p=xn[r];if(xn[r++]=null,u!==null&&f!==null){var b=u.pending;b===null?f.next=f:(f.next=b.next,b.next=f),u.pending=f}p!==0&&mb(l,f,p)}}function Js(e,r,l,u){xn[ni++]=e,xn[ni++]=r,xn[ni++]=l,xn[ni++]=u,cf|=u,e.lanes|=u,e=e.alternate,e!==null&&(e.lanes|=u)}function ff(e,r,l,u){return Js(e,r,l,u),$s(e)}function sa(e,r){return Js(e,null,null,r),$s(e)}function mb(e,r,l){e.lanes|=l;var u=e.alternate;u!==null&&(u.lanes|=l);for(var f=!1,p=e.return;p!==null;)p.childLanes|=l,u=p.alternate,u!==null&&(u.childLanes|=l),p.tag===22&&(e=p.stateNode,e===null||e._visibility&1||(f=!0)),e=p,p=p.return;return e.tag===3?(p=e.stateNode,f&&r!==null&&(f=31-Wt(l),e=p.hiddenUpdates,u=e[f],u===null?e[f]=[r]:u.push(r),r.lane=l|536870912),p):null}function $s(e){if(50<Ul)throw Ul=0,xd=null,Error(i(185));for(var r=e.return;r!==null;)e=r,r=e.return;return e.tag===3?e.stateNode:null}var ri={};function QM(e,r,l,u){this.tag=e,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=r,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=u,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function un(e,r,l,u){return new QM(e,r,l,u)}function df(e){return e=e.prototype,!(!e||!e.isReactComponent)}function er(e,r){var l=e.alternate;return l===null?(l=un(e.tag,r,e.key,e.mode),l.elementType=e.elementType,l.type=e.type,l.stateNode=e.stateNode,l.alternate=e,e.alternate=l):(l.pendingProps=r,l.type=e.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=e.flags&65011712,l.childLanes=e.childLanes,l.lanes=e.lanes,l.child=e.child,l.memoizedProps=e.memoizedProps,l.memoizedState=e.memoizedState,l.updateQueue=e.updateQueue,r=e.dependencies,l.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext},l.sibling=e.sibling,l.index=e.index,l.ref=e.ref,l.refCleanup=e.refCleanup,l}function gb(e,r){e.flags&=65011714;var l=e.alternate;return l===null?(e.childLanes=0,e.lanes=r,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=l.childLanes,e.lanes=l.lanes,e.child=l.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=l.memoizedProps,e.memoizedState=l.memoizedState,e.updateQueue=l.updateQueue,e.type=l.type,r=l.dependencies,e.dependencies=r===null?null:{lanes:r.lanes,firstContext:r.firstContext}),e}function Ws(e,r,l,u,f,p){var b=0;if(u=e,typeof e=="function")df(e)&&(b=1);else if(typeof e=="string")b=Wz(e,l,ut.current)?26:e==="html"||e==="head"||e==="body"?27:5;else t:switch(e){case ct:return e=un(31,l,r,f),e.elementType=ct,e.lanes=p,e;case z:return ua(l.children,f,p,r);case D:b=8,f|=24;break;case k:return e=un(12,l,r,f|2),e.elementType=k,e.lanes=p,e;case lt:return e=un(13,l,r,f),e.elementType=lt,e.lanes=p,e;case L:return e=un(19,l,r,f),e.elementType=L,e.lanes=p,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case I:b=10;break t;case q:b=9;break t;case at:b=11;break t;case J:b=14;break t;case st:b=16,u=null;break t}b=29,l=Error(i(130,e===null?"null":typeof e,"")),u=null}return r=un(b,l,r,f),r.elementType=e,r.type=u,r.lanes=p,r}function ua(e,r,l,u){return e=un(7,e,u,r),e.lanes=l,e}function hf(e,r,l){return e=un(6,e,null,r),e.lanes=l,e}function yb(e){var r=un(18,null,null,0);return r.stateNode=e,r}function pf(e,r,l){return r=un(4,e.children!==null?e.children:[],e.key,r),r.lanes=l,r.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},r}var bb=new WeakMap;function Sn(e,r){if(typeof e=="object"&&e!==null){var l=bb.get(e);return l!==void 0?l:(r={value:e,source:r,stack:Ns(r)},bb.set(e,r),r)}return{value:e,source:r,stack:Ns(r)}}var ai=[],ii=0,tu=null,bl=0,wn=[],_n=0,Tr=null,Vn=1,Yn="";function nr(e,r){ai[ii++]=bl,ai[ii++]=tu,tu=e,bl=r}function vb(e,r,l){wn[_n++]=Vn,wn[_n++]=Yn,wn[_n++]=Tr,Tr=e;var u=Vn;e=Yn;var f=32-Wt(u)-1;u&=~(1<<f),l+=1;var p=32-Wt(r)+f;if(30<p){var b=f-f%5;p=(u&(1<<b)-1).toString(32),u>>=b,f-=b,Vn=1<<32-Wt(r)+f|l<<f|u,Yn=p+e}else Vn=1<<p|l<<f|u,Yn=e}function mf(e){e.return!==null&&(nr(e,1),vb(e,1,0))}function gf(e){for(;e===tu;)tu=ai[--ii],ai[ii]=null,bl=ai[--ii],ai[ii]=null;for(;e===Tr;)Tr=wn[--_n],wn[_n]=null,Yn=wn[--_n],wn[_n]=null,Vn=wn[--_n],wn[_n]=null}function xb(e,r){wn[_n++]=Vn,wn[_n++]=Yn,wn[_n++]=Tr,Vn=r.id,Yn=r.overflow,Tr=e}var Ae=null,ae=null,Bt=!1,Er=null,Tn=!1,yf=Error(i(519));function Cr(e){var r=Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw vl(Sn(r,e)),yf}function Sb(e){var r=e.stateNode,l=e.type,u=e.memoizedProps;switch(r[Ce]=e,r[Pe]=u,l){case"dialog":It("cancel",r),It("close",r);break;case"iframe":case"object":case"embed":It("load",r);break;case"video":case"audio":for(l=0;l<ql.length;l++)It(ql[l],r);break;case"source":It("error",r);break;case"img":case"image":case"link":It("error",r),It("load",r);break;case"details":It("toggle",r);break;case"input":It("invalid",r),Ny(r,u.value,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name,!0);break;case"select":It("invalid",r);break;case"textarea":It("invalid",r),jy(r,u.value,u.defaultValue,u.children)}l=u.children,typeof l!="string"&&typeof l!="number"&&typeof l!="bigint"||r.textContent===""+l||u.suppressHydrationWarning===!0||Bx(r.textContent,l)?(u.popover!=null&&(It("beforetoggle",r),It("toggle",r)),u.onScroll!=null&&It("scroll",r),u.onScrollEnd!=null&&It("scrollend",r),u.onClick!=null&&(r.onclick=Wn),r=!0):r=!1,r||Cr(e,!0)}function wb(e){for(Ae=e.return;Ae;)switch(Ae.tag){case 5:case 31:case 13:Tn=!1;return;case 27:case 3:Tn=!0;return;default:Ae=Ae.return}}function li(e){if(e!==Ae)return!1;if(!Bt)return wb(e),Bt=!0,!1;var r=e.tag,l;if((l=r!==3&&r!==27)&&((l=r===5)&&(l=e.type,l=!(l!=="form"&&l!=="button")||Id(e.type,e.memoizedProps)),l=!l),l&&ae&&Cr(e),wb(e),r===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(i(317));ae=Xx(e)}else if(r===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(i(317));ae=Xx(e)}else r===27?(r=ae,Hr(e.type)?(e=Hd,Hd=null,ae=e):ae=r):ae=Ae?Cn(e.stateNode.nextSibling):null;return!0}function oa(){ae=Ae=null,Bt=!1}function bf(){var e=Er;return e!==null&&(Je===null?Je=e:Je.push.apply(Je,e),Er=null),e}function vl(e){Er===null?Er=[e]:Er.push(e)}var vf=M(null),ca=null,rr=null;function Ar(e,r,l){T(vf,r._currentValue),r._currentValue=l}function ar(e){e._currentValue=vf.current,P(vf)}function xf(e,r,l){for(;e!==null;){var u=e.alternate;if((e.childLanes&r)!==r?(e.childLanes|=r,u!==null&&(u.childLanes|=r)):u!==null&&(u.childLanes&r)!==r&&(u.childLanes|=r),e===l)break;e=e.return}}function Sf(e,r,l,u){var f=e.child;for(f!==null&&(f.return=e);f!==null;){var p=f.dependencies;if(p!==null){var b=f.child;p=p.firstContext;t:for(;p!==null;){var S=p;p=f;for(var A=0;A<r.length;A++)if(S.context===r[A]){p.lanes|=l,S=p.alternate,S!==null&&(S.lanes|=l),xf(p.return,l,e),u||(b=null);break t}p=S.next}}else if(f.tag===18){if(b=f.return,b===null)throw Error(i(341));b.lanes|=l,p=b.alternate,p!==null&&(p.lanes|=l),xf(b,l,e),b=null}else b=f.child;if(b!==null)b.return=f;else for(b=f;b!==null;){if(b===e){b=null;break}if(f=b.sibling,f!==null){f.return=b.return,b=f;break}b=b.return}f=b}}function si(e,r,l,u){e=null;for(var f=r,p=!1;f!==null;){if(!p){if((f.flags&524288)!==0)p=!0;else if((f.flags&262144)!==0)break}if(f.tag===10){var b=f.alternate;if(b===null)throw Error(i(387));if(b=b.memoizedProps,b!==null){var S=f.type;sn(f.pendingProps.value,b.value)||(e!==null?e.push(S):e=[S])}}else if(f===Ot.current){if(b=f.alternate,b===null)throw Error(i(387));b.memoizedState.memoizedState!==f.memoizedState.memoizedState&&(e!==null?e.push(Pl):e=[Pl])}f=f.return}e!==null&&Sf(r,e,l,u),r.flags|=262144}function eu(e){for(e=e.firstContext;e!==null;){if(!sn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function fa(e){ca=e,rr=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function ke(e){return _b(ca,e)}function nu(e,r){return ca===null&&fa(e),_b(e,r)}function _b(e,r){var l=r._currentValue;if(r={context:r,memoizedValue:l,next:null},rr===null){if(e===null)throw Error(i(308));rr=r,e.dependencies={lanes:0,firstContext:r},e.flags|=524288}else rr=rr.next=r;return l}var ZM=typeof AbortController!="undefined"?AbortController:function(){var e=[],r=this.signal={aborted:!1,addEventListener:function(l,u){e.push(u)}};this.abort=function(){r.aborted=!0,e.forEach(function(l){return l()})}},KM=t.unstable_scheduleCallback,JM=t.unstable_NormalPriority,me={$$typeof:I,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function wf(){return{controller:new ZM,data:new Map,refCount:0}}function xl(e){e.refCount--,e.refCount===0&&KM(JM,function(){e.controller.abort()})}var Sl=null,_f=0,ui=0,oi=null;function $M(e,r){if(Sl===null){var l=Sl=[];_f=0,ui=Cd(),oi={status:"pending",value:void 0,then:function(u){l.push(u)}}}return _f++,r.then(Tb,Tb),r}function Tb(){if(--_f===0&&Sl!==null){oi!==null&&(oi.status="fulfilled");var e=Sl;Sl=null,ui=0,oi=null;for(var r=0;r<e.length;r++)(0,e[r])()}}function WM(e,r){var l=[],u={status:"pending",value:null,reason:null,then:function(f){l.push(f)}};return e.then(function(){u.status="fulfilled",u.value=r;for(var f=0;f<l.length;f++)(0,l[f])(r)},function(f){for(u.status="rejected",u.reason=f,f=0;f<l.length;f++)(0,l[f])(void 0)}),u}var Eb=H.S;H.S=function(e,r){ux=He(),typeof r=="object"&&r!==null&&typeof r.then=="function"&&$M(e,r),Eb!==null&&Eb(e,r)};var da=M(null);function Tf(){var e=da.current;return e!==null?e:te.pooledCache}function ru(e,r){r===null?T(da,da.current):T(da,r.pool)}function Cb(){var e=Tf();return e===null?null:{parent:me._currentValue,pool:e}}var ci=Error(i(460)),Ef=Error(i(474)),au=Error(i(542)),iu={then:function(){}};function Ab(e){return e=e.status,e==="fulfilled"||e==="rejected"}function kb(e,r,l){switch(l=e[l],l===void 0?e.push(r):l!==r&&(r.then(Wn,Wn),r=l),r.status){case"fulfilled":return r.value;case"rejected":throw e=r.reason,Mb(e),e;default:if(typeof r.status=="string")r.then(Wn,Wn);else{if(e=te,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=r,e.status="pending",e.then(function(u){if(r.status==="pending"){var f=r;f.status="fulfilled",f.value=u}},function(u){if(r.status==="pending"){var f=r;f.status="rejected",f.reason=u}})}switch(r.status){case"fulfilled":return r.value;case"rejected":throw e=r.reason,Mb(e),e}throw pa=r,ci}}function ha(e){try{var r=e._init;return r(e._payload)}catch(l){throw l!==null&&typeof l=="object"&&typeof l.then=="function"?(pa=l,ci):l}}var pa=null;function Rb(){if(pa===null)throw Error(i(459));var e=pa;return pa=null,e}function Mb(e){if(e===ci||e===au)throw Error(i(483))}var fi=null,wl=0;function lu(e){var r=wl;return wl+=1,fi===null&&(fi=[]),kb(fi,e,r)}function _l(e,r){r=r.props.ref,e.ref=r!==void 0?r:null}function su(e,r){throw r.$$typeof===v?Error(i(525)):(e=Object.prototype.toString.call(r),Error(i(31,e==="[object Object]"?"object with keys {"+Object.keys(r).join(", ")+"}":e)))}function zb(e){function r(N,O){if(e){var B=N.deletions;B===null?(N.deletions=[O],N.flags|=16):B.push(O)}}function l(N,O){if(!e)return null;for(;O!==null;)r(N,O),O=O.sibling;return null}function u(N){for(var O=new Map;N!==null;)N.key!==null?O.set(N.key,N):O.set(N.index,N),N=N.sibling;return O}function f(N,O){return N=er(N,O),N.index=0,N.sibling=null,N}function p(N,O,B){return N.index=B,e?(B=N.alternate,B!==null?(B=B.index,B<O?(N.flags|=67108866,O):B):(N.flags|=67108866,O)):(N.flags|=1048576,O)}function b(N){return e&&N.alternate===null&&(N.flags|=67108866),N}function S(N,O,B,Z){return O===null||O.tag!==6?(O=hf(B,N.mode,Z),O.return=N,O):(O=f(O,B),O.return=N,O)}function A(N,O,B,Z){var xt=B.type;return xt===z?X(N,O,B.props.children,Z,B.key):O!==null&&(O.elementType===xt||typeof xt=="object"&&xt!==null&&xt.$$typeof===st&&ha(xt)===O.type)?(O=f(O,B.props),_l(O,B),O.return=N,O):(O=Ws(B.type,B.key,B.props,null,N.mode,Z),_l(O,B),O.return=N,O)}function U(N,O,B,Z){return O===null||O.tag!==4||O.stateNode.containerInfo!==B.containerInfo||O.stateNode.implementation!==B.implementation?(O=pf(B,N.mode,Z),O.return=N,O):(O=f(O,B.children||[]),O.return=N,O)}function X(N,O,B,Z,xt){return O===null||O.tag!==7?(O=ua(B,N.mode,Z,xt),O.return=N,O):(O=f(O,B),O.return=N,O)}function K(N,O,B){if(typeof O=="string"&&O!==""||typeof O=="number"||typeof O=="bigint")return O=hf(""+O,N.mode,B),O.return=N,O;if(typeof O=="object"&&O!==null){switch(O.$$typeof){case x:return B=Ws(O.type,O.key,O.props,null,N.mode,B),_l(B,O),B.return=N,B;case w:return O=pf(O,N.mode,B),O.return=N,O;case st:return O=ha(O),K(N,O,B)}if(nt(O)||$(O))return O=ua(O,N.mode,B,null),O.return=N,O;if(typeof O.then=="function")return K(N,lu(O),B);if(O.$$typeof===I)return K(N,nu(N,O),B);su(N,O)}return null}function V(N,O,B,Z){var xt=O!==null?O.key:null;if(typeof B=="string"&&B!==""||typeof B=="number"||typeof B=="bigint")return xt!==null?null:S(N,O,""+B,Z);if(typeof B=="object"&&B!==null){switch(B.$$typeof){case x:return B.key===xt?A(N,O,B,Z):null;case w:return B.key===xt?U(N,O,B,Z):null;case st:return B=ha(B),V(N,O,B,Z)}if(nt(B)||$(B))return xt!==null?null:X(N,O,B,Z,null);if(typeof B.then=="function")return V(N,O,lu(B),Z);if(B.$$typeof===I)return V(N,O,nu(N,B),Z);su(N,B)}return null}function F(N,O,B,Z,xt){if(typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint")return N=N.get(B)||null,S(O,N,""+Z,xt);if(typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case x:return N=N.get(Z.key===null?B:Z.key)||null,A(O,N,Z,xt);case w:return N=N.get(Z.key===null?B:Z.key)||null,U(O,N,Z,xt);case st:return Z=ha(Z),F(N,O,B,Z,xt)}if(nt(Z)||$(Z))return N=N.get(B)||null,X(O,N,Z,xt,null);if(typeof Z.then=="function")return F(N,O,B,lu(Z),xt);if(Z.$$typeof===I)return F(N,O,B,nu(O,Z),xt);su(O,Z)}return null}function dt(N,O,B,Z){for(var xt=null,qt=null,ht=O,Mt=O=0,Lt=null;ht!==null&&Mt<B.length;Mt++){ht.index>Mt?(Lt=ht,ht=null):Lt=ht.sibling;var Vt=V(N,ht,B[Mt],Z);if(Vt===null){ht===null&&(ht=Lt);break}e&&ht&&Vt.alternate===null&&r(N,ht),O=p(Vt,O,Mt),qt===null?xt=Vt:qt.sibling=Vt,qt=Vt,ht=Lt}if(Mt===B.length)return l(N,ht),Bt&&nr(N,Mt),xt;if(ht===null){for(;Mt<B.length;Mt++)ht=K(N,B[Mt],Z),ht!==null&&(O=p(ht,O,Mt),qt===null?xt=ht:qt.sibling=ht,qt=ht);return Bt&&nr(N,Mt),xt}for(ht=u(ht);Mt<B.length;Mt++)Lt=F(ht,N,Mt,B[Mt],Z),Lt!==null&&(e&&Lt.alternate!==null&&ht.delete(Lt.key===null?Mt:Lt.key),O=p(Lt,O,Mt),qt===null?xt=Lt:qt.sibling=Lt,qt=Lt);return e&&ht.forEach(function(Gr){return r(N,Gr)}),Bt&&nr(N,Mt),xt}function wt(N,O,B,Z){if(B==null)throw Error(i(151));for(var xt=null,qt=null,ht=O,Mt=O=0,Lt=null,Vt=B.next();ht!==null&&!Vt.done;Mt++,Vt=B.next()){ht.index>Mt?(Lt=ht,ht=null):Lt=ht.sibling;var Gr=V(N,ht,Vt.value,Z);if(Gr===null){ht===null&&(ht=Lt);break}e&&ht&&Gr.alternate===null&&r(N,ht),O=p(Gr,O,Mt),qt===null?xt=Gr:qt.sibling=Gr,qt=Gr,ht=Lt}if(Vt.done)return l(N,ht),Bt&&nr(N,Mt),xt;if(ht===null){for(;!Vt.done;Mt++,Vt=B.next())Vt=K(N,Vt.value,Z),Vt!==null&&(O=p(Vt,O,Mt),qt===null?xt=Vt:qt.sibling=Vt,qt=Vt);return Bt&&nr(N,Mt),xt}for(ht=u(ht);!Vt.done;Mt++,Vt=B.next())Vt=F(ht,N,Mt,Vt.value,Z),Vt!==null&&(e&&Vt.alternate!==null&&ht.delete(Vt.key===null?Mt:Vt.key),O=p(Vt,O,Mt),qt===null?xt=Vt:qt.sibling=Vt,qt=Vt);return e&&ht.forEach(function(cO){return r(N,cO)}),Bt&&nr(N,Mt),xt}function Zt(N,O,B,Z){if(typeof B=="object"&&B!==null&&B.type===z&&B.key===null&&(B=B.props.children),typeof B=="object"&&B!==null){switch(B.$$typeof){case x:t:{for(var xt=B.key;O!==null;){if(O.key===xt){if(xt=B.type,xt===z){if(O.tag===7){l(N,O.sibling),Z=f(O,B.props.children),Z.return=N,N=Z;break t}}else if(O.elementType===xt||typeof xt=="object"&&xt!==null&&xt.$$typeof===st&&ha(xt)===O.type){l(N,O.sibling),Z=f(O,B.props),_l(Z,B),Z.return=N,N=Z;break t}l(N,O);break}else r(N,O);O=O.sibling}B.type===z?(Z=ua(B.props.children,N.mode,Z,B.key),Z.return=N,N=Z):(Z=Ws(B.type,B.key,B.props,null,N.mode,Z),_l(Z,B),Z.return=N,N=Z)}return b(N);case w:t:{for(xt=B.key;O!==null;){if(O.key===xt)if(O.tag===4&&O.stateNode.containerInfo===B.containerInfo&&O.stateNode.implementation===B.implementation){l(N,O.sibling),Z=f(O,B.children||[]),Z.return=N,N=Z;break t}else{l(N,O);break}else r(N,O);O=O.sibling}Z=pf(B,N.mode,Z),Z.return=N,N=Z}return b(N);case st:return B=ha(B),Zt(N,O,B,Z)}if(nt(B))return dt(N,O,B,Z);if($(B)){if(xt=$(B),typeof xt!="function")throw Error(i(150));return B=xt.call(B),wt(N,O,B,Z)}if(typeof B.then=="function")return Zt(N,O,lu(B),Z);if(B.$$typeof===I)return Zt(N,O,nu(N,B),Z);su(N,B)}return typeof B=="string"&&B!==""||typeof B=="number"||typeof B=="bigint"?(B=""+B,O!==null&&O.tag===6?(l(N,O.sibling),Z=f(O,B),Z.return=N,N=Z):(l(N,O),Z=hf(B,N.mode,Z),Z.return=N,N=Z),b(N)):l(N,O)}return function(N,O,B,Z){try{wl=0;var xt=Zt(N,O,B,Z);return fi=null,xt}catch(ht){if(ht===ci||ht===au)throw ht;var qt=un(29,ht,null,N.mode);return qt.lanes=Z,qt.return=N,qt}finally{}}}var ma=zb(!0),Ob=zb(!1),kr=!1;function Cf(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Af(e,r){e=e.updateQueue,r.updateQueue===e&&(r.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Rr(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Mr(e,r,l){var u=e.updateQueue;if(u===null)return null;if(u=u.shared,(Yt&2)!==0){var f=u.pending;return f===null?r.next=r:(r.next=f.next,f.next=r),u.pending=r,r=$s(e),mb(e,null,l),r}return Js(e,u,r,l),$s(e)}function Tl(e,r,l){if(r=r.updateQueue,r!==null&&(r=r.shared,(l&4194048)!==0)){var u=r.lanes;u&=e.pendingLanes,l|=u,r.lanes=l,_y(e,l)}}function kf(e,r){var l=e.updateQueue,u=e.alternate;if(u!==null&&(u=u.updateQueue,l===u)){var f=null,p=null;if(l=l.firstBaseUpdate,l!==null){do{var b={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};p===null?f=p=b:p=p.next=b,l=l.next}while(l!==null);p===null?f=p=r:p=p.next=r}else f=p=r;l={baseState:u.baseState,firstBaseUpdate:f,lastBaseUpdate:p,shared:u.shared,callbacks:u.callbacks},e.updateQueue=l;return}e=l.lastBaseUpdate,e===null?l.firstBaseUpdate=r:e.next=r,l.lastBaseUpdate=r}var Rf=!1;function El(){if(Rf){var e=oi;if(e!==null)throw e}}function Cl(e,r,l,u){Rf=!1;var f=e.updateQueue;kr=!1;var p=f.firstBaseUpdate,b=f.lastBaseUpdate,S=f.shared.pending;if(S!==null){f.shared.pending=null;var A=S,U=A.next;A.next=null,b===null?p=U:b.next=U,b=A;var X=e.alternate;X!==null&&(X=X.updateQueue,S=X.lastBaseUpdate,S!==b&&(S===null?X.firstBaseUpdate=U:S.next=U,X.lastBaseUpdate=A))}if(p!==null){var K=f.baseState;b=0,X=U=A=null,S=p;do{var V=S.lane&-536870913,F=V!==S.lane;if(F?(jt&V)===V:(u&V)===V){V!==0&&V===ui&&(Rf=!0),X!==null&&(X=X.next={lane:0,tag:S.tag,payload:S.payload,callback:null,next:null});t:{var dt=e,wt=S;V=r;var Zt=l;switch(wt.tag){case 1:if(dt=wt.payload,typeof dt=="function"){K=dt.call(Zt,K,V);break t}K=dt;break t;case 3:dt.flags=dt.flags&-65537|128;case 0:if(dt=wt.payload,V=typeof dt=="function"?dt.call(Zt,K,V):dt,V==null)break t;K=g({},K,V);break t;case 2:kr=!0}}V=S.callback,V!==null&&(e.flags|=64,F&&(e.flags|=8192),F=f.callbacks,F===null?f.callbacks=[V]:F.push(V))}else F={lane:V,tag:S.tag,payload:S.payload,callback:S.callback,next:null},X===null?(U=X=F,A=K):X=X.next=F,b|=V;if(S=S.next,S===null){if(S=f.shared.pending,S===null)break;F=S,S=F.next,F.next=null,f.lastBaseUpdate=F,f.shared.pending=null}}while(!0);X===null&&(A=K),f.baseState=A,f.firstBaseUpdate=U,f.lastBaseUpdate=X,p===null&&(f.shared.lanes=0),Ir|=b,e.lanes=b,e.memoizedState=K}}function Db(e,r){if(typeof e!="function")throw Error(i(191,e));e.call(r)}function Nb(e,r){var l=e.callbacks;if(l!==null)for(e.callbacks=null,e=0;e<l.length;e++)Db(l[e],r)}var di=M(null),uu=M(0);function Ib(e,r){e=hr,T(uu,e),T(di,r),hr=e|r.baseLanes}function Mf(){T(uu,hr),T(di,di.current)}function zf(){hr=uu.current,P(di),P(uu)}var on=M(null),En=null;function zr(e){var r=e.alternate;T(ce,ce.current&1),T(on,e),En===null&&(r===null||di.current!==null||r.memoizedState!==null)&&(En=e)}function Of(e){T(ce,ce.current),T(on,e),En===null&&(En=e)}function jb(e){e.tag===22?(T(ce,ce.current),T(on,e),En===null&&(En=e)):Or()}function Or(){T(ce,ce.current),T(on,on.current)}function cn(e){P(on),En===e&&(En=null),P(ce)}var ce=M(0);function ou(e){for(var r=e;r!==null;){if(r.tag===13){var l=r.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||Bd(l)||Ud(l)))return r}else if(r.tag===19&&(r.memoizedProps.revealOrder==="forwards"||r.memoizedProps.revealOrder==="backwards"||r.memoizedProps.revealOrder==="unstable_legacy-backwards"||r.memoizedProps.revealOrder==="together")){if((r.flags&128)!==0)return r}else if(r.child!==null){r.child.return=r,r=r.child;continue}if(r===e)break;for(;r.sibling===null;){if(r.return===null||r.return===e)return null;r=r.return}r.sibling.return=r.return,r=r.sibling}return null}var ir=0,kt=null,Xt=null,ge=null,cu=!1,hi=!1,ga=!1,fu=0,Al=0,pi=null,tz=0;function ue(){throw Error(i(321))}function Df(e,r){if(r===null)return!1;for(var l=0;l<r.length&&l<e.length;l++)if(!sn(e[l],r[l]))return!1;return!0}function Nf(e,r,l,u,f,p){return ir=p,kt=r,r.memoizedState=null,r.updateQueue=null,r.lanes=0,H.H=e===null||e.memoizedState===null?vv:Zf,ga=!1,p=l(u,f),ga=!1,hi&&(p=Bb(r,l,u,f)),Lb(e),p}function Lb(e){H.H=Ml;var r=Xt!==null&&Xt.next!==null;if(ir=0,ge=Xt=kt=null,cu=!1,Al=0,pi=null,r)throw Error(i(300));e===null||ye||(e=e.dependencies,e!==null&&eu(e)&&(ye=!0))}function Bb(e,r,l,u){kt=e;var f=0;do{if(hi&&(pi=null),Al=0,hi=!1,25<=f)throw Error(i(301));if(f+=1,ge=Xt=null,e.updateQueue!=null){var p=e.updateQueue;p.lastEffect=null,p.events=null,p.stores=null,p.memoCache!=null&&(p.memoCache.index=0)}H.H=xv,p=r(l,u)}while(hi);return p}function ez(){var e=H.H,r=e.useState()[0];return r=typeof r.then=="function"?kl(r):r,e=e.useState()[0],(Xt!==null?Xt.memoizedState:null)!==e&&(kt.flags|=1024),r}function If(){var e=fu!==0;return fu=0,e}function jf(e,r,l){r.updateQueue=e.updateQueue,r.flags&=-2053,e.lanes&=~l}function Lf(e){if(cu){for(e=e.memoizedState;e!==null;){var r=e.queue;r!==null&&(r.pending=null),e=e.next}cu=!1}ir=0,ge=Xt=kt=null,hi=!1,Al=fu=0,pi=null}function Ve(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ge===null?kt.memoizedState=ge=e:ge=ge.next=e,ge}function fe(){if(Xt===null){var e=kt.alternate;e=e!==null?e.memoizedState:null}else e=Xt.next;var r=ge===null?kt.memoizedState:ge.next;if(r!==null)ge=r,Xt=e;else{if(e===null)throw kt.alternate===null?Error(i(467)):Error(i(310));Xt=e,e={memoizedState:Xt.memoizedState,baseState:Xt.baseState,baseQueue:Xt.baseQueue,queue:Xt.queue,next:null},ge===null?kt.memoizedState=ge=e:ge=ge.next=e}return ge}function du(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function kl(e){var r=Al;return Al+=1,pi===null&&(pi=[]),e=kb(pi,e,r),r=kt,(ge===null?r.memoizedState:ge.next)===null&&(r=r.alternate,H.H=r===null||r.memoizedState===null?vv:Zf),e}function hu(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return kl(e);if(e.$$typeof===I)return ke(e)}throw Error(i(438,String(e)))}function Bf(e){var r=null,l=kt.updateQueue;if(l!==null&&(r=l.memoCache),r==null){var u=kt.alternate;u!==null&&(u=u.updateQueue,u!==null&&(u=u.memoCache,u!=null&&(r={data:u.data.map(function(f){return f.slice()}),index:0})))}if(r==null&&(r={data:[],index:0}),l===null&&(l=du(),kt.updateQueue=l),l.memoCache=r,l=r.data[r.index],l===void 0)for(l=r.data[r.index]=Array(e),u=0;u<e;u++)l[u]=j;return r.index++,l}function lr(e,r){return typeof r=="function"?r(e):r}function pu(e){var r=fe();return Uf(r,Xt,e)}function Uf(e,r,l){var u=e.queue;if(u===null)throw Error(i(311));u.lastRenderedReducer=l;var f=e.baseQueue,p=u.pending;if(p!==null){if(f!==null){var b=f.next;f.next=p.next,p.next=b}r.baseQueue=f=p,u.pending=null}if(p=e.baseState,f===null)e.memoizedState=p;else{r=f.next;var S=b=null,A=null,U=r,X=!1;do{var K=U.lane&-536870913;if(K!==U.lane?(jt&K)===K:(ir&K)===K){var V=U.revertLane;if(V===0)A!==null&&(A=A.next={lane:0,revertLane:0,gesture:null,action:U.action,hasEagerState:U.hasEagerState,eagerState:U.eagerState,next:null}),K===ui&&(X=!0);else if((ir&V)===V){U=U.next,V===ui&&(X=!0);continue}else K={lane:0,revertLane:U.revertLane,gesture:null,action:U.action,hasEagerState:U.hasEagerState,eagerState:U.eagerState,next:null},A===null?(S=A=K,b=p):A=A.next=K,kt.lanes|=V,Ir|=V;K=U.action,ga&&l(p,K),p=U.hasEagerState?U.eagerState:l(p,K)}else V={lane:K,revertLane:U.revertLane,gesture:U.gesture,action:U.action,hasEagerState:U.hasEagerState,eagerState:U.eagerState,next:null},A===null?(S=A=V,b=p):A=A.next=V,kt.lanes|=K,Ir|=K;U=U.next}while(U!==null&&U!==r);if(A===null?b=p:A.next=S,!sn(p,e.memoizedState)&&(ye=!0,X&&(l=oi,l!==null)))throw l;e.memoizedState=p,e.baseState=b,e.baseQueue=A,u.lastRenderedState=p}return f===null&&(u.lanes=0),[e.memoizedState,u.dispatch]}function Hf(e){var r=fe(),l=r.queue;if(l===null)throw Error(i(311));l.lastRenderedReducer=e;var u=l.dispatch,f=l.pending,p=r.memoizedState;if(f!==null){l.pending=null;var b=f=f.next;do p=e(p,b.action),b=b.next;while(b!==f);sn(p,r.memoizedState)||(ye=!0),r.memoizedState=p,r.baseQueue===null&&(r.baseState=p),l.lastRenderedState=p}return[p,u]}function Ub(e,r,l){var u=kt,f=fe(),p=Bt;if(p){if(l===void 0)throw Error(i(407));l=l()}else l=r();var b=!sn((Xt||f).memoizedState,l);if(b&&(f.memoizedState=l,ye=!0),f=f.queue,Yf(Vb.bind(null,u,f,e),[e]),f.getSnapshot!==r||b||ge!==null&&ge.memoizedState.tag&1){if(u.flags|=2048,mi(9,{destroy:void 0},qb.bind(null,u,f,l,r),null),te===null)throw Error(i(349));p||(ir&127)!==0||Hb(u,r,l)}return l}function Hb(e,r,l){e.flags|=16384,e={getSnapshot:r,value:l},r=kt.updateQueue,r===null?(r=du(),kt.updateQueue=r,r.stores=[e]):(l=r.stores,l===null?r.stores=[e]:l.push(e))}function qb(e,r,l,u){r.value=l,r.getSnapshot=u,Yb(r)&&Fb(e)}function Vb(e,r,l){return l(function(){Yb(r)&&Fb(e)})}function Yb(e){var r=e.getSnapshot;e=e.value;try{var l=r();return!sn(e,l)}catch(u){return!0}}function Fb(e){var r=sa(e,2);r!==null&&$e(r,e,2)}function qf(e){var r=Ve();if(typeof e=="function"){var l=e;if(e=l(),ga){Ge(!0);try{l()}finally{Ge(!1)}}}return r.memoizedState=r.baseState=e,r.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:lr,lastRenderedState:e},r}function Gb(e,r,l,u){return e.baseState=l,Uf(e,Xt,typeof u=="function"?u:lr)}function nz(e,r,l,u,f){if(yu(e))throw Error(i(485));if(e=r.action,e!==null){var p={payload:f,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(b){p.listeners.push(b)}};H.T!==null?l(!0):p.isTransition=!1,u(p),l=r.pending,l===null?(p.next=r.pending=p,Pb(r,p)):(p.next=l.next,r.pending=l.next=p)}}function Pb(e,r){var l=r.action,u=r.payload,f=e.state;if(r.isTransition){var p=H.T,b={};H.T=b;try{var S=l(f,u),A=H.S;A!==null&&A(b,S),Xb(e,r,S)}catch(U){Vf(e,r,U)}finally{p!==null&&b.types!==null&&(p.types=b.types),H.T=p}}else try{p=l(f,u),Xb(e,r,p)}catch(U){Vf(e,r,U)}}function Xb(e,r,l){l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(function(u){Qb(e,r,u)},function(u){return Vf(e,r,u)}):Qb(e,r,l)}function Qb(e,r,l){r.status="fulfilled",r.value=l,Zb(r),e.state=l,r=e.pending,r!==null&&(l=r.next,l===r?e.pending=null:(l=l.next,r.next=l,Pb(e,l)))}function Vf(e,r,l){var u=e.pending;if(e.pending=null,u!==null){u=u.next;do r.status="rejected",r.reason=l,Zb(r),r=r.next;while(r!==u)}e.action=null}function Zb(e){e=e.listeners;for(var r=0;r<e.length;r++)(0,e[r])()}function Kb(e,r){return r}function Jb(e,r){if(Bt){var l=te.formState;if(l!==null){t:{var u=kt;if(Bt){if(ae){e:{for(var f=ae,p=Tn;f.nodeType!==8;){if(!p){f=null;break e}if(f=Cn(f.nextSibling),f===null){f=null;break e}}p=f.data,f=p==="F!"||p==="F"?f:null}if(f){ae=Cn(f.nextSibling),u=f.data==="F!";break t}}Cr(u)}u=!1}u&&(r=l[0])}}return l=Ve(),l.memoizedState=l.baseState=r,u={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Kb,lastRenderedState:r},l.queue=u,l=gv.bind(null,kt,u),u.dispatch=l,u=qf(!1),p=Qf.bind(null,kt,!1,u.queue),u=Ve(),f={state:r,dispatch:null,action:e,pending:null},u.queue=f,l=nz.bind(null,kt,f,p,l),f.dispatch=l,u.memoizedState=e,[r,l,!1]}function $b(e){var r=fe();return Wb(r,Xt,e)}function Wb(e,r,l){if(r=Uf(e,r,Kb)[0],e=pu(lr)[0],typeof r=="object"&&r!==null&&typeof r.then=="function")try{var u=kl(r)}catch(b){throw b===ci?au:b}else u=r;r=fe();var f=r.queue,p=f.dispatch;return l!==r.memoizedState&&(kt.flags|=2048,mi(9,{destroy:void 0},rz.bind(null,f,l),null)),[u,p,e]}function rz(e,r){e.action=r}function tv(e){var r=fe(),l=Xt;if(l!==null)return Wb(r,l,e);fe(),r=r.memoizedState,l=fe();var u=l.queue.dispatch;return l.memoizedState=e,[r,u,!1]}function mi(e,r,l,u){return e={tag:e,create:l,deps:u,inst:r,next:null},r=kt.updateQueue,r===null&&(r=du(),kt.updateQueue=r),l=r.lastEffect,l===null?r.lastEffect=e.next=e:(u=l.next,l.next=e,e.next=u,r.lastEffect=e),e}function ev(){return fe().memoizedState}function mu(e,r,l,u){var f=Ve();kt.flags|=e,f.memoizedState=mi(1|r,{destroy:void 0},l,u===void 0?null:u)}function gu(e,r,l,u){var f=fe();u=u===void 0?null:u;var p=f.memoizedState.inst;Xt!==null&&u!==null&&Df(u,Xt.memoizedState.deps)?f.memoizedState=mi(r,p,l,u):(kt.flags|=e,f.memoizedState=mi(1|r,p,l,u))}function nv(e,r){mu(8390656,8,e,r)}function Yf(e,r){gu(2048,8,e,r)}function az(e){kt.flags|=4;var r=kt.updateQueue;if(r===null)r=du(),kt.updateQueue=r,r.events=[e];else{var l=r.events;l===null?r.events=[e]:l.push(e)}}function rv(e){var r=fe().memoizedState;return az({ref:r,nextImpl:e}),function(){if((Yt&2)!==0)throw Error(i(440));return r.impl.apply(void 0,arguments)}}function av(e,r){return gu(4,2,e,r)}function iv(e,r){return gu(4,4,e,r)}function lv(e,r){if(typeof r=="function"){e=e();var l=r(e);return function(){typeof l=="function"?l():r(null)}}if(r!=null)return e=e(),r.current=e,function(){r.current=null}}function sv(e,r,l){l=l!=null?l.concat([e]):null,gu(4,4,lv.bind(null,r,e),l)}function Ff(){}function uv(e,r){var l=fe();r=r===void 0?null:r;var u=l.memoizedState;return r!==null&&Df(r,u[1])?u[0]:(l.memoizedState=[e,r],e)}function ov(e,r){var l=fe();r=r===void 0?null:r;var u=l.memoizedState;if(r!==null&&Df(r,u[1]))return u[0];if(u=e(),ga){Ge(!0);try{e()}finally{Ge(!1)}}return l.memoizedState=[u,r],u}function Gf(e,r,l){return l===void 0||(ir&1073741824)!==0&&(jt&261930)===0?e.memoizedState=r:(e.memoizedState=l,e=cx(),kt.lanes|=e,Ir|=e,l)}function cv(e,r,l,u){return sn(l,r)?l:di.current!==null?(e=Gf(e,l,u),sn(e,r)||(ye=!0),e):(ir&42)===0||(ir&1073741824)!==0&&(jt&261930)===0?(ye=!0,e.memoizedState=l):(e=cx(),kt.lanes|=e,Ir|=e,r)}function fv(e,r,l,u,f){var p=et.p;et.p=p!==0&&8>p?p:8;var b=H.T,S={};H.T=S,Qf(e,!1,r,l);try{var A=f(),U=H.S;if(U!==null&&U(S,A),A!==null&&typeof A=="object"&&typeof A.then=="function"){var X=WM(A,u);Rl(e,r,X,hn(e))}else Rl(e,r,u,hn(e))}catch(K){Rl(e,r,{then:function(){},status:"rejected",reason:K},hn())}finally{et.p=p,b!==null&&S.types!==null&&(b.types=S.types),H.T=b}}function iz(){}function Pf(e,r,l,u){if(e.tag!==5)throw Error(i(476));var f=dv(e).queue;fv(e,f,r,ft,l===null?iz:function(){return hv(e),l(u)})}function dv(e){var r=e.memoizedState;if(r!==null)return r;r={memoizedState:ft,baseState:ft,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:lr,lastRenderedState:ft},next:null};var l={};return r.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:lr,lastRenderedState:l},next:null},e.memoizedState=r,e=e.alternate,e!==null&&(e.memoizedState=r),r}function hv(e){var r=dv(e);r.next===null&&(r=e.alternate.memoizedState),Rl(e,r.next.queue,{},hn())}function Xf(){return ke(Pl)}function pv(){return fe().memoizedState}function mv(){return fe().memoizedState}function lz(e){for(var r=e.return;r!==null;){switch(r.tag){case 24:case 3:var l=hn();e=Rr(l);var u=Mr(r,e,l);u!==null&&($e(u,r,l),Tl(u,r,l)),r={cache:wf()},e.payload=r;return}r=r.return}}function sz(e,r,l){var u=hn();l={lane:u,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},yu(e)?yv(r,l):(l=ff(e,r,l,u),l!==null&&($e(l,e,u),bv(l,r,u)))}function gv(e,r,l){var u=hn();Rl(e,r,l,u)}function Rl(e,r,l,u){var f={lane:u,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(yu(e))yv(r,f);else{var p=e.alternate;if(e.lanes===0&&(p===null||p.lanes===0)&&(p=r.lastRenderedReducer,p!==null))try{var b=r.lastRenderedState,S=p(b,l);if(f.hasEagerState=!0,f.eagerState=S,sn(S,b))return Js(e,r,f,0),te===null&&Ks(),!1}catch(A){}finally{}if(l=ff(e,r,f,u),l!==null)return $e(l,e,u),bv(l,r,u),!0}return!1}function Qf(e,r,l,u){if(u={lane:2,revertLane:Cd(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},yu(e)){if(r)throw Error(i(479))}else r=ff(e,l,u,2),r!==null&&$e(r,e,2)}function yu(e){var r=e.alternate;return e===kt||r!==null&&r===kt}function yv(e,r){hi=cu=!0;var l=e.pending;l===null?r.next=r:(r.next=l.next,l.next=r),e.pending=r}function bv(e,r,l){if((l&4194048)!==0){var u=r.lanes;u&=e.pendingLanes,l|=u,r.lanes=l,_y(e,l)}}var Ml={readContext:ke,use:hu,useCallback:ue,useContext:ue,useEffect:ue,useImperativeHandle:ue,useLayoutEffect:ue,useInsertionEffect:ue,useMemo:ue,useReducer:ue,useRef:ue,useState:ue,useDebugValue:ue,useDeferredValue:ue,useTransition:ue,useSyncExternalStore:ue,useId:ue,useHostTransitionStatus:ue,useFormState:ue,useActionState:ue,useOptimistic:ue,useMemoCache:ue,useCacheRefresh:ue};Ml.useEffectEvent=ue;var vv={readContext:ke,use:hu,useCallback:function(e,r){return Ve().memoizedState=[e,r===void 0?null:r],e},useContext:ke,useEffect:nv,useImperativeHandle:function(e,r,l){l=l!=null?l.concat([e]):null,mu(4194308,4,lv.bind(null,r,e),l)},useLayoutEffect:function(e,r){return mu(4194308,4,e,r)},useInsertionEffect:function(e,r){mu(4,2,e,r)},useMemo:function(e,r){var l=Ve();r=r===void 0?null:r;var u=e();if(ga){Ge(!0);try{e()}finally{Ge(!1)}}return l.memoizedState=[u,r],u},useReducer:function(e,r,l){var u=Ve();if(l!==void 0){var f=l(r);if(ga){Ge(!0);try{l(r)}finally{Ge(!1)}}}else f=r;return u.memoizedState=u.baseState=f,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:f},u.queue=e,e=e.dispatch=sz.bind(null,kt,e),[u.memoizedState,e]},useRef:function(e){var r=Ve();return e={current:e},r.memoizedState=e},useState:function(e){e=qf(e);var r=e.queue,l=gv.bind(null,kt,r);return r.dispatch=l,[e.memoizedState,l]},useDebugValue:Ff,useDeferredValue:function(e,r){var l=Ve();return Gf(l,e,r)},useTransition:function(){var e=qf(!1);return e=fv.bind(null,kt,e.queue,!0,!1),Ve().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,r,l){var u=kt,f=Ve();if(Bt){if(l===void 0)throw Error(i(407));l=l()}else{if(l=r(),te===null)throw Error(i(349));(jt&127)!==0||Hb(u,r,l)}f.memoizedState=l;var p={value:l,getSnapshot:r};return f.queue=p,nv(Vb.bind(null,u,p,e),[e]),u.flags|=2048,mi(9,{destroy:void 0},qb.bind(null,u,p,l,r),null),l},useId:function(){var e=Ve(),r=te.identifierPrefix;if(Bt){var l=Yn,u=Vn;l=(u&~(1<<32-Wt(u)-1)).toString(32)+l,r="_"+r+"R_"+l,l=fu++,0<l&&(r+="H"+l.toString(32)),r+="_"}else l=tz++,r="_"+r+"r_"+l.toString(32)+"_";return e.memoizedState=r},useHostTransitionStatus:Xf,useFormState:Jb,useActionState:Jb,useOptimistic:function(e){var r=Ve();r.memoizedState=r.baseState=e;var l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return r.queue=l,r=Qf.bind(null,kt,!0,l),l.dispatch=r,[e,r]},useMemoCache:Bf,useCacheRefresh:function(){return Ve().memoizedState=lz.bind(null,kt)},useEffectEvent:function(e){var r=Ve(),l={impl:e};return r.memoizedState=l,function(){if((Yt&2)!==0)throw Error(i(440));return l.impl.apply(void 0,arguments)}}},Zf={readContext:ke,use:hu,useCallback:uv,useContext:ke,useEffect:Yf,useImperativeHandle:sv,useInsertionEffect:av,useLayoutEffect:iv,useMemo:ov,useReducer:pu,useRef:ev,useState:function(){return pu(lr)},useDebugValue:Ff,useDeferredValue:function(e,r){var l=fe();return cv(l,Xt.memoizedState,e,r)},useTransition:function(){var e=pu(lr)[0],r=fe().memoizedState;return[typeof e=="boolean"?e:kl(e),r]},useSyncExternalStore:Ub,useId:pv,useHostTransitionStatus:Xf,useFormState:$b,useActionState:$b,useOptimistic:function(e,r){var l=fe();return Gb(l,Xt,e,r)},useMemoCache:Bf,useCacheRefresh:mv};Zf.useEffectEvent=rv;var xv={readContext:ke,use:hu,useCallback:uv,useContext:ke,useEffect:Yf,useImperativeHandle:sv,useInsertionEffect:av,useLayoutEffect:iv,useMemo:ov,useReducer:Hf,useRef:ev,useState:function(){return Hf(lr)},useDebugValue:Ff,useDeferredValue:function(e,r){var l=fe();return Xt===null?Gf(l,e,r):cv(l,Xt.memoizedState,e,r)},useTransition:function(){var e=Hf(lr)[0],r=fe().memoizedState;return[typeof e=="boolean"?e:kl(e),r]},useSyncExternalStore:Ub,useId:pv,useHostTransitionStatus:Xf,useFormState:tv,useActionState:tv,useOptimistic:function(e,r){var l=fe();return Xt!==null?Gb(l,Xt,e,r):(l.baseState=e,[e,l.queue.dispatch])},useMemoCache:Bf,useCacheRefresh:mv};xv.useEffectEvent=rv;function Kf(e,r,l,u){r=e.memoizedState,l=l(u,r),l=l==null?r:g({},r,l),e.memoizedState=l,e.lanes===0&&(e.updateQueue.baseState=l)}var Jf={enqueueSetState:function(e,r,l){e=e._reactInternals;var u=hn(),f=Rr(u);f.payload=r,l!=null&&(f.callback=l),r=Mr(e,f,u),r!==null&&($e(r,e,u),Tl(r,e,u))},enqueueReplaceState:function(e,r,l){e=e._reactInternals;var u=hn(),f=Rr(u);f.tag=1,f.payload=r,l!=null&&(f.callback=l),r=Mr(e,f,u),r!==null&&($e(r,e,u),Tl(r,e,u))},enqueueForceUpdate:function(e,r){e=e._reactInternals;var l=hn(),u=Rr(l);u.tag=2,r!=null&&(u.callback=r),r=Mr(e,u,l),r!==null&&($e(r,e,l),Tl(r,e,l))}};function Sv(e,r,l,u,f,p,b){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(u,p,b):r.prototype&&r.prototype.isPureReactComponent?!gl(l,u)||!gl(f,p):!0}function wv(e,r,l,u){e=r.state,typeof r.componentWillReceiveProps=="function"&&r.componentWillReceiveProps(l,u),typeof r.UNSAFE_componentWillReceiveProps=="function"&&r.UNSAFE_componentWillReceiveProps(l,u),r.state!==e&&Jf.enqueueReplaceState(r,r.state,null)}function ya(e,r){var l=r;if("ref"in r){l={};for(var u in r)u!=="ref"&&(l[u]=r[u])}if(e=e.defaultProps){l===r&&(l=g({},l));for(var f in e)l[f]===void 0&&(l[f]=e[f])}return l}function _v(e){Zs(e)}function Tv(e){console.error(e)}function Ev(e){Zs(e)}function bu(e,r){try{var l=e.onUncaughtError;l(r.value,{componentStack:r.stack})}catch(u){setTimeout(function(){throw u})}}function Cv(e,r,l){try{var u=e.onCaughtError;u(l.value,{componentStack:l.stack,errorBoundary:r.tag===1?r.stateNode:null})}catch(f){setTimeout(function(){throw f})}}function $f(e,r,l){return l=Rr(l),l.tag=3,l.payload={element:null},l.callback=function(){bu(e,r)},l}function Av(e){return e=Rr(e),e.tag=3,e}function kv(e,r,l,u){var f=l.type.getDerivedStateFromError;if(typeof f=="function"){var p=u.value;e.payload=function(){return f(p)},e.callback=function(){Cv(r,l,u)}}var b=l.stateNode;b!==null&&typeof b.componentDidCatch=="function"&&(e.callback=function(){Cv(r,l,u),typeof f!="function"&&(jr===null?jr=new Set([this]):jr.add(this));var S=u.stack;this.componentDidCatch(u.value,{componentStack:S!==null?S:""})})}function uz(e,r,l,u,f){if(l.flags|=32768,u!==null&&typeof u=="object"&&typeof u.then=="function"){if(r=l.alternate,r!==null&&si(r,l,f,!0),l=on.current,l!==null){switch(l.tag){case 31:case 13:return En===null?Mu():l.alternate===null&&oe===0&&(oe=3),l.flags&=-257,l.flags|=65536,l.lanes=f,u===iu?l.flags|=16384:(r=l.updateQueue,r===null?l.updateQueue=new Set([u]):r.add(u),_d(e,u,f)),!1;case 22:return l.flags|=65536,u===iu?l.flags|=16384:(r=l.updateQueue,r===null?(r={transitions:null,markerInstances:null,retryQueue:new Set([u])},l.updateQueue=r):(l=r.retryQueue,l===null?r.retryQueue=new Set([u]):l.add(u)),_d(e,u,f)),!1}throw Error(i(435,l.tag))}return _d(e,u,f),Mu(),!1}if(Bt)return r=on.current,r!==null?((r.flags&65536)===0&&(r.flags|=256),r.flags|=65536,r.lanes=f,u!==yf&&(e=Error(i(422),{cause:u}),vl(Sn(e,l)))):(u!==yf&&(r=Error(i(423),{cause:u}),vl(Sn(r,l))),e=e.current.alternate,e.flags|=65536,f&=-f,e.lanes|=f,u=Sn(u,l),f=$f(e.stateNode,u,f),kf(e,f),oe!==4&&(oe=2)),!1;var p=Error(i(520),{cause:u});if(p=Sn(p,l),Bl===null?Bl=[p]:Bl.push(p),oe!==4&&(oe=2),r===null)return!0;u=Sn(u,l),l=r;do{switch(l.tag){case 3:return l.flags|=65536,e=f&-f,l.lanes|=e,e=$f(l.stateNode,u,e),kf(l,e),!1;case 1:if(r=l.type,p=l.stateNode,(l.flags&128)===0&&(typeof r.getDerivedStateFromError=="function"||p!==null&&typeof p.componentDidCatch=="function"&&(jr===null||!jr.has(p))))return l.flags|=65536,f&=-f,l.lanes|=f,f=Av(f),kv(f,e,l,u),kf(l,f),!1}l=l.return}while(l!==null);return!1}var Wf=Error(i(461)),ye=!1;function Re(e,r,l,u){r.child=e===null?Ob(r,null,l,u):ma(r,e.child,l,u)}function Rv(e,r,l,u,f){l=l.render;var p=r.ref;if("ref"in u){var b={};for(var S in u)S!=="ref"&&(b[S]=u[S])}else b=u;return fa(r),u=Nf(e,r,l,b,p,f),S=If(),e!==null&&!ye?(jf(e,r,f),sr(e,r,f)):(Bt&&S&&mf(r),r.flags|=1,Re(e,r,u,f),r.child)}function Mv(e,r,l,u,f){if(e===null){var p=l.type;return typeof p=="function"&&!df(p)&&p.defaultProps===void 0&&l.compare===null?(r.tag=15,r.type=p,zv(e,r,p,u,f)):(e=Ws(l.type,null,u,r,r.mode,f),e.ref=r.ref,e.return=r,r.child=e)}if(p=e.child,!sd(e,f)){var b=p.memoizedProps;if(l=l.compare,l=l!==null?l:gl,l(b,u)&&e.ref===r.ref)return sr(e,r,f)}return r.flags|=1,e=er(p,u),e.ref=r.ref,e.return=r,r.child=e}function zv(e,r,l,u,f){if(e!==null){var p=e.memoizedProps;if(gl(p,u)&&e.ref===r.ref)if(ye=!1,r.pendingProps=u=p,sd(e,f))(e.flags&131072)!==0&&(ye=!0);else return r.lanes=e.lanes,sr(e,r,f)}return td(e,r,l,u,f)}function Ov(e,r,l,u){var f=u.children,p=e!==null?e.memoizedState:null;if(e===null&&r.stateNode===null&&(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),u.mode==="hidden"){if((r.flags&128)!==0){if(p=p!==null?p.baseLanes|l:l,e!==null){for(u=r.child=e.child,f=0;u!==null;)f=f|u.lanes|u.childLanes,u=u.sibling;u=f&~p}else u=0,r.child=null;return Dv(e,r,p,l,u)}if((l&536870912)!==0)r.memoizedState={baseLanes:0,cachePool:null},e!==null&&ru(r,p!==null?p.cachePool:null),p!==null?Ib(r,p):Mf(),jb(r);else return u=r.lanes=536870912,Dv(e,r,p!==null?p.baseLanes|l:l,l,u)}else p!==null?(ru(r,p.cachePool),Ib(r,p),Or(),r.memoizedState=null):(e!==null&&ru(r,null),Mf(),Or());return Re(e,r,f,l),r.child}function zl(e,r){return e!==null&&e.tag===22||r.stateNode!==null||(r.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.sibling}function Dv(e,r,l,u,f){var p=Tf();return p=p===null?null:{parent:me._currentValue,pool:p},r.memoizedState={baseLanes:l,cachePool:p},e!==null&&ru(r,null),Mf(),jb(r),e!==null&&si(e,r,u,!0),r.childLanes=f,null}function vu(e,r){return r=Su({mode:r.mode,children:r.children},e.mode),r.ref=e.ref,e.child=r,r.return=e,r}function Nv(e,r,l){return ma(r,e.child,null,l),e=vu(r,r.pendingProps),e.flags|=2,cn(r),r.memoizedState=null,e}function oz(e,r,l){var u=r.pendingProps,f=(r.flags&128)!==0;if(r.flags&=-129,e===null){if(Bt){if(u.mode==="hidden")return e=vu(r,u),r.lanes=536870912,zl(null,e);if(Of(r),(e=ae)?(e=Px(e,Tn),e=e!==null&&e.data==="&"?e:null,e!==null&&(r.memoizedState={dehydrated:e,treeContext:Tr!==null?{id:Vn,overflow:Yn}:null,retryLane:536870912,hydrationErrors:null},l=yb(e),l.return=r,r.child=l,Ae=r,ae=null)):e=null,e===null)throw Cr(r);return r.lanes=536870912,null}return vu(r,u)}var p=e.memoizedState;if(p!==null){var b=p.dehydrated;if(Of(r),f)if(r.flags&256)r.flags&=-257,r=Nv(e,r,l);else if(r.memoizedState!==null)r.child=e.child,r.flags|=128,r=null;else throw Error(i(558));else if(ye||si(e,r,l,!1),f=(l&e.childLanes)!==0,ye||f){if(u=te,u!==null&&(b=Ty(u,l),b!==0&&b!==p.retryLane))throw p.retryLane=b,sa(e,b),$e(u,e,b),Wf;Mu(),r=Nv(e,r,l)}else e=p.treeContext,ae=Cn(b.nextSibling),Ae=r,Bt=!0,Er=null,Tn=!1,e!==null&&xb(r,e),r=vu(r,u),r.flags|=4096;return r}return e=er(e.child,{mode:u.mode,children:u.children}),e.ref=r.ref,r.child=e,e.return=r,e}function xu(e,r){var l=r.ref;if(l===null)e!==null&&e.ref!==null&&(r.flags|=4194816);else{if(typeof l!="function"&&typeof l!="object")throw Error(i(284));(e===null||e.ref!==l)&&(r.flags|=4194816)}}function td(e,r,l,u,f){return fa(r),l=Nf(e,r,l,u,void 0,f),u=If(),e!==null&&!ye?(jf(e,r,f),sr(e,r,f)):(Bt&&u&&mf(r),r.flags|=1,Re(e,r,l,f),r.child)}function Iv(e,r,l,u,f,p){return fa(r),r.updateQueue=null,l=Bb(r,u,l,f),Lb(e),u=If(),e!==null&&!ye?(jf(e,r,p),sr(e,r,p)):(Bt&&u&&mf(r),r.flags|=1,Re(e,r,l,p),r.child)}function jv(e,r,l,u,f){if(fa(r),r.stateNode===null){var p=ri,b=l.contextType;typeof b=="object"&&b!==null&&(p=ke(b)),p=new l(u,p),r.memoizedState=p.state!==null&&p.state!==void 0?p.state:null,p.updater=Jf,r.stateNode=p,p._reactInternals=r,p=r.stateNode,p.props=u,p.state=r.memoizedState,p.refs={},Cf(r),b=l.contextType,p.context=typeof b=="object"&&b!==null?ke(b):ri,p.state=r.memoizedState,b=l.getDerivedStateFromProps,typeof b=="function"&&(Kf(r,l,b,u),p.state=r.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof p.getSnapshotBeforeUpdate=="function"||typeof p.UNSAFE_componentWillMount!="function"&&typeof p.componentWillMount!="function"||(b=p.state,typeof p.componentWillMount=="function"&&p.componentWillMount(),typeof p.UNSAFE_componentWillMount=="function"&&p.UNSAFE_componentWillMount(),b!==p.state&&Jf.enqueueReplaceState(p,p.state,null),Cl(r,u,p,f),El(),p.state=r.memoizedState),typeof p.componentDidMount=="function"&&(r.flags|=4194308),u=!0}else if(e===null){p=r.stateNode;var S=r.memoizedProps,A=ya(l,S);p.props=A;var U=p.context,X=l.contextType;b=ri,typeof X=="object"&&X!==null&&(b=ke(X));var K=l.getDerivedStateFromProps;X=typeof K=="function"||typeof p.getSnapshotBeforeUpdate=="function",S=r.pendingProps!==S,X||typeof p.UNSAFE_componentWillReceiveProps!="function"&&typeof p.componentWillReceiveProps!="function"||(S||U!==b)&&wv(r,p,u,b),kr=!1;var V=r.memoizedState;p.state=V,Cl(r,u,p,f),El(),U=r.memoizedState,S||V!==U||kr?(typeof K=="function"&&(Kf(r,l,K,u),U=r.memoizedState),(A=kr||Sv(r,l,A,u,V,U,b))?(X||typeof p.UNSAFE_componentWillMount!="function"&&typeof p.componentWillMount!="function"||(typeof p.componentWillMount=="function"&&p.componentWillMount(),typeof p.UNSAFE_componentWillMount=="function"&&p.UNSAFE_componentWillMount()),typeof p.componentDidMount=="function"&&(r.flags|=4194308)):(typeof p.componentDidMount=="function"&&(r.flags|=4194308),r.memoizedProps=u,r.memoizedState=U),p.props=u,p.state=U,p.context=b,u=A):(typeof p.componentDidMount=="function"&&(r.flags|=4194308),u=!1)}else{p=r.stateNode,Af(e,r),b=r.memoizedProps,X=ya(l,b),p.props=X,K=r.pendingProps,V=p.context,U=l.contextType,A=ri,typeof U=="object"&&U!==null&&(A=ke(U)),S=l.getDerivedStateFromProps,(U=typeof S=="function"||typeof p.getSnapshotBeforeUpdate=="function")||typeof p.UNSAFE_componentWillReceiveProps!="function"&&typeof p.componentWillReceiveProps!="function"||(b!==K||V!==A)&&wv(r,p,u,A),kr=!1,V=r.memoizedState,p.state=V,Cl(r,u,p,f),El();var F=r.memoizedState;b!==K||V!==F||kr||e!==null&&e.dependencies!==null&&eu(e.dependencies)?(typeof S=="function"&&(Kf(r,l,S,u),F=r.memoizedState),(X=kr||Sv(r,l,X,u,V,F,A)||e!==null&&e.dependencies!==null&&eu(e.dependencies))?(U||typeof p.UNSAFE_componentWillUpdate!="function"&&typeof p.componentWillUpdate!="function"||(typeof p.componentWillUpdate=="function"&&p.componentWillUpdate(u,F,A),typeof p.UNSAFE_componentWillUpdate=="function"&&p.UNSAFE_componentWillUpdate(u,F,A)),typeof p.componentDidUpdate=="function"&&(r.flags|=4),typeof p.getSnapshotBeforeUpdate=="function"&&(r.flags|=1024)):(typeof p.componentDidUpdate!="function"||b===e.memoizedProps&&V===e.memoizedState||(r.flags|=4),typeof p.getSnapshotBeforeUpdate!="function"||b===e.memoizedProps&&V===e.memoizedState||(r.flags|=1024),r.memoizedProps=u,r.memoizedState=F),p.props=u,p.state=F,p.context=A,u=X):(typeof p.componentDidUpdate!="function"||b===e.memoizedProps&&V===e.memoizedState||(r.flags|=4),typeof p.getSnapshotBeforeUpdate!="function"||b===e.memoizedProps&&V===e.memoizedState||(r.flags|=1024),u=!1)}return p=u,xu(e,r),u=(r.flags&128)!==0,p||u?(p=r.stateNode,l=u&&typeof l.getDerivedStateFromError!="function"?null:p.render(),r.flags|=1,e!==null&&u?(r.child=ma(r,e.child,null,f),r.child=ma(r,null,l,f)):Re(e,r,l,f),r.memoizedState=p.state,e=r.child):e=sr(e,r,f),e}function Lv(e,r,l,u){return oa(),r.flags|=256,Re(e,r,l,u),r.child}var ed={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function nd(e){return{baseLanes:e,cachePool:Cb()}}function rd(e,r,l){return e=e!==null?e.childLanes&~l:0,r&&(e|=dn),e}function Bv(e,r,l){var u=r.pendingProps,f=!1,p=(r.flags&128)!==0,b;if((b=p)||(b=e!==null&&e.memoizedState===null?!1:(ce.current&2)!==0),b&&(f=!0,r.flags&=-129),b=(r.flags&32)!==0,r.flags&=-33,e===null){if(Bt){if(f?zr(r):Or(),(e=ae)?(e=Px(e,Tn),e=e!==null&&e.data!=="&"?e:null,e!==null&&(r.memoizedState={dehydrated:e,treeContext:Tr!==null?{id:Vn,overflow:Yn}:null,retryLane:536870912,hydrationErrors:null},l=yb(e),l.return=r,r.child=l,Ae=r,ae=null)):e=null,e===null)throw Cr(r);return Ud(e)?r.lanes=32:r.lanes=536870912,null}var S=u.children;return u=u.fallback,f?(Or(),f=r.mode,S=Su({mode:"hidden",children:S},f),u=ua(u,f,l,null),S.return=r,u.return=r,S.sibling=u,r.child=S,u=r.child,u.memoizedState=nd(l),u.childLanes=rd(e,b,l),r.memoizedState=ed,zl(null,u)):(zr(r),ad(r,S))}var A=e.memoizedState;if(A!==null&&(S=A.dehydrated,S!==null)){if(p)r.flags&256?(zr(r),r.flags&=-257,r=id(e,r,l)):r.memoizedState!==null?(Or(),r.child=e.child,r.flags|=128,r=null):(Or(),S=u.fallback,f=r.mode,u=Su({mode:"visible",children:u.children},f),S=ua(S,f,l,null),S.flags|=2,u.return=r,S.return=r,u.sibling=S,r.child=u,ma(r,e.child,null,l),u=r.child,u.memoizedState=nd(l),u.childLanes=rd(e,b,l),r.memoizedState=ed,r=zl(null,u));else if(zr(r),Ud(S)){if(b=S.nextSibling&&S.nextSibling.dataset,b)var U=b.dgst;b=U,u=Error(i(419)),u.stack="",u.digest=b,vl({value:u,source:null,stack:null}),r=id(e,r,l)}else if(ye||si(e,r,l,!1),b=(l&e.childLanes)!==0,ye||b){if(b=te,b!==null&&(u=Ty(b,l),u!==0&&u!==A.retryLane))throw A.retryLane=u,sa(e,u),$e(b,e,u),Wf;Bd(S)||Mu(),r=id(e,r,l)}else Bd(S)?(r.flags|=192,r.child=e.child,r=null):(e=A.treeContext,ae=Cn(S.nextSibling),Ae=r,Bt=!0,Er=null,Tn=!1,e!==null&&xb(r,e),r=ad(r,u.children),r.flags|=4096);return r}return f?(Or(),S=u.fallback,f=r.mode,A=e.child,U=A.sibling,u=er(A,{mode:"hidden",children:u.children}),u.subtreeFlags=A.subtreeFlags&65011712,U!==null?S=er(U,S):(S=ua(S,f,l,null),S.flags|=2),S.return=r,u.return=r,u.sibling=S,r.child=u,zl(null,u),u=r.child,S=e.child.memoizedState,S===null?S=nd(l):(f=S.cachePool,f!==null?(A=me._currentValue,f=f.parent!==A?{parent:A,pool:A}:f):f=Cb(),S={baseLanes:S.baseLanes|l,cachePool:f}),u.memoizedState=S,u.childLanes=rd(e,b,l),r.memoizedState=ed,zl(e.child,u)):(zr(r),l=e.child,e=l.sibling,l=er(l,{mode:"visible",children:u.children}),l.return=r,l.sibling=null,e!==null&&(b=r.deletions,b===null?(r.deletions=[e],r.flags|=16):b.push(e)),r.child=l,r.memoizedState=null,l)}function ad(e,r){return r=Su({mode:"visible",children:r},e.mode),r.return=e,e.child=r}function Su(e,r){return e=un(22,e,null,r),e.lanes=0,e}function id(e,r,l){return ma(r,e.child,null,l),e=ad(r,r.pendingProps.children),e.flags|=2,r.memoizedState=null,e}function Uv(e,r,l){e.lanes|=r;var u=e.alternate;u!==null&&(u.lanes|=r),xf(e.return,r,l)}function ld(e,r,l,u,f,p){var b=e.memoizedState;b===null?e.memoizedState={isBackwards:r,rendering:null,renderingStartTime:0,last:u,tail:l,tailMode:f,treeForkCount:p}:(b.isBackwards=r,b.rendering=null,b.renderingStartTime=0,b.last=u,b.tail=l,b.tailMode=f,b.treeForkCount=p)}function Hv(e,r,l){var u=r.pendingProps,f=u.revealOrder,p=u.tail;u=u.children;var b=ce.current,S=(b&2)!==0;if(S?(b=b&1|2,r.flags|=128):b&=1,T(ce,b),Re(e,r,u,l),u=Bt?bl:0,!S&&e!==null&&(e.flags&128)!==0)t:for(e=r.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Uv(e,l,r);else if(e.tag===19)Uv(e,l,r);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===r)break t;for(;e.sibling===null;){if(e.return===null||e.return===r)break t;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(f){case"forwards":for(l=r.child,f=null;l!==null;)e=l.alternate,e!==null&&ou(e)===null&&(f=l),l=l.sibling;l=f,l===null?(f=r.child,r.child=null):(f=l.sibling,l.sibling=null),ld(r,!1,f,l,p,u);break;case"backwards":case"unstable_legacy-backwards":for(l=null,f=r.child,r.child=null;f!==null;){if(e=f.alternate,e!==null&&ou(e)===null){r.child=f;break}e=f.sibling,f.sibling=l,l=f,f=e}ld(r,!0,l,null,p,u);break;case"together":ld(r,!1,null,null,void 0,u);break;default:r.memoizedState=null}return r.child}function sr(e,r,l){if(e!==null&&(r.dependencies=e.dependencies),Ir|=r.lanes,(l&r.childLanes)===0)if(e!==null){if(si(e,r,l,!1),(l&r.childLanes)===0)return null}else return null;if(e!==null&&r.child!==e.child)throw Error(i(153));if(r.child!==null){for(e=r.child,l=er(e,e.pendingProps),r.child=l,l.return=r;e.sibling!==null;)e=e.sibling,l=l.sibling=er(e,e.pendingProps),l.return=r;l.sibling=null}return r.child}function sd(e,r){return(e.lanes&r)!==0?!0:(e=e.dependencies,!!(e!==null&&eu(e)))}function cz(e,r,l){switch(r.tag){case 3:_t(r,r.stateNode.containerInfo),Ar(r,me,e.memoizedState.cache),oa();break;case 27:case 5:re(r);break;case 4:_t(r,r.stateNode.containerInfo);break;case 10:Ar(r,r.type,r.memoizedProps.value);break;case 31:if(r.memoizedState!==null)return r.flags|=128,Of(r),null;break;case 13:var u=r.memoizedState;if(u!==null)return u.dehydrated!==null?(zr(r),r.flags|=128,null):(l&r.child.childLanes)!==0?Bv(e,r,l):(zr(r),e=sr(e,r,l),e!==null?e.sibling:null);zr(r);break;case 19:var f=(e.flags&128)!==0;if(u=(l&r.childLanes)!==0,u||(si(e,r,l,!1),u=(l&r.childLanes)!==0),f){if(u)return Hv(e,r,l);r.flags|=128}if(f=r.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),T(ce,ce.current),u)break;return null;case 22:return r.lanes=0,Ov(e,r,l,r.pendingProps);case 24:Ar(r,me,e.memoizedState.cache)}return sr(e,r,l)}function qv(e,r,l){if(e!==null)if(e.memoizedProps!==r.pendingProps)ye=!0;else{if(!sd(e,l)&&(r.flags&128)===0)return ye=!1,cz(e,r,l);ye=(e.flags&131072)!==0}else ye=!1,Bt&&(r.flags&1048576)!==0&&vb(r,bl,r.index);switch(r.lanes=0,r.tag){case 16:t:{var u=r.pendingProps;if(e=ha(r.elementType),r.type=e,typeof e=="function")df(e)?(u=ya(e,u),r.tag=1,r=jv(null,r,e,u,l)):(r.tag=0,r=td(null,r,e,u,l));else{if(e!=null){var f=e.$$typeof;if(f===at){r.tag=11,r=Rv(null,r,e,u,l);break t}else if(f===J){r.tag=14,r=Mv(null,r,e,u,l);break t}}throw r=ot(e)||e,Error(i(306,r,""))}}return r;case 0:return td(e,r,r.type,r.pendingProps,l);case 1:return u=r.type,f=ya(u,r.pendingProps),jv(e,r,u,f,l);case 3:t:{if(_t(r,r.stateNode.containerInfo),e===null)throw Error(i(387));u=r.pendingProps;var p=r.memoizedState;f=p.element,Af(e,r),Cl(r,u,null,l);var b=r.memoizedState;if(u=b.cache,Ar(r,me,u),u!==p.cache&&Sf(r,[me],l,!0),El(),u=b.element,p.isDehydrated)if(p={element:u,isDehydrated:!1,cache:b.cache},r.updateQueue.baseState=p,r.memoizedState=p,r.flags&256){r=Lv(e,r,u,l);break t}else if(u!==f){f=Sn(Error(i(424)),r),vl(f),r=Lv(e,r,u,l);break t}else{switch(e=r.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName==="HTML"?e.ownerDocument.body:e}for(ae=Cn(e.firstChild),Ae=r,Bt=!0,Er=null,Tn=!0,l=Ob(r,null,u,l),r.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling}else{if(oa(),u===f){r=sr(e,r,l);break t}Re(e,r,u,l)}r=r.child}return r;case 26:return xu(e,r),e===null?(l=$x(r.type,null,r.pendingProps,null))?r.memoizedState=l:Bt||(l=r.type,e=r.pendingProps,u=Lu(mt.current).createElement(l),u[Ce]=r,u[Pe]=e,Me(u,l,e),_e(u),r.stateNode=u):r.memoizedState=$x(r.type,e.memoizedProps,r.pendingProps,e.memoizedState),null;case 27:return re(r),e===null&&Bt&&(u=r.stateNode=Zx(r.type,r.pendingProps,mt.current),Ae=r,Tn=!0,f=ae,Hr(r.type)?(Hd=f,ae=Cn(u.firstChild)):ae=f),Re(e,r,r.pendingProps.children,l),xu(e,r),e===null&&(r.flags|=4194304),r.child;case 5:return e===null&&Bt&&((f=u=ae)&&(u=Hz(u,r.type,r.pendingProps,Tn),u!==null?(r.stateNode=u,Ae=r,ae=Cn(u.firstChild),Tn=!1,f=!0):f=!1),f||Cr(r)),re(r),f=r.type,p=r.pendingProps,b=e!==null?e.memoizedProps:null,u=p.children,Id(f,p)?u=null:b!==null&&Id(f,b)&&(r.flags|=32),r.memoizedState!==null&&(f=Nf(e,r,ez,null,null,l),Pl._currentValue=f),xu(e,r),Re(e,r,u,l),r.child;case 6:return e===null&&Bt&&((e=l=ae)&&(l=qz(l,r.pendingProps,Tn),l!==null?(r.stateNode=l,Ae=r,ae=null,e=!0):e=!1),e||Cr(r)),null;case 13:return Bv(e,r,l);case 4:return _t(r,r.stateNode.containerInfo),u=r.pendingProps,e===null?r.child=ma(r,null,u,l):Re(e,r,u,l),r.child;case 11:return Rv(e,r,r.type,r.pendingProps,l);case 7:return Re(e,r,r.pendingProps,l),r.child;case 8:return Re(e,r,r.pendingProps.children,l),r.child;case 12:return Re(e,r,r.pendingProps.children,l),r.child;case 10:return u=r.pendingProps,Ar(r,r.type,u.value),Re(e,r,u.children,l),r.child;case 9:return f=r.type._context,u=r.pendingProps.children,fa(r),f=ke(f),u=u(f),r.flags|=1,Re(e,r,u,l),r.child;case 14:return Mv(e,r,r.type,r.pendingProps,l);case 15:return zv(e,r,r.type,r.pendingProps,l);case 19:return Hv(e,r,l);case 31:return oz(e,r,l);case 22:return Ov(e,r,l,r.pendingProps);case 24:return fa(r),u=ke(me),e===null?(f=Tf(),f===null&&(f=te,p=wf(),f.pooledCache=p,p.refCount++,p!==null&&(f.pooledCacheLanes|=l),f=p),r.memoizedState={parent:u,cache:f},Cf(r),Ar(r,me,f)):((e.lanes&l)!==0&&(Af(e,r),Cl(r,null,null,l),El()),f=e.memoizedState,p=r.memoizedState,f.parent!==u?(f={parent:u,cache:u},r.memoizedState=f,r.lanes===0&&(r.memoizedState=r.updateQueue.baseState=f),Ar(r,me,u)):(u=p.cache,Ar(r,me,u),u!==f.cache&&Sf(r,[me],l,!0))),Re(e,r,r.pendingProps.children,l),r.child;case 29:throw r.pendingProps}throw Error(i(156,r.tag))}function ur(e){e.flags|=4}function ud(e,r,l,u,f){if((r=(e.mode&32)!==0)&&(r=!1),r){if(e.flags|=16777216,(f&335544128)===f)if(e.stateNode.complete)e.flags|=8192;else if(px())e.flags|=8192;else throw pa=iu,Ef}else e.flags&=-16777217}function Vv(e,r){if(r.type!=="stylesheet"||(r.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!rS(r))if(px())e.flags|=8192;else throw pa=iu,Ef}function wu(e,r){r!==null&&(e.flags|=4),e.flags&16384&&(r=e.tag!==22?Sy():536870912,e.lanes|=r,vi|=r)}function Ol(e,r){if(!Bt)switch(e.tailMode){case"hidden":r=e.tail;for(var l=null;r!==null;)r.alternate!==null&&(l=r),r=r.sibling;l===null?e.tail=null:l.sibling=null;break;case"collapsed":l=e.tail;for(var u=null;l!==null;)l.alternate!==null&&(u=l),l=l.sibling;u===null?r||e.tail===null?e.tail=null:e.tail.sibling=null:u.sibling=null}}function ie(e){var r=e.alternate!==null&&e.alternate.child===e.child,l=0,u=0;if(r)for(var f=e.child;f!==null;)l|=f.lanes|f.childLanes,u|=f.subtreeFlags&65011712,u|=f.flags&65011712,f.return=e,f=f.sibling;else for(f=e.child;f!==null;)l|=f.lanes|f.childLanes,u|=f.subtreeFlags,u|=f.flags,f.return=e,f=f.sibling;return e.subtreeFlags|=u,e.childLanes=l,r}function fz(e,r,l){var u=r.pendingProps;switch(gf(r),r.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ie(r),null;case 1:return ie(r),null;case 3:return l=r.stateNode,u=null,e!==null&&(u=e.memoizedState.cache),r.memoizedState.cache!==u&&(r.flags|=2048),ar(me),Ht(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(e===null||e.child===null)&&(li(r)?ur(r):e===null||e.memoizedState.isDehydrated&&(r.flags&256)===0||(r.flags|=1024,bf())),ie(r),null;case 26:var f=r.type,p=r.memoizedState;return e===null?(ur(r),p!==null?(ie(r),Vv(r,p)):(ie(r),ud(r,f,null,u,l))):p?p!==e.memoizedState?(ur(r),ie(r),Vv(r,p)):(ie(r),r.flags&=-16777217):(e=e.memoizedProps,e!==u&&ur(r),ie(r),ud(r,f,e,u,l)),null;case 27:if(yn(r),l=mt.current,f=r.type,e!==null&&r.stateNode!=null)e.memoizedProps!==u&&ur(r);else{if(!u){if(r.stateNode===null)throw Error(i(166));return ie(r),null}e=ut.current,li(r)?Sb(r):(e=Zx(f,u,l),r.stateNode=e,ur(r))}return ie(r),null;case 5:if(yn(r),f=r.type,e!==null&&r.stateNode!=null)e.memoizedProps!==u&&ur(r);else{if(!u){if(r.stateNode===null)throw Error(i(166));return ie(r),null}if(p=ut.current,li(r))Sb(r);else{var b=Lu(mt.current);switch(p){case 1:p=b.createElementNS("http://www.w3.org/2000/svg",f);break;case 2:p=b.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;default:switch(f){case"svg":p=b.createElementNS("http://www.w3.org/2000/svg",f);break;case"math":p=b.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;case"script":p=b.createElement("div"),p.innerHTML="<script><\/script>",p=p.removeChild(p.firstChild);break;case"select":p=typeof u.is=="string"?b.createElement("select",{is:u.is}):b.createElement("select"),u.multiple?p.multiple=!0:u.size&&(p.size=u.size);break;default:p=typeof u.is=="string"?b.createElement(f,{is:u.is}):b.createElement(f)}}p[Ce]=r,p[Pe]=u;t:for(b=r.child;b!==null;){if(b.tag===5||b.tag===6)p.appendChild(b.stateNode);else if(b.tag!==4&&b.tag!==27&&b.child!==null){b.child.return=b,b=b.child;continue}if(b===r)break t;for(;b.sibling===null;){if(b.return===null||b.return===r)break t;b=b.return}b.sibling.return=b.return,b=b.sibling}r.stateNode=p;t:switch(Me(p,f,u),f){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break t;case"img":u=!0;break t;default:u=!1}u&&ur(r)}}return ie(r),ud(r,r.type,e===null?null:e.memoizedProps,r.pendingProps,l),null;case 6:if(e&&r.stateNode!=null)e.memoizedProps!==u&&ur(r);else{if(typeof u!="string"&&r.stateNode===null)throw Error(i(166));if(e=mt.current,li(r)){if(e=r.stateNode,l=r.memoizedProps,u=null,f=Ae,f!==null)switch(f.tag){case 27:case 5:u=f.memoizedProps}e[Ce]=r,e=!!(e.nodeValue===l||u!==null&&u.suppressHydrationWarning===!0||Bx(e.nodeValue,l)),e||Cr(r,!0)}else e=Lu(e).createTextNode(u),e[Ce]=r,r.stateNode=e}return ie(r),null;case 31:if(l=r.memoizedState,e===null||e.memoizedState!==null){if(u=li(r),l!==null){if(e===null){if(!u)throw Error(i(318));if(e=r.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(i(557));e[Ce]=r}else oa(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;ie(r),e=!1}else l=bf(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=l),e=!0;if(!e)return r.flags&256?(cn(r),r):(cn(r),null);if((r.flags&128)!==0)throw Error(i(558))}return ie(r),null;case 13:if(u=r.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(f=li(r),u!==null&&u.dehydrated!==null){if(e===null){if(!f)throw Error(i(318));if(f=r.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(i(317));f[Ce]=r}else oa(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;ie(r),f=!1}else f=bf(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=f),f=!0;if(!f)return r.flags&256?(cn(r),r):(cn(r),null)}return cn(r),(r.flags&128)!==0?(r.lanes=l,r):(l=u!==null,e=e!==null&&e.memoizedState!==null,l&&(u=r.child,f=null,u.alternate!==null&&u.alternate.memoizedState!==null&&u.alternate.memoizedState.cachePool!==null&&(f=u.alternate.memoizedState.cachePool.pool),p=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(p=u.memoizedState.cachePool.pool),p!==f&&(u.flags|=2048)),l!==e&&l&&(r.child.flags|=8192),wu(r,r.updateQueue),ie(r),null);case 4:return Ht(),e===null&&Md(r.stateNode.containerInfo),ie(r),null;case 10:return ar(r.type),ie(r),null;case 19:if(P(ce),u=r.memoizedState,u===null)return ie(r),null;if(f=(r.flags&128)!==0,p=u.rendering,p===null)if(f)Ol(u,!1);else{if(oe!==0||e!==null&&(e.flags&128)!==0)for(e=r.child;e!==null;){if(p=ou(e),p!==null){for(r.flags|=128,Ol(u,!1),e=p.updateQueue,r.updateQueue=e,wu(r,e),r.subtreeFlags=0,e=l,l=r.child;l!==null;)gb(l,e),l=l.sibling;return T(ce,ce.current&1|2),Bt&&nr(r,u.treeForkCount),r.child}e=e.sibling}u.tail!==null&&He()>Au&&(r.flags|=128,f=!0,Ol(u,!1),r.lanes=4194304)}else{if(!f)if(e=ou(p),e!==null){if(r.flags|=128,f=!0,e=e.updateQueue,r.updateQueue=e,wu(r,e),Ol(u,!0),u.tail===null&&u.tailMode==="hidden"&&!p.alternate&&!Bt)return ie(r),null}else 2*He()-u.renderingStartTime>Au&&l!==536870912&&(r.flags|=128,f=!0,Ol(u,!1),r.lanes=4194304);u.isBackwards?(p.sibling=r.child,r.child=p):(e=u.last,e!==null?e.sibling=p:r.child=p,u.last=p)}return u.tail!==null?(e=u.tail,u.rendering=e,u.tail=e.sibling,u.renderingStartTime=He(),e.sibling=null,l=ce.current,T(ce,f?l&1|2:l&1),Bt&&nr(r,u.treeForkCount),e):(ie(r),null);case 22:case 23:return cn(r),zf(),u=r.memoizedState!==null,e!==null?e.memoizedState!==null!==u&&(r.flags|=8192):u&&(r.flags|=8192),u?(l&536870912)!==0&&(r.flags&128)===0&&(ie(r),r.subtreeFlags&6&&(r.flags|=8192)):ie(r),l=r.updateQueue,l!==null&&wu(r,l.retryQueue),l=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(l=e.memoizedState.cachePool.pool),u=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(u=r.memoizedState.cachePool.pool),u!==l&&(r.flags|=2048),e!==null&&P(da),null;case 24:return l=null,e!==null&&(l=e.memoizedState.cache),r.memoizedState.cache!==l&&(r.flags|=2048),ar(me),ie(r),null;case 25:return null;case 30:return null}throw Error(i(156,r.tag))}function dz(e,r){switch(gf(r),r.tag){case 1:return e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 3:return ar(me),Ht(),e=r.flags,(e&65536)!==0&&(e&128)===0?(r.flags=e&-65537|128,r):null;case 26:case 27:case 5:return yn(r),null;case 31:if(r.memoizedState!==null){if(cn(r),r.alternate===null)throw Error(i(340));oa()}return e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 13:if(cn(r),e=r.memoizedState,e!==null&&e.dehydrated!==null){if(r.alternate===null)throw Error(i(340));oa()}return e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 19:return P(ce),null;case 4:return Ht(),null;case 10:return ar(r.type),null;case 22:case 23:return cn(r),zf(),e!==null&&P(da),e=r.flags,e&65536?(r.flags=e&-65537|128,r):null;case 24:return ar(me),null;case 25:return null;default:return null}}function Yv(e,r){switch(gf(r),r.tag){case 3:ar(me),Ht();break;case 26:case 27:case 5:yn(r);break;case 4:Ht();break;case 31:r.memoizedState!==null&&cn(r);break;case 13:cn(r);break;case 19:P(ce);break;case 10:ar(r.type);break;case 22:case 23:cn(r),zf(),e!==null&&P(da);break;case 24:ar(me)}}function Dl(e,r){try{var l=r.updateQueue,u=l!==null?l.lastEffect:null;if(u!==null){var f=u.next;l=f;do{if((l.tag&e)===e){u=void 0;var p=l.create,b=l.inst;u=p(),b.destroy=u}l=l.next}while(l!==f)}}catch(S){Pt(r,r.return,S)}}function Dr(e,r,l){try{var u=r.updateQueue,f=u!==null?u.lastEffect:null;if(f!==null){var p=f.next;u=p;do{if((u.tag&e)===e){var b=u.inst,S=b.destroy;if(S!==void 0){b.destroy=void 0,f=r;var A=l,U=S;try{U()}catch(X){Pt(f,A,X)}}}u=u.next}while(u!==p)}}catch(X){Pt(r,r.return,X)}}function Fv(e){var r=e.updateQueue;if(r!==null){var l=e.stateNode;try{Nb(r,l)}catch(u){Pt(e,e.return,u)}}}function Gv(e,r,l){l.props=ya(e.type,e.memoizedProps),l.state=e.memoizedState;try{l.componentWillUnmount()}catch(u){Pt(e,r,u)}}function Nl(e,r){try{var l=e.ref;if(l!==null){switch(e.tag){case 26:case 27:case 5:var u=e.stateNode;break;case 30:u=e.stateNode;break;default:u=e.stateNode}typeof l=="function"?e.refCleanup=l(u):l.current=u}}catch(f){Pt(e,r,f)}}function Fn(e,r){var l=e.ref,u=e.refCleanup;if(l!==null)if(typeof u=="function")try{u()}catch(f){Pt(e,r,f)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(f){Pt(e,r,f)}else l.current=null}function Pv(e){var r=e.type,l=e.memoizedProps,u=e.stateNode;try{t:switch(r){case"button":case"input":case"select":case"textarea":l.autoFocus&&u.focus();break t;case"img":l.src?u.src=l.src:l.srcSet&&(u.srcset=l.srcSet)}}catch(f){Pt(e,e.return,f)}}function od(e,r,l){try{var u=e.stateNode;Nz(u,e.type,l,r),u[Pe]=r}catch(f){Pt(e,e.return,f)}}function Xv(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Hr(e.type)||e.tag===4}function cd(e){t:for(;;){for(;e.sibling===null;){if(e.return===null||Xv(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Hr(e.type)||e.flags&2||e.child===null||e.tag===4)continue t;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function fd(e,r,l){var u=e.tag;if(u===5||u===6)e=e.stateNode,r?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(e,r):(r=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,r.appendChild(e),l=l._reactRootContainer,l!=null||r.onclick!==null||(r.onclick=Wn));else if(u!==4&&(u===27&&Hr(e.type)&&(l=e.stateNode,r=null),e=e.child,e!==null))for(fd(e,r,l),e=e.sibling;e!==null;)fd(e,r,l),e=e.sibling}function _u(e,r,l){var u=e.tag;if(u===5||u===6)e=e.stateNode,r?l.insertBefore(e,r):l.appendChild(e);else if(u!==4&&(u===27&&Hr(e.type)&&(l=e.stateNode),e=e.child,e!==null))for(_u(e,r,l),e=e.sibling;e!==null;)_u(e,r,l),e=e.sibling}function Qv(e){var r=e.stateNode,l=e.memoizedProps;try{for(var u=e.type,f=r.attributes;f.length;)r.removeAttributeNode(f[0]);Me(r,u,l),r[Ce]=e,r[Pe]=l}catch(p){Pt(e,e.return,p)}}var or=!1,be=!1,dd=!1,Zv=typeof WeakSet=="function"?WeakSet:Set,Te=null;function hz(e,r){if(e=e.containerInfo,Dd=Fu,e=sb(e),af(e)){if("selectionStart"in e)var l={start:e.selectionStart,end:e.selectionEnd};else t:{l=(l=e.ownerDocument)&&l.defaultView||window;var u=l.getSelection&&l.getSelection();if(u&&u.rangeCount!==0){l=u.anchorNode;var f=u.anchorOffset,p=u.focusNode;u=u.focusOffset;try{l.nodeType,p.nodeType}catch(wt){l=null;break t}var b=0,S=-1,A=-1,U=0,X=0,K=e,V=null;e:for(;;){for(var F;K!==l||f!==0&&K.nodeType!==3||(S=b+f),K!==p||u!==0&&K.nodeType!==3||(A=b+u),K.nodeType===3&&(b+=K.nodeValue.length),(F=K.firstChild)!==null;)V=K,K=F;for(;;){if(K===e)break e;if(V===l&&++U===f&&(S=b),V===p&&++X===u&&(A=b),(F=K.nextSibling)!==null)break;K=V,V=K.parentNode}K=F}l=S===-1||A===-1?null:{start:S,end:A}}else l=null}l=l||{start:0,end:0}}else l=null;for(Nd={focusedElem:e,selectionRange:l},Fu=!1,Te=r;Te!==null;)if(r=Te,e=r.child,(r.subtreeFlags&1028)!==0&&e!==null)e.return=r,Te=e;else for(;Te!==null;){switch(r=Te,p=r.alternate,e=r.flags,r.tag){case 0:if((e&4)!==0&&(e=r.updateQueue,e=e!==null?e.events:null,e!==null))for(l=0;l<e.length;l++)f=e[l],f.ref.impl=f.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&p!==null){e=void 0,l=r,f=p.memoizedProps,p=p.memoizedState,u=l.stateNode;try{var dt=ya(l.type,f);e=u.getSnapshotBeforeUpdate(dt,p),u.__reactInternalSnapshotBeforeUpdate=e}catch(wt){Pt(l,l.return,wt)}}break;case 3:if((e&1024)!==0){if(e=r.stateNode.containerInfo,l=e.nodeType,l===9)Ld(e);else if(l===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Ld(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(i(163))}if(e=r.sibling,e!==null){e.return=r.return,Te=e;break}Te=r.return}}function Kv(e,r,l){var u=l.flags;switch(l.tag){case 0:case 11:case 15:fr(e,l),u&4&&Dl(5,l);break;case 1:if(fr(e,l),u&4)if(e=l.stateNode,r===null)try{e.componentDidMount()}catch(b){Pt(l,l.return,b)}else{var f=ya(l.type,r.memoizedProps);r=r.memoizedState;try{e.componentDidUpdate(f,r,e.__reactInternalSnapshotBeforeUpdate)}catch(b){Pt(l,l.return,b)}}u&64&&Fv(l),u&512&&Nl(l,l.return);break;case 3:if(fr(e,l),u&64&&(e=l.updateQueue,e!==null)){if(r=null,l.child!==null)switch(l.child.tag){case 27:case 5:r=l.child.stateNode;break;case 1:r=l.child.stateNode}try{Nb(e,r)}catch(b){Pt(l,l.return,b)}}break;case 27:r===null&&u&4&&Qv(l);case 26:case 5:fr(e,l),r===null&&u&4&&Pv(l),u&512&&Nl(l,l.return);break;case 12:fr(e,l);break;case 31:fr(e,l),u&4&&Wv(e,l);break;case 13:fr(e,l),u&4&&tx(e,l),u&64&&(e=l.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(l=wz.bind(null,l),Vz(e,l))));break;case 22:if(u=l.memoizedState!==null||or,!u){r=r!==null&&r.memoizedState!==null||be,f=or;var p=be;or=u,(be=r)&&!p?dr(e,l,(l.subtreeFlags&8772)!==0):fr(e,l),or=f,be=p}break;case 30:break;default:fr(e,l)}}function Jv(e){var r=e.alternate;r!==null&&(e.alternate=null,Jv(r)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(r=e.stateNode,r!==null&&qc(r)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var le=null,Qe=!1;function cr(e,r,l){for(l=l.child;l!==null;)$v(e,r,l),l=l.sibling}function $v(e,r,l){if(Se&&typeof Se.onCommitFiberUnmount=="function")try{Se.onCommitFiberUnmount(qe,l)}catch(p){}switch(l.tag){case 26:be||Fn(l,r),cr(e,r,l),l.memoizedState?l.memoizedState.count--:l.stateNode&&(l=l.stateNode,l.parentNode.removeChild(l));break;case 27:be||Fn(l,r);var u=le,f=Qe;Hr(l.type)&&(le=l.stateNode,Qe=!1),cr(e,r,l),Yl(l.stateNode),le=u,Qe=f;break;case 5:be||Fn(l,r);case 6:if(u=le,f=Qe,le=null,cr(e,r,l),le=u,Qe=f,le!==null)if(Qe)try{(le.nodeType===9?le.body:le.nodeName==="HTML"?le.ownerDocument.body:le).removeChild(l.stateNode)}catch(p){Pt(l,r,p)}else try{le.removeChild(l.stateNode)}catch(p){Pt(l,r,p)}break;case 18:le!==null&&(Qe?(e=le,Fx(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,l.stateNode),Ai(e)):Fx(le,l.stateNode));break;case 4:u=le,f=Qe,le=l.stateNode.containerInfo,Qe=!0,cr(e,r,l),le=u,Qe=f;break;case 0:case 11:case 14:case 15:Dr(2,l,r),be||Dr(4,l,r),cr(e,r,l);break;case 1:be||(Fn(l,r),u=l.stateNode,typeof u.componentWillUnmount=="function"&&Gv(l,r,u)),cr(e,r,l);break;case 21:cr(e,r,l);break;case 22:be=(u=be)||l.memoizedState!==null,cr(e,r,l),be=u;break;default:cr(e,r,l)}}function Wv(e,r){if(r.memoizedState===null&&(e=r.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Ai(e)}catch(l){Pt(r,r.return,l)}}}function tx(e,r){if(r.memoizedState===null&&(e=r.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Ai(e)}catch(l){Pt(r,r.return,l)}}function pz(e){switch(e.tag){case 31:case 13:case 19:var r=e.stateNode;return r===null&&(r=e.stateNode=new Zv),r;case 22:return e=e.stateNode,r=e._retryCache,r===null&&(r=e._retryCache=new Zv),r;default:throw Error(i(435,e.tag))}}function Tu(e,r){var l=pz(e);r.forEach(function(u){if(!l.has(u)){l.add(u);var f=_z.bind(null,e,u);u.then(f,f)}})}function Ze(e,r){var l=r.deletions;if(l!==null)for(var u=0;u<l.length;u++){var f=l[u],p=e,b=r,S=b;t:for(;S!==null;){switch(S.tag){case 27:if(Hr(S.type)){le=S.stateNode,Qe=!1;break t}break;case 5:le=S.stateNode,Qe=!1;break t;case 3:case 4:le=S.stateNode.containerInfo,Qe=!0;break t}S=S.return}if(le===null)throw Error(i(160));$v(p,b,f),le=null,Qe=!1,p=f.alternate,p!==null&&(p.return=null),f.return=null}if(r.subtreeFlags&13886)for(r=r.child;r!==null;)ex(r,e),r=r.sibling}var Ln=null;function ex(e,r){var l=e.alternate,u=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Ze(r,e),Ke(e),u&4&&(Dr(3,e,e.return),Dl(3,e),Dr(5,e,e.return));break;case 1:Ze(r,e),Ke(e),u&512&&(be||l===null||Fn(l,l.return)),u&64&&or&&(e=e.updateQueue,e!==null&&(u=e.callbacks,u!==null&&(l=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=l===null?u:l.concat(u))));break;case 26:var f=Ln;if(Ze(r,e),Ke(e),u&512&&(be||l===null||Fn(l,l.return)),u&4){var p=l!==null?l.memoizedState:null;if(u=e.memoizedState,l===null)if(u===null)if(e.stateNode===null){t:{u=e.type,l=e.memoizedProps,f=f.ownerDocument||f;e:switch(u){case"title":p=f.getElementsByTagName("title")[0],(!p||p[sl]||p[Ce]||p.namespaceURI==="http://www.w3.org/2000/svg"||p.hasAttribute("itemprop"))&&(p=f.createElement(u),f.head.insertBefore(p,f.querySelector("head > title"))),Me(p,u,l),p[Ce]=e,_e(p),u=p;break t;case"link":var b=eS("link","href",f).get(u+(l.href||""));if(b){for(var S=0;S<b.length;S++)if(p=b[S],p.getAttribute("href")===(l.href==null||l.href===""?null:l.href)&&p.getAttribute("rel")===(l.rel==null?null:l.rel)&&p.getAttribute("title")===(l.title==null?null:l.title)&&p.getAttribute("crossorigin")===(l.crossOrigin==null?null:l.crossOrigin)){b.splice(S,1);break e}}p=f.createElement(u),Me(p,u,l),f.head.appendChild(p);break;case"meta":if(b=eS("meta","content",f).get(u+(l.content||""))){for(S=0;S<b.length;S++)if(p=b[S],p.getAttribute("content")===(l.content==null?null:""+l.content)&&p.getAttribute("name")===(l.name==null?null:l.name)&&p.getAttribute("property")===(l.property==null?null:l.property)&&p.getAttribute("http-equiv")===(l.httpEquiv==null?null:l.httpEquiv)&&p.getAttribute("charset")===(l.charSet==null?null:l.charSet)){b.splice(S,1);break e}}p=f.createElement(u),Me(p,u,l),f.head.appendChild(p);break;default:throw Error(i(468,u))}p[Ce]=e,_e(p),u=p}e.stateNode=u}else nS(f,e.type,e.stateNode);else e.stateNode=tS(f,u,e.memoizedProps);else p!==u?(p===null?l.stateNode!==null&&(l=l.stateNode,l.parentNode.removeChild(l)):p.count--,u===null?nS(f,e.type,e.stateNode):tS(f,u,e.memoizedProps)):u===null&&e.stateNode!==null&&od(e,e.memoizedProps,l.memoizedProps)}break;case 27:Ze(r,e),Ke(e),u&512&&(be||l===null||Fn(l,l.return)),l!==null&&u&4&&od(e,e.memoizedProps,l.memoizedProps);break;case 5:if(Ze(r,e),Ke(e),u&512&&(be||l===null||Fn(l,l.return)),e.flags&32){f=e.stateNode;try{Ka(f,"")}catch(dt){Pt(e,e.return,dt)}}u&4&&e.stateNode!=null&&(f=e.memoizedProps,od(e,f,l!==null?l.memoizedProps:f)),u&1024&&(dd=!0);break;case 6:if(Ze(r,e),Ke(e),u&4){if(e.stateNode===null)throw Error(i(162));u=e.memoizedProps,l=e.stateNode;try{l.nodeValue=u}catch(dt){Pt(e,e.return,dt)}}break;case 3:if(Hu=null,f=Ln,Ln=Bu(r.containerInfo),Ze(r,e),Ln=f,Ke(e),u&4&&l!==null&&l.memoizedState.isDehydrated)try{Ai(r.containerInfo)}catch(dt){Pt(e,e.return,dt)}dd&&(dd=!1,nx(e));break;case 4:u=Ln,Ln=Bu(e.stateNode.containerInfo),Ze(r,e),Ke(e),Ln=u;break;case 12:Ze(r,e),Ke(e);break;case 31:Ze(r,e),Ke(e),u&4&&(u=e.updateQueue,u!==null&&(e.updateQueue=null,Tu(e,u)));break;case 13:Ze(r,e),Ke(e),e.child.flags&8192&&e.memoizedState!==null!=(l!==null&&l.memoizedState!==null)&&(Cu=He()),u&4&&(u=e.updateQueue,u!==null&&(e.updateQueue=null,Tu(e,u)));break;case 22:f=e.memoizedState!==null;var A=l!==null&&l.memoizedState!==null,U=or,X=be;if(or=U||f,be=X||A,Ze(r,e),be=X,or=U,Ke(e),u&8192)t:for(r=e.stateNode,r._visibility=f?r._visibility&-2:r._visibility|1,f&&(l===null||A||or||be||ba(e)),l=null,r=e;;){if(r.tag===5||r.tag===26){if(l===null){A=l=r;try{if(p=A.stateNode,f)b=p.style,typeof b.setProperty=="function"?b.setProperty("display","none","important"):b.display="none";else{S=A.stateNode;var K=A.memoizedProps.style,V=K!=null&&K.hasOwnProperty("display")?K.display:null;S.style.display=V==null||typeof V=="boolean"?"":(""+V).trim()}}catch(dt){Pt(A,A.return,dt)}}}else if(r.tag===6){if(l===null){A=r;try{A.stateNode.nodeValue=f?"":A.memoizedProps}catch(dt){Pt(A,A.return,dt)}}}else if(r.tag===18){if(l===null){A=r;try{var F=A.stateNode;f?Gx(F,!0):Gx(A.stateNode,!1)}catch(dt){Pt(A,A.return,dt)}}}else if((r.tag!==22&&r.tag!==23||r.memoizedState===null||r===e)&&r.child!==null){r.child.return=r,r=r.child;continue}if(r===e)break t;for(;r.sibling===null;){if(r.return===null||r.return===e)break t;l===r&&(l=null),r=r.return}l===r&&(l=null),r.sibling.return=r.return,r=r.sibling}u&4&&(u=e.updateQueue,u!==null&&(l=u.retryQueue,l!==null&&(u.retryQueue=null,Tu(e,l))));break;case 19:Ze(r,e),Ke(e),u&4&&(u=e.updateQueue,u!==null&&(e.updateQueue=null,Tu(e,u)));break;case 30:break;case 21:break;default:Ze(r,e),Ke(e)}}function Ke(e){var r=e.flags;if(r&2){try{for(var l,u=e.return;u!==null;){if(Xv(u)){l=u;break}u=u.return}if(l==null)throw Error(i(160));switch(l.tag){case 27:var f=l.stateNode,p=cd(e);_u(e,p,f);break;case 5:var b=l.stateNode;l.flags&32&&(Ka(b,""),l.flags&=-33);var S=cd(e);_u(e,S,b);break;case 3:case 4:var A=l.stateNode.containerInfo,U=cd(e);fd(e,U,A);break;default:throw Error(i(161))}}catch(X){Pt(e,e.return,X)}e.flags&=-3}r&4096&&(e.flags&=-4097)}function nx(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var r=e;nx(r),r.tag===5&&r.flags&1024&&r.stateNode.reset(),e=e.sibling}}function fr(e,r){if(r.subtreeFlags&8772)for(r=r.child;r!==null;)Kv(e,r.alternate,r),r=r.sibling}function ba(e){for(e=e.child;e!==null;){var r=e;switch(r.tag){case 0:case 11:case 14:case 15:Dr(4,r,r.return),ba(r);break;case 1:Fn(r,r.return);var l=r.stateNode;typeof l.componentWillUnmount=="function"&&Gv(r,r.return,l),ba(r);break;case 27:Yl(r.stateNode);case 26:case 5:Fn(r,r.return),ba(r);break;case 22:r.memoizedState===null&&ba(r);break;case 30:ba(r);break;default:ba(r)}e=e.sibling}}function dr(e,r,l){for(l=l&&(r.subtreeFlags&8772)!==0,r=r.child;r!==null;){var u=r.alternate,f=e,p=r,b=p.flags;switch(p.tag){case 0:case 11:case 15:dr(f,p,l),Dl(4,p);break;case 1:if(dr(f,p,l),u=p,f=u.stateNode,typeof f.componentDidMount=="function")try{f.componentDidMount()}catch(U){Pt(u,u.return,U)}if(u=p,f=u.updateQueue,f!==null){var S=u.stateNode;try{var A=f.shared.hiddenCallbacks;if(A!==null)for(f.shared.hiddenCallbacks=null,f=0;f<A.length;f++)Db(A[f],S)}catch(U){Pt(u,u.return,U)}}l&&b&64&&Fv(p),Nl(p,p.return);break;case 27:Qv(p);case 26:case 5:dr(f,p,l),l&&u===null&&b&4&&Pv(p),Nl(p,p.return);break;case 12:dr(f,p,l);break;case 31:dr(f,p,l),l&&b&4&&Wv(f,p);break;case 13:dr(f,p,l),l&&b&4&&tx(f,p);break;case 22:p.memoizedState===null&&dr(f,p,l),Nl(p,p.return);break;case 30:break;default:dr(f,p,l)}r=r.sibling}}function hd(e,r){var l=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(l=e.memoizedState.cachePool.pool),e=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(e=r.memoizedState.cachePool.pool),e!==l&&(e!=null&&e.refCount++,l!=null&&xl(l))}function pd(e,r){e=null,r.alternate!==null&&(e=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==e&&(r.refCount++,e!=null&&xl(e))}function Bn(e,r,l,u){if(r.subtreeFlags&10256)for(r=r.child;r!==null;)rx(e,r,l,u),r=r.sibling}function rx(e,r,l,u){var f=r.flags;switch(r.tag){case 0:case 11:case 15:Bn(e,r,l,u),f&2048&&Dl(9,r);break;case 1:Bn(e,r,l,u);break;case 3:Bn(e,r,l,u),f&2048&&(e=null,r.alternate!==null&&(e=r.alternate.memoizedState.cache),r=r.memoizedState.cache,r!==e&&(r.refCount++,e!=null&&xl(e)));break;case 12:if(f&2048){Bn(e,r,l,u),e=r.stateNode;try{var p=r.memoizedProps,b=p.id,S=p.onPostCommit;typeof S=="function"&&S(b,r.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(A){Pt(r,r.return,A)}}else Bn(e,r,l,u);break;case 31:Bn(e,r,l,u);break;case 13:Bn(e,r,l,u);break;case 23:break;case 22:p=r.stateNode,b=r.alternate,r.memoizedState!==null?p._visibility&2?Bn(e,r,l,u):Il(e,r):p._visibility&2?Bn(e,r,l,u):(p._visibility|=2,gi(e,r,l,u,(r.subtreeFlags&10256)!==0||!1)),f&2048&&hd(b,r);break;case 24:Bn(e,r,l,u),f&2048&&pd(r.alternate,r);break;default:Bn(e,r,l,u)}}function gi(e,r,l,u,f){for(f=f&&((r.subtreeFlags&10256)!==0||!1),r=r.child;r!==null;){var p=e,b=r,S=l,A=u,U=b.flags;switch(b.tag){case 0:case 11:case 15:gi(p,b,S,A,f),Dl(8,b);break;case 23:break;case 22:var X=b.stateNode;b.memoizedState!==null?X._visibility&2?gi(p,b,S,A,f):Il(p,b):(X._visibility|=2,gi(p,b,S,A,f)),f&&U&2048&&hd(b.alternate,b);break;case 24:gi(p,b,S,A,f),f&&U&2048&&pd(b.alternate,b);break;default:gi(p,b,S,A,f)}r=r.sibling}}function Il(e,r){if(r.subtreeFlags&10256)for(r=r.child;r!==null;){var l=e,u=r,f=u.flags;switch(u.tag){case 22:Il(l,u),f&2048&&hd(u.alternate,u);break;case 24:Il(l,u),f&2048&&pd(u.alternate,u);break;default:Il(l,u)}r=r.sibling}}var jl=8192;function yi(e,r,l){if(e.subtreeFlags&jl)for(e=e.child;e!==null;)ax(e,r,l),e=e.sibling}function ax(e,r,l){switch(e.tag){case 26:yi(e,r,l),e.flags&jl&&e.memoizedState!==null&&tO(l,Ln,e.memoizedState,e.memoizedProps);break;case 5:yi(e,r,l);break;case 3:case 4:var u=Ln;Ln=Bu(e.stateNode.containerInfo),yi(e,r,l),Ln=u;break;case 22:e.memoizedState===null&&(u=e.alternate,u!==null&&u.memoizedState!==null?(u=jl,jl=16777216,yi(e,r,l),jl=u):yi(e,r,l));break;default:yi(e,r,l)}}function ix(e){var r=e.alternate;if(r!==null&&(e=r.child,e!==null)){r.child=null;do r=e.sibling,e.sibling=null,e=r;while(e!==null)}}function Ll(e){var r=e.deletions;if((e.flags&16)!==0){if(r!==null)for(var l=0;l<r.length;l++){var u=r[l];Te=u,sx(u,e)}ix(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)lx(e),e=e.sibling}function lx(e){switch(e.tag){case 0:case 11:case 15:Ll(e),e.flags&2048&&Dr(9,e,e.return);break;case 3:Ll(e);break;case 12:Ll(e);break;case 22:var r=e.stateNode;e.memoizedState!==null&&r._visibility&2&&(e.return===null||e.return.tag!==13)?(r._visibility&=-3,Eu(e)):Ll(e);break;default:Ll(e)}}function Eu(e){var r=e.deletions;if((e.flags&16)!==0){if(r!==null)for(var l=0;l<r.length;l++){var u=r[l];Te=u,sx(u,e)}ix(e)}for(e=e.child;e!==null;){switch(r=e,r.tag){case 0:case 11:case 15:Dr(8,r,r.return),Eu(r);break;case 22:l=r.stateNode,l._visibility&2&&(l._visibility&=-3,Eu(r));break;default:Eu(r)}e=e.sibling}}function sx(e,r){for(;Te!==null;){var l=Te;switch(l.tag){case 0:case 11:case 15:Dr(8,l,r);break;case 23:case 22:if(l.memoizedState!==null&&l.memoizedState.cachePool!==null){var u=l.memoizedState.cachePool.pool;u!=null&&u.refCount++}break;case 24:xl(l.memoizedState.cache)}if(u=l.child,u!==null)u.return=l,Te=u;else t:for(l=e;Te!==null;){u=Te;var f=u.sibling,p=u.return;if(Jv(u),u===l){Te=null;break t}if(f!==null){f.return=p,Te=f;break t}Te=p}}}var mz={getCacheForType:function(e){var r=ke(me),l=r.data.get(e);return l===void 0&&(l=e(),r.data.set(e,l)),l},cacheSignal:function(){return ke(me).controller.signal}},gz=typeof WeakMap=="function"?WeakMap:Map,Yt=0,te=null,Nt=null,jt=0,Gt=0,fn=null,Nr=!1,bi=!1,md=!1,hr=0,oe=0,Ir=0,va=0,gd=0,dn=0,vi=0,Bl=null,Je=null,yd=!1,Cu=0,ux=0,Au=1/0,ku=null,jr=null,we=0,Lr=null,xi=null,pr=0,bd=0,vd=null,ox=null,Ul=0,xd=null;function hn(){return(Yt&2)!==0&&jt!==0?jt&-jt:H.T!==null?Cd():Ey()}function cx(){if(dn===0)if((jt&536870912)===0||Bt){var e=js;js<<=1,(js&3932160)===0&&(js=262144),dn=e}else dn=536870912;return e=on.current,e!==null&&(e.flags|=32),dn}function $e(e,r,l){(e===te&&(Gt===2||Gt===9)||e.cancelPendingCommit!==null)&&(Si(e,0),Br(e,jt,dn,!1)),ll(e,l),((Yt&2)===0||e!==te)&&(e===te&&((Yt&2)===0&&(va|=l),oe===4&&Br(e,jt,dn,!1)),Gn(e))}function fx(e,r,l){if((Yt&6)!==0)throw Error(i(327));var u=!l&&(r&127)===0&&(r&e.expiredLanes)===0||il(e,r),f=u?vz(e,r):wd(e,r,!0),p=u;do{if(f===0){bi&&!u&&Br(e,r,0,!1);break}else{if(l=e.current.alternate,p&&!yz(l)){f=wd(e,r,!1),p=!1;continue}if(f===2){if(p=r,e.errorRecoveryDisabledLanes&p)var b=0;else b=e.pendingLanes&-536870913,b=b!==0?b:b&536870912?536870912:0;if(b!==0){r=b;t:{var S=e;f=Bl;var A=S.current.memoizedState.isDehydrated;if(A&&(Si(S,b).flags|=256),b=wd(S,b,!1),b!==2){if(md&&!A){S.errorRecoveryDisabledLanes|=p,va|=p,f=4;break t}p=Je,Je=f,p!==null&&(Je===null?Je=p:Je.push.apply(Je,p))}f=b}if(p=!1,f!==2)continue}}if(f===1){Si(e,0),Br(e,r,0,!0);break}t:{switch(u=e,p=f,p){case 0:case 1:throw Error(i(345));case 4:if((r&4194048)!==r)break;case 6:Br(u,r,dn,!Nr);break t;case 2:Je=null;break;case 3:case 5:break;default:throw Error(i(329))}if((r&62914560)===r&&(f=Cu+300-He(),10<f)){if(Br(u,r,dn,!Nr),Bs(u,0,!0)!==0)break t;pr=r,u.timeoutHandle=Vx(dx.bind(null,u,l,Je,ku,yd,r,dn,va,vi,Nr,p,"Throttled",-0,0),f);break t}dx(u,l,Je,ku,yd,r,dn,va,vi,Nr,p,null,-0,0)}}break}while(!0);Gn(e)}function dx(e,r,l,u,f,p,b,S,A,U,X,K,V,F){if(e.timeoutHandle=-1,K=r.subtreeFlags,K&8192||(K&16785408)===16785408){K={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Wn},ax(r,p,K);var dt=(p&62914560)===p?Cu-He():(p&4194048)===p?ux-He():0;if(dt=eO(K,dt),dt!==null){pr=p,e.cancelPendingCommit=dt(xx.bind(null,e,r,p,l,u,f,b,S,A,X,K,null,V,F)),Br(e,p,b,!U);return}}xx(e,r,p,l,u,f,b,S,A)}function yz(e){for(var r=e;;){var l=r.tag;if((l===0||l===11||l===15)&&r.flags&16384&&(l=r.updateQueue,l!==null&&(l=l.stores,l!==null)))for(var u=0;u<l.length;u++){var f=l[u],p=f.getSnapshot;f=f.value;try{if(!sn(p(),f))return!1}catch(b){return!1}}if(l=r.child,r.subtreeFlags&16384&&l!==null)l.return=r,r=l;else{if(r===e)break;for(;r.sibling===null;){if(r.return===null||r.return===e)return!0;r=r.return}r.sibling.return=r.return,r=r.sibling}}return!0}function Br(e,r,l,u){r&=~gd,r&=~va,e.suspendedLanes|=r,e.pingedLanes&=~r,u&&(e.warmLanes|=r),u=e.expirationTimes;for(var f=r;0<f;){var p=31-Wt(f),b=1<<p;u[p]=-1,f&=~b}l!==0&&wy(e,l,r)}function Ru(){return(Yt&6)===0?(Hl(0),!1):!0}function Sd(){if(Nt!==null){if(Gt===0)var e=Nt.return;else e=Nt,rr=ca=null,Lf(e),fi=null,wl=0,e=Nt;for(;e!==null;)Yv(e.alternate,e),e=e.return;Nt=null}}function Si(e,r){var l=e.timeoutHandle;l!==-1&&(e.timeoutHandle=-1,Lz(l)),l=e.cancelPendingCommit,l!==null&&(e.cancelPendingCommit=null,l()),pr=0,Sd(),te=e,Nt=l=er(e.current,null),jt=r,Gt=0,fn=null,Nr=!1,bi=il(e,r),md=!1,vi=dn=gd=va=Ir=oe=0,Je=Bl=null,yd=!1,(r&8)!==0&&(r|=r&32);var u=e.entangledLanes;if(u!==0)for(e=e.entanglements,u&=r;0<u;){var f=31-Wt(u),p=1<<f;r|=e[f],u&=~p}return hr=r,Ks(),l}function hx(e,r){kt=null,H.H=Ml,r===ci||r===au?(r=Rb(),Gt=3):r===Ef?(r=Rb(),Gt=4):Gt=r===Wf?8:r!==null&&typeof r=="object"&&typeof r.then=="function"?6:1,fn=r,Nt===null&&(oe=1,bu(e,Sn(r,e.current)))}function px(){var e=on.current;return e===null?!0:(jt&4194048)===jt?En===null:(jt&62914560)===jt||(jt&536870912)!==0?e===En:!1}function mx(){var e=H.H;return H.H=Ml,e===null?Ml:e}function gx(){var e=H.A;return H.A=mz,e}function Mu(){oe=4,Nr||(jt&4194048)!==jt&&on.current!==null||(bi=!0),(Ir&134217727)===0&&(va&134217727)===0||te===null||Br(te,jt,dn,!1)}function wd(e,r,l){var u=Yt;Yt|=2;var f=mx(),p=gx();(te!==e||jt!==r)&&(ku=null,Si(e,r)),r=!1;var b=oe;t:do try{if(Gt!==0&&Nt!==null){var S=Nt,A=fn;switch(Gt){case 8:Sd(),b=6;break t;case 3:case 2:case 9:case 6:on.current===null&&(r=!0);var U=Gt;if(Gt=0,fn=null,wi(e,S,A,U),l&&bi){b=0;break t}break;default:U=Gt,Gt=0,fn=null,wi(e,S,A,U)}}bz(),b=oe;break}catch(X){hx(e,X)}while(!0);return r&&e.shellSuspendCounter++,rr=ca=null,Yt=u,H.H=f,H.A=p,Nt===null&&(te=null,jt=0,Ks()),b}function bz(){for(;Nt!==null;)yx(Nt)}function vz(e,r){var l=Yt;Yt|=2;var u=mx(),f=gx();te!==e||jt!==r?(ku=null,Au=He()+500,Si(e,r)):bi=il(e,r);t:do try{if(Gt!==0&&Nt!==null){r=Nt;var p=fn;e:switch(Gt){case 1:Gt=0,fn=null,wi(e,r,p,1);break;case 2:case 9:if(Ab(p)){Gt=0,fn=null,bx(r);break}r=function(){Gt!==2&&Gt!==9||te!==e||(Gt=7),Gn(e)},p.then(r,r);break t;case 3:Gt=7;break t;case 4:Gt=5;break t;case 7:Ab(p)?(Gt=0,fn=null,bx(r)):(Gt=0,fn=null,wi(e,r,p,7));break;case 5:var b=null;switch(Nt.tag){case 26:b=Nt.memoizedState;case 5:case 27:var S=Nt;if(b?rS(b):S.stateNode.complete){Gt=0,fn=null;var A=S.sibling;if(A!==null)Nt=A;else{var U=S.return;U!==null?(Nt=U,zu(U)):Nt=null}break e}}Gt=0,fn=null,wi(e,r,p,5);break;case 6:Gt=0,fn=null,wi(e,r,p,6);break;case 8:Sd(),oe=6;break t;default:throw Error(i(462))}}xz();break}catch(X){hx(e,X)}while(!0);return rr=ca=null,H.H=u,H.A=f,Yt=l,Nt!==null?0:(te=null,jt=0,Ks(),oe)}function xz(){for(;Nt!==null&&!Nc();)yx(Nt)}function yx(e){var r=qv(e.alternate,e,hr);e.memoizedProps=e.pendingProps,r===null?zu(e):Nt=r}function bx(e){var r=e,l=r.alternate;switch(r.tag){case 15:case 0:r=Iv(l,r,r.pendingProps,r.type,void 0,jt);break;case 11:r=Iv(l,r,r.pendingProps,r.type.render,r.ref,jt);break;case 5:Lf(r);default:Yv(l,r),r=Nt=gb(r,hr),r=qv(l,r,hr)}e.memoizedProps=e.pendingProps,r===null?zu(e):Nt=r}function wi(e,r,l,u){rr=ca=null,Lf(r),fi=null,wl=0;var f=r.return;try{if(uz(e,f,r,l,jt)){oe=1,bu(e,Sn(l,e.current)),Nt=null;return}}catch(p){if(f!==null)throw Nt=f,p;oe=1,bu(e,Sn(l,e.current)),Nt=null;return}r.flags&32768?(Bt||u===1?e=!0:bi||(jt&536870912)!==0?e=!1:(Nr=e=!0,(u===2||u===9||u===3||u===6)&&(u=on.current,u!==null&&u.tag===13&&(u.flags|=16384))),vx(r,e)):zu(r)}function zu(e){var r=e;do{if((r.flags&32768)!==0){vx(r,Nr);return}e=r.return;var l=fz(r.alternate,r,hr);if(l!==null){Nt=l;return}if(r=r.sibling,r!==null){Nt=r;return}Nt=r=e}while(r!==null);oe===0&&(oe=5)}function vx(e,r){do{var l=dz(e.alternate,e);if(l!==null){l.flags&=32767,Nt=l;return}if(l=e.return,l!==null&&(l.flags|=32768,l.subtreeFlags=0,l.deletions=null),!r&&(e=e.sibling,e!==null)){Nt=e;return}Nt=e=l}while(e!==null);oe=6,Nt=null}function xx(e,r,l,u,f,p,b,S,A){e.cancelPendingCommit=null;do Ou();while(we!==0);if((Yt&6)!==0)throw Error(i(327));if(r!==null){if(r===e.current)throw Error(i(177));if(p=r.lanes|r.childLanes,p|=cf,W2(e,l,p,b,S,A),e===te&&(Nt=te=null,jt=0),xi=r,Lr=e,pr=l,bd=p,vd=f,ox=u,(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,Tz(Et,function(){return Ex(),null})):(e.callbackNode=null,e.callbackPriority=0),u=(r.flags&13878)!==0,(r.subtreeFlags&13878)!==0||u){u=H.T,H.T=null,f=et.p,et.p=2,b=Yt,Yt|=4;try{hz(e,r,l)}finally{Yt=b,et.p=f,H.T=u}}we=1,Sx(),wx(),_x()}}function Sx(){if(we===1){we=0;var e=Lr,r=xi,l=(r.flags&13878)!==0;if((r.subtreeFlags&13878)!==0||l){l=H.T,H.T=null;var u=et.p;et.p=2;var f=Yt;Yt|=4;try{ex(r,e);var p=Nd,b=sb(e.containerInfo),S=p.focusedElem,A=p.selectionRange;if(b!==S&&S&&S.ownerDocument&&lb(S.ownerDocument.documentElement,S)){if(A!==null&&af(S)){var U=A.start,X=A.end;if(X===void 0&&(X=U),"selectionStart"in S)S.selectionStart=U,S.selectionEnd=Math.min(X,S.value.length);else{var K=S.ownerDocument||document,V=K&&K.defaultView||window;if(V.getSelection){var F=V.getSelection(),dt=S.textContent.length,wt=Math.min(A.start,dt),Zt=A.end===void 0?wt:Math.min(A.end,dt);!F.extend&&wt>Zt&&(b=Zt,Zt=wt,wt=b);var N=ib(S,wt),O=ib(S,Zt);if(N&&O&&(F.rangeCount!==1||F.anchorNode!==N.node||F.anchorOffset!==N.offset||F.focusNode!==O.node||F.focusOffset!==O.offset)){var B=K.createRange();B.setStart(N.node,N.offset),F.removeAllRanges(),wt>Zt?(F.addRange(B),F.extend(O.node,O.offset)):(B.setEnd(O.node,O.offset),F.addRange(B))}}}}for(K=[],F=S;F=F.parentNode;)F.nodeType===1&&K.push({element:F,left:F.scrollLeft,top:F.scrollTop});for(typeof S.focus=="function"&&S.focus(),S=0;S<K.length;S++){var Z=K[S];Z.element.scrollLeft=Z.left,Z.element.scrollTop=Z.top}}Fu=!!Dd,Nd=Dd=null}finally{Yt=f,et.p=u,H.T=l}}e.current=r,we=2}}function wx(){if(we===2){we=0;var e=Lr,r=xi,l=(r.flags&8772)!==0;if((r.subtreeFlags&8772)!==0||l){l=H.T,H.T=null;var u=et.p;et.p=2;var f=Yt;Yt|=4;try{Kv(e,r.alternate,r)}finally{Yt=f,et.p=u,H.T=l}}we=3}}function _x(){if(we===4||we===3){we=0,Ic();var e=Lr,r=xi,l=pr,u=ox;(r.subtreeFlags&10256)!==0||(r.flags&10256)!==0?we=5:(we=0,xi=Lr=null,Tx(e,e.pendingLanes));var f=e.pendingLanes;if(f===0&&(jr=null),Uc(l),r=r.stateNode,Se&&typeof Se.onCommitFiberRoot=="function")try{Se.onCommitFiberRoot(qe,r,void 0,(r.current.flags&128)===128)}catch(A){}if(u!==null){r=H.T,f=et.p,et.p=2,H.T=null;try{for(var p=e.onRecoverableError,b=0;b<u.length;b++){var S=u[b];p(S.value,{componentStack:S.stack})}}finally{H.T=r,et.p=f}}(pr&3)!==0&&Ou(),Gn(e),f=e.pendingLanes,(l&261930)!==0&&(f&42)!==0?e===xd?Ul++:(Ul=0,xd=e):Ul=0,Hl(0)}}function Tx(e,r){(e.pooledCacheLanes&=r)===0&&(r=e.pooledCache,r!=null&&(e.pooledCache=null,xl(r)))}function Ou(){return Sx(),wx(),_x(),Ex()}function Ex(){if(we!==5)return!1;var e=Lr,r=bd;bd=0;var l=Uc(pr),u=H.T,f=et.p;try{et.p=32>l?32:l,H.T=null,l=vd,vd=null;var p=Lr,b=pr;if(we=0,xi=Lr=null,pr=0,(Yt&6)!==0)throw Error(i(331));var S=Yt;if(Yt|=4,lx(p.current),rx(p,p.current,b,l),Yt=S,Hl(0,!1),Se&&typeof Se.onPostCommitFiberRoot=="function")try{Se.onPostCommitFiberRoot(qe,p)}catch(A){}return!0}finally{et.p=f,H.T=u,Tx(e,r)}}function Cx(e,r,l){r=Sn(l,r),r=$f(e.stateNode,r,2),e=Mr(e,r,2),e!==null&&(ll(e,2),Gn(e))}function Pt(e,r,l){if(e.tag===3)Cx(e,e,l);else for(;r!==null;){if(r.tag===3){Cx(r,e,l);break}else if(r.tag===1){var u=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(jr===null||!jr.has(u))){e=Sn(l,e),l=Av(2),u=Mr(r,l,2),u!==null&&(kv(l,u,r,e),ll(u,2),Gn(u));break}}r=r.return}}function _d(e,r,l){var u=e.pingCache;if(u===null){u=e.pingCache=new gz;var f=new Set;u.set(r,f)}else f=u.get(r),f===void 0&&(f=new Set,u.set(r,f));f.has(l)||(md=!0,f.add(l),e=Sz.bind(null,e,r,l),r.then(e,e))}function Sz(e,r,l){var u=e.pingCache;u!==null&&u.delete(r),e.pingedLanes|=e.suspendedLanes&l,e.warmLanes&=~l,te===e&&(jt&l)===l&&(oe===4||oe===3&&(jt&62914560)===jt&&300>He()-Cu?(Yt&2)===0&&Si(e,0):gd|=l,vi===jt&&(vi=0)),Gn(e)}function Ax(e,r){r===0&&(r=Sy()),e=sa(e,r),e!==null&&(ll(e,r),Gn(e))}function wz(e){var r=e.memoizedState,l=0;r!==null&&(l=r.retryLane),Ax(e,l)}function _z(e,r){var l=0;switch(e.tag){case 31:case 13:var u=e.stateNode,f=e.memoizedState;f!==null&&(l=f.retryLane);break;case 19:u=e.stateNode;break;case 22:u=e.stateNode._retryCache;break;default:throw Error(i(314))}u!==null&&u.delete(r),Ax(e,l)}function Tz(e,r){return Ya(e,r)}var Du=null,_i=null,Td=!1,Nu=!1,Ed=!1,Ur=0;function Gn(e){e!==_i&&e.next===null&&(_i===null?Du=_i=e:_i=_i.next=e),Nu=!0,Td||(Td=!0,Cz())}function Hl(e,r){if(!Ed&&Nu){Ed=!0;do for(var l=!1,u=Du;u!==null;){if(e!==0){var f=u.pendingLanes;if(f===0)var p=0;else{var b=u.suspendedLanes,S=u.pingedLanes;p=(1<<31-Wt(42|e)+1)-1,p&=f&~(b&~S),p=p&201326741?p&201326741|1:p?p|2:0}p!==0&&(l=!0,zx(u,p))}else p=jt,p=Bs(u,u===te?p:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(p&3)===0||il(u,p)||(l=!0,zx(u,p));u=u.next}while(l);Ed=!1}}function Ez(){kx()}function kx(){Nu=Td=!1;var e=0;Ur!==0&&jz()&&(e=Ur);for(var r=He(),l=null,u=Du;u!==null;){var f=u.next,p=Rx(u,r);p===0?(u.next=null,l===null?Du=f:l.next=f,f===null&&(_i=l)):(l=u,(e!==0||(p&3)!==0)&&(Nu=!0)),u=f}we!==0&&we!==5||Hl(e),Ur!==0&&(Ur=0)}function Rx(e,r){for(var l=e.suspendedLanes,u=e.pingedLanes,f=e.expirationTimes,p=e.pendingLanes&-62914561;0<p;){var b=31-Wt(p),S=1<<b,A=f[b];A===-1?((S&l)===0||(S&u)!==0)&&(f[b]=$2(S,r)):A<=r&&(e.expiredLanes|=S),p&=~S}if(r=te,l=jt,l=Bs(e,e===r?l:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),u=e.callbackNode,l===0||e===r&&(Gt===2||Gt===9)||e.cancelPendingCommit!==null)return u!==null&&u!==null&&al(u),e.callbackNode=null,e.callbackPriority=0;if((l&3)===0||il(e,l)){if(r=l&-l,r===e.callbackPriority)return r;switch(u!==null&&al(u),Uc(l)){case 2:case 8:l=it;break;case 32:l=Et;break;case 268435456:l=Ft;break;default:l=Et}return u=Mx.bind(null,e),l=Ya(l,u),e.callbackPriority=r,e.callbackNode=l,r}return u!==null&&u!==null&&al(u),e.callbackPriority=2,e.callbackNode=null,2}function Mx(e,r){if(we!==0&&we!==5)return e.callbackNode=null,e.callbackPriority=0,null;var l=e.callbackNode;if(Ou()&&e.callbackNode!==l)return null;var u=jt;return u=Bs(e,e===te?u:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),u===0?null:(fx(e,u,r),Rx(e,He()),e.callbackNode!=null&&e.callbackNode===l?Mx.bind(null,e):null)}function zx(e,r){if(Ou())return null;fx(e,r,!0)}function Cz(){Bz(function(){(Yt&6)!==0?Ya(Q,Ez):kx()})}function Cd(){if(Ur===0){var e=ui;e===0&&(e=Is,Is<<=1,(Is&261888)===0&&(Is=256)),Ur=e}return Ur}function Ox(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Vs(""+e)}function Dx(e,r){var l=r.ownerDocument.createElement("input");return l.name=r.name,l.value=r.value,e.id&&l.setAttribute("form",e.id),r.parentNode.insertBefore(l,r),e=new FormData(e),l.parentNode.removeChild(l),e}function Az(e,r,l,u,f){if(r==="submit"&&l&&l.stateNode===f){var p=Ox((f[Pe]||null).action),b=u.submitter;b&&(r=(r=b[Pe]||null)?Ox(r.formAction):b.getAttribute("formAction"),r!==null&&(p=r,b=null));var S=new Ps("action","action",null,u,f);e.push({event:S,listeners:[{instance:null,listener:function(){if(u.defaultPrevented){if(Ur!==0){var A=b?Dx(f,b):new FormData(f);Pf(l,{pending:!0,data:A,method:f.method,action:p},null,A)}}else typeof p=="function"&&(S.preventDefault(),A=b?Dx(f,b):new FormData(f),Pf(l,{pending:!0,data:A,method:f.method,action:p},p,A))},currentTarget:f}]})}}for(var Ad=0;Ad<of.length;Ad++){var kd=of[Ad],kz=kd.toLowerCase(),Rz=kd[0].toUpperCase()+kd.slice(1);jn(kz,"on"+Rz)}jn(cb,"onAnimationEnd"),jn(fb,"onAnimationIteration"),jn(db,"onAnimationStart"),jn("dblclick","onDoubleClick"),jn("focusin","onFocus"),jn("focusout","onBlur"),jn(GM,"onTransitionRun"),jn(PM,"onTransitionStart"),jn(XM,"onTransitionCancel"),jn(hb,"onTransitionEnd"),Qa("onMouseEnter",["mouseout","mouseover"]),Qa("onMouseLeave",["mouseout","mouseover"]),Qa("onPointerEnter",["pointerout","pointerover"]),Qa("onPointerLeave",["pointerout","pointerover"]),ra("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ra("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ra("onBeforeInput",["compositionend","keypress","textInput","paste"]),ra("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ra("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ra("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ql="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Mz=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(ql));function Nx(e,r){r=(r&4)!==0;for(var l=0;l<e.length;l++){var u=e[l],f=u.event;u=u.listeners;t:{var p=void 0;if(r)for(var b=u.length-1;0<=b;b--){var S=u[b],A=S.instance,U=S.currentTarget;if(S=S.listener,A!==p&&f.isPropagationStopped())break t;p=S,f.currentTarget=U;try{p(f)}catch(X){Zs(X)}f.currentTarget=null,p=A}else for(b=0;b<u.length;b++){if(S=u[b],A=S.instance,U=S.currentTarget,S=S.listener,A!==p&&f.isPropagationStopped())break t;p=S,f.currentTarget=U;try{p(f)}catch(X){Zs(X)}f.currentTarget=null,p=A}}}}function It(e,r){var l=r[Hc];l===void 0&&(l=r[Hc]=new Set);var u=e+"__bubble";l.has(u)||(Ix(r,e,2,!1),l.add(u))}function Rd(e,r,l){var u=0;r&&(u|=4),Ix(l,e,u,r)}var Iu="_reactListening"+Math.random().toString(36).slice(2);function Md(e){if(!e[Iu]){e[Iu]=!0,ky.forEach(function(l){l!=="selectionchange"&&(Mz.has(l)||Rd(l,!1,e),Rd(l,!0,e))});var r=e.nodeType===9?e:e.ownerDocument;r===null||r[Iu]||(r[Iu]=!0,Rd("selectionchange",!1,r))}}function Ix(e,r,l,u){switch(cS(r)){case 2:var f=aO;break;case 8:f=iO;break;default:f=Gd}l=f.bind(null,r,l,e),f=void 0,!Zc||r!=="touchstart"&&r!=="touchmove"&&r!=="wheel"||(f=!0),u?f!==void 0?e.addEventListener(r,l,{capture:!0,passive:f}):e.addEventListener(r,l,!0):f!==void 0?e.addEventListener(r,l,{passive:f}):e.addEventListener(r,l,!1)}function zd(e,r,l,u,f){var p=u;if((r&1)===0&&(r&2)===0&&u!==null)t:for(;;){if(u===null)return;var b=u.tag;if(b===3||b===4){var S=u.stateNode.containerInfo;if(S===f)break;if(b===4)for(b=u.return;b!==null;){var A=b.tag;if((A===3||A===4)&&b.stateNode.containerInfo===f)return;b=b.return}for(;S!==null;){if(b=Ga(S),b===null)return;if(A=b.tag,A===5||A===6||A===26||A===27){u=p=b;continue t}S=S.parentNode}}u=u.return}Hy(function(){var U=p,X=Xc(l),K=[];t:{var V=pb.get(e);if(V!==void 0){var F=Ps,dt=e;switch(e){case"keypress":if(Fs(l)===0)break t;case"keydown":case"keyup":F=_M;break;case"focusin":dt="focus",F=Wc;break;case"focusout":dt="blur",F=Wc;break;case"beforeblur":case"afterblur":F=Wc;break;case"click":if(l.button===2)break t;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":F=Yy;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":F=fM;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":F=CM;break;case cb:case fb:case db:F=pM;break;case hb:F=kM;break;case"scroll":case"scrollend":F=oM;break;case"wheel":F=MM;break;case"copy":case"cut":case"paste":F=gM;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":F=Gy;break;case"toggle":case"beforetoggle":F=OM}var wt=(r&4)!==0,Zt=!wt&&(e==="scroll"||e==="scrollend"),N=wt?V!==null?V+"Capture":null:V;wt=[];for(var O=U,B;O!==null;){var Z=O;if(B=Z.stateNode,Z=Z.tag,Z!==5&&Z!==26&&Z!==27||B===null||N===null||(Z=ol(O,N),Z!=null&&wt.push(Vl(O,Z,B))),Zt)break;O=O.return}0<wt.length&&(V=new F(V,dt,null,l,X),K.push({event:V,listeners:wt}))}}if((r&7)===0){t:{if(V=e==="mouseover"||e==="pointerover",F=e==="mouseout"||e==="pointerout",V&&l!==Pc&&(dt=l.relatedTarget||l.fromElement)&&(Ga(dt)||dt[Fa]))break t;if((F||V)&&(V=X.window===X?X:(V=X.ownerDocument)?V.defaultView||V.parentWindow:window,F?(dt=l.relatedTarget||l.toElement,F=U,dt=dt?Ga(dt):null,dt!==null&&(Zt=o(dt),wt=dt.tag,dt!==Zt||wt!==5&&wt!==27&&wt!==6)&&(dt=null)):(F=null,dt=U),F!==dt)){if(wt=Yy,Z="onMouseLeave",N="onMouseEnter",O="mouse",(e==="pointerout"||e==="pointerover")&&(wt=Gy,Z="onPointerLeave",N="onPointerEnter",O="pointer"),Zt=F==null?V:ul(F),B=dt==null?V:ul(dt),V=new wt(Z,O+"leave",F,l,X),V.target=Zt,V.relatedTarget=B,Z=null,Ga(X)===U&&(wt=new wt(N,O+"enter",dt,l,X),wt.target=B,wt.relatedTarget=Zt,Z=wt),Zt=Z,F&&dt)e:{for(wt=zz,N=F,O=dt,B=0,Z=N;Z;Z=wt(Z))B++;Z=0;for(var xt=O;xt;xt=wt(xt))Z++;for(;0<B-Z;)N=wt(N),B--;for(;0<Z-B;)O=wt(O),Z--;for(;B--;){if(N===O||O!==null&&N===O.alternate){wt=N;break e}N=wt(N),O=wt(O)}wt=null}else wt=null;F!==null&&jx(K,V,F,wt,!1),dt!==null&&Zt!==null&&jx(K,Zt,dt,wt,!0)}}t:{if(V=U?ul(U):window,F=V.nodeName&&V.nodeName.toLowerCase(),F==="select"||F==="input"&&V.type==="file")var qt=Wy;else if(Jy(V))if(tb)qt=VM;else{qt=HM;var ht=UM}else F=V.nodeName,!F||F.toLowerCase()!=="input"||V.type!=="checkbox"&&V.type!=="radio"?U&&Gc(U.elementType)&&(qt=Wy):qt=qM;if(qt&&(qt=qt(e,U))){$y(K,qt,l,X);break t}ht&&ht(e,V,U),e==="focusout"&&U&&V.type==="number"&&U.memoizedProps.value!=null&&Fc(V,"number",V.value)}switch(ht=U?ul(U):window,e){case"focusin":(Jy(ht)||ht.contentEditable==="true")&&(ti=ht,lf=U,yl=null);break;case"focusout":yl=lf=ti=null;break;case"mousedown":sf=!0;break;case"contextmenu":case"mouseup":case"dragend":sf=!1,ub(K,l,X);break;case"selectionchange":if(FM)break;case"keydown":case"keyup":ub(K,l,X)}var Mt;if(ef)t:{switch(e){case"compositionstart":var Lt="onCompositionStart";break t;case"compositionend":Lt="onCompositionEnd";break t;case"compositionupdate":Lt="onCompositionUpdate";break t}Lt=void 0}else Wa?Zy(e,l)&&(Lt="onCompositionEnd"):e==="keydown"&&l.keyCode===229&&(Lt="onCompositionStart");Lt&&(Py&&l.locale!=="ko"&&(Wa||Lt!=="onCompositionStart"?Lt==="onCompositionEnd"&&Wa&&(Mt=qy()):(_r=X,Kc="value"in _r?_r.value:_r.textContent,Wa=!0)),ht=ju(U,Lt),0<ht.length&&(Lt=new Fy(Lt,e,null,l,X),K.push({event:Lt,listeners:ht}),Mt?Lt.data=Mt:(Mt=Ky(l),Mt!==null&&(Lt.data=Mt)))),(Mt=NM?IM(e,l):jM(e,l))&&(Lt=ju(U,"onBeforeInput"),0<Lt.length&&(ht=new Fy("onBeforeInput","beforeinput",null,l,X),K.push({event:ht,listeners:Lt}),ht.data=Mt)),Az(K,e,U,l,X)}Nx(K,r)})}function Vl(e,r,l){return{instance:e,listener:r,currentTarget:l}}function ju(e,r){for(var l=r+"Capture",u=[];e!==null;){var f=e,p=f.stateNode;if(f=f.tag,f!==5&&f!==26&&f!==27||p===null||(f=ol(e,l),f!=null&&u.unshift(Vl(e,f,p)),f=ol(e,r),f!=null&&u.push(Vl(e,f,p))),e.tag===3)return u;e=e.return}return[]}function zz(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function jx(e,r,l,u,f){for(var p=r._reactName,b=[];l!==null&&l!==u;){var S=l,A=S.alternate,U=S.stateNode;if(S=S.tag,A!==null&&A===u)break;S!==5&&S!==26&&S!==27||U===null||(A=U,f?(U=ol(l,p),U!=null&&b.unshift(Vl(l,U,A))):f||(U=ol(l,p),U!=null&&b.push(Vl(l,U,A)))),l=l.return}b.length!==0&&e.push({event:r,listeners:b})}var Oz=/\r\n?/g,Dz=/\u0000|\uFFFD/g;function Lx(e){return(typeof e=="string"?e:""+e).replace(Oz,`
9
- `).replace(Dz,"")}function Bx(e,r){return r=Lx(r),Lx(e)===r}function Qt(e,r,l,u,f,p){switch(l){case"children":typeof u=="string"?r==="body"||r==="textarea"&&u===""||Ka(e,u):(typeof u=="number"||typeof u=="bigint")&&r!=="body"&&Ka(e,""+u);break;case"className":Hs(e,"class",u);break;case"tabIndex":Hs(e,"tabindex",u);break;case"dir":case"role":case"viewBox":case"width":case"height":Hs(e,l,u);break;case"style":By(e,u,p);break;case"data":if(r!=="object"){Hs(e,"data",u);break}case"src":case"href":if(u===""&&(r!=="a"||l!=="href")){e.removeAttribute(l);break}if(u==null||typeof u=="function"||typeof u=="symbol"||typeof u=="boolean"){e.removeAttribute(l);break}u=Vs(""+u),e.setAttribute(l,u);break;case"action":case"formAction":if(typeof u=="function"){e.setAttribute(l,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof p=="function"&&(l==="formAction"?(r!=="input"&&Qt(e,r,"name",f.name,f,null),Qt(e,r,"formEncType",f.formEncType,f,null),Qt(e,r,"formMethod",f.formMethod,f,null),Qt(e,r,"formTarget",f.formTarget,f,null)):(Qt(e,r,"encType",f.encType,f,null),Qt(e,r,"method",f.method,f,null),Qt(e,r,"target",f.target,f,null)));if(u==null||typeof u=="symbol"||typeof u=="boolean"){e.removeAttribute(l);break}u=Vs(""+u),e.setAttribute(l,u);break;case"onClick":u!=null&&(e.onclick=Wn);break;case"onScroll":u!=null&&It("scroll",e);break;case"onScrollEnd":u!=null&&It("scrollend",e);break;case"dangerouslySetInnerHTML":if(u!=null){if(typeof u!="object"||!("__html"in u))throw Error(i(61));if(l=u.__html,l!=null){if(f.children!=null)throw Error(i(60));e.innerHTML=l}}break;case"multiple":e.multiple=u&&typeof u!="function"&&typeof u!="symbol";break;case"muted":e.muted=u&&typeof u!="function"&&typeof u!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(u==null||typeof u=="function"||typeof u=="boolean"||typeof u=="symbol"){e.removeAttribute("xlink:href");break}l=Vs(""+u),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",l);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":u!=null&&typeof u!="function"&&typeof u!="symbol"?e.setAttribute(l,""+u):e.removeAttribute(l);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":u&&typeof u!="function"&&typeof u!="symbol"?e.setAttribute(l,""):e.removeAttribute(l);break;case"capture":case"download":u===!0?e.setAttribute(l,""):u!==!1&&u!=null&&typeof u!="function"&&typeof u!="symbol"?e.setAttribute(l,u):e.removeAttribute(l);break;case"cols":case"rows":case"size":case"span":u!=null&&typeof u!="function"&&typeof u!="symbol"&&!isNaN(u)&&1<=u?e.setAttribute(l,u):e.removeAttribute(l);break;case"rowSpan":case"start":u==null||typeof u=="function"||typeof u=="symbol"||isNaN(u)?e.removeAttribute(l):e.setAttribute(l,u);break;case"popover":It("beforetoggle",e),It("toggle",e),Us(e,"popover",u);break;case"xlinkActuate":$n(e,"http://www.w3.org/1999/xlink","xlink:actuate",u);break;case"xlinkArcrole":$n(e,"http://www.w3.org/1999/xlink","xlink:arcrole",u);break;case"xlinkRole":$n(e,"http://www.w3.org/1999/xlink","xlink:role",u);break;case"xlinkShow":$n(e,"http://www.w3.org/1999/xlink","xlink:show",u);break;case"xlinkTitle":$n(e,"http://www.w3.org/1999/xlink","xlink:title",u);break;case"xlinkType":$n(e,"http://www.w3.org/1999/xlink","xlink:type",u);break;case"xmlBase":$n(e,"http://www.w3.org/XML/1998/namespace","xml:base",u);break;case"xmlLang":$n(e,"http://www.w3.org/XML/1998/namespace","xml:lang",u);break;case"xmlSpace":$n(e,"http://www.w3.org/XML/1998/namespace","xml:space",u);break;case"is":Us(e,"is",u);break;case"innerText":case"textContent":break;default:(!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(l=sM.get(l)||l,Us(e,l,u))}}function Od(e,r,l,u,f,p){switch(l){case"style":By(e,u,p);break;case"dangerouslySetInnerHTML":if(u!=null){if(typeof u!="object"||!("__html"in u))throw Error(i(61));if(l=u.__html,l!=null){if(f.children!=null)throw Error(i(60));e.innerHTML=l}}break;case"children":typeof u=="string"?Ka(e,u):(typeof u=="number"||typeof u=="bigint")&&Ka(e,""+u);break;case"onScroll":u!=null&&It("scroll",e);break;case"onScrollEnd":u!=null&&It("scrollend",e);break;case"onClick":u!=null&&(e.onclick=Wn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Ry.hasOwnProperty(l))t:{if(l[0]==="o"&&l[1]==="n"&&(f=l.endsWith("Capture"),r=l.slice(2,f?l.length-7:void 0),p=e[Pe]||null,p=p!=null?p[l]:null,typeof p=="function"&&e.removeEventListener(r,p,f),typeof u=="function")){typeof p!="function"&&p!==null&&(l in e?e[l]=null:e.hasAttribute(l)&&e.removeAttribute(l)),e.addEventListener(r,u,f);break t}l in e?e[l]=u:u===!0?e.setAttribute(l,""):Us(e,l,u)}}}function Me(e,r,l){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":It("error",e),It("load",e);var u=!1,f=!1,p;for(p in l)if(l.hasOwnProperty(p)){var b=l[p];if(b!=null)switch(p){case"src":u=!0;break;case"srcSet":f=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,r));default:Qt(e,r,p,b,l,null)}}f&&Qt(e,r,"srcSet",l.srcSet,l,null),u&&Qt(e,r,"src",l.src,l,null);return;case"input":It("invalid",e);var S=p=b=f=null,A=null,U=null;for(u in l)if(l.hasOwnProperty(u)){var X=l[u];if(X!=null)switch(u){case"name":f=X;break;case"type":b=X;break;case"checked":A=X;break;case"defaultChecked":U=X;break;case"value":p=X;break;case"defaultValue":S=X;break;case"children":case"dangerouslySetInnerHTML":if(X!=null)throw Error(i(137,r));break;default:Qt(e,r,u,X,l,null)}}Ny(e,p,S,A,U,b,f,!1);return;case"select":It("invalid",e),u=b=p=null;for(f in l)if(l.hasOwnProperty(f)&&(S=l[f],S!=null))switch(f){case"value":p=S;break;case"defaultValue":b=S;break;case"multiple":u=S;default:Qt(e,r,f,S,l,null)}r=p,l=b,e.multiple=!!u,r!=null?Za(e,!!u,r,!1):l!=null&&Za(e,!!u,l,!0);return;case"textarea":It("invalid",e),p=f=u=null;for(b in l)if(l.hasOwnProperty(b)&&(S=l[b],S!=null))switch(b){case"value":u=S;break;case"defaultValue":f=S;break;case"children":p=S;break;case"dangerouslySetInnerHTML":if(S!=null)throw Error(i(91));break;default:Qt(e,r,b,S,l,null)}jy(e,u,f,p);return;case"option":for(A in l)if(l.hasOwnProperty(A)&&(u=l[A],u!=null))switch(A){case"selected":e.selected=u&&typeof u!="function"&&typeof u!="symbol";break;default:Qt(e,r,A,u,l,null)}return;case"dialog":It("beforetoggle",e),It("toggle",e),It("cancel",e),It("close",e);break;case"iframe":case"object":It("load",e);break;case"video":case"audio":for(u=0;u<ql.length;u++)It(ql[u],e);break;case"image":It("error",e),It("load",e);break;case"details":It("toggle",e);break;case"embed":case"source":case"link":It("error",e),It("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(U in l)if(l.hasOwnProperty(U)&&(u=l[U],u!=null))switch(U){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,r));default:Qt(e,r,U,u,l,null)}return;default:if(Gc(r)){for(X in l)l.hasOwnProperty(X)&&(u=l[X],u!==void 0&&Od(e,r,X,u,l,void 0));return}}for(S in l)l.hasOwnProperty(S)&&(u=l[S],u!=null&&Qt(e,r,S,u,l,null))}function Nz(e,r,l,u){switch(r){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var f=null,p=null,b=null,S=null,A=null,U=null,X=null;for(F in l){var K=l[F];if(l.hasOwnProperty(F)&&K!=null)switch(F){case"checked":break;case"value":break;case"defaultValue":A=K;default:u.hasOwnProperty(F)||Qt(e,r,F,null,u,K)}}for(var V in u){var F=u[V];if(K=l[V],u.hasOwnProperty(V)&&(F!=null||K!=null))switch(V){case"type":p=F;break;case"name":f=F;break;case"checked":U=F;break;case"defaultChecked":X=F;break;case"value":b=F;break;case"defaultValue":S=F;break;case"children":case"dangerouslySetInnerHTML":if(F!=null)throw Error(i(137,r));break;default:F!==K&&Qt(e,r,V,F,u,K)}}Yc(e,b,S,A,U,X,p,f);return;case"select":F=b=S=V=null;for(p in l)if(A=l[p],l.hasOwnProperty(p)&&A!=null)switch(p){case"value":break;case"multiple":F=A;default:u.hasOwnProperty(p)||Qt(e,r,p,null,u,A)}for(f in u)if(p=u[f],A=l[f],u.hasOwnProperty(f)&&(p!=null||A!=null))switch(f){case"value":V=p;break;case"defaultValue":S=p;break;case"multiple":b=p;default:p!==A&&Qt(e,r,f,p,u,A)}r=S,l=b,u=F,V!=null?Za(e,!!l,V,!1):!!u!=!!l&&(r!=null?Za(e,!!l,r,!0):Za(e,!!l,l?[]:"",!1));return;case"textarea":F=V=null;for(S in l)if(f=l[S],l.hasOwnProperty(S)&&f!=null&&!u.hasOwnProperty(S))switch(S){case"value":break;case"children":break;default:Qt(e,r,S,null,u,f)}for(b in u)if(f=u[b],p=l[b],u.hasOwnProperty(b)&&(f!=null||p!=null))switch(b){case"value":V=f;break;case"defaultValue":F=f;break;case"children":break;case"dangerouslySetInnerHTML":if(f!=null)throw Error(i(91));break;default:f!==p&&Qt(e,r,b,f,u,p)}Iy(e,V,F);return;case"option":for(var dt in l)if(V=l[dt],l.hasOwnProperty(dt)&&V!=null&&!u.hasOwnProperty(dt))switch(dt){case"selected":e.selected=!1;break;default:Qt(e,r,dt,null,u,V)}for(A in u)if(V=u[A],F=l[A],u.hasOwnProperty(A)&&V!==F&&(V!=null||F!=null))switch(A){case"selected":e.selected=V&&typeof V!="function"&&typeof V!="symbol";break;default:Qt(e,r,A,V,u,F)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var wt in l)V=l[wt],l.hasOwnProperty(wt)&&V!=null&&!u.hasOwnProperty(wt)&&Qt(e,r,wt,null,u,V);for(U in u)if(V=u[U],F=l[U],u.hasOwnProperty(U)&&V!==F&&(V!=null||F!=null))switch(U){case"children":case"dangerouslySetInnerHTML":if(V!=null)throw Error(i(137,r));break;default:Qt(e,r,U,V,u,F)}return;default:if(Gc(r)){for(var Zt in l)V=l[Zt],l.hasOwnProperty(Zt)&&V!==void 0&&!u.hasOwnProperty(Zt)&&Od(e,r,Zt,void 0,u,V);for(X in u)V=u[X],F=l[X],!u.hasOwnProperty(X)||V===F||V===void 0&&F===void 0||Od(e,r,X,V,u,F);return}}for(var N in l)V=l[N],l.hasOwnProperty(N)&&V!=null&&!u.hasOwnProperty(N)&&Qt(e,r,N,null,u,V);for(K in u)V=u[K],F=l[K],!u.hasOwnProperty(K)||V===F||V==null&&F==null||Qt(e,r,K,V,u,F)}function Ux(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Iz(){if(typeof performance.getEntriesByType=="function"){for(var e=0,r=0,l=performance.getEntriesByType("resource"),u=0;u<l.length;u++){var f=l[u],p=f.transferSize,b=f.initiatorType,S=f.duration;if(p&&S&&Ux(b)){for(b=0,S=f.responseEnd,u+=1;u<l.length;u++){var A=l[u],U=A.startTime;if(U>S)break;var X=A.transferSize,K=A.initiatorType;X&&Ux(K)&&(A=A.responseEnd,b+=X*(A<S?1:(S-U)/(A-U)))}if(--u,r+=8*(p+b)/(f.duration/1e3),e++,10<e)break}}if(0<e)return r/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var Dd=null,Nd=null;function Lu(e){return e.nodeType===9?e:e.ownerDocument}function Hx(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function qx(e,r){if(e===0)switch(r){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&r==="foreignObject"?0:e}function Id(e,r){return e==="textarea"||e==="noscript"||typeof r.children=="string"||typeof r.children=="number"||typeof r.children=="bigint"||typeof r.dangerouslySetInnerHTML=="object"&&r.dangerouslySetInnerHTML!==null&&r.dangerouslySetInnerHTML.__html!=null}var jd=null;function jz(){var e=window.event;return e&&e.type==="popstate"?e===jd?!1:(jd=e,!0):(jd=null,!1)}var Vx=typeof setTimeout=="function"?setTimeout:void 0,Lz=typeof clearTimeout=="function"?clearTimeout:void 0,Yx=typeof Promise=="function"?Promise:void 0,Bz=typeof queueMicrotask=="function"?queueMicrotask:typeof Yx!="undefined"?function(e){return Yx.resolve(null).then(e).catch(Uz)}:Vx;function Uz(e){setTimeout(function(){throw e})}function Hr(e){return e==="head"}function Fx(e,r){var l=r,u=0;do{var f=l.nextSibling;if(e.removeChild(l),f&&f.nodeType===8)if(l=f.data,l==="/$"||l==="/&"){if(u===0){e.removeChild(f),Ai(r);return}u--}else if(l==="$"||l==="$?"||l==="$~"||l==="$!"||l==="&")u++;else if(l==="html")Yl(e.ownerDocument.documentElement);else if(l==="head"){l=e.ownerDocument.head,Yl(l);for(var p=l.firstChild;p;){var b=p.nextSibling,S=p.nodeName;p[sl]||S==="SCRIPT"||S==="STYLE"||S==="LINK"&&p.rel.toLowerCase()==="stylesheet"||l.removeChild(p),p=b}}else l==="body"&&Yl(e.ownerDocument.body);l=f}while(l);Ai(r)}function Gx(e,r){var l=e;e=0;do{var u=l.nextSibling;if(l.nodeType===1?r?(l._stashedDisplay=l.style.display,l.style.display="none"):(l.style.display=l._stashedDisplay||"",l.getAttribute("style")===""&&l.removeAttribute("style")):l.nodeType===3&&(r?(l._stashedText=l.nodeValue,l.nodeValue=""):l.nodeValue=l._stashedText||""),u&&u.nodeType===8)if(l=u.data,l==="/$"){if(e===0)break;e--}else l!=="$"&&l!=="$?"&&l!=="$~"&&l!=="$!"||e++;l=u}while(l)}function Ld(e){var r=e.firstChild;for(r&&r.nodeType===10&&(r=r.nextSibling);r;){var l=r;switch(r=r.nextSibling,l.nodeName){case"HTML":case"HEAD":case"BODY":Ld(l),qc(l);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(l.rel.toLowerCase()==="stylesheet")continue}e.removeChild(l)}}function Hz(e,r,l,u){for(;e.nodeType===1;){var f=l;if(e.nodeName.toLowerCase()!==r.toLowerCase()){if(!u&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(u){if(!e[sl])switch(r){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(p=e.getAttribute("rel"),p==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(p!==f.rel||e.getAttribute("href")!==(f.href==null||f.href===""?null:f.href)||e.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin)||e.getAttribute("title")!==(f.title==null?null:f.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(p=e.getAttribute("src"),(p!==(f.src==null?null:f.src)||e.getAttribute("type")!==(f.type==null?null:f.type)||e.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin))&&p&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(r==="input"&&e.type==="hidden"){var p=f.name==null?null:""+f.name;if(f.type==="hidden"&&e.getAttribute("name")===p)return e}else return e;if(e=Cn(e.nextSibling),e===null)break}return null}function qz(e,r,l){if(r==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!l||(e=Cn(e.nextSibling),e===null))return null;return e}function Px(e,r){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!r||(e=Cn(e.nextSibling),e===null))return null;return e}function Bd(e){return e.data==="$?"||e.data==="$~"}function Ud(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function Vz(e,r){var l=e.ownerDocument;if(e.data==="$~")e._reactRetry=r;else if(e.data!=="$?"||l.readyState!=="loading")r();else{var u=function(){r(),l.removeEventListener("DOMContentLoaded",u)};l.addEventListener("DOMContentLoaded",u),e._reactRetry=u}}function Cn(e){for(;e!=null;e=e.nextSibling){var r=e.nodeType;if(r===1||r===3)break;if(r===8){if(r=e.data,r==="$"||r==="$!"||r==="$?"||r==="$~"||r==="&"||r==="F!"||r==="F")break;if(r==="/$"||r==="/&")return null}}return e}var Hd=null;function Xx(e){e=e.nextSibling;for(var r=0;e;){if(e.nodeType===8){var l=e.data;if(l==="/$"||l==="/&"){if(r===0)return Cn(e.nextSibling);r--}else l!=="$"&&l!=="$!"&&l!=="$?"&&l!=="$~"&&l!=="&"||r++}e=e.nextSibling}return null}function Qx(e){e=e.previousSibling;for(var r=0;e;){if(e.nodeType===8){var l=e.data;if(l==="$"||l==="$!"||l==="$?"||l==="$~"||l==="&"){if(r===0)return e;r--}else l!=="/$"&&l!=="/&"||r++}e=e.previousSibling}return null}function Zx(e,r,l){switch(r=Lu(l),e){case"html":if(e=r.documentElement,!e)throw Error(i(452));return e;case"head":if(e=r.head,!e)throw Error(i(453));return e;case"body":if(e=r.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function Yl(e){for(var r=e.attributes;r.length;)e.removeAttributeNode(r[0]);qc(e)}var An=new Map,Kx=new Set;function Bu(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var mr=et.d;et.d={f:Yz,r:Fz,D:Gz,C:Pz,L:Xz,m:Qz,X:Kz,S:Zz,M:Jz};function Yz(){var e=mr.f(),r=Ru();return e||r}function Fz(e){var r=Pa(e);r!==null&&r.tag===5&&r.type==="form"?hv(r):mr.r(e)}var Ti=typeof document=="undefined"?null:document;function Jx(e,r,l){var u=Ti;if(u&&typeof r=="string"&&r){var f=vn(r);f='link[rel="'+e+'"][href="'+f+'"]',typeof l=="string"&&(f+='[crossorigin="'+l+'"]'),Kx.has(f)||(Kx.add(f),e={rel:e,crossOrigin:l,href:r},u.querySelector(f)===null&&(r=u.createElement("link"),Me(r,"link",e),_e(r),u.head.appendChild(r)))}}function Gz(e){mr.D(e),Jx("dns-prefetch",e,null)}function Pz(e,r){mr.C(e,r),Jx("preconnect",e,r)}function Xz(e,r,l){mr.L(e,r,l);var u=Ti;if(u&&e&&r){var f='link[rel="preload"][as="'+vn(r)+'"]';r==="image"&&l&&l.imageSrcSet?(f+='[imagesrcset="'+vn(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(f+='[imagesizes="'+vn(l.imageSizes)+'"]')):f+='[href="'+vn(e)+'"]';var p=f;switch(r){case"style":p=Ei(e);break;case"script":p=Ci(e)}An.has(p)||(e=g({rel:"preload",href:r==="image"&&l&&l.imageSrcSet?void 0:e,as:r},l),An.set(p,e),u.querySelector(f)!==null||r==="style"&&u.querySelector(Fl(p))||r==="script"&&u.querySelector(Gl(p))||(r=u.createElement("link"),Me(r,"link",e),_e(r),u.head.appendChild(r)))}}function Qz(e,r){mr.m(e,r);var l=Ti;if(l&&e){var u=r&&typeof r.as=="string"?r.as:"script",f='link[rel="modulepreload"][as="'+vn(u)+'"][href="'+vn(e)+'"]',p=f;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":p=Ci(e)}if(!An.has(p)&&(e=g({rel:"modulepreload",href:e},r),An.set(p,e),l.querySelector(f)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(Gl(p)))return}u=l.createElement("link"),Me(u,"link",e),_e(u),l.head.appendChild(u)}}}function Zz(e,r,l){mr.S(e,r,l);var u=Ti;if(u&&e){var f=Xa(u).hoistableStyles,p=Ei(e);r=r||"default";var b=f.get(p);if(!b){var S={loading:0,preload:null};if(b=u.querySelector(Fl(p)))S.loading=5;else{e=g({rel:"stylesheet",href:e,"data-precedence":r},l),(l=An.get(p))&&qd(e,l);var A=b=u.createElement("link");_e(A),Me(A,"link",e),A._p=new Promise(function(U,X){A.onload=U,A.onerror=X}),A.addEventListener("load",function(){S.loading|=1}),A.addEventListener("error",function(){S.loading|=2}),S.loading|=4,Uu(b,r,u)}b={type:"stylesheet",instance:b,count:1,state:S},f.set(p,b)}}}function Kz(e,r){mr.X(e,r);var l=Ti;if(l&&e){var u=Xa(l).hoistableScripts,f=Ci(e),p=u.get(f);p||(p=l.querySelector(Gl(f)),p||(e=g({src:e,async:!0},r),(r=An.get(f))&&Vd(e,r),p=l.createElement("script"),_e(p),Me(p,"link",e),l.head.appendChild(p)),p={type:"script",instance:p,count:1,state:null},u.set(f,p))}}function Jz(e,r){mr.M(e,r);var l=Ti;if(l&&e){var u=Xa(l).hoistableScripts,f=Ci(e),p=u.get(f);p||(p=l.querySelector(Gl(f)),p||(e=g({src:e,async:!0,type:"module"},r),(r=An.get(f))&&Vd(e,r),p=l.createElement("script"),_e(p),Me(p,"link",e),l.head.appendChild(p)),p={type:"script",instance:p,count:1,state:null},u.set(f,p))}}function $x(e,r,l,u){var f=(f=mt.current)?Bu(f):null;if(!f)throw Error(i(446));switch(e){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(r=Ei(l.href),l=Xa(f).hoistableStyles,u=l.get(r),u||(u={type:"style",instance:null,count:0,state:null},l.set(r,u)),u):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){e=Ei(l.href);var p=Xa(f).hoistableStyles,b=p.get(e);if(b||(f=f.ownerDocument||f,b={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},p.set(e,b),(p=f.querySelector(Fl(e)))&&!p._p&&(b.instance=p,b.state.loading=5),An.has(e)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},An.set(e,l),p||$z(f,e,l,b.state))),r&&u===null)throw Error(i(528,""));return b}if(r&&u!==null)throw Error(i(529,""));return null;case"script":return r=l.async,l=l.src,typeof l=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=Ci(l),l=Xa(f).hoistableScripts,u=l.get(r),u||(u={type:"script",instance:null,count:0,state:null},l.set(r,u)),u):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Ei(e){return'href="'+vn(e)+'"'}function Fl(e){return'link[rel="stylesheet"]['+e+"]"}function Wx(e){return g({},e,{"data-precedence":e.precedence,precedence:null})}function $z(e,r,l,u){e.querySelector('link[rel="preload"][as="style"]['+r+"]")?u.loading=1:(r=e.createElement("link"),u.preload=r,r.addEventListener("load",function(){return u.loading|=1}),r.addEventListener("error",function(){return u.loading|=2}),Me(r,"link",l),_e(r),e.head.appendChild(r))}function Ci(e){return'[src="'+vn(e)+'"]'}function Gl(e){return"script[async]"+e}function tS(e,r,l){if(r.count++,r.instance===null)switch(r.type){case"style":var u=e.querySelector('style[data-href~="'+vn(l.href)+'"]');if(u)return r.instance=u,_e(u),u;var f=g({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return u=(e.ownerDocument||e).createElement("style"),_e(u),Me(u,"style",f),Uu(u,l.precedence,e),r.instance=u;case"stylesheet":f=Ei(l.href);var p=e.querySelector(Fl(f));if(p)return r.state.loading|=4,r.instance=p,_e(p),p;u=Wx(l),(f=An.get(f))&&qd(u,f),p=(e.ownerDocument||e).createElement("link"),_e(p);var b=p;return b._p=new Promise(function(S,A){b.onload=S,b.onerror=A}),Me(p,"link",u),r.state.loading|=4,Uu(p,l.precedence,e),r.instance=p;case"script":return p=Ci(l.src),(f=e.querySelector(Gl(p)))?(r.instance=f,_e(f),f):(u=l,(f=An.get(p))&&(u=g({},l),Vd(u,f)),e=e.ownerDocument||e,f=e.createElement("script"),_e(f),Me(f,"link",u),e.head.appendChild(f),r.instance=f);case"void":return null;default:throw Error(i(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(u=r.instance,r.state.loading|=4,Uu(u,l.precedence,e));return r.instance}function Uu(e,r,l){for(var u=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),f=u.length?u[u.length-1]:null,p=f,b=0;b<u.length;b++){var S=u[b];if(S.dataset.precedence===r)p=S;else if(p!==f)break}p?p.parentNode.insertBefore(e,p.nextSibling):(r=l.nodeType===9?l.head:l,r.insertBefore(e,r.firstChild))}function qd(e,r){e.crossOrigin==null&&(e.crossOrigin=r.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=r.referrerPolicy),e.title==null&&(e.title=r.title)}function Vd(e,r){e.crossOrigin==null&&(e.crossOrigin=r.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=r.referrerPolicy),e.integrity==null&&(e.integrity=r.integrity)}var Hu=null;function eS(e,r,l){if(Hu===null){var u=new Map,f=Hu=new Map;f.set(l,u)}else f=Hu,u=f.get(l),u||(u=new Map,f.set(l,u));if(u.has(e))return u;for(u.set(e,null),l=l.getElementsByTagName(e),f=0;f<l.length;f++){var p=l[f];if(!(p[sl]||p[Ce]||e==="link"&&p.getAttribute("rel")==="stylesheet")&&p.namespaceURI!=="http://www.w3.org/2000/svg"){var b=p.getAttribute(r)||"";b=e+b;var S=u.get(b);S?S.push(p):u.set(b,[p])}}return u}function nS(e,r,l){e=e.ownerDocument||e,e.head.insertBefore(l,r==="title"?e.querySelector("head > title"):null)}function Wz(e,r,l){if(l===1||r.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;switch(r.rel){case"stylesheet":return e=r.disabled,typeof r.precedence=="string"&&e==null;default:return!0}case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function rS(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function tO(e,r,l,u){if(l.type==="stylesheet"&&(typeof u.media!="string"||matchMedia(u.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var f=Ei(u.href),p=r.querySelector(Fl(f));if(p){r=p._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(e.count++,e=qu.bind(e),r.then(e,e)),l.state.loading|=4,l.instance=p,_e(p);return}p=r.ownerDocument||r,u=Wx(u),(f=An.get(f))&&qd(u,f),p=p.createElement("link"),_e(p);var b=p;b._p=new Promise(function(S,A){b.onload=S,b.onerror=A}),Me(p,"link",u),l.instance=p}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(l,r),(r=l.state.preload)&&(l.state.loading&3)===0&&(e.count++,l=qu.bind(e),r.addEventListener("load",l),r.addEventListener("error",l))}}var Yd=0;function eO(e,r){return e.stylesheets&&e.count===0&&Yu(e,e.stylesheets),0<e.count||0<e.imgCount?function(l){var u=setTimeout(function(){if(e.stylesheets&&Yu(e,e.stylesheets),e.unsuspend){var p=e.unsuspend;e.unsuspend=null,p()}},6e4+r);0<e.imgBytes&&Yd===0&&(Yd=62500*Iz());var f=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Yu(e,e.stylesheets),e.unsuspend)){var p=e.unsuspend;e.unsuspend=null,p()}},(e.imgBytes>Yd?50:800)+r);return e.unsuspend=l,function(){e.unsuspend=null,clearTimeout(u),clearTimeout(f)}}:null}function qu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Yu(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Vu=null;function Yu(e,r){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Vu=new Map,r.forEach(nO,e),Vu=null,qu.call(e))}function nO(e,r){if(!(r.state.loading&4)){var l=Vu.get(e);if(l)var u=l.get(null);else{l=new Map,Vu.set(e,l);for(var f=e.querySelectorAll("link[data-precedence],style[data-precedence]"),p=0;p<f.length;p++){var b=f[p];(b.nodeName==="LINK"||b.getAttribute("media")!=="not all")&&(l.set(b.dataset.precedence,b),u=b)}u&&l.set(null,u)}f=r.instance,b=f.getAttribute("data-precedence"),p=l.get(b)||u,p===u&&l.set(null,f),l.set(b,f),this.count++,u=qu.bind(this),f.addEventListener("load",u),f.addEventListener("error",u),p?p.parentNode.insertBefore(f,p.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(f,e.firstChild)),r.state.loading|=4}}var Pl={$$typeof:I,Provider:null,Consumer:null,_currentValue:ft,_currentValue2:ft,_threadCount:0};function rO(e,r,l,u,f,p,b,S,A){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Lc(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Lc(0),this.hiddenUpdates=Lc(null),this.identifierPrefix=u,this.onUncaughtError=f,this.onCaughtError=p,this.onRecoverableError=b,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=A,this.incompleteTransitions=new Map}function aS(e,r,l,u,f,p,b,S,A,U,X,K){return e=new rO(e,r,l,b,A,U,X,K,S),r=1,p===!0&&(r|=24),p=un(3,null,null,r),e.current=p,p.stateNode=e,r=wf(),r.refCount++,e.pooledCache=r,r.refCount++,p.memoizedState={element:u,isDehydrated:l,cache:r},Cf(p),e}function iS(e){return e?(e=ri,e):ri}function lS(e,r,l,u,f,p){f=iS(f),u.context===null?u.context=f:u.pendingContext=f,u=Rr(r),u.payload={element:l},p=p===void 0?null:p,p!==null&&(u.callback=p),l=Mr(e,u,r),l!==null&&($e(l,e,r),Tl(l,e,r))}function sS(e,r){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var l=e.retryLane;e.retryLane=l!==0&&l<r?l:r}}function Fd(e,r){sS(e,r),(e=e.alternate)&&sS(e,r)}function uS(e){if(e.tag===13||e.tag===31){var r=sa(e,67108864);r!==null&&$e(r,e,67108864),Fd(e,67108864)}}function oS(e){if(e.tag===13||e.tag===31){var r=hn();r=Bc(r);var l=sa(e,r);l!==null&&$e(l,e,r),Fd(e,r)}}var Fu=!0;function aO(e,r,l,u){var f=H.T;H.T=null;var p=et.p;try{et.p=2,Gd(e,r,l,u)}finally{et.p=p,H.T=f}}function iO(e,r,l,u){var f=H.T;H.T=null;var p=et.p;try{et.p=8,Gd(e,r,l,u)}finally{et.p=p,H.T=f}}function Gd(e,r,l,u){if(Fu){var f=Pd(u);if(f===null)zd(e,r,u,Gu,l),fS(e,u);else if(sO(f,e,r,l,u))u.stopPropagation();else if(fS(e,u),r&4&&-1<lO.indexOf(e)){for(;f!==null;){var p=Pa(f);if(p!==null)switch(p.tag){case 3:if(p=p.stateNode,p.current.memoizedState.isDehydrated){var b=na(p.pendingLanes);if(b!==0){var S=p;for(S.pendingLanes|=2,S.entangledLanes|=2;b;){var A=1<<31-Wt(b);S.entanglements[1]|=A,b&=~A}Gn(p),(Yt&6)===0&&(Au=He()+500,Hl(0))}}break;case 31:case 13:S=sa(p,2),S!==null&&$e(S,p,2),Ru(),Fd(p,2)}if(p=Pd(u),p===null&&zd(e,r,u,Gu,l),p===f)break;f=p}f!==null&&u.stopPropagation()}else zd(e,r,u,null,l)}}function Pd(e){return e=Xc(e),Xd(e)}var Gu=null;function Xd(e){if(Gu=null,e=Ga(e),e!==null){var r=o(e);if(r===null)e=null;else{var l=r.tag;if(l===13){if(e=c(r),e!==null)return e;e=null}else if(l===31){if(e=d(r),e!==null)return e;e=null}else if(l===3){if(r.stateNode.current.memoizedState.isDehydrated)return r.tag===3?r.stateNode.containerInfo:null;e=null}else r!==e&&(e=null)}}return Gu=e,null}function cS(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(jc()){case Q:return 2;case it:return 8;case Et:case Dt:return 32;case Ft:return 268435456;default:return 32}default:return 32}}var Qd=!1,qr=null,Vr=null,Yr=null,Xl=new Map,Ql=new Map,Fr=[],lO="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function fS(e,r){switch(e){case"focusin":case"focusout":qr=null;break;case"dragenter":case"dragleave":Vr=null;break;case"mouseover":case"mouseout":Yr=null;break;case"pointerover":case"pointerout":Xl.delete(r.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ql.delete(r.pointerId)}}function Zl(e,r,l,u,f,p){return e===null||e.nativeEvent!==p?(e={blockedOn:r,domEventName:l,eventSystemFlags:u,nativeEvent:p,targetContainers:[f]},r!==null&&(r=Pa(r),r!==null&&uS(r)),e):(e.eventSystemFlags|=u,r=e.targetContainers,f!==null&&r.indexOf(f)===-1&&r.push(f),e)}function sO(e,r,l,u,f){switch(r){case"focusin":return qr=Zl(qr,e,r,l,u,f),!0;case"dragenter":return Vr=Zl(Vr,e,r,l,u,f),!0;case"mouseover":return Yr=Zl(Yr,e,r,l,u,f),!0;case"pointerover":var p=f.pointerId;return Xl.set(p,Zl(Xl.get(p)||null,e,r,l,u,f)),!0;case"gotpointercapture":return p=f.pointerId,Ql.set(p,Zl(Ql.get(p)||null,e,r,l,u,f)),!0}return!1}function dS(e){var r=Ga(e.target);if(r!==null){var l=o(r);if(l!==null){if(r=l.tag,r===13){if(r=c(l),r!==null){e.blockedOn=r,Cy(e.priority,function(){oS(l)});return}}else if(r===31){if(r=d(l),r!==null){e.blockedOn=r,Cy(e.priority,function(){oS(l)});return}}else if(r===3&&l.stateNode.current.memoizedState.isDehydrated){e.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Pu(e){if(e.blockedOn!==null)return!1;for(var r=e.targetContainers;0<r.length;){var l=Pd(e.nativeEvent);if(l===null){l=e.nativeEvent;var u=new l.constructor(l.type,l);Pc=u,l.target.dispatchEvent(u),Pc=null}else return r=Pa(l),r!==null&&uS(r),e.blockedOn=l,!1;r.shift()}return!0}function hS(e,r,l){Pu(e)&&l.delete(r)}function uO(){Qd=!1,qr!==null&&Pu(qr)&&(qr=null),Vr!==null&&Pu(Vr)&&(Vr=null),Yr!==null&&Pu(Yr)&&(Yr=null),Xl.forEach(hS),Ql.forEach(hS)}function Xu(e,r){e.blockedOn===r&&(e.blockedOn=null,Qd||(Qd=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,uO)))}var Qu=null;function pS(e){Qu!==e&&(Qu=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Qu===e&&(Qu=null);for(var r=0;r<e.length;r+=3){var l=e[r],u=e[r+1],f=e[r+2];if(typeof u!="function"){if(Xd(u||l)===null)continue;break}var p=Pa(l);p!==null&&(e.splice(r,3),r-=3,Pf(p,{pending:!0,data:f,method:l.method,action:u},u,f))}}))}function Ai(e){function r(A){return Xu(A,e)}qr!==null&&Xu(qr,e),Vr!==null&&Xu(Vr,e),Yr!==null&&Xu(Yr,e),Xl.forEach(r),Ql.forEach(r);for(var l=0;l<Fr.length;l++){var u=Fr[l];u.blockedOn===e&&(u.blockedOn=null)}for(;0<Fr.length&&(l=Fr[0],l.blockedOn===null);)dS(l),l.blockedOn===null&&Fr.shift();if(l=(e.ownerDocument||e).$$reactFormReplay,l!=null)for(u=0;u<l.length;u+=3){var f=l[u],p=l[u+1],b=f[Pe]||null;if(typeof p=="function")b||pS(l);else if(b){var S=null;if(p&&p.hasAttribute("formAction")){if(f=p,b=p[Pe]||null)S=b.formAction;else if(Xd(f)!==null)continue}else S=b.action;typeof S=="function"?l[u+1]=S:(l.splice(u,3),u-=3),pS(l)}}}function mS(){function e(p){p.canIntercept&&p.info==="react-transition"&&p.intercept({handler:function(){return new Promise(function(b){return f=b})},focusReset:"manual",scroll:"manual"})}function r(){f!==null&&(f(),f=null),u||setTimeout(l,20)}function l(){if(!u&&!navigation.transition){var p=navigation.currentEntry;p&&p.url!=null&&navigation.navigate(p.url,{state:p.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var u=!1,f=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",r),navigation.addEventListener("navigateerror",r),setTimeout(l,100),function(){u=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",r),navigation.removeEventListener("navigateerror",r),f!==null&&(f(),f=null)}}}function Zd(e){this._internalRoot=e}Zu.prototype.render=Zd.prototype.render=function(e){var r=this._internalRoot;if(r===null)throw Error(i(409));var l=r.current,u=hn();lS(l,u,e,r,null,null)},Zu.prototype.unmount=Zd.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var r=e.containerInfo;lS(e.current,2,null,e,null,null),Ru(),r[Fa]=null}};function Zu(e){this._internalRoot=e}Zu.prototype.unstable_scheduleHydration=function(e){if(e){var r=Ey();e={blockedOn:null,target:e,priority:r};for(var l=0;l<Fr.length&&r!==0&&r<Fr[l].priority;l++);Fr.splice(l,0,e),l===0&&dS(e)}};var gS=n.version;if(gS!=="19.2.1")throw Error(i(527,gS,"19.2.1"));et.findDOMNode=function(e){var r=e._reactInternals;if(r===void 0)throw typeof e.render=="function"?Error(i(188)):(e=Object.keys(e).join(","),Error(i(268,e)));return e=m(r),e=e!==null?y(e):null,e=e===null?null:e.stateNode,e};var oO={bundleType:0,version:"19.2.1",rendererPackageName:"react-dom",currentDispatcherRef:H,reconcilerVersion:"19.2.1"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__!="undefined"){var Ku=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Ku.isDisabled&&Ku.supportsFiber)try{qe=Ku.inject(oO),Se=Ku}catch(e){}}return Mi.createRoot=function(e,r){if(!s(e))throw Error(i(299));var l=!1,u="",f=_v,p=Tv,b=Ev;return r!=null&&(r.unstable_strictMode===!0&&(l=!0),r.identifierPrefix!==void 0&&(u=r.identifierPrefix),r.onUncaughtError!==void 0&&(f=r.onUncaughtError),r.onCaughtError!==void 0&&(p=r.onCaughtError),r.onRecoverableError!==void 0&&(b=r.onRecoverableError)),r=aS(e,1,!1,null,null,l,u,null,f,p,b,mS),e[Fa]=r.current,Md(e),new Zd(r)},Mi.hydrateRoot=function(e,r,l){if(!s(e))throw Error(i(299));var u=!1,f="",p=_v,b=Tv,S=Ev,A=null;return l!=null&&(l.unstable_strictMode===!0&&(u=!0),l.identifierPrefix!==void 0&&(f=l.identifierPrefix),l.onUncaughtError!==void 0&&(p=l.onUncaughtError),l.onCaughtError!==void 0&&(b=l.onCaughtError),l.onRecoverableError!==void 0&&(S=l.onRecoverableError),l.formState!==void 0&&(A=l.formState)),r=aS(e,1,!0,r,l!=null?l:null,u,f,A,p,b,S,mS),r.context=iS(null),l=r.current,u=hn(),u=Bc(u),f=Rr(u),f.callback=null,Mr(l,f,u),l=u,r.current.lanes=l,ll(r,l),Gn(r),e[Fa]=r.current,Md(e),new Zu(r)},Mi.version="19.2.1",Mi}var lh;function RS(){if(lh)return eo.exports;lh=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__=="undefined"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(n){console.error(n)}}return t(),eo.exports=kS(),eo.exports}var MS=RS(),sh=ah();const zS=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),OS=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(n,a,i)=>i?i.toUpperCase():a.toLowerCase()),uh=t=>{const n=OS(t);return n.charAt(0).toUpperCase()+n.slice(1)},oh=(...t)=>t.filter((n,a,i)=>!!n&&n.trim()!==""&&i.indexOf(n)===a).join(" ").trim(),DS=t=>{for(const n in t)if(n.startsWith("aria-")||n==="role"||n==="title")return!0};var NS={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const IS=R.forwardRef((m,h)=>{var y=m,{color:t="currentColor",size:n=24,strokeWidth:a=2,absoluteStrokeWidth:i,className:s="",children:o,iconNode:c}=y,d=gt(y,["color","size","strokeWidth","absoluteStrokeWidth","className","children","iconNode"]);return R.createElement("svg",_(_(G(_({ref:h},NS),{width:n,height:n,stroke:t,strokeWidth:i?Number(a)*24/Number(n):a,className:oh("lucide",s)}),!o&&!DS(d)&&{"aria-hidden":"true"}),d),[...c.map(([g,v])=>R.createElement(g,v)),...Array.isArray(o)?o:[o]])});const Pn=(t,n)=>{const a=R.forwardRef((c,o)=>{var d=c,{className:i}=d,s=gt(d,["className"]);return R.createElement(IS,_({ref:o,iconNode:n,className:oh(`lucide-${zS(uh(t))}`,`lucide-${t}`,i)},s))});return a.displayName=uh(t),a};const jS=Pn("arrow-up",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);const LS=Pn("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const BS=Pn("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const US=Pn("contrast",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 18a6 6 0 0 0 0-12v12z",key:"j4l70d"}]]);const HS=Pn("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const qS=Pn("ellipsis-vertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]);const ch=Pn("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const VS=Pn("menu",[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]]);const YS=Pn("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);var FS=t=>Array.from(t).map(a=>a.getModelContext()).sort((a,i)=>{var s,o;return((s=i.priority)!=null?s:0)-((o=a.priority)!=null?o:0)}).reduce((a,i)=>{var s;if(i.system&&(a.system?a.system+=`
1
+ (function(U,p){typeof exports=="object"&&typeof module!="undefined"?p(exports,require("react/jsx-runtime"),require("react"),require("react-dom/client"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","react-dom/client","react-dom"],p):(U=typeof globalThis!="undefined"?globalThis:U||self,p(U.CuadraUIKit={},U.React,U.React,U.ReactDOM,U.ReactDOM))})(this,(function(U,p,y,ae,Oe){"use strict";var Dx=Object.defineProperty,Ox=Object.defineProperties;var Fx=Object.getOwnPropertyDescriptors;var an=Object.getOwnPropertySymbols;var su=Object.prototype.hasOwnProperty,au=Object.prototype.propertyIsEnumerable;var Ri=(U,p)=>(p=Symbol[U])?p:Symbol.for("Symbol."+U),ou=U=>{throw TypeError(U)},lu=Math.pow,ji=(U,p,y)=>p in U?Dx(U,p,{enumerable:!0,configurable:!0,writable:!0,value:y}):U[p]=y,m=(U,p)=>{for(var y in p||(p={}))su.call(p,y)&&ji(U,y,p[y]);if(an)for(var y of an(p))au.call(p,y)&&ji(U,y,p[y]);return U},E=(U,p)=>Ox(U,Fx(p));var H=(U,p)=>{var y={};for(var ae in U)su.call(U,ae)&&p.indexOf(ae)<0&&(y[ae]=U[ae]);if(U!=null&&an)for(var ae of an(U))p.indexOf(ae)<0&&au.call(U,ae)&&(y[ae]=U[ae]);return y};var T=(U,p,y)=>ji(U,typeof p!="symbol"?p+"":p,y),uu=(U,p,y)=>p.has(U)||ou("Cannot "+y);var De=(U,p,y)=>(uu(U,p,"read from private field"),y?y.call(U):p.get(U)),jt=(U,p,y)=>p.has(U)?ou("Cannot add the same private member more than once"):p instanceof WeakSet?p.add(U):p.set(U,y),Ut=(U,p,y,ae)=>(uu(U,p,"write to private field"),ae?ae.call(U,y):p.set(U,y),y);var P=(U,p,y)=>new Promise((ae,Oe)=>{var Se=me=>{try{J(y.next(me))}catch(Pe){Oe(Pe)}},Fe=me=>{try{J(y.throw(me))}catch(Pe){Oe(Pe)}},J=me=>me.done?ae(me.value):Promise.resolve(me.value).then(Se,Fe);J((y=y.apply(U,p)).next())}),it=function(U,p){this[0]=U,this[1]=p},wr=(U,p,y)=>{var ae=(Fe,J,me,Pe)=>{try{var $t=y[Fe](J),Ht=(J=$t.value)instanceof it,un=$t.done;Promise.resolve(Ht?J[0]:J).then(Ge=>Ht?ae(Fe==="return"?Fe:"next",J[1]?{done:Ge.done,value:Ge.value}:Ge,me,Pe):me({value:Ge,done:un})).catch(Ge=>ae("throw",Ge,me,Pe))}catch(Ge){Pe(Ge)}},Oe=Fe=>Se[Fe]=J=>new Promise((me,Pe)=>ae(Fe,J,me,Pe)),Se={};return y=y.apply(U,p),Se[Ri("asyncIterator")]=()=>Se,Oe("next"),Oe("throw"),Oe("return"),Se};var xt=(U,p,y)=>(p=U[Ri("asyncIterator")])?p.call(U):(U=U[Ri("iterator")](),p={},y=(ae,Oe)=>(Oe=U[ae])&&(p[ae]=Se=>new Promise((Fe,J,me)=>(Se=Oe.call(U,Se),me=Se.done,Promise.resolve(Se.value).then(Pe=>Fe({value:Pe,done:me}),J)))),y("next"),y("return"),p);var We,yt,ze,Kl,fr,Xl,pr,mr,gr,Ql,Zl;var Se=typeof document!="undefined"?document.currentScript:null;function Fe(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const J=Fe(y);const me=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Pe=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,n)=>n?n.toUpperCase():r.toLowerCase()),$t=e=>{const t=Pe(e);return t.charAt(0).toUpperCase()+t.slice(1)},Ht=(...e)=>e.filter((t,r,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===r).join(" ").trim(),un=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var Ge={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const du=y.forwardRef((u,l)=>{var d=u,{color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:i="",children:s,iconNode:a}=d,o=H(d,["color","size","strokeWidth","absoluteStrokeWidth","className","children","iconNode"]);return y.createElement("svg",m(m(E(m({ref:l},Ge),{width:t,height:t,stroke:e,strokeWidth:n?Number(r)*24/Number(t):r,className:Ht("lucide",i)}),!s&&!un(o)&&{"aria-hidden":"true"}),o),[...a.map(([c,f])=>y.createElement(c,f)),...Array.isArray(s)?s:[s]])});const Qe=(e,t)=>{const r=y.forwardRef((a,s)=>{var o=a,{className:n}=o,i=H(o,["className"]);return y.createElement(du,m({ref:s,iconNode:t,className:Ht(`lucide-${me($t(e))}`,`lucide-${e}`,n)},i))});return r.displayName=$t(e),r};const hu=Qe("arrow-up",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);const fu=Qe("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const pu=Qe("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const mu=Qe("contrast",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 18a6 6 0 0 0 0-12v12z",key:"j4l70d"}]]);const gu=Qe("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const yu=Qe("ellipsis-vertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]);const $i=Qe("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const bu=Qe("menu",[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]]);const wu=Qe("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);var xu=e=>Array.from(e).map(r=>r.getModelContext()).sort((r,n)=>{var i,s;return((i=n.priority)!=null?i:0)-((s=r.priority)!=null?s:0)}).reduce((r,n)=>{var i;if(n.system&&(r.system?r.system+=`
10
2
 
11
- ${i.system}`:a.system=i.system),i.tools)for(const[o,c]of Object.entries(i.tools)){const d=(s=a.tools)==null?void 0:s[o];if(d&&d!==c)throw new Error(`You tried to define a tool with the name ${o}, but it already exists.`);a.tools||(a.tools={}),a.tools[o]=c}return i.config&&(a.config=_(_({},a.config),i.config)),i.callSettings&&(a.callSettings=_(_({},a.callSettings),i.callSettings)),a},{}),io=class{constructor(){Y(this,"_providers",new Set);Y(this,"_subscribers",new Set)}getModelContext(){return FS(this._providers)}registerModelContextProvider(t){var a;this._providers.add(t);const n=(a=t.subscribe)==null?void 0:a.call(t,()=>{this.notifySubscribers()});return this.notifySubscribers(),()=>{this._providers.delete(t),n==null||n(),this.notifySubscribers()}}notifySubscribers(){for(const t of this._subscribers)t()}subscribe(t){return this._subscribers.add(t),()=>this._subscribers.delete(t)}},lo=class{constructor(){Y(this,"_contextProvider",new io)}registerModelContextProvider(t){return this._contextProvider.registerModelContextProvider(t)}getModelContextProvider(){return this._contextProvider}},zi=class{constructor(){Y(this,"_subscribers",new Set)}subscribe(t){return this._subscribers.add(t),()=>this._subscribers.delete(t)}waitForUpdate(){return new Promise(t=>{const n=this.subscribe(()=>{n(),t()})})}_notifySubscribers(){const t=[];for(const n of this._subscribers)try{n()}catch(a){t.push(a)}if(t.length>0)throw t.length===1?t[0]:new AggregateError(t)}},GS=t=>t.status.type==="complete",fh=class extends zi{constructor(){super(...arguments);Y(this,"isEditing",!0);Y(this,"_attachments",[]);Y(this,"_text","");Y(this,"_role","user");Y(this,"_runConfig",{});Y(this,"_eventSubscribers",new Map)}get attachmentAccept(){var n,a;return(a=(n=this.getAttachmentAdapter())==null?void 0:n.accept)!=null?a:"*"}get attachments(){return this._attachments}setAttachments(n){this._attachments=n,this._notifySubscribers()}get isEmpty(){return!this.text.trim()&&!this.attachments.length}get text(){return this._text}get role(){return this._role}get runConfig(){return this._runConfig}setText(n){this._text!==n&&(this._text=n,this._notifySubscribers())}setRole(n){this._role!==n&&(this._role=n,this._notifySubscribers())}setRunConfig(n){this._runConfig!==n&&(this._runConfig=n,this._notifySubscribers())}_emptyTextAndAttachments(){this._attachments=[],this._text="",this._notifySubscribers()}_onClearAttachments(){return W(this,null,function*(){const n=this.getAttachmentAdapter();n&&(yield Promise.all(this._attachments.map(a=>n.remove(a))))})}reset(){return W(this,null,function*(){if(this._attachments.length===0&&this._text===""&&this._role==="user"&&Object.keys(this._runConfig).length===0)return;this._role="user",this._runConfig={};const n=this._onClearAttachments();this._emptyTextAndAttachments(),yield n})}clearAttachments(){return W(this,null,function*(){const n=this._onClearAttachments();this.setAttachments([]),yield n})}send(){return W(this,null,function*(){const n=this.getAttachmentAdapter(),a=n&&this.attachments.length>0?Promise.all(this.attachments.map(o=>W(this,null,function*(){return GS(o)?o:yield n.send(o)}))):[],i=this.text;this._emptyTextAndAttachments();const s={createdAt:new Date,role:this.role,content:i?[{type:"text",text:i}]:[],attachments:yield a,runConfig:this.runConfig,metadata:{custom:{}}};this.handleSend(s),this._notifyEventSubscribers("send")})}cancel(){this.handleCancel()}addAttachment(n){return W(this,null,function*(){const a=this.getAttachmentAdapter();if(!a)throw new Error("Attachments are not supported");const i=m=>{const y=this._attachments.findIndex(g=>g.id===m.id);y!==-1?this._attachments=[...this._attachments.slice(0,y),m,...this._attachments.slice(y+1)]:this._attachments=[...this._attachments,m],this._notifySubscribers()},s=a.add({file:n});if(Symbol.asyncIterator in s)try{for(var o=xa(s),c,d,h;c=!(d=yield o.next()).done;c=!1){const m=d.value;i(m)}}catch(d){h=[d]}finally{try{c&&(d=o.return)&&(yield d.call(o))}finally{if(h)throw h[0]}}else i(yield s);this._notifyEventSubscribers("attachment-add"),this._notifySubscribers()})}removeAttachment(n){return W(this,null,function*(){const a=this.getAttachmentAdapter();if(!a)throw new Error("Attachments are not supported");const i=this._attachments.findIndex(o=>o.id===n);if(i===-1)throw new Error("Attachment not found");const s=this._attachments[i];yield a.remove(s),this._attachments=[...this._attachments.slice(0,i),...this._attachments.slice(i+1)],this._notifySubscribers()})}_notifyEventSubscribers(n){const a=this._eventSubscribers.get(n);if(a)for(const i of a)i()}unstable_on(n,a){const i=this._eventSubscribers.get(n);return i?i.add(a):this._eventSubscribers.set(n,new Set([a])),()=>{const s=this._eventSubscribers.get(n);s&&s.delete(a)}}},dh=class extends fh{constructor(n){super();Y(this,"_canCancel",!1);this.runtime=n,this.connect()}get canCancel(){return this._canCancel}get attachments(){return super.attachments}getAttachmentAdapter(){var n;return(n=this.runtime.adapters)==null?void 0:n.attachments}connect(){return this.runtime.subscribe(()=>{this.canCancel!==this.runtime.capabilities.cancel&&(this._canCancel=this.runtime.capabilities.cancel,this._notifySubscribers())})}handleSend(n){return W(this,null,function*(){var a,i;this.runtime.append(G(_({},n),{parentId:(i=(a=this.runtime.messages.at(-1))==null?void 0:a.id)!=null?i:null,sourceId:null}))})}handleCancel(){return W(this,null,function*(){this.runtime.cancelRun()})}};let hh=(t,n=21)=>(a=n)=>{let i="",s=a|0;for(;s--;)i+=t[Math.random()*t.length|0];return i};var Pr=hh("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7),PS="__optimistic__",XS=()=>`${PS}${Pr()}`,Oi=Symbol("autoStatus"),QS=Object.freeze(Object.assign({type:"running"},{[Oi]:!0})),ZS=Object.freeze(Object.assign({type:"complete",reason:"unknown"},{[Oi]:!0})),KS=Object.freeze(Object.assign({type:"requires-action",reason:"tool-calls"},{[Oi]:!0})),JS=Object.freeze(Object.assign({type:"requires-action",reason:"interrupt"},{[Oi]:!0})),ph=(t,n,a,i,s)=>t&&s?Object.assign({type:"incomplete",reason:"error",error:s},{[Oi]:!0}):t&&n?QS:a?JS:i?KS:ZS,Xr={exports:{}},mh;function $S(){if(mh)return Xr.exports;mh=1;const t=typeof Buffer!="undefined",n=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,a=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function i(d,h,m){m==null&&h!==null&&typeof h=="object"&&(m=h,h=void 0),t&&Buffer.isBuffer(d)&&(d=d.toString()),d&&d.charCodeAt(0)===65279&&(d=d.slice(1));const y=JSON.parse(d,h);if(y===null||typeof y!="object")return y;const g=m&&m.protoAction||"error",v=m&&m.constructorAction||"error";if(g==="ignore"&&v==="ignore")return y;if(g!=="ignore"&&v!=="ignore"){if(n.test(d)===!1&&a.test(d)===!1)return y}else if(g!=="ignore"&&v==="ignore"){if(n.test(d)===!1)return y}else if(a.test(d)===!1)return y;return s(y,{protoAction:g,constructorAction:v,safe:m&&m.safe})}function s(d,{protoAction:h="error",constructorAction:m="error",safe:y}={}){let g=[d];for(;g.length;){const v=g;g=[];for(const x of v){if(h!=="ignore"&&Object.prototype.hasOwnProperty.call(x,"__proto__")){if(y===!0)return null;if(h==="error")throw new SyntaxError("Object contains forbidden prototype property");delete x.__proto__}if(m!=="ignore"&&Object.prototype.hasOwnProperty.call(x,"constructor")&&x.constructor!==null&&typeof x.constructor=="object"&&Object.prototype.hasOwnProperty.call(x.constructor,"prototype")){if(y===!0)return null;if(m==="error")throw new SyntaxError("Object contains forbidden prototype property");delete x.constructor}for(const w in x){const z=x[w];z&&typeof z=="object"&&g.push(z)}}}return d}function o(d,h,m){const{stackTraceLimit:y}=Error;Error.stackTraceLimit=0;try{return i(d,h,m)}finally{Error.stackTraceLimit=y}}function c(d,h){const{stackTraceLimit:m}=Error;Error.stackTraceLimit=0;try{return i(d,h,{safe:!0})}catch(y){return}finally{Error.stackTraceLimit=m}}return Xr.exports=o,Xr.exports.default=o,Xr.exports.parse=o,Xr.exports.safeParse=c,Xr.exports.scan=s,Xr.exports}var WS=$S();const so=Kt(WS);function t0(t){const n=["ROOT"];let a=-1,i=null;const s=[];let o;function c(){o!==void 0&&(s.push(JSON.parse('"'+o+'"')),o=void 0)}function d(g,v,x){switch(g){case'"':{a=v,n.pop(),n.push(x),n.push("INSIDE_STRING"),c();break}case"f":case"t":case"n":{a=v,i=v,n.pop(),n.push(x),n.push("INSIDE_LITERAL");break}case"-":{n.pop(),n.push(x),n.push("INSIDE_NUMBER"),c();break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{a=v,n.pop(),n.push(x),n.push("INSIDE_NUMBER"),c();break}case"{":{a=v,n.pop(),n.push(x),n.push("INSIDE_OBJECT_START"),c();break}case"[":{a=v,n.pop(),n.push(x),n.push("INSIDE_ARRAY_START"),c();break}}}function h(g,v){switch(g){case",":{n.pop(),n.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{a=v,n.pop(),o=s.pop();break}}}function m(g,v){switch(g){case",":{n.pop(),n.push("INSIDE_ARRAY_AFTER_COMMA"),o=(Number(o)+1).toString();break}case"]":{a=v,n.pop(),o=s.pop();break}}}for(let g=0;g<t.length;g++){const v=t[g];switch(n[n.length-1]){case"ROOT":d(v,g,"FINISH");break;case"INSIDE_OBJECT_START":{switch(v){case'"':{n.pop(),n.push("INSIDE_OBJECT_KEY"),o="";break}case"}":{a=g,n.pop(),o=s.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(v){case'"':{n.pop(),n.push("INSIDE_OBJECT_KEY"),o="";break}}break}case"INSIDE_OBJECT_KEY":{switch(v){case'"':{n.pop(),n.push("INSIDE_OBJECT_AFTER_KEY");break}case"\\":{n.push("INSIDE_STRING_ESCAPE"),o+=v;break}default:{o+=v;break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(v){case":":{n.pop(),n.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{d(v,g,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{h(v,g);break}case"INSIDE_STRING":{switch(v){case'"':{n.pop(),a=g,o=s.pop();break}case"\\":{n.push("INSIDE_STRING_ESCAPE");break}default:a=g}break}case"INSIDE_ARRAY_START":{switch(v){case"]":{a=g,n.pop(),o=s.pop();break}default:{a=g,o="0",d(v,g,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(v){case",":{n.pop(),n.push("INSIDE_ARRAY_AFTER_COMMA"),o=(Number(o)+1).toString();break}case"]":{a=g,n.pop(),o=s.pop();break}default:{a=g;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{d(v,g,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{n.pop(),n[n.length-1]==="INSIDE_STRING"?a=g:n[n.length-1]==="INSIDE_OBJECT_KEY"&&(o+=v);break}case"INSIDE_NUMBER":{switch(v){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{a=g;break}case"e":case"E":case"-":case".":break;case",":{n.pop(),o=s.pop(),n[n.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&m(v,g),n[n.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&h(v,g);break}case"}":{n.pop(),o=s.pop(),n[n.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&h(v,g);break}case"]":{n.pop(),o=s.pop(),n[n.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&m(v,g);break}default:{n.pop(),o=s.pop();break}}break}case"INSIDE_LITERAL":{const w=t.substring(i,g+1);!"false".startsWith(w)&&!"true".startsWith(w)&&!"null".startsWith(w)?(n.pop(),n[n.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?h(v,g):n[n.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&m(v,g)):a=g;break}}}let y=t.slice(0,a+1);for(let g=n.length-1;g>=0;g--)switch(n[g]){case"INSIDE_STRING":{y+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{y+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{y+="]";break}case"INSIDE_LITERAL":{const x=t.substring(i,t.length);"true".startsWith(x)?y+="true".slice(x.length):"false".startsWith(x)?y+="false".slice(x.length):"null".startsWith(x)&&(y+="null".slice(x.length))}}return[y,s]}var Jl=Symbol("aui.parse-partial-json-object.meta"),e0=t=>t==null?void 0:t[Jl],$l=t=>{if(t.length===0)return{[Jl]:{state:"partial",partialPath:[]}};try{const n=so.parse(t);if(typeof n!="object"||n===null)throw new Error("argsText is expected to be an object");return n[Jl]={state:"complete",partialPath:[]},n}catch(n){try{const[a,i]=t0(t),s=so.parse(a);if(typeof s!="object"||s===null)throw new Error("argsText is expected to be an object");return s[Jl]={state:"partial",partialPath:i},s}catch(a){return}}},gh=(t,n,a)=>{if(typeof t!="object"||t===null)return n.state;if(n.state==="complete")return"complete";if(a.length===0)return n.state;const[i,...s]=a;if(!Object.prototype.hasOwnProperty.call(t,i))return"partial";const[o,...c]=n.partialPath;if(i!==o)return"complete";const d=t[i];return gh(d,{state:"partial",partialPath:c},s)},wa=(t,n)=>{const a=e0(t);if(!a)throw new Error("unable to determine object state");return gh(t,a,n.map(String))};function n0(){return Kl(this,null,function*(){const t=this.getReader();try{for(;;){const{done:n,value:a}=yield new gr(t.read());if(n)break;yield a}}finally{t.releaseLock()}})}function uo(t){var n,a;return(a=t[n=Symbol.asyncIterator])!=null||(t[n]=n0),t}var oo={toResponse(t,n){var a;return new Response(oo.toByteStream(t,n),{headers:(a=n.headers)!=null?a:{}})},fromResponse(t,n){return oo.fromByteStream(t.body,n)},toByteStream(t,n){return t.pipeThrough(n)},fromByteStream(t,n){return t.pipeThrough(n)}},co=function(){let t,n;const a=new Promise((i,s)=>{t=i,n=s});if(!t||!n)throw new Error("Failed to create promise");return{promise:a,resolve:t,reject:n}},r0=()=>{const t=[];let n=!1,a,i;const s=c=>{c.promise||(c.promise=c.reader.read().then(({done:d,value:h})=>{c.promise=void 0,d?(t.splice(t.indexOf(c),1),n&&t.length===0&&a.close()):a.enqueue(h),i==null||i.resolve(),i=void 0}).catch(d=>{console.error(d),t.forEach(h=>{h.reader.cancel()}),t.length=0,a.error(d),i==null||i.reject(d),i=void 0}))};return{readable:new ReadableStream({start(c){a=c},pull(){return i=co(),t.forEach(c=>{s(c)}),i.promise},cancel(){t.forEach(c=>{c.reader.cancel()}),t.length=0}}),isSealed(){return n},seal(){n=!0,t.length===0&&a.close()},addStream(c){if(n)throw new Error("Cannot add streams after the run callback has settled.");const d={reader:c.getReader()};t.push(d),s(d)},enqueue(c){this.addStream(new ReadableStream({start(d){d.enqueue(c),d.close()}}))}}},yh=class{constructor(t){Y(this,"_controller");Y(this,"_isClosed",!1);this._controller=t}append(t){return this._controller.enqueue({type:"text-delta",path:[],textDelta:t}),this}close(){this._isClosed||(this._isClosed=!0,this._controller.enqueue({type:"part-finish",path:[]}),this._controller.close())}},bh=t=>new ReadableStream({start(n){var a;return(a=t.start)==null?void 0:a.call(t,new yh(n))},pull(n){var a;return(a=t.pull)==null?void 0:a.call(t,new yh(n))},cancel(n){var a;return(a=t.cancel)==null?void 0:a.call(t,n)}}),vh=()=>{let t;return[bh({start(a){t=a}}),t]},xh=class{constructor(t){Y(this,"_isClosed",!1);Y(this,"_mergeTask");Y(this,"_argsTextController");this._controller=t;const n=bh({start:i=>{this._argsTextController=i}});let a=!1;this._mergeTask=n.pipeTo(new WritableStream({write:i=>{switch(i.type){case"text-delta":a=!0,this._controller.enqueue(i);break;case"part-finish":a||this._controller.enqueue({type:"text-delta",textDelta:"{}",path:[]}),this._controller.enqueue({type:"tool-call-args-text-finish",path:[]});break;default:throw new Error(`Unexpected chunk type: ${i.type}`)}}}))}get argsText(){return this._argsTextController}setResponse(t){return W(this,null,function*(){var n;this._argsTextController.close(),yield Promise.resolve(),this._controller.enqueue(G(_({type:"result",path:[]},t.artifact!==void 0?{artifact:t.artifact}:{}),{result:t.result,isError:(n=t.isError)!=null?n:!1}))})}close(){return W(this,null,function*(){this._isClosed||(this._isClosed=!0,this._argsTextController.close(),yield this._mergeTask,this._controller.enqueue({type:"part-finish",path:[]}),this._controller.close())})}},a0=t=>new ReadableStream({start(n){var a;return(a=t.start)==null?void 0:a.call(t,new xh(n))},pull(n){var a;return(a=t.pull)==null?void 0:a.call(t,new xh(n))},cancel(n){var a;return(a=t.cancel)==null?void 0:a.call(t,n)}}),i0=()=>{let t;return[a0({start(a){t=a}}),t]},Sh=class{constructor(){Y(this,"value",-1)}up(){return++this.value}},l0=class extends TransformStream{constructor(t){super({transform(n,a){a.enqueue(G(_({},n),{path:[t,...n.path]}))}})}};(class extends TransformStream{constructor(t){super({transform(n,a){const{path:[i,...s]}=n;if(t!==i)throw new Error(`Path mismatch: expected ${t}, got ${i}`);a.enqueue(G(_({},n),{path:s}))}})}});var s0=class extends TransformStream{constructor(t){const n=new Sh,a=new Map;super({transform(i,s){i.type==="part-start"&&i.path.length===0&&a.set(n.up(),t.up());const[o,...c]=i.path;if(o===void 0){s.enqueue(i);return}const d=a.get(o);if(d===void 0)throw new Error("Path not found");s.enqueue(G(_({},i),{path:[d,...c]}))}})}},wh=class extends TransformStream{constructor(t){super();const n=t(super.readable);Object.defineProperty(this,"readable",{value:n,writable:!1})}},_h=class extends TransformStream{constructor(){const t=[];super({transform(n,a){if(n.type==="part-start"){if(n.path.length!==0){a.error(new Error("Nested parts are not supported"));return}t.push(n.part),a.enqueue(n);return}if(n.type==="text-delta"||n.type==="result"||n.type==="part-finish"||n.type==="tool-call-args-text-finish"){if(n.path.length!==1){a.error(new Error(`${n.type} chunks must have a path of length 1`));return}const i=n.path[0];if(i<0||i>=t.length){a.error(new Error(`Invalid path index: ${i}`));return}const s=t[i];a.enqueue(G(_({},n),{meta:s}));return}a.enqueue(n)}})}},Th=hh("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7),u0=class wS{constructor(n){Y(this,"_state");Y(this,"_parentId");this._state=n||{merger:r0(),contentCounter:new Sh}}get __internal_isClosed(){return this._state.merger.isSealed()}__internal_getReadable(){return this._state.merger.readable}__internal_subscribeToClose(n){this._state.closeSubscriber=n}_addPart(n,a){this._state.append&&(this._state.append.controller.close(),this._state.append=void 0),this.enqueue({type:"part-start",part:n,path:[]}),this._state.merger.addStream(a.pipeThrough(new l0(this._state.contentCounter.value)))}merge(n){this._state.merger.addStream(n.pipeThrough(new s0(this._state.contentCounter)))}appendText(n){var a;((a=this._state.append)==null?void 0:a.kind)!=="text"&&(this._state.append={kind:"text",controller:this.addTextPart()}),this._state.append.controller.append(n)}appendReasoning(n){var a;((a=this._state.append)==null?void 0:a.kind)!=="reasoning"&&(this._state.append={kind:"reasoning",controller:this.addReasoningPart()}),this._state.append.controller.append(n)}addTextPart(){const[n,a]=vh();return this._addPart({type:"text"},n),a}addReasoningPart(){const[n,a]=vh();return this._addPart({type:"reasoning"},n),a}addToolCallPart(n){var d;const a=typeof n=="string"?{toolName:n}:n,i=a.toolName,s=(d=a.toolCallId)!=null?d:Th(),[o,c]=i0();return this._addPart(_({type:"tool-call",toolName:i,toolCallId:s},this._parentId&&{parentId:this._parentId}),o),a.argsText!==void 0&&(c.argsText.append(a.argsText),c.argsText.close()),a.args!==void 0&&(c.argsText.append(JSON.stringify(a.args)),c.argsText.close()),a.response!==void 0&&c.setResponse(a.response),c}appendSource(n){this._addPart(_(_({},n),this._parentId&&{parentId:this._parentId}),new ReadableStream({start(a){a.enqueue({type:"part-finish",path:[]}),a.close()}}))}appendFile(n){this._addPart(n,new ReadableStream({start(a){a.enqueue({type:"part-finish",path:[]}),a.close()}}))}enqueue(n){this._state.merger.enqueue(n),n.type==="part-start"&&n.path.length===0&&this._state.contentCounter.up()}withParentId(n){const a=new wS(this._state);return a._parentId=n,a}close(){var n,a,i,s;(a=(n=this._state.append)==null?void 0:n.controller)==null||a.close(),this._state.merger.seal(),(s=(i=this._state).closeSubscriber)==null||s.call(i)}};function o0(t){const n=new u0;return W(null,null,function*(){try{yield t(n)}catch(i){throw n.__internal_isClosed||n.enqueue({type:"error",path:[],error:String(i)}),i}finally{n.__internal_isClosed||n.close()}}),n.__internal_getReadable()}function Eh(){const{resolve:t,promise:n}=co();let a;return[o0(s=>(a=s,a.__internal_subscribeToClose(t),n)),a]}var c0=class extends TransformStream{constructor(t,n,a){const[i,s]=Eh();let o;super({start(d){var h;return o=i.pipeTo(new WritableStream({write(m){d.enqueue(m)},abort(m){d.error(m)},close(){d.terminate()}})).catch(m=>{d.error(m)}),(h=t.start)==null?void 0:h.call(t,s)},transform(d){var h;return(h=t.transform)==null?void 0:h.call(t,d,s)},flush(){return W(this,null,function*(){var d;yield(d=t.flush)==null?void 0:d.call(t,s),s.close(),yield o})}},n,a)}},Di=(t,n,a)=>{var v,x,w,z,D,k,q;const{role:i,id:s,createdAt:o,attachments:c,status:d,metadata:h}=t,m={id:s!=null?s:n,createdAt:o!=null?o:new Date},y=typeof t.content=="string"?[{type:"text",text:t.content}]:t.content,g=lt=>{var L=lt,{image:I}=L,at=gt(L,["image"]);return I.match(/^data:image\/(png|jpeg|jpg|gif|webp);base64,(.*)$/)?G(_({},at),{image:I}):(console.warn("Invalid image data format detected"),null)};if(i!=="user"&&(c!=null&&c.length))throw new Error("attachments are only supported for user messages");if(i!=="assistant"&&d)throw new Error("status is only supported for assistant messages");if(i!=="assistant"&&(h!=null&&h.steps))throw new Error("metadata.steps is only supported for assistant messages");switch(i){case"assistant":return G(_({},m),{role:i,content:y.map(I=>{var L,J,st,ct,j;const at=I.type;switch(at){case"text":case"reasoning":return I.text.trim().length===0?null:I;case"file":case"source":return I;case"image":return g(I);case"data":return I;case"tool-call":{const lt=I,{parentId:tt,messages:$}=lt,bt=gt(lt,["parentId","messages"]),ot=_(_(G(_({},bt),{toolCallId:(L=I.toolCallId)!=null?L:`tool-${Pr()}`}),tt!==void 0&&{parentId:tt}),$!==void 0&&{messages:$});return I.args?G(_({},ot),{args:I.args,argsText:(J=I.argsText)!=null?J:JSON.stringify(I.args)}):G(_({},ot),{args:(ct=$l((st=I.argsText)!=null?st:""))!=null?ct:{},argsText:(j=I.argsText)!=null?j:""})}default:{const tt=at;throw new Error(`Unsupported assistant message part type: ${tt}`)}}}).filter(I=>!!I),status:d!=null?d:a,metadata:_({unstable_state:(v=h==null?void 0:h.unstable_state)!=null?v:null,unstable_annotations:(x=h==null?void 0:h.unstable_annotations)!=null?x:[],unstable_data:(w=h==null?void 0:h.unstable_data)!=null?w:[],custom:(z=h==null?void 0:h.custom)!=null?z:{},steps:(D=h==null?void 0:h.steps)!=null?D:[]},(h==null?void 0:h.submittedFeedback)&&{submittedFeedback:h.submittedFeedback})});case"user":return G(_({},m),{role:i,content:y.map(I=>{const at=I.type;switch(at){case"text":case"image":case"audio":case"file":return I;default:{const lt=at;throw new Error(`Unsupported user message part type: ${lt}`)}}}),attachments:c!=null?c:[],metadata:{custom:(k=h==null?void 0:h.custom)!=null?k:{}}});case"system":if(y.length!==1||y[0].type!=="text")throw new Error("System messages must have exactly one text message part.");return G(_({},m),{role:i,content:y,metadata:{custom:(q=h==null?void 0:h.custom)!=null?q:{}}});default:{const I=i;throw new Error(`Unknown message role: ${I}`)}}},fo={fromArray:t=>{const n=t.map(a=>Di(a,Pr(),ph(!1,!1,!1,!1,void 0)));return{messages:n.map((a,i)=>({parentId:i>0?n[i-1].id:null,message:a}))}}},Wl=t=>t.next?Wl(t.next):"current"in t?t:null,f0=class{constructor(t){Y(this,"_value",null);this.func=t}get value(){return this._value===null&&(this._value=this.func()),this._value}dirty(){this._value=null}},Ch=class{constructor(){Y(this,"messages",new Map);Y(this,"head",null);Y(this,"root",{children:[],next:null});Y(this,"_messages",new f0(()=>{var n,a;const t=new Array(((a=(n=this.head)==null?void 0:n.level)!=null?a:-1)+1);for(let i=this.head;i;i=i.prev)t[i.level]=i.current;return t}))}updateLevels(t,n){t.level=n;for(const a of t.children){const i=this.messages.get(a);i&&this.updateLevels(i,n+1)}}performOp(t,n,a){var o;const i=(o=n.prev)!=null?o:this.root,s=t!=null?t:this.root;if(!(a==="relink"&&i===s)){if(a!=="link"&&(i.children=i.children.filter(c=>c!==n.current.id),i.next===n)){const c=i.children.at(-1),d=c?this.messages.get(c):null;if(d===void 0)throw new Error("MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui.");i.next=d}if(a!=="cut"){for(let d=t;d;d=d.prev)if(d.current.id===n.current.id)throw new Error("MessageRepository(performOp/link): A message with the same id already exists in the parent tree. This error occurs if the same message id is found multiple times. This is likely an internal bug in assistant-ui.");s.children=[...s.children,n.current.id],(Wl(n)===this.head||s.next===null)&&(s.next=n),n.prev=t;const c=t?t.level+1:0;this.updateLevels(n,c)}}}get headId(){var t,n;return(n=(t=this.head)==null?void 0:t.current.id)!=null?n:null}getMessages(t){var i;if(t===void 0||t===((i=this.head)==null?void 0:i.current.id))return this._messages.value;const n=this.messages.get(t);if(!n)throw new Error("MessageRepository(getMessages): Head message not found. This is likely an internal bug in assistant-ui.");const a=new Array(n.level+1);for(let s=n;s;s=s.prev)a[s.level]=s.current;return a}addOrUpdateMessage(t,n){const a=this.messages.get(n.id),i=t?this.messages.get(t):null;if(i===void 0)throw new Error("MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui.");if(a){a.current=n,this.performOp(i,a,"relink"),this._messages.dirty();return}const s={prev:i,current:n,next:null,children:[],level:i?i.level+1:0};this.messages.set(n.id,s),this.performOp(i,s,"link"),this.head===i&&(this.head=s),this._messages.dirty()}getMessage(t){var a,i;const n=this.messages.get(t);if(!n)throw new Error("MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui.");return{parentId:(i=(a=n.prev)==null?void 0:a.current.id)!=null?i:null,message:n.current,index:n.level}}appendOptimisticMessage(t,n){let a;do a=XS();while(this.messages.has(a));return this.addOrUpdateMessage(t,Di(n,a,{type:"running"})),a}deleteMessage(t,n){const a=this.messages.get(t);if(!a)throw new Error("MessageRepository(deleteMessage): Message not found. This is likely an internal bug in assistant-ui.");const i=n===void 0?a.prev:n===null?null:this.messages.get(n);if(i===void 0)throw new Error("MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui.");for(const s of a.children){const o=this.messages.get(s);if(!o)throw new Error("MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui.");this.performOp(i,o,"relink")}this.performOp(null,a,"cut"),this.messages.delete(t),this.head===a&&(this.head=Wl(i!=null?i:this.root)),this._messages.dirty()}getBranches(t){var i;const n=this.messages.get(t);if(!n)throw new Error("MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui.");const{children:a}=(i=n.prev)!=null?i:this.root;return a}switchToBranch(t){var i;const n=this.messages.get(t);if(!n)throw new Error("MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui.");const a=(i=n.prev)!=null?i:this.root;a.next=n,this.head=Wl(n),this._messages.dirty()}resetHead(t){if(t===null){this.clear();return}const n=this.messages.get(t);if(!n)throw new Error("MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui.");if(n.children.length>0){const a=i=>{for(const s of i.children){const o=this.messages.get(s);o&&(a(o),this.messages.delete(s))}};a(n),n.children=[],n.next=null}this.head=n;for(let a=n;a;a=a.prev)a.prev&&(a.prev.next=a);this._messages.dirty()}clear(){this.messages.clear(),this.head=null,this.root={children:[],next:null},this._messages.dirty()}export(){var n,a,i,s;const t=[];for(const[,o]of this.messages)t.push({message:o.current,parentId:(a=(n=o.prev)==null?void 0:n.current.id)!=null?a:null});return{headId:(s=(i=this.head)==null?void 0:i.current.id)!=null?s:null,messages:t}}import({headId:t,messages:n}){var a,i;for(const{message:s,parentId:o}of n)this.addOrUpdateMessage(o,s);this.resetHead((i=t!=null?t:(a=n.at(-1))==null?void 0:a.message.id)!=null?i:null)}},ts=class{constructor(){Y(this,"_subscriptions",new Set);Y(this,"_connection")}get isConnected(){return!!this._connection}notifySubscribers(){for(const t of this._subscriptions)t()}_updateConnection(){var t;if(this._subscriptions.size>0){if(this._connection)return;this._connection=this._connect()}else(t=this._connection)==null||t.call(this),this._connection=void 0}subscribe(t){return this._subscriptions.add(t),this._updateConnection(),()=>{this._subscriptions.delete(t),this._updateConnection()}}},Rn=Symbol("skip-update"),ho=class extends ts{constructor(n){super();Y(this,"_previousStateDirty",!0);Y(this,"_previousState");Y(this,"getState",()=>{if(!this.isConnected||this._previousStateDirty){const n=this.binding.getState();n!==Rn&&(this._previousState=n),this._previousStateDirty=!1}if(this._previousState===void 0)throw new Error("Entry not available in the store");return this._previousState});this.binding=n}get path(){return this.binding.path}_connect(){const n=()=>{this._previousStateDirty=!0,this.notifySubscribers()};return this.binding.subscribe(n)}},es=class{constructor(t,n){this._core=t,this._threadListBinding=n,this.__internal_bindMethods()}get path(){return this._core.path}__internal_bindMethods(){this.switchTo=this.switchTo.bind(this),this.rename=this.rename.bind(this),this.archive=this.archive.bind(this),this.unarchive=this.unarchive.bind(this),this.delete=this.delete.bind(this),this.initialize=this.initialize.bind(this),this.generateTitle=this.generateTitle.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getState=this.getState.bind(this),this.detach=this.detach.bind(this)}getState(){return this._core.getState()}switchTo(){const t=this._core.getState();return this._threadListBinding.switchToThread(t.id)}rename(t){const n=this._core.getState();return this._threadListBinding.rename(n.id,t)}archive(){const t=this._core.getState();return this._threadListBinding.archive(t.id)}unarchive(){const t=this._core.getState();return this._threadListBinding.unarchive(t.id)}delete(){const t=this._core.getState();return this._threadListBinding.delete(t.id)}initialize(){const t=this._core.getState();return this._threadListBinding.initialize(t.id)}generateTitle(){const t=this._core.getState();return this._threadListBinding.generateTitle(t.id)}unstable_on(t,n){let a=this._core.getState().isMain,i=this._core.getState().id;return this.subscribe(()=>{const s=this._core.getState(),o=s.isMain,c=s.id;a===o&&i===c||(a=o,i=c,!(t==="switched-to"&&!o)&&(t==="switched-away"&&o||n()))})}subscribe(t){return this._core.subscribe(t)}detach(){const t=this._core.getState();this._threadListBinding.detach(t.id)}__internal_getRuntime(){return this}};function d0(t,n){if(t===void 0&&n===void 0)return!0;if(t===void 0||n===void 0)return!1;for(const a of Object.keys(t)){const i=t[a],s=n[a];if(!Object.is(i,s))return!1}return!0}var Mn=class extends ts{constructor(n){super();Y(this,"_previousState");Y(this,"getState",()=>(this.isConnected||this._syncState(),this._previousState));this.binding=n;const a=n.getState();if(a===Rn)throw new Error("Entry not available in the store");this._previousState=a}get path(){return this.binding.path}_syncState(){const n=this.binding.getState();return n===Rn||d0(n,this._previousState)?!1:(this._previousState=n,!0)}_connect(){const n=()=>{this._syncState()&&this.notifySubscribers()};return this.binding.subscribe(n)}},ns=Symbol("innerMessage"),rs=t=>t.content.filter(a=>a.type==="text").map(a=>a.text).join(`
3
+ ${n.system}`:r.system=n.system),n.tools)for(const[s,a]of Object.entries(n.tools)){const o=(i=r.tools)==null?void 0:i[s];if(o&&o!==a)throw new Error(`You tried to define a tool with the name ${s}, but it already exists.`);r.tools||(r.tools={}),r.tools[s]=a}return n.config&&(r.config=m(m({},r.config),n.config)),n.callSettings&&(r.callSettings=m(m({},r.callSettings),n.callSettings)),r},{}),cn=class{constructor(){T(this,"_providers",new Set);T(this,"_subscribers",new Set)}getModelContext(){return xu(this._providers)}registerModelContextProvider(e){var r;this._providers.add(e);const t=(r=e.subscribe)==null?void 0:r.call(e,()=>{this.notifySubscribers()});return this.notifySubscribers(),()=>{this._providers.delete(e),t==null||t(),this.notifySubscribers()}}notifySubscribers(){for(const e of this._subscribers)e()}subscribe(e){return this._subscribers.add(e),()=>this._subscribers.delete(e)}},dn=class{constructor(){T(this,"_contextProvider",new cn)}registerModelContextProvider(e){return this._contextProvider.registerModelContextProvider(e)}getModelContextProvider(){return this._contextProvider}},qt=class{constructor(){T(this,"_subscribers",new Set)}subscribe(e){return this._subscribers.add(e),()=>this._subscribers.delete(e)}waitForUpdate(){return new Promise(e=>{const t=this.subscribe(()=>{t(),e()})})}_notifySubscribers(){const e=[];for(const t of this._subscribers)try{t()}catch(r){e.push(r)}if(e.length>0)throw e.length===1?e[0]:new AggregateError(e)}},vu=e=>e.status.type==="complete",Hi=class extends qt{constructor(){super(...arguments);T(this,"isEditing",!0);T(this,"_attachments",[]);T(this,"_text","");T(this,"_role","user");T(this,"_runConfig",{});T(this,"_eventSubscribers",new Map)}get attachmentAccept(){var t,r;return(r=(t=this.getAttachmentAdapter())==null?void 0:t.accept)!=null?r:"*"}get attachments(){return this._attachments}setAttachments(t){this._attachments=t,this._notifySubscribers()}get isEmpty(){return!this.text.trim()&&!this.attachments.length}get text(){return this._text}get role(){return this._role}get runConfig(){return this._runConfig}setText(t){this._text!==t&&(this._text=t,this._notifySubscribers())}setRole(t){this._role!==t&&(this._role=t,this._notifySubscribers())}setRunConfig(t){this._runConfig!==t&&(this._runConfig=t,this._notifySubscribers())}_emptyTextAndAttachments(){this._attachments=[],this._text="",this._notifySubscribers()}_onClearAttachments(){return P(this,null,function*(){const t=this.getAttachmentAdapter();t&&(yield Promise.all(this._attachments.map(r=>t.remove(r))))})}reset(){return P(this,null,function*(){if(this._attachments.length===0&&this._text===""&&this._role==="user"&&Object.keys(this._runConfig).length===0)return;this._role="user",this._runConfig={};const t=this._onClearAttachments();this._emptyTextAndAttachments(),yield t})}clearAttachments(){return P(this,null,function*(){const t=this._onClearAttachments();this.setAttachments([]),yield t})}send(){return P(this,null,function*(){const t=this.getAttachmentAdapter(),r=t&&this.attachments.length>0?Promise.all(this.attachments.map(s=>P(this,null,function*(){return vu(s)?s:yield t.send(s)}))):[],n=this.text;this._emptyTextAndAttachments();const i={createdAt:new Date,role:this.role,content:n?[{type:"text",text:n}]:[],attachments:yield r,runConfig:this.runConfig,metadata:{custom:{}}};this.handleSend(i),this._notifyEventSubscribers("send")})}cancel(){this.handleCancel()}addAttachment(t){return P(this,null,function*(){const r=this.getAttachmentAdapter();if(!r)throw new Error("Attachments are not supported");const n=u=>{const d=this._attachments.findIndex(c=>c.id===u.id);d!==-1?this._attachments=[...this._attachments.slice(0,d),u,...this._attachments.slice(d+1)]:this._attachments=[...this._attachments,u],this._notifySubscribers()},i=r.add({file:t});if(Symbol.asyncIterator in i)try{for(var s=xt(i),a,o,l;a=!(o=yield s.next()).done;a=!1){const u=o.value;n(u)}}catch(o){l=[o]}finally{try{a&&(o=s.return)&&(yield o.call(s))}finally{if(l)throw l[0]}}else n(yield i);this._notifyEventSubscribers("attachment-add"),this._notifySubscribers()})}removeAttachment(t){return P(this,null,function*(){const r=this.getAttachmentAdapter();if(!r)throw new Error("Attachments are not supported");const n=this._attachments.findIndex(s=>s.id===t);if(n===-1)throw new Error("Attachment not found");const i=this._attachments[n];yield r.remove(i),this._attachments=[...this._attachments.slice(0,n),...this._attachments.slice(n+1)],this._notifySubscribers()})}_notifyEventSubscribers(t){const r=this._eventSubscribers.get(t);if(r)for(const n of r)n()}unstable_on(t,r){const n=this._eventSubscribers.get(t);return n?n.add(r):this._eventSubscribers.set(t,new Set([r])),()=>{const i=this._eventSubscribers.get(t);i&&i.delete(r)}}},qi=class extends Hi{constructor(t){super();T(this,"_canCancel",!1);this.runtime=t,this.connect()}get canCancel(){return this._canCancel}get attachments(){return super.attachments}getAttachmentAdapter(){var t;return(t=this.runtime.adapters)==null?void 0:t.attachments}connect(){return this.runtime.subscribe(()=>{this.canCancel!==this.runtime.capabilities.cancel&&(this._canCancel=this.runtime.capabilities.cancel,this._notifySubscribers())})}handleSend(t){return P(this,null,function*(){var r,n;this.runtime.append(E(m({},t),{parentId:(n=(r=this.runtime.messages.at(-1))==null?void 0:r.id)!=null?n:null,sourceId:null}))})}handleCancel(){return P(this,null,function*(){this.runtime.cancelRun()})}};let Vi=(e,t=21)=>(r=t)=>{let n="",i=r|0;for(;i--;)n+=e[Math.random()*e.length|0];return n};var ut=Vi("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7),Su="__optimistic__",ku=()=>`${Su}${ut()}`,Vt=Symbol("autoStatus"),_u=Object.freeze(Object.assign({type:"running"},{[Vt]:!0})),Tu=Object.freeze(Object.assign({type:"complete",reason:"unknown"},{[Vt]:!0})),Cu=Object.freeze(Object.assign({type:"requires-action",reason:"tool-calls"},{[Vt]:!0})),Iu=Object.freeze(Object.assign({type:"requires-action",reason:"interrupt"},{[Vt]:!0})),Wi=(e,t,r,n,i)=>e&&i?Object.assign({type:"incomplete",reason:"error",error:i},{[Vt]:!0}):e&&t?_u:r?Iu:n?Cu:Tu;function xr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ct={exports:{}},Ji;function Eu(){if(Ji)return ct.exports;Ji=1;const e=typeof Buffer!="undefined",t=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,r=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function n(o,l,u){u==null&&l!==null&&typeof l=="object"&&(u=l,l=void 0),e&&Buffer.isBuffer(o)&&(o=o.toString()),o&&o.charCodeAt(0)===65279&&(o=o.slice(1));const d=JSON.parse(o,l);if(d===null||typeof d!="object")return d;const c=u&&u.protoAction||"error",f=u&&u.constructorAction||"error";if(c==="ignore"&&f==="ignore")return d;if(c!=="ignore"&&f!=="ignore"){if(t.test(o)===!1&&r.test(o)===!1)return d}else if(c!=="ignore"&&f==="ignore"){if(t.test(o)===!1)return d}else if(r.test(o)===!1)return d;return i(d,{protoAction:c,constructorAction:f,safe:u&&u.safe})}function i(o,{protoAction:l="error",constructorAction:u="error",safe:d}={}){let c=[o];for(;c.length;){const f=c;c=[];for(const h of f){if(l!=="ignore"&&Object.prototype.hasOwnProperty.call(h,"__proto__")){if(d===!0)return null;if(l==="error")throw new SyntaxError("Object contains forbidden prototype property");delete h.__proto__}if(u!=="ignore"&&Object.prototype.hasOwnProperty.call(h,"constructor")&&h.constructor!==null&&typeof h.constructor=="object"&&Object.prototype.hasOwnProperty.call(h.constructor,"prototype")){if(d===!0)return null;if(u==="error")throw new SyntaxError("Object contains forbidden prototype property");delete h.constructor}for(const g in h){const S=h[g];S&&typeof S=="object"&&c.push(S)}}}return o}function s(o,l,u){const{stackTraceLimit:d}=Error;Error.stackTraceLimit=0;try{return n(o,l,u)}finally{Error.stackTraceLimit=d}}function a(o,l){const{stackTraceLimit:u}=Error;Error.stackTraceLimit=0;try{return n(o,l,{safe:!0})}catch(d){return}finally{Error.stackTraceLimit=u}}return ct.exports=s,ct.exports.default=s,ct.exports.parse=s,ct.exports.safeParse=a,ct.exports.scan=i,ct.exports}var Au=Eu();const hn=xr(Au);function Pu(e){const t=["ROOT"];let r=-1,n=null;const i=[];let s;function a(){s!==void 0&&(i.push(JSON.parse(`"${s}"`)),s=void 0)}function o(c,f,h){switch(c){case'"':{r=f,t.pop(),t.push(h),t.push("INSIDE_STRING"),a();break}case"f":case"t":case"n":{r=f,n=f,t.pop(),t.push(h),t.push("INSIDE_LITERAL");break}case"-":{t.pop(),t.push(h),t.push("INSIDE_NUMBER"),a();break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{r=f,t.pop(),t.push(h),t.push("INSIDE_NUMBER"),a();break}case"{":{r=f,t.pop(),t.push(h),t.push("INSIDE_OBJECT_START"),a();break}case"[":{r=f,t.pop(),t.push(h),t.push("INSIDE_ARRAY_START"),a();break}}}function l(c,f){switch(c){case",":{t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{r=f,t.pop(),s=i.pop();break}}}function u(c,f){switch(c){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA"),s=(Number(s)+1).toString();break}case"]":{r=f,t.pop(),s=i.pop();break}}}for(let c=0;c<e.length;c++){const f=e[c];switch(t[t.length-1]){case"ROOT":o(f,c,"FINISH");break;case"INSIDE_OBJECT_START":{switch(f){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY"),s="";break}case"}":{r=c,t.pop(),s=i.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(f){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY"),s="";break}}break}case"INSIDE_OBJECT_KEY":{switch(f){case'"':{t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY");break}case"\\":{t.push("INSIDE_STRING_ESCAPE"),s+=f;break}default:{s+=f;break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(f){case":":{t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{o(f,c,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{l(f,c);break}case"INSIDE_STRING":{switch(f){case'"':{t.pop(),r=c,s=i.pop();break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:r=c}break}case"INSIDE_ARRAY_START":{switch(f){case"]":{r=c,t.pop(),s=i.pop();break}default:{r=c,s="0",o(f,c,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(f){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA"),s=(Number(s)+1).toString();break}case"]":{r=c,t.pop(),s=i.pop();break}default:{r=c;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{o(f,c,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),t[t.length-1]==="INSIDE_STRING"?r=c:t[t.length-1]==="INSIDE_OBJECT_KEY"&&(s+=f);break}case"INSIDE_NUMBER":{switch(f){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{r=c;break}case"e":case"E":case"-":case".":break;case",":{t.pop(),s=i.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&u(f,c),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&l(f,c);break}case"}":{t.pop(),s=i.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&l(f,c);break}case"]":{t.pop(),s=i.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&u(f,c);break}default:{t.pop(),s=i.pop();break}}break}case"INSIDE_LITERAL":{const g=e.substring(n,c+1);!"false".startsWith(g)&&!"true".startsWith(g)&&!"null".startsWith(g)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?l(f,c):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&u(f,c)):r=c;break}}}let d=e.slice(0,r+1);for(let c=t.length-1;c>=0;c--)switch(t[c]){case"INSIDE_STRING":{d+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{d+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{d+="]";break}case"INSIDE_LITERAL":{const h=e.substring(n,e.length);"true".startsWith(h)?d+="true".slice(h.length):"false".startsWith(h)?d+="false".slice(h.length):"null".startsWith(h)&&(d+="null".slice(h.length))}}return[d,i]}var vr=Symbol("aui.parse-partial-json-object.meta"),Mu=e=>e==null?void 0:e[vr],Sr=e=>{if(e.length===0)return{[vr]:{state:"partial",partialPath:[]}};try{const t=hn.parse(e);if(typeof t!="object"||t===null)throw new Error("argsText is expected to be an object");return t[vr]={state:"complete",partialPath:[]},t}catch(t){try{const[r,n]=Pu(e),i=hn.parse(r);if(typeof i!="object"||i===null)throw new Error("argsText is expected to be an object");return i[vr]={state:"partial",partialPath:n},i}catch(r){return}}},Gi=(e,t,r)=>{if(typeof e!="object"||e===null)return t.state;if(t.state==="complete")return"complete";if(r.length===0)return t.state;const[n,...i]=r;if(!Object.prototype.hasOwnProperty.call(e,n))return"partial";const[s,...a]=t.partialPath;if(n!==s)return"complete";const o=e[n];return Gi(o,{state:"partial",partialPath:a},i)},vt=(e,t)=>{const r=Mu(e);if(!r)throw new Error("unable to determine object state");return Gi(e,r,t.map(String))};function Lu(){return wr(this,null,function*(){const e=this.getReader();try{for(;;){const{done:t,value:r}=yield new it(e.read());if(t)break;yield r}}finally{e.releaseLock()}})}function fn(e){var t,r;return(r=e[t=Symbol.asyncIterator])!=null||(e[t]=Lu),e}var pn={toResponse(e,t){var r;return new Response(pn.toByteStream(e,t),{headers:(r=t.headers)!=null?r:{}})},fromResponse(e,t){return pn.fromByteStream(e.body,t)},toByteStream(e,t){return e.pipeThrough(t)},fromByteStream(e,t){return e.pipeThrough(t)}},mn=function(){let e,t;const r=new Promise((n,i)=>{e=n,t=i});if(!e||!t)throw new Error("Failed to create promise");return{promise:r,resolve:e,reject:t}},Nu=()=>{const e=[];let t=!1,r,n;const i=a=>{a.promise||(a.promise=a.reader.read().then(({done:o,value:l})=>{a.promise=void 0,o?(e.splice(e.indexOf(a),1),t&&e.length===0&&r.close()):r.enqueue(l),n==null||n.resolve(),n=void 0}).catch(o=>{console.error(o),e.forEach(l=>{l.reader.cancel()}),e.length=0,r.error(o),n==null||n.reject(o),n=void 0}))};return{readable:new ReadableStream({start(a){r=a},pull(){return n=mn(),e.forEach(a=>{i(a)}),n.promise},cancel(){e.forEach(a=>{a.reader.cancel()}),e.length=0}}),isSealed(){return t},seal(){t=!0,e.length===0&&r.close()},addStream(a){if(t)throw new Error("Cannot add streams after the run callback has settled.");const o={reader:a.getReader()};e.push(o),i(o)},enqueue(a){this.addStream(new ReadableStream({start(o){o.enqueue(a),o.close()}}))}}},Yi=class{constructor(e){T(this,"_controller");T(this,"_isClosed",!1);this._controller=e}append(e){return this._controller.enqueue({type:"text-delta",path:[],textDelta:e}),this}close(){this._isClosed||(this._isClosed=!0,this._controller.enqueue({type:"part-finish",path:[]}),this._controller.close())}},Ki=e=>new ReadableStream({start(t){var r;return(r=e.start)==null?void 0:r.call(e,new Yi(t))},pull(t){var r;return(r=e.pull)==null?void 0:r.call(e,new Yi(t))},cancel(t){var r;return(r=e.cancel)==null?void 0:r.call(e,t)}}),Xi=()=>{let e;return[Ki({start(r){e=r}}),e]},Qi=class{constructor(e){T(this,"_isClosed",!1);T(this,"_mergeTask");T(this,"_argsTextController");this._controller=e;const t=Ki({start:n=>{this._argsTextController=n}});let r=!1;this._mergeTask=t.pipeTo(new WritableStream({write:n=>{switch(n.type){case"text-delta":r=!0,this._controller.enqueue(n);break;case"part-finish":r||this._controller.enqueue({type:"text-delta",textDelta:"{}",path:[]}),this._controller.enqueue({type:"tool-call-args-text-finish",path:[]});break;default:throw new Error(`Unexpected chunk type: ${n.type}`)}}}))}get argsText(){return this._argsTextController}setResponse(e){return P(this,null,function*(){var t;this._argsTextController.close(),yield Promise.resolve(),this._controller.enqueue(E(m({type:"result",path:[]},e.artifact!==void 0?{artifact:e.artifact}:{}),{result:e.result,isError:(t=e.isError)!=null?t:!1}))})}close(){return P(this,null,function*(){this._isClosed||(this._isClosed=!0,this._argsTextController.close(),yield this._mergeTask,this._controller.enqueue({type:"part-finish",path:[]}),this._controller.close())})}},Du=e=>new ReadableStream({start(t){var r;return(r=e.start)==null?void 0:r.call(e,new Qi(t))},pull(t){var r;return(r=e.pull)==null?void 0:r.call(e,new Qi(t))},cancel(t){var r;return(r=e.cancel)==null?void 0:r.call(e,t)}}),Ou=()=>{let e;return[Du({start(r){e=r}}),e]},Zi=class{constructor(){T(this,"value",-1)}up(){return++this.value}},Fu=class extends TransformStream{constructor(e){super({transform(t,r){r.enqueue(E(m({},t),{path:[e,...t.path]}))}})}};(class extends TransformStream{constructor(e){super({transform(t,r){const{path:[n,...i]}=t;if(e!==n)throw new Error(`Path mismatch: expected ${e}, got ${n}`);r.enqueue(E(m({},t),{path:i}))}})}});var Bu=class extends TransformStream{constructor(e){const t=new Zi,r=new Map;super({transform(n,i){n.type==="part-start"&&n.path.length===0&&r.set(t.up(),e.up());const[s,...a]=n.path;if(s===void 0){i.enqueue(n);return}const o=r.get(s);if(o===void 0)throw new Error("Path not found");i.enqueue(E(m({},n),{path:[o,...a]}))}})}},es=class extends TransformStream{constructor(e){super();const t=e(super.readable);Object.defineProperty(this,"readable",{value:t,writable:!1})}},ts=class extends TransformStream{constructor(){const e=[];super({transform(t,r){if(t.type==="part-start"){if(t.path.length!==0){r.error(new Error("Nested parts are not supported"));return}e.push(t.part),r.enqueue(t);return}if(t.type==="text-delta"||t.type==="result"||t.type==="part-finish"||t.type==="tool-call-args-text-finish"){if(t.path.length!==1){r.error(new Error(`${t.type} chunks must have a path of length 1`));return}const n=t.path[0];if(n<0||n>=e.length){r.error(new Error(`Invalid path index: ${n}`));return}const i=e[n];r.enqueue(E(m({},t),{meta:i}));return}r.enqueue(t)}})}},rs=Vi("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7),zu=class cu{constructor(t){T(this,"_state");T(this,"_parentId");this._state=t||{merger:Nu(),contentCounter:new Zi}}get __internal_isClosed(){return this._state.merger.isSealed()}__internal_getReadable(){return this._state.merger.readable}__internal_subscribeToClose(t){this._state.closeSubscriber=t}_addPart(t,r){this._state.append&&(this._state.append.controller.close(),this._state.append=void 0),this.enqueue({type:"part-start",part:t,path:[]}),this._state.merger.addStream(r.pipeThrough(new Fu(this._state.contentCounter.value)))}merge(t){this._state.merger.addStream(t.pipeThrough(new Bu(this._state.contentCounter)))}appendText(t){var r;((r=this._state.append)==null?void 0:r.kind)!=="text"&&(this._state.append={kind:"text",controller:this.addTextPart()}),this._state.append.controller.append(t)}appendReasoning(t){var r;((r=this._state.append)==null?void 0:r.kind)!=="reasoning"&&(this._state.append={kind:"reasoning",controller:this.addReasoningPart()}),this._state.append.controller.append(t)}addTextPart(){const[t,r]=Xi();return this._addPart({type:"text"},t),r}addReasoningPart(){const[t,r]=Xi();return this._addPart({type:"reasoning"},t),r}addToolCallPart(t){var o;const r=typeof t=="string"?{toolName:t}:t,n=r.toolName,i=(o=r.toolCallId)!=null?o:rs(),[s,a]=Ou();return this._addPart(m({type:"tool-call",toolName:n,toolCallId:i},this._parentId&&{parentId:this._parentId}),s),r.argsText!==void 0&&(a.argsText.append(r.argsText),a.argsText.close()),r.args!==void 0&&(a.argsText.append(JSON.stringify(r.args)),a.argsText.close()),r.response!==void 0&&a.setResponse(r.response),a}appendSource(t){this._addPart(m(m({},t),this._parentId&&{parentId:this._parentId}),new ReadableStream({start(r){r.enqueue({type:"part-finish",path:[]}),r.close()}}))}appendFile(t){this._addPart(t,new ReadableStream({start(r){r.enqueue({type:"part-finish",path:[]}),r.close()}}))}enqueue(t){this._state.merger.enqueue(t),t.type==="part-start"&&t.path.length===0&&this._state.contentCounter.up()}withParentId(t){const r=new cu(this._state);return r._parentId=t,r}close(){var t,r,n,i;(r=(t=this._state.append)==null?void 0:t.controller)==null||r.close(),this._state.merger.seal(),(i=(n=this._state).closeSubscriber)==null||i.call(n)}};function Ru(e){const t=new zu;return P(null,null,function*(){try{yield e(t)}catch(n){throw t.__internal_isClosed||t.enqueue({type:"error",path:[],error:String(n)}),n}finally{t.__internal_isClosed||t.close()}}),t.__internal_getReadable()}function ns(){const{resolve:e,promise:t}=mn();let r;return[Ru(i=>(r=i,r.__internal_subscribeToClose(e),t)),r]}var ju=class extends TransformStream{constructor(e,t,r){const[n,i]=ns();let s;super({start(o){var l;return s=n.pipeTo(new WritableStream({write(u){o.enqueue(u)},abort(u){o.error(u)},close(){o.terminate()}})).catch(u=>{o.error(u)}),(l=e.start)==null?void 0:l.call(e,i)},transform(o){var l;return(l=e.transform)==null?void 0:l.call(e,o,i)},flush(){return P(this,null,function*(){var o;yield(o=e.flush)==null?void 0:o.call(e,i),i.close(),yield s})}},t,r)}},Wt=(e,t,r)=>{var f,h,g,S,w,b,C;const{role:n,id:i,createdAt:s,attachments:a,status:o,metadata:l}=e,u={id:i!=null?i:t,createdAt:s!=null?s:new Date},d=typeof e.content=="string"?[{type:"text",text:e.content}]:e.content,c=B=>{var I=B,{image:_}=I,F=H(I,["image"]);return _.match(/^data:image\/(png|jpeg|jpg|gif|webp);base64,(.*)$/)?E(m({},F),{image:_}):(console.warn("Invalid image data format detected"),null)};if(n!=="user"&&(a!=null&&a.length))throw new Error("attachments are only supported for user messages");if(n!=="assistant"&&o)throw new Error("status is only supported for assistant messages");if(n!=="assistant"&&(l!=null&&l.steps))throw new Error("metadata.steps is only supported for assistant messages");switch(n){case"assistant":return E(m({},u),{role:n,content:d.map(_=>{var I,z,j,$,k;const F=_.type;switch(F){case"text":case"reasoning":return _.text.trim().length===0?null:_;case"file":case"source":return _;case"image":return c(_);case"data":return _;case"tool-call":{const B=_,{parentId:N,messages:M}=B,V=H(B,["parentId","messages"]),R=m(m(E(m({},V),{toolCallId:(I=_.toolCallId)!=null?I:`tool-${ut()}`}),N!==void 0&&{parentId:N}),M!==void 0&&{messages:M});return _.args?E(m({},R),{args:_.args,argsText:(z=_.argsText)!=null?z:JSON.stringify(_.args)}):E(m({},R),{args:($=Sr((j=_.argsText)!=null?j:""))!=null?$:{},argsText:(k=_.argsText)!=null?k:""})}default:{const N=F;throw new Error(`Unsupported assistant message part type: ${N}`)}}}).filter(_=>!!_),status:o!=null?o:r,metadata:m({unstable_state:(f=l==null?void 0:l.unstable_state)!=null?f:null,unstable_annotations:(h=l==null?void 0:l.unstable_annotations)!=null?h:[],unstable_data:(g=l==null?void 0:l.unstable_data)!=null?g:[],custom:(S=l==null?void 0:l.custom)!=null?S:{},steps:(w=l==null?void 0:l.steps)!=null?w:[]},(l==null?void 0:l.submittedFeedback)&&{submittedFeedback:l.submittedFeedback})});case"user":return E(m({},u),{role:n,content:d.map(_=>{const F=_.type;switch(F){case"text":case"image":case"audio":case"file":return _;default:{const B=F;throw new Error(`Unsupported user message part type: ${B}`)}}}),attachments:a!=null?a:[],metadata:{custom:(b=l==null?void 0:l.custom)!=null?b:{}}});case"system":if(d.length!==1||d[0].type!=="text")throw new Error("System messages must have exactly one text message part.");return E(m({},u),{role:n,content:d,metadata:{custom:(C=l==null?void 0:l.custom)!=null?C:{}}});default:{const _=n;throw new Error(`Unknown message role: ${_}`)}}},gn={fromArray:e=>{const t=e.map(r=>Wt(r,ut(),Wi(!1,!1,!1,!1,void 0)));return{messages:t.map((r,n)=>({parentId:n>0?t[n-1].id:null,message:r}))}}},kr=e=>e.next?kr(e.next):"current"in e?e:null,Uu=class{constructor(e){T(this,"_value",null);this.func=e}get value(){return this._value===null&&(this._value=this.func()),this._value}dirty(){this._value=null}},is=class{constructor(){T(this,"messages",new Map);T(this,"head",null);T(this,"root",{children:[],next:null});T(this,"_messages",new Uu(()=>{var t,r;const e=new Array(((r=(t=this.head)==null?void 0:t.level)!=null?r:-1)+1);for(let n=this.head;n;n=n.prev)e[n.level]=n.current;return e}))}updateLevels(e,t){e.level=t;for(const r of e.children){const n=this.messages.get(r);n&&this.updateLevels(n,t+1)}}performOp(e,t,r){var s;const n=(s=t.prev)!=null?s:this.root,i=e!=null?e:this.root;if(!(r==="relink"&&n===i)){if(r!=="link"&&(n.children=n.children.filter(a=>a!==t.current.id),n.next===t)){const a=n.children.at(-1),o=a?this.messages.get(a):null;if(o===void 0)throw new Error("MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui.");n.next=o}if(r!=="cut"){for(let o=e;o;o=o.prev)if(o.current.id===t.current.id)throw new Error("MessageRepository(performOp/link): A message with the same id already exists in the parent tree. This error occurs if the same message id is found multiple times. This is likely an internal bug in assistant-ui.");i.children=[...i.children,t.current.id],(kr(t)===this.head||i.next===null)&&(i.next=t),t.prev=e;const a=e?e.level+1:0;this.updateLevels(t,a)}}}get headId(){var e,t;return(t=(e=this.head)==null?void 0:e.current.id)!=null?t:null}getMessages(e){var n;if(e===void 0||e===((n=this.head)==null?void 0:n.current.id))return this._messages.value;const t=this.messages.get(e);if(!t)throw new Error("MessageRepository(getMessages): Head message not found. This is likely an internal bug in assistant-ui.");const r=new Array(t.level+1);for(let i=t;i;i=i.prev)r[i.level]=i.current;return r}addOrUpdateMessage(e,t){const r=this.messages.get(t.id),n=e?this.messages.get(e):null;if(n===void 0)throw new Error("MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui.");if(r){r.current=t,this.performOp(n,r,"relink"),this._messages.dirty();return}const i={prev:n,current:t,next:null,children:[],level:n?n.level+1:0};this.messages.set(t.id,i),this.performOp(n,i,"link"),this.head===n&&(this.head=i),this._messages.dirty()}getMessage(e){var r,n;const t=this.messages.get(e);if(!t)throw new Error("MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui.");return{parentId:(n=(r=t.prev)==null?void 0:r.current.id)!=null?n:null,message:t.current,index:t.level}}appendOptimisticMessage(e,t){let r;do r=ku();while(this.messages.has(r));return this.addOrUpdateMessage(e,Wt(t,r,{type:"running"})),r}deleteMessage(e,t){const r=this.messages.get(e);if(!r)throw new Error("MessageRepository(deleteMessage): Message not found. This is likely an internal bug in assistant-ui.");const n=t===void 0?r.prev:t===null?null:this.messages.get(t);if(n===void 0)throw new Error("MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui.");for(const i of r.children){const s=this.messages.get(i);if(!s)throw new Error("MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui.");this.performOp(n,s,"relink")}this.performOp(null,r,"cut"),this.messages.delete(e),this.head===r&&(this.head=kr(n!=null?n:this.root)),this._messages.dirty()}getBranches(e){var n;const t=this.messages.get(e);if(!t)throw new Error("MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui.");const{children:r}=(n=t.prev)!=null?n:this.root;return r}switchToBranch(e){var n;const t=this.messages.get(e);if(!t)throw new Error("MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui.");const r=(n=t.prev)!=null?n:this.root;r.next=t,this.head=kr(t),this._messages.dirty()}resetHead(e){if(e===null){this.clear();return}const t=this.messages.get(e);if(!t)throw new Error("MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui.");if(t.children.length>0){const r=n=>{for(const i of n.children){const s=this.messages.get(i);s&&(r(s),this.messages.delete(i))}};r(t),t.children=[],t.next=null}this.head=t;for(let r=t;r;r=r.prev)r.prev&&(r.prev.next=r);this._messages.dirty()}clear(){this.messages.clear(),this.head=null,this.root={children:[],next:null},this._messages.dirty()}export(){var t,r,n,i;const e=[];for(const[,s]of this.messages)e.push({message:s.current,parentId:(r=(t=s.prev)==null?void 0:t.current.id)!=null?r:null});return{headId:(i=(n=this.head)==null?void 0:n.current.id)!=null?i:null,messages:e}}import({headId:e,messages:t}){var r,n;for(const{message:i,parentId:s}of t)this.addOrUpdateMessage(s,i);this.resetHead((n=e!=null?e:(r=t.at(-1))==null?void 0:r.message.id)!=null?n:null)}},_r=class{constructor(){T(this,"_subscriptions",new Set);T(this,"_connection")}get isConnected(){return!!this._connection}notifySubscribers(){for(const e of this._subscriptions)e()}_updateConnection(){var e;if(this._subscriptions.size>0){if(this._connection)return;this._connection=this._connect()}else(e=this._connection)==null||e.call(this),this._connection=void 0}subscribe(e){return this._subscriptions.add(e),this._updateConnection(),()=>{this._subscriptions.delete(e),this._updateConnection()}}},Ue=Symbol("skip-update"),yn=class extends _r{constructor(t){super();T(this,"_previousStateDirty",!0);T(this,"_previousState");T(this,"getState",()=>{if(!this.isConnected||this._previousStateDirty){const t=this.binding.getState();t!==Ue&&(this._previousState=t),this._previousStateDirty=!1}if(this._previousState===void 0)throw new Error("Entry not available in the store");return this._previousState});this.binding=t}get path(){return this.binding.path}_connect(){const t=()=>{this._previousStateDirty=!0,this.notifySubscribers()};return this.binding.subscribe(t)}},Tr=class{constructor(e,t){this._core=e,this._threadListBinding=t,this.__internal_bindMethods()}get path(){return this._core.path}__internal_bindMethods(){this.switchTo=this.switchTo.bind(this),this.rename=this.rename.bind(this),this.archive=this.archive.bind(this),this.unarchive=this.unarchive.bind(this),this.delete=this.delete.bind(this),this.initialize=this.initialize.bind(this),this.generateTitle=this.generateTitle.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getState=this.getState.bind(this),this.detach=this.detach.bind(this)}getState(){return this._core.getState()}switchTo(){const e=this._core.getState();return this._threadListBinding.switchToThread(e.id)}rename(e){const t=this._core.getState();return this._threadListBinding.rename(t.id,e)}archive(){const e=this._core.getState();return this._threadListBinding.archive(e.id)}unarchive(){const e=this._core.getState();return this._threadListBinding.unarchive(e.id)}delete(){const e=this._core.getState();return this._threadListBinding.delete(e.id)}initialize(){const e=this._core.getState();return this._threadListBinding.initialize(e.id)}generateTitle(){const e=this._core.getState();return this._threadListBinding.generateTitle(e.id)}unstable_on(e,t){let r=this._core.getState().isMain,n=this._core.getState().id;return this.subscribe(()=>{const i=this._core.getState(),s=i.isMain,a=i.id;r===s&&n===a||(r=s,n=a,!(e==="switched-to"&&!s)&&(e==="switched-away"&&s||t()))})}subscribe(e){return this._core.subscribe(e)}detach(){const e=this._core.getState();this._threadListBinding.detach(e.id)}__internal_getRuntime(){return this}};function $u(e,t){if(e===void 0&&t===void 0)return!0;if(e===void 0||t===void 0)return!1;for(const r of Object.keys(e)){const n=e[r],i=t[r];if(!Object.is(n,i))return!1}return!0}var $e=class extends _r{constructor(t){super();T(this,"_previousState");T(this,"getState",()=>(this.isConnected||this._syncState(),this._previousState));this.binding=t;const r=t.getState();if(r===Ue)throw new Error("Entry not available in the store");this._previousState=r}get path(){return this.binding.path}_syncState(){const t=this.binding.getState();return t===Ue||$u(t,this._previousState)?!1:(this._previousState=t,!0)}_connect(){const t=()=>{this._syncState()&&this.notifySubscribers()};return this.binding.subscribe(t)}},Cr=Symbol("innerMessage"),Ir=e=>e.content.filter(r=>r.type==="text").map(r=>r.text).join(`
12
4
 
13
- `),Ah=class{constructor(t){this._core=t,this.__internal_bindMethods()}get path(){return this._core.path}__internal_bindMethods(){this.getState=this.getState.bind(this),this.remove=this.remove.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this._core.getState()}subscribe(t){return this._core.subscribe(t)}},kh=class extends Ah{constructor(t,n){super(t),this._composerApi=n}remove(){const t=this._composerApi.getState();if(!t)throw new Error("Composer is not available");return t.removeAttachment(this.getState().id)}},h0=class extends kh{get source(){return"thread-composer"}},p0=class extends kh{get source(){return"edit-composer"}},m0=class extends Ah{get source(){return"message"}constructor(t){super(t)}remove(){throw new Error("Message attachments cannot be removed")}},Rh=class extends ts{constructor(t){super(),this.config=t}getState(){return this.config.binding.getState()}outerSubscribe(t){return this.config.binding.subscribe(t)}_connect(){const t=()=>{this.notifySubscribers()};let n=this.config.binding.getState(),a=n==null?void 0:n.unstable_on(this.config.event,t);const i=()=>{var c;const o=this.config.binding.getState();o!==n&&(n=o,a==null||a(),a=(c=this.config.binding.getState())==null?void 0:c.unstable_on(this.config.event,t))},s=this.outerSubscribe(i);return()=>{s==null||s(),a==null||a()}}},Mh=Object.freeze([]),zh=Object.freeze({}),g0=t=>{var n,a,i,s,o,c,d,h,m;return Object.freeze({type:"thread",isEditing:(n=t==null?void 0:t.isEditing)!=null?n:!1,canCancel:(a=t==null?void 0:t.canCancel)!=null?a:!1,isEmpty:(i=t==null?void 0:t.isEmpty)!=null?i:!0,attachments:(s=t==null?void 0:t.attachments)!=null?s:Mh,text:(o=t==null?void 0:t.text)!=null?o:"",role:(c=t==null?void 0:t.role)!=null?c:"user",runConfig:(d=t==null?void 0:t.runConfig)!=null?d:zh,attachmentAccept:(h=t==null?void 0:t.attachmentAccept)!=null?h:"",value:(m=t==null?void 0:t.text)!=null?m:""})},y0=t=>{var n,a,i,s,o,c,d,h,m;return Object.freeze({type:"edit",isEditing:(n=t==null?void 0:t.isEditing)!=null?n:!1,canCancel:(a=t==null?void 0:t.canCancel)!=null?a:!1,isEmpty:(i=t==null?void 0:t.isEmpty)!=null?i:!0,text:(s=t==null?void 0:t.text)!=null?s:"",role:(o=t==null?void 0:t.role)!=null?o:"user",attachments:(c=t==null?void 0:t.attachments)!=null?c:Mh,runConfig:(d=t==null?void 0:t.runConfig)!=null?d:zh,attachmentAccept:(h=t==null?void 0:t.attachmentAccept)!=null?h:"",value:(m=t==null?void 0:t.text)!=null?m:""})},Oh=class{constructor(t){Y(this,"_eventSubscriptionSubjects",new Map);this._core=t}get path(){return this._core.path}__internal_bindMethods(){this.setText=this.setText.bind(this),this.setRunConfig=this.setRunConfig.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.addAttachment=this.addAttachment.bind(this),this.reset=this.reset.bind(this),this.clearAttachments=this.clearAttachments.bind(this),this.send=this.send.bind(this),this.cancel=this.cancel.bind(this),this.setRole=this.setRole.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.unstable_on=this.unstable_on.bind(this)}setText(t){const n=this._core.getState();if(!n)throw new Error("Composer is not available");n.setText(t)}setRunConfig(t){const n=this._core.getState();if(!n)throw new Error("Composer is not available");n.setRunConfig(t)}addAttachment(t){const n=this._core.getState();if(!n)throw new Error("Composer is not available");return n.addAttachment(t)}reset(){const t=this._core.getState();if(!t)throw new Error("Composer is not available");return t.reset()}clearAttachments(){const t=this._core.getState();if(!t)throw new Error("Composer is not available");return t.clearAttachments()}send(){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.send()}cancel(){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.cancel()}setRole(t){const n=this._core.getState();if(!n)throw new Error("Composer is not available");n.setRole(t)}subscribe(t){return this._core.subscribe(t)}unstable_on(t,n){let a=this._eventSubscriptionSubjects.get(t);return a||(a=new Rh({event:t,binding:this._core}),this._eventSubscriptionSubjects.set(t,a)),a.subscribe(n)}},b0=class extends Oh{constructor(n){const a=new ho({path:n.path,getState:()=>g0(n.getState()),subscribe:i=>n.subscribe(i)});super({path:n.path,getState:()=>n.getState(),subscribe:i=>a.subscribe(i)});Y(this,"_getState");this._getState=a.getState.bind(a),this.__internal_bindMethods()}get path(){return this._core.path}get type(){return"thread"}getState(){return this._getState()}getAttachmentByIndex(n){return new h0(new Mn({path:G(_({},this.path),{attachmentSource:"thread-composer",attachmentSelector:{type:"index",index:n},ref:`${this.path.ref}${this.path.ref}.attachments[${n}]`}),getState:()=>{const i=this.getState().attachments[n];return i?G(_({},i),{source:"thread-composer"}):Rn},subscribe:a=>this._core.subscribe(a)}),this._core)}},v0=class extends Oh{constructor(n,a){const i=new ho({path:n.path,getState:()=>y0(n.getState()),subscribe:s=>n.subscribe(s)});super({path:n.path,getState:()=>n.getState(),subscribe:s=>i.subscribe(s)});Y(this,"_getState");this._beginEdit=a,this._getState=i.getState.bind(i),this.__internal_bindMethods()}get path(){return this._core.path}get type(){return"edit"}__internal_bindMethods(){super.__internal_bindMethods(),this.beginEdit=this.beginEdit.bind(this)}getState(){return this._getState()}beginEdit(){this._beginEdit()}getAttachmentByIndex(n){return new p0(new Mn({path:G(_({},this.path),{attachmentSource:"edit-composer",attachmentSelector:{type:"index",index:n},ref:`${this.path.ref}${this.path.ref}.attachments[${n}]`}),getState:()=>{const i=this.getState().attachments[n];return i?G(_({},i),{source:"edit-composer"}):Rn},subscribe:a=>this._core.subscribe(a)}),this._core)}},x0=class $u{constructor(n=null){Y(this,"_state");this._state=n}get state(){return this._state}append(n){this._state=n.reduce((a,i)=>$u.apply(a,i),this._state)}static apply(n,a){const i=a.type;switch(i){case"set":return $u.updatePath(n,a.path,()=>a.value);case"append-text":return $u.updatePath(n,a.path,s=>{if(typeof s!="string")throw new Error(`Expected string at path [${a.path.join(", ")}]`);return s+a.value});default:{const s=i;throw new Error(`Invalid operation type: ${s}`)}}}static updatePath(n,a,i){if(a.length===0)return i(n);if(n!=null||(n={}),typeof n!="object")throw new Error(`Invalid path: [${a.join(", ")}]`);const[s,...o]=a;if(Array.isArray(n)){const d=Number(s);if(isNaN(d))throw new Error(`Expected array index at [${a.join(", ")}]`);if(d>n.length||d<0)throw new Error("Insert array index out of bounds");const h=[...n];return h[d]=this.updatePath(h[d],o,i),h}const c=_({},n);return c[s]=this.updatePath(c[s],o,i),c}},S0=({unstable_state:t=null}={})=>({role:"assistant",status:{type:"running"},parts:[],get content(){return this.parts},metadata:{unstable_state:t,unstable_data:[],unstable_annotations:[],steps:[],custom:{}}}),as=(t,n,a)=>{if(t.parts.length===0)throw new Error("No parts available to update.");if(n.path.length!==1)throw new Error("Nested paths are not supported yet.");const i=n.path[0],s=a(t.parts[i]);return G(_({},t),{parts:[...t.parts.slice(0,i),s,...t.parts.slice(i+1)],get content(){return this.parts}})},w0=(t,n)=>{const a=n.part;if(a.type==="text"||a.type==="reasoning"){const i=_({type:a.type,text:"",status:{type:"running"}},a.parentId&&{parentId:a.parentId});return G(_({},t),{parts:[...t.parts,i],get content(){return this.parts}})}else if(a.type==="tool-call"){const i=_({type:"tool-call",state:"partial-call",status:{type:"running",isArgsComplete:!1},toolCallId:a.toolCallId,toolName:a.toolName,argsText:"",args:{}},a.parentId&&{parentId:a.parentId});return G(_({},t),{parts:[...t.parts,i],get content(){return this.parts}})}else if(a.type==="source"){const i=_(_({type:"source",sourceType:a.sourceType,id:a.id,url:a.url},a.title?{title:a.title}:void 0),a.parentId&&{parentId:a.parentId});return G(_({},t),{parts:[...t.parts,i],get content(){return this.parts}})}else if(a.type==="file"){const i={type:"file",mimeType:a.mimeType,data:a.data};return G(_({},t),{parts:[...t.parts,i],get content(){return this.parts}})}else throw new Error(`Unsupported part type: ${a.type}`)},_0=(t,n)=>as(t,n,a=>{if(a.type!=="tool-call")throw new Error("Last is not a tool call");return a.state!=="partial-call"?a:G(_({},a),{state:"call"})}),T0=(t,n)=>as(t,n,a=>G(_({},a),{status:{type:"complete",reason:"unknown"}})),E0=(t,n)=>as(t,n,a=>{var i;if(a.type==="text"||a.type==="reasoning")return G(_({},a),{text:a.text+n.textDelta});if(a.type==="tool-call"){const s=a.argsText+n.textDelta,o=(i=$l(s))!=null?i:a.args;return G(_({},a),{argsText:s,args:o})}else throw new Error("text-delta received but part is neither text nor tool-call")}),C0=(t,n)=>as(t,n,a=>{var i;if(a.type==="tool-call")return G(_(G(_({},a),{state:"result"}),n.artifact!==void 0?{artifact:n.artifact}:{}),{result:n.result,isError:(i=n.isError)!=null?i:!1,status:{type:"complete",reason:"stop"}});throw new Error("Result chunk received but part is not a tool-call")}),Dh=(t,n)=>{var i,s;if(((i=t.status)==null?void 0:i.type)==="incomplete"&&((s=t.status)==null?void 0:s.reason)==="error")return t;const a=A0(n);return G(_({},t),{status:a})},A0=t=>t.finishReason==="tool-calls"?{type:"requires-action",reason:"tool-calls"}:t.finishReason==="stop"||t.finishReason==="unknown"?{type:"complete",reason:t.finishReason}:{type:"incomplete",reason:t.finishReason},k0=(t,n)=>G(_({},t),{metadata:G(_({},t.metadata),{unstable_annotations:[...t.metadata.unstable_annotations,...n.annotations]})}),R0=(t,n)=>G(_({},t),{metadata:G(_({},t.metadata),{unstable_data:[...t.metadata.unstable_data,...n.data]})}),M0=(t,n)=>G(_({},t),{metadata:G(_({},t.metadata),{steps:[...t.metadata.steps,{state:"started",messageId:n.messageId}]})}),z0=(t,n)=>{var s;const a=t.metadata.steps.slice(),i=a.length-1;return a.length>0&&((s=a[i])==null?void 0:s.state)==="started"?a[i]=G(_({},a[i]),{state:"finished",finishReason:n.finishReason,usage:n.usage,isContinued:n.isContinued}):a.push({state:"finished",messageId:Th(),finishReason:n.finishReason,usage:n.usage,isContinued:n.isContinued}),G(_({},t),{metadata:G(_({},t.metadata),{steps:a})})},O0=(t,n)=>G(_({},t),{status:{type:"incomplete",reason:"error",error:n.error}}),D0=(t,n)=>{const a=new x0(t.metadata.unstable_state);return a.append(n.operations),G(_({},t),{metadata:G(_({},t.metadata),{unstable_state:a.state})})},N0=t=>{let n=!1;return()=>{n||(n=!0,queueMicrotask(()=>{n=!1,t()}))}},I0=class extends TransformStream{constructor({initialMessage:t,throttle:n,onError:a}={}){let i=t!=null?t:S0(),s;const o=n?N0(()=>{s==null||s.enqueue(i)}):()=>{s==null||s.enqueue(i)};super({start(c){s=c},transform(c){const d=c.type;switch(d){case"part-start":i=w0(i,c);break;case"tool-call-args-text-finish":i=_0(i,c);break;case"part-finish":i=T0(i,c);break;case"text-delta":i=E0(i,c);break;case"result":i=C0(i,c);break;case"message-finish":i=Dh(i,c);break;case"annotations":i=k0(i,c);break;case"data":i=R0(i,c);break;case"step-start":i=M0(i,c);break;case"step-finish":i=z0(i,c);break;case"error":i=O0(i,c),a==null||a(c.error);break;case"update-state":i=D0(i,c);break;default:{const h=d;throw new Error(`Unsupported chunk type: ${h}`)}}o()},flush(c){var d,h,m;if(((d=i.status)==null?void 0:d.type)==="running"){const y=(m=(h=i.parts)==null?void 0:h.some(g=>g.type==="tool-call"&&(g.state==="call"||g.state==="partial-call")&&g.result===void 0))!=null?m:!1;i=Dh(i,{finishReason:y?"tool-calls":"unknown"}),c.enqueue(i)}}})}},j0=class extends wh{constructor(){super(t=>{const n=new c0({transform(a,i){i.appendText(a)}});return t.pipeThrough(new TextDecoderStream).pipeThrough(n)})}},L0=class Wu{constructor(n){this.readable=n,this.readable=n}static fromAssistantStream(n){return new Wu(n.pipeThrough(new I0))}unstable_result(){return W(this,null,function*(){let n;try{for(var a=xa(this),i,s,o;i=!(s=yield a.next()).done;i=!1){const c=s.value;n=c}}catch(s){o=[s]}finally{try{i&&(s=a.return)&&(yield s.call(a))}finally{if(o)throw o[0]}}return n||{role:"assistant",status:{type:"complete",reason:"unknown"},parts:[],content:[],metadata:{unstable_state:null,unstable_data:[],unstable_annotations:[],steps:[],custom:{}}}})}[Symbol.asyncIterator](){const n=this.readable.getReader();return{next(){return W(this,null,function*(){const{done:i,value:s}=yield n.read();return i?{done:!0,value:void 0}:{done:!1,value:s}})}}}tee(){const[n,a]=this.readable.tee();return[new Wu(n),new Wu(a)]}},Nh=Symbol.for("aui.tool-response"),_a=class $d{constructor(n){Y(this,"artifact");Y(this,"result");Y(this,"isError");var a;n.artifact!==void 0&&(this.artifact=n.artifact),this.result=n.result,this.isError=(a=n.isError)!=null?a:!1}get[Nh](){return!0}static[Symbol.hasInstance](n){return typeof n=="object"&&n!==null&&Nh in n}static toResponse(n){return n instanceof $d?n:new $d({result:n===void 0?"<no result>":n})}};function B0(t,n,a){try{const i=t();if(typeof i=="object"&&i!==null&&"then"in i)return i.then(n,a);n(i)}catch(i){a(i)}}function Ni(t,n){let a=t;for(const i of n){if(a==null)return;a=a[i]}return a}var U0=class{constructor(t,n,a){Y(this,"resolve");Y(this,"reject");Y(this,"disposed",!1);Y(this,"fieldPath");this.resolve=t,this.reject=n,this.fieldPath=a}update(t){if(!this.disposed)try{if(wa(t,this.fieldPath)==="complete"){const n=Ni(t,this.fieldPath);n!==void 0&&(this.resolve(n),this.dispose())}}catch(n){this.reject(n),this.dispose()}}dispose(){this.disposed=!0}},Ih=class{constructor(t,n){Y(this,"controller");Y(this,"disposed",!1);Y(this,"fieldPath");this.controller=t,this.fieldPath=n}update(t){if(!this.disposed)try{const n=Ni(t,this.fieldPath);n!==void 0&&this.controller.enqueue(n),wa(t,this.fieldPath)==="complete"&&(this.controller.close(),this.dispose())}catch(n){this.controller.error(n),this.dispose()}}dispose(){this.disposed=!0}},jh=class{constructor(t,n){Y(this,"controller");Y(this,"disposed",!1);Y(this,"fieldPath");Y(this,"lastValue");this.controller=t,this.fieldPath=n}update(t){var n;if(!this.disposed)try{const a=Ni(t,this.fieldPath);if(a!==void 0&&typeof a=="string"){const i=a.substring(((n=this.lastValue)==null?void 0:n.length)||0);this.lastValue=a,this.controller.enqueue(i)}wa(t,this.fieldPath)==="complete"&&(this.controller.close(),this.dispose())}catch(a){this.controller.error(a),this.dispose()}}dispose(){this.disposed=!0}},Lh=class{constructor(t,n){Y(this,"controller");Y(this,"disposed",!1);Y(this,"fieldPath");Y(this,"processedIndexes",new Set);this.controller=t,this.fieldPath=n}update(t){if(!this.disposed)try{const n=Ni(t,this.fieldPath);if(!Array.isArray(n))return;for(let a=0;a<n.length;a++)if(!this.processedIndexes.has(a)){const i=[...this.fieldPath,a];wa(t,i)==="complete"&&(this.controller.enqueue(n[a]),this.processedIndexes.add(a))}wa(t,this.fieldPath)==="complete"&&(this.controller.close(),this.dispose())}catch(n){this.controller.error(n),this.dispose()}}dispose(){this.disposed=!0}},H0=class{constructor(t){Y(this,"argTextDeltas");Y(this,"handles",new Set);Y(this,"args",$l(""));this.argTextDeltas=t,this.processStream()}processStream(){return W(this,null,function*(){try{let t="";const n=this.argTextDeltas.getReader();for(;;){const{value:a,done:i}=yield n.read();if(i)break;t+=a;const s=$l(t);if(s!==void 0){this.args=s;for(const o of this.handles)o.update(s)}}}catch(t){console.error("Error processing argument stream:",t);for(const n of this.handles)n.dispose()}})}get(...t){return new Promise((n,a)=>{const i=new U0(n,a,t);if(this.args&&wa(this.args,t)==="complete"){const s=Ni(this.args,t);if(s!==void 0){n(s);return}}this.handles.add(i),i.update(this.args)})}streamValues(...t){const n=t,a=new ReadableStream({start:i=>{const s=new Ih(i,n);this.handles.add(s),s.update(this.args)},cancel:()=>{for(const i of this.handles)if(i instanceof Ih){i.dispose(),this.handles.delete(i);break}}});return uo(a)}streamText(...t){const n=t,a=new ReadableStream({start:i=>{const s=new jh(i,n);this.handles.add(s),s.update(this.args)},cancel:()=>{for(const i of this.handles)if(i instanceof jh){i.dispose(),this.handles.delete(i);break}}});return uo(a)}forEach(...t){const n=t,a=new ReadableStream({start:i=>{const s=new Lh(i,n);this.handles.add(s),s.update(this.args)},cancel:()=>{for(const i of this.handles)if(i instanceof Lh){i.dispose(),this.handles.delete(i);break}}});return uo(a)}},q0=class{constructor(t){this.promise=t}get(){return this.promise}},V0=class{constructor(){Y(this,"args");Y(this,"response");Y(this,"writable");Y(this,"resolve");Y(this,"argsText","");Y(this,"result",{get:()=>W(this,null,function*(){return(yield this.response.get()).result})});const t=new TransformStream;this.writable=t.writable,this.args=new H0(t.readable);const{promise:n,resolve:a}=co();this.resolve=a,this.response=new q0(n)}appendArgsTextDelta(t){return W(this,null,function*(){const n=this.writable.getWriter();try{yield n.write(t)}catch(a){console.warn(a)}finally{n.releaseLock()}this.argsText+=t})}setResponse(t){this.resolve(t)}},Y0=class extends wh{constructor(t){const n=new Map,a=new Map;super(i=>{const s=new TransformStream({transform(c,d){switch((c.type!=="part-finish"||c.meta.type!=="tool-call")&&d.enqueue(c),c.type){case"part-start":if(c.part.type==="tool-call"){const m=new V0;a.set(c.part.toolCallId,m),t.streamCall({reader:m,toolCallId:c.part.toolCallId,toolName:c.part.toolName})}break;case"text-delta":{if(c.meta.type==="tool-call"){const m=c.meta.toolCallId,y=a.get(m);if(!y)throw new Error("No controller found for tool call");y.appendArgsTextDelta(c.textDelta)}break}case"result":{if(c.meta.type!=="tool-call")break;const{toolCallId:m}=c.meta,y=a.get(m);if(!y)throw new Error("No controller found for tool call");y.setResponse(new _a({result:c.result,artifact:c.artifact,isError:c.isError}));break}case"tool-call-args-text-finish":{if(c.meta.type!=="tool-call")break;const{toolCallId:m,toolName:y}=c.meta,g=a.get(m);if(!g)throw new Error("No controller found for tool call");const v=B0(()=>{let x;try{x=so.parse(g.argsText)}catch(w){throw new Error(`Function parameter parsing failed. ${JSON.stringify(w.message)}`)}return t.execute({toolCallId:m,toolName:y,args:x})},x=>{if(x===void 0)return;const w=new _a({artifact:x.artifact,result:x.result,isError:x.isError});g.setResponse(w),d.enqueue(_({type:"result",path:c.path},w))},x=>{const w=new _a({result:String(x),isError:!0});g.setResponse(w),d.enqueue(_({type:"result",path:c.path},w))});v&&n.set(m,v);break}case"part-finish":{if(c.meta.type!=="tool-call")break;const{toolCallId:m}=c.meta,y=n.get(m);y?y.then(()=>{n.delete(m),a.delete(m),d.enqueue(c)}):d.enqueue(c)}}},flush(){return W(this,null,function*(){yield Promise.all(n.values())})}});return i.pipeThrough(new _h).pipeThrough(s)})}},F0=t=>typeof t=="object"&&t!==null&&"~standard"in t&&t["~standard"].version===1;function G0(t,n,a,i){const s=t==null?void 0:t[a.toolName];return!s||!s.execute?void 0:(c=>W(null,null,function*(){var m;let d=c;if(F0(s.parameters)){let y=s.parameters["~standard"].validate(a.args);y instanceof Promise&&(y=yield y),y.issues&&(d=(m=s.experimental_onSchemaValidationError)!=null?m:(()=>{throw new Error(`Function parameter validation failed. ${JSON.stringify(y.issues)}`)}))}const h=yield d(a.args,{toolCallId:a.toolCallId,abortSignal:n,human:y=>i(a.toolCallId,y)});return _a.toResponse(h)}))(s.execute)}function P0(t,n,a,i,s){var o,c;(c=(o=t==null?void 0:t[i.toolName])==null?void 0:o.streamCall)==null||c.call(o,a,{toolCallId:i.toolCallId,abortSignal:n,human:d=>s(i.toolCallId,d)})}function X0(t,n,a){const i=typeof t=="function"?t:()=>t,s=typeof n=="function"?n:()=>n;return new Y0({execute:o=>G0(i(),s(),o,a),streamCall:d=>{var h=d,{reader:o}=h,c=gt(h,["reader"]);return P0(i(),s(),o,c,a)}})}var Bh=class{constructor(t,n,a){this.contentBinding=t,this.messageApi=n,this.threadApi=a,this.__internal_bindMethods()}get path(){return this.contentBinding.path}__internal_bindMethods(){this.addToolResult=this.addToolResult.bind(this),this.resumeToolCall=this.resumeToolCall.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this.contentBinding.getState()}addToolResult(t){const n=this.contentBinding.getState();if(!n)throw new Error("Message part is not available");if(n.type!=="tool-call")throw new Error("Tried to add tool result to non-tool message part");if(!this.messageApi)throw new Error("Message API is not available. This is likely a bug in assistant-ui.");if(!this.threadApi)throw new Error("Thread API is not available");const a=this.messageApi.getState();if(!a)throw new Error("Message is not available");const i=n.toolName,s=n.toolCallId,o=_a.toResponse(t);this.threadApi.getState().addToolResult({messageId:a.id,toolName:i,toolCallId:s,result:o.result,artifact:o.artifact,isError:o.isError})}resumeToolCall(t){const n=this.contentBinding.getState();if(!n)throw new Error("Message part is not available");if(n.type!=="tool-call")throw new Error("Tried to resume tool call on non-tool message part");if(!this.threadApi)throw new Error("Thread API is not available");const a=n.toolCallId;this.threadApi.getState().resumeToolCall({toolCallId:a,payload:t})}subscribe(t){return this.contentBinding.subscribe(t)}},is=class extends ts{constructor(t){super(),this.binding=t}get path(){return this.binding.path}getState(){return this.binding.getState()}outerSubscribe(t){return this.binding.subscribe(t)}_connect(){const t=()=>{this.notifySubscribers()};let n=this.binding.getState(),a=n==null?void 0:n.subscribe(t);const i=()=>{var c;const o=this.binding.getState();o!==n&&(n=o,a==null||a(),a=(c=this.binding.getState())==null?void 0:c.subscribe(t),t())},s=this.outerSubscribe(i);return()=>{s==null||s(),a==null||a()}}},ls=Object.freeze({type:"complete"}),Q0=(t,n,a)=>{if(t.role!=="assistant")return ls;if(a.type==="tool-call")return a.result?ls:t.status;const i=n===Math.max(0,t.content.length-1);return t.status.type==="requires-action"?ls:i?t.status:ls},Uh=(t,n)=>{const a=t.content[n];if(!a)return Rn;const i=Q0(t,n,a);return Object.freeze(G(_({},a),{[ns]:a[ns],status:i}))},Z0=class{constructor(t,n){Y(this,"composer");Y(this,"_getEditComposerRuntimeCore",()=>this._threadBinding.getState().getEditComposer(this._core.getState().id));this._core=t,this._threadBinding=n,this.composer=new v0(new is({path:G(_({},this.path),{ref:`${this.path.ref}${this.path.ref}.composer`,composerSource:"edit"}),getState:this._getEditComposerRuntimeCore,subscribe:a=>this._threadBinding.subscribe(a)}),()=>this._threadBinding.getState().beginEdit(this._core.getState().id)),this.__internal_bindMethods()}get path(){return this._core.path}__internal_bindMethods(){this.reload=this.reload.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getMessagePartByIndex=this.getMessagePartByIndex.bind(this),this.getMessagePartByToolCallId=this.getMessagePartByToolCallId.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.unstable_getCopyText=this.unstable_getCopyText.bind(this),this.speak=this.speak.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.submitFeedback=this.submitFeedback.bind(this),this.switchToBranch=this.switchToBranch.bind(this)}getState(){return this._core.getState()}reload(t={}){const n=this._getEditComposerRuntimeCore(),a=n!=null?n:this._threadBinding.getState().composer,i=n!=null?n:a,{runConfig:s=i.runConfig}=t,o=this._core.getState();if(o.role!=="assistant")throw new Error("Can only reload assistant messages");this._threadBinding.getState().startRun({parentId:o.parentId,sourceId:o.id,runConfig:s})}speak(){const t=this._core.getState();return this._threadBinding.getState().speak(t.id)}stopSpeaking(){var a;const t=this._core.getState();if(((a=this._threadBinding.getState().speech)==null?void 0:a.messageId)===t.id)this._threadBinding.getState().stopSpeaking();else throw new Error("Message is not being spoken")}submitFeedback({type:t}){const n=this._core.getState();this._threadBinding.getState().submitFeedback({messageId:n.id,type:t})}switchToBranch({position:t,branchId:n}){const a=this._core.getState();if(n&&t)throw new Error("May not specify both branchId and position");if(!n&&!t)throw new Error("Must specify either branchId or position");const s=this._threadBinding.getState().getBranches(a.id);let o=n;if(t==="previous"?o=s[a.branchNumber-2]:t==="next"&&(o=s[a.branchNumber]),!o)throw new Error("Branch not found");this._threadBinding.getState().switchToBranch(o)}unstable_getCopyText(){return rs(this.getState())}subscribe(t){return this._core.subscribe(t)}getMessagePartByIndex(t){if(t<0)throw new Error("Message part index must be >= 0");return new Bh(new Mn({path:G(_({},this.path),{ref:`${this.path.ref}${this.path.ref}.content[${t}]`,messagePartSelector:{type:"index",index:t}}),getState:()=>Uh(this.getState(),t),subscribe:n=>this._core.subscribe(n)}),this._core,this._threadBinding)}getMessagePartByToolCallId(t){return new Bh(new Mn({path:G(_({},this.path),{ref:this.path.ref+`${this.path.ref}.content[toolCallId=${JSON.stringify(t)}]`,messagePartSelector:{type:"toolCallId",toolCallId:t}}),getState:()=>{const n=this._core.getState(),a=n.content.findIndex(i=>i.type==="tool-call"&&i.toolCallId===t);return a===-1?Rn:Uh(n,a)},subscribe:n=>this._core.subscribe(n)}),this._core,this._threadBinding)}getAttachmentByIndex(t){return new m0(new Mn({path:G(_({},this.path),{ref:`${this.path.ref}${this.path.ref}.attachments[${t}]`,attachmentSource:"message",attachmentSelector:{type:"index",index:t}}),getState:()=>{const n=this.getState().attachments,a=n==null?void 0:n[t];return a?G(_({},a),{source:"message"}):Rn},subscribe:n=>this._core.subscribe(n)}))}},K0=t=>{var n,a,i;return _({parentId:(n=t.parentId)!=null?n:null,sourceId:(a=t.sourceId)!=null?a:null,runConfig:(i=t.runConfig)!=null?i:{}},t.stream?{stream:t.stream}:{})},J0=t=>{var n,a,i;return{parentId:(n=t.parentId)!=null?n:null,sourceId:(a=t.sourceId)!=null?a:null,runConfig:(i=t.runConfig)!=null?i:{}}},$0=(t,n)=>{var a,i,s,o,c,d,h,m,y,g,v;return typeof n=="string"?{createdAt:new Date,parentId:(i=(a=t.at(-1))==null?void 0:a.id)!=null?i:null,sourceId:null,runConfig:{},role:"user",content:[{type:"text",text:n}],attachments:[],metadata:{custom:{}}}:{createdAt:(s=n.createdAt)!=null?s:new Date,parentId:(d=(c=n.parentId)!=null?c:(o=t.at(-1))==null?void 0:o.id)!=null?d:null,sourceId:(h=n.sourceId)!=null?h:null,role:(m=n.role)!=null?m:"user",content:n.content,attachments:(y=n.attachments)!=null?y:[],metadata:(g=n.metadata)!=null?g:{custom:{}},runConfig:(v=n.runConfig)!=null?v:{},startRun:n.startRun}},W0=(t,n)=>{const a=t.messages.at(-1);return Object.freeze({threadId:n.id,metadata:n,capabilities:t.capabilities,isDisabled:t.isDisabled,isLoading:t.isLoading,isRunning:(a==null?void 0:a.role)!=="assistant"?!1:a.status.type==="running",messages:t.messages,state:t.state,suggestions:t.suggestions,extras:t.extras,speech:t.speech})},Hh=class{constructor(t,n){Y(this,"_threadBinding");Y(this,"composer");Y(this,"_eventSubscriptionSubjects",new Map);const a=new Mn({path:t.path,getState:()=>W0(t.getState(),n.getState()),subscribe:i=>{const s=t.subscribe(i),o=n.subscribe(i);return()=>{s(),o()}}});this._threadBinding={path:t.path,getState:()=>t.getState(),getStateState:()=>a.getState(),outerSubscribe:i=>t.outerSubscribe(i),subscribe:i=>t.subscribe(i)},this.composer=new b0(new is({path:G(_({},this.path),{ref:`${this.path.ref}${this.path.ref}.composer`,composerSource:"thread"}),getState:()=>this._threadBinding.getState().composer,subscribe:i=>this._threadBinding.subscribe(i)})),this.__internal_bindMethods()}get path(){return this._threadBinding.path}get __internal_threadBinding(){return this._threadBinding}__internal_bindMethods(){this.append=this.append.bind(this),this.unstable_resumeRun=this.unstable_resumeRun.bind(this),this.unstable_loadExternalState=this.unstable_loadExternalState.bind(this),this.startRun=this.startRun.bind(this),this.cancelRun=this.cancelRun.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.export=this.export.bind(this),this.import=this.import.bind(this),this.reset=this.reset.bind(this),this.getMessageByIndex=this.getMessageByIndex.bind(this),this.getMessageById=this.getMessageById.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getModelContext=this.getModelContext.bind(this),this.getModelConfig=this.getModelConfig.bind(this),this.getState=this.getState.bind(this)}getState(){return this._threadBinding.getStateState()}append(t){this._threadBinding.getState().append($0(this._threadBinding.getState().messages,t))}subscribe(t){return this._threadBinding.subscribe(t)}getModelContext(){return this._threadBinding.getState().getModelContext()}getModelConfig(){return this.getModelContext()}startRun(t){const n=t===null||typeof t=="string"?{parentId:t}:t;return this._threadBinding.getState().startRun(J0(n))}unstable_resumeRun(t){return this._threadBinding.getState().resumeRun(K0(t))}unstable_loadExternalState(t){this._threadBinding.getState().unstable_loadExternalState(t)}cancelRun(){this._threadBinding.getState().cancelRun()}stopSpeaking(){return this._threadBinding.getState().stopSpeaking()}export(){return this._threadBinding.getState().export()}import(t){this._threadBinding.getState().import(t)}reset(t){this._threadBinding.getState().reset(t)}getMessageByIndex(t){if(t<0)throw new Error("Message index must be >= 0");return this._getMessageRuntime(G(_({},this.path),{ref:`${this.path.ref}${this.path.ref}.messages[${t}]`,messageSelector:{type:"index",index:t}}),()=>{var i,s;const n=this._threadBinding.getState().messages,a=n[t];if(a)return{message:a,parentId:(s=(i=n[t-1])==null?void 0:i.id)!=null?s:null,index:t}})}getMessageById(t){return this._getMessageRuntime(G(_({},this.path),{ref:this.path.ref+`${this.path.ref}.messages[messageId=${JSON.stringify(t)}]`,messageSelector:{type:"messageId",messageId:t}}),()=>this._threadBinding.getState().getMessageById(t))}_getMessageRuntime(t,n){return new Z0(new Mn({path:t,getState:()=>{var y,g;const{message:a,parentId:i,index:s}=(y=n())!=null?y:{},{messages:o,speech:c}=this._threadBinding.getState();if(!a||i===void 0||s===void 0)return Rn;const h=this._threadBinding.getState().getBranches(a.id),m=a.metadata.submittedFeedback;return G(_({},a),{[ns]:a[ns],index:s,isLast:((g=o.at(-1))==null?void 0:g.id)===a.id,parentId:i,branchNumber:h.indexOf(a.id)+1,branchCount:h.length,speech:(c==null?void 0:c.messageId)===a.id?c:void 0,submittedFeedback:m})},subscribe:a=>this._threadBinding.subscribe(a)}),this._threadBinding)}unstable_on(t,n){let a=this._eventSubscriptionSubjects.get(t);return a||(a=new Rh({event:t,binding:this._threadBinding}),this._eventSubscriptionSubjects.set(t,a)),a.subscribe(n)}},t1=t=>({mainThreadId:t.mainThreadId,newThread:t.newThreadId,threads:t.threadIds,archivedThreads:t.archivedThreadIds,isLoading:t.isLoading,threadItems:t.threadData}),ss=(t,n)=>{if(n===void 0)return Rn;const a=t.getItemById(n);return a?{id:a.id,threadId:a.id,remoteId:a.remoteId,externalId:a.externalId,title:a.title,status:a.status,isMain:a.id===t.mainThreadId}:Rn},e1=class{constructor(t,n=Hh){Y(this,"_getState");Y(this,"_mainThreadListItemRuntime");Y(this,"main");this._core=t,this._runtimeFactory=n;const a=new ho({path:{},getState:()=>t1(t),subscribe:i=>t.subscribe(i)});this._getState=a.getState.bind(a),this._mainThreadListItemRuntime=new es(new Mn({path:{ref:"threadItems[main]",threadSelector:{type:"main"}},getState:()=>ss(this._core,this._core.mainThreadId),subscribe:i=>this._core.subscribe(i)}),this._core),this.main=new n(new is({path:{ref:"threads.main",threadSelector:{type:"main"}},getState:()=>t.getMainThreadRuntimeCore(),subscribe:i=>t.subscribe(i)}),this._mainThreadListItemRuntime),this.__internal_bindMethods()}__internal_bindMethods(){this.switchToThread=this.switchToThread.bind(this),this.switchToNewThread=this.switchToNewThread.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getById=this.getById.bind(this),this.getItemById=this.getItemById.bind(this),this.getItemByIndex=this.getItemByIndex.bind(this),this.getArchivedItemByIndex=this.getArchivedItemByIndex.bind(this)}switchToThread(t){return this._core.switchToThread(t)}switchToNewThread(){return this._core.switchToNewThread()}getState(){return this._getState()}subscribe(t){return this._core.subscribe(t)}get mainItem(){return this._mainThreadListItemRuntime}getById(t){return new this._runtimeFactory(new is({path:{ref:`threads[threadId=${JSON.stringify(t)}]`,threadSelector:{type:"threadId",threadId:t}},getState:()=>this._core.getThreadRuntimeCore(t),subscribe:n=>this._core.subscribe(n)}),this.mainItem)}getItemByIndex(t){return new es(new Mn({path:{ref:`threadItems[${t}]`,threadSelector:{type:"index",index:t}},getState:()=>ss(this._core,this._core.threadIds[t]),subscribe:n=>this._core.subscribe(n)}),this._core)}getArchivedItemByIndex(t){return new es(new Mn({path:{ref:`archivedThreadItems[${t}]`,threadSelector:{type:"archiveIndex",index:t}},getState:()=>ss(this._core,this._core.archivedThreadIds[t]),subscribe:n=>this._core.subscribe(n)}),this._core)}getItemById(t){return new es(new Mn({path:{ref:`threadItems[threadId=${t}]`,threadSelector:{type:"threadId",threadId:t}},getState:()=>ss(this._core,t),subscribe:n=>this._core.subscribe(n)}),this._core)}},n1=t=>t.startsWith("image/")?"image":t.startsWith("text/")?"document":"file",r1=class{constructor(t){Y(this,"accept","*");Y(this,"uploadedUrls",new Map);this.cloud=t}add(n){return Kl(this,arguments,function*({file:t}){const a=crypto.randomUUID(),i=n1(t.type);let s={id:a,type:i,name:t.name,contentType:t.type,file:t,status:{type:"running",reason:"uploading",progress:0}};yield s;try{const{signedUrl:o,publicUrl:c}=yield new gr(this.cloud.files.generatePresignedUploadUrl({filename:t.name}));yield new gr(fetch(o,{method:"PUT",body:t,headers:{"Content-Type":t.type},mode:"cors"})),this.uploadedUrls.set(a,c),s=G(_({},s),{status:{type:"requires-action",reason:"composer-send"}}),yield s}catch(o){s=G(_({},s),{status:{type:"incomplete",reason:"error"}}),yield s}})}remove(t){return W(this,null,function*(){this.uploadedUrls.delete(t.id)})}send(t){return W(this,null,function*(){const n=this.uploadedUrls.get(t.id);if(!n)throw new Error("Attachment not uploaded");this.uploadedUrls.delete(t.id);let a;return t.type==="image"?a=[{type:"image",image:n,filename:t.name}]:a=[{type:"file",data:n,mimeType:t.contentType,filename:t.name}],G(_({},t),{status:{type:"complete"},content:a})})}},po=R.createContext(null),mo=({adapters:t,children:n})=>{const a=R.useContext(po);return E.jsx(po.Provider,{value:_(_({},a),t),children:n})},a1=()=>R.useContext(po),i1=class extends fh{constructor(n,a,{parentId:i,message:s}){var o;super();Y(this,"_nonTextParts");Y(this,"_previousText");Y(this,"_parentId");Y(this,"_sourceId");this.runtime=n,this.endEditCallback=a,this._parentId=i,this._sourceId=s.id,this._previousText=rs(s),this.setText(this._previousText),this.setRole(s.role),this.setAttachments((o=s.attachments)!=null?o:[]),this._nonTextParts=s.content.filter(c=>c.type!=="text"),this.setRunConfig(_({},n.composer.runConfig))}get canCancel(){return!0}getAttachmentAdapter(){var n;return(n=this.runtime.adapters)==null?void 0:n.attachments}handleSend(n){return W(this,null,function*(){rs(n)!==this._previousText&&this.runtime.append(G(_({},n),{content:[...n.content,...this._nonTextParts],parentId:this._parentId,sourceId:this._sourceId})),this.handleCancel()})}handleCancel(){this.endEditCallback(),this._notifySubscribers()}},l1=class{constructor(t){Y(this,"_subscriptions",new Set);Y(this,"_isInitialized",!1);Y(this,"repository",new Ch);Y(this,"composer",new dh(this));Y(this,"_editComposers",new Map);Y(this,"_stopSpeaking");Y(this,"speech");Y(this,"_eventSubscribers",new Map);this._contextProvider=t}get messages(){return this.repository.getMessages()}get state(){var n;let t;for(const a of this.messages)if(a.role==="assistant"){t=a;break}return(n=t==null?void 0:t.metadata.unstable_state)!=null?n:null}getModelContext(){return this._contextProvider.getModelContext()}getEditComposer(t){return this._editComposers.get(t)}beginEdit(t){if(this._editComposers.has(t))throw new Error("Edit already in progress");this._editComposers.set(t,new i1(this,()=>this._editComposers.delete(t),this.repository.getMessage(t))),this._notifySubscribers()}getMessageById(t){try{return this.repository.getMessage(t)}catch(n){return}}getBranches(t){return this.repository.getBranches(t)}switchToBranch(t){this.repository.switchToBranch(t),this._notifySubscribers()}_notifySubscribers(){for(const t of this._subscriptions)t()}_notifyEventSubscribers(t){const n=this._eventSubscribers.get(t);if(n)for(const a of n)a()}subscribe(t){return this._subscriptions.add(t),()=>this._subscriptions.delete(t)}submitFeedback({messageId:t,type:n}){var o;const a=(o=this.adapters)==null?void 0:o.feedback;if(!a)throw new Error("Feedback adapter not configured");const{message:i,parentId:s}=this.repository.getMessage(t);if(a.submit({message:i,type:n}),i.role==="assistant"){const c=G(_({},i),{metadata:G(_({},i.metadata),{submittedFeedback:{type:n}})});this.repository.addOrUpdateMessage(s,c)}this._notifySubscribers()}speak(t){var o,c;const n=(o=this.adapters)==null?void 0:o.speech;if(!n)throw new Error("Speech adapter not configured");const{message:a}=this.repository.getMessage(t);(c=this._stopSpeaking)==null||c.call(this);const i=n.speak(rs(a)),s=i.subscribe(()=>{i.status.type==="ended"?(this._stopSpeaking=void 0,this.speech=void 0):this.speech={messageId:t,status:i.status},this._notifySubscribers()});this.speech={messageId:t,status:i.status},this._notifySubscribers(),this._stopSpeaking=()=>{i.cancel(),s(),this.speech=void 0,this._stopSpeaking=void 0}}stopSpeaking(){if(!this._stopSpeaking)throw new Error("No message is being spoken");this._stopSpeaking(),this._notifySubscribers()}ensureInitialized(){this._isInitialized||(this._isInitialized=!0,this._notifyEventSubscribers("initialize"))}export(){return this.repository.export()}import(t){this.ensureInitialized(),this.repository.clear(),this.repository.import(t),this._notifySubscribers()}reset(t){this.import(fo.fromArray(t!=null?t:[]))}unstable_on(t,n){var i,s,o;if(t==="model-context-update")return(o=(s=(i=this._contextProvider).subscribe)==null?void 0:s.call(i,n))!=null?o:(()=>{});const a=this._eventSubscribers.get(t);return a?a.add(n):this._eventSubscribers.set(t,new Set([n])),()=>{this._eventSubscribers.get(t).delete(n)}}},s1=t=>{try{return JSON.parse(t),!0}catch(n){return!1}};function u1({state:t,getTools:n,onResult:a,setToolStatuses:i}){const s=R.useRef({}),o=R.useRef(new Map),c=R.useRef(new AbortController),[d]=R.useState(()=>{const[g,v]=Eh(),x=X0(n,()=>{var w,z;return(z=(w=c.current)==null?void 0:w.signal)!=null?z:new AbortController().signal},(w,z)=>new Promise((D,k)=>{const q=o.current.get(w);q&&q.reject(new Error("Human input request was superseded by a new request")),o.current.set(w,{resolve:D,reject:k}),i(I=>G(_({},I),{[w]:{type:"interrupt",payload:{type:"human",payload:z}}}))}));return g.pipeThrough(x).pipeThrough(new _h).pipeTo(new WritableStream({write(w){var z;if(w.type==="result"){if((z=s.current[w.meta.toolCallId])!=null&&z.hasResult)return;a(_({type:"add-tool-result",toolCallId:w.meta.toolCallId,toolName:w.meta.toolName,result:w.result,isError:w.isError},w.artifact&&{artifact:w.artifact})),i(D=>{const k=_({},D);return delete k[w.meta.toolCallId],k})}}})),v}),h=R.useRef(new Set),m=R.useRef(!0);R.useEffect(()=>{const g=v=>{v.forEach(x=>{x.content.forEach(w=>{if(w.type==="tool-call"){if(m.current)h.current.add(w.toolCallId);else{if(h.current.has(w.toolCallId))return;let z=s.current[w.toolCallId];if(z||(z={argsText:"",hasResult:!1,argsComplete:!1,controller:d.addToolCallPart({toolName:w.toolName,toolCallId:w.toolCallId})},s.current[w.toolCallId]=z),w.argsText!==z.argsText)if(z.argsComplete)process.env.NODE_ENV!=="production"&&console.warn("argsText updated after controller was closed:",{previous:z.argsText,next:w.argsText});else{if(!w.argsText.startsWith(z.argsText))throw new Error(`Tool call argsText can only be appended, not updated: ${w.argsText} does not start with ${z.argsText}`);const D=w.argsText.slice(z.argsText.length);z.controller.argsText.append(D);const k=s1(w.argsText);k&&z.controller.argsText.close(),s.current[w.toolCallId]={argsText:w.argsText,hasResult:z.hasResult,argsComplete:k,controller:z.controller}}w.result!==void 0&&!z.hasResult&&(z.controller.setResponse(new _a({result:w.result,artifact:w.artifact,isError:w.isError})),z.controller.close(),s.current[w.toolCallId]={hasResult:!0,argsComplete:!0,argsText:z.argsText,controller:z.controller})}w.messages&&g(w.messages)}})})};g(t.messages),m.current&&(m.current=!1)},[t,d,a]);const y=()=>{o.current.forEach(({reject:g})=>{g(new Error("Tool execution aborted"))}),o.current.clear(),i({}),c.current.abort(),c.current=new AbortController};return{reset:()=>{y(),m.current=!0},abort:y,resume:(g,v)=>{const x=o.current.get(g);if(x)o.current.delete(g),i(w=>{const z=_({},w);return delete z[g],z}),x.resolve(v);else throw new Error(`Tool call ${g} is not waiting for human input`)}}}var o1=class{list(){return Promise.resolve({threads:[]})}rename(){return Promise.resolve()}archive(){return Promise.resolve()}unarchive(){return Promise.resolve()}delete(){return Promise.resolve()}initialize(t){return Promise.resolve({remoteId:t,externalId:void 0})}generateTitle(){return Promise.resolve(new ReadableStream)}fetch(t){return Promise.reject(new Error("Thread not found"))}};function c1(t,n){t.commitTasks.forEach(a=>{const i=a.cellIndex,s=n.cells[i];if(s.type!=="effect")throw new Error("Cannot find effect cell");let o=!0;if(s.deps!==void 0&&a.deps!==void 0&&(o=s.deps.length!==a.deps.length||s.deps.some((c,d)=>!Object.is(c,a.deps[d]))),o){if(s.mounted){if(typeof s.deps!=typeof a.deps)throw new Error("tapEffect called with and without dependencies across re-renders");try{s.mounted&&s.cleanup&&s.cleanup()}finally{s.mounted=!1}}try{const c=a.effect();if(c!==void 0&&typeof c!="function")throw new Error(`An effect function must either return a cleanup function or nothing. Received: ${typeof c}`);s.mounted=!0,s.cleanup=typeof c=="function"?c:void 0,s.deps=a.deps}catch(c){throw c}}})}function f1(t){let n=null;for(let a=t.cells.length-1;a>=0;a--){const i=t.cells[a];if((i==null?void 0:i.type)==="effect"&&i.mounted&&i.cleanup)try{i.cleanup()}catch(s){n==null&&(n=s)}finally{i.mounted=!1}}if(n!=null)throw n}var Ii=null;function d1(t,n){t.currentIndex=0;const a=Ii;Ii=t;try{if(n(),t.isFirstRender=!1,t.cells.length!==t.currentIndex)throw new Error(`Rendered ${t.currentIndex} hooks but expected ${t.cells.length}. Hooks must be called in the exact same order in every render.`)}finally{Ii=a}}function go(){if(!Ii)throw new Error("No resource fiber available");return Ii}function qh(t,n){const a=t[Vh];if(!a)throw new Error("ResourceElement.type is not a valid Resource");return a(n)}var Vh=Symbol("fnSymbol");function us(t,n){return{resource:t,scheduleRerender:n,cells:[],currentIndex:0,renderContext:void 0,isFirstRender:!0,isMounted:!1,isNeverMounted:!0}}function Ta(t){t.isMounted=!1,f1(t)}function ji(t,n){const a={commitTasks:[],props:n,state:void 0};return d1(t,()=>{t.renderContext=a;try{a.state=qh(t.resource,n)}finally{t.renderContext=void 0}}),a}function Ea(t,n){t.isMounted=!0,t.isNeverMounted=!1,c1(n,t)}var h1=globalThis.__ASSISTANT_UI_DISABLE_LAYOUT_EFFECT__===!0,Yh=h1?R.useEffect:R.useLayoutEffect;function yo(t){const[,n]=R.useState({}),a=R.useMemo(()=>us(t.type,()=>n({})),[t.type,n]),i=ji(a,t.props);return Yh(()=>()=>Ta(a),[]),Yh(()=>{Ea(a,i)}),i.state}var Ca=t=>typeof t=="string"?{scope:t.split(".")[0],event:t}:{scope:t.scope,event:t.event},Qr=(t,n,a)=>n===t,Aa,bo=()=>{if(Aa)return Aa;const t=()=>({apis:new Map,nextId:0,listeners:new Set});if(typeof window=="undefined")return Aa=t(),Aa;const n=window.__ASSISTANT_UI_DEVTOOLS_HOOK__;if(n)return Aa=n,n;const a=t();return window.__ASSISTANT_UI_DEVTOOLS_HOOK__=a,Aa=a,a},p1=(Nn=class{static register(n){var d,h;const a=bo();for(const m of a.apis.values())if(m.api===n)return()=>{};const i=a.nextId++,s={api:n,logs:[]},o=(d=n.on)==null?void 0:d.call(n,"*",m=>{const y=a.apis.get(i);y&&(y.logs.push({time:new Date,event:m.event,data:m.payload}),y.logs.length>Nn.MAX_EVENT_LOGS_PER_API&&(y.logs=y.logs.slice(-200)),Nn.notifyListeners(i))}),c=(h=n.subscribe)==null?void 0:h.call(n,()=>{Nn.notifyListeners(i)});return a.apis.set(i,s),Nn.notifyListeners(i),()=>{const m=bo();m.apis.get(i)&&(o==null||o(),c==null||c(),m.apis.delete(i),Nn.notifyListeners(i))}}static notifyListeners(n){bo().listeners.forEach(i=>i(n))}},Y(Nn,"MAX_EVENT_LOGS_PER_API",200),Nn);function se(t){const n=(a,i)=>_({type:n,props:a},(i==null?void 0:i.key)!==void 0&&{key:i.key});return n[Vh]=t,n}var m1=t=>{if(t.renderContext)throw new Error("Resource updated during render");if(t.isNeverMounted)throw new Error("Resource updated before mount");t.isMounted&&t.scheduleRerender()};function g1(t){const n=go(),a=n.currentIndex++;if(!n.isFirstRender&&a>=n.cells.length)throw new Error("Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.");if(!n.cells[a]){const o={type:"state",value:typeof t=="function"?t():t,set:c=>{const d=o.value,h=typeof c=="function"?c(d):c;Object.is(d,h)||(o.value=h,m1(n))}};n.cells[a]=o}const i=n.cells[a];if(i.type!=="state")throw new Error("Hook order changed between renders");return i}function Un(t){const n=g1(t);return[n.value,n.set]}function y1(){const t=go(),n=t.currentIndex++;if(!t.isFirstRender&&n>=t.cells.length)throw new Error("Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.");if(!t.cells[n]){const i={type:"effect",mounted:!1};t.cells[n]=i}if(t.cells[n].type!=="effect")throw new Error("Hook order changed between renders");return n}function je(t,n){const a=go(),i=y1();a.renderContext.commitTasks.push({effect:t,deps:n,cellIndex:i})}function ka(t){const[n]=Un(()=>({current:t}));return n}var b1=(t,n)=>{if(t.length!==n.length)return!1;for(let a=0;a<t.length;a++)if(!Object.is(t[a],n[a]))return!1;return!0},Jt=(t,n)=>{const a=ka();return a.current||(a.current={value:t(),deps:n}),b1(a.current.deps,n)||(a.current.value=t(),a.current.deps=n),a.current.value};function os(t,n){const[a,i]=Un({}),s=Jt(()=>us(t.type,()=>i({})),[t.type]),o=n?Jt(()=>t.props,n):t.props,c=Jt(()=>ji(s,o),[s,o,a]);return je(()=>()=>Ta(s),[s]),je(()=>{Ea(s,c)},[s,c]),c.state}function zn(t){return qh(t.type,t.props)}function Fh(t){const n=new Set;t.forEach((d,h)=>{if(d.key===void 0)throw new Error(`tapResources: All resource elements must have a key. Element at index ${h} is missing a key.`);if(n.has(d.key))throw new Error(`tapResources: Duplicate key "${d.key}" found. All keys must be unique.`);n.add(d.key)});const[a,i]=Un({}),s=Jt(()=>new Map(t.map(d=>[d.key,d])),[t]),[o]=Un(()=>new Map),c=Jt(()=>{const d=new Map,h=new Set;return s.forEach((m,y)=>{h.add(y);let g=o.get(y);(!g||g.resource!==m.type)&&(g&&Ta(g),g=us(m.type,()=>i({})),o.set(y,g));const v=ji(g,m.props);d.set(y,v)}),o.forEach((m,y)=>{h.has(y)||(Ta(m),o.delete(y))}),d},[s,a]);return je(()=>{c.forEach((d,h)=>{const m=o.get(h);m&&Ea(m,d)})},[c,o]),je(()=>()=>{o.forEach(d=>{Ta(d)}),o.clear()},[o]),Jt(()=>t.map(d=>{var h;return(h=c.get(d.key))==null?void 0:h.state}),[t,c])}var vo=[],xo=!1;function v1(){xo=!1;const t=vo;vo=[];for(const n of t)try{n()}catch(a){console.error("Error in scheduled task:",a)}}function x1(t){vo.push(t),xo||(xo=!0,queueMicrotask(v1))}var S1=(ta=class{constructor(n){Y(this,"_isDirty",!1);Y(this,"_hasScheduledTask",!1);Y(this,"_isFlushing",!1);this._task=n}get isDirty(){return this._isDirty}markDirty(){this._isDirty=!0,!(this._hasScheduledTask||this._isFlushing)&&(this._hasScheduledTask=!0,x1(()=>{this._hasScheduledTask=!1,this.flushSync()}))}flushSync(){if(this._isFlushing)return;this._isFlushing=!0;let n=0;try{for(;this._isDirty;){if(n++,n>ta.MAX_FLUSH_DEPTH)throw new Error("Maximum update depth exceeded. This can happen when a resource repeatedly calls setState inside tapEffect.");this._isDirty=!1,this._task()}}finally{this._isFlushing=!1}}},Y(ta,"MAX_FLUSH_DEPTH",50),ta),w1=se(({element:t,onUpdateInput:n,onFlushSync:a,onDispose:i})=>{const[s,o]=Un(t.props),c=zn({type:t.type,props:s}),d=ka(new Set).current,h=ka(c);return je(()=>{c!==h.current&&(h.current=c,d.forEach(y=>y()))}),Jt(()=>({getState:()=>h.current,subscribe:y=>(d.add(y),()=>d.delete(y)),updateInput:y=>{n(),o(()=>y)},flushSync:a,dispose:i}),[])}),_1=(t,n=!1)=>{let a=!n;const i={element:t,onUpdateInput:()=>{a||(a=!0,Ea(o,c))},onFlushSync:()=>{s.flushSync()},onDispose:()=>Ta(o)},s=new S1(()=>{c=ji(o,i),a&&Ea(o,c)}),o=us(w1,()=>s.markDirty());let c=ji(o,i);return a&&Ea(o,c),c.state},Li=Symbol("tap.Context"),Gh=t=>({[Li]:t}),Ph=(t,n,a)=>{const i=t[Li];t[Li]=n;try{return a()}finally{t[Li]=i}},Xh=t=>t[Li];const Qh=t=>{let n;const a=new Set,i=(m,y)=>{const g=typeof m=="function"?m(n):m;if(!Object.is(g,n)){const v=n;n=(y!=null?y:typeof g!="object"||g===null)?g:Object.assign({},n,g),a.forEach(x=>x(n,v))}},s=()=>n,d={setState:i,getState:s,getInitialState:()=>h,subscribe:m=>(a.add(m),()=>a.delete(m))},h=n=t(i,s,d);return d},T1=(t=>t?Qh(t):Qh),E1=t=>t;function C1(t,n=E1){const a=nn.useSyncExternalStore(t.subscribe,nn.useCallback(()=>n(t.getState()),[t,n]),nn.useCallback(()=>n(t.getInitialState()),[t,n]));return nn.useDebugValue(a),a}const Zh=t=>{const n=T1(t),a=i=>C1(n,i);return Object.assign(a,n),a},Ra=(t=>t?Zh(t):Zh);function Kh(t,n){if(typeof t=="function")return t(n);t!=null&&(t.current=n)}function Jh(...t){return n=>{let a=!1;const i=t.map(s=>{const o=Kh(s,n);return!a&&typeof o=="function"&&(a=!0),o});if(a)return()=>{for(let s=0;s<i.length;s++){const o=i[s];typeof o=="function"?o():Kh(t[s],null)}}}}function cs(...t){return R.useCallback(Jh(...t),t)}var $h=se(t=>{const n=Jt(()=>_1(t,!0),[t.type]);return je(()=>{n.updateInput(t.props)}),n}),A1=class{constructor(t){this.getApi=t}get(t,n){return this.getApi()[n]}ownKeys(){return Object.keys(this.getApi())}has(t,n){return n in this.getApi()}getOwnPropertyDescriptor(t,n){return Object.getOwnPropertyDescriptor(this.getApi(),n)}set(){return!1}defineProperty(){return!1}deleteProperty(){return!1}},On=(t,n)=>{const a=ka(t);je(()=>{a.current=t});const i=Jt(()=>new Proxy({},new A1(()=>a.current)),[]),s=n==null?void 0:n.key,o=t.getState();return Jt(()=>({key:s,state:o,api:i}),[o,s])},Ma=se(t=>{const n=ka(t.get);return je(()=>{n.current=t.get}),Jt(()=>Oe({source:t.source,query:t.query,get:()=>n.current()}),[t.source,JSON.stringify(t.query)])}),k1=se(t=>{const n=os(t.scopeElement);return Jt(()=>[t.fieldName,n],[t.fieldName,n])}),R1=se(t=>{const d=t,{on:n,subscribe:a,flushSync:i}=d,s=gt(d,["on","subscribe","flushSync"]),o=ka({on:n,subscribe:a,flushSync:i});je(()=>{o.current={on:n,subscribe:a,flushSync:i}});const c=Fh(Object.entries(s).map(([h,m])=>k1({fieldName:h,scopeElement:m},{key:h})));return Jt(()=>{const h=Object.fromEntries(c),{on:m,subscribe:y,flushSync:g}=o.current;return m&&(h.on=(v,x)=>m(v,x)),y&&(h.subscribe=v=>y(v)),g&&(h.flushSync=()=>g()),h},[...c])}),Wh=Gh(null),M1=(t,n)=>Ph(Wh,t,n),tp=()=>{const t=Xh(Wh);if(!t)throw new Error("Model context is not available in this context");return t},z1=se(({toolkit:t})=>{const[n,a]=Un(()=>({tools:{}})),i=tp();je(()=>{if(!t)return;const o=[];for(const[h,m]of Object.entries(t))m.render&&o.push(s(h,m.render));const c=Object.entries(t).reduce((h,[m,y])=>{const x=y,{render:g}=x,v=gt(x,["render"]);return h[m]=v,h},{}),d={getModelContext:()=>({tools:c})};return o.push(i.register(d)),()=>{o.forEach(h=>h())}},[t,i]);const s=(o,c)=>(a(d=>{var h;return G(_({},d),{tools:G(_({},d.tools),{[o]:[...(h=d.tools[o])!=null?h:[],c]})})}),()=>{a(d=>{var h,m;return G(_({},d),{tools:G(_({},d.tools),{[o]:(m=(h=d.tools[o])==null?void 0:h.filter(y=>y!==c))!=null?m:[]})})})});return On({getState:()=>n,setToolUI:s})}),O1=se(()=>Jt(()=>{const n=new Map;return{on:(a,i)=>{n.has(a)||n.set(a,new Set);const s=n.get(a);return s.add(i),()=>{s.delete(i),s.size===0&&n.delete(a)}},emit:(a,i)=>{const s=n.get(a),o=n.get("*");!s&&!o||queueMicrotask(()=>{if(s)for(const c of s)c(i);if(o)for(const c of o)c({event:a,payload:i})})}}},[])),ep=Gh(null),D1=(t,n)=>Ph(ep,t,n),So=()=>{const t=Xh(ep);if(!t)throw new Error("Events context is not available");return t},N1=se(()=>{const[t]=Un(()=>({})),n=new io;return On({getState:()=>t,getModelContext:()=>n.getModelContext(),subscribe:a=>n.subscribe(a),register:a=>n.registerModelContextProvider(a)})}),I1=se(({threads:t,modelContext:n,tools:a})=>{const i=zn(O1()),{threads:s,tools:o,modelContext:c}=D1(i,()=>{const h=os(n!=null?n:N1(),[n]);return M1(h.api,()=>({modelContext:h,tools:os(a!=null?a:z1({}),[a]),threads:os(t,[t])}))}),d=Jt(()=>({threads:s.state,tools:o.state,modelContext:c.state}),[s.state,o.state,c.state]);return On({getState:()=>d,threads:s.api,tools:o.api,modelContext:c.api,on:i.on})}),j1=t=>{const n=()=>t.getState().api.threads.item("main");return{threads:Oe({source:"root",query:{},get:()=>t.getState().api.threads}),tools:Oe({source:"root",query:{},get:()=>t.getState().api.tools}),modelContext:Oe({source:"root",query:{},get:()=>t.getState().api.modelContext}),thread:Oe({source:"threads",query:{type:"main"},get:()=>t.getState().api.threads.thread("main")}),threadListItem:Oe({source:"threads",query:{type:"main"},get:()=>n()}),composer:Oe({source:"thread",query:{},get:()=>t.getState().api.threads.thread("main").composer}),on(a,i){const{event:s,scope:o}=Ca(a);if(o==="*")return t.getState().api.on(s,i);if(Qr("thread",o)||Qr("thread-list-item",o)||Qr("composer",o))return t.getState().api.on(s,c=>{c.threadId===n().getState().id&&i(c)});throw new Error(`Event scope is not available in this component: ${o}`)},subscribe:t.subscribe,flushSync:t.flushSync}},L1=t=>{const n=fs(),a=yo($h(I1(t))),i=R.useMemo(()=>j1(a),[a]);return R.useMemo(()=>rp(n,i),[n,i])},Oe=t=>{const n=t.get;return n.source=t.source,n.query=t.query,n},yr=()=>()=>{},np=R.createContext({threads:Oe({source:null,query:{},get:()=>{throw new Error("Threads is only available inside <AssistantProvider />")}}),tools:Oe({source:null,query:{},get:()=>{throw new Error("Tools is only available inside <AssistantProvider />")}}),modelContext:Oe({source:null,query:{},get:()=>{throw new Error("ModelContext is only available inside <AssistantProvider />")}}),threadListItem:Oe({source:null,query:{},get:()=>{throw new Error("ThreadListItem is only available inside <AssistantProvider />")}}),thread:Oe({source:null,query:{},get:()=>{throw new Error("Thread is only available inside <AssistantProvider />")}}),composer:Oe({source:null,query:{},get:()=>{throw new Error("Composer is only available inside <AssistantProvider />")}}),message:Oe({source:null,query:{},get:()=>{throw new Error("Message is only available inside <ThreadPrimitive.Messages />")}}),part:Oe({source:null,query:{},get:()=>{throw new Error("Part is only available inside <MessagePrimitive.Parts />")}}),attachment:Oe({source:null,query:{},get:()=>{throw new Error("Attachment is only available inside <MessagePrimitive.Attachments /> or <ComposerPrimitive.Attachments />")}}),subscribe:yr,flushSync:yr,on:t=>{const{scope:n}=Ca(t);throw new Error(`Event scope is not available in this component: ${n}`)}}),fs=()=>R.useContext(np),Bi=t=>{const n=fs(),a=yo(R1(t));return R.useMemo(()=>rp(n,a),[n,a])},B1=t=>L1(t);function de(t){return t?B1(t):fs()}var U1=(t,n)=>t===yr?n:n===yr?t:(...a)=>{t(...a),n(...a)},H1=(t,n)=>t===yr?n:n===yr?t:(...a)=>{const i=t(...a),s=n(...a);return()=>{i(),s()}},rp=(t,n)=>{const a=n.subscribe,i=n.flushSync;return G(_(_({},t),n),{subscribe:H1(t.subscribe,a!=null?a:yr),flushSync:U1(t.flushSync,i!=null?i:yr)})},za=({api:t,children:n,devToolsVisible:a=!0})=>(R.useEffect(()=>{if(!(!a||!t.subscribe))return p1.register(t)},[t,a]),E.jsx(np.Provider,{value:t,children:n})),ap=(yy=class{constructor(t){ki(this,gn);Ri(this,gn,t)}get threads(){return pn(this,gn).threads().getState()}get tools(){return pn(this,gn).tools().getState()}get threadListItem(){return pn(this,gn).threadListItem().getState()}get thread(){return pn(this,gn).thread().getState()}get composer(){return pn(this,gn).composer().getState()}get message(){return pn(this,gn).message().getState()}get part(){return pn(this,gn).part().getState()}get attachment(){return pn(this,gn).attachment().getState()}},gn=new WeakMap,yy),ne=t=>{const n=de(),a=R.useMemo(()=>new ap(n),[n]),i=R.useSyncExternalStore(n.subscribe,()=>t(a),()=>t(a));if(R.useDebugValue(i),i instanceof ap)throw new Error("You tried to return the entire AssistantState. This is not supported due to technical limitations.");return i},q1=(t,n)=>{const a=de(),i=R.useRef(n);R.useEffect(()=>{i.current=n});const{scope:s,event:o}=Ca(t);R.useEffect(()=>a.on({scope:s,event:o},c=>i.current(c)),[a,s,o])};function V1(t,n){function a(i){const s=R.useContext(t);if(!(i!=null&&i.optional)&&!s)throw new Error(`This component must be used within ${n}.`);return s}return a}function ip(t,n){function a(s){const o=t(s);return o?o[n]:null}function i(s){let o=!1,c;typeof s=="function"?c=s:s&&typeof s=="object"&&(o=!!s.optional,c=s.selector);const d=a({optional:o});return d?c?d(c):d():null}return{[n]:i,[`${n}Store`]:a}}var lp=R.createContext(null),Y1=V1(lp,"ThreadPrimitive.Viewport"),{useThreadViewport:ds,useThreadViewportStore:wo}=ip(Y1,"useThreadViewport"),F1=t=>{var a;const n=t;n.__isBound||((a=n.__internal_bindMethods)==null||a.call(n),n.__isBound=!0)};function G1(t,n=P1){F1(t);const a=R.useSyncExternalStore(t.subscribe,()=>n(t.getState()),()=>n(t.getState()));return R.useDebugValue(a),a}var P1=t=>t;function sp(t){function n(a){let i=!1,s;typeof a=="function"?s=a:a&&(i=!!a.optional,s=a.selector);const o=t({optional:i});return o?G1(o,s):null}return n}function up(t){const n=de(),a=ne(()=>{var i,s,o;return n.thread.source&&(o=(s=(i=n.thread()).__internal_getRuntime)==null?void 0:s.call(i))!=null?o:null});if(!a&&!(t!=null&&t.optional))throw new Error("ThreadRuntime is not available");return a}var X1=sp(up);function Q1(t){const n=de(),a=ne(()=>{var i,s,o;return n.threadListItem.source&&(o=(s=(i=n.threadListItem()).__internal_getRuntime)==null?void 0:s.call(i))!=null?o:null});if(!a&&!(t!=null&&t.optional))throw new Error("ThreadListItemRuntime is not available");return a}var op=sp(Q1),Zr=t=>{const[,n]=Un(t.getState);return je(()=>(n(t.getState()),t.subscribe(()=>{n(t.getState())})),[t]),t.getState()},Z1=se(({runtime:t})=>{const n=Zr(t),a=So();return je(()=>{const i=[],s=["switched-to","switched-away"];for(const o of s){const c=t.unstable_on(o,()=>{a.emit(`thread-list-item.${o}`,{threadId:t.getState().id})});i.push(c)}return()=>{for(const o of i)o()}},[t,a]),On({getState:()=>n,switchTo:t.switchTo,rename:t.rename,archive:t.archive,unarchive:t.unarchive,delete:t.delete,generateTitle:t.generateTitle,initialize:t.initialize,detach:t.detach,__internal_getRuntime:()=>t},{key:n.id})}),Ui=t=>{const n=Fh(t);return{state:n.map(a=>a.state),api:a=>{var s,o;const i="index"in a?(s=n[a.index])==null?void 0:s.api:(o=n.find(c=>c.key===a.key))==null?void 0:o.api;if(!i)throw new Error(`tapLookupResources: Resource not found for lookup: ${JSON.stringify(a)}`);return i}}},cp=se(({runtime:t})=>{const n=Zr(t);return On({getState:()=>n,remove:t.remove,__internal_getRuntime:()=>t},{key:n.id})}),K1=se(({runtime:t,index:n})=>{const a=Jt(()=>t.getAttachmentByIndex(n),[t,n]);return zn(cp({runtime:a}))}),fp=se(({threadIdRef:t,messageIdRef:n,runtime:a})=>{var d;const i=Zr(a),s=So();je(()=>{const h=[],m=["send","attachment-add"];for(const y of m){const g=a.unstable_on(y,()=>{s.emit(`composer.${y}`,_({threadId:t.current},n&&{messageId:n.current}))});h.push(g)}return()=>{for(const y of h)y()}},[a,s,t,n]);const o=Ui(i.attachments.map((h,m)=>K1({runtime:a,index:m},{key:m}))),c=Jt(()=>{var h;return{text:i.text,role:i.role,attachments:o.state,runConfig:i.runConfig,isEditing:i.isEditing,canCancel:i.canCancel,attachmentAccept:i.attachmentAccept,isEmpty:i.isEmpty,type:(h=i.type)!=null?h:"thread"}},[i,o.state]);return On({getState:()=>c,setText:a.setText,setRole:a.setRole,setRunConfig:a.setRunConfig,addAttachment:a.addAttachment,reset:a.reset,clearAttachments:a.clearAttachments,send:a.send,cancel:a.cancel,beginEdit:(d=a.beginEdit)!=null?d:(()=>{throw new Error("beginEdit is not supported in this runtime")}),attachment:h=>"id"in h?o.api({key:h.id}):o.api(h),__internal_getRuntime:()=>a})}),J1=se(({runtime:t})=>{const n=Zr(t);return On({getState:()=>n,addToolResult:i=>t.addToolResult(i),resumeToolCall:i=>t.resumeToolCall(i),__internal_getRuntime:()=>t},{key:n.type==="tool-call"?`toolCallId-${n.toolCallId}`:void 0})}),$1=se(({runtime:t,index:n})=>{const a=Jt(()=>t.getAttachmentByIndex(n),[t,n]);return zn(cp({runtime:a}))}),W1=se(({runtime:t,index:n})=>{const a=Jt(()=>t.getMessagePartByIndex(n),[t,n]);return zn(J1({runtime:a}))}),tw=se(({runtime:t,threadIdRef:n})=>{var v,x;const a=Zr(t),[i,s]=Un(!1),[o,c]=Un(!1),d=Jt(()=>({get current(){return t.getState().id}}),[t]),h=zn(fp({runtime:t.composer,threadIdRef:n,messageIdRef:d})),m=Ui(a.content.map((w,z)=>W1({runtime:t,index:z},{key:z}))),y=Ui((x=(v=a.attachments)==null?void 0:v.map((w,z)=>$1({runtime:t,index:z},{key:z})))!=null?x:[]),g=Jt(()=>G(_({},a),{parts:m.state,composer:h.state,isCopied:i,isHovering:o}),[a,m.state,h.state,i,o]);return On({getState:()=>g,composer:h.api,reload:w=>t.reload(w),speak:()=>t.speak(),stopSpeaking:()=>t.stopSpeaking(),submitFeedback:w=>t.submitFeedback(w),switchToBranch:w=>t.switchToBranch(w),getCopyText:()=>t.unstable_getCopyText(),part:w=>"index"in w?m.api({index:w.index}):m.api({key:`toolCallId-${w.toolCallId}`}),attachment:w=>"id"in w?y.api({key:w.id}):y.api(w),setIsCopied:s,setIsHovering:c,__internal_getRuntime:()=>t},{key:a.id})}),ew=se(({runtime:t,id:n,threadIdRef:a})=>{const i=Jt(()=>t.getMessageById(n),[t,n]);return zn(tw({runtime:i,threadIdRef:a}))}),nw=se(({runtime:t})=>{const n=Zr(t),a=So();je(()=>{const d=[],h=["run-start","run-end","initialize","model-context-update"];for(const m of h){const y=t.unstable_on(m,()=>{var v;const g=((v=t.getState())==null?void 0:v.threadId)||"unknown";a.emit(`thread.${m}`,{threadId:g})});d.push(y)}return()=>{for(const m of d)m()}},[t]);const i=Jt(()=>({get current(){return t.getState().threadId}}),[t]),s=zn(fp({runtime:t.composer,threadIdRef:i})),o=Ui(n.messages.map(d=>ew({runtime:t,id:d.id,threadIdRef:i},{key:d.id}))),c=Jt(()=>({isDisabled:n.isDisabled,isLoading:n.isLoading,isRunning:n.isRunning,capabilities:n.capabilities,state:n.state,suggestions:n.suggestions,extras:n.extras,speech:n.speech,composer:s.state,messages:o.state}),[n,o,s.state]);return On({getState:()=>c,composer:s.api,append:t.append,startRun:t.startRun,unstable_resumeRun:t.unstable_resumeRun,cancelRun:t.cancelRun,getModelContext:t.getModelContext,export:t.export,import:t.import,reset:t.reset,stopSpeaking:t.stopSpeaking,startVoice:()=>W(null,null,function*(){throw new Error("startVoice is not supported in this runtime")}),stopVoice:()=>W(null,null,function*(){throw new Error("stopVoice is not supported in this runtime")}),message:d=>"id"in d?o.api({key:d.id}):o.api(d),__internal_getRuntime:()=>t})}),rw=se(({runtime:t,id:n})=>{const a=Jt(()=>t.getItemById(n),[t,n]);return zn(Z1({runtime:a}))}),aw=se(({runtime:t,__internal_assistantRuntime:n})=>{const a=Zr(t),i=zn(nw({runtime:t.main})),s=Ui(Object.keys(a.threadItems).map(c=>rw({runtime:t,id:c},{key:c}))),o=Jt(()=>{var c;return{mainThreadId:a.mainThreadId,newThreadId:(c=a.newThread)!=null?c:null,isLoading:a.isLoading,threadIds:a.threads,archivedThreadIds:a.archivedThreads,threadItems:s.state,main:i.state}},[a,s.state,i.state]);return On({getState:()=>o,thread:()=>i.api,item:c=>{if(c==="main")return s.api({key:o.mainThreadId});if("id"in c)return s.api({key:c.id});const{index:d,archived:h=!1}=c,m=h?o.archivedThreadIds[d]:o.threadIds[d];return s.api({key:m})},switchToThread:c=>{t.switchToThread(c)},switchToNewThread:()=>{t.switchToNewThread()},__internal_getAssistantRuntime:()=>n})}),iw=se(t=>{const n=tp();return je(()=>t.registerModelContextProvider(n),[t,n]),zn(aw({runtime:t.threads,__internal_assistantRuntime:t}))}),_o=t=>{const n=new Map,a=()=>{let i=0;for(const s of n.values())i+=s;t(i)};return{register:()=>{const i=Symbol();return n.set(i,0),{setHeight:s=>{n.get(i)!==s&&(n.set(i,s),a())},unregister:()=>{n.delete(i),a()}}}}},lw=(t={})=>{const n=new Set,a=_o(c=>{o.setState({height:G(_({},o.getState().height),{viewport:c})})}),i=_o(c=>{o.setState({height:G(_({},o.getState().height),{inset:c})})}),s=_o(c=>{o.setState({height:G(_({},o.getState().height),{userMessage:c})})}),o=Ra(()=>{var c;return{isAtBottom:!0,scrollToBottom:({behavior:d="auto"}={})=>{for(const h of n)h({behavior:d})},onScrollToBottom:d=>(n.add(d),()=>{n.delete(d)}),turnAnchor:(c=t.turnAnchor)!=null?c:"bottom",height:{viewport:0,inset:0,userMessage:0},registerViewport:a.register,registerContentInset:i.register,registerUserMessageHeight:s.register}});return o},Hi=t=>t,sw=t=>{const n=wo({optional:!0}),[a]=R.useState(()=>lw(t));return R.useEffect(()=>n==null?void 0:n.getState().onScrollToBottom(()=>{a.getState().scrollToBottom()}),[n,a]),R.useEffect(()=>{if(n)return a.subscribe(i=>{n.getState().isAtBottom!==i.isAtBottom&&Hi(n).setState({isAtBottom:i.isAtBottom})})},[a,n]),R.useEffect(()=>{var o;const i={turnAnchor:(o=t.turnAnchor)!=null?o:"bottom"};a.getState().turnAnchor!==i.turnAnchor&&Hi(a).setState(i)},[a,t.turnAnchor]),a},dp=({children:t,options:n={}})=>{const a=sw(n),[i]=R.useState(()=>({useThreadViewport:a}));return E.jsx(lp.Provider,{value:i,children:t})},uw=t=>{var n;return(n=t._core)==null?void 0:n.RenderComponent},ow=({children:t,runtime:n})=>{const a=de({threads:iw(n)}),i=uw(n);return E.jsxs(za,{api:a,children:[i&&E.jsx(i,{}),E.jsx(dp,{children:t})]})},hp=R.memo(ow),cw=({index:t,archived:n,children:a})=>{const i=de(),s=Bi({threadListItem:Ma({source:"threads",query:{type:"index",index:t,archived:n},get:()=>i.threads().item({index:t,archived:n})}),on(o,c){const d=()=>i.threads().item({index:t,archived:n}),{event:h,scope:m}=Ca(o);return Qr("thread-list-item",m)?i.on({scope:"*",event:h},y=>{y.threadId===d().getState().id&&c(y)}):i.on(o,c)}});return E.jsx(za,{api:s,children:a})},fw=({id:t,children:n})=>{const a=de(),i=Bi({threadListItem:Ma({source:"threads",query:{type:"id",id:t},get:()=>a.threads().item({id:t})}),on(s,o){const c=()=>a.threads().item({id:t}),{event:d,scope:h}=Ca(s);return Qr("thread-list-item",h)?a.on({scope:"*",event:d},m=>{m.threadId===c().getState().id&&o(m)}):a.on(s,o)}});return E.jsx(za,{api:i,children:n})},dw=({index:t,children:n})=>{const a=de(),i=Bi({message:Ma({source:"thread",query:{type:"index",index:t},get:()=>a.thread().message({index:t})}),composer:Ma({source:"message",query:{},get:()=>a.thread().message({index:t}).composer}),on(s,o){const c=()=>a.thread().message({index:t}),{event:d,scope:h}=Ca(s);return!Qr("composer",h)&&!Qr("message",h)?a.on(s,o):a.on({scope:"thread",event:d},m=>{m.messageId===c().getState().id&&o(m)})}});return E.jsx(za,{api:i,children:n})},hw=({index:t,children:n})=>{const a=de(),i=Bi({part:Ma({source:"message",query:{type:"index",index:t},get:()=>a.message().part({index:t})})});return E.jsx(za,{api:i,children:n})},pw=se(({text:t,isRunning:n})=>{const a=Jt(()=>({type:"text",text:t,status:n?{type:"running"}:{type:"complete"}}),[t,n]);return On({getState:()=>a,addToolResult:()=>{throw new Error("Not supported")},resumeToolCall:()=>{throw new Error("Not supported")}})}),mw=({text:t,isRunning:n=!1,children:a})=>{const i=yo($h(pw({text:t,isRunning:n}))),s=Bi({part:Ma({source:"root",query:{},get:()=>i.getState().api}),subscribe:i.subscribe,flushSync:i.flushSync});return E.jsx(za,{api:s,children:a})},pp=(t,n)=>{var a,i;return n===void 0?((a=t.status)==null?void 0:a.type)==="requires-action"&&t.status.reason==="tool-calls"&&t.content.every(s=>s.type!=="tool-call"||!!s.result):((i=t.status)==null?void 0:i.type)==="requires-action"&&t.status.reason==="tool-calls"&&t.content.every(s=>s.type!=="tool-call"||!!s.result||!n.includes(s.toolName))},To=class extends Error{constructor(n,a){super(a);Y(this,"name","AbortError");Y(this,"detach");this.detach=n}},gw=class extends l1{constructor(n,a){super(n);Y(this,"capabilities",{switchToBranch:!0,switchBranchDuringRun:!0,edit:!0,reload:!0,cancel:!0,unstable_copy:!0,speech:!1,attachments:!1,feedback:!1});Y(this,"abortController",null);Y(this,"isDisabled",!1);Y(this,"_isLoading",!1);Y(this,"_suggestions",[]);Y(this,"_suggestionsController",null);Y(this,"_options");Y(this,"_lastRunConfig",{});Y(this,"_loadPromise");this.__internal_setOptions(a)}get isLoading(){return this._isLoading}get suggestions(){return this._suggestions}get adapters(){return this._options.adapters}get extras(){}__internal_setOptions(n){var c,d,h;if(this._options===n)return;this._options=n;let a=!1;const i=((c=n.adapters)==null?void 0:c.speech)!==void 0;this.capabilities.speech!==i&&(this.capabilities.speech=i,a=!0);const s=((d=n.adapters)==null?void 0:d.attachments)!==void 0;this.capabilities.attachments!==s&&(this.capabilities.attachments=s,a=!0);const o=((h=n.adapters)==null?void 0:h.feedback)!==void 0;this.capabilities.feedback!==o&&(this.capabilities.feedback=o,a=!0),a&&this._notifySubscribers()}__internal_load(){var a,i;if(this._loadPromise)return this._loadPromise;const n=(i=(a=this.adapters.history)==null?void 0:a.load())!=null?i:Promise.resolve(null);return this._isLoading=!0,this._notifySubscribers(),this._loadPromise=n.then(s=>{var c,d;if(!s)return;this.repository.import(s),this._notifySubscribers();const o=(d=(c=this.adapters.history)==null?void 0:c.resume)==null?void 0:d.bind(this.adapters.history);s.unstable_resume&&o&&this.startRun({parentId:this.repository.headId,sourceId:this.repository.headId,runConfig:this._lastRunConfig},o)}).finally(()=>{this._isLoading=!1,this._notifySubscribers()}),this._loadPromise}append(n){return W(this,null,function*(){var s,o,c;this.ensureInitialized();const a=Di(n,Pr(),{type:"complete",reason:"unknown"});this.repository.addOrUpdateMessage(n.parentId,a),(s=this._options.adapters.history)==null||s.append(_({parentId:n.parentId,message:a},n.runConfig!==void 0&&{runConfig:n.runConfig})),((o=n.startRun)!=null?o:n.role==="user")?yield this.startRun({parentId:a.id,sourceId:n.sourceId,runConfig:(c=n.runConfig)!=null?c:{}}):(this.repository.resetHead(a.id),this._notifySubscribers())})}resumeRun(i){var s=i,{stream:n}=s,a=gt(s,["stream"]);if(!n)throw new Error("You must pass a stream parameter to resume runs.");return this.startRun(a,n)}unstable_loadExternalState(){throw new Error("Runtime does not support importing external states.")}startRun(s,o){return W(this,arguments,function*({parentId:n,runConfig:a},i){var m,y,g;this.ensureInitialized();let d={id:Pr(),role:"assistant",status:{type:"running"},content:[],metadata:{unstable_state:this.state,unstable_annotations:[],unstable_data:[],steps:[],custom:{}},createdAt:new Date};this._notifyEventSubscribers("run-start");try{this._suggestions=[],(m=this._suggestionsController)==null||m.abort(),this._suggestionsController=null,this._notifySubscribers();do d=yield this.performRoundtrip(n,d,a,i),i=void 0;while(pp(d,this._options.unstable_humanToolNames))}finally{this._notifyEventSubscribers("run-end")}this._suggestionsController=new AbortController;const h=this._suggestionsController.signal;if(this.adapters.suggestion&&((y=d.status)==null?void 0:y.type)!=="requires-action"){const D=(g=this.adapters.suggestion)==null?void 0:g.generate({messages:this.messages});if(Symbol.asyncIterator in D)try{for(var v=xa(D),x,w,z;x=!(w=yield v.next()).done;x=!1){const k=w.value;if(h.aborted)break;this._suggestions=k,this._notifySubscribers()}}catch(w){z=[w]}finally{try{x&&(w=v.return)&&(yield w.call(v))}finally{if(z)throw z[0]}}else{const k=yield D;if(h.aborted)return;this._suggestions=k,this._notifySubscribers()}}})}performRoundtrip(n,a,i,s){return W(this,null,function*(){var w,z,D,k,q,I,at,lt,L,tt;const o=n?this.repository.getMessages(n):[];(w=this.abortController)==null||w.abort(),this.abortController=new AbortController;const c=a.content,d=(z=a.metadata)==null?void 0:z.unstable_annotations,h=(D=a.metadata)==null?void 0:D.unstable_data,m=(k=a.metadata)==null?void 0:k.steps,y=(q=a.metadata)==null?void 0:q.custom,g=$=>{var Tt,C,M,P,T,ut;const bt=(Tt=$.metadata)==null?void 0:Tt.steps,ot=bt?[...m!=null?m:[],...bt]:void 0,nt=(C=$.metadata)==null?void 0:C.unstable_annotations,H=(M=$.metadata)==null?void 0:M.unstable_data,et=nt?[...d!=null?d:[],...nt]:void 0,ft=H?[...h!=null?h:[],...H]:void 0;a=_(G(_(_({},a),$.content?{content:[...c,...(P=$.content)!=null?P:[]]}:void 0),{status:(T=$.status)!=null?T:a.status}),$.metadata?{metadata:_(_(_(_(_(_({},a.metadata),$.metadata.unstable_state?{unstable_state:$.metadata.unstable_state}:void 0),et?{unstable_annotations:et}:void 0),ft?{unstable_data:ft}:void 0),ot?{steps:ot}:void 0),(ut=$.metadata)!=null&&ut.custom?{custom:_(_({},y!=null?y:{}),$.metadata.custom)}:void 0)}:void 0),this.repository.addOrUpdateMessage(n,a),this._notifySubscribers()},v=(I=this._options.maxSteps)!=null?I:2;if(((L=(lt=(at=a.metadata)==null?void 0:at.steps)==null?void 0:lt.length)!=null?L:0)>=v)return g({status:{type:"incomplete",reason:"tool-calls"}}),a;g({status:{type:"running"}}),this.repository.resetHead(a.id),this._notifySubscribers();try{this._lastRunConfig=i!=null?i:{};const $=this.getModelContext();s=s!=null?s:this.adapters.chatModel.run.bind(this.adapters.chatModel);const bt=this.abortController.signal,ot=s({messages:o,runConfig:this._lastRunConfig,abortSignal:bt,context:$,config:$,unstable_assistantMessageId:a.id,unstable_getMessage(){return a}});if(Symbol.asyncIterator in ot)try{for(var J=xa(ot),st,ct,j;st=!(ct=yield J.next()).done;st=!1){const nt=ct.value;if(bt.aborted){g({status:{type:"incomplete",reason:"cancelled"}});break}g(nt)}}catch(ct){j=[ct]}finally{try{st&&(ct=J.return)&&(yield ct.call(J))}finally{if(j)throw j[0]}}else g(yield ot);a.status.type==="running"&&g({status:{type:"complete",reason:"unknown"}})}catch($){if($ instanceof To)g({status:{type:"incomplete",reason:"cancelled"}});else throw g({status:{type:"incomplete",reason:"error",error:$ instanceof Error?$.message:`[${typeof $}] ${new String($).toString()}`}}),$}finally{this.abortController=null,(a.status.type==="complete"||a.status.type==="incomplete")&&(yield(tt=this._options.adapters.history)==null?void 0:tt.append({parentId:n,message:a,runConfig:this._lastRunConfig}))}return a})}detach(){var a;const n=new To(!0);(a=this.abortController)==null||a.abort(n),this.abortController=null}cancelRun(){var a;const n=new To(!1);(a=this.abortController)==null||a.abort(n),this.abortController=null}addToolResult({messageId:n,toolCallId:a,result:i,isError:s,artifact:o}){const c=this.repository.getMessage(n),{parentId:d}=c;let{message:h}=c;if(h.role!=="assistant")throw new Error("Tried to add tool result to non-assistant message");let m=!1,y=!1;const g=h.content.map(v=>v.type!=="tool-call"||v.toolCallId!==a?v:(y=!0,v.result||(m=!0),G(_({},v),{result:i,artifact:o,isError:s})));if(!y)throw new Error("Tried to add tool result to non-existing tool call");h=G(_({},h),{content:g}),this.repository.addOrUpdateMessage(d,h),m&&pp(h,this._options.unstable_humanToolNames)&&this.performRoundtrip(d,h,this._lastRunConfig)}resumeToolCall(n){throw new Error("Local runtime does not support resuming tool calls.")}},mp=Object.freeze([]),Eo="__DEFAULT_ID__",yw=Object.freeze({[Eo]:{id:Eo,remoteId:void 0,externalId:void 0,status:"regular",title:void 0}}),bw=class extends zi{constructor(n){super();Y(this,"_mainThread");this._mainThread=n()}get isLoading(){return!1}getMainThreadRuntimeCore(){return this._mainThread}get newThreadId(){throw new Error("Method not implemented.")}get threadIds(){throw mp}get archivedThreadIds(){throw mp}get mainThreadId(){return Eo}get threadData(){return yw}getThreadRuntimeCore(){throw new Error("Method not implemented.")}getLoadThreadsPromise(){throw new Error("Method not implemented.")}getItemById(n){if(n===this.mainThreadId)return{status:"regular",id:this.mainThreadId,remoteId:this.mainThreadId,externalId:void 0,title:void 0,isMain:!0};throw new Error("Method not implemented")}switchToThread(){return W(this,null,function*(){throw new Error("Method not implemented.")})}switchToNewThread(){throw new Error("Method not implemented.")}rename(){throw new Error("Method not implemented.")}archive(){throw new Error("Method not implemented.")}detach(){throw new Error("Method not implemented.")}unarchive(){throw new Error("Method not implemented.")}delete(){throw new Error("Method not implemented.")}initialize(n){return Promise.resolve({remoteId:n,externalId:void 0})}generateTitle(){throw new Error("Method not implemented.")}},vw=class extends lo{constructor(n,a){super();Y(this,"threads");Y(this,"Provider");Y(this,"_options");this._options=n,this.threads=new bw(()=>new gw(this._contextProvider,this._options)),a&&this.threads.getMainThreadRuntimeCore().import(fo.fromArray(a))}},gp=t=>{try{const a=t.split(".")[1];if(!a)throw new Error("Invalid JWT format");let i=a.replace(/-/g,"+").replace(/_/g,"/");for(;i.length%4!==0;)i+="=";const s=atob(i),c=JSON.parse(s).exp;if(!c||typeof c!="number")throw new Error('JWT does not contain a valid "exp" field');return c*1e3}catch(n){throw new Error("Unable to determine the token expiry: "+n)}},yp=(by=class{constructor(t){Y(this,"strategy","jwt");Y(this,"cachedToken",null);Y(this,"tokenExpiry",null);ki(this,tl);Ri(this,tl,t)}getAuthHeaders(){return W(this,null,function*(){const t=Date.now();if(this.cachedToken&&this.tokenExpiry&&this.tokenExpiry-t>30*1e3)return{Authorization:`Bearer ${this.cachedToken}`};const n=yield pn(this,tl).call(this);return n?(this.cachedToken=n,this.tokenExpiry=gp(n),{Authorization:`Bearer ${n}`}):!1})}readAuthHeaders(t){const n=t.get("Authorization");if(!n)return;const[a,i]=n.split(" ");if(a!=="Bearer"||!i)throw new Error("Invalid auth header received");this.cachedToken=i,this.tokenExpiry=gp(i)}},tl=new WeakMap,by),xw=(vy=class{constructor(t,n,a){Y(this,"strategy","api-key");ki(this,el);ki(this,nl);ki(this,rl);Ri(this,el,t),Ri(this,nl,n),Ri(this,rl,a)}getAuthHeaders(){return W(this,null,function*(){return{Authorization:`Bearer ${pn(this,el)}`,"Aui-User-Id":pn(this,nl),"Aui-Workspace-Id":pn(this,rl)}})}readAuthHeaders(){}},el=new WeakMap,nl=new WeakMap,rl=new WeakMap,vy),hs="aui:refresh_token",Sw=class{constructor(t){Y(this,"strategy","anon");Y(this,"baseUrl");Y(this,"jwtStrategy");this.baseUrl=t,this.jwtStrategy=new yp(()=>W(this,null,function*(){const n=Date.now(),a=localStorage.getItem(hs),i=a?JSON.parse(a):void 0;if(i)if(new Date(i.expires_at).getTime()-n>30*1e3){const m=yield fetch(`${this.baseUrl}/v1/auth/tokens/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refresh_token:i.token})});if(m.ok){const y=yield m.json(),{access_token:g,refresh_token:v}=y;return v&&localStorage.setItem(hs,JSON.stringify(v)),g}}else localStorage.removeItem(hs);const s=yield fetch(`${this.baseUrl}/v1/auth/tokens/anonymous`,{method:"POST"});if(!s.ok)return null;const o=yield s.json(),{access_token:c,refresh_token:d}=o;return!c||!d?null:(localStorage.setItem(hs,JSON.stringify(d)),c)}))}getAuthHeaders(){return W(this,null,function*(){return this.jwtStrategy.getAuthHeaders()})}readAuthHeaders(t){this.jwtStrategy.readAuthHeaders(t)}},ww=class extends Error{constructor(t){super(t),this.name="APIError"}},_w=class{constructor(t){Y(this,"_auth");Y(this,"_baseUrl");if("authToken"in t)this._baseUrl=t.baseUrl,this._auth=new yp(t.authToken);else if("apiKey"in t)this._baseUrl="https://backend.assistant-api.com",this._auth=new xw(t.apiKey,t.userId,t.workspaceId);else if("anonymous"in t)this._baseUrl=t.baseUrl,this._auth=new Sw(t.baseUrl);else throw new Error("Invalid configuration: Must provide authToken, apiKey, or anonymous configuration")}initializeAuth(){return W(this,null,function*(){return!!this._auth.getAuthHeaders()})}makeRawRequest(a){return W(this,arguments,function*(t,n={}){var h;const i=yield this._auth.getAuthHeaders();if(!i)throw new Error("Authorization failed");const s=G(_(_({},i),n.headers),{"Content-Type":"application/json"}),o=new URLSearchParams;if(n.query)for(const[m,y]of Object.entries(n.query))y!==!1&&(y===!0?o.set(m,"true"):o.set(m,y.toString()));const c=new URL(`${this._baseUrl}/v1${t}`);c.search=o.toString();const d=yield fetch(c,{method:(h=n.method)!=null?h:"GET",headers:s,body:n.body?JSON.stringify(n.body):null});if(this._auth.readAuthHeaders(d.headers),!d.ok){const m=yield d.text();try{const y=JSON.parse(m);throw new ww(y.message)}catch(y){throw new Error(`Request failed with status ${d.status}, ${m}`)}}return d})}makeRequest(a){return W(this,arguments,function*(t,n={}){return(yield this.makeRawRequest(t,n)).json()})}},Tw=class{constructor(t){this.cloud=t}create(){return W(this,null,function*(){return this.cloud.makeRequest("/auth/tokens",{method:"POST"})})}},Ew=class{constructor(t){this.cloud=t}__internal_getAssistantOptions(t){return{api:this.cloud._baseUrl+"/v1/runs/stream",headers:()=>W(this,null,function*(){const n=yield this.cloud._auth.getAuthHeaders();if(!n)throw new Error("Authorization failed");return G(_({},n),{Accept:"text/plain"})}),body:{assistant_id:t,response_format:"vercel-ai-data-stream/v1",thread_id:"unstable_todo"}}}stream(t){return W(this,null,function*(){const n=yield this.cloud.makeRawRequest("/runs/stream",{method:"POST",headers:{Accept:"text/plain"},body:t});return oo.fromResponse(n,new j0)})}},Cw=class{constructor(t){this.cloud=t}list(t,n){return W(this,null,function*(){return this.cloud.makeRequest(`/threads/${encodeURIComponent(t)}/messages`,{query:n})})}create(t,n){return W(this,null,function*(){return this.cloud.makeRequest(`/threads/${encodeURIComponent(t)}/messages`,{method:"POST",body:n})})}},Aw=class{constructor(t){Y(this,"messages");this.cloud=t,this.messages=new Cw(t)}list(t){return W(this,null,function*(){return this.cloud.makeRequest("/threads",{query:t})})}get(t){return W(this,null,function*(){return this.cloud.makeRequest(`/threads/${encodeURIComponent(t)}`)})}create(t){return W(this,null,function*(){return this.cloud.makeRequest("/threads",{method:"POST",body:t})})}update(t,n){return W(this,null,function*(){return this.cloud.makeRequest(`/threads/${encodeURIComponent(t)}`,{method:"PUT",body:n})})}delete(t){return W(this,null,function*(){return this.cloud.makeRequest(`/threads/${encodeURIComponent(t)}`,{method:"DELETE"})})}},kw=class{constructor(t){this.cloud=t}pdfToImages(t){return W(this,null,function*(){return this.cloud.makeRequest("/files/pdf-to-images",{method:"POST",body:t})})}generatePresignedUploadUrl(t){return W(this,null,function*(){return this.cloud.makeRequest("/files/attachments/generate-presigned-upload-url",{method:"POST",body:t})})}},Rw=class{constructor(t){Y(this,"threads");Y(this,"auth");Y(this,"runs");Y(this,"files");const n=new _w(t);this.threads=new Aw(n),this.auth={tokens:new Tw(n)},this.runs=new Ew(n),this.files=new kw(n)}};function Co(t,n=0){return n>100?!1:t===null||typeof t=="string"||typeof t=="boolean"?!0:typeof t=="number"?!Number.isNaN(t)&&Number.isFinite(t):Array.isArray(t)?t.every(a=>Co(a,n+1)):typeof t=="object"?Object.entries(t).every(([a,i])=>typeof a=="string"&&Co(i,n+1)):!1}var Mw=t=>{var n;return _({role:t.role,content:t.content.map(a=>{const i=a.type;switch(i){case"text":return{type:"text",text:a.text};case"reasoning":return{type:"reasoning",text:a.text};case"source":return _({type:"source",sourceType:a.sourceType,id:a.id,url:a.url},a.title?{title:a.title}:void 0);case"tool-call":return Co(a.result)||console.warn(`tool-call result is not JSON! ${JSON.stringify(a)}`),_(_(_({type:"tool-call",toolCallId:a.toolCallId,toolName:a.toolName},JSON.stringify(a.args)===a.argsText?{args:a.args}:{argsText:a.argsText}),a.result?{result:a.result}:{}),a.isError?{isError:!0}:{});default:{const s=i;throw new Error(`Message part type not supported by aui/v0: ${s}`)}}}),metadata:t.metadata},t.status?{status:((n=t.status)==null?void 0:n.type)==="running"?{type:"incomplete",reason:"cancelled"}:t.status}:void 0)},zw=t=>{const n=t.content,a=Di(_({id:t.id,createdAt:t.created_at},n),t.id,{type:"complete",reason:"unknown"});return{parentId:t.parent_id,message:a}},Ao=new WeakMap,Ow=class{constructor(t,n){this.parent=t,this.formatAdapter=n}append(t){return W(this,null,function*(){const n=this.formatAdapter.encode(t),a=this.formatAdapter.getId(t.message);return this.parent._appendWithFormat(t.parentId,a,this.formatAdapter.format,n)})}load(){return W(this,null,function*(){return this.parent._loadWithFormat(this.formatAdapter.format,t=>this.formatAdapter.decode(t))})}},Dw=class{constructor(t,n){this.cloudRef=t,this.store=n}get _getIdForLocalId(){return Ao.has(this.store.threadListItem())||Ao.set(this.store.threadListItem(),{}),Ao.get(this.store.threadListItem())}withFormat(t){return new Ow(this,t)}append(a){return W(this,arguments,function*({parentId:t,message:n}){var o;const{remoteId:i}=yield this.store.threadListItem().initialize(),s=this.cloudRef.current.threads.messages.create(i,{parent_id:t?(o=yield this._getIdForLocalId[t])!=null?o:t:null,format:"aui/v0",content:Mw(n)}).then(({message_id:c})=>(this._getIdForLocalId[n.id]=c,c));return this._getIdForLocalId[n.id]=s,s.then(()=>{})})}load(){return W(this,null,function*(){const t=this.store.threadListItem().getState().remoteId;if(!t)return{messages:[]};const{messages:n}=yield this.cloudRef.current.threads.messages.list(t,{format:"aui/v0"});return{messages:n.filter(i=>i.format==="aui/v0").map(zw).reverse()}})}_appendWithFormat(t,n,a,i){return W(this,null,function*(){var c;const{remoteId:s}=yield this.store.threadListItem().initialize(),o=this.cloudRef.current.threads.messages.create(s,{parent_id:t?(c=yield this._getIdForLocalId[t])!=null?c:t:null,format:a,content:i}).then(({message_id:d})=>(this._getIdForLocalId[n]=d,d));return this._getIdForLocalId[n]=o,o.then(()=>{})})}_loadWithFormat(t,n){return W(this,null,function*(){const a=this.store.threadListItem().getState().remoteId;if(!a)return{messages:[]};const{messages:i}=yield this.cloudRef.current.threads.messages.list(a,{format:t});return{messages:i.filter(s=>s.format===t).map(s=>n({id:s.id,parent_id:s.parent_id,format:s.format,content:s.content})).reverse()}})}},Nw=t=>{const n=de(),[a]=R.useState(()=>new Dw(t,n));return a},bp=typeof process!="undefined"&&((xy=process==null?void 0:process.env)==null?void 0:xy.NEXT_PUBLIC_ASSISTANT_BASE_URL),ko=bp?new Rw({baseUrl:bp,anonymous:!0}):void 0,Iw=t=>{var s;const n=R.useRef(t);R.useEffect(()=>{n.current=t},[t]);const a=R.useCallback(function({children:c}){var g;const d=Nw({get current(){var v;return(v=n.current.cloud)!=null?v:ko}}),h=(g=n.current.cloud)!=null?g:ko,m=R.useMemo(()=>new r1(h),[h]),y=R.useMemo(()=>({history:d,attachments:m}),[d,m]);return E.jsx(mo,{adapters:y,children:c})},[]),i=(s=t.cloud)!=null?s:ko;return i?{list:()=>W(null,null,function*(){const{threads:o}=yield i.threads.list();return{threads:o.map(c=>{var d;return{status:c.is_archived?"archived":"regular",remoteId:c.id,title:c.title,externalId:(d=c.external_id)!=null?d:void 0}})}}),initialize:()=>W(null,null,function*(){var m,y;const c=yield(y=(m=t.create)==null?void 0:m.call(t))!=null?y:Promise.resolve(),d=c?c.externalId:void 0,{thread_id:h}=yield i.threads.create({last_message_at:new Date,external_id:d});return{externalId:d,remoteId:h}}),rename:(o,c)=>W(null,null,function*(){return i.threads.update(o,{title:c})}),archive:o=>W(null,null,function*(){return i.threads.update(o,{is_archived:!0})}),unarchive:o=>W(null,null,function*(){return i.threads.update(o,{is_archived:!1})}),delete:o=>W(null,null,function*(){var c;return yield(c=t.delete)==null?void 0:c.call(t,o),i.threads.delete(o)}),generateTitle:(o,c)=>W(null,null,function*(){return i.runs.stream({thread_id:o,assistant_id:"system/thread_title",messages:c})}),fetch:o=>W(null,null,function*(){var d;const c=yield i.threads.get(o);return{status:c.is_archived?"archived":"regular",remoteId:c.id,title:c.title,externalId:(d=c.external_id)!=null?d:void 0}}),unstable_Provider:a}:new o1},jw=(t,i)=>{var s=i,{initialMessages:n}=s,a=gt(s,["initialMessages"]);var m;const y=(m=a1())!=null?m:{},{modelContext:o}=y,c=gt(y,["modelContext"]),d=R.useMemo(()=>G(_({},a),{adapters:G(_(_({},c),a.adapters),{chatModel:t})}),[t,a,c]),[h]=R.useState(()=>new vw(d,n));return R.useEffect(()=>()=>{h.threads.getMainThreadRuntimeCore().detach()},[h]),R.useEffect(()=>{h.threads.getMainThreadRuntimeCore().__internal_setOptions(d),h.threads.getMainThreadRuntimeCore().__internal_load()},[h,d]),R.useEffect(()=>{if(o)return h.registerModelContextProvider(o)},[o,h]),R.useMemo(()=>new Ro(h),[h])},vp=(t,i={})=>{var s=i,{cloud:n}=s,a=gt(s,["cloud"]);const o=Iw({cloud:n});return Tp({runtimeHook:function(){return jw(t,a)},adapter:o,allowNesting:!0})},Ro=class{constructor(t){Y(this,"threads");Y(this,"_thread");this._core=t,this.threads=new e1(t.threads),this._thread=this.threads.main,this.__internal_bindMethods()}get threadList(){return this.threads}__internal_bindMethods(){this.switchToNewThread=this.switchToNewThread.bind(this),this.switchToThread=this.switchToThread.bind(this),this.registerModelContextProvider=this.registerModelContextProvider.bind(this),this.registerModelConfigProvider=this.registerModelConfigProvider.bind(this),this.reset=this.reset.bind(this)}get thread(){return this._thread}switchToNewThread(){return this._core.threads.switchToNewThread()}switchToThread(t){return this._core.threads.switchToThread(t)}registerModelContextProvider(t){return this._core.registerModelContextProvider(t)}registerModelConfigProvider(t){return this.registerModelContextProvider(t)}reset({initialMessages:t}={}){return this._core.threads.getMainThreadRuntimeCore().import(fo.fromArray(t!=null?t:[]))}},Lw=t=>{const d=t,{cloud:n,initialMessages:a,maxSteps:i,adapters:s,unstable_humanToolNames:o}=d,c=gt(d,["cloud","initialMessages","maxSteps","adapters","unstable_humanToolNames"]);return{localRuntimeOptions:{cloud:n,initialMessages:a,maxSteps:i,adapters:s,unstable_humanToolNames:o},otherOptions:c}};function Kr(t){const n=R.useRef(t);return R.useEffect(()=>{n.current=t}),R.useMemo(()=>(...a)=>{var i;return(i=n.current)==null?void 0:i.call(n,...a)},[])}var xp=R.createContext(null),Bw=t=>({useSmoothStatus:Ra(()=>t)}),Uw=({children:t})=>{const n=Sp({optional:!0}),a=de(),[i]=R.useState(()=>Bw(a.part().getState().status));return n?t:E.jsx(xp.Provider,{value:i,children:t})},Hw=t=>{const n=R.forwardRef((a,i)=>E.jsx(Uw,{children:E.jsx(t,G(_({},a),{ref:i}))}));return n.displayName=t.displayName,n};function Sp(t){const n=R.useContext(xp);if(!(t!=null&&t.optional)&&!n)throw new Error("This component must be used within a SmoothContextProvider.");return n}var{useSmoothStatus:qw,useSmoothStatusStore:Vw}=ip(Sp,"useSmoothStatus"),Yw=class{constructor(t,n){Y(this,"animationFrameId",null);Y(this,"lastUpdateTime",Date.now());Y(this,"targetText","");Y(this,"animate",()=>{const t=Date.now();let a=t-this.lastUpdateTime;const i=this.targetText.length-this.currentText.length,s=Math.min(5,250/i);let o=0;for(;a>=s&&o<i;)o++,a-=s;o!==i?this.animationFrameId=requestAnimationFrame(this.animate):this.animationFrameId=null,o!==0&&(this.currentText=this.targetText.slice(0,this.currentText.length+o),this.lastUpdateTime=t-a,this.setText(this.currentText))});this.currentText=t,this.setText=n}start(){this.animationFrameId===null&&(this.lastUpdateTime=Date.now(),this.animate())}stop(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}},Mo=Object.freeze({type:"running"}),wp=(t,n=!1)=>{const{text:a}=t,i=ne(({message:y})=>y.id),s=R.useRef(i),[o,c]=R.useState(a),d=Vw({optional:!0}),h=Kr(y=>{if(c(y),d){const g=o!==y||t.status.type==="running"?Mo:t.status;Hi(d).setState(g,!0)}});R.useEffect(()=>{if(d){const y=n&&(o!==a||t.status.type==="running")?Mo:t.status;Hi(d).setState(y,!0)}},[d,n,a,o,t.status]);const[m]=R.useState(new Yw(a,h));return R.useEffect(()=>{if(!n){m.stop();return}if(s.current!==i||!a.startsWith(m.targetText)){s.current=i,h(a),m.currentText=a,m.targetText=a,m.stop();return}m.targetText=a,m.start()},[h,m,i,n,a]),R.useEffect(()=>()=>{m.stop()},[m]),R.useMemo(()=>n?{type:"text",text:o,status:a===o?t.status:Mo}:t,[n,o,t,a])};const Fw=Object.freeze(Object.defineProperty({__proto__:null,AssistantRuntimeImpl:Ro,BaseAssistantRuntimeCore:lo,CompositeContextProvider:io,DefaultThreadComposerRuntimeCore:dh,MessageRepository:Ch,ThreadRuntimeImpl:Hh,fromThreadMessageLike:Di,generateId:Pr,getAutoStatus:ph,splitLocalRuntimeOptions:Lw,useSmooth:wp,useSmoothStatus:qw,useToolInvocations:u1,withSmoothContextProvider:Hw},Symbol.toStringTag,{value:"Module"}));var Gw=class extends zi{constructor(n){super();Y(this,"useRuntimeHook");Y(this,"instances",new Map);Y(this,"useAliveThreadsKeysChanged",Ra(()=>({})));Y(this,"_InnerActiveThreadProvider",({threadId:n})=>{const{useRuntime:a}=this.useRuntimeHook(),i=a(),s=i.thread.__internal_threadBinding,o=R.useCallback(()=>{const h=this.instances.get(n);if(!h)throw new Error("Thread not found. This is a bug in assistant-ui.");h.runtime=s.getState(),this._notifySubscribers()},[n,s]),c=R.useRef(!1);c.current||o(),R.useEffect(()=>(c.current=!0,o(),s.outerSubscribe(o)),[s,o]);const d=de();return R.useEffect(()=>i.threads.main.unstable_on("initialize",()=>{if(d.threadListItem().getState().status==="new"){d.threadListItem().initialize();const m=i.thread.unstable_on("run-end",()=>{m(),d.threadListItem().generateTitle()})}}),[i,d]),null});Y(this,"_OuterActiveThreadProvider",R.memo(({threadId:n,provider:a})=>E.jsx(fw,{id:n,children:E.jsx(a,{children:E.jsx(this._InnerActiveThreadProvider,{threadId:n})})})));Y(this,"__internal_RenderThreadRuntimes",({provider:n})=>(this.useAliveThreadsKeysChanged(),Array.from(this.instances.keys()).map(a=>E.jsx(this._OuterActiveThreadProvider,{threadId:a,provider:n},a))));this.useRuntimeHook=Ra(()=>({useRuntime:n}))}startThreadRuntime(n){return this.instances.has(n)||(this.instances.set(n,{}),this.useAliveThreadsKeysChanged.setState({},!0)),new Promise((a,i)=>{const s=()=>{const c=this.instances.get(n);if(!c)o(),i(new Error("Thread was deleted before runtime was started"));else if(c.runtime)o(),a(c.runtime);else return},o=this.subscribe(s);s()})}getThreadRuntimeCore(n){const a=this.instances.get(n);if(a)return a.runtime}stopThreadRuntime(n){this.instances.delete(n),this.useAliveThreadsKeysChanged.setState({},!0)}setRuntimeHook(n){this.useRuntimeHook.getState().useRuntime!==n&&this.useRuntimeHook.setState({useRuntime:n},!0)}},he=new Error("This is the empty thread, a placeholder for the main thread. You cannot perform any actions on this thread instance. This error is probably because you tried to call a thread method in your render function. Call the method inside a `useEffect` hook instead."),Pw={getMessageById(){},getBranches(){return[]},switchToBranch(){throw he},append(){throw he},startRun(){throw he},resumeRun(){throw he},cancelRun(){throw he},addToolResult(){throw he},resumeToolCall(){throw he},speak(){throw he},stopSpeaking(){throw he},submitFeedback(){throw he},getModelContext(){return{}},unstable_loadExternalState(){throw he},composer:{attachments:[],attachmentAccept:"*",addAttachment(){return W(this,null,function*(){throw he})},removeAttachment(){return W(this,null,function*(){throw he})},isEditing:!0,canCancel:!1,isEmpty:!0,text:"",setText(){throw he},role:"user",setRole(){throw he},runConfig:{},setRunConfig(){throw he},reset(){return W(this,null,function*(){})},clearAttachments(){return W(this,null,function*(){})},send(){throw he},cancel(){},subscribe(){return()=>{}},unstable_on(){return()=>{}}},getEditComposer(){},beginEdit(){throw he},speech:void 0,capabilities:{switchToBranch:!1,switchBranchDuringRun:!1,edit:!1,reload:!1,cancel:!1,unstable_copy:!1,speech:!1,attachments:!1,feedback:!1},isDisabled:!1,isLoading:!1,messages:[],state:null,suggestions:[],extras:void 0,subscribe(){return()=>{}},import(){throw he},export(){return{messages:[]}},reset(){throw he},unstable_on(){return()=>{}}},_p=(t,n,a)=>a.reduce((i,s)=>{var o;return(o=s==null?void 0:s(i,n))!=null?o:i},t),Xw=class extends zi{constructor(n){super();Y(this,"_pendingTransforms",[]);Y(this,"_baseValue");Y(this,"_cachedValue");this._baseValue=n,this._cachedValue=n}_updateState(){this._cachedValue=this._pendingTransforms.reduce((n,a)=>_p(n,a.task,[a.loading,a.optimistic]),this._baseValue),this._notifySubscribers()}get baseValue(){return this._baseValue}get value(){return this._cachedValue}update(n){this._baseValue=n,this._updateState()}optimisticUpdate(n){return W(this,null,function*(){const a=n.execute(),i=G(_({},n),{task:a});try{this._pendingTransforms.push(i),this._updateState();const s=yield a;return this._baseValue=_p(this._baseValue,s,[n.optimistic,n.then]),s}finally{const s=this._pendingTransforms.indexOf(i);s>-1&&this._pendingTransforms.splice(s,1),this._updateState()}})}};function _O(t){return t}var ps=(t,n)=>{const a=t.threadIdMap[n];if(a!==void 0)return t.threadData[a]},ms=(t,n,a)=>{const i=ps(t,n);if(!i)return t;const{id:s,remoteId:o,status:c}=i;if(c===a)return t;const d=_({},t);switch(c){case"new":d.newThreadId=void 0;break;case"regular":d.threadIds=d.threadIds.filter(h=>h!==s);break;case"archived":d.archivedThreadIds=d.archivedThreadIds.filter(h=>h!==s);break;default:{const h=c;throw new Error(`Unsupported state: ${h}`)}}switch(a){case"regular":d.threadIds=[s,...d.threadIds];break;case"archived":d.archivedThreadIds=[s,...d.archivedThreadIds];break;case"deleted":d.threadData=Object.fromEntries(Object.entries(d.threadData).filter(([h])=>h!==s)),d.threadIdMap=Object.fromEntries(Object.entries(d.threadIdMap).filter(([h])=>h!==s&&h!==o));break;default:{const h=a;throw new Error(`Unsupported state: ${h}`)}}return a!=="deleted"&&(d.threadData=G(_({},d.threadData),{[s]:G(_({},i),{status:a})})),d},Qw=class extends zi{constructor(n,a){super();Y(this,"_options");Y(this,"_hookManager");Y(this,"_loadThreadsPromise");Y(this,"_mainThreadId");Y(this,"_state",new Xw({isLoading:!1,newThreadId:void 0,threadIds:[],archivedThreadIds:[],threadIdMap:{},threadData:{}}));Y(this,"useProvider");Y(this,"initialize",n=>W(this,null,function*(){if(this._state.value.newThreadId!==n){const a=this.getItemById(n);if(!a)throw new Error("Thread not found");if(a.status==="new")throw new Error("Unexpected new state");return a.initializeTask}return this._state.optimisticUpdate({execute:()=>this._options.adapter.initialize(n),optimistic:a=>ms(a,n,"regular"),loading:(a,i)=>{const s=n;return G(_({},a),{threadData:G(_({},a.threadData),{[s]:G(_({},a.threadData[s]),{initializeTask:i})})})},then:(a,{remoteId:i,externalId:s})=>{const o=ps(a,n);if(!o)return a;const c=n;return G(_({},a),{threadIdMap:G(_({},a.threadIdMap),{[i]:c}),threadData:G(_({},a.threadData),{[c]:G(_({},o),{initializeTask:Promise.resolve({remoteId:i,externalId:s}),remoteId:i,externalId:s})})})}})}));Y(this,"generateTitle",n=>W(this,null,function*(){var h;const a=this.getItemById(n);if(!a)throw new Error("Thread not found");if(a.status==="new")throw new Error("Thread is not yet initialized");const{remoteId:i}=yield a.initializeTask,s=this._hookManager.getThreadRuntimeCore(a.id);if(!s)return;const o=s.messages,c=yield this._options.adapter.generateTitle(i,o),d=L0.fromAssistantStream(c);try{for(var m=xa(d),y,g,v;y=!(g=yield m.next()).done;y=!1){const x=g.value;const w=(h=x.parts.filter(D=>D.type==="text")[0])==null?void 0:h.text,z=this._state.baseValue;this._state.update(G(_({},z),{threadData:G(_({},z.threadData),{[a.id]:G(_({},a),{title:w})})}))}}catch(g){v=[g]}finally{try{y&&(g=m.return)&&(yield g.call(m))}finally{if(v)throw v[0]}}}));Y(this,"useBoundIds",Ra(()=>[]));Y(this,"__internal_RenderComponent",()=>{const n=R.useId();R.useEffect(()=>(this.useBoundIds.setState(o=>[...o,n],!0),()=>{this.useBoundIds.setState(o=>o.filter(c=>c!==n),!0)}),[n]);const a=this.useBoundIds(),{Provider:i}=this.useProvider(),s={modelContext:this.contextProvider};return(a.length===0||a[0]===n)&&E.jsx(mo,{adapters:s,children:E.jsx(this._hookManager.__internal_RenderThreadRuntimes,{provider:i})})});this.contextProvider=a,this._state.subscribe(()=>this._notifySubscribers()),this._hookManager=new Gw(n.runtimeHook),this.useProvider=Ra(()=>{var i;return{Provider:(i=n.adapter.unstable_Provider)!=null?i:R.Fragment}}),this.__internal_setOptions(n),this.switchToNewThread()}get threadData(){return this._state.value.threadData}getLoadThreadsPromise(){return this._loadThreadsPromise||(this._loadThreadsPromise=this._state.optimisticUpdate({execute:()=>this._options.adapter.list(),loading:n=>G(_({},n),{isLoading:!0}),then:(n,a)=>{const i=[],s=[],o={},c={};for(const d of a.threads){switch(d.status){case"regular":i.push(d.remoteId);break;case"archived":s.push(d.remoteId);break;default:{const m=d.status;throw new Error(`Unsupported state: ${m}`)}}const h=d.remoteId;o[d.remoteId]=h,c[h]={id:d.remoteId,remoteId:d.remoteId,externalId:d.externalId,status:d.status,title:d.title,initializeTask:Promise.resolve({remoteId:d.remoteId,externalId:d.externalId})}}return G(_({},n),{threadIds:i,archivedThreadIds:s,threadIdMap:_(_({},n.threadIdMap),o),threadData:_(_({},n.threadData),c)})}}).then(()=>{})),this._loadThreadsPromise}__internal_setOptions(n){var i;if(this._options===n)return;this._options=n;const a=(i=n.adapter.unstable_Provider)!=null?i:R.Fragment;a!==this.useProvider.getState().Provider&&this.useProvider.setState({Provider:a},!0),this._hookManager.setRuntimeHook(n.runtimeHook)}__internal_load(){this.getLoadThreadsPromise()}get isLoading(){return this._state.value.isLoading}get threadIds(){return this._state.value.threadIds}get archivedThreadIds(){return this._state.value.archivedThreadIds}get newThreadId(){return this._state.value.newThreadId}get mainThreadId(){return this._mainThreadId}getMainThreadRuntimeCore(){const n=this._hookManager.getThreadRuntimeCore(this._mainThreadId);return n||Pw}getThreadRuntimeCore(n){const a=this.getItemById(n);if(!a)throw new Error("Thread not found");const i=this._hookManager.getThreadRuntimeCore(a.id);if(!i)throw new Error("Thread not found");return i}getItemById(n){return ps(this._state.value,n)}switchToThread(n){return W(this,null,function*(){let a=this.getItemById(n);if(!a){const s=yield this._options.adapter.fetch(n),o=this._state.value,c=s.remoteId,d=G(_({},o.threadData),{[c]:{id:c,initializeTask:Promise.resolve({remoteId:s.remoteId,externalId:s.externalId}),remoteId:s.remoteId,externalId:s.externalId,status:s.status,title:s.title}}),h=G(_({},o.threadIdMap),{[s.remoteId]:c}),m=s.status==="regular"?[...o.threadIds,s.remoteId]:o.threadIds,y=s.status==="archived"?[...o.archivedThreadIds,s.remoteId]:o.archivedThreadIds;this._state.update(G(_({},o),{threadIds:m,archivedThreadIds:y,threadIdMap:h,threadData:d})),a=this.getItemById(n)}if(!a)throw new Error("Thread not found");if(this._mainThreadId===a.id)return;const i=this._hookManager.startThreadRuntime(a.id);this.mainThreadId!==void 0?yield i:i.then(()=>this._notifySubscribers()),a.status==="archived"&&(yield this.unarchive(a.id)),this._mainThreadId=a.id,this._notifySubscribers()})}switchToNewThread(){return W(this,null,function*(){for(;this._state.baseValue.newThreadId!==void 0&&this._state.value.newThreadId===void 0;)yield this._state.waitForUpdate();const n=this._state.value;let a=this._state.value.newThreadId;if(a===void 0){do a=`__LOCALID_${Pr()}`;while(n.threadIdMap[a]);const i=a;this._state.update(G(_({},n),{newThreadId:a,threadIdMap:G(_({},n.threadIdMap),{[a]:i}),threadData:G(_({},n.threadData),{[i]:{status:"new",id:a,remoteId:void 0,externalId:void 0,title:void 0}})}))}return this.switchToThread(a)})}rename(n,a){const i=this.getItemById(n);if(!i)throw new Error("Thread not found");if(i.status==="new")throw new Error("Thread is not yet initialized");return this._state.optimisticUpdate({execute:()=>W(this,null,function*(){const{remoteId:s}=yield i.initializeTask;return this._options.adapter.rename(s,a)}),optimistic:s=>{const o=ps(s,n);return o?G(_({},s),{threadData:G(_({},s.threadData),{[o.id]:G(_({},o),{title:a})})}):s}})}_ensureThreadIsNotMain(n){return W(this,null,function*(){if(n===this.newThreadId)throw new Error("Cannot ensure new thread is not main");n===this._mainThreadId&&(yield this.switchToNewThread())})}archive(n){return W(this,null,function*(){const a=this.getItemById(n);if(!a)throw new Error("Thread not found");if(a.status!=="regular")throw new Error("Thread is not yet initialized or already archived");return this._state.optimisticUpdate({execute:()=>W(this,null,function*(){yield this._ensureThreadIsNotMain(a.id);const{remoteId:i}=yield a.initializeTask;return this._options.adapter.archive(i)}),optimistic:i=>ms(i,a.id,"archived")})})}unarchive(n){const a=this.getItemById(n);if(!a)throw new Error("Thread not found");if(a.status!=="archived")throw new Error("Thread is not archived");return this._state.optimisticUpdate({execute:()=>W(this,null,function*(){try{const{remoteId:i}=yield a.initializeTask;return yield this._options.adapter.unarchive(i)}catch(i){throw yield this._ensureThreadIsNotMain(a.id),i}}),optimistic:i=>ms(i,a.id,"regular")})}delete(n){return W(this,null,function*(){const a=this.getItemById(n);if(!a)throw new Error("Thread not found");if(a.status!=="regular"&&a.status!=="archived")throw new Error("Thread is not yet initialized");return this._state.optimisticUpdate({execute:()=>W(this,null,function*(){yield this._ensureThreadIsNotMain(a.id);const{remoteId:i}=yield a.initializeTask;return yield this._options.adapter.delete(i)}),optimistic:i=>ms(i,a.id,"deleted")})})}detach(n){return W(this,null,function*(){const a=this.getItemById(n);if(!a)throw new Error("Thread not found");if(a.status!=="regular"&&a.status!=="archived")throw new Error("Thread is not yet initialized");yield this._ensureThreadIsNotMain(a.id),this._hookManager.stopThreadRuntime(a.id)})}},Zw=class extends lo{constructor(n){super();Y(this,"threads");this.threads=new Qw(n,this._contextProvider)}get RenderComponent(){return this.threads.__internal_RenderComponent}},Kw=t=>{const[n]=R.useState(()=>new Zw(t));return R.useEffect(()=>{n.threads.__internal_setOptions(t),n.threads.__internal_load()},[n,t]),R.useMemo(()=>new Ro(n),[n])},Tp=t=>{if(fs().threadListItem.source!==null){if(!t.allowNesting)throw new Error("useRemoteThreadListRuntime cannot be nested inside another RemoteThreadListRuntime. Set allowNesting: true to allow nesting (the inner runtime will become a no-op).");return t.runtimeHook()}return Kw(t)},Jw=Symbol.for("react.lazy"),gs=TS[" use ".trim().toString()];function $w(t){return typeof t=="object"&&t!==null&&"then"in t}function Ep(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===Jw&&"_payload"in t&&$w(t._payload)}function Cp(t){const n=Ww(t),a=R.forwardRef((i,s)=>{let m=i,{children:o}=m,c=gt(m,["children"]);Ep(o)&&typeof gs=="function"&&(o=gs(o._payload));const d=R.Children.toArray(o),h=d.find(e_);if(h){const y=h.props.children,g=d.map(v=>v===h?R.Children.count(y)>1?R.Children.only(null):R.isValidElement(y)?y.props.children:null:v);return E.jsx(n,G(_({},c),{ref:s,children:R.isValidElement(y)?R.cloneElement(y,void 0,g):null}))}return E.jsx(n,G(_({},c),{ref:s,children:o}))});return a.displayName=`${t}.Slot`,a}var Ap=Cp("Slot");function Ww(t){const n=R.forwardRef((a,i)=>{let c=a,{children:s}=c,o=gt(c,["children"]);if(Ep(s)&&typeof gs=="function"&&(s=gs(s._payload)),R.isValidElement(s)){const d=r_(s),h=n_(o,s.props);return s.type!==R.Fragment&&(h.ref=i?Jh(i,d):d),R.cloneElement(s,h)}return R.Children.count(s)>1?R.Children.only(null):null});return n.displayName=`${t}.SlotClone`,n}var t_=Symbol("radix.slottable");function e_(t){return R.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===t_}function n_(t,n){const a=_({},n);for(const i in n){const s=t[i],o=n[i];/^on[A-Z]/.test(i)?s&&o?a[i]=(...d)=>{const h=o(...d);return s(...d),h}:s&&(a[i]=s):i==="style"?a[i]=_(_({},s),o):i==="className"&&(a[i]=[s,o].filter(Boolean).join(" "))}return _(_({},t),a)}function r_(t){var i,s;let n=(i=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:i.get,a=n&&"isReactWarning"in n&&n.isReactWarning;return a?t.ref:(n=(s=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:s.get,a=n&&"isReactWarning"in n&&n.isReactWarning,a?t.props.ref:t.props.ref||t.ref)}var a_=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Xn=a_.reduce((t,n)=>{const a=Cp(`Primitive.${n}`),i=R.forwardRef((s,o)=>{const m=s,{asChild:c}=m,d=gt(m,["asChild"]),h=c?a:n;return typeof window!="undefined"&&(window[Symbol.for("radix-ui")]=!0),E.jsx(h,G(_({},d),{ref:o}))});return i.displayName=`Primitive.${n}`,G(_({},t),{[n]:i})},{});function Oa(t,n,{checkForDefaultPrevented:a=!0}={}){return function(s){if(t==null||t(s),a===!1||!s.defaultPrevented)return n==null?void 0:n(s)}}var zo=(t,n,a=[])=>{const i=R.forwardRef((s,o)=>{var m;const c={},d={};Object.keys(s).forEach(y=>{a.includes(y)?c[y]=s[y]:d[y]=s[y]});const h=(m=n(c))!=null?m:void 0;return E.jsx(Xn.button,G(_({type:"button"},d),{ref:o,disabled:d.disabled||!h,onClick:Oa(d.onClick,h)}))});return i.displayName=t,i};function i_(t,n=globalThis==null?void 0:globalThis.document){const a=Kr(t);R.useEffect(()=>{const i=s=>{s.key==="Escape"&&a(s)};return n.addEventListener("keydown",i,{capture:!0}),()=>n.removeEventListener("keydown",i,{capture:!0})},[a,n])}var qi=t=>{const n=R.useRef(void 0);return R.useCallback(i=>{n.current&&n.current(),i&&(n.current=t(i))},[t])},kp=(t,n)=>{const a=R.useCallback(i=>{if(!t)return;const s=t(),o=()=>{const d=n?n(i):i.offsetHeight;s.setHeight(d)},c=new ResizeObserver(o);return c.observe(i),o(),()=>{c.disconnect(),s.unregister()}},[t,n]);return qi(a)},Rp=R.createContext(!1),Mp=(t,n)=>{const a=t.match(/^([\d.]+)(em|px|rem)$/);if(!a)return 0;const i=parseFloat(a[1]),s=a[2];if(s==="px")return i;if(s==="em"){const o=parseFloat(getComputedStyle(n).fontSize)||16;return i*o}if(s==="rem"){const o=parseFloat(getComputedStyle(document.documentElement).fontSize)||16;return i*o}return 0},zp=({children:t,fillClampThreshold:n="10em",fillClampOffset:a="6em"})=>{const i=ne(({message:h})=>h.isLast),s=wo({optional:!0}),o=R.useContext(Rp),c=R.useCallback(h=>{if(!s||o)return;const m=()=>{const y=s.getState();if(y.turnAnchor==="top"&&i){const{viewport:g,inset:v,userMessage:x}=y.height,w=Mp(n,h),z=Mp(a,h),D=x<=w?x:z,k=Math.max(0,g-v-D);h.style.minHeight=`${k}px`,h.style.flexShrink="0",h.style.transition="min-height 0s"}else h.style.minHeight="",h.style.flexShrink="",h.style.transition=""};return m(),s.subscribe(m)},[s,i,o,n,a]),d=qi(c);return E.jsx(Rp.Provider,{value:!0,children:E.jsx(Ap,{ref:d,children:t})})};zp.displayName="ThreadPrimitive.ViewportSlack";var l_=()=>{const t=de(),n=ne(()=>t.message()),a=R.useCallback(i=>{const s=()=>{n.setIsHovering(!0)},o=()=>{n.setIsHovering(!1)};return i.addEventListener("mouseenter",s),i.addEventListener("mouseleave",o),i.matches(":hover")&&n.setIsHovering(!0),()=>{i.removeEventListener("mouseenter",s),i.removeEventListener("mouseleave",o),n.setIsHovering(!1)}},[n]);return qi(a)},s_=()=>{const t=ds(s=>s.turnAnchor),n=ds(s=>s.registerUserMessageHeight),a=ne(({thread:s,message:o})=>{var c;return t==="top"&&o.role==="user"&&o.index===s.messages.length-2&&((c=s.messages.at(-1))==null?void 0:c.role)==="assistant"}),i=R.useCallback(s=>s.offsetHeight,[]);return kp(a?n:null,i)},Oo=R.forwardRef((t,n)=>{const a=l_(),i=s_(),s=cs(n,a,i);return E.jsx(zp,{children:E.jsx(Xn.div,G(_({},t),{ref:s}))})});Oo.displayName="MessagePrimitive.Root";var Op=()=>ne(({part:n})=>{if(n.type!=="text"&&n.type!=="reasoning")throw new Error("MessagePartText can only be used inside text or reasoning message parts.");return n}),Dp=R.forwardRef((s,i)=>{var o=s,{smooth:t=!0,component:n="span"}=o,a=gt(o,["smooth","component"]);const{text:c,status:d}=wp(Op(),t);return E.jsx(n,G(_({"data-status":d.type},a),{ref:i,children:c}))});Dp.displayName="MessagePartPrimitive.Text";var u_=()=>ne(({part:n})=>{if(n.type!=="image")throw new Error("MessagePartImage can only be used inside image message parts.");return n}),Np=R.forwardRef((t,n)=>{const{image:a}=u_();return E.jsx(Xn.img,G(_({src:a},t),{ref:n}))});Np.displayName="MessagePartPrimitive.Image";var Ip=({children:t})=>ne(({part:a})=>a.status.type==="running")?t:null;Ip.displayName="MessagePartPrimitive.InProgress";const jp=t=>Symbol.iterator in t,Lp=t=>"entries"in t,Bp=(t,n)=>{const a=t instanceof Map?t:new Map(t.entries()),i=n instanceof Map?n:new Map(n.entries());if(a.size!==i.size)return!1;for(const[s,o]of a)if(!i.has(s)||!Object.is(o,i.get(s)))return!1;return!0},o_=(t,n)=>{const a=t[Symbol.iterator](),i=n[Symbol.iterator]();let s=a.next(),o=i.next();for(;!s.done&&!o.done;){if(!Object.is(s.value,o.value))return!1;s=a.next(),o=i.next()}return!!s.done&&!!o.done};function c_(t,n){return Object.is(t,n)?!0:typeof t!="object"||t===null||typeof n!="object"||n===null||Object.getPrototypeOf(t)!==Object.getPrototypeOf(n)?!1:jp(t)&&jp(n)?Lp(t)&&Lp(n)?Bp(t,n):o_(t,n):Bp({entries:()=>Object.entries(t)},{entries:()=>Object.entries(n)})}function f_(t){const n=nn.useRef(void 0);return a=>{const i=t(a);return c_(n.current,i)?n.current:n.current=i}}var Up=t=>{let n=-1;return{startGroup:a=>{n===-1&&(n=a)},endGroup:(a,i)=>{n!==-1&&(i.push({type:t,startIndex:n,endIndex:a}),n=-1)},finalize:(a,i)=>{n!==-1&&i.push({type:t,startIndex:n,endIndex:a})}}},d_=t=>{const n=[],a=Up("toolGroup"),i=Up("reasoningGroup");for(let s=0;s<t.length;s++){const o=t[s];o==="tool-call"?(i.endGroup(s-1,n),a.startGroup(s)):o==="reasoning"?(a.endGroup(s-1,n),i.startGroup(s)):(a.endGroup(s-1,n),i.endGroup(s-1,n),n.push({type:"single",index:s}))}return a.finalize(t.length-1,n),i.finalize(t.length-1,n),n},h_=()=>{const t=ne(f_(n=>n.message.parts.map(a=>a.type)));return R.useMemo(()=>t.length===0?[]:d_(t),[t])},p_=a=>{var i=a,{Fallback:t}=i,n=gt(i,["Fallback"]);const s=ne(({tools:o})=>{var d,h;const c=(d=o.tools[n.toolName])!=null?d:t;return Array.isArray(c)?(h=c[0])!=null?h:t:c});return s?E.jsx(s,_({},n)):null},Qn={Text:()=>E.jsxs("p",{style:{whiteSpace:"pre-line"},children:[E.jsx(Dp,{}),E.jsx(Ip,{children:E.jsx("span",{style:{fontFamily:"revert"},children:" ●"})})]}),Reasoning:()=>null,Source:()=>null,Image:()=>E.jsx(Np,{}),File:()=>null,Unstable_Audio:()=>null,ToolGroup:({children:t})=>t,ReasoningGroup:({children:t})=>t},m_=({components:{Text:t=Qn.Text,Reasoning:n=Qn.Reasoning,Image:a=Qn.Image,Source:i=Qn.Source,File:s=Qn.File,Unstable_Audio:o=Qn.Unstable_Audio,tools:c={}}={}})=>{var y,g,v;const d=de(),h=ne(({part:x})=>x),m=h.type;if(m==="tool-call"){const x=d.part().addToolResult,w=d.part().resumeToolCall;if("Override"in c)return E.jsx(c.Override,G(_({},h),{addResult:x,resume:w}));const z=(g=(y=c.by_name)==null?void 0:y[h.toolName])!=null?g:c.Fallback;return E.jsx(p_,G(_({},h),{Fallback:z,addResult:x,resume:w}))}if(((v=h.status)==null?void 0:v.type)==="requires-action")throw new Error("Encountered unexpected requires-action status");switch(m){case"text":return E.jsx(t,_({},h));case"reasoning":return E.jsx(n,_({},h));case"source":return E.jsx(i,_({},h));case"image":return E.jsx(a,_({},h));case"file":return E.jsx(s,_({},h));case"audio":return E.jsx(o,_({},h));case"data":return null;default:const x=m;throw new Error(`Unknown message part type: ${x}`)}},ys=R.memo(({index:t,components:n})=>E.jsx(hw,{index:t,children:E.jsx(m_,{components:n})}),(t,n)=>{var a,i,s,o,c,d,h,m,y,g,v,x,w,z,D,k,q,I;return t.index===n.index&&((a=t.components)==null?void 0:a.Text)===((i=n.components)==null?void 0:i.Text)&&((s=t.components)==null?void 0:s.Reasoning)===((o=n.components)==null?void 0:o.Reasoning)&&((c=t.components)==null?void 0:c.Source)===((d=n.components)==null?void 0:d.Source)&&((h=t.components)==null?void 0:h.Image)===((m=n.components)==null?void 0:m.Image)&&((y=t.components)==null?void 0:y.File)===((g=n.components)==null?void 0:g.File)&&((v=t.components)==null?void 0:v.Unstable_Audio)===((x=n.components)==null?void 0:x.Unstable_Audio)&&((w=t.components)==null?void 0:w.tools)===((z=n.components)==null?void 0:z.tools)&&((D=t.components)==null?void 0:D.ToolGroup)===((k=n.components)==null?void 0:k.ToolGroup)&&((q=t.components)==null?void 0:q.ReasoningGroup)===((I=n.components)==null?void 0:I.ReasoningGroup)});ys.displayName="MessagePrimitive.PartByIndex";var g_=({status:t,component:n})=>E.jsx(mw,{text:"",isRunning:t.type==="running",children:E.jsx(n,{type:"text",text:"",status:t})}),y_=Object.freeze({type:"complete"}),b_=({components:t})=>{var a;const n=ne(i=>{var s;return(s=i.message.status)!=null?s:y_});return t!=null&&t.Empty?E.jsx(t.Empty,{status:n}):E.jsx(g_,{status:n,component:(a=t==null?void 0:t.Text)!=null?a:Qn.Text})},v_=R.memo(b_,(t,n)=>{var a,i,s,o;return((a=t.components)==null?void 0:a.Empty)===((i=n.components)==null?void 0:i.Empty)&&((s=t.components)==null?void 0:s.Text)===((o=n.components)==null?void 0:o.Text)}),Do=({components:t})=>{const n=ne(({message:s})=>s.parts.length),a=h_(),i=R.useMemo(()=>n===0?E.jsx(v_,{components:t}):a.map(s=>{var o,c;if(s.type==="single")return E.jsx(ys,{index:s.index,components:t},s.index);if(s.type==="toolGroup"){const d=(o=t.ToolGroup)!=null?o:Qn.ToolGroup;return E.jsx(d,{startIndex:s.startIndex,endIndex:s.endIndex,children:Array.from({length:s.endIndex-s.startIndex+1},(h,m)=>E.jsx(ys,{index:s.startIndex+m,components:t},m))},`tool-${s.startIndex}`)}else{const d=(c=t.ReasoningGroup)!=null?c:Qn.ReasoningGroup;return E.jsx(d,{startIndex:s.startIndex,endIndex:s.endIndex,children:Array.from({length:s.endIndex-s.startIndex+1},(h,m)=>E.jsx(ys,{index:s.startIndex+m,components:t},m))},`reasoning-${s.startIndex}`)}}),[a,t,n]);return E.jsx(E.Fragment,{children:i})};Do.displayName="MessagePrimitive.Parts";var Hp=()=>{const t=de(),n=ne(i=>i.thread.isRunning||!i.composer.isEditing||i.composer.isEmpty),a=R.useCallback(()=>{t.composer().send()},[t]);return n?null:a},x_=zo("ComposerPrimitive.Send",Hp),qp=R.forwardRef((i,a)=>{var s=i,{onSubmit:t}=s,n=gt(s,["onSubmit"]);const o=Hp(),c=d=>{d.preventDefault(),o&&o()};return E.jsx(Xn.form,G(_({},n),{ref:a,onSubmit:Oa(t,c)}))});qp.displayName="ComposerPrimitive.Root";function No(){return No=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var a=arguments[n];for(var i in a)({}).hasOwnProperty.call(a,i)&&(t[i]=a[i])}return t},No.apply(null,arguments)}function S_(t,n){if(t==null)return{};var a={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(n.indexOf(i)!==-1)continue;a[i]=t[i]}return a}var w_=R.useLayoutEffect,__=function(n){var a=nn.useRef(n);return w_(function(){a.current=n}),a},Vp=function(n,a){if(typeof n=="function"){n(a);return}n.current=a},T_=function(n,a){var i=nn.useRef();return nn.useCallback(function(s){n.current=s,i.current&&Vp(i.current,null),i.current=a,a&&Vp(a,s)},[a])},Yp={"min-height":"0","max-height":"none",height:"0",visibility:"hidden",overflow:"hidden",position:"absolute","z-index":"-1000",top:"0",right:"0",display:"block"},E_=function(n){Object.keys(Yp).forEach(function(a){n.style.setProperty(a,Yp[a],"important")})},Fp=E_,Le=null,Gp=function(n,a){var i=n.scrollHeight;return a.sizingStyle.boxSizing==="border-box"?i+a.borderSize:i-a.paddingSize};function C_(t,n,a,i){a===void 0&&(a=1),i===void 0&&(i=1/0),Le||(Le=document.createElement("textarea"),Le.setAttribute("tabindex","-1"),Le.setAttribute("aria-hidden","true"),Fp(Le)),Le.parentNode===null&&document.body.appendChild(Le);var s=t.paddingSize,o=t.borderSize,c=t.sizingStyle,d=c.boxSizing;Object.keys(c).forEach(function(v){var x=v;Le.style[x]=c[x]}),Fp(Le),Le.value=n;var h=Gp(Le,t);Le.value=n,h=Gp(Le,t),Le.value="x";var m=Le.scrollHeight-s,y=m*a;d==="border-box"&&(y=y+s+o),h=Math.max(y,h);var g=m*i;return d==="border-box"&&(g=g+s+o),h=Math.min(g,h),[h,m]}var Pp=function(){},A_=function(n,a){return n.reduce(function(i,s){return i[s]=a[s],i},{})},k_=["borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","boxSizing","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textRendering","textTransform","width","wordBreak","wordSpacing","scrollbarGutter"],R_=!!document.documentElement.currentStyle,M_=function(n){var a=window.getComputedStyle(n);if(a===null)return null;var i=A_(k_,a),s=i.boxSizing;if(s==="")return null;R_&&s==="border-box"&&(i.width=parseFloat(i.width)+parseFloat(i.borderRightWidth)+parseFloat(i.borderLeftWidth)+parseFloat(i.paddingRight)+parseFloat(i.paddingLeft)+"px");var o=parseFloat(i.paddingBottom)+parseFloat(i.paddingTop),c=parseFloat(i.borderBottomWidth)+parseFloat(i.borderTopWidth);return{sizingStyle:i,paddingSize:o,borderSize:c}},z_=M_;function Io(t,n,a){var i=__(a);R.useLayoutEffect(function(){var s=function(c){return i.current(c)};if(t)return t.addEventListener(n,s),function(){return t.removeEventListener(n,s)}},[])}var O_=function(n,a){Io(document.body,"reset",function(i){n.current.form===i.target&&a(i)})},D_=function(n){Io(window,"resize",n)},N_=function(n){Io(document.fonts,"loadingdone",n)},I_=["cacheMeasurements","maxRows","minRows","onChange","onHeightChange"],j_=function(n,a){var i=n.cacheMeasurements,s=n.maxRows,o=n.minRows,c=n.onChange,d=c===void 0?Pp:c,h=n.onHeightChange,m=h===void 0?Pp:h,y=S_(n,I_),g=y.value!==void 0,v=R.useRef(null),x=T_(v,a),w=R.useRef(0),z=R.useRef(),D=function(){var I=v.current,at=i&&z.current?z.current:z_(I);if(at){z.current=at;var lt=C_(at,I.value||I.placeholder||"x",o,s),L=lt[0],J=lt[1];w.current!==L&&(w.current=L,I.style.setProperty("height",L+"px","important"),m(L,{rowHeight:J}))}},k=function(I){g||D(),d(I)};return R.useLayoutEffect(D),O_(v,function(){if(!g){var q=v.current.value;requestAnimationFrame(function(){var I=v.current;I&&q!==I.value&&D()})}}),D_(D),N_(D),R.createElement("textarea",No({},y,{onChange:k,ref:x}))},L_=R.forwardRef(j_),Xp=t=>{const n=Kr(t),a=ds(i=>i.onScrollToBottom);R.useEffect(()=>a(n),[a,n])},Qp=R.forwardRef((w,x)=>{var z=w,{autoFocus:t=!1,asChild:n,disabled:a,onChange:i,onKeyDown:s,onPaste:o,submitOnEnter:c=!0,cancelOnEscape:d=!0,unstable_focusOnRunStart:h=!0,unstable_focusOnScrollToBottom:m=!0,unstable_focusOnThreadSwitched:y=!0,addAttachmentOnPaste:g=!0}=z,v=gt(z,["autoFocus","asChild","disabled","onChange","onKeyDown","onPaste","submitOnEnter","cancelOnEscape","unstable_focusOnRunStart","unstable_focusOnScrollToBottom","unstable_focusOnThreadSwitched","addAttachmentOnPaste"]);const D=de(),k=ne(({composer:j})=>j.isEditing?j.text:""),q=n?Ap:L_,I=ne(({thread:j})=>j.isDisabled)||a,at=R.useRef(null),lt=cs(x,at);i_(j=>{if(!d)return;const tt=D.composer();tt.getState().canCancel&&(tt.cancel(),j.preventDefault())});const L=j=>{var tt,$;I||!c||j.nativeEvent.isComposing||j.key==="Enter"&&j.shiftKey===!1&&(D.thread().getState().isRunning||(j.preventDefault(),($=(tt=at.current)==null?void 0:tt.closest("form"))==null||$.requestSubmit()))},J=j=>W(null,null,function*(){var bt;if(!g)return;const tt=D.thread().getState().capabilities,$=Array.from(((bt=j.clipboardData)==null?void 0:bt.files)||[]);if(tt.attachments&&$.length>0)try{j.preventDefault(),yield Promise.all($.map(ot=>D.composer().addAttachment(ot)))}catch(ot){console.error("Error adding attachment:",ot)}}),st=t&&!I,ct=R.useCallback(()=>{const j=at.current;!j||!st||(j.focus({preventScroll:!0}),j.setSelectionRange(j.value.length,j.value.length))},[st]);return R.useEffect(()=>ct(),[ct]),Xp(()=>{D.composer().getState().type==="thread"&&m&&ct()}),R.useEffect(()=>{if(!(D.composer().getState().type!=="thread"||!h))return D.on("thread.run-start",ct)},[h,ct,D]),R.useEffect(()=>{if(!(D.composer().getState().type!=="thread"||!y))return D.on("thread-list-item.switched-to",ct)},[y,ct,D]),E.jsx(q,G(_({name:"input",value:k},v),{ref:lt,disabled:I,onChange:Oa(i,j=>{D.composer().getState().isEditing&&(D.composer().setText(j.target.value),D.flushSync())}),onKeyDown:Oa(s,L),onPaste:Oa(o,J)}))});Qp.displayName="ComposerPrimitive.Input";var Zp=R.forwardRef((t,n)=>E.jsx(Xn.div,G(_({},t),{ref:n})));Zp.displayName="ThreadPrimitive.Root";var Kp=({children:t})=>ne(({thread:a})=>a.messages.length===0&&!a.isLoading)?t:null;Kp.displayName="ThreadPrimitive.Empty";var B_=t=>ne(({thread:n})=>{const a=n.messages.length===0&&!n.isLoading;return!(t.empty===!0&&!a||t.empty===!1&&a||t.running===!0&&!n.isRunning||t.running===!1&&n.isRunning||t.disabled===!0&&!n.isDisabled||t.disabled===!1&&n.isDisabled)}),Jp=a=>{var i=a,{children:t}=i,n=gt(i,["children"]);return B_(n)?t:null};Jp.displayName="ThreadPrimitive.If";var U_=t=>{const n=Kr(t),a=R.useCallback(i=>{const s=new ResizeObserver(()=>{n()}),o=new MutationObserver(()=>{n()});return s.observe(i),o.observe(i,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),()=>{s.disconnect(),o.disconnect()}},[n]);return qi(a)},H_=({autoScroll:t})=>{const n=R.useRef(null),a=wo();t===void 0&&(t=a.getState().turnAnchor!=="top");const i=R.useRef(0),s=R.useRef(null),o=R.useCallback(y=>{const g=n.current;g&&(s.current=y,g.scrollTo({top:g.scrollHeight,behavior:y}))},[]),c=()=>{const y=n.current;if(!y)return;const g=a.getState().isAtBottom,v=Math.abs(y.scrollHeight-y.scrollTop-y.clientHeight)<1||y.scrollHeight<=y.clientHeight;!v&&i.current<y.scrollTop||(v&&(s.current=null),v!==g&&Hi(a).setState({isAtBottom:v})),i.current=y.scrollTop},d=U_(()=>{const y=s.current;y?o(y):t&&a.getState().isAtBottom&&o("instant"),c()}),h=qi(y=>(y.addEventListener("scroll",c),()=>{y.removeEventListener("scroll",c)}));return Xp(({behavior:y})=>{o(y)}),q1("thread.run-start",()=>{s.current="auto",requestAnimationFrame(()=>{o("auto")})}),cs(d,h,n)},q_=()=>{const t=ds(a=>a.registerViewport),n=R.useCallback(a=>a.clientHeight-parseFloat(getComputedStyle(a).paddingTop),[]);return kp(t,n)},$p=R.forwardRef((s,i)=>{var o=s,{autoScroll:t,children:n}=o,a=gt(o,["autoScroll","children"]);const c=H_({autoScroll:t}),d=q_(),h=cs(i,c,d);return E.jsx(Xn.div,G(_({},a),{ref:h,children:n}))});$p.displayName="ThreadPrimitive.ViewportScrollable";var Wp=R.forwardRef((i,a)=>{var s=i,{turnAnchor:t}=s,n=gt(s,["turnAnchor"]);return E.jsx(dp,{options:{turnAnchor:t},children:E.jsx($p,G(_({},n),{ref:a}))})});Wp.displayName="ThreadPrimitive.Viewport";var tm=(t,n)=>t.Message===n.Message&&t.EditComposer===n.EditComposer&&t.UserEditComposer===n.UserEditComposer&&t.AssistantEditComposer===n.AssistantEditComposer&&t.SystemEditComposer===n.SystemEditComposer&&t.UserMessage===n.UserMessage&&t.AssistantMessage===n.AssistantMessage&&t.SystemMessage===n.SystemMessage,V_=()=>null,Y_=(t,n,a)=>{var i,s,o,c,d,h,m,y,g,v,x,w;switch(n){case"user":return a?(o=(s=(i=t.UserEditComposer)!=null?i:t.EditComposer)!=null?s:t.UserMessage)!=null?o:t.Message:(c=t.UserMessage)!=null?c:t.Message;case"assistant":return a?(m=(h=(d=t.AssistantEditComposer)!=null?d:t.EditComposer)!=null?h:t.AssistantMessage)!=null?m:t.Message:(y=t.AssistantMessage)!=null?y:t.Message;case"system":return a?(x=(v=(g=t.SystemEditComposer)!=null?g:t.EditComposer)!=null?v:t.SystemMessage)!=null?x:t.Message:(w=t.SystemMessage)!=null?w:V_;default:const z=n;throw new Error(`Unknown message role: ${z}`)}},F_=({components:t})=>{const n=ne(({message:s})=>s.role),a=ne(({message:s})=>s.composer.isEditing),i=Y_(t,n,a);return E.jsx(i,{})},em=R.memo(({index:t,components:n})=>E.jsx(dw,{index:t,children:E.jsx(F_,{components:n})}),(t,n)=>t.index===n.index&&tm(t.components,n.components));em.displayName="ThreadPrimitive.MessageByIndex";var nm=({components:t})=>{const n=ne(({thread:i})=>i.messages.length);return R.useMemo(()=>n===0?null:Array.from({length:n},(i,s)=>E.jsx(em,{index:s,components:t},s)),[n,t])};nm.displayName="ThreadPrimitive.Messages";var G_=R.memo(nm,(t,n)=>tm(t.components,n.components)),rm=R.forwardRef((s,i)=>{var o=s,{onClick:t,disabled:n}=o,a=gt(o,["onClick","disabled"]);const c=ne(({threads:h})=>h.newThreadId===h.mainThreadId),d=de();return E.jsx(Xn.button,G(_(_({type:"button"},c?{"data-active":"true","aria-current":"true"}:null),a),{ref:i,disabled:n,onClick:Oa(t,()=>{d.threads().switchToNewThread()})}))});rm.displayName="ThreadListPrimitive.New";var am=R.memo(({index:t,archived:n=!1,components:a})=>{const i=a.ThreadListItem;return E.jsx(cw,{index:t,archived:n,children:E.jsx(i,{})})},(t,n)=>t.index===n.index&&t.archived===n.archived&&t.components.ThreadListItem===n.components.ThreadListItem);am.displayName="ThreadListPrimitive.ItemByIndex";var im=({archived:t=!1,components:n})=>{const a=ne(({threads:s})=>t?s.archivedThreadIds.length:s.threadIds.length);return R.useMemo(()=>Array.from({length:a},(s,o)=>E.jsx(am,{index:o,archived:t,components:n},o)),[a,t,n])};im.displayName="ThreadListPrimitive.Items";var lm=R.forwardRef((t,n)=>E.jsx(Xn.div,G(_({},t),{ref:n})));lm.displayName="ThreadListPrimitive.Root";var sm=R.forwardRef((t,n)=>{const a=ne(({threads:i,threadListItem:s})=>i.mainThreadId===s.id);return E.jsx(Xn.div,G(_(_({},a?{"data-active":"true","aria-current":"true"}:null),t),{ref:n}))});sm.displayName="ThreadListItemPrimitive.Root";var P_=()=>{const t=de();return R.useCallback(()=>{t.threadListItem().delete()},[t])},X_=zo("ThreadListItemPrimitive.Delete",P_),Q_=()=>{const t=de();return R.useCallback(()=>{t.threadListItem().switchTo()},[t])},Z_=zo("ThreadListItemPrimitive.Trigger",Q_);class um{constructor(n,a,i=!1){Y(this,"baseUrl");Y(this,"sessionToken",null);Y(this,"isProxyMode",!1);this.baseUrl=n.replace(/\/$/,""),this.isProxyMode=i,a&&(this.sessionToken=a)}setSessionToken(n){this.sessionToken=n}getUrl(n){if(this.isProxyMode){const a=`${this.baseUrl}${n.replace("/v1","")}`;return a.startsWith("/")||a.startsWith("./"),a}return`${this.baseUrl}${n}`}createOrContinueChat(n,a){return W(this,null,function*(){const i=this.getUrl("/v1/chats"),o={"Content-Type":"application/json","Idempotency-Key":this.generateIdempotencyKey()};this.sessionToken&&(o.Authorization=`Bearer ${this.sessionToken}`);const c=G(_({},n),{stream:!0}),d=yield fetch(i,{method:"POST",headers:o,body:JSON.stringify(c),signal:a});if(!d.ok){const h=yield d.json().catch(()=>({}));throw new Error(h.detail||h.message||`API error: ${d.status} ${d.statusText}`)}if(!d.body)throw new Error("Response body is null");return d.body})}getChat(n){return W(this,null,function*(){const a=this.getUrl(`/v1/chats/${n}`),i={"Content-Type":"application/json"};this.sessionToken&&(i.Authorization=`Bearer ${this.sessionToken}`);const s=yield fetch(a,{method:"GET",headers:i});if(!s.ok){const o=yield s.json().catch(()=>({}));throw new Error(o.detail||o.message||`API error: ${s.status} ${s.statusText}`)}return s.json()})}listChats(n){return W(this,null,function*(){const a=this.getUrl("/v1/chats"),i=a.startsWith("/")||a.startsWith("./")?new URL(a,window.location.origin):new URL(a);n!=null&&n.limit&&i.searchParams.set("limit",n.limit.toString()),n!=null&&n.cursor&&i.searchParams.set("cursor",n.cursor),n!=null&&n["expand[]"]&&n["expand[]"].forEach(c=>{i.searchParams.append("expand[]",c)});const s={"Content-Type":"application/json"};this.sessionToken&&(s.Authorization=`Bearer ${this.sessionToken}`);const o=yield fetch(i.toString(),{method:"GET",headers:s});if(!o.ok){const c=yield o.json().catch(()=>({}));throw new Error(c.detail||c.message||`API error: ${o.status} ${o.statusText}`)}return o.json()})}generateIdempotencyKey(){try{if(typeof crypto!="undefined"&&crypto.randomUUID)return crypto.randomUUID()}catch(i){}const n=i=>Array.from({length:i},()=>Math.floor(Math.random()*16).toString(16)).join(""),a=()=>{const i=["8","9","a","b"];return i[Math.floor(Math.random()*i.length)]};return`${n(8)}-${n(4)}-4${n(3)}-${a()}${n(3)}-${n(12)}`}updateChat(n,a){return W(this,null,function*(){const i=`/v1/chats/${n}`,s=this.getUrl(i),o=s.startsWith("/")||s.startsWith("./")?new URL(s,window.location.origin):new URL(s),d={"Content-Type":"application/json","Idempotency-Key":this.generateIdempotencyKey()};this.sessionToken&&(d.Authorization=`Bearer ${this.sessionToken}`);const h=yield fetch(o.toString(),{method:"PATCH",headers:d,body:JSON.stringify(a)});if(!h.ok){const y=yield h.text();let g={};try{g=JSON.parse(y)}catch(v){g={detail:y}}throw new Error(g.detail||g.message||`API error: ${h.status} ${h.statusText}`)}if(h.status===204)return{};const m=yield h.text();if(!m)return{};try{return JSON.parse(m)}catch(y){return{}}})}deleteChat(n){return W(this,null,function*(){const a=`/v1/chats/${n}`,i=this.getUrl(a),s=i.startsWith("/")||i.startsWith("./")?new URL(i,window.location.origin):new URL(i),c={"Content-Type":"application/json","Idempotency-Key":this.generateIdempotencyKey()};this.sessionToken&&(c.Authorization=`Bearer ${this.sessionToken}`);const d=yield fetch(s.toString(),{method:"DELETE",headers:c});if(!d.ok){const h=yield d.json().catch(()=>({}));throw new Error(h.detail||h.message||`API error: ${d.status} ${d.statusText}`)}})}listModels(n){return W(this,null,function*(){const a=this.getUrl("/v1/models"),i=a.startsWith("/")||a.startsWith("./")?new URL(a,window.location.origin):new URL(a);n!=null&&n.limit&&i.searchParams.set("limit",n.limit.toString()),n!=null&&n.cursor&&i.searchParams.set("cursor",n.cursor),n!=null&&n["expand[]"]&&n["expand[]"].forEach(c=>{i.searchParams.append("expand[]",c)});const s={"Content-Type":"application/json"};this.sessionToken&&(s.Authorization=`Bearer ${this.sessionToken}`);const o=yield fetch(i.toString(),{method:"GET",headers:s});if(!o.ok){const c=yield o.json().catch(()=>({}));throw new Error(c.detail||c.message||`API error: ${o.status} ${o.statusText}`)}return o.json()})}getModel(n){return W(this,null,function*(){const a=this.getUrl(`/v1/models/${n}`),i={"Content-Type":"application/json"};this.sessionToken&&(i.Authorization=`Bearer ${this.sessionToken}`);const s=yield fetch(a,{method:"GET",headers:i});if(!s.ok){const o=yield s.json().catch(()=>({}));throw new Error(o.detail||o.message||`API error: ${s.status} ${s.statusText}`)}return s.json()})}}function K_(t,n){return Kl(this,null,function*(){const a=t.getReader(),i=new TextDecoder;let s="";try{for(;;){if(n!=null&&n.aborted){a.cancel();break}const{done:o,value:c}=yield new gr(a.read());if(o)break;s+=i.decode(c,{stream:!0});const d=s.split(`
5
+ `),ss=class{constructor(e){this._core=e,this.__internal_bindMethods()}get path(){return this._core.path}__internal_bindMethods(){this.getState=this.getState.bind(this),this.remove=this.remove.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this._core.getState()}subscribe(e){return this._core.subscribe(e)}},as=class extends ss{constructor(e,t){super(e),this._composerApi=t}remove(){const e=this._composerApi.getState();if(!e)throw new Error("Composer is not available");return e.removeAttachment(this.getState().id)}},Hu=class extends as{get source(){return"thread-composer"}},qu=class extends as{get source(){return"edit-composer"}},Vu=class extends ss{get source(){return"message"}constructor(e){super(e)}remove(){throw new Error("Message attachments cannot be removed")}},os=class extends _r{constructor(e){super(),this.config=e}getState(){return this.config.binding.getState()}outerSubscribe(e){return this.config.binding.subscribe(e)}_connect(){const e=()=>{this.notifySubscribers()};let t=this.config.binding.getState(),r=t==null?void 0:t.unstable_on(this.config.event,e);const n=()=>{var a;const s=this.config.binding.getState();s!==t&&(t=s,r==null||r(),r=(a=this.config.binding.getState())==null?void 0:a.unstable_on(this.config.event,e))},i=this.outerSubscribe(n);return()=>{i==null||i(),r==null||r()}}},ls=Object.freeze([]),us=Object.freeze({}),Wu=e=>{var t,r,n,i,s,a,o,l,u;return Object.freeze({type:"thread",isEditing:(t=e==null?void 0:e.isEditing)!=null?t:!1,canCancel:(r=e==null?void 0:e.canCancel)!=null?r:!1,isEmpty:(n=e==null?void 0:e.isEmpty)!=null?n:!0,attachments:(i=e==null?void 0:e.attachments)!=null?i:ls,text:(s=e==null?void 0:e.text)!=null?s:"",role:(a=e==null?void 0:e.role)!=null?a:"user",runConfig:(o=e==null?void 0:e.runConfig)!=null?o:us,attachmentAccept:(l=e==null?void 0:e.attachmentAccept)!=null?l:"",value:(u=e==null?void 0:e.text)!=null?u:""})},Ju=e=>{var t,r,n,i,s,a,o,l,u;return Object.freeze({type:"edit",isEditing:(t=e==null?void 0:e.isEditing)!=null?t:!1,canCancel:(r=e==null?void 0:e.canCancel)!=null?r:!1,isEmpty:(n=e==null?void 0:e.isEmpty)!=null?n:!0,text:(i=e==null?void 0:e.text)!=null?i:"",role:(s=e==null?void 0:e.role)!=null?s:"user",attachments:(a=e==null?void 0:e.attachments)!=null?a:ls,runConfig:(o=e==null?void 0:e.runConfig)!=null?o:us,attachmentAccept:(l=e==null?void 0:e.attachmentAccept)!=null?l:"",value:(u=e==null?void 0:e.text)!=null?u:""})},cs=class{constructor(e){T(this,"_eventSubscriptionSubjects",new Map);this._core=e}get path(){return this._core.path}__internal_bindMethods(){this.setText=this.setText.bind(this),this.setRunConfig=this.setRunConfig.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.addAttachment=this.addAttachment.bind(this),this.reset=this.reset.bind(this),this.clearAttachments=this.clearAttachments.bind(this),this.send=this.send.bind(this),this.cancel=this.cancel.bind(this),this.setRole=this.setRole.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.unstable_on=this.unstable_on.bind(this)}setText(e){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.setText(e)}setRunConfig(e){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.setRunConfig(e)}addAttachment(e){const t=this._core.getState();if(!t)throw new Error("Composer is not available");return t.addAttachment(e)}reset(){const e=this._core.getState();if(!e)throw new Error("Composer is not available");return e.reset()}clearAttachments(){const e=this._core.getState();if(!e)throw new Error("Composer is not available");return e.clearAttachments()}send(){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.send()}cancel(){const e=this._core.getState();if(!e)throw new Error("Composer is not available");e.cancel()}setRole(e){const t=this._core.getState();if(!t)throw new Error("Composer is not available");t.setRole(e)}subscribe(e){return this._core.subscribe(e)}unstable_on(e,t){let r=this._eventSubscriptionSubjects.get(e);return r||(r=new os({event:e,binding:this._core}),this._eventSubscriptionSubjects.set(e,r)),r.subscribe(t)}},Gu=class extends cs{constructor(t){const r=new yn({path:t.path,getState:()=>Wu(t.getState()),subscribe:n=>t.subscribe(n)});super({path:t.path,getState:()=>t.getState(),subscribe:n=>r.subscribe(n)});T(this,"_getState");this._getState=r.getState.bind(r),this.__internal_bindMethods()}get path(){return this._core.path}get type(){return"thread"}getState(){return this._getState()}getAttachmentByIndex(t){return new Hu(new $e({path:E(m({},this.path),{attachmentSource:"thread-composer",attachmentSelector:{type:"index",index:t},ref:`${this.path.ref}${this.path.ref}.attachments[${t}]`}),getState:()=>{const n=this.getState().attachments[t];return n?E(m({},n),{source:"thread-composer"}):Ue},subscribe:r=>this._core.subscribe(r)}),this._core)}},Yu=class extends cs{constructor(t,r){const n=new yn({path:t.path,getState:()=>Ju(t.getState()),subscribe:i=>t.subscribe(i)});super({path:t.path,getState:()=>t.getState(),subscribe:i=>n.subscribe(i)});T(this,"_getState");this._beginEdit=r,this._getState=n.getState.bind(n),this.__internal_bindMethods()}get path(){return this._core.path}get type(){return"edit"}__internal_bindMethods(){super.__internal_bindMethods(),this.beginEdit=this.beginEdit.bind(this)}getState(){return this._getState()}beginEdit(){this._beginEdit()}getAttachmentByIndex(t){return new qu(new $e({path:E(m({},this.path),{attachmentSource:"edit-composer",attachmentSelector:{type:"index",index:t},ref:`${this.path.ref}${this.path.ref}.attachments[${t}]`}),getState:()=>{const n=this.getState().attachments[t];return n?E(m({},n),{source:"edit-composer"}):Ue},subscribe:r=>this._core.subscribe(r)}),this._core)}},Ku=class on{constructor(t=null){T(this,"_state");this._state=t}get state(){return this._state}append(t){this._state=t.reduce((r,n)=>on.apply(r,n),this._state)}static apply(t,r){const n=r.type;switch(n){case"set":return on.updatePath(t,r.path,()=>r.value);case"append-text":return on.updatePath(t,r.path,i=>{if(typeof i!="string")throw new Error(`Expected string at path [${r.path.join(", ")}]`);return i+r.value});default:{const i=n;throw new Error(`Invalid operation type: ${i}`)}}}static updatePath(t,r,n){if(r.length===0)return n(t);if(t!=null||(t={}),typeof t!="object")throw new Error(`Invalid path: [${r.join(", ")}]`);const[i,...s]=r;if(Array.isArray(t)){const o=Number(i);if(Number.isNaN(o))throw new Error(`Expected array index at [${r.join(", ")}]`);if(o>t.length||o<0)throw new Error("Insert array index out of bounds");const l=[...t];return l[o]=this.updatePath(l[o],s,n),l}const a=m({},t);return a[i]=this.updatePath(a[i],s,n),a}},Xu=({unstable_state:e=null}={})=>({role:"assistant",status:{type:"running"},parts:[],get content(){return this.parts},metadata:{unstable_state:e,unstable_data:[],unstable_annotations:[],steps:[],custom:{}}}),Er=(e,t,r)=>{if(e.parts.length===0)throw new Error("No parts available to update.");if(t.path.length!==1)throw new Error("Nested paths are not supported yet.");const n=t.path[0],i=r(e.parts[n]);return E(m({},e),{parts:[...e.parts.slice(0,n),i,...e.parts.slice(n+1)],get content(){return this.parts}})},Qu=(e,t)=>{const r=t.part;if(r.type==="text"||r.type==="reasoning"){const n=m({type:r.type,text:"",status:{type:"running"}},r.parentId&&{parentId:r.parentId});return E(m({},e),{parts:[...e.parts,n],get content(){return this.parts}})}else if(r.type==="tool-call"){const n=m({type:"tool-call",state:"partial-call",status:{type:"running",isArgsComplete:!1},toolCallId:r.toolCallId,toolName:r.toolName,argsText:"",args:{}},r.parentId&&{parentId:r.parentId});return E(m({},e),{parts:[...e.parts,n],get content(){return this.parts}})}else if(r.type==="source"){const n=m(m({type:"source",sourceType:r.sourceType,id:r.id,url:r.url},r.title?{title:r.title}:void 0),r.parentId&&{parentId:r.parentId});return E(m({},e),{parts:[...e.parts,n],get content(){return this.parts}})}else if(r.type==="file"){const n={type:"file",mimeType:r.mimeType,data:r.data};return E(m({},e),{parts:[...e.parts,n],get content(){return this.parts}})}else throw new Error(`Unsupported part type: ${r.type}`)},Zu=(e,t)=>Er(e,t,r=>{if(r.type!=="tool-call")throw new Error("Last is not a tool call");return r.state!=="partial-call"?r:E(m({},r),{state:"call"})}),ec=(e,t)=>Er(e,t,r=>E(m({},r),{status:{type:"complete",reason:"unknown"}})),tc=(e,t)=>Er(e,t,r=>{var n;if(r.type==="text"||r.type==="reasoning")return E(m({},r),{text:r.text+t.textDelta});if(r.type==="tool-call"){const i=r.argsText+t.textDelta,s=(n=Sr(i))!=null?n:r.args;return E(m({},r),{argsText:i,args:s})}else throw new Error("text-delta received but part is neither text nor tool-call")}),rc=(e,t)=>Er(e,t,r=>{var n;if(r.type==="tool-call")return E(m(E(m({},r),{state:"result"}),t.artifact!==void 0?{artifact:t.artifact}:{}),{result:t.result,isError:(n=t.isError)!=null?n:!1,status:{type:"complete",reason:"stop"}});throw new Error("Result chunk received but part is not a tool-call")}),ds=(e,t)=>{var n,i;if(((n=e.status)==null?void 0:n.type)==="incomplete"&&((i=e.status)==null?void 0:i.reason)==="error")return e;const r=nc(t);return E(m({},e),{status:r})},nc=e=>e.finishReason==="tool-calls"?{type:"requires-action",reason:"tool-calls"}:e.finishReason==="stop"||e.finishReason==="unknown"?{type:"complete",reason:e.finishReason}:{type:"incomplete",reason:e.finishReason},ic=(e,t)=>E(m({},e),{metadata:E(m({},e.metadata),{unstable_annotations:[...e.metadata.unstable_annotations,...t.annotations]})}),sc=(e,t)=>E(m({},e),{metadata:E(m({},e.metadata),{unstable_data:[...e.metadata.unstable_data,...t.data]})}),ac=(e,t)=>E(m({},e),{metadata:E(m({},e.metadata),{steps:[...e.metadata.steps,{state:"started",messageId:t.messageId}]})}),oc=(e,t)=>{var i;const r=e.metadata.steps.slice(),n=r.length-1;return r.length>0&&((i=r[n])==null?void 0:i.state)==="started"?r[n]=E(m({},r[n]),{state:"finished",finishReason:t.finishReason,usage:t.usage,isContinued:t.isContinued}):r.push({state:"finished",messageId:rs(),finishReason:t.finishReason,usage:t.usage,isContinued:t.isContinued}),E(m({},e),{metadata:E(m({},e.metadata),{steps:r})})},lc=(e,t)=>E(m({},e),{status:{type:"incomplete",reason:"error",error:t.error}}),uc=(e,t)=>{const r=new Ku(e.metadata.unstable_state);return r.append(t.operations),E(m({},e),{metadata:E(m({},e.metadata),{unstable_state:r.state})})},cc=e=>{let t=!1;return()=>{t||(t=!0,queueMicrotask(()=>{t=!1,e()}))}},dc=class extends TransformStream{constructor({initialMessage:e,throttle:t,onError:r}={}){let n=e!=null?e:Xu(),i;const s=t?cc(()=>{i==null||i.enqueue(n)}):()=>{i==null||i.enqueue(n)};super({start(a){i=a},transform(a){const o=a.type;switch(o){case"part-start":n=Qu(n,a);break;case"tool-call-args-text-finish":n=Zu(n,a);break;case"part-finish":n=ec(n,a);break;case"text-delta":n=tc(n,a);break;case"result":n=rc(n,a);break;case"message-finish":n=ds(n,a);break;case"annotations":n=ic(n,a);break;case"data":n=sc(n,a);break;case"step-start":n=ac(n,a);break;case"step-finish":n=oc(n,a);break;case"error":n=lc(n,a),r==null||r(a.error);break;case"update-state":n=uc(n,a);break;default:{const l=o;throw new Error(`Unsupported chunk type: ${l}`)}}s()},flush(a){var o,l,u;if(((o=n.status)==null?void 0:o.type)==="running"){const d=(u=(l=n.parts)==null?void 0:l.some(c=>c.type==="tool-call"&&(c.state==="call"||c.state==="partial-call")&&c.result===void 0))!=null?u:!1;n=ds(n,{finishReason:d?"tool-calls":"unknown"}),a.enqueue(n)}}})}},hc=class extends es{constructor(){super(e=>{const t=new ju({transform(r,n){n.appendText(r)}});return e.pipeThrough(new TextDecoderStream).pipeThrough(t)})}},fc=class ln{constructor(t){this.readable=t,this.readable=t}static fromAssistantStream(t){return new ln(t.pipeThrough(new dc))}unstable_result(){return P(this,null,function*(){let t;try{for(var r=xt(this),n,i,s;n=!(i=yield r.next()).done;n=!1){const a=i.value;t=a}}catch(i){s=[i]}finally{try{n&&(i=r.return)&&(yield i.call(r))}finally{if(s)throw s[0]}}return t||{role:"assistant",status:{type:"complete",reason:"unknown"},parts:[],content:[],metadata:{unstable_state:null,unstable_data:[],unstable_annotations:[],steps:[],custom:{}}}})}[Symbol.asyncIterator](){const t=this.readable.getReader();return{next(){return P(this,null,function*(){const{done:n,value:i}=yield t.read();return n?{done:!0,value:void 0}:{done:!1,value:i}})}}}tee(){const[t,r]=this.readable.tee();return[new ln(t),new ln(r)]}},hs=Symbol.for("aui.tool-response"),st=class Ui{constructor(t){T(this,"artifact");T(this,"result");T(this,"isError");var r;t.artifact!==void 0&&(this.artifact=t.artifact),this.result=t.result,this.isError=(r=t.isError)!=null?r:!1}get[hs](){return!0}static[Symbol.hasInstance](t){return typeof t=="object"&&t!==null&&hs in t}static toResponse(t){return t instanceof Ui?t:new Ui({result:t===void 0?"<no result>":t})}};function pc(e,t,r){try{const n=e();if(typeof n=="object"&&n!==null&&"then"in n)return n.then(t,r);t(n)}catch(n){r(n)}}function Jt(e,t){let r=e;for(const n of t){if(r==null)return;r=r[n]}return r}var mc=class{constructor(e,t,r){T(this,"resolve");T(this,"reject");T(this,"disposed",!1);T(this,"fieldPath");this.resolve=e,this.reject=t,this.fieldPath=r}update(e){if(!this.disposed)try{if(vt(e,this.fieldPath)==="complete"){const t=Jt(e,this.fieldPath);t!==void 0&&(this.resolve(t),this.dispose())}}catch(t){this.reject(t),this.dispose()}}dispose(){this.disposed=!0}},fs=class{constructor(e,t){T(this,"controller");T(this,"disposed",!1);T(this,"fieldPath");this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{const t=Jt(e,this.fieldPath);t!==void 0&&this.controller.enqueue(t),vt(e,this.fieldPath)==="complete"&&(this.controller.close(),this.dispose())}catch(t){this.controller.error(t),this.dispose()}}dispose(){this.disposed=!0}},ps=class{constructor(e,t){T(this,"controller");T(this,"disposed",!1);T(this,"fieldPath");T(this,"lastValue");this.controller=e,this.fieldPath=t}update(e){var t;if(!this.disposed)try{const r=Jt(e,this.fieldPath);if(r!==void 0&&typeof r=="string"){const n=r.substring(((t=this.lastValue)==null?void 0:t.length)||0);this.lastValue=r,this.controller.enqueue(n)}vt(e,this.fieldPath)==="complete"&&(this.controller.close(),this.dispose())}catch(r){this.controller.error(r),this.dispose()}}dispose(){this.disposed=!0}},ms=class{constructor(e,t){T(this,"controller");T(this,"disposed",!1);T(this,"fieldPath");T(this,"processedIndexes",new Set);this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{const t=Jt(e,this.fieldPath);if(!Array.isArray(t))return;for(let r=0;r<t.length;r++)if(!this.processedIndexes.has(r)){const n=[...this.fieldPath,r];vt(e,n)==="complete"&&(this.controller.enqueue(t[r]),this.processedIndexes.add(r))}vt(e,this.fieldPath)==="complete"&&(this.controller.close(),this.dispose())}catch(t){this.controller.error(t),this.dispose()}}dispose(){this.disposed=!0}},gc=class{constructor(e){T(this,"argTextDeltas");T(this,"handles",new Set);T(this,"args",Sr(""));this.argTextDeltas=e,this.processStream()}processStream(){return P(this,null,function*(){try{let e="";const t=this.argTextDeltas.getReader();for(;;){const{value:r,done:n}=yield t.read();if(n)break;e+=r;const i=Sr(e);if(i!==void 0){this.args=i;for(const s of this.handles)s.update(i)}}}catch(e){console.error("Error processing argument stream:",e);for(const t of this.handles)t.dispose()}})}get(...e){return new Promise((t,r)=>{const n=new mc(t,r,e);if(this.args&&vt(this.args,e)==="complete"){const i=Jt(this.args,e);if(i!==void 0){t(i);return}}this.handles.add(n),n.update(this.args)})}streamValues(...e){const t=e,r=new ReadableStream({start:n=>{const i=new fs(n,t);this.handles.add(i),i.update(this.args)},cancel:()=>{for(const n of this.handles)if(n instanceof fs){n.dispose(),this.handles.delete(n);break}}});return fn(r)}streamText(...e){const t=e,r=new ReadableStream({start:n=>{const i=new ps(n,t);this.handles.add(i),i.update(this.args)},cancel:()=>{for(const n of this.handles)if(n instanceof ps){n.dispose(),this.handles.delete(n);break}}});return fn(r)}forEach(...e){const t=e,r=new ReadableStream({start:n=>{const i=new ms(n,t);this.handles.add(i),i.update(this.args)},cancel:()=>{for(const n of this.handles)if(n instanceof ms){n.dispose(),this.handles.delete(n);break}}});return fn(r)}},yc=class{constructor(e){this.promise=e}get(){return this.promise}},bc=class{constructor(){T(this,"args");T(this,"response");T(this,"writable");T(this,"resolve");T(this,"argsText","");T(this,"result",{get:()=>P(this,null,function*(){return(yield this.response.get()).result})});const e=new TransformStream;this.writable=e.writable,this.args=new gc(e.readable);const{promise:t,resolve:r}=mn();this.resolve=r,this.response=new yc(t)}appendArgsTextDelta(e){return P(this,null,function*(){const t=this.writable.getWriter();try{yield t.write(e)}catch(r){console.warn(r)}finally{t.releaseLock()}this.argsText+=e})}setResponse(e){this.resolve(e)}},wc=class extends es{constructor(e){const t=new Map,r=new Map;super(n=>{const i=new TransformStream({transform(a,o){switch((a.type!=="part-finish"||a.meta.type!=="tool-call")&&o.enqueue(a),a.type){case"part-start":if(a.part.type==="tool-call"){const u=new bc;r.set(a.part.toolCallId,u),e.streamCall({reader:u,toolCallId:a.part.toolCallId,toolName:a.part.toolName})}break;case"text-delta":{if(a.meta.type==="tool-call"){const u=a.meta.toolCallId,d=r.get(u);if(!d)throw new Error("No controller found for tool call");d.appendArgsTextDelta(a.textDelta)}break}case"result":{if(a.meta.type!=="tool-call")break;const{toolCallId:u}=a.meta,d=r.get(u);if(!d)throw new Error("No controller found for tool call");d.setResponse(new st({result:a.result,artifact:a.artifact,isError:a.isError}));break}case"tool-call-args-text-finish":{if(a.meta.type!=="tool-call")break;const{toolCallId:u,toolName:d}=a.meta,c=r.get(u);if(!c)throw new Error("No controller found for tool call");let f=!1;const h=pc(()=>{var w;let g;try{g=hn.parse(c.argsText)}catch(b){throw new Error(`Function parameter parsing failed. ${JSON.stringify(b.message)}`)}const S=e.execute({toolCallId:u,toolName:d,args:g});return S!==void 0&&(f=!0,(w=e.onExecutionStart)==null||w.call(e,u,d)),S},g=>{var w;if(f&&((w=e.onExecutionEnd)==null||w.call(e,u,d)),g===void 0)return;const S=new st({artifact:g.artifact,result:g.result,isError:g.isError});c.setResponse(S),o.enqueue(m({type:"result",path:a.path},S))},g=>{var w;f&&((w=e.onExecutionEnd)==null||w.call(e,u,d));const S=new st({result:String(g),isError:!0});c.setResponse(S),o.enqueue(m({type:"result",path:a.path},S))});h&&t.set(u,h);break}case"part-finish":{if(a.meta.type!=="tool-call")break;const{toolCallId:u}=a.meta,d=t.get(u);d?d.then(()=>{t.delete(u),r.delete(u),o.enqueue(a)}):o.enqueue(a)}}},flush(){return P(this,null,function*(){yield Promise.all(t.values())})}});return n.pipeThrough(new ts).pipeThrough(i)})}},xc=e=>typeof e=="object"&&e!==null&&"~standard"in e&&e["~standard"].version===1;function vc(e,t,r,n){const i=e==null?void 0:e[r.toolName];return!i||!i.execute?void 0:(a=>P(null,null,function*(){var d;if(t.aborted)return new st({result:"Tool execution was cancelled.",isError:!0});let o=a;if(xc(i.parameters)){let c=i.parameters["~standard"].validate(r.args);c instanceof Promise&&(c=yield c),c.issues&&(o=(d=i.experimental_onSchemaValidationError)!=null?d:(()=>{throw new Error(`Function parameter validation failed. ${JSON.stringify(c.issues)}`)}))}const l=new Promise(c=>{const f=()=>{queueMicrotask(()=>{queueMicrotask(()=>{c(new st({result:"Tool execution was cancelled.",isError:!0}))})})};t.aborted?f():t.addEventListener("abort",f,{once:!0})}),u=P(null,null,function*(){const c=yield o(r.args,{toolCallId:r.toolCallId,abortSignal:t,human:f=>n(r.toolCallId,f)});return st.toResponse(c)});return Promise.race([u,l])}))(i.execute)}function Sc(e,t,r,n,i){var s,a;(a=(s=e==null?void 0:e[n.toolName])==null?void 0:s.streamCall)==null||a.call(s,r,{toolCallId:n.toolCallId,abortSignal:t,human:o=>i(n.toolCallId,o)})}function kc(e,t,r,n){const i=typeof e=="function"?e:()=>e,s=typeof t=="function"?t:()=>t;return new wc({execute:a=>vc(i(),s(),a,r),streamCall:l=>{var u=l,{reader:a}=u,o=H(u,["reader"]);return Sc(i(),s(),a,o,r)},onExecutionStart:n==null?void 0:n.onExecutionStart,onExecutionEnd:n==null?void 0:n.onExecutionEnd})}var gs=class{constructor(e,t,r){this.contentBinding=e,this.messageApi=t,this.threadApi=r,this.__internal_bindMethods()}get path(){return this.contentBinding.path}__internal_bindMethods(){this.addToolResult=this.addToolResult.bind(this),this.resumeToolCall=this.resumeToolCall.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this.contentBinding.getState()}addToolResult(e){const t=this.contentBinding.getState();if(!t)throw new Error("Message part is not available");if(t.type!=="tool-call")throw new Error("Tried to add tool result to non-tool message part");if(!this.messageApi)throw new Error("Message API is not available. This is likely a bug in assistant-ui.");if(!this.threadApi)throw new Error("Thread API is not available");const r=this.messageApi.getState();if(!r)throw new Error("Message is not available");const n=t.toolName,i=t.toolCallId,s=st.toResponse(e);this.threadApi.getState().addToolResult({messageId:r.id,toolName:n,toolCallId:i,result:s.result,artifact:s.artifact,isError:s.isError})}resumeToolCall(e){const t=this.contentBinding.getState();if(!t)throw new Error("Message part is not available");if(t.type!=="tool-call")throw new Error("Tried to resume tool call on non-tool message part");if(!this.threadApi)throw new Error("Thread API is not available");const r=t.toolCallId;this.threadApi.getState().resumeToolCall({toolCallId:r,payload:e})}subscribe(e){return this.contentBinding.subscribe(e)}},Ar=class extends _r{constructor(e){super(),this.binding=e}get path(){return this.binding.path}getState(){return this.binding.getState()}outerSubscribe(e){return this.binding.subscribe(e)}_connect(){const e=()=>{this.notifySubscribers()};let t=this.binding.getState(),r=t==null?void 0:t.subscribe(e);const n=()=>{var a;const s=this.binding.getState();s!==t&&(t=s,r==null||r(),r=(a=this.binding.getState())==null?void 0:a.subscribe(e),e())},i=this.outerSubscribe(n);return()=>{i==null||i(),r==null||r()}}},Pr=Object.freeze({type:"complete"}),_c=(e,t,r)=>{if(e.role!=="assistant")return Pr;if(r.type==="tool-call")return r.result?Pr:e.status;const n=t===Math.max(0,e.content.length-1);return e.status.type==="requires-action"?Pr:n?e.status:Pr},ys=(e,t)=>{const r=e.content[t];if(!r)return Ue;const n=_c(e,t,r);return Object.freeze(E(m({},r),{[Cr]:r[Cr],status:n}))},Tc=class{constructor(e,t){T(this,"composer");T(this,"_getEditComposerRuntimeCore",()=>this._threadBinding.getState().getEditComposer(this._core.getState().id));this._core=e,this._threadBinding=t,this.composer=new Yu(new Ar({path:E(m({},this.path),{ref:`${this.path.ref}${this.path.ref}.composer`,composerSource:"edit"}),getState:this._getEditComposerRuntimeCore,subscribe:r=>this._threadBinding.subscribe(r)}),()=>this._threadBinding.getState().beginEdit(this._core.getState().id)),this.__internal_bindMethods()}get path(){return this._core.path}__internal_bindMethods(){this.reload=this.reload.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getMessagePartByIndex=this.getMessagePartByIndex.bind(this),this.getMessagePartByToolCallId=this.getMessagePartByToolCallId.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.unstable_getCopyText=this.unstable_getCopyText.bind(this),this.speak=this.speak.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.submitFeedback=this.submitFeedback.bind(this),this.switchToBranch=this.switchToBranch.bind(this)}getState(){return this._core.getState()}reload(e={}){const t=this._getEditComposerRuntimeCore(),r=t!=null?t:this._threadBinding.getState().composer,n=t!=null?t:r,{runConfig:i=n.runConfig}=e,s=this._core.getState();if(s.role!=="assistant")throw new Error("Can only reload assistant messages");this._threadBinding.getState().startRun({parentId:s.parentId,sourceId:s.id,runConfig:i})}speak(){const e=this._core.getState();return this._threadBinding.getState().speak(e.id)}stopSpeaking(){var r;const e=this._core.getState();if(((r=this._threadBinding.getState().speech)==null?void 0:r.messageId)===e.id)this._threadBinding.getState().stopSpeaking();else throw new Error("Message is not being spoken")}submitFeedback({type:e}){const t=this._core.getState();this._threadBinding.getState().submitFeedback({messageId:t.id,type:e})}switchToBranch({position:e,branchId:t}){const r=this._core.getState();if(t&&e)throw new Error("May not specify both branchId and position");if(!t&&!e)throw new Error("Must specify either branchId or position");const i=this._threadBinding.getState().getBranches(r.id);let s=t;if(e==="previous"?s=i[r.branchNumber-2]:e==="next"&&(s=i[r.branchNumber]),!s)throw new Error("Branch not found");this._threadBinding.getState().switchToBranch(s)}unstable_getCopyText(){return Ir(this.getState())}subscribe(e){return this._core.subscribe(e)}getMessagePartByIndex(e){if(e<0)throw new Error("Message part index must be >= 0");return new gs(new $e({path:E(m({},this.path),{ref:`${this.path.ref}${this.path.ref}.content[${e}]`,messagePartSelector:{type:"index",index:e}}),getState:()=>ys(this.getState(),e),subscribe:t=>this._core.subscribe(t)}),this._core,this._threadBinding)}getMessagePartByToolCallId(e){return new gs(new $e({path:E(m({},this.path),{ref:this.path.ref+`${this.path.ref}.content[toolCallId=${JSON.stringify(e)}]`,messagePartSelector:{type:"toolCallId",toolCallId:e}}),getState:()=>{const t=this._core.getState(),r=t.content.findIndex(n=>n.type==="tool-call"&&n.toolCallId===e);return r===-1?Ue:ys(t,r)},subscribe:t=>this._core.subscribe(t)}),this._core,this._threadBinding)}getAttachmentByIndex(e){return new Vu(new $e({path:E(m({},this.path),{ref:`${this.path.ref}${this.path.ref}.attachments[${e}]`,attachmentSource:"message",attachmentSelector:{type:"index",index:e}}),getState:()=>{const t=this.getState().attachments,r=t==null?void 0:t[e];return r?E(m({},r),{source:"message"}):Ue},subscribe:t=>this._core.subscribe(t)}))}},Cc=e=>{var t,r,n;return m({parentId:(t=e.parentId)!=null?t:null,sourceId:(r=e.sourceId)!=null?r:null,runConfig:(n=e.runConfig)!=null?n:{}},e.stream?{stream:e.stream}:{})},Ic=e=>{var t,r,n;return{parentId:(t=e.parentId)!=null?t:null,sourceId:(r=e.sourceId)!=null?r:null,runConfig:(n=e.runConfig)!=null?n:{}}},Ec=(e,t)=>{var r,n,i,s,a,o,l,u,d,c,f;return typeof t=="string"?{createdAt:new Date,parentId:(n=(r=e.at(-1))==null?void 0:r.id)!=null?n:null,sourceId:null,runConfig:{},role:"user",content:[{type:"text",text:t}],attachments:[],metadata:{custom:{}}}:{createdAt:(i=t.createdAt)!=null?i:new Date,parentId:(o=(a=t.parentId)!=null?a:(s=e.at(-1))==null?void 0:s.id)!=null?o:null,sourceId:(l=t.sourceId)!=null?l:null,role:(u=t.role)!=null?u:"user",content:t.content,attachments:(d=t.attachments)!=null?d:[],metadata:(c=t.metadata)!=null?c:{custom:{}},runConfig:(f=t.runConfig)!=null?f:{},startRun:t.startRun}},Ac=(e,t)=>{const r=e.messages.at(-1);return Object.freeze({threadId:t.id,metadata:t,capabilities:e.capabilities,isDisabled:e.isDisabled,isLoading:e.isLoading,isRunning:(r==null?void 0:r.role)!=="assistant"?!1:r.status.type==="running",messages:e.messages,state:e.state,suggestions:e.suggestions,extras:e.extras,speech:e.speech})},bs=class{constructor(e,t){T(this,"_threadBinding");T(this,"composer");T(this,"_eventSubscriptionSubjects",new Map);const r=new $e({path:e.path,getState:()=>Ac(e.getState(),t.getState()),subscribe:n=>{const i=e.subscribe(n),s=t.subscribe(n);return()=>{i(),s()}}});this._threadBinding={path:e.path,getState:()=>e.getState(),getStateState:()=>r.getState(),outerSubscribe:n=>e.outerSubscribe(n),subscribe:n=>e.subscribe(n)},this.composer=new Gu(new Ar({path:E(m({},this.path),{ref:`${this.path.ref}${this.path.ref}.composer`,composerSource:"thread"}),getState:()=>this._threadBinding.getState().composer,subscribe:n=>this._threadBinding.subscribe(n)})),this.__internal_bindMethods()}get path(){return this._threadBinding.path}get __internal_threadBinding(){return this._threadBinding}__internal_bindMethods(){this.append=this.append.bind(this),this.unstable_resumeRun=this.unstable_resumeRun.bind(this),this.unstable_loadExternalState=this.unstable_loadExternalState.bind(this),this.startRun=this.startRun.bind(this),this.cancelRun=this.cancelRun.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.export=this.export.bind(this),this.import=this.import.bind(this),this.reset=this.reset.bind(this),this.getMessageByIndex=this.getMessageByIndex.bind(this),this.getMessageById=this.getMessageById.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getModelContext=this.getModelContext.bind(this),this.getModelConfig=this.getModelConfig.bind(this),this.getState=this.getState.bind(this)}getState(){return this._threadBinding.getStateState()}append(e){this._threadBinding.getState().append(Ec(this._threadBinding.getState().messages,e))}subscribe(e){return this._threadBinding.subscribe(e)}getModelContext(){return this._threadBinding.getState().getModelContext()}getModelConfig(){return this.getModelContext()}startRun(e){const t=e===null||typeof e=="string"?{parentId:e}:e;return this._threadBinding.getState().startRun(Ic(t))}unstable_resumeRun(e){return this._threadBinding.getState().resumeRun(Cc(e))}unstable_loadExternalState(e){this._threadBinding.getState().unstable_loadExternalState(e)}cancelRun(){this._threadBinding.getState().cancelRun()}stopSpeaking(){return this._threadBinding.getState().stopSpeaking()}export(){return this._threadBinding.getState().export()}import(e){this._threadBinding.getState().import(e)}reset(e){this._threadBinding.getState().reset(e)}getMessageByIndex(e){if(e<0)throw new Error("Message index must be >= 0");return this._getMessageRuntime(E(m({},this.path),{ref:`${this.path.ref}${this.path.ref}.messages[${e}]`,messageSelector:{type:"index",index:e}}),()=>{var n,i;const t=this._threadBinding.getState().messages,r=t[e];if(r)return{message:r,parentId:(i=(n=t[e-1])==null?void 0:n.id)!=null?i:null,index:e}})}getMessageById(e){return this._getMessageRuntime(E(m({},this.path),{ref:this.path.ref+`${this.path.ref}.messages[messageId=${JSON.stringify(e)}]`,messageSelector:{type:"messageId",messageId:e}}),()=>this._threadBinding.getState().getMessageById(e))}_getMessageRuntime(e,t){return new Tc(new $e({path:e,getState:()=>{var d,c;const{message:r,parentId:n,index:i}=(d=t())!=null?d:{},{messages:s,speech:a}=this._threadBinding.getState();if(!r||n===void 0||i===void 0)return Ue;const l=this._threadBinding.getState().getBranches(r.id),u=r.metadata.submittedFeedback;return E(m({},r),{[Cr]:r[Cr],index:i,isLast:((c=s.at(-1))==null?void 0:c.id)===r.id,parentId:n,branchNumber:l.indexOf(r.id)+1,branchCount:l.length,speech:(a==null?void 0:a.messageId)===r.id?a:void 0,submittedFeedback:u})},subscribe:r=>this._threadBinding.subscribe(r)}),this._threadBinding)}unstable_on(e,t){let r=this._eventSubscriptionSubjects.get(e);return r||(r=new os({event:e,binding:this._threadBinding}),this._eventSubscriptionSubjects.set(e,r)),r.subscribe(t)}},Pc=e=>({mainThreadId:e.mainThreadId,newThread:e.newThreadId,threads:e.threadIds,archivedThreads:e.archivedThreadIds,isLoading:e.isLoading,threadItems:e.threadData}),Mr=(e,t)=>{if(t===void 0)return Ue;const r=e.getItemById(t);return r?{id:r.id,threadId:r.id,remoteId:r.remoteId,externalId:r.externalId,title:r.title,status:r.status,isMain:r.id===e.mainThreadId}:Ue},Mc=class{constructor(e,t=bs){T(this,"_getState");T(this,"_mainThreadListItemRuntime");T(this,"main");this._core=e,this._runtimeFactory=t;const r=new yn({path:{},getState:()=>Pc(e),subscribe:n=>e.subscribe(n)});this._getState=r.getState.bind(r),this._mainThreadListItemRuntime=new Tr(new $e({path:{ref:"threadItems[main]",threadSelector:{type:"main"}},getState:()=>Mr(this._core,this._core.mainThreadId),subscribe:n=>this._core.subscribe(n)}),this._core),this.main=new t(new Ar({path:{ref:"threads.main",threadSelector:{type:"main"}},getState:()=>e.getMainThreadRuntimeCore(),subscribe:n=>e.subscribe(n)}),this._mainThreadListItemRuntime),this.__internal_bindMethods()}__internal_bindMethods(){this.switchToThread=this.switchToThread.bind(this),this.switchToNewThread=this.switchToNewThread.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getById=this.getById.bind(this),this.getItemById=this.getItemById.bind(this),this.getItemByIndex=this.getItemByIndex.bind(this),this.getArchivedItemByIndex=this.getArchivedItemByIndex.bind(this)}switchToThread(e){return this._core.switchToThread(e)}switchToNewThread(){return this._core.switchToNewThread()}getState(){return this._getState()}subscribe(e){return this._core.subscribe(e)}get mainItem(){return this._mainThreadListItemRuntime}getById(e){return new this._runtimeFactory(new Ar({path:{ref:`threads[threadId=${JSON.stringify(e)}]`,threadSelector:{type:"threadId",threadId:e}},getState:()=>this._core.getThreadRuntimeCore(e),subscribe:t=>this._core.subscribe(t)}),this.mainItem)}getItemByIndex(e){return new Tr(new $e({path:{ref:`threadItems[${e}]`,threadSelector:{type:"index",index:e}},getState:()=>Mr(this._core,this._core.threadIds[e]),subscribe:t=>this._core.subscribe(t)}),this._core)}getArchivedItemByIndex(e){return new Tr(new $e({path:{ref:`archivedThreadItems[${e}]`,threadSelector:{type:"archiveIndex",index:e}},getState:()=>Mr(this._core,this._core.archivedThreadIds[e]),subscribe:t=>this._core.subscribe(t)}),this._core)}getItemById(e){return new Tr(new $e({path:{ref:`threadItems[threadId=${e}]`,threadSelector:{type:"threadId",threadId:e}},getState:()=>Mr(this._core,e),subscribe:t=>this._core.subscribe(t)}),this._core)}},Lc=e=>e.startsWith("image/")?"image":e.startsWith("text/")?"document":"file",Nc=class{constructor(e){T(this,"accept","*");T(this,"uploadedUrls",new Map);this.cloud=e}add(t){return wr(this,arguments,function*({file:e}){const r=crypto.randomUUID(),n=Lc(e.type);let i={id:r,type:n,name:e.name,contentType:e.type,file:e,status:{type:"running",reason:"uploading",progress:0}};yield i;try{const{signedUrl:s,publicUrl:a}=yield new it(this.cloud.files.generatePresignedUploadUrl({filename:e.name}));yield new it(fetch(s,{method:"PUT",body:e,headers:{"Content-Type":e.type},mode:"cors"})),this.uploadedUrls.set(r,a),i=E(m({},i),{status:{type:"requires-action",reason:"composer-send"}}),yield i}catch(s){i=E(m({},i),{status:{type:"incomplete",reason:"error"}}),yield i}})}remove(e){return P(this,null,function*(){this.uploadedUrls.delete(e.id)})}send(e){return P(this,null,function*(){const t=this.uploadedUrls.get(e.id);if(!t)throw new Error("Attachment not uploaded");this.uploadedUrls.delete(e.id);let r;return e.type==="image"?r=[{type:"image",image:t,filename:e.name}]:r=[{type:"file",data:t,mimeType:e.contentType,filename:e.name}],E(m({},e),{status:{type:"complete"},content:r})})}},bn=y.createContext(null),wn=({adapters:e,children:t})=>{const r=y.useContext(bn);return p.jsx(bn.Provider,{value:m(m({},r),e),children:t})},Dc=()=>y.useContext(bn),Oc=class extends Hi{constructor(t,r,{parentId:n,message:i}){var s;super();T(this,"_nonTextParts");T(this,"_previousText");T(this,"_parentId");T(this,"_sourceId");this.runtime=t,this.endEditCallback=r,this._parentId=n,this._sourceId=i.id,this._previousText=Ir(i),this.setText(this._previousText),this.setRole(i.role),this.setAttachments((s=i.attachments)!=null?s:[]),this._nonTextParts=i.content.filter(a=>a.type!=="text"),this.setRunConfig(m({},t.composer.runConfig))}get canCancel(){return!0}getAttachmentAdapter(){var t;return(t=this.runtime.adapters)==null?void 0:t.attachments}handleSend(t){return P(this,null,function*(){Ir(t)!==this._previousText&&this.runtime.append(E(m({},t),{content:[...t.content,...this._nonTextParts],parentId:this._parentId,sourceId:this._sourceId})),this.handleCancel()})}handleCancel(){this.endEditCallback(),this._notifySubscribers()}},Fc=class{constructor(e){T(this,"_subscriptions",new Set);T(this,"_isInitialized",!1);T(this,"repository",new is);T(this,"composer",new qi(this));T(this,"_editComposers",new Map);T(this,"_stopSpeaking");T(this,"speech");T(this,"_eventSubscribers",new Map);this._contextProvider=e}get messages(){return this.repository.getMessages()}get state(){var t;let e;for(const r of this.messages)if(r.role==="assistant"){e=r;break}return(t=e==null?void 0:e.metadata.unstable_state)!=null?t:null}getModelContext(){return this._contextProvider.getModelContext()}getEditComposer(e){return this._editComposers.get(e)}beginEdit(e){if(this._editComposers.has(e))throw new Error("Edit already in progress");this._editComposers.set(e,new Oc(this,()=>this._editComposers.delete(e),this.repository.getMessage(e))),this._notifySubscribers()}getMessageById(e){try{return this.repository.getMessage(e)}catch(t){return}}getBranches(e){return this.repository.getBranches(e)}switchToBranch(e){this.repository.switchToBranch(e),this._notifySubscribers()}_notifySubscribers(){for(const e of this._subscriptions)e()}_notifyEventSubscribers(e){const t=this._eventSubscribers.get(e);if(t)for(const r of t)r()}subscribe(e){return this._subscriptions.add(e),()=>this._subscriptions.delete(e)}submitFeedback({messageId:e,type:t}){var s;const r=(s=this.adapters)==null?void 0:s.feedback;if(!r)throw new Error("Feedback adapter not configured");const{message:n,parentId:i}=this.repository.getMessage(e);if(r.submit({message:n,type:t}),n.role==="assistant"){const a=E(m({},n),{metadata:E(m({},n.metadata),{submittedFeedback:{type:t}})});this.repository.addOrUpdateMessage(i,a)}this._notifySubscribers()}speak(e){var s,a;const t=(s=this.adapters)==null?void 0:s.speech;if(!t)throw new Error("Speech adapter not configured");const{message:r}=this.repository.getMessage(e);(a=this._stopSpeaking)==null||a.call(this);const n=t.speak(Ir(r)),i=n.subscribe(()=>{n.status.type==="ended"?(this._stopSpeaking=void 0,this.speech=void 0):this.speech={messageId:e,status:n.status},this._notifySubscribers()});this.speech={messageId:e,status:n.status},this._notifySubscribers(),this._stopSpeaking=()=>{n.cancel(),i(),this.speech=void 0,this._stopSpeaking=void 0}}stopSpeaking(){if(!this._stopSpeaking)throw new Error("No message is being spoken");this._stopSpeaking(),this._notifySubscribers()}ensureInitialized(){this._isInitialized||(this._isInitialized=!0,this._notifyEventSubscribers("initialize"))}export(){return this.repository.export()}import(e){this.ensureInitialized(),this.repository.clear(),this.repository.import(e),this._notifySubscribers()}reset(e){this.import(gn.fromArray(e!=null?e:[]))}unstable_on(e,t){var n,i,s;if(e==="model-context-update")return(s=(i=(n=this._contextProvider).subscribe)==null?void 0:i.call(n,t))!=null?s:(()=>{});const r=this._eventSubscribers.get(e);return r?r.add(t):this._eventSubscribers.set(e,new Set([t])),()=>{this._eventSubscribers.get(e).delete(t)}}},Bc=e=>{try{return JSON.parse(e),!0}catch(t){return!1}};function zc({state:e,getTools:t,onResult:r,setToolStatuses:n}){const i=y.useRef({}),s=y.useRef(new Map),a=y.useRef(new AbortController),o=y.useRef(0),l=y.useRef([]),[u]=y.useState(()=>{const[h,g]=ns(),S=kc(t,()=>{var w,b;return(b=(w=a.current)==null?void 0:w.signal)!=null?b:new AbortController().signal},(w,b)=>new Promise((C,_)=>{const F=s.current.get(w);F&&F.reject(new Error("Human input request was superseded by a new request")),s.current.set(w,{resolve:C,reject:_}),n(B=>E(m({},B),{[w]:{type:"interrupt",payload:{type:"human",payload:b}}}))}),{onExecutionStart:w=>{o.current++,n(b=>E(m({},b),{[w]:{type:"executing"}}))},onExecutionEnd:w=>{o.current--,n(b=>{const C=m({},b);return delete C[w],C}),o.current===0&&(l.current.forEach(b=>b()),l.current=[])}});return h.pipeThrough(S).pipeThrough(new ts).pipeTo(new WritableStream({write(w){var b;if(w.type==="result"){if((b=i.current[w.meta.toolCallId])!=null&&b.hasResult)return;r(m({type:"add-tool-result",toolCallId:w.meta.toolCallId,toolName:w.meta.toolName,result:w.result,isError:w.isError},w.artifact&&{artifact:w.artifact}))}}})),g}),d=y.useRef(new Set),c=y.useRef(!0);y.useEffect(()=>{const h=g=>{g.forEach(S=>{S.content.forEach(w=>{if(w.type==="tool-call"){if(c.current)d.current.add(w.toolCallId);else{if(d.current.has(w.toolCallId))return;let b=i.current[w.toolCallId];if(b||(b={argsText:"",hasResult:!1,argsComplete:!1,controller:u.addToolCallPart({toolName:w.toolName,toolCallId:w.toolCallId})},i.current[w.toolCallId]=b),w.argsText!==b.argsText)if(b.argsComplete)process.env.NODE_ENV!=="production"&&console.warn("argsText updated after controller was closed:",{previous:b.argsText,next:w.argsText});else{if(!w.argsText.startsWith(b.argsText))throw new Error(`Tool call argsText can only be appended, not updated: ${w.argsText} does not start with ${b.argsText}`);const C=w.argsText.slice(b.argsText.length);b.controller.argsText.append(C);const _=Bc(w.argsText);_&&b.controller.argsText.close(),i.current[w.toolCallId]={argsText:w.argsText,hasResult:b.hasResult,argsComplete:_,controller:b.controller}}w.result!==void 0&&!b.hasResult&&(b.controller.setResponse(new st({result:w.result,artifact:w.artifact,isError:w.isError})),b.controller.close(),i.current[w.toolCallId]={hasResult:!0,argsComplete:!0,argsText:b.argsText,controller:b.controller})}w.messages&&h(w.messages)}})})};h(e.messages),c.current&&(c.current=!1)},[e,u,r]);const f=()=>(s.current.forEach(({reject:h})=>{h(new Error("Tool execution aborted"))}),s.current.clear(),a.current.abort(),a.current=new AbortController,o.current===0?Promise.resolve():new Promise(h=>{l.current.push(h)}));return{reset:()=>{f(),c.current=!0},abort:f,resume:(h,g)=>{const S=s.current.get(h);if(S)s.current.delete(h),n(w=>E(m({},w),{[h]:{type:"executing"}})),S.resolve(g);else throw new Error(`Tool call ${h} is not waiting for human input`)}}}var Rc=class{list(){return Promise.resolve({threads:[]})}rename(){return Promise.resolve()}archive(){return Promise.resolve()}unarchive(){return Promise.resolve()}delete(){return Promise.resolve()}initialize(e){return Promise.resolve({remoteId:e,externalId:void 0})}generateTitle(){return Promise.resolve(new ReadableStream)}fetch(e){return Promise.reject(new Error("Thread not found"))}};function jc(e,t){e.commitTasks.forEach(r=>{const n=r.cellIndex,i=t.cells[n];if(i.type!=="effect")throw new Error("Cannot find effect cell");let s=!0;if(i.deps!==void 0&&r.deps!==void 0&&(s=i.deps.length!==r.deps.length||i.deps.some((a,o)=>!Object.is(a,r.deps[o]))),s){if(i.mounted){if(typeof i.deps!=typeof r.deps)throw new Error("tapEffect called with and without dependencies across re-renders");try{i.mounted&&i.cleanup&&i.cleanup()}finally{i.mounted=!1}}try{const a=r.effect();if(a!==void 0&&typeof a!="function")throw new Error(`An effect function must either return a cleanup function or nothing. Received: ${typeof a}`);i.mounted=!0,i.cleanup=typeof a=="function"?a:void 0,i.deps=r.deps}catch(a){throw a}}})}function Uc(e){let t=null;for(let r=e.cells.length-1;r>=0;r--){const n=e.cells[r];if((n==null?void 0:n.type)==="effect"&&n.mounted&&n.cleanup)try{n.cleanup()}catch(i){t==null&&(t=i)}finally{n.mounted=!1}}if(t!=null)throw t}var Gt=null;function $c(e,t){e.currentIndex=0;const r=Gt;Gt=e;try{if(t(),e.isFirstRender=!1,e.cells.length!==e.currentIndex)throw new Error(`Rendered ${e.currentIndex} hooks but expected ${e.cells.length}. Hooks must be called in the exact same order in every render.`)}finally{Gt=r}}function xn(){if(!Gt)throw new Error("No resource fiber available");return Gt}function ws(e,t){const r=e[xs];if(!r)throw new Error("ResourceElement.type is not a valid Resource");return r(t)}var xs=Symbol("fnSymbol");function Lr(e,t){return{resource:e,scheduleRerender:t,cells:[],currentIndex:0,renderContext:void 0,isFirstRender:!0,isMounted:!1,isNeverMounted:!0}}function St(e){e.isMounted=!1,Uc(e)}function Yt(e,t){const r={commitTasks:[],props:t,state:void 0};return $c(e,()=>{e.renderContext=r;try{r.state=ws(e.resource,t)}finally{e.renderContext=void 0}}),r}function kt(e,t){e.isMounted=!0,e.isNeverMounted=!1,jc(t,e)}var Hc=globalThis.__ASSISTANT_UI_DISABLE_LAYOUT_EFFECT__===!0,vs=Hc?y.useEffect:y.useLayoutEffect;function vn(e){const[,t]=y.useState({}),r=y.useMemo(()=>Lr(e.type,()=>t({})),[e.type,t]),n=Yt(r,e.props);return vs(()=>()=>St(r),[]),vs(()=>{kt(r,n)}),n.state}var _t=e=>typeof e=="string"?{scope:e.split(".")[0],event:e}:{scope:e.scope,event:e.event},dt=(e,t,r)=>t===e,Tt,Sn=()=>{if(Tt)return Tt;const e=()=>({apis:new Map,nextId:0,listeners:new Set});if(typeof window=="undefined")return Tt=e(),Tt;const t=window.__ASSISTANT_UI_DEVTOOLS_HOOK__;if(t)return Tt=t,t;const r=e();return window.__ASSISTANT_UI_DEVTOOLS_HOOK__=r,Tt=r,r},qc=(We=class{static register(t){var o,l;const r=Sn();for(const u of r.apis.values())if(u.api===t)return()=>{};const n=r.nextId++,i={api:t,logs:[]},s=(o=t.on)==null?void 0:o.call(t,"*",u=>{const d=r.apis.get(n);d&&(d.logs.push({time:new Date,event:u.event,data:u.payload}),d.logs.length>We.MAX_EVENT_LOGS_PER_API&&(d.logs=d.logs.slice(-200)),We.notifyListeners(n))}),a=(l=t.subscribe)==null?void 0:l.call(t,()=>{We.notifyListeners(n)});return r.apis.set(n,i),We.notifyListeners(n),()=>{const u=Sn();u.apis.get(n)&&(s==null||s(),a==null||a(),u.apis.delete(n),We.notifyListeners(n))}}static notifyListeners(t){Sn().listeners.forEach(n=>n(t))}},T(We,"MAX_EVENT_LOGS_PER_API",200),We);function oe(e){const t=(r,n)=>m({type:t,props:r},(n==null?void 0:n.key)!==void 0&&{key:n.key});return t[xs]=e,t}var Vc=e=>{if(e.renderContext)throw new Error("Resource updated during render");if(e.isNeverMounted)throw new Error("Resource updated before mount");e.isMounted&&e.scheduleRerender()};function Wc(e){const t=xn(),r=t.currentIndex++;if(!t.isFirstRender&&r>=t.cells.length)throw new Error("Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.");if(!t.cells[r]){const s={type:"state",value:typeof e=="function"?e():e,set:a=>{const o=s.value,l=typeof a=="function"?a(o):a;Object.is(o,l)||(s.value=l,Vc(t))}};t.cells[r]=s}const n=t.cells[r];if(n.type!=="state")throw new Error("Hook order changed between renders");return n}function Ye(e){const t=Wc(e);return[t.value,t.set]}function Jc(){const e=xn(),t=e.currentIndex++;if(!e.isFirstRender&&t>=e.cells.length)throw new Error("Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.");if(!e.cells[t]){const n={type:"effect",mounted:!1};e.cells[t]=n}if(e.cells[t].type!=="effect")throw new Error("Hook order changed between renders");return t}function ke(e,t){const r=xn(),n=Jc();r.renderContext.commitTasks.push({effect:e,deps:t,cellIndex:n})}function Ct(e){const[t]=Ye(()=>({current:e}));return t}var Gc=(e,t)=>{if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Object.is(e[r],t[r]))return!1;return!0},ee=(e,t)=>{const r=Ct();return r.current||(r.current={value:e(),deps:t}),Gc(r.current.deps,t)||(r.current.value=e(),r.current.deps=t),r.current.value};function Nr(e,t){const[r,n]=Ye({}),i=ee(()=>Lr(e.type,()=>n({})),[e.type]),s=t?ee(()=>e.props,t):e.props,a=ee(()=>Yt(i,s),[i,s,r]);return ke(()=>()=>St(i),[i]),ke(()=>{kt(i,a)},[i,a]),a.state}function He(e){return ws(e.type,e.props)}function Ss(e){const t=new Set;e.forEach((o,l)=>{if(o.key===void 0)throw new Error(`tapResources: All resource elements must have a key. Element at index ${l} is missing a key.`);if(t.has(o.key))throw new Error(`tapResources: Duplicate key "${o.key}" found. All keys must be unique.`);t.add(o.key)});const[r,n]=Ye({}),i=ee(()=>new Map(e.map(o=>[o.key,o])),[e]),[s]=Ye(()=>new Map),a=ee(()=>{const o=new Map,l=new Set;return i.forEach((u,d)=>{l.add(d);let c=s.get(d);(!c||c.resource!==u.type)&&(c&&St(c),c=Lr(u.type,()=>n({})),s.set(d,c));const f=Yt(c,u.props);o.set(d,f)}),s.forEach((u,d)=>{l.has(d)||(St(u),s.delete(d))}),o},[i,r]);return ke(()=>{a.forEach((o,l)=>{const u=s.get(l);u&&kt(u,o)})},[a,s]),ke(()=>()=>{s.forEach(o=>{St(o)}),s.clear()},[s]),ee(()=>e.map(o=>{var l;return(l=a.get(o.key))==null?void 0:l.state}),[e,a])}var kn=[],_n=!1;function Yc(){_n=!1;const e=kn;kn=[];for(const t of e)try{t()}catch(r){console.error("Error in scheduled task:",r)}}function Kc(e){kn.push(e),_n||(_n=!0,queueMicrotask(Yc))}var Xc=(yt=class{constructor(t){T(this,"_isDirty",!1);T(this,"_hasScheduledTask",!1);T(this,"_isFlushing",!1);this._task=t}get isDirty(){return this._isDirty}markDirty(){this._isDirty=!0,!(this._hasScheduledTask||this._isFlushing)&&(this._hasScheduledTask=!0,Kc(()=>{this._hasScheduledTask=!1,this.flushSync()}))}flushSync(){if(this._isFlushing)return;this._isFlushing=!0;let t=0;try{for(;this._isDirty;){if(t++,t>yt.MAX_FLUSH_DEPTH)throw new Error("Maximum update depth exceeded. This can happen when a resource repeatedly calls setState inside tapEffect.");this._isDirty=!1,this._task()}}finally{this._isFlushing=!1}}},T(yt,"MAX_FLUSH_DEPTH",50),yt),Qc=oe(({element:e,onUpdateInput:t,onFlushSync:r,onDispose:n})=>{const[i,s]=Ye(e.props),a=He({type:e.type,props:i}),o=Ct(new Set).current,l=Ct(a);return ke(()=>{a!==l.current&&(l.current=a,o.forEach(d=>d()))}),ee(()=>({getState:()=>l.current,subscribe:d=>(o.add(d),()=>o.delete(d)),updateInput:d=>{t(),s(()=>d)},flushSync:r,dispose:n}),[])}),Zc=(e,t=!1)=>{let r=!t;const n={element:e,onUpdateInput:()=>{r||(r=!0,kt(s,a))},onFlushSync:()=>{i.flushSync()},onDispose:()=>St(s)},i=new Xc(()=>{a=Yt(s,n),r&&kt(s,a)}),s=Lr(Qc,()=>i.markDirty());let a=Yt(s,n);return r&&kt(s,a),a.state},Kt=Symbol("tap.Context"),ks=e=>({[Kt]:e}),_s=(e,t,r)=>{const n=e[Kt];e[Kt]=t;try{return r()}finally{e[Kt]=n}},Ts=e=>e[Kt];const Cs=e=>{let t;const r=new Set,n=(u,d)=>{const c=typeof u=="function"?u(t):u;if(!Object.is(c,t)){const f=t;t=(d!=null?d:typeof c!="object"||c===null)?c:Object.assign({},t,c),r.forEach(h=>h(t,f))}},i=()=>t,o={setState:n,getState:i,getInitialState:()=>l,subscribe:u=>(r.add(u),()=>r.delete(u))},l=t=e(n,i,o);return o},ed=(e=>e?Cs(e):Cs),td=e=>e;function rd(e,t=td){const r=y.useSyncExternalStore(e.subscribe,y.useCallback(()=>t(e.getState()),[e,t]),y.useCallback(()=>t(e.getInitialState()),[e,t]));return y.useDebugValue(r),r}const Is=e=>{const t=ed(e),r=n=>rd(t,n);return Object.assign(r,t),r},It=(e=>e?Is(e):Is);function Es(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function As(...e){return t=>{let r=!1;const n=e.map(i=>{const s=Es(i,t);return!r&&typeof s=="function"&&(r=!0),s});if(r)return()=>{for(let i=0;i<n.length;i++){const s=n[i];typeof s=="function"?s():Es(e[i],null)}}}}function Dr(...e){return J.useCallback(As(...e),e)}var Ps=oe(e=>{const t=ee(()=>Zc(e,!0),[e.type]);return ke(()=>{t.updateInput(e.props)}),t}),nd=class{constructor(e){this.getApi=e}get(e,t){return this.getApi()[t]}ownKeys(){return Object.keys(this.getApi())}has(e,t){return t in this.getApi()}getOwnPropertyDescriptor(e,t){return Object.getOwnPropertyDescriptor(this.getApi(),t)}set(){return!1}defineProperty(){return!1}deleteProperty(){return!1}},qe=(e,t)=>{const r=Ct(e);ke(()=>{r.current=e});const n=ee(()=>new Proxy({},new nd(()=>r.current)),[]),i=t==null?void 0:t.key,s=e.getState();return ee(()=>({key:i,state:s,api:n}),[s,i])},Et=oe(e=>{const t=Ct(e.get);return ke(()=>{t.current=e.get}),ee(()=>be({source:e.source,query:e.query,get:()=>t.current()}),[e.source,JSON.stringify(e.query)])}),id=oe(e=>{const t=Nr(e.scopeElement);return ee(()=>[e.fieldName,t],[e.fieldName,t])}),sd=oe(e=>{const o=e,{on:t,subscribe:r,flushSync:n}=o,i=H(o,["on","subscribe","flushSync"]),s=Ct({on:t,subscribe:r,flushSync:n});ke(()=>{s.current={on:t,subscribe:r,flushSync:n}});const a=Ss(Object.entries(i).map(([l,u])=>id({fieldName:l,scopeElement:u},{key:l})));return ee(()=>{const l=Object.fromEntries(a),{on:u,subscribe:d,flushSync:c}=s.current;return u&&(l.on=(f,h)=>u(f,h)),d&&(l.subscribe=f=>d(f)),c&&(l.flushSync=()=>c()),l},[...a])}),Ms=ks(null),ad=(e,t)=>_s(Ms,e,t),Ls=()=>{const e=Ts(Ms);if(!e)throw new Error("Model context is not available in this context");return e},od=oe(({toolkit:e})=>{const[t,r]=Ye(()=>({tools:{}})),n=Ls();ke(()=>{if(!e)return;const s=[];for(const[l,u]of Object.entries(e))u.render&&s.push(i(l,u.render));const a=Object.entries(e).reduce((l,[u,d])=>{const h=d,{render:c}=h,f=H(h,["render"]);return l[u]=f,l},{}),o={getModelContext:()=>({tools:a})};return s.push(n.register(o)),()=>{s.forEach(l=>l())}},[e,n]);const i=(s,a)=>(r(o=>{var l;return E(m({},o),{tools:E(m({},o.tools),{[s]:[...(l=o.tools[s])!=null?l:[],a]})})}),()=>{r(o=>{var l,u;return E(m({},o),{tools:E(m({},o.tools),{[s]:(u=(l=o.tools[s])==null?void 0:l.filter(d=>d!==a))!=null?u:[]})})})});return qe({getState:()=>t,setToolUI:i})}),ld=oe(()=>ee(()=>{const t=new Map;return{on:(r,n)=>{t.has(r)||t.set(r,new Set);const i=t.get(r);return i.add(n),()=>{i.delete(n),i.size===0&&t.delete(r)}},emit:(r,n)=>{const i=t.get(r),s=t.get("*");!i&&!s||queueMicrotask(()=>{if(i)for(const a of i)a(n);if(s)for(const a of s)a({event:r,payload:n})})}}},[])),Ns=ks(null),ud=(e,t)=>_s(Ns,e,t),Tn=()=>{const e=Ts(Ns);if(!e)throw new Error("Events context is not available");return e},cd=oe(()=>{const[e]=Ye(()=>({})),t=new cn;return qe({getState:()=>e,getModelContext:()=>t.getModelContext(),subscribe:r=>t.subscribe(r),register:r=>t.registerModelContextProvider(r)})}),dd=oe(({threads:e,modelContext:t,tools:r})=>{const n=He(ld()),{threads:i,tools:s,modelContext:a}=ud(n,()=>{const l=Nr(t!=null?t:cd(),[t]);return ad(l.api,()=>({modelContext:l,tools:Nr(r!=null?r:od({}),[r]),threads:Nr(e,[e])}))}),o=ee(()=>({threads:i.state,tools:s.state,modelContext:a.state}),[i.state,s.state,a.state]);return qe({getState:()=>o,threads:i.api,tools:s.api,modelContext:a.api,on:n.on})}),hd=e=>{const t=()=>e.getState().api.threads.item("main");return{threads:be({source:"root",query:{},get:()=>e.getState().api.threads}),tools:be({source:"root",query:{},get:()=>e.getState().api.tools}),modelContext:be({source:"root",query:{},get:()=>e.getState().api.modelContext}),thread:be({source:"threads",query:{type:"main"},get:()=>e.getState().api.threads.thread("main")}),threadListItem:be({source:"threads",query:{type:"main"},get:()=>t()}),composer:be({source:"thread",query:{},get:()=>e.getState().api.threads.thread("main").composer}),on(r,n){const{event:i,scope:s}=_t(r);if(s==="*")return e.getState().api.on(i,n);if(dt("thread",s)||dt("thread-list-item",s)||dt("composer",s))return e.getState().api.on(i,a=>{a.threadId===t().getState().id&&n(a)});throw new Error(`Event scope is not available in this component: ${s}`)},subscribe:e.subscribe,flushSync:e.flushSync}},fd=e=>{const t=Or(),r=vn(Ps(dd(e))),n=y.useMemo(()=>hd(r),[r]);return y.useMemo(()=>Os(t,n),[t,n])},be=e=>{const t=e.get;return t.source=e.source,t.query=e.query,t},at=()=>()=>{},Ds=y.createContext({threads:be({source:null,query:{},get:()=>{throw new Error("Threads is only available inside <AssistantProvider />")}}),tools:be({source:null,query:{},get:()=>{throw new Error("Tools is only available inside <AssistantProvider />")}}),modelContext:be({source:null,query:{},get:()=>{throw new Error("ModelContext is only available inside <AssistantProvider />")}}),threadListItem:be({source:null,query:{},get:()=>{throw new Error("ThreadListItem is only available inside <AssistantProvider />")}}),thread:be({source:null,query:{},get:()=>{throw new Error("Thread is only available inside <AssistantProvider />")}}),composer:be({source:null,query:{},get:()=>{throw new Error("Composer is only available inside <AssistantProvider />")}}),message:be({source:null,query:{},get:()=>{throw new Error("Message is only available inside <ThreadPrimitive.Messages />")}}),part:be({source:null,query:{},get:()=>{throw new Error("Part is only available inside <MessagePrimitive.Parts />")}}),attachment:be({source:null,query:{},get:()=>{throw new Error("Attachment is only available inside <MessagePrimitive.Attachments /> or <ComposerPrimitive.Attachments />")}}),subscribe:at,flushSync:at,on:e=>{const{scope:t}=_t(e);throw new Error(`Event scope is not available in this component: ${t}`)}}),Or=()=>y.useContext(Ds),Xt=e=>{const t=Or(),r=vn(sd(e));return y.useMemo(()=>Os(t,r),[t,r])},pd=e=>fd(e);function ue(e){return e?pd(e):Or()}var md=(e,t)=>e===at?t:t===at?e:(...r)=>{e(...r),t(...r)},gd=(e,t)=>e===at?t:t===at?e:(...r)=>{const n=e(...r),i=t(...r);return()=>{n(),i()}},Os=(e,t)=>{const r=t.subscribe,n=t.flushSync;return E(m(m({},e),t),{subscribe:gd(e.subscribe,r!=null?r:at),flushSync:md(e.flushSync,n!=null?n:at)})},At=({api:e,children:t,devToolsVisible:r=!0})=>(y.useEffect(()=>{if(!(!r||!e.subscribe))return qc.register(e)},[e,r]),p.jsx(Ds.Provider,{value:e,children:t})),Fs=(Kl=class{constructor(e){jt(this,ze);Ut(this,ze,e)}get threads(){return De(this,ze).threads().getState()}get tools(){return De(this,ze).tools().getState()}get threadListItem(){return De(this,ze).threadListItem().getState()}get thread(){return De(this,ze).thread().getState()}get composer(){return De(this,ze).composer().getState()}get message(){return De(this,ze).message().getState()}get part(){return De(this,ze).part().getState()}get attachment(){return De(this,ze).attachment().getState()}},ze=new WeakMap,Kl),ie=e=>{const t=ue(),r=y.useMemo(()=>new Fs(t),[t]),n=y.useSyncExternalStore(t.subscribe,()=>e(r),()=>e(r));if(y.useDebugValue(n),n instanceof Fs)throw new Error("You tried to return the entire AssistantState. This is not supported due to technical limitations.");return n},Cn=(e,t)=>{const r=ue(),n=y.useRef(t);y.useEffect(()=>{n.current=t});const{scope:i,event:s}=_t(e);y.useEffect(()=>r.on({scope:i,event:s},a=>n.current(a)),[r,i,s])};function yd(e,t){function r(n){const i=y.useContext(e);if(!(n!=null&&n.optional)&&!i)throw new Error(`This component must be used within ${t}.`);return i}return r}function Bs(e,t){function r(i){const s=e(i);return s?s[t]:null}function n(i){let s=!1,a;typeof i=="function"?a=i:i&&typeof i=="object"&&(s=!!i.optional,a=i.selector);const o=r({optional:s});return o?a?o(a):o():null}return{[t]:n,[`${t}Store`]:r}}var zs=y.createContext(null),bd=yd(zs,"ThreadPrimitive.Viewport"),{useThreadViewport:Fr,useThreadViewportStore:In}=Bs(bd,"useThreadViewport"),wd=e=>{var r;const t=e;t.__isBound||((r=t.__internal_bindMethods)==null||r.call(t),t.__isBound=!0)};function xd(e,t=vd){wd(e);const r=y.useSyncExternalStore(e.subscribe,()=>t(e.getState()),()=>t(e.getState()));return y.useDebugValue(r),r}var vd=e=>e;function Rs(e){function t(r){let n=!1,i;typeof r=="function"?i=r:r&&(n=!!r.optional,i=r.selector);const s=e({optional:n});return s?xd(s,i):null}return t}function js(e){const t=ue(),r=ie(()=>{var n,i,s;return t.thread.source&&(s=(i=(n=t.thread()).__internal_getRuntime)==null?void 0:i.call(n))!=null?s:null});if(!r&&!(e!=null&&e.optional))throw new Error("ThreadRuntime is not available");return r}var Sd=Rs(js);function kd(e){const t=ue(),r=ie(()=>{var n,i,s;return t.threadListItem.source&&(s=(i=(n=t.threadListItem()).__internal_getRuntime)==null?void 0:i.call(n))!=null?s:null});if(!r&&!(e!=null&&e.optional))throw new Error("ThreadListItemRuntime is not available");return r}var Us=Rs(kd),ht=e=>{const[,t]=Ye(e.getState);return ke(()=>(t(e.getState()),e.subscribe(()=>{t(e.getState())})),[e]),e.getState()},_d=oe(({runtime:e})=>{const t=ht(e),r=Tn();return ke(()=>{const n=[],i=["switched-to","switched-away"];for(const s of i){const a=e.unstable_on(s,()=>{r.emit(`thread-list-item.${s}`,{threadId:e.getState().id})});n.push(a)}return()=>{for(const s of n)s()}},[e,r]),qe({getState:()=>t,switchTo:e.switchTo,rename:e.rename,archive:e.archive,unarchive:e.unarchive,delete:e.delete,generateTitle:e.generateTitle,initialize:e.initialize,detach:e.detach,__internal_getRuntime:()=>e},{key:t.id})}),Qt=e=>{const t=Ss(e);return{state:t.map(r=>r.state),api:r=>{var i,s;const n="index"in r?(i=t[r.index])==null?void 0:i.api:(s=t.find(a=>a.key===r.key))==null?void 0:s.api;if(!n)throw new Error(`tapLookupResources: Resource not found for lookup: ${JSON.stringify(r)}`);return n}}},$s=oe(({runtime:e})=>{const t=ht(e);return qe({getState:()=>t,remove:e.remove,__internal_getRuntime:()=>e},{key:t.id})}),Td=oe(({runtime:e,index:t})=>{const r=ee(()=>e.getAttachmentByIndex(t),[e,t]);return He($s({runtime:r}))}),Hs=oe(({threadIdRef:e,messageIdRef:t,runtime:r})=>{var o;const n=ht(r),i=Tn();ke(()=>{const l=[],u=["send","attachment-add"];for(const d of u){const c=r.unstable_on(d,()=>{i.emit(`composer.${d}`,m({threadId:e.current},t&&{messageId:t.current}))});l.push(c)}return()=>{for(const d of l)d()}},[r,i,e,t]);const s=Qt(n.attachments.map((l,u)=>Td({runtime:r,index:u},{key:u}))),a=ee(()=>{var l;return{text:n.text,role:n.role,attachments:s.state,runConfig:n.runConfig,isEditing:n.isEditing,canCancel:n.canCancel,attachmentAccept:n.attachmentAccept,isEmpty:n.isEmpty,type:(l=n.type)!=null?l:"thread"}},[n,s.state]);return qe({getState:()=>a,setText:r.setText,setRole:r.setRole,setRunConfig:r.setRunConfig,addAttachment:r.addAttachment,reset:r.reset,clearAttachments:r.clearAttachments,send:r.send,cancel:r.cancel,beginEdit:(o=r.beginEdit)!=null?o:(()=>{throw new Error("beginEdit is not supported in this runtime")}),attachment:l=>"id"in l?s.api({key:l.id}):s.api(l),__internal_getRuntime:()=>r})}),Cd=oe(({runtime:e})=>{const t=ht(e);return qe({getState:()=>t,addToolResult:n=>e.addToolResult(n),resumeToolCall:n=>e.resumeToolCall(n),__internal_getRuntime:()=>e},{key:t.type==="tool-call"?`toolCallId-${t.toolCallId}`:void 0})}),Id=oe(({runtime:e,index:t})=>{const r=ee(()=>e.getAttachmentByIndex(t),[e,t]);return He($s({runtime:r}))}),Ed=oe(({runtime:e,index:t})=>{const r=ee(()=>e.getMessagePartByIndex(t),[e,t]);return He(Cd({runtime:r}))}),Ad=oe(({runtime:e,threadIdRef:t})=>{var f,h;const r=ht(e),[n,i]=Ye(!1),[s,a]=Ye(!1),o=ee(()=>({get current(){return e.getState().id}}),[e]),l=He(Hs({runtime:e.composer,threadIdRef:t,messageIdRef:o})),u=Qt(r.content.map((g,S)=>Ed({runtime:e,index:S},{key:S}))),d=Qt((h=(f=r.attachments)==null?void 0:f.map((g,S)=>Id({runtime:e,index:S},{key:S})))!=null?h:[]),c=ee(()=>E(m({},r),{parts:u.state,composer:l.state,isCopied:n,isHovering:s}),[r,u.state,l.state,n,s]);return qe({getState:()=>c,composer:l.api,reload:g=>e.reload(g),speak:()=>e.speak(),stopSpeaking:()=>e.stopSpeaking(),submitFeedback:g=>e.submitFeedback(g),switchToBranch:g=>e.switchToBranch(g),getCopyText:()=>e.unstable_getCopyText(),part:g=>"index"in g?u.api({index:g.index}):u.api({key:`toolCallId-${g.toolCallId}`}),attachment:g=>"id"in g?d.api({key:g.id}):d.api(g),setIsCopied:i,setIsHovering:a,__internal_getRuntime:()=>e},{key:r.id})}),Pd=oe(({runtime:e,id:t,threadIdRef:r})=>{const n=ee(()=>e.getMessageById(t),[e,t]);return He(Ad({runtime:n,threadIdRef:r}))}),Md=oe(({runtime:e})=>{const t=ht(e),r=Tn();ke(()=>{const o=[],l=["run-start","run-end","initialize","model-context-update"];for(const u of l){const d=e.unstable_on(u,()=>{var f;const c=((f=e.getState())==null?void 0:f.threadId)||"unknown";r.emit(`thread.${u}`,{threadId:c})});o.push(d)}return()=>{for(const u of o)u()}},[e]);const n=ee(()=>({get current(){return e.getState().threadId}}),[e]),i=He(Hs({runtime:e.composer,threadIdRef:n})),s=Qt(t.messages.map(o=>Pd({runtime:e,id:o.id,threadIdRef:n},{key:o.id}))),a=ee(()=>({isEmpty:s.state.length===0&&!t.isLoading,isDisabled:t.isDisabled,isLoading:t.isLoading,isRunning:t.isRunning,capabilities:t.capabilities,state:t.state,suggestions:t.suggestions,extras:t.extras,speech:t.speech,composer:i.state,messages:s.state}),[t,s,i.state]);return qe({getState:()=>a,composer:i.api,append:e.append,startRun:e.startRun,unstable_resumeRun:e.unstable_resumeRun,cancelRun:e.cancelRun,getModelContext:e.getModelContext,export:e.export,import:e.import,reset:e.reset,stopSpeaking:e.stopSpeaking,startVoice:()=>P(null,null,function*(){throw new Error("startVoice is not supported in this runtime")}),stopVoice:()=>P(null,null,function*(){throw new Error("stopVoice is not supported in this runtime")}),message:o=>"id"in o?s.api({key:o.id}):s.api(o),__internal_getRuntime:()=>e})}),Ld=oe(({runtime:e,id:t})=>{const r=ee(()=>e.getItemById(t),[e,t]);return He(_d({runtime:r}))}),Nd=oe(({runtime:e,__internal_assistantRuntime:t})=>{const r=ht(e),n=He(Md({runtime:e.main})),i=Qt(Object.keys(r.threadItems).map(a=>Ld({runtime:e,id:a},{key:a}))),s=ee(()=>{var a;return{mainThreadId:r.mainThreadId,newThreadId:(a=r.newThread)!=null?a:null,isLoading:r.isLoading,threadIds:r.threads,archivedThreadIds:r.archivedThreads,threadItems:i.state,main:n.state}},[r,i.state,n.state]);return qe({getState:()=>s,thread:()=>n.api,item:a=>{if(a==="main")return i.api({key:s.mainThreadId});if("id"in a)return i.api({key:a.id});const{index:o,archived:l=!1}=a,u=l?s.archivedThreadIds[o]:s.threadIds[o];return i.api({key:u})},switchToThread:a=>{e.switchToThread(a)},switchToNewThread:()=>{e.switchToNewThread()},__internal_getAssistantRuntime:()=>t})}),Dd=oe(e=>{const t=Ls();return ke(()=>e.registerModelContextProvider(t),[e,t]),He(Nd({runtime:e.threads,__internal_assistantRuntime:e}))}),En=e=>{const t=new Map,r=()=>{let n=0;for(const i of t.values())n+=i;e(n)};return{register:()=>{const n=Symbol();return t.set(n,0),{setHeight:i=>{t.get(n)!==i&&(t.set(n,i),r())},unregister:()=>{t.delete(n),r()}}}}},Od=(e={})=>{const t=new Set,r=En(a=>{s.setState({height:E(m({},s.getState().height),{viewport:a})})}),n=En(a=>{s.setState({height:E(m({},s.getState().height),{inset:a})})}),i=En(a=>{s.setState({height:E(m({},s.getState().height),{userMessage:a})})}),s=It(()=>{var a;return{isAtBottom:!0,scrollToBottom:({behavior:o="auto"}={})=>{for(const l of t)l({behavior:o})},onScrollToBottom:o=>(t.add(o),()=>{t.delete(o)}),turnAnchor:(a=e.turnAnchor)!=null?a:"bottom",height:{viewport:0,inset:0,userMessage:0},registerViewport:r.register,registerContentInset:n.register,registerUserMessageHeight:i.register}});return s},Zt=e=>e,Fd=e=>{const t=In({optional:!0}),[r]=y.useState(()=>Od(e));return y.useEffect(()=>t==null?void 0:t.getState().onScrollToBottom(()=>{r.getState().scrollToBottom()}),[t,r]),y.useEffect(()=>{if(t)return r.subscribe(n=>{t.getState().isAtBottom!==n.isAtBottom&&Zt(t).setState({isAtBottom:n.isAtBottom})})},[r,t]),y.useEffect(()=>{var s;const n={turnAnchor:(s=e.turnAnchor)!=null?s:"bottom"};r.getState().turnAnchor!==n.turnAnchor&&Zt(r).setState(n)},[r,e.turnAnchor]),r},qs=({children:e,options:t={}})=>{const r=Fd(t),[n]=y.useState(()=>({useThreadViewport:r}));return p.jsx(zs.Provider,{value:n,children:e})},Bd=e=>{var t;return(t=e._core)==null?void 0:t.RenderComponent},zd=({children:e,runtime:t})=>{const r=ue({threads:Dd(t)}),n=Bd(t);return p.jsxs(At,{api:r,children:[n&&p.jsx(n,{}),p.jsx(qs,{children:e})]})},Vs=y.memo(zd),Rd=({index:e,archived:t,children:r})=>{const n=ue(),i=Xt({threadListItem:Et({source:"threads",query:{type:"index",index:e,archived:t},get:()=>n.threads().item({index:e,archived:t})}),on(s,a){const o=()=>n.threads().item({index:e,archived:t}),{event:l,scope:u}=_t(s);return dt("thread-list-item",u)?n.on({scope:"*",event:l},d=>{d.threadId===o().getState().id&&a(d)}):n.on(s,a)}});return p.jsx(At,{api:i,children:r})},jd=({id:e,children:t})=>{const r=ue(),n=Xt({threadListItem:Et({source:"threads",query:{type:"id",id:e},get:()=>r.threads().item({id:e})}),on(i,s){const a=()=>r.threads().item({id:e}),{event:o,scope:l}=_t(i);return dt("thread-list-item",l)?r.on({scope:"*",event:o},u=>{u.threadId===a().getState().id&&s(u)}):r.on(i,s)}});return p.jsx(At,{api:n,children:t})},Ud=({index:e,children:t})=>{const r=ue(),n=Xt({message:Et({source:"thread",query:{type:"index",index:e},get:()=>r.thread().message({index:e})}),composer:Et({source:"message",query:{},get:()=>r.thread().message({index:e}).composer}),on(i,s){const a=()=>r.thread().message({index:e}),{event:o,scope:l}=_t(i);return!dt("composer",l)&&!dt("message",l)?r.on(i,s):r.on({scope:"thread",event:o},u=>{u.messageId===a().getState().id&&s(u)})}});return p.jsx(At,{api:n,children:t})},$d=({index:e,children:t})=>{const r=ue(),n=Xt({part:Et({source:"message",query:{type:"index",index:e},get:()=>r.message().part({index:e})})});return p.jsx(At,{api:n,children:t})},Hd=oe(({text:e,isRunning:t})=>{const r=ee(()=>({type:"text",text:e,status:t?{type:"running"}:{type:"complete"}}),[e,t]);return qe({getState:()=>r,addToolResult:()=>{throw new Error("Not supported")},resumeToolCall:()=>{throw new Error("Not supported")}})}),qd=({text:e,isRunning:t=!1,children:r})=>{const n=vn(Ps(Hd({text:e,isRunning:t}))),i=Xt({part:Et({source:"root",query:{},get:()=>n.getState().api}),subscribe:n.subscribe,flushSync:n.flushSync});return p.jsx(At,{api:i,children:r})},Ws=(e,t)=>{var r,n;return t===void 0?((r=e.status)==null?void 0:r.type)==="requires-action"&&e.status.reason==="tool-calls"&&e.content.every(i=>i.type!=="tool-call"||!!i.result):((n=e.status)==null?void 0:n.type)==="requires-action"&&e.status.reason==="tool-calls"&&e.content.every(i=>i.type!=="tool-call"||!!i.result||!t.includes(i.toolName))},An=class extends Error{constructor(t,r){super(r);T(this,"name","AbortError");T(this,"detach");this.detach=t}},Vd=class extends Fc{constructor(t,r){super(t);T(this,"capabilities",{switchToBranch:!0,switchBranchDuringRun:!0,edit:!0,reload:!0,cancel:!0,unstable_copy:!0,speech:!1,attachments:!1,feedback:!1});T(this,"abortController",null);T(this,"isDisabled",!1);T(this,"_isLoading",!1);T(this,"_suggestions",[]);T(this,"_suggestionsController",null);T(this,"_options");T(this,"_lastRunConfig",{});T(this,"_loadPromise");this.__internal_setOptions(r)}get isLoading(){return this._isLoading}get suggestions(){return this._suggestions}get adapters(){return this._options.adapters}get extras(){}__internal_setOptions(t){var a,o,l;if(this._options===t)return;this._options=t;let r=!1;const n=((a=t.adapters)==null?void 0:a.speech)!==void 0;this.capabilities.speech!==n&&(this.capabilities.speech=n,r=!0);const i=((o=t.adapters)==null?void 0:o.attachments)!==void 0;this.capabilities.attachments!==i&&(this.capabilities.attachments=i,r=!0);const s=((l=t.adapters)==null?void 0:l.feedback)!==void 0;this.capabilities.feedback!==s&&(this.capabilities.feedback=s,r=!0),r&&this._notifySubscribers()}__internal_load(){var r,n;if(this._loadPromise)return this._loadPromise;const t=(n=(r=this.adapters.history)==null?void 0:r.load())!=null?n:Promise.resolve(null);return this._isLoading=!0,this._notifySubscribers(),this._loadPromise=t.then(i=>{var a,o;if(!i)return;this.repository.import(i),this._notifySubscribers();const s=(o=(a=this.adapters.history)==null?void 0:a.resume)==null?void 0:o.bind(this.adapters.history);i.unstable_resume&&s&&this.startRun({parentId:this.repository.headId,sourceId:this.repository.headId,runConfig:this._lastRunConfig},s)}).finally(()=>{this._isLoading=!1,this._notifySubscribers()}),this._loadPromise}append(t){return P(this,null,function*(){var i,s,a;this.ensureInitialized();const r=Wt(t,ut(),{type:"complete",reason:"unknown"});this.repository.addOrUpdateMessage(t.parentId,r),(i=this._options.adapters.history)==null||i.append(m({parentId:t.parentId,message:r},t.runConfig!==void 0&&{runConfig:t.runConfig})),((s=t.startRun)!=null?s:t.role==="user")?yield this.startRun({parentId:r.id,sourceId:t.sourceId,runConfig:(a=t.runConfig)!=null?a:{}}):(this.repository.resetHead(r.id),this._notifySubscribers())})}resumeRun(n){var i=n,{stream:t}=i,r=H(i,["stream"]);if(!t)throw new Error("You must pass a stream parameter to resume runs.");return this.startRun(r,t)}unstable_loadExternalState(){throw new Error("Runtime does not support importing external states.")}startRun(i,s){return P(this,arguments,function*({parentId:t,runConfig:r},n){var u,d,c;this.ensureInitialized();let o={id:ut(),role:"assistant",status:{type:"running"},content:[],metadata:{unstable_state:this.state,unstable_annotations:[],unstable_data:[],steps:[],custom:{}},createdAt:new Date};this._notifyEventSubscribers("run-start");try{this._suggestions=[],(u=this._suggestionsController)==null||u.abort(),this._suggestionsController=null,this._notifySubscribers();do o=yield this.performRoundtrip(t,o,r,n),n=void 0;while(Ws(o,this._options.unstable_humanToolNames))}finally{this._notifyEventSubscribers("run-end")}this._suggestionsController=new AbortController;const l=this._suggestionsController.signal;if(this.adapters.suggestion&&((d=o.status)==null?void 0:d.type)!=="requires-action"){const w=(c=this.adapters.suggestion)==null?void 0:c.generate({messages:this.messages});if(Symbol.asyncIterator in w)try{for(var f=xt(w),h,g,S;h=!(g=yield f.next()).done;h=!1){const b=g.value;if(l.aborted)break;this._suggestions=b,this._notifySubscribers()}}catch(g){S=[g]}finally{try{h&&(g=f.return)&&(yield g.call(f))}finally{if(S)throw S[0]}}else{const b=yield w;if(l.aborted)return;this._suggestions=b,this._notifySubscribers()}}})}performRoundtrip(t,r,n,i){return P(this,null,function*(){var g,S,w,b,C,_,F,B,I,N;const s=t?this.repository.getMessages(t):[];(g=this.abortController)==null||g.abort(),this.abortController=new AbortController;const a=r.content,o=(S=r.metadata)==null?void 0:S.unstable_annotations,l=(w=r.metadata)==null?void 0:w.unstable_data,u=(b=r.metadata)==null?void 0:b.steps,d=(C=r.metadata)==null?void 0:C.custom,c=M=>{var fe,x,ye,Ie,v,ve;const V=(fe=M.metadata)==null?void 0:fe.steps,R=V?[...u!=null?u:[],...V]:void 0,D=(x=M.metadata)==null?void 0:x.unstable_annotations,Q=(ye=M.metadata)==null?void 0:ye.unstable_data,se=D?[...o!=null?o:[],...D]:void 0,ge=Q?[...l!=null?l:[],...Q]:void 0;r=m(E(m(m({},r),M.content?{content:[...a,...(Ie=M.content)!=null?Ie:[]]}:void 0),{status:(v=M.status)!=null?v:r.status}),M.metadata?{metadata:m(m(m(m(m(m({},r.metadata),M.metadata.unstable_state?{unstable_state:M.metadata.unstable_state}:void 0),se?{unstable_annotations:se}:void 0),ge?{unstable_data:ge}:void 0),R?{steps:R}:void 0),(ve=M.metadata)!=null&&ve.custom?{custom:m(m({},d!=null?d:{}),M.metadata.custom)}:void 0)}:void 0),this.repository.addOrUpdateMessage(t,r),this._notifySubscribers()},f=(_=this._options.maxSteps)!=null?_:2;if(((I=(B=(F=r.metadata)==null?void 0:F.steps)==null?void 0:B.length)!=null?I:0)>=f)return c({status:{type:"incomplete",reason:"tool-calls"}}),r;c({status:{type:"running"}}),this.repository.resetHead(r.id),this._notifySubscribers();try{this._lastRunConfig=n!=null?n:{};const M=this.getModelContext();i=i!=null?i:this.adapters.chatModel.run.bind(this.adapters.chatModel);const V=this.abortController.signal,R=i({messages:s,runConfig:this._lastRunConfig,abortSignal:V,context:M,config:M,unstable_assistantMessageId:r.id,unstable_getMessage(){return r}});if(Symbol.asyncIterator in R)try{for(var z=xt(R),j,$,k;j=!($=yield z.next()).done;j=!1){const D=$.value;if(V.aborted){c({status:{type:"incomplete",reason:"cancelled"}});break}c(D)}}catch($){k=[$]}finally{try{j&&($=z.return)&&(yield $.call(z))}finally{if(k)throw k[0]}}else c(yield R);r.status.type==="running"&&c({status:{type:"complete",reason:"unknown"}})}catch(M){if(M instanceof An)c({status:{type:"incomplete",reason:"cancelled"}});else throw c({status:{type:"incomplete",reason:"error",error:M instanceof Error?M.message:`[${typeof M}] ${new String(M).toString()}`}}),M}finally{this.abortController=null,(r.status.type==="complete"||r.status.type==="incomplete")&&(yield(N=this._options.adapters.history)==null?void 0:N.append({parentId:t,message:r,runConfig:this._lastRunConfig}))}return r})}detach(){var r;const t=new An(!0);(r=this.abortController)==null||r.abort(t),this.abortController=null}cancelRun(){var r;const t=new An(!1);(r=this.abortController)==null||r.abort(t),this.abortController=null}addToolResult({messageId:t,toolCallId:r,result:n,isError:i,artifact:s}){const a=this.repository.getMessage(t),{parentId:o}=a;let{message:l}=a;if(l.role!=="assistant")throw new Error("Tried to add tool result to non-assistant message");let u=!1,d=!1;const c=l.content.map(f=>f.type!=="tool-call"||f.toolCallId!==r?f:(d=!0,f.result||(u=!0),E(m({},f),{result:n,artifact:s,isError:i})));if(!d)throw new Error("Tried to add tool result to non-existing tool call");l=E(m({},l),{content:c}),this.repository.addOrUpdateMessage(o,l),u&&Ws(l,this._options.unstable_humanToolNames)&&this.performRoundtrip(o,l,this._lastRunConfig)}resumeToolCall(t){throw new Error("Local runtime does not support resuming tool calls.")}},Js=Object.freeze([]),Pn="__DEFAULT_ID__",Wd=Object.freeze({[Pn]:{id:Pn,remoteId:void 0,externalId:void 0,status:"regular",title:void 0}}),Jd=class extends qt{constructor(t){super();T(this,"_mainThread");this._mainThread=t()}get isLoading(){return!1}getMainThreadRuntimeCore(){return this._mainThread}get newThreadId(){throw new Error("Method not implemented.")}get threadIds(){throw Js}get archivedThreadIds(){throw Js}get mainThreadId(){return Pn}get threadData(){return Wd}getThreadRuntimeCore(){throw new Error("Method not implemented.")}getLoadThreadsPromise(){throw new Error("Method not implemented.")}getItemById(t){if(t===this.mainThreadId)return{status:"regular",id:this.mainThreadId,remoteId:this.mainThreadId,externalId:void 0,title:void 0,isMain:!0};throw new Error("Method not implemented")}switchToThread(){return P(this,null,function*(){throw new Error("Method not implemented.")})}switchToNewThread(){throw new Error("Method not implemented.")}rename(){throw new Error("Method not implemented.")}archive(){throw new Error("Method not implemented.")}detach(){throw new Error("Method not implemented.")}unarchive(){throw new Error("Method not implemented.")}delete(){throw new Error("Method not implemented.")}initialize(t){return Promise.resolve({remoteId:t,externalId:void 0})}generateTitle(){throw new Error("Method not implemented.")}},Gd=class extends dn{constructor(t,r){super();T(this,"threads");T(this,"Provider");T(this,"_options");this._options=t,this.threads=new Jd(()=>new Vd(this._contextProvider,this._options)),r&&this.threads.getMainThreadRuntimeCore().import(gn.fromArray(r))}},Gs=e=>{try{const r=e.split(".")[1];if(!r)throw new Error("Invalid JWT format");let n=r.replace(/-/g,"+").replace(/_/g,"/");for(;n.length%4!==0;)n+="=";const i=atob(n),a=JSON.parse(i).exp;if(!a||typeof a!="number")throw new Error('JWT does not contain a valid "exp" field');return a*1e3}catch(t){throw new Error(`Unable to determine the token expiry: ${t}`)}},Ys=(Xl=class{constructor(e){T(this,"strategy","jwt");T(this,"cachedToken",null);T(this,"tokenExpiry",null);jt(this,fr);Ut(this,fr,e)}getAuthHeaders(){return P(this,null,function*(){const e=Date.now();if(this.cachedToken&&this.tokenExpiry&&this.tokenExpiry-e>30*1e3)return{Authorization:`Bearer ${this.cachedToken}`};const t=yield De(this,fr).call(this);return t?(this.cachedToken=t,this.tokenExpiry=Gs(t),{Authorization:`Bearer ${t}`}):!1})}readAuthHeaders(e){const t=e.get("Authorization");if(!t)return;const[r,n]=t.split(" ");if(r!=="Bearer"||!n)throw new Error("Invalid auth header received");this.cachedToken=n,this.tokenExpiry=Gs(n)}},fr=new WeakMap,Xl),Yd=(Ql=class{constructor(e,t,r){T(this,"strategy","api-key");jt(this,pr);jt(this,mr);jt(this,gr);Ut(this,pr,e),Ut(this,mr,t),Ut(this,gr,r)}getAuthHeaders(){return P(this,null,function*(){return{Authorization:`Bearer ${De(this,pr)}`,"Aui-User-Id":De(this,mr),"Aui-Workspace-Id":De(this,gr)}})}readAuthHeaders(){}},pr=new WeakMap,mr=new WeakMap,gr=new WeakMap,Ql),Br="aui:refresh_token",Kd=class{constructor(e){T(this,"strategy","anon");T(this,"baseUrl");T(this,"jwtStrategy");this.baseUrl=e,this.jwtStrategy=new Ys(()=>P(this,null,function*(){const t=Date.now(),r=localStorage.getItem(Br),n=r?JSON.parse(r):void 0;if(n)if(new Date(n.expires_at).getTime()-t>30*1e3){const u=yield fetch(`${this.baseUrl}/v1/auth/tokens/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refresh_token:n.token})});if(u.ok){const d=yield u.json(),{access_token:c,refresh_token:f}=d;return f&&localStorage.setItem(Br,JSON.stringify(f)),c}}else localStorage.removeItem(Br);const i=yield fetch(`${this.baseUrl}/v1/auth/tokens/anonymous`,{method:"POST"});if(!i.ok)return null;const s=yield i.json(),{access_token:a,refresh_token:o}=s;return!a||!o?null:(localStorage.setItem(Br,JSON.stringify(o)),a)}))}getAuthHeaders(){return P(this,null,function*(){return this.jwtStrategy.getAuthHeaders()})}readAuthHeaders(e){this.jwtStrategy.readAuthHeaders(e)}},Xd=class extends Error{constructor(e){super(e),this.name="APIError"}},Qd=class{constructor(e){T(this,"_auth");T(this,"_baseUrl");if("authToken"in e)this._baseUrl=e.baseUrl,this._auth=new Ys(e.authToken);else if("apiKey"in e)this._baseUrl="https://backend.assistant-api.com",this._auth=new Yd(e.apiKey,e.userId,e.workspaceId);else if("anonymous"in e)this._baseUrl=e.baseUrl,this._auth=new Kd(e.baseUrl);else throw new Error("Invalid configuration: Must provide authToken, apiKey, or anonymous configuration")}initializeAuth(){return P(this,null,function*(){return!!this._auth.getAuthHeaders()})}makeRawRequest(r){return P(this,arguments,function*(e,t={}){var l;const n=yield this._auth.getAuthHeaders();if(!n)throw new Error("Authorization failed");const i=E(m(m({},n),t.headers),{"Content-Type":"application/json"}),s=new URLSearchParams;if(t.query)for(const[u,d]of Object.entries(t.query))d!==!1&&(d===!0?s.set(u,"true"):s.set(u,d.toString()));const a=new URL(`${this._baseUrl}/v1${e}`);a.search=s.toString();const o=yield fetch(a,{method:(l=t.method)!=null?l:"GET",headers:i,body:t.body?JSON.stringify(t.body):null});if(this._auth.readAuthHeaders(o.headers),!o.ok){const u=yield o.text();try{const d=JSON.parse(u);throw new Xd(d.message)}catch(d){throw new Error(`Request failed with status ${o.status}, ${u}`)}}return o})}makeRequest(r){return P(this,arguments,function*(e,t={}){return(yield this.makeRawRequest(e,t)).json()})}},Zd=class{constructor(e){this.cloud=e}create(){return P(this,null,function*(){return this.cloud.makeRequest("/auth/tokens",{method:"POST"})})}},eh=class{constructor(e){this.cloud=e}__internal_getAssistantOptions(e){return{api:`${this.cloud._baseUrl}/v1/runs/stream`,headers:()=>P(this,null,function*(){const t=yield this.cloud._auth.getAuthHeaders();if(!t)throw new Error("Authorization failed");return E(m({},t),{Accept:"text/plain"})}),body:{assistant_id:e,response_format:"vercel-ai-data-stream/v1",thread_id:"unstable_todo"}}}stream(e){return P(this,null,function*(){const t=yield this.cloud.makeRawRequest("/runs/stream",{method:"POST",headers:{Accept:"text/plain"},body:e});return pn.fromResponse(t,new hc)})}},th=class{constructor(e){this.cloud=e}list(e,t){return P(this,null,function*(){return this.cloud.makeRequest(`/threads/${encodeURIComponent(e)}/messages`,{query:t})})}create(e,t){return P(this,null,function*(){return this.cloud.makeRequest(`/threads/${encodeURIComponent(e)}/messages`,{method:"POST",body:t})})}},rh=class{constructor(e){T(this,"messages");this.cloud=e,this.messages=new th(e)}list(e){return P(this,null,function*(){return this.cloud.makeRequest("/threads",{query:e})})}get(e){return P(this,null,function*(){return this.cloud.makeRequest(`/threads/${encodeURIComponent(e)}`)})}create(e){return P(this,null,function*(){return this.cloud.makeRequest("/threads",{method:"POST",body:e})})}update(e,t){return P(this,null,function*(){return this.cloud.makeRequest(`/threads/${encodeURIComponent(e)}`,{method:"PUT",body:t})})}delete(e){return P(this,null,function*(){return this.cloud.makeRequest(`/threads/${encodeURIComponent(e)}`,{method:"DELETE"})})}},nh=class{constructor(e){this.cloud=e}pdfToImages(e){return P(this,null,function*(){return this.cloud.makeRequest("/files/pdf-to-images",{method:"POST",body:e})})}generatePresignedUploadUrl(e){return P(this,null,function*(){return this.cloud.makeRequest("/files/attachments/generate-presigned-upload-url",{method:"POST",body:e})})}},ih=class{constructor(e){T(this,"threads");T(this,"auth");T(this,"runs");T(this,"files");const t=new Qd(e);this.threads=new rh(t),this.auth={tokens:new Zd(t)},this.runs=new eh(t),this.files=new nh(t)}};function Mn(e,t=0){return t>100?!1:e===null||typeof e=="string"||typeof e=="boolean"?!0:typeof e=="number"?!Number.isNaN(e)&&Number.isFinite(e):Array.isArray(e)?e.every(r=>Mn(r,t+1)):typeof e=="object"?Object.entries(e).every(([r,n])=>typeof r=="string"&&Mn(n,t+1)):!1}var sh=e=>{var t;return m({role:e.role,content:e.content.map(r=>{const n=r.type;switch(n){case"text":return{type:"text",text:r.text};case"reasoning":return{type:"reasoning",text:r.text};case"source":return m({type:"source",sourceType:r.sourceType,id:r.id,url:r.url},r.title?{title:r.title}:void 0);case"tool-call":return Mn(r.result)||console.warn(`tool-call result is not JSON! ${JSON.stringify(r)}`),m(m(m({type:"tool-call",toolCallId:r.toolCallId,toolName:r.toolName},JSON.stringify(r.args)===r.argsText?{args:r.args}:{argsText:r.argsText}),r.result?{result:r.result}:{}),r.isError?{isError:!0}:{});default:{const i=n;throw new Error(`Message part type not supported by aui/v0: ${i}`)}}}),metadata:e.metadata},e.status?{status:((t=e.status)==null?void 0:t.type)==="running"?{type:"incomplete",reason:"cancelled"}:e.status}:void 0)},ah=e=>{const t=e.content,r=Wt(m({id:e.id,createdAt:e.created_at},t),e.id,{type:"complete",reason:"unknown"});return{parentId:e.parent_id,message:r}},Ln=new WeakMap,oh=class{constructor(e,t){this.parent=e,this.formatAdapter=t}append(e){return P(this,null,function*(){const t=this.formatAdapter.encode(e),r=this.formatAdapter.getId(e.message);return this.parent._appendWithFormat(e.parentId,r,this.formatAdapter.format,t)})}load(){return P(this,null,function*(){return this.parent._loadWithFormat(this.formatAdapter.format,e=>this.formatAdapter.decode(e))})}},lh=class{constructor(e,t){this.cloudRef=e,this.store=t}get _getIdForLocalId(){return Ln.has(this.store.threadListItem())||Ln.set(this.store.threadListItem(),{}),Ln.get(this.store.threadListItem())}withFormat(e){return new oh(this,e)}append(r){return P(this,arguments,function*({parentId:e,message:t}){var s;const{remoteId:n}=yield this.store.threadListItem().initialize(),i=this.cloudRef.current.threads.messages.create(n,{parent_id:e?(s=yield this._getIdForLocalId[e])!=null?s:e:null,format:"aui/v0",content:sh(t)}).then(({message_id:a})=>(this._getIdForLocalId[t.id]=a,a));return this._getIdForLocalId[t.id]=i,i.then(()=>{})})}load(){return P(this,null,function*(){const e=this.store.threadListItem().getState().remoteId;if(!e)return{messages:[]};const{messages:t}=yield this.cloudRef.current.threads.messages.list(e,{format:"aui/v0"});return{messages:t.filter(n=>n.format==="aui/v0").map(ah).reverse()}})}_appendWithFormat(e,t,r,n){return P(this,null,function*(){var a;const{remoteId:i}=yield this.store.threadListItem().initialize(),s=this.cloudRef.current.threads.messages.create(i,{parent_id:e?(a=yield this._getIdForLocalId[e])!=null?a:e:null,format:r,content:n}).then(({message_id:o})=>(this._getIdForLocalId[t]=o,o));return this._getIdForLocalId[t]=s,s.then(()=>{})})}_loadWithFormat(e,t){return P(this,null,function*(){const r=this.store.threadListItem().getState().remoteId;if(!r)return{messages:[]};const{messages:n}=yield this.cloudRef.current.threads.messages.list(r,{format:e});return{messages:n.filter(i=>i.format===e).map(i=>t({id:i.id,parent_id:i.parent_id,format:i.format,content:i.content})).reverse()}})}},uh=e=>{const t=ue(),[r]=y.useState(()=>new lh(e,t));return r},Ks=typeof process!="undefined"&&((Zl=process==null?void 0:process.env)==null?void 0:Zl.NEXT_PUBLIC_ASSISTANT_BASE_URL),Nn=Ks?new ih({baseUrl:Ks,anonymous:!0}):void 0,ch=e=>{var i;const t=y.useRef(e);y.useEffect(()=>{t.current=e},[e]);const r=y.useCallback(function({children:a}){var c;const o=uh({get current(){var f;return(f=t.current.cloud)!=null?f:Nn}}),l=(c=t.current.cloud)!=null?c:Nn,u=y.useMemo(()=>new Nc(l),[l]),d=y.useMemo(()=>({history:o,attachments:u}),[o,u]);return p.jsx(wn,{adapters:d,children:a})},[]),n=(i=e.cloud)!=null?i:Nn;return n?{list:()=>P(null,null,function*(){const{threads:s}=yield n.threads.list();return{threads:s.map(a=>{var o;return{status:a.is_archived?"archived":"regular",remoteId:a.id,title:a.title,externalId:(o=a.external_id)!=null?o:void 0}})}}),initialize:()=>P(null,null,function*(){var u,d;const a=yield(d=(u=e.create)==null?void 0:u.call(e))!=null?d:Promise.resolve(),o=a?a.externalId:void 0,{thread_id:l}=yield n.threads.create({last_message_at:new Date,external_id:o});return{externalId:o,remoteId:l}}),rename:(s,a)=>P(null,null,function*(){return n.threads.update(s,{title:a})}),archive:s=>P(null,null,function*(){return n.threads.update(s,{is_archived:!0})}),unarchive:s=>P(null,null,function*(){return n.threads.update(s,{is_archived:!1})}),delete:s=>P(null,null,function*(){var a;return yield(a=e.delete)==null?void 0:a.call(e,s),n.threads.delete(s)}),generateTitle:(s,a)=>P(null,null,function*(){return n.runs.stream({thread_id:s,assistant_id:"system/thread_title",messages:a})}),fetch:s=>P(null,null,function*(){var o;const a=yield n.threads.get(s);return{status:a.is_archived?"archived":"regular",remoteId:a.id,title:a.title,externalId:(o=a.external_id)!=null?o:void 0}}),unstable_Provider:r}:new Rc},dh=(e,n)=>{var i=n,{initialMessages:t}=i,r=H(i,["initialMessages"]);var u;const d=(u=Dc())!=null?u:{},{modelContext:s}=d,a=H(d,["modelContext"]),o=y.useMemo(()=>E(m({},r),{adapters:E(m(m({},a),r.adapters),{chatModel:e})}),[e,r,a]),[l]=y.useState(()=>new Gd(o,t));return y.useEffect(()=>()=>{l.threads.getMainThreadRuntimeCore().detach()},[l]),y.useEffect(()=>{l.threads.getMainThreadRuntimeCore().__internal_setOptions(o),l.threads.getMainThreadRuntimeCore().__internal_load()},[l,o]),y.useEffect(()=>{if(s)return l.registerModelContextProvider(s)},[s,l]),y.useMemo(()=>new Dn(l),[l])},Xs=(e,n={})=>{var i=n,{cloud:t}=i,r=H(i,["cloud"]);const s=ch({cloud:t});return ra({runtimeHook:function(){return dh(e,r)},adapter:s,allowNesting:!0})},Dn=class{constructor(e){T(this,"threads");T(this,"_thread");this._core=e,this.threads=new Mc(e.threads),this._thread=this.threads.main,this.__internal_bindMethods()}get threadList(){return this.threads}__internal_bindMethods(){this.switchToNewThread=this.switchToNewThread.bind(this),this.switchToThread=this.switchToThread.bind(this),this.registerModelContextProvider=this.registerModelContextProvider.bind(this),this.registerModelConfigProvider=this.registerModelConfigProvider.bind(this),this.reset=this.reset.bind(this)}get thread(){return this._thread}switchToNewThread(){return this._core.threads.switchToNewThread()}switchToThread(e){return this._core.threads.switchToThread(e)}registerModelContextProvider(e){return this._core.registerModelContextProvider(e)}registerModelConfigProvider(e){return this.registerModelContextProvider(e)}reset({initialMessages:e}={}){return this._core.threads.getMainThreadRuntimeCore().import(gn.fromArray(e!=null?e:[]))}},hh=e=>{const o=e,{cloud:t,initialMessages:r,maxSteps:n,adapters:i,unstable_humanToolNames:s}=o,a=H(o,["cloud","initialMessages","maxSteps","adapters","unstable_humanToolNames"]);return{localRuntimeOptions:{cloud:t,initialMessages:r,maxSteps:n,adapters:i,unstable_humanToolNames:s},otherOptions:a}};function ft(e){const t=J.useRef(e);return J.useEffect(()=>{t.current=e}),J.useMemo(()=>(...r)=>{var n;return(n=t.current)==null?void 0:n.call(t,...r)},[])}var Qs=y.createContext(null),fh=e=>({useSmoothStatus:It(()=>e)}),ph=({children:e})=>{const t=Zs({optional:!0}),r=ue(),[n]=y.useState(()=>fh(r.part().getState().status));return t?e:p.jsx(Qs.Provider,{value:n,children:e})},mh=e=>{const t=y.forwardRef((r,n)=>p.jsx(ph,{children:p.jsx(e,E(m({},r),{ref:n}))}));return t.displayName=e.displayName,t};function Zs(e){const t=y.useContext(Qs);if(!(e!=null&&e.optional)&&!t)throw new Error("This component must be used within a SmoothContextProvider.");return t}var{useSmoothStatus:gh,useSmoothStatusStore:yh}=Bs(Zs,"useSmoothStatus"),bh=class{constructor(e,t){T(this,"animationFrameId",null);T(this,"lastUpdateTime",Date.now());T(this,"targetText","");T(this,"animate",()=>{const e=Date.now();let r=e-this.lastUpdateTime;const n=this.targetText.length-this.currentText.length,i=Math.min(5,250/n);let s=0;for(;r>=i&&s<n;)s++,r-=i;s!==n?this.animationFrameId=requestAnimationFrame(this.animate):this.animationFrameId=null,s!==0&&(this.currentText=this.targetText.slice(0,this.currentText.length+s),this.lastUpdateTime=e-r,this.setText(this.currentText))});this.currentText=e,this.setText=t}start(){this.animationFrameId===null&&(this.lastUpdateTime=Date.now(),this.animate())}stop(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}},On=Object.freeze({type:"running"}),ea=(e,t=!1)=>{const{text:r}=e,n=ie(({message:d})=>d.id),i=y.useRef(n),[s,a]=y.useState(r),o=yh({optional:!0}),l=ft(d=>{if(a(d),o){const c=s!==d||e.status.type==="running"?On:e.status;Zt(o).setState(c,!0)}});y.useEffect(()=>{if(o){const d=t&&(s!==r||e.status.type==="running")?On:e.status;Zt(o).setState(d,!0)}},[o,t,r,s,e.status]);const[u]=y.useState(new bh(r,l));return y.useEffect(()=>{if(!t){u.stop();return}if(i.current!==n||!r.startsWith(u.targetText)){i.current=n,l(r),u.currentText=r,u.targetText=r,u.stop();return}u.targetText=r,u.start()},[l,u,n,t,r]),y.useEffect(()=>()=>{u.stop()},[u]),y.useMemo(()=>t?{type:"text",text:s,status:r===s?e.status:On}:e,[t,s,e,r])};const wh=Object.freeze(Object.defineProperty({__proto__:null,AssistantRuntimeImpl:Dn,BaseAssistantRuntimeCore:dn,CompositeContextProvider:cn,DefaultThreadComposerRuntimeCore:qi,MessageRepository:is,ThreadRuntimeImpl:bs,fromThreadMessageLike:Wt,generateId:ut,getAutoStatus:Wi,splitLocalRuntimeOptions:hh,useSmooth:ea,useSmoothStatus:gh,useToolInvocations:zc,withSmoothContextProvider:mh},Symbol.toStringTag,{value:"Module"}));var xh=class extends qt{constructor(t){super();T(this,"useRuntimeHook");T(this,"instances",new Map);T(this,"useAliveThreadsKeysChanged",It(()=>({})));T(this,"_InnerActiveThreadProvider",({threadId:t})=>{const{useRuntime:r}=this.useRuntimeHook(),n=r(),i=n.thread.__internal_threadBinding,s=y.useCallback(()=>{const l=this.instances.get(t);if(!l)throw new Error("Thread not found. This is a bug in assistant-ui.");l.runtime=i.getState(),this._notifySubscribers()},[t,i]),a=y.useRef(!1);a.current||s(),y.useEffect(()=>(a.current=!0,s(),i.outerSubscribe(s)),[i,s]);const o=ue();return y.useEffect(()=>n.threads.main.unstable_on("initialize",()=>{if(o.threadListItem().getState().status==="new"){o.threadListItem().initialize();const u=n.thread.unstable_on("run-end",()=>{u(),o.threadListItem().generateTitle()})}}),[n,o]),null});T(this,"_OuterActiveThreadProvider",y.memo(({threadId:t,provider:r})=>p.jsx(jd,{id:t,children:p.jsx(r,{children:p.jsx(this._InnerActiveThreadProvider,{threadId:t})})})));T(this,"__internal_RenderThreadRuntimes",({provider:t})=>(this.useAliveThreadsKeysChanged(),Array.from(this.instances.keys()).map(r=>p.jsx(this._OuterActiveThreadProvider,{threadId:r,provider:t},r))));this.useRuntimeHook=It(()=>({useRuntime:t}))}startThreadRuntime(t){return this.instances.has(t)||(this.instances.set(t,{}),this.useAliveThreadsKeysChanged.setState({},!0)),new Promise((r,n)=>{const i=()=>{const a=this.instances.get(t);if(!a)s(),n(new Error("Thread was deleted before runtime was started"));else if(a.runtime)s(),r(a.runtime);else return},s=this.subscribe(i);i()})}getThreadRuntimeCore(t){const r=this.instances.get(t);if(r)return r.runtime}stopThreadRuntime(t){this.instances.delete(t),this.useAliveThreadsKeysChanged.setState({},!0)}setRuntimeHook(t){this.useRuntimeHook.getState().useRuntime!==t&&this.useRuntimeHook.setState({useRuntime:t},!0)}},ce=new Error("This is the empty thread, a placeholder for the main thread. You cannot perform any actions on this thread instance. This error is probably because you tried to call a thread method in your render function. Call the method inside a `useEffect` hook instead."),vh={getMessageById(){},getBranches(){return[]},switchToBranch(){throw ce},append(){throw ce},startRun(){throw ce},resumeRun(){throw ce},cancelRun(){throw ce},addToolResult(){throw ce},resumeToolCall(){throw ce},speak(){throw ce},stopSpeaking(){throw ce},submitFeedback(){throw ce},getModelContext(){return{}},unstable_loadExternalState(){throw ce},composer:{attachments:[],attachmentAccept:"*",addAttachment(){return P(this,null,function*(){throw ce})},removeAttachment(){return P(this,null,function*(){throw ce})},isEditing:!0,canCancel:!1,isEmpty:!0,text:"",setText(){throw ce},role:"user",setRole(){throw ce},runConfig:{},setRunConfig(){throw ce},reset(){return P(this,null,function*(){})},clearAttachments(){return P(this,null,function*(){})},send(){throw ce},cancel(){},subscribe(){return()=>{}},unstable_on(){return()=>{}}},getEditComposer(){},beginEdit(){throw ce},speech:void 0,capabilities:{switchToBranch:!1,switchBranchDuringRun:!1,edit:!1,reload:!1,cancel:!1,unstable_copy:!1,speech:!1,attachments:!1,feedback:!1},isDisabled:!1,isLoading:!1,messages:[],state:null,suggestions:[],extras:void 0,subscribe(){return()=>{}},import(){throw ce},export(){return{messages:[]}},reset(){throw ce},unstable_on(){return()=>{}}},ta=(e,t,r)=>r.reduce((n,i)=>{var s;return(s=i==null?void 0:i(n,t))!=null?s:n},e),Sh=class extends qt{constructor(t){super();T(this,"_pendingTransforms",[]);T(this,"_baseValue");T(this,"_cachedValue");this._baseValue=t,this._cachedValue=t}_updateState(){this._cachedValue=this._pendingTransforms.reduce((t,r)=>ta(t,r.task,[r.loading,r.optimistic]),this._baseValue),this._notifySubscribers()}get baseValue(){return this._baseValue}get value(){return this._cachedValue}update(t){this._baseValue=t,this._updateState()}optimisticUpdate(t){return P(this,null,function*(){const r=t.execute(),n=E(m({},t),{task:r});try{this._pendingTransforms.push(n),this._updateState();const i=yield r;return this._baseValue=ta(this._baseValue,i,[t.optimistic,t.then]),i}finally{const i=this._pendingTransforms.indexOf(n);i>-1&&this._pendingTransforms.splice(i,1),this._updateState()}})}};function Wx(e){return e}var zr=(e,t)=>{const r=e.threadIdMap[t];if(r!==void 0)return e.threadData[r]},Rr=(e,t,r)=>{const n=zr(e,t);if(!n)return e;const{id:i,remoteId:s,status:a}=n;if(a===r)return e;const o=m({},e);switch(a){case"new":o.newThreadId=void 0;break;case"regular":o.threadIds=o.threadIds.filter(l=>l!==i);break;case"archived":o.archivedThreadIds=o.archivedThreadIds.filter(l=>l!==i);break;default:{const l=a;throw new Error(`Unsupported state: ${l}`)}}switch(r){case"regular":o.threadIds=[i,...o.threadIds];break;case"archived":o.archivedThreadIds=[i,...o.archivedThreadIds];break;case"deleted":o.threadData=Object.fromEntries(Object.entries(o.threadData).filter(([l])=>l!==i)),o.threadIdMap=Object.fromEntries(Object.entries(o.threadIdMap).filter(([l])=>l!==i&&l!==s));break;default:{const l=r;throw new Error(`Unsupported state: ${l}`)}}return r!=="deleted"&&(o.threadData=E(m({},o.threadData),{[i]:E(m({},n),{status:r})})),o},kh=class extends qt{constructor(t,r){super();T(this,"_options");T(this,"_hookManager");T(this,"_loadThreadsPromise");T(this,"_mainThreadId");T(this,"_state",new Sh({isLoading:!1,newThreadId:void 0,threadIds:[],archivedThreadIds:[],threadIdMap:{},threadData:{}}));T(this,"useProvider");T(this,"initialize",t=>P(this,null,function*(){if(this._state.value.newThreadId!==t){const r=this.getItemById(t);if(!r)throw new Error("Thread not found");if(r.status==="new")throw new Error("Unexpected new state");return r.initializeTask}return this._state.optimisticUpdate({execute:()=>this._options.adapter.initialize(t),optimistic:r=>Rr(r,t,"regular"),loading:(r,n)=>{const i=t;return E(m({},r),{threadData:E(m({},r.threadData),{[i]:E(m({},r.threadData[i]),{initializeTask:n})})})},then:(r,{remoteId:n,externalId:i})=>{const s=zr(r,t);if(!s)return r;const a=t;return E(m({},r),{threadIdMap:E(m({},r.threadIdMap),{[n]:a}),threadData:E(m({},r.threadData),{[a]:E(m({},s),{initializeTask:Promise.resolve({remoteId:n,externalId:i}),remoteId:n,externalId:i})})})}})}));T(this,"generateTitle",t=>P(this,null,function*(){var l;const r=this.getItemById(t);if(!r)throw new Error("Thread not found");if(r.status==="new")throw new Error("Thread is not yet initialized");const{remoteId:n}=yield r.initializeTask,i=this._hookManager.getThreadRuntimeCore(r.id);if(!i)return;const s=i.messages,a=yield this._options.adapter.generateTitle(n,s),o=fc.fromAssistantStream(a);try{for(var u=xt(o),d,c,f;d=!(c=yield u.next()).done;d=!1){const h=c.value;const g=(l=h.parts.filter(w=>w.type==="text")[0])==null?void 0:l.text,S=this._state.baseValue;this._state.update(E(m({},S),{threadData:E(m({},S.threadData),{[r.id]:E(m({},r),{title:g})})}))}}catch(c){f=[c]}finally{try{d&&(c=u.return)&&(yield c.call(u))}finally{if(f)throw f[0]}}}));T(this,"useBoundIds",It(()=>[]));T(this,"__internal_RenderComponent",()=>{const t=y.useId();y.useEffect(()=>(this.useBoundIds.setState(s=>[...s,t],!0),()=>{this.useBoundIds.setState(s=>s.filter(a=>a!==t),!0)}),[t]);const r=this.useBoundIds(),{Provider:n}=this.useProvider(),i={modelContext:this.contextProvider};return(r.length===0||r[0]===t)&&p.jsx(wn,{adapters:i,children:p.jsx(this._hookManager.__internal_RenderThreadRuntimes,{provider:n})})});this.contextProvider=r,this._state.subscribe(()=>this._notifySubscribers()),this._hookManager=new xh(t.runtimeHook),this.useProvider=It(()=>{var n;return{Provider:(n=t.adapter.unstable_Provider)!=null?n:y.Fragment}}),this.__internal_setOptions(t),this.switchToNewThread()}get threadData(){return this._state.value.threadData}getLoadThreadsPromise(){return this._loadThreadsPromise||(this._loadThreadsPromise=this._state.optimisticUpdate({execute:()=>this._options.adapter.list(),loading:t=>E(m({},t),{isLoading:!0}),then:(t,r)=>{const n=[],i=[],s={},a={};for(const o of r.threads){switch(o.status){case"regular":n.push(o.remoteId);break;case"archived":i.push(o.remoteId);break;default:{const u=o.status;throw new Error(`Unsupported state: ${u}`)}}const l=o.remoteId;s[o.remoteId]=l,a[l]={id:o.remoteId,remoteId:o.remoteId,externalId:o.externalId,status:o.status,title:o.title,initializeTask:Promise.resolve({remoteId:o.remoteId,externalId:o.externalId})}}return E(m({},t),{threadIds:n,archivedThreadIds:i,threadIdMap:m(m({},t.threadIdMap),s),threadData:m(m({},t.threadData),a)})}}).then(()=>{})),this._loadThreadsPromise}__internal_setOptions(t){var n;if(this._options===t)return;this._options=t;const r=(n=t.adapter.unstable_Provider)!=null?n:y.Fragment;r!==this.useProvider.getState().Provider&&this.useProvider.setState({Provider:r},!0),this._hookManager.setRuntimeHook(t.runtimeHook)}__internal_load(){this.getLoadThreadsPromise()}get isLoading(){return this._state.value.isLoading}get threadIds(){return this._state.value.threadIds}get archivedThreadIds(){return this._state.value.archivedThreadIds}get newThreadId(){return this._state.value.newThreadId}get mainThreadId(){return this._mainThreadId}getMainThreadRuntimeCore(){const t=this._hookManager.getThreadRuntimeCore(this._mainThreadId);return t||vh}getThreadRuntimeCore(t){const r=this.getItemById(t);if(!r)throw new Error("Thread not found");const n=this._hookManager.getThreadRuntimeCore(r.id);if(!n)throw new Error("Thread not found");return n}getItemById(t){return zr(this._state.value,t)}switchToThread(t){return P(this,null,function*(){let r=this.getItemById(t);if(!r){const i=yield this._options.adapter.fetch(t),s=this._state.value,a=i.remoteId,o=E(m({},s.threadData),{[a]:{id:a,initializeTask:Promise.resolve({remoteId:i.remoteId,externalId:i.externalId}),remoteId:i.remoteId,externalId:i.externalId,status:i.status,title:i.title}}),l=E(m({},s.threadIdMap),{[i.remoteId]:a}),u=i.status==="regular"?[...s.threadIds,i.remoteId]:s.threadIds,d=i.status==="archived"?[...s.archivedThreadIds,i.remoteId]:s.archivedThreadIds;this._state.update(E(m({},s),{threadIds:u,archivedThreadIds:d,threadIdMap:l,threadData:o})),r=this.getItemById(t)}if(!r)throw new Error("Thread not found");if(this._mainThreadId===r.id)return;const n=this._hookManager.startThreadRuntime(r.id);this.mainThreadId!==void 0?yield n:n.then(()=>this._notifySubscribers()),r.status==="archived"&&(yield this.unarchive(r.id)),this._mainThreadId=r.id,this._notifySubscribers()})}switchToNewThread(){return P(this,null,function*(){for(;this._state.baseValue.newThreadId!==void 0&&this._state.value.newThreadId===void 0;)yield this._state.waitForUpdate();const t=this._state.value;let r=this._state.value.newThreadId;if(r===void 0){do r=`__LOCALID_${ut()}`;while(t.threadIdMap[r]);const n=r;this._state.update(E(m({},t),{newThreadId:r,threadIdMap:E(m({},t.threadIdMap),{[r]:n}),threadData:E(m({},t.threadData),{[n]:{status:"new",id:r,remoteId:void 0,externalId:void 0,title:void 0}})}))}return this.switchToThread(r)})}rename(t,r){const n=this.getItemById(t);if(!n)throw new Error("Thread not found");if(n.status==="new")throw new Error("Thread is not yet initialized");return this._state.optimisticUpdate({execute:()=>P(this,null,function*(){const{remoteId:i}=yield n.initializeTask;return this._options.adapter.rename(i,r)}),optimistic:i=>{const s=zr(i,t);return s?E(m({},i),{threadData:E(m({},i.threadData),{[s.id]:E(m({},s),{title:r})})}):i}})}_ensureThreadIsNotMain(t){return P(this,null,function*(){if(t===this.newThreadId)throw new Error("Cannot ensure new thread is not main");t===this._mainThreadId&&(yield this.switchToNewThread())})}archive(t){return P(this,null,function*(){const r=this.getItemById(t);if(!r)throw new Error("Thread not found");if(r.status!=="regular")throw new Error("Thread is not yet initialized or already archived");return this._state.optimisticUpdate({execute:()=>P(this,null,function*(){yield this._ensureThreadIsNotMain(r.id);const{remoteId:n}=yield r.initializeTask;return this._options.adapter.archive(n)}),optimistic:n=>Rr(n,r.id,"archived")})})}unarchive(t){const r=this.getItemById(t);if(!r)throw new Error("Thread not found");if(r.status!=="archived")throw new Error("Thread is not archived");return this._state.optimisticUpdate({execute:()=>P(this,null,function*(){try{const{remoteId:n}=yield r.initializeTask;return yield this._options.adapter.unarchive(n)}catch(n){throw yield this._ensureThreadIsNotMain(r.id),n}}),optimistic:n=>Rr(n,r.id,"regular")})}delete(t){return P(this,null,function*(){const r=this.getItemById(t);if(!r)throw new Error("Thread not found");if(r.status!=="regular"&&r.status!=="archived")throw new Error("Thread is not yet initialized");return this._state.optimisticUpdate({execute:()=>P(this,null,function*(){yield this._ensureThreadIsNotMain(r.id);const{remoteId:n}=yield r.initializeTask;return yield this._options.adapter.delete(n)}),optimistic:n=>Rr(n,r.id,"deleted")})})}detach(t){return P(this,null,function*(){const r=this.getItemById(t);if(!r)throw new Error("Thread not found");if(r.status!=="regular"&&r.status!=="archived")throw new Error("Thread is not yet initialized");yield this._ensureThreadIsNotMain(r.id),this._hookManager.stopThreadRuntime(r.id)})}},_h=class extends dn{constructor(t){super();T(this,"threads");this.threads=new kh(t,this._contextProvider)}get RenderComponent(){return this.threads.__internal_RenderComponent}},Th=e=>{const[t]=y.useState(()=>new _h(e));return y.useEffect(()=>{t.threads.__internal_setOptions(e),t.threads.__internal_load()},[t,e]),y.useMemo(()=>new Dn(t),[t])},ra=e=>{if(Or().threadListItem.source!==null){if(!e.allowNesting)throw new Error("useRemoteThreadListRuntime cannot be nested inside another RemoteThreadListRuntime. Set allowNesting: true to allow nesting (the inner runtime will become a no-op).");return e.runtimeHook()}return Th(e)},Ch=Symbol.for("react.lazy"),jr=J[" use ".trim().toString()];function Ih(e){return typeof e=="object"&&e!==null&&"then"in e}function na(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===Ch&&"_payload"in e&&Ih(e._payload)}function ia(e){const t=Eh(e),r=J.forwardRef((n,i)=>{let u=n,{children:s}=u,a=H(u,["children"]);na(s)&&typeof jr=="function"&&(s=jr(s._payload));const o=J.Children.toArray(s),l=o.find(Ph);if(l){const d=l.props.children,c=o.map(f=>f===l?J.Children.count(d)>1?J.Children.only(null):J.isValidElement(d)?d.props.children:null:f);return p.jsx(t,E(m({},a),{ref:i,children:J.isValidElement(d)?J.cloneElement(d,void 0,c):null}))}return p.jsx(t,E(m({},a),{ref:i,children:s}))});return r.displayName=`${e}.Slot`,r}var sa=ia("Slot");function Eh(e){const t=J.forwardRef((r,n)=>{let a=r,{children:i}=a,s=H(a,["children"]);if(na(i)&&typeof jr=="function"&&(i=jr(i._payload)),J.isValidElement(i)){const o=Lh(i),l=Mh(s,i.props);return i.type!==J.Fragment&&(l.ref=n?As(n,o):o),J.cloneElement(i,l)}return J.Children.count(i)>1?J.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Ah=Symbol("radix.slottable");function Ph(e){return J.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Ah}function Mh(e,t){const r=m({},t);for(const n in t){const i=e[n],s=t[n];/^on[A-Z]/.test(n)?i&&s?r[n]=(...o)=>{const l=s(...o);return i(...o),l}:i&&(r[n]=i):n==="style"?r[n]=m(m({},i),s):n==="className"&&(r[n]=[i,s].filter(Boolean).join(" "))}return m(m({},e),r)}function Lh(e){var n,i;let t=(n=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:n.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var Nh=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ze=Nh.reduce((e,t)=>{const r=ia(`Primitive.${t}`),n=J.forwardRef((i,s)=>{const u=i,{asChild:a}=u,o=H(u,["asChild"]),l=a?r:t;return typeof window!="undefined"&&(window[Symbol.for("radix-ui")]=!0),p.jsx(l,E(m({},o),{ref:s}))});return n.displayName=`Primitive.${t}`,E(m({},e),{[t]:n})},{});function Pt(e,t,{checkForDefaultPrevented:r=!0}={}){return function(i){if(e==null||e(i),r===!1||!i.defaultPrevented)return t==null?void 0:t(i)}}var Fn=(e,t,r=[])=>{const n=y.forwardRef((i,s)=>{var u;const a={},o={};Object.keys(i).forEach(d=>{r.includes(d)?a[d]=i[d]:o[d]=i[d]});const l=(u=t(a))!=null?u:void 0;return p.jsx(Ze.button,E(m({type:"button"},o),{ref:s,disabled:o.disabled||!l,onClick:Pt(o.onClick,l)}))});return n.displayName=e,n};function Dh(e,t=globalThis==null?void 0:globalThis.document){const r=ft(e);J.useEffect(()=>{const n=i=>{i.key==="Escape"&&r(i)};return t.addEventListener("keydown",n,{capture:!0}),()=>t.removeEventListener("keydown",n,{capture:!0})},[r,t])}var er=e=>{const t=y.useRef(void 0);return y.useCallback(n=>{t.current&&t.current(),n&&(t.current=e(n))},[e])},aa=(e,t)=>{const r=y.useCallback(n=>{if(!e)return;const i=e(),s=()=>{const o=t?t(n):n.offsetHeight;i.setHeight(o)},a=new ResizeObserver(s);return a.observe(n),s(),()=>{a.disconnect(),i.unregister()}},[e,t]);return er(r)},oa=y.createContext(!1),la=(e,t)=>{const r=e.match(/^([\d.]+)(em|px|rem)$/);if(!r)return 0;const n=parseFloat(r[1]),i=r[2];if(i==="px")return n;if(i==="em"){const s=parseFloat(getComputedStyle(t).fontSize)||16;return n*s}if(i==="rem"){const s=parseFloat(getComputedStyle(document.documentElement).fontSize)||16;return n*s}return 0},ua=({children:e,fillClampThreshold:t="10em",fillClampOffset:r="6em"})=>{const n=ie(({message:l})=>l.isLast&&l.index>=2),i=In({optional:!0}),s=y.useContext(oa),a=y.useCallback(l=>{if(!i||s)return;const u=()=>{const d=i.getState();if(d.turnAnchor==="top"&&n){const{viewport:c,inset:f,userMessage:h}=d.height,g=la(t,l),S=la(r,l),w=h<=g?h:S,b=Math.max(0,c-f-w);l.style.minHeight=`${b}px`,l.style.flexShrink="0",l.style.transition="min-height 0s"}else l.style.minHeight="",l.style.flexShrink="",l.style.transition=""};return u(),i.subscribe(u)},[i,n,s,t,r]),o=er(a);return p.jsx(oa.Provider,{value:!0,children:p.jsx(sa,{ref:o,children:e})})};ua.displayName="ThreadPrimitive.ViewportSlack";var Oh=()=>{const e=ue(),t=ie(()=>e.message()),r=y.useCallback(n=>{const i=()=>{t.setIsHovering(!0)},s=()=>{t.setIsHovering(!1)};return n.addEventListener("mouseenter",i),n.addEventListener("mouseleave",s),n.matches(":hover")&&t.setIsHovering(!0),()=>{n.removeEventListener("mouseenter",i),n.removeEventListener("mouseleave",s),t.setIsHovering(!1)}},[t]);return er(r)},Fh=()=>{const e=Fr(i=>i.turnAnchor),t=Fr(i=>i.registerUserMessageHeight),r=ie(({thread:i,message:s})=>{var a;return e==="top"&&s.role==="user"&&s.index===i.messages.length-2&&((a=i.messages.at(-1))==null?void 0:a.role)==="assistant"}),n=y.useCallback(i=>i.offsetHeight,[]);return aa(r?t:null,n)},Bn=y.forwardRef((e,t)=>{const r=Oh(),n=Fh(),i=Dr(t,r,n);return p.jsx(ua,{children:p.jsx(Ze.div,E(m({},e),{ref:i}))})});Bn.displayName="MessagePrimitive.Root";var ca=()=>ie(({part:t})=>{if(t.type!=="text"&&t.type!=="reasoning")throw new Error("MessagePartText can only be used inside text or reasoning message parts.");return t}),da=y.forwardRef((i,n)=>{var s=i,{smooth:e=!0,component:t="span"}=s,r=H(s,["smooth","component"]);const{text:a,status:o}=ea(ca(),e);return p.jsx(t,E(m({"data-status":o.type},r),{ref:n,children:a}))});da.displayName="MessagePartPrimitive.Text";var Bh=()=>ie(({part:t})=>{if(t.type!=="image")throw new Error("MessagePartImage can only be used inside image message parts.");return t}),ha=y.forwardRef((e,t)=>{const{image:r}=Bh();return p.jsx(Ze.img,E(m({src:r},e),{ref:t}))});ha.displayName="MessagePartPrimitive.Image";var fa=({children:e})=>ie(({part:r})=>r.status.type==="running")?e:null;fa.displayName="MessagePartPrimitive.InProgress";const pa=e=>Symbol.iterator in e,ma=e=>"entries"in e,ga=(e,t)=>{const r=e instanceof Map?e:new Map(e.entries()),n=t instanceof Map?t:new Map(t.entries());if(r.size!==n.size)return!1;for(const[i,s]of r)if(!n.has(i)||!Object.is(s,n.get(i)))return!1;return!0},zh=(e,t)=>{const r=e[Symbol.iterator](),n=t[Symbol.iterator]();let i=r.next(),s=n.next();for(;!i.done&&!s.done;){if(!Object.is(i.value,s.value))return!1;i=r.next(),s=n.next()}return!!i.done&&!!s.done};function Rh(e,t){return Object.is(e,t)?!0:typeof e!="object"||e===null||typeof t!="object"||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:pa(e)&&pa(t)?ma(e)&&ma(t)?ga(e,t):zh(e,t):ga({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function jh(e){const t=y.useRef(void 0);return r=>{const n=e(r);return Rh(t.current,n)?t.current:t.current=n}}var ya=e=>{let t=-1;return{startGroup:r=>{t===-1&&(t=r)},endGroup:(r,n)=>{t!==-1&&(n.push({type:e,startIndex:t,endIndex:r}),t=-1)},finalize:(r,n)=>{t!==-1&&n.push({type:e,startIndex:t,endIndex:r})}}},Uh=e=>{const t=[],r=ya("toolGroup"),n=ya("reasoningGroup");for(let i=0;i<e.length;i++){const s=e[i];s==="tool-call"?(n.endGroup(i-1,t),r.startGroup(i)):s==="reasoning"?(r.endGroup(i-1,t),n.startGroup(i)):(r.endGroup(i-1,t),n.endGroup(i-1,t),t.push({type:"single",index:i}))}return r.finalize(e.length-1,t),n.finalize(e.length-1,t),t},$h=()=>{const e=ie(jh(t=>t.message.parts.map(r=>r.type)));return y.useMemo(()=>e.length===0?[]:Uh(e),[e])},Hh=r=>{var n=r,{Fallback:e}=n,t=H(n,["Fallback"]);const i=ie(({tools:s})=>{var o,l;const a=(o=s.tools[t.toolName])!=null?o:e;return Array.isArray(a)?(l=a[0])!=null?l:e:a});return i?p.jsx(i,m({},t)):null},et={Text:()=>p.jsxs("p",{style:{whiteSpace:"pre-line"},children:[p.jsx(da,{}),p.jsx(fa,{children:p.jsx("span",{style:{fontFamily:"revert"},children:" ●"})})]}),Reasoning:()=>null,Source:()=>null,Image:()=>p.jsx(ha,{}),File:()=>null,Unstable_Audio:()=>null,ToolGroup:({children:e})=>e,ReasoningGroup:({children:e})=>e},qh=({components:{Text:e=et.Text,Reasoning:t=et.Reasoning,Image:r=et.Image,Source:n=et.Source,File:i=et.File,Unstable_Audio:s=et.Unstable_Audio,tools:a={}}={}})=>{var d,c,f;const o=ue(),l=ie(({part:h})=>h),u=l.type;if(u==="tool-call"){const h=o.part().addToolResult,g=o.part().resumeToolCall;if("Override"in a)return p.jsx(a.Override,E(m({},l),{addResult:h,resume:g}));const S=(c=(d=a.by_name)==null?void 0:d[l.toolName])!=null?c:a.Fallback;return p.jsx(Hh,E(m({},l),{Fallback:S,addResult:h,resume:g}))}if(((f=l.status)==null?void 0:f.type)==="requires-action")throw new Error("Encountered unexpected requires-action status");switch(u){case"text":return p.jsx(e,m({},l));case"reasoning":return p.jsx(t,m({},l));case"source":return p.jsx(n,m({},l));case"image":return p.jsx(r,m({},l));case"file":return p.jsx(i,m({},l));case"audio":return p.jsx(s,m({},l));case"data":return null;default:const h=u;throw new Error(`Unknown message part type: ${h}`)}},Ur=y.memo(({index:e,components:t})=>p.jsx($d,{index:e,children:p.jsx(qh,{components:t})}),(e,t)=>{var r,n,i,s,a,o,l,u,d,c,f,h,g,S,w,b,C,_;return e.index===t.index&&((r=e.components)==null?void 0:r.Text)===((n=t.components)==null?void 0:n.Text)&&((i=e.components)==null?void 0:i.Reasoning)===((s=t.components)==null?void 0:s.Reasoning)&&((a=e.components)==null?void 0:a.Source)===((o=t.components)==null?void 0:o.Source)&&((l=e.components)==null?void 0:l.Image)===((u=t.components)==null?void 0:u.Image)&&((d=e.components)==null?void 0:d.File)===((c=t.components)==null?void 0:c.File)&&((f=e.components)==null?void 0:f.Unstable_Audio)===((h=t.components)==null?void 0:h.Unstable_Audio)&&((g=e.components)==null?void 0:g.tools)===((S=t.components)==null?void 0:S.tools)&&((w=e.components)==null?void 0:w.ToolGroup)===((b=t.components)==null?void 0:b.ToolGroup)&&((C=e.components)==null?void 0:C.ReasoningGroup)===((_=t.components)==null?void 0:_.ReasoningGroup)});Ur.displayName="MessagePrimitive.PartByIndex";var Vh=({status:e,component:t})=>p.jsx(qd,{text:"",isRunning:e.type==="running",children:p.jsx(t,{type:"text",text:"",status:e})}),Wh=Object.freeze({type:"complete"}),Jh=({components:e})=>{var r;const t=ie(n=>{var i;return(i=n.message.status)!=null?i:Wh});return e!=null&&e.Empty?p.jsx(e.Empty,{status:t}):p.jsx(Vh,{status:t,component:(r=e==null?void 0:e.Text)!=null?r:et.Text})},Gh=y.memo(Jh,(e,t)=>{var r,n,i,s;return((r=e.components)==null?void 0:r.Empty)===((n=t.components)==null?void 0:n.Empty)&&((i=e.components)==null?void 0:i.Text)===((s=t.components)==null?void 0:s.Text)}),zn=({components:e})=>{const t=ie(({message:i})=>i.parts.length),r=$h(),n=y.useMemo(()=>t===0?p.jsx(Gh,{components:e}):r.map(i=>{var s,a;if(i.type==="single")return p.jsx(Ur,{index:i.index,components:e},i.index);if(i.type==="toolGroup"){const o=(s=e==null?void 0:e.ToolGroup)!=null?s:et.ToolGroup;return p.jsx(o,{startIndex:i.startIndex,endIndex:i.endIndex,children:Array.from({length:i.endIndex-i.startIndex+1},(l,u)=>p.jsx(Ur,{index:i.startIndex+u,components:e},u))},`tool-${i.startIndex}`)}else{const o=(a=e==null?void 0:e.ReasoningGroup)!=null?a:et.ReasoningGroup;return p.jsx(o,{startIndex:i.startIndex,endIndex:i.endIndex,children:Array.from({length:i.endIndex-i.startIndex+1},(l,u)=>p.jsx(Ur,{index:i.startIndex+u,components:e},u))},`reasoning-${i.startIndex}`)}}),[r,e,t]);return p.jsx(p.Fragment,{children:n})};zn.displayName="MessagePrimitive.Parts";var ba=()=>{const e=ue(),t=ie(n=>n.thread.isRunning||!n.composer.isEditing||n.composer.isEmpty),r=y.useCallback(()=>{e.composer().send()},[e]);return t?null:r},Yh=Fn("ComposerPrimitive.Send",ba),wa=y.forwardRef((n,r)=>{var i=n,{onSubmit:e}=i,t=H(i,["onSubmit"]);const s=ba(),a=o=>{o.preventDefault(),s&&s()};return p.jsx(Ze.form,E(m({},t),{ref:r,onSubmit:Pt(e,a)}))});wa.displayName="ComposerPrimitive.Root";function Rn(){return Rn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Rn.apply(null,arguments)}function Kh(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}var Xh=y.useLayoutEffect,Qh=function(t){var r=y.useRef(t);return Xh(function(){r.current=t}),r},xa=function(t,r){if(typeof t=="function"){t(r);return}t.current=r},Zh=function(t,r){var n=y.useRef();return y.useCallback(function(i){t.current=i,n.current&&xa(n.current,null),n.current=r,r&&xa(r,i)},[r])},va={"min-height":"0","max-height":"none",height:"0",visibility:"hidden",overflow:"hidden",position:"absolute","z-index":"-1000",top:"0",right:"0",display:"block"},ef=function(t){Object.keys(va).forEach(function(r){t.style.setProperty(r,va[r],"important")})},Sa=ef,_e=null,ka=function(t,r){var n=t.scrollHeight;return r.sizingStyle.boxSizing==="border-box"?n+r.borderSize:n-r.paddingSize};function tf(e,t,r,n){r===void 0&&(r=1),n===void 0&&(n=1/0),_e||(_e=document.createElement("textarea"),_e.setAttribute("tabindex","-1"),_e.setAttribute("aria-hidden","true"),Sa(_e)),_e.parentNode===null&&document.body.appendChild(_e);var i=e.paddingSize,s=e.borderSize,a=e.sizingStyle,o=a.boxSizing;Object.keys(a).forEach(function(f){var h=f;_e.style[h]=a[h]}),Sa(_e),_e.value=t;var l=ka(_e,e);_e.value=t,l=ka(_e,e),_e.value="x";var u=_e.scrollHeight-i,d=u*r;o==="border-box"&&(d=d+i+s),l=Math.max(d,l);var c=u*n;return o==="border-box"&&(c=c+i+s),l=Math.min(c,l),[l,u]}var _a=function(){},rf=function(t,r){return t.reduce(function(n,i){return n[i]=r[i],n},{})},nf=["borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","boxSizing","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textRendering","textTransform","width","wordBreak","wordSpacing","scrollbarGutter"],sf=!!document.documentElement.currentStyle,af=function(t){var r=window.getComputedStyle(t);if(r===null)return null;var n=rf(nf,r),i=n.boxSizing;if(i==="")return null;sf&&i==="border-box"&&(n.width=parseFloat(n.width)+parseFloat(n.borderRightWidth)+parseFloat(n.borderLeftWidth)+parseFloat(n.paddingRight)+parseFloat(n.paddingLeft)+"px");var s=parseFloat(n.paddingBottom)+parseFloat(n.paddingTop),a=parseFloat(n.borderBottomWidth)+parseFloat(n.borderTopWidth);return{sizingStyle:n,paddingSize:s,borderSize:a}},of=af;function jn(e,t,r){var n=Qh(r);J.useLayoutEffect(function(){var i=function(a){return n.current(a)};if(e)return e.addEventListener(t,i),function(){return e.removeEventListener(t,i)}},[])}var lf=function(t,r){jn(document.body,"reset",function(n){t.current.form===n.target&&r(n)})},uf=function(t){jn(window,"resize",t)},cf=function(t){jn(document.fonts,"loadingdone",t)},df=["cacheMeasurements","maxRows","minRows","onChange","onHeightChange"],hf=function(t,r){var n=t.cacheMeasurements,i=t.maxRows,s=t.minRows,a=t.onChange,o=a===void 0?_a:a,l=t.onHeightChange,u=l===void 0?_a:l,d=Kh(t,df),c=d.value!==void 0,f=J.useRef(null),h=Zh(f,r),g=J.useRef(0),S=J.useRef(),w=function(){var _=f.current,F=n&&S.current?S.current:of(_);if(F){S.current=F;var B=tf(F,_.value||_.placeholder||"x",s,i),I=B[0],z=B[1];g.current!==I&&(g.current=I,_.style.setProperty("height",I+"px","important"),u(I,{rowHeight:z}))}},b=function(_){c||w(),o(_)};return J.useLayoutEffect(w),lf(f,function(){if(!c){var C=f.current.value;requestAnimationFrame(function(){var _=f.current;_&&C!==_.value&&w()})}}),uf(w),cf(w),J.createElement("textarea",Rn({},d,{onChange:b,ref:h}))},ff=J.forwardRef(hf),Ta=e=>{const t=ft(e),r=Fr(n=>n.onScrollToBottom);y.useEffect(()=>r(t),[r,t])},Ca=y.forwardRef((g,h)=>{var S=g,{autoFocus:e=!1,asChild:t,disabled:r,onChange:n,onKeyDown:i,onPaste:s,submitOnEnter:a=!0,cancelOnEscape:o=!0,unstable_focusOnRunStart:l=!0,unstable_focusOnScrollToBottom:u=!0,unstable_focusOnThreadSwitched:d=!0,addAttachmentOnPaste:c=!0}=S,f=H(S,["autoFocus","asChild","disabled","onChange","onKeyDown","onPaste","submitOnEnter","cancelOnEscape","unstable_focusOnRunStart","unstable_focusOnScrollToBottom","unstable_focusOnThreadSwitched","addAttachmentOnPaste"]);const w=ue(),b=ie(({composer:k})=>k.isEditing?k.text:""),C=t?sa:ff,_=ie(({thread:k})=>k.isDisabled)||r,F=y.useRef(null),B=Dr(h,F);Dh(k=>{var M;if(!o||!((M=F.current)!=null&&M.contains(k.target)))return;const N=w.composer();N.getState().canCancel&&(N.cancel(),k.preventDefault())});const I=k=>{var N,M;_||!a||k.nativeEvent.isComposing||k.key==="Enter"&&k.shiftKey===!1&&(w.thread().getState().isRunning||(k.preventDefault(),(M=(N=F.current)==null?void 0:N.closest("form"))==null||M.requestSubmit()))},z=k=>P(null,null,function*(){var V;if(!c)return;const N=w.thread().getState().capabilities,M=Array.from(((V=k.clipboardData)==null?void 0:V.files)||[]);if(N.attachments&&M.length>0)try{k.preventDefault(),yield Promise.all(M.map(R=>w.composer().addAttachment(R)))}catch(R){console.error("Error adding attachment:",R)}}),j=e&&!_,$=y.useCallback(()=>{const k=F.current;!k||!j||(k.focus({preventScroll:!0}),k.setSelectionRange(k.value.length,k.value.length))},[j]);return y.useEffect(()=>$(),[$]),Ta(()=>{w.composer().getState().type==="thread"&&u&&$()}),y.useEffect(()=>{if(!(w.composer().getState().type!=="thread"||!l))return w.on("thread.run-start",$)},[l,$,w]),y.useEffect(()=>{if(!(w.composer().getState().type!=="thread"||!d))return w.on("thread-list-item.switched-to",$)},[d,$,w]),p.jsx(C,E(m({name:"input",value:b},f),{ref:B,disabled:_,onChange:Pt(n,k=>{w.composer().getState().isEditing&&(w.composer().setText(k.target.value),w.flushSync())}),onKeyDown:Pt(i,I),onPaste:Pt(s,z)}))});Ca.displayName="ComposerPrimitive.Input";var Ia=y.forwardRef((e,t)=>p.jsx(Ze.div,E(m({},e),{ref:t})));Ia.displayName="ThreadPrimitive.Root";var Ea=({children:e})=>ie(({thread:r})=>r.messages.length===0&&!r.isLoading)?e:null;Ea.displayName="ThreadPrimitive.Empty";var pf=e=>ie(({thread:t})=>!(e.empty===!0&&!t.isEmpty||e.empty===!1&&t.isEmpty||e.running===!0&&!t.isRunning||e.running===!1&&t.isRunning||e.disabled===!0&&!t.isDisabled||e.disabled===!1&&t.isDisabled)),Aa=r=>{var n=r,{children:e}=n,t=H(n,["children"]);return pf(t)?e:null};Aa.displayName="ThreadPrimitive.If";var mf=e=>{const t=ft(e),r=y.useCallback(n=>{const i=new ResizeObserver(()=>{t()}),s=new MutationObserver(()=>{t()});return i.observe(n),s.observe(n,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),()=>{i.disconnect(),s.disconnect()}},[t]);return er(r)},gf=({autoScroll:e,scrollToBottomOnRunStart:t=!0,scrollToBottomOnInitialize:r=!0,scrollToBottomOnThreadSwitch:n=!0})=>{const i=y.useRef(null),s=In();e===void 0&&(e=s.getState().turnAnchor!=="top");const a=y.useRef(0),o=y.useRef(null),l=y.useCallback(h=>{const g=i.current;g&&(o.current=h,g.scrollTo({top:g.scrollHeight,behavior:h}))},[]),u=()=>{const h=i.current;if(!h)return;const g=s.getState().isAtBottom,S=Math.abs(h.scrollHeight-h.scrollTop-h.clientHeight)<1||h.scrollHeight<=h.clientHeight;!S&&a.current<h.scrollTop||(S&&(o.current=null),(S||o.current===null)&&S!==g&&Zt(s).setState({isAtBottom:S})),a.current=h.scrollTop},d=mf(()=>{const h=o.current;h?l(h):e&&s.getState().isAtBottom&&l("instant"),u()}),c=er(h=>(h.addEventListener("scroll",u),()=>{h.removeEventListener("scroll",u)}));return Ta(({behavior:h})=>{l(h)}),Cn("thread.run-start",()=>{t&&(o.current="auto",requestAnimationFrame(()=>{l("auto")}))}),Cn("thread.initialize",()=>{r&&(o.current="instant",requestAnimationFrame(()=>{l("instant")}))}),Cn("thread-list-item.switched-to",()=>{n&&(o.current="instant",requestAnimationFrame(()=>{l("instant")}))}),Dr(d,c,i)},yf=()=>{const e=Fr(r=>r.registerViewport),t=y.useCallback(r=>r.clientHeight,[]);return aa(e,t)},Pa=y.forwardRef((o,a)=>{var l=o,{autoScroll:e,scrollToBottomOnRunStart:t,scrollToBottomOnInitialize:r,scrollToBottomOnThreadSwitch:n,children:i}=l,s=H(l,["autoScroll","scrollToBottomOnRunStart","scrollToBottomOnInitialize","scrollToBottomOnThreadSwitch","children"]);const u=gf({autoScroll:e,scrollToBottomOnRunStart:t,scrollToBottomOnInitialize:r,scrollToBottomOnThreadSwitch:n}),d=yf(),c=Dr(a,u,d);return p.jsx(Ze.div,E(m({},s),{ref:c,children:i}))});Pa.displayName="ThreadPrimitive.ViewportScrollable";var Ma=y.forwardRef((n,r)=>{var i=n,{turnAnchor:e}=i,t=H(i,["turnAnchor"]);return p.jsx(qs,{options:{turnAnchor:e},children:p.jsx(Pa,E(m({},t),{ref:r}))})});Ma.displayName="ThreadPrimitive.Viewport";var La=(e,t)=>e.Message===t.Message&&e.EditComposer===t.EditComposer&&e.UserEditComposer===t.UserEditComposer&&e.AssistantEditComposer===t.AssistantEditComposer&&e.SystemEditComposer===t.SystemEditComposer&&e.UserMessage===t.UserMessage&&e.AssistantMessage===t.AssistantMessage&&e.SystemMessage===t.SystemMessage,bf=()=>null,wf=(e,t,r)=>{var n,i,s,a,o,l,u,d,c,f,h,g;switch(t){case"user":return r?(s=(i=(n=e.UserEditComposer)!=null?n:e.EditComposer)!=null?i:e.UserMessage)!=null?s:e.Message:(a=e.UserMessage)!=null?a:e.Message;case"assistant":return r?(u=(l=(o=e.AssistantEditComposer)!=null?o:e.EditComposer)!=null?l:e.AssistantMessage)!=null?u:e.Message:(d=e.AssistantMessage)!=null?d:e.Message;case"system":return r?(h=(f=(c=e.SystemEditComposer)!=null?c:e.EditComposer)!=null?f:e.SystemMessage)!=null?h:e.Message:(g=e.SystemMessage)!=null?g:bf;default:const S=t;throw new Error(`Unknown message role: ${S}`)}},xf=({components:e})=>{const t=ie(({message:i})=>i.role),r=ie(({message:i})=>i.composer.isEditing),n=wf(e,t,r);return p.jsx(n,{})},Na=y.memo(({index:e,components:t})=>p.jsx(Ud,{index:e,children:p.jsx(xf,{components:t})}),(e,t)=>e.index===t.index&&La(e.components,t.components));Na.displayName="ThreadPrimitive.MessageByIndex";var Da=({components:e})=>{const t=ie(({thread:n})=>n.messages.length);return y.useMemo(()=>t===0?null:Array.from({length:t},(n,i)=>p.jsx(Na,{index:i,components:e},i)),[t,e])};Da.displayName="ThreadPrimitive.Messages";var vf=y.memo(Da,(e,t)=>La(e.components,t.components)),Oa=y.forwardRef((i,n)=>{var s=i,{onClick:e,disabled:t}=s,r=H(s,["onClick","disabled"]);const a=ie(({threads:l})=>l.newThreadId===l.mainThreadId),o=ue();return p.jsx(Ze.button,E(m(m({type:"button"},a?{"data-active":"true","aria-current":"true"}:null),r),{ref:n,disabled:t,onClick:Pt(e,()=>{o.threads().switchToNewThread()})}))});Oa.displayName="ThreadListPrimitive.New";var Fa=y.memo(({index:e,archived:t=!1,components:r})=>{const n=r.ThreadListItem;return p.jsx(Rd,{index:e,archived:t,children:p.jsx(n,{})})},(e,t)=>e.index===t.index&&e.archived===t.archived&&e.components.ThreadListItem===t.components.ThreadListItem);Fa.displayName="ThreadListPrimitive.ItemByIndex";var Ba=({archived:e=!1,components:t})=>{const r=ie(({threads:i})=>e?i.archivedThreadIds.length:i.threadIds.length);return y.useMemo(()=>Array.from({length:r},(i,s)=>p.jsx(Fa,{index:s,archived:e,components:t},s)),[r,e,t])};Ba.displayName="ThreadListPrimitive.Items";var za=y.forwardRef((e,t)=>p.jsx(Ze.div,E(m({},e),{ref:t})));za.displayName="ThreadListPrimitive.Root";var Ra=y.forwardRef((e,t)=>{const r=ie(({threads:n,threadListItem:i})=>n.mainThreadId===i.id);return p.jsx(Ze.div,E(m(m({},r?{"data-active":"true","aria-current":"true"}:null),e),{ref:t}))});Ra.displayName="ThreadListItemPrimitive.Root";var Sf=()=>{const e=ue();return y.useCallback(()=>{e.threadListItem().delete()},[e])},kf=Fn("ThreadListItemPrimitive.Delete",Sf),_f=()=>{const e=ue();return y.useCallback(()=>{e.threadListItem().switchTo()},[e])},Tf=Fn("ThreadListItemPrimitive.Trigger",_f);class ja{constructor(t,r,n=!1){T(this,"baseUrl");T(this,"sessionToken",null);T(this,"isProxyMode",!1);this.baseUrl=t.replace(/\/$/,""),this.isProxyMode=n,r&&(this.sessionToken=r)}setSessionToken(t){this.sessionToken=t}getUrl(t){if(this.isProxyMode){const r=`${this.baseUrl}${t.replace("/v1","")}`;return r.startsWith("/")||r.startsWith("./"),r}return`${this.baseUrl}${t}`}createOrContinueChat(t,r){return P(this,null,function*(){const n=this.getUrl("/v1/chats"),s={"Content-Type":"application/json","Idempotency-Key":this.generateIdempotencyKey()};this.sessionToken&&(s.Authorization=`Bearer ${this.sessionToken}`);const a=E(m({},t),{stream:!0}),o=yield fetch(n,{method:"POST",headers:s,body:JSON.stringify(a),signal:r});if(!o.ok){const l=yield o.json().catch(()=>({}));throw new Error(l.detail||l.message||`API error: ${o.status} ${o.statusText}`)}if(!o.body)throw new Error("Response body is null");return o.body})}getChat(t){return P(this,null,function*(){const r=this.getUrl(`/v1/chats/${t}`),n={"Content-Type":"application/json"};this.sessionToken&&(n.Authorization=`Bearer ${this.sessionToken}`);const i=yield fetch(r,{method:"GET",headers:n});if(!i.ok){const s=yield i.json().catch(()=>({}));throw new Error(s.detail||s.message||`API error: ${i.status} ${i.statusText}`)}return i.json()})}listChats(t){return P(this,null,function*(){const r=this.getUrl("/v1/chats"),n=r.startsWith("/")||r.startsWith("./")?new URL(r,window.location.origin):new URL(r);t!=null&&t.limit&&n.searchParams.set("limit",t.limit.toString()),t!=null&&t.cursor&&n.searchParams.set("cursor",t.cursor),t!=null&&t["expand[]"]&&t["expand[]"].forEach(a=>{n.searchParams.append("expand[]",a)});const i={"Content-Type":"application/json"};this.sessionToken&&(i.Authorization=`Bearer ${this.sessionToken}`);const s=yield fetch(n.toString(),{method:"GET",headers:i});if(!s.ok){const a=yield s.json().catch(()=>({}));throw new Error(a.detail||a.message||`API error: ${s.status} ${s.statusText}`)}return s.json()})}generateIdempotencyKey(){try{if(typeof crypto!="undefined"&&crypto.randomUUID)return crypto.randomUUID()}catch(n){}const t=n=>Array.from({length:n},()=>Math.floor(Math.random()*16).toString(16)).join(""),r=()=>{const n=["8","9","a","b"];return n[Math.floor(Math.random()*n.length)]};return`${t(8)}-${t(4)}-4${t(3)}-${r()}${t(3)}-${t(12)}`}updateChat(t,r){return P(this,null,function*(){const n=`/v1/chats/${t}`,i=this.getUrl(n),s=i.startsWith("/")||i.startsWith("./")?new URL(i,window.location.origin):new URL(i),o={"Content-Type":"application/json","Idempotency-Key":this.generateIdempotencyKey()};this.sessionToken&&(o.Authorization=`Bearer ${this.sessionToken}`);const l=yield fetch(s.toString(),{method:"PATCH",headers:o,body:JSON.stringify(r)});if(!l.ok){const d=yield l.text();let c={};try{c=JSON.parse(d)}catch(f){c={detail:d}}throw new Error(c.detail||c.message||`API error: ${l.status} ${l.statusText}`)}if(l.status===204)return{};const u=yield l.text();if(!u)return{};try{return JSON.parse(u)}catch(d){return{}}})}deleteChat(t){return P(this,null,function*(){const r=`/v1/chats/${t}`,n=this.getUrl(r),i=n.startsWith("/")||n.startsWith("./")?new URL(n,window.location.origin):new URL(n),a={"Content-Type":"application/json","Idempotency-Key":this.generateIdempotencyKey()};this.sessionToken&&(a.Authorization=`Bearer ${this.sessionToken}`);const o=yield fetch(i.toString(),{method:"DELETE",headers:a});if(!o.ok){const l=yield o.json().catch(()=>({}));throw new Error(l.detail||l.message||`API error: ${o.status} ${o.statusText}`)}})}listModels(t){return P(this,null,function*(){const r=this.getUrl("/v1/models"),n=r.startsWith("/")||r.startsWith("./")?new URL(r,window.location.origin):new URL(r);t!=null&&t.limit&&n.searchParams.set("limit",t.limit.toString()),t!=null&&t.cursor&&n.searchParams.set("cursor",t.cursor),t!=null&&t["expand[]"]&&t["expand[]"].forEach(a=>{n.searchParams.append("expand[]",a)});const i={"Content-Type":"application/json"};this.sessionToken&&(i.Authorization=`Bearer ${this.sessionToken}`);const s=yield fetch(n.toString(),{method:"GET",headers:i});if(!s.ok){const a=yield s.json().catch(()=>({}));throw new Error(a.detail||a.message||`API error: ${s.status} ${s.statusText}`)}return s.json()})}getModel(t){return P(this,null,function*(){const r=this.getUrl(`/v1/models/${t}`),n={"Content-Type":"application/json"};this.sessionToken&&(n.Authorization=`Bearer ${this.sessionToken}`);const i=yield fetch(r,{method:"GET",headers:n});if(!i.ok){const s=yield i.json().catch(()=>({}));throw new Error(s.detail||s.message||`API error: ${i.status} ${i.statusText}`)}return i.json()})}}function Cf(e,t){return wr(this,null,function*(){const r=e.getReader(),n=new TextDecoder;let i="";try{for(;;){if(t!=null&&t.aborted){r.cancel();break}const{done:s,value:a}=yield new it(r.read());if(s)break;i+=n.decode(a,{stream:!0});const o=i.split(`
14
6
 
15
- `);s=d.pop()||"";for(const h of d)if(h.startsWith("data: ")){const m=h.slice(6);if(m.trim()==="[DONE]"){yield{done:!0};continue}try{yield JSON.parse(m)}catch(y){}}}}finally{a.releaseLock()}})}function J_(t){return t.map(n=>{let a="";if(typeof n.content=="string")a=n.content;else if(Array.isArray(n.content)){const i=n.content.find(s=>s.type==="text");i&&typeof i=="object"&&"text"in i&&(a=i.text)}return{role:n.role,content:a}})}function $_(t){return _(_({id:t.id,role:t.role,content:[{type:"text",text:t.content}],createdAt:new Date(t.createdAt),metadata:{custom:{}}},t.role==="assistant"&&{status:{type:"complete",reason:"stop"},metadata:{unstable_state:null,unstable_annotations:[],unstable_data:[],steps:[],custom:{}}}),t.role==="user"&&{attachments:[]})}function om(t,n){const{modelId:a,systemPrompt:i,ephemeral:s,onChatCreated:o,onUserMessage:c,onThreadIdUpdate:d}=n;return{run(m){return Kl(this,null,function*(){const{messages:y,abortSignal:g,context:v}=m,x=v==null?void 0:v.threadId;c==null||c();const z={messages:J_(y),chatId:null,systemPrompt:i,ephemeral:s,stream:!0};a&&a.trim()!==""&&(z.modelId=a);const D=yield new gr(t.createOrContinueChat(z,g));let k="",q;try{for(var I=xa(K_(D,g)),at,lt,L;at=!(lt=yield new gr(I.next())).done;at=!1){const J=lt.value;if(g!=null&&g.aborted)throw new Error("Request aborted");const st=J.id;st&&!q&&(q=st,o==null||o(st),x&&d&&d(x,st));const ct=J.delta;if(ct!=null&&(k+=ct),J.type==="message"||J.content){const tt=J.content||"";k+=tt}if(J.message&&(k+=J.message.content||""),J.tool_calls,J.finished){k&&(yield{content:[{type:"text",text:k}]});break}k&&(yield{content:[{type:"text",text:k}]})}}catch(lt){L=[lt]}finally{try{at&&(lt=I.return)&&(yield new gr(lt.call(I)))}finally{if(L)throw L[0]}}k&&(yield{content:[{type:"text",text:k}]})})}}}const cm=new Map;function W_(t,n){return{list(){return W(this,null,function*(){const i=[];let o,c=0;do{const h=yield t.listChats({limit:50,cursor:o}),m=h.items||[];Array.isArray(m)&&m.length>0&&i.push(...m),o=h.nextCursor||void 0,c++}while(o&&c<50);return{threads:i.map(h=>{const m=h.id;return!m||h.deletedAt?null:{status:"regular",remoteId:m,title:h.title||"New Chat",createdAt:h.createdAt?new Date(h.createdAt):new Date,updatedAt:h.updatedAt?new Date(h.updatedAt):new Date}}).filter(h=>h!==null)}})},initialize(i){return W(this,null,function*(){return{remoteId:cm.get(i)||i,externalId:void 0}})},rename(i,s){return W(this,null,function*(){yield t.updateChat(i,{title:s})})},archive(i){return W(this,null,function*(){})},unarchive(i){return W(this,null,function*(){})},delete(i){return W(this,null,function*(){yield t.deleteChat(i)})},generateTitle(i,s){return W(this,null,function*(){return new ReadableStream})},fetch(i){return W(this,null,function*(){try{const s=yield t.getChat(i);return{status:"regular",remoteId:s.id||i,title:s.title||"Chat",createdAt:s.createdAt?new Date(s.createdAt):new Date,updatedAt:s.updatedAt?new Date(s.updatedAt):new Date}}catch(s){return{status:"regular",remoteId:i,createdAt:new Date,updatedAt:new Date}}})},updateRemoteId(i,s){cm.set(i,s),n==null||n(i,s)},unstable_Provider:({children:i})=>{const s=op(),o=s==null?void 0:s.remoteId,c=nn.useMemo(()=>({load(){return W(this,null,function*(){if(!o)return{messages:[]};try{const m=yield t.getChat(o);return!m.messages||m.messages.length===0?{messages:[]}:{messages:m.messages.map(g=>$_(g))}}catch(m){return console.error("Failed to load messages for thread:",o,m),{messages:[]}}})},append(m){return W(this,null,function*(){})}}),[o,t]),d=nn.useMemo(()=>({history:c}),[c]);return E.jsx(mo,{adapters:d,children:i})}}}function tT({children:t,baseUrl:n,sessionToken:a,isProxyMode:i=!1,mode:s="multiChat",modelId:o,onModelChange:c,ephemeral:d=!1,systemPrompt:h,initialThreadId:m,onError:y,onChatCreated:g,onUserMessage:v,onThreadIdUpdate:x,onChatsLoaded:w}){const z=R.useMemo(()=>new um(n,a||void 0,i),[n,a,i]),[D,k]=R.useState(o||null);R.useEffect(()=>{o&&k(o)},[o]);const q=R.useCallback(lt=>{g==null||g(lt)},[g]),I=R.useCallback((lt,L)=>{x==null||x(lt,L)},[x]),at=R.useMemo(()=>om(z,{modelId:D||void 0,systemPrompt:h,ephemeral:d,onChatCreated:q,onUserMessage:v}),[z,D,h,d,q,v]);return s==="singleChat"?E.jsx(eT,{modelAdapter:at,children:t}):E.jsx(nT,{client:z,modelAdapterOptions:{modelId:D||void 0,systemPrompt:h,ephemeral:d,onChatCreated:q,onUserMessage:v},initialThreadId:m,onChatsLoaded:w,onThreadIdUpdate:I,onError:y,children:t})}function eT({modelAdapter:t,children:n}){const a=vp(t);return E.jsx(hp,{runtime:a,children:n})}function nT({client:t,modelAdapterOptions:n,initialThreadId:a,onChatsLoaded:i,onThreadIdUpdate:s,onError:o,children:c}){const d=R.useMemo(()=>W_(t,(x,w)=>{s==null||s(x,w)}),[t,s]),h=R.useCallback((x,w)=>{d.updateRemoteId&&d.updateRemoteId(x,w),s==null||s(x,w)},[d,s]),m=R.useMemo(()=>G(_({},d),{list(){return W(this,null,function*(){const w=yield d.list();return i==null||i(),w})}}),[d,i]);R.useEffect(()=>{window.__cuadraThreadListAdapter=m,window.__cuadraThreadListRuntime=null},[m]);const y=R.useMemo(()=>om(t,G(_({},n),{onThreadIdUpdate:h})),[t,n,h]),g=R.useCallback(()=>vp(y),[y]),v=Tp({adapter:m,runtimeHook:g});return R.useEffect(()=>{window.__cuadraThreadListRuntime=v},[v]),E.jsx(hp,{runtime:v,children:c})}function TO(){}function EO(){}function rT(t,n){const a={};return(t[t.length-1]===""?[...t,""]:t).join((a.padRight?" ":"")+","+(a.padLeft===!1?"":" ")).trim()}const aT=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,iT=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,lT={};function fm(t,n){return(lT.jsx?iT:aT).test(t)}const sT=/[ \t\n\f\r]/g;function uT(t){return typeof t=="object"?t.type==="text"?dm(t.value):!1:dm(t)}function dm(t){return t.replace(sT,"")===""}class Vi{constructor(n,a,i){this.normal=a,this.property=n,i&&(this.space=i)}}Vi.prototype.normal={},Vi.prototype.property={},Vi.prototype.space=void 0;function hm(t,n){const a={},i={};for(const s of t)Object.assign(a,s.property),Object.assign(i,s.normal);return new Vi(a,i,n)}function jo(t){return t.toLowerCase()}class Ye{constructor(n,a){this.attribute=a,this.property=n}}Ye.prototype.attribute="",Ye.prototype.booleanish=!1,Ye.prototype.boolean=!1,Ye.prototype.commaOrSpaceSeparated=!1,Ye.prototype.commaSeparated=!1,Ye.prototype.defined=!1,Ye.prototype.mustUseProperty=!1,Ye.prototype.number=!1,Ye.prototype.overloadedBoolean=!1,Ye.prototype.property="",Ye.prototype.spaceSeparated=!1,Ye.prototype.space=void 0;let oT=0;const Rt=Jr(),pe=Jr(),Lo=Jr(),rt=Jr(),ee=Jr(),Da=Jr(),rn=Jr();function Jr(){return xS(2,++oT)}const Bo=Object.freeze(Object.defineProperty({__proto__:null,boolean:Rt,booleanish:pe,commaOrSpaceSeparated:rn,commaSeparated:Da,number:rt,overloadedBoolean:Lo,spaceSeparated:ee},Symbol.toStringTag,{value:"Module"})),Uo=Object.keys(Bo);class Ho extends Ye{constructor(n,a,i,s){let o=-1;if(super(n,a),pm(this,"space",s),typeof i=="number")for(;++o<Uo.length;){const c=Uo[o];pm(this,Uo[o],(i&Bo[c])===Bo[c])}}}Ho.prototype.defined=!0;function pm(t,n,a){a&&(t[n]=a)}function Na(t){const n={},a={};for(const[i,s]of Object.entries(t.properties)){const o=new Ho(i,t.transform(t.attributes||{},i),s,t.space);t.mustUseProperty&&t.mustUseProperty.includes(i)&&(o.mustUseProperty=!0),n[i]=o,a[jo(i)]=i,a[jo(o.attribute)]=i}return new Vi(n,a,t.space)}const mm=Na({properties:{ariaActiveDescendant:null,ariaAtomic:pe,ariaAutoComplete:null,ariaBusy:pe,ariaChecked:pe,ariaColCount:rt,ariaColIndex:rt,ariaColSpan:rt,ariaControls:ee,ariaCurrent:null,ariaDescribedBy:ee,ariaDetails:null,ariaDisabled:pe,ariaDropEffect:ee,ariaErrorMessage:null,ariaExpanded:pe,ariaFlowTo:ee,ariaGrabbed:pe,ariaHasPopup:null,ariaHidden:pe,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ee,ariaLevel:rt,ariaLive:null,ariaModal:pe,ariaMultiLine:pe,ariaMultiSelectable:pe,ariaOrientation:null,ariaOwns:ee,ariaPlaceholder:null,ariaPosInSet:rt,ariaPressed:pe,ariaReadOnly:pe,ariaRelevant:null,ariaRequired:pe,ariaRoleDescription:ee,ariaRowCount:rt,ariaRowIndex:rt,ariaRowSpan:rt,ariaSelected:pe,ariaSetSize:rt,ariaSort:null,ariaValueMax:rt,ariaValueMin:rt,ariaValueNow:rt,ariaValueText:null,role:null},transform(t,n){return n==="role"?n:"aria-"+n.slice(4).toLowerCase()}});function gm(t,n){return n in t?t[n]:n}function ym(t,n){return gm(t,n.toLowerCase())}const cT=Na({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Da,acceptCharset:ee,accessKey:ee,action:null,allow:null,allowFullScreen:Rt,allowPaymentRequest:Rt,allowUserMedia:Rt,alt:null,as:null,async:Rt,autoCapitalize:null,autoComplete:ee,autoFocus:Rt,autoPlay:Rt,blocking:ee,capture:null,charSet:null,checked:Rt,cite:null,className:ee,cols:rt,colSpan:null,content:null,contentEditable:pe,controls:Rt,controlsList:ee,coords:rt|Da,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Rt,defer:Rt,dir:null,dirName:null,disabled:Rt,download:Lo,draggable:pe,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Rt,formTarget:null,headers:ee,height:rt,hidden:Lo,high:rt,href:null,hrefLang:null,htmlFor:ee,httpEquiv:ee,id:null,imageSizes:null,imageSrcSet:null,inert:Rt,inputMode:null,integrity:null,is:null,isMap:Rt,itemId:null,itemProp:ee,itemRef:ee,itemScope:Rt,itemType:ee,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Rt,low:rt,manifest:null,max:null,maxLength:rt,media:null,method:null,min:null,minLength:rt,multiple:Rt,muted:Rt,name:null,nonce:null,noModule:Rt,noValidate:Rt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Rt,optimum:rt,pattern:null,ping:ee,placeholder:null,playsInline:Rt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Rt,referrerPolicy:null,rel:ee,required:Rt,reversed:Rt,rows:rt,rowSpan:rt,sandbox:ee,scope:null,scoped:Rt,seamless:Rt,selected:Rt,shadowRootClonable:Rt,shadowRootDelegatesFocus:Rt,shadowRootMode:null,shape:null,size:rt,sizes:null,slot:null,span:rt,spellCheck:pe,src:null,srcDoc:null,srcLang:null,srcSet:null,start:rt,step:null,style:null,tabIndex:rt,target:null,title:null,translate:null,type:null,typeMustMatch:Rt,useMap:null,value:pe,width:rt,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ee,axis:null,background:null,bgColor:null,border:rt,borderColor:null,bottomMargin:rt,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Rt,declare:Rt,event:null,face:null,frame:null,frameBorder:null,hSpace:rt,leftMargin:rt,link:null,longDesc:null,lowSrc:null,marginHeight:rt,marginWidth:rt,noResize:Rt,noHref:Rt,noShade:Rt,noWrap:Rt,object:null,profile:null,prompt:null,rev:null,rightMargin:rt,rules:null,scheme:null,scrolling:pe,standby:null,summary:null,text:null,topMargin:rt,valueType:null,version:null,vAlign:null,vLink:null,vSpace:rt,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Rt,disableRemotePlayback:Rt,prefix:null,property:null,results:rt,security:null,unselectable:null},space:"html",transform:ym}),fT=Na({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:rn,accentHeight:rt,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:rt,amplitude:rt,arabicForm:null,ascent:rt,attributeName:null,attributeType:null,azimuth:rt,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:rt,by:null,calcMode:null,capHeight:rt,className:ee,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:rt,diffuseConstant:rt,direction:null,display:null,dur:null,divisor:rt,dominantBaseline:null,download:Rt,dx:null,dy:null,edgeMode:null,editable:null,elevation:rt,enableBackground:null,end:null,event:null,exponent:rt,externalResourcesRequired:null,fill:null,fillOpacity:rt,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Da,g2:Da,glyphName:Da,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:rt,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:rt,horizOriginX:rt,horizOriginY:rt,id:null,ideographic:rt,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:rt,k:rt,k1:rt,k2:rt,k3:rt,k4:rt,kernelMatrix:rn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:rt,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:rt,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:rt,overlineThickness:rt,paintOrder:null,panose1:null,path:null,pathLength:rt,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ee,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:rt,pointsAtY:rt,pointsAtZ:rt,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:rn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:rn,rev:rn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:rn,requiredFeatures:rn,requiredFonts:rn,requiredFormats:rn,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:rt,specularExponent:rt,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:rt,strikethroughThickness:rt,string:null,stroke:null,strokeDashArray:rn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:rt,strokeOpacity:rt,strokeWidth:null,style:null,surfaceScale:rt,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:rn,tabIndex:rt,tableValues:null,target:null,targetX:rt,targetY:rt,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:rn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:rt,underlineThickness:rt,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:rt,values:null,vAlphabetic:rt,vMathematical:rt,vectorEffect:null,vHanging:rt,vIdeographic:rt,version:null,vertAdvY:rt,vertOriginX:rt,vertOriginY:rt,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:rt,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:gm}),bm=Na({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(t,n){return"xlink:"+n.slice(5).toLowerCase()}}),vm=Na({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:ym}),xm=Na({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(t,n){return"xml:"+n.slice(3).toLowerCase()}}),dT={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},hT=/[A-Z]/g,Sm=/-[a-z]/g,pT=/^data[-\w.:]+$/i;function mT(t,n){const a=jo(n);let i=n,s=Ye;if(a in t.normal)return t.property[t.normal[a]];if(a.length>4&&a.slice(0,4)==="data"&&pT.test(n)){if(n.charAt(4)==="-"){const o=n.slice(5).replace(Sm,yT);i="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=n.slice(4);if(!Sm.test(o)){let c=o.replace(hT,gT);c.charAt(0)!=="-"&&(c="-"+c),n="data"+c}}s=Ho}return new s(i,n)}function gT(t){return"-"+t.toLowerCase()}function yT(t){return t.charAt(1).toUpperCase()}const bT=hm([mm,cT,bm,vm,xm],"html"),qo=hm([mm,fT,bm,vm,xm],"svg");function vT(t){return t.join(" ").trim()}var Ia={},Vo,wm;function xT(){if(wm)return Vo;wm=1;var t=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,n=/\n/g,a=/^\s*/,i=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,s=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,d=/^\s+|\s+$/g,h=`
16
- `,m="/",y="*",g="",v="comment",x="declaration";function w(D,k){if(typeof D!="string")throw new TypeError("First argument must be a string");if(!D)return[];k=k||{};var q=1,I=1;function at(ot){var nt=ot.match(n);nt&&(q+=nt.length);var H=ot.lastIndexOf(h);I=~H?ot.length-H:I+ot.length}function lt(){var ot={line:q,column:I};return function(nt){return nt.position=new L(ot),ct(),nt}}function L(ot){this.start=ot,this.end={line:q,column:I},this.source=k.source}L.prototype.content=D;function J(ot){var nt=new Error(k.source+":"+q+":"+I+": "+ot);if(nt.reason=ot,nt.filename=k.source,nt.line=q,nt.column=I,nt.source=D,!k.silent)throw nt}function st(ot){var nt=ot.exec(D);if(nt){var H=nt[0];return at(H),D=D.slice(H.length),nt}}function ct(){st(a)}function j(ot){var nt;for(ot=ot||[];nt=tt();)nt!==!1&&ot.push(nt);return ot}function tt(){var ot=lt();if(!(m!=D.charAt(0)||y!=D.charAt(1))){for(var nt=2;g!=D.charAt(nt)&&(y!=D.charAt(nt)||m!=D.charAt(nt+1));)++nt;if(nt+=2,g===D.charAt(nt-1))return J("End of comment missing");var H=D.slice(2,nt-2);return I+=2,at(H),D=D.slice(nt),I+=2,ot({type:v,comment:H})}}function $(){var ot=lt(),nt=st(i);if(nt){if(tt(),!st(s))return J("property missing ':'");var H=st(o),et=ot({type:x,property:z(nt[0].replace(t,g)),value:H?z(H[0].replace(t,g)):g});return st(c),et}}function bt(){var ot=[];j(ot);for(var nt;nt=$();)nt!==!1&&(ot.push(nt),j(ot));return ot}return ct(),bt()}function z(D){return D?D.replace(d,g):g}return Vo=w,Vo}var _m;function ST(){if(_m)return Ia;_m=1;var t=Ia&&Ia.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(Ia,"__esModule",{value:!0}),Ia.default=a;const n=t(xT());function a(i,s){let o=null;if(!i||typeof i!="string")return o;const c=(0,n.default)(i),d=typeof s=="function";return c.forEach(h=>{if(h.type!=="declaration")return;const{property:m,value:y}=h;d?s(m,y,h):y&&(o=o||{},o[m]=y)}),o}return Ia}var Yi={},Tm;function wT(){if(Tm)return Yi;Tm=1,Object.defineProperty(Yi,"__esModule",{value:!0}),Yi.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,a=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,s=/^-(ms)-/,o=function(m){return!m||a.test(m)||t.test(m)},c=function(m,y){return y.toUpperCase()},d=function(m,y){return"".concat(y,"-")},h=function(m,y){return y===void 0&&(y={}),o(m)?m:(m=m.toLowerCase(),y.reactCompat?m=m.replace(s,d):m=m.replace(i,d),m.replace(n,c))};return Yi.camelCase=h,Yi}var Fi,Em;function _T(){if(Em)return Fi;Em=1;var t=Fi&&Fi.__importDefault||function(s){return s&&s.__esModule?s:{default:s}},n=t(ST()),a=wT();function i(s,o){var c={};return!s||typeof s!="string"||(0,n.default)(s,function(d,h){d&&h&&(c[(0,a.camelCase)(d,o)]=h)}),c}return i.default=i,Fi=i,Fi}var TT=_T();const ET=Kt(TT),Cm=Am("end"),Yo=Am("start");function Am(t){return n;function n(a){const i=a&&a.position&&a.position[t]||{};if(typeof i.line=="number"&&i.line>0&&typeof i.column=="number"&&i.column>0)return{line:i.line,column:i.column,offset:typeof i.offset=="number"&&i.offset>-1?i.offset:void 0}}}function CT(t){const n=Yo(t),a=Cm(t);if(n&&a)return{start:n,end:a}}function Gi(t){return!t||typeof t!="object"?"":"position"in t||"type"in t?km(t.position):"start"in t||"end"in t?km(t):"line"in t||"column"in t?Fo(t):""}function Fo(t){return Rm(t&&t.line)+":"+Rm(t&&t.column)}function km(t){return Fo(t&&t.start)+"-"+Fo(t&&t.end)}function Rm(t){return t&&typeof t=="number"?t:1}class De extends Error{constructor(n,a,i){super(),typeof a=="string"&&(i=a,a=void 0);let s="",o={},c=!1;if(a&&("line"in a&&"column"in a?o={place:a}:"start"in a&&"end"in a?o={place:a}:"type"in a?o={ancestors:[a],place:a.position}:o=_({},a)),typeof n=="string"?s=n:!o.cause&&n&&(c=!0,s=n.message,o.cause=n),!o.ruleId&&!o.source&&typeof i=="string"){const h=i.indexOf(":");h===-1?o.ruleId=i:(o.source=i.slice(0,h),o.ruleId=i.slice(h+1))}if(!o.place&&o.ancestors&&o.ancestors){const h=o.ancestors[o.ancestors.length-1];h&&(o.place=h.position)}const d=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=d?d.column:void 0,this.fatal=void 0,this.file="",this.message=s,this.line=d?d.line:void 0,this.name=Gi(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=c&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}De.prototype.file="",De.prototype.name="",De.prototype.reason="",De.prototype.message="",De.prototype.stack="",De.prototype.column=void 0,De.prototype.line=void 0,De.prototype.ancestors=void 0,De.prototype.cause=void 0,De.prototype.fatal=void 0,De.prototype.place=void 0,De.prototype.ruleId=void 0,De.prototype.source=void 0;const Go={}.hasOwnProperty,AT=new Map,kT=/[A-Z]/g,RT=new Set(["table","tbody","thead","tfoot","tr"]),MT=new Set(["td","th"]),Mm="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function zT(t,n){if(!n||n.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const a=n.filePath||void 0;let i;if(n.development){if(typeof n.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");i=UT(a,n.jsxDEV)}else{if(typeof n.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof n.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");i=BT(a,n.jsx,n.jsxs)}const s={Fragment:n.Fragment,ancestors:[],components:n.components||{},create:i,elementAttributeNameCase:n.elementAttributeNameCase||"react",evaluater:n.createEvaluater?n.createEvaluater():void 0,filePath:a,ignoreInvalidStyle:n.ignoreInvalidStyle||!1,passKeys:n.passKeys!==!1,passNode:n.passNode||!1,schema:n.space==="svg"?qo:bT,stylePropertyNameCase:n.stylePropertyNameCase||"dom",tableCellAlignToStyle:n.tableCellAlignToStyle!==!1},o=zm(s,t,void 0);return o&&typeof o!="string"?o:s.create(t,s.Fragment,{children:o||void 0},void 0)}function zm(t,n,a){if(n.type==="element")return OT(t,n,a);if(n.type==="mdxFlowExpression"||n.type==="mdxTextExpression")return DT(t,n);if(n.type==="mdxJsxFlowElement"||n.type==="mdxJsxTextElement")return IT(t,n,a);if(n.type==="mdxjsEsm")return NT(t,n);if(n.type==="root")return jT(t,n,a);if(n.type==="text")return LT(t,n)}function OT(t,n,a){const i=t.schema;let s=i;n.tagName.toLowerCase()==="svg"&&i.space==="html"&&(s=qo,t.schema=s),t.ancestors.push(n);const o=Dm(t,n.tagName,!1),c=HT(t,n);let d=Xo(t,n);return RT.has(n.tagName)&&(d=d.filter(function(h){return typeof h=="string"?!uT(h):!0})),Om(t,c,o,n),Po(c,d),t.ancestors.pop(),t.schema=i,t.create(n,o,c,a)}function DT(t,n){if(n.data&&n.data.estree&&t.evaluater){const i=n.data.estree.body[0];return i.type,t.evaluater.evaluateExpression(i.expression)}Pi(t,n.position)}function NT(t,n){if(n.data&&n.data.estree&&t.evaluater)return t.evaluater.evaluateProgram(n.data.estree);Pi(t,n.position)}function IT(t,n,a){const i=t.schema;let s=i;n.name==="svg"&&i.space==="html"&&(s=qo,t.schema=s),t.ancestors.push(n);const o=n.name===null?t.Fragment:Dm(t,n.name,!0),c=qT(t,n),d=Xo(t,n);return Om(t,c,o,n),Po(c,d),t.ancestors.pop(),t.schema=i,t.create(n,o,c,a)}function jT(t,n,a){const i={};return Po(i,Xo(t,n)),t.create(n,t.Fragment,i,a)}function LT(t,n){return n.value}function Om(t,n,a,i){typeof a!="string"&&a!==t.Fragment&&t.passNode&&(n.node=i)}function Po(t,n){if(n.length>0){const a=n.length>1?n:n[0];a&&(t.children=a)}}function BT(t,n,a){return i;function i(s,o,c,d){const m=Array.isArray(c.children)?a:n;return d?m(o,c,d):m(o,c)}}function UT(t,n){return a;function a(i,s,o,c){const d=Array.isArray(o.children),h=Yo(i);return n(s,o,c,d,{columnNumber:h?h.column-1:void 0,fileName:t,lineNumber:h?h.line:void 0},void 0)}}function HT(t,n){const a={};let i,s;for(s in n.properties)if(s!=="children"&&Go.call(n.properties,s)){const o=VT(t,s,n.properties[s]);if(o){const[c,d]=o;t.tableCellAlignToStyle&&c==="align"&&typeof d=="string"&&MT.has(n.tagName)?i=d:a[c]=d}}if(i){const o=a.style||(a.style={});o[t.stylePropertyNameCase==="css"?"text-align":"textAlign"]=i}return a}function qT(t,n){const a={};for(const i of n.attributes)if(i.type==="mdxJsxExpressionAttribute")if(i.data&&i.data.estree&&t.evaluater){const o=i.data.estree.body[0];o.type;const c=o.expression;c.type;const d=c.properties[0];d.type,Object.assign(a,t.evaluater.evaluateExpression(d.argument))}else Pi(t,n.position);else{const s=i.name;let o;if(i.value&&typeof i.value=="object")if(i.value.data&&i.value.data.estree&&t.evaluater){const d=i.value.data.estree.body[0];d.type,o=t.evaluater.evaluateExpression(d.expression)}else Pi(t,n.position);else o=i.value===null?!0:i.value;a[s]=o}return a}function Xo(t,n){const a=[];let i=-1;const s=t.passKeys?new Map:AT;for(;++i<n.children.length;){const o=n.children[i];let c;if(t.passKeys){const h=o.type==="element"?o.tagName:o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement"?o.name:void 0;if(h){const m=s.get(h)||0;c=h+"-"+m,s.set(h,m+1)}}const d=zm(t,o,c);d!==void 0&&a.push(d)}return a}function VT(t,n,a){const i=mT(t.schema,n);if(!(a==null||typeof a=="number"&&Number.isNaN(a))){if(Array.isArray(a)&&(a=i.commaSeparated?rT(a):vT(a)),i.property==="style"){let s=typeof a=="object"?a:YT(t,String(a));return t.stylePropertyNameCase==="css"&&(s=FT(s)),["style",s]}return[t.elementAttributeNameCase==="react"&&i.space?dT[i.property]||i.property:i.attribute,a]}}function YT(t,n){try{return ET(n,{reactCompat:!0})}catch(a){if(t.ignoreInvalidStyle)return{};const i=a,s=new De("Cannot parse `style` attribute",{ancestors:t.ancestors,cause:i,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw s.file=t.filePath||void 0,s.url=Mm+"#cannot-parse-style-attribute",s}}function Dm(t,n,a){let i;if(!a)i={type:"Literal",value:n};else if(n.includes(".")){const s=n.split(".");let o=-1,c;for(;++o<s.length;){const d=fm(s[o])?{type:"Identifier",name:s[o]}:{type:"Literal",value:s[o]};c=c?{type:"MemberExpression",object:c,property:d,computed:!!(o&&d.type==="Literal"),optional:!1}:d}i=c}else i=fm(n)&&!/^[a-z]/.test(n)?{type:"Identifier",name:n}:{type:"Literal",value:n};if(i.type==="Literal"){const s=i.value;return Go.call(t.components,s)?t.components[s]:s}if(t.evaluater)return t.evaluater.evaluateExpression(i);Pi(t)}function Pi(t,n){const a=new De("Cannot handle MDX estrees without `createEvaluater`",{ancestors:t.ancestors,place:n,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw a.file=t.filePath||void 0,a.url=Mm+"#cannot-handle-mdx-estrees-without-createevaluater",a}function FT(t){const n={};let a;for(a in t)Go.call(t,a)&&(n[GT(a)]=t[a]);return n}function GT(t){let n=t.replace(kT,PT);return n.slice(0,3)==="ms-"&&(n="-"+n),n}function PT(t){return"-"+t.toLowerCase()}const Qo={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},XT={};function Zo(t,n){const a=XT,i=typeof a.includeImageAlt=="boolean"?a.includeImageAlt:!0,s=typeof a.includeHtml=="boolean"?a.includeHtml:!0;return Nm(t,i,s)}function Nm(t,n,a){if(QT(t)){if("value"in t)return t.type==="html"&&!a?"":t.value;if(n&&"alt"in t&&t.alt)return t.alt;if("children"in t)return Im(t.children,n,a)}return Array.isArray(t)?Im(t,n,a):""}function Im(t,n,a){const i=[];let s=-1;for(;++s<t.length;)i[s]=Nm(t[s],n,a);return i.join("")}function QT(t){return!!(t&&typeof t=="object")}const jm=document.createElement("i");function Ko(t){const n="&"+t+";";jm.innerHTML=n;const a=jm.textContent;return a.charCodeAt(a.length-1)===59&&t!=="semi"||a===n?!1:a}function an(t,n,a,i){const s=t.length;let o=0,c;if(n<0?n=-n>s?0:s+n:n=n>s?s:n,a=a>0?a:0,i.length<1e4)c=Array.from(i),c.unshift(n,a),t.splice(...c);else for(a&&t.splice(n,a);o<i.length;)c=i.slice(o,o+1e4),c.unshift(n,0),t.splice(...c),o+=1e4,n+=1e4}function mn(t,n){return t.length>0?(an(t,t.length,0,n),t):n}const Lm={}.hasOwnProperty;function Bm(t){const n={};let a=-1;for(;++a<t.length;)ZT(n,t[a]);return n}function ZT(t,n){let a;for(a in n){const s=(Lm.call(t,a)?t[a]:void 0)||(t[a]={}),o=n[a];let c;if(o)for(c in o){Lm.call(s,c)||(s[c]=[]);const d=o[c];KT(s[c],Array.isArray(d)?d:d?[d]:[])}}}function KT(t,n){let a=-1;const i=[];for(;++a<n.length;)(n[a].add==="after"?t:i).push(n[a]);an(t,0,0,i)}function Um(t,n){const a=Number.parseInt(t,n);return a<9||a===11||a>13&&a<32||a>126&&a<160||a>55295&&a<57344||a>64975&&a<65008||(a&65535)===65535||(a&65535)===65534||a>1114111?"�":String.fromCodePoint(a)}function Dn(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Be=br(/[A-Za-z]/),Ne=br(/[\dA-Za-z]/),JT=br(/[#-'*+\--9=?A-Z^-~]/);function bs(t){return t!==null&&(t<32||t===127)}const Jo=br(/\d/),$T=br(/[\dA-Fa-f]/),WT=br(/[!-/:-@[-`{-~]/);function St(t){return t!==null&&t<-2}function $t(t){return t!==null&&(t<0||t===32)}function zt(t){return t===-2||t===-1||t===32}const vs=br(new RegExp("\\p{P}|\\p{S}","u")),$r=br(/\s/);function br(t){return n;function n(a){return a!==null&&a>-1&&t.test(String.fromCharCode(a))}}function ja(t){const n=[];let a=-1,i=0,s=0;for(;++a<t.length;){const o=t.charCodeAt(a);let c="";if(o===37&&Ne(t.charCodeAt(a+1))&&Ne(t.charCodeAt(a+2)))s=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(c=String.fromCharCode(o));else if(o>55295&&o<57344){const d=t.charCodeAt(a+1);o<56320&&d>56319&&d<57344?(c=String.fromCharCode(o,d),s=1):c="�"}else c=String.fromCharCode(o);c&&(n.push(t.slice(i,a),encodeURIComponent(c)),i=a+s+1,c=""),s&&(a+=s,s=0)}return n.join("")+t.slice(i)}function Ut(t,n,a,i){const s=i?i-1:Number.POSITIVE_INFINITY;let o=0;return c;function c(h){return zt(h)?(t.enter(a),d(h)):n(h)}function d(h){return zt(h)&&o++<s?(t.consume(h),d):(t.exit(a),n(h))}}const tE={tokenize:eE};function eE(t){const n=t.attempt(this.parser.constructs.contentInitial,i,s);let a;return n;function i(d){if(d===null){t.consume(d);return}return t.enter("lineEnding"),t.consume(d),t.exit("lineEnding"),Ut(t,n,"linePrefix")}function s(d){return t.enter("paragraph"),o(d)}function o(d){const h=t.enter("chunkText",{contentType:"text",previous:a});return a&&(a.next=h),a=h,c(d)}function c(d){if(d===null){t.exit("chunkText"),t.exit("paragraph"),t.consume(d);return}return St(d)?(t.consume(d),t.exit("chunkText"),o):(t.consume(d),c)}}const nE={tokenize:rE},Hm={tokenize:aE};function rE(t){const n=this,a=[];let i=0,s,o,c;return d;function d(I){if(i<a.length){const at=a[i];return n.containerState=at[1],t.attempt(at[0].continuation,h,m)(I)}return m(I)}function h(I){if(i++,n.containerState._closeFlow){n.containerState._closeFlow=void 0,s&&q();const at=n.events.length;let lt=at,L;for(;lt--;)if(n.events[lt][0]==="exit"&&n.events[lt][1].type==="chunkFlow"){L=n.events[lt][1].end;break}k(i);let J=at;for(;J<n.events.length;)n.events[J][1].end=_({},L),J++;return an(n.events,lt+1,0,n.events.slice(at)),n.events.length=J,m(I)}return d(I)}function m(I){if(i===a.length){if(!s)return v(I);if(s.currentConstruct&&s.currentConstruct.concrete)return w(I);n.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return n.containerState={},t.check(Hm,y,g)(I)}function y(I){return s&&q(),k(i),v(I)}function g(I){return n.parser.lazy[n.now().line]=i!==a.length,c=n.now().offset,w(I)}function v(I){return n.containerState={},t.attempt(Hm,x,w)(I)}function x(I){return i++,a.push([n.currentConstruct,n.containerState]),v(I)}function w(I){if(I===null){s&&q(),k(0),t.consume(I);return}return s=s||n.parser.flow(n.now()),t.enter("chunkFlow",{_tokenizer:s,contentType:"flow",previous:o}),z(I)}function z(I){if(I===null){D(t.exit("chunkFlow"),!0),k(0),t.consume(I);return}return St(I)?(t.consume(I),D(t.exit("chunkFlow")),i=0,n.interrupt=void 0,d):(t.consume(I),z)}function D(I,at){const lt=n.sliceStream(I);if(at&&lt.push(null),I.previous=o,o&&(o.next=I),o=I,s.defineSkip(I.start),s.write(lt),n.parser.lazy[I.start.line]){let L=s.events.length;for(;L--;)if(s.events[L][1].start.offset<c&&(!s.events[L][1].end||s.events[L][1].end.offset>c))return;const J=n.events.length;let st=J,ct,j;for(;st--;)if(n.events[st][0]==="exit"&&n.events[st][1].type==="chunkFlow"){if(ct){j=n.events[st][1].end;break}ct=!0}for(k(i),L=J;L<n.events.length;)n.events[L][1].end=_({},j),L++;an(n.events,st+1,0,n.events.slice(J)),n.events.length=L}}function k(I){let at=a.length;for(;at-- >I;){const lt=a[at];n.containerState=lt[1],lt[0].exit.call(n,t)}a.length=I}function q(){s.write([null]),o=void 0,s=void 0,n.containerState._closeFlow=void 0}}function aE(t,n,a){return Ut(t,t.attempt(this.parser.constructs.document,n,a),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function La(t){if(t===null||$t(t)||$r(t))return 1;if(vs(t))return 2}function xs(t,n,a){const i=[];let s=-1;for(;++s<t.length;){const o=t[s].resolveAll;o&&!i.includes(o)&&(n=o(n,a),i.push(o))}return n}const $o={name:"attention",resolveAll:iE,tokenize:lE};function iE(t,n){let a=-1,i,s,o,c,d,h,m,y;for(;++a<t.length;)if(t[a][0]==="enter"&&t[a][1].type==="attentionSequence"&&t[a][1]._close){for(i=a;i--;)if(t[i][0]==="exit"&&t[i][1].type==="attentionSequence"&&t[i][1]._open&&n.sliceSerialize(t[i][1]).charCodeAt(0)===n.sliceSerialize(t[a][1]).charCodeAt(0)){if((t[i][1]._close||t[a][1]._open)&&(t[a][1].end.offset-t[a][1].start.offset)%3&&!((t[i][1].end.offset-t[i][1].start.offset+t[a][1].end.offset-t[a][1].start.offset)%3))continue;h=t[i][1].end.offset-t[i][1].start.offset>1&&t[a][1].end.offset-t[a][1].start.offset>1?2:1;const g=_({},t[i][1].end),v=_({},t[a][1].start);qm(g,-h),qm(v,h),c={type:h>1?"strongSequence":"emphasisSequence",start:g,end:_({},t[i][1].end)},d={type:h>1?"strongSequence":"emphasisSequence",start:_({},t[a][1].start),end:v},o={type:h>1?"strongText":"emphasisText",start:_({},t[i][1].end),end:_({},t[a][1].start)},s={type:h>1?"strong":"emphasis",start:_({},c.start),end:_({},d.end)},t[i][1].end=_({},c.start),t[a][1].start=_({},d.end),m=[],t[i][1].end.offset-t[i][1].start.offset&&(m=mn(m,[["enter",t[i][1],n],["exit",t[i][1],n]])),m=mn(m,[["enter",s,n],["enter",c,n],["exit",c,n],["enter",o,n]]),m=mn(m,xs(n.parser.constructs.insideSpan.null,t.slice(i+1,a),n)),m=mn(m,[["exit",o,n],["enter",d,n],["exit",d,n],["exit",s,n]]),t[a][1].end.offset-t[a][1].start.offset?(y=2,m=mn(m,[["enter",t[a][1],n],["exit",t[a][1],n]])):y=0,an(t,i-1,a-i+3,m),a=i+m.length-y-2;break}}for(a=-1;++a<t.length;)t[a][1].type==="attentionSequence"&&(t[a][1].type="data");return t}function lE(t,n){const a=this.parser.constructs.attentionMarkers.null,i=this.previous,s=La(i);let o;return c;function c(h){return o=h,t.enter("attentionSequence"),d(h)}function d(h){if(h===o)return t.consume(h),d;const m=t.exit("attentionSequence"),y=La(h),g=!y||y===2&&s||a.includes(h),v=!s||s===2&&y||a.includes(i);return m._open=!!(o===42?g:g&&(s||!v)),m._close=!!(o===42?v:v&&(y||!g)),n(h)}}function qm(t,n){t.column+=n,t.offset+=n,t._bufferIndex+=n}const sE={name:"autolink",tokenize:uE};function uE(t,n,a){let i=0;return s;function s(x){return t.enter("autolink"),t.enter("autolinkMarker"),t.consume(x),t.exit("autolinkMarker"),t.enter("autolinkProtocol"),o}function o(x){return Be(x)?(t.consume(x),c):x===64?a(x):m(x)}function c(x){return x===43||x===45||x===46||Ne(x)?(i=1,d(x)):m(x)}function d(x){return x===58?(t.consume(x),i=0,h):(x===43||x===45||x===46||Ne(x))&&i++<32?(t.consume(x),d):(i=0,m(x))}function h(x){return x===62?(t.exit("autolinkProtocol"),t.enter("autolinkMarker"),t.consume(x),t.exit("autolinkMarker"),t.exit("autolink"),n):x===null||x===32||x===60||bs(x)?a(x):(t.consume(x),h)}function m(x){return x===64?(t.consume(x),y):JT(x)?(t.consume(x),m):a(x)}function y(x){return Ne(x)?g(x):a(x)}function g(x){return x===46?(t.consume(x),i=0,y):x===62?(t.exit("autolinkProtocol").type="autolinkEmail",t.enter("autolinkMarker"),t.consume(x),t.exit("autolinkMarker"),t.exit("autolink"),n):v(x)}function v(x){if((x===45||Ne(x))&&i++<63){const w=x===45?v:g;return t.consume(x),w}return a(x)}}const Xi={partial:!0,tokenize:oE};function oE(t,n,a){return i;function i(o){return zt(o)?Ut(t,s,"linePrefix")(o):s(o)}function s(o){return o===null||St(o)?n(o):a(o)}}const Vm={continuation:{tokenize:fE},exit:dE,name:"blockQuote",tokenize:cE};function cE(t,n,a){const i=this;return s;function s(c){if(c===62){const d=i.containerState;return d.open||(t.enter("blockQuote",{_container:!0}),d.open=!0),t.enter("blockQuotePrefix"),t.enter("blockQuoteMarker"),t.consume(c),t.exit("blockQuoteMarker"),o}return a(c)}function o(c){return zt(c)?(t.enter("blockQuotePrefixWhitespace"),t.consume(c),t.exit("blockQuotePrefixWhitespace"),t.exit("blockQuotePrefix"),n):(t.exit("blockQuotePrefix"),n(c))}}function fE(t,n,a){const i=this;return s;function s(c){return zt(c)?Ut(t,o,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c):o(c)}function o(c){return t.attempt(Vm,n,a)(c)}}function dE(t){t.exit("blockQuote")}const Ym={name:"characterEscape",tokenize:hE};function hE(t,n,a){return i;function i(o){return t.enter("characterEscape"),t.enter("escapeMarker"),t.consume(o),t.exit("escapeMarker"),s}function s(o){return WT(o)?(t.enter("characterEscapeValue"),t.consume(o),t.exit("characterEscapeValue"),t.exit("characterEscape"),n):a(o)}}const Fm={name:"characterReference",tokenize:pE};function pE(t,n,a){const i=this;let s=0,o,c;return d;function d(g){return t.enter("characterReference"),t.enter("characterReferenceMarker"),t.consume(g),t.exit("characterReferenceMarker"),h}function h(g){return g===35?(t.enter("characterReferenceMarkerNumeric"),t.consume(g),t.exit("characterReferenceMarkerNumeric"),m):(t.enter("characterReferenceValue"),o=31,c=Ne,y(g))}function m(g){return g===88||g===120?(t.enter("characterReferenceMarkerHexadecimal"),t.consume(g),t.exit("characterReferenceMarkerHexadecimal"),t.enter("characterReferenceValue"),o=6,c=$T,y):(t.enter("characterReferenceValue"),o=7,c=Jo,y(g))}function y(g){if(g===59&&s){const v=t.exit("characterReferenceValue");return c===Ne&&!Ko(i.sliceSerialize(v))?a(g):(t.enter("characterReferenceMarker"),t.consume(g),t.exit("characterReferenceMarker"),t.exit("characterReference"),n)}return c(g)&&s++<o?(t.consume(g),y):a(g)}}const Gm={partial:!0,tokenize:gE},Pm={concrete:!0,name:"codeFenced",tokenize:mE};function mE(t,n,a){const i=this,s={partial:!0,tokenize:lt};let o=0,c=0,d;return h;function h(L){return m(L)}function m(L){const J=i.events[i.events.length-1];return o=J&&J[1].type==="linePrefix"?J[2].sliceSerialize(J[1],!0).length:0,d=L,t.enter("codeFenced"),t.enter("codeFencedFence"),t.enter("codeFencedFenceSequence"),y(L)}function y(L){return L===d?(c++,t.consume(L),y):c<3?a(L):(t.exit("codeFencedFenceSequence"),zt(L)?Ut(t,g,"whitespace")(L):g(L))}function g(L){return L===null||St(L)?(t.exit("codeFencedFence"),i.interrupt?n(L):t.check(Gm,z,at)(L)):(t.enter("codeFencedFenceInfo"),t.enter("chunkString",{contentType:"string"}),v(L))}function v(L){return L===null||St(L)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),g(L)):zt(L)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),Ut(t,x,"whitespace")(L)):L===96&&L===d?a(L):(t.consume(L),v)}function x(L){return L===null||St(L)?g(L):(t.enter("codeFencedFenceMeta"),t.enter("chunkString",{contentType:"string"}),w(L))}function w(L){return L===null||St(L)?(t.exit("chunkString"),t.exit("codeFencedFenceMeta"),g(L)):L===96&&L===d?a(L):(t.consume(L),w)}function z(L){return t.attempt(s,at,D)(L)}function D(L){return t.enter("lineEnding"),t.consume(L),t.exit("lineEnding"),k}function k(L){return o>0&&zt(L)?Ut(t,q,"linePrefix",o+1)(L):q(L)}function q(L){return L===null||St(L)?t.check(Gm,z,at)(L):(t.enter("codeFlowValue"),I(L))}function I(L){return L===null||St(L)?(t.exit("codeFlowValue"),q(L)):(t.consume(L),I)}function at(L){return t.exit("codeFenced"),n(L)}function lt(L,J,st){let ct=0;return j;function j(nt){return L.enter("lineEnding"),L.consume(nt),L.exit("lineEnding"),tt}function tt(nt){return L.enter("codeFencedFence"),zt(nt)?Ut(L,$,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(nt):$(nt)}function $(nt){return nt===d?(L.enter("codeFencedFenceSequence"),bt(nt)):st(nt)}function bt(nt){return nt===d?(ct++,L.consume(nt),bt):ct>=c?(L.exit("codeFencedFenceSequence"),zt(nt)?Ut(L,ot,"whitespace")(nt):ot(nt)):st(nt)}function ot(nt){return nt===null||St(nt)?(L.exit("codeFencedFence"),J(nt)):st(nt)}}}function gE(t,n,a){const i=this;return s;function s(c){return c===null?a(c):(t.enter("lineEnding"),t.consume(c),t.exit("lineEnding"),o)}function o(c){return i.parser.lazy[i.now().line]?a(c):n(c)}}const Wo={name:"codeIndented",tokenize:bE},yE={partial:!0,tokenize:vE};function bE(t,n,a){const i=this;return s;function s(m){return t.enter("codeIndented"),Ut(t,o,"linePrefix",5)(m)}function o(m){const y=i.events[i.events.length-1];return y&&y[1].type==="linePrefix"&&y[2].sliceSerialize(y[1],!0).length>=4?c(m):a(m)}function c(m){return m===null?h(m):St(m)?t.attempt(yE,c,h)(m):(t.enter("codeFlowValue"),d(m))}function d(m){return m===null||St(m)?(t.exit("codeFlowValue"),c(m)):(t.consume(m),d)}function h(m){return t.exit("codeIndented"),n(m)}}function vE(t,n,a){const i=this;return s;function s(c){return i.parser.lazy[i.now().line]?a(c):St(c)?(t.enter("lineEnding"),t.consume(c),t.exit("lineEnding"),s):Ut(t,o,"linePrefix",5)(c)}function o(c){const d=i.events[i.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?n(c):St(c)?s(c):a(c)}}const xE={name:"codeText",previous:wE,resolve:SE,tokenize:_E};function SE(t){let n=t.length-4,a=3,i,s;if((t[a][1].type==="lineEnding"||t[a][1].type==="space")&&(t[n][1].type==="lineEnding"||t[n][1].type==="space")){for(i=a;++i<n;)if(t[i][1].type==="codeTextData"){t[a][1].type="codeTextPadding",t[n][1].type="codeTextPadding",a+=2,n-=2;break}}for(i=a-1,n++;++i<=n;)s===void 0?i!==n&&t[i][1].type!=="lineEnding"&&(s=i):(i===n||t[i][1].type==="lineEnding")&&(t[s][1].type="codeTextData",i!==s+2&&(t[s][1].end=t[i-1][1].end,t.splice(s+2,i-s-2),n-=i-s-2,i=s+2),s=void 0);return t}function wE(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"}function _E(t,n,a){let i=0,s,o;return c;function c(g){return t.enter("codeText"),t.enter("codeTextSequence"),d(g)}function d(g){return g===96?(t.consume(g),i++,d):(t.exit("codeTextSequence"),h(g))}function h(g){return g===null?a(g):g===32?(t.enter("space"),t.consume(g),t.exit("space"),h):g===96?(o=t.enter("codeTextSequence"),s=0,y(g)):St(g)?(t.enter("lineEnding"),t.consume(g),t.exit("lineEnding"),h):(t.enter("codeTextData"),m(g))}function m(g){return g===null||g===32||g===96||St(g)?(t.exit("codeTextData"),h(g)):(t.consume(g),m)}function y(g){return g===96?(t.consume(g),s++,y):s===i?(t.exit("codeTextSequence"),t.exit("codeText"),n(g)):(o.type="codeTextData",m(g))}}class TE{constructor(n){this.left=n?[...n]:[],this.right=[]}get(n){if(n<0||n>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+n+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return n<this.left.length?this.left[n]:this.right[this.right.length-n+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(n,a){const i=a==null?Number.POSITIVE_INFINITY:a;return i<this.left.length?this.left.slice(n,i):n>this.left.length?this.right.slice(this.right.length-i+this.left.length,this.right.length-n+this.left.length).reverse():this.left.slice(n).concat(this.right.slice(this.right.length-i+this.left.length).reverse())}splice(n,a,i){const s=a||0;this.setCursor(Math.trunc(n));const o=this.right.splice(this.right.length-s,Number.POSITIVE_INFINITY);return i&&Qi(this.left,i),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(n){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(n)}pushMany(n){this.setCursor(Number.POSITIVE_INFINITY),Qi(this.left,n)}unshift(n){this.setCursor(0),this.right.push(n)}unshiftMany(n){this.setCursor(0),Qi(this.right,n.reverse())}setCursor(n){if(!(n===this.left.length||n>this.left.length&&this.right.length===0||n<0&&this.left.length===0))if(n<this.left.length){const a=this.left.splice(n,Number.POSITIVE_INFINITY);Qi(this.right,a.reverse())}else{const a=this.right.splice(this.left.length+this.right.length-n,Number.POSITIVE_INFINITY);Qi(this.left,a.reverse())}}}function Qi(t,n){let a=0;if(n.length<1e4)t.push(...n);else for(;a<n.length;)t.push(...n.slice(a,a+1e4)),a+=1e4}function Xm(t){const n={};let a=-1,i,s,o,c,d,h,m;const y=new TE(t);for(;++a<y.length;){for(;a in n;)a=n[a];if(i=y.get(a),a&&i[1].type==="chunkFlow"&&y.get(a-1)[1].type==="listItemPrefix"&&(h=i[1]._tokenizer.events,o=0,o<h.length&&h[o][1].type==="lineEndingBlank"&&(o+=2),o<h.length&&h[o][1].type==="content"))for(;++o<h.length&&h[o][1].type!=="content";)h[o][1].type==="chunkText"&&(h[o][1]._isInFirstContentOfListItem=!0,o++);if(i[0]==="enter")i[1].contentType&&(Object.assign(n,EE(y,a)),a=n[a],m=!0);else if(i[1]._container){for(o=a,s=void 0;o--;)if(c=y.get(o),c[1].type==="lineEnding"||c[1].type==="lineEndingBlank")c[0]==="enter"&&(s&&(y.get(s)[1].type="lineEndingBlank"),c[1].type="lineEnding",s=o);else if(!(c[1].type==="linePrefix"||c[1].type==="listItemIndent"))break;s&&(i[1].end=_({},y.get(s)[1].start),d=y.slice(s,a),d.unshift(i),y.splice(s,a-s+1,d))}}return an(t,0,Number.POSITIVE_INFINITY,y.slice(0)),!m}function EE(t,n){const a=t.get(n)[1],i=t.get(n)[2];let s=n-1;const o=[];let c=a._tokenizer;c||(c=i.parser[a.contentType](a.start),a._contentTypeTextTrailing&&(c._contentTypeTextTrailing=!0));const d=c.events,h=[],m={};let y,g,v=-1,x=a,w=0,z=0;const D=[z];for(;x;){for(;t.get(++s)[1]!==x;);o.push(s),x._tokenizer||(y=i.sliceStream(x),x.next||y.push(null),g&&c.defineSkip(x.start),x._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=!0),c.write(y),x._isInFirstContentOfListItem&&(c._gfmTasklistFirstContentOfListItem=void 0)),g=x,x=x.next}for(x=a;++v<d.length;)d[v][0]==="exit"&&d[v-1][0]==="enter"&&d[v][1].type===d[v-1][1].type&&d[v][1].start.line!==d[v][1].end.line&&(z=v+1,D.push(z),x._tokenizer=void 0,x.previous=void 0,x=x.next);for(c.events=[],x?(x._tokenizer=void 0,x.previous=void 0):D.pop(),v=D.length;v--;){const k=d.slice(D[v],D[v+1]),q=o.pop();h.push([q,q+k.length-1]),t.splice(q,2,k)}for(h.reverse(),v=-1;++v<h.length;)m[w+h[v][0]]=w+h[v][1],w+=h[v][1]-h[v][0]-1;return m}const CE={resolve:kE,tokenize:RE},AE={partial:!0,tokenize:ME};function kE(t){return Xm(t),t}function RE(t,n){let a;return i;function i(d){return t.enter("content"),a=t.enter("chunkContent",{contentType:"content"}),s(d)}function s(d){return d===null?o(d):St(d)?t.check(AE,c,o)(d):(t.consume(d),s)}function o(d){return t.exit("chunkContent"),t.exit("content"),n(d)}function c(d){return t.consume(d),t.exit("chunkContent"),a.next=t.enter("chunkContent",{contentType:"content",previous:a}),a=a.next,s}}function ME(t,n,a){const i=this;return s;function s(c){return t.exit("chunkContent"),t.enter("lineEnding"),t.consume(c),t.exit("lineEnding"),Ut(t,o,"linePrefix")}function o(c){if(c===null||St(c))return a(c);const d=i.events[i.events.length-1];return!i.parser.constructs.disable.null.includes("codeIndented")&&d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?n(c):t.interrupt(i.parser.constructs.flow,a,n)(c)}}function Qm(t,n,a,i,s,o,c,d,h){const m=h||Number.POSITIVE_INFINITY;let y=0;return g;function g(k){return k===60?(t.enter(i),t.enter(s),t.enter(o),t.consume(k),t.exit(o),v):k===null||k===32||k===41||bs(k)?a(k):(t.enter(i),t.enter(c),t.enter(d),t.enter("chunkString",{contentType:"string"}),z(k))}function v(k){return k===62?(t.enter(o),t.consume(k),t.exit(o),t.exit(s),t.exit(i),n):(t.enter(d),t.enter("chunkString",{contentType:"string"}),x(k))}function x(k){return k===62?(t.exit("chunkString"),t.exit(d),v(k)):k===null||k===60||St(k)?a(k):(t.consume(k),k===92?w:x)}function w(k){return k===60||k===62||k===92?(t.consume(k),x):x(k)}function z(k){return!y&&(k===null||k===41||$t(k))?(t.exit("chunkString"),t.exit(d),t.exit(c),t.exit(i),n(k)):y<m&&k===40?(t.consume(k),y++,z):k===41?(t.consume(k),y--,z):k===null||k===32||k===40||bs(k)?a(k):(t.consume(k),k===92?D:z)}function D(k){return k===40||k===41||k===92?(t.consume(k),z):z(k)}}function Zm(t,n,a,i,s,o){const c=this;let d=0,h;return m;function m(x){return t.enter(i),t.enter(s),t.consume(x),t.exit(s),t.enter(o),y}function y(x){return d>999||x===null||x===91||x===93&&!h||x===94&&!d&&"_hiddenFootnoteSupport"in c.parser.constructs?a(x):x===93?(t.exit(o),t.enter(s),t.consume(x),t.exit(s),t.exit(i),n):St(x)?(t.enter("lineEnding"),t.consume(x),t.exit("lineEnding"),y):(t.enter("chunkString",{contentType:"string"}),g(x))}function g(x){return x===null||x===91||x===93||St(x)||d++>999?(t.exit("chunkString"),y(x)):(t.consume(x),h||(h=!zt(x)),x===92?v:g)}function v(x){return x===91||x===92||x===93?(t.consume(x),d++,g):g(x)}}function Km(t,n,a,i,s,o){let c;return d;function d(v){return v===34||v===39||v===40?(t.enter(i),t.enter(s),t.consume(v),t.exit(s),c=v===40?41:v,h):a(v)}function h(v){return v===c?(t.enter(s),t.consume(v),t.exit(s),t.exit(i),n):(t.enter(o),m(v))}function m(v){return v===c?(t.exit(o),h(c)):v===null?a(v):St(v)?(t.enter("lineEnding"),t.consume(v),t.exit("lineEnding"),Ut(t,m,"linePrefix")):(t.enter("chunkString",{contentType:"string"}),y(v))}function y(v){return v===c||v===null||St(v)?(t.exit("chunkString"),m(v)):(t.consume(v),v===92?g:y)}function g(v){return v===c||v===92?(t.consume(v),y):y(v)}}function Zi(t,n){let a;return i;function i(s){return St(s)?(t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),a=!0,i):zt(s)?Ut(t,i,a?"linePrefix":"lineSuffix")(s):n(s)}}const zE={name:"definition",tokenize:DE},OE={partial:!0,tokenize:NE};function DE(t,n,a){const i=this;let s;return o;function o(x){return t.enter("definition"),c(x)}function c(x){return Zm.call(i,t,d,a,"definitionLabel","definitionLabelMarker","definitionLabelString")(x)}function d(x){return s=Dn(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),x===58?(t.enter("definitionMarker"),t.consume(x),t.exit("definitionMarker"),h):a(x)}function h(x){return $t(x)?Zi(t,m)(x):m(x)}function m(x){return Qm(t,y,a,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(x)}function y(x){return t.attempt(OE,g,g)(x)}function g(x){return zt(x)?Ut(t,v,"whitespace")(x):v(x)}function v(x){return x===null||St(x)?(t.exit("definition"),i.parser.defined.push(s),n(x)):a(x)}}function NE(t,n,a){return i;function i(d){return $t(d)?Zi(t,s)(d):a(d)}function s(d){return Km(t,o,a,"definitionTitle","definitionTitleMarker","definitionTitleString")(d)}function o(d){return zt(d)?Ut(t,c,"whitespace")(d):c(d)}function c(d){return d===null||St(d)?n(d):a(d)}}const IE={name:"hardBreakEscape",tokenize:jE};function jE(t,n,a){return i;function i(o){return t.enter("hardBreakEscape"),t.consume(o),s}function s(o){return St(o)?(t.exit("hardBreakEscape"),n(o)):a(o)}}const LE={name:"headingAtx",resolve:BE,tokenize:UE};function BE(t,n){let a=t.length-2,i=3,s,o;return t[i][1].type==="whitespace"&&(i+=2),a-2>i&&t[a][1].type==="whitespace"&&(a-=2),t[a][1].type==="atxHeadingSequence"&&(i===a-1||a-4>i&&t[a-2][1].type==="whitespace")&&(a-=i+1===a?2:4),a>i&&(s={type:"atxHeadingText",start:t[i][1].start,end:t[a][1].end},o={type:"chunkText",start:t[i][1].start,end:t[a][1].end,contentType:"text"},an(t,i,a-i+1,[["enter",s,n],["enter",o,n],["exit",o,n],["exit",s,n]])),t}function UE(t,n,a){let i=0;return s;function s(y){return t.enter("atxHeading"),o(y)}function o(y){return t.enter("atxHeadingSequence"),c(y)}function c(y){return y===35&&i++<6?(t.consume(y),c):y===null||$t(y)?(t.exit("atxHeadingSequence"),d(y)):a(y)}function d(y){return y===35?(t.enter("atxHeadingSequence"),h(y)):y===null||St(y)?(t.exit("atxHeading"),n(y)):zt(y)?Ut(t,d,"whitespace")(y):(t.enter("atxHeadingText"),m(y))}function h(y){return y===35?(t.consume(y),h):(t.exit("atxHeadingSequence"),d(y))}function m(y){return y===null||y===35||$t(y)?(t.exit("atxHeadingText"),d(y)):(t.consume(y),m)}}const HE=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Jm=["pre","script","style","textarea"],qE={concrete:!0,name:"htmlFlow",resolveTo:FE,tokenize:GE},VE={partial:!0,tokenize:XE},YE={partial:!0,tokenize:PE};function FE(t){let n=t.length;for(;n--&&!(t[n][0]==="enter"&&t[n][1].type==="htmlFlow"););return n>1&&t[n-2][1].type==="linePrefix"&&(t[n][1].start=t[n-2][1].start,t[n+1][1].start=t[n-2][1].start,t.splice(n-2,2)),t}function GE(t,n,a){const i=this;let s,o,c,d,h;return m;function m(T){return y(T)}function y(T){return t.enter("htmlFlow"),t.enter("htmlFlowData"),t.consume(T),g}function g(T){return T===33?(t.consume(T),v):T===47?(t.consume(T),o=!0,z):T===63?(t.consume(T),s=3,i.interrupt?n:C):Be(T)?(t.consume(T),c=String.fromCharCode(T),D):a(T)}function v(T){return T===45?(t.consume(T),s=2,x):T===91?(t.consume(T),s=5,d=0,w):Be(T)?(t.consume(T),s=4,i.interrupt?n:C):a(T)}function x(T){return T===45?(t.consume(T),i.interrupt?n:C):a(T)}function w(T){const ut="CDATA[";return T===ut.charCodeAt(d++)?(t.consume(T),d===ut.length?i.interrupt?n:$:w):a(T)}function z(T){return Be(T)?(t.consume(T),c=String.fromCharCode(T),D):a(T)}function D(T){if(T===null||T===47||T===62||$t(T)){const ut=T===47,vt=c.toLowerCase();return!ut&&!o&&Jm.includes(vt)?(s=1,i.interrupt?n(T):$(T)):HE.includes(c.toLowerCase())?(s=6,ut?(t.consume(T),k):i.interrupt?n(T):$(T)):(s=7,i.interrupt&&!i.parser.lazy[i.now().line]?a(T):o?q(T):I(T))}return T===45||Ne(T)?(t.consume(T),c+=String.fromCharCode(T),D):a(T)}function k(T){return T===62?(t.consume(T),i.interrupt?n:$):a(T)}function q(T){return zt(T)?(t.consume(T),q):j(T)}function I(T){return T===47?(t.consume(T),j):T===58||T===95||Be(T)?(t.consume(T),at):zt(T)?(t.consume(T),I):j(T)}function at(T){return T===45||T===46||T===58||T===95||Ne(T)?(t.consume(T),at):lt(T)}function lt(T){return T===61?(t.consume(T),L):zt(T)?(t.consume(T),lt):I(T)}function L(T){return T===null||T===60||T===61||T===62||T===96?a(T):T===34||T===39?(t.consume(T),h=T,J):zt(T)?(t.consume(T),L):st(T)}function J(T){return T===h?(t.consume(T),h=null,ct):T===null||St(T)?a(T):(t.consume(T),J)}function st(T){return T===null||T===34||T===39||T===47||T===60||T===61||T===62||T===96||$t(T)?lt(T):(t.consume(T),st)}function ct(T){return T===47||T===62||zt(T)?I(T):a(T)}function j(T){return T===62?(t.consume(T),tt):a(T)}function tt(T){return T===null||St(T)?$(T):zt(T)?(t.consume(T),tt):a(T)}function $(T){return T===45&&s===2?(t.consume(T),H):T===60&&s===1?(t.consume(T),et):T===62&&s===4?(t.consume(T),M):T===63&&s===3?(t.consume(T),C):T===93&&s===5?(t.consume(T),Tt):St(T)&&(s===6||s===7)?(t.exit("htmlFlowData"),t.check(VE,P,bt)(T)):T===null||St(T)?(t.exit("htmlFlowData"),bt(T)):(t.consume(T),$)}function bt(T){return t.check(YE,ot,P)(T)}function ot(T){return t.enter("lineEnding"),t.consume(T),t.exit("lineEnding"),nt}function nt(T){return T===null||St(T)?bt(T):(t.enter("htmlFlowData"),$(T))}function H(T){return T===45?(t.consume(T),C):$(T)}function et(T){return T===47?(t.consume(T),c="",ft):$(T)}function ft(T){if(T===62){const ut=c.toLowerCase();return Jm.includes(ut)?(t.consume(T),M):$(T)}return Be(T)&&c.length<8?(t.consume(T),c+=String.fromCharCode(T),ft):$(T)}function Tt(T){return T===93?(t.consume(T),C):$(T)}function C(T){return T===62?(t.consume(T),M):T===45&&s===2?(t.consume(T),C):$(T)}function M(T){return T===null||St(T)?(t.exit("htmlFlowData"),P(T)):(t.consume(T),M)}function P(T){return t.exit("htmlFlow"),n(T)}}function PE(t,n,a){const i=this;return s;function s(c){return St(c)?(t.enter("lineEnding"),t.consume(c),t.exit("lineEnding"),o):a(c)}function o(c){return i.parser.lazy[i.now().line]?a(c):n(c)}}function XE(t,n,a){return i;function i(s){return t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),t.attempt(Xi,n,a)}}const QE={name:"htmlText",tokenize:ZE};function ZE(t,n,a){const i=this;let s,o,c;return d;function d(C){return t.enter("htmlText"),t.enter("htmlTextData"),t.consume(C),h}function h(C){return C===33?(t.consume(C),m):C===47?(t.consume(C),lt):C===63?(t.consume(C),I):Be(C)?(t.consume(C),st):a(C)}function m(C){return C===45?(t.consume(C),y):C===91?(t.consume(C),o=0,w):Be(C)?(t.consume(C),q):a(C)}function y(C){return C===45?(t.consume(C),x):a(C)}function g(C){return C===null?a(C):C===45?(t.consume(C),v):St(C)?(c=g,et(C)):(t.consume(C),g)}function v(C){return C===45?(t.consume(C),x):g(C)}function x(C){return C===62?H(C):C===45?v(C):g(C)}function w(C){const M="CDATA[";return C===M.charCodeAt(o++)?(t.consume(C),o===M.length?z:w):a(C)}function z(C){return C===null?a(C):C===93?(t.consume(C),D):St(C)?(c=z,et(C)):(t.consume(C),z)}function D(C){return C===93?(t.consume(C),k):z(C)}function k(C){return C===62?H(C):C===93?(t.consume(C),k):z(C)}function q(C){return C===null||C===62?H(C):St(C)?(c=q,et(C)):(t.consume(C),q)}function I(C){return C===null?a(C):C===63?(t.consume(C),at):St(C)?(c=I,et(C)):(t.consume(C),I)}function at(C){return C===62?H(C):I(C)}function lt(C){return Be(C)?(t.consume(C),L):a(C)}function L(C){return C===45||Ne(C)?(t.consume(C),L):J(C)}function J(C){return St(C)?(c=J,et(C)):zt(C)?(t.consume(C),J):H(C)}function st(C){return C===45||Ne(C)?(t.consume(C),st):C===47||C===62||$t(C)?ct(C):a(C)}function ct(C){return C===47?(t.consume(C),H):C===58||C===95||Be(C)?(t.consume(C),j):St(C)?(c=ct,et(C)):zt(C)?(t.consume(C),ct):H(C)}function j(C){return C===45||C===46||C===58||C===95||Ne(C)?(t.consume(C),j):tt(C)}function tt(C){return C===61?(t.consume(C),$):St(C)?(c=tt,et(C)):zt(C)?(t.consume(C),tt):ct(C)}function $(C){return C===null||C===60||C===61||C===62||C===96?a(C):C===34||C===39?(t.consume(C),s=C,bt):St(C)?(c=$,et(C)):zt(C)?(t.consume(C),$):(t.consume(C),ot)}function bt(C){return C===s?(t.consume(C),s=void 0,nt):C===null?a(C):St(C)?(c=bt,et(C)):(t.consume(C),bt)}function ot(C){return C===null||C===34||C===39||C===60||C===61||C===96?a(C):C===47||C===62||$t(C)?ct(C):(t.consume(C),ot)}function nt(C){return C===47||C===62||$t(C)?ct(C):a(C)}function H(C){return C===62?(t.consume(C),t.exit("htmlTextData"),t.exit("htmlText"),n):a(C)}function et(C){return t.exit("htmlTextData"),t.enter("lineEnding"),t.consume(C),t.exit("lineEnding"),ft}function ft(C){return zt(C)?Ut(t,Tt,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(C):Tt(C)}function Tt(C){return t.enter("htmlTextData"),c(C)}}const tc={name:"labelEnd",resolveAll:WE,resolveTo:tC,tokenize:eC},KE={tokenize:nC},JE={tokenize:rC},$E={tokenize:aC};function WE(t){let n=-1;const a=[];for(;++n<t.length;){const i=t[n][1];if(a.push(t[n]),i.type==="labelImage"||i.type==="labelLink"||i.type==="labelEnd"){const s=i.type==="labelImage"?4:2;i.type="data",n+=s}}return t.length!==a.length&&an(t,0,t.length,a),t}function tC(t,n){let a=t.length,i=0,s,o,c,d;for(;a--;)if(s=t[a][1],o){if(s.type==="link"||s.type==="labelLink"&&s._inactive)break;t[a][0]==="enter"&&s.type==="labelLink"&&(s._inactive=!0)}else if(c){if(t[a][0]==="enter"&&(s.type==="labelImage"||s.type==="labelLink")&&!s._balanced&&(o=a,s.type!=="labelLink")){i=2;break}}else s.type==="labelEnd"&&(c=a);const h={type:t[o][1].type==="labelLink"?"link":"image",start:_({},t[o][1].start),end:_({},t[t.length-1][1].end)},m={type:"label",start:_({},t[o][1].start),end:_({},t[c][1].end)},y={type:"labelText",start:_({},t[o+i+2][1].end),end:_({},t[c-2][1].start)};return d=[["enter",h,n],["enter",m,n]],d=mn(d,t.slice(o+1,o+i+3)),d=mn(d,[["enter",y,n]]),d=mn(d,xs(n.parser.constructs.insideSpan.null,t.slice(o+i+4,c-3),n)),d=mn(d,[["exit",y,n],t[c-2],t[c-1],["exit",m,n]]),d=mn(d,t.slice(c+1)),d=mn(d,[["exit",h,n]]),an(t,o,t.length,d),t}function eC(t,n,a){const i=this;let s=i.events.length,o,c;for(;s--;)if((i.events[s][1].type==="labelImage"||i.events[s][1].type==="labelLink")&&!i.events[s][1]._balanced){o=i.events[s][1];break}return d;function d(v){return o?o._inactive?g(v):(c=i.parser.defined.includes(Dn(i.sliceSerialize({start:o.end,end:i.now()}))),t.enter("labelEnd"),t.enter("labelMarker"),t.consume(v),t.exit("labelMarker"),t.exit("labelEnd"),h):a(v)}function h(v){return v===40?t.attempt(KE,y,c?y:g)(v):v===91?t.attempt(JE,y,c?m:g)(v):c?y(v):g(v)}function m(v){return t.attempt($E,y,g)(v)}function y(v){return n(v)}function g(v){return o._balanced=!0,a(v)}}function nC(t,n,a){return i;function i(g){return t.enter("resource"),t.enter("resourceMarker"),t.consume(g),t.exit("resourceMarker"),s}function s(g){return $t(g)?Zi(t,o)(g):o(g)}function o(g){return g===41?y(g):Qm(t,c,d,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(g)}function c(g){return $t(g)?Zi(t,h)(g):y(g)}function d(g){return a(g)}function h(g){return g===34||g===39||g===40?Km(t,m,a,"resourceTitle","resourceTitleMarker","resourceTitleString")(g):y(g)}function m(g){return $t(g)?Zi(t,y)(g):y(g)}function y(g){return g===41?(t.enter("resourceMarker"),t.consume(g),t.exit("resourceMarker"),t.exit("resource"),n):a(g)}}function rC(t,n,a){const i=this;return s;function s(d){return Zm.call(i,t,o,c,"reference","referenceMarker","referenceString")(d)}function o(d){return i.parser.defined.includes(Dn(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?n(d):a(d)}function c(d){return a(d)}}function aC(t,n,a){return i;function i(o){return t.enter("reference"),t.enter("referenceMarker"),t.consume(o),t.exit("referenceMarker"),s}function s(o){return o===93?(t.enter("referenceMarker"),t.consume(o),t.exit("referenceMarker"),t.exit("reference"),n):a(o)}}const iC={name:"labelStartImage",resolveAll:tc.resolveAll,tokenize:lC};function lC(t,n,a){const i=this;return s;function s(d){return t.enter("labelImage"),t.enter("labelImageMarker"),t.consume(d),t.exit("labelImageMarker"),o}function o(d){return d===91?(t.enter("labelMarker"),t.consume(d),t.exit("labelMarker"),t.exit("labelImage"),c):a(d)}function c(d){return d===94&&"_hiddenFootnoteSupport"in i.parser.constructs?a(d):n(d)}}const sC={name:"labelStartLink",resolveAll:tc.resolveAll,tokenize:uC};function uC(t,n,a){const i=this;return s;function s(c){return t.enter("labelLink"),t.enter("labelMarker"),t.consume(c),t.exit("labelMarker"),t.exit("labelLink"),o}function o(c){return c===94&&"_hiddenFootnoteSupport"in i.parser.constructs?a(c):n(c)}}const ec={name:"lineEnding",tokenize:oC};function oC(t,n){return a;function a(i){return t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),Ut(t,n,"linePrefix")}}const Ss={name:"thematicBreak",tokenize:cC};function cC(t,n,a){let i=0,s;return o;function o(m){return t.enter("thematicBreak"),c(m)}function c(m){return s=m,d(m)}function d(m){return m===s?(t.enter("thematicBreakSequence"),h(m)):i>=3&&(m===null||St(m))?(t.exit("thematicBreak"),n(m)):a(m)}function h(m){return m===s?(t.consume(m),i++,h):(t.exit("thematicBreakSequence"),zt(m)?Ut(t,d,"whitespace")(m):d(m))}}const Fe={continuation:{tokenize:pC},exit:gC,name:"list",tokenize:hC},fC={partial:!0,tokenize:yC},dC={partial:!0,tokenize:mC};function hC(t,n,a){const i=this,s=i.events[i.events.length-1];let o=s&&s[1].type==="linePrefix"?s[2].sliceSerialize(s[1],!0).length:0,c=0;return d;function d(x){const w=i.containerState.type||(x===42||x===43||x===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!i.containerState.marker||x===i.containerState.marker:Jo(x)){if(i.containerState.type||(i.containerState.type=w,t.enter(w,{_container:!0})),w==="listUnordered")return t.enter("listItemPrefix"),x===42||x===45?t.check(Ss,a,m)(x):m(x);if(!i.interrupt||x===49)return t.enter("listItemPrefix"),t.enter("listItemValue"),h(x)}return a(x)}function h(x){return Jo(x)&&++c<10?(t.consume(x),h):(!i.interrupt||c<2)&&(i.containerState.marker?x===i.containerState.marker:x===41||x===46)?(t.exit("listItemValue"),m(x)):a(x)}function m(x){return t.enter("listItemMarker"),t.consume(x),t.exit("listItemMarker"),i.containerState.marker=i.containerState.marker||x,t.check(Xi,i.interrupt?a:y,t.attempt(fC,v,g))}function y(x){return i.containerState.initialBlankLine=!0,o++,v(x)}function g(x){return zt(x)?(t.enter("listItemPrefixWhitespace"),t.consume(x),t.exit("listItemPrefixWhitespace"),v):a(x)}function v(x){return i.containerState.size=o+i.sliceSerialize(t.exit("listItemPrefix"),!0).length,n(x)}}function pC(t,n,a){const i=this;return i.containerState._closeFlow=void 0,t.check(Xi,s,o);function s(d){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,Ut(t,n,"listItemIndent",i.containerState.size+1)(d)}function o(d){return i.containerState.furtherBlankLines||!zt(d)?(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,c(d)):(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,t.attempt(dC,n,c)(d))}function c(d){return i.containerState._closeFlow=!0,i.interrupt=void 0,Ut(t,t.attempt(Fe,n,a),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(d)}}function mC(t,n,a){const i=this;return Ut(t,s,"listItemIndent",i.containerState.size+1);function s(o){const c=i.events[i.events.length-1];return c&&c[1].type==="listItemIndent"&&c[2].sliceSerialize(c[1],!0).length===i.containerState.size?n(o):a(o)}}function gC(t){t.exit(this.containerState.type)}function yC(t,n,a){const i=this;return Ut(t,s,"listItemPrefixWhitespace",i.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function s(o){const c=i.events[i.events.length-1];return!zt(o)&&c&&c[1].type==="listItemPrefixWhitespace"?n(o):a(o)}}const $m={name:"setextUnderline",resolveTo:bC,tokenize:vC};function bC(t,n){let a=t.length,i,s,o;for(;a--;)if(t[a][0]==="enter"){if(t[a][1].type==="content"){i=a;break}t[a][1].type==="paragraph"&&(s=a)}else t[a][1].type==="content"&&t.splice(a,1),!o&&t[a][1].type==="definition"&&(o=a);const c={type:"setextHeading",start:_({},t[i][1].start),end:_({},t[t.length-1][1].end)};return t[s][1].type="setextHeadingText",o?(t.splice(s,0,["enter",c,n]),t.splice(o+1,0,["exit",t[i][1],n]),t[i][1].end=_({},t[o][1].end)):t[i][1]=c,t.push(["exit",c,n]),t}function vC(t,n,a){const i=this;let s;return o;function o(m){let y=i.events.length,g;for(;y--;)if(i.events[y][1].type!=="lineEnding"&&i.events[y][1].type!=="linePrefix"&&i.events[y][1].type!=="content"){g=i.events[y][1].type==="paragraph";break}return!i.parser.lazy[i.now().line]&&(i.interrupt||g)?(t.enter("setextHeadingLine"),s=m,c(m)):a(m)}function c(m){return t.enter("setextHeadingLineSequence"),d(m)}function d(m){return m===s?(t.consume(m),d):(t.exit("setextHeadingLineSequence"),zt(m)?Ut(t,h,"lineSuffix")(m):h(m))}function h(m){return m===null||St(m)?(t.exit("setextHeadingLine"),n(m)):a(m)}}const xC={tokenize:SC};function SC(t){const n=this,a=t.attempt(Xi,i,t.attempt(this.parser.constructs.flowInitial,s,Ut(t,t.attempt(this.parser.constructs.flow,s,t.attempt(CE,s)),"linePrefix")));return a;function i(o){if(o===null){t.consume(o);return}return t.enter("lineEndingBlank"),t.consume(o),t.exit("lineEndingBlank"),n.currentConstruct=void 0,a}function s(o){if(o===null){t.consume(o);return}return t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),n.currentConstruct=void 0,a}}const wC={resolveAll:tg()},_C=Wm("string"),TC=Wm("text");function Wm(t){return{resolveAll:tg(t==="text"?EC:void 0),tokenize:n};function n(a){const i=this,s=this.parser.constructs[t],o=a.attempt(s,c,d);return c;function c(y){return m(y)?o(y):d(y)}function d(y){if(y===null){a.consume(y);return}return a.enter("data"),a.consume(y),h}function h(y){return m(y)?(a.exit("data"),o(y)):(a.consume(y),h)}function m(y){if(y===null)return!0;const g=s[y];let v=-1;if(g)for(;++v<g.length;){const x=g[v];if(!x.previous||x.previous.call(i,i.previous))return!0}return!1}}}function tg(t){return n;function n(a,i){let s=-1,o;for(;++s<=a.length;)o===void 0?a[s]&&a[s][1].type==="data"&&(o=s,s++):(!a[s]||a[s][1].type!=="data")&&(s!==o+2&&(a[o][1].end=a[s-1][1].end,a.splice(o+2,s-o-2),s=o+2),o=void 0);return t?t(a,i):a}}function EC(t,n){let a=0;for(;++a<=t.length;)if((a===t.length||t[a][1].type==="lineEnding")&&t[a-1][1].type==="data"){const i=t[a-1][1],s=n.sliceStream(i);let o=s.length,c=-1,d=0,h;for(;o--;){const m=s[o];if(typeof m=="string"){for(c=m.length;m.charCodeAt(c-1)===32;)d++,c--;if(c)break;c=-1}else if(m===-2)h=!0,d++;else if(m!==-1){o++;break}}if(n._contentTypeTextTrailing&&a===t.length&&(d=0),d){const m={type:a===t.length||h||d<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?c:i.start._bufferIndex+c,_index:i.start._index+o,line:i.end.line,column:i.end.column-d,offset:i.end.offset-d},end:_({},i.end)};i.end=_({},m.start),i.start.offset===i.end.offset?Object.assign(i,m):(t.splice(a,0,["enter",m,n],["exit",m,n]),a+=2)}a++}return t}const CC=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:{null:[42,95]},contentInitial:{91:zE},disable:{null:[]},document:{42:Fe,43:Fe,45:Fe,48:Fe,49:Fe,50:Fe,51:Fe,52:Fe,53:Fe,54:Fe,55:Fe,56:Fe,57:Fe,62:Vm},flow:{35:LE,42:Ss,45:[$m,Ss],60:qE,61:$m,95:Ss,96:Pm,126:Pm},flowInitial:{[-2]:Wo,[-1]:Wo,32:Wo},insideSpan:{null:[$o,wC]},string:{38:Fm,92:Ym},text:{[-5]:ec,[-4]:ec,[-3]:ec,33:iC,38:Fm,42:$o,60:[sE,QE],91:sC,92:[IE,Ym],93:tc,95:$o,96:xE}},Symbol.toStringTag,{value:"Module"}));function AC(t,n,a){let i={_bufferIndex:-1,_index:0,line:a&&a.line||1,column:a&&a.column||1,offset:a&&a.offset||0};const s={},o=[];let c=[],d=[];const h={attempt:J(lt),check:J(L),consume:q,enter:I,exit:at,interrupt:J(L,{interrupt:!0})},m={code:null,containerState:{},defineSkip:z,events:[],now:w,parser:t,previous:null,sliceSerialize:v,sliceStream:x,write:g};let y=n.tokenize.call(m,h);return n.resolveAll&&o.push(n),m;function g(tt){return c=mn(c,tt),D(),c[c.length-1]!==null?[]:(st(n,0),m.events=xs(o,m.events,m),m.events)}function v(tt,$){return RC(x(tt),$)}function x(tt){return kC(c,tt)}function w(){const{_bufferIndex:tt,_index:$,line:bt,column:ot,offset:nt}=i;return{_bufferIndex:tt,_index:$,line:bt,column:ot,offset:nt}}function z(tt){s[tt.line]=tt.column,j()}function D(){let tt;for(;i._index<c.length;){const $=c[i._index];if(typeof $=="string")for(tt=i._index,i._bufferIndex<0&&(i._bufferIndex=0);i._index===tt&&i._bufferIndex<$.length;)k($.charCodeAt(i._bufferIndex));else k($)}}function k(tt){y=y(tt)}function q(tt){St(tt)?(i.line++,i.column=1,i.offset+=tt===-3?2:1,j()):tt!==-1&&(i.column++,i.offset++),i._bufferIndex<0?i._index++:(i._bufferIndex++,i._bufferIndex===c[i._index].length&&(i._bufferIndex=-1,i._index++)),m.previous=tt}function I(tt,$){const bt=$||{};return bt.type=tt,bt.start=w(),m.events.push(["enter",bt,m]),d.push(bt),bt}function at(tt){const $=d.pop();return $.end=w(),m.events.push(["exit",$,m]),$}function lt(tt,$){st(tt,$.from)}function L(tt,$){$.restore()}function J(tt,$){return bt;function bt(ot,nt,H){let et,ft,Tt,C;return Array.isArray(ot)?P(ot):"tokenize"in ot?P([ot]):M(ot);function M(mt){return Ot;function Ot(_t){const Ht=_t!==null&&mt[_t],re=_t!==null&&mt.null,yn=[...Array.isArray(Ht)?Ht:Ht?[Ht]:[],...Array.isArray(re)?re:re?[re]:[]];return P(yn)(_t)}}function P(mt){return et=mt,ft=0,mt.length===0?H:T(mt[ft])}function T(mt){return Ot;function Ot(_t){return C=ct(),Tt=mt,mt.partial||(m.currentConstruct=mt),mt.name&&m.parser.constructs.disable.null.includes(mt.name)?vt():mt.tokenize.call($?Object.assign(Object.create(m),$):m,h,ut,vt)(_t)}}function ut(mt){return tt(Tt,C),nt}function vt(mt){return C.restore(),++ft<et.length?T(et[ft]):H}}}function st(tt,$){tt.resolveAll&&!o.includes(tt)&&o.push(tt),tt.resolve&&an(m.events,$,m.events.length-$,tt.resolve(m.events.slice($),m)),tt.resolveTo&&(m.events=tt.resolveTo(m.events,m))}function ct(){const tt=w(),$=m.previous,bt=m.currentConstruct,ot=m.events.length,nt=Array.from(d);return{from:ot,restore:H};function H(){i=tt,m.previous=$,m.currentConstruct=bt,m.events.length=ot,d=nt,j()}}function j(){i.line in s&&i.column<2&&(i.column=s[i.line],i.offset+=s[i.line]-1)}}function kC(t,n){const a=n.start._index,i=n.start._bufferIndex,s=n.end._index,o=n.end._bufferIndex;let c;if(a===s)c=[t[a].slice(i,o)];else{if(c=t.slice(a,s),i>-1){const d=c[0];typeof d=="string"?c[0]=d.slice(i):c.shift()}o>0&&c.push(t[s].slice(0,o))}return c}function RC(t,n){let a=-1;const i=[];let s;for(;++a<t.length;){const o=t[a];let c;if(typeof o=="string")c=o;else switch(o){case-5:{c="\r";break}case-4:{c=`
17
- `;break}case-3:{c=`\r
18
- `;break}case-2:{c=n?" ":" ";break}case-1:{if(!n&&s)continue;c=" ";break}default:c=String.fromCharCode(o)}s=o===-2,i.push(c)}return i.join("")}function MC(t){const i={constructs:Bm([CC,...(t||{}).extensions||[]]),content:s(tE),defined:[],document:s(nE),flow:s(xC),lazy:{},string:s(_C),text:s(TC)};return i;function s(o){return c;function c(d){return AC(i,o,d)}}}function zC(t){for(;!Xm(t););return t}const eg=/[\0\t\n\r]/g;function OC(){let t=1,n="",a=!0,i;return s;function s(o,c,d){const h=[];let m,y,g,v,x;for(o=n+(typeof o=="string"?o.toString():new TextDecoder(c||void 0).decode(o)),g=0,n="",a&&(o.charCodeAt(0)===65279&&g++,a=void 0);g<o.length;){if(eg.lastIndex=g,m=eg.exec(o),v=m&&m.index!==void 0?m.index:o.length,x=o.charCodeAt(v),!m){n=o.slice(g);break}if(x===10&&g===v&&i)h.push(-3),i=void 0;else switch(i&&(h.push(-5),i=void 0),g<v&&(h.push(o.slice(g,v)),t+=v-g),x){case 0:{h.push(65533),t++;break}case 9:{for(y=Math.ceil(t/4)*4,h.push(-2);t++<y;)h.push(-1);break}case 10:{h.push(-4),t=1;break}default:i=!0,t=1}g=v+1}return d&&(i&&h.push(-5),n&&h.push(n),h.push(null)),h}}const DC=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function NC(t){return t.replace(DC,IC)}function IC(t,n,a){if(n)return n;if(a.charCodeAt(0)===35){const s=a.charCodeAt(1),o=s===120||s===88;return Um(a.slice(o?2:1),o?16:10)}return Ko(a)||t}const ng={}.hasOwnProperty;function jC(t,n,a){return typeof n!="string"&&(a=n,n=void 0),LC(a)(zC(MC(a).document().write(OC()(t,n,!0))))}function LC(t){const n={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(Va),autolinkProtocol:ct,autolinkEmail:ct,atxHeading:o(Ha),blockQuote:o(re),characterEscape:ct,characterReference:ct,codeFenced:o(yn),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:o(yn,c),codeText:o(xr,c),codeTextData:ct,data:ct,codeFlowValue:ct,definition:o(ea),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:o(Kn),hardBreakEscape:o(qa),hardBreakTrailing:o(qa),htmlFlow:o(Ds,c),htmlFlowData:ct,htmlText:o(Ds,c),htmlTextData:ct,image:o(Ns),label:c,link:o(Va),listItem:o(al),listItemValue:v,listOrdered:o(Ya,g),listUnordered:o(Ya),paragraph:o(Nc),reference:T,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:o(Ha),strong:o(Ic),thematicBreak:o(jc)},exit:{atxHeading:h(),atxHeadingSequence:lt,autolink:h(),autolinkEmail:Ht,autolinkProtocol:_t,blockQuote:h(),characterEscapeValue:j,characterReferenceMarkerHexadecimal:vt,characterReferenceMarkerNumeric:vt,characterReferenceValue:mt,characterReference:Ot,codeFenced:h(D),codeFencedFence:z,codeFencedFenceInfo:x,codeFencedFenceMeta:w,codeFlowValue:j,codeIndented:h(k),codeText:h(nt),codeTextData:j,data:j,definition:h(),definitionDestinationString:at,definitionLabelString:q,definitionTitleString:I,emphasis:h(),hardBreakEscape:h($),hardBreakTrailing:h($),htmlFlow:h(bt),htmlFlowData:j,htmlText:h(ot),htmlTextData:j,image:h(et),label:Tt,labelText:ft,lineEnding:tt,link:h(H),listItem:h(),listOrdered:h(),listUnordered:h(),paragraph:h(),referenceString:ut,resourceDestinationString:C,resourceTitleString:M,resource:P,setextHeading:h(st),setextHeadingLineSequence:J,setextHeadingText:L,strong:h(),thematicBreak:h()}};rg(n,(t||{}).mdastExtensions||[]);const a={};return i;function i(Q){let it={type:"root",children:[]};const Et={stack:[it],tokenStack:[],config:n,enter:d,exit:m,buffer:c,resume:y,data:a},Dt=[];let Ft=-1;for(;++Ft<Q.length;)if(Q[Ft][1].type==="listOrdered"||Q[Ft][1].type==="listUnordered")if(Q[Ft][0]==="enter")Dt.push(Ft);else{const ln=Dt.pop();Ft=s(Q,ln,Ft)}for(Ft=-1;++Ft<Q.length;){const ln=n[Q[Ft][0]];ng.call(ln,Q[Ft][1].type)&&ln[Q[Ft][1].type].call(Object.assign({sliceSerialize:Q[Ft][2].sliceSerialize},Et),Q[Ft][1])}if(Et.tokenStack.length>0){const ln=Et.tokenStack[Et.tokenStack.length-1];(ln[1]||ag).call(Et,void 0,ln[0])}for(it.position={start:vr(Q.length>0?Q[0][1].start:{line:1,column:1,offset:0}),end:vr(Q.length>0?Q[Q.length-2][1].end:{line:1,column:1,offset:0})},Ft=-1;++Ft<n.transforms.length;)it=n.transforms[Ft](it)||it;return it}function s(Q,it,Et){let Dt=it-1,Ft=-1,ln=!1,Jn,qe,Se,Ge;for(;++Dt<=Et;){const Wt=Q[Dt];switch(Wt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Wt[0]==="enter"?Ft++:Ft--,Ge=void 0;break}case"lineEndingBlank":{Wt[0]==="enter"&&(Jn&&!Ge&&!Ft&&!Se&&(Se=Dt),Ge=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Ge=void 0}if(!Ft&&Wt[0]==="enter"&&Wt[1].type==="listItemPrefix"||Ft===-1&&Wt[0]==="exit"&&(Wt[1].type==="listUnordered"||Wt[1].type==="listOrdered")){if(Jn){let Sr=Dt;for(qe=void 0;Sr--;){const In=Q[Sr];if(In[1].type==="lineEnding"||In[1].type==="lineEndingBlank"){if(In[0]==="exit")continue;qe&&(Q[qe][1].type="lineEndingBlank",ln=!0),In[1].type="lineEnding",qe=Sr}else if(!(In[1].type==="linePrefix"||In[1].type==="blockQuotePrefix"||In[1].type==="blockQuotePrefixWhitespace"||In[1].type==="blockQuoteMarker"||In[1].type==="listItemIndent"))break}Se&&(!qe||Se<qe)&&(Jn._spread=!0),Jn.end=Object.assign({},qe?Q[qe][1].start:Wt[1].end),Q.splice(qe||Dt,0,["exit",Jn,Wt[2]]),Dt++,Et++}if(Wt[1].type==="listItemPrefix"){const Sr={type:"listItem",_spread:!1,start:Object.assign({},Wt[1].start),end:void 0};Jn=Sr,Q.splice(Dt,0,["enter",Sr,Wt[2]]),Dt++,Et++,Se=void 0,Ge=!0}}}return Q[it][1]._spread=ln,Et}function o(Q,it){return Et;function Et(Dt){d.call(this,Q(Dt),Dt),it&&it.call(this,Dt)}}function c(){this.stack.push({type:"fragment",children:[]})}function d(Q,it,Et){this.stack[this.stack.length-1].children.push(Q),this.stack.push(Q),this.tokenStack.push([it,Et||void 0]),Q.position={start:vr(it.start),end:void 0}}function h(Q){return it;function it(Et){Q&&Q.call(this,Et),m.call(this,Et)}}function m(Q,it){const Et=this.stack.pop(),Dt=this.tokenStack.pop();if(Dt)Dt[0].type!==Q.type&&(it?it.call(this,Q,Dt[0]):(Dt[1]||ag).call(this,Q,Dt[0]));else throw new Error("Cannot close `"+Q.type+"` ("+Gi({start:Q.start,end:Q.end})+"): it’s not open");Et.position.end=vr(Q.end)}function y(){return Zo(this.stack.pop())}function g(){this.data.expectingFirstListItemValue=!0}function v(Q){if(this.data.expectingFirstListItemValue){const it=this.stack[this.stack.length-2];it.start=Number.parseInt(this.sliceSerialize(Q),10),this.data.expectingFirstListItemValue=void 0}}function x(){const Q=this.resume(),it=this.stack[this.stack.length-1];it.lang=Q}function w(){const Q=this.resume(),it=this.stack[this.stack.length-1];it.meta=Q}function z(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function D(){const Q=this.resume(),it=this.stack[this.stack.length-1];it.value=Q.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function k(){const Q=this.resume(),it=this.stack[this.stack.length-1];it.value=Q.replace(/(\r?\n|\r)$/g,"")}function q(Q){const it=this.resume(),Et=this.stack[this.stack.length-1];Et.label=it,Et.identifier=Dn(this.sliceSerialize(Q)).toLowerCase()}function I(){const Q=this.resume(),it=this.stack[this.stack.length-1];it.title=Q}function at(){const Q=this.resume(),it=this.stack[this.stack.length-1];it.url=Q}function lt(Q){const it=this.stack[this.stack.length-1];if(!it.depth){const Et=this.sliceSerialize(Q).length;it.depth=Et}}function L(){this.data.setextHeadingSlurpLineEnding=!0}function J(Q){const it=this.stack[this.stack.length-1];it.depth=this.sliceSerialize(Q).codePointAt(0)===61?1:2}function st(){this.data.setextHeadingSlurpLineEnding=void 0}function ct(Q){const Et=this.stack[this.stack.length-1].children;let Dt=Et[Et.length-1];(!Dt||Dt.type!=="text")&&(Dt=He(),Dt.position={start:vr(Q.start),end:void 0},Et.push(Dt)),this.stack.push(Dt)}function j(Q){const it=this.stack.pop();it.value+=this.sliceSerialize(Q),it.position.end=vr(Q.end)}function tt(Q){const it=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Et=it.children[it.children.length-1];Et.position.end=vr(Q.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&n.canContainEols.includes(it.type)&&(ct.call(this,Q),j.call(this,Q))}function $(){this.data.atHardBreak=!0}function bt(){const Q=this.resume(),it=this.stack[this.stack.length-1];it.value=Q}function ot(){const Q=this.resume(),it=this.stack[this.stack.length-1];it.value=Q}function nt(){const Q=this.resume(),it=this.stack[this.stack.length-1];it.value=Q}function H(){const Q=this.stack[this.stack.length-1];if(this.data.inReference){const it=this.data.referenceType||"shortcut";Q.type+="Reference",Q.referenceType=it,delete Q.url,delete Q.title}else delete Q.identifier,delete Q.label;this.data.referenceType=void 0}function et(){const Q=this.stack[this.stack.length-1];if(this.data.inReference){const it=this.data.referenceType||"shortcut";Q.type+="Reference",Q.referenceType=it,delete Q.url,delete Q.title}else delete Q.identifier,delete Q.label;this.data.referenceType=void 0}function ft(Q){const it=this.sliceSerialize(Q),Et=this.stack[this.stack.length-2];Et.label=NC(it),Et.identifier=Dn(it).toLowerCase()}function Tt(){const Q=this.stack[this.stack.length-1],it=this.resume(),Et=this.stack[this.stack.length-1];if(this.data.inReference=!0,Et.type==="link"){const Dt=Q.children;Et.children=Dt}else Et.alt=it}function C(){const Q=this.resume(),it=this.stack[this.stack.length-1];it.url=Q}function M(){const Q=this.resume(),it=this.stack[this.stack.length-1];it.title=Q}function P(){this.data.inReference=void 0}function T(){this.data.referenceType="collapsed"}function ut(Q){const it=this.resume(),Et=this.stack[this.stack.length-1];Et.label=it,Et.identifier=Dn(this.sliceSerialize(Q)).toLowerCase(),this.data.referenceType="full"}function vt(Q){this.data.characterReferenceType=Q.type}function mt(Q){const it=this.sliceSerialize(Q),Et=this.data.characterReferenceType;let Dt;Et?(Dt=Um(it,Et==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Dt=Ko(it);const Ft=this.stack[this.stack.length-1];Ft.value+=Dt}function Ot(Q){const it=this.stack.pop();it.position.end=vr(Q.end)}function _t(Q){j.call(this,Q);const it=this.stack[this.stack.length-1];it.url=this.sliceSerialize(Q)}function Ht(Q){j.call(this,Q);const it=this.stack[this.stack.length-1];it.url="mailto:"+this.sliceSerialize(Q)}function re(){return{type:"blockquote",children:[]}}function yn(){return{type:"code",lang:null,meta:null,value:""}}function xr(){return{type:"inlineCode",value:""}}function ea(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Kn(){return{type:"emphasis",children:[]}}function Ha(){return{type:"heading",depth:0,children:[]}}function qa(){return{type:"break"}}function Ds(){return{type:"html",value:""}}function Ns(){return{type:"image",title:null,url:"",alt:null}}function Va(){return{type:"link",title:null,url:"",children:[]}}function Ya(Q){return{type:"list",ordered:Q.type==="listOrdered",start:null,spread:Q._spread,children:[]}}function al(Q){return{type:"listItem",spread:Q._spread,checked:null,children:[]}}function Nc(){return{type:"paragraph",children:[]}}function Ic(){return{type:"strong",children:[]}}function He(){return{type:"text",value:""}}function jc(){return{type:"thematicBreak"}}}function vr(t){return{line:t.line,column:t.column,offset:t.offset}}function rg(t,n){let a=-1;for(;++a<n.length;){const i=n[a];Array.isArray(i)?rg(t,i):BC(t,i)}}function BC(t,n){let a;for(a in n)if(ng.call(n,a))switch(a){case"canContainEols":{const i=n[a];i&&t[a].push(...i);break}case"transforms":{const i=n[a];i&&t[a].push(...i);break}case"enter":case"exit":{const i=n[a];i&&Object.assign(t[a],i);break}}}function ag(t,n){throw t?new Error("Cannot close `"+t.type+"` ("+Gi({start:t.start,end:t.end})+"): a different token (`"+n.type+"`, "+Gi({start:n.start,end:n.end})+") is open"):new Error("Cannot close document, a token (`"+n.type+"`, "+Gi({start:n.start,end:n.end})+") is still open")}function UC(t){const n=this;n.parser=a;function a(i){return jC(i,G(_(_({},n.data("settings")),t),{extensions:n.data("micromarkExtensions")||[],mdastExtensions:n.data("fromMarkdownExtensions")||[]}))}}function HC(t,n){const a={type:"element",tagName:"blockquote",properties:{},children:t.wrap(t.all(n),!0)};return t.patch(n,a),t.applyData(n,a)}function qC(t,n){const a={type:"element",tagName:"br",properties:{},children:[]};return t.patch(n,a),[t.applyData(n,a),{type:"text",value:`
19
- `}]}function VC(t,n){const a=n.value?n.value+`
20
- `:"",i={},s=n.lang?n.lang.split(/\s+/):[];s.length>0&&(i.className=["language-"+s[0]]);let o={type:"element",tagName:"code",properties:i,children:[{type:"text",value:a}]};return n.meta&&(o.data={meta:n.meta}),t.patch(n,o),o=t.applyData(n,o),o={type:"element",tagName:"pre",properties:{},children:[o]},t.patch(n,o),o}function YC(t,n){const a={type:"element",tagName:"del",properties:{},children:t.all(n)};return t.patch(n,a),t.applyData(n,a)}function FC(t,n){const a={type:"element",tagName:"em",properties:{},children:t.all(n)};return t.patch(n,a),t.applyData(n,a)}function GC(t,n){const a=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",i=String(n.identifier).toUpperCase(),s=ja(i.toLowerCase()),o=t.footnoteOrder.indexOf(i);let c,d=t.footnoteCounts.get(i);d===void 0?(d=0,t.footnoteOrder.push(i),c=t.footnoteOrder.length):c=o+1,d+=1,t.footnoteCounts.set(i,d);const h={type:"element",tagName:"a",properties:{href:"#"+a+"fn-"+s,id:a+"fnref-"+s+(d>1?"-"+d:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(c)}]};t.patch(n,h);const m={type:"element",tagName:"sup",properties:{},children:[h]};return t.patch(n,m),t.applyData(n,m)}function PC(t,n){const a={type:"element",tagName:"h"+n.depth,properties:{},children:t.all(n)};return t.patch(n,a),t.applyData(n,a)}function XC(t,n){if(t.options.allowDangerousHtml){const a={type:"raw",value:n.value};return t.patch(n,a),t.applyData(n,a)}}function ig(t,n){const a=n.referenceType;let i="]";if(a==="collapsed"?i+="[]":a==="full"&&(i+="["+(n.label||n.identifier)+"]"),n.type==="imageReference")return[{type:"text",value:"!["+n.alt+i}];const s=t.all(n),o=s[0];o&&o.type==="text"?o.value="["+o.value:s.unshift({type:"text",value:"["});const c=s[s.length-1];return c&&c.type==="text"?c.value+=i:s.push({type:"text",value:i}),s}function QC(t,n){const a=String(n.identifier).toUpperCase(),i=t.definitionById.get(a);if(!i)return ig(t,n);const s={src:ja(i.url||""),alt:n.alt};i.title!==null&&i.title!==void 0&&(s.title=i.title);const o={type:"element",tagName:"img",properties:s,children:[]};return t.patch(n,o),t.applyData(n,o)}function ZC(t,n){const a={src:ja(n.url)};n.alt!==null&&n.alt!==void 0&&(a.alt=n.alt),n.title!==null&&n.title!==void 0&&(a.title=n.title);const i={type:"element",tagName:"img",properties:a,children:[]};return t.patch(n,i),t.applyData(n,i)}function KC(t,n){const a={type:"text",value:n.value.replace(/\r?\n|\r/g," ")};t.patch(n,a);const i={type:"element",tagName:"code",properties:{},children:[a]};return t.patch(n,i),t.applyData(n,i)}function JC(t,n){const a=String(n.identifier).toUpperCase(),i=t.definitionById.get(a);if(!i)return ig(t,n);const s={href:ja(i.url||"")};i.title!==null&&i.title!==void 0&&(s.title=i.title);const o={type:"element",tagName:"a",properties:s,children:t.all(n)};return t.patch(n,o),t.applyData(n,o)}function $C(t,n){const a={href:ja(n.url)};n.title!==null&&n.title!==void 0&&(a.title=n.title);const i={type:"element",tagName:"a",properties:a,children:t.all(n)};return t.patch(n,i),t.applyData(n,i)}function WC(t,n,a){const i=t.all(n),s=a?tA(a):lg(n),o={},c=[];if(typeof n.checked=="boolean"){const y=i[0];let g;y&&y.type==="element"&&y.tagName==="p"?g=y:(g={type:"element",tagName:"p",properties:{},children:[]},i.unshift(g)),g.children.length>0&&g.children.unshift({type:"text",value:" "}),g.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:n.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let d=-1;for(;++d<i.length;){const y=i[d];(s||d!==0||y.type!=="element"||y.tagName!=="p")&&c.push({type:"text",value:`
21
- `}),y.type==="element"&&y.tagName==="p"&&!s?c.push(...y.children):c.push(y)}const h=i[i.length-1];h&&(s||h.type!=="element"||h.tagName!=="p")&&c.push({type:"text",value:`
22
- `});const m={type:"element",tagName:"li",properties:o,children:c};return t.patch(n,m),t.applyData(n,m)}function tA(t){let n=!1;if(t.type==="list"){n=t.spread||!1;const a=t.children;let i=-1;for(;!n&&++i<a.length;)n=lg(a[i])}return n}function lg(t){const n=t.spread;return n==null?t.children.length>1:n}function eA(t,n){const a={},i=t.all(n);let s=-1;for(typeof n.start=="number"&&n.start!==1&&(a.start=n.start);++s<i.length;){const c=i[s];if(c.type==="element"&&c.tagName==="li"&&c.properties&&Array.isArray(c.properties.className)&&c.properties.className.includes("task-list-item")){a.className=["contains-task-list"];break}}const o={type:"element",tagName:n.ordered?"ol":"ul",properties:a,children:t.wrap(i,!0)};return t.patch(n,o),t.applyData(n,o)}function nA(t,n){const a={type:"element",tagName:"p",properties:{},children:t.all(n)};return t.patch(n,a),t.applyData(n,a)}function rA(t,n){const a={type:"root",children:t.wrap(t.all(n))};return t.patch(n,a),t.applyData(n,a)}function aA(t,n){const a={type:"element",tagName:"strong",properties:{},children:t.all(n)};return t.patch(n,a),t.applyData(n,a)}function iA(t,n){const a=t.all(n),i=a.shift(),s=[];if(i){const c={type:"element",tagName:"thead",properties:{},children:t.wrap([i],!0)};t.patch(n.children[0],c),s.push(c)}if(a.length>0){const c={type:"element",tagName:"tbody",properties:{},children:t.wrap(a,!0)},d=Yo(n.children[1]),h=Cm(n.children[n.children.length-1]);d&&h&&(c.position={start:d,end:h}),s.push(c)}const o={type:"element",tagName:"table",properties:{},children:t.wrap(s,!0)};return t.patch(n,o),t.applyData(n,o)}function lA(t,n,a){const i=a?a.children:void 0,o=(i?i.indexOf(n):1)===0?"th":"td",c=a&&a.type==="table"?a.align:void 0,d=c?c.length:n.children.length;let h=-1;const m=[];for(;++h<d;){const g=n.children[h],v={},x=c?c[h]:void 0;x&&(v.align=x);let w={type:"element",tagName:o,properties:v,children:[]};g&&(w.children=t.all(g),t.patch(g,w),w=t.applyData(g,w)),m.push(w)}const y={type:"element",tagName:"tr",properties:{},children:t.wrap(m,!0)};return t.patch(n,y),t.applyData(n,y)}function sA(t,n){const a={type:"element",tagName:"td",properties:{},children:t.all(n)};return t.patch(n,a),t.applyData(n,a)}const sg=9,ug=32;function uA(t){const n=String(t),a=/\r?\n|\r/g;let i=a.exec(n),s=0;const o=[];for(;i;)o.push(og(n.slice(s,i.index),s>0,!0),i[0]),s=i.index+i[0].length,i=a.exec(n);return o.push(og(n.slice(s),s>0,!1)),o.join("")}function og(t,n,a){let i=0,s=t.length;if(n){let o=t.codePointAt(i);for(;o===sg||o===ug;)i++,o=t.codePointAt(i)}if(a){let o=t.codePointAt(s-1);for(;o===sg||o===ug;)s--,o=t.codePointAt(s-1)}return s>i?t.slice(i,s):""}function oA(t,n){const a={type:"text",value:uA(String(n.value))};return t.patch(n,a),t.applyData(n,a)}function cA(t,n){const a={type:"element",tagName:"hr",properties:{},children:[]};return t.patch(n,a),t.applyData(n,a)}const fA={blockquote:HC,break:qC,code:VC,delete:YC,emphasis:FC,footnoteReference:GC,heading:PC,html:XC,imageReference:QC,image:ZC,inlineCode:KC,linkReference:JC,link:$C,listItem:WC,list:eA,paragraph:nA,root:rA,strong:aA,table:iA,tableCell:sA,tableRow:lA,text:oA,thematicBreak:cA,toml:ws,yaml:ws,definition:ws,footnoteDefinition:ws};function ws(){}const cg=-1,_s=0,Ki=1,Ts=2,nc=3,rc=4,ac=5,ic=6,fg=7,dg=8,hg=typeof self=="object"?self:globalThis,dA=(t,n)=>{const a=(s,o)=>(t.set(o,s),s),i=s=>{if(t.has(s))return t.get(s);const[o,c]=n[s];switch(o){case _s:case cg:return a(c,s);case Ki:{const d=a([],s);for(const h of c)d.push(i(h));return d}case Ts:{const d=a({},s);for(const[h,m]of c)d[i(h)]=i(m);return d}case nc:return a(new Date(c),s);case rc:{const{source:d,flags:h}=c;return a(new RegExp(d,h),s)}case ac:{const d=a(new Map,s);for(const[h,m]of c)d.set(i(h),i(m));return d}case ic:{const d=a(new Set,s);for(const h of c)d.add(i(h));return d}case fg:{const{name:d,message:h}=c;return a(new hg[d](h),s)}case dg:return a(BigInt(c),s);case"BigInt":return a(Object(BigInt(c)),s);case"ArrayBuffer":return a(new Uint8Array(c).buffer,c);case"DataView":{const{buffer:d}=new Uint8Array(c);return a(new DataView(d),c)}}return a(new hg[o](c),s)};return i},pg=t=>dA(new Map,t)(0),Ba="",{toString:hA}={},{keys:pA}=Object,Ji=t=>{const n=typeof t;if(n!=="object"||!t)return[_s,n];const a=hA.call(t).slice(8,-1);switch(a){case"Array":return[Ki,Ba];case"Object":return[Ts,Ba];case"Date":return[nc,Ba];case"RegExp":return[rc,Ba];case"Map":return[ac,Ba];case"Set":return[ic,Ba];case"DataView":return[Ki,a]}return a.includes("Array")?[Ki,a]:a.includes("Error")?[fg,a]:[Ts,a]},Es=([t,n])=>t===_s&&(n==="function"||n==="symbol"),mA=(t,n,a,i)=>{const s=(c,d)=>{const h=i.push(c)-1;return a.set(d,h),h},o=c=>{if(a.has(c))return a.get(c);let[d,h]=Ji(c);switch(d){case _s:{let y=c;switch(h){case"bigint":d=dg,y=c.toString();break;case"function":case"symbol":if(t)throw new TypeError("unable to serialize "+h);y=null;break;case"undefined":return s([cg],c)}return s([d,y],c)}case Ki:{if(h){let v=c;return h==="DataView"?v=new Uint8Array(c.buffer):h==="ArrayBuffer"&&(v=new Uint8Array(c)),s([h,[...v]],c)}const y=[],g=s([d,y],c);for(const v of c)y.push(o(v));return g}case Ts:{if(h)switch(h){case"BigInt":return s([h,c.toString()],c);case"Boolean":case"Number":case"String":return s([h,c.valueOf()],c)}if(n&&"toJSON"in c)return o(c.toJSON());const y=[],g=s([d,y],c);for(const v of pA(c))(t||!Es(Ji(c[v])))&&y.push([o(v),o(c[v])]);return g}case nc:return s([d,c.toISOString()],c);case rc:{const{source:y,flags:g}=c;return s([d,{source:y,flags:g}],c)}case ac:{const y=[],g=s([d,y],c);for(const[v,x]of c)(t||!(Es(Ji(v))||Es(Ji(x))))&&y.push([o(v),o(x)]);return g}case ic:{const y=[],g=s([d,y],c);for(const v of c)(t||!Es(Ji(v)))&&y.push(o(v));return g}}const{message:m}=c;return s([d,{name:h,message:m}],c)};return o},mg=(t,{json:n,lossy:a}={})=>{const i=[];return mA(!(n||a),!!n,new Map,i)(t),i},Cs=typeof structuredClone=="function"?(t,n)=>n&&("json"in n||"lossy"in n)?pg(mg(t,n)):structuredClone(t):(t,n)=>pg(mg(t,n));function gA(t,n){const a=[{type:"text",value:"↩"}];return n>1&&a.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(n)}]}),a}function yA(t,n){return"Back to reference "+(t+1)+(n>1?"-"+n:"")}function bA(t){const n=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",a=t.options.footnoteBackContent||gA,i=t.options.footnoteBackLabel||yA,s=t.options.footnoteLabel||"Footnotes",o=t.options.footnoteLabelTagName||"h2",c=t.options.footnoteLabelProperties||{className:["sr-only"]},d=[];let h=-1;for(;++h<t.footnoteOrder.length;){const m=t.footnoteById.get(t.footnoteOrder[h]);if(!m)continue;const y=t.all(m),g=String(m.identifier).toUpperCase(),v=ja(g.toLowerCase());let x=0;const w=[],z=t.footnoteCounts.get(g);for(;z!==void 0&&++x<=z;){w.length>0&&w.push({type:"text",value:" "});let q=typeof a=="string"?a:a(h,x);typeof q=="string"&&(q={type:"text",value:q}),w.push({type:"element",tagName:"a",properties:{href:"#"+n+"fnref-"+v+(x>1?"-"+x:""),dataFootnoteBackref:"",ariaLabel:typeof i=="string"?i:i(h,x),className:["data-footnote-backref"]},children:Array.isArray(q)?q:[q]})}const D=y[y.length-1];if(D&&D.type==="element"&&D.tagName==="p"){const q=D.children[D.children.length-1];q&&q.type==="text"?q.value+=" ":D.children.push({type:"text",value:" "}),D.children.push(...w)}else y.push(...w);const k={type:"element",tagName:"li",properties:{id:n+"fn-"+v},children:t.wrap(y,!0)};t.patch(m,k),d.push(k)}if(d.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:G(_({},Cs(c)),{id:"footnote-label"}),children:[{type:"text",value:s}]},{type:"text",value:`
23
- `},{type:"element",tagName:"ol",properties:{},children:t.wrap(d,!0)},{type:"text",value:`
24
- `}]}}const As=(function(t){if(t==null)return wA;if(typeof t=="function")return ks(t);if(typeof t=="object")return Array.isArray(t)?vA(t):xA(t);if(typeof t=="string")return SA(t);throw new Error("Expected function, string, or object as test")});function vA(t){const n=[];let a=-1;for(;++a<t.length;)n[a]=As(t[a]);return ks(i);function i(...s){let o=-1;for(;++o<n.length;)if(n[o].apply(this,s))return!0;return!1}}function xA(t){const n=t;return ks(a);function a(i){const s=i;let o;for(o in t)if(s[o]!==n[o])return!1;return!0}}function SA(t){return ks(n);function n(a){return a&&a.type===t}}function ks(t){return n;function n(a,i,s){return!!(_A(a)&&t.call(this,a,typeof i=="number"?i:void 0,s||void 0))}}function wA(){return!0}function _A(t){return t!==null&&typeof t=="object"&&"type"in t}function IO(t){return t}const gg=[],TA=!0,lc=!1,EA="skip";function yg(t,n,a,i){let s;typeof n=="function"&&typeof a!="function"?(i=a,a=n):s=n;const o=As(s),c=i?-1:1;d(t,void 0,[])();function d(h,m,y){const g=h&&typeof h=="object"?h:{};if(typeof g.type=="string"){const x=typeof g.tagName=="string"?g.tagName:typeof g.name=="string"?g.name:void 0;Object.defineProperty(v,"name",{value:"node ("+(h.type+(x?"<"+x+">":""))+")"})}return v;function v(){let x=gg,w,z,D;if((!n||o(h,m,y[y.length-1]||void 0))&&(x=CA(a(h,y)),x[0]===lc))return x;if("children"in h&&h.children){const k=h;if(k.children&&x[0]!==EA)for(z=(i?k.children.length:-1)+c,D=y.concat(k);z>-1&&z<k.children.length;){const q=k.children[z];if(w=d(q,z,D)(),w[0]===lc)return w;z=typeof w[1]=="number"?w[1]:z+c}}return x}}}function CA(t){return Array.isArray(t)?t:typeof t=="number"?[TA,t]:t==null?gg:[t]}function sc(t,n,a,i){let s,o,c;typeof n=="function"&&typeof a!="function"?(o=void 0,c=n,s=a):(o=n,c=a,s=i),yg(t,o,d,s);function d(h,m){const y=m[m.length-1],g=y?y.children.indexOf(h):void 0;return c(h,g,y)}}const uc={}.hasOwnProperty,AA={};function kA(t,n){const a=n||AA,i=new Map,s=new Map,o=new Map,c=_(_({},fA),a.handlers),d={all:m,applyData:MA,definitionById:i,footnoteById:s,footnoteCounts:o,footnoteOrder:[],handlers:c,one:h,options:a,patch:RA,wrap:OA};return sc(t,function(y){if(y.type==="definition"||y.type==="footnoteDefinition"){const g=y.type==="definition"?i:s,v=String(y.identifier).toUpperCase();g.has(v)||g.set(v,y)}}),d;function h(y,g){const v=y.type,x=d.handlers[v];if(uc.call(d.handlers,v)&&x)return x(d,y,g);if(d.options.passThrough&&d.options.passThrough.includes(v)){if("children"in y){const z=y,{children:D}=z,k=gt(z,["children"]),q=Cs(k);return q.children=d.all(y),q}return Cs(y)}return(d.options.unknownHandler||zA)(d,y,g)}function m(y){const g=[];if("children"in y){const v=y.children;let x=-1;for(;++x<v.length;){const w=d.one(v[x],y);if(w){if(x&&v[x-1].type==="break"&&(!Array.isArray(w)&&w.type==="text"&&(w.value=bg(w.value)),!Array.isArray(w)&&w.type==="element")){const z=w.children[0];z&&z.type==="text"&&(z.value=bg(z.value))}Array.isArray(w)?g.push(...w):g.push(w)}}}return g}}function RA(t,n){t.position&&(n.position=CT(t))}function MA(t,n){let a=n;if(t&&t.data){const i=t.data.hName,s=t.data.hChildren,o=t.data.hProperties;if(typeof i=="string")if(a.type==="element")a.tagName=i;else{const c="children"in a?a.children:[a];a={type:"element",tagName:i,properties:{},children:c}}a.type==="element"&&o&&Object.assign(a.properties,Cs(o)),"children"in a&&a.children&&s!==null&&s!==void 0&&(a.children=s)}return a}function zA(t,n){const a=n.data||{},i="value"in n&&!(uc.call(a,"hProperties")||uc.call(a,"hChildren"))?{type:"text",value:n.value}:{type:"element",tagName:"div",properties:{},children:t.all(n)};return t.patch(n,i),t.applyData(n,i)}function OA(t,n){const a=[];let i=-1;for(n&&a.push({type:"text",value:`
25
- `});++i<t.length;)i&&a.push({type:"text",value:`
26
- `}),a.push(t[i]);return n&&t.length>0&&a.push({type:"text",value:`
27
- `}),a}function bg(t){let n=0,a=t.charCodeAt(n);for(;a===9||a===32;)n++,a=t.charCodeAt(n);return t.slice(n)}function vg(t,n){const a=kA(t,n),i=a.one(t,void 0),s=bA(a),o=Array.isArray(i)?{type:"root",children:i}:i||{type:"root",children:[]};return s&&o.children.push({type:"text",value:`
28
- `},s),o}function DA(t,n){return t&&"run"in t?function(a,i){return W(this,null,function*(){const s=vg(a,_({file:i},n));yield t.run(s,i)})}:function(a,i){return vg(a,_({file:i},t||n))}}function xg(t){if(t)throw t}var oc,Sg;function NA(){if(Sg)return oc;Sg=1;var t=Object.prototype.hasOwnProperty,n=Object.prototype.toString,a=Object.defineProperty,i=Object.getOwnPropertyDescriptor,s=function(m){return typeof Array.isArray=="function"?Array.isArray(m):n.call(m)==="[object Array]"},o=function(m){if(!m||n.call(m)!=="[object Object]")return!1;var y=t.call(m,"constructor"),g=m.constructor&&m.constructor.prototype&&t.call(m.constructor.prototype,"isPrototypeOf");if(m.constructor&&!y&&!g)return!1;var v;for(v in m);return typeof v=="undefined"||t.call(m,v)},c=function(m,y){a&&y.name==="__proto__"?a(m,y.name,{enumerable:!0,configurable:!0,value:y.newValue,writable:!0}):m[y.name]=y.newValue},d=function(m,y){if(y==="__proto__")if(t.call(m,y)){if(i)return i(m,y).value}else return;return m[y]};return oc=function h(){var m,y,g,v,x,w,z=arguments[0],D=1,k=arguments.length,q=!1;for(typeof z=="boolean"&&(q=z,z=arguments[1]||{},D=2),(z==null||typeof z!="object"&&typeof z!="function")&&(z={});D<k;++D)if(m=arguments[D],m!=null)for(y in m)g=d(z,y),v=d(m,y),z!==v&&(q&&v&&(o(v)||(x=s(v)))?(x?(x=!1,w=g&&s(g)?g:[]):w=g&&o(g)?g:{},c(z,{name:y,newValue:h(q,w,v)})):typeof v!="undefined"&&c(z,{name:y,newValue:v}));return z},oc}var IA=NA();const cc=Kt(IA);function fc(t){if(typeof t!="object"||t===null)return!1;const n=Object.getPrototypeOf(t);return(n===null||n===Object.prototype||Object.getPrototypeOf(n)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)}function jA(){const t=[],n={run:a,use:i};return n;function a(...s){let o=-1;const c=s.pop();if(typeof c!="function")throw new TypeError("Expected function as last argument, not "+c);d(null,...s);function d(h,...m){const y=t[++o];let g=-1;if(h){c(h);return}for(;++g<s.length;)(m[g]===null||m[g]===void 0)&&(m[g]=s[g]);s=m,y?LA(y,d)(...m):c(null,...m)}}function i(s){if(typeof s!="function")throw new TypeError("Expected `middelware` to be a function, not "+s);return t.push(s),n}}function LA(t,n){let a;return i;function i(...c){const d=t.length>c.length;let h;d&&c.push(s);try{h=t.apply(this,c)}catch(m){const y=m;if(d&&a)throw y;return s(y)}d||(h&&h.then&&typeof h.then=="function"?h.then(o,s):h instanceof Error?s(h):o(h))}function s(c,...d){a||(a=!0,n(c,...d))}function o(c){s(null,c)}}const Hn={basename:BA,dirname:UA,extname:HA,join:qA,sep:"/"};function BA(t,n){if(n!==void 0&&typeof n!="string")throw new TypeError('"ext" argument must be a string');$i(t);let a=0,i=-1,s=t.length,o;if(n===void 0||n.length===0||n.length>t.length){for(;s--;)if(t.codePointAt(s)===47){if(o){a=s+1;break}}else i<0&&(o=!0,i=s+1);return i<0?"":t.slice(a,i)}if(n===t)return"";let c=-1,d=n.length-1;for(;s--;)if(t.codePointAt(s)===47){if(o){a=s+1;break}}else c<0&&(o=!0,c=s+1),d>-1&&(t.codePointAt(s)===n.codePointAt(d--)?d<0&&(i=s):(d=-1,i=c));return a===i?i=c:i<0&&(i=t.length),t.slice(a,i)}function UA(t){if($i(t),t.length===0)return".";let n=-1,a=t.length,i;for(;--a;)if(t.codePointAt(a)===47){if(i){n=a;break}}else i||(i=!0);return n<0?t.codePointAt(0)===47?"/":".":n===1&&t.codePointAt(0)===47?"//":t.slice(0,n)}function HA(t){$i(t);let n=t.length,a=-1,i=0,s=-1,o=0,c;for(;n--;){const d=t.codePointAt(n);if(d===47){if(c){i=n+1;break}continue}a<0&&(c=!0,a=n+1),d===46?s<0?s=n:o!==1&&(o=1):s>-1&&(o=-1)}return s<0||a<0||o===0||o===1&&s===a-1&&s===i+1?"":t.slice(s,a)}function qA(...t){let n=-1,a;for(;++n<t.length;)$i(t[n]),t[n]&&(a=a===void 0?t[n]:a+"/"+t[n]);return a===void 0?".":VA(a)}function VA(t){$i(t);const n=t.codePointAt(0)===47;let a=YA(t,!n);return a.length===0&&!n&&(a="."),a.length>0&&t.codePointAt(t.length-1)===47&&(a+="/"),n?"/"+a:a}function YA(t,n){let a="",i=0,s=-1,o=0,c=-1,d,h;for(;++c<=t.length;){if(c<t.length)d=t.codePointAt(c);else{if(d===47)break;d=47}if(d===47){if(!(s===c-1||o===1))if(s!==c-1&&o===2){if(a.length<2||i!==2||a.codePointAt(a.length-1)!==46||a.codePointAt(a.length-2)!==46){if(a.length>2){if(h=a.lastIndexOf("/"),h!==a.length-1){h<0?(a="",i=0):(a=a.slice(0,h),i=a.length-1-a.lastIndexOf("/")),s=c,o=0;continue}}else if(a.length>0){a="",i=0,s=c,o=0;continue}}n&&(a=a.length>0?a+"/..":"..",i=2)}else a.length>0?a+="/"+t.slice(s+1,c):a=t.slice(s+1,c),i=c-s-1;s=c,o=0}else d===46&&o>-1?o++:o=-1}return a}function $i(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}const FA={cwd:GA};function GA(){return"/"}function dc(t){return!!(t!==null&&typeof t=="object"&&"href"in t&&t.href&&"protocol"in t&&t.protocol&&t.auth===void 0)}function PA(t){if(typeof t=="string")t=new URL(t);else if(!dc(t)){const n=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+t+"`");throw n.code="ERR_INVALID_ARG_TYPE",n}if(t.protocol!=="file:"){const n=new TypeError("The URL must be of scheme file");throw n.code="ERR_INVALID_URL_SCHEME",n}return XA(t)}function XA(t){if(t.hostname!==""){const i=new TypeError('File URL host must be "localhost" or empty on darwin');throw i.code="ERR_INVALID_FILE_URL_HOST",i}const n=t.pathname;let a=-1;for(;++a<n.length;)if(n.codePointAt(a)===37&&n.codePointAt(a+1)===50){const i=n.codePointAt(a+2);if(i===70||i===102){const s=new TypeError("File URL path must not include encoded / characters");throw s.code="ERR_INVALID_FILE_URL_PATH",s}}return decodeURIComponent(n)}const hc=["history","path","basename","stem","extname","dirname"];class wg{constructor(n){let a;n?dc(n)?a={path:n}:typeof n=="string"||QA(n)?a={value:n}:a=n:a={},this.cwd="cwd"in a?"":FA.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let i=-1;for(;++i<hc.length;){const o=hc[i];o in a&&a[o]!==void 0&&a[o]!==null&&(this[o]=o==="history"?[...a[o]]:a[o])}let s;for(s in a)hc.includes(s)||(this[s]=a[s])}get basename(){return typeof this.path=="string"?Hn.basename(this.path):void 0}set basename(n){mc(n,"basename"),pc(n,"basename"),this.path=Hn.join(this.dirname||"",n)}get dirname(){return typeof this.path=="string"?Hn.dirname(this.path):void 0}set dirname(n){_g(this.basename,"dirname"),this.path=Hn.join(n||"",this.basename)}get extname(){return typeof this.path=="string"?Hn.extname(this.path):void 0}set extname(n){if(pc(n,"extname"),_g(this.dirname,"extname"),n){if(n.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(n.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Hn.join(this.dirname,this.stem+(n||""))}get path(){return this.history[this.history.length-1]}set path(n){dc(n)&&(n=PA(n)),mc(n,"path"),this.path!==n&&this.history.push(n)}get stem(){return typeof this.path=="string"?Hn.basename(this.path,this.extname):void 0}set stem(n){mc(n,"stem"),pc(n,"stem"),this.path=Hn.join(this.dirname||"",n+(this.extname||""))}fail(n,a,i){const s=this.message(n,a,i);throw s.fatal=!0,s}info(n,a,i){const s=this.message(n,a,i);return s.fatal=void 0,s}message(n,a,i){const s=new De(n,a,i);return this.path&&(s.name=this.path+":"+s.name,s.file=this.path),s.fatal=!1,this.messages.push(s),s}toString(n){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(n||void 0).decode(this.value)}}function pc(t,n){if(t&&t.includes(Hn.sep))throw new Error("`"+n+"` cannot be a path: did not expect `"+Hn.sep+"`")}function mc(t,n){if(!t)throw new Error("`"+n+"` cannot be empty")}function _g(t,n){if(!t)throw new Error("Setting `"+n+"` requires `path` to be set too")}function QA(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const ZA=(function(t){const i=this.constructor.prototype,s=i[t],o=function(){return s.apply(o,arguments)};return Object.setPrototypeOf(o,i),o}),KA={}.hasOwnProperty;class gc extends ZA{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=jA()}copy(){const n=new gc;let a=-1;for(;++a<this.attachers.length;){const i=this.attachers[a];n.use(...i)}return n.data(cc(!0,{},this.namespace)),n}data(n,a){return typeof n=="string"?arguments.length===2?(vc("data",this.frozen),this.namespace[n]=a,this):KA.call(this.namespace,n)&&this.namespace[n]||void 0:n?(vc("data",this.frozen),this.namespace=n,this):this.namespace}freeze(){if(this.frozen)return this;const n=this;for(;++this.freezeIndex<this.attachers.length;){const[a,...i]=this.attachers[this.freezeIndex];if(i[0]===!1)continue;i[0]===!0&&(i[0]=void 0);const s=a.call(n,...i);typeof s=="function"&&this.transformers.use(s)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(n){this.freeze();const a=Rs(n),i=this.parser||this.Parser;return yc("parse",i),i(String(a),a)}process(n,a){const i=this;return this.freeze(),yc("process",this.parser||this.Parser),bc("process",this.compiler||this.Compiler),a?s(void 0,a):new Promise(s);function s(o,c){const d=Rs(n),h=i.parse(d);i.run(h,d,function(y,g,v){if(y||!g||!v)return m(y);const x=g,w=i.stringify(x,v);WA(w)?v.value=w:v.result=w,m(y,v)});function m(y,g){y||!g?c(y):o?o(g):a(void 0,g)}}}processSync(n){let a=!1,i;return this.freeze(),yc("processSync",this.parser||this.Parser),bc("processSync",this.compiler||this.Compiler),this.process(n,s),Eg("processSync","process",a),i;function s(o,c){a=!0,xg(o),i=c}}run(n,a,i){Tg(n),this.freeze();const s=this.transformers;return!i&&typeof a=="function"&&(i=a,a=void 0),i?o(void 0,i):new Promise(o);function o(c,d){const h=Rs(a);s.run(n,h,m);function m(y,g,v){const x=g||n;y?d(y):c?c(x):i(void 0,x,v)}}}runSync(n,a){let i=!1,s;return this.run(n,a,o),Eg("runSync","run",i),s;function o(c,d){xg(c),s=d,i=!0}}stringify(n,a){this.freeze();const i=Rs(a),s=this.compiler||this.Compiler;return bc("stringify",s),Tg(n),s(n,i)}use(n,...a){const i=this.attachers,s=this.namespace;if(vc("use",this.frozen),n!=null)if(typeof n=="function")h(n,a);else if(typeof n=="object")Array.isArray(n)?d(n):c(n);else throw new TypeError("Expected usable value, not `"+n+"`");return this;function o(m){if(typeof m=="function")h(m,[]);else if(typeof m=="object")if(Array.isArray(m)){const[y,...g]=m;h(y,g)}else c(m);else throw new TypeError("Expected usable value, not `"+m+"`")}function c(m){if(!("plugins"in m)&&!("settings"in m))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");d(m.plugins),m.settings&&(s.settings=cc(!0,s.settings,m.settings))}function d(m){let y=-1;if(m!=null)if(Array.isArray(m))for(;++y<m.length;){const g=m[y];o(g)}else throw new TypeError("Expected a list of plugins, not `"+m+"`")}function h(m,y){let g=-1,v=-1;for(;++g<i.length;)if(i[g][0]===m){v=g;break}if(v===-1)i.push([m,...y]);else if(y.length>0){let[x,...w]=y;const z=i[v][1];fc(z)&&fc(x)&&(x=cc(!0,z,x)),i[v]=[m,x,...w]}}}}const JA=new gc().freeze();function yc(t,n){if(typeof n!="function")throw new TypeError("Cannot `"+t+"` without `parser`")}function bc(t,n){if(typeof n!="function")throw new TypeError("Cannot `"+t+"` without `compiler`")}function vc(t,n){if(n)throw new Error("Cannot call `"+t+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Tg(t){if(!fc(t)||typeof t.type!="string")throw new TypeError("Expected node, got `"+t+"`")}function Eg(t,n,a){if(!a)throw new Error("`"+t+"` finished async. Use `"+n+"` instead")}function Rs(t){return $A(t)?t:new wg(t)}function $A(t){return!!(t&&typeof t=="object"&&"message"in t&&"messages"in t)}function WA(t){return typeof t=="string"||tk(t)}function tk(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const ek="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Cg=[],Ag={allowDangerousHtml:!0},nk=/^(https?|ircs?|mailto|xmpp)$/i,rk=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function ak(t){const n=ik(t),a=lk(t);return sk(n.runSync(n.parse(a),a),t)}function ik(t){const n=t.rehypePlugins||Cg,a=t.remarkPlugins||Cg,i=t.remarkRehypeOptions?_(_({},t.remarkRehypeOptions),Ag):Ag;return JA().use(UC).use(a).use(DA,i).use(n)}function lk(t){const n=t.children||"",a=new wg;return typeof n=="string"&&(a.value=n),a}function sk(t,n){const a=n.allowedElements,i=n.allowElement,s=n.components,o=n.disallowedElements,c=n.skipHtml,d=n.unwrapDisallowed,h=n.urlTransform||uk;for(const y of rk)Object.hasOwn(n,y.from)&&(""+y.from+(y.to?"use `"+y.to+"` instead":"remove it")+ek+y.id,void 0);return sc(t,m),zT(t,{Fragment:E.Fragment,components:s,ignoreInvalidStyle:!0,jsx:E.jsx,jsxs:E.jsxs,passKeys:!0,passNode:!0});function m(y,g,v){if(y.type==="raw"&&v&&typeof g=="number")return c?v.children.splice(g,1):v.children[g]={type:"text",value:y.value},g;if(y.type==="element"){let x;for(x in Qo)if(Object.hasOwn(Qo,x)&&Object.hasOwn(y.properties,x)){const w=y.properties[x],z=Qo[x];(z===null||z.includes(y.tagName))&&(y.properties[x]=h(String(w||""),x,y))}}if(y.type==="element"){let x=a?!a.includes(y.tagName):o?o.includes(y.tagName):!1;if(!x&&i&&typeof g=="number"&&(x=!i(y,g,v)),x&&v&&typeof g=="number")return d&&y.children?v.children.splice(g,1,...y.children):v.children.splice(g,1),g}}}function uk(t){const n=t.indexOf(":"),a=t.indexOf("?"),i=t.indexOf("#"),s=t.indexOf("/");return n===-1||s!==-1&&n>s||a!==-1&&n>a||i!==-1&&n>i||nk.test(t.slice(0,n))?t:""}var ok=(t,n)=>typeof t=="string"?t===n:JSON.stringify(t)===JSON.stringify(n),ck=(t,n)=>{if(!t||!n)return!1;const a=i=>{const d=i||{},{position:s,data:o}=d;return gt(d,["position","data"])};return JSON.stringify(a(t.properties))===JSON.stringify(a(n.properties))&&ok(t.children,n.children)},xc=(t,n)=>ck(t.node,n.node),fk=(t={})=>Object.fromEntries(Object.entries(t!=null?t:{}).map(([n,a])=>{if(!a)return[n,a];const i=a,s=d=>{var h=d,{node:o}=h,c=gt(h,["node"]);return E.jsx(i,_({},c))};return[n,R.memo(s,xc)]})),Sc=R.createContext(null),kg=()=>R.useContext(Sc)!==null,dk=a=>{var i=a,{children:t}=i,n=gt(i,["children"]);return E.jsx(Sc.Provider,{value:n,children:t})},hk=R.memo(dk,xc),pk=a=>{var i=a,{node:t}=i,n=gt(i,["node"]);return E.jsx("pre",_({},n))},mk=a=>{var i=a,{node:t}=i,n=gt(i,["node"]);return E.jsx("code",_({},n))},wc=({node:t,components:{Pre:n,Code:a},code:i})=>E.jsx(n,{children:E.jsx(a,{node:t,children:i})}),gk=()=>null,yk=({node:t,components:{Pre:n,Code:a,SyntaxHighlighter:i,CodeHeader:s},language:o,code:c})=>{const d=R.useMemo(()=>({Pre:n,Code:a}),[n,a]),h=o?i:wc;return E.jsxs(E.Fragment,{children:[E.jsx(s,{node:t,language:o,code:c}),E.jsx(h,{node:t,components:d,language:o!=null?o:"unknown",code:c})]})},_c={exports:{}};var Rg;function bk(){return Rg||(Rg=1,(function(t){(function(){var n={}.hasOwnProperty;function a(){for(var o="",c=0;c<arguments.length;c++){var d=arguments[c];d&&(o=s(o,i(d)))}return o}function i(o){if(typeof o=="string"||typeof o=="number")return o;if(typeof o!="object")return"";if(Array.isArray(o))return a.apply(null,o);if(o.toString!==Object.prototype.toString&&!o.toString.toString().includes("[native code]"))return o.toString();var c="";for(var d in o)n.call(o,d)&&o[d]&&(c=s(c,d));return c}function s(o,c){return c?o?o+" "+c:o+c:o}t.exports?(a.default=a,t.exports=a):window.classNames=a})()})(_c)),_c.exports}var vk=bk();const Mg=Kt(vk);var zg=a=>{var i=a,{className:t}=i,n=gt(i,["className"]);return c=>{var d=c,{className:s}=d,o=gt(d,["className"]);return _(_({className:Mg(t,s)},n),o)}},xk=h=>{var m=h,{node:t,components:{Pre:n,Code:a,SyntaxHighlighter:i,CodeHeader:s},componentsByLanguage:o={},children:c}=m,d=gt(m,["node","components","componentsByLanguage","children"]);var q,I,at,lt,L,J;const y=R.useContext(Sc),g=zg(y),v=Kr(st=>E.jsx(n,_({},g(st)))),x=zg(d),w=Kr(st=>E.jsx(a,_({},x(st)))),z=(I=(q=/language-(\w+)/.exec(d.className||""))==null?void 0:q[1])!=null?I:"";if(typeof c!="string")return E.jsx(wc,{node:t,components:{Pre:v,Code:w},code:c});const D=(lt=(at=o[z])==null?void 0:at.SyntaxHighlighter)!=null?lt:i,k=(J=(L=o[z])==null?void 0:L.CodeHeader)!=null?J:s;return E.jsx(yk,{node:t,components:{Pre:v,Code:w,SyntaxHighlighter:D,CodeHeader:k},language:z||"unknown",code:c})},Sk=s=>{var o=s,{node:t,components:n,componentsByLanguage:a}=o,i=gt(o,["node","components","componentsByLanguage"]);return kg()?E.jsx(xk,_({node:t,components:n,componentsByLanguage:a},i)):E.jsx(n.Code,_({},i))},wk=R.memo(Sk,(t,n)=>t.components===n.components&&t.componentsByLanguage===n.componentsByLanguage&&xc(t,n)),{useSmooth:_k,useSmoothStatus:Tk,withSmoothContextProvider:Ek}=Fw,Ck=o=>{var c=o,{components:t,componentsByLanguage:n,smooth:a=!0,preprocess:i}=c,s=gt(c,["components","componentsByLanguage","smooth","preprocess"]);const d=Op(),h=R.useMemo(()=>i?G(_({},d),{text:i(d.text)}):d,[d,i]),{text:m}=_k(h,a),{pre:y=pk,code:g=mk,SyntaxHighlighter:v=wc,CodeHeader:x=gk}=t!=null?t:{},w=R.useMemo(()=>({Pre:y,Code:g,SyntaxHighlighter:v,CodeHeader:x}),[y,g,v,x]),z=Kr(k=>E.jsx(wk,_({components:w,componentsByLanguage:n},k))),D=R.useMemo(()=>{const L=t!=null?t:{},{pre:k,code:q,SyntaxHighlighter:I,CodeHeader:at}=L,lt=gt(L,["pre","code","SyntaxHighlighter","CodeHeader"]);return G(_({},lt),{pre:hk,code:z})},[z,t]);return E.jsx(ak,G(_({components:D},s),{children:m}))},Og=R.forwardRef((o,s)=>{var c=o,{className:t,containerProps:n,containerComponent:a="div"}=c,i=gt(c,["className","containerProps","containerComponent"]);const d=Tk();return E.jsx(a,G(_({"data-status":d.type},n),{className:Mg(t,n==null?void 0:n.className),ref:s,children:E.jsx(Ck,_({},i))}))});Og.displayName="MarkdownTextPrimitive";var Ak=Ek(Og);function Dg(t,n){const a=String(t);if(typeof n!="string")throw new TypeError("Expected character");let i=0,s=a.indexOf(n);for(;s!==-1;)i++,s=a.indexOf(n,s+n.length);return i}function kk(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function Rk(t,n,a){const s=As((a||{}).ignore||[]),o=Mk(n);let c=-1;for(;++c<o.length;)yg(t,"text",d);function d(m,y){let g=-1,v;for(;++g<y.length;){const x=y[g],w=v?v.children:void 0;if(s(x,w?w.indexOf(x):void 0,v))return;v=x}if(v)return h(m,y)}function h(m,y){const g=y[y.length-1],v=o[c][0],x=o[c][1];let w=0;const D=g.children.indexOf(m);let k=!1,q=[];v.lastIndex=0;let I=v.exec(m.value);for(;I;){const at=I.index,lt={index:I.index,input:I.input,stack:[...y,m]};let L=x(...I,lt);if(typeof L=="string"&&(L=L.length>0?{type:"text",value:L}:void 0),L===!1?v.lastIndex=at+1:(w!==at&&q.push({type:"text",value:m.value.slice(w,at)}),Array.isArray(L)?q.push(...L):L&&q.push(L),w=at+I[0].length,k=!0),!v.global)break;I=v.exec(m.value)}return k?(w<m.value.length&&q.push({type:"text",value:m.value.slice(w)}),g.children.splice(D,1,...q)):q=[m],D+q.length}}function Mk(t){const n=[];if(!Array.isArray(t))throw new TypeError("Expected find and replace tuple or list of tuples");const a=!t[0]||Array.isArray(t[0])?t:[t];let i=-1;for(;++i<a.length;){const s=a[i];n.push([zk(s[0]),Ok(s[1])])}return n}function zk(t){return typeof t=="string"?new RegExp(kk(t),"g"):t}function Ok(t){return typeof t=="function"?t:function(){return t}}const Tc="phrasing",Ec=["autolink","link","image","label"];function Dk(){return{transforms:[Hk],enter:{literalAutolink:Ik,literalAutolinkEmail:Cc,literalAutolinkHttp:Cc,literalAutolinkWww:Cc},exit:{literalAutolink:Uk,literalAutolinkEmail:Bk,literalAutolinkHttp:jk,literalAutolinkWww:Lk}}}function Nk(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Tc,notInConstruct:Ec},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Tc,notInConstruct:Ec},{character:":",before:"[ps]",after:"\\/",inConstruct:Tc,notInConstruct:Ec}]}}function Ik(t){this.enter({type:"link",title:null,url:"",children:[]},t)}function Cc(t){this.config.enter.autolinkProtocol.call(this,t)}function jk(t){this.config.exit.autolinkProtocol.call(this,t)}function Lk(t){this.config.exit.data.call(this,t);const n=this.stack[this.stack.length-1];n.type,n.url="http://"+this.sliceSerialize(t)}function Bk(t){this.config.exit.autolinkEmail.call(this,t)}function Uk(t){this.exit(t)}function Hk(t){Rk(t,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,qk],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),Vk]],{ignore:["link","linkReference"]})}function qk(t,n,a,i,s){let o="";if(!Ng(s)||(/^w/i.test(n)&&(a=n+a,n="",o="http://"),!Yk(a)))return!1;const c=Fk(a+i);if(!c[0])return!1;const d={type:"link",title:null,url:o+n+c[0],children:[{type:"text",value:n+c[0]}]};return c[1]?[d,{type:"text",value:c[1]}]:d}function Vk(t,n,a,i){return!Ng(i,!0)||/[-\d_]$/.test(a)?!1:{type:"link",title:null,url:"mailto:"+n+"@"+a,children:[{type:"text",value:n+"@"+a}]}}function Yk(t){const n=t.split(".");return!(n.length<2||n[n.length-1]&&(/_/.test(n[n.length-1])||!/[a-zA-Z\d]/.test(n[n.length-1]))||n[n.length-2]&&(/_/.test(n[n.length-2])||!/[a-zA-Z\d]/.test(n[n.length-2])))}function Fk(t){const n=/[!"&'),.:;<>?\]}]+$/.exec(t);if(!n)return[t,void 0];t=t.slice(0,n.index);let a=n[0],i=a.indexOf(")");const s=Dg(t,"(");let o=Dg(t,")");for(;i!==-1&&s>o;)t+=a.slice(0,i+1),a=a.slice(i+1),i=a.indexOf(")"),o++;return[t,a]}function Ng(t,n){const a=t.input.charCodeAt(t.index-1);return(t.index===0||$r(a)||vs(a))&&(!n||a!==47)}Ig.peek=Wk;function Gk(){this.buffer()}function Pk(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function Xk(){this.buffer()}function Qk(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function Zk(t){const n=this.resume(),a=this.stack[this.stack.length-1];a.type,a.identifier=Dn(this.sliceSerialize(t)).toLowerCase(),a.label=n}function Kk(t){this.exit(t)}function Jk(t){const n=this.resume(),a=this.stack[this.stack.length-1];a.type,a.identifier=Dn(this.sliceSerialize(t)).toLowerCase(),a.label=n}function $k(t){this.exit(t)}function Wk(){return"["}function Ig(t,n,a,i){const s=a.createTracker(i);let o=s.move("[^");const c=a.enter("footnoteReference"),d=a.enter("reference");return o+=s.move(a.safe(a.associationId(t),{after:"]",before:o})),d(),c(),o+=s.move("]"),o}function tR(){return{enter:{gfmFootnoteCallString:Gk,gfmFootnoteCall:Pk,gfmFootnoteDefinitionLabelString:Xk,gfmFootnoteDefinition:Qk},exit:{gfmFootnoteCallString:Zk,gfmFootnoteCall:Kk,gfmFootnoteDefinitionLabelString:Jk,gfmFootnoteDefinition:$k}}}function eR(t){let n=!1;return t&&t.firstLineBlank&&(n=!0),{handlers:{footnoteDefinition:a,footnoteReference:Ig},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function a(i,s,o,c){const d=o.createTracker(c);let h=d.move("[^");const m=o.enter("footnoteDefinition"),y=o.enter("label");return h+=d.move(o.safe(o.associationId(i),{before:h,after:"]"})),y(),h+=d.move("]:"),i.children&&i.children.length>0&&(d.shift(4),h+=d.move((n?`
29
- `:" ")+o.indentLines(o.containerFlow(i,d.current()),n?jg:nR))),m(),h}}function nR(t,n,a){return n===0?t:jg(t,n,a)}function jg(t,n,a){return(a?"":" ")+t}const rR=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Lg.peek=uR;function aR(){return{canContainEols:["delete"],enter:{strikethrough:lR},exit:{strikethrough:sR}}}function iR(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:rR}],handlers:{delete:Lg}}}function lR(t){this.enter({type:"delete",children:[]},t)}function sR(t){this.exit(t)}function Lg(t,n,a,i){const s=a.createTracker(i),o=a.enter("strikethrough");let c=s.move("~~");return c+=a.containerPhrasing(t,G(_({},s.current()),{before:c,after:"~"})),c+=s.move("~~"),o(),c}function uR(){return"~"}function oR(t){return t.length}function cR(t,n){const a=n||{},i=(a.align||[]).concat(),s=a.stringLength||oR,o=[],c=[],d=[],h=[];let m=0,y=-1;for(;++y<t.length;){const z=[],D=[];let k=-1;for(t[y].length>m&&(m=t[y].length);++k<t[y].length;){const q=fR(t[y][k]);if(a.alignDelimiters!==!1){const I=s(q);D[k]=I,(h[k]===void 0||I>h[k])&&(h[k]=I)}z.push(q)}c[y]=z,d[y]=D}let g=-1;if(typeof i=="object"&&"length"in i)for(;++g<m;)o[g]=Bg(i[g]);else{const z=Bg(i);for(;++g<m;)o[g]=z}g=-1;const v=[],x=[];for(;++g<m;){const z=o[g];let D="",k="";z===99?(D=":",k=":"):z===108?D=":":z===114&&(k=":");let q=a.alignDelimiters===!1?1:Math.max(1,h[g]-D.length-k.length);const I=D+"-".repeat(q)+k;a.alignDelimiters!==!1&&(q=D.length+q+k.length,q>h[g]&&(h[g]=q),x[g]=q),v[g]=I}c.splice(1,0,v),d.splice(1,0,x),y=-1;const w=[];for(;++y<c.length;){const z=c[y],D=d[y];g=-1;const k=[];for(;++g<m;){const q=z[g]||"";let I="",at="";if(a.alignDelimiters!==!1){const lt=h[g]-(D[g]||0),L=o[g];L===114?I=" ".repeat(lt):L===99?lt%2?(I=" ".repeat(lt/2+.5),at=" ".repeat(lt/2-.5)):(I=" ".repeat(lt/2),at=I):at=" ".repeat(lt)}a.delimiterStart!==!1&&!g&&k.push("|"),a.padding!==!1&&!(a.alignDelimiters===!1&&q==="")&&(a.delimiterStart!==!1||g)&&k.push(" "),a.alignDelimiters!==!1&&k.push(I),k.push(q),a.alignDelimiters!==!1&&k.push(at),a.padding!==!1&&k.push(" "),(a.delimiterEnd!==!1||g!==m-1)&&k.push("|")}w.push(a.delimiterEnd===!1?k.join("").replace(/ +$/,""):k.join(""))}return w.join(`
30
- `)}function fR(t){return t==null?"":String(t)}function Bg(t){const n=typeof t=="string"?t.codePointAt(0):0;return n===67||n===99?99:n===76||n===108?108:n===82||n===114?114:0}function dR(t,n,a,i){const s=a.enter("blockquote"),o=a.createTracker(i);o.move("> "),o.shift(2);const c=a.indentLines(a.containerFlow(t,o.current()),hR);return s(),c}function hR(t,n,a){return">"+(a?"":" ")+t}function pR(t,n){return Ug(t,n.inConstruct,!0)&&!Ug(t,n.notInConstruct,!1)}function Ug(t,n,a){if(typeof n=="string"&&(n=[n]),!n||n.length===0)return a;let i=-1;for(;++i<n.length;)if(t.includes(n[i]))return!0;return!1}function Hg(t,n,a,i){let s=-1;for(;++s<a.unsafe.length;)if(a.unsafe[s].character===`
31
- `&&pR(a.stack,a.unsafe[s]))return/[ \t]/.test(i.before)?"":" ";return`\\
32
- `}function mR(t,n){const a=String(t);let i=a.indexOf(n),s=i,o=0,c=0;if(typeof n!="string")throw new TypeError("Expected substring");for(;i!==-1;)i===s?++o>c&&(c=o):o=1,s=i+n.length,i=a.indexOf(n,s);return c}function gR(t,n){return!!(n.options.fences===!1&&t.value&&!t.lang&&/[^ \r\n]/.test(t.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(t.value))}function yR(t){const n=t.options.fence||"`";if(n!=="`"&&n!=="~")throw new Error("Cannot serialize code with `"+n+"` for `options.fence`, expected `` ` `` or `~`");return n}function bR(t,n,a,i){const s=yR(a),o=t.value||"",c=s==="`"?"GraveAccent":"Tilde";if(gR(t,a)){const g=a.enter("codeIndented"),v=a.indentLines(o,vR);return g(),v}const d=a.createTracker(i),h=s.repeat(Math.max(mR(o,s)+1,3)),m=a.enter("codeFenced");let y=d.move(h);if(t.lang){const g=a.enter(`codeFencedLang${c}`);y+=d.move(a.safe(t.lang,_({before:y,after:" ",encode:["`"]},d.current()))),g()}if(t.lang&&t.meta){const g=a.enter(`codeFencedMeta${c}`);y+=d.move(" "),y+=d.move(a.safe(t.meta,_({before:y,after:`
33
- `,encode:["`"]},d.current()))),g()}return y+=d.move(`
34
- `),o&&(y+=d.move(o+`
35
- `)),y+=d.move(h),m(),y}function vR(t,n,a){return(a?"":" ")+t}function Ac(t){const n=t.options.quote||'"';if(n!=='"'&&n!=="'")throw new Error("Cannot serialize title with `"+n+"` for `options.quote`, expected `\"`, or `'`");return n}function xR(t,n,a,i){const s=Ac(a),o=s==='"'?"Quote":"Apostrophe",c=a.enter("definition");let d=a.enter("label");const h=a.createTracker(i);let m=h.move("[");return m+=h.move(a.safe(a.associationId(t),_({before:m,after:"]"},h.current()))),m+=h.move("]: "),d(),!t.url||/[\0- \u007F]/.test(t.url)?(d=a.enter("destinationLiteral"),m+=h.move("<"),m+=h.move(a.safe(t.url,_({before:m,after:">"},h.current()))),m+=h.move(">")):(d=a.enter("destinationRaw"),m+=h.move(a.safe(t.url,_({before:m,after:t.title?" ":`
36
- `},h.current())))),d(),t.title&&(d=a.enter(`title${o}`),m+=h.move(" "+s),m+=h.move(a.safe(t.title,_({before:m,after:s},h.current()))),m+=h.move(s),d()),c(),m}function SR(t){const n=t.options.emphasis||"*";if(n!=="*"&&n!=="_")throw new Error("Cannot serialize emphasis with `"+n+"` for `options.emphasis`, expected `*`, or `_`");return n}function Wi(t){return"&#x"+t.toString(16).toUpperCase()+";"}function Ms(t,n,a){const i=La(t),s=La(n);return i===void 0?s===void 0?a==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:s===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:i===1?s===void 0?{inside:!1,outside:!1}:s===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:s===void 0?{inside:!1,outside:!1}:s===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}qg.peek=wR;function qg(t,n,a,i){const s=SR(a),o=a.enter("emphasis"),c=a.createTracker(i),d=c.move(s);let h=c.move(a.containerPhrasing(t,_({after:s,before:d},c.current())));const m=h.charCodeAt(0),y=Ms(i.before.charCodeAt(i.before.length-1),m,s);y.inside&&(h=Wi(m)+h.slice(1));const g=h.charCodeAt(h.length-1),v=Ms(i.after.charCodeAt(0),g,s);v.inside&&(h=h.slice(0,-1)+Wi(g));const x=c.move(s);return o(),a.attentionEncodeSurroundingInfo={after:v.outside,before:y.outside},d+h+x}function wR(t,n,a){return a.options.emphasis||"*"}function _R(t,n){let a=!1;return sc(t,function(i){if("value"in i&&/\r?\n|\r/.test(i.value)||i.type==="break")return a=!0,lc}),!!((!t.depth||t.depth<3)&&Zo(t)&&(n.options.setext||a))}function TR(t,n,a,i){const s=Math.max(Math.min(6,t.depth||1),1),o=a.createTracker(i);if(_R(t,a)){const y=a.enter("headingSetext"),g=a.enter("phrasing"),v=a.containerPhrasing(t,G(_({},o.current()),{before:`
7
+ `);i=o.pop()||"";for(const l of o)if(l.startsWith("data: ")){const u=l.slice(6);if(u.trim()==="[DONE]"){yield{done:!0};continue}try{yield JSON.parse(u)}catch(d){}}}}finally{r.releaseLock()}})}function If(e){return e.map(t=>{let r="";if(typeof t.content=="string")r=t.content;else if(Array.isArray(t.content)){const n=t.content.find(i=>i.type==="text");n&&typeof n=="object"&&"text"in n&&(r=n.text)}return{role:t.role,content:r}})}function Ef(e){return m(m({id:e.id,role:e.role,content:[{type:"text",text:e.content}],createdAt:new Date(e.createdAt),metadata:{custom:{}}},e.role==="assistant"&&{status:{type:"complete",reason:"stop"},metadata:{unstable_state:null,unstable_annotations:[],unstable_data:[],steps:[],custom:{}}}),e.role==="user"&&{attachments:[]})}function Ua(e,t){const{modelId:r,systemPrompt:n,ephemeral:i,onChatCreated:s,onUserMessage:a,onThreadIdUpdate:o}=t;return{run(u){return wr(this,null,function*(){const{messages:d,abortSignal:c,context:f}=u,h=f==null?void 0:f.threadId;a==null||a();const S={messages:If(d),chatId:null,systemPrompt:n,ephemeral:i,stream:!0};r&&r.trim()!==""&&(S.modelId=r);const w=yield new it(e.createOrContinueChat(S,c));let b="",C;try{for(var _=xt(Cf(w,c)),F,B,I;F=!(B=yield new it(_.next())).done;F=!1){const z=B.value;if(c!=null&&c.aborted)throw new Error("Request aborted");const j=z.id;j&&!C&&(C=j,s==null||s(j),h&&o&&o(h,j));const $=z.delta;if($!=null&&(b+=$),z.type==="message"||z.content){const N=z.content||"";b+=N}if(z.message&&(b+=z.message.content||""),z.tool_calls,z.finished){b&&(yield{content:[{type:"text",text:b}]});break}b&&(yield{content:[{type:"text",text:b}]})}}catch(B){I=[B]}finally{try{F&&(B=_.return)&&(yield new it(B.call(_)))}finally{if(I)throw I[0]}}b&&(yield{content:[{type:"text",text:b}]})})}}}const $a=new Map;function Af(e,t){return{list(){return P(this,null,function*(){const n=[];let s,a=0;do{const l=yield e.listChats({limit:50,cursor:s}),u=l.items||[];Array.isArray(u)&&u.length>0&&n.push(...u),s=l.nextCursor||void 0,a++}while(s&&a<50);return{threads:n.map(l=>{const u=l.id;return!u||l.deletedAt?null:{status:"regular",remoteId:u,title:l.title||"New Chat",createdAt:l.createdAt?new Date(l.createdAt):new Date,updatedAt:l.updatedAt?new Date(l.updatedAt):new Date}}).filter(l=>l!==null)}})},initialize(n){return P(this,null,function*(){return{remoteId:$a.get(n)||n,externalId:void 0}})},rename(n,i){return P(this,null,function*(){yield e.updateChat(n,{title:i})})},archive(n){return P(this,null,function*(){})},unarchive(n){return P(this,null,function*(){})},delete(n){return P(this,null,function*(){yield e.deleteChat(n)})},generateTitle(n,i){return P(this,null,function*(){return new ReadableStream})},fetch(n){return P(this,null,function*(){try{const i=yield e.getChat(n);return{status:"regular",remoteId:i.id||n,title:i.title||"Chat",createdAt:i.createdAt?new Date(i.createdAt):new Date,updatedAt:i.updatedAt?new Date(i.updatedAt):new Date}}catch(i){return{status:"regular",remoteId:n,createdAt:new Date,updatedAt:new Date}}})},updateRemoteId(n,i){$a.set(n,i),t==null||t(n,i)},unstable_Provider:({children:n})=>{const i=Us(),s=i==null?void 0:i.remoteId,a=y.useMemo(()=>({load(){return P(this,null,function*(){if(!s)return{messages:[]};try{const u=yield e.getChat(s);return!u.messages||u.messages.length===0?{messages:[]}:{messages:u.messages.map(c=>Ef(c))}}catch(u){return console.error("Failed to load messages for thread:",s,u),{messages:[]}}})},append(u){return P(this,null,function*(){})}}),[s,e]),o=y.useMemo(()=>({history:a}),[a]);return p.jsx(wn,{adapters:o,children:n})}}}function Pf({children:e,baseUrl:t,sessionToken:r,isProxyMode:n=!1,mode:i="multiChat",modelId:s,onModelChange:a,ephemeral:o=!1,systemPrompt:l,initialThreadId:u,onError:d,onChatCreated:c,onUserMessage:f,onThreadIdUpdate:h,onChatsLoaded:g}){const S=y.useMemo(()=>new ja(t,r||void 0,n),[t,r,n]),[w,b]=y.useState(s||null);y.useEffect(()=>{s&&b(s)},[s]);const C=y.useCallback(B=>{c==null||c(B)},[c]),_=y.useCallback((B,I)=>{h==null||h(B,I)},[h]),F=y.useMemo(()=>Ua(S,{modelId:w||void 0,systemPrompt:l,ephemeral:o,onChatCreated:C,onUserMessage:f}),[S,w,l,o,C,f]);return i==="singleChat"?p.jsx(Mf,{modelAdapter:F,children:e}):p.jsx(Lf,{client:S,modelAdapterOptions:{modelId:w||void 0,systemPrompt:l,ephemeral:o,onChatCreated:C,onUserMessage:f},initialThreadId:u,onChatsLoaded:g,onThreadIdUpdate:_,onError:d,children:e})}function Mf({modelAdapter:e,children:t}){const r=Xs(e);return p.jsx(Vs,{runtime:r,children:t})}function Lf({client:e,modelAdapterOptions:t,initialThreadId:r,onChatsLoaded:n,onThreadIdUpdate:i,onError:s,children:a}){const o=y.useMemo(()=>Af(e,(h,g)=>{i==null||i(h,g)}),[e,i]),l=y.useCallback((h,g)=>{o.updateRemoteId&&o.updateRemoteId(h,g),i==null||i(h,g)},[o,i]),u=y.useMemo(()=>E(m({},o),{list(){return P(this,null,function*(){const g=yield o.list();return n==null||n(),g})}}),[o,n]);y.useEffect(()=>{window.__cuadraThreadListAdapter=u,window.__cuadraThreadListRuntime=null},[u]);const d=y.useMemo(()=>Ua(e,E(m({},t),{onThreadIdUpdate:l})),[e,t,l]),c=y.useCallback(()=>Xs(d),[d]),f=ra({adapter:u,runtimeHook:c});return y.useEffect(()=>{window.__cuadraThreadListRuntime=f},[f]),p.jsx(Vs,{runtime:f,children:a})}function Jx(){}function Gx(){}function Nf(e,t){const r={};return(e[e.length-1]===""?[...e,""]:e).join((r.padRight?" ":"")+","+(r.padLeft===!1?"":" ")).trim()}const Df=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Of=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ff={};function Ha(e,t){return(Ff.jsx?Of:Df).test(e)}const Bf=/[ \t\n\f\r]/g;function zf(e){return typeof e=="object"?e.type==="text"?qa(e.value):!1:qa(e)}function qa(e){return e.replace(Bf,"")===""}class tr{constructor(t,r,n){this.normal=r,this.property=t,n&&(this.space=n)}}tr.prototype.normal={},tr.prototype.property={},tr.prototype.space=void 0;function Va(e,t){const r={},n={};for(const i of e)Object.assign(r,i.property),Object.assign(n,i.normal);return new tr(r,n,t)}function Un(e){return e.toLowerCase()}class Ee{constructor(t,r){this.attribute=r,this.property=t}}Ee.prototype.attribute="",Ee.prototype.booleanish=!1,Ee.prototype.boolean=!1,Ee.prototype.commaOrSpaceSeparated=!1,Ee.prototype.commaSeparated=!1,Ee.prototype.defined=!1,Ee.prototype.mustUseProperty=!1,Ee.prototype.number=!1,Ee.prototype.overloadedBoolean=!1,Ee.prototype.property="",Ee.prototype.spaceSeparated=!1,Ee.prototype.space=void 0;let Rf=0;const G=pt(),de=pt(),$n=pt(),L=pt(),ne=pt(),Mt=pt(),Me=pt();function pt(){return lu(2,++Rf)}const Hn=Object.freeze(Object.defineProperty({__proto__:null,boolean:G,booleanish:de,commaOrSpaceSeparated:Me,commaSeparated:Mt,number:L,overloadedBoolean:$n,spaceSeparated:ne},Symbol.toStringTag,{value:"Module"})),qn=Object.keys(Hn);class Vn extends Ee{constructor(t,r,n,i){let s=-1;if(super(t,r),Wa(this,"space",i),typeof n=="number")for(;++s<qn.length;){const a=qn[s];Wa(this,qn[s],(n&Hn[a])===Hn[a])}}}Vn.prototype.defined=!0;function Wa(e,t,r){r&&(e[t]=r)}function Lt(e){const t={},r={};for(const[n,i]of Object.entries(e.properties)){const s=new Vn(n,e.transform(e.attributes||{},n),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(n)&&(s.mustUseProperty=!0),t[n]=s,r[Un(n)]=n,r[Un(s.attribute)]=n}return new tr(t,r,e.space)}const Ja=Lt({properties:{ariaActiveDescendant:null,ariaAtomic:de,ariaAutoComplete:null,ariaBusy:de,ariaChecked:de,ariaColCount:L,ariaColIndex:L,ariaColSpan:L,ariaControls:ne,ariaCurrent:null,ariaDescribedBy:ne,ariaDetails:null,ariaDisabled:de,ariaDropEffect:ne,ariaErrorMessage:null,ariaExpanded:de,ariaFlowTo:ne,ariaGrabbed:de,ariaHasPopup:null,ariaHidden:de,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ne,ariaLevel:L,ariaLive:null,ariaModal:de,ariaMultiLine:de,ariaMultiSelectable:de,ariaOrientation:null,ariaOwns:ne,ariaPlaceholder:null,ariaPosInSet:L,ariaPressed:de,ariaReadOnly:de,ariaRelevant:null,ariaRequired:de,ariaRoleDescription:ne,ariaRowCount:L,ariaRowIndex:L,ariaRowSpan:L,ariaSelected:de,ariaSetSize:L,ariaSort:null,ariaValueMax:L,ariaValueMin:L,ariaValueNow:L,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Ga(e,t){return t in e?e[t]:t}function Ya(e,t){return Ga(e,t.toLowerCase())}const jf=Lt({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Mt,acceptCharset:ne,accessKey:ne,action:null,allow:null,allowFullScreen:G,allowPaymentRequest:G,allowUserMedia:G,alt:null,as:null,async:G,autoCapitalize:null,autoComplete:ne,autoFocus:G,autoPlay:G,blocking:ne,capture:null,charSet:null,checked:G,cite:null,className:ne,cols:L,colSpan:null,content:null,contentEditable:de,controls:G,controlsList:ne,coords:L|Mt,crossOrigin:null,data:null,dateTime:null,decoding:null,default:G,defer:G,dir:null,dirName:null,disabled:G,download:$n,draggable:de,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:G,formTarget:null,headers:ne,height:L,hidden:$n,high:L,href:null,hrefLang:null,htmlFor:ne,httpEquiv:ne,id:null,imageSizes:null,imageSrcSet:null,inert:G,inputMode:null,integrity:null,is:null,isMap:G,itemId:null,itemProp:ne,itemRef:ne,itemScope:G,itemType:ne,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:G,low:L,manifest:null,max:null,maxLength:L,media:null,method:null,min:null,minLength:L,multiple:G,muted:G,name:null,nonce:null,noModule:G,noValidate:G,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:G,optimum:L,pattern:null,ping:ne,placeholder:null,playsInline:G,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:G,referrerPolicy:null,rel:ne,required:G,reversed:G,rows:L,rowSpan:L,sandbox:ne,scope:null,scoped:G,seamless:G,selected:G,shadowRootClonable:G,shadowRootDelegatesFocus:G,shadowRootMode:null,shape:null,size:L,sizes:null,slot:null,span:L,spellCheck:de,src:null,srcDoc:null,srcLang:null,srcSet:null,start:L,step:null,style:null,tabIndex:L,target:null,title:null,translate:null,type:null,typeMustMatch:G,useMap:null,value:de,width:L,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ne,axis:null,background:null,bgColor:null,border:L,borderColor:null,bottomMargin:L,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:G,declare:G,event:null,face:null,frame:null,frameBorder:null,hSpace:L,leftMargin:L,link:null,longDesc:null,lowSrc:null,marginHeight:L,marginWidth:L,noResize:G,noHref:G,noShade:G,noWrap:G,object:null,profile:null,prompt:null,rev:null,rightMargin:L,rules:null,scheme:null,scrolling:de,standby:null,summary:null,text:null,topMargin:L,valueType:null,version:null,vAlign:null,vLink:null,vSpace:L,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:G,disableRemotePlayback:G,prefix:null,property:null,results:L,security:null,unselectable:null},space:"html",transform:Ya}),Uf=Lt({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Me,accentHeight:L,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:L,amplitude:L,arabicForm:null,ascent:L,attributeName:null,attributeType:null,azimuth:L,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:L,by:null,calcMode:null,capHeight:L,className:ne,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:L,diffuseConstant:L,direction:null,display:null,dur:null,divisor:L,dominantBaseline:null,download:G,dx:null,dy:null,edgeMode:null,editable:null,elevation:L,enableBackground:null,end:null,event:null,exponent:L,externalResourcesRequired:null,fill:null,fillOpacity:L,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Mt,g2:Mt,glyphName:Mt,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:L,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:L,horizOriginX:L,horizOriginY:L,id:null,ideographic:L,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:L,k:L,k1:L,k2:L,k3:L,k4:L,kernelMatrix:Me,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:L,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:L,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:L,overlineThickness:L,paintOrder:null,panose1:null,path:null,pathLength:L,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ne,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:L,pointsAtY:L,pointsAtZ:L,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Me,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Me,rev:Me,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Me,requiredFeatures:Me,requiredFonts:Me,requiredFormats:Me,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:L,specularExponent:L,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:L,strikethroughThickness:L,string:null,stroke:null,strokeDashArray:Me,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:L,strokeOpacity:L,strokeWidth:null,style:null,surfaceScale:L,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Me,tabIndex:L,tableValues:null,target:null,targetX:L,targetY:L,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Me,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:L,underlineThickness:L,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:L,values:null,vAlphabetic:L,vMathematical:L,vectorEffect:null,vHanging:L,vIdeographic:L,version:null,vertAdvY:L,vertOriginX:L,vertOriginY:L,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:L,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Ga}),Ka=Lt({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),Xa=Lt({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Ya}),Qa=Lt({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),$f={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Hf=/[A-Z]/g,Za=/-[a-z]/g,qf=/^data[-\w.:]+$/i;function Vf(e,t){const r=Un(t);let n=t,i=Ee;if(r in e.normal)return e.property[e.normal[r]];if(r.length>4&&r.slice(0,4)==="data"&&qf.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(Za,Jf);n="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!Za.test(s)){let a=s.replace(Hf,Wf);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=Vn}return new i(n,t)}function Wf(e){return"-"+e.toLowerCase()}function Jf(e){return e.charAt(1).toUpperCase()}const Gf=Va([Ja,jf,Ka,Xa,Qa],"html"),Wn=Va([Ja,Uf,Ka,Xa,Qa],"svg");function Yf(e){return e.join(" ").trim()}var Nt={},Jn,eo;function Kf(){if(eo)return Jn;eo=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,r=/^\s*/,n=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,a=/^[;\s]*/,o=/^\s+|\s+$/g,l=`
8
+ `,u="/",d="*",c="",f="comment",h="declaration";function g(w,b){if(typeof w!="string")throw new TypeError("First argument must be a string");if(!w)return[];b=b||{};var C=1,_=1;function F(R){var D=R.match(t);D&&(C+=D.length);var Q=R.lastIndexOf(l);_=~Q?R.length-Q:_+R.length}function B(){var R={line:C,column:_};return function(D){return D.position=new I(R),$(),D}}function I(R){this.start=R,this.end={line:C,column:_},this.source=b.source}I.prototype.content=w;function z(R){var D=new Error(b.source+":"+C+":"+_+": "+R);if(D.reason=R,D.filename=b.source,D.line=C,D.column=_,D.source=w,!b.silent)throw D}function j(R){var D=R.exec(w);if(D){var Q=D[0];return F(Q),w=w.slice(Q.length),D}}function $(){j(r)}function k(R){var D;for(R=R||[];D=N();)D!==!1&&R.push(D);return R}function N(){var R=B();if(!(u!=w.charAt(0)||d!=w.charAt(1))){for(var D=2;c!=w.charAt(D)&&(d!=w.charAt(D)||u!=w.charAt(D+1));)++D;if(D+=2,c===w.charAt(D-1))return z("End of comment missing");var Q=w.slice(2,D-2);return _+=2,F(Q),w=w.slice(D),_+=2,R({type:f,comment:Q})}}function M(){var R=B(),D=j(n);if(D){if(N(),!j(i))return z("property missing ':'");var Q=j(s),se=R({type:h,property:S(D[0].replace(e,c)),value:Q?S(Q[0].replace(e,c)):c});return j(a),se}}function V(){var R=[];k(R);for(var D;D=M();)D!==!1&&(R.push(D),k(R));return R}return $(),V()}function S(w){return w?w.replace(o,c):c}return Jn=g,Jn}var to;function Xf(){if(to)return Nt;to=1;var e=Nt&&Nt.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(Nt,"__esModule",{value:!0}),Nt.default=r;const t=e(Kf());function r(n,i){let s=null;if(!n||typeof n!="string")return s;const a=(0,t.default)(n),o=typeof i=="function";return a.forEach(l=>{if(l.type!=="declaration")return;const{property:u,value:d}=l;o?i(u,d,l):d&&(s=s||{},s[u]=d)}),s}return Nt}var rr={},ro;function Qf(){if(ro)return rr;ro=1,Object.defineProperty(rr,"__esModule",{value:!0}),rr.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,r=/^[^-]+$/,n=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,s=function(u){return!u||r.test(u)||e.test(u)},a=function(u,d){return d.toUpperCase()},o=function(u,d){return"".concat(d,"-")},l=function(u,d){return d===void 0&&(d={}),s(u)?u:(u=u.toLowerCase(),d.reactCompat?u=u.replace(i,o):u=u.replace(n,o),u.replace(t,a))};return rr.camelCase=l,rr}var nr,no;function Zf(){if(no)return nr;no=1;var e=nr&&nr.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(Xf()),r=Qf();function n(i,s){var a={};return!i||typeof i!="string"||(0,t.default)(i,function(o,l){o&&l&&(a[(0,r.camelCase)(o,s)]=l)}),a}return n.default=n,nr=n,nr}var ep=Zf();const tp=xr(ep),io=so("end"),Gn=so("start");function so(e){return t;function t(r){const n=r&&r.position&&r.position[e]||{};if(typeof n.line=="number"&&n.line>0&&typeof n.column=="number"&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset=="number"&&n.offset>-1?n.offset:void 0}}}function rp(e){const t=Gn(e),r=io(e);if(t&&r)return{start:t,end:r}}function ir(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?ao(e.position):"start"in e||"end"in e?ao(e):"line"in e||"column"in e?Yn(e):""}function Yn(e){return oo(e&&e.line)+":"+oo(e&&e.column)}function ao(e){return Yn(e&&e.start)+"-"+Yn(e&&e.end)}function oo(e){return e&&typeof e=="number"?e:1}class we extends Error{constructor(t,r,n){super(),typeof r=="string"&&(n=r,r=void 0);let i="",s={},a=!1;if(r&&("line"in r&&"column"in r?s={place:r}:"start"in r&&"end"in r?s={place:r}:"type"in r?s={ancestors:[r],place:r.position}:s=m({},r)),typeof t=="string"?i=t:!s.cause&&t&&(a=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof n=="string"){const l=n.indexOf(":");l===-1?s.ruleId=n:(s.source=n.slice(0,l),s.ruleId=n.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const o=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=o?o.line:void 0,this.name=ir(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=a&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}we.prototype.file="",we.prototype.name="",we.prototype.reason="",we.prototype.message="",we.prototype.stack="",we.prototype.column=void 0,we.prototype.line=void 0,we.prototype.ancestors=void 0,we.prototype.cause=void 0,we.prototype.fatal=void 0,we.prototype.place=void 0,we.prototype.ruleId=void 0,we.prototype.source=void 0;const Kn={}.hasOwnProperty,np=new Map,ip=/[A-Z]/g,sp=new Set(["table","tbody","thead","tfoot","tr"]),ap=new Set(["td","th"]),lo="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function op(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const r=t.filePath||void 0;let n;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");n=mp(r,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");n=pp(r,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:n,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:r,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Wn:Gf,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=uo(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function uo(e,t,r){if(t.type==="element")return lp(e,t,r);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return up(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return dp(e,t,r);if(t.type==="mdxjsEsm")return cp(e,t);if(t.type==="root")return hp(e,t,r);if(t.type==="text")return fp(e,t)}function lp(e,t,r){const n=e.schema;let i=n;t.tagName.toLowerCase()==="svg"&&n.space==="html"&&(i=Wn,e.schema=i),e.ancestors.push(t);const s=ho(e,t.tagName,!1),a=gp(e,t);let o=Qn(e,t);return sp.has(t.tagName)&&(o=o.filter(function(l){return typeof l=="string"?!zf(l):!0})),co(e,a,s,t),Xn(a,o),e.ancestors.pop(),e.schema=n,e.create(t,s,a,r)}function up(e,t){if(t.data&&t.data.estree&&e.evaluater){const n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}sr(e,t.position)}function cp(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);sr(e,t.position)}function dp(e,t,r){const n=e.schema;let i=n;t.name==="svg"&&n.space==="html"&&(i=Wn,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:ho(e,t.name,!0),a=yp(e,t),o=Qn(e,t);return co(e,a,s,t),Xn(a,o),e.ancestors.pop(),e.schema=n,e.create(t,s,a,r)}function hp(e,t,r){const n={};return Xn(n,Qn(e,t)),e.create(t,e.Fragment,n,r)}function fp(e,t){return t.value}function co(e,t,r,n){typeof r!="string"&&r!==e.Fragment&&e.passNode&&(t.node=n)}function Xn(e,t){if(t.length>0){const r=t.length>1?t:t[0];r&&(e.children=r)}}function pp(e,t,r){return n;function n(i,s,a,o){const u=Array.isArray(a.children)?r:t;return o?u(s,a,o):u(s,a)}}function mp(e,t){return r;function r(n,i,s,a){const o=Array.isArray(s.children),l=Gn(n);return t(i,s,a,o,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function gp(e,t){const r={};let n,i;for(i in t.properties)if(i!=="children"&&Kn.call(t.properties,i)){const s=bp(e,i,t.properties[i]);if(s){const[a,o]=s;e.tableCellAlignToStyle&&a==="align"&&typeof o=="string"&&ap.has(t.tagName)?n=o:r[a]=o}}if(n){const s=r.style||(r.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=n}return r}function yp(e,t){const r={};for(const n of t.attributes)if(n.type==="mdxJsxExpressionAttribute")if(n.data&&n.data.estree&&e.evaluater){const s=n.data.estree.body[0];s.type;const a=s.expression;a.type;const o=a.properties[0];o.type,Object.assign(r,e.evaluater.evaluateExpression(o.argument))}else sr(e,t.position);else{const i=n.name;let s;if(n.value&&typeof n.value=="object")if(n.value.data&&n.value.data.estree&&e.evaluater){const o=n.value.data.estree.body[0];o.type,s=e.evaluater.evaluateExpression(o.expression)}else sr(e,t.position);else s=n.value===null?!0:n.value;r[i]=s}return r}function Qn(e,t){const r=[];let n=-1;const i=e.passKeys?new Map:np;for(;++n<t.children.length;){const s=t.children[n];let a;if(e.passKeys){const l=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(l){const u=i.get(l)||0;a=l+"-"+u,i.set(l,u+1)}}const o=uo(e,s,a);o!==void 0&&r.push(o)}return r}function bp(e,t,r){const n=Vf(e.schema,t);if(!(r==null||typeof r=="number"&&Number.isNaN(r))){if(Array.isArray(r)&&(r=n.commaSeparated?Nf(r):Yf(r)),n.property==="style"){let i=typeof r=="object"?r:wp(e,String(r));return e.stylePropertyNameCase==="css"&&(i=xp(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&n.space?$f[n.property]||n.property:n.attribute,r]}}function wp(e,t){try{return tp(t,{reactCompat:!0})}catch(r){if(e.ignoreInvalidStyle)return{};const n=r,i=new we("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=lo+"#cannot-parse-style-attribute",i}}function ho(e,t,r){let n;if(!r)n={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,a;for(;++s<i.length;){const o=Ha(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};a=a?{type:"MemberExpression",object:a,property:o,computed:!!(s&&o.type==="Literal"),optional:!1}:o}n=a}else n=Ha(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(n.type==="Literal"){const i=n.value;return Kn.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(n);sr(e)}function sr(e,t){const r=new we("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw r.file=e.filePath||void 0,r.url=lo+"#cannot-handle-mdx-estrees-without-createevaluater",r}function xp(e){const t={};let r;for(r in e)Kn.call(e,r)&&(t[vp(r)]=e[r]);return t}function vp(e){let t=e.replace(ip,Sp);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function Sp(e){return"-"+e.toLowerCase()}const Zn={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},kp={};function ei(e,t){const r=kp,n=typeof r.includeImageAlt=="boolean"?r.includeImageAlt:!0,i=typeof r.includeHtml=="boolean"?r.includeHtml:!0;return fo(e,n,i)}function fo(e,t,r){if(_p(e)){if("value"in e)return e.type==="html"&&!r?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return po(e.children,t,r)}return Array.isArray(e)?po(e,t,r):""}function po(e,t,r){const n=[];let i=-1;for(;++i<e.length;)n[i]=fo(e[i],t,r);return n.join("")}function _p(e){return!!(e&&typeof e=="object")}const mo=document.createElement("i");function ti(e){const t="&"+e+";";mo.innerHTML=t;const r=mo.textContent;return r.charCodeAt(r.length-1)===59&&e!=="semi"||r===t?!1:r}function Le(e,t,r,n){const i=e.length;let s=0,a;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,r=r>0?r:0,n.length<1e4)a=Array.from(n),a.unshift(t,r),e.splice(...a);else for(r&&e.splice(t,r);s<n.length;)a=n.slice(s,s+1e4),a.unshift(t,0),e.splice(...a),s+=1e4,t+=1e4}function Be(e,t){return e.length>0?(Le(e,e.length,0,t),e):t}const go={}.hasOwnProperty;function yo(e){const t={};let r=-1;for(;++r<e.length;)Tp(t,e[r]);return t}function Tp(e,t){let r;for(r in t){const i=(go.call(e,r)?e[r]:void 0)||(e[r]={}),s=t[r];let a;if(s)for(a in s){go.call(i,a)||(i[a]=[]);const o=s[a];Cp(i[a],Array.isArray(o)?o:o?[o]:[])}}}function Cp(e,t){let r=-1;const n=[];for(;++r<t.length;)(t[r].add==="after"?e:n).push(t[r]);Le(e,0,0,n)}function bo(e,t){const r=Number.parseInt(e,t);return r<9||r===11||r>13&&r<32||r>126&&r<160||r>55295&&r<57344||r>64975&&r<65008||(r&65535)===65535||(r&65535)===65534||r>1114111?"�":String.fromCodePoint(r)}function Ve(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Te=ot(/[A-Za-z]/),xe=ot(/[\dA-Za-z]/),Ip=ot(/[#-'*+\--9=?A-Z^-~]/);function $r(e){return e!==null&&(e<32||e===127)}const ri=ot(/\d/),Ep=ot(/[\dA-Fa-f]/),Ap=ot(/[!-/:-@[-`{-~]/);function q(e){return e!==null&&e<-2}function te(e){return e!==null&&(e<0||e===32)}function Y(e){return e===-2||e===-1||e===32}const Hr=ot(new RegExp("\\p{P}|\\p{S}","u")),mt=ot(/\s/);function ot(e){return t;function t(r){return r!==null&&r>-1&&e.test(String.fromCharCode(r))}}function Dt(e){const t=[];let r=-1,n=0,i=0;for(;++r<e.length;){const s=e.charCodeAt(r);let a="";if(s===37&&xe(e.charCodeAt(r+1))&&xe(e.charCodeAt(r+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(a=String.fromCharCode(s));else if(s>55295&&s<57344){const o=e.charCodeAt(r+1);s<56320&&o>56319&&o<57344?(a=String.fromCharCode(s,o),i=1):a="�"}else a=String.fromCharCode(s);a&&(t.push(e.slice(n,r),encodeURIComponent(a)),n=r+i+1,a=""),i&&(r+=i,i=0)}return t.join("")+e.slice(n)}function X(e,t,r,n){const i=n?n-1:Number.POSITIVE_INFINITY;let s=0;return a;function a(l){return Y(l)?(e.enter(r),o(l)):t(l)}function o(l){return Y(l)&&s++<i?(e.consume(l),o):(e.exit(r),t(l))}}const Pp={tokenize:Mp};function Mp(e){const t=e.attempt(this.parser.constructs.contentInitial,n,i);let r;return t;function n(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),X(e,t,"linePrefix")}function i(o){return e.enter("paragraph"),s(o)}function s(o){const l=e.enter("chunkText",{contentType:"text",previous:r});return r&&(r.next=l),r=l,a(o)}function a(o){if(o===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(o);return}return q(o)?(e.consume(o),e.exit("chunkText"),s):(e.consume(o),a)}}const Lp={tokenize:Np},wo={tokenize:Dp};function Np(e){const t=this,r=[];let n=0,i,s,a;return o;function o(_){if(n<r.length){const F=r[n];return t.containerState=F[1],e.attempt(F[0].continuation,l,u)(_)}return u(_)}function l(_){if(n++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&C();const F=t.events.length;let B=F,I;for(;B--;)if(t.events[B][0]==="exit"&&t.events[B][1].type==="chunkFlow"){I=t.events[B][1].end;break}b(n);let z=F;for(;z<t.events.length;)t.events[z][1].end=m({},I),z++;return Le(t.events,B+1,0,t.events.slice(F)),t.events.length=z,u(_)}return o(_)}function u(_){if(n===r.length){if(!i)return f(_);if(i.currentConstruct&&i.currentConstruct.concrete)return g(_);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(wo,d,c)(_)}function d(_){return i&&C(),b(n),f(_)}function c(_){return t.parser.lazy[t.now().line]=n!==r.length,a=t.now().offset,g(_)}function f(_){return t.containerState={},e.attempt(wo,h,g)(_)}function h(_){return n++,r.push([t.currentConstruct,t.containerState]),f(_)}function g(_){if(_===null){i&&C(),b(0),e.consume(_);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),S(_)}function S(_){if(_===null){w(e.exit("chunkFlow"),!0),b(0),e.consume(_);return}return q(_)?(e.consume(_),w(e.exit("chunkFlow")),n=0,t.interrupt=void 0,o):(e.consume(_),S)}function w(_,F){const B=t.sliceStream(_);if(F&&B.push(null),_.previous=s,s&&(s.next=_),s=_,i.defineSkip(_.start),i.write(B),t.parser.lazy[_.start.line]){let I=i.events.length;for(;I--;)if(i.events[I][1].start.offset<a&&(!i.events[I][1].end||i.events[I][1].end.offset>a))return;const z=t.events.length;let j=z,$,k;for(;j--;)if(t.events[j][0]==="exit"&&t.events[j][1].type==="chunkFlow"){if($){k=t.events[j][1].end;break}$=!0}for(b(n),I=z;I<t.events.length;)t.events[I][1].end=m({},k),I++;Le(t.events,j+1,0,t.events.slice(z)),t.events.length=I}}function b(_){let F=r.length;for(;F-- >_;){const B=r[F];t.containerState=B[1],B[0].exit.call(t,e)}r.length=_}function C(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Dp(e,t,r){return X(e,e.attempt(this.parser.constructs.document,t,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ot(e){if(e===null||te(e)||mt(e))return 1;if(Hr(e))return 2}function qr(e,t,r){const n=[];let i=-1;for(;++i<e.length;){const s=e[i].resolveAll;s&&!n.includes(s)&&(t=s(t,r),n.push(s))}return t}const ni={name:"attention",resolveAll:Op,tokenize:Fp};function Op(e,t){let r=-1,n,i,s,a,o,l,u,d;for(;++r<e.length;)if(e[r][0]==="enter"&&e[r][1].type==="attentionSequence"&&e[r][1]._close){for(n=r;n--;)if(e[n][0]==="exit"&&e[n][1].type==="attentionSequence"&&e[n][1]._open&&t.sliceSerialize(e[n][1]).charCodeAt(0)===t.sliceSerialize(e[r][1]).charCodeAt(0)){if((e[n][1]._close||e[r][1]._open)&&(e[r][1].end.offset-e[r][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[r][1].end.offset-e[r][1].start.offset)%3))continue;l=e[n][1].end.offset-e[n][1].start.offset>1&&e[r][1].end.offset-e[r][1].start.offset>1?2:1;const c=m({},e[n][1].end),f=m({},e[r][1].start);xo(c,-l),xo(f,l),a={type:l>1?"strongSequence":"emphasisSequence",start:c,end:m({},e[n][1].end)},o={type:l>1?"strongSequence":"emphasisSequence",start:m({},e[r][1].start),end:f},s={type:l>1?"strongText":"emphasisText",start:m({},e[n][1].end),end:m({},e[r][1].start)},i={type:l>1?"strong":"emphasis",start:m({},a.start),end:m({},o.end)},e[n][1].end=m({},a.start),e[r][1].start=m({},o.end),u=[],e[n][1].end.offset-e[n][1].start.offset&&(u=Be(u,[["enter",e[n][1],t],["exit",e[n][1],t]])),u=Be(u,[["enter",i,t],["enter",a,t],["exit",a,t],["enter",s,t]]),u=Be(u,qr(t.parser.constructs.insideSpan.null,e.slice(n+1,r),t)),u=Be(u,[["exit",s,t],["enter",o,t],["exit",o,t],["exit",i,t]]),e[r][1].end.offset-e[r][1].start.offset?(d=2,u=Be(u,[["enter",e[r][1],t],["exit",e[r][1],t]])):d=0,Le(e,n-1,r-n+3,u),r=n+u.length-d-2;break}}for(r=-1;++r<e.length;)e[r][1].type==="attentionSequence"&&(e[r][1].type="data");return e}function Fp(e,t){const r=this.parser.constructs.attentionMarkers.null,n=this.previous,i=Ot(n);let s;return a;function a(l){return s=l,e.enter("attentionSequence"),o(l)}function o(l){if(l===s)return e.consume(l),o;const u=e.exit("attentionSequence"),d=Ot(l),c=!d||d===2&&i||r.includes(l),f=!i||i===2&&d||r.includes(n);return u._open=!!(s===42?c:c&&(i||!f)),u._close=!!(s===42?f:f&&(d||!c)),t(l)}}function xo(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Bp={name:"autolink",tokenize:zp};function zp(e,t,r){let n=0;return i;function i(h){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(h){return Te(h)?(e.consume(h),a):h===64?r(h):u(h)}function a(h){return h===43||h===45||h===46||xe(h)?(n=1,o(h)):u(h)}function o(h){return h===58?(e.consume(h),n=0,l):(h===43||h===45||h===46||xe(h))&&n++<32?(e.consume(h),o):(n=0,u(h))}function l(h){return h===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):h===null||h===32||h===60||$r(h)?r(h):(e.consume(h),l)}function u(h){return h===64?(e.consume(h),d):Ip(h)?(e.consume(h),u):r(h)}function d(h){return xe(h)?c(h):r(h)}function c(h){return h===46?(e.consume(h),n=0,d):h===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):f(h)}function f(h){if((h===45||xe(h))&&n++<63){const g=h===45?f:c;return e.consume(h),g}return r(h)}}const ar={partial:!0,tokenize:Rp};function Rp(e,t,r){return n;function n(s){return Y(s)?X(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||q(s)?t(s):r(s)}}const vo={continuation:{tokenize:Up},exit:$p,name:"blockQuote",tokenize:jp};function jp(e,t,r){const n=this;return i;function i(a){if(a===62){const o=n.containerState;return o.open||(e.enter("blockQuote",{_container:!0}),o.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),s}return r(a)}function s(a){return Y(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function Up(e,t,r){const n=this;return i;function i(a){return Y(a)?X(e,s,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):s(a)}function s(a){return e.attempt(vo,t,r)(a)}}function $p(e){e.exit("blockQuote")}const So={name:"characterEscape",tokenize:Hp};function Hp(e,t,r){return n;function n(s){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(s),e.exit("escapeMarker"),i}function i(s){return Ap(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):r(s)}}const ko={name:"characterReference",tokenize:qp};function qp(e,t,r){const n=this;let i=0,s,a;return o;function o(c){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(c),e.exit("characterReferenceMarker"),l}function l(c){return c===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(c),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),s=31,a=xe,d(c))}function u(c){return c===88||c===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(c),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,a=Ep,d):(e.enter("characterReferenceValue"),s=7,a=ri,d(c))}function d(c){if(c===59&&i){const f=e.exit("characterReferenceValue");return a===xe&&!ti(n.sliceSerialize(f))?r(c):(e.enter("characterReferenceMarker"),e.consume(c),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(c)&&i++<s?(e.consume(c),d):r(c)}}const _o={partial:!0,tokenize:Wp},To={concrete:!0,name:"codeFenced",tokenize:Vp};function Vp(e,t,r){const n=this,i={partial:!0,tokenize:B};let s=0,a=0,o;return l;function l(I){return u(I)}function u(I){const z=n.events[n.events.length-1];return s=z&&z[1].type==="linePrefix"?z[2].sliceSerialize(z[1],!0).length:0,o=I,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),d(I)}function d(I){return I===o?(a++,e.consume(I),d):a<3?r(I):(e.exit("codeFencedFenceSequence"),Y(I)?X(e,c,"whitespace")(I):c(I))}function c(I){return I===null||q(I)?(e.exit("codeFencedFence"),n.interrupt?t(I):e.check(_o,S,F)(I)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),f(I))}function f(I){return I===null||q(I)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c(I)):Y(I)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),X(e,h,"whitespace")(I)):I===96&&I===o?r(I):(e.consume(I),f)}function h(I){return I===null||q(I)?c(I):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(I))}function g(I){return I===null||q(I)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),c(I)):I===96&&I===o?r(I):(e.consume(I),g)}function S(I){return e.attempt(i,F,w)(I)}function w(I){return e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),b}function b(I){return s>0&&Y(I)?X(e,C,"linePrefix",s+1)(I):C(I)}function C(I){return I===null||q(I)?e.check(_o,S,F)(I):(e.enter("codeFlowValue"),_(I))}function _(I){return I===null||q(I)?(e.exit("codeFlowValue"),C(I)):(e.consume(I),_)}function F(I){return e.exit("codeFenced"),t(I)}function B(I,z,j){let $=0;return k;function k(D){return I.enter("lineEnding"),I.consume(D),I.exit("lineEnding"),N}function N(D){return I.enter("codeFencedFence"),Y(D)?X(I,M,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):M(D)}function M(D){return D===o?(I.enter("codeFencedFenceSequence"),V(D)):j(D)}function V(D){return D===o?($++,I.consume(D),V):$>=a?(I.exit("codeFencedFenceSequence"),Y(D)?X(I,R,"whitespace")(D):R(D)):j(D)}function R(D){return D===null||q(D)?(I.exit("codeFencedFence"),z(D)):j(D)}}}function Wp(e,t,r){const n=this;return i;function i(a){return a===null?r(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s)}function s(a){return n.parser.lazy[n.now().line]?r(a):t(a)}}const ii={name:"codeIndented",tokenize:Gp},Jp={partial:!0,tokenize:Yp};function Gp(e,t,r){const n=this;return i;function i(u){return e.enter("codeIndented"),X(e,s,"linePrefix",5)(u)}function s(u){const d=n.events[n.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?a(u):r(u)}function a(u){return u===null?l(u):q(u)?e.attempt(Jp,a,l)(u):(e.enter("codeFlowValue"),o(u))}function o(u){return u===null||q(u)?(e.exit("codeFlowValue"),a(u)):(e.consume(u),o)}function l(u){return e.exit("codeIndented"),t(u)}}function Yp(e,t,r){const n=this;return i;function i(a){return n.parser.lazy[n.now().line]?r(a):q(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):X(e,s,"linePrefix",5)(a)}function s(a){const o=n.events[n.events.length-1];return o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(a):q(a)?i(a):r(a)}}const Kp={name:"codeText",previous:Qp,resolve:Xp,tokenize:Zp};function Xp(e){let t=e.length-4,r=3,n,i;if((e[r][1].type==="lineEnding"||e[r][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(n=r;++n<t;)if(e[n][1].type==="codeTextData"){e[r][1].type="codeTextPadding",e[t][1].type="codeTextPadding",r+=2,t-=2;break}}for(n=r-1,t++;++n<=t;)i===void 0?n!==t&&e[n][1].type!=="lineEnding"&&(i=n):(n===t||e[n][1].type==="lineEnding")&&(e[i][1].type="codeTextData",n!==i+2&&(e[i][1].end=e[n-1][1].end,e.splice(i+2,n-i-2),t-=n-i-2,n=i+2),i=void 0);return e}function Qp(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Zp(e,t,r){let n=0,i,s;return a;function a(c){return e.enter("codeText"),e.enter("codeTextSequence"),o(c)}function o(c){return c===96?(e.consume(c),n++,o):(e.exit("codeTextSequence"),l(c))}function l(c){return c===null?r(c):c===32?(e.enter("space"),e.consume(c),e.exit("space"),l):c===96?(s=e.enter("codeTextSequence"),i=0,d(c)):q(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),l):(e.enter("codeTextData"),u(c))}function u(c){return c===null||c===32||c===96||q(c)?(e.exit("codeTextData"),l(c)):(e.consume(c),u)}function d(c){return c===96?(e.consume(c),i++,d):i===n?(e.exit("codeTextSequence"),e.exit("codeText"),t(c)):(s.type="codeTextData",u(c))}}class em{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,r){const n=r==null?Number.POSITIVE_INFINITY:r;return n<this.left.length?this.left.slice(t,n):t>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(t,r,n){const i=r||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return n&&or(this.left,n),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),or(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),or(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const r=this.left.splice(t,Number.POSITIVE_INFINITY);or(this.right,r.reverse())}else{const r=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);or(this.left,r.reverse())}}}function or(e,t){let r=0;if(t.length<1e4)e.push(...t);else for(;r<t.length;)e.push(...t.slice(r,r+1e4)),r+=1e4}function Co(e){const t={};let r=-1,n,i,s,a,o,l,u;const d=new em(e);for(;++r<d.length;){for(;r in t;)r=t[r];if(n=d.get(r),r&&n[1].type==="chunkFlow"&&d.get(r-1)[1].type==="listItemPrefix"&&(l=n[1]._tokenizer.events,s=0,s<l.length&&l[s][1].type==="lineEndingBlank"&&(s+=2),s<l.length&&l[s][1].type==="content"))for(;++s<l.length&&l[s][1].type!=="content";)l[s][1].type==="chunkText"&&(l[s][1]._isInFirstContentOfListItem=!0,s++);if(n[0]==="enter")n[1].contentType&&(Object.assign(t,tm(d,r)),r=t[r],u=!0);else if(n[1]._container){for(s=r,i=void 0;s--;)if(a=d.get(s),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(i&&(d.get(i)[1].type="lineEndingBlank"),a[1].type="lineEnding",i=s);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;i&&(n[1].end=m({},d.get(i)[1].start),o=d.slice(i,r),o.unshift(n),d.splice(i,r-i+1,o))}}return Le(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!u}function tm(e,t){const r=e.get(t)[1],n=e.get(t)[2];let i=t-1;const s=[];let a=r._tokenizer;a||(a=n.parser[r.contentType](r.start),r._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const o=a.events,l=[],u={};let d,c,f=-1,h=r,g=0,S=0;const w=[S];for(;h;){for(;e.get(++i)[1]!==h;);s.push(i),h._tokenizer||(d=n.sliceStream(h),h.next||d.push(null),c&&a.defineSkip(h.start),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(d),h._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),c=h,h=h.next}for(h=r;++f<o.length;)o[f][0]==="exit"&&o[f-1][0]==="enter"&&o[f][1].type===o[f-1][1].type&&o[f][1].start.line!==o[f][1].end.line&&(S=f+1,w.push(S),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(a.events=[],h?(h._tokenizer=void 0,h.previous=void 0):w.pop(),f=w.length;f--;){const b=o.slice(w[f],w[f+1]),C=s.pop();l.push([C,C+b.length-1]),e.splice(C,2,b)}for(l.reverse(),f=-1;++f<l.length;)u[g+l[f][0]]=g+l[f][1],g+=l[f][1]-l[f][0]-1;return u}const rm={resolve:im,tokenize:sm},nm={partial:!0,tokenize:am};function im(e){return Co(e),e}function sm(e,t){let r;return n;function n(o){return e.enter("content"),r=e.enter("chunkContent",{contentType:"content"}),i(o)}function i(o){return o===null?s(o):q(o)?e.check(nm,a,s)(o):(e.consume(o),i)}function s(o){return e.exit("chunkContent"),e.exit("content"),t(o)}function a(o){return e.consume(o),e.exit("chunkContent"),r.next=e.enter("chunkContent",{contentType:"content",previous:r}),r=r.next,i}}function am(e,t,r){const n=this;return i;function i(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),X(e,s,"linePrefix")}function s(a){if(a===null||q(a))return r(a);const o=n.events[n.events.length-1];return!n.parser.constructs.disable.null.includes("codeIndented")&&o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(a):e.interrupt(n.parser.constructs.flow,r,t)(a)}}function Io(e,t,r,n,i,s,a,o,l){const u=l||Number.POSITIVE_INFINITY;let d=0;return c;function c(b){return b===60?(e.enter(n),e.enter(i),e.enter(s),e.consume(b),e.exit(s),f):b===null||b===32||b===41||$r(b)?r(b):(e.enter(n),e.enter(a),e.enter(o),e.enter("chunkString",{contentType:"string"}),S(b))}function f(b){return b===62?(e.enter(s),e.consume(b),e.exit(s),e.exit(i),e.exit(n),t):(e.enter(o),e.enter("chunkString",{contentType:"string"}),h(b))}function h(b){return b===62?(e.exit("chunkString"),e.exit(o),f(b)):b===null||b===60||q(b)?r(b):(e.consume(b),b===92?g:h)}function g(b){return b===60||b===62||b===92?(e.consume(b),h):h(b)}function S(b){return!d&&(b===null||b===41||te(b))?(e.exit("chunkString"),e.exit(o),e.exit(a),e.exit(n),t(b)):d<u&&b===40?(e.consume(b),d++,S):b===41?(e.consume(b),d--,S):b===null||b===32||b===40||$r(b)?r(b):(e.consume(b),b===92?w:S)}function w(b){return b===40||b===41||b===92?(e.consume(b),S):S(b)}}function Eo(e,t,r,n,i,s){const a=this;let o=0,l;return u;function u(h){return e.enter(n),e.enter(i),e.consume(h),e.exit(i),e.enter(s),d}function d(h){return o>999||h===null||h===91||h===93&&!l||h===94&&!o&&"_hiddenFootnoteSupport"in a.parser.constructs?r(h):h===93?(e.exit(s),e.enter(i),e.consume(h),e.exit(i),e.exit(n),t):q(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),c(h))}function c(h){return h===null||h===91||h===93||q(h)||o++>999?(e.exit("chunkString"),d(h)):(e.consume(h),l||(l=!Y(h)),h===92?f:c)}function f(h){return h===91||h===92||h===93?(e.consume(h),o++,c):c(h)}}function Ao(e,t,r,n,i,s){let a;return o;function o(f){return f===34||f===39||f===40?(e.enter(n),e.enter(i),e.consume(f),e.exit(i),a=f===40?41:f,l):r(f)}function l(f){return f===a?(e.enter(i),e.consume(f),e.exit(i),e.exit(n),t):(e.enter(s),u(f))}function u(f){return f===a?(e.exit(s),l(a)):f===null?r(f):q(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),X(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(f))}function d(f){return f===a||f===null||q(f)?(e.exit("chunkString"),u(f)):(e.consume(f),f===92?c:d)}function c(f){return f===a||f===92?(e.consume(f),d):d(f)}}function lr(e,t){let r;return n;function n(i){return q(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),r=!0,n):Y(i)?X(e,n,r?"linePrefix":"lineSuffix")(i):t(i)}}const om={name:"definition",tokenize:um},lm={partial:!0,tokenize:cm};function um(e,t,r){const n=this;let i;return s;function s(h){return e.enter("definition"),a(h)}function a(h){return Eo.call(n,e,o,r,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function o(h){return i=Ve(n.sliceSerialize(n.events[n.events.length-1][1]).slice(1,-1)),h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),l):r(h)}function l(h){return te(h)?lr(e,u)(h):u(h)}function u(h){return Io(e,d,r,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function d(h){return e.attempt(lm,c,c)(h)}function c(h){return Y(h)?X(e,f,"whitespace")(h):f(h)}function f(h){return h===null||q(h)?(e.exit("definition"),n.parser.defined.push(i),t(h)):r(h)}}function cm(e,t,r){return n;function n(o){return te(o)?lr(e,i)(o):r(o)}function i(o){return Ao(e,s,r,"definitionTitle","definitionTitleMarker","definitionTitleString")(o)}function s(o){return Y(o)?X(e,a,"whitespace")(o):a(o)}function a(o){return o===null||q(o)?t(o):r(o)}}const dm={name:"hardBreakEscape",tokenize:hm};function hm(e,t,r){return n;function n(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return q(s)?(e.exit("hardBreakEscape"),t(s)):r(s)}}const fm={name:"headingAtx",resolve:pm,tokenize:mm};function pm(e,t){let r=e.length-2,n=3,i,s;return e[n][1].type==="whitespace"&&(n+=2),r-2>n&&e[r][1].type==="whitespace"&&(r-=2),e[r][1].type==="atxHeadingSequence"&&(n===r-1||r-4>n&&e[r-2][1].type==="whitespace")&&(r-=n+1===r?2:4),r>n&&(i={type:"atxHeadingText",start:e[n][1].start,end:e[r][1].end},s={type:"chunkText",start:e[n][1].start,end:e[r][1].end,contentType:"text"},Le(e,n,r-n+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function mm(e,t,r){let n=0;return i;function i(d){return e.enter("atxHeading"),s(d)}function s(d){return e.enter("atxHeadingSequence"),a(d)}function a(d){return d===35&&n++<6?(e.consume(d),a):d===null||te(d)?(e.exit("atxHeadingSequence"),o(d)):r(d)}function o(d){return d===35?(e.enter("atxHeadingSequence"),l(d)):d===null||q(d)?(e.exit("atxHeading"),t(d)):Y(d)?X(e,o,"whitespace")(d):(e.enter("atxHeadingText"),u(d))}function l(d){return d===35?(e.consume(d),l):(e.exit("atxHeadingSequence"),o(d))}function u(d){return d===null||d===35||te(d)?(e.exit("atxHeadingText"),o(d)):(e.consume(d),u)}}const gm=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Po=["pre","script","style","textarea"],ym={concrete:!0,name:"htmlFlow",resolveTo:xm,tokenize:vm},bm={partial:!0,tokenize:km},wm={partial:!0,tokenize:Sm};function xm(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function vm(e,t,r){const n=this;let i,s,a,o,l;return u;function u(v){return d(v)}function d(v){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(v),c}function c(v){return v===33?(e.consume(v),f):v===47?(e.consume(v),s=!0,S):v===63?(e.consume(v),i=3,n.interrupt?t:x):Te(v)?(e.consume(v),a=String.fromCharCode(v),w):r(v)}function f(v){return v===45?(e.consume(v),i=2,h):v===91?(e.consume(v),i=5,o=0,g):Te(v)?(e.consume(v),i=4,n.interrupt?t:x):r(v)}function h(v){return v===45?(e.consume(v),n.interrupt?t:x):r(v)}function g(v){const ve="CDATA[";return v===ve.charCodeAt(o++)?(e.consume(v),o===ve.length?n.interrupt?t:M:g):r(v)}function S(v){return Te(v)?(e.consume(v),a=String.fromCharCode(v),w):r(v)}function w(v){if(v===null||v===47||v===62||te(v)){const ve=v===47,Re=a.toLowerCase();return!ve&&!s&&Po.includes(Re)?(i=1,n.interrupt?t(v):M(v)):gm.includes(a.toLowerCase())?(i=6,ve?(e.consume(v),b):n.interrupt?t(v):M(v)):(i=7,n.interrupt&&!n.parser.lazy[n.now().line]?r(v):s?C(v):_(v))}return v===45||xe(v)?(e.consume(v),a+=String.fromCharCode(v),w):r(v)}function b(v){return v===62?(e.consume(v),n.interrupt?t:M):r(v)}function C(v){return Y(v)?(e.consume(v),C):k(v)}function _(v){return v===47?(e.consume(v),k):v===58||v===95||Te(v)?(e.consume(v),F):Y(v)?(e.consume(v),_):k(v)}function F(v){return v===45||v===46||v===58||v===95||xe(v)?(e.consume(v),F):B(v)}function B(v){return v===61?(e.consume(v),I):Y(v)?(e.consume(v),B):_(v)}function I(v){return v===null||v===60||v===61||v===62||v===96?r(v):v===34||v===39?(e.consume(v),l=v,z):Y(v)?(e.consume(v),I):j(v)}function z(v){return v===l?(e.consume(v),l=null,$):v===null||q(v)?r(v):(e.consume(v),z)}function j(v){return v===null||v===34||v===39||v===47||v===60||v===61||v===62||v===96||te(v)?B(v):(e.consume(v),j)}function $(v){return v===47||v===62||Y(v)?_(v):r(v)}function k(v){return v===62?(e.consume(v),N):r(v)}function N(v){return v===null||q(v)?M(v):Y(v)?(e.consume(v),N):r(v)}function M(v){return v===45&&i===2?(e.consume(v),Q):v===60&&i===1?(e.consume(v),se):v===62&&i===4?(e.consume(v),ye):v===63&&i===3?(e.consume(v),x):v===93&&i===5?(e.consume(v),fe):q(v)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(bm,Ie,V)(v)):v===null||q(v)?(e.exit("htmlFlowData"),V(v)):(e.consume(v),M)}function V(v){return e.check(wm,R,Ie)(v)}function R(v){return e.enter("lineEnding"),e.consume(v),e.exit("lineEnding"),D}function D(v){return v===null||q(v)?V(v):(e.enter("htmlFlowData"),M(v))}function Q(v){return v===45?(e.consume(v),x):M(v)}function se(v){return v===47?(e.consume(v),a="",ge):M(v)}function ge(v){if(v===62){const ve=a.toLowerCase();return Po.includes(ve)?(e.consume(v),ye):M(v)}return Te(v)&&a.length<8?(e.consume(v),a+=String.fromCharCode(v),ge):M(v)}function fe(v){return v===93?(e.consume(v),x):M(v)}function x(v){return v===62?(e.consume(v),ye):v===45&&i===2?(e.consume(v),x):M(v)}function ye(v){return v===null||q(v)?(e.exit("htmlFlowData"),Ie(v)):(e.consume(v),ye)}function Ie(v){return e.exit("htmlFlow"),t(v)}}function Sm(e,t,r){const n=this;return i;function i(a){return q(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):r(a)}function s(a){return n.parser.lazy[n.now().line]?r(a):t(a)}}function km(e,t,r){return n;function n(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(ar,t,r)}}const _m={name:"htmlText",tokenize:Tm};function Tm(e,t,r){const n=this;let i,s,a;return o;function o(x){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(x),l}function l(x){return x===33?(e.consume(x),u):x===47?(e.consume(x),B):x===63?(e.consume(x),_):Te(x)?(e.consume(x),j):r(x)}function u(x){return x===45?(e.consume(x),d):x===91?(e.consume(x),s=0,g):Te(x)?(e.consume(x),C):r(x)}function d(x){return x===45?(e.consume(x),h):r(x)}function c(x){return x===null?r(x):x===45?(e.consume(x),f):q(x)?(a=c,se(x)):(e.consume(x),c)}function f(x){return x===45?(e.consume(x),h):c(x)}function h(x){return x===62?Q(x):x===45?f(x):c(x)}function g(x){const ye="CDATA[";return x===ye.charCodeAt(s++)?(e.consume(x),s===ye.length?S:g):r(x)}function S(x){return x===null?r(x):x===93?(e.consume(x),w):q(x)?(a=S,se(x)):(e.consume(x),S)}function w(x){return x===93?(e.consume(x),b):S(x)}function b(x){return x===62?Q(x):x===93?(e.consume(x),b):S(x)}function C(x){return x===null||x===62?Q(x):q(x)?(a=C,se(x)):(e.consume(x),C)}function _(x){return x===null?r(x):x===63?(e.consume(x),F):q(x)?(a=_,se(x)):(e.consume(x),_)}function F(x){return x===62?Q(x):_(x)}function B(x){return Te(x)?(e.consume(x),I):r(x)}function I(x){return x===45||xe(x)?(e.consume(x),I):z(x)}function z(x){return q(x)?(a=z,se(x)):Y(x)?(e.consume(x),z):Q(x)}function j(x){return x===45||xe(x)?(e.consume(x),j):x===47||x===62||te(x)?$(x):r(x)}function $(x){return x===47?(e.consume(x),Q):x===58||x===95||Te(x)?(e.consume(x),k):q(x)?(a=$,se(x)):Y(x)?(e.consume(x),$):Q(x)}function k(x){return x===45||x===46||x===58||x===95||xe(x)?(e.consume(x),k):N(x)}function N(x){return x===61?(e.consume(x),M):q(x)?(a=N,se(x)):Y(x)?(e.consume(x),N):$(x)}function M(x){return x===null||x===60||x===61||x===62||x===96?r(x):x===34||x===39?(e.consume(x),i=x,V):q(x)?(a=M,se(x)):Y(x)?(e.consume(x),M):(e.consume(x),R)}function V(x){return x===i?(e.consume(x),i=void 0,D):x===null?r(x):q(x)?(a=V,se(x)):(e.consume(x),V)}function R(x){return x===null||x===34||x===39||x===60||x===61||x===96?r(x):x===47||x===62||te(x)?$(x):(e.consume(x),R)}function D(x){return x===47||x===62||te(x)?$(x):r(x)}function Q(x){return x===62?(e.consume(x),e.exit("htmlTextData"),e.exit("htmlText"),t):r(x)}function se(x){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),ge}function ge(x){return Y(x)?X(e,fe,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(x):fe(x)}function fe(x){return e.enter("htmlTextData"),a(x)}}const si={name:"labelEnd",resolveAll:Am,resolveTo:Pm,tokenize:Mm},Cm={tokenize:Lm},Im={tokenize:Nm},Em={tokenize:Dm};function Am(e){let t=-1;const r=[];for(;++t<e.length;){const n=e[t][1];if(r.push(e[t]),n.type==="labelImage"||n.type==="labelLink"||n.type==="labelEnd"){const i=n.type==="labelImage"?4:2;n.type="data",t+=i}}return e.length!==r.length&&Le(e,0,e.length,r),e}function Pm(e,t){let r=e.length,n=0,i,s,a,o;for(;r--;)if(i=e[r][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[r][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(a){if(e[r][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=r,i.type!=="labelLink")){n=2;break}}else i.type==="labelEnd"&&(a=r);const l={type:e[s][1].type==="labelLink"?"link":"image",start:m({},e[s][1].start),end:m({},e[e.length-1][1].end)},u={type:"label",start:m({},e[s][1].start),end:m({},e[a][1].end)},d={type:"labelText",start:m({},e[s+n+2][1].end),end:m({},e[a-2][1].start)};return o=[["enter",l,t],["enter",u,t]],o=Be(o,e.slice(s+1,s+n+3)),o=Be(o,[["enter",d,t]]),o=Be(o,qr(t.parser.constructs.insideSpan.null,e.slice(s+n+4,a-3),t)),o=Be(o,[["exit",d,t],e[a-2],e[a-1],["exit",u,t]]),o=Be(o,e.slice(a+1)),o=Be(o,[["exit",l,t]]),Le(e,s,e.length,o),e}function Mm(e,t,r){const n=this;let i=n.events.length,s,a;for(;i--;)if((n.events[i][1].type==="labelImage"||n.events[i][1].type==="labelLink")&&!n.events[i][1]._balanced){s=n.events[i][1];break}return o;function o(f){return s?s._inactive?c(f):(a=n.parser.defined.includes(Ve(n.sliceSerialize({start:s.end,end:n.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(f),e.exit("labelMarker"),e.exit("labelEnd"),l):r(f)}function l(f){return f===40?e.attempt(Cm,d,a?d:c)(f):f===91?e.attempt(Im,d,a?u:c)(f):a?d(f):c(f)}function u(f){return e.attempt(Em,d,c)(f)}function d(f){return t(f)}function c(f){return s._balanced=!0,r(f)}}function Lm(e,t,r){return n;function n(c){return e.enter("resource"),e.enter("resourceMarker"),e.consume(c),e.exit("resourceMarker"),i}function i(c){return te(c)?lr(e,s)(c):s(c)}function s(c){return c===41?d(c):Io(e,a,o,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(c)}function a(c){return te(c)?lr(e,l)(c):d(c)}function o(c){return r(c)}function l(c){return c===34||c===39||c===40?Ao(e,u,r,"resourceTitle","resourceTitleMarker","resourceTitleString")(c):d(c)}function u(c){return te(c)?lr(e,d)(c):d(c)}function d(c){return c===41?(e.enter("resourceMarker"),e.consume(c),e.exit("resourceMarker"),e.exit("resource"),t):r(c)}}function Nm(e,t,r){const n=this;return i;function i(o){return Eo.call(n,e,s,a,"reference","referenceMarker","referenceString")(o)}function s(o){return n.parser.defined.includes(Ve(n.sliceSerialize(n.events[n.events.length-1][1]).slice(1,-1)))?t(o):r(o)}function a(o){return r(o)}}function Dm(e,t,r){return n;function n(s){return e.enter("reference"),e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),i}function i(s){return s===93?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),t):r(s)}}const Om={name:"labelStartImage",resolveAll:si.resolveAll,tokenize:Fm};function Fm(e,t,r){const n=this;return i;function i(o){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(o),e.exit("labelImageMarker"),s}function s(o){return o===91?(e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelImage"),a):r(o)}function a(o){return o===94&&"_hiddenFootnoteSupport"in n.parser.constructs?r(o):t(o)}}const Bm={name:"labelStartLink",resolveAll:si.resolveAll,tokenize:zm};function zm(e,t,r){const n=this;return i;function i(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),s}function s(a){return a===94&&"_hiddenFootnoteSupport"in n.parser.constructs?r(a):t(a)}}const ai={name:"lineEnding",tokenize:Rm};function Rm(e,t){return r;function r(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),X(e,t,"linePrefix")}}const Vr={name:"thematicBreak",tokenize:jm};function jm(e,t,r){let n=0,i;return s;function s(u){return e.enter("thematicBreak"),a(u)}function a(u){return i=u,o(u)}function o(u){return u===i?(e.enter("thematicBreakSequence"),l(u)):n>=3&&(u===null||q(u))?(e.exit("thematicBreak"),t(u)):r(u)}function l(u){return u===i?(e.consume(u),n++,l):(e.exit("thematicBreakSequence"),Y(u)?X(e,o,"whitespace")(u):o(u))}}const Ae={continuation:{tokenize:qm},exit:Wm,name:"list",tokenize:Hm},Um={partial:!0,tokenize:Jm},$m={partial:!0,tokenize:Vm};function Hm(e,t,r){const n=this,i=n.events[n.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,a=0;return o;function o(h){const g=n.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!n.containerState.marker||h===n.containerState.marker:ri(h)){if(n.containerState.type||(n.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),h===42||h===45?e.check(Vr,r,u)(h):u(h);if(!n.interrupt||h===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(h)}return r(h)}function l(h){return ri(h)&&++a<10?(e.consume(h),l):(!n.interrupt||a<2)&&(n.containerState.marker?h===n.containerState.marker:h===41||h===46)?(e.exit("listItemValue"),u(h)):r(h)}function u(h){return e.enter("listItemMarker"),e.consume(h),e.exit("listItemMarker"),n.containerState.marker=n.containerState.marker||h,e.check(ar,n.interrupt?r:d,e.attempt(Um,f,c))}function d(h){return n.containerState.initialBlankLine=!0,s++,f(h)}function c(h){return Y(h)?(e.enter("listItemPrefixWhitespace"),e.consume(h),e.exit("listItemPrefixWhitespace"),f):r(h)}function f(h){return n.containerState.size=s+n.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(h)}}function qm(e,t,r){const n=this;return n.containerState._closeFlow=void 0,e.check(ar,i,s);function i(o){return n.containerState.furtherBlankLines=n.containerState.furtherBlankLines||n.containerState.initialBlankLine,X(e,t,"listItemIndent",n.containerState.size+1)(o)}function s(o){return n.containerState.furtherBlankLines||!Y(o)?(n.containerState.furtherBlankLines=void 0,n.containerState.initialBlankLine=void 0,a(o)):(n.containerState.furtherBlankLines=void 0,n.containerState.initialBlankLine=void 0,e.attempt($m,t,a)(o))}function a(o){return n.containerState._closeFlow=!0,n.interrupt=void 0,X(e,e.attempt(Ae,t,r),"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o)}}function Vm(e,t,r){const n=this;return X(e,i,"listItemIndent",n.containerState.size+1);function i(s){const a=n.events[n.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===n.containerState.size?t(s):r(s)}}function Wm(e){e.exit(this.containerState.type)}function Jm(e,t,r){const n=this;return X(e,i,"listItemPrefixWhitespace",n.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const a=n.events[n.events.length-1];return!Y(s)&&a&&a[1].type==="listItemPrefixWhitespace"?t(s):r(s)}}const Mo={name:"setextUnderline",resolveTo:Gm,tokenize:Ym};function Gm(e,t){let r=e.length,n,i,s;for(;r--;)if(e[r][0]==="enter"){if(e[r][1].type==="content"){n=r;break}e[r][1].type==="paragraph"&&(i=r)}else e[r][1].type==="content"&&e.splice(r,1),!s&&e[r][1].type==="definition"&&(s=r);const a={type:"setextHeading",start:m({},e[n][1].start),end:m({},e[e.length-1][1].end)};return e[i][1].type="setextHeadingText",s?(e.splice(i,0,["enter",a,t]),e.splice(s+1,0,["exit",e[n][1],t]),e[n][1].end=m({},e[s][1].end)):e[n][1]=a,e.push(["exit",a,t]),e}function Ym(e,t,r){const n=this;let i;return s;function s(u){let d=n.events.length,c;for(;d--;)if(n.events[d][1].type!=="lineEnding"&&n.events[d][1].type!=="linePrefix"&&n.events[d][1].type!=="content"){c=n.events[d][1].type==="paragraph";break}return!n.parser.lazy[n.now().line]&&(n.interrupt||c)?(e.enter("setextHeadingLine"),i=u,a(u)):r(u)}function a(u){return e.enter("setextHeadingLineSequence"),o(u)}function o(u){return u===i?(e.consume(u),o):(e.exit("setextHeadingLineSequence"),Y(u)?X(e,l,"lineSuffix")(u):l(u))}function l(u){return u===null||q(u)?(e.exit("setextHeadingLine"),t(u)):r(u)}}const Km={tokenize:Xm};function Xm(e){const t=this,r=e.attempt(ar,n,e.attempt(this.parser.constructs.flowInitial,i,X(e,e.attempt(this.parser.constructs.flow,i,e.attempt(rm,i)),"linePrefix")));return r;function n(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,r}function i(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,r}}const Qm={resolveAll:No()},Zm=Lo("string"),eg=Lo("text");function Lo(e){return{resolveAll:No(e==="text"?tg:void 0),tokenize:t};function t(r){const n=this,i=this.parser.constructs[e],s=r.attempt(i,a,o);return a;function a(d){return u(d)?s(d):o(d)}function o(d){if(d===null){r.consume(d);return}return r.enter("data"),r.consume(d),l}function l(d){return u(d)?(r.exit("data"),s(d)):(r.consume(d),l)}function u(d){if(d===null)return!0;const c=i[d];let f=-1;if(c)for(;++f<c.length;){const h=c[f];if(!h.previous||h.previous.call(n,n.previous))return!0}return!1}}}function No(e){return t;function t(r,n){let i=-1,s;for(;++i<=r.length;)s===void 0?r[i]&&r[i][1].type==="data"&&(s=i,i++):(!r[i]||r[i][1].type!=="data")&&(i!==s+2&&(r[s][1].end=r[i-1][1].end,r.splice(s+2,i-s-2),i=s+2),s=void 0);return e?e(r,n):r}}function tg(e,t){let r=0;for(;++r<=e.length;)if((r===e.length||e[r][1].type==="lineEnding")&&e[r-1][1].type==="data"){const n=e[r-1][1],i=t.sliceStream(n);let s=i.length,a=-1,o=0,l;for(;s--;){const u=i[s];if(typeof u=="string"){for(a=u.length;u.charCodeAt(a-1)===32;)o++,a--;if(a)break;a=-1}else if(u===-2)l=!0,o++;else if(u!==-1){s++;break}}if(t._contentTypeTextTrailing&&r===e.length&&(o=0),o){const u={type:r===e.length||l||o<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?a:n.start._bufferIndex+a,_index:n.start._index+s,line:n.end.line,column:n.end.column-o,offset:n.end.offset-o},end:m({},n.end)};n.end=m({},u.start),n.start.offset===n.end.offset?Object.assign(n,u):(e.splice(r,0,["enter",u,t],["exit",u,t]),r+=2)}r++}return e}const rg=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:{null:[42,95]},contentInitial:{91:om},disable:{null:[]},document:{42:Ae,43:Ae,45:Ae,48:Ae,49:Ae,50:Ae,51:Ae,52:Ae,53:Ae,54:Ae,55:Ae,56:Ae,57:Ae,62:vo},flow:{35:fm,42:Vr,45:[Mo,Vr],60:ym,61:Mo,95:Vr,96:To,126:To},flowInitial:{[-2]:ii,[-1]:ii,32:ii},insideSpan:{null:[ni,Qm]},string:{38:ko,92:So},text:{[-5]:ai,[-4]:ai,[-3]:ai,33:Om,38:ko,42:ni,60:[Bp,_m],91:Bm,92:[dm,So],93:si,95:ni,96:Kp}},Symbol.toStringTag,{value:"Module"}));function ng(e,t,r){let n={_bufferIndex:-1,_index:0,line:r&&r.line||1,column:r&&r.column||1,offset:r&&r.offset||0};const i={},s=[];let a=[],o=[];const l={attempt:z(B),check:z(I),consume:C,enter:_,exit:F,interrupt:z(I,{interrupt:!0})},u={code:null,containerState:{},defineSkip:S,events:[],now:g,parser:e,previous:null,sliceSerialize:f,sliceStream:h,write:c};let d=t.tokenize.call(u,l);return t.resolveAll&&s.push(t),u;function c(N){return a=Be(a,N),w(),a[a.length-1]!==null?[]:(j(t,0),u.events=qr(s,u.events,u),u.events)}function f(N,M){return sg(h(N),M)}function h(N){return ig(a,N)}function g(){const{_bufferIndex:N,_index:M,line:V,column:R,offset:D}=n;return{_bufferIndex:N,_index:M,line:V,column:R,offset:D}}function S(N){i[N.line]=N.column,k()}function w(){let N;for(;n._index<a.length;){const M=a[n._index];if(typeof M=="string")for(N=n._index,n._bufferIndex<0&&(n._bufferIndex=0);n._index===N&&n._bufferIndex<M.length;)b(M.charCodeAt(n._bufferIndex));else b(M)}}function b(N){d=d(N)}function C(N){q(N)?(n.line++,n.column=1,n.offset+=N===-3?2:1,k()):N!==-1&&(n.column++,n.offset++),n._bufferIndex<0?n._index++:(n._bufferIndex++,n._bufferIndex===a[n._index].length&&(n._bufferIndex=-1,n._index++)),u.previous=N}function _(N,M){const V=M||{};return V.type=N,V.start=g(),u.events.push(["enter",V,u]),o.push(V),V}function F(N){const M=o.pop();return M.end=g(),u.events.push(["exit",M,u]),M}function B(N,M){j(N,M.from)}function I(N,M){M.restore()}function z(N,M){return V;function V(R,D,Q){let se,ge,fe,x;return Array.isArray(R)?Ie(R):"tokenize"in R?Ie([R]):ye(R);function ye(le){return zt;function zt(Z){const je=Z!==null&&le[Z],pe=Z!==null&&le.null,bt=[...Array.isArray(je)?je:je?[je]:[],...Array.isArray(pe)?pe:pe?[pe]:[]];return Ie(bt)(Z)}}function Ie(le){return se=le,ge=0,le.length===0?Q:v(le[ge])}function v(le){return zt;function zt(Z){return x=$(),fe=le,le.partial||(u.currentConstruct=le),le.name&&u.parser.constructs.disable.null.includes(le.name)?Re():le.tokenize.call(M?Object.assign(Object.create(u),M):u,l,ve,Re)(Z)}}function ve(le){return N(fe,x),D}function Re(le){return x.restore(),++ge<se.length?v(se[ge]):Q}}}function j(N,M){N.resolveAll&&!s.includes(N)&&s.push(N),N.resolve&&Le(u.events,M,u.events.length-M,N.resolve(u.events.slice(M),u)),N.resolveTo&&(u.events=N.resolveTo(u.events,u))}function $(){const N=g(),M=u.previous,V=u.currentConstruct,R=u.events.length,D=Array.from(o);return{from:R,restore:Q};function Q(){n=N,u.previous=M,u.currentConstruct=V,u.events.length=R,o=D,k()}}function k(){n.line in i&&n.column<2&&(n.column=i[n.line],n.offset+=i[n.line]-1)}}function ig(e,t){const r=t.start._index,n=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let a;if(r===i)a=[e[r].slice(n,s)];else{if(a=e.slice(r,i),n>-1){const o=a[0];typeof o=="string"?a[0]=o.slice(n):a.shift()}s>0&&a.push(e[i].slice(0,s))}return a}function sg(e,t){let r=-1;const n=[];let i;for(;++r<e.length;){const s=e[r];let a;if(typeof s=="string")a=s;else switch(s){case-5:{a="\r";break}case-4:{a=`
9
+ `;break}case-3:{a=`\r
10
+ `;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&i)continue;a=" ";break}default:a=String.fromCharCode(s)}i=s===-2,n.push(a)}return n.join("")}function ag(e){const n={constructs:yo([rg,...(e||{}).extensions||[]]),content:i(Pp),defined:[],document:i(Lp),flow:i(Km),lazy:{},string:i(Zm),text:i(eg)};return n;function i(s){return a;function a(o){return ng(n,s,o)}}}function og(e){for(;!Co(e););return e}const Do=/[\0\t\n\r]/g;function lg(){let e=1,t="",r=!0,n;return i;function i(s,a,o){const l=[];let u,d,c,f,h;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(a||void 0).decode(s)),c=0,t="",r&&(s.charCodeAt(0)===65279&&c++,r=void 0);c<s.length;){if(Do.lastIndex=c,u=Do.exec(s),f=u&&u.index!==void 0?u.index:s.length,h=s.charCodeAt(f),!u){t=s.slice(c);break}if(h===10&&c===f&&n)l.push(-3),n=void 0;else switch(n&&(l.push(-5),n=void 0),c<f&&(l.push(s.slice(c,f)),e+=f-c),h){case 0:{l.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,l.push(-2);e++<d;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:n=!0,e=1}c=f+1}return o&&(n&&l.push(-5),t&&l.push(t),l.push(null)),l}}const ug=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function cg(e){return e.replace(ug,dg)}function dg(e,t,r){if(t)return t;if(r.charCodeAt(0)===35){const i=r.charCodeAt(1),s=i===120||i===88;return bo(r.slice(s?2:1),s?16:10)}return ti(r)||e}const Oo={}.hasOwnProperty;function hg(e,t,r){return typeof t!="string"&&(r=t,t=void 0),fg(r)(og(ag(r).document().write(lg()(e,t,!0))))}function fg(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(nu),autolinkProtocol:$,autolinkEmail:$,atxHeading:s(eu),blockQuote:s(pe),characterEscape:$,characterReference:$,codeFenced:s(bt),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:s(bt,a),codeText:s(nn,a),codeTextData:$,data:$,codeFlowValue:$,definition:s(sn),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:s(Ix),hardBreakEscape:s(tu),hardBreakTrailing:s(tu),htmlFlow:s(ru,a),htmlFlowData:$,htmlText:s(ru,a),htmlTextData:$,image:s(Ex),label:a,link:s(nu),listItem:s(Ax),listItemValue:f,listOrdered:s(iu,c),listUnordered:s(iu),paragraph:s(Px),reference:v,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:s(eu),strong:s(Mx),thematicBreak:s(Nx)},exit:{atxHeading:l(),atxHeadingSequence:B,autolink:l(),autolinkEmail:je,autolinkProtocol:Z,blockQuote:l(),characterEscapeValue:k,characterReferenceMarkerHexadecimal:Re,characterReferenceMarkerNumeric:Re,characterReferenceValue:le,characterReference:zt,codeFenced:l(w),codeFencedFence:S,codeFencedFenceInfo:h,codeFencedFenceMeta:g,codeFlowValue:k,codeIndented:l(b),codeText:l(D),codeTextData:k,data:k,definition:l(),definitionDestinationString:F,definitionLabelString:C,definitionTitleString:_,emphasis:l(),hardBreakEscape:l(M),hardBreakTrailing:l(M),htmlFlow:l(V),htmlFlowData:k,htmlText:l(R),htmlTextData:k,image:l(se),label:fe,labelText:ge,lineEnding:N,link:l(Q),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:ve,resourceDestinationString:x,resourceTitleString:ye,resource:Ie,setextHeading:l(j),setextHeadingLineSequence:z,setextHeadingText:I,strong:l(),thematicBreak:l()}};Fo(t,(e||{}).mdastExtensions||[]);const r={};return n;function n(A){let O={type:"root",children:[]};const W={stack:[O],tokenStack:[],config:t,enter:o,exit:u,buffer:a,resume:d,data:r},K=[];let re=-1;for(;++re<A.length;)if(A[re][1].type==="listOrdered"||A[re][1].type==="listUnordered")if(A[re][0]==="enter")K.push(re);else{const Je=K.pop();re=i(A,Je,re)}for(re=-1;++re<A.length;){const Je=t[A[re][0]];Oo.call(Je,A[re][1].type)&&Je[A[re][1].type].call(Object.assign({sliceSerialize:A[re][2].sliceSerialize},W),A[re][1])}if(W.tokenStack.length>0){const Je=W.tokenStack[W.tokenStack.length-1];(Je[1]||Bo).call(W,void 0,Je[0])}for(O.position={start:lt(A.length>0?A[0][1].start:{line:1,column:1,offset:0}),end:lt(A.length>0?A[A.length-2][1].end:{line:1,column:1,offset:0})},re=-1;++re<t.transforms.length;)O=t.transforms[re](O)||O;return O}function i(A,O,W){let K=O-1,re=-1,Je=!1,wt,rt,yr,br;for(;++K<=W;){const Ne=A[K];switch(Ne[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Ne[0]==="enter"?re++:re--,br=void 0;break}case"lineEndingBlank":{Ne[0]==="enter"&&(wt&&!br&&!re&&!yr&&(yr=K),br=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:br=void 0}if(!re&&Ne[0]==="enter"&&Ne[1].type==="listItemPrefix"||re===-1&&Ne[0]==="exit"&&(Ne[1].type==="listUnordered"||Ne[1].type==="listOrdered")){if(wt){let Rt=K;for(rt=void 0;Rt--;){const nt=A[Rt];if(nt[1].type==="lineEnding"||nt[1].type==="lineEndingBlank"){if(nt[0]==="exit")continue;rt&&(A[rt][1].type="lineEndingBlank",Je=!0),nt[1].type="lineEnding",rt=Rt}else if(!(nt[1].type==="linePrefix"||nt[1].type==="blockQuotePrefix"||nt[1].type==="blockQuotePrefixWhitespace"||nt[1].type==="blockQuoteMarker"||nt[1].type==="listItemIndent"))break}yr&&(!rt||yr<rt)&&(wt._spread=!0),wt.end=Object.assign({},rt?A[rt][1].start:Ne[1].end),A.splice(rt||K,0,["exit",wt,Ne[2]]),K++,W++}if(Ne[1].type==="listItemPrefix"){const Rt={type:"listItem",_spread:!1,start:Object.assign({},Ne[1].start),end:void 0};wt=Rt,A.splice(K,0,["enter",Rt,Ne[2]]),K++,W++,yr=void 0,br=!0}}}return A[O][1]._spread=Je,W}function s(A,O){return W;function W(K){o.call(this,A(K),K),O&&O.call(this,K)}}function a(){this.stack.push({type:"fragment",children:[]})}function o(A,O,W){this.stack[this.stack.length-1].children.push(A),this.stack.push(A),this.tokenStack.push([O,W||void 0]),A.position={start:lt(O.start),end:void 0}}function l(A){return O;function O(W){A&&A.call(this,W),u.call(this,W)}}function u(A,O){const W=this.stack.pop(),K=this.tokenStack.pop();if(K)K[0].type!==A.type&&(O?O.call(this,A,K[0]):(K[1]||Bo).call(this,A,K[0]));else throw new Error("Cannot close `"+A.type+"` ("+ir({start:A.start,end:A.end})+"): it’s not open");W.position.end=lt(A.end)}function d(){return ei(this.stack.pop())}function c(){this.data.expectingFirstListItemValue=!0}function f(A){if(this.data.expectingFirstListItemValue){const O=this.stack[this.stack.length-2];O.start=Number.parseInt(this.sliceSerialize(A),10),this.data.expectingFirstListItemValue=void 0}}function h(){const A=this.resume(),O=this.stack[this.stack.length-1];O.lang=A}function g(){const A=this.resume(),O=this.stack[this.stack.length-1];O.meta=A}function S(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function w(){const A=this.resume(),O=this.stack[this.stack.length-1];O.value=A.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function b(){const A=this.resume(),O=this.stack[this.stack.length-1];O.value=A.replace(/(\r?\n|\r)$/g,"")}function C(A){const O=this.resume(),W=this.stack[this.stack.length-1];W.label=O,W.identifier=Ve(this.sliceSerialize(A)).toLowerCase()}function _(){const A=this.resume(),O=this.stack[this.stack.length-1];O.title=A}function F(){const A=this.resume(),O=this.stack[this.stack.length-1];O.url=A}function B(A){const O=this.stack[this.stack.length-1];if(!O.depth){const W=this.sliceSerialize(A).length;O.depth=W}}function I(){this.data.setextHeadingSlurpLineEnding=!0}function z(A){const O=this.stack[this.stack.length-1];O.depth=this.sliceSerialize(A).codePointAt(0)===61?1:2}function j(){this.data.setextHeadingSlurpLineEnding=void 0}function $(A){const W=this.stack[this.stack.length-1].children;let K=W[W.length-1];(!K||K.type!=="text")&&(K=Lx(),K.position={start:lt(A.start),end:void 0},W.push(K)),this.stack.push(K)}function k(A){const O=this.stack.pop();O.value+=this.sliceSerialize(A),O.position.end=lt(A.end)}function N(A){const O=this.stack[this.stack.length-1];if(this.data.atHardBreak){const W=O.children[O.children.length-1];W.position.end=lt(A.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(O.type)&&($.call(this,A),k.call(this,A))}function M(){this.data.atHardBreak=!0}function V(){const A=this.resume(),O=this.stack[this.stack.length-1];O.value=A}function R(){const A=this.resume(),O=this.stack[this.stack.length-1];O.value=A}function D(){const A=this.resume(),O=this.stack[this.stack.length-1];O.value=A}function Q(){const A=this.stack[this.stack.length-1];if(this.data.inReference){const O=this.data.referenceType||"shortcut";A.type+="Reference",A.referenceType=O,delete A.url,delete A.title}else delete A.identifier,delete A.label;this.data.referenceType=void 0}function se(){const A=this.stack[this.stack.length-1];if(this.data.inReference){const O=this.data.referenceType||"shortcut";A.type+="Reference",A.referenceType=O,delete A.url,delete A.title}else delete A.identifier,delete A.label;this.data.referenceType=void 0}function ge(A){const O=this.sliceSerialize(A),W=this.stack[this.stack.length-2];W.label=cg(O),W.identifier=Ve(O).toLowerCase()}function fe(){const A=this.stack[this.stack.length-1],O=this.resume(),W=this.stack[this.stack.length-1];if(this.data.inReference=!0,W.type==="link"){const K=A.children;W.children=K}else W.alt=O}function x(){const A=this.resume(),O=this.stack[this.stack.length-1];O.url=A}function ye(){const A=this.resume(),O=this.stack[this.stack.length-1];O.title=A}function Ie(){this.data.inReference=void 0}function v(){this.data.referenceType="collapsed"}function ve(A){const O=this.resume(),W=this.stack[this.stack.length-1];W.label=O,W.identifier=Ve(this.sliceSerialize(A)).toLowerCase(),this.data.referenceType="full"}function Re(A){this.data.characterReferenceType=A.type}function le(A){const O=this.sliceSerialize(A),W=this.data.characterReferenceType;let K;W?(K=bo(O,W==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):K=ti(O);const re=this.stack[this.stack.length-1];re.value+=K}function zt(A){const O=this.stack.pop();O.position.end=lt(A.end)}function Z(A){k.call(this,A);const O=this.stack[this.stack.length-1];O.url=this.sliceSerialize(A)}function je(A){k.call(this,A);const O=this.stack[this.stack.length-1];O.url="mailto:"+this.sliceSerialize(A)}function pe(){return{type:"blockquote",children:[]}}function bt(){return{type:"code",lang:null,meta:null,value:""}}function nn(){return{type:"inlineCode",value:""}}function sn(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Ix(){return{type:"emphasis",children:[]}}function eu(){return{type:"heading",depth:0,children:[]}}function tu(){return{type:"break"}}function ru(){return{type:"html",value:""}}function Ex(){return{type:"image",title:null,url:"",alt:null}}function nu(){return{type:"link",title:null,url:"",children:[]}}function iu(A){return{type:"list",ordered:A.type==="listOrdered",start:null,spread:A._spread,children:[]}}function Ax(A){return{type:"listItem",spread:A._spread,checked:null,children:[]}}function Px(){return{type:"paragraph",children:[]}}function Mx(){return{type:"strong",children:[]}}function Lx(){return{type:"text",value:""}}function Nx(){return{type:"thematicBreak"}}}function lt(e){return{line:e.line,column:e.column,offset:e.offset}}function Fo(e,t){let r=-1;for(;++r<t.length;){const n=t[r];Array.isArray(n)?Fo(e,n):pg(e,n)}}function pg(e,t){let r;for(r in t)if(Oo.call(t,r))switch(r){case"canContainEols":{const n=t[r];n&&e[r].push(...n);break}case"transforms":{const n=t[r];n&&e[r].push(...n);break}case"enter":case"exit":{const n=t[r];n&&Object.assign(e[r],n);break}}}function Bo(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+ir({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+ir({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+ir({start:t.start,end:t.end})+") is still open")}function mg(e){const t=this;t.parser=r;function r(n){return hg(n,E(m(m({},t.data("settings")),e),{extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]}))}}function gg(e,t){const r={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,r),e.applyData(t,r)}function yg(e,t){const r={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,r),[e.applyData(t,r),{type:"text",value:`
11
+ `}]}function bg(e,t){const r=t.value?t.value+`
12
+ `:"",n={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(n.className=["language-"+i[0]]);let s={type:"element",tagName:"code",properties:n,children:[{type:"text",value:r}]};return t.meta&&(s.data={meta:t.meta}),e.patch(t,s),s=e.applyData(t,s),s={type:"element",tagName:"pre",properties:{},children:[s]},e.patch(t,s),s}function wg(e,t){const r={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function xg(e,t){const r={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function vg(e,t){const r=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=String(t.identifier).toUpperCase(),i=Dt(n.toLowerCase()),s=e.footnoteOrder.indexOf(n);let a,o=e.footnoteCounts.get(n);o===void 0?(o=0,e.footnoteOrder.push(n),a=e.footnoteOrder.length):a=s+1,o+=1,e.footnoteCounts.set(n,o);const l={type:"element",tagName:"a",properties:{href:"#"+r+"fn-"+i,id:r+"fnref-"+i+(o>1?"-"+o:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};e.patch(t,l);const u={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,u),e.applyData(t,u)}function Sg(e,t){const r={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function kg(e,t){if(e.options.allowDangerousHtml){const r={type:"raw",value:t.value};return e.patch(t,r),e.applyData(t,r)}}function zo(e,t){const r=t.referenceType;let n="]";if(r==="collapsed"?n+="[]":r==="full"&&(n+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+n}];const i=e.all(t),s=i[0];s&&s.type==="text"?s.value="["+s.value:i.unshift({type:"text",value:"["});const a=i[i.length-1];return a&&a.type==="text"?a.value+=n:i.push({type:"text",value:n}),i}function _g(e,t){const r=String(t.identifier).toUpperCase(),n=e.definitionById.get(r);if(!n)return zo(e,t);const i={src:Dt(n.url||""),alt:t.alt};n.title!==null&&n.title!==void 0&&(i.title=n.title);const s={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,s),e.applyData(t,s)}function Tg(e,t){const r={src:Dt(t.url)};t.alt!==null&&t.alt!==void 0&&(r.alt=t.alt),t.title!==null&&t.title!==void 0&&(r.title=t.title);const n={type:"element",tagName:"img",properties:r,children:[]};return e.patch(t,n),e.applyData(t,n)}function Cg(e,t){const r={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,r);const n={type:"element",tagName:"code",properties:{},children:[r]};return e.patch(t,n),e.applyData(t,n)}function Ig(e,t){const r=String(t.identifier).toUpperCase(),n=e.definitionById.get(r);if(!n)return zo(e,t);const i={href:Dt(n.url||"")};n.title!==null&&n.title!==void 0&&(i.title=n.title);const s={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function Eg(e,t){const r={href:Dt(t.url)};t.title!==null&&t.title!==void 0&&(r.title=t.title);const n={type:"element",tagName:"a",properties:r,children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Ag(e,t,r){const n=e.all(t),i=r?Pg(r):Ro(t),s={},a=[];if(typeof t.checked=="boolean"){const d=n[0];let c;d&&d.type==="element"&&d.tagName==="p"?c=d:(c={type:"element",tagName:"p",properties:{},children:[]},n.unshift(c)),c.children.length>0&&c.children.unshift({type:"text",value:" "}),c.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let o=-1;for(;++o<n.length;){const d=n[o];(i||o!==0||d.type!=="element"||d.tagName!=="p")&&a.push({type:"text",value:`
13
+ `}),d.type==="element"&&d.tagName==="p"&&!i?a.push(...d.children):a.push(d)}const l=n[n.length-1];l&&(i||l.type!=="element"||l.tagName!=="p")&&a.push({type:"text",value:`
14
+ `});const u={type:"element",tagName:"li",properties:s,children:a};return e.patch(t,u),e.applyData(t,u)}function Pg(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const r=e.children;let n=-1;for(;!t&&++n<r.length;)t=Ro(r[n])}return t}function Ro(e){const t=e.spread;return t==null?e.children.length>1:t}function Mg(e,t){const r={},n=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(r.start=t.start);++i<n.length;){const a=n[i];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){r.className=["contains-task-list"];break}}const s={type:"element",tagName:t.ordered?"ol":"ul",properties:r,children:e.wrap(n,!0)};return e.patch(t,s),e.applyData(t,s)}function Lg(e,t){const r={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function Ng(e,t){const r={type:"root",children:e.wrap(e.all(t))};return e.patch(t,r),e.applyData(t,r)}function Dg(e,t){const r={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function Og(e,t){const r=e.all(t),n=r.shift(),i=[];if(n){const a={type:"element",tagName:"thead",properties:{},children:e.wrap([n],!0)};e.patch(t.children[0],a),i.push(a)}if(r.length>0){const a={type:"element",tagName:"tbody",properties:{},children:e.wrap(r,!0)},o=Gn(t.children[1]),l=io(t.children[t.children.length-1]);o&&l&&(a.position={start:o,end:l}),i.push(a)}const s={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,s),e.applyData(t,s)}function Fg(e,t,r){const n=r?r.children:void 0,s=(n?n.indexOf(t):1)===0?"th":"td",a=r&&r.type==="table"?r.align:void 0,o=a?a.length:t.children.length;let l=-1;const u=[];for(;++l<o;){const c=t.children[l],f={},h=a?a[l]:void 0;h&&(f.align=h);let g={type:"element",tagName:s,properties:f,children:[]};c&&(g.children=e.all(c),e.patch(c,g),g=e.applyData(c,g)),u.push(g)}const d={type:"element",tagName:"tr",properties:{},children:e.wrap(u,!0)};return e.patch(t,d),e.applyData(t,d)}function Bg(e,t){const r={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}const jo=9,Uo=32;function zg(e){const t=String(e),r=/\r?\n|\r/g;let n=r.exec(t),i=0;const s=[];for(;n;)s.push($o(t.slice(i,n.index),i>0,!0),n[0]),i=n.index+n[0].length,n=r.exec(t);return s.push($o(t.slice(i),i>0,!1)),s.join("")}function $o(e,t,r){let n=0,i=e.length;if(t){let s=e.codePointAt(n);for(;s===jo||s===Uo;)n++,s=e.codePointAt(n)}if(r){let s=e.codePointAt(i-1);for(;s===jo||s===Uo;)i--,s=e.codePointAt(i-1)}return i>n?e.slice(n,i):""}function Rg(e,t){const r={type:"text",value:zg(String(t.value))};return e.patch(t,r),e.applyData(t,r)}function jg(e,t){const r={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,r),e.applyData(t,r)}const Ug={blockquote:gg,break:yg,code:bg,delete:wg,emphasis:xg,footnoteReference:vg,heading:Sg,html:kg,imageReference:_g,image:Tg,inlineCode:Cg,linkReference:Ig,link:Eg,listItem:Ag,list:Mg,paragraph:Lg,root:Ng,strong:Dg,table:Og,tableCell:Bg,tableRow:Fg,text:Rg,thematicBreak:jg,toml:Wr,yaml:Wr,definition:Wr,footnoteDefinition:Wr};function Wr(){}const Ho=-1,Jr=0,ur=1,Gr=2,oi=3,li=4,ui=5,ci=6,qo=7,Vo=8,Wo=typeof self=="object"?self:globalThis,$g=(e,t)=>{const r=(i,s)=>(e.set(s,i),i),n=i=>{if(e.has(i))return e.get(i);const[s,a]=t[i];switch(s){case Jr:case Ho:return r(a,i);case ur:{const o=r([],i);for(const l of a)o.push(n(l));return o}case Gr:{const o=r({},i);for(const[l,u]of a)o[n(l)]=n(u);return o}case oi:return r(new Date(a),i);case li:{const{source:o,flags:l}=a;return r(new RegExp(o,l),i)}case ui:{const o=r(new Map,i);for(const[l,u]of a)o.set(n(l),n(u));return o}case ci:{const o=r(new Set,i);for(const l of a)o.add(n(l));return o}case qo:{const{name:o,message:l}=a;return r(new Wo[o](l),i)}case Vo:return r(BigInt(a),i);case"BigInt":return r(Object(BigInt(a)),i);case"ArrayBuffer":return r(new Uint8Array(a).buffer,a);case"DataView":{const{buffer:o}=new Uint8Array(a);return r(new DataView(o),a)}}return r(new Wo[s](a),i)};return n},Jo=e=>$g(new Map,e)(0),Ft="",{toString:Hg}={},{keys:qg}=Object,cr=e=>{const t=typeof e;if(t!=="object"||!e)return[Jr,t];const r=Hg.call(e).slice(8,-1);switch(r){case"Array":return[ur,Ft];case"Object":return[Gr,Ft];case"Date":return[oi,Ft];case"RegExp":return[li,Ft];case"Map":return[ui,Ft];case"Set":return[ci,Ft];case"DataView":return[ur,r]}return r.includes("Array")?[ur,r]:r.includes("Error")?[qo,r]:[Gr,r]},Yr=([e,t])=>e===Jr&&(t==="function"||t==="symbol"),Vg=(e,t,r,n)=>{const i=(a,o)=>{const l=n.push(a)-1;return r.set(o,l),l},s=a=>{if(r.has(a))return r.get(a);let[o,l]=cr(a);switch(o){case Jr:{let d=a;switch(l){case"bigint":o=Vo,d=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+l);d=null;break;case"undefined":return i([Ho],a)}return i([o,d],a)}case ur:{if(l){let f=a;return l==="DataView"?f=new Uint8Array(a.buffer):l==="ArrayBuffer"&&(f=new Uint8Array(a)),i([l,[...f]],a)}const d=[],c=i([o,d],a);for(const f of a)d.push(s(f));return c}case Gr:{if(l)switch(l){case"BigInt":return i([l,a.toString()],a);case"Boolean":case"Number":case"String":return i([l,a.valueOf()],a)}if(t&&"toJSON"in a)return s(a.toJSON());const d=[],c=i([o,d],a);for(const f of qg(a))(e||!Yr(cr(a[f])))&&d.push([s(f),s(a[f])]);return c}case oi:return i([o,a.toISOString()],a);case li:{const{source:d,flags:c}=a;return i([o,{source:d,flags:c}],a)}case ui:{const d=[],c=i([o,d],a);for(const[f,h]of a)(e||!(Yr(cr(f))||Yr(cr(h))))&&d.push([s(f),s(h)]);return c}case ci:{const d=[],c=i([o,d],a);for(const f of a)(e||!Yr(cr(f)))&&d.push(s(f));return c}}const{message:u}=a;return i([o,{name:l,message:u}],a)};return s},Go=(e,{json:t,lossy:r}={})=>{const n=[];return Vg(!(t||r),!!t,new Map,n)(e),n},Kr=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Jo(Go(e,t)):structuredClone(e):(e,t)=>Jo(Go(e,t));function Wg(e,t){const r=[{type:"text",value:"↩"}];return t>1&&r.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),r}function Jg(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function Gg(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=e.options.footnoteBackContent||Wg,n=e.options.footnoteBackLabel||Jg,i=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},o=[];let l=-1;for(;++l<e.footnoteOrder.length;){const u=e.footnoteById.get(e.footnoteOrder[l]);if(!u)continue;const d=e.all(u),c=String(u.identifier).toUpperCase(),f=Dt(c.toLowerCase());let h=0;const g=[],S=e.footnoteCounts.get(c);for(;S!==void 0&&++h<=S;){g.length>0&&g.push({type:"text",value:" "});let C=typeof r=="string"?r:r(l,h);typeof C=="string"&&(C={type:"text",value:C}),g.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+f+(h>1?"-"+h:""),dataFootnoteBackref:"",ariaLabel:typeof n=="string"?n:n(l,h),className:["data-footnote-backref"]},children:Array.isArray(C)?C:[C]})}const w=d[d.length-1];if(w&&w.type==="element"&&w.tagName==="p"){const C=w.children[w.children.length-1];C&&C.type==="text"?C.value+=" ":w.children.push({type:"text",value:" "}),w.children.push(...g)}else d.push(...g);const b={type:"element",tagName:"li",properties:{id:t+"fn-"+f},children:e.wrap(d,!0)};e.patch(u,b),o.push(b)}if(o.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:E(m({},Kr(a)),{id:"footnote-label"}),children:[{type:"text",value:i}]},{type:"text",value:`
15
+ `},{type:"element",tagName:"ol",properties:{},children:e.wrap(o,!0)},{type:"text",value:`
16
+ `}]}}const Xr=(function(e){if(e==null)return Qg;if(typeof e=="function")return Qr(e);if(typeof e=="object")return Array.isArray(e)?Yg(e):Kg(e);if(typeof e=="string")return Xg(e);throw new Error("Expected function, string, or object as test")});function Yg(e){const t=[];let r=-1;for(;++r<e.length;)t[r]=Xr(e[r]);return Qr(n);function n(...i){let s=-1;for(;++s<t.length;)if(t[s].apply(this,i))return!0;return!1}}function Kg(e){const t=e;return Qr(r);function r(n){const i=n;let s;for(s in e)if(i[s]!==t[s])return!1;return!0}}function Xg(e){return Qr(t);function t(r){return r&&r.type===e}}function Qr(e){return t;function t(r,n,i){return!!(Zg(r)&&e.call(this,r,typeof n=="number"?n:void 0,i||void 0))}}function Qg(){return!0}function Zg(e){return e!==null&&typeof e=="object"&&"type"in e}function iv(e){return e}const Yo=[],ey=!0,di=!1,ty="skip";function Ko(e,t,r,n){let i;typeof t=="function"&&typeof r!="function"?(n=r,r=t):i=t;const s=Xr(i),a=n?-1:1;o(e,void 0,[])();function o(l,u,d){const c=l&&typeof l=="object"?l:{};if(typeof c.type=="string"){const h=typeof c.tagName=="string"?c.tagName:typeof c.name=="string"?c.name:void 0;Object.defineProperty(f,"name",{value:"node ("+(l.type+(h?"<"+h+">":""))+")"})}return f;function f(){let h=Yo,g,S,w;if((!t||s(l,u,d[d.length-1]||void 0))&&(h=ry(r(l,d)),h[0]===di))return h;if("children"in l&&l.children){const b=l;if(b.children&&h[0]!==ty)for(S=(n?b.children.length:-1)+a,w=d.concat(b);S>-1&&S<b.children.length;){const C=b.children[S];if(g=o(C,S,w)(),g[0]===di)return g;S=typeof g[1]=="number"?g[1]:S+a}}return h}}}function ry(e){return Array.isArray(e)?e:typeof e=="number"?[ey,e]:e==null?Yo:[e]}function hi(e,t,r,n){let i,s,a;typeof t=="function"&&typeof r!="function"?(s=void 0,a=t,i=r):(s=t,a=r,i=n),Ko(e,s,o,i);function o(l,u){const d=u[u.length-1],c=d?d.children.indexOf(l):void 0;return a(l,c,d)}}const fi={}.hasOwnProperty,ny={};function iy(e,t){const r=t||ny,n=new Map,i=new Map,s=new Map,a=m(m({},Ug),r.handlers),o={all:u,applyData:ay,definitionById:n,footnoteById:i,footnoteCounts:s,footnoteOrder:[],handlers:a,one:l,options:r,patch:sy,wrap:ly};return hi(e,function(d){if(d.type==="definition"||d.type==="footnoteDefinition"){const c=d.type==="definition"?n:i,f=String(d.identifier).toUpperCase();c.has(f)||c.set(f,d)}}),o;function l(d,c){const f=d.type,h=o.handlers[f];if(fi.call(o.handlers,f)&&h)return h(o,d,c);if(o.options.passThrough&&o.options.passThrough.includes(f)){if("children"in d){const S=d,{children:w}=S,b=H(S,["children"]),C=Kr(b);return C.children=o.all(d),C}return Kr(d)}return(o.options.unknownHandler||oy)(o,d,c)}function u(d){const c=[];if("children"in d){const f=d.children;let h=-1;for(;++h<f.length;){const g=o.one(f[h],d);if(g){if(h&&f[h-1].type==="break"&&(!Array.isArray(g)&&g.type==="text"&&(g.value=Xo(g.value)),!Array.isArray(g)&&g.type==="element")){const S=g.children[0];S&&S.type==="text"&&(S.value=Xo(S.value))}Array.isArray(g)?c.push(...g):c.push(g)}}}return c}}function sy(e,t){e.position&&(t.position=rp(e))}function ay(e,t){let r=t;if(e&&e.data){const n=e.data.hName,i=e.data.hChildren,s=e.data.hProperties;if(typeof n=="string")if(r.type==="element")r.tagName=n;else{const a="children"in r?r.children:[r];r={type:"element",tagName:n,properties:{},children:a}}r.type==="element"&&s&&Object.assign(r.properties,Kr(s)),"children"in r&&r.children&&i!==null&&i!==void 0&&(r.children=i)}return r}function oy(e,t){const r=t.data||{},n="value"in t&&!(fi.call(r,"hProperties")||fi.call(r,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function ly(e,t){const r=[];let n=-1;for(t&&r.push({type:"text",value:`
17
+ `});++n<e.length;)n&&r.push({type:"text",value:`
18
+ `}),r.push(e[n]);return t&&e.length>0&&r.push({type:"text",value:`
19
+ `}),r}function Xo(e){let t=0,r=e.charCodeAt(t);for(;r===9||r===32;)t++,r=e.charCodeAt(t);return e.slice(t)}function Qo(e,t){const r=iy(e,t),n=r.one(e,void 0),i=Gg(r),s=Array.isArray(n)?{type:"root",children:n}:n||{type:"root",children:[]};return i&&s.children.push({type:"text",value:`
20
+ `},i),s}function uy(e,t){return e&&"run"in e?function(r,n){return P(this,null,function*(){const i=Qo(r,m({file:n},t));yield e.run(i,n)})}:function(r,n){return Qo(r,m({file:n},e||t))}}function Zo(e){if(e)throw e}var pi,el;function cy(){if(el)return pi;el=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,r=Object.defineProperty,n=Object.getOwnPropertyDescriptor,i=function(u){return typeof Array.isArray=="function"?Array.isArray(u):t.call(u)==="[object Array]"},s=function(u){if(!u||t.call(u)!=="[object Object]")return!1;var d=e.call(u,"constructor"),c=u.constructor&&u.constructor.prototype&&e.call(u.constructor.prototype,"isPrototypeOf");if(u.constructor&&!d&&!c)return!1;var f;for(f in u);return typeof f=="undefined"||e.call(u,f)},a=function(u,d){r&&d.name==="__proto__"?r(u,d.name,{enumerable:!0,configurable:!0,value:d.newValue,writable:!0}):u[d.name]=d.newValue},o=function(u,d){if(d==="__proto__")if(e.call(u,d)){if(n)return n(u,d).value}else return;return u[d]};return pi=function l(){var u,d,c,f,h,g,S=arguments[0],w=1,b=arguments.length,C=!1;for(typeof S=="boolean"&&(C=S,S=arguments[1]||{},w=2),(S==null||typeof S!="object"&&typeof S!="function")&&(S={});w<b;++w)if(u=arguments[w],u!=null)for(d in u)c=o(S,d),f=o(u,d),S!==f&&(C&&f&&(s(f)||(h=i(f)))?(h?(h=!1,g=c&&i(c)?c:[]):g=c&&s(c)?c:{},a(S,{name:d,newValue:l(C,g,f)})):typeof f!="undefined"&&a(S,{name:d,newValue:f}));return S},pi}var dy=cy();const mi=xr(dy);function gi(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function hy(){const e=[],t={run:r,use:n};return t;function r(...i){let s=-1;const a=i.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);o(null,...i);function o(l,...u){const d=e[++s];let c=-1;if(l){a(l);return}for(;++c<i.length;)(u[c]===null||u[c]===void 0)&&(u[c]=i[c]);i=u,d?fy(d,o)(...u):a(null,...u)}}function n(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function fy(e,t){let r;return n;function n(...a){const o=e.length>a.length;let l;o&&a.push(i);try{l=e.apply(this,a)}catch(u){const d=u;if(o&&r)throw d;return i(d)}o||(l&&l.then&&typeof l.then=="function"?l.then(s,i):l instanceof Error?i(l):s(l))}function i(a,...o){r||(r=!0,t(a,...o))}function s(a){i(null,a)}}const Ke={basename:py,dirname:my,extname:gy,join:yy,sep:"/"};function py(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');dr(e);let r=0,n=-1,i=e.length,s;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(s){r=i+1;break}}else n<0&&(s=!0,n=i+1);return n<0?"":e.slice(r,n)}if(t===e)return"";let a=-1,o=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(s){r=i+1;break}}else a<0&&(s=!0,a=i+1),o>-1&&(e.codePointAt(i)===t.codePointAt(o--)?o<0&&(n=i):(o=-1,n=a));return r===n?n=a:n<0&&(n=e.length),e.slice(r,n)}function my(e){if(dr(e),e.length===0)return".";let t=-1,r=e.length,n;for(;--r;)if(e.codePointAt(r)===47){if(n){t=r;break}}else n||(n=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function gy(e){dr(e);let t=e.length,r=-1,n=0,i=-1,s=0,a;for(;t--;){const o=e.codePointAt(t);if(o===47){if(a){n=t+1;break}continue}r<0&&(a=!0,r=t+1),o===46?i<0?i=t:s!==1&&(s=1):i>-1&&(s=-1)}return i<0||r<0||s===0||s===1&&i===r-1&&i===n+1?"":e.slice(i,r)}function yy(...e){let t=-1,r;for(;++t<e.length;)dr(e[t]),e[t]&&(r=r===void 0?e[t]:r+"/"+e[t]);return r===void 0?".":by(r)}function by(e){dr(e);const t=e.codePointAt(0)===47;let r=wy(e,!t);return r.length===0&&!t&&(r="."),r.length>0&&e.codePointAt(e.length-1)===47&&(r+="/"),t?"/"+r:r}function wy(e,t){let r="",n=0,i=-1,s=0,a=-1,o,l;for(;++a<=e.length;){if(a<e.length)o=e.codePointAt(a);else{if(o===47)break;o=47}if(o===47){if(!(i===a-1||s===1))if(i!==a-1&&s===2){if(r.length<2||n!==2||r.codePointAt(r.length-1)!==46||r.codePointAt(r.length-2)!==46){if(r.length>2){if(l=r.lastIndexOf("/"),l!==r.length-1){l<0?(r="",n=0):(r=r.slice(0,l),n=r.length-1-r.lastIndexOf("/")),i=a,s=0;continue}}else if(r.length>0){r="",n=0,i=a,s=0;continue}}t&&(r=r.length>0?r+"/..":"..",n=2)}else r.length>0?r+="/"+e.slice(i+1,a):r=e.slice(i+1,a),n=a-i-1;i=a,s=0}else o===46&&s>-1?s++:s=-1}return r}function dr(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const xy={cwd:vy};function vy(){return"/"}function yi(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function Sy(e){if(typeof e=="string")e=new URL(e);else if(!yi(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return ky(e)}function ky(e){if(e.hostname!==""){const n=new TypeError('File URL host must be "localhost" or empty on darwin');throw n.code="ERR_INVALID_FILE_URL_HOST",n}const t=e.pathname;let r=-1;for(;++r<t.length;)if(t.codePointAt(r)===37&&t.codePointAt(r+1)===50){const n=t.codePointAt(r+2);if(n===70||n===102){const i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(t)}const bi=["history","path","basename","stem","extname","dirname"];class tl{constructor(t){let r;t?yi(t)?r={path:t}:typeof t=="string"||_y(t)?r={value:t}:r=t:r={},this.cwd="cwd"in r?"":xy.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<bi.length;){const s=bi[n];s in r&&r[s]!==void 0&&r[s]!==null&&(this[s]=s==="history"?[...r[s]]:r[s])}let i;for(i in r)bi.includes(i)||(this[i]=r[i])}get basename(){return typeof this.path=="string"?Ke.basename(this.path):void 0}set basename(t){xi(t,"basename"),wi(t,"basename"),this.path=Ke.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Ke.dirname(this.path):void 0}set dirname(t){rl(this.basename,"dirname"),this.path=Ke.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Ke.extname(this.path):void 0}set extname(t){if(wi(t,"extname"),rl(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Ke.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){yi(t)&&(t=Sy(t)),xi(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Ke.basename(this.path,this.extname):void 0}set stem(t){xi(t,"stem"),wi(t,"stem"),this.path=Ke.join(this.dirname||"",t+(this.extname||""))}fail(t,r,n){const i=this.message(t,r,n);throw i.fatal=!0,i}info(t,r,n){const i=this.message(t,r,n);return i.fatal=void 0,i}message(t,r,n){const i=new we(t,r,n);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function wi(e,t){if(e&&e.includes(Ke.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Ke.sep+"`")}function xi(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function rl(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function _y(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const Ty=(function(e){const n=this.constructor.prototype,i=n[e],s=function(){return i.apply(s,arguments)};return Object.setPrototypeOf(s,n),s}),Cy={}.hasOwnProperty;class vi extends Ty{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=hy()}copy(){const t=new vi;let r=-1;for(;++r<this.attachers.length;){const n=this.attachers[r];t.use(...n)}return t.data(mi(!0,{},this.namespace)),t}data(t,r){return typeof t=="string"?arguments.length===2?(_i("data",this.frozen),this.namespace[t]=r,this):Cy.call(this.namespace,t)&&this.namespace[t]||void 0:t?(_i("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[r,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);const i=r.call(t,...n);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const r=Zr(t),n=this.parser||this.Parser;return Si("parse",n),n(String(r),r)}process(t,r){const n=this;return this.freeze(),Si("process",this.parser||this.Parser),ki("process",this.compiler||this.Compiler),r?i(void 0,r):new Promise(i);function i(s,a){const o=Zr(t),l=n.parse(o);n.run(l,o,function(d,c,f){if(d||!c||!f)return u(d);const h=c,g=n.stringify(h,f);Ay(g)?f.value=g:f.result=g,u(d,f)});function u(d,c){d||!c?a(d):s?s(c):r(void 0,c)}}}processSync(t){let r=!1,n;return this.freeze(),Si("processSync",this.parser||this.Parser),ki("processSync",this.compiler||this.Compiler),this.process(t,i),il("processSync","process",r),n;function i(s,a){r=!0,Zo(s),n=a}}run(t,r,n){nl(t),this.freeze();const i=this.transformers;return!n&&typeof r=="function"&&(n=r,r=void 0),n?s(void 0,n):new Promise(s);function s(a,o){const l=Zr(r);i.run(t,l,u);function u(d,c,f){const h=c||t;d?o(d):a?a(h):n(void 0,h,f)}}}runSync(t,r){let n=!1,i;return this.run(t,r,s),il("runSync","run",n),i;function s(a,o){Zo(a),i=o,n=!0}}stringify(t,r){this.freeze();const n=Zr(r),i=this.compiler||this.Compiler;return ki("stringify",i),nl(t),i(t,n)}use(t,...r){const n=this.attachers,i=this.namespace;if(_i("use",this.frozen),t!=null)if(typeof t=="function")l(t,r);else if(typeof t=="object")Array.isArray(t)?o(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function s(u){if(typeof u=="function")l(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[d,...c]=u;l(d,c)}else a(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function a(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(u.plugins),u.settings&&(i.settings=mi(!0,i.settings,u.settings))}function o(u){let d=-1;if(u!=null)if(Array.isArray(u))for(;++d<u.length;){const c=u[d];s(c)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function l(u,d){let c=-1,f=-1;for(;++c<n.length;)if(n[c][0]===u){f=c;break}if(f===-1)n.push([u,...d]);else if(d.length>0){let[h,...g]=d;const S=n[f][1];gi(S)&&gi(h)&&(h=mi(!0,S,h)),n[f]=[u,h,...g]}}}}const Iy=new vi().freeze();function Si(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function ki(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function _i(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function nl(e){if(!gi(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function il(e,t,r){if(!r)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Zr(e){return Ey(e)?e:new tl(e)}function Ey(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function Ay(e){return typeof e=="string"||Py(e)}function Py(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const My="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",sl=[],al={allowDangerousHtml:!0},Ly=/^(https?|ircs?|mailto|xmpp)$/i,Ny=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Dy(e){const t=Oy(e),r=Fy(e);return By(t.runSync(t.parse(r),r),e)}function Oy(e){const t=e.rehypePlugins||sl,r=e.remarkPlugins||sl,n=e.remarkRehypeOptions?m(m({},e.remarkRehypeOptions),al):al;return Iy().use(mg).use(r).use(uy,n).use(t)}function Fy(e){const t=e.children||"",r=new tl;return typeof t=="string"&&(r.value=t),r}function By(e,t){const r=t.allowedElements,n=t.allowElement,i=t.components,s=t.disallowedElements,a=t.skipHtml,o=t.unwrapDisallowed,l=t.urlTransform||zy;for(const d of Ny)Object.hasOwn(t,d.from)&&(""+d.from+(d.to?"use `"+d.to+"` instead":"remove it")+My+d.id,void 0);return hi(e,u),op(e,{Fragment:p.Fragment,components:i,ignoreInvalidStyle:!0,jsx:p.jsx,jsxs:p.jsxs,passKeys:!0,passNode:!0});function u(d,c,f){if(d.type==="raw"&&f&&typeof c=="number")return a?f.children.splice(c,1):f.children[c]={type:"text",value:d.value},c;if(d.type==="element"){let h;for(h in Zn)if(Object.hasOwn(Zn,h)&&Object.hasOwn(d.properties,h)){const g=d.properties[h],S=Zn[h];(S===null||S.includes(d.tagName))&&(d.properties[h]=l(String(g||""),h,d))}}if(d.type==="element"){let h=r?!r.includes(d.tagName):s?s.includes(d.tagName):!1;if(!h&&n&&typeof c=="number"&&(h=!n(d,c,f)),h&&f&&typeof c=="number")return o&&d.children?f.children.splice(c,1,...d.children):f.children.splice(c,1),c}}}function zy(e){const t=e.indexOf(":"),r=e.indexOf("?"),n=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||r!==-1&&t>r||n!==-1&&t>n||Ly.test(e.slice(0,t))?e:""}var Ry=(e,t)=>typeof e=="string"?e===t:JSON.stringify(e)===JSON.stringify(t),jy=(e,t)=>{if(!e||!t)return!1;const r=n=>{const o=n||{},{position:i,data:s}=o;return H(o,["position","data"])};return JSON.stringify(r(e.properties))===JSON.stringify(r(t.properties))&&Ry(e.children,t.children)},Ti=(e,t)=>jy(e.node,t.node),Uy=(e={})=>Object.fromEntries(Object.entries(e!=null?e:{}).map(([t,r])=>{if(!r)return[t,r];const n=r,i=o=>{var l=o,{node:s}=l,a=H(l,["node"]);return p.jsx(n,m({},a))};return[t,y.memo(i,Ti)]})),Ci=y.createContext(null),ol=()=>y.useContext(Ci)!==null,$y=r=>{var n=r,{children:e}=n,t=H(n,["children"]);return p.jsx(Ci.Provider,{value:t,children:e})},Hy=y.memo($y,Ti),qy=r=>{var n=r,{node:e}=n,t=H(n,["node"]);return p.jsx("pre",m({},t))},Vy=r=>{var n=r,{node:e}=n,t=H(n,["node"]);return p.jsx("code",m({},t))},Ii=({node:e,components:{Pre:t,Code:r},code:n})=>p.jsx(t,{children:p.jsx(r,{node:e,children:n})}),Wy=()=>null,Jy=({node:e,components:{Pre:t,Code:r,SyntaxHighlighter:n,CodeHeader:i},language:s,code:a})=>{const o=y.useMemo(()=>({Pre:t,Code:r}),[t,r]),l=s?n:Ii;return p.jsxs(p.Fragment,{children:[p.jsx(i,{node:e,language:s,code:a}),p.jsx(l,{node:e,components:o,language:s!=null?s:"unknown",code:a})]})},Ei={exports:{}};var ll;function Gy(){return ll||(ll=1,(function(e){(function(){var t={}.hasOwnProperty;function r(){for(var s="",a=0;a<arguments.length;a++){var o=arguments[a];o&&(s=i(s,n(o)))}return s}function n(s){if(typeof s=="string"||typeof s=="number")return s;if(typeof s!="object")return"";if(Array.isArray(s))return r.apply(null,s);if(s.toString!==Object.prototype.toString&&!s.toString.toString().includes("[native code]"))return s.toString();var a="";for(var o in s)t.call(s,o)&&s[o]&&(a=i(a,o));return a}function i(s,a){return a?s?s+" "+a:s+a:s}e.exports?(r.default=r,e.exports=r):window.classNames=r})()})(Ei)),Ei.exports}var Yy=Gy();const ul=xr(Yy);var cl=r=>{var n=r,{className:e}=n,t=H(n,["className"]);return a=>{var o=a,{className:i}=o,s=H(o,["className"]);return m(m({className:ul(e,i)},t),s)}},Ky=l=>{var u=l,{node:e,components:{Pre:t,Code:r,SyntaxHighlighter:n,CodeHeader:i},componentsByLanguage:s={},children:a}=u,o=H(u,["node","components","componentsByLanguage","children"]);var C,_,F,B,I,z;const d=y.useContext(Ci),c=cl(d),f=ft(j=>p.jsx(t,m({},c(j)))),h=cl(o),g=ft(j=>p.jsx(r,m({},h(j)))),S=(_=(C=/language-(\w+)/.exec(o.className||""))==null?void 0:C[1])!=null?_:"";if(typeof a!="string")return p.jsx(Ii,{node:e,components:{Pre:f,Code:g},code:a});const w=(B=(F=s[S])==null?void 0:F.SyntaxHighlighter)!=null?B:n,b=(z=(I=s[S])==null?void 0:I.CodeHeader)!=null?z:i;return p.jsx(Jy,{node:e,components:{Pre:f,Code:g,SyntaxHighlighter:w,CodeHeader:b},language:S||"unknown",code:a})},Xy=i=>{var s=i,{node:e,components:t,componentsByLanguage:r}=s,n=H(s,["node","components","componentsByLanguage"]);return ol()?p.jsx(Ky,m({node:e,components:t,componentsByLanguage:r},n)):p.jsx(t.Code,m({},n))},Qy=y.memo(Xy,(e,t)=>e.components===t.components&&e.componentsByLanguage===t.componentsByLanguage&&Ti(e,t)),{useSmooth:Zy,useSmoothStatus:eb,withSmoothContextProvider:tb}=wh,rb=s=>{var a=s,{components:e,componentsByLanguage:t,smooth:r=!0,preprocess:n}=a,i=H(a,["components","componentsByLanguage","smooth","preprocess"]);const o=ca(),l=y.useMemo(()=>n?E(m({},o),{text:n(o.text)}):o,[o,n]),{text:u}=Zy(l,r),{pre:d=qy,code:c=Vy,SyntaxHighlighter:f=Ii,CodeHeader:h=Wy}=e!=null?e:{},g=y.useMemo(()=>({Pre:d,Code:c,SyntaxHighlighter:f,CodeHeader:h}),[d,c,f,h]),S=ft(b=>p.jsx(Qy,m({components:g,componentsByLanguage:t},b))),w=y.useMemo(()=>{const I=e!=null?e:{},{pre:b,code:C,SyntaxHighlighter:_,CodeHeader:F}=I,B=H(I,["pre","code","SyntaxHighlighter","CodeHeader"]);return E(m({},B),{pre:Hy,code:S})},[S,e]);return p.jsx(Dy,E(m({components:w},i),{children:u}))},dl=y.forwardRef((s,i)=>{var a=s,{className:e,containerProps:t,containerComponent:r="div"}=a,n=H(a,["className","containerProps","containerComponent"]);const o=eb();return p.jsx(r,E(m({"data-status":o.type},t),{className:ul(e,t==null?void 0:t.className),ref:i,children:p.jsx(rb,m({},n))}))});dl.displayName="MarkdownTextPrimitive";var nb=tb(dl);function hl(e,t){const r=String(e);if(typeof t!="string")throw new TypeError("Expected character");let n=0,i=r.indexOf(t);for(;i!==-1;)n++,i=r.indexOf(t,i+t.length);return n}function ib(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function sb(e,t,r){const i=Xr((r||{}).ignore||[]),s=ab(t);let a=-1;for(;++a<s.length;)Ko(e,"text",o);function o(u,d){let c=-1,f;for(;++c<d.length;){const h=d[c],g=f?f.children:void 0;if(i(h,g?g.indexOf(h):void 0,f))return;f=h}if(f)return l(u,d)}function l(u,d){const c=d[d.length-1],f=s[a][0],h=s[a][1];let g=0;const w=c.children.indexOf(u);let b=!1,C=[];f.lastIndex=0;let _=f.exec(u.value);for(;_;){const F=_.index,B={index:_.index,input:_.input,stack:[...d,u]};let I=h(..._,B);if(typeof I=="string"&&(I=I.length>0?{type:"text",value:I}:void 0),I===!1?f.lastIndex=F+1:(g!==F&&C.push({type:"text",value:u.value.slice(g,F)}),Array.isArray(I)?C.push(...I):I&&C.push(I),g=F+_[0].length,b=!0),!f.global)break;_=f.exec(u.value)}return b?(g<u.value.length&&C.push({type:"text",value:u.value.slice(g)}),c.children.splice(w,1,...C)):C=[u],w+C.length}}function ab(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const r=!e[0]||Array.isArray(e[0])?e:[e];let n=-1;for(;++n<r.length;){const i=r[n];t.push([ob(i[0]),lb(i[1])])}return t}function ob(e){return typeof e=="string"?new RegExp(ib(e),"g"):e}function lb(e){return typeof e=="function"?e:function(){return e}}const Ai="phrasing",Pi=["autolink","link","image","label"];function ub(){return{transforms:[gb],enter:{literalAutolink:db,literalAutolinkEmail:Mi,literalAutolinkHttp:Mi,literalAutolinkWww:Mi},exit:{literalAutolink:mb,literalAutolinkEmail:pb,literalAutolinkHttp:hb,literalAutolinkWww:fb}}}function cb(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Ai,notInConstruct:Pi},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Ai,notInConstruct:Pi},{character:":",before:"[ps]",after:"\\/",inConstruct:Ai,notInConstruct:Pi}]}}function db(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Mi(e){this.config.enter.autolinkProtocol.call(this,e)}function hb(e){this.config.exit.autolinkProtocol.call(this,e)}function fb(e){this.config.exit.data.call(this,e);const t=this.stack[this.stack.length-1];t.type,t.url="http://"+this.sliceSerialize(e)}function pb(e){this.config.exit.autolinkEmail.call(this,e)}function mb(e){this.exit(e)}function gb(e){sb(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,yb],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),bb]],{ignore:["link","linkReference"]})}function yb(e,t,r,n,i){let s="";if(!fl(i)||(/^w/i.test(t)&&(r=t+r,t="",s="http://"),!wb(r)))return!1;const a=xb(r+n);if(!a[0])return!1;const o={type:"link",title:null,url:s+t+a[0],children:[{type:"text",value:t+a[0]}]};return a[1]?[o,{type:"text",value:a[1]}]:o}function bb(e,t,r,n){return!fl(n,!0)||/[-\d_]$/.test(r)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+r,children:[{type:"text",value:t+"@"+r}]}}function wb(e){const t=e.split(".");return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function xb(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let r=t[0],n=r.indexOf(")");const i=hl(e,"(");let s=hl(e,")");for(;n!==-1&&i>s;)e+=r.slice(0,n+1),r=r.slice(n+1),n=r.indexOf(")"),s++;return[e,r]}function fl(e,t){const r=e.input.charCodeAt(e.index-1);return(e.index===0||mt(r)||Hr(r))&&(!t||r!==47)}pl.peek=Ab;function vb(){this.buffer()}function Sb(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function kb(){this.buffer()}function _b(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function Tb(e){const t=this.resume(),r=this.stack[this.stack.length-1];r.type,r.identifier=Ve(this.sliceSerialize(e)).toLowerCase(),r.label=t}function Cb(e){this.exit(e)}function Ib(e){const t=this.resume(),r=this.stack[this.stack.length-1];r.type,r.identifier=Ve(this.sliceSerialize(e)).toLowerCase(),r.label=t}function Eb(e){this.exit(e)}function Ab(){return"["}function pl(e,t,r,n){const i=r.createTracker(n);let s=i.move("[^");const a=r.enter("footnoteReference"),o=r.enter("reference");return s+=i.move(r.safe(r.associationId(e),{after:"]",before:s})),o(),a(),s+=i.move("]"),s}function Pb(){return{enter:{gfmFootnoteCallString:vb,gfmFootnoteCall:Sb,gfmFootnoteDefinitionLabelString:kb,gfmFootnoteDefinition:_b},exit:{gfmFootnoteCallString:Tb,gfmFootnoteCall:Cb,gfmFootnoteDefinitionLabelString:Ib,gfmFootnoteDefinition:Eb}}}function Mb(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:r,footnoteReference:pl},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function r(n,i,s,a){const o=s.createTracker(a);let l=o.move("[^");const u=s.enter("footnoteDefinition"),d=s.enter("label");return l+=o.move(s.safe(s.associationId(n),{before:l,after:"]"})),d(),l+=o.move("]:"),n.children&&n.children.length>0&&(o.shift(4),l+=o.move((t?`
21
+ `:" ")+s.indentLines(s.containerFlow(n,o.current()),t?ml:Lb))),u(),l}}function Lb(e,t,r){return t===0?e:ml(e,t,r)}function ml(e,t,r){return(r?"":" ")+e}const Nb=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];gl.peek=zb;function Db(){return{canContainEols:["delete"],enter:{strikethrough:Fb},exit:{strikethrough:Bb}}}function Ob(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:Nb}],handlers:{delete:gl}}}function Fb(e){this.enter({type:"delete",children:[]},e)}function Bb(e){this.exit(e)}function gl(e,t,r,n){const i=r.createTracker(n),s=r.enter("strikethrough");let a=i.move("~~");return a+=r.containerPhrasing(e,E(m({},i.current()),{before:a,after:"~"})),a+=i.move("~~"),s(),a}function zb(){return"~"}function Rb(e){return e.length}function jb(e,t){const r=t||{},n=(r.align||[]).concat(),i=r.stringLength||Rb,s=[],a=[],o=[],l=[];let u=0,d=-1;for(;++d<e.length;){const S=[],w=[];let b=-1;for(e[d].length>u&&(u=e[d].length);++b<e[d].length;){const C=Ub(e[d][b]);if(r.alignDelimiters!==!1){const _=i(C);w[b]=_,(l[b]===void 0||_>l[b])&&(l[b]=_)}S.push(C)}a[d]=S,o[d]=w}let c=-1;if(typeof n=="object"&&"length"in n)for(;++c<u;)s[c]=yl(n[c]);else{const S=yl(n);for(;++c<u;)s[c]=S}c=-1;const f=[],h=[];for(;++c<u;){const S=s[c];let w="",b="";S===99?(w=":",b=":"):S===108?w=":":S===114&&(b=":");let C=r.alignDelimiters===!1?1:Math.max(1,l[c]-w.length-b.length);const _=w+"-".repeat(C)+b;r.alignDelimiters!==!1&&(C=w.length+C+b.length,C>l[c]&&(l[c]=C),h[c]=C),f[c]=_}a.splice(1,0,f),o.splice(1,0,h),d=-1;const g=[];for(;++d<a.length;){const S=a[d],w=o[d];c=-1;const b=[];for(;++c<u;){const C=S[c]||"";let _="",F="";if(r.alignDelimiters!==!1){const B=l[c]-(w[c]||0),I=s[c];I===114?_=" ".repeat(B):I===99?B%2?(_=" ".repeat(B/2+.5),F=" ".repeat(B/2-.5)):(_=" ".repeat(B/2),F=_):F=" ".repeat(B)}r.delimiterStart!==!1&&!c&&b.push("|"),r.padding!==!1&&!(r.alignDelimiters===!1&&C==="")&&(r.delimiterStart!==!1||c)&&b.push(" "),r.alignDelimiters!==!1&&b.push(_),b.push(C),r.alignDelimiters!==!1&&b.push(F),r.padding!==!1&&b.push(" "),(r.delimiterEnd!==!1||c!==u-1)&&b.push("|")}g.push(r.delimiterEnd===!1?b.join("").replace(/ +$/,""):b.join(""))}return g.join(`
22
+ `)}function Ub(e){return e==null?"":String(e)}function yl(e){const t=typeof e=="string"?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function $b(e,t,r,n){const i=r.enter("blockquote"),s=r.createTracker(n);s.move("> "),s.shift(2);const a=r.indentLines(r.containerFlow(e,s.current()),Hb);return i(),a}function Hb(e,t,r){return">"+(r?"":" ")+e}function qb(e,t){return bl(e,t.inConstruct,!0)&&!bl(e,t.notInConstruct,!1)}function bl(e,t,r){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return r;let n=-1;for(;++n<t.length;)if(e.includes(t[n]))return!0;return!1}function wl(e,t,r,n){let i=-1;for(;++i<r.unsafe.length;)if(r.unsafe[i].character===`
23
+ `&&qb(r.stack,r.unsafe[i]))return/[ \t]/.test(n.before)?"":" ";return`\\
24
+ `}function Vb(e,t){const r=String(e);let n=r.indexOf(t),i=n,s=0,a=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;n!==-1;)n===i?++s>a&&(a=s):s=1,i=n+t.length,n=r.indexOf(t,i);return a}function Wb(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function Jb(e){const t=e.options.fence||"`";if(t!=="`"&&t!=="~")throw new Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function Gb(e,t,r,n){const i=Jb(r),s=e.value||"",a=i==="`"?"GraveAccent":"Tilde";if(Wb(e,r)){const c=r.enter("codeIndented"),f=r.indentLines(s,Yb);return c(),f}const o=r.createTracker(n),l=i.repeat(Math.max(Vb(s,i)+1,3)),u=r.enter("codeFenced");let d=o.move(l);if(e.lang){const c=r.enter(`codeFencedLang${a}`);d+=o.move(r.safe(e.lang,m({before:d,after:" ",encode:["`"]},o.current()))),c()}if(e.lang&&e.meta){const c=r.enter(`codeFencedMeta${a}`);d+=o.move(" "),d+=o.move(r.safe(e.meta,m({before:d,after:`
25
+ `,encode:["`"]},o.current()))),c()}return d+=o.move(`
26
+ `),s&&(d+=o.move(s+`
27
+ `)),d+=o.move(l),u(),d}function Yb(e,t,r){return(r?"":" ")+e}function Li(e){const t=e.options.quote||'"';if(t!=='"'&&t!=="'")throw new Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function Kb(e,t,r,n){const i=Li(r),s=i==='"'?"Quote":"Apostrophe",a=r.enter("definition");let o=r.enter("label");const l=r.createTracker(n);let u=l.move("[");return u+=l.move(r.safe(r.associationId(e),m({before:u,after:"]"},l.current()))),u+=l.move("]: "),o(),!e.url||/[\0- \u007F]/.test(e.url)?(o=r.enter("destinationLiteral"),u+=l.move("<"),u+=l.move(r.safe(e.url,m({before:u,after:">"},l.current()))),u+=l.move(">")):(o=r.enter("destinationRaw"),u+=l.move(r.safe(e.url,m({before:u,after:e.title?" ":`
28
+ `},l.current())))),o(),e.title&&(o=r.enter(`title${s}`),u+=l.move(" "+i),u+=l.move(r.safe(e.title,m({before:u,after:i},l.current()))),u+=l.move(i),o()),a(),u}function Xb(e){const t=e.options.emphasis||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function hr(e){return"&#x"+e.toString(16).toUpperCase()+";"}function en(e,t,r){const n=Ot(e),i=Ot(t);return n===void 0?i===void 0?r==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:n===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}xl.peek=Qb;function xl(e,t,r,n){const i=Xb(r),s=r.enter("emphasis"),a=r.createTracker(n),o=a.move(i);let l=a.move(r.containerPhrasing(e,m({after:i,before:o},a.current())));const u=l.charCodeAt(0),d=en(n.before.charCodeAt(n.before.length-1),u,i);d.inside&&(l=hr(u)+l.slice(1));const c=l.charCodeAt(l.length-1),f=en(n.after.charCodeAt(0),c,i);f.inside&&(l=l.slice(0,-1)+hr(c));const h=a.move(i);return s(),r.attentionEncodeSurroundingInfo={after:f.outside,before:d.outside},o+l+h}function Qb(e,t,r){return r.options.emphasis||"*"}function Zb(e,t){let r=!1;return hi(e,function(n){if("value"in n&&/\r?\n|\r/.test(n.value)||n.type==="break")return r=!0,di}),!!((!e.depth||e.depth<3)&&ei(e)&&(t.options.setext||r))}function ew(e,t,r,n){const i=Math.max(Math.min(6,e.depth||1),1),s=r.createTracker(n);if(Zb(e,r)){const d=r.enter("headingSetext"),c=r.enter("phrasing"),f=r.containerPhrasing(e,E(m({},s.current()),{before:`
37
29
  `,after:`
38
- `}));return g(),y(),v+`
39
- `+(s===1?"=":"-").repeat(v.length-(Math.max(v.lastIndexOf("\r"),v.lastIndexOf(`
40
- `))+1))}const c="#".repeat(s),d=a.enter("headingAtx"),h=a.enter("phrasing");o.move(c+" ");let m=a.containerPhrasing(t,_({before:"# ",after:`
41
- `},o.current()));return/^[\t ]/.test(m)&&(m=Wi(m.charCodeAt(0))+m.slice(1)),m=m?c+" "+m:c,a.options.closeAtx&&(m+=" "+c),h(),d(),m}Vg.peek=ER;function Vg(t){return t.value||""}function ER(){return"<"}Yg.peek=CR;function Yg(t,n,a,i){const s=Ac(a),o=s==='"'?"Quote":"Apostrophe",c=a.enter("image");let d=a.enter("label");const h=a.createTracker(i);let m=h.move("![");return m+=h.move(a.safe(t.alt,_({before:m,after:"]"},h.current()))),m+=h.move("]("),d(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(d=a.enter("destinationLiteral"),m+=h.move("<"),m+=h.move(a.safe(t.url,_({before:m,after:">"},h.current()))),m+=h.move(">")):(d=a.enter("destinationRaw"),m+=h.move(a.safe(t.url,_({before:m,after:t.title?" ":")"},h.current())))),d(),t.title&&(d=a.enter(`title${o}`),m+=h.move(" "+s),m+=h.move(a.safe(t.title,_({before:m,after:s},h.current()))),m+=h.move(s),d()),m+=h.move(")"),c(),m}function CR(){return"!"}Fg.peek=AR;function Fg(t,n,a,i){const s=t.referenceType,o=a.enter("imageReference");let c=a.enter("label");const d=a.createTracker(i);let h=d.move("![");const m=a.safe(t.alt,_({before:h,after:"]"},d.current()));h+=d.move(m+"]["),c();const y=a.stack;a.stack=[],c=a.enter("reference");const g=a.safe(a.associationId(t),_({before:h,after:"]"},d.current()));return c(),a.stack=y,o(),s==="full"||!m||m!==g?h+=d.move(g+"]"):s==="shortcut"?h=h.slice(0,-1):h+=d.move("]"),h}function AR(){return"!"}Gg.peek=kR;function Gg(t,n,a){let i=t.value||"",s="`",o=-1;for(;new RegExp("(^|[^`])"+s+"([^`]|$)").test(i);)s+="`";for(/[^ \r\n]/.test(i)&&(/^[ \r\n]/.test(i)&&/[ \r\n]$/.test(i)||/^`|`$/.test(i))&&(i=" "+i+" ");++o<a.unsafe.length;){const c=a.unsafe[o],d=a.compilePattern(c);let h;if(c.atBreak)for(;h=d.exec(i);){let m=h.index;i.charCodeAt(m)===10&&i.charCodeAt(m-1)===13&&m--,i=i.slice(0,m)+" "+i.slice(h.index+1)}}return s+i+s}function kR(){return"`"}function Pg(t,n){const a=Zo(t);return!!(!n.options.resourceLink&&t.url&&!t.title&&t.children&&t.children.length===1&&t.children[0].type==="text"&&(a===t.url||"mailto:"+a===t.url)&&/^[a-z][a-z+.-]+:/i.test(t.url)&&!/[\0- <>\u007F]/.test(t.url))}Xg.peek=RR;function Xg(t,n,a,i){const s=Ac(a),o=s==='"'?"Quote":"Apostrophe",c=a.createTracker(i);let d,h;if(Pg(t,a)){const y=a.stack;a.stack=[],d=a.enter("autolink");let g=c.move("<");return g+=c.move(a.containerPhrasing(t,_({before:g,after:">"},c.current()))),g+=c.move(">"),d(),a.stack=y,g}d=a.enter("link"),h=a.enter("label");let m=c.move("[");return m+=c.move(a.containerPhrasing(t,_({before:m,after:"]("},c.current()))),m+=c.move("]("),h(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(h=a.enter("destinationLiteral"),m+=c.move("<"),m+=c.move(a.safe(t.url,_({before:m,after:">"},c.current()))),m+=c.move(">")):(h=a.enter("destinationRaw"),m+=c.move(a.safe(t.url,_({before:m,after:t.title?" ":")"},c.current())))),h(),t.title&&(h=a.enter(`title${o}`),m+=c.move(" "+s),m+=c.move(a.safe(t.title,_({before:m,after:s},c.current()))),m+=c.move(s),h()),m+=c.move(")"),d(),m}function RR(t,n,a){return Pg(t,a)?"<":"["}Qg.peek=MR;function Qg(t,n,a,i){const s=t.referenceType,o=a.enter("linkReference");let c=a.enter("label");const d=a.createTracker(i);let h=d.move("[");const m=a.containerPhrasing(t,_({before:h,after:"]"},d.current()));h+=d.move(m+"]["),c();const y=a.stack;a.stack=[],c=a.enter("reference");const g=a.safe(a.associationId(t),_({before:h,after:"]"},d.current()));return c(),a.stack=y,o(),s==="full"||!m||m!==g?h+=d.move(g+"]"):s==="shortcut"?h=h.slice(0,-1):h+=d.move("]"),h}function MR(){return"["}function kc(t){const n=t.options.bullet||"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bullet`, expected `*`, `+`, or `-`");return n}function zR(t){const n=kc(t),a=t.options.bulletOther;if(!a)return n==="*"?"-":"*";if(a!=="*"&&a!=="+"&&a!=="-")throw new Error("Cannot serialize items with `"+a+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(a===n)throw new Error("Expected `bullet` (`"+n+"`) and `bulletOther` (`"+a+"`) to be different");return a}function OR(t){const n=t.options.bulletOrdered||".";if(n!=="."&&n!==")")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOrdered`, expected `.` or `)`");return n}function Zg(t){const n=t.options.rule||"*";if(n!=="*"&&n!=="-"&&n!=="_")throw new Error("Cannot serialize rules with `"+n+"` for `options.rule`, expected `*`, `-`, or `_`");return n}function DR(t,n,a,i){const s=a.enter("list"),o=a.bulletCurrent;let c=t.ordered?OR(a):kc(a);const d=t.ordered?c==="."?")":".":zR(a);let h=n&&a.bulletLastUsed?c===a.bulletLastUsed:!1;if(!t.ordered){const y=t.children?t.children[0]:void 0;if((c==="*"||c==="-")&&y&&(!y.children||!y.children[0])&&a.stack[a.stack.length-1]==="list"&&a.stack[a.stack.length-2]==="listItem"&&a.stack[a.stack.length-3]==="list"&&a.stack[a.stack.length-4]==="listItem"&&a.indexStack[a.indexStack.length-1]===0&&a.indexStack[a.indexStack.length-2]===0&&a.indexStack[a.indexStack.length-3]===0&&(h=!0),Zg(a)===c&&y){let g=-1;for(;++g<t.children.length;){const v=t.children[g];if(v&&v.type==="listItem"&&v.children&&v.children[0]&&v.children[0].type==="thematicBreak"){h=!0;break}}}}h&&(c=d),a.bulletCurrent=c;const m=a.containerFlow(t,i);return a.bulletLastUsed=c,a.bulletCurrent=o,s(),m}function NR(t){const n=t.options.listItemIndent||"one";if(n!=="tab"&&n!=="one"&&n!=="mixed")throw new Error("Cannot serialize items with `"+n+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return n}function IR(t,n,a,i){const s=NR(a);let o=a.bulletCurrent||kc(a);n&&n.type==="list"&&n.ordered&&(o=(typeof n.start=="number"&&n.start>-1?n.start:1)+(a.options.incrementListMarker===!1?0:n.children.indexOf(t))+o);let c=o.length+1;(s==="tab"||s==="mixed"&&(n&&n.type==="list"&&n.spread||t.spread))&&(c=Math.ceil(c/4)*4);const d=a.createTracker(i);d.move(o+" ".repeat(c-o.length)),d.shift(c);const h=a.enter("listItem"),m=a.indentLines(a.containerFlow(t,d.current()),y);return h(),m;function y(g,v,x){return v?(x?"":" ".repeat(c))+g:(x?o:o+" ".repeat(c-o.length))+g}}function jR(t,n,a,i){const s=a.enter("paragraph"),o=a.enter("phrasing"),c=a.containerPhrasing(t,i);return o(),s(),c}const LR=As(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function BR(t,n,a,i){return(t.children.some(function(c){return LR(c)})?a.containerPhrasing:a.containerFlow).call(a,t,i)}function UR(t){const n=t.options.strong||"*";if(n!=="*"&&n!=="_")throw new Error("Cannot serialize strong with `"+n+"` for `options.strong`, expected `*`, or `_`");return n}Kg.peek=HR;function Kg(t,n,a,i){const s=UR(a),o=a.enter("strong"),c=a.createTracker(i),d=c.move(s+s);let h=c.move(a.containerPhrasing(t,_({after:s,before:d},c.current())));const m=h.charCodeAt(0),y=Ms(i.before.charCodeAt(i.before.length-1),m,s);y.inside&&(h=Wi(m)+h.slice(1));const g=h.charCodeAt(h.length-1),v=Ms(i.after.charCodeAt(0),g,s);v.inside&&(h=h.slice(0,-1)+Wi(g));const x=c.move(s+s);return o(),a.attentionEncodeSurroundingInfo={after:v.outside,before:y.outside},d+h+x}function HR(t,n,a){return a.options.strong||"*"}function qR(t,n,a,i){return a.safe(t.value,i)}function VR(t){const n=t.options.ruleRepetition||3;if(n<3)throw new Error("Cannot serialize rules with repetition `"+n+"` for `options.ruleRepetition`, expected `3` or more");return n}function YR(t,n,a){const i=(Zg(a)+(a.options.ruleSpaces?" ":"")).repeat(VR(a));return a.options.ruleSpaces?i.slice(0,-1):i}const Jg={blockquote:dR,break:Hg,code:bR,definition:xR,emphasis:qg,hardBreak:Hg,heading:TR,html:Vg,image:Yg,imageReference:Fg,inlineCode:Gg,link:Xg,linkReference:Qg,list:DR,listItem:IR,paragraph:jR,root:BR,strong:Kg,text:qR,thematicBreak:YR};function FR(){return{enter:{table:GR,tableData:$g,tableHeader:$g,tableRow:XR},exit:{codeText:QR,table:PR,tableData:Rc,tableHeader:Rc,tableRow:Rc}}}function GR(t){const n=t._align;this.enter({type:"table",align:n.map(function(a){return a==="none"?null:a}),children:[]},t),this.data.inTable=!0}function PR(t){this.exit(t),this.data.inTable=void 0}function XR(t){this.enter({type:"tableRow",children:[]},t)}function Rc(t){this.exit(t)}function $g(t){this.enter({type:"tableCell",children:[]},t)}function QR(t){let n=this.resume();this.data.inTable&&(n=n.replace(/\\([\\|])/g,ZR));const a=this.stack[this.stack.length-1];a.type,a.value=n,this.exit(t)}function ZR(t,n){return n==="|"?n:t}function KR(t){const n=t||{},a=n.tableCellPadding,i=n.tablePipeAlign,s=n.stringLength,o=a?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
42
- `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:v,table:c,tableCell:h,tableRow:d}};function c(x,w,z,D){return m(y(x,z,D),x.align)}function d(x,w,z,D){const k=g(x,z,D),q=m([k]);return q.slice(0,q.indexOf(`
43
- `))}function h(x,w,z,D){const k=z.enter("tableCell"),q=z.enter("phrasing"),I=z.containerPhrasing(x,G(_({},D),{before:o,after:o}));return q(),k(),I}function m(x,w){return cR(x,{align:w,alignDelimiters:i,padding:a,stringLength:s})}function y(x,w,z){const D=x.children;let k=-1;const q=[],I=w.enter("table");for(;++k<D.length;)q[k]=g(D[k],w,z);return I(),q}function g(x,w,z){const D=x.children;let k=-1;const q=[],I=w.enter("tableRow");for(;++k<D.length;)q[k]=h(D[k],x,w,z);return I(),q}function v(x,w,z){let D=Jg.inlineCode(x,w,z);return z.stack.includes("tableCell")&&(D=D.replace(/\|/g,"\\$&")),D}}function JR(){return{exit:{taskListCheckValueChecked:Wg,taskListCheckValueUnchecked:Wg,paragraph:WR}}}function $R(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:t2}}}function Wg(t){const n=this.stack[this.stack.length-2];n.type,n.checked=t.type==="taskListCheckValueChecked"}function WR(t){const n=this.stack[this.stack.length-2];if(n&&n.type==="listItem"&&typeof n.checked=="boolean"){const a=this.stack[this.stack.length-1];a.type;const i=a.children[0];if(i&&i.type==="text"){const s=n.children;let o=-1,c;for(;++o<s.length;){const d=s[o];if(d.type==="paragraph"){c=d;break}}c===a&&(i.value=i.value.slice(1),i.value.length===0?a.children.shift():a.position&&i.position&&typeof i.position.start.offset=="number"&&(i.position.start.column++,i.position.start.offset++,a.position.start=Object.assign({},i.position.start)))}}this.exit(t)}function t2(t,n,a,i){const s=t.children[0],o=typeof t.checked=="boolean"&&s&&s.type==="paragraph",c="["+(t.checked?"x":" ")+"] ",d=a.createTracker(i);o&&d.move(c);let h=Jg.listItem(t,n,a,_(_({},i),d.current()));return o&&(h=h.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,m)),h;function m(y){return y+c}}function e2(){return[Dk(),tR(),aR(),FR(),JR()]}function n2(t){return{extensions:[Nk(),eR(t),iR(),KR(t),$R()]}}const r2={tokenize:o2,partial:!0},ty={tokenize:c2,partial:!0},ey={tokenize:f2,partial:!0},ny={tokenize:d2,partial:!0},a2={tokenize:h2,partial:!0},ry={name:"wwwAutolink",tokenize:s2,previous:iy},ay={name:"protocolAutolink",tokenize:u2,previous:ly},Zn={name:"emailAutolink",tokenize:l2,previous:sy},qn={};function i2(){return{text:qn}}let Wr=48;for(;Wr<123;)qn[Wr]=Zn,Wr++,Wr===58?Wr=65:Wr===91&&(Wr=97);qn[43]=Zn,qn[45]=Zn,qn[46]=Zn,qn[95]=Zn,qn[72]=[Zn,ay],qn[104]=[Zn,ay],qn[87]=[Zn,ry],qn[119]=[Zn,ry];function l2(t,n,a){const i=this;let s,o;return c;function c(g){return!Mc(g)||!sy.call(i,i.previous)||zc(i.events)?a(g):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),d(g))}function d(g){return Mc(g)?(t.consume(g),d):g===64?(t.consume(g),h):a(g)}function h(g){return g===46?t.check(a2,y,m)(g):g===45||g===95||Ne(g)?(o=!0,t.consume(g),h):y(g)}function m(g){return t.consume(g),s=!0,h}function y(g){return o&&s&&Be(i.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),n(g)):a(g)}}function s2(t,n,a){const i=this;return s;function s(c){return c!==87&&c!==119||!iy.call(i,i.previous)||zc(i.events)?a(c):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(r2,t.attempt(ty,t.attempt(ey,o),a),a)(c))}function o(c){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),n(c)}}function u2(t,n,a){const i=this;let s="",o=!1;return c;function c(g){return(g===72||g===104)&&ly.call(i,i.previous)&&!zc(i.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),s+=String.fromCodePoint(g),t.consume(g),d):a(g)}function d(g){if(Be(g)&&s.length<5)return s+=String.fromCodePoint(g),t.consume(g),d;if(g===58){const v=s.toLowerCase();if(v==="http"||v==="https")return t.consume(g),h}return a(g)}function h(g){return g===47?(t.consume(g),o?m:(o=!0,h)):a(g)}function m(g){return g===null||bs(g)||$t(g)||$r(g)||vs(g)?a(g):t.attempt(ty,t.attempt(ey,y),a)(g)}function y(g){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),n(g)}}function o2(t,n,a){let i=0;return s;function s(c){return(c===87||c===119)&&i<3?(i++,t.consume(c),s):c===46&&i===3?(t.consume(c),o):a(c)}function o(c){return c===null?a(c):n(c)}}function c2(t,n,a){let i,s,o;return c;function c(m){return m===46||m===95?t.check(ny,h,d)(m):m===null||$t(m)||$r(m)||m!==45&&vs(m)?h(m):(o=!0,t.consume(m),c)}function d(m){return m===95?i=!0:(s=i,i=void 0),t.consume(m),c}function h(m){return s||i||!o?a(m):n(m)}}function f2(t,n){let a=0,i=0;return s;function s(c){return c===40?(a++,t.consume(c),s):c===41&&i<a?o(c):c===33||c===34||c===38||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===60||c===63||c===93||c===95||c===126?t.check(ny,n,o)(c):c===null||$t(c)||$r(c)?n(c):(t.consume(c),s)}function o(c){return c===41&&i++,t.consume(c),s}}function d2(t,n,a){return i;function i(d){return d===33||d===34||d===39||d===41||d===42||d===44||d===46||d===58||d===59||d===63||d===95||d===126?(t.consume(d),i):d===38?(t.consume(d),o):d===93?(t.consume(d),s):d===60||d===null||$t(d)||$r(d)?n(d):a(d)}function s(d){return d===null||d===40||d===91||$t(d)||$r(d)?n(d):i(d)}function o(d){return Be(d)?c(d):a(d)}function c(d){return d===59?(t.consume(d),i):Be(d)?(t.consume(d),c):a(d)}}function h2(t,n,a){return i;function i(o){return t.consume(o),s}function s(o){return Ne(o)?a(o):n(o)}}function iy(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||$t(t)}function ly(t){return!Be(t)}function sy(t){return!(t===47||Mc(t))}function Mc(t){return t===43||t===45||t===46||t===95||Ne(t)}function zc(t){let n=t.length,a=!1;for(;n--;){const i=t[n][1];if((i.type==="labelLink"||i.type==="labelImage")&&!i._balanced){a=!0;break}if(i._gfmAutolinkLiteralWalkedInto){a=!1;break}}return t.length>0&&!a&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),a}const p2={tokenize:w2,partial:!0};function m2(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:v2,continuation:{tokenize:x2},exit:S2}},text:{91:{name:"gfmFootnoteCall",tokenize:b2},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:g2,resolveTo:y2}}}}function g2(t,n,a){const i=this;let s=i.events.length;const o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let c;for(;s--;){const h=i.events[s][1];if(h.type==="labelImage"){c=h;break}if(h.type==="gfmFootnoteCall"||h.type==="labelLink"||h.type==="label"||h.type==="image"||h.type==="link")break}return d;function d(h){if(!c||!c._balanced)return a(h);const m=Dn(i.sliceSerialize({start:c.end,end:i.now()}));return m.codePointAt(0)!==94||!o.includes(m.slice(1))?a(h):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(h),t.exit("gfmFootnoteCallLabelMarker"),n(h))}}function y2(t,n){let a=t.length;for(;a--;)if(t[a][1].type==="labelImage"&&t[a][0]==="enter"){t[a][1];break}t[a+1][1].type="data",t[a+3][1].type="gfmFootnoteCallLabelMarker";const i={type:"gfmFootnoteCall",start:Object.assign({},t[a+3][1].start),end:Object.assign({},t[t.length-1][1].end)},s={type:"gfmFootnoteCallMarker",start:Object.assign({},t[a+3][1].end),end:Object.assign({},t[a+3][1].end)};s.end.column++,s.end.offset++,s.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},s.end),end:Object.assign({},t[t.length-1][1].start)},c={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},d=[t[a+1],t[a+2],["enter",i,n],t[a+3],t[a+4],["enter",s,n],["exit",s,n],["enter",o,n],["enter",c,n],["exit",c,n],["exit",o,n],t[t.length-2],t[t.length-1],["exit",i,n]];return t.splice(a,t.length-a+1,...d),t}function b2(t,n,a){const i=this,s=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let o=0,c;return d;function d(g){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(g),t.exit("gfmFootnoteCallLabelMarker"),h}function h(g){return g!==94?a(g):(t.enter("gfmFootnoteCallMarker"),t.consume(g),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",m)}function m(g){if(o>999||g===93&&!c||g===null||g===91||$t(g))return a(g);if(g===93){t.exit("chunkString");const v=t.exit("gfmFootnoteCallString");return s.includes(Dn(i.sliceSerialize(v)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(g),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),n):a(g)}return $t(g)||(c=!0),o++,t.consume(g),g===92?y:m}function y(g){return g===91||g===92||g===93?(t.consume(g),o++,m):m(g)}}function v2(t,n,a){const i=this,s=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let o,c=0,d;return h;function h(w){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(w),t.exit("gfmFootnoteDefinitionLabelMarker"),m}function m(w){return w===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(w),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",y):a(w)}function y(w){if(c>999||w===93&&!d||w===null||w===91||$t(w))return a(w);if(w===93){t.exit("chunkString");const z=t.exit("gfmFootnoteDefinitionLabelString");return o=Dn(i.sliceSerialize(z)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(w),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),v}return $t(w)||(d=!0),c++,t.consume(w),w===92?g:y}function g(w){return w===91||w===92||w===93?(t.consume(w),c++,y):y(w)}function v(w){return w===58?(t.enter("definitionMarker"),t.consume(w),t.exit("definitionMarker"),s.includes(o)||s.push(o),Ut(t,x,"gfmFootnoteDefinitionWhitespace")):a(w)}function x(w){return n(w)}}function x2(t,n,a){return t.check(Xi,n,t.attempt(p2,n,a))}function S2(t){t.exit("gfmFootnoteDefinition")}function w2(t,n,a){const i=this;return Ut(t,s,"gfmFootnoteDefinitionIndent",5);function s(o){const c=i.events[i.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?n(o):a(o)}}function _2(t){let a=(t||{}).singleTilde;const i={name:"strikethrough",tokenize:o,resolveAll:s};return a==null&&(a=!0),{text:{126:i},insideSpan:{null:[i]},attentionMarkers:{null:[126]}};function s(c,d){let h=-1;for(;++h<c.length;)if(c[h][0]==="enter"&&c[h][1].type==="strikethroughSequenceTemporary"&&c[h][1]._close){let m=h;for(;m--;)if(c[m][0]==="exit"&&c[m][1].type==="strikethroughSequenceTemporary"&&c[m][1]._open&&c[h][1].end.offset-c[h][1].start.offset===c[m][1].end.offset-c[m][1].start.offset){c[h][1].type="strikethroughSequence",c[m][1].type="strikethroughSequence";const y={type:"strikethrough",start:Object.assign({},c[m][1].start),end:Object.assign({},c[h][1].end)},g={type:"strikethroughText",start:Object.assign({},c[m][1].end),end:Object.assign({},c[h][1].start)},v=[["enter",y,d],["enter",c[m][1],d],["exit",c[m][1],d],["enter",g,d]],x=d.parser.constructs.insideSpan.null;x&&an(v,v.length,0,xs(x,c.slice(m+1,h),d)),an(v,v.length,0,[["exit",g,d],["enter",c[h][1],d],["exit",c[h][1],d],["exit",y,d]]),an(c,m-1,h-m+3,v),h=m+v.length-2;break}}for(h=-1;++h<c.length;)c[h][1].type==="strikethroughSequenceTemporary"&&(c[h][1].type="data");return c}function o(c,d,h){const m=this.previous,y=this.events;let g=0;return v;function v(w){return m===126&&y[y.length-1][1].type!=="characterEscape"?h(w):(c.enter("strikethroughSequenceTemporary"),x(w))}function x(w){const z=La(m);if(w===126)return g>1?h(w):(c.consume(w),g++,x);if(g<2&&!a)return h(w);const D=c.exit("strikethroughSequenceTemporary"),k=La(w);return D._open=!k||k===2&&!!z,D._close=!z||z===2&&!!k,d(w)}}}class T2{constructor(){this.map=[]}add(n,a,i){E2(this,n,a,i)}consume(n){if(this.map.sort(function(o,c){return o[0]-c[0]}),this.map.length===0)return;let a=this.map.length;const i=[];for(;a>0;)a-=1,i.push(n.slice(this.map[a][0]+this.map[a][1]),this.map[a][2]),n.length=this.map[a][0];i.push(n.slice()),n.length=0;let s=i.pop();for(;s;){for(const o of s)n.push(o);s=i.pop()}this.map.length=0}}function E2(t,n,a,i){let s=0;if(!(a===0&&i.length===0)){for(;s<t.map.length;){if(t.map[s][0]===n){t.map[s][1]+=a,t.map[s][2].push(...i);return}s+=1}t.map.push([n,a,i])}}function C2(t,n){let a=!1;const i=[];for(;n<t.length;){const s=t[n];if(a){if(s[0]==="enter")s[1].type==="tableContent"&&i.push(t[n+1][1].type==="tableDelimiterMarker"?"left":"none");else if(s[1].type==="tableContent"){if(t[n-1][1].type==="tableDelimiterMarker"){const o=i.length-1;i[o]=i[o]==="left"?"center":"right"}}else if(s[1].type==="tableDelimiterRow")break}else s[0]==="enter"&&s[1].type==="tableDelimiterRow"&&(a=!0);n+=1}return i}function A2(){return{flow:{null:{name:"table",tokenize:k2,resolveAll:R2}}}}function k2(t,n,a){const i=this;let s=0,o=0,c;return d;function d(j){let tt=i.events.length-1;for(;tt>-1;){const ot=i.events[tt][1].type;if(ot==="lineEnding"||ot==="linePrefix")tt--;else break}const $=tt>-1?i.events[tt][1].type:null,bt=$==="tableHead"||$==="tableRow"?L:h;return bt===L&&i.parser.lazy[i.now().line]?a(j):bt(j)}function h(j){return t.enter("tableHead"),t.enter("tableRow"),m(j)}function m(j){return j===124||(c=!0,o+=1),y(j)}function y(j){return j===null?a(j):St(j)?o>1?(o=0,i.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(j),t.exit("lineEnding"),x):a(j):zt(j)?Ut(t,y,"whitespace")(j):(o+=1,c&&(c=!1,s+=1),j===124?(t.enter("tableCellDivider"),t.consume(j),t.exit("tableCellDivider"),c=!0,y):(t.enter("data"),g(j)))}function g(j){return j===null||j===124||$t(j)?(t.exit("data"),y(j)):(t.consume(j),j===92?v:g)}function v(j){return j===92||j===124?(t.consume(j),g):g(j)}function x(j){return i.interrupt=!1,i.parser.lazy[i.now().line]?a(j):(t.enter("tableDelimiterRow"),c=!1,zt(j)?Ut(t,w,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(j):w(j))}function w(j){return j===45||j===58?D(j):j===124?(c=!0,t.enter("tableCellDivider"),t.consume(j),t.exit("tableCellDivider"),z):lt(j)}function z(j){return zt(j)?Ut(t,D,"whitespace")(j):D(j)}function D(j){return j===58?(o+=1,c=!0,t.enter("tableDelimiterMarker"),t.consume(j),t.exit("tableDelimiterMarker"),k):j===45?(o+=1,k(j)):j===null||St(j)?at(j):lt(j)}function k(j){return j===45?(t.enter("tableDelimiterFiller"),q(j)):lt(j)}function q(j){return j===45?(t.consume(j),q):j===58?(c=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(j),t.exit("tableDelimiterMarker"),I):(t.exit("tableDelimiterFiller"),I(j))}function I(j){return zt(j)?Ut(t,at,"whitespace")(j):at(j)}function at(j){return j===124?w(j):j===null||St(j)?!c||s!==o?lt(j):(t.exit("tableDelimiterRow"),t.exit("tableHead"),n(j)):lt(j)}function lt(j){return a(j)}function L(j){return t.enter("tableRow"),J(j)}function J(j){return j===124?(t.enter("tableCellDivider"),t.consume(j),t.exit("tableCellDivider"),J):j===null||St(j)?(t.exit("tableRow"),n(j)):zt(j)?Ut(t,J,"whitespace")(j):(t.enter("data"),st(j))}function st(j){return j===null||j===124||$t(j)?(t.exit("data"),J(j)):(t.consume(j),j===92?ct:st)}function ct(j){return j===92||j===124?(t.consume(j),st):st(j)}}function R2(t,n){let a=-1,i=!0,s=0,o=[0,0,0,0],c=[0,0,0,0],d=!1,h=0,m,y,g;const v=new T2;for(;++a<t.length;){const x=t[a],w=x[1];x[0]==="enter"?w.type==="tableHead"?(d=!1,h!==0&&(uy(v,n,h,m,y),y=void 0,h=0),m={type:"table",start:Object.assign({},w.start),end:Object.assign({},w.end)},v.add(a,0,[["enter",m,n]])):w.type==="tableRow"||w.type==="tableDelimiterRow"?(i=!0,g=void 0,o=[0,0,0,0],c=[0,a+1,0,0],d&&(d=!1,y={type:"tableBody",start:Object.assign({},w.start),end:Object.assign({},w.end)},v.add(a,0,[["enter",y,n]])),s=w.type==="tableDelimiterRow"?2:y?3:1):s&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")?(i=!1,c[2]===0&&(o[1]!==0&&(c[0]=c[1],g=zs(v,n,o,s,void 0,g),o=[0,0,0,0]),c[2]=a)):w.type==="tableCellDivider"&&(i?i=!1:(o[1]!==0&&(c[0]=c[1],g=zs(v,n,o,s,void 0,g)),o=c,c=[o[1],a,0,0])):w.type==="tableHead"?(d=!0,h=a):w.type==="tableRow"||w.type==="tableDelimiterRow"?(h=a,o[1]!==0?(c[0]=c[1],g=zs(v,n,o,s,a,g)):c[1]!==0&&(g=zs(v,n,c,s,a,g)),s=0):s&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")&&(c[3]=a)}for(h!==0&&uy(v,n,h,m,y),v.consume(n.events),a=-1;++a<n.events.length;){const x=n.events[a];x[0]==="enter"&&x[1].type==="table"&&(x[1]._align=C2(n.events,a))}return t}function zs(t,n,a,i,s,o){const c=i===1?"tableHeader":i===2?"tableDelimiter":"tableData",d="tableContent";a[0]!==0&&(o.end=Object.assign({},Ua(n.events,a[0])),t.add(a[0],0,[["exit",o,n]]));const h=Ua(n.events,a[1]);if(o={type:c,start:Object.assign({},h),end:Object.assign({},h)},t.add(a[1],0,[["enter",o,n]]),a[2]!==0){const m=Ua(n.events,a[2]),y=Ua(n.events,a[3]),g={type:d,start:Object.assign({},m),end:Object.assign({},y)};if(t.add(a[2],0,[["enter",g,n]]),i!==2){const v=n.events[a[2]],x=n.events[a[3]];if(v[1].end=Object.assign({},x[1].end),v[1].type="chunkText",v[1].contentType="text",a[3]>a[2]+1){const w=a[2]+1,z=a[3]-a[2]-1;t.add(w,z,[])}}t.add(a[3]+1,0,[["exit",g,n]])}return s!==void 0&&(o.end=Object.assign({},Ua(n.events,s)),t.add(s,0,[["exit",o,n]]),o=void 0),o}function uy(t,n,a,i,s){const o=[],c=Ua(n.events,a);s&&(s.end=Object.assign({},c),o.push(["exit",s,n])),i.end=Object.assign({},c),o.push(["exit",i,n]),t.add(a+1,0,o)}function Ua(t,n){const a=t[n],i=a[0]==="enter"?"start":"end";return a[1][i]}const M2={name:"tasklistCheck",tokenize:O2};function z2(){return{text:{91:M2}}}function O2(t,n,a){const i=this;return s;function s(h){return i.previous!==null||!i._gfmTasklistFirstContentOfListItem?a(h):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(h),t.exit("taskListCheckMarker"),o)}function o(h){return $t(h)?(t.enter("taskListCheckValueUnchecked"),t.consume(h),t.exit("taskListCheckValueUnchecked"),c):h===88||h===120?(t.enter("taskListCheckValueChecked"),t.consume(h),t.exit("taskListCheckValueChecked"),c):a(h)}function c(h){return h===93?(t.enter("taskListCheckMarker"),t.consume(h),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),d):a(h)}function d(h){return St(h)?n(h):zt(h)?t.check({tokenize:D2},n,a)(h):a(h)}}function D2(t,n,a){return Ut(t,i,"whitespace");function i(s){return s===null?a(s):n(s)}}function N2(t){return Bm([i2(),m2(),_2(t),A2(),z2()])}const I2={};function j2(t){const n=this,a=t||I2,i=n.data(),s=i.micromarkExtensions||(i.micromarkExtensions=[]),o=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),c=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);s.push(N2(a)),o.push(e2()),c.push(n2(a))}function xe(...t){return t.filter(Boolean).join(" ")}const L2=({content:t})=>E.jsx(Ak,{remarkPlugins:[j2],className:"cuadra-aui-md",components:H2,children:t}),oy=R.memo(L2),B2=({language:t,code:n})=>{const{isCopied:a,copyToClipboard:i}=U2(),s=()=>{!n||a||i(n)};return E.jsxs("div",{className:"cuadra-flex cuadra-items-center cuadra-justify-between cuadra-gap-4 cuadra-mt-4 cuadra-rounded-t-lg cuadra-bg-muted/50 cuadra-border-b cuadra-border-border cuadra-px-4 cuadra-py-2 cuadra-text-sm cuadra-font-normal cuadra-text-foreground cuadra-font-brand",children:[E.jsx("span",{className:"cuadra-lowercase [&>span]:cuadra-text-xs cuadra-font-brand",children:t}),E.jsxs("button",{onClick:s,className:"cuadra-p-1 cuadra-rounded hover:cuadra-bg-muted cuadra-transition-colors","aria-label":"Copy code",children:[!a&&E.jsx(HS,{className:"cuadra-h-4 cuadra-w-4"}),a&&E.jsx(LS,{className:"cuadra-h-4 cuadra-w-4"})]})]})},U2=({copiedDuration:t=3e3}={})=>{const[n,a]=R.useState(!1);return{isCopied:n,copyToClipboard:s=>{s&&navigator.clipboard.writeText(s).then(()=>{a(!0),setTimeout(()=>a(!1),t)})}}},H2=fk({h1:a=>{var i=a,{className:t}=i,n=gt(i,["className"]);return E.jsx("h1",_({className:xe("cuadra-mb-6 cuadra-scroll-m-20 cuadra-text-2xl cuadra-font-normal cuadra-tracking-tight last:cuadra-mb-0 font-brand",t)},n))},h2:a=>{var i=a,{className:t}=i,n=gt(i,["className"]);return E.jsx("h2",_({className:xe("cuadra-mb-4 cuadra-mt-6 cuadra-scroll-m-20 cuadra-text-xl cuadra-font-normal cuadra-tracking-tight first:cuadra-mt-0 last:cuadra-mb-0 font-brand",t)},n))},h3:a=>{var i=a,{className:t}=i,n=gt(i,["className"]);return E.jsx("h3",_({className:xe("cuadra-mb-3 cuadra-mt-5 cuadra-scroll-m-20 cuadra-text-lg cuadra-font-normal cuadra-tracking-tight first:cuadra-mt-0 last:cuadra-mb-0 font-brand",t)},n))},h4:a=>{var i=a,{className:t}=i,n=gt(i,["className"]);return E.jsx("h4",_({className:xe("cuadra-mb-4 cuadra-mt-6 cuadra-scroll-m-20 cuadra-text-xl cuadra-font-normal cuadra-tracking-tight first:cuadra-mt-0 last:cuadra-mb-0 font-brand",t)},n))},h5:a=>{var i=a,{className:t}=i,n=gt(i,["className"]);return E.jsx("h5",_({className:xe("cuadra-my-4 cuadra-text-lg cuadra-font-normal first:cuadra-mt-0 last:cuadra-mb-0 font-brand",t)},n))},h6:a=>{var i=a,{className:t}=i,n=gt(i,["className"]);return E.jsx("h6",_({className:xe("cuadra-my-4 cuadra-font-normal first:cuadra-mb-0 font-brand",t)},n))},p:a=>{var i=a,{className:t}=i,n=gt(i,["className"]);return E.jsx("p",_({className:xe("cuadra-mb-5 cuadra-mt-5 cuadra-leading-7 first:cuadra-mt-0 last:cuadra-mb-0 font-brand",t)},n))},a:a=>{var i=a,{className:t}=i,n=gt(i,["className"]);return E.jsx("a",_({className:xe("cuadra-text-primary cuadra-font-medium cuadra-underline cuadra-underline-offset-4 font-brand",t)},n))},blockquote:a=>{var i=a,{className:t}=i,n=gt(i,["className"]);return E.jsx("blockquote",_({className:xe("cuadra-border-l-2 cuadra-pl-6 cuadra-italic font-brand",t)},n))},ul:a=>{var i=a,{className:t}=i,n=gt(i,["className"]);return E.jsx("ul",_({className:xe("cuadra-my-5 cuadra-ml-6 cuadra-list-disc [&>li]:cuadra-mt-2 font-brand",t)},n))},ol:a=>{var i=a,{className:t}=i,n=gt(i,["className"]);return E.jsx("ol",_({className:xe("cuadra-my-5 cuadra-ml-6 cuadra-list-decimal [&>li]:cuadra-mt-2 font-brand",t)},n))},hr:a=>{var i=a,{className:t}=i,n=gt(i,["className"]);return E.jsx("hr",_({className:xe("cuadra-my-5 cuadra-border-b",t)},n))},table:a=>{var i=a,{className:t}=i,n=gt(i,["className"]);return E.jsx("table",_({className:xe("cuadra-my-5 cuadra-w-full cuadra-border-separate cuadra-border-spacing-0 cuadra-overflow-y-auto font-brand",t)},n))},th:a=>{var i=a,{className:t}=i,n=gt(i,["className"]);return E.jsx("th",_({className:xe("cuadra-bg-muted cuadra-px-4 cuadra-py-2 cuadra-text-left cuadra-font-normal first:cuadra-rounded-tl-lg last:cuadra-rounded-tr-lg [&[align=center]]:cuadra-text-center [&[align=right]]:cuadra-text-right font-brand",t)},n))},td:a=>{var i=a,{className:t}=i,n=gt(i,["className"]);return E.jsx("td",_({className:xe("cuadra-border-b cuadra-border-l cuadra-px-4 cuadra-py-2 cuadra-text-left last:cuadra-border-r [&[align=center]]:cuadra-text-center [&[align=right]]:cuadra-text-right font-brand",t)},n))},tr:a=>{var i=a,{className:t}=i,n=gt(i,["className"]);return E.jsx("tr",_({className:xe("cuadra-m-0 cuadra-border-b cuadra-p-0 first:cuadra-border-t [&:last-child>td:first-child]:cuadra-rounded-bl-lg [&:last-child>td:last-child]:cuadra-rounded-br-lg",t)},n))},sup:a=>{var i=a,{className:t}=i,n=gt(i,["className"]);return E.jsx("sup",_({className:xe("[&>a]:cuadra-text-xs [&>a]:cuadra-no-underline font-brand",t)},n))},pre:a=>{var i=a,{className:t}=i,n=gt(i,["className"]);return E.jsx("pre",_({className:xe("cuadra-overflow-x-auto cuadra-rounded-b-lg !cuadra-rounded-t-none cuadra-bg-muted cuadra-p-4 cuadra-text-foreground font-brand",t)},n))},code:function(i){var s=i,{className:n}=s,a=gt(s,["className"]);const o=kg();return E.jsx("code",_({className:xe(!o&&"cuadra-bg-muted cuadra-rounded cuadra-border cuadra-font-normal font-brand",n)},a))},CodeHeader:B2}),cy=["Sending question…","Understanding your need…","Scanning data…","Comparing results…","Composing answer…"];function q2({active:t}){const[n,a]=R.useState(0);return R.useEffect(()=>{if(!t){a(0);return}const i=window.setInterval(()=>{a(s=>s>=cy.length-1?(window.clearInterval(i),s):s+1)},2500);return()=>window.clearInterval(i)},[t]),t?E.jsxs("span",{className:"cuadra-text-xs cuadra-text-muted-foreground cuadra-font-brand",children:["Thinking… ",cy[n]]}):null}function fy({welcomeTitle:t="Hi, how can I help you today?",welcomeSubtitle:n="Start exploring our platform and discover what you can build.",extraTopPadding:a,suggestions:i,inputPlaceholder:s="Type your message..."}={}){const o=up(),[c,d]=R.useState(!1),[h,m]=R.useState(null),[y,g]=R.useState(!1);return R.useEffect(()=>{var v,x;if(!o){d(!1);return}try{const w=o==null?void 0:o.store;if(!w){d(!1);return}const z=(v=w.subscribe)==null?void 0:v.call(w,k=>{const q=k==null?void 0:k.threadId,I=(k==null?void 0:k.messages)||[],at=(k==null?void 0:k.isLoadingHistory)||!1,lt=I.length;q&&q!==h&&m(q),d(at&&lt===0);const J=I.some(st=>st.role==="assistant"&&!!st.content&&(Array.isArray(st.content)?st.content.some(ct=>typeof ct=="object"&&(ct!=null&&ct.text)?ct.text.trim().length>0:!1):typeof st.content=="string"?st.content.trim().length>0:!1));g(J)}),D=(x=w.getState)==null?void 0:x.call(w);if(D){const k=D==null?void 0:D.threadId,q=(D==null?void 0:D.messages)||[],I=(D==null?void 0:D.isLoadingHistory)||!1,at=q.length;k&&k!==h&&m(k),d(I&&at===0);const L=q.some(J=>J.role==="assistant"&&!!J.content&&(Array.isArray(J.content)?J.content.some(st=>typeof st=="object"&&(st!=null&&st.text)?st.text.trim().length>0:!1):typeof J.content=="string"?J.content.trim().length>0:!1));g(L)}return()=>{z&&z()}}catch(w){d(!1)}},[o,h]),E.jsxs(Zp,{className:"cuadra-bg-inherit cuadra-flex cuadra-flex-col cuadra-w-full cuadra-h-full",children:[E.jsx(Wp,{className:"cuadra-w-full cuadra-bg-inherit cuadra-px-4 cuadra-flex-1 cuadra-min-h-0 cuadra-overflow-y-auto cuadra-relative scrollbar-thin cuadra-pt-4",style:a?{paddingTop:a}:void 0,children:c?E.jsx("div",{className:"cuadra-absolute cuadra-inset-0 cuadra-flex cuadra-items-center cuadra-justify-center",children:E.jsxs("div",{className:"cuadra-flex cuadra-flex-col cuadra-items-center cuadra-gap-2",children:[E.jsx(ch,{className:"cuadra-h-6 cuadra-w-6 cuadra-animate-spin cuadra-text-muted-foreground"}),E.jsx("p",{className:"cuadra-text-sm cuadra-text-muted-foreground font-brand",children:"Loading messages..."})]})}):E.jsxs(E.Fragment,{children:[E.jsx(Kp,{children:E.jsx(V2,{title:t,subtitle:n,suggestions:i})}),E.jsx(G_,{components:{UserMessage:Y2,AssistantMessage:F2}}),E.jsx(Jp,{running:!0,children:!y&&E.jsx("div",{className:"cuadra-mt-2 cuadra-max-w-2xl",children:E.jsx(q2,{active:!0})})})]})}),E.jsx("div",{className:"cuadra-w-full cuadra-mt-3 cuadra-border-t cuadra-border-border cuadra-pt-4",children:E.jsxs(qp,{className:"cuadra-relative !cuadra-relative cuadra-flex-1 cuadra-w-full",children:[E.jsx(Qp,{asChild:!0,children:E.jsx("textarea",{rows:3,placeholder:s,className:"cuadra-flex cuadra-min-h-[80px] cuadra-w-full cuadra-rounded-md cuadra-border cuadra-border-border cuadra-bg-background cuadra-px-3 cuadra-py-2 cuadra-text-base placeholder:cuadra-text-muted-foreground focus-visible:cuadra-outline-none disabled:cuadra-cursor-not-allowed disabled:cuadra-opacity-50 cuadra-resize-none cuadra-pr-10 font-brand",style:{paddingRight:"2.5rem",fontSize:"1rem",borderWidth:"1px"}})}),E.jsx(x_,{asChild:!0,children:E.jsx("button",{className:"!cuadra-absolute !cuadra-bottom-2 !cuadra-right-2 cuadra-size-8 cuadra-rounded-md cuadra-shadow-sm hover:cuadra-opacity-90 disabled:cuadra-opacity-50 disabled:cuadra-cursor-not-allowed cuadra-flex cuadra-items-center cuadra-justify-center",style:{position:"absolute",bottom:"0.5rem",right:"0.5rem",backgroundColor:"var(--primary)",color:"hsl(var(--primary-foreground))"},"aria-label":"Send message",type:"button",children:E.jsx(jS,{className:"cuadra-h-4 cuadra-w-4"})})})]})})]})}function V2({title:t,subtitle:n,suggestions:a}){const i=de(),s=o=>W(null,null,function*(){try{i.composer().setText(o),yield new Promise(c=>setTimeout(c,10)),i.composer().send()}catch(c){}});return E.jsx("div",{className:"cuadra-flex cuadra-flex-col cuadra-items-center cuadra-h-full cuadra-py-12 cuadra-px-4 cuadra-overflow-y-auto scrollbar-hide",children:E.jsxs("div",{className:"cuadra-text-center cuadra-max-w-3xl cuadra-w-full cuadra-flex cuadra-flex-col cuadra-items-center cuadra-justify-center cuadra-min-h-full",children:[E.jsxs("div",{className:"cuadra-flex cuadra-flex-col cuadra-items-center cuadra-justify-center cuadra-mb-8",children:[E.jsx("h2",{className:"cuadra-text-lg cuadra-font-normal cuadra-text-foreground cuadra-mb-2 font-brand",children:t}),E.jsx("p",{className:"cuadra-text-muted-foreground font-brand",children:n})]}),a&&a.length>0&&E.jsx("div",{className:"cuadra-grid cuadra-grid-cols-2 cuadra-gap-2 cuadra-pb-4 cuadra-w-full cuadra-max-w-2xl",children:a.map((o,c)=>E.jsx("button",{type:"button",onClick:()=>s(o.prompt),className:"cuadra-w-full cuadra-text-center cuadra-px-4 cuadra-py-3 cuadra-rounded-lg cuadra-border cuadra-border-border cuadra-bg-background cuadra-text-sm font-brand cuadra-cursor-pointer focus:cuadra-outline-none focus:cuadra-ring-0",style:{borderWidth:"1px"},children:o.prompt},`suggestion-${c}`))})]})})}function Y2(){return E.jsx(Oo,{className:"cuadra-grid cuadra-w-full cuadra-auto-rows-auto cuadra-grid-cols-[minmax(72px,1fr)_auto] cuadra-gap-y-2 cuadra-py-3 [&:where(>*)]:cuadra-col-start-2",children:E.jsx("div",{className:"cuadra-bg-muted cuadra-text-foreground cuadra-col-start-2 cuadra-row-start-2 cuadra-max-w-[calc(42rem*0.8)] cuadra-break-words cuadra-rounded-3xl cuadra-border cuadra-border-border cuadra-px-5 cuadra-py-2.5 font-brand",style:{maxWidth:"calc(42rem * 0.8)",borderRadius:"1.5rem",backgroundColor:"hsl(var(--muted))",color:"hsl(var(--foreground))",paddingLeft:"1.25rem",paddingRight:"1.25rem",paddingTop:"0.625rem",paddingBottom:"0.625rem",wordBreak:"break-word",borderWidth:"1px"},children:E.jsx(Do,{components:{Text:({text:t})=>E.jsx(oy,{content:t||""})}})})})}function F2(){return E.jsx(Oo,{className:"cuadra-relative cuadra-grid cuadra-w-full cuadra-grid-cols-[auto_auto_1fr] cuadra-grid-rows-[auto_1fr] cuadra-py-3",children:E.jsx("div",{className:"cuadra-text-foreground cuadra-col-span-2 cuadra-col-start-2 cuadra-row-start-1 cuadra-my-1.5 cuadra-max-w-[90%] cuadra-break-words cuadra-leading-7 font-brand",style:{maxWidth:"90%",marginTop:"0.375rem",marginBottom:"0.375rem"},children:E.jsx(Do,{components:{Text:({text:t})=>E.jsx(oy,{content:t||""})}})})})}function G2({onThreadSelect:t}){var D,k;const n=op(),a=X1(q=>q.threadId),[i,s]=R.useState(null),o=(n==null?void 0:n.id)===a,c=i===(n==null?void 0:n.id),[d,h]=R.useState(!1),[m,y]=R.useState((n==null?void 0:n.title)||""),[g,v]=R.useState(!1),[x,w]=R.useState(!1),z=()=>W(null,null,function*(){if(!(n!=null&&n.remoteId)||!m||m===n.title){h(!1);return}try{w(!0);const q=window.__cuadraThreadListAdapter;q&&typeof q.rename=="function"&&(yield q.rename(n.remoteId,m)),h(!1),v(!1)}catch(q){h(!1),v(!1)}finally{w(!1)}});return R.useEffect(()=>{n!=null&&n.title&&!d&&y(n.title)},[n==null?void 0:n.title,d]),n?E.jsx(sm,{className:`group cuadra-relative cuadra-flex cuadra-items-center cuadra-gap-3 cuadra-rounded-lg cuadra-transition-colors cuadra-cursor-pointer cuadra-border cuadra-mb-2 ${o?"cuadra-bg-muted cuadra-border-border":"cuadra-border-transparent hover:cuadra-bg-muted hover:cuadra-border-border"}`,style:{marginBottom:"0.5rem"},onMouseEnter:()=>s(n.id),onMouseLeave:()=>s(null),children:E.jsxs(Z_,{className:"cuadra-p-3 cuadra-flex-1 cuadra-flex cuadra-items-center cuadra-justify-between cuadra-w-full cuadra-min-w-0 cuadra-cursor-pointer",onClick:()=>t==null?void 0:t(),children:[E.jsx("div",{className:"cuadra-flex cuadra-flex-col cuadra-min-w-0 cuadra-flex-1 cuadra-items-start cuadra-text-left",children:d?E.jsx("input",{className:"cuadra-flex cuadra-w-full cuadra-rounded-md cuadra-border cuadra-border-input cuadra-bg-background cuadra-px-3 cuadra-py-2 cuadra-text-sm placeholder:cuadra-text-muted-foreground focus-visible:cuadra-outline-none disabled:cuadra-cursor-not-allowed disabled:cuadra-opacity-50 font-brand",value:m,onChange:q=>y(q.target.value),onKeyDown:q=>{q.key==="Enter"&&z(),q.key==="Escape"&&(h(!1),y(n.title||""))},disabled:x,autoFocus:!0,onClick:q=>q.stopPropagation()}):E.jsxs(E.Fragment,{children:[E.jsx("span",{className:"cuadra-text-sm cuadra-font-normal cuadra-text-foreground cuadra-truncate font-brand",children:(((D=n.title)==null?void 0:D.length)||0)>60?`${(k=n.title)==null?void 0:k.slice(0,60)}…`:n.title||"Chat"}),n.updatedAt&&E.jsx("span",{className:"cuadra-text-xs cuadra-text-muted-foreground cuadra-mt-1 font-brand",children:new Date(n.updatedAt).toLocaleDateString()})]})}),E.jsx("div",{className:"cuadra-ml-2 cuadra-flex-shrink-0 cuadra-w-6 cuadra-h-6 cuadra-flex cuadra-items-center cuadra-justify-center",children:(c||o||g)&&E.jsxs("div",{className:"cuadra-relative",children:[E.jsx("button",{className:"cuadra-p-1 cuadra-rounded hover:cuadra-bg-background/50 cuadra-transition-colors",onClick:q=>{q.stopPropagation(),v(!g)},"aria-label":"Thread options",children:E.jsx(qS,{className:"cuadra-h-4 cuadra-w-4 cuadra-text-muted-foreground"})}),g&&E.jsxs(E.Fragment,{children:[E.jsx("div",{className:"cuadra-fixed cuadra-inset-0 cuadra-z-40",onClick:()=>v(!1)}),E.jsx("div",{className:"cuadra-absolute cuadra-right-0 cuadra-top-8 cuadra-z-50 cuadra-bg-background cuadra-border cuadra-border-border cuadra-rounded-lg cuadra-shadow-lg cuadra-min-w-[120px] cuadra-overflow-hidden",children:d?E.jsx("button",{className:"cuadra-w-full cuadra-px-3 cuadra-py-2 cuadra-text-sm cuadra-text-left hover:cuadra-bg-muted cuadra-transition-colors font-brand",onClick:q=>{q.stopPropagation(),z()},disabled:x,children:"Save"}):E.jsxs(E.Fragment,{children:[E.jsx("button",{className:"cuadra-w-full cuadra-px-3 cuadra-py-2 cuadra-text-sm cuadra-text-left hover:cuadra-bg-muted cuadra-transition-colors font-brand",onClick:q=>{q.stopPropagation(),h(!0),y(n.title||""),v(!1)},children:"Rename"}),E.jsx("div",{className:"cuadra-border-t cuadra-border-border"}),E.jsx(X_,{asChild:!0,children:E.jsx("button",{className:"cuadra-w-full cuadra-px-3 cuadra-py-2 cuadra-text-sm cuadra-text-left cuadra-text-destructive hover:cuadra-bg-muted cuadra-transition-colors font-brand",onClick:q=>{q.stopPropagation(),v(!1)},children:"Delete"})})]})})]})]})})]})}):null}function dy({onThreadSelect:t}){return E.jsxs(lm,{className:"!cuadra-border-r cuadra-border-border cuadra-flex cuadra-flex-col cuadra-bg-background cuadra-transition-all cuadra-duration-300 cuadra-ease-in-out cuadra-h-full cuadra-w-80",style:{borderRightWidth:"1px"},children:[E.jsx("div",{className:"cuadra-border-b cuadra-border-border cuadra-flex cuadra-items-center cuadra-justify-between cuadra-transition-all cuadra-duration-300 cuadra-h-16 cuadra-px-4",children:E.jsx("h3",{className:"cuadra-text-sm cuadra-font-normal cuadra-text-foreground cuadra-text-nowrap font-brand",children:"Chat History"})}),E.jsxs("div",{className:"cuadra-flex-1 cuadra-overflow-y-auto cuadra-p-2 scrollbar-thin",children:[E.jsx(rm,{className:"group cuadra-relative cuadra-flex cuadra-items-center cuadra-gap-3 cuadra-p-3 cuadra-rounded-lg cuadra-cursor-pointer cuadra-transition-colors cuadra-border cuadra-border-transparent hover:cuadra-bg-muted hover:cuadra-border-border",onClick:()=>t==null?void 0:t(),children:E.jsx("div",{className:"cuadra-flex-1 cuadra-min-w-0",children:E.jsxs("div",{className:"cuadra-flex cuadra-items-center cuadra-gap-2",children:[E.jsx(YS,{className:"cuadra-h-4 cuadra-w-4 cuadra-text-muted-foreground"}),E.jsx("h4",{className:"cuadra-text-sm cuadra-font-normal cuadra-text-foreground font-brand",children:"New Chat"})]})})}),E.jsx("div",{className:"cuadra-my-2 cuadra-border-t cuadra-border-border"}),E.jsx(im,{components:{ThreadListItem:n=>E.jsx(G2,G(_({},n),{onThreadSelect:t}))}})]})]})}const P2=`
30
+ `}));return c(),d(),f+`
31
+ `+(i===1?"=":"-").repeat(f.length-(Math.max(f.lastIndexOf("\r"),f.lastIndexOf(`
32
+ `))+1))}const a="#".repeat(i),o=r.enter("headingAtx"),l=r.enter("phrasing");s.move(a+" ");let u=r.containerPhrasing(e,m({before:"# ",after:`
33
+ `},s.current()));return/^[\t ]/.test(u)&&(u=hr(u.charCodeAt(0))+u.slice(1)),u=u?a+" "+u:a,r.options.closeAtx&&(u+=" "+a),l(),o(),u}vl.peek=tw;function vl(e){return e.value||""}function tw(){return"<"}Sl.peek=rw;function Sl(e,t,r,n){const i=Li(r),s=i==='"'?"Quote":"Apostrophe",a=r.enter("image");let o=r.enter("label");const l=r.createTracker(n);let u=l.move("![");return u+=l.move(r.safe(e.alt,m({before:u,after:"]"},l.current()))),u+=l.move("]("),o(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(o=r.enter("destinationLiteral"),u+=l.move("<"),u+=l.move(r.safe(e.url,m({before:u,after:">"},l.current()))),u+=l.move(">")):(o=r.enter("destinationRaw"),u+=l.move(r.safe(e.url,m({before:u,after:e.title?" ":")"},l.current())))),o(),e.title&&(o=r.enter(`title${s}`),u+=l.move(" "+i),u+=l.move(r.safe(e.title,m({before:u,after:i},l.current()))),u+=l.move(i),o()),u+=l.move(")"),a(),u}function rw(){return"!"}kl.peek=nw;function kl(e,t,r,n){const i=e.referenceType,s=r.enter("imageReference");let a=r.enter("label");const o=r.createTracker(n);let l=o.move("![");const u=r.safe(e.alt,m({before:l,after:"]"},o.current()));l+=o.move(u+"]["),a();const d=r.stack;r.stack=[],a=r.enter("reference");const c=r.safe(r.associationId(e),m({before:l,after:"]"},o.current()));return a(),r.stack=d,s(),i==="full"||!u||u!==c?l+=o.move(c+"]"):i==="shortcut"?l=l.slice(0,-1):l+=o.move("]"),l}function nw(){return"!"}_l.peek=iw;function _l(e,t,r){let n=e.value||"",i="`",s=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(n);)i+="`";for(/[^ \r\n]/.test(n)&&(/^[ \r\n]/.test(n)&&/[ \r\n]$/.test(n)||/^`|`$/.test(n))&&(n=" "+n+" ");++s<r.unsafe.length;){const a=r.unsafe[s],o=r.compilePattern(a);let l;if(a.atBreak)for(;l=o.exec(n);){let u=l.index;n.charCodeAt(u)===10&&n.charCodeAt(u-1)===13&&u--,n=n.slice(0,u)+" "+n.slice(l.index+1)}}return i+n+i}function iw(){return"`"}function Tl(e,t){const r=ei(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(r===e.url||"mailto:"+r===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}Cl.peek=sw;function Cl(e,t,r,n){const i=Li(r),s=i==='"'?"Quote":"Apostrophe",a=r.createTracker(n);let o,l;if(Tl(e,r)){const d=r.stack;r.stack=[],o=r.enter("autolink");let c=a.move("<");return c+=a.move(r.containerPhrasing(e,m({before:c,after:">"},a.current()))),c+=a.move(">"),o(),r.stack=d,c}o=r.enter("link"),l=r.enter("label");let u=a.move("[");return u+=a.move(r.containerPhrasing(e,m({before:u,after:"]("},a.current()))),u+=a.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=r.enter("destinationLiteral"),u+=a.move("<"),u+=a.move(r.safe(e.url,m({before:u,after:">"},a.current()))),u+=a.move(">")):(l=r.enter("destinationRaw"),u+=a.move(r.safe(e.url,m({before:u,after:e.title?" ":")"},a.current())))),l(),e.title&&(l=r.enter(`title${s}`),u+=a.move(" "+i),u+=a.move(r.safe(e.title,m({before:u,after:i},a.current()))),u+=a.move(i),l()),u+=a.move(")"),o(),u}function sw(e,t,r){return Tl(e,r)?"<":"["}Il.peek=aw;function Il(e,t,r,n){const i=e.referenceType,s=r.enter("linkReference");let a=r.enter("label");const o=r.createTracker(n);let l=o.move("[");const u=r.containerPhrasing(e,m({before:l,after:"]"},o.current()));l+=o.move(u+"]["),a();const d=r.stack;r.stack=[],a=r.enter("reference");const c=r.safe(r.associationId(e),m({before:l,after:"]"},o.current()));return a(),r.stack=d,s(),i==="full"||!u||u!==c?l+=o.move(c+"]"):i==="shortcut"?l=l.slice(0,-1):l+=o.move("]"),l}function aw(){return"["}function Ni(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function ow(e){const t=Ni(e),r=e.options.bulletOther;if(!r)return t==="*"?"-":"*";if(r!=="*"&&r!=="+"&&r!=="-")throw new Error("Cannot serialize items with `"+r+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(r===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+r+"`) to be different");return r}function lw(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function El(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function uw(e,t,r,n){const i=r.enter("list"),s=r.bulletCurrent;let a=e.ordered?lw(r):Ni(r);const o=e.ordered?a==="."?")":".":ow(r);let l=t&&r.bulletLastUsed?a===r.bulletLastUsed:!1;if(!e.ordered){const d=e.children?e.children[0]:void 0;if((a==="*"||a==="-")&&d&&(!d.children||!d.children[0])&&r.stack[r.stack.length-1]==="list"&&r.stack[r.stack.length-2]==="listItem"&&r.stack[r.stack.length-3]==="list"&&r.stack[r.stack.length-4]==="listItem"&&r.indexStack[r.indexStack.length-1]===0&&r.indexStack[r.indexStack.length-2]===0&&r.indexStack[r.indexStack.length-3]===0&&(l=!0),El(r)===a&&d){let c=-1;for(;++c<e.children.length;){const f=e.children[c];if(f&&f.type==="listItem"&&f.children&&f.children[0]&&f.children[0].type==="thematicBreak"){l=!0;break}}}}l&&(a=o),r.bulletCurrent=a;const u=r.containerFlow(e,n);return r.bulletLastUsed=a,r.bulletCurrent=s,i(),u}function cw(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function dw(e,t,r,n){const i=cw(r);let s=r.bulletCurrent||Ni(r);t&&t.type==="list"&&t.ordered&&(s=(typeof t.start=="number"&&t.start>-1?t.start:1)+(r.options.incrementListMarker===!1?0:t.children.indexOf(e))+s);let a=s.length+1;(i==="tab"||i==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(a=Math.ceil(a/4)*4);const o=r.createTracker(n);o.move(s+" ".repeat(a-s.length)),o.shift(a);const l=r.enter("listItem"),u=r.indentLines(r.containerFlow(e,o.current()),d);return l(),u;function d(c,f,h){return f?(h?"":" ".repeat(a))+c:(h?s:s+" ".repeat(a-s.length))+c}}function hw(e,t,r,n){const i=r.enter("paragraph"),s=r.enter("phrasing"),a=r.containerPhrasing(e,n);return s(),i(),a}const fw=Xr(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function pw(e,t,r,n){return(e.children.some(function(a){return fw(a)})?r.containerPhrasing:r.containerFlow).call(r,e,n)}function mw(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Al.peek=gw;function Al(e,t,r,n){const i=mw(r),s=r.enter("strong"),a=r.createTracker(n),o=a.move(i+i);let l=a.move(r.containerPhrasing(e,m({after:i,before:o},a.current())));const u=l.charCodeAt(0),d=en(n.before.charCodeAt(n.before.length-1),u,i);d.inside&&(l=hr(u)+l.slice(1));const c=l.charCodeAt(l.length-1),f=en(n.after.charCodeAt(0),c,i);f.inside&&(l=l.slice(0,-1)+hr(c));const h=a.move(i+i);return s(),r.attentionEncodeSurroundingInfo={after:f.outside,before:d.outside},o+l+h}function gw(e,t,r){return r.options.strong||"*"}function yw(e,t,r,n){return r.safe(e.value,n)}function bw(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function ww(e,t,r){const n=(El(r)+(r.options.ruleSpaces?" ":"")).repeat(bw(r));return r.options.ruleSpaces?n.slice(0,-1):n}const Pl={blockquote:$b,break:wl,code:Gb,definition:Kb,emphasis:xl,hardBreak:wl,heading:ew,html:vl,image:Sl,imageReference:kl,inlineCode:_l,link:Cl,linkReference:Il,list:uw,listItem:dw,paragraph:hw,root:pw,strong:Al,text:yw,thematicBreak:ww};function xw(){return{enter:{table:vw,tableData:Ml,tableHeader:Ml,tableRow:kw},exit:{codeText:_w,table:Sw,tableData:Di,tableHeader:Di,tableRow:Di}}}function vw(e){const t=e._align;this.enter({type:"table",align:t.map(function(r){return r==="none"?null:r}),children:[]},e),this.data.inTable=!0}function Sw(e){this.exit(e),this.data.inTable=void 0}function kw(e){this.enter({type:"tableRow",children:[]},e)}function Di(e){this.exit(e)}function Ml(e){this.enter({type:"tableCell",children:[]},e)}function _w(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Tw));const r=this.stack[this.stack.length-1];r.type,r.value=t,this.exit(e)}function Tw(e,t){return t==="|"?t:e}function Cw(e){const t=e||{},r=t.tableCellPadding,n=t.tablePipeAlign,i=t.stringLength,s=r?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
34
+ `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:f,table:a,tableCell:l,tableRow:o}};function a(h,g,S,w){return u(d(h,S,w),h.align)}function o(h,g,S,w){const b=c(h,S,w),C=u([b]);return C.slice(0,C.indexOf(`
35
+ `))}function l(h,g,S,w){const b=S.enter("tableCell"),C=S.enter("phrasing"),_=S.containerPhrasing(h,E(m({},w),{before:s,after:s}));return C(),b(),_}function u(h,g){return jb(h,{align:g,alignDelimiters:n,padding:r,stringLength:i})}function d(h,g,S){const w=h.children;let b=-1;const C=[],_=g.enter("table");for(;++b<w.length;)C[b]=c(w[b],g,S);return _(),C}function c(h,g,S){const w=h.children;let b=-1;const C=[],_=g.enter("tableRow");for(;++b<w.length;)C[b]=l(w[b],h,g,S);return _(),C}function f(h,g,S){let w=Pl.inlineCode(h,g,S);return S.stack.includes("tableCell")&&(w=w.replace(/\|/g,"\\$&")),w}}function Iw(){return{exit:{taskListCheckValueChecked:Ll,taskListCheckValueUnchecked:Ll,paragraph:Aw}}}function Ew(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:Pw}}}function Ll(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function Aw(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const r=this.stack[this.stack.length-1];r.type;const n=r.children[0];if(n&&n.type==="text"){const i=t.children;let s=-1,a;for(;++s<i.length;){const o=i[s];if(o.type==="paragraph"){a=o;break}}a===r&&(n.value=n.value.slice(1),n.value.length===0?r.children.shift():r.position&&n.position&&typeof n.position.start.offset=="number"&&(n.position.start.column++,n.position.start.offset++,r.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function Pw(e,t,r,n){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",a="["+(e.checked?"x":" ")+"] ",o=r.createTracker(n);s&&o.move(a);let l=Pl.listItem(e,t,r,m(m({},n),o.current()));return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),l;function u(d){return d+a}}function Mw(){return[ub(),Pb(),Db(),xw(),Iw()]}function Lw(e){return{extensions:[cb(),Mb(e),Ob(),Cw(e),Ew()]}}const Nw={tokenize:Rw,partial:!0},Nl={tokenize:jw,partial:!0},Dl={tokenize:Uw,partial:!0},Ol={tokenize:$w,partial:!0},Dw={tokenize:Hw,partial:!0},Fl={name:"wwwAutolink",tokenize:Bw,previous:zl},Bl={name:"protocolAutolink",tokenize:zw,previous:Rl},tt={name:"emailAutolink",tokenize:Fw,previous:jl},Xe={};function Ow(){return{text:Xe}}let gt=48;for(;gt<123;)Xe[gt]=tt,gt++,gt===58?gt=65:gt===91&&(gt=97);Xe[43]=tt,Xe[45]=tt,Xe[46]=tt,Xe[95]=tt,Xe[72]=[tt,Bl],Xe[104]=[tt,Bl],Xe[87]=[tt,Fl],Xe[119]=[tt,Fl];function Fw(e,t,r){const n=this;let i,s;return a;function a(c){return!Oi(c)||!jl.call(n,n.previous)||Fi(n.events)?r(c):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),o(c))}function o(c){return Oi(c)?(e.consume(c),o):c===64?(e.consume(c),l):r(c)}function l(c){return c===46?e.check(Dw,d,u)(c):c===45||c===95||xe(c)?(s=!0,e.consume(c),l):d(c)}function u(c){return e.consume(c),i=!0,l}function d(c){return s&&i&&Te(n.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(c)):r(c)}}function Bw(e,t,r){const n=this;return i;function i(a){return a!==87&&a!==119||!zl.call(n,n.previous)||Fi(n.events)?r(a):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(Nw,e.attempt(Nl,e.attempt(Dl,s),r),r)(a))}function s(a){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(a)}}function zw(e,t,r){const n=this;let i="",s=!1;return a;function a(c){return(c===72||c===104)&&Rl.call(n,n.previous)&&!Fi(n.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(c),e.consume(c),o):r(c)}function o(c){if(Te(c)&&i.length<5)return i+=String.fromCodePoint(c),e.consume(c),o;if(c===58){const f=i.toLowerCase();if(f==="http"||f==="https")return e.consume(c),l}return r(c)}function l(c){return c===47?(e.consume(c),s?u:(s=!0,l)):r(c)}function u(c){return c===null||$r(c)||te(c)||mt(c)||Hr(c)?r(c):e.attempt(Nl,e.attempt(Dl,d),r)(c)}function d(c){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(c)}}function Rw(e,t,r){let n=0;return i;function i(a){return(a===87||a===119)&&n<3?(n++,e.consume(a),i):a===46&&n===3?(e.consume(a),s):r(a)}function s(a){return a===null?r(a):t(a)}}function jw(e,t,r){let n,i,s;return a;function a(u){return u===46||u===95?e.check(Ol,l,o)(u):u===null||te(u)||mt(u)||u!==45&&Hr(u)?l(u):(s=!0,e.consume(u),a)}function o(u){return u===95?n=!0:(i=n,n=void 0),e.consume(u),a}function l(u){return i||n||!s?r(u):t(u)}}function Uw(e,t){let r=0,n=0;return i;function i(a){return a===40?(r++,e.consume(a),i):a===41&&n<r?s(a):a===33||a===34||a===38||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===60||a===63||a===93||a===95||a===126?e.check(Ol,t,s)(a):a===null||te(a)||mt(a)?t(a):(e.consume(a),i)}function s(a){return a===41&&n++,e.consume(a),i}}function $w(e,t,r){return n;function n(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),n):o===38?(e.consume(o),s):o===93?(e.consume(o),i):o===60||o===null||te(o)||mt(o)?t(o):r(o)}function i(o){return o===null||o===40||o===91||te(o)||mt(o)?t(o):n(o)}function s(o){return Te(o)?a(o):r(o)}function a(o){return o===59?(e.consume(o),n):Te(o)?(e.consume(o),a):r(o)}}function Hw(e,t,r){return n;function n(s){return e.consume(s),i}function i(s){return xe(s)?r(s):t(s)}}function zl(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||te(e)}function Rl(e){return!Te(e)}function jl(e){return!(e===47||Oi(e))}function Oi(e){return e===43||e===45||e===46||e===95||xe(e)}function Fi(e){let t=e.length,r=!1;for(;t--;){const n=e[t][1];if((n.type==="labelLink"||n.type==="labelImage")&&!n._balanced){r=!0;break}if(n._gfmAutolinkLiteralWalkedInto){r=!1;break}}return e.length>0&&!r&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),r}const qw={tokenize:Qw,partial:!0};function Vw(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:Yw,continuation:{tokenize:Kw},exit:Xw}},text:{91:{name:"gfmFootnoteCall",tokenize:Gw},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Ww,resolveTo:Jw}}}}function Ww(e,t,r){const n=this;let i=n.events.length;const s=n.parser.gfmFootnotes||(n.parser.gfmFootnotes=[]);let a;for(;i--;){const l=n.events[i][1];if(l.type==="labelImage"){a=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return o;function o(l){if(!a||!a._balanced)return r(l);const u=Ve(n.sliceSerialize({start:a.end,end:n.now()}));return u.codePointAt(0)!==94||!s.includes(u.slice(1))?r(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function Jw(e,t){let r=e.length;for(;r--;)if(e[r][1].type==="labelImage"&&e[r][0]==="enter"){e[r][1];break}e[r+1][1].type="data",e[r+3][1].type="gfmFootnoteCallLabelMarker";const n={type:"gfmFootnoteCall",start:Object.assign({},e[r+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[r+3][1].end),end:Object.assign({},e[r+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},a={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},o=[e[r+1],e[r+2],["enter",n,t],e[r+3],e[r+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",a,t],["exit",a,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",n,t]];return e.splice(r,e.length-r+1,...o),e}function Gw(e,t,r){const n=this,i=n.parser.gfmFootnotes||(n.parser.gfmFootnotes=[]);let s=0,a;return o;function o(c){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),l}function l(c){return c!==94?r(c):(e.enter("gfmFootnoteCallMarker"),e.consume(c),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(c){if(s>999||c===93&&!a||c===null||c===91||te(c))return r(c);if(c===93){e.exit("chunkString");const f=e.exit("gfmFootnoteCallString");return i.includes(Ve(n.sliceSerialize(f)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):r(c)}return te(c)||(a=!0),s++,e.consume(c),c===92?d:u}function d(c){return c===91||c===92||c===93?(e.consume(c),s++,u):u(c)}}function Yw(e,t,r){const n=this,i=n.parser.gfmFootnotes||(n.parser.gfmFootnotes=[]);let s,a=0,o;return l;function l(g){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(g){return g===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",d):r(g)}function d(g){if(a>999||g===93&&!o||g===null||g===91||te(g))return r(g);if(g===93){e.exit("chunkString");const S=e.exit("gfmFootnoteDefinitionLabelString");return s=Ve(n.sliceSerialize(S)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),f}return te(g)||(o=!0),a++,e.consume(g),g===92?c:d}function c(g){return g===91||g===92||g===93?(e.consume(g),a++,d):d(g)}function f(g){return g===58?(e.enter("definitionMarker"),e.consume(g),e.exit("definitionMarker"),i.includes(s)||i.push(s),X(e,h,"gfmFootnoteDefinitionWhitespace")):r(g)}function h(g){return t(g)}}function Kw(e,t,r){return e.check(ar,t,e.attempt(qw,t,r))}function Xw(e){e.exit("gfmFootnoteDefinition")}function Qw(e,t,r){const n=this;return X(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const a=n.events[n.events.length-1];return a&&a[1].type==="gfmFootnoteDefinitionIndent"&&a[2].sliceSerialize(a[1],!0).length===4?t(s):r(s)}}function Zw(e){let r=(e||{}).singleTilde;const n={name:"strikethrough",tokenize:s,resolveAll:i};return r==null&&(r=!0),{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function i(a,o){let l=-1;for(;++l<a.length;)if(a[l][0]==="enter"&&a[l][1].type==="strikethroughSequenceTemporary"&&a[l][1]._close){let u=l;for(;u--;)if(a[u][0]==="exit"&&a[u][1].type==="strikethroughSequenceTemporary"&&a[u][1]._open&&a[l][1].end.offset-a[l][1].start.offset===a[u][1].end.offset-a[u][1].start.offset){a[l][1].type="strikethroughSequence",a[u][1].type="strikethroughSequence";const d={type:"strikethrough",start:Object.assign({},a[u][1].start),end:Object.assign({},a[l][1].end)},c={type:"strikethroughText",start:Object.assign({},a[u][1].end),end:Object.assign({},a[l][1].start)},f=[["enter",d,o],["enter",a[u][1],o],["exit",a[u][1],o],["enter",c,o]],h=o.parser.constructs.insideSpan.null;h&&Le(f,f.length,0,qr(h,a.slice(u+1,l),o)),Le(f,f.length,0,[["exit",c,o],["enter",a[l][1],o],["exit",a[l][1],o],["exit",d,o]]),Le(a,u-1,l-u+3,f),l=u+f.length-2;break}}for(l=-1;++l<a.length;)a[l][1].type==="strikethroughSequenceTemporary"&&(a[l][1].type="data");return a}function s(a,o,l){const u=this.previous,d=this.events;let c=0;return f;function f(g){return u===126&&d[d.length-1][1].type!=="characterEscape"?l(g):(a.enter("strikethroughSequenceTemporary"),h(g))}function h(g){const S=Ot(u);if(g===126)return c>1?l(g):(a.consume(g),c++,h);if(c<2&&!r)return l(g);const w=a.exit("strikethroughSequenceTemporary"),b=Ot(g);return w._open=!b||b===2&&!!S,w._close=!S||S===2&&!!b,o(g)}}}class ex{constructor(){this.map=[]}add(t,r,n){tx(this,t,r,n)}consume(t){if(this.map.sort(function(s,a){return s[0]-a[0]}),this.map.length===0)return;let r=this.map.length;const n=[];for(;r>0;)r-=1,n.push(t.slice(this.map[r][0]+this.map[r][1]),this.map[r][2]),t.length=this.map[r][0];n.push(t.slice()),t.length=0;let i=n.pop();for(;i;){for(const s of i)t.push(s);i=n.pop()}this.map.length=0}}function tx(e,t,r,n){let i=0;if(!(r===0&&n.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=r,e.map[i][2].push(...n);return}i+=1}e.map.push([t,r,n])}}function rx(e,t){let r=!1;const n=[];for(;t<e.length;){const i=e[t];if(r){if(i[0]==="enter")i[1].type==="tableContent"&&n.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const s=n.length-1;n[s]=n[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(r=!0);t+=1}return n}function nx(){return{flow:{null:{name:"table",tokenize:ix,resolveAll:sx}}}}function ix(e,t,r){const n=this;let i=0,s=0,a;return o;function o(k){let N=n.events.length-1;for(;N>-1;){const R=n.events[N][1].type;if(R==="lineEnding"||R==="linePrefix")N--;else break}const M=N>-1?n.events[N][1].type:null,V=M==="tableHead"||M==="tableRow"?I:l;return V===I&&n.parser.lazy[n.now().line]?r(k):V(k)}function l(k){return e.enter("tableHead"),e.enter("tableRow"),u(k)}function u(k){return k===124||(a=!0,s+=1),d(k)}function d(k){return k===null?r(k):q(k)?s>1?(s=0,n.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),h):r(k):Y(k)?X(e,d,"whitespace")(k):(s+=1,a&&(a=!1,i+=1),k===124?(e.enter("tableCellDivider"),e.consume(k),e.exit("tableCellDivider"),a=!0,d):(e.enter("data"),c(k)))}function c(k){return k===null||k===124||te(k)?(e.exit("data"),d(k)):(e.consume(k),k===92?f:c)}function f(k){return k===92||k===124?(e.consume(k),c):c(k)}function h(k){return n.interrupt=!1,n.parser.lazy[n.now().line]?r(k):(e.enter("tableDelimiterRow"),a=!1,Y(k)?X(e,g,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(k):g(k))}function g(k){return k===45||k===58?w(k):k===124?(a=!0,e.enter("tableCellDivider"),e.consume(k),e.exit("tableCellDivider"),S):B(k)}function S(k){return Y(k)?X(e,w,"whitespace")(k):w(k)}function w(k){return k===58?(s+=1,a=!0,e.enter("tableDelimiterMarker"),e.consume(k),e.exit("tableDelimiterMarker"),b):k===45?(s+=1,b(k)):k===null||q(k)?F(k):B(k)}function b(k){return k===45?(e.enter("tableDelimiterFiller"),C(k)):B(k)}function C(k){return k===45?(e.consume(k),C):k===58?(a=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(k),e.exit("tableDelimiterMarker"),_):(e.exit("tableDelimiterFiller"),_(k))}function _(k){return Y(k)?X(e,F,"whitespace")(k):F(k)}function F(k){return k===124?g(k):k===null||q(k)?!a||i!==s?B(k):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(k)):B(k)}function B(k){return r(k)}function I(k){return e.enter("tableRow"),z(k)}function z(k){return k===124?(e.enter("tableCellDivider"),e.consume(k),e.exit("tableCellDivider"),z):k===null||q(k)?(e.exit("tableRow"),t(k)):Y(k)?X(e,z,"whitespace")(k):(e.enter("data"),j(k))}function j(k){return k===null||k===124||te(k)?(e.exit("data"),z(k)):(e.consume(k),k===92?$:j)}function $(k){return k===92||k===124?(e.consume(k),j):j(k)}}function sx(e,t){let r=-1,n=!0,i=0,s=[0,0,0,0],a=[0,0,0,0],o=!1,l=0,u,d,c;const f=new ex;for(;++r<e.length;){const h=e[r],g=h[1];h[0]==="enter"?g.type==="tableHead"?(o=!1,l!==0&&(Ul(f,t,l,u,d),d=void 0,l=0),u={type:"table",start:Object.assign({},g.start),end:Object.assign({},g.end)},f.add(r,0,[["enter",u,t]])):g.type==="tableRow"||g.type==="tableDelimiterRow"?(n=!0,c=void 0,s=[0,0,0,0],a=[0,r+1,0,0],o&&(o=!1,d={type:"tableBody",start:Object.assign({},g.start),end:Object.assign({},g.end)},f.add(r,0,[["enter",d,t]])),i=g.type==="tableDelimiterRow"?2:d?3:1):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")?(n=!1,a[2]===0&&(s[1]!==0&&(a[0]=a[1],c=tn(f,t,s,i,void 0,c),s=[0,0,0,0]),a[2]=r)):g.type==="tableCellDivider"&&(n?n=!1:(s[1]!==0&&(a[0]=a[1],c=tn(f,t,s,i,void 0,c)),s=a,a=[s[1],r,0,0])):g.type==="tableHead"?(o=!0,l=r):g.type==="tableRow"||g.type==="tableDelimiterRow"?(l=r,s[1]!==0?(a[0]=a[1],c=tn(f,t,s,i,r,c)):a[1]!==0&&(c=tn(f,t,a,i,r,c)),i=0):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")&&(a[3]=r)}for(l!==0&&Ul(f,t,l,u,d),f.consume(t.events),r=-1;++r<t.events.length;){const h=t.events[r];h[0]==="enter"&&h[1].type==="table"&&(h[1]._align=rx(t.events,r))}return e}function tn(e,t,r,n,i,s){const a=n===1?"tableHeader":n===2?"tableDelimiter":"tableData",o="tableContent";r[0]!==0&&(s.end=Object.assign({},Bt(t.events,r[0])),e.add(r[0],0,[["exit",s,t]]));const l=Bt(t.events,r[1]);if(s={type:a,start:Object.assign({},l),end:Object.assign({},l)},e.add(r[1],0,[["enter",s,t]]),r[2]!==0){const u=Bt(t.events,r[2]),d=Bt(t.events,r[3]),c={type:o,start:Object.assign({},u),end:Object.assign({},d)};if(e.add(r[2],0,[["enter",c,t]]),n!==2){const f=t.events[r[2]],h=t.events[r[3]];if(f[1].end=Object.assign({},h[1].end),f[1].type="chunkText",f[1].contentType="text",r[3]>r[2]+1){const g=r[2]+1,S=r[3]-r[2]-1;e.add(g,S,[])}}e.add(r[3]+1,0,[["exit",c,t]])}return i!==void 0&&(s.end=Object.assign({},Bt(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function Ul(e,t,r,n,i){const s=[],a=Bt(t.events,r);i&&(i.end=Object.assign({},a),s.push(["exit",i,t])),n.end=Object.assign({},a),s.push(["exit",n,t]),e.add(r+1,0,s)}function Bt(e,t){const r=e[t],n=r[0]==="enter"?"start":"end";return r[1][n]}const ax={name:"tasklistCheck",tokenize:lx};function ox(){return{text:{91:ax}}}function lx(e,t,r){const n=this;return i;function i(l){return n.previous!==null||!n._gfmTasklistFirstContentOfListItem?r(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),s)}function s(l){return te(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),a):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),a):r(l)}function a(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),o):r(l)}function o(l){return q(l)?t(l):Y(l)?e.check({tokenize:ux},t,r)(l):r(l)}}function ux(e,t,r){return X(e,n,"whitespace");function n(i){return i===null?r(i):t(i)}}function cx(e){return yo([Ow(),Vw(),Zw(e),nx(),ox()])}const dx={};function hx(e){const t=this,r=e||dx,n=t.data(),i=n.micromarkExtensions||(n.micromarkExtensions=[]),s=n.fromMarkdownExtensions||(n.fromMarkdownExtensions=[]),a=n.toMarkdownExtensions||(n.toMarkdownExtensions=[]);i.push(cx(r)),s.push(Mw()),a.push(Lw(r))}function he(...e){return e.filter(Boolean).join(" ")}const fx=({content:e})=>p.jsx(nb,{remarkPlugins:[hx],className:"cuadra-aui-md",components:gx,children:e}),$l=y.memo(fx),px=({language:e,code:t})=>{const{isCopied:r,copyToClipboard:n}=mx(),i=()=>{!t||r||n(t)};return p.jsxs("div",{className:"cuadra-flex cuadra-items-center cuadra-justify-between cuadra-gap-4 cuadra-mt-4 cuadra-rounded-t-lg cuadra-bg-muted/50 cuadra-border-b cuadra-border-border cuadra-px-4 cuadra-py-2 cuadra-text-sm cuadra-font-normal cuadra-text-foreground cuadra-font-brand",children:[p.jsx("span",{className:"cuadra-lowercase [&>span]:cuadra-text-xs cuadra-font-brand",children:e}),p.jsxs("button",{onClick:i,className:"cuadra-p-1 cuadra-rounded hover:cuadra-bg-muted cuadra-transition-colors","aria-label":"Copy code",children:[!r&&p.jsx(gu,{className:"cuadra-h-4 cuadra-w-4"}),r&&p.jsx(fu,{className:"cuadra-h-4 cuadra-w-4"})]})]})},mx=({copiedDuration:e=3e3}={})=>{const[t,r]=y.useState(!1);return{isCopied:t,copyToClipboard:i=>{i&&navigator.clipboard.writeText(i).then(()=>{r(!0),setTimeout(()=>r(!1),e)})}}},gx=Uy({h1:r=>{var n=r,{className:e}=n,t=H(n,["className"]);return p.jsx("h1",m({className:he("cuadra-mb-6 cuadra-scroll-m-20 cuadra-text-2xl cuadra-font-normal cuadra-tracking-tight last:cuadra-mb-0 font-brand",e)},t))},h2:r=>{var n=r,{className:e}=n,t=H(n,["className"]);return p.jsx("h2",m({className:he("cuadra-mb-4 cuadra-mt-6 cuadra-scroll-m-20 cuadra-text-xl cuadra-font-normal cuadra-tracking-tight first:cuadra-mt-0 last:cuadra-mb-0 font-brand",e)},t))},h3:r=>{var n=r,{className:e}=n,t=H(n,["className"]);return p.jsx("h3",m({className:he("cuadra-mb-3 cuadra-mt-5 cuadra-scroll-m-20 cuadra-text-lg cuadra-font-normal cuadra-tracking-tight first:cuadra-mt-0 last:cuadra-mb-0 font-brand",e)},t))},h4:r=>{var n=r,{className:e}=n,t=H(n,["className"]);return p.jsx("h4",m({className:he("cuadra-mb-4 cuadra-mt-6 cuadra-scroll-m-20 cuadra-text-xl cuadra-font-normal cuadra-tracking-tight first:cuadra-mt-0 last:cuadra-mb-0 font-brand",e)},t))},h5:r=>{var n=r,{className:e}=n,t=H(n,["className"]);return p.jsx("h5",m({className:he("cuadra-my-4 cuadra-text-lg cuadra-font-normal first:cuadra-mt-0 last:cuadra-mb-0 font-brand",e)},t))},h6:r=>{var n=r,{className:e}=n,t=H(n,["className"]);return p.jsx("h6",m({className:he("cuadra-my-4 cuadra-font-normal first:cuadra-mb-0 font-brand",e)},t))},p:r=>{var n=r,{className:e}=n,t=H(n,["className"]);return p.jsx("p",m({className:he("cuadra-mb-5 cuadra-mt-5 cuadra-leading-7 first:cuadra-mt-0 last:cuadra-mb-0 font-brand",e)},t))},a:r=>{var n=r,{className:e}=n,t=H(n,["className"]);return p.jsx("a",m({className:he("cuadra-text-primary cuadra-font-medium cuadra-underline cuadra-underline-offset-4 font-brand",e)},t))},blockquote:r=>{var n=r,{className:e}=n,t=H(n,["className"]);return p.jsx("blockquote",m({className:he("cuadra-border-l-2 cuadra-pl-6 cuadra-italic font-brand",e)},t))},ul:r=>{var n=r,{className:e}=n,t=H(n,["className"]);return p.jsx("ul",m({className:he("cuadra-my-5 cuadra-ml-6 cuadra-list-disc [&>li]:cuadra-mt-2 font-brand",e)},t))},ol:r=>{var n=r,{className:e}=n,t=H(n,["className"]);return p.jsx("ol",m({className:he("cuadra-my-5 cuadra-ml-6 cuadra-list-decimal [&>li]:cuadra-mt-2 font-brand",e)},t))},hr:r=>{var n=r,{className:e}=n,t=H(n,["className"]);return p.jsx("hr",m({className:he("cuadra-my-5 cuadra-border-b",e)},t))},table:r=>{var n=r,{className:e}=n,t=H(n,["className"]);return p.jsx("table",m({className:he("cuadra-my-5 cuadra-w-full cuadra-border-separate cuadra-border-spacing-0 cuadra-overflow-y-auto font-brand",e)},t))},th:r=>{var n=r,{className:e}=n,t=H(n,["className"]);return p.jsx("th",m({className:he("cuadra-bg-muted cuadra-px-4 cuadra-py-2 cuadra-text-left cuadra-font-normal first:cuadra-rounded-tl-lg last:cuadra-rounded-tr-lg [&[align=center]]:cuadra-text-center [&[align=right]]:cuadra-text-right font-brand",e)},t))},td:r=>{var n=r,{className:e}=n,t=H(n,["className"]);return p.jsx("td",m({className:he("cuadra-border-b cuadra-border-l cuadra-px-4 cuadra-py-2 cuadra-text-left last:cuadra-border-r [&[align=center]]:cuadra-text-center [&[align=right]]:cuadra-text-right font-brand",e)},t))},tr:r=>{var n=r,{className:e}=n,t=H(n,["className"]);return p.jsx("tr",m({className:he("cuadra-m-0 cuadra-border-b cuadra-p-0 first:cuadra-border-t [&:last-child>td:first-child]:cuadra-rounded-bl-lg [&:last-child>td:last-child]:cuadra-rounded-br-lg",e)},t))},sup:r=>{var n=r,{className:e}=n,t=H(n,["className"]);return p.jsx("sup",m({className:he("[&>a]:cuadra-text-xs [&>a]:cuadra-no-underline font-brand",e)},t))},pre:r=>{var n=r,{className:e}=n,t=H(n,["className"]);return p.jsx("pre",m({className:he("cuadra-overflow-x-auto cuadra-rounded-b-lg !cuadra-rounded-t-none cuadra-bg-muted cuadra-p-4 cuadra-text-foreground font-brand",e)},t))},code:function(n){var i=n,{className:t}=i,r=H(i,["className"]);const s=ol();return p.jsx("code",m({className:he(!s&&"cuadra-bg-muted cuadra-rounded cuadra-border cuadra-font-normal font-brand",t)},r))},CodeHeader:px}),Hl=["Sending question…","Understanding your need…","Scanning data…","Comparing results…","Composing answer…"];function yx({active:e}){const[t,r]=y.useState(0);return y.useEffect(()=>{if(!e){r(0);return}const n=window.setInterval(()=>{r(i=>i>=Hl.length-1?(window.clearInterval(n),i):i+1)},2500);return()=>window.clearInterval(n)},[e]),e?p.jsxs("span",{className:"cuadra-text-xs cuadra-text-muted-foreground cuadra-font-brand",children:["Thinking… ",Hl[t]]}):null}function ql({welcomeTitle:e="Hi, how can I help you today?",welcomeSubtitle:t="Start exploring our platform and discover what you can build.",extraTopPadding:r,suggestions:n,inputPlaceholder:i="Type your message..."}={}){const s=js(),[a,o]=y.useState(!1),[l,u]=y.useState(null),[d,c]=y.useState(!1);return y.useEffect(()=>{var f,h;if(!s){o(!1);return}try{const g=s==null?void 0:s.store;if(!g){o(!1);return}const S=(f=g.subscribe)==null?void 0:f.call(g,b=>{const C=b==null?void 0:b.threadId,_=(b==null?void 0:b.messages)||[],F=(b==null?void 0:b.isLoadingHistory)||!1,B=_.length;C&&C!==l&&u(C),o(F&&B===0);const z=_.some(j=>j.role==="assistant"&&!!j.content&&(Array.isArray(j.content)?j.content.some($=>typeof $=="object"&&($!=null&&$.text)?$.text.trim().length>0:!1):typeof j.content=="string"?j.content.trim().length>0:!1));c(z)}),w=(h=g.getState)==null?void 0:h.call(g);if(w){const b=w==null?void 0:w.threadId,C=(w==null?void 0:w.messages)||[],_=(w==null?void 0:w.isLoadingHistory)||!1,F=C.length;b&&b!==l&&u(b),o(_&&F===0);const I=C.some(z=>z.role==="assistant"&&!!z.content&&(Array.isArray(z.content)?z.content.some(j=>typeof j=="object"&&(j!=null&&j.text)?j.text.trim().length>0:!1):typeof z.content=="string"?z.content.trim().length>0:!1));c(I)}return()=>{S&&S()}}catch(g){o(!1)}},[s,l]),p.jsxs(Ia,{className:"cuadra-bg-inherit cuadra-flex cuadra-flex-col cuadra-w-full cuadra-h-full",children:[p.jsx(Ma,{className:"cuadra-w-full cuadra-bg-inherit cuadra-px-4 cuadra-flex-1 cuadra-min-h-0 cuadra-overflow-y-auto cuadra-relative scrollbar-thin cuadra-pt-4",style:r?{paddingTop:r}:void 0,children:a?p.jsx("div",{className:"cuadra-absolute cuadra-inset-0 cuadra-flex cuadra-items-center cuadra-justify-center",children:p.jsxs("div",{className:"cuadra-flex cuadra-flex-col cuadra-items-center cuadra-gap-2",children:[p.jsx($i,{className:"cuadra-h-6 cuadra-w-6 cuadra-animate-spin cuadra-text-muted-foreground"}),p.jsx("p",{className:"cuadra-text-sm cuadra-text-muted-foreground font-brand",children:"Loading messages..."})]})}):p.jsxs(p.Fragment,{children:[p.jsx(Ea,{children:p.jsx(bx,{title:e,subtitle:t,suggestions:n})}),p.jsx(vf,{components:{UserMessage:wx,AssistantMessage:xx}}),p.jsx(Aa,{running:!0,children:!d&&p.jsx("div",{className:"cuadra-mt-2 cuadra-max-w-2xl",children:p.jsx(yx,{active:!0})})})]})}),p.jsx("div",{className:"cuadra-w-full cuadra-mt-3 cuadra-border-t cuadra-border-border cuadra-pt-4",children:p.jsxs(wa,{className:"cuadra-relative !cuadra-relative cuadra-flex-1 cuadra-w-full",children:[p.jsx(Ca,{asChild:!0,children:p.jsx("textarea",{rows:3,placeholder:i,className:"cuadra-flex cuadra-min-h-[80px] cuadra-w-full cuadra-rounded-md cuadra-border cuadra-border-border cuadra-bg-background cuadra-px-3 cuadra-py-2 cuadra-text-base placeholder:cuadra-text-muted-foreground focus-visible:cuadra-outline-none disabled:cuadra-cursor-not-allowed disabled:cuadra-opacity-50 cuadra-resize-none cuadra-pr-10 font-brand",style:{paddingRight:"2.5rem",fontSize:"1rem",borderWidth:"1px"}})}),p.jsx(Yh,{asChild:!0,children:p.jsx("button",{className:"!cuadra-absolute !cuadra-bottom-2 !cuadra-right-2 cuadra-size-8 cuadra-rounded-md cuadra-shadow-sm hover:cuadra-opacity-90 disabled:cuadra-opacity-50 disabled:cuadra-cursor-not-allowed cuadra-flex cuadra-items-center cuadra-justify-center",style:{position:"absolute",bottom:"0.5rem",right:"0.5rem",backgroundColor:"var(--primary)",color:"hsl(var(--primary-foreground))"},"aria-label":"Send message",type:"button",children:p.jsx(hu,{className:"cuadra-h-4 cuadra-w-4"})})})]})})]})}function bx({title:e,subtitle:t,suggestions:r}){const n=ue(),i=s=>P(null,null,function*(){try{n.composer().setText(s),yield new Promise(a=>setTimeout(a,10)),n.composer().send()}catch(a){}});return p.jsx("div",{className:"cuadra-flex cuadra-flex-col cuadra-items-center cuadra-h-full cuadra-py-12 cuadra-px-4 cuadra-overflow-y-auto scrollbar-hide",children:p.jsxs("div",{className:"cuadra-text-center cuadra-max-w-3xl cuadra-w-full cuadra-flex cuadra-flex-col cuadra-items-center cuadra-justify-center cuadra-min-h-full",children:[p.jsxs("div",{className:"cuadra-flex cuadra-flex-col cuadra-items-center cuadra-justify-center cuadra-mb-8",children:[p.jsx("h2",{className:"cuadra-text-lg cuadra-font-normal cuadra-text-foreground cuadra-mb-2 font-brand",children:e}),p.jsx("p",{className:"cuadra-text-muted-foreground font-brand",children:t})]}),r&&r.length>0&&p.jsx("div",{className:"cuadra-grid cuadra-grid-cols-2 cuadra-gap-2 cuadra-pb-4 cuadra-w-full cuadra-max-w-2xl",children:r.map((s,a)=>p.jsx("button",{type:"button",onClick:()=>i(s.prompt),className:"cuadra-w-full cuadra-text-center cuadra-px-4 cuadra-py-3 cuadra-rounded-lg cuadra-border cuadra-border-border cuadra-bg-background cuadra-text-sm font-brand cuadra-cursor-pointer focus:cuadra-outline-none focus:cuadra-ring-0",style:{borderWidth:"1px"},children:s.prompt},`suggestion-${a}`))})]})})}function wx(){return p.jsx(Bn,{className:"cuadra-grid cuadra-w-full cuadra-auto-rows-auto cuadra-grid-cols-[minmax(72px,1fr)_auto] cuadra-gap-y-2 cuadra-py-3 [&:where(>*)]:cuadra-col-start-2",children:p.jsx("div",{className:"cuadra-bg-muted cuadra-text-foreground cuadra-col-start-2 cuadra-row-start-2 cuadra-max-w-[calc(42rem*0.8)] cuadra-break-words cuadra-rounded-3xl cuadra-border cuadra-border-border cuadra-px-5 cuadra-py-2.5 font-brand",style:{maxWidth:"calc(42rem * 0.8)",borderRadius:"1.5rem",backgroundColor:"var(--muted)",color:"hsl(var(--foreground))",paddingLeft:"1.25rem",paddingRight:"1.25rem",paddingTop:"0.625rem",paddingBottom:"0.625rem",wordBreak:"break-word",borderWidth:"1px"},children:p.jsx(zn,{components:{Text:({text:e})=>p.jsx($l,{content:e||""})}})})})}function xx(){return p.jsx(Bn,{className:"cuadra-relative cuadra-grid cuadra-w-full cuadra-grid-cols-[auto_auto_1fr] cuadra-grid-rows-[auto_1fr] cuadra-py-3",children:p.jsx("div",{className:"cuadra-text-foreground cuadra-col-span-2 cuadra-col-start-2 cuadra-row-start-1 cuadra-my-1.5 cuadra-max-w-[90%] cuadra-break-words cuadra-leading-7 font-brand",style:{maxWidth:"90%",marginTop:"0.375rem",marginBottom:"0.375rem"},children:p.jsx(zn,{components:{Text:({text:e})=>p.jsx($l,{content:e||""})}})})})}function vx({onThreadSelect:e}){var w,b;const t=Us(),r=Sd(C=>C.threadId),[n,i]=y.useState(null),s=(t==null?void 0:t.id)===r,a=n===(t==null?void 0:t.id),[o,l]=y.useState(!1),[u,d]=y.useState((t==null?void 0:t.title)||""),[c,f]=y.useState(!1),[h,g]=y.useState(!1),S=()=>P(null,null,function*(){if(!(t!=null&&t.remoteId)||!u||u===t.title){l(!1);return}try{g(!0);const C=window.__cuadraThreadListAdapter;C&&typeof C.rename=="function"&&(yield C.rename(t.remoteId,u)),l(!1),f(!1)}catch(C){l(!1),f(!1)}finally{g(!1)}});return y.useEffect(()=>{t!=null&&t.title&&!o&&d(t.title)},[t==null?void 0:t.title,o]),t?p.jsx(Ra,{className:`group cuadra-relative cuadra-flex cuadra-items-center cuadra-gap-3 cuadra-rounded-lg cuadra-transition-colors cuadra-cursor-pointer cuadra-border cuadra-mb-2 ${s?"cuadra-bg-muted cuadra-border-border":"cuadra-border-transparent hover:cuadra-bg-muted hover:cuadra-border-border"}`,style:{marginBottom:"0.5rem"},onMouseEnter:()=>i(t.id),onMouseLeave:()=>i(null),children:p.jsxs(Tf,{className:"cuadra-p-3 cuadra-flex-1 cuadra-flex cuadra-items-center cuadra-justify-between cuadra-w-full cuadra-min-w-0 cuadra-cursor-pointer",onClick:()=>e==null?void 0:e(),children:[p.jsx("div",{className:"cuadra-flex cuadra-flex-col cuadra-min-w-0 cuadra-flex-1 cuadra-items-start cuadra-text-left",children:o?p.jsx("input",{className:"cuadra-flex cuadra-w-full cuadra-rounded-md cuadra-border cuadra-border-input cuadra-bg-background cuadra-px-3 cuadra-py-2 cuadra-text-sm placeholder:cuadra-text-muted-foreground focus-visible:cuadra-outline-none disabled:cuadra-cursor-not-allowed disabled:cuadra-opacity-50 font-brand",value:u,onChange:C=>d(C.target.value),onKeyDown:C=>{C.key==="Enter"&&S(),C.key==="Escape"&&(l(!1),d(t.title||""))},disabled:h,autoFocus:!0,onClick:C=>C.stopPropagation()}):p.jsxs(p.Fragment,{children:[p.jsx("span",{className:"cuadra-text-sm cuadra-font-normal cuadra-text-foreground cuadra-truncate font-brand",children:(((w=t.title)==null?void 0:w.length)||0)>60?`${(b=t.title)==null?void 0:b.slice(0,60)}…`:t.title||"Chat"}),t.updatedAt&&p.jsx("span",{className:"cuadra-text-xs cuadra-text-muted-foreground cuadra-mt-1 font-brand",children:new Date(t.updatedAt).toLocaleDateString()})]})}),p.jsx("div",{className:"cuadra-ml-2 cuadra-flex-shrink-0 cuadra-w-6 cuadra-h-6 cuadra-flex cuadra-items-center cuadra-justify-center",children:(a||s||c)&&p.jsxs("div",{className:"cuadra-relative",children:[p.jsx("button",{className:"cuadra-p-1 cuadra-rounded hover:cuadra-bg-background/50 cuadra-transition-colors",onClick:C=>{C.stopPropagation(),f(!c)},"aria-label":"Thread options",children:p.jsx(yu,{className:"cuadra-h-4 cuadra-w-4 cuadra-text-muted-foreground"})}),c&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"cuadra-fixed cuadra-inset-0 cuadra-z-40",onClick:()=>f(!1)}),p.jsx("div",{className:"cuadra-absolute cuadra-right-0 cuadra-top-8 cuadra-z-50 cuadra-bg-background cuadra-border cuadra-border-border cuadra-rounded-lg cuadra-shadow-lg cuadra-min-w-[120px] cuadra-overflow-hidden",children:o?p.jsx("button",{className:"cuadra-w-full cuadra-px-3 cuadra-py-2 cuadra-text-sm cuadra-text-left hover:cuadra-bg-muted cuadra-transition-colors font-brand",onClick:C=>{C.stopPropagation(),S()},disabled:h,children:"Save"}):p.jsxs(p.Fragment,{children:[p.jsx("button",{className:"cuadra-w-full cuadra-px-3 cuadra-py-2 cuadra-text-sm cuadra-text-left hover:cuadra-bg-muted cuadra-transition-colors font-brand",onClick:C=>{C.stopPropagation(),l(!0),d(t.title||""),f(!1)},children:"Rename"}),p.jsx("div",{className:"cuadra-border-t cuadra-border-border"}),p.jsx(kf,{asChild:!0,children:p.jsx("button",{className:"cuadra-w-full cuadra-px-3 cuadra-py-2 cuadra-text-sm cuadra-text-left cuadra-text-destructive hover:cuadra-bg-muted cuadra-transition-colors font-brand",onClick:C=>{C.stopPropagation(),f(!1)},children:"Delete"})})]})})]})]})})]})}):null}function Vl({onThreadSelect:e}){return p.jsxs(za,{className:"!cuadra-border-r cuadra-border-border cuadra-flex cuadra-flex-col cuadra-bg-background cuadra-transition-all cuadra-duration-300 cuadra-ease-in-out cuadra-h-full cuadra-w-80",style:{borderRightWidth:"1px"},children:[p.jsx("div",{className:"cuadra-border-b cuadra-border-border cuadra-flex cuadra-items-center cuadra-justify-between cuadra-transition-all cuadra-duration-300 cuadra-h-16 cuadra-px-4",children:p.jsx("h3",{className:"cuadra-text-sm cuadra-font-normal cuadra-text-foreground cuadra-text-nowrap font-brand",children:"Chat History"})}),p.jsxs("div",{className:"cuadra-flex-1 cuadra-overflow-y-auto cuadra-p-2 scrollbar-thin",children:[p.jsx(Oa,{className:"group cuadra-relative cuadra-flex cuadra-items-center cuadra-gap-3 cuadra-p-3 cuadra-rounded-lg cuadra-cursor-pointer cuadra-transition-colors cuadra-border cuadra-border-transparent hover:cuadra-bg-muted hover:cuadra-border-border",onClick:()=>e==null?void 0:e(),children:p.jsx("div",{className:"cuadra-flex-1 cuadra-min-w-0",children:p.jsxs("div",{className:"cuadra-flex cuadra-items-center cuadra-gap-2",children:[p.jsx(wu,{className:"cuadra-h-4 cuadra-w-4 cuadra-text-muted-foreground"}),p.jsx("h4",{className:"cuadra-text-sm cuadra-font-normal cuadra-text-foreground font-brand",children:"New Chat"})]})})}),p.jsx("div",{className:"cuadra-my-2 cuadra-border-t cuadra-border-border"}),p.jsx(Ba,{components:{ThreadListItem:t=>p.jsx(vx,E(m({},t),{onThreadSelect:e}))}})]})]})}const Sx=`
44
36
  @keyframes rotate {
45
37
  100% { transform: rotate(1turn); }
46
38
  }
47
- `,Oc=({children:t,className:n="",paddingX:a="px-0",paddingY:i="py-0",borderSizePx:s=4,style:o,contentStyle:c,rotating:d=!1})=>E.jsxs(E.Fragment,{children:[E.jsx("style",{children:P2}),E.jsxs("div",{className:`cuadra-relative cuadra-bg-background md:cuadra-rounded-xl cuadra-overflow-hidden ${n}`,style:_({padding:s},o),children:[E.jsx("div",{className:"cuadra-absolute md:cuadra-rounded-xl",style:d?{left:"-100%",top:"-100%",width:"300%",height:"300%",backgroundImage:"conic-gradient(#F4633A, #FF7A4D, #FF8C5C, #F4633A, #FF7A4D, #FF8C5C)",backgroundRepeat:"no-repeat",backgroundSize:"cover",backgroundPosition:"center",animation:"rotate 4s linear infinite"}:{backgroundImage:"linear-gradient(to right, #F4633A, #FF7A4D, #FF8C5C, #F4633A)",backgroundSize:"cover",backgroundPosition:"center",backgroundRepeat:"no-repeat",top:"0",left:"0",width:"100%",height:"100%"}}),E.jsx("div",{className:`cuadra-relative cuadra-bg-background cuadra-h-full cuadra-z-10 cuadra-flex cuadra-flex-col cuadra-overflow-hidden ${a} ${i}`,style:_({borderRadius:"calc(0.75rem - 4px)"},c),children:t})]})]}),X2=({className:t="",theme:n="system"})=>{const a=()=>{if(typeof window=="undefined")return"light";if(n==="system"){const c=localStorage.getItem("theme");return c||(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")}return n},[i,s]=R.useState(a);R.useEffect(()=>{n!=="system"&&s(n)},[n]),R.useEffect(()=>{const c=document.documentElement;c.classList.remove("light","dark"),c.classList.add(i),n==="system"&&localStorage.setItem("theme",i)},[i,n]);const o=()=>{n==="system"&&s(c=>c==="light"?"dark":"light")};return E.jsx("button",{type:"button","aria-label":"Toggle theme",onClick:o,disabled:n!=="system",className:`cuadra-flex cuadra-items-center cuadra-justify-center cuadra-h-8 cuadra-w-8 cuadra-rounded-full cuadra-bg-muted hover:cuadra-bg-muted/80 cuadra-transition-colors disabled:cuadra-opacity-50 disabled:cuadra-cursor-not-allowed ${t}`,children:E.jsx(US,{className:`cuadra-h-4 cuadra-w-4 cuadra-transition-colors ${i==="dark"?"cuadra-text-primary":"cuadra-text-gray-400"}`})})},hy=({currentModel:t,models:n,modelsLoading:a,modelsError:i,onModelChange:s,hideModelSelector:o=!1,showThemeToggle:c=!0,theme:d="system",onMobileMenuClick:h,showMobileMenuButton:m=!1})=>{const[y,g]=R.useState(!1),v=R.useRef(null);R.useEffect(()=>{const w=z=>{v.current&&!v.current.contains(z.target)&&g(!1)};return y&&document.addEventListener("mousedown",w),()=>{document.removeEventListener("mousedown",w)}},[y]);const x=n.find(w=>w.id===t);return E.jsxs("div",{className:"cuadra-h-16 cuadra-px-4 cuadra-border-b cuadra-border-border cuadra-flex cuadra-items-center cuadra-justify-between cuadra-bg-background",children:[E.jsxs("div",{className:"cuadra-flex cuadra-items-center cuadra-gap-2",children:[m&&E.jsx("button",{type:"button",onClick:h,className:"cuadra-flex cuadra-items-center cuadra-justify-center cuadra-h-8 cuadra-w-8 cuadra-rounded-full cuadra-bg-muted hover:cuadra-bg-muted/80 cuadra-transition-colors disabled:cuadra-opacity-50 disabled:cuadra-cursor-not-allowed md:cuadra-hidden","aria-label":"Toggle thread list",children:E.jsx(VS,{className:"cuadra-h-4 cuadra-w-4 cuadra-text-foreground"})}),c&&E.jsx("div",{className:"cuadra-flex cuadra-items-center cuadra-gap-2",children:E.jsx(X2,{theme:d})})]}),E.jsxs("div",{className:"cuadra-flex cuadra-items-center cuadra-gap-2 md:cuadra-ml-0 cuadra-ml-auto",children:[!o&&E.jsx("label",{className:"cuadra-hidden md:cuadra-inline cuadra-text-sm cuadra-text-muted-foreground cuadra-font-brand",children:"Model"}),o?null:a?E.jsx("div",{className:"cuadra-w-48 cuadra-rounded-md cuadra-border cuadra-border-border cuadra-px-3 cuadra-py-2 cuadra-bg-muted",children:E.jsx("span",{className:"cuadra-text-muted-foreground cuadra-text-sm cuadra-font-brand",children:"Loading..."})}):i?E.jsx("div",{className:"cuadra-w-48 cuadra-rounded-md cuadra-border cuadra-border-destructive cuadra-px-3 cuadra-py-2 cuadra-bg-destructive/10",children:E.jsx("span",{className:"cuadra-text-destructive cuadra-text-sm cuadra-font-brand",children:"Failed to load models"})}):E.jsxs("div",{ref:v,className:"cuadra-relative cuadra-w-48",children:[E.jsxs("button",{type:"button",onClick:()=>g(!y),disabled:a||n.length===0||!!i,className:"cuadra-flex cuadra-h-10 cuadra-w-full cuadra-items-center cuadra-justify-between cuadra-rounded-md cuadra-border cuadra-border-input cuadra-bg-background cuadra-px-3 cuadra-py-2 cuadra-text-sm placeholder:cuadra-text-muted-foreground focus:cuadra-outline-none disabled:cuadra-cursor-not-allowed disabled:cuadra-opacity-50 cuadra-font-brand",children:[E.jsx("span",{className:x?"cuadra-text-foreground":"cuadra-text-muted-foreground",children:(x==null?void 0:x.name)||"Select model"}),E.jsx(BS,{className:"cuadra-ml-2 cuadra-h-4 cuadra-w-4 cuadra-opacity-50"})]}),y&&n.length>0&&E.jsx("div",{className:"cuadra-absolute cuadra-z-50 cuadra-mt-1 cuadra-w-full cuadra-min-w-[8rem] cuadra-overflow-hidden cuadra-rounded-md glass-popover cuadra-text-popover-foreground cuadra-animate-in fade-in-80 cuadra-border cuadra-border-border cuadra-bg-popover cuadra-shadow-md",children:E.jsx("div",{className:"cuadra-p-1",children:n.map(w=>E.jsxs("button",{type:"button",onClick:()=>{s(w.id),g(!1)},className:`cuadra-relative cuadra-flex cuadra-w-full cuadra-cursor-pointer cuadra-select-none cuadra-items-center cuadra-rounded-sm cuadra-py-1.5 cuadra-pl-8 cuadra-pr-2 cuadra-text-sm cuadra-outline-none focus:cuadra-bg-secondary focus:cuadra-text-secondary-foreground font-brand cuadra-transition-colors ${t===w.id?"cuadra-bg-secondary cuadra-text-secondary-foreground":"hover:cuadra-bg-secondary/50"}`,children:[t===w.id&&E.jsx("span",{className:"cuadra-absolute cuadra-left-2 cuadra-flex cuadra-h-3.5 cuadra-w-3.5 cuadra-items-center cuadra-justify-center",children:E.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"none",viewBox:"0 0 16 16",children:E.jsx("path",{fill:"currentColor",fillRule:"evenodd",d:"M6.47 10.03a.75.75 0 0 1-1.06-1.06l2-2a.75.75 0 0 1 1.06 0l2 2a.75.75 0 1 1-1.06 1.06L8 9.06l-1.53 1.53Z",clipRule:"evenodd"})})}),E.jsx("span",{children:w.name})]},w.id))})})]})]})]})},Q2=R.createContext(void 0),Dc=({children:t,value:n})=>E.jsx(Q2.Provider,{value:n,children:t});function Z2(){R.useEffect(()=>{if(document.querySelector("style[data-cuadra-uikit]"))return;const n=document.createElement("div");n.className="cuadra-flex",document.body.appendChild(n);const a=window.getComputedStyle(n).display==="flex";if(document.body.removeChild(n),a)return;const i=document.createElement("link");i.setAttribute("data-cuadra-uikit","true"),i.rel="stylesheet",i.type="text/css";const s=["/node_modules/@cuadra-ai/uikit/dist/uikit.css",new URL("../dist/uikit.css",typeof document=="undefined"&&typeof location=="undefined"?require("url").pathToFileURL(__filename).href:typeof document=="undefined"?location.href:yt&&yt.tagName.toUpperCase()==="SCRIPT"&&yt.src||new URL("cuadra-uikit.umd.js",document.baseURI).href).href];let o=!1;for(const c of s)if(i.href=c,i.onload=()=>{o=!0},i.onerror=()=>{},document.head.appendChild(i),o)break},[])}const py=({config:t})=>{Z2();const{baseUrl:n,proxyUrl:a,sessionToken:i,mode:s="multiChat",modelMode:o="fixed",modelId:c,onModelChange:d,ephemeral:h=!1,systemPrompt:m,initialThreadId:y,welcomeTitle:g,welcomeSubtitle:v,extraTopPadding:x,suggestions:w,inputPlaceholder:z,showThemeToggle:D=!0,theme:k="system",onError:q,onChatCreated:I,onUserMessage:at,onThreadIdUpdate:lt}=t,[L,J]=R.useState(!1),st=a||n||"",ct=!!a,j=R.useMemo(()=>new um(st,i||void 0,ct),[st,i,ct]),[tt,$]=R.useState(null),[bt,ot]=R.useState(!1),[nt,H]=R.useState(null),[et,ft]=R.useState(!1);R.useEffect(()=>{s==="multiChat"&&ft(!0)},[s]);const Tt=R.useCallback(()=>W(null,null,function*(){if(o==="selector"){ot(!0),H(null);try{const _t=yield j.listModels();$(_t)}catch(_t){H(_t instanceof Error?_t:new Error("Failed to load models"))}finally{ot(!1)}}}),[j,o]);R.useEffect(()=>{o==="selector"&&Tt()},[o,Tt]),R.useEffect(()=>(typeof window!="undefined"&&(window.__cuadraUIKitRefetchModels=Tt),()=>{typeof window!="undefined"&&delete window.__cuadraUIKitRefetchModels}),[Tt]);const[C,M]=R.useState(o==="fixed"&&c||null),P=R.useRef(C),T=R.useCallback(_t=>{const Ht=P.current;M(_t),P.current=_t,d==null||d(_t),Ht!==null&&Ht!==_t&&s==="multiChat"&&setTimeout(()=>{var yn,xr;const re=window.__cuadraThreadListRuntime;if((yn=re==null?void 0:re.threads)!=null&&yn.switchToNewThread)try{re.threads.switchToNewThread()}catch(ea){}else if((xr=re==null?void 0:re.threads)!=null&&xr.createThread)try{re.threads.createThread()}catch(ea){}else if(re!=null&&re.switchToNewThread)try{re.switchToNewThread()}catch(ea){}},100)},[d,s]);R.useEffect(()=>{if(o==="selector"&&(tt!=null&&tt.items)&&tt.items.length>0&&!C){const _t=tt.items[0];if(_t!=null&&_t.id){const Ht=_t.id;M(Ht),d==null||d(Ht)}}},[o,tt==null?void 0:tt.items,C,d]);const ut=o==="fixed"?!!c:!!C,vt=R.useMemo(()=>((tt==null?void 0:tt.items)||[]).filter(_t=>(_t==null?void 0:_t.id)&&(_t==null?void 0:_t.displayName)).map(_t=>({id:_t.id,name:_t.displayName})),[tt]),mt=R.useMemo(()=>({currentModelId:C||"",models:vt,modelsLoading:bt,modelsError:nt,onModelChange:T,refetchModels:Tt}),[C,vt,bt,nt,T,Tt]);return o==="selector"&&bt||s==="multiChat"&&et?E.jsx(Dc,{value:mt,children:E.jsx(Oc,{className:"cuadra-h-full",paddingX:"cuadra-px-0",paddingY:"cuadra-py-0",children:E.jsx("div",{className:"cuadra-flex cuadra-items-center cuadra-justify-center cuadra-h-full",children:E.jsx(ch,{className:"cuadra-h-6 cuadra-w-6 cuadra-animate-spin cuadra-text-muted-foreground"})})})}):o==="selector"&&!ut&&nt?E.jsx(Dc,{value:mt,children:E.jsx(Oc,{className:"cuadra-h-full",paddingX:"cuadra-px-0",paddingY:"cuadra-py-0",children:E.jsx("div",{className:"cuadra-flex cuadra-items-center cuadra-justify-center cuadra-h-full",children:E.jsx("div",{className:"cuadra-flex cuadra-flex-col cuadra-items-center cuadra-gap-2",children:E.jsx("p",{className:"cuadra-text-sm cuadra-text-destructive font-brand",children:"Failed to load models"})})})})}):E.jsx("div",{className:"cuadra-uikit cuadra-h-full cuadra-w-full",style:{height:"100%",width:"100%"},children:E.jsx(Dc,{value:mt,children:E.jsx(tT,{baseUrl:ct?st:n||st,sessionToken:i,isProxyMode:ct,mode:s,modelMode:o,modelId:C||c||void 0,onModelChange:T,ephemeral:h,systemPrompt:m,initialThreadId:y,onError:q,onChatCreated:I,onUserMessage:at,onThreadIdUpdate:lt,onChatsLoaded:()=>{s==="multiChat"&&ft(!1)},children:E.jsx(Oc,{paddingX:"cuadra-px-0",paddingY:"cuadra-py-0",className:`cuadra-h-full ${t.containerClass||""}`,borderSizePx:4,style:{height:"100%"},children:E.jsx("div",{className:"cuadra-h-full cuadra-flex cuadra-relative",style:{height:"100%"},children:s==="multiChat"?E.jsxs(E.Fragment,{children:[L&&typeof document!="undefined"&&sh.createPortal(E.jsx("div",{className:"cuadra-fixed cuadra-inset-0 cuadra-bg-black/50 cuadra-z-40 md:cuadra-hidden",onClick:()=>J(!1)}),document.body),typeof document!="undefined"&&E.jsxs(E.Fragment,{children:[E.jsx("div",{className:"cuadra-hidden md:cuadra-block !cuadra-border-r cuadra-border-border cuadra-flex cuadra-flex-col cuadra-bg-background cuadra-transition-all cuadra-duration-300 cuadra-ease-in-out cuadra-h-full cuadra-w-80 cuadra-relative",style:{borderRightWidth:"1px",height:"100%"},children:E.jsx(dy,{onThreadSelect:()=>J(!1)})}),L&&sh.createPortal(E.jsx("div",{className:"cuadra-block md:cuadra-hidden !cuadra-border-r cuadra-border-border cuadra-flex cuadra-flex-col cuadra-bg-background cuadra-transition-all cuadra-duration-300 cuadra-ease-in-out cuadra-h-screen cuadra-w-80 cuadra-fixed cuadra-z-50 cuadra-top-0 cuadra-left-0 cuadra-translate-x-0",style:{borderRightWidth:"1px"},children:E.jsx(dy,{onThreadSelect:()=>J(!1)})}),document.body)]}),E.jsxs("div",{className:"cuadra-flex-1 cuadra-flex cuadra-flex-col",children:[o==="selector"&&E.jsx(hy,{currentModel:C||"",models:vt,modelsLoading:bt,modelsError:nt,onModelChange:T,showThemeToggle:D,theme:k,onMobileMenuClick:()=>J(!L),showMobileMenuButton:s==="multiChat"}),E.jsx("div",{className:"cuadra-flex-1 cuadra-relative cuadra-min-h-0 cuadra-space-y-4 cuadra-p-4",children:E.jsx(fy,{welcomeTitle:g,welcomeSubtitle:v,extraTopPadding:x,suggestions:w,inputPlaceholder:z})})]})]}):E.jsxs("div",{className:"cuadra-flex-1 cuadra-flex cuadra-flex-col",children:[o==="selector"&&E.jsx(hy,{currentModel:C||"",models:vt,modelsLoading:bt,modelsError:nt,onModelChange:T,showThemeToggle:D,theme:k}),E.jsx("div",{className:"cuadra-flex-1 cuadra-relative cuadra-min-h-0 cuadra-space-y-4 cuadra-p-4",children:E.jsx(fy,{welcomeTitle:g,welcomeSubtitle:v,extraTopPadding:x,suggestions:w})})]})})})})})})};class Os{constructor(){Y(this,"config",null);Y(this,"root",null);Y(this,"container",null);Y(this,"instances",new Map)}init(n){if(!n.baseUrl&&!n.proxyUrl)throw new Error("Either baseUrl or proxyUrl is required");if(n.modelMode==="fixed"&&n.modelId!==void 0&&(!n.modelId||n.modelId.trim()===""))throw new Error("modelId cannot be empty when explicitly provided. Omit modelId to let backend resolve it.");const a=n.containerId||"cuadra-chat";let i=document.getElementById(a);i||(i=document.createElement("div"),i.id=a,document.body.appendChild(i)),n.containerClass&&i.classList.add(...n.containerClass.split(" ")),this.config=G(_({},n),{containerId:a}),this.container=i,this.root=MS.createRoot(i),this.root.render(nn.createElement(my,{config:this.config})),this.instances.set(a,this)}destroy(n){var s;const a=n||((s=this.config)==null?void 0:s.containerId);if(!a)return;const i=this.instances.get(a);i!=null&&i.root&&(i.root.unmount(),i.root=null),i!=null&&i.container&&i.container.parentNode&&i.container.parentNode.removeChild(i.container),this.instances.delete(a)}updateConfig(n,a){var c;const i=a||((c=this.config)==null?void 0:c.containerId);if(!i)return;const s=this.instances.get(i);if(!(s!=null&&s.config))return;const o=_(_({},s.config),n);s.config=o,s.root&&s.container&&s.root.render(nn.createElement(my,{config:o}))}getInstance(n){var i;const a=n||((i=this.config)==null?void 0:i.containerId);return a&&this.instances.get(a)||null}static parseConfigFromAttributes(n,a){const i={};return n.dataset.baseUrl&&(i.baseUrl=n.dataset.baseUrl),n.dataset.proxyUrl&&(i.proxyUrl=n.dataset.proxyUrl),n.dataset.sessionToken&&(i.sessionToken=n.dataset.sessionToken),n.dataset.containerId&&(i.containerId=n.dataset.containerId),n.dataset.containerClass&&(i.containerClass=n.dataset.containerClass),n.dataset.mode&&(i.mode=n.dataset.mode),n.dataset.modelMode&&(i.modelMode=n.dataset.modelMode),n.dataset.modelId&&(i.modelId=n.dataset.modelId),n.dataset.ephemeral&&(i.ephemeral=n.dataset.ephemeral==="true"),n.dataset.systemPrompt&&(i.systemPrompt=n.dataset.systemPrompt),a&&(a.dataset.baseUrl&&(i.baseUrl=a.dataset.baseUrl),a.dataset.proxyUrl&&(i.proxyUrl=a.dataset.proxyUrl),a.dataset.sessionToken&&(i.sessionToken=a.dataset.sessionToken),a.dataset.mode&&(i.mode=a.dataset.mode),a.dataset.modelMode&&(i.modelMode=a.dataset.modelMode),a.dataset.modelId&&(i.modelId=a.dataset.modelId)),i}}const my=({config:t})=>E.jsx(py,{config:t});let Ue=null;typeof window!="undefined"&&(Ue=new Os);const gy={init:t=>(Ue||(Ue=new Os),Ue.init(t)),destroy:t=>Ue==null?void 0:Ue.destroy(t),updateConfig:(t,n)=>Ue==null?void 0:Ue.updateConfig(t,n),getInstance:t=>Ue==null?void 0:Ue.getInstance(t),refetchModels:()=>{if(typeof window!="undefined"){const t=window.__cuadraUIKitRefetchModels;t&&t()}},version:"0.1.0"};if(typeof window!="undefined"){window.CuadraUIKit=gy;const t=()=>{const n=document.querySelectorAll('script[src*="cuadra-uikit"]'),a=Array.from(n).find(i=>(i.getAttribute("src")||"").includes("cuadra-uikit.umd.js"));a&&a.dataset.autoInit!=="false"&&K2(a)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",t):setTimeout(t,0)}function K2(t){if(!t||!Ue)return;const n=Os.parseConfigFromAttributes(t),a=n.containerId||"cuadra-chat",i=document.getElementById(a);if(i){const s=Os.parseConfigFromAttributes(t,i);Object.assign(n,s)}(n.baseUrl||n.proxyUrl)&&Ue.init(n)}pt.WidgetContent=py,pt.default=gy,Object.defineProperties(pt,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
39
+ `,Bi=({children:e,className:t="",paddingX:r="px-0",paddingY:n="py-0",borderSizePx:i=4,style:s,contentStyle:a,rotating:o=!1})=>p.jsxs(p.Fragment,{children:[p.jsx("style",{children:Sx}),p.jsxs("div",{className:`cuadra-relative cuadra-bg-background md:cuadra-rounded-xl cuadra-overflow-hidden ${t}`,style:m({padding:i},s),children:[p.jsx("div",{className:"cuadra-absolute md:cuadra-rounded-xl",style:o?{left:"-100%",top:"-100%",width:"300%",height:"300%",backgroundImage:"conic-gradient(#F4633A, #FF7A4D, #FF8C5C, #F4633A, #FF7A4D, #FF8C5C)",backgroundRepeat:"no-repeat",backgroundSize:"cover",backgroundPosition:"center",animation:"rotate 4s linear infinite"}:{backgroundImage:"linear-gradient(to right, #F4633A, #FF7A4D, #FF8C5C, #F4633A)",backgroundSize:"cover",backgroundPosition:"center",backgroundRepeat:"no-repeat",top:"0",left:"0",width:"100%",height:"100%"}}),p.jsx("div",{className:`cuadra-relative cuadra-bg-background cuadra-h-full cuadra-z-10 cuadra-flex cuadra-flex-col cuadra-overflow-hidden ${r} ${n}`,style:m({borderRadius:"calc(0.75rem - 4px)"},a),children:e})]})]}),kx=({className:e="",theme:t="system"})=>{const r=()=>{if(typeof window=="undefined")return"light";if(t==="system"){const a=localStorage.getItem("theme");return a||(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")}return t},[n,i]=y.useState(r);y.useEffect(()=>{t!=="system"&&i(t)},[t]),y.useEffect(()=>{const a=document.documentElement;a.classList.remove("light","dark"),a.classList.add(n),t==="system"&&localStorage.setItem("theme",n)},[n,t]);const s=()=>{t==="system"&&i(a=>a==="light"?"dark":"light")};return p.jsx("button",{type:"button","aria-label":"Toggle theme",onClick:s,disabled:t!=="system",className:`cuadra-flex cuadra-items-center cuadra-justify-center cuadra-h-8 cuadra-w-8 cuadra-rounded-full cuadra-bg-muted hover:cuadra-bg-muted/80 cuadra-transition-colors disabled:cuadra-opacity-50 disabled:cuadra-cursor-not-allowed ${e}`,children:p.jsx(mu,{className:`cuadra-h-4 cuadra-w-4 cuadra-transition-colors ${n==="dark"?"cuadra-text-primary":"cuadra-text-gray-400"}`})})},Wl=({currentModel:e,models:t,modelsLoading:r,modelsError:n,onModelChange:i,hideModelSelector:s=!1,showThemeToggle:a=!0,theme:o="system",onMobileMenuClick:l,showMobileMenuButton:u=!1})=>{const[d,c]=y.useState(!1),f=y.useRef(null);y.useEffect(()=>{const g=S=>{f.current&&!f.current.contains(S.target)&&c(!1)};return d&&document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g)}},[d]);const h=t.find(g=>g.id===e);return p.jsxs("div",{className:"cuadra-h-16 cuadra-px-4 cuadra-border-b cuadra-border-border cuadra-flex cuadra-items-center cuadra-justify-between cuadra-bg-background",children:[p.jsxs("div",{className:"cuadra-flex cuadra-items-center cuadra-gap-2",children:[u&&p.jsx("button",{type:"button",onClick:l,className:"cuadra-flex cuadra-items-center cuadra-justify-center cuadra-h-8 cuadra-w-8 cuadra-rounded-full cuadra-bg-muted hover:cuadra-bg-muted/80 cuadra-transition-colors disabled:cuadra-opacity-50 disabled:cuadra-cursor-not-allowed md:cuadra-hidden","aria-label":"Toggle thread list",children:p.jsx(bu,{className:"cuadra-h-4 cuadra-w-4 cuadra-text-foreground"})}),a&&p.jsx("div",{className:"cuadra-flex cuadra-items-center cuadra-gap-2",children:p.jsx(kx,{theme:o})})]}),p.jsxs("div",{className:"cuadra-flex cuadra-items-center cuadra-gap-2 md:cuadra-ml-0 cuadra-ml-auto",children:[!s&&p.jsx("label",{className:"cuadra-hidden md:cuadra-inline cuadra-text-sm cuadra-text-muted-foreground cuadra-font-brand",children:"Model"}),s?null:r?p.jsx("div",{className:"cuadra-w-48 cuadra-rounded-md cuadra-border cuadra-border-border cuadra-px-3 cuadra-py-2 cuadra-bg-muted",children:p.jsx("span",{className:"cuadra-text-muted-foreground cuadra-text-sm cuadra-font-brand",children:"Loading..."})}):n?p.jsx("div",{className:"cuadra-w-48 cuadra-rounded-md cuadra-border cuadra-border-destructive cuadra-px-3 cuadra-py-2 cuadra-bg-destructive/10",children:p.jsx("span",{className:"cuadra-text-destructive cuadra-text-sm cuadra-font-brand",children:"Failed to load models"})}):p.jsxs("div",{ref:f,className:"cuadra-relative cuadra-w-48",children:[p.jsxs("button",{type:"button",onClick:()=>c(!d),disabled:r||t.length===0||!!n,className:"cuadra-flex cuadra-h-10 cuadra-w-full cuadra-items-center cuadra-justify-between cuadra-rounded-md cuadra-border cuadra-border-input cuadra-bg-background cuadra-px-3 cuadra-py-2 cuadra-text-sm placeholder:cuadra-text-muted-foreground focus:cuadra-outline-none disabled:cuadra-cursor-not-allowed disabled:cuadra-opacity-50 cuadra-font-brand",children:[p.jsx("span",{className:h?"cuadra-text-foreground":"cuadra-text-muted-foreground",children:(h==null?void 0:h.name)||"Select model"}),p.jsx(pu,{className:"cuadra-ml-2 cuadra-h-4 cuadra-w-4 cuadra-opacity-50"})]}),d&&t.length>0&&p.jsx("div",{className:"cuadra-absolute cuadra-z-50 cuadra-mt-1 cuadra-w-full cuadra-min-w-[8rem] cuadra-overflow-hidden cuadra-rounded-md glass-popover cuadra-text-popover-foreground cuadra-animate-in fade-in-80 cuadra-border cuadra-border-border cuadra-bg-popover cuadra-shadow-md",children:p.jsx("div",{className:"cuadra-p-1",children:t.map(g=>p.jsxs("button",{type:"button",onClick:()=>{i(g.id),c(!1)},className:`cuadra-relative cuadra-flex cuadra-w-full cuadra-cursor-pointer cuadra-select-none cuadra-items-center cuadra-rounded-sm cuadra-py-1.5 cuadra-pl-8 cuadra-pr-2 cuadra-text-sm cuadra-outline-none focus:cuadra-bg-secondary focus:cuadra-text-secondary-foreground font-brand cuadra-transition-colors ${e===g.id?"cuadra-bg-secondary cuadra-text-secondary-foreground":"hover:cuadra-bg-secondary/50"}`,children:[e===g.id&&p.jsx("span",{className:"cuadra-absolute cuadra-left-2 cuadra-flex cuadra-h-3.5 cuadra-w-3.5 cuadra-items-center cuadra-justify-center",children:p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"none",viewBox:"0 0 16 16",children:p.jsx("path",{fill:"currentColor",fillRule:"evenodd",d:"M6.47 10.03a.75.75 0 0 1-1.06-1.06l2-2a.75.75 0 0 1 1.06 0l2 2a.75.75 0 1 1-1.06 1.06L8 9.06l-1.53 1.53Z",clipRule:"evenodd"})})}),p.jsx("span",{children:g.name})]},g.id))})})]})]})]})},_x=y.createContext(void 0),zi=({children:e,value:t})=>p.jsx(_x.Provider,{value:t,children:e});function Tx(){y.useEffect(()=>{if(document.querySelector("style[data-cuadra-uikit]"))return;const t=document.createElement("div");t.className="cuadra-flex",document.body.appendChild(t);const r=window.getComputedStyle(t).display==="flex";if(document.body.removeChild(t),r)return;const n=document.createElement("link");n.setAttribute("data-cuadra-uikit","true"),n.rel="stylesheet",n.type="text/css";const i=["/node_modules/@cuadra-ai/uikit/dist/uikit.css",new URL("../dist/uikit.css",typeof document=="undefined"&&typeof location=="undefined"?require("url").pathToFileURL(__filename).href:typeof document=="undefined"?location.href:Se&&Se.tagName.toUpperCase()==="SCRIPT"&&Se.src||new URL("cuadra-uikit.umd.js",document.baseURI).href).href];let s=!1;for(const a of i)if(n.href=a,n.onload=()=>{s=!0},n.onerror=()=>{},document.head.appendChild(n),s)break},[])}const Jl=({config:e})=>{Tx();const{baseUrl:t,proxyUrl:r,sessionToken:n,mode:i="multiChat",modelMode:s="fixed",modelId:a,onModelChange:o,ephemeral:l=!1,systemPrompt:u,initialThreadId:d,welcomeTitle:c,welcomeSubtitle:f,extraTopPadding:h,suggestions:g,inputPlaceholder:S,showThemeToggle:w=!0,theme:b="system",onError:C,onChatCreated:_,onUserMessage:F,onThreadIdUpdate:B}=e,[I,z]=y.useState(!1),j=r||t||"",$=!!r,k=y.useMemo(()=>new ja(j,n||void 0,$),[j,n,$]),[N,M]=y.useState(null),[V,R]=y.useState(!1),[D,Q]=y.useState(null),[se,ge]=y.useState(!1);y.useEffect(()=>{i==="multiChat"&&ge(!0)},[i]);const fe=y.useCallback(()=>P(null,null,function*(){if(s==="selector"){R(!0),Q(null);try{const Z=yield k.listModels();M(Z)}catch(Z){Q(Z instanceof Error?Z:new Error("Failed to load models"))}finally{R(!1)}}}),[k,s]);y.useEffect(()=>{s==="selector"&&fe()},[s,fe]),y.useEffect(()=>(typeof window!="undefined"&&(window.__cuadraUIKitRefetchModels=fe),()=>{typeof window!="undefined"&&delete window.__cuadraUIKitRefetchModels}),[fe]);const[x,ye]=y.useState(s==="fixed"&&a||null),Ie=y.useRef(x),v=y.useCallback(Z=>{const je=Ie.current;ye(Z),Ie.current=Z,o==null||o(Z),je!==null&&je!==Z&&i==="multiChat"&&setTimeout(()=>{var bt,nn;const pe=window.__cuadraThreadListRuntime;if((bt=pe==null?void 0:pe.threads)!=null&&bt.switchToNewThread)try{pe.threads.switchToNewThread()}catch(sn){}else if((nn=pe==null?void 0:pe.threads)!=null&&nn.createThread)try{pe.threads.createThread()}catch(sn){}else if(pe!=null&&pe.switchToNewThread)try{pe.switchToNewThread()}catch(sn){}},100)},[o,i]);y.useEffect(()=>{if(s==="selector"&&(N!=null&&N.items)&&N.items.length>0&&!x){const Z=N.items[0];if(Z!=null&&Z.id){const je=Z.id;ye(je),o==null||o(je)}}},[s,N==null?void 0:N.items,x,o]);const ve=s==="fixed"?!!a:!!x,Re=y.useMemo(()=>((N==null?void 0:N.items)||[]).filter(Z=>(Z==null?void 0:Z.id)&&(Z==null?void 0:Z.displayName)).map(Z=>({id:Z.id,name:Z.displayName})),[N]),le=y.useMemo(()=>({currentModelId:x||"",models:Re,modelsLoading:V,modelsError:D,onModelChange:v,refetchModels:fe}),[x,Re,V,D,v,fe]);return s==="selector"&&V||i==="multiChat"&&se?p.jsx(zi,{value:le,children:p.jsx(Bi,{className:"cuadra-h-full",paddingX:"cuadra-px-0",paddingY:"cuadra-py-0",children:p.jsx("div",{className:"cuadra-flex cuadra-items-center cuadra-justify-center cuadra-h-full",children:p.jsx($i,{className:"cuadra-h-6 cuadra-w-6 cuadra-animate-spin cuadra-text-muted-foreground"})})})}):s==="selector"&&!ve&&D?p.jsx(zi,{value:le,children:p.jsx(Bi,{className:"cuadra-h-full",paddingX:"cuadra-px-0",paddingY:"cuadra-py-0",children:p.jsx("div",{className:"cuadra-flex cuadra-items-center cuadra-justify-center cuadra-h-full",children:p.jsx("div",{className:"cuadra-flex cuadra-flex-col cuadra-items-center cuadra-gap-2",children:p.jsx("p",{className:"cuadra-text-sm cuadra-text-destructive font-brand",children:"Failed to load models"})})})})}):p.jsx("div",{className:"cuadra-uikit cuadra-h-full cuadra-w-full",style:{height:"100%",width:"100%"},children:p.jsx(zi,{value:le,children:p.jsx(Pf,{baseUrl:$?j:t||j,sessionToken:n,isProxyMode:$,mode:i,modelMode:s,modelId:x||a||void 0,onModelChange:v,ephemeral:l,systemPrompt:u,initialThreadId:d,onError:C,onChatCreated:_,onUserMessage:F,onThreadIdUpdate:B,onChatsLoaded:()=>{i==="multiChat"&&ge(!1)},children:p.jsx(Bi,{paddingX:"cuadra-px-0",paddingY:"cuadra-py-0",className:`cuadra-h-full ${e.containerClass||""}`,borderSizePx:4,style:{height:"100%"},children:p.jsx("div",{className:"cuadra-h-full cuadra-flex cuadra-relative",style:{height:"100%"},children:i==="multiChat"?p.jsxs(p.Fragment,{children:[I&&typeof document!="undefined"&&Oe.createPortal(p.jsx("div",{className:"cuadra-fixed cuadra-inset-0 cuadra-bg-black/50 cuadra-z-40 md:cuadra-hidden",onClick:()=>z(!1)}),document.body),typeof document!="undefined"&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:"cuadra-hidden md:cuadra-block !cuadra-border-r cuadra-border-border cuadra-flex cuadra-flex-col cuadra-bg-background cuadra-transition-all cuadra-duration-300 cuadra-ease-in-out cuadra-h-full cuadra-w-80 cuadra-relative",style:{borderRightWidth:"1px",height:"100%"},children:p.jsx(Vl,{onThreadSelect:()=>z(!1)})}),I&&Oe.createPortal(p.jsx("div",{className:"cuadra-block md:cuadra-hidden !cuadra-border-r cuadra-border-border cuadra-flex cuadra-flex-col cuadra-bg-background cuadra-transition-all cuadra-duration-300 cuadra-ease-in-out cuadra-h-screen cuadra-w-80 cuadra-fixed cuadra-z-50 cuadra-top-0 cuadra-left-0 cuadra-translate-x-0",style:{borderRightWidth:"1px"},children:p.jsx(Vl,{onThreadSelect:()=>z(!1)})}),document.body)]}),p.jsxs("div",{className:"cuadra-flex-1 cuadra-flex cuadra-flex-col",children:[s==="selector"&&p.jsx(Wl,{currentModel:x||"",models:Re,modelsLoading:V,modelsError:D,onModelChange:v,showThemeToggle:w,theme:b,onMobileMenuClick:()=>z(!I),showMobileMenuButton:i==="multiChat"}),p.jsx("div",{className:"cuadra-flex-1 cuadra-relative cuadra-min-h-0 cuadra-space-y-4 cuadra-p-4",children:p.jsx(ql,{welcomeTitle:c,welcomeSubtitle:f,extraTopPadding:h,suggestions:g,inputPlaceholder:S})})]})]}):p.jsxs("div",{className:"cuadra-flex-1 cuadra-flex cuadra-flex-col",children:[s==="selector"&&p.jsx(Wl,{currentModel:x||"",models:Re,modelsLoading:V,modelsError:D,onModelChange:v,showThemeToggle:w,theme:b}),p.jsx("div",{className:"cuadra-flex-1 cuadra-relative cuadra-min-h-0 cuadra-space-y-4 cuadra-p-4",children:p.jsx(ql,{welcomeTitle:c,welcomeSubtitle:f,extraTopPadding:h,suggestions:g})})]})})})})})})};class rn{constructor(){T(this,"config",null);T(this,"root",null);T(this,"container",null);T(this,"instances",new Map)}init(t){if(!t.baseUrl&&!t.proxyUrl)throw new Error("Either baseUrl or proxyUrl is required");if(t.modelMode==="fixed"&&t.modelId!==void 0&&(!t.modelId||t.modelId.trim()===""))throw new Error("modelId cannot be empty when explicitly provided. Omit modelId to let backend resolve it.");const r=t.containerId||"cuadra-chat";let n=document.getElementById(r);n||(n=document.createElement("div"),n.id=r,document.body.appendChild(n)),t.containerClass&&n.classList.add(...t.containerClass.split(" ")),this.config=E(m({},t),{containerId:r}),this.container=n,this.root=ae.createRoot(n),this.root.render(y.createElement(Gl,{config:this.config})),this.instances.set(r,this)}destroy(t){var i;const r=t||((i=this.config)==null?void 0:i.containerId);if(!r)return;const n=this.instances.get(r);n!=null&&n.root&&(n.root.unmount(),n.root=null),n!=null&&n.container&&n.container.parentNode&&n.container.parentNode.removeChild(n.container),this.instances.delete(r)}updateConfig(t,r){var a;const n=r||((a=this.config)==null?void 0:a.containerId);if(!n)return;const i=this.instances.get(n);if(!(i!=null&&i.config))return;const s=m(m({},i.config),t);i.config=s,i.root&&i.container&&i.root.render(y.createElement(Gl,{config:s}))}getInstance(t){var n;const r=t||((n=this.config)==null?void 0:n.containerId);return r&&this.instances.get(r)||null}static parseConfigFromAttributes(t,r){const n={};return t.dataset.baseUrl&&(n.baseUrl=t.dataset.baseUrl),t.dataset.proxyUrl&&(n.proxyUrl=t.dataset.proxyUrl),t.dataset.sessionToken&&(n.sessionToken=t.dataset.sessionToken),t.dataset.containerId&&(n.containerId=t.dataset.containerId),t.dataset.containerClass&&(n.containerClass=t.dataset.containerClass),t.dataset.mode&&(n.mode=t.dataset.mode),t.dataset.modelMode&&(n.modelMode=t.dataset.modelMode),t.dataset.modelId&&(n.modelId=t.dataset.modelId),t.dataset.ephemeral&&(n.ephemeral=t.dataset.ephemeral==="true"),t.dataset.systemPrompt&&(n.systemPrompt=t.dataset.systemPrompt),r&&(r.dataset.baseUrl&&(n.baseUrl=r.dataset.baseUrl),r.dataset.proxyUrl&&(n.proxyUrl=r.dataset.proxyUrl),r.dataset.sessionToken&&(n.sessionToken=r.dataset.sessionToken),r.dataset.mode&&(n.mode=r.dataset.mode),r.dataset.modelMode&&(n.modelMode=r.dataset.modelMode),r.dataset.modelId&&(n.modelId=r.dataset.modelId)),n}}const Gl=({config:e})=>p.jsx(Jl,{config:e});let Ce=null;typeof window!="undefined"&&(Ce=new rn);const Yl={init:e=>(Ce||(Ce=new rn),Ce.init(e)),destroy:e=>Ce==null?void 0:Ce.destroy(e),updateConfig:(e,t)=>Ce==null?void 0:Ce.updateConfig(e,t),getInstance:e=>Ce==null?void 0:Ce.getInstance(e),refetchModels:()=>{if(typeof window!="undefined"){const e=window.__cuadraUIKitRefetchModels;e&&e()}},version:"0.1.0"};if(typeof window!="undefined"){window.CuadraUIKit=Yl;const e=()=>{const t=document.querySelectorAll('script[src*="cuadra-uikit"]'),r=Array.from(t).find(n=>(n.getAttribute("src")||"").includes("cuadra-uikit.umd.js"));r&&r.dataset.autoInit!=="false"&&Cx(r)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e):setTimeout(e,0)}function Cx(e){if(!e||!Ce)return;const t=rn.parseConfigFromAttributes(e),r=t.containerId||"cuadra-chat",n=document.getElementById(r);if(n){const i=rn.parseConfigFromAttributes(e,n);Object.assign(t,i)}(t.baseUrl||t.proxyUrl)&&Ce.init(t)}U.WidgetContent=Jl,U.default=Yl,Object.defineProperties(U,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
48
40
  //# sourceMappingURL=cuadra-uikit.umd.js.map