@alexkroman1/aai-ui 5.13.1 → 5.13.2
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/default-client/assets/{audio-BAAzYW28.js → audio-BqyrSHNq.js} +1 -1
- package/dist/default-client/assets/{capture-processor-vx5IW_Rd.js → capture-processor-CWRLCPS3.js} +1 -1
- package/dist/default-client/assets/{index-Cn-zI5ic.js → index-DfVI-qZ8.js} +3 -3
- package/dist/default-client/assets/{playback-processor-2p9HLz_W.js → playback-processor-SKKE9qu2.js} +1 -1
- package/dist/default-client/index.html +1 -1
- package/dist/define-client.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{session-core-BoB7kTzL.js → session-core-BA8H3qtF.js} +38 -15
- package/dist/session-core-types.d.ts +22 -0
- package/dist/session-core.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,o as t,t as n}from"./index-
|
|
1
|
+
import{a as e,o as t,t as n}from"./index-DfVI-qZ8.js";function r(e,t,n){if(e!==t)throw Error(`Browser refused the ${n} sample rate: asked for ${t} Hz, got ${e} Hz`)}function i(e){e.then(e=>{for(let t of e.getTracks())t.stop()}).catch(()=>{})}function a(e,t,n){let r=new AudioWorkletNode(e,`capture-processor`,{channelCount:1,channelCountMode:`explicit`}),i=null;return r.port.onmessage=e=>{let r=e.data;r.event===`chunk`&&r.buffer?t(r.buffer):r.event===`silent`?n?.():r.event===`stopped`&&(i?.(),i=null)},{node:r,start(){r.port.postMessage({event:`start`})},stop(){return new Promise(e=>{let t=setTimeout(e,250);i=()=>{clearTimeout(t),e()},r.port.postMessage({event:`stop`})})}}}async function o(o){let{sttSampleRate:s,ttsSampleRate:c,captureWorkletSrc:l,playbackWorkletSrc:u,onMicData:d,onError:f,onPlaybackStats:p,onPlaybackProgress:m,onMicSilent:h}=o,g=new AudioContext({sampleRate:c,latencyHint:`playback`}),_=s===c,v=_?g:new AudioContext({sampleRate:s,latencyHint:`interactive`});async function y(){let e=_?[g]:[g,v];await Promise.all(e.map(e=>e.close().catch(e=>{console.warn(`AudioContext close failed:`,e)})))}let b=navigator.mediaDevices.getUserMedia({audio:{deviceId:{ideal:`default`},...n}}),x;try{[x]=await Promise.all([b,g.resume(),v.resume(),v.audioWorklet.addModule(l),g.audioWorklet.addModule(u)]),r(v.sampleRate,s,`capture`),r(g.sampleRate,c,`playback`)}catch(e){throw i(b),await y(),e}let S=v.createMediaStreamSource(x),C=a(v,d,h);S.connect(C.node),C.node.onprocessorerror=()=>{let e=Error(`Audio capture worklet crashed`);console.error(`[aai-ui]`,e.message),f?.(e)},C.start();let w=null,T=null,E=0,D=null,O=new AbortController;function k(){T?.(),T=null,D=null}function A(e){e.stats&&e.stats.concealedSamples>0&&p?.(e.stats),e.reason!==`interrupt`&&(D!==null&&e.turn!==D||k())}function j(){if(w)return w;let e=new AudioWorkletNode(g,`playback-processor`);return e.connect(g.destination),e.port.onmessage=e=>{e.data.event===`stop`?A(e.data):e.data.event===`progress`&&m?.(e.data.bufferedMs)},e.onprocessorerror=()=>{let e=Error(`Audio playback worklet crashed`);console.error(`[aai-ui]`,e.message),k(),f?.(e)},w=e,e}let M={enqueue(e){O.signal.aborted||e.byteLength!==0&&j().port.postMessage({event:`write`,buffer:new Uint8Array(e)},[e])},done(){if(!w)return Promise.resolve();let n=++E;return w.port.postMessage({event:`done`,turn:n}),g.state===`running`?new Promise(r=>{T?.();let i=()=>{clearInterval(a),clearTimeout(o),T===i&&(T=null,D=null),r()},a=setInterval(()=>{g.state!==`running`&&i()},t),o=setTimeout(i,e);T=i,D=n}):(D=null,Promise.resolve())},flush(){w&&(k(),w.port.postMessage({event:`interrupt`}))},async close(){if(!O.signal.aborted){O.abort(),await C.stop(),S.disconnect(),C.node.disconnect(),w&&w.disconnect();for(let e of x.getTracks())e.stop();await y()}},async[Symbol.asyncDispose](){await M.close()}};return M}export{o as createVoiceIO};
|
package/dist/default-client/assets/{capture-processor-vx5IW_Rd.js → capture-processor-CWRLCPS3.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e,r as t}from"./index-
|
|
1
|
+
import{n as e,r as t}from"./index-DfVI-qZ8.js";import{t as n}from"./_module-url-BX0RuRU2.js";var r=n(`
|
|
2
2
|
class CaptureProcessor extends AudioWorkletProcessor {
|
|
3
3
|
constructor(options) {
|
|
4
4
|
super();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./capture-processor-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./capture-processor-CWRLCPS3.js","./_module-url-BX0RuRU2.js","./playback-processor-SKKE9qu2.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
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,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(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},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,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),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var u=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 ee=Array.isArray;function S(){}var C={H:null,A:null,T:null,S:null},te=Object.prototype.hasOwnProperty;function ne(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function re(e,t){return ne(e.type,t,e.props)}function w(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function ie(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var ae=/\/+/g;function oe(e,t){return typeof e==`object`&&e&&e.key!=null?ie(``+e.key):t.toString(36)}function se(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(S,S):(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 ce(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,ce(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+oe(e,0):a,ee(o)?(i=``,c!=null&&(i=c.replace(ae,`$&/`)+`/`),ce(o,r,i,``,function(e){return e})):o!=null&&(w(o)&&(o=re(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(ae,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(ee(e))for(var u=0;u<e.length;u++)a=e[u],s=l+oe(a,u),c+=ce(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+oe(a,u++),c+=ce(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return ce(se(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 le(e,t,n){if(e==null)return e;var r=[],i=0;return ce(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function T(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 E=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)},D={map:le,forEach:function(e,t,n){le(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return le(e,function(){t++}),t},toArray:function(e){return le(e,function(e){return e})||[]},only:function(e){if(!w(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=D,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=C,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return C.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)!te.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 ne(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)te.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 ne(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=w,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:T}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=C.T,n={};C.T=n;try{var r=e(),i=C.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(S,E)}catch(e){E(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),C.T=t}},e.unstable_useCacheRefresh=function(){return C.H.useCacheRefresh()},e.use=function(e){return C.H.use(e)},e.useActionState=function(e,t,n){return C.H.useActionState(e,t,n)},e.useCallback=function(e,t){return C.H.useCallback(e,t)},e.useContext=function(e){return C.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return C.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return C.H.useEffect(e,t)},e.useEffectEvent=function(e){return C.H.useEffectEvent(e)},e.useId=function(){return C.H.useId()},e.useImperativeHandle=function(e,t,n){return C.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return C.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return C.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return C.H.useMemo(e,t)},e.useOptimistic=function(e,t){return C.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return C.H.useReducer(e,t,n)},e.useRef=function(e){return C.H.useRef(e)},e.useState=function(e){return C.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return C.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return C.H.useTransition()},e.version=`19.2.8`})),d=o(((e,t)=>{t.exports=u()})),f=o((e=>{var t=d();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`})),p=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=f()})),m=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,ee||(ee=!0,w());else{var t=n(l);t!==null&&oe(x,t.startTime-e)}}var ee=!1,S=-1,C=5,te=-1;function ne(){return g?!0:!(e.unstable_now()-te<C)}function re(){if(g=!1,ee){var t=e.unstable_now();te=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(S),S=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&ne());){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&&oe(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?w():ee=!1}}}var w;if(typeof y==`function`)w=function(){y(re)};else if(typeof MessageChannel<`u`){var ie=new MessageChannel,ae=ie.port2;ie.port1.onmessage=re,w=function(){ae.postMessage(null)}}else w=function(){_(re,0)};function oe(t,n){S=_(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`):C=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(S),S=-1):h=!0,oe(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,ee||(ee=!0,w()))),r},e.unstable_shouldYield=ne,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),h=o(((e,t)=>{t.exports=m()})),g=o((e=>{var t=h(),n=d(),r=p();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 u(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 f(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=f(e),t!==null)return t;e=e.sibling}return null}var m=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`),ee=Symbol.for(`react.consumer`),S=Symbol.for(`react.context`),C=Symbol.for(`react.forward_ref`),te=Symbol.for(`react.suspense`),ne=Symbol.for(`react.suspense_list`),re=Symbol.for(`react.memo`),w=Symbol.for(`react.lazy`),ie=Symbol.for(`react.activity`),ae=Symbol.for(`react.memo_cache_sentinel`),oe=Symbol.iterator;function se(e){return typeof e!=`object`||!e?null:(e=oe&&e[oe]||e[`@@iterator`],typeof e==`function`?e:null)}var ce=Symbol.for(`react.client.reference`);function le(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ce?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 te:return`Suspense`;case ne:return`SuspenseList`;case ie:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case v:return`Portal`;case S:return e.displayName||`Context`;case ee:return(e._context.displayName||`Context`)+`.Consumer`;case C:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case re:return t=e.displayName||null,t===null?le(e.type)||`Memo`:t;case w:t=e._payload,e=e._init;try{return le(e(t))}catch{}}return null}var T=Array.isArray,E=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ue={pending:!1,data:null,method:null,action:null},de=[],fe=-1;function pe(e){return{current:e}}function me(e){0>fe||(e.current=de[fe],de[fe]=null,fe--)}function O(e,t){fe++,de[fe]=e.current,e.current=t}var he=pe(null),ge=pe(null),_e=pe(null),k=pe(null);function ve(e,t){switch(O(_e,t),O(ge,e),O(he,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}me(he),O(he,e)}function ye(){me(he),me(ge),me(_e)}function be(e){e.memoizedState!==null&&O(k,e);var t=he.current,n=Hd(t,e.type);t!==n&&(O(ge,e),O(he,n))}function xe(e){ge.current===e&&(me(he),me(ge)),k.current===e&&(me(k),Qf._currentValue=ue)}var Se,Ce;function we(e){if(Se===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Se=t&&t[1]||``,Ce=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+Se+e+Ce}var Te=!1;function Ee(e,t){if(!e||Te)return``;Te=!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(`
|
|
@@ -269,7 +269,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
269
269
|
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return Sh(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=yg.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function kg(){return{exit:{taskListCheckValueChecked:jg,taskListCheckValueUnchecked:jg,paragraph:Mg}}}function Ag(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:Ng}}}function jg(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function Mg(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function Ng(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=yg.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function Pg(){return[Bm(),uh(),hh(),bg(),kg()]}function Fg(e){return{extensions:[Vm(),dh(e),gh(),Og(e),Ag()]}}var Ig={tokenize:Xg,partial:!0},Lg={tokenize:Zg,partial:!0},Rg={tokenize:Qg,partial:!0},zg={tokenize:$g,partial:!0},Bg={tokenize:e_,partial:!0},Vg={name:`wwwAutolink`,tokenize:Jg,previous:t_},Hg={name:`protocolAutolink`,tokenize:Yg,previous:n_},Ug={name:`emailAutolink`,tokenize:qg,previous:r_},Wg={};function Gg(){return{text:Wg}}for(var Kg=48;Kg<123;)Wg[Kg]=Ug,Kg++,Kg===58?Kg=65:Kg===91&&(Kg=97);Wg[43]=Ug,Wg[45]=Ug,Wg[46]=Ug,Wg[95]=Ug,Wg[72]=[Ug,Hg],Wg[104]=[Ug,Hg],Wg[87]=[Ug,Vg],Wg[119]=[Ug,Vg];function qg(e,t,n){let r=this,i,a;return o;function o(t){return!i_(t)||!r_.call(r,r.previous)||a_(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return i_(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(Bg,u,l)(t):t===45||t===95||Gl(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&Wl(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function Jg(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!t_.call(r,r.previous)||a_(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(Ig,e.attempt(Lg,e.attempt(Rg,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function Yg(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&n_.call(r,r.previous)&&!a_(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(Wl(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||ql(t)||J(t)||Ql(t)||Zl(t)?n(t):e.attempt(Lg,e.attempt(Rg,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function Xg(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function Zg(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(zg,c,s)(t):t===null||J(t)||Ql(t)||t!==45&&Zl(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function Qg(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(zg,t,a)(o):o===null||J(o)||Ql(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function $g(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||J(o)||Ql(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||J(e)||Ql(e)?t(e):r(e)}function a(e){return Wl(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):Wl(t)?(e.consume(t),o):n(t)}}function e_(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return Gl(e)?n(e):t(e)}}function t_(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||J(e)}function n_(e){return!Wl(e)}function r_(e){return!(e===47||i_(e))}function i_(e){return e===43||e===45||e===46||e===95||Gl(e)}function a_(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var o_={tokenize:m_,partial:!0};function s_(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:d_,continuation:{tokenize:f_},exit:p_}},text:{91:{name:`gfmFootnoteCall`,tokenize:u_},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:c_,resolveTo:l_}}}}function c_(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=Ul(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function l_(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function u_(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||J(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(Ul(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return J(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function d_(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||J(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=Ul(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return J(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),X(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function f_(e,t,n){return e.check(hu,t,e.attempt(o_,t,n))}function p_(e){e.exit(`gfmFootnoteDefinition`)}function m_(e,t,n){let r=this;return X(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function h_(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&Vl(o,o.length,0,cu(s,e.slice(r+1,n),t)),Vl(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),Vl(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=su(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=su(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var g_=class{constructor(){this.map=[]}add(e,t,n){__(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function __(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function v_(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function y_(){return{flow:{null:{name:`table`,tokenize:b_,resolveAll:x_}}}}function b_(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?ee:c;return a===ee&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):q(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):Y(t)?X(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||J(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,Y(t)?X(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return Y(t)?X(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||q(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return Y(t)?X(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||q(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function ee(t){return e.enter(`tableRow`),S(t)}function S(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),S):n===null||q(n)?(e.exit(`tableRow`),t(n)):Y(n)?X(e,S,`whitespace`)(n):(e.enter(`data`),C(n))}function C(t){return t===null||t===124||J(t)?(e.exit(`data`),S(t)):(e.consume(t),t===92?te:C)}function te(t){return t===92||t===124?(e.consume(t),C):C(t)}}function x_(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new g_;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(C_(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=S_(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=S_(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=S_(f,t,o,i,n,d)):(o[0]=o[1],d=S_(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&C_(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=v_(t.events,n))}return e}function S_(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},w_(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=w_(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=w_(t.events,n[2]),a=w_(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},w_(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function C_(e,t,n,r,i){let a=[],o=w_(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function w_(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var T_={name:`tasklistCheck`,tokenize:D_};function E_(){return{text:{91:T_}}}function D_(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return J(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return q(r)?t(r):Y(r)?e.check({tokenize:O_},t,n)(r):n(r)}}function O_(e,t,n){return X(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function k_(e){return U([Gg(),s_(),h_(e),y_(),E_()])}var A_={};function j_(e){let t=this,n=e||A_,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(k_(n)),a.push(Pg()),o.push(Fg(n))}var M_=/^(\s*)(\d{1,9})([.)])\s*$/,N_=/^(\s*)([-*+])\s*$/,P_=/^\s*(```|~~~)/;function F_(e){let t=!1;return e.split(`
|
|
270
270
|
`).map(e=>{if(P_.test(e))return t=!t,e;if(t)return e;let n=M_.exec(e);if(n)return`${n[1]}${n[2]}\\${n[3]}`;let r=N_.exec(e);return r?`${r[1]}\\${r[2]}`:e}).join(`
|
|
271
271
|
`)}var I_={default:{h1:`mt-3 mb-1.5 text-[17px] font-semibold`,h2:`mt-3 mb-1.5 text-[16px] font-semibold`,h3:`mt-3 mb-1.5 text-[15px] font-semibold`,code:`text-[12.5px]`,table:`my-1.5 w-full border-collapse text-sm`},compact:{h1:`mt-3 mb-1.5 text-[15px] font-medium`,h2:`mt-3 mb-1.5 text-[14px] font-medium`,h3:`mt-3 mb-1.5 text-[13px] font-medium`,code:`text-[11px]`,table:`my-1.5 w-full border-collapse text-[12px]`}},L_=(0,v.memo)(function({text:e,variant:t=`default`}){let n=Es(),r=I_[t],i=(0,v.useMemo)(()=>({p:e=>(0,R.jsx)(`p`,{className:`my-1.5 first:mt-0 last:mb-0`,...e}),ul:e=>(0,R.jsx)(`ul`,{className:`my-1.5 list-disc pl-5`,...e}),ol:e=>(0,R.jsx)(`ol`,{className:`my-1.5 list-decimal pl-5`,...e}),li:e=>(0,R.jsx)(`li`,{className:`my-0.5`,...e}),h1:e=>(0,R.jsx)(`h1`,{className:r.h1,...e}),h2:e=>(0,R.jsx)(`h2`,{className:r.h2,...e}),h3:e=>(0,R.jsx)(`h3`,{className:r.h3,...e}),a:({style:e,...t})=>(0,R.jsx)(`a`,{className:`underline underline-offset-2`,style:{color:n.primary,...e},target:`_blank`,rel:`noreferrer noopener`,...t}),code:({className:e,style:t,children:i,...a})=>/language-/.test(e??``)?(0,R.jsx)(`code`,{className:Os(`font-aai-mono`,r.code),...a,children:i}):(0,R.jsx)(`code`,{className:Os(`rounded-sm border px-1 py-0.5 font-aai-mono`,r.code),style:{borderColor:n.border,background:ks(n.text,n.surface,3),...t},...a,children:i}),pre:({style:e,...t})=>(0,R.jsx)(`pre`,{className:`my-1.5 overflow-x-auto rounded-md border p-2.5 whitespace-pre-wrap wrap-break-word`,style:{borderColor:n.border,background:ks(n.text,n.surface,3),...e},...t}),blockquote:({style:e,...t})=>(0,R.jsx)(`blockquote`,{className:`my-1.5 border-l-2 pl-3`,style:{borderColor:n.border,color:ks(n.text,n.surface,75),...e},...t}),table:e=>(0,R.jsx)(`table`,{className:r.table,...e}),th:({style:e,...t})=>(0,R.jsx)(`th`,{className:`border px-2 py-1 text-left font-medium`,style:{borderColor:n.border,...e},...t}),td:({style:e,...t})=>(0,R.jsx)(`td`,{className:`border px-2 py-1`,style:{borderColor:n.border,...e},...t}),hr:({style:e,...t})=>(0,R.jsx)(`hr`,{className:`my-2.5 border-t`,style:{borderColor:n.border,...e},...t})}),[n,r]);return(0,R.jsx)(Dm,{remarkPlugins:[j_],components:i,children:F_(e)})}),R_={default:{button:`gap-2.5 px-3.5 py-2.5`,title:`text-[13px]`,chevron:`text-[10px]`},compact:{button:`gap-2 px-3 py-2`,title:`text-[11px]`,chevron:`text-[9px]`}};function z_({title:e,detail:t,pending:n=!1,icon:r,variant:i=`default`,className:a,children:o}){let[s,c]=(0,v.useState)(!1),l=Es(),u=R_[i],d=o!=null;return(0,R.jsxs)(`div`,{className:Os(`flex flex-col rounded-md border overflow-hidden`,a),style:{borderColor:l.border,background:l.bg},children:[(0,R.jsxs)(`button`,{type:`button`,"aria-expanded":d?s:void 0,disabled:!d,className:Os(`flex items-center select-none text-left w-full appearance-none border-none bg-transparent`,u.button,d&&`cursor-pointer`),onClick:()=>{d&&c(!s)},children:[r?(0,R.jsx)(`span`,{className:`w-4 h-4 shrink-0 text-center leading-4`,children:r}):(0,R.jsx)(Fs,{className:`shrink-0`,style:{color:ks(l.text,l.bg,65)},children:`Tool`}),(0,R.jsx)(`span`,{className:Os(`min-w-0 truncate font-aai-mono font-medium`,u.title,n&&`tool-shimmer`),style:{color:l.text},children:e}),(0,R.jsx)(`span`,{className:Os(`font-aai-mono truncate flex-1 min-w-0`,u.title),style:{color:ks(l.text,l.bg,65)},children:t}),d&&(0,R.jsx)(`span`,{className:Os(`shrink-0 transition-transform duration-150`,u.chevron,s&&`rotate-90`),style:{color:ks(l.text,l.bg,65)},children:`▶`})]}),s&&d&&(0,R.jsx)(`div`,{className:`border-t max-h-64 overflow-auto`,style:{borderColor:l.border,background:l.surface},children:o})]})}var B_=(0,v.createContext)({});function V_(){return(0,v.useContext)(B_)}function H_(e){let t=Xo(e);return t===e?e:JSON.stringify(t,null,2)}var U_=(0,v.memo)(function({toolCall:e,className:t}){let n=Es(),r=V_(),i=Object.hasOwn(r,e.name)?r[e.name]:void 0,a=e.status===`pending`,o=i?.label||e.name,s=i?.icon,c=!a&&!!e.result,l=(0,v.useMemo)(()=>e.result?H_(e.result):``,[e.result]);return(0,R.jsx)(z_,{title:o,detail:(0,v.useMemo)(()=>{let t=e.args;if(e.name===`run_code`&&t.code)return Zo(String(t.code).split(`
|
|
272
|
-
`)[0]??``);for(let e of[`query`,`url`,`question`])if(t[e])return String(t[e]);return Zo(JSON.stringify(t))},[e.name,e.args]),pending:a,icon:s,className:t,children:c?(0,R.jsxs)(R.Fragment,{children:[e.name===`run_code`&&!!e.args.code&&(0,R.jsx)(`pre`,{className:`font-aai-mono text-xs px-3.5 py-3 m-0 whitespace-pre-wrap wrap-break-word border-b`,style:{color:n.text,borderColor:n.border},children:String(e.args.code)}),l&&(0,R.jsx)(`pre`,{className:`font-aai-mono text-xs px-3.5 py-3 m-0 whitespace-pre-wrap wrap-break-word`,style:{color:ks(n.text,n.surface,75)},children:l})]}):void 0})}),W_=[0,.16,.32].map(e=>({animation:`aai-bounce 1.4s infinite ease-in-out both`,animationDelay:`${e}s`}));function G_(){let e=Es(),t=ks(e.text,e.surface,75);return(0,R.jsx)(`div`,{className:`flex items-center gap-2 text-sm font-medium min-h-5`,style:{color:t},children:W_.map((e,n)=>(0,R.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full`,style:{...e,background:t}},n))})}function K_({theme:e,color:t,children:n}){return(0,R.jsx)(`div`,{className:`flex flex-col w-full items-end`,children:(0,R.jsx)(`div`,{className:`max-w-[min(78%,64ch)] border px-3.5 py-2.5 rounded-md whitespace-pre-wrap wrap-break-word text-[15px] font-normal leading-[22px]`,style:{background:Ms(e.primary,e.surface,7),borderColor:Ms(e.primary,e.surface,16),color:t},children:n})})}var q_=(0,v.memo)(function({message:e,theme:t}){return e.role===`user`?(0,R.jsx)(K_,{theme:t,color:t.text,children:e.content}):(0,R.jsxs)(`div`,{className:`flex flex-col gap-1 max-w-[82%]`,children:[(0,R.jsx)(`span`,{className:`text-[10px] font-medium tracking-[1.2px] uppercase leading-none`,style:{color:ks(t.text,t.surface,65)},children:`Agent`}),(0,R.jsx)(`div`,{className:`wrap-break-word text-[15px] font-normal leading-[23px]`,style:{color:t.text},children:(0,R.jsx)(L_,{text:e.content})})]})});function J_(e,t,n,r){let i=[],a=0,o=e=>{let n=t[a];for(;n&&n.afterMessageId<=e;)i.push(r(n)),a++,n=t[a]},s=e[0];s&&o(s.id-1);for(let t of e)i.push(n(t)),o(t.id);return o(1/0),i}var Y_=(0,v.memo)(function({className:e}){let t=Ss(e=>e.state),n=Ss(e=>e.messages),r=Ss(e=>e.toolCalls),i=Ss(e=>e.userTranscript),a=Ss(e=>e.agentTranscript),o=Es(),s=(0,v.useMemo)(()=>{if(t!==`thinking`)return!1;let e=r.at(-1);if(e?.status===`pending`)return!1;let i=n.at(-1);return!i||i.role===`user`||!!e},[t,r,n]),c=(0,v.useMemo)(()=>a?{role:`assistant`,content:a}:null,[a]),l=(0,v.useMemo)(()=>J_(n,r,e=>(0,R.jsx)(q_,{message:e,theme:o},e.id),e=>(0,R.jsx)(U_,{toolCall:e},e.callId)),[n,r,o]);return(0,R.jsx)(nc,{role:`log`,className:Os(`flex-1 min-h-0`,e),style:{background:o.surface},initial:`instant`,resize:`smooth`,children:(0,R.jsxs)(nc.Content,{scrollClassName:`overflow-y-auto [scrollbar-width:none]`,className:`flex flex-col gap-4 p-7`,children:[l,c&&(0,R.jsx)(q_,{message:c,theme:o}),i!==null&&(0,R.jsx)(K_,{theme:o,color:ks(o.text,o.surface,65),children:i||(0,R.jsx)(G_,{})}),s&&(0,R.jsx)(G_,{})]})})}),X_=new Set([`listening`,`speaking`]);function Z_({icon:e,title:t,className:n}){let r=Ss(e=>e.state),i=Ss(e=>e.error);return(0,R.jsx)(Ls,{icon:e,title:t,state:r,pulsing:X_.has(r),error:i?.message,className:n,footer:(0,R.jsx)(Ws,{}),children:(0,R.jsx)(Y_,{})})}function Q_({sidebar:e,children:t,sidebarWidth:n=`18rem`,sidebarPosition:r=`left`,className:i}){let a=Es(),o=(0,R.jsx)(`div`,{className:Os(`shrink-0 flex flex-col overflow-y-auto`,`w-full max-h-[40vh] md:w-(--aai-sidebar-w) md:max-h-none`,r===`left`?`border-b md:border-b-0 md:border-r`:`border-t md:border-t-0 md:border-l order-last md:order-none`),style:{borderColor:a.border},children:e}),s={background:a.bg,"--aai-sidebar-w":n};return(0,R.jsxs)(`div`,{className:Os(`flex flex-col md:flex-row min-h-screen md:h-screen`,i),style:s,children:[r===`left`&&o,(0,R.jsx)(`div`,{className:`flex-1 min-w-0 min-h-0`,children:t}),r===`right`&&o]})}function $_({children:e,icon:t,title:n,subtitle:r,buttonText:i=`Start Conversation`,className:a}){let o=Ss(e=>e.started),{start:s}=xs(),c=Es();return o?e:(0,R.jsx)(`div`,{className:Os(`flex items-center justify-center h-screen font-aai`,a),style:{background:c.bg},children:(0,R.jsxs)(`div`,{className:`flex flex-col items-center gap-5 border rounded-xl px-10 py-12 sm:px-16 sm:py-14 max-w-105 text-center`,style:{background:c.surface,borderColor:c.border,boxShadow:`0 4px 12px -2px rgb(20 18 12 / 0.08)`},children:[t??(0,R.jsx)(Ps,{size:24}),(0,R.jsx)(Fs,{children:`Voice Agent`}),n&&(0,R.jsx)(`h1`,{className:`font-aai-serif font-normal text-[32px] leading-[1.15] tracking-[-0.2px] m-0 text-balance`,style:{color:c.text},children:n}),r&&(0,R.jsx)(`p`,{className:`text-[15px] leading-[22px] m-0 max-w-75`,style:{color:ks(c.text,c.surface,75)},children:r}),(0,R.jsx)(Rs,{size:`lg`,className:`mt-2`,onClick:s,children:i})]})})}function ev(){let e=0;return{current:()=>e,bump(){e+=1},isCurrent:t=>t===e}}var tv=`modulepreload`,nv=function(e,t){return new URL(e,t).href},rv={},iv=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=nv(t,n),t=s(t),t in rv)return;rv[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:tv,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},av=null;function ov(){return av??=Promise.all([iv(()=>import(`./audio-
|
|
272
|
+
`)[0]??``);for(let e of[`query`,`url`,`question`])if(t[e])return String(t[e]);return Zo(JSON.stringify(t))},[e.name,e.args]),pending:a,icon:s,className:t,children:c?(0,R.jsxs)(R.Fragment,{children:[e.name===`run_code`&&!!e.args.code&&(0,R.jsx)(`pre`,{className:`font-aai-mono text-xs px-3.5 py-3 m-0 whitespace-pre-wrap wrap-break-word border-b`,style:{color:n.text,borderColor:n.border},children:String(e.args.code)}),l&&(0,R.jsx)(`pre`,{className:`font-aai-mono text-xs px-3.5 py-3 m-0 whitespace-pre-wrap wrap-break-word`,style:{color:ks(n.text,n.surface,75)},children:l})]}):void 0})}),W_=[0,.16,.32].map(e=>({animation:`aai-bounce 1.4s infinite ease-in-out both`,animationDelay:`${e}s`}));function G_(){let e=Es(),t=ks(e.text,e.surface,75);return(0,R.jsx)(`div`,{className:`flex items-center gap-2 text-sm font-medium min-h-5`,style:{color:t},children:W_.map((e,n)=>(0,R.jsx)(`div`,{className:`w-1.5 h-1.5 rounded-full`,style:{...e,background:t}},n))})}function K_({theme:e,color:t,children:n}){return(0,R.jsx)(`div`,{className:`flex flex-col w-full items-end`,children:(0,R.jsx)(`div`,{className:`max-w-[min(78%,64ch)] border px-3.5 py-2.5 rounded-md whitespace-pre-wrap wrap-break-word text-[15px] font-normal leading-[22px]`,style:{background:Ms(e.primary,e.surface,7),borderColor:Ms(e.primary,e.surface,16),color:t},children:n})})}var q_=(0,v.memo)(function({message:e,theme:t}){return e.role===`user`?(0,R.jsx)(K_,{theme:t,color:t.text,children:e.content}):(0,R.jsxs)(`div`,{className:`flex flex-col gap-1 max-w-[82%]`,children:[(0,R.jsx)(`span`,{className:`text-[10px] font-medium tracking-[1.2px] uppercase leading-none`,style:{color:ks(t.text,t.surface,65)},children:`Agent`}),(0,R.jsx)(`div`,{className:`wrap-break-word text-[15px] font-normal leading-[23px]`,style:{color:t.text},children:(0,R.jsx)(L_,{text:e.content})})]})});function J_(e,t,n,r){let i=[],a=0,o=e=>{let n=t[a];for(;n&&n.afterMessageId<=e;)i.push(r(n)),a++,n=t[a]},s=e[0];s&&o(s.id-1);for(let t of e)i.push(n(t)),o(t.id);return o(1/0),i}var Y_=(0,v.memo)(function({className:e}){let t=Ss(e=>e.state),n=Ss(e=>e.messages),r=Ss(e=>e.toolCalls),i=Ss(e=>e.userTranscript),a=Ss(e=>e.agentTranscript),o=Es(),s=(0,v.useMemo)(()=>{if(t!==`thinking`)return!1;let e=r.at(-1);if(e?.status===`pending`)return!1;let i=n.at(-1);return!i||i.role===`user`||!!e},[t,r,n]),c=(0,v.useMemo)(()=>a?{role:`assistant`,content:a}:null,[a]),l=(0,v.useMemo)(()=>J_(n,r,e=>(0,R.jsx)(q_,{message:e,theme:o},e.id),e=>(0,R.jsx)(U_,{toolCall:e},e.callId)),[n,r,o]);return(0,R.jsx)(nc,{role:`log`,className:Os(`flex-1 min-h-0`,e),style:{background:o.surface},initial:`instant`,resize:`smooth`,children:(0,R.jsxs)(nc.Content,{scrollClassName:`overflow-y-auto [scrollbar-width:none]`,className:`flex flex-col gap-4 p-7`,children:[l,c&&(0,R.jsx)(q_,{message:c,theme:o}),i!==null&&(0,R.jsx)(K_,{theme:o,color:ks(o.text,o.surface,65),children:i||(0,R.jsx)(G_,{})}),s&&(0,R.jsx)(G_,{})]})})}),X_=new Set([`listening`,`speaking`]);function Z_({icon:e,title:t,className:n}){let r=Ss(e=>e.state),i=Ss(e=>e.error);return(0,R.jsx)(Ls,{icon:e,title:t,state:r,pulsing:X_.has(r),error:i?.message,className:n,footer:(0,R.jsx)(Ws,{}),children:(0,R.jsx)(Y_,{})})}function Q_({sidebar:e,children:t,sidebarWidth:n=`18rem`,sidebarPosition:r=`left`,className:i}){let a=Es(),o=(0,R.jsx)(`div`,{className:Os(`shrink-0 flex flex-col overflow-y-auto`,`w-full max-h-[40vh] md:w-(--aai-sidebar-w) md:max-h-none`,r===`left`?`border-b md:border-b-0 md:border-r`:`border-t md:border-t-0 md:border-l order-last md:order-none`),style:{borderColor:a.border},children:e}),s={background:a.bg,"--aai-sidebar-w":n};return(0,R.jsxs)(`div`,{className:Os(`flex flex-col md:flex-row min-h-screen md:h-screen`,i),style:s,children:[r===`left`&&o,(0,R.jsx)(`div`,{className:`flex-1 min-w-0 min-h-0`,children:t}),r===`right`&&o]})}function $_({children:e,icon:t,title:n,subtitle:r,buttonText:i=`Start Conversation`,className:a}){let o=Ss(e=>e.started),{start:s}=xs(),c=Es();return o?e:(0,R.jsx)(`div`,{className:Os(`flex items-center justify-center h-screen font-aai`,a),style:{background:c.bg},children:(0,R.jsxs)(`div`,{className:`flex flex-col items-center gap-5 border rounded-xl px-10 py-12 sm:px-16 sm:py-14 max-w-105 text-center`,style:{background:c.surface,borderColor:c.border,boxShadow:`0 4px 12px -2px rgb(20 18 12 / 0.08)`},children:[t??(0,R.jsx)(Ps,{size:24}),(0,R.jsx)(Fs,{children:`Voice Agent`}),n&&(0,R.jsx)(`h1`,{className:`font-aai-serif font-normal text-[32px] leading-[1.15] tracking-[-0.2px] m-0 text-balance`,style:{color:c.text},children:n}),r&&(0,R.jsx)(`p`,{className:`text-[15px] leading-[22px] m-0 max-w-75`,style:{color:ks(c.text,c.surface,75)},children:r}),(0,R.jsx)(Rs,{size:`lg`,className:`mt-2`,onClick:s,children:i})]})})}function ev(){let e=0;return{current:()=>e,bump(){e+=1},isCurrent:t=>t===e}}var tv=`modulepreload`,nv=function(e,t){return new URL(e,t).href},rv={},iv=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=nv(t,n),t=s(t),t in rv)return;rv[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:tv,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},av=null;function ov(){return av??=Promise.all([iv(()=>import(`./audio-BqyrSHNq.js`),[],import.meta.url),iv(()=>import(`./capture-processor-CWRLCPS3.js`).then(e=>e.default),__vite__mapDeps([0,1]),import.meta.url),iv(()=>import(`./playback-processor-SKKE9qu2.js`).then(e=>e.default),__vite__mapDeps([2,1]),import.meta.url)]).catch(e=>{throw av=null,e}),av}async function sv(e,t,n){if(e.audioSetupInFlight)return;e.audioSetupInFlight=!0;let r=e.generation.current(),i=()=>!(e.generation.isCurrent(r)&&e.ws)||e.ws.readyState!==1,a=e=>{n.cleanupAudio(),n.updateState({state:`error`,error:{code:`audio`,message:e},running:!1,recording:!1})};try{let[{createVoiceIO:o},s,c]=await ov(),l=await o({sttSampleRate:t.sampleRate,ttsSampleRate:t.ttsSampleRate,captureWorkletSrc:s,playbackWorkletSrc:c,onMicData:e=>{try{n.sendAudio(e)}catch{console.debug(`[aai-ui] sendAudio dropped: connection closed`)}},onPlaybackProgress:t=>{if(e.generation.isCurrent(r))try{n.sendJson({type:`playback_progress`,bufferedMs:t})}catch{}},onError:t=>{e.generation.isCurrent(r)&&a(t.message)}});if(i()){l.close().catch(()=>{});return}if(e.voiceIO?.close().catch(()=>{}),e.voiceIO=l,e.preInitAudio.length>0){for(let t of e.preInitAudio)l.enqueue(t);e.preInitAudio=[]}n.sendJson({type:`audio_ready`}),n.updateState({recording:!0}),e.preInitDone?(e.preInitDone=!1,n.settleWhenAudioDrained(l)):n.updateState({state:`listening`})}catch(e){if(i())return;a(`Microphone access failed: ${Ko(e)}`)}finally{e.generation.isCurrent(r)&&(e.audioSetupInFlight=!1)}}(!globalThis.EventTarget||!globalThis.Event)&&console.error(`
|
|
273
273
|
PartySocket requires a global 'EventTarget' class to be available!
|
|
274
274
|
You can polyfill this global by adding this to your code before any partysocket imports:
|
|
275
275
|
|
|
@@ -290,4 +290,4 @@ const partysocket = new PartySocket({
|
|
|
290
290
|
WebSocket: WS
|
|
291
291
|
});
|
|
292
292
|
|
|
293
|
-
`),vv=!0);let r=this._options.WebSocket||WebSocket;this._debug(`connect`,{url:e,protocols:n}),this._ws=n?new r(e,n):new r(e),this._ws.binaryType=this._binaryType,this._connectLock=!1,this._addListeners(),this._connectTimeout=setTimeout(()=>this._handleTimeout(),t)}).catch(e=>{this._connectLock=!1,this._handleError(new uv.ErrorEvent(Error(e.message),this))})}_handleTimeout(){this._debug(`timeout event`),this._handleError(new uv.ErrorEvent(Error(`TIMEOUT`),this))}_disconnect(e=1e3,t){if(this._clearTimeouts(),this._ws){this._removeListeners();try{(this._ws.readyState===this.OPEN||this._ws.readyState===this.CONNECTING)&&this._ws.close(e,t),this._handleClose(new uv.CloseEvent(e,t,this))}catch{}}}_acceptOpen(){this._debug(`accept open`),this._retryCount=0}_handleOpen=e=>{this._debug(`open event`);let{minUptime:t=_v.minUptime}=this._options;clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),t),dv(this._ws,`WebSocket is not defined`),this._ws.binaryType=this._binaryType,this._messageQueue.forEach(e=>{this._ws?.send(e)}),this._messageQueue=[],this.onopen&&this.onopen(e),this.dispatchEvent(gv(e))};_handleMessage=e=>{this._debug(`message event`),this.onmessage&&this.onmessage(e),this.dispatchEvent(gv(e))};_handleError=e=>{this._debug(`error event`,e.message),this._disconnect(void 0,e.message===`TIMEOUT`?`timeout`:void 0),this.onerror&&this.onerror(e),this._debug(`exec error listeners`),this.dispatchEvent(gv(e)),this._connect()};_handleClose=e=>{this._debug(`close event`),this._clearTimeouts(),this._options.shouldReconnectOnClose&&!this._options.shouldReconnectOnClose(e)&&(this._shouldReconnect=!1),this._shouldReconnect&&this._connect(),this.onclose&&this.onclose(e),this.dispatchEvent(gv(e))};_removeListeners(){this._ws&&(this._debug(`removeListeners`),this._ws.removeEventListener(`open`,this._handleOpen),this._ws.removeEventListener(`close`,this._handleClose),this._ws.removeEventListener(`message`,this._handleMessage),this._ws.removeEventListener(`error`,this._handleError),this._ws.addEventListener(`error`,yv))}_addListeners(){this._ws&&(this._debug(`addListeners`),this._ws.addEventListener(`open`,this._handleOpen),this._ws.addEventListener(`close`,this._handleClose),this._ws.addEventListener(`message`,this._handleMessage),this._ws.addEventListener(`error`,this._handleError))}_clearTimeouts(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)}},xv={minReconnectionDelay:1e3,maxReconnectionDelay:15e3,reconnectionDelayGrowFactor:2,maxRetries:10};function Sv(e){return new bv(e,void 0,xv)}function Cv(e){return e instanceof bv?(e.reconnect(),!0):!1}function wv(e){return e instanceof bv&&e.shouldReconnect&&e.retryCount<xv.maxRetries}var Tv={code:`connection`,message:`Agent did not complete the session handshake`},Ev=1e4,Dv=3;function Ov(e){let t,n=0;function r(){t!==void 0&&(clearTimeout(t),t=void 0)}function i(){if(t=void 0,n+=1,n<Dv&&Cv(e.socket)){e.onRetry();return}e.onExhausted()}return e.signal.addEventListener(`abort`,r),{arm(){r(),t=setTimeout(i,Ev)},disarm:r}}var kv=200,Av=200,jv=100,Mv={messages:[],toolCalls:[],customEvents:[],agentState:null,userTranscript:null,agentTranscript:null,error:null};function Nv(e,t,n){if(e.length<n)return[...e,t];let r=e.slice(e.length-n+1);return r.push(t),r}function Pv(e){let{getSnapshot:t,updateState:n,conn:r,cleanupAudio:i}=e,a=0,o=0,s=0;function c(e,r){n({customEvents:Nv(t().customEvents,{id:++a,event:e,data:r},kv)})}function l(e){r.turn.bump(),n({userTranscript:null,messages:Nv(t().messages,{id:++o,role:`user`,content:e},Av),state:`thinking`})}function u(e){n({agentTranscript:e})}function d(){let e=t().agentTranscript;if(e===null||e.length===0){n({agentTranscript:null});return}n({agentTranscript:null,messages:Nv(t().messages,{id:++o,role:`assistant`,content:e},Av)})}function f(){let e=t();e.state===`error`?n({state:`listening`,error:null}):e.error!==null&&n({error:null})}function p(e){console.error(`Agent error:`,e.message),e.fatal===!1?n({error:{code:e.code,message:e.message}}):(i(),r.generation.bump(),n({state:`error`,error:{code:e.code,message:e.message},running:!1,recording:!1}))}function m(i){switch(i.type!==`error`&&f(),i.type){case`speech_started`:n({userTranscript:``});break;case`speech_stopped`:break;case`user_transcript`:l(i.text);break;case`user_transcript_partial`:n({userTranscript:i.text});break;case`agent_transcript`:u(i.text);break;case`tool_call`:n({toolCalls:Nv(t().toolCalls,{callId:i.toolCallId,name:i.toolName,args:Yo(i.args),status:`pending`,seq:++s,afterMessageId:t().messages.at(-1)?.id??-1},Av)});break;case`tool_call_done`:{let e=t().toolCalls,r=e.findIndex(e=>e.callId===i.toolCallId);if(r!==-1){let t=[...e],a=t[r];a&&(t[r]={...a,status:`done`,result:i.result}),n({toolCalls:t})}break}case`reply_done`:d(),n({state:`listening`});break;case`cancelled`:r.turn.bump(),r.voiceIO?.flush(),d(),n({userTranscript:null,state:`listening`});break;case`reset`:r.turn.bump(),r.voiceIO?.flush(),n({...Mv,state:`listening`});break;case`custom_event`:c(i.event,i.data);break;case`agent_state`:n({agentState:i.state});break;case`error`:p(i);break;case`idle_timeout`:e.conn.retiredByServer=!0;break;default:break}}function h(e){let i=t();i.state===`error`||i.state===`disconnected`&&i.error!==null||(i.state!==`speaking`&&n({state:`speaking`}),r.voiceIO?r.voiceIO.enqueue(e):r.preInitAudio.length<jv&&r.preInitAudio.push(e))}function g(e){let t=r.turn.current();e.done().then(()=>{r.turn.isCurrent(t)&&n({state:`listening`})}).catch(e=>{console.warn(`Audio playback done failed:`,e)})}function _(){let e=r.voiceIO;e?g(e):(r.preInitDone=!0,n({state:`listening`}))}function v(e){if(e instanceof ArrayBuffer){h(e);return}if(typeof e!=`string`){console.warn(`session-core: non-string, non-binary frame received; dropping`);return}let t=qo(e);if(t===void 0){console.warn(`session-core: invalid JSON; dropping`);return}let n=is(ls,t);if(!n.ok){n.malformed&&console.warn(`session-core: malformed server message`,n.error);return}let r=n.data;if(r.type===`config`)return{sampleRate:r.sampleRate,ttsSampleRate:r.ttsSampleRate,sid:r.sessionId};if(r.type===`audio_done`){_();return}m(r)}return{handleMessage:v,settleWhenAudioDrained:g}}function Fv(e,t,n){return Rv(ds(e,`websocket`),t,n)}function Iv(e,t,n){return Rv(new URL(e),t,n)}var Lv={"https:":`wss:`,"http:":`ws:`};function Rv(e,t,n){return e.protocol=Lv[e.protocol]??e.protocol,n?e.searchParams.set(`sessionId`,n):t&&e.searchParams.set(`resume`,`1`),e}var zv={echoCancellation:!0,noiseSuppression:!1,autoGainControl:!1,voiceIsolation:!1};function Bv(e){let t={...Mv,state:`disconnected`,contentVersion:0,started:!1,running:!1,recording:!1,apiUrl:Fv(e.platformUrl,!1).toString()},n=new Set;function r(){for(let e of n)e()}let i=[`messages`,`toolCalls`,`userTranscript`,`agentTranscript`];function a(e){t=i.some(n=>n in e&&e[n]!==t[n])?{...t,...e,contentVersion:t.contentVersion+1}:{...t,...e},r()}function o(){return t}function s(e){return n.add(e),()=>{n.delete(e)}}let c={ws:null,retiredByServer:!1,voiceIO:null,audioSetupInFlight:!1,generation:ev(),turn:ev(),preInitAudio:[],preInitDone:!1},l=null,u=!1,d=e.resumeSessionId,f;function p(){c.audioSetupInFlight=!1,c.turn.bump(),c.voiceIO?.close().catch(()=>{}),c.voiceIO=null,c.preInitAudio=[],c.preInitDone=!1}function m(){a(Mv)}function h(e){c.ws&&c.ws.readyState===1&&c.ws.send(JSON.stringify(e))}function g(e){!c.ws||c.ws.readyState!==1||c.ws.bufferedAmount>65536||c.ws.send(e)}let{handleMessage:_,settleWhenAudioDrained:v}=Pv({getSnapshot:o,updateState:a,conn:c,cleanupAudio:p}),y={sendJson:h,sendAudio:g,updateState:a,settleWhenAudioDrained:v,cleanupAudio:p};function b(){l?.abort(),l=null,p(),c.ws?.close(),c.ws=null}function x(n){n.sid&&(d=n.sid,e.onSessionId?.(n.sid));let r=u;u=!0,sv(c,n,y),r&&t.messages.length>0&&h({type:`history`,messages:t.messages.map(e=>({role:e.role,content:e.content}))})}async function ee(){let t=f===!1?null:await ms(e.platformUrl);return t&&(f=t.sessionUrl!==void 0),(t?.sessionUrl?Iv(t.sessionUrl,u,d):Fv(e.platformUrl,u,d)).toString()}function S(){return e.WebSocket?new e.WebSocket(Fv(e.platformUrl,u,d).toString()):Sv(ee)}function C(e){if(e?.signal?.aborted){re();return}a({state:`connecting`,error:null}),ov().catch(()=>{}),b(),c.generation.bump(),c.retiredByServer=!1;let n=new AbortController;l=n;let{signal:r}=n;e?.signal&&e.signal.addEventListener(`abort`,()=>re(),{signal:r});let i=S();i.binaryType=`arraybuffer`,c.ws=i;let o=!1,s=Ov({socket:i,signal:r,onRetry:()=>{p(),c.generation.bump(),a({state:`connecting`,recording:!1})},onExhausted:()=>{p(),n.abort(),i.close(),c.ws=null,a({state:`error`,error:Tv,running:!1,recording:!1})}});i.addEventListener(`open`,()=>{a({state:`ready`}),s.arm()},{signal:r}),i.addEventListener(`message`,e=>{let t=_(e.data);t&&(s.disarm(),x(t))},{signal:r}),i.addEventListener(`error`,()=>{o=!0},{signal:r}),i.addEventListener(`close`,()=>{if(!r.aborted){if(s.disarm(),p(),!c.retiredByServer&&wv(i)){c.generation.bump(),o=!1,a({state:`connecting`,recording:!1});return}n.abort(),i.close(),c.ws=null,o?a({state:`error`,error:{code:`connection`,message:`WebSocket connection error`},running:!1,recording:!1}):t.state===`error`?a({running:!1,recording:!1}):a({state:`disconnected`,error:null,running:!1,recording:!1})}},{signal:r})}function te(){!c.ws||c.ws.readyState!==1||(c.turn.bump(),c.voiceIO?.flush(),a({state:`listening`}),h({type:`cancel`}))}function ne(){if(c.turn.bump(),c.voiceIO?.flush(),c.ws&&c.ws.readyState===1){h({type:`reset`});return}ae(),w()}function re(){b(),a({state:`disconnected`,running:!1,recording:!1})}function w(){a({started:!0,running:!0}),C()}function ie(){t.running?re():(a({running:!0}),C())}function ae(){b(),d=void 0,u=!1,a({...Mv,state:`disconnected`,started:!1,running:!1,recording:!1})}return{getSnapshot:o,subscribe:s,connect:C,cancel:te,resetState:m,reset:ne,disconnect:re,start:w,toggle:ie,end:ae,[Symbol.dispose](){re()}}}function Vv(e=`#app`){if(typeof e!=`string`)return e;let t=document.querySelector(e);if(!t)throw Error(`Element not found: ${e}`);return t}function Hv({name:e,Sidebar:t,sidebarWidth:n}){let r=(0,R.jsx)(Z_,{title:e});return(0,R.jsx)($_,{title:e,children:t?(0,R.jsx)(Q_,{sidebar:(0,R.jsx)(t,{}),sidebarWidth:n,children:r}):r})}function Uv({platformUrl:e,name:t,Sidebar:n,sidebarWidth:r}){let[i,a]=(0,v.useState)(null);return(0,v.useEffect)(()=>{let t=!1;return hs(e).then(e=>{t||a(e)}),()=>{t=!0}},[e]),(0,R.jsx)(Hv,{name:t??i?.name,Sidebar:n,sidebarWidth:r})}function Wv(e){let t=Vv(e.target),n=e.platformUrl??Qo(),r=Bv({platformUrl:n,onSessionId:e.onSessionId,resumeSessionId:e.resumeSessionId,WebSocket:e.WebSocket});e.name&&typeof document<`u`&&(document.title=e.name);let i=e.component?(0,v.createElement)(e.component):(0,v.createElement)(Uv,{platformUrl:n,name:e.name,Sidebar:e.sidebar,sidebarWidth:e.sidebarWidth}),a=e.tools??{},o=(0,b.createRoot)(t);(0,y.flushSync)(()=>{o.render((0,v.createElement)(B_.Provider,{value:a},(0,v.createElement)(ws,{value:e.theme},(0,v.createElement)(bs,{value:r},i))))});let s={session:r,dispose(){o.unmount(),r[Symbol.dispose]()},[Symbol.dispose](){s.dispose()}};return s}Wv({});export{te as a,S as i,x as n,C as o,ee as r,zv as t};
|
|
293
|
+
`),vv=!0);let r=this._options.WebSocket||WebSocket;this._debug(`connect`,{url:e,protocols:n}),this._ws=n?new r(e,n):new r(e),this._ws.binaryType=this._binaryType,this._connectLock=!1,this._addListeners(),this._connectTimeout=setTimeout(()=>this._handleTimeout(),t)}).catch(e=>{this._connectLock=!1,this._handleError(new uv.ErrorEvent(Error(e.message),this))})}_handleTimeout(){this._debug(`timeout event`),this._handleError(new uv.ErrorEvent(Error(`TIMEOUT`),this))}_disconnect(e=1e3,t){if(this._clearTimeouts(),this._ws){this._removeListeners();try{(this._ws.readyState===this.OPEN||this._ws.readyState===this.CONNECTING)&&this._ws.close(e,t),this._handleClose(new uv.CloseEvent(e,t,this))}catch{}}}_acceptOpen(){this._debug(`accept open`),this._retryCount=0}_handleOpen=e=>{this._debug(`open event`);let{minUptime:t=_v.minUptime}=this._options;clearTimeout(this._connectTimeout),this._uptimeTimeout=setTimeout(()=>this._acceptOpen(),t),dv(this._ws,`WebSocket is not defined`),this._ws.binaryType=this._binaryType,this._messageQueue.forEach(e=>{this._ws?.send(e)}),this._messageQueue=[],this.onopen&&this.onopen(e),this.dispatchEvent(gv(e))};_handleMessage=e=>{this._debug(`message event`),this.onmessage&&this.onmessage(e),this.dispatchEvent(gv(e))};_handleError=e=>{this._debug(`error event`,e.message),this._disconnect(void 0,e.message===`TIMEOUT`?`timeout`:void 0),this.onerror&&this.onerror(e),this._debug(`exec error listeners`),this.dispatchEvent(gv(e)),this._connect()};_handleClose=e=>{this._debug(`close event`),this._clearTimeouts(),this._options.shouldReconnectOnClose&&!this._options.shouldReconnectOnClose(e)&&(this._shouldReconnect=!1),this._shouldReconnect&&this._connect(),this.onclose&&this.onclose(e),this.dispatchEvent(gv(e))};_removeListeners(){this._ws&&(this._debug(`removeListeners`),this._ws.removeEventListener(`open`,this._handleOpen),this._ws.removeEventListener(`close`,this._handleClose),this._ws.removeEventListener(`message`,this._handleMessage),this._ws.removeEventListener(`error`,this._handleError),this._ws.addEventListener(`error`,yv))}_addListeners(){this._ws&&(this._debug(`addListeners`),this._ws.addEventListener(`open`,this._handleOpen),this._ws.addEventListener(`close`,this._handleClose),this._ws.addEventListener(`message`,this._handleMessage),this._ws.addEventListener(`error`,this._handleError))}_clearTimeouts(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)}},xv={minReconnectionDelay:1e3,maxReconnectionDelay:15e3,reconnectionDelayGrowFactor:2,maxRetries:10};function Sv(e){return new bv(e,void 0,xv)}function Cv(e){return e instanceof bv?(e.reconnect(),!0):!1}function wv(e){return e instanceof bv&&e.shouldReconnect&&e.retryCount<xv.maxRetries}var Tv={code:`connection`,message:`Agent did not complete the session handshake`},Ev=1e4,Dv=3;function Ov(e){let t,n=0;function r(){t!==void 0&&(clearTimeout(t),t=void 0)}function i(){if(t=void 0,n+=1,n<Dv&&Cv(e.socket)){e.onRetry();return}e.onExhausted()}return e.signal.addEventListener(`abort`,r),{arm(){r(),t=setTimeout(i,Ev)},disarm:r}}var kv=200,Av=200,jv=100,Mv={messages:[],toolCalls:[],customEvents:[],agentState:null,userTranscript:null,agentTranscript:null,error:null};function Nv(e,t,n){if(e.length<n)return[...e,t];let r=e.slice(e.length-n+1);return r.push(t),r}function Pv(e){let{getSnapshot:t,updateState:n,conn:r,cleanupAudio:i}=e,a=0,o=0,s=0;function c(e,r){n({customEvents:Nv(t().customEvents,{id:++a,event:e,data:r},kv)})}function l(e){r.turn.bump(),n({userTranscript:null,messages:Nv(t().messages,{id:++o,role:`user`,content:e},Av),state:`thinking`})}function u(e){n({agentTranscript:e})}function d(){let e=t().agentTranscript;if(e===null||e.length===0){n({agentTranscript:null});return}n({agentTranscript:null,messages:Nv(t().messages,{id:++o,role:`assistant`,content:e},Av)})}function f(){if(r.fatalError)return;let e=t();e.state===`error`?n({state:`listening`,error:null}):e.error!==null&&n({error:null})}function p(e={}){n(r.fatalError?e:{...e,state:`listening`})}function m(e){console.error(`Agent error:`,e.message),e.fatal===!1?n({error:{code:e.code,message:e.message}}):(i(),r.generation.bump(),r.fatalError=!0,n({state:`error`,error:{code:e.code,message:e.message},running:!1,recording:!1}))}function h(i){switch(i.type!==`error`&&f(),i.type){case`speech_started`:n({userTranscript:``});break;case`speech_stopped`:break;case`user_transcript`:l(i.text);break;case`user_transcript_partial`:n({userTranscript:i.text});break;case`agent_transcript`:u(i.text);break;case`tool_call`:n({toolCalls:Nv(t().toolCalls,{callId:i.toolCallId,name:i.toolName,args:Yo(i.args),status:`pending`,seq:++s,afterMessageId:t().messages.at(-1)?.id??-1},Av)});break;case`tool_call_done`:{let e=t().toolCalls,r=e.findIndex(e=>e.callId===i.toolCallId);if(r!==-1){let t=[...e],a=t[r];a&&(t[r]={...a,status:`done`,result:i.result}),n({toolCalls:t})}break}case`reply_done`:d(),p();break;case`cancelled`:r.turn.bump(),r.voiceIO?.flush(),d(),p({userTranscript:null});break;case`reset`:r.turn.bump(),r.voiceIO?.flush(),p(r.fatalError?{}:Mv);break;case`custom_event`:c(i.event,i.data);break;case`agent_state`:n({agentState:i.state});break;case`error`:m(i);break;case`idle_timeout`:e.conn.retiredByServer=!0;break;default:break}}function g(e){let i=t();i.state===`error`||i.state===`disconnected`&&i.error!==null||(i.state!==`speaking`&&n({state:`speaking`}),r.voiceIO?r.voiceIO.enqueue(e):r.preInitAudio.length<jv&&r.preInitAudio.push(e))}function _(e){let t=r.turn.current();e.done().then(()=>{r.turn.isCurrent(t)&&n({state:`listening`})}).catch(e=>{console.warn(`Audio playback done failed:`,e)})}function v(){let e=r.voiceIO;e?_(e):(r.preInitDone=!0,n({state:`listening`}))}function y(e){if(e instanceof ArrayBuffer){g(e);return}if(typeof e!=`string`){console.warn(`session-core: non-string, non-binary frame received; dropping`);return}let t=qo(e);if(t===void 0){console.warn(`session-core: invalid JSON; dropping`);return}let n=is(ls,t);if(!n.ok){n.malformed&&console.warn(`session-core: malformed server message`,n.error);return}let i=n.data;if(i.type===`config`)return r.fatalError=!1,{sampleRate:i.sampleRate,ttsSampleRate:i.ttsSampleRate,sid:i.sessionId};if(i.type===`audio_done`){v();return}h(i)}return{handleMessage:y,settleWhenAudioDrained:_}}function Fv(e,t,n){return Rv(ds(e,`websocket`),t,n)}function Iv(e,t,n){return Rv(new URL(e),t,n)}var Lv={"https:":`wss:`,"http:":`ws:`};function Rv(e,t,n){return e.protocol=Lv[e.protocol]??e.protocol,n?e.searchParams.set(`sessionId`,n):t&&e.searchParams.set(`resume`,`1`),e}var zv={echoCancellation:!0,noiseSuppression:!1,autoGainControl:!1,voiceIsolation:!1};function Bv(e){let t={...Mv,state:`disconnected`,contentVersion:0,started:!1,running:!1,recording:!1,apiUrl:Fv(e.platformUrl,!1).toString()},n=new Set;function r(){for(let e of n)e()}let i=[`messages`,`toolCalls`,`userTranscript`,`agentTranscript`];function a(e){t=i.some(n=>n in e&&e[n]!==t[n])?{...t,...e,contentVersion:t.contentVersion+1}:{...t,...e},r()}function o(){return t}function s(e){return n.add(e),()=>{n.delete(e)}}let c={ws:null,retiredByServer:!1,fatalError:!1,voiceIO:null,audioSetupInFlight:!1,generation:ev(),turn:ev(),preInitAudio:[],preInitDone:!1},l=null,u=!1,d=e.resumeSessionId,f;function p(){c.audioSetupInFlight=!1,c.turn.bump(),c.voiceIO?.close().catch(()=>{}),c.voiceIO=null,c.preInitAudio=[],c.preInitDone=!1}function m(){a(Mv)}function h(e){c.ws&&c.ws.readyState===1&&c.ws.send(JSON.stringify(e))}function g(e){!c.ws||c.ws.readyState!==1||c.ws.bufferedAmount>65536||c.ws.send(e)}let{handleMessage:_,settleWhenAudioDrained:v}=Pv({getSnapshot:o,updateState:a,conn:c,cleanupAudio:p}),y={sendJson:h,sendAudio:g,updateState:a,settleWhenAudioDrained:v,cleanupAudio:p};function b(){l?.abort(),l=null,p(),c.ws?.close(),c.ws=null}function x(n){n.sid&&(d=n.sid,e.onSessionId?.(n.sid));let r=u;u=!0,sv(c,n,y),r&&t.messages.length>0&&h({type:`history`,messages:t.messages.map(e=>({role:e.role,content:e.content}))})}async function ee(){let t=f===!1?null:await ms(e.platformUrl);return t&&(f=t.sessionUrl!==void 0),(t?.sessionUrl?Iv(t.sessionUrl,u,d):Fv(e.platformUrl,u,d)).toString()}function S(){return e.WebSocket?new e.WebSocket(Fv(e.platformUrl,u,d).toString()):Sv(ee)}function C(e){if(e?.signal?.aborted){re();return}a({state:`connecting`,error:null}),ov().catch(()=>{}),b(),c.generation.bump(),c.retiredByServer=!1;let n=new AbortController;l=n;let{signal:r}=n;e?.signal&&e.signal.addEventListener(`abort`,()=>re(),{signal:r});let i=S();i.binaryType=`arraybuffer`,c.ws=i;let o=!1,s=Ov({socket:i,signal:r,onRetry:()=>{p(),c.generation.bump(),a({state:`connecting`,recording:!1})},onExhausted:()=>{p(),n.abort(),i.close(),c.ws=null,a({state:`error`,error:Tv,running:!1,recording:!1})}});i.addEventListener(`open`,()=>{a({state:`ready`}),s.arm()},{signal:r}),i.addEventListener(`message`,e=>{let t=_(e.data);t&&(s.disarm(),x(t))},{signal:r}),i.addEventListener(`error`,()=>{o=!0},{signal:r}),i.addEventListener(`close`,()=>{if(!r.aborted){if(s.disarm(),p(),!c.retiredByServer&&wv(i)){c.generation.bump(),o=!1,a({state:`connecting`,recording:!1});return}n.abort(),i.close(),c.ws=null,o?a({state:`error`,error:{code:`connection`,message:`WebSocket connection error`},running:!1,recording:!1}):t.state===`error`?a({running:!1,recording:!1}):a({state:`disconnected`,error:null,running:!1,recording:!1})}},{signal:r})}function te(){!c.ws||c.ws.readyState!==1||(c.turn.bump(),c.voiceIO?.flush(),a({state:`listening`}),h({type:`cancel`}))}function ne(){if(c.turn.bump(),c.voiceIO?.flush(),c.ws&&c.ws.readyState===1){h({type:`reset`});return}ae(),w()}function re(){b(),a({state:`disconnected`,running:!1,recording:!1})}function w(){a({started:!0,running:!0}),C()}function ie(){t.running?re():(a({running:!0}),C())}function ae(){b(),d=void 0,u=!1,a({...Mv,state:`disconnected`,started:!1,running:!1,recording:!1})}return{getSnapshot:o,subscribe:s,connect:C,cancel:te,resetState:m,reset:ne,disconnect:re,start:w,toggle:ie,end:ae,[Symbol.dispose](){re()}}}function Vv(e=`#app`){if(typeof e!=`string`)return e;let t=document.querySelector(e);if(!t)throw Error(`Element not found: ${e}`);return t}function Hv({name:e,Sidebar:t,sidebarWidth:n}){let r=(0,R.jsx)(Z_,{title:e});return(0,R.jsx)($_,{title:e,children:t?(0,R.jsx)(Q_,{sidebar:(0,R.jsx)(t,{}),sidebarWidth:n,children:r}):r})}function Uv({platformUrl:e,name:t,Sidebar:n,sidebarWidth:r}){let[i,a]=(0,v.useState)(null);return(0,v.useEffect)(()=>{let t=!1;return hs(e).then(e=>{t||a(e)}),()=>{t=!0}},[e]),(0,R.jsx)(Hv,{name:t??i?.name,Sidebar:n,sidebarWidth:r})}function Wv(e){let t=Vv(e.target),n=e.platformUrl??Qo(),r=Bv({platformUrl:n,onSessionId:e.onSessionId,resumeSessionId:e.resumeSessionId,WebSocket:e.WebSocket});e.name&&typeof document<`u`&&(document.title=e.name);let i=e.component?(0,v.createElement)(e.component):(0,v.createElement)(Uv,{platformUrl:n,name:e.name,Sidebar:e.sidebar,sidebarWidth:e.sidebarWidth}),a=e.tools??{},o=(0,b.createRoot)(t);(0,y.flushSync)(()=>{o.render((0,v.createElement)(B_.Provider,{value:a},(0,v.createElement)(ws,{value:e.theme},(0,v.createElement)(bs,{value:r},i))))});let s={session:r,dispose(){o.unmount(),r[Symbol.dispose]()},[Symbol.dispose](){s.dispose()}};return s}Wv({});export{te as a,S as i,x as n,C as o,ee as r,zv as t};
|
package/dist/default-client/assets/{playback-processor-2p9HLz_W.js → playback-processor-SKKE9qu2.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e}from"./index-
|
|
1
|
+
import{i as e}from"./index-DfVI-qZ8.js";import{t}from"./_module-url-BX0RuRU2.js";var n=t(`
|
|
2
2
|
class PlaybackProcessor extends AudioWorkletProcessor {
|
|
3
3
|
constructor(options) {
|
|
4
4
|
super();
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<title>aai</title>
|
|
7
7
|
<link rel="icon" href="./favicon.ico" />
|
|
8
8
|
<style>html, body { background: #FBF8F2; margin: 0; }</style>
|
|
9
|
-
<script type="module" crossorigin src="./assets/index-
|
|
9
|
+
<script type="module" crossorigin src="./assets/index-DfVI-qZ8.js"></script>
|
|
10
10
|
<link rel="stylesheet" crossorigin href="./assets/index-Ctjrde3-.css">
|
|
11
11
|
</head>
|
|
12
12
|
<body>
|
package/dist/define-client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as fetchClientConfig, t as createSessionCore } from "./session-core-
|
|
1
|
+
import { r as fetchClientConfig, t as createSessionCore } from "./session-core-BA8H3qtF.js";
|
|
2
2
|
import { SessionProvider, ThemeProvider } from "./context.js";
|
|
3
3
|
import { t as ChatView } from "./chat-view-DadZOvJO.js";
|
|
4
4
|
import { t as pageBaseUrl } from "./_utils-CsqbIVGI.js";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as loadClientConfig, n as buildAgentUrl, r as fetchClientConfig, t as createSessionCore } from "./session-core-
|
|
1
|
+
import { i as loadClientConfig, n as buildAgentUrl, r as fetchClientConfig, t as createSessionCore } from "./session-core-BA8H3qtF.js";
|
|
2
2
|
import { SessionProvider, ThemeProvider, useSession, useSessionSelector, useTheme } from "./context.js";
|
|
3
3
|
import { Button } from "./components/button.js";
|
|
4
4
|
import { t as ChatView } from "./chat-view-DadZOvJO.js";
|
|
@@ -439,8 +439,16 @@ function createMessageHandlers(deps) {
|
|
|
439
439
|
});
|
|
440
440
|
}
|
|
441
441
|
/** Clear error state when a non-error event arrives — proves the session
|
|
442
|
-
* is functional (e.g. audio init failed but WebSocket still works).
|
|
442
|
+
* is functional (e.g. audio init failed but WebSocket still works).
|
|
443
|
+
*
|
|
444
|
+
* A FATAL error is exempt, and that exemption is the whole reason the flag
|
|
445
|
+
* exists (see `ConnState.fatalError`): the host's teardown emits, so the
|
|
446
|
+
* frames that follow a fatal error are a consequence of it rather than
|
|
447
|
+
* evidence against it. Recovering on them left the one message that says
|
|
448
|
+
* what to fix — a missing provider key — on screen for a fraction of a
|
|
449
|
+
* second, over a session that could no longer hear anyone. */
|
|
443
450
|
function clearRecoveredError() {
|
|
451
|
+
if (conn.fatalError) return;
|
|
444
452
|
const snap = getSnapshot();
|
|
445
453
|
if (snap.state === "error") updateState({
|
|
446
454
|
state: "listening",
|
|
@@ -448,6 +456,22 @@ function createMessageHandlers(deps) {
|
|
|
448
456
|
});
|
|
449
457
|
else if (snap.error !== null) updateState({ error: null });
|
|
450
458
|
}
|
|
459
|
+
/**
|
|
460
|
+
* Return to "listening" at a turn boundary — unless the session is over.
|
|
461
|
+
*
|
|
462
|
+
* `reply_done`, `cancelled` and `reset` each wrote `state: "listening"`
|
|
463
|
+
* unconditionally, which is the second half of the same bug
|
|
464
|
+
* `clearRecoveredError`'s latch covers: the host's fatal paths all call
|
|
465
|
+
* `terminate()`, and terminating emits `onCancelled()`. So the frame that
|
|
466
|
+
* ANNOUNCES the session's death was also the frame that painted a live-mic
|
|
467
|
+
* state over the error it had just reported.
|
|
468
|
+
*/
|
|
469
|
+
function toListening(extra = {}) {
|
|
470
|
+
updateState(conn.fatalError ? extra : {
|
|
471
|
+
...extra,
|
|
472
|
+
state: "listening"
|
|
473
|
+
});
|
|
474
|
+
}
|
|
451
475
|
function handleErrorEvent(e) {
|
|
452
476
|
console.error("Agent error:", e.message);
|
|
453
477
|
if (e.fatal === false) updateState({ error: {
|
|
@@ -457,6 +481,7 @@ function createMessageHandlers(deps) {
|
|
|
457
481
|
else {
|
|
458
482
|
cleanupAudio();
|
|
459
483
|
conn.generation.bump();
|
|
484
|
+
conn.fatalError = true;
|
|
460
485
|
updateState({
|
|
461
486
|
state: "error",
|
|
462
487
|
error: {
|
|
@@ -512,24 +537,18 @@ function createMessageHandlers(deps) {
|
|
|
512
537
|
}
|
|
513
538
|
case "reply_done":
|
|
514
539
|
commitAgentTranscript();
|
|
515
|
-
|
|
540
|
+
toListening();
|
|
516
541
|
break;
|
|
517
542
|
case "cancelled":
|
|
518
543
|
conn.turn.bump();
|
|
519
544
|
conn.voiceIO?.flush();
|
|
520
545
|
commitAgentTranscript();
|
|
521
|
-
|
|
522
|
-
userTranscript: null,
|
|
523
|
-
state: "listening"
|
|
524
|
-
});
|
|
546
|
+
toListening({ userTranscript: null });
|
|
525
547
|
break;
|
|
526
548
|
case "reset":
|
|
527
549
|
conn.turn.bump();
|
|
528
550
|
conn.voiceIO?.flush();
|
|
529
|
-
|
|
530
|
-
...CLEARED_SESSION_STATE,
|
|
531
|
-
state: "listening"
|
|
532
|
-
});
|
|
551
|
+
toListening(conn.fatalError ? {} : CLEARED_SESSION_STATE);
|
|
533
552
|
break;
|
|
534
553
|
case "custom_event":
|
|
535
554
|
appendCustomEvent(e.event, e.data);
|
|
@@ -600,11 +619,14 @@ function createMessageHandlers(deps) {
|
|
|
600
619
|
return;
|
|
601
620
|
}
|
|
602
621
|
const msg = parsed.data;
|
|
603
|
-
if (msg.type === "config")
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
622
|
+
if (msg.type === "config") {
|
|
623
|
+
conn.fatalError = false;
|
|
624
|
+
return {
|
|
625
|
+
sampleRate: msg.sampleRate,
|
|
626
|
+
ttsSampleRate: msg.ttsSampleRate,
|
|
627
|
+
sid: msg.sessionId
|
|
628
|
+
};
|
|
629
|
+
}
|
|
608
630
|
if (msg.type === "audio_done") {
|
|
609
631
|
playAudioDone();
|
|
610
632
|
return;
|
|
@@ -724,6 +746,7 @@ function createSessionCore(options) {
|
|
|
724
746
|
const conn = {
|
|
725
747
|
ws: null,
|
|
726
748
|
retiredByServer: false,
|
|
749
|
+
fatalError: false,
|
|
727
750
|
voiceIO: null,
|
|
728
751
|
audioSetupInFlight: false,
|
|
729
752
|
generation: createEpoch(),
|
|
@@ -151,6 +151,28 @@ export type ConnState = {
|
|
|
151
151
|
* reconnect on demand).
|
|
152
152
|
*/
|
|
153
153
|
retiredByServer: boolean;
|
|
154
|
+
/**
|
|
155
|
+
* A FATAL error has been reported for this connection — the session is
|
|
156
|
+
* over, and no later frame may take its banner off the screen.
|
|
157
|
+
*
|
|
158
|
+
* The recovery rule below it (`clearRecoveredError`) reads a non-error
|
|
159
|
+
* frame as proof the session works, which is right for a client-side or
|
|
160
|
+
* turn-level failure and wrong for a server error that ended the call:
|
|
161
|
+
* every fatal path in the host tears the transport down, and tearing down
|
|
162
|
+
* EMITS — `terminate()` calls `onCancelled()` immediately after
|
|
163
|
+
* `emitError`. So the very next frame recovered the state to "listening"
|
|
164
|
+
* and wiped the message. A missing provider key is the case that made this
|
|
165
|
+
* visible: the one error that says exactly what to go and fix
|
|
166
|
+
* ("Cartesia TTS: missing API key. Set CARTESIA_API_KEY in the agent env.")
|
|
167
|
+
* was on screen for a few hundred milliseconds and left a session that
|
|
168
|
+
* looked live and was deaf.
|
|
169
|
+
*
|
|
170
|
+
* Cleared by exactly one thing — the next `config` frame, i.e. a completed
|
|
171
|
+
* handshake. That is per CONNECTION rather than per session, so a
|
|
172
|
+
* reconnect that really works is not pinned to a dead session's banner,
|
|
173
|
+
* and it is the only frame a dying session cannot produce.
|
|
174
|
+
*/
|
|
175
|
+
fatalError: boolean;
|
|
154
176
|
voiceIO: VoiceIO | null;
|
|
155
177
|
audioSetupInFlight: boolean;
|
|
156
178
|
/** Connection epoch, bumped on each connect()/retry (see `createEpoch`).
|
package/dist/session-core.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as createSessionCore } from "./session-core-
|
|
1
|
+
import { t as createSessionCore } from "./session-core-BA8H3qtF.js";
|
|
2
2
|
export { createSessionCore };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alexkroman1/aai-ui",
|
|
3
|
-
"version": "5.13.
|
|
3
|
+
"version": "5.13.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"remark-gfm": "^4.0.1",
|
|
29
29
|
"use-stick-to-bottom": "^1.1.6",
|
|
30
30
|
"use-sync-external-store": "^1.6.0",
|
|
31
|
-
"@alexkroman1/aai": "5.13.
|
|
31
|
+
"@alexkroman1/aai": "5.13.2"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"react": "^19.0.0",
|