@whitenight_5/web-assistant 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web-assistant-core.umd.css +3 -0
- package/dist/web-assistant-core.umd.js +272 -0
- package/dist/web-assistant-fab.umd.js +56 -0
- package/dist/web-assistant.umd.css +70 -2
- package/dist/web-assistant.umd.js +89 -170
- package/package.json +13 -6
- package/dist/assets/index-Bmgto34i.css +0 -2
- package/dist/assets/index-WRsgiXm_.js +0 -196
- package/dist/index.html +0 -14
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,o)=>(o=n==null?{}:e(i(n)),s(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var l=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=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,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function ee(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var te=/\/+/g;function ne(e,t){return typeof e==`object`&&e&&e.key!=null?ee(``+e.key):t.toString(36)}function k(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function re(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,re(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+ne(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(te,`$&/`)+`/`),re(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(te,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+ne(a,u),c+=re(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+ne(a,u++),c+=re(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return re(k(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function ie(e,t,n){if(e==null)return e;var r=[],i=0;return re(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function ae(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var A=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},j={map:ie,forEach:function(e,t,n){ie(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return ie(e,function(){t++}),t},toArray:function(e){return ie(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=j,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:ae}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,A)}catch(e){A(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.8`})),u=o(((e,t)=>{t.exports=l()})),d=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&ne(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&ne(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var ee=new MessageChannel,te=ee.port2;ee.port1.onmessage=D,O=function(){te.postMessage(null)}}else O=function(){_(D,0)};function ne(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,ne(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),f=o(((e,t)=>{t.exports=d()})),p=o((e=>{var t=u();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.8`})),m=o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=p()})),h=o((e=>{var t=f(),n=u(),r=m();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function d(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function p(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=p(e),t!==null)return t;e=e.sibling}return null}var h=Object.assign,g=Symbol.for(`react.element`),_=Symbol.for(`react.transitional.element`),v=Symbol.for(`react.portal`),y=Symbol.for(`react.fragment`),b=Symbol.for(`react.strict_mode`),x=Symbol.for(`react.profiler`),S=Symbol.for(`react.consumer`),C=Symbol.for(`react.context`),w=Symbol.for(`react.forward_ref`),T=Symbol.for(`react.suspense`),E=Symbol.for(`react.suspense_list`),D=Symbol.for(`react.memo`),O=Symbol.for(`react.lazy`),ee=Symbol.for(`react.activity`),te=Symbol.for(`react.memo_cache_sentinel`),ne=Symbol.iterator;function k(e){return typeof e!=`object`||!e?null:(e=ne&&e[ne]||e[`@@iterator`],typeof e==`function`?e:null)}var re=Symbol.for(`react.client.reference`);function ie(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===re?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case y:return`Fragment`;case x:return`Profiler`;case b:return`StrictMode`;case T:return`Suspense`;case E:return`SuspenseList`;case ee:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case v:return`Portal`;case C:return e.displayName||`Context`;case S:return(e._context.displayName||`Context`)+`.Consumer`;case w:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case D:return t=e.displayName||null,t===null?ie(e.type)||`Memo`:t;case O:t=e._payload,e=e._init;try{return ie(e(t))}catch{}}return null}var ae=Array.isArray,A=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,j=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,oe={pending:!1,data:null,method:null,action:null},se=[],ce=-1;function le(e){return{current:e}}function ue(e){0>ce||(e.current=se[ce],se[ce]=null,ce--)}function de(e,t){ce++,se[ce]=e.current,e.current=t}var fe=le(null),pe=le(null),me=le(null),he=le(null);function ge(e,t){switch(de(me,t),de(pe,e),de(fe,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?nf(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=nf(t),e=rf(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}ue(fe),de(fe,e)}function _e(){ue(fe),ue(pe),ue(me)}function ve(e){e.memoizedState!==null&&de(he,e);var t=fe.current,n=rf(t,e.type);t!==n&&(de(pe,e),de(fe,n))}function ye(e){pe.current===e&&(ue(fe),ue(pe)),he.current===e&&(ue(he),pp._currentValue=oe)}var be,xe;function Se(e){if(be===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);be=t&&t[1]||``,xe=-1<e.stack.indexOf(`
|
|
2
|
-
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
3
|
-
`+be+e+xe}var Ce=!1;function we(e,t){if(!e||Ce)return``;Ce=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
4
|
-
`),l=s.split(`
|
|
5
|
-
`);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
|
|
6
|
-
`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{Ce=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?Se(n):``}function Te(e,t){switch(e.tag){case 26:case 27:case 5:return Se(e.type);case 16:return Se(`Lazy`);case 13:return e.child!==t&&t!==null?Se(`Suspense Fallback`):Se(`Suspense`);case 19:return Se(`SuspenseList`);case 0:case 15:return we(e.type,!1);case 11:return we(e.type.render,!1);case 1:return we(e.type,!0);case 31:return Se(`Activity`);default:return``}}function Ee(e){try{var t=``,n=null;do t+=Te(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
|
|
7
|
-
Error generating stack: `+e.message+`
|
|
8
|
-
`+e.stack}}var De=Object.prototype.hasOwnProperty,Oe=t.unstable_scheduleCallback,ke=t.unstable_cancelCallback,Ae=t.unstable_shouldYield,je=t.unstable_requestPaint,Me=t.unstable_now,Ne=t.unstable_getCurrentPriorityLevel,Pe=t.unstable_ImmediatePriority,Fe=t.unstable_UserBlockingPriority,Ie=t.unstable_NormalPriority,Le=t.unstable_LowPriority,Re=t.unstable_IdlePriority,ze=t.log,Be=t.unstable_setDisableYieldValue,Ve=null,He=null;function Ue(e){if(typeof ze==`function`&&Be(e),He&&typeof He.setStrictMode==`function`)try{He.setStrictMode(Ve,e)}catch{}}var We=Math.clz32?Math.clz32:qe,Ge=Math.log,Ke=Math.LN2;function qe(e){return e>>>=0,e===0?32:31-(Ge(e)/Ke|0)|0}var Je=256,Ye=262144,Xe=4194304;function Ze(e){var t=e&42;if(t!==0)return t;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 Qe(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=Ze(n))):i=Ze(o):i=Ze(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Ze(n))):i=Ze(o)):i=Ze(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function $e(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function et(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+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 t+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 tt(){var e=Xe;return Xe<<=1,!(Xe&62914560)&&(Xe=4194304),e}function nt(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function rt(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function it(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-We(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&at(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function at(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-We(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function ot(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-We(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function st(e,t){var n=t&-t;return n=n&42?1:ct(n),(n&(e.suspendedLanes|t))===0?n:0}function ct(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 lt(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function ut(){var e=j.p;return e===0?(e=window.event,e===void 0?32:kp(e.type)):e}function dt(e,t){var n=j.p;try{return j.p=e,t()}finally{j.p=n}}var ft=Math.random().toString(36).slice(2),pt=`__reactFiber$`+ft,mt=`__reactProps$`+ft,ht=`__reactContainer$`+ft,gt=`__reactEvents$`+ft,_t=`__reactListeners$`+ft,M=`__reactHandles$`+ft,vt=`__reactResources$`+ft,yt=`__reactMarker$`+ft;function bt(e){delete e[pt],delete e[mt],delete e[gt],delete e[_t],delete e[M]}function xt(e){var t=e[pt];if(t)return t;for(var n=e.parentNode;n;){if(t=n[ht]||n[pt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Ef(e);e!==null;){if(n=e[pt])return n;e=Ef(e)}return t}e=n,n=e.parentNode}return null}function St(e){if(e=e[pt]||e[ht]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function Ct(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function wt(e){var t=e[vt];return t||=e[vt]={hoistableStyles:new Map,hoistableScripts:new Map},t}function Tt(e){e[yt]=!0}var Et=new Set,Dt={};function Ot(e,t){kt(e,t),kt(e+`Capture`,t)}function kt(e,t){for(Dt[e]=t,e=0;e<t.length;e++)Et.add(t[e])}var At=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]*$`),jt={},Mt={};function Nt(e){return De.call(Mt,e)?!0:De.call(jt,e)?!1:At.test(e)?Mt[e]=!0:(jt[e]=!0,!1)}function Pt(e,t,n){if(Nt(t)){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,``+n)}}}function Ft(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,``+n)}}function It(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,``+r)}}function Lt(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function Rt(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function zt(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Bt(e){if(!e._valueTracker){var t=Rt(e)?`checked`:`value`;e._valueTracker=zt(e,t,``+e[t])}}function Vt(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=Rt(e)?e.checked?`true`:`false`:e.value),e=r,e!==n&&(t.setValue(e),!0)}function Ht(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}var Ut=/[\n"\\]/g;function Wt(e){return e.replace(Ut,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function Gt(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+Lt(t)):e.value!==``+Lt(t)&&(e.value=``+Lt(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):qt(e,o,Lt(n)):qt(e,o,Lt(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+Lt(s):e.removeAttribute(`name`)}function Kt(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){Bt(e);return}n=n==null?``:``+Lt(n),t=t==null?n:``+Lt(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),Bt(e)}function qt(e,t,n){t===`number`&&Ht(e.ownerDocument)===e||e.defaultValue===``+n||(e.defaultValue=``+n)}function Jt(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+Lt(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function Yt(e,t,n){if(t!=null&&(t=``+Lt(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+Lt(n)}function Xt(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(ae(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=Lt(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),Bt(e)}function Zt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Qt=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 $t(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||Qt.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function en(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(i(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&$t(e,a,r)}else for(var o in t)t.hasOwnProperty(o)&&$t(e,o,t[o])}function tn(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 nn=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`]]),rn=/^[\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 an(e){return rn.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function on(){}var sn=null;function cn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ln=null,un=null;function dn(e){var t=St(e);if(t&&(e=t.stateNode)){var n=e[mt]||null;a:switch(e=t.stateNode,t.type){case`input`:if(Gt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+Wt(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[mt]||null;if(!a)throw Error(i(90));Gt(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&Vt(r)}break a;case`textarea`:Yt(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&Jt(e,!!n.multiple,t,!1)}}}var fn=!1;function pn(e,t,n){if(fn)return e(t,n);fn=!0;try{return e(t)}finally{if(fn=!1,(ln!==null||un!==null)&&(Nu(),ln&&(t=ln,e=un,un=ln=null,dn(t),e)))for(t=0;t<e.length;t++)dn(e[t])}}function mn(e,t){var n=e.stateNode;if(n===null)return null;var r=n[mt]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=e!==`button`&&e!==`input`&&e!==`select`&&e!==`textarea`),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(i(231,t,typeof n));return n}var hn=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),gn=!1;if(hn)try{var _n={};Object.defineProperty(_n,"passive",{get:function(){gn=!0}}),window.addEventListener(`test`,_n,_n),window.removeEventListener(`test`,_n,_n)}catch{gn=!1}var vn=null,yn=null,bn=null;function xn(){if(bn)return bn;var e,t=yn,n=t.length,r,i=`value`in vn?vn.value:vn.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return bn=i.slice(e,1<r?1-r:void 0)}function Sn(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Cn(){return!0}function wn(){return!1}function Tn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?Cn:wn,this.isPropagationStopped=wn,this}return h(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=Cn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=Cn)},persist:function(){},isPersistent:Cn}),t}var En={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Dn=Tn(En),On=h({},En,{view:0,detail:0}),kn=Tn(On),An,jn,Mn,Nn=h({},On,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Wn,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!==Mn&&(Mn&&e.type===`mousemove`?(An=e.screenX-Mn.screenX,jn=e.screenY-Mn.screenY):jn=An=0,Mn=e),An)},movementY:function(e){return`movementY`in e?e.movementY:jn}}),Pn=Tn(Nn),Fn=Tn(h({},Nn,{dataTransfer:0})),In=Tn(h({},On,{relatedTarget:0})),Ln=Tn(h({},En,{animationName:0,elapsedTime:0,pseudoElement:0})),Rn=Tn(h({},En,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),zn=Tn(h({},En,{data:0})),Bn={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},Vn={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`},Hn={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function Un(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Hn[e])?!!t[e]:!1}function Wn(){return Un}var Gn=Tn(h({},On,{key:function(e){if(e.key){var t=Bn[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=Sn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?Vn[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Wn,charCode:function(e){return e.type===`keypress`?Sn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?Sn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),Kn=Tn(h({},Nn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),qn=Tn(h({},On,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Wn})),Jn=Tn(h({},En,{propertyName:0,elapsedTime:0,pseudoElement:0})),Yn=Tn(h({},Nn,{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})),Xn=Tn(h({},En,{newState:0,oldState:0})),Zn=[9,13,27,32],Qn=hn&&`CompositionEvent`in window,$n=null;hn&&`documentMode`in document&&($n=document.documentMode);var er=hn&&`TextEvent`in window&&!$n,tr=hn&&(!Qn||$n&&8<$n&&11>=$n),nr=` `,rr=!1;function ir(e,t){switch(e){case`keyup`:return Zn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function ar(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var or=!1;function sr(e,t){switch(e){case`compositionend`:return ar(t);case`keypress`:return t.which===32?(rr=!0,nr):null;case`textInput`:return e=t.data,e===nr&&rr?null:e;default:return null}}function cr(e,t){if(or)return e===`compositionend`||!Qn&&ir(e,t)?(e=xn(),bn=yn=vn=null,or=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return tr&&t.locale!==`ko`?null:t.data;default:return null}}var lr={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 ur(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!lr[e.type]:t===`textarea`}function dr(e,t,n,r){ln?un?un.push(r):un=[r]:ln=r,t=Vd(t,`onChange`),0<t.length&&(n=new Dn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var fr=null,pr=null;function mr(e){Nd(e,0)}function hr(e){if(Vt(Ct(e)))return e}function gr(e,t){if(e===`change`)return t}var _r=!1;if(hn){var vr;if(hn){var yr=`oninput`in document;if(!yr){var br=document.createElement(`div`);br.setAttribute(`oninput`,`return;`),yr=typeof br.oninput==`function`}vr=yr}else vr=!1;_r=vr&&(!document.documentMode||9<document.documentMode)}function xr(){fr&&(fr.detachEvent(`onpropertychange`,Sr),pr=fr=null)}function Sr(e){if(e.propertyName===`value`&&hr(pr)){var t=[];dr(t,pr,e,cn(e)),pn(mr,t)}}function Cr(e,t,n){e===`focusin`?(xr(),fr=t,pr=n,fr.attachEvent(`onpropertychange`,Sr)):e===`focusout`&&xr()}function wr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return hr(pr)}function Tr(e,t){if(e===`click`)return hr(t)}function Er(e,t){if(e===`input`||e===`change`)return hr(t)}function Dr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var Or=typeof Object.is==`function`?Object.is:Dr;function kr(e,t){if(Or(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!De.call(t,i)||!Or(e[i],t[i]))return!1}return!0}function Ar(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function jr(e,t){var n=Ar(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Ar(n)}}function Mr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Mr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Nr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Ht(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ht(e.document)}return t}function N(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var Pr=hn&&`documentMode`in document&&11>=document.documentMode,Fr=null,Ir=null,Lr=null,Rr=!1;function zr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Rr||Fr==null||Fr!==Ht(r)||(r=Fr,`selectionStart`in r&&N(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Lr&&kr(Lr,r)||(Lr=r,r=Vd(Ir,`onSelect`),0<r.length&&(t=new Dn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=Fr)))}function Br(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var P={animationend:Br(`Animation`,`AnimationEnd`),animationiteration:Br(`Animation`,`AnimationIteration`),animationstart:Br(`Animation`,`AnimationStart`),transitionrun:Br(`Transition`,`TransitionRun`),transitionstart:Br(`Transition`,`TransitionStart`),transitioncancel:Br(`Transition`,`TransitionCancel`),transitionend:Br(`Transition`,`TransitionEnd`)},Vr={},Hr={};hn&&(Hr=document.createElement(`div`).style,`AnimationEvent`in window||(delete P.animationend.animation,delete P.animationiteration.animation,delete P.animationstart.animation),`TransitionEvent`in window||delete P.transitionend.transition);function Ur(e){if(Vr[e])return Vr[e];if(!P[e])return e;var t=P[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Hr)return Vr[e]=t[n];return e}var Wr=Ur(`animationend`),Gr=Ur(`animationiteration`),Kr=Ur(`animationstart`),qr=Ur(`transitionrun`),Jr=Ur(`transitionstart`),Yr=Ur(`transitioncancel`),Xr=Ur(`transitionend`),Zr=new Map,Qr=`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(` `);Qr.push(`scrollEnd`);function $r(e,t){Zr.set(e,t),Ot(t,[e])}var ei=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},ti=[],ni=0,ri=0;function ii(){for(var e=ni,t=ri=ni=0;t<e;){var n=ti[t];ti[t++]=null;var r=ti[t];ti[t++]=null;var i=ti[t];ti[t++]=null;var a=ti[t];if(ti[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&ci(n,i,a)}}function ai(e,t,n,r){ti[ni++]=e,ti[ni++]=t,ti[ni++]=n,ti[ni++]=r,ri|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function oi(e,t,n,r){return ai(e,t,n,r),li(e)}function si(e,t){return ai(e,null,null,t),li(e)}function ci(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-We(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function li(e){if(50<wu)throw wu=0,Tu=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var ui={};function di(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function fi(e,t,n,r){return new di(e,t,n,r)}function pi(e){return e=e.prototype,!(!e||!e.isReactComponent)}function mi(e,t){var n=e.alternate;return n===null?(n=fi(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function hi(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function gi(e,t,n,r,a,o){var s=0;if(r=e,typeof e==`function`)pi(e)&&(s=1);else if(typeof e==`string`)s=ip(e,n,fe.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(e){case ee:return e=fi(31,n,t,a),e.elementType=ee,e.lanes=o,e;case y:return _i(n.children,a,o,t);case b:s=8,a|=24;break;case x:return e=fi(12,n,t,a|2),e.elementType=x,e.lanes=o,e;case T:return e=fi(13,n,t,a),e.elementType=T,e.lanes=o,e;case E:return e=fi(19,n,t,a),e.elementType=E,e.lanes=o,e;default:if(typeof e==`object`&&e)switch(e.$$typeof){case C:s=10;break a;case S:s=9;break a;case w:s=11;break a;case D:s=14;break a;case O:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=fi(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function _i(e,t,n,r){return e=fi(7,e,r,t),e.lanes=n,e}function vi(e,t,n){return e=fi(6,e,null,t),e.lanes=n,e}function yi(e){var t=fi(18,null,null,0);return t.stateNode=e,t}function bi(e,t,n){return t=fi(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var xi=new WeakMap;function Si(e,t){if(typeof e==`object`&&e){var n=xi.get(e);return n===void 0?(t={value:e,source:t,stack:Ee(t)},xi.set(e,t),t):n}return{value:e,source:t,stack:Ee(t)}}var Ci=[],wi=0,Ti=null,Ei=0,Di=[],Oi=0,ki=null,Ai=1,ji=``;function Mi(e,t){Ci[wi++]=Ei,Ci[wi++]=Ti,Ti=e,Ei=t}function Ni(e,t,n){Di[Oi++]=Ai,Di[Oi++]=ji,Di[Oi++]=ki,ki=e;var r=Ai;e=ji;var i=32-We(r)-1;r&=~(1<<i),n+=1;var a=32-We(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,Ai=1<<32-We(t)+i|n<<i|r,ji=a+e}else Ai=1<<a|n<<i|r,ji=e}function Pi(e){e.return!==null&&(Mi(e,1),Ni(e,1,0))}function Fi(e){for(;e===Ti;)Ti=Ci[--wi],Ci[wi]=null,Ei=Ci[--wi],Ci[wi]=null;for(;e===ki;)ki=Di[--Oi],Di[Oi]=null,ji=Di[--Oi],Di[Oi]=null,Ai=Di[--Oi],Di[Oi]=null}function Ii(e,t){Di[Oi++]=Ai,Di[Oi++]=ji,Di[Oi++]=ki,Ai=t.id,ji=t.overflow,ki=e}var Li=null,Ri=null,zi=!1,Bi=null,Vi=!1,Hi=Error(i(519));function Ui(e){throw Yi(Si(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),Hi}function Wi(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[pt]=e,t[mt]=r,n){case`dialog`:Pd(`cancel`,t),Pd(`close`,t);break;case`iframe`:case`object`:case`embed`:Pd(`load`,t);break;case`video`:case`audio`:for(n=0;n<jd.length;n++)Pd(jd[n],t);break;case`source`:Pd(`error`,t);break;case`img`:case`image`:case`link`:Pd(`error`,t),Pd(`load`,t);break;case`details`:Pd(`toggle`,t);break;case`input`:Pd(`invalid`,t),Kt(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:Pd(`invalid`,t);break;case`textarea`:Pd(`invalid`,t),Xt(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||Kd(t.textContent,n)?(r.popover!=null&&(Pd(`beforetoggle`,t),Pd(`toggle`,t)),r.onScroll!=null&&Pd(`scroll`,t),r.onScrollEnd!=null&&Pd(`scrollend`,t),r.onClick!=null&&(t.onclick=on),t=!0):t=!1,t||Ui(e,!0)}function Gi(e){for(Li=e.return;Li;)switch(Li.tag){case 5:case 31:case 13:Vi=!1;return;case 27:case 3:Vi=!0;return;default:Li=Li.return}}function Ki(e){if(e!==Li)return!1;if(!zi)return Gi(e),zi=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=n===`form`||n===`button`||af(e.type,e.memoizedProps)),n=!n),n&&Ri&&Ui(e),Gi(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Ri=Tf(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Ri=Tf(e)}else t===27?(t=Ri,pf(e.type)?(e=wf,wf=null,Ri=e):Ri=t):Ri=Li?Cf(e.stateNode.nextSibling):null;return!0}function qi(){Ri=Li=null,zi=!1}function Ji(){var e=Bi;return e!==null&&(uu===null?uu=e:uu.push.apply(uu,e),Bi=null),e}function Yi(e){Bi===null?Bi=[e]:Bi.push(e)}var Xi=le(null),Zi=null,Qi=null;function $i(e,t,n){de(Xi,t._currentValue),t._currentValue=n}function ea(e){e._currentValue=Xi.current,ue(Xi)}function ta(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function na(e,t,n,r){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){var s=a.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=a;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),ta(o.return,n,e),r||(s=null);break a}o=c.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(i(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),ta(s,n,e),s=null}else s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function ra(e,t,n,r){e=null;for(var a=t,o=!1;a!==null;){if(!o){if(a.flags&524288)o=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(i(387));if(s=s.memoizedProps,s!==null){var c=a.type;Or(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===he.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[pp]:e.push(pp))}a=a.return}e!==null&&na(t,e,n,r),t.flags|=262144}function ia(e){for(e=e.firstContext;e!==null;){if(!Or(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function aa(e){Zi=e,Qi=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function oa(e){return ca(Zi,e)}function sa(e,t){return Zi===null&&aa(e),ca(e,t)}function ca(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},Qi===null){if(e===null)throw Error(i(308));Qi=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Qi=Qi.next=t;return n}var la=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},ua=t.unstable_scheduleCallback,da=t.unstable_NormalPriority,fa={$$typeof:C,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function pa(){return{controller:new la,data:new Map,refCount:0}}function ma(e){e.refCount--,e.refCount===0&&ua(da,function(){e.controller.abort()})}var ha=null,ga=0,_a=0,va=null;function ya(e,t){if(ha===null){var n=ha=[];ga=0,_a=Td(),va={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return ga++,t.then(ba,ba),t}function ba(){if(--ga===0&&ha!==null){va!==null&&(va.status=`fulfilled`);var e=ha;ha=null,_a=0,va=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function xa(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var Sa=A.S;A.S=function(e,t){pu=Me(),typeof t==`object`&&t&&typeof t.then==`function`&&ya(e,t),Sa!==null&&Sa(e,t)};var Ca=le(null);function wa(){var e=Ca.current;return e===null?Jl.pooledCache:e}function Ta(e,t){t===null?de(Ca,Ca.current):de(Ca,t.pool)}function Ea(){var e=wa();return e===null?null:{parent:fa._currentValue,pool:e}}var Da=Error(i(460)),Oa=Error(i(474)),ka=Error(i(542)),Aa={then:function(){}};function ja(e){return e=e.status,e===`fulfilled`||e===`rejected`}function Ma(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(on,on),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Ia(e),e;default:if(typeof t.status==`string`)t.then(on,on);else{if(e=Jl,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Ia(e),e}throw Pa=t,Da}}function Na(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(Pa=e,Da):e}}var Pa=null;function Fa(){if(Pa===null)throw Error(i(459));var e=Pa;return Pa=null,e}function Ia(e){if(e===Da||e===ka)throw Error(i(483))}var La=null,Ra=0;function za(e){var t=Ra;return Ra+=1,La===null&&(La=[]),Ma(La,e,t)}function Ba(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function Va(e,t){throw t.$$typeof===g?Error(i(525)):(e=Object.prototype.toString.call(t),Error(i(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function Ha(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function a(e,t){return e=mi(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=67108866,n):(r=r.index,r<n?(t.flags|=67108866,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=67108866),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=vi(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===y?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===O&&Na(i)===t.type)?(t=a(t,n.props),Ba(t,n),t.return=e,t):(t=gi(n.type,n.key,n.props,null,e.mode,r),Ba(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=bi(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=_i(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=vi(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case _:return n=gi(t.type,t.key,t.props,null,e.mode,n),Ba(n,t),n.return=e,n;case v:return t=bi(t,e.mode,n),t.return=e,t;case O:return t=Na(t),f(e,t,n)}if(ae(t)||k(t))return t=_i(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,za(t),n);if(t.$$typeof===C)return f(e,sa(e,t),n);Va(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case _:return n.key===i?l(e,t,n,r):null;case v:return n.key===i?u(e,t,n,r):null;case O:return n=Na(n),p(e,t,n,r)}if(ae(n)||k(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,za(n),r);if(n.$$typeof===C)return p(e,t,sa(e,n),r);Va(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case _:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case v:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case O:return r=Na(r),m(e,t,n,r,i)}if(ae(r)||k(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,za(r),i);if(r.$$typeof===C)return m(e,t,n,sa(t,r),i);Va(t,r)}return null}function h(i,a,s,c){for(var l=null,u=null,d=a,h=a=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),zi&&Mi(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return zi&&Mi(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&g.alternate!==null&&d.delete(g.key===null?h:g.key),a=o(g,a,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),zi&&Mi(i,h),l}function g(a,s,c,l){if(c==null)throw Error(i(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),zi&&Mi(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return zi&&Mi(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),zi&&Mi(a,g),u}function b(e,r,o,c){if(typeof o==`object`&&o&&o.type===y&&o.key===null&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case _:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===y){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===O&&Na(l)===r.type){n(e,r.sibling),c=a(r,o.props),Ba(c,o),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}o.type===y?(c=_i(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=gi(o.type,o.key,o.props,null,e.mode,c),Ba(c,o),c.return=e,e=c)}return s(e);case v:a:{for(l=o.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=bi(o,e.mode,c),c.return=e,e=c}return s(e);case O:return o=Na(o),b(e,r,o,c)}if(ae(o))return h(e,r,o,c);if(k(o)){if(l=k(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return b(e,r,za(o),c);if(o.$$typeof===C)return b(e,r,sa(e,o),c);Va(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=vi(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{Ra=0;var i=b(e,t,n,r);return La=null,i}catch(t){if(t===Da||t===ka)throw t;var a=fi(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Ua=Ha(!0),Wa=Ha(!1),Ga=!1;function Ka(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function qa(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Ja(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Ya(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,ql&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=li(e),ci(e,null,n),t}return ai(e,r,t,n),li(e)}function Xa(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ot(e,n)}}function Za(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Qa=!1;function $a(){if(Qa){var e=va;if(e!==null)throw e}}function eo(e,t,n,r){Qa=!1;var i=e.updateQueue;Ga=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(Xl&f)===f:(r&f)===f){f!==0&&f===_a&&(Qa=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,g=s;f=t;var _=n;switch(g.tag){case 1:if(m=g.payload,typeof m==`function`){d=m.call(_,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=g.payload,f=typeof m==`function`?m.call(_,d,f):m,f==null)break a;d=h({},d,f);break a;case 2:Ga=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),iu|=o,e.lanes=o,e.memoizedState=d}}function to(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function no(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)to(n[e],t)}var ro=le(null),io=le(0);function ao(e,t){e=nu,de(io,e),de(ro,t),nu=e|t.baseLanes}function oo(){de(io,nu),de(ro,ro.current)}function so(){nu=io.current,ue(ro),ue(io)}var co=le(null),lo=null;function uo(e){var t=e.alternate;de(go,go.current&1),de(co,e),lo===null&&(t===null||ro.current!==null||t.memoizedState!==null)&&(lo=e)}function fo(e){de(go,go.current),de(co,e),lo===null&&(lo=e)}function po(e){e.tag===22?(de(go,go.current),de(co,e),lo===null&&(lo=e)):mo(e)}function mo(){de(go,go.current),de(co,co.current)}function ho(e){ue(co),lo===e&&(lo=null),ue(go)}var go=le(0);function _o(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||bf(n)||xf(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder===`forwards`||t.memoizedProps.revealOrder===`backwards`||t.memoizedProps.revealOrder===`unstable_legacy-backwards`||t.memoizedProps.revealOrder===`together`)){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var vo=0,yo=null,bo=null,xo=null,So=!1,Co=!1,wo=!1,To=0,Eo=0,Do=null,Oo=0;function ko(){throw Error(i(321))}function Ao(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Or(e[n],t[n]))return!1;return!0}function jo(e,t,n,r,i,a){return vo=a,yo=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,A.H=e===null||e.memoizedState===null?qs:Js,wo=!1,a=n(r,i),wo=!1,Co&&(a=No(t,n,r,i)),Mo(e),a}function Mo(e){A.H=Ks;var t=bo!==null&&bo.next!==null;if(vo=0,xo=bo=yo=null,So=!1,Eo=0,Do=null,t)throw Error(i(300));e===null||dc||(e=e.dependencies,e!==null&&ia(e)&&(dc=!0))}function No(e,t,n,r){yo=e;var a=0;do{if(Co&&(Do=null),Eo=0,Co=!1,25<=a)throw Error(i(301));if(a+=1,xo=bo=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}A.H=Ys,o=t(n,r)}while(Co);return o}function Po(){var e=A.H,t=e.useState()[0];return t=typeof t.then==`function`?Vo(t):t,e=e.useState()[0],(bo===null?null:bo.memoizedState)!==e&&(yo.flags|=1024),t}function Fo(){var e=To!==0;return To=0,e}function Io(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function Lo(e){if(So){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}So=!1}vo=0,xo=bo=yo=null,Co=!1,Eo=To=0,Do=null}function Ro(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return xo===null?yo.memoizedState=xo=e:xo=xo.next=e,xo}function zo(){if(bo===null){var e=yo.alternate;e=e===null?null:e.memoizedState}else e=bo.next;var t=xo===null?yo.memoizedState:xo.next;if(t!==null)xo=t,bo=e;else{if(e===null)throw yo.alternate===null?Error(i(467)):Error(i(310));bo=e,e={memoizedState:bo.memoizedState,baseState:bo.baseState,baseQueue:bo.baseQueue,queue:bo.queue,next:null},xo===null?yo.memoizedState=xo=e:xo=xo.next=e}return xo}function Bo(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Vo(e){var t=Eo;return Eo+=1,Do===null&&(Do=[]),e=Ma(Do,e,t),t=yo,(xo===null?t.memoizedState:xo.next)===null&&(t=t.alternate,A.H=t===null||t.memoizedState===null?qs:Js),e}function Ho(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return Vo(e);if(e.$$typeof===C)return oa(e)}throw Error(i(438,String(e)))}function Uo(e){var t=null,n=yo.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=yo.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=Bo(),yo.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=te;return t.index++,n}function Wo(e,t){return typeof t==`function`?t(e):t}function Go(e){return Ko(zo(),bo,e)}function Ko(e,t,n){var r=e.queue;if(r===null)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,o=r.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}t.baseQueue=a=o,r.pending=null}if(o=e.baseState,a===null)e.memoizedState=o;else{t=a.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(vo&f)===f:(Xl&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===_a&&(d=!0);else if((vo&p)===p){u=u.next,p===_a&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,yo.lanes|=p,iu|=p;f=u.action,wo&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,yo.lanes|=f,iu|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!Or(o,e.memoizedState)&&(dc=!0,d&&(n=va,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return a===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function qo(e){var t=zo(),n=t.queue;if(n===null)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);Or(o,t.memoizedState)||(dc=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function Jo(e,t,n){var r=yo,a=zo(),o=zi;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!Or((bo||a).memoizedState,n);if(s&&(a.memoizedState=n,dc=!0),a=a.queue,ys(Zo.bind(null,r,a,e),[e]),a.getSnapshot!==t||s||xo!==null&&xo.memoizedState.tag&1){if(r.flags|=2048,ms(9,{destroy:void 0},Xo.bind(null,r,a,n,t),null),Jl===null)throw Error(i(349));o||vo&127||Yo(r,t,n)}return n}function Yo(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=yo.updateQueue,t===null?(t=Bo(),yo.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Xo(e,t,n,r){t.value=n,t.getSnapshot=r,Qo(t)&&$o(e)}function Zo(e,t,n){return n(function(){Qo(t)&&$o(e)})}function Qo(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Or(e,n)}catch{return!0}}function $o(e){var t=si(e,2);t!==null&&Ou(t,e,2)}function es(e){var t=Ro();if(typeof e==`function`){var n=e;if(e=n(),wo){Ue(!0);try{n()}finally{Ue(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Wo,lastRenderedState:e},t}function ts(e,t,n,r){return e.baseState=n,Ko(e,bo,typeof r==`function`?r:Wo)}function ns(e,t,n,r,a){if(Us(e))throw Error(i(485));if(e=t.action,e!==null){var o={payload:a,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};A.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,rs(t,o)):(o.next=n.next,t.pending=n.next=o)}}function rs(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=A.T,o={};A.T=o;try{var s=n(i,r),c=A.S;c!==null&&c(o,s),is(e,t,s)}catch(n){os(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),A.T=a}}else try{a=n(i,r),is(e,t,a)}catch(n){os(e,t,n)}}function is(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){as(e,t,n)},function(n){return os(e,t,n)}):as(e,t,n)}function as(e,t,n){t.status=`fulfilled`,t.value=n,ss(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,rs(e,n)))}function os(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,ss(t),t=t.next;while(t!==r)}e.action=null}function ss(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function cs(e,t){return t}function ls(e,t){if(zi){var n=Jl.formState;if(n!==null){a:{var r=yo;if(zi){if(Ri){b:{for(var i=Ri,a=Vi;i.nodeType!==8;){if(!a){i=null;break b}if(i=Cf(i.nextSibling),i===null){i=null;break b}}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){Ri=Cf(i.nextSibling),r=i.data===`F!`;break a}}Ui(r)}r=!1}r&&(t=n[0])}}return n=Ro(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:cs,lastRenderedState:t},n.queue=r,n=Bs.bind(null,yo,r),r.dispatch=n,r=es(!1),a=Hs.bind(null,yo,!1,r.queue),r=Ro(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=ns.bind(null,yo,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function us(e){return ds(zo(),bo,e)}function ds(e,t,n){if(t=Ko(e,t,cs)[0],e=Go(Wo)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=Vo(t)}catch(e){throw e===Da?ka:e}else r=t;t=zo();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(yo.flags|=2048,ms(9,{destroy:void 0},fs.bind(null,i,n),null)),[r,a,e]}function fs(e,t){e.action=t}function ps(e){var t=zo(),n=bo;if(n!==null)return ds(t,n,e);zo(),t=t.memoizedState,n=zo();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function ms(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=yo.updateQueue,t===null&&(t=Bo(),yo.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function hs(){return zo().memoizedState}function gs(e,t,n,r){var i=Ro();yo.flags|=e,i.memoizedState=ms(1|t,{destroy:void 0},n,r===void 0?null:r)}function _s(e,t,n,r){var i=zo();r=r===void 0?null:r;var a=i.memoizedState.inst;bo!==null&&r!==null&&Ao(r,bo.memoizedState.deps)?i.memoizedState=ms(t,a,n,r):(yo.flags|=e,i.memoizedState=ms(1|t,a,n,r))}function vs(e,t){gs(8390656,8,e,t)}function ys(e,t){_s(2048,8,e,t)}function bs(e){yo.flags|=4;var t=yo.updateQueue;if(t===null)t=Bo(),yo.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function xs(e){var t=zo().memoizedState;return bs({ref:t,nextImpl:e}),function(){if(ql&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function Ss(e,t){return _s(4,2,e,t)}function Cs(e,t){return _s(4,4,e,t)}function ws(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Ts(e,t,n){n=n==null?null:n.concat([e]),_s(4,4,ws.bind(null,t,e),n)}function Es(){}function Ds(e,t){var n=zo();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&Ao(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Os(e,t){var n=zo();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&Ao(t,r[1]))return r[0];if(r=e(),wo){Ue(!0);try{e()}finally{Ue(!1)}}return n.memoizedState=[r,t],r}function ks(e,t,n){return n===void 0||vo&1073741824&&!(Xl&261930)?e.memoizedState=t:(e.memoizedState=n,e=Du(),yo.lanes|=e,iu|=e,n)}function As(e,t,n,r){return Or(n,t)?n:ro.current===null?!(vo&42)||vo&1073741824&&!(Xl&261930)?(dc=!0,e.memoizedState=n):(e=Du(),yo.lanes|=e,iu|=e,t):(e=ks(e,n,r),Or(e,t)||(dc=!0),e)}function js(e,t,n,r,i){var a=j.p;j.p=a!==0&&8>a?a:8;var o=A.T,s={};A.T=s,Hs(e,!1,t,n);try{var c=i(),l=A.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Vs(e,t,xa(c,r),Eu(e)):Vs(e,t,r,Eu(e))}catch(n){Vs(e,t,{then:function(){},status:`rejected`,reason:n},Eu())}finally{j.p=a,o!==null&&s.types!==null&&(o.types=s.types),A.T=o}}function Ms(){}function Ns(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=Ps(e).queue;js(e,a,t,oe,n===null?Ms:function(){return Fs(e),n(r)})}function Ps(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:oe,baseState:oe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Wo,lastRenderedState:oe},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Wo,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Fs(e){var t=Ps(e);t.next===null&&(t=e.alternate.memoizedState),Vs(e,t.next.queue,{},Eu())}function Is(){return oa(pp)}function F(){return zo().memoizedState}function Ls(){return zo().memoizedState}function Rs(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Eu();e=Ja(n);var r=Ya(t,e,n);r!==null&&(Ou(r,t,n),Xa(r,t,n)),t={cache:pa()},e.payload=t;return}t=t.return}}function zs(e,t,n){var r=Eu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Us(e)?Ws(t,n):(n=oi(e,t,n,r),n!==null&&(Ou(n,e,r),Gs(n,t,r)))}function Bs(e,t,n){Vs(e,t,n,Eu())}function Vs(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Us(e))Ws(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Or(s,o))return ai(e,t,i,0),Jl===null&&ii(),!1}catch{}if(n=oi(e,t,i,r),n!==null)return Ou(n,e,r),Gs(n,t,r),!0}return!1}function Hs(e,t,n,r){if(r={lane:2,revertLane:Td(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Us(e)){if(t)throw Error(i(479))}else t=oi(e,n,r,2),t!==null&&Ou(t,e,2)}function Us(e){var t=e.alternate;return e===yo||t!==null&&t===yo}function Ws(e,t){Co=So=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Gs(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ot(e,n)}}var Ks={readContext:oa,use:Ho,useCallback:ko,useContext:ko,useEffect:ko,useImperativeHandle:ko,useLayoutEffect:ko,useInsertionEffect:ko,useMemo:ko,useReducer:ko,useRef:ko,useState:ko,useDebugValue:ko,useDeferredValue:ko,useTransition:ko,useSyncExternalStore:ko,useId:ko,useHostTransitionStatus:ko,useFormState:ko,useActionState:ko,useOptimistic:ko,useMemoCache:ko,useCacheRefresh:ko};Ks.useEffectEvent=ko;var qs={readContext:oa,use:Ho,useCallback:function(e,t){return Ro().memoizedState=[e,t===void 0?null:t],e},useContext:oa,useEffect:vs,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),gs(4194308,4,ws.bind(null,t,e),n)},useLayoutEffect:function(e,t){return gs(4194308,4,e,t)},useInsertionEffect:function(e,t){gs(4,2,e,t)},useMemo:function(e,t){var n=Ro();t=t===void 0?null:t;var r=e();if(wo){Ue(!0);try{e()}finally{Ue(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=Ro();if(n!==void 0){var i=n(t);if(wo){Ue(!0);try{n(t)}finally{Ue(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=zs.bind(null,yo,e),[r.memoizedState,e]},useRef:function(e){var t=Ro();return e={current:e},t.memoizedState=e},useState:function(e){e=es(e);var t=e.queue,n=Bs.bind(null,yo,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Es,useDeferredValue:function(e,t){return ks(Ro(),e,t)},useTransition:function(){var e=es(!1);return e=js.bind(null,yo,e.queue,!0,!1),Ro().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=yo,a=Ro();if(zi){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Jl===null)throw Error(i(349));Xl&127||Yo(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,vs(Zo.bind(null,r,o,e),[e]),r.flags|=2048,ms(9,{destroy:void 0},Xo.bind(null,r,o,n,t),null),n},useId:function(){var e=Ro(),t=Jl.identifierPrefix;if(zi){var n=ji,r=Ai;n=(r&~(1<<32-We(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=To++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=Oo++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:Is,useFormState:ls,useActionState:ls,useOptimistic:function(e){var t=Ro();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Hs.bind(null,yo,!0,n),n.dispatch=t,[e,t]},useMemoCache:Uo,useCacheRefresh:function(){return Ro().memoizedState=Rs.bind(null,yo)},useEffectEvent:function(e){var t=Ro(),n={impl:e};return t.memoizedState=n,function(){if(ql&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},Js={readContext:oa,use:Ho,useCallback:Ds,useContext:oa,useEffect:ys,useImperativeHandle:Ts,useInsertionEffect:Ss,useLayoutEffect:Cs,useMemo:Os,useReducer:Go,useRef:hs,useState:function(){return Go(Wo)},useDebugValue:Es,useDeferredValue:function(e,t){return As(zo(),bo.memoizedState,e,t)},useTransition:function(){var e=Go(Wo)[0],t=zo().memoizedState;return[typeof e==`boolean`?e:Vo(e),t]},useSyncExternalStore:Jo,useId:F,useHostTransitionStatus:Is,useFormState:us,useActionState:us,useOptimistic:function(e,t){return ts(zo(),bo,e,t)},useMemoCache:Uo,useCacheRefresh:Ls};Js.useEffectEvent=xs;var Ys={readContext:oa,use:Ho,useCallback:Ds,useContext:oa,useEffect:ys,useImperativeHandle:Ts,useInsertionEffect:Ss,useLayoutEffect:Cs,useMemo:Os,useReducer:qo,useRef:hs,useState:function(){return qo(Wo)},useDebugValue:Es,useDeferredValue:function(e,t){var n=zo();return bo===null?ks(n,e,t):As(n,bo.memoizedState,e,t)},useTransition:function(){var e=qo(Wo)[0],t=zo().memoizedState;return[typeof e==`boolean`?e:Vo(e),t]},useSyncExternalStore:Jo,useId:F,useHostTransitionStatus:Is,useFormState:ps,useActionState:ps,useOptimistic:function(e,t){var n=zo();return bo===null?(n.baseState=e,[e,n.queue.dispatch]):ts(n,bo,e,t)},useMemoCache:Uo,useCacheRefresh:Ls};Ys.useEffectEvent=xs;function Xs(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:h({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Zs={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Eu(),i=Ja(r);i.payload=t,n!=null&&(i.callback=n),t=Ya(e,i,r),t!==null&&(Ou(t,e,r),Xa(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Eu(),i=Ja(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Ya(e,i,r),t!==null&&(Ou(t,e,r),Xa(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Eu(),r=Ja(n);r.tag=2,t!=null&&(r.callback=t),t=Ya(e,r,n),t!==null&&(Ou(t,e,n),Xa(t,e,n))}};function Qs(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!kr(n,r)||!kr(i,a):!0}function $s(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Zs.enqueueReplaceState(t,t.state,null)}function ec(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=h({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function tc(e){ei(e)}function nc(e){console.error(e)}function rc(e){ei(e)}function ic(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function ac(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function oc(e,t,n){return n=Ja(n),n.tag=3,n.payload={element:null},n.callback=function(){ic(e,t)},n}function sc(e){return e=Ja(e),e.tag=3,e}function cc(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){ac(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){ac(t,n,r),typeof i!=`function`&&(gu===null?gu=new Set([this]):gu.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function lc(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&ra(t,n,a,!0),n=co.current,n!==null){switch(n.tag){case 31:case 13:return lo===null?Bu():n.alternate===null&&ru===0&&(ru=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===Aa?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),ad(e,r,a)),!1;case 22:return n.flags|=65536,r===Aa?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),ad(e,r,a)),!1}throw Error(i(435,n.tag))}return ad(e,r,a),Bu(),!1}if(zi)return t=co.current,t===null?(r!==Hi&&(t=Error(i(423),{cause:r}),Yi(Si(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=Si(r,n),a=oc(e.stateNode,r,a),Za(e,a),ru!==4&&(ru=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==Hi&&(e=Error(i(422),{cause:r}),Yi(Si(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=Si(o,n),lu===null?lu=[o]:lu.push(o),ru!==4&&(ru=2),t===null)return!0;r=Si(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=oc(n.stateNode,r,e),Za(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(gu===null||!gu.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=sc(a),cc(a,e,n,r),Za(n,a),!1}n=n.return}while(n!==null);return!1}var uc=Error(i(461)),dc=!1;function fc(e,t,n,r){t.child=e===null?Wa(t,null,n,r):Ua(t,e.child,n,r)}function pc(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return aa(t),r=jo(e,t,n,o,a,i),s=Fo(),e!==null&&!dc?(Io(e,t,i),Ic(e,t,i)):(zi&&s&&Pi(t),t.flags|=1,fc(e,t,r,i),t.child)}function mc(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!pi(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,hc(e,t,a,r,i)):(e=gi(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!Lc(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?kr:n,n(o,r)&&e.ref===t.ref)return Ic(e,t,i)}return t.flags|=1,e=mi(a,r),e.ref=t.ref,e.return=t,t.child=e}function hc(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(kr(a,r)&&e.ref===t.ref){if(dc=!1,t.pendingProps=r=a,Lc(e,i))e.flags&131072&&(dc=!0);else return t.lanes=e.lanes,Ic(e,t,i)}}return Cc(e,t,n,r,i)}function gc(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return vc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Ta(t,a===null?null:a.cachePool),a===null?oo():ao(t,a),po(t);else return r=t.lanes=536870912,vc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&Ta(t,null),oo(),mo(t)):(Ta(t,a.cachePool),ao(t,a),mo(t),t.memoizedState=null);return fc(e,t,i,n),t.child}function _c(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function vc(e,t,n,r,i){var a=wa();return a=a===null?null:{parent:fa._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&Ta(t,null),oo(),po(t),e!==null&&ra(e,t,r,!0),t.childLanes=i,null}function yc(e,t){return t=Mc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function bc(e,t,n){return Ua(t,e.child,null,n),e=yc(t,t.pendingProps),e.flags|=2,ho(t),t.memoizedState=null,e}function xc(e,t,n){var r=t.pendingProps,a=!!(t.flags&128);if(t.flags&=-129,e===null){if(zi){if(r.mode===`hidden`)return e=yc(t,r),t.lanes=536870912,_c(null,e);if(fo(t),(e=Ri)?(e=yf(e,Vi),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ki===null?null:{id:Ai,overflow:ji},retryLane:536870912,hydrationErrors:null},n=yi(e),n.return=t,t.child=n,Li=t,Ri=null)):e=null,e===null)throw Ui(t);return t.lanes=536870912,null}return yc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(fo(t),a){if(t.flags&256)t.flags&=-257,t=bc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558))}else if(dc||ra(e,t,n,!1),a=(n&e.childLanes)!==0,dc||a){if(r=Jl,r!==null&&(s=st(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,si(e,s),Ou(r,e,s),uc;Bu(),t=bc(e,t,n)}else e=o.treeContext,Ri=Cf(s.nextSibling),Li=t,zi=!0,Bi=null,Vi=!1,e!==null&&Ii(t,e),t=yc(t,r),t.flags|=4096;return t}return e=mi(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function Sc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(i(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function Cc(e,t,n,r,i){return aa(t),n=jo(e,t,n,r,void 0,i),r=Fo(),e!==null&&!dc?(Io(e,t,i),Ic(e,t,i)):(zi&&r&&Pi(t),t.flags|=1,fc(e,t,n,i),t.child)}function wc(e,t,n,r,i,a){return aa(t),t.updateQueue=null,n=No(t,r,n,i),Mo(e),r=Fo(),e!==null&&!dc?(Io(e,t,a),Ic(e,t,a)):(zi&&r&&Pi(t),t.flags|=1,fc(e,t,n,a),t.child)}function Tc(e,t,n,r,i){if(aa(t),t.stateNode===null){var a=ui,o=n.contextType;typeof o==`object`&&o&&(a=oa(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Zs,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},Ka(t),o=n.contextType,a.context=typeof o==`object`&&o?oa(o):ui,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Xs(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&Zs.enqueueReplaceState(a,a.state,null),eo(t,r,a,i),$a(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=ec(n,s);a.props=c;var l=a.context,u=n.contextType;o=ui,typeof u==`object`&&u&&(o=oa(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&$s(t,a,r,o),Ga=!1;var f=t.memoizedState;a.state=f,eo(t,r,a,i),$a(),l=t.memoizedState,s||f!==l||Ga?(typeof d==`function`&&(Xs(t,n,d,r),l=t.memoizedState),(c=Ga||Qs(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,qa(e,t),o=t.memoizedProps,u=ec(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=ui,typeof l==`object`&&l&&(c=oa(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&$s(t,a,r,c),Ga=!1,f=t.memoizedState,a.state=f,eo(t,r,a,i),$a();var p=t.memoizedState;o!==d||f!==p||Ga||e!==null&&e.dependencies!==null&&ia(e.dependencies)?(typeof s==`function`&&(Xs(t,n,s,r),p=t.memoizedState),(u=Ga||Qs(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&ia(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,Sc(e,t),r=!!(t.flags&128),a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=Ua(t,e.child,null,i),t.child=Ua(t,null,n,i)):fc(e,t,n,i),t.memoizedState=a.state,e=t.child):e=Ic(e,t,i),e}function Ec(e,t,n,r){return qi(),t.flags|=256,fc(e,t,n,r),t.child}var Dc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Oc(e){return{baseLanes:e,cachePool:Ea()}}function kc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=su),e}function Ac(e,t,n){var r=t.pendingProps,a=!1,o=!!(t.flags&128),s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:!!(go.current&2)),s&&(a=!0,t.flags&=-129),s=!!(t.flags&32),t.flags&=-33,e===null){if(zi){if(a?uo(t):mo(t),(e=Ri)?(e=yf(e,Vi),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ki===null?null:{id:Ai,overflow:ji},retryLane:536870912,hydrationErrors:null},n=yi(e),n.return=t,t.child=n,Li=t,Ri=null)):e=null,e===null)throw Ui(t);return xf(e)?t.lanes=32:t.lanes=536870912,null}var c=r.children;return r=r.fallback,a?(mo(t),a=t.mode,c=Mc({mode:`hidden`,children:c},a),r=_i(r,a,n,null),c.return=t,r.return=t,c.sibling=r,t.child=c,r=t.child,r.memoizedState=Oc(n),r.childLanes=kc(e,s,n),t.memoizedState=Dc,_c(null,r)):(uo(t),jc(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(o)t.flags&256?(uo(t),t.flags&=-257,t=Nc(e,t,n)):t.memoizedState===null?(mo(t),c=r.fallback,a=t.mode,r=Mc({mode:`visible`,children:r.children},a),c=_i(c,a,n,null),c.flags|=2,r.return=t,c.return=t,r.sibling=c,t.child=r,Ua(t,e.child,null,n),r=t.child,r.memoizedState=Oc(n),r.childLanes=kc(e,s,n),t.memoizedState=Dc,t=_c(null,r)):(mo(t),t.child=e.child,t.flags|=128,t=null);else if(uo(t),xf(c)){if(s=c.nextSibling&&c.nextSibling.dataset,s)var u=s.dgst;s=u,r=Error(i(419)),r.stack=``,r.digest=s,Yi({value:r,source:null,stack:null}),t=Nc(e,t,n)}else if(dc||ra(e,t,n,!1),s=(n&e.childLanes)!==0,dc||s){if(s=Jl,s!==null&&(r=st(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,si(e,r),Ou(s,e,r),uc;bf(c)||Bu(),t=Nc(e,t,n)}else bf(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,Ri=Cf(c.nextSibling),Li=t,zi=!0,Bi=null,Vi=!1,e!==null&&Ii(t,e),t=jc(t,r.children),t.flags|=4096);return t}return a?(mo(t),c=r.fallback,a=t.mode,l=e.child,u=l.sibling,r=mi(l,{mode:`hidden`,children:r.children}),r.subtreeFlags=l.subtreeFlags&65011712,u===null?(c=_i(c,a,n,null),c.flags|=2):c=mi(u,c),c.return=t,r.return=t,r.sibling=c,t.child=r,_c(null,r),r=t.child,c=e.child.memoizedState,c===null?c=Oc(n):(a=c.cachePool,a===null?a=Ea():(l=fa._currentValue,a=a.parent===l?a:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:a}),r.memoizedState=c,r.childLanes=kc(e,s,n),t.memoizedState=Dc,_c(e.child,r)):(uo(t),n=e.child,e=n.sibling,n=mi(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function jc(e,t){return t=Mc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function Mc(e,t){return e=fi(22,e,null,t),e.lanes=0,e}function Nc(e,t,n){return Ua(t,e.child,null,n),e=jc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Pc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),ta(e.return,t,n)}function Fc(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function I(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=go.current,s=!!(o&2);if(s?(o=o&1|2,t.flags|=128):o&=1,de(go,o),fc(e,t,r,n),r=zi?Ei:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Pc(e,n,t);else if(e.tag===19)Pc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&_o(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),Fc(t,!1,i,n,a,r);break;case`backwards`:case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&_o(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}Fc(t,!0,n,null,a,r);break;case`together`:Fc(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function Ic(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),iu|=t.lanes,(n&t.childLanes)===0){if(e!==null){if(ra(e,t,n,!1),(n&t.childLanes)===0)return null}else return null}if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,n=mi(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=mi(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Lc(e,t){return(e.lanes&t)!==0||(e=e.dependencies,!!(e!==null&&ia(e)))}function L(e,t,n){switch(t.tag){case 3:ge(t,t.stateNode.containerInfo),$i(t,fa,e.memoizedState.cache),qi();break;case 27:case 5:ve(t);break;case 4:ge(t,t.stateNode.containerInfo);break;case 10:$i(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,fo(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(uo(t),e=Ic(e,t,n),e===null?null:e.sibling):Ac(e,t,n):(uo(t),t.flags|=128,null);uo(t);break;case 19:var i=!!(e.flags&128);if(r=(n&t.childLanes)!==0,r||=(ra(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return I(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),de(go,go.current),r)break;return null;case 22:return t.lanes=0,gc(e,t,n,t.pendingProps);case 24:$i(t,fa,e.memoizedState.cache)}return Ic(e,t,n)}function Rc(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps)dc=!0;else{if(!Lc(e,n)&&!(t.flags&128))return dc=!1,L(e,t,n);dc=!!(e.flags&131072)}}else dc=!1,zi&&t.flags&1048576&&Ni(t,Ei,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=Na(t.elementType),t.type=e,typeof e==`function`)pi(e)?(r=ec(e,r),t.tag=1,t=Tc(null,t,e,r,n)):(t.tag=0,t=Cc(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===w){t.tag=11,t=pc(null,t,e,r,n);break a}if(a===D){t.tag=14,t=mc(null,t,e,r,n);break a}}throw t=ie(e)||e,Error(i(306,t,``))}}return t;case 0:return Cc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=ec(r,t.pendingProps),Tc(e,t,r,a,n);case 3:a:{if(ge(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,qa(e,t),eo(t,r,null,n);var s=t.memoizedState;if(r=s.cache,$i(t,fa,r),r!==o.cache&&na(t,[fa],n,!0),$a(),r=s.element,o.isDehydrated){if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=Ec(e,t,r,n);break a}if(r!==a){a=Si(Error(i(424)),t),Yi(a),t=Ec(e,t,r,n);break a}switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(Ri=Cf(e.firstChild),Li=t,zi=!0,Bi=null,Vi=!0,n=Wa(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(qi(),r===a){t=Ic(e,t,n);break a}fc(e,t,r,n)}t=t.child}return t;case 26:return Sc(e,t),e===null?(n=Wf(t.type,null,t.pendingProps,null))?t.memoizedState=n:zi||(n=t.type,e=t.pendingProps,r=tf(me.current).createElement(n),r[pt]=t,r[mt]=e,Yd(r,n,e),Tt(r),t.stateNode=r):t.memoizedState=Wf(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return ve(t),e===null&&zi&&(r=t.stateNode=Df(t.type,t.pendingProps,me.current),Li=t,Vi=!0,a=Ri,pf(t.type)?(wf=a,Ri=Cf(r.firstChild)):Ri=a),fc(e,t,t.pendingProps.children,n),Sc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&zi&&((a=r=Ri)&&(r=_f(r,t.type,t.pendingProps,Vi),r===null?a=!1:(t.stateNode=r,Li=t,Ri=Cf(r.firstChild),Vi=!1,a=!0)),a||Ui(t)),ve(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,af(a,o)?r=null:s!==null&&af(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=jo(e,t,Po,null,null,n),pp._currentValue=a),Sc(e,t),fc(e,t,r,n),t.child;case 6:return e===null&&zi&&((e=n=Ri)&&(n=vf(n,t.pendingProps,Vi),n===null?e=!1:(t.stateNode=n,Li=t,Ri=null,e=!0)),e||Ui(t)),null;case 13:return Ac(e,t,n);case 4:return ge(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Ua(t,null,r,n):fc(e,t,r,n),t.child;case 11:return pc(e,t,t.type,t.pendingProps,n);case 7:return fc(e,t,t.pendingProps,n),t.child;case 8:return fc(e,t,t.pendingProps.children,n),t.child;case 12:return fc(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,$i(t,t.type,r.value),fc(e,t,r.children,n),t.child;case 9:return a=t.type._context,r=t.pendingProps.children,aa(t),a=oa(a),r=r(a),t.flags|=1,fc(e,t,r,n),t.child;case 14:return mc(e,t,t.type,t.pendingProps,n);case 15:return hc(e,t,t.type,t.pendingProps,n);case 19:return I(e,t,n);case 31:return xc(e,t,n);case 22:return gc(e,t,n,t.pendingProps);case 24:return aa(t),r=oa(fa),e===null?(a=wa(),a===null&&(a=Jl,o=pa(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},Ka(t),$i(t,fa,a)):((e.lanes&n)!==0&&(qa(e,t),eo(t,null,null,n),$a()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,$i(t,fa,r),r!==a.cache&&na(t,[fa],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),$i(t,fa,r))),fc(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function zc(e){e.flags|=4}function Bc(e,t,n,r,i){if((t=!!(e.mode&32))&&(t=!1),t){if(e.flags|=16777216,(i&335544128)===i){if(e.stateNode.complete)e.flags|=8192;else if(Lu())e.flags|=8192;else throw Pa=Aa,Oa}}else e.flags&=-16777217}function Vc(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!ap(t)){if(Lu())e.flags|=8192;else throw Pa=Aa,Oa}}function Hc(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:tt(),e.lanes|=t,cu|=t)}function Uc(e,t){if(!zi)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Wc(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Gc(e,t,n){var r=t.pendingProps;switch(Fi(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Wc(t),null;case 1:return Wc(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),ea(fa),_e(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(Ki(t)?zc(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Ji())),Wc(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(zc(t),o===null?(Wc(t),Bc(t,a,null,r,n)):(Wc(t),Vc(t,o))):o?o===e.memoizedState?(Wc(t),t.flags&=-16777217):(zc(t),Wc(t),Vc(t,o)):(e=e.memoizedProps,e!==r&&zc(t),Wc(t),Bc(t,a,e,r,n)),null;case 27:if(ye(t),n=me.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&zc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Wc(t),null}e=fe.current,Ki(t)?Wi(t,e):(e=Df(a,r,n),t.stateNode=e,zc(t))}return Wc(t),null;case 5:if(ye(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&zc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Wc(t),null}if(o=fe.current,Ki(t))Wi(t,o);else{var s=tf(me.current);switch(o){case 1:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case 2:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;default:switch(a){case`svg`:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case`math`:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;case`script`:o=s.createElement(`div`),o.innerHTML=`<script><\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[pt]=t,o[mt]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(Yd(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&zc(t)}}return Wc(t),Bc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&zc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=me.current,Ki(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=Li,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[pt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||Kd(e.nodeValue,n)),e||Ui(t,!0)}else e=tf(e).createTextNode(r),e[pt]=t,t.stateNode=e}return Wc(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Ki(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[pt]=t}else qi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Wc(t),e=!1}else n=Ji(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(ho(t),t):(ho(t),null);if(t.flags&128)throw Error(i(558))}return Wc(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=Ki(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[pt]=t}else qi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Wc(t),a=!1}else a=Ji(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(ho(t),t):(ho(t),null)}return ho(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Hc(t,t.updateQueue),Wc(t),null);case 4:return _e(),e===null&&Ld(t.stateNode.containerInfo),Wc(t),null;case 10:return ea(t.type),Wc(t),null;case 19:if(ue(go),r=t.memoizedState,r===null)return Wc(t),null;if(a=!!(t.flags&128),o=r.rendering,o===null){if(a)Uc(r,!1);else{if(ru!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=_o(e),o!==null){for(t.flags|=128,Uc(r,!1),e=o.updateQueue,t.updateQueue=e,Hc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)hi(n,e),n=n.sibling;return de(go,go.current&1|2),zi&&Mi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Me()>mu&&(t.flags|=128,a=!0,Uc(r,!1),t.lanes=4194304)}}else{if(!a){if(e=_o(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Hc(t,e),Uc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!zi)return Wc(t),null}else 2*Me()-r.renderingStartTime>mu&&n!==536870912&&(t.flags|=128,a=!0,Uc(r,!1),t.lanes=4194304)}r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}return r.tail===null?(Wc(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Me(),e.sibling=null,n=go.current,de(go,a?n&1|2:n&1),zi&&Mi(t,r.treeForkCount),e);case 22:case 23:return ho(t),so(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(Wc(t),t.subtreeFlags&6&&(t.flags|=8192)):Wc(t),n=t.updateQueue,n!==null&&Hc(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&ue(Ca),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),ea(fa),Wc(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function Kc(e,t){switch(Fi(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ea(fa),_e(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ye(t),null;case 31:if(t.memoizedState!==null){if(ho(t),t.alternate===null)throw Error(i(340));qi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(ho(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));qi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ue(go),null;case 4:return _e(),null;case 10:return ea(t.type),null;case 22:case 23:return ho(t),so(),e!==null&&ue(Ca),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return ea(fa),null;case 25:return null;default:return null}}function qc(e,t){switch(Fi(t),t.tag){case 3:ea(fa),_e();break;case 26:case 27:case 5:ye(t);break;case 4:_e();break;case 31:t.memoizedState!==null&&ho(t);break;case 13:ho(t);break;case 19:ue(go);break;case 10:ea(t.type);break;case 22:case 23:ho(t),so(),e!==null&&ue(Ca);break;case 24:ea(fa)}}function Jc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){id(t,t.return,e)}}function Yc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){id(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){id(t,t.return,e)}}function Xc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{no(t,n)}catch(t){id(e,e.return,t)}}}function Zc(e,t,n){n.props=ec(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){id(e,t,n)}}function Qc(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){id(e,t,n)}}function $c(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){id(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){id(e,t,n)}else n.current=null}}function el(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){id(e,e.return,t)}}function tl(e,t,n){try{var r=e.stateNode;Xd(r,e.type,n,t),r[mt]=t}catch(t){id(e,e.return,t)}}function nl(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&pf(e.type)||e.tag===4}function rl(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||nl(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&&pf(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function il(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=on));else if(r!==4&&(r===27&&pf(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(il(e,t,n),e=e.sibling;e!==null;)il(e,t,n),e=e.sibling}function al(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&pf(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(al(e,t,n),e=e.sibling;e!==null;)al(e,t,n),e=e.sibling}function ol(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Yd(t,r,n),t[pt]=e,t[mt]=n}catch(t){id(e,e.return,t)}}var sl=!1,cl=!1,ll=!1,ul=typeof WeakSet==`function`?WeakSet:Set,dl=null;function fl(e,t){if(e=e.containerInfo,$d=Sp,e=Nr(e),N(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(ef={focusedElem:e,selectionRange:n},Sp=!1,dl=t;dl!==null;)if(t=dl,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,dl=e;else for(;dl!==null;){switch(t=dl,o=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n<e.length;n++)a=e[n],a.ref.impl=a.nextImpl;break;case 11:case 15:break;case 1:if(e&1024&&o!==null){e=void 0,n=t,a=o.memoizedProps,o=o.memoizedState,r=n.stateNode;try{var h=ec(n.type,a);e=r.getSnapshotBeforeUpdate(h,o),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){id(n,n.return,e)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)gf(e);else if(n===1)switch(e.nodeName){case`HEAD`:case`HTML`:case`BODY`:gf(e);break;default:e.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(e&1024)throw Error(i(163))}if(e=t.sibling,e!==null){e.return=t.return,dl=e;break}dl=t.return}}function pl(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:Ol(e,n),r&4&&Jc(5,n);break;case 1:if(Ol(e,n),r&4){if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){id(n,n.return,e)}else{var i=ec(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){id(n,n.return,e)}}}r&64&&Xc(n),r&512&&Qc(n,n.return);break;case 3:if(Ol(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{no(e,t)}catch(e){id(n,n.return,e)}}break;case 27:t===null&&r&4&&ol(n);case 26:case 5:Ol(e,n),t===null&&r&4&&el(n),r&512&&Qc(n,n.return);break;case 12:Ol(e,n);break;case 31:Ol(e,n),r&4&&yl(e,n);break;case 13:Ol(e,n),r&4&&bl(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=cd.bind(null,n),Sf(e,n))));break;case 22:if(r=n.memoizedState!==null||sl,!r){t=t!==null&&t.memoizedState!==null||cl,i=sl;var a=cl;sl=r,(cl=t)&&!a?Al(e,n,!!(n.subtreeFlags&8772)):Ol(e,n),sl=i,cl=a}break;case 30:break;default:Ol(e,n)}}function ml(e){var t=e.alternate;t!==null&&(e.alternate=null,ml(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&bt(t)),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 hl=null,gl=!1;function _l(e,t,n){for(n=n.child;n!==null;)vl(e,t,n),n=n.sibling}function vl(e,t,n){if(He&&typeof He.onCommitFiberUnmount==`function`)try{He.onCommitFiberUnmount(Ve,n)}catch{}switch(n.tag){case 26:cl||$c(n,t),_l(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:cl||$c(n,t);var r=hl,i=gl;pf(n.type)&&(hl=n.stateNode,gl=!1),_l(e,t,n),Of(n.stateNode),hl=r,gl=i;break;case 5:cl||$c(n,t);case 6:if(r=hl,i=gl,hl=null,_l(e,t,n),hl=r,gl=i,hl!==null){if(gl)try{(hl.nodeType===9?hl.body:hl.nodeName===`HTML`?hl.ownerDocument.body:hl).removeChild(n.stateNode)}catch(e){id(n,t,e)}else try{hl.removeChild(n.stateNode)}catch(e){id(n,t,e)}}break;case 18:hl!==null&&(gl?(e=hl,mf(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Jp(e)):mf(hl,n.stateNode));break;case 4:r=hl,i=gl,hl=n.stateNode.containerInfo,gl=!0,_l(e,t,n),hl=r,gl=i;break;case 0:case 11:case 14:case 15:Yc(2,n,t),cl||Yc(4,n,t),_l(e,t,n);break;case 1:cl||($c(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&Zc(n,t,r)),_l(e,t,n);break;case 21:_l(e,t,n);break;case 22:cl=(r=cl)||n.memoizedState!==null,_l(e,t,n),cl=r;break;default:_l(e,t,n)}}function yl(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Jp(e)}catch(e){id(t,t.return,e)}}}function bl(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Jp(e)}catch(e){id(t,t.return,e)}}function xl(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new ul),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new ul),t;default:throw Error(i(435,e.tag))}}function Sl(e,t){var n=xl(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=ld.bind(null,e,t);t.then(r,r)}})}function Cl(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var a=n[r],o=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 27:if(pf(c.type)){hl=c.stateNode,gl=!1;break a}break;case 5:hl=c.stateNode,gl=!1;break a;case 3:case 4:hl=c.stateNode.containerInfo,gl=!0;break a}c=c.return}if(hl===null)throw Error(i(160));vl(o,s,a),hl=null,gl=!1,o=a.alternate,o!==null&&(o.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Tl(t,e),t=t.sibling}var wl=null;function Tl(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Cl(t,e),El(e),r&4&&(Yc(3,e,e.return),Jc(3,e),Yc(5,e,e.return));break;case 1:Cl(t,e),El(e),r&512&&(cl||n===null||$c(n,n.return)),r&64&&sl&&(e=e.updateQueue,e!==null&&(r=e.callbacks,r!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?r:n.concat(r))));break;case 26:var a=wl;if(Cl(t,e),El(e),r&512&&(cl||n===null||$c(n,n.return)),r&4){var o=n===null?null:n.memoizedState;if(r=e.memoizedState,n===null){if(r===null){if(e.stateNode===null){a:{r=e.type,n=e.memoizedProps,a=a.ownerDocument||a;b:switch(r){case`title`:o=a.getElementsByTagName(`title`)[0],(!o||o[yt]||o[pt]||o.namespaceURI===`http://www.w3.org/2000/svg`||o.hasAttribute(`itemprop`))&&(o=a.createElement(r),a.head.insertBefore(o,a.querySelector(`head > title`))),Yd(o,r,n),o[pt]=e,Tt(o),r=o;break a;case`link`:var s=np(`link`,`href`,a).get(r+(n.href||``));if(s){for(var c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&o.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&o.getAttribute(`title`)===(n.title==null?null:n.title)&&o.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(c,1);break b}}o=a.createElement(r),Yd(o,r,n),a.head.appendChild(o);break;case`meta`:if(s=np(`meta`,`content`,a).get(r+(n.content||``))){for(c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`content`)===(n.content==null?null:``+n.content)&&o.getAttribute(`name`)===(n.name==null?null:n.name)&&o.getAttribute(`property`)===(n.property==null?null:n.property)&&o.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&o.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){s.splice(c,1);break b}}o=a.createElement(r),Yd(o,r,n),a.head.appendChild(o);break;default:throw Error(i(468,r))}o[pt]=e,Tt(o),r=o}e.stateNode=r}else rp(a,e.type,e.stateNode)}else e.stateNode=Zf(a,r,e.memoizedProps)}else o===r?r===null&&e.stateNode!==null&&tl(e,e.memoizedProps,n.memoizedProps):(o===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):o.count--,r===null?rp(a,e.type,e.stateNode):Zf(a,r,e.memoizedProps))}break;case 27:Cl(t,e),El(e),r&512&&(cl||n===null||$c(n,n.return)),n!==null&&r&4&&tl(e,e.memoizedProps,n.memoizedProps);break;case 5:if(Cl(t,e),El(e),r&512&&(cl||n===null||$c(n,n.return)),e.flags&32){a=e.stateNode;try{Zt(a,``)}catch(t){id(e,e.return,t)}}r&4&&e.stateNode!=null&&(a=e.memoizedProps,tl(e,a,n===null?a:n.memoizedProps)),r&1024&&(ll=!0);break;case 6:if(Cl(t,e),El(e),r&4){if(e.stateNode===null)throw Error(i(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){id(e,e.return,t)}}break;case 3:if(tp=null,a=wl,wl=jf(t.containerInfo),Cl(t,e),wl=a,El(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Jp(t.containerInfo)}catch(t){id(e,e.return,t)}ll&&(ll=!1,Dl(e));break;case 4:r=wl,wl=jf(e.stateNode.containerInfo),Cl(t,e),El(e),wl=r;break;case 12:Cl(t,e),El(e);break;case 31:Cl(t,e),El(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,Sl(e,r)));break;case 13:Cl(t,e),El(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(fu=Me()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,Sl(e,r)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,u=sl,d=cl;if(sl=u||a,cl=d||l,Cl(t,e),cl=d,sl=u,El(e),r&8192)a:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||sl||cl||kl(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(o=l.stateNode,a)s=o.style,typeof s.setProperty==`function`?s.setProperty(`display`,`none`,`important`):s.display=`none`;else{c=l.stateNode;var f=l.memoizedProps.style,p=f!=null&&f.hasOwnProperty(`display`)?f.display:null;c.style.display=p==null||typeof p==`boolean`?``:(``+p).trim()}}catch(e){id(l,l.return,e)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=a?``:l.memoizedProps}catch(e){id(l,l.return,e)}}}else if(t.tag===18){if(n===null){l=t;try{var m=l.stateNode;a?hf(m,!0):hf(l.stateNode,!1)}catch(e){id(l,l.return,e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break a;for(;t.sibling===null;){if(t.return===null||t.return===e)break a;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=e.updateQueue,r!==null&&(n=r.retryQueue,n!==null&&(r.retryQueue=null,Sl(e,n))));break;case 19:Cl(t,e),El(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,Sl(e,r)));break;case 30:break;case 21:break;default:Cl(t,e),El(e)}}function El(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(nl(r)){n=r;break}r=r.return}if(n==null)throw Error(i(160));switch(n.tag){case 27:var a=n.stateNode;al(e,rl(e),a);break;case 5:var o=n.stateNode;n.flags&32&&(Zt(o,``),n.flags&=-33),al(e,rl(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;il(e,rl(e),s);break;default:throw Error(i(161))}}catch(t){id(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Dl(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Dl(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function Ol(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)pl(e,t.alternate,t),t=t.sibling}function kl(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Yc(4,t,t.return),kl(t);break;case 1:$c(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&Zc(t,t.return,n),kl(t);break;case 27:Of(t.stateNode);case 26:case 5:$c(t,t.return),kl(t);break;case 22:t.memoizedState===null&&kl(t);break;case 30:kl(t);break;default:kl(t)}e=e.sibling}}function Al(e,t,n){for(n&&=!!(t.subtreeFlags&8772),t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags;switch(a.tag){case 0:case 11:case 15:Al(i,a,n),Jc(4,a);break;case 1:if(Al(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){id(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var s=r.stateNode;try{var c=i.shared.hiddenCallbacks;if(c!==null)for(i.shared.hiddenCallbacks=null,i=0;i<c.length;i++)to(c[i],s)}catch(e){id(r,r.return,e)}}n&&o&64&&Xc(a),Qc(a,a.return);break;case 27:ol(a);case 26:case 5:Al(i,a,n),n&&r===null&&o&4&&el(a),Qc(a,a.return);break;case 12:Al(i,a,n);break;case 31:Al(i,a,n),n&&o&4&&yl(i,a);break;case 13:Al(i,a,n),n&&o&4&&bl(i,a);break;case 22:a.memoizedState===null&&Al(i,a,n),Qc(a,a.return);break;case 30:break;default:Al(i,a,n)}t=t.sibling}}function jl(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&ma(n))}function Ml(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&ma(e))}function Nl(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Pl(e,t,n,r),t=t.sibling}function Pl(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:Nl(e,t,n,r),i&2048&&Jc(9,t);break;case 1:Nl(e,t,n,r);break;case 3:Nl(e,t,n,r),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&ma(e)));break;case 12:if(i&2048){Nl(e,t,n,r),e=t.stateNode;try{var a=t.memoizedProps,o=a.id,s=a.onPostCommit;typeof s==`function`&&s(o,t.alternate===null?`mount`:`update`,e.passiveEffectDuration,-0)}catch(e){id(t,t.return,e)}}else Nl(e,t,n,r);break;case 31:Nl(e,t,n,r);break;case 13:Nl(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?Nl(e,t,n,r):(a._visibility|=2,Fl(e,t,n,r,!!(t.subtreeFlags&10256)||!1)):a._visibility&2?Nl(e,t,n,r):Il(e,t),i&2048&&jl(o,t);break;case 24:Nl(e,t,n,r),i&2048&&Ml(t.alternate,t);break;default:Nl(e,t,n,r)}}function Fl(e,t,n,r,i){for(i&&=!!(t.subtreeFlags&10256)||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:Fl(a,o,s,c,i),Jc(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,Fl(a,o,s,c,i)):u._visibility&2?Fl(a,o,s,c,i):Il(a,o),i&&l&2048&&jl(o.alternate,o);break;case 24:Fl(a,o,s,c,i),i&&l&2048&&Ml(o.alternate,o);break;default:Fl(a,o,s,c,i)}t=t.sibling}}function Il(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:Il(n,r),i&2048&&jl(r.alternate,r);break;case 24:Il(n,r),i&2048&&Ml(r.alternate,r);break;default:Il(n,r)}t=t.sibling}}var Ll=8192;function Rl(e,t,n){if(e.subtreeFlags&Ll)for(e=e.child;e!==null;)zl(e,t,n),e=e.sibling}function zl(e,t,n){switch(e.tag){case 26:Rl(e,t,n),e.flags&Ll&&e.memoizedState!==null&&op(n,wl,e.memoizedState,e.memoizedProps);break;case 5:Rl(e,t,n);break;case 3:case 4:var r=wl;wl=jf(e.stateNode.containerInfo),Rl(e,t,n),wl=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Ll,Ll=16777216,Rl(e,t,n),Ll=r):Rl(e,t,n));break;default:Rl(e,t,n)}}function Bl(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Vl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];dl=r,Wl(r,e)}Bl(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Hl(e),e=e.sibling}function Hl(e){switch(e.tag){case 0:case 11:case 15:Vl(e),e.flags&2048&&Yc(9,e,e.return);break;case 3:Vl(e);break;case 12:Vl(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Ul(e)):Vl(e);break;default:Vl(e)}}function Ul(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];dl=r,Wl(r,e)}Bl(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Yc(8,t,t.return),Ul(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Ul(t));break;default:Ul(t)}e=e.sibling}}function Wl(e,t){for(;dl!==null;){var n=dl;switch(n.tag){case 0:case 11:case 15:Yc(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:ma(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,dl=r;else a:for(n=e;dl!==null;){r=dl;var i=r.sibling,a=r.return;if(ml(r),r===n){dl=null;break a}if(i!==null){i.return=a,dl=i;break a}dl=a}}}var Gl={getCacheForType:function(e){var t=oa(fa),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return oa(fa).controller.signal}},Kl=typeof WeakMap==`function`?WeakMap:Map,ql=0,Jl=null,Yl=null,Xl=0,Zl=0,Ql=null,$l=!1,eu=!1,tu=!1,nu=0,ru=0,iu=0,au=0,ou=0,su=0,cu=0,lu=null,uu=null,du=!1,fu=0,pu=0,mu=1/0,hu=null,gu=null,_u=0,vu=null,yu=null,bu=0,xu=0,Su=null,Cu=null,wu=0,Tu=null;function Eu(){return ql&2&&Xl!==0?Xl&-Xl:A.T===null?ut():Td()}function Du(){if(su===0){if(!(Xl&536870912)||zi){var e=Ye;Ye<<=1,!(Ye&3932160)&&(Ye=262144),su=e}else su=536870912}return e=co.current,e!==null&&(e.flags|=32),su}function Ou(e,t,n){(e===Jl&&(Zl===2||Zl===9)||e.cancelPendingCommit!==null)&&(Fu(e,0),Mu(e,Xl,su,!1)),rt(e,n),(!(ql&2)||e!==Jl)&&(e===Jl&&(!(ql&2)&&(au|=n),ru===4&&Mu(e,Xl,su,!1)),_d(e))}function ku(e,t,n){if(ql&6)throw Error(i(327));var r=!n&&!(t&127)&&(t&e.expiredLanes)===0||$e(e,t),a=r?Uu(e,t):Vu(e,t,!0),o=r;do{if(a===0){eu&&!r&&Mu(e,t,0,!1);break}if(n=e.current.alternate,o&&!ju(n)){a=Vu(e,t,!1),o=!1;continue}if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;a=lu;var l=c.current.memoizedState.isDehydrated;if(l&&(Fu(c,s).flags|=256),s=Vu(c,s,!1),s!==2){if(tu&&!l){c.errorRecoveryDisabledLanes|=o,au|=o,a=4;break a}o=uu,uu=a,o!==null&&(uu===null?uu=o:uu.push.apply(uu,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){Fu(e,0),Mu(e,t,0,!0);break}a:{switch(r=e,o=a,o){case 0:case 1:throw Error(i(345));case 4:if((t&4194048)!==t)break;case 6:Mu(r,t,su,!$l);break a;case 2:uu=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=fu+300-Me(),10<a)){if(Mu(r,t,su,!$l),Qe(r,0,!0)!==0)break a;bu=t,r.timeoutHandle=cf(Au.bind(null,r,n,uu,hu,du,t,su,au,cu,$l,o,`Throttled`,-0,0),a);break a}Au(r,n,uu,hu,du,t,su,au,cu,$l,o,null,-0,0)}break}while(1);_d(e)}function Au(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(e.timeoutHandle=-1,d=t.subtreeFlags,d&8192||(d&16785408)==16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:on},zl(t,a,d);var m=(a&62914560)===a?fu-Me():(a&4194048)===a?pu-Me():0;if(m=cp(d,m),m!==null){bu=a,e.cancelPendingCommit=m(Xu.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),Mu(e,a,o,!l);return}}Xu(e,t,a,n,r,i,o,s,c)}function ju(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!Or(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Mu(e,t,n,r){t&=~ou,t&=~au,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-We(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&at(e,n,t)}function Nu(){return ql&6?!0:(vd(0,!1),!1)}function Pu(){if(Yl!==null){if(Zl===0)var e=Yl.return;else e=Yl,Qi=Zi=null,Lo(e),La=null,Ra=0,e=Yl;for(;e!==null;)qc(e.alternate,e),e=e.return;Yl=null}}function Fu(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,lf(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),bu=0,Pu(),Jl=e,Yl=n=mi(e.current,null),Xl=t,Zl=0,Ql=null,$l=!1,eu=$e(e,t),tu=!1,cu=su=ou=au=iu=ru=0,uu=lu=null,du=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-We(r),a=1<<i;t|=e[i],r&=~a}return nu=t,ii(),n}function Iu(e,t){yo=null,A.H=Ks,t===Da||t===ka?(t=Fa(),Zl=3):t===Oa?(t=Fa(),Zl=4):Zl=t===uc?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,Ql=t,Yl===null&&(ru=1,ic(e,Si(t,e.current)))}function Lu(){var e=co.current;return e===null?!0:(Xl&4194048)===Xl?lo===null:(Xl&62914560)===Xl||Xl&536870912?e===lo:!1}function Ru(){var e=A.H;return A.H=Ks,e===null?Ks:e}function zu(){var e=A.A;return A.A=Gl,e}function Bu(){ru=4,$l||(Xl&4194048)!==Xl&&co.current!==null||(eu=!0),!(iu&134217727)&&!(au&134217727)||Jl===null||Mu(Jl,Xl,su,!1)}function Vu(e,t,n){var r=ql;ql|=2;var i=Ru(),a=zu();(Jl!==e||Xl!==t)&&(hu=null,Fu(e,t)),t=!1;var o=ru;a:do try{if(Zl!==0&&Yl!==null){var s=Yl,c=Ql;switch(Zl){case 8:Pu(),o=6;break a;case 3:case 2:case 9:case 6:co.current===null&&(t=!0);var l=Zl;if(Zl=0,Ql=null,qu(e,s,c,l),n&&eu){o=0;break a}break;default:l=Zl,Zl=0,Ql=null,qu(e,s,c,l)}}Hu(),o=ru;break}catch(t){Iu(e,t)}while(1);return t&&e.shellSuspendCounter++,Qi=Zi=null,ql=r,A.H=i,A.A=a,Yl===null&&(Jl=null,Xl=0,ii()),o}function Hu(){for(;Yl!==null;)Gu(Yl)}function Uu(e,t){var n=ql;ql|=2;var r=Ru(),a=zu();Jl!==e||Xl!==t?(hu=null,mu=Me()+500,Fu(e,t)):eu=$e(e,t);a:do try{if(Zl!==0&&Yl!==null){t=Yl;var o=Ql;b:switch(Zl){case 1:Zl=0,Ql=null,qu(e,t,o,1);break;case 2:case 9:if(ja(o)){Zl=0,Ql=null,Ku(t);break}t=function(){Zl!==2&&Zl!==9||Jl!==e||(Zl=7),_d(e)},o.then(t,t);break a;case 3:Zl=7;break a;case 4:Zl=5;break a;case 7:ja(o)?(Zl=0,Ql=null,Ku(t)):(Zl=0,Ql=null,qu(e,t,o,7));break;case 5:var s=null;switch(Yl.tag){case 26:s=Yl.memoizedState;case 5:case 27:var c=Yl;if(s?ap(s):c.stateNode.complete){Zl=0,Ql=null;var l=c.sibling;if(l!==null)Yl=l;else{var u=c.return;u===null?Yl=null:(Yl=u,Ju(u))}break b}}Zl=0,Ql=null,qu(e,t,o,5);break;case 6:Zl=0,Ql=null,qu(e,t,o,6);break;case 8:Pu(),ru=6;break a;default:throw Error(i(462))}}Wu();break}catch(t){Iu(e,t)}while(1);return Qi=Zi=null,A.H=r,A.A=a,ql=n,Yl===null?(Jl=null,Xl=0,ii(),ru):0}function Wu(){for(;Yl!==null&&!Ae();)Gu(Yl)}function Gu(e){var t=Rc(e.alternate,e,nu);e.memoizedProps=e.pendingProps,t===null?Ju(e):Yl=t}function Ku(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=wc(n,t,t.pendingProps,t.type,void 0,Xl);break;case 11:t=wc(n,t,t.pendingProps,t.type.render,t.ref,Xl);break;case 5:Lo(t);default:qc(n,t),t=Yl=hi(t,nu),t=Rc(n,t,nu)}e.memoizedProps=e.pendingProps,t===null?Ju(e):Yl=t}function qu(e,t,n,r){Qi=Zi=null,Lo(t),La=null,Ra=0;var i=t.return;try{if(lc(e,i,t,n,Xl)){ru=1,ic(e,Si(n,e.current)),Yl=null;return}}catch(t){if(i!==null)throw Yl=i,t;ru=1,ic(e,Si(n,e.current)),Yl=null;return}t.flags&32768?(zi||r===1?e=!0:eu||Xl&536870912?e=!1:($l=e=!0,(r===2||r===9||r===3||r===6)&&(r=co.current,r!==null&&r.tag===13&&(r.flags|=16384))),Yu(t,e)):Ju(t)}function Ju(e){var t=e;do{if(t.flags&32768){Yu(t,$l);return}e=t.return;var n=Gc(t.alternate,t,nu);if(n!==null){Yl=n;return}if(t=t.sibling,t!==null){Yl=t;return}Yl=t=e}while(t!==null);ru===0&&(ru=5)}function Yu(e,t){do{var n=Kc(e.alternate,e);if(n!==null){n.flags&=32767,Yl=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Yl=e;return}Yl=e=n}while(e!==null);ru=6,Yl=null}function Xu(e,t,n,r,a,o,s,c,l){e.cancelPendingCommit=null;do td();while(_u!==0);if(ql&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));if(o=t.lanes|t.childLanes,o|=ri,it(e,n,o,s,c,l),e===Jl&&(Yl=Jl=null,Xl=0),yu=t,vu=e,bu=n,xu=o,Su=a,Cu=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,ud(Ie,function(){return nd(),null})):(e.callbackNode=null,e.callbackPriority=0),r=!!(t.flags&13878),t.subtreeFlags&13878||r){r=A.T,A.T=null,a=j.p,j.p=2,s=ql,ql|=4;try{fl(e,t,n)}finally{ql=s,j.p=a,A.T=r}}_u=1,Zu(),Qu(),$u()}}function Zu(){if(_u===1){_u=0;var e=vu,t=yu,n=!!(t.flags&13878);if(t.subtreeFlags&13878||n){n=A.T,A.T=null;var r=j.p;j.p=2;var i=ql;ql|=4;try{Tl(t,e);var a=ef,o=Nr(e.containerInfo),s=a.focusedElem,c=a.selectionRange;if(o!==s&&s&&s.ownerDocument&&Mr(s.ownerDocument.documentElement,s)){if(c!==null&&N(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=jr(s,h),v=jr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}Sp=!!$d,ef=$d=null}finally{ql=i,j.p=r,A.T=n}}e.current=t,_u=2}}function Qu(){if(_u===2){_u=0;var e=vu,t=yu,n=!!(t.flags&8772);if(t.subtreeFlags&8772||n){n=A.T,A.T=null;var r=j.p;j.p=2;var i=ql;ql|=4;try{pl(e,t.alternate,t)}finally{ql=i,j.p=r,A.T=n}}_u=3}}function $u(){if(_u===4||_u===3){_u=0,je();var e=vu,t=yu,n=bu,r=Cu;t.subtreeFlags&10256||t.flags&10256?_u=5:(_u=0,yu=vu=null,ed(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(gu=null),lt(n),t=t.stateNode,He&&typeof He.onCommitFiberRoot==`function`)try{He.onCommitFiberRoot(Ve,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=A.T,i=j.p,j.p=2,A.T=null;try{for(var a=e.onRecoverableError,o=0;o<r.length;o++){var s=r[o];a(s.value,{componentStack:s.stack})}}finally{A.T=t,j.p=i}}bu&3&&td(),_d(e),i=e.pendingLanes,n&261930&&i&42?e===Tu?wu++:(wu=0,Tu=e):wu=0,vd(0,!1)}}function ed(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,ma(t)))}function td(){return Zu(),Qu(),$u(),nd()}function nd(){if(_u!==5)return!1;var e=vu,t=xu;xu=0;var n=lt(bu),r=A.T,a=j.p;try{j.p=32>n?32:n,A.T=null,n=Su,Su=null;var o=vu,s=bu;if(_u=0,yu=vu=null,bu=0,ql&6)throw Error(i(331));var c=ql;if(ql|=4,Hl(o.current),Pl(o,o.current,s,n),ql=c,vd(0,!1),He&&typeof He.onPostCommitFiberRoot==`function`)try{He.onPostCommitFiberRoot(Ve,o)}catch{}return!0}finally{j.p=a,A.T=r,ed(e,t)}}function rd(e,t,n){t=Si(n,t),t=oc(e.stateNode,t,2),e=Ya(e,t,2),e!==null&&(rt(e,2),_d(e))}function id(e,t,n){if(e.tag===3)rd(e,e,n);else for(;t!==null;){if(t.tag===3){rd(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(gu===null||!gu.has(r))){e=Si(n,e),n=sc(2),r=Ya(t,n,2),r!==null&&(cc(n,r,t,e),rt(r,2),_d(r));break}}t=t.return}}function ad(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Kl;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(tu=!0,i.add(n),e=od.bind(null,e,t,n),t.then(e,e))}function od(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Jl===e&&(Xl&n)===n&&(ru===4||ru===3&&(Xl&62914560)===Xl&&300>Me()-fu?!(ql&2)&&Fu(e,0):ou|=n,cu===Xl&&(cu=0)),_d(e)}function sd(e,t){t===0&&(t=tt()),e=si(e,t),e!==null&&(rt(e,t),_d(e))}function cd(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),sd(e,n)}function ld(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),sd(e,n)}function ud(e,t){return Oe(e,t)}var dd=null,fd=null,pd=!1,md=!1,hd=!1,gd=0;function _d(e){e!==fd&&e.next===null&&(fd===null?dd=fd=e:fd=fd.next=e),md=!0,pd||(pd=!0,wd())}function vd(e,t){if(!hd&&md){hd=!0;do for(var n=!1,r=dd;r!==null;){if(!t){if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-We(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,Cd(r,a))}else a=Xl,a=Qe(r,r===Jl?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||$e(r,a)||(n=!0,Cd(r,a))}r=r.next}while(n);hd=!1}}function yd(){bd()}function bd(){md=pd=!1;var e=0;gd!==0&&sf()&&(e=gd);for(var t=Me(),n=null,r=dd;r!==null;){var i=r.next,a=xd(r,t);a===0?(r.next=null,n===null?dd=i:n.next=i,i===null&&(fd=n)):(n=r,(e!==0||a&3)&&(md=!0)),r=i}_u!==0&&_u!==5||vd(e,!1),gd!==0&&(gd=0)}function xd(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-We(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=et(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Jl,n=Xl,n=Qe(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Zl===2||Zl===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&ke(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||$e(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&ke(r),lt(n)){case 2:case 8:n=Fe;break;case 32:n=Ie;break;case 268435456:n=Re;break;default:n=Ie}return r=Sd.bind(null,e),n=Oe(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&ke(r),e.callbackPriority=2,e.callbackNode=null,2}function Sd(e,t){if(_u!==0&&_u!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(td()&&e.callbackNode!==n)return null;var r=Xl;return r=Qe(e,e===Jl?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(ku(e,r,t),xd(e,Me()),e.callbackNode!=null&&e.callbackNode===n?Sd.bind(null,e):null)}function Cd(e,t){if(td())return null;ku(e,t,!0)}function wd(){df(function(){ql&6?Oe(Pe,yd):bd()})}function Td(){if(gd===0){var e=_a;e===0&&(e=Je,Je<<=1,!(Je&261888)&&(Je=256)),gd=e}return gd}function Ed(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:an(``+e)}function Dd(e,t){var n=t.ownerDocument.createElement(`input`);return n.name=t.name,n.value=t.value,e.id&&n.setAttribute(`form`,e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function Od(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=Ed((i[mt]||null).action),o=r.submitter;o&&(t=(t=o[mt]||null)?Ed(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new Dn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(gd!==0){var e=o?Dd(i,o):new FormData(i);Ns(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=o?Dd(i,o):new FormData(i),Ns(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var kd=0;kd<Qr.length;kd++){var Ad=Qr[kd];$r(Ad.toLowerCase(),`on`+(Ad[0].toUpperCase()+Ad.slice(1)))}$r(Wr,`onAnimationEnd`),$r(Gr,`onAnimationIteration`),$r(Kr,`onAnimationStart`),$r(`dblclick`,`onDoubleClick`),$r(`focusin`,`onFocus`),$r(`focusout`,`onBlur`),$r(qr,`onTransitionRun`),$r(Jr,`onTransitionStart`),$r(Yr,`onTransitionCancel`),$r(Xr,`onTransitionEnd`),kt(`onMouseEnter`,[`mouseout`,`mouseover`]),kt(`onMouseLeave`,[`mouseout`,`mouseover`]),kt(`onPointerEnter`,[`pointerout`,`pointerover`]),kt(`onPointerLeave`,[`pointerout`,`pointerover`]),Ot(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),Ot(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),Ot(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),Ot(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),Ot(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),Ot(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var jd=`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(` `),Md=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(jd));function Nd(e,t){t=!!(t&4);for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){ei(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){ei(e)}i.currentTarget=null,a=c}}}}function Pd(e,t){var n=t[gt];n===void 0&&(n=t[gt]=new Set);var r=e+`__bubble`;n.has(r)||(Rd(t,e,2,!1),n.add(r))}function Fd(e,t,n){var r=0;t&&(r|=4),Rd(n,e,r,t)}var Id=`_reactListening`+Math.random().toString(36).slice(2);function Ld(e){if(!e[Id]){e[Id]=!0,Et.forEach(function(t){t!==`selectionchange`&&(Md.has(t)||Fd(t,!1,e),Fd(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Id]||(t[Id]=!0,Fd(`selectionchange`,!1,t))}}function Rd(e,t,n,r){switch(kp(t)){case 2:var i=Cp;break;case 8:i=wp;break;default:i=Tp}n=i.bind(null,t,n,e),i=void 0,!gn||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function zd(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var c=r.stateNode.containerInfo;if(c===i)break;if(s===4)for(s=r.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===i)return;s=s.return}for(;c!==null;){if(s=xt(c),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){r=a=s;continue a}c=c.parentNode}}r=r.return}pn(function(){var r=a,i=cn(n),s=[];a:{var c=Zr.get(e);if(c!==void 0){var l=Dn,u=e;switch(e){case`keypress`:if(Sn(n)===0)break a;case`keydown`:case`keyup`:l=Gn;break;case`focusin`:u=`focus`,l=In;break;case`focusout`:u=`blur`,l=In;break;case`beforeblur`:case`afterblur`:l=In;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=Pn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=Fn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=qn;break;case Wr:case Gr:case Kr:l=Ln;break;case Xr:l=Jn;break;case`scroll`:case`scrollend`:l=kn;break;case`wheel`:l=Yn;break;case`copy`:case`cut`:case`paste`:l=Rn;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=Kn;break;case`toggle`:case`beforetoggle`:l=Xn}var d=!!(t&4),f=!d&&(e===`scroll`||e===`scrollend`),p=d?c===null?null:c+`Capture`:c;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=mn(m,p),g!=null&&d.push(Bd(m,g,h))),f)break;m=m.return}0<d.length&&(c=new l(c,u,null,n,i),s.push({event:c,listeners:d}))}}if(!(t&7)){a:{if(c=e===`mouseover`||e===`pointerover`,l=e===`mouseout`||e===`pointerout`,c&&n!==sn&&(u=n.relatedTarget||n.fromElement)&&(xt(u)||u[ht]))break a;if((l||c)&&(c=i.window===i?i:(c=i.ownerDocument)?c.defaultView||c.parentWindow:window,l?(u=n.relatedTarget||n.toElement,l=r,u=u?xt(u):null,u!==null&&(f=o(u),d=u.tag,u!==f||d!==5&&d!==27&&d!==6)&&(u=null)):(l=null,u=r),l!==u)){if(d=Pn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=Kn,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=l==null?c:Ct(l),h=u==null?c:Ct(u),c=new d(g,m+`leave`,l,n,i),c.target=f,c.relatedTarget=h,g=null,xt(i)===r&&(d=new d(p,m+`enter`,u,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,l&&u)b:{for(d=Hd,p=l,m=u,h=0,g=p;g;g=d(g))h++;g=0;for(var _=m;_;_=d(_))g++;for(;0<h-g;)p=d(p),h--;for(;0<g-h;)m=d(m),g--;for(;h--;){if(p===m||m!==null&&p===m.alternate){d=p;break b}p=d(p),m=d(m)}d=null}else d=null;l!==null&&Ud(s,c,l,d,!1),u!==null&&f!==null&&Ud(s,f,u,d,!0)}}a:{if(c=r?Ct(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var v=gr;else if(ur(c)){if(_r)v=Er;else{v=wr;var y=Cr}}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&tn(r.elementType)&&(v=gr):v=Tr;if(v&&=v(e,r)){dr(s,v,n,i);break a}y&&y(e,c,r),e===`focusout`&&r&&c.type===`number`&&r.memoizedProps.value!=null&&qt(c,`number`,c.value)}switch(y=r?Ct(r):window,e){case`focusin`:(ur(y)||y.contentEditable===`true`)&&(Fr=y,Ir=r,Lr=null);break;case`focusout`:Lr=Ir=Fr=null;break;case`mousedown`:Rr=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:Rr=!1,zr(s,n,i);break;case`selectionchange`:if(Pr)break;case`keydown`:case`keyup`:zr(s,n,i)}var b;if(Qn)b:{switch(e){case`compositionstart`:var x=`onCompositionStart`;break b;case`compositionend`:x=`onCompositionEnd`;break b;case`compositionupdate`:x=`onCompositionUpdate`;break b}x=void 0}else or?ir(e,n)&&(x=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(x=`onCompositionStart`);x&&(tr&&n.locale!==`ko`&&(or||x!==`onCompositionStart`?x===`onCompositionEnd`&&or&&(b=xn()):(vn=i,yn=`value`in vn?vn.value:vn.textContent,or=!0)),y=Vd(r,x),0<y.length&&(x=new zn(x,e,null,n,i),s.push({event:x,listeners:y}),b?x.data=b:(b=ar(n),b!==null&&(x.data=b)))),(b=er?sr(e,n):cr(e,n))&&(x=Vd(r,`onBeforeInput`),0<x.length&&(y=new zn(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:y,listeners:x}),y.data=b)),Od(s,e,r,n,i)}Nd(s,t)})}function Bd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Vd(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=mn(e,n),i!=null&&r.unshift(Bd(e,i,a)),i=mn(e,t),i!=null&&r.push(Bd(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Hd(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Ud(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=mn(n,a),l!=null&&o.unshift(Bd(n,l,c))):i||(l=mn(n,a),l!=null&&o.push(Bd(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Wd=/\r\n?/g,R=/\u0000|\uFFFD/g;function Gd(e){return(typeof e==`string`?e:``+e).replace(Wd,`
|
|
9
|
-
`).replace(R,``)}function Kd(e,t){return t=Gd(t),Gd(e)===t}function qd(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||Zt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&Zt(e,``+r);break;case`className`:Ft(e,`class`,r);break;case`tabIndex`:Ft(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Ft(e,n,r);break;case`style`:en(e,r,o);break;case`data`:if(t!==`object`){Ft(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=an(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`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}if(typeof o==`function`&&(n===`formAction`?(t!==`input`&&qd(e,t,`name`,a.name,a,null),qd(e,t,`formEncType`,a.formEncType,a,null),qd(e,t,`formMethod`,a.formMethod,a,null),qd(e,t,`formTarget`,a.formTarget,a,null)):(qd(e,t,`encType`,a.encType,a,null),qd(e,t,`method`,a.method,a,null),qd(e,t,`target`,a.target,a,null))),r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=an(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=on);break;case`onScroll`:r!=null&&Pd(`scroll`,e);break;case`onScrollEnd`:r!=null&&Pd(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=an(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);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`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:Pd(`beforetoggle`,e),Pd(`toggle`,e),Pt(e,`popover`,r);break;case`xlinkActuate`:It(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:It(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:It(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:It(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:It(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:It(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:It(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:It(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:It(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Pt(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=nn.get(n)||n,Pt(e,n,r))}}function Jd(e,t,n,r,a,o){switch(n){case`style`:en(e,r,o);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?Zt(e,r):(typeof r==`number`||typeof r==`bigint`)&&Zt(e,``+r);break;case`onScroll`:r!=null&&Pd(`scroll`,e);break;case`onScrollEnd`:r!=null&&Pd(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=on);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!Dt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),t=n.slice(2,a?n.length-7:void 0),o=e[mt]||null,o=o==null?null:o[n],typeof o==`function`&&e.removeEventListener(t,o,a),typeof r==`function`)){typeof o!=`function`&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):Pt(e,n,r)}}}function Yd(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:Pd(`error`,e),Pd(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:qd(e,t,o,s,n,null)}}a&&qd(e,t,`srcSet`,n.srcSet,n,null),r&&qd(e,t,`src`,n.src,n,null);return;case`input`:Pd(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:qd(e,t,r,d,n,null)}}Kt(e,o,c,l,u,s,a,!1);return;case`select`:for(a in Pd(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:qd(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&Jt(e,!!r,n,!0):Jt(e,!!r,t,!1);return;case`textarea`:for(s in Pd(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:qd(e,t,s,c,n,null)}Xt(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:qd(e,t,l,r,n,null)}return;case`dialog`:Pd(`beforetoggle`,e),Pd(`toggle`,e),Pd(`cancel`,e),Pd(`close`,e);break;case`iframe`:case`object`:Pd(`load`,e);break;case`video`:case`audio`:for(r=0;r<jd.length;r++)Pd(jd[r],e);break;case`image`:Pd(`error`,e),Pd(`load`,e);break;case`details`:Pd(`toggle`,e);break;case`embed`:case`source`:case`link`:Pd(`error`,e),Pd(`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 n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:qd(e,t,u,r,n,null)}return;default:if(tn(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Jd(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&qd(e,t,c,r,n,null))}function Xd(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||qd(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:o=m;break;case`name`:a=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&qd(e,t,p,m,r,f)}}Gt(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||qd(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:p=o;break;case`defaultValue`:c=o;break;case`multiple`:s=o;default:o!==l&&qd(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?Jt(e,!!n,n?[]:``,!1):Jt(e,!!n,t,!0)):Jt(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:qd(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:p=a;break;case`defaultValue`:m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&qd(e,t,s,a,r,o)}Yt(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:qd(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:qd(e,t,l,p,r,m)}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 g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&qd(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:qd(e,t,u,p,r,m)}return;default:if(tn(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Jd(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Jd(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&qd(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||qd(e,t,f,p,r,m)}function Zd(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function Qd(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&Zd(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&Zd(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var $d=null,ef=null;function tf(e){return e.nodeType===9?e:e.ownerDocument}function nf(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 rf(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function af(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var of=null;function sf(){var e=window.event;return e&&e.type===`popstate`?e!==of&&(of=e,!0):(of=null,!1)}var cf=typeof setTimeout==`function`?setTimeout:void 0,lf=typeof clearTimeout==`function`?clearTimeout:void 0,uf=typeof Promise==`function`?Promise:void 0,df=typeof queueMicrotask==`function`?queueMicrotask:uf===void 0?cf:function(e){return uf.resolve(null).then(e).catch(ff)};function ff(e){setTimeout(function(){throw e})}function pf(e){return e===`head`}function mf(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8){if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Jp(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)Of(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,Of(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[yt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&Of(e.ownerDocument.body)}n=i}while(n);Jp(t)}function hf(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8){if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++}n=r}while(n)}function gf(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:gf(n),bt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function _f(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r){if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e}else if(!e[yt])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=Cf(e.nextSibling),e===null)break}return null}function vf(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=Cf(e.nextSibling),e===null))return null;return e}function yf(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=Cf(e.nextSibling),e===null))return null;return e}function bf(e){return e.data===`$?`||e.data===`$~`}function xf(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function Sf(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function Cf(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var wf=null;function Tf(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return Cf(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function Ef(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function Df(e,t,n){switch(t=tf(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function Of(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);bt(e)}var kf=new Map,Af=new Set;function jf(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Mf=j.d;j.d={f:Nf,r:Pf,D:Lf,C:Rf,L:zf,m:Bf,X:Hf,S:Vf,M:Uf};function Nf(){var e=Mf.f(),t=Nu();return e||t}function Pf(e){var t=St(e);t!==null&&t.tag===5&&t.type===`form`?Fs(t):Mf.r(e)}var Ff=typeof document>`u`?null:document;function If(e,t,n){var r=Ff;if(r&&typeof t==`string`&&t){var i=Wt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),Af.has(i)||(Af.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Yd(t,`link`,e),Tt(t),r.head.appendChild(t)))}}function Lf(e){Mf.D(e),If(`dns-prefetch`,e,null)}function Rf(e,t){Mf.C(e,t),If(`preconnect`,e,t)}function zf(e,t,n){Mf.L(e,t,n);var r=Ff;if(r&&e&&t){var i=`link[rel="preload"][as="`+Wt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Wt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Wt(n.imageSizes)+`"]`)):i+=`[href="`+Wt(e)+`"]`;var a=i;switch(t){case`style`:a=Gf(e);break;case`script`:a=Yf(e)}kf.has(a)||(e=h({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),kf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Kf(a))||t===`script`&&r.querySelector(Xf(a))||(t=r.createElement(`link`),Yd(t,`link`,e),Tt(t),r.head.appendChild(t)))}}function Bf(e,t){Mf.m(e,t);var n=Ff;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Wt(r)+`"][href="`+Wt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Yf(e)}if(!kf.has(a)&&(e=h({rel:`modulepreload`,href:e},t),kf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Xf(a)))return}r=n.createElement(`link`),Yd(r,`link`,e),Tt(r),n.head.appendChild(r)}}}function Vf(e,t,n){Mf.S(e,t,n);var r=Ff;if(r&&e){var i=wt(r).hoistableStyles,a=Gf(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Kf(a)))s.loading=5;else{e=h({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=kf.get(a))&&$f(e,n);var c=o=r.createElement(`link`);Tt(c),Yd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Qf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Hf(e,t){Mf.X(e,t);var n=Ff;if(n&&e){var r=wt(n).hoistableScripts,i=Yf(e),a=r.get(i);a||(a=n.querySelector(Xf(i)),a||(e=h({src:e,async:!0},t),(t=kf.get(i))&&ep(e,t),a=n.createElement(`script`),Tt(a),Yd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Uf(e,t){Mf.M(e,t);var n=Ff;if(n&&e){var r=wt(n).hoistableScripts,i=Yf(e),a=r.get(i);a||(a=n.querySelector(Xf(i)),a||(e=h({src:e,async:!0,type:`module`},t),(t=kf.get(i))&&ep(e,t),a=n.createElement(`script`),Tt(a),Yd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Wf(e,t,n,r){var a=(a=me.current)?jf(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Gf(n.href),n=wt(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Gf(n.href);var o=wt(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Kf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),kf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},kf.set(e,n),o||Jf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Yf(n),n=wt(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Gf(e){return`href="`+Wt(e)+`"`}function Kf(e){return`link[rel="stylesheet"][`+e+`]`}function qf(e){return h({},e,{"data-precedence":e.precedence,precedence:null})}function Jf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Yd(t,`link`,n),Tt(t),e.head.appendChild(t))}function Yf(e){return`[src="`+Wt(e)+`"]`}function Xf(e){return`script[async]`+e}function Zf(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Wt(n.href)+`"]`);if(r)return t.instance=r,Tt(r),r;var a=h({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),Tt(r),Yd(r,`style`,a),Qf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Gf(n.href);var o=e.querySelector(Kf(a));if(o)return t.state.loading|=4,t.instance=o,Tt(o),o;r=qf(n),(a=kf.get(a))&&$f(r,a),o=(e.ownerDocument||e).createElement(`link`),Tt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Yd(o,`link`,r),t.state.loading|=4,Qf(o,n.precedence,e),t.instance=o;case`script`:return o=Yf(n.src),(a=e.querySelector(Xf(o)))?(t.instance=a,Tt(a),a):(r=n,(a=kf.get(o))&&(r=h({},n),ep(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),Tt(a),Yd(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Qf(r,n.precedence,e));return t.instance}function Qf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function $f(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function ep(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var tp=null;function np(e,t,n){if(tp===null){var r=new Map,i=tp=new Map;i.set(n,r)}else i=tp,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[yt]||a[pt]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function rp(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function ip(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function ap(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function op(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Gf(r.href),a=t.querySelector(Kf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=lp.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,Tt(a);return}a=t.ownerDocument||t,r=qf(r),(i=kf.get(i))&&$f(r,i),a=a.createElement(`link`),Tt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Yd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=lp.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var sp=0;function cp(e,t){return e.stylesheets&&e.count===0&&dp(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&dp(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&sp===0&&(sp=62500*Qd());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&dp(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>sp?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function lp(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)dp(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var up=null;function dp(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,up=new Map,t.forEach(fp,e),up=null,lp.call(e))}function fp(e,t){if(!(t.state.loading&4)){var n=up.get(e);if(n)var r=n.get(null);else{n=new Map,up.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=lp.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var pp={$$typeof:C,Provider:null,Consumer:null,_currentValue:oe,_currentValue2:oe,_threadCount:0};function mp(e,t,n,r,i,a,o,s,c){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=nt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=nt(0),this.hiddenUpdates=nt(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function hp(e,t,n,r,i,a,o,s,c,l,u,d){return e=new mp(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=fi(3,null,null,t),e.current=a,a.stateNode=e,t=pa(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},Ka(a),e}function gp(e){return e?(e=ui,e):ui}function _p(e,t,n,r,i,a){i=gp(i),r.context===null?r.context=i:r.pendingContext=i,r=Ja(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=Ya(e,r,t),n!==null&&(Ou(n,e,t),Xa(n,e,t))}function vp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function yp(e,t){vp(e,t),(e=e.alternate)&&vp(e,t)}function bp(e){if(e.tag===13||e.tag===31){var t=si(e,67108864);t!==null&&Ou(t,e,67108864),yp(e,67108864)}}function xp(e){if(e.tag===13||e.tag===31){var t=Eu();t=ct(t);var n=si(e,t);n!==null&&Ou(n,e,t),yp(e,t)}}var Sp=!0;function Cp(e,t,n,r){var i=A.T;A.T=null;var a=j.p;try{j.p=2,Tp(e,t,n,r)}finally{j.p=a,A.T=i}}function wp(e,t,n,r){var i=A.T;A.T=null;var a=j.p;try{j.p=8,Tp(e,t,n,r)}finally{j.p=a,A.T=i}}function Tp(e,t,n,r){if(Sp){var i=Ep(r);if(i===null)zd(e,t,r,Dp,n),Rp(e,r);else if(Bp(i,e,t,n,r))r.stopPropagation();else if(Rp(e,r),t&4&&-1<Lp.indexOf(e)){for(;i!==null;){var a=St(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=Ze(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-We(o);s.entanglements[1]|=c,o&=~c}_d(a),!(ql&6)&&(mu=Me()+500,vd(0,!1))}}break;case 31:case 13:s=si(a,2),s!==null&&Ou(s,a,2),Nu(),yp(a,2)}if(a=Ep(r),a===null&&zd(e,t,r,Dp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else zd(e,t,r,null,n)}}function Ep(e){return e=cn(e),Op(e)}var Dp=null;function Op(e){if(Dp=null,e=xt(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Dp=e,null}function kp(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(Ne()){case Pe:return 2;case Fe:return 8;case Ie:case Le:return 32;case Re:return 268435456;default:return 32}default:return 32}}var Ap=!1,jp=null,Mp=null,Np=null,Pp=new Map,Fp=new Map,Ip=[],Lp=`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 Rp(e,t){switch(e){case`focusin`:case`focusout`:jp=null;break;case`dragenter`:case`dragleave`:Mp=null;break;case`mouseover`:case`mouseout`:Np=null;break;case`pointerover`:case`pointerout`:Pp.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:Fp.delete(t.pointerId)}}function zp(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=St(t),t!==null&&bp(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Bp(e,t,n,r,i){switch(t){case`focusin`:return jp=zp(jp,e,t,n,r,i),!0;case`dragenter`:return Mp=zp(Mp,e,t,n,r,i),!0;case`mouseover`:return Np=zp(Np,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return Pp.set(a,zp(Pp.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,Fp.set(a,zp(Fp.get(a)||null,e,t,n,r,i)),!0}return!1}function Vp(e){var t=xt(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,dt(e.priority,function(){xp(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,dt(e.priority,function(){xp(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Hp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Ep(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);sn=r,n.target.dispatchEvent(r),sn=null}else return t=St(n),t!==null&&bp(t),e.blockedOn=n,!1;t.shift()}return!0}function Up(e,t,n){Hp(e)&&n.delete(t)}function Wp(){Ap=!1,jp!==null&&Hp(jp)&&(jp=null),Mp!==null&&Hp(Mp)&&(Mp=null),Np!==null&&Hp(Np)&&(Np=null),Pp.forEach(Up),Fp.forEach(Up)}function Gp(e,n){e.blockedOn===n&&(e.blockedOn=null,Ap||(Ap=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Wp)))}var Kp=null;function qp(e){Kp!==e&&(Kp=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Kp===e&&(Kp=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(Op(r||n)===null)continue;break}var a=St(n);a!==null&&(e.splice(t,3),t-=3,Ns(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Jp(e){function t(t){return Gp(t,e)}jp!==null&&Gp(jp,e),Mp!==null&&Gp(Mp,e),Np!==null&&Gp(Np,e),Pp.forEach(t),Fp.forEach(t);for(var n=0;n<Ip.length;n++){var r=Ip[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Ip.length&&(n=Ip[0],n.blockedOn===null);)Vp(n),n.blockedOn===null&&Ip.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[mt]||null;if(typeof a==`function`)o||qp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[mt]||null)s=o.formAction;else if(Op(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),qp(n)}}}function Yp(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Xp(e){this._internalRoot=e}Zp.prototype.render=Xp.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;_p(n,Eu(),e,t,null,null)},Zp.prototype.unmount=Xp.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;_p(e.current,2,null,e,null,null),Nu(),t[ht]=null}};function Zp(e){this._internalRoot=e}Zp.prototype.unstable_scheduleHydration=function(e){if(e){var t=ut();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Ip.length&&t!==0&&t<Ip[n].priority;n++);Ip.splice(n,0,e),n===0&&Vp(e)}};var Qp=n.version;if(Qp!==`19.2.8`)throw Error(i(527,Qp,`19.2.8`));j.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=d(t),e=e===null?null:p(e),e=e===null?null:e.stateNode,e};var $p={bundleType:0,version:`19.2.8`,rendererPackageName:`react-dom`,currentDispatcherRef:A,reconcilerVersion:`19.2.8`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var em=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!em.isDisabled&&em.supportsFiber)try{Ve=em.inject($p),He=em}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=tc,s=nc,c=rc;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=hp(e,1,!1,null,null,n,r,null,o,s,c,Yp),e[ht]=t.current,Ld(e),new Xp(t)}})),g=o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=h()})),_=c(u(),1),v=g(),y=!1;function b(){return y}function x(e){if(typeof window>`u`||window.navigator==null)return!1;let t=window.navigator.userAgentData?.brands;return Array.isArray(t)&&t.some(t=>e.test(t.brand))||e.test(window.navigator.userAgent)}function S(e){return typeof window<`u`&&window.navigator!=null&&e.test(window.navigator.userAgentData?.platform||window.navigator.platform)}function C(e){let t=null;return()=>(t??=e(),t)}var w=C(function(){return S(/^Mac/i)}),T=C(function(){return S(/^iPhone/i)}),E=C(function(){return S(/^iPad/i)||w()&&navigator.maxTouchPoints>1}),D=C(function(){return T()||E()}),O=C(function(){return x(/AppleWebKit/i)&&(D()||!ee())}),ee=C(function(){return x(/Chrome|CriOS|CrMo/i)}),te=C(function(){return x(/Android/i)}),ne=C(function(){return x(/(Firefox|FxiOS)/i)});function k(e){if(ie())e.focus({preventScroll:!0});else{let t=ae(e);e.focus(),A(t)}}var re=null;function ie(){if(re==null){re=!1;try{document.createElement(`div`).focus({get preventScroll(){return re=!0,!0}})}catch{}}return re}function ae(e){let t=e.parentNode,n=[],r=document.scrollingElement||document.documentElement;for(;t instanceof HTMLElement&&t!==r;)(t.offsetHeight<t.scrollHeight||t.offsetWidth<t.scrollWidth)&&n.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}),t=t.parentNode;return r instanceof HTMLElement&&n.push({element:r,scrollTop:r.scrollTop,scrollLeft:r.scrollLeft}),n}function A(e){for(let{element:t,scrollTop:n,scrollLeft:r}of e)t.scrollTop=n,t.scrollLeft=r}function j(e,t,n=!0){let{metaKey:r,ctrlKey:i,altKey:a,shiftKey:o}=t;!O()&&ne()&&window.event?.type?.startsWith(`key`)&&e.target===`_blank`&&(w()?r=!0:i=!0);let s=O()&&w()&&!E()?new KeyboardEvent(`keydown`,{keyIdentifier:`Enter`,metaKey:r,ctrlKey:i,altKey:a,shiftKey:o}):new MouseEvent(`click`,{metaKey:r,ctrlKey:i,altKey:a,shiftKey:o,detail:1,bubbles:!0,cancelable:!0});j.isOpening=n,k(e),e.dispatchEvent(s),j.isOpening=!1}j.isOpening=!1;var oe=typeof document<`u`?_.useLayoutEffect:()=>{},se={prefix:String(Math.round(Math.random()*1e10)),current:0},ce=_.createContext(se),le=_.createContext(!1);typeof window<`u`&&window.document&&window.document.createElement;var ue=new WeakMap;function de(e=!1){let t=(0,_.useContext)(ce),n=(0,_.useRef)(null);if(n.current===null&&!e){let e=_.default.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED?.ReactCurrentOwner?.current;if(e){let n=ue.get(e);n==null?ue.set(e,{id:t.current,state:e.memoizedState}):e.memoizedState!==n.state&&(t.current=n.id,ue.delete(e))}n.current=++t.current}return n.current}function fe(e){let t=(0,_.useContext)(ce),n=de(!!e),r=`react-aria${t.prefix}`;return e||`${r}-${n}`}function pe(e){let t=_.useId(),[n]=(0,_.useState)(ve()),r=n?`react-aria`:`react-aria${se.prefix}`;return e||`${r}-${t}`}var me=typeof _.useId==`function`?pe:fe;function he(){return!1}function ge(){return!0}function _e(e){return()=>{}}function ve(){return typeof _.useSyncExternalStore==`function`?_.useSyncExternalStore(_e,he,ge):(0,_.useContext)(le)}var ye=!!(typeof window<`u`&&window.document&&window.document.createElement),be=new Map,xe;typeof FinalizationRegistry<`u`&&(xe=new FinalizationRegistry(e=>{be.delete(e)}));var Se=new WeakMap;function Ce(e){let[t,n]=(0,_.useState)(e),r=(0,_.useRef)(null),i=me(t),a=(0,_.useRef)(null),o=Se.get(a);if(xe&&o!==i&&(o!=null&&xe.unregister(a),xe.register(a,i,a),Se.set(a,i)),ye){let e=be.get(i);e&&!e.includes(r)?e.push(r):be.set(i,[r])}return oe(()=>{let e=i;return()=>{xe&&(xe.unregister(a),Se.delete(a)),be.delete(e)}},[i]),(0,_.useEffect)(()=>{let e=r.current;return e&&n(e),()=>{e&&(r.current=null)}}),i}function we(e,t){if(e===t)return e;let n=be.get(e);if(n)return n.forEach(e=>e.current=t),t;let r=be.get(t);return r?(r.forEach(t=>t.current=e),e):t}function Te(...e){return(...t)=>{for(let n of e)typeof n==`function`&&n(...t)}}var Ee=e=>ke(e)?e.document:Ae(e)?e:e?.ownerDocument??(typeof document<`u`?document:void 0),De=e=>Ee(e)?.defaultView??(typeof window<`u`?window:void 0);function Oe(e){return typeof e==`object`&&!!e&&`nodeType`in e&&typeof e.nodeType==`number`}function ke(e){return typeof e==`object`&&!!e&&`window`in e&&e.window===e}function Ae(e){return Oe(e)&&e.nodeType===9}function je(e){return Oe(e)&&e.nodeType===11&&`host`in e}function Me(e,t){if(!b())return t&&e?e.contains(t):!1;if(!e||!t)return!1;let n=t;for(;n!==null;){if(n===e)return!0;n=typeof n.assignedElements!=`function`&&n.assignedSlot?.parentNode?n.assignedSlot.parentNode:je(n)?n.host:n.parentNode}return!1}var Ne=(e=document)=>{if(!b())return e.activeElement;let t=e.activeElement;for(;t&&`shadowRoot`in t&&t.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t};function Pe(e){if(b()&&e.target instanceof Element&&e.target.shadowRoot){if(`composedPath`in e)return e.composedPath()[0]??null;if(`composedPath`in e.nativeEvent)return e.nativeEvent.composedPath()[0]??null}return e.target}function Fe(...e){return e.length===1&&e[0]?e[0]:t=>{let n=!1,r=e.map(e=>{let r=Ie(e,t);return n||=typeof r==`function`,r});if(n)return()=>{r.forEach((t,n)=>{typeof t==`function`?t():Ie(e[n],null)})}}}function Ie(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}var Le=c(m(),1);function Re(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Re(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function ze(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Re(e))&&(r&&(r+=` `),r+=t);return r}function Be(...e){let t={...e[0]};for(let n=1;n<e.length;n++){let r=e[n];for(let e in r){let n=t[e],i=r[e];typeof n==`function`&&typeof i==`function`&&e[0]===`o`&&e[1]===`n`&&e.charCodeAt(2)>=65&&e.charCodeAt(2)<=90?t[e]=Te(n,i):(e===`className`||e===`UNSAFE_className`)&&typeof n==`string`&&typeof i==`string`?t[e]=ze(n,i):e===`id`&&n&&i?t.id=we(n,i):e===`ref`&&n&&i?t.ref=Fe(n,i):t[e]=i===void 0?n:i}}return t}var Ve=new Set([`id`]),He=new Set([`aria-label`,`aria-labelledby`,`aria-describedby`,`aria-details`]),Ue=new Set([`href`,`hrefLang`,`target`,`rel`,`download`,`ping`,`referrerPolicy`]),We=new Set([`dir`,`lang`,`hidden`,`inert`,`translate`]),Ge=new Set(`onClick.onAuxClick.onContextMenu.onDoubleClick.onMouseDown.onMouseEnter.onMouseLeave.onMouseMove.onMouseOut.onMouseOver.onMouseUp.onTouchCancel.onTouchEnd.onTouchMove.onTouchStart.onPointerDown.onPointerMove.onPointerUp.onPointerCancel.onPointerEnter.onPointerLeave.onPointerOver.onPointerOut.onGotPointerCapture.onLostPointerCapture.onScroll.onWheel.onAnimationStart.onAnimationEnd.onAnimationIteration.onTransitionCancel.onTransitionEnd.onTransitionRun.onTransitionStart`.split(`.`)),Ke=/^(data-.*)$/;function qe(e,t={}){let{labelable:n,isLink:r,global:i,events:a=i,propNames:o}=t,s={};for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&(Ve.has(t)||n&&He.has(t)||r&&Ue.has(t)||i&&We.has(t)||a&&(Ge.has(t)||t.endsWith(`Capture`)&&Ge.has(t.slice(0,-7)))||o?.has(t)||Ke.test(t))&&(s[t]=e[t]);return s}var Je=new Map,Ye=new Set;function Xe(){if(typeof window>`u`)return;function e(e){return`propertyName`in e}let t=t=>{let r=Pe(t);if(!e(t)||!r)return;let i=Je.get(r);i||(i=new Set,Je.set(r,i),r.addEventListener(`transitioncancel`,n,{once:!0})),i.add(t.propertyName)},n=t=>{let r=Pe(t);if(!e(t)||!r)return;let i=Je.get(r);if(i&&(i.delete(t.propertyName),i.size===0&&(r.removeEventListener(`transitioncancel`,n),Je.delete(r)),Je.size===0)){for(let e of Ye)e();Ye.clear()}};document.body.addEventListener(`transitionrun`,t),document.body.addEventListener(`transitionend`,n)}typeof document<`u`&&(document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,Xe):Xe());function Ze(){for(let[e]of Je)`isConnected`in e&&!e.isConnected&&Je.delete(e)}function Qe(e){requestAnimationFrame(()=>{Ze(),Je.size===0?e():Ye.add(e)})}function $e(){let e=(0,_.useRef)(new Map),t=(0,_.useCallback)((t,n,r,i)=>{let a=i?.once?(...t)=>{e.current.delete(r),r(...t)}:r;e.current.set(r,{type:n,eventTarget:t,fn:a,options:i}),t.addEventListener(n,a,i)},[]),n=(0,_.useCallback)((t,n,r,i)=>{let a=e.current.get(r)?.fn||r;t.removeEventListener(n,a,i),e.current.delete(r)},[]),r=(0,_.useCallback)(()=>{e.current.forEach((e,t)=>{n(e.eventTarget,e.type,t,e.options)})},[n]);return(0,_.useEffect)(()=>r,[r]),{addGlobalListener:t,removeGlobalListener:n,removeAllGlobalListeners:r}}function et(e){let t=(0,_.useRef)(null),n=(0,_.useRef)(void 0),r=(0,_.useCallback)(t=>{if(typeof e==`function`){let n=e,r=n(t);return()=>{typeof r==`function`?r():n(null)}}if(e)return e.current=t,()=>{e.current=null}},[e]);return(0,_.useMemo)(()=>({get current(){return t.current},set current(e){t.current=e,n.current&&=(n.current(),void 0),e!=null&&(n.current=r(e))}}),[r])}var tt=_.useInsertionEffect??oe;function nt(e){let t=(0,_.useRef)(null);return tt(()=>{t.current=e},[e]),(0,_.useCallback)((...e)=>{let n=t.current;return n?.(...e)},[])}function rt(e,t){oe(()=>{if(e&&e.ref&&t)return e.ref.current=t.current,()=>{e.ref&&(e.ref.current=null)}})}function it(e){return e.pointerType===``&&e.isTrusted?!0:te()&&e.pointerType?e.type===`click`&&e.buttons===1:e.detail===0&&!e.pointerType}function at(e){return!te()&&e.width===0&&e.height===0||te()&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType===`mouse`}var ot=typeof Element<`u`&&`checkVisibility`in Element.prototype;function st(e){let t=De(e);if(!(e instanceof t.HTMLElement)&&!(e instanceof t.SVGElement))return!1;let{display:n,visibility:r}=e.style,i=n!==`none`&&r!==`hidden`&&r!==`collapse`;if(i){let{getComputedStyle:t}=De(e),{display:n,visibility:r}=t(e);i=n!==`none`&&r!==`hidden`&&r!==`collapse`}return i}function ct(e,t){return!e.hasAttribute(`hidden`)&&!e.hasAttribute(`data-react-aria-prevent-focus`)&&(e.nodeName===`DETAILS`&&t&&t.nodeName!==`SUMMARY`?e.hasAttribute(`open`):!0)}function lt(e,t){return ot?e.checkVisibility({visibilityProperty:!0})&&!e.closest(`[data-react-aria-prevent-focus]`):e.nodeName!==`#comment`&&st(e)&&ct(e,t)&&(!e.parentElement||lt(e.parentElement,e))}var ut=[`input:not([disabled]):not([type=hidden])`,`select:not([disabled])`,`textarea:not([disabled])`,`button:not([disabled])`,`a[href]`,`area[href]`,`summary`,`iframe`,`object`,`embed`,`audio[controls]`,`video[controls]`,`[contenteditable]:not([contenteditable^="false"])`,`permission`],dt=ut.join(`:not([hidden]),`)+`,[tabindex]:not([disabled]):not([hidden])`;ut.push(`[tabindex]:not([tabindex="-1"]):not([disabled])`),ut.join(`:not([hidden]):not([tabindex="-1"]),`);function ft(e,t){return e.matches(dt)&&!pt(e)&&(t?.skipVisibilityCheck||lt(e))}function pt(e){let t=e;for(;t!=null;){if(t instanceof De(t).HTMLElement&&t.inert)return!0;t=t.parentElement}return!1}function mt(e){return e?.defaultView?.__webpack_nonce__||globalThis.__webpack_nonce__||void 0}var ht=new WeakMap;function gt(e){let t=e??(typeof document<`u`?document:void 0);if(!t)return mt(t);if(ht.has(t))return ht.get(t);let n=t.querySelector(`meta[property="csp-nonce"]`),r=n&&n instanceof De(n).HTMLMetaElement&&(n.nonce||n.content)||mt(t)||void 0;return r!==void 0&&ht.set(t,r),r}var _t=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),M=o(((e,t)=>{t.exports=_t()}))();function vt(e,t){let{ref:n,render:r,...i}=t,a=(0,_.useRef)(null),o=(0,_.useMemo)(()=>Fe(n,a),[n,a]);oe(()=>{},[e,r]);let s={...i,ref:o};return r?r(s,void 0):(0,M.jsx)(e,{...s})}var yt={},bt=new Proxy({},{get(e,t){if(typeof t!=`string`)return;let n=yt[t];return n||(n=vt.bind(null,t),yt[t]=n),n}}),xt=Array.isArray,St=e=>{if(!e&&e!==0&&e!==0n)return``;if(typeof e==`string`)return e;if(typeof e==`number`)return e===e?``+e:``;if(typeof e==`bigint`)return``+e;let t=``;if(xt(e)){let n=e.length;for(let r=0;r<n;r++){let n=e[r];if(!n&&n!==0&&n!==0n)continue;let i=typeof n==`string`?n:St(n);i&&(t&&(t+=` `),t+=i)}return t}if(typeof e==`object`)for(let n in e)e[n]&&(t&&(t+=` `),t+=n);return t},Ct=/\s+/g,wt=Array.isArray,Tt=e=>typeof e!=`string`||!e?e:e.replace(Ct,` `).trim(),Et=e=>{let t=e.length;if(t===0)return!1;let n=e.charCodeAt(0),r=e.charCodeAt(t-1);if(n===32||r===32||n>=9&&n<=13||n===160||r>=9&&r<=13||r===160)return!0;for(let n=0;n<t;n++){let r=e.charCodeAt(n);if(r>=9&&r<=13||r===160||r===32&&n+1<t&&e.charCodeAt(n+1)===32)return!0}return!1},Dt=(...e)=>{let t=St(e);if(t)return Et(t)?Tt(t):t},Ot=e=>e===!1?`false`:e===!0?`true`:e===0?`0`:e,kt=e=>{if(!e||typeof e!=`object`)return!0;for(let t in e)return!1;return!0},At=(e,t)=>{if(e===t)return!0;if(!e||!t)return!1;let n=e,r=t,i=Object.keys(n),a=Object.keys(r);if(i.length!==a.length)return!1;for(let e=0;e<i.length;e++){let t=i[e];if(!a.includes(t)||n[t]!==r[t])return!1}return!0},jt=(e,t)=>{let n=e;for(let e in t)if(Object.hasOwn(t,e)){let r=t[e];n[e]=e in n?Dt(n[e],r):r}return e},Mt=(e,t)=>{for(let n=0;n<e.length;n++){let r=e[n];wt(r)?Mt(r,t):r&&t.push(r)}},Nt=(...e)=>{let t=[];Mt(e,t);let n=[];for(let e=0;e<t.length;e++)t[e]&&n.push(t[e]);return n},Pt=(e,t)=>{let n=e,r=t,i={};for(let e in n){let t=n[e];if(e in r){let n=r[e];i[e]=wt(t)||wt(n)?Nt(n,t):typeof t==`object`&&typeof n==`object`&&t&&n?Pt(t,n):n+` `+t}else i[e]=t}for(let e in r)e in n||(i[e]=r[e]);return i},Ft={twMerge:!0,twMergeConfig:{}},It=256,Lt=128,Rt=Symbol(`tv-cache-miss`),zt=e=>e?.class!=null&&e.class!==``||e?.className!=null&&e.className!==``,Bt=e=>{if(e===void 0)return``;if(e===null)return`null`;if(typeof e==`string`)return e;if(typeof e==`boolean`)return e?`true`:`false`;if(typeof e==`number`)return e===0?`0`:String(e);if(typeof e==`bigint`)return String(e);let t=Ot(e),n=typeof t;if(n===`string`||n===`number`||n===`boolean`||n===`bigint`)return String(t);if(n===`object`)try{return JSON.stringify(t)}catch{return null}return null},Vt=(e,t)=>{if(t===void 0)return e;if(t===null)return e+`null`;let n=typeof t;if(n===`string`||n===`number`||n===`boolean`||n===`bigint`)return e+String(t);if(Array.isArray(t))return e+t.join(`\0`);try{return e+JSON.stringify(t)}catch{return e+`?`}},Ht=(e,t,n,r)=>{let i=``,a=Object.create(null);for(let r=0;r<e.length;r++){let o=e[r];a[o]=1;let s=t[o];n&&n[o]!==void 0&&(s=n[o]);let c=Bt(s);if(c===null)return null;i+=o+`:`+c+`;`}let o=[];for(let e in t)e===`class`||e===`className`||a[e]||(a[e]=1,o.push(e));if(n)for(let e in n)e===`class`||e===`className`||a[e]||n[e]===void 0||(a[e]=1,o.push(e));o.length>1&&o.sort();for(let e=0;e<o.length;e++){let r=o[e],a=t[r];n&&n[r]!==void 0&&(a=n[r]);let s=Bt(a);if(s===null)return null;i+=r+`:`+s+`;`}return i},Ut=(e,t)=>{let n=``;for(let t=0;t<e.length;t++){let{conditionKeys:r,source:i}=e[t];for(let e=0;e<r.length;e++){let t=r[e];n+=t+`=`,n=Vt(n,i[t]),n+=`,`}n+=`c=`,n=Vt(n,i.class),n+=`|cn=`,n=Vt(n,i.className),n+=`;`}for(let e=0;e<t.length;e++){let{conditionKeys:r,source:i}=t[e];for(let e=0;e<r.length;e++){let t=r[e];n+=t+`=`,n=Vt(n,i[t]),n+=`,`}Array.isArray(i.slots)&&(n+=`slots=`+i.slots.join(`,`)+`,`),n+=`c=`,n=Vt(n,i.class),n+=`|cn=`,n=Vt(n,i.className),n+=`;`}return n},Wt=(e=It)=>{let t=new Map,n=null;return{get(e){if(t.has(e))return t.get(e);if(n?.has(e)){let r=n.get(e);return t.set(e,r),r}return Rt},set(r,i){t.size>=e&&(n=t,t=new Map),t.set(r,i)}}},Gt=(e=It)=>{let t=Wt(e);return{get(e){return t.get(e)},set(e,n){t.set(e,n)}}},Kt=(e=Lt)=>{let t=new Map,n=null,r=0;return{get(e,i){let a=t.get(e);if(a){let e=a.get(i);if(e!==void 0||a.has(i))return e}if(n){let a=n.get(e);if(a){let n=a.get(i);if(n!==void 0||a.has(i)){let a=t.get(e);return a||(a=new Map,t.set(e,a)),a.has(i)||r++,a.set(i,n),n}}}return Rt},set(i,a,o){r>=e&&(n=t,t=new Map,r=0);let s=t.get(i);s||(s=new Map,t.set(i,s)),s.has(a)||r++,s.set(a,o)}}},qt=(e,t)=>{let n=null;return(r,i)=>{if(!zt(i))return r;let a=i.class,o=i.className;if(a!=null&&a!==``&&typeof a!=`string`||o!=null&&o!==``&&typeof o!=`string`)return e(t,r,a,o);n??=Kt();let s=r??``,c=(typeof a==`string`?a:``)+`\0`+(typeof o==`string`?o:``),l=n.get(s,c);if(l!==Rt)return l;let u=e(t,r,a,o);return n.set(s,c,u),u}};function Jt(){let e=null,t={},n=!1;return{get cachedTwMerge(){return e},set cachedTwMerge(t){e=t},get cachedTwMergeConfig(){return t},set cachedTwMergeConfig(e){t=e},get didTwMergeConfigChange(){return n},set didTwMergeConfigChange(e){n=e},reset(){e=null,t={},n=!1}}}var Yt=Jt(),Xt=e=>{!kt(e.twMergeConfig)&&!At(e.twMergeConfig,Yt.cachedTwMergeConfig)&&(Yt.didTwMergeConfigChange=!0,Yt.cachedTwMergeConfig=e.twMergeConfig)},Zt=(e,t)=>{let n=[];for(let r=0;r<t.length;r++){let i=t[r],a=e[i];n.push({key:i,values:a,isEmpty:kt(a)})}return n},Qt=e=>{if(!Array.isArray(e)||e.length===0)return[];let t=[];for(let n=0;n<e.length;n++){let r=e[n],i=[];for(let e in r)e!==`class`&&e!==`className`&&i.push(e);t.push({conditionKeys:i,source:r})}return t},$t=e=>{if(!Array.isArray(e)||e.length===0)return[];let t=[];for(let n=0;n<e.length;n++){let r=e[n],i=[];for(let e in r)e!==`slots`&&e!==`class`&&e!==`className`&&i.push(e);t.push({conditionKeys:i,source:r})}return t},en=e=>{let t={};for(let n=0;n<e.length;n++){let r=e[n],i=r.source.slots;if(Array.isArray(i))for(let e=0;e<i.length;e++){let n=i[e];t[n]||(t[n]=[]),t[n].push(r)}}return t},tn=(e,t)=>{let{extend:n=null,slots:r={},variants:i={},compoundVariants:a=[],compoundSlots:o=[],defaultVariants:s={}}=e,c={...Ft,...t},l=e.slots!==void 0,u=n?.base?Dt(n.base,e?.base):e?.base,d=n?.variants&&!kt(n.variants)?Pt(i,n.variants):i,f=n?.defaultVariants&&!kt(n.defaultVariants)?{...n.defaultVariants,...s}:s;Xt(c);let p=!n?.slots||kt(n.slots),m=l?p&&n?.base?Dt(e?.base,n.base):typeof e?.base==`string`||e?.base==null?e.base:Dt(e.base):void 0,h=l?{base:m,...r}:{},g=p?h:jt({...n?.slots},kt(h)?{base:e?.base}:h),_=!n?.compoundVariants||kt(n.compoundVariants)?a:Nt(n?.compoundVariants,a),v=!n?.compoundSlots||kt(n.compoundSlots)?o:Nt(n?.compoundSlots,o),y=Object.keys(d);return{config:c,extend:n,base:u,variants:d,defaultVariants:f,slots:g,compoundVariants:_,compoundSlots:v,compiledVariants:null,compiledCompoundVariants:null,compiledCompoundSlots:null,compiledCompoundSlotsBySlot:null,deferredError:_&&!Array.isArray(_)?TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof _}`):v&&!Array.isArray(v)?TypeError(`The "compoundSlots" prop must be an array. Received: ${typeof v}`):null,mode:l||!p?`slots`:y.length===0?`plain`:`variants`,slotKeys:null,variantKeys:y}},nn=e=>e.compiledVariants===null?(e.compiledVariants=Zt(e.variants,e.variantKeys),e.compiledCompoundVariants=Qt(e.compoundVariants),e.compiledCompoundSlots=$t(e.compoundSlots),e.compiledCompoundSlotsBySlot=en(e.compiledCompoundSlots),e.slotKeys=e.slots&&typeof e.slots==`object`?Object.keys(e.slots):[],e):e,rn=[],an=[],on=[],sn=[],cn=[],ln=(e,t,n)=>{let r={};for(let t in e)r[t]=e[t];if(t)for(let e in t)t[e]!==void 0&&(r[e]=t[e]);if(n)for(let e in n)n[e]!==void 0&&(r[e]=n[e]);return r},un=e=>e==null||e===!1,dn=(e,t)=>{if(!Array.isArray(e))return e===t||un(e)&&un(t);for(let n=0;n<e.length;n++){let r=e[n];if(r===t||un(r)&&un(t))return!0}return!1},fn=(e,t,n,r)=>{if(e.isEmpty)return null;let i=r?.[e.key]??n?.[e.key];if(i===null)return null;let a=Ot(i);if(typeof a==`object`)return null;let o=t?.[e.key],s=a??Ot(o);return e.values[s||`false`]},pn=(e,t)=>{let{conditionKeys:n,source:r}=e;for(let e=0;e<n.length;e++){let i=n[e];if(!dn(r[i],t[i]))return!1}return!0},mn=(e,t,n)=>{typeof n==`string`?t===`base`&&e.push(n):n&&typeof n==`object`&&n[t]&&e.push(n[t])},hn=(e,t,n)=>{let r=an;r.length=0;for(let i=0;i<e.length;i++){let a=fn(e[i],t,n);a&&r.push(a)}return r},gn=(e,t,n,r,i)=>{let a=an;a.length=0;for(let o=0;o<t.length;o++){let s=fn(t[o],n,r,i),c=e===`base`&&typeof s==`string`?s:s&&s[e];c&&a.push(c)}return a},_n=(e,t)=>{let n=on;n.length=0;for(let r=0;r<e.length;r++){let i=e[r];pn(i,t)&&(i.source.class&&n.push(i.source.class),i.source.className&&n.push(i.source.className))}return n},vn=(e,t,n)=>{let r=sn;r.length=0;for(let i=0;i<t.length;i++){let a=t[i];pn(a,n)&&(mn(r,e,a.source.class),mn(r,e,a.source.className))}return r},yn=(e,t)=>{let n=cn;n.length=0;for(let r=0;r<e.length;r++){let i=e[r];pn(i,t)&&(i.source.class&&n.push(i.source.class),i.source.className&&n.push(i.source.className))}return n},bn=(e,t)=>{let{base:n,config:r}=e,i=Rt,a=qt(t,r);return(e=>(i===Rt&&(i=t(r,n)),a(i,e)))},xn=(e,t)=>{let{base:n,config:r,defaultVariants:i,deferredError:a,variantKeys:o}=e,s=e.compiledCompoundVariants,c=e.compiledVariants,l=rn,u=null,d=qt(t,r),f=1,p=e=>{let a=s.length>0?_n(s,ln(i,e)):void 0;return t(r,n,hn(c,i,e),a)};return(t=>{if(a)throw a;(c===null||s===null)&&(nn(e),c=e.compiledVariants,s=e.compiledCompoundVariants,l=e.compiledCompoundSlots??rn);let n;if(f>0)f--,n=p(t);else{u??=Gt();let e=Ht(o,i,t);if(e!==null){let r=s.length>0||l.length>0?Ut(s,l):``,i=e+`#`+r,a=u.get(i);a===Rt?(n=p(t),u.set(i,n)):n=a}else n=p(t)}return d(n,t)})},Sn=(e,t)=>{let{config:n,defaultVariants:r,deferredError:i,slots:a,variantKeys:o}=e,s=null,c=null,l=null,u=null,d=!1,f=null,p=null,m=1,h=()=>{if(l!==null)return;(e.compiledVariants===null||e.compiledCompoundVariants===null||e.compiledCompoundSlots===null||e.compiledCompoundSlotsBySlot===null||e.slotKeys===null)&&nn(e);let i=e.compiledVariants;s=e.compiledCompoundVariants,c=e.compiledCompoundSlots;let o=e.compiledCompoundSlotsBySlot;l=e.slotKeys,d=s.length>0||c.length>0,f=qt(t,n);let p=Array(l.length);for(let e=0;e<l.length;e++){let c=l[e],u=o[c]??rn;p[e]=(e,o)=>{let l=d?ln(r,e,o):void 0,f=l?vn(c,s,l):void 0,p=l?yn(u,l):void 0;return t(n,a[c],gn(c,i,r,e,o),f,p)}}u=p},g=e=>{let t=l,n=u,r=f,i={};for(let a=0;a<t.length;a++){let o=n[a],s=o(e);i[t[a]]=t=>{if(t==null)return s;let n=!1;for(let e in t)if(e!==`class`&&e!==`className`&&t[e]!==void 0){n=!0;break}return r(n?o(e,t):s,t)}}return i};return(e=>{if(i)throw i;if(h(),m>0)return m--,g(e);let t=Ht(o,r,e);if(t===null)return g(e);let n=d?Ut(s,c):``,a=t+`#`+n;p??=Wt();let l=p.get(a);if(l!==Rt)return l;let u=g(e);return p.set(a,u),u})},Cn=(e,t)=>{if(e.mode===`plain`)return bn(e,t);let n;return(r=>(n??=e.mode===`slots`?Sn(e,t):xn(e,t),n(r)))},wn=(e,t)=>{e.variantKeys=t.variantKeys,e.extend=t.extend,e.base=t.base,e.slots=t.slots,e.variants=t.variants,e.defaultVariants=t.defaultVariants,e.compoundSlots=t.compoundSlots,e.compoundVariants=t.compoundVariants},Tn=e=>{let t=(t,n)=>{let r=tn(t,n),i=Cn(r,e);return wn(i,r),i};return{tv:t,createTV:e=>(n,r)=>t(n,r?Pt(e,r):e)}},En=(e,t)=>{let n=e.length,r=t.length,i=Array(n+r);for(let t=0;t<n;t++)i[t]=e[t];for(let e=0;e<r;e++)i[n+e]=t[e];return i},Dn=(e,t)=>({classGroupId:e,validator:t}),On=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),kn=`-`,An=[],jn=`arbitrary..`,Mn=e=>{let t=Fn(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e[0]===`[`&&e[e.length-1]===`]`)return Pn(e);let n=e.split(kn);return Nn(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?En(i,t):t:i||An}return n[e]||An}}},Nn=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=Nn(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(kn):e.slice(t).join(kn),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},Pn=e=>{let t=e.slice(1,-1),n=t.indexOf(`:`);if(n===-1)return;let r=t.slice(0,n);return r?jn+r:void 0},Fn=e=>{let{theme:t,classGroups:n}=e;return In(n,t)},In=(e,t)=>{let n=On();for(let r in e){let i=e[r];Ln(i,n,r,t)}return n},Ln=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];Rn(i,t,n,r)}},Rn=(e,t,n,r)=>{if(typeof e==`string`){zn(e,t,n);return}if(typeof e==`function`){Bn(e,t,n,r);return}Vn(e,t,n,r)},zn=(e,t,n)=>{let r=e===``?t:Hn(t,e);r.classGroupId=n},Bn=(e,t,n,r)=>{if(Un(e)){Ln(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(Dn(n,e))},Vn=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];Ln(o,Hn(t,a),n,r)}},Hn=(e,t)=>{let n=e,r=t.split(kn),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=On(),n.nextPart.set(t,i)),n=i}return n},Un=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,Wn=`!`,Gn=58,Kn=47,qn=91,Jn=93,Yn=40,Xn=41,Zn=33,Qn=(e,t,n,r)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:void 0}),$n=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e.charCodeAt(s);if(n===0&&r===0){if(o===Gn){t.push(e.slice(i,s)),i=s+1;continue}if(o===Kn){a=s;continue}}o===qn?n++:o===Jn?n--:o===Yn?r++:o===Xn&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1,u=s.length-1;s.charCodeAt(u)===Zn?(c=s.slice(0,-1),l=!0):s.charCodeAt(0)===Zn&&(c=s.slice(1),l=!0);let d=a&&a>i?a-i:void 0;return Qn(t,l,c,d)},er=e=>{let t=new Set(e.orderSensitiveModifiers);return e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);if(o||s){if(r.length>0){r.sort();for(let e=0;e<r.length;e++)n.push(r[e]);r=[]}n.push(a)}else r.push(a)}if(r.length>0){r.sort();for(let e=0;e<r.length;e++)n.push(r[e])}return n}},tr={isExternal:!0,classId:-1,conflictIds:[]},nr=4096,rr=16384,ir=e=>{let t=er(e),n=ar(e),{getClassGroupId:r,getConflictingClassGroupIds:i}=Mn(e),a=Object.create(null),o=Object.create(null),s=0,c=new Int32Array(256),l=0,u=new Uint8Array(64),d=!1,f=e=>{let t=[],n=e.length,r=-1;d=!1;for(let i=0;i<n;i++){let n=e.charCodeAt(i);n===32?r!==-1&&(t.push(e.slice(r,i)),r=-1):n>=9&&n<=13?(d=!0,r!==-1&&(t.push(e.slice(r,i)),r=-1)):r===-1&&(r=i)}return r!==-1&&t.push(e.slice(r)),t},p=new Map,m=0,h=e=>{let t=p.get(e);if(t===void 0&&(t=m++,p.set(e,t),t>=c.length)){let e=new Int32Array(c.length*2);e.set(c),c=e}return t},g=e=>{let{isExternal:a,modifiers:o,hasImportantModifier:s,baseClassName:c,maybePostfixModifierPosition:l}=$n(e);if(a)return tr;let u=!!l,d;if(u){let e=c.substring(0,l);d=r(e);let t=d&&n[d]?r(c):void 0;t&&t!==d&&(d=t,u=!1)}else d=r(c);if(!d){if(!u||(d=r(c),!d))return tr;u=!1}let f=o.length===0?``:o.length===1?o[0]:t(o).join(`:`),p=s?f+Wn:f,m=i(d,u),g=[];for(let e=0;e<m.length;e++)g.push(h(p+m[e]));return{isExternal:!1,classId:h(p+d),conflictIds:g}},_=e=>{let t=a[e];return t===void 0?(t=o[e],t===void 0&&(t=g(e)),a[e]=t,++s>nr&&(s=0,o=a,a=Object.create(null)),t):t};return{parseClassName:$n,sortModifiers:t,postfixLookupClassGroupIds:n,getClassGroupId:r,getConflictingClassGroupIds:i,getClassDescriptor:_,mergeClassList:e=>{let t=f(e),n=t.length;if(n===1)return t[0];m>rr&&(p.clear(),m=0,a=Object.create(null),o=Object.create(null),s=0),l=l+1|0,l===0&&(l=1);let r=l;if(n>u.length){let e=u.length;for(;e<n;)e*=2;u=new Uint8Array(e)}let i=!1,h=0;for(let e=n-1;e>=0;--e){let n=t[e];h+=n.length;let a=_(n);if(a.isExternal){u[e]=1;continue}let o=a.classId;if(c[o]===r){u[e]=0,i=!0;continue}c[o]=r;let s=a.conflictIds;for(let e=0;e<s.length;e++)c[s[e]]=r;u[e]=1}if(!i&&!d&&e.length===h+n-1)return e;let g=``;for(let e=0;e<n;e++)u[e]===1&&(g&&(g+=` `),g+=t[e]);return g}}},ar=e=>{let t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let e=0;e<n.length;e++)t[n[e]]=!0;return t},or=500,sr=e=>{let t,n,r=Object.create(null),i=Object.create(null),a=0,o=r=>(t=ir(e()),n=t.mergeClassList,c.mergeString=s,s(r)),s=e=>{let t=r[e];return t===void 0?(t=i[e],t===void 0&&(t=n(e)),r[e]=t,++a>or&&(a=0,i=r,r=Object.create(null)),t):t},c=(...e)=>c.mergeString(St(e));return c.mergeString=o,c},cr=[],lr=e=>{let t=t=>t[e]||cr;return t.isThemeGetter=!0,t},ur=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,dr=/^\((?:(\w[\w-]*):)?(.+)\)$/i,fr=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,pr=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,mr=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,hr=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,gr=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,_r=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,vr=Number,yr=Number.isNaN,br=Number.isInteger,xr=e=>fr.test(e),Sr=e=>!!e&&!yr(vr(e)),Cr=e=>!!e&&br(vr(e)),wr=e=>e.endsWith(`%`)&&Sr(e.slice(0,-1)),Tr=e=>pr.test(e),Er=()=>!0,Dr=e=>mr.test(e)&&!hr.test(e),Or=()=>!1,kr=e=>gr.test(e),Ar=e=>_r.test(e),jr=e=>!N(e)&&!P(e),Mr=e=>e.startsWith(`@container`)&&(e[10]===`/`&&e[11]!==void 0||e[11]===`s`&&e[16]!==void 0&&e.startsWith(`-size/`,10)||e[11]===`n`&&e[18]!==void 0&&e.startsWith(`-normal/`,10)),Nr=e=>Jr(e,Qr,Or),N=e=>ur.test(e),Pr=e=>Jr(e,$r,Dr),Fr=e=>Jr(e,ei,Sr),Ir=e=>Jr(e,ni,Er),Lr=e=>Jr(e,ti,Or),Rr=e=>Jr(e,Xr,Or),zr=e=>Jr(e,Zr,Ar),Br=e=>Jr(e,ri,kr),P=e=>dr.test(e),Vr=e=>Yr(e,$r),Hr=e=>Yr(e,ti),Ur=e=>Yr(e,Xr),Wr=e=>Yr(e,Qr),Gr=e=>Yr(e,Zr),Kr=e=>Yr(e,ri,!0),qr=e=>Yr(e,ni,!0),Jr=(e,t,n)=>{let r=ur.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Yr=(e,t,n=!1)=>{let r=dr.exec(e);return r?r[1]?t(r[1]):n:!1},Xr=e=>e===`position`||e===`percentage`,Zr=e=>e===`image`||e===`url`,Qr=e=>e===`length`||e===`size`||e===`bg-size`,$r=e=>e===`length`,ei=e=>e===`number`,ti=e=>e===`family-name`,ni=e=>e===`number`||e===`weight`,ri=e=>e===`shadow`,ii=()=>{let e=lr(`color`),t=lr(`font`),n=lr(`text`),r=lr(`font-weight`),i=lr(`tracking`),a=lr(`leading`),o=lr(`breakpoint`),s=lr(`container`),c=lr(`spacing`),l=lr(`radius`),u=lr(`shadow`),d=lr(`inset-shadow`),f=lr(`text-shadow`),p=lr(`drop-shadow`),m=lr(`blur`),h=lr(`perspective`),g=lr(`aspect`),_=lr(`ease`),v=lr(`animate`),y=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],b=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],x=()=>[...b(),P,N],S=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],C=()=>[`auto`,`contain`,`none`],w=()=>[P,N,c],T=()=>[xr,`full`,`auto`,...w()],E=()=>[Cr,`none`,`subgrid`,P,N],D=()=>[`auto`,{span:[`full`,Cr,P,N]},Cr,P,N],O=()=>[Cr,`auto`,P,N],ee=()=>[`auto`,`min`,`max`,`fr`,P,N],te=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],ne=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],k=()=>[`auto`,...w()],re=()=>[xr,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],ie=()=>[xr,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...w()],ae=()=>[xr,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...w()],A=()=>[e,P,N],j=()=>[...b(),Ur,Rr,{position:[P,N]}],oe=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],se=()=>[`auto`,`cover`,`contain`,Wr,Nr,{size:[P,N]}],ce=()=>[wr,Vr,Pr],le=()=>[``,`none`,`full`,l,P,N],ue=()=>[``,Sr,Vr,Pr],de=()=>[`solid`,`dashed`,`dotted`,`double`],fe=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],pe=()=>[Sr,wr,Ur,Rr],me=()=>[``,`none`,m,P,N],he=()=>[`none`,Sr,P,N],ge=()=>[`none`,Sr,P,N],_e=()=>[Sr,P,N],ve=()=>[xr,`full`,...w()];return{theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[Tr],breakpoint:[Tr],color:[Er],container:[Tr],"drop-shadow":[Tr],ease:[`in`,`out`,`in-out`],font:[jr],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[Tr],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[Tr],shadow:[Tr],spacing:[`px`,Sr],text:[Tr],"text-shadow":[Tr],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,xr,N,P,g]}],container:[`container`],"container-type":[{"@container":[``,`normal`,`size`,P,N]}],"container-named":[Mr],columns:[{columns:[Sr,N,P,s]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],sr:[`sr-only`,`not-sr-only`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:x()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{"inset-s":T(),start:T()}],end:[{"inset-e":T(),end:T()}],"inset-bs":[{"inset-bs":T()}],"inset-be":[{"inset-be":T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[Cr,`auto`,P,N]}],basis:[{basis:[xr,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[Sr,xr,`auto`,`initial`,`none`,N]}],grow:[{grow:[``,Sr,P,N]}],shrink:[{shrink:[``,Sr,P,N]}],order:[{order:[Cr,`first`,`last`,`none`,P,N]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:D()}],"row-start":[{"row-start":O()}],"row-end":[{"row-end":O()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":ee()}],"auto-rows":[{"auto-rows":ee()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...te(),`normal`]}],"justify-items":[{"justify-items":[...ne(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...ne()]}],"align-content":[{content:[`normal`,...te()]}],"align-items":[{items:[...ne(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...ne(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":te()}],"place-items":[{"place-items":[...ne(),`baseline`]}],"place-self":[{"place-self":[`auto`,...ne()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pbs:[{pbs:w()}],pbe:[{pbe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:k()}],mx:[{mx:k()}],my:[{my:k()}],ms:[{ms:k()}],me:[{me:k()}],mbs:[{mbs:k()}],mbe:[{mbe:k()}],mt:[{mt:k()}],mr:[{mr:k()}],mb:[{mb:k()}],ml:[{ml:k()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:re()}],"inline-size":[{inline:[`auto`,...ie()]}],"min-inline-size":[{"min-inline":[`auto`,...ie()]}],"max-inline-size":[{"max-inline":[`none`,...ie()]}],"block-size":[{block:[`auto`,...ae()]}],"min-block-size":[{"min-block":[`auto`,...ae()]}],"max-block-size":[{"max-block":[`none`,...ae()]}],w:[{w:[s,`screen`,...re()]}],"min-w":[{"min-w":[s,`screen`,`none`,...re()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...re()]}],h:[{h:[`screen`,`lh`,...re()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...re()]}],"max-h":[{"max-h":[`screen`,`lh`,...re()]}],"font-size":[{text:[`base`,n,Vr,Pr]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,qr,Ir]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,wr,N]}],"font-family":[{font:[Hr,Lr,t]}],"font-features":[{"font-features":[N]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[i,P,N]}],"line-clamp":[{"line-clamp":[Sr,`none`,P,Fr]}],leading:[{leading:[a,...w()]}],"list-image":[{"list-image":[`none`,P,N]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,P,N]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:A()}],"text-color":[{text:A()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...de(),`wavy`]}],"text-decoration-thickness":[{decoration:[Sr,`from-font`,`auto`,P,Pr]}],"text-decoration-color":[{decoration:A()}],"underline-offset":[{"underline-offset":[Sr,`auto`,P,N]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:w()}],"tab-size":[{tab:[Cr,P,N]}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,P,N]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,P,N]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:j()}],"bg-repeat":[{bg:oe()}],"bg-size":[{bg:se()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},Cr,P,N],radial:[``,P,N],conic:[Cr,P,N]},Gr,zr]}],"bg-color":[{bg:A()}],"gradient-from-pos":[{from:ce()}],"gradient-via-pos":[{via:ce()}],"gradient-to-pos":[{to:ce()}],"gradient-from":[{from:A()}],"gradient-via":[{via:A()}],"gradient-to":[{to:A()}],rounded:[{rounded:le()}],"rounded-s":[{"rounded-s":le()}],"rounded-e":[{"rounded-e":le()}],"rounded-t":[{"rounded-t":le()}],"rounded-r":[{"rounded-r":le()}],"rounded-b":[{"rounded-b":le()}],"rounded-l":[{"rounded-l":le()}],"rounded-ss":[{"rounded-ss":le()}],"rounded-se":[{"rounded-se":le()}],"rounded-ee":[{"rounded-ee":le()}],"rounded-es":[{"rounded-es":le()}],"rounded-tl":[{"rounded-tl":le()}],"rounded-tr":[{"rounded-tr":le()}],"rounded-br":[{"rounded-br":le()}],"rounded-bl":[{"rounded-bl":le()}],"border-w":[{border:ue()}],"border-w-x":[{"border-x":ue()}],"border-w-y":[{"border-y":ue()}],"border-w-s":[{"border-s":ue()}],"border-w-e":[{"border-e":ue()}],"border-w-bs":[{"border-bs":ue()}],"border-w-be":[{"border-be":ue()}],"border-w-t":[{"border-t":ue()}],"border-w-r":[{"border-r":ue()}],"border-w-b":[{"border-b":ue()}],"border-w-l":[{"border-l":ue()}],"divide-x":[{"divide-x":ue()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":ue()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...de(),`hidden`,`none`]}],"divide-style":[{divide:[...de(),`hidden`,`none`]}],"border-color":[{border:A()}],"border-color-x":[{"border-x":A()}],"border-color-y":[{"border-y":A()}],"border-color-s":[{"border-s":A()}],"border-color-e":[{"border-e":A()}],"border-color-bs":[{"border-bs":A()}],"border-color-be":[{"border-be":A()}],"border-color-t":[{"border-t":A()}],"border-color-r":[{"border-r":A()}],"border-color-b":[{"border-b":A()}],"border-color-l":[{"border-l":A()}],"divide-color":[{divide:A()}],"outline-style":[{outline:[...de(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[Sr,P,N]}],"outline-w":[{outline:[``,Sr,Vr,Pr]}],"outline-color":[{outline:A()}],shadow:[{shadow:[``,`none`,u,Kr,Br]}],"shadow-color":[{shadow:A()}],"inset-shadow":[{"inset-shadow":[`none`,d,Kr,Br]}],"inset-shadow-color":[{"inset-shadow":A()}],"ring-w":[{ring:ue()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:A()}],"ring-offset-w":[{"ring-offset":[Sr,Pr]}],"ring-offset-color":[{"ring-offset":A()}],"inset-ring-w":[{"inset-ring":ue()}],"inset-ring-color":[{"inset-ring":A()}],"text-shadow":[{"text-shadow":[`none`,f,Kr,Br]}],"text-shadow-color":[{"text-shadow":A()}],opacity:[{opacity:[Sr,P,N]}],"mix-blend":[{"mix-blend":[...fe(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":fe()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[Sr]}],"mask-image-linear-from-pos":[{"mask-linear-from":pe()}],"mask-image-linear-to-pos":[{"mask-linear-to":pe()}],"mask-image-linear-from-color":[{"mask-linear-from":A()}],"mask-image-linear-to-color":[{"mask-linear-to":A()}],"mask-image-t-from-pos":[{"mask-t-from":pe()}],"mask-image-t-to-pos":[{"mask-t-to":pe()}],"mask-image-t-from-color":[{"mask-t-from":A()}],"mask-image-t-to-color":[{"mask-t-to":A()}],"mask-image-r-from-pos":[{"mask-r-from":pe()}],"mask-image-r-to-pos":[{"mask-r-to":pe()}],"mask-image-r-from-color":[{"mask-r-from":A()}],"mask-image-r-to-color":[{"mask-r-to":A()}],"mask-image-b-from-pos":[{"mask-b-from":pe()}],"mask-image-b-to-pos":[{"mask-b-to":pe()}],"mask-image-b-from-color":[{"mask-b-from":A()}],"mask-image-b-to-color":[{"mask-b-to":A()}],"mask-image-l-from-pos":[{"mask-l-from":pe()}],"mask-image-l-to-pos":[{"mask-l-to":pe()}],"mask-image-l-from-color":[{"mask-l-from":A()}],"mask-image-l-to-color":[{"mask-l-to":A()}],"mask-image-x-from-pos":[{"mask-x-from":pe()}],"mask-image-x-to-pos":[{"mask-x-to":pe()}],"mask-image-x-from-color":[{"mask-x-from":A()}],"mask-image-x-to-color":[{"mask-x-to":A()}],"mask-image-y-from-pos":[{"mask-y-from":pe()}],"mask-image-y-to-pos":[{"mask-y-to":pe()}],"mask-image-y-from-color":[{"mask-y-from":A()}],"mask-image-y-to-color":[{"mask-y-to":A()}],"mask-image-radial":[{"mask-radial":[P,N]}],"mask-image-radial-from-pos":[{"mask-radial-from":pe()}],"mask-image-radial-to-pos":[{"mask-radial-to":pe()}],"mask-image-radial-from-color":[{"mask-radial-from":A()}],"mask-image-radial-to-color":[{"mask-radial-to":A()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[Sr]}],"mask-image-conic-from-pos":[{"mask-conic-from":pe()}],"mask-image-conic-to-pos":[{"mask-conic-to":pe()}],"mask-image-conic-from-color":[{"mask-conic-from":A()}],"mask-image-conic-to-color":[{"mask-conic-to":A()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:j()}],"mask-repeat":[{mask:oe()}],"mask-size":[{mask:se()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,P,N]}],filter:[{filter:[``,`none`,P,N]}],blur:[{blur:me()}],brightness:[{brightness:[Sr,P,N]}],contrast:[{contrast:[Sr,P,N]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,Kr,Br]}],"drop-shadow-color":[{"drop-shadow":A()}],grayscale:[{grayscale:[``,Sr,P,N]}],"hue-rotate":[{"hue-rotate":[Sr,P,N]}],invert:[{invert:[``,Sr,P,N]}],saturate:[{saturate:[Sr,P,N]}],sepia:[{sepia:[``,Sr,P,N]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,P,N]}],"backdrop-blur":[{"backdrop-blur":me()}],"backdrop-brightness":[{"backdrop-brightness":[Sr,P,N]}],"backdrop-contrast":[{"backdrop-contrast":[Sr,P,N]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,Sr,P,N]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Sr,P,N]}],"backdrop-invert":[{"backdrop-invert":[``,Sr,P,N]}],"backdrop-opacity":[{"backdrop-opacity":[Sr,P,N]}],"backdrop-saturate":[{"backdrop-saturate":[Sr,P,N]}],"backdrop-sepia":[{"backdrop-sepia":[``,Sr,P,N]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,P,N]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[Sr,`initial`,P,N]}],ease:[{ease:[`linear`,`initial`,_,P,N]}],delay:[{delay:[Sr,P,N]}],animate:[{animate:[`none`,v,P,N]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,P,N]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:he()}],"rotate-x":[{"rotate-x":he()}],"rotate-y":[{"rotate-y":he()}],"rotate-z":[{"rotate-z":he()}],scale:[{scale:ge()}],"scale-x":[{"scale-x":ge()}],"scale-y":[{"scale-y":ge()}],"scale-z":[{"scale-z":ge()}],"scale-3d":[`scale-3d`],skew:[{skew:_e()}],"skew-x":[{"skew-x":_e()}],"skew-y":[{"skew-y":_e()}],transform:[{transform:[P,N,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:ve()}],"translate-x":[{"translate-x":ve()}],"translate-y":[{"translate-y":ve()}],"translate-z":[{"translate-z":ve()}],"translate-none":[`translate-none`],zoom:[{zoom:[Cr,P,N]}],accent:[{accent:A()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:A()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,P,N]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scrollbar-thumb-color":[{"scrollbar-thumb":A()}],"scrollbar-track-color":[{"scrollbar-track":A()}],"scrollbar-gutter":[{"scrollbar-gutter":[`auto`,`stable`,`both`]}],"scrollbar-w":[{scrollbar:[`auto`,`thin`,`none`]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mbs":[{"scroll-mbs":w()}],"scroll-mbe":[{"scroll-mbe":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pbs":[{"scroll-pbs":w()}],"scroll-pbe":[{"scroll-pbe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,P,N]}],fill:[{fill:[`none`,...A()]}],"stroke-w":[{stroke:[Sr,Vr,Pr,Fr]}],stroke:[{stroke:[`none`,...A()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{"container-named":[`container-type`],overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`inset-bs`,`inset-be`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`right`,`left`],"inset-y":[`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pbs`,`pbe`,`pt`,`pr`,`pb`,`pl`],px:[`pr`,`pl`],py:[`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mbs`,`mbe`,`mt`,`mr`,`mb`,`ml`],mx:[`mr`,`ml`],my:[`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-r`,`border-w-l`],"border-w-y":[`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-r`,`border-color-l`],"border-color-y":[`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},postfixLookupClassGroups:[`container-type`],orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}},ai=(e,{extend:t={},override:n={}})=>(si(e.theme,n.theme),si(e.classGroups,n.classGroups),si(e.conflictingClassGroups,n.conflictingClassGroups),si(e.conflictingClassGroupModifiers,n.conflictingClassGroupModifiers),oi(e,`postfixLookupClassGroups`,n.postfixLookupClassGroups),oi(e,`orderSensitiveModifiers`,n.orderSensitiveModifiers),ci(e.theme,t.theme),ci(e.classGroups,t.classGroups),ci(e.conflictingClassGroups,t.conflictingClassGroups),ci(e.conflictingClassGroupModifiers,t.conflictingClassGroupModifiers),li(e,t,`postfixLookupClassGroups`),li(e,t,`orderSensitiveModifiers`),e),oi=(e,t,n)=>{n!==void 0&&(e[t]=n)},si=(e,t)=>{if(t)for(let n in t)oi(e,n,t[n])},ci=(e,t)=>{if(t)for(let n in t)li(e,t,n)},li=(e,t,n)=>{let r=t[n];r!==void 0&&(e[n]=e[n]?e[n].concat(r):r)},ui=e=>sr(e?typeof e==`function`?()=>e(ii()):()=>ai(ii(),e):ii),di=e=>{if(kt(e))return;let t=e,n={...t.extend??{}};for(let e of[`theme`,`classGroups`,`conflictingClassGroups`,`conflictingClassGroupModifiers`,`postfixLookupClassGroups`,`orderSensitiveModifiers`,`cacheSize`,`prefix`,`separator`,`experimentalParseClassName`])t[e]!==void 0&&n[e]===void 0&&(n[e]=t[e]);let r={};if(Object.keys(n).length>0&&(r.extend=n),t.override!=null&&!kt(t.override)&&(r.override=t.override),!(!r.extend&&!r.override))return r},fi=e=>{let t=ui(di(e));return e=>t.mergeString(e)},pi,mi=()=>(pi||=ui(),pi),hi=()=>((!Yt.cachedTwMerge||Yt.didTwMergeConfigChange)&&(Yt.didTwMergeConfigChange=!1,Yt.cachedTwMerge=fi(Yt.cachedTwMergeConfig)),Yt.cachedTwMerge),gi=e=>{let t=e?.twMergeConfig;!t||kt(t)||At(t,Yt.cachedTwMergeConfig)||(Yt.cachedTwMergeConfig=t,Yt.didTwMergeConfigChange=!0)},_i=e=>St(e);(()=>{let e=Error();return!(`line`in e)&&!(`lineNumber`in e)})();var vi=Yt.reset.bind(Yt);Yt.reset=()=>{pi=void 0,vi()};var yi=(e,t)=>{let n=_i(e);return!n||!(t?.twMerge??!0)?n||void 0:n.indexOf(` `)===-1?n:(gi(t),(t?.twMergeConfig&&!kt(t.twMergeConfig)?hi():mi().mergeString)(n)||void 0)},bi=Tn((e,...t)=>yi(t,e)),xi=bi.tv;bi.createTV;var Si=Dt,Ci=xi({defaultVariants:{status:`default`},slots:{base:`alert`,content:`alert__content`,description:`alert__description`,indicator:`alert__indicator`,title:`alert__title`},variants:{status:{accent:{base:`alert--accent`},danger:{base:`alert--danger`},default:{base:`alert--default`},success:{base:`alert--success`},warning:{base:`alert--warning`}}}}),wi=xi({base:`button`,defaultVariants:{fullWidth:!1,isIconOnly:!1,size:`md`,variant:`primary`},variants:{fullWidth:{false:``,true:`button--full-width`},isIconOnly:{true:`button--icon-only`},size:{lg:`button--lg`,md:`button--md`,sm:`button--sm`},variant:{danger:`button--danger`,"danger-soft":`button--danger-soft`,ghost:`button--ghost`,outline:`button--outline`,primary:`button--primary`,secondary:`button--secondary`,tertiary:`button--tertiary`}}}),Ti=xi({defaultVariants:{variant:`default`},slots:{base:`card`,content:`card__content`,description:`card__description`,footer:`card__footer`,header:`card__header`,title:`card__title`},variants:{variant:{default:{base:`card--default`},secondary:{base:`card--secondary`},tertiary:{base:`card--tertiary`},transparent:{base:`card--transparent`}}}}),Ei=Symbol(`default`);function Di(e){let{className:t,style:n,children:r,defaultClassName:i,defaultChildren:a,defaultStyle:o,values:s,render:c}=e;return(0,_.useMemo)(()=>{let e,l,u;return e=typeof t==`function`?t({...s,defaultClassName:i}):t,l=typeof n==`function`?n({...s,defaultStyle:o||{}}):n,u=typeof r==`function`?r({...s,defaultChildren:a}):r??a,{className:e??i,style:l||o?{...o,...l}:void 0,children:u??a,"data-rac":``,render:c?e=>c(e,s):void 0}},[t,n,r,i,a,o,s,c])}function Oi(e,t){return n=>t(typeof e==`function`?e(n):e,n)}function ki(e,t){let n=(0,_.useContext)(e);if(t===null)return null;if(n&&typeof n==`object`&&`slots`in n&&n.slots){let e=t||Ei;if(!n.slots[e]){let e=new Intl.ListFormat().format(Object.keys(n.slots).map(e=>`"${e}"`)),r=t?`Invalid slot "${t}".`:`A slot prop is required.`;throw Error(`${r} Valid slot names are ${e}.`)}return n.slots[e]}return n}function Ai(e,t,n){let{ref:r,...i}=ki(n,e.slot)||{},a=et((0,_.useMemo)(()=>Fe(t,r),[t,r])),o=Be(i,e);return`style`in i&&i.style&&`style`in e&&e.style&&(o.style=typeof i.style==`function`||typeof e.style==`function`?t=>{let n=typeof i.style==`function`?i.style(t):i.style,r={...t.defaultStyle,...n},a=typeof e.style==`function`?e.style({...t,defaultStyle:r}):e.style;return{...r,...a}}:{...i.style,...e.style}),[o,a]}function ji(e,t,n){let{render:r,...i}=t,a=(0,_.useRef)(null),o=(0,_.useMemo)(()=>Fe(n,a),[n,a]);oe(()=>{},[e,r]);let s={...i,ref:o};return r?r(s,void 0):_.createElement(e,s)}var Mi={},Ni=new Proxy({},{get(e,t){if(typeof t!=`string`)return;let n=Mi[t];return n||(n=(0,_.forwardRef)(ji.bind(null,t)),Mi[t]=n),n}});typeof HTMLTemplateElement<`u`&&(Object.defineProperty(HTMLTemplateElement.prototype,"firstChild",{configurable:!0,enumerable:!0,get:function(){return this.content.firstChild}}),Object.defineProperty(HTMLTemplateElement.prototype,"appendChild",{configurable:!0,enumerable:!0,value:function(e){return this.content.appendChild(e)}}),Object.defineProperty(HTMLTemplateElement.prototype,"removeChild",{configurable:!0,enumerable:!0,value:function(e){return this.content.removeChild(e)}}),Object.defineProperty(HTMLTemplateElement.prototype,"insertBefore",{configurable:!0,enumerable:!0,value:function(e,t){return this.content.insertBefore(e,t)}}));var Pi=(0,_.createContext)(!1);function Fi(e){let t=(t,n)=>(0,_.useContext)(Pi)?null:e(t,n);return t.displayName=e.displayName||e.name,(0,_.forwardRef)(t)}var Ii=(0,_.createContext)(null),Li=7e3,Ri=null;function zi(e,t=`assertive`,n=Li){Ri?Ri.announce(e,t,n):(Ri=new Bi,(typeof IS_REACT_ACT_ENVIRONMENT==`boolean`?IS_REACT_ACT_ENVIRONMENT:typeof jest<`u`)?Ri.announce(e,t,n):setTimeout(()=>{Ri?.isAttached()&&Ri?.announce(e,t,n)},100))}var Bi=class{constructor(){this.node=null,this.assertiveLog=null,this.politeLog=null,typeof document<`u`&&(this.node=document.createElement(`div`),this.node.dataset.liveAnnouncer=`true`,Object.assign(this.node.style,{border:0,clip:`rect(0 0 0 0)`,clipPath:`inset(50%)`,height:`1px`,margin:`-1px`,overflow:`hidden`,padding:0,position:`absolute`,width:`1px`,whiteSpace:`nowrap`}),this.assertiveLog=this.createLog(`assertive`),this.node.appendChild(this.assertiveLog),this.politeLog=this.createLog(`polite`),this.node.appendChild(this.politeLog),document.body.prepend(this.node))}isAttached(){return this.node?.isConnected}createLog(e){let t=document.createElement(`div`);return t.setAttribute(`role`,`log`),t.setAttribute(`aria-live`,e),t.setAttribute(`aria-relevant`,`additions`),t}destroy(){this.node&&=(document.body.removeChild(this.node),null)}announce(e,t=`assertive`,n=Li){if(!this.node)return;let r=document.createElement(`div`);typeof e==`object`?(r.setAttribute(`role`,`img`),r.setAttribute(`aria-labelledby`,e[`aria-labelledby`])):r.textContent=e,t===`assertive`?this.assertiveLog?.appendChild(r):this.politeLog?.appendChild(r),e!==``&&setTimeout(()=>{r.remove()},n)}clear(e){this.node&&((!e||e===`assertive`)&&this.assertiveLog&&(this.assertiveLog.innerHTML=``),(!e||e===`polite`)&&this.politeLog&&(this.politeLog.innerHTML=``))}};function Vi(e){let t=e;return t.nativeEvent=e,t.isDefaultPrevented=()=>t.defaultPrevented,t.isPropagationStopped=()=>t.cancelBubble,t.persist=()=>{},t}function Hi(e,t){Object.defineProperty(e,"target",{value:t}),Object.defineProperty(e,"currentTarget",{value:t})}function Ui(e){let t=(0,_.useRef)({isFocused:!1,observer:null});return oe(()=>{let e=t.current;return()=>{e.observer&&=(e.observer.disconnect(),null)}},[]),(0,_.useCallback)(n=>{let r=Pe(n);if(r instanceof HTMLButtonElement||r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement||r instanceof HTMLSelectElement){t.current.isFocused=!0;let n=r;n.addEventListener(`focusout`,r=>{if(t.current.isFocused=!1,n.disabled){let t=Vi(r);e?.(t)}t.current.observer&&(t.current.observer.disconnect(),t.current.observer=null)},{once:!0}),t.current.observer=new MutationObserver(()=>{if(t.current.isFocused&&n.disabled){t.current.observer?.disconnect();let e=n===Ne()?null:Ne();n.dispatchEvent(new FocusEvent(`blur`,{relatedTarget:e})),n.dispatchEvent(new FocusEvent(`focusout`,{bubbles:!0,relatedTarget:e}))}}),t.current.observer.observe(n,{attributes:!0,attributeFilter:[`disabled`]})}},[e])}var Wi=!1;function Gi(e){for(;e&&!ft(e,{skipVisibilityCheck:!0});)e=e.parentElement;let t=De(e),n=t.document.activeElement;if(!n||n===e)return;Wi=!0;let r=!1,i=e=>{(Pe(e)===n||r)&&e.stopImmediatePropagation()},a=t=>{(Pe(t)===n||r)&&(t.stopImmediatePropagation(),!e&&!r&&(r=!0,k(n),c()))},o=t=>{(Pe(t)===e||r)&&t.stopImmediatePropagation()},s=t=>{(Pe(t)===e||r)&&(t.stopImmediatePropagation(),r||(r=!0,k(n),c()))};t.addEventListener(`blur`,i,!0),t.addEventListener(`focusout`,a,!0),t.addEventListener(`focusin`,s,!0),t.addEventListener(`focus`,o,!0);let c=()=>{cancelAnimationFrame(l),t.removeEventListener(`blur`,i,!0),t.removeEventListener(`focusout`,a,!0),t.removeEventListener(`focusin`,s,!0),t.removeEventListener(`focus`,o,!0),Wi=!1,r=!1},l=requestAnimationFrame(c);return c}var Ki=null,qi=new Set,Ji=new Map,Yi=!1,Xi=!1,Zi={Tab:!0,Escape:!0};function Qi(e,t){for(let n of qi)n(e,t)}function $i(e){return!(e.metaKey||!w()&&e.altKey||e.ctrlKey||e.key===`Control`||e.key===`Shift`||e.key===`Meta`)}function ea(e){Yi=!0,!j.isOpening&&$i(e)&&(Ki=`keyboard`,Qi(`keyboard`,e))}function ta(e){Ki=`pointer`,`pointerType`in e&&e.pointerType,(e.type===`mousedown`||e.type===`pointerdown`)&&(Yi=!0,Qi(`pointer`,e))}function na(e){!j.isOpening&&it(e)&&(Yi=!0,Ki=`virtual`)}function ra(e){let t=De(Pe(e)),n=Ee(Pe(e));Pe(e)===t||Pe(e)===n||Wi||!e.isTrusted||(!Yi&&!Xi&&(Ki=`virtual`,Qi(`virtual`,e)),Yi=!1,Xi=!1)}function ia(){Wi||(Yi=!1,Xi=!0)}function aa(e){if(typeof window>`u`||typeof document>`u`)return;let t=De(e),n=Ee(e);if(Ji.get(t))return;let r=t.HTMLElement.prototype.focus;Reflect.defineProperty(t.HTMLElement.prototype,"focus",{configurable:!0,writable:!0,value:function(){Yi=!0,r.apply(this,arguments)}}),n.addEventListener(`keydown`,ea,!0),n.addEventListener(`keyup`,ea,!0),n.addEventListener(`click`,na,!0),t.addEventListener(`focus`,ra,!0),t.addEventListener(`blur`,ia,!1),typeof PointerEvent<`u`&&(n.addEventListener(`pointerdown`,ta,!0),n.addEventListener(`pointermove`,ta,!0),n.addEventListener(`pointerup`,ta,!0)),t.addEventListener(`beforeunload`,()=>{oa(e)},{once:!0}),Ji.set(t,{focus:r})}var oa=(e,t)=>{let n=De(e),r=Ee(e);t&&r.removeEventListener(`DOMContentLoaded`,t),Ji.has(n)&&(Reflect.defineProperty(n.HTMLElement.prototype,"focus",{configurable:!0,writable:!0,value:Ji.get(n).focus}),r.removeEventListener(`keydown`,ea,!0),r.removeEventListener(`keyup`,ea,!0),r.removeEventListener(`click`,na,!0),n.removeEventListener(`focus`,ra,!0),n.removeEventListener(`blur`,ia,!1),typeof PointerEvent<`u`&&(r.removeEventListener(`pointerdown`,ta,!0),r.removeEventListener(`pointermove`,ta,!0),r.removeEventListener(`pointerup`,ta,!0)),Ji.delete(n))};function sa(e){let t=Ee(e),n;return t.readyState===`loading`?(n=()=>{aa(e)},t.addEventListener(`DOMContentLoaded`,n)):aa(e),()=>oa(e,n)}typeof document<`u`&&sa();function ca(){return Ki!==`pointer`}function la(){return Ki}var ua=new Set([`checkbox`,`radio`,`range`,`color`,`file`,`image`,`button`,`submit`,`reset`]);function da(e,t,n){let r=n?Pe(n):void 0,i=Ee(r),a=De(r),o=a===void 0?HTMLInputElement:a.HTMLInputElement,s=a===void 0?HTMLTextAreaElement:a.HTMLTextAreaElement,c=a===void 0?HTMLElement:a.HTMLElement,l=a===void 0?KeyboardEvent:a.KeyboardEvent,u=Ne(i);return e=e||u instanceof o&&!ua.has(u.type)||u instanceof s||u instanceof c&&u.isContentEditable,!(e&&t===`keyboard`&&n instanceof l&&!Zi[n.key])}function fa(e,t,n){aa(),(0,_.useEffect)(()=>{if(n?.enabled===!1)return;let t=(t,r)=>{da(!!n?.isTextInput,t,r)&&e(ca())};return qi.add(t),()=>{qi.delete(t)}},t)}function pa(e){if(!e.isConnected)return;let t=Ee(e);if(la()===`virtual`){let n=Ne(t);Qe(()=>{let r=Ne(t);(r===n||r===t.body)&&e.isConnected&&k(e)})}else k(e)}function ma(e){let{isDisabled:t,onFocus:n,onBlur:r,onFocusChange:i}=e,a=(0,_.useCallback)(e=>{if(Pe(e)===e.currentTarget)return r&&r(e),i&&i(!1),!0},[r,i]),o=Ui(a),s=(0,_.useCallback)(e=>{let t=Pe(e),r=Ee(t),a=r?Ne(r):Ne();t===e.currentTarget&&t===a&&(n&&n(e),i&&i(!0),o(e))},[i,n,o]);return{focusProps:{onFocus:!t&&(n||i||r)?s:void 0,onBlur:!t&&(r||i)?a:void 0}}}function ha(e){if(e)return t=>{let n=!0;e({...t,preventDefault(){t.preventDefault()},isDefaultPrevented(){return t.isDefaultPrevented()},stopPropagation(){n=!0},continuePropagation(){n=!1,typeof t.continuePropagation==`function`&&t.continuePropagation()},isPropagationStopped(){return n}}),n&&!(typeof t.isPropagationStopped==`function`&&t.isPropagationStopped())&&t.stopPropagation()}}var ga=new Set([`shift`,`alt`,`control`,`meta`,`mod`]),_a=[`Alt`,`Control`,`Meta`,`Shift`];function va(e){let t=new Set;return e.alt&&t.add(`Alt`),e.shift&&t.add(`Shift`),e.ctrl&&t.add(`Control`),e.meta&&t.add(`Meta`),e.mod&&t.add(w()?`Meta`:`Control`),t}function ya(e){let t=new Set;return e.altKey&&t.add(`Alt`),e.ctrlKey&&t.add(`Control`),e.metaKey&&t.add(`Meta`),e.shiftKey&&t.add(`Shift`),t}function ba(e){return _a.filter(t=>e.has(t))}function xa(e){let t=e.split(`+`).reduce((e,t)=>{let n=t.toLowerCase();return ga.has(n)?n===`shift`?e.shift=!0:n===`alt`?e.alt=!0:n===`control`?e.ctrl=!0:n===`meta`?e.meta=!0:n===`mod`&&(e.mod=!0):e.key=t,e},{shift:!1,alt:!1,ctrl:!1,meta:!1,mod:!1,key:``});if(t.key===``)throw Error(`Invalid keyboard shortcut: "${e}". Must include exactly one non-modifier key (e.g. "a", "Enter", "ArrowDown"). Combine any of Shift, Alt, Ctrl, Meta, and Mod.`);return t}function Sa(e){return e.toLowerCase()}var Ca={space:` `,esc:`escape`,del:`delete`,ins:`insert`,left:`arrowleft`,right:`arrowright`,up:`arrowup`,down:`arrowdown`,pageup:`pageup`,pagedown:`pagedown`};function wa(e){let t=Sa(e);return Ca[t]??t}function Ta(e){let t=ba(va(e)),n=wa(e.key);return t.length>0?`${t.join(`+`)}+${n}`:n}function Ea(e){let t=ba(ya(e)),n=Sa(e.key);return(t.length>0?`${t.join(`+`)}+`:``)+n}function Da(e){let t=new Map;for(let[n,r]of Object.entries(e)){let e=xa(n);t.set(Ta(e),r)}return e=>{let n=Ea(e),r=t.get(n),i=r?.(e);i===void 0&&r!==void 0?i={shouldContinuePropagation:!1,shouldPreventDefault:!0}:typeof i==`boolean`&&(i={shouldContinuePropagation:!i,shouldPreventDefault:i}),i?.shouldPreventDefault&&e.preventDefault(),(!r||i?.shouldContinuePropagation)&&e.continuePropagation()}}function Oa(e){let{shortcuts:t,allowRepeats:n=!1,allowComposing:r=!1}=e,i,a;if(t){let o=Da(t),s=ha(e=>{if(!Me(e.currentTarget,Pe(e))){e.continuePropagation();return}if(e.nativeEvent?.repeat&&!n||e.nativeEvent?.isComposing&&!r){e.continuePropagation();return}o(e)}),c=ha(e=>{if(!Me(e.currentTarget,Pe(e))){e.continuePropagation();return}if(e.nativeEvent?.repeat&&!n||e.nativeEvent?.isComposing&&!r){e.continuePropagation();return}e.continuePropagation()});i=e.onKeyDown?Te(e.onKeyDown,s):s,a=e.onKeyUp?Te(e.onKeyUp,c):c}else i=ha(e.onKeyDown),a=ha(e.onKeyUp);return{keyboardProps:e.isDisabled?{}:{onKeyDown:i,onKeyUp:a}}}var ka=_.createContext(null);function Aa(e){let t=(0,_.useContext)(ka)||{};rt(t,e);let{ref:n,...r}=t;return r}function ja(e,t){let{focusProps:n}=ma(e),{keyboardProps:r}=Oa(e),i=Be(n,r),a=Aa(t),o=e.isDisabled?{}:a,s=(0,_.useRef)(e.autoFocus);(0,_.useEffect)(()=>{s.current&&t.current&&pa(t.current),s.current=!1},[t]);let c=e.excludeFromTabOrder?-1:0;return e.isDisabled&&(c=void 0),{focusableProps:Be({...i,tabIndex:c},o)}}var Ma=`default`,Na=``,Pa=new WeakMap;function Fa(e){if(D()&&O()){if(Ma==="default"){let t=Ee(e);Na=t.documentElement.style.webkitUserSelect,t.documentElement.style.webkitUserSelect=`none`}Ma=`disabled`}else if(e instanceof HTMLElement||e instanceof SVGElement){let t=`userSelect`in e.style?`userSelect`:`webkitUserSelect`;Pa.set(e,e.style[t]),e.style[t]=`none`}}function Ia(e){if(D()&&O()){if(Ma!==`disabled`)return;Ma=`restoring`,setTimeout(()=>{Qe(()=>{if(Ma===`restoring`){let t=Ee(e);t.documentElement.style.webkitUserSelect===`none`&&(t.documentElement.style.webkitUserSelect=Na||``),Na=``,Ma=`default`}})},300)}else if((e instanceof HTMLElement||e instanceof SVGElement)&&e&&Pa.has(e)){let t=Pa.get(e),n=`userSelect`in e.style?`userSelect`:`webkitUserSelect`;e.style[n]===`none`&&(e.style[n]=t),e.getAttribute(`style`)===``&&e.removeAttribute(`style`),Pa.delete(e)}}var La=_.createContext({register:()=>{}});La.displayName=`PressResponderContext`;function Ra(e){let t=(0,_.useContext)(La);if(t){let{register:n,ref:r,...i}=t;e=Be(i,e),n()}return rt(t,e.ref),e}var za=class{#e;constructor(e,t,n,r){this.#e=!0;let i=(r?.target??n.currentTarget)?.getBoundingClientRect(),a,o=0,s,c=null;n.clientX!=null&&n.clientY!=null&&(s=n.clientX,c=n.clientY),i&&(s!=null&&c!=null?(a=s-i.left,o=c-i.top):(a=i.width/2,o=i.height/2)),this.type=e,this.pointerType=t,this.target=n.currentTarget,this.shiftKey=n.shiftKey,this.metaKey=n.metaKey,this.ctrlKey=n.ctrlKey,this.altKey=n.altKey,this.x=a,this.y=o,this.key=n.key}continuePropagation(){this.#e=!1}get shouldStopPropagation(){return this.#e}},Ba=Symbol(`linkClicked`),Va=`react-aria-pressable-style`,Ha=`data-react-aria-pressable`;function Ua(e){let{onPress:t,onPressChange:n,onPressStart:r,onPressEnd:i,onPressUp:a,onClick:o,isDisabled:s,isPressed:c,preventFocusOnPress:l,shouldCancelOnPointerExit:u,allowTextSelectionOnPress:d,ref:f,...p}=Ra(e),[m,h]=(0,_.useState)(!1),g=(0,_.useRef)({isPressed:!1,ignoreEmulatedMouseEvents:!1,didFirePressStart:!1,isTriggeringEvent:!1,activePointerId:null,target:null,isOverTarget:!1,pointerType:null,disposables:[]}),{addGlobalListener:v,removeAllGlobalListeners:y}=$e(),b=(0,_.useCallback)((e,t)=>{let i=g.current;if(s||i.didFirePressStart)return!1;let a=!0;if(i.isTriggeringEvent=!0,r){let n=new za(`pressstart`,t,e);r(n),a=n.shouldStopPropagation}return n&&n(!0),i.isTriggeringEvent=!1,i.didFirePressStart=!0,h(!0),a},[s,r,n]),x=(0,_.useCallback)((e,r,a=!0)=>{let o=g.current;if(!o.didFirePressStart)return!1;o.didFirePressStart=!1,o.isTriggeringEvent=!0;let c=!0;if(i){let t=new za(`pressend`,r,e);i(t),c=t.shouldStopPropagation}if(n&&n(!1),h(!1),t&&a&&!s){let n=new za(`press`,r,e);t(n),c&&=n.shouldStopPropagation}return o.isTriggeringEvent=!1,c},[s,i,n,t]),S=nt(x),C=nt((0,_.useCallback)((e,t)=>{let n=g.current;if(s)return!1;if(a){n.isTriggeringEvent=!0;let r=new za(`pressup`,t,e);return a(r),n.isTriggeringEvent=!1,r.shouldStopPropagation}return!0},[s,a])),T=(0,_.useCallback)(e=>{let t=g.current;if(t.isPressed&&t.target){t.didFirePressStart&&t.pointerType!=null&&x(Ka(t.target,e),t.pointerType,!1),t.isPressed=!1,t.isOverTarget=!1,t.activePointerId=null,t.pointerType=null,y(),d||Ia(t.target);for(let e of t.disposables)e();t.disposables=[]}},[d,y,x]),E=nt(T);(0,_.useEffect)(()=>{s&&g.current.isPressed&&E({currentTarget:g.current.target,shiftKey:!1,ctrlKey:!1,metaKey:!1,altKey:!1})},[s]);let D=(0,_.useCallback)(e=>{u&&T(e)},[u,T]),O=(0,_.useCallback)(e=>{s||o?.(e)},[s,o]),ee=(0,_.useCallback)((e,t)=>{if(!s&&o){let n=new MouseEvent(`click`,e);Hi(n,t),o(Vi(n))}},[s,o]),te=(0,_.useMemo)(()=>{let e=g.current,t={onKeyDown(t){if(Ga(t.nativeEvent,t.currentTarget)&&Me(t.currentTarget,Pe(t))){Ja(Pe(t),t.key)&&t.preventDefault();let r=!0;!e.isPressed&&!t.repeat&&(e.target=t.currentTarget,e.isPressed=!0,e.pointerType=`keyboard`,r=b(t,`keyboard`));let i=t.currentTarget;v(Ee(t.currentTarget),`keyup`,Te(t=>{Ga(t,i)&&!t.repeat&&Me(i,Pe(t))&&e.target&&C(Ka(e.target,t),`keyboard`)},n),!0),r&&t.stopPropagation(),t.metaKey&&w()&&e.metaKeyEvents?.set(t.key,t.nativeEvent)}else t.key===`Meta`&&(e.metaKeyEvents=new Map)},onClick(t){if(!(t&&!Me(t.currentTarget,Pe(t)))&&t&&t.button===0&&!e.isTriggeringEvent&&!j.isOpening){let n=!0;if(s&&t.preventDefault(),!e.ignoreEmulatedMouseEvents&&!e.isPressed&&(e.pointerType===`virtual`||it(t.nativeEvent))){let e=b(t,`virtual`),r=C(t,`virtual`),i=S(t,`virtual`);O(t),n=e&&r&&i}else if(e.isPressed&&e.pointerType!==`keyboard`){let r=e.pointerType||t.nativeEvent.pointerType||`virtual`,i=C(Ka(t.currentTarget,t),r),a=S(Ka(t.currentTarget,t),r,!0);n=i&&a,e.isOverTarget=!1,O(t),E(t)}e.ignoreEmulatedMouseEvents=!1,n&&t.stopPropagation()}}},n=t=>{if(e.isPressed&&e.target&&Ga(t,e.target)){Ja(Pe(t),t.key)&&t.preventDefault();let n=Pe(t),r=Me(e.target,n);S(Ka(e.target,t),`keyboard`,r),r&&ee(t,e.target),y(),t.key!==`Enter`&&Wa(e.target)&&Me(e.target,n)&&!t[Ba]&&(t[Ba]=!0,j(e.target,t,!1)),e.isPressed=!1,e.metaKeyEvents?.delete(t.key)}else if(t.key===`Meta`&&e.metaKeyEvents?.size){let t=e.metaKeyEvents;e.metaKeyEvents=void 0;for(let n of t.values())e.target?.dispatchEvent(new KeyboardEvent(`keyup`,n))}};if(typeof PointerEvent<`u`){t.onPointerDown=t=>{if(t.button!==0||!Me(t.currentTarget,Pe(t)))return;if(at(t.nativeEvent)){e.pointerType=`virtual`;return}e.pointerType=t.pointerType;let i=!0;if(!e.isPressed){e.isPressed=!0,e.isOverTarget=!0,e.activePointerId=t.pointerId,e.target=t.currentTarget,d||Fa(e.target),i=b(t,e.pointerType);let a=Pe(t);`releasePointerCapture`in a&&(`hasPointerCapture`in a?a.hasPointerCapture(t.pointerId)&&a.releasePointerCapture(t.pointerId):a.releasePointerCapture(t.pointerId)),v(Ee(t.currentTarget),`pointerup`,n,!1),v(Ee(t.currentTarget),`pointercancel`,r,!1)}i&&t.stopPropagation()},t.onMouseDown=t=>{if(Me(t.currentTarget,Pe(t))&&t.button===0){if(l){let n=Gi(t.target);n&&e.disposables.push(n)}t.stopPropagation()}},t.onPointerUp=t=>{!Me(t.currentTarget,Pe(t))||e.pointerType===`virtual`||t.button===0&&!e.isPressed&&C(t,e.pointerType||t.pointerType)},t.onPointerEnter=t=>{t.pointerId===e.activePointerId&&e.target&&!e.isOverTarget&&e.pointerType!=null&&(e.isOverTarget=!0,b(Ka(e.target,t),e.pointerType))},t.onPointerLeave=t=>{t.pointerId===e.activePointerId&&e.target&&e.isOverTarget&&e.pointerType!=null&&(e.isOverTarget=!1,S(Ka(e.target,t),e.pointerType,!1),D(t))};let n=t=>{if(t.pointerId===e.activePointerId&&e.isPressed&&t.button===0&&e.target){if(Me(e.target,Pe(t))&&e.pointerType!=null){let n=!1,r=setTimeout(()=>{e.isPressed&&e.target instanceof HTMLElement&&(n?E(t):(k(e.target),e.target.click()))},80);v(t.currentTarget,`click`,()=>n=!0,!0),e.disposables.push(()=>clearTimeout(r))}else E(t);e.isOverTarget=!1}},r=e=>{E(e)};t.onDragStart=e=>{Me(e.currentTarget,Pe(e))&&E(e)}}return t},[v,s,l,y,d,D,b,O,ee]);return(0,_.useEffect)(()=>{if(!f)return;let e=Ee(f.current);if(!e||!e.head||e.getElementById(Va))return;let t=e.createElement(`style`);t.id=Va;let n=gt(e);n&&(t.nonce=n),t.textContent=`
|
|
10
|
-
@layer {
|
|
11
|
-
[${Ha}] {
|
|
12
|
-
touch-action: pan-x pan-y pinch-zoom;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
`.trim(),e.head.prepend(t)},[f]),(0,_.useEffect)(()=>{let e=g.current;return()=>{d||Ia(e.target??void 0);for(let t of e.disposables)t();e.disposables=[]}},[d]),{isPressed:c||m,pressProps:Be(p,te,{[Ha]:!0})}}function Wa(e){return e.tagName===`A`&&e.hasAttribute(`href`)}function Ga(e,t){let{key:n,code:r}=e,i=t,a=i.getAttribute(`role`);return(n===`Enter`||n===` `||n===`Spacebar`||r===`Space`)&&!(i instanceof De(i).HTMLInputElement&&!Xa(i,n)||i instanceof De(i).HTMLTextAreaElement||i.isContentEditable)&&!((a===`link`||!a&&Wa(i))&&n!==`Enter`)}function Ka(e,t){let n=t.clientX,r=t.clientY;return{currentTarget:e,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,altKey:t.altKey,clientX:n,clientY:r,key:t.key}}function qa(e){return e instanceof HTMLInputElement?!1:e instanceof HTMLButtonElement?e.type!==`submit`&&e.type!==`reset`:!Wa(e)}function Ja(e,t){return w()&&t===`Enter`?!1:e instanceof HTMLInputElement?t===`Enter`&&(e.type===`checkbox`||e.type===`radio`)?!1:!Xa(e,t):qa(e)}var Ya=new Set([`checkbox`,`radio`,`range`,`color`,`file`,`image`,`button`,`submit`,`reset`]);function Xa(e,t){return e.type===`checkbox`||e.type===`radio`?t===` `:Ya.has(e.type)}function Za(e,t){let{elementType:n=`button`,isDisabled:r,onPress:i,onPressStart:a,onPressEnd:o,onPressUp:s,onPressChange:c,preventFocusOnPress:l,allowFocusWhenDisabled:u,onClick:d,href:f,target:p,rel:m,type:h=`button`}=e,g;g=n===`button`?{type:h,disabled:r,form:e.form,formAction:e.formAction,formEncType:e.formEncType,formMethod:e.formMethod,formNoValidate:e.formNoValidate,formTarget:e.formTarget,name:e.name,value:e.value}:{role:`button`,href:n===`a`&&!r?f:void 0,target:n===`a`?p:void 0,type:n===`input`?h:void 0,disabled:n===`input`?r:void 0,"aria-disabled":!r||n===`input`?void 0:r,rel:n===`a`?m:void 0};let{pressProps:_,isPressed:v}=Ua({onPressStart:a,onPressEnd:o,onPressChange:c,onPress:i,onPressUp:s,onClick:d,isDisabled:r,preventFocusOnPress:l,ref:t}),{focusableProps:y}=ja(e,t);u&&(y.tabIndex=r?-1:y.tabIndex);let b=Be(y,_,qe(e,{labelable:!0}));return{isPressed:v,buttonProps:Be(g,b,{"aria-haspopup":e[`aria-haspopup`],"aria-expanded":e[`aria-expanded`],"aria-controls":e[`aria-controls`],"aria-pressed":e[`aria-pressed`],"aria-current":e[`aria-current`],"aria-disabled":e[`aria-disabled`]})}}function Qa(e){let{isDisabled:t,onBlurWithin:n,onFocusWithin:r,onFocusWithinChange:i}=e,a=(0,_.useRef)({isFocusWithin:!1}),{addGlobalListener:o,removeAllGlobalListeners:s}=$e(),c=(0,_.useCallback)(e=>{Me(e.currentTarget,Pe(e))&&a.current.isFocusWithin&&!Me(e.currentTarget,e.relatedTarget)&&(a.current.isFocusWithin=!1,s(),n&&n(e),i&&i(!1))},[n,i,a,s]),l=Ui(c),u=(0,_.useCallback)(e=>{if(!Me(e.currentTarget,Pe(e)))return;let t=Pe(e),n=Ee(t),s=Ne(n);if(!a.current.isFocusWithin&&s===t){r&&r(e),i&&i(!0),a.current.isFocusWithin=!0,l(e);let t=e.currentTarget;o(n,`focus`,e=>{let r=Pe(e);if(a.current.isFocusWithin&&!Me(t,r)){let e=new n.defaultView.FocusEvent(`blur`,{relatedTarget:r});Hi(e,t);let i=Vi(e);c(i)}},{capture:!0})}},[r,i,l,o,c]);return t?{focusWithinProps:{onFocus:void 0,onBlur:void 0}}:{focusWithinProps:{onFocus:u,onBlur:c}}}function $a(e={}){let{autoFocus:t=!1,isTextInput:n,within:r}=e,i=(0,_.useRef)({isFocused:!1,isFocusVisible:t||ca()}),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(()=>i.current.isFocused&&i.current.isFocusVisible),l=(0,_.useCallback)(()=>c(i.current.isFocused&&i.current.isFocusVisible),[]),u=(0,_.useCallback)(e=>{i.current.isFocused=e,i.current.isFocusVisible=ca(),o(e),l()},[l]);fa(e=>{i.current.isFocusVisible=e,l()},[n,a],{enabled:a,isTextInput:n});let{focusProps:d}=ma({isDisabled:r,onFocusChange:u}),{focusWithinProps:f}=Qa({isDisabled:!r,onFocusWithinChange:u});return{isFocused:a,isFocusVisible:s,focusProps:r?f:d}}var eo=!1,to=0;function no(){eo=!0,setTimeout(()=>{eo=!1},500)}function ro(e){e.pointerType===`touch`&&no()}function io(){let e=Ee(null);if(e!==void 0)return to===0&&typeof PointerEvent<`u`&&e.addEventListener(`pointerup`,ro),to++,()=>{to--,!(to>0)&&typeof PointerEvent<`u`&&e.removeEventListener(`pointerup`,ro)}}function ao(e){let{onHoverStart:t,onHoverChange:n,onHoverEnd:r,isDisabled:i}=e,[a,o]=(0,_.useState)(!1),s=(0,_.useRef)({isHovered:!1,ignoreEmulatedMouseEvents:!1,pointerType:``,target:null}).current;(0,_.useEffect)(io,[]);let{addGlobalListener:c,removeAllGlobalListeners:l}=$e(),{hoverProps:u,triggerHoverEnd:d}=(0,_.useMemo)(()=>{let e=(e,r)=>{if(s.pointerType=r,i||r===`touch`||s.isHovered||!Me(e.currentTarget,Pe(e)))return;s.isHovered=!0;let l=e.currentTarget;s.target=l,c(Ee(Pe(e)),`pointerover`,e=>{s.isHovered&&s.target&&!Me(s.target,Pe(e))&&a(e,e.pointerType)},{capture:!0}),t&&t({type:`hoverstart`,target:l,pointerType:r}),n&&n(!0),o(!0)},a=(e,t)=>{let i=s.target;s.pointerType=``,s.target=null,!(t===`touch`||!s.isHovered||!i)&&(s.isHovered=!1,l(),r&&r({type:`hoverend`,target:i,pointerType:t}),n&&n(!1),o(!1))},u={};return typeof PointerEvent<`u`&&(u.onPointerEnter=t=>{eo&&t.pointerType===`mouse`||e(t,t.pointerType)},u.onPointerLeave=e=>{!i&&Me(e.currentTarget,Pe(e))&&a(e,e.pointerType)}),{hoverProps:u,triggerHoverEnd:a}},[t,n,r,i,s,c,l]);return(0,_.useEffect)(()=>{i&&d({currentTarget:s.target},s.pointerType)},[i]),{hoverProps:u,isHovered:a}}var oo=(0,_.createContext)({}),so=Fi(function(e,t){[e,t]=Ai(e,t,oo);let n=e,{isPending:r}=n,{buttonProps:i,isPressed:a}=Za(e,t);i=lo(i,r);let{focusProps:o,isFocused:s,isFocusVisible:c}=$a(e),{hoverProps:l,isHovered:u}=ao({...e,isDisabled:e.isDisabled||r}),d={isHovered:u,isPressed:(n.isPressed||a)&&!r,isFocused:s,isFocusVisible:c,isDisabled:e.isDisabled||!1,isPending:r??!1},f=Di({...e,values:d,defaultClassName:`react-aria-Button`}),p=Ce(i.id),m=Ce(),h=i[`aria-labelledby`];r&&(h?h=`${h} ${m}`:i[`aria-label`]&&(h=`${p} ${m}`));let g=(0,_.useRef)(r);(0,_.useEffect)(()=>{let e={"aria-labelledby":h||p};(!g.current&&s&&r||g.current&&s&&!r)&&zi(e,`assertive`),g.current=r},[r,s,h,p]);let v=qe(e,{global:!0});return delete v.onClick,_.createElement(Ni.button,{...Be(v,f,i,o,l),type:i.type===`submit`&&r?`button`:i.type,id:p,ref:t,"aria-labelledby":h,slot:e.slot||void 0,"aria-disabled":r?`true`:i[`aria-disabled`],"data-disabled":e.isDisabled||void 0,"data-pressed":d.isPressed||void 0,"data-hovered":u||void 0,"data-focused":s||void 0,"data-pending":r||void 0,"data-focus-visible":c||void 0},_.createElement(Ii.Provider,{value:{id:m}},f.children))}),co=/Focus|Blur|Hover|Pointer(Enter|Leave|Over|Out)|Mouse(Enter|Leave|Over|Out)/;function lo(e,t){if(t){for(let t in e)t.startsWith(`on`)&&!co.test(t)&&(e[t]=void 0);e.href=void 0,e.target=void 0}return e}function uo(e,t){return Oi(e,(e,n)=>Si(typeof t==`function`?t(n)??``:t??``,e??``)??``)}var fo=(e,t,n)=>typeof e==`function`?e({...n??{},className:t}):t,po=e=>(0,M.jsx)(`svg`,{"aria-hidden":`true`,fill:`none`,height:16,role:`presentation`,viewBox:`0 0 16 16`,width:16,xmlns:`http://www.w3.org/2000/svg`,...e,children:(0,M.jsx)(`path`,{clipRule:`evenodd`,d:`M8 13.5a5.5 5.5 0 1 0 0-11a5.5 5.5 0 0 0 0 11M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14m1-9.5a1 1 0 1 1-2 0a1 1 0 0 1 2 0m-.25 3a.75.75 0 0 0-1.5 0V11a.75.75 0 0 0 1.5 0z`,fill:`currentColor`,fillRule:`evenodd`})}),mo=e=>(0,M.jsx)(`svg`,{"aria-hidden":`true`,fill:`none`,height:16,role:`presentation`,viewBox:`0 0 16 16`,width:16,xmlns:`http://www.w3.org/2000/svg`,...e,children:(0,M.jsx)(`path`,{clipRule:`evenodd`,d:`M7.134 2.994L2.217 11.5a1 1 0 0 0 .866 1.5h9.834a1 1 0 0 0 .866-1.5L8.866 2.993a1 1 0 0 0-1.732 0m3.03-.75c-.962-1.665-3.366-1.665-4.329 0L.918 10.749c-.963 1.666.24 3.751 2.165 3.751h9.834c1.925 0 3.128-2.085 2.164-3.751zM8 5a.75.75 0 0 1 .75.75v2a.75.75 0 0 1-1.5 0v-2A.75.75 0 0 1 8 5m1 5.75a1 1 0 1 1-2 0a1 1 0 0 1 2 0`,fill:`currentColor`,fillRule:`evenodd`})}),ho=e=>(0,M.jsx)(`svg`,{"aria-hidden":`true`,fill:`none`,height:16,role:`presentation`,viewBox:`0 0 16 16`,width:16,xmlns:`http://www.w3.org/2000/svg`,...e,children:(0,M.jsx)(`path`,{clipRule:`evenodd`,d:`M8 13.5a5.5 5.5 0 1 0 0-11a5.5 5.5 0 0 0 0 11M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14m1-4.5a1 1 0 1 1-2 0a1 1 0 0 1 2 0M8.75 5a.75.75 0 0 0-1.5 0v2.5a.75.75 0 0 0 1.5 0z`,fill:`currentColor`,fillRule:`evenodd`})}),go=e=>(0,M.jsx)(`svg`,{"aria-hidden":`true`,fill:`none`,height:16,role:`presentation`,viewBox:`0 0 16 16`,width:16,xmlns:`http://www.w3.org/2000/svg`,...e,children:(0,M.jsx)(`path`,{clipRule:`evenodd`,d:`M13.5 8a5.5 5.5 0 1 1-11 0a5.5 5.5 0 0 1 11 0M15 8A7 7 0 1 1 1 8a7 7 0 0 1 14 0m-3.9-1.55a.75.75 0 1 0-1.2-.9L7.419 8.858L6.03 7.47a.75.75 0 0 0-1.06 1.06l2 2a.75.75 0 0 0 1.13-.08z`,fill:`currentColor`,fillRule:`evenodd`})}),_o=(0,_.createContext)({}),vo=(0,_.createContext)({}),yo=`__button_group_child`,bo=({children:e,className:t,fullWidth:n,isDisabled:r,isIconOnly:i,size:a,slot:o,style:s,variant:c,[yo]:l,...u})=>{let d=(0,_.use)(vo),f=l===!0,p=a??(f?d?.size:void 0),m=c??(f?d?.variant:void 0),h=r??(f?d?.isDisabled:void 0),g=wi({fullWidth:n??(f?d?.fullWidth:void 0),isIconOnly:i,size:p,variant:m});return(0,M.jsx)(so,{className:uo(t,g),"data-slot":`button`,isDisabled:h,slot:o,style:s,...u,children:t=>typeof e==`function`?e(t):e})},xo=Object.assign(bo,{Root:bo}),So=(0,_.createContext)({}),Co=({children:e,className:t,variant:n=`default`,...r})=>{let i=_.useMemo(()=>Ti({variant:n}),[n]),a=(0,M.jsx)(bt.div,{className:i.base({className:t}),"data-slot":`card`,...r,children:e});return(0,M.jsx)(So,{value:{slots:i},children:n===`transparent`?a:(0,M.jsx)(_o,{value:{variant:n},children:a})})},wo=Object.assign(Co,{Root:Co,Header:({className:e,...t})=>{let{slots:n}=(0,_.use)(So);return(0,M.jsx)(bt.div,{className:fo(n?.header,e),"data-slot":`card-header`,...t})},Title:({children:e,className:t,...n})=>{let{slots:r}=(0,_.use)(So);return(0,M.jsx)(bt.h3,{className:fo(r?.title,t),"data-slot":`card-title`,...n,children:e})},Description:({children:e,className:t,...n})=>{let{slots:r}=(0,_.use)(So);return(0,M.jsx)(bt.p,{className:fo(r?.description,t),"data-slot":`card-description`,...n,children:e})},Content:({className:e,...t})=>{let{slots:n}=(0,_.use)(So);return(0,M.jsx)(bt.div,{className:fo(n?.content,e),"data-slot":`card-content`,...t})},Footer:({className:e,...t})=>{let{slots:n}=(0,_.use)(So);return(0,M.jsx)(bt.div,{className:fo(n?.footer,e),"data-slot":`card-footer`,...t})}}),To=(0,_.createContext)({}),Eo=({children:e,className:t,status:n,...r})=>{let i=_.useMemo(()=>Ci({status:n}),[n]);return(0,M.jsx)(To,{value:{slots:i,status:n},children:(0,M.jsx)(_o,{value:{variant:`default`},children:(0,M.jsx)(bt.div,{className:i?.base({className:t}),"data-slot":`alert-root`,...r,children:e})})})},Do=Object.assign(Eo,{Root:Eo,Indicator:({children:e,className:t,...n})=>{let{slots:r,status:i}=(0,_.use)(To),a=()=>{switch(i){case`accent`:return(0,M.jsx)(po,{"data-slot":`alert-default-icon`});case`success`:return(0,M.jsx)(go,{"data-slot":`alert-default-icon`});case`warning`:return(0,M.jsx)(mo,{"data-slot":`alert-default-icon`});case`danger`:return(0,M.jsx)(ho,{"data-slot":`alert-default-icon`});default:return(0,M.jsx)(po,{"data-slot":`alert-default-icon`})}};return(0,M.jsx)(bt.div,{className:fo(r?.indicator,t),"data-slot":`alert-indicator`,...n,children:e??a()})},Content:({children:e,className:t,...n})=>{let{slots:r}=(0,_.use)(To);return(0,M.jsx)(bt.div,{className:fo(r?.content,t),"data-slot":`alert-content`,...n,children:e})},Title:({children:e,className:t,...n})=>{let{slots:r}=(0,_.use)(To);return(0,M.jsx)(bt.p,{className:fo(r?.title,t),"data-slot":`alert-title`,...n,children:e})},Description:({children:e,className:t,...n})=>{let{slots:r}=(0,_.use)(To);return(0,M.jsx)(bt.span,{className:fo(r?.description,t),"data-slot":`alert-description`,...n,children:e})}}),Oo=.2,ko=12,Ao=75,jo=.35,Mo={INACTIVE:0,TOUCH_DELAY:1,HOLDING:2,WAITING_FOR_CLICK:3},No=({hoverOpacity:e,pressedOpacity:t,disabled:n=!1,className:r=``,style:i,easing:a,duration:o=150,minimumPressDuration:s=225,touchDelay:c=150})=>{let[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(!1),p=(0,_.useRef)(null),m=(0,_.useRef)(null),h=(0,_.useRef)(``),g=(0,_.useRef)(``),v=(0,_.useRef)(0),y=(0,_.useRef)(void 0),b=(0,_.useRef)(Mo.INACTIVE),x=(0,_.useRef)(void 0),S=(0,_.useRef)(!1);(0,_.useEffect)(()=>{if(!m.current)return;let n=m.current.style;e!==void 0&&n.setProperty(`--ripple-hover-opacity`,e+``),t!==void 0&&n.setProperty(`--ripple-pressed-opacity`,t+``),o!==void 0&&o!==150&&n.setProperty(`--ripple-duration`,o+`ms`)},[e,t,o]),(0,_.useEffect)(()=>{let e=p.current?.parentElement;if(!e)return;let t=(t,n)=>e.addEventListener(t,n,!0);return t(`click`,ae),t(`contextmenu`,j),t(`pointercancel`,A),t(`pointerdown`,ie),t(`pointerenter`,E),t(`pointerleave`,k),t(`pointerup`,re),()=>{let t=(t,n)=>e.removeEventListener(t,n,!0);t(`click`,ae),t(`contextmenu`,j),t(`pointercancel`,A),t(`pointerdown`,ie),t(`pointerenter`,E),t(`pointerleave`,k),t(`pointerup`,re)}},[n,a,o,s,c]);let C=(0,_.useCallback)(({pointerType:e})=>e===`touch`,[]),w=(0,_.useCallback)(e=>{var t;if(n||(t=p.current?.parentElement)!=null&&t.disabled||!e.isPrimary||x.current&&x.current.pointerId!==e.pointerId)return!1;if(e.type===`pointerenter`||e.type===`pointerleave`)return!C(e);let r=e.buttons===1;return C(e)||r},[n,C]),T=(0,_.useCallback)(({x:e,y:t})=>{let n=p.current;if(!n)return!1;let r=n.getBoundingClientRect();return e>=r.left&&e<=r.right&&t>=r.top&&t<=r.bottom},[p]),E=(0,_.useCallback)(e=>{w(e)&&u(!0)},[w]),D=(0,_.useCallback)(()=>{let e=p.current;if(!e)return;let{height:t,width:n}=e.getBoundingClientRect(),r=Math.max(t,n),i=Math.max(jo*r,Ao),a=Math.floor(r*Oo),o=Math.sqrt(n**2+t**2)+ko;v.current=a,g.current=(o+i)/a+``,h.current=a+`px`},[p]),O=(0,_.useCallback)(e=>{let t=p.current;if(!t)return{x:0,y:0};let n=t.getBoundingClientRect(),r=window.scrollX+n.left,i=window.scrollY+n.top;return{x:e.pageX-r,y:e.pageY-i}},[p]),ee=(0,_.useCallback)(e=>{let t=p.current?.parentElement;if(!t)return{startPoint:{x:0,y:0},endPoint:{x:0,y:0}};let n=t.getBoundingClientRect(),r={x:(n.width-v.current)/2,y:(n.height-v.current)/2};return{startPoint:e?O(e):r,endPoint:r}},[p,O]),te=(0,_.useCallback)(e=>{var t;let n=m.current;if(!n)return;f(!0),(t=y.current)==null||t.cancel(),D();let{startPoint:r,endPoint:i}=ee(e),s=`${r.x}px,${r.y}px`,c=`${i.x}px,${i.y}px`;y.current=n.animate({height:[h.current,h.current],width:[h.current,h.current],transform:[`translate(${s}) scale(1)`,`translate(${c}) scale(${g.current})`]},{pseudoElement:`::after`,duration:o,easing:a,fill:`forwards`})},[D,o,a,ee]),ne=(0,_.useCallback)(()=>{x.current=void 0,b.current=Mo.INACTIVE;let e=y.current,t=1/0;if(typeof e?.currentTime==`number`?t=e.currentTime:e!=null&&e.currentTime&&(t=e.currentTime.to(`ms`).value),t>=s)return void f(!1);setTimeout(()=>{y.current===e&&f(!1)},s-t)},[s]),k=(0,_.useCallback)(e=>{w(e)&&(u(!1),b.current!==Mo.INACTIVE&&ne())},[ne,w]),re=(0,_.useCallback)(e=>{if(w(e)){if(b.current===Mo.HOLDING){b.current=Mo.WAITING_FOR_CLICK;return}if(b.current===Mo.TOUCH_DELAY){b.current=Mo.WAITING_FOR_CLICK,te(x.current);return}}},[w,te]),ie=(0,_.useCallback)(e=>{if(w(e)){if(x.current=e,!C(e)){b.current=Mo.WAITING_FOR_CLICK,te(e);return}S.current&&!T(e)||(S.current=!1,b.current=Mo.TOUCH_DELAY,setTimeout(()=>{b.current===Mo.TOUCH_DELAY&&(b.current=Mo.HOLDING,te(e))},c))}},[w,C,T,te,c]),ae=(0,_.useCallback)(e=>{if(!n){if(b.current===Mo.WAITING_FOR_CLICK){ne();return}b.current===Mo.INACTIVE&&(te(e),ne())}},[n,ne,te]),A=(0,_.useCallback)(e=>{w(e)&&ne()},[ne,w]),j=(0,_.useCallback)(()=>{n||(S.current=!0,ne())},[n,ne]);return(0,M.jsx)(`div`,{ref:p,className:`salty-ripple${r?` ${r}`:``}`,style:i,"aria-hidden":`true`,children:(0,M.jsx)(`div`,{ref:m,className:`salty-ripple-surface${l?` --hover`:``}${d?` --press`:``}`})})},Po={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Fo=_.createContext&&_.createContext(Po),Io=[`attr`,`size`,`title`];function Lo(e,t){if(e==null)return{};var n,r,i=Ro(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Ro(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function zo(){return zo=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},zo.apply(null,arguments)}function Bo(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Vo(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Bo(Object(n),!0).forEach(function(t){Ho(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Bo(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ho(e,t,n){return(t=Uo(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Uo(e){var t=Wo(e,`string`);return typeof t==`symbol`?t:t+``}function Wo(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Go(e){return e&&e.map((e,t)=>_.createElement(e.tag,Vo({key:t},e.attr),Go(e.child)))}function Ko(e){return t=>_.createElement(qo,zo({attr:Vo({},e.attr)},t),Go(e.child))}function qo(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=Lo(e,Io),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),_.createElement(`svg`,zo({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:Vo(Vo({color:e.color||t.color},t.style),e.style),height:o,width:o,xmlns:`http://www.w3.org/2000/svg`}),i&&_.createElement(`title`,null,i),e.children)};return Fo===void 0?t(Po):_.createElement(Fo.Consumer,null,e=>t(e))}function Jo(e){return Ko({tag:`svg`,attr:{viewBox:`0 0 384 512`},child:[{tag:`path`,attr:{d:`M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z`},child:[]}]})(e)}function Yo(e){return Ko({tag:`svg`,attr:{viewBox:`0 0 576 512`},child:[{tag:`path`,attr:{d:`M234.7 42.7L197 56.8c-3 1.1-5 4-5 7.2s2 6.1 5 7.2l37.7 14.1L248.8 123c1.1 3 4 5 7.2 5s6.1-2 7.2-5l14.1-37.7L315 71.2c3-1.1 5-4 5-7.2s-2-6.1-5-7.2L277.3 42.7 263.2 5c-1.1-3-4-5-7.2-5s-6.1 2-7.2 5L234.7 42.7zM46.1 395.4c-18.7 18.7-18.7 49.1 0 67.9l34.6 34.6c18.7 18.7 49.1 18.7 67.9 0L529.9 116.5c18.7-18.7 18.7-49.1 0-67.9L495.3 14.1c-18.7-18.7-49.1-18.7-67.9 0L46.1 395.4zM484.6 82.6l-105 105-23.3-23.3 105-105 23.3 23.3zM7.5 117.2C3 118.9 0 123.2 0 128s3 9.1 7.5 10.8L64 160l21.2 56.5c1.7 4.5 6 7.5 10.8 7.5s9.1-3 10.8-7.5L128 160l56.5-21.2c4.5-1.7 7.5-6 7.5-10.8s-3-9.1-7.5-10.8L128 96 106.8 39.5C105.1 35 100.8 32 96 32s-9.1 3-10.8 7.5L64 96 7.5 117.2zm352 256c-4.5 1.7-7.5 6-7.5 10.8s3 9.1 7.5 10.8L416 416l21.2 56.5c1.7 4.5 6 7.5 10.8 7.5s9.1-3 10.8-7.5L480 416l56.5-21.2c4.5-1.7 7.5-6 7.5-10.8s-3-9.1-7.5-10.8L480 352l-21.2-56.5c-1.7-4.5-6-7.5-10.8-7.5s-9.1 3-10.8 7.5L416 352l-56.5 21.2z`},child:[]}]})(e)}function Xo(e){return Ko({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M224 256A128 128 0 1 0 224 0a128 128 0 1 0 0 256zm-45.7 48C79.8 304 0 383.8 0 482.3C0 498.7 13.3 512 29.7 512l388.6 0c16.4 0 29.7-13.3 29.7-29.7C448 383.8 368.2 304 269.7 304l-91.4 0z`},child:[]}]})(e)}function Zo(e){return Ko({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M135.2 17.7C140.6 6.8 151.7 0 163.8 0L284.2 0c12.1 0 23.2 6.8 28.6 17.7L320 32l96 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 96C14.3 96 0 81.7 0 64S14.3 32 32 32l96 0 7.2-14.3zM32 128l384 0 0 320c0 35.3-28.7 64-64 64L96 512c-35.3 0-64-28.7-64-64l0-320zm96 64c-8.8 0-16 7.2-16 16l0 224c0 8.8 7.2 16 16 16s16-7.2 16-16l0-224c0-8.8-7.2-16-16-16zm96 0c-8.8 0-16 7.2-16 16l0 224c0 8.8 7.2 16 16 16s16-7.2 16-16l0-224c0-8.8-7.2-16-16-16zm96 0c-8.8 0-16 7.2-16 16l0 224c0 8.8 7.2 16 16 16s16-7.2 16-16l0-224c0-8.8-7.2-16-16-16z`},child:[]}]})(e)}function Qo(e){return Ko({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M0 80L0 229.5c0 17 6.7 33.3 18.7 45.3l176 176c25 25 65.5 25 90.5 0L418.7 317.3c25-25 25-65.5 0-90.5l-176-176c-12-12-28.3-18.7-45.3-18.7L48 32C21.5 32 0 53.5 0 80zm112 32a32 32 0 1 1 0 64 32 32 0 1 1 0-64z`},child:[]}]})(e)}function $o(e){return Ko({tag:`svg`,attr:{viewBox:`0 0 576 512`},child:[{tag:`path`,attr:{d:`M316.9 18C311.6 7 300.4 0 288.1 0s-23.4 7-28.8 18L195 150.3 51.4 171.5c-12 1.8-22 10.2-25.7 21.7s-.7 24.2 7.9 32.7L137.8 329 113.2 474.7c-2 12 3 24.2 12.9 31.3s23 8 33.8 2.3l128.3-68.5 128.3 68.5c10.8 5.7 23.9 4.9 33.8-2.3s14.9-19.3 12.9-31.3L438.5 329 542.7 225.9c8.6-8.5 11.7-21.2 7.9-32.7s-13.7-19.9-25.7-21.7L381.2 150.3 316.9 18z`},child:[]}]})(e)}function es(e){return Ko({tag:`svg`,attr:{viewBox:`0 0 640 512`},child:[{tag:`path`,attr:{d:`M320 0c17.7 0 32 14.3 32 32l0 64 120 0c39.8 0 72 32.2 72 72l0 272c0 39.8-32.2 72-72 72l-304 0c-39.8 0-72-32.2-72-72l0-272c0-39.8 32.2-72 72-72l120 0 0-64c0-17.7 14.3-32 32-32zM208 384c-8.8 0-16 7.2-16 16s7.2 16 16 16l32 0c8.8 0 16-7.2 16-16s-7.2-16-16-16l-32 0zm96 0c-8.8 0-16 7.2-16 16s7.2 16 16 16l32 0c8.8 0 16-7.2 16-16s-7.2-16-16-16l-32 0zm96 0c-8.8 0-16 7.2-16 16s7.2 16 16 16l32 0c8.8 0 16-7.2 16-16s-7.2-16-16-16l-32 0zM264 256a40 40 0 1 0 -80 0 40 40 0 1 0 80 0zm152 40a40 40 0 1 0 0-80 40 40 0 1 0 0 80zM48 224l16 0 0 192-16 0c-26.5 0-48-21.5-48-48l0-96c0-26.5 21.5-48 48-48zm544 0c26.5 0 48 21.5 48 48l0 96c0 26.5-21.5 48-48 48l-16 0 0-192 16 0z`},child:[]}]})(e)}function ts(e){return Ko({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M256 80c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 144L48 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l144 0 0 144c0 17.7 14.3 32 32 32s32-14.3 32-32l0-144 144 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-144 0 0-144z`},child:[]}]})(e)}function ns(e){return Ko({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480l0-83.6c0-4 1.5-7.8 4.2-10.8L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z`},child:[]}]})(e)}function rs(e){return Ko({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M432 256c0 17.7-14.3 32-32 32L48 288c-17.7 0-32-14.3-32-32s14.3-32 32-32l352 0c17.7 0 32 14.3 32 32z`},child:[]}]})(e)}function is(e){return Ko({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M416 208c0 45.9-14.9 88.3-40 122.7L502.6 457.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.2-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208zM208 352a144 144 0 1 0 0-288 144 144 0 1 0 0 288z`},child:[]}]})(e)}function as(e){return Ko({tag:`svg`,attr:{viewBox:`0 0 576 512`},child:[{tag:`path`,attr:{d:`M575.8 255.5c0 18-15 32.1-32 32.1l-32 0 .7 160.2c0 2.7-.2 5.4-.5 8.1l0 16.2c0 22.1-17.9 40-40 40l-16 0c-1.1 0-2.2 0-3.3-.1c-1.4 .1-2.8 .1-4.2 .1L416 512l-24 0c-22.1 0-40-17.9-40-40l0-24 0-64c0-17.7-14.3-32-32-32l-64 0c-17.7 0-32 14.3-32 32l0 64 0 24c0 22.1-17.9 40-40 40l-24 0-31.9 0c-1.5 0-3-.1-4.5-.2c-1.2 .1-2.4 .2-3.6 .2l-16 0c-22.1 0-40-17.9-40-40l0-112c0-.9 0-1.9 .1-2.8l0-69.7-32 0c-18 0-32-14-32-32.1c0-9 3-17 10-24L266.4 8c7-7 15-8 22-8s15 2 21 7L564.8 231.5c8 7 12 15 11 24z`},child:[]}]})(e)}function os(e){return Ko({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M47.6 300.4L228.3 469.1c7.5 7 17.4 10.9 27.7 10.9s20.2-3.9 27.7-10.9L464.4 300.4c30.4-28.3 47.6-68 47.6-109.5v-5.8c0-69.9-50.5-129.5-119.4-141C347 36.5 300.6 51.4 268 84L256 96 244 84c-32.6-32.6-79-47.5-124.6-39.9C50.5 55.6 0 115.2 0 185.1v5.8c0 41.5 17.2 81.2 47.6 109.5z`},child:[]}]})(e)}function ss(e){return Ko({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M495.9 166.6c3.2 8.7 .5 18.4-6.4 24.6l-43.3 39.4c1.1 8.3 1.7 16.8 1.7 25.4s-.6 17.1-1.7 25.4l43.3 39.4c6.9 6.2 9.6 15.9 6.4 24.6c-4.4 11.9-9.7 23.3-15.8 34.3l-4.7 8.1c-6.6 11-14 21.4-22.1 31.2c-5.9 7.2-15.7 9.6-24.5 6.8l-55.7-17.7c-13.4 10.3-28.2 18.9-44 25.4l-12.5 57.1c-2 9.1-9 16.3-18.2 17.8c-13.8 2.3-28 3.5-42.5 3.5s-28.7-1.2-42.5-3.5c-9.2-1.5-16.2-8.7-18.2-17.8l-12.5-57.1c-15.8-6.5-30.6-15.1-44-25.4L83.1 425.9c-8.8 2.8-18.6 .3-24.5-6.8c-8.1-9.8-15.5-20.2-22.1-31.2l-4.7-8.1c-6.1-11-11.4-22.4-15.8-34.3c-3.2-8.7-.5-18.4 6.4-24.6l43.3-39.4C64.6 273.1 64 264.6 64 256s.6-17.1 1.7-25.4L22.4 191.2c-6.9-6.2-9.6-15.9-6.4-24.6c4.4-11.9 9.7-23.3 15.8-34.3l4.7-8.1c6.6-11 14-21.4 22.1-31.2c5.9-7.2 15.7-9.6 24.5-6.8l55.7 17.7c13.4-10.3 28.2-18.9 44-25.4l12.5-57.1c2-9.1 9-16.3 18.2-17.8C227.3 1.2 241.5 0 256 0s28.7 1.2 42.5 3.5c9.2 1.5 16.2 8.7 18.2 17.8l12.5 57.1c15.8 6.5 30.6 15.1 44 25.4l55.7-17.7c8.8-2.8 18.6-.3 24.5 6.8c8.1 9.8 15.5 20.2 22.1 31.2l4.7 8.1c6.1 11 11.4 22.4 15.8 34.3zM256 336a80 80 0 1 0 0-160 80 80 0 1 0 0 160z`},child:[]}]})(e)}function cs(e){return Ko({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M222.7 32.1c5 16.9-4.6 34.8-21.5 39.8C121.8 95.6 64 169.1 64 256c0 106 86 192 192 192s192-86 192-192c0-86.9-57.8-160.4-137.1-184.1c-16.9-5-26.6-22.9-21.5-39.8s22.9-26.6 39.8-21.5C434.9 42.1 512 140 512 256c0 141.4-114.6 256-256 256S0 397.4 0 256C0 140 77.1 42.1 182.9 10.6c16.9-5 34.8 4.6 39.8 21.5z`},child:[]}]})(e)}function ls(e){return Ko({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm0-384c13.3 0 24 10.7 24 24l0 112c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-112c0-13.3 10.7-24 24-24zM224 352a32 32 0 1 1 64 0 32 32 0 1 1 -64 0z`},child:[]}]})(e)}function us(e){return Ko({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM369 209L241 337c-9.4 9.4-24.6 9.4-33.9 0l-64-64c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L335 175c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z`},child:[]}]})(e)}function ds(e){return Ko({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z`},child:[]}]})(e)}function fs(e){return Ko({tag:`svg`,attr:{viewBox:`0 0 576 512`},child:[{tag:`path`,attr:{d:`M0 24C0 10.7 10.7 0 24 0L69.5 0c22 0 41.5 12.8 50.6 32l411 0c26.3 0 45.5 25 38.6 50.4l-41 152.3c-8.5 31.4-37 53.3-69.5 53.3l-288.5 0 5.4 28.5c2.2 11.3 12.1 19.5 23.6 19.5L488 336c13.3 0 24 10.7 24 24s-10.7 24-24 24l-288.3 0c-34.6 0-64.3-24.6-70.7-58.5L77.4 54.5c-.7-3.8-4-6.5-7.9-6.5L24 48C10.7 48 0 37.3 0 24zM128 464a48 48 0 1 1 96 0 48 48 0 1 1 -96 0zm336-48a48 48 0 1 1 0 96 48 48 0 1 1 0-96zM252 160c0 11 9 20 20 20l44 0 0 44c0 11 9 20 20 20s20-9 20-20l0-44 44 0c11 0 20-9 20-20s-9-20-20-20l-44 0 0-44c0-11-9-20-20-20s-20 9-20 20l0 44-44 0c-11 0-20 9-20 20z`},child:[]}]})(e)}function ps(e){return Ko({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M0 96C0 78.3 14.3 64 32 64l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 128C14.3 128 0 113.7 0 96zM0 256c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 288c-17.7 0-32-14.3-32-32zM448 416c0 17.7-14.3 32-32 32L32 448c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z`},child:[]}]})(e)}function ms(e){return Ko({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M438.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-160-160c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L338.8 224 32 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l306.7 0L233.4 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l160-160z`},child:[]}]})(e)}function hs(e){return Ko({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M160 368c26.5 0 48 21.5 48 48l0 16 72.5-54.4c8.3-6.2 18.4-9.6 28.8-9.6L448 368c8.8 0 16-7.2 16-16l0-288c0-8.8-7.2-16-16-16L64 48c-8.8 0-16 7.2-16 16l0 288c0 8.8 7.2 16 16 16l96 0zm48 124l-.2 .2-5.1 3.8-17.1 12.8c-4.8 3.6-11.3 4.2-16.8 1.5s-8.8-8.2-8.8-14.3l0-21.3 0-6.4 0-.3 0-4 0-48-48 0-48 0c-35.3 0-64-28.7-64-64L0 64C0 28.7 28.7 0 64 0L448 0c35.3 0 64 28.7 64 64l0 288c0 35.3-28.7 64-64 64l-138.7 0L208 492z`},child:[]}]})(e)}function gs(e){return Ko({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M384 336l-192 0c-8.8 0-16-7.2-16-16l0-256c0-8.8 7.2-16 16-16l140.1 0L400 115.9 400 320c0 8.8-7.2 16-16 16zM192 384l192 0c35.3 0 64-28.7 64-64l0-204.1c0-12.7-5.1-24.9-14.1-33.9L366.1 14.1c-9-9-21.2-14.1-33.9-14.1L192 0c-35.3 0-64 28.7-64 64l0 256c0 35.3 28.7 64 64 64zM64 128c-35.3 0-64 28.7-64 64L0 448c0 35.3 28.7 64 64 64l192 0c35.3 0 64-28.7 64-64l0-32-48 0 0 32c0 8.8-7.2 16-16 16L64 464c-8.8 0-16-7.2-16-16l0-256c0-8.8 7.2-16 16-16l32 0 0-48-32 0z`},child:[]}]})(e)}var _s={robot:es,wandMagic:Yo,paperPlane:ns,message:hs,copy:gs,close:Jo,menu:ps,chevronDown:ds,settings:ss,loading:cs,success:us,error:ls,home:as,cartPlus:fs,search:is,arrowRight:ms,trash:Zo,user:Xo,heart:os,tag:Qo,star:$o,plus:ts,minus:rs},vs=({isOpen:e,onToggle:t})=>(0,M.jsxs)(xo,{isIconOnly:!0,variant:`primary`,onPress:t,"aria-label":e?`Close AI Assistant`:`Open AI Assistant`,className:`fixed bottom-6 right-6 z-[2147483647] h-14 w-14 rounded-full shadow-lg transition-transform hover:scale-105`,children:[e?(0,M.jsx)(_s.close,{size:24}):(0,M.jsx)(_s.wandMagic,{size:24}),(0,M.jsx)(No,{})]}),ys=null;function bs(e,t){e.currentIndex=0,e.wipContextDeps=null,e.wipCommitCallbacks=[];let n=ys;ys=e;try{if(t(),e.isFirstRender=!1,e.cells.length!==e.currentIndex)throw Error(`Rendered ${e.currentIndex} hooks but expected ${e.cells.length}. Hooks must be called in the exact same order in every render.`)}finally{ys=n}}function xs(){if(!ys)throw Error(`No resource fiber available`);return ys}function Ss(){return ys}var Cs=typeof process<`u`&&!1,ws=e=>({version:0,committedVersion:0,dispatchUpdate:e,changelog:[],committedLog:[],unsettledCount:0,rollbackCallbacks:[]}),Ts=e=>{e.committedVersion=e.version;for(let t of e.changelog)t.logged=!1,t.settled||(t.settled=!0,e.unsettledCount--),e.committedLog.push(t);e.changelog.length=0,e.unsettledCount===0&&(e.committedLog.length=0),e.rollbackCallbacks.length=0},Es=(e,t)=>{let n=e.version>t;if(e.version=t,n){for(let t=0;t<e.rollbackCallbacks.length;t++)e.rollbackCallbacks[t]();if(e.rollbackCallbacks.length=0,t<=e.committedVersion){let n=[];for(;e.committedVersion-n.length>t;){let t=e.committedLog.pop();if(t===void 0){if(Cs)throw Error(`tap: committed history is shorter than the replay base.`);break}As(t.fiber,t.cell),t.cell.workInProgress=t.prevState,n.push({record:t,prevState:t.prevState,eagerState:t.eagerState,hasEagerState:t.hasEagerState})}if(n.length>0){let t=e.committedVersion;ks(e,()=>{for(let t=n.length-1;t>=0;t--){let r=n[t];r.record.prevState=r.prevState,r.record.eagerState=r.eagerState,r.record.hasEagerState=r.hasEagerState,e.committedLog.push(r.record)}e.committedVersion=t})}e.committedVersion=t;for(let t of e.changelog)t.logged=!1;e.changelog.length=0}else{for(;e.committedVersion+e.changelog.length>t;)e.changelog.pop().logged=!1;for(let t=0;t<e.changelog.length;t++)Ds(e.changelog[t]);Ts(e)}}},Ds=e=>{As(e.fiber,e.cell),e.queued||(e.queued=!0,(e.cell.queue??=[]).push(e))},Os=(e,t)=>{e.wipCommitCallbacks.push(t)},ks=(e,t)=>{e.rollbackCallbacks.push(t)},As=(e,t)=>{t.isDirty||(t.isDirty=!0,e.markDirty?.(),ks(e.root,()=>{if(t.queue!==null){for(let e of t.queue)e.queued=!1;t.queue=null}t.workInProgress=t.current,t.isDirty=!1}))},js=Symbol.for(`react.memo_cache_sentinel`),Ms=e=>Array(e).fill(js),Ns=(e,t)=>{let n=e.memoCache,r=n.workInProgress;if(r===null){let t=n.current;r=t===null?[]:t.map(e=>e.slice()),n.workInProgress=r,ks(e.root,()=>{n.workInProgress=null})}let i=n.index++,a=r[i];return a===void 0?(a=Ms(t),r[i]=a):Cs&&a.length!==t&&console.error(`Expected a constant size argument for each invocation of c(). The previous cache was allocated with size ${a.length} but size ${t} was requested.`),a},Ps=e=>Ns(xs(),e),Fs=_.default.__COMPILER_RUNTIME?.c??(e=>(0,_.useMemo)(()=>{let t=Ms(e);return t[js]=!0,t},[])),Is=()=>Ss()!==null,F=e=>Is()?Ps(e):Fs(e),Ls=()=>{throw Error(`Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.`)},Rs=()=>{throw Error(`Hook order changed between renders`)},zs=()=>({type:`effect`,setup:void 0,setupDeps:void 0,cleanup:void 0,deps:null,generation:0});function Bs(e,t){let n=xs(),r=n.currentIndex++,i=n.cells[r],a=i===void 0?zs():i.type===`effect`?i:Rs();if(i===void 0&&(n.isFirstRender||Ls(),n.cells[r]=a,n.effectCells.push(a)),a.deps!==null&&!!t!=!!a.deps)throw Error(`useEffect called with and without dependencies across re-renders`);Os(n,()=>{a.setup=e,a.setupDeps=t,a.generation++})}var Vs=(e,t)=>{Cs&&e.length!==t.length&&console.error(`The final argument passed to a hook changed size between renders. The order and size of this array must remain constant.
|
|
16
|
-
|
|
17
|
-
Previous: [${e.join(`, `)}]\nIncoming: [${t.join(`, `)}]`);for(let n=0;n<e.length&&n<t.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0},Hs=(e,t)=>{Os(e,()=>{t.current=t.wip,t.currentDeps=t.wipDeps,t.isDirty=!1})},Us=(e,t)=>{let n=xs(),r=n.currentIndex++,i=n.cells[r];if(i===void 0){n.isFirstRender||Ls();let a=e();return Cs&&n.devStrictMode&&e(),i={type:`memo`,current:a,currentDeps:t,wip:a,wipDeps:t,isDirty:!1},n.cells[r]=i,a}i.type!==`memo`&&Rs();let a=i;if(Vs(a.wipDeps,t))return a.isDirty&&Hs(n,a),a.wip;let o=e();return Cs&&n.devStrictMode&&e(),a.wip=o,a.wipDeps=t,a.isDirty||(a.isDirty=!0,ks(n.root,()=>{a.wip=a.current,a.wipDeps=a.currentDeps,a.isDirty=!1})),Hs(n,a),o};function Ws(e){return Us(()=>({current:e}),[])}var Gs=Symbol(`tap.Context.defaultValue`),Ks=e=>e,qs=new Map,Js=new Set,Ys=()=>new Map(qs),Xs=(e,t)=>{let n=qs;qs=e;try{return t()}finally{qs=n}},Zs=(e,t)=>{e[Gs]=t},Qs=e=>typeof e==`object`&&!!e&&Gs in e,$s=e=>typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===Symbol.for(`react.context`),ec=e=>Qs(e)||$s(e),tc=e=>{if(!Qs(e)){if($s(e)){Zs(e,e._currentValue??e._currentValue2);return}throw Error("A tap resource's `use()` only accepts a tap context.")}},nc=(e,t,n)=>{if(typeof e!=`object`||!e)throw Error(`useContextProvider only accepts a React context.`);tc(e);let r=e,i=xs(),a=Ws(void 0),o=a.current===void 0||!Object.is(a.current.value,t);Bs(()=>{a.current={value:t}},[t]);let s=qs.get(r),c=s!==void 0||qs.has(r);qs.set(r,{value:t,source:i});try{return rc(r,o,n)}finally{c?qs.set(r,s):qs.delete(r)}},rc=(e,t,n)=>{let r=Js.has(e);t?Js.add(e):Js.delete(e);try{return n()}finally{r?Js.add(e):Js.delete(e)}},ic=e=>{tc(e);let t=e,n=ac(t,e),r=xs();return(r.wipContextDeps??=new Map).set(t,n.source),n.value},ac=(e,t)=>qs.get(e)??{value:Ks(t)[Gs],source:null},oc=(e,t,n,r)=>{if(!r)return n;let i=n;for(let[n,a]of r)a!==t&&a!==e&&(i??=new Map).set(n,a);return i},sc=(e,t=e.wipContextDeps)=>{let n=Ss();!n||!t||(n.wipContextDeps=oc(n,e,n.wipContextDeps,t))},cc=()=>Js.size>0,lc=e=>{if(!e.contextDeps||!cc())return!1;for(let t of Js.keys())if(e.contextDeps.has(t))return!0;return!1},uc=(e,t,n)=>{if(e.isNeverMounted)throw Error(`Resource updated before mount`);let r=!1,i=!0;e.root.unsettledCount++,e.root.dispatchUpdate(()=>r?i:(r=!0,n&&e.root.changelog.length===0&&!t.cell.isDirty&&!t.hasEagerState&&(t.prevState=t.cell.workInProgress,t.eagerState=n(t.cell.workInProgress,t.action),t.hasEagerState=!0,i=!Object.is(t.cell.current,t.eagerState),!i&&!t.settled&&(t.settled=!0,e.root.unsettledCount--)),i),()=>(r=!0,i=!0,Ds(t),t.logged||(t.logged=!0,e.root.changelog.push(t)),!0))},dc=(e,t,n,r,i)=>{let a=r?r(n):n;Cs&&e.devStrictMode&&r&&r(n);let o={type:`reducer`,workInProgress:a,current:a,isDirty:!1,queue:null,renderQueue:null,reducer:t,dispatch:n=>{let r=Ss();if(r!==null){if(r!==e)throw Error(`Cannot update a resource while rendering a different resource.`);(e.renderPendingCells??=new Set).add(o),(o.renderQueue??=[]).push(n)}else uc(e,{fiber:e,cell:o,action:n,hasEagerState:!1,eagerState:void 0,prevState:o.current,settled:!1,queued:!1,logged:!1},i?t:void 0)}};return o};function fc(e,t,n,r){let i=xs(),a=i.currentIndex++,o=i.cells[a],s=(()=>{if(o!==void 0)return o.type===`reducer`?o:Rs();i.isFirstRender||Ls();let s=dc(i,e,t,n,r);return i.cells[a]=s,s})(),c=s.queue;if(c!==null){let t=e===s.reducer;for(let n=0;n<c.length;n++){let r=c[n];!r.hasEagerState||!t||!Object.is(r.prevState,s.workInProgress)?(r.prevState=s.workInProgress,r.eagerState=e(s.workInProgress,r.action),r.hasEagerState=!0,Cs&&i.devStrictMode&&(r.eagerState=e(s.workInProgress,r.action))):Cs&&i.devStrictMode&&e(s.workInProgress,r.action),r.queued=!1,s.workInProgress=r.eagerState}s.queue=null}if(s.reducer=e,s.renderQueue!==null){let t=s.workInProgress;for(let n of s.renderQueue)t=e(t,n);s.renderQueue=null,i.renderPendingCells?.delete(s),Object.is(t,s.workInProgress)||(As(i,s),s.workInProgress=t)}return s.isDirty&&Os(i,()=>{s.current=s.workInProgress,s.isDirty=!1}),[s.workInProgress,s.dispatch]}function pc(e,t,n){return fc(e,t,n,!1)}var mc=(e,t)=>typeof t==`function`?t(e):t,hc=e=>e===void 0?void 0:typeof e==`function`?e():e;function gc(e){return fc(mc,e,hc,!0)}var _c=(e,t)=>Us(()=>e,t);function vc(e){let t=xs(),n=Ws(e);return n.current!==e&&Os(t,()=>{n.current=e}),_c(((...e)=>{if(Cs&&Ss())throw Error(`useEffectEvent cannot be called during render`);return n.current(...e)}),[])}var yc=e=>typeof e==`object`&&!!e&&typeof e.then==`function`,bc=()=>{},xc=e=>{let t=e;switch(typeof t.status==`string`?t.status!==`fulfilled`&&t.status!==`rejected`&&e.then(bc,bc):(t.status=`pending`,e.then(e=>{t.status===`pending`&&(t.status=`fulfilled`,t.value=e)},e=>{t.status===`pending`&&(t.status=`rejected`,t.reason=e)})),t.status){case`fulfilled`:return t.value;case`rejected`:throw t.reason;default:throw e}},Sc=e=>yc(e)?xc(e):ic(e),Cc=!1,wc=(e,t,n=t)=>{let r=xs().isNeverMounted,i=r?n():t();Cs&&!Cc&&(!r||n===t)&&(Object.is(i,t())||(Cc=!0,console.error(`The result of getSnapshot should be cached to avoid an infinite loop`)));let[,a]=pc(e=>e+1,0),o=Ws(0),s=vc(()=>{try{if(Object.is(i,t()))return o.current=0,!1}catch{}return!0});return Bs(()=>e(()=>{s()&&a()}),[e]),Bs(()=>{if(s()){if(++o.current>50)throw o.current=0,Error(`Maximum update depth exceeded. The result of getSnapshot should be cached to avoid an infinite loop.`);a()}},[e,i,t]),i},Tc=(e,t)=>{},Ec=0,Dc=()=>{let e=Ws(null);return e.current??=`:tap${Ec++}:`,e.current},Oc=(e,t,n)=>{let r=()=>{if(!e)return;let n=t();if(typeof e==`function`){let t=e(n);return typeof t==`function`?t:()=>e(null)}return e.current=n,()=>{e.current=null}};n==null?Bs(r):Bs(r,[...n,e])},kc=_.default;function Ac(e){let t=(0,_.useRef)(e);return(0,_.useInsertionEffect)(()=>{t.current=e}),(0,_.useCallback)(((...e)=>t.current(...e)),[])}var jc=kc.useEffectEvent??Ac,Mc=()=>Ss()!==null,Nc=_.default,Pc=e=>Mc()?gc(e):Nc.useState(e),Fc=(e,t,n)=>Mc()?pc(e,t,n):Nc.useReducer(e,t,n),I=e=>Mc()?Ws(e):Nc.useRef(e),Ic=(e,t)=>Mc()?Us(e,t):Nc.useMemo(e,t),Lc=(e,t)=>Mc()?_c(e,t):Nc.useCallback(e,t),L=(e,t)=>Mc()?Bs(e,t):Nc.useEffect(e,t),Rc=(e,t)=>Mc()?Bs(e,t):Nc.useLayoutEffect(e,t),zc=e=>Mc()?vc(e):jc(e),Bc=(e,t,n)=>Mc()?wc(e,t,n):Nc.useSyncExternalStore(e,t,n),Vc=(e,t)=>Mc()?void 0:Nc.useDebugValue(e,t),Hc=(e,t)=>Mc()?Bs(e,t):Nc.useInsertionEffect(e,t),Uc=()=>Mc()?Dc():Nc.useId(),Wc=(e,t,n)=>Mc()?Oc(e,t,n):Nc.useImperativeHandle(e,t,n),Gc=e=>Nc.forwardRef(e),Kc=(e,t)=>Nc.memo(e,t),qc=Nc.Fragment,Jc=(...e)=>Nc.createElement(...e),Yc=(...e)=>Nc.cloneElement(...e),Xc=e=>Nc.isValidElement(e);Nc.Children,Nc.Suspense;var Zc=e=>{let t=Nc.createContext(e);return Zs(t,e),t},Qc=e=>Mc()&&ec(e)?Sc(e):Nc.use(e),$c=e=>Mc()&&ec(e)?Sc(e):Nc.useContext(e);function el(e){return(...t)=>({hook:e,args:t})}function tl(e,t,n){return typeof t==`function`?(...n)=>tl(e,t(...n)):n?{...t,key:e,deps:n}:{...t,key:e}}var nl=(e,t)=>{if(e.length!==0){if(e.length===1)throw e[0];for(let t of e)console.error(t);throw AggregateError(e,t)}},rl=50,il={schedulers:new Set,isScheduled:!1},al=null,ol=[],sl=class{_isDirty=!1;_task;constructor(e){this._task=e}get isDirty(){return this._isDirty}markDirty(){if(al&&(al.get(this)??0)>=rl)throw Error(`Maximum update depth exceeded. This can happen when a resource repeatedly calls setState inside useEffect.`);this._isDirty=!0,il.schedulers.add(this),ul()}runTask(){al?.set(this,(al.get(this)??0)+1),this._isDirty=!1,this._task()}settle(){this._isDirty=!1}},cl=[];new sl(()=>{let e=cl.splice(0),t=[];for(let n of e)try{n()}catch(e){t.push(e)}nl(t,`Errors occurred while running scheduled tasks`)});var ll=e=>{if(al!==null){ol.push(e);return}e()},ul=()=>{il.isScheduled||(il.isScheduled=!0,fl())},dl=()=>{let e=al;al=new Map;let t=[];try{for(let e of il.schedulers)if(il.schedulers.delete(e),e.isDirty)try{e.runTask()}catch(e){t.push(e)}}finally{if(al=e,il.schedulers.clear(),il.isScheduled=!1,al===null)for(;ol.length>0;)try{ol.shift()()}catch(e){t.push(e)}}nl(t,`Errors occurred during flushSync`)},fl=(()=>{if(typeof MessageChannel<`u`){let e=null,t;return()=>{if(!e){let n=new MessageChannel;n.port1.onmessage=()=>{e?.unref?.(),dl()},e=n.port1,t=n.port2}e.ref?.(),t.postMessage(null)}}return()=>setTimeout(dl,0)})(),pl=e=>{if(al!==null)return Cs&&console.warn(`flushTapSync was called from inside a render or commit. The flush is deferred until the current pass completes.`),e();let t=il;il={schedulers:new Set,isScheduled:!0};try{let t=e();return dl(),t}finally{let e=il.schedulers;if(il=t,e.size>0){for(let t of e)il.schedulers.add(t);ul()}}};function ml(e){let t=[];for(let n=0;n<e.length;n++)try{e[n]()}catch(e){t.push(e)}nl(t,`Errors during commit`)}function hl(e){let t=e.setup,n=e.setupDeps,r=e.generation,i;try{let e=t();if(e!==void 0&&typeof e!=`function`)throw Error(`An effect function must either return a cleanup function or nothing. Received: ${typeof e}`);i=e}finally{e.generation===r?(e.cleanup=i,e.deps=n):i?.()}}var gl=e=>e.setup===void 0?!1:e.deps===null||e.setupDeps===void 0||!Vs(e.deps,e.setupDeps);function _l(e){let t=[],n=[];for(let t of e.effectCells)gl(t)&&n.push(t);for(let e of n)if(e.deps=null,e.cleanup!==void 0)try{e.cleanup()}catch(e){t.push(e)}finally{e.cleanup=void 0}for(let e of n)try{hl(e)}catch(e){t.push(e)}nl(t,`Errors during commit`)}function vl(e){let t=[];for(let n of e.effectCells)if(n.deps=null,n.cleanup)try{n.cleanup?.()}catch(e){t.push(e)}finally{n.cleanup=void 0}nl(t,`Errors during cleanup`)}var yl={useState:gc,useReducer:pc,useRef:Ws,useMemo:Us,useCallback:_c,useEffect:Bs,useLayoutEffect:Bs,useInsertionEffect:Bs,useEffectEvent:vc,useContext:ic,use:Sc,useSyncExternalStore:wc,useDebugValue:Tc,useId:Dc,useImperativeHandle:Oc,useMemoCache:Ps},bl=_.default,xl=bl.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE??bl.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Sl=xl==null?null:`H`in xl?{get current(){return xl.H},set current(e){xl.H=e}}:`ReactCurrentDispatcher`in xl?{get current(){return xl.ReactCurrentDispatcher.current},set current(e){xl.ReactCurrentDispatcher.current=e}}:null;function Cl(e){if(!Sl)return e();let t=Sl.current;Sl.current=yl;try{return e()}finally{Sl.current=t}}function wl(e,t,n=void 0,r){return{hook:e,root:t,markDirty:n,devStrictMode:r,cells:[],effectCells:[],contextDeps:null,wipContextDeps:null,wipCommitCallbacks:null,memoCache:{current:null,workInProgress:null,index:0},renderPendingCells:null,currentIndex:0,isFirstRender:!0,isMounted:!1,isNeverMounted:!0}}function Tl(e){e.wipCommitCallbacks=null,e.wipContextDeps=null,e.memoCache.workInProgress=null}function El(e){e.isMounted&&(e.isMounted=!1,vl(e))}function Dl(e,t){if(e.renderPendingCells!==null){for(let t of e.renderPendingCells)t.renderQueue=null;e.renderPendingCells.clear()}let n=0,r;try{do{if(++n>25)throw Error(`Too many re-renders. tap limits the number of renders to prevent an infinite loop.`);e.memoCache.index=0,bs(e,()=>{r=Cl(()=>e.hook(...t))})}while((e.renderPendingCells?.size??0)>0)}catch(t){throw Tl(e),t}return sc(e),r}function Ol(e){let t=e.wipCommitCallbacks;e.wipCommitCallbacks=null;let n=Cs&&!e.isMounted&&e.devStrictMode===`root`;e.isMounted=!0,e.isNeverMounted=!1,t!==null&&(e.contextDeps=e.wipContextDeps,Ts(e.root),e.memoCache.workInProgress!==null&&(e.memoCache.current=e.memoCache.workInProgress,e.memoCache.workInProgress=null),ml(t)),n&&(_l(e),vl(e)),_l(e)}var kl=()=>{let e=xs();return e.devStrictMode?e.isFirstRender?`child`:`root`:null},Al=()=>`child`,jl=()=>null,Ml=()=>{if(!Cs)return jl;let e=I(0);return Pc(()=>e.current++),e.current===2?Al:jl},Nl=()=>Ss()?kl:Ml(),Pl=e=>e(),Fl=(e,t,n)=>{let r=new sl(()=>s.handleUpdate()),i=[],a=ws((e,t)=>{i.length===0&&!e()||(i.push(t),r.markDirty())}),o=wl(Pl,a,void 0,t),s={scheduler:r,queue:i,fiber:o,subscribers:new Set,pendingHostRender:!1,isMounted:!1,hasRendered:!1,committedRender:e,context:new Map,value:void 0,applyQueue:()=>{Es(a,a.committedVersion);for(let e of i)Cs&&o.devStrictMode&&e(),e();return Es(a,a.committedVersion+a.changelog.length),i.length},publish:(e,t)=>{r.isDirty||a.committedVersion!==t||s.value===e||(s.value=e,ll(()=>s.subscribers.forEach(e=>e())))},finishFlush:(e,t,n)=>{Ts(a),i.splice(0,n),s.pendingHostRender=!1,i.length===0&&r.settle(),s.isMounted&&Ol(o),s.publish(e,t)},handleUpdate:()=>{let e=s.applyQueue(),t;try{Cs&&o.devStrictMode&&Xs(s.context,()=>Dl(o,[s.committedRender])),t=Xs(s.context,()=>Dl(o,[s.committedRender]))}catch(e){if(Es(a,a.committedVersion),yc(e)){let t=()=>{s.isMounted&&r.markDirty()};e.then(t,t);return}if(s.isMounted){s.pendingHostRender=!0,n(e=>e+1);return}throw e}if(r.isDirty)throw Error(`Scheduler is dirty, this should never happen`);s.finishFlush(t,a.version,e)}};return s},Il=e=>{let[,t]=Pc(0),n=Nl(),r=I(null),i=r.current??=Fl(e,n(),t),a=Ys(),o=i.scheduler.isDirty||i.pendingHostRender?i.applyQueue():0,s=Xs(a,()=>Dl(i.fiber,[e])),c={render:e,context:a,value:s,drained:o,wip:i.fiber.wipCommitCallbacks,version:i.fiber.root.version,processed:!1};return i.hasRendered||(i.hasRendered=!0,i.committedRender=e,i.context=a,i.value=s),L(()=>(i.isMounted=!0,()=>{i.isMounted=!1,El(i.fiber)}),[i]),L(()=>{if(c.processed){i.fiber.isMounted||(Ol(i.fiber),i.queue.length&&!i.scheduler.isDirty&&i.scheduler.markDirty());return}if(c.processed=!0,i.committedRender=c.render,i.context=c.context,i.fiber.wipCommitCallbacks!==c.wip){i.scheduler.isDirty||i.handleUpdate();return}if(c.drained>0&&i.fiber.root.version===c.version){i.finishFlush(c.value,c.version,c.drained);return}Ol(i.fiber),i.publish(c.value,c.version)}),Ic(()=>({getValue:()=>i.value,subscribe:e=>(i.subscribers.add(e),()=>i.subscribers.delete(e))}),[i])},Ll=()=>{let e=I(0),t=e.current,n=xs();return{version:t,markDirty:Ic(()=>()=>{e.current++,n.markDirty?.()},[n]),root:n.root}},Rl=()=>{let[e]=Pc(()=>ws((e,t)=>{let i=!1;r(t=>(i=!e(),i?t:t+1)),i||n(t)})),[t,n]=Fc((t,n)=>(Es(e,t),t+ +!!n()),0),[,r]=Pc(0);return Es(e,t),{root:e,version:t,markDirty:void 0}},zl=()=>{let e=Nl(),{root:t,version:n,markDirty:r}=Ss()?Ll():Rl();return{version:n,createFiber:Lc((n,i,a)=>wl(n,t,a?()=>{a(),r?.()}:r,e()),[])}},Bl=(e,t,n)=>{let r=I(null),i=r.current??={wipDeps:null,wip:null,currentDeps:null,current:null};return i.wipDeps=i.currentDeps,i.wip=i.current,L(()=>{i.currentDeps=i.wipDeps,i.current=i.wip}),!n&&i.currentDeps&&Vs(i.currentDeps,t)?i.current:(i.wipDeps=t,i.wip=e(),i.wip)};function Vl(e){let{version:t,createFiber:n}=zl(),r=Ic(()=>n(e.hook,e.key),[e.hook,e.key,n]),i=Bl(()=>({value:Dl(r,e.args)}),[r,t,e.args],lc(r));return L(()=>()=>El(r),[r]),L(()=>{Ol(r)},[r,i]),i.value}var Hl=(e,t)=>{let n=e.get(t);n&&(n.isDirty=!0)},Ul=(e,t)=>!e.isDirty&&!lc(e.fiber)&&t!==void 0&&e.committedDeps!==void 0&&Vs(e.committedDeps,t),Wl=e=>{if(!cc())return!1;for(let{fiber:t}of e.values())if(lc(t))return!0;return!1};function Gl(e){let[t]=Pc(()=>new Map),{version:n,createFiber:r}=zl(),i=Wl(t),a=Bl(()=>{let n=new Set,i=[],a=0;for(let o=0;o<e.length;o++){let s=e[o],c=s.key;if(c===void 0)throw Error(`useResources did not provide a key for array at index ${o}`);if(n.has(c))throw Error(`Duplicate key ${c} in useResources`);n.add(c);let l=t.get(c);if(!l){let e=r(s.hook,s.key,()=>Hl(t,c));l={fiber:e,next:{value:Dl(e,s.args),deps:s.deps},isDirty:!1,committedDeps:void 0,committedValue:void 0},a++,t.set(c,l)}else if(l.fiber.hook!==s.hook){let e=r(s.hook,s.key,()=>Hl(t,c)),n=Dl(e,s.args);l.next={value:n,deps:s.deps,remount:e}}else if(Ul(l,s.deps))typeof l.next==`object`&&Tl(l.fiber),l.fiber.contextDeps&&sc(l.fiber,l.fiber.contextDeps),l.next=`skip`;else{let e=Dl(l.fiber,s.args);l.next={value:e,deps:s.deps}}i.push(typeof l.next==`object`?l.next.value:l.committedValue)}if(t.size>i.length-a)for(let e of t.keys())n.has(e)||(t.get(e).next=`delete`);return i},[e,t,r,n],i);return L(()=>()=>{for(let e of t.keys())El(t.get(e).fiber)},[t]),L(()=>{for(let[e,n]of t.entries()){let r=n.next;r===`delete`?(El(n.fiber),t.delete(e)):r===`skip`?!n.fiber.isNeverMounted&&!n.fiber.isMounted&&Ol(n.fiber):(r.remount&&(El(n.fiber),n.fiber=r.remount),Ol(n.fiber),n.committedDeps=r.deps,n.committedValue=r.value,n.isDirty=!1,n.next=`skip`)}},[a,t]),a}var Kl=e=>e(),ql=e=>{let{createFiber:t}=zl(),n=Ic(()=>t(Kl,void 0),[t]),r=Dl(n,[e]);L(()=>()=>{El(n)},[n]);let i=!1,a=()=>{i&&n.isMounted||(i=!0,Ol(n))};return L(a),{value:r,effects:a}},Jl=el(()=>{let e=F(4),[t,n]=Pc(Yl),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(e,t)=>(n(n=>({...n,renderers:{...n.renderers,[e]:[...n.renderers[e]??[],t]}})),()=>{n(n=>({...n,renderers:{...n.renderers,[e]:n.renderers[e]?.filter(e=>e!==t)??[]}}))}),e[0]=r):r=e[0];let i=r,a;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=e=>(n(t=>({...t,fallbacks:[...t.fallbacks,e]})),()=>{n(t=>({...t,fallbacks:t.fallbacks.filter(t=>t!==e)}))}),e[1]=a):a=e[1];let o=a,s;return e[2]===t?s=e[3]:(s={getState:()=>t,setDataUI:i,setFallbackDataUI:o},e[2]=t,e[3]=s),s});function Yl(){return{renderers:{},fallbacks:[]}}var Xl=e=>{if(!e.overwrite)return e;let{overwrite:t,...n}=e;return n},Zl=e=>{let t=Array.from(e).map(e=>e.getModelContext()).sort((e,t)=>(t.priority??0)-(e.priority??0)),n={};return t.reduce((e,t)=>{let r=t.priority??0;if(t.system&&(e.system?e.system+=`\n\n${t.system}`:e.system=t.system),t.tools)for(let[i,a]of Object.entries(t.tools)){let t=e.tools?.[i];if(t&&t!==a){let o=n[i];if(o===r){if(!a.overwrite)throw Error(`You tried to define a tool with the name ${i}, but it already exists.`);e.tools[i]=Xl(a);continue}let s=o>r?t:a,c=o>r?a:t;e.tools[i]=Xl({...c,...s}),n[i]=Math.max(o,r);continue}e.tools||={},e.tools[i]=Xl(a),n[i]??=r}return t.config&&(e.config={...e.config,...t.config}),t.callSettings&&(e.callSettings={...e.callSettings,...t.callSettings}),t.unstable_composerMetadata&&(e.unstable_composerMetadata={...e.unstable_composerMetadata,...t.unstable_composerMetadata}),e},{})},Ql=(e,t,n)=>{let r=e=>{console.error(`[assistant-ui] ${n} listener threw an error`,e)};for(let n of e)try{let e=n(typeof t==`function`?t():t);e!==null&&(typeof e==`object`||typeof e==`function`)&&`then`in e&&typeof e.then==`function`&&Promise.resolve(e).catch(r)}catch(e){r(e)}},$l=Symbol(`skip-update`),eu=(e,...t)=>{let n=[];for(let r of e)try{r(...t)}catch(e){n.push(e)}if(n.length===1)throw n[0];if(n.length>1){for(let e of n)console.error(e);throw AggregateError(n)}};function tu(e,t){if(e===void 0&&t===void 0)return!0;if(e===void 0||t===void 0)return!1;let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n){let n=e[r],i=t[r];if(!Object.is(n,i))return!1}return!0}var nu=class{_subscribers=new Set;subscribe(e){return this._subscribers.add(e),()=>this._subscribers.delete(e)}waitForUpdate(){return new Promise(e=>{let t=this.subscribe(()=>{t(),e()})})}_notifySubscribers(){eu(this._subscribers)}},ru=class{_subscriptions=new Set;_connection;get isConnected(){return!!this._connection}notifySubscribers(e,t){if(t){Ql(this._subscriptions,e,t);return}eu(this._subscriptions,e)}_updateConnection(){if(this._subscriptions.size>0){if(this._connection)return;this._connection=this._connect()}else this._connection?.(),this._connection=void 0}subscribe(e){return this._subscriptions.add(e),this._updateConnection(),()=>{this._subscriptions.delete(e),this._updateConnection()}}},iu=class extends ru{get path(){return this.binding.path}binding;constructor(e){super(),this.binding=e;let t=e.getState();if(t===$l)throw Error(`Entry not available in the store`);this._previousState=t}_previousState;getState=()=>(this.isConnected||this._syncState(),this._previousState);_syncState(){let e=this.binding.getState();return e===$l||tu(e,this._previousState)?!1:(this._previousState=e,!0)}_connect(){let e=this.binding.subscribe(()=>{this._syncState()&&this.notifySubscribers()});return this._syncState(),e}},au=class extends ru{get path(){return this.binding.path}binding;constructor(e){super(),this.binding=e}_previousStateDirty=!0;_previousState;getState=()=>{if(!this.isConnected||this._previousStateDirty){let e=this.binding.getState();e!==$l&&(this._previousState===void 0||!tu(e,this._previousState))&&(this._previousState=e),this._previousStateDirty=!1}if(this._previousState===void 0)throw Error(`Entry not available in the store`);return this._previousState};_connect(){let e=this.binding.subscribe(()=>{this._previousStateDirty=!0,this.notifySubscribers()});return this._previousStateDirty=!0,e}},ou=class extends ru{get path(){return this.binding.path}binding;constructor(e){super(),this.binding=e}getState(){return this.binding.getState()}outerSubscribe(e){return this.binding.subscribe(e)}_connect(){let e=()=>{this.notifySubscribers()},t=this.binding.getState(),n=t?.subscribe(e),r=this.outerSubscribe(()=>{let r=this.binding.getState();r!==t&&(t=r,n?.(),n=r?.subscribe(e),e())});return()=>{r?.(),n?.()}}},su=class extends ru{config;constructor(e){super(),this.config=e}getState(){return this.config.binding.getState()}outerSubscribe(e){return this.config.binding.subscribe(e)}_connect(){let e=`Runtime event "${this.config.event}"`,t=t=>{this.notifySubscribers(t,e)},n=this.config.binding.getState(),r=n?.unstable_on(this.config.event,t),i=this.outerSubscribe(()=>{let e=this.config.binding.getState();e!==n&&(n=e,r?.(),r=e?.unstable_on(this.config.event,t))});return()=>{i?.(),r?.()}}},cu=class{_providers=new Map;_providerUnsubscribes=new Map;getModelContext(){return Zl(new Set(this._providers.values()))}registerModelContextProvider(e){let t=Symbol();this._providers.set(t,e);let n;try{n=e.subscribe?.(()=>{this.notifySubscribers()})}catch(e){this._providers.delete(t);try{this.notifySubscribers()}catch(e){console.error(e)}throw e}return this._providerUnsubscribes.set(t,n),this.notifySubscribers(),()=>{this._providers.delete(t),this._providerUnsubscribes.get(t)?.(),this._providerUnsubscribes.delete(t),this.notifySubscribers()}}_subscribers=new Set;notifySubscribers(){eu(this._subscribers)}subscribe(e){return this._subscribers.add(e),()=>{this._subscribers.delete(e)}}},lu=[],uu={modelName:void 0,toolNames:lu},du=(e,t)=>e===t||e.length===t.length&&e.every((e,n)=>e===t[n]),fu=(e,t)=>{let n=e.getModelContext(),r=n.config?.modelName,i=n.tools?Object.keys(n.tools).sort():lu,a=i.length?i:lu;return r===t.modelName&&du(a,t.toolNames)?t:{modelName:r,toolNames:a}},pu=el(()=>{let e=F(11),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=new cu,e[0]=t):t=e[0];let n=t,r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>fu(n,uu),e[1]=r):r=e[1];let[i,a]=Pc(r),o,s;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>(a(e=>fu(n,e)),n.subscribe(()=>{a(e=>fu(n,e))})),s=[n],e[2]=o,e[3]=s):(o=e[2],s=e[3]),L(o,s);let c;e[4]===i?c=e[5]:(c=()=>fu(n,i),e[4]=i,e[5]=c);let l,u,d;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>n.getModelContext(),u=e=>n.subscribe(e),d=e=>n.registerModelContextProvider(e),e[6]=l,e[7]=u,e[8]=d):(l=e[6],u=e[7],d=e[8]);let f;return e[9]===c?f=e[10]:(f={getState:c,getModelContext:l,subscribe:u,register:d},e[9]=c,e[10]=f),f}),mu=e=>e.display===void 0?e.type===`human`:e.display===`standalone`,hu=(e,t)=>{if(t.status?.type!==`running`&&t.status?.type!==`requires-action`){let n=e.complete;return typeof n==`function`?n({args:t.args,result:t.result}):n??null}let n=e.running;return typeof n==`function`?n({args:t.args}):n??null},gu=e=>function(t){return hu(e,t)},_u=e=>e,vu=new Set([`$$typeof`,`nodeType`,`then`,`__v_raw`,`__v_isRef`,`__v_isReactive`,`__v_isReadonly`,`__v_isShallow`,`__v_skip`]),yu=(e,t)=>{if(e===Symbol.toStringTag)return t;if(typeof e!=`symbol`){if(e===`toJSON`)return()=>t;if(!vu.has(e))return!1}},bu=class{getOwnPropertyDescriptor(e,t){let n=this.get(e,t);if(n!==void 0)return{value:n,writable:!1,enumerable:!0,configurable:!0}}set(){return!1}setPrototypeOf(){return!1}defineProperty(){return!1}deleteProperty(){return!1}preventExtensions(){return!1}},xu=Symbol(`assistant-ui.store.clientId`),Su=Symbol(`assistant-ui.store.instanceTag`),Cu=(e,t)=>{let n=new Proxy((()=>{}),{apply:()=>(t(),n),get:(n,r)=>r===`source`?e.source:r===`query`?e.query:r===`name`?e.name:r===xu?Du(t()):t()[r],has:(e,n)=>n===`source`||n===`query`||n===`name`||n===xu||n in t(),ownKeys:()=>Reflect.ownKeys(t()),getOwnPropertyDescriptor:(e,n)=>{if(!(typeof n==`symbol`||!(n in t())))return{value:t()[n],writable:!1,enumerable:!0,configurable:!0}}});return n},wu=(e,t)=>{let n=()=>{throw Error(e)};return new Proxy((()=>{}),{apply:n,get:(e,r)=>{if(r===`source`||r===`query`)return null;if(r===`name`)return t;if(r===xu)return n();let i=yu(r,`AssistantClientAccessor`);return i===!1?n():i},has:(e,t)=>t===`source`||t===`query`||t===`name`,ownKeys:()=>[],getOwnPropertyDescriptor:()=>void 0})},Tu=e=>e?.source!=null,Eu=e=>e?.source===null,Du=e=>e[xu]??e,Ou=e=>e[Su]??Du(e),ku=e=>e===`optional`||e===`subscribe`||e===`on`||e===`__proto__`||typeof e==`symbol`,Au=e=>{let t=[];for(let n in e)ku(n)||t.push(n);return t},ju=class extends bu{#e;constructor(e){super(),this.#e=e}get(e,t){let n=yu(t,`OptionalAssistantClient`);if(n!==!1)return n;if(ku(t))return;let r=this.#e[t];return Tu(r)?r:void 0}ownKeys(){return Au(this.#e)}has(e,t){return!ku(t)&&t in this.#e}},Mu=e=>new Proxy({},new ju(e)),Nu=()=>()=>{},Pu=`You are using a component or hook that requires an AuiProvider. Wrap your component in an <AuiProvider> component.`,Fu=class extends bu{#e;#t;#n;#r;constructor(e,t,n){super(),this.#e=e,this.#t=t,this.#n=n}get(e,t){if(t===`subscribe`||t===`on`)return Nu;if(t===`optional`)return this.#r??=Mu(this.#n());let n=yu(t,this.#e);return n===!1?wu(this.#t(String(t)),String(t)):n}ownKeys(){return[`subscribe`,`on`,`optional`]}getOwnPropertyDescriptor(e,t){if(t!==`optional`)return super.getOwnPropertyDescriptor(e,t);let n=this.get(e,t);if(n!==void 0)return{value:n,writable:!1,enumerable:!1,configurable:!0}}has(e,t){return t===`subscribe`||t===`on`||t===`optional`}},Iu=((e,t)=>{let n=new Proxy({},new Fu(e,t,()=>n));return n})(`DefaultAssistantClient`,()=>Pu),Lu=()=>new Proxy({},{get(e,t){let n=yu(t,`AssistantClient`);return n===!1?wu(`The current scope does not have a "${String(t)}" property.`,String(t)):n}}),Ru=Zc(Iu),zu=()=>{},Bu=new WeakMap,Vu=e=>Bu.get(e)??zu,Hu=(e,t)=>{Bu.set(e,t)},Uu=()=>$c(Ru),Wu=(e,t)=>nc(Ru,e,t),Gu=Symbol(`assistant-ui.transform-scopes`);function Ku(e,t){let n=e;if(n[Gu])throw Error(`transformScopes is already attached to this resource`);n[Gu]=t}function qu(e){return e[Gu]}var Ju=e=>typeof e==`string`?{scope:e.split(`.`)[0],event:e}:{scope:e.scope,event:e.event},Yu=()=>{let e=new Map,t=new Set,n=new Set;return{on(n,r){let i=r;if(n===`*`)return t.add(i),()=>t.delete(i);let a=e.get(n);return a||(a=new Set,e.set(n,a)),a.add(i),()=>{a.delete(i),a.size===0&&e.delete(n)}},emit(n,r,i){!e.has(n)&&t.size===0||queueMicrotask(()=>{let a=[],o=e.get(n);if(o)for(let e of o)try{e(r,i)}catch(e){a.push(e)}if(t.size>0){let e={event:n,payload:r};for(let n of t)try{n(e,i)}catch(e){a.push(e)}}if(a.length>0){if(a.length===1)throw a[0];for(let e of a)console.error(e);throw AggregateError(a,`Errors occurred during event emission`)}})},subscribe(e){return n.add(e),()=>n.delete(e)},notifySubscribers(){for(let e of n)try{e()}catch(e){console.error(`NotificationManager: subscriber callback error`,e)}}}},Xu=()=>Pc(Yu)[0],Zu=Symbol(`assistant-ui.store.clientIndex`),Qu=e=>e[Zu],$u=Zc([]),ed=()=>Qc($u),td=(e,t)=>{let n=F(3),r=ed(),i;return n[0]!==e||n[1]!==r?(i=[...r,e],n[0]=e,n[1]=r,n[2]=i):i=n[2],nc($u,i,t)},nd=Zc(null),rd=Symbol(`aui.scope-effect-unapplied`),id=(e,t)=>nc(nd,e,t),ad=()=>{let e=Qc(nd);if(!e)throw Error(`AssistantTapContext is not available`);return e},od=()=>ad().clientRef,sd=()=>Qc(nd)?.destroySignal,cd=(e,t,n)=>{let r=F(8),{clientRef:i}=ad(),a;r[0]!==i||r[1]!==t||r[2]!==e?(a=()=>{let n=i.current;if(n===null)throw Error(`useAssistantScopeEffect ran before the client was committed. This is likely an internal bug in assistant-ui.`);let r=()=>{let t=i.current?.[e];return t!==void 0&&Tu(t)?Ou(t):void 0},a=rd,o,s=e=>{if(o?.(),o=void 0,a=rd,e!==void 0){let e=t();o=typeof e==`function`?e:void 0}a=e};s(r());let c=n.subscribe(()=>{let e=r();e!==a&&s(e)});return()=>{c(),o?.()}},r[0]=i,r[1]=t,r[2]=e,r[3]=a):a=r[3];let o;r[4]!==i||r[5]!==n||r[6]!==e?(o=[i,e,...n],r[4]=i,r[5]=n,r[6]=e,r[7]=o):o=r[7],L(a,o)},ld=()=>{let e=F(3),{emit:t}=ad(),n=ed(),r;return e[0]!==n||e[1]!==t?(r=(e,r)=>{t(e,r,n)},e[0]=n,e[1]=t,e[2]=r):r=e[2],zc(r)},ud=Symbol(`assistant-ui.store.getValue`),dd=e=>{let t=e[ud];if(!t)throw Error(`Client scope contains a non-client resource. Ensure your Derived get() returns a client created with useClientResource(), not a plain resource.`);return t.getState?.()},fd=new Map;function pd(e){let t=fd.get(e);return t||(t=function(...t){if(!this||typeof this!=`object`)throw Error(`Method "${String(e)}" called without proper context. This may indicate the function was called incorrectly.`);let n=this[ud];if(!n)throw Error(`Method "${String(e)}" called on invalid client proxy. Ensure you are calling this method on a valid client instance.`);let r=n[e];if(!r)throw Error(`Method "${String(e)}" is not implemented.`);if(typeof r!=`function`)throw Error(`"${String(e)}" is not a function.`);return r(...t)},fd.set(e,t)),t}var md=class extends bu{boundFns;cachedReceiver;outputRef;tagRef;index;constructor(e,t,n){super(),this.outputRef=e,this.tagRef=t,this.index=n}get(e,t,n){if(t===ud)return this.outputRef.current;if(t===Zu)return this.index;if(t===Su)return this.tagRef.current;let r=yu(t,`ClientProxy`);if(r!==!1)return r;let i=this.outputRef.current[t];if(typeof i==`function`){if(n===void 0)return i;(!this.boundFns||this.cachedReceiver!==n)&&(this.boundFns=new Map,this.cachedReceiver=n);let e=this.boundFns.get(t);return e||(e=pd(t).bind(n),this.boundFns.set(t,e)),e}return i}ownKeys(){return Object.keys(this.outputRef.current)}has(e,t){return t===ud||t===Zu||t===Su||t in this.outputRef.current}},hd=e=>{let t=I(null),n=I(null),r=Ic(()=>({}),[e.hook,e.key]),i=ed().length,a=Ic(()=>new Proxy({},new md(t,n,i)),[i]),o=td(a,function(){return Vl(e)});return t.current||(t.current=o,n.current=r),L(()=>{t.current=o,n.current=r}),{methods:a,state:o.getState?.(),key:e.key}},gd=el(hd),_d=(e,t)=>{if(Array.isArray(e)!==Array.isArray(t))return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,n)=>Object.is(e,t[n]));let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Object.hasOwn(t,n)&&Object.is(e[n],t[n]))},vd=e=>{let t=Ic(()=>({}),[]);return t.v!==void 0&&_d(t.v,e)?t.v:(t.v=e,e)},yd=typeof process<`u`&&!1,bd=(e,t)=>{let n={...e},r=new Set,i=!0;for(;i;){i=!1;for(let e of Object.values(n)){if(r.has(e.hook))continue;r.add(e.hook);let a=qu(e.hook);if(a){a(n,t),i=!0;break}}}return n},xd=e=>e.hook===Gd,Sd=e=>{if(!xd(e))return{source:`root`,query:{}};let t=e.args[0];return{source:t.source,query:t.query??{}}},Cd=Symbol.for(`aui.event-receiver-ref`),wd=(e,t)=>{let n=e===Iu?Lu():e,r=Object.create(n);Object.assign(r,t);let i;return Object.defineProperty(r,"optional",{get:()=>i??=Mu(r),enumerable:!1}),r},Td=({notifications:e,clientRef:t})=>Ic(()=>({subscribe:e.subscribe,on:function(n,r){if(!this)throw Error(`const { on } = useAui() is not supported. Use aui.on() instead.`);let{scope:i,event:a}=Ju(n),o=n[Cd];if(i!==`*`&&!o&&Eu(this[i]))throw Error(`Scope "${i}" is not available. Use { scope: "*", event: "${a}" } to listen globally.`);let s=e.on(a,(e,n)=>{if(i===`*`){r(e);return}let a=((o??t).current??this)[i];if(!Tu(a))return;let s=Du(a);s===n[Qu(s)]&&r(e)});if(i!==`*`){if(o){if(t.parent===Iu)return s}else if(Eu(t.parent[i]))return s}let c=t.parent.on(n,r);return()=>{s(),c()}}}),[e,t]),Ed=e=>{let t=F(5),n;t[0]===e?n=t[1]:(n=Sd(e),t[0]=e,t[1]=n);let{source:r,query:i}=n,a=vd(i),o;return t[2]!==r||t[3]!==a?(o={source:r,query:a},t[2]=r,t[3]=a,t[4]=o):o=t[4],vd(o)},Dd=(e,t)=>{let n=F(3),r;return n[0]!==t||n[1]!==e?(r=t?e:gd(e),n[0]=t,n[1]=e,n[2]=r):r=n[2],Vl(r)},Od=el((e,t)=>{let n=Uu(),r=xd(t),i=Dd(t,r),a=r?i:i.methods,o=Ed(t),s=Ic(()=>Cu({name:e,...o},()=>a),[e,o,a]);return n[e]=s,s}),kd=e=>{let t=F(2),n;return t[0]===e?n=t[1]:(n=e.map(Bd),t[0]=e,t[1]=n),Gl(n)},Ad=(e,t)=>{let n=vd(t),r=Ic(()=>({}),[]);return r.deps!==n&&(r.deps=n,r.client=e),r.client},jd=({parent:e,entries:t,clientRef:n,notifications:r,destroySignal:i})=>{let a=wd(e,Td({notifications:r,clientRef:n}));return{client:Ad(a,[e,...id({clientRef:n,emit:r.emit,destroySignal:i},function(){return Wu(a,function(){return kd(t)})})])}},Md=({parent:e,entries:t})=>{let n=I({parent:e,current:null}).current,{value:r,effects:i}=ql(function(){let r=Xu(),{client:i}=jd({parent:e,entries:t,clientRef:n,notifications:r});return L(()=>e.subscribe(r.notifySubscribers),[e,r]),L(()=>r.notifySubscribers()),i});return Hc(()=>{n.parent=e,n.current=r},[r,e,n]),{client:r,effects:i}},Nd=({parent:e,entries:t})=>{let n=I({parent:e,current:null}).current,{value:r,effects:i}=ql(function(){let r=Xu(),i=Il(function(){return jd({parent:e,entries:t,clientRef:n,notifications:r})}),a=Bc(i.subscribe,()=>i.getValue().client,()=>i.getValue().client);return L(()=>{let t=()=>pl(()=>{n.current=i.getValue().client,r.notifySubscribers()}),a=i.subscribe(t),o=e.subscribe(t);return()=>{a(),o()}},[i,e,r]),a});return Hc(()=>{n.parent=e,n.current=r},[r,e,n]),{client:r,effects:i}},Pd=(e,t,n,r)=>{let{get:i}=r.args[0],a=Bc(e.subscribe,()=>i(e),()=>i(e)),o=Ed(r),s=Ic(()=>Cu({name:n,...o},()=>a),[n,o,a]);return t[n]=s,s},Fd=(e,t)=>{if(yd){let[e]=Pc(()=>t.map(([e])=>e).join(`,`)),n=t.find(([,e])=>!xd(e));if(n)throw Error(`Scope "${n[0]}" is a root scope but this useAui mounted derived-only; remount with a new key to change scope kinds.`);let r=t.map(([e])=>e).join(`,`);if(r!==e)throw Error(`A derived-only config mounted scopes [${e}] but now has [${r}]; remount with a new key to change the scope set.`)}let n=I({parent:e,current:null}).current,r=wd(e,{subscribe:e.subscribe,on:function(t,r){if(!this)throw Error(`const { on } = useAui() is not supported. Use aui.on() instead.`);let{scope:i,event:a}=Ju(t);if(i===`*`)return e.on(t,r);let o=t[Cd];if(!o&&Eu(this[i]))throw Error(`Scope "${i}" is not available. Use { scope: "*", event: "${a}" } to listen globally.`);return e.on({scope:i,event:a,[Cd]:o??n},r)}}),i=Ad(r,[e,...t.map(([t,n])=>Pd(e,r,t,n))]);return Hc(()=>{n.parent=e,n.current=i},[i,e,n]),i},Id=(e,t)=>{let n=F(8),r;n[0]!==t||n[1]!==e?(r=Object.entries(bd(t,e)),n[0]=t,n[1]=e,n[2]=r):r=n[2];let i=r,a;n[3]===i?a=n[4]:(a=()=>i.length===0||i.some(Vd),n[3]=i,n[4]=a);let[o]=Pc(a),s;return n[5]!==i||n[6]!==o?(s={entries:i,rooted:o},n[5]=i,n[6]=o,n[7]=s):s=n[7],s},Ld=(e,t,n)=>{let{entries:r,rooted:i}=Id(e,t);return i?n({parent:e,entries:r}):{client:Fd(e,r)}},Rd=(e,t)=>Ld(e,t,Md);function zd(e){let t=Uu();if(e){let{client:n,effects:r}=Ld(t,e,Nd);return r&&Hu(n,r),n}return t}function Bd(e){let[t,n]=e;return tl(t,Od(t,n))}function Vd(e){let[,t]=e;return!xd(t)}var Hd=e=>{let t;class n extends bu{get(t,n){let r=yu(n,`OptionalAssistantState`);if(r!==!1)return r;let i=n;if(!ku(i)&&Tu(e[i]))return dd(e[i]())}ownKeys(){return Au(e)}has(t,n){return!ku(n)&&n in e}}class r extends bu{get(r,i){let a=yu(i,`AssistantState`);if(a!==!1)return a;if(i===`optional`)return t??=new Proxy({},new n);let o=i;if(!ku(o))return dd(e[o]())}ownKeys(){return[...Au(e),`optional`]}has(t,n){return n===`optional`||!ku(n)&&n in e}}return new Proxy({},new r)},Ud=new WeakMap,Wd=e=>{let t=Ud.get(e);return t||(t=Hd(e),Ud.set(e,t)),t},R=e=>{let t=F(6),n=zd(),r;t[0]===n?r=t[1]:(r=Wd(n),t[0]=n,t[1]=r);let i=r,a,o;t[2]!==i||t[3]!==e?(a=()=>e(i),o=()=>e(i),t[2]=i,t[3]=e,t[4]=a,t[5]=o):(a=t[4],o=t[5]);let s=Bc(n.subscribe,a,o);if(typeof s==`object`&&s&&(s===i||s===i.optional))throw Error(`You tried to return the entire AssistantState. This is not supported due to technical limitations.`);return Vc(s),s},Gd=e=>{let t=F(3),{get:n}=e,r=zd(),i;return t[0]!==r||t[1]!==n?(i=()=>n(r),t[0]=r,t[1]=n,t[2]=i):i=t[2],R(i)},Kd=el(Gd),qd=e=>{if(e.key===void 0)throw Error(`useClientLookup: Element has no key`);return e.key};function Jd(e){let t=F(12),n;t[0]===e?n=t[1]:(n=e.map(Zd),t[0]=e,t[1]=n);let r=Gl(n),i;t[2]===e?i=t[3]:(i=e.reduce(Xd,{}),t[2]=e,t[3]=i);let a=i,o;t[4]===r?o=t[5]:(o=r.map(Yd),t[4]=r,t[5]=o);let s=o,c;t[6]!==a||t[7]!==r?(c=e=>{if(`index`in e){if(e.index<0||e.index>=r.length)throw Error(`useClientLookup: index ${e.index} out of bounds (length: ${r.length}) (ignore if recovered)`);return r[e.index].methods}let t=a[e.key];if(t===void 0)throw Error(`useClientLookup: key "${e.key}" not found (ignore if recovered)`);return r[t].methods},t[6]=a,t[7]=r,t[8]=c):c=t[8];let l;return t[9]!==s||t[10]!==c?(l={state:s,get:c},t[9]=s,t[10]=c,t[11]=l):l=t[11],l}function Yd(e){return e.state}function Xd(e,t,n){return e[qd(t)]=n,e}function Zd(e){return tl(qd(e),gd(e),e.deps)}var Qd=(e,t)=>e.scrollTop>t.scrollTop&&e.scrollHeight===t.scrollHeight,$d=e=>{let t=F(16),{toolkit:n,mcpApp:r}=e,i;t[0]===r?i=t[1]:(i=r?[tl(`mcpApp`,r)]:[],t[0]=r,t[1]=i);let a=Gl(i)[0],[o,s]=Pc(tf),c;t[2]!==a||t[3]!==o?(c={toolUIs:o,mcpApp:a},t[2]=a,t[3]=o,t[4]=c):c=t[4];let l=c,u=od(),d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=(e,t,n)=>{let r={render:t,standalone:n?.standalone??!1};return s(t=>({...t,[e]:[...t[e]??[],r]})),()=>{s(t=>{let n=t[e]?.filter(e=>e!==r)??[];if(n.length>0)return{...t,[e]:n};let i={...t};return delete i[e],i})}},t[5]=d):d=t[5];let f=d,p,m;t[6]===n?(p=t[7],m=t[8]):(p=()=>{if(!n)return;let e=[];for(let[t,r]of Object.entries(n)){let n=`render`in r?r.render:void 0,i=`renderText`in r?r.renderText:void 0,a=n??(i?gu(i):void 0);a&&e.push(f(t,a,{standalone:mu(r)}))}return()=>{e.forEach(nf)}},m=[n,f],t[6]=n,t[7]=p,t[8]=m),L(p,m);let h;t[9]!==u||t[10]!==n?(h=()=>{if(!n)return;let e=Object.entries(n).reduce(rf,{});return u.current.modelContext().register({getModelContext:()=>({tools:e})})},t[9]=u,t[10]=n,t[11]=h):h=t[11];let g;t[12]===n?g=t[13]:(g=[n],t[12]=n,t[13]=g),cd(`modelContext`,h,g);let _;return t[14]===l?_=t[15]:(_={getState:()=>l,setToolUI:f},t[14]=l,t[15]=_),_},ef=el($d);Ku($d,(e,t)=>{!e.modelContext&&t.modelContext.source===null&&(e.modelContext=pu())});function tf(){return{}}function nf(e){return e()}function rf(e,t){let[n,r]=t;if(r.type===`mcp`)return e;let{display:i,render:a,renderText:o,...s}=r;return e[n]=s,e}var af=e=>Bc(e.subscribe,e.getState),of=Symbol.for(`assistant-ui.silent-runtime-action`),sf=e=>typeof e==`object`&&!!e&&of in e,cf=(e,t)=>{let n=t();return n.catch(t=>{sf(t)||console.error(`[assistant-ui] ${e} failed:`,t)}),n},lf=el(e=>{let t=F(9),{runtime:n}=e,r=af(n),i;t[0]===r?i=t[1]:(i=()=>r,t[0]=r,t[1]=i);let a,o;t[2]===n?(a=t[3],o=t[4]):(a=()=>cf(`attachment remove`,n.remove),o=()=>n,t[2]=n,t[3]=a,t[4]=o);let s;return t[5]!==i||t[6]!==a||t[7]!==o?(s={getState:i,remove:a,__internal_getRuntime:o},t[5]=i,t[6]=a,t[7]=o,t[8]=s):s=t[8],s}),uf=el(e=>{let t=F(5),{runtime:n,index:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getAttachmentByIndex(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=lf({runtime:a}),t[3]=a,t[4]=o),Vl(o)}),df=el(({item:e,onMove:t,onRemove:n})=>({getState:()=>e,steer:()=>t({lane:`steer`,insertAfter:null}),move:t,remove:n})),ff=el(e=>{let t=F(55),{threadIdRef:n,messageIdRef:r,runtime:i}=e,a=af(i),o=ld(),s,c;t[0]!==o||t[1]!==r||t[2]!==i||t[3]!==n?(s=()=>{let e=[];for(let t of[`send`,`attachmentAdd`]){let a=i.unstable_on(t,()=>{o(`composer.${t}`,{threadId:n.current,...r&&{messageId:r.current}})});e.push(a)}return e.push(i.unstable_on(`attachmentAddError`,e=>{o(`composer.attachmentAddError`,{threadId:n.current,...r&&{messageId:r.current},...e.attachmentId&&{attachmentId:e.attachmentId},reason:e.reason,message:e.message})})),()=>{for(let t of e)t()}},c=[i,o,n,r],t[0]=o,t[1]=r,t[2]=i,t[3]=n,t[4]=s,t[5]=c):(s=t[4],c=t[5]),L(s,c);let l;if(t[6]!==i||t[7]!==a.attachments){let e;t[9]===i?e=t[10]:(e=(e,t)=>tl(e.id,uf({runtime:i,index:t}),[i,t]),t[9]=i,t[10]=e),l=a.attachments.map(e),t[6]=i,t[7]=a.attachments,t[8]=l}else l=t[8];let u=Jd(l),d=a.queue,f;if(t[11]!==d||t[12]!==i){let e;t[14]===i?e=t[15]:(e=e=>tl(e.id,df({item:e,onMove:t=>i.moveQueueItem(e.id,t),onRemove:()=>i.removeQueueItem(e.id)})),t[14]=i,t[15]=e),f=d.map(e),t[11]=d,t[12]=i,t[13]=f}else f=t[13];let p=Jd(f),m=a.type??`thread`,h;t[16]!==u.state||t[17]!==d||t[18]!==a.attachmentAccept||t[19]!==a.canCancel||t[20]!==a.canSend||t[21]!==a.dictation||t[22]!==a.isEditing||t[23]!==a.isEmpty||t[24]!==a.quote||t[25]!==a.role||t[26]!==a.runConfig||t[27]!==a.text||t[28]!==m?(h={text:a.text,role:a.role,attachments:u.state,runConfig:a.runConfig,isEditing:a.isEditing,canCancel:a.canCancel,canSend:a.canSend,attachmentAccept:a.attachmentAccept,isEmpty:a.isEmpty,type:m,dictation:a.dictation,quote:a.quote,queue:d},t[16]=u.state,t[17]=d,t[18]=a.attachmentAccept,t[19]=a.canCancel,t[20]=a.canSend,t[21]=a.dictation,t[22]=a.isEditing,t[23]=a.isEmpty,t[24]=a.quote,t[25]=a.role,t[26]=a.runConfig,t[27]=a.text,t[28]=m,t[29]=h):h=t[29];let g=h,_;t[30]===g?_=t[31]:(_=()=>g,t[30]=g,t[31]=_);let v=i.beginEdit??pf,y;t[32]===u?y=t[33]:(y=e=>`id`in e?u.get({key:e.id}):u.get(e),t[32]=u,t[33]=y);let b;t[34]===p?b=t[35]:(b=e=>`id`in e?p.get({key:e.id}):p.get(e),t[34]=p,t[35]=b);let x;t[36]===i?x=t[37]:(x=()=>i,t[36]=i,t[37]=x);let S;return t[38]!==i.addAttachment||t[39]!==i.cancel||t[40]!==i.clearAttachments||t[41]!==i.reset||t[42]!==i.send||t[43]!==i.setQuote||t[44]!==i.setRole||t[45]!==i.setRunConfig||t[46]!==i.setText||t[47]!==i.startDictation||t[48]!==i.stopDictation||t[49]!==b||t[50]!==x||t[51]!==_||t[52]!==v||t[53]!==y?(S={getState:_,setText:i.setText,setRole:i.setRole,setRunConfig:i.setRunConfig,addAttachment:i.addAttachment,reset:i.reset,clearAttachments:i.clearAttachments,send:i.send,cancel:i.cancel,beginEdit:v,startDictation:i.startDictation,stopDictation:i.stopDictation,setQuote:i.setQuote,attachment:y,queueItem:b,__internal_getRuntime:x},t[38]=i.addAttachment,t[39]=i.cancel,t[40]=i.clearAttachments,t[41]=i.reset,t[42]=i.send,t[43]=i.setQuote,t[44]=i.setRole,t[45]=i.setRunConfig,t[46]=i.setText,t[47]=i.startDictation,t[48]=i.stopDictation,t[49]=b,t[50]=x,t[51]=_,t[52]=v,t[53]=y,t[54]=S):S=t[54],S});function pf(){throw Error(`beginEdit is not supported in this runtime`)}var mf=e=>({get current(){return e()}}),hf=el(e=>{let t=F(13),{runtime:n}=e,r=af(n),i;t[0]===r?i=t[1]:(i=()=>r,t[0]=r,t[1]=i);let a,o,s,c;t[2]===n?(a=t[3],o=t[4],s=t[5],c=t[6]):(a=e=>n.addToolResult(e),o=e=>n.resumeToolCall(e),s=e=>n.respondToToolApproval(e),c=()=>n,t[2]=n,t[3]=a,t[4]=o,t[5]=s,t[6]=c);let l;return t[7]!==i||t[8]!==a||t[9]!==o||t[10]!==s||t[11]!==c?(l={getState:i,addToolResult:a,resumeToolCall:o,respondToToolApproval:s,__internal_getRuntime:c},t[7]=i,t[8]=a,t[9]=o,t[10]=s,t[11]=c,t[12]=l):l=t[12],l}),gf=el(e=>{let t=F(5),{runtime:n,index:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getAttachmentByIndex(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=lf({runtime:a}),t[3]=a,t[4]=o),Vl(o)}),_f=el(e=>{let t=F(5),{runtime:n,index:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getMessagePartByIndex(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=hf({runtime:a}),t[3]=a,t[4]=o),Vl(o)}),vf=el(e=>{let t=F(55),{runtime:n,threadIdRef:r}=e,i=af(n),[a,o]=Pc(!1),[s,c]=Pc(!1),l;t[0]===n?l=t[1]:(l=mf(()=>n.getState().id),t[0]=n,t[1]=l);let u=l,d;t[2]!==u||t[3]!==n.composer||t[4]!==r?(d=ff({runtime:n.composer,threadIdRef:r,messageIdRef:u}),t[2]=u,t[3]=n.composer,t[4]=r,t[5]=d):d=t[5];let f=hd(d),p;if(t[6]!==n||t[7]!==i.content){let e;t[9]===n?e=t[10]:(e=(e,t)=>tl(`toolCallId`in e&&e.toolCallId!=null?`toolCallId-${e.toolCallId}`:`index-${t}`,_f({runtime:n,index:t}),[n,t]),t[9]=n,t[10]=e),p=i.content.map(e),t[6]=n,t[7]=i.content,t[8]=p}else p=t[8];let m=Jd(p),h;t[11]===i.attachments?h=t[12]:(h=i.attachments??[],t[11]=i.attachments,t[12]=h);let g;if(t[13]!==n||t[14]!==h){let e;t[16]===n?e=t[17]:(e=(e,t)=>tl(e.id,gf({runtime:n,index:t}),[n,t]),t[16]=n,t[17]=e),g=h.map(e),t[13]=n,t[14]=h,t[15]=g}else g=t[15];let _=Jd(g),v=i,y;t[18]!==f.state||t[19]!==a||t[20]!==s||t[21]!==m.state||t[22]!==v?(y={...v,parts:m.state,composer:f.state,isCopied:a,isHovering:s},t[18]=f.state,t[19]=a,t[20]=s,t[21]=m.state,t[22]=v,t[23]=y):y=t[23];let b=y,x;t[24]===b?x=t[25]:(x=()=>b,t[24]=b,t[25]=x);let S;t[26]===f.methods?S=t[27]:(S=()=>f.methods,t[26]=f.methods,t[27]=S);let C,w,T,E,D,O,ee;t[28]===n?(C=t[29],w=t[30],T=t[31],E=t[32],D=t[33],O=t[34],ee=t[35]):(C=()=>n.delete(),w=e=>n.reload(e),T=()=>n.speak(),E=()=>n.stopSpeaking(),D=e=>n.submitFeedback(e),O=e=>n.switchToBranch(e),ee=()=>n.unstable_getCopyText(),t[28]=n,t[29]=C,t[30]=w,t[31]=T,t[32]=E,t[33]=D,t[34]=O,t[35]=ee);let te;t[36]===m?te=t[37]:(te=e=>`index`in e?m.get({index:e.index}):m.get({key:`toolCallId-${e.toolCallId}`}),t[36]=m,t[37]=te);let ne;t[38]===_?ne=t[39]:(ne=e=>`id`in e?_.get({key:e.id}):_.get(e),t[38]=_,t[39]=ne);let k;t[40]===n?k=t[41]:(k=()=>n,t[40]=n,t[41]=k);let re;return t[42]!==C||t[43]!==w||t[44]!==T||t[45]!==E||t[46]!==D||t[47]!==O||t[48]!==ee||t[49]!==te||t[50]!==ne||t[51]!==k||t[52]!==x||t[53]!==S?(re={getState:x,composer:S,delete:C,reload:w,speak:T,stopSpeaking:E,submitFeedback:D,switchToBranch:O,getCopyText:ee,part:te,attachment:ne,setIsCopied:o,setIsHovering:c,__internal_getRuntime:k},t[42]=C,t[43]=w,t[44]=T,t[45]=E,t[46]=D,t[47]=O,t[48]=ee,t[49]=te,t[50]=ne,t[51]=k,t[52]=x,t[53]=S,t[54]=re):re=t[54],re}),yf=el(e=>({getState:()=>e})),bf=e=>{let t=F(9),n;t[0]===e.suggestions?n=t[1]:(n=e.suggestions.map(Sf),t[0]=e.suggestions,t[1]=n);let r=Jd(n),i;t[2]===e?i=t[3]:(i=()=>e,t[2]=e,t[3]=i);let a;t[4]===r?a=t[5]:(a=e=>{let{index:t}=e;return r.get({index:t})},t[4]=r,t[5]=a);let o;return t[6]!==i||t[7]!==a?(o={getState:i,suggestion:a},t[6]=i,t[7]=a,t[8]=o):o=t[8],o},xf=el(e=>{let t=F(4),n;t[0]===e?n=t[1]:(n=e.map(Cf),t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r={suggestions:n},t[2]=n,t[3]=r),bf(r)});function Sf(e,t){return tl(t,yf(e),[e])}function Cf(e){return{title:e.title??e.prompt,label:e.label??``,prompt:e.prompt}}var wf=el(e=>{let t=F(6),{runtime:n,id:r,threadIdRef:i}=e,a;t[0]!==r||t[1]!==n?(a=n.getMessageById(r),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o=a,s;return t[3]!==o||t[4]!==i?(s=vf({runtime:o,threadIdRef:i}),t[3]=o,t[4]=i,t[5]=s):s=t[5],Vl(s)}),Tf=el(e=>{let t=F(64),{runtime:n}=e,r=af(n),i=ld(),a,o;t[0]!==i||t[1]!==n?(a=()=>{let e=[];for(let t of[`runStart`,`runEnd`,`initialize`,`modelContextUpdate`]){let r=n.unstable_on(t,()=>{let e=n.getState()?.threadId||`unknown`;i(`thread.${t}`,{threadId:e})});e.push(r)}return()=>{for(let t of e)t()}},o=[n,i],t[0]=i,t[1]=n,t[2]=a,t[3]=o):(a=t[2],o=t[3]),L(a,o);let s;t[4]===n?s=t[5]:(s=mf(()=>n.getState().threadId),t[4]=n,t[5]=s);let c=s,l;t[6]!==n.composer||t[7]!==c?(l=ff({runtime:n.composer,threadIdRef:c}),t[6]=n.composer,t[7]=c,t[8]=l):l=t[8];let u=hd(l),d;t[9]===r.suggestions?d=t[10]:(d=xf(r.suggestions),t[9]=r.suggestions,t[10]=d);let f=hd(d),p;if(t[11]!==n||t[12]!==r.messages||t[13]!==c){let e;t[15]!==n||t[16]!==c?(e=e=>tl(e.id,wf({runtime:n,id:e.id,threadIdRef:c}),[n,e.id,c]),t[15]=n,t[16]=c,t[17]=e):e=t[17],p=r.messages.map(e),t[11]=n,t[12]=r.messages,t[13]=c,t[14]=p}else p=t[14];let m=Jd(p),h=m.state.length===0&&!r.isLoading,g;t[18]!==u.state||t[19]!==m.state||t[20]!==r.capabilities||t[21]!==r.extras||t[22]!==r.isDisabled||t[23]!==r.isLoading||t[24]!==r.isRunning||t[25]!==r.speech||t[26]!==r.state||t[27]!==r.suggestions||t[28]!==r.voice||t[29]!==h?(g={isEmpty:h,isDisabled:r.isDisabled,isLoading:r.isLoading,isRunning:r.isRunning,capabilities:r.capabilities,state:r.state,suggestions:r.suggestions,extras:r.extras,speech:r.speech,voice:r.voice,composer:u.state,messages:m.state},t[18]=u.state,t[19]=m.state,t[20]=r.capabilities,t[21]=r.extras,t[22]=r.isDisabled,t[23]=r.isLoading,t[24]=r.isRunning,t[25]=r.speech,t[26]=r.state,t[27]=r.suggestions,t[28]=r.voice,t[29]=h,t[30]=g):g=t[30];let _=g,v;t[31]===_?v=t[32]:(v=()=>_,t[31]=_,t[32]=v);let y;t[33]===u.methods?y=t[34]:(y=()=>u.methods,t[33]=u.methods,t[34]=y);let b;t[35]===f?b=t[36]:(b=()=>f.methods,t[35]=f,t[36]=b);let x;t[37]===m?x=t[38]:(x=e=>`id`in e?m.get({key:e.id}):m.get(e),t[37]=m,t[38]=x);let S;t[39]===n?S=t[40]:(S=()=>n,t[39]=n,t[40]=S);let C;return t[41]!==n.append||t[42]!==n.cancelRun||t[43]!==n.connectVoice||t[44]!==n.deleteMessage||t[45]!==n.disconnectVoice||t[46]!==n.export||t[47]!==n.getModelContext||t[48]!==n.getVoiceVolume||t[49]!==n.import||t[50]!==n.importExternalState||t[51]!==n.muteVoice||t[52]!==n.reset||t[53]!==n.resumeRun||t[54]!==n.startRun||t[55]!==n.stopSpeaking||t[56]!==n.subscribeVoiceVolume||t[57]!==n.unmuteVoice||t[58]!==y||t[59]!==b||t[60]!==x||t[61]!==S||t[62]!==v?(C={getState:v,composer:y,suggestions:b,append:n.append,deleteMessage:n.deleteMessage,startRun:n.startRun,resumeRun:n.resumeRun,importExternalState:n.importExternalState,cancelRun:n.cancelRun,getModelContext:n.getModelContext,export:n.export,import:n.import,reset:n.reset,stopSpeaking:n.stopSpeaking,connectVoice:n.connectVoice,disconnectVoice:n.disconnectVoice,getVoiceVolume:n.getVoiceVolume,subscribeVoiceVolume:n.subscribeVoiceVolume,muteVoice:n.muteVoice,unmuteVoice:n.unmuteVoice,message:x,__internal_getRuntime:S},t[41]=n.append,t[42]=n.cancelRun,t[43]=n.connectVoice,t[44]=n.deleteMessage,t[45]=n.disconnectVoice,t[46]=n.export,t[47]=n.getModelContext,t[48]=n.getVoiceVolume,t[49]=n.import,t[50]=n.importExternalState,t[51]=n.muteVoice,t[52]=n.reset,t[53]=n.resumeRun,t[54]=n.startRun,t[55]=n.stopSpeaking,t[56]=n.subscribeVoiceVolume,t[57]=n.unmuteVoice,t[58]=y,t[59]=b,t[60]=x,t[61]=S,t[62]=v,t[63]=C):C=t[63],C}),Ef=(e,t)=>cf(`thread list ${e}`,t),Df=el(e=>{let t=F(35),{runtime:n,mainThreadIsRunning:r}=e,i=r!==void 0&&r,a=af(n),o;bb0:{let e=a.isRunning||a.isMain&&i;if(e===a.isRunning){o=a;break bb0}let n;t[0]!==e||t[1]!==a?(n={...a,isRunning:e},t[0]=e,t[1]=a,t[2]=n):n=t[2],o=n}let s=o,c=ld(),{isMain:l,id:u}=a,d;t[3]!==l||t[4]!==u?(d={isMain:l,threadId:u},t[3]=l,t[4]=u,t[5]=d):d=t[5];let f=I(d),p,m;t[6]!==c||t[7]!==l||t[8]!==u?(p=()=>{let e=f.current;(e.isMain!==l||e.threadId!==u)&&(f.current={isMain:l,threadId:u},c(l?`threadListItem.switchedTo`:`threadListItem.switchedAway`,{threadId:u}))},m=[l,u,c],t[6]=c,t[7]=l,t[8]=u,t[9]=p,t[10]=m):(p=t[9],m=t[10]),L(p,m);let h;t[11]===s?h=t[12]:(h=()=>s,t[11]=s,t[12]=h);let g,_,v,y,b,x,S;t[13]===n?(g=t[14],_=t[15],v=t[16],y=t[17],b=t[18],x=t[19],S=t[20]):(b=e=>Ef(`switch`,()=>n.switchTo(e)),x=e=>Ef(`rename`,()=>n.rename(e)),S=e=>Ef(`update custom metadata`,()=>n.updateCustom(e)),g=()=>Ef(`archive`,()=>n.archive()),_=()=>Ef(`unarchive`,()=>n.unarchive()),v=()=>Ef(`delete`,()=>n.delete()),y=()=>Ef(`generate title`,()=>n.generateTitle()),t[13]=n,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b,t[19]=x,t[20]=S);let C;t[21]===n?C=t[22]:(C=()=>n,t[21]=n,t[22]=C);let w;return t[23]!==n.detach||t[24]!==n.initialize||t[25]!==g||t[26]!==_||t[27]!==v||t[28]!==y||t[29]!==C||t[30]!==h||t[31]!==b||t[32]!==x||t[33]!==S?(w={getState:h,switchTo:b,rename:x,updateCustom:S,archive:g,unarchive:_,delete:v,generateTitle:y,initialize:n.initialize,detach:n.detach,__internal_getRuntime:C},t[23]=n.detach,t[24]=n.initialize,t[25]=g,t[26]=_,t[27]=v,t[28]=y,t[29]=C,t[30]=h,t[31]=b,t[32]=x,t[33]=S,t[34]=w):w=t[34],w}),Of=e=>{let t=F(4),n=ld(),r=I(e),i,a;t[0]!==n||t[1]!==e?(i=()=>{let t=r.current;t!==e&&(r.current=e,n(`threads.selectionChanged`,{threadId:e,previousThreadId:t}))},a=[e,n],t[0]=n,t[1]=e,t[2]=i,t[3]=a):(i=t[2],a=t[3]),L(i,a)},kf=el(e=>{let t=F(6),{runtime:n,id:r,mainThreadIsRunning:i}=e,a;t[0]!==r||t[1]!==n?(a=n.getItemById(r),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o=a,s;return t[3]!==i||t[4]!==o?(s=Df({runtime:o,mainThreadIsRunning:i}),t[3]=i,t[4]=o,t[5]=s):s=t[5],Vl(s)}),Af=el(e=>{let t=F(43),{runtime:n,__internal_assistantRuntime:r}=e,i=af(n);Of(i.mainThreadId);let a;t[0]===n.main?a=t[1]:(a=Tf({runtime:n.main}),t[0]=n.main,t[1]=a);let o=hd(a),s;t[2]!==o.state||t[3]!==n||t[4]!==i.threadItems?(s=Object.keys(i.threadItems).map(e=>tl(e,kf({runtime:n,id:e,mainThreadIsRunning:o.state.isRunning}),[n,e,o.state.isRunning])),t[2]=o.state,t[3]=n,t[4]=i.threadItems,t[5]=s):s=t[5];let c=Jd(s),l=i.newThreadId??null,u;t[6]!==o.state||t[7]!==i.archivedThreadIds||t[8]!==i.hasMore||t[9]!==i.isLoading||t[10]!==i.isLoadingMore||t[11]!==i.mainThreadId||t[12]!==i.threadIds||t[13]!==l||t[14]!==c.state?(u={mainThreadId:i.mainThreadId,newThreadId:l,isLoading:i.isLoading,isLoadingMore:i.isLoadingMore,hasMore:i.hasMore,threadIds:i.threadIds,archivedThreadIds:i.archivedThreadIds,threadItems:c.state,main:o.state},t[6]=o.state,t[7]=i.archivedThreadIds,t[8]=i.hasMore,t[9]=i.isLoading,t[10]=i.isLoadingMore,t[11]=i.mainThreadId,t[12]=i.threadIds,t[13]=l,t[14]=c.state,t[15]=u):u=t[15];let d=u,f;t[16]===d?f=t[17]:(f=()=>d,t[16]=d,t[17]=f);let p;t[18]===o.methods?p=t[19]:(p=()=>o.methods,t[18]=o.methods,t[19]=p);let m;t[20]!==d||t[21]!==c?(m=e=>{if(e===`main`)return c.get({key:d.mainThreadId});if(`id`in e)return c.get({key:e.id});let{index:t,archived:n}=e,r=n!==void 0&&n?d.archivedThreadIds[t]:d.threadIds[t];return c.get({key:r})},t[20]=d,t[21]=c,t[22]=m):m=t[22];let h,g,_,v,y,b;t[23]===n?(h=t[24],g=t[25],_=t[26],v=t[27],y=t[28],b=t[29]):(y=(e,t)=>Ef(`switch`,()=>n.switchToThread(e,t)),b=()=>Ef(`create`,()=>n.switchToNewThread()),h=()=>n.getLoadThreadsPromise(),g=()=>n.reload(),_=()=>n.reloadMainThread(),v=()=>n.loadMore(),t[23]=n,t[24]=h,t[25]=g,t[26]=_,t[27]=v,t[28]=y,t[29]=b);let x;t[30]===r?x=t[31]:(x=()=>r,t[30]=r,t[31]=x);let S;return t[32]!==h||t[33]!==g||t[34]!==_||t[35]!==v||t[36]!==x||t[37]!==f||t[38]!==p||t[39]!==m||t[40]!==y||t[41]!==b?(S={getState:f,thread:p,item:m,switchToThread:y,switchToNewThread:b,getLoadThreadsPromise:h,reload:g,reloadMainThread:_,loadMore:v,__internal_getAssistantRuntime:x},t[32]=h,t[33]=g,t[34]=_,t[35]=v,t[36]=x,t[37]=f,t[38]=p,t[39]=m,t[40]=y,t[41]=b,t[42]=S):S=t[42],S}),jf=(e,t)=>{e.thread??=Kd({source:`threads`,query:{type:`main`},get:e=>e.threads.thread(`main`)}),e.threadListItem??=Kd({source:`threads`,query:{type:`main`},get:e=>e.threads.item(`main`)}),e.composer??=Kd({source:`thread`,query:{},get:e=>e.threads.thread(`main`).composer()}),!e.modelContext&&t.modelContext.source===null&&(e.modelContext=pu()),!e.suggestions&&t.suggestions.source===null&&(e.suggestions=Kd({source:`thread`,query:{},get:e=>e.thread.suggestions()}))},Mf=e=>{let t=F(7),n=od(),r;t[0]!==n||t[1]!==e?(r=()=>e.registerModelContextProvider(n.current.modelContext()),t[0]=n,t[1]=e,t[2]=r):r=t[2];let i;t[3]===e?i=t[4]:(i=[e],t[3]=e,t[4]=i),cd(`modelContext`,r,i);let a;return t[5]===e?a=t[6]:(a=Af({runtime:e.threads,__internal_assistantRuntime:e}),t[5]=e,t[6]=a),Vl(a)},Nf=el(Mf);Ku(Mf,(e,t)=>{jf(e,t),!e.tools&&t.tools.source===null&&(e.tools=ef({})),!e.dataRenderers&&t.dataRenderers.source===null&&(e.dataRenderers=Jl())});var Pf=e=>{let{children:t,condition:n}=e;return R(n)?t:null};Pf.displayName=`AuiIf`;var Ff=typeof process<`u`&&!1,If=_u({}),Lf=({effects:e})=>{"use no memo";return L(e),null},Rf=Gc(function(e,t){"use no memo";let{config:n,children:r}=e,i=`extends`in e,a=`value`in e,o=Uu();if(Ff){if(i&&a)throw Error("AuiProvider: pass either `extends` or `value`, not both.");if(i&&e.extends===void 0)throw Error("AuiProvider: `extends` must be a client or null, not undefined.");if(i&&!n)throw Error("AuiProvider: `extends` requires a `config`.");if(a&&n)throw Error("AuiProvider: pass either `value` or `config`, not both.");if(!a&&!n)throw Error("AuiProvider: a `config` is required.");if(!i&&!a&&o!==Iu)throw Error(`A parent AuiProvider exists — pass extends={aui} to inherit it or extends={null} to isolate.`)}let s=i?e.extends??Iu:a?e.value??Iu:o,{client:c,effects:l}=Rd(s,n??If);return Wc(t,()=>c,[c]),(0,M.jsxs)(Ru.Provider,{value:c,children:[(0,M.jsx)(Lf,{effects:Vu(s)}),l&&(0,M.jsx)(Lf,{effects:l}),r]})}),zf=e=>{let t=zd(),n=I(!1),r=n.current?null:e(t);return R(()=>n.current?e(t):r),()=>(n.current=!0,e(t))},Bf=Object.freeze({});function Vf(e){let t=F(3),{getItemState:n,children:r}=e,i=zf(n),a;return t[0]!==r||t[1]!==i?(a=r(i),t[0]=r,t[1]=i,t[2]=a):a=t[2],Hf(a)}var Hf=e=>{let t=typeof e==`object`&&e&&`type`in e?e:null,n=t?.type,r=t?.key;return Ic(()=>t,[n,r,typeof t?.props==`object`&&t.props!=null&&Object.entries(t.props).length===0?Bf:t?.props])??e},Uf=(e,t)=>{let n=F(11),r=zd(),i=zc(t),a;n[0]===e?a=n[1]:(a=Ju(e),n[0]=e,n[1]=a);let{scope:o,event:s}=a,c;n[2]!==r||n[3]!==i||n[4]!==s||n[5]!==o?(c=()=>r.on({scope:o,event:s},i),n[2]=r,n[3]=i,n[4]=s,n[5]=o,n[6]=c):c=n[6];let l;n[7]!==r||n[8]!==s||n[9]!==o?(l=[r,o,s],n[7]=r,n[8]=s,n[9]=o,n[10]=l):l=n[10],L(c,l)},Wf=e=>e._core?.RenderComponent,Gf=({runtime:e,aui:t,config:n,children:r})=>{"use no memo";let i=Wf(e),a=_u({...n,threads:Nf(e)});return(0,M.jsxs)(Rf,{extends:t,config:a,children:[i&&(0,M.jsx)(i,{}),r]})},Kf=Kc(e=>{let t=F(5),{runtime:n,aui:r,config:i,children:a}=e,o=r===void 0?null:r,s;return t[0]!==o||t[1]!==a||t[2]!==i||t[3]!==n?(s=(0,M.jsx)(Gf,{runtime:n,aui:o,config:i,children:a}),t[0]=o,t[1]=a,t[2]=i,t[3]=n,t[4]=s):s=t[4],s}),qf=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},Jf=(e=>e?qf(e):qf),Yf=e=>e;function Xf(e,t=Yf){let n=_.useSyncExternalStore(e.subscribe,_.useCallback(()=>t(e.getState()),[e,t]),_.useCallback(()=>t(e.getInitialState()),[e,t]));return _.useDebugValue(n),n}var Zf=e=>{let t=Jf(e),n=e=>Xf(t,e);return Object.assign(n,t),n},Qf=(e=>e?Zf(e):Zf);function $f(e){return e}function ep(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function tp(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(e=>tp(e,t+1)):ep(e)?Object.entries(e).every(([e,n])=>typeof e==`string`&&tp(n,t+1)):!1}var np=100,rp=(e,t,n)=>{if(e===t)return!0;if(n>np||e==null||t==null)return!1;if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:e.every((e,r)=>rp(e,t[r],n+1));if(Array.isArray(t)||!ep(e)||!ep(t))return!1;let r=Object.keys(e),i=Object.keys(t);return r.length===i.length&&r.every(r=>Object.hasOwn(t,r)&&rp(e[r],t[r],n+1))},ip=(e,t)=>!tp(e)||!tp(t)?!1:rp(e,t,0);function ap(e){let t=e.metadata;if(!t||typeof t!=`object`)return;let n=t.custom;if(!n||typeof n!=`object`)return;let r=n.interactables;return Array.isArray(r)?r:void 0}function op(e){return`update_${e.replace(/[^a-zA-Z0-9_-]/g,`_`)}`}var sp=e=>{if(!ep(e))return;let t=e.id;return typeof t==`string`||typeof t==`number`?t:void 0};function cp(e,t,n){let r=Array.isArray(t.set)?[...t.set]:[...e];if(t.clear===!0&&(r=[]),Array.isArray(t.remove)&&t.remove.length>0){let e=new Set(t.remove);r=r.filter(t=>{let n=sp(t);return n===void 0?!e.has(t):!e.has(n)})}let i=t.update;if(Array.isArray(i)&&i.length>0&&(r=r.map(e=>{let t=sp(e);if(t===void 0||!ep(e))return e;let n=i.find(e=>ep(e)&&e.id===t);return n?{...e,...n}:e})),Array.isArray(t.add)&&t.add.length>0){let e=n?t.add.map(e=>{if(!ep(e)||e.id!==void 0)return e;let t=n();return t===void 0?e:{...e,id:t}}):t.add;r=[...r,...e]}return r}function lp(e,t,n){if(!ep(e)||!ep(t))return t;let r=ep(n?.arrayBaseline)?n.arrayBaseline:e,i={...e};for(let[e,a]of Object.entries(t)){let t=r[e];i[e]=Array.isArray(t)&&ep(a)?cp(t,a,n?.idFactory&&(n.idKeyedFields===void 0||n.idKeyedFields.has(e))?()=>n.idFactory?.(e):void 0):a}return i}function up(e,t){if(!ep(e)||!ep(t))return;for(let n of Object.keys(e))if(!(n in t))return;let n={};for(let[r,i]of Object.entries(t))(!(r in e)||!ip(e[r],i))&&(n[r]=i);let r=Object.keys(n).length;if(r!==0&&r!==Object.keys(t).length)return n}var dp=e=>{if(!e||typeof e!=`object`)return;let t=e;return t.type===`tool-call`?t:void 0},fp=(e,t)=>{if(!e.args||typeof e.args!=`object`)return!1;let n=ep(e.result)?e.result:void 0;if(n?.success===!1)return!1;if(typeof n?.id==`string`)return n.id===t;let r=e.args.id;return r===t||r===void 0},pp=e=>{let t=ep(e)?e.addedItemIds:void 0;if(!ep(t))return;let n=new Map;for(let[e,r]of Object.entries(t)){if(!Array.isArray(r))continue;let t=r.filter(e=>typeof e==`string`);t.length>0&&n.set(e,t)}if(n.size!==0)return e=>n.get(e)?.shift()},mp=new WeakMap;function hp(e,t,n){let r=mp.get(e);r||(r=new Map,mp.set(e,r));let i=r.get(n);i||(i=new Map,r.set(n,i));let a=i.get(t);if(a)return a;let o=op(n),s=[],c=()=>s[s.length-1];for(let r of e){if(r.role===`user`){let e=ap(r)?.find(e=>e.id===t);if(!e)continue;if(e.partial){let t=c();t&&s.push({state:lp(t.state,e.state),origin:`user-edit`})}else s.push({state:e.state,origin:`user-edit`});continue}if(r.role===`assistant`)for(let e of r.content??[]){let r=dp(e);if(r){if(r.toolCallId===t&&r.toolName===n)r.args&&typeof r.args==`object`&&s.push({state:r.args,origin:`create`,toolCallId:t});else if(r.toolName===o&&fp(r,t)){let e=c();if(e){let{id:t,...n}=r.args,i=pp(r.result);s.push({state:i?lp(e.state,n,{idFactory:i}):lp(e.state,n),origin:`update`,toolCallId:r.toolCallId})}}}}}return i.set(t,s),s}function gp(e,t,n){let r=hp(e,t,n),i=r[r.length-1];return i?{state:i.state}:void 0}function _p(e,t){if(!e)return;let{interactables:n,...r}=e,i={...r};if(Array.isArray(n)){let e=[];for(let r of n){let n=gp(t,r.id,r.name);if(!n){e.push({id:r.id,name:r.name,state:r.state});continue}if(ip(r.state,n.state))continue;let i=up(n.state,r.state);e.push(i?{id:r.id,name:r.name,state:i,partial:!0}:{id:r.id,name:r.name,state:r.state})}e.length&&(i.interactables=e)}return Object.keys(i).length?i:void 0}var vp={toResponse(e,t){return new Response(vp.toByteStream(e,t),{headers:t.headers??{}})},fromResponse(e,t){return vp.fromByteStream(e.body,t)},toByteStream(e,t){return e.pipeThrough(t)},fromByteStream(e,t){return e.pipeThrough(t)}},yp=()=>{let e,t,n=new Promise((n,r)=>{e=n,t=r});if(!e||!t)throw Error(`Failed to create promise`);return{promise:n,resolve:e,reject:t}},bp=()=>{let e=[],t=!1,n=!1,r=!1,i,a,o,s=()=>(o??=Promise.all(e.splice(0).map(async e=>{try{await e.reader.cancel().catch(()=>void 0),await e.pipeTask}finally{e.reader.releaseLock()}})).then(()=>void 0),o),c=o=>{o.promise||=o.reader.read().then(({done:s,value:c})=>{o.promise=void 0,!(n||r)&&(s?(e.splice(e.indexOf(o),1),o.reader.releaseLock(),t&&e.length===0&&i.close()):i.enqueue(c),a?.resolve(),a=void 0)}).catch(e=>{n||r||(r=!0,console.error(e),s(),i.error(e),a?.reject(e),a=void 0)})};return{readable:new ReadableStream({start(e){i=e},pull(){return a=yp(),e.forEach(e=>{c(e)}),a.promise},async cancel(){n=!0;let e=s();a?.resolve(),a=void 0,await e}}),isSealed(){return t},isCancelled(){return n},isErrored(){return r},seal(){n||r||(t=!0,e.length===0&&i.close())},addStream(i,a){let o=a?.catch(()=>void 0);if(n||r){i.cancel().catch(()=>void 0);return}if(t)throw i.cancel().catch(()=>void 0),Error(`Cannot add streams after the run callback has settled.`);let s={reader:i.getReader(),pipeTask:o};e.push(s),c(s)},enqueue(e){this.addStream(new ReadableStream({start(t){t.enqueue(e),t.close()}}))}}},xp=class{_controller;_strict;_isClosed=!1;_warnedDropped=!1;constructor(e,t={}){this._controller=e,this._strict=t.strict??!0}append(e){let t={type:`text-delta`,path:[],textDelta:e};if(this._strict)return this._controller.enqueue(t),this;try{this._controller.enqueue(t)}catch(e){this._warnedDropped||(this._warnedDropped=!0,console.error(`Dropped text delta for closed stream: ${String(e)}`))}return this}close(){this._isClosed||(this._isClosed=!0,this._controller.enqueue({type:`part-finish`,path:[]}),this._controller.close())}},Sp=(e,t={})=>new ReadableStream({start(n){return e.start?.(new xp(n,t))},pull(n){return e.pull?.(new xp(n,t))},cancel(t){return e.cancel?.(t)}}),Cp=(e={})=>{let t;return[Sp({start(e){t=e}},e),t]},wp=Symbol.for(`aui.tool-response`),Tp=`<no result>`,Ep=class e{get[wp](){return!0}artifact;result;isError;modelContent;messages;constructor(e){e.artifact!==void 0&&(this.artifact=e.artifact);let t=e.result;this.result=t===void 0?Tp:t,this.isError=e.isError??!1,e.modelContent!==void 0&&(this.modelContent=e.modelContent),e.messages!==void 0&&(this.messages=e.messages)}static[Symbol.hasInstance](e){return typeof e==`object`&&!!e&&wp in e}static toResponse(t){return t instanceof e?t:new e({result:t===void 0?Tp:t})}},Dp=class{_isClosed=!1;_mergeTask;_controller;constructor(e){this._controller=e;let t=Sp({start:e=>{this._argsTextController=e}}),n=!1;this._mergeTask=t.pipeTo(new WritableStream({write:e=>{switch(e.type){case`text-delta`:n=!0,this._controller.enqueue(e);break;case`part-finish`:n||this._controller.enqueue({type:`text-delta`,textDelta:`{}`,path:[]}),this._controller.enqueue({type:`tool-call-args-text-finish`,path:[]});break;default:throw Error(`Unexpected chunk type: ${e.type}`)}}}))}get argsText(){return this._argsTextController}_argsTextController;async setResponse(e){if(this._isClosed)return;let t=e.result;this._controller.enqueue({type:`result`,path:[],...e.artifact===void 0?{}:{artifact:e.artifact},result:t===void 0?Tp:t,isError:e.isError??!1,...e.modelContent===void 0?{}:{modelContent:e.modelContent},...e.messages===void 0?{}:{messages:e.messages}}),await this.close()}async close(){this._isClosed||(this._isClosed=!0,this._argsTextController.close(),await this._mergeTask,this._controller.enqueue({type:`part-finish`,path:[]}),this._controller.close())}},Op=e=>new ReadableStream({start(t){return e.start?.(new Dp(t))},pull(t){return e.pull?.(new Dp(t))},cancel(t){return e.cancel?.(t)}}),kp=()=>{let e;return[Op({start(t){e=t}}),e]},Ap=class{value=-1;up(){return++this.value}},jp=class extends TransformStream{constructor(e){super({transform(t,n){n.enqueue({...t,path:[e,...t.path]})}})}};TransformStream;var Mp=class extends TransformStream{constructor(e){let t=new Ap,n=new Map;super({transform(r,i){r.type===`part-start`&&r.path.length===0&&n.set(t.up(),e.up());let[a,...o]=r.path;if(a===void 0){i.enqueue(r);return}let s=n.get(a);if(s===void 0)throw Error(`Path not found`);i.enqueue({...r,path:[s,...o]})}})}},Np=class extends TransformStream{constructor(e){super();let t=e(super.readable);Object.defineProperty(this,"readable",{value:t,writable:!1})}},Pp=o(((e,t)=>{var n=typeof Buffer<`u`,r=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,i=/"(?: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 a(e,t,a){a==null&&typeof t==`object`&&t&&(a=t,t=void 0),n&&Buffer.isBuffer(e)&&(e=e.toString()),e&&e.charCodeAt(0)===65279&&(e=e.slice(1));let s=JSON.parse(e,t);if(typeof s!=`object`||!s)return s;let c=a&&a.protoAction||`error`,l=a&&a.constructorAction||`error`;if(c===`ignore`&&l===`ignore`)return s;if(c!==`ignore`&&l!==`ignore`){if(r.test(e)===!1&&i.test(e)===!1)return s}else if(c!==`ignore`&&l===`ignore`){if(r.test(e)===!1)return s}else if(i.test(e)===!1)return s;return o(s,{protoAction:c,constructorAction:l,safe:a&&a.safe})}function o(e,{protoAction:t=`error`,constructorAction:n=`error`,safe:r}={}){let i=[e];for(;i.length;){let e=i;i=[];for(let a of e){if(t!==`ignore`&&Object.prototype.hasOwnProperty.call(a,`__proto__`)){if(r===!0)return null;if(t===`error`)throw SyntaxError(`Object contains forbidden prototype property`);delete a.__proto__}if(n!==`ignore`&&Object.prototype.hasOwnProperty.call(a,`constructor`)&&a.constructor!==null&&typeof a.constructor==`object`&&Object.prototype.hasOwnProperty.call(a.constructor,`prototype`)){if(r===!0)return null;if(n===`error`)throw SyntaxError(`Object contains forbidden prototype property`);delete a.constructor}for(let e in a){let t=a[e];t&&typeof t==`object`&&i.push(t)}}}return e}function s(e,t,n){let{stackTraceLimit:r}=Error;Error.stackTraceLimit=0;try{return a(e,t,n)}finally{Error.stackTraceLimit=r}}function c(e,t){let{stackTraceLimit:n}=Error;Error.stackTraceLimit=0;try{return a(e,t,{safe:!0})}catch{return}finally{Error.stackTraceLimit=n}}t.exports=s,t.exports.default=s,t.exports.parse=s,t.exports.safeParse=c,t.exports.scan=o})),Fp=class extends TransformStream{constructor(){let e=[];super({transform(t,n){if(t.type===`part-start`){if(t.path.length!==0){n.error(Error(`Nested parts are not supported`));return}e.push(t.part),n.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){n.error(Error(`${t.type} chunks must have a path of length 1`));return}let r=t.path[0];if(r<0||r>=e.length){n.error(Error(`Invalid path index: ${r}`));return}let i=e[r];n.enqueue({...t,meta:i});return}n.enqueue(t)}})}},Ip=((e,t=21)=>(n=t)=>{let r=``,i=n|0;for(;i-->0;)r+=e[Math.random()*e.length|0];return r})(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,7),Lp=class e{_state;_parentId;constructor(e,t={}){this._state=e||{strict:t.strict??!0,merger:bp(),contentCounter:new Ap}}get __internal_isClosed(){return this._state.merger.isSealed()||this._state.merger.isCancelled()||this._state.merger.isErrored()}get __internal_isCancelled(){return this._state.merger.isCancelled()}__internal_getReadable(){return this._state.merger.readable}__internal_subscribeToClose(e){this._state.closeSubscriber=e}_addTransformedStream(e,t){if(e.locked)throw TypeError(`Cannot merge a stream that is already locked to a reader.`);let n=e.pipeTo(t.writable).catch(async e=>{throw await t.writable.abort(e).catch(()=>void 0),e});this._state.merger.addStream(t.readable,n)}_addPart(e,t){this._state.append&&(this._state.append.controller.close(),this._state.append=void 0),this.enqueue({type:`part-start`,part:e,path:[]}),this._addTransformedStream(t,new jp(this._state.contentCounter.value))}merge(e){this._addTransformedStream(e,new Mp(this._state.contentCounter))}appendText(e){(this._state.append?.kind!==`text`||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:`text`,parentId:this._parentId,controller:this.addTextPart()}),this._state.append.controller.append(e)}appendReasoning(e,t){(t!==void 0||this._state.append?.kind!==`reasoning`||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:`reasoning`,parentId:this._parentId,controller:this.addReasoningPart(t)}),(t===void 0||e.length!==0)&&this._state.append.controller.append(e)}addTextPart(){let[e,t]=Cp({strict:this._state.strict});return this._addPart(this._withParentIdOption({type:`text`}),e),t}addReasoningPart(e){let[t,n]=Cp({strict:this._state.strict});return this._addPart(this._withParentIdOption({type:`reasoning`,...e}),t),n}addToolCallPart(e){let t=typeof e==`string`?{toolName:e}:e,n=t.toolName,r=t.toolCallId??Ip(),[i,a]=kp();return this._addPart({type:`tool-call`,toolName:n,toolCallId:r,...this._parentId&&{parentId:this._parentId}},i),t.argsText!==void 0&&(a.argsText.append(t.argsText),a.argsText.close()),t.args!==void 0&&(a.argsText.append(JSON.stringify(t.args)),a.argsText.close()),t.response!==void 0&&a.setResponse(t.response),a}_finishedPartStream(){return new ReadableStream({start(e){e.enqueue({type:`part-finish`,path:[]}),e.close()}})}_withParentIdOption(e){return this._parentId?{...e,parentId:this._parentId}:e}appendSource(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}appendFile(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}appendData(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}enqueue(e){this._state.merger.enqueue(e),e.type===`part-start`&&e.path.length===0&&this._state.contentCounter.up()}withParentId(t){let n=new e(this._state);return n._parentId=t,n}close(){this._state.append?.controller?.close(),this._state.merger.seal(),this._state.closeSubscriber?.()}};function Rp(e,t={}){let n=new Lp(void 0,t);return(async()=>{try{await e(n)}catch(e){n.__internal_isClosed?n.__internal_isCancelled||console.error(e):n.enqueue({type:`error`,path:[],error:String(e)})}finally{n.__internal_isClosed||n.close()}})(),n.__internal_getReadable()}function zp(e={}){let{resolve:t,promise:n}=yp(),r;return[Rp(e=>(r=e,r.__internal_subscribeToClose(t),n),e),r]}var Bp=class extends TransformStream{constructor(e,t,n){let[r,i]=zp({strict:e.strict}),a;super({start(t){return a=r.pipeTo(new WritableStream({write(e){t.enqueue(e)},abort(e){t.error(e)},close(){t.terminate()}})).catch(e=>{t.error(e)}),e.start?.(i)},transform(t){return e.transform?.(t,i)},async flush(){await e.flush?.(i),i.close(),await a}},t,n)}};function Vp(e){let t=[`ROOT`],n=-1,r=null,i=[],a;function o(){a!==void 0&&(i.push(JSON.parse(`"${a}"`)),a=void 0)}function s(e,i,a){switch(e){case`"`:n=i,t.pop(),t.push(a),t.push(`INSIDE_STRING`),o();break;case`f`:case`t`:case`n`:n=i,r=i,t.pop(),t.push(a),t.push(`INSIDE_LITERAL`);break;case`-`:t.pop(),t.push(a),t.push(`INSIDE_NUMBER`),o();break;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=i,t.pop(),t.push(a),t.push(`INSIDE_NUMBER`),o();break;case`{`:n=i,t.pop(),t.push(a),t.push(`INSIDE_OBJECT_START`),o();break;case`[`:n=i,t.pop(),t.push(a),t.push(`INSIDE_ARRAY_START`),o()}}function c(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_COMMA`);break;case`}`:n=r,t.pop(),a=i.pop()}}function l(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`),a=(Number(a)+1).toString();break;case`]`:n=r,t.pop(),a=i.pop()}}for(let o=0;o<e.length;o++){let u=e[o];switch(t[t.length-1]){case`ROOT`:s(u,o,`FINISH`);break;case`INSIDE_OBJECT_START`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`),a=``;break;case`}`:n=o,t.pop(),a=i.pop()}break;case`INSIDE_OBJECT_AFTER_COMMA`:u===`"`&&(t.pop(),t.push(`INSIDE_OBJECT_KEY`),a=``);break;case`INSIDE_OBJECT_KEY`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_KEY`);break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`),a+=u;break;default:a+=u}break;case`INSIDE_OBJECT_AFTER_KEY`:u===`:`&&(t.pop(),t.push(`INSIDE_OBJECT_BEFORE_VALUE`));break;case`INSIDE_OBJECT_BEFORE_VALUE`:s(u,o,`INSIDE_OBJECT_AFTER_VALUE`);break;case`INSIDE_OBJECT_AFTER_VALUE`:c(u,o);break;case`INSIDE_STRING`:switch(u){case`"`:t.pop(),n=o,a=i.pop();break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`);break;default:n=o}break;case`INSIDE_ARRAY_START`:switch(u){case`]`:n=o,t.pop(),a=i.pop();break;default:a=`0`,s(u,o,`INSIDE_ARRAY_AFTER_VALUE`)}break;case`INSIDE_ARRAY_AFTER_VALUE`:switch(u){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`),a=(Number(a)+1).toString();break;case`]`:n=o,t.pop(),a=i.pop();break;default:n=o}break;case`INSIDE_ARRAY_AFTER_COMMA`:s(u,o,`INSIDE_ARRAY_AFTER_VALUE`);break;case`INSIDE_STRING_ESCAPE`:t.pop(),t[t.length-1]===`INSIDE_STRING`?n=o:t[t.length-1]===`INSIDE_OBJECT_KEY`&&(a+=u);break;case`INSIDE_NUMBER`:switch(u){case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=o;break;case`e`:case`E`:case`-`:case`.`:break;case`,`:t.pop(),a=i.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&l(u,o),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&c(u,o);break;case`}`:t.pop(),a=i.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&c(u,o);break;case`]`:t.pop(),a=i.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&l(u,o);break;default:t.pop(),a=i.pop()}break;case`INSIDE_LITERAL`:{let i=e.substring(r,o+1);!`false`.startsWith(i)&&!`true`.startsWith(i)&&!`null`.startsWith(i)?(t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`?c(u,o):t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&l(u,o)):n=o;break}}}let u=e.slice(0,n+1);for(let n=t.length-1;n>=0;n--)switch(t[n]){case`INSIDE_STRING`:u+=`"`;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`:u+=`}`;break;case`INSIDE_ARRAY_START`:case`INSIDE_ARRAY_AFTER_COMMA`:case`INSIDE_ARRAY_AFTER_VALUE`:u+=`]`;break;case`INSIDE_LITERAL`:{let t=e.substring(r,e.length);`true`.startsWith(t)?u+=`true`.slice(t.length):`false`.startsWith(t)?u+=`false`.slice(t.length):`null`.startsWith(t)&&(u+=`null`.slice(t.length))}}return[u,i]}var Hp=c(Pp(),1),Up=Symbol(`aui.parse-partial-json-object.meta`),Wp=e=>e?.[Up],Gp=e=>{if(e.length===0)return{[Up]:{state:`partial`,partialPath:[]}};try{let t=Hp.default.parse(e);if(typeof t!=`object`||!t)throw Error(`argsText is expected to be an object`);return t[Up]={state:`complete`,partialPath:[]},t}catch{try{let[t,n]=Vp(e),r=Hp.default.parse(t);if(typeof r!=`object`||!r)throw Error(`argsText is expected to be an object`);return r[Up]={state:`partial`,partialPath:n},r}catch{return}}},Kp=(e,t,n)=>{if(typeof e!=`object`||!e)return t.state;if(t.state===`complete`)return`complete`;if(n.length===0)return t.state;let[r,...i]=n;if(!Object.hasOwn(e,r))return`partial`;let[a,...o]=t.partialPath;if(r!==a)return`complete`;let s=e[r];return Kp(s,{state:`partial`,partialPath:o},i)},qp=(e,t)=>{let n=Wp(e);if(!n)throw Error(`unable to determine object state`);return Kp(e,n,t.map(String))};async function*Jp(){let e=this.getReader(),t=!0;try{for(;;){let n;try{n=await e.read()}catch(e){throw t=!1,e}if(n.done){t=!1;break}let{value:r}=n;yield r}}finally{try{t&&await e.cancel()}finally{e.releaseLock()}}}function Yp(e){return e[Symbol.asyncIterator]??=Jp,e}var Xp=Zc(null),Zp=(e,t)=>nc(Xp,e,t),Qp=()=>$c(Xp),$p={},em=e=>{let t=vd(e??$p);return e==null?null:t},tm=((e,t=21)=>(n=t)=>{let r=``,i=n|0;for(;i-->0;)r+=e[Math.random()*e.length|0];return r})(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,7),nm=`__error__`,rm=()=>`${nm}${tm()}`,im=/^https?:\/\//i;function am(e){let t=e.match(/^data:([^;,]+)(?:;[^;,]+)*;base64,(.*)$/i);return t?{mimeType:t[1].toLowerCase(),data:t[2]}:null}function om(e){try{return new URL(e),!0}catch{return!1}}function sm(e){return/^data:([^;,]+)(?:[;,])/i.exec(e)?.[1]?.toLowerCase()}var cm=(e,t)=>{if(e.startsWith(`data-`))return{type:`data`,name:e.substring(5),data:t}},lm=(e,t,n)=>{let{role:r,id:i,createdAt:a,attachments:o,status:s,metadata:c}=e,l={id:i??t,createdAt:a??new Date},u=typeof e.content==`string`?[{type:`text`,text:e.content}]:e.content,d=({image:e,...t})=>typeof e==`string`?am(e)?.mimeType.startsWith(`image/`)||/^(https:\/\/|blob:)/i.test(e)?{...t,image:e}:(console.warn(`Invalid image data format detected`),null):null;if(r!==`user`&&o?.length)throw Error(`attachments are only supported for user messages`);if(r!==`assistant`&&s)throw Error(`status is only supported for assistant messages`);if(r!==`assistant`&&c?.steps)throw Error(`metadata.steps is only supported for assistant messages`);switch(r){case`assistant`:return{...l,role:r,content:u.map(e=>{let t=e.type;switch(t){case`text`:return e.text?.trim()?e:null;case`reasoning`:return!e.text?.trim()&&!e.unstable_summary?.trim()?null:e;case`file`:case`source`:return e;case`image`:return d(e);case`data`:return e;case`generative-ui`:return e;case`tool-call`:{let{parentId:t,messages:n,...r}=e,i={...r,toolCallId:e.toolCallId??`tool-${tm()}`,...t!==void 0&&{parentId:t},...n!==void 0&&{messages:n}};return e.args?{...i,args:e.args,argsText:e.argsText??JSON.stringify(e.args)}:{...i,args:Gp(e.argsText??``)??{},argsText:e.argsText??``}}default:{let n=cm(t,e.data);if(n)return n;throw Error(`Unsupported assistant message part type: ${t}`)}}}).filter(e=>!!e),status:s??n,metadata:{unstable_state:c?.unstable_state??null,unstable_annotations:c?.unstable_annotations??[],unstable_data:c?.unstable_data??[],custom:c?.custom??{},steps:c?.steps??[],...c?.timing&&{timing:c.timing},...c?.submittedFeedback&&{submittedFeedback:c.submittedFeedback},...c?.isOptimistic&&{isOptimistic:!0}}};case`user`:return{...l,role:r,content:u.map(e=>{let t=e.type;switch(t){case`text`:case`image`:case`audio`:case`file`:case`data`:return e;default:{let n=cm(t,e.data);if(n)return n;throw Error(`Unsupported user message part type: ${t}`)}}}),attachments:(o??[]).map(e=>({...e,content:e.content.map(e=>cm(e.type,e.data)??e)})),metadata:{custom:c?.custom??{},...c?.isOptimistic&&{isOptimistic:!0}}};case`system`:if(u.length!==1||u[0].type!==`text`)throw Error(`System messages must have exactly one text message part.`);return{...l,role:r,content:u,metadata:{custom:c?.custom??{}}};default:throw Error(`Unknown message role: ${r}`)}},um=Symbol(`innerMessage`),dm=Symbol(`innerMessages`),fm=[],pm=(e,t)=>{um in e||(e[um]=t)},mm=e=>{let t=`messages`in e?e.messages:e,n=t[dm]||t[um];return n?Array.isArray(n)?n:(t[dm]=[n],t[dm]):fm},hm=Symbol(`autoStatus`),gm=Object.freeze(Object.assign({type:`running`},{[hm]:!0})),_m=Object.freeze(Object.assign({type:`complete`,reason:`unknown`},{[hm]:!0})),vm=Object.freeze(Object.assign({type:`requires-action`,reason:`tool-calls`},{[hm]:!0})),ym=Object.freeze(Object.assign({type:`requires-action`,reason:`interrupt`},{[hm]:!0})),bm=e=>e[hm]===!0,xm=(e,t,n,r,i)=>e&&i?Object.assign({type:`incomplete`,reason:`error`,error:i},{[hm]:!0}):e&&t?gm:n?ym:r?vm:_m,Sm=class{cache=new WeakMap;convertMessages(e,t){return e.map((e,n)=>{let r=t(this.cache.get(e),e,n);return this.cache.set(e,r),r})}},Cm=e=>e.type===`tool-call`&&e.result===void 0,wm=e=>e.type!==`tool-call`||e.result!==void 0?!1:e.interrupt!=null||e.approval!=null&&e.approval.approved===void 0&&e.approval.resolution===void 0,Tm=e=>{let t;try{t=e instanceof Error?String(e):JSON.stringify(e)}catch{}return t??=String(e),t.length>200?`${t.slice(0,200)}…`:t},Em=(e,t)=>{let n=Array.isArray(e)?e:[e];for(let e of n)if(!(typeof e==`object`&&e&&(e.role===`tool`||(e.role===`assistant`||e.role===`user`||e.role===`system`)&&(typeof e.content==`string`||Array.isArray(e.content)))))throw Error(`External message converter: the converter callback returned an invalid message (${Tm(e)}) for input ${Tm(t)}. Return an empty array to skip a message.`);return n},Dm=(e,t)=>({[um]:[...e[um]??[],...t[um]??[]]}),Om=e=>{let t={role:`assistant`,content:[]};for(let n of e)if(n.role===`tool`){let e=t.content.findIndex(e=>e.type===`tool-call`&&e.toolCallId===n.toolCallId);if(e!==-1){let r=t.content[e];if(n.toolName!=null&&r.toolName!==n.toolName)throw Error(`Tool call name ${n.toolCallId} ${n.toolName} does not match existing tool call ${r.toolName}`);t.content[e]={...r,[um]:[...r[um]??[],n],result:n.result,artifact:n.artifact,isError:n.isError,messages:n.messages}}}else{let e=n.role,r=(typeof n.content==`string`?[{type:`text`,text:n.content}]:n.content).map(e=>({...e,[um]:[n]}));switch(e){case`system`:case`user`:return{...n,content:r};case`assistant`:t.content.length===0&&(t.id=n.id,t.createdAt??=n.createdAt,t.status??=n.status,n.attachments&&(t.attachments=[...t.attachments??[],...n.attachments])),n.metadata&&(t.metadata??={},n.metadata.unstable_state!==void 0&&(t.metadata.unstable_state=n.metadata.unstable_state),n.metadata.unstable_annotations&&(t.metadata.unstable_annotations=[...t.metadata.unstable_annotations??[],...n.metadata.unstable_annotations]),n.metadata.unstable_data&&(t.metadata.unstable_data=[...t.metadata.unstable_data??[],...n.metadata.unstable_data]),n.metadata.steps&&(t.metadata.steps=[...t.metadata.steps??[],...n.metadata.steps]),n.metadata.custom&&(t.metadata.custom={...t.metadata.custom??{},...n.metadata.custom}),n.metadata.timing&&(t.metadata.timing=n.metadata.timing),n.metadata.submittedFeedback&&(t.metadata.submittedFeedback=n.metadata.submittedFeedback),n.metadata.isOptimistic&&(t.metadata.isOptimistic=!0));for(let e of r){if(e.type===`tool-call`){let n=t.content.findIndex(t=>t.type===`tool-call`&&t.toolCallId===e.toolCallId);if(n!==-1){let r=t.content[n];t.content[n]={...r,...e,...Dm(r,e)};continue}}if(e.type===`reasoning`&&`parentId`in e&&e.parentId){let n=t.content.findIndex(t=>t.type===`reasoning`&&`parentId`in t&&t.parentId===e.parentId);if(n!==-1){let r=t.content[n];t.content[n]={...r,text:`${r.text}\n\n${e.text}`,...Dm(r,e)};continue}}t.content.push(e)}break;default:throw Error(`Unknown message role: ${e}`)}}return t},km=(e,t)=>{let n=[],r=!1,i=!1,a=[],o=[],s=()=>{o.length&&n.push({inputs:a,outputs:o}),a=[],o=[],r=!1,i=!1};for(let n of e)for(let e of n.outputs)(i&&e.role!==`tool`||!r||e.role===`user`||e.role===`system`)&&s(),r=e.role===`assistant`||e.role===`tool`,a.at(-1)!==n.input&&a.push(n.input),o.push(e),e.role===`assistant`&&(e.convertConfig?.joinStrategy===`none`||t===`none`)&&(i=!0);return s(),n};function Am(e){let t={id:rm(),role:`assistant`,content:[],status:{type:`incomplete`,reason:`error`,error:e},createdAt:new Date,metadata:{unstable_state:null,unstable_annotations:[],unstable_data:[],custom:{},steps:[]}};return pm(t,[]),t}var jm=(e,t,n,r)=>{let i=[];for(let n of e){let e={input:n,outputs:Em(t(n,r),n)};i.push(e)}let a=km(i),o=a.map((e,t)=>{let i=t===a.length-1,o=Om(e.outputs),s=xm(i,n,typeof o.content==`object`&&o.content.some(wm),typeof o.content==`object`&&o.content.some(Cm),i?r.error:void 0),c=lm(o,t.toString(),s);return pm(c,e.inputs),c});if(r.error){let e=o.at(-1);(!e||e.role!==`assistant`)&&o.push(Am(r.error))}return o},Mm=e=>{let t=F(13),{callback:n,messages:r,isRunning:i,joinStrategy:a,metadata:o}=e,[s]=Pc(Pm),c;t[0]===o?c=t[1]:(c=o??{},t[0]=o,t[1]=c);let l;t[2]!==s||t[3]!==n||t[4]!==c?(l={metadata:c,callback:n,...s},t[2]=s,t[3]=n,t[4]=c,t[5]=l):l=t[5];let u=l,d;if(t[6]!==i||t[7]!==a||t[8]!==r||t[9]!==u){let e=[];for(let t of r){let n=u.callbackCache.get(t);(!n||n.metadata!==u.metadata||n.callback!==u.callback)&&(n={input:t,outputs:Em(u.callback(t,u.metadata),t),metadata:u.metadata,callback:u.callback},u.callbackCache.set(t,n)),e.push(n)}let n;t[11]===u.chunkCache?n=t[12]:(n=e=>{let t=e.outputs[0];if(!t)return e;let n=u.chunkCache.get(t);return n&&Nm(n.outputs,e.outputs)?n:(u.chunkCache.set(t,e),e)},t[11]=u.chunkCache,t[12]=n);let o=km(e,a).map(n);if(d=u.converterCache.convertMessages(o,(e,t,n)=>{let r=n===o.length-1,a=Om(t.outputs),s=typeof a.content==`object`&&a.content.some(wm),c=typeof a.content==`object`&&a.content.some(Cm),l=xm(r,i,s,c,r?u.metadata.error:void 0);if(e&&(e.role!==`assistant`||!bm(e.status)||e.status===l)&&Nm(mm(e),t.inputs))return e;let d=lm(a,n.toString(),l);return pm(d,t.inputs),d}),pm(d,r),u.metadata.error){let e=d.at(-1);(!e||e.role!==`assistant`)&&d.push(Am(u.metadata.error))}t[6]=i,t[7]=a,t[8]=r,t[9]=u,t[10]=d}else d=t[10];return d},Nm=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0};function Pm(){return{callbackCache:new WeakMap,chunkCache:new WeakMap,converterCache:new Sm}}var Fm=e=>Math.ceil(e/4),Im=(e,t,n)=>t<=e.lastContentLength?e:{...e,firstTokenTime:e.firstTokenTime??n()-e.startTime,lastContentLength:t,totalChunks:e.totalChunks+1},Lm=(e,t,n,r,i,a=Date.now)=>{let o=r.getAssistantMessageId(t),s=i?.estimateTokens??Fm;if(n&&o!==void 0){let n;return n=e===null||e.messageId!==o?{messageId:o,startTime:a(),lastContentLength:0,totalChunks:0}:e,{state:Im(n,r.getTextLength(t,n.messageId),a),timings:{}}}if(!n&&e!==null){let n=a(),i=Im(e,r.getTextLength(t,e.messageId),()=>n),o=n-i.startTime,c=s(i.lastContentLength),l=r.getToolCallCount(t,i.messageId),u={streamStartTime:i.startTime,totalStreamTime:o,totalChunks:i.totalChunks,toolCallCount:l,...i.firstTokenTime!==void 0&&{firstTokenTime:i.firstTokenTime},...c>0&&{tokenCount:c},...o>0&&c>0&&{tokensPerSecond:c/(o/1e3)}};return{state:null,timings:{[i.messageId]:u}}}return{state:e,timings:{}}},Rm=(e,t,n,r)=>{let[i,a]=Pc({}),o=I(null),s=I(n);s.current=n;let c=I(r);return c.current=r,L(()=>{let n=Lm(o.current,e,t,s.current,c.current);o.current=n.state,Object.keys(n.timings).length>0&&a(e=>({...e,...n.timings}))},[e,t]),i},zm=new Set([`__proto__`,`constructor`,`prototype`]);function Bm(e){if(zm.has(e))throw Error(`Unsafe gorp path segment: ${e}`)}var Vm=class{_state;_strict;_logged=new Set;_warnedClamp=!1;constructor(e=null,t={}){this._state=e,this._strict=t.strict??!0}get state(){return this._state}logOnce(e,t){this._logged.has(e)||this._logged.size>=20||(this._logged.add(e),t())}append(e){this._state=e.reduce((e,t)=>{if(this._strict)return this.apply(e,t);try{return this.apply(e,t)}catch(n){return this.logOnce(`skip:${String(n)}`,()=>console.error(`Skipped unappliable gorp operation: ${String(n)}`,t)),e}},this._state)}apply(e,t){let n=t.type;switch(n){case`set`:return this.updatePath(e,t.path,()=>t.value);case`append-text`:return this.updatePath(e,t.path,e=>{if(typeof e!=`string`)throw Error(`Expected string at path [${t.path.join(`, `)}]`);return e+t.value});default:throw Error(`Invalid operation type: ${n}`)}}updatePath(e,t,n){if(t.length===0)return n(e);if(e??={},typeof e!=`object`)throw Error(`Invalid path: [${t.join(`, `)}]`);let[r,...i]=t;if(Bm(r),Array.isArray(e)){let a=Number(r);if(Number.isNaN(a))throw Error(`Expected array index at [${t.join(`, `)}]`);if(a<0)throw Error(`Insert array index out of bounds`);if(a>e.length){if(this._strict)throw Error(`Insert array index out of bounds`);this._warnedClamp||(this._warnedClamp=!0,console.warn(`Clamped out-of-bounds gorp array index ${a} to ${e.length}`)),a=Math.min(a,e.length)}let o=[...e];return o[a]=this.updatePath(Object.hasOwn(o,a)?o[a]:void 0,i,n),o}let a={...e};return a[r]=this.updatePath(Object.hasOwn(a,r)?a[r]:void 0,i,n),a}},Hm=class{_streamStartTime;_firstTokenTime;_totalChunks=0;_toolCallIds=new Set;constructor(){this._streamStartTime=Date.now()}recordChunk(){this._totalChunks++}recordFirstToken(){this._firstTokenTime===void 0&&(this._firstTokenTime=Date.now())}recordToolCallStart(e){this._toolCallIds.add(e)}getTiming(e,t){let n=Date.now()-this._streamStartTime,r=e&&e>0?e:t?Math.ceil(t.length/4):void 0,i=r&&n>0?r/n*1e3:void 0;return{streamStartTime:this._streamStartTime,...this._firstTokenTime===void 0?void 0:{firstTokenTime:this._firstTokenTime-this._streamStartTime},totalStreamTime:n,...r===void 0?void 0:{tokenCount:r},...i===void 0?void 0:{tokensPerSecond:i},totalChunks:this._totalChunks,toolCallCount:this._toolCallIds.size}}},Um=({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:{}}}),Wm=16,Gm=(e,t,n,r)=>{let i=t.path.length===1?e.parts[t.path[0]]:void 0;if(i===void 0)return n(`no-part:${t.type}`,`Dropped ${t.type} chunk: no part at path [${t.path.join(`, `)}]`),e;let a=t.path[0],o=r(i);return o===i?e:{...e,parts:[...e.parts.slice(0,a),o,...e.parts.slice(a+1)],get content(){return this.parts}}},Km=(e,t,n)=>{let r=t.part;if(r.type===`text`||r.type===`reasoning`){let t={type:r.type,text:``,status:{type:`running`},...r.type===`reasoning`&&r.unstable_summary!==void 0?{unstable_summary:r.unstable_summary}:void 0,...r.parentId&&{parentId:r.parentId}};return{...e,parts:[...e.parts,t],get content(){return this.parts}}}if(r.type===`tool-call`){let t={type:`tool-call`,state:`partial-call`,status:{type:`running`,isArgsComplete:!1},toolCallId:r.toolCallId,toolName:r.toolName,argsText:``,args:{},timing:{startedAt:Date.now()},...r.parentId&&{parentId:r.parentId}};return{...e,parts:[...e.parts,t],get content(){return this.parts}}}if(r.type===`source`){let t={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,parts:[...e.parts,t],get content(){return this.parts}}}if(r.type===`file`){let t={type:`file`,mimeType:r.mimeType,data:r.data,...r.parentId&&{parentId:r.parentId}};return{...e,parts:[...e.parts,t],get content(){return this.parts}}}if(r.type===`data`){let t={type:`data`,name:r.name,data:r.data,...r.parentId&&{parentId:r.parentId}};return{...e,parts:[...e.parts,t],get content(){return this.parts}}}{let t=String(r.type);n(`unsupported-part-start:${t}`,`Unsupported part-start type ${t}: inserting an empty reasoning part to preserve part indices`);let i={type:`reasoning`,text:``,status:{type:`running`}};return{...e,parts:[...e.parts,i],get content(){return this.parts}}}},qm=(e,t,n)=>Gm(e,t,n,e=>e.type===`tool-call`?e.state===`partial-call`?{...e,state:`call`}:{...e}:(n(`wrong-part:tool-call-args-text-finish`,`Dropped tool-call-args-text-finish chunk: part is not a tool-call`),e)),Jm=(e,t,n)=>Gm(e,t,n,e=>({...e,status:{type:`complete`,reason:`unknown`}})),Ym=(e,t,n)=>Gm(e,t,n,e=>{if(e.type===`text`||e.type===`reasoning`)return{...e,text:e.text+t.textDelta};if(e.type===`tool-call`){let n=e.argsText+t.textDelta,r=Gp(n)??e.args;return{...e,argsText:n,args:r}}return n(`wrong-part:text-delta`,`Dropped text-delta chunk: part is neither text nor tool-call`),e}),Xm=(e,t,n)=>Gm(e,t,n,e=>e.type===`tool-call`?{...e,state:`result`,...e.timing===void 0?{}:{timing:{...e.timing,completedAt:e.timing.completedAt??Date.now()}},...t.artifact===void 0?{}:{artifact:t.artifact},result:t.result,isError:t.isError??!1,...t.modelContent===void 0?{}:{modelContent:t.modelContent},...t.messages===void 0?{}:{messages:t.messages},status:{type:`complete`,reason:`stop`}}:(n(`wrong-part:result`,`Dropped result chunk: part is not a tool-call`),e)),Zm=(e,t)=>{if(e.status?.type===`incomplete`&&e.status?.reason===`error`)return e;let n=Qm(t);return{...e,status:n}},Qm=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},$m=(e,t)=>({...e,metadata:{...e.metadata,unstable_annotations:[...e.metadata.unstable_annotations,...t.annotations]}}),eh=(e,t)=>({...e,metadata:{...e.metadata,unstable_data:[...e.metadata.unstable_data,...t.data]}}),th=(e,t)=>({...e,metadata:{...e.metadata,steps:[...e.metadata.steps,{state:`started`,messageId:t.messageId}]}}),nh=(e,t)=>{let n=e.metadata.steps.slice(),r=n.length-1;return n.length>0&&n[r]?.state===`started`?n[r]={...n[r],state:`finished`,finishReason:t.finishReason,usage:t.usage,isContinued:t.isContinued}:n.push({state:`finished`,messageId:Ip(),finishReason:t.finishReason,usage:t.usage,isContinued:t.isContinued}),{...e,metadata:{...e.metadata,steps:n}}},rh=(e,t)=>{let n=t.severity===`critical`||t.severity===`warning`||t.severity===`info`?t.severity:void 0;return{...e,status:{type:`incomplete`,reason:`error`,error:{code:t.code??`unknown`,message:t.error??`unknown error`,...n!==void 0&&{severity:n}}}}},ih=(e,t,n)=>(n.append(t.operations),{...e,metadata:{...e.metadata,unstable_state:n.state}}),ah=(e,t)=>{let n=0;for(let e of t.metadata.steps)e.state===`finished`&&e.usage&&(n+=e.usage.outputTokens);let r=``;for(let e of t.parts)(e.type===`text`||e.type===`reasoning`)&&(r+=e.text);return e.getTiming(n>0?n:void 0,r||void 0)},oh=e=>{let t=!1;return()=>{t||(t=!0,queueMicrotask(()=>{t=!1,e()}))}},sh=class extends TransformStream{constructor({initialMessage:e,throttle:t,onError:n,strict:r=!0}={}){let i=e??Um(),a,o=new Hm,s=new Set,c=(e,t)=>{s.has(e)||s.size>=Wm||(s.add(e),console.warn(t))},l,u=t?oh(()=>{l?.enqueue(i)}):()=>{l?.enqueue(i)};super({start(e){l=e},transform(e){o.recordChunk();let t=e.type;switch(t){case`part-start`:i=Km(i,e,c),e.part.type===`tool-call`&&o.recordToolCallStart(e.part.toolCallId);break;case`tool-call-args-text-finish`:i=qm(i,e,c);break;case`part-finish`:i=Jm(i,e,c);break;case`text-delta`:{let t=Ym(i,e,c);t!==i&&o.recordFirstToken(),i=t;break}case`result`:i=Xm(i,e,c);break;case`message-finish`:i=Zm(i,e);break;case`annotations`:i=$m(i,e);break;case`data`:i=eh(i,e);break;case`step-start`:i=th(i,e);break;case`step-finish`:i=nh(i,e);break;case`error`:i=rh(i,e),n?.(e.error);break;case`update-state`:a??=new Vm(i.metadata.unstable_state,{strict:r}),i=ih(i,e,a);break;default:throw Error(`Unsupported chunk type: ${t}`)}i.status.type!==`running`&&(i={...i,metadata:{...i.metadata,timing:ah(o,i)}}),u()},flush(e){if(i.status?.type===`running`){let t=i.parts?.some(e=>e.type===`tool-call`&&(e.state===`call`||e.state===`partial-call`)&&e.result===void 0)??!1;i=Zm(i,{type:`message-finish`,path:[],finishReason:t?`tool-calls`:`unknown`,usage:{inputTokens:0,outputTokens:0}}),i={...i,metadata:{...i.metadata,timing:ah(o,i)}},e.enqueue(i)}}})}},ch=class extends Np{constructor(){super(e=>{let t=new Bp({transform(e,t){t.appendText(e)}});return e.pipeThrough(new TextDecoderStream).pipeThrough(t)})}},lh=class e{readable;constructor(e){this.readable=e}static fromAssistantStream(t){return new e(t.pipeThrough(new sh))}async unstable_result(){let e;for await(let t of this)e=t;return e||{role:`assistant`,status:{type:`complete`,reason:`unknown`},parts:[],content:[],metadata:{unstable_state:null,unstable_data:[],unstable_annotations:[],steps:[],custom:{}}}}[Symbol.asyncIterator](){return Yp(this.readable)[Symbol.asyncIterator]()}tee(){let[t,n]=this.readable.tee();return[new e(t),new e(n)]}};function uh(e,t,n){try{let r=e();if(typeof r==`object`&&r&&`then`in r)return r.then(t,n);t(r)}catch(e){n(e)}}function dh(e,t){let n=e;for(let e of t){if(n==null)return;n=n[e]}return n}var fh=class{resolve;reject;disposed=!1;fieldPath;constructor(e,t,n){this.resolve=e,this.reject=t,this.fieldPath=n}update(e){if(!this.disposed)try{if(qp(e,this.fieldPath)===`complete`){let t=dh(e,this.fieldPath);t!==void 0&&(this.resolve(t),this.dispose())}}catch(e){this.reject(e),this.dispose()}}end(e){if(!this.disposed)try{let t=dh(e,this.fieldPath);this.resolve(t)}catch(e){this.reject(e)}finally{this.dispose()}}dispose(){this.disposed=!0}},ph=class{controller;disposed=!1;fieldPath;constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=dh(e,this.fieldPath);t!==void 0&&this.controller.enqueue(t),qp(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},mh=class{controller;disposed=!1;fieldPath;lastValue=void 0;constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=dh(e,this.fieldPath);if(t!==void 0&&typeof t==`string`){let e=t.substring(this.lastValue?.length||0);this.lastValue=t,this.controller.enqueue(e)}qp(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},hh=class{controller;disposed=!1;fieldPath;processedIndexes=new Set;constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=dh(e,this.fieldPath);if(!Array.isArray(t))return;for(let n=0;n<t.length;n++)this.processedIndexes.has(n)||qp(e,[...this.fieldPath,n])===`complete`&&(this.controller.enqueue(t[n]),this.processedIndexes.add(n));qp(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},gh=class{argTextDeltas;handles=new Set;args=Gp(``);finished=!1;constructor(e){this.argTextDeltas=e,this.processStream()}async processStream(){try{let e=``,t=this.argTextDeltas.getReader();for(;;){let{value:n,done:r}=await t.read();if(r)break;e+=n;let i=Gp(e);if(i!==void 0){this.args=i;for(let e of this.handles)e.update(i)}}}catch(e){console.error(`Error processing argument stream:`,e)}finally{this.finished=!0;for(let e of this.handles)e.end(this.args);this.handles.clear()}}get(...e){return new Promise((t,n)=>{let r=new fh(t,n,e);if(this.args&&qp(this.args,e)===`complete`){let n=dh(this.args,e);if(n!==void 0){t(n);return}}if(this.finished){r.end(this.args);return}this.handles.add(r),r.update(this.args)})}streamValues(...e){let t=e,n;return Yp(new ReadableStream({start:e=>{n=new ph(e,t),this.finished||this.handles.add(n),n.update(this.args),this.finished&&n.end()},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}streamText(...e){let t=e,n;return Yp(new ReadableStream({start:e=>{n=new mh(e,t),this.finished||this.handles.add(n),n.update(this.args),this.finished&&n.end()},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}forEach(...e){let t=e,n;return Yp(new ReadableStream({start:e=>{n=new hh(e,t),this.finished||this.handles.add(n),n.update(this.args),this.finished&&n.end()},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}},_h=class{promise;constructor(e){this.promise=e}get(){return this.promise}},vh=class{args;response;writable;resolve;argsText=``;constructor(){let e=new TransformStream;this.writable=e.writable,this.args=new gh(e.readable);let{promise:t,resolve:n}=yp();this.resolve=n,this.response=new _h(t)}async appendArgsTextDelta(e){let t=this.writable.getWriter();try{await t.write(e)}catch(e){console.warn(e)}finally{t.releaseLock()}this.argsText+=e}async finishArgsText(){let e=this.writable.getWriter();try{await e.close()}catch(e){console.warn(e)}finally{e.releaseLock()}}setResponse(e){this.resolve(e)}result={get:async()=>(await this.response.get()).result}},yh=Symbol.for(`assistant-stream.tool-execution-id`),bh=(e,t,n,r,i)=>{try{let a=t?.(n,r,i);Promise.resolve(a).catch(t=>{console.error(`[assistant-stream] ${e} callback threw an error`,t)})}catch(t){console.error(`[assistant-stream] ${e} callback threw an error`,t)}},xh=e=>e.join(`,`),Sh=(e,t)=>{let n={...e};return Object.defineProperty(n,yh,{value:t,enumerable:!0}),n},Ch=(e,t)=>{try{e.enqueue(t)}catch(e){if(!(e instanceof TypeError))throw e}},wh=class extends Np{constructor(e){let t=e,n=new Map,r=new Map,i=new Set,a=new Map,o=0;super(e=>{let s=new TransformStream({async transform(e,s){let c=a.get(xh(e.path));switch((e.type!==`part-finish`||e.meta.type!==`tool-call`)&&s.enqueue(c?Sh(e,c):e),e.type){case`part-start`:{let n=o;if(o+=1,e.part.type===`tool-call`){let i=new vh,o=Symbol();a.set(String(n),o),r.set(o,i),t.streamCall({reader:i,toolCallId:e.part.toolCallId,toolName:e.part.toolName,executionId:o})}break}case`text-delta`:if(e.meta.type===`tool-call`){let t=a.get(xh(e.path)),n=t?r.get(t):void 0;if(!n)throw Error(`No controller found for tool call`);await n.appendArgsTextDelta(e.textDelta)}break;case`result`:{if(e.meta.type!==`tool-call`)break;let t=a.get(xh(e.path)),n=t?r.get(t):void 0;if(!n)throw Error(`No controller found for tool call`);n.setResponse(new Ep({result:e.result,artifact:e.artifact,isError:e.isError,modelContent:e.modelContent})),i.add(t);break}case`tool-call-args-text-finish`:{if(e.meta.type!==`tool-call`)break;let{toolCallId:o,toolName:c}=e.meta,l=a.get(xh(e.path)),u=l?r.get(l):void 0;if(!u)throw Error(`No controller found for tool call`);if(await u.finishArgsText(),i.has(l))break;let d=!1,f=uh(()=>{let e;try{e=Hp.default.parse(u.argsText)}catch(e){throw Error(`Function parameter parsing failed. ${JSON.stringify(e.message)}`)}let n=t.execute({toolCallId:o,toolName:c,args:e,executionId:l});return n!==void 0&&(d=!0,bh(`onExecutionStart`,t.onExecutionStart,o,c,l)),n},n=>{if(d&&bh(`onExecutionEnd`,t.onExecutionEnd,o,c,l),n===void 0)return;let r=new Ep({artifact:n.artifact,result:n.result,isError:n.isError,messages:n.messages,modelContent:n.modelContent});u.setResponse(r),Ch(s,Sh({type:`result`,path:e.path,...r},l))},n=>{d&&bh(`onExecutionEnd`,t.onExecutionEnd,o,c,l);let r=new Ep({result:String(n),isError:!0});u.setResponse(r),Ch(s,Sh({type:`result`,path:e.path,...r},l))});f&&n.set(l,f);break}case`part-finish`:{if(e.meta.type!==`tool-call`)break;let t=a.get(xh(e.path)),o=t?n.get(t):void 0,c=()=>{t&&(n.delete(t),r.delete(t),i.delete(t),a.delete(xh(e.path)))};o?o.then(()=>{c(),Ch(s,e)}):(c(),s.enqueue(e))}}},async flush(){await Promise.all(n.values())}});return e.pipeThrough(new Fp).pipeThrough(s)})}},Th=Symbol.for(`assistant-stream.tool-execution-id`),Eh=e=>typeof e==`object`&&!!e&&`~standard`in e&&e[`~standard`].version===1;function Dh(e,t,n,r){let i=e?.[n.toolName];return i?.execute?(async e=>{if(t.aborted)return new Ep({result:`Tool execution was cancelled.`,isError:!0});let a=e;if(Eh(i.parameters)){let e=i.parameters[`~standard`].validate(n.args);e instanceof Promise&&(e=await e),e.issues&&(a=i.experimental_onSchemaValidationError??(()=>{throw Error(`Function parameter validation failed. ${JSON.stringify(e.issues)}`)}))}let o,s=new Promise(e=>{o=()=>{queueMicrotask(()=>{queueMicrotask(()=>{e(new Ep({result:`Tool execution was cancelled.`,isError:!0}))})})},t.aborted?o():t.addEventListener(`abort`,o,{once:!0})}),c=(async()=>{let e={toolCallId:n.toolCallId,abortSignal:t,human:e=>r(n.toolCallId,e,n.executionId),[Th]:n.executionId},o=await a(n.args,e),s=Ep.toResponse(o);if(i.toModelOutput&&!s.isError&&s.modelContent===void 0)try{let e=await i.toModelOutput({toolCallId:n.toolCallId,input:n.args,output:s.result});return new Ep({result:s.result,artifact:s.artifact,isError:s.isError,messages:s.messages,modelContent:e})}catch(e){console.warn(`[assistant-stream] tool "${n.toolName}" toModelOutput threw; falling back to default projection.`,e)}return s})();try{return await Promise.race([c,s])}finally{t.removeEventListener(`abort`,o)}})(i.execute):void 0}function Oh(e,t,n,r,i){let a={toolCallId:r.toolCallId,abortSignal:t,human:e=>i(r.toolCallId,e,r.executionId),[Th]:r.executionId};e?.[r.toolName]?.streamCall?.(n,a)}function kh(e,t,n,r){let i=typeof e==`function`?e:()=>e,a=typeof t==`function`?t:()=>t,o=r,s=n;return new wh({execute:e=>Dh(i(),a(),e,s),streamCall:({reader:e,...t})=>Oh(i(),a(),e,t,s),onExecutionStart:o?.onExecutionStart,onExecutionEnd:o?.onExecutionEnd})}function Ah(e){return typeof e==`object`&&!!e&&`~standard`in e&&typeof e[`~standard`]==`object`}function jh(e){return typeof e==`object`&&!!e&&`toJSONSchema`in e&&typeof e.toJSONSchema==`function`}function Mh(e){return typeof e==`object`&&!!e&&`toJSON`in e&&typeof e.toJSON==`function`}function Nh(e){if(Ah(e)){let t=e[`~standard`].toJSONSchema;if(typeof t==`function`)return t();let n=e[`~standard`].jsonSchema;if(typeof n==`object`&&n&&typeof n.input==`function`)return n.input()}if(jh(e))return e.toJSONSchema();if(Mh(e))return e.toJSON();if(Ah(e))throw Error(`Could not convert schema to JSON Schema. The schema implements Standard Schema but does not support JSON Schema conversion. If you are using Zod, please upgrade to Zod v4 (npm install zod@latest). Alternatively, pass a plain JSON Schema object instead.`);return e}function Ph(e,t){return!t.disabled&&t.type!==`backend`&&(t.type!==`frontend`||t.execute!==void 0)}function Fh(e){return e.parameters!==void 0&&!e.unstable_backendDefault?.parameters}function Ih(e,t={}){if(!e)return{};let n=t.filter??Ph;return Object.fromEntries(Object.entries(e).filter(([e,t])=>n(e,t)).filter(e=>Fh(e[1])).sort(([e],[t])=>e<t?-1:+(e>t)).map(([e,t])=>[e,{...t.description&&{description:t.description},parameters:Nh(t.parameters),...t.providerOptions&&{providerOptions:t.providerOptions}}]))}var Lh=e=>{let t=F(6),{index:n,children:r}=e,i=zd(),a;t[0]===n?a=t[1]:(a=_u({attachment:Kd({source:`message`,query:{type:`index`,index:n},get:e=>e.message.attachment({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,M.jsx)(Rf,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},Rh=e=>{let t=F(6),{index:n,children:r}=e,i=zd(),a;t[0]===n?a=t[1]:(a=_u({attachment:Kd({source:`composer`,query:{type:`index`,index:n},get:e=>e.composer.attachment({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,M.jsx)(Rf,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},zh=e=>{let t=F(6),{runtime:n,children:r}=e,i=zd(),a;t[0]===n?a=t[1]:(a=_u({threadListItem:Df({runtime:n})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,M.jsx)(Rf,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},Bh=e=>{let t=F(6),{index:n,children:r}=e,i=zd(),a;t[0]===n?a=t[1]:(a=_u({message:Kd({source:`thread`,query:{type:`index`,index:n},get:e=>e.thread.message({index:n})}),composer:Kd({source:`message`,query:{},get:e=>e.thread.message({index:n}).composer()})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,M.jsx)(Rf,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},Vh=e=>{let t=F(6),{index:n,children:r}=e,i=zd(),a;t[0]===n?a=t[1]:(a=_u({part:Kd({source:`message`,query:{type:`index`,index:n},get:e=>e.message.part({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,M.jsx)(Rf,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},Hh=el(e=>{let t=F(7),{text:n,isRunning:r}=e,i;t[0]===r?i=t[1]:(i=r?{type:`running`}:{type:`complete`},t[0]=r,t[1]=i);let a;t[2]!==i||t[3]!==n?(a={type:`text`,text:n,status:i},t[2]=i,t[3]=n,t[4]=a):a=t[4];let o=a,s;return t[5]===o?s=t[6]:(s={getState:()=>o,addToolResult:Wh,resumeToolCall:Gh,respondToToolApproval:Kh},t[5]=o,t[6]=s),s}),Uh=e=>{let t=F(7),{text:n,isRunning:r,children:i}=e,a=r!==void 0&&r,o=zd(),s;t[0]!==a||t[1]!==n?(s=_u({part:Hh({text:n,isRunning:a})}),t[0]=a,t[1]=n,t[2]=s):s=t[2];let c=s,l;return t[3]!==o||t[4]!==i||t[5]!==c?(l=(0,M.jsx)(Rf,{extends:o,config:c,children:i}),t[3]=o,t[4]=i,t[5]=c,t[6]=l):l=t[6],l};function Wh(){throw Error(`Not supported`)}function Gh(){throw Error(`Not supported`)}function Kh(){throw Error(`Not supported`)}var qh=Object.freeze({type:`complete`}),Jh=Object.freeze({type:`running`}),Yh=Object.freeze({cancelled:Object.freeze({type:`incomplete`,reason:`cancelled`}),length:Object.freeze({type:`incomplete`,reason:`length`}),"content-filter":Object.freeze({type:`incomplete`,reason:`content-filter`}),other:Object.freeze({type:`incomplete`,reason:`other`}),error:Object.freeze({type:`incomplete`,reason:`error`})}),Xh=e=>{let t=e.status;if(!t||typeof t!=`object`)return;let{type:n}=t;if(n===`running`)return Jh;if(n===`complete`)return qh;if(n!==`incomplete`)return;let{reason:r}=t;return Yh[r===`cancelled`||r===`length`||r===`content-filter`||r===`other`||r===`error`?r:`other`]},Zh=(e,t,n)=>{if(e.role!==`assistant`)return qh;if(n.type===`tool-call`)return n.result===void 0?e.status:qh;if(e.status.type===`running`){let e=Xh(n);if(e)return e}let r=t===Math.max(0,e.content.length-1);return e.status.type===`requires-action`?qh:r?e.status:qh},Qh=(e,t)=>{if(t){for(let n of t)if(e[n]?.status.type===`running`)return Jh;let n=t.at(-1);return n===void 0?qh:e[n]?.status??qh}for(let t of e)if(t?.status.type===`running`)return Jh;return e.at(-1)?.status??qh},$h=el(e=>{let t=F(11),{parts:n,getMessagePart:r}=e,[i,a]=Pc(!0),o;t[0]===n?o=t[1]:(o=Qh(n),t[0]=n,t[1]=o);let s=o,c;t[2]!==i||t[3]!==n||t[4]!==s?(c={parts:n,collapsed:i,status:s},t[2]=i,t[3]=n,t[4]=s,t[5]=c):c=t[5];let l=c,u;t[6]===l?u=t[7]:(u=()=>l,t[6]=l,t[7]=u);let d;return t[8]!==r||t[9]!==u?(d={getState:u,setCollapsed:a,part:r},t[8]=r,t[9]=u,t[10]=d):d=t[10],d}),eg=e=>{let t=F(4),{startIndex:n,endIndex:r,children:i}=e,a=R(tg).slice(n,r+1),o=zd(),s=_u({chainOfThought:$h({parts:a,getMessagePart:e=>{let{index:t}=e;if(t<0||t>=a.length)throw Error(`ChainOfThought part index ${t} is out of bounds (0..${a.length-1})`);return o.message.part({index:n+t})}})}),c;return t[0]!==i||t[1]!==s||t[2]!==o?(c=(0,M.jsx)(Rf,{extends:o,config:s,children:i}),t[0]=i,t[1]=s,t[2]=o,t[3]=c):c=t[3],c};function tg(e){return e.message.parts}var ng=e=>{let t=F(6),{index:n,children:r}=e,i=zd(),a;t[0]===n?a=t[1]:(a=_u({suggestion:Kd({source:`suggestions`,query:{index:n},get:e=>e.suggestions.suggestion({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,M.jsx)(Rf,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},rg=e=>{let t=F(6),{index:n,children:r}=e,i=zd(),a;t[0]===n?a=t[1]:(a=_u({queueItem:Kd({source:`composer`,query:{type:`index`,index:n},get:e=>e.composer.queueItem({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,M.jsx)(Rf,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},ig=[`critical`,`warning`,`info`],ag=[`inline`,`toast`,`silent`,`dev-only`],og=e=>{if(typeof e!=`object`||!e)return!1;let t=e;return!(typeof t.code!=`string`||typeof t.message!=`string`||`severity`in t&&t.severity!==void 0&&(typeof t.severity!=`string`||!ig.includes(t.severity))||`display`in t&&t.display!==void 0&&(typeof t.display!=`string`||!ag.includes(t.display)))},sg=Symbol.for(`assistant-ui.message-not-sent`),cg=class extends Error{[sg]=!0;constructor(e=`The message was not sent.`){super(e),this.name=`MessageNotSentError`}},lg=e=>typeof e==`object`&&!!e&&sg in e,ug=e=>{if(og(e))return e;if(e instanceof Error)return{code:`unknown`,message:e.message};if(typeof e==`string`)return{code:`unknown`,message:e};try{return{code:`unknown`,message:`[${typeof e}] ${String(e)}`}}catch{return{code:`unknown`,message:`[${typeof e}]`}}},dg=class{get path(){return this._core.path}_core;constructor(e){this._core=e,this.__internal_bindMethods()}__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)}},fg=class extends dg{_composerApi;constructor(e,t){super(e),this._composerApi=t}remove(){let e=this._composerApi.getState();if(!e)throw Error(`Composer is not available`);return e.removeAttachment(this.getState().id)}},pg=class extends fg{get source(){return`thread-composer`}},mg=class extends fg{get source(){return`edit-composer`}},hg=class extends dg{get source(){return`message`}remove(){throw Error(`Message attachments cannot be removed`)}},gg=Object.freeze([]),_g=Object.freeze({}),vg=e=>Object.freeze({type:`thread`,isEditing:e?.isEditing??!1,canCancel:e?.canCancel??!1,canSend:e?.canSend??!1,isEmpty:e?.isEmpty??!0,attachments:e?.attachments??gg,text:e?.text??``,role:e?.role??`user`,runConfig:e?.runConfig??_g,attachmentAccept:e?.attachmentAccept??``,dictation:e?.dictation,quote:e?.quote,queue:e?.queue??gg,value:e?.text??``}),yg=e=>Object.freeze({type:`edit`,isEditing:e?.isEditing??!1,canCancel:e?.canCancel??!1,canSend:e?.canSend??!1,isEmpty:e?.isEmpty??!0,text:e?.text??``,role:e?.role??`user`,attachments:e?.attachments??gg,runConfig:e?.runConfig??_g,attachmentAccept:e?.attachmentAccept??``,dictation:e?.dictation,quote:e?.quote,queue:e?.queue??gg,parentId:e?.parentId??null,sourceId:e?.sourceId??null,value:e?.text??``}),bg=class{get path(){return this._core.path}_core;constructor(e){this._core=e}__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.steerQueueItem=this.steerQueueItem.bind(this),this.moveQueueItem=this.moveQueueItem.bind(this),this.removeQueueItem=this.removeQueueItem.bind(this),this.setRole=this.setRole.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.startDictation=this.startDictation.bind(this),this.stopDictation=this.stopDictation.bind(this),this.setQuote=this.setQuote.bind(this),this.unstable_on=this.unstable_on.bind(this)}setText(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setText(e)}setRunConfig(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setRunConfig(e)}addAttachment(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);return t.addAttachment(e)}reset(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);return e.reset()}clearAttachments(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);return e.clearAttachments()}send(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.send(e)}cancel(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.cancel()}steerQueueItem(e){this.moveQueueItem(e,{lane:`steer`,insertAfter:null})}moveQueueItem(e,t){let n=this._core.getState();if(!n)throw Error(`Composer is not available`);n.moveQueueItem(e,t)}removeQueueItem(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.removeQueueItem(e)}setRole(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setRole(e)}startDictation(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.startDictation()}stopDictation(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.stopDictation()}setQuote(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setQuote(e)}subscribe(e){return this._core.subscribe(e)}_eventSubscriptionSubjects=new Map;unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new su({event:e,binding:this._core}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},xg=class extends bg{get path(){return this._core.path}get type(){return`thread`}_getState;constructor(e){let t=new au({path:e.path,getState:()=>vg(e.getState()),subscribe:t=>e.subscribe(t)});super({path:e.path,getState:()=>e.getState(),subscribe:e=>t.subscribe(e)}),this._getState=t.getState.bind(t),this.__internal_bindMethods()}getState(){return this._getState()}getAttachmentByIndex(e){return new pg(new iu({path:{...this.path,attachmentSource:`thread-composer`,attachmentSelector:{type:`index`,index:e},ref:`${this.path.ref}.attachments[${e}]`},getState:()=>{let t=this.getState().attachments[e];return t?{...t,source:`thread-composer`}:$l},subscribe:e=>this._core.subscribe(e)}),this._core)}},Sg=class extends bg{get path(){return this._core.path}get type(){return`edit`}_getState;_beginEdit;constructor(e,t){let n=new au({path:e.path,getState:()=>yg(e.getState()),subscribe:t=>e.subscribe(t)});super({path:e.path,getState:()=>e.getState(),subscribe:e=>n.subscribe(e)}),this._beginEdit=t,this._getState=n.getState.bind(n),this.__internal_bindMethods()}__internal_bindMethods(){super.__internal_bindMethods(),this.beginEdit=this.beginEdit.bind(this)}getState(){return this._getState()}beginEdit(){this._beginEdit()}getAttachmentByIndex(e){return new mg(new iu({path:{...this.path,attachmentSource:`edit-composer`,attachmentSelector:{type:`index`,index:e},ref:`${this.path.ref}.attachments[${e}]`},getState:()=>{let t=this.getState().attachments[e];return t?{...t,source:`edit-composer`}:$l},subscribe:e=>this._core.subscribe(e)}),this._core)}},Cg=e=>e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
18
|
-
|
|
19
|
-
`),wg={"allow-once":!0,"allow-always":!0,"reject-once":!1,"reject-always":!1},Tg=(e,t)=>{let n,r;if(`optionId`in t){let i=e.options?.find(e=>e.id===t.optionId);if(!i)throw Error(`Tool approval has no option with id "${t.optionId}"`);if(`approved`in t)n=t.approved;else{if(!Object.hasOwn(wg,i.kind))throw Error(`Tool approval option "${i.id}" has a custom kind "${i.kind}"; respond with an explicit approved value instead`);n=wg[i.kind]}r=i.id}else n=t.approved;return{approvalId:e.id,approved:n,...r!==void 0&&{optionId:r},...t.reason!=null&&{reason:t.reason}}},Eg=class{get path(){return this.contentBinding.path}contentBinding;messageApi;threadApi;constructor(e,t,n){this.contentBinding=e,this.messageApi=t,this.threadApi=n,this.__internal_bindMethods()}__internal_bindMethods(){this.addToolResult=this.addToolResult.bind(this),this.resumeToolCall=this.resumeToolCall.bind(this),this.respondToToolApproval=this.respondToToolApproval.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this.contentBinding.getState()}addToolResult(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to add tool result to non-tool message part`);if(!this.messageApi)throw Error(`Message API is not available. This is likely a bug in assistant-ui.`);if(!this.threadApi)throw Error(`Thread API is not available`);let n=this.messageApi.getState();if(!n)throw Error(`Message is not available`);let r=t.toolName,i=t.toolCallId,a=Ep.toResponse(e);this.threadApi.getState().addToolResult({messageId:n.id,toolName:r,toolCallId:i,result:a.result,artifact:a.artifact,isError:a.isError})}resumeToolCall(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to resume tool call on non-tool message part`);if(!this.threadApi)throw Error(`Thread API is not available`);let n=t.toolCallId;this.threadApi.getState().resumeToolCall({toolCallId:n,payload:e})}respondToToolApproval(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to respond to tool approval on non-tool message part`);if(!t.approval||t.approval.approved!==void 0||t.approval.resolution!==void 0)throw Error(`Tool call has no pending approval`);if(!this.threadApi)throw Error(`Thread API is not available`);this.threadApi.getState().respondToToolApproval(Tg(t.approval,e))}subscribe(e){return this.contentBinding.subscribe(e)}},Dg=(e,t)=>{let n=e.content[t];if(!n)return $l;let r=Zh(e,t,n);return Object.freeze({...n,[um]:n[um],status:r})},Og=class{get path(){return this._core.path}_core;_threadBinding;constructor(e,t){this._core=e,this._threadBinding=t,this.composer=new Sg(new ou({path:{...this.path,ref:`${this.path.ref}.composer`,composerSource:`edit`},getState:this._getEditComposerRuntimeCore,subscribe:e=>this._threadBinding.subscribe(e)}),()=>this._threadBinding.getState().beginEdit(this._core.getState().id)),this.__internal_bindMethods()}__internal_bindMethods(){this.reload=this.reload.bind(this),this.delete=this.delete.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)}composer;_getEditComposerRuntimeCore=()=>this._threadBinding.getState().getEditComposer(this._core.getState().id);getState(){return this._core.getState()}delete(){let e=this._core.getState();return this._threadBinding.getState().deleteMessage(e.id)}reload(e={}){let t=this._getEditComposerRuntimeCore(),n=t??this._threadBinding.getState().composer,r=t??n,{runConfig:i=r.runConfig}=e,a=this._core.getState();if(a.role!==`assistant`)throw Error(`Can only reload assistant messages`);this._threadBinding.getState().startRun({parentId:a.parentId,sourceId:a.id,runConfig:i})}speak(){let e=this._core.getState();return this._threadBinding.getState().speak(e.id)}stopSpeaking(){let e=this._core.getState();if(this._threadBinding.getState().speech?.messageId===e.id)this._threadBinding.getState().stopSpeaking();else throw Error(`Message is not being spoken`)}submitFeedback({type:e}){let t=this._core.getState();this._threadBinding.getState().submitFeedback({messageId:t.id,type:e})}switchToBranch({position:e,branchId:t}){let n=this._core.getState();if(t&&e)throw Error(`May not specify both branchId and position`);if(!t&&!e)throw Error(`Must specify either branchId or position`);let r=this._threadBinding.getState().getBranches(n.id),i=t;if(e===`previous`?i=r[n.branchNumber-2]:e===`next`&&(i=r[n.branchNumber]),!i)throw Error(`Branch not found`);this._threadBinding.getState().switchToBranch(i)}unstable_getCopyText(){return Cg(this.getState())}subscribe(e){return this._core.subscribe(e)}getMessagePartByIndex(e){if(e<0)throw Error(`Message part index must be >= 0`);return new Eg(new iu({path:{...this.path,ref:`${this.path.ref}.content[${e}]`,messagePartSelector:{type:`index`,index:e}},getState:()=>Dg(this.getState(),e),subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getMessagePartByToolCallId(e){return new Eg(new iu({path:{...this.path,ref:`${this.path.ref}.content[toolCallId=${JSON.stringify(e)}]`,messagePartSelector:{type:`toolCallId`,toolCallId:e}},getState:()=>{let t=this._core.getState(),n=t.content.findIndex(t=>t.type===`tool-call`&&t.toolCallId===e);return n===-1?$l:Dg(t,n)},subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getAttachmentByIndex(e){return new hg(new iu({path:{...this.path,ref:`${this.path.ref}.attachments[${e}]`,attachmentSource:`message`,attachmentSelector:{type:`index`,index:e}},getState:()=>{let t=this.getState().attachments?.[e];return t?{...t,source:`message`}:$l},subscribe:e=>this._core.subscribe(e)}))}},kg=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{},...e.stream?{stream:e.stream}:{}}),Ag=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{}}),jg=(e,t)=>typeof t==`string`?{createdAt:new Date,parentId:e.at(-1)?.id??null,sourceId:null,runConfig:{},role:`user`,content:[{type:`text`,text:t}],attachments:[],metadata:{custom:{}}}:{createdAt:t.createdAt??new Date,parentId:t.parentId??e.at(-1)?.id??null,sourceId:t.sourceId??null,role:t.role??`user`,content:t.content,attachments:t.attachments??[],metadata:t.metadata??{custom:{}},runConfig:t.runConfig??{},startRun:t.startRun},Mg=e=>{if(e.isRunning!==void 0)return e.isRunning;let t=e.messages.at(-1);return t?.role===`assistant`&&t.status.type===`running`},Ng=(e,t)=>Object.freeze({threadId:t.id,metadata:t,capabilities:e.capabilities,isDisabled:e.isDisabled,isLoading:e.isLoading,isRunning:Mg(e),messages:e.messages,state:e.state,suggestions:e.suggestions,extras:e.extras,speech:e.speech,voice:e.voice}),Pg=class{get path(){return this._threadBinding.path}get __internal_threadBinding(){return this._threadBinding}_threadBinding;_stateBinding;constructor(e,t){let n=new iu({path:e.path,getState:()=>Ng(e.getState(),t.getState()),subscribe:n=>{let r=e.subscribe(n),i=t.subscribe(n);return()=>{r(),i()}}});this._stateBinding=n,this._threadBinding={path:e.path,getState:()=>e.getState(),getStateState:()=>n.getState(),outerSubscribe:t=>e.outerSubscribe(t),subscribe:t=>e.subscribe(t)},this.composer=new xg(new ou({path:{...this.path,ref:`${this.path.ref}.composer`,composerSource:`thread`},getState:()=>this._threadBinding.getState().composer,subscribe:e=>this._threadBinding.subscribe(e)})),this.__internal_bindMethods()}__internal_bindMethods(){this.append=this.append.bind(this),this.deleteMessage=this.deleteMessage.bind(this),this.resumeRun=this.resumeRun.bind(this),this.importExternalState=this.importExternalState.bind(this),this.exportExternalState=this.exportExternalState.bind(this),this.startRun=this.startRun.bind(this),this.cancelRun=this.cancelRun.bind(this),this.unstable_notifySessionReset=this.unstable_notifySessionReset.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.connectVoice=this.connectVoice.bind(this),this.disconnectVoice=this.disconnectVoice.bind(this),this.muteVoice=this.muteVoice.bind(this),this.unmuteVoice=this.unmuteVoice.bind(this),this.getVoiceVolume=this.getVoiceVolume.bind(this),this.subscribeVoiceVolume=this.subscribeVoiceVolume.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.getState=this.getState.bind(this)}composer;getState(){return this._threadBinding.getStateState()}append(e){let t=this._threadBinding.getState().append(jg(this._threadBinding.getState().messages,e));Promise.resolve(t).catch(e=>{if(!lg(e))throw e})}deleteMessage(e){return this._threadBinding.getState().deleteMessage(e)}subscribe(e){return this._stateBinding.subscribe(e)}getModelContext(){return this._threadBinding.getState().getModelContext()}startRun(e){return this._threadBinding.getState().startRun(Ag(e))}resumeRun(e){return this._threadBinding.getState().resumeRun(kg(e))}exportExternalState(){return this._threadBinding.getState().exportExternalState()}importExternalState(e){this._threadBinding.getState().importExternalState(e)}cancelRun(){this._threadBinding.getState().cancelRun()}unstable_notifySessionReset(){this._threadBinding.getState().unstable_notifySessionReset()}stopSpeaking(){return this._threadBinding.getState().stopSpeaking()}connectVoice(){this._threadBinding.getState().connectVoice()}disconnectVoice(){this._threadBinding.getState().disconnectVoice()}getVoiceVolume(){return this._threadBinding.getState().getVoiceVolume()}subscribeVoiceVolume(e){return this._threadBinding.getState().subscribeVoiceVolume(e)}muteVoice(){this._threadBinding.getState().muteVoice()}unmuteVoice(){this._threadBinding.getState().unmuteVoice()}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 Error(`Message index must be >= 0`);return this._getMessageRuntime({...this.path,ref:`${this.path.ref}.messages[${e}]`,messageSelector:{type:`index`,index:e}},()=>{let t=this._threadBinding.getState().messages,n=t[e];if(n)return{message:n,parentId:t[e-1]?.id??null,index:e}})}getMessageById(e){return this._getMessageRuntime({...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 Og(new iu({path:e,getState:()=>{let{message:e,parentId:n,index:r}=t()??{},{messages:i,speech:a}=this._threadBinding.getState();if(!e||n===void 0||r===void 0)return $l;let o=this._threadBinding.getState().getBranches(e.id);return{...e,[um]:e[um],index:r,isLast:i.at(-1)?.id===e.id,parentId:n,branchNumber:o.indexOf(e.id)+1,branchCount:o.length,speech:a?.messageId===e.id?a:void 0}},subscribe:e=>this._threadBinding.subscribe(e)}),this._threadBinding)}_eventSubscriptionSubjects=new Map;unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new su({event:e,binding:this._threadBinding}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},Fg=(e,t)=>({attachments:[],attachmentAccept:`*`,async addAttachment(){throw e},async removeAttachment(){throw e},isEditing:t,canCancel:!1,canSend:!1,isEmpty:!0,text:``,setText(){throw e},role:`user`,setRole(){throw e},runConfig:{},setRunConfig(){throw e},async reset(){},async clearAttachments(){},send(){throw e},cancel(){},queue:[],moveQueueItem(){},removeQueueItem(){},dictation:void 0,startDictation(){throw e},stopDictation(){},quote:void 0,setQuote(){throw e},subscribe(){return()=>{}},unstable_on(){return()=>{}}}),Ig=class extends nu{switchToBranch(){throw this.error}append(){throw this.error}deleteMessage(){throw this.error}startRun(){throw this.error}resumeRun(){throw this.error}cancelRun(){throw this.error}unstable_notifySessionReset(){throw this.error}addToolResult(){throw this.error}resumeToolCall(){throw this.error}respondToToolApproval(){throw this.error}speak(){throw this.error}stopSpeaking(){throw this.error}connectVoice(){throw this.error}disconnectVoice(){throw this.error}muteVoice(){throw this.error}unmuteVoice(){throw this.error}submitFeedback(){throw this.error}exportExternalState(){throw this.error}importExternalState(){throw this.error}beginEdit(){throw this.error}import(){throw this.error}reset(){throw this.error}getModelContext(){return{}}getEditComposer(){}getVoiceVolume=()=>0;subscribeVoiceVolume=()=>()=>{};speech=void 0;voice=void 0;capabilities={switchToBranch:!1,switchBranchDuringRun:!1,edit:!1,delete:!1,reload:!1,refetchThread:!1,cancel:!1,unstable_copy:!1,speech:!1,dictation:!1,voice:!1,attachments:!1,feedback:!1,queue:!1};isDisabled=!1;isSendDisabled=!1;state=null;suggestions=[];extras=void 0;unstable_on(){return()=>{}}},Lg=e=>{let t=F(6),{adapters:n,children:r}=e,i=$c(Xp),a;t[0]!==n||t[1]!==i?(a={...i,...n},t[0]=n,t[1]=i,t[2]=a):a=t[2];let o=a,s;return t[3]!==r||t[4]!==o?(s=(0,M.jsx)(Xp.Provider,{value:o,children:r}),t[3]=r,t[4]=o,t[5]=s):s=t[5],s},Rg=class{get path(){return this._core.path}_core;_threadListBinding;constructor(e,t){this._core=e,this._threadListBinding=t,this.__internal_bindMethods()}__internal_bindMethods(){this.switchTo=this.switchTo.bind(this),this.rename=this.rename.bind(this),this.updateCustom=this.updateCustom.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(e){let t=this._core.getState();return this._threadListBinding.switchToThread(t.id,e)}rename(e){let t=this._core.getState();return this._threadListBinding.rename(t.id,e)}updateCustom(e){let t=this._core.getState();if(!this._threadListBinding.updateCustom)throw Error(`Thread list runtime does not support updating custom metadata`);return this._threadListBinding.updateCustom(t.id,e)}archive(){let e=this._core.getState();return this._threadListBinding.archive(e.id)}unarchive(){let e=this._core.getState();return this._threadListBinding.unarchive(e.id)}delete(){let e=this._core.getState();return this._threadListBinding.delete(e.id)}initialize(){let e=this._core.getState();return this._threadListBinding.initialize(e.id)}generateTitle(){let e=this._core.getState();return this._threadListBinding.generateTitle(e.id)}unstable_on(e,t){let n=this._core.getState().isMain,r=this._core.getState().id;return this.subscribe(()=>{let i=this._core.getState(),a=i.isMain,o=i.id;(n!==a||r!==o)&&(n=a,r=o,!(e===`switchedTo`&&!a)&&(e===`switchedAway`&&a||Ql([t],{},`Thread list item "${e}"`)))})}subscribe(e){return this._core.subscribe(e)}detach(){let e=this._core.getState();this._threadListBinding.detach(e.id)}__internal_getRuntime(){return this}},zg=Promise.resolve(),Bg=e=>({mainThreadId:e.mainThreadId,newThreadId:e.newThreadId,threadIds:e.threadIds,archivedThreadIds:e.archivedThreadIds,isLoading:e.isLoading,isLoadingMore:e.isLoadingMore??!1,hasMore:e.hasMore??!1,threadItems:e.threadItems}),Vg=(e,t)=>{if(t===void 0)return $l;let n=e.getItemById(t);return n?{id:n.id,remoteId:n.remoteId,externalId:n.externalId,title:n.title,status:n.status,lastMessageAt:n.lastMessageAt,custom:n.custom,isMain:n.id===e.mainThreadId,isRunning:e.unstable_isThreadRunning?.(n.id)??!1}:$l},Hg=class{_getState;_stateBinding;_core;_runtimeFactory;constructor(e,t=Pg){this._core=e,this._runtimeFactory=t;let n=new au({path:{},getState:()=>Bg(e),subscribe:t=>e.subscribe(t)});this._getState=n.getState.bind(n),this._stateBinding=n,this._mainThreadListItemRuntime=new Rg(new iu({path:{ref:`threadItems[main]`,threadSelector:{type:`main`}},getState:()=>Vg(this._core,this._core.mainThreadId),subscribe:e=>this._core.subscribe(e)}),this._core),this.main=new t(new ou({path:{ref:`threads.main`,threadSelector:{type:`main`}},getState:()=>e.getMainThreadRuntimeCore(),subscribe:t=>e.subscribe(t)}),this._mainThreadListItemRuntime),this.__internal_bindMethods()}__internal_bindMethods(){this.switchToThread=this.switchToThread.bind(this),this.switchToNewThread=this.switchToNewThread.bind(this),this.getLoadThreadsPromise=this.getLoadThreadsPromise.bind(this),this.reload=this.reload.bind(this),this.reloadMainThread=this.reloadMainThread.bind(this),this.loadMore=this.loadMore.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,t){return this._core.switchToThread(e,t)}switchToNewThread(){return this._core.switchToNewThread()}getLoadThreadsPromise(){return this._core.getLoadThreadsPromise()}reload(){return this._core.reload?.()??zg}reloadMainThread(){return this._core.reloadMainThread?.()??zg}loadMore(){return this._core.loadMore?.()??zg}getState(){return this._getState()}subscribe(e){return this._stateBinding.subscribe(e)}_mainThreadListItemRuntime;main;get mainItem(){return this._mainThreadListItemRuntime}getById(e){return new this._runtimeFactory(new ou({path:{ref:`threads[threadId=${JSON.stringify(e)}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>this._core.getThreadRuntimeCore(e),subscribe:e=>this._core.subscribe(e)}),this.mainItem)}getItemByIndex(e){return new Rg(new iu({path:{ref:`threadItems[${e}]`,threadSelector:{type:`index`,index:e}},getState:()=>Vg(this._core,this._core.threadIds[e]),subscribe:e=>this._core.subscribe(e)}),this._core)}getArchivedItemByIndex(e){return new Rg(new iu({path:{ref:`archivedThreadItems[${e}]`,threadSelector:{type:`archiveIndex`,index:e}},getState:()=>Vg(this._core,this._core.archivedThreadIds[e]),subscribe:e=>this._core.subscribe(e)}),this._core)}getItemById(e){return new Rg(new iu({path:{ref:`threadItems[threadId=${e}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>Vg(this._core,e),subscribe:e=>this._core.subscribe(e)}),this._core)}},Ug=class{threads;_thread;_core;constructor(e){this._core=e,this.threads=new Hg(e.threads),this._thread=this.threads.main,this.__internal_bindMethods()}__internal_bindMethods(){this.registerModelContextProvider=this.registerModelContextProvider.bind(this)}get thread(){return this._thread}registerModelContextProvider(e){return this._core.registerModelContextProvider(e)}},Wg=new WeakMap,Gg=e=>Wg.get(e)??0,Kg=(e,t)=>Gg(e)===t,qg=e=>{Wg.set(e,Gg(e)+1)},Jg=class{_contextProvider=new cu;registerModelContextProvider(e){return this._contextProvider.registerModelContextProvider(e)}getModelContextProvider(){return this._contextProvider}},Yg=Object.freeze([]),Xg=`DEFAULT_THREAD_ID`,Zg=Object.freeze([Xg]),Qg=Object.freeze({id:Xg,remoteId:void 0,externalId:void 0,status:`regular`}),$g=Promise.resolve(),e_=Object.freeze({[Xg]:Qg}),t_=class{_mainThreadId=Xg;_threads=Zg;_archivedThreads=Yg;_threadData=e_;adapter={};get isLoading(){return this.adapter.isLoading??!1}get newThreadId(){}get threadIds(){return this._threads}get archivedThreadIds(){return this._archivedThreads}get threadItems(){return this._threadData}getLoadThreadsPromise(){return $g}_mainThread;get mainThreadId(){return this._mainThreadId}threadFactory;constructor(e={},t){this.threadFactory=t,this.__internal_setAdapter(e,!0)}getMainThreadRuntimeCore(){return this._mainThread}getThreadRuntimeCore(){throw Error(`Method not implemented.`)}getItemById(e){return this._threadData[e]}__internal_setAdapter(e,t=!1){let n=this.adapter;this.adapter=e;let r=e.threadId??Xg,i=e.threads??Yg,a=e.archivedThreads??Yg,o=n.threadId??Xg,s=n.threads??Yg,c=n.archivedThreads??Yg;!t&&o===r&&s===i&&c===a||((s!==i||c!==a||o!==r)&&(this._threadData={...e_,...Object.fromEntries(e.threads?.map(e=>[e.id,{...e,remoteId:e.remoteId,externalId:e.externalId,status:`regular`}])??[]),...Object.fromEntries(e.archivedThreads?.map(e=>[e.id,{...e,remoteId:e.remoteId,externalId:e.externalId,status:`archived`}])??[])}),s!==i&&(this._threads=this.adapter.threads?.map(e=>e.id)??Yg),c!==a&&(this._archivedThreads=this.adapter.archivedThreads?.map(e=>e.id)??Yg),(t||o!==r)&&(t||qg(this._mainThread),this._mainThreadId=r,this._mainThread=this.threadFactory()),this._threadData[this._mainThreadId]||(this._threadData={...this._threadData,[this._mainThreadId]:{id:this._mainThreadId,remoteId:void 0,externalId:void 0,status:`regular`}}),this._notifySubscribers())}async reloadMainThread(){this._mainThread.unstable_refetchThread&&await this._mainThread.unstable_refetchThread()}async switchToThread(e,t){if(this._mainThreadId===e)return;let n=this.adapter.onSwitchToThread;if(!n)throw Error(`External store adapter does not support switching to thread`);await n(e)}async switchToNewThread(){let e=this.adapter.onSwitchToNewThread;if(!e)throw Error(`External store adapter does not support switching to new thread`);await e()}async rename(e,t){let n=this.adapter.onRename;if(!n)throw Error(`External store adapter does not support renaming`);await n(e,t)}async updateCustom(e,t){let n=this.adapter.onUpdateCustom;if(!n)throw Error(`External store adapter does not support updating custom metadata`);await n(e,t)}async detach(){}async archive(e){let t=this.adapter.onArchive;if(!t)throw Error(`External store adapter does not support archiving`);await t(e)}async unarchive(e){let t=this.adapter.onUnarchive;if(!t)throw Error(`External store adapter does not support unarchiving`);await t(e)}async delete(e){let t=this.adapter.onDelete;if(!t)throw Error(`External store adapter does not support deleting`);await t(e)}initialize(e){return Promise.resolve({remoteId:e,externalId:void 0})}generateTitle(){throw Error(`Method not implemented.`)}_subscriptions=new Set;subscribe(e){return this._subscriptions.add(e),()=>this._subscriptions.delete(e)}_notifySubscribers(){eu(this._subscriptions)}},n_={fromArray:e=>{let t=e.map(e=>lm(e,tm(),xm(!1,!1,!1,!1,void 0)));return{messages:t.map((e,n)=>({parentId:n>0?t[n-1].id:null,message:e}))}},fromBranchableArray:(e,t)=>{let n=xm(!1,!1,!1,!1,void 0);return{...t?.headId===void 0?void 0:{headId:t.headId},messages:e.map(({message:e,parentId:t})=>{if(!e.id)throw Error(`ExportedMessageRepository.fromBranchableArray: Each message must have an 'id' field set.`);return{parentId:t,message:lm(e,e.id,n)}})}}},r_=e=>{let t=e;for(;t.next;)t=t.next;return`current`in t?t:null},i_=class{_value=null;func;constructor(e){this.func=e}get value(){return this._value===null&&(this._value=this.func()),this._value}dirty(){this._value=null}},a_=class{messages=new Map;head=null;root={children:[],next:null};updateLevels(e,t){let n=[{message:e,level:t}];for(;n.length>0;){let e=n.pop();e.message.level=e.level;for(let t of e.message.children){let r=this.messages.get(t);r&&n.push({message:r,level:e.level+1})}}}performOp(e,t,n){let r=t.prev??this.root,i=e??this.root;if(n!==`relink`||r!==i){if(n===`relink`){for(let n=e;n;n=n.prev)if(n.current.id===t.current.id)throw Error(`MessageRepository(performOp/relink): 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.`)}if(n!==`link`&&(r.children=r.children.filter(e=>e!==t.current.id),r.next===t)){let e=r.children.at(-1),t=e?this.messages.get(e):null;if(t===void 0)throw Error(`MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui.`);r.next=t}if(n!==`cut`){i.children=[...i.children,t.current.id],(r_(t)===this.head||i.next===null)&&(i.next=t),t.prev=e;let n=e?e.level+1:0;this.updateLevels(t,n)}}}_messages=new i_(()=>{let e=Array((this.head?.level??-1)+1);for(let t=this.head;t;t=t.prev)e[t.level]=t.current;return e});get headId(){return this.head?.current.id??null}get canonicalHeadId(){let e=this.head;for(;e?.current.metadata?.isOptimistic;)e=e.prev;return e?.current.id??null}getMessages(e){if(e===void 0||e===this.head?.current.id)return this._messages.value;let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(getMessages): Head message not found. This is likely an internal bug in assistant-ui.`);let n=Array(t.level+1);for(let e=t;e;e=e.prev)n[e.level]=e.current;return n}addOrUpdateMessage(e,t){let n=this.messages.get(t.id),r=e?this.messages.get(e):null;if(r===void 0)throw Error(`MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui.`);if(n){n.current=t,this.performOp(r,n,`relink`),this._messages.dirty();return}let i={prev:r,current:t,next:null,children:[],level:r?r.level+1:0};this.messages.set(t.id,i),this.performOp(r,i,`link`),this.head===r&&(this.head=i),this._messages.dirty()}getMessage(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui.`);return{parentId:t.prev?.current.id??null,message:t.current,index:t.level}}deleteMessage(e,t){let n=this.messages.get(e);if(!n)throw Error(`MessageRepository(deleteMessage): Message not found. This is likely an internal bug in assistant-ui.`);let r=t===void 0?n.prev:t===null?null:this.messages.get(t);if(r===void 0)throw Error(`MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui.`);for(let e of n.children){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui.`);this.performOp(r,t,`relink`)}this.performOp(null,n,`cut`),this.messages.delete(e),this.head===n&&(this.head=r_(r??this.root)),this._messages.dirty()}getBranches(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui.`);let{children:n}=t.prev??this.root;return n}evictOffBranchOptimisticMessages(e,t){if(!e)return;let n=new Set;for(let e=t;e;e=e.prev)n.add(e.current.id);let r=[];for(let t=e;t&&!n.has(t.current.id);t=t.prev)t.current.metadata?.isOptimistic&&r.push(t.current.id);for(let e of r)this.messages.has(e)&&this.deleteMessage(e)}switchToBranch(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui.`);let n=this.head,r=t.prev??this.root;r.next=t,this.head=r_(t),this.evictOffBranchOptimisticMessages(n,this.head),this._messages.dirty()}resetHead(e){if(e===null){this.clear();return}let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui.`);let n=this.head;if(t.children.length>0){let e=[...t.children];for(;e.length>0;){let t=e.pop(),n=this.messages.get(t);if(n){for(let t of n.children)e.push(t);this.messages.delete(t)}}t.children=[],t.next=null}this.head=t;for(let e=t;e;e=e.prev)e.prev?e.prev.next=e:this.root.next=e;this.evictOffBranchOptimisticMessages(n,this.head),this._messages.dirty()}clear(){this.messages.clear(),this.head=null,this.root={children:[],next:null},this._messages.dirty()}export(){let e=[];for(let[,t]of this.messages){if(t.current.metadata?.isOptimistic)continue;let n=t.prev;for(;n&&n.current.metadata?.isOptimistic;)n=n.prev;e.push({message:t.current,parentId:n?.current.id??null})}return{headId:this.canonicalHeadId,messages:e}}import({headId:e,messages:t}){for(let{message:e,parentId:n}of t)this.addOrUpdateMessage(n,e);this.resetHead(e??t.at(-1)?.message.id??null)}},o_=Object.freeze([]),s_=e=>{let t=globalThis.Buffer;if(t)return t.from(e).toString(`base64`);let n=``,r=32768;for(let t=0;t<e.length;t+=r)n+=String.fromCharCode(...e.subarray(t,t+r));return btoa(n)},c_=async e=>{if(typeof FileReader>`u`){let t=await e.arrayBuffer();return`data:${e.type||`application/octet-stream`};base64,${s_(new Uint8Array(t))}`}return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=e=>n(e),r.readAsDataURL(e)})};function l_(e,t){if(t===`*`)return!0;let n=t.split(`,`).map(e=>e.trim().toLowerCase()),r=`.${e.name.split(`.`).pop().toLowerCase()}`,i=e.type.split(`;`,1)[0].trim().toLowerCase();for(let e of n){if(e.startsWith(`.`)&&e===r||e.includes(`/`)&&e===i)return!0;if(e.endsWith(`/*`)){let t=e.split(`/`)[0];if(i.startsWith(`${t}/`))return!0}}return!1}function u_(e){let t=tm();return e.type===`image`?{id:t,type:`image`,name:e.filename??`image`,content:[e],status:{type:`complete`}}:e.type===`file`?{id:t,type:`document`,name:e.filename??`document`,contentType:e.mimeType,content:[e],status:{type:`complete`}}:e.type===`audio`?{id:t,type:`audio`,name:`audio.${e.audio.format}`,contentType:`audio/${e.audio.format}`,content:[e],status:{type:`complete`}}:{id:t,type:`data`,name:e.name,content:[e],status:{type:`complete`}}}function d_(e){let t=[];for(let n of e)n.type!==`text`&&t.push(u_(n));return t}var f_=e=>`content`in e&&!(`lastModified`in e),p_=e=>e.status.type===`complete`,m_=class extends nu{isEditing=!0;enrichWithComposerMetadata(e,t){return t?{...e,metadata:{...e.metadata,custom:{...e.metadata?.custom,...t}}}:e}get attachmentAccept(){return this.getAttachmentAdapter()?.accept??`*`}_attachments=[];get attachments(){return this._attachments}setAttachments(e){this._attachments=e,this._notifySubscribers()}get isEmpty(){return!this.text.trim()&&!this.attachments.length}_text=``;get text(){return this._text}_role=`user`;get role(){return this._role}_runConfig={};get runConfig(){return this._runConfig}_quote=void 0;get quote(){return this._quote}setQuote(e){this._quote!==e&&(this._quote=e,this._notifySubscribers())}setText(e){this._text!==e&&(this._text=e,this._rebaseDictation(e),this._notifySubscribers())}_rebaseDictation(e){if(!this._dictation)return;this._dictationBaseText=e,this._currentInterimText=``;let{status:t,inputDisabled:n}=this._dictation;this._dictation=n?{status:t,inputDisabled:n}:{status:t}}setRole(e){this._role!==e&&(this._role=e,this._notifySubscribers())}setRunConfig(e){this._runConfig!==e&&(this._runConfig=e,this._notifySubscribers())}_isSending=!1;_removedDuringSend=new Set;_sendGeneration=0;_attachmentAddOperations=new Set;_cancelAttachmentAdd(e){for(let t of[...this._attachmentAddOperations])t.attachmentIds.has(e)&&(t.cancelled=!0,this._attachmentAddOperations.delete(t))}_cancelAllAttachmentAdds(){for(let e of this._attachmentAddOperations)e.cancelled=!0;this._attachmentAddOperations.clear()}_emptyTextAndAttachments(){this._attachments=[],this._text=``,this._notifySubscribers()}async _onClearAttachments(){let e=this.getAttachmentAdapter();if(e){let t=this._attachments.filter(e=>!p_(e));await Promise.all(t.map(t=>e.remove(t)))}}async reset(){if(this._cancelAllAttachmentAdds(),this._sendGeneration++,this._isSending=!1,this._removedDuringSend.clear(),this._attachments.length===0&&this._text===``&&this._role===`user`&&Object.keys(this._runConfig).length===0&&this._quote===void 0)return;this._role=`user`,this._runConfig={},this._quote=void 0;let e=this._onClearAttachments();this._emptyTextAndAttachments(),await e}async clearAttachments(){this._cancelAllAttachmentAdds();let e=this._onClearAttachments();this.setAttachments([]),await e}async send(e){if(!this.canSend||this._isSending)return;this._dictationSession&&(this._dictationSession.cancel(),this._cleanupDictation());let t=this.getAttachmentAdapter(),n=this.attachments.map(async e=>{if(p_(e))return e;if(!t)throw Error(`Attachments are not supported`);return await t.send(e)}),r=this.attachments,i=this.text,a=this._quote,o=this.role,s=this.runConfig;this._quote=void 0,this._text=``,this._isSending=!0;let c=++this._sendGeneration;this._notifySubscribers();let l;try{l=await Promise.all(n)}catch(e){throw c===this._sendGeneration&&(!this.text.trim()&&this._quote===void 0&&(this._text=i,this._rebaseDictation(i),this._quote=a,this._notifySubscribers()),Promise.allSettled(n).then(()=>{c===this._sendGeneration&&(this._removedDuringSend.clear(),this._isSending=!1,this._notifySubscribers())})),e}if(c!==this._sendGeneration)return;let u=new Set(r.map(e=>e.id));this._attachments=this._attachments.filter(e=>!u.has(e.id)),this._isSending=!1,this._notifySubscribers();let d=l.filter(e=>!this._removedDuringSend.has(e.id));this._removedDuringSend.clear();let f={createdAt:new Date,role:o,content:i?[{type:`text`,text:i}]:[],attachments:d,runConfig:s,metadata:{custom:{...a?{quote:a}:{}}}},p={text:i,quote:a,attachments:d},m;try{m=this.handleSend(f,e)}catch(e){throw this._restoreUnsentDraft(e,c,p),e}m&&m.catch(e=>{this._restoreUnsentDraft(e,c,p)}),this._notifyEventSubscribers(`send`,{})}restoreDraft(e){return this._text.trim()||this._quote!==void 0||this._attachments.length>0?!1:(this._text=e.text,this._rebaseDictation(e.text),this._quote=e.quote,this._attachments=e.attachments??[],this._notifySubscribers(),!0)}retractDraft(e){let t=e.attachments===void 0?this._attachments.length===0:this._attachments===e.attachments;this._text!==e.text||this._quote!==e.quote||!t||(this._text=``,this._rebaseDictation(``),this._quote=void 0,this._attachments=[],this._notifySubscribers())}_restoreUnsentDraft(e,t,n){lg(e)&&t===this._sendGeneration&&this.restoreDraft(n)}cancel(){this.handleCancel()}get queue(){return o_}moveQueueItem(e,t){}removeQueueItem(e){}async addAttachment(e){if(f_(e)){let t=this.getAttachmentAdapter();if(t&&!l_({name:e.name,type:e.contentType??``},t.accept)){let n=`File type ${e.contentType||`unknown`} is not accepted. Accepted types: ${t.accept}`,r=Error(n);throw this._safeEmitAttachmentAddError(`not-accepted`,n,void 0,r),r}let n={id:e.id??tm(),type:e.type??`document`,name:e.name,contentType:e.contentType,content:e.content,status:{type:`complete`}};this._attachments=[...this._attachments,n],this._notifySubscribers(),this._notifyEventSubscribers(`attachmentAdd`,{});return}let t=this.getAttachmentAdapter();if(!t){let e=`Attachments are not supported`,t=Error(e);throw this._safeEmitAttachmentAddError(`no-adapter`,e,void 0,t),t}if(!l_({name:e.name,type:e.type},t.accept)){let n=`File type ${e.type||`unknown`} is not accepted. Accepted types: ${t.accept}`,r=Error(n);throw this._safeEmitAttachmentAddError(`not-accepted`,n,void 0,r),r}let n={cancelled:!1,attachmentIds:new Set},r=this._attachmentAddOperations;r.add(n);let i=e=>{if(n.cancelled)return!1;n.attachmentIds.add(e.id);let t=this._attachments.findIndex(t=>t.id===e.id);return this._attachments=t===-1?[...this._attachments,e]:[...this._attachments.slice(0,t),e,...this._attachments.slice(t+1)],this._notifySubscribers(),!0},a;try{let n=t.add({file:e});if(Symbol.asyncIterator in n){for await(let e of n)if(a=e,!i(e))break}else a=await n,i(a)}catch(e){if(n.cancelled)return;throw a&&i({...a,status:{type:`incomplete`,reason:`error`,message:e instanceof Error?e.message:String(e)}}),this._safeEmitAttachmentAddError(`adapter-error`,e instanceof Error?e.message:String(e),a?.id,e instanceof Error?e:void 0),e}finally{r.delete(n)}n.cancelled||(a?.status.type===`incomplete`&&a.status.reason===`error`?this._safeEmitAttachmentAddError(`adapter-error`,a.status.message??`Attachment upload did not complete successfully.`,a.id):this._notifyEventSubscribers(`attachmentAdd`,{}))}_safeEmitAttachmentAddError(e,t,n,r){try{this._notifyEventSubscribers(`attachmentAddError`,{reason:e,message:t,...n!==void 0&&{attachmentId:n},...r!==void 0&&{error:r}})}catch(e){console.error(`[assistant-ui] attachmentAddError subscriber threw:`,e)}}async removeAttachment(e){let t=this._attachments.findIndex(t=>t.id===e);if(t===-1)throw Error(`Attachment not found`);let n=this._attachments[t];if(this._cancelAttachmentAdd(e),this._isSending&&this._removedDuringSend.add(e),!p_(n)){let t=this.getAttachmentAdapter();if(!t)throw Error(`Attachments are not supported`);try{await t.remove(n)}catch(t){let n=t instanceof Error?t.message:String(t);throw this._attachments=this._attachments.map(t=>t.id===e&&!p_(t)?{...t,status:{type:`incomplete`,reason:`error`,message:n}}:t),this._notifySubscribers(),t}}this._attachments=this._attachments.filter(t=>t.id!==e),this._notifySubscribers()}_dictation;_dictationSession;_dictationUnsubscribes=[];_dictationBaseText=``;_currentInterimText=``;_dictationSessionIdCounter=0;_activeDictationSessionId;_isCleaningDictation=!1;get dictation(){return this._dictation}_isActiveSession(e,t){return this._activeDictationSessionId===e&&this._dictationSession===t}startDictation(){let e=this.getDictationAdapter();if(!e)throw Error(`Dictation adapter not configured`);if(this._dictationSession){for(let e of this._dictationUnsubscribes)e();this._dictationUnsubscribes=[],this._dictationSession.stop().catch(()=>{}),this._dictationSession=void 0}let t=e.disableInputDuringDictation??!1;this._dictationBaseText=this._text,this._currentInterimText=``;let n=e.listen();this._dictationSession=n;let r=++this._dictationSessionIdCounter;this._activeDictationSessionId=r,this._dictation={status:n.status,inputDisabled:t},this._notifySubscribers();let i=n.onSpeech(e=>{if(!this._isActiveSession(r,n))return;let t=e.isFinal!==!1,i=this._dictationBaseText&&!this._dictationBaseText.endsWith(` `)&&e.transcript?` `:``;if(t){if(this._dictationBaseText=this._dictationBaseText+i+e.transcript,this._currentInterimText=``,this._text=this._dictationBaseText,this._dictation){let{transcript:e,...t}=this._dictation;this._dictation=t}this._notifySubscribers()}else this._currentInterimText=i+e.transcript,this._text=this._dictationBaseText+this._currentInterimText,this._dictation&&={...this._dictation,transcript:e.transcript},this._notifySubscribers()});this._dictationUnsubscribes.push(i);let a=n.onSpeechStart(()=>{this._isActiveSession(r,n)&&(this._dictation={status:{type:`running`},inputDisabled:t,...this._dictation?.transcript&&{transcript:this._dictation.transcript}},this._notifySubscribers())});this._dictationUnsubscribes.push(a);let o=n.onSpeechEnd(()=>{this._cleanupDictation({sessionId:r})});this._dictationUnsubscribes.push(o);let s=setInterval(()=>{this._isActiveSession(r,n)&&n.status.type===`ended`&&this._cleanupDictation({sessionId:r})},100);this._dictationUnsubscribes.push(()=>clearInterval(s))}stopDictation(){if(!this._dictationSession)return;let e=this._dictationSession,t=this._activeDictationSessionId,n=()=>this._cleanupDictation({sessionId:t});e.stop().then(n,n)}_cleanupDictation(e){if(!(e?.sessionId!==void 0&&e.sessionId!==this._activeDictationSessionId||this._isCleaningDictation)){this._isCleaningDictation=!0;try{for(let e of this._dictationUnsubscribes)e();this._dictationUnsubscribes=[],this._dictationSession=void 0,this._activeDictationSessionId=void 0,this._dictation=void 0,this._dictationBaseText=``,this._currentInterimText=``,this._notifySubscribers()}finally{this._isCleaningDictation=!1}}}_eventSubscribers=new Map;_notifyEventSubscribers(e,t){let n=this._eventSubscribers.get(e);n&&Ql(n,t,`Composer runtime "${e}"`)}unstable_on(e,t){let n=t,r=this._eventSubscribers.get(e);return r||(r=new Set,this._eventSubscribers.set(e,r)),r.add(n),()=>{this._eventSubscribers.get(e)?.delete(n)}}},h_=e=>e.capabilities?.cancel?Mg(e):!1,g_=class extends m_{get canCancel(){return h_(this.runtime)}get canSend(){return!this.isEmpty&&!this.runtime.isSendDisabled&&!this._isSending}_queueCache;get queue(){let e=this.runtime.getSteerQueueItems?.()??o_,t=this.runtime.getQueueItems?.()??o_,n=this._queueCache;if(n&&n.steer===e&&n.queue===t)return n.flat;let r=e.length===0?t:t.length===0?e:[...e,...t];return this._queueCache={steer:e,queue:t,flat:r},r}moveQueueItem(e,t){this.runtime.moveQueueItem?.(e,t)}removeQueueItem(e){this.runtime.removeQueueItem?.(e)}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}runtime;constructor(e){super(),this.runtime=e,this.connect()}connect(){let e=!1,t=this.runtime.isSendDisabled,n=this.queue;return this.runtime.subscribe(()=>{let r=!1,i=this.canCancel;e!==i&&(e=i,r=!0),t!==this.runtime.isSendDisabled&&(t=this.runtime.isSendDisabled,r=!0),n!==this.queue&&(n=this.queue,r=!0),r&&this._notifySubscribers()})}async handleSend(e,t){return this.runtime.append({...e,parentId:this.runtime.messages.at(-1)?.id??null,sourceId:null,startRun:t?.startRun,steer:t?.steer})}async handleCancel(){this.runtime.cancelRun()}},__=class extends m_{get canCancel(){return!0}get canSend(){return!this.isEmpty&&!this._isSending}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}_nonTextPassthrough;_parentId;_sourceId;runtime;endEditCallback;constructor(e,t,{parentId:n,message:r}){super(),this.runtime=e,this.endEditCallback=t,this._parentId=n,this._sourceId=r.id,this.setText(Cg(r)),this.setRole(r.role);let i;r.role===`user`?(i=[...r.attachments??[],...d_(r.content)],this._nonTextPassthrough=[]):(i=r.attachments??[],this._nonTextPassthrough=r.content.filter(e=>e.type!==`text`)),this.setAttachments(i),this.setRunConfig({...e.composer.runConfig})}get parentId(){return this._parentId}get sourceId(){return this._sourceId}async handleSend(e,t){let n=this._nonTextPassthrough.length>0?[...e.content,...this._nonTextPassthrough]:e.content,r=this.runtime.append({...e,content:n,parentId:this._parentId,sourceId:this._sourceId,startRun:t?.startRun});return this.handleCancel(),r}handleCancel(){this.endEditCallback(),this._notifySubscribers()}},v_=class{_subscriptions=new Set;_isInitialized=!1;repository=new a_;_voiceMessages=[];_voiceGeneration=0;_cachedMergedMessages=null;_cachedVoiceGeneration=-1;_cachedMergedBase=null;_markVoiceMessagesDirty(){this._voiceGeneration++,this._cachedMergedMessages=null}_getBaseMessages(){return this.repository.getMessages()}get messages(){if(this._voiceMessages.length===0)return this._getBaseMessages();let e=this._getBaseMessages();return(this._cachedVoiceGeneration!==this._voiceGeneration||this._cachedMergedBase!==e)&&(this._cachedMergedMessages=[...e,...this._voiceMessages],this._cachedVoiceGeneration=this._voiceGeneration,this._cachedMergedBase=e),this._cachedMergedMessages}get state(){let e;for(let t of this.messages)t.role===`assistant`&&(e=t);return e?.metadata.unstable_state??null}composer=new g_(this);_contextProvider;constructor(e){this._contextProvider=e}getModelContext(){return this._contextProvider.getModelContext()}enrichAppendMetadata(e,t=e.parentId){if(e.role!==`user`)return e;let n=this.messages,r=t===null?-1:n.findIndex(e=>e.id===t),i=_p(this.getModelContext().unstable_composerMetadata,n.slice(0,r+1));return i?{...e,metadata:{...e.metadata,custom:{...e.metadata?.custom,...i}}}:e}_editComposers=new Map;getEditComposer(e){return this._editComposers.get(e)}beginEdit(e){if(this._editComposers.has(e))throw Error(`Edit already in progress`);this._editComposers.set(e,new __(this,()=>this._editComposers.delete(e),this.repository.getMessage(e))),this._notifySubscribers()}getMessageById(e){try{return this.repository.getMessage(e)}catch{let t=this.repository.getMessages(),n=this._voiceMessages.findIndex(t=>t.id===e);return n===-1?void 0:{parentId:n>0?this._voiceMessages[n-1].id:t.at(-1)?.id??null,message:this._voiceMessages[n],index:t.length+n}}}getBranches(e){return this._voiceMessages.some(t=>t.id===e)?[]:this.repository.getBranches(e)}switchToBranch(e){this.repository.switchToBranch(e),this._notifySubscribers()}_notifySubscribers(){for(let e of this._subscriptions)e()}_notifyEventSubscribers(e,t){let n=this._eventSubscribers.get(e);n&&Ql(n,t,`Thread runtime "${e}"`)}subscribe(e){return this._subscriptions.add(e),()=>this._subscriptions.delete(e)}submitFeedback({messageId:e,type:t}){let n=this.adapters?.feedback;if(!n)throw Error(`Feedback adapter not configured`);let{message:r,parentId:i}=this.repository.getMessage(e);if(n.submit({message:r,type:t}),r.role===`assistant`){let e={...r,metadata:{...r.metadata,submittedFeedback:{type:t}}};this.repository.addOrUpdateMessage(i,e)}this._notifySubscribers()}_stopSpeaking;speech;speak(e){let t=this.adapters?.speech;if(!t)throw Error(`Speech adapter not configured`);let{message:n}=this.repository.getMessage(e);this._stopSpeaking?.();let r=t.speak(Cg(n)),i=r.subscribe(()=>{r.status.type===`ended`?(this._stopSpeaking=void 0,this.speech=void 0):this.speech={messageId:e,status:r.status},this._notifySubscribers()});this.speech={messageId:e,status:r.status},this._notifySubscribers(),this._stopSpeaking=()=>{r.cancel(),i(),this.speech=void 0,this._stopSpeaking=void 0}}stopSpeaking(){if(!this._stopSpeaking)throw Error(`No message is being spoken`);this._stopSpeaking(),this._notifySubscribers()}_voiceSession;_voiceUnsubs=[];voice;_voiceVolume=0;_voiceVolumeSubscribers=new Set;getVoiceVolume=()=>this._voiceVolume;subscribeVoiceVolume=e=>(this._voiceVolumeSubscribers.add(e),()=>this._voiceVolumeSubscribers.delete(e));connectVoice(){let e=this.adapters?.voice;if(!e)throw Error(`Voice adapter not configured`);this.disconnectVoice();let t=e.connect({});this._voiceSession=t;let n=[],r=`listening`;this.voice={status:t.status,isMuted:t.isMuted,mode:r},this._voiceVolume=0,this._notifySubscribers(),n.push(t.onStatusChange(e=>{e.type===`ended`?(this._finishVoiceAssistantMessage(),this._voiceSession=void 0,this.voice=void 0):this.voice={status:e,isMuted:t.isMuted,mode:r},this._notifySubscribers()})),n.push(t.onModeChange(e=>{r=e,this.voice&&(this.voice={...this.voice,mode:e},this._notifySubscribers())})),n.push(t.onVolumeChange(e=>{this._voiceVolume=e,Ql(this._voiceVolumeSubscribers,void 0,`Voice volume`)})),n.push(t.onTranscript(e=>{this._handleVoiceTranscript(e)})),this._voiceUnsubs=n}_currentAssistantMsg=null;_handleVoiceTranscript(e){if(this.ensureInitialized(),e.role===`user`)this._finishVoiceAssistantMessage(),this._currentAssistantMsg=null,e.isFinal&&(this._voiceMessages.push({id:tm(),role:`user`,content:[{type:`text`,text:e.text}],metadata:{custom:{}},createdAt:new Date,status:{type:`complete`,reason:`unknown`},attachments:[]}),this._markVoiceMessagesDirty(),this._notifySubscribers());else{if(!this._currentAssistantMsg)this._currentAssistantMsg={id:tm(),role:`assistant`,content:[{type:`text`,text:e.text}],metadata:{unstable_state:this.state,unstable_annotations:[],unstable_data:[],steps:[],custom:{}},status:{type:`running`},createdAt:new Date},this._voiceMessages.push(this._currentAssistantMsg);else{let t=this._voiceMessages.indexOf(this._currentAssistantMsg);if(t===-1)return;let n={...this._currentAssistantMsg,content:[{type:`text`,text:e.text}],...e.isFinal?{status:{type:`complete`,reason:`stop`}}:{}};this._voiceMessages[t]=n,this._currentAssistantMsg=n}e.isFinal&&(this._currentAssistantMsg=null),this._markVoiceMessagesDirty(),this._notifySubscribers()}}_finishVoiceAssistantMessage(){let e=this._voiceMessages.at(-1);if(e?.role===`assistant`&&e.status.type===`running`){let t=this._voiceMessages.length-1;this._voiceMessages[t]={...e,status:{type:`complete`,reason:`stop`}},this._markVoiceMessagesDirty(),this._notifySubscribers()}}disconnectVoice(){this._finishVoiceAssistantMessage(),this._currentAssistantMsg=null;for(let e of this._voiceUnsubs)e();this._voiceUnsubs=[],this._voiceSession?.disconnect(),this._voiceSession=void 0,this.voice=void 0,this._voiceVolume=0,Ql(this._voiceVolumeSubscribers,void 0,`Voice volume`),this._voiceMessages=[],this._markVoiceMessagesDirty(),this._notifySubscribers()}muteVoice(){if(!this._voiceSession)throw Error(`No active voice session`);this._voiceSession.mute(),this.voice={...this.voice,isMuted:!0},this._notifySubscribers()}unmuteVoice(){if(!this._voiceSession)throw Error(`No active voice session`);this._voiceSession.unmute(),this.voice={...this.voice,isMuted:!1},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(n_.fromArray(e??[]))}_eventSubscribers=new Map;unstable_on(e,t){let n=t;if(e===`modelContextUpdate`)return this._contextProvider.subscribe?.(()=>n({}))??(()=>{});let r=this._eventSubscribers.get(e);return r||(r=new Set,this._eventSubscribers.set(e,r)),r.add(n),e===`initialize`&&this._isInitialized&&queueMicrotask(()=>{r.has(n)&&n({})}),()=>{this._eventSubscribers.get(e)?.delete(n)}}},y_=Symbol.for(`assistant-stream.tool-execution-id`),b_=e=>{try{return JSON.parse(e),!0}catch{return!1}},x_=e=>{try{return JSON.parse(e)}catch{return}},S_=(e,t)=>{let n=x_(e),r=x_(t);return n===void 0||r===void 0?!1:ip(n,r)},C_=e=>e[y_],w_=class{_getTools;_callbacks;_entries=new Map;_humanInput=new Map;_executing=new Set;_settledResolvers=[];_statuses=new Map;_ac=new AbortController;_pendingRestore=!0;_lastSnapshot=null;_isRunning=!1;_controller;_pipelineDead=!1;_pipelineRestartUsed=!1;constructor(e,t){this._getTools=e,this._callbacks=t,this._initPipeline()}_initPipeline(){let[e,t]=zp();this._controller=t;let n=kh(()=>this._getWrappedTools(),()=>this._ac.signal,(e,t,n)=>this._onHumanInput(e,t,n),{onExecutionStart:(e,t,n)=>this._onExecutionStart(e,n),onExecutionEnd:(e,t,n)=>this._onExecutionEnd(e,n)});e.pipeThrough(n).pipeThrough(new Fp).pipeTo(new WritableStream({write:e=>{try{if(e.type!==`result`)return;this._handleResultChunk(e)}catch(e){console.error(`[ToolInvocationTracker] result chunk handling failed`,e)}}})).catch(e=>{console.error(`[ToolInvocationTracker] stream pipeline failed; will attempt single restart on next setState`,e),this._pipelineDead=!0})}setState(e){try{if(this._pipelineDead){if(this._pipelineRestartUsed)return;this._pipelineRestartUsed=!0,this._pipelineDead=!1,this._demoteEntriesToRestored(),this._executing.clear(),this._ac=new AbortController,this._initPipeline()}if(this._lastSnapshot&&this._lastSnapshot.messages===e.messages&&this._lastSnapshot.isRunning===e.isRunning&&this._lastSnapshot.isLoading===e.isLoading)return;e.isLoading===!0&&(this._pendingRestore=!0);let t=this._isRunning;this._isRunning=e.isRunning;try{this._processMessages(e.messages)}catch(e){throw this._isRunning=t,e}this._lastSnapshot=e,this._pendingRestore=!1}catch(e){console.error(`[ToolInvocationTracker] setState failed; snapshot dropped`,e)}}reset(){try{this._pendingRestore=!0,this._entries.clear(),this._lastSnapshot=null,this.abort(),this._statuses.size>0&&(this._statuses=new Map,this._invokeOnStatusesChange())}catch(e){console.error(`[ToolInvocationTracker] reset failed`,e)}}abort(){try{if(this._humanInput.forEach(({reject:e})=>{try{e(Error(`Tool execution aborted`))}catch{}}),this._humanInput.clear(),this._ac.abort(),this._ac=new AbortController,this._executing.size===0)return Promise.resolve();let e=new Set(this._executing);return new Promise(t=>{this._settledResolvers.push({executionIds:e,resolve:t})})}catch(e){return console.error(`[ToolInvocationTracker] abort failed`,e),Promise.resolve()}}resume(e,t){try{let n=this._humanInput.get(e);return n?(this._humanInput.delete(e),this._setStatus(e,{type:`executing`}),n.resolve(t),!0):!1}catch(e){return console.error(`[ToolInvocationTracker] resume failed`,e),!1}}getStatuses(){return this._statuses}_getWrappedTools(){let e=this._getTools();if(e)return Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=t.execute,r=t.streamCall;return n===void 0&&r===void 0?[e,t]:[e,{...t,...n!==void 0&&{execute:(...[e,t])=>{let r=C_(t),i=this._captureExecution(t.toolCallId,r);return!i||i.skipExecute?new Promise(()=>{}):n(e,t)}},...r!==void 0&&{streamCall:(...[e,t])=>{let n=C_(t);if(this._captureExecution(t.toolCallId,n))return r(e,t)}}}]}))}_captureExecution(e,t){if(t===void 0)return;let n=this._entries.get(e);if(n?.controller)return n.executionId===void 0&&(n.executionId=t),n.executionId===t?n:void 0}_onHumanInput(e,t,n){return new Promise((r,i)=>{let a=this._entries.get(e);if(!a?.controller||a.executionId!==n){i(Error(`Tool execution aborted`));return}let o=this._humanInput.get(e);if(o)try{o.reject(Error(`Human input request was superseded by a new request`))}catch{}this._humanInput.set(e,{executionId:n,resolve:r,reject:i}),this._setStatus(e,{type:`interrupt`,payload:{type:`human`,payload:t}})})}_onExecutionStart(e,t){this._captureExecution(e,t)&&(this._entries.get(e).skipExecute||(this._executing.add(t),this._setStatus(e,{type:`executing`})))}_onExecutionEnd(e,t){if(t===void 0||!this._executing.delete(t))return;this._entries.get(e)?.executionId===t&&this._deleteStatus(e);let n=[];this._settledResolvers.forEach(({executionIds:e,resolve:t})=>{if([...e].some(e=>this._executing.has(e))){n.push({executionIds:e,resolve:t});return}try{t()}catch{}}),this._settledResolvers.length=0,this._settledResolvers.push(...n)}_handleResultChunk(e){let t=e.meta.toolCallId,n=C_(e),r=this._entries.get(t);!r||r.executionId!==n||r?.hasResult||this._invokeOnResult({type:`add-tool-result`,toolCallId:t,toolName:e.meta.toolName,result:e.result,isError:e.isError,...e.artifact!==void 0&&{artifact:e.artifact},...e.modelContent!==void 0&&{modelContent:e.modelContent}})}_invokeOnResult(e){try{this._callbacks.onResult(e)}catch(e){console.error(`[ToolInvocationTracker] onResult callback threw; result dropped`,e)}}_invokeOnStatusesChange(){try{this._callbacks.onStatusesChange(this._statuses)}catch(e){console.error(`[ToolInvocationTracker] onStatusesChange callback threw; status change not propagated`,e)}}_setStatus(e,t){let n=new Map(this._statuses);n.set(e,t),this._statuses=n,this._invokeOnStatusesChange()}_deleteStatus(e){if(!this._statuses.has(e))return;let t=new Map(this._statuses);t.delete(e),this._statuses=t,this._invokeOnStatusesChange()}_hasExecutableTool(e){let t=this._getTools()?.[e];return t?.execute!==void 0||t?.streamCall!==void 0}_shouldCloseArgsStream({toolName:e,argsText:t,hasResult:n}){return n?!0:(this._hasExecutableTool(e)||!this._isRunning)&&b_(t)}_startActiveEntry(e,t,n){let r={toolName:t,controller:this._controller.addToolCallPart({toolName:t,toolCallId:e}),argsText:``,hasResult:!1,skipExecute:n,argsComplete:!1};return this._entries.set(e,r),r}_demoteEntriesToRestored(){for(let[e,t]of this._entries)t.controller&&this._entries.set(e,{toolName:t.toolName,argsText:t.argsText,hasResult:t.hasResult})}_processArgsText(e,t){if(!e.controller)return;let n=t.result!==void 0;if(t.argsText!==e.argsText){let r=!0;if(e.argsComplete)S_(e.argsText,t.argsText)&&(e.argsText=t.argsText),r=!1;else if(!t.argsText.startsWith(e.argsText)){if(b_(e.argsText)&&b_(t.argsText)&&S_(e.argsText,t.argsText)){let i=this._shouldCloseArgsStream({toolName:t.toolName,argsText:t.argsText,hasResult:n});i&&e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=i,r=!1}else r=!1}if(r&&e.controller){let r=t.argsText.slice(e.argsText.length);e.controller.argsText.append(r);let i=this._shouldCloseArgsStream({toolName:t.toolName,argsText:t.argsText,hasResult:n});i&&e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=i}}!e.argsComplete&&e.controller&&this._shouldCloseArgsStream({toolName:t.toolName,argsText:e.argsText,hasResult:n})&&(e.controller.argsText.close(),e.argsComplete=!0)}_processMessages(e){let t=this._pendingRestore;for(let n of e)if(!(!n||!Array.isArray(n.content)))for(let e of n.content){if(!e||e.type!==`tool-call`)continue;let n=this._entries.get(e.toolCallId);if(t){n?.controller||this._entries.set(e.toolCallId,{toolName:e.toolName,argsText:e.argsText,hasResult:e.result!==void 0}),e.messages&&this._processMessages(e.messages);continue}let r=n;if(r&&!r.controller){if(e.argsText===r.argsText&&e.result!==void 0===r.hasResult){e.messages&&this._processMessages(e.messages);continue}this._entries.delete(e.toolCallId),r=void 0}if(r||=this._startActiveEntry(e.toolCallId,e.toolName,e.result!==void 0),this._processArgsText(r,e),e.result!==void 0&&!r.hasResult){let{controller:t}=r;if(!t)continue;r.hasResult=!0,r.argsComplete=!0,t.setResponse(new Ep({result:e.result,artifact:e.artifact,isError:e.isError,...e.modelContent===void 0?{}:{modelContent:e.modelContent}})),t.close()}e.messages&&this._processMessages(e.messages)}}},T_=Object.freeze([]),E_=(e,t)=>{Promise.resolve(t).catch(t=>{console.error(`[ExternalStoreThreadRuntimeCore] ${e} callback rejected`,t)})},D_=(e,t)=>{let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(e[r]!==t[r])return!1;return!0},O_=(e,t)=>e&&t[t.length-1]?.role!==`assistant`,k_=class extends v_{_capabilities={switchToBranch:!1,switchBranchDuringRun:!1,edit:!1,delete:!1,reload:!1,refetchThread:!1,cancel:!1,unstable_copy:!1,speech:!1,dictation:!1,voice:!1,attachments:!1,feedback:!1,queue:!1};get capabilities(){return this._capabilities}_messages;isDisabled;isSendDisabled;get isLoading(){return this._store.isLoading??!1}get isRunning(){return this._store.isRunning}_getBaseMessages(){return this._messages}get state(){return this._store.state??super.state}get adapters(){return this._store.adapters}get unstable_refetchThread(){if(this._store.onRefetchThread)return()=>this._store.onRefetchThread()}suggestions=[];extras=void 0;_converter=new Sm;_store;_getInitializePromise;__internal_setGetInitializePromise(e){this._getInitializePromise=e}_transformedQueue;_toolInvocations=null;beginEdit(e){if(!this._store.onEdit)throw Error(`Runtime does not support editing.`);super.beginEdit(e)}constructor(e,t){super(e),this.__internal_setAdapter(t)}__internal_setAdapter(e){if(this._store===e)return;let t=e.isRunning??!1;this.isDisabled=e.isDisabled??!1,this.isSendDisabled=e.isSendDisabled??!1;let n=this._store;this._store=e,n?.queue!==e.queue&&(this._transformedQueue=void 0,e.queue?.__internal_setDispatchTransform?.(e=>{let t=this.messages.at(-1)?.id??null;return this.enrichAppendMetadata({...e,parentId:t},t)}),e.queue?.__internal_setDispatchTransform&&(this._transformedQueue=e.queue)),this.extras!==e.extras&&(this.extras=e.extras);let r=e.suggestions??T_;D_(this.suggestions,r)||(this.suggestions=r);let i={switchToBranch:this._store.setMessages!==void 0,switchBranchDuringRun:!1,edit:this._store.onEdit!==void 0,delete:this._store.onDelete!==void 0||this._store.setMessages!==void 0,reload:this._store.onReload!==void 0,refetchThread:this._store.onRefetchThread!==void 0,cancel:this._store.onCancel!==void 0,speech:this._store.adapters?.speech!==void 0,dictation:this._store.adapters?.dictation!==void 0,voice:this._store.adapters?.voice!==void 0,unstable_copy:this._store.unstable_capabilities?.copy!==!1,attachments:!!this._store.adapters?.attachments,feedback:!!this._store.adapters?.feedback,queue:this._store.queue!==void 0};D_(this._capabilities,i)||(this._capabilities=i);let a;if(e.messageRepository){if(n&&n.isRunning===e.isRunning&&n.messageRepository===e.messageRepository){this._notifySubscribers();return}let t=e.messageRepository.messages,r=e.messageRepository.headId??t.at(-1)?.message.id??null;if(n&&n.messageRepository===e.messageRepository)this.repository.resetHead(r),a=this.repository.getMessages();else{let e=new Set(t.map(({message:e})=>e.id));for(let{message:e,parentId:n}of t)this.repository.addOrUpdateMessage(n,e);for(let{message:t}of this.repository.export().messages)e.has(t.id)||this.repository.deleteMessage(t.id);this.repository.resetHead(r),a=this.repository.getMessages()}}else if(e.messages){if(n){if(n.convertMessage!==e.convertMessage)this._converter=new Sm;else if(n.isRunning===e.isRunning&&n.messages===e.messages){this._notifySubscribers();return}}a=e.convertMessage?this._converter.convertMessages(e.messages,(n,r,i)=>{if(!e.convertMessage)return r;let a=xm(i===(e.messages?.length??0)-1,t,!1,!1,void 0);if(n&&(n.role!==`assistant`||!bm(n.status)||n.status===a))return n;let o=lm(e.convertMessage(r,i),i.toString(),a);return pm(o,r),o}):e.messages;let r=new Set,i=[];for(let e=a.length-1;e>=0;e--){let t=a[e];if(r.has(t.id)){console.warn(`ExternalStoreThreadRuntimeCore: duplicate message id "${t.id}" in the provided messages array; keeping the last occurrence.`);continue}r.add(t.id),i.push(t)}i.length!==a.length&&(a=i.reverse());for(let e=0;e<a.length;e++){let t=a[e],n=a[e-1];this.repository.addOrUpdateMessage(n?.id??null,t)}}else throw Error(`ExternalStoreAdapter must provide either 'messages' or 'messageRepository'`);a.length>0&&this.ensureInitialized(),(n?.isRunning??!1)!==(e.isRunning??!1)&&(e.isRunning?this._notifyEventSubscribers(`runStart`,{}):this._notifyEventSubscribers(`runEnd`,{}));let o=null;O_(t,a)&&(o=tm(),this.repository.addOrUpdateMessage(a.at(-1)?.id??null,lm({role:`assistant`,content:[],metadata:{isOptimistic:!0}},o,{type:`running`}))),this.repository.resetHead(o??a.at(-1)?.id??null),this._messages=this.repository.getMessages(),this._driveToolInvocations(),this._notifySubscribers()}_driveToolInvocations(){if(!this._store.unstable_enableToolInvocations){this._toolInvocations&&(this._toolInvocations.reset(),this._toolInvocations=null,this._store.setToolStatuses?.({}));return}this._toolInvocations||=new w_(()=>this.getModelContext().tools,{onResult:e=>{try{let t=this._findMessageIdForToolCall(e.toolCallId);if(t===void 0)return;E_(`onAddToolResult`,this._store.onAddToolResult?.({messageId:t,toolCallId:e.toolCallId,toolName:e.toolName,result:e.result,isError:e.isError,...e.artifact!==void 0&&{artifact:e.artifact},...e.modelContent!==void 0&&{modelContent:e.modelContent}}))}catch(e){console.error(`[ExternalStoreThreadRuntimeCore] onAddToolResult dispatch failed`,e)}},onStatusesChange:e=>{this._store.setToolStatuses?.(Object.fromEntries(e))}}),this._toolInvocations.setState({messages:this._messages,isRunning:this._store.isRunning??!1,...this._store.isLoading!==void 0&&{isLoading:this._store.isLoading}})}_toolCallToMessageId=new Map;_messagesForToolCallIndex=null;_findMessageIdForToolCall(e){if(this._messagesForToolCallIndex!==this._messages){this._toolCallToMessageId.clear();let e=t=>{for(let n of t)if(Array.isArray(n.content))for(let t of n.content)!t||t.type!==`tool-call`||(this._toolCallToMessageId.set(t.toolCallId,n.id),t.messages&&e(t.messages))};e(this._messages),this._messagesForToolCallIndex=this._messages}return this._toolCallToMessageId.get(e)}switchToBranch(e){if(!this._store.setMessages)throw Error(`Runtime does not support switching branches.`);if(this._store.isRunning)return;let t=this._store.unstable_onBranchChange,n=t?this.repository.canonicalHeadId:null;this.repository.switchToBranch(e),this.updateMessages(this.repository.getMessages()),t&&this._notifyBranchChange(n,t)}_notifyBranchChange(e,t){let n=this.repository.canonicalHeadId;n!==e&&t({headId:n,visibleMessageIds:this.repository.getMessages().map(e=>e.id)})}async append(e){let t=e.sourceId!=null||e.parentId!==(this.messages.at(-1)?.id??null),n=!t&&this._store.queue&&this._store.queue===this._transformedQueue?e:this.enrichAppendMetadata(e),r=Gg(this);this.ensureInitialized();let i=this._getInitializePromise?.();if(!t&&this._store.queue){if(i&&await i,!Kg(this,r))return;n.steer??this._store.isRunning??!1?this._store.queue.steer(n):this._store.queue.enqueue(n);return}if(i?.catch(()=>{}),(n.startRun??n.role===`user`)&&await this._toolInvocations?.abort(),Kg(this,r)){if(t){if(!this._store.onEdit)throw Error(`Runtime does not support editing messages.`);await this._store.onEdit(n)}else await this._store.onNew(n)}}async deleteMessage(e){if(this._store.onDelete){await this._store.onDelete(e);return}if(!this._store.setMessages)throw Error(`Runtime does not support deleting messages.`);this._store.isRunning&&await this._toolInvocations?.abort();let t=this.repository.getMessages();if(t.findIndex(t=>t.id===e)===-1)throw Error(`Message not found.`);this.updateMessages(t.filter(t=>t.id!==e))}getQueueItems(){return this._store?.queue?.items??o_}getSteerQueueItems(){return this._store?.queue?.steerItems??o_}moveQueueItem(e,t){this._store?.queue?.move(e,t)}removeQueueItem(e){this._store?.queue?.remove(e)}async startRun(e){if(!this._store.onReload)throw Error(`Runtime does not support reloading messages.`);await this._toolInvocations?.abort(),await this._store.onReload(e.parentId,e)}async resumeRun(e){if(!this._store.onResume)throw Error(`Runtime does not support resuming runs.`);await this._store.onResume(e)}exportExternalState(){if(!this._store.onExportExternalState)throw Error(`Runtime does not support exporting external states.`);return this._store.onExportExternalState()}importExternalState(e){if(!this._store.onLoadExternalState)throw Error(`Runtime does not support importing external states.`);this._toolInvocations?.reset(),this._store.onLoadExternalState(e)}unstable_notifySessionReset(){this._toolInvocations?.reset(),this._store.queue?.__internal_notifyCancelled?.()}cancelRun(){if(!this._store.onCancel)throw Error(`Runtime does not support cancelling runs.`);let e=Gg(this);this._toolInvocations?.abort(),this._store.queue?.__internal_notifyCancelled?.(),E_(`onCancel`,this._store.onCancel()),this.dropEmptyOptimisticHead();let t=this.repository.getMessages(),n=t[t.length-1],r=this._store.setMessages!==void 0&&n?.role===`user`&&n.id===t.at(-1)?.id&&n.content.every(e=>e.type===`text`)?n:void 0,i;if(r){let e={text:Cg(r),attachments:r.attachments,quote:r.metadata.custom.quote};this.composer.restoreDraft(e)&&(this.repository.deleteMessage(r.id),i={id:r.id,draft:e})}i||this._notifySubscribers(),setTimeout(()=>{if(Kg(this,e)){if(this.dropEmptyOptimisticHead(),i){let e=this.repository.getMessages();e.at(-1)?.id===i.id?this.repository.deleteMessage(i.id):e.some(e=>e.id===i.id)&&this.composer.retractDraft(i.draft)}this.updateMessages(this.repository.getMessages())}},0)}dropEmptyOptimisticHead(){let e=this.repository.getMessages().at(-1);e&&e.metadata.isOptimistic&&e.content.length===0&&this.repository.deleteMessage(e.id)}addToolResult(e){if(!this._store.onAddToolResult)throw Error(`Runtime does not support tool results.`);E_(`onAddToolResult`,this._store.onAddToolResult(e))}resumeToolCall(e){if(!(this._toolInvocations?.resume(e.toolCallId,e.payload)??!1)){if(this._store.onResumeToolCall){this._store.onResumeToolCall(e);return}throw Error(`Tool call ${e.toolCallId} is not waiting for resume.`)}}respondToToolApproval(e){if(!this._store.onRespondToToolApproval)throw Error(`Runtime does not support tool approvals.`);E_(`onRespondToToolApproval`,this._store.onRespondToToolApproval(e))}reset(e){let t=new a_;t.import(n_.fromArray(e??[])),this.updateMessages(t.getMessages())}import(e){super.import(e),this._store.onImport&&this._store.onImport(this.repository.getMessages())}updateMessages=e=>{this._store.convertMessage===void 0?this._store.setMessages?.(e):this._store.setMessages?.(e.flatMap(mm))}},A_=e=>e.adapters?.threadList??{},j_=class extends Jg{threads;constructor(e){super(),this.threads=new t_(A_(e),()=>new k_(this._contextProvider,e))}setAdapter(e){this.threads.__internal_setAdapter(A_(e)),this.threads.getMainThreadRuntimeCore().__internal_setAdapter(e)}},M_=e=>{let t=F(15),n;t[0]===e?n=t[1]:(n=()=>new j_(e),t[0]=e,t[1]=n);let[r]=Pc(n),i;t[2]===r.threads?i=t[3]:(i=()=>()=>{qg(r.threads.getMainThreadRuntimeCore())},t[2]=r.threads,t[3]=i);let a;t[4]===r?a=t[5]:(a=[r],t[4]=r,t[5]=a),L(i,a);let o;t[6]!==r||t[7]!==e?(o=()=>{r.setAdapter(e)},t[6]=r,t[7]=e,t[8]=o):o=t[8],L(o);let{modelContext:s}=Qp()??{},c,l;t[9]!==s||t[10]!==r?(c=()=>{if(s)return r.registerModelContextProvider(s)},l=[s,r],t[9]=s,t[10]=r,t[11]=c,t[12]=l):(c=t[11],l=t[12]),L(c,l);let u;return t[13]===r?u=t[14]:(u=new Ug(r),t[13]=r,t[14]=u),u},N_=e=>{let t={useThreadMessages:({messages:t,isRunning:n,joinStrategy:r,metadata:i})=>Mm({callback:e,messages:t,isRunning:n,joinStrategy:r,metadata:i}),toThreadMessages:(t,n=!1,r={})=>jm(t,e,n,r),toOriginalMessages:e=>{let t=mm(e);if(t.length===0)throw Error(`No original messages found`);return t},toOriginalMessage:e=>t.toOriginalMessages(e)[0],useOriginalMessage:()=>t.useOriginalMessages()[0],useOriginalMessages:()=>{let e=zd(),t=R(t=>{if(e.part.source)return mm(t.part)}),n=R(e=>mm(e.message)),r=t??n;if(r.length===0)throw Error(`No original messages found`);return r}};return t},P_=e=>{let t=Symbol(`${e} extras`),n=e=>typeof e==`object`&&!!e&&t in e;return{provide:e=>(Object.defineProperty(e,t,{value:!0,enumerable:!1,configurable:!0}),e),is:n,tryGet:e=>n(e)?e:void 0,assert:t=>{if(!n(t))throw Error(`The current thread is not backed by the ${e} runtime.`);return t}}},F_=e=>{let{provide:t,is:n,tryGet:r,assert:i}=e,a=e=>i(e.thread.getState().extras);function o(e,...t){let r=t.length>0,a=t[0];return R(t=>{let o=t.thread.extras;return n(o)?e?e(o):o:r?a:i(o)})}return{provide:t,is:n,tryGet:r,get:a,use:o}},I_=e=>F_(P_(e)),L_=e=>e.status?.type!==`running`,R_=(e,t)=>{let n=()=>void t.generateTitle().catch(e=>{sf(e)||console.error(`[assistant-ui] Thread title generation failed`,e)}),r=()=>e.getState().messages.some(L_);if(r())return n(),()=>{};let i=e.subscribe(()=>{r()&&(i(),n())});return i},z_=({threadId:e,generation:t,runtimeHook:n,publish:r,itemRuntime:i})=>{let a=n(),o=a?.thread?.__internal_threadBinding,s=Lc(()=>{o&&r(e,o.getState(),t)},[e,t,o,r]),c=I(!1);c.current||s(),L(()=>{if(o)return c.current=!0,s(),o.outerSubscribe(s)},[o,s]);let l=I(void 0),u=I(!1),d=I(void 0),f=I(!1),p=zc(()=>{if(u.current||i.getState().status!==`new`)return;u.current=!0;let e=i.initialize();l.current=e,e.then(()=>{f.current&&(d.current?.(),d.current=R_(a.thread,i))},()=>{l.current===e&&(l.current=void 0,u.current=!1)})}),m=zc(()=>(p(),l.current));return L(()=>{if(!o)return;let e=o.getState(),t=e.__internal_setGetInitializePromise;typeof t==`function`&&t.call(e,m)},[o]),L(()=>{if(!a?.threads?.main)return;u.current=!1,f.current=!0;let e=a.threads.main.unstable_on(`initialize`,p);return()=>{f.current=!1,e(),d.current?.(),d.current=void 0}},[a]),a},B_=el(({threadId:e,generation:t,parentList:n,runtimeHook:r,parentClient:i,adapters:a,publish:o})=>{let s=Ic(()=>new Rg(new iu({path:{ref:`threadItems[threadId=${e}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>{let t=n.getItemById(e);return t?{id:t.id,remoteId:t.remoteId,externalId:t.externalId,title:t.title,lastMessageAt:t.lastMessageAt,custom:t.custom,status:t.status,isMain:t.id===n.mainThreadId,isRunning:n.unstable_isThreadRunning?.(t.id)??!1}:$l},subscribe:e=>n.subscribe(e)}),n),[n,e]),{client:c}=Rd(i,{threadListItem:Df({runtime:s})});return Wu(c,function(){return Zp(a,function(){return z_({threadId:e,generation:t,runtimeHook:r,publish:o,itemRuntime:s})})})}),V_=e=>{let t=F(3),{detectorRef:n}=e,r,i;return t[0]===n?(r=t[1],i=t[2]):(r=()=>{n.current=!0},i=[n],t[0]=n,t[1]=r,t[2]=i),Rc(r,i),null},H_=class extends nu{runtimeHook;adapterStore=Qf(()=>({defaultAdapters:null,threadAdapters:new Map}));hostStore=Qf(()=>({threads:[],hookEpoch:0}));pendingThreadAdapters=new Map;instances=new Map;nextGeneration=0;parent;constructor(e,t){super(),this.parent=t,this.runtimeHook=e}_whenRuntimeAttached(e){return new Promise((t,n)=>{let r=()=>{let r=this.instances.get(e);if(!r)i(),n(Error(`Thread was deleted before runtime was started`));else if(!r.runtime||r.publishedGeneration!==r.generation)return;else i(),t(r.runtime)},i=this.subscribe(r);r()})}startThreadRuntime(e){if(!this.instances.has(e)){let t=this.nextGeneration++;this.instances.set(e,{generation:t,isRunning:!1}),this._syncHostThreads()}return this._whenRuntimeAttached(e)}__internal_restartThreadRuntime(e){let t=this.instances.get(e);return t?(t.runtime&&qg(t.runtime),t.generation=this.nextGeneration++,this._syncHostThreads(),this._notifySubscribers(),this._whenRuntimeAttached(e)):this.startThreadRuntime(e)}getThreadRuntimeCore(e){let t=this.instances.get(e);if(t)return t.runtime}__internal_isThreadRunning(e){return this.instances.get(e)?.isRunning??!1}runningSubscribers=new Set;__internal_subscribeRunningChanged(e){return this.runningSubscribers.add(e),()=>this.runningSubscribers.delete(e)}_publish=(e,t,n)=>{this._publishThreadRuntime(e,t,n)};_publishThreadRuntime(e,t,n){let r=this.instances.get(e);if(!r||r.generation!==n)return;let i=r.runtime;if(r.runtime=t,r.publishedGeneration=n,i!==t&&this._trackRunning(r),this._notifySubscribers(),i!==void 0&&i!==t)for(let e of this.replacedSubscribers)e()}replacedSubscribers=new Set;__internal_subscribeRuntimeReplaced(e){return this.replacedSubscribers.add(e),()=>this.replacedSubscribers.delete(e)}_trackRunning(e){e.unsubscribeRunning?.();let t=e.runtime;if(!t){e.unsubscribeRunning=void 0,this._setRunning(e,!1);return}this._setRunning(e,Mg(t)),e.unsubscribeRunning=t.subscribe(()=>{this._setRunning(e,Mg(t))})}_setRunning(e,t){if(e.isRunning!==t){e.isRunning=t;for(let e of this.runningSubscribers)e()}}stopThreadRuntime(e){let t=this.instances.get(e);t?.runtime&&qg(t.runtime),t?.unsubscribeRunning?.(),this.instances.delete(e),this.pendingThreadAdapters.delete(e),this._syncHostThreads(),this._notifySubscribers()}setRuntimeHook(e){this.runtimeHook!==e&&(this.runtimeHook=e,this.hostStore.setState(e=>({...e,hookEpoch:e.hookEpoch+1}),!0))}__internal_setDefaultAdapters(e){let t=this.adapterStore.getState();t.defaultAdapters!==e&&this.adapterStore.setState({...t,defaultAdapters:e},!0)}__internal_setThreadAdapters(e,t){let n=this.adapterStore.getState(),r=new Map(n.threadAdapters);t===null?r.delete(e):r.set(e,t),this.adapterStore.setState({...n,threadAdapters:r},!0)}__internal_dispose(){for(let e of[...this.instances.keys()])this.stopThreadRuntime(e)}_syncHostThreads(){this.hostStore.setState(e=>({...e,threads:Array.from(this.instances.entries()).map(([e,{generation:t}])=>({id:e,generation:t}))}),!0)}__internal_useHost(e){let{threads:t,hookEpoch:n}=this.hostStore(),r=this.adapterStore(),i=this.runtimeHook;return Gl(t.map(({id:t,generation:a})=>{let o=this.pendingThreadAdapters.has(t)?this.pendingThreadAdapters.get(t):r.threadAdapters.get(t)??r.defaultAdapters;return tl(`${t}:${a}:${n}`,B_({threadId:t,generation:a,parentList:this.parent,runtimeHook:i,parentClient:e,adapters:o,publish:this._publish}))}))}__internal_RenderThreadRuntimes=({provider:e})=>(this.hostStore(),Array.from(this.instances.entries()).map(([t,{generation:n}])=>(0,M.jsx)(this._OuterActiveThreadProvider,{threadId:t,provider:e},`${t}:${n}`)));__internal_Host=({parentClient:e})=>(this.__internal_useHost(e),null);_OuterActiveThreadProvider=Kc(({threadId:e,provider:t})=>{let n=Ic(()=>new Hg(this.parent).getItemById(e),[e]),r=I(!1);return L(()=>{},[t]),(0,M.jsx)(zh,{runtime:n,children:(0,M.jsx)(t,{children:(0,M.jsx)(this._AdapterSink,{threadId:e,detectorRef:r})})})});_AdapterSink=({threadId:e,detectorRef:t})=>{let n=Qp();return this.pendingThreadAdapters.set(e,n),Rc(()=>(this.__internal_setThreadAdapters(e,n),()=>{this.pendingThreadAdapters.get(e)===n&&this.pendingThreadAdapters.delete(e),this.__internal_setThreadAdapters(e,null)}),[e,n]),(0,M.jsx)(V_,{detectorRef:t})}},U_=(e,t,n)=>n.reduce((e,n)=>n?.(e,t)??e,e),W_=class extends nu{_pendingTransforms=[];_completedOptimistics=[];_nextTransformOrder=0;_epoch=0;_baseValue;_cachedValue;constructor(e){super(),this._baseValue=e,this._cachedValue=e}_updateState(){let e=[...this._pendingTransforms.map(e=>({order:e.order,apply:t=>U_(t,e.task,[e.loading,e.optimistic])})),...this._completedOptimistics.map(({order:e,optimistic:t})=>({order:e,apply:t}))].sort((e,t)=>e.order-t.order);this._cachedValue=e.reduce((e,t)=>t.apply(e),this._baseValue),this._notifySubscribers()}get baseValue(){return this._baseValue}get value(){return this._cachedValue}update(e){this._baseValue=e,this._updateState()}reset(e){this._epoch++,this._pendingTransforms.length=0,this._completedOptimistics.length=0,this._baseValue=e,this._cachedValue=e,this._notifySubscribers()}async optimisticUpdate(e){let t=this._epoch,n=this._nextTransformOrder++,r=e.execute(),i={...e,order:n,task:r};try{this._pendingTransforms.push(i),this._updateState();let n=await r;if(t!==this._epoch)return n;this._baseValue=U_(this._baseValue,n,[e.optimistic,e.then]);for(let t of this._completedOptimistics)(e.then||t.order>i.order)&&(this._baseValue=t.optimistic(this._baseValue));return e.optimistic&&(this._completedOptimistics.push({order:i.order,optimistic:e.optimistic}),this._completedOptimistics.sort((e,t)=>e.order-t.order)),n}finally{let e=this._pendingTransforms.indexOf(i);e>-1&&this._pendingTransforms.splice(e,1),this._pendingTransforms.length===0&&(this._completedOptimistics.length=0),this._updateState()}}},G_=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."),K_=new class extends Ig{get error(){return G_}messages=[];composer=Fg(G_,!0);isLoading=!0;getMessageById(){}getBranches(){return[]}export(){return{messages:[]}}subscribe(){return()=>{}}waitForUpdate(){return Promise.reject(G_)}};function q_(e){return e}var J_=e=>e||void 0,Y_=(e,t)=>{for(let n of e){if(t.threadIdMap[n.remoteId]!==void 0)continue;switch(n.status){case`regular`:t.threadIds.push(n.remoteId);break;case`archived`:t.archivedThreadIds.push(n.remoteId);break;default:{let e=n.status;throw Error(`Unsupported state: ${e}`)}}let e=q_(n.remoteId);t.threadIdMap[n.remoteId]=e,t.threadData[e]={id:n.remoteId,remoteId:n.remoteId,externalId:n.externalId,status:n.status,title:n.title,lastMessageAt:n.lastMessageAt,custom:n.custom,initializeTask:Promise.resolve({remoteId:n.remoteId,externalId:n.externalId})}}return t},X_=(e,t)=>{let n=e.threadIdMap[t];if(n!==void 0)return e.threadData[n]},Z_=(e,t,n)=>{let r=X_(e,t);if(!r)return e;let{id:i,remoteId:a,status:o}=r;if(o===n)return e;let s={...e};switch(o){case`new`:s.newThreadId=void 0;break;case`regular`:s.threadIds=s.threadIds.filter(e=>e!==i);break;case`archived`:s.archivedThreadIds=s.archivedThreadIds.filter(e=>e!==i);break;default:throw Error(`Unsupported state: ${o}`)}switch(n){case`regular`:s.threadIds=[i,...s.threadIds];break;case`archived`:s.archivedThreadIds=[i,...s.archivedThreadIds];break;case`deleted`:s.threadData=Object.fromEntries(Object.entries(s.threadData).filter(([e])=>e!==i)),s.threadIdMap=Object.fromEntries(Object.entries(s.threadIdMap).filter(([e])=>e!==i&&e!==a));break;default:throw Error(`Unsupported state: ${n}`)}return n!==`deleted`&&(s.threadData={...s.threadData,[i]:{...r,status:n}}),s},Q_=class extends Error{[of]=!0;constructor(){super(`Thread list adapter changed while an operation was pending.`),this.name=`ThreadListAdapterChangedError`}},$_=(e,t)=>Error(`Thread "${e}" not found while ${t}.`),ev=(e,t,n)=>Error(`Thread "${e}" has status "${t}", so it cannot ${n}.`),tv={isLoading:!0,isLoadingMore:!1,cursor:void 0,newThreadId:void 0,threadIds:[],archivedThreadIds:[],threadIdMap:{},threadData:{}},nv=e=>{let t;do t=`__LOCALID_${tm()}`;while(e.threadIdMap[t]);let n=q_(t);return{id:t,state:{...e,newThreadId:t,threadIdMap:{...e.threadIdMap,[t]:n},threadData:{...e.threadData,[n]:{status:`new`,id:t,remoteId:void 0,externalId:void 0,title:void 0,custom:void 0}}}}},rv=class extends nu{_options;_hookManager;_runtimeAdapters;_loadThreadsPromise;_loadMorePromise;_loadGeneration=0;_adapterGeneration=0;_replaceListOnNextLoad=!1;_staleThreadIdsOnReplace;_switchGeneration=0;_switchTask;_mainThreadId;_state=new W_(tv);_useAdaptersProvider=({children:e})=>{let t=this._options.adapter.unstable_useAdapters;return t===void 0?e:(0,M.jsx)(this._SynthesizedAdapters,{useAdapters:t,children:e})};_SynthesizedAdapters=({useAdapters:e,children:t})=>{let n=em(e());return n==null?t:(0,M.jsx)(Lg,{adapters:n,children:t})};resolveProvider(e){return e.unstable_Provider===void 0?e.unstable_useAdapters===void 0?qc:this._useAdaptersProvider:e.unstable_Provider}get threadItems(){return this._state.value.threadData}getLoadThreadsPromise(){if(!this._loadThreadsPromise){let e=this._loadGeneration,t=!1;this._loadThreadsPromise=this._state.optimisticUpdate({execute:()=>this._options.adapter.list(),loading:e=>({...e,isLoading:!0}),then:(n,r)=>{if(e!==this._loadGeneration)return n;if(this._replaceListOnNextLoad)return this._replaceListOnNextLoad=!1,t=!0,this._replaceWithThreads(n,r.threads,J_(r.nextCursor));let i=Y_(r.threads,{threadIds:[],archivedThreadIds:[],threadIdMap:{},threadData:{}});return{...n,isLoading:!1,cursor:J_(r.nextCursor),threadIds:i.threadIds,archivedThreadIds:i.archivedThreadIds,threadIdMap:{...n.threadIdMap,...i.threadIdMap},threadData:{...n.threadData,...i.threadData}}}}).catch(n=>{if(e===this._loadGeneration){if(console.error(`[assistant-ui] thread list load failed:`,n),this._loadThreadsPromise=void 0,!this._replaceListOnNextLoad){this._state.update({...this._state.baseValue,isLoading:!1});return}this._replaceListOnNextLoad=!1,t=!0,this._state.update(this._replaceWithThreads(this._state.baseValue,[],void 0))}}).then(()=>{if(!t)return;let e=this._options.threadId;e!==void 0&&this.getItemById(e)?.id!==this._mainThreadId&&this._switchToThreadFromProp(e).catch(()=>{})})}return this._loadThreadsPromise}loadMore(){if(this._loadMorePromise)return this._loadMorePromise;let e=this._state.value;if(e.cursor===void 0||e.isLoading)return Promise.resolve();let t=this._loadGeneration,n=this._options.adapter,r=e.cursor,i=this._state.optimisticUpdate({execute:()=>n.list({after:r}),loading:e=>({...e,isLoadingMore:!0}),then:(e,r)=>{if(t!==this._loadGeneration||n!==this._options.adapter)return e;let i=Y_(r.threads,{threadIds:[...e.threadIds],archivedThreadIds:[...e.archivedThreadIds],threadIdMap:{...e.threadIdMap},threadData:{...e.threadData}});return{...e,isLoadingMore:!1,cursor:J_(r.nextCursor),threadIds:i.threadIds,archivedThreadIds:i.archivedThreadIds,threadIdMap:i.threadIdMap,threadData:i.threadData}}}).catch(e=>{t===this._loadGeneration&&console.error(`[assistant-ui] thread list loadMore failed:`,e)}).then(()=>{this._loadMorePromise===i&&(this._loadMorePromise=void 0)});return this._loadMorePromise=i,i}constructor(e,t){super(),this._state.subscribe(()=>{this._notifySubscribers(),this._notifyThreadIdChange()}),this._runtimeAdapters={modelContext:t},this._hookManager=new H_(e.runtimeHook,this),this._hookManager.__internal_setDefaultAdapters(this._runtimeAdapters),this._hookManager.__internal_subscribeRunningChanged(()=>this._notifySubscribers()),this._hookManager.__internal_subscribeRuntimeReplaced(()=>{queueMicrotask(()=>this._notifySubscribers())}),this.useProvider=Qf(()=>({Provider:this.resolveProvider(e.adapter)})),this.__internal_setOptions(e),this.switchToNewThread()}_initialThreadLoaded=!1;useProvider;__internal_setOptions(e){if(this._options===e)return;let t=this._options!==void 0&&this._options.adapter!==e.adapter,n=this._initialThreadLoaded&&this._options!==void 0&&this._options.threadId!==e.threadId;this._options=e;let r=this.resolveProvider(e.adapter);r!==this.useProvider.getState().Provider&&this.useProvider.setState({Provider:r},!0),this._hookManager.setRuntimeHook(e.runtimeHook),t&&(this._loadGeneration++,this._adapterGeneration++,this._switchGeneration++,this._switchTask=void 0,this._loadThreadsPromise=void 0,this._loadMorePromise=void 0,this._replaceListOnNextLoad=!0,this._staleThreadIdsOnReplace=new Set(Object.values(this._state.baseValue.threadData).filter(e=>e.status!==`new`).map(e=>e.id)),this._state.update({...this._state.baseValue,cursor:void 0})),n&&this._switchToThreadFromProp(e.threadId).catch(()=>{})}_requireAdapterGeneration(e){if(e!==this._adapterGeneration)throw new Q_}_requireAdapterSettled(){if(this._replaceListOnNextLoad)throw new Q_}_replaceWithThreads(e,t,n){let r=Y_(t,{threadIds:[],archivedThreadIds:[],threadIdMap:{},threadData:{}}),i={...r.threadIdMap},a={...r.threadData},o=[...r.threadIds],s=[...r.archivedThreadIds];if(e.newThreadId){let t=e.threadIdMap[e.newThreadId],n=t?e.threadData[t]:void 0;n?.status===`new`&&(i[e.newThreadId]=t,a[t]=n)}let c=this._staleThreadIdsOnReplace;if(c)for(let t of Object.values(e.threadData)){if(c.has(t.id)||t.status!==`new`&&t.remoteId===void 0)continue;let e=q_(t.id);a[e]||(i[t.id]=e,t.remoteId!==void 0&&(i[t.remoteId]=e),a[e]=t,t.remoteId!==void 0&&(t.status===`regular`&&!o.includes(t.remoteId)?o.push(t.remoteId):t.status===`archived`&&!s.includes(t.remoteId)&&s.push(t.remoteId)))}this._staleThreadIdsOnReplace=void 0;let l={...e,isLoading:!1,cursor:n,threadIds:o,archivedThreadIds:s,threadIdMap:i,threadData:a,newThreadId:e.newThreadId!==void 0&&i[e.newThreadId]===void 0?void 0:e.newThreadId};if(X_(l,this._mainThreadId)===void 0){let e=l.newThreadId;if(e!==void 0)this._mainThreadId=e;else{let e=nv(l);this._mainThreadId=e.id,l=e.state}this._options.threadId===void 0?this._notifyThreadIdChange():this._lastNotifiedThreadId=void 0}let u=new Set(Object.values(l.threadData).map(e=>e.id));for(let t of Object.values(e.threadData))u.has(t.id)||this._hookManager.stopThreadRuntime(t.id);return this._hookManager.startThreadRuntime(this._mainThreadId).then(()=>this._notifySubscribers(),()=>void 0),l}__internal_load(){if(this.getLoadThreadsPromise(),this._initialThreadLoaded)return;this._initialThreadLoaded=!0;let e=this._options.threadId??this._options.initialThreadId;e!==void 0&&(this._options.threadId===void 0?this.switchToThread(e):this._switchToThreadFromProp(e)).catch(()=>{})}async reloadMainThread(){let e=this._mainThreadId;if(e===void 0||this.getItemById(e)?.status===`new`)return;let t=this._hookManager.getThreadRuntimeCore(e);try{t?.unstable_refetchThread?await t.unstable_refetchThread():await this._hookManager.__internal_restartThreadRuntime(e)}catch(t){if(e!==this._mainThreadId)return;throw t}e===this._mainThreadId&&this._notifySubscribers()}reload(){return this._loadGeneration++,this._loadThreadsPromise=void 0,this._loadMorePromise=void 0,this._state.update({...this._state.baseValue,cursor:void 0}),this.getLoadThreadsPromise()}get isLoading(){return this._state.value.isLoading}get isLoadingMore(){return this._state.value.isLoadingMore}get hasMore(){return this._state.value.cursor!==void 0}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}get _mainThreadRemoteId(){if(this._mainThreadId!==void 0)return X_(this._state.value,this._mainThreadId)?.remoteId}_lastNotifiedThreadId=void 0;_notifyThreadIdChange(e=!0){let t=this._mainThreadRemoteId;this._lastNotifiedThreadId!==t&&(this._lastNotifiedThreadId=t,e&&this._options.onThreadIdChange?.(t))}getMainThreadRuntimeCore(){return this._hookManager.getThreadRuntimeCore(this._mainThreadId)||K_}getThreadRuntimeCore(e){let t=this.getItemById(e);if(!t)throw $_(e,`getting its runtime`);let n=this._hookManager.getThreadRuntimeCore(t.id);if(!n)throw Error(`Runtime for thread "${e}" not found while getting its runtime.`);return n}unstable_isThreadRunning(e){let t=this.getItemById(e);return t?this._hookManager.__internal_isThreadRunning(t.id):!1}getItemById(e){return X_(this._state.value,e)}switchToThread(e,t){return this._startSwitchToThread(e,t,!0)}_startSwitchToThread(e,t,n){let r=++this._switchGeneration,i=this._switchToThread(e,t,r,n);return this._switchTask=i,i}async _switchToThread(e,t,n,r){if(this._replaceListOnNextLoad&&e!==this._state.value.newThreadId)throw new Q_;let i=this.getItemById(e);if(!i){let t=await this._options.adapter.fetch(e);if(n!==this._switchGeneration)return;let r=this._state.value,a=q_(t.remoteId),o={...r.threadData,[a]:{id:a,initializeTask:Promise.resolve({remoteId:t.remoteId,externalId:t.externalId}),remoteId:t.remoteId,externalId:t.externalId,status:t.status,title:t.title,lastMessageAt:t.lastMessageAt,custom:t.custom}},s={...r.threadIdMap,[t.remoteId]:a},c=t.remoteId,l=t.status===`regular`?r.threadIds.includes(c):r.archivedThreadIds.includes(c),u=r.threadIds.filter(e=>e!==c),d=r.archivedThreadIds.filter(e=>e!==c),f=t.status===`regular`?l?r.threadIds:[...u,c]:u,p=t.status===`archived`?l?r.archivedThreadIds:[...d,c]:d;this._state.update({...r,threadIds:f,archivedThreadIds:p,threadIdMap:s,threadData:o}),i=this.getItemById(e)}if(!i)throw $_(e,`switching to it`);if(this._mainThreadId===i.id)return;let a=this._hookManager.startThreadRuntime(i.id);this.mainThreadId===void 0?a.then(()=>this._notifySubscribers(),()=>void 0):await a,n===this._switchGeneration&&(i.status===`archived`&&t?.unarchive!==!1&&(await this.unarchive(i.id),n!==this._switchGeneration)||(this._mainThreadId=i.id,this._notifySubscribers(),this._notifyThreadIdChange(r)))}switchToNewThread(){return this._startSwitchToNewThread(!0)}_switchToThreadFromProp(e){return e===void 0?this._startSwitchToNewThread(!1):this._startSwitchToThread(e,void 0,!1)}_startSwitchToNewThread(e){let t=++this._switchGeneration,n=this._switchToNewThread(t,e);return this._switchTask=n,n}async _switchToNewThread(e,t){for(;this._state.baseValue.newThreadId!==void 0&&this._state.value.newThreadId===void 0;)if(await this._state.waitForUpdate(),e!==this._switchGeneration)return;let n=this._state.baseValue,r=this._state.value.newThreadId;if(r===void 0){let e=nv(n);r=e.id,this._state.update(e.state)}return this._switchToThread(r,void 0,e,t)}initialize=async e=>{let t=this._options.adapter,n=this._adapterGeneration;if(this._state.value.newThreadId!==e){this._requireAdapterSettled();let t=this.getItemById(e);if(!t)throw $_(e,`initializing it`);if(t.status===`new`)throw ev(e,t.status,`be initialized here`);let{remoteId:r,externalId:i}=await t.initializeTask;return this._requireAdapterGeneration(n),{remoteId:r,externalId:i}}let{remoteId:r,externalId:i}=await this._state.optimisticUpdate({execute:()=>(this._requireAdapterGeneration(n),t.initialize(e)),optimistic:t=>Z_(t,e,`regular`),loading:(t,n)=>{let r=q_(e);return{...t,threadData:{...t.threadData,[r]:{...t.threadData[r],initializeTask:n}}}},then:(t,{remoteId:r,externalId:i})=>{if(n!==this._adapterGeneration)return t;let a=X_(t,e);if(!a)return t;let o=q_(e);return{...t,threadIdMap:{...t.threadIdMap,[r]:o},threadData:{...t.threadData,[o]:{...a,initializeTask:Promise.resolve({remoteId:r,externalId:i}),remoteId:r,externalId:i}}}}});return this._requireAdapterGeneration(n),{remoteId:r,externalId:i}};generateTitle=async e=>{this._requireAdapterSettled();let t=this._options.adapter,n=this._adapterGeneration,r=this.getItemById(e);if(!r)throw $_(e,`generating its title`);if(r.status===`new`)throw ev(e,r.status,`generate a title`);let{remoteId:i}=await r.initializeTask;this._requireAdapterGeneration(n);let a=this._hookManager.getThreadRuntimeCore(r.id);if(!a)return;let o=a.messages.filter(L_),s=await t.generateTitle(i,o),c=lh.fromAssistantStream(s);for await(let e of c){if(n!==this._adapterGeneration)return;let t=e.parts.filter(e=>e.type===`text`)[0]?.text,i=this._state.baseValue,a=X_(i,r.id);a&&this._state.update({...i,threadData:{...i.threadData,[a.id]:{...a,title:t}}})}};async rename(e,t){this._requireAdapterSettled();let n=this._options.adapter,r=this._adapterGeneration,i=this.getItemById(e);if(!i)throw $_(e,`renaming it`);if(i.status===`new`)throw ev(e,i.status,`be renamed`);return this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await i.initializeTask;return this._requireAdapterGeneration(r),n.rename(e,t)},optimistic:n=>{let r=X_(n,e);return r?{...n,threadData:{...n.threadData,[r.id]:{...r,title:t}}}:n}})}async updateCustom(e,t){this._requireAdapterSettled();let n=this._options.adapter,r=this._adapterGeneration,i=this.getItemById(e);if(!i)throw $_(e,`updating its custom metadata`);if(i.status===`new`)throw ev(e,i.status,`update custom metadata`);if(!n.updateCustom)throw Error(`Remote thread list adapter does not support updating custom metadata`);return this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await i.initializeTask;if(this._requireAdapterGeneration(r),!n.updateCustom)throw Error(`Remote thread list adapter does not support updating custom metadata`);return n.updateCustom(e,t)},optimistic:n=>{let r=X_(n,e);return r?{...n,threadData:{...n.threadData,[r.id]:{...r,custom:t}}}:n}})}async _ensureThreadIsNotMain(e){if(e===this.newThreadId)throw Error(`Cannot ensure new thread is not main`);let t;for(;e===this._mainThreadId;){let e=this._switchTask,n=!e||e===t;n&&(e=this.switchToNewThread()),t=e;try{await e}catch(t){if(n&&this._switchTask===e)throw t}}}async archive(e){this._requireAdapterSettled();let t=this._options.adapter,n=this._adapterGeneration,r=this.getItemById(e);if(!r)throw $_(e,`archiving it`);if(r.status!==`regular`)throw ev(e,r.status,`be archived`);return await this._ensureThreadIsNotMain(r.id),this._requireAdapterGeneration(n),this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await r.initializeTask;return this._requireAdapterGeneration(n),t.archive(e)},optimistic:e=>Z_(e,r.id,`archived`)})}async unarchive(e){this._requireAdapterSettled();let t=this._options.adapter,n=this._adapterGeneration,r=this.getItemById(e);if(!r)throw $_(e,`unarchiving it`);if(r.status!==`archived`)throw ev(e,r.status,`be unarchived`);return this._state.optimisticUpdate({execute:async()=>{try{let{remoteId:e}=await r.initializeTask;return this._requireAdapterGeneration(n),await t.unarchive(e)}catch(e){throw n===this._adapterGeneration&&await this._ensureThreadIsNotMain(r.id),e}},optimistic:e=>Z_(e,r.id,`regular`)})}async delete(e){this._requireAdapterSettled();let t=this._options.adapter,n=this._adapterGeneration,r=this.getItemById(e);if(!r)throw $_(e,`deleting it`);if(r.status!==`regular`&&r.status!==`archived`)throw ev(e,r.status,`be deleted`);return await this._ensureThreadIsNotMain(r.id),this._requireAdapterGeneration(n),this._hookManager.stopThreadRuntime(r.id),this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await r.initializeTask;return this._requireAdapterGeneration(n),await t.delete(e)},optimistic:e=>Z_(e,r.id,`deleted`)})}__internal_dispose(){this._hookManager.__internal_dispose()}async detach(e){let t=this._adapterGeneration,n=this.getItemById(e);if(!n)throw $_(e,`detaching it`);if(n.status!==`regular`&&n.status!==`archived`)throw ev(e,n.status,`be detached`);await this._ensureThreadIsNotMain(n.id),this._requireAdapterGeneration(t),this._hookManager.stopThreadRuntime(n.id)}useBoundIds=Qf(()=>[]);__internal_RenderComponent=()=>{let e=Uc();L(()=>(this.useBoundIds.setState(t=>[...t,e],!0),()=>{this.useBoundIds.setState(t=>t.filter(t=>t!==e),!0)}),[e]);let t=this.useBoundIds(),{Provider:n}=this.useProvider(),r=zd();return(t.length===0||t[0]===e)&&(0,M.jsxs)(Lg,{adapters:this._runtimeAdapters,children:[(0,M.jsx)(this._hookManager.__internal_RenderThreadRuntimes,{provider:n}),(0,M.jsx)(this._hookManager.__internal_Host,{parentClient:r})]})}},iv=class extends Jg{threads;constructor(e){super(),this.threads=new rv(e,this._contextProvider)}get RenderComponent(){return this.threads.__internal_RenderComponent}},av=e=>{let t=F(10),n;t[0]===e?n=t[1]:(n=()=>new iv(e),t[0]=e,t[1]=n);let[r]=Pc(n),i;t[2]!==e||t[3]!==r.threads?(i=()=>{r.threads.__internal_setOptions(e),r.threads.__internal_load()},t[2]=e,t[3]=r.threads,t[4]=i):i=t[4];let a;t[5]!==e||t[6]!==r?(a=[r,e],t[5]=e,t[6]=r,t[7]=a):a=t[7],L(i,a);let o;return t[8]===r?o=t[9]:(o=new Ug(r),t[8]=r,t[9]=o),o},ov=e=>{let t=I(e.runtimeHook);t.current=e.runtimeHook;let n=I(e.initialThreadId),r=Lc(()=>t.current(),[]),i=zc(t=>{e.onThreadIdChange?.(t)}),a=Ic(()=>({adapter:e.adapter,allowNesting:e.allowNesting,threadId:e.threadId,initialThreadId:n.current,runtimeHook:r,onThreadIdChange:i}),[e.adapter,e.allowNesting,e.threadId,r]);if(zd().threadListItem.source!==null){if(!a.allowNesting)throw Error(`useRemoteThreadListRuntime cannot be nested inside another RemoteThreadListRuntime. Set allowNesting: true to allow nesting (the inner runtime will become a no-op).`);return r()}return av(a)},sv=e=>{let t=e.type;switch(t){case`text`:return{type:`text`,text:e.text};case`image`:return{type:`image`,image:e.image,...e.filename==null?void 0:{filename:e.filename}};case`file`:return{type:`file`,data:e.data,mimeType:e.mimeType,...e.filename==null?void 0:{filename:e.filename},...e.sourceType==null?void 0:{sourceType:e.sourceType}};case`audio`:return{type:`audio`,audio:{data:e.audio.data,format:e.audio.format}};case`data`:return tp(e.data)||console.warn(`attachment data is not JSON! ${JSON.stringify(e)}`),{type:`data`,name:e.name,data:e.data};default:throw Error(`Attachment part type not supported by aui/v0: ${t}`)}},cv=e=>{if(e.role===`user`&&e.attachments.length!==0)return e.attachments.map(({id:e,type:t,name:n,contentType:r,status:i,content:a})=>({id:e,type:t,name:n,status:i,...r==null?void 0:{contentType:r},content:a.map(sv)}))};function lv(e){let t=e.status?.type===`running`?{type:`incomplete`,reason:`cancelled`}:e.status,n=cv(e);return{role:e.role,content:e.content.map(e=>{let t=e.type;switch(t){case`text`:return{type:`text`,text:e.text};case`reasoning`:return{type:`reasoning`,text:e.text,...e.unstable_summary===void 0?void 0:{unstable_summary:e.unstable_summary}};case`source`:return e.sourceType===`url`?{type:`source`,sourceType:`url`,id:e.id,url:e.url,...e.title==null?void 0:{title:e.title},...e.providerMetadata==null?void 0:{providerMetadata:e.providerMetadata}}:{type:`source`,sourceType:`document`,id:e.id,title:e.title,mediaType:e.mediaType,...e.filename==null?void 0:{filename:e.filename},...e.providerMetadata==null?void 0:{providerMetadata:e.providerMetadata}};case`tool-call`:return e.result!==void 0&&!tp(e.result)&&console.warn(`tool-call result is not JSON! ${JSON.stringify(e)}`),{type:`tool-call`,toolCallId:e.toolCallId,toolName:e.toolName,...JSON.stringify(e.args)===e.argsText?{args:e.args}:{argsText:e.argsText},...e.result===void 0?void 0:{result:e.result},...e.isError?{isError:!0}:void 0,...e.approval?{approval:e.approval}:void 0};case`image`:return{type:`image`,image:e.image};case`file`:return{type:`file`,data:e.data,mimeType:e.mimeType,...e.filename?{filename:e.filename}:void 0,...e.sourceType?{sourceType:e.sourceType}:void 0};case`data`:return tp(e.data)||console.warn(`data part is not JSON! ${JSON.stringify(e)}`),{type:`data`,name:e.name,data:e.data};default:throw Error(`Message part type not supported by aui/v0: ${t}`)}}),metadata:e.metadata,...t?{status:t}:void 0,...n?{attachments:n}:void 0}}function uv(e){let t=e.content,n=lm({id:e.id,createdAt:e.created_at,...t},e.id,{type:`complete`,reason:`unknown`});return{parentId:e.parent_id,message:n}}var dv=class extends Error{constructor(e){super(e),this.name=`CloudResponseError`}},fv=(e,t)=>new dv(`Invalid Assistant Cloud response for "${e}": expected ${t}`),pv=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw fv(t,`an object`);return e},mv=(e,t)=>{if(!Array.isArray(e))throw fv(t,`an array`);return e},hv=(e,t)=>{if(typeof e!=`string`)throw fv(t,`a string`);return e},gv=(e,t)=>e===null?null:hv(e,t),_v=(e,t)=>{if(typeof e!=`boolean`)throw fv(t,`a boolean`);return e},vv=(e,t)=>{if(!Number.isInteger(e))throw fv(t,`an integer`);return e},yv=(e,t)=>{if(typeof e!=`string`)throw fv(t,`a canonical ISO timestamp`);let n=new Date(e);if(Number.isNaN(n.getTime())||n.toISOString()!==e)throw fv(t,`a canonical ISO timestamp`);return n},bv=(e,t)=>pv(e,t),xv=e=>{try{let t=e.split(`.`)[1];if(!t)throw Error(`Invalid JWT format`);let n=t.replace(/-/g,`+`).replace(/_/g,`/`);for(;n.length%4!=0;)n+=`=`;let r=atob(n),i=JSON.parse(r).exp;if(!i||typeof i!=`number`)throw Error(`JWT does not contain a valid "exp" field`);return i*1e3}catch(e){throw Error(`Unable to determine the token expiry: ${e}`)}},Sv=(e,t)=>{let n=hv(e,t);if(n.length===0)throw new dv(`Invalid Assistant Cloud response for "${t}": expected a non-empty string`);return n},Cv=(e,t)=>{let n=pv(e,t);return{token:Sv(n.token,`${t}.token`),expires_at:Sv(n.expires_at,`${t}.expires_at`)}},wv=async(e,t)=>{let n;try{n=await e.json()}catch{throw new dv(`Invalid Assistant Cloud response for "${t}": expected valid JSON`)}let r=pv(n,t);return{data:r,accessToken:Sv(r.access_token,`${t}.access_token`)}},Tv=class{strategy=`jwt`;cachedToken=null;tokenExpiry=null;tokenRequest=null;#e;constructor(e){this.#e=e}async getAuthHeaders(){let e=Date.now();if(this.cachedToken&&this.tokenExpiry&&this.tokenExpiry-e>3e4)return{Authorization:`Bearer ${this.cachedToken}`};this.tokenRequest||=this.fetchAuthHeaders();let t=this.tokenRequest;try{return await t}finally{this.tokenRequest===t&&(this.tokenRequest=null)}}async fetchAuthHeaders(){let e=await this.#e();return e?(this.cachedToken=e,this.tokenExpiry=xv(e),{Authorization:`Bearer ${e}`}):!1}readAuthHeaders(e){let t=e.get(`Authorization`);if(!t)return;let[n,r]=t.split(` `);if(n!==`Bearer`||!r)throw Error(`Invalid auth header received`);this.cachedToken=r,this.tokenExpiry=xv(r)}},Ev=class{strategy=`api-key`;#e;#t;#n;constructor(e,t,n){this.#e=e,this.#t=t,this.#n=n}async getAuthHeaders(){return{Authorization:`Bearer ${this.#e}`,"Aui-User-Id":this.#t,"Aui-Workspace-Id":this.#n}}readAuthHeaders(){}},Dv=`aui:refresh_token`,Ov=e=>`${Dv}:${e}`,kv=e=>{try{e.removeItem(Dv)}catch{}},Av=()=>{if(!(`localStorage`in globalThis))return null;try{return globalThis.localStorage}catch{return null}},jv=e=>{let t=Av();if(t)try{let n=Ov(e),r=t.getItem(n);if(r)return kv(t),JSON.parse(r);let i=t.getItem(Dv);if(!i)return;let a;try{a=JSON.parse(i)}catch{kv(t);return}return t.setItem(n,i),kv(t),a}catch{return}},Mv=(e,t)=>{let n=Av();if(n)try{n.setItem(Ov(e),JSON.stringify(t))}catch{}},Nv=e=>{let t=Av();if(t)try{t.removeItem(Ov(e))}catch{}},Pv=class{strategy=`anon`;baseUrl;jwtStrategy;constructor(e){this.baseUrl=e,this.jwtStrategy=new Tv(async()=>{let e=Date.now(),t=jv(this.baseUrl);if(t){if(new Date(t.expires_at).getTime()-e>3e4){let e=await fetch(`${this.baseUrl}/v1/auth/tokens/refresh`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({refresh_token:t.token})});if(e.ok){let{data:t,accessToken:n}=await wv(e,`refresh auth token response`);return t.refresh_token!=null&&Mv(this.baseUrl,Cv(t.refresh_token,`refresh auth token response.refresh_token`)),n}if(e.status===429||e.status>=500)throw Error(`Assistant Cloud token refresh failed with status ${e.status}`)}else Nv(this.baseUrl)}let n=await fetch(`${this.baseUrl}/v1/auth/tokens/anonymous`,{method:`POST`});if(!n.ok)return null;let{data:r,accessToken:i}=await wv(n,`anonymous auth token response`);return Mv(this.baseUrl,Cv(r.refresh_token,`anonymous auth token response.refresh_token`)),i})}async getAuthHeaders(){return this.jwtStrategy.getAuthHeaders()}readAuthHeaders(e){this.jwtStrategy.readAuthHeaders(e)}},Fv=class extends Error{status;constructor(e,t){super(e),this.status=t,this.name=`CloudAPIError`}},Iv=e=>!e||!e.endsWith(`/`)?e:e.slice(0,-1),Lv=class{_auth;_baseUrl;constructor(e){if(`authToken`in e)this._baseUrl=Iv(e.baseUrl),this._auth=new Tv(e.authToken);else if(`apiKey`in e)this._baseUrl=Iv(e.baseUrl??`https://backend.assistant-api.com`),this._auth=new Ev(e.apiKey,e.userId,e.workspaceId);else if(`anonymous`in e)this._baseUrl=Iv(e.baseUrl),this._auth=new Pv(this._baseUrl);else throw Error(`Invalid configuration: Must provide authToken, apiKey, or anonymous configuration`)}async initializeAuth(){return!!await this._auth.getAuthHeaders()}async makeRawRequest(e,t={}){let n=await this._auth.getAuthHeaders();if(!n)throw Error(`Authorization failed`);let r={...n,...t.headers,"Content-Type":`application/json`},i=new URLSearchParams;if(t.query)for(let[e,n]of Object.entries(t.query))n!==!1&&(n===!0?i.set(e,`true`):i.set(e,n.toString()));let a=new URL(`${this._baseUrl}/v1${e}`);a.search=i.toString();let o=await fetch(a,{method:t.method??`GET`,headers:r,body:t.body?JSON.stringify(t.body):null});if(this._auth.readAuthHeaders(o.headers),!o.ok){let e=await o.text();try{throw new Fv(JSON.parse(e).message,o.status)}catch(t){throw t instanceof Fv?t:new Fv(`Request failed with status ${o.status}, ${e}`,o.status)}}return o}async makeRequest(e,t={}){let n=await this.makeRawRequest(e,t);if(n.status===204||n.headers.get(`content-length`)===`0`)return;let r=await n.text();if(r.trim()!==``)return JSON.parse(r)}},Rv=class{cloud;constructor(e){this.cloud=e}async create(){return{token:hv(pv(await this.cloud.makeRequest(`/auth/tokens`,{method:`POST`}),`auth token response`).token,`token`)}}},zv=(e,t)=>{let n=pv(e,t);return{id:hv(n.id,`${t}.id`),parent_id:gv(n.parent_id,`${t}.parent_id`),height:vv(n.height,`${t}.height`),created_at:yv(n.created_at,`${t}.created_at`),updated_at:yv(n.updated_at,`${t}.updated_at`),format:hv(n.format,`${t}.format`),content:bv(n.content,`${t}.content`)}},Bv=class{cloud;constructor(e){this.cloud=e}async list(e,t){return{messages:mv(pv(await this.cloud.makeRequest(`/threads/${encodeURIComponent(e)}/messages`,{query:t}),`thread message list response`).messages,`messages`).map((e,t)=>zv(e,`messages[${t}]`))}}async create(e,t){return{message_id:hv(pv(await this.cloud.makeRequest(`/threads/${encodeURIComponent(e)}/messages`,{method:`POST`,body:t}),`thread message create response`).message_id,`message_id`)}}async update(e,t,n){return this.cloud.makeRequest(`/threads/${encodeURIComponent(e)}/messages/${encodeURIComponent(t)}`,{method:`PUT`,body:n})}},Vv=(e,t)=>{let n=pv(e,t);return{title:gv(n.title,`${t}.title`)??``,last_message_at:yv(n.last_message_at,`${t}.last_message_at`),metadata:n.metadata,external_id:gv(n.external_id,`${t}.external_id`),id:hv(n.id,`${t}.id`),project_id:hv(n.project_id,`${t}.project_id`),created_at:yv(n.created_at,`${t}.created_at`),updated_at:yv(n.updated_at,`${t}.updated_at`),workspace_id:hv(n.workspace_id,`${t}.workspace_id`),is_archived:_v(n.is_archived,`${t}.is_archived`)}},Hv=class{messages;cloud;constructor(e){this.cloud=e,this.messages=new Bv(e)}async list(e){let t=e?.is_archived===void 0?e:{...e,is_archived:String(e.is_archived)};return{threads:mv(pv(await this.cloud.makeRequest(`/threads`,{query:t}),`thread list response`).threads,`threads`).map((e,t)=>Vv(e,`threads[${t}]`))}}async get(e){return Vv(pv(await this.cloud.makeRequest(`/threads/${encodeURIComponent(e)}`),`thread response`).thread,`thread`)}async create(e){return{thread_id:hv(pv(await this.cloud.makeRequest(`/threads`,{method:`POST`,body:e}),`thread create response`).thread_id,`thread_id`)}}async update(e,t){return this.cloud.makeRequest(`/threads/${encodeURIComponent(e)}`,{method:`PUT`,body:t})}async delete(e){return this.cloud.makeRequest(`/threads/${encodeURIComponent(e)}`,{method:`DELETE`})}},Uv=class{cloud;constructor(e){this.cloud=e}async list(e,t){return{messages:mv(pv(await this.cloud.makeRequest(`/projects/threads/${encodeURIComponent(e)}/messages`,{query:t}),`project thread message list response`).messages,`messages`).map((e,t)=>zv(e,`messages[${t}]`))}}},Wv=class{messages;cloud;constructor(e){this.cloud=e,this.messages=new Uv(e)}async list(e){return{threads:mv(pv(await this.cloud.makeRequest(`/projects/threads`,{query:{...e,...e?.is_archived===void 0?{}:{is_archived:String(e.is_archived)}}}),`project thread list response`).threads,`threads`).map((e,t)=>Vv(e,`threads[${t}]`))}}},Gv=class{threads;constructor(e){this.threads=new Wv(e)}},Kv=class{cloud;constructor(e){this.cloud=e}__internal_getAssistantOptions(e){return{api:`${this.cloud._baseUrl}/v1/runs/stream`,headers:async()=>{let e=await this.cloud._auth.getAuthHeaders();if(!e)throw Error(`Authorization failed`);return{...e,Accept:`text/plain`}},body:{assistant_id:e,response_format:`vercel-ai-data-stream/v1`,thread_id:`unstable_todo`}}}async stream(e){let t=await this.cloud.makeRawRequest(`/runs/stream`,{method:`POST`,headers:{Accept:`text/plain`},body:e});if(!t.body)throw new dv(`Invalid Assistant Cloud response for "run stream": expected a response body`);let n=t.headers.get(`content-type`);if(n?.split(`;`,1)[0]?.trim().toLowerCase()!==`text/plain`)throw await t.body.cancel().catch(()=>void 0),new dv(`Invalid Assistant Cloud response for "run stream": expected a "text/plain" content type, received ${n?`"${n}"`:`no Content-Type header`}`);return vp.fromResponse(t,new ch)}async report(e){return{run_id:hv(pv(await this.cloud.makeRequest(`/runs`,{method:`POST`,body:e}),`run report response`).run_id,`run_id`)}}},qv=class{cloud;constructor(e){this.cloud=e}async pdfToImages(e){let t=pv(await this.cloud.makeRequest(`/files/pdf-to-images`,{method:`POST`,body:e}),`PDF conversion response`);return{success:_v(t.success,`PDF conversion response.success`),urls:mv(t.urls,`PDF conversion response.urls`).map((e,t)=>hv(e,`PDF conversion response.urls[${t}]`)),message:hv(t.message,`PDF conversion response.message`)}}async generatePresignedUploadUrl(e){let t=pv(await this.cloud.makeRequest(`/files/attachments/generate-presigned-upload-url`,{method:`POST`,body:e}),`presigned upload response`);return{success:_v(t.success,`presigned upload response.success`),signedUrl:hv(t.signedUrl,`presigned upload response.signedUrl`),expiresAt:hv(t.expiresAt,`presigned upload response.expiresAt`),publicUrl:hv(t.publicUrl,`presigned upload response.publicUrl`)}}},Jv=class{threads;projects;auth;runs;files;telemetry;constructor(e){let t=new Lv(e);this.threads=new Hv(t),this.projects=new Gv(t),this.auth={tokens:new Rv(t)},this.runs=new Kv(t),this.files=new qv(t);let n=e.telemetry;this.telemetry=n===!1?{enabled:!1}:n===!0||n===void 0?{enabled:!0}:{enabled:n.enabled!==!1,...n}}},Yv=class{idMapping={};getCloud;constructor(e){this.getCloud=typeof e==`function`?e:()=>e}async append(e,t,n,r,i){let a=this.getCloud(),o=n?await this.idMapping[n]??n:null,s=a.threads.messages.create(e,{parent_id:o,format:r,content:i}).then(({message_id:e})=>(this.idMapping[t]=e,e)).catch(e=>{throw this.idMapping[t]===s&&delete this.idMapping[t],e});return this.idMapping[t]=s,s.then(()=>{})}async update(e,t,n,r){let i=this.getCloud(),a=await this.getRemoteId(t);if(!a){console.warn(`Skipping update for message ${t}: no remote id is mapped.`);return}await i.threads.messages.update(e,a,{content:r})}isPersisted(e){return e in this.idMapping}async getRemoteId(e){let t=this.idMapping[e];if(t)return t}async load(e,t){let{messages:n}=await this.getCloud().threads.messages.list(e,t?{format:t}:void 0);for(let e of n)this.idMapping[e.id]=e.id;return n}reset(){this.idMapping={}}},Xv=(e,t)=>({append:async(n,r)=>{let i=t.getId(r.message),a=t.encode(r);return e.append(n,i,r.parentId,t.format,a)},update:e.update?async(n,r,i)=>{let a=t.encode(r);return e.update(n,i,t.format,a)}:void 0,load:async n=>({messages:(await e.load(n,t.format)).filter(e=>e.format===t.format).map(e=>t.decode({id:e.id,parent_id:e.parent_id,format:e.format,content:e.content})).reverse()}),isPersisted:t=>e.isPersisted(t)}),Zv=new WeakMap,Qv=class{cloudRef;getAui;constructor(e,t){this.cloudRef=e,this.getAui=t}get aui(){return this.getAui()}getPersistence(e=this.aui.threadListItem){let t=Du(e);return Zv.has(t)||Zv.set(t,new Yv(()=>this.cloudRef.current)),Zv.get(t)}get _persistence(){return this.getPersistence()}tryGetKeyedThreadListItem(){let e=this.aui.threadListItem;if(!e.source)return;let t=e.getState().id;if(t!==void 0)return this.aui.threads.item({id:t})}withFormat(e){let t=this,n,r=()=>{let e=t.tryGetKeyedThreadListItem();return e&&(n=e),n},i=()=>n??r(),a=()=>Xv(t._persistence,e),o=n=>Xv(t.getPersistence(n),e);return{pin(){r()},async append(e){let t=i();if(!t)throw Error(`Cannot persist cloud history without a thread list item.`);let n=t.getState().remoteId??(await t.initialize()).remoteId;await o(t).append(n,e)},async update(e,t){let n=i(),r=n?.getState().remoteId;!r||!n||await o(n).update?.(r,e,t)},async delete(){throw Error(`Assistant Cloud does not support deleting thread messages yet.`)},reportTelemetry(n,r){let a=n.map(t=>e.encode(t));t._reportRunTelemetry(e.format,a,r,i())},async load(){r();let e=t.aui.threadListItem,n=e.source?e.getState().remoteId:void 0;return n?a().load(n):{messages:[]}}}}async append({parentId:e,message:t}){let{remoteId:n}=await this.aui.threadListItem.initialize(),r=lv(t);await this._persistence.append(n,t.id,e,`aui/v0`,r),this.cloudRef.current.telemetry.enabled&&this._maybeReportRun(n,`aui/v0`,r)}async update(e){if(!this._persistence.isPersisted(e.message.id))return this.append(e);let{message:t}=e,n=this.aui.threadListItem.getState().remoteId;if(!n)return;let r=lv(t);await this._persistence.update(n,t.id,`aui/v0`,r),this.cloudRef.current.telemetry.enabled&&this._maybeReportRun(n,`aui/v0`,r)}async delete(){throw Error(`Assistant Cloud does not support deleting thread messages yet.`)}async load(){let e=this.aui.threadListItem.getState().remoteId;return e?{messages:(await this._persistence.load(e,`aui/v0`)).filter(e=>e.format===`aui/v0`).map(uv).reverse()}:{messages:[]}}_reportRunTelemetry(e,t,n,r){if(!this.cloudRef.current.telemetry.enabled)return;let i=(r??this.aui.threadListItem).getState().remoteId;if(!i)return;let a=sy(e,t);a&&this._sendReport(i,a,n?.durationMs,n?.stepTimestamps)}_maybeReportRun(e,t,n){let r=oy(t,n);r&&this._sendReport(e,r)}_sendReport(e,t,n,r){let i=ay(t.steps,r),a={thread_id:e,status:t.status,...t.totalSteps==null?void 0:{total_steps:t.totalSteps},...t.toolCalls?{tool_calls:t.toolCalls}:void 0,...i?{steps:i}:void 0,...t.inputTokens==null?void 0:{input_tokens:t.inputTokens},...t.outputTokens==null?void 0:{output_tokens:t.outputTokens},...t.reasoningTokens==null?void 0:{reasoning_tokens:t.reasoningTokens},...t.cachedInputTokens==null?void 0:{cached_input_tokens:t.cachedInputTokens},...n==null?void 0:{duration_ms:n},...t.outputText==null?void 0:{output_text:t.outputText},...t.metadata?{metadata:t.metadata}:void 0,...t.modelId?{model_id:t.modelId}:void 0},{beforeReport:o}=this.cloudRef.current.telemetry,s=o?o(a):a;s&&this.cloudRef.current.runs.report(s).catch(()=>{})}},$v=5e4;function ey(e){return e.length<=$v?e:e.slice(0,$v)}function ty(e){if(e!=null)try{return ey(JSON.stringify(e))}catch{return}}var ny=/^[A-Za-z0-9+/]{100,}={0,2}$/;function ry(e){if(e!=null){try{let t=typeof e==`string`?JSON.parse(e):e;if(Array.isArray(t)){let e=t.map(e=>{if(e&&typeof e==`object`&&e.type&&(e.type===`image`||e.type===`audio`)&&typeof e.data==`string`&&ny.test(e.data.slice(0,200))){let t=(e.data.length*3/4/1024).toFixed(1);return{...e,data:`[${e.type}: ${t}KB]`}}return e});return ey(JSON.stringify(e))}}catch{}return ty(e)}}function iy(e,t,n,r,i,a){let o={tool_name:e,tool_call_id:t},s=i??ty(n);s!==void 0&&(o.tool_args=s);let c=a===`mcp`?ry(r):ty(r);return c!==void 0&&(o.tool_result=c),a&&(o.tool_source=a),o}function ay(e,t){if(!t)return e;if(!e)return t.map(e=>({...e}));let n=Math.min(e.length,t.length);return e.map((e,r)=>({...e,...r<n?t[r]:void 0}))}function oy(e,t){switch(e){case`aui/v0`:return ly(t);case`ai-sdk/v6`:return vy(t);default:return null}}function sy(e,t){if(e===`ai-sdk/v6`)return yy(t);for(let n=t.length-1;n>=0;n--){let r=oy(e,t[n]);if(r)return r}return null}var cy={error:`error`,incomplete:`incomplete`};function ly(e){let t=e;if(t.role!==`assistant`||t.status?.type===`requires-action`)return null;let n=t.content?.filter(e=>e.type===`tool-call`&&e.toolName&&e.toolCallId).map(e=>iy(e.toolName,e.toolCallId,e.args,e.result,e.argsText)),r=t.content?.filter(e=>e.type===`text`&&e.text),i=r&&r.length>0?ey(r.map(e=>e.text).join(``)):void 0,a=t.metadata?.steps,o,s,c,l;if(a&&a.length>0){let e=0,t=0,n=0,r=0,i=!1,u=!1,d=!1,f=!1;for(let o of a)o.usage?.inputTokens!=null&&(e+=o.usage.inputTokens,i=!0),o.usage?.outputTokens!=null&&(t+=o.usage.outputTokens,u=!0),o.usage?.reasoningTokens!=null&&(n+=o.usage.reasoningTokens,d=!0),o.usage?.cachedInputTokens!=null&&(r+=o.usage.cachedInputTokens,f=!0);o=i?e:void 0,s=u?t:void 0,c=d?n:void 0,l=f?r:void 0}let u=t.status?.type,d=u&&cy[u]||`completed`,f=t.metadata?.custom,p=t.metadata?.modelId??(typeof t.metadata?.custom?.modelId==`string`?t.metadata.custom.modelId:void 0),m=a&&a.length>1?a.map(e=>({...e.usage?.inputTokens==null?void 0:{input_tokens:e.usage.inputTokens},...e.usage?.outputTokens==null?void 0:{output_tokens:e.usage.outputTokens},...e.usage?.reasoningTokens==null?void 0:{reasoning_tokens:e.usage.reasoningTokens},...e.usage?.cachedInputTokens==null?void 0:{cached_input_tokens:e.usage.cachedInputTokens}})):void 0;return{status:d,...n&&n.length>0?{toolCalls:n}:void 0,...a?.length?{totalSteps:a.length}:void 0,...o==null?void 0:{inputTokens:o},...s==null?void 0:{outputTokens:s},...c==null?void 0:{reasoningTokens:c},...l==null?void 0:{cachedInputTokens:l},...i==null?void 0:{outputText:i},...f?{metadata:f}:void 0,...m?{steps:m}:void 0,...p?{modelId:p}:void 0}}function uy(e){return e.toolCallId?e.type===`tool-call`||e.type===`dynamic-tool`?!!e.toolName:e.type.startsWith(`tool-`)||e.type.startsWith(`dynamic-tool-`):!1}function dy(e){return e.type===`dynamic-tool`||e.type.startsWith(`dynamic-tool-`)}function fy(e){let t=dy(e)?`mcp`:void 0;return iy(e.toolName??e.type.slice(5),e.toolCallId,e.args??e.input,e.result??e.output,void 0,t)}function py(e){let t=[],n=[],r=[],i=null;for(let a of e)if(a.type===`step-start`)i!==null&&r.push({tool_calls:i}),i=[];else if(a.type===`text`&&a.text)t.push(a.text);else if(uy(a)){let e=fy(a);n.push(e),i!==null&&i.push(e)}return i!==null&&r.push({tool_calls:i}),{textParts:t,toolCalls:n,stepsData:r}}function my(e){if(!e)return;if(typeof e.modelId==`string`)return e.modelId;let t=e.custom;if(typeof t?.modelId==`string`)return t.modelId}function hy(e,t,n,r,i,a){let o=e.length>0,s=o?ey(e.join(``)):void 0,c=my(r),l=i&&i.length>1?i.map(e=>({...e.tool_calls.length>0?{tool_calls:e.tool_calls}:void 0})):void 0;return{status:o?`completed`:`incomplete`,...t.length>0?{toolCalls:t}:void 0,...n>0?{totalSteps:n}:void 0,...a?.inputTokens==null?void 0:{inputTokens:a.inputTokens},...a?.outputTokens==null?void 0:{outputTokens:a.outputTokens},...a?.reasoningTokens==null?void 0:{reasoningTokens:a.reasoningTokens},...a?.cachedInputTokens==null?void 0:{cachedInputTokens:a.cachedInputTokens},...s==null?void 0:{outputText:s},...r?{metadata:r}:void 0,...l?{steps:l}:void 0,...c?{modelId:c}:void 0}}function gy(e){let t=e.inputTokens??e.promptTokens,n=e.outputTokens??e.completionTokens;if(t!=null||n!=null||e.reasoningTokens!=null||e.cachedInputTokens!=null)return{...t==null?void 0:{inputTokens:t},...n==null?void 0:{outputTokens:n},...e.reasoningTokens==null?void 0:{reasoningTokens:e.reasoningTokens},...e.cachedInputTokens==null?void 0:{cachedInputTokens:e.cachedInputTokens}}}function _y(e){let t=e?.usage;if(t){let e=gy(t);if(e)return e}let n=e?.steps;if(n&&n.length>0){let e=0,t=0,r=0,i=0,a=!1,o=!1,s=!1,c=!1,l=!1;for(let u of n){if(!u.usage)continue;let n=gy(u.usage);n&&(n.inputTokens!=null&&(e+=n.inputTokens,a=!0),n.outputTokens!=null&&(t+=n.outputTokens,o=!0),n.reasoningTokens!=null&&(r+=n.reasoningTokens,s=!0),n.cachedInputTokens!=null&&(i+=n.cachedInputTokens,c=!0),l=!0)}if(l)return{...a?{inputTokens:e}:void 0,...o?{outputTokens:t}:void 0,...s?{reasoningTokens:r}:void 0,...c?{cachedInputTokens:i}:void 0}}}function vy(e){let t=e;if(t.role!==`assistant`)return null;let{textParts:n,toolCalls:r,stepsData:i}=py(t.parts??[]);return hy(n,r,i.length,t.metadata,i,_y(t.metadata))}function yy(e){let t=[],n=[],r=[],i=!1,a,o=0,s=0,c=0,l=0,u=!1,d=!1,f=!1,p=!1;for(let m of e){let e=m;if(e.role!==`assistant`)continue;i=!0;let{textParts:h,toolCalls:g,stepsData:_}=py(e.parts??[]);t.push(...h),n.push(...g),r.push(..._),e.metadata&&(a=e.metadata);let v=_y(e.metadata);v&&(v.inputTokens!=null&&(o+=v.inputTokens,u=!0),v.outputTokens!=null&&(s+=v.outputTokens,d=!0),v.reasoningTokens!=null&&(c+=v.reasoningTokens,f=!0),v.cachedInputTokens!=null&&(l+=v.cachedInputTokens,p=!0))}return i?hy(t,n,r.length,a,r,{...u?{inputTokens:o}:void 0,...d?{outputTokens:s}:void 0,...f?{reasoningTokens:c}:void 0,...p?{cachedInputTokens:l}:void 0}):null}function by(e){let t=zd(),n=I(t);L(()=>{n.current=t});let[r]=Pc(()=>new Qv(e,()=>n.current));return r}var xy=e=>e.startsWith(`image/`)?`image`:e.startsWith(`text/`)?`document`:`file`,Sy=class{accept=`*`;getCloud;constructor(e){this.getCloud=typeof e==`function`?e:()=>e}uploadedUrls=new Map;async*add({file:e}){let t=tm(),n={id:t,type:xy(e.type),name:e.name,contentType:e.type,file:e,status:{type:`running`,reason:`uploading`,progress:0}};yield n;try{let{signedUrl:r,publicUrl:i}=await this.getCloud().files.generatePresignedUploadUrl({filename:e.name}),a=await fetch(r,{method:`PUT`,body:e,headers:{"Content-Type":e.type},mode:`cors`});if(!a.ok)throw Error(`Failed to upload file: ${a.status} ${a.statusText}`);this.uploadedUrls.set(t,i),n={...n,status:{type:`requires-action`,reason:`composer-send`}},yield n}catch(e){console.error(`[assistant-ui] Failed to upload attachment:`,e),n={...n,status:{type:`incomplete`,reason:`error`,message:e instanceof Error?e.message:String(e)}},yield n}}async remove(e){this.uploadedUrls.delete(e.id)}async send(e){let t=this.uploadedUrls.get(e.id);if(!t)throw Error(`Attachment not uploaded`);this.uploadedUrls.delete(e.id);let n;return n=e.type===`image`?[{type:`image`,image:t,filename:e.name}]:[{type:`file`,data:t,mimeType:e.contentType??``,filename:e.name}],{...e,status:{type:`complete`},content:n}}},Cy=class{list(){return Promise.resolve({threads:[]})}rename(){return Promise.resolve()}updateCustom(){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({start(e){e.close()}}))}fetch(e){return Promise.reject(Error(`Thread "${e}" not found in in-memory thread list.`))}},wy=e=>ep(e)?e:void 0,Ty=typeof process<`u`&&{}.NEXT_PUBLIC_ASSISTANT_BASE_URL,Ey=Ty?new Jv({baseUrl:Ty,anonymous:!0}):void 0,Dy=20,Oy=e=>{let t={activeCursor:e,archivedCursor:void 0,activeExhausted:!1,archivedExhausted:!1};if(!e||!e.startsWith(`{`))return t;try{let n=JSON.parse(e);return ep(n)?{activeCursor:typeof n.a==`string`?n.a:void 0,archivedCursor:typeof n.r==`string`?n.r:void 0,activeExhausted:n.ae===!0,archivedExhausted:n.re===!0}:t}catch{return t}},ky=e=>{let t=by({get current(){return e.current.cloud??Ey}}),[n]=Pc(()=>new Sy(()=>e.current.cloud??Ey));return Ic(()=>({history:t,attachments:n}),[t,n])},Ay=e=>{let t=I(e);L(()=>{t.current=e},[e]);let n=Lc(function(){return ky(t)},[]),r=Lc(function({children:e}){let n=ky(t);return(0,M.jsx)(Lg,{adapters:n,children:e})},[]),i=e.cloud??Ey;return Ic(()=>{if(!i){let e=t,n=new Cy;return n.initialize=async t=>({remoteId:t,externalId:(await e.current.create?.())?.externalId}),n}return{list:async({after:e}={})=>{let{activeCursor:t,archivedCursor:n,activeExhausted:r,archivedExhausted:a}=Oy(e),[{threads:o},{threads:s}]=await Promise.all([r?Promise.resolve({threads:[]}):i.threads.list({limit:Dy,...t?{after:t}:{}}),a?Promise.resolve({threads:[]}):i.threads.list({is_archived:!0,limit:Dy,...n?{after:n}:{}})]),c=!r&&o.length===Dy?o.at(-1)?.id:void 0,l=!a&&s.length===Dy?s.at(-1)?.id:void 0;return{threads:[...o,...s].map(e=>({status:e.is_archived?`archived`:`regular`,remoteId:e.id,title:e.title,lastMessageAt:e.last_message_at?new Date(e.last_message_at):void 0,externalId:e.external_id??void 0,custom:wy(e.metadata)})),nextCursor:c||l?JSON.stringify({a:c,r:l,...c===void 0?{ae:!0}:{},...l===void 0?{re:!0}:{}}):void 0}},initialize:async()=>{let e=await(t.current.create?.()??Promise.resolve()),n=e?e.externalId:void 0,{thread_id:r}=await i.threads.create({last_message_at:new Date,external_id:n});return{externalId:n,remoteId:r}},rename:async(e,t)=>i.threads.update(e,{title:t}),updateCustom:async(e,t)=>i.threads.update(e,{metadata:t??null}),archive:async e=>i.threads.update(e,{is_archived:!0}),unarchive:async e=>i.threads.update(e,{is_archived:!1}),delete:async e=>(await t.current.delete?.(e),i.threads.delete(e)),generateTitle:async(e,t)=>{let n=t.map(e=>({...e,content:e.content.filter(e=>e.type===`text`||e.type===`tool-call`)}));return i.runs.stream({thread_id:e,assistant_id:`system/thread_title`,messages:n})},fetch:async e=>{let t=await i.threads.get(e);return{status:t.is_archived?`archived`:`regular`,remoteId:t.id,title:t.title,lastMessageAt:t.last_message_at?new Date(t.last_message_at):void 0,externalId:t.external_id??void 0,custom:wy(t.metadata)}},unstable_Provider:r,unstable_useAdapters:n}},[i,r,n])},jy=e=>{let t=F(6),{id:n,children:r}=e,i=zd(),a;t[0]===n?a=t[1]:(a=_u({message:Kd({source:`thread`,query:{type:`id`,id:n},get:e=>e.thread.message({id:n})}),composer:Kd({source:`message`,query:{},get:e=>e.thread.message({id:n}).composer()})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,M.jsx)(Rf,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},My=(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,Ny=()=>null,Py=new WeakMap,Fy=(e,t)=>{let n=Py.get(e);return n||(n=new Set(e.map(e=>e.id)),Py.set(e,n)),n.has(t)},Iy=(e,t,n)=>{switch(t){case`user`:return n?e.UserEditComposer??e.EditComposer??e.UserMessage??e.Message:e.UserMessage??e.Message;case`assistant`:return n?e.AssistantEditComposer??e.EditComposer??e.AssistantMessage??e.Message:e.AssistantMessage??e.Message;case`system`:return n?e.SystemEditComposer??e.EditComposer??e.SystemMessage??e.Message??Ny:e.SystemMessage??e.Message??Ny;default:throw Error(`Unknown message role: ${t}`)}},Ly=e=>{let t=F(6),{components:n}=e,r=R(Uy),i=R(Wy),a;t[0]!==n||t[1]!==i||t[2]!==r?(a=Iy(n,r,i),t[0]=n,t[1]=i,t[2]=r,t[3]=a):a=t[3];let o=a,s;return t[4]===o?s=t[5]:(s=(0,M.jsx)(o,{}),t[4]=o,t[5]=s),s},Ry=Kc(e=>{let t=F(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,M.jsx)(Ly,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,M.jsx)(Bh,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&My(e.components,t.components));Ry.displayName=`ThreadPrimitive.MessageByIndex`;var zy=Kc(e=>{let t=F(7),{messageId:n,components:r}=e,i;if(t[0]===n?i=t[1]:(i=e=>Fy(e.thread.messages,n),t[0]=n,t[1]=i),!R(i))return null;let a;t[2]===r?a=t[3]:(a=(0,M.jsx)(Ly,{components:r}),t[2]=r,t[3]=a);let o;return t[4]!==n||t[5]!==a?(o=(0,M.jsx)(jy,{id:n,children:a}),t[4]=n,t[5]=a,t[6]=o):o=t[6],o},(e,t)=>e.messageId===t.messageId&&My(e.components,t.components));zy.displayName=`ThreadPrimitive.Unstable_MessageById`;var By=({children:e})=>{let t=R(e=>e.thread.messages.length);return Ic(()=>t===0?null:Array.from({length:t},(t,n)=>(0,M.jsx)(Bh,{index:n,children:(0,M.jsx)(Vf,{getItemState:e=>e.thread.message({index:n}).getState(),children:t=>e({get message(){return t()}})})},n)),[t,e])},Vy=e=>{let t=F(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,M.jsx)(By,{children:()=>(0,M.jsx)(Ly,{components:n})}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,M.jsx)(By,{children:r}),t[2]=r,t[3]=i),i};Vy.displayName=`ThreadPrimitive.Messages`;var Hy=Kc(Vy,(e,t)=>e.children||t.children?e.children===t.children:My(e.components,t.components));function Uy(e){return e.message.role}function Wy(e){return e.message.composer.isEditing}var Gy=e=>{let t=e.message.metadata;if(!(!t||typeof t!=`object`))return t.custom?.quote},Ky=class extends Error{componentName;constructor(e,t=`Component "${e}" is not in the generative-ui allowlist.`){super(t),this.name=`GenerativeUIRenderError`,this.componentName=e}},qy=e=>typeof e==`object`&&!!e,Jy=(e,t,n,r)=>{if(e==null)return null;if(typeof e==`string`)return e;if(!qy(e)||!(`component`in e)||typeof e.component!=`string`)return null;let{component:i,props:a,children:o,key:s}=e,c=t[i];if(!c){if(n)return(0,M.jsx)(n,{component:i,props:a},s??r);throw new Ky(i)}let l=o?.length?o.map((e,i)=>Jy(e,t,n,`${r}/${i}`)):void 0;return Jc(c,{...a??{},key:s??r},...l??[])},Yy=e=>{if(!e||e.root===void 0||e.root===null)return[];let t=e.root;return Array.isArray(t)?t:[t]},Xy=e=>{let t=F(11),{spec:n,components:r,Fallback:i}=e,a;t[0]===n?a=t[1]:(a=Yy(n),t[0]=n,t[1]=a);let o=a,s;if(t[2]!==i||t[3]!==r||t[4]!==o){let e;t[6]!==i||t[7]!==r?(e=(e,t)=>Jy(e,r,i,`${t}`),t[6]=i,t[7]=r,t[8]=e):e=t[8],s=o.map(e),t[2]=i,t[3]=r,t[4]=o,t[5]=s}else s=t[5];let c;return t[9]===s?c=t[10]:(c=(0,M.jsx)(M.Fragment,{children:s}),t[9]=s,t[10]=c),c};Xy.displayName=`GenerativeUIRender`;var Zy=e=>{let t=F(4),{components:n,spec:r,Fallback:i}=e,a=R(Qy),o=r??a;if(!o)return null;let s;return t[0]!==i||t[1]!==n||t[2]!==o?(s=(0,M.jsx)(Xy,{spec:o,components:n,Fallback:i}),t[0]=i,t[1]=n,t[2]=o,t[3]=s):s=t[3],s};Zy.displayName=`MessagePrimitive.GenerativeUI`;function Qy(e){let t=e.part;return t?.type===`generative-ui`?t.spec:void 0}var $y=`ui://`,eb=e=>!!e?.startsWith($y),tb=e=>Symbol.iterator in e,nb=e=>`entries`in e,rb=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},ib=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function ab(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:tb(e)&&tb(t)?nb(e)&&nb(t)?rb(e,t):ib(e,t):rb({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function ob(e){let t=_.useRef(void 0);return n=>{let r=e(n);return ab(t.current,r)?t.current:t.current=r}}var sb=e=>{let t=-1;return{startGroup:e=>{t===-1&&(t=e)},endGroup:(n,r)=>{t!==-1&&(r.push({type:e,startIndex:t,endIndex:n}),t=-1)},finalize:(n,r)=>{t!==-1&&r.push({type:e,startIndex:t,endIndex:n})}}},cb=(e,t,n)=>{let r=[];if(t){let t=sb(`chainOfThoughtGroup`);for(let n=0;n<e.length;n++){let i=e[n];i===`tool-call`||i===`reasoning`?t.startGroup(n):(t.endGroup(n-1,r),r.push({type:`single`,index:n}))}t.finalize(e.length-1,r)}else{let t=sb(`toolGroup`),n=sb(`reasoningGroup`);for(let i=0;i<e.length;i++){let a=e[i];a===`tool-call`?(n.endGroup(i-1,r),t.startGroup(i)):a===`reasoning`?(t.endGroup(i-1,r),n.startGroup(i)):(t.endGroup(i-1,r),n.endGroup(i-1,r),r.push({type:`single`,index:i}))}t.finalize(e.length-1,r),n.finalize(e.length-1,r)}if(n){let e=new Set;for(let t of r){if(t.type===`single`)continue;let r=n[t.startIndex];r!==void 0&&!e.has(r)&&(e.add(r),t.idKey=`id:${r}`)}}return r},lb=e=>{let t=F(10),n=R(ob(Nb)),r=R(ob(Fb)),i;bb0:{if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0];let n;t[1]===r?n=t[2]:(n={ranges:e,partIds:r},t[1]=r,t[2]=n),i=n;break bb0}let a;t[3]!==n||t[4]!==r||t[5]!==e?(a=cb(n,e,r),t[3]=n,t[4]=r,t[5]=e,t[6]=a):a=t[6];let o;t[7]!==r||t[8]!==a?(o={ranges:a,partIds:r},t[7]=r,t[8]=a,t[9]=o):o=t[9],i=o}return i},ub=e=>{let t=F(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.toolName?(i=e=>e.tools.toolUIs[r.toolName]?.[0]?.render??n,t[3]=n,t[4]=r.toolName,t[5]=i):i=t[5];let a=R(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,M.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},db=(e,t,n)=>e.renderers[t]?.[0]||(e.fallbacks[0]??n),fb=e=>{let t=F(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.name?(i=e=>db(e.dataRenderers,r.name,n),t[3]=n,t[4]=r.name,t[5]=i):i=t[5];let a=R(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,M.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},pb={Text:()=>null,Reasoning:()=>null,Source:()=>null,Image:()=>null,File:()=>null,Unstable_Audio:()=>null,ToolGroup:({children:e})=>e,ReasoningGroup:({children:e})=>e},mb=e=>{let t=F(41),{components:n}=e,r;t[0]===n?r=t[1]:(r=n===void 0?{}:n,t[0]=n,t[1]=r);let{Text:i,Reasoning:a,Image:o,Source:s,File:c,Unstable_Audio:l,tools:u,data:d,generativeUI:f}=r,p=i===void 0?pb.Text:i,m=a===void 0?pb.Reasoning:a,h=o===void 0?pb.Image:o,g=s===void 0?pb.Source:s,_=c===void 0?pb.File:c,v=l===void 0?pb.Unstable_Audio:l,y;t[2]===u?y=t[3]:(y=u===void 0?{}:u,t[2]=u,t[3]=y);let b=y,x=zd(),S=R(Ib),C=S.type;if(C===`tool-call`){let e=x.part.addToolResult,n=x.part.resumeToolCall,r=x.part.respondToToolApproval;if(`Override`in b){let i;return t[4]!==e||t[5]!==S||t[6]!==r||t[7]!==n||t[8]!==b.Override?(i=(0,M.jsx)(b.Override,{...S,addResult:e,resume:n,respondToApproval:r}),t[4]=e,t[5]=S,t[6]=r,t[7]=n,t[8]=b.Override,t[9]=i):i=t[9],i}let i=b.by_name?.[S.toolName]??b.Fallback,a;return t[10]!==i||t[11]!==e||t[12]!==S||t[13]!==r||t[14]!==n?(a=(0,M.jsx)(ub,{...S,Fallback:i,addResult:e,resume:n,respondToApproval:r}),t[10]=i,t[11]=e,t[12]=S,t[13]=r,t[14]=n,t[15]=a):a=t[15],a}if(S.status?.type===`requires-action`)throw Error(`Encountered unexpected requires-action status`);switch(C){case`text`:{let e;return t[16]!==p||t[17]!==S?(e=(0,M.jsx)(p,{...S}),t[16]=p,t[17]=S,t[18]=e):e=t[18],e}case`reasoning`:{let e;return t[19]!==m||t[20]!==S?(e=(0,M.jsx)(m,{...S}),t[19]=m,t[20]=S,t[21]=e):e=t[21],e}case`source`:{let e;return t[22]!==g||t[23]!==S?(e=(0,M.jsx)(g,{...S}),t[22]=g,t[23]=S,t[24]=e):e=t[24],e}case`image`:{let e;return t[25]!==h||t[26]!==S?(e=(0,M.jsx)(h,{...S}),t[25]=h,t[26]=S,t[27]=e):e=t[27],e}case`file`:{let e;return t[28]!==_||t[29]!==S?(e=(0,M.jsx)(_,{...S}),t[28]=_,t[29]=S,t[30]=e):e=t[30],e}case`audio`:{let e;return t[31]!==v||t[32]!==S?(e=(0,M.jsx)(v,{...S}),t[31]=v,t[32]=S,t[33]=e):e=t[33],e}case`data`:{let e=d?.by_name?.[S.name]??d?.Fallback,n;return t[34]!==e||t[35]!==S?(n=(0,M.jsx)(fb,{...S,Fallback:e}),t[34]=e,t[35]=S,t[36]=n):n=t[36],n}case`generative-ui`:{if(!f?.components)return null;let e=S,n;return t[37]!==f.Fallback||t[38]!==f.components||t[39]!==e.spec?(n=(0,M.jsx)(Xy,{spec:e.spec,components:f.components,Fallback:f.Fallback}),t[37]=f.Fallback,t[38]=f.components,t[39]=e.spec,t[40]=n):n=t[40],n}default:return console.warn(`Unknown message part type: ${C}`),null}},hb=Kc(e=>{let t=F(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,M.jsx)(mb,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,M.jsx)(Vh,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components?.Text===t.components?.Text&&e.components?.Reasoning===t.components?.Reasoning&&e.components?.Source===t.components?.Source&&e.components?.Image===t.components?.Image&&e.components?.File===t.components?.File&&e.components?.Unstable_Audio===t.components?.Unstable_Audio&&e.components?.tools===t.components?.tools&&e.components?.data===t.components?.data&&e.components?.generativeUI===t.components?.generativeUI&&e.components?.ToolGroup===t.components?.ToolGroup&&e.components?.ReasoningGroup===t.components?.ReasoningGroup);hb.displayName=`MessagePrimitive.PartByIndex`;var gb=e=>{let t=F(6),{status:n,component:r}=e,i=n.type===`running`,a;t[0]!==r||t[1]!==n?(a=(0,M.jsx)(r,{type:`text`,text:``,status:n}),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o;return t[3]!==i||t[4]!==a?(o=(0,M.jsx)(Uh,{text:``,isRunning:i,children:a}),t[3]=i,t[4]=a,t[5]=o):o=t[5],o},_b=Object.freeze({type:`complete`}),vb=Object.freeze({type:`running`}),yb=Kc(e=>{let t=F(6),{components:n}=e,r=R(Lb);if(n?.Empty){let e;return t[0]!==n.Empty||t[1]!==r?(e=(0,M.jsx)(n.Empty,{status:r}),t[0]=n.Empty,t[1]=r,t[2]=e):e=t[2],e}if(r.type!==`running`)return null;let i=n?.Text??pb.Text,a;return t[3]!==r||t[4]!==i?(a=(0,M.jsx)(gb,{status:r,component:i}),t[3]=r,t[4]=i,t[5]=a):a=t[5],a},(e,t)=>e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),bb=Kc(e=>{let t=F(4),{components:n,enabled:r}=e,i;if(t[0]===r?i=t[1]:(i=e=>{if(!r||e.message.parts.length===0)return!1;let t=e.message.parts[e.message.parts.length-1];return t?.type!==`text`&&t?.type!==`reasoning`},t[0]=r,t[1]=i),!R(i))return null;let a;return t[2]===n?a=t[3]:(a=(0,M.jsx)(yb,{components:n}),t[2]=n,t[3]=a),a},(e,t)=>e.enabled===t.enabled&&e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),xb=Kc(e=>{let t=F(4),{Quote:n}=e,r=R(Gy);if(!r)return null;let i;return t[0]!==n||t[1]!==r.messageId||t[2]!==r.text?(i=(0,M.jsx)(n,{text:r.text,messageId:r.messageId}),t[0]=n,t[1]=r.messageId,t[2]=r.text,t[3]=i):i=t[3],i});function Sb(e,t){return(e.toolUIs[t.toolName]?.[0]?.render??null)||(eb(t.mcp?.app?.resourceUri)&&e.mcpApp?e.mcpApp.render:null)}var Cb=()=>{let e=F(6),t=zd(),n=R(Rb),r=R(zb);if(!r||n.type!==`tool-call`)return null;let i;return e[0]!==r||e[1]!==t.part.addToolResult||e[2]!==t.part.respondToToolApproval||e[3]!==t.part.resumeToolCall||e[4]!==n?(i=(0,M.jsx)(r,{...n,addResult:t.part.addToolResult,resume:t.part.resumeToolCall,respondToApproval:t.part.respondToToolApproval}),e[0]=r,e[1]=t.part.addToolResult,e[2]=t.part.respondToToolApproval,e[3]=t.part.resumeToolCall,e[4]=n,e[5]=i):i=e[5],i},wb=()=>{let e=F(3),t=R(Bb),n=R(Vb);if(!n||t.type!==`data`)return null;let r=t,i;return e[0]!==n||e[1]!==r?(i=(0,M.jsx)(n,{...r}),e[0]=n,e[1]=r,e[2]=i):i=e[2],i},Tb=()=>{let e=F(2),t=R(Hb);if(t===`tool-call`){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,M.jsx)(Cb,{}),e[0]=t):t=e[0],t}if(t===`data`){let t;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,M.jsx)(wb,{}),e[1]=t):t=e[1],t}return null},Eb=Object.freeze({type:`text`,text:``,status:vb}),Db=({children:e})=>{let t=zd(),n=R(e=>e.dataRenderers);return(0,M.jsx)(Vf,{getItemState:e=>e.part.getState(),children:r=>e({get part(){let e=r();if(e.type===`tool-call`){let n=Sb(t.tools.getState(),e)!==null,r=t.part;return{...e,toolUI:n?(0,M.jsx)(Cb,{}):null,addResult:r.addToolResult,resume:r.resumeToolCall,respondToApproval:r.respondToToolApproval}}if(e.type===`data`){let t=db(n,e.name,void 0)!==void 0;return{...e,dataRendererUI:t?(0,M.jsx)(wb,{}):null}}return e}})})},Ob=e=>{let t=F(5),{index:n,children:r}=e,i;t[0]===r?i=t[1]:(i=(0,M.jsx)(Db,{children:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,M.jsx)(Vh,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},kb=e=>{let t=F(9),{children:n}=e,r=R(Ub),i=R(Wb),a=r===0&&i;if(r===0){if(!a)return null;let e;t[0]===n?e=t[1]:(e=n({part:Eb}),t[0]=n,t[1]=e);let r;return t[2]===e?r=t[3]:(r=(0,M.jsx)(Uh,{text:``,isRunning:!0,children:e}),t[2]=e,t[3]=r),r}let o;if(t[4]!==n||t[5]!==r){let e;t[7]===n?e=t[8]:(e=(e,t)=>(0,M.jsx)(Ob,{index:t,children:e=>n(e)??(0,M.jsx)(Tb,{})},t),t[7]=n,t[8]=e),o=(0,M.jsx)(M.Fragment,{children:Array.from({length:r},e)}),t[4]=n,t[5]=r,t[6]=o}else o=t[6];return o},Ab=e=>{let t=F(5),{components:n,unstable_showEmptyOnNonTextEnd:r,children:i}=e,a=r===void 0||r;if(i){let e;return t[0]===i?e=t[1]:(e=(0,M.jsx)(kb,{children:i}),t[0]=i,t[1]=e),e}let o;return t[2]!==n||t[3]!==a?(o=(0,M.jsx)(jb,{components:n,unstable_showEmptyOnNonTextEnd:a}),t[2]=n,t[3]=a,t[4]=o):o=t[4],o};Ab.displayName=`MessagePrimitive.Parts`;var jb=e=>{let t=F(15),{components:n,unstable_showEmptyOnNonTextEnd:r}=e,i=R(Gb),{ranges:a,partIds:o}=lb(!!n?.ChainOfThought),s;bb0:{if(i===0){let e;t[0]===n?e=t[1]:(e=(0,M.jsx)(yb,{components:n}),t[0]=n,t[1]=e),s=e;break bb0}let e;if(t[2]!==n||t[3]!==a||t[4]!==o){let r=new Set,i=e=>{let t=o[e];return t!==void 0&&!r.has(t)?(r.add(t),`part-id:${t}`):`part-${e}`};e=a.map(e=>{if(e.type===`single`)return(0,M.jsx)(hb,{index:e.index,components:n},e.index);if(e.type===`chainOfThoughtGroup`){let t=n?.ChainOfThought;return t?(0,M.jsx)(eg,{startIndex:e.startIndex,endIndex:e.endIndex,children:(0,M.jsx)(t,{})},`chainOfThought-${e.idKey??e.startIndex}`):null}if(e.type===`toolGroup`){let t=n?.ToolGroup??pb.ToolGroup;return(0,M.jsx)(t,{startIndex:e.startIndex,endIndex:e.endIndex,children:Array.from({length:e.endIndex-e.startIndex+1},(t,r)=>{let a=e.startIndex+r;return(0,M.jsx)(hb,{index:a,components:n},i(a))})},`tool-${e.idKey??e.startIndex}`)}{let t=n?.ReasoningGroup??pb.ReasoningGroup;return(0,M.jsx)(t,{startIndex:e.startIndex,endIndex:e.endIndex,children:Array.from({length:e.endIndex-e.startIndex+1},(t,r)=>{let i=e.startIndex+r;return(0,M.jsx)(hb,{index:i,components:n},`part-${i}`)})},`reasoning-${e.startIndex}`)}}),t[2]=n,t[3]=a,t[4]=o,t[5]=e}else e=t[5];s=e}let c=s,l;t[6]===n?l=t[7]:(l=n?.Quote&&(0,M.jsx)(xb,{Quote:n.Quote}),t[6]=n,t[7]=l);let u;t[8]!==n||t[9]!==r?(u=(0,M.jsx)(bb,{components:n,enabled:r}),t[8]=n,t[9]=r,t[10]=u):u=t[10];let d;return t[11]!==c||t[12]!==l||t[13]!==u?(d=(0,M.jsxs)(M.Fragment,{children:[l,c,u]}),t[11]=c,t[12]=l,t[13]=u,t[14]=d):d=t[14],d};function Mb(e){return e.type}function Nb(e){return e.message.parts.map(Mb)}function Pb(e){return e.type===`tool-call`?e.toolCallId:void 0}function Fb(e){return e.message.parts.map(Pb)}function Ib(e){return e.part}function Lb(e){return e.message.status??_b}function Rb(e){return e.part}function zb(e){return e.part.type===`tool-call`?Sb(e.tools,e.part):null}function Bb(e){return e.part}function Vb(e){return e.part.type===`data`?db(e.dataRenderers,e.part.name,void 0)??null:null}function Hb(e){return e.part.type}function Ub(e){return e.message.parts.length}function Wb(e){return(e.message.status?.type??`complete`)===`running`}function Gb(e){return e.message.parts.length}var Kb=Symbol.for(`@assistant-ui/groupBy.memoKey`),qb=e=>{let t=e.nextChildIdx++;return e.nodeKey===``?String(t):`${e.nodeKey}.${t}`},Jb=(e,t)=>{if(!(t===void 0||e.claimed.has(t)))return e.claimed.add(t),`id:${t}`},Yb=(e,t)=>{let n={key:``,nodeKey:``,indices:[],children:[],nextChildIdx:0,claimed:new Set},r=[n],i=()=>{let e=r.pop(),n=r[r.length-1];n.children.push({type:`group`,key:e.key,nodeKey:e.nodeKey,idKey:Jb(n,t?.[e.indices[0]]),indices:e.indices,children:e.children})};for(let n=0;n<e.length;n++){let a=e[n],o=0;for(;o<r.length-1&&o<a.length&&r[o+1].key===a[o];)o++;for(;r.length-1>o;)i();for(;r.length-1<a.length;){let e=r[r.length-1];r.push({key:a[r.length-1],nodeKey:qb(e),indices:[],children:[],nextChildIdx:0,claimed:new Set})}let s=r[r.length-1];s.children.push({type:`part`,index:n,nodeKey:qb(s),idKey:Jb(s,t?.[n])});for(let e=1;e<r.length;e++)r[e].indices.push(n)}for(;r.length>1;)i();return n.children},Xb=(e,t,n)=>{if(!n)return!1;switch(e){case`never`:return!1;case`always`:return!0;case`empty`:return t.length===0;case`no-text`:{let e=t[t.length-1];return e===void 0||e.type!==`text`&&e.type!==`reasoning`}}},Zb=()=>{throw Error("MessagePrimitive.GroupedParts: rendered `children` under a leaf part. `children` is only meaningful for `group-…` cases — add a matching case for the part type or return `null` to skip it.")},Qb=(e,t,n)=>{if(e.type===`part`)return(0,M.jsx)(Ob,{index:e.index,children:({part:e})=>n({part:e,children:(0,M.jsx)(Zb,{})})},e.idKey?`part-${e.idKey}`:`part-${e.index}`);let r=Qh(t,e.indices),i={type:e.key,status:r,indices:e.indices};return(0,M.jsx)(qc,{children:n({part:i,children:(0,M.jsx)(M.Fragment,{children:e.children.map(e=>Qb(e,t,n))})})},e.idKey??e.nodeKey)},$b=({groupBy:e,indicator:t=`no-text`,children:n})=>{let r=R(ob(e=>e.message.parts)),i=R(e=>e.tools.toolUIs),a=R(e=>t!==`never`&&e.message.status?.type===`running`),o=Ic(()=>{let t={toolUIs:i};return Yb(r.map(n=>e(n,t)??[]),r.map(e=>e.type===`tool-call`?e.toolCallId:void 0))},[r,e[Kb]??e,i]);return(0,M.jsxs)(M.Fragment,{children:[o.map(e=>Qb(e,r,n)),Xb(t,r,a)&&n({part:{type:`indicator`},children:(0,M.jsx)(Zb,{})})]})};$b.displayName=`MessagePrimitive.GroupedParts`;var ex=Kc(e=>{let t=F(5),{children:n}=e,r=R(Gy);if(!r)return null;let i;t[0]!==n||t[1]!==r?(i=n(r),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a;return t[3]===i?a=t[4]:(a=(0,M.jsx)(M.Fragment,{children:i}),t[3]=i,t[4]=a),a});ex.displayName=`MessagePrimitive.Quote`;var tx=(e,t)=>{switch(t.type){case`image`:return e?.Image??e?.Attachment;case`document`:return e?.Document??e?.Attachment;case`file`:return e?.File??e?.Attachment;default:return e?.Attachment}},nx=e=>{let t=F(5),{components:n}=e,r=R(ox);if(!r)return null;let i=r,a;t[0]!==n||t[1]!==i?(a=tx(n,i),t[0]=n,t[1]=i,t[2]=a):a=t[2];let o=a;if(!o)return null;let s;return t[3]===o?s=t[4]:(s=(0,M.jsx)(o,{}),t[3]=o,t[4]=s),s},rx=Kc(e=>{let t=F(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,M.jsx)(nx,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,M.jsx)(Lh,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components?.Image===t.components?.Image&&e.components?.Document===t.components?.Document&&e.components?.File===t.components?.File&&e.components?.Attachment===t.components?.Attachment);rx.displayName=`MessagePrimitive.AttachmentByIndex`;var ix=({children:e})=>{let t=R(e=>e.message.role===`user`?(e.message.attachments??[]).length:0);return Ic(()=>Array.from({length:t},(t,n)=>(0,M.jsx)(Lh,{index:n,children:(0,M.jsx)(Vf,{getItemState:e=>e.message.attachment({index:n}).getState(),children:t=>e({get attachment(){return t()}})})},n)),[t,e])},ax=e=>{let t=F(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,M.jsx)(ix,{children:e=>{let{attachment:t}=e,r=tx(n,t);return r?(0,M.jsx)(r,{}):null}}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,M.jsx)(ix,{children:r}),t[2]=r,t[3]=i),i};ax.displayName=`MessagePrimitive.Attachments`;function ox(e){return e.attachment}var sx=(e,t)=>{switch(t.type){case`image`:return e?.Image??e?.Attachment;case`document`:return e?.Document??e?.Attachment;case`file`:return e?.File??e?.Attachment;default:return e?.Attachment}},cx=e=>{let t=F(5),{components:n}=e,r=R(fx);if(!r)return null;let i;t[0]!==r||t[1]!==n?(i=sx(n,r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i;if(!a)return null;let o;return t[3]===a?o=t[4]:(o=(0,M.jsx)(a,{}),t[3]=a,t[4]=o),o},lx=Kc(e=>{let t=F(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,M.jsx)(cx,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,M.jsx)(Rh,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components?.Image===t.components?.Image&&e.components?.Document===t.components?.Document&&e.components?.File===t.components?.File&&e.components?.Attachment===t.components?.Attachment);lx.displayName=`ComposerPrimitive.AttachmentByIndex`;var ux=({children:e})=>{let t=R(e=>e.composer.attachments.length);return Ic(()=>Array.from({length:t},(t,n)=>(0,M.jsx)(Rh,{index:n,children:(0,M.jsx)(Vf,{getItemState:e=>e.composer.attachment({index:n}).getState(),children:t=>e({get attachment(){return t()}})})},n)),[t,e])},dx=e=>{let t=F(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,M.jsx)(ux,{children:e=>{let{attachment:t}=e,r=sx(n,t);return r?(0,M.jsx)(r,{}):null}}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,M.jsx)(ux,{children:r}),t[2]=r,t[3]=i),i};dx.displayName=`ComposerPrimitive.Attachments`;function fx(e){return e.attachment}var px=Kc(({children:e})=>{let t=R(e=>e.composer.queue.length);return Ic(()=>Array.from({length:t},(t,n)=>(0,M.jsx)(rg,{index:n,children:(0,M.jsx)(Vf,{getItemState:e=>e.composer.queueItem({index:n}).getState(),children:t=>e({get queueItem(){return t()}})})},n)),[t,e])});px.displayName=`ComposerPrimitive.Queue`;var mx=e=>{let{children:t}=e;return R(hx)?t:null};mx.displayName=`MessagePartPrimitive.InProgress`;function hx(e){return e.part.status.type===`running`}var gx=e=>{let t=F(2),{components:n}=e,r=n.Suggestion,i;return t[0]===r?i=t[1]:(i=(0,M.jsx)(r,{}),t[0]=r,t[1]=i),i},_x=Kc(e=>{let t=F(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,M.jsx)(gx,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,M.jsx)(ng,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components.Suggestion===t.components.Suggestion);_x.displayName=`ThreadPrimitive.SuggestionByIndex`;var vx=({children:e})=>{let t=R(e=>e.suggestions.suggestions.length);return Ic(()=>t===0?null:Array.from({length:t},(t,n)=>(0,M.jsx)(ng,{index:n,children:(0,M.jsx)(Vf,{getItemState:e=>e.suggestions.suggestion({index:n}).getState(),children:t=>e({get suggestion(){return t()}})})},n)),[t,e])},yx=e=>{let t=F(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,M.jsx)(vx,{children:()=>(0,M.jsx)(gx,{components:n})}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,M.jsx)(vx,{children:r}),t[2]=r,t[3]=i),i};yx.displayName=`ThreadPrimitive.Suggestions`;var bx=Kc(yx,(e,t)=>e.children||t.children?e.children===t.children:e.components.Suggestion===t.components.Suggestion),xx=e=>{let t=F(3),n;return t[0]!==e.dictation||t[1]!==e.editing?(n=t=>{if(e.editing===!0&&!t.composer.isEditing||e.editing===!1&&t.composer.isEditing)return!1;let n=t.composer.dictation!=null;return!(e.dictation===!0&&!n||e.dictation===!1&&n)},t[0]=e.dictation,t[1]=e.editing,t[2]=n):n=t[2],R(n)},Sx=e=>{let t=F(3),n,r;return t[0]===e?(n=t[1],r=t[2]):({children:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),xx(r)?n:null};Sx.displayName=`ComposerPrimitive.If`;var Cx=()=>{let e=R(e=>e.thread.messages),t=I([]),n=e.map(e=>e.id),r=t.current;return(r.length!==n.length||r.some((e,t)=>e!==n[t]))&&(t.current=n),t.current},wx=e=>!e.composer.canSend||e.thread.isRunning&&!e.thread.capabilities.queue,Tx=e=>!e.composer.canCancel,Ex=e=>e.thread.isRunning||e.thread.isDisabled||e.message.role!==`assistant`,Dx=e=>!((e.message.role!==`assistant`||e.message.status?.type!==`running`)&&e.message.parts.some(e=>e.type===`text`&&e.text.length>0)),Ox=(e,t)=>e.thread.isDisabled||t&&e.thread.isRunning&&!e.thread.capabilities.queue,kx=()=>{let e=F(5),t=zd(),n=R(wx),r;e[0]===t?r=e[1]:(r=e=>{t.composer.send(e)},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={send:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},Ax=()=>{let e=F(5),t=zd(),n=R(Tx),r;e[0]===t?r=e[1]:(r=()=>{t.composer.cancel()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==i||e[3]!==n?(a={cancel:i,disabled:n},e[2]=i,e[3]=n,e[4]=a):a=e[4],a},jx=()=>{let e=F(5),t=zd(),n=R(Mx),r;e[0]===t?r=e[1]:(r=()=>{t.composer.startDictation()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={startDictation:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function Mx(e){return e.composer.dictation!=null||!e.thread.capabilities.dictation||!e.composer.isEditing}var Nx=()=>{let e=F(5),t=zd(),n=R(Px),r;e[0]===t?r=e[1]:(r=e=>t.composer.addAttachment(e),e[0]=t,e[1]=r);let i=r,a;return e[2]!==i||e[3]!==n?(a={addAttachment:i,disabled:n},e[2]=i,e[3]=n,e[4]=a):a=e[4],a};function Px(e){return!e.composer.isEditing}var Fx=e=>{let t=F(15),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{copiedDuration:r,copyToClipboard:i}=n,a=r===void 0?3e3:r,o=zd(),s=R(Dx),c=R(Ix),l=R(Lx),u=R(Rx),d=I(void 0),f=I(0),p,m;t[2]===o?(p=t[3],m=t[4]):(p=()=>()=>{f.current+=1,d.current!==void 0&&(clearTimeout(d.current),d.current=void 0,o.message.setIsCopied(!1))},m=[o],t[2]=o,t[3]=p,t[4]=m),L(p,m);let h;t[5]!==o||t[6]!==u||t[7]!==a||t[8]!==i||t[9]!==l?(h=()=>{if(!i)return;let e=l?u:o.message.getCopyText();if(!e)return;let t=f.current,n;try{n=i(e)}catch{return}Promise.resolve(n).then(()=>{t===f.current&&(d.current!==void 0&&clearTimeout(d.current),o.message.setIsCopied(!0),d.current=setTimeout(()=>{d.current=void 0,o.message.setIsCopied(!1)},a))},zx)},t[5]=o,t[6]=u,t[7]=a,t[8]=i,t[9]=l,t[10]=h):h=t[10];let g=h,_=s||!i,v;return t[11]!==g||t[12]!==c||t[13]!==_?(v={copy:g,disabled:_,isCopied:c},t[11]=g,t[12]=c,t[13]=_,t[14]=v):v=t[14],v};function Ix(e){return e.message.isCopied}function Lx(e){return e.composer.isEditing}function Rx(e){return e.composer.text}function zx(){}var Bx=()=>{let e=F(5),t=zd(),n=R(Ex),r;e[0]===t?r=e[1]:(r=()=>{t.message.reload()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={reload:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},Vx=e=>{let t=F(10),{prompt:n,send:r,clearComposer:i}=e,a=i===void 0||i,o=zd(),s=r??!1,c;t[0]===s?c=t[1]:(c=e=>Ox(e,s),t[0]=s,t[1]=c);let l=R(c),u;t[2]!==o||t[3]!==a||t[4]!==n||t[5]!==s?(u=()=>{if(s){let{isRunning:e,capabilities:t}=o.thread.getState();if(e&&!t.queue)return;o.thread.append({content:[{type:`text`,text:n}],runConfig:o.composer.getState().runConfig}),a&&!e&&o.composer.setText(``)}else if(a)o.composer.setText(n);else{let e=o.composer.getState().text;o.composer.setText([e,n].filter(Hx).join(` `))}},t[2]=o,t[3]=a,t[4]=n,t[5]=s,t[6]=u):u=t[6];let d=u,f;return t[7]!==l||t[8]!==d?(f={trigger:d,disabled:l},t[7]=l,t[8]=d,t[9]=f):f=t[9],f};function Hx(e){return e.trim()}var Ux=()=>R(Wx);function Wx(e){if(e.message.status?.type!==`incomplete`||e.message.status.reason!==`error`)return;let t=e.message.status.error;return typeof t==`string`?t:typeof t==`object`&&t&&`message`in t&&typeof t.message==`string`?t.message:t??`An error occurred`}var Gx=async(e,t)=>{let{signal:n,onUpdate:r}=t;if(Symbol.asyncIterator in e)for await(let t of e){if(n.aborted)break;r(t)}else{let t=await e;if(n.aborted)return;r(t)}},Kx=e=>{let t=[...e.content,...(e.attachments??[]).flatMap(e=>(e.content??[]).filter(e=>e.type!==`text`))],n=[];for(let e of t)e.type===`file`||e.type===`text`?n.push(e):e.type===`image`&&n.push({type:`file`,data:e.image,mimeType:`image/*`,...e.filename!==void 0&&{filename:e.filename}});return n},qx=e=>{let t={queue:o_,steer:o_},n=new Map,r=new Set,i=!1,a=!1,o=e=>e,s=0,c=0,l=!1,u=()=>{Ql(r,void 0,`Message queue`)},d=e=>{t=e,C.items=e.queue,C.steerItems=e.steer,u()},f=(e,t)=>({id:e,prompt:Cg(t),parts:Kx(t)}),p=e=>{if(t.steer.some(t=>t.id===e))return`steer`;if(t.queue.some(t=>t.id===e))return`queue`},m=()=>{if(i||a)return;let r=t.steer.length>0?`steer`:`queue`,s=t[r][0];if(!s)return;let c=n.get(s.id);n.delete(s.id),d({...t,[r]:t[r].slice(1)}),c&&(i=!0,e.run(o(c),{steer:!1}))},h=t=>{a=!1,s+=Math.max(c,1),c=0,l=!0;try{e.cancel()}finally{l=!1}i=!0,e.run(o(t),{steer:!0})},g=(e,r)=>{a=!1;let i=tm();n.set(i,r),d({...t,[e]:[...t[e],f(i,r)]}),m()},_=e=>{g(`queue`,e)},v=t=>{if(i&&e.cancel){h(t);return}g(`steer`,t)},y=(r,a)=>{let o=p(r);if(!o)throw Error(`Unknown queue item "${r}".`);let s=a.lane??o,c=t[o].find(e=>e.id===r),l=(s===o?t[o]:t[s]).filter(e=>e.id!==r),u=e=>{if(e===r)throw Error(`Queue item "${r}" cannot anchor itself.`);let t=l.findIndex(t=>t.id===e);if(t===-1)throw Error(`Unknown anchor "${e}" in lane "${s}".`);return t},{insertAfter:f,insertBefore:g}=a,_;if(f===void 0&&g===void 0)_=s===o?t[o].findIndex(e=>e.id===r):l.length;else if(f!==void 0&&g!==void 0){let e=f===null?-1:u(f);if((g===null?l.length:u(g))!==e+1)throw Error(`insertAfter "${f}" and insertBefore "${g}" are not adjacent in lane "${s}".`);_=e+1}else _=f===void 0?g===null?l.length:u(g):f===null?0:u(f)+1;if(f===void 0&&g===void 0&&s===`steer`&&o!==`steer`&&i&&e.cancel){let e=n.get(r);n.delete(r),d({queue:t.queue.filter(e=>e.id!==r),steer:t.steer}),h(e);return}let v=[...l.slice(0,_),c,...l.slice(_)],y={...t,[s]:v};s!==o&&(y[o]=t[o].filter(e=>e.id!==r)),d(y),m()},b=(e,r)=>{let i=p(e);if(!i)throw Error(`Unknown queue item "${e}".`);n.set(e,r),d({...t,[i]:t[i].map(t=>t.id===e?f(e,r):t)})},x=e=>{n.delete(e)&&d({queue:t.queue.filter(t=>t.id!==e),steer:t.steer.filter(t=>t.id!==e)})},S=()=>{l||i&&c===0&&(a=!0,c=1)},C={items:t.queue,steerItems:t.steer,enqueue:_,steer:v,move:y,edit:b,remove:x,__internal_setDispatchTransform:e=>{o=e},__internal_notifyCancelled:S};return{adapter:C,notifyBusy:()=>{a=!1,s+=c,c=0,i=!0},notifyIdle:()=>{if(s>0){s--;return}c>0&&c--,i=!1,m()},notifyCancelled:S,clear:()=>{n.clear(),d({queue:o_,steer:o_})},subscribe:e=>(r.add(e),()=>{r.delete(e)})}},Jx=(e,t)=>e.status?.type!==`requires-action`||e.status.reason!==`tool-calls`||e.content.some(e=>e.type===`tool-call`&&e.result===void 0&&e.approval!==void 0&&e.approval.approved===void 0&&e.approval.resolution===void 0)?!1:t===void 0?e.content.every(e=>e.type!==`tool-call`||e.result!==void 0||e.approval!==void 0):e.content.every(e=>e.type!==`tool-call`||e.result!==void 0||e.approval!==void 0||!t.includes(e.toolName)),Yx=class extends Error{name=`AbortError`;detach;constructor(e,t){super(t),this.detach=e}},Xx=class extends v_{capabilities={switchToBranch:!0,switchBranchDuringRun:!0,edit:!0,delete:!1,reload:!0,refetchThread:!1,cancel:!0,unstable_copy:!0,speech:!1,dictation:!1,voice:!1,attachments:!1,feedback:!1,queue:!1};abortController=null;_queue=null;_queueRunInFlight=!1;_activeRun=null;_runGeneration=0;_historyWrites=new Map;_chainHistoryWrite(e,t){let n=(this._historyWrites.get(e)??Promise.resolve()).then(t,t),r=n.then(()=>{},()=>{});return this._historyWrites.set(e,r),r.then(()=>{this._historyWrites.get(e)===r&&this._historyWrites.delete(e)}),n}_persistPausedMessage(e,t){if(t.status?.type!==`requires-action`)return;let n=this._options.adapters.history;if(!n?.update)return;let r=n.update.bind(n),i={parentId:e,message:t,runConfig:this._lastRunConfig};this._chainHistoryWrite(t.id,()=>r(i)).catch(()=>{})}isDisabled=!1;isSendDisabled=!1;_isLoading=!1;get isLoading(){return this._isLoading}_suggestions=[];_suggestionsController=null;get suggestions(){return this._suggestions}get adapters(){return this._options.adapters}constructor(e,t){super(e),this.__internal_setOptions(t)}_options;_lastRunConfig={};_getThreadId;__internal_setGetThreadId(e){this._getThreadId=e}_getInitializePromise;__internal_setGetInitializePromise(e){this._getInitializePromise=e}get extras(){}__internal_setOptions(e){if(this._options===e)return;let t=this._options?.adapters.history;this._options=e;let n=!1,r=e.adapters?.speech!==void 0;this.capabilities.speech!==r&&(this.capabilities.speech=r,n=!0);let i=e.adapters?.dictation!==void 0;this.capabilities.dictation!==i&&(this.capabilities.dictation=i,n=!0);let a=e.adapters?.voice!==void 0;this.capabilities.voice!==a&&(this.capabilities.voice=a,n=!0);let o=e.adapters?.attachments!==void 0;this.capabilities.attachments!==o&&(this.capabilities.attachments=o,n=!0);let s=e.adapters?.feedback!==void 0;this.capabilities.feedback!==s&&(this.capabilities.feedback=s,n=!0);let c=e.adapters?.history?.delete!==void 0;this.capabilities.delete!==c&&(this.capabilities.delete=c,n=!0);let l=e.unstable_enableMessageQueue===!0;l&&!this._queue?(this._queue=qx({run:e=>{this._queueRunInFlight=!0;let t=this._runGeneration;this._runAppend({...e,parentId:this.messages.at(-1)?.id??null}).finally(()=>{this._queueRunInFlight=!1,this._runGeneration===t&&this._queue?.notifyIdle()}).catch(()=>{})}}),this._queue.subscribe(()=>this._notifySubscribers())):!l&&this._queue&&(this._queue=null),this.capabilities.queue!==l&&(this.capabilities.queue=l,n=!0),n&&this._notifySubscribers(),this._loadRequested&&!this._loadPromise&&!t&&e.adapters.history&&this.messages.length===0&&this.__internal_load().catch(e=>{console.error(`[assistant-ui] local thread history load failed:`,e)})}_loadPromise;_loadRequested=!1;__internal_load(){if(this._loadRequested=!0,this._loadPromise)return this._loadPromise;if(!this.adapters.history)return Promise.resolve();let e=this.adapters.history.load();return this._isLoading=!0,this._notifySubscribers(),this._loadPromise=e.then(e=>{if(!e)return;this.repository.import(e),e.messages.length>0&&this.ensureInitialized(),this._notifySubscribers();let t=this.adapters.history?.resume?.bind(this.adapters.history);e.unstable_resume&&t&&this.startRun({parentId:this.repository.headId,sourceId:this.repository.headId,runConfig:this._lastRunConfig},t).catch(()=>{})}).finally(()=>{this._isLoading=!1,this._notifySubscribers()}),this._loadPromise}async append(e){let t=e.parentId===(this.messages.at(-1)?.id??null),n=e.startRun??e.role===`user`;if(this._queue&&n&&t){e.steer??this._queueRunInFlight?this._queue.adapter.steer(e):this._queue.adapter.enqueue(e);return}return this._queue&&!t&&(this._options.unstable_queueClearOnRewind??!0)&&this._queue.clear(),this._runAppend(e)}getQueueItems(){return this._queue?.adapter.items??o_}getSteerQueueItems(){return this._queue?.adapter.steerItems??o_}moveQueueItem(e,t){this._queue?.adapter.move(e,t)}removeQueueItem(e){this._queue?.adapter.remove(e)}_rollbackAppend(e){try{this.repository.deleteMessage(e)}catch{return}this._notifySubscribers()}async _runAppend(e){let t=Gg(this),n=this.enrichAppendMetadata(e);this.ensureInitialized();let r=lm(n,tm(),{type:`complete`,reason:`unknown`});this.repository.addOrUpdateMessage(n.parentId,r),this._notifySubscribers();try{let e=this._getInitializePromise?.();e&&await e}catch(e){if(this._rollbackAppend(r.id),!Kg(this,t))return;let n=new cg;throw n.cause=e,n}if(!Kg(this,t)){this._rollbackAppend(r.id);return}let i=this._options.adapters.history?.append({parentId:n.parentId,message:r,...n.runConfig!==void 0&&{runConfig:n.runConfig}});if(i?.catch(()=>{}),n.startRun??n.role===`user`){let[e,t]=await Promise.allSettled([this.startRun({parentId:r.id,sourceId:n.sourceId,runConfig:n.runConfig??{}}),i]);if(e.status===`rejected`)throw e.reason;if(t.status===`rejected`)throw t.reason}else this.repository.resetHead(r.id),this._notifySubscribers(),await i}async deleteMessage(e){let t=this._options.adapters.history;if(!t?.delete)throw Error(`Runtime does not support deleting messages.`);let n=this.repository.getMessages(),r=n.findIndex(t=>t.id===e);if(r===-1)throw Error(`Message not found.`);let i=n[r],a=[{parentId:n[r-1]?.id??null,message:i}];await t.delete(a),this.repository.deleteMessage(e),this._notifySubscribers()}resumeRun({stream:e,...t}){if(!e)throw Error(`You must pass a stream parameter to resume runs.`);return this.startRun(t,e)}exportExternalState(){throw Error(`Runtime does not support exporting external states.`)}importExternalState(){throw Error(`Runtime does not support importing external states.`)}unstable_notifySessionReset(){throw Error(`Runtime does not support resetting sessions.`)}async startRun({parentId:e,runConfig:t},n){this.ensureInitialized();let r={id:tm(),role:`assistant`,status:{type:`running`},content:[],metadata:{unstable_state:this.state,unstable_annotations:[],unstable_data:[],steps:[],custom:{}},createdAt:new Date};return this._runLoop(e,r,t,n)}async _runLoop(e,t,n,r){this._notifyEventSubscribers(`runStart`,{});let i=t.status?.type===`requires-action`&&this._options.adapters.history?.update!==void 0,a={cancelled:!1};this._activeRun=a,this._runGeneration++;let o=!1;try{this._queue?.notifyBusy(),this._suggestions=[],this._suggestionsController?.abort(),this._suggestionsController=null,this._notifySubscribers();do if(t=await this.performRoundtrip(e,t,n,i,a,r),r=void 0,this._activeRun!==a)break;while(Jx(t,this._options.unstable_humanToolNames))}finally{this._notifyEventSubscribers(`runEnd`,{}),o=this._activeRun===a,o&&(this._activeRun=null),(o||a.cancelled)&&queueMicrotask(()=>this._queue?.notifyIdle())}if(o&&this.adapters.suggestion&&t.status?.type!==`requires-action`){this._suggestionsController=new AbortController;let e=this._suggestionsController.signal,t=this.adapters.suggestion;(async()=>{try{await Gx(t.generate({messages:this.messages,signal:e}),{signal:e,onUpdate:e=>{this._suggestions=e,this._notifySubscribers()}})}catch{}})()}}async performRoundtrip(e,t,n,r,i,a){let o=e?this.repository.getMessages(e):[];this.abortController?.abort();let s=new AbortController;this.abortController=s;let c=t.content,l=t.metadata?.unstable_annotations,u=t.metadata?.unstable_data,d=t.metadata?.steps,f=t.metadata?.custom,p=!0;try{this.repository.getMessage(t.id)}catch{p=!1}let m=()=>{if(!p)return this._activeRun===i;try{return this.repository.getMessage(t.id).message===t}catch{return!1}},h=n=>{if(!m())return;let r=n.metadata?.steps,i=r?[...d??[],...r]:void 0,a=n.metadata?.unstable_annotations,o=n.metadata?.unstable_data,s=a?[...l??[],...a]:void 0,h=o?[...u??[],...o]:void 0;t={...t,...n.content?{content:[...c,...n.content??[]]}:void 0,status:n.status??t.status,...n.metadata?{metadata:{...t.metadata,...n.metadata.unstable_state===void 0?void 0:{unstable_state:n.metadata.unstable_state},...s?{unstable_annotations:s}:void 0,...h?{unstable_data:h}:void 0,...i?{steps:i}:void 0,...n.metadata?.timing?{timing:n.metadata.timing}:void 0,...n.metadata?.custom?{custom:{...f??{},...n.metadata.custom}}:void 0}}:void 0},this.repository.addOrUpdateMessage(e,t),p=!0,this._notifySubscribers()},g=this._options.maxSteps??2;try{if((t.metadata?.steps?.length??0)>=g)return h({status:{type:`incomplete`,reason:`tool-calls`}}),t;h({status:{type:`running`}}),this.repository.resetHead(t.id),this._notifySubscribers(),this._lastRunConfig=n??{};let{unstable_composerMetadata:r,...c}=this.getModelContext();a??=this.adapters.chatModel.run.bind(this.adapters.chatModel);let l=s.signal,u=()=>l.aborted&&(t.status.type===`running`||t.status.type===`requires-action`&&(this._activeRun!==i||Jx(t,this._options.unstable_humanToolNames))),d=this._getThreadId?.(),f=a({messages:o,runConfig:this._lastRunConfig,abortSignal:l,context:c,unstable_assistantMessageId:t.id,unstable_threadId:d,unstable_parentId:e,unstable_getMessage(){return t}});if(Symbol.asyncIterator in f)for await(let e of f){if(l.aborted){u()&&h({status:{type:`incomplete`,reason:`cancelled`}});break}h(e)}else h(await f);u()?h({status:{type:`incomplete`,reason:`cancelled`}}):t.status.type===`running`&&h({status:{type:`complete`,reason:`unknown`}})}catch(e){if(e instanceof Yx)h({status:{type:`incomplete`,reason:`cancelled`}});else if(e instanceof Error&&e.name===`AbortError`)h({status:{type:`incomplete`,reason:`cancelled`}});else throw h({status:{type:`incomplete`,reason:`error`,error:ug(e)}}),e}finally{this.abortController===s&&(this.abortController=null);let n=this._options.adapters.history,i={parentId:e,message:t,runConfig:this._lastRunConfig},a=t.status.type===`complete`||t.status.type===`incomplete`,o=t.status.type===`requires-action`&&!Jx(t,this._options.unstable_humanToolNames);if(m()&&(a||o&&n?.update)){let e=r&&n?.update?n.update.bind(n):n?.append.bind(n);e&&await this._chainHistoryWrite(t.id,()=>e(i))}}return t}detach(){qg(this),this._queue=null;let e=new Yx(!0);this.abortController?.abort(e),this.abortController=null,this._suggestionsController?.abort(),this._suggestionsController=null}cancelRun(){this._queue&&(this._options.unstable_queueClearOnCancel??!0?this._queue.clear():(this._queue.notifyCancelled(),this._activeRun&&(this._activeRun.cancelled=!0)));let e=new Yx(!1);this.abortController?.abort(e),this.abortController=null,this._suggestionsController?.abort(),this._suggestionsController=null}addToolResult({messageId:e,toolCallId:t,result:n,isError:r,artifact:i}){let a=this.repository.getMessage(e),{parentId:o}=a,{message:s}=a;if(s.role!==`assistant`)throw Error(`Tried to add tool result to non-assistant message`);let c=!1,l=!1,u=s.content.map(e=>e.type!==`tool-call`||e.toolCallId!==t?e:(l=!0,e.result===void 0&&(c=!0),{...e,result:n,artifact:i,isError:r}));if(!l)throw Error(`Tried to add tool result to non-existing tool call`);s={...s,content:u},this.repository.addOrUpdateMessage(o,s),this._notifySubscribers(),c&&Jx(s,this._options.unstable_humanToolNames)?this._runLoop(o,s,this._lastRunConfig).catch(()=>{}):c&&this._persistPausedMessage(o,s)}resumeToolCall(e){throw Error(`Local runtime does not support resuming tool calls. For human-in-the-loop tools, list the tool in unstable_humanToolNames and complete the call with addToolResult.`)}respondToToolApproval({approvalId:e,approved:t,optionId:n,reason:r}){let i=this.repository.getMessages().findLast(t=>t.role===`assistant`&&t.content.some(t=>t.type===`tool-call`&&t.approval?.id===e));if(!i)throw Error(`Tried to respond to a non-existing tool approval`);if(this.abortController!==null)throw Error(`Tried to respond to a tool approval while a run is in progress`);if(i.status?.type!==`requires-action`)throw Error(`Tried to respond to a tool approval on a message whose status is not requires-action`);let a=i.content.find(t=>t.type===`tool-call`&&t.approval?.id===e);if(a?.type!==`tool-call`||!a.approval)throw Error(`Tried to respond to a non-existing tool approval`);if(a.approval.resolution!==void 0)throw Error(`Tried to respond to a tool approval that was cancelled or expired`);if(a.approval.approved!==void 0)throw Error(`Tried to respond to an already decided tool approval`);let o=a.approval,s=i.content.map(e=>{if(e!==a)return e;let i={...o,approved:t,...n!=null&&{optionId:n},...r!=null&&{reason:r}};return t?{...e,approval:i}:{...e,approval:i,result:{error:r||`Tool approval denied`},isError:!0}});i={...i,content:s};let{parentId:c}=this.repository.getMessage(i.id);this.repository.addOrUpdateMessage(c,i),this._notifySubscribers(),this.repository.headId===i.id&&Jx(i,this._options.unstable_humanToolNames)?this._runLoop(c,i,this._lastRunConfig).catch(()=>{}):this._persistPausedMessage(c,i)}},Zx=Object.freeze([]),Qx=`__DEFAULT_ID__`,$x=Object.freeze({[Qx]:{id:Qx,remoteId:void 0,externalId:void 0,status:`regular`,title:void 0}}),eS=class extends nu{_mainThread;constructor(e){super(),this._mainThread=e()}get isLoading(){return!1}getMainThreadRuntimeCore(){return this._mainThread}get newThreadId(){}get threadIds(){return Zx}get archivedThreadIds(){return Zx}get mainThreadId(){return Qx}get threadItems(){return $x}getThreadRuntimeCore(){throw Error(`Method not implemented.`)}getLoadThreadsPromise(){return Promise.resolve()}getItemById(e){if(e===this.mainThreadId)return{status:`regular`,id:this.mainThreadId,remoteId:this.mainThreadId,externalId:void 0,title:void 0,isMain:!0};throw Error(`Method not implemented`)}async switchToThread(){throw Error(`Method not implemented.`)}switchToNewThread(){throw Error(`Method not implemented.`)}rename(){throw Error(`Method not implemented.`)}archive(){throw Error(`Method not implemented.`)}detach(){throw Error(`Method not implemented.`)}unarchive(){throw Error(`Method not implemented.`)}delete(){throw Error(`Method not implemented.`)}initialize(e){return Promise.resolve({remoteId:e,externalId:void 0})}generateTitle(){throw Error(`Method not implemented.`)}},tS=class extends Jg{threads;Provider=void 0;_options;constructor(e,t){super(),this._options=e,this.threads=new eS(()=>new Xx(this._contextProvider,this._options)),t&&this.threads.getMainThreadRuntimeCore().import(n_.fromArray(t))}},nS=(e,{initialMessages:t,...n})=>{let{modelContext:r,...i}=Qp()??{},a={...n,adapters:{...i,...n.adapters,chatModel:e}},[o]=Pc(()=>new tS(a,t)),s=I(void 0),c=I(void 0);return s.current=R(e=>e.threadListItem.remoteId),L(()=>{o.threads.getMainThreadRuntimeCore().__internal_setGetThreadId(()=>s.current)},[o]),L(()=>()=>{o.threads.getMainThreadRuntimeCore().detach()},[o]),L(()=>{o.threads.getMainThreadRuntimeCore().__internal_setOptions(a)}),L(()=>{let e=o.threads.getMainThreadRuntimeCore().__internal_load();c.current!==e&&(c.current=e,e.catch(e=>{console.error(`[assistant-ui] local thread history load failed:`,e)}))},[o]),L(()=>{if(r)return o.registerModelContextProvider(r)},[r,o]),Ic(()=>new Ug(o),[o])},rS=(e,{cloud:t,...n}={})=>ov({runtimeHook:function(){return nS(e,n)},adapter:Ay({cloud:t}),allowNesting:!0});function iS(e,t){function n(n){let r=$c(e);if(!n?.optional&&!r)throw Error(`This component must be used within ${t}.`);return r}return n}function aS(e,t){function n(n){let r=e(n);return r?r[t]:null}function r(e){let t=!1,r;typeof e==`function`?r=e:e&&typeof e==`object`&&(t=!!e.optional,r=e.selector);let i=n({optional:t});return i?r?i(r):i():null}return{[t]:r,[`${t}Store`]:n}}var oS=Zc(null),{useThreadViewport:sS,useThreadViewportStore:cS}=aS(iS(oS,`ThreadPrimitive.Viewport`),`useThreadViewport`),lS=e=>{let t=new Map,n=()=>{let n=0;for(let e of t.values())n+=e;e(n)};return{register:()=>{let e=Symbol();return t.set(e,0),{setHeight:r=>{t.get(e)!==r&&(t.set(e,r),n())},unregister:()=>{t.delete(e),n()}}}}},uS=(e={})=>{let t=new Set,n=lS(e=>{a.setState({height:{...a.getState().height,viewport:e}})}),r=lS(e=>{a.setState({height:{...a.getState().height,inset:e}})}),i=(e,t)=>(a.setState({element:{...a.getState().element,[e]:t}}),()=>{a.getState().element[e]===t&&a.setState({element:{...a.getState().element,[e]:null}})}),a=Qf(()=>({isAtBottom:!0,scrollToBottom:({behavior:e=`auto`}={})=>{for(let n of t)n({behavior:e})},onScrollToBottom:e=>(t.add(e),()=>{t.delete(e)}),turnAnchor:e.turnAnchor??`bottom`,topAnchorMessageClamp:{tallerThan:e.topAnchorMessageClamp?.tallerThan??`10em`,visibleHeight:e.topAnchorMessageClamp?.visibleHeight??`6em`},height:{viewport:0,inset:0},element:{viewport:null,anchor:null,target:null},targetConfig:null,topAnchorTurn:null,registerViewport:n.register,registerContentInset:r.register,registerViewportElement:e=>i(`viewport`,e),registerAnchorElement:e=>i(`anchor`,e),registerAnchorTargetElement:(e,t)=>(a.setState({element:{...a.getState().element,target:e},targetConfig:e&&t?t:null}),()=>{a.getState().element.target===e&&a.setState({element:{...a.getState().element,target:null},targetConfig:null})}),setTopAnchorTurn:e=>{a.setState({topAnchorTurn:e})}}));return a},dS=e=>e,fS=e=>{let t=F(11),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={optional:!0},t[0]=n):n=t[0];let r=cS(n),i;t[1]===e?i=t[2]:(i=()=>uS(e),t[1]=e,t[2]=i);let[a]=Pc(i),o,s;t[3]!==r||t[4]!==a?(o=()=>r?.getState().onScrollToBottom(()=>{a.getState().scrollToBottom()}),s=[r,a],t[3]=r,t[4]=a,t[5]=o,t[6]=s):(o=t[5],s=t[6]),L(o,s);let c,l;return t[7]!==r||t[8]!==a?(c=()=>{if(r)return a.subscribe(e=>{r.getState().isAtBottom!==e.isAtBottom&&dS(r).setState({isAtBottom:e.isAtBottom})})},l=[a,r],t[7]=r,t[8]=a,t[9]=c,t[10]=l):(c=t[9],l=t[10]),L(c,l),a},pS=e=>{let t=F(7),{children:n,options:r}=e,i;t[0]===r?i=t[1]:(i=r===void 0?{}:r,t[0]=r,t[1]=i);let a=fS(i),o;t[2]===a?o=t[3]:(o=()=>({useThreadViewport:a}),t[2]=a,t[3]=o);let[s]=Pc(o),c;return t[4]!==n||t[5]!==s?(c=(0,M.jsx)(oS.Provider,{value:s,children:n}),t[4]=n,t[5]=s,t[6]=c):c=t[6],c},mS=()=>{let e=F(3),t=zd(),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{},r=[t],e[0]=t,e[1]=n,e[2]=r),L(n,r),null},hS=Kc(e=>{let t=F(8),{children:n,aui:r,config:i,runtime:a}=e,o=r??null,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,M.jsx)(mS,{}),t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,M.jsx)(pS,{children:n}),t[1]=n,t[2]=c);let l;return t[3]!==i||t[4]!==a||t[5]!==o||t[6]!==c?(l=(0,M.jsxs)(Kf,{runtime:a,aui:o,config:i,children:[s,c]}),t[3]=i,t[4]=a,t[5]=o,t[6]=c,t[7]=l):l=t[7],l}),gS=/:([\w-]{1,64})\[([^\]\n]{1,1024})\](?:\{name=([^}\n]{1,1024})\})?/gu,_S={serialize(e){let t=e.id===e.label?``:`{name=${e.id}}`;return`:${e.type}[${e.label}]${t}`},parse(e){let t=[],n=0;for(let r of e.matchAll(gS)){r.index>n&&t.push({kind:`text`,text:e.slice(n,r.index)});let i=r[2];t.push({kind:`mention`,type:r[1],label:i,id:r[3]??i}),n=r.index+r[0].length}return n<e.length&&t.push({kind:`text`,text:e.slice(n)}),t}},vS=e=>({isDisabled:e.isDisabled,isSendDisabled:e.isSendDisabled,unstable_capabilities:e.unstable_capabilities,suggestions:e.suggestions}),yS=Object.defineProperty,bS=(e,t)=>yS(e,`name`,{value:t,configurable:!0});function xS(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}bS(xS,`setRef`);function SS(...e){return t=>{let n=!1,r=e.map(e=>{let r=xS(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():xS(e[t],null)}}}}bS(SS,`composeRefs`);function CS(...e){return _.useCallback(SS(...e),e)}bS(CS,`useComposedRefs`);var wS=Object.defineProperty,TS=(e,t)=>{let n={};for(var r in e)wS(n,r,{get:e[r],enumerable:!0});return t||wS(n,Symbol.toStringTag,{value:`Module`}),n},ES=Object.defineProperty,DS=(e,t)=>ES(e,`name`,{value:t,configurable:!0});function OS(e){let t=_.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,s=[];LS(r)&&typeof VS==`function`&&(r=VS(r._payload)),_.Children.forEach(r,e=>{if(FS(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;LS(n)&&typeof VS==`function`&&(n=VS(n._payload)),a=MS(t,n),s.push(a?.props?.children)}else s.push(e)}),a?a=_.cloneElement(a,void 0,s):!o&&_.Children.count(r)===1&&_.isValidElement(r)&&(a=r);let c=a?PS(a):void 0,l=CS(n,c);if(!a){if(r||r===0)throw Error(o?BS(e):zS(e));return r}let u=NS(i,a.props??{});return a.type!==_.Fragment&&(u.ref=n?l:c),_.cloneElement(a,u)});return t.displayName=`${e}.Slot`,t}DS(OS,`createSlot`);var kS=OS(`Slot`),AS=Symbol.for(`radix.slottable`);function jS(e){let t=DS(e=>`child`in e?e.children(e.child):e.children,`Slottable`);return t.displayName=`${e}.Slottable`,t.__radixId=AS,t}DS(jS,`createSlottable`);var MS=DS((e,t)=>{if(`child`in e.props){let t=e.props.child;return _.isValidElement(t)?_.cloneElement(t,void 0,e.props.children(t.props.children)):null}return _.isValidElement(t)?t:null},`getSlottableElementFromSlottable`);function NS(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}DS(NS,`mergeProps`);function PS(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}DS(PS,`getElementRef`);function FS(e){return _.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===AS}DS(FS,`isSlottable`);var IS=Symbol.for(`react.lazy`);function LS(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===IS&&`_payload`in e&&RS(e._payload)}DS(LS,`isLazyComponent`);function RS(e){return typeof e==`object`&&!!e&&`then`in e}DS(RS,`isPromiseLike`);var zS=DS(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,`createSlotError`),BS=DS(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,`createSlottableError`),VS=_.use,HS=Object.defineProperty,US=(e,t)=>HS(e,`name`,{value:t,configurable:!0}),WS=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=OS(`Primitive.${t}`),r=_.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,M.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function GS(e,t){e&&Le.flushSync(()=>e.dispatchEvent(t))}US(GS,`dispatchDiscreteCustomEvent`);var KS=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`];function qS(e){let t=Gc((t,n)=>{let r=F(17),i,a,o,s;r[0]===t?(i=r[1],a=r[2],o=r[3],s=r[4]):({render:o,asChild:i,children:a,...s}=t,r[0]=t,r[1]=i,r[2]=a,r[3]=o,r[4]=s);let c=e;if(o&&Xc(o)){let e=a===void 0?o.props.children:a,t=s,i;r[5]!==o||r[6]!==e?(i=Yc(o,void 0,e),r[5]=o,r[6]=e,r[7]=i):i=r[7];let l;return r[8]!==n||r[9]!==t||r[10]!==i?(l=(0,M.jsx)(c,{...t,asChild:!0,ref:n,children:i}),r[8]=n,r[9]=t,r[10]=i,r[11]=l):l=r[11],l}let l=s,u;return r[12]!==i||r[13]!==a||r[14]!==n||r[15]!==l?(u=(0,M.jsx)(c,{...l,asChild:i,ref:n,children:a}),r[12]=i,r[13]=a,r[14]=n,r[15]=l,r[16]=u):u=r[16],u});return t.displayName=typeof e==`string`?e:e.displayName??e.name??`Component`,t}function JS(e){let t=WS[e],n=qS(t);return n.displayName=`Primitive.${e}`,n}var YS=KS.reduce((e,t)=>(e[t]=JS(t),e),{}),XS=Object.defineProperty,ZS=(e,t)=>XS(e,`name`,{value:t,configurable:!0}),QS=!!(typeof window<`u`&&window.document&&window.document.createElement);function $S(e,t,{checkForDefaultPrevented:n=!0}={}){return ZS(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}ZS($S,`composeEventHandlers`);function eC(e){if(!QS)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}ZS(eC,`getOwnerWindow`);function tC(e){if(!QS)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}ZS(tC,`getOwnerDocument`);function nC(e,t=!1){let{activeElement:n}=tC(e);if(!n?.nodeName)return null;if(rC(n)&&n.contentDocument)return nC(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=tC(n).getElementById(e);if(t)return t}}return n}ZS(nC,`getActiveElement`);function rC(e){return e.tagName===`IFRAME`}ZS(rC,`isFrame`);var iC=(e,t,n=[])=>{let r=Gc((e,r)=>{let i=F(6),a={},o={};Object.keys(e).forEach(t=>{n.includes(t)?a[t]=e[t]:o[t]=e[t]});let s=t(a)??void 0,c=YS,l=o.disabled||!s,u=$S(o.onClick,s),d;return i[0]!==r||i[1]!==o||i[2]!==c.button||i[3]!==l||i[4]!==u?(d=(0,M.jsx)(c.button,{type:`button`,...o,ref:r,disabled:l,onClick:u}),i[0]=r,i[1]=o,i[2]=c.button,i[3]=l,i[4]=u,i[5]=d):d=i[5],d});return r.displayName=e,r},aC=Object.defineProperty,oC=(e,t)=>aC(e,`name`,{value:t,configurable:!0});function sC(e){let t=_.useRef(e);return _.useEffect(()=>{t.current=e}),_.useMemo(()=>((...e)=>t.current?.(...e)),[])}oC(sC,`useCallbackRef`);var cC=e=>{let t=F(12),n;return t[0]!==e.assistant||t[1]!==e.copied||t[2]!==e.hasAttachments||t[3]!==e.hasBranches||t[4]!==e.hasContent||t[5]!==e.last||t[6]!==e.lastOrHover||t[7]!==e.speaking||t[8]!==e.submittedFeedback||t[9]!==e.system||t[10]!==e.user?(n=t=>{let{role:n,attachments:r,parts:i,branchCount:a,isLast:o,speech:s,isCopied:c,isHovering:l}=t.message;return!(e.hasBranches===!0&&a<2||e.user&&n!==`user`||e.assistant&&n!==`assistant`||e.system&&n!==`system`||e.lastOrHover===!0&&!l&&!o||e.last!==void 0&&e.last!==o||e.copied===!0&&!c||e.copied===!1&&c||e.speaking===!0&&s==null||e.speaking===!1&&s!=null||e.hasAttachments===!0&&(n!==`user`||!r?.length)||e.hasAttachments===!1&&n===`user`&&r?.length||e.hasContent===!0&&i.length===0||e.hasContent===!1&&i.length>0||e.submittedFeedback!==void 0&&(t.message.metadata.submittedFeedback?.type??null)!==e.submittedFeedback)},t[0]=e.assistant,t[1]=e.copied,t[2]=e.hasAttachments,t[3]=e.hasBranches,t[4]=e.hasContent,t[5]=e.last,t[6]=e.lastOrHover,t[7]=e.speaking,t[8]=e.submittedFeedback,t[9]=e.system,t[10]=e.user,t[11]=n):n=t[11],R(n)},lC=e=>{let t=F(3),n,r;return t[0]===e?(n=t[1],r=t[2]):({children:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),cC(r)?n:null};lC.displayName=`MessagePrimitive.If`;var uC=Zc(null),dC=()=>$c(uC),fC=e=>{let t=F(8),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=new Map,t[0]=r):r=t[0];let i=I(r),a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=[],t[1]=a):a=t[1];let o=I(a),s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=Array.from(i.current.entries());e.sort(pC),o.current=e.map(mC)},t[2]=s):s=t[2];let c=s,l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(e,t)=>{let n=t?.priority??0;return i.current.set(e,n),c(),()=>{i.current.delete(e),c()}},t[3]=l):l=t[3];let u=l,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>o.current,t[4]=d):d=t[4];let f=d,p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p={register:u,getPlugins:f},t[5]=p):p=t[5];let m=p,h;return t[6]===n?h=t[7]:(h=(0,M.jsx)(uC.Provider,{value:m,children:n}),t[6]=n,t[7]=h),h};function pC(e,t){return t[1]-e[1]}function mC(e){let[t]=e;return t}var hC=Zc(null),gC=Zc(null),_C=()=>{let e=$c(hC);if(!e)throw Error(`useTriggerPopoverRootContext must be used within ComposerPrimitive.TriggerPopoverRoot`);return e},vC=()=>$c(hC),yC=()=>{let e=$c(gC);if(!e)throw Error(`useTriggerPopoverAriaPublish must be used within ComposerPrimitive.TriggerPopoverRoot`);return e},bC=()=>{let e=_C();return Bc(e.subscribe,e.getTriggers,e.getTriggers)},xC=new Map,SC=()=>()=>{},CC=()=>xC,wC=()=>{let e=vC();return Bc(e?e.subscribe:SC,e?e.getTriggers:CC,e?e.getTriggers:CC)},TC=()=>null,EC=()=>{let e=vC();return Bc(e?e.subscribeAria:SC,e?e.getActiveAria:TC,e?e.getActiveAria:TC)};function DC(){let e=F(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=new Set,e[0]=t):t=e[0];let n=I(t),r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{for(let e of n.current)e()},e[1]=r):r=e[1];let i=r,a;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=e=>(n.current.add(e),()=>{n.current.delete(e)}),e[2]=a):a=e[2];let o=a,s;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(s={notify:i,subscribe:o},e[3]=s):s=e[3],s}var OC=e=>{let t=F(21),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=new Map,t[0]=r):r=t[0];let i=I(r),a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=new Set,t[1]=a):a=t[1];let o=I(a),{notify:s,subscribe:c}=DC(),l;t[2]===s?l=t[3]:(l=e=>{let{char:t}=e;if(i.current.has(t))return AC;let n=new Map(i.current);n.set(t,e),i.current=n,s();for(let t of o.current)t.added(e);return()=>{let e=new Map(i.current);e.delete(t),i.current=e,s();for(let e of o.current)e.removed(t)}},t[2]=s,t[3]=l);let u=l,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>i.current,t[4]=d):d=t[4];let f=d,p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p=e=>(o.current.add(e),()=>{o.current.delete(e)}),t[5]=p):p=t[5];let m=p,h=I(null),g=I(null),{notify:_,subscribe:v}=DC(),y;t[6]===_?y=t[7]:(y=(e,t)=>{if(t===null){if(g.current!==e)return;h.current=null,g.current=null,_();return}let n=h.current;(g.current!==e||n===null||n.popoverId!==t.popoverId||n.highlightedItemId!==t.highlightedItemId)&&(h.current=t,g.current=e,_())},t[6]=_,t[7]=y);let b=y,x;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>h.current,t[8]=x):x=t[8];let S=x,C;t[9]!==u||t[10]!==c||t[11]!==v?(C={register:u,getTriggers:f,subscribe:c,subscribeLifecycle:m,getActiveAria:S,subscribeAria:v},t[9]=u,t[10]=c,t[11]=v,t[12]=C):C=t[12];let w=C,T;t[13]===b?T=t[14]:(T={setActiveAria:b},t[13]=b,t[14]=T);let E=T,D;t[15]!==E||t[16]!==n?(D=(0,M.jsx)(gC.Provider,{value:E,children:n}),t[15]=E,t[16]=n,t[17]=D):D=t[17];let O;return t[18]!==D||t[19]!==w?(O=(0,M.jsx)(hC.Provider,{value:w,children:D}),t[18]=D,t[19]=w,t[20]=O):O=t[20],O},kC=e=>{let t=F(4),{children:n}=e;if(dC()){let e;return t[0]===n?e=t[1]:(e=(0,M.jsx)(OC,{children:n}),t[0]=n,t[1]=e),e}let r;return t[2]===n?r=t[3]:(r=(0,M.jsx)(fC,{children:(0,M.jsx)(OC,{children:n})}),t[2]=n,t[3]=r),r};kC.displayName=`ComposerPrimitive.TriggerPopoverRoot`;function AC(){}var jC=/\s/u;function MC(e,t,n){let r=e.slice(0,n);for(let e=r.length-1;e>=0;e--){let n=r[e];if(jC.test(n))return null;if(r.startsWith(t,e)){if(e>0&&!jC.test(r[e-1]))continue;return{query:r.slice(e+t.length),offset:e}}}return null}var NC=el(e=>{let t=F(7),{text:n,triggerChar:r}=e,[i,a]=Pc(n.length),o=Math.min(i,n.length),s;t[0]!==o||t[1]!==n||t[2]!==r?(s=MC(n,r,o),t[0]=o,t[1]=n,t[2]=r,t[3]=s):s=t[3];let c=s,l=c?.query??``,u;return t[4]!==l||t[5]!==c?(u={trigger:c,query:l,setCursorPosition:a},t[4]=l,t[5]=c,t[6]=u):u=t[6],u});function PC(e){return`type`in e}var FC=el(e=>{let t=F(25),{navigableList:n,isSearchMode:r,activeCategoryId:i,query:a,popoverId:o,open:s,selectItem:c,selectCategory:l,goBack:u,close:d}=e,[f,p]=Pc(0),m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{p(0)},t[0]=m):m=t[0];let h;t[1]===n?h=t[2]:(h=[n],t[1]=n,t[2]=h),L(m,h);let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{p(0)},t[3]=g):g=t[3];let _;t[4]!==i||t[5]!==r?(_=[r,i],t[4]=i,t[5]=r,t[6]=_):_=t[6],L(g,_);let v;t[7]!==f||t[8]!==n.length?(v=e=>{e<0||e>=n.length||e!==f&&p(e)},t[7]=f,t[8]=n.length,t[9]=v):v=t[9];let y=zc(v),b;t[10]!==i||t[11]!==d||t[12]!==u||t[13]!==f||t[14]!==n||t[15]!==s||t[16]!==a||t[17]!==l||t[18]!==c?(b=e=>{if(!s)return!1;switch(e.key){case`ArrowDown`:return e.preventDefault(),p(e=>{let t=n.length;return t===0?0:e<t-1?e+1:0}),!0;case`ArrowUp`:return e.preventDefault(),p(e=>{let t=n.length;return t===0?0:e>0?e-1:t-1}),!0;case`Enter`:case`Tab`:{if(e.shiftKey)return!1;e.preventDefault();let t=n[f];return t&&(PC(t)?c(t):l(t.id)),!0}case`Escape`:return e.preventDefault(),d(),!0;case`Backspace`:return i&&a===``?(e.preventDefault(),u(),!0):!1;default:return!1}},t[10]=i,t[11]=d,t[12]=u,t[13]=f,t[14]=n,t[15]=s,t[16]=a,t[17]=l,t[18]=c,t[19]=b):b=t[19];let x=zc(b),S=n[f],C=s&&S?`${o}-option-${S.id}`:void 0,w;return t[20]!==x||t[21]!==y||t[22]!==f||t[23]!==C?(w={highlightedIndex:f,highlightedItemId:C,highlightIndex:y,handleKeyDown:x},t[20]=x,t[21]=y,t[22]=f,t[23]=C,t[24]=w):w=t[24],w});function IC(e,t){return e.id.toLowerCase().includes(t)||e.label.toLowerCase().includes(t)||(e.description?.toLowerCase().includes(t)??!1)}var LC=el(e=>{let t=F(38),{adapter:n,query:r,open:i}=e,[a,o]=Pc(null),s,c;t[0]===i?(s=t[1],c=t[2]):(s=()=>{i||o(null)},c=[i],t[0]=i,t[1]=s,t[2]=c),L(s,c);let l;bb0:{if(!i||!n){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[3]=e):e=t[3],l=e;break bb0}let e;t[4]===n?e=t[5]:(e=n.categories(),t[4]=n,t[5]=e),l=e}let u=l,d=i?a:null,f;bb1:{if(!d||!n){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[6]=e):e=t[6],f=e;break bb1}let e;t[7]!==n||t[8]!==d?(e=n.categoryItems(d),t[7]=n,t[8]=d,t[9]=e):e=t[9],f=e}let p=f,m;bb2:{if(!i||!n||d){m=null;break bb2}if(!r&&u.length>0){m=null;break bb2}if(n.search){let e;t[10]!==n||t[11]!==r?(e=n.search(r),t[10]=n,t[11]=r,t[12]=e):e=t[12],m=e;break bb2}let e;if(t[13]!==n||t[14]!==u||t[15]!==r){e=[];let i=r.toLowerCase();for(let t of u)for(let r of n.categoryItems(t.id))IC(r,i)&&e.push(r);t[13]=n,t[14]=u,t[15]=r,t[16]=e}else e=t[16];m=e}let h=m,g=h!==null,_;bb3:{if(g){let e;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[17]=e):e=t[17],_=e;break bb3}if(!r){_=u;break bb3}let e;if(t[18]!==u||t[19]!==r){let n=r.toLowerCase();e=u.filter(e=>e.label.toLowerCase().includes(n)),t[18]=u,t[19]=r,t[20]=e}else e=t[20];_=e}let v=_,y;bb4:{if(g){let e;t[21]===h?e=t[22]:(e=h??[],t[21]=h,t[22]=e),y=e;break bb4}if(!r){y=p;break bb4}let e;if(t[23]!==p||t[24]!==r){let n=r.toLowerCase();e=p.filter(e=>IC(e,n)),t[23]=p,t[24]=r,t[25]=e}else e=t[25];y=e}let b=y,x;bb5:{if(g){let e;t[26]===h?e=t[27]:(e=h??[],t[26]=h,t[27]=e),x=e;break bb5}if(d){x=b;break bb5}x=v}let S=x,C;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{o(e)},t[28]=C):C=t[28];let w=zc(C),T;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>{o(null)},t[29]=T):T=t[29];let E=zc(T),D;return t[30]!==d||t[31]!==v||t[32]!==b||t[33]!==E||t[34]!==g||t[35]!==S||t[36]!==w?(D={categories:v,items:b,isSearchMode:g,activeCategoryId:d,navigableList:S,selectCategory:w,goBack:E},t[30]=d,t[31]=v,t[32]=b,t[33]=E,t[34]=g,t[35]=S,t[36]=w,t[37]=D):D=t[37],D}),RC=el(e=>{let t=F(15),{behavior:n,trigger:r,aui:i,triggerChar:a,setCursorPosition:o,onSelected:s}=e,c=I(null),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=e=>(c.current=e,()=>{c.current===e&&(c.current=null)}),t[0]=l):l=t[0];let u=zc(l),d;t[1]!==i||t[2]!==n||t[3]!==s||t[4]!==r||t[5]!==a?(d=e=>{if(!r||!n)return;if(c.current?.(e)){s();return}let t=i.composer.getState().text,o=t.slice(0,r.offset),l=t.slice(r.offset+a.length+r.query.length),u=()=>{let t=n.formatter.serialize(e);i.composer.setText(o+t+(l.startsWith(` `)?l:` ${l}`))};n.kind===`directive`?(u(),n.onInserted?.(e)):(n.removeOnExecute?i.composer.setText(o+(l.startsWith(` `)?l.slice(1):l)):u(),n.onExecute(e)),s()},t[1]=i,t[2]=n,t[3]=s,t[4]=r,t[5]=a,t[6]=d):d=t[6];let f=zc(d),p;t[7]!==s||t[8]!==o||t[9]!==r?(p=()=>{s(),r&&o(r.offset)},t[7]=s,t[8]=o,t[9]=r,t[10]=p):p=t[10];let m=zc(p),h;return t[11]!==m||t[12]!==u||t[13]!==f?(h={selectItem:f,close:m,registerSelectItemOverride:u},t[11]=m,t[12]=u,t[13]=f,t[14]=h):h=t[14],h}),zC=el(e=>{let t=F(46),{adapter:n,text:r,triggerChar:i,behavior:a,aui:o,popoverId:s,isLoading:c}=e,l;t[0]!==r||t[1]!==i?(l=NC({text:r,triggerChar:i}),t[0]=r,t[1]=i,t[2]=l):l=t[2];let u=Vl(l),d=u.trigger!==null&&n!==void 0&&a!==void 0,f;t[3]!==n||t[4]!==u.query||t[5]!==d?(f=LC({adapter:n,query:u.query,open:d}),t[3]=n,t[4]=u.query,t[5]=d,t[6]=f):f=t[6];let p=Vl(f),m;t[7]===p?m=t[8]:(m=()=>{p.goBack()},t[7]=p,t[8]=m);let h=zc(m),g;t[9]!==o||t[10]!==a||t[11]!==u.setCursorPosition||t[12]!==u.trigger||t[13]!==h||t[14]!==i?(g=RC({behavior:a,trigger:u.trigger,aui:o,triggerChar:i,setCursorPosition:u.setCursorPosition,onSelected:h}),t[9]=o,t[10]=a,t[11]=u.setCursorPosition,t[12]=u.trigger,t[13]=h,t[14]=i,t[15]=g):g=t[15];let _=Vl(g),v;t[16]!==u.query||t[17]!==p.activeCategoryId||t[18]!==p.goBack||t[19]!==p.isSearchMode||t[20]!==p.navigableList||t[21]!==p.selectCategory||t[22]!==d||t[23]!==s||t[24]!==_.close||t[25]!==_.selectItem?(v=FC({navigableList:p.navigableList,isSearchMode:p.isSearchMode,activeCategoryId:p.activeCategoryId,query:u.query,popoverId:s,open:d,selectItem:_.selectItem,selectCategory:p.selectCategory,goBack:p.goBack,close:_.close}),t[16]=u.query,t[17]=p.activeCategoryId,t[18]=p.goBack,t[19]=p.isSearchMode,t[20]=p.navigableList,t[21]=p.selectCategory,t[22]=d,t[23]=s,t[24]=_.close,t[25]=_.selectItem,t[26]=v):v=t[26];let y=Vl(v),b;return t[27]!==u.query||t[28]!==u.setCursorPosition||t[29]!==c||t[30]!==y.handleKeyDown||t[31]!==y.highlightIndex||t[32]!==y.highlightedIndex||t[33]!==y.highlightedItemId||t[34]!==p.activeCategoryId||t[35]!==p.categories||t[36]!==p.goBack||t[37]!==p.isSearchMode||t[38]!==p.items||t[39]!==p.selectCategory||t[40]!==d||t[41]!==s||t[42]!==_.close||t[43]!==_.registerSelectItemOverride||t[44]!==_.selectItem?(b={open:d,query:u.query,activeCategoryId:p.activeCategoryId,categories:p.categories,items:p.items,highlightedIndex:y.highlightedIndex,isSearchMode:p.isSearchMode,isLoading:c,popoverId:s,highlightedItemId:y.highlightedItemId,selectCategory:p.selectCategory,goBack:p.goBack,selectItem:_.selectItem,close:_.close,highlightIndex:y.highlightIndex,handleKeyDown:y.handleKeyDown,setCursorPosition:u.setCursorPosition,registerSelectItemOverride:_.registerSelectItemOverride},t[27]=u.query,t[28]=u.setCursorPosition,t[29]=c,t[30]=y.handleKeyDown,t[31]=y.highlightIndex,t[32]=y.highlightedIndex,t[33]=y.highlightedItemId,t[34]=p.activeCategoryId,t[35]=p.categories,t[36]=p.goBack,t[37]=p.isSearchMode,t[38]=p.items,t[39]=p.selectCategory,t[40]=d,t[41]=s,t[42]=_.close,t[43]=_.registerSelectItemOverride,t[44]=_.selectItem,t[45]=b):b=t[45],b}),BC=Zc(null),VC=()=>{let e=$c(BC);if(!e)throw Error(`useTriggerPopoverScopeContext must be used within ComposerPrimitive.TriggerPopover`);return e},HC=()=>$c(BC),UC=Zc(null),WC=()=>{let e=$c(UC);if(!e)throw Error(`TriggerPopover.Directive / TriggerPopover.Action must be rendered inside ComposerPrimitive.TriggerPopover`);return e},GC=Gc((e,t)=>{let n=F(61),r,i,a,o,s,c;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[6]):({char:a,adapter:r,isLoading:c,"aria-label":i,children:o,...s}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s,n[6]=c);let l=c!==void 0&&c,u=zd(),d=R(KC),f=Uc(),p=I(null),[m,h]=Pc(null),g=I(0),_;n[7]===a?_=n[8]:(_=e=>(g.current+=1,p.current=e,h(e),()=>{g.current=Math.max(0,g.current-1),p.current===e&&(p.current=null,h(null))}),n[7]=a,n[8]=_);let v=_,y;n[9]===v?y=n[10]:(y={register:v},n[9]=v,n[10]=y);let b=y,x=m??void 0,S;n[11]!==r||n[12]!==u||n[13]!==a||n[14]!==l||n[15]!==f||n[16]!==x||n[17]!==d?(S=zC({adapter:r,text:d,triggerChar:a,behavior:x,aui:u,popoverId:f,isLoading:l}),n[11]=r,n[12]=u,n[13]=a,n[14]=l,n[15]=f,n[16]=x,n[17]=d,n[18]=S):S=n[18];let C=Vl(S),w;n[19]===C?w=n[20]:(w=()=>C,n[19]=C,n[20]=w);let T=zc(w),E=_C(),D;n[21]!==m||n[22]!==a||n[23]!==T||n[24]!==E?(D=()=>E.register({char:a,...m?{behavior:m}:{},resource:T()}),n[21]=m,n[22]=a,n[23]=T,n[24]=E,n[25]=D):D=n[25];let O;n[26]!==m||n[27]!==a||n[28]!==E?(O=[E,a,m],n[26]=m,n[27]=a,n[28]=E,n[29]=O):O=n[29],L(D,O);let ee=dC(),te;n[30]!==T||n[31]!==ee?(te=()=>{if(ee)return ee.register(T())},n[30]=T,n[31]=ee,n[32]=te):te=n[32];let ne;n[33]===ee?ne=n[34]:(ne=[ee],n[33]=ee,n[34]=ne),L(te,ne);let k=m!==null&&C.open,re=yC(),ie,ae;n[35]!==re||n[36]!==a||n[37]!==k?(ie=()=>{if(k)return()=>{re.setActiveAria(a,null)}},ae=[re,a,k],n[35]=re,n[36]=a,n[37]=k,n[38]=ie,n[39]=ae):(ie=n[38],ae=n[39]),L(ie,ae);let A,j;n[40]!==re||n[41]!==a||n[42]!==k||n[43]!==f||n[44]!==C.highlightedItemId?(A=()=>{k&&re.setActiveAria(a,{popoverId:f,highlightedItemId:C.highlightedItemId})},j=[re,a,f,k,C.highlightedItemId],n[40]=re,n[41]=a,n[42]=k,n[43]=f,n[44]=C.highlightedItemId,n[45]=A,n[46]=j):(A=n[45],j=n[46]),L(A,j);let oe;n[47]!==i||n[48]!==o||n[49]!==t||n[50]!==k||n[51]!==f||n[52]!==s||n[53]!==C.highlightedItemId?(oe=k?(0,M.jsx)(YS.div,{role:`listbox`,id:f,"aria-label":i??`Suggestions`,"aria-activedescendant":C.highlightedItemId,"data-state":`open`,...s,ref:t,children:o}):o,n[47]=i,n[48]=o,n[49]=t,n[50]=k,n[51]=f,n[52]=s,n[53]=C.highlightedItemId,n[54]=oe):oe=n[54];let se;n[55]!==C||n[56]!==oe?(se=(0,M.jsx)(BC.Provider,{value:C,children:oe}),n[55]=C,n[56]=oe,n[57]=se):se=n[57];let ce;return n[58]!==b||n[59]!==se?(ce=(0,M.jsx)(UC.Provider,{value:b,children:se}),n[58]=b,n[59]=se,n[60]=ce):ce=n[60],ce});GC.displayName=`ComposerPrimitive.TriggerPopover`;function KC(e){return e.composer.text}var qC=()=>{let e=F(2),{disabled:t,send:n}=kx(),r;return e[0]===n?r=e[1]:(r=()=>n(),e[0]=n,e[1]=r),t?null:r},JC=iC(`ComposerPrimitive.Send`,qC),YC=Zc(null),XC=()=>$c(YC),ZC=`[contenteditable]:not([contenteditable='false'])`,QC=`textarea:not(:disabled), ${ZC}`,$C=[`a`,`audio[controls]`,`button`,`details`,`embed`,`iframe`,`input`,`label`,`select`,`summary`,`textarea`,`video[controls]`,ZC,`[tabindex]`].join(`, `),ew=Gc((e,t)=>{let n=F(24),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({onSubmit:a,onMouseDown:i,compact:r,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=qC(),[c,l]=Pc(!1),u;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(u={setMultiline:l},n[5]=u):u=n[5];let d=u,f;n[6]===r?f=n[7]:(f=e=>r?e.composer.attachments.length===0&&e.composer.quote==null&&e.composer.queue.length===0&&e.composer.dictation==null&&!e.composer.text.includes(`
|
|
20
|
-
`):!1,n[6]=r,n[7]=f);let p=R(f)&&!c,m;n[8]===s?m=n[9]:(m=e=>{e.preventDefault(),s&&s()},n[8]=s,n[9]=m);let h=m,g=tw,_=r?d:null,v=p?``:void 0,y;n[10]!==h||n[11]!==a?(y=$S(a,h),n[10]=h,n[11]=a,n[12]=y):y=n[12];let b;n[13]===i?b=n[14]:(b=$S(i,g),n[13]=i,n[14]=b);let x;n[15]!==t||n[16]!==o||n[17]!==v||n[18]!==y||n[19]!==b?(x=(0,M.jsx)(YS.form,{...o,"data-compact":v,ref:t,onSubmit:y,onMouseDown:b}),n[15]=t,n[16]=o,n[17]=v,n[18]=y,n[19]=b,n[20]=x):x=n[20];let S;return n[21]!==_||n[22]!==x?(S=(0,M.jsx)(YC.Provider,{value:_,children:x}),n[21]=_,n[22]=x,n[23]=S):S=n[23],S});ew.displayName=`ComposerPrimitive.Root`;function tw(e){if(e.button!==0)return;let t=e.target;if(!(t instanceof Element)||!e.currentTarget.contains(t))return;let n=t.closest($C);if(n&&e.currentTarget.contains(n))return;let r=e.currentTarget.querySelector(QC);r&&(e.preventDefault(),r.focus())}var nw=e=>{let t=F(4),n=sC(e),r=sS(rw),i,a;t[0]!==n||t[1]!==r?(i=()=>r(n),a=[r,n],t[0]=n,t[1]=r,t[2]=i,t[3]=a):(i=t[2],a=t[3]),L(i,a)};function rw(e){return e.onScrollToBottom}var iw=()=>!1,aw=()=>{},ow=e=>{let t=F(4),n;t[0]===e?n=t[1]:(n=t=>{if(typeof window>`u`||e===null||!window.matchMedia)return aw;let n=window.matchMedia(e);return n.addEventListener(`change`,t),()=>n.removeEventListener(`change`,t)},t[0]=e,t[1]=n);let r=n,i;return t[2]===e?i=t[3]:(i=()=>typeof window>`u`||e===null||!window.matchMedia?!1:window.matchMedia(e).matches,t[2]=e,t[3]=i),Bc(r,i,iw)};function sw(){return R(cw)}function cw(e){return e.composer.isEditing?e.composer.text:``}function lw(e){return!!R(uw)||!!e}function uw(e){return e.thread.isDisabled||e.composer.dictation?.inputDisabled}function dw(){let e=F(4),t=EC();if(!t){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={},e[0]=t):t=e[0],t}let n;return e[1]!==t.highlightedItemId||e[2]!==t.popoverId?(n={"aria-controls":t.popoverId,"aria-expanded":!0,"aria-haspopup":`listbox`,"aria-activedescendant":t.highlightedItemId},e[1]=t.highlightedItemId,e[2]=t.popoverId,e[3]=n):n=e[3],n}function fw(){return fw=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},fw.apply(null,arguments)}function pw(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var mw=_.useLayoutEffect,hw=function(e){var t=_.useRef(e);return mw(function(){t.current=e}),t},gw=function(e,t){if(typeof e==`function`){e(t);return}e.current=t},_w=function(e,t){var n=_.useRef();return _.useCallback(function(r){e.current=r,n.current&&gw(n.current,null),n.current=t,t&&gw(t,r)},[t])},vw={"min-height":`0`,"max-height":`none`,height:`0`,visibility:`hidden`,overflow:`hidden`,position:`absolute`,"z-index":`-1000`,top:`0`,right:`0`,display:`block`},yw=function(e){Object.keys(vw).forEach(function(t){e.style.setProperty(t,vw[t],`important`)})},bw=null,xw=function(e,t){var n=e.scrollHeight;return t.sizingStyle.boxSizing===`border-box`?n+t.borderSize:n-t.paddingSize};function Sw(e,t,n,r){n===void 0&&(n=1),r===void 0&&(r=1/0),bw||(bw=document.createElement(`textarea`),bw.setAttribute(`tabindex`,`-1`),bw.setAttribute(`aria-hidden`,`true`),yw(bw)),bw.parentNode===null&&document.body.appendChild(bw);var i=e.paddingSize,a=e.borderSize,o=e.sizingStyle,s=o.boxSizing;Object.keys(o).forEach(function(e){var t=e;bw.style[t]=o[t]}),yw(bw),bw.value=t;var c=xw(bw,e);bw.value=t,c=xw(bw,e),bw.value=`x`;var l=bw.scrollHeight-i,u=l*n;s===`border-box`&&(u=u+i+a),c=Math.max(u,c);var d=l*r;return s===`border-box`&&(d=d+i+a),c=Math.min(d,c),[c,l]}var Cw=function(){},ww=function(e,t){return e.reduce(function(e,n){return e[n]=t[n],e},{})},Tw=[`borderBottomWidth`,`borderLeftWidth`,`borderRightWidth`,`borderTopWidth`,`boxSizing`,`fontFamily`,`fontSize`,`fontStyle`,`fontWeight`,`letterSpacing`,`lineHeight`,`paddingBottom`,`paddingLeft`,`paddingRight`,`paddingTop`,`tabSize`,`textIndent`,`textRendering`,`textTransform`,`width`,`wordBreak`,`wordSpacing`,`scrollbarGutter`],Ew=!!document.documentElement.currentStyle,Dw=function(e){var t=window.getComputedStyle(e);if(t===null)return null;var n=ww(Tw,t),r=n.boxSizing;return r===``?null:(Ew&&r===`border-box`&&(n.width=parseFloat(n.width)+parseFloat(n.borderRightWidth)+parseFloat(n.borderLeftWidth)+parseFloat(n.paddingRight)+parseFloat(n.paddingLeft)+`px`),{sizingStyle:n,paddingSize:parseFloat(n.paddingBottom)+parseFloat(n.paddingTop),borderSize:parseFloat(n.borderBottomWidth)+parseFloat(n.borderTopWidth)})};function Ow(e,t,n){var r=hw(n);_.useLayoutEffect(function(){var n=function(e){return r.current(e)};if(e)return e.addEventListener(t,n),function(){return e.removeEventListener(t,n)}},[])}var kw=function(e,t){Ow(document.body,`reset`,function(n){e.current.form===n.target&&t(n)})},Aw=function(e){Ow(window,`resize`,e)},jw=function(e){Ow(document.fonts,`loadingdone`,e)},Mw=[`cacheMeasurements`,`maxRows`,`minRows`,`onChange`,`onHeightChange`],Nw=_.forwardRef(function(e,t){var n=e.cacheMeasurements,r=e.maxRows,i=e.minRows,a=e.onChange,o=a===void 0?Cw:a,s=e.onHeightChange,c=s===void 0?Cw:s,l=pw(e,Mw),u=l.value!==void 0,d=_.useRef(null),f=_w(d,t),p=_.useRef(0),m=_.useRef(),h=function(){var e=d.current,t=n&&m.current?m.current:Dw(e);if(t){m.current=t;var a=Sw(t,e.value||e.placeholder||`x`,i,r),o=a[0],s=a[1];p.current!==o&&(p.current=o,e.style.setProperty(`height`,o+`px`,`important`),c(o,{rowHeight:s}))}};return _.useLayoutEffect(h),kw(d,function(){if(!u){var e=d.current.value;requestAnimationFrame(function(){var t=d.current;t&&e!==t.value&&h()})}}),Aw(h),jw(h),_.createElement(`textarea`,fw({},l,{onChange:function(e){u||h(),o(e)},ref:f}))}),Pw=Object.defineProperty,Fw=(e,t)=>Pw(e,`name`,{value:t,configurable:!0});function Iw(e,t=globalThis?.document){let n=sC(e);_.useEffect(()=>{let e=Fw(e=>{e.key===`Escape`&&n(e)},`handleKeyDown`);return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}Fw(Iw,`useEscapeKeydown`);var Lw=`(pointer: coarse) and (not (any-pointer: fine))`,Rw=Gc(({autoFocus:e=!1,asChild:t,render:n,disabled:r,onChange:i,onKeyDown:a,onPaste:o,onSelect:s,submitOnEnter:c,submitMode:l,cancelOnEscape:u=!0,unstable_focusOnRunStart:d=!0,unstable_focusOnScrollToBottom:f=!0,unstable_focusOnThreadSwitched:p=!0,unstable_insertNewlineOnTouchEnter:m=!1,addAttachmentOnPaste:h=!0,onHeightChange:g,..._},v)=>{let y=zd(),b=dC(),x=XC(),S=l??(c===!1?`none`:`enter`),C=ow(m?Lw:null),w=m&&C&&S===`enter`?`none`:S,T=sw(),E=lw(r),D=I(null),O=CS(v,D),ee=I(!1);Iw(e=>{if(!D.current?.contains(e.target)||e.isComposing)return;if(b){for(let t of b.getPlugins())if(t.handleKeyDown(e))return}if(!u)return;let t=y.composer;t.getState().canCancel&&(t.cancel(),e.preventDefault())});let te=e=>{if(!E&&!e.nativeEvent.isComposing){if(b){for(let t of b.getPlugins())if(t.handleKeyDown(e))return}if(e.key===`Enter`){let t=y.thread.getState(),n=t.capabilities.queue;if(e.shiftKey&&(e.ctrlKey||e.metaKey)&&n&&S!==`none`&&y.composer.getState().canSend){e.preventDefault(),y.composer.send({steer:!0});return}if(e.shiftKey||t.isRunning&&!n)return;let r=!1;w===`ctrlEnter`?r=e.ctrlKey||e.metaKey:w===`enter`&&(r=!0),r&&(e.preventDefault(),D.current?.closest(`form`)?.requestSubmit())}}},ne=async e=>{if(!h)return;let t=y.thread.getState().capabilities,n=Array.from(e.clipboardData?.files||[]);t.attachments&&n.length>0&&(e.preventDefault(),await Promise.all(n.map(async e=>{try{await y.composer.addAttachment(e)}catch{}})))},k=(e,t)=>{if(g?.(e,t),!x)return;let n=D.current;if(!n||n.value===``)return;let r=getComputedStyle(n),i=r.boxSizing===`border-box`?e-parseFloat(r.paddingTop)-parseFloat(r.paddingBottom)-parseFloat(r.borderTopWidth)-parseFloat(r.borderBottomWidth):e;Math.round(i/t.rowHeight)>1&&x.setMultiline(!0)},re=e&&!E,ie=Lc(()=>{let e=D.current;!e||!re||(e.focus({preventScroll:!0}),e.setSelectionRange(e.value.length,e.value.length))},[re]);L(()=>ie(),[ie]),nw(()=>{y.composer.getState().type===`thread`&&f&&ie()}),L(()=>{if(!(y.composer.getState().type!==`thread`||!d))return y.on(`thread.runStart`,ie)},[d,ie,y]),L(()=>{if(!(y.composer.getState().type!==`thread`||!p))return y.on(`threads.selectionChanged`,ie)},[p,ie,y]),L(()=>{T===``&&x?.setMultiline(!1)},[T,x]);let ae=dw(),A={name:`input`,value:T,..._,...ae,ref:O,disabled:E,onChange:$S(i,e=>{if(!y.composer.getState().isEditing)return;let t=e.nativeEvent.isComposing===!0;ee.current&&!t&&(ee.current=!1);let n=t||ee.current;if(pl(()=>{y.composer.setText(e.target.value)}),n)return;let r=e.target.selectionStart??e.target.value.length;if(b)for(let e of b.getPlugins())e.setCursorPosition(r)}),onKeyDown:$S(a,te),onCompositionStart:$S(_.onCompositionStart,()=>{ee.current=!0}),onCompositionEnd:$S(_.onCompositionEnd,e=>{if(ee.current=!1,!y.composer.getState().isEditing)return;let t=e.target;pl(()=>{y.composer.setText(t.value)});let n=t.selectionStart??t.value.length;if(b)for(let e of b.getPlugins())e.setCursorPosition(n)}),onSelect:$S(s,e=>{if(ee.current)return;let t=e.target,n=t.selectionStart??t.value.length;if(b)for(let e of b.getPlugins())e.setCursorPosition(n)}),onPaste:$S(o,ne),...x?{onHeightChange:k}:g===void 0?{}:{onHeightChange:g}};if(n&&Xc(n)){let e=_.children===void 0?n.props.children:_.children;return(0,M.jsx)(kS,{...A,children:Yc(n,void 0,e)})}let j=t?kS:Nw;return(0,M.jsx)(j,{...A})});Rw.displayName=`ComposerPrimitive.Input`;var zw=iC(`ComposerPrimitive.Cancel`,()=>{let{disabled:e,cancel:t}=Ax();return e?null:t}),Bw=iC(`ComposerPrimitive.AddAttachment`,e=>{let t=F(6),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{multiple:r}=n,i=r===void 0||r,{disabled:a,addAttachment:o}=Nx(),s=zd(),c;return t[2]!==o||t[3]!==s.composer||t[4]!==i?(c=()=>{let e=document.createElement(`input`);e.type=`file`,e.multiple=i,e.hidden=!0;let t=s.composer.getState().attachmentAccept;t!==`*`&&(e.accept=t),document.body.appendChild(e),e.onchange=async t=>{let n=t.target.files;if(!n)return;let r=Array.from(n,async e=>{try{await o(e)}catch{}});document.body.removeChild(e),await Promise.all(r)},e.oncancel=()=>{(!e.files||e.files.length===0)&&document.body.removeChild(e)},e.click()},t[2]=o,t[3]=s.composer,t[4]=i,t[5]=c):c=t[5],a?null:c},[`multiple`]),Vw=Gc((e,t)=>{let n=F(32),{disabled:r,asChild:i,render:a,children:o,...s}=e,c=i!==void 0&&i,[l,u]=Pc(!1),d=zd(),f;n[0]!==d||n[1]!==r?(f=e=>{if(!r&&e.dataTransfer.types.includes(`Files`)){if(e.preventDefault(),!d.thread.getState().capabilities.attachments){e.dataTransfer.dropEffect=`none`;return}u(!0)}},n[0]=d,n[1]=r,n[2]=f):f=n[2];let p=f,m;n[3]!==d||n[4]!==r||n[5]!==l?(m=e=>{if(!r&&e.dataTransfer.types.includes(`Files`)){if(e.preventDefault(),!d.thread.getState().capabilities.attachments){e.dataTransfer.dropEffect=`none`;return}l||u(!0)}},n[3]=d,n[4]=r,n[5]=l,n[6]=m):m=n[6];let h=m,g;n[7]===r?g=n[8]:(g=e=>{if(r)return;e.preventDefault();let t=e.relatedTarget;t&&e.currentTarget.contains(t)||u(!1)},n[7]=r,n[8]=g);let _=g,v;n[9]!==d||n[10]!==r?(v=async e=>{if(r||(u(!1),!e.dataTransfer.types.includes(`Files`)))return;e.preventDefault();let t=Array.from(e.dataTransfer.files);!d.thread.getState().capabilities.attachments||t.length===0||await Promise.all(t.map(async e=>{try{await d.composer.addAttachment(e)}catch{}}))},n[9]=d,n[10]=r,n[11]=v):v=n[11];let y=v,b;n[12]===l?b=n[13]:(b=l?{"data-dragging":`true`}:null,n[12]=l,n[13]=b);let x=$S(s.onDragEnterCapture,p),S=$S(s.onDragOverCapture,h),C=$S(s.onDragLeaveCapture,_),w=$S(s.onDropCapture,y),T;n[14]!==t||n[15]!==s||n[16]!==w||n[17]!==b||n[18]!==x||n[19]!==S||n[20]!==C?(T={...b,...s,onDragEnterCapture:x,onDragOverCapture:S,onDragLeaveCapture:C,onDropCapture:w,ref:t},n[14]=t,n[15]=s,n[16]=w,n[17]=b,n[18]=x,n[19]=S,n[20]=C,n[21]=T):T=n[21];let E=T;if(a&&Xc(a)){let e=o===void 0?a.props.children:o,t;n[22]!==a||n[23]!==e?(t=Yc(a,void 0,e),n[22]=a,n[23]=e,n[24]=t):t=n[24];let r;return n[25]!==E||n[26]!==t?(r=(0,M.jsx)(kS,{...E,children:t}),n[25]=E,n[26]=t,n[27]=r):r=n[27],r}let D=c?kS:`div`,O;return n[28]!==D||n[29]!==o||n[30]!==E?(O=(0,M.jsx)(D,{...E,children:o}),n[28]=D,n[29]=o,n[30]=E,n[31]=O):O=n[31],O});Vw.displayName=`ComposerPrimitive.AttachmentDropzone`;var Hw=iC(`ComposerPrimitive.Dictate`,()=>{let{disabled:e,startDictation:t}=jx();return e?null:t}),Uw=iC(`ComposerPrimitive.StopDictation`,()=>{let e=F(2),t=zd(),n=R(Ww),r;return e[0]===t.composer?r=e[1]:(r=()=>{t.composer.stopDictation()},e[0]=t.composer,e[1]=r),n?r:null});function Ww(e){return e.composer.dictation!=null}var Gw=Gc((e,t)=>{let n=F(7),r,i;n[0]===e?(r=n[1],i=n[2]):({children:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=R(Kw);if(!a)return null;let o=r??a,s;return n[3]!==t||n[4]!==i||n[5]!==o?(s=(0,M.jsx)(YS.span,{...i,ref:t,children:o}),n[3]=t,n[4]=i,n[5]=o,n[6]=s):s=n[6],s});Gw.displayName=`ComposerPrimitive.DictationTranscript`;function Kw(e){return e.composer.dictation?.transcript}var qw=Gc((e,t)=>{let n=F(3);if(!R(Xw))return null;let r;return n[0]!==t||n[1]!==e?(r=(0,M.jsx)(YS.div,{...e,ref:t}),n[0]=t,n[1]=e,n[2]=r):r=n[2],r});qw.displayName=`ComposerPrimitive.Quote`;var Jw=Gc((e,t)=>{let n=F(7),r,i;n[0]===e?(r=n[1],i=n[2]):({children:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=R(Zw);if(!a)return null;let o=r??a,s;return n[3]!==t||n[4]!==i||n[5]!==o?(s=(0,M.jsx)(YS.span,{...i,ref:t,children:o}),n[3]=t,n[4]=i,n[5]=o,n[6]=s):s=n[6],s});Jw.displayName=`ComposerPrimitive.QuoteText`;var Yw=Gc((e,t)=>{let n=F(12),r,i;n[0]===e?(r=n[1],i=n[2]):({onClick:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=zd(),o;n[3]===a?o=n[4]:(o=()=>{a.composer.setQuote(void 0)},n[3]=a,n[4]=o);let s=o,c;n[5]!==s||n[6]!==r?(c=$S(r,s),n[5]=s,n[6]=r,n[7]=c):c=n[7];let l;return n[8]!==t||n[9]!==i||n[10]!==c?(l=(0,M.jsx)(YS.button,{type:`button`,...i,ref:t,onClick:c}),n[8]=t,n[9]=i,n[10]=c,n[11]=l):l=n[11],l});Yw.displayName=`ComposerPrimitive.QuoteDismiss`;function Xw(e){return e.composer.quote}function Zw(e){return e.composer.quote?.text}var Qw=Gc((e,t)=>{let n=F(12),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({children:i,"aria-label":r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let{categories:o,activeCategoryId:s,isSearchMode:c,open:l}=VC();if(!l||s||c)return null;let u=r??`Categories`,d;n[4]!==o||n[5]!==i?(d=i(o),n[4]=o,n[5]=i,n[6]=d):d=n[6];let f;return n[7]!==t||n[8]!==a||n[9]!==u||n[10]!==d?(f=(0,M.jsx)(YS.div,{role:`group`,"aria-label":u,...a,ref:t,children:d}),n[7]=t,n[8]=a,n[9]=u,n[10]=d,n[11]=f):f=n[11],f});Qw.displayName=`ComposerPrimitive.TriggerPopoverCategories`;var $w=Gc((e,t)=>{let n=F(30),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({categoryId:r,onClick:i,onMouseMove:a,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let{selectCategory:s,highlightIndex:c,categories:l,highlightedIndex:u,activeCategoryId:d,isSearchMode:f,popoverId:p}=VC(),m;n[5]!==r||n[6]!==s?(m=()=>{s(r)},n[5]=r,n[6]=s,n[7]=m):m=n[7];let h=m,g;if(n[8]!==l||n[9]!==r){let e;n[11]===r?e=n[12]:(e=e=>e.id===r,n[11]=r,n[12]=e),g=l.findIndex(e),n[8]=l,n[9]=r,n[10]=g}else g=n[10];let _=g,v=!d&&!f&&_===u,y;n[13]!==_||n[14]!==c?(y=()=>{c(_)},n[13]=_,n[14]=c,n[15]=y):y=n[15];let b=y,x=`${p}-option-${r}`,S=v?``:void 0,C;n[16]!==h||n[17]!==i?(C=$S(i,h),n[16]=h,n[17]=i,n[18]=C):C=n[18];let w;n[19]!==b||n[20]!==a?(w=$S(a,b),n[19]=b,n[20]=a,n[21]=w):w=n[21];let T;return n[22]!==t||n[23]!==v||n[24]!==o||n[25]!==x||n[26]!==S||n[27]!==C||n[28]!==w?(T=(0,M.jsx)(YS.button,{type:`button`,role:`option`,id:x,"aria-selected":v,"data-highlighted":S,...o,ref:t,onClick:C,onMouseMove:w}),n[22]=t,n[23]=v,n[24]=o,n[25]=x,n[26]=S,n[27]=C,n[28]=w,n[29]=T):T=n[29],T});$w.displayName=`ComposerPrimitive.TriggerPopoverCategoryItem`;var eT=Gc((e,t)=>{let n=F(12),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({children:i,"aria-label":r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let{items:o,activeCategoryId:s,isSearchMode:c,open:l}=VC();if(!l||!s&&!c)return null;let u=r??`Items`,d;n[4]!==i||n[5]!==o?(d=i(o),n[4]=i,n[5]=o,n[6]=d):d=n[6];let f;return n[7]!==t||n[8]!==a||n[9]!==u||n[10]!==d?(f=(0,M.jsx)(YS.div,{role:`group`,"aria-label":u,...a,ref:t,children:d}),n[7]=t,n[8]=a,n[9]=u,n[10]=d,n[11]=f):f=n[11],f});eT.displayName=`ComposerPrimitive.TriggerPopoverItems`;var tT=Gc((e,t)=>{let n=F(30),r,i,a,o,s;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5]):({item:i,index:r,onClick:a,onMouseMove:o,...s}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s);let{selectItem:c,highlightIndex:l,items:u,highlightedIndex:d,activeCategoryId:f,isSearchMode:p,popoverId:m}=VC(),h;n[6]!==i||n[7]!==c?(h=()=>{c(i)},n[6]=i,n[7]=c,n[8]=h):h=n[8];let g=h,_;n[9]!==r||n[10]!==i.id||n[11]!==u?(_=r??u.findIndex(e=>e.id===i.id),n[9]=r,n[10]=i.id,n[11]=u,n[12]=_):_=n[12];let v=_,y=(p||f!==null)&&v===d,b;n[13]!==l||n[14]!==v?(b=()=>{l(v)},n[13]=l,n[14]=v,n[15]=b):b=n[15];let x=b,S=`${m}-option-${i.id}`,C=y?``:void 0,w;n[16]!==g||n[17]!==a?(w=$S(a,g),n[16]=g,n[17]=a,n[18]=w):w=n[18];let T;n[19]!==x||n[20]!==o?(T=$S(o,x),n[19]=x,n[20]=o,n[21]=T):T=n[21];let E;return n[22]!==t||n[23]!==y||n[24]!==s||n[25]!==S||n[26]!==C||n[27]!==w||n[28]!==T?(E=(0,M.jsx)(YS.button,{type:`button`,role:`option`,id:S,"aria-selected":y,"data-highlighted":C,...s,ref:t,onClick:w,onMouseMove:T}),n[22]=t,n[23]=y,n[24]=s,n[25]=S,n[26]=C,n[27]=w,n[28]=T,n[29]=E):E=n[29],E});tT.displayName=`ComposerPrimitive.TriggerPopoverItem`;var nT=Gc((e,t)=>{let n=F(10),r,i;n[0]===e?(r=n[1],i=n[2]):({onClick:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let{activeCategoryId:a,isSearchMode:o,goBack:s,open:c}=VC();if(!c||!a||o)return null;let l;n[3]!==s||n[4]!==r?(l=$S(r,s),n[3]=s,n[4]=r,n[5]=l):l=n[5];let u;return n[6]!==t||n[7]!==i||n[8]!==l?(u=(0,M.jsx)(YS.button,{type:`button`,...i,ref:t,onClick:l}),n[6]=t,n[7]=i,n[8]=l,n[9]=u):u=n[9],u});nT.displayName=`ComposerPrimitive.TriggerPopoverBack`;var rT=({formatter:e,onExecute:t,removeOnExecute:n})=>{let{register:r}=WC(),i=I(t);return i.current=t,L(()=>{let t={kind:`action`,formatter:e??_S,onExecute:e=>i.current(e),...n===void 0?{}:{removeOnExecute:n}};return r(t)},[r,e,n]),null};rT.displayName=`ComposerPrimitive.TriggerPopoverAction`;var iT=({formatter:e,onInserted:t})=>{let{register:n}=WC(),r=I(t);return r.current=t,L(()=>n({kind:`directive`,formatter:e??_S,onInserted:e=>r.current?.(e)}),[n,e]),null};iT.displayName=`ComposerPrimitive.TriggerPopoverDirective`;var aT=Object.assign(GC,{Directive:iT,Action:rT}),oT=TS({AddAttachment:()=>Bw,AttachmentByIndex:()=>lx,AttachmentDropzone:()=>Vw,Attachments:()=>dx,Cancel:()=>zw,Dictate:()=>Hw,DictationTranscript:()=>Gw,If:()=>Sx,Input:()=>Rw,Queue:()=>px,Quote:()=>qw,QuoteDismiss:()=>Yw,QuoteText:()=>Jw,Root:()=>ew,Send:()=>JC,StopDictation:()=>Uw,Unstable_TriggerPopover:()=>aT,Unstable_TriggerPopoverBack:()=>nT,Unstable_TriggerPopoverCategories:()=>Qw,Unstable_TriggerPopoverCategoryItem:()=>$w,Unstable_TriggerPopoverItem:()=>tT,Unstable_TriggerPopoverItems:()=>eT,Unstable_TriggerPopoverRoot:()=>kC,unstable_useTriggerPopoverRootContext:()=>_C,unstable_useTriggerPopoverRootContextOptional:()=>vC,unstable_useTriggerPopoverScopeContext:()=>VC,unstable_useTriggerPopoverScopeContextOptional:()=>HC,unstable_useTriggerPopoverTriggers:()=>bC,unstable_useTriggerPopoverTriggersOptional:()=>wC}),sT=Object.freeze({type:`complete`}),cT=Object.freeze({type:`text`,text:``,status:sT}),lT=()=>R(uT);function uT(e){return e.part.type!==`text`&&e.part.type!==`reasoning`?cT:e.part}var dT=Zc(null);function fT(e){let t=$c(dT);if(!e?.optional&&!t)throw Error(`This component must be used within a SmoothContextProvider.`);return t}var{useSmoothStatus:pT,useSmoothStatusStore:mT}=aS(fT,`useSmoothStatus`),hT=250,gT=5,_T=class{animationFrameId=null;lastUpdateTime=Date.now();lastCommitTime=0;targetText=``;drainMs=hT;maxCharIntervalMs=gT;maxCharsPerFrame=1/0;minCommitMs=0;currentText;setText;constructor(e,t){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)}animate=()=>{let e=Date.now(),t=e-this.lastUpdateTime,n=this.targetText.length-this.currentText.length,r=Math.min(this.maxCharIntervalMs,this.drainMs/n),i=Math.min(n,this.maxCharsPerFrame),a=0;for(;t>=r&&a<i;)a++,t-=r;a===i&&i===this.maxCharsPerFrame&&(t=0),this.animationFrameId=a===n?null:requestAnimationFrame(this.animate),a!==0&&(this.currentText=this.targetText.slice(0,this.currentText.length+a),this.lastUpdateTime=e-t,(a===n||e-this.lastCommitTime>=this.minCommitMs)&&(this.lastCommitTime=e,this.setText(this.currentText)))}},vT=Object.freeze({type:`running`}),yT=(e,t)=>e!==void 0&&e>0?e:t,bT=(e,t=!1)=>{let{text:n}=e,r=ow(`(prefers-reduced-motion: reduce)`),i=typeof t==`object`&&t?t:void 0,a=t!==!1&&t!==null&&!r,o=yT(i?.drainMs,hT),s=yT(i?.maxCharIntervalMs,gT),c=yT(i?.maxCharsPerFrame,1/0),l=yT(i?.minCommitMs,0),[u,d]=Pc(e.status.type===`running`?``:n),f=zd(),p=R(()=>f.part),[m,h]=Pc(p);(p!==m||!n.startsWith(u))&&(h(p),d(e.status.type===`running`?``:n));let g=mT({optional:!0}),_=sC(t=>{if(d(t),g){let n=u!==t||e.status.type===`running`?vT:e.status;dS(g).setState(n,!0)}});L(()=>{if(g){let t=a&&(u!==n||e.status.type===`running`)?vT:e.status;dS(g).setState(t,!0)}},[g,a,n,u,e.status]);let[v]=Pc(new _T(u,_));L(()=>{v.drainMs=o,v.maxCharIntervalMs=s,v.maxCharsPerFrame=c,v.minCommitMs=l},[v,o,s,c,l]);let y=I(p);return L(()=>{if(!a){v.stop();return}let t=y.current!==p;if(y.current=p,t||!n.startsWith(v.targetText)){e.status.type===`running`?(v.currentText=``,v.targetText=n,v.lastCommitTime=0,v.start()):(v.currentText=n,v.targetText=n,v.stop());return}v.targetText=n,v.start()},[v,a,n,e.status.type,p]),L(()=>()=>{v.stop()},[v]),Ic(()=>a?{...e,text:u,status:n===u?e.status:vT}:e,[a,u,e,n])},xT=Object.freeze({type:`complete`}),ST=Object.freeze({type:`image`,image:``,status:xT}),CT=()=>R(wT);function wT(e){return e.part.type===`image`?e.part:ST}var TT=Gc((e,t)=>{let n=F(10),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({smooth:i,component:a,...r}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=i===void 0||i,s=a===void 0?`span`:a,{text:c,status:l}=bT(lT(),o),u;return n[4]!==s||n[5]!==t||n[6]!==r||n[7]!==l.type||n[8]!==c?(u=(0,M.jsx)(s,{"data-status":l.type,...r,ref:t,children:c}),n[4]=s,n[5]=t,n[6]=r,n[7]=l.type,n[8]=c,n[9]=u):u=n[9],u});TT.displayName=`MessagePartPrimitive.Text`;var ET=Gc((e,t)=>{let n=F(4),{image:r}=CT(),i;return n[0]!==t||n[1]!==r||n[2]!==e?(i=(0,M.jsx)(YS.img,{src:r,...e,ref:t}),n[0]=t,n[1]=r,n[2]=e,n[3]=i):i=n[3],i});ET.displayName=`MessagePartPrimitive.Image`;var DT=e=>{let t=F(2),n=I(void 0),r;return t[0]===e?r=t[1]:(r=t=>{n.current&&=(n.current(),void 0),t&&(n.current=e(t))},t[0]=e,t[1]=r),r},OT=(e,t)=>{let n=e.trim().match(/^(\d+(?:\.\d+)?|\.\d+)(em|px|rem)$/);if(!n)return 1/0;let r=Number(n[1]),i=n[2];return i===`px`?r:i===`em`?r*(parseFloat(getComputedStyle(t).fontSize)||16):i===`rem`?r*(parseFloat(getComputedStyle(document.documentElement).fontSize)||16):1/0},kT=e=>e.dataset.messageId,AT=()=>{let e=document.createElement(`div`);return e.dataset.auiTopAnchorReserve=``,e.style.height=`0px`,e.style.flexShrink=`0`,e.style.pointerEvents=`none`,e.setAttribute(`aria-hidden`,`true`),e},jT=(e,t)=>{let n=`${t}px`;return e.style.height!==n&&(e.style.height=n,!0)},MT=e=>{let t=window.devicePixelRatio||1;return Math.round(e*t)/t},NT=()=>{let e=F(4),t=zd(),n;e[0]===t.message?n=e[1]:(n=()=>t.message,e[0]=t.message,e[1]=n);let r=R(n),i;return e[2]===r?i=e[3]:(i=e=>{let t=()=>{r.setIsHovering(!0)},n=()=>{r.setIsHovering(!1)};return e.addEventListener(`mouseenter`,t),e.addEventListener(`mouseleave`,n),e.matches(`:hover`)&&queueMicrotask(()=>r.setIsHovering(!0)),()=>{e.removeEventListener(`mouseenter`,t),e.removeEventListener(`mouseleave`,n),r.setIsHovering(!1)}},e[2]=r,e[3]=i),DT(i)},PT=()=>{let e=F(2),t=sS(VT),n;return e[0]===t?n=e[1]:(n=e=>e.message.role===`user`&&e.message.index>0&&e.message.index===e.thread.messages.length-2&&e.thread.messages.at(-1)?.role===`assistant`&&(e.message.id===t||e.thread.isRunning),e[0]=t,e[1]=n),R(n)},FT=()=>{let e=F(2),t=sS(HT),n;return e[0]===t?n=e[1]:(n=e=>e.message.isLast&&e.message.role===`assistant`&&e.message.index>=1&&e.thread.messages.at(e.message.index-1)?.role===`user`&&(e.message.id===t||e.thread.isRunning),e[0]=t,e[1]=n),R(n)},IT=(e,t)=>{let n=F(3),r;return n[0]!==e||n[1]!==t?(r=n=>{if(e)return t.getState().registerAnchorElement(n)},n[0]=e,n[1]=t,n[2]=r):r=n[2],DT(r)},LT=e=>{let t=F(3),{active:n,threadViewportStore:r}=e,i;return t[0]!==n||t[1]!==r?(i=e=>{if(!n)return;let t=r.getState(),i=t.topAnchorMessageClamp;return t.registerAnchorTargetElement(e,{tallerThan:OT(i.tallerThan,e),visibleHeight:OT(i.visibleHeight,e)})},t[0]=n,t[1]=r,t[2]=i):i=t[2],DT(i)},RT=e=>{let t=F(7),n,r;t[0]===e?(n=t[1],r=t[2]):({forwardedRef:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i=NT(),a=CS(n,i),o=R(UT),s;return t[3]!==o||t[4]!==r||t[5]!==a?(s=(0,M.jsx)(YS.div,{...r,ref:a,"data-message-id":o}),t[3]=o,t[4]=r,t[5]=a,t[6]=s):s=t[6],s},zT=e=>{let t=F(13),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({forwardedRef:n,threadViewportStore:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=NT(),o=PT(),s=FT(),c=IT(o,i),l;t[4]!==s||t[5]!==i?(l={active:s,threadViewportStore:i},t[4]=s,t[5]=i,t[6]=l):l=t[6];let u=LT(l),d=CS(n,a,c,u),f=R(WT),p=o?``:void 0,m=s?``:void 0,h;return t[7]!==f||t[8]!==r||t[9]!==d||t[10]!==p||t[11]!==m?(h=(0,M.jsx)(YS.div,{...r,ref:d,"data-message-id":f,"data-aui-top-anchor-user":p,"data-aui-top-anchor-target":m}),t[7]=f,t[8]=r,t[9]=d,t[10]=p,t[11]=m,t[12]=h):h=t[12],h},BT=Gc((e,t)=>{let n=F(7),r=cS();if(r.getState().turnAnchor===`top`){let i;return n[0]!==t||n[1]!==e||n[2]!==r?(i=(0,M.jsx)(zT,{...e,forwardedRef:t,threadViewportStore:r}),n[0]=t,n[1]=e,n[2]=r,n[3]=i):i=n[3],i}let i;return n[4]!==t||n[5]!==e?(i=(0,M.jsx)(RT,{...e,forwardedRef:t}),n[4]=t,n[5]=e,n[6]=i):i=n[6],i});BT.displayName=`MessagePrimitive.Root`;function VT(e){return e.topAnchorTurn?.anchorId}function HT(e){return e.topAnchorTurn?.targetId}function UT(e){return e.message.id}function WT(e){return e.message.id}var GT={...pb,Text:()=>(0,M.jsxs)(`p`,{style:{whiteSpace:`pre-line`},children:[(0,M.jsx)(TT,{}),(0,M.jsx)(mx,{children:(0,M.jsx)(`span`,{style:{fontFamily:`revert`},children:` ●`})})]}),Image:()=>(0,M.jsx)(ET,{})},KT=e=>{let t=F(10);if(`children`in e){let n;return t[0]===e.children?n=t[1]:(n=(0,M.jsx)(Ab,{children:e.children}),t[0]=e.children,t[1]=n),n}let n,r;t[2]===e?(n=t[3],r=t[4]):({components:n,...r}=e,t[2]=e,t[3]=n,t[4]=r);let i;t[5]===n?i=t[6]:(i=n?{Text:n.Text??GT.Text,Image:n.Image??GT.Image,Reasoning:n.Reasoning??pb.Reasoning,Source:n.Source??pb.Source,File:n.File??pb.File,Unstable_Audio:n.Unstable_Audio??pb.Unstable_Audio,...`ChainOfThought`in n?{ChainOfThought:n.ChainOfThought}:{tools:n.tools,data:n.data,ToolGroup:n.ToolGroup??pb.ToolGroup,ReasoningGroup:n.ReasoningGroup??pb.ReasoningGroup},Empty:n.Empty,Quote:n.Quote,generativeUI:n.generativeUI}:GT,t[5]=n,t[6]=i);let a=i,o;return t[7]!==r||t[8]!==a?(o=(0,M.jsx)(Ab,{components:a,...r}),t[7]=r,t[8]=a,t[9]=o):o=t[9],o};KT.displayName=`MessagePrimitive.Parts`;var qT=e=>{let{children:t}=e;return Ux()===void 0?null:t};qT.displayName=`MessagePrimitive.Error`;var JT=e=>{let t=new Map;for(let n=0;n<e.length;n++){let r=e[n]?.parentId??`__ungrouped_${n}`,i=t.get(r)??[];i.push(n),t.set(r,i)}let n=[];for(let[e,r]of t){let t=e.startsWith(`__ungrouped_`)?void 0:e;n.push({groupKey:t,indices:r})}return n},YT=e=>{let t=F(4),n=R(oE),r;bb0:{if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],r=e;break bb0}let i;t[1]!==e||t[2]!==n?(i=e(n),t[1]=e,t[2]=n,t[3]=i):i=t[3],r=i}return r},XT=e=>{let t=F(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.toolName?(i=e=>e.tools.toolUIs[r.toolName]?.[0]?.render??n,t[3]=n,t[4]=r.toolName,t[5]=i):i=t[5];let a=R(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,M.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},ZT=e=>{let t=F(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.name?(i=e=>{let t=e.dataRenderers.renderers[r.name]??n;return Array.isArray(t)?t[0]??n:t},t[3]=n,t[4]=r.name,t[5]=i):i=t[5];let a=R(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,M.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},QT={Text:()=>(0,M.jsxs)(`p`,{style:{whiteSpace:`pre-line`},children:[(0,M.jsx)(TT,{}),(0,M.jsx)(mx,{children:(0,M.jsx)(`span`,{style:{fontFamily:`revert`},children:` ●`})})]}),Reasoning:()=>null,Source:()=>null,Image:()=>(0,M.jsx)(ET,{}),File:()=>null,Unstable_Audio:()=>null,Group:({children:e})=>e},$T=e=>{let t=F(37),{components:n}=e,r;t[0]===n?r=t[1]:(r=n===void 0?{}:n,t[0]=n,t[1]=r);let{Text:i,Reasoning:a,Image:o,Source:s,File:c,Unstable_Audio:l,tools:u,data:d}=r,f=i===void 0?QT.Text:i,p=a===void 0?QT.Reasoning:a,m=o===void 0?QT.Image:o,h=s===void 0?QT.Source:s,g=c===void 0?QT.File:c,_=l===void 0?QT.Unstable_Audio:l,v;t[2]===u?v=t[3]:(v=u===void 0?{}:u,t[2]=u,t[3]=v);let y=v,b=zd(),x=R(sE),S=x.type;if(S===`tool-call`){let e=b.part.addToolResult,n=b.part.resumeToolCall,r=b.part.respondToToolApproval;if(`Override`in y){let i;return t[4]!==e||t[5]!==x||t[6]!==r||t[7]!==n||t[8]!==y.Override?(i=(0,M.jsx)(y.Override,{...x,addResult:e,resume:n,respondToApproval:r}),t[4]=e,t[5]=x,t[6]=r,t[7]=n,t[8]=y.Override,t[9]=i):i=t[9],i}let i=y.by_name?.[x.toolName]??y.Fallback,a;return t[10]!==i||t[11]!==e||t[12]!==x||t[13]!==r||t[14]!==n?(a=(0,M.jsx)(XT,{...x,Fallback:i,addResult:e,resume:n,respondToApproval:r}),t[10]=i,t[11]=e,t[12]=x,t[13]=r,t[14]=n,t[15]=a):a=t[15],a}if(x.status?.type===`requires-action`)throw Error(`Encountered unexpected requires-action status`);switch(S){case`text`:{let e;return t[16]!==f||t[17]!==x?(e=(0,M.jsx)(f,{...x}),t[16]=f,t[17]=x,t[18]=e):e=t[18],e}case`reasoning`:{let e;return t[19]!==p||t[20]!==x?(e=(0,M.jsx)(p,{...x}),t[19]=p,t[20]=x,t[21]=e):e=t[21],e}case`source`:{let e;return t[22]!==h||t[23]!==x?(e=(0,M.jsx)(h,{...x}),t[22]=h,t[23]=x,t[24]=e):e=t[24],e}case`image`:{let e;return t[25]!==m||t[26]!==x?(e=(0,M.jsx)(m,{...x}),t[25]=m,t[26]=x,t[27]=e):e=t[27],e}case`file`:{let e;return t[28]!==g||t[29]!==x?(e=(0,M.jsx)(g,{...x}),t[28]=g,t[29]=x,t[30]=e):e=t[30],e}case`audio`:{let e;return t[31]!==_||t[32]!==x?(e=(0,M.jsx)(_,{...x}),t[31]=_,t[32]=x,t[33]=e):e=t[33],e}case`data`:{let e=d?.by_name?.[x.name]??d?.Fallback,n;return t[34]!==e||t[35]!==x?(n=(0,M.jsx)(ZT,{...x,Fallback:e}),t[34]=e,t[35]=x,t[36]=n):n=t[36],n}default:return console.warn(`Unknown message part type: ${S}`),null}},eE=Kc(e=>{let t=F(5),{partIndex:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,M.jsx)($T,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,M.jsx)(Vh,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.partIndex===t.partIndex&&e.components?.Text===t.components?.Text&&e.components?.Reasoning===t.components?.Reasoning&&e.components?.Source===t.components?.Source&&e.components?.Image===t.components?.Image&&e.components?.File===t.components?.File&&e.components?.Unstable_Audio===t.components?.Unstable_Audio&&e.components?.tools===t.components?.tools&&e.components?.data===t.components?.data&&e.components?.Group===t.components?.Group),tE=e=>{let t=F(6),{status:n,component:r}=e,i=n.type===`running`,a;t[0]!==r||t[1]!==n?(a=(0,M.jsx)(r,{type:`text`,text:``,status:n}),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o;return t[3]!==i||t[4]!==a?(o=(0,M.jsx)(Uh,{text:``,isRunning:i,children:a}),t[3]=i,t[4]=a,t[5]=o):o=t[5],o},nE=Object.freeze({type:`complete`}),rE=Kc(e=>{let t=F(6),{components:n}=e,r=R(cE);if(n?.Empty){let e;return t[0]!==n.Empty||t[1]!==r?(e=(0,M.jsx)(n.Empty,{status:r}),t[0]=n.Empty,t[1]=r,t[2]=e):e=t[2],e}let i=n?.Text??QT.Text,a;return t[3]!==r||t[4]!==i?(a=(0,M.jsx)(tE,{status:r,component:i}),t[3]=r,t[4]=i,t[5]=a):a=t[5],a},(e,t)=>e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),iE=e=>{let t=F(9),{groupingFunction:n,components:r}=e,i=R(lE),a=YT(n),o;bb0:{if(i===0){let e;t[0]===r?e=t[1]:(e=(0,M.jsx)(rE,{components:r}),t[0]=r,t[1]=e),o=e;break bb0}let e;if(t[2]!==r||t[3]!==a){let n;t[5]===r?n=t[6]:(n=(e,t)=>{let n=r?.Group??QT.Group;return(0,M.jsx)(n,{groupKey:e.groupKey,indices:e.indices,children:e.indices.map(e=>(0,M.jsx)(eE,{partIndex:e,components:r},e))},`group-${t}-${e.groupKey??`ungrouped`}`)},t[5]=r,t[6]=n),e=a.map(n),t[2]=r,t[3]=a,t[4]=e}else e=t[4];o=e}let s=o,c;return t[7]===s?c=t[8]:(c=(0,M.jsx)(M.Fragment,{children:s}),t[7]=s,t[8]=c),c};iE.displayName=`MessagePrimitive.Unstable_PartsGrouped`;var aE=e=>{let t=F(6),n,r;t[0]===e?(n=t[1],r=t[2]):({components:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==n||t[4]!==r?(i=(0,M.jsx)(iE,{...r,components:n,groupingFunction:JT}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i};aE.displayName=`MessagePrimitive.Unstable_PartsGroupedByParentId`;function oE(e){return e.message.parts}function sE(e){return e.part}function cE(e){return e.message.status??nE}function lE(e){return e.message.parts.length}var uE=TS({AttachmentByIndex:()=>rx,Attachments:()=>ax,Content:()=>KT,Error:()=>qT,GenerativeUI:()=>Zy,GroupedParts:()=>$b,If:()=>lC,PartByIndex:()=>hb,Parts:()=>KT,Quote:()=>ex,Root:()=>BT,Unstable_PartsGrouped:()=>iE,Unstable_PartsGroupedByParentId:()=>aE}),dE=e=>{let t=F(2),n=sC(e),r;return t[0]===n?r=t[1]:(r=e=>{let t=new ResizeObserver(()=>{n()}),r=new MutationObserver(e=>{e.some(fE)&&n()});return t.observe(e),r.observe(e,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),()=>{t.disconnect(),r.disconnect()}},t[0]=n,t[1]=r),DT(r)};function fE(e){return e.type!==`attributes`||e.attributeName!==`style`}var pE=({autoScroll:e,scrollToBottomOnRunStart:t=!0,scrollToBottomOnInitialize:n=!0,scrollToBottomOnThreadSwitch:r=!0})=>{let i=I(null),a=R(e=>e.thread.messages.length>0),o=R(e=>e.thread.isRunning),s=I(!1),c=I(null),l=cS();e===void 0&&(e=l.getState().turnAnchor!==`top`);let u=I(0),d=I(0),f=I(0),p=I(0),m=I(null),h=I(e),g=Lc(e=>{let t=i.current;t&&(h.current=!0,m.current=e,t.scrollTo({top:t.scrollHeight,behavior:e}))},[]),_=Lc(()=>{c.current!==null&&(cancelAnimationFrame(c.current),c.current=null)},[]),v=Lc(e=>{m.current=e,_(),c.current=requestAnimationFrame(()=>{c.current=null,g(e)})},[_,g]);Rc(()=>()=>_(),[_]);let y=Lc(()=>{let e=l.getState();return e.turnAnchor===`top`&&e.element.viewport===i.current&&e.element.anchor!==null},[l]),b=()=>{let t=i.current;if(!t)return;let n=l.getState().isAtBottom,r=Math.abs(t.scrollHeight-t.scrollTop-t.clientHeight)<=1||t.scrollHeight<=t.clientHeight;if(!(!r&&u.current<t.scrollTop)){let i=Qd({scrollTop:u.current,scrollHeight:d.current},t);r?(t.scrollHeight>t.clientHeight+1&&(m.current=null),e&&(h.current=!0)):i&&(_(),m.current=null,h.current=!1),(r||m.current===null)&&r!==n&&dS(l).setState({isAtBottom:r})}u.current=t.scrollTop,d.current=t.scrollHeight},x=dE(()=>{let t=i.current;if(!t)return;let{scrollHeight:n,clientHeight:r}=t;if(n===f.current&&r===p.current)return;f.current=n,p.current=r;let a=m.current;a&&y()?m.current=null:a?g(a):e&&!(o&&y())&&h.current&&g(`instant`),b()}),S=DT(e=>{let t=()=>{m.current=null};return e.addEventListener(`scroll`,b),e.addEventListener(`pointerdown`,t),()=>{e.removeEventListener(`scroll`,b),e.removeEventListener(`pointerdown`,t)}});return Rc(()=>{if(n){if(!a){s.current=!1;return}s.current||(s.current=!0,m.current===null&&v(`instant`))}},[a,v,n]),nw(({behavior:e})=>{g(e)}),Uf(`thread.runStart`,()=>{t&&l.getState().turnAnchor!==`top`&&v(`auto`)}),Uf(`threads.selectionChanged`,()=>{r&&v(`instant`)}),CS(x,S,i)},mE=Gc((e,t)=>{let n=F(6),r=zd(),i,a;n[0]===r?(i=n[1],a=n[2]):(i=()=>{let e=e=>{if(e.key===`Escape`&&!(e.defaultPrevented||r.thread.source===null)&&r.thread.getState().speech!=null){e.preventDefault();try{r.thread.stopSpeaking()}catch(e){let t=e;if(!(t instanceof Error)||t.message!==`No message is being spoken`)throw t}}};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},a=[r],n[0]=r,n[1]=i,n[2]=a),L(i,a);let o;return n[3]!==e||n[4]!==t?(o=(0,M.jsx)(YS.div,{...e,ref:t}),n[3]=e,n[4]=t,n[5]=o):o=n[5],o});mE.displayName=`ThreadPrimitive.Root`;var hE=e=>{let{children:t}=e;return R(gE)?t:null};hE.displayName=`ThreadPrimitive.Empty`;function gE(e){return e.thread.isEmpty}var _E=e=>{let t=F(4),n;return t[0]!==e.disabled||t[1]!==e.empty||t[2]!==e.running?(n=t=>!(e.empty===!0&&!t.thread.isEmpty||e.empty===!1&&t.thread.isEmpty||e.running===!0&&!t.thread.isRunning||e.running===!1&&t.thread.isRunning||e.disabled===!0&&!t.thread.isDisabled||e.disabled===!1&&t.thread.isDisabled),t[0]=e.disabled,t[1]=e.empty,t[2]=e.running,t[3]=n):n=t[3],R(n)},vE=e=>{let t=F(3),n,r;return t[0]===e?(n=t[1],r=t[2]):({children:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),_E(r)?n:null};vE.displayName=`ThreadPrimitive.If`;var yE=(e,t)=>{let n=F(3),r;return n[0]!==t||n[1]!==e?(r=n=>{if(!e)return;let r=e(),i=()=>{let e=t?t(n):n.offsetHeight;r.setHeight(e)},a=new ResizeObserver(i);return a.observe(n),i(),()=>{a.disconnect(),r.unregister()}},n[0]=t,n[1]=e,n[2]=r):r=n[2],DT(r)},bE=e=>{let t=0,n=e;for(;n;)t+=n.offsetTop,n=n.offsetParent;return t},xE=(e,t)=>{let n=0,r=e;for(;r&&r!==t;)n+=r.offsetTop,r=r.offsetParent;return r===t?n:bE(e)-bE(t)},SE=({viewport:e,anchor:t,tallerThan:n,visibleHeight:r})=>{let i=xE(t,e),a=t.offsetHeight;return i+Math.max(0,a-(a<=n?a:r))},CE=({scrollHeight:e,...t})=>{let{viewport:n}=t,r=SE(t)+n.clientHeight;return Math.max(0,r-e)},wE=({viewport:e,reserve:t,...n})=>CE({viewport:e,...n,scrollHeight:e.scrollHeight-t.offsetHeight}),TE=e=>{let t=new ResizeObserver(e),n=new MutationObserver(e),r=null,i=null,a=null,o=()=>{t.disconnect(),n.disconnect(),r=null,i=null,a=null};return{target:(e,s,c)=>{(r!==e||i!==s||a!==c)&&(o(),t.observe(e),t.observe(s),t.observe(c),n.observe(c,{childList:!0,subtree:!0,characterData:!0}),r=e,i=s,a=c)},disconnect:o}},EE=e=>{let t=null;return{schedule:()=>{t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))},cancel:()=>{t!==null&&(cancelAnimationFrame(t),t=null)}}},DE=e=>{let t=null,n;function r(){let r=e.getState(),{viewport:o,anchor:s,target:c}=r.element,l=r.targetConfig;if(r.turnAnchor!==`top`||!o){a.disconnect(),t&&(jT(t,0),t.remove());return}if(!s&&!c&&!l&&r.topAnchorTurn){a.disconnect(),t?.parentElement&&t.parentElement.lastElementChild!==t&&t.parentElement.append(t);return}if(!s||!c||!l){a.disconnect(),t&&(jT(t,0),t.remove());return}if(t??=AT(),(t.parentElement!==c.parentElement||t.previousElementSibling!==c)&&c.after(t),a.target(o,s,c),jT(t,wE({viewport:o,anchor:s,reserve:t,...l}))){i.schedule();return}let u=kT(s);if(u!==void 0&&n===u)return;let d=MT(SE({viewport:o,anchor:s,...l}));Math.abs(o.scrollTop-d)>1&&o.scrollTo({top:d,behavior:`smooth`}),u!==void 0&&(n=u)}let i=EE(r),a=TE(i.schedule);i.schedule();let o=e.subscribe(i.schedule);return()=>{i.cancel(),o(),a.disconnect(),t?.remove()}},OE=e=>{let t=F(4),n=cS(),r,i;t[0]!==e||t[1]!==n?(r=()=>{if(e)return DE(n)},i=[e,n],t[0]=e,t[1]=n,t[2]=r,t[3]=i):(r=t[2],i=t[3]),Rc(r,i)},kE=(e,t)=>{if(!e)return!1;let n=t.findIndex(t=>t.id===e.targetId);return n<1?!1:t[n-1]?.id===e.anchorId&&t.slice(n+1).every(e=>e.role===`user`)},AE=({isRunning:e,messages:t})=>{if(!e)return null;let n=t.at(-1),r=t.at(-2);return r?.role!==`user`||n?.role!==`assistant`?null:{anchorId:r.id,targetId:n.id}},jE=e=>AE(e)?.anchorId,ME=e=>AE(e)?.targetId,NE=()=>yE(sS(RE),zE),PE=()=>DT(sS(BE)),FE=e=>{let t=F(19),n=cS(),r;t[0]===e?r=t[1]:(r=t=>{if(e)return jE(t.thread)},t[0]=e,t[1]=r);let i=R(r),a;t[2]===e?a=t[3]:(a=t=>{if(e)return ME(t.thread)},t[2]=e,t[3]=a);let o=R(a),s=sS(VE),c;bb0:{if(!i||!o){c=null;break bb0}let e;t[4]!==i||t[5]!==o?(e={anchorId:i,targetId:o},t[4]=i,t[5]=o,t[6]=e):e=t[6],c=e}let l=c,u;t[7]!==e||t[8]!==s?(u=t=>e&&!!s&&kE(s,t.thread.messages),t[7]=e,t[8]=s,t[9]=u):u=t[9];let d=R(u),f,p;t[10]!==n||t[11]!==s||t[12]!==d?(f=()=>{!s||d||n.getState().setTopAnchorTurn(null)},p=[n,s,d],t[10]=n,t[11]=s,t[12]=d,t[13]=f,t[14]=p):(f=t[13],p=t[14]),Rc(f,p);let m,h;t[15]!==l||t[16]!==n?(m=()=>{if(!l)return;let e=n.getState(),t=e.topAnchorTurn;(t?.anchorId!==l.anchorId||t.targetId!==l.targetId)&&e.setTopAnchorTurn(l)},h=[l,n],t[15]=l,t[16]=n,t[17]=m,t[18]=h):(m=t[17],h=t[18]),Rc(m,h)},IE=Gc((e,t)=>{let n=F(18),r,i,a,o,s,c;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[6]):({autoScroll:r,scrollToBottomOnRunStart:s,scrollToBottomOnInitialize:o,scrollToBottomOnThreadSwitch:c,children:i,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s,n[6]=c);let l;n[7]!==r||n[8]!==o||n[9]!==s||n[10]!==c?(l={autoScroll:r,scrollToBottomOnRunStart:s,scrollToBottomOnInitialize:o,scrollToBottomOnThreadSwitch:c},n[7]=r,n[8]=o,n[9]=s,n[10]=c,n[11]=l):l=n[11];let u=pE(l),d=NE(),f=PE(),p=cS(),m;n[12]===p?m=n[13]:(m=p.getState(),n[12]=p,n[13]=m);let h=m.turnAnchor===`top`;FE(h),OE(h);let g=CS(t,u,d,f),_;return n[14]!==i||n[15]!==g||n[16]!==a?(_=(0,M.jsx)(YS.div,{...a,ref:g,children:i}),n[14]=i,n[15]=g,n[16]=a,n[17]=_):_=n[17],_});IE.displayName=`ThreadPrimitive.ViewportScrollable`;var LE=Gc((e,t)=>{let n=F(13),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({turnAnchor:a,topAnchorMessageClamp:i,...r}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]!==i||n[5]!==a?(o={turnAnchor:a,topAnchorMessageClamp:i},n[4]=i,n[5]=a,n[6]=o):o=n[6];let s;n[7]!==r||n[8]!==t?(s=(0,M.jsx)(IE,{...r,ref:t}),n[7]=r,n[8]=t,n[9]=s):s=n[9];let c;return n[10]!==o||n[11]!==s?(c=(0,M.jsx)(pS,{options:o,children:s}),n[10]=o,n[11]=s,n[12]=c):c=n[12],c});LE.displayName=`ThreadPrimitive.Viewport`;function RE(e){return e.registerViewport}function zE(e){return e.clientHeight}function BE(e){return e.registerViewportElement}function VE(e){return e.topAnchorTurn}var HE=Gc((e,t)=>{let n=F(3),r=CS(t,yE(sS(UE),WE)),i;return n[0]!==e||n[1]!==r?(i=(0,M.jsx)(YS.div,{...e,ref:r}),n[0]=e,n[1]=r,n[2]=i):i=n[2],i});HE.displayName=`ThreadPrimitive.ViewportFooter`;function UE(e){return e.registerContentInset}function WE(e){let t=parseFloat(getComputedStyle(e).marginTop)||0;return e.offsetHeight+t}var GE=iC(`ThreadPrimitive.ScrollToBottom`,e=>{let t=F(5),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{behavior:r}=n,i=sS(KE),a=cS(),o;return t[2]!==r||t[3]!==a?(o=()=>{a.getState().scrollToBottom({behavior:r})},t[2]=r,t[3]=a,t[4]=o):o=t[4],i?null:o},[`behavior`]);function KE(e){return e.isAtBottom}var qE=iC(`ThreadPrimitive.Suggestion`,e=>{let t=F(4),{prompt:n,send:r,clearComposer:i,autoSend:a}=e,o=r??a??!1,s;t[0]!==i||t[1]!==n||t[2]!==o?(s={prompt:n,send:o,clearComposer:i},t[0]=i,t[1]=n,t[2]=o,t[3]=s):s=t[3];let{disabled:c,trigger:l}=Vx(s);return c?null:l},[`prompt`,`send`,`clearComposer`,`autoSend`,`method`]),JE=TS({Empty:()=>hE,If:()=>vE,MessageByIndex:()=>Ry,Messages:()=>Hy,Root:()=>mE,ScrollToBottom:()=>GE,Suggestion:()=>qE,SuggestionByIndex:()=>_x,Suggestions:()=>bx,Unstable_MessageById:()=>zy,Viewport:()=>LE,ViewportFooter:()=>HE,ViewportProvider:()=>pS}),YE=(e,t,n)=>{if(Array.isArray(e))return e.map((e,r)=>YE(e,`${t}[${r}]`,n));if(e&&typeof e==`object`){let r=e,i=Object.keys(r),a=n.get(t)??[],o=new Set(a),s=[...a.filter(e=>Object.hasOwn(r,e)),...i.filter(e=>!o.has(e))];return n.set(t,s),Object.fromEntries(s.map(e=>[e,YE(r[e],`${t}.${JSON.stringify(e)}`,n)]))}return e},XE=(e,t)=>{let n=e?.get(t)??new Map;return e?.set(t,n),n},ZE=(e,t,n)=>{let r=YE(n,`$`,XE(e,t));return JSON.stringify(r)},QE=[{mediaType:`image/gif`,prefix:[71,73,70]},{mediaType:`image/png`,prefix:[137,80,78,71]},{mediaType:`image/jpeg`,prefix:[255,216]},{mediaType:`image/webp`,prefix:[82,73,70,70,null,null,null,null,87,69,66,80]},{mediaType:`image/bmp`,prefix:[66,77]},{mediaType:`image/tiff`,prefix:[73,73,42,0]},{mediaType:`image/tiff`,prefix:[77,77,0,42]},{mediaType:`image/avif`,prefix:[null,null,null,null,102,116,121,112,97,118,105,102]},{mediaType:`image/heic`,prefix:[null,null,null,null,102,116,121,112,104,101,105,99]}],$E=16,eD=e=>{let t=e.slice(0,$E),n=t.slice(0,t.length-t.length%4);if(n.length===0)return;let r=globalThis.Buffer;if(r)return new Uint8Array(r.from(n,`base64`));try{let e=atob(n),t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}catch{return}};function tD(e){let t=eD(e);if(t)return QE.find(({prefix:e})=>t.length>=e.length&&e.every((e,n)=>e===null||t[n]===e))?.mediaType}function nD(e,t){if(t?.startsWith(`image/`))return t;let n=sm(e);if(n?.startsWith(`image/`))return n;let r=am(e)?.data??(om(e)?void 0:e);if(r!==void 0){let e=tD(r);if(e)return e}return`image/png`}function rD(e,t){return t||sm(e)||`application/octet-stream`}function iD(e,t){let n=am(e);return n?n.mimeType===t?e:`data:${t};base64,${n.data}`:om(e)?e:`data:${t};base64,${e}`}var aD={mode:`dify-sdk`,localApiUrl:`http://localhost:5688/api/ai/chat/stream`},oD={DIFY_CHAT_MESSAGES:`https://dify.app.hicloudapp.com/v1/chat-messages`,DIFY_CONVERSATIONS:`https://dify.app.hicloudapp.com/v1/conversations`,DIFY_MESSAGES:e=>`https://dify.app.hicloudapp.com/v1/messages?conversation_id=${e}`,DIFY_DELETE_CONVERSATION:e=>`https://dify.app.hicloudapp.com/v1/conversations/${e}`,LOCAL_AGENT_CHAT:`/local/api/ai/chat/demo`},sD={API_KEY:`app-gDlpetMgsv6zqeqd1NjJt9u7`,APP_ID:`test-app-id`,BASE_URL:`https://dify.app.hicloudapp.com/v1`},cD={apiKey:`app-gDlpetMgsv6zqeqd1NjJt9u7`,appId:`test-app-id`,baseUrl:`https://dify.app.hicloudapp.com/v1`},lD=()=>{if(!cD.apiKey)throw Error(`Dify API Key not configured. Set VITE_DIFY_API_KEY in .env.local`);if(!cD.appId)throw Error(`Dify App ID not configured. Set VITE_DIFY_APP_ID in .env.local`);return!0},uD;function z(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var dD=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},fD=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(uD=globalThis).__zod_globalConfig??(uD.__zod_globalConfig={});var pD=globalThis.__zod_globalConfig;function mD(e){return e&&Object.assign(pD,e),pD}function hD(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function gD(e,t){return typeof t==`bigint`?t.toString():t}function _D(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function vD(e){return e==null}function yD(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function bD(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var xD=Symbol(`evaluating`);function SD(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==xD)return r===void 0&&(r=xD,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function CD(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function wD(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function TD(e){return JSON.stringify(e)}function ED(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var DD=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function OD(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var kD=_D(()=>{if(pD.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function AD(e){if(OD(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return OD(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function jD(e){return AD(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var MD=new Set([`string`,`number`,`symbol`]);function ND(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function PD(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function B(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function FD(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var ID={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function LD(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return PD(e,wD(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return CD(this,`shape`,e),e},checks:[]}))}function RD(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return PD(e,wD(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return CD(this,`shape`,r),r},checks:[]}))}function zD(e,t){if(!AD(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return PD(e,wD(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return CD(this,`shape`,n),n}}))}function BD(e,t){if(!AD(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return PD(e,wD(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return CD(this,`shape`,n),n}}))}function VD(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return PD(e,wD(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return CD(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function HD(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return PD(t,wD(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return CD(this,`shape`,i),i},checks:[]}))}function UD(e,t,n){return PD(t,wD(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return CD(this,`shape`,i),i}}))}function WD(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function GD(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function KD(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function qD(e){return typeof e==`string`?e:e?.message}function JD(e,t,n){let r=e.message?e.message:qD(e.inst?._zod.def?.error?.(e))??qD(t?.error?.(e))??qD(n.customError?.(e))??qD(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function YD(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function XD(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var ZD=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,gD,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},QD=z(`$ZodError`,ZD),$D=z(`$ZodError`,ZD,{Parent:Error});function eO(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function tO(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}var nO=e=>(t,n,r,i)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new dD;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>JD(e,a,mD())));throw DD(t,i?.callee),t}return o.value},rO=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>JD(e,a,mD())));throw DD(t,i?.callee),t}return o.value},iO=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new dD;return a.issues.length?{success:!1,error:new(e??QD)(a.issues.map(e=>JD(e,i,mD())))}:{success:!0,data:a.value}},aO=iO($D),oO=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>JD(e,i,mD())))}:{success:!0,data:a.value}},sO=oO($D),cO=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return nO(e)(t,n,i)},lO=e=>(t,n,r)=>nO(e)(t,n,r),uO=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return rO(e)(t,n,i)},dO=e=>async(t,n,r)=>rO(e)(t,n,r),fO=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return iO(e)(t,n,i)},pO=e=>(t,n,r)=>iO(e)(t,n,r),mO=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return oO(e)(t,n,i)},hO=e=>async(t,n,r)=>oO(e)(t,n,r),gO=/^[cC][0-9a-z]{6,}$/,_O=/^[0-9a-z]+$/,vO=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,yO=/^[0-9a-vA-V]{20}$/,bO=/^[A-Za-z0-9]{27}$/,xO=/^[a-zA-Z0-9_-]{21}$/,SO=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,CO=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,wO=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,TO=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,EO=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function DO(){return new RegExp(EO,`u`)}var OO=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,kO=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,AO=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,jO=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,MO=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,NO=/^[A-Za-z0-9_-]*$/,PO=/^https?$/,FO=/^\+[1-9]\d{6,14}$/,IO=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,LO=RegExp(`^${IO}$`);function RO(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function zO(e){return RegExp(`^${RO(e)}$`)}function BO(e){let t=RO({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${IO}T(?:${r})$`)}var VO=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},HO=/^-?\d+$/,UO=/^-?\d+(?:\.\d+)?$/,WO=/^(?:true|false)$/i,GO=/^null$/i,KO=/^[^A-Z]*$/,qO=/^[^a-z]*$/,JO=z(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),YO={number:`number`,bigint:`bigint`,object:`date`},XO=z(`$ZodCheckLessThan`,(e,t)=>{JO.init(e,t);let n=YO[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ZO=z(`$ZodCheckGreaterThan`,(e,t)=>{JO.init(e,t);let n=YO[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),QO=z(`$ZodCheckMultipleOf`,(e,t)=>{JO.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):bD(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),$O=z(`$ZodCheckNumberFormat`,(e,t)=>{JO.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=ID[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=HO)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),ek=z(`$ZodCheckMaxLength`,(e,t)=>{var n;JO.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!vD(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=YD(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),tk=z(`$ZodCheckMinLength`,(e,t)=>{var n;JO.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!vD(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=YD(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),nk=z(`$ZodCheckLengthEquals`,(e,t)=>{var n;JO.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!vD(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=YD(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),rk=z(`$ZodCheckStringFormat`,(e,t)=>{var n,r;JO.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),ik=z(`$ZodCheckRegex`,(e,t)=>{rk.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),ak=z(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=KO,rk.init(e,t)}),ok=z(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=qO,rk.init(e,t)}),sk=z(`$ZodCheckIncludes`,(e,t)=>{JO.init(e,t);let n=ND(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),ck=z(`$ZodCheckStartsWith`,(e,t)=>{JO.init(e,t);let n=RegExp(`^${ND(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),lk=z(`$ZodCheckEndsWith`,(e,t)=>{JO.init(e,t);let n=RegExp(`.*${ND(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),uk=z(`$ZodCheckOverwrite`,(e,t)=>{JO.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),dk=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
21
|
-
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
|
|
22
|
-
`))}},fk={major:4,minor:4,patch:3},pk=z(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=fk;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=WD(e),i;for(let a of t){if(a._zod.def.when){if(GD(e)||!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new dD;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=WD(e,t))});else{if(e.issues.length===t)continue;r||=WD(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(WD(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new dD;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new dD;return o.then(e=>t(e,r,a))}return t(o,r,a)}}SD(e,`~standard`,()=>({validate:t=>{try{let n=aO(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return sO(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),mk=z(`$ZodString`,(e,t)=>{pk.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??VO(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),hk=z(`$ZodStringFormat`,(e,t)=>{rk.init(e,t),mk.init(e,t)}),gk=z(`$ZodGUID`,(e,t)=>{t.pattern??=CO,hk.init(e,t)}),_k=z(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=wO(e)}else t.pattern??=wO();hk.init(e,t)}),vk=z(`$ZodEmail`,(e,t)=>{t.pattern??=TO,hk.init(e,t)}),yk=z(`$ZodURL`,(e,t)=>{hk.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===PO.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),n.value=t.normalize?i.href:r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),bk=z(`$ZodEmoji`,(e,t)=>{t.pattern??=DO(),hk.init(e,t)}),xk=z(`$ZodNanoID`,(e,t)=>{t.pattern??=xO,hk.init(e,t)}),Sk=z(`$ZodCUID`,(e,t)=>{t.pattern??=gO,hk.init(e,t)}),Ck=z(`$ZodCUID2`,(e,t)=>{t.pattern??=_O,hk.init(e,t)}),wk=z(`$ZodULID`,(e,t)=>{t.pattern??=vO,hk.init(e,t)}),Tk=z(`$ZodXID`,(e,t)=>{t.pattern??=yO,hk.init(e,t)}),Ek=z(`$ZodKSUID`,(e,t)=>{t.pattern??=bO,hk.init(e,t)}),Dk=z(`$ZodISODateTime`,(e,t)=>{t.pattern??=BO(t),hk.init(e,t)}),Ok=z(`$ZodISODate`,(e,t)=>{t.pattern??=LO,hk.init(e,t)}),kk=z(`$ZodISOTime`,(e,t)=>{t.pattern??=zO(t),hk.init(e,t)}),Ak=z(`$ZodISODuration`,(e,t)=>{t.pattern??=SO,hk.init(e,t)}),jk=z(`$ZodIPv4`,(e,t)=>{t.pattern??=OO,hk.init(e,t),e._zod.bag.format=`ipv4`}),Mk=z(`$ZodIPv6`,(e,t)=>{t.pattern??=kO,hk.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),Nk=z(`$ZodCIDRv4`,(e,t)=>{t.pattern??=AO,hk.init(e,t)}),Pk=z(`$ZodCIDRv6`,(e,t)=>{t.pattern??=jO,hk.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function Fk(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var Ik=z(`$ZodBase64`,(e,t)=>{t.pattern??=MO,hk.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{Fk(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function Lk(e){if(!NO.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return Fk(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var Rk=z(`$ZodBase64URL`,(e,t)=>{t.pattern??=NO,hk.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{Lk(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),zk=z(`$ZodE164`,(e,t)=>{t.pattern??=FO,hk.init(e,t)});function Bk(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var Vk=z(`$ZodJWT`,(e,t)=>{hk.init(e,t),e._zod.check=n=>{Bk(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Hk=z(`$ZodNumber`,(e,t)=>{pk.init(e,t),e._zod.pattern=e._zod.bag.pattern??UO,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Uk=z(`$ZodNumberFormat`,(e,t)=>{$O.init(e,t),Hk.init(e,t)}),Wk=z(`$ZodBoolean`,(e,t)=>{pk.init(e,t),e._zod.pattern=WO,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),Gk=z(`$ZodNull`,(e,t)=>{pk.init(e,t),e._zod.pattern=GO,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),Kk=z(`$ZodAny`,(e,t)=>{pk.init(e,t),e._zod.parse=e=>e}),qk=z(`$ZodUnknown`,(e,t)=>{pk.init(e,t),e._zod.parse=e=>e}),Jk=z(`$ZodNever`,(e,t)=>{pk.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Yk(e,t,n){e.issues.length&&t.issues.push(...KD(n,e.issues)),t.value[n]=e.value}var Xk=z(`$ZodArray`,(e,t)=>{pk.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>Yk(t,n,e))):Yk(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function Zk(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...KD(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function Qk(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=FD(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function $k(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Zk(e,n,i,t,u,d))):Zk(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var eA=z(`$ZodObject`,(e,t)=>{if(pk.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=_D(()=>Qk(t));SD(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=OD,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>Zk(n,t,e,s,r,i))):Zk(a,t,e,s,r,i)}return i?$k(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),tA=z(`$ZodObjectJIT`,(e,t)=>{eA.init(e,t);let n=e._zod.parse,r=_D(()=>Qk(t)),i=e=>{let t=new dk([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=TD(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=TD(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
|
|
23
|
-
if (${n}.issues.length) {
|
|
24
|
-
if (${o} in input) {
|
|
25
|
-
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
26
|
-
...iss,
|
|
27
|
-
path: iss.path ? [${o}, ...iss.path] : [${o}]
|
|
28
|
-
})));
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (${n}.value === undefined) {
|
|
33
|
-
if (${o} in input) {
|
|
34
|
-
newResult[${o}] = undefined;
|
|
35
|
-
}
|
|
36
|
-
} else {
|
|
37
|
-
newResult[${o}] = ${n}.value;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
`):c?t.write(`
|
|
41
|
-
if (${n}.issues.length) {
|
|
42
|
-
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
43
|
-
...iss,
|
|
44
|
-
path: iss.path ? [${o}, ...iss.path] : [${o}]
|
|
45
|
-
})));
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (${n}.value === undefined) {
|
|
49
|
-
if (${o} in input) {
|
|
50
|
-
newResult[${o}] = undefined;
|
|
51
|
-
}
|
|
52
|
-
} else {
|
|
53
|
-
newResult[${o}] = ${n}.value;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
`):t.write(`
|
|
57
|
-
const ${n}_present = ${o} in input;
|
|
58
|
-
if (${n}.issues.length) {
|
|
59
|
-
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
60
|
-
...iss,
|
|
61
|
-
path: iss.path ? [${o}, ...iss.path] : [${o}]
|
|
62
|
-
})));
|
|
63
|
-
}
|
|
64
|
-
if (!${n}_present && !${n}.issues.length) {
|
|
65
|
-
payload.issues.push({
|
|
66
|
-
code: "invalid_type",
|
|
67
|
-
expected: "nonoptional",
|
|
68
|
-
input: undefined,
|
|
69
|
-
path: [${o}]
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (${n}_present) {
|
|
74
|
-
if (${n}.value === undefined) {
|
|
75
|
-
newResult[${o}] = undefined;
|
|
76
|
-
} else {
|
|
77
|
-
newResult[${o}] = ${n}.value;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=OD,s=!pD.jitless,c=s&&kD.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?$k([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function nA(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!WD(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>JD(e,r,mD())))}),t)}var rA=z(`$ZodUnion`,(e,t)=>{pk.init(e,t),SD(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),SD(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),SD(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),SD(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>yD(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>nA(t,r,e,i)):nA(o,r,e,i)}}),iA=z(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,rA.init(e,t);let n=e._zod.parse;SD(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=_D(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!OD(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),aA=z(`$ZodIntersection`,(e,t)=>{pk.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>sA(e,t,n)):sA(e,i,a)}});function oA(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(AD(e)&&AD(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=oA(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=oA(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function sA(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),WD(e))return e;let o=oA(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var cA=z(`$ZodRecord`,(e,t)=>{pk.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!AD(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let c of o)if(typeof c==`string`||typeof c==`number`||typeof c==`symbol`){s.add(typeof c==`number`?c.toString():c);let o=t.keyType._zod.run({value:c,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>JD(e,r,mD())),input:c,path:[c],inst:e});continue}let l=o.value,u=t.valueType._zod.run({value:i[c],issues:[]},r);u instanceof Promise?a.push(u.then(e=>{e.issues.length&&n.issues.push(...KD(c,e.issues)),n.value[l]=e.value})):(u.issues.length&&n.issues.push(...KD(c,u.issues)),n.value[l]=u.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&UO.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>JD(e,r,mD())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...KD(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...KD(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),lA=z(`$ZodEnum`,(e,t)=>{pk.init(e,t);let n=hD(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>MD.has(typeof e)).map(e=>typeof e==`string`?ND(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),uA=z(`$ZodLiteral`,(e,t)=>{if(pk.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?ND(e):e?ND(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),dA=z(`$ZodTransform`,(e,t)=>{pk.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new fD(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n.fallback=!0,n));if(i instanceof Promise)throw new dD;return n.value=i,n.fallback=!0,n}});function fA(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var pA=z(`$ZodOptional`,(e,t)=>{pk.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,SD(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),SD(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${yD(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>fA(e,r)):fA(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),mA=z(`$ZodExactOptional`,(e,t)=>{pA.init(e,t),SD(e._zod,`values`,()=>t.innerType._zod.values),SD(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),hA=z(`$ZodNullable`,(e,t)=>{pk.init(e,t),SD(e._zod,`optin`,()=>t.innerType._zod.optin),SD(e._zod,`optout`,()=>t.innerType._zod.optout),SD(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${yD(e.source)}|null)$`):void 0}),SD(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),gA=z(`$ZodDefault`,(e,t)=>{pk.init(e,t),e._zod.optin=`optional`,SD(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>_A(e,t)):_A(r,t)}});function _A(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var vA=z(`$ZodPrefault`,(e,t)=>{pk.init(e,t),e._zod.optin=`optional`,SD(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),yA=z(`$ZodNonOptional`,(e,t)=>{pk.init(e,t),SD(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>bA(t,e)):bA(i,e)}});function bA(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var xA=z(`$ZodCatch`,(e,t)=>{pk.init(e,t),e._zod.optin=`optional`,SD(e._zod,`optout`,()=>t.innerType._zod.optout),SD(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>JD(e,n,mD()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>JD(e,n,mD()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),SA=z(`$ZodPipe`,(e,t)=>{pk.init(e,t),SD(e._zod,`values`,()=>t.in._zod.values),SD(e._zod,`optin`,()=>t.in._zod.optin),SD(e._zod,`optout`,()=>t.out._zod.optout),SD(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>CA(e,t.in,n)):CA(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>CA(e,t.out,n)):CA(r,t.out,n)}});function CA(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var wA=z(`$ZodReadonly`,(e,t)=>{pk.init(e,t),SD(e._zod,`propValues`,()=>t.innerType._zod.propValues),SD(e._zod,`values`,()=>t.innerType._zod.values),SD(e._zod,`optin`,()=>t.innerType?._zod?.optin),SD(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(TA):TA(r)}});function TA(e){return e.value=Object.freeze(e.value),e}var EA=z(`$ZodLazy`,(e,t)=>{pk.init(e,t),SD(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),SD(e._zod,`pattern`,()=>e._zod.innerType?._zod?.pattern),SD(e._zod,`propValues`,()=>e._zod.innerType?._zod?.propValues),SD(e._zod,`optin`,()=>e._zod.innerType?._zod?.optin??void 0),SD(e._zod,`optout`,()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),DA=z(`$ZodCustom`,(e,t)=>{JO.init(e,t),pk.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>OA(t,n,r,e));OA(i,n,r,e)}});function OA(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(XD(e))}}var kA,AA=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function jA(){return new AA}(kA=globalThis).__zod_globalRegistry??(kA.__zod_globalRegistry=jA());var MA=globalThis.__zod_globalRegistry;function NA(e,t){return new e({type:`string`,...B(t)})}function PA(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...B(t)})}function FA(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...B(t)})}function IA(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...B(t)})}function LA(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...B(t)})}function RA(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...B(t)})}function zA(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...B(t)})}function BA(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...B(t)})}function VA(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...B(t)})}function HA(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...B(t)})}function UA(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...B(t)})}function WA(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...B(t)})}function GA(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...B(t)})}function KA(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...B(t)})}function qA(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...B(t)})}function JA(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...B(t)})}function YA(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...B(t)})}function XA(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...B(t)})}function ZA(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...B(t)})}function QA(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...B(t)})}function $A(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...B(t)})}function ej(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...B(t)})}function tj(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...B(t)})}function nj(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...B(t)})}function rj(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...B(t)})}function ij(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...B(t)})}function aj(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...B(t)})}function oj(e,t){return new e({type:`number`,checks:[],...B(t)})}function sj(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...B(t)})}function cj(e,t){return new e({type:`boolean`,...B(t)})}function lj(e,t){return new e({type:`null`,...B(t)})}function uj(e){return new e({type:`any`})}function dj(e){return new e({type:`unknown`})}function fj(e,t){return new e({type:`never`,...B(t)})}function pj(e,t){return new XO({check:`less_than`,...B(t),value:e,inclusive:!1})}function mj(e,t){return new XO({check:`less_than`,...B(t),value:e,inclusive:!0})}function hj(e,t){return new ZO({check:`greater_than`,...B(t),value:e,inclusive:!1})}function gj(e,t){return new ZO({check:`greater_than`,...B(t),value:e,inclusive:!0})}function _j(e,t){return new QO({check:`multiple_of`,...B(t),value:e})}function vj(e,t){return new ek({check:`max_length`,...B(t),maximum:e})}function yj(e,t){return new tk({check:`min_length`,...B(t),minimum:e})}function bj(e,t){return new nk({check:`length_equals`,...B(t),length:e})}function xj(e,t){return new ik({check:`string_format`,format:`regex`,...B(t),pattern:e})}function Sj(e){return new ak({check:`string_format`,format:`lowercase`,...B(e)})}function Cj(e){return new ok({check:`string_format`,format:`uppercase`,...B(e)})}function wj(e,t){return new sk({check:`string_format`,format:`includes`,...B(t),includes:e})}function Tj(e,t){return new ck({check:`string_format`,format:`starts_with`,...B(t),prefix:e})}function Ej(e,t){return new lk({check:`string_format`,format:`ends_with`,...B(t),suffix:e})}function Dj(e){return new uk({check:`overwrite`,tx:e})}function Oj(e){return Dj(t=>t.normalize(e))}function kj(){return Dj(e=>e.trim())}function Aj(){return Dj(e=>e.toLowerCase())}function jj(){return Dj(e=>e.toUpperCase())}function Mj(){return Dj(e=>ED(e))}function Nj(e,t,n){return new e({type:`array`,element:t,...B(n)})}function Pj(e,t,n){let r=B(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function Fj(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...B(n)})}function Ij(e,t){let n=Lj(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(XD(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(XD(r))}},e(t.value,t)),t);return n}function Lj(e,t){let n=new JO({check:`custom`,...B(t)});return n._zod.check=e,n}function Rj(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??MA,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function zj(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,zj(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&Hj(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Bj(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
82
|
-
|
|
83
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Vj(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Wj(t,`input`,e.processors),output:Wj(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Hj(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Hj(r.element,n);if(r.type===`set`)return Hj(r.valueType,n);if(r.type===`lazy`)return Hj(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return Hj(r.innerType,n);if(r.type===`intersection`)return Hj(r.left,n)||Hj(r.right,n);if(r.type===`record`||r.type===`map`)return Hj(r.keyType,n)||Hj(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Hj(r.in,n)||Hj(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Hj(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Hj(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Hj(e,n))return!0;return!!(r.rest&&Hj(r.rest,n))}return!1}var Uj=(e,t={})=>n=>{let r=Rj({...n,processors:t});return zj(e,r),Bj(r,e),Vj(r,e)},Wj=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Rj({...i??{},target:a,io:t,processors:n});return zj(e,o),Bj(o,e),Vj(o,e)},Gj={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Kj=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Gj[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},qj=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},Jj=(e,t,n,r)=>{n.type=`boolean`},Yj=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`BigInt cannot be represented in JSON Schema`)},Xj=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Symbols cannot be represented in JSON Schema`)},Zj=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},Qj=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},$j=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Void cannot be represented in JSON Schema`)},eM=(e,t,n,r)=>{n.not={}},tM=(e,t,n,r)=>{},nM=(e,t,n,r)=>{},rM=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Date cannot be represented in JSON Schema`)},iM=(e,t,n,r)=>{let i=e._zod.def,a=hD(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},aM=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},oM=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`NaN cannot be represented in JSON Schema`)},sM=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},cM=(e,t,n,r)=>{let i=n,a={type:`string`,format:`binary`,contentEncoding:`binary`},{minimum:o,maximum:s,mime:c}=e._zod.bag;o!==void 0&&(a.minLength=o),s!==void 0&&(a.maxLength=s),c?c.length===1?(a.contentMediaType=c[0],Object.assign(i,a)):(Object.assign(i,a),i.anyOf=c.map(e=>({contentMediaType:e}))):Object.assign(i,a)},lM=(e,t,n,r)=>{n.type=`boolean`},uM=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},dM=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Function types cannot be represented in JSON Schema`)},fM=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},pM=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Map cannot be represented in JSON Schema`)},mM=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Set cannot be represented in JSON Schema`)},hM=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=zj(a.element,t,{...r,path:[...r.path,`items`]})},gM=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=zj(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=zj(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},_M=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>zj(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},vM=(e,t,n,r)=>{let i=e._zod.def,a=zj(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=zj(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},yM=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>zj(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?zj(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null;t.target===`draft-2020-12`?(i.prefixItems=c,l&&(i.items=l)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:d}=e._zod.bag;typeof u==`number`&&(i.minItems=u),typeof d==`number`&&(i.maxItems=d)},bM=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=zj(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=zj(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=zj(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},xM=(e,t,n,r)=>{let i=e._zod.def,a=zj(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},SM=(e,t,n,r)=>{let i=e._zod.def;zj(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},CM=(e,t,n,r)=>{let i=e._zod.def;zj(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},wM=(e,t,n,r)=>{let i=e._zod.def;zj(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},TM=(e,t,n,r)=>{let i=e._zod.def;zj(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},EM=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;zj(o,t,r);let s=t.seen.get(e);s.ref=o},DM=(e,t,n,r)=>{let i=e._zod.def;zj(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},OM=(e,t,n,r)=>{let i=e._zod.def;zj(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},kM=(e,t,n,r)=>{let i=e._zod.def;zj(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},AM=(e,t,n,r)=>{let i=e._zod.innerType;zj(i,t,r);let a=t.seen.get(e);a.ref=i},jM={string:Kj,number:qj,boolean:Jj,bigint:Yj,symbol:Xj,null:Zj,undefined:Qj,void:$j,never:eM,any:tM,unknown:nM,date:rM,enum:iM,literal:aM,nan:oM,template_literal:sM,file:cM,success:lM,custom:uM,function:dM,transform:fM,map:pM,set:mM,array:hM,object:gM,union:_M,intersection:vM,tuple:yM,record:bM,nullable:xM,nonoptional:SM,default:CM,prefault:wM,catch:TM,pipe:EM,readonly:DM,promise:OM,optional:kM,lazy:AM};function MM(e,t){if(`_idmap`in e){let n=e,r=Rj({...t,processors:jM}),i={};for(let e of n._idmap.entries()){let[t,n]=e;zj(n,r)}let a={};r.external={registry:n,uri:t?.uri,defs:i};for(let e of n._idmap.entries()){let[t,n]=e;Bj(r,n),a[t]=Vj(r,n)}return Object.keys(i).length>0&&(a.__shared={[r.target===`draft-2020-12`?`$defs`:`definitions`]:i}),{schemas:a}}let n=Rj({...t,processors:jM});return zj(e,n),Bj(n,e),Vj(n,e)}var NM=z(`ZodISODateTime`,(e,t)=>{Dk.init(e,t),aN.init(e,t)});function PM(e){return nj(NM,e)}var FM=z(`ZodISODate`,(e,t)=>{Ok.init(e,t),aN.init(e,t)});function IM(e){return rj(FM,e)}var LM=z(`ZodISOTime`,(e,t)=>{kk.init(e,t),aN.init(e,t)});function RM(e){return ij(LM,e)}var zM=z(`ZodISODuration`,(e,t)=>{Ak.init(e,t),aN.init(e,t)});function BM(e){return aj(zM,e)}var VM=z(`ZodError`,(e,t)=>{QD.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>tO(e,t)},flatten:{value:t=>eO(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,gD,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,gD,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),HM=nO(VM),UM=rO(VM),WM=iO(VM),GM=oO(VM),KM=cO(VM),qM=lO(VM),JM=uO(VM),YM=dO(VM),XM=fO(VM),ZM=pO(VM),QM=mO(VM),$M=hO(VM),eN=new WeakMap;function tN(e,t,n){let r=Object.getPrototypeOf(e),i=eN.get(r);if(i||(i=new Set,eN.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var nN=z(`ZodType`,(e,t)=>(pk.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:Wj(e,`input`),output:Wj(e,`output`)}}),e.toJSONSchema=Uj(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>HM(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>WM(e,t,n),e.parseAsync=async(t,n)=>UM(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>GM(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>KM(e,t,n),e.decode=(t,n)=>qM(e,t,n),e.encodeAsync=async(t,n)=>JM(e,t,n),e.decodeAsync=async(t,n)=>YM(e,t,n),e.safeEncode=(t,n)=>XM(e,t,n),e.safeDecode=(t,n)=>ZM(e,t,n),e.safeEncodeAsync=async(t,n)=>QM(e,t,n),e.safeDecodeAsync=async(t,n)=>$M(e,t,n),tN(e,`ZodType`,{check(...e){let t=this.def;return this.clone(wD(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return PD(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(EP(e,t))},superRefine(e,t){return this.check(DP(e,t))},overwrite(e){return this.check(Dj(e))},optional(){return aP(this)},exactOptional(){return sP(this)},nullable(){return lP(this)},nullish(){return aP(lP(this))},nonoptional(e){return hP(this,e)},array(){return BN(this)},or(e){return GN([this,e])},and(e){return YN(this,e)},transform(e){return yP(this,rP(e))},default(e){return dP(this,e)},prefault(e){return pP(this,e)},catch(e){return _P(this,e)},pipe(e){return yP(this,e)},readonly(){return xP(this)},describe(e){let t=this.clone();return MA.add(t,{description:e}),t},meta(...e){if(e.length===0)return MA.get(this);let t=this.clone();return MA.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return MA.get(e)?.description},configurable:!0}),e)),rN=z(`_ZodString`,(e,t)=>{mk.init(e,t),nN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Kj(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,tN(e,`_ZodString`,{regex(...e){return this.check(xj(...e))},includes(...e){return this.check(wj(...e))},startsWith(...e){return this.check(Tj(...e))},endsWith(...e){return this.check(Ej(...e))},min(...e){return this.check(yj(...e))},max(...e){return this.check(vj(...e))},length(...e){return this.check(bj(...e))},nonempty(...e){return this.check(yj(1,...e))},lowercase(e){return this.check(Sj(e))},uppercase(e){return this.check(Cj(e))},trim(){return this.check(kj())},normalize(...e){return this.check(Oj(...e))},toLowerCase(){return this.check(Aj())},toUpperCase(){return this.check(jj())},slugify(){return this.check(Mj())}})}),iN=z(`ZodString`,(e,t)=>{mk.init(e,t),rN.init(e,t),e.email=t=>e.check(PA(oN,t)),e.url=t=>e.check(BA(lN,t)),e.jwt=t=>e.check(tj(wN,t)),e.emoji=t=>e.check(VA(uN,t)),e.guid=t=>e.check(FA(sN,t)),e.uuid=t=>e.check(IA(cN,t)),e.uuidv4=t=>e.check(LA(cN,t)),e.uuidv6=t=>e.check(RA(cN,t)),e.uuidv7=t=>e.check(zA(cN,t)),e.nanoid=t=>e.check(HA(dN,t)),e.guid=t=>e.check(FA(sN,t)),e.cuid=t=>e.check(UA(fN,t)),e.cuid2=t=>e.check(WA(pN,t)),e.ulid=t=>e.check(GA(mN,t)),e.base64=t=>e.check(QA(xN,t)),e.base64url=t=>e.check($A(SN,t)),e.xid=t=>e.check(KA(hN,t)),e.ksuid=t=>e.check(qA(gN,t)),e.ipv4=t=>e.check(JA(_N,t)),e.ipv6=t=>e.check(YA(vN,t)),e.cidrv4=t=>e.check(XA(yN,t)),e.cidrv6=t=>e.check(ZA(bN,t)),e.e164=t=>e.check(ej(CN,t)),e.datetime=t=>e.check(PM(t)),e.date=t=>e.check(IM(t)),e.time=t=>e.check(RM(t)),e.duration=t=>e.check(BM(t))});function V(e){return NA(iN,e)}var aN=z(`ZodStringFormat`,(e,t)=>{hk.init(e,t),rN.init(e,t)}),oN=z(`ZodEmail`,(e,t)=>{vk.init(e,t),aN.init(e,t)}),sN=z(`ZodGUID`,(e,t)=>{gk.init(e,t),aN.init(e,t)}),cN=z(`ZodUUID`,(e,t)=>{_k.init(e,t),aN.init(e,t)}),lN=z(`ZodURL`,(e,t)=>{yk.init(e,t),aN.init(e,t)}),uN=z(`ZodEmoji`,(e,t)=>{bk.init(e,t),aN.init(e,t)}),dN=z(`ZodNanoID`,(e,t)=>{xk.init(e,t),aN.init(e,t)}),fN=z(`ZodCUID`,(e,t)=>{Sk.init(e,t),aN.init(e,t)}),pN=z(`ZodCUID2`,(e,t)=>{Ck.init(e,t),aN.init(e,t)}),mN=z(`ZodULID`,(e,t)=>{wk.init(e,t),aN.init(e,t)}),hN=z(`ZodXID`,(e,t)=>{Tk.init(e,t),aN.init(e,t)}),gN=z(`ZodKSUID`,(e,t)=>{Ek.init(e,t),aN.init(e,t)}),_N=z(`ZodIPv4`,(e,t)=>{jk.init(e,t),aN.init(e,t)}),vN=z(`ZodIPv6`,(e,t)=>{Mk.init(e,t),aN.init(e,t)}),yN=z(`ZodCIDRv4`,(e,t)=>{Nk.init(e,t),aN.init(e,t)}),bN=z(`ZodCIDRv6`,(e,t)=>{Pk.init(e,t),aN.init(e,t)}),xN=z(`ZodBase64`,(e,t)=>{Ik.init(e,t),aN.init(e,t)}),SN=z(`ZodBase64URL`,(e,t)=>{Rk.init(e,t),aN.init(e,t)}),CN=z(`ZodE164`,(e,t)=>{zk.init(e,t),aN.init(e,t)}),wN=z(`ZodJWT`,(e,t)=>{Vk.init(e,t),aN.init(e,t)}),TN=z(`ZodNumber`,(e,t)=>{Hk.init(e,t),nN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qj(e,t,n,r),tN(e,`ZodNumber`,{gt(e,t){return this.check(hj(e,t))},gte(e,t){return this.check(gj(e,t))},min(e,t){return this.check(gj(e,t))},lt(e,t){return this.check(pj(e,t))},lte(e,t){return this.check(mj(e,t))},max(e,t){return this.check(mj(e,t))},int(e){return this.check(ON(e))},safe(e){return this.check(ON(e))},positive(e){return this.check(hj(0,e))},nonnegative(e){return this.check(gj(0,e))},negative(e){return this.check(pj(0,e))},nonpositive(e){return this.check(mj(0,e))},multipleOf(e,t){return this.check(_j(e,t))},step(e,t){return this.check(_j(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function EN(e){return oj(TN,e)}var DN=z(`ZodNumberFormat`,(e,t)=>{Uk.init(e,t),TN.init(e,t)});function ON(e){return sj(DN,e)}var kN=z(`ZodBoolean`,(e,t)=>{Wk.init(e,t),nN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Jj(e,t,n,r)});function AN(e){return cj(kN,e)}var jN=z(`ZodNull`,(e,t)=>{Gk.init(e,t),nN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Zj(e,t,n,r)});function MN(e){return lj(jN,e)}var NN=z(`ZodAny`,(e,t)=>{Kk.init(e,t),nN.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function PN(){return uj(NN)}var FN=z(`ZodUnknown`,(e,t)=>{qk.init(e,t),nN.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function IN(){return dj(FN)}var LN=z(`ZodNever`,(e,t)=>{Jk.init(e,t),nN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>eM(e,t,n,r)});function RN(e){return fj(LN,e)}var zN=z(`ZodArray`,(e,t)=>{Xk.init(e,t),nN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hM(e,t,n,r),e.element=t.element,tN(e,`ZodArray`,{min(e,t){return this.check(yj(e,t))},nonempty(e){return this.check(yj(1,e))},max(e,t){return this.check(vj(e,t))},length(e,t){return this.check(bj(e,t))},unwrap(){return this.element}})});function BN(e,t){return Nj(zN,e,t)}var VN=z(`ZodObject`,(e,t)=>{tA.init(e,t),nN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gM(e,t,n,r),SD(e,`shape`,()=>t.shape),tN(e,`ZodObject`,{keyof(){return $N(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:IN()})},loose(){return this.clone({...this._zod.def,catchall:IN()})},strict(){return this.clone({...this._zod.def,catchall:RN()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return zD(this,e)},safeExtend(e){return BD(this,e)},merge(e){return VD(this,e)},pick(e){return LD(this,e)},omit(e){return RD(this,e)},partial(...e){return HD(iP,this,e[0])},required(...e){return UD(mP,this,e[0])}})});function HN(e,t){return new VN({type:`object`,shape:e??{},...B(t)})}function UN(e,t){return new VN({type:`object`,shape:e,catchall:IN(),...B(t)})}var WN=z(`ZodUnion`,(e,t)=>{rA.init(e,t),nN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_M(e,t,n,r),e.options=t.options});function GN(e,t){return new WN({type:`union`,options:e,...B(t)})}var KN=z(`ZodDiscriminatedUnion`,(e,t)=>{WN.init(e,t),iA.init(e,t)});function qN(e,t,n){return new KN({type:`union`,options:t,discriminator:e,...B(n)})}var JN=z(`ZodIntersection`,(e,t)=>{aA.init(e,t),nN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vM(e,t,n,r)});function YN(e,t){return new JN({type:`intersection`,left:e,right:t})}var XN=z(`ZodRecord`,(e,t)=>{cA.init(e,t),nN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bM(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function ZN(e,t,n){return!t||!t._zod?new XN({type:`record`,keyType:V(),valueType:e,...B(t)}):new XN({type:`record`,keyType:e,valueType:t,...B(n)})}var QN=z(`ZodEnum`,(e,t)=>{lA.init(e,t),nN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>iM(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new QN({...t,checks:[],...B(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new QN({...t,checks:[],...B(r),entries:i})}});function $N(e,t){return new QN({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...B(t)})}var eP=z(`ZodLiteral`,(e,t)=>{uA.init(e,t),nN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>aM(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function tP(e,t){return new eP({type:`literal`,values:Array.isArray(e)?e:[e],...B(t)})}var nP=z(`ZodTransform`,(e,t)=>{dA.init(e,t),nN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fM(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new fD(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(XD(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(XD(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function rP(e){return new nP({type:`transform`,transform:e})}var iP=z(`ZodOptional`,(e,t)=>{pA.init(e,t),nN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>kM(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function aP(e){return new iP({type:`optional`,innerType:e})}var oP=z(`ZodExactOptional`,(e,t)=>{mA.init(e,t),nN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>kM(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function sP(e){return new oP({type:`optional`,innerType:e})}var cP=z(`ZodNullable`,(e,t)=>{hA.init(e,t),nN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xM(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function lP(e){return new cP({type:`nullable`,innerType:e})}var uP=z(`ZodDefault`,(e,t)=>{gA.init(e,t),nN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>CM(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function dP(e,t){return new uP({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():jD(t)}})}var fP=z(`ZodPrefault`,(e,t)=>{vA.init(e,t),nN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wM(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function pP(e,t){return new fP({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():jD(t)}})}var mP=z(`ZodNonOptional`,(e,t)=>{yA.init(e,t),nN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>SM(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function hP(e,t){return new mP({type:`nonoptional`,innerType:e,...B(t)})}var gP=z(`ZodCatch`,(e,t)=>{xA.init(e,t),nN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>TM(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function _P(e,t){return new gP({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var vP=z(`ZodPipe`,(e,t)=>{SA.init(e,t),nN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>EM(e,t,n,r),e.in=t.in,e.out=t.out});function yP(e,t){return new vP({type:`pipe`,in:e,out:t})}var bP=z(`ZodReadonly`,(e,t)=>{wA.init(e,t),nN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>DM(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function xP(e){return new bP({type:`readonly`,innerType:e})}var SP=z(`ZodLazy`,(e,t)=>{EA.init(e,t),nN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>AM(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function CP(e){return new SP({type:`lazy`,getter:e})}var wP=z(`ZodCustom`,(e,t)=>{DA.init(e,t),nN.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uM(e,t,n,r)});function TP(e,t){return Pj(wP,e??(()=>!0),t)}function EP(e,t={}){return Fj(wP,e,t)}function DP(e,t){return Ij(e,t)}function OP(e,t={}){let n=new wP({type:`custom`,check:`custom`,fn:t=>t instanceof e,abort:!0,...B(t)});return n._zod.bag.Class=e,n._zod.check=t=>{t.value instanceof e||t.issues.push({code:`invalid_type`,expected:e.name,input:t.value,inst:n,path:[...n._zod.def.path??[]]})},n}var kP=HN({query:V().min(1).describe(`User message content`),inputs:ZN(V(),V()).default({}).describe(`Custom variables`),response_mode:$N([`streaming`,`blocking`]).default(`streaming`),user:V().min(1).describe(`User identifier`),conversation_id:V().optional().describe(`Conversation ID for resuming`)}),AP=GN([HN({event:tP(`message`),message_id:V(),conversation_id:V(),answer:V().describe(`Current reply text fragment (streaming accumulation)`),created_at:EN().optional()}),HN({event:tP(`message_end`),message_id:V(),conversation_id:V(),metadata:ZN(V(),IN()).optional()}),HN({event:tP(`agent_thought`),id:V().optional(),thought:V().optional().describe(`Thought content`),observation:V().optional().describe(`Observation result`),tool:V().optional().describe(`Tool name`),tool_input:V().optional().describe(`Tool input`),message_files:BN(IN()).optional()}),HN({event:tP(`error`),code:V().optional(),message:V(),status:EN().optional()}),HN({event:tP(`ping`)}),HN({event:tP(`workflow_started`),conversation_id:V(),message_id:V(),created_at:EN(),task_id:V(),workflow_run_id:V(),data:HN({id:V(),workflow_id:V(),inputs:ZN(V(),IN()),created_at:EN(),reason:V().optional()})}),HN({event:tP(`node_started`),conversation_id:V(),message_id:V(),created_at:EN(),task_id:V(),workflow_run_id:V(),data:HN({id:V(),node_id:V(),node_type:V(),title:V(),index:EN(),predecessor_node_id:V().nullable(),inputs:IN().nullable(),inputs_truncated:AN(),created_at:EN(),extras:ZN(V(),IN()),iteration_id:V().nullable(),loop_id:V().nullable(),agent_strategy:V().nullable()})}),HN({event:tP(`node_finished`),conversation_id:V(),message_id:V(),created_at:EN(),task_id:V(),workflow_run_id:V(),data:HN({id:V(),node_id:V(),node_type:V(),title:V(),index:EN(),predecessor_node_id:V().nullable(),inputs:ZN(V(),IN()),inputs_truncated:AN(),process_data:ZN(V(),IN()),process_data_truncated:AN(),outputs:ZN(V(),IN()),outputs_truncated:AN(),status:V(),error:V().nullable(),elapsed_time:EN(),execution_metadata:IN().nullable(),created_at:EN(),finished_at:EN(),files:BN(IN()),iteration_id:V().nullable(),loop_id:V().nullable()})}),HN({event:tP(`workflow_finished`),conversation_id:V(),message_id:V(),created_at:EN(),task_id:V(),workflow_run_id:V(),data:HN({id:V(),workflow_id:V(),status:V(),outputs:ZN(V(),IN()),error:V().nullable(),elapsed_time:EN(),total_tokens:EN(),total_steps:EN(),created_by:HN({id:V(),user:V()}),created_at:EN(),finished_at:EN(),exceptions_count:EN(),files:BN(IN())})})]),jP=e=>{if(!e.startsWith(`data:`))return null;let t=e.slice(5).trim();if(!t)return null;try{let e=JSON.parse(t),n=AP.safeParse(e);return n.success?n.data:null}catch{return null}},MP=e=>{let t=e.getReader(),n=new TextDecoder,r=``;return{async*[Symbol.asyncIterator](){try{for(;;){let{done:e,value:i}=await t.read();if(e){if(r.trim()){let e=jP(r);e&&(yield e)}return}r+=n.decode(i,{stream:!0});let a=r.split(`
|
|
84
|
-
`);r=a.pop()??``;for(let e of a){let t=e.trim();if(!t)continue;let n=jP(t);n&&(yield n)}}}finally{t.releaseLock()}}}},NP=e=>{let t={query:e.query,inputs:e.inputs??{},response_mode:`streaming`,user:e.user,conversation_id:e.conversationId},n=kP.safeParse(t);if(!n.success)throw Error(`Dify request validation failed: ${n.error.message}`);return n.data},PP=async e=>{lD();let t=NP(e),n=await fetch(oD.DIFY_CHAT_MESSAGES,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${cD.apiKey}`},body:JSON.stringify(t)});if(!n.ok){let e=await n.text().catch(()=>`Unknown error`);throw Error(`Dify API request failed (${n.status}): ${e}`)}if(!n.body)throw Error(`Dify API returned empty response body`);return MP(n.body)},FP=`ai-assist-conversation-id`,IP=`ai-assist-session-id`,LP=`ai-assist-history`,RP=50,zP=()=>{try{return sessionStorage.getItem(FP)}catch{return null}},BP=e=>{try{sessionStorage.setItem(FP,e)}catch{}},VP=()=>{try{let e=sessionStorage.getItem(IP);if(e)return e;let t=`anonymous_${crypto.randomUUID()}`;return sessionStorage.setItem(IP,t),t}catch{return`anonymous_${Date.now()}`}},HP=()=>{try{sessionStorage.removeItem(FP)}catch{}},UP=()=>{try{let e=localStorage.getItem(LP);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}},WP=(e,t)=>{try{let n=UP(),r={conversationId:e,lastMessage:t,timestamp:Date.now()},i=n.filter(t=>t.conversationId!==e);i.unshift(r),localStorage.setItem(LP,JSON.stringify(i.slice(0,RP)))}catch{}},GP=`ai-assist-last-action-result`,KP=e=>{try{sessionStorage.setItem(GP,e)}catch{}},qP=()=>{try{return sessionStorage.getItem(GP)!==null}catch{return!1}},JP=()=>{try{let e=sessionStorage.getItem(GP)??``;return sessionStorage.removeItem(GP),e}catch{return``}},YP=e=>({log:(...e)=>void 0,warn:(...e)=>void 0,error:(...e)=>void 0}),XP=/```action\s*([\s\S]*?)```/g,ZP=YP(`[action-parser]`),QP=e=>{ZP.log(`Parse start, input text length:`,e.length),ZP.log(`Raw text preview:`,e.slice(0,200));let t=[];XP.lastIndex=0;let n=/```action/.test(e);ZP.log("Has ```action marker:",n);let r=(e.match(/```/g)||[]).length;if(ZP.log(`Code fence count:`,r,`(should be even for balanced fences)`),!n)return ZP.log("Parse failed: no ```action marker found in text"),ZP.log(`Parse end, result count:`,0),[];(r<2||r%2!=0)&&ZP.warn(`Unbalanced code fences detected`);let i=0,a;for(;(a=XP.exec(e))!==null;){i++,ZP.log(`--- Matched action block #${i} ---`),ZP.log(`Match position: index=`,a.index,`~`,a.index+a[0].length);let e=a[1].trim();if(ZP.log(`Extracted JSON string:`,e),!e){ZP.log(`Skipped: empty JSON content`);continue}try{let n=JSON.parse(e);ZP.log(`JSON parsed successfully:`,n),$P(n)?(ZP.log(`Validation passed:`,n),t.push(n)):(ZP.warn(`Validation failed: missing tool or params field, or wrong type`),ZP.warn(`Expected structure: { tool: string, params: object }`),ZP.warn(`Actual structure:`,JSON.stringify(n,null,2)))}catch(t){ZP.error(`JSON parse failed:`,t instanceof Error?t.message:t),ZP.error(`Raw string:`,e)}}return ZP.log(`Regex match complete, matched`,i,`action blocks`),ZP.log(`Valid action count:`,t.length),t.length===0&&i===0&&(ZP.warn("Parse failed: regex did not match a complete ```action ... ``` structure"),ZP.warn(`Possible causes:`),ZP.warn(" 1. Missing closing ``` marker"),ZP.warn(" 2. Extra characters between ``` and action"),ZP.warn(" 3. Dify reply node not wrapped in ```action")),ZP.log(`Parse end`),t},$P=e=>{if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.tool==`string`&&typeof t.params==`object`&&t.params!==null},eF=e=>e.replace(XP,``).trim(),tF=[{name:`click_element`,description:`Click on a page element, such as add-to-cart button, navigation link, etc. (requires user confirmation)`,parameters:{data_attributes:`data-* attribute selector (e.g. [data-assistant-action='add-to-cart'])`,css_selector:`PRIMARY selector - direct CSS selector from the interactive elements table's '最佳选择器' column (e.g. .btn-orange.px-3). Fill this first.`,text_match:`Exact visible text of the element (e.g. 'Add to Cart'). Fill from '元素文本' column.`,anchor_context:`FALLBACK only - JSON: { anchorText: 'nearby product title text from 父链上下文 column', targetSelector: 'simple tag name like button or a' }. Only use when css_selector and text_match are insufficient.`,confirmRequired:`true (always requires user confirmation for click)`}},{name:`fill_input`,description:`Fill content into an input field, such as search box, form field, etc. (auto-execute)`,parameters:{data_attributes:`data-* attribute selector (e.g. [data-assistant-action='search-input'])`,css_selector:`PRIMARY selector - direct CSS selector from the interactive elements table's '最佳选择器' column`,text_match:`Input placeholder or label text. Fill from '元素文本' column.`,anchor_context:`FALLBACK only - JSON: { anchorText: 'label text', targetSelector: 'input' }`,value:`Content to fill (required)`}},{name:`scroll_to`,description:`Scroll the page to a specified element or position (auto-execute)`,parameters:{data_attributes:`data-* attribute selector for target element`,css_selector:`PRIMARY selector - direct CSS selector from the interactive elements table's '最佳选择器' column`,text_match:`Text content of the element to scroll to. Fill from '元素文本' column.`,anchor_context:`FALLBACK only - JSON: { anchorText: 'anchor text', targetSelector: 'simple tag name' }`,position:`Scroll position: top or bottom (alternative to element selectors)`}},{name:`navigate_to`,description:`Navigate to a specified URL (requires user confirmation)`,parameters:{url:`Target URL (required)`}},{name:`highlight_element`,description:`Highlight a page element to draw user attention (auto-execute)`,parameters:{data_attributes:`data-* attribute selector`,css_selector:`PRIMARY selector - direct CSS selector from the interactive elements table's '最佳选择器' column`,text_match:`Visible text of the element. Fill from '元素文本' column.`,anchor_context:`FALLBACK only - JSON: { anchorText: 'anchor text', targetSelector: 'simple tag name' }`}}],nF=JSON.stringify(tF);`
|
|
85
|
-
## Available Tools
|
|
86
|
-
|
|
87
|
-
You can use the following tools to help users interact with web pages. When an action needs to be performed, embed an instruction block in the reply using the following format:
|
|
88
|
-
|
|
89
|
-
\`\`\`action
|
|
90
|
-
{
|
|
91
|
-
"tool": "tool_name",
|
|
92
|
-
"params": { ... }
|
|
93
|
-
}
|
|
94
|
-
\`\`\`
|
|
95
|
-
|
|
96
|
-
### Tool List
|
|
97
|
-
|
|
98
|
-
${tF.map(e=>`
|
|
99
|
-
#### ${e.name}
|
|
100
|
-
${e.description}
|
|
101
|
-
Parameters: ${JSON.stringify(e.parameters)}`).join(`
|
|
102
|
-
`)}
|
|
103
|
-
|
|
104
|
-
### Usage Rules
|
|
105
|
-
1. Each reply may contain at most one instruction block
|
|
106
|
-
2. Instruction blocks must be wrapped in \`\`\`action
|
|
107
|
-
3. Parameter values must be strings (except anchor_context which is a JSON object)
|
|
108
|
-
4. Element location priority: css_selector > text_match > data_attributes > anchor_context
|
|
109
|
-
5. Use anchor_context ONLY when css_selector and text_match cannot uniquely identify the element (e.g. product cards with identical buttons)
|
|
110
|
-
6. click_element and navigate_to require user confirmation before execution
|
|
111
|
-
7. fill_input, scroll_to, and highlight_element execute automatically`.trim();var rF=YP(`[action-resolver]`),iF=e=>{let t=window.getComputedStyle(e);if(t.display===`none`||t.visibility===`hidden`||t.opacity===`0`)return!1;let n=e.getBoundingClientRect();return n.width>0&&n.height>0},aF=e=>{try{let t=document.querySelector(e);if(t&&iF(t))return t}catch{rF.log(`[strategy-1] invalid data_attributes selector:`,e)}return null},oF=(e,t)=>{if(!e)return null;let n=e.trim(),r=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT,{acceptNode:e=>e.textContent?.trim().includes(n)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}).nextNode();if(!r?.parentElement)return null;let i=r.parentElement;if(!iF(i))return null;let a=i.parentElement;for(let e=0;e<6&&a&&a!==document.body;e++){let e=a.querySelector(t);if(e&&iF(e))return e;a=a.parentElement}return null},sF=(e=``)=>{let t=e.trim(),n=Array.from(document.querySelectorAll(`button, a, [role="button"], input[type="submit"], input[type="button"]`));for(let e of n)if((e.textContent||``).trim()===t&&iF(e))return e;for(let e of n)if((e.textContent||``).trim().includes(t)&&iF(e))return e;return null},cF=e=>{try{let t=document.querySelector(e);if(t&&iF(t))return t}catch{rF.log(`[strategy-4] invalid css_selector:`,e)}return null},lF=e=>{if(rF.log(`[resolveElement] params:`,e),e.dataAttributes){let t=aF(e.dataAttributes);if(t)return{element:t,strategy:`data-attribute`}}if(e.anchorContext){let t=oF(e.anchorContext.anchorText,e.anchorContext.targetSelector);if(t)return{element:t,strategy:`anchor-context`}}if(e.textMatch){let t=sF(e.textMatch);if(t)return{element:t,strategy:`text-match`}}if(e.cssSelector){let t=cF(e.cssSelector);if(t)return{element:t,strategy:`css-selector`}}return null},uF=async e=>{let{element:t}=e;if(!t)return{success:!1,error:`element_not_found`,message:`Target element not found`};if(t.hasAttribute(`disabled`)||t.getAttribute(`aria-disabled`)===`true`)return{success:!1,error:`element_not_interactable`,message:`Element is disabled, cannot click`};let n=t.getBoundingClientRect();if(n.width===0||n.height===0)return{success:!1,error:`element_not_visible`,message:`Element is not visible, cannot click`};try{return t.scrollIntoView({behavior:`smooth`,block:`center`}),await new Promise(e=>setTimeout(e,300)),t.click(),{success:!0,message:`Clicked element: ${t.tagName.toLowerCase()}${t.id?`#${t.id}`:``}`,data:{tagName:t.tagName.toLowerCase(),text:(t.textContent||``).trim().slice(0,50)}}}catch(e){return{success:!1,error:`click_failed`,message:`Click failed: ${e instanceof Error?e.message:`Unknown error`}`}}},dF=async e=>{let{element:t,value:n}=e;if(!t)return{success:!1,error:`element_not_found`,message:`Target input element not found`};if(!(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t.getAttribute(`contenteditable`)===`true`))return{success:!1,error:`element_not_input`,message:`Target element is not an input`};if(!n)return{success:!1,error:`value_required`,message:`A value parameter is required for fill`};try{if(t.focus(),t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement){let e=Object.getOwnPropertyDescriptor(t instanceof HTMLInputElement?HTMLInputElement.prototype:HTMLTextAreaElement.prototype,`value`)?.set;e?e.call(t,n):t.value=n,t.dispatchEvent(new Event(`input`,{bubbles:!0})),t.dispatchEvent(new Event(`change`,{bubbles:!0}))}return{success:!0,message:`Filled with: "${n}"`,data:{value:n}}}catch(e){return{success:!1,error:`fill_failed`,message:`Fill failed: ${e instanceof Error?e.message:`Unknown error`}`}}},fF=async e=>{let{element:t,position:n}=e;try{if(t)return t.scrollIntoView({behavior:`smooth`,block:`center`}),{success:!0,message:`Scrolled to target element`,data:{tagName:t.tagName.toLowerCase(),text:(t.textContent||``).trim().slice(0,50)}};if(n){let e={behavior:`smooth`};switch(n){case`top`:e.top=0;break;case`bottom`:e.top=document.documentElement.scrollHeight;break;default:return{success:!1,error:`invalid_position`,message:`Unsupported position: ${n} (only top/bottom allowed)`}}return window.scrollTo(e),{success:!0,message:n===`top`?`Scrolled to page top`:`Scrolled to page bottom`}}return{success:!1,error:`missing_target`,message:`element or position parameter is required`}}catch(e){return{success:!1,error:`scroll_failed`,message:`Scroll failed: ${e instanceof Error?e.message:`Unknown error`}`}}},pF=async e=>{let{url:t}=e;if(!t)return{success:!1,error:`url_required`,message:`URL is required for navigation`};try{let e=new URL(t,window.location.href);return window.location.href=e.href,{success:!0,message:`Navigating to: ${e.href}`,data:{url:e.href}}}catch(e){return{success:!1,error:`invalid_url`,message:`Invalid URL: ${e instanceof Error?e.message:`Unknown error`}`}}},mF=`ai-assistant-highlight`,hF=()=>{if(document.getElementById(`ai-assistant-highlight-style`))return;let e=document.createElement(`style`);e.id=`ai-assistant-highlight-style`,e.textContent=`
|
|
112
|
-
.${mF} {
|
|
113
|
-
outline: 3px solid #3b82f6 !important;
|
|
114
|
-
outline-offset: 2px !important;
|
|
115
|
-
box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.3) !important;
|
|
116
|
-
transition: outline 0.3s, box-shadow 0.3s !important;
|
|
117
|
-
}
|
|
118
|
-
`,document.head.appendChild(e)},gF=()=>{document.querySelectorAll(`.${mF}`).forEach(e=>{e.classList.remove(mF)})},_F=async e=>{let{element:t}=e;if(!t)return{success:!1,error:`element_not_found`,message:`Target element not found`};try{return hF(),gF(),t.scrollIntoView({behavior:`smooth`,block:`center`}),await new Promise(e=>setTimeout(e,300)),t.classList.add(mF),setTimeout(()=>{t.classList.remove(mF)},5e3),{success:!0,message:`Element highlighted`,data:{tagName:t.tagName.toLowerCase(),text:(t.textContent||``).trim().slice(0,50)}}}catch(e){return{success:!1,error:`highlight_failed`,message:`Highlight failed: ${e instanceof Error?e.message:`Unknown error`}`}}},vF=class e{static findMainContent(t){return t.querySelector(`main, [role="main"]`)||(t.body?e.detectMainContent(t.body):t.documentElement)}static detectMainContent(t){let n=[];if(e.collectCandidates(t,n,15),n.length===0)return t;n.sort((t,n)=>e.calculateContentScore(n)-e.calculateContentScore(t));let r=n[0];for(let t=1;t<n.length;t++){let i=n[t];!n.some((e,n)=>n!==t&&e.contains(i))&&e.calculateContentScore(i)>e.calculateContentScore(r)&&(r=i)}return r}static collectCandidates(t,n,r){e.calculateContentScore(t)>=r&&n.push(t),Array.from(t.children).forEach(t=>{e.collectCandidates(t,n,r)})}static calculateContentScore(t){let n=0;[`article`,`content`,`main-container`,`main`,`main-content`,`post`,`entry`].forEach(e=>{t.classList.contains(e)&&(n+=10)}),[`content`,`main`,`article`,`post`,`entry`].forEach(e=>{t.id?.toLowerCase().includes(e)&&(n+=10)});let r=t.tagName.toLowerCase();[`article`,`main`,`section`].includes(r)&&(n+=8);let i=t.getElementsByTagName(`p`).length;n+=Math.min(i*2,10);let a=t.querySelectorAll(`h1, h2, h3`).length;n+=Math.min(a*3,9);let o=t.textContent?.trim().length||0;o>300&&(n+=Math.min(Math.floor(o/300)*2,10));let s=e.calculateLinkDensity(t);s<.3?n+=5:s>.5&&(n-=5),(t.hasAttribute(`data-main`)||t.hasAttribute(`data-content`)||t.hasAttribute(`itemprop`))&&(n+=8);let c=t.getAttribute(`role`);return(c===`main`||c===`article`)&&(n+=10),t.matches(`aside, nav, header, footer, .sidebar, .navigation, .menu, .ad, .advertisement`)&&(n-=10),t.getElementsByTagName(`form`).length>2&&(n-=5),Math.max(0,n)}static calculateLinkDensity(e){let t=e.getElementsByTagName(`a`),n=0;for(let e of Array.from(t))n+=e.textContent?.length||0;let r=e.textContent?.length||1;return n/r}static isNavigation(e){if(e.tagName.toLowerCase()===`nav`||e.getAttribute(`role`)===`navigation`)return!0;let t=[/nav/i,/menu/i,/sidebar/i,/toolbar/i],n=`${e.className} ${e.id}`.toLowerCase();return t.some(e=>e.test(n))}static isSupplementary(e){if(e.tagName.toLowerCase()===`aside`||e.getAttribute(`role`)===`complementary`)return!0;let t=[/sidebar/i,/widget/i,/related/i,/advertisement/i,/social/i],n=`${e.className} ${e.id}`.toLowerCase();return t.some(e=>e.test(n))}static detectLandmarks(e){let t={navigation:[],main:[],complementary:[],contentinfo:[],banner:[],search:[],form:[],region:[]};for(let[n,r]of Object.entries({navigation:`nav, [role="navigation"]`,main:`main, [role="main"]`,complementary:`aside, [role="complementary"]`,contentinfo:`footer, [role="contentinfo"]`,banner:`header, [role="banner"]`,search:`[role="search"]`,form:`form[aria-label], form[aria-labelledby], [role="form"]`,region:`section[aria-label], section[aria-labelledby], [role="region"]`})){let i=e.querySelectorAll(r);t[n]=Array.from(i)}return t}};function yF(e,t){let n=(e??``).trim();if(!t||n.length<=t)return n;let r=[`login`,`log in`,`sign in`,`sign up`,`submit`,`search`,`filter`,`add to cart`,`next`,`continue`],i=n.toLowerCase(),a=r.map(e=>({k:e,i:i.indexOf(e)})).find(e=>e.i>-1),o=Math.max(0,Math.floor(t*.66));if(a&&a.i>o){let e=Math.max(12,t-o-5),r=Math.max(0,a.i-Math.floor(e/2)),i=Math.min(n.length,r+e);return`${n.slice(0,o).trimEnd()} … ${n.slice(r,i).trim()}…`}let s=n.slice(0,t),c=s.lastIndexOf(` `);return`${c>32?s.slice(0,c):s}…`}function bF(e){let t=5381;for(let n=0;n<e.length;n++)t=t*33^e.charCodeAt(n);return`sec-${(t>>>0).toString(36)}`}function xF(e){switch(e){case`header`:return`🧭`;case`navigation`:return`📑`;case`main`:return`📄`;case`sections`:return`🗂️`;case`sidebar`:return`📚`;case`footer`:return`🔻`;case`modals`:return`💬`;default:return`🔹`}}function SF(e,t){let n=yF(e.text||e.attributes?.ariaLabel,t?.maxTextLength??80),r=e.selector?.css||``,i=e.tag.toLowerCase(),a=e.interaction?.submit?`submit`:e.interaction?.click?`click`:e.interaction?.change?`change`:void 0,o=a?` (${a})`:``;return`- ${i.toUpperCase()}: ${n||`(no text)`} → \`${r}\`${o}`}function CF(e){let t=[];t.push(...e.buttons.map(e=>e.selector?.css||``)),t.push(...e.links.map(e=>e.selector?.css||``)),t.push(...e.inputs.map(e=>e.selector?.css||``)),t.push(...e.clickable.map(e=>e.selector?.css||``));let n=t.length||1,r=t.filter(e=>e.startsWith(`#`)).length,i=t.filter(e=>/\[data-testid=/.test(e)).length,a=t.filter(e=>/:nth-child\(/.test(e)).length,o=r+i;return`Selector quality: ${Math.round(o/n*100)}% stable (ID/data-testid), ${Math.round(a/n*100)}% structural (:nth-child)`}function wF(e,t){let n=[],r=e=>typeof t?.maxElements==`number`?e.slice(0,t.maxElements):e;if(e.buttons.length){n.push(`Buttons:`);for(let i of r(e.buttons))n.push(SF(i,t))}if(e.links.length){n.push(`Links:`);for(let i of r(e.links))n.push(SF(i,t))}if(e.inputs.length){n.push(`Inputs:`);for(let i of r(e.inputs))n.push(SF(i,t))}if(e.clickable.length){n.push(`Other Clickable:`);for(let i of r(e.clickable))n.push(SF(i,t))}if(e.forms.length){n.push(`Forms:`);for(let t of r(e.forms))n.push(`- FORM: action=${t.action??`-`} method=${t.method??`-`} → \`${t.selector}\``)}return n.join(`
|
|
119
|
-
`)}function TF(e){let t=xF(`region`),n=bF(`${e.selector}|${e.label??``}|${e.role??``}`),r=e.label?` ${e.label}`:``,i=[];e.buttonCount&&i.push(`${e.buttonCount} buttons`),e.linkCount&&i.push(`${e.linkCount} links`),e.inputCount&&i.push(`${e.inputCount} inputs`),e.textPreview&&i.push(`“${yF(e.textPreview,80)}”`);let a=i.length?` — ${i.join(`, `)}`:``;return`${t} ${r} → \`${e.selector}\` [${n}]${a}`}function EF(e,t,n=`section`){return`<page ${[t?.title?`title="${DF(t.title)}"`:null,t?.url?`url="${DF(t.url)}"`:null].filter(Boolean).join(` `)}>\n <${n}><![CDATA[\n${e}\n]]></${n}>\n</page>`}function DF(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}var OF=class{static structure(e,t={},n){let r=[];r.push(`# Page Outline`),(n?.title||n?.url)&&(r.push(`Title: ${n?.title??``}`.trim()),r.push(`URL: ${n?.url??``}`.trim())),r.push(``);let i=e.regions,a=[[`header`,i.header],[`navigation`,i.navigation],[`main`,i.main],[`sections`,i.sections],[`sidebar`,i.sidebar],[`footer`,i.footer],[`modals`,i.modals]];for(let[e,t]of a){if(!t)continue;let n=xF(e);if(Array.isArray(t)){if(!t.length)continue;r.push(`## ${n} ${kF(e)}`);for(let e of t)r.push(TF(e))}else r.push(`## ${n} ${kF(e)}`),r.push(TF(t));r.push(``)}if(e.suggestions?.length){r.push(`## Suggestions`);for(let t of e.suggestions)r.push(`- ${t}`);r.push(``)}return r.push(`Next: choose a region (by selector or [sectionId]) and call dom_extract_region for actionable details.`),EF(r.join(`
|
|
120
|
-
`),n,`outline`)}static region(e,t={},n){let r=[];r.push(`# Region Details`),(n?.title||n?.url)&&(r.push(`Title: ${n?.title??``}`.trim()),r.push(`URL: ${n?.url??``}`.trim())),r.push(``);let i=e.interactive;if(e.page){let t=[e.page.hasErrors?`errors: yes`:`errors: no`,e.page.isLoading?`loading: yes`:`loading: no`,e.page.hasModals?`modals: yes`:`modals: no`];r.push(`Page state: ${t.join(`, `)}`)}let a=[],o=e=>e?e.length:0;return a.push(`${o(i.buttons)} buttons`),a.push(`${o(i.links)} links`),a.push(`${o(i.inputs)} inputs`),i.forms?.length&&a.push(`${o(i.forms)} forms`),r.push(`Summary: ${a.join(`, `)}`),r.push(CF(i)),r.push(``),r.push(wF(i,t)),r.push(``),r.push(`Next: write a script using the most stable selectors above. If selectors look unstable, rerun dom_extract_region with higher detail or call dom_extract_content for text context.`),EF(r.join(`
|
|
121
|
-
`),n,`section`)}static content(e,t={},n){let r=[];if(r.push(`# Content`),r.push(`Selector: \`${e.selector}\``),r.push(``),e.text.headings?.length){r.push(`Headings:`);for(let n of e.text.headings)r.push(`- H${n.level}: ${yF(n.text,t.maxTextLength??120)}`);r.push(``)}if(e.text.paragraphs?.length){let n=typeof t.maxElements==`number`?t.maxElements:e.text.paragraphs.length;r.push(`Paragraphs:`);for(let i of e.text.paragraphs.slice(0,n))r.push(`- ${yF(i,t.maxTextLength??200)}`);r.push(``)}if(e.text.lists?.length){r.push(`Lists:`);for(let n of e.text.lists){r.push(`- ${n.type.toUpperCase()}:`);let e=typeof t.maxElements==`number`?t.maxElements:n.items.length;for(let i of n.items.slice(0,e))r.push(` - ${yF(i,t.maxTextLength??120)}`)}r.push(``)}if(e.tables?.length){r.push(`Tables:`);for(let n of e.tables){r.push(`- Headers: ${n.headers.join(` | `)}`);let e=typeof t.maxElements==`number`?t.maxElements:n.rows.length;for(let t of n.rows.slice(0,e))r.push(` - ${t.join(` | `)}`)}r.push(``)}if(e.media?.length){r.push(`Media:`);let n=typeof t.maxElements==`number`?t.maxElements:e.media.length;for(let t of e.media.slice(0,n))r.push(`- ${t.type.toUpperCase()}: ${t.alt??``} ${t.src?`→ ${t.src}`:``}`.trim());r.push(``)}return r.push(`Next: if text is insufficient for targeting, call dom_extract_region for interactive selectors.`),EF(r.join(`
|
|
122
|
-
`),n,`content`)}};function kF(e){return e.charAt(0).toUpperCase()+e.slice(1)}var AF=class e{static generateSelectors(t){let n=t.ownerDocument||document,r=[];t.id&&e.isUniqueId(t.id,n)&&r.push({type:`id`,value:`#${CSS.escape(t.id)}`,score:100});let i=e.getDataTestId(t);if(i){let t=`[data-testid="${CSS.escape(i)}"]`;r.push({type:`data-testid`,value:t,score:90+(e.isUniqueSelectorSafe(t,n)?5:0)})}let a=t.getAttribute(`role`),o=t.getAttribute(`aria-label`);if(a&&o){let t=`[role="${CSS.escape(a)}"][aria-label="${CSS.escape(o)}"]`;r.push({type:`role-aria`,value:t,score:85+(e.isUniqueSelectorSafe(t,n)?5:0)})}let s=t.getAttribute(`name`);if(s){let t=`[name="${CSS.escape(s)}"]`;r.push({type:`name`,value:t,score:78+(e.isUniqueSelectorSafe(t,n)?5:0)})}let c=e.generateCSSSelector(t,n),l=(c.match(/:nth-child\(/g)||[]).length*10,u=c.includes(`.`)?8:0,d=Math.max(0,70+u-l);r.push({type:`class-path`,value:c,score:d});let f=e.generateXPath(t,n);r.push({type:`xpath`,value:f,score:40});let p=e.generateTextBasedSelector(t);p&&r.push({type:`text`,value:p,score:30}),r.sort((e,t)=>t.score-e.score);let m={css:r.find(e=>e.type!==`xpath`&&e.type!==`text`)?.value||c,xpath:f,candidates:r};return p&&(m.textBased=p),i&&(m.dataTestId=i),o&&(m.ariaLabel=o),m}static generateCSSSelector(t,n){if(t.id&&e.isUniqueId(t.id,n))return`#${CSS.escape(t.id)}`;let r=e.getDataTestId(t);if(r)return`[data-testid="${CSS.escape(r)}"]`;let i=[],a=t;for(;a&&a.nodeType===Node.ELEMENT_NODE;){let t=a.nodeName.toLowerCase();if(a.id&&e.isUniqueId(a.id,n)){t=`#${CSS.escape(a.id)}`,i.unshift(t);break}let r=e.getMeaningfulClasses(a);r.length>0&&(t+=`.${r.map(e=>CSS.escape(e)).join(`.`)}`);let o=a.parentElement?.children;if(o&&o.length>1){let n=Array.from(o).indexOf(a);(n>0||!e.isUniqueSelector(t,a.parentElement))&&(t+=`:nth-child(${n+1})`)}i.unshift(t),a=a.parentElement}return e.optimizePath(i,t,n)}static generateXPath(t,n){if(t.id&&e.isUniqueId(t.id,n))return`//*[@id="${t.id}"]`;let r=[],i=t;for(;i&&i.nodeType===Node.ELEMENT_NODE;){let t=i.nodeName.toLowerCase();if(i.id&&e.isUniqueId(i.id,n)){r.unshift(`//*[@id="${i.id}"]`);break}let a=t,o=i.parentElement?.children;if(o){let e=Array.from(o).filter(e=>e.nodeName.toLowerCase()===t);if(e.length>1){let t=e.indexOf(i)+1;a+=`[${t}]`}}r.unshift(a),i=i.parentElement}return`//${r.join(`/`)}`}static generateTextBasedSelector(e){let t=e.textContent?.trim();if(!t||t.length>50)return;let n=e.nodeName.toLowerCase();if([`button`,`a`,`label`].includes(n))return`${n}:contains("${t.replace(/['"\\]/g,`\\$&`)}")`}static getDataTestId(e){return e.getAttribute(`data-testid`)||e.getAttribute(`data-test-id`)||e.getAttribute(`data-test`)||e.getAttribute(`data-cy`)||void 0}static isUniqueId(e,t){return t.querySelectorAll(`#${CSS.escape(e)}`).length===1}static isUniqueSelector(e,t){try{return t.querySelectorAll(e).length===1}catch{return!1}}static isUniqueSelectorSafe(e,t){try{return t.querySelectorAll(e).length===1}catch{return!1}}static getMeaningfulClasses(e){let t=Array.from(e.classList),n=[/^(p|m|w|h|text|bg|border|flex|grid|col|row)-/,/^(xs|sm|md|lg|xl|2xl):/,/^(hover|focus|active|disabled|checked):/,/^js-/,/^is-/,/^has-/];return t.filter(e=>e.length<3?!1:!n.some(t=>t.test(e))).slice(0,2)}static optimizePath(e,t,n){for(let r=0;r<e.length-1;r++){let i=e.slice(r).join(` > `);try{let e=n.querySelectorAll(i);if(e.length===1&&e[0]===t)return i}catch{}}return e.join(` > `)}static getContextPath(e){let t=[],n=e,r=0;for(;n&&n!==e.ownerDocument?.body&&r<5;){let e=n.nodeName.toLowerCase(),i=e;if(n.id)i=`${e}#${n.id}`;else if(n.className&&typeof n.className==`string`){let t=n.className.split(` `)[0];t&&(i=`${e}.${t}`)}let a=n.getAttribute(`role`);a&&(i+=`[role="${a}"]`),t.unshift(i),n=n.parentElement,r++}return t}},jF=class e{static isDocument(e){return e.nodeType===Node.DOCUMENT_NODE}static isVisible(e){let t=e.getBoundingClientRect(),n=e.ownerDocument?.defaultView?.getComputedStyle(e);return n?t.width>0&&t.height>0&&n.display!==`none`&&n.visibility!==`hidden`&&n.opacity!==`0`:!1}static isInViewport(e){let t=e.getBoundingClientRect(),n={width:e.ownerDocument?.defaultView?.innerWidth||0,height:e.ownerDocument?.defaultView?.innerHeight||0};return t.top<n.height&&t.bottom>0&&t.left<n.width&&t.right>0}static passesFilter(t,n){if(!n)return!0;if(n.excludeSelectors?.length){for(let e of n.excludeSelectors)if(t.matches(e))return!1}if(n.includeSelectors?.length){let e=!1;for(let r of n.includeSelectors)if(t.matches(r)){e=!0;break}if(!e)return!1}if(n.tags?.length&&!n.tags.includes(t.tagName.toLowerCase()))return!1;let r=t.textContent?.toLowerCase()||``;if(n.textContains?.length){let e=!1;for(let t of n.textContains)if(r.includes(t.toLowerCase())){e=!0;break}if(!e)return!1}if(n.textMatches?.length){let e=!1;for(let t of n.textMatches)if(t.test(r)){e=!0;break}if(!e)return!1}if(n.hasAttributes?.length){for(let e of n.hasAttributes)if(!t.hasAttribute(e))return!1}if(n.attributeValues)for(let[e,r]of Object.entries(n.attributeValues)){let n=t.getAttribute(e);if(!n)return!1;if(typeof r==`string`){if(n!==r)return!1}else if(r instanceof RegExp&&!r.test(n))return!1}if(n.withinSelectors?.length){let e=!1;for(let r of n.withinSelectors)if(t.closest(r)){e=!0;break}if(!e)return!1}if(n.interactionTypes?.length){let r=e.getInteractionInfo(t),i=!1;for(let e of n.interactionTypes)if(r[e]){i=!0;break}if(!i)return!1}if(n.nearText){let e=t.parentElement;if(!e||!e.textContent?.toLowerCase().includes(n.nearText.toLowerCase()))return!1}return!0}static extractElement(t,n,r=0){if(n.maxDepth&&r>n.maxDepth||!n.includeHidden&&!e.isVisible(t)||n.viewportOnly&&!e.isInViewport(t)||!e.passesFilter(t,n.filter))return null;let i={tag:t.tagName.toLowerCase(),text:e.getElementText(t,n),selector:AF.generateSelectors(t),attributes:e.getRelevantAttributes(t,n),context:e.getElementContext(t),interaction:e.getInteractionInfo(t)};if(n.mode===`full`&&e.isSemanticContainer(t)){let a=[];if(n.includeShadowDOM&&t.shadowRoot){let i=e.extractChildren(t.shadowRoot,n,r+1);a.push(...i)}let o=e.extractChildren(t,n,r+1);a.push(...o),a.length>0&&(i.children=a)}return i}static extractChildren(t,n,r){let i=[],a=t.querySelectorAll(`*`);for(let t of Array.from(a)){if(e.hasExtractedAncestor(t,a))continue;let o=e.extractElement(t,n,r);o&&i.push(o)}return i}static hasExtractedAncestor(e,t){let n=e.parentElement;for(;n;){if(Array.from(t).includes(n))return!0;n=n.parentElement}return!1}static getRelevantAttributes(e,t){let n=`id.class.name.type.value.placeholder.href.src.alt.title.action.method.aria-label.aria-describedby.aria-controls.role.disabled.readonly.required.checked.min.max.pattern.step.autocomplete.data-testid.data-test.data-cy`.split(`.`),r={},i=t.attributeTruncateLength??100,a=t.dataAttributeTruncateLength??50;for(let t of n){let n=e.getAttribute(t);n&&(r[t]=n.length>i?`${n.substring(0,i)}...`:n)}for(let t of e.attributes)t.name.startsWith(`data-`)&&!n.includes(t.name)&&(r[t.name]=t.value.length>a?`${t.value.substring(0,a)}...`:t.value);return r}static getElementContext(e){let t={parentChain:AF.getContextPath(e)},n=e.closest(`form`);n&&(t.nearestForm=AF.generateSelectors(n).css);let r=e.closest(`section, [role="region"]`);r&&(t.nearestSection=AF.generateSelectors(r).css);let i=e.closest(`main, [role="main"]`);i&&(t.nearestMain=AF.generateSelectors(i).css);let a=e.closest(`nav, [role="navigation"]`);return a&&(t.nearestNav=AF.generateSelectors(a).css),t}static getInteractionInfo(t){let n=t,r={};(n.onclick||t.getAttribute(`onclick`)||t.matches(`button, a[href], [role="button"], [tabindex]:not([tabindex="-1"])`))&&(r.click=!0),(n.onchange||t.getAttribute(`onchange`)||t.matches(`input, select, textarea`))&&(r.change=!0),(n.onsubmit||t.getAttribute(`onsubmit`)||t.matches(`form`))&&(r.submit=!0),t.matches(`a[href], button[type="submit"]`)&&(r.nav=!0),(t.hasAttribute(`disabled`)||t.getAttribute(`aria-disabled`)===`true`)&&(r.disabled=!0),e.isVisible(t)||(r.hidden=!0);let i=t.getAttribute(`role`);if(i&&(r.role=i),t.matches(`input, textarea, select, button`)){let e=t.form||t.closest(`form`);e&&(r.form=AF.generateSelectors(e).css)}return r}static getElementText(e,t){if(e.matches(`input, textarea`)){let t=e;return t.value||t.placeholder||``}if(e.matches(`img`))return e.alt||``;let n=e.textContent?.trim()||``,r=t?.textTruncateLength;return r&&n.length>r?`${n.substring(0,r)}...`:n}static isSemanticContainer(e){return e.matches(`article, section, nav, aside, main, header, footer, form, table, ul, ol, dl, figure, details, dialog, [role="region"], [role="navigation"], [role="main"], [role="complementary"]`)}},MF=class e{options;constructor(e={}){this.options={mode:e.mode||`interactive`,maxDepth:e.maxDepth||5,includeHidden:e.includeHidden||!1,includeShadowDOM:e.includeShadowDOM??!0,includeIframes:e.includeIframes||!1,viewportOnly:e.viewportOnly||!1,mainContentOnly:e.mainContentOnly||!1,customSelectors:e.customSelectors||[],...e.attributeTruncateLength!==void 0&&{attributeTruncateLength:e.attributeTruncateLength},...e.dataAttributeTruncateLength!==void 0&&{dataAttributeTruncateLength:e.dataAttributeTruncateLength},...e.textTruncateLength!==void 0&&{textTruncateLength:e.textTruncateLength},...e.filter!==void 0&&{filter:e.filter}}}extract(e=document,t){let n=Date.now(),r=jF.isDocument(e),i=r?e:e.ownerDocument,a={...this.options,...t},o=r?i:e;a.mainContentOnly&&r&&(o=vF.findMainContent(i));let s=this.extractPageState(i),c=this.extractLandmarks(i),l=this.extractInteractiveElements(o,a),u={mode:a.mode,timestamp:n,page:s,landmarks:c,interactive:l};if(a.mode===`full`){let e=this.extractSemanticElements(o,a),t=this.extractMetadata(i,o,a);return{...u,semantic:e,metadata:t}}return u}extractPageState(e){let t=this.getFocusedElement(e);return{url:e.location?.href||``,title:e.title||``,hasErrors:this.detectErrors(e),isLoading:this.detectLoading(e),hasModals:this.detectModals(e),...t!==void 0&&{hasFocus:t}}}extractLandmarks(e){let t=vF.detectLandmarks(e);return{navigation:this.elementsToSelectors(t.navigation||[]),main:this.elementsToSelectors(t.main||[]),forms:this.elementsToSelectors(t.form||[]),headers:this.elementsToSelectors(t.banner||[]),footers:this.elementsToSelectors(t.contentinfo||[]),articles:this.elementsToSelectors(t.region||[]),sections:this.elementsToSelectors(t.region||[])}}elementsToSelectors(e){return e.map(e=>AF.generateSelectors(e).css)}querySelectorAll(e,t,n){let r=[...e.querySelectorAll(t)];if(!n)return r;for(let n of e.querySelectorAll(`*`))n.shadowRoot&&r.push(...this.querySelectorAll(n.shadowRoot,t,!0));return r}extractAll(e,t,n){let r=[];for(let i of this.querySelectorAll(e,t,n.includeShadowDOM)){let e=jF.extractElement(i,n);e&&r.push(e)}return r}extractInteractiveElements(e,t){let n=[];for(let r of t.customSelectors??[])n.push(...this.extractAll(e,r,t));return{buttons:this.extractAll(e,`button, [role="button"], input[type="button"], input[type="submit"]`,t),links:this.extractAll(e,`a[href]`,t),inputs:this.extractAll(e,`input:not([type="button"]):not([type="submit"]), textarea, select`,t),forms:this.extractForms(e,t),clickable:n}}extractForms(e,t){let n=[];return this.querySelectorAll(e,`form`,t.includeShadowDOM).forEach(e=>{if(!this.shouldIncludeElement(e,t))return;let r=e.getAttribute(`action`),i=e.getAttribute(`method`),a={selector:AF.generateSelectors(e).css,inputs:this.extractAll(e,`input:not([type="button"]):not([type="submit"]), textarea, select`,t),buttons:this.extractAll(e,`button, input[type="button"], input[type="submit"]`,t)};r&&(a.action=r),i&&(a.method=i),n.push(a)}),n}extractSemanticElements(e,t){return{headings:this.extractAll(e,`h1, h2, h3, h4, h5, h6`,t),images:this.extractAll(e,`img`,t),tables:this.extractAll(e,`table`,t),lists:this.extractAll(e,`ul, ol`,t),articles:this.extractAll(e,`article, [role="article"]`,t)}}extractMetadata(e,t,n){let r=this.querySelectorAll(t,`*`,n.includeShadowDOM),i=this.querySelectorAll(t,`button, a, input, textarea, select, h1, h2, h3, h4, h5, h6, img, table, ul, ol, article`,n.includeShadowDOM).length,a={totalElements:r.length,extractedElements:i};n.mainContentOnly&&!jF.isDocument(t)&&(a.mainContent=AF.generateSelectors(t).css);let o=e.documentElement.getAttribute(`lang`);return o&&(a.language=o),a}shouldIncludeElement(e,t){return!(!t.includeHidden&&!jF.isVisible(e)||t.viewportOnly&&!jF.isInViewport(e)||t.filter&&!jF.passesFilter(e,t.filter))}detectErrors(e){return[`.error`,`.alert-danger`,`[role="alert"]`,`.error-message`].some(t=>{let n=e.querySelector(t);return n?jF.isVisible(n):!1})}detectLoading(e){return[`.loading`,`.spinner`,`[aria-busy="true"]`,`.loader`].some(t=>{let n=e.querySelector(t);return n?jF.isVisible(n):!1})}detectModals(e){return[`[role="dialog"]`,`.modal`,`.popup`,`.overlay`].some(t=>{let n=e.querySelector(t);return n?jF.isVisible(n):!1})}getFocusedElement(e){let t=e.activeElement;if(t&&t!==e.body)return AF.generateSelectors(t).css}static extractInteractive(t,n={}){return new e({...n,mode:`interactive`}).extract(t)}static extractFull(t,n={}){return new e({...n,mode:`full`}).extract(t)}static extractFromElement(t,n=`interactive`,r={}){return new e({...r,mode:n}).extract(t)}},NF=YP(`[page-context-extractor]`),PF=()=>({title:document.title||``,url:window.location.href,description:document.querySelector(`meta[name="description"]`)?.getAttribute(`content`)??``}),FF=()=>{try{let e=PF(),t=MF.extractFull(document,{includeHidden:!1,includeShadowDOM:!0,includeIframes:!0,mainContentOnly:!0,textTruncateLength:80,attributeTruncateLength:60});return OF.region(t,{detail:`deep`,maxTextLength:4e3,maxElements:150},{title:e.title,url:e.url}).trim()}catch(e){NF.log(`[extractMainContent] smart-dom-reader failed, fallback to textContent:`,e);let t=document.body.cloneNode(!0);return t.querySelectorAll(`script, style, noscript`).forEach(e=>e.remove()),(t.textContent||``).trim().slice(0,4e3)}},IF=e=>{let t=[],n=e.interactive;if(!n)return t;for(let e of Object.values(n))if(Array.isArray(e))for(let n of e)typeof n==`object`&&n&&t.push(n);return t},LF=(e,t=4)=>{let n=[],r=e.parentElement;for(let e=0;e<t&&r&&r!==document.body;e++){let t=Array.from(r.childNodes).filter(e=>e.nodeType===Node.TEXT_NODE).map(e=>e.textContent?.trim()??``).filter(e=>e.length>0).join(` `)||(r.textContent||``).trim().slice(0,120);t&&n.push(`L${e+1}: ${t.slice(0,120)}`),r=r.parentElement}return n.join(` → `)},RF=e=>e.filter(e=>String(e.text??``).trim().length>0).map(e=>{let t=e.selector,n=t?.candidates?.[0]?.value??``,r=t?.css??n,i=null;if(r)try{i=document.querySelector(r)}catch{}let a=e.attributes,o=a?.[`data-assistant-action`]??i?.getAttribute(`data-assistant-action`)??``,s=a?.[`data-product-id`]??i?.getAttribute(`data-product-id`)??``,c=i?LF(i):``,l=e.interaction;return{tag:String(e.tag??``),text:String(e.text??``).slice(0,50),dataAction:o,dataProductId:s,parentChain:c,bestSelector:r,disabled:l?.disabled??!1}}),zF=e=>e.length===0?``:`| # | 标签 | 元素文本 | data-action | data-product-id | 父链上下文(从近到远) | 最佳选择器 | 状态 |\n| --- | --- | --- | --- | --- | --- | --- | --- |\n${e.map((e,t)=>`| ${t+1} | ${e.tag} | ${e.text} | ${e.dataAction} | ${e.dataProductId} | ${e.parentChain} | ${e.bestSelector} | ${e.disabled?`disabled`:`active`} |`).join(`
|
|
123
|
-
`)}`,BF=()=>{try{return zF(RF(IF(MF.extractInteractive(document,{includeHidden:!1,includeShadowDOM:!0,includeIframes:!0,viewportOnly:!1,mainContentOnly:!1,textTruncateLength:80,attributeTruncateLength:80}))))}catch(e){return NF.log(`[extractInteractiveIndex] smart-dom-reader failed, return empty:`,e),``}},VF=null,HF=``,UF=()=>{VF=null,HF=``},WF=()=>{let e=window.location.href;if(HF===e&&VF)return VF;let t=PF(),n=FF(),r=BF();return VF={pageTitle:t.title,pageUrl:t.url,pageDescription:t.description,pageContent:n,interactiveElements:r},HF=e,VF},GF=YP(`[action-executor]`),KF={click_element:uF,fill_input:dF,scroll_to:fF,navigate_to:pF,highlight_element:_F},qF=e=>e.tool===`navigate_to`?{url:e.params.url}:e.tool===`scroll_to`&&e.params.position?{position:e.params.position}:(GF.log(e.params),{element:lF({dataAttributes:e.params.data_attributes,anchorContext:e.params.anchor_context?{anchorText:e.params.anchor_context.anchorText,targetSelector:e.params.anchor_context.targetSelector}:void 0,textMatch:e.params.text_match,cssSelector:e.params.css_selector})?.element,value:e.params.value,url:e.params.url,position:e.params.position}),JF=async e=>{let t=KF[e.tool];if(!t){let t={success:!1,error:`unknown_tool`,message:`Unknown tool: ${e.tool}`};return KP(JSON.stringify(t)),t}let n=qF(e);GF.log(`[executeAction] tool=${e.tool} params=`,n);let r=await t(n);return GF.log(`[executeAction] result=`,r),UF(),KP(JSON.stringify(r)),r},YF=(0,_.createContext)(null);YF.Provider;var XF=()=>(0,_.useContext)(YF),ZF={click_element:`Click Element`,navigate_to:`Navigate`},QF=({toolName:e,args:t,addResult:n})=>{let r=XF(),[i,a]=(0,_.useState)(!0),[o,s]=(0,_.useState)(!1),[c,l]=(0,_.useState)(!1),u=(0,_.useCallback)(e=>{o||(s(!0),a(!1),n(e))},[o,n]);if((0,_.useEffect)(()=>{!r&&!o&&u(new Ep({result:{success:!1,error:`portal_missing`,message:`Confirm UI portal target not found`},isError:!0}))},[r,o,u]),!r)return(0,M.jsxs)(Do,{status:`danger`,className:`mx-3 my-2 max-[300px]`,children:[(0,M.jsx)(Do.Indicator,{}),(0,M.jsxs)(Do.Content,{children:[(0,M.jsx)(Do.Title,{children:`System Error`}),(0,M.jsx)(Do.Description,{children:`Confirmation UI failed to initialize. Please refresh the page.`})]})]});let d=t.url?`Navigate to: ${t.url}`:t.data_attributes?`Execute: ${t.data_attributes}`:t.anchor_context&&typeof t.anchor_context==`object`?`Click: ${t.anchor_context.anchorText}`:t.text_match?`Click: ${t.text_match}`:t.css_selector?`Operate: ${t.css_selector}`:`Perform page action`,f=(0,_.useCallback)(async()=>{if(!(o||c)){l(!0);try{let n=await JF({tool:e,params:t});u(new Ep({result:n,isError:!n.success,...n.data&&{artifact:n.data}}))}catch(e){let t=e instanceof Error?e.message:`Action execution failed`;u(new Ep({result:{success:!1,error:`exception`,message:t},isError:!0}))}finally{l(!1)}}},[o,c,e,t,u]),p=(0,_.useCallback)(()=>{u({success:!1,error:`user_cancelled`,message:`User cancelled the operation`})},[u]),m=(0,_.useCallback)(()=>{p()},[p]);return i?(0,Le.createPortal)((0,M.jsx)(`div`,{className:`absolute inset-0 z-20 flex items-center justify-center backdrop-blur-sm pointer-events-auto`,onClick:m,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`confirm-tool-title`,children:(0,M.jsxs)(wo,{className:`w-[90%] max-w-sm shadow-2xl`,onClick:e=>e.stopPropagation(),children:[(0,M.jsxs)(`div`,{id:`confirm-tool-title`,className:`flex items-center gap-2 border-b border-gray-100 px-4 py-3 text-base font-semibold text-gray-900`,children:[(0,M.jsx)(_s.wandMagic,{size:18}),ZF[e]??`Confirm Action`]}),(0,M.jsxs)(`div`,{className:`space-y-1 px-4 py-4`,children:[(0,M.jsx)(`p`,{className:`text-sm text-gray-700`,children:d}),(0,M.jsx)(`p`,{className:`text-xs text-gray-400`,children:`Please confirm this action`})]}),(0,M.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-gray-100 px-4 py-3`,children:[(0,M.jsxs)(xo,{variant:`ghost`,size:`sm`,onPress:p,isDisabled:c,children:[`Cancel`,(0,M.jsx)(No,{})]}),(0,M.jsxs)(xo,{variant:`primary`,size:`sm`,onPress:f,isDisabled:c,children:[c?`Executing...`:`Confirm`,(0,M.jsx)(No,{})]})]})]})}),r):null},$F={fill_input:`Fill Input`,scroll_to:`Scroll Page`,highlight_element:`Highlight Element`},eI=({toolName:e,args:t,result:n,status:r})=>{let i=$F[e]??`Tool`,a=r?.type;if(a===`running`)return(0,M.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-blue-50 px-3 py-2 text-xs text-blue-600`,children:[(0,M.jsx)(_s.loading,{className:`animate-spin`,size:14}),(0,M.jsxs)(`span`,{children:[`Executing: `,i]}),t.value&&(0,M.jsxs)(`span`,{className:`text-blue-400`,children:[`→ `,t.value]})]});if(a===`complete`||n){let e=n?.success!==!1,t=n?.message??`Completed`;return(0,M.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg px-3 py-2 text-xs ${e?`bg-green-50 text-green-600`:`bg-red-50 text-red-600`}`,children:[e?(0,M.jsx)(_s.success,{size:14}):(0,M.jsx)(_s.error,{size:14}),(0,M.jsx)(`span`,{children:t})]})}return(0,M.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-gray-50 px-3 py-2 text-xs text-gray-500`,children:[(0,M.jsx)(_s.wandMagic,{size:14}),(0,M.jsx)(`span`,{children:i})]})},tI=GN([HN({anchorText:V(),targetSelector:V()}),V(),tP(``)]),nI=HN({data_attributes:V().optional(),anchor_context:tI.optional(),text_match:V().optional(),css_selector:V().optional()}),rI=$f({click_element:{type:`human`,description:`Click on a page element, such as add-to-cart button, navigation link, etc.`,parameters:nI,render:QF},navigate_to:{type:`human`,description:`Navigate to the specified URL`,parameters:HN({url:V()}),render:QF},fill_input:{type:`frontend`,description:`Fill content into an input field, such as search box, form field, etc.`,parameters:nI.extend({value:V()}),execute:async e=>JF({tool:`fill_input`,params:{data_attributes:e.data_attributes,anchor_context:e.anchor_context,text_match:e.text_match,css_selector:e.css_selector,value:e.value}}),render:eI},scroll_to:{type:`frontend`,description:`Scroll the page to a specified element or position`,parameters:nI.extend({position:$N([`top`,`bottom`]).optional()}),execute:async e=>JF({tool:`scroll_to`,params:{data_attributes:e.data_attributes,anchor_context:e.anchor_context,text_match:e.text_match,css_selector:e.css_selector,position:e.position}}),render:eI},highlight_element:{type:`frontend`,description:`Highlight a page element to draw user attention`,parameters:nI,execute:async e=>JF({tool:`highlight_element`,params:{data_attributes:e.data_attributes,anchor_context:e.anchor_context,text_match:e.text_match,css_selector:e.css_selector}}),render:eI}}),iI=[`click_element`,`navigate_to`],aI={name:``,price:``,sku:``,availability:``,found:!1},oI=()=>{let e=document.querySelectorAll(`script[type="application/ld+json]`);for(let t of e)try{let e=JSON.parse(t.textContent||``),n=Array.isArray(e)?e:[e];for(let e of n){let t=e,n=t[`@graph`];if(Array.isArray(n))for(let e of n){let t=sI(e);if(t)return t}let r=sI(t);if(r)return r}}catch{}return null},sI=e=>{let t=e[`@type`];if(typeof t!=`string`||!t.includes(`Product`))return null;let n=typeof e.name==`string`?e.name:``,r=e.offers;return{name:n,price:typeof r?.price==`string`?r.price:``,sku:typeof e.sku==`string`?e.sku:``,availability:typeof e.availability==`string`?e.availability.replace(`https://schema.org/`,``):``,found:!0}},cI=()=>{let e=document.querySelector(`meta[property="og:title"]`)?.getAttribute(`content`),t=[`.price`,`.product-price`,`[data-price]`,`[itemprop="price"]`,`.price-current`],n=``;for(let e of t){let t=document.querySelector(e);if(t?.textContent?.trim()){n=t.textContent.trim();break}}let r=e||document.title||``;return r||n?{name:r,price:n,sku:``,availability:``,found:!0}:aI},lI=()=>oI()||cI(),uI=e=>{if(!e.found)return``;let t=[];return e.name&&t.push(`名称: ${e.name}`),e.price&&t.push(`价格: ${e.price}`),e.sku&&t.push(`SKU: ${e.sku}`),e.availability&&t.push(`库存: ${e.availability}`),t.join(` | `)},dI=()=>{let e=WF(),t=lI();return{page_title:e.pageTitle,page_url:e.pageUrl,page_content:e.pageContent,page_description:e.pageDescription,product_info:uI(t),interactive_elements:e.interactiveElements}},fI=e=>{for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.role===`user`)return n.content.filter(e=>e.type===`text`).map(e=>e.text).join(``)||``}return``},pI=()=>dI(),mI=YP(`[use-dify-assistant]`),hI=e=>{for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.role!==`assistant`)continue;let r=n.content.find(e=>e.type===`tool-call`&&e.result!==void 0);if(r)return{toolCallId:r.toolCallId,toolName:r.toolName,result:r.result}}return null},gI=()=>({...pI(),tools:nF}),_I=e=>iI.includes(e),vI=()=>({async*run({messages:e,abortSignal:t,unstable_getMessage:n}){let r=hI(e)??(n?hI([n()]):null);if(r){mI.log(`resume detected for tool:`,r.toolName,`callId:`,r.toolCallId.slice(0,8));let e=r.result;yield{content:[{type:`text`,text:e?.success===!0?`✅ ${e.message??`Operation completed`}`:`❌ ${e?.message??e?.error??`Operation failed`}`}]};return}if([...e].reverse().find(e=>e.role===`assistant`)?.content.some(e=>e.type===`tool-call`&&e.result===void 0)){mI.log(`pending tool-call detected, skip resend`);return}let i=fI(e);if(!i)return;let a=VP(),o=zP()??void 0;try{let e=await PP({query:i,inputs:gI(),conversationId:o,user:a}),n=``,r=null;for await(let a of e){if(t.aborted)return;switch(a.event){case`message`:n+=a.answer,r=a.conversation_id,yield{content:[{type:`text`,text:eF(n)||`Processing your request...`}]};break;case`agent_thought`:a.thought&&(yield{content:[{type:`reasoning`,text:a.thought},...n?[{type:`text`,text:eF(n)}]:[]]});break;case`message_end`:{r=a.conversation_id,BP(r),WP(r,eF(n)||i);let e=QP(n);if(e.length===0){yield{content:[{type:`text`,text:eF(n)}]};return}let t=e[0],o=crypto.randomUUID(),s=[{type:`text`,text:eF(n)},{type:`tool-call`,toolCallId:o,toolName:t.tool,args:t.params,argsText:JSON.stringify(t.params)}];mI.log(`emit tool-call:`,t.tool),_I(t.tool)?yield{content:s,status:{type:`requires-action`,reason:`tool-calls`}}:yield{content:s};return}case`error`:yield{content:[{type:`text`,text:`[Error] ${a.message}`}]};return}}}catch(e){yield{content:[{type:`text`,text:`[Request failed] ${e instanceof Error?e.message:`Unknown error`}`}]}}}}),yI=e=>{mI.log(`useDifyAssistant:`,e);let t=rS((0,_.useMemo)(()=>vI(),[]),{unstable_humanToolNames:[...e.humanToolNames]}),n=(0,_.useCallback)(()=>{HP()},[]);return{runtime:t,config:e.config,clearConversation:n}},bI=I_(`useAISDKRuntime`),xI=(e,t)=>{if(t==null)return[];let n=e.findIndex(e=>e.id===t);if(n===-1)throw Error(`sliceMessagesUntil: Message "${t}" not found in AI SDK messages. This is likely an internal bug in assistant-ui.`);for(;e[n+1]?.role===`assistant`;)n++;return e.slice(0,n+1)},SI=e=>{let t=[...e.content,...e.attachments?.flatMap(e=>e.content.map(t=>({...t,filename:e.name,contentType:e.contentType})))??[]].map(e=>{switch(e.type){case`text`:return{type:`text`,text:e.text};case`image`:{let t=nD(e.image,e.contentType);return{type:`file`,url:iD(e.image,t),...e.filename&&{filename:e.filename},mediaType:t}}case`file`:{let t=rD(e.data,e.mimeType);return{type:`file`,url:e.sourceType===`id`?e.data:iD(e.data,t),mediaType:t,...e.filename&&{filename:e.filename}}}case`audio`:{let t=`audio/${e.audio.format}`,n=e.audio.data;return{type:`file`,url:im.test(n)?n:`data:${t};base64,${am(n)?.data??n}`,mediaType:t,...e.filename&&{filename:e.filename}}}case`data`:return{type:`data-${e.name}`,data:e.data};default:throw Error(`Unsupported part type: ${e.type}`)}});return{role:e.role,parts:t,metadata:e.metadata}},CI=`vercel.ai.error`,wI=Symbol.for(CI),TI,EI,H=class e extends (EI=Error,TI=wI,EI){constructor({name:e,message:t,cause:n}){super(t),this[TI]=!0,this.name=e,this.cause=n}static isInstance(t){return e.hasMarker(t,CI)}static hasMarker(e,t){let n=Symbol.for(t);return typeof e==`object`&&!!e&&n in e&&typeof e[n]==`boolean`&&e[n]===!0}},DI=`AI_APICallError`,OI=`vercel.ai.error.${DI}`,kI=Symbol.for(OI),AI,jI,MI=class extends (jI=H,AI=kI,jI){constructor({message:e,url:t,requestBodyValues:n,statusCode:r,responseHeaders:i,responseBody:a,cause:o,isRetryable:s=r!=null&&(r===408||r===409||r===429||r>=500),data:c}){super({name:DI,message:e,cause:o}),this[AI]=!0,this.url=t,this.requestBodyValues=n,this.statusCode=r,this.responseHeaders=i,this.responseBody=a,this.isRetryable=s,this.data=c}static isInstance(e){return H.hasMarker(e,OI)}},NI=`AI_EmptyResponseBodyError`,PI=`vercel.ai.error.${NI}`,FI=Symbol.for(PI),II,LI,RI=class extends (LI=H,II=FI,LI){constructor({message:e=`Empty response body`}={}){super({name:NI,message:e}),this[II]=!0}static isInstance(e){return H.hasMarker(e,PI)}};function zI(e){return e==null?`unknown error`:typeof e==`string`?e:e instanceof Error?e.toString():JSON.stringify(e)}var BI=`AI_InvalidArgumentError`,VI=`vercel.ai.error.${BI}`,HI=Symbol.for(VI),UI,WI,GI=class extends (WI=H,UI=HI,WI){constructor({message:e,cause:t,argument:n}){super({name:BI,message:e,cause:t}),this[UI]=!0,this.argument=n}static isInstance(e){return H.hasMarker(e,VI)}},KI=`AI_InvalidPromptError`,qI=`vercel.ai.error.${KI}`,JI=Symbol.for(qI),YI,XI,ZI=class extends (XI=H,YI=JI,XI){constructor({prompt:e,message:t,cause:n}){super({name:KI,message:`Invalid prompt: ${t}`,cause:n}),this[YI]=!0,this.prompt=e}static isInstance(e){return H.hasMarker(e,qI)}},QI=`AI_JSONParseError`,$I=`vercel.ai.error.${QI}`,eL=Symbol.for($I),tL,nL,rL=class extends (nL=H,tL=eL,nL){constructor({text:e,cause:t}){super({name:QI,message:`JSON parsing failed: Text: ${e}.
|
|
124
|
-
Error message: ${zI(t)}`,cause:t}),this[tL]=!0,this.text=e}static isInstance(e){return H.hasMarker(e,$I)}},iL=`AI_TypeValidationError`,aL=`vercel.ai.error.${iL}`,oL=Symbol.for(aL),sL,cL,lL=class e extends (cL=H,sL=oL,cL){constructor({value:e,cause:t,context:n}){let r=`Type validation failed`;if(n?.field&&(r+=` for ${n.field}`),n?.entityName||n?.entityId){r+=` (`;let e=[];n.entityName&&e.push(n.entityName),n.entityId&&e.push(`id: "${n.entityId}"`),r+=e.join(`, `),r+=`)`}super({name:iL,message:`${r}: Value: ${JSON.stringify(e)}.
|
|
125
|
-
Error message: ${zI(t)}`,cause:t}),this[sL]=!0,this.value=e,this.context=n}static isInstance(e){return H.hasMarker(e,aL)}static wrap({value:t,cause:n,context:r}){return e.isInstance(n)&&n.value===t&&n.context?.field===r?.field&&n.context?.entityName===r?.entityName&&n.context?.entityId===r?.entityId?n:new e({value:t,cause:n,context:r})}},uL=`AI_UnsupportedFunctionalityError`,dL=`vercel.ai.error.${uL}`,fL=Symbol.for(dL),pL,mL,hL=class extends (mL=H,pL=fL,mL){constructor({functionality:e,message:t=`'${e}' functionality not supported.`}){super({name:uL,message:t}),this[pL]=!0,this.functionality=e}static isInstance(e){return H.hasMarker(e,dL)}},gL=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}},_L=10,vL=13,yL=32;function bL(e){}function xL(e){if(typeof e==`function`)throw TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{onEvent:t=bL,onError:n=bL,onRetry:r=bL,onComment:i,maxBufferSize:a}=e,o=[],s=0,c=!0,l,u=``,d=0,f,p=!1;function m(e){if(p)throw Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,e.charCodeAt(0)===239&&e.charCodeAt(1)===187&&e.charCodeAt(2)===191&&(e=e.slice(3))),o.length===0){let t=g(e);t!==``&&(o.push(t),s=t.length),h();return}if(e.indexOf(`
|
|
126
|
-
`)===-1&&e.indexOf(`\r`)===-1){o.push(e),s+=e.length,h();return}o.push(e);let t=o.join(``);o.length=0,s=0;let n=g(t);n!==``&&(o.push(n),s=n.length),h()}function h(){a!==void 0&&(s+u.length<=a||(p=!0,o.length=0,s=0,l=void 0,u=``,d=0,f=void 0,n(new gL(`Buffered data exceeded max buffer size of ${a} characters`,{type:`max-buffer-size-exceeded`}))))}function g(e){let n=0;if(e.indexOf(`\r`)===-1){let r=e.indexOf(`
|
|
127
|
-
`,n);for(;r!==-1;){if(n===r){d>0&&t({id:l,event:f,data:u}),l=void 0,u=``,d=0,f=void 0,n=r+1,r=e.indexOf(`
|
|
128
|
-
`,n);continue}let i=e.charCodeAt(n);if(SL(e,n,i)){let i=e.charCodeAt(n+5)===yL?n+6:n+5,a=e.slice(i,r);if(d===0&&e.charCodeAt(r+1)===_L){t({id:l,event:f,data:a}),l=void 0,u=``,f=void 0,n=r+2,r=e.indexOf(`
|
|
129
|
-
`,n);continue}u=d===0?a:`${u}
|
|
130
|
-
${a}`,d++}else CL(e,n,i)?f=e.slice(e.charCodeAt(n+6)===yL?n+7:n+6,r)||void 0:_(e,n,r);n=r+1,r=e.indexOf(`
|
|
131
|
-
`,n)}return e.slice(n)}for(;n<e.length;){let t=e.indexOf(`\r`,n),r=e.indexOf(`
|
|
132
|
-
`,n),i=-1;if(t!==-1&&r!==-1?i=t<r?t:r:t===-1?r!==-1&&(i=r):i=t===e.length-1?-1:t,i===-1)break;_(e,n,i),n=i+1,e.charCodeAt(n-1)===vL&&e.charCodeAt(n)===_L&&n++}return e.slice(n)}function _(e,t,n){if(t===n){y();return}let r=e.charCodeAt(t);if(SL(e,t,r)){let r=e.charCodeAt(t+5)===yL?t+6:t+5,i=e.slice(r,n);u=d===0?i:`${u}
|
|
133
|
-
${i}`,d++;return}if(CL(e,t,r)){f=e.slice(e.charCodeAt(t+6)===yL?t+7:t+6,n)||void 0;return}if(r===105&&e.charCodeAt(t+1)===100&&e.charCodeAt(t+2)===58){let r=e.slice(e.charCodeAt(t+3)===yL?t+4:t+3,n);r.includes(`\0`)||(l=r);return}if(r===58){if(i){let r=e.slice(t,n);i(r.slice(e.charCodeAt(t+1)===yL?2:1))}return}let a=e.slice(t,n),o=a.indexOf(`:`);if(o===-1){v(a,``,a);return}let s=a.slice(0,o),c=a.charCodeAt(o+1)===yL?2:1;v(s,a.slice(o+c),a)}function v(e,t,i){switch(e){case`event`:f=t||void 0;break;case`data`:u=d===0?t:`${u}
|
|
134
|
-
${t}`,d++;break;case`id`:t.includes(`\0`)||(l=t);break;case`retry`:/^\d+$/.test(t)?r(parseInt(t,10)):n(new gL(`Invalid \`retry\` value: "${t}"`,{type:`invalid-retry`,value:t,line:i}));break;default:n(new gL(`Unknown field "${e.length>20?`${e.slice(0,20)}\u2026`:e}"`,{type:`unknown-field`,field:e,value:t,line:i}))}}function y(){d>0&&t({id:l,event:f,data:u}),l=void 0,u=``,d=0,f=void 0}function b(e={}){if(e.consume&&o.length>0){let e=o.join(``);_(e,0,e.length)}c=!0,l=void 0,u=``,d=0,f=void 0,o.length=0,s=0,p=!1}return{feed:m,reset:b}}function SL(e,t,n){return n===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function CL(e,t,n){return n===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}var wL=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n,maxBufferSize:r}={}){let i;super({start(a){i=xL({onEvent:e=>{a.enqueue(e)},onError(t){typeof e==`function`&&e(t),(e===`terminate`||t.type===`max-buffer-size-exceeded`)&&a.error(t)},onRetry:t,onComment:n,maxBufferSize:r})},transform(e){i.feed(e)}})}},TL=Symbol.for(`workflow-serialize`),EL=Symbol.for(`workflow-deserialize`);function DL(e){return e===void 0?[]:Array.isArray(e)?e:[e]}function OL(...e){return e.reduce((e,t)=>({...e,...t??{}}),{})}function kL(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>t!=null))}async function AL(e,t){if(e==null)return Promise.resolve();let n=t?.abortSignal;return new Promise((t,r)=>{if(n?.aborted){r(jL());return}let i=setTimeout(()=>{a(),t()},e),a=()=>{clearTimeout(i),n?.removeEventListener(`abort`,o)},o=()=>{a(),r(jL())};n?.addEventListener(`abort`,o)})}function jL(){return new DOMException(`Delay was aborted`,`AbortError`)}function ML(e){let t=e??globalThis.WebSocket;if(t==null)throw Error(`No WebSocket implementation available.`);return t}var NL=new TextDecoder;async function PL(e){return typeof e==`string`?e:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?NL.decode(e):typeof Blob<`u`&&e instanceof Blob?e.text():String(e)}var FL=1;async function IL(e,{highWaterMark:t=1048576,pollIntervalMs:n=20,abortSignal:r}={}){for(;e.readyState===FL&&(e.bufferedAmount??0)>t;){if(r?.aborted===!0)return;await AL(n)}}function LL({url:e,protocols:t,headers:n,webSocket:r,abortSignal:i,onOpen:a,onMessageText:o,onProcessingError:s,onSocketError:c,onClose:l,onAbort:u}){let d,f,p=e=>{f!=null&&(i?.removeEventListener(`abort`,f),f=void 0);try{d?.close(e)}catch{}};if(i?.aborted)return u?.(i.reason??Error(`Aborted`)),{socket:void 0,close:p};try{d=new(ML(r))(e,t,{headers:kL(n??{})})}catch(e){return s(e),{socket:void 0,close:p}}i!=null&&u!=null&&(f=()=>u(i.reason??Error(`Aborted`)),i.addEventListener(`abort`,f,{once:!0}));let m=d;d.onopen=()=>{try{a?.(m)}catch(e){s(e)}};let h=Promise.resolve();return d.onmessage=e=>{h=h.then(()=>PL(e.data)).then(e=>o(e)).catch(s)},d.onerror=()=>{h=h.then(()=>c?.()).catch(s)},d.onclose=e=>{let t=e,n=typeof t?.code==`number`?t.code:void 0,r=typeof t?.reason==`string`?t.reason:void 0;h=h.then(()=>l?.({code:n,reason:r})).catch(s)},{socket:d,close:p}}var{btoa:RL,atob:zL}=globalThis;function BL(e){let t=zL(e.replace(/-/g,`+`).replace(/_/g,`/`));return Uint8Array.from(t,e=>e.codePointAt(0))}function VL(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCodePoint(e[n]);return RL(t)}var HL=class{constructor(){this.status={type:`pending`},this._resolve=void 0,this._reject=void 0}get promise(){return this._promise||=new Promise((e,t)=>{this.status.type===`resolved`?e(this.status.value):this.status.type===`rejected`&&t(this.status.error),this._resolve=e,this._reject=t}),this._promise}resolve(e){var t;this.status={type:`resolved`,value:e},this._promise&&((t=this._resolve)==null||t.call(this,e))}reject(e){var t;this.status={type:`rejected`,error:e},this._promise&&((t=this._reject)==null||t.call(this,e))}isResolved(){return this.status.type===`resolved`}isRejected(){return this.status.type===`rejected`}isPending(){return this.status.type===`pending`}},UL=[{mediaType:`image/gif`,bytesPrefix:[71,73,70]},{mediaType:`image/png`,bytesPrefix:[137,80,78,71]},{mediaType:`image/jpeg`,bytesPrefix:[255,216]},{mediaType:`image/webp`,bytesPrefix:[82,73,70,70,null,null,null,null,87,69,66,80]},{mediaType:`image/bmp`,bytesPrefix:[66,77]},{mediaType:`image/tiff`,bytesPrefix:[73,73,42,0]},{mediaType:`image/tiff`,bytesPrefix:[77,77,0,42]},{mediaType:`image/avif`,bytesPrefix:[0,0,0,32,102,116,121,112,97,118,105,102]},{mediaType:`image/heic`,bytesPrefix:[0,0,0,32,102,116,121,112,104,101,105,99]}],WL=[{mediaType:`application/pdf`,bytesPrefix:[37,80,68,70]}],GL=[{mediaType:`audio/mpeg`,bytesPrefix:[255,251]},{mediaType:`audio/mpeg`,bytesPrefix:[255,250]},{mediaType:`audio/mpeg`,bytesPrefix:[255,243]},{mediaType:`audio/mpeg`,bytesPrefix:[255,242]},{mediaType:`audio/mpeg`,bytesPrefix:[255,227]},{mediaType:`audio/mpeg`,bytesPrefix:[255,226]},{mediaType:`audio/wav`,bytesPrefix:[82,73,70,70,null,null,null,null,87,65,86,69]},{mediaType:`audio/ogg`,bytesPrefix:[79,103,103,83]},{mediaType:`audio/flac`,bytesPrefix:[102,76,97,67]},{mediaType:`audio/aac`,bytesPrefix:[64,21,0,0]},{mediaType:`audio/webm`,bytesPrefix:[26,69,223,163]}],KL=[...GL,{mediaType:`audio/mp4`,bytesPrefix:[0,0,0,null,102,116,121,112]}],qL=[{mediaType:`video/mp4`,bytesPrefix:[0,0,0,null,102,116,121,112]},{mediaType:`video/webm`,bytesPrefix:[26,69,223,163]},{mediaType:`video/quicktime`,bytesPrefix:[0,0,0,20,102,116,121,112,113,116]},{mediaType:`video/x-msvideo`,bytesPrefix:[82,73,70,70]}],JL=18,YL=131084;function XL(e,t){if(typeof e!=`string`)return e.length>t?e.subarray(0,t):e;let n=Math.ceil(t/3)*4,r=BL(e.substring(0,Math.min(e.length,n)));return r.length>t?r.subarray(0,t):r}function ZL(e){return e.length>10&&e[0]===73&&e[1]===68&&e[2]===51}var QL=e=>{let t=(e[6]&127)<<21|(e[7]&127)<<14|(e[8]&127)<<7|e[9]&127;return e.subarray(t+10)};function $L({data:e,signatures:t}){let n=XL(e,JL);ZL(n)&&(n=QL(XL(e,YL)));for(let e of t)if(n.length>=e.bytesPrefix.length&&e.bytesPrefix.every((e,t)=>e===null||n[t]===e))return e.mediaType}var eR={image:UL,audio:KL,video:qL,application:WL};function tR({data:e,topLevelType:t}){if(t===void 0)return $L({data:e,signatures:[...UL,...WL,...GL,...qL]});let n=eR[t];if(n!==void 0)return $L({data:e,signatures:n})}function nR(e){let t=e.indexOf(`/`);if(t===-1)return!1;let n=e.substring(t+1);return n.length>0&&n!==`*`}async function rR(e){try{await e.body?.cancel()}catch{}}var iR=`AI_DownloadError`,aR=`vercel.ai.error.${iR}`,oR=Symbol.for(aR),sR,cR,lR=class extends (cR=H,sR=oR,cR){constructor({url:e,statusCode:t,statusText:n,cause:r,message:i=r==null?`Failed to download ${e}: ${t} ${n}`:`Failed to download ${e}: ${r}`}){super({name:iR,message:i,cause:r}),this[sR]=!0,this.url=e,this.statusCode=t,this.statusText=n}static isInstance(e){return H.hasMarker(e,aR)}};function uR(e=globalThis){return e.window!=null}function dR(e,t){try{return new URL(e).origin===new URL(t).origin}catch{return!1}}function fR(e){let t;try{t=new URL(e)}catch{throw new lR({url:e,message:`Invalid URL: ${e}`})}if(t.protocol===`data:`)return;if(t.protocol!==`http:`&&t.protocol!==`https:`)throw new lR({url:e,message:`URL scheme must be http, https, or data, got ${t.protocol}`});let n=t.hostname.toLowerCase().replace(/\.+$/,``);if(!n)throw new lR({url:e,message:`URL must have a hostname`});if(n===`localhost`||n.endsWith(`.local`)||n.endsWith(`.localhost`))throw new lR({url:e,message:`URL with hostname ${n} is not allowed`});if(n.startsWith(`[`)&&n.endsWith(`]`)){if(_R(n.slice(1,-1)))throw new lR({url:e,message:`URL with IPv6 address ${n} is not allowed`});return}if(mR(n)){if(hR(n))throw new lR({url:e,message:`URL with IP address ${n} is not allowed`});return}}function pR({address:e,family:t,hostname:n}){if(t===4?!mR(e)||hR(e):t!==6||_R(e))throw new lR({url:n,message:`Hostname ${n} resolved to disallowed IP address ${e}`})}function mR(e){let t=e.split(`.`);return t.length===4&&t.every(e=>{let t=Number(e);return Number.isInteger(t)&&t>=0&&t<=255&&String(t)===e})}function hR(e){let[t,n,r]=e.split(`.`).map(Number);return t===0||t===10||t===100&&n>=64&&n<=127||t===127||t===169&&n===254||t===172&&n>=16&&n<=31||t===192&&n===0&&r===0||t===192&&n===0&&r===2||t===192&&n===168||t===198&&(n===18||n===19)||t===198&&n===51&&r===100||t===203&&n===0&&r===113||t>=224}function gR(e){let t=e.toLowerCase(),n=t.indexOf(`%`);n!==-1&&(t=t.slice(0,n));let r=t.split(`::`);if(r.length>2)return null;let i=e=>{if(e===``)return[];let t=[],n=e.split(`:`);for(let e=0;e<n.length;e++){let r=n[e];if(r.includes(`.`)){if(e!==n.length-1||!mR(r))return null;let[i,a,o,s]=r.split(`.`).map(Number);t.push(i<<8|a,o<<8|s);continue}if(!/^[0-9a-f]{1,4}$/.test(r))return null;t.push(parseInt(r,16))}return t},a=i(r[0]);if(a===null)return null;if(r.length===2){let e=i(r[1]);if(e===null)return null;let t=8-a.length-e.length;return t<0?null:[...a,...Array(t).fill(0),...e]}return a.length===8?a:null}function _R(e){let t=gR(e);if(t===null)return!0;let n=e=>t.slice(0,e).every(e=>e===0);return n(7)&&(t[7]===0||t[7]===1)||(t[0]&65024)==64512||(t[0]&65472)==65152||(t[0]&65472)==65216||(t[0]&65280)==65280||t[0]===8193&&t[1]===3512||t[0]===16383&&!(t[1]&61440)?!0:n(6)||n(5)&&t[5]===65535||n(4)&&t[4]===65535&&t[5]===0||t[0]===100&&t[1]===65435&&t[2]===0&&t[3]===0&&t[4]===0&&t[5]===0||t[0]===100&&t[1]===65435&&t[2]===1?hR(`${t[6]>>8&255}.${t[6]&255}.${t[7]>>8&255}.${t[7]&255}`):!1}function vR(e){return((t,n,r)=>{e(t,{...n,all:!0},(e,i)=>{if(e){r(e);return}try{let[e]=i;if(e==null)throw Error(`Hostname ${t} did not resolve to an address`);for(let{address:e,family:n}of i)pR({address:e,family:n,hostname:t});n.all===!0?r(null,i):r(null,e.address,e.family)}catch(e){r(e instanceof Error?e:Error(String(e)))}})})}var yR,bR=globalThis.fetch,xR=wR(bR);function SR(){let e=globalThis.process;return e?.release?.name===`node`&&e.versions?.bun==null}async function CR(){return!SR()||!xR||globalThis.fetch!==bR?globalThis.fetch:yR??=Promise.resolve().then(TR)}function wR(e){if(typeof e!=`function`)return!1;let t=Function.prototype.toString.call(e);return t.includes(`internal/deps/undici`)||t.includes(`lazy loading of undici`)}function TR(){let{createRequire:e}=ER(`node:module`),{lookup:t}=ER(`node:dns`),{Agent:n,fetch:r}=e(DR())(`undici`),i=new n({connect:{lookup:vR(t)}});return((e,t)=>r(e,{...t,dispatcher:i}))}function ER(e){let t=globalThis.process,n=(t?.getBuiltinModule)?.call(t,e);if(n==null)throw Error(`Node.js built-in module ${e} is unavailable`);return n}function DR(){let e=Error.prepareStackTrace;try{Error.prepareStackTrace=(e,t)=>t;let e=Error(`Capture current module path`);Error.captureStackTrace(e,DR);let[t]=e.stack,n=t?.getFileName();if(n==null)throw Error(`Unable to determine the current module path`);return n}finally{Error.prepareStackTrace=e}}var OR=[`connection`,`keep-alive`,`te`,`trailer`,`transfer-encoding`,`upgrade`,`host`,`forwarded`,`proxy-authorization`,`via`,`x-forwarded-for`,`x-forwarded-host`,`x-forwarded-proto`,`x-real-ip`,`metadata`,`metadata-flavor`,`x-aws-ec2-metadata-token`,`x-metadata-token`,`cookie`,`set-cookie`];function kR(e){let t=new Headers(e);for(let e of OR)t.delete(e);return t}var AR=10,jR=new Set([301,302,303,307,308]);async function MR({url:e,headers:t,abortSignal:n,maxRedirects:r=AR,fetch:i,trustedOrigin:a}){let o=t===void 0?void 0:kR(t),s=e=>{let t={signal:n,redirect:e};return o!==void 0&&(t.headers=new Headers(o)),t},c=e;for(let t=0;t<=r;t++){let t=a!==void 0&&dR(c,a);t||fR(c);let n=i??(t?globalThis.fetch:await CR()),r=await n(c,s(`manual`));if(r.type===`opaqueredirect`){if(!uR())throw new lR({url:e,message:`Redirect from ${c} could not be validated and was blocked`});return await n(c,s(`follow`))}let l=r.headers.get(`location`);if(jR.has(r.status)&&l){await rR(r);let e=new URL(l,c).toString();if(o!==void 0&&!dR(e,c)){let e=o.get(`user-agent`);o=new Headers(e==null?void 0:{"user-agent":e})}c=e;continue}return r}throw new lR({url:e,message:`Too many redirects (max ${r})`})}var NR=2147483648;async function PR({response:e,url:t,maxBytes:n=NR}){let r=e.headers.get(`content-length`);if(r!=null){let i=parseInt(r,10);if(!isNaN(i)&&i>n)throw await rR(e),new lR({url:t,message:`Download of ${t} exceeded maximum size of ${n} bytes (Content-Length: ${i}).`})}let i=e.body;if(i==null)return new Uint8Array;let a=i.getReader(),o=[],s=0;try{for(;;){let{done:e,value:r}=await a.read();if(e)break;if(s+=r.length,s>n)throw new lR({url:t,message:`Download of ${t} exceeded maximum size of ${n} bytes.`});o.push(r)}}finally{try{await a.cancel()}catch{}finally{a.releaseLock()}}let c=new Uint8Array(s),l=0;for(let e of o)c.set(e,l),l+=e.length;return c}function FR(e){return Object.fromEntries([...e.headers])}function IR(...e){return e.filter(e=>e!=null)}var LR=({prefix:e,size:t=16,alphabet:n=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,separator:r=`-`}={})=>{let i=()=>{let e=n.length,r=Array(t);for(let i=0;i<t;i++)r[i]=n[Math.random()*e|0];return r.join(``)};if(e==null)return i;if(n.includes(r))throw new GI({argument:`separator`,message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${e}${r}${i()}`},RR=LR();function zR(e){return(e instanceof Error||e instanceof DOMException)&&(e.name===`AbortError`||e.name===`ResponseAborted`||e.name===`TimeoutError`)}var BR=[`fetch failed`,`failed to fetch`],VR=[`ConnectionRefused`,`ConnectionClosed`,`FailedToOpenSocket`,`ECONNRESET`,`ECONNREFUSED`,`ETIMEDOUT`,`EPIPE`];function HR(e){if(!(e instanceof Error))return!1;let t=e.code;return!!(typeof t==`string`&&VR.includes(t))}function UR({error:e,url:t,requestBodyValues:n}){if(zR(e))return e;if(e instanceof TypeError&&BR.includes(e.message.toLowerCase())){let r=e.cause;if(r!=null)return new MI({message:`Cannot connect to API: ${r.message}`,cause:r,url:t,requestBodyValues:n,isRetryable:!0})}return HR(e)?new MI({message:`Cannot connect to API: ${e.message}`,cause:e,url:t,requestBodyValues:n,isRetryable:!0}):e}function WR(e=globalThis){return e.window?`runtime/browser`:e.navigator?.userAgent?`runtime/${e.navigator.userAgent.toLowerCase()}`:e.process?.versions?.node?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?`runtime/vercel-edge`:`runtime/unknown`}function GR(e){if(e==null)return{};let t={};if(e instanceof Headers)e.forEach((e,n)=>{t[n.toLowerCase()]=e});else{Array.isArray(e)||(e=Object.entries(e));for(let[n,r]of e)r!=null&&(t[n.toLowerCase()]=r)}return t}function KR(e,...t){let n=new Headers(GR(e)),r=n.get(`user-agent`)||``;return n.set(`user-agent`,[r,...t].filter(Boolean).join(` `)),Object.fromEntries(n.entries())}var qR=`5.0.27`,JR=()=>globalThis.fetch,YR=async({url:e,headers:t={},successfulResponseHandler:n,failedResponseHandler:r,abortSignal:i,fetch:a,validateUrl:o,credentialedOrigin:s,trustedOrigin:c})=>{try{let l=a??JR(),u=KR(s!==void 0&&!dR(e,s)?{}:t,`ai-sdk/provider-utils/${qR}`,WR()),d=o?await MR({url:e,headers:u,abortSignal:i,fetch:a,trustedOrigin:c}):await l(e,{method:`GET`,headers:u,signal:i}),f=FR(d);if(!d.ok){let t;try{t=await r({response:d,url:e,requestBodyValues:{}})}catch(t){throw zR(t)||MI.isInstance(t)?t:new MI({message:`Failed to process error response`,cause:t,statusCode:d.status,url:e,responseHeaders:f,requestBodyValues:{}})}throw t.value}try{return await n({response:d,url:e,requestBodyValues:{}})}catch(t){throw t instanceof Error&&(zR(t)||MI.isInstance(t))?t:new MI({message:`Failed to process successful response`,cause:t,statusCode:d.status,url:e,responseHeaders:f,requestBodyValues:{}})}}catch(t){throw UR({error:t,url:e,requestBodyValues:{}})}};function XR(e){return globalThis.Buffer?.isBuffer(e)??!1}function ZR(e){return e!=null}function QR(e){return typeof e==`object`&&!!e&&!(e instanceof Uint8Array)&&!(e instanceof URL)&&!(e instanceof ArrayBuffer)&&!XR(e)&&!(`type`in e)}function $R(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ez({mediaType:e,url:t,supportedUrls:n}){t=t.toLowerCase(),e=e.toLowerCase();let r=!e.includes(`/`);return Object.entries(n).map(([e,t])=>{let n=e.toLowerCase();return n===`*`||n===`*/*`?{mediaTypePrefix:``,regexes:t}:{mediaTypePrefix:n.replace(/\*/,``),regexes:t}}).filter(({mediaTypePrefix:t})=>t===``?!0:r?`${e}/`===t:e.startsWith(t)).flatMap(({regexes:e})=>e).some(e=>tz(e,t))}function tz(e,t){if(!e.global&&!e.sticky)return e.test(t);let n=e.lastIndex;e.lastIndex=0;try{return e.test(t)}finally{e.lastIndex=n}}function nz({settingValue:e,environmentVariableName:t}){if(typeof e==`string`||!(e!=null||typeof process>`u`)&&(e={}[t],e!=null&&typeof e==`string`))return e}var rz=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,iz=/"(?: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 az(e){let t=JSON.parse(e);return typeof t!=`object`||!t||rz.test(e)===!1&&iz.test(e)===!1?t:oz(t)}function oz(e){let t=[e];for(;t.length;){let e=t;t=[];for(let n of e){if(Object.prototype.hasOwnProperty.call(n,`__proto__`)||Object.prototype.hasOwnProperty.call(n,`constructor`)&&n.constructor!==null&&typeof n.constructor==`object`&&Object.prototype.hasOwnProperty.call(n.constructor,`prototype`))throw SyntaxError(`Object contains forbidden prototype property`);for(let e in n){let r=n[e];r&&typeof r==`object`&&t.push(r)}}}return e}function sz(e){let{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return az(e)}try{return az(e)}finally{Error.stackTraceLimit=t}}function cz(e){if(e.type===`object`||Array.isArray(e.type)&&e.type.includes(`object`)){e.additionalProperties=!1;let{properties:t}=e;if(t!=null)for(let e of Object.keys(t))t[e]=lz(t[e])}e.items!=null&&(e.items=Array.isArray(e.items)?e.items.map(lz):lz(e.items)),e.anyOf!=null&&(e.anyOf=e.anyOf.map(lz)),e.allOf!=null&&(e.allOf=e.allOf.map(lz)),e.oneOf!=null&&(e.oneOf=e.oneOf.map(lz));let{definitions:t}=e;if(t!=null)for(let e of Object.keys(t))t[e]=lz(t[e]);return e}function lz(e){return typeof e==`boolean`?e:cz(e)}var uz=Symbol(`Let zodToJsonSchema decide on which parser to use`),dz={name:void 0,$refStrategy:`root`,basePath:[`#`],effectStrategy:`input`,pipeStrategy:`all`,dateStrategy:`format:date-time`,mapStrategy:`entries`,removeAdditionalStrategy:`passthrough`,allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:`definitions`,strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:`escape`,applyRegexFlags:!1,emailStrategy:`format:email`,base64Strategy:`contentEncoding:base64`,nameStrategy:`ref`},fz=e=>typeof e==`string`?{...dz,name:e}:{...dz,...e};function pz(){return{}}function mz(e,t){let n={type:`array`};return e.type?._def&&e.type?._def?.typeName!==`ZodAny`&&(n.items=aB(e.type._def,{...t,currentPath:[...t.currentPath,`items`]})),e.minLength&&(n.minItems=e.minLength.value),e.maxLength&&(n.maxItems=e.maxLength.value),e.exactLength&&(n.minItems=e.exactLength.value,n.maxItems=e.exactLength.value),n}function hz(e){let t={type:`integer`,format:`int64`};if(!e.checks)return t;for(let n of e.checks)switch(n.kind){case`min`:n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case`max`:n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case`multipleOf`:t.multipleOf=n.value}return t}function gz(){return{type:`boolean`}}function _z(e,t){return aB(e.type._def,t)}var vz=(e,t)=>aB(e.innerType._def,t);function yz(e,t,n){let r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map(n=>yz(e,t,n))};switch(r){case`string`:case`format:date-time`:return{type:`string`,format:`date-time`};case`format:date`:return{type:`string`,format:`date`};case`integer`:return bz(e)}}var bz=e=>{let t={type:`integer`,format:`unix-time`};for(let n of e.checks)switch(n.kind){case`min`:t.minimum=n.value;break;case`max`:t.maximum=n.value}return t};function xz(e,t){return{...aB(e.innerType._def,t),default:e.defaultValue()}}function Sz(e,t){return t.effectStrategy===`input`?aB(e.schema._def,t):pz()}function Cz(e){return{type:`string`,enum:Array.from(e.values)}}var wz=e=>`type`in e&&e.type===`string`?!1:`allOf`in e;function Tz(e,t){let n=[aB(e.left._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]}),aB(e.right._def,{...t,currentPath:[...t.currentPath,`allOf`,`1`]})].filter(e=>!!e),r=[];return n.forEach(e=>{if(wz(e))r.push(...e.allOf);else{let t=e;if(`additionalProperties`in e&&e.additionalProperties===!1){let{additionalProperties:n,...r}=e;t=r}r.push(t)}}),r.length?{allOf:r}:void 0}function Ez(e){let t=typeof e.value;return t!==`bigint`&&t!==`number`&&t!==`boolean`&&t!==`string`?{type:Array.isArray(e.value)?`array`:`object`}:{type:t===`bigint`?`integer`:t,const:e.value}}var Dz=void 0,Oz={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(Dz===void 0&&(Dz=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)),Dz),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function kz(e,t){let n={type:`string`};if(e.checks)for(let r of e.checks)switch(r.kind){case`min`:n.minLength=typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value;break;case`max`:n.maxLength=typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value;break;case`email`:switch(t.emailStrategy){case`format:email`:Nz(n,`email`,r.message,t);break;case`format:idn-email`:Nz(n,`idn-email`,r.message,t);break;case`pattern:zod`:Pz(n,Oz.email,r.message,t)}break;case`url`:Nz(n,`uri`,r.message,t);break;case`uuid`:Nz(n,`uuid`,r.message,t);break;case`regex`:Pz(n,r.regex,r.message,t);break;case`cuid`:Pz(n,Oz.cuid,r.message,t);break;case`cuid2`:Pz(n,Oz.cuid2,r.message,t);break;case`startsWith`:Pz(n,RegExp(`^${Az(r.value,t)}`),r.message,t);break;case`endsWith`:Pz(n,RegExp(`${Az(r.value,t)}$`),r.message,t);break;case`datetime`:Nz(n,`date-time`,r.message,t);break;case`date`:Nz(n,`date`,r.message,t);break;case`time`:Nz(n,`time`,r.message,t);break;case`duration`:Nz(n,`duration`,r.message,t);break;case`length`:n.minLength=typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value,n.maxLength=typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value;break;case`includes`:Pz(n,RegExp(Az(r.value,t)),r.message,t);break;case`ip`:r.version!==`v6`&&Nz(n,`ipv4`,r.message,t),r.version!==`v4`&&Nz(n,`ipv6`,r.message,t);break;case`base64url`:Pz(n,Oz.base64url,r.message,t);break;case`jwt`:Pz(n,Oz.jwt,r.message,t);break;case`cidr`:r.version!==`v6`&&Pz(n,Oz.ipv4Cidr,r.message,t),r.version!==`v4`&&Pz(n,Oz.ipv6Cidr,r.message,t);break;case`emoji`:Pz(n,Oz.emoji(),r.message,t);break;case`ulid`:Pz(n,Oz.ulid,r.message,t);break;case`base64`:switch(t.base64Strategy){case`format:binary`:Nz(n,`binary`,r.message,t);break;case`contentEncoding:base64`:n.contentEncoding=`base64`;break;case`pattern:zod`:Pz(n,Oz.base64,r.message,t)}break;case`nanoid`:Pz(n,Oz.nanoid,r.message,t)}return n}function Az(e,t){return t.patternStrategy===`escape`?Mz(e):e}var jz=new Set(`ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789`);function Mz(e){let t=``;for(let n=0;n<e.length;n++)jz.has(e[n])||(t+=`\\`),t+=e[n];return t}function Nz(e,t,n,r){e.format||e.anyOf?.some(e=>e.format)?(e.anyOf||=[],e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...n&&r.errorMessages&&{errorMessage:{format:n}}})):e.format=t}function Pz(e,t,n,r){e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||=[],e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:Fz(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=Fz(t,r)}function Fz(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let n={i:e.flags.includes(`i`),m:e.flags.includes(`m`),s:e.flags.includes(`s`)},r=n.i?e.source.toLowerCase():e.source,i=``,a=!1,o=!1,s=!1;for(let e=0;e<r.length;e++){if(a){i+=r[e],a=!1;continue}if(n.i){if(o){if(r[e].match(/[a-z]/)){s?(i+=r[e],i+=`${r[e-2]}-${r[e]}`.toUpperCase(),s=!1):r[e+1]===`-`&&r[e+2]?.match(/[a-z]/)?(i+=r[e],s=!0):i+=`${r[e]}${r[e].toUpperCase()}`;continue}}else if(r[e].match(/[a-z]/)){i+=`[${r[e]}${r[e].toUpperCase()}]`;continue}}if(n.m){if(r[e]===`^`){i+=`(^|(?<=[\r
|
|
135
|
-
]))`;continue}if(r[e]===`$`){i+=`($|(?=[\r
|
|
136
|
-
]))`;continue}}if(n.s&&r[e]===`.`){i+=o?`${r[e]}\r
|
|
137
|
-
`:`[${r[e]}\r
|
|
138
|
-
]`;continue}i+=r[e],r[e]===`\\`?a=!0:o&&r[e]===`]`?o=!1:!o&&r[e]===`[`&&(o=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join(`/`)} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function Iz(e,t){let n={type:`object`,additionalProperties:aB(e.valueType._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]})??t.allowedAdditionalProperties};if(e.keyType?._def.typeName===`ZodString`&&e.keyType._def.checks?.length){let{type:r,...i}=kz(e.keyType._def,t);return{...n,propertyNames:i}}if(e.keyType?._def.typeName===`ZodEnum`)return{...n,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===`ZodBranded`&&e.keyType._def.type._def.typeName===`ZodString`&&e.keyType._def.type._def.checks?.length){let{type:r,...i}=_z(e.keyType._def,t);return{...n,propertyNames:i}}return n}function Lz(e,t){return t.mapStrategy===`record`?Iz(e,t):{type:`array`,maxItems:125,items:{type:`array`,items:[aB(e.keyType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`0`]})||pz(),aB(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`1`]})||pz()],minItems:2,maxItems:2}}}function Rz(e){let t=e.values,n=Object.keys(e.values).filter(e=>typeof t[t[e]]!=`number`).map(e=>t[e]),r=Array.from(new Set(n.map(e=>typeof e)));return{type:r.length===1?r[0]===`string`?`string`:`number`:[`string`,`number`],enum:n}}function zz(){return{not:pz()}}function Bz(){return{type:`null`}}var Vz={ZodString:`string`,ZodNumber:`number`,ZodBigInt:`integer`,ZodBoolean:`boolean`,ZodNull:`null`};function Hz(e,t){let n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(e=>e._def.typeName in Vz&&(!e._def.checks||!e._def.checks.length))){let e=n.reduce((e,t)=>{let n=Vz[t._def.typeName];return n&&!e.includes(n)?[...e,n]:e},[]);return{type:e.length>1?e:e[0]}}if(n.every(e=>e._def.typeName===`ZodLiteral`&&!e.description)){let e=n.reduce((e,t)=>{let n=typeof t._def.value;switch(n){case`string`:case`number`:case`boolean`:return[...e,n];case`bigint`:return[...e,`integer`];case`object`:if(t._def.value===null)return[...e,`null`];default:return e}},[]);if(e.length===n.length){let t=e.filter((e,t,n)=>n.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:n.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(n.every(e=>e._def.typeName===`ZodEnum`))return{type:`string`,enum:n.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return Uz(e,t)}var Uz=(e,t)=>{let n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,n)=>aB(e._def,{...t,currentPath:[...t.currentPath,`anyOf`,`${n}`]})).filter(e=>!!e&&(!t.strictUnions||typeof e==`object`&&Object.keys(e).length>0));return n.length?{anyOf:n}:void 0};function Wz(e,t){if([`ZodString`,`ZodNumber`,`ZodBigInt`,`ZodBoolean`,`ZodNull`].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[Vz[e.innerType._def.typeName],`null`]};let n=aB(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`0`]});return n&&{anyOf:[n,{type:`null`}]}}function Gz(e){let t={type:`number`};if(!e.checks)return t;for(let n of e.checks)switch(n.kind){case`int`:t.type=`integer`;break;case`min`:n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case`max`:n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case`multipleOf`:t.multipleOf=n.value}return t}function Kz(e,t){let n={type:`object`,properties:{}},r=[],i=e.shape();for(let e in i){let a=i[e];if(a===void 0||a._def===void 0)continue;let o=Jz(a),s=aB(a._def,{...t,currentPath:[...t.currentPath,`properties`,e],propertyPath:[...t.currentPath,`properties`,e]});s!==void 0&&(n.properties[e]=s,o||r.push(e))}r.length&&(n.required=r);let a=qz(e,t);return a!==void 0&&(n.additionalProperties=a),n}function qz(e,t){if(e.catchall._def.typeName!==`ZodNever`)return aB(e.catchall._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]});switch(e.unknownKeys){case`passthrough`:return t.allowedAdditionalProperties;case`strict`:return t.rejectedAdditionalProperties;case`strip`:return t.removeAdditionalStrategy===`strict`?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function Jz(e){try{return e.isOptional()}catch{return!0}}var Yz=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return aB(e.innerType._def,t);let n=aB(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`1`]});return n?{anyOf:[{not:pz()},n]}:pz()},Xz=(e,t)=>{if(t.pipeStrategy===`input`)return aB(e.in._def,t);if(t.pipeStrategy===`output`)return aB(e.out._def,t);let n=aB(e.in._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]});return{allOf:[n,aB(e.out._def,{...t,currentPath:[...t.currentPath,`allOf`,n?`1`:`0`]})].filter(e=>e!==void 0)}};function Zz(e,t){return aB(e.type._def,t)}function Qz(e,t){let n={type:`array`,uniqueItems:!0,items:aB(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`]})};return e.minSize&&(n.minItems=e.minSize.value),e.maxSize&&(n.maxItems=e.maxSize.value),n}function $z(e,t){return e.rest?{type:`array`,minItems:e.items.length,items:e.items.map((e,n)=>aB(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[]),additionalItems:aB(e.rest._def,{...t,currentPath:[...t.currentPath,`additionalItems`]})}:{type:`array`,minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,n)=>aB(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[])}}function eB(){return{not:pz()}}function tB(){return pz()}var nB=(e,t)=>aB(e.innerType._def,t),rB=(e,t,n)=>{switch(t){case`ZodString`:return kz(e,n);case`ZodNumber`:return Gz(e);case`ZodObject`:return Kz(e,n);case`ZodBigInt`:return hz(e);case`ZodBoolean`:return gz();case`ZodDate`:return yz(e,n);case`ZodUndefined`:return eB();case`ZodNull`:return Bz();case`ZodArray`:return mz(e,n);case`ZodUnion`:case`ZodDiscriminatedUnion`:return Hz(e,n);case`ZodIntersection`:return Tz(e,n);case`ZodTuple`:return $z(e,n);case`ZodRecord`:return Iz(e,n);case`ZodLiteral`:return Ez(e);case`ZodEnum`:return Cz(e);case`ZodNativeEnum`:return Rz(e);case`ZodNullable`:return Wz(e,n);case`ZodOptional`:return Yz(e,n);case`ZodMap`:return Lz(e,n);case`ZodSet`:return Qz(e,n);case`ZodLazy`:return()=>e.getter()._def;case`ZodPromise`:return Zz(e,n);case`ZodNaN`:case`ZodNever`:return zz();case`ZodEffects`:return Sz(e,n);case`ZodAny`:return pz();case`ZodUnknown`:return tB();case`ZodDefault`:return xz(e,n);case`ZodBranded`:return _z(e,n);case`ZodReadonly`:return nB(e,n);case`ZodCatch`:return vz(e,n);case`ZodPipeline`:return Xz(e,n);case`ZodFunction`:case`ZodVoid`:case`ZodSymbol`:return;default:return(e=>void 0)(t)}},iB=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join(`/`)};function aB(e,t,n=!1){let r=t.seen.get(e);if(t.override){let i=t.override?.call(t,e,t,r,n);if(i!==uz)return i}if(r&&!n){let e=oB(r,t);if(e!==void 0)return e}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let a=rB(e,e.typeName,t),o=typeof a==`function`?aB(a(),t):a;if(o&&sB(e,t,o),t.postProcess){let n=t.postProcess(o,e,t);return i.jsonSchema=o,n}return i.jsonSchema=o,o}var oB=(e,t)=>{switch(t.$refStrategy){case`root`:return{$ref:e.path.join(`/`)};case`relative`:return{$ref:iB(t.currentPath,e.path)};case`none`:case`seen`:return e.path.length<t.currentPath.length&&e.path.every((e,n)=>t.currentPath[n]===e)?(console.warn(`Recursive reference detected at ${t.currentPath.join(`/`)}! Defaulting to any`),pz()):t.$refStrategy===`seen`?pz():void 0}},sB=(e,t,n)=>(e.description&&(n.description=e.description),n),cB=e=>{let t=fz(e),n=t.name===void 0?t.basePath:[...t.basePath,t.definitionPath,t.name];return{...t,currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([e,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}},lB=(e,t)=>{let n=cB(t),r=typeof t==`object`&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:aB(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??pz()}),{}):void 0,i=typeof t==`string`?t:t?.nameStrategy===`title`?void 0:t?.name,a=aB(e._def,i===void 0?n:{...n,currentPath:[...n.basePath,n.definitionPath,i]},!1)??pz(),o=typeof t==`object`&&t.name!==void 0&&t.nameStrategy===`title`?t.name:void 0;o!==void 0&&(a.title=o);let s=i===void 0?r?{...a,[n.definitionPath]:r}:a:{$ref:[...n.$refStrategy===`relative`?[]:n.basePath,n.definitionPath,i].join(`/`),[n.definitionPath]:{...r,[i]:a}};return s.$schema=`http://json-schema.org/draft-07/schema#`,s},uB=Symbol.for(`vercel.ai.schema`);function dB(e){let t;return()=>(t??=e(),t)}function fB(e,{validate:t}={}){return{[uB]:!0,_type:void 0,get jsonSchema(){return typeof e==`function`&&(e=e()),e},validate:t}}function pB(e){return typeof e==`object`&&!!e&&uB in e&&e[uB]===!0&&`jsonSchema`in e&&`validate`in e}function mB(e){return e==null?fB({type:`object`,properties:{},additionalProperties:!1}):pB(e)?e:`~standard`in e?e[`~standard`].vendor===`zod`?bB(e):hB(e):e()}function hB(e){return fB(()=>{if(!gB(e))throw Error(`Standard schema vendor '${e[`~standard`].vendor}' does not support JSON Schema conversion.`);return cz(e[`~standard`].jsonSchema.input({target:`draft-07`}))},{validate:async t=>{let n=await e[`~standard`].validate(t);return`value`in n?{success:!0,value:n.value}:{success:!1,error:new lL({value:t,cause:n.issues})}}})}function gB(e){return e[`~standard`].jsonSchema!=null}function _B(e,t){let n=t?.useReferences??!1;return fB(()=>lB(e,{$refStrategy:n?`root`:`none`}),{validate:async t=>{let n=await e.safeParseAsync(t);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function vB(e,t){let n=t?.useReferences??!1;return fB(()=>cz(MM(e,{target:`draft-7`,io:`input`,reused:n?`ref`:`inline`})),{validate:async t=>{let n=await GM(e,t);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function yB(e){return`_zod`in e}function bB(e,t){return yB(e)?vB(e,t):_B(e,t)}async function xB({value:e,schema:t,context:n}){let r=await SB({value:e,schema:t,context:n});if(!r.success)throw lL.wrap({value:e,cause:r.error,context:n});return r.value}async function SB({value:e,schema:t,context:n}){let r=mB(t);try{if(r.validate==null)return{success:!0,value:e,rawValue:e};let t=await r.validate(e);return t.success?{success:!0,value:t.value,rawValue:e}:{success:!1,error:lL.wrap({value:e,cause:t.error,context:n}),rawValue:e}}catch(t){return{success:!1,error:lL.wrap({value:e,cause:t,context:n}),rawValue:e}}}async function CB({text:e,schema:t}){try{let n=sz(e);return t==null?n:await xB({value:n,schema:t})}catch(t){throw rL.isInstance(t)||lL.isInstance(t)?t:new rL({text:e,cause:t})}}async function wB({text:e,schema:t}){try{let n=sz(e);return t==null?{success:!0,value:n,rawValue:n}:await SB({value:n,schema:t})}catch(t){return{success:!1,error:rL.isInstance(t)?t:new rL({text:e,cause:t}),rawValue:void 0}}}function TB({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new wL).pipeThrough(new TransformStream({async transform({data:e},n){e!==`[DONE]`&&n.enqueue(await wB({text:e,schema:t}))}}))}var EB=()=>globalThis.fetch,DB=async({url:e,headers:t,body:n,failedResponseHandler:r,successfulResponseHandler:i,abortSignal:a,fetch:o})=>await OB({url:e,headers:{"Content-Type":`application/json`,...t},body:{content:JSON.stringify(n),values:n},failedResponseHandler:r,successfulResponseHandler:i,abortSignal:a,fetch:o}),OB=async({url:e,headers:t={},body:n,successfulResponseHandler:r,failedResponseHandler:i,abortSignal:a,fetch:o=EB()})=>{try{let s=await o(e,{method:`POST`,headers:KR(t,`ai-sdk/provider-utils/${qR}`,WR()),body:n.content,signal:a}),c=FR(s);if(!s.ok){let t;try{t=await i({response:s,url:e,requestBodyValues:n.values})}catch(t){throw zR(t)||MI.isInstance(t)?t:new MI({message:`Failed to process error response`,cause:t,statusCode:s.status,url:e,responseHeaders:c,requestBodyValues:n.values})}throw t.value}try{return await r({response:s,url:e,requestBodyValues:n.values})}catch(t){throw t instanceof Error&&(zR(t)||MI.isInstance(t))?t:new MI({message:`Failed to process successful response`,cause:t,statusCode:s.status,url:e,responseHeaders:c,requestBodyValues:n.values})}}catch(t){throw UR({error:t,url:e,requestBodyValues:n.values})}};function kB(e){return e}function AB({id:e,inputSchema:t,outputSchema:n,supportsDeferredResults:r}){return({onInputStart:i,onInputDelta:a,onInputAvailable:o,...s})=>kB({type:`provider`,isProviderExecuted:!0,id:e,args:s,inputSchema:t,outputSchema:n,onInputStart:i,onInputDelta:a,onInputAvailable:o,supportsDeferredResults:r})}async function jB(e){return typeof e==`function`&&(e=e()),Promise.resolve(e)}var MB=({maxRetries:e=2,initialDelayInMs:t=2e3,backoffFactor:n=2,abortSignal:r,shouldRetry:i,getDelayInMs:a=({exponentialBackoffDelay:e})=>e,createRetryError:o=({message:e})=>Error(e)})=>async s=>NB(s,{maxRetries:e,delayInMs:t,backoffFactor:n,abortSignal:r,shouldRetry:i,getDelayInMs:a,createRetryError:o});async function NB(e,{maxRetries:t,delayInMs:n,backoffFactor:r,abortSignal:i,shouldRetry:a,getDelayInMs:o,createRetryError:s},c=[]){try{return await e()}catch(l){if(zR(l)||t===0)throw l;let u=zI(l),d=[...c,l],f=d.length;if(f>t)throw s({message:`Failed after ${f} attempts. Last error: ${u}`,reason:`maxRetriesExceeded`,errors:d});if(await a(l)&&f<=t)return await AL(o({error:l,exponentialBackoffDelay:n}),{abortSignal:i}),NB(e,{maxRetries:t,delayInMs:r*n,backoffFactor:r,abortSignal:i,shouldRetry:a,getDelayInMs:o,createRetryError:s},d);throw f===1?l:s({message:`Failed after ${f} attempts with non-retryable error: '${u}'`,reason:`errorNotRetryable`,errors:d})}}var PB=new TextDecoder;async function FB({response:e,url:t}){return PB.decode(await PR({response:e,url:t}))}var IB=({errorSchema:e,errorToMessage:t,isRetryable:n})=>async({response:r,url:i,requestBodyValues:a})=>{let o=await FB({response:r,url:i}),s=FR(r);if(o.trim()===``)return{responseHeaders:s,value:new MI({message:r.statusText,url:i,requestBodyValues:a,statusCode:r.status,responseHeaders:s,responseBody:o,isRetryable:n?.(r)})};try{let c=await CB({text:o,schema:e});return{responseHeaders:s,value:new MI({message:t(c),url:i,requestBodyValues:a,statusCode:r.status,responseHeaders:s,responseBody:o,data:c,isRetryable:n?.(r,c)})}}catch{return{responseHeaders:s,value:new MI({message:r.statusText,url:i,requestBodyValues:a,statusCode:r.status,responseHeaders:s,responseBody:o,isRetryable:n?.(r)})}}},LB=e=>async({response:t})=>{let n=FR(t);if(t.body==null)throw new RI({});return{responseHeaders:n,value:TB({stream:t.body,schema:e})}},RB=e=>async({response:t,url:n,requestBodyValues:r})=>{let i=await FB({response:t,url:n}),a=await wB({text:i,schema:e}),o=FR(t);if(!a.success)throw new MI({message:`Invalid JSON response`,cause:a.error,statusCode:t.status,responseHeaders:o,responseBody:i,url:n,requestBodyValues:r});return{responseHeaders:o,value:a.value,rawValue:a.rawValue}};function zB(e){if(e==null)return!0;let t=typeof e;return t===`string`||t===`number`||t===`boolean`?!0:t===`function`||t===`symbol`||t===`bigint`?!1:Array.isArray(e)?e.every(zB):Object.getPrototypeOf(e)===Object.prototype&&Object.values(e).every(zB)}var BB=`AI_SerializationError`,VB=`vercel.ai.error.${BB}`,HB=Symbol.for(VB),UB,WB,GB=class extends (WB=H,UB=HB,WB){constructor({message:e=`Failed to serialize value.`,cause:t}={}){super({name:BB,message:e,cause:t}),this[UB]=!0}static isInstance(e){return H.hasMarker(e,VB)}};function KB(e){let t={};for(let[n,r]of Object.entries(e.config))if(n===`headers`){let e=qB(r);zB(e)&&(t[n]=e)}else zB(r)&&(t[n]=r);return{modelId:e.modelId,config:t}}function qB(e){let t=e;if(typeof e==`function`&&(t=e()),t instanceof Promise)throw new GB({message:`Cannot serialize asynchronous model options.`});return t}var JB=`transcription-stream.start`,YB=`transcription-stream.audio-done`;function XB(e){let t;try{t=sz(e)}catch{return}if(typeof t!=`object`||!t||Array.isArray(t))return;let n=t;switch(n.type){case`stream-start`:return Array.isArray(n.warnings)&&n.warnings.every(eV)?n:void 0;case`transcript-delta`:return ZB(n.delta)&&$B(n.id,ZB)&&$B(n.providerMetadata,$R)?n:void 0;case`transcript-partial`:return ZB(n.text)&&$B(n.id,ZB)&&$B(n.startSecond,QB)&&$B(n.durationInSeconds,QB)&&$B(n.channelIndex,QB)&&$B(n.providerMetadata,$R)?n:void 0;case`transcript-final`:return ZB(n.text)&&$B(n.id,ZB)&&$B(n.startSecond,QB)&&$B(n.endSecond,QB)&&$B(n.channelIndex,QB)&&$B(n.providerMetadata,$R)?n:void 0;case`finish`:return ZB(n.text)&&Array.isArray(n.segments)&&n.segments.every(tV)&&$B(n.language,ZB)&&$B(n.durationInSeconds,QB)&&$B(n.providerMetadata,$R)?n:void 0;case`response-metadata`:{if(!($B(n.modelId,ZB)&&$B(n.headers,$R)))return;let e=n.timestamp;if(e==null)return{...n,timestamp:void 0};if(typeof e!=`string`)return;let t=new Date(e);return Number.isNaN(t.getTime())?void 0:{...n,timestamp:t}}case`raw`:return`rawValue`in n?n:void 0;case`error`:return`error`in n?n:void 0;default:return}}function ZB(e){return typeof e==`string`}function QB(e){return typeof e==`number`}function $B(e,t){return e===void 0||t(e)}function eV(e){return $R(e)&&ZB(e.type)}function tV(e){return $R(e)&&ZB(e.text)&&QB(e.startSecond)&&QB(e.endSecond)}function nV(e){return e?.replace(/\/$/,``)}function rV(e){return e!=null&&typeof e.execute==`function`}function iV(e){return e!=null&&typeof e[Symbol.asyncIterator]==`function`}async function*aV({tool:e,input:t,options:n}){let r=e.execute(t,n);if(iV(r)){let e;for await(let t of r)e=t,yield{type:`preliminary`,output:t};yield{type:`final`,output:e}}else yield{type:`final`,output:await r}}function oV(e){return e?.experimental_toolCaller}var sV=o(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{SYMBOL_FOR_REQ_CONTEXT:()=>u,getContext:()=>d}),t.exports=c(l);var u=Symbol.for(`@vercel/request-context`);function d(){return globalThis[u]?.get?.()??{}}0&&(t.exports={SYMBOL_FOR_REQ_CONTEXT:u,getContext:d})})),cV=o(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{AccessTokenMissingError:()=>u,RefreshAccessTokenFailedError:()=>d}),t.exports=c(l);var u=class extends Error{constructor(){super(`No authentication found. Please log in with the Vercel CLI (vercel login).`),this.name=`AccessTokenMissingError`}},d=class extends Error{constructor(e){super(`Failed to refresh authentication token.`,{cause:e}),this.name=`RefreshAccessTokenFailedError`}};0&&(t.exports={AccessTokenMissingError:u,RefreshAccessTokenFailedError:d})})),lV=o(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{AccessTokenMissingError:()=>d.AccessTokenMissingError,RefreshAccessTokenFailedError:()=>d.RefreshAccessTokenFailedError,getContext:()=>u.getContext,getVercelOidcToken:()=>f,getVercelOidcTokenSync:()=>p,getVercelToken:()=>m}),t.exports=c(l);var u=sV(),d=cV();async function f(){return``}function p(){return``}async function m(){throw Error(`getVercelToken is not supported in browser environments`)}0&&(t.exports={AccessTokenMissingError,RefreshAccessTokenFailedError,getContext,getVercelOidcToken:f,getVercelOidcTokenSync:p,getVercelToken:m})}))(),uV=`ai-gateway-realtime.v1`,dV=`ai-gateway-transcription.v1`,fV=`ai-gateway-auth.`,pV=`ai-gateway-team.`;function mV(e,t){return gV(uV,e,t)}function hV(e,t){return gV(dV,e,t)}function gV(e,t,n){let r=[e,`${fV}${t}`];return n?.teamIdOrSlug&&r.push(`${pV}${_V(n.teamIdOrSlug)}`),r}function _V(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/u,``)}var U={any:PN,array:BN,boolean:AN,discriminatedUnion:qN,enum:$N,literal:tP,number:EN,object:HN,record:ZN,string:V,union:GN,unknown:IN},vV=Symbol.for(`vercel.ai.gateway.error`),yV,bV,xV=class e extends (bV=Error,yV=vV,bV){constructor({message:e,statusCode:t=500,cause:n,generationId:r,isRetryable:i=t!=null&&(t===408||t===409||t===429||t>=500)}){super(r?`${e} [${r}]`:e),this[yV]=!0,this.statusCode=t,this.cause=n,this.generationId=r,this.isRetryable=i}static isInstance(t){return e.hasMarker(t)}static hasMarker(e){return typeof e==`object`&&!!e&&vV in e&&e[vV]===!0}},SV=`GatewayAuthenticationError`,CV=`vercel.ai.gateway.error.${SV}`,wV=Symbol.for(CV),TV,EV,DV=class e extends (EV=xV,TV=wV,EV){constructor({message:e=`Authentication failed`,statusCode:t=401,cause:n,generationId:r}={}){super({message:e,statusCode:t,cause:n,generationId:r}),this[TV]=!0,this.name=SV,this.type=`authentication_error`}static isInstance(e){return xV.hasMarker(e)&&wV in e}static createContextualError({apiKeyProvided:t,oidcTokenProvided:n,statusCode:r=401,cause:i,generationId:a}){let o;return o=t?`AI Gateway authentication failed: Invalid API key or token.
|
|
139
|
-
|
|
140
|
-
Create a new API key: https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%2Fapi-keys
|
|
141
|
-
|
|
142
|
-
Provide an API key or Vercel access token via 'apiKey' option or 'AI_GATEWAY_API_KEY' environment variable.`:n?`AI Gateway authentication failed: Invalid OIDC token.
|
|
143
|
-
|
|
144
|
-
Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the token.
|
|
145
|
-
|
|
146
|
-
Alternatively, use an API key: https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%2Fapi-keys
|
|
147
|
-
or pass a Vercel access token via the 'apiKey' option.`:`AI Gateway authentication failed: No authentication provided.
|
|
148
|
-
|
|
149
|
-
Option 1 - API key:
|
|
150
|
-
Create an API key: https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%2Fapi-keys
|
|
151
|
-
Provide via 'apiKey' option or 'AI_GATEWAY_API_KEY' environment variable.
|
|
152
|
-
|
|
153
|
-
Option 2 - Vercel access token:
|
|
154
|
-
Pass a Vercel personal access token or Vercel app access token via the 'apiKey' option.
|
|
155
|
-
|
|
156
|
-
Option 3 - OIDC token:
|
|
157
|
-
Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the token.`,new e({message:o,statusCode:r,cause:i,generationId:a})}},OV=`GatewayInvalidRequestError`,kV=`vercel.ai.gateway.error.${OV}`,AV=Symbol.for(kV),jV,MV,NV=class extends (MV=xV,jV=AV,MV){constructor({message:e=`Invalid request`,statusCode:t=400,cause:n,generationId:r}={}){super({message:e,statusCode:t,cause:n,generationId:r}),this[jV]=!0,this.name=OV,this.type=`invalid_request_error`}static isInstance(e){return xV.hasMarker(e)&&AV in e}},PV=`GatewayRateLimitError`,FV=`vercel.ai.gateway.error.${PV}`,IV=Symbol.for(FV),LV,RV,zV=class extends (RV=xV,LV=IV,RV){constructor({message:e=`Rate limit exceeded`,statusCode:t=429,cause:n,generationId:r}={}){super({message:e,statusCode:t,cause:n,generationId:r}),this[LV]=!0,this.name=PV,this.type=`rate_limit_exceeded`}static isInstance(e){return xV.hasMarker(e)&&IV in e}},BV=`GatewayModelNotFoundError`,VV=`vercel.ai.gateway.error.${BV}`,HV=Symbol.for(VV),UV=dB(()=>bB(U.object({modelId:U.string()}))),WV,GV,KV=class extends (GV=xV,WV=HV,GV){constructor({message:e=`Model not found`,statusCode:t=404,modelId:n,cause:r,generationId:i}={}){super({message:e,statusCode:t,cause:r,generationId:i}),this[WV]=!0,this.name=BV,this.type=`model_not_found`,this.modelId=n}static isInstance(e){return xV.hasMarker(e)&&HV in e}},qV=`GatewayInternalServerError`,JV=`vercel.ai.gateway.error.${qV}`,YV=Symbol.for(JV),XV,ZV,QV=class extends (ZV=xV,XV=YV,ZV){constructor({message:e=`Internal server error`,statusCode:t=500,cause:n,generationId:r}={}){super({message:e,statusCode:t,cause:n,generationId:r}),this[XV]=!0,this.name=qV,this.type=`internal_server_error`}static isInstance(e){return xV.hasMarker(e)&&YV in e}},$V=`GatewayFailedDependencyError`,eH=`vercel.ai.gateway.error.${$V}`,tH=Symbol.for(eH),nH,rH,iH=class extends (rH=xV,nH=tH,rH){constructor({message:e=`Failed dependency`,statusCode:t=424,cause:n,generationId:r}={}){super({message:e,statusCode:t,cause:n,generationId:r}),this[nH]=!0,this.name=$V,this.type=`failed_dependency`}static isInstance(e){return xV.hasMarker(e)&&tH in e}},aH=`GatewayForbiddenError`,oH=`vercel.ai.gateway.error.${aH}`,sH=Symbol.for(oH),cH=dB(()=>bB(U.object({ruleId:U.string()}))),lH,uH,dH=class extends (uH=xV,lH=sH,uH){constructor({message:e=`Forbidden`,statusCode:t=403,cause:n,generationId:r,ruleId:i}={}){super({message:e,statusCode:t,cause:n,generationId:r}),this[lH]=!0,this.name=aH,this.type=`forbidden`,this.ruleId=i}static isInstance(e){return xV.hasMarker(e)&&sH in e}},fH=`GatewayResponseError`,pH=`vercel.ai.gateway.error.${fH}`,mH=Symbol.for(pH),hH,gH,_H=class extends (gH=xV,hH=mH,gH){constructor({message:e=`Invalid response from Gateway`,statusCode:t=502,response:n,validationError:r,cause:i,generationId:a}={}){super({message:e,statusCode:t,cause:i,generationId:a}),this[hH]=!0,this.name=fH,this.type=`response_error`,this.response=n,this.validationError=r}static isInstance(e){return xV.hasMarker(e)&&mH in e}};async function vH({response:e,statusCode:t,defaultMessage:n=`Gateway request failed`,cause:r,authMethod:i}){let a=await SB({value:e,schema:yH});if(!a.success){let i=typeof e==`object`&&e&&`generationId`in e?e.generationId:void 0;return new _H({message:`Invalid error response format: ${n}`,statusCode:t,response:e,validationError:a.error,cause:r,generationId:i})}let o=a.value,s=o.error.type,c=o.error.message,l=o.generationId??void 0;switch(s){case`authentication_error`:return DV.createContextualError({apiKeyProvided:i===`api-key`,oidcTokenProvided:i===`oidc`,statusCode:t,cause:r,generationId:l});case`invalid_request_error`:return new NV({message:c,statusCode:t,cause:r,generationId:l});case`rate_limit_exceeded`:return new zV({message:c,statusCode:t,cause:r,generationId:l});case`model_not_found`:{let e=await SB({value:o.error.param,schema:UV});return new KV({message:c,statusCode:t,modelId:e.success?e.value.modelId:void 0,cause:r,generationId:l})}case`internal_server_error`:return new QV({message:c,statusCode:t,cause:r,generationId:l});case`failed_dependency`:return new iH({message:c,statusCode:t,cause:r,generationId:l});case`forbidden`:{let e=await SB({value:o.error.param,schema:cH});return new dH({message:c,statusCode:t,cause:r,generationId:l,ruleId:e.success?e.value.ruleId:void 0})}default:return new QV({message:c,statusCode:t,cause:r,generationId:l})}}var yH=dB(()=>bB(U.object({error:U.object({message:U.string(),type:U.string().nullish(),param:U.unknown().nullish(),code:U.union([U.string(),U.number()]).nullish()}),generationId:U.string().nullish()})));function bH(e){if(e.data!==void 0)return e.data;if(e.responseBody!=null)try{return sz(e.responseBody)}catch{return e.responseBody}return{}}var xH=`GatewayTimeoutError`,SH=`vercel.ai.gateway.error.${xH}`,CH=Symbol.for(SH),wH,TH,EH=class e extends (TH=xV,wH=CH,TH){constructor({message:e=`Request timed out`,statusCode:t=408,cause:n,generationId:r}={}){super({message:e,statusCode:t,cause:n,generationId:r}),this[wH]=!0,this.name=xH,this.type=`timeout_error`}static isInstance(e){return xV.hasMarker(e)&&CH in e}static createTimeoutError({originalMessage:t,statusCode:n=408,cause:r,generationId:i}){let a=`Gateway request timed out: ${t}
|
|
158
|
-
|
|
159
|
-
This is a client-side timeout. To resolve this, increase your timeout configuration: https://vercel.com/docs/ai-gateway/capabilities/video-generation#extending-timeouts-for-node.js`;return new e({message:a,statusCode:n,cause:r,generationId:i})}};function DH(e){if(!(e instanceof Error))return!1;let t=e.code;return typeof t==`string`&&[`UND_ERR_HEADERS_TIMEOUT`,`UND_ERR_BODY_TIMEOUT`,`UND_ERR_CONNECT_TIMEOUT`].includes(t)}async function OH(e,t){return xV.isInstance(e)?e:DH(e)?EH.createTimeoutError({originalMessage:e instanceof Error?e.message:`Unknown error`,cause:e}):MI.isInstance(e)?e.cause&&DH(e.cause)?EH.createTimeoutError({originalMessage:e.message,cause:e}):await vH({response:bH(e),statusCode:e.statusCode??500,defaultMessage:`Gateway request failed`,cause:e,authMethod:t}):await vH({response:{},statusCode:500,defaultMessage:e instanceof Error?`Gateway request failed: ${e.message}`:`Unknown Gateway error`,cause:e,authMethod:t})}var kH=`ai-gateway-auth-method`,AH=`x-vercel-ai-gateway-team`;async function jH(e){let t=await SB({value:e[kH],schema:MH});return t.success?t.value:void 0}var MH=dB(()=>bB(U.union([U.literal(`api-key`),U.literal(`oidc`)]))),NH=[`embedding`,`image`,`language`,`realtime`,`reranking`,`speech`,`transcription`,`video`],PH=class{constructor(e){this.config=e}async getAvailableModels(){try{let{value:e}=await YR({url:`${this.config.baseURL}/config`,validateUrl:!1,headers:this.config.headers?await jB(this.config.headers):void 0,successfulResponseHandler:RB(FH),failedResponseHandler:IB({errorSchema:U.any(),errorToMessage:e=>zI(e)??`unknown error`}),fetch:this.config.fetch});return e}catch(e){throw await OH(e)}}async getCredits(){try{let{value:e}=await YR({url:`${new URL(this.config.baseURL).origin}/v1/credits`,validateUrl:!1,headers:this.config.headers?await jB(this.config.headers):void 0,successfulResponseHandler:RB(IH),failedResponseHandler:IB({errorSchema:U.any(),errorToMessage:e=>zI(e)??`unknown error`}),fetch:this.config.fetch});return e}catch(e){throw await OH(e)}}},FH=dB(()=>bB(U.object({models:U.array(U.object({id:U.string(),name:U.string(),description:U.string().nullish(),pricing:U.object({input:U.string(),output:U.string(),input_cache_read:U.string().nullish(),input_cache_write:U.string().nullish()}).transform(({input:e,output:t,input_cache_read:n,input_cache_write:r})=>({input:e,output:t,...n?{cachedInputTokens:n}:{},...r?{cacheCreationInputTokens:r}:{}})).nullish(),specification:U.object({specificationVersion:U.literal(`v4`),provider:U.string(),modelId:U.string()}),modelType:U.string().nullish()})).transform(e=>e.filter(e=>e.modelType==null||NH.includes(e.modelType)))}))),IH=dB(()=>bB(U.object({balance:U.string(),total_used:U.string()}).transform(({balance:e,total_used:t})=>({balance:e,totalUsed:t})))),LH=class{constructor(e){this.config=e}async getSpendReport(e){try{let t=new URL(this.config.baseURL),n=new URLSearchParams;n.set(`start_date`,e.startDate),n.set(`end_date`,e.endDate),e.groupBy&&n.set(`group_by`,e.groupBy),e.datePart&&n.set(`date_part`,e.datePart),e.userId&&n.set(`user_id`,e.userId),e.model&&n.set(`model`,e.model),e.provider&&n.set(`provider`,e.provider),e.credentialType&&n.set(`credential_type`,e.credentialType),e.tags&&e.tags.length>0&&n.set(`tags`,e.tags.join(`,`));let{value:r}=await YR({url:`${t.origin}/v1/report?${n.toString()}`,validateUrl:!1,headers:this.config.headers?await jB(this.config.headers):void 0,successfulResponseHandler:RB(RH),failedResponseHandler:IB({errorSchema:U.any(),errorToMessage:e=>zI(e)??`unknown error`}),fetch:this.config.fetch});return r}catch(e){throw await OH(e)}}},RH=dB(()=>bB(U.object({results:U.array(U.object({day:U.string().optional(),hour:U.string().optional(),user:U.string().optional(),model:U.string().optional(),tag:U.string().optional(),provider:U.string().optional(),credential_type:U.enum([`byok`,`system`]).optional(),total_cost:U.number(),market_cost:U.number().optional(),input_tokens:U.number().optional(),output_tokens:U.number().optional(),cached_input_tokens:U.number().optional(),cache_creation_input_tokens:U.number().optional(),reasoning_tokens:U.number().optional(),request_count:U.number().optional()}).transform(({credential_type:e,total_cost:t,market_cost:n,input_tokens:r,output_tokens:i,cached_input_tokens:a,cache_creation_input_tokens:o,reasoning_tokens:s,request_count:c,...l})=>({...l,...e===void 0?{}:{credentialType:e},totalCost:t,...n===void 0?{}:{marketCost:n},...r===void 0?{}:{inputTokens:r},...i===void 0?{}:{outputTokens:i},...a===void 0?{}:{cachedInputTokens:a},...o===void 0?{}:{cacheCreationInputTokens:o},...s===void 0?{}:{reasoningTokens:s},...c===void 0?{}:{requestCount:c}})))}))),zH=class{constructor(e){this.config=e}async getGenerationInfo(e){try{let{value:t}=await YR({url:`${new URL(this.config.baseURL).origin}/v1/generation?id=${encodeURIComponent(e.id)}`,validateUrl:!1,headers:this.config.headers?await jB(this.config.headers):void 0,successfulResponseHandler:RB(BH),failedResponseHandler:IB({errorSchema:U.any(),errorToMessage:e=>zI(e)??`unknown error`}),fetch:this.config.fetch});return t}catch(e){throw await OH(e)}}},BH=dB(()=>bB(U.object({data:U.object({id:U.string(),total_cost:U.number(),upstream_inference_cost:U.number(),usage:U.number(),created_at:U.string(),model:U.string(),is_byok:U.boolean(),provider_name:U.string(),streamed:U.boolean(),finish_reason:U.string(),latency:U.number(),generation_time:U.number(),native_tokens_prompt:U.number(),native_tokens_completion:U.number(),native_tokens_reasoning:U.number(),native_tokens_cached:U.number(),native_tokens_cache_creation:U.number(),billable_web_search_calls:U.number()}).transform(({total_cost:e,upstream_inference_cost:t,created_at:n,is_byok:r,provider_name:i,finish_reason:a,generation_time:o,native_tokens_prompt:s,native_tokens_completion:c,native_tokens_reasoning:l,native_tokens_cached:u,native_tokens_cache_creation:d,billable_web_search_calls:f,...p})=>({...p,totalCost:e,upstreamInferenceCost:t,createdAt:n,isByok:r,providerName:i,finishReason:a,generationTime:o,promptTokens:s,completionTokens:c,reasoningTokens:l,cachedTokens:u,cacheCreationTokens:d,billableWebSearchCalls:f}))}).transform(({data:e})=>e))),VH=class e{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion=`v4`,this.supportedUrls={"*/*":[/.*/]}}static[TL](e){return KB({modelId:e.modelId,config:e.config})}static[EL](t){return new e(t.modelId,t.config)}get provider(){return this.config.provider}async getArgs(e){let{abortSignal:t,...n}=e;return{args:this.maybeEncodeFileParts(n),warnings:[]}}async doGenerate(e){let{args:t,warnings:n}=await this.getArgs(e),{abortSignal:r}=e,i=this.config.headers?await jB(this.config.headers):void 0;try{let{responseHeaders:a,value:o,rawValue:s}=await DB({url:this.getUrl(),headers:OL(i,e.headers,this.getModelConfigHeaders(this.modelId,!1),await jB(this.config.o11yHeaders)),body:t,successfulResponseHandler:RB(U.any()),failedResponseHandler:IB({errorSchema:U.any(),errorToMessage:e=>zI(e)??`unknown error`}),...r&&{abortSignal:r},fetch:this.config.fetch});return{...o,request:{body:t},response:{headers:a,body:s},warnings:n}}catch(e){throw await OH(e,await jH(i??{}))}}async doStream(e){let{args:t,warnings:n}=await this.getArgs(e),{abortSignal:r}=e,i=this.config.headers?await jB(this.config.headers):void 0;try{let{value:a,responseHeaders:o}=await DB({url:this.getUrl(),headers:OL(i,e.headers,this.getModelConfigHeaders(this.modelId,!0),await jB(this.config.o11yHeaders)),body:t,successfulResponseHandler:LB(U.any()),failedResponseHandler:IB({errorSchema:U.any(),errorToMessage:e=>zI(e)??`unknown error`}),...r&&{abortSignal:r},fetch:this.config.fetch});return{stream:a.pipeThrough(new TransformStream({start(e){n.length>0&&e.enqueue({type:`stream-start`,warnings:n})},transform(t,n){if(t.success){let r=t.value;if(r.type===`raw`&&!e.includeRawChunks)return;r.type===`response-metadata`&&r.timestamp&&typeof r.timestamp==`string`&&(r.timestamp=new Date(r.timestamp)),n.enqueue(r)}else n.error(t.error)}})),request:{body:t},response:{headers:o}}}catch(e){throw await OH(e,await jH(i??{}))}}maybeEncodeFileParts(e){for(let t of e.prompt)if(Array.isArray(t.content)){for(let e of t.content)if(e.type===`file`||e.type===`reasoning-file`)e.data=HH(e.data);else if(e.type===`tool-result`&&e.output.type===`content`)for(let t of e.output.value)t.type===`file`&&(t.data=HH(t.data))}return e}getUrl(){return`${this.config.baseURL}/language-model`}getModelConfigHeaders(e,t){return{"ai-language-model-specification-version":`4`,"ai-language-model-id":e,"ai-language-model-streaming":String(t)}}};function HH(e){if(e.type===`data`){let t=e.data;if(t instanceof Uint8Array)return{...e,data:Buffer.from(t).toString(`base64`)}}return e}var UH=class e{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion=`v4`,this.maxEmbeddingsPerCall=2048,this.supportsParallelCalls=!0}static[TL](e){return KB({modelId:e.modelId,config:e.config})}static[EL](t){return new e(t.modelId,t.config)}get provider(){return this.config.provider}async doEmbed({values:e,headers:t,abortSignal:n,providerOptions:r}){let i=this.config.headers?await jB(this.config.headers):void 0;try{let{responseHeaders:a,value:o,rawValue:s}=await DB({url:this.getUrl(),headers:OL(i,t??{},this.getModelConfigHeaders(),await jB(this.config.o11yHeaders)),body:{values:e,...r?{providerOptions:r}:{}},successfulResponseHandler:RB(GH),failedResponseHandler:IB({errorSchema:U.any(),errorToMessage:e=>zI(e)??`unknown error`}),...n&&{abortSignal:n},fetch:this.config.fetch});return{embeddings:o.embeddings,usage:o.usage??void 0,providerMetadata:o.providerMetadata,response:{headers:a,body:s},warnings:o.warnings??[]}}catch(e){throw await OH(e,await jH(i??{}))}}getUrl(){return`${this.config.baseURL}/embedding-model`}getModelConfigHeaders(){return{"ai-embedding-model-specification-version":`4`,"ai-model-id":this.modelId}}},WH=U.discriminatedUnion(`type`,[U.object({type:U.literal(`unsupported`),feature:U.string(),details:U.string().optional()}),U.object({type:U.literal(`compatibility`),feature:U.string(),details:U.string().optional()}),U.object({type:U.literal(`deprecated`),setting:U.string(),message:U.string()}),U.object({type:U.literal(`other`),message:U.string()})]),GH=dB(()=>bB(U.object({embeddings:U.array(U.array(U.number())),usage:U.object({tokens:U.number()}).nullish(),warnings:U.array(WH).optional(),providerMetadata:U.record(U.string(),U.record(U.string(),U.unknown())).optional()}))),KH=class e{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion=`v4`,this.maxImagesPerCall=2**53-1}static[TL](e){return KB({modelId:e.modelId,config:e.config})}static[EL](t){return new e(t.modelId,t.config)}get provider(){return this.config.provider}async doGenerate({prompt:e,n:t,size:n,aspectRatio:r,seed:i,files:a,mask:o,providerOptions:s,headers:c,abortSignal:l}){let u=this.config.headers?await jB(this.config.headers):void 0;try{let{responseHeaders:d,value:f}=await DB({url:this.getUrl(),headers:OL(u,c??{},this.getModelConfigHeaders(),await jB(this.config.o11yHeaders)),body:{prompt:e,n:t,...n&&{size:n},...r&&{aspectRatio:r},...i&&{seed:i},...s&&{providerOptions:s},...a&&{files:a.map(e=>qH(e))},...o&&{mask:qH(o)}},successfulResponseHandler:RB(ZH),failedResponseHandler:IB({errorSchema:U.any(),errorToMessage:e=>zI(e)??`unknown error`}),...l&&{abortSignal:l},fetch:this.config.fetch});return{images:f.images,warnings:f.warnings??[],providerMetadata:f.providerMetadata,response:{timestamp:new Date,modelId:this.modelId,headers:d},...f.usage!=null&&{usage:{inputTokens:f.usage.inputTokens??void 0,outputTokens:f.usage.outputTokens??void 0,totalTokens:f.usage.totalTokens??void 0}}}}catch(e){throw await OH(e,await jH(u??{}))}}getUrl(){return`${this.config.baseURL}/image-model`}getModelConfigHeaders(){return{"ai-image-model-specification-version":`4`,"ai-model-id":this.modelId}}};function qH(e){return e.type===`file`&&e.data instanceof Uint8Array?{...e,data:VL(e.data)}:e}var JH=U.object({images:U.array(U.unknown()).optional()}).catchall(U.unknown()),YH=U.discriminatedUnion(`type`,[U.object({type:U.literal(`unsupported`),feature:U.string(),details:U.string().optional()}),U.object({type:U.literal(`compatibility`),feature:U.string(),details:U.string().optional()}),U.object({type:U.literal(`deprecated`),setting:U.string(),message:U.string()}),U.object({type:U.literal(`other`),message:U.string()})]),XH=U.object({inputTokens:U.number().nullish(),outputTokens:U.number().nullish(),totalTokens:U.number().nullish()}),ZH=U.object({images:U.array(U.string()),warnings:U.array(YH).optional(),providerMetadata:U.record(U.string(),JH).optional(),usage:XH.optional()}),QH=class{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion=`v4`,this.maxVideosPerCall=2**53-1}get provider(){return this.config.provider}async doGenerate(e){let{headers:t,abortSignal:n}=e,r=this.config.headers?await jB(this.config.headers):void 0;try{let{responseHeaders:i,value:a}=await DB({url:this.getUrl(),headers:OL(r,t??{},this.getModelConfigHeaders(),await jB(this.config.o11yHeaders),{accept:`text/event-stream`}),body:this.buildRequestBody(e),successfulResponseHandler:async({response:e,url:t,requestBodyValues:n})=>{if(e.body==null)throw new MI({message:`SSE response body is empty`,url:t,requestBodyValues:n,statusCode:e.status});let r=TB({stream:e.body,schema:rU}).getReader(),{done:i,value:a}=await r.read();if(r.releaseLock(),i||!a)throw new MI({message:`SSE stream ended without a data event`,url:t,requestBodyValues:n,statusCode:e.status});if(!a.success)throw new MI({message:`Failed to parse video SSE event`,cause:a.error,url:t,requestBodyValues:n,statusCode:e.status});let o=a.value;if(o.type===`error`)throw new MI({message:o.message,statusCode:o.statusCode,url:t,requestBodyValues:n,responseHeaders:Object.fromEntries([...e.headers]),responseBody:JSON.stringify(o),data:{error:{message:o.message,type:o.errorType,param:o.param}}});return{value:{videos:o.videos,warnings:o.warnings,providerMetadata:o.providerMetadata},responseHeaders:Object.fromEntries([...e.headers])}},failedResponseHandler:IB({errorSchema:U.any(),errorToMessage:e=>zI(e)??`unknown error`}),...n&&{abortSignal:n},fetch:this.config.fetch});return{videos:a.videos,warnings:a.warnings??[],providerMetadata:a.providerMetadata??void 0,response:{timestamp:new Date,modelId:this.modelId,headers:i}}}catch(e){throw await OH(e,await jH(r??{}))}}async doStart(e){let{headers:t,abortSignal:n,webhookUrl:r}=e,i=this.config.headers?await jB(this.config.headers):void 0;try{let{responseHeaders:a,value:o}=await DB({url:this.getStartUrl(),headers:OL(i,t??{},this.getModelConfigHeaders(),await jB(this.config.o11yHeaders)),body:{...this.buildRequestBody(e),...r&&{callbackUrl:r}},successfulResponseHandler:RB(iU),failedResponseHandler:IB({errorSchema:U.any(),errorToMessage:e=>zI(e)??`unknown error`}),...n&&{abortSignal:n},fetch:this.config.fetch});return{operation:o.operation,warnings:o.warnings??[],providerMetadata:o.providerMetadata??void 0,response:{timestamp:new Date,modelId:this.modelId,headers:a}}}catch(e){throw await OH(e,await jH(i??{}))}}async doStatus({operation:e,abortSignal:t,headers:n}){let r=this.config.headers?await jB(this.config.headers):void 0;try{let{responseHeaders:i,value:a}=await DB({url:this.getStatusUrl(),headers:OL(r,n??{},this.getModelConfigHeaders(),await jB(this.config.o11yHeaders)),body:{operation:e},successfulResponseHandler:RB(aU),failedResponseHandler:IB({errorSchema:U.any(),errorToMessage:e=>zI(e)??`unknown error`}),...t&&{abortSignal:t},fetch:this.config.fetch}),o={timestamp:new Date,modelId:this.modelId,headers:i};return a.status===`completed`?{status:`completed`,videos:a.videos,warnings:a.warnings??[],providerMetadata:a.providerMetadata??void 0,response:o}:a.status===`error`?{status:`error`,error:a.error,providerMetadata:a.providerMetadata??void 0,response:o}:a.status===`cancelled`?{status:`error`,error:`Video generation was cancelled.`,providerMetadata:a.providerMetadata??void 0,response:o}:{status:`pending`,warnings:a.warnings??[],providerMetadata:a.providerMetadata??void 0,response:o}}catch(e){throw await OH(e,await jH(r??{}))}}buildRequestBody({prompt:e,n:t,aspectRatio:n,resolution:r,duration:i,fps:a,seed:o,generateAudio:s,image:c,frameImages:l,inputReferences:u,providerOptions:d}){return{prompt:e,n:t,...n&&{aspectRatio:n},...r&&{resolution:r},...i&&{duration:i},...a&&{fps:a},...o&&{seed:o},...s!==void 0&&{generateAudio:s},...d&&{providerOptions:d},...c&&{image:$H(c)},...l&&{frameImages:l.map(e=>({...e,image:$H(e.image)}))},...u&&{inputReferences:u.map(e=>$H(e))}}}getUrl(){return`${this.config.baseURL}/video-model`}getStartUrl(){return`${this.config.baseURL}/video-model/start`}getStatusUrl(){return`${this.config.baseURL}/video-model/status`}getModelConfigHeaders(){return{"ai-video-model-specification-version":`4`,"ai-model-id":this.modelId}}};function $H(e){return e.type===`file`&&e.data instanceof Uint8Array?{...e,data:VL(e.data)}:e}var eU=U.object({videos:U.array(U.unknown()).optional()}).catchall(U.unknown()),tU=U.union([U.object({type:U.literal(`url`),url:U.string(),mediaType:U.string()}),U.object({type:U.literal(`base64`),data:U.string(),mediaType:U.string()})]),nU=U.discriminatedUnion(`type`,[U.object({type:U.literal(`unsupported`),feature:U.string(),details:U.string().optional()}),U.object({type:U.literal(`compatibility`),feature:U.string(),details:U.string().optional()}),U.object({type:U.literal(`deprecated`),setting:U.string(),message:U.string()}),U.object({type:U.literal(`other`),message:U.string()})]),rU=U.discriminatedUnion(`type`,[U.object({type:U.literal(`result`),videos:U.array(tU),warnings:U.array(nU).optional(),providerMetadata:U.record(U.string(),eU).optional()}),U.object({type:U.literal(`error`),message:U.string(),errorType:U.string(),statusCode:U.number(),param:U.unknown().nullable()})]),iU=U.object({operation:U.unknown(),warnings:U.array(nU).nullish(),providerMetadata:U.record(U.string(),eU).nullish()}),aU=U.discriminatedUnion(`status`,[U.object({status:U.literal(`pending`),warnings:U.array(nU).nullish(),providerMetadata:U.record(U.string(),eU).nullish()}),U.object({status:U.literal(`completed`),videos:U.array(tU),warnings:U.array(nU).nullish(),providerMetadata:U.record(U.string(),eU).nullish()}),U.object({status:U.literal(`error`),error:U.string(),providerMetadata:U.record(U.string(),eU).nullish()}),U.object({status:U.literal(`cancelled`),providerMetadata:U.record(U.string(),eU).nullish()})]),oU=class{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion=`v4`}get provider(){return this.config.provider}async doRerank({documents:e,query:t,topN:n,headers:r,abortSignal:i,providerOptions:a}){let o=this.config.headers?await jB(this.config.headers):void 0;try{let{responseHeaders:s,value:c,rawValue:l}=await DB({url:this.getUrl(),headers:OL(o,r??{},this.getModelConfigHeaders(),await jB(this.config.o11yHeaders)),body:{documents:e,query:t,...n==null?{}:{topN:n},...a?{providerOptions:a}:{}},successfulResponseHandler:RB(cU),failedResponseHandler:IB({errorSchema:U.any(),errorToMessage:e=>zI(e)??`unknown error`}),...i&&{abortSignal:i},fetch:this.config.fetch});return{ranking:c.ranking,providerMetadata:c.providerMetadata,response:{headers:s,body:l},warnings:c.warnings??[]}}catch(e){throw await OH(e,await jH(o??{}))}}getUrl(){return`${this.config.baseURL}/reranking-model`}getModelConfigHeaders(){return{"ai-reranking-model-specification-version":`4`,"ai-model-id":this.modelId}}},sU=U.discriminatedUnion(`type`,[U.object({type:U.literal(`unsupported`),feature:U.string(),details:U.string().optional()}),U.object({type:U.literal(`compatibility`),feature:U.string(),details:U.string().optional()}),U.object({type:U.literal(`deprecated`),setting:U.string(),message:U.string()}),U.object({type:U.literal(`other`),message:U.string()})]),cU=dB(()=>bB(U.object({ranking:U.array(U.object({index:U.number(),relevanceScore:U.number()})),warnings:U.array(sU).optional(),providerMetadata:U.record(U.string(),U.record(U.string(),U.unknown())).optional()}))),lU=class{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion=`v4`}get provider(){return this.config.provider}async doGenerate({text:e,voice:t,outputFormat:n,instructions:r,speed:i,language:a,providerOptions:o,headers:s,abortSignal:c}){let l=this.config.headers?await jB(this.config.headers):void 0;try{let{responseHeaders:u,value:d,rawValue:f}=await DB({url:this.getUrl(),headers:OL(l,s??{},this.getModelConfigHeaders(),await jB(this.config.o11yHeaders)),body:{text:e,...t&&{voice:t},...n&&{outputFormat:n},...r&&{instructions:r},...i!=null&&{speed:i},...a&&{language:a},...o&&{providerOptions:o}},successfulResponseHandler:RB(fU),failedResponseHandler:IB({errorSchema:U.any(),errorToMessage:e=>zI(e)??`unknown error`}),...c&&{abortSignal:c},fetch:this.config.fetch});return{audio:d.audio,warnings:d.warnings??[],providerMetadata:d.providerMetadata,response:{timestamp:new Date,modelId:this.modelId,headers:u,body:f}}}catch(e){throw await OH(e,await jH(l??{}))}}getUrl(){return`${this.config.baseURL}/speech-model`}getModelConfigHeaders(){return{"ai-speech-model-specification-version":`4`,"ai-model-id":this.modelId}}},uU=U.object({}).catchall(U.unknown()),dU=U.discriminatedUnion(`type`,[U.object({type:U.literal(`unsupported`),feature:U.string(),details:U.string().optional()}),U.object({type:U.literal(`compatibility`),feature:U.string(),details:U.string().optional()}),U.object({type:U.literal(`deprecated`),setting:U.string(),message:U.string()}),U.object({type:U.literal(`other`),message:U.string()})]),fU=U.object({audio:U.string(),warnings:U.array(dU).optional(),providerMetadata:U.record(U.string(),uU).optional()}),pU=class{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion=`v4`}get provider(){return this.config.provider}async doGenerate({audio:e,mediaType:t,providerOptions:n,headers:r,abortSignal:i}){let a=this.config.headers?await jB(this.config.headers):void 0;try{let{responseHeaders:o,value:s,rawValue:c}=await DB({url:this.getUrl(),headers:OL(a,r??{},this.getModelConfigHeaders(),await jB(this.config.o11yHeaders)),body:{audio:e instanceof Uint8Array?VL(e):e,mediaType:t,...n&&{providerOptions:n}},successfulResponseHandler:RB(bU),failedResponseHandler:IB({errorSchema:U.any(),errorToMessage:e=>zI(e)??`unknown error`}),...i&&{abortSignal:i},fetch:this.config.fetch});return{text:s.text,segments:s.segments??[],language:s.language??void 0,durationInSeconds:s.durationInSeconds??void 0,warnings:s.warnings??[],providerMetadata:s.providerMetadata,response:{timestamp:new Date,modelId:this.modelId,headers:o,body:c}}}catch(e){throw await OH(e,await jH(a??{}))}}async doStream(e){var t;let n=((t=this.config._internal)?.currentDate)?.call(t)??new Date,r=OL(await jB(this.config.headers??{}),e.headers??{},this.getModelConfigHeaders(),await jB(this.config.o11yHeaders)),i=await jH(r),a={type:JB,inputAudioFormat:e.inputAudioFormat,...e.providerOptions!=null&&{providerOptions:e.providerOptions},...e.includeRawChunks!=null&&{includeRawChunks:e.includeRawChunks}};return{stream:_U({webSocket:this.config.webSocket,url:mU(this.config.baseURL,this.modelId),protocols:hU(r),headers:r,startFrame:a,audio:e.audio,abortSignal:e.abortSignal,authMethod:i}),request:{body:a},response:{timestamp:n,modelId:this.modelId}}}getUrl(){return`${this.config.baseURL}/transcription-model`}getModelConfigHeaders(){return{"ai-transcription-model-specification-version":`4`,"ai-model-id":this.modelId}}};function mU(e,t){let n=new URL(`${e.replace(/^http/,`ws`)}/transcription-model`);return n.searchParams.set(`ai-model-id`,t),n.toString()}function hU(e){let t=GR(e),n=t.authorization,r=n?.startsWith(`Bearer `)?n.slice(7):void 0;return r==null?[dV]:hV(r,{teamIdOrSlug:t[AH]})}var gU=65536;function _U({webSocket:e,url:t,protocols:n,headers:r,startFrame:i,audio:a,abortSignal:o,authMethod:s}){let c=!1,l=()=>{};return new ReadableStream({start:u=>{let d,f=!1,p,m=!1,h;l=e=>{d==null?a.cancel().catch(()=>{}):d.cancel().catch(()=>{}),h?.close(e)};let g=()=>{m=!0,d==null?a.cancel().catch(()=>{}):(d.cancel().catch(()=>{}),d=void 0)},_=e=>{c||(c=!0,l(),xU(u,e,s))},v=async e=>{let t=a.getReader();d=t;try{for(;;){let{done:n,value:r}=await t.read();if(n||c)break;let i=typeof r==`string`?BL(r):r;for(let t=0;t<i.length&&!c;t+=gU)e.send(i.subarray(t,t+gU)),await IL(e)}}finally{t.releaseLock(),d===t&&(d=void 0)}!c&&!m&&e.send(JSON.stringify({type:YB}))};h=LL({url:t,protocols:n,headers:r,webSocket:e,abortSignal:o,onAbort:e=>{c||(c=!0,l(),u.error(e))},onProcessingError:_,onOpen:e=>{e.send(JSON.stringify(i)),v(e).catch(_)},onMessageText:e=>{if(c)return;let t=XB(e);if(t!=null){if(t.type===`finish`){c=!0,u.enqueue(t),u.close(),l(1e3);return}t.type===`error`&&(f=!0,p=t.error,g()),u.enqueue(t)}},onSocketError:()=>{_(Error(`Connection error on AI Gateway transcription stream`))},onClose:()=>{if(f){if(c)return;wU(p,s).then(_);return}_(Error(`AI Gateway transcription stream closed before a finish part was received`))}})},cancel:()=>{c||(c=!0,l())}})}var vU=U.object({}).catchall(U.unknown()),yU=U.discriminatedUnion(`type`,[U.object({type:U.literal(`unsupported`),feature:U.string(),details:U.string().optional()}),U.object({type:U.literal(`compatibility`),feature:U.string(),details:U.string().optional()}),U.object({type:U.literal(`deprecated`),setting:U.string(),message:U.string()}),U.object({type:U.literal(`other`),message:U.string()})]),bU=U.object({text:U.string(),segments:U.array(U.object({text:U.string(),startSecond:U.number(),endSecond:U.number()})).optional(),language:U.string().nullish(),durationInSeconds:U.number().nullish(),warnings:U.array(yU).optional(),providerMetadata:U.record(U.string(),vU).optional()});async function xU(e,t,n){e.error(await OH(t,n))}function SU(e){return typeof e==`object`&&e&&`message`in e&&typeof e.message==`string`?e.message:zI(e)}var CU={authentication_error:401,failed_dependency:424,forbidden:403,internal_server_error:500,invalid_request_error:400,model_not_found:404,rate_limit_exceeded:429};async function wU(e,t){return typeof e==`object`&&e&&`message`in e&&typeof e.message==`string`&&`type`in e&&typeof e.type==`string`&&e.type in CU?vH({response:{error:{message:e.message,type:e.type}},statusCode:CU[e.type],authMethod:t}):Error(`AI Gateway transcription stream failed: ${SU(e)}`)}var TU=class{constructor(e,t){this.specificationVersion=`v4`,this.modelId=e,this.provider=t.provider,this.config=t}async doCreateClientSecret(e){let t=await this.config.createClientSecret({modelId:this.modelId,...e?.expiresAfterSeconds!=null&&{expiresAfterSeconds:e.expiresAfterSeconds}});return{token:t.token,url:EU(this.config.baseURL,this.modelId),...t.expiresAt!=null&&{expiresAt:t.expiresAt}}}getWebSocketConfig(e){return{url:e.url,protocols:mV(e.token,{teamIdOrSlug:this.config.teamIdOrSlug})}}parseServerEvent(e){return e}serializeClientEvent(e){return e}buildSessionConfig(e){return e}};function EU(e,t){let n=new URL(`${e.replace(/^http/,`ws`)}/realtime-model`);return n.searchParams.set(`ai-model-id`,t),n.toString()}var DU=AB({id:`gateway.exa_search`,inputSchema:dB(()=>bB(U.object({query:U.string().describe(`Natural-language web search query. This is required.`),type:U.enum([`auto`,`fast`,`instant`]).optional().describe(`Search method. Use auto for the default balance of speed and quality.`),num_results:U.number().optional().describe(`Maximum number of results to return (1-100, default: 10).`),category:U.enum([`company`,`people`,`research paper`,`news`,`personal site`,`financial report`]).optional().describe(`Optional content category to focus results.`),user_location:U.string().optional().describe(`Two-letter ISO country code such as 'US'.`),include_domains:U.array(U.string()).optional().describe(`Only return results from these domains.`),exclude_domains:U.array(U.string()).optional().describe(`Exclude results from these domains.`),start_published_date:U.string().optional().describe(`Only return links published after this ISO 8601 date.`),end_published_date:U.string().optional().describe(`Only return links published before this ISO 8601 date.`),contents:U.object({text:U.union([U.boolean(),U.object({max_characters:U.number().optional(),include_html_tags:U.boolean().optional(),verbosity:U.enum([`compact`,`standard`,`full`]).optional(),include_sections:U.array(U.enum([`header`,`navigation`,`banner`,`body`,`sidebar`,`footer`,`metadata`])).optional(),exclude_sections:U.array(U.enum([`header`,`navigation`,`banner`,`body`,`sidebar`,`footer`,`metadata`])).optional()})]).optional(),highlights:U.union([U.boolean(),U.object({query:U.string().optional(),max_characters:U.number().optional()})]).optional(),max_age_hours:U.number().optional(),livecrawl_timeout:U.number().optional(),subpages:U.number().optional(),subpage_target:U.union([U.string(),U.array(U.string())]).optional(),extras:U.object({links:U.number().optional(),image_links:U.number().optional()}).optional()}).optional().describe(`Controls extracted page content and freshness.`)}))),outputSchema:dB(()=>bB(U.union([U.object({requestId:U.string(),searchType:U.string().optional(),resolvedSearchType:U.string().optional(),results:U.array(U.object({title:U.string(),url:U.string(),id:U.string(),publishedDate:U.string().nullable().optional(),author:U.string().nullable().optional(),image:U.string().nullable().optional(),favicon:U.string().nullable().optional(),text:U.string().optional(),highlights:U.array(U.string()).optional(),highlightScores:U.array(U.number()).optional(),summary:U.string().optional(),subpages:U.array(U.any()).optional(),extras:U.object({links:U.array(U.string()).optional(),imageLinks:U.array(U.string()).optional()}).optional()})),costDollars:U.object({total:U.number().optional(),search:U.record(U.string(),U.number()).optional()}).optional()}),U.object({error:U.enum([`api_error`,`rate_limit`,`timeout`,`invalid_input`,`configuration_error`,`execution_error`,`unknown`]),statusCode:U.number().optional(),message:U.string()})])))}),OU=(e={})=>DU(e),kU=AB({id:`gateway.parallel_search`,inputSchema:dB(()=>bB(U.object({objective:U.string().describe(`Natural-language description of the web research goal, including source or freshness guidance and broader context from the task. Maximum 5000 characters.`),search_queries:U.array(U.string()).optional().describe(`Optional search queries to supplement the objective. Maximum 200 characters per query.`),mode:U.enum([`one-shot`,`agentic`]).optional().describe(`Mode preset: "one-shot" for comprehensive results with longer excerpts (default), "agentic" for concise, token-efficient results for multi-step workflows.`),max_results:U.number().optional().describe(`Maximum number of results to return (1-20). Defaults to 10 if not specified.`),source_policy:U.object({include_domains:U.array(U.string()).optional().describe(`Limit results to these domains. Use plain domain names only — e.g. example.com or sub.example.gov, or a bare extension like .edu. Do not include a scheme, path, or port (e.g. not https://example.com/page).`),exclude_domains:U.array(U.string()).optional().describe(`Exclude results from these domains. Use plain domain names only — e.g. example.com or sub.example.gov, or a bare extension like .edu. Do not include a scheme, path, or port (e.g. not https://example.com/page).`),after_date:U.string().optional().describe(`Only include results published after this date. Use an ISO 8601 calendar date formatted YYYY-MM-DD (e.g. 2025-01-01); do not include a time.`)}).optional().describe(`Source policy for controlling which domains to include/exclude and freshness.`),excerpts:U.object({max_chars_per_result:U.number().optional().describe(`Maximum characters per result.`),max_chars_total:U.number().optional().describe(`Maximum total characters across all results.`)}).optional().describe(`Excerpt configuration for controlling result length.`),fetch_policy:U.object({max_age_seconds:U.number().optional().describe(`Maximum age in seconds for cached content. Set to 0 to always fetch fresh content.`)}).optional().describe(`Fetch policy for controlling content freshness.`)}))),outputSchema:dB(()=>bB(U.union([U.object({searchId:U.string(),results:U.array(U.object({url:U.string(),title:U.string(),excerpt:U.string(),publishDate:U.string().nullable().optional(),relevanceScore:U.number().optional()}))}),U.object({error:U.enum([`api_error`,`rate_limit`,`timeout`,`invalid_input`,`configuration_error`,`unknown`]),statusCode:U.number().optional(),message:U.string()})])))}),AU=(e={})=>kU(e),jU=AB({id:`gateway.perplexity_search`,inputSchema:dB(()=>bB(U.object({query:U.union([U.string(),U.array(U.string())]).describe(`Search query (string) or multiple queries (array of up to 5 strings). Multi-query searches return combined results from all queries.`),max_results:U.number().optional().describe(`Maximum number of search results to return (1-20, default: 10)`),max_tokens_per_page:U.number().optional().describe(`Maximum number of tokens to extract per search result page (256-2048, default: 2048)`),max_tokens:U.number().optional().describe(`Maximum total tokens across all search results (default: 25000, max: 1000000)`),country:U.string().optional().describe(`Two-letter ISO 3166-1 alpha-2 country code for regional search results (e.g., 'US', 'GB', 'FR')`),search_domain_filter:U.array(U.string()).optional().describe(`List of domains to include or exclude from search results (max 20). To include: ['nature.com', 'science.org']. To exclude: ['-example.com', '-spam.net']`),search_language_filter:U.array(U.string()).optional().describe(`List of ISO 639-1 language codes to filter results (max 10, lowercase). Examples: ['en', 'fr', 'de']`),search_after_date:U.string().optional().describe(`Include only results published after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter.`),search_before_date:U.string().optional().describe(`Include only results published before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter.`),last_updated_after_filter:U.string().optional().describe(`Include only results last updated after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter.`),last_updated_before_filter:U.string().optional().describe(`Include only results last updated before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter.`),search_recency_filter:U.enum([`day`,`week`,`month`,`year`]).optional().describe(`Filter results by relative time period. Cannot be used with search_after_date or search_before_date.`)}))),outputSchema:dB(()=>bB(U.union([U.object({results:U.array(U.object({title:U.string(),url:U.string(),snippet:U.string(),date:U.string().optional(),lastUpdated:U.string().optional()})),id:U.string()}),U.object({error:U.enum([`api_error`,`rate_limit`,`timeout`,`invalid_input`,`unknown`]),statusCode:U.number().optional(),message:U.string()})])))}),MU={exaSearch:OU,parallelSearch:AU,perplexitySearch:(e={})=>jU(e)};async function NU(){return(0,lV.getContext)().headers?.[`x-vercel-id`]}var PU=`4.0.52`,FU=`0.0.1`,IU=U.object({token:U.string(),expiresAt:U.number().nullish()});function LU(e={}){let t=null,n=null,r=e.metadataCacheRefreshMillis??3e5,i=0,a=nV(e.baseURL)??`https://ai-gateway.vercel.sh/v4/ai`,o=t=>KR({Authorization:`Bearer ${t.token}`,"ai-gateway-protocol-version":FU,[kH]:t.authMethod,...e.teamIdOrSlug==null?{}:{[AH]:e.teamIdOrSlug},...e.headers},`ai-sdk/gateway/${PU}`),s=async()=>{try{return o(await zU(e))}catch(e){throw DV.createContextualError({apiKeyProvided:!1,oidcTokenProvided:!1,statusCode:401,cause:e})}},c=async()=>{try{return await zU(e)}catch(e){throw DV.createContextualError({apiKeyProvided:!1,oidcTokenProvided:!1,statusCode:401,cause:e})}},l=async t=>{BU();let n=await c(),r=o(n),i=new URL(`/v1/realtime/client-secrets`,a).toString();try{let{value:n}=await DB({url:i,headers:r,body:{model:t.modelId,...t.routeKind!=null&&{routeKind:t.routeKind},...t.expiresAfterSeconds!=null&&{expiresIn:t.expiresAfterSeconds}},successfulResponseHandler:RB(IU),failedResponseHandler:IB({errorSchema:U.any(),errorToMessage:e=>zI(e)??`unknown error`}),fetch:e.fetch});return{token:n.token,...n.expiresAt!=null&&{expiresAt:n.expiresAt}}}catch(e){throw await OH(e,await jH(r))}},u=()=>{let e=nz({settingValue:void 0,environmentVariableName:`VERCEL_DEPLOYMENT_ID`}),t=nz({settingValue:void 0,environmentVariableName:`VERCEL_ENV`}),n=nz({settingValue:void 0,environmentVariableName:`VERCEL_REGION`}),r=nz({settingValue:void 0,environmentVariableName:`VERCEL_PROJECT_ID`});return async()=>{let i=await NU();return{...e&&{"ai-o11y-deployment-id":e},...t&&{"ai-o11y-environment":t},...n&&{"ai-o11y-region":n},...i&&{"ai-o11y-request-id":i},...r&&{"ai-o11y-project-id":r}}}},d=t=>new VH(t,{provider:`gateway`,baseURL:a,headers:s,fetch:e.fetch,o11yHeaders:u()}),f=async()=>{var o;let c=((o=e._internal)?.currentDate)?.call(o).getTime()??Date.now();return(!t||c-i>r)&&(i=c,t=new PH({baseURL:a,headers:s,fetch:e.fetch}).getAvailableModels().then(e=>(n=e,e)).catch(async e=>{throw await OH(e,await jH(await s()))})),n?Promise.resolve(n):t},p=async()=>new PH({baseURL:a,headers:s,fetch:e.fetch}).getCredits().catch(async e=>{throw await OH(e,await jH(await s()))}),m=async t=>new LH({baseURL:a,headers:s,fetch:e.fetch}).getSpendReport(t).catch(async e=>{throw await OH(e,await jH(await s()))}),h=async t=>new zH({baseURL:a,headers:s,fetch:e.fetch}).getGenerationInfo(t).catch(async e=>{throw await OH(e,await jH(await s()))}),g=function(e){if(new.target)throw Error(`The Gateway Provider model function cannot be called with the new keyword.`);return d(e)};g.specificationVersion=`v4`,g.getAvailableModels=f,g.getCredits=p,g.getSpendReport=m,g.getGenerationInfo=h,g.imageModel=t=>new KH(t,{provider:`gateway`,baseURL:a,headers:s,fetch:e.fetch,o11yHeaders:u()}),g.languageModel=d;let _=t=>new UH(t,{provider:`gateway`,baseURL:a,headers:s,fetch:e.fetch,o11yHeaders:u()});g.embeddingModel=_,g.textEmbeddingModel=_,g.videoModel=t=>new QH(t,{provider:`gateway`,baseURL:a,headers:s,fetch:e.fetch,o11yHeaders:u()});let v=t=>new oU(t,{provider:`gateway`,baseURL:a,headers:s,fetch:e.fetch,o11yHeaders:u()});g.rerankingModel=v,g.reranking=v;let y=t=>new lU(t,{provider:`gateway`,baseURL:a,headers:s,fetch:e.fetch,o11yHeaders:u()});g.speechModel=y,g.speech=y;let b=t=>new pU(t,{provider:`gateway`,baseURL:a,headers:s,fetch:e.fetch,o11yHeaders:u(),webSocket:e.webSocket});g.transcriptionModel=b,g.transcription=b,g.experimental_transcription=Object.assign(e=>b(e),{getToken:async e=>{let t=await l({modelId:e.model,routeKind:`transcription`,...e.expiresAfterSeconds!=null&&{expiresAfterSeconds:e.expiresAfterSeconds}});return{token:t.token,url:mU(a,e.model),...t.expiresAt!=null&&{expiresAt:t.expiresAt}}}});let x=t=>new TU(t,{provider:`gateway.realtime`,baseURL:a,teamIdOrSlug:e.teamIdOrSlug,createClientSecret:l});return g.experimental_realtime=Object.assign(e=>x(e),{getToken:async e=>{let{model:t,...n}=e,r=await x(t).doCreateClientSecret(n);return{token:r.token,url:r.url,...r.expiresAt!=null&&{expiresAt:r.expiresAt}}}}),g.chat=g.languageModel,g.embedding=g.embeddingModel,g.image=g.imageModel,g.video=g.videoModel,g.tools=MU,g}var RU=LU();async function zU(e){let t=nz({settingValue:e.apiKey,environmentVariableName:`AI_GATEWAY_API_KEY`});return t?{token:t,authMethod:`api-key`}:{token:await(0,lV.getVercelOidcToken)(),authMethod:`oidc`}}function BU(){if(globalThis.window!==void 0)throw Error(`AI Gateway client secrets must be minted server-side: minting needs your Gateway credential, which must never reach the browser. Call gateway.experimental_realtime.getToken() or gateway.experimental_transcription.getToken() from your server and pass the returned token to the client.`)}var VU=Object.defineProperty,HU=(e,t)=>{for(var n in t)VU(e,n,{get:t[n],enumerable:!0})},UU=`AI_InvalidArgumentError`,WU=`vercel.ai.error.${UU}`,GU=Symbol.for(WU),KU,qU=class extends H{constructor({parameter:e,value:t,message:n}){super({name:UU,message:`Invalid argument for parameter ${e}: ${n}`}),this[KU]=!0,this.parameter=e,this.value=t}static isInstance(e){return H.hasMarker(e,WU)}};KU=GU;var JU=`AI_InvalidToolApprovalError`,YU=`vercel.ai.error.${JU}`,XU=Symbol.for(YU),ZU,QU=class extends H{constructor({approvalId:e}){super({name:JU,message:`Tool approval response references unknown approvalId: "${e}". No matching tool-approval-request found in message history.`}),this[ZU]=!0,this.approvalId=e}static isInstance(e){return H.hasMarker(e,YU)}};ZU=XU;var $U=`AI_InvalidToolApprovalSignatureError`,eW=`vercel.ai.error.${$U}`,tW=Symbol.for(eW),nW,rW=class extends H{constructor({approvalId:e,toolCallId:t,reason:n}){super({name:$U,message:`Tool approval signature verification failed for approval "${e}" (tool call "${t}"): ${n}`}),this[nW]=!0,this.approvalId=e,this.toolCallId=t}static isInstance(e){return H.hasMarker(e,eW)}};nW=tW;var iW=`AI_InvalidToolInputError`,aW=`vercel.ai.error.${iW}`,oW=Symbol.for(aW),sW,cW=class extends H{constructor({toolInput:e,toolName:t,cause:n,message:r=`Invalid input for tool ${t}: ${zI(n)}`}){super({name:iW,message:r,cause:n}),this[sW]=!0,this.toolInput=e,this.toolName=t}static isInstance(e){return H.hasMarker(e,aW)}};sW=oW;var lW=`AI_ToolCallNotFoundForApprovalError`,uW=`vercel.ai.error.${lW}`,dW=Symbol.for(uW),fW,pW=class extends H{constructor({toolCallId:e,approvalId:t}){super({name:lW,message:`Tool call "${e}" not found for approval request "${t}".`}),this[fW]=!0,this.toolCallId=e,this.approvalId=t}static isInstance(e){return H.hasMarker(e,uW)}};fW=dW;var mW=`AI_MissingToolResultsError`,hW=`vercel.ai.error.${mW}`,gW=Symbol.for(hW),_W,vW=class extends H{constructor({toolCallIds:e}){super({name:mW,message:`Tool result${e.length>1?`s are`:` is`} missing for tool call${e.length>1?`s`:``} ${e.join(`, `)}.`}),this[_W]=!0,this.toolCallIds=e}static isInstance(e){return H.hasMarker(e,hW)}};_W=gW;var yW=`AI_NoObjectGeneratedError`,bW=`vercel.ai.error.${yW}`,xW=Symbol.for(bW),SW,CW=class extends H{constructor({message:e=`No object generated.`,cause:t,text:n,response:r,usage:i,finishReason:a}){super({name:yW,message:e,cause:t}),this[SW]=!0,this.text=n,this.response=r,this.usage=i,this.finishReason=a}static isInstance(e){return H.hasMarker(e,bW)}};SW=xW;var wW=`AI_NoOutputGeneratedError`,TW=`vercel.ai.error.${wW}`,EW=Symbol.for(TW),DW,OW=class extends H{constructor({message:e=`No output generated.`,cause:t}={}){super({name:wW,message:e,cause:t}),this[DW]=!0}static isInstance(e){return H.hasMarker(e,TW)}};DW=EW;var kW=`AI_NoSuchToolError`,AW=`vercel.ai.error.${kW}`,jW=Symbol.for(AW),MW,NW=class extends H{constructor({toolName:e,availableTools:t=void 0,message:n=`Model tried to call unavailable tool '${e}'. ${t===void 0?`No tools are available.`:`Available tools: ${t.join(`, `)}.`}`}){super({name:kW,message:n}),this[MW]=!0,this.toolName=e,this.availableTools=t}static isInstance(e){return H.hasMarker(e,AW)}};MW=jW;var PW=`AI_ToolCallRepairError`,FW=`vercel.ai.error.${PW}`,IW=Symbol.for(FW),LW,RW=class extends H{constructor({cause:e,originalError:t,message:n=`Error repairing tool call: ${zI(e)}`}){super({name:PW,message:n,cause:e}),this[LW]=!0,this.originalError=t}static isInstance(e){return H.hasMarker(e,FW)}};LW=IW;var zW=class extends H{constructor(e){super({name:`AI_UnsupportedModelVersionError`,message:`Unsupported model version ${e.version} for provider "${e.provider}" and model "${e.modelId}". AI SDK 5 only supports models that implement specification version "v2".`}),this.version=e.version,this.provider=e.provider,this.modelId=e.modelId}},BW=`AI_UIMessageStreamError`,VW=`vercel.ai.error.${BW}`,HW=Symbol.for(VW),UW,WW=class extends H{constructor({chunkType:e,chunkId:t,message:n}){super({name:BW,message:n}),this[UW]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return H.hasMarker(e,VW)}};UW=HW;var GW=`AI_InvalidDataContentError`,KW=`vercel.ai.error.${GW}`,qW=Symbol.for(KW),JW,YW=class extends H{constructor({content:e,cause:t,message:n=`Invalid data content. Expected a base64 string, Uint8Array, ArrayBuffer, or Buffer, but got ${typeof e}.`}){super({name:GW,message:n,cause:t}),this[JW]=!0,this.content=e}static isInstance(e){return H.hasMarker(e,KW)}};JW=qW;var XW=`AI_InvalidMessageRoleError`,ZW=`vercel.ai.error.${XW}`,QW=Symbol.for(ZW),$W,eG=class extends H{constructor({role:e,message:t=`Invalid message role: '${e}'. Must be one of: "system", "user", "assistant", "tool".`}){super({name:XW,message:t}),this[$W]=!0,this.role=e}static isInstance(e){return H.hasMarker(e,ZW)}};$W=QW;var tG=`AI_MessageConversionError`,nG=`vercel.ai.error.${tG}`,rG=Symbol.for(nG),iG,aG=class extends H{constructor({originalMessage:e,message:t}){super({name:tG,message:t}),this[iG]=!0,this.originalMessage=e}static isInstance(e){return H.hasMarker(e,nG)}};iG=rG;var oG=`AI_RetryError`,sG=`vercel.ai.error.${oG}`,cG=Symbol.for(sG),lG,uG=class extends H{constructor({message:e,reason:t,errors:n}){super({name:oG,message:e}),this[lG]=!0,this.reason=t,this.errors=n,this.lastError=n[n.length-1]}static isInstance(e){return H.hasMarker(e,sG)}};lG=cG;function dG({warning:e,provider:t,model:n}){let r=`AI SDK Warning${t!=null&&n!=null?` (${t} / ${n})`:``}:`;switch(e.type){case`unsupported`:{let t=`${r} The feature "${e.feature}" is not supported.`;return e.details&&(t+=` ${e.details}`),t}case`compatibility`:{let t=`${r} The feature "${e.feature}" is used in a compatibility mode.`;return e.details&&(t+=` ${e.details}`),t}case`deprecated`:return`${r} Deprecated: "${e.setting}". ${e.message}`;case`other`:return`${r} ${e.message}`;default:return`${r} ${JSON.stringify(e,null,2)}`}}var fG=`AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.`,pG=!1;function mG({message:e,type:t}){typeof process<`u`&&typeof process.emitWarning==`function`?process.emitWarning(e,{type:t}):console.warn(e)}var hG=e=>{if(e.warnings.length===0)return;let t=globalThis.AI_SDK_LOG_WARNINGS;if(t!==!1){if(typeof t==`function`){t(e);return}pG||(pG=!0,mG({message:fG,type:`Warning`}));for(let t of e.warnings)mG({message:dG({warning:t,provider:e.provider,model:e.model}),type:t.type===`deprecated`?`DeprecationWarning`:`Warning`})}};function gG({provider:e,modelId:t}){hG({warnings:[{type:`compatibility`,feature:`specificationVersion`,details:`Using v2 specification compatibility mode. Some features may not be available.`}],provider:e,model:t})}function _G(e){return e.specificationVersion===`v3`?e:(gG({provider:e.provider,modelId:e.modelId}),new Proxy(e,{get(e,t){return t===`specificationVersion`?`v3`:e[t]}}))}function vG(e){if(e.specificationVersion===`v4`)return e;let t=e.specificationVersion===`v2`?_G(e):e;return new Proxy(t,{get(e,t){return t===`specificationVersion`?`v4`:e[t]}})}function yG(e){return e.specificationVersion===`v3`?e:(gG({provider:e.provider,modelId:e.modelId}),new Proxy(e,{get(e,t){return t===`specificationVersion`?`v3`:e[t]}}))}function bG(e){if(e.specificationVersion===`v4`)return e;let t=e.specificationVersion===`v2`?yG(e):e;return new Proxy(t,{get(e,t){return t===`specificationVersion`?`v4`:e[t]}})}function xG(e){return e.specificationVersion===`v3`?e:(gG({provider:e.provider,modelId:e.modelId}),new Proxy(e,{get(e,t){switch(t){case`specificationVersion`:return`v3`;case`doGenerate`:return async(...t)=>{let n=await e.doGenerate(...t);return{...n,finishReason:CG(n.finishReason),usage:wG(n.usage)}};case`doStream`:return async(...t)=>{let n=await e.doStream(...t);return{...n,stream:SG(n.stream)}};default:return e[t]}}}))}function SG(e){return e.pipeThrough(new TransformStream({transform(e,t){switch(e.type){case`finish`:t.enqueue({...e,finishReason:CG(e.finishReason),usage:wG(e.usage)});break;default:t.enqueue(e)}}}))}function CG(e){return{unified:e===`unknown`?`other`:e,raw:void 0}}function wG(e){return{inputTokens:{total:e.inputTokens,noCache:void 0,cacheRead:e.cachedInputTokens,cacheWrite:void 0},outputTokens:{total:e.outputTokens,text:void 0,reasoning:e.reasoningTokens}}}function TG(e){if(e.specificationVersion===`v4`)return e;let t=e.specificationVersion===`v2`?xG(e):e;return new Proxy(t,{get(e,t){return t===`specificationVersion`?`v4`:e[t]}})}function EG(e){return e.specificationVersion===`v4`?e:new Proxy(e,{get(e,t){return t===`specificationVersion`?`v4`:e[t]}})}function DG(e){return e.specificationVersion===`v3`?e:(gG({provider:e.provider,modelId:e.modelId}),new Proxy(e,{get(e,t){return t===`specificationVersion`?`v3`:e[t]}}))}function OG(e){if(e.specificationVersion===`v4`)return e;let t=e.specificationVersion===`v2`?DG(e):e;return new Proxy(t,{get(e,t){return t===`specificationVersion`?`v4`:e[t]}})}function kG(e){return e.specificationVersion===`v3`?e:(gG({provider:e.provider,modelId:e.modelId}),new Proxy(e,{get(e,t){return t===`specificationVersion`?`v3`:e[t]}}))}function AG(e){if(e.specificationVersion===`v4`)return e;let t=e.specificationVersion===`v2`?kG(e):e;return new Proxy(t,{get(e,t){return t===`specificationVersion`?`v4`:e[t]}})}function jG(e){if(`specificationVersion`in e&&e.specificationVersion===`v3`)return e;let t=e;return{specificationVersion:`v3`,languageModel:e=>xG(t.languageModel(e)),embeddingModel:e=>_G(t.textEmbeddingModel(e)),imageModel:e=>yG(t.imageModel(e)),transcriptionModel:t.transcriptionModel?e=>kG(t.transcriptionModel(e)):void 0,speechModel:t.speechModel?e=>DG(t.speechModel(e)):void 0,rerankingModel:void 0}}function MG(e){if(`specificationVersion`in e&&e.specificationVersion===`v4`)return e;let t=!(`specificationVersion`in e)||e.specificationVersion!==`v3`?jG(e):e;return{specificationVersion:`v4`,languageModel:e=>TG(t.languageModel(e)),embeddingModel:e=>vG(t.embeddingModel(e)),imageModel:e=>bG(t.imageModel(e)),transcriptionModel:t.transcriptionModel?e=>AG(t.transcriptionModel(e)):void 0,speechModel:t.speechModel?e=>OG(t.speechModel(e)):void 0,rerankingModel:t.rerankingModel?e=>EG(t.rerankingModel(e)):void 0}}function NG(e){if(typeof e==`string`)return PG().languageModel(e);if(![`v4`,`v3`,`v2`].includes(e.specificationVersion)){let t=e;throw new zW({version:t.specificationVersion,provider:t.provider,modelId:t.modelId})}return TG(e)}function PG(){return MG(globalThis.AI_SDK_DEFAULT_PROVIDER??RU)}function FG(e){return e.map(e=>IG(e))}function IG(e){return e instanceof URL?new URL(e.href):Array.isArray(e)?e.map(e=>IG(e)):e instanceof Uint8Array?new Uint8Array(e):e instanceof ArrayBuffer?e.slice(0):e instanceof Date?new Date(e):typeof e==`object`&&e?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,IG(t)])):e}var LG=`7.0.66`,RG=async({url:e,maxBytes:t,abortSignal:n})=>{let r=e.toString();try{let e=await MR({url:r,headers:KR({},`ai-sdk/${LG}`,WR()),abortSignal:n});if(!e.ok)throw await rR(e),new lR({url:r,statusCode:e.status,statusText:e.statusText});return{data:await PR({response:e,url:r,maxBytes:t??NR}),mediaType:e.headers.get(`content-type`)??void 0}}catch(e){throw lR.isInstance(e)?e:new lR({url:r,cause:e})}},zG=(e=RG)=>t=>Promise.all(t.map(async t=>t.isUrlSupportedByModel?null:await e(t)));function BG(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;let n={...e};for(let r in t)if(r!==`__proto__`&&r!==`constructor`&&r!==`prototype`&&Object.prototype.hasOwnProperty.call(t,r)){let i=t[r];if(i===void 0)continue;let a=r in e?e[r]:void 0,o=typeof i==`object`&&!!i&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp),s=typeof a==`object`&&!!a&&!Array.isArray(a)&&!(a instanceof Date)&&!(a instanceof RegExp);n[r]=o&&s?BG(a,i):i}return n}function VG(e){try{let[t,n]=e.split(`,`);return{mediaType:t.split(`;`)[0].split(`:`)[1],base64Content:n}}catch{return{mediaType:void 0,base64Content:void 0}}}function HG(e){if(typeof e!=`object`||!e)return!1;let t=e.type;return t===`data`||t===`url`||t===`reference`||t===`text`}function UG(e){if(e.protocol===`data:`){let{mediaType:t,base64Content:n}=VG(e.toString());if(t==null||n==null)throw new YW({content:e,message:`Invalid data URL format in content ${e.toString()}`});return{data:{type:`data`,data:n},mediaType:t}}return{data:{type:`url`,url:e},mediaType:void 0}}function WG(e){return e instanceof Uint8Array?{data:{type:`data`,data:e},mediaType:void 0}:e instanceof ArrayBuffer||XR(e)?{data:{type:`data`,data:new Uint8Array(e)},mediaType:void 0}:{data:{type:`data`,data:e},mediaType:void 0}}function GG(e){if(HG(e))switch(e.type){case`data`:if(typeof e.data==`string`&&e.data.startsWith(`data:`))throw new YW({content:e.data,message:`Data URLs are not valid inline data. Pass them as { type: "url", url } instead.`});return WG(e.data);case`url`:return UG(e.url);case`reference`:return{data:{type:`reference`,reference:e.reference},mediaType:void 0};case`text`:return{data:{type:`text`,text:e.text},mediaType:void 0}}if(e instanceof URL)return UG(e);if(typeof e==`string`)try{return UG(new URL(e))}catch{return WG(e)}return QR(e)?{data:{type:`reference`,reference:e},mediaType:void 0}:WG(e)}async function KG({prompt:e,supportedUrls:t,download:n=zG(),provider:r}){let i=await YG(e.messages,n,t),a=new Map;for(let t of e.messages)if(t.role===`assistant`&&Array.isArray(t.content))for(let e of t.content)e.type===`tool-approval-request`&&`approvalId`in e&&`toolCallId`in e&&a.set(e.approvalId,e.toolCallId);let o=new Set;for(let t of e.messages)if(t.role===`tool`){for(let e of t.content)if(e.type===`tool-approval-response`){let t=a.get(e.approvalId);t&&o.add(t)}}let s=[...e.instructions==null?[]:typeof e.instructions==`string`?[{role:`system`,content:e.instructions}]:DL(e.instructions).map(e=>({role:`system`,content:e.content,providerOptions:e.providerOptions})),...e.messages.map(e=>qG({message:e,downloadedAssets:i,provider:r}))],c=[];for(let e of s){if(e.role!==`tool`){c.push(e);continue}let t=c.at(-1);if(t?.role===`tool`){let n=t.content.at(-1);n!=null&&t.providerOptions!=null&&(n.providerOptions=BG(t.providerOptions,n.providerOptions)),t.content.push(...e.content),t.providerOptions=e.providerOptions}else c.push(e)}let l=new Set;for(let e of c)switch(e.role){case`assistant`:for(let t of e.content)t.type===`tool-call`&&!t.providerExecuted&&l.add(t.toolCallId);break;case`tool`:for(let t of e.content)t.type===`tool-result`&&l.delete(t.toolCallId);break;case`user`:case`system`:for(let e of o)l.delete(e);if(l.size>0)throw new vW({toolCallIds:Array.from(l)})}for(let e of o)l.delete(e);if(l.size>0)throw new vW({toolCallIds:Array.from(l)});return c.filter(e=>e.role!==`tool`||e.content.length>0)}function qG({message:e,downloadedAssets:t,provider:n}){let r=[],i=e.role;switch(i){case`system`:return{role:`system`,content:e.content,providerOptions:e.providerOptions};case`user`:{if(typeof e.content==`string`)return{role:`user`,content:[{type:`text`,text:e.content}],providerOptions:e.providerOptions};let n={role:`user`,content:e.content.map(e=>(e.type===`image`&&r.push({type:`deprecated`,setting:`"image" content part`,message:`The "image" content part type is deprecated. Use a "file" part with mediaType: 'image' (or a more specific image/* subtype) instead.`}),JG(e))).map(e=>XG(e,t)).filter(e=>e.type!==`text`||e.text!==``),providerOptions:e.providerOptions};return r.length>0&&hG({warnings:r}),n}case`assistant`:{if(typeof e.content==`string`)return{role:`assistant`,content:[{type:`text`,text:e.content}],providerOptions:e.providerOptions};let i={role:`assistant`,content:e.content.filter(e=>e.type!==`text`||e.text!==``||e.providerOptions!=null).filter(e=>e.type!==`tool-approval-request`).map(e=>{let i=e.providerOptions;switch(e.type){case`custom`:return{type:`custom`,kind:e.kind,providerOptions:i};case`file`:{let{data:t,mediaType:n}=GG(e.data);return{type:`file`,data:t,filename:e.filename,mediaType:n??e.mediaType,providerOptions:i}}case`reasoning`:return{type:`reasoning`,text:e.text,providerOptions:i};case`reasoning-file`:{let{data:t,mediaType:n}=GG(e.data);if(t.type!==`data`&&t.type!==`url`)throw Error(`Unsupported reasoning-file data type: ${t.type}`);return{type:`reasoning-file`,data:t,mediaType:n??e.mediaType,providerOptions:i}}case`text`:return{type:`text`,text:e.text,providerOptions:i};case`tool-call`:return{type:`tool-call`,toolCallId:e.toolCallId,toolName:e.toolName,input:e.input,providerExecuted:e.providerExecuted,providerOptions:i};case`tool-result`:return{type:`tool-result`,toolCallId:e.toolCallId,toolName:e.toolName,output:ZG({output:e.output,provider:n,warnings:r,downloadedAssets:t}),providerOptions:i}}}),providerOptions:e.providerOptions};return r.length>0&&hG({warnings:r}),i}case`tool`:{let i={role:`tool`,content:e.content.filter(e=>e.type!==`tool-approval-response`||e.providerExecuted).map(e=>{switch(e.type){case`tool-result`:return{type:`tool-result`,toolCallId:e.toolCallId,toolName:e.toolName,output:ZG({output:e.output,provider:n,warnings:r,downloadedAssets:t}),providerOptions:e.providerOptions};case`tool-approval-response`:return{type:`tool-approval-response`,approvalId:e.approvalId,approved:e.approved,reason:e.reason}}}),providerOptions:e.providerOptions};return r.length>0&&hG({warnings:r}),i}default:throw new eG({role:i})}}function JG(e){return e.type===`image`?{type:`file`,data:e.image,mediaType:e.mediaType??`image`,providerOptions:e.providerOptions}:e}async function YG(e,t,n){let r=[];for(let t of e){if(t.role===`user`&&Array.isArray(t.content))for(let e of t.content){let t=JG(e);t.type===`file`&&r.push(t)}if(t.role===`tool`){for(let e of t.content)if(e.type===`tool-result`&&e.output.type===`content`)for(let t of e.output.value)t.type===`file`&&r.push(t)}if(t.role===`assistant`&&Array.isArray(t.content)){for(let e of t.content)if(e.type===`tool-result`&&e.output.type===`content`)for(let t of e.output.value)t.type===`file`&&r.push(t)}}let i=r.map(e=>{let t=e.mediaType,{data:n}=GG(e.data);return{mediaType:t,data:n}}).filter(e=>e.data.type===`url`).map(e=>({url:e.data.url,isUrlSupportedByModel:e.mediaType!=null&&ez({url:e.data.url.toString(),mediaType:e.mediaType,supportedUrls:n})})),a=await t(i);return Object.fromEntries(a.map((e,t)=>e==null?null:[i[t].url.toString(),{data:e.data,mediaType:e.mediaType}]).filter(e=>e!=null))}function XG(e,t){if(e.type===`text`)return{type:`text`,text:e.text,providerOptions:e.providerOptions};let{data:n,mediaType:r}=GG(e.data),i=r??e.mediaType,a=n;if(a.type===`url`){let e=t[a.url.toString()];e&&(a={type:`data`,data:e.data},e.mediaType!=null&&(i==null||!nR(i))&&(i=e.mediaType))}if(a.type===`data`&&(a.data instanceof Uint8Array||typeof a.data==`string`)){let e=tR({data:a.data,topLevelType:`image`});e!=null&&(i=e)}if(i==null)throw Error(`Media type is missing for file part`);return{type:`file`,mediaType:i,filename:e.filename,data:a,providerOptions:e.providerOptions}}function ZG({output:e,provider:t,warnings:n=[],downloadedAssets:r}){return e.type===`content`?{type:`content`,value:e.value.map(e=>{switch(e.type){case`file`:{let t=XG(e,r);if(t.type!==`file`)throw Error(`Expected tool result file content to convert to file.`);return t}case`file-data`:return n.push({type:`deprecated`,setting:`"tool-result" content of type "file-data"`,message:`The "file-data" type for tool result content is deprecated. Use the "file" type with mediaType and { type: 'data', data } instead.`}),{type:`file`,data:{type:`data`,data:e.data},filename:e.filename,mediaType:e.mediaType,providerOptions:e.providerOptions};case`file-url`:{let t=e.mediaType??eK(e.url),r=`The "file-url" type for tool result content is deprecated. Use the "file" type with mediaType and { type: 'url', url } instead.`;if(!e.mediaType){let n=t===`application/octet-stream`?`Unable to infer media type from URL. Defaulting to 'application/octet-stream'.`:`Inferred media type '${t}' from URL.`;r=`The "file-url" tool result content part with URL "${e.url}" is missing a "mediaType". ${n} ${r}`}return n.push({type:`deprecated`,setting:`"tool-result" content of type "file-url"`,message:r}),{type:`file`,data:{type:`url`,url:new URL(e.url)},mediaType:t,providerOptions:e.providerOptions}}case`file-id`:return n.push({type:`deprecated`,setting:`"tool-result" content of type "file-id"`,message:`The "file-id" type for tool result content is deprecated. Use the "file" type with mediaType and { type: 'reference', reference } instead.`}),{type:`file`,data:{type:`reference`,reference:QG({fileId:e.fileId,provider:t})},mediaType:`application`,providerOptions:e.providerOptions};case`file-reference`:return n.push({type:`deprecated`,setting:`"tool-result" content of type "file-reference"`,message:`The "file-reference" type for tool result content is deprecated. Use the "file" type with mediaType and { type: 'reference', reference } instead.`}),{type:`file`,data:{type:`reference`,reference:e.providerReference},mediaType:`application`,providerOptions:e.providerOptions};case`image-data`:return n.push({type:`deprecated`,setting:`"tool-result" content of type "image-data"`,message:`The "image-data" type for tool result content is deprecated. Use the "file" type with mediaType and { type: 'data', data } instead.`}),{type:`file`,data:{type:`data`,data:e.data},mediaType:e.mediaType,providerOptions:e.providerOptions};case`image-url`:return n.push({type:`deprecated`,setting:`"tool-result" content of type "image-url"`,message:`The "image-url" type for tool result content is deprecated. Use the "file" type with mediaType 'image' (or a specific image/* subtype) and { type: 'url', url } instead.`}),{type:`file`,data:{type:`url`,url:new URL(e.url)},mediaType:`image`,providerOptions:e.providerOptions};case`image-file-id`:return n.push({type:`deprecated`,setting:`"tool-result" content of type "image-file-id"`,message:`The "image-file-id" type for tool result content is deprecated. Use the "file" type with mediaType and { type: 'reference', reference } instead.`}),{type:`file`,data:{type:`reference`,reference:QG({fileId:e.fileId,provider:t})},mediaType:`image`,providerOptions:e.providerOptions};case`image-file-reference`:return n.push({type:`deprecated`,setting:`"tool-result" content of type "image-file-reference"`,message:`The "image-file-reference" type for tool result content is deprecated. Use the "file" type with mediaType and { type: 'reference', reference } instead.`}),{type:`file`,data:{type:`reference`,reference:e.providerReference},mediaType:`image`,providerOptions:e.providerOptions};default:return e}})}:e}function QG({fileId:e,provider:t}){if(typeof e==`object`)return e;if(t==null)throw Error(`Cannot convert string fileId to provider reference without a provider ID. Use a Record<string, string> fileId or switch to the file-reference type.`);return{[t]:e}}var $G={jpg:`image/jpeg`,jpeg:`image/jpeg`,png:`image/png`,gif:`image/gif`,webp:`image/webp`,svg:`image/svg+xml`,avif:`image/avif`,heic:`image/heic`,bmp:`image/bmp`,tiff:`image/tiff`,tif:`image/tiff`,pdf:`application/pdf`,mp4:`video/mp4`,webm:`video/webm`,mp3:`audio/mpeg`,wav:`audio/wav`,ogg:`audio/ogg`};function eK(e,t=`application/octet-stream`){try{let t=new URL(e).pathname.split(`.`).pop()?.toLowerCase();if(t&&Object.hasOwn($G,t))return $G[t]}catch{}return t}async function tK({toolCallId:e,input:t,output:n,tool:r,errorMode:i}){return i===`text`?{type:`error-text`,value:zI(n)}:i===`json`?{type:`error-json`,value:nK(n)}:r?.toModelOutput?await r.toModelOutput({toolCallId:e,input:t,output:n}):typeof n==`string`?{type:`text`,value:n}:{type:`json`,value:nK(n)}}function nK(e){return e===void 0?null:e}function rK({maxOutputTokens:e,temperature:t,topP:n,topK:r,presencePenalty:i,frequencyPenalty:a,seed:o,stopSequences:s,reasoning:c}){if(e!=null){if(!Number.isInteger(e))throw new qU({parameter:`maxOutputTokens`,value:e,message:`maxOutputTokens must be an integer`});if(e<1)throw new qU({parameter:`maxOutputTokens`,value:e,message:`maxOutputTokens must be >= 1`})}if(t!=null&&typeof t!=`number`)throw new qU({parameter:`temperature`,value:t,message:`temperature must be a number`});if(n!=null&&typeof n!=`number`)throw new qU({parameter:`topP`,value:n,message:`topP must be a number`});if(r!=null&&typeof r!=`number`)throw new qU({parameter:`topK`,value:r,message:`topK must be a number`});if(i!=null&&typeof i!=`number`)throw new qU({parameter:`presencePenalty`,value:i,message:`presencePenalty must be a number`});if(a!=null&&typeof a!=`number`)throw new qU({parameter:`frequencyPenalty`,value:a,message:`frequencyPenalty must be a number`});if(o!=null&&!Number.isInteger(o))throw new qU({parameter:`seed`,value:o,message:`seed must be an integer`});return{maxOutputTokens:e,temperature:t,topP:n,topK:r,presencePenalty:i,frequencyPenalty:a,stopSequences:s,seed:o,reasoning:c}}function iK({toolChoice:e}){return e==null?{type:`auto`}:typeof e==`string`?{type:e}:{type:`tool`,toolName:e.toolName}}function aK(e){return e!=null&&Object.keys(e).length>0}async function oK({tools:e,toolOrder:t,toolsContext:n={},experimental_sandbox:r}){if(!aK(e))return;let i=[];for(let[a,o]of sK({tools:e,toolOrder:t})){let e=o.type;switch(e){case void 0:case`dynamic`:case`function`:{let e=cK({tool:o,toolName:a,toolsContext:n,experimental_sandbox:r}),t=o.providerOptions,s=o.inputExamples,c=o.strict;i.push({type:`function`,name:a,inputSchema:await mB(o.inputSchema).jsonSchema,...e==null?{}:{description:e},...s==null?{}:{inputExamples:s},...t==null?{}:{providerOptions:t},...c==null?{}:{strict:c}});break}case`provider`:i.push({type:`provider`,name:a,id:o.id,args:o.args});break;default:throw Error(`Unsupported tool type: ${e}`)}}return i}function sK({tools:e,toolOrder:t}){if(t==null)return Object.entries(e);let n=Object.entries(e),r=n.filter(([e])=>t.includes(e)).sort(([e],[n])=>t.indexOf(e)-t.indexOf(n)),i=n.filter(([e])=>!t.includes(e)).sort(([e],[t])=>e<t?-1:+(e>t));return[...r,...i]}function cK({tool:e,toolName:t,toolsContext:n,experimental_sandbox:r}){return e.description===void 0?void 0:typeof e.description==`string`?e.description:e.description({context:n[t],experimental_sandbox:r})}function lK(e){if(e!=null)return typeof e==`number`?e:e.totalMs}function uK(e){if(e!=null&&typeof e!=`number`)return e.stepMs}function dK(e){if(e!=null&&typeof e!=`number`)return e.firstChunkMs}function fK(e){if(e!=null&&typeof e!=`number`)return e.chunkMs}function pK(e,t){if(e!=null&&typeof e!=`number`)return e.tools?.[`${t}Ms`]??e.toolMs}var W={array:BN,boolean:AN,custom:TP,discriminatedUnion:qN,enum:$N,instanceof:OP,lazy:CP,literal:tP,looseObject:UN,never:RN,null:MN,number:EN,object:HN,record:ZN,string:V,union:GN,unknown:IN},mK=W.lazy(()=>W.union([W.null(),W.string(),W.number(),W.boolean(),W.record(W.string(),mK.optional()),W.array(mK)])),hK=W.record(W.string(),W.record(W.string(),mK.optional())),gK=W.union([W.string(),W.instanceof(Uint8Array),W.instanceof(ArrayBuffer),W.custom(XR,{message:`Must be a Buffer`})]),_K=W.record(W.string(),W.string()),vK=W.object({type:W.literal(`text`),text:W.string(),providerOptions:hK.optional()}),yK=W.object({type:W.literal(`image`),image:W.union([gK,W.instanceof(URL),_K]),mediaType:W.string().optional(),providerOptions:hK.optional()}),bK=W.discriminatedUnion(`type`,[W.object({type:W.literal(`data`),data:gK}),W.object({type:W.literal(`url`),url:W.instanceof(URL)}),W.object({type:W.literal(`reference`),reference:_K}),W.object({type:W.literal(`text`),text:W.string()})]),xK=W.discriminatedUnion(`type`,[W.object({type:W.literal(`data`),data:gK}),W.object({type:W.literal(`url`),url:W.instanceof(URL)})]),SK=W.object({type:W.literal(`file`),data:W.union([bK,gK,W.instanceof(URL),_K]),filename:W.string().optional(),mediaType:W.string(),providerOptions:hK.optional()}),CK=W.object({type:W.literal(`reasoning`),text:W.string(),providerOptions:hK.optional()}),wK=W.object({type:W.literal(`custom`),kind:W.string().transform(e=>e),providerOptions:hK.optional()}),TK=W.object({type:W.literal(`reasoning-file`),data:W.union([xK,gK,W.instanceof(URL)]),mediaType:W.string(),providerOptions:hK.optional()}),EK=W.object({type:W.literal(`tool-call`),toolCallId:W.string(),toolName:W.string(),input:W.unknown(),providerOptions:hK.optional(),providerExecuted:W.boolean().optional()}),DK=W.discriminatedUnion(`type`,[W.object({type:W.literal(`text`),value:W.string(),providerOptions:hK.optional()}),W.object({type:W.literal(`json`),value:mK,providerOptions:hK.optional()}),W.object({type:W.literal(`execution-denied`),reason:W.string().optional(),providerOptions:hK.optional()}),W.object({type:W.literal(`error-text`),value:W.string(),providerOptions:hK.optional()}),W.object({type:W.literal(`error-json`),value:mK,providerOptions:hK.optional()}),W.object({type:W.literal(`content`),value:W.array(W.union([W.object({type:W.literal(`text`),text:W.string(),providerOptions:hK.optional()}),W.object({type:W.literal(`file`),data:bK,mediaType:W.string(),filename:W.string().optional(),providerOptions:hK.optional()}),W.object({type:W.literal(`file-data`),data:W.string(),mediaType:W.string(),filename:W.string().optional(),providerOptions:hK.optional()}),W.object({type:W.literal(`file-url`),url:W.string(),mediaType:W.string().optional(),providerOptions:hK.optional()}),W.object({type:W.literal(`file-id`),fileId:W.union([W.string(),W.record(W.string(),W.string())]),providerOptions:hK.optional()}),W.object({type:W.literal(`file-reference`),providerReference:W.record(W.string(),W.string()),providerOptions:hK.optional()}),W.object({type:W.literal(`image-data`),data:W.string(),mediaType:W.string(),providerOptions:hK.optional()}),W.object({type:W.literal(`image-url`),url:W.string(),providerOptions:hK.optional()}),W.object({type:W.literal(`image-file-id`),fileId:W.union([W.string(),W.record(W.string(),W.string())]),providerOptions:hK.optional()}),W.object({type:W.literal(`image-file-reference`),providerReference:W.record(W.string(),W.string()),providerOptions:hK.optional()}),W.object({type:W.literal(`custom`),providerOptions:hK.optional()})]))})]),OK=W.object({type:W.literal(`tool-result`),toolCallId:W.string(),toolName:W.string(),output:DK,providerOptions:hK.optional()}),kK=W.object({type:W.literal(`tool-approval-request`),approvalId:W.string(),toolCallId:W.string()}),AK=W.object({type:W.literal(`tool-approval-response`),approvalId:W.string(),approved:W.boolean(),reason:W.string().optional()}),jK=W.object({role:W.literal(`system`),content:W.string(),providerOptions:hK.optional()}),MK=W.object({role:W.literal(`user`),content:W.union([W.string(),W.array(W.union([vK,yK,SK]))]),providerOptions:hK.optional()}),NK=W.object({role:W.literal(`assistant`),content:W.union([W.string(),W.array(W.union([vK,wK,SK,CK,TK,EK,OK,kK]))]),providerOptions:hK.optional()}),PK=W.object({role:W.literal(`tool`),content:W.array(W.union([OK,AK])),providerOptions:hK.optional()}),FK=W.union([jK,MK,NK,PK]);async function IK({allowSystemInMessages:e=!1,system:t,instructions:n=t,prompt:r,messages:i}){if(r==null&&i==null)throw new ZI({prompt:r,message:`prompt or messages must be defined`});if(r!=null&&i!=null)throw new ZI({prompt:r,message:`prompt and messages cannot be defined at the same time`});if(typeof n!=`string`&&!DL(n).every(e=>e.role===`system`))throw new ZI({prompt:r,message:`instructions must be a string, SystemModelMessage, or array of SystemModelMessage`});if(r!=null&&typeof r==`string`)i=[{role:`user`,content:r}];else if(r!=null&&Array.isArray(r))i=r;else if(i==null)throw new ZI({prompt:r,message:`prompt or messages must be defined`});if(i.length===0)throw new ZI({prompt:r,message:`messages must not be empty`});if(!e&&i.some(e=>e.role===`system`))throw new ZI({prompt:r,message:`System messages are not allowed in the prompt or messages fields. Use the instructions option instead.`});let a=await SB({value:i,schema:W.array(FK)});if(!a.success)throw new ZI({prompt:r,message:`The messages do not match the ModelMessage[] schema.`,cause:a.error});return{messages:i,instructions:n}}function LK(e){if(!DV.isInstance(e))return e;let t=(process==null?void 0:`production`)===`production`,n=`https://ai-sdk.dev/unauthenticated-ai-gateway`;return t?new H({name:`GatewayError`,message:`Unauthenticated. Configure AI_GATEWAY_API_KEY or use a provider module. Learn more: ${n}`}):Object.assign(Error(`\x1B[1m\x1B[31mUnauthenticated request to AI Gateway.\x1B[0m
|
|
160
|
-
|
|
161
|
-
To authenticate, set the \x1B[33mAI_GATEWAY_API_KEY\x1B[0m environment variable with your API key.
|
|
162
|
-
|
|
163
|
-
Alternatively, you can use a provider module instead of the AI Gateway.
|
|
164
|
-
|
|
165
|
-
Learn more: \x1B[34m${n}\x1B[0m
|
|
166
|
-
|
|
167
|
-
`),{name:`GatewayAuthenticationError`})}function RK(e){return{inputTokens:e.inputTokens.total,inputTokenDetails:{noCacheTokens:e.inputTokens.noCache,cacheReadTokens:e.inputTokens.cacheRead,cacheWriteTokens:e.inputTokens.cacheWrite},outputTokens:e.outputTokens.total,outputTokenDetails:{textTokens:e.outputTokens.text,reasoningTokens:e.outputTokens.reasoning},totalTokens:VK(e.inputTokens.total,e.outputTokens.total),raw:e.raw}}function zK(){return{inputTokens:void 0,inputTokenDetails:{noCacheTokens:void 0,cacheReadTokens:void 0,cacheWriteTokens:void 0},outputTokens:void 0,outputTokenDetails:{textTokens:void 0,reasoningTokens:void 0},totalTokens:void 0,raw:void 0}}function BK(e,t){return{inputTokens:VK(e.inputTokens,t.inputTokens),inputTokenDetails:{noCacheTokens:VK(e.inputTokenDetails?.noCacheTokens,t.inputTokenDetails?.noCacheTokens),cacheReadTokens:VK(e.inputTokenDetails?.cacheReadTokens,t.inputTokenDetails?.cacheReadTokens),cacheWriteTokens:VK(e.inputTokenDetails?.cacheWriteTokens,t.inputTokenDetails?.cacheWriteTokens)},outputTokens:VK(e.outputTokens,t.outputTokens),outputTokenDetails:{textTokens:VK(e.outputTokenDetails?.textTokens,t.outputTokenDetails?.textTokens),reasoningTokens:VK(e.outputTokenDetails?.reasoningTokens,t.outputTokenDetails?.reasoningTokens)},totalTokens:VK(e.totalTokens,t.totalTokens)}}function VK(e,t){return e==null&&t==null?void 0:(e??0)+(t??0)}function HK(e,t){return e!=null&&Object.hasOwn(e,t)?e[t]:void 0}function UK(...e){let t=IR(...e).map(e=>e instanceof AbortSignal?e:AbortSignal.timeout(e));return t.length===0?void 0:t.length===1?t[0]:AbortSignal.any(t)}function WK(){return(globalThis==null?void 0:globalThis.performance)?.now()??Date.now()}async function GK(e){await Promise.all(DL(e.callbacks).map(async t=>{try{await t?.(e.event)}catch{}}))}function KK({error:e,exponentialBackoffDelay:t}){let n=MI.isInstance(e)?e.responseHeaders:MI.isInstance(e.cause)?e.cause.responseHeaders:void 0;if(!n)return t;let r,i=n[`retry-after-ms`];if(i){let e=parseFloat(i);Number.isNaN(e)||(r=e)}let a=n[`retry-after`];if(a&&r===void 0){let e=parseFloat(a);r=Number.isNaN(e)?Date.parse(a)-Date.now():e*1e3}return r!=null&&!Number.isNaN(r)&&0<=r&&(r<6e4||r<t)?r:t}var qK=({maxRetries:e=2,initialDelayInMs:t=2e3,backoffFactor:n=2,abortSignal:r}={})=>MB({maxRetries:e,initialDelayInMs:t,backoffFactor:n,abortSignal:r,shouldRetry:e=>e instanceof Error&&(MI.isInstance(e)&&e.isRetryable===!0||xV.isInstance(e)&&e.isRetryable===!0),getDelayInMs:({error:e,exponentialBackoffDelay:t})=>KK({error:e,exponentialBackoffDelay:t}),createRetryError:({message:e,reason:t,errors:n})=>new uG({message:e,reason:t,errors:n})});function JK({maxRetries:e,abortSignal:t}){if(e!=null){if(!Number.isInteger(e))throw new qU({parameter:`maxRetries`,value:e,message:`maxRetries must be an integer`});if(e<0)throw new qU({parameter:`maxRetries`,value:e,message:`maxRetries must be >= 0`})}let n=e??2;return{maxRetries:n,retry:qK({maxRetries:n,abortSignal:t})}}function YK({abortController:e,label:t,timeoutMs:n}){if(e!=null&&n!=null)return setTimeout(()=>e.abort(new DOMException(`${t} timeout of ${n}ms exceeded`,`TimeoutError`)),n)}function XK({tokens:e,durationMs:t}){let n=1e3*(e??0)/(t??0);return Number.isFinite(n)?n:0}function ZK({messages:e}){let t=e.at(-1);if(t?.role!=`tool`)return{approvedToolApprovals:[],deniedToolApprovals:[]};let n=Object.create(null);for(let t of e)if(t.role===`assistant`&&typeof t.content!=`string`){let e=t.content;for(let t of e)t.type===`tool-call`&&(n[t.toolCallId]=t)}let r=Object.create(null);for(let t of e)if(t.role===`assistant`&&typeof t.content!=`string`){let e=t.content;for(let t of e)t.type===`tool-approval-request`&&(r[t.approvalId]=t)}let i=Object.create(null);for(let e of t.content)e.type===`tool-result`&&(i[e.toolCallId]=e);let a=[],o=[],s=t.content.filter(e=>e.type===`tool-approval-response`);for(let e of s){let t=r[e.approvalId];if(t==null)throw new QU({approvalId:e.approvalId});let s=i[t.toolCallId];if(s!=null&&(e.approved||s.output.type!==`execution-denied`))continue;let c=n[t.toolCallId];if(c==null)throw new pW({toolCallId:t.toolCallId,approvalId:t.approvalId});let l={approvalRequest:t,approvalResponse:e,toolCall:c,...s==null?{}:{existingToolResult:s}};e.approved?a.push(l):o.push(l)}return{approvedToolApprovals:a,deniedToolApprovals:o}}async function QK({toolName:e,context:t,contextSchema:n}){return n==null?t:await xB({value:t,schema:n,context:{field:`tool context`,entityName:e}})}async function $K({toolCall:e,tools:t,toolsContext:n,callId:r,messages:i,abortSignal:a,timeout:o,experimental_sandbox:s,onPreliminaryToolResult:c,onToolExecutionStart:l,onToolExecutionEnd:u,executeToolInTelemetryContext:d=async({execute:e})=>await e(),runInTracingChannelSpan:f=async({execute:e})=>await e()}){let{toolName:p,toolCallId:m,input:h}=e,g=HK(t,p);if(!rV(g))return;let _=await QK({toolName:p,context:HK(n,p),contextSchema:g.contextSchema}),v={toolCall:e,messages:i,toolContext:_},y={callId:r,...v};return await f({type:`executeTool`,event:y,execute:async()=>{let t;await GK({event:y,callbacks:l});let n=UK(a,pK(o,p)),f=0;try{await d({callId:r,toolCallId:m,...v,execute:async()=>{let r=WK();try{let r=aV({tool:g,input:h,options:{toolCallId:m,messages:i,abortSignal:n,context:_,experimental_sandbox:s}});for await(let n of r)n.type===`preliminary`?c?.({...e,type:`tool-result`,output:n.output,preliminary:!0}):t=n.output}finally{f=WK()-r}}})}catch(t){let n={type:`tool-error`,toolCallId:m,toolName:p,input:h,error:t,dynamic:g.type===`dynamic`,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata},...e.toolMetadata==null?{}:{toolMetadata:e.toolMetadata}};return await GK({event:{...y,toolOutput:n,toolExecutionMs:f},callbacks:u}),{output:n,toolExecutionMs:f}}let b={type:`tool-result`,toolCallId:m,toolName:p,input:h,output:t,dynamic:g.type===`dynamic`,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata},...e.toolMetadata==null?{}:{toolMetadata:e.toolMetadata}};return await GK({event:{...y,toolOutput:b,toolExecutionMs:f},callbacks:u}),{output:b,toolExecutionMs:f}}})}function eq({tools:e,activeTools:t}){return e==null||t==null?e:Object.fromEntries(Object.entries(e).filter(([e])=>t.includes(e)))}var tq=class{constructor({data:e,mediaType:t}){let n=e instanceof Uint8Array;this.base64Data=n?void 0:e,this.uint8ArrayData=n?e:void 0,this.mediaType=t}get base64(){return this.base64Data??=VL(this.uint8ArrayData),this.base64Data}get uint8Array(){return this.uint8ArrayData??=BL(this.base64Data),this.uint8ArrayData}},nq=class extends tq{constructor(e){super(e),this.type=`file`}};HU({},{array:()=>sq,choice:()=>cq,json:()=>lq,object:()=>oq,text:()=>aq});function rq(e){let t=[`ROOT`],n=-1,r=null,i=0;function a(e){return e>=`0`&&e<=`9`||e>=`A`&&e<=`F`||e>=`a`&&e<=`f`}function o(e,i,a){switch(e){case`"`:n=i,t.pop(),t.push(a),t.push(`INSIDE_STRING`);break;case`f`:case`t`:case`n`:n=i,r=i,t.pop(),t.push(a),t.push(`INSIDE_LITERAL`);break;case`-`:t.pop(),t.push(a),t.push(`INSIDE_NUMBER`);break;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=i,t.pop(),t.push(a),t.push(`INSIDE_NUMBER`);break;case`{`:n=i,t.pop(),t.push(a),t.push(`INSIDE_OBJECT_START`);break;case`[`:n=i,t.pop(),t.push(a),t.push(`INSIDE_ARRAY_START`)}}function s(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_COMMA`);break;case`}`:n=r,t.pop()}}function c(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`);break;case`]`:n=r,t.pop()}}for(let l=0;l<e.length;l++){let u=e[l];switch(t[t.length-1]){case`ROOT`:o(u,l,`FINISH`);break;case`INSIDE_OBJECT_START`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`);break;case`}`:n=l,t.pop()}break;case`INSIDE_OBJECT_AFTER_COMMA`:u===`"`&&(t.pop(),t.push(`INSIDE_OBJECT_KEY`));break;case`INSIDE_OBJECT_KEY`:u===`"`&&(t.pop(),t.push(`INSIDE_OBJECT_AFTER_KEY`));break;case`INSIDE_OBJECT_AFTER_KEY`:u===`:`&&(t.pop(),t.push(`INSIDE_OBJECT_BEFORE_VALUE`));break;case`INSIDE_OBJECT_BEFORE_VALUE`:o(u,l,`INSIDE_OBJECT_AFTER_VALUE`);break;case`INSIDE_OBJECT_AFTER_VALUE`:s(u,l);break;case`INSIDE_STRING`:switch(u){case`"`:t.pop(),n=l;break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`);break;default:n=l}break;case`INSIDE_ARRAY_START`:switch(u){case`]`:n=l,t.pop();break;default:n=l,o(u,l,`INSIDE_ARRAY_AFTER_VALUE`)}break;case`INSIDE_ARRAY_AFTER_VALUE`:switch(u){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`);break;case`]`:n=l,t.pop();break;default:n=l}break;case`INSIDE_ARRAY_AFTER_COMMA`:o(u,l,`INSIDE_ARRAY_AFTER_VALUE`);break;case`INSIDE_STRING_ESCAPE`:t.pop(),u===`u`?(i=0,t.push(`INSIDE_STRING_UNICODE_ESCAPE`)):n=l;break;case`INSIDE_STRING_UNICODE_ESCAPE`:a(u)&&(i++,i===4&&(t.pop(),n=l));break;case`INSIDE_NUMBER`:switch(u){case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=l;break;case`e`:case`E`:case`-`:case`.`:break;case`,`:t.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&c(u,l),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&s(u,l);break;case`}`:t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&s(u,l);break;case`]`:t.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&c(u,l);break;default:t.pop()}break;case`INSIDE_LITERAL`:{let i=e.substring(r,l+1);!`false`.startsWith(i)&&!`true`.startsWith(i)&&!`null`.startsWith(i)?(t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`?s(u,l):t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&c(u,l)):n=l;break}}}let l=e.slice(0,n+1);for(let n=t.length-1;n>=0;n--)switch(t[n]){case`INSIDE_STRING`:l+=`"`;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`:l+=`}`;break;case`INSIDE_ARRAY_START`:case`INSIDE_ARRAY_AFTER_COMMA`:case`INSIDE_ARRAY_AFTER_VALUE`:l+=`]`;break;case`INSIDE_LITERAL`:{let t=e.substring(r,e.length);`true`.startsWith(t)?l+=`true`.slice(t.length):`false`.startsWith(t)?l+=`false`.slice(t.length):`null`.startsWith(t)&&(l+=`null`.slice(t.length))}}return l}async function iq(e){if(e===void 0)return{value:void 0,state:`undefined-input`};let t=await wB({text:e});return t.success?{value:t.value,state:`successful-parse`}:(t=await wB({text:rq(e)}),t.success?{value:t.value,state:`repaired-parse`}:{value:void 0,state:`failed-parse`})}var aq=()=>({name:`text`,responseFormat:Promise.resolve({type:`text`}),async parseCompleteOutput({text:e}){return e},async parsePartialOutput({text:e}){return{partial:e}},createElementStreamTransform(){}}),oq=({schema:e,name:t,description:n})=>{let r=mB(e);return{name:`object`,responseFormat:jB(r.jsonSchema).then(e=>({type:`json`,schema:e,...t!=null&&{name:t},...n!=null&&{description:n}})),async parseCompleteOutput({text:e},t){let n=await wB({text:e});if(!n.success)throw new CW({message:`No object generated: could not parse the response.`,cause:n.error,text:e,response:t.response,usage:t.usage,finishReason:t.finishReason});let i=await SB({value:n.value,schema:r});if(!i.success)throw new CW({message:`No object generated: response did not match schema.`,cause:i.error,text:e,response:t.response,usage:t.usage,finishReason:t.finishReason});return i.value},async parsePartialOutput({text:e}){let t=await iq(e);switch(t.state){case`failed-parse`:case`undefined-input`:return;case`repaired-parse`:case`successful-parse`:return{partial:t.value}}},createElementStreamTransform(){}}},sq=({element:e,name:t,description:n})=>{let r=mB(e);return{name:`array`,responseFormat:jB(r.jsonSchema).then(e=>{let{$schema:r,definitions:i,$defs:a,...o}=e;return{type:`json`,schema:{$schema:`http://json-schema.org/draft-07/schema#`,...i!=null&&{definitions:i},...a!=null&&{$defs:a},type:`object`,properties:{elements:{type:`array`,items:o}},required:[`elements`],additionalProperties:!1},...t!=null&&{name:t},...n!=null&&{description:n}}}),async parseCompleteOutput({text:e},t){let n=await wB({text:e});if(!n.success)throw new CW({message:`No object generated: could not parse the response.`,cause:n.error,text:e,response:t.response,usage:t.usage,finishReason:t.finishReason});let i=n.value;if(typeof i!=`object`||!i||!(`elements`in i)||!Array.isArray(i.elements))throw new CW({message:`No object generated: response did not match schema.`,cause:new lL({value:i,cause:`response must be an object with an elements array`}),text:e,response:t.response,usage:t.usage,finishReason:t.finishReason});let a=[];for(let n of i.elements){let i=await SB({value:n,schema:r});if(!i.success)throw new CW({message:`No object generated: response did not match schema.`,cause:i.error,text:e,response:t.response,usage:t.usage,finishReason:t.finishReason});a.push(i.value)}return a},async parsePartialOutput({text:e}){let t=await iq(e);switch(t.state){case`failed-parse`:case`undefined-input`:return;case`repaired-parse`:case`successful-parse`:{let e=t.value;if(typeof e!=`object`||!e||!(`elements`in e)||!Array.isArray(e.elements))return;let n=t.state===`repaired-parse`&&e.elements.length>0?e.elements.slice(0,-1):e.elements,i=[];for(let e of n){let t=await SB({value:e,schema:r});t.success&&i.push(t.value)}return{partial:i}}}},createElementStreamTransform(){let e=0;return new TransformStream({transform({partialOutput:t},n){if(t!=null)for(;e<t.length;e++)n.enqueue(t[e])}})}}},cq=({options:e,name:t,description:n})=>({name:`choice`,responseFormat:Promise.resolve({type:`json`,schema:{$schema:`http://json-schema.org/draft-07/schema#`,type:`object`,properties:{result:{type:`string`,enum:e}},required:[`result`],additionalProperties:!1},...t!=null&&{name:t},...n!=null&&{description:n}}),async parseCompleteOutput({text:t},n){let r=await wB({text:t});if(!r.success)throw new CW({message:`No object generated: could not parse the response.`,cause:r.error,text:t,response:n.response,usage:n.usage,finishReason:n.finishReason});let i=r.value;if(typeof i!=`object`||!i||!(`result`in i)||typeof i.result!=`string`||!e.includes(i.result))throw new CW({message:`No object generated: response did not match schema.`,cause:new lL({value:i,cause:`response must be an object that contains a choice value.`}),text:t,response:n.response,usage:n.usage,finishReason:n.finishReason});return i.result},async parsePartialOutput({text:t}){let n=await iq(t);switch(n.state){case`failed-parse`:case`undefined-input`:return;case`repaired-parse`:case`successful-parse`:{let t=n.value;if(typeof t!=`object`||!t||!(`result`in t)||typeof t.result!=`string`)return;let r=e.filter(e=>e.startsWith(t.result));return n.state===`successful-parse`?r.includes(t.result)?{partial:t.result}:void 0:r.length===1?{partial:r[0]}:void 0}}},createElementStreamTransform(){}}),lq=({name:e,description:t}={})=>({name:`json`,responseFormat:Promise.resolve({type:`json`,...e!=null&&{name:e},...t!=null&&{description:t}}),async parseCompleteOutput({text:e},t){let n=await wB({text:e});if(!n.success)throw new CW({message:`No object generated: could not parse the response.`,cause:n.error,text:e,response:t.response,usage:t.usage,finishReason:t.finishReason});return n.value},async parsePartialOutput({text:e}){let t=await iq(e);switch(t.state){case`failed-parse`:case`undefined-input`:return;case`repaired-parse`:case`successful-parse`:return t.value===void 0?void 0:{partial:t.value}}},createElementStreamTransform(){}});async function uq({toolCall:e,tools:t,repairToolCall:n,refineToolInput:r,messages:i,instructions:a}){try{if(t==null){if(e.providerExecuted&&e.dynamic)return await dq({toolCall:await fq(e),refineToolInput:r});throw new NW({toolName:e.toolName})}try{return await dq({toolCall:await pq({toolCall:e,tools:t}),refineToolInput:r})}catch(o){if(n==null||!(NW.isInstance(o)||cW.isInstance(o)))throw o;let s=null;try{s=await n({toolCall:e,tools:t,inputSchema:async({toolName:e})=>{let n=HK(t,e)?.inputSchema;return await mB(n).jsonSchema},instructions:a,system:a,messages:i,error:o})}catch(e){throw new RW({cause:e,originalError:o})}if(s==null)throw o;return await dq({toolCall:await pq({toolCall:s,tools:t}),refineToolInput:r})}}catch(n){let r=await wB({text:e.input}),i=r.success?r.value:e.input,a=HK(t,e.toolName);return{type:`tool-call`,toolCallId:e.toolCallId,toolName:e.toolName,input:i,dynamic:!0,invalid:!0,error:n,title:a?.title,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,...a?.metadata==null?{}:{toolMetadata:a.metadata}}}}async function dq({toolCall:e,refineToolInput:t}){let n=HK(t,e.toolName);return n==null?e:{...e,input:await n(e.input)}}async function fq(e){let t=e.input.trim()===``?{success:!0,value:{}}:await wB({text:e.input});if(t.success===!1)throw new cW({toolName:e.toolName,toolInput:e.input,cause:t.error});return{type:`tool-call`,toolCallId:e.toolCallId,toolName:e.toolName,input:t.value,providerExecuted:!0,dynamic:!0,providerMetadata:e.providerMetadata}}async function pq({toolCall:e,tools:t}){let n=e.toolName,r=HK(t,n);if(r==null){if(e.providerExecuted&&e.dynamic)return await fq(e);throw new NW({toolName:e.toolName,availableTools:Object.keys(t)})}let i=mB(r.inputSchema),a=e.input.trim()===``?await SB({value:{},schema:i}):await wB({text:e.input,schema:i});if(a.success===!1)throw new cW({toolName:n,toolInput:e.input,cause:a.error});return r.type===`dynamic`?{type:`tool-call`,toolCallId:e.toolCallId,toolName:e.toolName,input:a.value,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,...r.metadata==null?{}:{toolMetadata:r.metadata},dynamic:!0,title:r.title}:{type:`tool-call`,toolCallId:e.toolCallId,toolName:n,input:a.value,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,...r.metadata==null?{}:{toolMetadata:r.metadata},title:r.title}}function mq({callSettings:e,stepSettings:t}){return rK({maxOutputTokens:t?.maxOutputTokens??e.maxOutputTokens,temperature:t?.temperature??e.temperature,topP:t?.topP??e.topP,topK:t?.topK??e.topK,presencePenalty:t?.presencePenalty??e.presencePenalty,frequencyPenalty:t?.frequencyPenalty??e.frequencyPenalty,stopSequences:t?.stopSequences??e.stopSequences,seed:t?.seed??e.seed,reasoning:t?.reasoning??e.reasoning})}function hq(e){return typeof e==`object`&&e&&`type`in e?e.type===`data`?e.data:e.url:e}function gq(e){return e.map(e=>e.type===`reasoning`?{type:`reasoning`,text:e.text,...e.providerMetadata==null?{}:{providerOptions:e.providerMetadata}}:{type:`reasoning-file`,data:e.file.base64,mediaType:e.file.mediaType,...e.providerMetadata==null?{}:{providerOptions:e.providerMetadata}})}function _q(e){return e.map(e=>{if(e.type===`reasoning`)return{type:`reasoning`,text:e.text,...e.providerOptions==null?{}:{providerMetadata:e.providerOptions}};let t=hq(e.data);return{type:`reasoning-file`,file:new tq({data:t instanceof ArrayBuffer?new Uint8Array(t):t instanceof URL?t.toString():t,mediaType:e.mediaType}),...e.providerOptions==null?{}:{providerMetadata:e.providerOptions}}})}async function vq({tools:e,toolCall:t,toolApproval:n,messages:r,toolsContext:i,runtimeContext:a}){if(n!=null&&typeof n==`function`)return yq(await n({toolCall:t,tools:e,toolsContext:i,messages:r,runtimeContext:a}));let o=t.toolName,s=HK(e,o),c=t.input,l=HK(n,o);return l==null?s?.needsApproval==null?{type:`not-applicable`}:(typeof s.needsApproval==`function`?await s.needsApproval(c,{toolCallId:t.toolCallId,messages:r,context:await QK({toolName:o,context:HK(i,o),contextSchema:s?.contextSchema})}):s.needsApproval)?{type:`user-approval`}:{type:`not-applicable`}:yq(typeof l==`function`?await l(c,{toolCallId:t.toolCallId,messages:r,toolContext:await QK({toolName:o,context:HK(i,o),contextSchema:s?.contextSchema}),runtimeContext:a}):l)}function yq(e){return e===void 0?{type:`not-applicable`}:typeof e==`string`?{type:e}:e}function bq(...e){return async t=>{await Promise.allSettled(e.map(async e=>{await e?.(t)}))}}var xq=`ai:telemetry`;function Sq(){return typeof process<`u`&&process.release?.name===`node`}var Cq;async function wq(){if(Sq())return Cq??=Promise.resolve(Tq(`node:diagnostics_channel`)),Cq}function Tq(e){let t=globalThis.process;try{return(t?.getBuiltinModule)?.call(t,e)}catch{return}}async function Eq(e,t){let n=await wq(),r=(n?.tracingChannel)?.call(n,xq);if(r==null||r.hasSubscribers===!1)return await t();let i,a,o,s=!1,c=!1,l=()=>{try{i=Promise.resolve(t())}catch(e){i=Promise.reject(e)}return i=i.then(e=>(a=e,s=!0,e),e=>{throw o=e,c=!0,e}),i};try{return await r.tracePromise(l,e)}catch{if(c)throw o;return s?a:i==null?await t():await i}}function Dq({message:e,completion:t}){if(!Sq())return;let n=Tq(`node:diagnostics_channel`),r=Tq(`node:async_hooks`),i=(n?.tracingChannel)?.call(n,xq);if(i==null||i.hasSubscribers===!1||r==null){Promise.resolve(t).catch(()=>{});return}let a=e,o,s=!1,c=e=>{try{e()}catch{}},l=({result:e,error:t})=>{s||(s=!0,t!==void 0&&(a.error=t,c(()=>i.error.publish(a))),e!==void 0&&(a.result=e),c(()=>i.asyncEnd.publish(a)))};return c(()=>{i.start.runStores(a,()=>{o=new r.AsyncResource(`ai.telemetry`)})}),c(()=>i.end.publish(a)),Promise.resolve(t).then(e=>l({result:e}),e=>l({error:e})),{run:e=>o==null?e():o.runInAsyncScope(e)}}function Oq(){return globalThis.AI_SDK_TELEMETRY_INTEGRATIONS??[]}function kq(e,t){return Object.assign(Object.create(Object.getPrototypeOf(e)),e,t)}function Aq({telemetry:e}){if(e?.isEnabled===!1)return{};let t=e?.integrations,n=t==null?Oq():DL(t),r={recordInputs:e?.recordInputs,recordOutputs:e?.recordOutputs,functionId:e?.functionId},i=e=>{let t=bq(...n.map(t=>t[e]?.bind(t)).filter(Boolean).map(e=>t=>e(kq(t,r))));return async e=>{await t(e)}},a=n.map(e=>e.executeLanguageModelCall?.bind(e)).filter(Boolean),o=n.map(e=>e.executeTool?.bind(e)).filter(Boolean);return{runInTracingChannelSpan:async({type:e,event:t,execute:n})=>await Eq({type:e,event:kq(t,r)},n),startTracingChannelContext:({type:e,event:t,completion:n})=>Dq({message:{type:e,event:kq(t,r)},completion:n}),onStart:i(`onStart`),onStepStart:i(`onStepStart`),onLanguageModelCallStart:i(`onLanguageModelCallStart`),onLanguageModelCallEnd:i(`onLanguageModelCallEnd`),onToolExecutionStart:i(`onToolExecutionStart`),onToolExecutionEnd:i(`onToolExecutionEnd`),onStepEnd:bq(i(`onStepEnd`),i(`onStepFinish`)),onObjectStepStart:i(`onObjectStepStart`),onObjectStepEnd:i(`onObjectStepEnd`),onEmbedStart:i(`onEmbedStart`),onEmbedEnd:i(`onEmbedEnd`),onRerankStart:i(`onRerankStart`),onRerankEnd:i(`onRerankEnd`),onEnd:i(`onEnd`),onAbort:i(`onAbort`),onError:i(`onError`),executeLanguageModelCall:async({execute:e,...t})=>{let n=kq(t,r),i=e;for(let e of a){let t=i;i=()=>e({...n,execute:t})}return await Eq({type:`languageModelCall`,event:n},i)},executeTool:async({execute:e,...t})=>{let n=kq(t,r),i=e;for(let e of o){let t=i;i=()=>e({...n,execute:t})}return await i()}}}function jq(e){let t=e.map(e=>`text`in e?e.text:``).join(``);return t.length>0?t:void 0}var Mq=class{constructor({callId:e,stepNumber:t,provider:n,modelId:r,runtimeContext:i,toolsContext:a,content:o,finishReason:s,rawFinishReason:c,usage:l,performance:u,warnings:d,request:f,response:p,providerMetadata:m}){this.callId=e,this.stepNumber=t,this.model={provider:n,modelId:r},this.runtimeContext=i,this.toolsContext=a,this.content=o,this.finishReason=s,this.rawFinishReason=c,this.usage=l,this.performance=u,this.warnings=d,this.request=f,this.response=p,this.providerMetadata=m}get text(){return this.content.filter(e=>e.type===`text`).map(e=>e.text).join(``)}get reasoning(){return gq(this.content.filter(e=>e.type===`reasoning`||e.type===`reasoning-file`))}get reasoningText(){return jq(this.reasoning)}get files(){return this.content.filter(e=>e.type===`file`).map(e=>e.file)}get sources(){return this.content.filter(e=>e.type===`source`)}get toolCalls(){return this.content.filter(e=>e.type===`tool-call`)}get staticToolCalls(){return this.toolCalls.filter(e=>e.dynamic!==!0)}get dynamicToolCalls(){return this.toolCalls.filter(e=>e.dynamic===!0)}get toolResults(){return this.content.filter(e=>e.type===`tool-result`)}get staticToolResults(){return this.toolResults.filter(e=>e.dynamic!==!0)}get dynamicToolResults(){return this.toolResults.filter(e=>e.dynamic===!0)}};function Nq({context:e,includeContext:t}){return e==null?{}:Object.fromEntries(Object.entries(e).filter(([e])=>t?.[e]===!0))}function Pq({step:e,includeRuntimeContext:t,includeToolsContext:n}){return new Mq({callId:e.callId,stepNumber:e.stepNumber,provider:e.model.provider,modelId:e.model.modelId,runtimeContext:Nq({context:e.runtimeContext,includeContext:t}),toolsContext:Fq({toolsContext:e.toolsContext,includeToolsContext:n}),content:e.content,finishReason:e.finishReason,rawFinishReason:e.rawFinishReason,usage:e.usage,performance:e.performance,warnings:e.warnings,request:e.request,response:e.response,providerMetadata:e.providerMetadata})}function Fq({toolsContext:e,includeToolsContext:t}){return t==null?{}:Object.fromEntries(Object.entries(e).map(([e,n])=>[e,Iq({toolName:e,toolContext:n,includeToolsContext:t})]))}function Iq({toolName:e,toolContext:t,includeToolsContext:n}){return Nq({context:t,includeContext:n?.[e]})}function Lq({telemetry:e,includeRuntimeContext:t,includeToolsContext:n}){let r=Aq({telemetry:e});return{...r,onStart:e=>r.onStart?.call(r,{...e,runtimeContext:Nq({context:e.runtimeContext,includeContext:t}),toolsContext:Fq({toolsContext:e.toolsContext,includeToolsContext:n})}),onStepStart:e=>r.onStepStart?.call(r,{...e,runtimeContext:Nq({context:e.runtimeContext,includeContext:t}),steps:e.steps.map(e=>Pq({step:e,includeRuntimeContext:t,includeToolsContext:n})),toolsContext:Fq({toolsContext:e.toolsContext,includeToolsContext:n})}),onStepEnd:e=>r.onStepEnd?.call(r,Pq({step:e,includeRuntimeContext:t,includeToolsContext:n})),onStepFinish:e=>r.onStepEnd?.call(r,Pq({step:e,includeRuntimeContext:t,includeToolsContext:n})),onEnd:e=>r.onEnd?.call(r,(r=>({...e,runtimeContext:Nq({context:e.runtimeContext,includeContext:t}),steps:r,finalStep:r.at(-1),toolsContext:Fq({toolsContext:e.toolsContext,includeToolsContext:n})}))(e.steps.map(e=>Pq({step:e,includeRuntimeContext:t,includeToolsContext:n})))),onAbort:e=>r.onAbort?.call(r,{...e,steps:e.steps.map(e=>Pq({step:e,includeRuntimeContext:t,includeToolsContext:n}))}),onToolExecutionStart:e=>r.onToolExecutionStart?.call(r,{...e,toolContext:Iq({toolName:e.toolCall.toolName,toolContext:e.toolContext,includeToolsContext:n})}),onToolExecutionEnd:e=>r.onToolExecutionEnd?.call(r,{...e,toolContext:Iq({toolName:e.toolCall.toolName,toolContext:e.toolContext,includeToolsContext:n})})}}function Rq(e){return({steps:t})=>t.length===e}async function zq({stopConditions:e,steps:t}){return(await Promise.all(e.map(e=>e({steps:t})))).some(e=>e)}function Bq(e,t){return e==null&&t==null?void 0:(e??0)+(t??0)}async function Vq({content:e,tools:t}){let n=[],r=new Map,i=[];for(let n of e)if(n.type!==`source`&&!((n.type===`tool-result`||n.type===`tool-error`)&&!n.providerExecuted)&&(n.type!==`text`||n.text.length!==0))switch(n.type){case`text`:i.push({type:`text`,text:n.text,providerOptions:n.providerMetadata});break;case`custom`:i.push({type:`custom`,kind:n.kind,providerOptions:n.providerMetadata});break;case`reasoning`:i.push({type:`reasoning`,text:n.text,providerOptions:n.providerMetadata});break;case`file`:i.push({type:`file`,data:n.file.base64,mediaType:n.file.mediaType,providerOptions:n.providerMetadata});break;case`reasoning-file`:i.push({type:`reasoning-file`,data:n.file.base64,mediaType:n.file.mediaType,providerOptions:n.providerMetadata});break;case`tool-call`:r.has(n.toolCallId)||r.set(n.toolCallId,r.size),i.push({type:`tool-call`,toolCallId:n.toolCallId,toolName:n.toolName,input:n.invalid&&typeof n.input!=`object`?{}:n.input,providerExecuted:n.providerExecuted,providerOptions:n.providerMetadata});break;case`tool-result`:{let e=await tK({toolCallId:n.toolCallId,input:n.input,tool:HK(t,n.toolName),output:n.output,errorMode:`none`});i.push({type:`tool-result`,toolCallId:n.toolCallId,toolName:n.toolName,output:e,providerOptions:n.providerMetadata});break}case`tool-error`:{let e=await tK({toolCallId:n.toolCallId,input:n.input,tool:HK(t,n.toolName),output:n.error,errorMode:`json`});i.push({type:`tool-result`,toolCallId:n.toolCallId,toolName:n.toolName,output:e,providerOptions:n.providerMetadata});break}case`tool-approval-request`:i.push({type:`tool-approval-request`,approvalId:n.approvalId,toolCallId:n.toolCall.toolCallId,isAutomatic:n.isAutomatic,...n.signature==null?{}:{signature:n.signature}})}i.length>0&&n.push({role:`assistant`,content:i});let a=[];for(let n of e){if(n.type!==`tool-approval-response`&&n.type!==`tool-result`&&n.type!==`tool-error`)continue;if(n.type===`tool-approval-response`){a.push({type:`tool-approval-response`,approvalId:n.approvalId,approved:n.approved,reason:n.reason,providerExecuted:n.providerExecuted}),n.approved===!1&&a.push({type:`tool-result`,toolCallId:n.toolCall.toolCallId,toolName:n.toolCall.toolName,output:{type:`execution-denied`,reason:n.reason}});continue}if(n.providerExecuted)continue;let e=await tK({toolCallId:n.toolCallId,input:n.input,tool:HK(t,n.toolName),output:n.type===`tool-result`?n.output:n.error,errorMode:n.type===`tool-error`?`text`:`none`});a.push({type:`tool-result`,toolCallId:n.toolCallId,toolName:n.toolName,output:e,...n.providerMetadata==null?{}:{providerOptions:n.providerMetadata}})}return a.length>0&&n.push({role:`tool`,content:Hq({toolResultContent:a,toolCallOrder:r})}),n}function Hq({toolResultContent:e,toolCallOrder:t}){let n=e.filter(e=>e.type===`tool-result`).map((e,t)=>({part:e,index:t})).sort((e,n)=>{let r=t.get(e.part.toolCallId),i=t.get(n.part.toolCallId);return r==null&&i==null?e.index-n.index:r==null?1:i==null?-1:r-i||e.index-n.index}).map(({part:e})=>e),r=0;return e.map(e=>e.type===`tool-result`?n[r++]:e)}var Uq=`AI_SDK_DIRECT_TOOL_CALL`;function Wq({tools:e,toolCallers:t}){if(e==null||t==null)return;let n={};for(let[r,i]of Object.entries(t)){if(!Object.prototype.hasOwnProperty.call(e,r))throw new qU({parameter:`experimental_toolCallers`,value:t,message:`unknown tool "${r}".`});if(!Array.isArray(i))throw new qU({parameter:`experimental_toolCallers`,value:t,message:`callers for tool "${r}" must be an array.`});n[r]=i.map(n=>{if(n===Uq)return n;if(typeof n!=`string`||!Object.prototype.hasOwnProperty.call(e,n)||oV(e[n])==null)throw new qU({parameter:`experimental_toolCallers`,value:t,message:`tool "${r}" contains an invalid caller.`});return n})}return n}function Gq({tools:e,toolCallers:t}){if(e==null||t==null)return{executionTools:e,modelTools:e};let n={...e},r={...e},i=new Map;for(let[e,a]of Object.entries(t)){let t=n[e];if(t==null)continue;let o=!1,s=!1,c=t;for(let t of a){if(t===Uq){o=!0;continue}let r=oV(n[t]);if(r!=null){if(r.type===`provider`)s=!0,c={...c,providerOptions:r.prepareProviderOptions(c.providerOptions)};else{let n=i.get(t)??{};n[e]=c,i.set(t,n)}}}n[e]=c,o||s?r[e]=c:delete r[e]}for(let[e,t]of Object.entries(n)){let a=oV(t);if(a?.type!==`local`)continue;let o=a.bind(i.get(e)??{});n[e]=o,Object.prototype.hasOwnProperty.call(r,e)&&(r[e]=o)}return{executionTools:n,modelTools:r}}var Kq=new TextEncoder;function qq(e){return typeof e!=`object`||!e?JSON.stringify(e):Array.isArray(e)?`[${e.map(qq).join(`,`)}]`:`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${qq(e[t])}`).join(`,`)}}`}function Jq(e){return VL(e).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)}async function Yq(e){let t=await crypto.subtle.digest(`SHA-256`,Kq.encode(qq(e)));return Jq(new Uint8Array(t))}var Xq=new TextEncoder;function Zq(e){return BL(e)}async function Qq(e){let t=typeof e==`string`?Xq.encode(e):e;return crypto.subtle.importKey(`raw`,t,{name:`HMAC`,hash:`SHA-256`},!1,[`sign`,`verify`])}function $q(e,t,n,r){return Xq.encode(JSON.stringify([`ai-sdk-tool-approval-v1`,e,t,n,r]))}function eJ(e,t,n,r){return Xq.encode(`${e}
|
|
168
|
-
${t}
|
|
169
|
-
${n}
|
|
170
|
-
${r}`)}async function tJ({secret:e,approvalId:t,toolCallId:n,toolName:r,input:i}){let a=await Qq(e),o=$q(t,n,r,await Yq(i)),s=await crypto.subtle.sign(`HMAC`,a,o);return Jq(new Uint8Array(s))}async function nJ({secret:e,signature:t,approvalId:n,toolCallId:r,toolName:i,input:a}){let o=await Qq(e),s=await Yq(a),c=Zq(t),l=$q(n,r,i,s);if(await crypto.subtle.verify(`HMAC`,o,c,l))return!0;if(!n.includes(`
|
|
171
|
-
`)&&!r.includes(`
|
|
172
|
-
`)&&!i.includes(`
|
|
173
|
-
`)){let e=eJ(n,r,i,s);return crypto.subtle.verify(`HMAC`,o,c,e)}return!1}async function rJ({secret:e,approvalId:t,toolCallId:n,toolName:r,input:i}){if(e!=null)return tJ({secret:e,approvalId:t,toolCallId:n,toolName:r,input:i})}async function iJ({approvedToolApprovals:e,tools:t,toolApproval:n,messages:r,toolsContext:i,runtimeContext:a,toolApprovalSecret:o}){let s=[],c=[];for(let l of e){let{toolCall:e,approvalRequest:u}=l,d=HK(t,e.toolName);if(o!=null){if(u.signature==null)throw new rW({approvalId:u.approvalId,toolCallId:e.toolCallId,reason:`missing signature`});if(!await nJ({secret:o,signature:u.signature,approvalId:u.approvalId,toolCallId:e.toolCallId,toolName:e.toolName,input:e.input}))throw new rW({approvalId:u.approvalId,toolCallId:e.toolCallId,reason:`invalid signature`})}if(rV(d)&&d.inputSchema!=null){let t=await SB({value:e.input,schema:mB(d.inputSchema)});if(!t.success)throw new cW({toolName:e.toolName,toolInput:JSON.stringify(e.input),cause:t.error})}let f=await vq({tools:t,toolApproval:n,toolCall:e,messages:r,toolsContext:i,runtimeContext:a});f.type===`denied`?c.push({...l,approvalResponse:{...l.approvalResponse,approved:!1,reason:f.reason??l.approvalResponse.reason}}):s.push(l)}return{approvedToolApprovals:s,deniedToolApprovals:c}}LR({prefix:`aitxt`,size:24}),LR({prefix:`call`,size:24});function aJ(e,t){let n=new Headers(e??{});for(let[e,r]of Object.entries(t))n.has(e)||n.set(e,r);return n}function oJ({status:e,statusText:t,headers:n,stream:r}){return new Response(r.pipeThrough(new TextEncoderStream),{status:e??200,statusText:t,headers:aJ(n,{"content-type":`text/plain; charset=utf-8`})})}function sJ({response:e,status:t,statusText:n,headers:r,stream:i}){let a=t??200;n===void 0?e.writeHead(a,r):e.writeHead(a,n,r);let o=i.getReader();return(async()=>{try{for(;;){let{done:t,value:n}=await o.read();if(t)break;let r=e.write(n),i=e.flush;typeof i==`function`&&i.call(e),r||await new Promise(t=>{e.once(`drain`,t)})}}catch(e){throw e}finally{e.end()}})()}function cJ({response:e,status:t,statusText:n,headers:r,stream:i}){return sJ({response:e,status:t,statusText:n,headers:Object.fromEntries(aJ(r,{"content-type":`text/plain; charset=utf-8`}).entries()),stream:i.pipeThrough(new TextEncoderStream)})}function lJ({stream:e}){return e.pipeThrough(new TransformStream({transform(e,t){e.type===`text-delta`&&t.enqueue(e.text)}}))}var uJ=class extends TransformStream{constructor(){super({transform(e,t){t.enqueue(`data: ${JSON.stringify(e)}
|
|
174
|
-
|
|
175
|
-
`)},flush(e){e.enqueue(`data: [DONE]
|
|
176
|
-
|
|
177
|
-
`)}})}},dJ={"content-type":`text/event-stream`,"cache-control":`no-cache`,connection:`keep-alive`,"x-vercel-ai-ui-message-stream":`v1`,"x-accel-buffering":`no`};function fJ({status:e,statusText:t,headers:n,stream:r,consumeSseStream:i}){let a=r.pipeThrough(new uJ);if(i){let[e,t]=a.tee();a=e,i({stream:t})}return new Response(a.pipeThrough(new TextEncoderStream),{status:e,statusText:t,headers:aJ(n,dJ)})}function pJ({response:e,status:t,statusText:n,headers:r,stream:i,consumeSseStream:a}){let o=i.pipeThrough(new uJ);if(a){let[e,t]=o.tee();o=e,a({stream:t})}return sJ({response:e,status:t,statusText:n,headers:Object.fromEntries(aJ(r,dJ).entries()),stream:o.pipeThrough(new TextEncoderStream)})}function mJ({originalMessages:e,responseMessageId:t}){if(e==null)return;let n=e[e.length-1];return n?.role===`assistant`?n.id:typeof t==`function`?t():t}var hJ=W.record(W.string(),mK.optional()),gJ=dB(()=>bB(W.union([W.looseObject({type:W.literal(`text-start`),id:W.string(),providerMetadata:hK.optional()}),W.looseObject({type:W.literal(`text-delta`),id:W.string(),delta:W.string(),providerMetadata:hK.optional()}),W.looseObject({type:W.literal(`text-end`),id:W.string(),providerMetadata:hK.optional()}),W.looseObject({type:W.literal(`error`),errorText:W.string()}),W.looseObject({type:W.literal(`tool-input-start`),toolCallId:W.string(),toolName:W.string(),providerExecuted:W.boolean().optional(),providerMetadata:hK.optional(),toolMetadata:hJ.optional(),dynamic:W.boolean().optional(),title:W.string().optional()}),W.looseObject({type:W.literal(`tool-input-delta`),toolCallId:W.string(),inputTextDelta:W.string()}),W.looseObject({type:W.literal(`tool-input-available`),toolCallId:W.string(),toolName:W.string(),input:W.unknown(),providerExecuted:W.boolean().optional(),providerMetadata:hK.optional(),toolMetadata:hJ.optional(),dynamic:W.boolean().optional(),title:W.string().optional()}),W.looseObject({type:W.literal(`tool-input-error`),toolCallId:W.string(),toolName:W.string(),input:W.unknown(),providerExecuted:W.boolean().optional(),providerMetadata:hK.optional(),toolMetadata:hJ.optional(),dynamic:W.boolean().optional(),errorText:W.string(),title:W.string().optional()}),W.looseObject({type:W.literal(`tool-approval-request`),approvalId:W.string(),toolCallId:W.string(),isAutomatic:W.boolean().optional(),signature:W.string().optional()}),W.looseObject({type:W.literal(`tool-approval-response`),approvalId:W.string(),approved:W.boolean(),reason:W.string().optional(),providerExecuted:W.boolean().optional(),providerMetadata:hK.optional()}),W.looseObject({type:W.literal(`tool-output-available`),toolCallId:W.string(),output:W.unknown(),providerExecuted:W.boolean().optional(),providerMetadata:hK.optional(),toolMetadata:hJ.optional(),dynamic:W.boolean().optional(),preliminary:W.boolean().optional()}),W.looseObject({type:W.literal(`tool-output-error`),toolCallId:W.string(),errorText:W.string(),providerExecuted:W.boolean().optional(),providerMetadata:hK.optional(),toolMetadata:hJ.optional(),dynamic:W.boolean().optional()}),W.looseObject({type:W.literal(`tool-output-denied`),toolCallId:W.string()}),W.looseObject({type:W.literal(`reasoning-start`),id:W.string(),providerMetadata:hK.optional()}),W.looseObject({type:W.literal(`reasoning-delta`),id:W.string(),delta:W.string(),providerMetadata:hK.optional()}),W.looseObject({type:W.literal(`reasoning-end`),id:W.string(),providerMetadata:hK.optional()}),W.looseObject({type:W.literal(`custom`),kind:W.string().transform(e=>e),providerMetadata:hK.optional()}),W.looseObject({type:W.literal(`source-url`),sourceId:W.string(),url:W.string(),title:W.string().optional(),providerMetadata:hK.optional()}),W.looseObject({type:W.literal(`source-document`),sourceId:W.string(),mediaType:W.string(),title:W.string(),filename:W.string().optional(),providerMetadata:hK.optional()}),W.looseObject({type:W.literal(`file`),url:W.string(),mediaType:W.string(),providerMetadata:hK.optional()}),W.looseObject({type:W.literal(`reasoning-file`),url:W.string(),mediaType:W.string(),providerMetadata:hK.optional()}),W.looseObject({type:W.custom(e=>typeof e==`string`&&e.startsWith(`data-`),{message:`Type must start with "data-"`}),id:W.string().optional(),data:W.unknown(),transient:W.boolean().optional()}),W.looseObject({type:W.literal(`start-step`)}),W.looseObject({type:W.literal(`finish-step`)}),W.looseObject({type:W.literal(`start`),messageId:W.string().optional(),messageMetadata:W.unknown().optional()}),W.looseObject({type:W.literal(`finish`),finishReason:W.enum([`stop`,`length`,`content-filter`,`tool-calls`,`error`,`other`]).optional(),messageMetadata:W.unknown().optional()}),W.looseObject({type:W.literal(`abort`),reason:W.string().optional()}),W.looseObject({type:W.literal(`message-metadata`),messageMetadata:W.unknown()})])));function _J(e){return e.type.startsWith(`data-`)}function vJ(){return Object.create(null)}function yJ(e){return e.type.startsWith(`data-`)}function bJ(e){return e.type===`text`}function xJ(e){return e.type===`custom`}function SJ(e){return e.type===`file`}function CJ(e){return e.type===`reasoning-file`}function wJ(e){return e.type===`reasoning`}function TJ(e){return e.type.startsWith(`tool-`)}function EJ(e){return e.type===`dynamic-tool`}function DJ(e){return TJ(e)||EJ(e)}function OJ(e){return e.type.split(`-`).slice(1).join(`-`)}function kJ(e){return EJ(e)?e.toolName:OJ(e)}function AJ({lastMessage:e,messageId:t}){return{message:e?.role===`assistant`?e:{id:t,metadata:void 0,role:`assistant`,parts:[]},activeTextParts:vJ(),activeReasoningParts:vJ(),partialToolCalls:vJ()}}function jJ({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:r,onError:i,onToolCall:a,onData:o}){return e.pipeThrough(new TransformStream({async transform(e,s){await r(async({state:r,write:c})=>{function l(){let e=r.message.parts,t=e.length-1;for(;t>=0&&e[t].type!==`step-start`;)t--;return e.slice(t+1)}function u(){return l().filter(DJ)}function d(e){let t=u().find(t=>t.toolCallId===e);if(t==null){let n=r.message.parts;for(let r=n.length-1;r>=0;r--){let i=n[r];if(DJ(i)&&i.toolCallId===e){t=i;break}}}if(t==null)throw new WW({chunkType:`tool-invocation`,chunkId:e,message:`No tool invocation found for tool call ID "${e}".`});return t}function f(e){let t=r.message.parts.filter(DJ).find(t=>t.approval?.id===e);if(t==null)throw new WW({chunkType:`tool-approval-response`,chunkId:e,message:`No tool invocation found for approval ID "${e}".`});return t}function p(e,t){let n=t??l().find(t=>TJ(t)&&t.toolCallId===e.toolCallId),i=e,a=n;if(n!=null){n.state=e.state,a.input=i.input,a.output=i.output,a.errorText=i.errorText,a.rawInput=i.rawInput,a.preliminary=i.preliminary,e.title!==void 0&&(a.title=e.title),e.toolMetadata!==void 0&&(a.toolMetadata=e.toolMetadata),a.providerExecuted=i.providerExecuted??n.providerExecuted;let t=i.providerMetadata;if(t!=null){if(e.state===`output-available`||e.state===`output-error`){let e=n;e.resultProviderMetadata=t}else n.callProviderMetadata=t}}else r.message.parts.push({type:`tool-${e.toolName}`,toolCallId:e.toolCallId,state:e.state,title:e.title,...e.toolMetadata===void 0?{}:{toolMetadata:e.toolMetadata},input:i.input,output:i.output,rawInput:i.rawInput,errorText:i.errorText,providerExecuted:i.providerExecuted,preliminary:i.preliminary,...i.providerMetadata!=null&&(e.state===`output-available`||e.state===`output-error`)?{resultProviderMetadata:i.providerMetadata}:{},...i.providerMetadata!=null&&e.state!==`output-available`&&e.state!==`output-error`?{callProviderMetadata:i.providerMetadata}:{}})}function m(e,t){let n=t??l().find(t=>t.type===`dynamic-tool`&&t.toolCallId===e.toolCallId),i=e,a=n;if(n!=null){n.state=e.state,a.toolName=e.toolName,a.input=i.input,a.output=i.output,a.errorText=i.errorText,a.rawInput=i.rawInput??a.rawInput,a.preliminary=i.preliminary,e.title!==void 0&&(a.title=e.title),e.toolMetadata!==void 0&&(a.toolMetadata=e.toolMetadata),a.providerExecuted=i.providerExecuted??n.providerExecuted;let t=i.providerMetadata;if(t!=null){if(e.state===`output-available`||e.state===`output-error`){let e=n;e.resultProviderMetadata=t}else n.callProviderMetadata=t}}else r.message.parts.push({type:`dynamic-tool`,toolName:e.toolName,toolCallId:e.toolCallId,state:e.state,input:i.input,output:i.output,errorText:i.errorText,preliminary:i.preliminary,providerExecuted:i.providerExecuted,title:e.title,...e.toolMetadata===void 0?{}:{toolMetadata:e.toolMetadata},...i.providerMetadata!=null&&(e.state===`output-available`||e.state===`output-error`)?{resultProviderMetadata:i.providerMetadata}:{},...i.providerMetadata!=null&&e.state!==`output-available`&&e.state!==`output-error`?{callProviderMetadata:i.providerMetadata}:{}})}async function h(e){if(e!=null){let n=r.message.metadata==null?e:BG(r.message.metadata,e);t!=null&&await xB({value:n,schema:t,context:{field:`message.metadata`,entityId:r.message.id}}),r.message.metadata=n}}switch(e.type){case`text-start`:{let t={type:`text`,text:``,providerMetadata:e.providerMetadata,state:`streaming`};r.activeTextParts[e.id]=t,r.message.parts.push(t),c();break}case`text-delta`:{let t=r.activeTextParts[e.id];if(t==null)throw new WW({chunkType:`text-delta`,chunkId:e.id,message:`Received text-delta for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});t.text+=e.delta,t.providerMetadata=e.providerMetadata??t.providerMetadata,c();break}case`text-end`:{let t=r.activeTextParts[e.id];if(t==null)throw new WW({chunkType:`text-end`,chunkId:e.id,message:`Received text-end for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});t.state=`done`,t.providerMetadata=e.providerMetadata??t.providerMetadata,delete r.activeTextParts[e.id],c();break}case`custom`:{let t={type:`custom`,kind:e.kind,providerMetadata:e.providerMetadata};r.message.parts.push(t),c();break}case`reasoning-start`:{let t={type:`reasoning`,id:e.id,text:``,providerMetadata:e.providerMetadata,state:`streaming`};r.activeReasoningParts[e.id]=t,r.message.parts.push(t),c();break}case`reasoning-delta`:{let t=r.activeReasoningParts[e.id];if(t==null)throw new WW({chunkType:`reasoning-delta`,chunkId:e.id,message:`Received reasoning-delta for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});t.text+=e.delta,t.providerMetadata=e.providerMetadata??t.providerMetadata,c();break}case`reasoning-end`:{let t=r.activeReasoningParts[e.id];if(t==null)throw new WW({chunkType:`reasoning-end`,chunkId:e.id,message:`Received reasoning-end for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});t.providerMetadata=e.providerMetadata??t.providerMetadata,t.state=`done`,delete r.activeReasoningParts[e.id],c();break}case`file`:case`reasoning-file`:r.message.parts.push({type:e.type,mediaType:e.mediaType,url:e.url,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}}),c();break;case`source-url`:r.message.parts.push({type:`source-url`,sourceId:e.sourceId,url:e.url,title:e.title,providerMetadata:e.providerMetadata}),c();break;case`source-document`:r.message.parts.push({type:`source-document`,sourceId:e.sourceId,mediaType:e.mediaType,title:e.title,filename:e.filename,providerMetadata:e.providerMetadata}),c();break;case`tool-input-start`:{let t=l().filter(TJ);r.partialToolCalls[e.toolCallId]={text:``,toolName:e.toolName,index:t.length,dynamic:e.dynamic,title:e.title,toolMetadata:e.toolMetadata},e.dynamic?m({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-streaming`,input:void 0,providerExecuted:e.providerExecuted,title:e.title,toolMetadata:e.toolMetadata,providerMetadata:e.providerMetadata}):p({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-streaming`,input:void 0,providerExecuted:e.providerExecuted,title:e.title,toolMetadata:e.toolMetadata,providerMetadata:e.providerMetadata}),c();break}case`tool-input-delta`:{let t=r.partialToolCalls[e.toolCallId];if(t==null)throw new WW({chunkType:`tool-input-delta`,chunkId:e.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${e.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});t.text+=e.inputTextDelta;let{value:n}=await iq(t.text);t.dynamic?m({toolCallId:e.toolCallId,toolName:t.toolName,state:`input-streaming`,input:n,title:t.title,toolMetadata:t.toolMetadata}):p({toolCallId:e.toolCallId,toolName:t.toolName,state:`input-streaming`,input:n,title:t.title,toolMetadata:t.toolMetadata}),c();break}case`tool-input-available`:e.dynamic?m({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-available`,input:e.input,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:e.title,toolMetadata:e.toolMetadata}):p({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-available`,input:e.input,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:e.title,toolMetadata:e.toolMetadata}),c(),a&&!e.providerExecuted&&await a({toolCall:e});break;case`tool-input-error`:{let t=l().filter(DJ).find(t=>t.toolCallId===e.toolCallId);(t==null?e.dynamic:t.type===`dynamic-tool`)?m({toolCallId:e.toolCallId,toolName:e.toolName,state:`output-error`,input:e.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,toolMetadata:e.toolMetadata}):p({toolCallId:e.toolCallId,toolName:e.toolName,state:`output-error`,input:void 0,rawInput:e.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,toolMetadata:e.toolMetadata}),c();break}case`tool-approval-request`:{let t=d(e.toolCallId);t.state=`approval-requested`,t.approval={id:e.approvalId,...e.isAutomatic===!0?{isAutomatic:!0}:{},...e.signature==null?{}:{signature:e.signature}},c();break}case`tool-approval-response`:{let t=f(e.approvalId),n=t.approval==null?{id:e.approvalId}:t.approval;t.state=`approval-responded`,t.approval={id:e.approvalId,approved:e.approved,...e.reason==null?{}:{reason:e.reason},...n.isAutomatic===!0?{isAutomatic:!0}:{},...n.signature==null?{}:{signature:n.signature}},e.providerExecuted!=null&&(t.providerExecuted=e.providerExecuted),e.providerMetadata!=null&&(t.callProviderMetadata=e.providerMetadata),c();break}case`tool-output-denied`:{let t=d(e.toolCallId);t.state=`output-denied`,c();break}case`tool-output-available`:{let t=d(e.toolCallId);t.type===`dynamic-tool`?m({toolCallId:e.toolCallId,toolName:t.toolName,state:`output-available`,input:t.input,output:e.output,preliminary:e.preliminary,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:t.toolMetadata},t):p({toolCallId:e.toolCallId,toolName:OJ(t),state:`output-available`,input:t.input,output:e.output,providerExecuted:e.providerExecuted,preliminary:e.preliminary,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:t.toolMetadata},t),c();break}case`tool-output-error`:{let t=d(e.toolCallId);t.type===`dynamic-tool`?m({toolCallId:e.toolCallId,toolName:t.toolName,state:`output-error`,input:t.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:t.toolMetadata},t):p({toolCallId:e.toolCallId,toolName:OJ(t),state:`output-error`,input:t.input,rawInput:t.rawInput,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:t.toolMetadata},t),c();break}case`start-step`:r.message.parts.push({type:`step-start`});break;case`finish-step`:r.activeTextParts=vJ(),r.activeReasoningParts=vJ();break;case`start`:e.messageId!=null&&(r.message.id=e.messageId),await h(e.messageMetadata),(e.messageId!=null||e.messageMetadata!=null)&&c({updateStatus:!1});break;case`finish`:e.finishReason!=null&&(r.finishReason=e.finishReason),await h(e.messageMetadata),e.messageMetadata!=null&&c();break;case`message-metadata`:await h(e.messageMetadata),e.messageMetadata!=null&&c();break;case`error`:i?.(Error(e.errorText));break;default:if(_J(e)){if(n?.[e.type]!=null){let t=r.message.parts.findIndex(t=>`id`in t&&`data`in t&&t.id===e.id&&t.type===e.type),i=t>=0?t:r.message.parts.length;await xB({value:e.data,schema:n[e.type],context:{field:`message.parts[${i}].data`,entityName:e.type,entityId:e.id}})}let t=e;if(t.transient){o?.(t);break}let i=t.id==null?void 0:r.message.parts.find(e=>t.type===e.type&&t.id===e.id);i==null?r.message.parts.push(t):i.data=t.data,o?.(t),c()}}s.enqueue(e)})}}))}function MJ({messageId:e,originalMessages:t=[],onStepEnd:n,onStepFinish:r,onEnd:i,onFinish:a,onError:o,stream:s}){let c=t?.[t.length-1];c?.role===`assistant`?e=c.id:c=void 0;let l=!1,u=s.pipeThrough(new TransformStream({transform(t,n){if(t.type===`start`){let n=t;n.messageId==null&&e!=null&&(n.messageId=e)}t.type===`abort`&&(l=!0),n.enqueue(t)}})),d=n??r,f=i??a;if(f==null&&d==null)return u;let p=AJ({lastMessage:c?structuredClone(c):void 0,messageId:e??``}),m=async e=>{await e({state:p,write:()=>{}})},h=!1,g=async()=>{if(h||!f)return;h=!0;let e=p.message.id===c?.id;await f({isAborted:l,isContinuation:e,responseMessage:p.message,messages:[...e?t.slice(0,-1):t,p.message],finishReason:p.finishReason})},_=async()=>{if(!d)return;let e=p.message.id===c?.id;try{await d({isContinuation:e,responseMessage:structuredClone(p.message),messages:[...e?t.slice(0,-1):t,structuredClone(p.message)]})}catch(e){o(e)}};return jJ({stream:u,runUpdateMessageJob:m,onError:o}).pipeThrough(new TransformStream({async transform(e,t){e.type===`finish-step`&&await _(),t.enqueue(e)},async cancel(){await g()},async flush(){await g()}}))}function NJ(e,{tools:t,sendReasoning:n=!0,sendSources:r=!1,sendStart:i=!0,sendFinish:a=!0,onError:o=()=>`An error occurred.`,messageMetadata:s,responseMessageId:c}={}){let l=e=>{let n=t?.[e.toolName];return n==null?e.dynamic:n?.type===`dynamic`||void 0},u=e.type;switch(u){case`text-start`:return{type:`text-start`,id:e.id,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}};case`text-delta`:return{type:`text-delta`,id:e.id,delta:e.text,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}};case`text-end`:return{type:`text-end`,id:e.id,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}};case`reasoning-start`:case`reasoning-end`:return n?{type:u,id:e.id,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}}:void 0;case`reasoning-delta`:return n?{type:`reasoning-delta`,id:e.id,delta:e.text,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}}:void 0;case`file`:case`reasoning-file`:return u===`reasoning-file`&&!n?void 0:{type:e.type,mediaType:e.file.mediaType,url:`data:${e.file.mediaType};base64,${e.file.base64}`,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}};case`source`:return r?e.sourceType===`url`?{type:`source-url`,sourceId:e.id,url:e.url,title:e.title,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}}:e.sourceType===`document`?{type:`source-document`,sourceId:e.id,mediaType:e.mediaType,title:e.title,filename:e.filename,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}}:void 0:void 0;case`custom`:return{type:`custom`,kind:e.kind,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}};case`tool-input-start`:{let t=l(e);return{type:`tool-input-start`,toolCallId:e.id,toolName:e.toolName,...e.providerExecuted==null?{}:{providerExecuted:e.providerExecuted},...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata},...e.toolMetadata==null?{}:{toolMetadata:e.toolMetadata},...t==null?{}:{dynamic:t},...e.title==null?{}:{title:e.title}}}case`tool-input-delta`:return{type:`tool-input-delta`,toolCallId:e.id,inputTextDelta:e.delta};case`tool-call`:{let t=l(e);return e.invalid?{type:`tool-input-error`,toolCallId:e.toolCallId,toolName:e.toolName,input:e.input,...e.providerExecuted==null?{}:{providerExecuted:e.providerExecuted},...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata},...e.toolMetadata==null?{}:{toolMetadata:e.toolMetadata},...t==null?{}:{dynamic:t},errorText:o(e.error),...e.title==null?{}:{title:e.title}}:{type:`tool-input-available`,toolCallId:e.toolCallId,toolName:e.toolName,input:e.input,...e.providerExecuted==null?{}:{providerExecuted:e.providerExecuted},...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata},...e.toolMetadata==null?{}:{toolMetadata:e.toolMetadata},...t==null?{}:{dynamic:t},...e.title==null?{}:{title:e.title}}}case`tool-approval-request`:return{type:`tool-approval-request`,approvalId:e.approvalId,toolCallId:e.toolCall.toolCallId,...e.isAutomatic==null?{}:{isAutomatic:e.isAutomatic},...e.signature==null?{}:{signature:e.signature}};case`tool-approval-response`:return{type:`tool-approval-response`,approvalId:e.approvalId,approved:e.approved,...e.reason==null?{}:{reason:e.reason},...e.providerExecuted==null?{}:{providerExecuted:e.providerExecuted}};case`tool-result`:{let t=l(e);return{type:`tool-output-available`,toolCallId:e.toolCallId,output:e.output===void 0?null:e.output,...e.providerExecuted==null?{}:{providerExecuted:e.providerExecuted},...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata},...e.toolMetadata==null?{}:{toolMetadata:e.toolMetadata},...e.preliminary==null?{}:{preliminary:e.preliminary},...t==null?{}:{dynamic:t}}}case`tool-error`:{let t=l(e);return{type:`tool-output-error`,toolCallId:e.toolCallId,errorText:e.providerExecuted?typeof e.error==`string`?e.error:JSON.stringify(e.error):o(e.error),...e.providerExecuted==null?{}:{providerExecuted:e.providerExecuted},...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata},...e.toolMetadata==null?{}:{toolMetadata:e.toolMetadata},...t==null?{}:{dynamic:t}}}case`tool-output-denied`:return{type:`tool-output-denied`,toolCallId:e.toolCallId};case`error`:return{type:`error`,errorText:o(e.error)};case`start-step`:return{type:`start-step`};case`finish-step`:return{type:`finish-step`};case`start`:return i?{type:`start`,...s==null?{}:{messageMetadata:s},...c==null?{}:{messageId:c}}:void 0;case`finish`:return a?{type:`finish`,finishReason:e.finishReason,...s==null?{}:{messageMetadata:s}}:void 0;case`abort`:return e;case`tool-input-end`:case`raw`:return;default:throw Error(`Unknown chunk type: ${u}`)}}function PJ({stream:e,tools:t,sendReasoning:n=!0,sendSources:r=!1,sendStart:i=!0,sendFinish:a=!0,onError:o=()=>`An error occurred.`,messageMetadata:s,originalMessages:c,generateMessageId:l,onEnd:u,onFinish:d}){let f=l==null?void 0:mJ({originalMessages:c,responseMessageId:l});return MJ({stream:e.pipeThrough(new TransformStream({transform:async(e,c)=>{let l=s?.({part:e}),u=NJ(e,{tools:t,sendReasoning:n,sendSources:r,sendStart:i,sendFinish:a,onError:o,messageMetadata:l,responseMessageId:f});u!=null&&c.enqueue(u),l!=null&&e.type!==`start`&&e.type!==`finish`&&c.enqueue({type:`message-metadata`,messageMetadata:l})}})),messageId:f??l?.(),originalMessages:c,onEnd:u??d,onError:o})}function FJ(e){return IJ(e.pipeThrough(new TransformStream))}function IJ(e){return e[Symbol.asyncIterator]=function(){let e=this.getReader(),t=!1;async function n(n){if(!t){t=!0;try{n&&await e.cancel?.call(e)}finally{try{e.releaseLock()}catch{}}}}return{async next(){if(t)return{done:!0,value:void 0};let r;try{r=await e.read()}catch(e){throw await n(!1),e}let{done:i,value:a}=r;return i?(await n(!0),{done:!0,value:void 0}):{done:!1,value:a}},async return(){return await n(!0),{done:!0,value:void 0}},async throw(e){throw await n(!0),e}}},e}async function LJ({stream:e,onError:t,abortSignal:n}){let r=e.getReader(),i=()=>{r.cancel().catch(()=>{})};n?.aborted?i():n?.addEventListener(`abort`,i,{once:!0});try{for(;;){let{done:e}=await r.read();if(e)break}}catch(e){t?.(e)}finally{n?.removeEventListener(`abort`,i),r.releaseLock()}}function RJ(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function zJ(){let e=[],t=null,n=!1,r=RJ(),i=()=>{n=!0,r.resolve(),e.forEach(({reader:e,onCancel:t})=>{t?.(),e.cancel()}),e=[],t?.close()},a=async()=>{var o;if(n&&e.length===0){t?.close();return}if(e.length===0)return r=RJ(),await r.promise,await a();let s=e[0];try{let{value:r,done:i}=await s.reader.read();i?(e.shift(),e.length===0&&n?t?.close():await a()):t?.enqueue(r)}catch(n){(o=s.onError)==null||o.call(s,n),t?.error(n),e.shift(),i()}};return{stream:new ReadableStream({start(e){t=e},pull:a,async cancel(){for(let{reader:t,onCancel:n}of e)n?.(),await t.cancel();e=[],n=!0}}),addStream:(t,i)=>{if(n)throw Error(`Cannot add inner stream: outer stream is closed`);e.push({reader:t.getReader(),...i}),r.resolve()},close:()=>{n=!0,r.resolve(),e.length===0&&t?.close()},terminate:i}}function BJ({stream:e,tools:t,callId:n,messages:r,abortSignal:i,timeout:a,experimental_sandbox:o,toolsContext:s,toolApproval:c,runtimeContext:l,toolApprovalSecret:u,generateId:d,onToolExecutionStart:f,onToolExecutionEnd:p,executeToolInTelemetryContext:m,runInTracingChannelSpan:h}){let g=[];return e.pipeThrough(new TransformStream({async transform(e,_){switch(_.enqueue(e),e.type){case`tool-call`:{if(e.invalid)return;let n=HK(t,e.toolName);if(n==null)return;let i=await vq({tools:t,toolCall:e,toolApproval:c,messages:r,toolsContext:s,runtimeContext:l});if(i.type===`not-applicable`){n.execute!=null&&e.providerExecuted!==!0&&g.push(e);return}let a=d(),o=await rJ({secret:u,approvalId:a,toolCallId:e.toolCallId,toolName:e.toolName,input:e.input});switch(i.type){case`user-approval`:_.enqueue({type:`tool-approval-request`,approvalId:a,toolCall:e,...o==null?{}:{signature:o}});return;case`denied`:_.enqueue({type:`tool-approval-request`,approvalId:a,toolCall:e,isAutomatic:!0,...o==null?{}:{signature:o}}),_.enqueue({type:`tool-approval-response`,approvalId:a,approved:!1,toolCall:e,reason:i.reason,providerExecuted:e.providerExecuted});return;case`approved`:_.enqueue({type:`tool-approval-request`,approvalId:a,toolCall:e,isAutomatic:!0,...o==null?{}:{signature:o}}),_.enqueue({type:`tool-approval-response`,approvalId:a,approved:!0,toolCall:e,reason:i.reason,providerExecuted:e.providerExecuted})}n.execute!=null&&e.providerExecuted!==!0&&g.push(e);return}case`model-call-end`:await Promise.all(g.map(async e=>{try{let c=await $K({toolCall:e,tools:t,callId:n,messages:r,abortSignal:i,timeout:a,experimental_sandbox:o,toolsContext:s,onToolExecutionStart:f,onToolExecutionEnd:p,executeToolInTelemetryContext:m,runInTracingChannelSpan:h,onPreliminaryToolResult:e=>{_.enqueue(e)}});c!=null&&(_.enqueue({type:`tool-execution-end`,toolCallId:c.output.toolCallId,toolExecutionMs:c.toolExecutionMs}),_.enqueue(c.output))}catch(e){_.enqueue({type:`error`,error:e})}}));return}}}))}function VJ({stream:e,tools:t,stepInputMessages:n,abortSignal:r,runtimeContext:i}){if(t==null)return e;let a=vJ();return e.pipeThrough(new TransformStream({async transform(e,o){switch(o.enqueue(e),e.type){case`tool-input-start`:{a[e.id]=e.toolName;let o=HK(t,e.toolName);o?.onInputStart!=null&&await o.onInputStart({toolCallId:e.id,messages:n,abortSignal:r,context:i});break}case`tool-input-delta`:{let o=a[e.id],s=HK(t,o);s?.onInputDelta!=null&&await s.onInputDelta({inputTextDelta:e.delta,toolCallId:e.id,messages:n,abortSignal:r,context:i});break}case`tool-call`:{let o=a[e.toolCallId],s=HK(t,o);delete a[e.toolCallId],s?.onInputAvailable!=null&&await s.onInputAvailable({input:e.input,toolCallId:e.toolCallId,messages:n,abortSignal:r,context:i})}}}}))}var HJ=LR({prefix:`aitxt`,size:24}),UJ=LR({prefix:`call`,size:24});async function WJ({model:e,tools:t,toolOrder:n,output:r,toolChoice:i,prompt:a,system:o,instructions:s,messages:c,allowSystemInMessages:l,download:u,abortSignal:d,headers:f,includeRawChunks:p,providerOptions:m,repairToolCall:h,refineToolInput:g,executeLanguageModelCallInTelemetryContext:_=async({execute:e})=>await e(),callId:v,toolsContext:y,experimental_sandbox:b,_internal:{generateId:x=HJ,generateCallId:S=UJ,now:C=WK}={},onStart:w,onLanguageModelCallStart:T,onLanguageModelCallEnd:E,...D}){let O=NG(e),ee=v??S(),te=await IK({instructions:s,system:o,prompt:a,messages:c,allowSystemInMessages:l}),ne=await KG({prompt:{instructions:te.instructions,messages:te.messages},supportedUrls:await O.supportedUrls,download:u,provider:O.provider.split(`.`)[0]}),k=await oK({tools:t,toolOrder:n,toolsContext:y,experimental_sandbox:b}),re=iK({toolChoice:i});await GK({event:{promptMessages:ne},callbacks:w});let ie={callId:ee,provider:O.provider,modelId:O.modelId,instructions:te.instructions,messages:te.messages,tools:k,...D};await GK({event:ie,callbacks:T});let ae=C(),{stream:A,response:j,request:oe}=await _({...ie,execute:async()=>await O.doStream({...D,tools:k,toolChoice:re,responseFormat:await r?.responseFormat,prompt:ne,providerOptions:m,abortSignal:d,headers:f,includeRawChunks:p})});return{stream:FJ(A.pipeThrough(GJ({tools:t,instructions:te.instructions,messages:te.messages,repairToolCall:h,refineToolInput:g,callId:ee,provider:O.provider,modelId:O.modelId,generateId:x,now:C,callStartTimestampMs:ae,onLanguageModelCallEnd:E}))),response:j,request:oe}}function GJ({tools:e,instructions:t,messages:n,repairToolCall:r,refineToolInput:i,callId:a,provider:o,modelId:s,generateId:c,now:l,callStartTimestampMs:u,onLanguageModelCallEnd:d}){let f=new Map,p=[],m=new Map,h=new Map,g=c(),_=s,v,y,b=[];return new TransformStream({async transform(s,c){if(KJ(s)){let e=l();v==null?v=e-u:y!=null&&b.push(e-y),y=e}switch(s.type){case`text-start`:YJ({content:p,partIndexes:m,id:s.id,type:`text`,providerMetadata:s.providerMetadata}),c.enqueue(s);break;case`text-delta`:YJ({content:p,partIndexes:m,id:s.id,type:`text`,textDelta:s.delta,providerMetadata:s.providerMetadata}),c.enqueue({type:`text-delta`,id:s.id,text:s.delta,providerMetadata:s.providerMetadata});break;case`text-end`:YJ({content:p,partIndexes:m,id:s.id,type:`text`,providerMetadata:s.providerMetadata}),m.delete(s.id),c.enqueue(s);break;case`reasoning-start`:YJ({content:p,partIndexes:h,id:s.id,type:`reasoning`,providerMetadata:s.providerMetadata}),c.enqueue(s);break;case`reasoning-delta`:YJ({content:p,partIndexes:h,id:s.id,type:`reasoning`,textDelta:s.delta,providerMetadata:s.providerMetadata}),c.enqueue({type:`reasoning-delta`,id:s.id,text:s.delta,providerMetadata:s.providerMetadata});break;case`reasoning-end`:YJ({content:p,partIndexes:h,id:s.id,type:`reasoning`,providerMetadata:s.providerMetadata}),h.delete(s.id),c.enqueue(s);break;case`file`:case`reasoning-file`:{let e=new nq({data:s.data.type===`data`?s.data.data:s.data.url.toString(),mediaType:s.mediaType});p.push({type:s.type,file:e,...s.providerMetadata==null?{}:{providerMetadata:s.providerMetadata}}),c.enqueue({type:s.type,file:e,providerMetadata:s.providerMetadata});break}case`finish`:{let e=RK(s.usage),t=l()-u,n={responseTimeMs:t,effectiveOutputTokensPerSecond:XK({tokens:e.outputTokens,durationMs:t}),outputTokensPerSecond:v==null?void 0:XK({tokens:e.outputTokens,durationMs:t-v}),inputTokensPerSecond:v==null?void 0:XK({tokens:e.inputTokens,durationMs:v}),effectiveTotalTokensPerSecond:XK({tokens:Bq(e.inputTokens,e.outputTokens),durationMs:t}),timeToFirstOutputMs:v,timeBetweenOutputChunksMs:b.length>0?qJ(b):void 0};await GK({event:{callId:a,provider:o,modelId:_,finishReason:s.finishReason.unified,usage:e,content:p,responseId:g,...s.providerMetadata==null?{}:{providerMetadata:s.providerMetadata},performance:n},callbacks:d}),c.enqueue({type:`model-call-end`,finishReason:s.finishReason.unified,rawFinishReason:s.finishReason.raw,usage:e,providerMetadata:s.providerMetadata,performance:n});break}case`tool-call`:try{let a=await uq({toolCall:s,tools:e,repairToolCall:r,refineToolInput:i,instructions:t,messages:n});if(f.set(a.toolCallId,a),c.enqueue(a),p.push(a),a.invalid){a.providerExecuted||c.enqueue({type:`tool-error`,toolCallId:a.toolCallId,toolName:a.toolName,input:a.input,error:zI(a.error),dynamic:!0,title:a.title,...a.toolMetadata==null?{}:{toolMetadata:a.toolMetadata}});break}}catch(e){c.enqueue({type:`error`,error:e})}break;case`tool-approval-request`:{let e=f.get(s.toolCallId);if(e==null){c.enqueue({type:`error`,error:new pW({toolCallId:s.toolCallId,approvalId:s.approvalId})});break}let t={type:`tool-approval-request`,approvalId:s.approvalId,toolCall:e};c.enqueue(t),p.push(t);break}case`tool-result`:{let e=s.toolName,t=f.get(s.toolCallId),n=s.isError?{type:`tool-error`,toolCallId:s.toolCallId,toolName:e,input:t?.input,providerExecuted:!0,error:s.result,dynamic:s.dynamic,...s.providerMetadata==null?{}:{providerMetadata:s.providerMetadata},...t?.toolMetadata==null?{}:{toolMetadata:t.toolMetadata}}:{type:`tool-result`,toolCallId:s.toolCallId,toolName:e,input:t?.input,output:s.result,providerExecuted:!0,dynamic:s.dynamic,...s.providerMetadata==null?{}:{providerMetadata:s.providerMetadata},...t?.toolMetadata==null?{}:{toolMetadata:t.toolMetadata}};c.enqueue(n),p.push(n);break}case`tool-input-start`:{let t=HK(e,s.toolName);c.enqueue({...s,dynamic:s.dynamic??t?.type===`dynamic`,title:t?.title,...t?.metadata==null?{}:{toolMetadata:t.metadata}});break}case`stream-start`:c.enqueue({type:`model-call-start`,warnings:s.warnings});break;case`response-metadata`:g=s.id??g,_=s.modelId??_,c.enqueue({type:`model-call-response-metadata`,id:s.id,timestamp:s.timestamp,modelId:s.modelId});break;default:(s.type===`custom`||s.type===`source`)&&p.push(s),c.enqueue(s)}}})}function KJ(e){return e.type===`text-delta`&&e.delta.length>0||e.type===`reasoning-delta`&&e.delta.length>0||e.type===`tool-input-delta`&&e.delta.length>0||e.type===`file`||e.type===`reasoning-file`||e.type===`tool-call`}function qJ(e){let t=[...e].sort((e,t)=>e-t),n=e.reduce((e,t)=>e+t,0);return{min:t[0],p10:JJ(t,.1),median:JJ(t,.5),avg:n/e.length,p90:JJ(t,.9),max:t[t.length-1]}}function JJ(e,t){return e[Math.ceil(t*e.length)-1]}function YJ({content:e,partIndexes:t,id:n,type:r,textDelta:i,providerMetadata:a}){let o=t.get(n);o??(o=e.push({type:r,text:``,...a==null?{}:{providerMetadata:a}})-1,t.set(n,o));let s=e[o];i!=null&&(s.text+=i),a!=null&&(s.providerMetadata=a)}var XJ=LR({prefix:`aitxt`,size:24}),ZJ=LR({prefix:`call`,size:24}),QJ={file:!0,custom:!1,source:!1,"text-start":!1,"text-end":!1,"text-delta":!0,"reasoning-start":!1,"reasoning-end":!1,"reasoning-delta":!0,"reasoning-file":!0,"tool-input-start":!1,"tool-input-end":!1,"tool-input-delta":!0,"tool-approval-request":!1,"tool-approval-response":!1,"tool-call":!0,"tool-result":!1,"tool-error":!1,"tool-execution-end":!1,"model-call-start":!1,"model-call-response-metadata":!1,"model-call-end":!1,error:!1,raw:!1};function $J(e){if(!QJ[e.type])return!1;switch(e.type){case`text-delta`:case`reasoning-delta`:return e.text.length>0;case`tool-input-delta`:return e.delta.length>0;case`file`:case`reasoning-file`:case`tool-call`:return!0;default:return!1}}function eY({model:e,tools:t,toolChoice:n,instructions:r,system:i,prompt:a,messages:o,allowSystemInMessages:s,maxRetries:c,abortSignal:l,timeout:u,headers:d,stopWhen:f=Rq(1),experimental_sandbox:p,output:m,toolApproval:h,experimental_toolCallers:g,experimental_toolApprovalSecret:_,experimental_telemetry:v,telemetry:y=v,prepareStep:b,providerOptions:x,activeTools:S,toolOrder:C,experimental_repairToolCall:w,repairToolCall:T=w,experimental_refineToolInput:E,experimental_transform:D,experimental_download:O,includeRawChunks:ee,onChunk:te,onError:ne=({error:e})=>{console.error(e)},onFinish:k,onEnd:re=k,onAbort:ie,onStepEnd:ae,onStepFinish:A,onStart:j,experimental_onStart:oe,onStepStart:se,experimental_onStepStart:ce,onLanguageModelCallStart:le,experimental_onLanguageModelCallStart:ue,onLanguageModelCallEnd:de,experimental_onLanguageModelCallEnd:fe,onToolExecutionStart:pe,onToolExecutionEnd:me,experimental_onToolCallStart:he,experimental_onToolCallFinish:ge,runtimeContext:_e={},toolsContext:ve={},experimental_include:ye,include:be=ye,_internal:{now:xe=WK,generateId:Se=XJ,generateCallId:Ce=ZJ}={},...we}){let Te=lK(u),Ee=uK(u),De=dK(u),Oe=fK(u),ke=Ee==null?void 0:new AbortController,Ae=De==null?void 0:new AbortController,je=Oe==null?void 0:new AbortController,Me=j??oe,Ne=se??ce,Pe=le??ue,Fe=de??fe,Ie=pe??he,Le=me??ge,Re=ae??A;return new rY({model:NG(e),telemetry:y,headers:d,settings:we,maxRetries:c,abortSignal:UK(l,Te,ke?.signal,Ae?.signal,je?.signal),stepTimeoutMs:Ee,stepAbortController:ke,firstChunkTimeoutMs:De,firstChunkAbortController:Ae,chunkTimeoutMs:Oe,chunkAbortController:je,instructions:r,system:i,prompt:a,messages:o,allowSystemInMessages:s,experimental_sandbox:p,tools:t,toolsContext:ve,runtimeContext:_e,toolChoice:n,transforms:DL(D),activeTools:S,toolOrder:C,repairToolCall:T,refineToolInput:E,stopConditions:DL(f),output:m,toolApproval:h,experimental_toolCallers:g,experimental_toolApprovalSecret:_,providerOptions:x,prepareStep:b,timeout:u,onChunk:te,onError:ne,onEnd:re,onAbort:ie,onStepFinish:Re,onStart:Me,onStepStart:Ne,onLanguageModelCallStart:Pe,onLanguageModelCallEnd:Fe,onToolExecutionStart:Ie,onToolExecutionEnd:Le,now:xe,generateId:Se,generateCallId:Ce,download:O,include:{requestBody:be?.requestBody??!1,requestMessages:be?.requestMessages??!1,rawChunks:be?.rawChunks??ee??!1}})}async function tY(e){try{await e}catch{}}function nY(e){let t,n=``,r=``,i,a=``;function o({controller:e,partialOutput:n=void 0}){e.enqueue({part:{type:`text-delta`,id:t,text:r,providerMetadata:i},partialOutput:n}),r=``}return new TransformStream({async transform(s,c){if(s.type===`finish-step`&&r.length>0&&o({controller:c}),s.type!==`text-delta`&&s.type!==`text-start`&&s.type!==`text-end`){c.enqueue({part:s,partialOutput:void 0});return}if(t==null)t=s.id;else if(s.id!==t){c.enqueue({part:s,partialOutput:void 0});return}if(s.type===`text-start`){c.enqueue({part:s,partialOutput:void 0});return}if(s.type===`text-end`){r.length>0&&o({controller:c}),c.enqueue({part:s,partialOutput:void 0});return}if(n+=s.text,r+=s.text,i=s.providerMetadata??i,s.text.length===0&&s.providerMetadata!=null){c.enqueue({part:s,partialOutput:void 0});return}let l=await e.parsePartialOutput({text:n});if(l!==void 0){let e=typeof l.partial==`string`?l.partial:JSON.stringify(l.partial);e!==a&&(o({controller:c,partialOutput:l.partial}),a=e)}}})}var rY=class{constructor({model:e,telemetry:t,headers:n,settings:r,maxRetries:i,abortSignal:a,stepTimeoutMs:o,stepAbortController:s,firstChunkTimeoutMs:c,firstChunkAbortController:l,chunkTimeoutMs:u,chunkAbortController:d,instructions:f,system:p,prompt:m,messages:h,allowSystemInMessages:g,experimental_sandbox:_,tools:v,toolChoice:y,transforms:b,activeTools:x,toolOrder:S,repairToolCall:C,refineToolInput:w,stopConditions:T,output:E,toolApproval:D,experimental_toolCallers:O,experimental_toolApprovalSecret:ee,providerOptions:te,prepareStep:ne,now:k,generateId:re,generateCallId:ie,timeout:ae,onChunk:A,onError:j,onEnd:oe,onAbort:se,onStepFinish:ce,onStart:le,onStepStart:ue,onLanguageModelCallStart:de,onLanguageModelCallEnd:fe,onToolExecutionStart:pe,onToolExecutionEnd:me,runtimeContext:he,toolsContext:ge,download:_e,include:ve}){this._totalUsage=new HL,this._finishReason=new HL,this._rawFinishReason=new HL,this._steps=new HL,this._initialResponseMessages=new HL,this.outputSpecification=E,this.tools=v;let ye=Wq({tools:v,toolCallers:O}),be=Lq({telemetry:t,includeRuntimeContext:t?.includeRuntimeContext,includeToolsContext:t?.includeToolsContext}),xe,Se=[],Ce,we,Te,Ee={},De=[],Oe=[],ke=[],Ae=[],je,Me=[],Ne=new Map,Pe=vJ(),Fe=vJ(),Ie,Le=new TransformStream({async transform(t,n){n.enqueue(t);let{part:r}=t;if(await A?.({chunk:r}),r.type===`error`){let e=LK(r.error);OW.isInstance(e)&&(Ie=e),await j({error:e})}if((r.type===`custom`||r.type===`source`||r.type===`tool-call`||r.type===`tool-approval-request`||r.type===`tool-approval-response`||r.type===`tool-error`)&&Se.push(r),r.type===`text-start`&&(Pe[r.id]={type:`text`,text:``,providerMetadata:r.providerMetadata},Se.push(Pe[r.id])),r.type===`text-delta`){let e=Pe[r.id];if(e==null){n.enqueue({part:{type:`error`,error:`text part ${r.id} not found`},partialOutput:void 0});return}e.text+=r.text,e.providerMetadata=r.providerMetadata??e.providerMetadata}if(r.type===`text-end`){let e=Pe[r.id];if(e==null){n.enqueue({part:{type:`error`,error:`text part ${r.id} not found`},partialOutput:void 0});return}e.providerMetadata=r.providerMetadata??e.providerMetadata,delete Pe[r.id]}if(r.type===`reasoning-start`&&(Fe[r.id]={type:`reasoning`,text:``,providerMetadata:r.providerMetadata},Se.push(Fe[r.id])),r.type===`reasoning-delta`){let e=Fe[r.id];if(e==null){n.enqueue({part:{type:`error`,error:`reasoning part ${r.id} not found`},partialOutput:void 0});return}e.text+=r.text,e.providerMetadata=r.providerMetadata??e.providerMetadata}if(r.type===`reasoning-end`){let e=Fe[r.id];if(e==null){n.enqueue({part:{type:`error`,error:`reasoning part ${r.id} not found`},partialOutput:void 0});return}e.providerMetadata=r.providerMetadata??e.providerMetadata,delete Fe[r.id]}if((r.type===`file`||r.type===`reasoning-file`)&&Se.push({type:r.type,file:r.file,...r.providerMetadata==null?{}:{providerMetadata:r.providerMetadata}}),r.type===`tool-result`&&!r.preliminary&&Se.push(r),r.type===`start-step`&&(Se=[],Fe=vJ(),Pe=vJ(),Ee=r.request,Oe=r.warnings),r.type===`finish-step`){let t=await Vq({content:Se,tools:v}),n=new Mq({callId:Ge,stepNumber:ke.length,provider:e.provider,modelId:e.modelId,runtimeContext:he,toolsContext:ge,content:Se,finishReason:r.finishReason,rawFinishReason:r.rawFinishReason,usage:r.usage,performance:r.performance,warnings:Oe,request:{...Ee,messages:ve.requestMessages?FG(De):void 0},response:{...r.response,messages:FG(t)},providerMetadata:r.providerMetadata});await GK({event:n,callbacks:[ce,be.onStepEnd]}),hG({warnings:Oe,provider:e.provider,model:e.modelId}),ke.push(n),je=[...Me,...t],xe.resolve()}r.type===`finish`&&(Te=r.totalUsage,Ce=r.finishReason,we=r.rawFinishReason)},async flush(e){try{if(ke.length===0||Ie!=null){let e=a?.aborted?a.reason:Ie??new OW({message:`No output generated. Check the stream for errors.`});We.rejectResultPromises(e);return}let e=Ce??`other`,t=Te??zK();We._finishReason.resolve(e),We._rawFinishReason.resolve(we),We._totalUsage.resolve(t),We._steps.resolve(ke);let n=ke[ke.length-1],r=ke.flatMap(e=>e.content),i=ke.flatMap(e=>e.files),o=ke.flatMap(e=>e.sources),s=ke.flatMap(e=>e.toolCalls),c=ke.flatMap(e=>e.staticToolCalls),l=ke.flatMap(e=>e.dynamicToolCalls),u=ke.flatMap(e=>e.toolResults),d=ke.flatMap(e=>e.staticToolResults),f=ke.flatMap(e=>e.dynamicToolResults),p=ke.flatMap(e=>e.warnings??[]);await GK({event:{callId:Ge,toolsContext:n.toolsContext,stepNumber:n.stepNumber,model:n.model,runtimeContext:n.runtimeContext,finishReason:n.finishReason,rawFinishReason:n.rawFinishReason,usage:t,totalUsage:t,content:r,text:n.text,reasoning:n.reasoning,reasoningText:n.reasoningText,files:i,sources:o,toolCalls:s,staticToolCalls:c,dynamicToolCalls:l,toolResults:u,staticToolResults:d,dynamicToolResults:f,responseMessages:[...Ae,...ke.flatMap(e=>e.response.messages)],warnings:p,request:n.request,response:n.response,providerMetadata:n.providerMetadata,steps:ke,finalStep:n},callbacks:[oe,be.onEnd]})}catch(t){e.error(t)}}}),Re=zJ();this.addStream=Re.addStream,this.closeStream=Re.close;let ze=Re.stream.getReader(),Be=new ReadableStream({async start(e){e.enqueue({type:`start`})},async pull(e){async function t(){await GK({event:{callId:Ge,steps:ke,...a?.reason===void 0?{}:{reason:a.reason}},callbacks:[se,be.onAbort]}),e.enqueue({type:`abort`,...a?.reason===void 0?{}:{reason:zI(a.reason)}}),e.close()}try{let{done:n,value:r}=await ze.read();if(n){e.close();return}if(a?.aborted){await t();return}e.enqueue(r)}catch(n){zR(n)&&a?.aborted?await t():e.error(n)}},cancel(e){return Re.stream.cancel(e)}}),Ve=!0;Be=Be.pipeThrough(new TransformStream({async transform(e,t){Ve&&t.enqueue(e)}}));for(let e of b)Be=Be.pipeThrough(e({tools:v,stopStream(){Re.terminate(),Ve=!1}}));this.baseStream=Be.pipeThrough(nY(E??aq())).pipeThrough(Le);let{maxRetries:He}=JK({maxRetries:i,abortSignal:a}),Ue=rK(r),We=this,Ge=ie();(async()=>{let t=await IK({instructions:f,system:p,prompt:m,messages:h,allowSystemInMessages:g}),r={callId:Ge,operationId:`ai.streamText`,provider:e.provider,modelId:e.modelId,instructions:t.instructions,messages:t.messages,tools:v,toolChoice:y,activeTools:x,toolOrder:S,maxOutputTokens:Ue.maxOutputTokens,temperature:Ue.temperature,topP:Ue.topP,topK:Ue.topK,presencePenalty:Ue.presencePenalty,frequencyPenalty:Ue.frequencyPenalty,stopSequences:Ue.stopSequences,seed:Ue.seed,reasoning:Ue.reasoning,maxRetries:He,timeout:ae,headers:n,providerOptions:te,output:E,runtimeContext:he,toolsContext:ge},i=be.startTracingChannelContext?.call(be,{type:`streamText`,event:r,completion:We._totalUsage.promise.then(()=>void 0)}),b=e=>i?.run(e)??e(),O=be.runInTracingChannelSpan==null?void 0:e=>b(()=>be.runInTracingChannelSpan(e));await GK({event:r,callbacks:[le,be.onStart]});let ie=t.messages,A=t.instructions,{approvedToolApprovals:j,deniedToolApprovals:oe}=ZK({messages:ie});if(oe.length>0||j.length>0){let{approvedToolApprovals:e,deniedToolApprovals:t}=await iJ({approvedToolApprovals:j.filter(e=>!e.toolCall.providerExecuted),tools:v,toolApproval:D,messages:ie,toolsContext:ge,runtimeContext:he,toolApprovalSecret:ee}),n=[...oe.filter(e=>!e.toolCall.providerExecuted),...t],r=n.filter(e=>e.existingToolResult==null),i=oe.filter(e=>e.toolCall.providerExecuted),o,s=new ReadableStream({start(e){o=e}});We.addStream(s);try{for(let e of[...n,...i])o?.enqueue({type:`tool-output-denied`,toolCallId:e.toolCall.toolCallId,toolName:e.toolCall.toolName});let t=[];if(await Promise.all(e.map(async e=>{let n=await $K({toolCall:e.toolCall,tools:v,callId:Ge,messages:ie,abortSignal:a,timeout:ae,experimental_sandbox:_,toolsContext:ge,onToolExecutionStart:IR(pe,be.onToolExecutionStart),onToolExecutionEnd:IR(me,be.onToolExecutionEnd),executeToolInTelemetryContext:be.executeTool,runInTracingChannelSpan:O,onPreliminaryToolResult:e=>{o?.enqueue(e)}});n!=null&&(o?.enqueue(n.output),t.push(n.output))})),t.length>0||r.length>0){let e=[];for(let n of t)e.push({type:`tool-result`,toolCallId:n.toolCallId,toolName:n.toolName,output:await tK({toolCallId:n.toolCallId,input:n.input,tool:HK(v,n.toolName),output:n.type===`tool-result`?n.output:n.error,errorMode:n.type===`tool-error`?`text`:`none`})});for(let t of r)e.push({type:`tool-result`,toolCallId:t.toolCall.toolCallId,toolName:t.toolCall.toolName,output:{type:`execution-denied`,reason:t.approvalResponse.reason}});Ae.push({role:`tool`,content:e})}}finally{o?.close()}}We._initialResponseMessages.resolve(Ae);async function se({currentStep:r,usage:i}){let f=YK({abortController:s,label:`Step`,timeoutMs:o}),p;function m(){a?.aborted||(p=YK({abortController:l,label:`First chunk`,timeoutMs:c}))}function h(){p!=null&&(clearTimeout(p),p=void 0)}let O;function j(){O!=null&&clearTimeout(O),O=YK({abortController:d,label:`Chunk`,timeoutMs:u})}function oe(){O!=null&&(clearTimeout(O),O=void 0)}function ce(){f!=null&&clearTimeout(f)}function le(){ce(),h(),oe()}function Se(){a?.removeEventListener(`abort`,Se),le()}a?.addEventListener(`abort`,Se,{once:!0});try{xe=new HL;let o=be.startTracingChannelContext?.call(be,{type:`step`,event:{callId:Ge,stepNumber:r},completion:xe.promise}),s=e=>o?.run(e)??e(),c=ke.flatMap(e=>e.response.messages),l=[...Ae,...c],u=je??[...ie,...Ae],d=await ne?.({model:e,steps:ke,stepNumber:ke.length,instructions:A,initialInstructions:t.instructions,messages:u,initialMessages:ie,responseMessages:l,toolsContext:ge,runtimeContext:he,experimental_sandbox:_}),f=d?.experimental_sandbox??_;he=d?.runtimeContext??he,ge=d?.toolsContext??ge;let p=NG(d?.model??e),{executionTools:O,modelTools:oe}=Gq({tools:eq({tools:v,activeTools:d?.activeTools??x}),toolCallers:ye}),ce=d?.toolOrder??S,le=await oK({tools:oe,toolOrder:ce,toolsContext:ge,experimental_sandbox:f}),Ce=iK({toolChoice:d?.toolChoice??y}),we=d?.messages??u;Me=we;let Te=d?.instructions??d?.system??A;A=Te;let Ee=BG(te,d?.providerOptions),Oe=mq({callSettings:Ue,stepSettings:d}),Pe=k(),{retry:Fe}=JK({maxRetries:He,abortSignal:a}),{stream:Ie,request:Le,response:Re}=await s(()=>Fe(async()=>WJ({model:d?.model??e,tools:oe,toolOrder:ce,toolChoice:d?.toolChoice??y,instructions:Te,messages:we,allowSystemInMessages:g,repairToolCall:C,refineToolInput:w,abortSignal:a,headers:n,includeRawChunks:ve.rawChunks,providerOptions:Ee,download:_e,output:E,callId:Ge,executeLanguageModelCallInTelemetryContext:be.executeLanguageModelCall,toolsContext:ge,experimental_sandbox:f,onLanguageModelCallStart:IR(de,be.onLanguageModelCallStart),onLanguageModelCallEnd:IR(fe,be.onLanguageModelCallEnd),onStart:async({promptMessages:e})=>{await GK({event:{callId:Ge,provider:p.provider,modelId:p.modelId,stepNumber:ke.length,instructions:Te,messages:we,tools:v,toolChoice:d?.toolChoice??y,activeTools:d?.activeTools??x,toolOrder:ce,steps:[...ke],providerOptions:Ee,runtimeContext:he,toolsContext:ge,output:E,promptMessages:e,stepTools:le,stepToolChoice:Ce},callbacks:[ue,be.onStepStart]})},_internal:{now:k},...Oe})));m();let ze=VJ({stream:Ie,tools:O,stepInputMessages:we,abortSignal:a,runtimeContext:he}),Be=be.runInTracingChannelSpan==null?void 0:e=>s(()=>be.runInTracingChannelSpan(e)),Ve=BJ({stream:ze,tools:O,callId:Ge,messages:we,abortSignal:a,timeout:ae,experimental_sandbox:f,toolsContext:ge,toolApproval:D,runtimeContext:he,toolApprovalSecret:ee,generateId:re,onToolExecutionStart:IR(pe,be.onToolExecutionStart),onToolExecutionEnd:IR(me,be.onToolExecutionEnd),executeToolInTelemetryContext:be.executeTool,runInTracingChannelSpan:Be}),Ke={...Le,body:ve.requestBody?Le?.body:void 0,messages:ve.requestMessages?FG(we):void 0};De=Ke.messages??[];let qe=[],Je=[],Ye=[],Xe,Ze=`other`,Qe,$e=!1,et=!1,tt=zK(),nt,rt=!0,it={responseTimeMs:0,effectiveOutputTokensPerSecond:0,outputTokensPerSecond:void 0,inputTokensPerSecond:void 0,effectiveTotalTokensPerSecond:0,timeToFirstOutputMs:void 0,timeBetweenOutputChunksMs:void 0},at={},ot={id:re(),timestamp:new Date,modelId:e.modelId};We.addStream(Ve.pipeThrough(new TransformStream({async transform(e,t){if(e.type===`model-call-start`){Xe=e.warnings;return}rt&&(rt=!1,t.enqueue({type:`start-step`,request:Ke,warnings:Xe??[]}));let n=e.type;switch($J(e)&&(et||h(),et=!0,j()),n){case`file`:case`custom`:case`source`:case`text-start`:case`text-end`:case`reasoning-start`:case`reasoning-end`:case`reasoning-delta`:case`reasoning-file`:case`tool-input-start`:case`tool-input-end`:case`tool-input-delta`:case`tool-approval-request`:t.enqueue(e);break;case`text-delta`:(e.text.length>0||e.providerMetadata!=null)&&t.enqueue(e);break;case`tool-call`:t.enqueue(e),qe.push(e);break;case`tool-approval-response`:t.enqueue(e),Ye.push(e);break;case`tool-result`:t.enqueue(e),e.preliminary||Je.push(e);break;case`tool-error`:t.enqueue(e),Je.push(e);break;case`tool-execution-end`:at[e.toolCallId]=e.toolExecutionMs;break;case`model-call-response-metadata`:ot={id:e.id??ot.id,timestamp:e.timestamp??ot.timestamp,modelId:e.modelId??ot.modelId};break;case`model-call-end`:$e=!0,tt=e.usage,Ze=e.finishReason,Qe=e.rawFinishReason,nt=e.providerMetadata,it=e.performance;break;case`error`:$e=!0,t.enqueue(e),Ze=`error`;break;case`raw`:ve.rawChunks&&t.enqueue(e);break;default:throw Error(`Unknown chunk type: ${n}`)}},async flush(e){if(!$e&&!et){e.enqueue({type:`error`,error:new OW({message:`No output generated. The model stream ended without a finish chunk.`})}),Se(),We.closeStream();return}let t=k()-Pe,n={type:`finish-step`,finishReason:Ze,rawFinishReason:Qe,usage:tt,performance:{stepTimeMs:t,toolExecutionMs:at,...it},providerMetadata:nt,response:{...ot,headers:Re?.headers}};e.enqueue(n);let a=BK(i,tt);await xe.promise;let o=qe.filter(e=>e.providerExecuted!==!0),s=Je.filter(e=>e.providerExecuted!==!0),c=Ye.filter(e=>e.approved===!1);for(let e of qe){if(e.providerExecuted!==!0)continue;let t=HK(O,e.toolName);t?.type===`provider`&&t.supportsDeferredResults&&(Je.some(t=>(t.type===`tool-result`||t.type===`tool-error`)&&t.toolCallId===e.toolCallId)||Ne.set(e.toolCallId,{toolName:e.toolName}))}for(let e of Je)(e.type===`tool-result`||e.type===`tool-error`)&&Ne.delete(e.toolCallId);if(Se(),(o.length>0&&o.length===s.length+c.length||Ne.size>0)&&!await zq({stopConditions:T,steps:ke}))try{await b(()=>se({currentStep:r+1,usage:a}))}catch(t){e.enqueue({type:`error`,error:t}),We.closeStream()}else e.enqueue({type:`finish`,finishReason:Ze,rawFinishReason:Qe,totalUsage:a}),We.closeStream()}})),{onError:Se,onCancel:Se})}catch(e){throw Se(),e}}await b(()=>se({currentStep:0,usage:zK()}))})().catch(async e=>{await be.onError?.call(be,{callId:Ge,error:e}),We._initialResponseMessages.reject(e),tY(We._initialResponseMessages.promise),We.addStream(new ReadableStream({start(t){t.enqueue({type:`error`,error:e}),t.close()}})),We.closeStream()})}get steps(){return this.consumeStream(),this._steps.promise}get finalStep(){return this.steps.then(e=>e.at(-1))}get content(){return this.steps.then(e=>e.flatMap(e=>e.content))}get warnings(){return this.steps.then(e=>e.flatMap(e=>e.warnings??[]))}get providerMetadata(){return this.finalStep.then(e=>e.providerMetadata)}get text(){return this.finalStep.then(e=>e.text)}get reasoningText(){return this.finalStep.then(e=>e.reasoningText)}get reasoning(){return this.finalStep.then(e=>_q(e.reasoning))}get sources(){return this.steps.then(e=>e.flatMap(e=>e.sources))}get files(){return this.steps.then(e=>e.flatMap(e=>e.files))}get toolCalls(){return this.steps.then(e=>e.flatMap(e=>e.toolCalls))}get staticToolCalls(){return this.steps.then(e=>e.flatMap(e=>e.staticToolCalls))}get dynamicToolCalls(){return this.steps.then(e=>e.flatMap(e=>e.dynamicToolCalls))}get toolResults(){return this.steps.then(e=>e.flatMap(e=>e.toolResults))}get staticToolResults(){return this.steps.then(e=>e.flatMap(e=>e.staticToolResults))}get dynamicToolResults(){return this.steps.then(e=>e.flatMap(e=>e.dynamicToolResults))}get usage(){return this.totalUsage}get request(){return this.finalStep.then(e=>e.request)}get response(){return this.finalStep.then(e=>e.response)}get responseMessages(){return Promise.all([this._initialResponseMessages.promise,this.steps]).then(([e,t])=>[...e,...t.flatMap(e=>e.response.messages)])}get totalUsage(){return this.consumeStream(),this._totalUsage.promise}get finishReason(){return this.consumeStream(),this._finishReason.promise}get rawFinishReason(){return this.consumeStream(),this._rawFinishReason.promise}teeStream(){let[e,t]=this.baseStream.tee();return this.baseStream=t,e}get textStream(){return FJ(lJ({stream:this.stream}))}get stream(){return FJ(this.teeStream().pipeThrough(new TransformStream({transform({part:e},t){t.enqueue(e)}})))}get fullStream(){return this.stream}rejectResultPromises(e){this.rejectResultPromise({delayedPromise:this._finishReason,error:e}),this.rejectResultPromise({delayedPromise:this._rawFinishReason,error:e}),this.rejectResultPromise({delayedPromise:this._totalUsage,error:e}),this.rejectResultPromise({delayedPromise:this._steps,error:e}),this.rejectResultPromise({delayedPromise:this._initialResponseMessages,error:e})}rejectResultPromise({delayedPromise:e,error:t}){e.isPending()&&(e.reject(t),tY(e.promise))}async consumeStream(e){var t;try{await LJ({stream:this.stream,onError:t=>{var n;this.rejectResultPromises(t),(n=e?.onError)==null||n.call(e,t)}})}catch(n){this.rejectResultPromises(n),(t=e?.onError)==null||t.call(e,n)}}get experimental_partialOutputStream(){return this.partialOutputStream}get partialOutputStream(){return FJ(this.teeStream().pipeThrough(new TransformStream({transform({partialOutput:e},t){e!=null&&t.enqueue(e)}})))}get elementStream(){let e=this.outputSpecification?.createElementStreamTransform();if(e==null)throw new hL({functionality:`element streams in ${this.outputSpecification?.name??`text`} mode`});return FJ(this.teeStream().pipeThrough(e))}get output(){return this.finalStep.then(e=>(this.outputSpecification??aq()).parseCompleteOutput({text:e.text},{response:e.response,usage:e.usage,finishReason:e.finishReason}))}toUIMessageStream({originalMessages:e,generateMessageId:t,onEnd:n,onFinish:r,messageMetadata:i,sendReasoning:a,sendSources:o,sendStart:s,sendFinish:c,onError:l}={}){return FJ(PJ({stream:this.stream,tools:this.tools,originalMessages:e,generateMessageId:t,onEnd:n??r,messageMetadata:i,sendReasoning:a,sendSources:o,sendStart:s,sendFinish:c,onError:l}))}pipeUIMessageStreamToResponse(e,{originalMessages:t,generateMessageId:n,onEnd:r,onFinish:i,messageMetadata:a,sendReasoning:o,sendSources:s,sendFinish:c,sendStart:l,onError:u,...d}={}){return pJ({response:e,stream:this.toUIMessageStream({originalMessages:t,generateMessageId:n,onEnd:r??i,messageMetadata:a,sendReasoning:o,sendSources:s,sendFinish:c,sendStart:l,onError:u}),...d})}pipeTextStreamToResponse(e,t){return cJ({response:e,stream:this.textStream,...t})}toUIMessageStreamResponse({originalMessages:e,generateMessageId:t,onEnd:n,onFinish:r,messageMetadata:i,sendReasoning:a,sendSources:o,sendFinish:s,sendStart:c,onError:l,...u}={}){return fJ({stream:this.toUIMessageStream({originalMessages:e,generateMessageId:t,onEnd:n??r,messageMetadata:i,sendReasoning:a,sendSources:o,sendFinish:s,sendStart:c,onError:l}),...u})}toTextStreamResponse(e){return oJ({stream:this.textStream,...e})}};async function iY(e,t){let n=[];t?.ignoreIncompleteToolCalls&&(e=e.map(e=>({...e,parts:e.parts.filter(e=>!DJ(e)||e.state===`approval-responded`||e.state===`output-available`||e.state===`output-error`||e.state===`output-denied`)})));for(let r of e)switch(r.role){case`system`:{let e=r.parts.filter(e=>e.type===`text`),t=e.reduce((e,t)=>t.providerMetadata==null?e:{...e,...t.providerMetadata},{});n.push({role:`system`,content:e.map(e=>e.text).join(``),...Object.keys(t).length>0?{providerOptions:t}:{}});break}case`user`:n.push({role:`user`,content:r.parts.map(e=>{if(bJ(e))return{type:`text`,text:e.text,...e.providerMetadata==null?{}:{providerOptions:e.providerMetadata}};if(SJ(e))return{type:`file`,mediaType:e.mediaType,filename:e.filename,data:e.providerReference==null?{type:`url`,url:new URL(e.url)}:{type:`reference`,reference:e.providerReference},...e.providerMetadata==null?{}:{providerOptions:e.providerMetadata}};if(yJ(e))return(t?.convertDataPart)?.call(t,e)}).filter(ZR)});break;case`assistant`:if(r.parts!=null){let e=[];async function i(){if(e.length===0)return;let r=[];for(let n of e)if(bJ(n))r.push({type:`text`,text:n.text,...n.providerMetadata==null?{}:{providerOptions:n.providerMetadata}});else if(xJ(n))r.push({type:`custom`,kind:n.kind,...n.providerMetadata==null?{}:{providerOptions:n.providerMetadata}});else if(SJ(n))r.push({type:`file`,mediaType:n.mediaType,filename:n.filename,data:n.providerReference==null?{type:`url`,url:new URL(n.url)}:{type:`reference`,reference:n.providerReference},...n.providerMetadata==null?{}:{providerOptions:n.providerMetadata}});else if(CJ(n))r.push({type:`reasoning-file`,data:{type:`url`,url:new URL(n.url)},mediaType:n.mediaType,providerOptions:n.providerMetadata});else if(wJ(n))r.push({type:`reasoning`,text:n.text,providerOptions:n.providerMetadata});else if(DJ(n)){let e=kJ(n);if(n.state!==`input-streaming`&&(r.push({type:`tool-call`,toolCallId:n.toolCallId,toolName:e,input:n.state===`output-error`?n.input??(`rawInput`in n?n.rawInput:void 0):n.input,providerExecuted:n.providerExecuted,...n.callProviderMetadata==null?{}:{providerOptions:n.callProviderMetadata}}),n.approval!=null&&r.push({type:`tool-approval-request`,approvalId:n.approval.id,toolCallId:n.toolCallId,isAutomatic:n.approval.isAutomatic,...n.approval.signature==null?{}:{signature:n.approval.signature}}),n.providerExecuted===!0&&n.state!==`approval-responded`&&(n.state===`output-available`||n.state===`output-error`))){let i=n.resultProviderMetadata??n.callProviderMetadata;r.push({type:`tool-result`,toolCallId:n.toolCallId,toolName:e,output:await tK({toolCallId:n.toolCallId,input:n.input,output:n.state===`output-error`?n.errorText:n.output,tool:HK(t?.tools,e),errorMode:n.state===`output-error`?`json`:`none`}),...i==null?{}:{providerOptions:i}})}}else if(yJ(n)){let e=(t?.convertDataPart)?.call(t,n);e!=null&&r.push(e)}else throw Error(`Unsupported part: ${n}`);r.length>0&&n.push({role:`assistant`,content:r});let i=e.filter(e=>DJ(e)&&(e.providerExecuted!==!0||e.approval?.approved!=null));if(i.length>0){let e=[];for(let n of i)if(n.approval?.approved!=null&&e.push({type:`tool-approval-response`,approvalId:n.approval.id,approved:n.approval.approved,reason:n.approval.reason,providerExecuted:n.providerExecuted}),n.state===`approval-responded`&&n.approval?.approved===!1&&e.push({type:`tool-result`,toolCallId:n.toolCallId,toolName:kJ(n),output:{type:`execution-denied`,reason:n.approval.reason},...n.callProviderMetadata==null?{}:{providerOptions:n.callProviderMetadata}}),n.providerExecuted!==!0)switch(n.state){case`output-denied`:e.push({type:`tool-result`,toolCallId:n.toolCallId,toolName:kJ(n),output:{type:`error-text`,value:n.approval?.reason??`Tool call execution denied.`},...n.callProviderMetadata==null?{}:{providerOptions:n.callProviderMetadata}});break;case`output-error`:case`output-available`:{let r=kJ(n);e.push({type:`tool-result`,toolCallId:n.toolCallId,toolName:r,output:await tK({toolCallId:n.toolCallId,input:n.input,output:n.state===`output-error`?n.errorText:n.output,tool:HK(t?.tools,r),errorMode:n.state===`output-error`?`text`:`none`}),...n.callProviderMetadata==null?{}:{providerOptions:n.callProviderMetadata}});break}}e.length>0&&n.push({role:`tool`,content:e})}e=[]}for(let t of r.parts)xJ(t)||bJ(t)||wJ(t)||CJ(t)||SJ(t)||DJ(t)||yJ(t)?e.push(t):t.type===`step-start`&&await i();await i();break}break;default:{let e=r.role;throw new aG({originalMessage:r,message:`Unsupported role: ${e}`})}}return n}W.record(W.string(),mK.optional()),W.record(W.string(),W.string()),LR({prefix:`call`,size:24}),LR({prefix:`call`,size:24}),LR({prefix:`aiobj`,size:24});var aY=class{constructor(){this.queue=[],this.isProcessing=!1}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.queue.length>0;)await this.queue[0](),this.queue.shift();this.isProcessing=!1}}async run(e){return new Promise((t,n)=>{this.queue.push(async()=>{try{await e(),t()}catch(e){n(e)}}),this.processQueue()})}};LR({prefix:`aiobj`,size:24}),LR({prefix:`call`,size:24});async function oY(e){if(e==null)return[];if(!globalThis.FileList||!(e instanceof globalThis.FileList))throw Error(`FileList is not supported in the current environment`);return Promise.all(Array.from(e).map(async e=>{let{name:t,type:n}=e;return{type:`file`,mediaType:n,filename:t,url:await new Promise((t,n)=>{let r=new FileReader;r.onload=e=>{t(e.target?.result)},r.onerror=e=>n(e),r.readAsDataURL(e)})}}))}var sY=class{constructor({api:e=`/api/chat`,credentials:t,headers:n,body:r,fetch:i,prepareSendMessagesRequest:a,prepareReconnectToStreamRequest:o}){this.api=e,this.credentials=t,this.headers=n,this.body=r,this.fetch=i,this.prepareSendMessagesRequest=a,this.prepareReconnectToStreamRequest=o}async sendMessages({abortSignal:e,...t}){let n=await jB(this.body),r=await jB(this.headers),i=await jB(this.credentials),a={...GR(r),...GR(t.headers)},o=await this.prepareSendMessagesRequest?.call(this,{api:this.api,id:t.chatId,messages:t.messages,body:{...n,...t.body},headers:a,credentials:i,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId}),s=o?.api??this.api,c=o?.headers===void 0?a:GR(o.headers),l=o?.body===void 0?{...n,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId}:o.body,u=o?.credentials??i,d=await(this.fetch??globalThis.fetch)(s,{method:`POST`,headers:{"Content-Type":`application/json`,...c},body:JSON.stringify(l),credentials:u,signal:e});if(!d.ok)throw Error(await d.text()??`Failed to fetch the chat response.`);if(!d.body)throw Error(`The response body is empty.`);return this.processResponseStream(d.body)}async reconnectToStream(e){let t=await jB(this.body),n=await jB(this.headers),r=await jB(this.credentials),i={...GR(n),...GR(e.headers)},a=await this.prepareReconnectToStreamRequest?.call(this,{api:this.api,id:e.chatId,body:{...t,...e.body},headers:i,credentials:r,requestMetadata:e.metadata}),o=a?.api??`${this.api}/${e.chatId}/stream`,s=a?.headers===void 0?i:GR(a.headers),c=a?.credentials??r,l=await(this.fetch??globalThis.fetch)(o,{method:`GET`,headers:s,credentials:c,signal:e.abortSignal});if(l.status===204)return null;if(!l.ok)throw Error(await l.text()??`Failed to fetch the chat response.`);if(!l.body)throw Error(`The response body is empty.`);return this.processResponseStream(l.body)}},cY=class extends sY{constructor(e={}){super(e)}processResponseStream(e){return TB({stream:e,schema:gJ}).pipeThrough(new TransformStream({async transform(e,t){if(!e.success)throw e.error;t.enqueue(e.value)}}))}},lY=class{constructor({generateId:e=RR,id:t=e(),transport:n=new cY,messageMetadataSchema:r,dataPartSchemas:i,state:a,onError:o,onToolCall:s,onFinish:c,onData:l,sendAutomaticallyWhen:u}){this.pendingMessagePreparations=new Set,this.activeResponse=void 0,this.activeResumeRequest=void 0,this.jobExecutor=new aY,this.sendMessage=async(e,t)=>{if(e==null){await this.makeRequest({trigger:`submit-message`,messageId:this.lastMessage?.id,...t});return}let n;if(`text`in e||`files`in e){let t=new AbortController;this.pendingMessagePreparations.add(t);let r;try{r=Array.isArray(e.files)?e.files:await oY(e.files)}finally{this.pendingMessagePreparations.delete(t)}if(t.signal.aborted)return;n={parts:[...r,...`text`in e&&e.text!=null?[{type:`text`,text:e.text}]:[]]}}else n=e;if(e.messageId!=null){let t=this.state.messages.findIndex(t=>t.id===e.messageId);if(t===-1)throw Error(`message with id ${e.messageId} not found`);if(this.state.messages[t].role!==`user`)throw Error(`message with id ${e.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,t+1),this.state.replaceMessage(t,{...n,id:e.messageId,role:n.role??`user`,metadata:e.metadata})}else this.state.pushMessage({...n,id:n.id??this.generateId(),role:n.role??`user`,metadata:e.metadata});await this.makeRequest({trigger:`submit-message`,messageId:e.messageId,...t})},this.regenerate=async({messageId:e,...t}={})=>{let n=e==null?this.state.messages.length-1:this.state.messages.findIndex(t=>t.id===e);if(n===-1)throw Error(`message ${e} not found`);this.state.messages=this.state.messages.slice(0,this.messages[n].role===`assistant`?n:n+1),await this.makeRequest({trigger:`regenerate-message`,messageId:e,...t})},this.resumeStream=async(e={})=>{await this.makeRequest({trigger:`resume-stream`,...e})},this.clearError=()=>{this.status===`error`&&(this.state.error=void 0,this.setStatus({status:`ready`}))},this.addToolApprovalResponse=async({id:e,approved:t,reason:n,options:r})=>this.jobExecutor.run(async()=>{let i=this.state.messages,a=i[i.length-1],o=r=>DJ(r)&&r.state===`approval-requested`&&r.approval.id===e?{...r,state:`approval-responded`,approval:{...r.approval,id:e,approved:t,reason:n}}:r;this.state.replaceMessage(i.length-1,{...a,parts:a.parts.map(o)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(o)),this.status!==`streaming`&&this.status!==`submitted`&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(e=>{e&&this.makeRequest({trigger:`submit-message`,messageId:this.lastMessage?.id,...r})})}),this.addToolOutput=async({state:e=`output-available`,toolCallId:t,output:n,errorText:r,options:i})=>this.jobExecutor.run(async()=>{let a=this.state.messages,o=a[a.length-1],s=i=>DJ(i)&&i.toolCallId===t?{...i,state:e,output:n,errorText:r}:i;this.state.replaceMessage(a.length-1,{...o,parts:o.parts.map(s)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(s)),this.status!==`streaming`&&this.status!==`submitted`&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(e=>{e&&this.makeRequest({trigger:`submit-message`,messageId:this.lastMessage?.id,...i})})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var e,t;for(let e of this.pendingMessagePreparations)e.abort();(e=this.activeResumeRequest)==null||e.abortController.abort(),(t=this.activeResponse)==null||t.abortController.abort()},this.id=t,this.transport=n,this.generateId=e,this.messageMetadataSchema=r,this.dataPartSchemas=i,this.state=a,this.onError=o,this.onToolCall=s,this.onFinish=c,this.onData=l,this.sendAutomaticallyWhen=u}get status(){return this.state.status}setStatus({status:e,error:t}){this.status!==e&&(this.state.status=e,this.state.error=t)}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}set messages(e){this.state.messages=e}async shouldSendAutomatically(){if(!this.sendAutomaticallyWhen)return!1;let e=this.sendAutomaticallyWhen({messages:this.state.messages});return e&&typeof e==`object`&&`then`in e?await e:e}async makeRequest({trigger:e,metadata:t,headers:n,body:r,messageId:i}){var a,o;let s=new AbortController,c=e===`resume-stream`?{abortController:s}:void 0;c&&((a=this.activeResumeRequest)==null||a.abortController.abort(),this.activeResumeRequest=c);let l=()=>c==null||this.activeResumeRequest===c,u=()=>{this.activeResumeRequest===c&&(this.activeResumeRequest=void 0)},d;if(e===`resume-stream`)try{let e=await this.transport.reconnectToStream({chatId:this.id,abortSignal:s.signal,metadata:t,headers:n,body:r});if(s.signal.aborted||!l()){await e?.cancel().catch(()=>{}),l()&&this.setStatus({status:`ready`}),u();return}if(e==null){this.setStatus({status:`ready`}),u();return}d=e}catch(e){if(s.signal.aborted||e.name===`AbortError`){l()&&this.setStatus({status:`ready`}),u();return}if(!l())return;this.onError&&e instanceof Error&&this.onError(e),this.setStatus({status:`error`,error:e}),u();return}this.setStatus({status:`submitted`,error:void 0});let f=this.lastMessage,p=!1,m=!1,h=!1,g;try{let a={state:AJ({lastMessage:e===`resume-stream`||e===`regenerate-message`?void 0:this.state.snapshot(f),messageId:this.generateId()}),abortController:s};g=a,a.abortController.signal.addEventListener(`abort`,()=>{p=!0}),this.activeResponse=a;let o;if(o=e===`resume-stream`?d:await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:a.abortController.signal,metadata:t,headers:n,body:r,trigger:e,messageId:i}),await LJ({stream:jJ({stream:o,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:e=>this.jobExecutor.run(()=>a.abortController.signal.aborted?Promise.resolve():e({state:a.state,write:({updateStatus:e=!0}={})=>{a.abortController.signal.aborted||(e&&this.setStatus({status:`streaming`}),a.state.message.id===this.lastMessage?.id?this.state.replaceMessage(this.state.messages.length-1,a.state.message):this.state.pushMessage(a.state.message))}})),onError:e=>{throw e}}),abortSignal:a.abortController.signal,onError:e=>{throw e}}),p)return l()&&this.setStatus({status:`ready`}),null;l()&&this.setStatus({status:`ready`})}catch(e){if(p||e.name===`AbortError`)return p=!0,l()&&this.setStatus({status:`ready`}),null;if(!l())return null;h=!0,e instanceof TypeError&&(e.message.toLowerCase().includes(`fetch`)||e.message.toLowerCase().includes(`network`))&&(m=!0),this.onError&&e instanceof Error&&this.onError(e),this.setStatus({status:`error`,error:e})}finally{try{g&&((o=this.onFinish)==null||o.call(this,{message:g.state.message,messages:this.state.messages,isAbort:p,isDisconnect:m,isError:h,finishReason:g.state.finishReason}))}finally{this.activeResponse===g&&(this.activeResponse=void 0),u()}}!h&&await this.shouldSendAutomatically()&&await this.makeRequest({trigger:`submit-message`,messageId:this.lastMessage?.id,metadata:t,headers:n,body:r})}},uY={accept:`*`,async add({file:e}){return{id:RR(),type:e.type.startsWith(`image/`)?`image`:`file`,name:e.name,file:e,contentType:e.type,content:[],status:{type:`requires-action`,reason:`composer-send`}}},async send(e){return{...e,status:{type:`complete`},content:[{type:`file`,mimeType:e.contentType??``,filename:e.name,data:await c_(e.file)}]}},async remove(){}},dY=e=>mm(e),fY=`__aui_modelContent`;function pY(e){return typeof e==`object`&&!!e&&fY in e&&Array.isArray(e[fY])}function mY(e,t){return{[fY]:t,value:e}}function hY(e){return pY(e)?{result:e.value,modelContent:e[fY]}:{result:e}}function gY(e){return e.replace(/[}\]"]+$/,``)}var _Y=100;function vY(e,t){if(!e||typeof e!=`object`)return;let n=e.callProviderMetadata,r=n&&typeof n==`object`?n.mcp:void 0,i=r&&typeof r==`object`?r.app:void 0,a;if(i&&typeof i==`object`)a=i;else{let t=e.output,n=t&&typeof t==`object`?t._meta:void 0,r=n&&typeof n==`object`?n.ui:void 0;if(r&&typeof r==`object`&&typeof r.resourceUri==`string`&&eb(r.resourceUri)){let e=r;a={resourceUri:e.resourceUri,...Array.isArray(e.visibility)?{visibility:e.visibility}:{}}}else{let e=n&&typeof n==`object`?n[`ui/resourceUri`]:void 0;if(typeof e!=`string`||!eb(e))return;a={resourceUri:e}}}if(typeof a.resourceUri!=`string`||!eb(a.resourceUri))return;let o=`${typeof a.serverId==`string`?a.serverId:``} ${a.resourceUri}`,s=t?.get(o);if(s)return t.delete(o),t.set(o,s),s;let c={resourceUri:a.resourceUri};if(typeof a.mimeType==`string`&&(c.mimeType=a.mimeType),Array.isArray(a.visibility)&&(c.visibility=a.visibility.filter(e=>e===`model`||e===`app`)),typeof a.serverId==`string`&&a.serverId.length>0&&(c.serverId=a.serverId),t){if(t.size>=_Y){let e=t.keys().next().value;e!==void 0&&t.delete(e)}t.set(o,c)}return c}function yY(e,t){if(e.approval&&typeof e.approval.id==`string`){let{id:t,approved:n,reason:r,isAutomatic:i}=e.approval;return{approval:{id:t,...typeof n==`boolean`&&{approved:n},...typeof r==`string`&&{reason:r},...i===!0&&{isAutomatic:!0}}}}return t?.type===`interrupt`?{interrupt:t.payload}:{}}var bY=e=>{if(e===`streaming`)return{type:`running`};if(e===`done`)return{type:`complete`}};function xY(e,t){if(!e.parts||e.parts.length===0)return[];let n=e.parts.filter(t=>t.type!==`step-start`&&(e.role!==`user`||t.type!==`file`)).map(n=>{if(n.type===`text`){let e=bY(n.state);return{type:`text`,text:n.text,...e==null?void 0:{status:e},...n.providerMetadata==null?void 0:{providerMetadata:n.providerMetadata}}}if(n.type===`reasoning`){let e=bY(n.state);return{type:`reasoning`,text:n.text,...e==null?void 0:{status:e},...n.providerMetadata==null?void 0:{providerMetadata:n.providerMetadata}}}if(DJ(n)){let r=kJ(n),i=n.toolCallId,a=`${e.id}:${i}`,o=n.input,s;typeof o==`object`&&o&&!Array.isArray(o)?(s=o,t.toolLastInputCache?.set(a,s)):s=t.toolLastInputCache?.get(a)??{};let c,l,u=!1;if(n.state===`output-available`){let e=hY(n.output);c=e.result,l=e.modelContent}else n.state===`output-error`?(u=!0,c={error:n.errorText}):n.state===`output-denied`&&(u=!0,c={error:n.approval?.reason||`Tool approval denied`});let d=ZE(t.toolArgsKeyOrderCache,a,s);n.state===`input-streaming`?(d=gY(d),s=Gp(d)??s):(t.toolArgsKeyOrderCache?.delete(a),(n.state===`output-available`||n.state===`output-error`||n.state===`output-denied`)&&t.toolLastInputCache?.delete(a));let f=t.toolStatuses?.[i],p=vY(n,t.mcpAppMetadataCache);return{type:`tool-call`,toolName:r,toolCallId:i,argsText:d,args:s,result:c,isError:u,...l!==void 0&&{modelContent:l},...p&&{mcp:{app:p}},...n.callProviderMetadata==null?void 0:{providerMetadata:n.callProviderMetadata},...yY(n,f)}}return n.type===`source-url`?{type:`source`,sourceType:`url`,id:n.sourceId,url:n.url,...n.title==null?void 0:{title:n.title},...n.providerMetadata==null?void 0:{providerMetadata:n.providerMetadata}}:n.type===`file`?{type:`file`,data:n.url,mimeType:n.mediaType,...n.filename!=null&&{filename:n.filename}}:n.type===`source-document`?{type:`source`,sourceType:`document`,id:n.sourceId,title:n.title,mediaType:n.mediaType,...n.filename==null?void 0:{filename:n.filename},...n.providerMetadata==null?void 0:{providerMetadata:n.providerMetadata}}:n.type.startsWith(`data-`)?{type:`data`,name:n.type.substring(5),data:n.data}:CJ(n)?{type:`file`,data:n.url,mimeType:n.mediaType}:xJ(n)?{type:`data`,name:n.kind,data:n.providerMetadata??null}:(console.warn(`Unsupported message part type: ${n.type}`),null)}).filter(Boolean),r=new Set;return n.filter(e=>{if(e.type===`tool-call`&&e.toolCallId!=null){if(r.has(e.toolCallId))return!1;r.add(e.toolCallId)}return!0})}var SY=N_((e,t)=>{let n=new Date,r=xY(e,t);switch(e.role){case`user`:return{role:`user`,id:e.id,createdAt:n,content:r,attachments:e.parts?.filter(e=>e.type===`file`).map((e,t)=>{let n=e.mediaType??`unknown/unknown`,r=n.startsWith(`image/`);return{id:t.toString(),type:r?`image`:`file`,name:e.filename??`file`,content:[r?{type:`image`,image:e.url,filename:e.filename}:{type:`file`,filename:e.filename,data:e.url,mimeType:n}],contentType:n,status:{type:`complete`}}}),metadata:e.metadata};case`system`:case`assistant`:{let i=t.messageTiming?.[e.id],a=e.role===`assistant`&&e.id===t.optimisticMessageId;return{role:e.role,id:e.id,createdAt:n,content:r,metadata:{...e.metadata,...i&&{timing:i},...a&&{isOptimistic:!0}}}}default:return console.warn(`Unsupported message role: ${e.role}`),[]}}),CY={format:`ai-sdk/v6`,encode({message:{id:e,parts:t,...n}}){return{...n,parts:t}},decode(e){return{parentId:e.parent_id,message:{id:e.id,...e.content}}},getId(e){return e.id}},wY=(e,t)=>{let n=new Set,r=t.messages.flatMap(t=>{let r=e([t.message])[0];return r?t.parentId&&!n.has(t.parentId)?[]:(n.add(r.id),[{...t,message:r}]):(console.warn(`Skipping a stored message that could not be loaded.`),[])});return{headId:t.headId&&n.has(t.headId)?t.headId:null,messages:r}},TY=e=>e.status?.type===`requires-action`&&e.status.reason===`tool-calls`,EY=e=>new Map(e.map(e=>[e.id,[...mm(e)]])),DY=(e,t,n,r,i)=>{let a=I(!1),[o,s]=Pc(0),c=zd(),l=Lc(()=>c.threadListItem.source?c.threadListItem:null,[c]),[u,d]=Pc(!1),f=I(new Set),p=I(new Set),m=I(new Set),h=I(new Map),g=I(i);L(()=>{g.current=i});let _=Ic(()=>{if(t){if(!t.withFormat)throw Error("useAISDKRuntime: ThreadHistoryAdapter is missing the required `withFormat` method.");return t.withFormat(r)}},[t,r]),v=_!=null&&!u;L(()=>{if(!_||a.current)return;let t=async()=>{try{let t=await _.load();if(t&&t.messages.length>0){for(let e of t.messages)p.current.add(r.getId(e.message));let i=wY(n,t);e.current.thread.import(i);let a=new a_;a.import(i);let o=a.getMessages();g.current(o.flatMap(mm)),f.current=new Set;for(let e of i.messages)f.current.add(e.message.id),TY(e.message)&&m.current.add(e.message.id);h.current=EY(i.messages.map(e=>e.message))}}catch(e){console.error(`Failed to load message history:`,e)}finally{d(!0)}};if(_.pin?.(),!l()?.getState().remoteId)return d(!0),c.subscribe(()=>{l()?.getState().remoteId&&s(e=>e+1)});let i=e.current.thread.getState();if(i.isRunning||i.messages.length>0){a.current=!0,d(!0);return}a.current=!0,t()},[_,n,e,l,c,o,r]);let y=I(null),b=I(null),x=I(Promise.resolve()),S=I([]),C=I(!1),w=I(0);return L(()=>{if(!_)return;let t=_,n=e.current.thread.subscribe(()=>{let n=e.current.thread.getState(),{isRunning:r}=n,a=C.current;if(C.current=r,y.current!=null){let e=n.messages.at(-1);if(e?.role===`assistant`){let t=e.content.filter(e=>e.type===`tool-call`).length;for(;w.current<t;)S.current.push(Date.now()-y.current),w.current++}}if(r){y.current??(y.current=Date.now(),S.current=[],w.current=0,t.pin?.()),b.current&&=(clearTimeout(b.current),null);return}a&&(y.current!=null&&S.current.push(Date.now()-y.current),b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{i(!1)},0))});function i(n){b.current=null;let i=e.current.thread.getState();if(!n&&i.isRunning)return;let a=S.current,o=a.length>0?a.at(-1):void 0;if(a.length===1&&o!=null){let e=i.messages.findLast(e=>e.role===`assistant`);if(e){let t=e.content.filter(e=>e.type===`tool-call`).length;if(t>0){let e=t+1,n=o/e;a.length=0;for(let t=0;t<e;t++)a.push(Math.round((t+1)*n))}}}let s=a.length>1?a.map((e,t)=>({start_ms:t===0?0:a[t-1],end_ms:e})):void 0;y.current=null,S.current=[];let c={...o==null?void 0:{durationMs:o},...s==null?void 0:{stepTimestamps:s}};x.current=x.current.then(async()=>{let e=new Set;for(let t of i.messages){let n=mm(t),r=h.current.get(t.id);(r===void 0||r.length!==n.length||n.some((e,t)=>e!==r[t]))&&e.add(t.id)}let{messages:n}=i,a=null,s=new Set,l=e=>e.length>0?r.getId(e.at(-1)):null,u=e=>e.map((t,n)=>({parentId:n===0?a:r.getId(e[n-1]),message:t}));for(let i of n){let n=mm(i),d=i.status===void 0||i.status.type===`complete`||i.status.type===`incomplete`,h=TY(i);if(!(d||h&&t.update!==void 0)){a=l(n)??a;continue}let g=f.current.has(i.id);if(g&&!e.has(i.id)){a=l(n)??a;continue}g||(f.current.add(i.id),m.current.add(i.id));let _=u(n);for(let e of _){let n=r.getId(e.message);if(!p.current.has(n))await t.append(e),p.current.add(n);else if(o!==void 0)try{await t.update?.(e,n)}catch{s.add(i.id)}}a=l(n)??a,m.current.has(i.id)&&d&&(m.current.delete(i.id),t.reportTelemetry?.(_,c))}let d=EY(i.messages);for(let e of s)d.delete(e);h.current=d}).catch(e=>{console.error(`Failed to persist message history:`,e)})}return()=>{n(),b.current&&(clearTimeout(b.current),b.current=null,i(!1))}},[_,r,e]),{isLoading:v,deleteMessage:Lc(async t=>{let n=_?.delete?.bind(_);if(!n)return;let i=e.current.thread.getState().messages,a=i.findIndex(e=>e.id===t);if(a===-1)return;let o=i.slice(0,a).flatMap(mm),s=o.at(-1)?r.getId(o.at(-1)):null,c=mm(i[a]).map(e=>{let t={parentId:s,message:e};return s=r.getId(e),t}),l=x.current.then(async()=>{await n(c),f.current.delete(t),m.current.delete(t),h.current.delete(t);for(let e of c)p.current.delete(r.getId(e.message))});x.current=l.catch(()=>{}),await l},[_,e,r])}},OY=(e,t)=>e.find(e=>e.role===`assistant`&&e.id===t),kY={getAssistantMessageId:e=>e.findLast(e=>e.role===`assistant`)?.id,getTextLength:(e,t)=>{let n=OY(e,t);if(!n?.parts)return 0;let r=0;for(let e of n.parts)e.type===`text`&&(r+=e.text.length);return r},getToolCallCount:(e,t)=>{let n=OY(e,t);if(!n?.parts)return 0;let r=0;for(let e of n.parts)DJ(e)&&r++;return r}},AY=(e,t)=>Rm(e,t,kY),jY=(e,t)=>({...e,id:e.id??RR(),role:e.role??t}),MY=[],NY=(e,t,n)=>{let[r,i]=Pc(MY),a=I(null),o=I(!1),s=I(t);s.current=t;let c=I(e);return c.current=e,L(()=>{let e=()=>{a.current?.abort(),a.current=null,i(e=>e.length===0?e:MY)},t=c.current;if(!t){e(),o.current=n;return}if(n){o.current||e(),o.current=!0;return}if(!o.current)return;o.current=!1;let r=s.current,l=r.at(-1);if(l?.role!==`assistant`||l.status?.type===`requires-action`)return;let u=new AbortController;a.current=u;let{signal:d}=u;(async()=>{try{await Gx(t.generate({messages:r,signal:d}),{signal:d,onUpdate:i})}catch{}})()},[e!=null,n]),L(()=>()=>{a.current?.abort()},[]),r},PY=(e,t={})=>{let{adapters:n,toCreateMessage:r,cancelPendingToolCallsOnSend:i=!0,onResume:a,onResumeToolCall:o,joinStrategy:s}=t,c=n?.suggestion,l=Qp(),[u,d]=Pc({}),f=I(new Map),p=I(new Map),m=I(new Map),h=I(void 0),g=Object.values(u).some(e=>e?.type===`executing`),_=e.status===`submitted`||e.status===`streaming`||g,v=AY(e.messages,_),y=e.messages.at(-1),b=_&&y?.role===`assistant`?y.id:void 0,x=SY.useThreadMessages({isRunning:_,messages:e.messages,joinStrategy:s,metadata:Ic(()=>({toolStatuses:u,messageTiming:v,toolArgsKeyOrderCache:f.current,toolLastInputCache:p.current,mcpAppMetadataCache:m.current,...b&&{optimisticMessageId:b},...e.error&&{error:e.error.message}}),[u,v,b,e.error])}),S=NY(c,x,_),[C]=Pc(()=>({get current(){return k}})),{isLoading:w,deleteMessage:T}=DY(C,n?.history??l?.history,SY.toThreadMessages,CY,t=>{e.setMessages(t)}),{id:E,messages:D,status:O,error:ee}=e,te=Ic(()=>bI.provide({chat:e,error:ee}),[E,D,O,ee]),ne=async()=>{i&&e.setMessages(e=>{let t=e.at(-1);if(t?.role!==`assistant`)return e;let n=!1,r=t.parts?.map(e=>{if(!DJ(e)||e.state===`output-available`||e.state===`output-error`)return e;n=!0;let{approval:t,...r}=e;return{...r,state:`output-error`,errorText:`User cancelled tool call by sending a new message.`}});return n?[...e.slice(0,-1),{...t,parts:r}]:e})},k=M_({isRunning:_,messages:x,unstable_enableToolInvocations:!0,setToolStatuses:d,setMessages:t=>e.setMessages(t.map(dY).filter(Boolean).flat()),onImport:t=>e.setMessages(t.map(dY).filter(Boolean).flat()),onExportExternalState:()=>{let e=C.current.thread.export(),t=[],n=new Map;for(let r of e.messages){let e=mm(r.message),i=r.parentId==null?null:n.get(r.parentId)??r.parentId;for(let n of e)t.push({parentId:i,message:n}),i=CY.getId(n);e.length>0&&n.set(r.message.id,CY.getId(e[e.length-1]))}let r={messages:t};return e.headId!=null&&(r.headId=n.get(e.headId)??e.headId),r},onLoadExternalState:e=>{let t=wY(SY.toThreadMessages,e);C.current.thread.import(t)},onCancel:async()=>{try{await e.stop()}catch(e){if(!(e instanceof Error&&e.name===`AbortError`))throw e}},onNew:async t=>{let n=(r??SI)(t);if(!(t.startRun??t.role===`user`)){e.setMessages(e=>[...e,jY(n,t.role)]);return}h.current=t.runConfig,await ne(),await e.sendMessage(n,{metadata:t.runConfig})},onEdit:async t=>{let n=(r??SI)(t);if(!(t.startRun??t.role===`user`)){e.setMessages(e=>[...xI(e,t.parentId),jY(n,t.role)]);return}h.current=t.runConfig,e.setMessages(e=>xI(e,t.parentId)),await e.sendMessage(n,{metadata:t.runConfig})},onDelete:async t=>{let n=C.current.thread.getState().messages,r=n.findIndex(e=>e.id===t);if(r===-1)return;await T(t);let i=new Set(mm(n[r]).map(e=>e.id));e.setMessages(e=>e.filter(e=>!i.has(e.id)))},onReload:async(t,n)=>{h.current=n.runConfig;let r=xI(e.messages,t);e.setMessages(r),await e.regenerate({metadata:n.runConfig})},onAddToolResult:({toolCallId:t,toolName:n,result:r,isError:i,modelContent:a})=>{let o={metadata:h.current};if(i)return Promise.resolve(e.addToolOutput({state:`output-error`,tool:n??t,toolCallId:t,errorText:typeof r==`string`?r:JSON.stringify(r),options:o}));{let i=a===void 0?r:mY(r,a);return Promise.resolve(e.addToolOutput({tool:n,toolCallId:t,output:i,options:o}))}},onRespondToToolApproval:({approvalId:t,approved:n,reason:r})=>Promise.resolve(e.addToolApprovalResponse({id:t,approved:n,...r!=null&&{reason:r},options:{metadata:h.current}})),...vS(t),...c?{suggestions:S}:{},...a&&{onResume:a},...o&&{onResumeToolCall:o},adapters:{attachments:uY,...l,...n},extras:te,isLoading:w});return k},FY=`x-resumable-stream-id`,IY=`"type":"finish"`,LY=4096,RY=`x-assistant-ui-resumable-thread-id`,zY=new Set([101,204,205,304]),BY=class extends cY{runtime;getThreadListItem;resumable;__internal_initOptions;__internal_clone(){let e=this.constructor;return new e(this.__internal_initOptions)}constructor(e){let{resumable:t,...n}=e??{},r=n.fetch,i=n.prepareReconnectToStreamRequest;super({...n,...t&&{fetch:VY(t,r),prepareReconnectToStreamRequest:UY(t,i)},prepareSendMessagesRequest:async e=>{let r=e.id,i=this.runtime?.thread.getModelContext(),a=(await(this.getThreadListItem?.()??this.runtime?.threads.mainItem)?.initialize())?.remoteId??e.id,o={...e,id:a,body:{callSettings:i?.callSettings,system:i?.system,config:i?.config,tools:Ih(i?.tools??{}),...e?.body}},s=await n.prepareSendMessagesRequest?.(o),c=t?new Headers(s?.headers??e.headers):void 0;return c?.set(RY,r),{...s,...c&&{headers:c},body:s?.body??{...o.body,id:a,messages:e.messages,trigger:e.trigger,messageId:e.messageId,metadata:e.requestMetadata}}}}),this.resumable=t,this.__internal_initOptions=e}setRuntime(e){this.runtime=e}getResumableAdapter(){return this.resumable}__internal_setGetThreadListItem(e){this.getThreadListItem=e}};function VY(e,t){let n=t?(e,n)=>t(e,n):globalThis.fetch.bind(globalThis);return async(t,r)=>{let i=new Headers(r?.headers),a=i.get(RY)??void 0;i.delete(RY);let o=await n(t,{...r,headers:i}),s=o.headers.get(FY);if(s&&e.storage.setStreamId(s,a),!o.body||zY.has(o.status))return o;let c=e.isFinishEvent??HY,l=new TextDecoder,u=``,d=new TransformStream({transform(t,n){n.enqueue(t),u+=l.decode(t,{stream:!0}),c(t,u)?((!s||e.storage.getStreamId(a)===s)&&e.storage.clear(a),u=``):u.length>LY&&(u=u.slice(-1024))}});return new Response(o.body.pipeThrough(d),{status:o.status,statusText:o.statusText,headers:o.headers})}}function HY(e,t){return t.includes(IY)}function UY(e,t){return async n=>{let r=e.storage.getStreamId(n.id);if(!r)throw Error(`AssistantChatTransport: no resumable stream id available; nothing to resume`);let i=typeof e.resumeApi==`function`?e.resumeApi(r):e.resumeApi,a=await t?.({...n,api:i}),o=new Headers(a?.headers??n.headers);return o.set(RY,n.id),{...a,headers:o,api:a?.api??i}}}var WY=(e,t)=>{let n=F(7),r=sd(),i=I(t),a=I(e),o=I(void 0),s;n[0]!==t||n[1]!==e?(s=()=>{i.current=t,a.current=e},n[0]=t,n[1]=e,n[2]=s):s=n[2],L(s);let c,l;n[3]!==r||n[4]!==e?(c=()=>{!e||!r||o.current!==r&&(o.current=r,r.addEventListener(`abort`,()=>{a.current&&i.current()},{once:!0}))},l=[r,e],n[3]=r,n[4]=e,n[5]=c,n[6]=l):(c=n[5],l=n[6]),L(c,l)},GY=c(o(((e,t)=>{function n(e,t){if(typeof e!=`function`)throw TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let n,r=0;return function(...i){clearTimeout(n);let a=Date.now(),o=t-(a-r);o<=0?(r=a,e.apply(this,i)):n=setTimeout(()=>{r=Date.now(),e.apply(this,i)},o)}}t.exports=n}))(),1),KY=(e,t,n)=>{if(!t.has(e))throw TypeError(`Cannot `+n)},qY=(e,t,n)=>(KY(e,t,`read from private field`),n?n.call(e):t.get(e)),JY=(e,t,n)=>{if(t.has(e))throw TypeError(`Cannot add the same private member more than once`);t instanceof WeakSet?t.add(e):t.set(e,n)},YY=(e,t,n,r)=>(KY(e,t,`write to private field`),r?r.call(e,n):t.set(e,n),n);function XY(e,t){return t==null?e:(0,GY.default)(e,t)}function ZY(e){return Array.isArray(e)?[...e]:typeof e==`object`&&e&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null)?{...e}:e}var QY,$Y,eX,tX,nX,rX,iX,aX,oX,sX=class{constructor(e=[]){JY(this,QY,void 0),JY(this,$Y,`ready`),JY(this,eX,void 0),JY(this,tX,new Set),JY(this,nX,new Set),JY(this,rX,new Set),this.pushMessage=e=>{YY(this,QY,qY(this,QY).concat(e)),qY(this,iX).call(this)},this.popMessage=()=>{YY(this,QY,qY(this,QY).slice(0,-1)),qY(this,iX).call(this)},this.replaceMessage=(e,t)=>{YY(this,QY,[...qY(this,QY).slice(0,e),this.snapshot(t),...qY(this,QY).slice(e+1)]),qY(this,iX).call(this)},this.snapshot=e=>{if(typeof e!=`object`||!e||!(`parts`in e)||!Array.isArray(e.parts))return e;let t=e,n={...t,parts:t.parts.map(e=>({...e}))};return`metadata`in t&&(n.metadata=ZY(t.metadata)),n},this[`~registerMessagesCallback`]=(e,t)=>{let n=t?XY(e,t):e;return qY(this,tX).add(n),()=>{qY(this,tX).delete(n)}},this[`~registerStatusCallback`]=e=>(qY(this,nX).add(e),()=>{qY(this,nX).delete(e)}),this[`~registerErrorCallback`]=e=>(qY(this,rX).add(e),()=>{qY(this,rX).delete(e)}),JY(this,iX,()=>{qY(this,tX).forEach(e=>e())}),JY(this,aX,()=>{qY(this,nX).forEach(e=>e())}),JY(this,oX,()=>{qY(this,rX).forEach(e=>e())}),YY(this,QY,e)}get status(){return qY(this,$Y)}set status(e){YY(this,$Y,e),qY(this,aX).call(this)}get error(){return qY(this,eX)}set error(e){YY(this,eX,e),qY(this,oX).call(this)}get messages(){return qY(this,QY)}set messages(e){YY(this,QY,[...e]),qY(this,iX).call(this)}};QY=new WeakMap,$Y=new WeakMap,eX=new WeakMap,tX=new WeakMap,nX=new WeakMap,rX=new WeakMap,iX=new WeakMap,aX=new WeakMap,oX=new WeakMap;var cX,lX=class extends lY{constructor({messages:e,...t}){let n=new sX(e);super({...t,state:n}),JY(this,cX,void 0),this[`~registerMessagesCallback`]=(e,t)=>qY(this,cX)[`~registerMessagesCallback`](e,t),this[`~registerStatusCallback`]=e=>qY(this,cX)[`~registerStatusCallback`](e),this[`~registerErrorCallback`]=e=>qY(this,cX)[`~registerErrorCallback`](e),YY(this,cX,n)}};cX=new WeakMap;function uX({throttle:e,experimental_throttle:t,resume:n=!1,...r}={}){let i=e??t,a=(0,_.useRef)({});`chat`in r||(a.current={onToolCall:r.onToolCall,onData:r.onData,onFinish:r.onFinish,onError:r.onError,sendAutomaticallyWhen:r.sendAutomaticallyWhen,transport:r.transport});let o,s=()=>a.current.transport??(o??=new cY),c={...r,transport:{sendMessages:e=>s().sendMessages(e),reconnectToStream:e=>s().reconnectToStream(e)},onToolCall:e=>{var t;return(t=a.current).onToolCall?.call(t,e)},onData:e=>{var t;return(t=a.current).onData?.call(t,e)},onFinish:e=>{var t;return(t=a.current).onFinish?.call(t,e)},onError:e=>{var t;return(t=a.current).onError?.call(t,e)},sendAutomaticallyWhen:e=>{var t;return(t=a.current).sendAutomaticallyWhen?.call(t,e)??!1}},l=(0,_.useRef)(`chat`in r?r.chat:new lX(c));(`chat`in r&&r.chat!==l.current||`id`in r&&r.id!=null&&l.current.id!==r.id)&&(l.current=`chat`in r?r.chat:new lX(c));let u=l.current,d=(0,_.useRef)({chat:u,messages:u.messages});d.current.chat!==u&&(d.current={chat:u,messages:u.messages});let f=(0,_.useCallback)(e=>{let t=!0,n=u[`~registerMessagesCallback`](()=>{!t||d.current.chat!==u||(d.current={chat:u,messages:u.messages},e())},i);return d.current={chat:u,messages:u.messages},()=>{t=!1,n()}},[u,i]),p=(0,_.useCallback)(()=>d.current.messages,[]),m=(0,_.useSyncExternalStore)(f,p,p),h=(0,_.useCallback)(e=>u[`~registerStatusCallback`](()=>{d.current.chat===u&&((u.status===`ready`||u.status===`error`)&&(d.current={chat:u,messages:u.messages}),e())}),[u]),g=(0,_.useCallback)(()=>u.status,[u]),v=(0,_.useSyncExternalStore)(h,g,g),y=(0,_.useSyncExternalStore)(l.current[`~registerErrorCallback`],()=>l.current.error,()=>l.current.error),b=(0,_.useCallback)(e=>{typeof e==`function`&&(e=e(l.current.messages)),l.current.messages=e},[l]);return(0,_.useEffect)(()=>{n&&l.current.resumeStream()},[n,l]),{id:l.current.id,messages:m,setMessages:b,sendMessage:l.current.sendMessage,regenerate:l.current.regenerate,clearError:l.current.clearError,stop:l.current.stop,error:y,resumeStream:l.current.resumeStream,status:v,addToolResult:l.current.addToolOutput,addToolOutput:l.current.addToolOutput,addToolApprovalResponse:l.current.addToolApprovalResponse}}var dX=e=>{let t=I(e);return L(()=>{t.current=e}),Ic(()=>new Proxy(t.current,{get(e,n){let r=t.current[n];return typeof r==`function`?r.bind(t.current):r}}),[])},fX=e=>{if(e instanceof BY)return e.getResumableAdapter();let t=e.getResumableAdapter;if(typeof t==`function`)return t.call(e)},pX=()=>null,mX=new WeakMap,hX=e=>{if(!e)return new Set;let t=mX.get(e);return t||(t=new Set,mX.set(e,t)),t},gX=e=>{let{adapters:t,transport:n,toCreateMessage:r,isDisabled:i,isSendDisabled:a,unstable_capabilities:o,suggestions:s,onResume:c,onResumeToolCall:l,onResumeError:u,joinStrategy:d,...f}=e??{};return{adapters:t,transport:n,toCreateMessage:r,onResume:c,onResumeToolCall:l,onResumeError:u,joinStrategy:d,chatInit:f}},_X=(e,t)=>{let{adapters:n,transport:r,toCreateMessage:i,onResume:a,onResumeToolCall:o,onResumeError:s,joinStrategy:c,chatInit:l}=gX(e),{id:u,isMainThread:d,getThreadListItem:f,stopOnClientDestroy:p=!1,chat:m}=t,h=Ic(()=>new BY,[]),g=r??h,_=dX(g),v=uX({...l,id:u,transport:_,...m!==void 0&&{chat:m}});WY(p,()=>{v.stop().catch(()=>{})});let y=PY(v,{adapters:n,...vS(e??{}),...i&&{toCreateMessage:i},...a&&{onResume:a},...o&&{onResumeToolCall:o},...c&&{joinStrategy:c}});g instanceof BY&&(g.setRuntime(y),g.__internal_setGetThreadListItem(f));let b=Lc(e=>y.thread.subscribe(e),[y]),x=Lc(()=>y.thread.getState().isLoading,[y]),S=Bc(b,x,x),C=Ic(()=>fX(g)?.storage,[g]),w=Bc(Lc(e=>d?C?.subscribe?.(e,u)??(()=>{}):()=>{},[u,d,C]),Lc(()=>d?C?.getStreamId(u)??null:null,[u,d,C]),pX),T=v.status===`submitted`||v.status===`streaming`,E=Ic(()=>hX(C),[C]),D=I(s);return L(()=>{D.current=s}),L(()=>{if(!(!w||E.has(w))){if(T){E.add(w);return}S||(E.add(w),v.resumeStream().catch(e=>{console.warn(`[assistant-ui] resumable: resume failed`,e);try{D.current?.(e)}catch(e){console.error(`[assistant-ui] resumable: onResumeError callback failed`,e)}finally{C?.getStreamId(u)===w&&C.clear(u)}}))}},[v,u,T,S,w,C,E]),y},vX=e=>{let t=F(6),n=R(bX),r=R(xX),i=zd(),a;t[0]===i?a=t[1]:(a=()=>i.threadListItem.source?i.threadListItem:void 0,t[0]=i,t[1]=a);let o;return t[2]!==n||t[3]!==r||t[4]!==a?(o={id:n,isMainThread:r,getThreadListItem:a},t[2]=n,t[3]=r,t[4]=a,t[5]=o):o=t[5],_X(e,o)},yX=({cloud:e,onThreadIdChange:t,...n}={})=>ov({runtimeHook:function(){return vX(n)},adapter:Ay({cloud:e}),allowNesting:!0,onThreadIdChange:t});function bX(e){return e.threadListItem.id}function xX(e){return e.threads.mainThreadId===e.threadListItem.id}var SX=`vercel.ai.error`,CX=Symbol.for(SX),wX,TX,EX=class e extends (TX=Error,wX=CX,TX){constructor({name:e,message:t,cause:n}){super(t),this[wX]=!0,this.name=e,this.cause=n}static isInstance(t){return e.hasMarker(t,SX)}static hasMarker(e,t){let n=Symbol.for(t);return typeof e==`object`&&!!e&&n in e&&typeof e[n]==`boolean`&&e[n]===!0}},DX=`AI_APICallError`,OX=`vercel.ai.error.${DX}`,kX=Symbol.for(OX),AX,jX,MX=class extends (jX=EX,AX=kX,jX){constructor({message:e,url:t,requestBodyValues:n,statusCode:r,responseHeaders:i,responseBody:a,cause:o,isRetryable:s=r!=null&&(r===408||r===409||r===429||r>=500),data:c}){super({name:DX,message:e,cause:o}),this[AX]=!0,this.url=t,this.requestBodyValues=n,this.statusCode=r,this.responseHeaders=i,this.responseBody=a,this.isRetryable=s,this.data=c}static isInstance(e){return EX.hasMarker(e,OX)}},NX=`AI_EmptyResponseBodyError`,PX=`vercel.ai.error.${NX}`,FX=Symbol.for(PX),IX,LX,RX=class extends (LX=EX,IX=FX,LX){constructor({message:e=`Empty response body`}={}){super({name:NX,message:e}),this[IX]=!0}static isInstance(e){return EX.hasMarker(e,PX)}};function zX(e){return e==null?`unknown error`:typeof e==`string`?e:e instanceof Error?e.message:JSON.stringify(e)}var BX=`AI_InvalidArgumentError`,VX=`vercel.ai.error.${BX}`,HX=Symbol.for(VX),UX,WX,GX=class extends (WX=EX,UX=HX,WX){constructor({message:e,cause:t,argument:n}){super({name:BX,message:e,cause:t}),this[UX]=!0,this.argument=n}static isInstance(e){return EX.hasMarker(e,VX)}},KX=`AI_JSONParseError`,qX=`vercel.ai.error.${KX}`,JX=Symbol.for(qX),YX,XX,ZX=class extends (XX=EX,YX=JX,XX){constructor({text:e,cause:t}){super({name:KX,message:`JSON parsing failed: Text: ${e}.
|
|
178
|
-
Error message: ${zX(t)}`,cause:t}),this[YX]=!0,this.text=e}static isInstance(e){return EX.hasMarker(e,qX)}},QX=`AI_LoadAPIKeyError`,$X=`vercel.ai.error.${QX}`,eZ=Symbol.for($X),tZ,nZ,rZ=class extends (nZ=EX,tZ=eZ,nZ){constructor({message:e}){super({name:QX,message:e}),this[tZ]=!0}static isInstance(e){return EX.hasMarker(e,$X)}},iZ=`AI_TypeValidationError`,aZ=`vercel.ai.error.${iZ}`,oZ=Symbol.for(aZ),sZ,cZ,lZ=class e extends (cZ=EX,sZ=oZ,cZ){constructor({value:e,cause:t}){super({name:iZ,message:`Type validation failed: Value: ${JSON.stringify(e)}.
|
|
179
|
-
Error message: ${zX(t)}`,cause:t}),this[sZ]=!0,this.value=e}static isInstance(e){return EX.hasMarker(e,aZ)}static wrap({value:t,cause:n}){return e.isInstance(n)&&n.value===t?n:new e({value:t,cause:n})}},uZ;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(uZ||={});var dZ;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(dZ||={});var G=uZ.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),fZ=e=>{switch(typeof e){case`undefined`:return G.undefined;case`string`:return G.string;case`number`:return Number.isNaN(e)?G.nan:G.number;case`boolean`:return G.boolean;case`function`:return G.function;case`bigint`:return G.bigint;case`symbol`:return G.symbol;case`object`:return Array.isArray(e)?G.array:e===null?G.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?G.promise:typeof Map<`u`&&e instanceof Map?G.map:typeof Set<`u`&&e instanceof Set?G.set:typeof Date<`u`&&e instanceof Date?G.date:G.object;default:return G.unknown}},K=uZ.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]),pZ=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,uZ.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};pZ.create=e=>new pZ(e);var mZ=(e,t)=>{let n;switch(e.code){case K.invalid_type:n=e.received===G.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case K.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,uZ.jsonStringifyReplacer)}`;break;case K.unrecognized_keys:n=`Unrecognized key(s) in object: ${uZ.joinValues(e.keys,`, `)}`;break;case K.invalid_union:n=`Invalid input`;break;case K.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${uZ.joinValues(e.options)}`;break;case K.invalid_enum_value:n=`Invalid enum value. Expected ${uZ.joinValues(e.options)}, received '${e.received}'`;break;case K.invalid_arguments:n=`Invalid function arguments`;break;case K.invalid_return_type:n=`Invalid function return type`;break;case K.invalid_date:n=`Invalid date`;break;case K.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:uZ.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case K.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case K.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case K.custom:n=`Invalid input`;break;case K.invalid_intersection_types:n=`Intersection results could not be merged`;break;case K.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case K.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,uZ.assertNever(e)}return{message:n}},hZ=mZ;function gZ(){return hZ}var _Z=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function q(e,t){let n=gZ(),r=_Z({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===mZ?void 0:mZ].filter(e=>!!e)});e.common.issues.push(r)}var vZ=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return yZ;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return yZ;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}},yZ=Object.freeze({status:`aborted`}),bZ=e=>({status:`dirty`,value:e}),xZ=e=>({status:`valid`,value:e}),SZ=e=>e.status===`aborted`,CZ=e=>e.status===`dirty`,wZ=e=>e.status===`valid`,TZ=e=>typeof Promise<`u`&&e instanceof Promise,J;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(J||={});var EZ=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},DZ=(e,t)=>{if(wZ(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){if(this._error)return this._error;let t=new pZ(e.common.issues);return this._error=t,this._error}}};function OZ(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var kZ=class{get description(){return this._def.description}_getType(e){return fZ(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:fZ(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new vZ,ctx:{common:e.parent.common,data:e.data,parsedType:fZ(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(TZ(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:fZ(e)};return DZ(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:fZ(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return wZ(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>wZ(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:fZ(e)},r=this._parse({data:e,path:n.path,parent:n});return DZ(n,await(TZ(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:K.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new MQ({schema:this,typeName:VQ.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return NQ.create(this,this._def)}nullable(){return PQ.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return pQ.create(this)}promise(){return jQ.create(this,this._def)}or(e){return gQ.create([this,e],this._def)}and(e){return bQ.create(this,e,this._def)}transform(e){return new MQ({...OZ(this._def),schema:this,typeName:VQ.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new FQ({...OZ(this._def),innerType:this,defaultValue:t,typeName:VQ.ZodDefault})}brand(){return new RQ({typeName:VQ.ZodBranded,type:this,...OZ(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new IQ({...OZ(this._def),innerType:this,catchValue:t,typeName:VQ.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return zQ.create(this,e)}readonly(){return BQ.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},AZ=/^c[^\s-]{8,}$/i,jZ=/^[0-9a-z]+$/,MZ=/^[0-9A-HJKMNP-TV-Z]{26}$/i,NZ=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,PZ=/^[a-z0-9_-]{21}$/i,FZ=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,IZ=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,LZ=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,RZ=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,zZ,BZ=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,VZ=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,HZ=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,UZ=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,WZ=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,GZ=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,KZ=`((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`,qZ=RegExp(`^${KZ}$`);function JZ(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function YZ(e){return RegExp(`^${JZ(e)}$`)}function XZ(e){let t=`${KZ}T${JZ(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function ZZ(e,t){return!!((t===`v4`||!t)&&BZ.test(e)||(t===`v6`||!t)&&HZ.test(e))}function QZ(e,t){if(!FZ.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function $Z(e,t){return!!((t===`v4`||!t)&&VZ.test(e)||(t===`v6`||!t)&&UZ.test(e))}var eQ=class e extends kZ{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==G.string){let t=this._getOrReturnCtx(e);return q(t,{code:K.invalid_type,expected:G.string,received:t.parsedType}),yZ}let t=new vZ,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),q(n,{code:K.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),q(n,{code:K.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?q(n,{code:K.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&q(n,{code:K.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)LZ.test(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{validation:`email`,code:K.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)zZ||=new RegExp(RZ,`u`),zZ.test(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{validation:`emoji`,code:K.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)NZ.test(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{validation:`uuid`,code:K.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)PZ.test(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{validation:`nanoid`,code:K.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)AZ.test(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{validation:`cuid`,code:K.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)jZ.test(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{validation:`cuid2`,code:K.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)MZ.test(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{validation:`ulid`,code:K.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),q(n,{validation:`url`,code:K.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{validation:`regex`,code:K.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),q(n,{code:K.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),q(n,{code:K.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),q(n,{code:K.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?XZ(r).test(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{code:K.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?qZ.test(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{code:K.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?YZ(r).test(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{code:K.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?IZ.test(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{validation:`duration`,code:K.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?ZZ(e.data,r.version)||(n=this._getOrReturnCtx(e,n),q(n,{validation:`ip`,code:K.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?QZ(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),q(n,{validation:`jwt`,code:K.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?$Z(e.data,r.version)||(n=this._getOrReturnCtx(e,n),q(n,{validation:`cidr`,code:K.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?WZ.test(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{validation:`base64`,code:K.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?GZ.test(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{validation:`base64url`,code:K.invalid_string,message:r.message}),t.dirty()):uZ.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:K.invalid_string,...J.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...J.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...J.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...J.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...J.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...J.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...J.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...J.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...J.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...J.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...J.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...J.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...J.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...J.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...J.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...J.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...J.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...J.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...J.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...J.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...J.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...J.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...J.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...J.errToObj(t)})}nonempty(e){return this.min(1,J.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};eQ.create=e=>new eQ({checks:[],typeName:VQ.ZodString,coerce:e?.coerce??!1,...OZ(e)});function tQ(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var nQ=class e extends kZ{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==G.number){let t=this._getOrReturnCtx(e);return q(t,{code:K.invalid_type,expected:G.number,received:t.parsedType}),yZ}let t,n=new vZ;for(let r of this._def.checks)r.kind===`int`?uZ.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),q(t,{code:K.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),q(t,{code:K.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),q(t,{code:K.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?tQ(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),q(t,{code:K.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),q(t,{code:K.not_finite,message:r.message}),n.dirty()):uZ.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,J.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,J.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,J.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,J.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:J.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:J.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:J.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:J.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:J.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:J.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:J.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:J.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:J.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:J.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&uZ.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};nQ.create=e=>new nQ({checks:[],typeName:VQ.ZodNumber,coerce:e?.coerce||!1,...OZ(e)});var rQ=class e extends kZ{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==G.bigint)return this._getInvalidInput(e);let t,n=new vZ;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),q(t,{code:K.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),q(t,{code:K.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),q(t,{code:K.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):uZ.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return q(t,{code:K.invalid_type,expected:G.bigint,received:t.parsedType}),yZ}gte(e,t){return this.setLimit(`min`,e,!0,J.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,J.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,J.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,J.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:J.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:J.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:J.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:J.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:J.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:J.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};rQ.create=e=>new rQ({checks:[],typeName:VQ.ZodBigInt,coerce:e?.coerce??!1,...OZ(e)});var iQ=class extends kZ{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==G.boolean){let t=this._getOrReturnCtx(e);return q(t,{code:K.invalid_type,expected:G.boolean,received:t.parsedType}),yZ}return xZ(e.data)}};iQ.create=e=>new iQ({typeName:VQ.ZodBoolean,coerce:e?.coerce||!1,...OZ(e)});var aQ=class e extends kZ{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==G.date){let t=this._getOrReturnCtx(e);return q(t,{code:K.invalid_type,expected:G.date,received:t.parsedType}),yZ}if(Number.isNaN(e.data.getTime()))return q(this._getOrReturnCtx(e),{code:K.invalid_date}),yZ;let t=new vZ,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),q(n,{code:K.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),q(n,{code:K.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):uZ.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:J.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:J.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};aQ.create=e=>new aQ({checks:[],coerce:e?.coerce||!1,typeName:VQ.ZodDate,...OZ(e)});var oQ=class extends kZ{_parse(e){if(this._getType(e)!==G.symbol){let t=this._getOrReturnCtx(e);return q(t,{code:K.invalid_type,expected:G.symbol,received:t.parsedType}),yZ}return xZ(e.data)}};oQ.create=e=>new oQ({typeName:VQ.ZodSymbol,...OZ(e)});var sQ=class extends kZ{_parse(e){if(this._getType(e)!==G.undefined){let t=this._getOrReturnCtx(e);return q(t,{code:K.invalid_type,expected:G.undefined,received:t.parsedType}),yZ}return xZ(e.data)}};sQ.create=e=>new sQ({typeName:VQ.ZodUndefined,...OZ(e)});var cQ=class extends kZ{_parse(e){if(this._getType(e)!==G.null){let t=this._getOrReturnCtx(e);return q(t,{code:K.invalid_type,expected:G.null,received:t.parsedType}),yZ}return xZ(e.data)}};cQ.create=e=>new cQ({typeName:VQ.ZodNull,...OZ(e)});var lQ=class extends kZ{constructor(){super(...arguments),this._any=!0}_parse(e){return xZ(e.data)}};lQ.create=e=>new lQ({typeName:VQ.ZodAny,...OZ(e)});var uQ=class extends kZ{constructor(){super(...arguments),this._unknown=!0}_parse(e){return xZ(e.data)}};uQ.create=e=>new uQ({typeName:VQ.ZodUnknown,...OZ(e)});var dQ=class extends kZ{_parse(e){let t=this._getOrReturnCtx(e);return q(t,{code:K.invalid_type,expected:G.never,received:t.parsedType}),yZ}};dQ.create=e=>new dQ({typeName:VQ.ZodNever,...OZ(e)});var fQ=class extends kZ{_parse(e){if(this._getType(e)!==G.undefined){let t=this._getOrReturnCtx(e);return q(t,{code:K.invalid_type,expected:G.void,received:t.parsedType}),yZ}return xZ(e.data)}};fQ.create=e=>new fQ({typeName:VQ.ZodVoid,...OZ(e)});var pQ=class e extends kZ{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==G.array)return q(t,{code:K.invalid_type,expected:G.array,received:t.parsedType}),yZ;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(q(t,{code:e?K.too_big:K.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(q(t,{code:K.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(q(t,{code:K.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new EZ(t,e,t.path,n)))).then(e=>vZ.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new EZ(t,e,t.path,n)));return vZ.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:J.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:J.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:J.toString(n)}})}nonempty(e){return this.min(1,e)}};pQ.create=(e,t)=>new pQ({type:e,minLength:null,maxLength:null,exactLength:null,typeName:VQ.ZodArray,...OZ(t)});function mQ(e){if(e instanceof hQ){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=NQ.create(mQ(r))}return new hQ({...e._def,shape:()=>t})}return e instanceof pQ?new pQ({...e._def,type:mQ(e.element)}):e instanceof NQ?NQ.create(mQ(e.unwrap())):e instanceof PQ?PQ.create(mQ(e.unwrap())):e instanceof xQ?xQ.create(e.items.map(e=>mQ(e))):e}var hQ=class e extends kZ{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=uZ.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==G.object){let t=this._getOrReturnCtx(e);return q(t,{code:K.invalid_type,expected:G.object,received:t.parsedType}),yZ}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof dQ&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new EZ(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof dQ){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(q(n,{code:K.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new EZ(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>vZ.mergeObjectSync(t,e)):vZ.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return J.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:J.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:VQ.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of uZ.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of uZ.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return mQ(this)}partial(t){let n={};for(let e of uZ.objectKeys(this.shape)){let r=this.shape[e];n[e]=t&&!t[e]?r:r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of uZ.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof NQ;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return OQ(uZ.objectKeys(this.shape))}};hQ.create=(e,t)=>new hQ({shape:()=>e,unknownKeys:`strip`,catchall:dQ.create(),typeName:VQ.ZodObject,...OZ(t)}),hQ.strictCreate=(e,t)=>new hQ({shape:()=>e,unknownKeys:`strict`,catchall:dQ.create(),typeName:VQ.ZodObject,...OZ(t)}),hQ.lazycreate=(e,t)=>new hQ({shape:e,unknownKeys:`strip`,catchall:dQ.create(),typeName:VQ.ZodObject,...OZ(t)});var gQ=class extends kZ{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new pZ(e.ctx.common.issues));return q(t,{code:K.invalid_union,unionErrors:n}),yZ}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new pZ(e));return q(t,{code:K.invalid_union,unionErrors:i}),yZ}}get options(){return this._def.options}};gQ.create=(e,t)=>new gQ({options:e,typeName:VQ.ZodUnion,...OZ(t)});var _Q=e=>e instanceof EQ?_Q(e.schema):e instanceof MQ?_Q(e.innerType()):e instanceof DQ?[e.value]:e instanceof kQ?e.options:e instanceof AQ?uZ.objectValues(e.enum):e instanceof FQ?_Q(e._def.innerType):e instanceof sQ?[void 0]:e instanceof cQ?[null]:e instanceof NQ?[void 0,..._Q(e.unwrap())]:e instanceof PQ?[null,..._Q(e.unwrap())]:e instanceof RQ||e instanceof BQ?_Q(e.unwrap()):e instanceof IQ?_Q(e._def.innerType):[],vQ=class e extends kZ{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.object)return q(t,{code:K.invalid_type,expected:G.object,received:t.parsedType}),yZ;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(q(t,{code:K.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),yZ)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=_Q(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:VQ.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...OZ(r)})}};function yQ(e,t){let n=fZ(e),r=fZ(t);if(e===t)return{valid:!0,data:e};if(n===G.object&&r===G.object){let n=uZ.objectKeys(t),r=uZ.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=yQ(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}if(n===G.array&&r===G.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=yQ(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}return n===G.date&&r===G.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var bQ=class extends kZ{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(SZ(e)||SZ(r))return yZ;let i=yQ(e.value,r.value);return i.valid?((CZ(e)||CZ(r))&&t.dirty(),{status:t.value,value:i.data}):(q(n,{code:K.invalid_intersection_types}),yZ)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};bQ.create=(e,t,n)=>new bQ({left:e,right:t,typeName:VQ.ZodIntersection,...OZ(n)});var xQ=class e extends kZ{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.array)return q(n,{code:K.invalid_type,expected:G.array,received:n.parsedType}),yZ;if(n.data.length<this._def.items.length)return q(n,{code:K.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),yZ;!this._def.rest&&n.data.length>this._def.items.length&&(q(n,{code:K.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new EZ(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>vZ.mergeArray(t,e)):vZ.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};xQ.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new xQ({items:e,typeName:VQ.ZodTuple,rest:null,...OZ(t)})};var SQ=class e extends kZ{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.object)return q(n,{code:K.invalid_type,expected:G.object,received:n.parsedType}),yZ;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new EZ(n,e,n.path,e)),value:a._parse(new EZ(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?vZ.mergeObjectAsync(t,r):vZ.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof kZ?new e({keyType:t,valueType:n,typeName:VQ.ZodRecord,...OZ(r)}):new e({keyType:eQ.create(),valueType:t,typeName:VQ.ZodRecord,...OZ(n)})}},CQ=class extends kZ{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.map)return q(n,{code:K.invalid_type,expected:G.map,received:n.parsedType}),yZ;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new EZ(n,e,n.path,[a,`key`])),value:i._parse(new EZ(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return yZ;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return yZ;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};CQ.create=(e,t,n)=>new CQ({valueType:t,keyType:e,typeName:VQ.ZodMap,...OZ(n)});var wQ=class e extends kZ{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==G.set)return q(n,{code:K.invalid_type,expected:G.set,received:n.parsedType}),yZ;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(q(n,{code:K.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(q(n,{code:K.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return yZ;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new EZ(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:J.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:J.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};wQ.create=(e,t)=>new wQ({valueType:e,minSize:null,maxSize:null,typeName:VQ.ZodSet,...OZ(t)});var TQ=class e extends kZ{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==G.function)return q(t,{code:K.invalid_type,expected:G.function,received:t.parsedType}),yZ;function n(e,n){return _Z({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,gZ(),mZ].filter(e=>!!e),issueData:{code:K.invalid_arguments,argumentsError:n}})}function r(e,n){return _Z({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,gZ(),mZ].filter(e=>!!e),issueData:{code:K.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof jQ){let e=this;return xZ(async function(...t){let o=new pZ([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}{let e=this;return xZ(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new pZ([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new pZ([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:xQ.create(t).rest(uQ.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||xQ.create([]).rest(uQ.create()),returns:n||uQ.create(),typeName:VQ.ZodFunction,...OZ(r)})}},EQ=class extends kZ{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};EQ.create=(e,t)=>new EQ({getter:e,typeName:VQ.ZodLazy,...OZ(t)});var DQ=class extends kZ{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return q(t,{received:t.data,code:K.invalid_literal,expected:this._def.value}),yZ}return{status:`valid`,value:e.data}}get value(){return this._def.value}};DQ.create=(e,t)=>new DQ({value:e,typeName:VQ.ZodLiteral,...OZ(t)});function OQ(e,t){return new kQ({values:e,typeName:VQ.ZodEnum,...OZ(t)})}var kQ=class e extends kZ{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return q(t,{expected:uZ.joinValues(n),received:t.parsedType,code:K.invalid_type}),yZ}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return q(t,{received:t.data,code:K.invalid_enum_value,options:n}),yZ}return xZ(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};kQ.create=OQ;var AQ=class extends kZ{_parse(e){let t=uZ.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==G.string&&n.parsedType!==G.number){let e=uZ.objectValues(t);return q(n,{expected:uZ.joinValues(e),received:n.parsedType,code:K.invalid_type}),yZ}if(this._cache||=new Set(uZ.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=uZ.objectValues(t);return q(n,{received:n.data,code:K.invalid_enum_value,options:e}),yZ}return xZ(e.data)}get enum(){return this._def.values}};AQ.create=(e,t)=>new AQ({values:e,typeName:VQ.ZodNativeEnum,...OZ(t)});var jQ=class extends kZ{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==G.promise&&t.common.async===!1?(q(t,{code:K.invalid_type,expected:G.promise,received:t.parsedType}),yZ):xZ((t.parsedType===G.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};jQ.create=(e,t)=>new jQ({type:e,typeName:VQ.ZodPromise,...OZ(t)});var MQ=class extends kZ{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===VQ.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{q(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return yZ;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?yZ:r.status===`dirty`||t.value===`dirty`?bZ(r.value):r});{if(t.value===`aborted`)return yZ;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?yZ:r.status===`dirty`||t.value===`dirty`?bZ(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?yZ:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?yZ:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`){if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!wZ(e))return yZ;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>wZ(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):yZ)}uZ.assertNever(r)}};MQ.create=(e,t,n)=>new MQ({schema:e,typeName:VQ.ZodEffects,effect:t,...OZ(n)}),MQ.createWithPreprocess=(e,t,n)=>new MQ({schema:t,effect:{type:`preprocess`,transform:e},typeName:VQ.ZodEffects,...OZ(n)});var NQ=class extends kZ{_parse(e){return this._getType(e)===G.undefined?xZ(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};NQ.create=(e,t)=>new NQ({innerType:e,typeName:VQ.ZodOptional,...OZ(t)});var PQ=class extends kZ{_parse(e){return this._getType(e)===G.null?xZ(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};PQ.create=(e,t)=>new PQ({innerType:e,typeName:VQ.ZodNullable,...OZ(t)});var FQ=class extends kZ{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===G.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};FQ.create=(e,t)=>new FQ({innerType:e,typeName:VQ.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...OZ(t)});var IQ=class extends kZ{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return TZ(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new pZ(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new pZ(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};IQ.create=(e,t)=>new IQ({innerType:e,typeName:VQ.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...OZ(t)});var LQ=class extends kZ{_parse(e){if(this._getType(e)!==G.nan){let t=this._getOrReturnCtx(e);return q(t,{code:K.invalid_type,expected:G.nan,received:t.parsedType}),yZ}return{status:`valid`,value:e.data}}};LQ.create=e=>new LQ({typeName:VQ.ZodNaN,...OZ(e)});var RQ=class extends kZ{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},zQ=class e extends kZ{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?yZ:e.status===`dirty`?(t.dirty(),bZ(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?yZ:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:VQ.ZodPipeline})}},BQ=class extends kZ{_parse(e){let t=this._def.innerType._parse(e),n=e=>(wZ(e)&&(e.value=Object.freeze(e.value)),e);return TZ(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};BQ.create=(e,t)=>new BQ({innerType:e,typeName:VQ.ZodReadonly,...OZ(t)}),hQ.lazycreate;var VQ;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(VQ||={});var Y=eQ.create,HQ=nQ.create;LQ.create,rQ.create,iQ.create,aQ.create,oQ.create,sQ.create,cQ.create,lQ.create;var UQ=uQ.create;dQ.create,fQ.create;var WQ=pQ.create,GQ=hQ.create;hQ.strictCreate,gQ.create;var KQ=vQ.create;bQ.create,xQ.create;var qQ=SQ.create;CQ.create,wQ.create,TQ.create,EQ.create;var JQ=DQ.create;kQ.create,AQ.create,jQ.create,MQ.create,NQ.create;var YQ=PQ.create;MQ.createWithPreprocess,zQ.create;function XQ(...e){return e.reduce((e,t)=>({...e,...t??{}}),{})}function ZQ(e){return Object.fromEntries([...e.headers])}var QQ=`AI_DownloadError`,$Q=`vercel.ai.error.${QQ}`,e$=Symbol.for($Q),t$,n$,r$=class extends (n$=EX,t$=e$,n$){constructor({url:e,statusCode:t,statusText:n,cause:r,message:i=r==null?`Failed to download ${e}: ${t} ${n}`:`Failed to download ${e}: ${r}`}){super({name:QQ,message:i,cause:r}),this[t$]=!0,this.url=e,this.statusCode=t,this.statusText=n}static isInstance(e){return EX.hasMarker(e,$Q)}};async function i$(e){try{await e.body?.cancel()}catch{}}var a$=globalThis.fetch;o$(a$);function o$(e){let t=Function.prototype.toString.call(e);return t.includes(`internal/deps/undici`)||t.includes(`lazy loading of undici`)}var s$=2147483648;async function c$({response:e,url:t,maxBytes:n=s$}){let r=e.headers.get(`content-length`);if(r!=null){let i=parseInt(r,10);if(!isNaN(i)&&i>n)throw await i$(e),new r$({url:t,message:`Download of ${t} exceeded maximum size of ${n} bytes (Content-Length: ${i}).`})}let i=e.body;if(i==null)return new Uint8Array;let a=i.getReader(),o=[],s=0;try{for(;;){let{done:e,value:r}=await a.read();if(e)break;if(s+=r.length,s>n)throw new r$({url:t,message:`Download of ${t} exceeded maximum size of ${n} bytes.`});o.push(r)}}finally{try{await a.cancel()}catch{}finally{a.releaseLock()}}let c=new Uint8Array(s),l=0;for(let e of o)c.set(e,l),l+=e.length;return c}var l$=(({prefix:e,size:t=16,alphabet:n=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,separator:r=`-`}={})=>{let i=()=>{let e=n.length,r=Array(t);for(let i=0;i<t;i++)r[i]=n[Math.random()*e|0];return r.join(``)};if(e==null)return i;if(n.includes(r))throw new GX({argument:`separator`,message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${e}${r}${i()}`})();function u$(e){return(e instanceof Error||e instanceof DOMException)&&(e.name===`AbortError`||e.name===`ResponseAborted`||e.name===`TimeoutError`)}var d$=[`fetch failed`,`failed to fetch`];function f$({error:e,url:t,requestBodyValues:n}){if(u$(e))return e;if(e instanceof TypeError&&d$.includes(e.message.toLowerCase())){let r=e.cause;if(r!=null)return new MX({message:`Cannot connect to API: ${r.message}`,cause:r,url:t,requestBodyValues:n,isRetryable:!0})}return e}function p$(e=globalThis){return e.window?`runtime/browser`:e.navigator?.userAgent?`runtime/${e.navigator.userAgent.toLowerCase()}`:e.process?.versions?.node?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?`runtime/vercel-edge`:`runtime/unknown`}function m$(e){if(e==null)return{};let t={};if(e instanceof Headers)e.forEach((e,n)=>{t[n.toLowerCase()]=e});else{Array.isArray(e)||(e=Object.entries(e));for(let[n,r]of e)r!=null&&(t[n.toLowerCase()]=r)}return t}function h$(e,...t){let n=new Headers(m$(e)),r=n.get(`user-agent`)||``;return n.set(`user-agent`,[r,...t].filter(Boolean).join(` `)),Object.fromEntries(n.entries())}var g$=`3.0.32`;function _$({apiKey:e,environmentVariableName:t,apiKeyParameterName:n=`apiKey`,description:r}){if(typeof e==`string`)return e;if(e!=null)throw new rZ({message:`${r} API key must be a string.`});if(typeof process>`u`)throw new rZ({message:`${r} API key is missing. Pass it using the '${n}' parameter. Environment variables is not supported in this environment.`});if(e={}[t],e==null)throw new rZ({message:`${r} API key is missing. Pass it using the '${n}' parameter or the ${t} environment variable.`});if(typeof e!=`string`)throw new rZ({message:`${r} API key must be a string. The value of the ${t} environment variable is not a string.`});return e}var v$=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,y$=/"(?: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 b$(e){let t=JSON.parse(e);return typeof t!=`object`||!t||v$.test(e)===!1&&y$.test(e)===!1?t:x$(t)}function x$(e){let t=[e];for(;t.length;){let e=t;t=[];for(let n of e){if(Object.prototype.hasOwnProperty.call(n,`__proto__`)||Object.prototype.hasOwnProperty.call(n,`constructor`)&&n.constructor!==null&&typeof n.constructor==`object`&&Object.prototype.hasOwnProperty.call(n.constructor,`prototype`))throw SyntaxError(`Object contains forbidden prototype property`);for(let e in n){let r=n[e];r&&typeof r==`object`&&t.push(r)}}}return e}function S$(e){let{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return b$(e)}try{return b$(e)}finally{Error.stackTraceLimit=t}}var C$=Symbol.for(`vercel.ai.validator`);function w$(e){return{[C$]:!0,validate:e}}function T$(e){return typeof e==`object`&&!!e&&C$ in e&&e[C$]===!0&&`validate`in e}function E$(e){return T$(e)?e:`~standard`in e?D$(e):e()}function D$(e){return w$(async t=>{let n=await e[`~standard`].validate(t);return n.issues==null?{success:!0,value:n.value}:{success:!1,error:new lZ({value:t,cause:n.issues})}})}async function O$({value:e,schema:t}){let n=await k$({value:e,schema:t});if(!n.success)throw lZ.wrap({value:e,cause:n.error});return n.value}async function k$({value:e,schema:t}){let n=E$(t);try{if(n.validate==null)return{success:!0,value:e,rawValue:e};let t=await n.validate(e);return t.success?{success:!0,value:t.value,rawValue:e}:{success:!1,error:lZ.wrap({value:e,cause:t.error}),rawValue:e}}catch(t){return{success:!1,error:lZ.wrap({value:e,cause:t}),rawValue:e}}}async function A$({text:e,schema:t}){try{let n=S$(e);return t==null?n:O$({value:n,schema:t})}catch(t){throw ZX.isInstance(t)||lZ.isInstance(t)?t:new ZX({text:e,cause:t})}}async function j$({text:e,schema:t}){try{let n=S$(e);return t==null?{success:!0,value:n,rawValue:n}:await k$({value:n,schema:t})}catch(t){return{success:!1,error:ZX.isInstance(t)?t:new ZX({text:e,cause:t}),rawValue:void 0}}}function M$({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new wL).pipeThrough(new TransformStream({async transform({data:e},n){e!==`[DONE]`&&n.enqueue(await j$({text:e,schema:t}))}}))}var N$=()=>globalThis.fetch,P$=async({url:e,headers:t,body:n,failedResponseHandler:r,successfulResponseHandler:i,abortSignal:a,fetch:o})=>F$({url:e,headers:{"Content-Type":`application/json`,...t},body:{content:JSON.stringify(n),values:n},failedResponseHandler:r,successfulResponseHandler:i,abortSignal:a,fetch:o}),F$=async({url:e,headers:t={},body:n,successfulResponseHandler:r,failedResponseHandler:i,abortSignal:a,fetch:o=N$()})=>{try{let s=await o(e,{method:`POST`,headers:h$(t,`ai-sdk/provider-utils/${g$}`,p$()),body:n.content,signal:a}),c=ZQ(s);if(!s.ok){let t;try{t=await i({response:s,url:e,requestBodyValues:n.values})}catch(t){throw u$(t)||MX.isInstance(t)?t:new MX({message:`Failed to process error response`,cause:t,statusCode:s.status,url:e,responseHeaders:c,requestBodyValues:n.values})}throw t.value}try{return await r({response:s,url:e,requestBodyValues:n.values})}catch(t){throw t instanceof Error&&(u$(t)||MX.isInstance(t))?t:new MX({message:`Failed to process successful response`,cause:t,statusCode:s.status,url:e,responseHeaders:c,requestBodyValues:n.values})}}catch(t){throw f$({error:t,url:e,requestBodyValues:n.values})}},I$=new TextDecoder;async function L$({response:e,url:t}){return I$.decode(await c$({response:e,url:t}))}var R$=({errorSchema:e,errorToMessage:t,isRetryable:n})=>async({response:r,url:i,requestBodyValues:a})=>{let o=await L$({response:r,url:i}),s=ZQ(r);if(o.trim()===``)return{responseHeaders:s,value:new MX({message:r.statusText,url:i,requestBodyValues:a,statusCode:r.status,responseHeaders:s,responseBody:o,isRetryable:n?.(r)})};try{let c=await A$({text:o,schema:e});return{responseHeaders:s,value:new MX({message:t(c),url:i,requestBodyValues:a,statusCode:r.status,responseHeaders:s,responseBody:o,data:c,isRetryable:n?.(r,c)})}}catch{return{responseHeaders:s,value:new MX({message:r.statusText,url:i,requestBodyValues:a,statusCode:r.status,responseHeaders:s,responseBody:o,isRetryable:n?.(r)})}}},z$=e=>async({response:t})=>{let n=ZQ(t);if(t.body==null)throw new RX({});return{responseHeaders:n,value:M$({stream:t.body,schema:e})}},B$=e=>async({response:t,url:n,requestBodyValues:r})=>{let i=await L$({response:t,url:n}),a=await j$({text:i,schema:e}),o=ZQ(t);if(!a.success)throw new MX({message:`Invalid JSON response`,cause:a.error,statusCode:t.status,responseHeaders:o,responseBody:i,url:n,requestBodyValues:r});return{responseHeaders:o,value:a.value,rawValue:a.rawValue}},{btoa:V$,atob:H$}=globalThis,U$={debug:(e,t)=>console.debug(`[dify-ai-provider] ${e}`,t??``),info:(e,t)=>console.log(`[dify-ai-provider] ${e}`,t??``),warn:(e,t)=>console.warn(`[dify-ai-provider] ${e}`,t??``),error:(e,t)=>console.error(`[dify-ai-provider] ${e}`,t??``)},W$=GQ({id:Y(),answer:Y(),task_id:Y(),conversation_id:Y(),message_id:Y(),metadata:GQ({usage:GQ({completion_tokens:HQ(),prompt_tokens:HQ(),total_tokens:HQ()})})}),G$=GQ({code:Y(),message:Y(),status:HQ()}),K$=GQ({event:Y(),conversation_id:Y().optional(),message_id:Y().optional(),task_id:Y().optional(),created_at:HQ().optional()}).passthrough(),q$=K$.extend({event:JQ(`workflow_started`),workflow_run_id:Y(),data:GQ({id:Y(),workflow_id:Y(),created_at:HQ()}).passthrough()}),J$=K$.extend({event:JQ(`workflow_finished`),workflow_run_id:Y(),task_id:Y().optional(),data:GQ({id:Y(),workflow_id:Y(),outputs:qQ(UQ()).optional(),status:Y().optional(),elapsed_time:HQ().optional(),total_tokens:HQ().optional(),total_steps:Y().optional(),created_at:HQ().optional(),finished_at:HQ().optional()}).passthrough()}),Y$=K$.extend({event:JQ(`node_started`),workflow_run_id:Y(),data:GQ({id:Y(),node_id:Y(),node_type:Y()}).passthrough()}),X$=K$.extend({event:JQ(`node_finished`),workflow_run_id:Y(),data:GQ({id:Y(),node_id:Y(),node_type:Y()}).passthrough()}),Z$=K$.extend({event:JQ(`message`),id:Y().optional(),answer:Y(),from_variable_selector:WQ(Y()).optional()}),Q$=K$.extend({event:JQ(`message_end`),id:Y().optional(),metadata:GQ({usage:GQ({prompt_tokens:HQ().optional(),completion_tokens:HQ().optional(),total_tokens:HQ().optional(),prompt_unit_price:Y().optional(),prompt_price_unit:Y().optional(),prompt_price:Y().optional(),completion_unit_price:Y().optional(),completion_price_unit:Y().optional(),completion_price:Y().optional(),total_price:Y().optional(),currency:Y().optional(),latency:HQ().optional()}).passthrough(),retriever_resources:WQ(UQ()).optional()}).passthrough(),files:YQ(WQ(UQ())).optional()}),$$=K$.extend({event:JQ(`tts_message`),audio:Y()}),e1=K$.extend({event:JQ(`tts_message_end`),audio:Y()}),t1=K$.extend({event:JQ(`agent_message`),answer:Y()}),n1=KQ(`event`,[q$,J$,Y$,X$,Z$,Q$,$$,e1,K$.extend({event:JQ(`agent_thought`),id:Y(),position:HQ(),thought:Y(),observation:Y(),tool:Y(),tool_labels:qQ(Y(),Y()).optional(),tool_input:Y(),message_files:WQ(UQ())}),t1,K$.extend({event:JQ(`message_replace`),answer:Y()}),K$.extend({event:JQ(`message_file`),id:Y(),type:Y(),belongs_to:Y(),url:Y()}),K$.extend({event:JQ(`ping`)}),K$.extend({event:JQ(`error`),status:HQ().optional(),code:Y().optional(),message:Y().optional()})]).or(K$),r1=class{constructor(){this.state=`text`,this.buffer=``,this.accumulated=``,this.hasStarted=!1,this.closed=!1,this.textAccumulated=``,this.inString=!1,this.escape=!1}feed(e){let t=[];this.accumulated+=e;for(let n=0;n<e.length;n++){let r=e[n];if(!this.hasStarted){if(r.trim()===``)continue;this.hasStarted=!0}if(this.inString){this.escape?(this.escape=!1,t.push({type:`text`,content:r})):r===`\\`?(this.escape=!0,t.push({type:`text`,content:r})):(r===`"`&&(this.inString=!1),t.push({type:`text`,content:r}));continue}if(r===`"`){this.inString=!0,t.push({type:`text`,content:r});continue}switch(this.state){case`text`:r===`<`&&!this.closed?(this.state=`maybe-open`,this.buffer=`<`):t.push({type:`text`,content:r});break;case`maybe-open`:this.buffer+=r,`<think>`.startsWith(this.buffer)?this.buffer===`<think>`&&(this.state=`reasoning`,this.buffer=``):(t.push({type:`text`,content:this.buffer}),this.buffer=``,this.state=`text`);break;case`reasoning`:r===`<`?(this.state=`maybe-close`,this.buffer=`<`):t.push({type:`reasoning`,content:r});break;case`maybe-close`:this.buffer+=r,`</think>`.startsWith(this.buffer)?this.buffer===`</think>`&&(this.state=`text`,this.buffer=``,this.closed=!0):(t.push({type:`reasoning`,content:this.buffer}),this.buffer=``,this.state=`reasoning`)}}let n=[];for(let e of t){let t=n[n.length-1];t&&t.type===e.type?t.content+=e.content:n.push({...e})}for(let e of n)e.type===`text`&&(this.textAccumulated+=e.content);return n}flush(){if(!this.buffer)return[];let e=this.state===`maybe-close`?`reasoning`:`text`,t=[{type:e,content:this.buffer}];return e===`text`&&(this.textAccumulated+=this.buffer),this.buffer=``,t}reset(e){this.accumulated=``,this.buffer=``,this.state=`text`,this.closed=!1,this.hasStarted=!1,this.inString=!1,this.escape=!1,this.feed(e)}getTextWithoutThink(){return this.textAccumulated.trim()}};function i1(e,t,n){let r=[],i=e;if(!t.length)return{toolCalls:r,cleanText:i};let a=t.map(e=>e.toLowerCase()),o=[],s=0,c=!1,l=!1,u=-1;for(let i=0;i<e.length;i++){let d=e[i];if(l){l=!1;continue}if(d===`\\`){l=!0;continue}if(d===`"`){c=!c;continue}if(!c){if(d===`{`)s===0&&(u=i),s++;else if(d===`}`&&(s--,s<0&&(s=0),s===0&&u!==-1)){let s=e.substring(u,i+1);try{let e=JSON.parse(s);if(e&&typeof e==`object`&&`name`in e&&`arguments`in e){let i=String(e.name).toLowerCase(),c=a.indexOf(i);c!==-1&&(r.push({id:n(),name:t[c],input:JSON.stringify(e.arguments)}),o.push(s))}}catch{}u=-1}}}for(let e of o)i=i.replace(e,``);return{toolCalls:r,cleanText:i.trim()}}function a1(e){if(!e)return`"..."`;let t=e.type;if(t===`array`)return`[${e.items?a1(e.items):`"..."`}]`;if(t===`object`){let t=e.properties;return t?`{${Object.entries(t).slice(0,3).map(([e,t])=>`"${e}": ${a1(t)}`).join(`, `)}}`:`{}`}return t===`number`||t===`integer`?`0`:t===`boolean`?`true`:`"..."`}var o1={question:`Ask the user a question`,bash:`Execute a bash command`,read:`Read a file`,glob:`Find files by pattern`,grep:`Search file contents with regex`,edit:`Edit a file with string replacement`,write:`Write/create a file`,task:`Launch a sub-agent for complex tasks`,webfetch:`Fetch content from a URL`,todowrite:`Create/manage a task list`,skill:`Load a specialized skill`};function s1(e,t){return o1[e]?o1[e]:t?t.replace(/[\r\n]+/g,` `).split(/[.!?。]/)[0].trim().substring(0,60):e}function c1(e){if(!e?.length)return{prompt:``,toolNames:[]};let t=e.filter(e=>e.type===`function`).map(e=>({name:e.name,description:e.description,parameters:e.inputSchema}));if(!t.length)return{prompt:``,toolNames:[]};let n=t.map(e=>e.name);return{prompt:`
|
|
180
|
-
|
|
181
|
-
# Tools
|
|
182
|
-
Call tools with JSON format:
|
|
183
|
-
|
|
184
|
-
${t.map(e=>{let t=e.parameters,n=t?.properties?Object.entries(t.properties).map(([e,t])=>`"${e}": ${a1(t)}`).join(`, `):``,r=s1(e.name,e.description);return`- ${e.name}: ${r}
|
|
185
|
-
{"name": "${e.name}", "arguments": {${n}}}`}).join(`
|
|
186
|
-
`)}`,toolNames:n}}async function l1(e,t,n,r,i,a,o){try{let s;if(typeof e==`string`){let n=Buffer.from(e,`base64`);s=new Blob([n],{type:t})}else s=new Blob([e],{type:t});let c=new FormData;c.append(`file`,s,n),c.append(`user`,r);let{"content-type":l,"Content-Type":u,...d}=a(),f=await fetch(`${i}/files/upload`,{method:`POST`,headers:{...d},body:c});if(!f.ok){let e=await f.text().catch(()=>``);o?.error(`Dify file upload failed`,{status:f.status,statusText:f.statusText,body:e});return}return(await f.json()).id}catch(e){o?.error(`Dify file upload error`,{error:String(e)});return}}async function u1(e,t,n,r,i){let a=[];for(let o of e)if(Array.isArray(o.content))for(let e of o.content){if(!e||typeof e!=`object`||e.type!==`file`)continue;let o=e.mediaType||e.mimeType||``;if(!o)continue;let s,c=e.filename||`file.${o.split(`/`)[1]||`bin`}`;if(typeof e.data==`string`){let t=e.data.match(/^data:[^;]+;base64,(.+)$/);s=t?t[1]:e.data}else e.data instanceof Uint8Array&&(s=e.data);if(s){let e=l1(s,o,c,t,n,r,i).then(e=>{if(e)return{type:o.startsWith(`image/`)?`image`:`document`,transfer_method:`local_file`,upload_file_id:e};i?.warn(`Dify file upload skipped, attachment will be missing`,{filename:c,mimeType:o})});a.push(e)}}return(await Promise.all(a)).filter(e=>e!==void 0)}function d1(e){if(!e)return``;let t=e.trim(),n=t.match(/<env>([\s\S]*?)<\/env>/),r=t.match(/<directories>([\s\S]*?)<\/directories>/),i=t.match(/^You are\b[^.]*\./m);if(n||i||r){let e=[];return i&&e.push(i[0]),n&&e.push(`<env>${n[1]}</env>`),r&&e.push(`<directories>${r[1]}</directories>`),e.join(`
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
`)}return t}function f1(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function p1(e,t){for(let n of t){let t=e[n];if(typeof t==`string`&&t)return t}}function m1(e,t){return Array.isArray(e)?e.map((e,n)=>{let r=f1(e)?e:{},i=p1(r,[`segment_id`,`document_id`,`id`])??`retriever-resource-${n+1}`,a=p1(r,[`document_name`,`title`,`dataset_name`,`segment_id`,`id`])??`Retriever resource ${n+1}`,o=p1(r,[`document_name`,`filename`]);return{type:`source`,sourceType:`document`,id:i,mediaType:`text/plain`,title:a,...o?{filename:o}:{},providerMetadata:{difyWorkflowData:{...t,retrieverResource:e}}}}):[]}var h1=class{constructor(e,t,n){this.settings=t,this.specificationVersion=`v2`,this.supportedUrls={},this.modelId=e,this.config=n,this.generateId=l$,this.chatMessagesEndpoint=`${this.config.baseURL}/chat-messages`,this.logger=t.logger===!1?void 0:t.logger??U$,this.settings.responseMode||(this.settings.responseMode=`streaming`)}createErrorHandler(){return R$({errorSchema:G$,errorToMessage:e=>{var t;return(t=this.logger)==null||t.error(`Dify API error`,e),`Dify API error: ${e.message}`}})}get provider(){return this.config.provider}async doGenerate(e){var t,n;let{abortSignal:r}=e,{body:i,toolNames:a,requestHeaders:o}=await this.getRequestBody(e),s={...i,response_mode:`blocking`};this.settings.logMessages&&((t=this.logger)==null||t.info(``,{body:s}));let{responseHeaders:c,value:l}=await P$({url:this.chatMessagesEndpoint,headers:XQ(this.config.headers(),o??e.headers),body:s,abortSignal:r,failedResponseHandler:this.createErrorHandler(),successfulResponseHandler:B$(W$),fetch:this.config.fetch}),u=l;this.settings.logMessages&&((n=this.logger)==null||n.info(``,{answer:u.answer,conversation_id:u.conversation_id}));let d=[];if(u.answer){let{toolCalls:e,cleanText:t}=i1(u.answer,a,this.generateId);t&&d.push({type:`text`,text:t});for(let t of e)d.push({type:`tool-call`,toolCallId:t.id,toolName:t.name,input:t.input})}return{content:d,finishReason:d.some(e=>e.type===`tool-call`)?`tool-calls`:`stop`,usage:{inputTokens:u.metadata.usage.prompt_tokens,outputTokens:u.metadata.usage.completion_tokens,totalTokens:u.metadata.usage.total_tokens},warnings:[],providerMetadata:{difyWorkflowData:{conversationId:u.conversation_id,messageId:u.message_id}},request:{body:JSON.stringify(s)},response:{id:u.id,timestamp:new Date,headers:c}}}async doStream(e){var t,n;this.settings.logMessages&&((t=this.logger)==null||t.info(``,{options:e}));let{abortSignal:r}=e,{body:i,toolNames:a,requestHeaders:o}=await this.getRequestBody(e),s={...i,response_mode:`streaming`};this.settings.logMessages&&((n=this.logger)==null||n.info(``,{body:s}));let{responseHeaders:c,value:l}=await P$({url:this.chatMessagesEndpoint,headers:XQ(this.config.headers(),o??e.headers),body:s,failedResponseHandler:this.createErrorHandler(),successfulResponseHandler:z$(n1),abortSignal:r,fetch:this.config.fetch}),u,d,f,p=!1,m=!1,h=new r1,g=this.generateId,_=this.logger,v=this.settings.logMessages;function y(){let e={};return u&&(e.conversationId=u),d&&(e.messageId=d),f&&(e.taskId=f),e}function b(){let e=y();return Object.keys(e).length?{providerMetadata:{difyWorkflowData:e}}:{}}function x(e,t){for(let n of e)n.type===`reasoning`?(p&&=(t.enqueue({type:`text-end`,id:`0`,...b()}),!1),m||(m=!0,t.enqueue({type:`reasoning-start`,id:`r0`,...b()})),t.enqueue({type:`reasoning-delta`,id:`r0`,delta:n.content,...b()})):n.content&&(m&&=(t.enqueue({type:`reasoning-end`,id:`r0`,...b()}),!1),p||(p=!0,t.enqueue({type:`text-start`,id:`0`,...b()})),t.enqueue({type:`text-delta`,id:`0`,delta:n.content,...b()}))}return{stream:l.pipeThrough(new TransformStream({transform(e,t){if(!e.success){_?.error(`Dify stream parse error`,{error:String(e.error)}),t.enqueue({type:`error`,error:e.error});return}let n=e.value;switch(v&&_?.info(``,{data:n}),n.conversation_id&&(u=n.conversation_id),n.message_id&&(d=n.message_id),n.task_id&&(f=n.task_id),n.event){case`workflow_finished`:case`message_end`:{let e=0,r=0,i=0;if(n.event===`workflow_finished`){let t=n.data||{};e=0,r=t.total_tokens??0,i=t.total_tokens??0}else{let t=n.metadata?.usage||{};e=t.prompt_tokens??0,r=t.completion_tokens??0,i=t.total_tokens??0}let{toolCalls:o}=i1(h.getTextWithoutThink(),a,g),s=o.length>0;if(v&&_?.info(``,{toolCalls:o}),x(h.flush(),t),m&&=(t.enqueue({type:`reasoning-end`,id:`r0`,...b()}),!1),p?(t.enqueue({type:`text-end`,id:`0`,...b()}),p=!1):s||(t.enqueue({type:`text-start`,id:`0`,...b()}),t.enqueue({type:`text-end`,id:`0`,...b()})),n.event===`message_end`)for(let e of m1(n.metadata?.retriever_resources,y()))t.enqueue(e);for(let e of o)t.enqueue({type:`tool-input-start`,id:e.id,toolName:e.name,...b()}),t.enqueue({type:`tool-input-delta`,id:e.id,delta:e.input,...b()}),t.enqueue({type:`tool-input-end`,id:e.id,...b()}),t.enqueue({type:`tool-call`,toolCallId:e.id,toolName:e.name,input:e.input,...b()});t.enqueue({type:`finish`,finishReason:s?`tool-calls`:`stop`,...b(),usage:{inputTokens:e,outputTokens:r,totalTokens:i}});break}case`message`:case`agent_message`:`answer`in n&&typeof n.answer==`string`&&n.answer&&(x(h.feed(n.answer),t),`id`in n&&typeof n.id==`string`&&t.enqueue({type:`response-metadata`,id:n.id}));break;case`agent_thought`:break;case`message_replace`:`answer`in n&&typeof n.answer==`string`&&n.answer&&(h.reset(n.answer),p&&=(t.enqueue({type:`text-end`,id:`0`,...b()}),!1),t.enqueue({type:`text-start`,id:`0`,...b()}),t.enqueue({type:`text-delta`,id:`0`,delta:n.answer,...b()}),p=!0);break;case`message_file`:case`ping`:break;case`error`:{let e=n,r=e.message??e.msg??`Unknown Dify error`,i=e.code??e.status??``;_?.error(`Dify stream error`,{code:i,message:r}),t.enqueue({type:`error`,error:Error(`Dify error${i?` (${i})`:``}: ${r}`)});break}}}})),request:{body:JSON.stringify(s)},response:{headers:c}}}async getRequestBody(e){var t,n;let r=e,i=e.prompt??r.messages;if(!i||!i.length)throw(t=this.logger)==null||t.error(`No messages provided`,{prompt:e.prompt}),new MX({message:`No messages provided`,url:this.chatMessagesEndpoint,requestBodyValues:e});let a=this.findConversationId(e.headers,i),o=this.buildQuery(i,a);if(!o)throw(n=this.logger)==null||n.error(`No user message found`,{messageCount:i.length,roles:i.map(e=>e.role)}),new MX({message:`No user message found`,url:this.chatMessagesEndpoint,requestBodyValues:{messageCount:i.length}});let s=e.headers?.[`user-id`]??`you_should_pass_user-id`,{"chat-id":c,"user-id":l,...u}=e.headers||{},d=await u1(i,s,this.config.baseURL,this.config.headers,this.logger),f=this.extractSystemPrompt(i),p=this.settings.injectToolsPrompt!==!1,{prompt:m,toolNames:h}=c1(e.tools),g=p?m:``,_=!a,v=[_?f:``,o,_?g:``].filter(Boolean).join(`
|
|
191
|
-
|
|
192
|
-
`);return{body:{inputs:this.settings.inputs||{},query:v,response_mode:this.settings.responseMode,conversation_id:a,user:s,...d.length?{files:d}:{}},toolNames:h,requestHeaders:u}}findConversationId(e,t){if(e?.[`chat-id`])return e[`chat-id`];for(let e=t.length-1;e>=0;e--){let n=t[e];if(Array.isArray(n.content))for(let e of n.content){let t=e?.providerMetadata?.difyWorkflowData||e?.callProviderMetadata?.difyWorkflowData;if(t?.conversationId)return t.conversationId}}}buildQuery(e,t){let n=0;if(t){n=e.length;for(let t=e.length-1;t>=0;t--){let r=e[t];if(r.role===`tool`){n=t;continue}if(r.role===`user`){n=t;break}break}}return e.slice(n).filter(e=>e.role===`user`||e.role===`tool`||!t&&e.role===`assistant`).map(e=>e.role===`tool`?this.extractToolResult(e):this.extractTextFromMessage(e)).filter(Boolean).join(`
|
|
193
|
-
|
|
194
|
-
`)}extractSystemPrompt(e){let t=e.find(e=>e.role===`system`);return d1(t?this.extractTextFromMessage(t):``)}extractTextFromMessage(e){return typeof e.content==`string`?e.content:Array.isArray(e.content)?e.content.map(e=>typeof e==`string`?e:e?.type===`text`&&e.text?e.text:``).filter(Boolean).join(` `):``}extractToolResult(e){let t=e.content;if(!Array.isArray(t))return``;let n=[];for(let e of t)if(e?.type===`tool-result`){let t=e.toolName||`tool`,r=e.output??e.result??e.content??e.text,i=r!==void 0&&typeof r==`object`&&r&&`value`in r?r.value:r,a=i===void 0?`[completed]`:typeof i==`string`?i:JSON.stringify(i);n.push(`[${t} result]: ${a}`)}return n.join(`
|
|
195
|
-
`)}};function g1(e={}){let t=(t,n={})=>new h1(t,n,{provider:`dify.chat`,baseURL:e.baseURL||`https://api.dify.ai/v1`,headers:()=>({Authorization:`Bearer ${_$({apiKey:n.apiKey,environmentVariableName:`DIFY_API_KEY`,description:`Dify API Key`})}`,"Content-Type":`application/json`,...e.headers})}),n=function(e,n){if(new.target)throw Error(`The model factory function cannot be called with the new keyword.`);return t(e,n)};return n.chat=t,n}g1();var _1=sD.BASE_URL,v1=g1({baseURL:_1}),y1=e=>new ReadableStream({start(t){t.enqueue({type:`text-start`,id:`0`}),t.enqueue({type:`text-delta`,id:`0`,delta:e}),t.enqueue({type:`text-end`,id:`0`}),t.close()}}),b1=YP(`[dify-chat-transport]`),x1=()=>{let e=pI(),t=JP();return{...e,round_type:t?`tool_result`:`new_query`,...t?{}:{tools:nF},...t?{action_result:t}:{}}},S1=class{async sendMessages(e){let{messages:t,abortSignal:n,headers:r}=e;try{let e=await iY(t);if(b1.log(`[debug] input messages roles:`,t.map(e=>e.role)),b1.log(`[debug] modelMessages count:`,e.length),b1.log(`[debug] modelMessages roles:`,e.map(e=>e.role)),b1.log(`[debug] modelMessages[-1].role:`,e[e.length-1]?.role),e.length>0){let t=e[e.length-1];t.role===`assistant`&&Array.isArray(t.content)&&b1.log(`[debug] last assistant content types:`,t.content.map(e=>typeof e==`object`&&e&&`type`in e?e.type:typeof e))}let i=e.map(e=>e.role===`assistant`&&Array.isArray(e.content)?{...e,content:e.content.filter(e=>!(typeof e==`object`&&`type`in e&&e.type===`tool-call`))}:e),a=[...i].reverse().find(e=>e.role===`assistant`);if(a&&Array.isArray(a.content)&&a.content.some(e=>typeof e==`object`&&!!e&&`type`in e&&e.type===`tool-result`)){let e=a.content.filter(e=>typeof e==`object`&&!!e&&`type`in e&&e.type===`tool-result`);e.length>0&&i.push({role:`tool`,content:e.map(e=>{let t=e,n=t.output??t.result;return{type:`tool-result`,toolCallId:t.toolCallId,toolName:t.toolName,output:typeof n==`string`?{type:`text`,value:n}:{type:`text`,value:JSON.stringify(n??``)}}})})}i=i.filter(e=>e.role!==`assistant`);let o=0;for(let e=i.length-1;e>=0;e--)if(i[e].role===`user`){o=e;break}i=i.slice(o),b1.log(`[debug] messages count:`,i.length),b1.log(`[debug] messages roles:`,i.map(e=>e.role)),b1.log(`[debug] conversationId:`,zP());let s={click_element:{description:rI.click_element.description,inputSchema:rI.click_element.parameters},navigate_to:{description:rI.navigate_to.description,inputSchema:rI.navigate_to.parameters},fill_input:{description:rI.fill_input.description,inputSchema:rI.fill_input.parameters},scroll_to:{description:rI.scroll_to.description,inputSchema:rI.scroll_to.parameters},highlight_element:{description:rI.highlight_element.description,inputSchema:rI.highlight_element.parameters}},c=eY({model:v1(`dify-chat`,{apiKey:sD.API_KEY,responseMode:`streaming`,injectToolsPrompt:!1,inputs:x1()}),messages:i,tools:s,abortSignal:n,headers:{"chat-id":zP()??``,"user-id":VP(),...r}}),l=c.stream.pipeThrough(new TransformStream({transform(e,t){e.type===`tool-input-start`?b1.log(`[stream] tool-input-start:`,JSON.stringify({id:e.id,toolName:e.toolName,input:e.input??e.args})):e.type===`tool-input-delta`?b1.log(`[stream] tool-input-delta:`,JSON.stringify({id:e.id,delta:e.delta??e.inputDelta})):e.type===`tool-input-end`?b1.log(`[stream] tool-input-end:`,JSON.stringify({id:e.id})):e.type===`tool-call`?b1.log(`[stream] tool-call:`,JSON.stringify({toolName:e.toolName,toolCallId:e.toolCallId,input:e.input})):e.type===`text-delta`?b1.log(`[stream] text-delta:`,JSON.stringify({delta:e.delta??e.textDelta})):e.type===`finish-step`?b1.log(`[stream] finish-step`):b1.log(`[stream] chunk type:`,e.type),t.enqueue(e)}})),u=new Set,d=new Set,f=new Set,p=!1,m=PJ({stream:l.pipeThrough(new TransformStream({transform(e,t){if(e.type===`finish-step`){if(p)return;p=!0,t.enqueue(e);return}if(e.type===`tool-input-start`){if(u.has(e.toolName)){d.add(e.id),b1.log(`[dedup] duplicate tool-input-start skipped:`,e.toolName);return}u.add(e.toolName),t.enqueue(e);return}if(!(e.type===`tool-input-delta`&&d.has(e.id))&&!(e.type===`tool-input-end`&&d.has(e.id))){if(e.type===`tool-call`){let t=`${e.toolName}:${JSON.stringify(e.input)}`;if(f.has(t))return;f.add(t)}t.enqueue(e)}}}))});return c.finalStep.then(e=>{let t=e.providerMetadata?.difyWorkflowData?.conversationId;t&&(BP(t),WP(t,``),b1.log(`[conversationId] saved:`,t))},e=>{b1.error(`[conversationId] extraction failed:`,e)}),m}catch(e){let t=e instanceof Error?e.message:`Request failed, please try again later`;return b1.error(`sendMessages error:`,t),y1(`[Error] ${t}`)}}async reconnectToStream(){return null}},C1=()=>{let e=(0,_.useMemo)(()=>_u({tools:ef({toolkit:rI})}),[]);return{runtime:yX({transport:(0,_.useMemo)(()=>new S1,[]),sendAutomaticallyWhen:()=>qP()}),config:e,clearConversation:(0,_.useCallback)(()=>{HP()},[])}},w1=GN([HN({type:tP(`start`),messageId:V().optional()}),HN({type:tP(`text-start`),id:V()}),HN({type:tP(`text-delta`),id:V(),delta:V()}),HN({type:tP(`text-end`),id:V()}),HN({type:tP(`reasoning-start`),id:V()}),HN({type:tP(`reasoning-delta`),id:V(),delta:V()}),HN({type:tP(`reasoning-end`),id:V()}),HN({type:tP(`tool-input-start`),toolCallId:V(),toolName:V()}),HN({type:tP(`tool-input-delta`),toolCallId:V(),inputTextDelta:V()}),HN({type:tP(`tool-input-available`),toolCallId:V(),toolName:V(),input:ZN(V(),IN())}),HN({type:tP(`tool-output-available`),toolCallId:V(),output:IN()}),HN({type:tP(`start-step`)}),HN({type:tP(`finish-step`)}),HN({type:tP(`finish`)}),HN({type:tP(`error`),errorText:V()})]),T1=e=>{if(!e.startsWith(`data:`))return null;let t=e.slice(5).trim();if(!t||t===`[DONE]`)return null;try{let e=JSON.parse(t),n=w1.safeParse(e);return n.success?n.data:null}catch{return null}},E1=e=>{let t=e.getReader(),n=new TextDecoder,r=``;return{async*[Symbol.asyncIterator](){try{for(;;){let{done:e,value:i}=await t.read();if(e){if(r.trim()){let e=T1(r);e&&(yield e)}return}r+=n.decode(i,{stream:!0});let a=r.split(`
|
|
196
|
-
`);r=a.pop()??``;for(let e of a){let t=e.trim();if(!t)continue;let n=T1(t);n&&(yield n)}}}finally{t.releaseLock()}}}},D1=async e=>{let t={query:e.query,inputs:e.inputs,...e.toolCallId?{toolCallId:e.toolCallId}:{},...e.toolOutput===void 0?{}:{toolOutput:e.toolOutput}},n=await fetch(oD.LOCAL_AGENT_CHAT,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.text().catch(()=>`Unknown error`);throw Error(`Local backend request failed (${n.status}): ${e}`)}if(!n.body)throw Error(`Local backend returned empty response body`);return E1(n.body)},O1=async(e,t,n)=>D1({query:``,inputs:n,toolCallId:e,toolOutput:t}),k1=e=>{for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.role!==`assistant`)continue;let r=n.content.find(e=>e.type===`tool-call`&&e.result!==void 0);if(r)return{toolCallId:r.toolCallId,result:r.result}}return null},A1=async function*(e,t){let n=``;try{for await(let r of e){if(t.aborted)return;switch(r.type){case`text-delta`:n+=r.delta,yield{content:[{type:`text`,text:n}]};break;case`reasoning-delta`:yield{content:[{type:`reasoning`,text:r.delta},...n?[{type:`text`,text:n}]:[]]};break;case`tool-input-available`:yield{content:[...n?[{type:`text`,text:n}]:[],{type:`tool-call`,toolCallId:r.toolCallId,toolName:r.toolName,args:r.input,argsText:JSON.stringify(r.input)}],status:{type:`requires-action`,reason:`tool-calls`}};return;case`error`:yield{content:[{type:`text`,text:`[Error] ${r.errorText}`}]};return}}}catch(e){yield{content:[{type:`text`,text:`[Request failed] ${e instanceof Error?e.message:`Unknown error`}`}]}}},j1=()=>({async*run({messages:e,abortSignal:t,unstable_getMessage:n}){let r=k1(e)??(n?k1([n()]):null);if(r){yield*A1(await O1(r.toolCallId,r.result,pI()),t);return}let i=fI(e);i&&(yield*A1(await D1({query:i,inputs:pI()}),t))}}),M1=e=>{let t=rS((0,_.useMemo)(()=>j1(),[]),{unstable_humanToolNames:[...e.humanToolNames]}),n=(0,_.useCallback)(()=>{},[]);return{runtime:t,config:e.config,clearConversation:n}},N1=()=>{let e=(0,_.useMemo)(()=>_u({tools:ef({toolkit:rI})}),[]);return aD.mode===`local`?M1({config:e,humanToolNames:iI}):aD.mode===`dify-sdk`?C1():yI({config:e,humanToolNames:iI})},P1=0,F1=1,I1=2,L1=4;function R1(e){return()=>e}function z1(e){e()}function B1(e,t){return n=>e(t(n))}function V1(e,t){return()=>e(t)}function H1(e,t){return n=>e(t,n)}function U1(e){return e!==void 0}function W1(...e){return()=>{e.map(z1)}}function G1(){}function K1(e,t){return t(e),e}function q1(e,t){return t(e)}function J1(...e){return e}function Y1(e,t){return e(F1,t)}function X1(e,t){e(P1,t)}function Z1(e){e(I1)}function Q1(e){return e(L1)}function X(e,t){return Y1(e,H1(t,P1))}function $1(e,t){let n=e(F1,e=>{n(),t(e)});return n}function e0(e){let t,n;return r=>i=>{t=i,n&&clearTimeout(n),n=setTimeout(()=>{r(t)},e)}}function t0(e,t){return e===t}function n0(e=t0){let t;return n=>r=>{e(t,r)||(t=r,n(r))}}function r0(e){return t=>n=>{e(n)&&t(n)}}function Z(e){return t=>B1(t,e)}function i0(e){return t=>()=>{t(e)}}function Q(e,...t){let n=l0(...t);return((t,r)=>{switch(t){case I1:Z1(e);return;case F1:return Y1(e,n(r))}})}function a0(e,t){return n=>r=>{n(t=e(t,r))}}function o0(e){return t=>n=>{e>0?e--:t(n)}}function s0(e){let t=null,n;return r=>i=>{t=i,!n&&(n=setTimeout(()=>{n=void 0,r(t)},e))}}function c0(...e){let t=Array.from({length:e.length}),n=0,r=null,i=2**e.length-1;return e.forEach((e,a)=>{let o=2**a;Y1(e,e=>{let s=n;n|=o,t[a]=e,s!==i&&n===i&&r&&(r(),r=null)})}),e=>a=>{let o=()=>{e([a].concat(t))};n===i?o():r=o}}function l0(...e){return t=>e.reduceRight(q1,t)}function u0(e){let t,n,r=()=>t?.();return function(i,a){switch(i){case F1:return a?n===a?void 0:(r(),n=a,t=Y1(e,a),t):(r(),G1);case I1:r(),n=null;return}}}function $(e){let t=e,n=f0();return((e,r)=>{switch(e){case P1:t=r;break;case F1:r(t);break;case L1:return t}return n(e,r)})}function d0(e,t){return K1($(t),t=>X(e,t))}function f0(){let e=[];return((t,n)=>{switch(t){case P1:e.slice().forEach(e=>{e(n)});return;case I1:e.splice(0);return;case F1:return e.push(n),()=>{let t=e.indexOf(n);t>-1&&e.splice(t,1)}}})}function p0(e){return K1(f0(),t=>X(e,t))}var m0={singleton:!0};function h0(e,t=[],n=m0){let{singleton:r}=n;return{constructor:e,dependencies:t,id:g0(),singleton:r}}var g0=()=>Symbol(`id`);function _0(e){let t=new Map,n=({constructor:e,dependencies:r,id:i,singleton:a})=>{if(a&&t.has(i))return t.get(i);let o=e(r.map(e=>n(e)));return a&&t.set(i,o),o};return n(e)}function v0(...e){let t=f0(),n=Array.from({length:e.length}),r=0,i=2**e.length-1;return e.forEach((e,a)=>{let o=2**a;Y1(e,e=>{n[a]=e,r|=o,r===i&&X1(t,n)})}),function(e,a){switch(e){case I1:Z1(t);return;case F1:return r===i&&a(n),Y1(t,a)}}}function y0(e,t=t0){return Q(e,n0(t))}function b0(...e){return function(t,n){switch(t){case I1:return;case F1:return W1(...e.map(e=>Y1(e,n)))}}}var x0={DEBUG:0,INFO:1,WARN:2,ERROR:3},S0={[x0.DEBUG]:`debug`,[x0.ERROR]:`error`,[x0.INFO]:`log`,[x0.WARN]:`warn`},C0=()=>typeof globalThis>`u`?window:globalThis,w0=h0(()=>{let e=$(x0.ERROR);return{log:$((t,n,r=x0.INFO)=>{r>=(C0().VIRTUOSO_LOG_LEVEL??Q1(e))&&console[S0[r]](`%creact-virtuoso: %c%s %o`,`color: #0253b3; font-weight: bold`,`color: initial`,t,n)}),logLevel:e}},[],{singleton:!0});function T0(e){return`self`in e?e.document.documentElement:e}function E0(e){let t=T0(e);return t.ownerDocument.defaultView.getComputedStyle(t).direction===`rtl`}function D0(e,t){return E0(e)?-t:t}function O0(e,t){return E0(e)?-t:t}function k0(e,t,n){return A0(e,t,n).callbackRef}function A0(e,t,n){let r=_.useRef(null),i=e=>{},a=_.useMemo(()=>typeof ResizeObserver<`u`?new ResizeObserver(t=>{let r=()=>{let n=t[0].target;n.offsetParent!==null&&e(n)};n?r():requestAnimationFrame(r)}):null,[e,n]);return i=e=>{e&&t?(a?.observe(e),r.current=e):(r.current&&a?.unobserve(r.current),r.current=null)},{callbackRef:i,ref:r}}function j0(e,t,n,r,i,a,o,s,c){return A0(_.useCallback(n=>{let c=M0(n.children,t,s?`offsetWidth`:`offsetHeight`,i),l=n.parentElement;for(;l.dataset.virtuosoScroller===void 0;)l=l.parentElement;let u=l.lastElementChild?.dataset.viewportType===`window`,d;u&&(d=l.ownerDocument.defaultView);let f=o?s?o.scrollWidth:o.scrollHeight:u?s?d.document.documentElement.scrollWidth:d.document.documentElement.scrollHeight:s?l.scrollWidth:l.scrollHeight,p=o?s?o.offsetWidth:o.offsetHeight:u?s?d.innerWidth:d.innerHeight:s?l.offsetWidth:l.offsetHeight,m=o?s?D0(o,o.scrollLeft):o.scrollTop:u?s?D0(d,d.scrollX||d.document.documentElement.scrollLeft):d.scrollY||d.document.documentElement.scrollTop:s?D0(l,l.scrollLeft):l.scrollTop;r({scrollHeight:f,scrollTop:Math.max(m,0),viewportHeight:p}),a?.(s?N0(`column-gap`,getComputedStyle(n).columnGap,i):N0(`row-gap`,getComputedStyle(n).rowGap,i)),c!==null&&e(c)},[e,t,i,a,o,r,s]),n,c)}function M0(e,t,n,r){let i=e.length;if(i===0)return null;let a=[];for(let o=0;o<i;o++){let i=e.item(o);if(i.dataset.index===void 0)continue;let s=parseInt(i.dataset.index,10),c=parseFloat(i.dataset.knownSize),l=t(i,n);if(l===0&&r(`Zero-sized element, this should not happen`,{child:i},x0.ERROR),l===c)continue;let u=a[a.length-1];a.length===0||u.size!==l||u.endIndex!==s-1?a.push({endIndex:s,size:l,startIndex:s}):a[a.length-1].endIndex++}return a}function N0(e,t,n){return t!==`normal`&&t?.endsWith(`px`)!==!0&&n(`${e} was not resolved to pixel value correctly`,t,x0.WARN),t===`normal`?0:parseInt(t??`0`,10)}function P0(e,t,n){let r=_.useRef(null),i=_.useCallback(n=>{if(!n?.offsetParent)return;let i=n.getBoundingClientRect(),a=i.width,s,c;if(t){let e=t.getBoundingClientRect(),n=i.top-e.top;c=e.height-Math.max(0,n),s=n+t.scrollTop}else{let e=o.current.ownerDocument.defaultView;c=e.innerHeight-Math.max(0,i.top),s=i.top+e.scrollY}r.current={listHeight:i.height,offsetTop:s,visibleHeight:c,visibleWidth:a},e(r.current)},[e,t]),{callbackRef:a,ref:o}=A0(i,!0,n),s=_.useCallback(()=>{i(o.current)},[i,o]);return _.useEffect(()=>{if(t){t.addEventListener(`scroll`,s);let e=new ResizeObserver(()=>{requestAnimationFrame(s)});return e.observe(t),()=>{t.removeEventListener(`scroll`,s),e.unobserve(t)}}let e=o.current?.ownerDocument.defaultView;return e?.addEventListener(`scroll`,s),e?.addEventListener(`resize`,s),()=>{e?.removeEventListener(`scroll`,s),e?.removeEventListener(`resize`,s)}},[s,t,o]),a}var F0=h0(()=>{let e=f0(),t=f0(),n=$(0),r=f0(),i=$(0),a=f0(),o=f0(),s=$(0),c=$(0),l=$(0),u=$(0),d=f0(),f=f0(),p=$(!1),m=$(!1),h=$(!1);return X(Q(e,Z(({scrollTop:e})=>e)),t),X(Q(e,Z(({scrollHeight:e})=>e)),o),X(t,i),{deviation:n,fixedFooterHeight:l,fixedHeaderHeight:c,footerHeight:u,headerHeight:s,horizontalDirection:m,scrollBy:f,scrollContainerState:e,scrollHeight:o,scrollingInProgress:p,scrollTo:d,scrollTop:t,skipAnimationFrameInResizeObserver:h,smoothScrollTargetReached:r,statefulScrollTop:i,viewportHeight:a}},[],{singleton:!0}),I0={lvl:0};function L0(e,t){let n=e.length;if(n===0)return[];let{index:r,value:i}=t(e[0]),a=[];for(let o=1;o<n;o++){let{index:n,value:s}=t(e[o]);a.push({end:n-1,start:r,value:i}),r=n,i=s}return a.push({end:1/0,start:r,value:i}),a}function R0(e){return e===I0}function z0(e,t){if(!R0(e))return t===e.k?e.v:t<e.k?z0(e.l,t):z0(e.r,t)}function B0(e,t,n=`k`){if(R0(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){let r=B0(e.r,t,n);return r[0]===-1/0?[e.k,e.v]:r}return B0(e.l,t,n)}function V0(e,t,n){return R0(e)?Q0(t,n,1):t===e.k?J0(e,{k:t,v:n}):t<e.k?$0(J0(e,{l:V0(e.l,t,n)})):$0(J0(e,{r:V0(e.r,t,n)}))}function H0(){return I0}function U0(e,t,n){if(R0(e))return[];let r=B0(e,t)[0];return n2(K0(e,r,n))}function W0(e,t){if(R0(e))return I0;let{k:n,l:r,r:i}=e;if(t===n){if(R0(r))return i;if(R0(i))return r;let[t,n]=Z0(r);return q0(J0(e,{k:t,l:Y0(r),v:n}))}return q0(t<n?J0(e,{l:W0(r,t)}):J0(e,{r:W0(i,t)}))}function G0(e){return R0(e)?[]:[...G0(e.l),{k:e.k,v:e.v},...G0(e.r)]}function K0(e,t,n){if(R0(e))return[];let{k:r,l:i,r:a,v:o}=e,s=[];return r>t&&(s=s.concat(K0(i,t,n))),r>=t&&r<=n&&s.push({k:r,v:o}),r<=n&&(s=s.concat(K0(a,t,n))),s}function q0(e){let{l:t,lvl:n,r}=e;if(r.lvl>=n-1&&t.lvl>=n-1)return e;if(n>r.lvl+1){if(X0(t))return e2(J0(e,{lvl:n-1}));if(!R0(t)&&!R0(t.r))return J0(t.r,{l:J0(t,{r:t.r.l}),lvl:n,r:J0(e,{l:t.r.r,lvl:n-1})});throw Error(`Unexpected empty nodes`)}if(X0(e))return t2(J0(e,{lvl:n-1}));if(!R0(r)&&!R0(r.l)){let t=r.l,i=X0(t)?r.lvl-1:r.lvl;return J0(t,{l:J0(e,{lvl:n-1,r:t.l}),lvl:t.lvl+1,r:t2(J0(r,{l:t.r,lvl:i}))})}throw Error(`Unexpected empty nodes`)}function J0(e,t){return Q0(t.k===void 0?e.k:t.k,t.v===void 0?e.v:t.v,t.lvl===void 0?e.lvl:t.lvl,t.l===void 0?e.l:t.l,t.r===void 0?e.r:t.r)}function Y0(e){return R0(e.r)?e.l:q0(J0(e,{r:Y0(e.r)}))}function X0(e){return R0(e)||e.lvl>e.r.lvl}function Z0(e){return R0(e.r)?[e.k,e.v]:Z0(e.r)}function Q0(e,t,n,r=I0,i=I0){return{k:e,l:r,lvl:n,r:i,v:t}}function $0(e){return t2(e2(e))}function e2(e){let{l:t}=e;return!R0(t)&&t.lvl===e.lvl?J0(t,{r:J0(e,{l:t.r})}):e}function t2(e){let{lvl:t,r:n}=e;return!R0(n)&&!R0(n.r)&&n.lvl===t&&n.r.lvl===t?J0(n,{l:J0(e,{r:n.l}),lvl:t+1}):e}function n2(e){return L0(e,({k:e,v:t})=>({index:e,value:t}))}function r2(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function i2(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}var a2=h0(()=>({recalcInProgress:$(!1)}),[],{singleton:!0});function o2(e,t,n){return e[s2(e,t,n)]}function s2(e,t,n,r=0){let i=e.length-1;for(;r<=i;){let a=Math.floor((r+i)/2),o=e[a],s=n(o,t);if(s===0)return a;if(s===-1){if(i-r<2)return a-1;i=a-1}else{if(i===r)return a;r=a+1}}throw Error(`Failed binary finding record in array - ${e.join(`,`)}, searched for ${t}`)}function c2(e,t,n,r){let i=s2(e,t,r),a=s2(e,n,r,i);return e.slice(i,a+1)}function l2(e,t){return Math.round(e.getBoundingClientRect()[t])}function u2(e){return!R0(e.groupOffsetTree)}function d2({index:e},t){return t===e?0:t<e?-1:1}function f2(){return{groupIndices:[],groupOffsetTree:H0(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:H0()}}function p2(e,t){let n=R0(e)?0:1/0;for(let r of t){let{endIndex:t,size:i,startIndex:a}=r;if(n=Math.min(n,a),R0(e)){e=V0(e,0,i);continue}let o=U0(e,a-1,t+1);if(o.some(T2(r)))continue;let s=!1,c=!1;for(let{end:n,start:r,value:a}of o)s?(t>=r||i===a)&&(e=W0(e,r)):(c=a!==i,s=!0),n>t&&t>=r&&a!==i&&(e=V0(e,t+1,a));c&&(e=V0(e,a,i))}return[e,n]}function m2(e){return e.groupIndex!==void 0}function h2({offset:e},t){return t===e?0:t<e?-1:1}function g2(e,t,n){if(t.length===0)return 0;let{index:r,offset:i,size:a}=o2(t,e,d2),o=e-r,s=a*o+(o-1)*n+i;return s>0?s+n:s}function _2(e,t){if(!u2(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function v2(e,t,n){if(m2(e))return t.groupIndices[e.groupIndex]+1;let r=_2(e.index===`LAST`?n:e.index,t);return r=Math.max(0,Math.min(n,r)),r}function y2(e,t,n,r=0){return r>0&&(t=Math.max(t,o2(e,r,d2).offset)),L0(c2(e,t,n,h2),w2)}function b2(e,[t,n,r,i]){t.length>0&&r(`received item sizes`,t,x0.DEBUG);let a=e.sizeTree,o=a,s=0;if(n.length>0&&R0(a)&&t.length===2){let e=t[0].size,r=t[1].size;o=n.reduce((t,n)=>V0(V0(t,n,e),n+1,r),o)}else[o,s]=p2(o,t);if(o===a)return e;let{lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d}=C2(e.offsetTree,s,o,i);return{groupIndices:n,groupOffsetTree:n.reduce((e,t)=>V0(e,t,g2(t,d,i)),H0()),lastIndex:c,lastOffset:l,lastSize:u,offsetTree:d,sizeTree:o}}function x2(e){return G0(e).map(({k:e,v:t},n,r)=>{let i=r[n+1];return{endIndex:i===void 0?1/0:i.k-1,size:t,startIndex:e}})}function S2(e,t){let n=0,r=0;for(;n<e;)n+=t[r+1]-t[r]-1,r++;return r-(n===e?0:1)}function C2(e,t,n,r){let i=e,a=0,o=0,s=0,c=0;if(t===0)i=[];else{c=s2(i,t-1,d2),s=i[c].offset;let e=B0(n,t-1);a=e[0],o=e[1],i.length&&i[c].size===B0(n,t)[1]&&--c,i=i.slice(0,c+1)}for(let{start:e,value:c}of U0(n,t,1/0)){let t=e-a,n=t*o+s+t*r;i.push({index:e,offset:n,size:c}),a=e,s=n,o=c}return{lastIndex:a,lastOffset:s,lastSize:o,offsetTree:i}}function w2(e){return{index:e.index,value:e}}function T2(e){let{endIndex:t,size:n,startIndex:r}=e;return e=>e.start===r&&(e.end===t||e.end===1/0)&&e.value===n}var E2={offsetHeight:`height`,offsetWidth:`width`},D2=h0(([{log:e},{recalcInProgress:t}])=>{let n=f0(),r=f0(),i=d0(r,0),a=f0(),o=f0(),s=$(0),c=$([]),l=$(void 0),u=$(void 0),d=$(void 0),f=$(void 0),p=$((e,t)=>l2(e,E2[t])),m=$(void 0),h=$(0),g=f2(),_=d0(Q(n,c0(c,e,h),a0(b2,g),n0()),g),v=d0(Q(c,n0(),a0((e,t)=>({current:t,prev:e.current}),{current:[],prev:[]}),Z(({prev:e})=>e)),[]);X(Q(c,r0(e=>e.length>0),c0(_,h),Z(([e,t,n])=>{let r=e.reduce((e,r,i)=>V0(e,r,g2(r,t.offsetTree,n)||i),H0());return{...t,groupIndices:e,groupOffsetTree:r}})),_),X(Q(r,c0(_),r0(([e,{lastIndex:t}])=>e<t),Z(([e,{lastIndex:t,lastSize:n}])=>[{endIndex:t,size:n,startIndex:e}])),n),X(l,u);let y=d0(Q(l,Z(e=>e===void 0)),!0);X(Q(u,r0(e=>e!==void 0&&R0(Q1(_).sizeTree)),Z(e=>{let t=Q1(d),n=Q1(c).length>0;return t!==void 0&&t!==0?n?[{endIndex:0,size:t,startIndex:0},{endIndex:1,size:e,startIndex:1}]:[]:[{endIndex:0,size:e,startIndex:0}]})),n),X(Q(f,r0(e=>e!==void 0&&e.length>0&&R0(Q1(_).sizeTree)),Z(e=>{let t=[],n=e[0],r=0;for(let i=1;i<e.length;i++){let a=e[i];a!==n&&(t.push({endIndex:i-1,size:n,startIndex:r}),n=a,r=i)}return t.push({endIndex:e.length-1,size:n,startIndex:r}),t})),n),X(Q(c,c0(d,u),r0(([,e,t])=>e!==void 0&&t!==void 0),Z(([e,t,n])=>{let r=[];for(let i=0;i<e.length;i++){let a=e[i],o=e[i+1];r.push({startIndex:a,endIndex:a,size:t}),o!==void 0&&r.push({startIndex:a+1,endIndex:o-1,size:n})}return r})),n);let b=p0(Q(n,c0(_),a0(({sizes:e},[t,n])=>({changed:n!==e,sizes:n}),{changed:!1,sizes:g}),Z(e=>e.changed)));Y1(Q(s,a0((e,t)=>({diff:e.prev-t,prev:t}),{diff:0,prev:0}),Z(e=>e.diff)),e=>{let{groupIndices:n}=Q1(_);if(e>0)X1(t,!0),X1(a,e+S2(e,n));else if(e<0){let t=Q1(v);t.length>0&&(e-=S2(-e,t)),X1(o,e)}}),Y1(Q(s,c0(e)),([e,t])=>{e<0&&t("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:s},x0.ERROR)});let x=p0(a);X(Q(a,c0(_),Z(([e,t])=>{let n=t.groupIndices.length>0,r=[],i=t.lastSize;if(n){let n=z0(t.sizeTree,0),a=0,o=0;for(;a<e;){let e=t.groupIndices[o],s=t.groupIndices.length===o+1?1/0:t.groupIndices[o+1]-e-1;r.push({endIndex:e,size:n,startIndex:e}),r.push({endIndex:e+1+s-1,size:i,startIndex:e+1}),o++,a+=s+1}let s=G0(t.sizeTree);return a!==e&&s.shift(),s.reduce((t,{k:n,v:r})=>{let i=t.ranges;return t.prevSize!==0&&(i=[...t.ranges,{endIndex:n+e-1,size:t.prevSize,startIndex:t.prevIndex}]),{prevIndex:n+e,prevSize:r,ranges:i}},{prevIndex:e,prevSize:0,ranges:r}).ranges}return G0(t.sizeTree).reduce((t,{k:n,v:r})=>({prevIndex:n+e,prevSize:r,ranges:[...t.ranges,{endIndex:n+e-1,size:t.prevSize,startIndex:t.prevIndex}]}),{prevIndex:0,prevSize:i,ranges:[]}).ranges})),n);let S=p0(Q(o,c0(_,h),Z(([e,{offsetTree:t},n])=>g2(-e,t,n))));return X(Q(o,c0(_,h),Z(([e,t,n])=>{if(t.groupIndices.length>0){if(R0(t.sizeTree))return t;let r=H0(),i=Q1(v),a=0,o=0,s=0;for(;a<-e;){s=i[o];let e=i[o+1]-s-1;o++,a+=e+1}if(r=G0(t.sizeTree).reduce((t,{k:n,v:r})=>V0(t,Math.max(0,n+e),r),r),a!==-e){let n=z0(t.sizeTree,s);r=V0(r,0,n);let i=B0(t.sizeTree,-e+1)[1];r=V0(r,1,i)}return{...t,sizeTree:r,...C2(t.offsetTree,0,r,n)}}let r=G0(t.sizeTree).reduce((t,{k:n,v:r})=>V0(t,Math.max(0,n+e),r),H0());return{...t,sizeTree:r,...C2(t.offsetTree,0,r,n)}})),_),{beforeUnshiftWith:x,data:m,defaultItemSize:u,firstItemIndex:s,fixedItemSize:l,fixedGroupSize:d,gap:h,groupIndices:c,heightEstimates:f,itemSize:p,listRefresh:b,shiftWith:o,shiftWithOffset:S,sizeRanges:n,sizes:_,statefulTotalCount:i,totalCount:r,trackItemSizes:y,unshiftWith:a}},J1(w0,a2),{singleton:!0});function O2(e){return e.reduce((e,t)=>(e.groupIndices.push(e.totalCount),e.totalCount+=t+1,e),{groupIndices:[],totalCount:0})}var k2=h0(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:r,scrollTop:i}])=>{let a=f0(),o=f0(),s=p0(Q(a,Z(O2)));return X(Q(s,Z(e=>e.totalCount)),n),X(Q(s,Z(e=>e.groupIndices)),e),X(Q(v0(i,t,r),r0(([e,t])=>u2(t)),Z(([e,t,n])=>B0(t.groupOffsetTree,Math.max(e-n,0),`v`)[0]),n0(),Z(e=>[e])),o),{groupCounts:a,topItemsIndexes:o}},J1(D2,F0)),A2=h0(([{log:e}])=>{let t=$(!1),n=p0(Q(t,r0(e=>e),n0()));return Y1(t,t=>{t&&Q1(e)(`props updated`,{},x0.DEBUG)}),{didMount:n,propsReady:t}},J1(w0),{singleton:!0}),j2=typeof document<`u`&&`scrollBehavior`in document.documentElement.style;function M2(e){let t=typeof e==`number`?{index:e}:{...e};return t.align||=`start`,(!t.behavior||!j2)&&(t.behavior=`auto`),t.offset===void 0&&(t.offset=0),t}var N2=h0(([{gap:e,listRefresh:t,sizes:n,totalCount:r},{fixedFooterHeight:i,fixedHeaderHeight:a,footerHeight:o,headerHeight:s,scrollingInProgress:c,scrollTo:l,smoothScrollTargetReached:u,viewportHeight:d},{log:f}])=>{let p=f0(),m=f0(),h=$(0),g=null,_=null,v=null;function y(){g!==null&&(g(),g=null),v!==null&&(v(),v=null),_&&=(clearTimeout(_),null),X1(c,!1)}return X(Q(p,c0(n,d,r,h,s,o,f),c0(e,a,i),Z(([[e,n,r,i,a,o,s,l],d,f,h])=>{let b=M2(e),{align:x,behavior:S,offset:C}=b,w=i-1,T=v2(b,n,w),E=g2(T,n.offsetTree,d)+o;x===`end`?(E+=f+B0(n.sizeTree,T)[1]-r+h,T===w&&(E+=s)):x===`center`?E+=(f+B0(n.sizeTree,T)[1]-r+h)/2:E-=a,C!==void 0&&C!==0&&(E+=C);let D=t=>{y(),t?(l(`retrying to scroll to`,{location:e},x0.DEBUG),X1(p,e)):(X1(m,!0),l(`list did not change, scroll successful`,{},x0.DEBUG))};if(y(),S===`smooth`){let e=!1;v=Y1(t,t=>{e||=t}),g=$1(u,()=>{D(e)})}else g=$1(Q(t,P2(150)),D);return _=setTimeout(()=>{y()},1200),X1(c,!0),l(`scrolling from index to`,{behavior:S,index:T,top:E},x0.DEBUG),{behavior:S,top:E}})),l),{scrollTargetReached:m,scrollToIndex:p,topListHeight:h}},J1(D2,F0,w0),{singleton:!0});function P2(e){return t=>{let n=setTimeout(()=>{t(!1)},e);return e=>{e&&(t(!0),clearTimeout(n))}}}function F2(e,t){e===0?t():requestAnimationFrame(()=>{F2(e-1,t)})}function I2(e,t){if(e===void 0)return 0;let n=t-1,r=typeof e==`number`?e:e.index===`LAST`?n:e.index;return Math.max(0,Math.min(r,n))}function L2(e){return e===void 0?!0:typeof e==`number`?e===0:e.index===0&&(e.align===void 0||e.align===`start`)&&(e.offset===void 0||e.offset===0)}var R2=h0(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:r},{scrollTargetReached:i,scrollToIndex:a},{didMount:o}])=>{let s=$(!0),c=$(0),l=$(!0);return X(Q(o,c0(c),r0(([e,t])=>!L2(t)),i0(!1)),s),X(Q(o,c0(c),r0(([e,t])=>!L2(t)),i0(!1)),l),Y1(Q(v0(t,o),c0(s,n,e,l),r0(([[,e],t,{sizeTree:n},r,i])=>e&&(!R0(n)||U1(r))&&!t&&!i),c0(c)),([,e])=>{if(e===void 0){X1(s,!0),X1(l,!0);return}$1(i,()=>{X1(l,!0)}),F2(4,()=>{$1(r,()=>{X1(s,!0)}),X1(a,e)})}),{initialItemFinalLocationReached:l,initialTopMostItemIndex:c,scrolledToInitialItem:s}},J1(D2,F0,N2,A2),{singleton:!0});function z2(e,t){return Math.abs(e-t)<1.01}var B2=`up`,V2=`down`,H2=`none`,U2={atBottom:!1,notAtBottomBecause:`NOT_SHOWING_LAST_ITEM`,state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},W2=0,G2=h0(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:r,scrollTop:i,viewportHeight:a}])=>{let o=$(!1),s=$(!0),c=f0(),l=f0(),u=$(4),d=$(W2),f=d0(Q(b0(Q(y0(i),o0(1),i0(!0)),Q(y0(i),o0(1),i0(!1),e0(100))),n0()),!1),p=d0(Q(b0(Q(n,i0(!0)),Q(n,i0(!1),e0(200))),n0()),!1);X(Q(v0(y0(i),y0(d)),Z(([e,t])=>e<=t),n0()),s),X(Q(s,s0(50)),l);let m=p0(Q(v0(r,y0(a),y0(t),y0(e),y0(u)),a0((e,[{scrollHeight:t,scrollTop:n},r,i,a,o])=>{let s=n+r-t>-o,c={scrollHeight:t,scrollTop:n,viewportHeight:r};if(s){let t,r;return n>e.state.scrollTop?(t=`SCROLLED_DOWN`,r=e.state.scrollTop-n):(t=`SIZE_DECREASED`,r=e.state.scrollTop-n||e.scrollTopDelta),{atBottom:!0,atBottomBecause:t,scrollTopDelta:r,state:c}}let l;return l=c.scrollHeight>e.state.scrollHeight?`SIZE_INCREASED`:r<e.state.viewportHeight?`VIEWPORT_HEIGHT_DECREASING`:n<e.state.scrollTop?`SCROLLING_UPWARDS`:`NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM`,{atBottom:!1,notAtBottomBecause:l,state:c}},U2),n0((e,t)=>e!==void 0&&e.atBottom===t.atBottom))),h=d0(Q(r,a0((e,{scrollHeight:t,scrollTop:n,viewportHeight:r})=>{if(!z2(e.scrollHeight,t)){let i=t-(n+r)<1;return e.scrollTop!==n&&i?{changed:!0,jump:e.scrollTop-n,scrollHeight:t,scrollTop:n}:{changed:!0,jump:0,scrollHeight:t,scrollTop:n}}return{changed:!1,jump:0,scrollHeight:t,scrollTop:n}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),r0(e=>e.changed),Z(e=>e.jump)),0);X(Q(m,Z(e=>e.atBottom)),o),X(Q(o,s0(50)),c);let g=$(V2);X(Q(r,Z(({scrollTop:e})=>e),n0(),a0((e,t)=>Q1(p)?{direction:e.direction,prevScrollTop:t}:{direction:t<e.prevScrollTop?B2:V2,prevScrollTop:t},{direction:V2,prevScrollTop:0}),Z(e=>e.direction)),g),X(Q(r,s0(50),i0(H2)),g);let _=$(0);return X(Q(f,r0(e=>!e),i0(0)),_),X(Q(i,s0(100),c0(f),r0(([e,t])=>t),a0(([e,t],[n])=>[t,n],[0,0]),Z(([e,t])=>t-e)),_),{atBottomState:m,atBottomStateChange:c,atBottomThreshold:u,atTopStateChange:l,atTopThreshold:d,isAtBottom:o,isAtTop:s,isScrolling:f,lastJumpDueToItemResize:h,scrollDirection:g,scrollVelocity:_}},J1(F0)),K2=`top`,q2=`bottom`,J2=`none`;function Y2(e,t,n){return typeof e==`number`?n===B2&&t===K2||n===V2&&t===q2?e:0:n===B2?t===K2?e.main:e.reverse:t===q2?e.main:e.reverse}function X2(e,t){return typeof e==`number`?e:e[t]??0}var Z2=h0(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:r,viewportHeight:i}])=>{let a=f0(),o=$(0),s=$(0),c=$(0);return{increaseViewportBy:s,listBoundary:a,overscan:c,topListHeight:o,visibleRange:d0(Q(v0(y0(r),y0(i),y0(n),y0(a,i2),y0(c),y0(o),y0(t),y0(e),y0(s)),Z(([e,t,n,[r,i],a,o,s,c,l])=>{let u=e-c,d=o+s,f=Math.max(n-u,0),p=J2,m=X2(l,K2),h=X2(l,q2);return r-=c,r+=n+s,i+=n+s,i-=c,r>e+d-m&&(p=B2),i<e-f+t+h&&(p=V2),p===J2?null:[Math.max(u-n-Y2(a,K2,p)-m,0),u-f-s+t+Y2(a,q2,p)+h]}),r0(e=>e!==null),n0(i2)),[0,0])}},J1(F0),{singleton:!0});function Q2(e,t,n){if(u2(t)){let r=_2(e,t);return[{index:B0(t.groupOffsetTree,r)[0],offset:0,size:0},{data:n?.[0],index:r,offset:0,size:0}]}return[{data:n?.[0],index:e,offset:0,size:0}]}var $2={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function e4(e,t,n,r,i,a){let{lastIndex:o,lastOffset:s,lastSize:c}=i,l=0,u=0;if(e.length>0){l=e[0].offset;let t=e[e.length-1];u=t.offset+t.size}let d=n-o,f=s+d*c+(d-1)*r,p=l,m=f-u;return{bottom:u,firstItemIndex:a,items:n4(e,i,a),offsetBottom:m,offsetTop:l,top:p,topItems:n4(t,i,a),topListHeight:t.reduce((e,t)=>t.size+e,0),totalCount:n}}function t4(e,t,n,r,i,a){let o=0;if(n.groupIndices.length>0)for(let t of n.groupIndices){if(t-o>=e)break;o++}let s=e+o,c=I2(t,s);return e4(Array.from({length:s}).map((e,t)=>({data:a[t+c],index:t+c,offset:0,size:0})),[],s,i,n,r)}function n4(e,t,n){if(e.length===0)return[];if(!u2(t))return e.map(e=>({...e,index:e.index+n,originalIndex:e.index}));let r=e[0].index,i=e[e.length-1].index,a=[],o=U0(t.groupOffsetTree,r,i),s,c=0;for(let r of e){(!s||s.end<r.index)&&(s=o.shift(),c=t.groupIndices.indexOf(s.start));let e;e=r.index===s.start?{index:c,type:`group`}:{groupIndex:c,index:r.index-(c+1)+n},a.push({...e,data:r.data,offset:r.offset,originalIndex:r.index,size:r.size})}return a}function r4(e,t){return e===void 0?0:typeof e==`number`?e:e[t]??0}var i4=h0(([{data:e,firstItemIndex:t,gap:n,sizes:r,totalCount:i},a,{listBoundary:o,topListHeight:s,visibleRange:c},{initialTopMostItemIndex:l,scrolledToInitialItem:u},{topListHeight:d},f,{didMount:p},{recalcInProgress:m}])=>{let h=$([]),g=$(0),_=f0(),v=$(0);X(a.topItemsIndexes,h);let y=d0(Q(v0(p,m,y0(c,i2),y0(i),y0(r),y0(l),u,y0(h),y0(t),y0(n),y0(v),e),r0(([e,t,,n,,,,,,,,r])=>{let i=r!==void 0&&r.length!==n;return e&&!t&&!i}),Z(([,,[e,t],n,r,i,a,o,s,c,l,u])=>{let d=r,{offsetTree:f,sizeTree:p}=d,m=Q1(g);if(n===0)return{...$2,totalCount:n};if(e===0&&t===0)return m===0?{...$2,totalCount:n}:t4(m,i,r,s,c,u||[]);if(R0(p))return m>0?null:e4(Q2(I2(i,n),d,u),[],n,c,d,s);let h=[];if(o.length>0){let e=o[0],t=o[o.length-1],n=0;for(let r of U0(p,e,t)){let i=r.value,a=Math.max(r.start,e),o=Math.min(r.end,t);for(let e=a;e<=o;e++)h.push({data:u?.[e],index:e,offset:n,size:i}),n+=i}}if(!a)return e4([],h,n,c,d,s);let _=o.length>0?o[o.length-1]+1:0,v=y2(f,e,t,_);if(v.length===0)return null;let y=n-1,b=K1([],n=>{for(let r of v){let i=r.value,a=i.offset,o=r.start,s=i.size;if(i.offset<e){o+=Math.floor((e-i.offset+c)/(s+c));let t=o-r.start;a+=t*s+t*c}o<_&&(a+=(_-o)*s,o=_);let l=Math.min(r.end,y);for(let e=o;e<=l&&!(a>=t);e++)n.push({data:u?.[e],index:e,offset:a,size:s}),a+=s+c}}),x=r4(l,K2),S=r4(l,q2);if(b.length>0&&(x>0||S>0)){let e=b[0],t=b[b.length-1];if(x>0&&e.index>_){let t=Math.min(x,e.index-_),n=[],r=e.offset;for(let i=e.index-1;i>=e.index-t;i--){let t=U0(p,i,i)[0]?.value??e.size;r-=t+c,n.unshift({data:u?.[i],index:i,offset:r,size:t})}b.unshift(...n)}if(S>0&&t.index<y){let e=Math.min(S,y-t.index),n=t.offset+t.size+c;for(let r=t.index+1;r<=t.index+e;r++){let e=U0(p,r,r)[0]?.value??t.size;b.push({data:u?.[r],index:r,offset:n,size:e}),n+=e+c}}}return e4(b,h,n,c,d,s)}),r0(e=>e!==null),n0()),$2);X(Q(e,r0(U1),Z(e=>e?.length)),i),X(Q(y,Z(e=>e.topListHeight)),d),X(d,s),X(Q(y,Z(e=>[e.top,e.bottom])),o),X(Q(y,Z(e=>e.items)),_);let b=p0(Q(y,r0(({items:e})=>e.length>0),c0(i,e),r0(([{items:e},t])=>e[e.length-1].originalIndex===t-1),Z(([,e,t])=>[e-1,t]),n0(i2),Z(([e])=>e))),x=p0(Q(y,s0(200),r0(({items:e,topItems:t})=>e.length>0&&e[0].originalIndex===t.length),Z(({items:e})=>e[0].index),n0()));return{endReached:b,initialItemCount:g,itemsRendered:_,listState:y,minOverscanItemCount:v,rangeChanged:p0(Q(y,r0(({items:e})=>e.length>0),Z(({items:e})=>{let t=0,n=e.length-1;for(;e[t].type===`group`&&t<n;)t++;for(;e[n].type===`group`&&n>t;)n--;return{endIndex:e[n].index,startIndex:e[t].index}}),n0(r2))),startReached:x,topItemsIndexes:h,...f}},J1(D2,k2,Z2,R2,N2,G2,A2,a2),{singleton:!0}),a4=h0(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:r},{listState:i}])=>{let a=f0(),o=d0(Q(v0(n,e,r,t,i),Z(([e,t,n,r,i])=>e+t+n+r+i.offsetBottom+i.bottom)),0);return X(y0(o),a),{totalListHeight:o,totalListHeightChanged:a}},J1(F0,i4),{singleton:!0}),o4=h0(([{viewportHeight:e},{totalListHeight:t}])=>{let n=$(!1);return{alignToBottom:n,paddingTopAddition:d0(Q(v0(n,e,t),r0(([e])=>e),Z(([,e,t])=>Math.max(0,e-t)),s0(0),n0()),0)}},J1(F0,a4),{singleton:!0}),s4=h0(()=>({context:$(null)})),c4=({itemBottom:e,itemTop:t,locationParams:{align:n,behavior:r,...i},viewportBottom:a,viewportTop:o})=>t<o?{...i,align:n??`start`,...r===void 0?{}:{behavior:r}}:e>a?{...i,align:n??`end`,...r===void 0?{}:{behavior:r}}:null,l4=h0(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:r,fixedHeaderHeight:i,headerHeight:a,scrollingInProgress:o,scrollTop:s,viewportHeight:c},{scrollToIndex:l}])=>{let u=f0();return X(Q(u,c0(t,c,n,a,i,r,s),c0(e),Z(([[e,t,n,r,i,a,s,c],l])=>{let{calculateViewLocation:u=c4,done:d,...f}=e,p=v2(e,t,r-1),m=g2(p,t.offsetTree,l)+i+a,h=m+B0(t.sizeTree,p)[1],g=c+a,_=u({itemBottom:h,itemTop:m,locationParams:f,viewportBottom:c+n-s,viewportTop:g});return _===null?d?.():d&&$1(Q(o,r0(e=>!e),o0(Q1(o)?1:2)),d),_}),r0(e=>e!==null)),l),{scrollIntoView:u}},J1(D2,F0,N2,i4,w0),{singleton:!0});function u4(e){return e===!1?!1:e===`smooth`?`smooth`:`auto`}var d4=(e,t)=>typeof e==`function`?u4(e(t)):t&&u4(e),f4=h0(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:r},{atBottomState:i,isAtBottom:a},{scrollToIndex:o},{scrolledToInitialItem:s},{didMount:c,propsReady:l},{log:u},{scrollingInProgress:d},{context:f},{scrollIntoView:p}])=>{let m=$(!1),h=f0(),g=null;function _(e){X1(o,{align:`end`,behavior:e,index:`LAST`})}Y1(Q(v0(Q(y0(t),o0(1)),c),c0(y0(m),a,s,d),Z(([[e,t],n,r,i,a])=>{let o=t&&i,s=`auto`;return o&&(s=d4(n,r||a),o&&=s!==!1),{followOutputBehavior:s,shouldFollow:o,totalCount:e}}),r0(({shouldFollow:e})=>e)),({followOutputBehavior:t,totalCount:r})=>{g!==null&&(g(),g=null),Q1(n)===void 0?g=$1(e,()=>{Q1(u)(`following output to `,{totalCount:r},x0.DEBUG),_(t),g=null}):requestAnimationFrame(()=>{Q1(u)(`following output to `,{totalCount:r},x0.DEBUG),_(t)})});function v(e){let t=$1(i,t=>{e&&!t.atBottom&&t.notAtBottomBecause===`SIZE_INCREASED`&&g===null&&(Q1(u)(`scrolling to bottom due to increased size`,{},x0.DEBUG),_(`auto`))});setTimeout(t,100)}Y1(Q(v0(y0(m),t,l),r0(([e,,t])=>e!==!1&&t),a0(({value:e},[,t])=>({refreshed:e===t,value:t}),{refreshed:!1,value:0}),r0(({refreshed:e})=>e),c0(m,t)),([,e])=>{Q1(s)&&v(e!==!1)}),Y1(h,()=>{v(Q1(m)!==!1)}),Y1(v0(y0(m),i),([e,t])=>{e!==!1&&!t.atBottom&&t.notAtBottomBecause===`VIEWPORT_HEIGHT_DECREASING`&&_(`auto`)});let y=$(null),b=f0();return X(b0(Q(y0(r),Z(e=>e?.length??0)),Q(y0(t))),b),Y1(Q(v0(Q(b,o0(1)),c),c0(y0(y),s,d,f),Z(([[e,t],n,r,i,a])=>t&&r&&n?.({context:a,totalCount:e,scrollingInProgress:i})),r0(e=>!!e),s0(0)),t=>{g!==null&&(g(),g=null),Q1(n)===void 0?g=$1(e,()=>{Q1(u)(`scrolling into view`,{}),X1(p,t),g=null}):requestAnimationFrame(()=>{Q1(u)(`scrolling into view`,{}),X1(p,t)})}),{autoscrollToBottom:h,followOutput:m,scrollIntoViewOnChange:y}},J1(D2,G2,N2,R2,A2,w0,F0,s4,l4)),p4=h0(([{data:e,firstItemIndex:t,gap:n,sizes:r},{initialTopMostItemIndex:i},{initialItemCount:a,listState:o},{didMount:s}])=>(X(Q(s,c0(a),r0(([,e])=>e!==0),c0(i,r,t,n,e),Z(([[,e],t,n,r,i,a=[]])=>t4(e,t,n,r,i,a))),o),{}),J1(D2,R2,i4,A2),{singleton:!0}),m4=h0(([{didMount:e},{scrollTo:t},{listState:n}])=>{let r=$(0);return Y1(Q(e,c0(r),r0(([,e])=>e!==0),Z(([,e])=>({top:e}))),e=>{$1(Q(n,o0(1),r0(e=>e.items.length>1)),()=>{requestAnimationFrame(()=>{X1(t,e)})})}),{initialScrollTop:r}},J1(A2,F0,i4),{singleton:!0}),h4=h0(([{scrollVelocity:e}])=>{let t=$(!1),n=f0(),r=$(!1);return X(Q(e,c0(r,t,n),r0(([e,t])=>t!==!1&&t!==void 0),Z(([e,t,n,r])=>{let{enter:i,exit:a}=t;if(n){if(a(e,r))return!1}else if(i(e,r))return!0;return n}),n0()),t),Y1(Q(v0(t,e,n),c0(r)),([[e,t,n],r])=>{e&&r!==!1&&r!==void 0&&r.change&&r.change(t,n)}),{isSeeking:t,scrollSeekConfiguration:r,scrollSeekRangeChanged:n,scrollVelocity:e}},J1(G2),{singleton:!0}),g4=h0(([{scrollContainerState:e,scrollTo:t}])=>{let n=f0(),r=f0(),i=f0(),a=$(!1),o=$(void 0);return X(Q(v0(n,r),Z(([{scrollTop:e,viewportHeight:t},{offsetTop:n,listHeight:r}])=>({scrollHeight:r,scrollTop:Math.max(0,e-n),viewportHeight:t}))),e),X(Q(t,c0(r),Z(([e,{offsetTop:t}])=>({...e,top:e.top+t}))),i),{customScrollParent:o,useWindowScroll:a,windowScrollContainerState:n,windowScrollTo:i,windowViewportRect:r}},J1(F0)),_4=h0(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:r},{initialTopMostItemIndex:i},{didMount:a},{useWindowScroll:o,windowScrollContainerState:s,windowViewportRect:c}])=>{let l=f0(),u=$(void 0),d=$(null),f=$(null);return X(s,d),X(c,f),Y1(Q(l,c0(t,r,o,d,f,n)),([e,t,n,r,i,a,o])=>{let s=x2(t.sizeTree);r&&i!==null&&a!==null&&(n=i.scrollTop-a.offsetTop),n-=o,e({ranges:s,scrollTop:n})}),X(Q(u,r0(U1),Z(v4)),i),X(Q(a,c0(u),r0(([,e])=>e!==void 0),n0(),Z(([,e])=>e.ranges)),e),{getState:l,restoreStateFrom:u}},J1(D2,F0,R2,A2,g4));function v4(e){return{align:`start`,index:0,offset:e.scrollTop}}var y4=h0(([{topItemsIndexes:e}])=>{let t=$(0);return X(Q(t,r0(e=>e>=0),Z(e=>Array.from({length:e}).map((e,t)=>t))),e),{topItemCount:t}},J1(i4));function b4(e){let t=!1,n;return(()=>(t||(t=!0,n=e()),n))}var x4=b4(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),S4=h0(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:r,fixedGroupSize:i,gap:a,groupIndices:o,heightEstimates:s,itemSize:c,sizeRanges:l,sizes:u,statefulTotalCount:d,totalCount:f,trackItemSizes:p},{initialItemFinalLocationReached:m,initialTopMostItemIndex:h,scrolledToInitialItem:g},_,v,y,b,{scrollToIndex:x},S,{topItemCount:C},{groupCounts:w},T])=>{let{listState:E,minOverscanItemCount:D,topItemsIndexes:O,rangeChanged:ee,...te}=b;return X(ee,T.scrollSeekRangeChanged),X(Q(v0(T.windowViewportRect,_.headerHeight,_.fixedHeaderHeight),Z(([e,t,n])=>Math.max(t+n+1,e.visibleHeight))),_.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:r,fixedGroupHeight:i,gap:a,groupCounts:w,heightEstimates:s,initialItemFinalLocationReached:m,initialTopMostItemIndex:h,scrolledToInitialItem:g,sizeRanges:l,topItemCount:C,topItemsIndexes:O,totalCount:f,...y,groupIndices:o,itemSize:c,listState:E,minOverscanItemCount:D,scrollToIndex:x,statefulTotalCount:d,trackItemSizes:p,rangeChanged:ee,...te,...T,..._,sizes:u,...v}},J1(D2,R2,F0,_4,f4,i4,N2,h0(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:r},{isAtBottom:i,isScrolling:a,lastJumpDueToItemResize:o,scrollDirection:s},{listState:c},{beforeUnshiftWith:l,gap:u,shiftWithOffset:d,sizes:f},{log:p},{recalcInProgress:m}])=>{let h=p0(Q(c,c0(o),a0(([,e,t,n],[{bottom:r,items:i,offsetBottom:a,totalCount:o},s])=>{let c=r+a,l=0;return t===o&&e.length>0&&i.length>0&&(i[0].originalIndex===0&&e[0].originalIndex===0||(l=c-n,l!==0&&(l+=s))),[l,i,o,c]},[0,[],0,0]),r0(([e])=>e!==0),c0(r,s,n,i,p,m),r0(([,e,t,n,,,r])=>!r&&!n&&e!==0&&t===B2),Z(([[e],,,,,t])=>(t(`Upward scrolling compensation`,{amount:e},x0.DEBUG),e))));function g(n){n>0?(X1(t,{behavior:`auto`,top:-n}),X1(e,0)):(X1(e,0),X1(t,{behavior:`auto`,top:-n}))}return Y1(Q(h,c0(e,a)),([t,n,r])=>{r&&x4()?X1(e,n-t):g(-t)}),Y1(Q(v0(d0(a,!1),e,m),r0(([e,t,n])=>!e&&!n&&t!==0),Z(([e,t])=>t),s0(1)),g),X(Q(d,Z(e=>({top:-e}))),t),Y1(Q(l,c0(f,u),Z(([e,{groupIndices:t,lastSize:n,sizeTree:r},i])=>{function a(e){return e*(n+i)}if(t.length===0)return a(e);let o=0,s=z0(r,0),c=0,l=0;for(;c<e;){c++,o+=s;let n=t.length===l+1?1/0:t[l+1]-t[l]-1;c+n>e&&(o-=s,n=e-c+1),c+=n,o+=a(n),l++}return o})),n=>{X1(e,n),requestAnimationFrame(()=>{X1(t,{top:n}),requestAnimationFrame(()=>{X1(e,0),X1(m,!1)})})}),{deviation:e}},J1(F0,G2,i4,D2,w0,a2)),y4,k2,h0(([e,t,n,r,i,a,o,s,c,l,u])=>({...e,...t,...n,...r,...i,...a,...o,...s,...c,...l,...u}),J1(Z2,p4,A2,h4,a4,m4,o4,g4,l4,w0,s4))));function C4(e,t){let n={},r={},i=0,a=e.length;for(;i<a;)r[e[i]]=1,i+=1;for(let e in t)Object.hasOwn(r,e)||(n[e]=t[e]);return n}var w4=typeof document>`u`?_.useEffect:_.useLayoutEffect;function T4(e,t,n){let r=Object.keys(t.required||{}),i=Object.keys(t.optional||{}),a=Object.keys(t.methods||{}),o=Object.keys(t.events||{}),s=_.createContext({});function c(e,n){e.propsReady!==void 0&&X1(e.propsReady,!1);for(let i of r){let r=e[t.required[i]];X1(r,n[i])}for(let r of i)if(r in n){let i=e[t.optional[r]];X1(i,n[r])}e.propsReady!==void 0&&X1(e.propsReady,!0)}function l(e){return a.reduce((n,r)=>(n[r]=n=>{let i=e[t.methods[r]];X1(i,n)},n),{})}function u(e){return o.reduce((n,r)=>(n[r]=u0(e[t.events[r]]),n),{})}return{Component:_.forwardRef(function(t,a){let{children:d,...f}=t,[p]=_.useState(()=>K1(_0(e),e=>{c(e,f)})),[m]=_.useState(V1(u,p));w4(()=>{for(let e of o)e in f&&Y1(m[e],f[e]);return()=>{Object.values(m).map(Z1)}},[f,m,p]),w4(()=>{c(p,f)}),_.useImperativeHandle(a,R1(l(p)));let h=n;return(0,M.jsx)(s.Provider,{value:p,children:n===void 0?d:(0,M.jsx)(h,{...C4([...r,...i,...o],f),children:d})})}),useEmitter:(e,t)=>{let n=_.useContext(s)[e];w4(()=>Y1(n,t),[t,n])},useEmitterValue:e=>{let t=_.useContext(s)[e],n=_.useCallback(e=>Y1(t,e),[t]);return _.useSyncExternalStore(n,()=>Q1(t),()=>Q1(t))},usePublisher:e=>{let t=_.useContext(s);return _.useCallback(n=>{X1(t[e],n)},[t,e])}}}var E4=_.createContext(void 0),D4=_.createContext(void 0),O4=`-webkit-sticky`,k4=`sticky`,A4=b4(()=>{if(typeof document>`u`)return k4;let e=document.createElement(`div`);return e.style.position=O4,e.style.position===O4?O4:k4}),j4=typeof document>`u`?_.useEffect:_.useLayoutEffect;function M4(e){return`self`in e}function N4(e){return`body`in e}function P4(e,t,n,r=G1,i,a){let o=_.useRef(null),s=_.useRef(null),c=_.useRef(null),l=_.useCallback(n=>{let r,i,o,l=n.target;if(N4(l)||M4(l)){let e=M4(l)?l:l.defaultView;o=a===!0?D0(e,e.scrollX):e.scrollY,r=a===!0?e.document.documentElement.scrollWidth:e.document.documentElement.scrollHeight,i=a===!0?e.innerWidth:e.innerHeight}else o=a===!0?D0(l,l.scrollLeft):l.scrollTop,r=a===!0?l.scrollWidth:l.scrollHeight,i=a===!0?l.offsetWidth:l.offsetHeight;let u=()=>{e({scrollHeight:r,scrollTop:Math.max(o,0),viewportHeight:i})};n.suppressFlushSync===!0?u():Le.flushSync(u),s.current!==null&&(o===s.current||o<=0||o===r-i)&&(s.current=null,t(!0),c.current&&=(clearTimeout(c.current),null))},[e,t,a]);_.useEffect(()=>{let e=i??o.current;return r(i??o.current),l({suppressFlushSync:!0,target:e}),e.addEventListener(`scroll`,l,{passive:!0}),()=>{r(null),e.removeEventListener(`scroll`,l)}},[o,l,n,r,i]);function u(n){let r=o.current;if(!r||(a===!0?`offsetWidth`in r&&r.offsetWidth===0:`offsetHeight`in r&&r.offsetHeight===0))return;let i=n.behavior===`smooth`,l,u,d;M4(r)?(u=Math.max(l2(r.document.documentElement,a===!0?`width`:`height`),a===!0?r.document.documentElement.scrollWidth:r.document.documentElement.scrollHeight),l=a===!0?r.innerWidth:r.innerHeight,d=a===!0?D0(r,r.scrollX):r.scrollY):(u=r[a===!0?`scrollWidth`:`scrollHeight`],l=l2(r,a===!0?`width`:`height`),d=a===!0?D0(r,r.scrollLeft):r.scrollTop);let f=u-l;if(n.top===void 0){r.scrollTo(n);return}let p=Math.ceil(Math.max(Math.min(f,n.top),0));if(n.top=p,z2(l,u)||p===d){e({scrollHeight:u,scrollTop:d,viewportHeight:l}),i&&t(!0);return}i?(s.current=p,c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,s.current=null,t(!0)},1e3)):s.current=null,a===!0&&(n={...n.behavior===void 0?{}:{behavior:n.behavior},left:O0(r,p)}),r.scrollTo(n)}function d(e){a===!0&&(e={...e.behavior===void 0?{}:{behavior:e.behavior},...e.top===void 0?{}:{left:O0(o.current,e.top)}}),o.current.scrollBy(e)}return{scrollByCallback:d,scrollerRef:o,scrollToCallback:u}}function F4(e){return e}var I4=h0(([e,t])=>({...e,...t}),J1(S4,h0(()=>{let e=$(e=>`Item ${e}`),t=$(e=>`Group ${e}`),n=$({}),r=$(F4),i=$(`div`),a=$(G1),o=(e,t=null)=>d0(Q(n,Z(t=>t[e]),n0()),t);return{components:n,computeItemKey:r,EmptyPlaceholder:o(`EmptyPlaceholder`),FooterComponent:o(`Footer`),GroupComponent:o(`Group`,`div`),groupContent:t,HeaderComponent:o(`Header`),HeaderFooterTag:i,ItemComponent:o(`Item`,`div`),itemContent:e,ListComponent:o(`List`,`div`),ScrollerComponent:o(`Scroller`,`div`),scrollerRef:a,ScrollSeekPlaceholder:o(`ScrollSeekPlaceholder`),TopItemListComponent:o(`TopItemList`)}}))),L4=({height:e})=>(0,M.jsx)(`div`,{style:{height:e}}),R4={overflowAnchor:`none`,position:A4(),zIndex:1},z4={overflowAnchor:`none`},B4={...z4,display:`inline-block`,height:`100%`},V4=_.memo(function({showTopList:e=!1}){let t=i3(`listState`),n=a3(`sizeRanges`),r=i3(`useWindowScroll`),i=i3(`customScrollParent`),a=a3(`windowScrollContainerState`),o=a3(`scrollContainerState`),s=i||r?a:o,c=i3(`itemContent`),l=i3(`context`),u=i3(`groupContent`),d=i3(`trackItemSizes`),f=i3(`itemSize`),p=i3(`log`),m=a3(`gap`),h=i3(`horizontalDirection`),{callbackRef:g}=j0(n,f,d,e?G1:s,p,m,i,h,i3(`skipAnimationFrameInResizeObserver`)),[v,y]=_.useState(0);r3(`deviation`,e=>{v!==e&&y(e)});let b=i3(`EmptyPlaceholder`),x=i3(`ScrollSeekPlaceholder`)??L4,S=i3(`ListComponent`),C=i3(`ItemComponent`),w=i3(`GroupComponent`),T=i3(`computeItemKey`),E=i3(`isSeeking`),D=i3(`groupIndices`).length>0,O=i3(`alignToBottom`),ee=i3(`initialItemFinalLocationReached`),te=e?{}:{boxSizing:`border-box`,...h?{display:`inline-block`,height:`100%`,marginInlineStart:v===0?O?`auto`:0:v,paddingInlineEnd:t.offsetBottom,paddingInlineStart:t.offsetTop,whiteSpace:`nowrap`}:{marginTop:v===0?O?`auto`:0:v,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...ee?{}:{visibility:`hidden`}};return!e&&t.totalCount===0&&b!=null?(0,M.jsx)(b,{...q4(b,l)}):(0,M.jsx)(S,{...q4(S,l),"data-testid":e?`virtuoso-top-item-list`:`virtuoso-item-list`,ref:g,style:te,children:(e?t.topItems:t.items).map(e=>{let n=e.originalIndex,r=T(n+t.firstItemIndex,e.data,l);return E?(0,_.createElement)(x,{...q4(x,l),height:e.size,index:e.index,key:r,type:e.type||`item`,...e.type===`group`?{}:{groupIndex:e.groupIndex}}):e.type===`group`?(0,_.createElement)(w,{...q4(w,l),"data-index":n,"data-item-index":e.index,"data-known-size":e.size,key:r,style:R4},u(e.index,l)):(0,_.createElement)(C,{...q4(C,l),...J4(C,e.data),"data-index":n,"data-item-group-index":e.groupIndex,"data-item-index":e.index,"data-known-size":e.size,key:r,style:h?B4:z4},D?c(e.index,e.groupIndex,e.data,l):c(e.index,e.data,l))})})}),H4={height:`100%`,outline:`none`,overflowY:`auto`,position:`relative`,WebkitOverflowScrolling:`touch`},U4={outline:`none`,overflowX:`auto`,position:`relative`},W4=e=>({height:`100%`,position:`absolute`,top:0,width:`100%`,...e?{display:`flex`,flexDirection:`column`}:void 0}),G4=(e,t,n=0)=>({...W4(e),position:t?`relative`:`absolute`,top:t?-n:0}),K4={position:A4(),top:0,width:`100%`,zIndex:1};function q4(e,t){if(typeof e!=`string`)return{context:t}}function J4(e,t){return{item:typeof e==`string`?void 0:t}}var Y4=_.memo(function(){let e=i3(`HeaderComponent`),t=a3(`headerHeight`),n=i3(`HeaderFooterTag`),r=k0(_.useMemo(()=>e=>{t(l2(e,`height`))},[t]),!0,i3(`skipAnimationFrameInResizeObserver`)),i=i3(`context`);return e==null?null:(0,M.jsx)(n,{ref:r,children:(0,M.jsx)(e,{...q4(e,i)})})}),X4=_.memo(function(){let e=i3(`FooterComponent`),t=a3(`footerHeight`),n=i3(`HeaderFooterTag`),r=k0(_.useMemo(()=>e=>{t(l2(e,`height`))},[t]),!0,i3(`skipAnimationFrameInResizeObserver`)),i=i3(`context`);return e==null?null:(0,M.jsx)(n,{ref:r,children:(0,M.jsx)(e,{...q4(e,i)})})});function Z4({useEmitter:e,useEmitterValue:t,usePublisher:n}){return _.memo(function({children:r,style:i,context:a,...o}){let s=n(`scrollContainerState`),c=t(`ScrollerComponent`),l=n(`smoothScrollTargetReached`),u=t(`scrollerRef`),d=t(`horizontalDirection`)||!1,{scrollByCallback:f,scrollerRef:p,scrollToCallback:m}=P4(s,l,c,u,void 0,d);return e(`scrollTo`,m),e(`scrollBy`,f),(0,M.jsx)(c,{"data-testid":`virtuoso-scroller`,"data-virtuoso-scroller":!0,ref:p,style:{...d?U4:H4,...i},tabIndex:0,...o,...q4(c,a),children:r})})}function Q4({useEmitter:e,useEmitterValue:t,usePublisher:n}){return _.memo(function({children:r,style:i,context:a,...o}){let s=n(`windowScrollContainerState`),c=t(`ScrollerComponent`),l=n(`smoothScrollTargetReached`),u=t(`totalListHeight`),d=t(`deviation`),f=t(`customScrollParent`),p=_.useRef(null),{scrollByCallback:m,scrollerRef:h,scrollToCallback:g}=P4(s,l,c,t(`scrollerRef`),f);return j4(()=>(h.current=f??p.current?.ownerDocument.defaultView,()=>{h.current=null}),[h,f]),e(`windowScrollTo`,g),e(`scrollBy`,m),(0,M.jsx)(c,{ref:p,"data-virtuoso-scroller":!0,style:{position:`relative`,...i,...u===0?void 0:{height:u+d}},...o,...q4(c,a),children:r})})}var $4=({children:e})=>{let t=_.useContext(E4),n=a3(`viewportHeight`),r=a3(`fixedItemHeight`),i=i3(`alignToBottom`),a=i3(`horizontalDirection`),o=k0(_.useMemo(()=>B1(n,e=>l2(e,a?`width`:`height`)),[n,a]),!0,i3(`skipAnimationFrameInResizeObserver`));return _.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),(0,M.jsx)(`div`,{"data-viewport-type":`element`,ref:o,style:W4(i),children:e})},e3=({children:e})=>{let t=_.useContext(E4),n=a3(`windowViewportRect`),r=a3(`fixedItemHeight`),i=i3(`customScrollParent`),a=i3(`useWindowScroll`),o=i3(`topListHeight`),s=P0(n,i,i3(`skipAnimationFrameInResizeObserver`)),c=i3(`alignToBottom`);return _.useEffect(()=>{t&&(r(t.itemHeight),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),(0,M.jsx)(`div`,{"data-viewport-type":`window`,ref:s,style:G4(c,a,o),children:e})},t3=({children:e})=>{let t=i3(`TopItemListComponent`)??`div`,n=i3(`headerHeight`),r={...K4,marginTop:`${n}px`},i=i3(`context`);return(0,M.jsx)(t,{style:r,...q4(t,i),children:e})},{Component:n3,useEmitter:r3,useEmitterValue:i3,usePublisher:a3}=T4(I4,{optional:{restoreStateFrom:`restoreStateFrom`,context:`context`,followOutput:`followOutput`,scrollIntoViewOnChange:`scrollIntoViewOnChange`,itemContent:`itemContent`,groupContent:`groupContent`,overscan:`overscan`,increaseViewportBy:`increaseViewportBy`,minOverscanItemCount:`minOverscanItemCount`,totalCount:`totalCount`,groupCounts:`groupCounts`,topItemCount:`topItemCount`,firstItemIndex:`firstItemIndex`,initialTopMostItemIndex:`initialTopMostItemIndex`,components:`components`,atBottomThreshold:`atBottomThreshold`,atTopThreshold:`atTopThreshold`,computeItemKey:`computeItemKey`,defaultItemHeight:`defaultItemHeight`,fixedGroupHeight:`fixedGroupHeight`,fixedItemHeight:`fixedItemHeight`,heightEstimates:`heightEstimates`,itemSize:`itemSize`,scrollSeekConfiguration:`scrollSeekConfiguration`,headerFooterTag:`HeaderFooterTag`,data:`data`,initialItemCount:`initialItemCount`,initialScrollTop:`initialScrollTop`,alignToBottom:`alignToBottom`,useWindowScroll:`useWindowScroll`,customScrollParent:`customScrollParent`,scrollerRef:`scrollerRef`,logLevel:`logLevel`,horizontalDirection:`horizontalDirection`,skipAnimationFrameInResizeObserver:`skipAnimationFrameInResizeObserver`},methods:{scrollToIndex:`scrollToIndex`,scrollIntoView:`scrollIntoView`,scrollTo:`scrollTo`,scrollBy:`scrollBy`,autoscrollToBottom:`autoscrollToBottom`,getState:`getState`},events:{isScrolling:`isScrolling`,endReached:`endReached`,startReached:`startReached`,rangeChanged:`rangeChanged`,atBottomStateChange:`atBottomStateChange`,atTopStateChange:`atTopStateChange`,totalListHeightChanged:`totalListHeightChanged`,itemsRendered:`itemsRendered`,groupIndices:`groupIndices`}},_.memo(function(e){let t=i3(`useWindowScroll`),n=i3(`topItemsIndexes`).length>0,r=i3(`customScrollParent`),i=i3(`context`);return(0,M.jsxs)(r||t?s3:o3,{...e,context:i,children:[n&&(0,M.jsx)(t3,{children:(0,M.jsx)(V4,{showTopList:!0})}),(0,M.jsxs)(r||t?e3:$4,{children:[(0,M.jsx)(Y4,{}),(0,M.jsx)(V4,{}),(0,M.jsx)(X4,{})]})]})})),o3=Z4({useEmitter:r3,useEmitterValue:i3,usePublisher:a3}),s3=Q4({useEmitter:r3,useEmitterValue:i3,usePublisher:a3}),c3=n3,l3=h0(([e,t])=>({...e,...t}),J1(S4,h0(()=>{let e=$(e=>(0,M.jsxs)(`td`,{children:[`Item $`,e]})),t=$(null),n=$(e=>(0,M.jsxs)(`td`,{colSpan:1e3,children:[`Group `,e]})),r=$(null),i=$(null),a=$({}),o=$(F4),s=$(G1),c=(e,t=null)=>d0(Q(a,Z(t=>t[e]),n0()),t);return{components:a,computeItemKey:o,context:t,EmptyPlaceholder:c(`EmptyPlaceholder`),FillerRow:c(`FillerRow`),fixedFooterContent:i,fixedHeaderContent:r,itemContent:e,groupContent:n,ScrollerComponent:c(`Scroller`,`div`),scrollerRef:s,ScrollSeekPlaceholder:c(`ScrollSeekPlaceholder`),TableBodyComponent:c(`TableBody`,`tbody`),TableComponent:c(`Table`,`table`),TableFooterComponent:c(`TableFoot`,`tfoot`),TableHeadComponent:c(`TableHead`,`thead`),TableRowComponent:c(`TableRow`,`tr`),GroupComponent:c(`Group`,`tr`)}}))),u3=({height:e})=>(0,M.jsx)(`tr`,{children:(0,M.jsx)(`td`,{style:{height:e}})}),d3=({height:e})=>(0,M.jsx)(`tr`,{children:(0,M.jsx)(`td`,{style:{border:0,height:e,padding:0}})}),f3={overflowAnchor:`none`},p3={position:A4(),zIndex:2,overflowAnchor:`none`},m3=_.memo(function({showTopList:e=!1}){let t=b3(`listState`),n=b3(`computeItemKey`),r=b3(`firstItemIndex`),i=b3(`context`),a=b3(`isSeeking`),o=b3(`fixedHeaderHeight`),s=b3(`groupIndices`).length>0,c=b3(`itemContent`),l=b3(`groupContent`),u=b3(`ScrollSeekPlaceholder`)??u3,d=b3(`GroupComponent`),f=b3(`TableRowComponent`),p=(e?t.topItems:[]).reduce((e,t,n)=>(n===0?e.push(t.size):e.push(e[n-1]+t.size),e),[]);return(e?t.topItems:t.items).map(t=>{let m=t.originalIndex,h=n(m+r,t.data,i),g=e?m===0?0:p[m-1]:0;return a?(0,_.createElement)(u,{...q4(u,i),height:t.size,index:t.index,key:h,type:t.type||`item`}):t.type===`group`?(0,_.createElement)(d,{...q4(d,i),"data-index":m,"data-item-index":t.index,"data-known-size":t.size,key:h,style:{...p3,top:o}},l(t.index,i)):(0,_.createElement)(f,{...q4(f,i),...J4(f,t.data),"data-index":m,"data-item-index":t.index,"data-known-size":t.size,"data-item-group-index":t.groupIndex,key:h,style:e?{...p3,top:o+g}:f3},s?c(t.index,t.groupIndex,t.data,i):c(t.index,t.data,i))})}),h3=_.memo(function(){let e=b3(`listState`),t=b3(`topItemsIndexes`).length>0,n=x3(`sizeRanges`),r=b3(`useWindowScroll`),i=b3(`customScrollParent`),a=x3(`windowScrollContainerState`),o=x3(`scrollContainerState`),s=i||r?a:o,c=b3(`trackItemSizes`),{callbackRef:l,ref:u}=j0(n,b3(`itemSize`),c,s,b3(`log`),void 0,i,!1,b3(`skipAnimationFrameInResizeObserver`)),[d,f]=_.useState(0);y3(`deviation`,e=>{d!==e&&(u.current.style.marginTop=`${e}px`,f(e))});let p=b3(`EmptyPlaceholder`),m=b3(`FillerRow`)??d3,h=b3(`TableBodyComponent`),g=b3(`paddingTopAddition`),v=b3(`statefulTotalCount`),y=b3(`context`);if(v===0&&p!=null)return(0,M.jsx)(p,{...q4(p,y)});let b=(t?e.topItems:[]).reduce((e,t)=>e+t.size,0),x=e.offsetTop+g+d-b,S=e.offsetBottom,C=x>0?(0,M.jsx)(m,{context:y,height:x},`padding-top`):null,w=S>0?(0,M.jsx)(m,{context:y,height:S},`padding-bottom`):null;return(0,M.jsxs)(h,{"data-testid":`virtuoso-item-list`,ref:l,...q4(h,y),children:[C,t&&(0,M.jsx)(m3,{showTopList:!0}),(0,M.jsx)(m3,{}),w]})}),g3=({children:e})=>{let t=_.useContext(E4),n=x3(`viewportHeight`),r=x3(`fixedItemHeight`),i=k0(_.useMemo(()=>B1(n,e=>l2(e,`height`)),[n]),!0,b3(`skipAnimationFrameInResizeObserver`));return _.useEffect(()=>{t&&(n(t.viewportHeight),r(t.itemHeight))},[t,n,r]),(0,M.jsx)(`div`,{"data-viewport-type":`element`,ref:i,style:W4(!1),children:e})},_3=({children:e})=>{let t=_.useContext(E4),n=x3(`windowViewportRect`),r=x3(`fixedItemHeight`),i=b3(`customScrollParent`),a=b3(`useWindowScroll`),o=P0(n,i,b3(`skipAnimationFrameInResizeObserver`));return _.useEffect(()=>{t&&(r(t.itemHeight),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,r]),(0,M.jsx)(`div`,{"data-viewport-type":`window`,ref:o,style:G4(!1,a),children:e})},{Component:v3,useEmitter:y3,useEmitterValue:b3,usePublisher:x3}=T4(l3,{optional:{restoreStateFrom:`restoreStateFrom`,context:`context`,followOutput:`followOutput`,firstItemIndex:`firstItemIndex`,itemContent:`itemContent`,groupContent:`groupContent`,fixedHeaderContent:`fixedHeaderContent`,fixedFooterContent:`fixedFooterContent`,overscan:`overscan`,increaseViewportBy:`increaseViewportBy`,minOverscanItemCount:`minOverscanItemCount`,totalCount:`totalCount`,topItemCount:`topItemCount`,initialTopMostItemIndex:`initialTopMostItemIndex`,components:`components`,groupCounts:`groupCounts`,atBottomThreshold:`atBottomThreshold`,atTopThreshold:`atTopThreshold`,computeItemKey:`computeItemKey`,defaultItemHeight:`defaultItemHeight`,fixedGroupHeight:`fixedGroupHeight`,fixedItemHeight:`fixedItemHeight`,itemSize:`itemSize`,scrollSeekConfiguration:`scrollSeekConfiguration`,data:`data`,initialItemCount:`initialItemCount`,initialScrollTop:`initialScrollTop`,alignToBottom:`alignToBottom`,useWindowScroll:`useWindowScroll`,customScrollParent:`customScrollParent`,scrollerRef:`scrollerRef`,logLevel:`logLevel`},methods:{scrollToIndex:`scrollToIndex`,scrollIntoView:`scrollIntoView`,scrollTo:`scrollTo`,scrollBy:`scrollBy`,getState:`getState`},events:{isScrolling:`isScrolling`,endReached:`endReached`,startReached:`startReached`,rangeChanged:`rangeChanged`,atBottomStateChange:`atBottomStateChange`,atTopStateChange:`atTopStateChange`,totalListHeightChanged:`totalListHeightChanged`,itemsRendered:`itemsRendered`,groupIndices:`groupIndices`}},_.memo(function(e){let t=b3(`useWindowScroll`),n=b3(`customScrollParent`),r=x3(`fixedHeaderHeight`),i=x3(`fixedFooterHeight`),a=b3(`fixedHeaderContent`),o=b3(`fixedFooterContent`),s=b3(`context`),c=k0(_.useMemo(()=>B1(r,e=>l2(e,`height`)),[r]),!0,b3(`skipAnimationFrameInResizeObserver`)),l=k0(_.useMemo(()=>B1(i,e=>l2(e,`height`)),[i]),!0,b3(`skipAnimationFrameInResizeObserver`)),u=n||t?C3:S3,d=n||t?_3:g3,f=b3(`TableComponent`),p=b3(`TableHeadComponent`),m=b3(`TableFooterComponent`),h=a?(0,M.jsx)(p,{ref:c,style:{position:`sticky`,top:0,zIndex:2},...q4(p,s),children:a()},`TableHead`):null,g=o?(0,M.jsx)(m,{ref:l,style:{bottom:0,position:`sticky`,zIndex:1},...q4(m,s),children:o()},`TableFoot`):null;return(0,M.jsx)(u,{...e,...q4(u,s),children:(0,M.jsx)(d,{children:(0,M.jsxs)(f,{style:{borderSpacing:0,overflowAnchor:`none`},...q4(f,s),children:[h,(0,M.jsx)(h3,{},`TableBody`),g]})})})})),S3=Z4({useEmitter:y3,useEmitterValue:b3,usePublisher:x3}),C3=Q4({useEmitter:y3,useEmitterValue:b3,usePublisher:x3}),w3={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},T3={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:E3,floor:D3,max:O3,min:k3,round:A3}=Math;function j3(e,t,n){return Array.from({length:t-e+1}).map((t,r)=>({data:n===null?null:n[r+e],index:r+e}))}function M3(e){return{...T3,items:e}}function N3(e,t){return e!==void 0&&e.width===t.width&&e.height===t.height}function P3(e,t){return e!==void 0&&e.column===t.column&&e.row===t.row}var F3=h0(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:r},{footerHeight:i,headerHeight:a,scrollBy:o,scrollContainerState:s,scrollTo:c,scrollTop:l,smoothScrollTargetReached:u,viewportHeight:d},f,p,{didMount:m,propsReady:h},{customScrollParent:g,useWindowScroll:_,windowScrollContainerState:v,windowScrollTo:y,windowViewportRect:b},x])=>{let S=$(0),C=$(0),w=$(w3),T=$({height:0,width:0}),E=$({height:0,width:0}),D=f0(),O=f0(),ee=$(0),te=$(null),ne=$({column:0,row:0}),k=f0(),re=f0(),ie=$(!1),ae=$(0),A=$(!0),j=$(!1),oe=$(!1);Y1(Q(m,c0(ae),r0(([e,t])=>!L2(t))),()=>{X1(A,!1)}),Y1(Q(v0(m,A,E,T,ae,j),r0(([e,t,n,r,,i])=>e&&!t&&n.height!==0&&r.height!==0&&!i)),([,,,,e])=>{if(e===void 0){X1(A,!0);return}X1(j,!0),F2(1,()=>{X1(D,e)}),$1(Q(l),()=>{X1(t,[0,0]),X1(A,!0)})}),X(Q(re,r0(e=>e!=null&&e.scrollTop>0),i0(0)),C),Y1(Q(m,c0(re),r0(([,e])=>e!=null)),([,e])=>{e&&(X1(T,e.viewport),X1(E,e.item),X1(ne,e.gap),e.scrollTop>0&&(X1(ie,!0),$1(Q(l,o0(1)),e=>{X1(ie,!1)}),X1(c,{top:e.scrollTop})))}),X(Q(T,Z(({height:e})=>e)),d),X(Q(v0(y0(T,N3),y0(E,N3),y0(ne,(e,t)=>e!==void 0&&e.column===t.column&&e.row===t.row),y0(l)),Z(([e,t,n,r])=>({gap:n,item:t,scrollTop:r,viewport:e}))),k),X(Q(v0(y0(S),r,y0(ne,P3),y0(E,N3),y0(T,N3),y0(te),y0(C),y0(ie),y0(A),y0(ae)),r0(([,,,,,,,e])=>!e),Z(([e,[t,n],r,i,a,o,s,,c,l])=>{let{column:u,row:d}=r,{height:f,width:p}=i,{width:m}=a;if(s===0&&(e===0||m===0))return w3;if(p===0){let t=I2(l,e);return M3(j3(t,t+Math.max(s-1,0),o))}let h=I3(m,p,u),g,_;c?t===0&&n===0&&s>0?(g=0,_=s-1):(g=h*D3((t+d)/(f+d)),_=h*E3((n+d)/(f+d))-1,_=k3(e-1,O3(_,h-1)),g=k3(_,O3(0,g))):(g=0,_=-1);let v=j3(g,_,o),{bottom:y,top:b}=L3(a,r,i,v),x=E3(e/h);return{bottom:y,itemHeight:f,items:v,itemWidth:p,offsetBottom:x*f+(x-1)*d-y,offsetTop:b,top:b}})),w),X(Q(te,r0(e=>e!==null),Z(e=>e.length)),S),X(Q(v0(T,E,w,ne),r0(([e,t,{items:n}])=>n.length>0&&t.height!==0&&e.height!==0),Z(([e,t,{items:n},r])=>{let{bottom:i,top:a}=L3(e,r,t,n);return[a,i]}),n0(i2)),t);let se=$(!1);X(Q(l,c0(se),Z(([e,t])=>t||e!==0)),se);let ce=p0(Q(v0(w,S),r0(([{items:e}])=>e.length>0),c0(se),r0(([[e,t],n])=>{let r=e.items[e.items.length-1].index===t-1;return(n||e.bottom>0&&e.itemHeight>0&&e.offsetBottom===0&&e.items.length===t)&&r}),Z(([[,e]])=>e-1),n0())),le=p0(Q(y0(w),r0(({items:e})=>e.length>0&&e[0].index===0),i0(0),n0())),ue=p0(Q(y0(w),c0(ie),r0(([{items:e},t])=>e.length>0&&!t),Z(([{items:e}])=>({endIndex:e[e.length-1].index,startIndex:e[0].index})),n0(r2),s0(0)));X(ue,p.scrollSeekRangeChanged),X(Q(D,c0(T,E,S,ne),Z(([e,t,n,r,i])=>{let a=M2(e),{align:o,behavior:s,offset:c}=a,l=a.index;l===`LAST`&&(l=r-1),l=O3(0,l,k3(r-1,l));let u=R3(t,i,n,l);return o===`end`?u=A3(u-t.height+n.height):o===`center`&&(u=A3(u-t.height/2+n.height/2)),c!==void 0&&c!==0&&(u+=c),{behavior:s,top:u}})),c);let de=d0(Q(w,Z(e=>e.offsetBottom+e.bottom)),0);return X(Q(b,Z(e=>({height:e.visibleHeight,width:e.visibleWidth}))),T),{customScrollParent:g,data:te,deviation:ee,footerHeight:i,gap:ne,headerHeight:a,increaseViewportBy:e,initialItemCount:C,itemDimensions:E,overscan:n,restoreStateFrom:re,scrollBy:o,scrollContainerState:s,scrollHeight:O,scrollTo:c,scrollToIndex:D,scrollTop:l,smoothScrollTargetReached:u,totalCount:S,useWindowScroll:_,viewportDimensions:T,windowScrollContainerState:v,windowScrollTo:y,windowViewportRect:b,...p,gridState:w,horizontalDirection:oe,initialTopMostItemIndex:ae,totalListHeight:de,...f,endReached:ce,propsReady:h,rangeChanged:ue,startReached:le,stateChanged:k,stateRestoreInProgress:ie,...x}},J1(Z2,F0,G2,h4,A2,g4,w0));function I3(e,t,n){return O3(1,D3((e+n)/(D3(t)+n)))}function L3(e,t,n,r){let{height:i}=n;if(i===void 0||r.length===0)return{bottom:0,top:0};let a=R3(e,t,n,r[0].index);return{bottom:R3(e,t,n,r[r.length-1].index)+i,top:a}}function R3(e,t,n,r){let i=D3(r/I3(e.width,n.width,t.column)),a=i*n.height+O3(0,i-1)*t.row;return a>0?a+t.row:a}var z3=h0(([e,t])=>({...e,...t}),J1(F3,h0(()=>{let e=$(e=>`Item ${e}`),t=$({}),n=$(null),r=$(`virtuoso-grid-item`),i=$(`virtuoso-grid-list`),a=$(F4),o=$(`div`),s=$(G1),c=(e,n=null)=>d0(Q(t,Z(t=>t[e]),n0()),n),l=$(!1),u=$(!1);return X(y0(u),l),{components:t,computeItemKey:a,context:n,FooterComponent:c(`Footer`),HeaderComponent:c(`Header`),headerFooterTag:o,itemClassName:r,ItemComponent:c(`Item`,`div`),itemContent:e,listClassName:i,ListComponent:c(`List`,`div`),readyStateChanged:l,reportReadyState:u,ScrollerComponent:c(`Scroller`,`div`),scrollerRef:s,ScrollSeekPlaceholder:c(`ScrollSeekPlaceholder`,`div`)}}))),B3=_.memo(function(){let e=q3(`gridState`),t=q3(`listClassName`),n=q3(`itemClassName`),r=q3(`itemContent`),i=q3(`computeItemKey`),a=q3(`isSeeking`),o=J3(`scrollHeight`),s=q3(`ItemComponent`),c=q3(`ListComponent`),l=q3(`ScrollSeekPlaceholder`),u=q3(`context`),d=J3(`itemDimensions`),f=J3(`gap`),p=q3(`log`),m=q3(`stateRestoreInProgress`),h=J3(`reportReadyState`),g=k0(_.useMemo(()=>e=>{let t=e.parentElement.parentElement.scrollHeight;o(t);let n=e.firstChild;if(n!==null){let{height:e,width:t}=n.getBoundingClientRect();d({height:e,width:t})}f({column:Z3(`column-gap`,getComputedStyle(e).columnGap,p),row:Z3(`row-gap`,getComputedStyle(e).rowGap,p)})},[o,d,f,p]),!0,!1);return j4(()=>{e.itemHeight>0&&e.itemWidth>0&&h(!0)},[e]),m?null:(0,M.jsx)(c,{className:t,ref:g,...q4(c,u),"data-testid":`virtuoso-item-list`,style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(t=>{let o=i(t.index,t.data,u);return a?(0,M.jsx)(l,{...q4(l,u),height:e.itemHeight,index:t.index,width:e.itemWidth},o):(0,_.createElement)(s,{...q4(s,u),className:n,"data-index":t.index,key:o},r(t.index,t.data,u))})})}),V3=_.memo(function(){let e=q3(`HeaderComponent`),t=J3(`headerHeight`),n=q3(`headerFooterTag`),r=k0(_.useMemo(()=>e=>{t(l2(e,`height`))},[t]),!0,!1),i=q3(`context`);return e==null?null:(0,M.jsx)(n,{ref:r,children:(0,M.jsx)(e,{...q4(e,i)})})}),H3=_.memo(function(){let e=q3(`FooterComponent`),t=J3(`footerHeight`),n=q3(`headerFooterTag`),r=k0(_.useMemo(()=>e=>{t(l2(e,`height`))},[t]),!0,!1),i=q3(`context`);return e==null?null:(0,M.jsx)(n,{ref:r,children:(0,M.jsx)(e,{...q4(e,i)})})}),U3=({children:e})=>{let t=_.useContext(D4),n=J3(`itemDimensions`),r=J3(`viewportDimensions`),i=k0(_.useMemo(()=>e=>{r(e.getBoundingClientRect())},[r]),!0,!1);return _.useEffect(()=>{t&&(r({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,r,n]),(0,M.jsx)(`div`,{ref:i,style:W4(!1),children:e})},W3=({children:e})=>{let t=_.useContext(D4),n=J3(`windowViewportRect`),r=J3(`itemDimensions`),i=q3(`customScrollParent`),a=q3(`useWindowScroll`),o=P0(n,i,!1);return _.useEffect(()=>{t&&(r({height:t.itemHeight,width:t.itemWidth}),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,r]),(0,M.jsx)(`div`,{ref:o,style:G4(!1,a),children:e})},{Component:G3,useEmitter:K3,useEmitterValue:q3,usePublisher:J3}=T4(z3,{optional:{context:`context`,totalCount:`totalCount`,overscan:`overscan`,itemContent:`itemContent`,components:`components`,computeItemKey:`computeItemKey`,data:`data`,initialItemCount:`initialItemCount`,scrollSeekConfiguration:`scrollSeekConfiguration`,headerFooterTag:`headerFooterTag`,listClassName:`listClassName`,itemClassName:`itemClassName`,useWindowScroll:`useWindowScroll`,customScrollParent:`customScrollParent`,scrollerRef:`scrollerRef`,logLevel:`logLevel`,restoreStateFrom:`restoreStateFrom`,initialTopMostItemIndex:`initialTopMostItemIndex`,increaseViewportBy:`increaseViewportBy`},methods:{scrollTo:`scrollTo`,scrollBy:`scrollBy`,scrollToIndex:`scrollToIndex`},events:{isScrolling:`isScrolling`,endReached:`endReached`,startReached:`startReached`,rangeChanged:`rangeChanged`,atBottomStateChange:`atBottomStateChange`,atTopStateChange:`atTopStateChange`,stateChanged:`stateChanged`,readyStateChanged:`readyStateChanged`}},_.memo(function({...e}){let t=q3(`useWindowScroll`),n=q3(`customScrollParent`),r=n||t?X3:Y3,i=n||t?W3:U3,a=q3(`context`);return(0,M.jsx)(r,{...e,...q4(r,a),children:(0,M.jsxs)(i,{children:[(0,M.jsx)(V3,{}),(0,M.jsx)(B3,{}),(0,M.jsx)(H3,{})]})})})),Y3=Z4({useEmitter:K3,useEmitterValue:q3,usePublisher:J3}),X3=Q4({useEmitter:K3,useEmitterValue:q3,usePublisher:J3});function Z3(e,t,n){return t!==`normal`&&t?.endsWith(`px`)!==!0&&n(`${e} was not resolved to pixel value correctly`,t,x0.WARN),t===`normal`?0:parseInt(t??`0`,10)}var Q3=()=>Cx(),$3=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),e6=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),t6=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),n6=e=>{let t=t6(e);return t.charAt(0).toUpperCase()+t.slice(1)},r6={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`},i6=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},a6=(0,_.createContext)({}),o6=()=>(0,_.useContext)(a6),s6=(0,_.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>{let{size:l=24,strokeWidth:u=2,absoluteStrokeWidth:d=!1,color:f=`currentColor`,className:p=``}=o6()??{},m=r??d?Number(n??u)*24/Number(t??l):n??u;return(0,_.createElement)(`svg`,{ref:c,...r6,width:t??l??r6.width,height:t??l??r6.height,stroke:e??f,strokeWidth:m,className:$3(`lucide`,p,i),...!a&&!i6(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,_.createElement)(e,t)),...Array.isArray(a)?a:[a]])}),c6=(e,t)=>{let n=(0,_.forwardRef)(({className:n,...r},i)=>(0,_.createElement)(s6,{ref:i,iconNode:t,className:$3(`lucide-${e6(n6(e))}`,`lucide-${e}`,n),...r}));return n.displayName=n6(e),n},l6=c6(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),u6=c6(`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`}]]),d6=c6(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),f6=c6(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),p6=c6(`thumbs-up`,[[`path`,{d:`M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z`,key:`emmmcr`}],[`path`,{d:`M7 10v12`,key:`1qc93n`}]]),m6=c6(`thumbs-down`,[[`path`,{d:`M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z`,key:`m61m77`}],[`path`,{d:`M17 14V2`,key:`8ymqnk`}]]),h6=(...e)=>ze(e),g6=`flex items-center justify-center rounded-full text-foreground/45 outline-none transition-[background-color,color,scale] duration-150 hover:bg-foreground/[0.06] hover:text-foreground/90 active:scale-[0.96] focus-visible:ring-1 focus-visible:ring-foreground/20 motion-reduce:transition-none dark:hover:bg-foreground/[0.09]`,_6=`[grid-area:1/1] transition-[opacity,scale,filter] duration-200 ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none`,v6=`scale-100 opacity-100 blur-none`,y6=`scale-[0.25] opacity-0 blur-[4px]`;function b6({copied:e,reaction:t,regenerating:n,onCopy:r,onReactionChange:i,onRegenerate:a,onMore:o,helpful:s=!0,className:c,...l}){let u=h6(g6,`size-7`);return(0,M.jsxs)(`div`,{"data-slot":`message-actions`,className:h6(`flex items-center gap-1`,c),...l,children:[(0,M.jsxs)(`button`,{type:`button`,"aria-label":e?`Copied response`:`Copy response`,onClick:r,className:h6(u,`grid place-items-center`,e&&`text-emerald-500`),children:[(0,M.jsx)(u6,{className:h6(_6,`size-3.5`,e?y6:v6)}),(0,M.jsx)(l6,{className:h6(_6,`size-3.5`,e?v6:y6)})]}),s&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`button`,{type:`button`,"aria-label":`Mark response helpful`,"aria-pressed":t===`up`,onClick:()=>i?.(t===`up`?null:`up`),className:h6(u,t===`up`&&`bg-foreground/[0.06] text-foreground/90 dark:bg-foreground/[0.09]`),children:(0,M.jsx)(p6,{className:`size-3.5`})}),(0,M.jsx)(`button`,{type:`button`,"aria-label":`Mark response unhelpful`,"aria-pressed":t===`down`,onClick:()=>i?.(t===`down`?null:`down`),className:h6(u,t===`down`&&`bg-foreground/[0.06] text-foreground/90 dark:bg-foreground/[0.09]`),children:(0,M.jsx)(m6,{className:`size-3.5`})})]}),i&&(0,M.jsx)(`button`,{type:`button`,"aria-label":`Regenerate response`,onClick:a,className:u,children:(0,M.jsx)(f6,{className:h6(`size-3.5`,n&&`animate-spin motion-reduce:animate-none`)})}),o&&(0,M.jsx)(`button`,{type:`button`,"aria-label":`More response actions`,onClick:o,className:u,children:(0,M.jsx)(d6,{className:`size-3.5`})})]})}var x6=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],S6=[`processing`,`analyzing`,`computing`,`evaluating`,`pondering`],C6=({state:e,className:t,toolName:n,verbCycleMs:r=1200,spinnerFrameMs:i=80})=>{let[a,o]=(0,_.useState)(0),[s,c]=(0,_.useState)(0);if((0,_.useEffect)(()=>{if(e===`idle`)return;let t=setInterval(()=>{o(e=>(e+1)%x6.length)},i);return()=>clearInterval(t)},[e,i]),(0,_.useEffect)(()=>{if(e!==`thinking`)return;let t=setInterval(()=>{c(e=>(e+1)%S6.length)},r);return()=>clearInterval(t)},[e,r]),e===`idle`)return null;let l;return l=e===`toolRunning`&&n?`Running tool: ${n}`:`${S6[s]} …`,(0,M.jsxs)(`div`,{className:t,style:{display:`flex`,alignItems:`center`,gap:8,padding:`10px`},children:[(0,M.jsx)(`span`,{style:{fontFamily:`monospace`,fontSize:16},children:x6[a]}),(0,M.jsx)(`span`,{children:l})]})};function w6(e,t,n){return Number.isNaN(e)?t:Math.min(n,Math.max(t,e))}function T6(e,t){return e.slice(0,Math.floor(w6(t,0,e.length)))}function E6({segments:e,count:t,streaming:n,className:r,...i}){let a=T6((0,_.useMemo)(()=>e.flatMap(e=>e.text.split(` `).map(t=>({word:t,mono:e.mono??!1}))),[e]),t);return(0,M.jsxs)(`p`,{"data-slot":`streaming-text`,className:h6(`min-h-[8.5rem] max-w-sm text-sm leading-relaxed text-pretty`,r),...i,children:[a.map(({word:e,mono:t},r)=>{let i=n&&a.length-1-r<2;return(0,M.jsxs)(`span`,{className:`fade-in animate-in fill-mode-both duration-500 motion-reduce:animate-none`,children:[(0,M.jsx)(`span`,{className:h6(`transition-colors duration-700 motion-reduce:transition-none`,i&&`text-blue-500 dark:text-blue-400`,t&&`bg-foreground/[0.06] rounded-md px-1.5 py-0.5 font-mono text-[0.85em]`),children:e}),` `]},r)}),n&&a.length>0&&(0,M.jsx)(`span`,{"aria-hidden":!0,className:`-mb-0.5 ml-0.5 inline-block h-4 w-0.5 animate-pulse rounded-full bg-blue-500 dark:bg-blue-400`})]})}var D6=()=>(0,M.jsx)(uE.Parts,{components:{Text:()=>{let e=lT(),t=e?.text??``,n=e?.status?.type===`running`||e?.status?.type===`incomplete`,r=t?[{text:t}]:[{text:``}],i=t?t.split(/\s+/).filter(Boolean).length:0;return!t&&n?(0,M.jsx)(C6,{state:`thinking`,className:`text-xs text-blue-600`}):(0,M.jsx)(E6,{segments:r,count:i,streaming:n})}}}),O6={UserMessage:()=>{let{copy:e,isCopied:t}=Fx({copyToClipboard:async e=>{await navigator.clipboard.writeText(e)}});return(0,M.jsxs)(uE.Root,{className:`flex flex-col items-end my-6`,children:[(0,M.jsx)(`div`,{className:`max-w-[80%] rounded-2xl rounded-br-sm bg-gray-100 border border-gray-200 px-4 py-2`,children:(0,M.jsx)(D6,{})}),(0,M.jsx)(b6,{className:`mt-2 justify-end`,copied:t,helpful:!1,onCopy:e})]})},AssistantMessage:()=>{let[e,t]=(0,_.useState)(null),n=R(e=>e.thread.isRunning),{copy:r,isCopied:i}=Fx({copyToClipboard:async e=>{await navigator.clipboard.writeText(e)}}),{reload:a,disabled:o}=Bx(),s=(0,_.useCallback)(()=>{o||a()},[a,o]);return(0,M.jsxs)(uE.Root,{className:`flex flex-col items-start justify-start mt-6`,children:[(0,M.jsx)(_s.robot,{size:26,className:`text-blue-500 rounded-md bg-gray-200 p-1`}),(0,M.jsxs)(`div`,{className:`rounded-2xl rounded-bl-sm py-2 text-gray-800`,children:[(0,M.jsx)(D6,{}),!n&&(0,M.jsx)(b6,{className:`mt-2 justify-end`,copied:i,reaction:e,regenerating:!1,onCopy:r,onReactionChange:t,onRegenerate:s})]})]})}},k6=()=>{let e=Q3(),t=(0,_.useCallback)(t=>{let n=e[t];return n?(0,M.jsx)(JE.Unstable_MessageById,{messageId:n,components:O6}):null},[e]);return(0,M.jsx)(c3,{className:`h-full py-3`,totalCount:e.length,itemContent:t,followOutput:`smooth`,overscan:200,defaultItemHeight:80})},A6=()=>(0,M.jsxs)(`div`,{className:`relative flex-1 px-4 overflow-hidden`,children:[(0,M.jsx)(k6,{}),(0,M.jsx)(Pf,{condition:e=>e.thread.isEmpty,children:(0,M.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 flex flex-col items-center justify-center gap-2 text-gray-400`,children:[(0,M.jsx)(_s.message,{size:32}),(0,M.jsx)(`p`,{className:`text-sm`,children:`Start a conversation with AI Assistant`})]})})]}),j6=()=>(0,M.jsxs)(oT.Root,{className:`flex items-end gap-2 border-t border-gray-200 p-3`,children:[(0,M.jsx)(oT.Input,{placeholder:`Type a message...`,submitMode:`enter`,className:`flex-1 resize-none rounded-lg border border-gray-300 px-3 py-2 text-sm outline-none`,rows:1}),(0,M.jsx)(oT.Send,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-blue-500 text-white hover:bg-blue-600 disabled:opacity-40`,children:(0,M.jsx)(_s.paperPlane,{size:16})})]}),M6=()=>{let{runtime:e,config:t}=N1();return(0,M.jsx)(hS,{runtime:e,config:t,children:(0,M.jsxs)(JE.Root,{className:`flex h-full flex-col bg-white`,children:[(0,M.jsx)(A6,{}),(0,M.jsx)(j6,{})]})})},N6=()=>{let[e,t]=(0,_.useState)(!1),n=()=>t(e=>!e);return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(vs,{isOpen:e,onToggle:n}),e&&(0,M.jsxs)(`div`,{className:`z-[2147483647] flex h-[500px] w-[380px] flex-col overflow-hidden rounded-xl border border-gray-200 bg-white shadow-2xl`,children:[(0,M.jsxs)(`header`,{className:`flex items-center justify-between border-b border-gray-200 px-4 py-3`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(_s.robot,{size:20,className:`text-blue-500`}),(0,M.jsx)(`h2`,{className:`text-sm font-semibold text-gray-800`,children:`AI Assistant`})]}),(0,M.jsxs)(xo,{isIconOnly:!0,variant:`ghost`,size:`sm`,onPress:n,"aria-label":`Close dialog`,children:[(0,M.jsx)(_s.close,{size:16}),(0,M.jsx)(No,{})]})]}),(0,M.jsx)(`button`,{className:`fixed bottom-10 left-6 px-4 py-2 bg-blue-500 text-white rounded-md cursor-pointer`,onClick:()=>{let e=cF(`#products-list > div.py-4:nth-child(2) > div.grid.items-center:nth-child(2) > div.flex.gap-4:nth-child(3) > button.btn-icon.rounded-md:nth-child(1)`);e&&e.click()},children:`点击`}),(0,M.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:(0,M.jsx)(M6,{})})]})]})};(0,v.createRoot)(document.getElementById(`root`)).render((0,M.jsx)(_.StrictMode,{children:(0,M.jsx)(()=>(0,M.jsx)(N6,{}),{})}));
|