@avatarfactory/react 0.1.40 → 0.1.41
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/README.md +1 -1
- package/dist/{AvatarProvider-Cll_r1hx.d.ts → AvatarProvider-CItqTL0v.d.ts} +3 -0
- package/dist/{AvatarProvider-BXaeG3PZ.d.mts → AvatarProvider-DqD003D2.d.mts} +3 -0
- package/dist/chunk-3SRQGZJ5.js +4 -0
- package/dist/chunk-6Q2I7WKW.mjs +16 -0
- package/dist/{chunk-YOMHPKHO.js → chunk-FDZA3OHI.js} +3 -3
- package/dist/chunk-WOQBPJGB.mjs +4 -0
- package/dist/embed/embed.js +5 -5
- package/dist/embed/meeting.js +14 -14
- package/dist/embed/runtime.js +14 -14
- package/dist/framer/index.framer.mjs +42 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/page.js +1 -1
- package/dist/page.mjs +1 -1
- package/dist/unstable.d.mts +2 -2
- package/dist/unstable.d.ts +2 -2
- package/dist/unstable.js +1 -1
- package/dist/unstable.mjs +1 -1
- package/package.json +6 -4
- package/dist/chunk-E7HVSIHB.mjs +0 -4
- package/dist/chunk-HRSHBEAW.js +0 -4
- package/dist/chunk-OANDIUVQ.mjs +0 -16
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import*as __banner_react from'react';import {createContext,memo,useState,useRef,useCallback,useEffect,useSyncExternalStore,useMemo,useLayoutEffect,useContext}from'react';import*as __banner_react_dom from'react-dom';import {createPortal}from'react-dom';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var require$1 = (id) => {
|
|
2
|
+
if (id === "react") return __banner_react;
|
|
3
|
+
if (id === "react-dom") return __banner_react_dom;
|
|
4
|
+
throw new Error('Dynamic require of "' + id + '" is not supported');
|
|
5
|
+
};
|
|
6
|
+
var bm=Object.create;var Us=Object.defineProperty;var ym=Object.getOwnPropertyDescriptor;var _m=Object.getOwnPropertyNames;var wm=Object.getPrototypeOf,Sm=Object.prototype.hasOwnProperty;var Em=(n=>typeof require$1<"u"?require$1:typeof Proxy<"u"?new Proxy(n,{get:(e,t)=>(typeof require$1<"u"?require$1:e)[t]}):n)(function(n){if(typeof require$1<"u")return require$1.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var cu=(n,e)=>()=>(n&&(e=n(n=0)),e);var uu=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),du=(n,e)=>{for(var t in e)Us(n,t,{get:e[t],enumerable:true});},Mm=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of _m(e))!Sm.call(n,o)&&o!==t&&Us(n,o,{get:()=>e[o],enumerable:!(r=ym(e,o))||r.enumerable});return n};var vi=(n,e,t)=>(t=n!=null?bm(wm(n)):{},Mm(!n||!n.__esModule?Us(t,"default",{value:n,enumerable:true}):t,n));var tf={};du(tf,{VAD_WORKER_SOURCE:()=>Zv});var Zv,nf=cu(()=>{Zv='"use strict";(()=>{var Ft=Object.defineProperty;var Et=(t,s)=>()=>(t&&(s=t(t=0)),s);var gt=(t,s)=>{for(var n in s)Ft(t,n,{get:s[n],enumerable:!0})};var St={};gt(St,{cmvn:()=>Yt,graph:()=>$t});var $t,Yt,Tt=Et(()=>{"use strict";$t={inputs:["feat","caches_in"],outputs:["probs","caches_out"],cache_shape:[8,1,128,19],nodes:[{op:"Gather",inputs:["caches_in","/Constant_output_0"],outputs:["/Gather_output_0"],attrs:{axis:0}},{op:"Gather",inputs:["caches_in","/Constant_1_output_0"],outputs:["/Gather_1_output_0"],attrs:{axis:0}},{op:"Gather",inputs:["caches_in","/Constant_2_output_0"],outputs:["/Gather_2_output_0"],attrs:{axis:0}},{op:"Gather",inputs:["caches_in","/Constant_3_output_0"],outputs:["/Gather_3_output_0"],attrs:{axis:0}},{op:"Gather",inputs:["caches_in","/Constant_4_output_0"],outputs:["/Gather_4_output_0"],attrs:{axis:0}},{op:"Gather",inputs:["caches_in","/Constant_5_output_0"],outputs:["/Gather_5_output_0"],attrs:{axis:0}},{op:"Gather",inputs:["caches_in","/Constant_6_output_0"],outputs:["/Gather_6_output_0"],attrs:{axis:0}},{op:"Gather",inputs:["caches_in","/Constant_7_output_0"],outputs:["/Gather_7_output_0"],attrs:{axis:0}},{op:"MatMul",inputs:["feat","onnx::MatMul_403"],outputs:["/model/dfsmn/fc1/fc1.0/MatMul_output_0"],attrs:{}},{op:"Add",inputs:["model.dfsmn.fc1.0.bias","/model/dfsmn/fc1/fc1.0/MatMul_output_0"],outputs:["/model/dfsmn/fc1/fc1.0/Add_output_0"],attrs:{}},{op:"Relu",inputs:["/model/dfsmn/fc1/fc1.0/Add_output_0"],outputs:["/model/dfsmn/fc1/fc1.1/Relu_output_0"],attrs:{}},{op:"MatMul",inputs:["/model/dfsmn/fc1/fc1.1/Relu_output_0","onnx::MatMul_404"],outputs:["/model/dfsmn/fc2/fc2.0/MatMul_output_0"],attrs:{}},{op:"Add",inputs:["model.dfsmn.fc2.0.bias","/model/dfsmn/fc2/fc2.0/MatMul_output_0"],outputs:["/model/dfsmn/fc2/fc2.0/Add_output_0"],attrs:{}},{op:"Relu",inputs:["/model/dfsmn/fc2/fc2.0/Add_output_0"],outputs:["/model/dfsmn/fc2/fc2.1/Relu_output_0"],attrs:{}},{op:"Transpose",inputs:["/model/dfsmn/fc2/fc2.1/Relu_output_0"],outputs:["/model/dfsmn/fsmn1/Transpose_output_0"],attrs:{perm:[0,2,1]}},{op:"Concat",inputs:["/Gather_output_0","/model/dfsmn/fsmn1/Transpose_output_0"],outputs:["/model/dfsmn/fsmn1/Concat_output_0"],attrs:{axis:2}},{op:"Slice",inputs:["/model/dfsmn/fsmn1/Concat_output_0","/model/dfsmn/fsmn1/Constant_1_output_0","/model/dfsmn/fsmn1/Constant_2_output_0","/model/dfsmn/fsmn1/Constant_output_0","/model/dfsmn/fsmn1/Constant_3_output_0"],outputs:["/model/dfsmn/fsmn1/Slice_output_0"],attrs:{}},{op:"Conv",inputs:["/model/dfsmn/fsmn1/Concat_output_0","model.dfsmn.fsmn1.lookback_filter.weight"],outputs:["/model/dfsmn/fsmn1/lookback_filter/Conv_output_0"],attrs:{dilations:[1],group:128,kernel_shape:[20],pads:[19,19],strides:[1]}},{op:"Slice",inputs:["/model/dfsmn/fsmn1/lookback_filter/Conv_output_0","/model/dfsmn/fsmn1/Constant_5_output_0","/model/dfsmn/fsmn1/Constant_1_output_0","/model/dfsmn/fsmn1/Constant_output_0","/model/dfsmn/fsmn1/Constant_3_output_0"],outputs:["/model/dfsmn/fsmn1/Slice_1_output_0"],attrs:{}},{op:"Slice",inputs:["/model/dfsmn/fsmn1/Slice_1_output_0","/model/dfsmn/fsmn1/Constant_9_output_0","/model/dfsmn/fsmn1/Constant_2_output_0","/model/dfsmn/fsmn1/Constant_output_0","/model/dfsmn/fsmn1/Constant_3_output_0"],outputs:["/model/dfsmn/fsmn1/Slice_2_output_0"],attrs:{}},{op:"Add",inputs:["/model/dfsmn/fsmn1/Transpose_output_0","/model/dfsmn/fsmn1/Slice_2_output_0"],outputs:["/model/dfsmn/fsmn1/Add_output_0"],attrs:{}},{op:"Transpose",inputs:["/model/dfsmn/fsmn1/Add_output_0"],outputs:["/model/dfsmn/fsmn1/Transpose_1_output_0"],attrs:{perm:[0,2,1]}},{op:"MatMul",inputs:["/model/dfsmn/fsmn1/Transpose_1_output_0","onnx::MatMul_417"],outputs:["/model/dfsmn/fsmns.0/fc1/fc1.0/MatMul_output_0"],attrs:{}},{op:"Add",inputs:["model.dfsmn.fsmns.0.fc1.0.bias","/model/dfsmn/fsmns.0/fc1/fc1.0/MatMul_output_0"],outputs:["/model/dfsmn/fsmns.0/fc1/fc1.0/Add_output_0"],attrs:{}},{op:"Relu",inputs:["/model/dfsmn/fsmns.0/fc1/fc1.0/Add_output_0"],outputs:["/model/dfsmn/fsmns.0/fc1/fc1.1/Relu_output_0"],attrs:{}},{op:"MatMul",inputs:["/model/dfsmn/fsmns.0/fc1/fc1.1/Relu_output_0","onnx::MatMul_418"],outputs:["/model/dfsmn/fsmns.0/fc2/MatMul_output_0"],attrs:{}},{op:"Transpose",inputs:["/model/dfsmn/fsmns.0/fc2/MatMul_output_0"],outputs:["/model/dfsmn/fsmns.0/fsmn/Transpose_output_0"],attrs:{perm:[0,2,1]}},{op:"Concat",inputs:["/Gather_1_output_0","/model/dfsmn/fsmns.0/fsmn/Transpose_output_0"],outputs:["/model/dfsmn/fsmns.0/fsmn/Concat_output_0"],attrs:{axis:2}},{op:"Slice",inputs:["/model/dfsmn/fsmns.0/fsmn/Concat_output_0","/model/dfsmn/fsmn1/Constant_1_output_0","/model/dfsmn/fsmn1/Constant_2_output_0","/model/dfsmn/fsmn1/Constant_output_0","/model/dfsmn/fsmn1/Constant_3_output_0"],outputs:["/model/dfsmn/fsmns.0/fsmn/Slice_output_0"],attrs:{}},{op:"Conv",inputs:["/model/dfsmn/fsmns.0/fsmn/Concat_output_0","model.dfsmn.fsmns.0.fsmn.lookback_filter.weight"],outputs:["/model/dfsmn/fsmns.0/fsmn/lookback_filter/Conv_output_0"],attrs:{dilations:[1],group:128,kernel_shape:[20],pads:[19,19],strides:[1]}},{op:"Slice",inputs:["/model/dfsmn/fsmns.0/fsmn/lookback_filter/Conv_output_0","/model/dfsmn/fsmn1/Constant_5_output_0","/model/dfsmn/fsmn1/Constant_1_output_0","/model/dfsmn/fsmn1/Constant_output_0","/model/dfsmn/fsmn1/Constant_3_output_0"],outputs:["/model/dfsmn/fsmns.0/fsmn/Slice_1_output_0"],attrs:{}},{op:"Slice",inputs:["/model/dfsmn/fsmns.0/fsmn/Slice_1_output_0","/model/dfsmn/fsmn1/Constant_9_output_0","/model/dfsmn/fsmn1/Constant_2_output_0","/model/dfsmn/fsmn1/Constant_output_0","/model/dfsmn/fsmn1/Constant_3_output_0"],outputs:["/model/dfsmn/fsmns.0/fsmn/Slice_2_output_0"],attrs:{}},{op:"Add",inputs:["/model/dfsmn/fsmns.0/fsmn/Transpose_output_0","/model/dfsmn/fsmns.0/fsmn/Slice_2_output_0"],outputs:["/model/dfsmn/fsmns.0/fsmn/Add_output_0"],attrs:{}},{op:"Transpose",inputs:["/model/dfsmn/fsmns.0/fsmn/Add_output_0"],outputs:["/model/dfsmn/fsmns.0/fsmn/Transpose_1_output_0"],attrs:{perm:[0,2,1]}},{op:"Add",inputs:["/model/dfsmn/fsmns.0/fsmn/Transpose_1_output_0","/model/dfsmn/fsmn1/Transpose_1_output_0"],outputs:["/model/dfsmn/fsmns.0/Add_output_0"],attrs:{}},{op:"MatMul",inputs:["/model/dfsmn/fsmns.0/Add_output_0","onnx::MatMul_431"],outputs:["/model/dfsmn/fsmns.1/fc1/fc1.0/MatMul_output_0"],attrs:{}},{op:"Add",inputs:["model.dfsmn.fsmns.1.fc1.0.bias","/model/dfsmn/fsmns.1/fc1/fc1.0/MatMul_output_0"],outputs:["/model/dfsmn/fsmns.1/fc1/fc1.0/Add_output_0"],attrs:{}},{op:"Relu",inputs:["/model/dfsmn/fsmns.1/fc1/fc1.0/Add_output_0"],outputs:["/model/dfsmn/fsmns.1/fc1/fc1.1/Relu_output_0"],attrs:{}},{op:"MatMul",inputs:["/model/dfsmn/fsmns.1/fc1/fc1.1/Relu_output_0","onnx::MatMul_432"],outputs:["/model/dfsmn/fsmns.1/fc2/MatMul_output_0"],attrs:{}},{op:"Transpose",inputs:["/model/dfsmn/fsmns.1/fc2/MatMul_output_0"],outputs:["/model/dfsmn/fsmns.1/fsmn/Transpose_output_0"],attrs:{perm:[0,2,1]}},{op:"Concat",inputs:["/Gather_2_output_0","/model/dfsmn/fsmns.1/fsmn/Transpose_output_0"],outputs:["/model/dfsmn/fsmns.1/fsmn/Concat_output_0"],attrs:{axis:2}},{op:"Slice",inputs:["/model/dfsmn/fsmns.1/fsmn/Concat_output_0","/model/dfsmn/fsmn1/Constant_1_output_0","/model/dfsmn/fsmn1/Constant_2_output_0","/model/dfsmn/fsmn1/Constant_output_0","/model/dfsmn/fsmn1/Constant_3_output_0"],outputs:["/model/dfsmn/fsmns.1/fsmn/Slice_output_0"],attrs:{}},{op:"Conv",inputs:["/model/dfsmn/fsmns.1/fsmn/Concat_output_0","model.dfsmn.fsmns.1.fsmn.lookback_filter.weight"],outputs:["/model/dfsmn/fsmns.1/fsmn/lookback_filter/Conv_output_0"],attrs:{dilations:[1],group:128,kernel_shape:[20],pads:[19,19],strides:[1]}},{op:"Slice",inputs:["/model/dfsmn/fsmns.1/fsmn/lookback_filter/Conv_output_0","/model/dfsmn/fsmn1/Constant_5_output_0","/model/dfsmn/fsmn1/Constant_1_output_0","/model/dfsmn/fsmn1/Constant_output_0","/model/dfsmn/fsmn1/Constant_3_output_0"],outputs:["/model/dfsmn/fsmns.1/fsmn/Slice_1_output_0"],attrs:{}},{op:"Slice",inputs:["/model/dfsmn/fsmns.1/fsmn/Slice_1_output_0","/model/dfsmn/fsmn1/Constant_9_output_0","/model/dfsmn/fsmn1/Constant_2_output_0","/model/dfsmn/fsmn1/Constant_output_0","/model/dfsmn/fsmn1/Constant_3_output_0"],outputs:["/model/dfsmn/fsmns.1/fsmn/Slice_2_output_0"],attrs:{}},{op:"Add",inputs:["/model/dfsmn/fsmns.1/fsmn/Transpose_output_0","/model/dfsmn/fsmns.1/fsmn/Slice_2_output_0"],outputs:["/model/dfsmn/fsmns.1/fsmn/Add_output_0"],attrs:{}},{op:"Transpose",inputs:["/model/dfsmn/fsmns.1/fsmn/Add_output_0"],outputs:["/model/dfsmn/fsmns.1/fsmn/Transpose_1_output_0"],attrs:{perm:[0,2,1]}},{op:"Add",inputs:["/model/dfsmn/fsmns.1/fsmn/Transpose_1_output_0","/model/dfsmn/fsmns.0/Add_output_0"],outputs:["/model/dfsmn/fsmns.1/Add_output_0"],attrs:{}},{op:"MatMul",inputs:["/model/dfsmn/fsmns.1/Add_output_0","onnx::MatMul_445"],outputs:["/model/dfsmn/fsmns.2/fc1/fc1.0/MatMul_output_0"],attrs:{}},{op:"Add",inputs:["model.dfsmn.fsmns.2.fc1.0.bias","/model/dfsmn/fsmns.2/fc1/fc1.0/MatMul_output_0"],outputs:["/model/dfsmn/fsmns.2/fc1/fc1.0/Add_output_0"],attrs:{}},{op:"Relu",inputs:["/model/dfsmn/fsmns.2/fc1/fc1.0/Add_output_0"],outputs:["/model/dfsmn/fsmns.2/fc1/fc1.1/Relu_output_0"],attrs:{}},{op:"MatMul",inputs:["/model/dfsmn/fsmns.2/fc1/fc1.1/Relu_output_0","onnx::MatMul_446"],outputs:["/model/dfsmn/fsmns.2/fc2/MatMul_output_0"],attrs:{}},{op:"Transpose",inputs:["/model/dfsmn/fsmns.2/fc2/MatMul_output_0"],outputs:["/model/dfsmn/fsmns.2/fsmn/Transpose_output_0"],attrs:{perm:[0,2,1]}},{op:"Concat",inputs:["/Gather_3_output_0","/model/dfsmn/fsmns.2/fsmn/Transpose_output_0"],outputs:["/model/dfsmn/fsmns.2/fsmn/Concat_output_0"],attrs:{axis:2}},{op:"Slice",inputs:["/model/dfsmn/fsmns.2/fsmn/Concat_output_0","/model/dfsmn/fsmn1/Constant_1_output_0","/model/dfsmn/fsmn1/Constant_2_output_0","/model/dfsmn/fsmn1/Constant_output_0","/model/dfsmn/fsmn1/Constant_3_output_0"],outputs:["/model/dfsmn/fsmns.2/fsmn/Slice_output_0"],attrs:{}},{op:"Conv",inputs:["/model/dfsmn/fsmns.2/fsmn/Concat_output_0","model.dfsmn.fsmns.2.fsmn.lookback_filter.weight"],outputs:["/model/dfsmn/fsmns.2/fsmn/lookback_filter/Conv_output_0"],attrs:{dilations:[1],group:128,kernel_shape:[20],pads:[19,19],strides:[1]}},{op:"Slice",inputs:["/model/dfsmn/fsmns.2/fsmn/lookback_filter/Conv_output_0","/model/dfsmn/fsmn1/Constant_5_output_0","/model/dfsmn/fsmn1/Constant_1_output_0","/model/dfsmn/fsmn1/Constant_output_0","/model/dfsmn/fsmn1/Constant_3_output_0"],outputs:["/model/dfsmn/fsmns.2/fsmn/Slice_1_output_0"],attrs:{}},{op:"Slice",inputs:["/model/dfsmn/fsmns.2/fsmn/Slice_1_output_0","/model/dfsmn/fsmn1/Constant_9_output_0","/model/dfsmn/fsmn1/Constant_2_output_0","/model/dfsmn/fsmn1/Constant_output_0","/model/dfsmn/fsmn1/Constant_3_output_0"],outputs:["/model/dfsmn/fsmns.2/fsmn/Slice_2_output_0"],attrs:{}},{op:"Add",inputs:["/model/dfsmn/fsmns.2/fsmn/Transpose_output_0","/model/dfsmn/fsmns.2/fsmn/Slice_2_output_0"],outputs:["/model/dfsmn/fsmns.2/fsmn/Add_output_0"],attrs:{}},{op:"Transpose",inputs:["/model/dfsmn/fsmns.2/fsmn/Add_output_0"],outputs:["/model/dfsmn/fsmns.2/fsmn/Transpose_1_output_0"],attrs:{perm:[0,2,1]}},{op:"Add",inputs:["/model/dfsmn/fsmns.2/fsmn/Transpose_1_output_0","/model/dfsmn/fsmns.1/Add_output_0"],outputs:["/model/dfsmn/fsmns.2/Add_output_0"],attrs:{}},{op:"MatMul",inputs:["/model/dfsmn/fsmns.2/Add_output_0","onnx::MatMul_459"],outputs:["/model/dfsmn/fsmns.3/fc1/fc1.0/MatMul_output_0"],attrs:{}},{op:"Add",inputs:["model.dfsmn.fsmns.3.fc1.0.bias","/model/dfsmn/fsmns.3/fc1/fc1.0/MatMul_output_0"],outputs:["/model/dfsmn/fsmns.3/fc1/fc1.0/Add_output_0"],attrs:{}},{op:"Relu",inputs:["/model/dfsmn/fsmns.3/fc1/fc1.0/Add_output_0"],outputs:["/model/dfsmn/fsmns.3/fc1/fc1.1/Relu_output_0"],attrs:{}},{op:"MatMul",inputs:["/model/dfsmn/fsmns.3/fc1/fc1.1/Relu_output_0","onnx::MatMul_460"],outputs:["/model/dfsmn/fsmns.3/fc2/MatMul_output_0"],attrs:{}},{op:"Transpose",inputs:["/model/dfsmn/fsmns.3/fc2/MatMul_output_0"],outputs:["/model/dfsmn/fsmns.3/fsmn/Transpose_output_0"],attrs:{perm:[0,2,1]}},{op:"Concat",inputs:["/Gather_4_output_0","/model/dfsmn/fsmns.3/fsmn/Transpose_output_0"],outputs:["/model/dfsmn/fsmns.3/fsmn/Concat_output_0"],attrs:{axis:2}},{op:"Slice",inputs:["/model/dfsmn/fsmns.3/fsmn/Concat_output_0","/model/dfsmn/fsmn1/Constant_1_output_0","/model/dfsmn/fsmn1/Constant_2_output_0","/model/dfsmn/fsmn1/Constant_output_0","/model/dfsmn/fsmn1/Constant_3_output_0"],outputs:["/model/dfsmn/fsmns.3/fsmn/Slice_output_0"],attrs:{}},{op:"Conv",inputs:["/model/dfsmn/fsmns.3/fsmn/Concat_output_0","model.dfsmn.fsmns.3.fsmn.lookback_filter.weight"],outputs:["/model/dfsmn/fsmns.3/fsmn/lookback_filter/Conv_output_0"],attrs:{dilations:[1],group:128,kernel_shape:[20],pads:[19,19],strides:[1]}},{op:"Slice",inputs:["/model/dfsmn/fsmns.3/fsmn/lookback_filter/Conv_output_0","/model/dfsmn/fsmn1/Constant_5_output_0","/model/dfsmn/fsmn1/Constant_1_output_0","/model/dfsmn/fsmn1/Constant_output_0","/model/dfsmn/fsmn1/Constant_3_output_0"],outputs:["/model/dfsmn/fsmns.3/fsmn/Slice_1_output_0"],attrs:{}},{op:"Slice",inputs:["/model/dfsmn/fsmns.3/fsmn/Slice_1_output_0","/model/dfsmn/fsmn1/Constant_9_output_0","/model/dfsmn/fsmn1/Constant_2_output_0","/model/dfsmn/fsmn1/Constant_output_0","/model/dfsmn/fsmn1/Constant_3_output_0"],outputs:["/model/dfsmn/fsmns.3/fsmn/Slice_2_output_0"],attrs:{}},{op:"Add",inputs:["/model/dfsmn/fsmns.3/fsmn/Transpose_output_0","/model/dfsmn/fsmns.3/fsmn/Slice_2_output_0"],outputs:["/model/dfsmn/fsmns.3/fsmn/Add_output_0"],attrs:{}},{op:"Transpose",inputs:["/model/dfsmn/fsmns.3/fsmn/Add_output_0"],outputs:["/model/dfsmn/fsmns.3/fsmn/Transpose_1_output_0"],attrs:{perm:[0,2,1]}},{op:"Add",inputs:["/model/dfsmn/fsmns.3/fsmn/Transpose_1_output_0","/model/dfsmn/fsmns.2/Add_output_0"],outputs:["/model/dfsmn/fsmns.3/Add_output_0"],attrs:{}},{op:"MatMul",inputs:["/model/dfsmn/fsmns.3/Add_output_0","onnx::MatMul_473"],outputs:["/model/dfsmn/fsmns.4/fc1/fc1.0/MatMul_output_0"],attrs:{}},{op:"Add",inputs:["model.dfsmn.fsmns.4.fc1.0.bias","/model/dfsmn/fsmns.4/fc1/fc1.0/MatMul_output_0"],outputs:["/model/dfsmn/fsmns.4/fc1/fc1.0/Add_output_0"],attrs:{}},{op:"Relu",inputs:["/model/dfsmn/fsmns.4/fc1/fc1.0/Add_output_0"],outputs:["/model/dfsmn/fsmns.4/fc1/fc1.1/Relu_output_0"],attrs:{}},{op:"MatMul",inputs:["/model/dfsmn/fsmns.4/fc1/fc1.1/Relu_output_0","onnx::MatMul_474"],outputs:["/model/dfsmn/fsmns.4/fc2/MatMul_output_0"],attrs:{}},{op:"Transpose",inputs:["/model/dfsmn/fsmns.4/fc2/MatMul_output_0"],outputs:["/model/dfsmn/fsmns.4/fsmn/Transpose_output_0"],attrs:{perm:[0,2,1]}},{op:"Concat",inputs:["/Gather_5_output_0","/model/dfsmn/fsmns.4/fsmn/Transpose_output_0"],outputs:["/model/dfsmn/fsmns.4/fsmn/Concat_output_0"],attrs:{axis:2}},{op:"Slice",inputs:["/model/dfsmn/fsmns.4/fsmn/Concat_output_0","/model/dfsmn/fsmn1/Constant_1_output_0","/model/dfsmn/fsmn1/Constant_2_output_0","/model/dfsmn/fsmn1/Constant_output_0","/model/dfsmn/fsmn1/Constant_3_output_0"],outputs:["/model/dfsmn/fsmns.4/fsmn/Slice_output_0"],attrs:{}},{op:"Conv",inputs:["/model/dfsmn/fsmns.4/fsmn/Concat_output_0","model.dfsmn.fsmns.4.fsmn.lookback_filter.weight"],outputs:["/model/dfsmn/fsmns.4/fsmn/lookback_filter/Conv_output_0"],attrs:{dilations:[1],group:128,kernel_shape:[20],pads:[19,19],strides:[1]}},{op:"Slice",inputs:["/model/dfsmn/fsmns.4/fsmn/lookback_filter/Conv_output_0","/model/dfsmn/fsmn1/Constant_5_output_0","/model/dfsmn/fsmn1/Constant_1_output_0","/model/dfsmn/fsmn1/Constant_output_0","/model/dfsmn/fsmn1/Constant_3_output_0"],outputs:["/model/dfsmn/fsmns.4/fsmn/Slice_1_output_0"],attrs:{}},{op:"Slice",inputs:["/model/dfsmn/fsmns.4/fsmn/Slice_1_output_0","/model/dfsmn/fsmn1/Constant_9_output_0","/model/dfsmn/fsmn1/Constant_2_output_0","/model/dfsmn/fsmn1/Constant_output_0","/model/dfsmn/fsmn1/Constant_3_output_0"],outputs:["/model/dfsmn/fsmns.4/fsmn/Slice_2_output_0"],attrs:{}},{op:"Add",inputs:["/model/dfsmn/fsmns.4/fsmn/Transpose_output_0","/model/dfsmn/fsmns.4/fsmn/Slice_2_output_0"],outputs:["/model/dfsmn/fsmns.4/fsmn/Add_output_0"],attrs:{}},{op:"Transpose",inputs:["/model/dfsmn/fsmns.4/fsmn/Add_output_0"],outputs:["/model/dfsmn/fsmns.4/fsmn/Transpose_1_output_0"],attrs:{perm:[0,2,1]}},{op:"Add",inputs:["/model/dfsmn/fsmns.4/fsmn/Transpose_1_output_0","/model/dfsmn/fsmns.3/Add_output_0"],outputs:["/model/dfsmn/fsmns.4/Add_output_0"],attrs:{}},{op:"MatMul",inputs:["/model/dfsmn/fsmns.4/Add_output_0","onnx::MatMul_487"],outputs:["/model/dfsmn/fsmns.5/fc1/fc1.0/MatMul_output_0"],attrs:{}},{op:"Add",inputs:["model.dfsmn.fsmns.5.fc1.0.bias","/model/dfsmn/fsmns.5/fc1/fc1.0/MatMul_output_0"],outputs:["/model/dfsmn/fsmns.5/fc1/fc1.0/Add_output_0"],attrs:{}},{op:"Relu",inputs:["/model/dfsmn/fsmns.5/fc1/fc1.0/Add_output_0"],outputs:["/model/dfsmn/fsmns.5/fc1/fc1.1/Relu_output_0"],attrs:{}},{op:"MatMul",inputs:["/model/dfsmn/fsmns.5/fc1/fc1.1/Relu_output_0","onnx::MatMul_488"],outputs:["/model/dfsmn/fsmns.5/fc2/MatMul_output_0"],attrs:{}},{op:"Transpose",inputs:["/model/dfsmn/fsmns.5/fc2/MatMul_output_0"],outputs:["/model/dfsmn/fsmns.5/fsmn/Transpose_output_0"],attrs:{perm:[0,2,1]}},{op:"Concat",inputs:["/Gather_6_output_0","/model/dfsmn/fsmns.5/fsmn/Transpose_output_0"],outputs:["/model/dfsmn/fsmns.5/fsmn/Concat_output_0"],attrs:{axis:2}},{op:"Slice",inputs:["/model/dfsmn/fsmns.5/fsmn/Concat_output_0","/model/dfsmn/fsmn1/Constant_1_output_0","/model/dfsmn/fsmn1/Constant_2_output_0","/model/dfsmn/fsmn1/Constant_output_0","/model/dfsmn/fsmn1/Constant_3_output_0"],outputs:["/model/dfsmn/fsmns.5/fsmn/Slice_output_0"],attrs:{}},{op:"Conv",inputs:["/model/dfsmn/fsmns.5/fsmn/Concat_output_0","model.dfsmn.fsmns.5.fsmn.lookback_filter.weight"],outputs:["/model/dfsmn/fsmns.5/fsmn/lookback_filter/Conv_output_0"],attrs:{dilations:[1],group:128,kernel_shape:[20],pads:[19,19],strides:[1]}},{op:"Slice",inputs:["/model/dfsmn/fsmns.5/fsmn/lookback_filter/Conv_output_0","/model/dfsmn/fsmn1/Constant_5_output_0","/model/dfsmn/fsmn1/Constant_1_output_0","/model/dfsmn/fsmn1/Constant_output_0","/model/dfsmn/fsmn1/Constant_3_output_0"],outputs:["/model/dfsmn/fsmns.5/fsmn/Slice_1_output_0"],attrs:{}},{op:"Slice",inputs:["/model/dfsmn/fsmns.5/fsmn/Slice_1_output_0","/model/dfsmn/fsmn1/Constant_9_output_0","/model/dfsmn/fsmn1/Constant_2_output_0","/model/dfsmn/fsmn1/Constant_output_0","/model/dfsmn/fsmn1/Constant_3_output_0"],outputs:["/model/dfsmn/fsmns.5/fsmn/Slice_2_output_0"],attrs:{}},{op:"Add",inputs:["/model/dfsmn/fsmns.5/fsmn/Transpose_output_0","/model/dfsmn/fsmns.5/fsmn/Slice_2_output_0"],outputs:["/model/dfsmn/fsmns.5/fsmn/Add_output_0"],attrs:{}},{op:"Transpose",inputs:["/model/dfsmn/fsmns.5/fsmn/Add_output_0"],outputs:["/model/dfsmn/fsmns.5/fsmn/Transpose_1_output_0"],attrs:{perm:[0,2,1]}},{op:"Add",inputs:["/model/dfsmn/fsmns.5/fsmn/Transpose_1_output_0","/model/dfsmn/fsmns.4/Add_output_0"],outputs:["/model/dfsmn/fsmns.5/Add_output_0"],attrs:{}},{op:"MatMul",inputs:["/model/dfsmn/fsmns.5/Add_output_0","onnx::MatMul_501"],outputs:["/model/dfsmn/fsmns.6/fc1/fc1.0/MatMul_output_0"],attrs:{}},{op:"Add",inputs:["model.dfsmn.fsmns.6.fc1.0.bias","/model/dfsmn/fsmns.6/fc1/fc1.0/MatMul_output_0"],outputs:["/model/dfsmn/fsmns.6/fc1/fc1.0/Add_output_0"],attrs:{}},{op:"Relu",inputs:["/model/dfsmn/fsmns.6/fc1/fc1.0/Add_output_0"],outputs:["/model/dfsmn/fsmns.6/fc1/fc1.1/Relu_output_0"],attrs:{}},{op:"MatMul",inputs:["/model/dfsmn/fsmns.6/fc1/fc1.1/Relu_output_0","onnx::MatMul_502"],outputs:["/model/dfsmn/fsmns.6/fc2/MatMul_output_0"],attrs:{}},{op:"Transpose",inputs:["/model/dfsmn/fsmns.6/fc2/MatMul_output_0"],outputs:["/model/dfsmn/fsmns.6/fsmn/Transpose_output_0"],attrs:{perm:[0,2,1]}},{op:"Concat",inputs:["/Gather_7_output_0","/model/dfsmn/fsmns.6/fsmn/Transpose_output_0"],outputs:["/model/dfsmn/fsmns.6/fsmn/Concat_output_0"],attrs:{axis:2}},{op:"Slice",inputs:["/model/dfsmn/fsmns.6/fsmn/Concat_output_0","/model/dfsmn/fsmn1/Constant_1_output_0","/model/dfsmn/fsmn1/Constant_2_output_0","/model/dfsmn/fsmn1/Constant_output_0","/model/dfsmn/fsmn1/Constant_3_output_0"],outputs:["/model/dfsmn/fsmns.6/fsmn/Slice_output_0"],attrs:{}},{op:"Conv",inputs:["/model/dfsmn/fsmns.6/fsmn/Concat_output_0","model.dfsmn.fsmns.6.fsmn.lookback_filter.weight"],outputs:["/model/dfsmn/fsmns.6/fsmn/lookback_filter/Conv_output_0"],attrs:{dilations:[1],group:128,kernel_shape:[20],pads:[19,19],strides:[1]}},{op:"Slice",inputs:["/model/dfsmn/fsmns.6/fsmn/lookback_filter/Conv_output_0","/model/dfsmn/fsmn1/Constant_5_output_0","/model/dfsmn/fsmn1/Constant_1_output_0","/model/dfsmn/fsmn1/Constant_output_0","/model/dfsmn/fsmn1/Constant_3_output_0"],outputs:["/model/dfsmn/fsmns.6/fsmn/Slice_1_output_0"],attrs:{}},{op:"Slice",inputs:["/model/dfsmn/fsmns.6/fsmn/Slice_1_output_0","/model/dfsmn/fsmn1/Constant_9_output_0","/model/dfsmn/fsmn1/Constant_2_output_0","/model/dfsmn/fsmn1/Constant_output_0","/model/dfsmn/fsmn1/Constant_3_output_0"],outputs:["/model/dfsmn/fsmns.6/fsmn/Slice_2_output_0"],attrs:{}},{op:"Add",inputs:["/model/dfsmn/fsmns.6/fsmn/Transpose_output_0","/model/dfsmn/fsmns.6/fsmn/Slice_2_output_0"],outputs:["/model/dfsmn/fsmns.6/fsmn/Add_output_0"],attrs:{}},{op:"Transpose",inputs:["/model/dfsmn/fsmns.6/fsmn/Add_output_0"],outputs:["/model/dfsmn/fsmns.6/fsmn/Transpose_1_output_0"],attrs:{perm:[0,2,1]}},{op:"Add",inputs:["/model/dfsmn/fsmns.6/fsmn/Transpose_1_output_0","/model/dfsmn/fsmns.5/Add_output_0"],outputs:["/model/dfsmn/fsmns.6/Add_output_0"],attrs:{}},{op:"MatMul",inputs:["/model/dfsmn/fsmns.6/Add_output_0","onnx::MatMul_515"],outputs:["/model/dfsmn/dnns/dnns.0/MatMul_output_0"],attrs:{}},{op:"Add",inputs:["model.dfsmn.dnns.0.bias","/model/dfsmn/dnns/dnns.0/MatMul_output_0"],outputs:["/model/dfsmn/dnns/dnns.0/Add_output_0"],attrs:{}},{op:"Relu",inputs:["/model/dfsmn/dnns/dnns.0/Add_output_0"],outputs:["/model/dfsmn/dnns/dnns.1/Relu_output_0"],attrs:{}},{op:"MatMul",inputs:["/model/dfsmn/dnns/dnns.1/Relu_output_0","onnx::MatMul_516"],outputs:["/model/out/MatMul_output_0"],attrs:{}},{op:"Add",inputs:["model.out.bias","/model/out/MatMul_output_0"],outputs:["/model/out/Add_output_0"],attrs:{}},{op:"Sigmoid",inputs:["/model/out/Add_output_0"],outputs:["probs"],attrs:{}},{op:"Unsqueeze",inputs:["/model/dfsmn/fsmn1/Slice_output_0","/model/dfsmn/fsmn1/Constant_5_output_0"],outputs:["/Unsqueeze_output_0"],attrs:{}},{op:"Unsqueeze",inputs:["/model/dfsmn/fsmns.0/fsmn/Slice_output_0","/model/dfsmn/fsmn1/Constant_5_output_0"],outputs:["/Unsqueeze_1_output_0"],attrs:{}},{op:"Unsqueeze",inputs:["/model/dfsmn/fsmns.1/fsmn/Slice_output_0","/model/dfsmn/fsmn1/Constant_5_output_0"],outputs:["/Unsqueeze_2_output_0"],attrs:{}},{op:"Unsqueeze",inputs:["/model/dfsmn/fsmns.2/fsmn/Slice_output_0","/model/dfsmn/fsmn1/Constant_5_output_0"],outputs:["/Unsqueeze_3_output_0"],attrs:{}},{op:"Unsqueeze",inputs:["/model/dfsmn/fsmns.3/fsmn/Slice_output_0","/model/dfsmn/fsmn1/Constant_5_output_0"],outputs:["/Unsqueeze_4_output_0"],attrs:{}},{op:"Unsqueeze",inputs:["/model/dfsmn/fsmns.4/fsmn/Slice_output_0","/model/dfsmn/fsmn1/Constant_5_output_0"],outputs:["/Unsqueeze_5_output_0"],attrs:{}},{op:"Unsqueeze",inputs:["/model/dfsmn/fsmns.5/fsmn/Slice_output_0","/model/dfsmn/fsmn1/Constant_5_output_0"],outputs:["/Unsqueeze_6_output_0"],attrs:{}},{op:"Unsqueeze",inputs:["/model/dfsmn/fsmns.6/fsmn/Slice_output_0","/model/dfsmn/fsmn1/Constant_5_output_0"],outputs:["/Unsqueeze_7_output_0"],attrs:{}},{op:"Concat",inputs:["/Unsqueeze_output_0","/Unsqueeze_1_output_0","/Unsqueeze_2_output_0","/Unsqueeze_3_output_0","/Unsqueeze_4_output_0","/Unsqueeze_5_output_0","/Unsqueeze_6_output_0","/Unsqueeze_7_output_0"],outputs:["caches_out"],attrs:{axis:0}}],weights:{"model.dfsmn.fc1.0.bias":{dtype:"fp32",shape:[256],off:0},"model.dfsmn.fc2.0.bias":{dtype:"fp32",shape:[128],off:1024},"model.dfsmn.fsmn1.lookback_filter.weight":{dtype:"int8_pc",shape:[128,1,20],off:1536,scale_off:4096,scale_shape:[1,1,20]},"model.dfsmn.fsmns.0.fc1.0.bias":{dtype:"fp32",shape:[256],off:4176},"model.dfsmn.fsmns.0.fsmn.lookback_filter.weight":{dtype:"int8_pc",shape:[128,1,20],off:5200,scale_off:7760,scale_shape:[1,1,20]},"model.dfsmn.fsmns.1.fc1.0.bias":{dtype:"fp32",shape:[256],off:7840},"model.dfsmn.fsmns.1.fsmn.lookback_filter.weight":{dtype:"int8_pc",shape:[128,1,20],off:8864,scale_off:11424,scale_shape:[1,1,20]},"model.dfsmn.fsmns.2.fc1.0.bias":{dtype:"fp32",shape:[256],off:11504},"model.dfsmn.fsmns.2.fsmn.lookback_filter.weight":{dtype:"int8_pc",shape:[128,1,20],off:12528,scale_off:15088,scale_shape:[1,1,20]},"model.dfsmn.fsmns.3.fc1.0.bias":{dtype:"fp32",shape:[256],off:15168},"model.dfsmn.fsmns.3.fsmn.lookback_filter.weight":{dtype:"int8_pc",shape:[128,1,20],off:16192,scale_off:18752,scale_shape:[1,1,20]},"model.dfsmn.fsmns.4.fc1.0.bias":{dtype:"fp32",shape:[256],off:18832},"model.dfsmn.fsmns.4.fsmn.lookback_filter.weight":{dtype:"int8_pc",shape:[128,1,20],off:19856,scale_off:22416,scale_shape:[1,1,20]},"model.dfsmn.fsmns.5.fc1.0.bias":{dtype:"fp32",shape:[256],off:22496},"model.dfsmn.fsmns.5.fsmn.lookback_filter.weight":{dtype:"int8_pc",shape:[128,1,20],off:23520,scale_off:26080,scale_shape:[1,1,20]},"model.dfsmn.fsmns.6.fc1.0.bias":{dtype:"fp32",shape:[256],off:26160},"model.dfsmn.fsmns.6.fsmn.lookback_filter.weight":{dtype:"int8_pc",shape:[128,1,20],off:27184,scale_off:29744,scale_shape:[1,1,20]},"model.dfsmn.dnns.0.bias":{dtype:"fp32",shape:[256],off:29824},"model.out.bias":{dtype:"fp32",shape:[1],off:30848},"onnx::MatMul_403":{dtype:"int8_pc",shape:[80,256],off:30852,scale_off:51332,scale_shape:[1,256]},"onnx::MatMul_404":{dtype:"int8_pc",shape:[256,128],off:52356,scale_off:85124,scale_shape:[1,128]},"onnx::MatMul_417":{dtype:"int8_pc",shape:[128,256],off:85636,scale_off:118404,scale_shape:[1,256]},"onnx::MatMul_418":{dtype:"int8_pc",shape:[256,128],off:119428,scale_off:152196,scale_shape:[1,128]},"onnx::MatMul_431":{dtype:"int8_pc",shape:[128,256],off:152708,scale_off:185476,scale_shape:[1,256]},"onnx::MatMul_432":{dtype:"int8_pc",shape:[256,128],off:186500,scale_off:219268,scale_shape:[1,128]},"onnx::MatMul_445":{dtype:"int8_pc",shape:[128,256],off:219780,scale_off:252548,scale_shape:[1,256]},"onnx::MatMul_446":{dtype:"int8_pc",shape:[256,128],off:253572,scale_off:286340,scale_shape:[1,128]},"onnx::MatMul_459":{dtype:"int8_pc",shape:[128,256],off:286852,scale_off:319620,scale_shape:[1,256]},"onnx::MatMul_460":{dtype:"int8_pc",shape:[256,128],off:320644,scale_off:353412,scale_shape:[1,128]},"onnx::MatMul_473":{dtype:"int8_pc",shape:[128,256],off:353924,scale_off:386692,scale_shape:[1,256]},"onnx::MatMul_474":{dtype:"int8_pc",shape:[256,128],off:387716,scale_off:420484,scale_shape:[1,128]},"onnx::MatMul_487":{dtype:"int8_pc",shape:[128,256],off:420996,scale_off:453764,scale_shape:[1,256]},"onnx::MatMul_488":{dtype:"int8_pc",shape:[256,128],off:454788,scale_off:487556,scale_shape:[1,128]},"onnx::MatMul_501":{dtype:"int8_pc",shape:[128,256],off:488068,scale_off:520836,scale_shape:[1,256]},"onnx::MatMul_502":{dtype:"int8_pc",shape:[256,128],off:521860,scale_off:554628,scale_shape:[1,128]},"onnx::MatMul_515":{dtype:"int8_pc",shape:[128,256],off:555140,scale_off:587908,scale_shape:[1,256]},"onnx::MatMul_516":{dtype:"fp32",shape:[256,1],off:588932},"/Constant_output_0":{dtype:"int32",shape:[],off:589956},"/Constant_1_output_0":{dtype:"int32",shape:[],off:589960},"/Constant_2_output_0":{dtype:"int32",shape:[],off:589964},"/Constant_3_output_0":{dtype:"int32",shape:[],off:589968},"/Constant_4_output_0":{dtype:"int32",shape:[],off:589972},"/Constant_5_output_0":{dtype:"int32",shape:[],off:589976},"/Constant_6_output_0":{dtype:"int32",shape:[],off:589980},"/Constant_7_output_0":{dtype:"int32",shape:[],off:589984},"/model/dfsmn/fsmn1/Constant_output_0":{dtype:"int32",shape:[1],off:589988},"/model/dfsmn/fsmn1/Constant_1_output_0":{dtype:"int32",shape:[1],off:589992},"/model/dfsmn/fsmn1/Constant_2_output_0":{dtype:"int32",shape:[1],off:589996},"/model/dfsmn/fsmn1/Constant_3_output_0":{dtype:"int32",shape:[1],off:59e4},"/model/dfsmn/fsmn1/Constant_5_output_0":{dtype:"int32",shape:[1],off:590004},"/model/dfsmn/fsmn1/Constant_9_output_0":{dtype:"int32",shape:[1],off:590008}}},Yt={means:[10.42295174919564,10.862097411631494,11.764544378124809,12.490164701573908,13.25983008289003,13.89594383242307,14.364940238918987,14.593948347480778,14.749723601612253,14.668315348346496,14.730796723156509,14.775052459167833,14.9890519821556,15.178004932637085,15.253520314586988,15.328637048782031,15.334018588850057,15.288641702136166,15.4276616890477,15.246266155846598,15.092573799088989,15.290421940704482,15.07575008669762,15.186772872540853,15.088673242416798,15.170797396442111,15.070178088017926,15.150795340269006,15.108532832116397,15.115345080167454,15.141279987705998,15.131832359605129,15.145195868641611,15.19151892676777,15.235478667211774,15.306369752614641,15.373021476906201,15.416394625766584,15.459857436373436,15.39143273165164,15.46357624247469,15.399661212735632,15.462907917820873,15.441629120393843,15.484969525295984,15.552401775001249,15.638091925650645,15.705489346158819,15.767008852632651,15.855123781367105,15.867269782501769,15.891537408746947,15.9231448295521,15.978382613315533,16.014801667676718,16.048674939996204,16.082029914992358,16.09680075379873,16.093736693349236,16.07247919506059,16.075509664672943,16.02227087563821,15.976762101902347,15.89786454765505,15.812741644368487,15.711205109067762,15.604198886052728,15.553519438005933,15.51025275187747,15.460023817226517,15.4156843628003,15.37602764551613,15.328348980305998,15.295370796331634,15.185470194591382,15.017044975516262,14.905080029850632,14.623806569017782,14.138093813776406,13.313870348004635],inv_std:[.2494980879825924,.23563235243542163,.23145152525802104,.2332233926481505,.23182660283718737,.22853356937894798,.2243486976577694,.21898920450844725,.21832438092730974,.22082592767700662,.2229673556813116,.22288416257259386,.22234810686081127,.22100642502031184,.21994202276343874,.22005444019015313,.22070092118977014,.22150809748461409,.22236667273698002,.22305291750035372,.22335341587062665,.22438905727453648,.22547701626910854,.2269007560258811,.22823023223045188,.22931472070164832,.23046728075908798,.23083553439603108,.23143382733873202,.2322065940520882,.2325798897870885,.2336197007969686,.23437240620327746,.23508252486137127,.23578078965798868,.235892002292441,.2360209777141303,.23663799549538955,.2374987640063862,.2379845180109627,.23899377757763487,.239748152899516,.24030835895648858,.2409769361661754,.24143248909906587,.24135465696291541,.24079937967447773,.24047405396120294,.23995525139180407,.23952287673801784,.2394808893818449,.2393650908183211,.23929339134427347,.23902199338028696,.23857873289710127,.23814701563685442,.23804621120577427,.23824193788738984,.2386009552212688,.23915406501238878,.23922540730102645,.2393830803524144,.2397336021407156,.2396056154523928,.24028502694537057,.2406181323375118,.2406792985927079,.24096201908324874,.24043605546026958,.24021526735270676,.23972514279402155,.23871998076352863,.2374413126648784,.23619509194955604,.23337281484306663,.2268023271445609,.2257750261856693,.22503847248255957,.2263113742246566,.2289949344716713]}});var J=11920929e-14,Y=t=>1127*Math.log(1+t/700),kt=(()=>{let t=new Float64Array(400),s=2*Math.PI/399;for(let n=0;n<400;n++)t[n]=Math.pow(.5-.5*Math.cos(s*n),.85);return t})(),vt=(()=>{let s=Y(20),o=(Y(8e3)-s)/81,u=[];for(let a=0;a<80;a++){let e=s+a*o,f=s+(a+1)*o,p=s+(a+2)*o,m=new Float64Array(256),_=-1,d=-1;for(let r=0;r<256;r++){let l=Y(31.25*r);l>e&&l<p&&(m[r]=l<=f?(l-e)/(f-e):(p-l)/(p-f),_===-1&&(_=r),d=r)}u.push({offset:_,weights:m.slice(_,d+1)})}return u})(),Rt=(()=>{let t=new Uint16Array(512),s=Math.log2(512);for(let n=0;n<512;n++){let o=n,u=0;for(let a=0;a<s;a++)u=u<<1|o&1,o>>=1;t[n]=u}return t})(),st=new Float64Array(512/2),nt=new Float64Array(512/2);for(let t=0;t<512/2;t++)st[t]=Math.cos(-2*Math.PI*t/512),nt[t]=Math.sin(-2*Math.PI*t/512);function Nt(t,s,n){for(let o=0;o<512;o++){let u=Rt[o];if(u>o){let a=t[o];t[o]=t[u],t[u]=a;let e=s[o];s[o]=s[u],s[u]=e}}for(let o=2;o<=512;o<<=1){let u=o>>1,a=512/o;for(let e=0;e<512;e+=o)for(let f=0;f<u;f++){let p=st[f*a],m=nt[f*a],_=e+f,d=_+u,r=t[d]*p-s[d]*m,l=t[d]*m+s[d]*p;t[d]=t[_]-r,s[d]=s[_]-l,t[_]+=r,s[_]+=l}}for(let o=0;o<=256;o++)n[o]=t[o]*t[o]+s[o]*s[o]}var E=new Float64Array(512),K=new Float64Array(512),tt=new Float64Array(257);function It(t,s,n,o){for(let e=0;e<400;e++)E[e]=t[s+e];let u=0;for(let e=0;e<400;e++)u+=E[e];let a=u/400;for(let e=0;e<400;e++)E[e]-=a;for(let e=399;e>0;e--)E[e]-=.97*E[e-1];E[0]-=.97*E[0];for(let e=0;e<400;e++)E[e]*=kt[e];for(let e=400;e<512;e++)E[e]=0;K.fill(0),Nt(E,K,tt);for(let e=0;e<80;e++){let{offset:f,weights:p}=vt[e],m=0;for(let _=0;_<p.length;_++)m+=p[_]*tt[f+_];m<J&&(m=J),n[o+e]=Math.log(m)}}function ot(t){let s=new Float64Array(t.length);for(let n=0;n<t.length;n++){let o=t[n];o>1?o=1:o<-1&&(o=-1),s[n]=Math.trunc(Math.fround(o*32767))}return s}function Dt(t,s,n){let{means:o,inv_std:u}=n;for(let a=0;a<s;a++){let e=a*80;for(let f=0;f<80;f++)t[e+f]=(t[e+f]-o[f])*u[f]}}var O=class{constructor(s){this.buffer=[];this.bufferStart=0;this.nextFrame=0;this.cmvn=s}reset(){this.buffer=[],this.bufferStart=0,this.nextFrame=0}push(s){for(let f=0;f<s.length;f++)this.buffer.push(s[f]);let n=this.bufferStart+this.buffer.length,o=[],u=0;for(;this.nextFrame*160+400<=n;){let f=this.nextFrame*160-this.bufferStart,p=new Float32Array(80);It(this.buffer,f,p,0),Dt(p,1,this.cmvn);for(let m=0;m<80;m++)o.push(p[m]);this.nextFrame++,u++}let a=this.nextFrame*160,e=a-this.bufferStart;return e>0&&(this.buffer=this.buffer.slice(e),this.bufferStart=a),{feats:new Float32Array(o),n:u}}};var b=class{constructor(s,n){this.shape=s;this.data=n}get rank(){return this.shape.length}get isInt(){return this.data instanceof Int32Array}};function w(t){let s=1;for(let n of t)s*=n;return s}function S(t){let s=new Array(t.length),n=1;for(let o=t.length-1;o>=0;o--)s[o]=n,n*=t[o];return s}function ut(t){return new b(t.slice(),new Float32Array(w(t)))}function ft(t,s){let n=Math.max(t.length,s.length),o=new Array(n);for(let u=0;u<n;u++){let a=t[t.length-1-u]??1,e=s[s.length-1-u]??1;if(a!==e&&a!==1&&e!==1)throw new Error(`broadcast mismatch ${t} vs ${s}`);o[n-1-u]=Math.max(a,e)}return o}function mt(t,s,n){let o=ft(t.shape,s.shape),u=w(o),a=new Float32Array(u),e=o.length,f=S(t.shape),p=S(s.shape),m=new Int32Array(e),_=new Int32Array(e);for(let c=0;c<e;c++){let M=c-(e-t.rank),y=c-(e-s.rank);m[c]=M>=0&&t.shape[M]!==1?f[M]:0,_[c]=y>=0&&s.shape[y]!==1?p[y]:0}let d=new Int32Array(e),r=t.data,l=s.data,A=0,h=0;for(let c=0;c<u;c++){a[c]=n(r[A],l[h]);for(let M=e-1;M>=0;M--){if(++d[M]<o[M]){A+=m[M],h+=_[M];break}d[M]=0,A-=m[M]*(o[M]-1),h-=_[M]*(o[M]-1)}}return new b(o,a)}function at(t,s){return mt(t,s,(n,o)=>n+o)}function pt(t,s){return mt(t,s,(n,o)=>n*o)}function _t(t){let s=new Float32Array(t.data.length);for(let n=0;n<s.length;n++)s[n]=t.data[n]>0?t.data[n]:0;return new b(t.shape.slice(),s)}function dt(t){let s=new Float32Array(t.data.length);for(let n=0;n<s.length;n++)s[n]=1/(1+Math.exp(-t.data[n]));return new b(t.shape.slice(),s)}function lt(t,s){let n=s??t.shape.map((r,l)=>t.rank-1-l),o=n.map(r=>t.shape[r]),u=t.data.length,a=new Float32Array(u),e=S(t.shape),f=o.length,p=new Int32Array(f);for(let r=0;r<f;r++)p[r]=e[n[r]];let m=new Int32Array(f),_=t.data,d=0;for(let r=0;r<u;r++){a[r]=_[d];for(let l=f-1;l>=0;l--){if(++m[l]<o[l]){d+=p[l];break}m[l]=0,d-=p[l]*(o[l]-1)}}return new b(o,a)}function rt(t,s){let n=t[0],o=n.rank,u=s<0?s+o:s,a=n.shape.slice();a[u]=t.reduce((m,_)=>m+_.shape[u],0);let e=new Float32Array(w(a)),f=S(a),p=0;for(let m of t){let _=S(m.shape),d=new Array(o).fill(0);for(let r=0;r<m.data.length;r++){let l=r;for(let h=0;h<o;h++)d[h]=Math.floor(l/_[h]),l-=d[h]*_[h];let A=0;for(let h=0;h<o;h++){let c=h===u?d[h]+p:d[h];A+=c*f[h]}e[A]=m.data[r]}p+=m.shape[u]}return new b(a,e)}function ct(t,s,n){let o=t.rank,u=n<0?n+o:n,a=S(t.shape),e=s.rank===0,f=e?[s.data[0]]:Array.from(s.data),p=e?[]:s.shape.slice(),m=[...t.shape.slice(0,u),...p,...t.shape.slice(u+1)],_=new Float32Array(w(m)),d=S(m),r=p.length;for(let l=0;l<_.length;l++){let A=l,h=new Array(m.length);for(let i=0;i<m.length;i++)h[i]=Math.floor(A/d[i]),A-=h[i]*d[i];let c=0;for(let i=0;i<u;i++)c+=h[i]*a[i];let M=0;for(let i=0;i<r;i++)M=M*p[i]+h[u+i];let y=f[e?0:M];y<0&&(y+=t.shape[u]),c+=y*a[u];for(let i=u+1;i<o;i++)c+=h[i-1+r]*a[i];_[l]=t.data[c]}return new b(m,_)}function it(t,s){let n=t.rank+s.length,o=s.map(e=>e<0?e+n:e).sort((e,f)=>e-f),u=t.shape.slice();for(let e of o)u.splice(e,0,1);let a=t.data instanceof Int32Array?Int32Array.from(t.data):Float32Array.from(t.data);return new b(u,a)}var Gt=2**31-1;function ht(t,s,n,o,u){let a=t.rank,e=o??s.map((c,M)=>M),f=u??s.map(()=>1),p=new Array(a).fill(0),m=t.shape.slice(),_=new Array(a).fill(1);for(let c=0;c<e.length;c++){let M=e[c]<0?e[c]+a:e[c],y=t.shape[M],i=s[c];i<0&&(i+=y),i=Math.max(0,Math.min(i,y));let T=n[c];T>=Gt?T=y:(T<0&&(T+=y),T=Math.max(0,Math.min(T,y))),p[M]=i,m[M]=T,_[M]=f[c]}let d=new Array(a);for(let c=0;c<a;c++)d[c]=Math.max(0,Math.ceil((m[c]-p[c])/_[c]));let r=S(t.shape),l=S(d),h=t.data instanceof Int32Array?new Int32Array(w(d)):new Float32Array(w(d));for(let c=0;c<h.length;c++){let M=c,y=0;for(let i=0;i<a;i++){let T=Math.floor(M/l[i]);M-=T*l[i],y+=(p[i]+T*_[i])*r[i]}h[c]=t.data[y]}return new b(d,h)}function Mt(t,s){let n=t,o=s,u=!1,a=!1;n.rank===1&&(n=new b([1,n.shape[0]],n.data),u=!0),o.rank===1&&(o=new b([o.shape[0],1],o.data),a=!0);let e=n.shape[n.rank-2],f=n.shape[n.rank-1],p=o.shape[o.rank-2],m=o.shape[o.rank-1];if(f!==p)throw new Error(`matmul inner dim ${f} vs ${p}`);let _=n.shape.slice(0,n.rank-2),d=o.shape.slice(0,o.rank-2),r=ft(_,d),l=w(r),A=[...r,e,m],h=new Float32Array(w(A)),c=e*f,M=p*m,y=e*m,i=S(r),T=S(_),B=S(d),D=new Array(r.length);for(let g=0;g<l;g++){let G=g;for(let C=0;C<r.length;C++)D[C]=Math.floor(G/i[C]),G-=D[C]*i[C];let L=0;for(let C=0;C<_.length;C++){let R=D[C+(r.length-_.length)];L+=(_[C]===1?0:R)*T[C]}let v=0;for(let C=0;C<d.length;C++){let R=D[C+(r.length-d.length)];v+=(d[C]===1?0:R)*B[C]}let U=L*c,$=v*M,P=g*y;for(let C=0;C<e;C++){let R=U+C*f;for(let H=0;H<m;H++){let N=0;for(let k=0;k<f;k++)N+=n.data[R+k]*o.data[$+k*m+H];h[P+C*m+H]=N}}}let x=new b(A,h);return u&&(x=et(x,x.rank-2)),a&&(x=et(x,x.rank-1)),x}function et(t,s){let n=t.shape.slice();return n.splice(s,1),new b(n,t.data)}function At(t,s,n,o,u,a,e){let[f,p,m]=t.shape,[_,d,r]=s.shape,l=u[0],A=a[0],h=e[0],c=m+l+u[1],M=Math.floor((c-(A*(r-1)+1))/h)+1,y=new Float32Array(f*_*M),i=S(t.shape),T=S(s.shape),B=_/o,D=p/o;for(let x=0;x<f;x++)for(let g=0;g<o;g++)for(let G=0;G<B;G++){let L=g*B+G;for(let v=0;v<M;v++){let U=0,$=v*h-l;for(let P=0;P<d;P++){let C=g*D+P,R=x*i[0]+C*i[1],H=L*T[0]+P*T[1];for(let N=0;N<r;N++){let k=$+N*A;k<0||k>=m||(U+=s.data[H+N]*t.data[R+k])}}n&&(U+=n.data[L]),y[x*_*M+L*M+v]=U}}return new b([f,_,M],y)}var Lt=80;function Pt(t,s){let n=w(t.shape);if(t.dtype==="int8_pc"){let u=new Float32Array(n);for(let f=0;f<n;f++)u[f]=s.getInt8(t.off+f);let a=w(t.scale_shape),e=new Float32Array(a);for(let f=0;f<a;f++)e[f]=s.getFloat32(t.scale_off+f*4,!0);return pt(new b(t.shape.slice(),u),new b(t.scale_shape.slice(),e))}if(t.dtype==="int32"){let u=new Int32Array(n);for(let a=0;a<n;a++)u[a]=s.getInt32(t.off+a*4,!0);return new b(t.shape.slice(),u)}let o=new Float32Array(n);for(let u=0;u<n;u++)o[u]=s.getFloat32(t.off+u*4,!0);return new b(t.shape.slice(),o)}var q=class{constructor(s,n){this.weights={};this.nodes=s.nodes,this.inputNames=s.inputs,this.outputNames=s.outputs,this.cacheShape=s.cache_shape;let o=new DataView(n.buffer,n.byteOffset,n.byteLength);for(let[u,a]of Object.entries(s.weights))this.weights[u]=Pt(a,o);this.reset()}reset(){this.cache=ut(this.cacheShape)}get cacheState(){return this.cache.data}step(s,n){let o={...this.weights};o[this.inputNames[0]]=new b([1,n,Lt],s),o[this.inputNames[1]]=this.cache;for(let f of this.nodes){let p=f.attrs,m=f.inputs.map(d=>d?o[d]:null),_;switch(f.op){case"MatMul":_=Mt(m[0],m[1]);break;case"Add":_=at(m[0],m[1]);break;case"Relu":_=_t(m[0]);break;case"Sigmoid":_=dt(m[0]);break;case"Transpose":_=lt(m[0],p.perm);break;case"Concat":_=rt(m.filter(d=>d!==null),p.axis);break;case"Gather":_=ct(m[0],m[1],p.axis??0);break;case"Unsqueeze":{let d=m.length>1&&m[1]!==null?Array.from(m[1].data):p.axes;_=it(m[0],d);break}case"Slice":{let d=Array.from(m[1].data),r=Array.from(m[2].data),l=m.length>3&&m[3]!==null?Array.from(m[3].data):void 0,A=m.length>4&&m[4]!==null?Array.from(m[4].data):void 0;_=ht(m[0],d,r,l,A);break}case"Conv":_=At(m[0],m[1],m.length>2?m[2]:null,p.group??1,p.pads??[0,0],p.dilations??[1],p.strides??[1]);break;default:throw new Error("unhandled op "+f.op)}o[f.outputs[0]]=_}this.cache=o[this.outputNames[1]];let u=o[this.outputNames[0]],a=S(u.shape),e=new Float32Array(n);for(let f=0;f<n;f++)e[f]=u.data[f*a[1]];return e}};var I=80,bt=160/16e3*1e3,Ht=1e3/bt,Ut=700,F=Math.round(Ut/bt),yt=8,Z=yt+1,zt=.2,Bt=.75,Ot=15,qt=4,Vt=50;function Wt(t,s,n){let o=0;for(let p=0;p<s;p++)o+=t[p];o/=s;let u=n*s/Ht,a=2*Math.cos(2*Math.PI*u/s),e=0,f=0;for(let p=0;p<s;p++){let m=t[p]-o+a*e-f;f=e,e=m}return Math.sqrt(Math.max(0,e*e+f*f-a*e*f))/s}function Qt(t,s){let n=0;for(let u=0;u<s;u++)n+=t[u];n/=s;let o=0;for(let u=0;u<s;u++)o+=(t[u]-n)**2;return Math.sqrt(o/s)}function Ct(t,s,n){let o=Math.min(s-1,Math.max(0,Math.round(n*(s-1))));return t[o]}var V=class{constructor(){this.motion=new Float64Array(F);this.flux=new Float64Array(F);this.level=new Float64Array(F);this.candidate=new Uint8Array(F);this.count=0;this.position=0;this.history=new Float32Array(Z*I);this.historyNorm=new Float64Array(Z);this.historyPosition=0;this.seen=0;this.scratchMotion=new Float64Array(F);this.scratchFlux=new Float64Array(F);this.scratchLevel=new Float64Array(F)}reset(){this.count=0,this.position=0,this.historyPosition=0,this.seen=0}push(s,n,o){let u=0,a=0,e=this.historyPosition*I;for(let l=0;l<I;l++){let A=s[n+l];this.history[e+l]=A,u+=A,a+=A*A}let f=Math.sqrt(a);this.historyNorm[this.historyPosition]=f;let p=(this.historyPosition+1)%Z;if(this.historyPosition=p,this.seen++,this.seen<=yt)return;let m=p*I,_=0,d=0;for(let l=0;l<I;l++)_+=this.history[e+l]*this.history[m+l],d+=Math.abs(this.history[e+l]-this.history[m+l]);let r=f*this.historyNorm[p];this.motion[this.position]=r>1e-9?1-_/r:0,this.flux[this.position]=d/I,this.level[this.position]=u/I,this.candidate[this.position]=o>=zt?1:0,this.position=(this.position+1)%F,this.count<F&&this.count++}score(){let s=this.count<F?0:this.position,n=0;for(let e=0;e<this.count;e++){let f=(s+e)%F;this.scratchLevel[e]=this.level[f],this.candidate[f]&&(this.scratchMotion[n]=this.motion[f],this.scratchFlux[n]=this.flux[f],n++)}if(n<Ot)return null;let o=this.scratchMotion.subarray(0,n),u=this.scratchFlux.subarray(0,n);o.sort(),u.sort();let a=0;if(this.count>=Vt){let e=Qt(this.scratchLevel,this.count);e>1e-6&&(a=Wt(this.scratchLevel,this.count,qt)/e)}return{motion:Ct(o,n,Bt),medianFlux:Ct(u,n,.5),modulation:a,frames:n}}};var z=5,Zt=80,jt=160/16e3*1e3;function xt(t){let s=new O(t.cmvn),n=new q(t.graph,t.weights),o=new V,u=new Float64Array(z),a=0,e=0,f=0,p=0,m=null;function _(d){return a<z?(u[e]=d,f+=d,a++,e=(e+1)%z,f/a):(f+=d-u[e],u[e]=d,e=(e+1)%z,f/z)}return{pushPcm(d){let{feats:r,n:l}=s.push(ot(d));if(l===0)return;let A=n.step(r,l);if(!m){p+=l;return}for(let h=0;h<l;h++){p++;let c=_(A[h]);o.push(r,h*Zt,c),m(c,p*jt,o.score())}},onProb(d){m=d},reset(){s.reset(),n.reset(),o.reset(),u.fill(0),a=0,e=0,f=0,p=0}}}async function wt(t){let s=await Promise.resolve().then(()=>(Tt(),St));return{graph:s.graph,cmvn:s.cmvn,weights:t}}var W=self,Q=null;async function Xt(t){let s=await wt(new Uint8Array(t));Q=xt(s),Q.onProb((n,o,u)=>W.postMessage({type:"prob",prob:n,tMs:o,speech:u})),W.postMessage({type:"ready"})}W.onmessage=t=>{let s=t.data;switch(s.type){case"init":Xt(s.weights).catch(n=>W.postMessage({type:"error",message:String(n)}));return;case"pcm":Q?.pushPcm(new Float32Array(s.buffer));return;case"reset":Q?.reset();return}};})();\n';});var of={};du(of,{MOOD_WORKER_SOURCE:()=>rA});var rA,af=cu(()=>{rA=`"use strict";(()=>{var o=self,l=/^(INFO: |[IW]\\d{4} |Graph successfully started running)/;for(let t of["log","info","warn","error"]){let e=console[t].bind(console);console[t]=(...r)=>{typeof r[0]=="string"&&l.test(r[0])||e(...r)}}var s=null,i=(t,e,r)=>t.FaceLandmarker.createFromOptions({wasmLoaderPath:e.loaderUrl,wasmBinaryPath:e.wasmUrl},{baseOptions:{modelAssetBuffer:e.model,delegate:r},runningMode:"VIDEO",numFaces:1,outputFaceBlendshapes:!0});async function d(t){o.importScripts(t.bundleUrl);let e=o.Vision;if(!e?.FaceLandmarker)throw new Error("MediaPipe bundle defined no Vision global");if(t.delegate==="GPU")try{s=await i(e,t,"GPU"),o.postMessage({type:"ready",delegate:"GPU"});return}catch{}s=await i(e,t,"CPU"),o.postMessage({type:"ready",delegate:"CPU"})}function p(t,e){try{if(!s)throw new Error("frame before init");let n=s.detectForVideo(t,e).faceBlendshapes?.[0]?.categories;o.postMessage({type:"result",blendshapes:n?Object.fromEntries(n.map(a=>[a.categoryName,a.score])):null})}catch(r){o.postMessage({type:"error",message:String(r)})}finally{t.close()}}o.onmessage=t=>{let e=t.data;e.type==="init"?d(e).catch(r=>o.postMessage({type:"error",message:String(r)})):p(e.frame,e.timestampMs)};})();
|
|
7
|
+
`;});var eo=uu((Zi,Ql)=>{(function(e,t){typeof Zi=="object"&&typeof Ql=="object"?Ql.exports=t():typeof define=="function"&&define.amd?define([],t):typeof Zi=="object"?Zi.rive=t():e.rive=t();})(Zi,()=>(()=>{var n=[,((o,s,u)=>{u.r(s),u.d(s,{Animation:()=>p.Animation});var p=u(2);}),((o,s,u)=>{u.r(s),u.d(s,{Animation:()=>p});var p=(function(){function h(A,y,b,m){this.animation=A,this.artboard=y,this.playing=m,this.loopCount=0,this.scrubTo=null,this.instance=new b.LinearAnimationInstance(A,y);}return Object.defineProperty(h.prototype,"name",{get:function(){return this.animation.name},enumerable:false,configurable:true}),Object.defineProperty(h.prototype,"time",{get:function(){return this.instance.time},set:function(A){this.instance.time=A;},enumerable:false,configurable:true}),Object.defineProperty(h.prototype,"loopValue",{get:function(){return this.animation.loopValue},enumerable:false,configurable:true}),Object.defineProperty(h.prototype,"needsScrub",{get:function(){return this.scrubTo!==null},enumerable:false,configurable:true}),h.prototype.advance=function(A){this.scrubTo===null?this.instance.advance(A):(this.instance.time=0,this.instance.advance(this.scrubTo),this.scrubTo=null);},h.prototype.apply=function(A){this.instance.apply(A);},h.prototype.cleanup=function(){this.instance.delete();},h})();}),((o,s,u)=>{u.r(s),u.d(s,{RuntimeLoader:()=>y});var p=u(4),h=u(5),A=function(){return A=Object.assign||function(b){for(var m,S=1,C=arguments.length;S<C;S++){m=arguments[S];for(var I in m)Object.prototype.hasOwnProperty.call(m,I)&&(b[I]=m[I]);}return b},A.apply(this,arguments)},y=(function(){function b(){}return b.notifyError=function(m){var S;for(b.isLoading=false;b.errorCallbackQueue.length>0;)(S=b.errorCallbackQueue.shift())===null||S===void 0||S(m);b.callBackQueue=[];},b.loadRuntime=function(){var m=b.wasmURL,S=b.wasmBinary;b.enablePerfMarks&&performance.mark("rive:wasm-init:start"),p.default(A({locateFile:function(){return m}},S?{wasmBinary:S}:{})).then(function(C){var I;for(b.enablePerfMarks&&(performance.mark("rive:wasm-init:end"),performance.measure("rive:wasm-init","rive:wasm-init:start","rive:wasm-init:end")),b.runtime=C,b.errorCallbackQueue=[];b.callBackQueue.length>0;)(I=b.callBackQueue.shift())===null||I===void 0||I(b.runtime);}).catch(function(C){var I={message:C?.message||"Unknown error",type:C?.name||"Error",wasmError:C instanceof WebAssembly.CompileError||C instanceof WebAssembly.RuntimeError,originalError:C};console.debug("Rive WASM load error details:",I);var L=b.wasmFallbackURL,B=L!==null&&m.toLowerCase()===L.toLowerCase();if(L!==null&&!B)console.warn("Failed to load WASM from ".concat(m," (").concat(I.message,"), trying fallback URL: ").concat(L)),b.wasmBinary=null,b.setWasmUrl(L),b.loadRuntime();else {var W=B?"the configured WASM URL or its fallback (".concat(L,")"):m,Q=["Could not load Rive WASM file from ".concat(W,"."),"Possible reasons:","- Network connection is down","- WebAssembly is not supported in this environment","- The WASM file is corrupted or incompatible",`
|
|
8
|
+
Error details:`,"- Type: ".concat(I.type),"- Message: ".concat(I.message),"- WebAssembly-specific error: ".concat(I.wasmError),`
|
|
9
|
+
To resolve, you may need to:`,"1. Check your network connection","2. Set a new WASM source via RuntimeLoader.setWasmUrl()","3. Call RuntimeLoader.awaitInstance() again"].join(`
|
|
10
|
+
`);console.error(Q),b.notifyError(new Error(Q));}});},b.getInstance=function(m,S){b.isLoading||(b.isLoading=true,b.loadRuntime()),b.runtime?m(b.runtime):(b.callBackQueue.push(m),S&&b.errorCallbackQueue.push(S));},b.awaitInstance=function(){return new Promise(function(m,S){return b.getInstance(m,S)})},b.setWasmUrl=function(m){b.wasmURL=m;},b.getWasmUrl=function(){return b.wasmURL},b.setWasmFallbackUrl=function(m){b.wasmFallbackURL=m;},b.getWasmFallbackUrl=function(){return b.wasmFallbackURL},b.setWasmBinary=function(m){if(m instanceof ArrayBuffer||m===null){b.wasmBinary=m;return}console.error("setWasmBinary expects an ArrayBuffer or null");},b.getWasmBinary=function(){return b.wasmBinary},b.isLoading=false,b.callBackQueue=[],b.wasmURL="https://unpkg.com/".concat(h.name,"@").concat(h.version,"/rive.wasm"),b.wasmFallbackURL="https://cdn.jsdelivr.net/npm/".concat(h.name,"@").concat(h.version,"/rive_fallback.wasm"),b.wasmBinary=null,b.errorCallbackQueue=[],b.enablePerfMarks=false,b})();}),((o,s,u)=>{u.r(s),u.d(s,{default:()=>h});var p=(()=>{var A=typeof document<"u"?document.currentScript?.src:void 0;return(function(y={}){var b,m=y,S,C,I=new Promise((i,a)=>{S=i,C=a;}),L=typeof window=="object",B=typeof importScripts=="function";function W(){function i(M){let k=d;c=a=0,d=new Map,k.forEach(D=>{try{D(M);}catch(O){console.error(O);}}),this.mb(),v&&v.Nb();}let a=0,c=0,d=new Map,v=null,_=null;this.requestAnimationFrame=function(M){a||(a=requestAnimationFrame(i.bind(this)));let k=++c;return d.set(k,M),k},this.cancelAnimationFrame=function(M){d.delete(M),a&&d.size==0&&(cancelAnimationFrame(a),a=0);},this.Lb=function(M){_&&(document.body.remove(_),_=null),M||(_=document.createElement("div"),_.style.backgroundColor="black",_.style.position="fixed",_.style.right=0,_.style.top=0,_.style.color="white",_.style.padding="4px",_.innerHTML="RIVE FPS",M=function(k){_.innerHTML="RIVE FPS "+k.toFixed(1);},document.body.appendChild(_)),v=new function(){let k=0,D=0;this.Nb=function(){var O=performance.now();D?(++k,O-=D,1e3<O&&(M(1e3*k/O),k=D=0)):(D=O,k=0);};};},this.mb=function(){};}function Q(){console.assert(true);let i=new Map,a=-1/0;this.push=function(c){return c=c+255>>8,i.has(c)&&clearTimeout(i.get(c)),i.set(c,setTimeout(function(){i.delete(c),i.length==0?a=-1/0:c==a&&(a=Math.max(...i.keys()),console.assert(a<c));},1e3)),a=Math.max(c,a),a<<8};}let Z=m.onRuntimeInitialized;m.onRuntimeInitialized=function(){Z&&Z();let i=m.decodeAudio;m.decodeAudio=function(_,M){_=i(_),M(_);};let a=m.decodeFont;m.decodeFont=function(_,M){_=a(_),M(_);};let c=m.setFallbackFontCb;m.setFallbackFontCallback=typeof c=="function"?function(_){c(_);}:function(){console.warn("Module.setFallbackFontCallback called, but text support is not enabled in this build.");};let d=m.FileAssetLoader;m.ptrToAsset=_=>{let M=m.ptrToFileAsset(_);return M.isImage?m.ptrToImageAsset(_):M.isFont?m.ptrToFontAsset(_):M.isAudio?m.ptrToAudioAsset(_):M},m.CustomFileAssetLoader=d.extend("CustomFileAssetLoader",{__construct:function({loadContents:_}){this.__parent.__construct.call(this),this.Bb=_;},loadContents:function(_,M){return _=m.ptrToAsset(_),this.Bb(_,M)}}),m.CDNFileAssetLoader=d.extend("CDNFileAssetLoader",{__construct:function(){this.__parent.__construct.call(this);},loadContents:function(_){let M=m.ptrToAsset(_);return _=M.cdnUuid,_===""?false:((function(k,D){var O=new XMLHttpRequest;O.responseType="arraybuffer",O.onreadystatechange=function(){O.readyState==4&&O.status==200&&D(O);},O.open("GET",k,true),O.send(null);})(M.cdnBaseUrl+"/"+_,k=>{M.decode(new Uint8Array(k.response));}),true)}}),m.FallbackFileAssetLoader=d.extend("FallbackFileAssetLoader",{__construct:function(){this.__parent.__construct.call(this),this.ib=[];},addLoader:function(_){this.ib.push(_);},loadContents:function(_,M){for(let k of this.ib)if(k.loadContents(_,M))return true;return false}});let v=m.computeAlignment;m.computeAlignment=function(_,M,k,D,O=1){return v.call(this,_,M,k,D,O)};};let $=m.onRuntimeInitialized;m.onRuntimeInitialized=function(){function i(K){this.G=K,this.Ab=K.getContext("2d"),this.Eb=d,this.S=[],this.ja=0,this.clear=function(){console.assert(this.ja==0),this.S=[],v.delete(this);},this.save=function(){++this.ja,this.S.push(d.save.bind(d));},this.restore=function(){0<this.ja&&(this.S.push(d.restore.bind(d)),--this.ja);},this.transform=function(ne){this.S.push(d.transform.bind(d,ne));},this.align=function(ne,Ce,Oe,ze,ut=1){this.S.push(d.align.bind(d,ne,Ce,Oe,ze,ut));},this.flush=function(){console.assert(this.ja==0),v.add(this),d.Ya||c();},this.delete=function(){};}function a(K,ne=false){var Ce={alpha:true,depth:ne,stencil:ne,antialias:ne,premultipliedAlpha:true,preserveDrawingBuffer:0,powerPreference:"high-performance",failIfMajorPerformanceCaveat:0,enableExtensionsByDefault:false,explicitSwapControl:0,renderViaOffscreenBackBuffer:0};if(ne=K.getContext("webgl2",Ce),!ne)return null;Ce=mm(ne,Ce),Is(Ce);let Oe=_(K.width,K.height);Oe.Ma=Ce,Oe.G=K,Oe.Na=K.width,Oe.Za=K.height,Oe.T=ne;var ze=Oe.delete;return Oe.delete=function(){ze.call(this);var ut=this.Ma;Tn===Ot[ut]&&(Tn=null),typeof JSEvents=="object"&&JSEvents.Qc(Ot[ut].F.canvas),Ot[ut]&&Ot[ut].F.canvas&&(Ot[ut].F.canvas.zb=void 0),this.Ma=this.G=this.Na=this.T=Ot[ut]=null;},Oe}function c(){if(d){var K=d.Db,ne=0,Ce=0,Oe=0,ze=Array(v.size),ut=0;for(var yt of v)yt.ea=Math.min(yt.G.width,K),yt.da=Math.min(yt.G.height,K),yt.Ka=yt.da*yt.ea,ne=Math.max(ne,yt.ea),Ce=Math.max(Ce,yt.da),Oe+=yt.Ka,ze[ut++]=yt;if(v.clear(),!(0>=Oe)){for(ne=1<<(0>=ne?0:32-Math.clz32(ne-1)),Ce=1<<(0>=Ce?0:32-Math.clz32(Ce-1));Ce*ne<Oe;)ne<=Ce?ne*=2:Ce*=2;for(ne=Math.min(ne,K),ne=Math.min(Ce,K),ze.sort((Cn,Bs)=>Bs.Ka-Cn.Ka),Oe=new m.DynamicRectanizer(K),yt=0;yt<ze.length;){for(Oe.reset(ne,Ce),ut=yt;ut<ze.length;++ut){var _t=ze[ut],pt=Oe.addRect(_t.ea,_t.da);if(0>pt){console.assert(ut>yt);break}_t.pa=pt&65535,_t.qa=pt>>16;}for(_t=D.push(Oe.drawWidth()),pt=O.push(Oe.drawHeight()),console.assert(_t>=Oe.drawWidth()),console.assert(pt>=Oe.drawHeight()),console.assert(_t<=K),console.assert(pt<=K),d.G.width!=_t&&(d.G.width=_t),d.G.height!=pt&&(d.G.height=pt),d.clear(),_t=yt;_t<ut;++_t){pt=ze[_t],d.saveClipRect(pt.pa,pt.qa,pt.pa+pt.ea,pt.qa+pt.da);let Cn=new m.Mat2D;Cn.xx=pt.ea/pt.G.width,Cn.yy=pt.da/pt.G.height,Cn.xy=Cn.yx=0,Cn.tx=pt.pa,Cn.ty=pt.qa,d.transform(Cn);for(let Bs of pt.S)Bs();d.restoreClipRect(),pt.S=[];}for(d.flush();yt<ut;++yt)_t=ze[yt],pt=_t.Ab,pt.globalCompositeOperation="copy",pt.drawImage(d.G,_t.pa,_t.qa,_t.ea,_t.da,0,0,_t.G.width,_t.G.height);yt=ut;}}}}$&&$();let d=null,v=new Set,_=m.makeRenderer;m.makeRenderer=function(K,ne){if(!d){let Ce=function(Oe){var ze=document.createElement("canvas");return ze.width=1,ze.height=1,d=a(ze,Oe),d?(d.Ya=!!d.T.getExtension("WEBGL_shader_pixel_local_storage"),d.Db=Math.min(d.T.getParameter(d.T.MAX_RENDERBUFFER_SIZE),d.T.getParameter(d.T.MAX_TEXTURE_SIZE)),d.La=!d.Ya,(Oe=d.T.getExtension("WEBGL_debug_renderer_info"))&&(ze=d.T.getParameter(Oe.UNMASKED_RENDERER_WEBGL),d.T.getParameter(Oe.UNMASKED_VENDOR_WEBGL).includes("Google")&&ze.includes("ANGLE Metal Renderer")&&(d.La=false)),d):null};if(d=Ce(true),!d)throw "Unable to create WebGL context, your environment may not support WebGL. Try out @rive-app/canvas as an alternative.";d.La||(d=Ce(false));}return ne?new i(K):a(K,d.La)};let M=m.Artboard.prototype.delete;m.Artboard.prototype.delete=function(){this.Fb=true,M.call(this);};let k=m.Artboard.prototype.draw;m.Artboard.prototype.draw=function(K){K.S?K.S.push(()=>{this.Fb||k.call(this,K.Eb);}):k.call(this,K);};let D=new Q,O=new Q,X=new W;m.requestAnimationFrame=X.requestAnimationFrame.bind(X),m.cancelAnimationFrame=X.cancelAnimationFrame.bind(X),m.enableFPSCounter=X.Lb.bind(X),X.mb=c,m.resolveAnimationFrame=c;let be=m.load;m.load=function(K,ne,Ce=true){let Oe=new m.FallbackFileAssetLoader;return ne!==void 0&&Oe.addLoader(ne),Ce&&(ne=new m.CDNFileAssetLoader,Oe.addLoader(ne)),Promise.resolve(be(K,Oe))};let Ee=m.WebGL2Renderer.prototype.clear;m.WebGL2Renderer.prototype.clear=function(){Is(this.Ma);let K=this.G;(this.Na!=K.width||this.Za!=K.height)&&(this.resize(K.width,K.height),this.Na=K.width,this.Za=K.height),Ee.call(this);},m.decodeImage=function(K,ne){K=m.decodeWebGL2Image(K),ne(K);};let F=m.Renderer.prototype.align;m.Renderer.prototype.align=function(K,ne,Ce,Oe,ze=1){F.call(this,K,ne,Ce,Oe,ze);};};var oe=Object.assign({},m),J="./this.program",H="",de,te;(L||B)&&(B?H=self.location.href:typeof document<"u"&&document.currentScript&&(H=document.currentScript.src),A&&(H=A),H.startsWith("blob:")?H="":H=H.substr(0,H.replace(/[?#].*/,"").lastIndexOf("/")+1),B&&(te=i=>{var a=new XMLHttpRequest;return a.open("GET",i,false),a.responseType="arraybuffer",a.send(null),new Uint8Array(a.response)}),de=(i,a,c)=>{if(pe(i)){var d=new XMLHttpRequest;d.open("GET",i,true),d.responseType="arraybuffer",d.onload=()=>{d.status==200||d.status==0&&d.response?a(d.response):c();},d.onerror=c,d.send(null);}else fetch(i,{credentials:"same-origin"}).then(v=>v.ok?v.arrayBuffer():Promise.reject(Error(v.status+" : "+v.url))).then(a,c);});var xe=m.print||console.log.bind(console),Se=m.printErr||console.error.bind(console);Object.assign(m,oe),oe=null,m.thisProgram&&(J=m.thisProgram);var ue;m.wasmBinary&&(ue=m.wasmBinary);var Ie,ae=false,G,z,P,N,U,q,se,Re;function Pe(){var i=Ie.buffer;m.HEAP8=G=new Int8Array(i),m.HEAP16=P=new Int16Array(i),m.HEAPU8=z=new Uint8Array(i),m.HEAPU16=N=new Uint16Array(i),m.HEAP32=U=new Int32Array(i),m.HEAPU32=q=new Uint32Array(i),m.HEAPF32=se=new Float32Array(i),m.HEAPF64=Re=new Float64Array(i);}var we=[],ve=[],De=[];function Xe(){var i=m.preRun.shift();we.unshift(i);}var qe=0,fe=null;function Fe(i){throw m.onAbort?.(i),i="Aborted("+i+")",Se(i),ae=true,i=new WebAssembly.RuntimeError(i+". Build with -sASSERTIONS for more info."),C(i),i}var ye=i=>i.startsWith("data:application/octet-stream;base64,"),pe=i=>i.startsWith("file://"),Ue;function We(i){if(i==Ue&&ue)return new Uint8Array(ue);if(te)return te(i);throw "both async and sync fetching of the wasm failed"}function Ve(i){return ue?Promise.resolve().then(()=>We(i)):new Promise((a,c)=>{de(i,d=>a(new Uint8Array(d)),()=>{try{a(We(i));}catch(d){c(d);}});})}function rt(i,a,c){return Ve(i).then(d=>WebAssembly.instantiate(d,a)).then(c,d=>{Se(`failed to asynchronously prepare wasm: ${d}`),Fe(d);})}function st(i,a){var c=Ue;return ue||typeof WebAssembly.instantiateStreaming!="function"||ye(c)||pe(c)||typeof fetch!="function"?rt(c,i,a):fetch(c,{credentials:"same-origin"}).then(d=>WebAssembly.instantiateStreaming(d,i).then(a,function(v){return Se(`wasm streaming compile failed: ${v}`),Se("falling back to ArrayBuffer instantiation"),rt(c,i,a)}))}var et,tt,He={570520:(i,a,c,d,v)=>{if(typeof window>"u"||(window.AudioContext||window.webkitAudioContext)===void 0)return 0;if(typeof window.h>"u"){window.h={Fa:0},window.h.I={},window.h.I.Ca=i,window.h.I.capture=a,window.h.I.Pa=c,window.h.ha={},window.h.ha.stopped=d,window.h.ha.ub=v;let _=window.h;_.C=[],_.mc=function(M){for(var k=0;k<_.C.length;++k)if(_.C[k]==null)return _.C[k]=M,k;return _.C.push(M),_.C.length-1},_.yb=function(M){for(_.C[M]=null;0<_.C.length&&_.C[_.C.length-1]==null;)_.C.pop();},_.Tc=function(M){for(var k=0;k<_.C.length;++k)if(_.C[k]==M)return _.yb(k)},_.ta=function(M){return _.C[M]},_.Xa=["touchend","click"],_.unlock=function(){for(var M=0;M<_.C.length;++M){var k=_.C[M];k!=null&&k.K!=null&&k.state===_.ha.ub&&k.K.resume().then(()=>{nu(k.nb);},D=>{console.error("Failed to resume audiocontext",D);});}_.Xa.map(function(D){document.removeEventListener(D,_.unlock,true);});},_.Xa.map(function(M){document.addEventListener(M,_.unlock,true);});}return window.h.Fa+=1,1},572698:()=>{typeof window.h<"u"&&(window.h.Xa.map(function(i){document.removeEventListener(i,window.h.unlock,true);}),--window.h.Fa,window.h.Fa===0&&delete window.h);},573002:()=>navigator.mediaDevices!==void 0&&navigator.mediaDevices.getUserMedia!==void 0,573106:()=>{try{var i=new(window.AudioContext||window.webkitAudioContext),a=i.sampleRate;return i.close(),a}catch{return 0}},573277:(i,a,c,d,v,_)=>{if(typeof window.h>"u")return -1;var M={},k={};return i==window.h.I.Ca&&c!=0&&(k.sampleRate=c),M.K=new(window.AudioContext||window.webkitAudioContext)(k),M.K.suspend(),M.state=window.h.ha.stopped,c=0,i!=window.h.I.Ca&&(c=a),M.Y=M.K.createScriptProcessor(d,c,a),M.Y.onaudioprocess=function(D){if((M.ua==null||M.ua.length==0)&&(M.ua=new Float32Array(se.buffer,v,d*a)),i==window.h.I.capture||i==window.h.I.Pa){for(var O=0;O<a;O+=1)for(var X=D.inputBuffer.getChannelData(O),be=M.ua,Ee=0;Ee<d;Ee+=1)be[Ee*a+O]=X[Ee];ru(_,d,v);}if(i==window.h.I.Ca||i==window.h.I.Pa)for(iu(_,d,v),O=0;O<D.outputBuffer.numberOfChannels;++O)for(X=D.outputBuffer.getChannelData(O),be=M.ua,Ee=0;Ee<d;Ee+=1)X[Ee]=be[Ee*a+O];else for(O=0;O<D.outputBuffer.numberOfChannels;++O)D.outputBuffer.getChannelData(O).fill(0);},i!=window.h.I.capture&&i!=window.h.I.Pa||navigator.mediaDevices.getUserMedia({audio:true,video:false}).then(function(D){M.Ga=M.K.createMediaStreamSource(D),M.Ga.connect(M.Y),M.Y.connect(M.K.destination);}).catch(function(D){console.log("Failed to get user media: "+D);}),i==window.h.I.Ca&&M.Y.connect(M.K.destination),M.nb=_,window.h.mc(M)},576154:i=>window.h.ta(i).K.sampleRate,576227:i=>{i=window.h.ta(i),i.Y!==void 0&&(i.Y.onaudioprocess=function(){},i.Y.disconnect(),i.Y=void 0),i.Ga!==void 0&&(i.Ga.disconnect(),i.Ga=void 0),i.K.close(),i.K=void 0,i.nb=void 0;},576627:i=>{window.h.yb(i);},576677:i=>{i=window.h.ta(i),i.K.resume(),i.state=window.h.ha.ub;},576816:i=>{i=window.h.ta(i),i.K.suspend(),i.state=window.h.ha.stopped;}},le=i=>{for(;0<i.length;)i.shift()(m);};function g(){var i=U[+or>>2];return or+=4,i}var l=(i,a)=>{for(var c=0,d=i.length-1;0<=d;d--){var v=i[d];v==="."?i.splice(d,1):v===".."?(i.splice(d,1),c++):c&&(i.splice(d,1),c--);}if(a)for(;c;c--)i.unshift("..");return i},f=i=>{var a=i.charAt(0)==="/",c=i.substr(-1)==="/";return (i=l(i.split("/").filter(d=>!!d),!a).join("/"))||a||(i="."),i&&c&&(i+="/"),(a?"/":"")+i},w=i=>{var a=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(i).slice(1);return i=a[0],a=a[1],!i&&!a?".":(a&&(a=a.substr(0,a.length-1)),i+a)},T=i=>{if(i==="/")return "/";i=f(i),i=i.replace(/\/$/,"");var a=i.lastIndexOf("/");return a===-1?i:i.substr(a+1)},R=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return i=>crypto.getRandomValues(i);Fe("initRandomDevice");},V=i=>(V=R())(i),re=(...i)=>{for(var a="",c=false,d=i.length-1;-1<=d&&!c;d--){if(c=0<=d?i[d]:"/",typeof c!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!c)return "";a=c+"/"+a,c=c.charAt(0)==="/";}return a=l(a.split("/").filter(v=>!!v),!c).join("/"),(c?"/":"")+a||"."},ke=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,ie=(i,a,c)=>{var d=a+c;for(c=a;i[c]&&!(c>=d);)++c;if(16<c-a&&i.buffer&&ke)return ke.decode(i.subarray(a,c));for(d="";a<c;){var v=i[a++];if(v&128){var _=i[a++]&63;if((v&224)==192)d+=String.fromCharCode((v&31)<<6|_);else {var M=i[a++]&63;v=(v&240)==224?(v&15)<<12|_<<6|M:(v&7)<<18|_<<12|M<<6|i[a++]&63,65536>v?d+=String.fromCharCode(v):(v-=65536,d+=String.fromCharCode(55296|v>>10,56320|v&1023));}}else d+=String.fromCharCode(v);}return d},_e=[],nt=i=>{for(var a=0,c=0;c<i.length;++c){var d=i.charCodeAt(c);127>=d?a++:2047>=d?a+=2:55296<=d&&57343>=d?(a+=4,++c):a+=3;}return a},Qe=(i,a,c,d)=>{if(!(0<d))return 0;var v=c;d=c+d-1;for(var _=0;_<i.length;++_){var M=i.charCodeAt(_);if(55296<=M&&57343>=M){var k=i.charCodeAt(++_);M=65536+((M&1023)<<10)|k&1023;}if(127>=M){if(c>=d)break;a[c++]=M;}else {if(2047>=M){if(c+1>=d)break;a[c++]=192|M>>6;}else {if(65535>=M){if(c+2>=d)break;a[c++]=224|M>>12;}else {if(c+3>=d)break;a[c++]=240|M>>18,a[c++]=128|M>>12&63;}a[c++]=128|M>>6&63;}a[c++]=128|M&63;}}return a[c]=0,c-v};function Ge(i,a){var c=Array(nt(i)+1);return i=Qe(i,c,0,c.length),a&&(c.length=i),c}var gt=[];function Tt(i,a){gt[i]={input:[],H:[],V:a},Ke(i,Ye);}var Ye={open(i){var a=gt[i.node.Ea];if(!a)throw new me(43);i.s=a,i.seekable=false;},close(i){i.s.V.sa(i.s);},sa(i){i.s.V.sa(i.s);},read(i,a,c,d){if(!i.s||!i.s.V.hb)throw new me(60);for(var v=0,_=0;_<d;_++){try{var M=i.s.V.hb(i.s);}catch{throw new me(29)}if(M===void 0&&v===0)throw new me(6);if(M==null)break;v++,a[c+_]=M;}return v&&(i.node.timestamp=Date.now()),v},write(i,a,c,d){if(!i.s||!i.s.V.Sa)throw new me(60);try{for(var v=0;v<d;v++)i.s.V.Sa(i.s,a[c+v]);}catch{throw new me(29)}return d&&(i.node.timestamp=Date.now()),v}},kt={hb(){e:{if(!_e.length){var i=null;if(typeof window<"u"&&typeof window.prompt=="function"&&(i=window.prompt("Input: "),i!==null&&(i+=`
|
|
11
|
+
`)),!i){i=null;break e}_e=Ge(i,true);}i=_e.shift();}return i},Sa(i,a){a===null||a===10?(xe(ie(i.H,0)),i.H=[]):a!=0&&i.H.push(a);},sa(i){i.H&&0<i.H.length&&(xe(ie(i.H,0)),i.H=[]);},Wb(){return {xc:25856,zc:5,wc:191,yc:35387,vc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},Xb(){return 0},Yb(){return [24,80]}},vt={Sa(i,a){a===null||a===10?(Se(ie(i.H,0)),i.H=[]):a!=0&&i.H.push(a);},sa(i){i.H&&0<i.H.length&&(Se(ie(i.H,0)),i.H=[]);}};function At(i,a){var c=i.l?i.l.length:0;c>=a||(a=Math.max(a,c*(1048576>c?2:1.125)>>>0),c!=0&&(a=Math.max(a,256)),c=i.l,i.l=new Uint8Array(a),0<i.v&&i.l.set(c.subarray(0,i.v),0));}var Me={N:null,U(){return Me.createNode(null,"/",16895,0)},createNode(i,a,c,d){if((c&61440)===24576||(c&61440)===4096)throw new me(63);return Me.N||(Me.N={dir:{node:{X:Me.j.X,P:Me.j.P,ka:Me.j.ka,Aa:Me.j.Aa,sb:Me.j.sb,xb:Me.j.xb,tb:Me.j.tb,rb:Me.j.rb,Ha:Me.j.Ha},stream:{aa:Me.m.aa}},file:{node:{X:Me.j.X,P:Me.j.P},stream:{aa:Me.m.aa,read:Me.m.read,write:Me.m.write,$a:Me.m.$a,jb:Me.m.jb,lb:Me.m.lb}},link:{node:{X:Me.j.X,P:Me.j.P,la:Me.j.la},stream:{}},ab:{node:{X:Me.j.X,P:Me.j.P},stream:$e}}),c=Bn(i,a,c,d),(c.mode&61440)===16384?(c.j=Me.N.dir.node,c.m=Me.N.dir.stream,c.l={}):(c.mode&61440)===32768?(c.j=Me.N.file.node,c.m=Me.N.file.stream,c.v=0,c.l=null):(c.mode&61440)===40960?(c.j=Me.N.link.node,c.m=Me.N.link.stream):(c.mode&61440)===8192&&(c.j=Me.N.ab.node,c.m=Me.N.ab.stream),c.timestamp=Date.now(),i&&(i.l[a]=c,i.timestamp=c.timestamp),c},Fc(i){return i.l?i.l.subarray?i.l.subarray(0,i.v):new Uint8Array(i.l):new Uint8Array(0)},j:{X(i){var a={};return a.Cc=(i.mode&61440)===8192?i.id:1,a.Hc=i.id,a.mode=i.mode,a.Nc=1,a.uid=0,a.Gc=0,a.Ea=i.Ea,(i.mode&61440)===16384?a.size=4096:(i.mode&61440)===32768?a.size=i.v:(i.mode&61440)===40960?a.size=i.link.length:a.size=0,a.tc=new Date(i.timestamp),a.Mc=new Date(i.timestamp),a.Ac=new Date(i.timestamp),a.Gb=4096,a.uc=Math.ceil(a.size/a.Gb),a},P(i,a){if(a.mode!==void 0&&(i.mode=a.mode),a.timestamp!==void 0&&(i.timestamp=a.timestamp),a.size!==void 0&&(a=a.size,i.v!=a))if(a==0)i.l=null,i.v=0;else {var c=i.l;i.l=new Uint8Array(a),c&&i.l.set(c.subarray(0,Math.min(a,i.v))),i.v=a;}},ka(){throw zt[44]},Aa(i,a,c,d){return Me.createNode(i,a,c,d)},sb(i,a,c){if((i.mode&61440)===16384){try{var d=yn(a,c);}catch{}if(d)for(var v in d.l)throw new me(55)}delete i.parent.l[i.name],i.parent.timestamp=Date.now(),i.name=c,a.l[c]=i,a.timestamp=i.parent.timestamp;},xb(i,a){delete i.l[a],i.timestamp=Date.now();},tb(i,a){var c=yn(i,a),d;for(d in c.l)throw new me(55);delete i.l[a],i.timestamp=Date.now();},rb(i){var a=[".",".."],c;for(c of Object.keys(i.l))a.push(c);return a},Ha(i,a,c){return i=Me.createNode(i,a,41471,0),i.link=c,i},la(i){if((i.mode&61440)!==40960)throw new me(28);return i.link}},m:{read(i,a,c,d,v){var _=i.node.l;if(v>=i.node.v)return 0;if(i=Math.min(i.node.v-v,d),8<i&&_.subarray)a.set(_.subarray(v,v+i),c);else for(d=0;d<i;d++)a[c+d]=_[v+d];return i},write(i,a,c,d,v,_){if(a.buffer===G.buffer&&(_=false),!d)return 0;if(i=i.node,i.timestamp=Date.now(),a.subarray&&(!i.l||i.l.subarray)){if(_)return i.l=a.subarray(c,c+d),i.v=d;if(i.v===0&&v===0)return i.l=a.slice(c,c+d),i.v=d;if(v+d<=i.v)return i.l.set(a.subarray(c,c+d),v),d}if(At(i,v+d),i.l.subarray&&a.subarray)i.l.set(a.subarray(c,c+d),v);else for(_=0;_<d;_++)i.l[v+_]=a[c+_];return i.v=Math.max(i.v,v+d),d},aa(i,a,c){if(c===1?a+=i.position:c===2&&(i.node.mode&61440)===32768&&(a+=i.node.v),0>a)throw new me(28);return a},$a(i,a,c){At(i.node,a+c),i.node.v=Math.max(i.node.v,a+c);},jb(i,a,c,d,v){if((i.node.mode&61440)!==32768)throw new me(43);if(i=i.node.l,v&2||i.buffer!==G.buffer){if((0<c||c+a<i.length)&&(i.subarray?i=i.subarray(c,c+a):i=Array.prototype.slice.call(i,c,c+a)),c=true,Fe(),a=void 0,!a)throw new me(48);G.set(i,a);}else c=false,a=i.byteOffset;return {o:a,sc:c}},lb(i,a,c,d){return Me.m.write(i,a,0,d,c,false),0}}},dn=(i,a)=>{var c=0;return i&&(c|=365),a&&(c|=146),c},Gt=null,x={},Zt=[],Dn=1,jt=null,fn=true,me=class{constructor(i){this.name="ErrnoError",this.$=i;}},zt={},Fn=class{constructor(){this.h={},this.node=null;}get flags(){return this.h.flags}set flags(i){this.h.flags=i;}get position(){return this.h.position}set position(i){this.h.position=i;}},rr=class{constructor(i,a,c,d){i||(i=this),this.parent=i,this.U=i.U,this.Ba=null,this.id=Dn++,this.name=a,this.mode=c,this.j={},this.m={},this.Ea=d;}get read(){return (this.mode&365)===365}set read(i){i?this.mode|=365:this.mode&=-366;}get write(){return (this.mode&146)===146}set write(i){i?this.mode|=146:this.mode&=-147;}};function Kt(i,a={}){if(i=re(i),!i)return {path:"",node:null};if(a=Object.assign({gb:true,Ua:0},a),8<a.Ua)throw new me(32);i=i.split("/").filter(M=>!!M);for(var c=Gt,d="/",v=0;v<i.length;v++){var _=v===i.length-1;if(_&&a.parent)break;if(c=yn(c,i[v]),d=f(d+"/"+i[v]),c.Ba&&(!_||_&&a.gb)&&(c=c.Ba.root),!_||a.fb){for(_=0;(c.mode&61440)===40960;)if(c=ds(d),d=re(w(d),c),c=Kt(d,{Ua:a.Ua+1}).node,40<_++)throw new me(32)}}return {path:d,node:c}}function bn(i){for(var a;;){if(i===i.parent)return i=i.U.kb,a?i[i.length-1]!=="/"?`${i}/${a}`:i+a:i;a=a?`${i.name}/${a}`:i.name,i=i.parent;}}function Er(i,a){for(var c=0,d=0;d<a.length;d++)c=(c<<5)-c+a.charCodeAt(d)|0;return (i+c>>>0)%jt.length}function yn(i,a){var c=(i.mode&61440)===16384?(c=Ae(i,"x"))?c:i.j.ka?0:2:54;if(c)throw new me(c);for(c=jt[Er(i.id,a)];c;c=c.ac){var d=c.name;if(c.parent.id===i.id&&d===a)return c}return i.j.ka(i,a)}function Bn(i,a,c,d){return i=new rr(i,a,c,d),a=Er(i.parent.id,i.name),i.ac=jt[a],jt[a]=i}function Y(i){var a=["r","w","rw"][i&3];return i&512&&(a+="w"),a}function Ae(i,a){if(fn)return 0;if(!a.includes("r")||i.mode&292){if(a.includes("w")&&!(i.mode&146)||a.includes("x")&&!(i.mode&73))return 2}else return 2;return 0}function Te(i,a){try{return yn(i,a),20}catch{}return Ae(i,"wx")}function Be(i){if(i=Zt[i],!i)throw new me(8);return i}function Je(i,a=-1){if(i=Object.assign(new Fn,i),a==-1)e:{for(a=0;4096>=a;a++)if(!Zt[a])break e;throw new me(33)}return i.W=a,Zt[a]=i}function St(i,a=-1){return i=Je(i,a),i.m?.Ec?.(i),i}var $e={open(i){i.m=x[i.node.Ea].m,i.m.open?.(i);},aa(){throw new me(70)}};function Ke(i,a){x[i]={m:a};}function lt(i,a){var c=a==="/";if(c&&Gt)throw new me(10);if(!c&&a){var d=Kt(a,{gb:false});if(a=d.path,d=d.node,d.Ba)throw new me(10);if((d.mode&61440)!==16384)throw new me(54)}a={type:i,Pc:{},kb:a,Zb:[]},i=i.U(a),i.U=a,a.root=i,c?Gt=i:d&&(d.Ba=a,d.U&&d.U.Zb.push(a));}function ct(i,a,c){var d=Kt(i,{parent:true}).node;if(i=T(i),!i||i==="."||i==="..")throw new me(28);var v=Te(d,i);if(v)throw new me(v);if(!d.j.Aa)throw new me(63);return d.j.Aa(d,i,a,c)}function it(i){return ct(i,16895,0)}function Pt(i,a,c){typeof c>"u"&&(c=a,a=438),ct(i,a|8192,c);}function _n(i,a){if(!re(i))throw new me(44);var c=Kt(a,{parent:true}).node;if(!c)throw new me(44);a=T(a);var d=Te(c,a);if(d)throw new me(d);if(!c.j.Ha)throw new me(63);c.j.Ha(c,a,i);}function ds(i){if(i=Kt(i).node,!i)throw new me(44);if(!i.j.la)throw new me(28);return re(bn(i.parent),i.j.la(i))}function Mr(i,a,c){if(i==="")throw new me(44);if(typeof a=="string"){var d={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090}[a];if(typeof d>"u")throw Error(`Unknown file open mode: ${a}`);a=d;}if(c=a&64?(typeof c>"u"?438:c)&4095|32768:0,typeof i=="object")var v=i;else {i=f(i);try{v=Kt(i,{fb:!(a&131072)}).node;}catch{}}if(d=false,a&64)if(v){if(a&128)throw new me(20)}else v=ct(i,c,0),d=true;if(!v)throw new me(44);if((v.mode&61440)===8192&&(a&=-513),a&65536&&(v.mode&61440)!==16384)throw new me(54);if(!d&&(c=v?(v.mode&61440)===40960?32:(v.mode&61440)===16384&&(Y(a)!=="r"||a&512)?31:Ae(v,Y(a)):44))throw new me(c);if(a&512&&!d){if(c=v,c=typeof c=="string"?Kt(c,{fb:true}).node:c,!c.j.P)throw new me(63);if((c.mode&61440)===16384)throw new me(31);if((c.mode&61440)!==32768)throw new me(28);if(d=Ae(c,"w"))throw new me(d);c.j.P(c,{size:0,timestamp:Date.now()});}return a&=-131713,v=Je({node:v,path:bn(v),flags:a,seekable:true,position:0,m:v.m,nc:[],error:false}),v.m.open&&v.m.open(v),!m.logReadFiles||a&1||(oi||(oi={}),i in oi||(oi[i]=1)),v}function po(i,a,c){if(i.W===null)throw new me(8);if(!i.seekable||!i.m.aa)throw new me(70);if(c!=0&&c!=1&&c!=2)throw new me(28);i.position=i.m.aa(i,a,c),i.nc=[];}var ho;function ir(i,a,c){i=f("/dev/"+i);var d=dn(!!a,!!c);mo||(mo=64);var v=mo++<<8|0;Ke(v,{open(_){_.seekable=false;},close(){c?.buffer?.length&&c(10);},read(_,M,k,D){for(var O=0,X=0;X<D;X++){try{var be=a();}catch{throw new me(29)}if(be===void 0&&O===0)throw new me(6);if(be==null)break;O++,M[k+X]=be;}return O&&(_.node.timestamp=Date.now()),O},write(_,M,k,D){for(var O=0;O<D;O++)try{c(M[k+O]);}catch{throw new me(29)}return D&&(_.node.timestamp=Date.now()),O}}),Pt(i,d,v);}var mo,wn={},oi,or=void 0,Un=(i,a)=>Object.defineProperty(a,"name",{value:i}),ai=[],en=[],Le,Yt=i=>{if(!i)throw new Le("Cannot use deleted val. handle = "+i);return en[i]},tn=i=>{switch(i){case void 0:return 2;case null:return 4;case true:return 6;case false:return 8;default:let a=ai.pop()||en.length;return en[a]=i,en[a+1]=1,a}},go=i=>{var a=Error,c=Un(i,function(d){this.name=i,this.message=d,d=Error(d).stack,d!==void 0&&(this.stack=this.toString()+`
|
|
12
|
+
`+d.replace(/^Error(:[^\n]*)?\n/,""));});return c.prototype=Object.create(a.prototype),c.prototype.constructor=c,c.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},c},vo,Ao,wt=i=>{for(var a="";z[i];)a+=Ao[z[i++]];return a},ar=[],Tr=()=>{for(;ar.length;){var i=ar.pop();i.g.ga=false,i.delete();}},Vn,qt={},Wn=(i,a)=>{if(a===void 0)throw new Le("ptr should not be undefined");for(;i.B;)a=i.na(a),i=i.B;return a},Sn={},si=i=>{i=tu(i);var a=wt(i);return kn(i),a},Hn=(i,a)=>{var c=Sn[i];if(c===void 0)throw i=`${a} has unknown type ${si(i)}`,new Le(i);return c},sr=()=>{},kr=false,bo=(i,a,c)=>a===c?i:c.B===void 0?null:(i=bo(i,a,c.B),i===null?null:c.Jb(i)),yo={},fs=(i,a)=>(a=Wn(i,a),qt[a]),lr,Cr=(i,a)=>{if(!a.u||!a.o)throw new lr("makeClassHandle requires ptr and ptrType");if(!!a.J!=!!a.D)throw new lr("Both smartPtrType and smartPtr must be specified");return a.count={value:1},Gn(Object.create(i,{g:{value:a,writable:true}}))},Gn=i=>typeof FinalizationRegistry>"u"?(Gn=a=>a,i):(kr=new FinalizationRegistry(a=>{a=a.g,--a.count.value,a.count.value===0&&(a.D?a.J.O(a.D):a.u.i.O(a.o));}),Gn=a=>{var c=a.g;return c.D&&kr.register(a,{g:c},a),a},sr=a=>{kr.unregister(a);},Gn(i)),xr={},cr=i=>{for(;i.length;){var a=i.pop();i.pop()(a);}};function En(i){return this.fromWireType(q[i>>2])}var jn={},Rr={},Dt=(i,a,c)=>{function d(k){if(k=c(k),k.length!==i.length)throw new lr("Mismatched type converter count");for(var D=0;D<i.length;++D)Xt(i[D],k[D]);}i.forEach(function(k){Rr[k]=a;});var v=Array(a.length),_=[],M=0;a.forEach((k,D)=>{Sn.hasOwnProperty(k)?v[D]=Sn[k]:(_.push(k),jn.hasOwnProperty(k)||(jn[k]=[]),jn[k].push(()=>{v[D]=Sn[k],++M,M===_.length&&d(v);}));}),_.length===0&&d(v);};function ps(i,a,c={}){var d=a.name;if(!i)throw new Le(`type "${d}" must have a positive integer typeid pointer`);if(Sn.hasOwnProperty(i)){if(c.Tb)return;throw new Le(`Cannot register type '${d}' twice`)}Sn[i]=a,delete Rr[i],jn.hasOwnProperty(i)&&(a=jn[i],delete jn[i],a.forEach(v=>v()));}function Xt(i,a,c={}){if(!("argPackAdvance"in a))throw new TypeError("registerType registeredInstance requires argPackAdvance");return ps(i,a,c)}var Pr=i=>{throw new Le(i.g.u.i.name+" instance already deleted")};function Ir(){}var li=(i,a,c)=>{if(i[a].A===void 0){var d=i[a];i[a]=function(...v){if(!i[a].A.hasOwnProperty(v.length))throw new Le(`Function '${c}' called with an invalid number of arguments (${v.length}) - expects one of (${i[a].A})!`);return i[a].A[v.length].apply(this,v)},i[a].A=[],i[a].A[d.fa]=d;}},ci=(i,a,c)=>{if(m.hasOwnProperty(i)){if(c===void 0||m[i].A!==void 0&&m[i].A[c]!==void 0)throw new Le(`Cannot register public name '${i}' twice`);if(li(m,i,i),m.hasOwnProperty(c))throw new Le(`Cannot register multiple overloads of a function with the same number of arguments (${c})!`);m[i].A[c]=a;}else m[i]=a,c!==void 0&&(m[i].Oc=c);},he=i=>{if(i===void 0)return "_unknown";i=i.replace(/[^a-zA-Z0-9_]/g,"$");var a=i.charCodeAt(0);return 48<=a&&57>=a?`_${i}`:i};function Ze(i,a,c,d,v,_,M,k){this.name=i,this.constructor=a,this.M=c,this.O=d,this.B=v,this.Ob=_,this.na=M,this.Jb=k,this.ob=[];}var bt=(i,a,c)=>{for(;a!==c;){if(!a.na)throw new Le(`Expected null or instance of ${c.name}, got an instance of ${a.name}`);i=a.na(i),a=a.B;}return i};function Mn(i,a){if(a===null){if(this.Ra)throw new Le(`null is not a valid ${this.name}`);return 0}if(!a.g)throw new Le(`Cannot pass "${pi(a)}" as a ${this.name}`);if(!a.g.o)throw new Le(`Cannot pass deleted object as a pointer of type ${this.name}`);return bt(a.g.o,a.g.u.i,this.i)}function hs(i,a){if(a===null){if(this.Ra)throw new Le(`null is not a valid ${this.name}`);if(this.wa){var c=this.Ta();return i!==null&&i.push(this.O,c),c}return 0}if(!a||!a.g)throw new Le(`Cannot pass "${pi(a)}" as a ${this.name}`);if(!a.g.o)throw new Le(`Cannot pass deleted object as a pointer of type ${this.name}`);if(!this.va&&a.g.u.va)throw new Le(`Cannot convert argument of type ${a.g.J?a.g.J.name:a.g.u.name} to parameter type ${this.name}`);if(c=bt(a.g.o,a.g.u.i,this.i),this.wa){if(a.g.D===void 0)throw new Le("Passing raw pointer to smart pointer is illegal");switch(this.hc){case 0:if(a.g.J===this)c=a.g.D;else throw new Le(`Cannot convert argument of type ${a.g.J?a.g.J.name:a.g.u.name} to parameter type ${this.name}`);break;case 1:c=a.g.D;break;case 2:if(a.g.J===this)c=a.g.D;else {var d=a.clone();c=this.cc(c,tn(()=>d.delete())),i!==null&&i.push(this.O,c);}break;default:throw new Le("Unsupporting sharing policy")}}return c}function ms(i,a){if(a===null){if(this.Ra)throw new Le(`null is not a valid ${this.name}`);return 0}if(!a.g)throw new Le(`Cannot pass "${pi(a)}" as a ${this.name}`);if(!a.g.o)throw new Le(`Cannot pass deleted object as a pointer of type ${this.name}`);if(a.g.u.va)throw new Le(`Cannot convert argument of type ${a.g.u.name} to parameter type ${this.name}`);return bt(a.g.o,a.g.u.i,this.i)}function Lr(i,a,c,d,v,_,M,k,D,O,X){this.name=i,this.i=a,this.Ra=c,this.va=d,this.wa=v,this.bc=_,this.hc=M,this.qb=k,this.Ta=D,this.cc=O,this.O=X,v||a.B!==void 0?this.toWireType=hs:(this.toWireType=d?Mn:ms,this.L=null);}var _o=(i,a,c)=>{if(!m.hasOwnProperty(i))throw new lr("Replacing nonexistent public symbol");m[i].A!==void 0&&c!==void 0?m[i].A[c]=a:(m[i]=a,m[i].fa=c);},Or=[],wo,ur=i=>{var a=Or[i];return a||(i>=Or.length&&(Or.length=i+1),Or[i]=a=wo.get(i)),a},gs=(i,a,c=[])=>(i.includes("j")?(i=i.replace(/p/g,"i"),a=(0, m["dynCall_"+i])(a,...c)):a=ur(a)(...c),a),vs=(i,a)=>(...c)=>gs(i,a,c),It=(i,a)=>{i=wt(i);var c=i.includes("j")?vs(i,a):ur(a);if(typeof c!="function")throw new Le(`unknown function pointer with signature ${i}: ${a}`);return c},So,nn=(i,a)=>{function c(_){v[_]||Sn[_]||(Rr[_]?Rr[_].forEach(c):(d.push(_),v[_]=true));}var d=[],v={};throw a.forEach(c),new So(`${i}: `+d.map(si).join([", "]))};function As(i){for(var a=1;a<i.length;++a)if(i[a]!==null&&i[a].L===void 0)return true;return false}function Nr(i,a,c,d,v){var _=a.length;if(2>_)throw new Le("argTypes array size mismatch! Must at least get return value and 'this' types!");var M=a[1]!==null&&c!==null,k=As(a),D=a[0].name!=="void",O=_-2,X=Array(O),be=[],Ee=[];return Un(i,function(...F){if(F.length!==O)throw new Le(`function ${i} called with ${F.length} arguments, expected ${O}`);if(Ee.length=0,be.length=M?2:1,be[0]=v,M){var K=a[1].toWireType(Ee,this);be[1]=K;}for(var ne=0;ne<O;++ne)X[ne]=a[ne+2].toWireType(Ee,F[ne]),be.push(X[ne]);if(F=d(...be),k)cr(Ee);else for(ne=M?1:2;ne<a.length;ne++){var Ce=ne===1?K:X[ne-2];a[ne].L!==null&&a[ne].L(Ce);}return K=D?a[0].fromWireType(F):void 0,K})}var dr=(i,a)=>{for(var c=[],d=0;d<i;d++)c.push(q[a+4*d>>2]);return c},ui=i=>{i=i.trim();let a=i.indexOf("(");return a!==-1?i.substr(0,a):i},di=(i,a,c)=>{if(!(i instanceof Object))throw new Le(`${c} with invalid "this": ${i}`);if(!(i instanceof a.i.constructor))throw new Le(`${c} incompatible with "this" of type ${i.constructor.name}`);if(!i.g.o)throw new Le(`cannot call emscripten binding method ${c} on deleted object`);return bt(i.g.o,i.g.u.i,a.i)},fi=i=>{9<i&&--en[i+1]===0&&(en[i]=void 0,ai.push(i));},bs={name:"emscripten::val",fromWireType:i=>{var a=Yt(i);return fi(i),a},toWireType:(i,a)=>tn(a),argPackAdvance:8,readValueFromPointer:En,L:null},ys=(i,a,c)=>{switch(a){case 1:return c?function(d){return this.fromWireType(G[d])}:function(d){return this.fromWireType(z[d])};case 2:return c?function(d){return this.fromWireType(P[d>>1])}:function(d){return this.fromWireType(N[d>>1])};case 4:return c?function(d){return this.fromWireType(U[d>>2])}:function(d){return this.fromWireType(q[d>>2])};default:throw new TypeError(`invalid integer width (${a}): ${i}`)}},pi=i=>{if(i===null)return "null";var a=typeof i;return a==="object"||a==="array"||a==="function"?i.toString():""+i},_s=(i,a)=>{switch(a){case 4:return function(c){return this.fromWireType(se[c>>2])};case 8:return function(c){return this.fromWireType(Re[c>>3])};default:throw new TypeError(`invalid float width (${a}): ${i}`)}},ws=(i,a,c)=>{switch(a){case 1:return c?d=>G[d]:d=>z[d];case 2:return c?d=>P[d>>1]:d=>N[d>>1];case 4:return c?d=>U[d>>2]:d=>q[d>>2];default:throw new TypeError(`invalid integer width (${a}): ${i}`)}},Eo=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,Ss=(i,a)=>{for(var c=i>>1,d=c+a/2;!(c>=d)&&N[c];)++c;if(c<<=1,32<c-i&&Eo)return Eo.decode(z.subarray(i,c));for(c="",d=0;!(d>=a/2);++d){var v=P[i+2*d>>1];if(v==0)break;c+=String.fromCharCode(v);}return c},Es=(i,a,c)=>{if(c??(c=2147483647),2>c)return 0;c-=2;var d=a;c=c<2*i.length?c/2:i.length;for(var v=0;v<c;++v)P[a>>1]=i.charCodeAt(v),a+=2;return P[a>>1]=0,a-d},Ms=i=>2*i.length,Ts=(i,a)=>{for(var c=0,d="";!(c>=a/4);){var v=U[i+4*c>>2];if(v==0)break;++c,65536<=v?(v-=65536,d+=String.fromCharCode(55296|v>>10,56320|v&1023)):d+=String.fromCharCode(v);}return d},ks=(i,a,c)=>{if(c??(c=2147483647),4>c)return 0;var d=a;c=d+c-4;for(var v=0;v<i.length;++v){var _=i.charCodeAt(v);if(55296<=_&&57343>=_){var M=i.charCodeAt(++v);_=65536+((_&1023)<<10)|M&1023;}if(U[a>>2]=_,a+=4,a+4>c)break}return U[a>>2]=0,a-d},Cs=i=>{for(var a=0,c=0;c<i.length;++c){var d=i.charCodeAt(c);55296<=d&&57343>=d&&++c,a+=4;}return a},Mo=(i,a,c)=>{var d=[];return i=i.toWireType(d,c),d.length&&(q[a>>2]=tn(d)),i},Dr=[],To={},ko=i=>{var a=To[i];return a===void 0?wt(i):a},xs=i=>{var a=Dr.length;return Dr.push(i),a},ge=(i,a)=>{for(var c=Array(i),d=0;d<i;++d)c[d]=Hn(q[a+4*d>>2],"parameter "+d);return c},je=Reflect.construct,Lt=i=>i%4===0&&(i%100!==0||i%400===0),Fr=[0,31,60,91,121,152,182,213,244,274,305,335],Co=[0,31,59,90,120,151,181,212,243,273,304,334],Rs=[],Wc=i=>{i.Dc=i.getExtension("WEBGL_draw_instanced_base_vertex_base_instance");},Hc=i=>{i.Lc=i.getExtension("WEBGL_multi_draw_instanced_base_vertex_base_instance");},Gc=i=>{var a="EXT_color_buffer_float EXT_conservative_depth EXT_disjoint_timer_query_webgl2 EXT_texture_norm16 NV_shader_noperspective_interpolation WEBGL_clip_cull_distance EXT_color_buffer_half_float EXT_depth_clamp EXT_float_blend EXT_texture_compression_bptc EXT_texture_compression_rgtc EXT_texture_filter_anisotropic KHR_parallel_shader_compile OES_texture_float_linear WEBGL_blend_func_extended WEBGL_compressed_texture_astc WEBGL_compressed_texture_etc WEBGL_compressed_texture_etc1 WEBGL_compressed_texture_s3tc WEBGL_compressed_texture_s3tc_srgb WEBGL_debug_renderer_info WEBGL_debug_shaders WEBGL_lose_context WEBGL_multi_draw".split(" ");return (i.getSupportedExtensions()||[]).filter(c=>a.includes(c))},jc=1,hi=[],rn=[],xo=[],mi=[],Br=[],fr=[],Ro=[],Ot=[],zc={},Ps=4,Yc=0,Po=i=>{for(var a=jc++,c=i.length;c<a;c++)i[c]=null;return a},gi=(i,a,c,d)=>{for(var v=0;v<i;v++){var _=j[c](),M=_&&Po(d);_?(_.name=M,d[M]=_):Ft||(Ft=1282),U[a+4*v>>2]=M;}},mm=(i,a)=>{var c=Po(Ot),d={handle:c,attributes:a,version:a.Kc,F:i};return i.canvas&&(i.canvas.zb=d),Ot[c]=d,(typeof a.Kb>"u"||a.Kb)&&gm(d),c},Is=i=>(Tn=Ot[i],m.Bc=j=Tn?.F,!(i&&!j)),gm=i=>{if(i||(i=Tn),!i.Ub){i.Ub=true;var a=i.F;Wc(a),Hc(a),2<=i.version&&(a.cb=a.getExtension("EXT_disjoint_timer_query_webgl2")),(2>i.version||!a.cb)&&(a.cb=a.getExtension("EXT_disjoint_timer_query")),a.$b=a.getExtension("WEBGL_multi_draw"),Gc(a).forEach(c=>{c.includes("lose_context")||c.includes("debug")||a.getExtension(c);});}},Ft,Tn,Ls={},Kc=()=>{if(!Os){var i={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:J||"./this.program"},a;for(a in Ls)Ls[a]===void 0?delete i[a]:i[a]=Ls[a];var c=[];for(a in i)c.push(`${a}=${i[a]}`);Os=c;}return Os},Os,Ns=[];function qc(){var i=Gc(j);return i=i.concat(i.map(a=>"GL_"+a))}var vm=(i,a)=>{if(a){var c=void 0;switch(i){case 36346:c=1;break;case 36344:return;case 34814:case 36345:c=0;break;case 34466:var d=j.getParameter(34467);c=d?d.length:0;break;case 33309:if(2>Tn.version){Ft||(Ft=1282);return}c=qc().length;break;case 33307:case 33308:if(2>Tn.version){Ft||(Ft=1280);return}c=i==33307?3:0;}if(c===void 0)switch(d=j.getParameter(i),typeof d){case "number":c=d;break;case "boolean":c=d?1:0;break;case "string":Ft||(Ft=1280);return;case "object":if(d===null)switch(i){case 34964:case 35725:case 34965:case 36006:case 36007:case 32873:case 34229:case 36662:case 36663:case 35053:case 35055:case 36010:case 35097:case 35869:case 32874:case 36389:case 35983:case 35368:case 34068:c=0;break;default:Ft||(Ft=1280);return}else {if(d instanceof Float32Array||d instanceof Uint32Array||d instanceof Int32Array||d instanceof Array){for(i=0;i<d.length;++i)U[a+4*i>>2]=d[i];return}try{c=d.name|0;}catch(v){Ft||(Ft=1280),Se(`GL_INVALID_ENUM in glGet0v: Unknown object returned from WebGL getParameter(${i})! (error: ${v})`);return}}break;default:Ft||(Ft=1280),Se(`GL_INVALID_ENUM in glGet0v: Native code calling glGet0v(${i}) and it returns ${d} of type ${typeof d}!`);return}U[a>>2]=c;}else Ft||(Ft=1281);},Io=i=>{var a=nt(i)+1,c=Oo(a);return c&&Qe(i,z,c,a),c},Xc=i=>i.slice(-1)=="]"&&i.lastIndexOf("["),Ds=i=>(i-=5120,i==0?G:i==1?z:i==2?P:i==4?U:i==6?se:i==5||i==28922||i==28520||i==30779||i==30782?q:N),Qc=[31,29,31,30,31,30,31,31,30,31,30,31],$c=[31,28,31,30,31,30,31,31,30,31,30,31],Jc=(i,a,c,d)=>{function v(F,K,ne){for(F=typeof F=="number"?F.toString():F||"";F.length<K;)F=ne[0]+F;return F}function _(F,K){return v(F,K,"0")}function M(F,K){function ne(Oe){return 0>Oe?-1:0<Oe?1:0}var Ce;return (Ce=ne(F.getFullYear()-K.getFullYear()))===0&&(Ce=ne(F.getMonth()-K.getMonth()))===0&&(Ce=ne(F.getDate()-K.getDate())),Ce}function k(F){switch(F.getDay()){case 0:return new Date(F.getFullYear()-1,11,29);case 1:return F;case 2:return new Date(F.getFullYear(),0,3);case 3:return new Date(F.getFullYear(),0,2);case 4:return new Date(F.getFullYear(),0,1);case 5:return new Date(F.getFullYear()-1,11,31);case 6:return new Date(F.getFullYear()-1,11,30)}}function D(F){var K=F.ba;for(F=new Date(new Date(F.ca+1900,0,1).getTime());0<K;){var ne=F.getMonth(),Ce=(Lt(F.getFullYear())?Qc:$c)[ne];if(K>Ce-F.getDate())K-=Ce-F.getDate()+1,F.setDate(1),11>ne?F.setMonth(ne+1):(F.setMonth(0),F.setFullYear(F.getFullYear()+1));else {F.setDate(F.getDate()+K);break}}return ne=new Date(F.getFullYear()+1,0,4),K=k(new Date(F.getFullYear(),0,4)),ne=k(ne),0>=M(K,F)?0>=M(ne,F)?F.getFullYear()+1:F.getFullYear():F.getFullYear()-1}var O=q[d+40>>2];d={kc:U[d>>2],jc:U[d+4>>2],Ia:U[d+8>>2],Va:U[d+12>>2],Ja:U[d+16>>2],ca:U[d+20>>2],R:U[d+24>>2],ba:U[d+28>>2],Sc:U[d+32>>2],ic:U[d+36>>2],lc:O&&O?ie(z,O):""},c=c?ie(z,c):"",O={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var X in O)c=c.replace(new RegExp(X,"g"),O[X]);var be="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),Ee="January February March April May June July August September October November December".split(" ");O={"%a":F=>be[F.R].substring(0,3),"%A":F=>be[F.R],"%b":F=>Ee[F.Ja].substring(0,3),"%B":F=>Ee[F.Ja],"%C":F=>_((F.ca+1900)/100|0,2),"%d":F=>_(F.Va,2),"%e":F=>v(F.Va,2," "),"%g":F=>D(F).toString().substring(2),"%G":D,"%H":F=>_(F.Ia,2),"%I":F=>(F=F.Ia,F==0?F=12:12<F&&(F-=12),_(F,2)),"%j":F=>{for(var K=0,ne=0;ne<=F.Ja-1;K+=(Lt(F.ca+1900)?Qc:$c)[ne++]);return _(F.Va+K,3)},"%m":F=>_(F.Ja+1,2),"%M":F=>_(F.jc,2),"%n":()=>`
|
|
13
|
+
`,"%p":F=>0<=F.Ia&&12>F.Ia?"AM":"PM","%S":F=>_(F.kc,2),"%t":()=>" ","%u":F=>F.R||7,"%U":F=>_(Math.floor((F.ba+7-F.R)/7),2),"%V":F=>{var K=Math.floor((F.ba+7-(F.R+6)%7)/7);if(2>=(F.R+371-F.ba-2)%7&&K++,K)K==53&&(ne=(F.R+371-F.ba)%7,ne==4||ne==3&&Lt(F.ca)||(K=1));else {K=52;var ne=(F.R+7-F.ba-1)%7;(ne==4||ne==5&&Lt(F.ca%400-1))&&K++;}return _(K,2)},"%w":F=>F.R,"%W":F=>_(Math.floor((F.ba+7-(F.R+6)%7)/7),2),"%y":F=>(F.ca+1900).toString().substring(2),"%Y":F=>F.ca+1900,"%z":F=>{F=F.ic;var K=0<=F;return F=Math.abs(F)/60,(K?"+":"-")+("0000"+(F/60*100+F%60)).slice(-4)},"%Z":F=>F.lc,"%%":()=>"%"},c=c.replace(/%%/g,"\0\0");for(X in O)c.includes(X)&&(c=c.replace(new RegExp(X,"g"),O[X](d)));return c=c.replace(/\0\0/g,"%"),X=Ge(c,false),X.length>a?0:(G.set(X,i),X.length-1)};[44].forEach(i=>{zt[i]=new me(i),zt[i].stack="<generic error, no stack>";}),jt=Array(4096),lt(Me,"/"),it("/tmp"),it("/home"),it("/home/web_user"),(function(){it("/dev"),Ke(259,{read:()=>0,write:(d,v,_,M)=>M}),Pt("/dev/null",259),Tt(1280,kt),Tt(1536,vt),Pt("/dev/tty",1280),Pt("/dev/tty1",1536);var i=new Uint8Array(1024),a=0,c=()=>(a===0&&(a=V(i).byteLength),i[--a]);ir("random",c),ir("urandom",c),it("/dev/shm"),it("/dev/shm/tmp");})(),(function(){it("/proc");var i=it("/proc/self");it("/proc/self/fd"),lt({U(){var a=Bn(i,"fd",16895,73);return a.j={ka(c,d){var v=Be(+d);return c={parent:null,U:{kb:"fake"},j:{la:()=>v.path}},c.parent=c}},a}},"/proc/self/fd");})(),Le=m.BindingError=class extends Error{constructor(i){super(i),this.name="BindingError";}},en.push(0,1,void 0,1,null,1,true,1,false,1),m.count_emval_handles=()=>en.length/2-5-ai.length,vo=m.PureVirtualError=go("PureVirtualError");for(var Zc=Array(256),Lo=0;256>Lo;++Lo)Zc[Lo]=String.fromCharCode(Lo);Ao=Zc,m.getInheritedInstanceCount=()=>Object.keys(qt).length,m.getLiveInheritedInstances=()=>{var i=[],a;for(a in qt)qt.hasOwnProperty(a)&&i.push(qt[a]);return i},m.flushPendingDeletes=Tr,m.setDelayFunction=i=>{Vn=i,ar.length&&Vn&&Vn(Tr);},lr=m.InternalError=class extends Error{constructor(i){super(i),this.name="InternalError";}},Object.assign(Ir.prototype,{isAliasOf:function(i){if(!(this instanceof Ir&&i instanceof Ir))return false;var a=this.g.u.i,c=this.g.o;i.g=i.g;var d=i.g.u.i;for(i=i.g.o;a.B;)c=a.na(c),a=a.B;for(;d.B;)i=d.na(i),d=d.B;return a===d&&c===i},clone:function(){if(this.g.o||Pr(this),this.g.ia)return this.g.count.value+=1,this;var i=Gn,a=Object,c=a.create,d=Object.getPrototypeOf(this),v=this.g;return i=i(c.call(a,d,{g:{value:{count:v.count,ga:v.ga,ia:v.ia,o:v.o,u:v.u,D:v.D,J:v.J}}})),i.g.count.value+=1,i.g.ga=false,i},delete(){if(this.g.o||Pr(this),this.g.ga&&!this.g.ia)throw new Le("Object already scheduled for deletion");sr(this);var i=this.g;--i.count.value,i.count.value===0&&(i.D?i.J.O(i.D):i.u.i.O(i.o)),this.g.ia||(this.g.D=void 0,this.g.o=void 0);},isDeleted:function(){return !this.g.o},deleteLater:function(){if(this.g.o||Pr(this),this.g.ga&&!this.g.ia)throw new Le("Object already scheduled for deletion");return ar.push(this),ar.length===1&&Vn&&Vn(Tr),this.g.ga=true,this}}),Object.assign(Lr.prototype,{Pb(i){return this.qb&&(i=this.qb(i)),i},bb(i){this.O?.(i);},argPackAdvance:8,readValueFromPointer:En,fromWireType:function(i){function a(){return this.wa?Cr(this.i.M,{u:this.bc,o:c,J:this,D:i}):Cr(this.i.M,{u:this,o:i})}var c=this.Pb(i);if(!c)return this.bb(i),null;var d=fs(this.i,c);if(d!==void 0)return d.g.count.value===0?(d.g.o=c,d.g.D=i,d.clone()):(d=d.clone(),this.bb(i),d);if(d=this.i.Ob(c),d=yo[d],!d)return a.call(this);d=this.va?d.Hb:d.pointerType;var v=bo(c,this.i,d.i);return v===null?a.call(this):this.wa?Cr(d.i.M,{u:d,o:v,J:this,D:i}):Cr(d.i.M,{u:d,o:v})}}),So=m.UnboundTypeError=go("UnboundTypeError");for(var j,Fs=0;32>Fs;++Fs)Ns.push(Array(Fs));var eu={__syscall_fcntl64:function(i,a,c){or=c;try{var d=Be(i);switch(a){case 0:var v=g();if(0>v)break;for(;Zt[v];)v++;return St(d,v).W;case 1:case 2:return 0;case 3:return d.flags;case 4:return v=g(),d.flags|=v,0;case 12:return v=g(),P[v+0>>1]=2,0;case 13:case 14:return 0}return -28}catch(_){if(typeof wn>"u"||_.name!=="ErrnoError")throw _;return -_.$}},__syscall_ioctl:function(i,a,c){or=c;try{var d=Be(i);switch(a){case 21509:return d.s?0:-59;case 21505:if(!d.s)return -59;if(d.s.V.Wb){i=[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];var v=g();U[v>>2]=25856,U[v+4>>2]=5,U[v+8>>2]=191,U[v+12>>2]=35387;for(var _=0;32>_;_++)G[v+_+17]=i[_]||0;}return 0;case 21510:case 21511:case 21512:return d.s?0:-59;case 21506:case 21507:case 21508:if(!d.s)return -59;if(d.s.V.Xb)for(v=g(),i=[],_=0;32>_;_++)i.push(G[v+_+17]);return 0;case 21519:return d.s?(v=g(),U[v>>2]=0):-59;case 21520:return d.s?-28:-59;case 21531:if(v=g(),!d.m.Vb)throw new me(59);return d.m.Vb(d,a,v);case 21523:return d.s?(d.s.V.Yb&&(_=[24,80],v=g(),P[v>>1]=_[0],P[v+2>>1]=_[1]),0):-59;case 21524:return d.s?0:-59;case 21515:return d.s?0:-59;default:return -28}}catch(M){if(typeof wn>"u"||M.name!=="ErrnoError")throw M;return -M.$}},__syscall_openat:function(i,a,c,d){or=d;try{a=a?ie(z,a):"";var v=a;if(v.charAt(0)==="/")a=v;else {var _=i===-100?"/":Be(i).path;if(v.length==0)throw new me(44);a=f(_+"/"+v);}var M=d?g():0;return Mr(a,c,M).W}catch(k){if(typeof wn>"u"||k.name!=="ErrnoError")throw k;return -k.$}},_abort_js:()=>{Fe("");},_embind_create_inheriting_constructor:(i,a,c)=>{i=wt(i),a=Hn(a,"wrapper"),c=Yt(c);var d=a.i,v=d.M,_=d.B.M,M=d.B.constructor;return i=Un(i,function(...k){d.B.ob.forEach(function(D){if(this[D]===_[D])throw new vo(`Pure virtual function ${D} must be implemented in JavaScript`)}.bind(this)),Object.defineProperty(this,"__parent",{value:v}),this.__construct(...k);}),v.__construct=function(...k){if(this===v)throw new Le("Pass correct 'this' to __construct");k=M.implement(this,...k),sr(k);var D=k.g;if(k.notifyOnDestruction(),D.ia=true,Object.defineProperties(this,{g:{value:D}}),Gn(this),k=D.o,k=Wn(d,k),qt.hasOwnProperty(k))throw new Le(`Tried to register registered instance: ${k}`);qt[k]=this;},v.__destruct=function(){if(this===v)throw new Le("Pass correct 'this' to __destruct");sr(this);var k=this.g.o;if(k=Wn(d,k),qt.hasOwnProperty(k))delete qt[k];else throw new Le(`Tried to unregister unregistered instance: ${k}`)},i.prototype=Object.create(v),Object.assign(i.prototype,c),tn(i)},_embind_finalize_value_object:i=>{var a=xr[i];delete xr[i];var c=a.Ta,d=a.O,v=a.eb,_=v.map(M=>M.Sb).concat(v.map(M=>M.ec));Dt([i],_,M=>{var k={};return v.forEach((D,O)=>{var X=M[O],be=D.Qb,Ee=D.Rb,F=M[O+v.length],K=D.dc,ne=D.fc;k[D.Mb]={read:Ce=>X.fromWireType(be(Ee,Ce)),write:(Ce,Oe)=>{var ze=[];K(ne,Ce,F.toWireType(ze,Oe)),cr(ze);}};}),[{name:a.name,fromWireType:D=>{var O={},X;for(X in k)O[X]=k[X].read(D);return d(D),O},toWireType:(D,O)=>{for(var X in k)if(!(X in O))throw new TypeError(`Missing field: "${X}"`);var be=c();for(X in k)k[X].write(be,O[X]);return D!==null&&D.push(d,be),be},argPackAdvance:8,readValueFromPointer:En,L:d}]});},_embind_register_bigint:()=>{},_embind_register_bool:(i,a,c,d)=>{a=wt(a),Xt(i,{name:a,fromWireType:function(v){return !!v},toWireType:function(v,_){return _?c:d},argPackAdvance:8,readValueFromPointer:function(v){return this.fromWireType(z[v])},L:null});},_embind_register_class:(i,a,c,d,v,_,M,k,D,O,X,be,Ee)=>{X=wt(X),_=It(v,_),k&&(k=It(M,k)),O&&(O=It(D,O)),Ee=It(be,Ee);var F=he(X);ci(F,function(){nn(`Cannot construct ${X} due to unbound types`,[d]);}),Dt([i,a,c],d?[d]:[],K=>{if(K=K[0],d)var ne=K.i,Ce=ne.M;else Ce=Ir.prototype;K=Un(X,function(...yt){if(Object.getPrototypeOf(this)!==Oe)throw new Le("Use 'new' to construct "+X);if(ze.Z===void 0)throw new Le(X+" has no accessible constructor");var _t=ze.Z[yt.length];if(_t===void 0)throw new Le(`Tried to invoke ctor of ${X} with invalid number of parameters (${yt.length}) - expected (${Object.keys(ze.Z).toString()}) parameters instead!`);return _t.apply(this,yt)});var Oe=Object.create(Ce,{constructor:{value:K}});K.prototype=Oe;var ze=new Ze(X,K,Oe,Ee,ne,_,k,O);if(ze.B){var ut;(ut=ze.B).oa??(ut.oa=[]),ze.B.oa.push(ze);}return ne=new Lr(X,ze,true,false,false),ut=new Lr(X+"*",ze,false,false,false),Ce=new Lr(X+" const*",ze,false,true,false),yo[i]={pointerType:ut,Hb:Ce},_o(F,K),[ne,ut,Ce]});},_embind_register_class_class_function:(i,a,c,d,v,_,M)=>{var k=dr(c,d);a=wt(a),a=ui(a),_=It(v,_),Dt([],[i],D=>{function O(){nn(`Cannot call ${X} due to unbound types`,k);}D=D[0];var X=`${D.name}.${a}`;a.startsWith("@@")&&(a=Symbol[a.substring(2)]);var be=D.i.constructor;return be[a]===void 0?(O.fa=c-1,be[a]=O):(li(be,a,X),be[a].A[c-1]=O),Dt([],k,Ee=>{if(Ee=Nr(X,[Ee[0],null].concat(Ee.slice(1)),null,_,M),be[a].A===void 0?(Ee.fa=c-1,be[a]=Ee):be[a].A[c-1]=Ee,D.i.oa)for(let F of D.i.oa)F.constructor.hasOwnProperty(a)||(F.constructor[a]=Ee);return []}),[]});},_embind_register_class_class_property:(i,a,c,d,v,_,M,k)=>{a=wt(a),_=It(v,_),Dt([],[i],D=>{D=D[0];var O=`${D.name}.${a}`,X={get(){nn(`Cannot access ${O} due to unbound types`,[c]);},enumerable:true,configurable:true};return X.set=k?()=>{nn(`Cannot access ${O} due to unbound types`,[c]);}:()=>{throw new Le(`${O} is a read-only property`)},Object.defineProperty(D.i.constructor,a,X),Dt([],[c],be=>{be=be[0];var Ee={get(){return be.fromWireType(_(d))},enumerable:true};return k&&(k=It(M,k),Ee.set=F=>{var K=[];k(d,be.toWireType(K,F)),cr(K);}),Object.defineProperty(D.i.constructor,a,Ee),[]}),[]});},_embind_register_class_constructor:(i,a,c,d,v,_)=>{var M=dr(a,c);v=It(d,v),Dt([],[i],k=>{k=k[0];var D=`constructor ${k.name}`;if(k.i.Z===void 0&&(k.i.Z=[]),k.i.Z[a-1]!==void 0)throw new Le(`Cannot register multiple constructors with identical number of parameters (${a-1}) for class '${k.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return k.i.Z[a-1]=()=>{nn(`Cannot construct ${k.name} due to unbound types`,M);},Dt([],M,O=>(O.splice(1,0,null),k.i.Z[a-1]=Nr(D,O,null,v,_),[])),[]});},_embind_register_class_function:(i,a,c,d,v,_,M,k)=>{var D=dr(c,d);a=wt(a),a=ui(a),_=It(v,_),Dt([],[i],O=>{function X(){nn(`Cannot call ${be} due to unbound types`,D);}O=O[0];var be=`${O.name}.${a}`;a.startsWith("@@")&&(a=Symbol[a.substring(2)]),k&&O.i.ob.push(a);var Ee=O.i.M,F=Ee[a];return F===void 0||F.A===void 0&&F.className!==O.name&&F.fa===c-2?(X.fa=c-2,X.className=O.name,Ee[a]=X):(li(Ee,a,be),Ee[a].A[c-2]=X),Dt([],D,K=>(K=Nr(be,K,O,_,M),Ee[a].A===void 0?(K.fa=c-2,Ee[a]=K):Ee[a].A[c-2]=K,[])),[]});},_embind_register_class_property:(i,a,c,d,v,_,M,k,D,O)=>{a=wt(a),v=It(d,v),Dt([],[i],X=>{X=X[0];var be=`${X.name}.${a}`,Ee={get(){nn(`Cannot access ${be} due to unbound types`,[c,M]);},enumerable:true,configurable:true};return Ee.set=D?()=>nn(`Cannot access ${be} due to unbound types`,[c,M]):()=>{throw new Le(be+" is a read-only property")},Object.defineProperty(X.i.M,a,Ee),Dt([],D?[c,M]:[c],F=>{var K=F[0],ne={get(){var Oe=di(this,X,be+" getter");return K.fromWireType(v(_,Oe))},enumerable:true};if(D){D=It(k,D);var Ce=F[1];ne.set=function(Oe){var ze=di(this,X,be+" setter"),ut=[];D(O,ze,Ce.toWireType(ut,Oe)),cr(ut);};}return Object.defineProperty(X.i.M,a,ne),[]}),[]});},_embind_register_emval:i=>Xt(i,bs),_embind_register_enum:(i,a,c,d)=>{function v(){}a=wt(a),v.values={},Xt(i,{name:a,constructor:v,fromWireType:function(_){return this.constructor.values[_]},toWireType:(_,M)=>M.value,argPackAdvance:8,readValueFromPointer:ys(a,c,d),L:null}),ci(a,v);},_embind_register_enum_value:(i,a,c)=>{var d=Hn(i,"enum");a=wt(a),i=d.constructor,d=Object.create(d.constructor.prototype,{value:{value:c},constructor:{value:Un(`${d.name}_${a}`,function(){})}}),i.values[c]=d,i[a]=d;},_embind_register_float:(i,a,c)=>{a=wt(a),Xt(i,{name:a,fromWireType:d=>d,toWireType:(d,v)=>v,argPackAdvance:8,readValueFromPointer:_s(a,c),L:null});},_embind_register_function:(i,a,c,d,v,_)=>{var M=dr(a,c);i=wt(i),i=ui(i),v=It(d,v),ci(i,function(){nn(`Cannot call ${i} due to unbound types`,M);},a-1),Dt([],M,k=>(_o(i,Nr(i,[k[0],null].concat(k.slice(1)),null,v,_),a-1),[]));},_embind_register_integer:(i,a,c,d,v)=>{if(a=wt(a),v===-1&&(v=4294967295),v=k=>k,d===0){var _=32-8*c;v=k=>k<<_>>>_;}var M=a.includes("unsigned")?function(k,D){return D>>>0}:function(k,D){return D};Xt(i,{name:a,fromWireType:v,toWireType:M,argPackAdvance:8,readValueFromPointer:ws(a,c,d!==0),L:null});},_embind_register_memory_view:(i,a,c)=>{function d(_){return new v(G.buffer,q[_+4>>2],q[_>>2])}var v=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][a];c=wt(c),Xt(i,{name:c,fromWireType:d,argPackAdvance:8,readValueFromPointer:d},{Tb:true});},_embind_register_std_string:(i,a)=>{a=wt(a);var c=a==="std::string";Xt(i,{name:a,fromWireType:function(d){var v=q[d>>2],_=d+4;if(c)for(var M=_,k=0;k<=v;++k){var D=_+k;if(k==v||z[D]==0){if(M=M?ie(z,M,D-M):"",O===void 0)var O=M;else O+="\0",O+=M;M=D+1;}}else {for(O=Array(v),k=0;k<v;++k)O[k]=String.fromCharCode(z[_+k]);O=O.join("");}return kn(d),O},toWireType:function(d,v){v instanceof ArrayBuffer&&(v=new Uint8Array(v));var _=typeof v=="string";if(!(_||v instanceof Uint8Array||v instanceof Uint8ClampedArray||v instanceof Int8Array))throw new Le("Cannot pass non-string to std::string");var M=c&&_?nt(v):v.length,k=Oo(4+M+1),D=k+4;if(q[k>>2]=M,c&&_)Qe(v,z,D,M+1);else if(_)for(_=0;_<M;++_){var O=v.charCodeAt(_);if(255<O)throw kn(D),new Le("String has UTF-16 code units that do not fit in 8 bits");z[D+_]=O;}else for(_=0;_<M;++_)z[D+_]=v[_];return d!==null&&d.push(kn,k),k},argPackAdvance:8,readValueFromPointer:En,L(d){kn(d);}});},_embind_register_std_wstring:(i,a,c)=>{if(c=wt(c),a===2)var d=Ss,v=Es,_=Ms,M=k=>N[k>>1];else a===4&&(d=Ts,v=ks,_=Cs,M=k=>q[k>>2]);Xt(i,{name:c,fromWireType:k=>{for(var D=q[k>>2],O,X=k+4,be=0;be<=D;++be){var Ee=k+4+be*a;(be==D||M(Ee)==0)&&(X=d(X,Ee-X),O===void 0?O=X:(O+="\0",O+=X),X=Ee+a);}return kn(k),O},toWireType:(k,D)=>{if(typeof D!="string")throw new Le(`Cannot pass non-string to C++ string type ${c}`);var O=_(D),X=Oo(4+O+a);return q[X>>2]=O/a,v(D,X+4,O+a),k!==null&&k.push(kn,X),X},argPackAdvance:8,readValueFromPointer:En,L(k){kn(k);}});},_embind_register_value_object:(i,a,c,d,v,_)=>{xr[i]={name:wt(a),Ta:It(c,d),O:It(v,_),eb:[]};},_embind_register_value_object_field:(i,a,c,d,v,_,M,k,D,O)=>{xr[i].eb.push({Mb:wt(a),Sb:c,Qb:It(d,v),Rb:_,ec:M,dc:It(k,D),fc:O});},_embind_register_void:(i,a)=>{a=wt(a),Xt(i,{Ic:true,name:a,argPackAdvance:0,fromWireType:()=>{},toWireType:()=>{}});},_emscripten_get_now_is_monotonic:()=>1,_emscripten_memcpy_js:(i,a,c)=>z.copyWithin(i,a,a+c),_emscripten_throw_longjmp:()=>{throw 1/0},_emval_as:(i,a,c)=>(i=Yt(i),a=Hn(a,"emval::as"),Mo(a,c,i)),_emval_call:(i,a,c,d)=>(i=Dr[i],a=Yt(a),i(null,a,c,d)),_emval_call_method:(i,a,c,d,v)=>(i=Dr[i],a=Yt(a),c=ko(c),i(a,a[c],d,v)),_emval_decref:fi,_emval_get_method_caller:(i,a,c)=>{var d=ge(i,a),v=d.shift();i--;var _=Array(i);return a=`methodCaller<(${d.map(M=>M.name).join(", ")}) => ${v.name}>`,xs(Un(a,(M,k,D,O)=>{for(var X=0,be=0;be<i;++be)_[be]=d[be].readValueFromPointer(O+X),X+=d[be].argPackAdvance;return M=c===1?je(k,_):k.apply(M,_),Mo(v,D,M)}))},_emval_get_property:(i,a)=>(i=Yt(i),a=Yt(a),tn(i[a])),_emval_incref:i=>{9<i&&(en[i+1]+=1);},_emval_new_array:()=>tn([]),_emval_new_cstring:i=>tn(ko(i)),_emval_new_object:()=>tn({}),_emval_run_destructors:i=>{var a=Yt(i);cr(a),fi(i);},_emval_set_property:(i,a,c)=>{i=Yt(i),a=Yt(a),c=Yt(c),i[a]=c;},_emval_take_value:(i,a)=>(i=Hn(i,"_emval_take_value"),i=i.readValueFromPointer(a),tn(i)),_gmtime_js:function(i,a,c){i=new Date(1e3*(a+2097152>>>0<4194305-!!i?(i>>>0)+4294967296*a:NaN)),U[c>>2]=i.getUTCSeconds(),U[c+4>>2]=i.getUTCMinutes(),U[c+8>>2]=i.getUTCHours(),U[c+12>>2]=i.getUTCDate(),U[c+16>>2]=i.getUTCMonth(),U[c+20>>2]=i.getUTCFullYear()-1900,U[c+24>>2]=i.getUTCDay(),U[c+28>>2]=(i.getTime()-Date.UTC(i.getUTCFullYear(),0,1,0,0,0,0))/864e5|0;},_localtime_js:function(i,a,c){i=new Date(1e3*(a+2097152>>>0<4194305-!!i?(i>>>0)+4294967296*a:NaN)),U[c>>2]=i.getSeconds(),U[c+4>>2]=i.getMinutes(),U[c+8>>2]=i.getHours(),U[c+12>>2]=i.getDate(),U[c+16>>2]=i.getMonth(),U[c+20>>2]=i.getFullYear()-1900,U[c+24>>2]=i.getDay(),U[c+28>>2]=(Lt(i.getFullYear())?Fr:Co)[i.getMonth()]+i.getDate()-1|0,U[c+36>>2]=-(60*i.getTimezoneOffset()),a=new Date(i.getFullYear(),6,1).getTimezoneOffset();var d=new Date(i.getFullYear(),0,1).getTimezoneOffset();U[c+32>>2]=(a!=d&&i.getTimezoneOffset()==Math.min(d,a))|0;},_tzset_js:(i,a,c,d)=>{var v=new Date().getFullYear(),_=new Date(v,0,1),M=new Date(v,6,1);v=_.getTimezoneOffset();var k=M.getTimezoneOffset();q[i>>2]=60*Math.max(v,k),U[a>>2]=+(v!=k),i=D=>D.toLocaleTimeString(void 0,{hour12:false,timeZoneName:"short"}).split(" ")[1],_=i(_),M=i(M),k<v?(Qe(_,z,c,17),Qe(M,z,d,17)):(Qe(_,z,d,17),Qe(M,z,c,17));},beginPixelLocalStorageWEBGL:function(i,a,c){(i=Ot[i].F.Da)&&i.beginPixelLocalStorageWEBGL(m.HEAPU32.subarray(c,c+a));},decode_image:function(i,a,c){var d=m.images;d||(d=new Map,m.images=d);var v=new Image;d.set(i,v),a=m.HEAP8.subarray(a,a+c),c=new Uint8Array(c),c.set(a),v.src=URL.createObjectURL(new Blob([c],{type:"image/png"})),v.onload=function(){m._setWebImage(i,v.width,v.height);};},delete_image:function(i){var a=m.images;a&&a.get(i)&&a.delete(i);},emscripten_asm_const_int:(i,a,c)=>{Rs.length=0;for(var d;d=z[a++];){var v=d!=105;v&=d!=112,c+=v&&c%8?4:0,Rs.push(d==112?q[c>>2]:d==105?U[c>>2]:Re[c>>3]),c+=v?8:4;}return He[i](...Rs)},emscripten_date_now:()=>Date.now(),emscripten_get_now:()=>performance.now(),emscripten_resize_heap:i=>{var a=z.length;if(i>>>=0,2147483648<i)return false;for(var c=1;4>=c;c*=2){var d=a*(1+.2/c);d=Math.min(d,i+100663296);var v=Math;d=Math.max(i,d);e:{v=(v.min.call(v,2147483648,d+(65536-d%65536)%65536)-Ie.buffer.byteLength+65535)/65536;try{Ie.grow(v),Pe();var _=1;break e}catch{}_=void 0;}if(_)return true}return false},emscripten_webgl_enable_extension:(i,a)=>(i=Ot[i],a=a?ie(z,a):"",a.startsWith("GL_")&&(a=a.substr(3)),a=="WEBGL_draw_instanced_base_vertex_base_instance"&&Wc(j),a=="WEBGL_multi_draw_instanced_base_vertex_base_instance"&&Hc(j),a=="WEBGL_multi_draw"&&(j.$b=j.getExtension("WEBGL_multi_draw")),!!i.F.getExtension(a)),emscripten_webgl_get_current_context:()=>Tn?Tn.handle:0,emscripten_webgl_make_context_current:i=>Is(i)?0:-5,enable_WEBGL_provoking_vertex:function(i){return i=Ot[i].F,i.pb=i.getExtension("WEBGL_provoking_vertex"),!!i.pb},enable_WEBGL_shader_pixel_local_storage_coherent:function(i){i=Ot[i].F;let a=i.getExtension("WEBGL_shader_pixel_local_storage");return a&&a.isCoherent()&&a.framebufferTexturePixelLocalStorageWEBGL.length==5?(i.Da=a,true):false},endPixelLocalStorageWEBGL:function(i,a,c){(i=Ot[i].F.Da)&&i.endPixelLocalStorageWEBGL(m.HEAPU32.subarray(c,c+a));},environ_get:(i,a)=>{var c=0;return Kc().forEach((d,v)=>{var _=a+c;for(v=q[i+4*v>>2]=_,_=0;_<d.length;++_)G[v++]=d.charCodeAt(_);G[v]=0,c+=d.length+1;}),0},environ_sizes_get:(i,a)=>{var c=Kc();q[i>>2]=c.length;var d=0;return c.forEach(v=>d+=v.length+1),q[a>>2]=d,0},fd_close:function(i){try{var a=Be(i);if(a.W===null)throw new me(8);a.Qa&&(a.Qa=null);try{a.m.close&&a.m.close(a);}catch(c){throw c}finally{Zt[a.W]=null;}return a.W=null,0}catch(c){if(typeof wn>"u"||c.name!=="ErrnoError")throw c;return c.$}},fd_read:function(i,a,c,d){try{e:{var v=Be(i);i=a;for(var _,M=a=0;M<c;M++){var k=q[i>>2],D=q[i+4>>2];i+=8;var O=v,X=_,be=G;if(0>D||0>X)throw new me(28);if(O.W===null)throw new me(8);if((O.flags&2097155)===1)throw new me(8);if((O.node.mode&61440)===16384)throw new me(31);if(!O.m.read)throw new me(28);var Ee=typeof X<"u";if(!Ee)X=O.position;else if(!O.seekable)throw new me(70);var F=O.m.read(O,be,k,D,X);Ee||(O.position+=F);var K=F;if(0>K){var ne=-1;break e}if(a+=K,K<D)break;typeof _<"u"&&(_+=K);}ne=a;}return q[d>>2]=ne,0}catch(Ce){if(typeof wn>"u"||Ce.name!=="ErrnoError")throw Ce;return Ce.$}},fd_seek:function(i,a,c,d,v){a=c+2097152>>>0<4194305-!!a?(a>>>0)+4294967296*c:NaN;try{if(isNaN(a))return 61;var _=Be(i);return po(_,a,d),tt=[_.position>>>0,(et=_.position,1<=+Math.abs(et)?0<et?+Math.floor(et/4294967296)>>>0:~~+Math.ceil((et-+(~~et>>>0))/4294967296)>>>0:0)],U[v>>2]=tt[0],U[v+4>>2]=tt[1],_.Qa&&a===0&&d===0&&(_.Qa=null),0}catch(M){if(typeof wn>"u"||M.name!=="ErrnoError")throw M;return M.$}},fd_write:function(i,a,c,d){try{e:{var v=Be(i);i=a;for(var _,M=a=0;M<c;M++){var k=q[i>>2],D=q[i+4>>2];i+=8;var O=v,X=k,be=D,Ee=_,F=G;if(0>be||0>Ee)throw new me(28);if(O.W===null)throw new me(8);if((O.flags&2097155)===0)throw new me(8);if((O.node.mode&61440)===16384)throw new me(31);if(!O.m.write)throw new me(28);O.seekable&&O.flags&1024&&po(O,0,2);var K=typeof Ee<"u";if(!K)Ee=O.position;else if(!O.seekable)throw new me(70);var ne=O.m.write(O,F,X,be,Ee,void 0);K||(O.position+=ne);var Ce=ne;if(0>Ce){var Oe=-1;break e}a+=Ce,typeof _<"u"&&(_+=Ce);}Oe=a;}return q[d>>2]=Oe,0}catch(ze){if(typeof wn>"u"||ze.name!=="ErrnoError")throw ze;return ze.$}},framebufferPixelLocalClearValuefvWEBGL:function(i,a,c,d,v,_){(i=Ot[i].F.Da)&&i.framebufferPixelLocalClearValuefvWEBGL(a,[c,d,v,_]);},framebufferTexturePixelLocalStorageWEBGL:function(i,a,c,d,v,_){(i=Ot[i].F.Da)&&i.framebufferTexturePixelLocalStorageWEBGL(a,Br[c],d,v,_);},glActiveTexture:i=>j.activeTexture(i),glAttachShader:(i,a)=>{j.attachShader(rn[i],fr[a]);},glBindBuffer:(i,a)=>{i==35051?j.Oa=a:i==35052&&(j.ra=a),j.bindBuffer(i,hi[a]);},glBindBufferRange:(i,a,c,d,v)=>{j.bindBufferRange(i,a,hi[c],d,v);},glBindFramebuffer:(i,a)=>{j.bindFramebuffer(i,xo[a]);},glBindRenderbuffer:(i,a)=>{j.bindRenderbuffer(i,mi[a]);},glBindTexture:(i,a)=>{j.bindTexture(i,Br[a]);},glBindVertexArray:i=>{j.bindVertexArray(Ro[i]);},glBlendEquation:i=>j.blendEquation(i),glBlendFunc:(i,a)=>j.blendFunc(i,a),glBlitFramebuffer:(i,a,c,d,v,_,M,k,D,O)=>j.blitFramebuffer(i,a,c,d,v,_,M,k,D,O),glBufferData:(i,a,c,d)=>{c&&a?j.bufferData(i,z,d,c,a):j.bufferData(i,a,d);},glBufferSubData:(i,a,c,d)=>{c&&j.bufferSubData(i,a,z,d,c);},glClear:i=>j.clear(i),glClearBufferfv:(i,a,c)=>{j.clearBufferfv(i,a,se,c>>2);},glClearBufferuiv:(i,a,c)=>{j.clearBufferuiv(i,a,q,c>>2);},glClearColor:(i,a,c,d)=>j.clearColor(i,a,c,d),glClearDepthf:i=>j.clearDepth(i),glClearStencil:i=>j.clearStencil(i),glColorMask:(i,a,c,d)=>{j.colorMask(!!i,!!a,!!c,!!d);},glCompileShader:i=>{j.compileShader(fr[i]);},glCompressedTexSubImage2D:(i,a,c,d,v,_,M,k,D)=>{j.ra||!k?j.compressedTexSubImage2D(i,a,c,d,v,_,M,k,D):j.compressedTexSubImage2D(i,a,c,d,v,_,M,z,D,k);},glCreateProgram:()=>{var i=Po(rn),a=j.createProgram();return a.name=i,a.za=a.xa=a.ya=0,a.Wa=1,rn[i]=a,i},glCreateShader:i=>{var a=Po(fr);return fr[a]=j.createShader(i),a},glCullFace:i=>j.cullFace(i),glDeleteBuffers:(i,a)=>{for(var c=0;c<i;c++){var d=U[a+4*c>>2],v=hi[d];v&&(j.deleteBuffer(v),v.name=0,hi[d]=null,d==j.Oa&&(j.Oa=0),d==j.ra&&(j.ra=0));}},glDeleteFramebuffers:(i,a)=>{for(var c=0;c<i;++c){var d=U[a+4*c>>2],v=xo[d];v&&(j.deleteFramebuffer(v),v.name=0,xo[d]=null);}},glDeleteProgram:i=>{if(i){var a=rn[i];a?(j.deleteProgram(a),a.name=0,rn[i]=null):Ft||(Ft=1281);}},glDeleteRenderbuffers:(i,a)=>{for(var c=0;c<i;c++){var d=U[a+4*c>>2],v=mi[d];v&&(j.deleteRenderbuffer(v),v.name=0,mi[d]=null);}},glDeleteShader:i=>{if(i){var a=fr[i];a?(j.deleteShader(a),fr[i]=null):Ft||(Ft=1281);}},glDeleteTextures:(i,a)=>{for(var c=0;c<i;c++){var d=U[a+4*c>>2],v=Br[d];v&&(j.deleteTexture(v),v.name=0,Br[d]=null);}},glDeleteVertexArrays:(i,a)=>{for(var c=0;c<i;c++){var d=U[a+4*c>>2];j.deleteVertexArray(Ro[d]),Ro[d]=null;}},glDepthFunc:i=>j.depthFunc(i),glDepthMask:i=>{j.depthMask(!!i);},glDepthRangef:(i,a)=>j.depthRange(i,a),glDisable:i=>j.disable(i),glDrawArrays:(i,a,c)=>{j.drawArrays(i,a,c);},glDrawArraysInstanced:(i,a,c,d)=>{j.drawArraysInstanced(i,a,c,d);},glDrawBuffers:(i,a)=>{for(var c=Ns[i],d=0;d<i;d++)c[d]=U[a+4*d>>2];j.drawBuffers(c);},glDrawElements:(i,a,c,d)=>{j.drawElements(i,a,c,d);},glDrawElementsInstanced:(i,a,c,d,v)=>{j.drawElementsInstanced(i,a,c,d,v);},glEnable:i=>j.enable(i),glEnableVertexAttribArray:i=>{j.enableVertexAttribArray(i);},glFlush:()=>j.flush(),glFramebufferRenderbuffer:(i,a,c,d)=>{j.framebufferRenderbuffer(i,a,c,mi[d]);},glFramebufferTexture2D:(i,a,c,d,v)=>{j.framebufferTexture2D(i,a,c,Br[d],v);},glFrontFace:i=>j.frontFace(i),glGenBuffers:(i,a)=>{gi(i,a,"createBuffer",hi);},glGenFramebuffers:(i,a)=>{gi(i,a,"createFramebuffer",xo);},glGenRenderbuffers:(i,a)=>{gi(i,a,"createRenderbuffer",mi);},glGenTextures:(i,a)=>{gi(i,a,"createTexture",Br);},glGenVertexArrays:(i,a)=>{gi(i,a,"createVertexArray",Ro);},glGenerateMipmap:i=>j.generateMipmap(i),glGetIntegerv:(i,a)=>vm(i,a),glGetProgramiv:(i,a,c)=>{if(c)if(i>=jc)Ft||(Ft=1281);else if(i=rn[i],a==35716)i=j.getProgramInfoLog(i),i===null&&(i="(unknown error)"),U[c>>2]=i.length+1;else if(a==35719){if(!i.za)for(a=0;a<j.getProgramParameter(i,35718);++a)i.za=Math.max(i.za,j.getActiveUniform(i,a).name.length+1);U[c>>2]=i.za;}else if(a==35722){if(!i.xa)for(a=0;a<j.getProgramParameter(i,35721);++a)i.xa=Math.max(i.xa,j.getActiveAttrib(i,a).name.length+1);U[c>>2]=i.xa;}else if(a==35381){if(!i.ya)for(a=0;a<j.getProgramParameter(i,35382);++a)i.ya=Math.max(i.ya,j.getActiveUniformBlockName(i,a).length+1);U[c>>2]=i.ya;}else U[c>>2]=j.getProgramParameter(i,a);else Ft||(Ft=1281);},glGetString:i=>{var a=zc[i];if(!a){switch(i){case 7939:a=Io(qc().join(" "));break;case 7936:case 7937:case 37445:case 37446:(a=j.getParameter(i))||Ft||(Ft=1280),a=a?Io(a):0;break;case 7938:a=Io(`OpenGL ES 3.0 (${j.getParameter(7938)})`);break;case 35724:a=j.getParameter(35724);var c=a.match(/^WebGL GLSL ES ([0-9]\.[0-9][0-9]?)(?:$| .*)/);c!==null&&(c[1].length==3&&(c[1]+="0"),a=`OpenGL ES GLSL ES ${c[1]} (${a})`),a=Io(a);break;default:Ft||(Ft=1280);}zc[i]=a;}return a},glGetUniformBlockIndex:(i,a)=>j.getUniformBlockIndex(rn[i],a?ie(z,a):""),glGetUniformLocation:(i,a)=>{if(a=a?ie(z,a):"",i=rn[i]){var c=i,d=c.ma,v=c.wb,_;if(!d)for(c.ma=d={},c.vb={},_=0;_<j.getProgramParameter(c,35718);++_){var M=j.getActiveUniform(c,_),k=M.name;M=M.size;var D=Xc(k);D=0<D?k.slice(0,D):k;var O=c.Wa;for(c.Wa+=M,v[D]=[M,O],k=0;k<M;++k)d[O]=k,c.vb[O++]=D;}if(c=i.ma,d=0,v=a,_=Xc(a),0<_&&(d=parseInt(a.slice(_+1))>>>0,v=a.slice(0,_)),(v=i.wb[v])&&d<v[0]&&(d+=v[1],c[d]=c[d]||j.getUniformLocation(i,a)))return d}else Ft||(Ft=1281);return -1},glInvalidateFramebuffer:(i,a,c)=>{for(var d=Ns[a],v=0;v<a;v++)d[v]=U[c+4*v>>2];j.invalidateFramebuffer(i,d);},glLinkProgram:i=>{i=rn[i],j.linkProgram(i),i.ma=0,i.wb={};},glPixelStorei:(i,a)=>{i==3317?Ps=a:i==3314&&(Yc=a),j.pixelStorei(i,a);},glReadPixels:(i,a,c,d,v,_,M)=>{if(j.Oa)j.readPixels(i,a,c,d,v,_,M);else {var k=Ds(_);M>>>=31-Math.clz32(k.BYTES_PER_ELEMENT),j.readPixels(i,a,c,d,v,_,k,M);}},glRenderbufferStorageMultisample:(i,a,c,d,v)=>j.renderbufferStorageMultisample(i,a,c,d,v),glScissor:(i,a,c,d)=>j.scissor(i,a,c,d),glShaderSource:(i,a,c,d)=>{for(var v="",_=0;_<a;++_){var M=(M=q[c+4*_>>2])?ie(z,M,d?q[d+4*_>>2]:void 0):"";v+=M;}j.shaderSource(fr[i],v);},glStencilFunc:(i,a,c)=>j.stencilFunc(i,a,c),glStencilFuncSeparate:(i,a,c,d)=>j.stencilFuncSeparate(i,a,c,d),glStencilMask:i=>j.stencilMask(i),glStencilOp:(i,a,c)=>j.stencilOp(i,a,c),glStencilOpSeparate:(i,a,c,d)=>j.stencilOpSeparate(i,a,c,d),glTexParameteri:(i,a,c)=>j.texParameteri(i,a,c),glTexStorage2D:(i,a,c,d,v)=>j.texStorage2D(i,a,c,d,v),glTexStorage3D:(i,a,c,d,v,_)=>j.texStorage3D(i,a,c,d,v,_),glTexSubImage2D:(i,a,c,d,v,_,M,k,D)=>{if(j.ra)j.texSubImage2D(i,a,c,d,v,_,M,k,D);else if(D){var O=Ds(k);j.texSubImage2D(i,a,c,d,v,_,M,k,O,D>>>31-Math.clz32(O.BYTES_PER_ELEMENT));}else {if(D){O=Ds(k);var X=_*((Yc||v)*({5:3,6:4,8:2,29502:3,29504:4,26917:2,26918:2,29846:3,29847:4}[M-6402]||1)*O.BYTES_PER_ELEMENT+Ps-1&-Ps);D=O.subarray(D>>>31-Math.clz32(O.BYTES_PER_ELEMENT),D+X>>>31-Math.clz32(O.BYTES_PER_ELEMENT));}else D=null;j.texSubImage2D(i,a,c,d,v,_,M,k,D);}},glUniform1i:(i,a)=>{var c=j,d=c.uniform1i,v=j.Ib;if(v){var _=v.ma[i];typeof _=="number"&&(v.ma[i]=_=j.getUniformLocation(v,v.vb[i]+(0<_?`[${_}]`:""))),i=_;}else Ft||(Ft=1282),i=void 0;d.call(c,i,a);},glUniformBlockBinding:(i,a,c)=>{i=rn[i],j.uniformBlockBinding(i,a,c);},glUseProgram:i=>{i=rn[i],j.useProgram(i),j.Ib=i;},glVertexAttribDivisor:(i,a)=>{j.vertexAttribDivisor(i,a);},glVertexAttribIPointer:(i,a,c,d,v)=>{j.vertexAttribIPointer(i,a,c,d,v);},glVertexAttribPointer:(i,a,c,d,v,_)=>{j.vertexAttribPointer(i,a,c,!!d,v,_);},glViewport:(i,a,c,d)=>j.viewport(i,a,c,d),invoke_vii:Am,isWindowsBrowser:function(){return -1<navigator.platform.indexOf("Win")},provokingVertexWEBGL:function(i,a){(i=Ot[i].F.pb)&&i.provokingVertexWEBGL(a);},strftime:Jc,strftime_l:(i,a,c,d)=>Jc(i,a,c,d),upload_image:function(i,a){var c=m.images;c&&(a=c.get(a))&&(i=Ot[i].F,i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,true),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,a),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,false));},wasm_start_image_decode:function(i,a,c){a=m.HEAP8.subarray(a,a+c),c=new Uint8Array(c),c.set(a),createImageBitmap(new Blob([c])).then(function(d){var v=new OffscreenCanvas(d.width,d.height).getContext("2d");v.drawImage(d,0,0),v=v.getImageData(0,0,d.width,d.height);var _=v.data.length,M=m.Cb(_);m.oc.set(v.data,M),m.qc(i,d.width,d.height,M,_);}).catch(function(d){d=d.message||"decode failed";var v=m.Jc(d)+1,_=m.Cb(v);m.Rc(d,_,v),m.rc(i,_),m.pc(_);});}},ot=(function(){function i(c){return ot=c.exports,Ie=ot.memory,Pe(),wo=ot.__indirect_function_table,ve.unshift(ot.__wasm_call_ctors),qe--,m.monitorRunDependencies?.(qe),qe==0&&(fe&&(c=fe,fe=null,c())),ot}var a={env:eu,wasi_snapshot_preview1:eu};if(qe++,m.monitorRunDependencies?.(qe),m.instantiateWasm)try{return m.instantiateWasm(a,i)}catch(c){Se(`Module.instantiateWasm callback failed with error: ${c}`),C(c);}return Ue||(Ue=ye("webgl2_advanced.wasm")?"webgl2_advanced.wasm":m.locateFile?m.locateFile("webgl2_advanced.wasm",H):H+"webgl2_advanced.wasm"),st(a,function(c){i(c.instance);}).catch(C),{}})(),kn=i=>(kn=ot.free)(i),Oo=i=>(Oo=ot.malloc)(i);m._setWebImage=(i,a,c)=>(m._setWebImage=ot.setWebImage)(i,a,c);var tu=i=>(tu=ot.__getTypeName)(i);m._wasm_image_decode_complete=(i,a,c,d,v)=>(m._wasm_image_decode_complete=ot.wasm_image_decode_complete)(i,a,c,d,v),m._wasm_image_decode_error=(i,a)=>(m._wasm_image_decode_error=ot.wasm_image_decode_error)(i,a);var nu=m._ma_device__on_notification_unlocked=i=>(nu=m._ma_device__on_notification_unlocked=ot.ma_device__on_notification_unlocked)(i);m._ma_malloc_emscripten=(i,a)=>(m._ma_malloc_emscripten=ot.ma_malloc_emscripten)(i,a),m._ma_free_emscripten=(i,a)=>(m._ma_free_emscripten=ot.ma_free_emscripten)(i,a);var ru=m._ma_device_process_pcm_frames_capture__webaudio=(i,a,c)=>(ru=m._ma_device_process_pcm_frames_capture__webaudio=ot.ma_device_process_pcm_frames_capture__webaudio)(i,a,c),iu=m._ma_device_process_pcm_frames_playback__webaudio=(i,a,c)=>(iu=m._ma_device_process_pcm_frames_playback__webaudio=ot.ma_device_process_pcm_frames_playback__webaudio)(i,a,c),ou=(i,a)=>(ou=ot.setThrew)(i,a),au=i=>(au=ot._emscripten_stack_restore)(i),su=()=>(su=ot.emscripten_stack_get_current)();m.dynCall_iiiji=(i,a,c,d,v,_)=>(m.dynCall_iiiji=ot.dynCall_iiiji)(i,a,c,d,v,_),m.dynCall_iij=(i,a,c,d)=>(m.dynCall_iij=ot.dynCall_iij)(i,a,c,d),m.dynCall_iiji=(i,a,c,d,v)=>(m.dynCall_iiji=ot.dynCall_iiji)(i,a,c,d,v),m.dynCall_jii=(i,a,c)=>(m.dynCall_jii=ot.dynCall_jii)(i,a,c),m.dynCall_vijj=(i,a,c,d,v,_)=>(m.dynCall_vijj=ot.dynCall_vijj)(i,a,c,d,v,_),m.dynCall_jiji=(i,a,c,d,v)=>(m.dynCall_jiji=ot.dynCall_jiji)(i,a,c,d,v),m.dynCall_viijii=(i,a,c,d,v,_,M)=>(m.dynCall_viijii=ot.dynCall_viijii)(i,a,c,d,v,_,M),m.dynCall_iiiiij=(i,a,c,d,v,_,M)=>(m.dynCall_iiiiij=ot.dynCall_iiiiij)(i,a,c,d,v,_,M),m.dynCall_iiiiijj=(i,a,c,d,v,_,M,k,D)=>(m.dynCall_iiiiijj=ot.dynCall_iiiiijj)(i,a,c,d,v,_,M,k,D),m.dynCall_iiiiiijj=(i,a,c,d,v,_,M,k,D,O)=>(m.dynCall_iiiiiijj=ot.dynCall_iiiiiijj)(i,a,c,d,v,_,M,k,D,O);function Am(i,a,c){var d=su();try{ur(i)(a,c);}catch(v){if(au(d),v!==v+0)throw v;ou(1,0);}}var No;fe=function i(){No||lu(),No||(fe=i);};function lu(){function i(){if(!No&&(No=true,m.calledRun=true,!ae)){if(m.noFSInit||ho||(ho=true,m.stdin=m.stdin,m.stdout=m.stdout,m.stderr=m.stderr,m.stdin?ir("stdin",m.stdin):_n("/dev/tty","/dev/stdin"),m.stdout?ir("stdout",null,m.stdout):_n("/dev/tty","/dev/stdout"),m.stderr?ir("stderr",null,m.stderr):_n("/dev/tty1","/dev/stderr"),Mr("/dev/stdin",0),Mr("/dev/stdout",1),Mr("/dev/stderr",1)),fn=false,le(ve),S(m),m.onRuntimeInitialized&&m.onRuntimeInitialized(),m.postRun)for(typeof m.postRun=="function"&&(m.postRun=[m.postRun]);m.postRun.length;){var a=m.postRun.shift();De.unshift(a);}le(De);}}if(!(0<qe)){if(m.preRun)for(typeof m.preRun=="function"&&(m.preRun=[m.preRun]);m.preRun.length;)Xe();le(we),0<qe||(m.setStatus?(m.setStatus("Running..."),setTimeout(function(){setTimeout(function(){m.setStatus("");},1),i();},1)):i());}}if(m.preInit)for(typeof m.preInit=="function"&&(m.preInit=[m.preInit]);0<m.preInit.length;)m.preInit.pop()();return lu(),b=I,b})})();let h=p;}),(o=>{o.exports=JSON.parse(`{"name":"@rive-app/webgl2","version":"2.38.0","description":"Rive's webgl2 based web api.","main":"rive.js","homepage":"https://rive.app","repository":{"type":"git","url":"https://github.com/rive-app/rive-wasm/tree/master/js"},"keywords":["rive","animation"],"author":"Rive","contributors":["Luigi Rosso <luigi@rive.app> (https://rive.app)","Maxwell Talbot <max@rive.app> (https://rive.app)","Arthur Vivian <arthur@rive.app> (https://rive.app)","Umberto Sonnino <umberto@rive.app> (https://rive.app)","Matthew Sullivan <matt.j.sullivan@gmail.com> (mailto:matt.j.sullivan@gmail.com)","Chris Dalton <chris@rive.app> (https://rive.app)"],"license":"MIT","files":["rive.js","rive.wasm","rive_fallback.wasm","rive.js.map","rive.d.ts","rive_advanced.mjs.d.ts","runtimeLoader.d.ts","utils"],"typings":"rive.d.ts","dependencies":{},"browser":{"fs":false,"path":false}}`);}),((o,s,u)=>{u.r(s),u.d(s,{AudioAssetWrapper:()=>y.AudioAssetWrapper,AudioWrapper:()=>y.AudioWrapper,BLANK_URL:()=>A.BLANK_URL,CustomFileAssetLoaderWrapper:()=>y.CustomFileAssetLoaderWrapper,FileAssetWrapper:()=>y.FileAssetWrapper,FileFinalizer:()=>y.FileFinalizer,FocusSessionState:()=>h.FocusSessionState,FontAssetWrapper:()=>y.FontAssetWrapper,FontWrapper:()=>y.FontWrapper,ImageAssetWrapper:()=>y.ImageAssetWrapper,ImageWrapper:()=>y.ImageWrapper,KeyboardInteractions:()=>h.KeyboardInteractions,RiveFont:()=>b.RiveFont,createFinalization:()=>y.createFinalization,finalizationRegistry:()=>y.finalizationRegistry,registerTouchInteractions:()=>p.registerTouchInteractions,sanitizeUrl:()=>A.sanitizeUrl});var p=u(7),h=u(8),A=u(9),y=u(10),b=u(11);}),((o,s,u)=>{u.r(s),u.d(s,{registerTouchInteractions:()=>y});var p=void 0,h=function(b,m,S){var C,I=[];if(m)for(var L=0;L<b.length;L++){var B=b[L];I.push({clientX:B.clientX,clientY:B.clientY,identifier:B.identifier});}else {var W=S!==null?(C=Array.from(b).find(function(Q){return Q.identifier===S}))!==null&&C!==void 0?C:null:b[0];W&&I.push({clientX:W.clientX,clientY:W.clientY,identifier:W.identifier});}return I},A=function(b,m,S,C){var I,L=b;return !((I=L.changedTouches)===null||I===void 0)&&I.length?(!m&&["touchstart","touchmove"].includes(b.type)&&b.preventDefault(),h(L.changedTouches,S,C)):[{clientX:b.clientX,clientY:b.clientY,identifier:0}]},y=function(b){var m=b.canvas,S=b.artboard,C=b.stateMachines,I=C===void 0?[]:C,L=b.renderer,B=b.rive,W=b.fit,Q=b.alignment,Z=b.isTouchScrollEnabled,$=Z===void 0?false:Z,oe=b.dispatchPointerExit,J=oe===void 0?true:oe,H=b.enableMultiTouch,de=H===void 0?false:H,te=b.layoutScaleFactor,xe=te===void 0?1:te,Se=b.advanceAndDrain;if(!m||!I.length||!L||!B||!S||typeof window>"u")return null;var ue=null,Ie=false,ae=null,G=function(N){var U;if(Ie&&N instanceof MouseEvent){N.type=="mouseup"&&(Ie=false);return}Ie=$&&N.type==="touchend"&&ue==="touchstart",ue=N.type;var q=N.currentTarget.getBoundingClientRect();if(!de&&N.type==="touchstart"&&ae===null){var se=(U=N.changedTouches)===null||U===void 0?void 0:U[0];se&&(ae=se.identifier);}var Re=A(N,$,de,de?null:ae),Pe=B.computeAlignment(W,Q,{minX:0,minY:0,maxX:q.width,maxY:q.height},S.bounds,xe),we=new B.Mat2D;switch(Pe.invert(we),Re.forEach(function(He){var le=He.clientX,g=He.clientY;if(!(!le&&!g)){var l=le-q.left,f=g-q.top,w=new B.Vec2D(l,f),T=B.mapXY(we,w),R=T.x(),V=T.y();He.transformedX=R,He.transformedY=V,T.delete(),w.delete();}}),we.delete(),Pe.delete(),N.type){case "mouseout":for(var ve=function(He){J?Re.forEach(function(le){He.pointerExit(le.transformedX,le.transformedY,le.identifier);}):Re.forEach(function(le){He.pointerMove(le.transformedX,le.transformedY,le.identifier);});},De=0,Xe=I;De<Xe.length;De++){var qe=Xe[De];ve(qe);}break;case "touchmove":case "mouseover":case "mousemove":{for(var ee=function(He){Re.forEach(function(le){He.pointerMove(le.transformedX,le.transformedY,le.identifier);});},fe=0,Fe=I;fe<Fe.length;fe++){var qe=Fe[fe];ee(qe);}break}case "touchstart":case "mousedown":{for(var ye=function(He){Re.forEach(function(le){He.pointerDown(le.transformedX,le.transformedY,le.identifier);});},pe=0,Ue=I;pe<Ue.length;pe++){var qe=Ue[pe];ye(qe);}Se(0);break}case "touchend":{for(var We=function(He){Re.forEach(function(le){He.pointerUp(le.transformedX,le.transformedY,le.identifier),He.pointerExit(le.transformedX,le.transformedY,le.identifier);});},Ve=0,rt=I;Ve<rt.length;Ve++){var qe=rt[Ve];We(qe);}Se(0),!de&&Re.some(function(He){return He.identifier===ae})&&(ae=null);break}case "mouseup":{for(var st=function(He){Re.forEach(function(le){He.pointerUp(le.transformedX,le.transformedY,le.identifier);});},et=0,tt=I;et<tt.length;et++){var qe=tt[et];st(qe);}Se(0);break}}},z=function(){ae=null;},P=G.bind(p);return m.addEventListener("mouseover",P),m.addEventListener("mouseout",P),m.addEventListener("mousemove",P),m.addEventListener("mousedown",P),m.addEventListener("mouseup",P),m.addEventListener("touchmove",P,{passive:$}),m.addEventListener("touchstart",P,{passive:$}),m.addEventListener("touchend",P),m.addEventListener("touchcancel",z),function(){m.removeEventListener("mouseover",P),m.removeEventListener("mouseout",P),m.removeEventListener("mousemove",P),m.removeEventListener("mousedown",P),m.removeEventListener("mouseup",P),m.removeEventListener("touchmove",P),m.removeEventListener("touchstart",P),m.removeEventListener("touchend",P),m.removeEventListener("touchcancel",z);}};}),((o,s,u)=>{u.r(s),u.d(s,{FocusSessionState:()=>p,KeyboardInteractions:()=>h});var p;(function(A){A.NotFocused="notFocused",A.EntryPending="entryPending",A.RiveFocused="riveFocused";})(p||(p={}));var h=(function(){function A(y){var b=y.canvas,m=y.stateMachine,S=y.hasFocusNodes,C=this;this.focusSessionState=p.NotFocused,this.onCanvasFocus=function(I){if(C.hasFocusNodes&&!C.mainSm.focusState().hasFocus&&(C.focusSessionState=p.EntryPending,!!C.isKeyboardDrivenFocus())){var L=C.cameFromBeforeCanvas(I.relatedTarget);(L?C.mainSm.focusNext():C.mainSm.focusPrevious())&&(C.focusSessionState=p.RiveFocused);}},this.onCanvasBlur=function(I){C.focusSessionState=p.NotFocused;},this.onKeyDown=function(I){if(C.focusSessionState!==p.NotFocused&&I.code==="Tab"&&C.hasFocusNodes){var L=!I.shiftKey,B=L?C.mainSm.focusNext():C.mainSm.focusPrevious();B?(C.focusSessionState=p.RiveFocused,I.preventDefault()):C.focusSessionState=p.NotFocused;}},this.canvas=b,this.mainSm=m,this.hasFocusNodes=S,b.addEventListener("focus",this.onCanvasFocus),b.addEventListener("blur",this.onCanvasBlur),b.addEventListener("keydown",this.onKeyDown);}return A.prototype.setFocusSessionState=function(y){this.focusSessionState=y;},A.prototype.notifyRiveFocused=function(){this.focusSessionState=p.RiveFocused;},A.prototype.isKeyboardDrivenFocus=function(){try{return this.canvas.matches(":focus-visible")}catch{return false}},A.prototype.cameFromBeforeCanvas=function(y){if(!y)return true;var b=this.canvas.compareDocumentPosition(y);return b&Node.DOCUMENT_POSITION_PRECEDING?true:!(b&Node.DOCUMENT_POSITION_FOLLOWING)},A.prototype.cleanup=function(){this.canvas.removeEventListener("focus",this.onCanvasFocus),this.canvas.removeEventListener("blur",this.onCanvasBlur),this.canvas.removeEventListener("keydown",this.onKeyDown);},A})();}),((o,s,u)=>{u.r(s),u.d(s,{BLANK_URL:()=>S,sanitizeUrl:()=>L});var p=/^([^\w]*)(javascript|data|vbscript)/im,h=/&#(\w+)(^\w|;)?/g,A=/&(newline|tab);/gi,y=/[\u0000-\u001F\u007F-\u009F\u2000-\u200D\uFEFF]/gim,b=/^.+(:|:)/gim,m=[".","/"],S="about:blank";function C(B){return m.indexOf(B[0])>-1}function I(B){var W=B.replace(y,"");return W.replace(h,function(Q,Z){return String.fromCharCode(Z)})}function L(B){if(!B)return S;var W=I(B).replace(A,"").replace(y,"").trim();if(!W)return S;if(C(W))return W;var Q=W.match(b);if(!Q)return W;var Z=Q[0];return p.test(Z)?S:W}}),((o,s,u)=>{u.r(s),u.d(s,{AudioAssetWrapper:()=>B,AudioWrapper:()=>m,CustomFileAssetLoaderWrapper:()=>C,FileAssetWrapper:()=>I,FileFinalizer:()=>h,FontAssetWrapper:()=>W,FontWrapper:()=>S,ImageAssetWrapper:()=>L,ImageWrapper:()=>b,createFinalization:()=>oe,finalizationRegistry:()=>$});var p=(function(){var J=function(H,de){return J=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(te,xe){te.__proto__=xe;}||function(te,xe){for(var Se in xe)Object.prototype.hasOwnProperty.call(xe,Se)&&(te[Se]=xe[Se]);},J(H,de)};return function(H,de){if(typeof de!="function"&&de!==null)throw new TypeError("Class extends value "+String(de)+" is not a constructor or null");J(H,de);function te(){this.constructor=H;}H.prototype=de===null?Object.create(de):(te.prototype=de.prototype,new te);}})(),h=(function(){function J(H){this.selfUnref=false,this._file=H;}return J.prototype.unref=function(){this._file&&this._file.unref();},J})(),A=(function(){function J(H){this._finalizableObject=H;}return J.prototype.unref=function(){this._finalizableObject.unref();},J})(),y=(function(){function J(){this.selfUnref=false;}return J.prototype.unref=function(){},J})(),b=(function(J){p(H,J);function H(de){var te=J.call(this)||this;return te._nativeImage=de,te}return Object.defineProperty(H.prototype,"nativeImage",{get:function(){return this._nativeImage},enumerable:false,configurable:true}),H.prototype.unref=function(){this.selfUnref&&this._nativeImage.unref();},H})(y),m=(function(J){p(H,J);function H(de){var te=J.call(this)||this;return te._nativeAudio=de,te}return Object.defineProperty(H.prototype,"nativeAudio",{get:function(){return this._nativeAudio},enumerable:false,configurable:true}),H.prototype.unref=function(){this.selfUnref&&this._nativeAudio.unref();},H})(y),S=(function(J){p(H,J);function H(de){var te=J.call(this)||this;return te._nativeFont=de,te}return Object.defineProperty(H.prototype,"nativeFont",{get:function(){return this._nativeFont},enumerable:false,configurable:true}),H.prototype.unref=function(){this.selfUnref&&this._nativeFont.unref();},H})(y),C=(function(){function J(H,de){this._assetLoaderCallback=de,this.assetLoader=new H.CustomFileAssetLoader({loadContents:this.loadContents.bind(this)});}return J.prototype.loadContents=function(H,de){var te;if(H.isImage)te=new L(H);else if(H.isAudio)te=new B(H);else if(H.isFont)te=new W(H);else return false;return this._assetLoaderCallback(te,de)},J})(),I=(function(){function J(H){this._nativeFileAsset=H;}return J.prototype.decode=function(H){this._nativeFileAsset.decode(H);},Object.defineProperty(J.prototype,"name",{get:function(){return this._nativeFileAsset.name},enumerable:false,configurable:true}),Object.defineProperty(J.prototype,"fileExtension",{get:function(){return this._nativeFileAsset.fileExtension},enumerable:false,configurable:true}),Object.defineProperty(J.prototype,"uniqueFilename",{get:function(){return this._nativeFileAsset.uniqueFilename},enumerable:false,configurable:true}),Object.defineProperty(J.prototype,"isAudio",{get:function(){return this._nativeFileAsset.isAudio},enumerable:false,configurable:true}),Object.defineProperty(J.prototype,"isImage",{get:function(){return this._nativeFileAsset.isImage},enumerable:false,configurable:true}),Object.defineProperty(J.prototype,"isFont",{get:function(){return this._nativeFileAsset.isFont},enumerable:false,configurable:true}),Object.defineProperty(J.prototype,"cdnUuid",{get:function(){return this._nativeFileAsset.cdnUuid},enumerable:false,configurable:true}),Object.defineProperty(J.prototype,"nativeFileAsset",{get:function(){return this._nativeFileAsset},enumerable:false,configurable:true}),J})(),L=(function(J){p(H,J);function H(){return J!==null&&J.apply(this,arguments)||this}return H.prototype.setRenderImage=function(de){this._nativeFileAsset.setRenderImage(de.nativeImage);},H})(I),B=(function(J){p(H,J);function H(){return J!==null&&J.apply(this,arguments)||this}return H.prototype.setAudioSource=function(de){this._nativeFileAsset.setAudioSource(de.nativeAudio);},H})(I),W=(function(J){p(H,J);function H(){return J!==null&&J.apply(this,arguments)||this}return H.prototype.setFont=function(de){this._nativeFileAsset.setFont(de.nativeFont);},H})(I),Q=(function(){function J(H){}return J.prototype.register=function(H){H.selfUnref=true;},J.prototype.unregister=function(H){},J})(),Z=typeof FinalizationRegistry<"u"?FinalizationRegistry:Q,$=new Z(function(J){J?.unref();}),oe=function(J,H){var de=new A(H);$.register(J,de);};}),((o,s,u)=>{u.r(s),u.d(s,{RiveFont:()=>h});var p=u(3),h=(function(){function A(){}return A.setFallbackFontCallback=function(y){A._fallbackFontCallback=y??null,A._wireFallbackProc();},A._fontToPtr=function(y){var b;if(y==null)return null;var m=y.nativeFont,S=(b=m?.ptr)===null||b===void 0?void 0:b.call(m);return S??null},A._getFallbackPtr=function(y,b){return b<0||b>=y.length?null:A._fontToPtr(y[b])},A._wireFallbackProc=function(){p.RuntimeLoader.getInstance(function(y){var b=A._fallbackFontCallback;b?y.setFallbackFontCallback((function(m,S,C){var I=b(m,C);return I?Array.isArray(I)?A._getFallbackPtr(I,S):S===0?A._fontToPtr(I):null:null})):y.setFallbackFontCallback(null);});},A._fallbackFontCallback=null,A})();})],e={};function t(o){var s=e[o];if(s!==void 0)return s.exports;var u=e[o]={exports:{}};return n[o](u,u.exports,t),u.exports}t.d=(o,s)=>{for(var u in s)t.o(s,u)&&!t.o(o,u)&&Object.defineProperty(o,u,{enumerable:true,get:s[u]});},t.o=(o,s)=>Object.prototype.hasOwnProperty.call(o,s),t.r=o=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:true});};var r={};return (()=>{t.r(r),t.d(r,{Alignment:()=>I,DataEnum:()=>we,DataType:()=>Re,DrawOptimizationOptions:()=>L,EventType:()=>te,Fit:()=>C,Layout:()=>B,LoopType:()=>xe,Rive:()=>se,RiveEventType:()=>Z,RiveFile:()=>q,RiveFont:()=>u.RiveFont,RuntimeLoader:()=>s.RuntimeLoader,StateMachineInput:()=>Q,StateMachineInputType:()=>W,Testing:()=>et,ViewModel:()=>Pe,ViewModelInstance:()=>De,ViewModelInstanceArtboard:()=>Ve,ViewModelInstanceAssetImage:()=>We,ViewModelInstanceBoolean:()=>fe,ViewModelInstanceColor:()=>Ue,ViewModelInstanceEnum:()=>ye,ViewModelInstanceList:()=>pe,ViewModelInstanceNumber:()=>ee,ViewModelInstanceString:()=>qe,ViewModelInstanceTrigger:()=>Fe,ViewModelInstanceValue:()=>Xe,decodeAudio:()=>tt,decodeFont:()=>le,decodeImage:()=>He});var o=t(1),s=t(3),u=t(6),p=(function(){var g=function(l,f){return g=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(w,T){w.__proto__=T;}||function(w,T){for(var R in T)Object.prototype.hasOwnProperty.call(T,R)&&(w[R]=T[R]);},g(l,f)};return function(l,f){if(typeof f!="function"&&f!==null)throw new TypeError("Class extends value "+String(f)+" is not a constructor or null");g(l,f);function w(){this.constructor=l;}l.prototype=f===null?Object.create(f):(w.prototype=f.prototype,new w);}})(),h=function(){return h=Object.assign||function(g){for(var l,f=1,w=arguments.length;f<w;f++){l=arguments[f];for(var T in l)Object.prototype.hasOwnProperty.call(l,T)&&(g[T]=l[T]);}return g},h.apply(this,arguments)},A=function(g,l,f,w){function T(R){return R instanceof f?R:new f(function(V){V(R);})}return new(f||(f=Promise))(function(R,V){function re(_e){try{ie(w.next(_e));}catch(nt){V(nt);}}function ke(_e){try{ie(w.throw(_e));}catch(nt){V(nt);}}function ie(_e){_e.done?R(_e.value):T(_e.value).then(re,ke);}ie((w=w.apply(g,[])).next());})},y=function(g,l){var f={label:0,sent:function(){if(R[0]&1)throw R[1];return R[1]},trys:[],ops:[]},w,T,R,V=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return V.next=re(0),V.throw=re(1),V.return=re(2),typeof Symbol=="function"&&(V[Symbol.iterator]=function(){return this}),V;function re(ie){return function(_e){return ke([ie,_e])}}function ke(ie){if(w)throw new TypeError("Generator is already executing.");for(;V&&(V=0,ie[0]&&(f=0)),f;)try{if(w=1,T&&(R=ie[0]&2?T.return:ie[0]?T.throw||((R=T.return)&&R.call(T),0):T.next)&&!(R=R.call(T,ie[1])).done)return R;switch(T=0,R&&(ie=[ie[0]&2,R.value]),ie[0]){case 0:case 1:R=ie;break;case 4:return f.label++,{value:ie[1],done:!1};case 5:f.label++,T=ie[1],ie=[0];continue;case 7:ie=f.ops.pop(),f.trys.pop();continue;default:if(R=f.trys,!(R=R.length>0&&R[R.length-1])&&(ie[0]===6||ie[0]===2)){f=0;continue}if(ie[0]===3&&(!R||ie[1]>R[0]&&ie[1]<R[3])){f.label=ie[1];break}if(ie[0]===6&&f.label<R[1]){f.label=R[1],R=ie;break}if(R&&f.label<R[2]){f.label=R[2],f.ops.push(ie);break}R[2]&&f.ops.pop(),f.trys.pop();continue}ie=l.call(g,f);}catch(_e){ie=[6,_e],T=0;}finally{w=R=0;}if(ie[0]&5)throw ie[1];return {value:ie[0]?ie[1]:void 0,done:true}}},b=function(g,l,f){for(var w=0,T=l.length,R;w<T;w++)(R||!(w in l))&&(R||(R=Array.prototype.slice.call(l,0,w)),R[w]=l[w]);return g.concat(R||Array.prototype.slice.call(l))},m=(function(g){p(l,g);function l(){var f=g!==null&&g.apply(this,arguments)||this;return f.isHandledError=true,f}return l})(Error),S=function(g){return g&&g.isHandledError?g.message:"Problem loading file; may be corrupt!"},C;(function(g){g.Cover="cover",g.Contain="contain",g.Fill="fill",g.FitWidth="fitWidth",g.FitHeight="fitHeight",g.None="none",g.ScaleDown="scaleDown",g.Layout="layout";})(C||(C={}));var I;(function(g){g.Center="center",g.TopLeft="topLeft",g.TopCenter="topCenter",g.TopRight="topRight",g.CenterLeft="centerLeft",g.CenterRight="centerRight",g.BottomLeft="bottomLeft",g.BottomCenter="bottomCenter",g.BottomRight="bottomRight";})(I||(I={}));var L;(function(g){g.AlwaysDraw="alwaysDraw",g.DrawOnChanged="drawOnChanged";})(L||(L={}));var B=(function(){function g(l){var f,w,T,R,V,re,ke;this.fit=(f=l?.fit)!==null&&f!==void 0?f:C.Contain,this.alignment=(w=l?.alignment)!==null&&w!==void 0?w:I.Center,this.layoutScaleFactor=(T=l?.layoutScaleFactor)!==null&&T!==void 0?T:1,this.minX=(R=l?.minX)!==null&&R!==void 0?R:0,this.minY=(V=l?.minY)!==null&&V!==void 0?V:0,this.maxX=(re=l?.maxX)!==null&&re!==void 0?re:0,this.maxY=(ke=l?.maxY)!==null&&ke!==void 0?ke:0;}return g.new=function(l){var f=l.fit,w=l.alignment,T=l.minX,R=l.minY,V=l.maxX,re=l.maxY;return console.warn("This function is deprecated: please use `new Layout({})` instead"),new g({fit:f,alignment:w,minX:T,minY:R,maxX:V,maxY:re})},g.prototype.copyWith=function(l){var f=l.fit,w=l.alignment,T=l.layoutScaleFactor,R=l.minX,V=l.minY,re=l.maxX,ke=l.maxY;return new g({fit:f??this.fit,alignment:w??this.alignment,layoutScaleFactor:T??this.layoutScaleFactor,minX:R??this.minX,minY:V??this.minY,maxX:re??this.maxX,maxY:ke??this.maxY})},g.prototype.runtimeFit=function(l){if(this.cachedRuntimeFit)return this.cachedRuntimeFit;var f;return this.fit===C.Cover?f=l.Fit.cover:this.fit===C.Contain?f=l.Fit.contain:this.fit===C.Fill?f=l.Fit.fill:this.fit===C.FitWidth?f=l.Fit.fitWidth:this.fit===C.FitHeight?f=l.Fit.fitHeight:this.fit===C.ScaleDown?f=l.Fit.scaleDown:this.fit===C.Layout?f=l.Fit.layout:f=l.Fit.none,this.cachedRuntimeFit=f,f},g.prototype.runtimeAlignment=function(l){if(this.cachedRuntimeAlignment)return this.cachedRuntimeAlignment;var f;return this.alignment===I.TopLeft?f=l.Alignment.topLeft:this.alignment===I.TopCenter?f=l.Alignment.topCenter:this.alignment===I.TopRight?f=l.Alignment.topRight:this.alignment===I.CenterLeft?f=l.Alignment.centerLeft:this.alignment===I.CenterRight?f=l.Alignment.centerRight:this.alignment===I.BottomLeft?f=l.Alignment.bottomLeft:this.alignment===I.BottomCenter?f=l.Alignment.bottomCenter:this.alignment===I.BottomRight?f=l.Alignment.bottomRight:f=l.Alignment.center,this.cachedRuntimeAlignment=f,f},g})(),W;(function(g){g[g.Number=56]="Number",g[g.Trigger=58]="Trigger",g[g.Boolean=59]="Boolean";})(W||(W={}));var Q=(function(){function g(l,f){this.type=l,this.runtimeInput=f;}return Object.defineProperty(g.prototype,"name",{get:function(){return this.runtimeInput.name},enumerable:false,configurable:true}),Object.defineProperty(g.prototype,"value",{get:function(){return this.runtimeInput.value},set:function(l){this.runtimeInput.value=l;},enumerable:false,configurable:true}),g.prototype.fire=function(){this.type===W.Trigger&&this.runtimeInput.fire();},g.prototype.delete=function(){this.runtimeInput=null;},g})(),Z;(function(g){g[g.General=128]="General",g[g.OpenUrl=131]="OpenUrl";})(Z||(Z={}));var $=(function(){function g(l){this.isBindableArtboard=false,this.isBindableArtboard=l;}return g})(),oe=(function(g){p(l,g);function l(f,w){var T=g.call(this,false)||this;return T.nativeArtboard=f,T.file=w,T}return l})($),J=(function(g){p(l,g);function l(f){var w=g.call(this,true)||this;return w.selfUnref=false,w.nativeArtboard=f,w}return Object.defineProperty(l.prototype,"viewModel",{set:function(f){this.nativeViewModel=f.nativeInstance;},enumerable:false,configurable:true}),l.prototype.destroy=function(){var f;this.selfUnref&&(this.nativeArtboard.unref(),(f=this.nativeViewModel)===null||f===void 0||f.unref());},l})($),H=(function(){function g(l,f,w,T){this.stateMachine=l,this.playing=w,this.artboard=T,this.inputs=[],this.instance=new f.StateMachineInstance(l,T),this.initInputs(f),this.hasFocusNodes=this.instance.hasFocusNodes();}return Object.defineProperty(g.prototype,"name",{get:function(){return this.stateMachine.name},enumerable:false,configurable:true}),Object.defineProperty(g.prototype,"statesChanged",{get:function(){for(var l=[],f=0;f<this.instance.stateChangedCount();f++)l.push(this.instance.stateChangedNameByIndex(f));return l},enumerable:false,configurable:true}),g.prototype.advance=function(l){this.instance.advance(l);},g.prototype.advanceAndApply=function(l){this.instance.advanceAndApply(l);},g.prototype.reportedEventCount=function(){return this.instance.reportedEventCount()},g.prototype.reportedEventAt=function(l){return this.instance.reportedEventAt(l)},g.prototype.initInputs=function(l){for(var f=0;f<this.instance.inputCount();f++){var w=this.instance.input(f);this.inputs.push(this.mapRuntimeInput(w,l));}},g.prototype.mapRuntimeInput=function(l,f){if(l.type===f.SMIInput.bool)return new Q(W.Boolean,l.asBool());if(l.type===f.SMIInput.number)return new Q(W.Number,l.asNumber());if(l.type===f.SMIInput.trigger)return new Q(W.Trigger,l.asTrigger())},g.prototype.cleanup=function(){this.inputs.forEach(function(l){l.delete();}),this.inputs.length=0,this.instance.delete();},g.prototype.bindViewModelInstance=function(l){l.runtimeInstance!=null&&this.instance.bindViewModelInstance(l.runtimeInstance);},g.prototype.focusState=function(){return this.instance.focusState()},g.prototype.clearFocus=function(){this.instance.clearFocus();},g})(),de=(function(){function g(l,f,w,T,R){T===void 0&&(T=[]),R===void 0&&(R=[]),this.runtime=l,this.artboard=f,this.eventManager=w,this.animations=T,this.stateMachines=R;}return g.prototype.add=function(l,f,w){if(w===void 0&&(w=true),l=st(l),l.length===0)this.animations.forEach(function(Ge){return Ge.playing=f}),this.stateMachines.forEach(function(Ge){return Ge.playing=f});else for(var T=this.animations.map(function(Ge){return Ge.name}),R=this.stateMachines.map(function(Ge){return Ge.name}),V=0;V<l.length;V++){var re=T.indexOf(l[V]),ke=R.indexOf(l[V]);if(re>=0||ke>=0)re>=0?this.animations[re].playing=f:this.stateMachines[ke].playing=f;else {var ie=this.artboard.animationByName(l[V]);if(ie){var _e=new o.Animation(ie,this.artboard,this.runtime,f);_e.advance(0),_e.apply(1),this.animations.push(_e);}else {var nt=this.artboard.stateMachineByName(l[V]);if(nt){var Qe=new H(nt,this.runtime,f,this.artboard);this.stateMachines.push(Qe);}}}}return w&&(f?this.eventManager.fire({type:te.Play,data:this.playing}):this.eventManager.fire({type:te.Pause,data:this.paused})),f?this.playing:this.paused},g.prototype.initLinearAnimations=function(l,f,w){w===void 0&&(w=false);for(var T=this.animations.map(function(_e){return _e.name}),R=0;R<l.length;R++){var V=T.indexOf(l[R]);if(V>=0)this.animations[V].playing=f;else {var re=this.artboard.animationByName(l[R]);if(re){var ke=new o.Animation(re,this.artboard,this.runtime,f);ke.advance(0),ke.apply(1),this.animations.push(ke);}else if(w){var ie="State Machine with name ".concat(l[R]," not found");throw new m(ie)}else console.error("Animation with name ".concat(l[R]," not found."));}}},g.prototype.initStateMachines=function(l,f){for(var w=this.stateMachines.map(function(ke){return ke.name}),T=0;T<l.length;T++){var R=w.indexOf(l[T]);if(R>=0)this.stateMachines[R].playing=f;else {var V=this.artboard.stateMachineByName(l[T]);if(V){var re=new H(V,this.runtime,f,this.artboard);this.stateMachines.push(re);}else console.warn("State Machine with name ".concat(l[T]," not found. Falling back to find an animation with the same name.")),this.initLinearAnimations([l[T]],f,true);}}},g.prototype.play=function(l){return this.add(l,true)},g.prototype.advanceIfPaused=function(){this.stateMachines.forEach(function(l){l.playing||l.advanceAndApply(0);});},g.prototype.pause=function(l){return this.add(l,false)},g.prototype.scrub=function(l,f){var w=this.animations.filter(function(T){return l.includes(T.name)});return w.forEach(function(T){return T.scrubTo=f}),w.map(function(T){return T.name})},Object.defineProperty(g.prototype,"playing",{get:function(){return this.animations.filter(function(l){return l.playing}).map(function(l){return l.name}).concat(this.stateMachines.filter(function(l){return l.playing}).map(function(l){return l.name}))},enumerable:false,configurable:true}),Object.defineProperty(g.prototype,"paused",{get:function(){return this.animations.filter(function(l){return !l.playing}).map(function(l){return l.name}).concat(this.stateMachines.filter(function(l){return !l.playing}).map(function(l){return l.name}))},enumerable:false,configurable:true}),g.prototype.stop=function(l){var f=this;l=st(l);var w=[];if(l.length===0)w=this.animations.map(function(V){return V.name}).concat(this.stateMachines.map(function(V){return V.name})),this.animations.forEach(function(V){return V.cleanup()}),this.stateMachines.forEach(function(V){return V.cleanup()}),this.animations.splice(0,this.animations.length),this.stateMachines.splice(0,this.stateMachines.length);else {var T=this.animations.filter(function(V){return l.includes(V.name)});T.forEach(function(V){V.cleanup(),f.animations.splice(f.animations.indexOf(V),1);});var R=this.stateMachines.filter(function(V){return l.includes(V.name)});R.forEach(function(V){V.cleanup(),f.stateMachines.splice(f.stateMachines.indexOf(V),1);}),w=T.map(function(V){return V.name}).concat(R.map(function(V){return V.name}));}return this.eventManager.fire({type:te.Stop,data:w}),w},Object.defineProperty(g.prototype,"isPlaying",{get:function(){return this.animations.reduce(function(l,f){return l||f.playing},false)||this.stateMachines.reduce(function(l,f){return l||f.playing},false)},enumerable:false,configurable:true}),Object.defineProperty(g.prototype,"isPaused",{get:function(){return !this.isPlaying&&(this.animations.length>0||this.stateMachines.length>0)},enumerable:false,configurable:true}),Object.defineProperty(g.prototype,"isStopped",{get:function(){return this.animations.length===0&&this.stateMachines.length===0},enumerable:false,configurable:true}),g.prototype.atLeastOne=function(l,f){f===void 0&&(f=true);var w;return this.animations.length===0&&this.stateMachines.length===0&&(this.artboard.animationCount()>0?this.add([w=this.artboard.animationByIndex(0).name],l,f):this.artboard.stateMachineCount()>0&&this.add([w=this.artboard.stateMachineByIndex(0).name],l,f)),w},g.prototype.handleLooping=function(){for(var l=0,f=this.animations.filter(function(T){return T.playing});l<f.length;l++){var w=f[l];w.loopValue===0&&w.loopCount?(w.loopCount=0,this.stop(w.name)):w.loopValue===1&&w.loopCount?(this.eventManager.fire({type:te.Loop,data:{animation:w.name,type:xe.Loop}}),w.loopCount=0):w.loopValue===2&&w.loopCount>1&&(this.eventManager.fire({type:te.Loop,data:{animation:w.name,type:xe.PingPong}}),w.loopCount=0);}},g.prototype.handleStateChanges=function(){for(var l=[],f=0,w=this.stateMachines.filter(function(R){return R.playing});f<w.length;f++){var T=w[f];l.push.apply(l,T.statesChanged);}l.length>0&&this.eventManager.fire({type:te.StateChange,data:l});},g.prototype.handleAdvancing=function(l){this.eventManager.fire({type:te.Advance,data:l});},g})(),te;(function(g){g.Load="load",g.LoadError="loaderror",g.Play="play",g.Pause="pause",g.Stop="stop",g.Loop="loop",g.Draw="draw",g.Advance="advance",g.StateChange="statechange",g.RiveEvent="riveevent",g.AudioStatusChange="audiostatuschange";})(te||(te={}));var xe;(function(g){g.OneShot="oneshot",g.Loop="loop",g.PingPong="pingpong";})(xe||(xe={}));var Se=(function(){function g(l){l===void 0&&(l=[]),this.listeners=l;}return g.prototype.getListeners=function(l){return this.listeners.filter(function(f){return f.type===l})},g.prototype.add=function(l){this.listeners.includes(l)||this.listeners.push(l);},g.prototype.remove=function(l){for(var f=0;f<this.listeners.length;f++){var w=this.listeners[f];if(w.type===l.type&&w.callback===l.callback){this.listeners.splice(f,1);break}}},g.prototype.removeAll=function(l){var f=this;l?this.listeners.filter(function(w){return w.type===l}).forEach(function(w){return f.remove(w)}):this.listeners.splice(0,this.listeners.length);},g.prototype.fire=function(l){var f=this.getListeners(l.type);f.forEach(function(w){return w.callback(l)});},g})(),ue=(function(){function g(l){this.eventManager=l,this.queue=[];}return g.prototype.add=function(l){this.queue.push(l);},g.prototype.process=function(){for(;this.queue.length>0;){var l=this.queue.shift();l?.action&&l.action(),l?.event&&this.eventManager.fire(l.event);}},g})(),Ie;(function(g){g[g.AVAILABLE=0]="AVAILABLE",g[g.UNAVAILABLE=1]="UNAVAILABLE";})(Ie||(Ie={}));var ae=(function(g){p(l,g);function l(){var f=g!==null&&g.apply(this,arguments)||this;return f._started=false,f._enabled=false,f._status=Ie.UNAVAILABLE,f}return l.prototype.delay=function(f){return A(this,void 0,void 0,function(){return y(this,function(w){return [2,new Promise(function(T){return setTimeout(T,f)})]})})},l.prototype.timeout=function(){return A(this,void 0,void 0,function(){return y(this,function(f){return [2,new Promise(function(w,T){return setTimeout(T,50)})]})})},l.prototype.reportToListeners=function(){this.fire({type:te.AudioStatusChange}),this.removeAll();},l.prototype.enableAudio=function(){return A(this,void 0,void 0,function(){return y(this,function(f){return this._enabled||(this._enabled=true,this._status=Ie.AVAILABLE,this.reportToListeners()),[2]})})},l.prototype.testAudio=function(){return A(this,void 0,void 0,function(){return y(this,function(w){switch(w.label){case 0:if(!(this._status===Ie.UNAVAILABLE&&this._audioContext!==null))return [3,4];w.label=1;case 1:return w.trys.push([1,3,,4]),[4,Promise.race([this._audioContext.resume(),this.timeout()])];case 2:return w.sent(),this.enableAudio(),[3,4];case 3:return w.sent(),[3,4];case 4:return [2]}})})},l.prototype._establishAudio=function(){return A(this,void 0,void 0,function(){return y(this,function(f){switch(f.label){case 0:return this._started?[3,5]:(this._started=true,typeof window>"u"?(this.enableAudio(),[3,5]):[3,1]);case 1:this._audioContext=new AudioContext,this.listenForUserAction(),f.label=2;case 2:return this._status!==Ie.UNAVAILABLE?[3,5]:[4,this.testAudio()];case 3:return f.sent(),[4,this.delay(1e3)];case 4:return f.sent(),[3,2];case 5:return [2]}})})},l.prototype.listenForUserAction=function(){var f=this,w=function(){return A(f,void 0,void 0,function(){return y(this,function(T){return this.enableAudio(),[2]})})};document.addEventListener("pointerdown",w,{once:true});},l.prototype.establishAudio=function(){return A(this,void 0,void 0,function(){return y(this,function(f){return this._establishAudio(),[2]})})},Object.defineProperty(l.prototype,"systemVolume",{get:function(){return this._status===Ie.UNAVAILABLE?(this.testAudio(),0):1},enumerable:false,configurable:true}),Object.defineProperty(l.prototype,"status",{get:function(){return this._status},enumerable:false,configurable:true}),l})(Se),G=new ae,z=(function(){function g(){}return g.prototype.observe=function(){},g.prototype.unobserve=function(){},g.prototype.disconnect=function(){},g})(),P=globalThis.ResizeObserver||z,N=(function(){function g(){var l=this;this._elementsMap=new Map,this._onObservedEntry=function(f){var w=l._elementsMap.get(f.target);w!==null?w.onResize(f.target.clientWidth==0||f.target.clientHeight==0):l._resizeObserver.unobserve(f.target);},this._onObserved=function(f){f.forEach(l._onObservedEntry);},this._resizeObserver=new P(this._onObserved);}return g.prototype.add=function(l,f){var w={onResize:f,element:l};return this._elementsMap.set(l,w),this._resizeObserver.observe(l),w},g.prototype.remove=function(l){this._resizeObserver.unobserve(l.element),this._elementsMap.delete(l.element);},g})(),U=new N,q=(function(){function g(l){this.enableRiveAssetCDN=true,this.enablePerfMarks=false,this.referenceCount=0,this.destroyed=false,this.selfUnref=false,this.bindableArtboards=[],this.src=l.src,this.buffer=l.buffer,l.assetLoader&&(this.assetLoader=l.assetLoader),this.enableRiveAssetCDN=typeof l.enableRiveAssetCDN=="boolean"?l.enableRiveAssetCDN:true,this.enablePerfMarks=!!l.enablePerfMarks,this.enablePerfMarks&&(s.RuntimeLoader.enablePerfMarks=true),this.eventManager=new Se,l.onLoad&&this.on(te.Load,l.onLoad),l.onLoadError&&this.on(te.LoadError,l.onLoadError);}return g.prototype.releaseFile=function(){var l;this.selfUnref&&((l=this.file)===null||l===void 0||l.unref()),this.file=null;},g.prototype.releaseBindableArtboards=function(){this.bindableArtboards.forEach(function(l){return l.destroy()});},g.prototype.initData=function(){return A(this,void 0,void 0,function(){var l,f,w,T,R,V;return y(this,function(re){switch(re.label){case 0:if(!(this.src&&!this.buffer))return [3,4];re.label=1;case 1:return re.trys.push([1,3,,4]),l=this,[4,rt(this.src)];case 2:return l.buffer=re.sent(),[3,4];case 3:throw f=re.sent(),f instanceof Error?f:new m(g.fileLoadErrorMessage);case 4:return this.destroyed?[2]:(this.assetLoader&&(T=new u.CustomFileAssetLoaderWrapper(this.runtime,this.assetLoader),w=T.assetLoader),this.enablePerfMarks&&performance.mark("rive:file-load:start"),R=this,[4,this.runtime.load(new Uint8Array(this.buffer),w,this.enableRiveAssetCDN)]);case 5:return R.file=re.sent(),this.enablePerfMarks&&(performance.mark("rive:file-load:end"),performance.measure("rive:file-load","rive:file-load:start","rive:file-load:end")),V=new u.FileFinalizer(this.file),u.finalizationRegistry.register(this,V),this.destroyed?(this.releaseFile(),[2]):(this.file!==null?this.eventManager.fire({type:te.Load,data:this}):this.fireLoadError(g.fileLoadErrorMessage),[2])}})})},g.prototype.loadRiveFileBytes=function(){return A(this,void 0,void 0,function(){var l;return y(this,function(f){return this.enablePerfMarks&&performance.mark("rive:fetch-riv:start"),l=this.src?rt(this.src):Promise.resolve(this.buffer),this.enablePerfMarks&&this.src&&l.then(function(){performance.mark("rive:fetch-riv:end"),performance.measure("rive:fetch-riv","rive:fetch-riv:start","rive:fetch-riv:end");}),[2,l]})})},g.prototype.loadRuntime=function(){return A(this,void 0,void 0,function(){var l;return y(this,function(f){return this.enablePerfMarks&&performance.mark("rive:await-wasm:start"),l=s.RuntimeLoader.awaitInstance(),this.enablePerfMarks&&l.then(function(){performance.mark("rive:await-wasm:end"),performance.measure("rive:await-wasm","rive:await-wasm:start","rive:await-wasm:end");}),[2,l]})})},g.prototype.init=function(){return A(this,void 0,void 0,function(){var l,f,w,T;return y(this,function(R){switch(R.label){case 0:if(!this.src&&!this.buffer)return this.fireLoadError(g.missingErrorMessage),[2];R.label=1;case 1:return R.trys.push([1,4,,5]),[4,Promise.all([this.loadRiveFileBytes(),this.loadRuntime()])];case 2:return l=R.sent(),f=l[0],w=l[1],this.destroyed?[2]:(this.buffer=f,this.runtime=w,this.enablePerfMarks&&performance.mark("rive:init-data:start"),[4,this.initData()]);case 3:return R.sent(),this.enablePerfMarks&&(performance.mark("rive:init-data:end"),performance.measure("rive:init-data","rive:init-data:start","rive:init-data:end")),[3,5];case 4:return T=R.sent(),this.fireLoadError(T instanceof Error?T.message:g.fileLoadErrorMessage),[3,5];case 5:return [2]}})})},g.prototype.fireLoadError=function(l){throw this.eventManager.fire({type:te.LoadError,data:l}),new m(l)},g.prototype.on=function(l,f){this.eventManager.add({type:l,callback:f});},g.prototype.off=function(l,f){this.eventManager.remove({type:l,callback:f});},g.prototype.cleanup=function(){this.referenceCount-=1,this.referenceCount<=0&&(this.removeAllRiveEventListeners(),this.releaseFile(),this.releaseBindableArtboards(),this.destroyed=true);},g.prototype.removeAllRiveEventListeners=function(l){this.eventManager.removeAll(l);},g.prototype.getInstance=function(){if(this.file!==null)return this.referenceCount+=1,this.file},g.prototype.destroyIfUnused=function(){this.referenceCount<=0&&this.cleanup();},g.prototype.createBindableArtboard=function(l){if(l!=null){var f=new J(l);return (0, u.createFinalization)(f,f.nativeArtboard),this.bindableArtboards.push(f),f}return null},g.prototype.getArtboard=function(l){var f=this.file.artboardByName(l);if(f!=null)return new oe(f,this)},g.prototype.getBindableArtboard=function(l){var f=this.file.bindableArtboardByName(l);return this.createBindableArtboard(f)},g.prototype.getDefaultBindableArtboard=function(){var l=this.file.bindableArtboardDefault();return this.createBindableArtboard(l)},g.prototype.internalBindableArtboardFromArtboard=function(l){var f=this.file.internalBindableArtboardFromArtboard(l);return this.createBindableArtboard(f)},g.prototype.viewModelByName=function(l){var f=this.file.viewModelByName(l);return f!==null?new Pe(f):null},g.missingErrorMessage="Rive source file or data buffer required",g.fileLoadErrorMessage="The file failed to load",g})(),se=(function(){function g(l){var f=this,w,T,R;this.loaded=false,this.destroyed=false,this._observed=null,this.readyForPlaying=false,this.artboard=null,this.eventCleanup=null,this._keyboardInteractions=null,this.shouldDisableRiveListeners=false,this.automaticallyHandleEvents=false,this.dispatchPointerExit=true,this.enableMultiTouch=false,this.enableRiveAssetCDN=true,this._volume=1,this._artboardWidth=void 0,this._artboardHeight=void 0,this._devicePixelRatioUsed=1,this._hasZeroSize=false,this._needsRedraw=false,this._currentCanvasWidth=0,this._currentCanvasHeight=0,this._audioEventListener=null,this._boundDraw=null,this._pageVisibilityHandler=null,this._explicitlyStoppedRendering=false,this._viewModelInstance=null,this._dataEnums=null,this._tabIndex=null,this._prevHasFocus=false,this._focusOptions={allowFocusInterrupt:false},this.drawOptimization=L.DrawOnChanged,this.enablePerfMarks=false,this.durations=[],this.frameTimes=[],this.frameCount=0,this.isTouchScrollEnabled=false,this.onCanvasResize=function(V){var re=f._hasZeroSize!==V;f._hasZeroSize=V,V?(!f._layout.maxX||!f._layout.maxY)&&f.resizeToCanvas():re&&f.resizeDrawingSurfaceToCanvas();},this.frameRequestId=null,this.renderSecondTimer=0,this._boundDraw=this.draw.bind(this),typeof document<"u"&&(this._pageVisibilityHandler=this._onPageVisibilityChange.bind(this),document.addEventListener("visibilitychange",this._pageVisibilityHandler)),this.canvas=l.canvas,l.canvas.constructor===HTMLCanvasElement&&(this._observed=U.add(this.canvas,this.onCanvasResize)),this._currentCanvasWidth=this.canvas.width,this._currentCanvasHeight=this.canvas.height,this.src=l.src,this.buffer=l.buffer,this.riveFile=l.riveFile,this.layout=(w=l.layout)!==null&&w!==void 0?w:new B,this.shouldDisableRiveListeners=!!l.shouldDisableRiveListeners,this.isTouchScrollEnabled=!!l.isTouchScrollEnabled,this.automaticallyHandleEvents=!!l.automaticallyHandleEvents,this.dispatchPointerExit=l.dispatchPointerExit===false?l.dispatchPointerExit:this.dispatchPointerExit,this.enableMultiTouch=!!l.enableMultiTouch,this.drawOptimization=(T=l.drawingOptions)!==null&&T!==void 0?T:this.drawOptimization,this.enableRiveAssetCDN=l.enableRiveAssetCDN===void 0?true:l.enableRiveAssetCDN,this.enablePerfMarks=!!l.enablePerfMarks,this.enablePerfMarks&&(s.RuntimeLoader.enablePerfMarks=true),this._focusOptions=(R=l.focusOptions)!==null&&R!==void 0?R:this._focusOptions,this.eventManager=new Se,l.onLoad&&this.on(te.Load,l.onLoad),l.onLoadError&&this.on(te.LoadError,l.onLoadError),l.onPlay&&this.on(te.Play,l.onPlay),l.onPause&&this.on(te.Pause,l.onPause),l.onStop&&this.on(te.Stop,l.onStop),l.onLoop&&this.on(te.Loop,l.onLoop),l.onStateChange&&this.on(te.StateChange,l.onStateChange),l.onAdvance&&this.on(te.Advance,l.onAdvance),l.onload&&!l.onLoad&&this.on(te.Load,l.onload),l.onloaderror&&!l.onLoadError&&this.on(te.LoadError,l.onloaderror),l.onplay&&!l.onPlay&&this.on(te.Play,l.onplay),l.onpause&&!l.onPause&&this.on(te.Pause,l.onpause),l.onstop&&!l.onStop&&this.on(te.Stop,l.onstop),l.onloop&&!l.onLoop&&this.on(te.Loop,l.onloop),l.onstatechange&&!l.onStateChange&&this.on(te.StateChange,l.onstatechange),l.assetLoader&&(this.assetLoader=l.assetLoader),this.taskQueue=new ue(this.eventManager),this.init({src:this.src,buffer:this.buffer,riveFile:this.riveFile,autoplay:l.autoplay,autoBind:l.autoBind,animations:l.animations,stateMachines:l.stateMachines,artboard:l.artboard,useOffscreenRenderer:l.useOffscreenRenderer,tabIndex:l.tabIndex});}return Object.defineProperty(g.prototype,"viewModelCount",{get:function(){return this.file.viewModelCount()},enumerable:false,configurable:true}),g.new=function(l){return console.warn("This function is deprecated: please use `new Rive({})` instead"),new g(l)},g.prototype.onSystemAudioChanged=function(){this.volume=this._volume;},g.prototype.init=function(l){var f=this,w=l.src,T=l.buffer,R=l.riveFile,V=l.animations,re=l.stateMachines,ke=l.artboard,ie=l.autoplay,_e=ie===void 0?false:ie,nt=l.useOffscreenRenderer,Qe=nt===void 0?false:nt,Ge=l.autoBind,gt=Ge===void 0?false:Ge,Tt=l.tabIndex;if(!this.destroyed){if(this.src=w,this.buffer=T,this.riveFile=R,this._tabIndex=Tt??null,!this.src&&!this.buffer&&!this.riveFile)throw new m(g.missingErrorMessage);var Ye=st(V),kt=st(re);this.loaded=false,this.readyForPlaying=false,s.RuntimeLoader.awaitInstance().then(function(vt){if(!f.destroyed){f.runtime=vt,f.removeRiveListeners(),f.deleteRiveRenderer(),f.enablePerfMarks&&performance.mark("rive:make-renderer:start");try{if(f.renderer=f.runtime.makeRenderer(f.canvas,Qe),!f.renderer)throw new Error("Renderer is null, cannot render Rive on the canvas.")}catch(At){throw console.error(At),new m("Unable to create the renderer, your environment may not support WebGL. Try the @rive-app/canvas runtime as an alternative.")}f.enablePerfMarks&&(performance.mark("rive:make-renderer:end"),performance.measure("rive:make-renderer","rive:make-renderer:start","rive:make-renderer:end")),f.canvas.width||f.canvas.height||f.resizeDrawingSurfaceToCanvas(),f.initData(ke,Ye,kt,_e,gt).then(function(At){if(At)return f.setupRiveListeners()}).catch(function(At){console.error(At);});}}).catch(function(vt){f.eventManager.fire({type:te.LoadError,data:vt.message});});}},g.prototype.setupRiveListeners=function(l){var f=this;if(this.eventCleanup&&this.eventCleanup(),this.cleanupKeyboardInteractions(),!this.shouldDisableRiveListeners){var w=this.animator.stateMachines.filter(function(_e){return _e.playing}),T=w.filter(function(_e){return f.runtime.hasListeners(_e.instance)}).map(function(_e){return _e.instance}),R=this.isTouchScrollEnabled,V=this.dispatchPointerExit,re=this.enableMultiTouch;l&&"isTouchScrollEnabled"in l&&(R=l.isTouchScrollEnabled),this.eventCleanup=(0, u.registerTouchInteractions)({canvas:this.canvas,artboard:this.artboard,stateMachines:T,renderer:this.renderer,rive:this.runtime,fit:this._layout.runtimeFit(this.runtime),alignment:this._layout.runtimeAlignment(this.runtime),isTouchScrollEnabled:R,dispatchPointerExit:V,enableMultiTouch:re,layoutScaleFactor:this._layout.layoutScaleFactor,advanceAndDrain:this.advanceAndReportChanges.bind(this)});var ke=w.filter(function(_e){return _e.hasFocusNodes});if(ke.length){var ie=this.canvas.tabIndex;(ie===-1||isNaN(ie))&&(this.canvas.tabIndex=this._tabIndex!==null?this._tabIndex:0),typeof window<"u"&&(this._keyboardInteractions=new u.KeyboardInteractions({canvas:this.canvas,stateMachine:ke[0].instance,hasFocusNodes:true}));}}},g.prototype.cleanupKeyboardInteractions=function(){this._keyboardInteractions&&(this._keyboardInteractions.cleanup(),this._keyboardInteractions=null);},g.prototype.removeRiveListeners=function(){this.eventCleanup&&(this.eventCleanup(),this.eventCleanup=null),this.cleanupKeyboardInteractions();},g.prototype.initializeAudio=function(){var l=this,f;G.status==Ie.UNAVAILABLE&&(this.file.hasAudio||!((f=this.artboard)===null||f===void 0)&&f.hasAudio&&this._audioEventListener===null)&&(this._audioEventListener={type:te.AudioStatusChange,callback:function(){return l.onSystemAudioChanged()}},G.add(this._audioEventListener),G.establishAudio());},g.prototype.initArtboardSize=function(){this.artboard&&(this._artboardWidth=this.artboard.width=this._artboardWidth||this.artboard.width,this._artboardHeight=this.artboard.height=this._artboardHeight||this.artboard.height);},g.prototype.initData=function(l,f,w,T,R){return A(this,void 0,void 0,function(){var V,re,ke,ie;return y(this,function(_e){switch(_e.label){case 0:return _e.trys.push([0,3,,4]),this.riveFile!=null?[3,2]:(V=new q({src:this.src,buffer:this.buffer,enableRiveAssetCDN:this.enableRiveAssetCDN,assetLoader:this.assetLoader,enablePerfMarks:this.enablePerfMarks}),this.riveFile=V,[4,V.init()]);case 1:if(_e.sent(),this.destroyed)return V.destroyIfUnused(),[2,false];_e.label=2;case 2:this.file=this.riveFile.getInstance(),this.initArtboard(l,f,w,T,R),this.initArtboardSize(),this.initializeAudio();try{this.loaded=!0,this.eventManager.fire({type:te.Load,data:(ie=this.src)!==null&&ie!==void 0?ie:"buffer"});}catch(nt){console.error(nt);}return this.animator.advanceIfPaused(),this.readyForPlaying=true,this.taskQueue.process(),this.drawFrame(),[2,true];case 3:return re=_e.sent(),ke=S(re),this.eventManager.fire({type:te.LoadError,data:ke}),[2,Promise.reject(ke)];case 4:return [2]}})})},g.prototype.initArtboard=function(l,f,w,T,R){if(this.file){var V=l?this.file.artboardByName(l):this.file.defaultArtboard();if(!V)throw new m("Invalid artboard name or no default artboard");this.artboard=V,V.volume=this._volume*G.systemVolume,this.animator=new de(this.runtime,this.artboard,this.eventManager);var re;if(f.length>0||w.length>0?(re=f.concat(w),this.animator.initLinearAnimations(f,T),this.animator.initStateMachines(w,T)):re=[this.animator.atLeastOne(T,false)],this.taskQueue.add({event:{type:T?te.Play:te.Pause,data:re}}),R){var ke=this.file.defaultArtboardViewModel(V);if(ke!==null){var ie=ke.defaultInstance();if(ie!==null){var _e=new De(ie,null);(0, u.createFinalization)(_e,_e.runtimeInstance),this.bindViewModelInstance(_e);}}}}},g.prototype.drawFrame=function(){var l,f;!((l=document?.timeline)===null||l===void 0)&&l.currentTime?this.loaded&&this.artboard&&!this.frameRequestId&&(this._boundDraw(document.timeline.currentTime),(f=this.runtime)===null||f===void 0||f.resolveAnimationFrame()):this.scheduleRendering();},g.prototype._canvasSizeChanged=function(){var l=false;return this.canvas&&(this.canvas.width!==this._currentCanvasWidth&&(this._currentCanvasWidth=this.canvas.width,l=true),this.canvas.height!==this._currentCanvasHeight&&(this._currentCanvasHeight=this.canvas.height,l=true)),l},g.prototype.pollFocusState=function(){if(!this._keyboardInteractions){this._prevHasFocus=false;return}var l=this.animator.stateMachines.find(function(w){return w.playing&&w.hasFocusNodes});if(!l){this._prevHasFocus=false;return}if(this.canvas instanceof HTMLCanvasElement){var f=l.focusState().hasFocus;if(f){this._keyboardInteractions.notifyRiveFocused(),this._prevHasFocus||(this.canvas!==document.activeElement&&this._focusOptions.allowFocusInterrupt&&this.canvas.focus(),this._prevHasFocus=true);return}this._prevHasFocus=false,this._keyboardInteractions.focusSessionState===u.FocusSessionState.RiveFocused&&this._keyboardInteractions.setFocusSessionState(u.FocusSessionState.NotFocused);}},g.prototype.advanceAndReportChanges=function(l){for(var f,w=this.animator.animations.filter(function(Me){return Me.playing||Me.needsScrub}).sort(function(Me){return Me.needsScrub?-1:1}),T=0,R=w;T<R.length;T++){var V=R[T];V.advance(l),V.instance.didLoop&&(V.loopCount+=1),V.apply(1);}for(var re=this.animator.stateMachines.filter(function(Me){return Me.playing}),ke=this.enablePerfMarks&&this.frameCount<3?this.frameCount:-1,ie=0,_e=re;ie<_e.length;ie++){var nt=_e[ie],Qe=nt.reportedEventCount();if(Qe)for(var Ge=0;Ge<Qe;Ge++){var gt=nt.reportedEventAt(Ge);if(gt)if(gt.type===Z.OpenUrl){if(this.eventManager.fire({type:te.RiveEvent,data:gt}),this.automaticallyHandleEvents){var Tt=document.createElement("a"),Ye=gt,kt=Ye.url,vt=Ye.target,At=(0, u.sanitizeUrl)(kt);kt&&Tt.setAttribute("href",At),vt&&Tt.setAttribute("target",vt),At&&At!==u.BLANK_URL&&Tt.click();}}else this.eventManager.fire({type:te.RiveEvent,data:gt});}ke>=0&&performance.mark("rive:sm-advance:start:f".concat(ke)),nt.advanceAndApply(l),ke>=0&&(performance.mark("rive:sm-advance:end:f".concat(ke)),performance.measure("rive:sm-advance:f".concat(ke),"rive:sm-advance:start:f".concat(ke),"rive:sm-advance:end:f".concat(ke)));}this.animator.stateMachines.length==0&&this.artboard.advance(l),this.animator.handleLooping(),this.animator.handleStateChanges(),this.animator.handleAdvancing(l),this.pollFocusState(),(f=this._viewModelInstance)===null||f===void 0||f.handleCallbacks();},g.prototype.draw=function(l,f){this.frameRequestId=null;var w=performance.now(),T=this.enablePerfMarks&&this.frameCount<3?this.frameCount:-1;this.lastRenderTime||(this.lastRenderTime=l),this.renderSecondTimer+=l-this.lastRenderTime,this.renderSecondTimer>5e3&&(this.renderSecondTimer=0,f?.());var R=(l-this.lastRenderTime)/1e3;this.lastRenderTime=l,this.advanceAndReportChanges(R);var V=this.renderer;this._hasZeroSize||(this.drawOptimization==L.AlwaysDraw||this.artboard.didChange()||this._needsRedraw||this._canvasSizeChanged())&&(V.clear(),V.save(),T>=0&&performance.mark("rive:align-renderer:start:f".concat(T)),this.alignRenderer(),T>=0&&(performance.mark("rive:align-renderer:end:f".concat(T)),performance.measure("rive:align-renderer:f".concat(T),"rive:align-renderer:start:f".concat(T),"rive:align-renderer:end:f".concat(T))),T>=0&&performance.mark("rive:artboard-draw:start:f".concat(T)),this.artboard.draw(V),T>=0&&(performance.mark("rive:artboard-draw:end:f".concat(T)),performance.measure("rive:artboard-draw:f".concat(T),"rive:artboard-draw:start:f".concat(T),"rive:artboard-draw:end:f".concat(T))),V.restore(),T>=0&&performance.mark("rive:renderer-flush:start:f".concat(T)),V.flush(),T>=0&&(performance.mark("rive:renderer-flush:end:f".concat(T)),performance.measure("rive:renderer-flush:f".concat(T),"rive:renderer-flush:start:f".concat(T),"rive:renderer-flush:end:f".concat(T))),this._needsRedraw=false),this.frameCount++;var re=performance.now();for(this.frameTimes.push(re),this.durations.push(re-w);this.frameTimes[0]<=re-1e3;)this.frameTimes.shift(),this.durations.shift();this.animator.isPlaying?this.scheduleRendering():this.animator.isPaused?this.lastRenderTime=0:this.animator.isStopped&&(this.lastRenderTime=0);},g.prototype.alignRenderer=function(){var l=this,f=l.renderer,w=l.runtime,T=l._layout,R=l.artboard;f.align(T.runtimeFit(w),T.runtimeAlignment(w),{minX:T.minX,minY:T.minY,maxX:T.maxX,maxY:T.maxY},R.bounds,this._devicePixelRatioUsed*T.layoutScaleFactor);},Object.defineProperty(g.prototype,"fps",{get:function(){return this.durations.length},enumerable:false,configurable:true}),Object.defineProperty(g.prototype,"frameTime",{get:function(){return this.durations.length===0?0:(this.durations.reduce(function(l,f){return l+f},0)/this.durations.length).toFixed(4)},enumerable:false,configurable:true}),g.prototype.cleanup=function(){var l,f;this.destroyed=true,this.stopRendering(),this.cleanupInstances(),this._observed!==null&&U.remove(this._observed),this.removeRiveListeners(),this.file&&((l=this.riveFile)===null||l===void 0||l.cleanup(),this.file=null),this.riveFile=null,this.deleteRiveRenderer(),this._audioEventListener!==null&&(G.remove(this._audioEventListener),this._audioEventListener=null),this._pageVisibilityHandler&&(document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this._pageVisibilityHandler=null),(f=this._viewModelInstance)===null||f===void 0||f.cleanup(),this._viewModelInstance=null,this._dataEnums=null;},g.prototype.deleteRiveRenderer=function(){var l;(l=this.renderer)===null||l===void 0||l.delete(),this.renderer=null;},g.prototype.cleanupInstances=function(){this.eventCleanup!==null&&this.eventCleanup(),this.cleanupKeyboardInteractions(),this.stop(),this.artboard&&(this.artboard.delete(),this.artboard=null);},g.prototype.retrieveTextRun=function(l){var f;if(!l){console.warn("No text run name provided");return}if(!this.artboard){console.warn("Tried to access text run, but the Artboard is null");return}var w=this.artboard.textRun(l);if(!w){console.warn("Could not access a text run with name '".concat(l,"' in the '").concat((f=this.artboard)===null||f===void 0?void 0:f.name,"' Artboard. Note that you must rename a text run node in the Rive editor to make it queryable at runtime."));return}return w},g.prototype.getTextRunValue=function(l){var f=this.retrieveTextRun(l);return f?f.text:void 0},g.prototype.setTextRunValue=function(l,f){var w=this.retrieveTextRun(l);w&&(w.text=f);},g.prototype.play=function(l,f){var w=this;if(l=st(l),!this.readyForPlaying){this.taskQueue.add({action:function(){return w.play(l,f)}});return}this.animator.play(l),this.eventCleanup&&this.eventCleanup(),this.cleanupKeyboardInteractions(),this.setupRiveListeners(),this.startRendering();},g.prototype.pause=function(l){var f=this;if(l=st(l),!this.readyForPlaying){this.taskQueue.add({action:function(){return f.pause(l)}});return}this.eventCleanup&&this.eventCleanup(),this.cleanupKeyboardInteractions(),this.animator.pause(l);},g.prototype.scrub=function(l,f){var w=this;if(l=st(l),!this.readyForPlaying){this.taskQueue.add({action:function(){return w.scrub(l,f)}});return}this.animator.scrub(l,f||0),this.drawFrame();},g.prototype.stop=function(l){var f=this;if(l=st(l),!this.readyForPlaying){this.taskQueue.add({action:function(){return f.stop(l)}});return}this.animator&&this.animator.stop(l),this.eventCleanup&&this.eventCleanup(),this.cleanupKeyboardInteractions();},g.prototype.reset=function(l){var f,w,T=l?.artboard,R=st(l?.animations),V=st(l?.stateMachines),re=(f=l?.autoplay)!==null&&f!==void 0?f:false,ke=(w=l?.autoBind)!==null&&w!==void 0?w:false;this.cleanupInstances(),this.initArtboard(T,R,V,re,ke),this.taskQueue.process();},g.prototype.load=function(l){this.file=null,this.stop(),this.init(l);},Object.defineProperty(g.prototype,"layout",{get:function(){return this._layout},set:function(l){this._layout=l,(!l.maxX||!l.maxY)&&this.resizeToCanvas(),this.loaded&&!this.animator.isPlaying&&this.drawFrame();},enumerable:false,configurable:true}),g.prototype.resizeToCanvas=function(){this._layout=this.layout.copyWith({minX:0,minY:0,maxX:this.canvas.width,maxY:this.canvas.height});},g.prototype.resizeDrawingSurfaceToCanvas=function(l){if(this.canvas instanceof HTMLCanvasElement&&window){var f=this.canvas.getBoundingClientRect(),w=f.width,T=f.height,R=l||window.devicePixelRatio||1;if(this.devicePixelRatioUsed=R,this.canvas.width=R*w,this.canvas.height=R*T,this._needsRedraw=true,this.resizeToCanvas(),this.drawFrame(),this.layout.fit===C.Layout){var V=this._layout.layoutScaleFactor;this.artboard.width=w/V,this.artboard.height=T/V;}}},Object.defineProperty(g.prototype,"source",{get:function(){return this.src},enumerable:false,configurable:true}),Object.defineProperty(g.prototype,"activeArtboard",{get:function(){return this.artboard?this.artboard.name:""},enumerable:false,configurable:true}),Object.defineProperty(g.prototype,"animationNames",{get:function(){if(!this.loaded||!this.artboard)return [];for(var l=[],f=0;f<this.artboard.animationCount();f++)l.push(this.artboard.animationByIndex(f).name);return l},enumerable:false,configurable:true}),Object.defineProperty(g.prototype,"stateMachineNames",{get:function(){if(!this.loaded||!this.artboard)return [];for(var l=[],f=0;f<this.artboard.stateMachineCount();f++)l.push(this.artboard.stateMachineByIndex(f).name);return l},enumerable:false,configurable:true}),g.prototype.stateMachineInputs=function(l){if(this.loaded){var f=this.animator.stateMachines.find(function(w){return w.name===l});return f?.inputs}},g.prototype.retrieveInputAtPath=function(l,f){if(!l){console.warn("No input name provided for path '".concat(f,"'"));return}if(!this.artboard){console.warn("Tried to access input: '".concat(l,"', at path: '").concat(f,"', but the Artboard is null"));return}var w=this.artboard.inputByPath(l,f);if(!w){console.warn("Could not access an input with name: '".concat(l,"', at path:'").concat(f,"'"));return}return w},g.prototype.setBooleanStateAtPath=function(l,f,w){var T=this.retrieveInputAtPath(l,w);T&&(T.type===W.Boolean?T.asBool().value=f:console.warn("Input with name: '".concat(l,"', at path:'").concat(w,"' is not a boolean")));},g.prototype.setNumberStateAtPath=function(l,f,w){var T=this.retrieveInputAtPath(l,w);T&&(T.type===W.Number?T.asNumber().value=f:console.warn("Input with name: '".concat(l,"', at path:'").concat(w,"' is not a number")));},g.prototype.fireStateAtPath=function(l,f){var w=this.retrieveInputAtPath(l,f);w&&(w.type===W.Trigger?w.asTrigger().fire():console.warn("Input with name: '".concat(l,"', at path:'").concat(f,"' is not a trigger")));},g.prototype.retrieveTextAtPath=function(l,f){if(!l){console.warn("No text name provided for path '".concat(f,"'"));return}if(!f){console.warn("No path provided for text '".concat(l,"'"));return}if(!this.artboard){console.warn("Tried to access text: '".concat(l,"', at path: '").concat(f,"', but the Artboard is null"));return}var w=this.artboard.textByPath(l,f);if(!w){console.warn("Could not access text with name: '".concat(l,"', at path:'").concat(f,"'"));return}return w},g.prototype.getTextRunValueAtPath=function(l,f){var w=this.retrieveTextAtPath(l,f);if(!w){console.warn("Could not get text with name: '".concat(l,"', at path:'").concat(f,"'"));return}return w.text},g.prototype.setTextRunValueAtPath=function(l,f,w){var T=this.retrieveTextAtPath(l,w);if(!T){console.warn("Could not set text with name: '".concat(l,"', at path:'").concat(w,"'"));return}T.text=f;},Object.defineProperty(g.prototype,"playingStateMachineNames",{get:function(){return this.loaded?this.animator.stateMachines.filter(function(l){return l.playing}).map(function(l){return l.name}):[]},enumerable:false,configurable:true}),Object.defineProperty(g.prototype,"playingAnimationNames",{get:function(){return this.loaded?this.animator.animations.filter(function(l){return l.playing}).map(function(l){return l.name}):[]},enumerable:false,configurable:true}),Object.defineProperty(g.prototype,"pausedAnimationNames",{get:function(){return this.loaded?this.animator.animations.filter(function(l){return !l.playing}).map(function(l){return l.name}):[]},enumerable:false,configurable:true}),Object.defineProperty(g.prototype,"pausedStateMachineNames",{get:function(){return this.loaded?this.animator.stateMachines.filter(function(l){return !l.playing}).map(function(l){return l.name}):[]},enumerable:false,configurable:true}),Object.defineProperty(g.prototype,"isPlaying",{get:function(){return this.animator.isPlaying},enumerable:false,configurable:true}),Object.defineProperty(g.prototype,"isPaused",{get:function(){return this.animator.isPaused},enumerable:false,configurable:true}),Object.defineProperty(g.prototype,"isStopped",{get:function(){var l,f;return (f=(l=this.animator)===null||l===void 0?void 0:l.isStopped)!==null&&f!==void 0?f:true},enumerable:false,configurable:true}),Object.defineProperty(g.prototype,"bounds",{get:function(){return this.artboard?this.artboard.bounds:void 0},enumerable:false,configurable:true}),g.prototype.on=function(l,f){this.eventManager.add({type:l,callback:f});},g.prototype.off=function(l,f){this.eventManager.remove({type:l,callback:f});},g.prototype.unsubscribe=function(l,f){console.warn("This function is deprecated: please use `off()` instead."),this.off(l,f);},g.prototype.removeAllRiveEventListeners=function(l){this.eventManager.removeAll(l);},g.prototype.unsubscribeAll=function(l){console.warn("This function is deprecated: please use `removeAllRiveEventListeners()` instead."),this.removeAllRiveEventListeners(l);},g.prototype.stopRendering=function(){this._explicitlyStoppedRendering=true,this.loaded&&this.frameRequestId&&(this.runtime.cancelAnimationFrame?this.runtime.cancelAnimationFrame(this.frameRequestId):cancelAnimationFrame(this.frameRequestId),this.frameRequestId=null);},g.prototype.startRendering=function(){this._explicitlyStoppedRendering=false,this.drawFrame();},g.prototype.scheduleRendering=function(){this.loaded&&this.artboard&&!this.frameRequestId&&(this.runtime.requestAnimationFrame?this.frameRequestId=this.runtime.requestAnimationFrame(this._boundDraw):this.frameRequestId=requestAnimationFrame(this._boundDraw));},g.prototype._onPageVisibilityChange=function(){var l,f;document.hidden?(this.frameRequestId!==null&&(!((l=this.runtime)===null||l===void 0)&&l.cancelAnimationFrame?this.runtime.cancelAnimationFrame(this.frameRequestId):cancelAnimationFrame(this.frameRequestId),this.frameRequestId=null),this.lastRenderTime=0):!((f=this.animator)===null||f===void 0)&&f.isPlaying&&!this._explicitlyStoppedRendering&&this.scheduleRendering();},g.prototype.enableFPSCounter=function(l){this.runtime.enableFPSCounter(l);},g.prototype.disableFPSCounter=function(){this.runtime.disableFPSCounter();},Object.defineProperty(g.prototype,"contents",{get:function(){if(this.loaded){for(var l={artboards:[]},f=0;f<this.file.artboardCount();f++){for(var w=this.file.artboardByIndex(f),T={name:w.name,animations:[],stateMachines:[]},R=0;R<w.animationCount();R++){var V=w.animationByIndex(R);T.animations.push(V.name);}for(var re=0;re<w.stateMachineCount();re++){for(var ke=w.stateMachineByIndex(re),ie=ke.name,_e=new this.runtime.StateMachineInstance(ke,w),nt=[],Qe=0;Qe<_e.inputCount();Qe++){var Ge=_e.input(Qe);nt.push({name:Ge.name,type:Ge.type});}T.stateMachines.push({name:ie,inputs:nt});}l.artboards.push(T);}return l}},enumerable:false,configurable:true}),Object.defineProperty(g.prototype,"volume",{get:function(){return this.artboard&&this.artboard.volume!==this._volume&&(this._volume=this.artboard.volume),this._volume},set:function(l){this._volume=l,this.artboard&&(this.artboard.volume=l*G.systemVolume);},enumerable:false,configurable:true}),Object.defineProperty(g.prototype,"artboardWidth",{get:function(){var l;return this.artboard?this.artboard.width:(l=this._artboardWidth)!==null&&l!==void 0?l:0},set:function(l){this._artboardWidth=l,this.artboard&&(this.artboard.width=l);},enumerable:false,configurable:true}),Object.defineProperty(g.prototype,"artboardHeight",{get:function(){var l;return this.artboard?this.artboard.height:(l=this._artboardHeight)!==null&&l!==void 0?l:0},set:function(l){this._artboardHeight=l,this.artboard&&(this.artboard.height=l);},enumerable:false,configurable:true}),g.prototype.resetArtboardSize=function(){this.artboard?(this.artboard.resetArtboardSize(),this._artboardWidth=this.artboard.width,this._artboardHeight=this.artboard.height):(this._artboardWidth=void 0,this._artboardHeight=void 0);},Object.defineProperty(g.prototype,"devicePixelRatioUsed",{get:function(){return this._devicePixelRatioUsed},set:function(l){this._devicePixelRatioUsed=l;},enumerable:false,configurable:true}),g.prototype.bindViewModelInstance=function(l){var f;this.artboard&&!this.destroyed&&l&&l.runtimeInstance&&(l.internalIncrementReferenceCount(),(f=this._viewModelInstance)===null||f===void 0||f.cleanup(),this._viewModelInstance=l,this.animator.stateMachines.length>0?this.animator.stateMachines.forEach(function(w){return w.bindViewModelInstance(l)}):this.artboard.bindViewModelInstance(l.runtimeInstance));},Object.defineProperty(g.prototype,"viewModelInstance",{get:function(){return this._viewModelInstance},enumerable:false,configurable:true}),g.prototype.viewModelByIndex=function(l){var f=this.file.viewModelByIndex(l);return f!==null?new Pe(f):null},g.prototype.viewModelByName=function(l){var f;return (f=this.riveFile)===null||f===void 0?void 0:f.viewModelByName(l)},g.prototype.enums=function(){if(this._dataEnums===null){var l=this.file.enums();this._dataEnums=l.map(function(f){return new we(f)});}return this._dataEnums},g.prototype.defaultViewModel=function(){if(this.artboard){var l=this.file.defaultArtboardViewModel(this.artboard);if(l)return new Pe(l)}return null},g.prototype.getArtboard=function(l){var f,w;return (w=(f=this.riveFile)===null||f===void 0?void 0:f.getArtboard(l))!==null&&w!==void 0?w:null},g.prototype.getBindableArtboard=function(l){var f,w;return (w=(f=this.riveFile)===null||f===void 0?void 0:f.getBindableArtboard(l))!==null&&w!==void 0?w:null},g.prototype.getDefaultBindableArtboard=function(){var l,f;return (f=(l=this.riveFile)===null||l===void 0?void 0:l.getDefaultBindableArtboard())!==null&&f!==void 0?f:null},g.prototype.clearFocus=function(){var l=this.animator.stateMachines.filter(function(f){return f.playing&&f.hasFocusNodes});l.forEach(function(f){return f.clearFocus()});},g.missingErrorMessage="Rive source file or data buffer required",g.cleanupErrorMessage="Attempt to use file after calling cleanup.",g})(),Re;(function(g){g.none="none",g.string="string",g.number="number",g.boolean="boolean",g.color="color",g.list="list",g.enumType="enumType",g.trigger="trigger",g.viewModel="viewModel",g.integer="integer",g.listIndex="listIndex",g.image="image",g.artboard="artboard";})(Re||(Re={}));var Pe=(function(){function g(l){this._viewModel=l;}return Object.defineProperty(g.prototype,"instanceCount",{get:function(){return this._viewModel.instanceCount},enumerable:false,configurable:true}),Object.defineProperty(g.prototype,"name",{get:function(){return this._viewModel.name},enumerable:false,configurable:true}),g.prototype.instanceByIndex=function(l){var f=this._viewModel.instanceByIndex(l);if(f!==null){var w=new De(f,null);return (0, u.createFinalization)(w,f),w}return null},g.prototype.instanceByName=function(l){var f=this._viewModel.instanceByName(l);if(f!==null){var w=new De(f,null);return (0, u.createFinalization)(w,f),w}return null},g.prototype.defaultInstance=function(){var l=this._viewModel.defaultInstance();if(l!==null){var f=new De(l,null);return (0, u.createFinalization)(f,l),f}return null},g.prototype.instance=function(){var l=this._viewModel.instance();if(l!==null){var f=new De(l,null);return (0, u.createFinalization)(f,l),f}return null},Object.defineProperty(g.prototype,"properties",{get:function(){return this._viewModel.getProperties()},enumerable:false,configurable:true}),Object.defineProperty(g.prototype,"instanceNames",{get:function(){return this._viewModel.getInstanceNames()},enumerable:false,configurable:true}),g})(),we=(function(){function g(l){this._dataEnum=l;}return Object.defineProperty(g.prototype,"name",{get:function(){return this._dataEnum.name},enumerable:false,configurable:true}),Object.defineProperty(g.prototype,"values",{get:function(){return this._dataEnum.values},enumerable:false,configurable:true}),g})(),ve;(function(g){g.Number="number",g.String="string",g.Boolean="boolean",g.Color="color",g.Trigger="trigger",g.Enum="enum",g.List="list",g.Image="image",g.Artboard="artboard";})(ve||(ve={}));var De=(function(){function g(l,f){this._parents=[],this._children=[],this._viewModelInstances=new Map,this._propertiesWithCallbacks=[],this._referenceCount=0,this.selfUnref=false,this._runtimeInstance=l,f!==null&&this._parents.push(f);}return Object.defineProperty(g.prototype,"runtimeInstance",{get:function(){return this._runtimeInstance},enumerable:false,configurable:true}),Object.defineProperty(g.prototype,"nativeInstance",{get:function(){return this._runtimeInstance},enumerable:false,configurable:true}),g.prototype.handleCallbacks=function(){this._propertiesWithCallbacks.length!==0&&(this._propertiesWithCallbacks.forEach(function(l){l.handleCallbacks();}),this._propertiesWithCallbacks.forEach(function(l){l.clearChanges();})),this._children.forEach(function(l){return l.handleCallbacks()});},g.prototype.addParent=function(l){this._parents.includes(l)||(this._parents.push(l),(this._propertiesWithCallbacks.length>0||this._children.length>0)&&l.addToViewModelCallbacks(this));},g.prototype.removeParent=function(l){var f=this._parents.indexOf(l);if(f!==-1){var w=this._parents[f];w.removeFromViewModelCallbacks(this),this._parents.splice(f,1);}},g.prototype.addToPropertyCallbacks=function(l){var f=this;this._propertiesWithCallbacks.includes(l)||(this._propertiesWithCallbacks.push(l),this._propertiesWithCallbacks.length>0&&this._parents.forEach(function(w){w.addToViewModelCallbacks(f);}));},g.prototype.removeFromPropertyCallbacks=function(l){var f=this;this._propertiesWithCallbacks.includes(l)&&(this._propertiesWithCallbacks=this._propertiesWithCallbacks.filter(function(w){return w!==l}),this._children.length===0&&this._propertiesWithCallbacks.length===0&&this._parents.forEach(function(w){w.removeFromViewModelCallbacks(f);}));},g.prototype.addToViewModelCallbacks=function(l){var f=this;this._children.includes(l)||(this._children.push(l),this._parents.forEach(function(w){w.addToViewModelCallbacks(f);}));},g.prototype.removeFromViewModelCallbacks=function(l){var f=this;this._children.includes(l)&&(this._children=this._children.filter(function(w){return w!==l}),this._children.length===0&&this._propertiesWithCallbacks.length===0&&this._parents.forEach(function(w){w.removeFromViewModelCallbacks(f);}));},g.prototype.clearCallbacks=function(){this._propertiesWithCallbacks.forEach(function(l){l.clearCallbacks();});},g.prototype.propertyFromPath=function(l,f){var w=l.split("/");return this.propertyFromPathSegments(w,0,f)},g.prototype.viewModelFromPathSegments=function(l,f){var w=this.internalViewModelInstance(l[f]);return w!==null?f==l.length-1?w:w.viewModelFromPathSegments(l,f++):null},g.prototype.propertyFromPathSegments=function(l,f,w){var T,R,V,re,ke,ie,_e,nt,Qe,Ge,gt,Tt,Ye,kt,vt,At,Me,dn;if(f<l.length-1){var Gt=this.internalViewModelInstance(l[f]);return Gt!==null?Gt.propertyFromPathSegments(l,f+1,w):null}var x=null;switch(w){case ve.Number:if(x=(R=(T=this._runtimeInstance)===null||T===void 0?void 0:T.number(l[f]))!==null&&R!==void 0?R:null,x!==null)return new ee(x,this);break;case ve.String:if(x=(re=(V=this._runtimeInstance)===null||V===void 0?void 0:V.string(l[f]))!==null&&re!==void 0?re:null,x!==null)return new qe(x,this);break;case ve.Boolean:if(x=(ie=(ke=this._runtimeInstance)===null||ke===void 0?void 0:ke.boolean(l[f]))!==null&&ie!==void 0?ie:null,x!==null)return new fe(x,this);break;case ve.Color:if(x=(nt=(_e=this._runtimeInstance)===null||_e===void 0?void 0:_e.color(l[f]))!==null&&nt!==void 0?nt:null,x!==null)return new Ue(x,this);break;case ve.Trigger:if(x=(Ge=(Qe=this._runtimeInstance)===null||Qe===void 0?void 0:Qe.trigger(l[f]))!==null&&Ge!==void 0?Ge:null,x!==null)return new Fe(x,this);break;case ve.Enum:if(x=(Tt=(gt=this._runtimeInstance)===null||gt===void 0?void 0:gt.enum(l[f]))!==null&&Tt!==void 0?Tt:null,x!==null)return new ye(x,this);break;case ve.List:if(x=(kt=(Ye=this._runtimeInstance)===null||Ye===void 0?void 0:Ye.list(l[f]))!==null&&kt!==void 0?kt:null,x!==null)return new pe(x,this);break;case ve.Image:if(x=(At=(vt=this._runtimeInstance)===null||vt===void 0?void 0:vt.image(l[f]))!==null&&At!==void 0?At:null,x!==null)return new We(x,this);break;case ve.Artboard:if(x=(dn=(Me=this._runtimeInstance)===null||Me===void 0?void 0:Me.artboard(l[f]))!==null&&dn!==void 0?dn:null,x!==null)return new Ve(x,this);break}return null},g.prototype.internalViewModelInstance=function(l){var f;if(this._viewModelInstances.has(l))return this._viewModelInstances.get(l);var w=(f=this._runtimeInstance)===null||f===void 0?void 0:f.viewModel(l);if(w!==null){var T=new g(w,this);return (0, u.createFinalization)(T,w),T.internalIncrementReferenceCount(),this._viewModelInstances.set(l,T),T}return null},g.prototype.number=function(l){var f=this.propertyFromPath(l,ve.Number);return f},g.prototype.string=function(l){var f=this.propertyFromPath(l,ve.String);return f},g.prototype.boolean=function(l){var f=this.propertyFromPath(l,ve.Boolean);return f},g.prototype.color=function(l){var f=this.propertyFromPath(l,ve.Color);return f},g.prototype.trigger=function(l){var f=this.propertyFromPath(l,ve.Trigger);return f},g.prototype.enum=function(l){var f=this.propertyFromPath(l,ve.Enum);return f},g.prototype.list=function(l){var f=this.propertyFromPath(l,ve.List);return f},g.prototype.image=function(l){var f=this.propertyFromPath(l,ve.Image);return f},g.prototype.artboard=function(l){var f=this.propertyFromPath(l,ve.Artboard);return f},g.prototype.viewModel=function(l){var f=l.split("/"),w=f.length>1?this.viewModelFromPathSegments(f.slice(0,f.length-1),0):this;return w!=null?w.internalViewModelInstance(f[f.length-1]):null},g.prototype.internalReplaceViewModel=function(l,f){var w;if(f.runtimeInstance!==null){var T=((w=this._runtimeInstance)===null||w===void 0?void 0:w.replaceViewModel(l,f.runtimeInstance))||false;if(T){f.internalIncrementReferenceCount();var R=this.internalViewModelInstance(l);R!==null&&(R.removeParent(this),this._children.includes(R)&&(this._children=this._children.filter(function(V){return V!==R})),R.cleanup()),this._viewModelInstances.set(l,f),f.addParent(this);}return T}return false},g.prototype.replaceViewModel=function(l,f){var w,T=l.split("/"),R=T.length>1?this.viewModelFromPathSegments(T.slice(0,T.length-1),0):this;return (w=R?.internalReplaceViewModel(T[T.length-1],f))!==null&&w!==void 0?w:false},g.prototype.incrementReferenceCount=function(){var l;this._referenceCount++,(l=this._runtimeInstance)===null||l===void 0||l.incrementReferenceCount();},g.prototype.decrementReferenceCount=function(){var l;this._referenceCount--,(l=this._runtimeInstance)===null||l===void 0||l.decrementReferenceCount();},Object.defineProperty(g.prototype,"properties",{get:function(){var l;return ((l=this._runtimeInstance)===null||l===void 0?void 0:l.getProperties().map(function(f){return h({},f)}))||[]},enumerable:false,configurable:true}),Object.defineProperty(g.prototype,"viewModelName",{get:function(){var l,f;return (f=(l=this._runtimeInstance)===null||l===void 0?void 0:l.getViewModelName())!==null&&f!==void 0?f:""},enumerable:false,configurable:true}),g.prototype.internalIncrementReferenceCount=function(){this._referenceCount++;},g.prototype.cleanup=function(){var l=this,f;if(this._referenceCount--,this._referenceCount<=0){this.selfUnref&&((f=this._runtimeInstance)===null||f===void 0||f.unref()),this._runtimeInstance=null,this.clearCallbacks(),this._propertiesWithCallbacks=[],this._viewModelInstances.forEach(function(R){R.cleanup();}),this._viewModelInstances.clear();var w=b([],this._children);this._children.length=0;var T=b([],this._parents);this._parents.length=0,w.forEach(function(R){R.removeParent(l);}),T.forEach(function(R){R.removeFromViewModelCallbacks(l);});}},g})(),Xe=(function(){function g(l,f){this.callbacks=[],this._viewModelInstanceValue=l,this._parentViewModel=f;}return g.prototype.on=function(l){this.callbacks.length===0&&this._viewModelInstanceValue.clearChanges(),this.callbacks.includes(l)||(this.callbacks.push(l),this._parentViewModel.addToPropertyCallbacks(this));},g.prototype.off=function(l){l?this.callbacks=this.callbacks.filter(function(f){return f!==l}):this.callbacks.length=0,this.callbacks.length===0&&this._parentViewModel.removeFromPropertyCallbacks(this);},g.prototype.internalHandleCallback=function(l){},g.prototype.handleCallbacks=function(){var l=this;this._viewModelInstanceValue.hasChanged&&this.callbacks.forEach(function(f){l.internalHandleCallback(f);});},g.prototype.clearChanges=function(){this._viewModelInstanceValue.clearChanges();},g.prototype.clearCallbacks=function(){this.callbacks.length=0;},Object.defineProperty(g.prototype,"name",{get:function(){return this._viewModelInstanceValue.name},enumerable:false,configurable:true}),g})(),qe=(function(g){p(l,g);function l(f,w){return g.call(this,f,w)||this}return Object.defineProperty(l.prototype,"value",{get:function(){return this._viewModelInstanceValue.value},set:function(f){this._viewModelInstanceValue.value=f;},enumerable:false,configurable:true}),l.prototype.internalHandleCallback=function(f){f(this.value);},l})(Xe),ee=(function(g){p(l,g);function l(f,w){return g.call(this,f,w)||this}return Object.defineProperty(l.prototype,"value",{get:function(){return this._viewModelInstanceValue.value},set:function(f){this._viewModelInstanceValue.value=f;},enumerable:false,configurable:true}),l.prototype.internalHandleCallback=function(f){f(this.value);},l})(Xe),fe=(function(g){p(l,g);function l(f,w){return g.call(this,f,w)||this}return Object.defineProperty(l.prototype,"value",{get:function(){return this._viewModelInstanceValue.value},set:function(f){this._viewModelInstanceValue.value=f;},enumerable:false,configurable:true}),l.prototype.internalHandleCallback=function(f){f(this.value);},l})(Xe),Fe=(function(g){p(l,g);function l(f,w){return g.call(this,f,w)||this}return l.prototype.trigger=function(){return this._viewModelInstanceValue.trigger()},l.prototype.internalHandleCallback=function(f){f();},l})(Xe),ye=(function(g){p(l,g);function l(f,w){return g.call(this,f,w)||this}return Object.defineProperty(l.prototype,"value",{get:function(){return this._viewModelInstanceValue.value},set:function(f){this._viewModelInstanceValue.value=f;},enumerable:false,configurable:true}),Object.defineProperty(l.prototype,"valueIndex",{get:function(){return this._viewModelInstanceValue.valueIndex},set:function(f){this._viewModelInstanceValue.valueIndex=f;},enumerable:false,configurable:true}),Object.defineProperty(l.prototype,"values",{get:function(){return this._viewModelInstanceValue.values},enumerable:false,configurable:true}),l.prototype.internalHandleCallback=function(f){f(this.value);},l})(Xe),pe=(function(g){p(l,g);function l(f,w){return g.call(this,f,w)||this}return Object.defineProperty(l.prototype,"length",{get:function(){return this._viewModelInstanceValue.size},enumerable:false,configurable:true}),l.prototype.addInstance=function(f){f.runtimeInstance!=null&&(this._viewModelInstanceValue.addInstance(f.runtimeInstance),f.addParent(this._parentViewModel));},l.prototype.addInstanceAt=function(f,w){return f.runtimeInstance!=null&&this._viewModelInstanceValue.addInstanceAt(f.runtimeInstance,w)?(f.addParent(this._parentViewModel),true):false},l.prototype.removeInstance=function(f){f.runtimeInstance!=null&&(this._viewModelInstanceValue.removeInstance(f.runtimeInstance),f.removeParent(this._parentViewModel));},l.prototype.removeInstanceAt=function(f){this._viewModelInstanceValue.removeInstanceAt(f);},l.prototype.instanceAt=function(f){var w=this._viewModelInstanceValue.instanceAt(f);if(w!=null){var T=new De(w,this._parentViewModel);return (0, u.createFinalization)(T,w),T}return null},l.prototype.swap=function(f,w){this._viewModelInstanceValue.swap(f,w);},l.prototype.internalHandleCallback=function(f){f();},l})(Xe),Ue=(function(g){p(l,g);function l(f,w){return g.call(this,f,w)||this}return Object.defineProperty(l.prototype,"value",{get:function(){return this._viewModelInstanceValue.value},set:function(f){this._viewModelInstanceValue.value=f;},enumerable:false,configurable:true}),l.prototype.rgb=function(f,w,T){this._viewModelInstanceValue.rgb(f,w,T);},l.prototype.rgba=function(f,w,T,R){this._viewModelInstanceValue.argb(R,f,w,T);},l.prototype.argb=function(f,w,T,R){this._viewModelInstanceValue.argb(f,w,T,R);},l.prototype.alpha=function(f){this._viewModelInstanceValue.alpha(f);},l.prototype.opacity=function(f){this._viewModelInstanceValue.alpha(Math.round(Math.max(0,Math.min(1,f))*255));},l.prototype.internalHandleCallback=function(f){f(this.value);},l})(Xe),We=(function(g){p(l,g);function l(f,w){return g.call(this,f,w)||this}return Object.defineProperty(l.prototype,"value",{set:function(f){var w;this._viewModelInstanceValue.value((w=f?.nativeImage)!==null&&w!==void 0?w:null);},enumerable:false,configurable:true}),l.prototype.internalHandleCallback=function(f){f();},l})(Xe),Ve=(function(g){p(l,g);function l(f,w){return g.call(this,f,w)||this}return Object.defineProperty(l.prototype,"value",{set:function(f){var w,T,R;f.isBindableArtboard?R=f:R=f.file.internalBindableArtboardFromArtboard(f.nativeArtboard),this._viewModelInstanceValue.value((w=R?.nativeArtboard)!==null&&w!==void 0?w:null),R?.nativeViewModel&&this._viewModelInstanceValue.viewModelInstance((T=R?.nativeViewModel)!==null&&T!==void 0?T:null);},enumerable:false,configurable:true}),l.prototype.internalHandleCallback=function(f){f();},l})(Xe),rt=function(g){return A(void 0,void 0,void 0,function(){var l,f,w;return y(this,function(T){switch(T.label){case 0:return l=new Request(g),[4,fetch(l)];case 1:if(f=T.sent(),!f.ok)throw new Error("Failed to fetch the Rive file: HTTP ".concat(f.status));return [4,f.arrayBuffer()];case 2:return w=T.sent(),[2,w]}})})},st=function(g){return typeof g=="string"?[g]:g instanceof Array?g:[]},et={EventManager:Se,TaskQueueManager:ue},tt=function(g){return A(void 0,void 0,void 0,function(){var l,f,w;return y(this,function(T){switch(T.label){case 0:return l=new Promise(function(R){return s.RuntimeLoader.getInstance(function(V){V.decodeAudio(g,R);})}),[4,l];case 1:return f=T.sent(),w=new u.AudioWrapper(f),u.finalizationRegistry.register(w,f),[2,w]}})})},He=function(g){return A(void 0,void 0,void 0,function(){var l,f,w;return y(this,function(T){switch(T.label){case 0:return l=new Promise(function(R){return s.RuntimeLoader.getInstance(function(V){V.decodeImage(g,R);})}),[4,l];case 1:return f=T.sent(),w=new u.ImageWrapper(f),u.finalizationRegistry.register(w,f),[2,w]}})})},le=function(g){return A(void 0,void 0,void 0,function(){var l,f,w;return y(this,function(T){switch(T.label){case 0:return l=new Promise(function(R){return s.RuntimeLoader.getInstance(function(V){V.decodeFont(g,R);})}),[4,l];case 1:return f=T.sent(),w=new u.FontWrapper(f),u.finalizationRegistry.register(w,f),[2,w]}})})};})(),r})());});var ic=uu(xt=>{Object.defineProperty(xt,"__esModule",{value:true});var rc,ce=Em("react"),sn=eo();function O0(n){return n&&typeof n=="object"&&"default"in n?n:{default:n}}var Ya=O0(ce);function Pp(n){var e=n||Cp(),t=ce.useState(e),r=t[0],o=t[1];return ce.useEffect(function(){if("u">typeof window&&"matchMedia"in window){var s=function(){o(n||Cp());},u=window.matchMedia("screen and (resolution: "+r+"dppx)");return u.hasOwnProperty("addEventListener")?u.addEventListener("change",s):u.addListener(s),function(){u.hasOwnProperty("removeEventListener")?u.removeEventListener("change",s):u.removeListener(s);}}},[r,n]),r}function Cp(){return Math.min(Math.max(1,"u">typeof window&&typeof window.devicePixelRatio=="number"?window.devicePixelRatio:1),3)}var N0=(function(){function n(){}var e=n.prototype;return e.observe=function(){},e.unobserve=function(){},e.disconnect=function(){},n})();function D0(n,e){var t=0;return function(){for(var r=this,o=arguments.length,s=Array(o),u=0;u<o;u++)s[u]=arguments[u];clearTimeout(t),t=window.setTimeout(function(){return n.apply(r,s)},e);}}var F0=globalThis.ResizeObserver||N0,B0=globalThis.ResizeObserver!==void 0,za=B0,U0=!za;function V0(n,e){e===void 0&&(e=true);var t=ce.useState({width:0,height:0}),r=t[0],o=t[1];ce.useEffect(function(){if("u">typeof window&&e){var u=function(){o({width:window.innerWidth,height:window.innerHeight});};return U0&&(u(),window.addEventListener("resize",u)),function(){return window.removeEventListener("resize",u)}}},[]);var s=ce.useRef(new F0(D0(function(u){za&&o({width:u[u.length-1].contentRect.width,height:u[u.length-1].contentRect.height});},0)));return ce.useEffect(function(){var u=s.current;if(!e)return void u.disconnect();var p=n.current;return n.current&&za&&u.observe(n.current),function(){u.disconnect(),p&&za&&u.unobserve(p);}},[n,s]),r}var W0={useDevicePixelRatio:true,fitCanvasToArtboardHeight:false,useOffscreenRenderer:true,shouldResizeCanvasToContainer:true};function Ip(n){return Object.assign({},W0,n)}function Lp(n){var e=n.riveLoaded,t=e!==void 0&&e,r=n.canvasElem,o=n.containerRef,s=n.options,u=n.onCanvasHasResized,p=n.artboardBounds,h=Ip(s===void 0?{}:s),A=ce.useState({height:0,width:0}),y=A[0],b=y.height,m=y.width,S=A[1],C=ce.useState({height:0,width:0}),I=C[0],L=I.height,B=I.width,W=C[1],Q=ce.useState(true),Z=Q[0],$=Q[1],oe=h.fitCanvasToArtboardHeight,J=h.shouldResizeCanvasToContainer,H=h.useDevicePixelRatio,de=h.customDevicePixelRatio,te=V0(o,J),xe=Pp(de),Se=p??{},ue=Se.maxX,Ie=Se.maxY,ae=ce.useCallback(function(){var G,z,P,N,U=(G=(P=o.current)==null?void 0:P.clientWidth)!=null?G:0,q=(z=(N=o.current)==null?void 0:N.clientHeight)!=null?z:0;return oe&&p?{width:U,height:p.maxY/p.maxX*U}:{width:U,height:q}},[o,oe,ue,Ie]);ce.useEffect(function(){if(J&&o.current&&t){var G=ae(),z=G.width,P=G.height,N=false;if(r){var U=z!==m||P!==b;if(h.fitCanvasToArtboardHeight&&U&&(o.current.style.height=P+"px",N=true),h.useDevicePixelRatio){var q=z*xe!==B||P*xe!==L;if(U||q){var se=xe*z,Re=xe*P;r.width=se,r.height=Re,r.style.width=z+"px",r.style.height=P+"px",W({width:se,height:Re}),N=true;}}else U&&(r.width=z,r.height=P,W({width:z,height:P}),N=true);S({width:z,height:P});}u&&(Z||N)&&u&&u(),Z&&$(false);}},[r,o,te,xe,ae,Z,$,L,B,b,m,u,J,oe,H,t]),ce.useEffect(function(){W({width:0,height:0});},[r]);}var H0=(function(){function n(){}var e=n.prototype;return e.observe=function(){},e.unobserve=function(){},e.disconnect=function(){},n})(),G0=globalThis.IntersectionObserver||H0,j0=(function(){function n(){var t=this;this.elementsMap=new Map,this.onObserved=function(r){r.forEach(function(o){var s=t.elementsMap.get(o.target);s&&s(o);});},this.observer=new G0(this.onObserved);}var e=n.prototype;return e.registerCallback=function(t,r){this.observer.observe(t),this.elementsMap.set(t,r);},e.removeCallback=function(t){this.observer.unobserve(t),this.elementsMap.delete(t);},n})(),xp=function(){return rc||(rc=new j0),rc};function z0(){return {observe:ce.useCallback(function(n,e){xp().registerCallback(n,e);},[]),unobserve:ce.useCallback(function(n){xp().removeCallback(n);},[])}}function Zr(){return (Zr=Object.assign||function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);}return n}).apply(this,arguments)}function Op(n,e){if(n==null)return {};var t,r,o={},s=Object.getOwnPropertyNames(n);for(r=0;r<s.length;r++)t=s[r],!(e.indexOf(t)>=0)&&Object.prototype.propertyIsEnumerable.call(n,t)&&(o[t]=n[t]);return o}function Y0(n){var e=n.setContainerRef,t=n.setCanvasRef,r=n.className,o=r===void 0?"":r,s=n.style,u=n.children,p=Op(n,["setContainerRef","setCanvasRef","className","style","children"]),h=Zr({width:"100%",height:"100%"},s);return Ya.default.createElement("div",Zr({ref:e,className:o},!o&&{style:h}),Ya.default.createElement("canvas",Zr({ref:t,style:{verticalAlign:"top",width:0,height:0}},p),u))}function Np(n,e){e===void 0&&(e={});var t=ce.useState(null),r=t[0],o=t[1],s=ce.useRef(null),u=ce.useRef(null),p=ce.useState(null),h=p[0],A=p[1],y=!!n,b=Ip(e),m=Pp(),S=ce.useCallback(function(){if(h){if(h.layout&&h.layout.fit===sn.Fit.Layout&&r){var $=m*h.layout.layoutScaleFactor;h.devicePixelRatioUsed=m,h.artboardWidth=r?.width/$,h.artboardHeight=r?.height/$;}h.startRendering(),h.resizeToCanvas();}},[h,m]);Lp({riveLoaded:!!h,canvasElem:r,containerRef:s,options:b,onCanvasHasResized:S,artboardBounds:h?.bounds});var C=ce.useCallback(function($){$===null&&r&&(r.height=0,r.width=0),o($);},[]);ce.useEffect(function(){if(r&&n){var $,oe=h!=null;if(h==null){var J=b.useOffscreenRenderer,H=n.onRiveReady,de=Op(n,["onRiveReady"]);$=new sn.Rive(Zr({useOffscreenRenderer:J},de,{canvas:r})),u.current!=null&&u.current.cleanup(),u.current=$,$.on(sn.EventType.Load,function(){oe=true,H&&H($),r?A($):$.cleanup();});}return function(){oe||$==null||$.cleanup();}}},[r,y,h]);var I=ce.useCallback(function($){s.current=$;},[]),L=z0(),B=L.observe,W=L.unobserve;ce.useEffect(function(){var $,oe=false,J=function(){if(r&&oe){var H=r.getBoundingClientRect();H.width>0&&H.height>0&&H.top<(window.innerHeight||document.documentElement.clientHeight)&&H.bottom>0&&H.left<(window.innerWidth||document.documentElement.clientWidth)&&H.right>0&&(h?.startRendering(),oe=false);}};return r&&b.shouldUseIntersectionObserver!==false&&B(r,function(H){H.isIntersecting?h&&h.startRendering():h&&h.stopRendering(),oe=!H.isIntersecting,clearTimeout($),H.isIntersecting||H.boundingClientRect.width!==0||($=setTimeout(J,10));}),function(){r&&W(r);}},[B,W,h,r,b.shouldUseIntersectionObserver]),ce.useEffect(function(){return function(){h&&(h.cleanup(),A(null));}},[h,r]),ce.useEffect(function(){return function(){u.current!=null&&u.current.cleanup();}},[]);var Q=n?.animations;ce.useEffect(function(){h&&Q&&(h.isPlaying?(h.stop(h.animationNames),h.play(Q)):h.isPaused&&(h.stop(h.animationNames),h.pause(Q)));},[Q,h]);var Z=ce.useCallback(function($){return Ya.default.createElement(Y0,Zr({setContainerRef:I,setCanvasRef:C},$))},[C,I]);return {canvas:r,container:s.current,setCanvasRef:C,setContainerRef:I,rive:h,RiveComponent:Z}}function K0(n,e){if(n==null)return {};var t,r,o={},s=Object.getOwnPropertyNames(n);for(r=0;r<s.length;r++)t=s[r],!(e.indexOf(t)>=0)&&Object.prototype.propertyIsEnumerable.call(n,t)&&(o[t]=n[t]);return o}var q0=function(n){var e=n.src,t=n.artboard,r=n.animations,o=n.stateMachines,s=n.layout,u=n.useOffscreenRenderer,p=n.shouldDisableRiveListeners,h=n.shouldResizeCanvasToContainer,A=n.automaticallyHandleEvents,y=n.children,b=K0(n,["src","artboard","animations","stateMachines","layout","useOffscreenRenderer","shouldDisableRiveListeners","shouldResizeCanvasToContainer","automaticallyHandleEvents","children"]),m=Np({src:e,artboard:t,animations:r,layout:s,stateMachines:o,autoplay:true,shouldDisableRiveListeners:p!==void 0&&p,automaticallyHandleEvents:A!==void 0&&A},{useOffscreenRenderer:u===void 0||u,shouldResizeCanvasToContainer:h===void 0||h}).RiveComponent;return Ya.default.createElement(m,b,y)};function X0(n,e,t,r){var o=ce.useState(null),s=o[0],u=o[1];return ce.useEffect(function(){var p=function(){if(n&&e&&t||u(null),n&&e&&t){var h=n.stateMachineInputs(e);if(h){var A=h.find(function(y){return y.name===t});r!==void 0&&A&&(A.value=r),u(A||null);}}else u(null);};p(),n&&n.on(sn.EventType.Load,function(){p();});},[n]),s}function Q0(n,e){var t=e??{},r=t.name,o=t.useDefault,s=ce.useState(null),u=s[0],p=s[1];return ce.useEffect(function(){var h=function(){if(!n)return void p(null);p(r!=null?(n.viewModelByName==null?void 0:n.viewModelByName.call(n,r))||null:n.defaultViewModel()||null);};return h(),n&&n.on(sn.EventType.Load,h),function(){n&&n.off(sn.EventType.Load,h);}},[n,r,o!==void 0&&o]),u}function $0(n,e){var t=e??{},r=t.name,o=t.useDefault,s=o!==void 0&&o,u=t.useNew,p=u!==void 0&&u,h=t.rive,A=ce.useState(null),y=A[0],b=A[1];return ce.useEffect(function(){if(!n)return void b(null);var m=null;b(m=r!=null?n.instanceByName(r)||null:s?(n.defaultInstance==null?void 0:n.defaultInstance.call(n))||null:p?(n.instance==null?void 0:n.instance.call(n))||null:(n.defaultInstance==null?void 0:n.defaultInstance.call(n))||null),h&&m&&h.viewModelInstance!==m&&h.bindViewModelInstance(m);},[n,r,s,p,h]),y}function Dp(){return (Dp=Object.assign||function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);}return n}).apply(this,arguments)}function In(n,e,t){var r=ce.useState(null),o=r[0],s=r[1],u=ce.useState(t.defaultValue),p=u[0],h=u[1],A=ce.useState(null),y=A[0],b=A[1],m=ce.useRef(null),S=ce.useRef(n),C=ce.useRef(t);ce.useEffect(function(){C.current=t;},[t]);var I=ce.useCallback(function(){var Q=m.current,Z=S.current,$=C.current;if(!Q||!Z)return s(null),h($.defaultValue),b(null),function(){};var oe=$.getProperty(Q,Z);if(oe){s(oe),h($.getValue(oe)),$.getExtendedData&&b($.getExtendedData(oe));var J=function(){h($.getValue(oe)),$.getExtendedData&&b($.getExtendedData(oe)),$.onPropertyEvent&&$.onPropertyEvent();};return oe.on(J),function(){oe.off(J);}}return function(){}},[]);ce.useEffect(function(){return m.current=e,S.current=n,I()},[e,n,I]);var L=ce.useCallback(function(Q){if(o&&m.current===e)try{Q(o),C.current.getExtendedData&&b(C.current.getExtendedData(o));return}catch{}if(m.current)try{var Z=C.current.getProperty(m.current,S.current);Z&&(s(Z),Q(Z),C.current.getExtendedData&&b(C.current.getExtendedData(Z)));}catch{}},[o,e]),B=ce.useMemo(function(){return C.current.buildPropertyOperations(L)},[L]),W=Dp({value:p},B);return t.getExtendedData&&(W.extendedData=y),W}function J0(n,e){var t=In(n,e,{getProperty:ce.useCallback(function(r,o){return r.number(o)},[]),getValue:ce.useCallback(function(r){return r.value},[]),defaultValue:null,buildPropertyOperations:ce.useCallback(function(r){return {setValue:function(o){r(function(s){s.value=o;});}}},[])});return {value:t.value,setValue:t.setValue}}function Z0(n,e){var t=In(n,e,{getProperty:ce.useCallback(function(r,o){return r.string(o)},[]),getValue:ce.useCallback(function(r){return r.value},[]),defaultValue:null,buildPropertyOperations:ce.useCallback(function(r){return {setValue:function(o){r(function(s){s.value=o;});}}},[])});return {value:t.value,setValue:t.setValue}}function ey(n,e){var t=In(n,e,{getProperty:ce.useCallback(function(r,o){return r.boolean(o)},[]),getValue:ce.useCallback(function(r){return r.value},[]),defaultValue:null,buildPropertyOperations:ce.useCallback(function(r){return {setValue:function(o){r(function(s){s.value=o;});}}},[])});return {value:t.value,setValue:t.setValue}}function ty(n,e){var t=In(n,e,{getProperty:ce.useCallback(function(r,o){return r.color(o)},[]),getValue:ce.useCallback(function(r){return r.value},[]),defaultValue:null,buildPropertyOperations:ce.useCallback(function(r){return {setValue:function(o){r(function(s){s.value=o;});},setRgb:function(o,s,u){r(function(p){p.rgb(o,s,u);});},setRgba:function(o,s,u,p){r(function(h){h.rgba(o,s,u,p);});},setAlpha:function(o){r(function(s){s.alpha(o);});},setOpacity:function(o){r(function(s){s.opacity(o);});}}},[])});return {value:t.value,setValue:t.setValue,setRgb:t.setRgb,setRgba:t.setRgba,setAlpha:t.setAlpha,setOpacity:t.setOpacity}}function ny(n,e){var t=In(n,e,{getProperty:ce.useCallback(function(r,o){return r.enum(o)},[]),getValue:ce.useCallback(function(r){return r.value},[]),defaultValue:null,getExtendedData:ce.useCallback(function(r){return r.values},[]),buildPropertyOperations:ce.useCallback(function(r){return {setValue:function(o){r(function(s){s.value=o;});}}},[])});return {value:t.value,values:t.extendedData||[],setValue:t.setValue}}function ry(n,e,t){var r=(t??{}).onTrigger;return {trigger:In(n,e,{getProperty:ce.useCallback(function(o,s){return o.trigger(s)},[]),getValue:ce.useCallback(function(){},[]),defaultValue:null,onPropertyEvent:r,buildPropertyOperations:ce.useCallback(function(o){return {trigger:function(){o(function(s){s.trigger();});}}},[])}).trigger}}function iy(n,e){return {setValue:In(n,e,{getProperty:ce.useCallback(function(t,r){return t.image(r)},[]),getValue:ce.useCallback(function(){},[]),defaultValue:null,buildPropertyOperations:ce.useCallback(function(t){return {setValue:function(r){t(function(o){o.value=r;});}}},[])}).setValue}}function oy(n,e){var t,r=ce.useState(0)[1],o=In(n,e,{getProperty:ce.useCallback(function(s,u){return s.list(u)},[]),getValue:ce.useCallback(function(s){return s.length},[]),defaultValue:null,onPropertyEvent:function(){r(function(s){return s+1});},buildPropertyOperations:ce.useCallback(function(s){return {addInstance:function(u){s(function(p){return p.addInstance(u)});},addInstanceAt:function(u,p){var h=false;return s(function(A){h=A.addInstanceAt(u,p);}),h},removeInstance:function(u){s(function(p){return p.removeInstance(u)});},removeInstanceAt:function(u){s(function(p){return p.removeInstanceAt(u)});},getInstanceAt:function(u){var p=null;return s(function(h){p=h.instanceAt(u);}),p},swap:function(u,p){s(function(h){return h.swap(u,p)});}}},[])});return {length:(t=o.value)!=null?t:0,addInstance:o.addInstance,addInstanceAt:o.addInstanceAt,removeInstance:o.removeInstance,removeInstanceAt:o.removeInstanceAt,getInstanceAt:o.getInstanceAt,swap:o.swap}}function Rp(n,e,t,r,o,s,u){try{var p=n[s](u),h=p.value;}catch(A){t(A);return}p.done?e(h):Promise.resolve(h).then(r,o);}function ay(n){return function(){var e=this,t=arguments;return new Promise(function(r,o){var s=n.apply(e,t);function u(h){Rp(s,r,o,u,p,"next",h);}function p(h){Rp(s,r,o,u,p,"throw",h);}u(void 0);})}}function sy(n,e){var t,r,o,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create((typeof Iterator=="function"?Iterator:Object).prototype),p=Object.defineProperty;return p(u,"next",{value:h(0)}),p(u,"throw",{value:h(1)}),p(u,"return",{value:h(2)}),typeof Symbol=="function"&&p(u,Symbol.iterator,{value:function(){return this}}),u;function h(A){return function(y){var b=[A,y];if(t)throw TypeError("Generator is already executing.");for(;u&&(u=0,b[0]&&(s=0)),s;)try{if(t=1,r&&(o=2&b[0]?r.return:b[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,b[1])).done)return o;switch(r=0,o&&(b=[2&b[0],o.value]),b[0]){case 0:case 1:o=b;break;case 4:return s.label++,{value:b[1],done:!1};case 5:s.label++,r=b[1],b=[0];continue;case 7:b=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(b[0]===6||b[0]===2)){s=0;continue}if(b[0]===3&&(!o||b[1]>o[0]&&b[1]<o[3])){s.label=b[1];break}if(b[0]===6&&s.label<o[1]){s.label=o[1],o=b;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(b);break}o[2]&&s.ops.pop(),s.trys.pop();continue}b=e.call(n,s);}catch(m){b=[6,m],r=0;}finally{t=o=0;}if(5&b[0])throw b[1];return {value:b[0]?b[1]:void 0,done:true}}}}function ly(n){var e=ce.useState(null),t=e[0],r=e[1],o=ce.useState("idle"),s=o[0],u=o[1];return ce.useEffect(function(){var p=null;return ay(function(){return sy(this,function(h){try{u("loading"),(p=new sn.RiveFile(n)).init(),p.on(sn.EventType.Load,function(){p?.getInstance(),r(p),u("success");}),p.on(sn.EventType.LoadError,function(){u("failed");}),r(p);}catch(A){console.error(A),u("failed");}return [2]})})(),function(){p?.cleanup();}},[n.src,n.buffer]),{riveFile:t,status:s}}function cy(n,e){return {setValue:In(n,e,{getProperty:ce.useCallback(function(t,r){return t.artboard(r)},[]),getValue:ce.useCallback(function(){},[]),defaultValue:null,buildPropertyOperations:ce.useCallback(function(t){return {setValue:function(r){t(function(o){o.value=r;});}}},[])}).setValue}}xt.default=q0,xt.useResizeCanvas=Lp,xt.useRive=Np,xt.useRiveFile=ly,xt.useStateMachineInput=X0,xt.useViewModel=Q0,xt.useViewModelInstance=$0,xt.useViewModelInstanceArtboard=cy,xt.useViewModelInstanceBoolean=ey,xt.useViewModelInstanceColor=ty,xt.useViewModelInstanceEnum=ny,xt.useViewModelInstanceImage=iy,xt.useViewModelInstanceList=oy,xt.useViewModelInstanceNumber=J0,xt.useViewModelInstanceString=Z0,xt.useViewModelInstanceTrigger=ry,Object.keys(sn).forEach(function(n){n==="default"||xt.hasOwnProperty(n)||Object.defineProperty(xt,n,{enumerable:true,get:function(){return sn[n]}});});});var Do="33d964ca31c2dcf0c6ef3bfe4204c140829a7400bc73242e39b6b121fa174ce0";var Fo="api.avatarfactory.in",Vs=()=>`wss://${Fo}`,Ws=()=>`https://${Fo}`,fu=()=>`https://${Fo}/v1/vad/weights-${Do}.bin`,Hs=(n,e)=>`https://${Fo}/v1/assets/${n}.${e}`;var Ai=class Ai{static setLogLevel(e){this.level=e;}static sanitize(e){return e.map(t=>{if(t&&typeof t=="object"){let r={...t};for(let o of Ai.SENSITIVE_FIELDS)o in r&&(r[o]="[REDACTED]");return r}return t})}static format(e,t,r){return `[${new Date().toISOString()}] [${e}] [${t}] ${r}`}static muted(e){return this.level>e&&!this.onLog}static debug(e,t,...r){if(this.muted(0))return;let o=this.sanitize(r);this.onLog?.(0,e,t,...o),this.level<=0&&console.debug(this.format("DEBUG",e,t),...o);}static info(e,t,...r){if(this.muted(1))return;let o=this.sanitize(r);this.onLog?.(1,e,t,...o),this.level<=1&&console.info(this.format("INFO",e,t),...o);}static warn(e,t,...r){if(this.muted(2))return;let o=this.sanitize(r);this.onLog?.(2,e,t,...o),this.level<=2&&console.warn(this.format("WARN",e,t),...o);}static error(e,t,...r){if(this.muted(3))return;let o=this.sanitize(r);this.onLog?.(3,e,t,...o),this.level<=3&&console.error(this.format("ERROR",e,t),...o);}static event(e,t,...r){this.info(`Event:${e}`,t,...r);}};Ai.level=4,Ai.SENSITIVE_FIELDS=["apiKey","sessionToken","getSessionToken","byok"];var E=Ai;var Gs=new Map;function bi(n,e,t){let r=Gs.get(n.sha256);if(r)return r;let o=Tm(n,e,t).catch(s=>{throw Gs.delete(n.sha256),s});return Gs.set(n.sha256,o),o}async function Tm(n,e,t){let r=await km(n.sha256,t);if(r&&await pu(r,n))return r;let o=await fetch(e,{priority:"low"});if(!o.ok)throw new Error(`asset ${n.sha256} HTTP ${o.status}`);let s=new Uint8Array(await o.arrayBuffer());if(!await pu(s,n))throw new Error(`asset ${n.sha256} failed integrity check (${s.byteLength}B)`);return t?.write(n.sha256,s)?.catch(u=>{E.warn("Assets","failed to cache asset",{sha256:n.sha256,cause:u});}),s}async function km(n,e){try{return await e?.read(n)??null}catch(t){return E.warn("Assets","asset cache read failed",{sha256:n,cause:t}),null}}async function pu(n,e){if(n.byteLength!==e.byteLength)return false;let t=globalThis.crypto?.subtle;if(!t)return E.warn("Assets","no SubtleCrypto \u2014 asset checked by length only"),true;let r=await t.digest("SHA-256",n);return Cm(new Uint8Array(r))===e.sha256}function Cm(n){let e="";for(let t=0;t<n.length;t++)e+=n[t].toString(16).padStart(2,"0");return e}function hu(n,e){return bi({sha256:Do,byteLength:590012},n,e&&{read:t=>e.getCachedVadWeights?.(t),write:(t,r)=>e.setCachedVadWeights?.(t,r)})}var js={A:2,E:4,I:6,O:8,U:7,Y:6,P:21,B:21,M:21,F:18,V:18,T:19,D:19,N:19,S:15,Z:15,L:14,R:13,K:20,C:20,G:20,Q:20,H:12,W:7,J:16,X:15," ":0,".":0,",":0,"!":0,"?":0,":":0,";":0,"-":0,"(":0,")":0,'"':0,"'":0,DEFAULT:0},Bo={TH:19,SH:16,CH:16,PH:18,GH:0,CK:20,NG:20,AI:4,AU:8,EA:6,EE:6,IE:6,OA:8,OO:7,OU:8,OW:8,UE:7,ER:5,IR:5,UR:5,AR:2,OR:8};var zs=400,mu=4e3,zn={loop:true,volume:.4,fadeOutMs:350},gu=15e3,Ys=500,vu=4010,Au=4011,bu=6e3,yu=1500,_u=[1e3,2e3,4e3,8e3,15e3],wu={echoCancellation:false,noiseSuppression:false,autoGainControl:false,channelCount:1},Ks=350,qs=-9999,Xs=9999,pn=Number.NEGATIVE_INFINITY,yi=.28,Uo=1,Qs=.15,$s=2.5,Vo=1,Js=.2,Zs=2,Wo=1,el=.25,tl=1.6,Ho=60,nl=.1,rl=200,Go=40,il=0,ol=100,al=12e3,sl=1e3,jo=0,zo=250,Su=3,Eu=10,ll=2500;var cl=1e3,_i=.25,Yo=.25,Ko=.01,Mu=200,Tu=250,ku=12e4,Cu=12e3;var qo=n=>{if(!Array.isArray(n))return null;let e=[];for(let t of n){let{visemeId:r,start:o,end:s}=t??{};!Number.isInteger(r)||!Number.isFinite(o)||!Number.isFinite(s)||e.push({char:"",visemeId:r,start:o,end:s});}return e},ul=(n,e)=>{let t=[],r=n[0];for(let s=1;s<n.length;s++){let u=n[s];u.start*1e3-r.start*1e3<=e&&u.char!==" "&&r.char!==" "?r={...r,end:u.end,char:r.char+u.char}:(Bo?.[r.char]&&(r={...r,visemeId:Bo?.[r.char]??0}),t.push(r),r=u);}t.push(r);let o=t.length-1;for(;o>=0&&t[o].visemeId===0;)o--;if(o<t.length-1){let s=t[t.length-1];t[o]={...t[o],end:s.start},t.splice(o+1,t.length-(o+1),{...s,start:t[o].end});}return t},Xo=(n,e=40)=>{if(!n||!Array.isArray(n.character_start_times_seconds))return [];let t=n.characters.map((r,o)=>{let s=n.character_start_times_seconds[o]??0,u=n.character_end_times_seconds[o]??s+.05,p=(r||" ").toUpperCase();return {char:r,start:s,end:u,visemeId:js[p]??0}});return ul(t,e)},wi=(n,{defaultDurationMs:e=50}={})=>{if(!n)return null;let t=Array.isArray(n.chars)?n.chars:[],r=Array.isArray(n.charStartTimesMs)?n.charStartTimesMs:[],o=Array.isArray(n.charDurationsMs)?n.charDurationsMs:[],s=t.length,u=new Array(s).fill(0),p=new Array(s).fill(e);for(let y=0;y<s;y++){let b=r[y],m=b==null?NaN:Number(b);u[y]=Number.isFinite(m)?m:0;let S=o[y],C=S==null?NaN:Number(S);p[y]=Number.isFinite(C)&&C>=0?C:NaN;}for(let y=0;y<s;y++)Number.isFinite(p[y])||(p[y]=y+1<s&&Number.isFinite(u[y+1])&&u[y+1]>u[y]?u[y+1]-u[y]:e);let h=new Array(s),A=new Array(s);for(let y=0;y<s;y++){let b=u[y]/1e3,m=(u[y]+Math.max(0,p[y]))/1e3;h[y]=Number.isFinite(b)?b:0,A[y]=Number.isFinite(m)?Math.max(h[y],m):h[y]+.001;}return {characters:t,character_start_times_seconds:h,character_end_times_seconds:A}};var dl=["idle","listening","thinking","talking"];var xu=n=>typeof n=="string"&&dl.includes(n),Ur=n=>typeof n=="string"&&n.trim()&&n.length<=64?n:null,Yn=n=>{let e=Number(n);return Number.isFinite(e)&&e>0?Math.min(Math.round(e),6e5):0};function Rm(n){if(!n||typeof n!="object")return null;let e=n,t=Ur(e.gate),r=Ur(e.act),o=r&&Array.isArray(e.acts)?e.acts.filter(s=>Number.isInteger(s)&&s>0&&s<=99):[];return !t&&!r?null:{gate:t,act:r,acts:o,...xu(e.fallback)&&{fallback:e.fallback}}}var Pm=["oneShot","loop","pingPong"],Im=/^[^\0\r\n]{1,120}$/;function Lm(n){if(!n||typeof n!="object")return null;let e=n,t=Ur(e.gate),r=Ur(e.act),o=Yn(e.windowMaxMs);if(!t||!r||!o)return null;let s=Math.min(Yn(e.windowMinMs),o),u=[];for(let p of Array.isArray(e.acts)?e.acts:[]){let h=p??{},A=h.id,y=Yn(h.ms);if(!Number.isInteger(A)||A<1||A>99||!y||u.some(S=>S.id===A))continue;let b=Pm.includes(h.loop)?h.loop:"loop",m=typeof h.timeline=="string"&&Im.test(h.timeline)?h.timeline:void 0;u.push({id:A,ms:y,loop:b,...m&&{timeline:m}});}return u.length?{gate:t,act:r,acts:u,windowMinMs:s,windowMaxMs:o}:null}var Om=12,Nm=4;function Dm(n){let e=(Array.isArray(n)?n:[]).map(Ur).filter(t=>!!t);return [...new Set(e)].slice(0,Nm)}function Fm(n){if(!n||typeof n!="object")return null;let e=n,t=[];for(let r of Array.isArray(e.gestures)?e.gestures:[]){let o=r??{},s=Ur(o.trigger),u=Yn(o.ms);if(!(!s||!u||t.some(p=>p.trigger===s))&&(t.push({trigger:s,ms:u}),t.length===Om))break}return t.length?{gestures:t}:null}function Ru(n,e,t,r,o=Math.random){if(!n?.length||t<r)return null;let s=n.filter(p=>p.trigger!==e),u=s.length?s:n;return u[Math.floor(o()*u.length)]}function Qo(n){if(!n||typeof n!="object")return null;let e=n,t=e.branches??{},r={};for(let p of dl){let h=Rm(t[p]);h&&(r[p]=h);}let o=Lm(e.idleActs);if(o&&(r.idle={gate:o.gate,act:o.act,acts:o.acts.map(p=>p.id)}),!Object.keys(r).length)return null;let s=Fm(e.playful),u=Dm(e.idleTriggers);return {version:Number(e.version)||1,branches:r,quietToIdleMs:Yn(e.quietToIdleMs),idleCycleMs:Yn(e.idleCycleMs),playfulAfterMs:Yn(e.playfulAfterMs),playfulRoles:Array.isArray(e.playfulRoles)?e.playfulRoles.filter(xu):[],thinkingMaxMs:Yn(e.thinkingMaxMs),...o&&{idleActs:o},...s&&{playful:s},...u.length&&{idleTriggers:u}}}var fl=n=>n.trim().replace(/\s+/g," ").slice(0,zs).trimEnd(),Bm=n=>{let e=2166136261;for(let t=0;t<n.length;t++)e^=n.charCodeAt(t),e=Math.imul(e,16777619)>>>0;return e.toString(16).padStart(8,"0")},pl=(n,e,t)=>`${n}:${e}:${Bm(t)}`;var Si=n=>n.environment!=="meeting"?n:{...n,autoStart:n.autoStart??true,controls:n.controls??{enabled:false},statusBanner:{enabled:false,...n.statusBanner},thinkingIndicator:{enabled:false,...n.thinkingIndicator},connectTone:n.connectTone??{enabled:false},turnTaking:{echoGate:false,clientBargeIn:false,...n.turnTaking}};var Pu=()=>{if(typeof document>"u")return true;let n=document.permissionsPolicy??document.featurePolicy;return typeof n?.allowsFeature!="function"||n.allowsFeature("microphone")!==false};var hn=1e3,Vr=(n,e,t,r)=>typeof n=="number"&&Number.isFinite(n)?Math.max(e,Math.min(t,n)):r,xn=class{constructor(){this.speed=Uo;this.jawSpeed=Vo;this.openness=Wo;this.holdSec=Ho/hn;this.rest=Go;this.offsetSec=jo/hn;this.maxStepFrames=Su;}apply(e){e&&(this.speed=Vr(e.mouthSpeed,Qs,$s,this.speed),this.jawSpeed=Vr(e.jawSpeed,Js,Zs,this.jawSpeed),this.openness=Vr(e.mouthOpenness,el,tl,this.openness),this.holdSec=Vr(e.mouthHold,nl,rl,this.holdSec*hn)/hn,this.rest=Vr(e.mouthRest,il,ol,this.rest),this.offsetSec=Vr(e.offsetMs,-zo,zo,this.offsetSec*hn)/hn);}reset(e){this.speed=Uo,this.jawSpeed=Vo,this.openness=Wo,this.holdSec=Ho/hn,this.rest=Go,this.offsetSec=jo/hn,this.apply(e);}snapshot(){return {offsetMs:Math.round(this.offsetSec*hn),mouthSpeed:this.speed,jawSpeed:this.jawSpeed,mouthOpenness:this.openness,mouthHold:Math.round(this.holdSec*hn),mouthRest:this.rest}}};var $o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function hl(n){let e="",t=n.length;for(let r=0;r<t;r+=3){let o=n[r],s=r+1<t?n[r+1]:0,u=r+2<t?n[r+2]:0;e+=$o[o>>2],e+=$o[(o&3)<<4|s>>4],e+=r+1<t?$o[(s&15)<<2|u>>6]:"=",e+=r+2<t?$o[u&63]:"=";}return e}var Ei=n=>n.characters.join("").replace(/\s+/g," ").trim(),Mi=n=>{let{characters:e,character_start_times_seconds:t,character_end_times_seconds:r}=n,o=[],s="",u=0,p=0,h=()=>{s&&(o.push({text:s,start:u,end:p}),s="");};for(let A=0;A<e.length;A++){let y=e[A];if(/\s/.test(y)){h();continue}s||(u=t[A]??0),s+=y,p=r[A]??u;}return h(),o},ml=n=>n.split(/\s+/).filter(Boolean).map(e=>({text:e,start:0,end:0})),Jo=(n,e)=>{let t=0;for(;t<n.words.length&&n.words[t].start<=e;)t++;return t},gl=(n,e)=>n.words.slice(0,Jo(n,e)).map(t=>t.text).join(" ").trim();var vl=["hmm","hmmm","mhm","mhmm","mm","mmm","uh","um","umm","uh huh","yeah","yep","ok","okay","right","haan","han","achha","accha","theek hai","theek"];var Zo={mode:"healthy",commitPostPauseMs:680,settleMs:60,circuitBreakerEnabled:true},Al={mode:"degraded",commitPostPauseMs:100,settleMs:100,circuitBreakerEnabled:false},Iu=1200,Lu=600,Ou=5,Nu=3,Du=6e4,Fu=400,Bu=6e3,Uu=.5,Vu=80,Wu=3,Hu=100,Gu=2,ju=.6,zu=.8,Yu=4,qu=400,Xu=40;function _l(n){let e="idle",t=null,r=null,o=0,s=0,u=0,p=0,h="",A=null,y=0,b=0,m=0,S=0,C=0,I=0;function L(){return n.getPolicy?.()??Zo}function B(){return L().circuitBreakerEnabled?{pause:C,threshold:I}:{pause:0,threshold:0}}function W(){return Math.min(.95,(e==="soft_pause"?.3:.5)+B().threshold)}function Q(){return h.trim().length>0&&!Qu(h)}function Z(ae){return A===null||A.motion>=ae}function $(){return A?{speechMotion:A.motion,speechMedianFlux:A.medianFlux,speechModulation:A.modulation}:{}}function oe(){t=null,r=null,o=0,s=0,u=0,p=0,h="",A=null;}function J(){b=0,m=0;}function H(){e="idle",oe(),J(),S=0,C=0,I=0;}function de(ae){n.onTelemetry?.({voiceOnsetToPauseMs:u-o,outcome:"commit",commitClause:ae,totalVoicedMs:s,postPauseVoicedMs:p,transcript:h||void 0,wordlessResumeStreak:S,mode:L().mode,...$()}),n.commitInterrupt(),H();}function te(ae){h.trim().length===0&&p<60?S++:S=0,n.onTelemetry?.({voiceOnsetToPauseMs:u-o,outcome:"resume",totalVoicedMs:s,postPauseVoicedMs:p,transcript:h||void 0,wordlessResumeStreak:S,mode:L().mode,...$()}),n.resumePlayback(),L().circuitBreakerEnabled&&S>=3&&(C=150,I=.1),s>=100?(b=s,m=ae+500):J(),e="speaking",oe();}function xe(ae,G,z){if(z!==void 0&&(A=z),y=G,!n.isAvatarSpeaking()){e!=="idle"&&Ie();return}if(e==="idle"&&(e="speaking",oe()),ae>=W()){if(t===null&&(t=G),r!==null){let q=G-r;q>0&&q<=150&&(s+=q,e==="soft_pause"&&G-u>L().settleMs&&(p+=Math.min(q,30)));}r=G;}else r!==null&&G-r>150&&(t=null);if(e==="speaking"){t!==null&&G-t>=70+B().pause&&(e="soft_pause",o=t,u=G,n.pausePlayback());return}if(p>=L().commitPostPauseMs&&!Q()&&Z(.02)){de("post_pause");return}let U=r!==null&&G-r<=150;if(U&&G-o>=1e3&&!Q()&&Z(.02)){de("sustained");return}if(!U&&r!==null&&G-r>=900){te(G);return}}function Se(ae){if(e==="idle"||!ae||n.getActiveScriptTail&&Ju(ae,n.getActiveScriptTail()))return;h=h?`${h} ${ae}`:ae;let G=m>0&&y<=m,z=s<100;(z&&G?b:s)<100||Qu(ae)&&(e==="speaking"&&(e="soft_pause",o=t??0,u=0,n.pausePlayback()),de(z?"words_late":"words"));}function ue(){e!=="idle"&&(e==="speaking"&&(e="soft_pause",u=0,n.pausePlayback()),de("manual"));}function Ie(){e==="soft_pause"&&n.resumePlayback(),H();}return {onVadProb:xe,onPartialTranscript:Se,manualStop:ue,abort:Ie,reset:Ie}}function ea(n){return n.toLowerCase().replace(/[^\p{L}\p{N}\s]/gu," ").replace(/\s+/g," ").trim()}function $u(n){return n.replace(/(.)\1+/g,"$1")}var tg=new Set(vl.filter(n=>!n.includes(" ")).map($u)),ng=vl.filter(n=>n.includes(" "));function Qu(n){let e=ea(n);if(!e)return false;for(let r of ng)e=e.replace(new RegExp(`(^| )${r}( |$)`,"g")," ");return e.split(" ").filter(Boolean).some(r=>!tg.has($u(r)))}function Ju(n,e,t=ju){let r=ea(n).split(" ").filter(Boolean);if(r.length===0)return false;let o=new Set(ea(e).split(" ").filter(Boolean));if(o.size===0)return false;let s=0;for(let u of r)o.has(u)&&s++;return s/r.length>=t}function Zu(n,e){return ea(n).split(" ").filter(Boolean).length<Yu?false:Ju(n,e,zu)}var ed=/^[a-z0-9][a-z0-9_.]{0,63}$/;var ta=class{constructor(){this.sentByName=new Map;this.windowStartedAt=0;this.windowCount=0;}validate(e){if(!ed.test(e.name))return {ok:false,reason:"invalid_name",message:`notify() name must be a slug matching ${ed} \u2014 got "${e.name}"`};if(e.say!==void 0&&e.say.length>1e3)return {ok:false,reason:"say_too_long",message:"notify() say is too long (max 1000 chars)"};if(e.data===void 0)return {ok:true};let t;if(typeof e.data=="string")t=e.data;else try{t=JSON.stringify(e.data);}catch{return {ok:false,reason:"data_invalid",message:"notify() data is not serializable"}}return t.length>512?{ok:false,reason:"data_too_long",message:"notify() data is too long (max 512 chars serialized)"}:{ok:true,data:t}}admit(e,t,r){let o=this.sentByName.get(e);return o&&r-o.sentAt<t?{ok:false,reason:"cooldown"}:(r-this.windowStartedAt>=1e4&&(this.windowStartedAt=r,this.windowCount=0),this.windowCount>=5?{ok:false,reason:"rate_limit"}:(this.windowCount+=1,this.sweepExpired(r),this.sentByName.set(e,{sentAt:r,cooldownMs:t}),{ok:true}))}sweepExpired(e){if(!(this.sentByName.size<64))for(let[t,r]of this.sentByName)e-r.sentAt>=r.cooldownMs&&this.sentByName.delete(t);}};var td=/^[a-z][a-z0-9_]{0,63}$/,nd=/^[a-zA-Z][a-zA-Z0-9_]{0,39}$/,rg=new Set(["confirm_action","cancel_action"]),rd=16,id=8,od=300,ad=120,sd=20,ig=1e3,og=250,pr={unavailable:"that action is not available right now",invalidArgs:"the details did not match what that action needs",failed:"the action failed",timedOut:"it took too long"},ag=new Set(["string","email","phone","date","datetime","number","boolean","enum"]),ld="[]",na=class{constructor(e){this.transport=e;this.actions=new Map;this.lastSent=ld;this.syncTimer=null;}get size(){return this.actions.size}get(e){return this.actions.get(e)}register(e){let t=lg(e);if(t)return {ok:false,message:`registerAction(): ${t}`};if(!this.actions.has(e.name)&&this.actions.size>=rd)return {ok:false,message:`registerAction(): at most ${rd} actions at once \u2014 "${e.name}" was not added`};let r={declaration:sg(e),handler:e.handler,...e.check&&{check:e.check}};return this.actions.set(e.name,r),this.scheduleSync(),{ok:true,unregister:()=>{this.actions.get(e.name)===r&&(this.actions.delete(e.name),this.scheduleSync());}}}declarations(){return [...this.actions.values()].map(e=>e.declaration).sort((e,t)=>e.name<t.name?-1:e.name>t.name?1:0)}syncNow(){if(this.clearSyncTimer(),!this.transport.canDeclare())return;let e=this.declarations(),t=JSON.stringify(e);t!==this.lastSent&&this.transport.send(e)&&(this.lastSent=t);}resetSession(){this.clearSyncTimer(),this.lastSent=ld;}scheduleSync(){this.clearSyncTimer(),this.syncTimer=setTimeout(()=>{this.syncTimer=null,this.syncNow();},og);}clearSyncTimer(){this.syncTimer!==null&&(clearTimeout(this.syncTimer),this.syncTimer=null);}},sg=n=>{let e={};for(let[r,o]of Object.entries(n.params??{}))e[r]={type:o.type,...o.description!==void 0&&{description:o.description},...o.required!==void 0&&{required:o.required},...o.type==="enum"&&{values:[...o.values??[]]},...o.check===true&&{check:true}};let t=n.ui&&{...n.ui.inputs!==void 0&&{inputs:n.ui.inputs==="*"?"*":[...n.ui.inputs]},...n.ui.review!==void 0&&{review:n.ui.review}};return {name:n.name,description:n.description.trim(),params:e,...n.kind==="lookup"&&{kind:"lookup"},...n.undoable===true&&{undoable:true},...t&&{ui:t}}},Kn=n=>!!n&&typeof n=="object"&&!Array.isArray(n),lg=n=>{if(!Kn(n))return "the action must be an object";let{name:e,description:t,params:r,handler:o}=n;if(typeof e!="string"||!td.test(e))return `name must match ${td} \u2014 got "${String(e)}"`;if(rg.has(e))return `"${e}" is reserved`;if(typeof t!="string"||!t.trim())return `"${e}" needs a description`;if(t.length>od)return `"${e}" description is too long (max ${od} chars)`;if(typeof o!="function")return `"${e}" needs a handler`;let s=cg(n);if(s)return `"${e}" ${s}`;if(r===void 0)return null;if(!Kn(r))return `"${e}" params must be an object`;let u=Object.entries(r);if(u.length>id)return `"${e}" has too many params (max ${id})`;for(let[p,h]of u){let A=ug(p,h);if(A)return `"${e}" param "${p}": ${A}`}return null},cg=n=>{let{kind:e,ui:t,check:r,undoable:o}=n,s=Kn(n.params)?n.params:{};if(e!==void 0&&e!=="action"&&e!=="lookup")return `kind must be "action" or "lookup" \u2014 got "${String(e)}"`;if(o!==void 0&&typeof o!="boolean")return "undoable must be a boolean";if(e==="lookup"&&o)return "is a lookup, which changes nothing to undo";let u=Object.values(s).some(A=>Kn(A)&&A.check===true);if(e==="lookup"&&(u||r!==void 0))return "is a lookup, which cannot check values";if(u&&typeof r!="function")return "marks a param check: true but has no check function";if(r!==void 0&&typeof r!="function")return "check must be a function";if(t===void 0)return null;if(!Kn(t))return "ui must be an object";if(t.review!==void 0&&typeof t.review!="boolean")return "ui.review must be a boolean";if(e==="lookup"&&t.review)return "is a lookup, which has no review";let{inputs:p}=t;if(p===void 0||p==="*")return null;if(!Array.isArray(p))return 'ui.inputs must be "*" or a list of params';let h=p.find(A=>!(String(A)in s));return h===void 0?null:`ui.inputs names "${String(h)}", which is not a param`},ug=(n,e)=>{if(!nd.test(n))return `name must match ${nd}`;if(!Kn(e))return "must be an object";if(!ag.has(e.type))return `unknown type "${String(e.type)}"`;if(e.description!==void 0&&(typeof e.description!="string"||e.description.length>ad))return `description must be a string of at most ${ad} chars`;if(e.required!==void 0&&typeof e.required!="boolean")return "required must be a boolean";if(e.check!==void 0&&typeof e.check!="boolean")return "check must be a boolean";if(e.type!=="enum")return null;let t=e.values;return Array.isArray(t)&&t.length>0&&t.length<=sd&&t.every(o=>typeof o=="string"&&o.trim())?null:`an enum needs 1\u2013${sd} non-empty string values`},dg=/^\d{4}-\d{2}-\d{2}$/,fg=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/,wl=(n,e)=>{switch(n.type){case "string":case "email":case "phone":return typeof e=="string";case "date":return typeof e=="string"&&dg.test(e);case "datetime":return typeof e=="string"&&fg.test(e);case "number":return typeof e=="number"&&Number.isFinite(e);case "boolean":return typeof e=="boolean";case "enum":return typeof e=="string"&&!!n.values?.includes(e)}},ud=(n,e)=>{if(e!==void 0&&!Kn(e))return null;let t=e??{},r={};for(let[o,s]of Object.entries(n.params)){let u=t[o];if(u==null||u===""){if(s.required!==false)return null;continue}if(!wl(s,u))return null;r[o]=u;}return r},cd=n=>String(n).slice(0,ig),dd=n=>Kn(n)?n.ok===true?n.result===void 0||n.result===null?{ok:true}:{ok:true,result:cd(n.result)}:n.ok===false?{ok:false,error:(n.error===void 0||n.error===null?"":cd(n.error).trim())||pr.failed}:null:null;var fd=2500,pg=200,hg=5,Ti=n=>!!n&&typeof n=="object"&&!Array.isArray(n),pd=n=>{if(!Ti(n))return null;let{actionId:e,revision:t,name:r,stage:o,args:s,missing:u,awaiting:p,outcome:h}=n;return typeof e!="string"||!e||typeof t!="number"||!Number.isFinite(t)||typeof r!="string"||typeof o!="string"?null:{actionId:e,revision:t,name:r,stage:o,args:Ti(s)?{...s}:{},missing:Array.isArray(u)?u.filter(A=>typeof A=="string"):[],awaiting:Ti(p)&&typeof p.kind=="string"?{...p}:null,...Ti(h)&&typeof h.ok=="boolean"&&{outcome:{ok:h.ok,message:typeof h.message=="string"?h.message:""}}}},mg=new Set(["done","cancelled","expired"]),ra=class{constructor(){this.current=null;}get flow(){return this.current}apply(e){let t=this.current;return t&&t.actionId===e.actionId&&e.revision<=t.revision?false:(this.current=e,true)}get isLive(){return !!this.current&&!mg.has(this.current.stage)}clear(){this.current=null;}},hd=(n,e)=>{let t={};for(let[r,o]of Object.entries(e)){let s=n.params[r];if(!s)return {ok:false,message:`"${n.name}" has no param "${r}"`};if(!wl(s,o))return {ok:false,message:`"${n.name}" param "${r}" must be a ${s.type}`};t[r]=o;}return Object.keys(t).length?{ok:true,args:t}:{ok:false,message:"input needs at least one value"}},md=async(n,e,t,r)=>{if(!n)return {ok:true,unverified:true};let o,s=Promise.resolve().then(()=>n(e,t,r)).then(gg,()=>null),u=new Promise(h=>{o=setTimeout(()=>h(null),fd);}),p=await Promise.race([s,u]);return clearTimeout(o),p??{ok:true,unverified:true}},gg=n=>{if(!Ti(n)||typeof n.ok!="boolean")return null;if(n.ok)return n.value===void 0?{ok:true}:{ok:true,value:n.value};let e=typeof n.reason=="string"?n.reason.slice(0,pg):void 0,t=Array.isArray(n.suggestions)?n.suggestions.slice(0,hg):void 0,r=typeof n.param=="string"&&n.param?n.param:void 0;return {ok:false,...e&&{reason:e},...t?.length&&{suggestions:t},...r&&{param:r}}};var ia=n=>{let e=n.cause?.name;return typeof e=="string"&&e!==""&&e!=="Error"?e:null},vg="embed_unauthorized_domain",Ag=/unauthorized domain/i,Sl=(n,e)=>n===vg||typeof e=="string"&&Ag.test(e),ki=class extends Error{constructor(e,t){let r=t??{},o=typeof r.error=="string"?r.error:void 0;super(`config route HTTP ${e}${o?`: ${o}`:""}`),this.name="ConfigRouteError",this.status=e,this.serverCode=typeof r.code=="string"?r.code:void 0,this.serverMessage=o;}},bg=123,gd=n=>`Initialization Failed: ${n.code} (${ia(n)??n.message})`.slice(0,bg);var yg=50,_g=4e3,oa=class{constructor(e,t=yg){this.onChange=e;this.entries=[];this.activeUserEntryId=null;this.lastFinalText="";this.lastFinalAt=0;this.activeAvatarEntryId=null;this.activeAvatarJobId=null;this.entryCounter=0;this.consumedChunks=0;this.openChars=[];this.openStarts=[];this.openEnds=[];this.maxEntries=Math.max(1,t);}applyUserTranscript({text:e,isFinal:t,turnId:r}){let o=e?.trim()??"";if(!o)return;let s=this.findEntry(this.activeUserEntryId);if(s&&s.turnId!==r&&(this.upsert({...s,isFinal:true}),s=null),s&&s.text===o&&s.isFinal===t||!s&&o===this.lastFinalText&&Date.now()-this.lastFinalAt<_g)return;let u={id:s?.id??this.nextId("user"),speaker:"user",text:o,words:ml(o),isFinal:t,turnId:r,createdAt:s?.createdAt??Date.now()};this.upsert(u),this.activeUserEntryId=t?null:u.id,t&&(this.lastFinalText=o,this.lastFinalAt=Date.now()),this.emit();}applyAvatarSpeech(e){let t=e.alignments??[],r=e.chunkOffset??0,o=r+t.length;if(this.activeAvatarJobId!==e.jobId&&(this.finalizeAvatar(),this.activeAvatarJobId=e.jobId,this.consumedChunks=0),o<=this.consumedChunks)return;this.activeAvatarEntryId||(this.activeAvatarEntryId=this.nextId("avatar"),this.openChars=[],this.openStarts=[],this.openEnds=[]);for(let h=Math.max(0,this.consumedChunks-r);h<t.length;h++){let A=e.displayAlignments?.[h]??t[h];A?.characters?.length&&(this.openChars.push(...A.characters),this.openStarts.push(...A.character_start_times_seconds),this.openEnds.push(...A.character_end_times_seconds));}if(this.consumedChunks=o,!this.openChars.length)return;let s={characters:this.openChars,character_start_times_seconds:this.openStarts,character_end_times_seconds:this.openEnds},u=Ei(s);if(!u)return;let p=this.findEntry(this.activeAvatarEntryId);p?.text!==u&&(this.upsert({id:this.activeAvatarEntryId,speaker:"avatar",text:u,words:Mi(s),isFinal:false,turnId:e.turnId,createdAt:p?.createdAt??Date.now()}),this.emit());}finalizeAvatar(){let e=this.findEntry(this.activeAvatarEntryId);this.activeAvatarEntryId=null,this.openChars=[],this.openStarts=[],this.openEnds=[],!(!e||e.isFinal)&&(this.upsert({...e,isFinal:true}),this.emit());}reset(){let e=this.entries.length>0;this.entries=[],this.activeUserEntryId=null,this.lastFinalText="",this.lastFinalAt=0,this.activeAvatarEntryId=null,this.activeAvatarJobId=null,this.consumedChunks=0,this.openChars=[],this.openStarts=[],this.openEnds=[],e&&this.emit();}getEntries(){return [...this.entries]}upsert(e){let t=this.entries.findIndex(r=>r.id===e.id);if(t>=0){this.entries[t]=e;return}this.entries.push(e),this.entries.length>this.maxEntries&&this.entries.splice(0,this.entries.length-this.maxEntries);}findEntry(e){return e?this.entries.find(t=>t.id===e)??null:null}nextId(e){return `${e}-${++this.entryCounter}`}emit(){this.onChange(this.getEntries());}};var aa=class{constructor(e){this.deps=e;this.held=false;this.open=false;this.preRollToFlush=[];this.recentFrames=[];this.tailTimer=null;this.maxHoldTimer=null;this.silenceByteSize=new Map;}isHeld(){return this.held}isTurnOpen(){return this.open}press(){if(this.held)return false;this.held=true;let e=this.open;return this.clearTailTimer(),this.open=true,e||(this.preRollToFlush=this.recentFrames.map(t=>t.buffer),this.recentFrames=[]),this.maxHoldTimer=setTimeout(()=>{this.maxHoldTimer=null,E.warn("PushToTalk","hold hit its ceiling \u2014 releasing"),this.release();},ku),E.event("ptt","press",{isContinuation:e,preRollFrames:this.preRollToFlush.length}),this.deps.onHeldChange(true),e||this.deps.onTurnStart(),!e}release(){this.held&&(this.held=false,this.clearMaxHoldTimer(),E.event("ptt","release"),this.deps.onHeldChange(false),this.tailTimer=setTimeout(()=>{this.tailTimer=null,this.closeTurn();},Tu));}gate(e){if(!this.open)return this.rememberFrame(e),[this.silenceOfSize(e.byteLength)];if(!this.preRollToFlush.length)return [e];let t=this.preRollToFlush;return this.preRollToFlush=[],t.push(e),t}reset(){this.held=false,this.open=false,this.preRollToFlush=[],this.recentFrames=[],this.clearTailTimer(),this.clearMaxHoldTimer();}closeTurn(){this.open&&(this.open=false,this.preRollToFlush=[],this.deps.onTurnEnd());}rememberFrame(e){let t=Date.now();for(this.recentFrames.push({capturedAt:t,buffer:e.slice(0)});this.recentFrames.length&&t-this.recentFrames[0].capturedAt>Mu;)this.recentFrames.shift();}silenceOfSize(e){let t=this.silenceByteSize.get(e);return t||(t=new ArrayBuffer(e),this.silenceByteSize.size>8&&this.silenceByteSize.clear(),this.silenceByteSize.set(e,t)),t}clearTailTimer(){this.tailTimer&&(clearTimeout(this.tailTimer),this.tailTimer=null);}clearMaxHoldTimer(){this.maxHoldTimer&&(clearTimeout(this.maxHoldTimer),this.maxHoldTimer=null);}};var vd="server_tick";var sa=class{constructor(){this.wedge=[];}note(e,t){if(typeof e!="number"||!Number.isFinite(e))return null;let r=t-e;for(;this.wedge.length>0&&this.wedge[this.wedge.length-1].offset>=r;)this.wedge.pop();for(this.wedge.push({offset:r,at:t});this.wedge.length>0&&t-this.wedge[0].at>6e4;)this.wedge.shift();let o=r-this.wedge[0].offset;return o<25?0:o}minOffset(){return this.wedge.length>0?this.wedge[0].offset:null}hasSamples(){return this.wedge.length>0}reset(){this.wedge=[];}};var la=class{constructor(e){this.opts=e;this.timer=null;this.lastProbeAt=0;this.lastMessageAt=0;this.loopLagPeak=0;this.ticksSeen=false;this.suspended=false;this.degraded=false;this.degradedAt=0;this.cleanSince=null;this.lastSeq=null;this.seqAtGap=null;this.resumeAt=null;this.resumeSeqJump=null;this.resumeCount=0;}begin(e=Date.now()){this.lastProbeAt=e,this.lastMessageAt=e;}start(e=Date.now()){this.timer||(this.begin(e),this.timer=setInterval(()=>this.tick(Date.now()),100));}stop(){this.timer&&clearInterval(this.timer),this.timer=null;}noteMessage(e,t,r=false){let o=this.expired(t)||this.degraded;this.lastMessageAt=t,this.loopLagPeak=0,this.suspended=false,r&&(this.ticksSeen=true);let s=typeof e=="number"&&Number.isFinite(e)?e:null;o&&this.resumeAt===null&&(this.resumeAt=t,this.seqAtGap=this.lastSeq),this.resumeAt!==null&&t-this.resumeAt<=300&&(this.resumeCount++,s!==null&&this.seqAtGap!==null&&(this.resumeSeqJump=s-this.seqAtGap)),s!==null&&(this.lastSeq=s),this.degraded&&this.cleanSince===null&&(this.cleanSince=t);}reset(){this.stop(),this.lastMessageAt=0,this.loopLagPeak=0,this.ticksSeen=false,this.suspended=false,this.degraded=false,this.degradedAt=0,this.cleanSince=null,this.lastSeq=null,this.seqAtGap=null,this.resumeAt=null,this.resumeSeqJump=null,this.resumeCount=0;}tick(e){let t=Math.max(0,e-this.lastProbeAt-100);if(this.lastProbeAt=e,t>this.loopLagPeak&&(this.loopLagPeak=t),this.degraded){this.evaluateRecovery(e);return}let r=this.currentGap(e);r!==null&&(this.degraded=true,this.degradedAt=e,this.cleanSince=null,this.resumeAt=null,this.resumeSeqJump=null,this.resumeCount=0,this.opts.onVerdict({state:"degraded",scope:this.loopLagPeak>=this.opts.loopLagHighMs?"device":"network",gapMs:r,loopLagMs:this.loopLagPeak}));}currentGap(e,t=1e3){if(!this.ticksSeen||this.suspended)return null;let r=e-this.lastMessageAt;return r>=t?r:null}evaluateRecovery(e){if(e-this.degradedAt>6e4){this.suspended=true,this.clear(e);return}if(this.currentGap(e,700)!==null){this.cleanSince=null;return}this.cleanSince!==null&&e-this.cleanSince>=2500&&this.clear(e);}clear(e){this.degraded=false,this.cleanSince=null;let t=this.resumeCount>=4&&this.resumeSeqJump!==null?this.resumeSeqJump:void 0;this.opts.onVerdict({state:"ok",scope:"network",gapMs:e-this.degradedAt,...t!==void 0&&{seqJump:t}}),this.resumeAt=null,this.resumeSeqJump=null,this.resumeCount=0;}expired(e){return this.currentGap(e)!==null}};var Ci=class{constructor(){this.listeners={};}on(e,t){return this.listeners[e]||(this.listeners[e]=new Set),this.listeners[e].add(t),()=>{this.listeners[e].delete(t);}}emit(e,...t){let r=this.listeners[e];if(r)for(let o of r)o(...t);}hasListeners(e){return (this.listeners[e]?.size??0)>0}removeAll(){for(let e in this.listeners)this.listeners[e]?.clear();}};var xi=(r=>(r.Idle="idle",r.Connecting="connecting",r.Active="active",r))(xi||{}),Ri=(o=>(o.None="none",o.Loading="loading",o.Painted="painted",o.Failed="failed",o))(Ri||{}),Pi=(s=>(s.Idle="idle",s.Greeting="greeting",s.Listening="listening",s.Thinking="thinking",s.Speaking="speaking",s))(Pi||{});var bd=n=>{let e=[];return n.fieldType&&e.push(n.fieldType),n.filled!==void 0&&e.push(n.filled?"filled":"empty"),n.checked!==void 0&&e.push(n.checked?"checked":"not checked"),n.shows&&e.push(`shows "${n.shows}"`),n.choiceOf&&e.push(`choice in ${n.choiceOf}`),n.options?.length&&e.push(`one of: ${n.options.join(" | ")}`),n.submits&&e.push("submits form"),n.count&&e.push(`${n.count} identical`),n.disabled&&e.push("disabled"),n.sensitive&&e.push("never fillable"),n.path&&e.push(n.path),n.site&&e.push(n.site),n.current&&e.push("this page"),n.children&&e.push(`contains ${n.children.join(" ")}`),e},yd=n=>n.length>0?` [${n.join(", ")}]`:"",Rg=(n,e)=>{let t=e.filter(o=>o.item?.screenPosition).length,r=[`list${n.id} "${n.name}" \u2014 ${n.total} items, ${t} on screen`];for(let o of e){let s=o.item,u=bd(o);s.screenPosition&&u.unshift(`on screen #${s.screenPosition}`);let p=s.detail?` \u2014 ${s.detail}`:"";r.push(` ${s.position}. ${o.handle} ${o.kind} "${o.name}"${p}${yd(u)}`);}return r};function El(n){let e=[`On the ${n.pageName} page \u2014 ${n.url} \u2014 "${n.title}"`],t=s=>`${s.handle} ${s.kind} "${s.name}"${yd(bd(s))}`,r=n.lists??[];if(r.length===0){for(let s of n.nodes)e.push(t(s));return e.join(`
|
|
14
|
+
`)}let o=n.nodes.filter(s=>!s.item);for(let s of o)s.kind!=="link"&&e.push(t(s));for(let s of r){let u=n.nodes.filter(p=>p.item?.list===s.id).sort((p,h)=>p.item.position-h.item.position);u.length>0&&e.push(...Rg(s,u));}for(let s of o)s.kind==="link"&&e.push(t(s));return e.join(`
|
|
15
|
+
`)}function _d(n){return n.nodes.map(e=>({h:e.handle,n:e.name,...e.kind==="field"&&e.fieldType&&{t:e.fieldType},...e.sensitive&&{sensitive:true},...e.submits&&{submit:true},...e.item&&{card:{list:e.item.list,position:e.item.position,...e.item.screenPosition&&{screen:e.item.screenPosition},...e.item.detail&&{detail:e.item.detail}}}}))}var wd=n=>{let e=n?.fields;if(!Array.isArray(e))return [];let t=new Map;for(let r of e){if(t.size>=12)break;let{h:o,v:s}=r??{};typeof o!="string"||typeof s!="string"||t.set(o,s.slice(0,2e3));}return [...t].map(([r,o])=>({handle:r,value:o}))},Pg={stale:"the page changed since it was read",unknown_target:"it is not on this page",not_fillable:"it is not a box the avatar can type into",sensitive:"passwords and payment details are only theirs to type",disabled:"it is disabled right now",read_only:"it is read-only",no_such_option:"none of its choices matches",rejected:"the page would not take that value",invalid:"the site says that value is not valid"},Sd=n=>{let e=n.filter(o=>o.outcome!=="ok");if(e.length===0)return;let t=n.filter(o=>o.outcome==="ok").map(o=>`"${o.name}"`),r=e.map(o=>{let s=Pg[o.outcome];return `"${o.name}" (${s}${o.detail?`: ${o.detail}`:""})`});return [t.length>0?`filled ${t.join(", ")}`:"",`could not fill ${r.join(", ")}`].filter(Boolean).join("; ")},Ed={stale:"the page has changed since it was read",unknown_target:"that button is not on this page",not_a_submit:"that button does not send a form",disabled:"that button is disabled right now",invalid:"the form is not complete yet",requires_reload:"sending this form would open a new page and end this call, so they need to press it themselves"};var qn={camera:true,screen:false,micMute:true,endCall:true,actions:false,mood:false,page:{read:false,scroll:false,navigate:false,click:false,fill:false,submit:false}},on=(n,e)=>typeof n=="boolean"?n:e,Md=n=>{if(!n||typeof n!="object")return qn;let e=n,t=e.page&&typeof e.page=="object"?e.page:{},r=on(t.read,qn.page.read),o=r&&on(t.click,false);return {camera:on(e.camera,qn.camera),screen:on(e.screen,qn.screen),micMute:on(e.micMute,qn.micMute),endCall:on(e.endCall,qn.endCall),actions:on(e.actions,qn.actions),mood:on(e.mood,qn.mood),page:{read:r,scroll:r&&on(t.scroll,false),navigate:r&&on(t.navigate,false),click:o,fill:r&&on(t.fill,false),submit:o}}};var Ig=/^([xy])=([+-]?)(\d{1,5})(%?)$/;var Lg=n=>{let e=Ig.exec(n);if(!e)return null;let[,t,r,o,s]=e,u=Number(o);return !s&&u>2e4||s&&u>100?null:{axis:t,move:{value:r==="-"?-u:u,percent:s==="%",relative:r!==""}}},Ii=n=>{let e=n.split(",");if(e.length>2)return null;let t={};for(let r of e){let o=Lg(r.trim());if(!o||t[o.axis])return null;t[o.axis]=o.move;}return t.x||t.y?t:null};var Og=new Set(["top-left","top-center","top-right","middle-left","center","middle-right","bottom-left","bottom-center","bottom-right"]),Ng=/^bounce(?:=(.+))?$/,Dg=new Set(["forever","loop","infinite"]),Fg=5,Bg=n=>{if(n===void 0)return 1;if(Dg.has(n))return "forever";if(!/^\d{1,3}$/.test(n))return null;let e=Number(n);return e<1?null:Math.min(e,Fg)},Li=n=>{let e=n.trim().toLowerCase();if(!e)return null;if(Og.has(e))return {kind:"spot",spot:e};if(e==="expand")return {kind:"stage",open:true};if(e==="collapse")return {kind:"stage",open:false};if(e==="stop"||e==="still")return {kind:"effect",effect:"stop"};let t=Ng.exec(e);if(t){let o=Bg(t[1]);return o===null?null:{kind:"effect",effect:"bounce",times:o}}let r=Ii(e);return r?{kind:"move",...r}:null};var Ug=new Set(["search","open","new_tab","switch","close","reload"]),Vg=new Set(["search","open","switch"]);function Td(n){if(typeof n!="string")return null;let e=n.indexOf("="),t=(e<0?n:n.slice(0,e)).trim(),r=e<0?"":n.slice(e+1).trim();return !Ug.has(t)||Vg.has(t)&&!r?null:r?{action:t,target:r}:{action:t}}var zg=new Set(["CONNECTION_FAILED","SERVER_ERROR","SESSION_TOKEN_FETCH_FAILED"]),kd=1e3,Cd=1e3,Yg=50,Kg=600,qg={ok:void 0,stale:"the page has changed since it was read",unknown_target:"that place is not on this page"},Xg={ok:void 0,stale:"the page has changed since it was read",unknown_target:"that link is not on this page",not_navigable:"that is not a link on this site",requires_reload:"opening that page would end this call",already_here:"they are already on that page",no_history:"there is nowhere in this call's history to go"},Qg={ok:void 0,stale:"the page has changed since it was read",unknown_target:"that is not on this page",not_clickable:"that is not a button or field the avatar can press",submits_form:"that button submits a form, which needs a confirmed action",requires_reload:"pressing that would open a new page and end this call",disabled:"that is disabled right now"},$g=400,Jg=[300,1e3,2500],Zg=3e3,ev="the page could not be reached",tv={ok:void 0,not_found:"no open tab matches that",blocked:"that is not a web address it can open",failed:"the browser refused"},nv=1e3,xd=12e3,Ml=()=>{},rv=()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}catch{return}},Oi=n=>typeof n?.arg=="string"?n.arg:"",iv=n=>n?.arg==="tab"||n?.arg==="window"||n?.arg==="screen"?n.arg:null,Ni=n=>typeof n?.generation=="number"?n.generation:void 0,Di=class extends Error{constructor(t){super("Failed to fetch session token");this.reason=t;this.name="SessionTokenError";}},Fi=class{constructor(e,t){this.sessionPhase="idle";this.paintPhase="none";this.turnPhase="idle";this.playful={last:null,busyUntilMs:0};this.sessionId=0;this.turnId=0;this.isConnected=false;this.lifecycle=0;this.userStoppedAt=null;this.speakReportedForStop=false;this.deliveryLagMs=null;this.firstAudioAt=null;this.firstAudioLagMs=null;this.transit=new sa;this.reconnectAttempt=0;this.hasBeenLive=false;this.reconnectTimer=null;this.intentionalClose=false;this.serverInitiatedReason=null;this.lastEmittedError=null;this.noticeReceived=false;this.noticeOnly=false;this.visualState="normal";this.micMuted=false;this.speakerMuted=false;this.pushToTalk=null;this.health={ingest:"ok",stt:"ok",llm:"ok",tts:"ok",downlink:"ok"};this.downlinkScope="network";this.downlinkVerdict=null;this.netStatusLastSentAt=0;this.netStatusTimer=null;this.moodDetectionOn=false;this.moodLatest=null;this.moodLastSentKey=null;this.moodLastSentAt=0;this.moodTimer=null;this.appEvents=new ta;this.actions=new na({canDeclare:()=>this.canDeclareActions(),send:e=>this.sendActionsSet(e)});this.actionCallsSeen=new Set;this.actionFlows=new ra;this.actionsGrantWarned=false;this.actionRereadTimer=null;this.jobQueue=[];this.processing=false;this.turnOpen=false;this.scriptTail={jobId:-1,upto:0,text:""};this.activeStream=null;this.ws=null;this.micStream=null;this.micStartedAt=null;this.agcEnabled=true;this.agcRestoreTimer=null;this.events=new Ci;this.transcript=null;this.greetingText="";this.greetingLanguage="en";this.greetingKey="";this.greetingEntry=null;this.greetingDecided=false;this.greetingDecisionTimer=null;this.greetingAwaitingPlayback=false;this.greetingDelayTimer=null;this.greetingAwaitingPaint=null;this.greetingPaintTimer=null;this.greetingAwaitingMic=null;this.greetingMicTimer=null;this.micPipelineSettled=false;this.talkingArmed=false;this.playerLeadInTimer=null;this.connectTonePlaying=false;this.connectToneTimer=null;this.connectToneStartedAt=null;this.tonePainted=false;this.toneSessionLive=false;this.greetingPlayed=false;this.skipGreetingOnce=false;this.greetedThisSession=false;this.jobCounter=0;this.riveReady=false;this.avatarConfig=null;this.serverReady=false;this.voiceSettings=null;this.watermark=false;this.lipSyncTuning=new xn;this.rivSrc=null;this.pendingRivBytes=null;this.pendingSession=false;this.pendingContext=[];this.lastContextSnapshot=null;this.firstPage=null;this.pageGeneration=0;this.lastPageContext=null;this.pageReadThisUtterance=false;this.pageWork=Promise.resolve();this.pageSession=0;this.heardSpeech=null;this.pendingTours=new Map;this.tourRequestSeq=0;this.sessionCapabilities=null;this.initAckPromise=null;this.initAckResolve=null;this.initAckReject=null;this.loadInFlight=null;this.startInvoked=false;this.utteranceBuffer={audio:[],alignments:[],displayAlignments:[],visemes:[],flushTimer:null};this.firstChunkPending=true;this.responseSlow=false;this.heldResumeToken=null;this.stopCount=0;this.mountSurface="inline";this.load=()=>this.serverReady?Promise.resolve():this.loadInFlight?this.loadInFlight:(this.loadInFlight=this.runLoad().finally(()=>{this.loadInFlight=null;}),this.loadInFlight);this.runLoad=async()=>{let e=this.lifecycle;this.setPaintPhase("loading");try{if(this.mode==="player")await this.paintFromCache(e)?this.revalidatePaint(e):await this.fetchRenderConfig(e);else {let t=await this.paintFromCache(e);this.mode==="call"&&!this.startInvoked&&(t?await this.revalidatePaint(e):await this.fetchRenderConfig(e));}}catch(t){if(this.stale(e))return;if(E.error("Runtime","Avatar load failed",t),this.setPaintPhase("failed"),t instanceof ki&&Sl(t.serverCode,t.serverMessage)){this.emitError("DOMAIN_NOT_ALLOWED","This page's domain is not in the deployment's authorised domains","server",{cause:t});return}let r=t instanceof Di;this.emitError(r?"SESSION_TOKEN_FETCH_FAILED":"AVATAR_LOAD_FAILED",r?"Failed to fetch session token":"Failed to load avatar","sdk",{cause:r?t.reason:t});return}this.stale(e)||this.mode!=="call"&&this.start();};this.start=async()=>{let e=this.lifecycle,t=this.stopCount;if(this.cancelReconnect(),this.startInvoked=true,this.lastEmittedError=null,this.startConnectTone(),this.mode!=="player"&&this.setSessionPhase("connecting"),await this.load(),!this.stale(e)){if(this.paintPhase==="failed"){this.setSessionPhase("idle");return}if(this.mode==="player"){this.setSessionPhase("active");return}try{(!this.ws||this.ws.readyState===WebSocket.CLOSED)&&await this.openWebSocket();let r=this.ws;if(this.staleSocket(e,r)||(this.initAckPromise&&(E.debug("Runtime","Waiting for server to acknowledge init..."),await this.initAckPromise),this.staleSocket(e,r))||this.noticeOnly)return;this.ws?.send(JSON.stringify({type:"start"}));}catch(r){if(this.stopCount!==t&&!this.lastEmittedError||(!this.stale(e)&&this.paintPhase!=="painted"&&this.setPaintPhase("failed"),this.lastEmittedError))return;if(r instanceof Di){this.emitError("SESSION_TOKEN_FETCH_FAILED","Failed to fetch session token","sdk",{cause:r.reason});return}this.emitError("UNKNOWN","Unexpected runtime error","sdk",{cause:r});}}};this.paintFromCache=async e=>{let[t,r]=await Promise.all([this.cache.getCachedRiv(this.avatarId),this.cache.getCachedAvatarConfig(this.avatarId)]);if(this.stale(e))return false;if(this.cachedConfigVersion=r?.configVersion,this.cachedRivVersion=t?.rivVersion,t&&r){let o=await this.urlResolver.bytesToSrc(t.bytes);return this.stale(e)?(this.urlResolver.revokeSrc(o),false):(this.rivSrc&&this.urlResolver.revokeSrc(this.rivSrc),this.rivSrc=o,this.avatarConfig={...r,rive:{...r.rive,src:o}},this.pendingRivBytes=t.bytes,this.serverReady=true,this.onRivReady(),true)}return t&&(this.pendingRivBytes=t.bytes),false};this.resolveSessionToken=async()=>{try{let e=await this.getSessionToken();if(!e)throw new Error("getSessionToken() returned an empty token");return e}catch(e){throw new Di(e)}};this.fetchRenderConfig=async e=>{let t={"Content-Type":"application/json"},r={avatarId:this.avatarId,...this.embedHostOrigin&&{hostOrigin:this.embedHostOrigin},needAvatarStream:!this.pendingRivBytes,...this.cachedConfigVersion!==void 0&&{cachedConfigVersion:this.cachedConfigVersion},...this.cachedRivVersion!==void 0&&{cachedRivVersion:this.cachedRivVersion}},o="";this.deployId?o=this.deployId:this.getSessionToken?o=await this.resolveSessionToken():this.apiKey&&(o=this.apiKey),t.Authorization=`Bearer ${o}`;let s=await fetch(`${this.httpUrl}/v1/avatar/config`,{method:"POST",headers:t,body:JSON.stringify(r)});if(!s.ok)throw new ki(s.status,await s.json().catch(()=>null));let u=await s.json();if(this.serverReady)return this.repaintFromPayload(u,e);let p=u.rivUrl?await this.fetchRivBytes(u.rivUrl):this.pendingRivBytes;if(!p)throw new Error("config response had no rivUrl and no cache");await this.applyRenderPayload(u,p,e);};this.paintForNotice=async()=>{let e=this.lifecycle;try{E.info("Runtime","notice with nothing painted \u2014 resolving config"),await this.fetchRenderConfig(e);}catch(t){if(this.stale(e))return;E.error("Runtime","Notice paint failed \u2014 notice will be silent",t),this.setPaintPhase("failed");}};this.revalidatePaint=async e=>{try{await this.fetchRenderConfig(e);}catch(t){E.warn("Runtime","Revalidation failed \u2014 keeping the cached paint",t);}};this.repaintFromPayload=async(e,t)=>{let r=e.rivUrl?await this.fetchRivBytes(e.rivUrl):null;if(e.rivUrl&&!r&&E.warn("Rive","New rig failed to download \u2014 keeping the painted one"),r)return this.applyRenderPayload(e,r,t);if(this.stale(t))return;let o=e.watermark===true!==this.watermark;this.watermark=e.watermark===true;let s=e.configVersion!==void 0&&e.configVersion!==this.avatarConfig?.configVersion,u=JSON.stringify(Qo(e.performance)??null)!==JSON.stringify(this.avatarConfig?.performance??null);!s&&!o&&!u||(this.avatarConfig=this.paintedConfigFrom(e,this.rivSrc),this.cachedConfigVersion=e.configVersion,e.rivVersion!==void 0&&(this.cachedRivVersion=e.rivVersion),(s||u)&&e.cacheable!==false&&this.cache.setCachedAvatarConfig(this.avatarId,this.toCacheableConfig(this.avatarConfig)).catch(()=>{}),this.onRivReady());};this.applyRenderPayload=async(e,t,r)=>{let o=await this.urlResolver.bytesToSrc(t);if(this.stale(r))return this.urlResolver.revokeSrc(o);this.watermark=e.watermark===true,this.cachedConfigVersion=e.configVersion,this.cachedRivVersion=e.rivVersion,this.rivSrc&&this.urlResolver.revokeSrc(this.rivSrc),this.rivSrc=o,this.avatarConfig=this.paintedConfigFrom(e,this.rivSrc),this.serverReady=true,e.cacheable!==false&&(e.rivVersion!==void 0&&this.cache.setCachedRiv(this.avatarId,t,e.rivVersion).catch(()=>{}),this.cache.setCachedAvatarConfig(this.avatarId,this.toCacheableConfig(this.avatarConfig)).catch(()=>{})),this.pendingRivBytes=t,this.onRivReady();};this.setMountSurface=e=>{this.mountSurface=e;};this.getLipSyncTuning=()=>this.lipSyncTuning;this.speakAudio=async e=>{if(this.mode!=="audio"){this.emitError("INVALID_MODE","speakAudio can only be used in audio mode","sdk",{fatal:false});return}if(this.ws?.readyState!==WebSocket.OPEN){this.emitError("NOT_CONNECTED","speakAudio() needs a live session \u2014 call start() first","sdk",{fatal:false});return}try{let t;e instanceof Blob?t=await e.arrayBuffer():e instanceof Float32Array?t=e.buffer:t=e;let r=15*1024*1024;if(t.byteLength>r){this.emitError("INVALID_INPUT","Audio payload too large (max 15MB)","sdk",{fatal:!1});return}this.ws?.send(t);}catch(t){this.emitError("UNKNOWN","Failed to process audio payload","sdk",{cause:t,fatal:false});}};this.isPushToTalk=()=>this.turnTaking==="push-to-talk";this.isTalking=()=>this.pushToTalk?.isHeld()??false;this.startTalking=()=>{this.pushToTalk&&this.sessionPhase==="active"&&(this.noticeReceived||this.pushToTalk.press());};this.stopTalking=()=>{this.pushToTalk?.release();};this.setMicMuted=e=>{this.micMuted!==e&&(this.micMuted=e,this.queueClientNetStatus(),this.events.emit("mic-muted",e));};this.setSpeakerMuted=e=>{this.speakerMuted!==e&&(this.speakerMuted=e,this.events.emit("speaker-muted",e));};this.getMicMuted=()=>this.micMuted;this.getSpeakerMuted=()=>this.speakerMuted;this.commandHandlers={stop:e=>{this.cancelSpeech(),this.reportCommandStatus("stop",this.commandTurnId(e),"ok");},request_vision:e=>{this.events.emit("vision-request",this.commandTurnId(e));},flip_camera:e=>{let t=typeof e?.args=="string"?e.args:null,r=t==="front"?"front":t==="back"?"back":"toggle";this.events.emit("camera-flip",r,this.commandTurnId(e));},mute_mic:e=>{if(this.environment==="meeting"){this.reportCommandStatus("mute_mic",this.commandTurnId(e),"unsupported");return}this.setMicMuted(true),this.reportCommandStatus("mute_mic",this.commandTurnId(e),"ok");},unmute_mic:e=>{this.setMicMuted(false),this.reportCommandStatus("unmute_mic",this.commandTurnId(e),"ok");},close_camera:e=>{this.events.emit("camera-close",this.commandTurnId(e));},open_camera:e=>{this.events.emit("camera-open",this.commandTurnId(e));},request_screen:e=>{let t=this.commandTurnId(e);if(!this.capabilities?.screen){this.reportScreenStatus("unavailable",t,{reason:"not granted"});return}if(!this.perception?.screen||!this.events.hasListeners("screen-request")){this.reportScreenStatus("unavailable",t,{reason:"screen sharing is not enabled here"});return}this.events.emit("screen-request",iv(e),t);},stop_screen:e=>{let t=this.commandTurnId(e);if(!this.events.hasListeners("screen-stop")){this.reportCommandStatus("stop_screen",t,"unsupported");return}this.events.emit("screen-stop",t);},scroll_to:e=>this.runPageCommand("scroll_to",e,t=>t.scroll,async(t,r)=>{let o=await t.scroll(Oi(e),Ni(e));this.reportCommandStatus("scroll_to",r,o==="ok"?"ok":"failed",qg[o]);}),navigate_to:e=>this.runPageCommand("navigate_to",e,t=>t.navigate,async(t,r)=>{let o=await t.navigate(Oi(e),Ni(e));this.reportCommandStatus("navigate_to",r,o==="ok"?"ok":"failed",Xg[o]);}),click_element:e=>this.runPageCommand("click_element",e,t=>t.click,async(t,r)=>{let o=await t.click(Oi(e),Ni(e));this.reportCommandStatus("click_element",r,o==="ok"?"ok":"failed",Qg[o]),o==="ok"&&this.scheduleReadAfterAction();}),fill_fields:e=>this.runPageCommand("fill_fields",e,t=>t.fill,async(t,r)=>{let o=wd(e);if(o.length===0){this.reportCommandStatus("fill_fields",r,"failed","there was nothing to fill");return}let s=await t.fill(o,Ni(e)),u=Sd(s);E.event("page","Fields filled",{fields:s.map(p=>`${p.handle}:${p.outcome}`)}),this.reportCommandStatus("fill_fields",r,u?"failed":"ok",u),s.some(p=>p.outcome==="ok")&&this.scheduleReadAfterAction();}),submit_form:e=>this.runPageCommand("submit_form",e,t=>t.submit,async(t,r)=>{let{outcome:o,detail:s}=await t.submit(Oi(e),Ni(e)),u=o==="ok"?void 0:`${Ed[o]}${s?`: ${s}`:""}`;this.reportCommandStatus("submit_form",r,o==="ok"?"ok":"failed",u),o==="ok"&&this.scheduleReadAfterAction();}),widget_control:e=>{let t=this.commandTurnId(e);if(this.mountSurface!=="widget"){this.reportCommandStatus("widget_control",t,"unsupported","the avatar is not in a widget here");return}let r=Li(Oi(e));if(!r){this.reportCommandStatus("widget_control",t,"failed","that is not somewhere the avatar can put itself");return}this.events.emit("widget-command",r,t);},browser:e=>{let t=this.commandTurnId(e),r=this.browser;if(!r){this.reportCommandStatus("browser",t,"unsupported","this client cannot drive the browser");return}let o=Td(e?.arg);if(!o){this.reportCommandStatus("browser",t,"failed","that is not a browser command");return}Promise.resolve().then(()=>r.run(o)).catch(s=>(E.warn("Runtime","browser command threw",{error:String(s)}),"failed")).then(s=>this.reportCommandStatus("browser",t,s==="ok"?"ok":"failed",tv[s]));},close_call:e=>{this.reportCommandStatus("close_call",this.commandTurnId(e),"ok"),this.stop({intentionalClose:true,code:4001,reason:"Closed by server command"});}};this.loadCachedGreeting=async()=>{if(!(!this.greeting?.enabled||this.greetingEntry))try{let e=await this.cache.getCachedGreeting(this.greetingKey);if(!e)return;this.greetingEntry=e,this.sentGreetingId=e.greetingId,E.debug("Greeting","Loaded greeting from cache",{greetingId:e.greetingId});}catch{}};this.openWebSocket=async()=>{if(!this.wsUrl)throw new Error("WebSocket URL not resolved");if(this.ws&&this.ws.readyState===WebSocket.OPEN)return;if(!this.pendingRivBytes){let t=await this.cache.getCachedRiv(this.avatarId);this.pendingRivBytes=t?.bytes??null,this.cachedRivVersion=t?.rivVersion;}await this.loadCachedGreeting();let e=this.getSessionToken?await this.resolveSessionToken():void 0;return this.initAckPromise=new Promise((t,r)=>{this.initAckResolve=t,this.initAckReject=r;}),new Promise((t,r)=>{try{let o=new WebSocket(this.wsUrl);this.ws=o,o.binaryType="arraybuffer",o.onopen=()=>{if(this.ws!==o)return;E.event("WebSocket","Connection opened"),this.intentionalClose=!1,this.serverInitiatedReason=null;let s=rv();o.send(JSON.stringify({type:"init",...this.deployId?{deployId:this.deployId,...this.embedHostOrigin&&{hostOrigin:this.embedHostOrigin}}:{avatarId:this.avatarId,...e?{sessionToken:e}:{apiKey:this.apiKey}},...this.onResumeState&&{resumable:!0},...this.resumeKept&&{resume:this.resumeKept},...this.voiceSettings&&{voiceSettings:this.voiceSettings},...this.brain&&{brain:this.brain},...this.languages!==void 0&&{languages:this.languages},...this.perception&&{perception:{...this.perception,...this.readsMood&&{mood:!0}}},...this.greeting?.enabled&&{greeting:{enabled:!0,...this.greetingText&&{message:this.greetingText},language:this.greetingLanguage,...this.sentGreetingId&&{cachedGreetingId:this.sentGreetingId}}},...this.useOwnVoice!==void 0&&{useOwnVoice:this.useOwnVoice},...this.useOwnBrain!==void 0&&{useOwnBrain:this.useOwnBrain},mode:this.mode,turnTaking:this.turnTaking,systemPrompt:this.systemPrompt,needAvatarStream:!this.pendingRivBytes,...this.cachedConfigVersion!==void 0&&{cachedConfigVersion:this.cachedConfigVersion},...this.cachedRivVersion!==void 0&&{cachedRivVersion:this.cachedRivVersion},...this.platform&&{platform:this.platform},...this.browser&&{browser:!0},surface:this.mountSurface,...this.framed!==void 0&&{framed:this.framed},...this.micBlocked()&&{micBlocked:!0},...s&&{timeZone:s}})),t();},o.onmessage=s=>{this.ws===o&&this.handleServerMessage(s);},o.onclose=s=>{if(this.ws!==o){E.debug("WebSocket","Ignoring onclose \u2014 already handled");return}let u=this.intentionalClose,p=this.serverInitiatedReason;if(this.isConnected=!1,this.events.emit("connection-status",!1),p)E.info("WebSocket","Closed following server message",{...p});else if(s.code===vu)E.info("WebSocket","Meeting ended; closed by the server");else if(s.code===Au)E.info("WebSocket","A newer session took over this meeting");else if(u)E.info("WebSocket","Connection closed gracefully");else {let{code:h,message:A}=this.classifyClose(s);this.emitError(h,A,"network",{cause:s?.reason});}this.ws=null,this.intentionalClose=!1,this.serverReady=!1,this.rejectInitAck("WebSocket closed before init acknowledged"),this.stop();},o.onerror=s=>{if(this.ws!==o)return;let u=this.intentionalClose,p=this.serverInitiatedReason;p?E.info("WebSocket","Transport error after server message",{...p}):u?E.info("WebSocket","Transport error during intentional close"):this.emitError("CONNECTION_FAILED","Transport error on the connection to the avatar service","network",{cause:s}),this.ws=null,this.isConnected=!1,this.events.emit("connection-status",!1),this.intentionalClose=!1,this.serverReady=!1,this.rejectInitAck("WebSocket error before init acknowledged"),this.stop(),r(s);};}catch(o){this.emitError("CONNECTION_FAILED","Could not open a connection to the avatar service","network",{cause:o}),r(o);}})};this.onRivReady=async()=>{if(!this.avatarConfig)return;this.setPaintPhase("painted");let e=this.avatarConfig.rive,t=this.voiceSettings?.visimeMs;this.lipSyncTuning.reset(this.avatarConfig.lipSync),this.lipSyncTuning.apply(this.voiceSettings?.lipSync),E.event("Runtime","lip-sync tuning seeded",{configVersion:this.avatarConfig.configVersion,fromConfig:!!this.avatarConfig.lipSync,overridden:!!this.voiceSettings?.lipSync,...this.lipSyncTuning.snapshot()}),this.events.emit("avatar-config",{...this.avatarConfig,rive:{...e,src:this.rivSrc,watermark:this.watermark},lipSync:{...this.avatarConfig.lipSync,...t!==void 0?{visemeMs:t}:{}}}),this.pendingSession&&(this.pendingSession=false,E.info("Runtime","Riv ready \u2014 starting deferred session"),this.startSession());};this.micBlocked=()=>this.mode==="call"&&this.usesDefaultMic&&!Pu();this.startMic=async()=>{let e=this.ws;if(this.micBlocked())return this.emitError("MIC_PERMISSION_DENIED","This page does not allow the microphone","sdk"),false;let t;try{t=await this.getMicStreamFn();}catch(r){return this.emitError("MIC_PERMISSION_DENIED","Microphone permission denied","sdk",{cause:r}),false}return this.ws!==e||e?.readyState!==WebSocket.OPEN?(E.warn("Runtime","session closed while awaiting mic \u2014 releasing it"),t.getTracks().forEach(r=>r.stop()),false):(this.micStream=t,this.micPipelineSettled=false,this.micStartedAt=Date.now(),this.agcEnabled=true,this.events.emit("mic-start",this.micStream),true)};this.setAgcForAvatarSpeech=e=>{if(!(!this.micStream||this.environment==="meeting")){if(this.agcRestoreTimer!==null&&(clearTimeout(this.agcRestoreTimer),this.agcRestoreTimer=null),e){this.applyAgc(false);return}this.agcRestoreTimer=setTimeout(()=>{this.agcRestoreTimer=null,this.applyAgc(true);},Kg);}};this.fetchRivBytes=async(e,t=false)=>{try{let r=await fetch(e);if(!r.ok)throw new Error(`HTTP ${r.status}`);return await r.arrayBuffer()}catch(r){return t?(E.error("Rive","Riv fetch failed after retry",{cause:r}),null):(E.warn("Rive","Riv fetch failed \u2014 retrying once",{cause:r}),this.fetchRivBytes(e,true))}};let r=Si(e);if(this.environment=r.environment,this.environment==="meeting"&&(this.lipSyncTuning.maxStepFrames=Eu),r.debug&&E.setLogLevel(0),E.debug("Runtime","Initializing with config",r),this.mode=r.mode||"call",this.turnTaking=this.mode==="call"&&r.turnTaking?.mode==="push-to-talk"?"push-to-talk":"auto",this.turnTaking==="push-to-talk"&&(this.pushToTalk=new aa({onTurnStart:()=>this.openUserTurn(),onTurnEnd:()=>this.closeUserTurn(),onHeldChange:o=>this.events.emit("ptt-held",o)})),this.greeting=t.embedResume?.kept?void 0:r.avatar?.greeting,this.connectTone=t.embedResume?.kept?void 0:r.connectTone,this.avatarId=r.avatar?.avatarId||"default",this.systemPrompt=r.avatar?.systemPrompt,this.apiKey=r.apiKey,this.getSessionToken=r.getSessionToken,this.deployId=r.deployId,this.voiceSettings=r.avatar?.voiceSettings||null,!this.apiKey&&!this.getSessionToken&&!this.deployId)throw new Error("AvatarConfig requires apiKey, getSessionToken, or deployId");this.useOwnVoice=r.avatar?.voiceSettings?.useOwnVoice,this.useOwnBrain=r.avatar?.brain?.useOwnBrain,this.brain=r.avatar?.brain,this.languages=r.avatar?.languages,this.perception=r.perception,this.readsMood=this.mode==="call"&&!!r.perception?.camera&&!!t.readsMood,this.wsUrl=Vs(),this.httpUrl=Ws(),this.greeting?.enabled&&(this.greetingLanguage=this.greeting.language??"en",this.greetingText=this.greeting.message?fl(this.greeting.message):"",this.greetingKey=pl(this.avatarId,this.greetingLanguage,this.greetingText)),r.transcript?.enabled&&(this.transcript=new oa(o=>this.events.emit("transcript",o),r.transcript.maxEntries)),this.cache=t.cache,this.urlResolver=t.urlResolver,this.pageSurface=t.pageSurface,this.browser=t.browser,this.pageBeforeLive=t.pageBeforeLive??false,this.reportsMicPipeline=t.reportsMicPipeline??false,this.usesDefaultMic=!t.getMicStream,this.getMicStreamFn=t.getMicStream??(async()=>{let o=await navigator.mediaDevices.getUserMedia({audio:this.environment==="meeting"?wu:{echoCancellation:true,noiseSuppression:true,autoGainControl:false,channelCount:1}});return E.event("mic","settings",{...o.getAudioTracks()[0]?.getSettings()}),o}),this.platform=t.platform,this.framed=t.framed,this.embedHostOrigin=t.embedHostOrigin,this.onResumeState=t.embedResume?.onState,this.resumeKept=t.embedResume?.kept,this.downlinkWatchdog=new la({loopLagHighMs:this.platform?500:250,onVerdict:o=>this.applyDownlinkVerdict(o)});}paintedConfigFrom(e,t){return {avatarId:e.avatarId,configVersion:e.configVersion,pipelineMode:e.pipelineMode,rive:{...e.rive??{artboard:"",stateMachine:"",layout:{}},src:t},lipSync:e.lipSync,performance:Qo(e.performance)??void 0}}toCacheableConfig(e){return {...e,rive:{...e.rive,src:"",watermark:void 0}}}async startSession(){if(this.isConnected||(this.resetHealth(),this.mode==="call"&&!this.noticeOnly&&!await this.startMic()))return;if(this.pageBeforeLive&&this.firstPage){let t=this.pageSession;if(await Promise.race([this.firstPage,new Promise(r=>setTimeout(r,Zg))]),t!==this.pageSession)return}if(this.isConnected=true,this.downlinkWatchdog.start(),this.mode==="call"&&!this.noticeOnly&&this.queueClientNetStatus(),this.pushToTalk&&this.sendClientVadStatus(true,"push_to_talk"),this.events.emit("connection-status",true),this.heldResumeToken&&this.onResumeState?.(this.heldResumeToken),this.heldResumeToken=null,this.setSessionPhase("active"),this.reconnectAttempt=0,this.hasBeenLive=true,this.markToneSessionLive(),this.noticeOnly)return;this.actions.syncNow(),this.greetingPlayed=false;let e=this.skipGreetingOnce;if(this.skipGreetingOnce=false,this.greetedThisSession=!!this.greeting?.enabled&&!e,!this.greeting?.enabled||e){this.greetingPlayed=e,this.enterListening();return}if(!this.playGreeting()){if(!this.greetingDecided){this.greetingAwaitingPlayback=true,this.setTurnPhase("greeting"),this.armGreetingBackstop();return}this.enterListening();}}stop(e={intentionalClose:false}){this.stopCount++,e.intentionalClose&&(this.intentionalClose=true,this.cancelReconnect()),this.teardownSession(e.code,e.reason,true),this.setSessionPhase("idle");}scheduleReconnect(e){if(this.environment!=="meeting"||this.reconnectTimer||!zg.has(e.code))return;let t=_u[this.reconnectAttempt];if(t===void 0){E.warn("Runtime","Meeting reconnect attempts exhausted",{attempts:this.reconnectAttempt});return}this.reconnectAttempt++,E.event("session","reconnect_scheduled",{attempt:this.reconnectAttempt,delayMs:t,code:e.code}),this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.hasBeenLive&&this.skipNextGreeting(),this.start();},t);}cancelReconnect(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null);}setLipSyncTuning(e){this.lipSyncTuning.apply(e);}speakText(e){try{if(this.mode!=="tts"){this.emitError("INVALID_MODE","speakText() is only available in text mode","sdk",{fatal:!1});return}if(!e.trim()){this.emitError("INVALID_INPUT","speakText() needs non-empty text","sdk",{fatal:!1});return}if(e.length>5e3){this.emitError("INVALID_INPUT","Text too long (max 5000 chars)","sdk",{fatal:!1});return}if(this.ws?.readyState!==WebSocket.OPEN){this.emitError("NOT_CONNECTED","speakText() needs a live session \u2014 call start() first","sdk",{fatal:!1});return}this.ws?.send(JSON.stringify({type:"input",payload:{text:e}}));}catch(t){this.emitError("UNKNOWN","Unexpected error in speakText()","sdk",{cause:t,fatal:false});}}addLiveContext({context:e,update:t}){if(!e||e.trim().length===0){this.emitError("INVALID_INPUT","Context cannot be empty","sdk",{fatal:false});return}if(e.length>2e3){this.emitError("INVALID_INPUT","Context too long (max 2000 chars)","sdk",{fatal:false});return}let r=e.trim();if(!(!t&&r===this.lastContextSnapshot)){if(t||(this.lastContextSnapshot=r),this.ws?.readyState!==WebSocket.OPEN||!this.sessionCapabilities){t||(this.pendingContext=[]),this.pendingContext.push({context:r,update:t}),this.pendingContext.length>16&&this.pendingContext.shift();return}this.sendLiveContext(r,t);}}get capabilities(){return this.sessionCapabilities}pageSendSkipReason(e){return this.mode!=="call"?"wrong_mode":this.ws?.readyState!==WebSocket.OPEN?"no_session":this.capabilities?.page.read?e===this.lastPageContext?"unchanged":null:"not_granted"}skipNextGreeting(){this.skipGreetingOnce=true;}async requestTour(){if(!this.isConnected||!this.ws)return null;let e=await this.readPage();if(!e||e.reason==="not_granted"||e.reason==="wrong_mode"||e.reason==="no_session")return E.warn("Runtime","requestTour(): the page cannot be sent",{reason:e?.reason??"no_page_surface"}),null;let t=`t${++this.tourRequestSeq}`;return new Promise(r=>{let o=u=>{clearTimeout(s),this.pendingTours.delete(t),r(u);},s=setTimeout(()=>o(null),Cu);this.pendingTours.set(t,o),this.ws?.send(JSON.stringify({type:"tour_request",requestId:t,greeted:this.greetedThisSession}));})}async sendFirstPage(){if(!this.pageSurface||!this.capabilities?.page.read)return;let e=this.pageSession;for(let t of [...Jg,null]){let r=await this.readPage();if(r?.sent||this.pageGeneration>0||e!==this.pageSession||r)return;if(t===null){E.warn("Runtime","The page never answered at call start; waiting for a change");return}if(E.warn("Runtime","First page read reached no page \u2014 retrying",{delayMs:t}),await new Promise(o=>setTimeout(o,t)),e!==this.pageSession)return}}readPage(){let e=this.pageSurface;return e?this.queuePageWork(()=>this.readPageNow(e)):(E.debug("Runtime","readPage(): no page surface on this platform"),Promise.resolve(null))}async readPageNow(e){let t=this.pageSession;try{let r=this.pageGeneration+1,o=await e.read(r);if(!o)return null;let s=El(o),u=o.unreadable?`${s} (${o.unreadable})`:s,p=t===this.pageSession?this.pageSendSkipReason(u):"no_session";return p?(await e.retag(this.pageGeneration),o.generation=this.pageGeneration):(this.pageGeneration=r,this.lastPageContext=u,this.ws?.send(JSON.stringify({type:"page_context",context:s,url:o.url,generation:o.generation,handles:_d(o),...o.covered&&{covered:o.covered},...o.unreadable&&{unreadable:o.unreadable}}))),E.event("page","Page read",{generation:o.generation,page:o.pageName,pageNamedBy:o.pageNamedBy,nodes:o.nodes.length,unnamed:Object.values(o.unnamed).reduce((h,A)=>h+A,0),characters:s.length,sent:!p,...p&&{reason:p}}),{index:o,context:s,sent:!p,...p&&{reason:p}}}catch(r){return this.emitError("UNKNOWN","Failed to read the host page","sdk",{cause:r,fatal:false}),null}}queuePageWork(e){let t=this.pageWork.then(e,e);return this.pageWork=t.catch(()=>{}),t}sendLiveContext(e,t){try{this.ws?.send(JSON.stringify({type:"live_context",context:e,update:t}));}catch(r){this.emitError("UNKNOWN","Failed to send live context","sdk",{cause:r,fatal:false});}}flushPendingContext(){if(this.pendingContext.length===0)return;let e=this.pendingContext;this.pendingContext=[];for(let t of e)this.sendLiveContext(t.context,t.update);}notify(e){try{if(this.mode==="player"){this.emitError("INVALID_MODE","notify() needs a session \u2014 player mode never opens a socket","sdk",{fatal:!1});return}let t=this.appEvents.validate(e);if(!t.ok){this.emitError("INVALID_INPUT",t.message,"sdk",{fatal:!1});return}let r=e.policy??"idle_only";if(!(this.ws?.readyState===WebSocket.OPEN)&&r!=="context_only"){E.event("app","Event dropped",{name:e.name,reason:"no_session"});return}let s=e.cooldownMs??5e3,u=this.appEvents.admit(e.name,s,Date.now());if(!u.ok){E.event("app","Event dropped",{name:e.name,reason:u.reason});return}if(r==="context_only"){this.addLiveContext({context:t.data?`${e.name}: ${t.data}`:e.name,update:!0});return}this.ws?.send(JSON.stringify({type:"app_event",name:e.name,data:t.data,policy:r,say:e.say})),E.event("app","Event sent",{name:e.name,policy:r});}catch(t){this.emitError("UNKNOWN","Unexpected error in notify()","sdk",{cause:t,fatal:false});}}registerAction(e){try{if(this.mode!=="call")return this.emitError("INVALID_MODE","registerAction() needs call mode \u2014 only a call can confirm an action","sdk",{fatal:!1}),Ml;let t=this.actions.register(e);return t.ok?t.unregister:(this.emitError("INVALID_INPUT",t.message,"sdk",{fatal:!1}),Ml)}catch(t){return this.emitError("UNKNOWN","Unexpected error in registerAction()","sdk",{cause:t,fatal:false}),Ml}}canDeclareActions(){if(this.ws?.readyState!==WebSocket.OPEN)return false;let e=this.capabilities;return e?e.actions?true:(this.actions.size>0&&!this.actionsGrantWarned&&(this.actionsGrantWarned=true,E.warn("Runtime","actions not granted for this avatar",{registered:this.actions.size})),false):false}sendActionsSet(e){try{return this.ws?.send(JSON.stringify({type:"actions_set",actions:e})),E.event("action","Actions declared",{names:e.map(t=>t.name)}),!0}catch(t){return E.warn("Runtime","failed to send actions_set",{err:t}),false}}async handleActionRun(e){let t=typeof e?.callId=="string"?e.callId:"",r=typeof e?.name=="string"?e.name:"";if(!t){E.warn("Runtime","action_run without a callId cannot be answered",{name:r});return}if(this.actionCallsSeen.has(t)){E.warn("Runtime","duplicate action_run ignored",{callId:t,name:r});return}this.actionCallsSeen.add(t);let o=this.ws,s=Date.now();E.event("action","Action run",{callId:t,name:r});let u=await this.runAction(t,r,e.args);if(E.event("action","Action result",{callId:t,name:r,ok:u.ok,ms:Date.now()-s}),o===null||o!==this.ws||o.readyState!==WebSocket.OPEN){E.warn("Runtime","action_result not sent: the session ended mid-run",{callId:t,name:r,ok:u.ok});return}try{o.send(JSON.stringify({type:"action_result",callId:t,...u}));}catch(p){E.warn("Runtime","failed to send action_result",{callId:t,err:p});}}async runAction(e,t,r){let o=this.actions.get(t);if(!o)return E.warn("Runtime","action_run for an unregistered action",{name:t}),{ok:false,error:pr.unavailable};let s=ud(o.declaration,r);if(!s)return E.warn("Runtime","action_run args do not match the declaration",{name:t,params:Object.keys(o.declaration.params)}),{ok:false,error:pr.invalidArgs};let u=new AbortController,p=Promise.resolve().then(()=>o.handler(s,{callId:e,signal:u.signal})).then(A=>{let y=dd(A);return y||(E.warn("Runtime","action handler returned no { ok } result",{name:t}),{ok:false,error:pr.failed})},A=>(E.error("Runtime","action handler threw",{name:t,err:A}),{ok:false,error:pr.failed})),h=new Promise(A=>{let y=setTimeout(()=>{u.abort(),E.warn("Runtime","action handler timed out",{name:t,timeoutMs:xd}),A({ok:false,error:pr.timedOut});},xd);p.then(()=>clearTimeout(y));});return Promise.race([p,h])}getActionFlow(){return this.actionFlows.flow}sendActionUi(e,t,r){let o=this.ws;if(!o||o.readyState!==WebSocket.OPEN)return this.emitError("NOT_CONNECTED","sendActionUi() needs a live session","sdk",{fatal:false}),false;let s=this.actionFlows.isLive?this.actionFlows.flow:null,u;if(e==="input"){let p=s?.name??r??"",h=this.actions.get(p),A=h?hd(h.declaration,t??{}):{ok:false,message:`no registered action "${p}"`};if(!A.ok)return this.emitError("INVALID_INPUT",`sendActionUi(): ${A.message}`,"sdk",{fatal:false}),false;u={type:"action_ui",op:e,...s?{actionId:s.actionId}:{name:p},args:A.args};}else {if(!s)return this.emitError("INVALID_INPUT",`sendActionUi("${e}") needs an action in progress`,"sdk",{fatal:false}),false;u={type:"action_ui",op:e,actionId:s.actionId,revision:s.revision};}try{return o.send(JSON.stringify(u)),E.event("action","Action UI sent",{op:e,actionId:s?.actionId,params:t?Object.keys(t):[]}),!0}catch(p){return E.warn("Runtime","failed to send action_ui",{op:e,err:p}),false}}handleActionState(e){let t=pd(e);if(!t){E.warn("Runtime","action_state ignored: not a flow");return}this.actionFlows.apply(t)&&(E.event("action","Action flow",{actionId:t.actionId,name:t.name,stage:t.stage,revision:t.revision,awaiting:t.awaiting?.kind??null}),this.events.emit("action-flow",t));}async handleActionCheck(e){let t=typeof e?.checkId=="string"?e.checkId:"",r=typeof e?.name=="string"?e.name:"",o=typeof e?.param=="string"?e.param:"";if(!t){E.warn("Runtime","action_check without a checkId cannot be answered",{name:r});return}let s=this.ws,u=e?.args&&typeof e.args=="object"&&!Array.isArray(e.args)?e.args:{},p=await md(this.actions.get(r)?.check,o,e?.value,u);if(E.event("action","Action check answered",{checkId:t,name:r,param:o,ok:p.ok,unverified:p.unverified===true}),s===null||s!==this.ws||s.readyState!==WebSocket.OPEN){E.warn("Runtime","action_check_result not sent: the session ended",{checkId:t});return}try{s.send(JSON.stringify({type:"action_check_result",checkId:t,...p}));}catch(h){E.warn("Runtime","failed to send action_check_result",{checkId:t,err:h});}}reportPerceptionOutcome(e,t,r){if(this.ws?.readyState!==WebSocket.OPEN){this.emitError("NOT_CONNECTED","reportPerceptionOutcome() needs a live session","sdk",{fatal:false});return}try{this.ws.send(JSON.stringify({type:"perception_status",turnId:t,outcome:e,...e==="granted"&&{hasHistory:!!r?.hasHistory,feed:r?.feed??"off"}}));}catch(o){this.emitError("UNKNOWN","Failed to send perception status","sdk",{cause:o,fatal:false});}}sendCameraState(e){if(this.ws?.readyState===WebSocket.OPEN&&!(e.access===void 0&&e.feed===void 0&&e.facing===void 0&&e.canFlip===void 0&&e.availableCameras===void 0)){try{this.ws.send(JSON.stringify({type:"camera_state",...e.access!==void 0&&{access:e.access},...e.feed!==void 0&&{feed:e.feed},...e.facing!==void 0&&{facing:e.facing},...e.canFlip!==void 0&&{canFlip:e.canFlip},...e.availableCameras!==void 0&&{availableCameras:e.availableCameras}}));}catch(t){E.warn("Runtime","failed to send camera_state",{err:t});}(e.feed==="off"||e.access&&e.access!=="granted")&&this.clearMood();}}get canReadMood(){return this.readsMood&&!!this.capabilities?.mood}get isMoodDetectionOn(){return this.moodDetectionOn}setMoodDetection(e){e!==this.moodDetectionOn&&(this.moodDetectionOn=e,this.moodLatest=null,this.events.emit("mood-detection",e),this.queueMoodState());}reportMood(e){!this.canReadMood||!this.moodDetectionOn||(this.moodLatest=e,this.queueMoodState());}resyncMoodSwitch(){this.moodLastSentKey="off",this.queueMoodState();}moodStateKey(){return this.moodDetectionOn?this.moodLatest?.state??"on":"off"}queueMoodState(){if(!this.canReadMood||this.moodTimer||this.moodStateKey()===this.moodLastSentKey)return;let e=Date.now()-this.moodLastSentAt;if(e>=Cd){this.sendMoodState();return}this.moodTimer=setTimeout(()=>{this.moodTimer=null,this.sendMoodState();},Cd-e);}sendMoodState(){let e=this.moodStateKey();if(e===this.moodLastSentKey||this.ws?.readyState!==WebSocket.OPEN)return;let t=this.moodDetectionOn?this.moodLatest:null;try{this.ws.send(JSON.stringify({type:"mood_state",enabled:this.moodDetectionOn,...t&&{label:t.state,confidence:t.confidence}})),this.moodLastSentKey=e,this.moodLastSentAt=Date.now(),E.debug("Runtime","mood_state sent",{key:e});}catch(r){E.warn("Runtime","failed to send mood_state",{err:r});}}clearMood(){this.moodLatest=null,this.moodLastSentKey!=="off"&&this.moodLastSentKey!==null&&(this.moodLastSentKey="on");}reportScreenStatus(e,t,r){if(E.event("screen","Share status",{outcome:e,turnId:t,surface:r?.surface??null,browser:r?.browser??null,reason:r?.reason??null}),this.ws?.readyState===WebSocket.OPEN)try{this.ws.send(JSON.stringify({type:"screen_status",turnId:t,outcome:e,...r?.surface&&{surface:r.surface},...r?.browser&&{browser:r.browser},...r?.reason&&{reason:r.reason}}));}catch(o){E.warn("Runtime","failed to send screen_status",{err:o});}}sendScreenState(e){if(this.ws?.readyState===WebSocket.OPEN)try{this.ws.send(JSON.stringify({type:"screen_state",feed:e.feed,...e.surface&&{surface:e.surface}}));}catch(t){E.warn("Runtime","failed to send screen_state",{err:t});}}sendScreenFrame(e){if(this.ws?.readyState===WebSocket.OPEN)try{this.ws.send(JSON.stringify({type:"screen_frame",format:"jpeg",width:e.width,height:e.height,frame:hl(e.bytes)}));}catch(t){E.warn("Runtime","failed to send screen_frame",{err:t});}}reportCommandStatus(e,t,r,o){if(this.ws?.readyState===WebSocket.OPEN)try{this.ws.send(JSON.stringify({type:"command_status",command:e,turnId:t,outcome:r,...o&&{reason:o}}));}catch(s){E.warn("Runtime","failed to send command_status",{err:s});}}loadVadWeights(){return hu(fu(),this.cache)}noteUserVoice(){this.events.emit("user-voice");}sendClientVadStatus(e,t){if(this.ws?.readyState===WebSocket.OPEN)try{this.ws.send(JSON.stringify({type:"client_vad_status",active:e,...t&&{reason:t}}));}catch(r){E.warn("Runtime","failed to send client_vad_status",{err:r});}}sendClientNetStatus(){if(this.ws?.readyState===WebSocket.OPEN){try{this.ws.send(JSON.stringify({type:"client_net_status",micMuted:this.micMuted,...this.downlinkVerdict&&{downlink:this.downlinkVerdict}})),this.downlinkVerdict?.state==="ok"&&(this.downlinkVerdict=null);}catch(e){E.warn("Runtime","failed to send client_net_status",{err:e});}this.netStatusLastSentAt=Date.now();}}queueClientNetStatus(){if(this.netStatusTimer)return;let e=Date.now()-this.netStatusLastSentAt;if(e>=kd){this.sendClientNetStatus();return}this.netStatusTimer=setTimeout(()=>{this.netStatusTimer=null,this.sendClientNetStatus();},kd-e);}sendVisionFrames(e,t){if(this.ws?.readyState!==WebSocket.OPEN){this.emitError("NOT_CONNECTED","sendVisionFrames() needs a live session","sdk",{fatal:false});return}if(!e.length){E.warn("Runtime","vision frames requested but buffer is empty",{turnId:t});return}try{let r=e.map(o=>hl(o));this.ws.send(JSON.stringify({type:"vision_query",turnId:t,format:"jpeg",frames:r}));}catch(r){this.emitError("UNKNOWN","Failed to send vision frames","sdk",{cause:r,fatal:false});}}play(e){if(this.mode!=="player"){this.emitError("INVALID_MODE","play() can only be used in player mode","sdk",{fatal:false});return}this.jobQueue.push({...e,sessionId:this.sessionId,turnId:this.turnId,jobId:++this.jobCounter,chunkOffset:0}),!(this.processing||this.playerLeadInTimer)&&(this.setTalkingArmed(true),this.playerLeadInTimer=setTimeout(()=>{this.playerLeadInTimer=null,this.setTalkingArmed(false),this.processQueue();},Ks));}setTalkingArmed(e){this.talkingArmed!==e&&(this.talkingArmed=e,this.events.emit("talking-armed",e));}clearPlayerLeadIn(){this.playerLeadInTimer&&(clearTimeout(this.playerLeadInTimer),this.playerLeadInTimer=null),this.setTalkingArmed(false);}sendPcmChunk(e){if(!this.micMuted&&!this.noticeReceived&&!(this.ws?.readyState!==WebSocket.OPEN||!this.isConnected)){if(!this.pushToTalk){this.ws.send(e);return}for(let t of this.pushToTalk.gate(e))this.ws.send(t);}}openUserTurn(){(this.turnPhase==="speaking"||this.turnPhase==="greeting")&&this.interrupt({notifyServer:true,reason:"push_to_talk"}),this.sendClientTurnSignal("client_turn_start");}closeUserTurn(){this.sendClientTurnSignal("client_turn_end");}sendClientTurnSignal(e){if(this.ws?.readyState===WebSocket.OPEN)try{this.ws.send(JSON.stringify({type:e,turnId:this.turnId}));}catch(t){E.warn("Runtime",`failed to send ${e}`,{err:t});}}interrupt(e){E.event("bargein","interrupt",{reason:e?.reason??"api",turnId:this.turnId,turnPhase:this.turnPhase});let t=this.turnId;this.sessionId++,this.turnId++,e?.notifyServer&&this.sendClientInterruptToServer(t,e.reason),this.resetSpeechPipeline(),this.setResponseSlow(false),this.events.emit("interrupt"),this.sessionPhase==="active"&&this.setTurnPhase("listening");}setHeardSpeechProvider(e){this.heardSpeech=e;}readHeardSpeech(){try{let e=this.heardSpeech?.()?.trim();return e?e.slice(0,nv):void 0}catch{return}}sendClientInterruptToServer(e,t){if(this.ws&&this.ws.readyState===WebSocket.OPEN){let r=this.readHeardSpeech();try{this.ws.send(JSON.stringify({type:"client_interrupt",turnId:e,...t&&{reason:t},...r&&{heard:r}}));}catch{}}}stopSpeaking(){this.sessionPhase==="active"&&(E.event("Runtime","User stopped the avatar"),this.interrupt({notifyServer:true,reason:"user_cancel"}));}cancelSpeech(){E.event("bargein","server_cancel_speech",{turnId:this.turnId,turnPhase:this.turnPhase}),this.resetSpeechPipeline(),this.events.emit("speech-cancelled"),this.sessionPhase==="active"&&this.setTurnPhase("listening");}setResponseSlow(e){this.responseSlow!==e&&(this.responseSlow=e,this.events.emit("avatar_slow_response",e));}armFirstChunk(){this.firstChunkPending=true;}resetSpeechPipeline(){this.utteranceBuffer.flushTimer&&clearTimeout(this.utteranceBuffer.flushTimer),this.utteranceBuffer={audio:[],alignments:[],displayAlignments:[],visemes:[],flushTimer:null},this.jobQueue=[],this.processing=false,this.turnOpen=false,this.activeStream=null,this.clearPlayerLeadIn(),this.armFirstChunk(),this.sendAvatarSpeakingSignalToServer(false),this.transcript?.finalizeAvatar();}grantedPageSurface(e,t,r){let o=this.capabilities?.page;return !o||!r(o)?(this.reportCommandStatus(e,this.commandTurnId(t),"unsupported","this avatar is not allowed to do that to the page"),null):this.pageSurface?this.pageSurface:(this.reportCommandStatus(e,this.commandTurnId(t),"unsupported","no page surface on this platform"),null)}runPageCommand(e,t,r,o){let s=this.grantedPageSurface(e,t,r);if(!s)return;let u=this.commandTurnId(t);this.queuePageWork(()=>o(s,u)).catch(p=>{E.warn("Runtime","page command failed",{command:e,error:String(p)}),this.reportCommandStatus(e,u,"failed",ev);});}scheduleReadAfterAction(){this.actionRereadTimer&&clearTimeout(this.actionRereadTimer),this.actionRereadTimer=setTimeout(()=>{this.actionRereadTimer=null,this.readPage();},$g);}commandTurnId(e){return typeof e?.turnId=="number"&&Number.isFinite(e.turnId)?e.turnId:this.turnId}handleCommand(e){let t=typeof e?.intent=="string"?e.intent:null;if(!t){E.warn("Runtime","command message missing intent",{msg:e});return}this.setResponseSlow(false);let r=this.commandHandlers[t];if(!r){E.warn("Runtime","unknown command intent",{intent:t}),this.reportCommandStatus(t,this.commandTurnId(e),"unsupported","unknown command");return}r(e);}dispose(e="SDK Disposed"){this.lifecycle++,this.cancelReconnect(),this.loadInFlight=null,this.teardownSession(4003,e,false),this.setSessionPhase("idle"),this.setPaintPhase("none");}setAvatarId(e){let t=e||"default";return t===this.avatarId?false:(E.event("Runtime","Avatar changed",{from:this.avatarId,to:t}),this.dispose("Avatar changed"),this.avatarId=t,this.startInvoked=false,this.load(),true)}stale(e){return e!==this.lifecycle}staleSocket(e,t){return this.stale(e)?(this.ws===t&&(this.ws=null),t?.close(4003,"SDK Disposed"),true):false}destroy(){this.dispose(),this.events.removeAll();}getPaintPhase(){return this.paintPhase}getSessionPhase(){return this.sessionPhase}getMode(){return this.mode}getTurnPhase(){return this.turnPhase}getTalkingArmed(){return this.talkingArmed}getSessionId(){return this.sessionId}on(e,t){return this.events.on(e,t)}markRiveReady(){this.riveReady||(this.riveReady=true,this.events.emit("avatar-ready"),this.releaseGreetingForPaint("rive-ready"),this.utteranceBuffer.audio.length&&(this.utteranceBuffer.flushTimer&&(clearTimeout(this.utteranceBuffer.flushTimer),this.utteranceBuffer.flushTimer=null),this.flushUtterance()));}notifyPlaybackEnded(){this.processing&&(this.processing=false,this.activeStream=null,this.armFirstChunk(),this.processQueue());}notifyAvatarLoadError(e){this.setPaintPhase("failed"),this.emitError("AVATAR_LOAD_FAILED","Failed to load avatar","sdk",{cause:e});}getAvatarConfig(){return this.serverReady?this.avatarConfig:null}getAvailableActions(){return Object.keys(this.avatarConfig?.rive?.gestures??{})}triggerAction(e){e&&this.events.emit("gesture",e);}avatarClicked(){if(this.turnPhase==="speaking"||this.turnPhase==="greeting")return;if(this.sessionPhase==="active"){try{this.ws?.send(JSON.stringify({type:"avatar_click"}));}catch{}return}let e=Date.now(),t=Ru(this.avatarConfig?.performance?.playful?.gestures,this.playful.last,e,this.playful.busyUntilMs);t&&(this.playful={last:t.trigger,busyUntilMs:e+t.ms},this.events.emit("gesture",t.trigger));}setSessionPhase(e){this.sessionPhase!==e&&(this.sessionPhase=e,E.debug("Runtime","Session phase",{next:e}),this.events.emit("session-phase",e),e!=="active"&&this.turnPhase!=="idle"&&this.setTurnPhase("idle"));}setPaintPhase(e){this.paintPhase!==e&&(this.paintPhase=e,E.debug("Runtime","Paint phase",{next:e}),this.events.emit("paint-phase",e),e==="painted"&&this.markTonePainted(),e==="failed"&&this.stopConnectTone("paint-failed"),e==="failed"&&this.releaseGreetingForPaint("paint-failed"));}setTurnPhase(e){this.turnPhase!==e&&(this.turnPhase=e,E.debug("Runtime","Turn phase",{next:e}),this.events.emit("turn-phase",e));}startConnectTone(){!this.connectTone?.enabled||this.connectTonePlaying||this.mode!=="player"&&(this.tonePainted=this.paintPhase==="painted",this.toneSessionLive=this.sessionPhase==="active",!(this.tonePainted&&this.toneSessionLive)&&(this.connectTonePlaying=true,this.connectToneStartedAt=Date.now(),E.event("ConnectTone","Ringback start",{paintedOnEntry:this.tonePainted,liveOnEntry:this.toneSessionLive}),this.events.emit("connect-tone","start",this.resolvedConnectTone()),this.connectToneTimer=setTimeout(()=>{E.warn("ConnectTone","Ringback hit its ceiling \u2014 stopping"),this.stopConnectTone("ceiling");},gu)));}stopConnectTone(e){this.connectToneTimer&&(clearTimeout(this.connectToneTimer),this.connectToneTimer=null),this.connectTonePlaying&&(this.connectTonePlaying=false,E.event("ConnectTone","Ringback stop",{reason:e,audibleMs:this.connectToneStartedAt?Date.now()-this.connectToneStartedAt:null}),this.connectToneStartedAt=null,this.events.emit("connect-tone","stop"));}resolvedConnectTone(){return {...zn,...this.connectTone}}getPendingConnectTone(){return this.connectTonePlaying?this.resolvedConnectTone():null}markTonePainted(){this.tonePainted=true,this.toneSessionLive&&this.stopConnectTone("painted+live");}markToneSessionLive(){this.toneSessionLive=true,this.tonePainted&&this.stopConnectTone("painted+live");}settleGreeting(e){this.greetingDecided||(this.greetingDecided=true,this.greetingDecisionTimer&&(clearTimeout(this.greetingDecisionTimer),this.greetingDecisionTimer=null),E.event("Greeting","Decision settled",{outcome:e}));}armGreetingBackstop(){this.greetingDecided||this.greetingDecisionTimer||(this.greetingDecisionTimer=setTimeout(()=>{this.greetingDecisionTimer=null,E.warn("Greeting","No greeting decision from server \u2014 listening"),this.settleGreeting("timeout"),this.greetingAwaitingPlayback=false,this.sessionPhase==="active"&&this.enterListening();},mu));}handleGreetingPayload(e,t){if(!t?.audio_base64){this.settleGreeting("empty-payload"),this.resolveGreetingPlayback();return}let r={greetingId:e,audioChunks:[t.audio_base64],alignments:[t.normalized_alignment??t.alignment??null],...t.visemes&&{visemes:[qo(t.visemes)]},cachedAt:Date.now()};this.greetingEntry=r,this.sentGreetingId=e,this.cache.setCachedGreeting(this.greetingKey,r).catch(()=>{}),this.settleGreeting("synthesized"),this.resolveGreetingPlayback();}resolveGreetingPlayback(){this.greetingAwaitingPlayback&&(this.greetingAwaitingPlayback=false,this.sessionPhase==="active"&&(this.playGreeting()||this.enterListening()));}playGreeting(){if(this.greetingPlayed)return false;let e=this.greetingEntry;if(!e?.audioChunks.length)return false;this.greetingPlayed=true,E.event("Greeting","Playing greeting",{greetingId:e.greetingId}),this.setTurnPhase("greeting");let t={audioChunks:e.audioChunks,alignments:e.alignments,...e.visemes&&{visemes:e.visemes},sessionId:this.sessionId,turnId:this.turnId,isGreeting:true,jobId:++this.jobCounter,chunkOffset:0},r=()=>{this.greetingDelayTimer=setTimeout(()=>{this.greetingDelayTimer=null,t.sessionId===this.sessionId&&this.sessionPhase==="active"&&this.enqueueJob(t);},Ys);},o=()=>{this.greetingWaitsForPaint()?this.holdGreetingForPaint(r):r();};return this.greetingWaitsForMic()?this.holdGreetingForMic(o):o(),true}reportMicPipelineSettled(){this.micPipelineSettled=true,this.releaseGreetingForMic("settled");}greetingWaitsForMic(){return this.reportsMicPipeline&&!!this.micStream&&!this.micPipelineSettled}holdGreetingForMic(e){this.greetingAwaitingMic=e,this.greetingMicTimer=setTimeout(()=>this.releaseGreetingForMic("timeout"),yu),E.event("Greeting","Held for mic pipeline");}releaseGreetingForMic(e){let t=this.greetingAwaitingMic;this.clearGreetingMicHold(),t&&(E.event("Greeting","Released after mic hold",{reason:e}),t());}clearGreetingMicHold(){this.greetingAwaitingMic=null,this.greetingMicTimer&&(clearTimeout(this.greetingMicTimer),this.greetingMicTimer=null);}greetingWaitsForPaint(){return this.environment==="meeting"&&!this.riveReady&&this.paintPhase!=="failed"}holdGreetingForPaint(e){this.greetingAwaitingPaint=e,this.greetingPaintTimer=setTimeout(()=>this.releaseGreetingForPaint("timeout"),bu),E.event("Greeting","Held for first paint");}releaseGreetingForPaint(e){let t=this.greetingAwaitingPaint;this.clearGreetingPaintHold(),t&&(E.event("Greeting","Released after paint hold",{reason:e}),t());}clearGreetingPaintHold(){this.greetingAwaitingPaint=null,this.greetingPaintTimer&&(clearTimeout(this.greetingPaintTimer),this.greetingPaintTimer=null);}enterListening(){this.setTurnPhase("listening");}enterThinking(){this.setTurnPhase("thinking"),this.events.emit("avatar_thinking");}holdsSpeech(){return this.processing||this.jobQueue.length>0||this.utteranceBuffer.audio.length>0}enqueueJob(e){this.jobQueue.push(e),this.processQueue();}processQueue(){if(this.processing)return;let e=this.jobQueue.shift();if(!e){this.transcript?.finalizeAvatar(),this.turnOpen?this.enterThinking():this.enterListening(),this.sendAvatarSpeakingSignalToServer(false);return}if(e.sessionId!==this.sessionId){this.processQueue();return}this.processing=true,this.setTurnPhase("speaking"),this.emitSpeak(e),this.sendAvatarSpeakingSignalToServer(true);}emitSpeak(e){this.setResponseSlow(false),this.rollScriptTail(e),this.transcript?.applyAvatarSpeech(e),this.events.emit("speak",e);}rollScriptTail(e){let t=this.scriptTail;t.jobId!==e.jobId&&(t.jobId=e.jobId,t.upto=0,t.text="");let r=e.alignments??[],o=e.chunkOffset+r.length;if(o<=t.upto)return;let s=[];for(let u=Math.max(0,t.upto-e.chunkOffset);u<r.length;u++){let p=r[u];if(!p)continue;let h=Ei(p);h&&s.push(h);}t.upto=o,t.text=[t.text,...s].join(" ").slice(-200);}getScriptTail(){return this.scriptTail.text}applyAgc(e){if(this.agcEnabled===e||typeof this.micStream?.getAudioTracks!="function")return;let t=this.micStream.getAudioTracks()[0];t&&(this.agcEnabled=e,E.event("mic","agc",{enabled:e}),t.applyConstraints({autoGainControl:e}).catch(r=>E.warn("Runtime","AGC toggle rejected",{enabled:e,error:r})));}async handleServerMessage(e){if(typeof e.data!="string")return;let t=Date.now(),r;try{r=JSON.parse(e.data);}catch{return}let o=this.transit.note(r.sentAt,t);switch(this.downlinkWatchdog.noteMessage(r.seq,t,r.type===vd),r.type){case "avatar_config":{let s=r.config;if(!s?.rive&&!this.serverReady){this.emitError("AVATAR_LOAD_FAILED","Server config had no rive configuration","server"),this.rejectInitAck("Server config missing rive configuration");return}if(this.serverReady)await this.repaintFromPayload(s,this.lifecycle);else {let u=s.rivUrl?await this.fetchRivBytes(s.rivUrl):this.pendingRivBytes;if(!u){this.emitError("AVATAR_LOAD_FAILED","No rivUrl in avatar_config and no cache","server"),this.rejectInitAck("no riv bytes");return}await this.applyRenderPayload(s,u,this.lifecycle);}this.resolveInitAck();break}case "greeting_current":{E.event("Greeting","Server confirmed cached greeting",{greetingId:r.greetingId}),this.settleGreeting("cache-hit"),this.resolveGreetingPlayback();break}case "greeting":{E.event("Greeting","Received greeting audio",{greetingId:r.greetingId}),this.handleGreetingPayload(r.greetingId,r.job);break}case "greeting_unavailable":{E.info("Greeting","Server sent no greeting",{reason:r.reason??null}),this.settleGreeting(`unavailable:${r.reason??"unspecified"}`),this.resolveGreetingPlayback();break}case "notice_only":{this.noticeOnly=true,E.info("Runtime","notice_only \u2014 suppressing mic/greeting",{kind:r.kind}),this.serverReady||await this.paintForNotice(),this.setSessionPhase("idle"),this.resolveInitAck();break}case "resume_state":{if(typeof r.token!="string")break;this.isConnected?this.onResumeState?.(r.token):this.heldResumeToken=r.token;break}case "session_started":{this.resumeKept=void 0,this.heldResumeToken=null,this.sessionCapabilities=Md(r.capabilities);let{camera:s,screen:u,micMute:p,endCall:h,actions:A,page:y}=this.sessionCapabilities;E.event("session","Capabilities resolved",{camera:s,screen:u,micMute:p,endCall:h,actions:A,pageRead:y.read,pageScroll:y.scroll,pageNavigate:y.navigate,pageClick:y.click}),this.resyncMoodSwitch(),this.flushPendingContext(),this.noticeOnly||(this.firstPage=this.sendFirstPage()),this.serverReady?this.startSession():(E.info("Runtime","session_started before riv ready \u2014 deferring"),this.pendingSession=true);break}case "error":case "closed":{let s=r.type==="error",u=s?"SERVER_ERROR":"SERVER_CLOSE_REQUESTED",p=r.message||(s?"Server error":"Server requested closure");this.serverInitiatedReason={code:u,message:p},this.emitError(u,p,"server"),this.rejectInitAck(p);return}case "usage_limit_reached":case "avatar_not_allowed":{let s=r.type==="usage_limit_reached",u=r.message||(s?"Usage limit reached":"This avatar is not in your active slots, and your active slots are full");this.serverInitiatedReason={code:r.type,message:u},this.handleNotice({kind:r.kind??"plan",action:r.action,message:u});return}case "brain_error":{let s=r.message||"The assistant failed to respond";this.emitError("BRAIN_ERROR",s,"server",{fatal:false}),this.turnOpen=false,this.turnPhase==="thinking"&&this.enterListening();return}case "stream_health":{let s=r.service,u=r.state;if(!this.isHealthService(s)||!this.isHealthState(u)){E.warn("Runtime","stream_health: unknown service/state",{service:r.service,state:r.state});return}E.event("Runtime","stream_health",{service:s,state:u,code:r.code??null,detail:r.detail??null}),this.health[s]=u,this.emitHealth(s,r.code);return}case "tts_alignment":{if(r.turnId!==this.turnId)return;let s=r.audio_base64??r.audio_base64_string??"";if(!s)return;this.firstAudioAt===null&&(this.firstAudioAt=t,this.firstAudioLagMs=o);let u=this.mode==="call"&&!this.noticeOnly?wi(r.normalized_alignment??r.alignment):r.normalized_alignment??null;E.debug("TTS","Processed alignment",u);let p=r.display_alignment?wi(r.display_alignment):null;if(this.utteranceBuffer.audio.push(s),this.utteranceBuffer.alignments.push(u),this.utteranceBuffer.displayAlignments.push(p),this.utteranceBuffer.visemes.push(qo(r.visemes)),!this.utteranceBuffer.flushTimer){let h=this.firstChunkPending?0:Yg;this.firstChunkPending=false,this.utteranceBuffer.flushTimer=setTimeout(()=>{this.flushUtterance();},h);}return}case "user_transcript":{E.debug("Transcript","user_transcript received",{text:r.text??"",isFinal:!!r.isFinal,turnId:r.turnId??null,event:r.event??null,msSinceMicStart:this.micStartedAt===null?null:Date.now()-this.micStartedAt,micMuted:this.micMuted,turnPhase:this.turnPhase});let s=this.turnPhase==="speaking"&&Zu(r.text??"",this.getScriptTail());s||this.transcript?.applyUserTranscript({text:r.text??"",isFinal:!!r.isFinal,turnId:r.turnId??this.turnId}),r.text&&this.events.emit("user-partial",r.text,!!r.isFinal),r.text&&!s&&!this.pageReadThisUtterance&&this.capabilities?.page.read&&(this.pageReadThisUtterance=true,this.readPage());return}case "user_speaking":{this.events.emit("user-speaking");return}case "user_stopped_speaking":{this.deliveryLagMs=o,this.pageReadThisUtterance=false,this.userStoppedAt=t-(o??0),this.speakReportedForStop=false,this.firstAudioAt=null,this.firstAudioLagMs=null;return}case "avatar_thinking":{if(r.settles===true&&(this.turnOpen=true,this.holdsSpeech()))return;this.enterThinking();return}case "turn_settled":{this.turnOpen=false,this.turnPhase==="thinking"&&r.audioPending!==true&&!this.holdsSpeech()&&this.enterListening();return}case "avatar_slow_response":{this.setResponseSlow(true);return}case "avatar_speech_starting":{this.utteranceBuffer.audio.length&&(this.utteranceBuffer.flushTimer&&(clearTimeout(this.utteranceBuffer.flushTimer),this.utteranceBuffer.flushTimer=null),this.flushUtterance()),this.transcript?.finalizeAvatar(),this.armFirstChunk(),this.events.emit("avatar_speech_starting");return}case "interrupt":{E.event("bargein","server_interrupt",{turnId:this.turnId,turnPhase:this.turnPhase}),this.interrupt({reason:"server"});return}case "command":{this.handleCommand(r);return}case "tour":{let s=Array.isArray(r.steps)?r.steps:null;this.pendingTours.get(r.requestId)?.(s);return}case "tour_unavailable":{E.warn("Runtime","Server could not write a tour",{reason:r.reason}),this.pendingTours.get(r.requestId)?.(null);return}case "action_run":{this.handleActionRun(r);return}case "action_state":{this.handleActionState(r);return}case "action_check":{this.handleActionCheck(r);return}case "gesture":{if(typeof r.name=="string"){let s=typeof r.atMs=="number"&&Number.isFinite(r.atMs)?r.atMs:void 0,u=typeof r.speechless=="boolean"?r.speechless:void 0;this.events.emit("gesture",r.name,s,u);}return}case "beep":{this.events.emit("beep",typeof r.atMs=="number"&&Number.isFinite(r.atMs)?r.atMs:void 0,typeof r.speechless=="boolean"?r.speechless:void 0);return}}}teardownSession(e,t,r=true){this.utteranceBuffer.flushTimer&&clearTimeout(this.utteranceBuffer.flushTimer),this.utteranceBuffer={audio:[],alignments:[],displayAlignments:[],visemes:[],flushTimer:null},this.turnOpen=false,this.stopConnectTone("session-teardown"),this.toneSessionLive=false,this.greetingDelayTimer&&(clearTimeout(this.greetingDelayTimer),this.greetingDelayTimer=null),this.clearGreetingPaintHold(),this.clearGreetingMicHold(),this.clearPlayerLeadIn(),this.greetingDecisionTimer&&(clearTimeout(this.greetingDecisionTimer),this.greetingDecisionTimer=null),this.greetingDecided=false,this.greetingAwaitingPlayback=false,this.greetingPlayed=false,this.sessionCapabilities=null,this.pageGeneration=0,this.lastPageContext=null,this.firstPage=null,this.pageSession++;for(let s of [...this.pendingTours.values()])s(null);this.actionRereadTimer&&(clearTimeout(this.actionRereadTimer),this.actionRereadTimer=null),this.actions.resetSession(),this.actionCallsSeen.clear(),this.actionFlows.flow&&(this.actionFlows.clear(),this.events.emit("action-flow",null)),this.actionsGrantWarned=false,this.armFirstChunk(),this.setResponseSlow(false),this.micMuted&&(this.micMuted=false,this.events.emit("mic-muted",false)),this.speakerMuted&&(this.speakerMuted=false,this.events.emit("speaker-muted",false)),this.sendAvatarSpeakingSignalToServer(false),this.isConnected&&(this.isConnected=false,this.events.emit("connection-status",false)),this.downlinkWatchdog.reset(),this.resetHealth(),this.heldResumeToken=null,this.lastContextSnapshot&&(this.pendingContext=[{context:this.lastContextSnapshot}]),this.netStatusTimer&&(clearTimeout(this.netStatusTimer),this.netStatusTimer=null),this.netStatusLastSentAt=0,this.moodTimer&&(clearTimeout(this.moodTimer),this.moodTimer=null),this.moodLatest=null,this.moodLastSentKey=null,this.moodLastSentAt=0,this.intentionalClose=false,this.serverInitiatedReason=null;let o=this.ws;this.ws=null,o?.close(e,t),this.agcRestoreTimer!==null&&(clearTimeout(this.agcRestoreTimer),this.agcRestoreTimer=null),this.micStream&&(this.micStream.getTracks().forEach(s=>s.stop()),this.micStream=null,this.micStartedAt=null,this.events.emit("mic-stop")),this.pushToTalk?.reset(),this.jobQueue=[],this.processing=false,this.activeStream=null,this.turnId=0,this.sessionId=0,this.userStoppedAt=null,this.speakReportedForStop=false,this.deliveryLagMs=null,this.firstAudioAt=null,this.firstAudioLagMs=null,this.transit.reset(),this.pendingSession=false,this.rejectInitAck("Runtime stopped"),this.transcript?.reset(),this.scriptTail={jobId:-1,upto:0,text:""},this.noticeReceived=false,this.noticeOnly=false,this.visualState="normal",r||(this.serverReady=false,this.rivSrc&&(this.urlResolver.revokeSrc(this.rivSrc),this.rivSrc=null),this.pendingRivBytes=null,this.riveReady=false,this.avatarConfig=null,this.cachedConfigVersion=void 0,this.watermark=false);}sendAvatarSpeakingSignalToServer(e){if(this.ws&&this.ws.readyState===WebSocket.OPEN)try{this.ws.send(JSON.stringify({type:"avatar_speaking",value:e}));}catch{}}resolveInitAck(){this.initAckResolve?.(),this.initAckResolve=null,this.initAckReject=null,this.initAckPromise=null;}rejectInitAck(e){this.initAckReject?.(new Error(e)),this.initAckResolve=null,this.initAckReject=null,this.initAckPromise=null;}emitError(e,t,r,o){let s=o?.fatal??true,u={code:e,message:t,source:r,cause:o?.cause,fatal:s,retryable:s&&e!=="MIC_PERMISSION_DENIED"&&e!=="DOMAIN_NOT_ALLOWED"};if(this.lastEmittedError=u,E.error("Runtime",`${r.toUpperCase()} ERROR: ${t}`,{code:e,fatal:s}),this.events.emit("error",u),!s)return;let p=r==="server"&&this.initAckReject!==null;this.failSession(u),p||this.scheduleReconnect(u);}reportAudioBlocked(e){this.emitError("UNKNOWN",`Audio ${e} is blocked: the page has not had a user gesture`,"sdk",{fatal:false});}classifyClose(e){let t=e?.reason?.trim();switch(e?.code){case 4008:return {code:"SESSION_IDLE_TIMEOUT",message:t||"Session disconnected due to inactivity"};case 1008:return Sl(void 0,t)?{code:"DOMAIN_NOT_ALLOWED",message:"This page's domain is not in the deployment's authorised domains"}:{code:"SERVER_CLOSE_REQUESTED",message:t||"The service ended the session"};case 1009:return {code:"SERVER_CLOSE_REQUESTED",message:t||"Message too big"};case 1011:return {code:"SERVER_ERROR",message:"The service ended the session after a component failure"};default:return {code:"CONNECTION_FAILED",message:t?`Connection to the avatar service closed: ${t}`:"Connection to the avatar service was lost unexpectedly"}}}failSession(e){if(e.code==="SESSION_IDLE_TIMEOUT"){this.stop({intentionalClose:true,code:4002,reason:"Idle timeout reached"});return}if(e.code==="AVATAR_LOAD_FAILED"||e.code==="DOMAIN_NOT_ALLOWED"||e.code==="MIC_PERMISSION_DENIED"||e.source==="sdk"){this.stop({intentionalClose:true,code:4004,reason:gd(e)});return}this.stop({intentionalClose:false,code:4e3,reason:e.message});}setVisualState(e){this.visualState!==e&&(this.visualState=e,E.event("Runtime","Visual state",{state:e}),this.events.emit("visual",e));}applyDownlinkVerdict(e){if(this.noticeReceived)return;let t=e.state==="degraded"?"degraded":"ok";this.downlinkVerdict=e,this.downlinkScope=e.scope,E.event("Runtime","downlink_health",{...e}),this.health.downlink!==t&&(this.health.downlink=t,this.emitHealth("downlink","DOWNLINK_SLOW")),this.queueClientNetStatus();}transcriptPathDegraded(){return this.health.downlink!=="ok"&&this.downlinkScope!=="device"||this.health.ingest!=="ok"||this.health.stt!=="ok"}isHealthService(e){return e==="ingest"||e==="stt"||e==="llm"||e==="tts"}isHealthState(e){return e==="ok"||e==="degraded"||e==="failed"}resolveHealthConcern(e,t){let r=u=>u===e?t:void 0;if(this.health.ingest!=="ok")return {scope:"network",service:"ingest",state:this.health.ingest,code:r("ingest")};if(this.health.downlink!=="ok")return {scope:this.downlinkScope,service:"downlink",state:this.health.downlink,code:r("downlink")};let o=["stt","llm","tts"],s=null;for(let u of o){let p=this.health[u];if(p==="failed"){s=u;break}p==="degraded"&&s===null&&(s=u);}return s===null?null:{scope:"service",service:s,state:this.health[s],code:r(s)}}emitHealth(e,t){let r={services:{...this.health},concern:this.resolveHealthConcern(e,t)};this.events.emit("health",r);}resetHealth(){let e=Object.values(this.health).some(t=>t!=="ok");this.health={ingest:"ok",stt:"ok",llm:"ok",tts:"ok",downlink:"ok"},this.downlinkScope="network",this.downlinkVerdict=null,e&&this.emitHealth();}handleNotice(e){this.noticeReceived=true,this.downlinkWatchdog.stop(),this.downlinkVerdict=null,this.health.downlink!=="ok"&&(this.health.downlink="ok",this.emitHealth()),E.event("Runtime","Session notice",{...e}),this.stopConnectTone("notice"),this.events.emit("notice",e),this.setVisualState("expired");}flushUtterance(){let e=this.utteranceBuffer;if(e.flushTimer=null,!e.audio.length)return;if(!this.riveReady){E.debug("Runtime","Holding speech \u2014 renderer not ready",{chunks:e.audio.length});return}(!this.activeStream||this.activeStream.turnId!==this.turnId)&&(this.activeStream={sessionId:this.sessionId,turnId:this.turnId,jobId:++this.jobCounter,emittedChunks:0});let t={audioChunks:e.audio,alignments:e.alignments,displayAlignments:e.displayAlignments,visemes:e.visemes,sessionId:this.activeStream.sessionId,turnId:this.activeStream.turnId,jobId:this.activeStream.jobId,chunkOffset:this.activeStream.emittedChunks};this.activeStream.emittedChunks+=e.audio.length,e.audio=[],e.alignments=[],e.displayAlignments=[],e.visemes=[],this.processing=true,this.setTurnPhase("speaking"),this.emitSpeak(t),this.sendAvatarSpeakingSignalToServer(true),this.reportAvatarStartedSpeaking();}reportAvatarStartedSpeaking(){if(this.speakReportedForStop)return;this.speakReportedForStop=true;let e=Date.now(),t=this.userStoppedAt!==null?e-this.userStoppedAt:null,r=this.firstAudioAt!==null?e-this.firstAudioAt:null;if(this.ws?.readyState===WebSocket.OPEN)try{this.ws.send(JSON.stringify({type:"avatar_started_speaking",turnId:this.turnId,clientLatencyMs:t,deliveryLagMs:this.firstAudioLagMs,stopNoticeLagMs:this.deliveryLagMs,clientRenderMs:r}));}catch{}}};var Bt={position:"bottom-right",offset:{x:20,y:20},bubbleSize:64,panel:{w:384,h:560},panelBackground:"#F4F2EE",avatarScale:.6,draggable:false,launcher:"avatar",mobile:"sheet",zIndex:2147483e3,teaserDelayMs:8e3,mobileBreakpointPx:640,stripQuery:true,maxSessionMinutes:15},Hr=n=>({...n,position:n?.position??Bt.position,offset:n?.offset??Bt.offset,bubbleSize:n?.bubbleSize??Bt.bubbleSize,panel:n?.panel??Bt.panel,panelBackground:n?.panelBackground??Bt.panelBackground,avatarScale:n?.avatarScale??Bt.avatarScale,draggable:n?.draggable??Bt.draggable,launcher:n?.launcher??Bt.launcher,mobile:n?.mobile??Bt.mobile,zIndex:n?.zIndex??Bt.zIndex});var ca=1e3,ua="I'm right here, so let me know if you have any questions.",av=80,Tl=n=>{if(typeof n!="string")return;let e=n.trim();return e&&e.length<=av?e:void 0},sv=["above","below","left","right"],Rd=(n,e)=>{let t=typeof e=="string"?{target:e}:e,r=Tl(t?.target);if(!r)return;let o=sv.find(s=>s===t?.from);return o?{kind:n,target:r,from:o}:{kind:n,target:r}},lv=n=>{let e=Rd("point",n.point);if(e)return e;let t=Rd("go",n.go);if(t)return t;if(typeof n.spot!="string")return;let r=Li(n.spot);return r?.kind==="spot"?{kind:"spot",spot:r.spot}:void 0},cv=n=>{let e=typeof n=="string"?{target:n}:n,t=Tl(e?.target);if(t)return {target:t,strong:e?.strong===true}},Pd=n=>n.split(/\s+/).filter(Boolean),da=(n,e=ua)=>{let t=[],r=[];for(let s of n??[]){let u=Pd(typeof s?.say=="string"?s.say:"");if(!u.length)continue;let p=typeof s.gesture=="string"&&s.gesture.trim()?s.gesture.trim():void 0;r.push({wordIndex:t.length,move:lv(s),highlight:cv(s.highlight),scroll:Tl(s.scroll),gesture:p}),t.push(...u);}if(!r.length)return {text:"",words:[],steps:[]};r[0].move||(r[0].move={kind:"spot",spot:"center"});let o=e===false?[]:Pd(e);return o.length&&(r.push({wordIndex:t.length,move:{kind:"home"},scrollTop:true}),t.push(...o)),{text:t.join(" "),words:t,steps:r}},kl=n=>{let e=JSON.stringify(n.steps)+n.text,t=5381;for(let r=0;r<e.length;r++)t=(t<<5)+t+e.charCodeAt(r)|0;return (t>>>0).toString(36)};var Id=n=>n.toLowerCase().normalize("NFKC").replace(/[^\p{L}\p{N}]+/gu,""),uv=(n,e,t)=>{let r="";for(let o=1;o<=3&&t-o>=0;o++){if(r=e[t-o]+r,r===n)return o;if(!n.endsWith(r))return 0}return 0},Cl=(n,e)=>{let t=n.map(Id),r=e.map(S=>Id(S.text)),o=t.length+1,s=r.length+1,u=new Int32Array(o*s),p=(S,C)=>t[S-1]?uv(t[S-1],r,C):0;for(let S=1;S<o;S++)for(let C=1;C<s;C++){let I=Math.max(u[(S-1)*s+C],u[S*s+C-1]),L=p(S,C);L&&(I=Math.max(I,u[(S-1)*s+C-L]+1)),u[S*s+C]=I;}let h=t.map(()=>null),A=o-1,y=s-1;for(;A>0&&y>0;){let S=u[A*s+y];if(S===u[(A-1)*s+y])A--;else if(S===u[A*s+y-1])y--;else {let C=p(A,y);h[A-1]={from:y-C,to:y},A--,y-=C;}}let b=t.map((S,C)=>{let I=h[C];return !I||S.length<=3&&!(h[C-1]?.to===I.from||h[C+1]?.from===I.to)?null:e[I.from].start}),m=null;for(let S=t.length-1;S>=0;S--)b[S]!==null?m=b[S]:m!==null&&(b[S]=m);return b};var Bi=class{constructor(){this.jobId=null;this.consumed=0;this.chars=[];this.starts=[];this.ends=[];this.cachedWords=[];}add(e){let t=e.alignments??[],r=e.chunkOffset??0;this.jobId!==e.jobId&&(this.reset(),this.jobId=e.jobId);let o=r+t.length;if(!(o<=this.consumed)){for(let s=Math.max(0,this.consumed-r);s<t.length;s++){let u=e.displayAlignments?.[s]??t[s];u?.characters?.length&&(this.chars.push(...u.characters),this.starts.push(...u.character_start_times_seconds),this.ends.push(...u.character_end_times_seconds));}this.consumed=o,this.cachedWords=null;}}get words(){return this.cachedWords??(this.cachedWords=Mi({characters:this.chars,character_start_times_seconds:this.starts,character_end_times_seconds:this.ends})),this.cachedWords}reset(){this.jobId=null,this.consumed=0,this.chars=[],this.starts=[],this.ends=[],this.cachedWords=[];}};var Ld=["right","left","below","above"],fa=(n,e,t)=>Math.min(Math.max(n,e),Math.max(e,t)),Od=(n,e,t,r,o)=>n>=o&&e>=o&&n+t.w<=r.w-o&&e+t.h<=r.h-o,dv=(n,e)=>{let t=n/2+e/2,r=[0];for(let o=24;o<=t;o+=24)r.push(-o,o);return r},xl=(n,e,t,{margin:r,gap:o=16,prefer:s,blocked:u})=>{let p=typeof o=="number"?o:o.x,h=typeof o=="number"?o:o.y,A=n.top+n.height/2-e.h/2,y=n.left+n.width/2-e.w/2,b={right:{left:n.left+n.width+p,top:A},left:{left:n.left-p-e.w,top:A},below:{left:y,top:n.top+n.height+h},above:{left:y,top:n.top-h-e.h}},m=s?[s,...Ld.filter(S=>S!==s)]:Ld;for(let S of m){let{left:C,top:I}=b[S];if(S==="right"||S==="left"){let B={left:C,top:fa(I,r,t.h-e.h-r),side:S};if(Od(B.left,B.top,e,t,r))return B;continue}let L=null;for(let B of dv(n.width,e.w)){let W={left:fa(C+B,r,t.w-e.w-r),top:I,side:S};if(Od(W.left,W.top,e,t,r)&&(L??(L=W),!u?.({left:W.left,top:W.top,width:e.w,height:e.h})))return W}if(L)return L}return {left:fa(b.right.left,r,t.w-e.w-r),top:fa(A,r,t.h-e.h-r),side:"right"}};var Rl=n=>{let e=new Uint8Array(n.length/4);for(let t=0;t<e.length;t+=1){let r=t*4;e[t]=(n[r]+n[r+1]+n[r+2])/3;}return e},fv=(n,e)=>{let t=0,r=0;for(let o=0;o<e.length;o+=1){let s=Math.abs(n[o]-e[o]);t+=s,s>r&&(r=s);}return {mean:e.length?t/e.length:0,max:r}},Pl=(n,e,t)=>{if(!n||n.length!==e.length)return true;let{mean:r,max:o}=fv(n,e);return r>=4?true:o>=8&&t>=4e3};var Ud={happy:[{shape:"mouthSmile",weight:.8},{shape:"cheekSquint",weight:.2}],surprised:[{shape:"browInnerUp",weight:.25},{shape:"browOuterUp",weight:.25},{shape:"eyeWide",weight:.1},{shape:"jawOpen",weight:.4,mouth:true}],angry:[{shape:"browDown",weight:.85},{shape:"noseSneer",weight:.15}],sad:[{shape:"mouthFrown",weight:.55,mouth:true},{shape:"browInnerUp",weight:.45}]},pv={happy:.45,surprised:.3,angry:.2,sad:.35},Nd=.3,Dd=.2,hv={neutral:1,happy:1,surprised:1,angry:.7,sad:.7},mv=1500,gv=.6,vv=1e3,Av=2e3,bv=.03,yv=.2,_v=new Set(["browInnerUp","browOuterUp","eyeWide"]),Fd=.1,Bd=.3,pa=n=>Math.round(n*100)/100,Ui=[...new Set([...Object.values(Ud).flatMap(n=>n.map(e=>e.shape)),"eyeBlink"])],Vi=(n,e)=>{let t=n[e];if(typeof t=="number")return t;let r=n[`${e}Left`]??0,o=n[`${e}Right`]??0;return (r+o)/2},Wi=class{constructor(){this.baseline=new Map;this.window=[];this.current=null;this.candidate=null;this.faceLostAtMs=null;this.last=null;}update(e,t,r){if(!e)return this.noteNoFace(t);if(this.faceLostAtMs=null,this.baseline.size===0)for(let h of Ui)this.baseline.set(h,Math.min(Vi(e,h),Bd));let o=new Map;for(let h of Ui){let A=this.baseline.get(h)??0,y=Vi(e,h);o.set(h,A<1?Math.max(0,(y-A)/(1-A)):0);}let{label:s,scores:u}=this.frameLabel(o,r),p=["browInnerUp","browOuterUp"].reduce((h,A)=>h+Math.max(0,(this.baseline.get(A)??0)-Vi(e,A)),0)/2;if(this.last={raw:Object.fromEntries(Ui.map(h=>[h,pa(Vi(e,h))])),baseline:Object.fromEntries(Ui.map(h=>[h,pa(this.baseline.get(h)??0)])),browDrop:pa(p),scores:u,label:s},s==="neutral"&&!r&&this.learnBaseline(e),s==="neutral"&&r)return this.candidate=null,this.current;for(this.window.push({atMs:t,label:s});this.window.length&&t-this.window[0].atMs>mv;)this.window.shift();return this.vote(t)}inspect(){return this.last}reset(){this.last=null,this.baseline.clear(),this.window=[],this.current=null,this.candidate=null,this.faceLostAtMs=null;}frameLabel(e,t){let r={},o="neutral",s=0;for(let[u,p]of Object.entries(Ud)){let h=0;for(let y of p)y.mouth&&t||(h+=y.weight*(e.get(y.shape)??0));if(u==="angry"||u==="sad"){let y=e.get("mouthSmile")??0;h*=1-Math.max(0,y-Dd)/(1-Dd);}if(u==="surprised"){let y=e.get("eyeBlink")??0;h*=1-Math.max(0,y-Nd)/(1-Nd);}r[u]=pa(h);let A=h-pv[u];A>s&&(o=u,s=A);}return {label:o,scores:r}}learnBaseline(e){for(let t of Ui){let r=Vi(e,t),o=this.baseline.get(t)??0;if(r-o>Fd)continue;let s=_v.has(t);if(s&&o-r>Fd)continue;let u=r<o&&!s?yv:bv;this.baseline.set(t,Math.min(o+u*(r-o),Bd));}}vote(e){let t=new Map;for(let u of this.window)t.set(u.label,(t.get(u.label)??0)+1);let r=null,o=0;for(let[u,p]of t){let h=p/this.window.length;h>o&&(r=u,o=h);}if(!r||o<gv)return this.candidate=null,this.current;let s=Math.round(o*hv[r]*100)/100;return this.current?.state===r?(this.candidate=null,this.current={state:r,confidence:s},this.current):(this.candidate?.label!==r&&(this.candidate={label:r,sinceMs:e}),e-this.candidate.sinceMs>=vv&&(this.current={state:r,confidence:s},this.candidate=null),this.current)}noteNoFace(e){return this.faceLostAtMs??(this.faceLostAtMs=e),e-this.faceLostAtMs<Av?this.current:(this.window=[],this.candidate=null,this.baseline.clear(),this.current={state:"no_face",confidence:1},this.current)}};var wv={top:"top",middle:"middle",center:"middle",centre:"middle",bottom:"bottom"},Sv=new Set(["up","down"]),Il=n=>{let e=n.trim().toLowerCase();if(!e)return null;let t=wv[e];if(t)return {kind:"edge",edge:t};if(Sv.has(e))return {kind:"step",direction:e};let r=Ii(e);return r?{kind:"axis",...r}:null};function Hi(n){let e=n,t=new Set;return {subscribe(r){return t.add(r),()=>t.delete(r)},getSnapshot:()=>e,getServerSnapshot:()=>n,set(r){if(!Object.is(e,r)){e=r;for(let o of t)o();}}}}var Gi=class{constructor(e,t=Math.random){this.idleActs=e;this.random=t;this.pass=[];this.round=[];this.lastId=null;}next(){this.round.length||(this.round=this.planRound());let e=this.round.shift();return this.lastId=e.id,e}planRound(){let{windowMinMs:e,windowMaxMs:t}=this.idleActs;this.pass.length||(this.pass=this.shuffled());let r=[],o=0;for(let u of [...this.pass])r.length&&o+u.ms>t||(r.push({act:u,holdMs:u.ms}),o+=u.ms,this.pass.splice(this.pass.indexOf(u),1));let s=u=>u.holdMs/u.act.ms;for(;o<e;){let u=t-o,p=r.filter(({act:A})=>A.loop!=="oneShot"&&A.ms<=u);if(!p.length)break;let h=p.reduce((A,y)=>s(y)<s(A)||s(y)===s(A)&&y.act.ms>A.act.ms?y:A);h.holdMs+=h.act.ms,o+=h.act.ms;}return r.map(({act:u,holdMs:p})=>({id:u.id,holdMs:p,cycleMs:u.ms,...u.timeline&&{timeline:u.timeline}}))}shuffled(){let e=[...this.idleActs.acts];for(let t=e.length-1;t>0;t--){let r=Math.floor(this.random()*(t+1));[e[t],e[r]]=[e[r],e[t]];}return e.length>1&&e[0].id===this.lastId&&e.push(e.shift()),e}};var Vd={quietToIdleMs:al,idleCycleMs:0,playfulAfterMs:0,playfulRoles:[],idleTriggers:[],thinkingMaxMs:0},Ev={has:()=>false,fire:()=>{}},ha="trigger:",Mv=.5,ji=class{constructor(e,t={},r=()=>{},o=()=>true,s=Ev){this.writeMode=e;this.cycle=r;this.rigHas=o;this.rigTriggers=s;this.phase="off";this.timer=null;this.cycleTimer=null;this.attending=false;this.idleSince=0;this.idleRole="idle";this.idleStep="idle";this.planner=null;this.hold=null;this.holdStartMs=0;this.holdEntered=false;this.followsRig=false;this.rigPose=null;this.timings={...Vd,...typeof t=="number"?{quietToIdleMs:t}:t},this.planner=this.timings.idleActs?new Gi(this.timings.idleActs):null,this.followsRig=this.namesActs();}setMode(e,t){e!=="idle"&&(this.rigPose=null),this.writeMode(e,t);}namesActs(){return !!this.timings.idleActs?.acts.some(e=>e.timeline)}configure(e){this.timings={...Vd,...e},this.planner=this.timings.idleActs?new Gi(this.timings.idleActs):null,this.hold=null,this.followsRig=this.namesActs(),this.phase==="listening"?this.listen(false):this.phase==="idle"?this.settle():this.phase==="thinking"&&this.armThinkingLimit();}rest(e){if(this.clear(),!e){this.phase="off",this.setMode("idle");return}this.listen(true);}connect(){this.clear(),this.phase="off",this.idleSince=Date.now(),this.settle();}resume(e){switch(this.phase){case "busy":return;case "off":e?this.connect():this.setMode("idle");return;case "listening":this.setMode("listening");return;case "idle":this.setMode(this.idleRole,this.idleRole==="idle"?this.hold?.id:void 0);return;case "thinking":this.setMode("thinking");return}}think(){if(!(this.phase==="busy"||this.phase==="off")){if(this.phase==="thinking"){this.armThinkingLimit();return}this.startThinking();}}restThinking(){this.startThinking();}startThinking(){this.clear(),this.phase="thinking",this.setMode("thinking"),this.armThinkingLimit();}stopThinking(){this.phase==="thinking"&&this.listen(true);}userActivity(){this.phase==="busy"||this.phase==="off"||this.listen(false);}setAttending(e){e!==this.attending&&(this.attending=e,this.userActivity());}busy(){this.clear(),this.phase="busy",this.rigPose=null;}dispose(){this.clear();}rigEntered(e){this.timings.idleActs?.acts.some(t=>t.timeline===e)&&(this.rigPose={timeline:e,sinceMs:Date.now()},!(this.phase!=="idle"||this.idleRole!=="idle"||this.holdEntered||e!==this.hold?.timeline)&&(this.holdEntered=true,this.holdStartMs=Date.now(),this.cycleTimer!==null&&clearTimeout(this.cycleTimer),this.cycleTimer=null,this.armCycle()));}get current(){return this.phase}listen(e){this.clear(),(e||this.phase!=="listening")&&this.setMode("listening"),this.phase="listening",this.timings.quietToIdleMs>0&&!this.attending&&(this.timer=setTimeout(()=>{this.timer=null,!(this.phase!=="listening"||this.attending)&&(this.idleSince=Date.now(),this.settle());},this.timings.quietToIdleMs));}settle(){this.clear(),this.phase!=="idle"?(this.phase="idle",this.idleRole="idle",this.idleStep="idle",this.setMode("idle",this.nextHold(Date.now()))):this.idleRole==="idle"&&this.planner&&!this.hold&&this.cycle(this.nextHold(Date.now())),this.armCycle();}nextHold(e){if(this.hold=this.planner?.next()??null,this.holdStartMs=e,this.holdEntered=false,this.hold?.timeline&&this.rigPose&&this.rigPose.timeline===this.hold.timeline){let t=Math.floor((e-this.rigPose.sinceMs)/this.hold.cycleMs);this.holdStartMs=this.rigPose.sinceMs+Math.max(0,t)*this.hold.cycleMs,this.holdEntered=true;}return this.hold?.id}armCycle(){let e=this.idleRole==="idle"?this.hold:null;if(!e){this.timings.idleCycleMs>0&&this.armTimer(this.timings.idleCycleMs,()=>this.onCycle());return}if(this.followsRig&&!this.holdEntered){let r=Math.max(...this.timings.idleActs?.acts.map(o=>o.ms)??[0]);this.armTimer(this.holdStartMs+r+e.cycleMs-Date.now(),()=>{this.followsRig=false,this.holdEntered=true,this.holdStartMs=Date.now(),this.armCycle();});return}let t=this.holdStartMs+e.holdMs-e.cycleMs*(1-Mv);this.armTimer(t-Date.now(),()=>this.onCycle());}armTimer(e,t){this.cycleTimer=setTimeout(()=>{this.cycleTimer=null,t();},Math.max(0,e));}onCycle(){if(this.phase!=="idle")return;let{playfulAfterMs:e,playfulRoles:t,idleTriggers:r=[]}=this.timings,o=t.length>0||r.length>0,u=e>0&&o&&Date.now()-this.idleSince>=e?this.nextIdleStep(t,r):"idle";if(u.startsWith(ha)){this.idleRole!=="idle"&&(this.idleRole="idle",this.setMode("idle",this.nextHold(Date.now()))),this.idleStep=u,this.rigTriggers.fire(u.slice(ha.length)),this.armCycle();return}let p=u;this.idleStep=p;let h=this.idleRole==="idle"&&this.hold?this.holdStartMs+this.hold.holdMs:Date.now(),A=p==="idle"?this.nextHold(h):void 0;p===this.idleRole?this.cycle(A):(this.idleRole=p,this.setMode(p,A)),this.armCycle();}nextIdleStep(e,t){let r=[...e.filter(o=>o!==this.idleStep&&(o===this.idleRole||this.rigHas(o))),...t.map(o=>ha+o).filter(o=>o!==this.idleStep&&this.rigTriggers.has(o.slice(ha.length)))];return r.length?r[Math.floor(Math.random()*r.length)]:this.idleRole}armThinkingLimit(){this.timer!==null&&clearTimeout(this.timer),this.timer=null,!(this.timings.thinkingMaxMs<=0)&&(this.timer=setTimeout(()=>{this.timer=null,this.phase==="thinking"&&this.listen(true);},this.timings.thinkingMaxMs));}clear(){this.timer!==null&&clearTimeout(this.timer),this.cycleTimer!==null&&clearTimeout(this.cycleTimer),this.timer=null,this.cycleTimer=null;}};var Tv=2,zi=class{constructor(e){this.writeControl=e;this.policy=null;this.role=null;this.lastAct={};}setPolicy(e){e!==this.policy&&(this.policy=e,this.role=null,this.lastAct={});}get hasPolicy(){return this.policy!==null}get mode(){return this.role}get act(){return this.role?this.lastAct[this.role]??null:null}setMode(e,t){return e===this.role&&(t===void 0||t===this.lastAct[e])?true:this.enter(e,t)}cycle(e){return this.role?this.enter(this.role,e):false}reapply(){let e=this.role;return e?this.write(e,this.lastAct[e]??0):false}has(e){if(e==="idle"||e===this.role)return true;let t=this.policy?.branches[e]?.gate;return !!t&&this.writeControl(t,false)}stop(){this.role=null;}enter(e,t){if(!this.policy)return E.debug("BranchToggler","no performance policy \u2014 branch not written",{role:e}),false;let r=t??this.pickAct(e);return this.write(e,r)?(this.lastAct[e]=r,this.role=e,true):(E.debug("BranchToggler","branch write did not land \u2014 staying put",{wanted:e,role:this.role}),false)}pickAct(e){let t=this.policy?.branches[e]?.acts??[];if(!t.length)return 0;let r=t.length>1?t.filter(o=>o!==this.lastAct[e]):t;return r[Math.floor(Math.random()*r.length)]}resolve(e){let t=e;for(let r=0;r<=Tv;r++){let o=this.policy?.branches[t];if(!o)return null;if(!o.gate||!o.fallback||this.writeControl(o.gate,false))return o;t=o.fallback;}return null}write(e,t){let r=this.resolve(e);if(!r&&e!=="idle")return false;let o=Object.values(this.policy?.branches??{}).filter(h=>h!==r),s=new Set(o.map(h=>h.gate).filter(h=>!!h&&h!==r?.gate)),u=new Set(o.map(h=>h.act).filter(h=>!!h&&h!==r?.act)),p=[];r?.act&&t&&p.push(this.writeControl(r.act,t));for(let h of s)p.push(this.writeControl(h,false));r?.gate&&p.push(this.writeControl(r.gate,true));for(let h of u)p.push(this.writeControl(h,0));return p.some(Boolean)}};var Yi=(n,e,t)=>{let r=e?.[n];return {input:r?.input??n,type:r?.type??"trigger",value:r?.value??1,binding:r?.binding??(t?"data-binding":"input"),resetMs:r?.resetMs,returnMs:r?.returnMs??ll}};var Ki=class{constructor(){this.segments=[];this.playable=0;}schedule(e,t,r){let o=this.segments[this.segments.length-1],s=r??(o?o.start+o.duration:0);return this.segments.push({at:e,start:s,duration:t}),o&&e<o.at&&this.segments.sort((u,p)=>u.at-p.at),this.playable=Math.max(this.playable,s+t),s}isAnchored(){return this.segments.length>0}timeAt(e){let t=this.segments;if(t.length===0)return qs;for(;t.length>1&&t[1].at<=e;)t.shift();let r=t[0];return r.start+(e-r.at)}playableTime(){return this.playable}reanchor(){this.segments.length=0;}reset(){this.segments.length=0,this.playable=0;}};var ma="viseme",ga={plain:n=>`${n}`,prefix:n=>`${ma}${n}`,"prefix-space":n=>`${ma} ${n}`,suffix:n=>`${n}${ma}`},Wd=["plain","prefix","prefix-space","suffix"],Cv=/^(?:viseme\s*(\d+)|(\d+)\s*viseme|(\d+))$/i,hr=n=>{let e=n.trim().match(Cv);if(!e)return null;let t=e[1]??e[2]??e[3];if(t===void 0)return null;let r=Number(t);return Number.isNaN(r)?null:r};function qi(n){let e=[0,1,2,6,21];for(let t of Wd){let r=ga[t];for(let o of e){let s=false;try{s=n(r(o));}catch{s=false;}if(s)return {format:r,shape:t,matched:true}}}return {format:ga.plain,shape:"plain",matched:false}}var va="Watermark_opacity";var xv=4e3,Rv=6,Pv=.2,Gd=-90,Iv=25,Lv=200,Aa=-50,Ov=18,jd=10,Nv=10,Dv=500,Fv=1e3,Bv=3,Uv=10,Vv=500,Wv=30,Hv=30,Gv=-50,jv=-30,jr=80,zv=400,Rn=n=>n<=1e-7?-140:20*Math.log10(n),Gr=n=>n.length?Rn(n.reduce((e,t)=>e+t,0)/n.length):-140;function zd(n,e){let t=0,r=0,o=0;for(let s=0;s<n.length;s++){for(r+=n[s].mic*n[s].mic;o<s&&n[s].t-n[o].t>e;)r-=n[o].mic*n[o].mic,o++;n[s].t-n[o].t<e*.9||(t=Math.max(t,r/(s-o+1)));}return Rn(Math.sqrt(t))}var ba=class{constructor(){this.buf=[];this.pausedAt=null;this.floorDb=null;this.floorComputedAt=0;this.erlSamples=[];this.erlSampledAt=0;this.micDb=-140;this.gateOpen=false;this.gateHoldUntil=0;this.gateLevelDb=-140;this.renderAudibleSince=null;}push(e,t){let r=Date.now();this.buf.push({t:r,mic:e,render:t});let o=r-xv,s=0;for(;s<this.buf.length&&this.buf[s].t<o;)s++;s&&this.buf.splice(0,s),Rn(t)>=Aa?this.renderAudibleSince===null&&(this.renderAudibleSince=r):this.renderAudibleSince=null,this.micDb=Rn(e),this.updateFloor(),this.updateErl(),this.updateGate();}updateErl(){let e=Date.now();if(e-this.erlSampledAt<Dv)return;let t=this.recent(Fv);!t||t.renderDb<Aa||this.floorDb!==null&&this.pausedAt===null&&(t.micDb<=Gd||t.micDb<this.floorDb+Uv&&(this.renderAudibleSince===null||e-this.renderAudibleSince<Vv)||(this.erlSampledAt=e,this.erlSamples.push(t.erlDb),this.erlSamples.length>Nv&&this.erlSamples.shift()));}erlEstimateDb(){if(this.erlSamples.length<Bv)return Ov;let e=[...this.erlSamples].sort((t,r)=>t-r);return Math.min(e[Math.floor(e.length/2)],Wv)}updateFloor(){let e=Date.now();if(this.floorDb!==null&&e-this.floorComputedAt<Lv)return;let t=[];for(let r of this.buf){let o=Rn(r.mic);o>Gd&&t.push(o);}t.length<Iv||(t.sort((r,o)=>r-o),this.floorDb=t[Math.floor((t.length-1)*Pv)],this.floorComputedAt=e);}updateGate(){this.gateLevelDb=Rn(this.meanMicRms(jr));let e=this.gateThresholdDb();if(this.gateLevelDb>=e){this.gateHoldUntil=Date.now()+zv,this.gateOpen=true;return}this.gateOpen=Date.now()<this.gateHoldUntil;}gateThresholdDb(){let e=this.floorDb===null?-1/0:this.floorDb+Hv,t=Rn(this.meanRenderRms(jr)),r=t>=Aa?t-this.erlEstimateDb()+jd:-1/0;return Math.min(Math.max(Gv,e,r),jv)}meanMicRms(e){let t=Date.now()-e,r=0,o=0;for(let s=this.buf.length-1;s>=0&&!(this.buf[s].t<t);s--)r+=this.buf[s].mic,o++;return o?r/o:0}meanRenderRms(e){let t=Date.now()-e,r=0,o=0;for(let s=this.buf.length-1;s>=0&&!(this.buf[s].t<t);s--)r+=this.buf[s].render,o++;return o?r/o:0}isLive(){return this.gateOpen}levels(){return {micNowDb:+this.micDb.toFixed(1),gateLevelDb:+this.gateLevelDb.toFixed(1),gateAtDb:+this.gateThresholdDb().toFixed(1),floorDb:+(this.floorDb??-140).toFixed(1),erlEstDb:+this.erlEstimateDb().toFixed(1)}}markPaused(){this.pausedAt=Date.now();}clearPaused(){this.pausedAt=null;}report(){if(this.buf.length<10)return null;let e=Date.now(),t=this.pausedAt??e,r=this.buf.filter(b=>b.t>=t-500&&b.t<=t),o=this.buf.filter(b=>b.t>t),s=Gr(r.map(b=>b.mic)),u=Gr(r.map(b=>b.render)),p=this.floorDb??-140,h=p+Rv,A=-1;for(let b of o)if(Rn(b.mic)<=h){A=b.t-t;break}let y=r.length?Math.max(...r.map(b=>Rn(b.mic))):-140;return {micPreDb:+s.toFixed(1),renderPreDb:+u.toFixed(1),erlDb:+(u-s).toFixed(1),micPostDb:+Gr(o.map(b=>b.mic)).toFixed(1),micFloorDb:+p.toFixed(1),micPeakDb:+y.toFixed(1),micPostSustainedDb:+zd(this.buf.filter(b=>b.t>t+60),jr).toFixed(1),gateAtDb:+this.gateThresholdDb().toFixed(1),micDecayMs:A}}provablyNotEcho(e,t){if(this.pausedAt===null)return false;let r=this.pausedAt,o=this.buf.filter(h=>h.t>=r-500&&h.t<=r),s=this.buf.filter(h=>h.t>r+t);if(o.length===0||s.length===0)return false;let u=Gr(o.map(h=>h.render));if(u<Aa)return false;let p=u-this.erlEstimateDb()+jd;return zd(s,jr)>=p+e}recent(e){let t=Date.now()-e,r=this.buf.filter(u=>u.t>=t);if(r.length<5)return null;let o=Gr(r.map(u=>u.mic)),s=Gr(r.map(u=>u.render));return {micDb:+o.toFixed(1),renderDb:+s.toFixed(1),erlDb:+(s-o).toFixed(1)}}reset(){this.buf=[],this.pausedAt=null,this.floorDb=null,this.floorComputedAt=0,this.erlSamples=[],this.erlSampledAt=0,this.micDb=-140,this.gateOpen=false,this.gateHoldUntil=0,this.gateLevelDb=-140,this.renderAudibleSince=null;}};function Yd(n){let e=0;for(let t=0;t<n.length;t++)e+=n[t]*n[t];return Math.sqrt(e/Math.max(1,n.length))}var ya=class{constructor(e){this.onModeChange=e;this.pending=null;this.samples=[];this.blackoutStreak=0;this.lastEpisodeAt=0;this.mode="healthy";this.episodesInMode=0;}noteVoiceFrame(e,t){this.expirePending(t);let r=this.pending;if(e<Uu){r&&r.endedAt===null&&t-r.lastVoicedAt>150&&(r.endedAt=t);return}if(!r){this.pending={onsetAt:t,voicedMs:0,lastVoicedAt:t,endedAt:null};return}r.endedAt=null;let o=t-r.lastVoicedAt;o>0&&o<=150&&(r.voicedMs+=o),r.lastVoicedAt=t;}noteTranscript(e){let t=this.pending;t&&(this.pending=null,this.blackoutStreak=0,this.samples.push(e-t.onsetAt),this.samples.length>Ou&&this.samples.shift(),this.closeEpisode(e));}policy(e,t=false){return this.isStale(e)&&this.setMode("healthy","stale"),t?Al:this.mode==="degraded"?Al:Zo}currentMode(){return this.mode}lagMs(){return this.median()}getBlackoutStreak(){return this.blackoutStreak}clearPending(){this.pending=null;}reset(){this.pending=null,this.samples=[],this.blackoutStreak=0,this.lastEpisodeAt=0,this.mode="healthy",this.episodesInMode=0;}expirePending(e){let t=this.pending;!t||t.endedAt===null||e-t.endedAt<Bu||(this.pending=null,!(t.voicedMs<Fu)&&(this.blackoutStreak++,this.closeEpisode(e)));}closeEpisode(e){this.lastEpisodeAt=e,this.episodesInMode++,!(this.episodesInMode<Nu)&&this.setMode(this.verdict(e),"lag");}setMode(e,t){if(e===this.mode)return;let r=this.mode;this.mode=e,this.episodesInMode=0,this.onModeChange?.({from:r,to:e,reason:t,lagMs:this.median(),blackoutStreak:this.blackoutStreak,samples:this.samples.length});}isStale(e){return this.lastEpisodeAt===0||e-this.lastEpisodeAt>Du}median(){if(this.samples.length===0)return null;let e=[...this.samples].sort((t,r)=>t-r);return e[Math.floor(e.length/2)]}verdict(e){let t=this.median();return t===null||this.isStale(e)?"healthy":t>Iu?"degraded":t<Lu?"healthy":this.mode}};var Xi=class{constructor(e,t,r){this.runtime=e;this.sensorProvider=t;this.vad=null;this.controller=null;this.initPromise=null;this.playback=null;this.speaking=false;this.micMuted=false;this.handedBack=false;this.framesPushed=0;this.voicedFramesSeen=0;this.userVoicedAtMs=0;this.voiceRunStartedAt=0;this.voiceWakeSent=false;this.partialsWhileBlind=0;this.trace=new ba;this.asrLag=new ya(e=>E.event("bargein","policy",e));this.lastEchoLogAt=0;this.vadCost={at:0,calls:0,totalMs:0,maxMs:0,audioMs:0};this.dutyBreaches=0;this.sessionStartedAt=Date.now();this.gatedFrames=0;this.farEndMs=0;this.softPaused=false;this.uplinkDelay=[];this.echoGate=r?.echoGate??true;}setPlaybackControls(e){this.playback=e;}setSpeaking(e){let t=this.speaking!==e;this.speaking=e,t&&this.runtime.setAgcForAvatarSpeech(e),e||(this.softPaused=false),t&&e&&this.resetBlindWatch();}isUserVoiced(){return Date.now()-this.userVoicedAtMs<qu}isAvatarAudible(){return this.speaking||(this.playback?.hasPendingAudio?.()??false)}setMicMuted(e){this.micMuted!==e&&(this.micMuted=e,e&&(this.controller?.abort(),this.vad?.reset(),this.trace.reset(),this.uplinkDelay=[],this.asrLag.clearPending()));}effectivePolicy(){return this.asrLag.policy(Date.now(),this.runtime.transcriptPathDegraded())}prefetch(){this.runtime.loadVadWeights().catch(()=>{});}async ensureInit(){if(this.sessionStartedAt=Date.now(),this.controller){this.runtime.sendClientVadStatus(true);return}return this.initPromise||(this.initPromise=this.init()),this.initPromise}async init(){try{let e=await this.sensorProvider.create(await this.runtime.loadVadWeights()),t=_l({isAvatarSpeaking:()=>this.isAvatarAudible(),pausePlayback:()=>{E.event("bargein","soft_pause",{mode:this.effectivePolicy().mode,...this.trace.levels()}),this.softPaused=!0,this.trace.markPaused(),this.playback?.pause();},resumePlayback:()=>{this.softPaused=!1,this.trace.clearPaused(),this.playback?.resume();},commitInterrupt:()=>this.runtime.interrupt({notifyServer:!0,reason:"barge_in"}),getActiveScriptTail:()=>this.runtime.getScriptTail(),isProvablyNotEcho:()=>this.trace.provablyNotEcho(10,60),getPolicy:()=>this.effectivePolicy(),onTelemetry:r=>E.event("bargein",r.outcome,{mode:r.mode,policySource:r.mode==="degraded"&&this.asrLag.currentMode()!=="degraded"?"health":"measured",pathFault:this.runtime.transcriptPathDegraded(),blackoutStreak:this.asrLag.getBlackoutStreak(),asrLagMs:this.asrLag.lagMs(),clause:r.commitClause,onsetToPauseMs:r.voiceOnsetToPauseMs,voicedMs:r.totalVoicedMs,postPauseMs:r.postPauseVoicedMs,wordlessStreak:r.wordlessResumeStreak,transcript:r.transcript,motion:r.speechMotion,medianFlux:r.speechMedianFlux,modulation:r.speechModulation,...this.trace.report()??{}})});e.onProb((r,o,s)=>{if(this.isAvatarAudible()?this.voiceRunStartedAt=0:(this.asrLag.noteVoiceFrame(r,Date.now()),r>=.5&&(this.userVoicedAtMs=Date.now()),this.noteVoiceForWake(r)),r>=.5&&this.voicedFramesSeen++,!this.echoGate||this.trace.isLive()&&!this.isWarming()){t.onVadProb(r,o,s);return}r>=.5&&this.gatedFrames++,t.onVadProb(0,o,null);}),this.vad=e,this.controller=t,this.handedBack=!1,this.resetBlindWatch(),E.debug("BargeIn","client VAD initialized"),this.runtime.sendClientVadStatus(!0);}catch(e){E.error("BargeIn","failed to init client VAD",e),this.initPromise=null,this.handedBack=true,this.runtime.sendClientVadStatus(false,"asset_load_failed");}}disable(e){this.vad?.destroy?.(),this.vad=null,this.controller=null,this.initPromise=null,this.dutyBreaches=0,this.handedBack=true,E.warn("BargeIn","client VAD disabled",{reason:e}),this.runtime.sendClientVadStatus(false,e);}pushLevel(e,t){this.micMuted||(this.isAvatarAudible()&&this.farEndMs<1500&&(this.farEndMs+=t/16e3*1e3),this.trace.push(e,this.playback?.getOutputLevel?.()??0),this.logEchoHealth());}pushPcm(e){if(this.micMuted)return;this.isAvatarAudible()&&this.farEndMs<1500&&(this.farEndMs+=e.length/16e3*1e3),this.trace.push(Yd(e),this.playback?.getOutputLevel?.()??0),this.logEchoHealth();let t=e.length,r=Date.now();this.vad&&(this.vad.pushPcm(e),this.framesPushed++),this.noteVadCost(Date.now()-r,t);}noteVadCost(e,t){let r=this.vadCost;r.calls++,r.totalMs+=e,r.audioMs+=t/16e3*1e3,e>r.maxMs&&(r.maxMs=e);let o=Date.now();if(r.at===0){r.at=o;return}let s=o-r.at;if(s<1e3)return;let u=Math.round(r.totalMs/s*100);this.vadCost={at:o,calls:0,totalMs:0,maxMs:0,audioMs:0},this.noteSensorHealth(u);}noteSensorHealth(e){if(this.vad){if(e<Vu){this.dutyBreaches=0;return}++this.dutyBreaches<Wu||(E.warn("BargeIn","client VAD cannot keep up",{dutyPct:e}),this.disable("sensor_too_slow"));}}isWarming(){return this.isAvatarAudible()&&this.farEndMs<1500}logEchoHealth(){}onPartialTranscript(e){e&&this.asrLag.noteTranscript(Date.now()),e&&this.noteBlindSensor(),this.controller?.onPartialTranscript(e);}noteBlindSensor(){!this.controller||this.micMuted||this.isAvatarAudible()&&(this.farEndMs<1500||this.framesPushed<Hu||this.voicedFramesSeen>0||++this.partialsWhileBlind<Gu||(E.warn("BargeIn","client VAD scored nothing while ASR returned words",{framesPushed:this.framesPushed}),this.disable("sensor_blind")));}resetBlindWatch(){this.framesPushed=0,this.voicedFramesSeen=0,this.partialsWhileBlind=0;}shouldUplink(){return this.handedBack||!this.isAvatarAudible()||this.softPaused?true:this.isWarming()?false:this.trace.isLive()}noteVoiceForWake(e){if(e<.5||!this.trace.isLive()){this.voiceRunStartedAt=0,this.voiceWakeSent=false;return}let t=Date.now();this.voiceRunStartedAt||(this.voiceRunStartedAt=t),!(this.voiceWakeSent||t-this.voiceRunStartedAt<Xu)&&(this.voiceWakeSent=true,this.runtime.noteUserVoice());}releaseUplinkFrames(e){if(!this.echoGate)return [e];if(!this.isAvatarAudible()){let s=this.uplinkDelay.map(u=>u.frame);return this.uplinkDelay=[],[...s,e]}let t=Date.now();this.uplinkDelay.push({t,frame:e});let r=this.shouldUplink(),o=[];for(;this.uplinkDelay.length>0&&t-this.uplinkDelay[0].t>=jr;){let s=this.uplinkDelay.shift();r||s.frame.fill(0),o.push(s.frame);}return o}reset(){this.vad?.reset(),this.controller?.reset(),this.trace.reset(),this.sessionStartedAt=Date.now(),this.softPaused=false,this.uplinkDelay=[],this.farEndMs=0,this.asrLag.reset(),this.dutyBreaches=0,this.vadCost={at:0,calls:0,totalMs:0,maxMs:0,audioMs:0},this.userVoicedAtMs=0,this.voiceRunStartedAt=0,this.voiceWakeSent=false,this.resetBlindWatch();}dispose(){this.vad?.destroy?.(),this.vad=null,this.controller=null,this.initPromise=null;}};var Kd=`
|
|
16
|
+
class PCMProcessor extends AudioWorkletProcessor {
|
|
17
|
+
process(inputs) {
|
|
18
|
+
const input = inputs[0];
|
|
19
|
+
if (!input || !input[0]) return true;
|
|
20
|
+
|
|
21
|
+
const channelData = new Float32Array(input[0]);
|
|
22
|
+
this.port.postMessage(channelData, [channelData.buffer]);
|
|
23
|
+
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
registerProcessor("pcm-processor", PCMProcessor);
|
|
29
|
+
`;var Kv={};var gr=()=>Kv;async function wa(n){let e=()=>n.state==="running";for(let t=0;t<5;t++){if(e())return true;if(n.state==="closed")return false;await Promise.race([n.resume().catch(()=>{}),new Promise(r=>setTimeout(r,400))]);}return e()}function qd(n,e){let t=2*Math.PI*n/e,r=Math.cos(t),o=Math.sin(t)/(2*Math.SQRT1_2),s=1+o,u=(1-r)/2/s,p=(1-r)/s,h=u,A=-2*r/s,y=(1-o)/s,b=0,m=0,S=0,C=0;return I=>{for(let L=0;L<I.length;L++){let B=I[L],W=u*B+p*b+h*m-A*S-y*C;m=b,b=B,C=S,S=W,I[L]=W;}}}function qv(n){let e=n/16e3,t=n>16e3?qd(7e3,n):null,r=n>16e3?qd(7e3,n):null,o=1,s=0;return u=>{let p=u.length;if(p===0)return new Float32Array(0);let h=u.slice();t&&r&&(t(h),r(h));let A=Math.max(0,Math.ceil((p-o)/e)),y=new Float32Array(A);for(let b=0;b<A;b++){let m=Math.floor(o),S=o-m,C=m===0?s:h[m-1],I=h[m];y[b]=C*(1-S)+I*S,o+=e;}return s=h[p-1],o-=p,y}}async function Xd(n,e,t){let r=new AudioContext(t!=null?{sampleRate:t}:void 0);try{await r.audioWorklet.addModule(e);let o=r.createMediaStreamSource(n),s=new AudioWorkletNode(r,"pcm-processor");return {ctx:r,source:o,worklet:s}}catch(o){throw r.state!=="closed"&&r.close().catch(()=>{}),o}}async function Qd(n,e,t){let r=t?.sampleRate??16e3,o=t?.workletUrl??gr().pcmWorklet,s=o??URL.createObjectURL(new Blob([Kd],{type:"application/javascript"})),u;try{try{u=await Xd(n,s,r);}catch(C){E.warn("Audio","Mic graph failed at requested rate; retrying at hardware rate",{requested:r,error:String(C)}),u=await Xd(n,s,void 0);}}finally{o||URL.revokeObjectURL(s);}let{ctx:p,source:h,worklet:A}=u;wa(p).then(C=>{t?.onSettled?.(),!(C||p.state==="closed")&&(E.warn("Audio","Mic AudioContext stayed suspended; uplink is silent"),t?.onBlocked?.());});let y=p.sampleRate,b=y!==16e3,m=b?qv(y):null;b&&E.warn("Audio","AudioContext rate is not 16kHz; resampling mic uplink",{requested:r,actual:y});let S=t?.onFloat32;return A.port.onmessage=C=>{let I=C.data,L=m?m(I):I;if(L.length===0)return;let B=new Int16Array(L.length);for(let W=0;W<L.length;W++)B[W]=Math.max(-1,Math.min(1,L[W]))*32767;S&&S(m?L:L.slice()),e(B);},h.connect(A),{stop(){try{A.disconnect();}catch{}try{h.disconnect();}catch{}try{p.state!=="closed"&&p.close().catch(()=>{});}catch{}}}}var $d="data:audio/mpeg;base64,//NoxAAQoEqwX0YYAgWUtG/4iIiP4gmnbGEAQgg8Hwffghh/D+UdwflAxhgDg+D4P1AgGMH//0f/xOD74gBAEDkTg+f1BjB8P/xOH//lAQTEFNRQMACQgABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//NoxAAyU8beX5qYAoBQKBQKBQKRWKhaLRaI66OG/9uYyG5nliZ+kagG+7LE/aonsG5wGQguIG4Buhk4VQwHQwFRjnDPEBJgvkKpRHG4gOK4LMH8zHkZMrmiZgbtoldJM8Zm6kFLrq5u6CabS2QA8SBP0urqQKiaCFNZoXzU+m6zdP/17ugzJGhoT5FB6JkkhhEAJEUiITDIjm/9tNjRbp6lpvxWghcmSZJIc4qk+XiGk0LmHk+b///ZbvdNr/5iRMexwJEMIeOQQwi45iBBy4fWbm5uRRMA//NoxAAxM6qIDd2gAAtTM1rEplLKRQC2TSSBGtNNMAAdMJiRM2QgMGwMZMn6o2UACYSlOdTBiYyCmYPAypqocIQAEBRBEmyqVTQdAJjgMDJANEAKBiQHkXQFQADAYQCI4gKBOsXh3OklOniuhWgdLpgipTutkUUUWRRR6VJKit0HRRy8pjJToOK4bKMUTVFFraSST6LM9FJ0kkv86pMsD4E4l1FT3SrVbrqSSRZFettLRRszoE+I2SWicU9X/U6Js+o1fZReRRV0TyyImQlhj9+lMQU1FAAA//NoxAAlK8acvtjbTcHLdvf5d9i9yXPS99B9utHCoOi1FG4OeF8C3ZhQwfsRpePfGLdnVu1VuY8pyoFWX1jeGqCRZ5579mRST6Yxcoq+R8FEv/Skv4kmLJofL6TM0FrLE00PmyXZSOs460ElPf91JJuXA+BSl5NKp7LXUqtbsu3//6hiiRbX9n++dJSjLtbcxL7vsplBFjymSLpQNn4hp+XSYgpqKBgASEAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//NoxAAqO8ZwHOpbLAoVyV2U25ungghAEmA93XVf1ebIiExzTMHEk1eo5GCIDAUCTAqCDagsRwNAEAu480iMvJFY/HHnh0lAQwQE+CEHl1RkugFQUhvSMpCe4yzZtjvvwED1vV2yyq/dz1GU36mpNPVnPR2ok8EhKaJ1GtVRl9T6nVMUdVS209FFRkEEJS61amu6/XWtv/tq60R9BaE7myP/+t2qTX90n+kZjhIDrOoGZpvfydCYgpqKBgASEAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//NoxAAxw9qxVsofVoQGvVss/nr/weufw+o1xZagafii6k2sP27AikB07rRSG5fKHftP5ORNy5cwycYhFY3G599IEic/Xt4A0MLeKp7SveyzyDHvdj4Mm0l40k9FeKhXIp7SqyDCw/AoRBcyT7IFBovANx6JLwKKKKL2KGFnwL2iS8Gg9QxwU4+nNOPU/GUdnk0HNP7a3Ahv4DyVQNbPI8mY3N4/wyVf3s8uXQOFjjxJr71/n/4zf7tjX+bZtT3+vu+NZ3TKncMXjtGIe/iPJQ2ho6tMQU1F//NoxAAvM96kBt5QmQXNLKmeW5Owl+r8uX1HQYPmnYxgi+D0DVORLLLIJh4cwXig5DFqCcym0QQ2hSXq6Z0tsAhh+xraSravxAQhKMA2y2B+YCi0qcGxcv3t0sax0noIQ6smuxEHs0qQHaXbWNEnMeUKnXNWw4c3K4bD2lqLGSsNRTuqHOa4rRQ8k1oprpUaV5W2ldtq+Pu/uogtVHRbyOKtozb4ememuuJ9I9l5jsdfIxDnHbOa0c010LGzMMo4erQcbMLUOQ+IWTEFNRQMACQgABAAAAAA//NoxAArM9qUDuNRbSqPeP1MZyq/qTpQIYk5j+s6hZjXOHMRihcqyfp27CITiRpkWdnPCVzdaedhhzUiQDGfQenohPg6Vt6BQcRI+KxV/qH7k1f5jrVe9paK2WZF50rI0kUcyNjFCutFSWmkZO3mTOy0FhYmjr1ttpWqM3C1/yTXEcM26zE1XCKrX1yt8RDMdyvqv/w1//P/txxMSuugswsc0hl2qclSih0M2qjr4p4Kuq1NgioQZ8WVMQU1FAwAJCAAEAAAAAAAAAAAAAAAAAAAAAAAAAAA//NoxAAsY8J8FurLUQgbjjXprUEPq5QWAEWLhPxaqfDcwwFTG2CD5kIzDkBx4QS+6D69gsD40hr/U7d2nvtLn9d6ILJQtHQHKoKmgAwBQD0M1RCEBxICAqEJkqEwyAcALpe+KmhQ1FjIVmKjlGjnNeeTfFw6W6TYh0N9rozj//69gFyfF9/Ef9BJeecSeZ6mYuxWvXqzmtsy0Mli5SpVWIeT1ar5hG/b+bEs4kIPooQD5Lzy3H1GxcXfBjDvapTEFNRQMACQgABAAAAAAAAAAAAAAAAAAAAA//NoxAAo88KEHu6alA4pJZaPlaT1YgzAMFVyIzKmhgABDD0CjlkaDLiUoXTeF8UpDUB3ihbY5VTR6U8lUPQxcLwH9SiTZVUwQtTKGBwicAwxCMxqzVLpgU3ZVGbMy5ifN32ol1BVVZyrer+l+yC2TE9BtGpQQZR2q30vSZf79SV/PJrUtKi95qkfQWpnWizbsfTSU1uuvff//1mJtH030rOYrWm2+ktGYJnjxV2FRLUhMQU1FAwAJCAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//NoxAAnpA6cFNGHQRqf7P+fuVt0QEpdoC0w2DppmNsnVXAYYxByHznltQVqJsPS/UHQcWI/FWhib7ppgwu0R9JBlZdMqi1TuPRW5eAwGFkyd46dhxbv13c4gAAO7v8iObn/9d3dz/d3d3Afd3f0Rz/iIjn8RERz9EREPRERE+Iif5In7u6fa7u5e7u7n9f/R3dzRE//JE0AAAQgQARMi//0T///rv/XdwNw9MQU1FAwAJCAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//NoxAAs3BqMDOZQlSCNTWuW5mWJPGGAKY0TQYSWvOK6JiRPnjw6jMiUBioHQlBWwDZAEQDFFml1LNXTZdpYZQJFZnTzAmJvbUOPsy0YfSgh93n2hVIUDYRnDktrCIWvJJnmVFRU0VFYlRUVFRUV/+pVVZmj6VWFmv6Ulm5quV+a/H88rXBzKqrVQ2qytZTWtfdlM39tcX////fzX/zUmrWqk1Iqq338M2xtcCxTeq8MzXx1DM3BTft3DMocs+bhSYgpqKBgASEAAIAAAAAAAAAAAAAAAAAA//NoxAArLA54HuoPWQnGoQI699JMZNAEYQBgwGD7KGK4KhUBlZ1gjB1mzt8OgwH14EIcv0vAwHEAwjBOOv4+bpAkCI4gOzwp5qCEyRkVWgOnFZDGhwHwcDCpX5m7OD4jDXFHJNNSmWRoypr2Uyf8aElrWNo+yJ4ZZniFqJr4XqaZnH+vN40Uu++skZf9eMCOILtHoY7QW3JuSOhdzed/uv/82Pln6b/5hyETMwThIR06f//99yrEiBjCYgpqKBgASEAAIAAAAAAAAAAAAAAAAAAAAAAAAAAA//NoxAAm7BaIHuDbUDLtu5JRS4Y/Gh0BCQAMHoAOb85HUEBDNTW5MazDjLYZpGBGAAFbn+zbPbkR7hYpJG04wIGGkvHJpvNmI0KXN1f5ktGyE+TIcqsDL/2G/OgxCFrTEV1OcdsEpZZaqR59G2p+uYk2ndPMTqlIdnCyMXWtlLQdJJlmClpvdTt////8usp0q1Jpf1rUSKaOkYCSrXV2/a//vuyZiVsxkmIKaigYAEhAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//NoxAAs3A5kEu7UlA+TMr9eJij5vKARGQUMXwWDNuQSJumEIEGInhm/BGGeD4qCCEwU0IA8Kkp+QUUDMplzvhQCfmUMXlcZdIYA2bGzno8HLYXwzVh46HGLBNRB2fuQMPDyYhICakWyVGdXKV6FWMVzR4jEF0Rh+eQkp1B9myxhXfRHMoa5i6a1IqfmemQi0vdnQ93W88hMO////9jqj4ZFlupmb+e5jiuMTXdRWEEUPq19Pu3nulNqzRkE4lsAqYgpqKBgASEAAIAAAAAAAAAAAAAAAAAA//NoxAAty/6QFt5Q0RwRSkYmaac37GGvg09K0N8oHZ+KyJOkLNVrXIoMVCM2GFOHZxHcEsGy2VEBZgsoi+icqFMMcAQNM1cuuBACsIt+nIsCHDiAouyDk1V2nJ0K3u8/ErmrGHM/rePc9Ke1eop4W7mbririUmKn+klqLKBYJR7wtpL/9Xz1//9f/zfM2hZ6TFJPVpNpFOlWk308U8K83XHdSNF4q0n/4+eIp4Mn6/9Sf/+pKDxjC2UXhXeB1pNpzZAtTiYgpqKBgASEAAIAAAAAAAAAAAAA//NoxAAt076MFuLbVS/tpkqofr4v87zvkhhDBlDkuUxFWeJZFHFbbHYm1UwFezFwUBQFEIAUmgqXKcR712zTc3hZkomYcFHKdtXca8jKHAlTKC5fFX2MxtND0pU6Gxw1Fh57YPSx9Xd8OPe2Xxc0bQfahUfcLtuToCw7jFMtSlrns5qq31USla/9y6G1H06KQ1AzopqOIG61Uj51A8ZOtmpNexx2mLo1s6zpqdG9kkb//9+cPfWa/49ShU5xf9/u9ZDQmhMQU1FAwAJCAAEAAAAAAAAAAAAA//NoxAAvJBZ4FuGbTB/ils3LMpXORFhqUoAX4YGFotYIQOYetZyQOjwVdNR9PVV5kz+nojQHCRCqCla3UbE15tqCRL6h9BCYdKKyI2pGRzUNMXmK+djZI4K9TvOHq/y10/+fUa318ue1ajRL82m11Y1TCnQUdDljxUpStExMfpIMy0mWXal6j/60VxJgzvb1rQWr9Tosy2q6TfUqeDietT7KRq12UbHVmhkiSJpapZKDuLVGC1KLpcApxyuplKR2WzIakUzFBe0+pMQU1FAwAJCAAEAAAAAA//NoxAAp665wFu5azS6adkuuUU5DELbgxMwGKcHGQmO4DBTBZTRqXCICFSKAShN0xMRE7wCk4EFTwhZz84RWjhpfZdFySoOfXC1VlLXlkoW2PBNjhdq5ibpHqT7OWeeMXVrpHmWugYmr0mVNbqqov6Jg+sFZNnV11p+yy63ahf2/XuTgflKVt3t+r0etdBvu7mYQqKtvZ2+pmdVKSqCFSlkskipFaBgcGgli+CaXTIO/Le/80mIKaigYAEhAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//NoxAAxQ6pcDV6gADyrAkVsO/AzW0eiyRgzAvlYiBfwWAMMC8BkwGBozIOATMCwBwv+YE4BoEAgBgAhgJBnGiEH6YJAMBECaFABlAU4g/oyZUEfkGBvwdYhoBYMM0FvIFQQbIJAHlGgMaFzQ6xO58ihKG6aalmayePNbRRXsgYe9SCqNGbutF00y89BWkzLUIDKNC+ZuowLhcQTLhcLiDG9N13MXu7snd7bY6BJk0l1JdKy70Gr9//1qQLwoMtMmbI//60Pa3ZLX3NiOSebV3XrTEFNRQAA//NoxAAx6/Lpn494AqQAABPPLtvXdrv//fCR9MafKhArcG4r7MTRbXmjSKaMrzr5vdn3ojBt/D5aHrdoXfZxA1oWcbn/4xFIqHC9pYL22/bf3/SnpSiHwXr2E+Zov/xvezLQtfFvPMMCqnAHDUnoJ+ohSoShsb/5m//OhwViscGePu990PcB8kiRyJP46kOg6xjwcf//0x6f4o/vun//3WDCYnL2fQWWbVreTfrTWJf8TfWb7pr6vd48iP7//3vf729i40zQYi5bma1vbNdf59t5tqTaYgpo//NoxAAwzBaAF9yoAAWapz+2asSQRGEQ8YlehlAkmFAE0Iz8WzIIgMPjoyX6DfZDIAIAg8llWMAhQxisjLglCBC7L8WYwLnFkkEFzEoBAAiukYBjJngYRBgGCwADhEYCbRKIIiELmI4gouEmSZYutUkpaToUJoh9bfWi/vR2ddXo1VpD8JGXS6km7uuyupIzXdSkk0dt7+utZKEiujtrP1K6uqtKpTrooppsupOOg3RomKn///db+db7pMkk5gpyfSZSZoZJlE2VNUUlPpGR9SYgpqKAAAAA//NoxAAli+KUHttPUFt975se9vdhksMQ8HrmbkZGrPE8JgswEs6kpA8EbpRkoWBkXzWd3tLVqxyNRSJAVCjcXUfeXUBoXS2zl+82SSSaub0E0yTSu1aCt8vLQV00TJOq0/1rZSGXgbxgaIMt1KZHf6KPm2TU82j0+OigMv/UKoy2foples5XuutQoE5A5HX//p1Mf47+0Iw9zkOMImnI0wci1SYgpqKBgASEAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//NoxAArw95oEujPSSQClnSR6q4a6TBljjVEC3AC4MmBD1sPRgMdT6E/HDhuCAVMEQLAwNonmDo9BjPlAFsQTrRjeqYfmNw+y9iBQCQGDIwmRtQJJEHAsr1ZQhBMwcAZ1LViHrgUAAcw/TAIdIKBDHbad83wFRpM9tXOs/NZ2qxoAOY9KO2/1nfpnvtU2PiIHv+ijQXjY6z0NT7K6/+p420X/+c6mPQKk2tlWOTzCo4Lj1HBSLBvc4tYqrtMQU1FAwAJCAAEAAAAAAAAAAAAAAAAAAAAAAAA//NoxAAww9ZwBO6UmBnhdqVydu66TAswDRMAQcE4wDBjwjg0JRhMBxg+e50KBgChw+ShyYUDS5mYZs3QQgBwgCAC1iiZgARehxKrc0T2HlBw4bgeclrmvPwvsCi1UQYEBQBCuAkeEUHla2u9nb/zlent3rUnJz3MMJDHQgMMY8jJyRp9z1qe7zDGoxjKUD0VD2bzz3z1vtf+6Cod3dUYWQTeZpx8RTfaeljL+ayqqWQ0hE07Hx/q/+26E5C3com3RxkNmVx4QlnPljw9D6yWIExBTUUDAAkI//NoxAAuE9Z4FuZQ0QCDakronZdSnYiYFERqcREAtFiiaXWaXJgMGAXqnKSIIQyBgYh2DAa74kTTRoTUIWw4wUFBSr6vzGHpQCtouYv8mNah503kSpIjTjUASy0waAWSQ2bukS11+ZqCnZitrJmOO6Thm+oKO5JNWFX+vZfZr9WutYFlrtdfmFX4/9v6/hjpVe2q6EoBmEFViOWrn9Y66+P69lmrZoxvXrVQ0/H//8/mh16123/6Xp1A+xKaxRsJnVUU3nUTEFNRQMACQgABAAAAAAAAAAAA//NoxAAv0/5gFOjVbQWWtr6qzvJL05fwwJGszTAtYo8fpuoiRhCAxgyDhiZx5iSNhhEDpfIoA54gSERgyUhn6FhCAbcmMvyWWeFpHIk1uOpGMvEgyWc7qqkGv4DQEMHwBpYYn4Xqal9NunfipKaTilrQr/HNR1otiONMjOnux005omh3rrD9FQwQV53d36z5iYmMYbVEQgEcIz1OeqHPOO+k9c9kv5vaqkw8MSs7v/zzEy49M2QjK6H3uLBhcgOOcfNIizMQ6kqIReJWExBTUUDAAkIAAQAA//NoxAAm+95sFuYOlSeJbjQ3a5GI5FR0ymMRoQDYMUJ0caDyEKoCMXWU2IDiZq/lGG3sGOSCCabu7kvYbKYpqharB8PJuuu71E5b5St/zEaWTuNuWMSeOkWUOWql1IDrXOuuXOZv5ph8vFBJTGqfO7GGbT6uguOXvqd/zRkgv7nhMqvb//Kula19Hf0UR2Z2z26f7NULk36nnaPzzUnGo5FqGGSmpPkOQpiCmooGABIQAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//NoxAAvS4JQCu7QmAkp1haUiAFgYVAoUTkwsDUwUSox0Dk6+wMxxBURhUYsPWc0AqRIsZMFMBYaHCUyx8PJVzDA5/kGE4kyGiJ6uUzlYQeBl8kIKZwErFgd3G8SSYCbUUrFcWk3UuwmzuZZTavvLYttCKfST+qqB5MStTctGPSnoqLjmG1/yx381NwNqE6/5El81NGxFB6rJc/bCAFxgxZlOonruPrJ/+MfP0MleJc2xCmK+xqxx/P/svmkXz2MF75I/ACZAM719iYgpqKBgASEAAIAAAAA//NoxAAqe7qAFtjLeRkTk1fP7VLSkAyCigVKlEjKbIvYsgwYHNQAYGUweVVQACRmjQaQyGdCAkASVda71iRSPrDq7afTK2IBEF3PYAkImIuyG3HtumzufqRiMXs69i7T2zRCcQm7+WX38uIVe6I+hZ/u8RCDgYGIru8RE0Trno76fn/u5/1zAEAABHQuIhdSF1w79d34nohV30I6aJ5Tqc//zs0+hJCTndAEAjsHA4xsZmx7454AmIKaigYAEhAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//NoxAAtzAK1fsIe+8AhKa3bb54a/9yWcgyVjI6KmbuoTDNS1jAQj83GYl1NTU0QzarQByQajijg6tV5lVhrba8VWijlhm/vMKO1Ug4WWBZpFVWpWtrkletdQk8SI6lU1KJm3V7rEaurQo19QaMNYuvi1s2fRrfMF7XXq+HjNZ8+rWtaxcb19f1q9VrLb1rWa0K3+7bzXWWMxXHVf62/tCt/8//G7e2sf/fvi2sPrbmgtrA9iywI0PcPEj7dsSXx/4NWYKYgpqKBgASEAAIAAAAAAAAAAAAA//NoxAAxA7JYHOrbVAE5WKcsdopW05uRgENJkcD4NEwDFEaeIEEGEnuYADCa0BuYCgshJb5E4wWBkxnvI2RAkBBsRBA05LAcCcdABC1mEyzCUOSu4xiAwtSzVMBj8oJQQFgLXNGpTM9OsNag9mBmVX7Wl3U88sa9eO4PSyumuuEl4qz1Ut7rhM1A8Ph0vrOtk1l1uf3Pdyv9XFRNNp17uipY8AhEkWdJTqqm2ips6gtmqa2paTIKUmmOAPKTpLb//+5r86a99U1QY4BgM0hbcqlMQU1FAAAA//NoxAAvw8ZQFuobURlBhCKjX2xzL/LZAATmZQeAEECIsjXEugESgGA8xCL4x2E8MBNQUKA0YVgQAQFMT4cH3WCBfSISedYcAIKAAxd3Z4RgW+C1iqBhMiyhS31it3dxEIiE5psvv0NXLqgxdDAuKj6ofoT9tsw6hOM+eqh76i/1e55uo/oOzTjl36hV/9aR/qq2/XUoXAlc4s2RdaatWronEGTdFJFVJ0D5TKDJmx4OgLWXS6bOy1//7NMU/njCyqqSjps6S1LNUKHcTEFNRQMACQgABAAA//NoxAAs+8JcHuFbTA065GY9yWxykcJlZoIFkAZMOgc048QABXqMEPA1SFRwALVbmjknoYdJh6UXBgviD3MyQTKOL/m6ZeENwO6IGCKvGUu7RRZ6mPbt5/6mLRaCxHZSwUUF0vlZB67FSrspkUtWFF5EWyBqbhJTVZuaWTUkYoGyDOpb0zJJ9Gyr6l6k5wQQjH0TVJFzyGqySClqQSM0UNrrW6jBbnq0jcqCmurdd/1d0l62W1dJJmPtzAy7WPvIXpiCmooGABIQAAgAAAAAAAAAAAAAAAAA//NoxAApEgp0Ft5QlRgCttHzlHBqHQx46EoEEgqfgWXC9adRl2sawwGIKhKLwoOgYYBmDe5WuLCBAaKiW7GVfyuRw2/ZbQy3wx8zzxAMrxrEMryQCPTCp6znCwjkNQ9BcYt1cVdSi3aD0dJjVv//mJtHSfllKBYSUUt06TEzEsOPFCxhRo8wMjAqS9U6wY//0fdH//tuxXXKTBx7EWr////9Xs6r+p6a9ByaLfn6+8/WUxBTUUDAAkIAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//NoxAAlmtp0HtjbSFLK7tabUomL1OF4gBFaKCKJmqKttdBh9Yd0FqwQuSRFpgXQAdfS+xuQvtXf65NUL2PWWxNSN1Y2O1ZTyalkuq7s9sXgZY4kyPIQKt/FBanmnYe30K2RX7rRY3JgLMsmKDqXUnXoqWp51S7tqrbf9j6KB+srPorNVOm3sikj2mtmQOgNKK6Rk34gaWOkLipMUFxRAWXEE8mIKaigYAEhAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//NoxAAwq6JIFO7WzAKShgrdGUJzrSTvMFYaNhRDICqLfmwiPAYljAwRTAeoDUItTAAGlbSQC4cGAQMIR6BVbJdqKJJKwjAWuV0o+/Kw7d2HKqH4uwIBjCw4tgwZqogAhole2XSKvYehdqJbJSutspxU7c62oqN9L//B5tKPnPuuGucet+fAznbPnWlLpbV/XFxbbmbfmrP93/7YX/4falKenM9dtY3uHXFWyFYqqps8X9O76+47+OXnoVPkk9bmqJmrjrLfbjoxTw+whbcrYmIKaigYAEhA//NoxAApe2JIFObKlBkSRnEOOcmktctSYlzh/sNGCVUCisehLYOJAyHTG/+P8pkycGEiUAAiTZICGBqonJNTWFbnG1ZmMqyua87XmMwCqQ6BDIAFo6uZVEknAEd3KteriYXRYjMZitdRJy0dwZCuwlYxtWuOk19zjqM9gGS+q7edGPVF6KUny/2bRCi5ZTuHTPOk4nKlUDpxZEILGbqRO856W/SWRDjSLY+waCYW0OIWVdiYgpqKBgASEAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//NoxAAu+2JIDO7KmCLJAzd5LA6eiOhiKYRx2A5hSIA0eZqYWJgWEYoBhiOMh16DhhYoYQJgpmNFCTIjQUmzDigzQWMPJzDQAxQOFQUBDDMXSdxiblKhQEGsjS7U50kC96JQAAhYGUqFgQCADkv0kQ7r3v48bvyu5epx8TsQj72VFlVCHQXVlRNSK+pxjkOjB9GOgOinR5O5Luky3rLVfVmZTiDKhboPa6jggOMVZGM7aDH3cZWkmrpS7P//rEQOtOieJCOXstvWmIKaigYAEhAACAAAAAAA//NoxAAq0oJkDt4Q0SOWt8JM3TKHYSBSEfxjAREaUjNWQHAqe5rtGbC2GKiZEWmBgQIAjIygyz/K+09fH2nPANuL0AAWUL+XLAjLnhXbI2SwFDRc0gYe7ibAcIcCs9MFbTD1LXCib8xKxfr3jpppuvn5qUuaadov/27Xb4tVphqNKHNrF1FrO01/8ft8TE1C000ooGxFZv33lhyKzPr/p70KqmvrympAoYmI8RdymqzvWWmZ7ztufpMQU1FAwAJCAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//NoxAApUt5MHOjNcAnHXCdL7KDKQaS9xg+ept2HBhiSY8VZhoqoICcGASYjRea0AMAgtIgmhoAAGYBgkYAEWbMhgX9ROUVWqVAJXmsWQQ4z2GnryREdmGoajUZAASiQMyNrNHKaD6W53DWrt+WoZNTIuJgKIEy/blNqFcSG2CgKnUkbKNlDnNzp9//mxeV5qV3m72ORD5lutHDe7bj427kt8x56PzILw2+5VDLu/AuJY1MQU1FAwAJCAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//NoxAArmqowAO6K0PQ5Fl0mxEDIEAQwJ3U5LHAxHZcwxDox2owwgActOZxaSffBqY4AsYqgkjgWXAAcGPMonKpAHFBlC8HB4EBhQZCg5CgFhlpiB7dGVm/TLyl8CQ1Hhg2NiXidO/zV6zV3KKbCZlnGoo0cNOyKhhcVEm1L9WIpTVUm3TR1ufSl7rx2ri7bqQzvRWc3IFAw0oeKLOOCRrvOqPaKu3hZakdfLPTZUUdiR8WCYxQ8sggYbWmIKaigYAEhAACAAAAAAAAAAAAAAAAAAAAAAAAA//NoxAAkImpUHubQWE7tLYLMqq8pGQFiGiggMBDcIKTV4MoEUVTDDs3IjHghobYZM0gwfjMSOGLtIZ9XkbtNrPYMKo6alLu40tX1DIERSpruI4nGjhqfA2xBj/xKJmMiWx9d/Ag5LySPJrqyLcd6EslzdjFLMMv+etZf+OquW+YRuxICuGk1x4VDwqeHgQUc5os54oH1ssWplXNXeUTEFNRQMACQgABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//NoxAAr+vJEBO5G0FknWtqDusnIFQGMKGDNEgRAgLmCQBGdxcJ7opmAQSDRSMcTlMAASFQQMOAyMFYvM3hBO9M01zHDV21ks+X3Lllpy25f8wSTNBC4RnkquXIgETUTvBI5jhlr0rH4nM5+VxuG5fY+kwQIAAAgw4t3P64d3d3/vuLd35l/7hw4GBvogGBgYdzhZ9tO2xEXpu+RLTe1CQYZcGHQsjpFm06WeSaJC8kQiriwc//fsQUBAEAAmIKaigYAEhAACAAAAAAAAAAAAAAAAAAAAAAA//NoxAAj44pwHtjLSBNZt+NY2cqaChwvB1Ao5FQUzsdkxi4PRRWE2HXUBMGmQMfN/NLqZUsE4sZjuFWtLqcmDoalViZlLAYFq3JTGaUBEr/+Zsx1ozMzNqX7ZMqku1PahjFLoJAYPB5cxkM/0ZqOxSllpKrK0qpMPDHRUGlY0WEmzGK7qUqb3K3KUoqIkVS9n+y7fpViP2KcRMOiVMQU1FAwAJCAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//NoxAAtGm40DO7QzBQAEASw6gLjOir8xGM872IEKBwYMA+cCBaYbgCYQCSYuPSYChwFgkCAWEQVGEgYmCoeGK3pmhR1GBB4sDKWlgOC4/F10MySoEIayBNJX53RaXNMGASzkteNCSmrNyuU/UFxBs+RPEBENu45GtU8fnNT3tc/w4cq13XVevzcxg1g26/mftach6t5GKL46bhkac63ThwyGqse49gCsiHb2RV67GttL7/lX4X1NXWSPNDZNTh27WmIKaigYAEhAACAAAAAAAAAAAAAAAAA//NoxAAoqnY0Cu6UzBQR6kF5frBVKTBYag9bCAFhgCjZNmjBIFCQAzGA1zIYIAgNR4ExAFoCBQwxEAyArE+IIA6gM0IEeAt6tRZhfF5GqkQlmLtqVHvbFvmzoOsmgpIxB9wKK/czPKnnyppA46yS5VFfe6KcWbc7RlUjZ2bIGSr7zHBwscfpdE7tMWpeuer3ObM1Y5VJT1OV0QpSWfGahNaneJv9VMlsfetDGTynL3piCmooGABIQAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//NoxAAmKnpEHO4WyAU7eF9sciYO8id4EI41CBEDAIgJMbjRZ2FQAMEguMWALJQMS5bsl4XbMMh9OYAVGuve2JiThQRBdyUvA5UM3zs9a8IdR5y8Mg9FbNjXZ764s3qfnbf/e6a+IuqfTanpW7cnMS6slPhiQC4QRKnnpZM1Uf8/3PeyWd1/9IXKJEN2StNtpPC7FywNTjXGzQNJFhc5c/7Mr/9EgmIKaigYAEhAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//NoxAArgu5QFtmHVBgCsDM6OeuZKZmFSh3Q0YUKF6jLVgHHYgADBEw2QoMmDgwYVvdQEgpgpoeoimFEQCGGjls1JumkGzCMu2ytJ4xYmMwJgElhQAXA/dYuAgY3Nl8OuPWQaILTLJ7Cj04z03d2QTx02QdPobH/e/Hj3piB6d20PphCSBpPYwnpCiEk6BFA6wdMxC0zELh7aPcT+volldC3/z/iURvErxYEJ0QGTDBcPja9ou6TRpJukExBTUUDAAkIAAQAAAAAAAAAAAAAAAAAAAAAAAAA//NoxAArqoZADObQzHlI2drcekaygqBCX1GojuGHlFQx4HQ4fggAmETOeUFoCCCmCcaOQWD5iR1nhgCY8HrQBwUoUCg3Nf6RLSlbnTJgAxtCPZJyIDBAYLByk3VQ8f1l0rkUpluUdBxZw022tTdSLhtUtGlYZ6/bRZWFRpNNKsk4lRh0g2KAWKBsebRVio5YFnFRwseCk4VNKOlWaGlY9a4tqtGdmu4vNSwJPDowLjCUKMZXX+vsbUOd7UpiCmooGABIQAAgAAAAAAAAAAAAAAAAAAAAAAAA//NoxAAtgqokAPdQXELE5l4lsAuAIYBgDZgqpCGMGEeMBEAYSTNslDEUKCIRDFotztQXzCcBggNVnA0GAECZk8Dp7cGpg8BQYAaRIsBZgKBjaK3LqYUhaIAOBIAmFwbmoQuFuTAMKl8JJtIUcWNAUVvTMgFwbBDI+XJklubkcISP1yXUfFQsXzBR9/+aOr4sZfySo396djrsb9u3j4z82Yi4577+Jnpmm/J+L7uP8dBadMVyWKB9XzLGqdqPWVY+QdfpTEFNRQMACQgABAAAAAAAAAAAAAAA//NoxAAi2qJEHuDNNEpNtCGvxuMxhz18mI5AEh8GhxS8xQGw4LFo0XDLQpGAqu92WzPUBEIbGErEHzdprLXYDm6SXxGhZ4+hj8CpfODq2BAjJ5vJfn0Uve0xp8YGHMvcMPDBf36/L/IYY0cPwgfUdLCFJeYVdMu5hSbx63MdT/qOVlJumWk0FU8pbYnU1GoQfvLPVF5FSf2JiCmooGABIQAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//NoxAAoAqIsFO8QXAbtBw7C62kIRhwEmJa5B7zjQbmEQwahRA6EgECzB4OHjcFwQs9M1EQmCwUzhgg2uEv1oi6otTtLiuViUsKLdgZcq4UOd+BIbgyH4Efi9L4sKGi6DikiZXmpzP4nQLT/D/f7il73FJcXEWEg+8hrsR671Z1si+A9uMfOLLF/YlHXD8QIr1GMkRFuaG1sp1jnajqDjbx3sUZ/Zd/uaouj6uxMQU1FAwAJCAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//NoxAAtSg4wDO6M0A0AwJ3YLLOJ+rmMBwxOgQWMDwxHgMMMj5MEwCYyYcCIBhEGAWEYDlUHDBcPDEwXzRUbDL8XDUETYljXAw7sbYgYw4YNeKnAQHDBREVLfLlLxFtggiDlQRIEl50NRUumtQBDUaIg4mAACOaeC11iKZrsdh05VFRyJJFawS2fcdkt/9w7Mez0RrN2LKdpZ3JK1nZ/8+fvv1sZyX307iWOmQKaExQg1kNCtLScXvV092n//dp5z8gmIKaigYAEhAACAAAAAAAAAAAAAAAA//NoxAAtq0YkDO6QzB0APAUxaEpXF1zBICDBA7zactDAYfTD4CjC5xDEgNxYNhk0jPAHhQFAwFAgCjAUFgMC5jhbJnQDQcPYYGL06Ro2DTAs2RRpHdlD9OszGVyqBUVmBGbpG/PDI9AIoYnOpEFwTC8FmsNQqah5WW/5IP+fvt5tat+riU5l4eYburp+GtL65XHGDnYejCS2YbT1dZtqLJGtsU7j5lpEVK2iJ7tr5qe/m//hZ5+6////xvTw17CZ/byHemIKaigYAEhAACAAAAAAAAAAAAAA//NoxAAtk7oYAumFWIL4Hgwj8CKODwNmHAjkylGEglGPAlmqOtipVgYViQ1DYgMxABAOCIWBNBAAQoMQKJA10t3EIXmCAMpsgoBYwq9/JFHlqZZ14tAVA9UOoFI/NDnOSnI/Qq1irfDdd6c0SGf59uhH9Ksk+/bdF8+s0tGf7P8Zm9D/Xdz/Zfdpj0HOay0elunUnK95jlVdwwf72nn/tTs3Yo1gq3aqj1D5hf5+9l61K5H1c9166prpxKNOADKSCmO6ExBTUUDAAkIAAQAAAAAAAAAAAAAA//NoxAAsw0oYAO4QyCAAC9K+QuEIFBsw7AAwPFAyvHswKLYEgWcFUkYfh+Y3gIQDwbfCcBgRMDAkGALFgFL3GK8wnPwxBOTCYAMTyAoLrwzkRetwaGlkrf38eCjhKES0Xo4ecFSqDG1mc92q84YH91EHze0Uli7TDvS8/dpaQ8dvKx9d3DJRCxntx3OmxiNC3jmT3G3vfG23c/U46amPeNR/pNY+a7m4+vyom28ZdlIiWJkR1wgFCdApQWOIkvZqTEFNRQMACQgABAAAAAAAAAAAAAAAAAAA//NoxAArCrYoDODNcDMADgSXkV242KM4iKxk0sAQjAQFnW0iJIVoxiQ7HOA+IQWXMVc8YgFBrZmnLjGXWZCUAZhC4VhFVS/aeinBd9dQAAScoCBiS6zi2ClIOAZfRCh04qw9530pYfoIcqzkrl+g4HCAxG3WsABS00R0T67hFMu3t6btEDsIBmBsl0p/IfS87topTv9PKQfvrSpk+oXSi9hbO/v/8paC6ddRw125ZyKsV6yiLdTsMc6mIKaigYAEhAACAAAAAAAAAAAAAAAAAAAAAAAAAAAA//NoxAArk2Y8BOZG0Z4jDK2CxFNBCeQDQz+MRCCBCAzRB1Egs/hpVTmrA0BQA8I0IQYBxkeG0aCY+SAUXZc/pjgMRgEuqh2V8XlRwTGS6CSS2KzS0ykzABFDhYYuaxBYWBFjQ3FZiHqGWzMZh6qJDCgEQAo1RuUy5rx2vxy3P/h1F2okMLEgWzlDX/7WUp1vKKl+/5dn8GZjpMagnb/Iz8MU2BgmMNbelEFKRn5fy/+5fSYLxHrH4yuldxMQU1FAwAJCAAEAAAAAAAAAAAAAAAAAAAAAAAAA//NoxAAkInY4FOYGzBvvSC3wcJTR7y9LIw8HGHwULDYxiajB4AEQRMlPcz8KRYKNwEgU/4wDTFGzPhCAaiz1zYkiM0p+InRPvL5e7QLlBj/TEKrNypoHxyr8Ow6WDQcizWZ/5Is/aX+rBaRTjAiNVMwbkpqZX/LKs/Mi85CzzkX8smQjpjhh6PwMYKiNQSHyoDSCpNTHOH19+vs+vtTEFNRQMACQgABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//NoxAAuKpIgCu+QsAoMGgGLZJoNGTSUVMM0FOOQCMJxLDgAMJxMIhsMIwEMOhxMaQJMGgGLICwYrCA4CowwBvTROBTMEwABS9KxmYwAbAqaydU27jcF2sAMEACdds4taHuOFKG+w+S8FwlDSw2SHoj3ED5kPqe1gaPObqVZmvZ8VrmVZU42ZSpqiLdk5iensb1v9jxm+Oq4sq5x92hMdyOxOp8STnw7D5OEiRJrjMetK3JU9sC1zOdD1JGLMuahcgZYeuyaYgpqKBgASEAAIAAAAAAAAAAA//NoxAAsk4YcAujLdEDICLSXOpYXDFgRMK4XNvyQMMwrMQwdMVm3BoGA4LgYJxkOIiJRgmBAOA4DBSYLBYZBJwfcF2ChsWHX6luYDgcXMWnD0ZfiIxeGDDEIJe8Tw1fu00WvVbNyxjRWeYfvGmFtSVwakWTiVyFQXn6aqq2fJntDZe3TVDhzbMjLQzgtaRHxIZFZtAA1yHrbkoKo7ILWH23Ml9XyLv3oT7p3wo36PRqj0JpRsPHoSDi4cyB33UrTEFNRQMACQgABAAAAAAAAAAAAAAAAAAAA//NoxAAr6mYkCuZMzBoFgq1tajwgoAmGgcYe84Q4zIIVMHAQzVoEgTBJXM/kMzeVTAQoMSAcgCJiIoGUDgYeih5Q2iFYS1RuassCCBlSI8AQAwBDKOM5g5Lh+gLGFAKt8nlDZQqKDg0x0ACxIowRMGpEAAg6Hwv8WFk917Pp3Lv29wQMxlb19shsgqLZ7t3fdyMjPj7V9y7u2yK8Zjae///bHynZ1OsegkXiUc2Fyjfqr6NVFlq+l4oKN3dCYgpqKBgASEAAIAAAAAAAAAAAAAAAAAAAAAAA//NoxAAp0tYsDObG0BFApN9HxSKYYp0DdGb+WThkoZNs6ExAKzBAjMvOs9uRgMSxIOSMs8YFEBjsKHLCKZYNmGAq3XLX6vpMmPNjRRfh7zDSQcnzIyYmHnSYk0UKBocARuCnda61mHYZhmWymU00al2AYMKlbY22OuqhVVV2ZhWz1c22Y84ff0FVVEqvc2MzP5VoXuu1PM/ypjakMerIx1IL40LHySTv0VcKDTEn9xd37vzj0xBTUUDAAkIAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//NoxAArq0YcAOoFVEiTBEGjA4Fw4SwgAE1jCyhz94GzBIIgqHxzpQwYQRbEwiHU2ZGgwGFNc6hSwSHMwMGw04BNO51GhqbIZMqSKkTsS+EF3UExgKRyegOBJrjgRphMCwNfu5T6KT2N+AmquZgfIzTrEaJa2jrVoU+7G1TTcMOuxv9y8zVjKq7e+eR3Mj0sQLa77RoioZGu8yPMpnUZGjpp8GzzvV9Mja6kppdmqkLQ9qrUu++0A8g5sOpiCmooGABIQAAgAAAAAAAAAAAAAAAAAAAAAAAA//NoxAAsC04cAO7QeE/mHKDBQCQIABhWAZkknZ/gFQ0Thdw6LC4yMAcxMKGQ818KDgUOfl9pEJOmAahzwiz5qrZYytmON2qzzdrEnUJHE9GpOWdoqCjfdz/paudOFrZLYaLy+J+RBsfkrZAXKtLE1tFw8oJnlbbGXVSjiUffSRt1PfW437Pm85qLx1N4hQ+dFwozpKkR/8bZfd3PfzVyN66jkf/8H/7Q91HPP/6j7WV4kVUtKEnVocbrBDX1piCmooGABIQAAgAAAAAAAAAAAAAAAAAAAAAA//NoxAAte/IkC12IAB8S9oGjF0DBIHjBQBjAoiDq4VQEPJi0MBuMoZjuKZgiBphqKJggExYAQOBpJ1FAHAwYEGAQg6pczBlGE4OYTZcKZJl+QcBOKhBiDkXc3LRWSN5fQRJ0+xkkpjFKtk3NTdNXUW1qSun7vN84k6zZF0KSjxupk05cdbo6CKR9nerUlRQQT6dtWYe6Zm6+pM4gpnWtJlqZbMfdk6zM/tplv10var6jB/rT9Tn2+qyt0kFV6n+cdkggmIKaigYAEhAACAAAAAAAAAAAAAAA//NoxAAybBbhH42gAgCARROByOhyOx8L/UtdKXxxakALwA2+aLcV0li94AQcChAAJYB0FzEOEdjB2wMlbA968KEBawbGyZJhGr8MYgYkaHiC08ZcWWYqfV/FnjjIOJwLIzYcYj0WR/5Ax3g3UEakGAxQoLhQGgYCgBuVEUWR//D+hYuLaDcsN/H8MjixigxmyuRcgJGEVRKRdmVSX//k+5cRTPE2VzAuMaMmgUnWVTAfzUmDh00l1Rj////oUGoN/OsViImBwyENHaYjydHJOpmZMkVKBLpg//NoxAAuy76UF9yoAT0Tk0ctYzkFvqMDMwwBpFWjAqAEAQo6jpZFAIKQDKDMBfVdMG9fmC3zyJ4pkCFJCUwbtAAA4GHBuBpgfAYaDYBADAsKQxiH6i4AFBaHKjXIkOcpJTonDJE6ZJXLpdLs8tbPTN3Z12ZK1TpI+q3tXpEcGXhmzxkXjZ/79SRsmykq0epWmitlJJJPR1rRbq9kUbVzIvU0Vl0y+pSX0UW20kn7ot1JGJqjSMiLGyVq60V6kjJJYn0FFSlH/eEmIKaigYAEhAACAAAAAAAA//NoxAAsnBJ8DutLbCtxxrtemjUy0YADOLLRDDAHdtFoDElQBv3zCcDUgVV37ayvltGtOcjrI5qRRiHMU3CIAg4EQgLDQkUwSFBCBQWAEtcj2FwiMMw1DAOfZTNVd+4PjElxs3MPkFMooMiuSb+bl1lUKZhoLYyU6/7Zec7ZTmISIzY0tRUfXkcwuMdWdA622lKEV/1TmdTS6RjGEgV4oecTClHNbyfv+v8tmxMOl5Bgw2yzXSskUnRmdu869FHJiCmooGABIQAAgAAAAAAAAAAAAAAAAAAA//NoxAAr/A6AFurLUTWdj0siDsTctekwCAcOSV1Ggu4roMBQwhI88FEIID8v0u984Zp2G08g7NTkNNinI2j6uYqgAj8ZPAeCAHcqDgCASt5gOAoKappiVNE1uA5OEq2sooJcGhPc1rh9Xd200hvxscfiuEdnE23X/kx6l0wqBls9cXMM9WRsokaZfrzkiJOkTbVyoxn3Eyisw9mGGaOKwsq+i/p+36v7B0JJ3FzNXtNzOLCLOhbprGOjtUawmIKaigYAEhAACAAAAAAAAAAAAAAAAAAAAAAA//NoxAAt2+5wFu7KnCUKbgcAzEYIUHpG6gwNDMYEQYADTSUDguAZKExg/LZ8mVSAMDDyh6V6giom6wM2VsT10zbQIyGgUzXIj+KgR4s0YuIAkCAI4LAwBABR3N8RggHTOUOT6s2qWbyzrY0zfaitTtuzjbtb1rQfE3Oyb0qMH23W4ga40QZH5gGM31L+/dq//Eha3qiXYwxjmH6ldHIDOzSMH3V1W2hv//93VjJDoeKWUoQFG9nMRIxzoHloORxHjjTI8kmIKaigYAEhAACAAAAAAAAAAAAA//NoxAAua45oDusPRCNxpY2bxRlcDcyQhjFYA6eDguAwqBIgCow3805NKIZBIwFAILALKgCABedDoj+kYvBx3bYczeOugpaiM3ACg2YoIaYTAmHA+QgiDgMW+CAxMeBfAQIJkx9G6XHTIfTVc0PZIKp4+5HzrTrW5CJipjOqKtjZp0787y30GoL9mv+ytNdB1TTVT1S5o8hdqGsYh8ufH0LDqVNqyXec7HC0ieNZj6or+e7/v0t2uPEU9y2PQIiw4dU5VgvuemIKaigYAEhAACAAAAAAAAAA//NoxAAmC8J8HuNLUBbfv9ZmzZzmMyEaILyB7XKgsGAYwR8TAYyS9YhK7UrsxXCliUis26vY513YeTKBpQfyO241TQWyerOZb062bmJrND6tR01RZI6ikz1VHTyLVJJJa3VRRVYvUSVSRUWg5SkUp65ieM3frVpld7aU8rruuMGIDhwcKGOoZjDlbqyuk9EjK01u1SX9P9635N9GflR0rx8hfeP2JiCmooGABIQAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//NoxAAuu45YDPbamC1opznSstnG7mAOFkDhaxUBJhYOAbSDHgKzCWV5NEoUw1Q/QFKdmCgKb7tNEeVvkn1cMqc6cht/i/4wAioCYuMmh/4KGETAUdotppDgel8DguGntYe+k7di+X67N1o2ggpqJMfeShP+ta1VVLdq3eXmsszYxZdEkwhjQ8bNW9Lq12pmjqvdVO6aFCaIO60k3WbF5I2m0ooVd1u7HD6ajmmpR5VFa1svX//6NTKUg3UySCzqKbXnFANFKNSYgpqKBgASEAAIAAAAAAAA//NoxAAsC4JwH12gABG5bq6SrT2ZpuA6DQ0U6a6pErWfmD4emD7jnVwbGQQfBAWEQAL4WEZxHJDWsPZmbEUYhxiRQNtHNAyzAERkUEKDDZBnQkJALyjLDIlMcxIzLKCCl2NUXTVWpM3Wi6BiXVfQT9aK0W8xbUcWmylSiOlTrWiir+talrM1KU7ar1oJJl2jVtRRPosY5gm+iiiitKylNNUtExbdba6lrZv/3SouxdMndrn4ADYUG4GXIT30JiCmooGABIQAAgAAAAAAAAAAAAAAAAAAAAAA//NoxAAu4lpkC52gACSQHMHQDkYgAkwhA8wIDgw3EQdGEiMAtuYKBqYxAUZC/qZICSbsF8aAgebDugZdhqFgi2LlEaigxYwNMRAzoAAowMaPgA5GAMWGaEtCASAwBDCANAIuYaYIEQGMBkINpEB4IBREITGaJVEaCDRZZAEjSqo6tSOLKHgWWSpAh2NSqftVkUIekSROF8u+ZH0Nutubk4ZGJuZmDHv/vX/1m6BseNzoMBEDm9nu/CIbCALjkBZ/7P/0BdA0OmakxBTUUDAAkIAAQAAAAAAA//NoxAAvAkIsAdp4AAsNM4pNcvNQfBSEVEGbVG3fG/eGYFsQa2YQuaRSaQqFAhq4h06xrj6IiKThggCYIClyX2MKGCtHcA7AQgkRYjtBsgZSXN5bScnTEL8F8DmQk/h6jKdsKGoarbVrIxK6M2q2NKwq1WxYSeOplhK5XPrvU6oY0F7F1Z8+t8bzWusWri1rWy9e2zBi19nz6uLW+a1r869rbzX+ta6xZ8MBo8CobEp0sDWJZ6DUFR4KuEQcLP/yUGnA1Ep1H/wVTEFNRQMACQgABAAAAAAA";var Xv=[440,480],Ol=2,Qv=4,$v=4,Zd=.02,ef=1e-4,Jv=.02,Sa=class{constructor(e){this.audioOut=e;this.ctx=null;this.gain=null;this.sources=[];this.stopTimer=null;this.generation=0;this.muted=false;this.volume=zn.volume;}start(e){this.stopImmediate();let t=++this.generation,{src:r,loop:o=zn.loop,volume:s=zn.volume}=e;this.volume=s;let u=this.audioOut.acquire();if(!u)return;let p=u.createGain();p.connect(u.destination),this.ctx=u,this.gain=p,E.debug("ConnectTone","Player start",{state:u.state,builtIn:!r,loop:o,volume:s,muted:this.muted}),(async()=>{if(u.state==="suspended"){try{await u.resume();}catch(y){E.warn("ConnectTone","resume() rejected \u2014 autoplay blocked",{err:String(y)});}if(t!==this.generation)return;let A=u.state;if(E.debug("ConnectTone","Post-resume state",{state:A}),A!=="running"){E.warn("ConnectTone","Context still suspended \u2014 no user gesture, ringback will be silent",{state:A});return}}let h=!r;p.gain.value=this.muted?0:s;try{let A=await fetch(r??$d).then(S=>S.arrayBuffer()),y=await u.decodeAudioData(A);if(t!==this.generation)return;let b=u.createBufferSource();b.buffer=y,b.loop=o;let m=h?this.applyLoopWindow(b,y):0;b.connect(p),b.start(0,m),this.sources.push(b),E.debug("ConnectTone","Decoded tone playing",{builtIn:h,durationS:y.duration,loopStart:b.loopStart,loopEnd:b.loopEnd});}catch(A){E.warn("ConnectTone","Decoded tone failed \u2014 falling back to synth",{builtIn:h,err:String(A)}),t===this.generation&&this.startSynthesized(u,p,o);}})();}applyLoopWindow(e,t){let r=t.getChannelData(0),o=0;for(;o<r.length&&Math.abs(r[o])<Jv;)o++;let s=o/t.sampleRate;return o>=r.length||s+2.7315>t.duration?(E.warn("ConnectTone","Loop window not found \u2014 looping whole buffer",{startS:s,durationS:t.duration}),0):(e.loopStart=s,e.loopEnd=s+2.7315,s)}startSynthesized(e,t,r){let o=e.currentTime,s=Ol+Qv,u=r?$v:1,p=this.muted?0:this.volume;try{t.gain.setValueAtTime(0,o);for(let h=0;h<u;h++){let A=o+h*s;t.gain.setValueAtTime(0,A),t.gain.linearRampToValueAtTime(p,A+Zd),t.gain.setValueAtTime(p,A+Ol-Zd),t.gain.linearRampToValueAtTime(0,A+Ol);}for(let h of Xv){let A=e.createOscillator();A.type="sine",A.frequency.value=h,A.connect(t),A.start(o),A.stop(o+u*s),this.sources.push(A);}E.debug("ConnectTone","Synthesized ringback scheduled",{cycles:u,level:p,ctxTime:o});}catch(h){E.warn("ConnectTone","Failed to schedule ringback",{err:String(h)});}}stop(e=zn.fadeOutMs){this.generation++;let t=this.ctx,r=this.gain;if(!t||!r){this.stopImmediate();return}let o=Math.max(0,e)/1e3;try{let s=t.currentTime,u=r.gain;if(typeof u.cancelAndHoldAtTime=="function")u.cancelAndHoldAtTime(s);else {let h=u.value;u.cancelScheduledValues(s),u.setValueAtTime(h,s);}let p=Math.max(u.value,ef);u.setValueAtTime(p,s),u.exponentialRampToValueAtTime(ef,s+o),u.setValueAtTime(0,s+o);}catch{}this.stopTimer=setTimeout(()=>this.stopImmediate(),e+20);}setMuted(e){if(this.muted=e,!(!this.gain||!this.ctx||this.ctx.state==="closed"))try{e?this.gain.disconnect():this.gain.connect(this.ctx.destination);}catch{}}destroy(){this.generation++,this.stopImmediate();}stopImmediate(){this.stopTimer&&(clearTimeout(this.stopTimer),this.stopTimer=null);for(let e of this.sources){try{e.stop();}catch{}try{e.disconnect();}catch{}}this.sources=[];try{this.gain?.disconnect();}catch{}this.gain=null,this.ctx=null;}};var Ea=class{constructor(){this.ctx=null;this.released=false;}acquire(){if(this.released)return null;if(this.ctx&&this.ctx.state!=="closed")return this.ctx;try{this.ctx=new AudioContext;}catch(e){E.warn("AudioOut","AudioContext unavailable",{err:String(e)}),this.ctx=null;}return this.ctx}peek(){return this.ctx&&this.ctx.state!=="closed"?this.ctx:null}warm(){let e=this.acquire();if(e)try{e.state==="suspended"&&e.resume().catch(()=>{});let t=e.createBufferSource();t.buffer=e.createBuffer(1,1,e.sampleRate),t.connect(e.destination),t.start();}catch{}}ensureRunning(){let e=this.acquire();return e?wa(e):Promise.resolve(false)}release(){this.released=true;let e=this.ctx;this.ctx=null,!(!e||e.state==="closed")&&e.close().catch(()=>{});}};async function eA(n){if(typeof Worker>"u")return Promise.reject(new Error("Web Workers unavailable"));let e=gr().vadWorker??URL.createObjectURL(new Blob([(await Promise.resolve().then(()=>(nf(),tf))).VAD_WORKER_SOURCE],{type:"application/javascript"})),t=new Worker(e),r=null;return new Promise((o,s)=>{t.onmessage=u=>{let p=u.data;p.type==="prob"?r?.(p.prob,p.tMs,p.speech??null):p.type==="ready"?o({pushPcm(h){t.postMessage({type:"pcm",buffer:h.buffer},[h.buffer]);},onProb(h){r=h;},reset(){t.postMessage({type:"reset"});},destroy(){t.terminate(),URL.revokeObjectURL(e);}}):p.type==="error"&&(t.terminate(),URL.revokeObjectURL(e),s(new Error(p.message)));},t.onerror=u=>{t.terminate(),URL.revokeObjectURL(e),s(new Error(u.message||"VAD worker failed"));},t.postMessage({type:"init",weights:n.slice().buffer});})}var rf={create:eA};var tA=6,nA=1500,Ma=class{constructor(e){this.stream=null;this.video=null;this.canvas=null;this.timer=null;this.buffer=[];this.startedAt=0;this.capturing=false;this.listeners=new Set;this.stateListeners=new Set;this.frameWaiters=new Set;this.blockedTicks=0;this.permissionStatus=null;this.everGranted=false;this.sessionOpen=false;this.userDisabled=false;this.stopped=false;this.pendingOpen=null;this.capabilities=null;this.handleTrackEnded=()=>{this.isActive&&(E.warn("Perception","camera track ended unexpectedly"),this.teardownCapture(),this.emitStateChange({feed:"off"}),this.emitChange());};this.handlePermissionChange=()=>{this.permissionStatus?.state==="denied"&&(E.warn("Perception","camera permission revoked mid-session"),this.everGranted=false,this.teardownCapture(),this.emitStateChange({access:"denied",feed:"off"}),this.emitChange());};this.fps=e?.fps??3,this.bufferMs=e?.bufferMs??12e3,this.maxEdge=e?.maxEdge??512,this.jpegQuality=e?.jpegQuality??.7,this.historyThresholdMs=e?.historyThresholdMs??3e3,this.facing=e?.facing??"user",this.maxFrames=Math.max(1,e?.maxFrames??3);}get isActive(){return this.stream!==null}get isSessionOpen(){return this.sessionOpen}get isVideoOff(){return this.userDisabled}get feed(){return this.isActive?"live":"off"}getStream(){return this.stream}getVideoElement(){return this.video}getFacing(){return this.facing}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}onStateChange(e){return this.stateListeners.add(e),()=>this.stateListeners.delete(e)}hasHistory(){return this.isActive&&Date.now()-this.startedAt>=this.historyThresholdMs}waitForFrames(e){if(this.freshFrames().length>0)return Promise.resolve(this.snapshot());if(!this.isActive)return Promise.resolve([]);this.buffer.length>0&&E.warn("Perception","newest frame is stale \u2014 waiting for a fresh one",{ageMs:Date.now()-this.buffer[this.buffer.length-1].t});let t=Date.now();return new Promise(r=>{let o=()=>{clearTimeout(s),this.frameWaiters.delete(o);let u=this.snapshot();E.info("Perception","waited for frames",{count:u.length,waitedMs:Date.now()-t}),r(u);},s=setTimeout(o,e);this.frameWaiters.add(o);})}async willPrompt(){if(this.isActive||typeof navigator>"u"||!navigator.mediaDevices?.getUserMedia)return false;try{let e=await navigator.permissions?.query({name:"camera"});if(e)return e.state==="prompt"}catch{}return !this.everGranted}async ensureCamera(){if(this.isActive)return "granted";if(this.stopped||typeof navigator>"u"||!navigator.mediaDevices?.getUserMedia)return "unavailable";let e;try{e=await this.openCamera();}catch(t){let r=t?.name;return E.warn("Perception","camera getUserMedia failed",{name:r}),r==="NotAllowedError"||r==="SecurityError"?"denied":"unavailable"}return e?(this.sessionOpen=true,this.userDisabled=false,this.emitChange(),this.emitStateChange({facing:this.facingLabel()}),this.reportCapabilities(),"granted"):"unavailable"}async setVideoEnabled(e){if(e){if(this.stopped||(this.userDisabled=false,this.isActive))return;let t;try{t=await this.openCamera();}catch(r){let o=r?.name;E.warn("Perception","failed to re-enable video",{name:o});let s=o==="NotAllowedError"||o==="SecurityError";s&&(this.everGranted=false),this.emitStateChange(s?{access:"denied",feed:"off"}:{feed:"off"}),this.emitChange();return}if(!t)return;this.sessionOpen=true,this.emitStateChange({feed:"live",facing:this.facingLabel()}),this.emitChange(),this.reportCapabilities();return}this.userDisabled=true,this.teardownCapture(),this.emitStateChange({feed:"off"}),this.emitChange();}snapshot(){return this.freshFrames().slice(-this.maxFrames).map(e=>e.bytes)}freshFrames(){let e=Date.now()-nA;return this.buffer.filter(t=>t.t>=e)}openCamera(){return this.stream?Promise.resolve(true):(this.pendingOpen??(this.pendingOpen=this.openStream(this.facing).then(e=>(this.everGranted=true,this.stopped||this.userDisabled?(e.getTracks().forEach(t=>t.stop()),E.info("Perception","released a camera opened after teardown"),false):(this.stream=e,this.attachTrackWatchers(),this.watchPermission(),this.startCaptureLoop(),true))).finally(()=>{this.pendingOpen=null;})),this.pendingOpen)}stop(){let e=this.sessionOpen||this.isActive;this.stopped=true,this.teardownCapture(),this.permissionStatus&&(this.permissionStatus.removeEventListener("change",this.handlePermissionChange),this.permissionStatus=null),this.sessionOpen=false,this.userDisabled=false,e&&this.emitChange();}async flip(e="toggle"){if(!this.isActive)return "unavailable";let t=e==="front"?"user":e==="back"||this.facing==="user"?"environment":"user";if(t===this.facing)return "unchanged";let r;try{r=await this.openStream(t);}catch(o){let s=o?.name;return E.warn("Perception","camera flip failed \u2014 keeping current camera",{name:s,next:t}),s==="OverconstrainedError"||s==="NotFoundError"?"unavailable":"failed"}return this.stopped||this.userDisabled||!this.stream?(r.getTracks().forEach(o=>o.stop()),"unavailable"):(this.detachTrackWatchers(),this.stream?.getTracks().forEach(o=>o.stop()),this.stream=r,this.facing=t,this.attachTrackWatchers(),this.video&&(this.video.srcObject=r),this.emitStateChange({facing:this.facingLabel()}),this.emitChange(),"switched")}facingLabel(){return this.facing==="environment"?"back":"front"}teardownCapture(){if(this.detachTrackWatchers(),this.timer&&(clearInterval(this.timer),this.timer=null),this.video){try{this.video.pause();}catch{}this.video.srcObject=null,this.video.remove(),this.video=null;}this.stream&&(this.stream.getTracks().forEach(e=>e.stop()),this.stream=null),this.buffer=[],this.canvas=null,this.capturing=false,this.startedAt=0,this.blockedTicks=0,[...this.frameWaiters].forEach(e=>e());}openStream(e){return navigator.mediaDevices.getUserMedia({video:{facingMode:e},audio:false})}async reportCapabilities(){try{this.capabilities||(this.capabilities=await this.detectCapabilities()),this.emitStateChange({canFlip:this.capabilities.canFlip,availableCameras:this.capabilities.availableCameras});}catch{}}async detectCapabilities(){let e=this.stream?.getVideoTracks()[0]?.getCapabilities?.().facingMode??[],t=e.includes("user")&&e.includes("environment"),r=0;try{r=(await navigator.mediaDevices.enumerateDevices()).filter(h=>h.kind==="videoinput").length;}catch{}let o=navigator.mediaDevices.getSupportedConstraints?.().facingMode??false,s=t||o&&r>=2,u=s?["front","back"]:[this.facing==="environment"?"back":"front"];return {canFlip:s,availableCameras:u}}emitChange(){this.listeners.forEach(e=>{try{e();}catch{}});}emitStateChange(e){this.stateListeners.forEach(t=>{try{t(e);}catch{}});}async watchPermission(){if(!this.permissionStatus)try{let e=await navigator.permissions?.query({name:"camera"});if(!e)return;this.permissionStatus=e,e.addEventListener("change",this.handlePermissionChange);}catch{}}attachTrackWatchers(){this.stream?.getVideoTracks().forEach(e=>e.addEventListener("ended",this.handleTrackEnded));}detachTrackWatchers(){this.stream?.getVideoTracks().forEach(e=>e.removeEventListener("ended",this.handleTrackEnded));}startCaptureLoop(){let e=document.createElement("video");e.playsInline=true,e.muted=true,e.autoplay=true,e.srcObject=this.stream,e.style.cssText="position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;pointer-events:none;",e.setAttribute("aria-hidden","true"),document.body.appendChild(e),this.video=e,this.canvas=document.createElement("canvas"),this.startedAt=Date.now(),e.play().catch(r=>E.error("Perception","capture video failed to play",{name:r?.name,message:r?.message}));let t=Math.max(1,Math.round(1e3/this.fps));this.timer=setInterval(()=>{this.captureFrame();},t);}async captureFrame(){if(this.capturing||!this.video||!this.canvas)return;let e=this.video.videoWidth,t=this.video.videoHeight;if(!e||!t){this.blockedTicks+=1,this.blockedTicks===tA&&E.error("Perception","capture video is not producing frames",{afterMs:Date.now()-this.startedAt,paused:this.video.paused,readyState:this.video.readyState,inDocument:this.video.isConnected});return}this.capturing=true;try{let r=Math.min(1,this.maxEdge/Math.max(e,t)),o=Math.max(1,Math.round(e*r)),s=Math.max(1,Math.round(t*r));this.canvas.width=o,this.canvas.height=s;let u=this.canvas.getContext("2d");if(!u)return;u.drawImage(this.video,0,0,o,s);let p=await this.canvasToJpegBytes(this.canvas);if(p){let h=Date.now(),A=this.buffer.length===0;this.buffer.push({t:h,bytes:p}),this.pruneBuffer(h),A&&E.info("Perception","first frame captured",{afterMs:h-this.startedAt,blockedTicks:this.blockedTicks}),this.frameWaiters.size>0&&[...this.frameWaiters].forEach(y=>y());}}catch(r){E.warn("Perception","frame capture failed",{err:r});}finally{this.capturing=false;}}canvasToJpegBytes(e){return new Promise(t=>{e.toBlob(r=>{if(!r)return t(null);r.arrayBuffer().then(o=>t(new Uint8Array(o))).catch(()=>t(null));},"image/jpeg",this.jpegQuality);})}pruneBuffer(e){let t=e-this.bufferMs,r=0;for(;r<this.buffer.length&&this.buffer[r].t<t;)r++;r>0&&this.buffer.splice(0,r);}};var zr={bundle:{sha256:"98db72469ffb176f5e9f2687be0f70783893aca681f7789c34b872b0a764371a",byteLength:155465,ext:"js"},loader:{sha256:"e170ee67dd4e16c1a6fcd8840a206687e5a59b22c20e4a902bc445b095454d73",byteLength:323377,ext:"js"},wasm:{sha256:"8da277a733926eacd0474b8704b36742d6ec3231c57a860c5b889dff8f1df886",byteLength:11756954,ext:"wasm"},model:{sha256:"64184e229b263107bc2b804c6625db1341ff2bb731874b0bcc2fe6544e0bc9ff",byteLength:3758596,ext:"task"}};var iA="CPU",oA=3e4;async function sf(n){if(typeof Worker>"u")throw new Error("Web Workers unavailable");let e=gr().moodAssets?.replace(/\/+$/,""),t=A=>e?`${e}/${A.sha256}.${A.ext}`:Hs(A.sha256,A.ext),r=n?.getCachedAsset?{read:A=>n.getCachedAsset?.(A),write:(A,y)=>n.setCachedAsset?.(A,y)}:void 0,o=A=>bi(A,t(A),r),s=[],u=(A,y)=>{let b=URL.createObjectURL(new Blob([A],{type:y}));return s.push(b),b},p=async A=>e?t(A):u(await o(A),"text/javascript"),h=null;try{let[A,y,b,m,S]=await Promise.all([gr().moodWorker??Promise.resolve().then(()=>(af(),of)).then(({MOOD_WORKER_SOURCE:L})=>u(L,"text/javascript")),p(zr.bundle),p(zr.loader),o(zr.wasm).then(L=>u(L,"application/wasm")),o(zr.model)]);h=new Worker(A);let C={type:"init",bundleUrl:y,loaderUrl:b,wasmUrl:m,model:S,delegate:iA};h.postMessage(C);let I=await aA(h);return n?.pruneCachedAssets?.(Object.values(zr).map(L=>L.sha256)).catch(()=>{}),sA(h,I)}catch(A){throw h?.terminate(),A}finally{for(let A of s)URL.revokeObjectURL(A);}}function aA(n){return new Promise((e,t)=>{let r=setTimeout(()=>t(new Error("mood worker did not start in time")),oA);n.onerror=o=>{clearTimeout(r),t(new Error(o.message||"mood worker failed to load"));},n.onmessage=o=>{let s=o.data;s.type==="ready"?(clearTimeout(r),e(s.delegate)):s.type==="error"&&(clearTimeout(r),t(new Error(s.message)));};})}function sA(n,e){let t=null,r=o=>{let s=t;t=null,s&&("error"in o?s.reject(o.error):s.resolve(o.blendshapes));};return n.onerror=o=>r({error:new Error(o.message||"mood worker crashed")}),n.onmessage=o=>{let s=o.data;s.type==="result"?r({blendshapes:s.blendshapes}):s.type==="error"&&r({error:new Error(s.message)});},{delegate:e,detect:(o,s)=>t?(o.close(),Promise.reject(new Error("detect already pending"))):new Promise((u,p)=>{t={resolve:u,reject:p};let h={type:"frame",frame:o,timestampMs:s};n.postMessage(h,[o]);}),terminate:()=>{r({error:new Error("mood worker terminated")}),n.terminate();}}}var lf=5,cf=480,lA="afx:mood-debug",cA=()=>{try{return globalThis.localStorage?.getItem(lA)==="1"}catch{return false}},uA=n=>{if(typeof VideoFrame=="function")try{return Promise.resolve(new VideoFrame(n))}catch{}return createImageBitmap(n,{resizeWidth:cf,resizeHeight:Math.round(cf*n.videoHeight/n.videoWidth),resizeQuality:"low"})},Ta=class{constructor(e){this.options=e;this.classifier=new Wi;this.worker=null;this.timer=null;this.generation=0;this.detecting=false;this.failed=false;this.timestampMs=0;this.debug=false;this.ticks=0;}start(){if(this.timer||this.failed)return;this.worker??(this.worker=sf(this.options.cache));let e=this.generation;this.worker.then(t=>{e!==this.generation||this.timer||(this.debug=cA(),E.info("Mood","face model ready",{delegate:t.delegate,debug:this.debug}),this.timer=setInterval(()=>{this.tick(t);},1e3/lf));},t=>{e===this.generation&&this.fail("face model failed to load",t);});}stop(){this.generation+=1,this.timer&&(clearInterval(this.timer),this.timer=null),this.classifier.reset();}dispose(){this.stop(),this.worker?.then(e=>e.terminate(),()=>{}),this.worker=null;}async tick(e){if(this.detecting)return;let t=this.options.getVideo();if(!t||t.readyState<HTMLMediaElement.HAVE_CURRENT_DATA||!t.videoWidth)return;let r=this.generation;this.detecting=true;try{let o=await uA(t);this.timestampMs=Math.max(performance.now(),this.timestampMs+1);let s=await e.detect(o,this.timestampMs);if(r!==this.generation)return;let u=this.classifier.update(s,Date.now(),this.options.isUserSpeaking());u&&this.options.onReading(u),this.debug&&++this.ticks%lf===0&&this.logFrame(u);}catch(o){r===this.generation&&this.fail("face detection failed",o);}finally{this.detecting=false;}}logFrame(e){let t=this.classifier.inspect();if(!t)return;let r=o=>Object.entries(o).map(([s,u])=>`${s}=${u}`).join(" ");E.info("Mood",`frame label=${t.label} reading=${e?.state??"none"} | scores ${r(t.scores)} | browDrop=${t.browDrop} | raw ${r(t.raw)} | base ${r(t.baseline)}`);}fail(e,t){this.failed=true,this.dispose(),E.warn("Mood",`${e}; mood reading is off for this session`,{cause:t});}};var dA=1280,fA=.75,pA=1e3,uf=5,df=300,hA=6e4,mA=2500,gA=3,vA=new Set(["InvalidAccessError","InvalidStateError","NotAllowedError"]),AA={tab:"browser",window:"window",screen:"monitor"},bA=()=>{if(typeof navigator>"u")return "other";let n=navigator.userAgentData?.brands??[];if(n.some(t=>/Edge/i.test(t.brand)))return "edge";if(n.some(t=>/Chrom/i.test(t.brand)))return "chrome";let e=navigator.userAgent;return /Edg\//.test(e)?"edge":/Firefox\//.test(e)?"firefox":/Chrome\//.test(e)?"chrome":/Safari\//.test(e)?"safari":"other"},yA=n=>n==="browser"?"tab":n==="window"?"window":n==="monitor"?"screen":void 0,_A=()=>{if(typeof navigator>"u"||typeof document>"u")return "no browser";if(navigator.userAgentData?.mobile===true||/Android|iPhone|iPad|iPod/i.test(navigator.userAgent))return "mobile browsers cannot share a screen";if(typeof navigator.mediaDevices?.getDisplayMedia!="function")return "this browser cannot share a screen";let e=document.permissionsPolicy??document.featurePolicy;return typeof e?.allowsFeature=="function"&&!e.allowsFeature("display-capture")?"the embedding page does not allow display-capture":null},ka=class{constructor(e){this.browser=bA();this.phase="idle";this.surface=null;this.requestedSurface=null;this.turnId=null;this.clickTimer=null;this.listeners=new Set;this.disposed=false;this.stream=null;this.imageCapture=null;this.grabFailures=0;this.video=null;this.thumbCanvas=null;this.frameCanvas=null;this.sampleTimer=null;this.sampling=false;this.lastTickAt=0;this.throttleLogged=false;this.lastSentThumb=null;this.lastSentAt=0;this.handleTrackEnded=()=>{this.phase==="live"&&(E.info("Perception","screen share ended by the user"),this.releaseCapture(),this.setPhase("idle"),this.handlers.onState({feed:"off"}));};this.handlers=e;}get currentPhase(){return this.phase}get currentSurface(){return this.surface}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}request(e,t){if(this.disposed){this.handlers.onStatus("unavailable",t,{reason:"session ended"});return}let r=_A();if(r){this.handlers.onStatus("unavailable",t,{reason:r});return}if(this.turnId=t,this.phase==="live"){this.report("granted",{surface:this.surface??void 0}),this.turnId=null;return}if(this.phase==="awaiting_click"){this.report("awaiting_click");return}this.phase!=="picking"&&(this.requestedSurface=e,this.pick(false));}shareFromClick(){this.phase!=="awaiting_click"||this.disposed||(this.clearClickTimer(),this.pick(true));}dismiss(){this.phase==="awaiting_click"&&(this.clearClickTimer(),this.finish("declined","dismissed"));}stop(){if(this.phase==="live"){this.releaseCapture(),this.setPhase("idle"),this.handlers.onState({feed:"off"});return}(this.phase==="awaiting_click"||this.phase==="picking")&&(this.clearClickTimer(),this.finish("declined","withdrawn"));}dispose(){this.disposed=true,this.clearClickTimer(),this.releaseCapture(),this.turnId=null,this.setPhase("idle"),this.listeners.clear();}async pick(e){this.setPhase("picking");let t=navigator.userActivation?.isActive??e,r=Date.now(),o=setTimeout(()=>{this.phase==="picking"&&!this.disposed&&this.report("picking");},df),s;try{s=await navigator.mediaDevices.getDisplayMedia(this.pickerOptions());}catch(u){if(clearTimeout(o),this.disposed||this.phase!=="picking")return;let p=u?.name??"Error",h=Date.now()-r<df;if(E.info("Perception","screen picker refused",{name:p,fromClick:e,hadActivation:t,afterMs:Date.now()-r}),!e&&!t&&h&&vA.has(p)){this.awaitClick();return}if(p==="NotAllowedError"){this.finish("declined",h?"blocked by the browser":"cancelled");return}this.finish("unavailable",p);return}if(clearTimeout(o),this.disposed||this.phase!=="picking"){s.getTracks().forEach(u=>u.stop()),E.info("Perception","released a screen shared after the request ended");return}this.adopt(s);}pickerOptions(){return {video:{frameRate:{ideal:uf,max:uf},...this.requestedSurface&&{displaySurface:AA[this.requestedSurface]}},audio:false,selfBrowserSurface:"exclude",surfaceSwitching:"include"}}awaitClick(){this.setPhase("awaiting_click"),this.report("awaiting_click"),this.clickTimer=setTimeout(()=>{this.clickTimer=null,this.phase==="awaiting_click"&&this.finish("declined","no click");},hA);}adopt(e){let t=e.getVideoTracks()[0];if(!t){e.getTracks().forEach(r=>r.stop()),this.finish("unavailable","no video track");return}this.stream=e,this.surface=yA(t.getSettings?.().displaySurface)??this.requestedSurface,t.addEventListener("ended",this.handleTrackEnded),this.setPhase("live"),this.report("granted",{surface:this.surface??void 0}),this.turnId=null,this.startSampler(t);}report(e,t){this.turnId!==null&&this.handlers.onStatus(e,this.turnId,{browser:this.browser,...t});}finish(e,t){this.report(e,{reason:t}),this.turnId=null,this.setPhase("idle");}clearClickTimer(){this.clickTimer&&clearTimeout(this.clickTimer),this.clickTimer=null;}setPhase(e){this.phase!==e&&(this.phase=e,this.listeners.forEach(t=>{try{t();}catch{}}));}startSampler(e){let t=globalThis.ImageCapture;typeof t=="function"?this.imageCapture=new t(e):this.attachVideo(),this.thumbCanvas=document.createElement("canvas"),this.thumbCanvas.width=32,this.thumbCanvas.height=32,this.frameCanvas=document.createElement("canvas"),this.lastTickAt=Date.now(),this.sampleTimer=setInterval(()=>{this.sample();},pA);}attachVideo(){if(this.video||!this.stream)return;let e=document.createElement("video");e.playsInline=true,e.muted=true,e.autoplay=true,e.srcObject=this.stream,e.style.cssText="position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;pointer-events:none;",e.setAttribute("aria-hidden","true"),document.body.appendChild(e),e.play().catch(()=>{}),this.video=e;}async sample(){if(this.sampling||!this.stream)return;let e=Date.now(),t=e-this.lastTickAt;this.lastTickAt=e,t>mA&&!this.throttleLogged&&(this.throttleLogged=true,E.warn("Perception","screen sampling throttled",{gapMs:t,hidden:document.hidden})),this.sampling=true;let r=null;try{if(r=await this.grabSource(),!r||!this.thumbCanvas||!this.stream)return;let o=this.thumbCanvas.getContext("2d",{willReadFrequently:!0});if(!o)return;o.drawImage(r.image,0,0,32,32);let s=Rl(o.getImageData(0,0,32,32).data);if(!Pl(this.lastSentThumb,s,e-this.lastSentAt))return;let u=await this.encode(r);if(!u||!this.stream)return;this.lastSentThumb=s,this.lastSentAt=e,this.handlers.onFrame(u);}catch(o){E.warn("Perception","screen frame failed",{name:o?.name});}finally{r?.release(),this.sampling=false;}}async grabSource(){if(this.imageCapture)try{let t=await this.imageCapture.grabFrame();return this.grabFailures=0,{image:t,width:t.width,height:t.height,release:()=>t.close()}}catch(t){return this.grabFailures+=1,this.grabFailures>=gA&&(E.warn("Perception","grabFrame keeps failing \u2014 using a video element",{name:t?.name}),this.imageCapture=null,this.attachVideo()),null}let e=this.video;return !e||!e.videoWidth||!e.videoHeight?null:{image:e,width:e.videoWidth,height:e.videoHeight,release:()=>{}}}encode(e){let t=this.frameCanvas;if(!t)return Promise.resolve(null);let r=Math.min(1,dA/Math.max(e.width,e.height)),o=Math.max(1,Math.round(e.width*r)),s=Math.max(1,Math.round(e.height*r));return t.width=o,t.height=s,t.getContext("2d")?.drawImage(e.image,0,0,o,s),new Promise(u=>{t.toBlob(p=>{if(!p)return u(null);p.arrayBuffer().then(h=>u({bytes:new Uint8Array(h),width:o,height:s})).catch(()=>u(null));},"image/jpeg",fA);})}releaseCapture(){this.stream?.getVideoTracks().forEach(e=>e.removeEventListener("ended",this.handleTrackEnded)),this.sampleTimer&&clearInterval(this.sampleTimer),this.sampleTimer=null,this.video&&(this.video.srcObject=null,this.video.remove(),this.video=null),this.stream?.getTracks().forEach(e=>e.stop()),this.stream=null,this.imageCapture=null,this.grabFailures=0,this.thumbCanvas=null,this.frameCanvas=null,this.lastSentThumb=null,this.lastSentAt=0,this.throttleLogged=false,this.surface=null;}};var wA="avatarfactory-riv-cache",Pn="riv-files",Xn="avatar-configs",Kr="greetings",qr="vad-weights",xa="cache-keys",Qn="content-assets";var ff="riv-wrap-key";var Yr=null;function Qt(){return Yr||(Yr=new Promise((e,t)=>{let r=indexedDB.open(wA,6);r.onupgradeneeded=o=>{let s=r.result;s.objectStoreNames.contains(Pn)?o.oldVersion<5&&r.transaction?.objectStore(Pn).clear():s.createObjectStore(Pn),s.objectStoreNames.contains(Xn)||s.createObjectStore(Xn),s.objectStoreNames.contains(Kr)||s.createObjectStore(Kr),s.objectStoreNames.contains(qr)||s.createObjectStore(qr),s.objectStoreNames.contains(xa)||s.createObjectStore(xa),s.objectStoreNames.contains(Qn)||s.createObjectStore(Qn);},r.onblocked=()=>t(new Error("indexedDB upgrade to v6 blocked")),r.onsuccess=()=>{let o=r.result;o.onversionchange=()=>{o.close(),Yr=null;},e(o);},r.onerror=()=>t(r.error);}).catch(e=>{throw Yr=null,e}),Yr)}var Ca=null;function pf(n){return Ca||(Ca=SA(n).catch(()=>null).then(e=>(e||(Ca=null),e))),Ca}async function SA(n){let e=globalThis.crypto?.subtle;if(!e)return null;let t=await e.generateKey({name:"AES-GCM",length:256},false,["encrypt","decrypt"]);return new Promise(r=>{let o=n.transaction(xa,"readwrite"),s=o.objectStore(xa),u=s.get(ff),p=t;u.onsuccess=()=>{let h=u.result;h?p=h:s.put(t,ff);},o.oncomplete=()=>r(p),o.onerror=()=>r(null);})}async function hf(n){try{let e=await Qt(),t=await pf(e);if(!t)return null;let r=await new Promise(s=>{let p=e.transaction(Pn,"readonly").objectStore(Pn).get(n);p.onsuccess=()=>{let h=p.result;s(h?.cipher?h:null);},p.onerror=()=>s(null);});return r?{bytes:await globalThis.crypto.subtle.decrypt({name:"AES-GCM",iv:r.iv},t,r.cipher),rivVersion:r.rivVersion}:null}catch{return null}}async function mf(n,e,t){try{let r=await Qt(),o=await pf(r);if(!o)return;let s=globalThis.crypto.getRandomValues(new Uint8Array(12)),u=await globalThis.crypto.subtle.encrypt({name:"AES-GCM",iv:s},o,e);return new Promise(p=>{let h={cipher:u,iv:s,rivVersion:t},A=r.transaction(Pn,"readwrite");A.objectStore(Pn).put(h,n),A.oncomplete=()=>p(),A.onerror=()=>p();})}catch{}}async function EA(n){try{let e=await Qt();return new Promise(t=>{let r=e.transaction([Pn,Xn],"readwrite");r.objectStore(Pn).delete(n),r.objectStore(Xn).delete(n),r.oncomplete=()=>t(),r.onerror=()=>t();})}catch{}}async function gf(n){try{let e=await Qt();return new Promise(t=>{let o=e.transaction(Xn,"readonly").objectStore(Xn).get(n);o.onsuccess=()=>{let s=o.result;if(!s){t(null);return}let u=s;if(!u.cachedAt||Date.now()-u.cachedAt>6048e5){EA(n),t(null);return}t(u.config);},o.onerror=()=>t(null);})}catch{return null}}async function vf(n,e){try{let t=await Qt();return new Promise(r=>{let o={config:e,cachedAt:Date.now()},s=t.transaction(Xn,"readwrite");s.objectStore(Xn).put(o,n),s.oncomplete=()=>r(),s.onerror=()=>r();})}catch{}}async function Af(n){try{let e=await Qt();return new Promise(t=>{let o=e.transaction(Kr,"readonly").objectStore(Kr).get(n);o.onsuccess=()=>{let s=o.result;if(!s?.cachedAt||Date.now()-s.cachedAt>2592e6){t(null);return}t(s);},o.onerror=()=>t(null);})}catch{return null}}async function bf(n,e){try{let t=await Qt();return new Promise(r=>{let o=t.transaction(Kr,"readwrite"),s=o.objectStore(Kr);s.put(e,n);let u=n.slice(0,n.indexOf(":"));if(u){let p=IDBKeyRange.bound(`${u}:`,`${u}:\uFFFF`),h=s.openKeyCursor(p);h.onsuccess=()=>{let A=h.result;A&&(A.key!==n&&s.delete(A.key),A.continue());};}o.oncomplete=()=>r(),o.onerror=()=>r();})}catch{}}async function yf(n){try{let e=await Qt();return new Promise(t=>{let o=e.transaction(qr,"readonly").objectStore(qr).get(n);o.onsuccess=()=>{let s=o.result;t(s instanceof Uint8Array?s:null);},o.onerror=()=>t(null);})}catch{return null}}async function _f(n,e){try{let t=await Qt();return new Promise(r=>{let o=t.transaction(qr,"readwrite"),s=o.objectStore(qr);s.put(e,n);let u=s.openKeyCursor();u.onsuccess=()=>{let p=u.result;p&&(p.key!==n&&s.delete(p.key),p.continue());},o.oncomplete=()=>r(),o.onerror=()=>r();})}catch{}}async function wf(n){try{let e=await Qt();return new Promise(t=>{let o=e.transaction(Qn,"readonly").objectStore(Qn).get(n);o.onsuccess=()=>{let s=o.result;t(s instanceof Uint8Array?s:null);},o.onerror=()=>t(null);})}catch{return null}}async function Sf(n,e){try{let t=await Qt();return new Promise(r=>{let o=t.transaction(Qn,"readwrite");o.objectStore(Qn).put(e,n),o.oncomplete=()=>r(),o.onerror=()=>r();})}catch{}}async function Ef(n){try{let e=await Qt(),t=new Set(n);return new Promise(r=>{let o=e.transaction(Qn,"readwrite"),s=o.objectStore(Qn),u=s.openKeyCursor();u.onsuccess=()=>{let p=u.result;p&&(t.has(String(p.key))||s.delete(p.key),p.continue());},o.oncomplete=()=>r(),o.onerror=()=>r();})}catch{}}var Nl={getCachedRiv:hf,setCachedRiv:mf,getCachedAvatarConfig:gf,setCachedAvatarConfig:vf,getCachedGreeting:Af,setCachedGreeting:bf,getCachedVadWeights:yf,setCachedVadWeights:_f,getCachedAsset:wf,setCachedAsset:Sf,pruneCachedAssets:Ef};var Mf={async bytesToSrc(n){let e=new Blob([n],{type:"application/octet-stream"});return URL.createObjectURL(e)},revokeSrc(n){URL.revokeObjectURL(n);}};var MA=/^(cc-|new-password|current-password|one-time-code)/,TA=/\b(?:card (?:number|no|num)|cc (?:number|num|no)|cvv|cvc|csc|security code|iban|ssn|social security|otp)\b/,kA=n=>n.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_\-.:]+/g," ").toLowerCase(),Ra=(n,e="")=>{if(n.getAttribute("type")==="password"||MA.test(n.getAttribute("autocomplete")||""))return true;let t=["name","id","aria-label","placeholder"].map(r=>n.getAttribute(r)||"").concat(e).join(" ");return TA.test(kA(t))},Qi=n=>(n instanceof HTMLButtonElement||n instanceof HTMLInputElement)&&(n.type==="submit"||n.type==="image")&&n.form!==null;var CA=/\bsponsored\b/i,xA="nav, aside, [role=navigation], [role=banner], [role=contentinfo], [role=complementary]",Dl=n=>{if(n.closest(xA))return true;let e=n.closest("header, footer");return !!e&&!e.parentElement?.closest("article, section, main, [role=main]")},RA=n=>{let e=n.getAttribute("role"),t=Array.from(n.classList).sort().slice(0,3).join(".");return `${n.tagName}${e?`[${e}]`:""}${t?`.${t}`:""}`},PA=n=>[n,n.parentElement,n.parentElement?.parentElement].map(e=>e?RA(e):"").join("<"),IA=n=>{let e=0;for(let t=n.parentElement;t;t=t.parentElement)e+=1;return e},Tf=(n,e)=>n.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1,LA=n=>{let e=n.ownerDocument.defaultView;if(!e)return false;let t=n.getBoundingClientRect(),r=t.left+t.width/2,o=t.top+t.height/2;return r>=0&&o>=0&&r<=e.innerWidth&&o<=e.innerHeight},Pa=(n,e)=>{if(n.length<=e)return n;let t=n.slice(0,e),r=t.lastIndexOf(" ");return `${r>0?t.slice(0,r):t}\u2026`},OA=n=>{let e=new Map,t=new Map;for(let o of n){let s=o.el;for(let u=0;s&&u<=8&&s!==s.ownerDocument.body;u+=1){let p=PA(s),h=e.get(p);h||e.set(p,h=new Set),h.add(s);let A=t.get(s);A||t.set(s,A=[]),A.push(o),s=s.parentElement;}}let r=[];for(let o of e.values()){if(o.size<3)continue;let s=Array.from(o).sort(Tf);s.some((u,p)=>p>0&&s[p-1].contains(u))||r.push({cards:s,depth:s.reduce((u,p)=>u+IA(p),0)/s.length});}return {groups:r,controlsIn:t}},NA=n=>{let e=new Set;for(let t of n){let r=new Set(t.cards);for(let o of n){let s=o.depth-t.depth;if(o===t||s<=0||s>8)continue;let u=new Map;for(let h of o.cards){let A=h.parentElement;for(let y=0;A&&y<8;y+=1,A=A.parentElement)if(r.has(A)){u.set(A,(u.get(A)??0)+1);break}}if(u.size<3)continue;Array.from(u.values()).reduce((h,A)=>h+A,0)/u.size>=1.5?e.add(t):e.add(o);}}return n.filter(t=>!e.has(t))};function kf(n,e){let t=new Map,r=m=>{let S=t.get(m);return S===void 0&&t.set(m,S=e.textOf(m)),S},{groups:o,controlsIn:s}=OA(n),u=m=>{if(Dl(m)||CA.test(r(m)))return false;let S=s.get(m)??[];return S.length!==1?S.length>1:r(m).length>S[0].name.length+3},p=m=>{let S=(L,B)=>r(B.el).length-r(L.el).length,C=m.filter(({el:L})=>L.matches("a[href], [role=link]"));return [...C.filter(({el:L})=>e.pathOf(L))].sort(S)[0]??[...C].sort(S)[0]??m[0]},h=(m,S)=>{let C=m[0].parentElement;for(let I=0;C&&I<3;I+=1,C=C.parentElement){let L=C.getAttribute("aria-label")?.trim();if(L)return Pa(L,60);let B=C.previousElementSibling;for(let W=0;B&&W<3;W+=1){let Q=B.matches("h1, h2, h3, [role=heading]")?B:B.querySelector("h1, h2, h3, [role=heading]"),Z=Q?r(Q):"";if(Z)return Pa(Z,60);B=B.previousElementSibling;}}return `List ${S}`},A=NA(o.map(m=>({...m,cards:m.cards.filter(u)})).filter(m=>m.cards.length>=3)).sort((m,S)=>Tf(m.cards[0],S.cards[0])),y={lists:[],primary:new Map,secondary:new Set},b=new Set;for(let m of A){if(y.lists.length>=6)break;let S=y.lists.length+1,C=[],I=[],L=0;for(let B of m.cards){let W=(s.get(B)??[]).filter(({el:oe})=>!b.has(oe)),Q=p(W);if(!Q)continue;let Z=r(Q.el),$=Pa(r(B).replace(Z," ").replace(/\s+/g," ").trim(),90);C.push([Q.el,{list:S,position:C.length+1,...LA(B)&&{screenPosition:++L},...$&&{detail:$},name:Pa(Z,60)||Q.name}]);for(let{el:oe}of W)oe!==Q.el&&I.push(oe);}if(!(C.length<3)){y.lists.push({id:S,name:h(m.cards,S),total:C.length});for(let[B,W]of C)y.primary.set(B,W),b.add(B);for(let B of I)y.secondary.add(B),b.add(B);}}return y}var Fl=/^skip (?:to\b|navigation\b|nav\b|main\b|links\b)/i,DA=25,FA=60,BA=40,Hl={maxControls:FA,reservedLinks:0,groupLists:false,maxItems:0,preferVisible:false};var Nf=60,UA=120,VA=200,Cf=2,Df="main, section, article, aside, nav, header, footer, [role=region], [role=tabpanel], [role=main], [role=navigation], [role=banner], [role=contentinfo]",Ff="h1, h2, h3, [role=heading]",Bf="button, summary, [role=button], [role=tab], [role=menuitem], [role=menuitemradio], [role=menuitemcheckbox], [role=option], input[type=submit], input[type=button], input[type=reset]",WA=new Set(["option","menuitemradio","menuitemcheckbox"]),Uf="a[href], [role=link]",Vl="input:not([type=hidden]):not([type=submit]):not([type=button]):not([type=reset]), select, textarea, [contenteditable=''], [contenteditable=true], [role=textbox], [role=combobox]",HA="form, [role=form]",xf={section:"s",button:"b",link:"l",field:"f",form:"frm"},Et=(n,e)=>(n.getAttribute(e)||"").trim(),Vf=/\s*[.(]?\s*opens? in (?:a )?new (?:tab|window)\)?\.?/gi,Nt=(n,e=Nf)=>n.replace(Vf,"").replace(/\s+/g," ").trim().slice(0,e),Wf=(n,e)=>{let t=Nt(n,1/0);if(t.length<=e)return t;let r=t.slice(0,e),o=r.lastIndexOf(" ");return o>0?r.slice(0,o):r},GA=n=>!!n.body&&n.body.getBoundingClientRect().width>0,Gl=(n,e)=>{let t=n;if(typeof t.checkVisibility=="function"&&!t.checkVisibility({contentVisibilityAuto:true,visibilityProperty:true}))return false;if(!e)return true;let r=n.getBoundingClientRect();return r.width>=Cf&&r.height>=Cf},jA=(n,e)=>{let t=e.defaultView;if(!t)return false;let r=n.getBoundingClientRect(),o=r.left+r.width/2,s=r.top+r.height/2;if(o<0||s<0||o>t.innerWidth||s>t.innerHeight)return false;let u=e.elementFromPoint(o,s);return !!u&&u!==n&&!n.contains(u)&&!u.contains(n)},zA=(n,e)=>{let t=e.defaultView;if(!t)return true;let r=n.getBoundingClientRect();return r.bottom>0&&r.right>0&&r.top<t.innerHeight&&r.left<t.innerWidth},YA=(n,e)=>{if(n.closest("[inert]"))return true;let t=e.defaultView;return t?t.getComputedStyle(n).pointerEvents==="none":false},Oa=n=>{let e=Et(n,"aria-label");if(e)return Nt(e);let t=Et(n,"aria-labelledby");if(!t)return "";let r=t.split(/\s+/).map(o=>{let s=n.ownerDocument.getElementById(o);return s?$n(s):""}).join(" ");return Nt(r)},KA=new Set(["A","ABBR","B","BDI","BDO","CITE","CODE","DATA","DFN","EM","I","KBD","MARK","Q","RUBY","S","SAMP","SMALL","SPAN","STRONG","SUB","SUP","TIME","U","VAR"]),Hf="script, style, [aria-hidden=true], [hidden]",$n=(n,e,t=true)=>{if(n.nodeType===Node.TEXT_NODE)return n.nodeValue||"";if(n.nodeType!==Node.ELEMENT_NODE)return "";let r=n;if(!t&&e&&r.matches(e))return "";let o="";for(let s of Array.from(r.childNodes))o+=$n(s,e,false);return KA.has(r.tagName)?o:` ${o} `},Gf=(n,e)=>{let t=[],r=n.ownerDocument.createTreeWalker(n,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,{acceptNode:o=>o!==n&&o.nodeType===Node.ELEMENT_NODE&&o.matches(e)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT});for(let o=r.nextNode();o;o=r.nextNode())o.nodeType===Node.TEXT_NODE&&t.push(o.nodeValue??"");return t},qA=n=>{let e=Nt($n(n,Hf));return e.length>VA?"":e},XA=n=>{let e=n.querySelector("img[alt], [role=img][aria-label]");return e?Nt(Et(e,"alt")||Et(e,"aria-label")):""},QA=n=>{let e=n.labels?.[0];if(e)return Nt($n(e));if(n.id){let r=n.ownerDocument.querySelector(`label[for="${CSS.escape(n.id)}"]`);if(r)return Nt($n(r))}let t=n.closest("label");return t?Nt($n(t)):""},$A=n=>n.length>=3&&/[a-z]/i.test(n)&&/[aeiou]/i.test(n)&&!/\d{3}/.test(n),Xr=n=>{if(!n)return "";let e=Nt(n.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_\-.:]+/g," ").toLowerCase());return $A(e)?e:""},JA=n=>{let e=Et(n,"autocomplete");if(e&&e!=="off"&&e!=="on")return Xr(e);let t=Et(n,"type");return t&&t!=="text"?`${t} field`:""},ZA=(n,e)=>{for(let t=e.parentElement;t&&t!==n;t=t.parentElement)if(t.matches(Df))return false;return true},jf=n=>{for(let e of Array.from(n.querySelectorAll(Ff)))if(ZA(n,e))return Nt($n(e));return ""},eb=4,zf=30,$i=n=>{for(let[e,t]of n){let r=t();if(r)return {name:r,namedBy:e}}return {name:"",namedBy:"none"}},tb={nav:"navigation",header:"header",footer:"footer",main:"main content",aside:"sidebar"},nb=n=>$i([["aria",()=>Oa(n)],["heading",()=>jf(n)],["id",()=>Xr(n.id)],["landmark",()=>tb[n.tagName.toLowerCase()]??""]]),Rf=n=>$i([["aria",()=>Oa(n)],["text",()=>qA(n)],["img-alt",()=>XA(n)],["title",()=>Et(n,"title")],["id",()=>Xr(Et(n,"name")||n.id)]]),rb=n=>$i([["aria",()=>Oa(n)],["label",()=>QA(n)],["placeholder",()=>Et(n,"placeholder")],["title",()=>Et(n,"title")],["id",()=>Xr(Et(n,"name")||n.id)],["type",()=>JA(n)]]),Yf=n=>Et(n,"role")==="combobox"&&!(n instanceof HTMLInputElement||n instanceof HTMLSelectElement||n instanceof HTMLTextAreaElement),ib=n=>n.hasAttribute("data-placeholder")?"":Nt(Gf(n,"[aria-hidden=true]").join("")),ob=(n,e)=>{if(!WA.has(Et(n,"role")))return null;let t=n.closest("[role=listbox], [role=menu]");if(!t?.id)return null;let r=CSS.escape(t.id);return e.querySelector(`[aria-controls~="${r}"], [aria-owns~="${r}"]`)},ab=n=>{let e=Et(n,"type");if(e==="checkbox"||e==="radio")return e;if(Yf(n))return "combobox";let t=Et(n,"autocomplete");if(t&&t!=="off"&&t!=="on")return t;if(e)return e;let r=n.tagName.toLowerCase();return r==="select"||r==="textarea"||r==="input"?r:Et(n,"role")==="combobox"?"combobox":"text"},sb=n=>n instanceof HTMLInputElement&&(n.type==="checkbox"||n.type==="radio"),Bl=12,lb=n=>{let e=Array.from(n.options).filter(r=>!r.disabled&&r.value!=="").map(r=>Nt(r.label||r.text,Nf)).filter(Boolean);if(e.length<=Bl)return e;let t=e.length-Bl;return [...e.slice(0,Bl),`+${t} more`]},Pf=n=>n.disabled===true||Et(n,"aria-disabled")==="true",cb=n=>{if(sb(n))return {checked:n.checked};if(!Yf(n))return {filled:ub(n)};let e=ib(n);return e?{shows:e}:{filled:false}},ub=n=>{let e=n.value;return typeof e=="string"?e.trim().length>0:Nt(n.textContent||"").length>0},If=(n,e)=>{let t=Et(n,"href");if(!(!t||t.startsWith("#")))try{let r=new URL(t,e.baseURI);return r.origin===e.location.origin?r.pathname+r.search:void 0}catch{return}},Ul=60,db=n=>{if(n.length<=Ul)return n;let e=n.split("?")[0];return e.length<=Ul?e:`${e.slice(0,Ul)}\u2026`},fb=n=>{for(let e of ["q","url","u"]){let t=n.searchParams.get(e);if(!(!t||!/^https?:\/\//i.test(t)))try{let r=new URL(t);if(r.origin!==n.origin)return r}catch{}}},pb=n=>n.querySelector("cite")?.textContent?.trim().match(/^(?:https?:\/\/)?(?:www\.)?([a-z0-9-]+(?:\.[a-z0-9-]+)+)/i)?.[1]?.toLowerCase(),hb=(n,e)=>{let t=Et(n,"href");if(!(!t||t.startsWith("#")))try{let r=new URL(t,e.baseURI);return /^https?:$/.test(r.protocol)?(r.origin===e.location.origin?fb(r):r)?.hostname.replace(/^www\./,"")??pb(n):void 0}catch{return}},Lf=n=>n.split("?")[0].replace(/\/+$/,"")||"/",mb=/\s+[—–|·:]\s+/,gb=(n,e)=>$i([["route",()=>Ab(Xr(vb(n.location.pathname)))],["self-link",()=>Nt(e)],["title",()=>Nt(n.title.split(mb)[0]||"")]]),vb=n=>n.split("/").filter(Boolean).pop()||"",Ab=n=>n?n[0].toUpperCase()+n.slice(1):"",bb=(n,e)=>{let t=n;for(let r=0;r<e&&t;r+=1)t=t.parentElement;return t?Wf($n(t,`${Bf}, ${Uf}, ${Vl}`),zf):""},Ia=(n,e=[])=>{let t=new Map;for(let o of n){let s=t.get(o.name);s?s.push(o):t.set(o.name,[o]);}let r=[];for(let o of t.values()){if(o.length===1){r.push(o[0]);continue}let s=Et(o[0].el,"href");if(s&&o.every(h=>Et(h.el,"href")===s)){r.push({...o[0],count:o.length});continue}let u=o.map(h=>Wf(Kf(h.el,e),zf));if(u.every(Boolean)&&new Set(u).size===o.length){o.forEach((h,A)=>{h.name=`${h.name} \u2014 in "${u[A]}"`;}),r.push(...o);continue}let p=false;for(let h=1;h<=eb&&!p;h+=1){let A=o.map(y=>bb(y.el,h));A.some(y=>!y)||new Set(A).size===o.length&&(o.forEach((y,b)=>{y.name=`${y.name} \u2014 ${A[b]}`;}),p=true);}p?r.push(...o):r.push({...o[0],count:o.length});}return r.sort(Wl)},La=(n,e,t,r,o=false)=>{let s=[],u=[],p=0;for(let h of Array.from(n.querySelectorAll(e))){if(!Gl(h,t)||o&&t&&YA(h,n))continue;let A=o&&t&&jA(h,n),y=r(h);if(A){y.name&&u.push(y.name);continue}if(!y.name){p+=1;continue}s.push({el:h,name:y.name,namedBy:y.namedBy});}return {named:s,unnamed:p,covered:u}},yb=n=>n.length>=2&&/[a-z]/i.test(n),_b=(n,e,t)=>{let r=[];for(let o of Array.from(n.querySelectorAll(Ff))){if(!Gl(o,e)||t.some(u=>u.contains(o)))continue;let s=Nt(o.textContent||"");yb(s)&&r.push({el:o,name:s,namedBy:"heading-block"});}return r},Wl=(n,e)=>n.el.compareDocumentPosition(e.el)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1,wb=n=>{let e=[];for(let t of n)e.some(o=>o.name===t.name&&(o.el.contains(t.el)||t.el.contains(o.el)))||e.push(t);return e},Kf=(n,e)=>{let t="",r="";for(let o of e)o.el.contains(n)?t=o.name:o.el.compareDocumentPosition(n)&Node.DOCUMENT_POSITION_FOLLOWING&&(r=o.name);return t||r},Sb=n=>Gf(n,Hf).join(" ").replace(Vf,"").replace(/\s+/g," ").trim(),Eb=(n,e)=>{let t=Array.from(n.primary).sort(([,r],[,o])=>(r.screenPosition?0:1)-(o.screenPosition?0:1)||r.list-o.list||r.position-o.position);return new Map(t.slice(0,e))},Of=({list:n,position:e,screenPosition:t,detail:r})=>({list:n,position:e,...t&&{screenPosition:t},...r&&{detail:r}});function qf(n=document,e=1,t=Hl){let r=GA(n),o=new Map,s=[],u={},p={section:0,button:0,link:0,field:0,form:0},h=new Map,A=(P,N)=>{p[N]+=1;let U=`${xf[N]}${p[N]}`;return o.set(U,P),h.set(P,U),U},y=La(n,Df,r,nb);u.section=y.unnamed;let b=wb([...y.named,..._b(n,r,y.named.map(P=>P.el))].sort(Wl)),m=Ia(b).slice(0,DA),S=m.filter(P=>P.namedBy!=="landmark");for(let{el:P,name:N,namedBy:U}of S)s.push({handle:A(P,"section"),kind:"section",name:N,namedBy:U});let C=La(n,Bf,r,Rf,true);C.named=C.named.filter(P=>!P.el.matches(Vl));let I=La(n,Uf,r,Rf,true);C.named=C.named.filter(({name:P})=>!Fl.test(P)),I.named=I.named.filter(({name:P})=>!Fl.test(P));let L=La(n,Vl,r,rb,true);u.button=C.unnamed,u.link=I.unnamed,u.field=L.unnamed;let B=t.groupLists&&r?kf([...C.named,...I.named],{textOf:Sb,pathOf:P=>If(P,n)}):null,W=B?Eb(B,t.maxItems):null;if(B&&W){let P=N=>B.primary.has(N.el)&&!W.has(N.el);C.named=C.named.filter(N=>!P(N)),I.named=I.named.filter(N=>!P(N));for(let N of [...C.named,...I.named]){let U=W.get(N.el);U&&(N.name=U.name);}}let Q=Ia(L.named,m),Z=Ia(C.named,m),$=Ia(I.named,m),oe=Math.min(t.reservedLinks,$.length),J={left:t.maxControls-oe},H=P=>{let N=zA(P.el,n)?0:3;return B?.secondary.has(P.el)?N?7:6:W?.has(P.el)?N:N+(Dl(P.el)?2:1)},de=P=>{let N=Math.max(0,J.left),U=P.slice(0,N);if(t.preferVisible&&r&&P.length>N){let q=P.map(se=>({candidate:se,rank:H(se)}));q.sort((se,Re)=>se.rank-Re.rank),U=q.slice(0,N).map(({candidate:se})=>se).sort(Wl);}return J.left-=U.length,U};for(let{el:P,name:N,namedBy:U,count:q}of de(Q))s.push({handle:A(P,"field"),kind:"field",name:N,namedBy:U,fieldType:ab(P),...cb(P),...P instanceof HTMLSelectElement&&{options:lb(P)},...q&&{count:q},...Pf(P)&&{disabled:true},...Ra(P,N)&&{sensitive:true}});for(let{el:P,name:N,namedBy:U,count:q}of de(Z)){let se=ob(P,n),Re=se?h.get(se):void 0,Pe=W?.get(P);s.push({handle:A(P,"button"),kind:"button",name:N,namedBy:U,...Pe&&{item:Of(Pe)},...Re&&{choiceOf:Re},...q&&{count:q},...Qi(P)&&{submits:true},...Pf(P)&&{disabled:true}});}let te=Lf(n.location.pathname),xe="";J.left+=oe;for(let{el:P,name:N,namedBy:U,count:q}of de($)){let se=If(P,n),Re=hb(P,n),Pe=se?.includes("?")?se.slice(se.indexOf("?")):"",we=!!se&&Lf(se)===te&&(!Pe||Pe===n.location.search);we&&!xe&&(xe=N);let ve=W?.get(P);s.push({handle:A(P,"link"),kind:"link",name:N,namedBy:U,...ve&&{item:Of(ve)},...q&&{count:q},...se&&!ve&&!Re&&{path:db(se)},...Re&&{site:Re},...we&&{current:true}});}let Se=new Map(s.map(P=>[o.get(P.handle),P.handle]));for(let P of Array.from(n.querySelectorAll(HA))){if(!Gl(P,r))continue;let N=[];for(let[se,Re]of Se)P.contains(se)&&!Re.startsWith(xf.section)&&N.push(Re);if(N.length===0)continue;let{name:U,namedBy:q}=$i([["aria",()=>Oa(P)],["heading",()=>jf(P)],["section",()=>Kf(P,m)],["id",()=>Xr(Et(P,"name")||P.id)]]);s.push({handle:A(P,"form"),kind:"form",name:U||"form",namedBy:q,children:N});}let{name:ue,namedBy:Ie}=gb(n,xe),ae=new Set(s.map(P=>P.item?.list)),G=B?.lists.filter(P=>ae.has(P.id))??[],z=[...new Set([...C.covered,...I.covered,...L.covered].filter(P=>!Fl.test(P)))].slice(0,BA);return {index:{generation:e,url:n.location.pathname+n.location.search,title:Nt(n.title,UA),pageName:ue||"this",pageNamedBy:Ie,nodes:s,unnamed:u,...G.length>0&&{lists:G},...r&&{covered:z}},elements:o}}var Zf=/^(?:true|yes|y|on|1|check|checked|tick|ticked|select|selected)$/i,Mb=/^(?:false|no|n|off|0|uncheck|unchecked|untick|unticked|deselect)$/i,Tb={date:"dates go in as YYYY-MM-DD",time:"times go in as HH:MM, 24-hour","datetime-local":"a date and time goes in as YYYY-MM-DDTHH:MM",month:"a month goes in as YYYY-MM",week:"a week goes in as YYYY-Www",number:"only a plain number fits",range:"only a plain number fits",color:"a colour goes in as #rrggbb"},Xf=n=>n.toLowerCase().replace(/[^\p{L}\p{N}]+/gu," ").trim(),Qf=(n,e)=>{let t=n.filter(e);return t.length===1?t[0]:void 0},ep=(n,e,t)=>{let r=Xf(t);if(!r)return;let o=s=>e(s).map(Xf);return n.find(s=>o(s).includes(r))??Qf(n,s=>o(s).some(u=>u.startsWith(r)))??Qf(n,s=>o(s).some(u=>u.includes(r)))},kb=(n,e)=>{let t=Object.getPrototypeOf(n),r=Object.getOwnPropertyDescriptor(t,"value")?.set;r?r.call(n,e):n.value=e;},tp=(n,e)=>{n.focus({preventScroll:true}),kb(n,e),n.dispatchEvent(new Event("input",{bubbles:true})),n.dispatchEvent(new Event("change",{bubbles:true})),n.blur();},$f=(n,e)=>n.readOnly?{outcome:"read_only"}:(tp(n,e),e&&n.value===""?{outcome:"rejected",detail:Tb[n.type]}:e&&!n.validity.valid?{outcome:"invalid",detail:n.validationMessage}:{outcome:"ok"}),Cb=(n,e)=>{let t=Array.from(n.options).filter(o=>!o.disabled),r=ep(t,o=>[o.value,o.label||o.text],e);return r?(tp(n,r.value),{outcome:"ok"}):{outcome:"no_such_option",detail:t.filter(o=>o.value!=="").map(o=>o.label||o.text).join(", ")}},Jf=n=>n.labels?.[0]?.textContent?.trim()||n.getAttribute("aria-label")||n.value,xb=(n,e)=>{let t=n.form??n.ownerDocument,r=n.name?Array.from(t.querySelectorAll(`input[type=radio][name="${CSS.escape(n.name)}"]`)):[n],o=ep(r,s=>[s.value,Jf(s)],e)??(Zf.test(e.trim())?n:void 0);return o?o.disabled?{outcome:"disabled"}:(o.checked||o.click(),o.checked?{outcome:"ok"}:{outcome:"rejected"}):{outcome:"no_such_option",detail:r.map(Jf).join(", ")}},Rb=(n,e)=>{let t=Zf.test(e.trim())?true:Mb.test(e.trim())?false:void 0;return t===void 0?{outcome:"rejected",detail:'a tick box takes "yes" or "no"'}:(n.checked!==t&&n.click(),n.checked===t?{outcome:"ok"}:{outcome:"rejected"})},Pb=(n,e)=>(n.focus({preventScroll:true}),window.getSelection()?.selectAllChildren(n),(e?document.execCommand("insertText",false,e):document.execCommand("delete"))||(n.textContent=e,n.dispatchEvent(new InputEvent("input",{bubbles:true,inputType:"insertText",data:e}))),n.blur(),{outcome:"ok"}),np=(n,e)=>n instanceof HTMLSelectElement?Cb(n,e):n instanceof HTMLTextAreaElement?$f(n,e):n instanceof HTMLInputElement?n.type==="radio"?xb(n,e):n.type==="checkbox"?Rb(n,e):n.type==="file"?{outcome:"not_fillable"}:$f(n,e):n instanceof HTMLElement&&n.isContentEditable?Pb(n,e):{outcome:"not_fillable"},Ib=n=>"willValidate"in n&&n.willValidate,Lb=(n,e)=>{let t=Array.from(n.elements).find(o=>Ib(o)&&!o.validity.valid);if(!t)return;let r=t.validationMessage||"still needs a valid value";return `"${e(t)}": ${r}`},rp=(n,e,t=false)=>{let r=n.form;if(r&&!r.noValidate&&!n.formNoValidate){let p=Lb(r,e);if(p)return {outcome:"invalid",detail:p}}let o=false,s=false,u=p=>{o=true,s=p.defaultPrevented,t||p.preventDefault();};window.addEventListener("submit",u);try{n.click();}finally{window.removeEventListener("submit",u);}return !o||s||t?{outcome:"ok"}:{outcome:"requires_reload"}};var Ob=new Set(["date","time","datetime-local","month","week","color"]),Nb=n=>{let e=n.getBoundingClientRect();return {clientX:e.left+e.width/2,clientY:e.top+e.height/2}},Ji=(n,e,t,r)=>{let o={bubbles:true,cancelable:true,composed:true,view:window,button:0,buttons:r?1:0,...t};return e.startsWith("pointer")?typeof PointerEvent!="function"?true:n.dispatchEvent(new PointerEvent(e,{...o,pointerId:1,pointerType:"mouse",isPrimary:true})):n.dispatchEvent(new MouseEvent(e,o))},jl=n=>{let e=Nb(n),t=Ji(n,"pointerdown",e,true),r=Ji(n,"mousedown",e,true);t&&r&&n instanceof HTMLElement&&n.focus({preventScroll:true}),Ji(n,"pointerup",e,false),Ji(n,"mouseup",e,false),n instanceof HTMLElement?n.click():Ji(n,"click",e,false);},Db=n=>{if(n instanceof HTMLSelectElement||n instanceof HTMLInputElement&&Ob.has(n.type))try{n.showPicker?.();}catch{}},ip=n=>{jl(n),Db(n);};var Qr=0,vr=0,Na=null,Fb=()=>{let n=Na;if(Na=null,n==="forward"){Qr+=1,vr=Math.max(0,vr-1);return}n==="back"?vr+=1:vr=0,Qr=Math.max(0,Qr-1);},zl={canGo:n=>n==="back"?Qr>0:vr>0,go(n){Na=n,n==="back"?window.history.back():window.history.forward();}};function op(n){if(typeof window>"u")return ()=>{};let e=null,t=()=>{e&&clearTimeout(e),e=setTimeout(n,500);};Qr=0,vr=0,Na=null;let{pushState:r,replaceState:o}=window.history,s=(A,y)=>function(...b){let m=A.apply(this,b);return y&&(Qr+=1,vr=0),t(),m},u=()=>{Fb(),t();},p=s(r,true),h=s(o,false);return window.history.pushState=p,window.history.replaceState=h,window.addEventListener("popstate",u),window.addEventListener("hashchange",t),()=>{e&&clearTimeout(e),window.history.pushState===p&&(window.history.pushState=r),window.history.replaceState===h&&(window.history.replaceState=o),window.removeEventListener("popstate",u),window.removeEventListener("hashchange",t);}}var Bb=.8,Ub="l",Xl="b",Yl="f",cp="s",Vb=new Set([cp,Xl]),$r=n=>/^([a-z]{1,4})\d{1,4}$/.exec(n)?.[1]??"",Wb=/\s+—\s+.*$/,Kl=n=>n.toLowerCase().replace(/\s+/g," ").trim(),Hb=n=>{try{return new URL(n,window.location.href).origin===window.location.origin}catch{return false}},ap=n=>n.replace(/\/+$/,"")||"/",Gb=n=>{try{return ap(new URL(n,window.location.href).pathname)===ap(window.location.pathname)}catch{return false}},sp=(n,e,t)=>{let r=false,o=u=>{r=u.defaultPrevented,e||u.preventDefault();};window.addEventListener("click",o);try{n.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window}));}finally{window.removeEventListener("click",o);}if(r||e)return "ok";let s=n.href;return t===void 0||!s?"requires_reload":(setTimeout(()=>window.location.assign(s),t),"ok")},ql=n=>n.matches(":disabled")||n.getAttribute("aria-disabled")==="true",jb=new Set(["back","forward"]),up=n=>zl.canGo(n)?(zl.go(n),"ok"):"no_history",zb=n=>{let e=window.navigation;return e?(n==="back"?!e.canGoBack:!e.canGoForward)?"no_history":(n==="back"?e.back():e.forward(),"ok"):up(n)},Yb=()=>{let n=document.documentElement;return {x:Math.max(0,n.scrollWidth-window.innerWidth),y:Math.max(0,n.scrollHeight-window.innerHeight)}},lp=(n,e,t,r)=>{if(!n)return e;if(n.relative){let o=n.percent?r*n.value/100:n.value;return e+o}return n.percent?t*n.value/100:n.value},Kb=n=>{let e=Yb();if(n.kind==="edge"){let t=n.edge==="top"?0:n.edge==="bottom"?e.y:e.y/2;window.scrollTo({top:t,behavior:"smooth"});return}if(n.kind==="step"){let t=window.innerHeight*Bb;window.scrollBy({top:n.direction==="up"?-t:t,behavior:"smooth"});return}window.scrollTo({left:lp(n.x,window.scrollX,e.x,window.innerWidth),top:lp(n.y,window.scrollY,e.y,window.innerHeight),behavior:"smooth"});};function qb(n={}){let e=n.survivesDocumentLoad??false,t=n.indexProfile??Hl,r=n.followLinksAnywhere??false,o=n.documentLoadAfterMs,s=null,u=(y,b)=>!s||s.generation!==b?null:s.elements.get(y)??null,p=y=>{let b=s?.elements.get(y);return b?.isConnected?{element:b,isSection:$r(y)===cp}:null},h=y=>s?.generation===y?"unknown_target":"stale",A=y=>{for(let[b,m]of s?.elements??[])if(m===y)return s?.names.get(b)??b;return y.labels?.[0]?.textContent?.trim()||y.getAttribute("aria-label")||y.getAttribute("placeholder")||y.getAttribute("name")||"a field"};return {elementNamed(y){let b=Kl(y);if(!s||!b)return null;let m=null;for(let[S,C]of s.names)if(Vb.has($r(S))){if(Kl(C)===b)return p(S);!m&&Kl(C.replace(Wb,""))===b&&(m=S);}return m?p(m):null},read(y){let{index:b,elements:m}=qf(document,y,t),S=new Map(b.nodes.map(C=>[C.handle,C.name]));return s={generation:y,elements:m,names:S},b},retag(y){s&&(s.generation=y);},scroll(y,b){let m=Il(y);if(m)return Kb(m),"ok";if(b===void 0)return "unknown_target";let S=u(y,b);return S?S.isConnected?(S.scrollIntoView({behavior:"smooth",block:"start"}),"ok"):"stale":h(b)},navigate(y,b){if(jb.has(y)){let I=y;return e?zb(I):up(I)}if(b===void 0)return "unknown_target";if($r(y)!==Ub)return "not_navigable";let m=u(y,b);if(!m)return h(b);if(!m.isConnected)return "stale";let S=m.getAttribute("href");if(!S)return "not_navigable";let C=Hb(S);return !C&&!r?"not_navigable":C&&Gb(S)?"already_here":sp(m,e,o)},click(y,b){if(b===void 0)return "unknown_target";let m=$r(y);if(m!==Xl&&m!==Yl)return "not_clickable";let S=u(y,b);return S?S.isConnected?Qi(S)?"submits_form":ql(S)?"disabled":(S.scrollIntoView({behavior:"smooth",block:"center"}),m===Yl?(ip(S),"ok"):S.closest("a[href]")?sp(S,e,o)==="ok"?"ok":"requires_reload":(jl(S),"ok")):"stale":h(b)},fill(y,b){let m=false;return y.map(({handle:S,value:C})=>{let I=s?.names.get(S)??S,L=(Z,$)=>({handle:S,name:I,outcome:Z,...$&&{detail:$}});if(b===void 0)return L("unknown_target");if($r(S)!==Yl)return L("not_fillable");let B=u(S,b);if(!B)return L(h(b));if(!B.isConnected)return L("stale");if(Ra(B,I))return L("sensitive");if(ql(B))return L("disabled");m||(B.scrollIntoView({behavior:"smooth",block:"center"}),m=true);let{outcome:W,detail:Q}=np(B,C);return L(W,Q)})},submit(y,b){if(b===void 0)return {outcome:"unknown_target"};if($r(y)!==Xl)return {outcome:"not_a_submit"};let m=u(y,b);return m?m.isConnected?Qi(m)?ql(m)?{outcome:"disabled"}:(m.scrollIntoView({behavior:"smooth",block:"center"}),rp(m,A,e)):{outcome:"not_a_submit"}:{outcome:"stale"}:{outcome:h(b)}}}}var Da=qb();var $l=vi(eo());var Mt=vi(eo()),mn=(n,e)=>{let t=[...e?[e]:[],...n.stateMachineNames??[]];for(let r of t){let o;try{o=n.stateMachineInputs(r);}catch{o=void 0;}if(o?.length)return {name:r,inputs:o}}return {name:null,inputs:[]}},Fa=(n,e)=>{let t;switch(n?.fit){case "fill":t=Mt.Fit.Fill;break;case "cover":t=Mt.Fit.Cover;break;case "fitWidth":t=Mt.Fit.FitWidth;break;case "fitHeight":t=Mt.Fit.FitHeight;break;case "none":t=Mt.Fit.None;break;case "scaleDown":t=Mt.Fit.ScaleDown;break;case "layout":t=Mt.Fit.Layout;break;default:t=Mt.Fit.Contain;}e&&(t=Mt.Fit.Contain);let r;switch(n?.alignment){case "topLeft":r=Mt.Alignment.TopLeft;break;case "topCenter":r=Mt.Alignment.TopCenter;break;case "topRight":r=Mt.Alignment.TopRight;break;case "centerLeft":r=Mt.Alignment.CenterLeft;break;case "centerRight":r=Mt.Alignment.CenterRight;break;case "bottomLeft":r=Mt.Alignment.BottomLeft;break;case "bottomCenter":r=Mt.Alignment.BottomCenter;break;case "bottomRight":r=Mt.Alignment.BottomRight;break;default:r=Mt.Alignment.Center;}return new Mt.Layout({fit:t,alignment:r})};var Xb=100,Qb=.001,$b=21,fp=n=>{let e=hr(n);return e!==null&&e<=$b},Jb=n=>n.type===$l.StateMachineInputType.Trigger?"trigger":n.type===$l.StateMachineInputType.Boolean?"boolean":"number",Zb=(n,e)=>{let{name:t,inputs:r}=mn(n,e),o=r.map(s=>{let u=Jb(s);return {path:s.name,kind:u,source:"input",isViseme:u==="number"&&fp(s.name),read:()=>u==="trigger"?null:s.value}});return {stateMachine:t,probes:o}},e0=(n,e,t,r)=>{let o={path:r,source:"property",isViseme:false};switch(t){case "number":{let s=n.number(e);return s&&{...o,kind:"number",isViseme:fp(e),read:()=>s.value}}case "boolean":{let s=n.boolean(e);return s&&{...o,kind:"boolean",read:()=>s.value}}case "string":{let s=n.string(e);return s&&{...o,kind:"string",read:()=>s.value}}case "color":{let s=n.color(e);return s&&{...o,kind:"color",read:()=>s.value}}case "enumType":{let s=n.enum(e);return s&&{...o,kind:"enum",read:()=>s.value}}case "trigger":{let s=n.trigger(e);return s&&{...o,kind:"trigger",read:()=>null,property:s}}default:return null}},pp=(n,e="")=>n.properties.flatMap(({name:t,type:r})=>{let o=e?`${e}/${t}`:t;if(r==="viewModel"){let u=n.viewModel(t);return u?pp(u,o):[]}let s=e0(n,t,r,o);return s?[s]:[]}),t0=(n,e)=>typeof n=="number"&&typeof e=="number"?Math.abs(n-e)>Qb:n!==e,dp=({read:n,property:e,...t},r)=>({...t,value:r}),Jl=class{constructor(e,t){this.target=e;this.emit=t;this.last=new Map;this.unreadable=new Set;this.triggerHandlers=new Map;this.timer=null;this.sample=()=>{for(let e of this.probes){if(e.kind==="trigger")continue;let t=this.read(e);if(t===void 0)continue;let r=this.last.get(e)??null;t0(t,r)&&(this.last.set(e,t),this.emit({type:"change",value:dp(e,t),previous:r}));}};let r=Zb(e.rive,e.stateMachine),o=e.rive.viewModelInstance;this.stateMachine=r.stateMachine,this.probes=[...r.probes,...o?pp(o):[]];}snapshot(){let e=this.probes.flatMap(t=>{let r=this.read(t);return r===void 0?[]:[dp(t,r)]});return {type:"snapshot",binding:this.target.binding,stateMachine:this.stateMachine,values:e}}start(){if(!this.timer){for(let e of this.probes){let t=this.read(e);t!==void 0&&this.last.set(e,t);}this.listenForTriggers(),this.timer=setInterval(this.sample,Xb);}}stop(){this.timer&&clearInterval(this.timer),this.timer=null;for(let[e,t]of this.triggerHandlers)e.property?.off(t);this.triggerHandlers.clear();}listenForTriggers(){for(let e of this.probes){if(!e.property)continue;let t=()=>this.emit({type:"trigger",path:e.path,source:"property"});e.property.on(t),this.triggerHandlers.set(e,t);}}read(e){if(!this.unreadable.has(e))try{return e.read()}catch(t){this.unreadable.add(e),E.warn("RigActivity",`can't read "${e.path}", skipping it`,{error:String(t)});return}}},Ba=class{constructor(){this.listeners=new Set;this.watcher=null;this.subscribe=e=>(this.listeners.add(e),this.watcher&&(this.watcher.start(),e(this.watcher.snapshot())),()=>{this.listeners.delete(e),this.listeners.size===0&&this.watcher?.stop();});this.emit=e=>{for(let t of this.listeners)try{t(e);}catch(r){E.warn("RigActivity","a listener threw",{error:String(r)});}};}attach(e){this.detach();try{this.watcher=new Jl(e,this.emit);}catch(t){E.warn("RigActivity","could not read the rig",{error:String(t)});return}this.listeners.size!==0&&(this.watcher.start(),this.emit(this.watcher.snapshot()));}detach(){this.watcher&&(this.watcher.stop(),this.watcher=null,this.emit({type:"detached"}));}reportTrigger(e){this.listeners.size&&this.emit({type:"trigger",path:e,source:"input"});}reportGesture(e,t){this.listeners.size&&this.emit({type:"gesture",name:e,target:t});}reportWrite(e,t,r){this.listeners.size&&this.emit({type:"write",path:e,value:t,landed:r});}};var hp=7e3,n0=()=>{if(typeof window>"u")return false;try{return window.self!==window.top}catch{return true}},r0=(n,e,t,r)=>{let o=useMemo(()=>Si(n),[n]),s=o.environment==="meeting",u=useRef(null),p=useRef(e),[h,A]=useState("idle"),[y,b]=useState("none"),[m,S]=useState("idle"),[C,I]=useState(null),[L,B]=useState(false),[W,Q]=useState(null),[Z,$]=useState(false),[oe,J]=useState(null),[H,de]=useState(false),te=useRef(null),xe=useRef(null),Se=useRef(null),ue=useRef(null),Ie=useRef(null),ae=useRef(null),G=useRef(null),z=useRef(null);z.current||(z.current=new Ea);let[P,N]=useState(null),[U,q]=useState("user"),[se,Re]=useState(false),[Pe,we]=useState("idle"),[ve,De]=useState(0),[Xe,qe]=useState(0),[ee,fe]=useState(false),[Fe,ye]=useState(false),[pe,Ue]=useState(false),[We,Ve]=useState(false),[rt,st]=useState(false),[et,tt]=useState(false),[He,le]=useState(false),[g,l]=useState(0),[f,w]=useState(0),T=useRef(0),R=useRef(0),V=useRef(null),re=useRef([]),[ke,ie]=useState(0),_e=useRef(0),nt=useMemo(()=>new Ba,[]),Qe=useRef(null);Qe.current||(Qe.current=Hi([]));let Ge=Qe.current,gt=useRef(null);gt.current||(gt.current=Hi(null));let Tt=gt.current,Ye=useRef(null),[kt,vt]=useState(null),At=useRef(null);At.current||(At.current=Hi({services:{ingest:"ok",stt:"ok",llm:"ok",tts:"ok",downlink:"ok"},concern:null}));let Me=At.current,[dn,Gt]=useState("normal");u.current||(u.current=new Fi(o,{cache:Nl,urlResolver:Mf,pageSurface:p.current?.surface??(t||s?void 0:Da),pageBeforeLive:p.current?.pageBeforeLive,browser:p.current?.browser,framed:n0(),embedHostOrigin:t,embedResume:r,readsMood:true,reportsMicPipeline:true}));let x=u.current,Zt=x.isPushToTalk();!ae.current&&(o.mode??"call")==="call"&&!Zt&&o.turnTaking?.clientBargeIn!==false&&(ae.current=new Xi(x,rf,{echoGate:o.turnTaking?.echoGate}),ae.current.prefetch()),ae.current?.setSpeaking(L);let Dn=useCallback(()=>{if(!Se.current){let he=new Ma;he.subscribe(()=>{N(he.getStream()),q(he.getFacing()),Re(he.isSessionOpen);}),he.onStateChange(Ze=>x.sendCameraState(Ze)),Se.current=he;}return Se.current},[x]),jt=useCallback(()=>{ue.current?.stop(),Se.current?.stop(),Se.current=null;},[]),fn=useCallback(()=>(ue.current??(ue.current=new Ta({getVideo:()=>Se.current?.getVideoElement()??null,isUserSpeaking:()=>ae.current?.isUserVoiced()??false,onReading:he=>x.reportMood(he),cache:Nl})),ue.current),[x]),me=useCallback(()=>{if(!Ie.current){let he=new ka({onStatus:(Ze,bt,Mn)=>x.reportScreenStatus(Ze,bt,Mn),onState:Ze=>x.sendScreenState(Ze),onFrame:Ze=>x.sendScreenFrame(Ze)});he.subscribe(()=>we(he.currentPhase)),Ie.current=he;}return Ie.current},[x]),zt=useCallback(()=>{Ie.current?.dispose(),Ie.current=null,we("idle");},[]),Fn=useCallback(async()=>{let he=Se.current;he&&await he.setVideoEnabled(!he.isActive);},[]);useEffect(()=>{if(x)return V.current&&(clearTimeout(V.current),V.current=null),x.load(),()=>{V.current=setTimeout(()=>{x.dispose(),ae.current?.dispose(),z.current?.release();},0);}},[x]);let rr=o.avatar?.avatarId||"default";useEffect(()=>{x.setAvatarId(rr)&&(Q(null),vt(null),Gt("normal"),J(null),$(false));},[x,rr]),useEffect(()=>{if(!x)return;let he=x.on("session-phase",ge=>{A(ge),ge==="connecting"&&(Q(null),vt(null),Gt("normal"),De(je=>je+1));}),Ze=x.on("paint-phase",b),bt=x.on("turn-phase",ge=>{S(ge),(ge==="listening"||ge==="idle")&&fe(false);}),Mn=x.on("talking-armed",ye);A(x.getSessionPhase()),b(x.getPaintPhase()),S(x.getTurnPhase()),ye(x.getTalkingArmed());let hs=x.on("speak",ge=>{I(ge),B(true);}),ms=x.on("interrupt",()=>{te.current?.reset(),I(null),B(false),fe(false),re.current=[];}),Lr=x.on("speech-cancelled",()=>{te.current?.reset(),B(false),fe(false),re.current=[];}),_o=x.on("avatar_thinking",()=>{fe(true),w(ge=>ge+1);}),Or=x.on("avatar_slow_response",Ue),wo=x.on("mic-start",async ge=>{ae.current?.ensureInit();try{xe.current=await Qd(ge,je=>{let Lt=ae.current;if(!Lt){x.sendPcmChunk(je.buffer);return}for(let Fr of Lt.releaseUplinkFrames(je))x.sendPcmChunk(Fr.buffer);},{sampleRate:16e3,onFloat32:je=>ae.current?.pushPcm(je),onBlocked:s?()=>x.reportAudioBlocked("mic"):void 0,onSettled:()=>x.reportMicPipelineSettled()});}catch{ae.current?.disable("mic_pipeline_failed"),x.reportMicPipelineSettled();}}),ur=()=>{let ge=Date.now();ge-T.current<sl||(T.current=ge,l(je=>je+1));},gs=x.on("user-partial",ge=>{ae.current?.onPartialTranscript(ge),ge.trim()&&ur();}),vs=x.on("user-speaking",ur),It=x.on("user-voice",ur),So=x.on("mic-muted",ge=>{Ve(ge),ae.current?.setMicMuted(ge);}),nn=x.on("speaker-muted",ge=>{st(ge),G.current?.setMuted(ge);}),As=x.on("mood-detection",tt),Nr=x.on("ptt-held",le),dr=ge=>{let je=G.current??(G.current=new Sa(z.current));je.setMuted(x.getSpeakerMuted()),je.start(ge);},ui=x.on("connect-tone",(ge,je)=>{if(ge==="start"){je&&dr(je);return}G.current?.stop(o.connectTone?.fadeOutMs);}),di=x.getPendingConnectTone();di&&(E.debug("SDK","connect-tone was already ringing on listener attach"),dr(di));let fi=x.on("avatar-ready",()=>{$(true);}),bs=x.on("gesture",(ge,je,Lt)=>{_e.current++,E.debug("SDK","gesture: received",{name:ge,atMs:je,speechless:Lt,token:_e.current}),re.current.push({name:ge,token:_e.current,atMs:je,speechless:Lt}),ie(_e.current);}),ys=x.on("beep",(ge,je)=>{_e.current++,re.current.push({name:"beep",beep:true,token:_e.current,atMs:ge,speechless:je}),ie(_e.current);}),pi=x.on("vision-request",async ge=>{if(!o.perception?.camera){x.reportPerceptionOutcome("unavailable",ge);return}let je=Dn();if(je.isActive){x.reportPerceptionOutcome("granted",ge,{hasHistory:je.hasHistory(),feed:"live"});let Co=await je.waitForFrames(hp);Co.length&&x.sendVisionFrames(Co,ge);return}if(je.isVideoOff){x.reportPerceptionOutcome("granted",ge,{hasHistory:false,feed:"off"});return}await je.willPrompt()&&x.reportPerceptionOutcome("prompting",ge);let Lt=await je.ensureCamera();if(Lt!=="granted"){x.reportPerceptionOutcome(Lt,ge);return}x.reportPerceptionOutcome("granted",ge,{hasHistory:je.hasHistory(),feed:je.feed});let Fr=await je.waitForFrames(hp);Fr.length&&x.sendVisionFrames(Fr,ge);}),_s=x.on("camera-flip",async(ge,je)=>{let Lt=Se.current?await Se.current.flip(ge):"unavailable";Lt==="switched"||Lt==="unchanged"?x.reportCommandStatus("flip_camera",je,"ok"):Lt==="unavailable"?x.reportCommandStatus("flip_camera",je,"unsupported","requested camera is not available"):x.reportCommandStatus("flip_camera",je,"failed","could not switch camera");}),ws=x.on("camera-close",async ge=>{try{await Se.current?.setVideoEnabled(!1),x.reportCommandStatus("close_camera",ge,"ok");}catch{x.reportCommandStatus("close_camera",ge,"failed","could not turn camera off");}}),Eo=x.on("camera-open",async ge=>{try{await Se.current?.setVideoEnabled(!0),x.reportCommandStatus("open_camera",ge,"ok");}catch{x.reportCommandStatus("open_camera",ge,"failed","could not turn camera on");}}),Ss=x.on("screen-request",(ge,je)=>{me().request(ge,je);}),Es=x.on("screen-stop",ge=>{Ie.current?.stop(),x.reportCommandStatus("stop_screen",ge,"ok");}),Ms=x.on("transcript",Ge.set),Ts=x.on("action-flow",Tt.set),ks=x.on("notice",ge=>{vt(ge);}),Cs=x.on("health",ge=>{Me.set(ge);}),Mo=x.on("visual",ge=>{Gt(ge);}),Dr=x.on("error",Q),To=x.getAvatarConfig();To&&J(To);let ko=x.on("avatar-config",ge=>{E.debug("SDK","Received avatar config subscription update",ge),J(ge);}),xs=x.on("connection-status",ge=>{de(ge),ge||(xe.current&&(xe.current.stop(),xe.current=null),ae.current?.reset(),jt(),zt(),I(null),B(false),fe(false),le(false),De(je=>je+1));});return ()=>{he(),Ze(),bt(),Mn(),hs(),ms(),Lr(),_o(),Or(),wo(),gs(),vs(),It(),So(),nn(),As(),Nr(),ui(),fi(),bs(),ys(),pi(),_s(),ws(),Eo(),Ss(),Es(),Ms(),Ts(),ks(),Cs(),Mo(),Dr(),ko(),xs(),xe.current?.stop(),xe.current=null,ae.current?.reset(),jt(),zt(),G.current?.destroy(),G.current=null;}},[x,Dn,jt,me,zt]);let Kt=useCallback(()=>(B(false),fe(false),I(null),x.notifyPlaybackEnded(),x.getTurnPhase()==="thinking"),[x]),bn=useCallback(he=>{jt(),zt(),x.stop({intentionalClose:true,code:4001,reason:he||"Manual disconnect"});},[x,jt,zt]),Er=useCallback(()=>x.markRiveReady(),[x]),yn=useCallback(he=>{if(R.current<1){R.current++,qe(Ze=>Ze+1);return}R.current=0,x.notifyAvatarLoadError(he);},[x]),Bn=useRef(new Map),Y=useCallback((he,Ze)=>{let bt;switch(he){case "start":bt=x.on("connection-status",Mn=>{Mn&&Ze();});break;case "stop":bt=x.on("connection-status",Mn=>{Mn||Ze();});break;case "interrupt":bt=x.on("interrupt",Ze);break;case "error":bt=x.on("error",Ze);break;case "speaking":bt=x.on("speak",()=>{Ze();});break;case "ready":bt=x.on("avatar-ready",Ze);break;case "notice":bt=x.on("notice",Ze);break;case "health":bt=x.on("health",Ze);break;case "transcript":bt=x.on("transcript",Ze);break;default:return}Bn.current.set(Ze,bt);},[x]),Ae=useCallback((he,Ze)=>{let bt=Bn.current.get(Ze);bt&&(bt(),Bn.current.delete(Ze));},[]),Te=useCallback(he=>{Ye.current=he;},[]);useEffect(()=>(x.setHeardSpeechProvider(()=>{let he=[...Ge.getSnapshot()].reverse().find(bt=>bt.speaker==="avatar"),Ze=Ye.current?.();return !he||he.isFinal||Ze==null?null:gl(he,Ze)}),()=>x.setHeardSpeechProvider(null)),[x,Ge]);let Be=useCallback(he=>{te.current=he,ae.current?.setPlaybackControls(he);},[]),Je=useCallback(()=>z.current?.acquire()??null,[]),St=useCallback(he=>x.setMicMuted(he),[x]),$e=useCallback(he=>x.setSpeakerMuted(he),[x]),Ke=useCallback(he=>x.setMoodDetection(he),[x]),lt=useCallback(()=>x.startTalking(),[x]),ct=useCallback(()=>x.stopTalking(),[x]),it=useCallback(()=>{z.current?.warm(),x.start();},[x]),Pt=useRef(false);useEffect(()=>{!o.autoStart||Pt.current||(Pt.current=true,it(),z.current?.ensureRunning().then(he=>{he||x.reportAudioBlocked("output");}));},[o.autoStart,it,x]);let _n=useCallback(()=>bn(),[bn]),ds=useCallback(()=>x.interrupt(),[x]),Mr=useCallback(()=>x.stopSpeaking(),[x]),po=useCallback(he=>x.speakText(he),[x]),ho=useCallback(he=>x.speakAudio(he),[x]),ir=useCallback(he=>x.setLipSyncTuning(he),[x]),mo=useCallback(he=>x.play(he),[x]),wn=useCallback(he=>x.addLiveContext(he),[x]),oi=useCallback(he=>x.notify(he),[x]),or=useCallback(()=>x.readPage(),[x]),Un=useCallback(he=>x.registerAction(he),[x]),ai=useCallback((...he)=>x.sendActionUi(...he),[x]),en=useCallback(()=>x.requestTour(),[x]),Le=useCallback(()=>x.skipNextGreeting(),[x]),Yt=useCallback(he=>x.on("speak",he),[x]),tn=useCallback(he=>x.on("widget-command",he),[x]),go=useCallback((he,Ze)=>x.reportCommandStatus("widget_control",he,Ze),[x]);useEffect(()=>!H||!x.capabilities?.page.read||!p.current&&t?void 0:(p.current?.watch??op)(()=>{x.readPage();}),[H,x,t]);let vo=useCallback(he=>x.triggerAction(he),[x]),Ao=useCallback(()=>x.avatarClicked(),[x]),wt=useMemo(()=>oe?.rive?.gestures?Object.keys(oe.rive.gestures):[],[oe]),ar=useMemo(()=>({enabled:o?.controls?.enabled||false,stopSpeaking:o?.controls?.stopSpeaking||false}),[o?.controls?.enabled,o?.controls?.stopSpeaking]),Tr=useCallback(()=>{Fn();},[Fn]),Vn=useCallback(()=>{Se.current?.flip();},[]),qt=useCallback(()=>x.setMoodDetection(!x.isMoodDetectionOn),[x]),Wn=H&&x.canReadMood,Sn=useMemo(()=>({stream:P,facing:U,sessionOpen:se,toggleVideo:Tr,flip:Vn,mood:Wn?{on:et,toggle:qt}:null}),[P,U,se,Tr,Vn,Wn,et,qt]),si=P!==null&&Wn&&et;useEffect(()=>{si?fn().start():ue.current?.stop();},[si,fn]),useEffect(()=>()=>ue.current?.dispose(),[]);let Hn=useCallback(()=>Ie.current?.shareFromClick(),[]),sr=useCallback(()=>Ie.current?.dismiss(),[]),kr=useCallback(()=>Ie.current?.stop(),[]),bo=useMemo(()=>({phase:Pe,share:Hn,dismiss:sr,stop:kr}),[Pe,Hn,sr,kr]),yo=h==="idle",fs=h==="connecting",lr=h==="active"&&m==="listening",Cr=y==="painted"&&Z,Gn=y==="failed",xr=y==="loading"||y==="painted"&&!Z,cr=ee||Fe||m==="greeting"||!!kt,En=o.transcript,jn=!!En?.enabled&&En.captions!==false,Rr=En?.position??"bottom-center",Dt=o.statusBanner,ps=Dt?.enabled!==false,Xt=Dt?.position??"bottom-left",Pr=o.thinkingIndicator,Ir=Pr?.enabled!==false,li=Pr?.position??"top-left",ci=o.screenShare?.position??"top-center";return {isReady:Cr,isLoading:xr,isConnecting:fs,isSpeaking:L,isListening:lr,isThinking:ee,isResponseSlow:pe,isIdle:yo,isFailed:Gn,isConnected:H,isMicMuted:We,isSpeakerMuted:rt,setMicMuted:St,setSpeakerMuted:$e,isMoodDetectionAvailable:Wn,isMoodDetectionOn:et,setMoodDetection:Ke,isPushToTalk:Zt,isTalking:He,startTalking:lt,stopTalking:ct,on:Y,off:Ae,start:it,stop:_n,interrupt:ds,stopSpeaking:Mr,speakText:po,speakAudio:ho,play:mo,addLiveContext:wn,notify:oi,readPage:or,registerAction:Un,triggerAction:vo,setLipSyncTuning:ir,availableActions:wt,notice:kt,_healthStore:Me,_transcriptStore:Ge,_actionFlowStore:Tt,_sendActionUi:ai,avatarId:o.avatar?.avatarId,error:W,controls:ar,_currentJob:C,_onPlaybackEnd:Kt,_onRiveReady:Er,_onRiveError:yn,_resetToken:ve,_mode:x.getMode(),_setMountSurface:x.setMountSurface,_onWidgetCommand:tn,_onSpeechJob:Yt,_requestTour:en,_skipNextGreeting:Le,_reportWidgetStatus:go,_riveKey:`${Xe}:${oe?.rive?.src??""}`,_avatarConfig:oe,_shouldArmTalking:cr,_userActivity:g,_thinkingSignal:f,_speakerMuted:rt,_gestureQueue:re,_gestureSignal:ke,_avatarClicked:Ao,_lipSyncTuning:x.getLipSyncTuning(),_rigActivity:nt,_visualState:dn,_camera:Sn,_screen:bo,_screenSharePosition:ci,_captionsEnabled:jn,_captionPosition:Rr,_statusBannerEnabled:ps,_statusBannerPosition:Xt,_thinkingIndicatorEnabled:Ir,_thinkingIndicatorPosition:li,_speechClockRef:Ye,_registerSpeechClock:Te,_registerPlaybackControls:Be,_getAudioContext:Je,_spacebarToTalk:o.turnTaking?.spacebar!==false,_environment:o.environment,mode:o.mode||"call"}},mp=r0;var gp=createContext(null),vp=({children:n})=>{let[e,t]=useState(false),[r,o]=useState("dormant"),[s,u]=useState("idle"),p=useRef(null),h=useCallback(y=>t(y),[]),A=useMemo(()=>({isOpen:e,stage:r,setOpen:h,setStage:o,tourState:s,setTourState:u,tourControlsRef:p}),[e,r,h,s]);return jsx(gp.Provider,{value:A,children:n})};function Ua(){let n=useContext(gp);if(!n)throw new Error("useAvatarWidget must be used within <AvatarProvider>");return n}var bp=createContext(null),f0=({config:n,children:e,pageHost:t,embedHostOrigin:r,embedResume:o})=>{let s=mp(n,t,r,o);return jsx(bp.Provider,{value:s,children:jsx(vp,{children:e})})},p0=f0;function Ut(){let n=useContext(bp);if(!n)throw new Error("useAvatar must be used within <AvatarProvider>");return n}function _p(){let n=Ut(),e=useSyncExternalStore(n._transcriptStore.subscribe,n._transcriptStore.getSnapshot,n._transcriptStore.getServerSnapshot),t=useSyncExternalStore(n._healthStore.subscribe,n._healthStore.getSnapshot,n._healthStore.getServerSnapshot);return {isReady:n.isReady,isLoading:n.isLoading,isConnecting:n.isConnecting,isSpeaking:n.isSpeaking,isListening:n.isListening,isThinking:n.isThinking,isResponseSlow:n.isResponseSlow,isIdle:n.isIdle,isFailed:n.isFailed,isConnected:n.isConnected,isMicMuted:n.isMicMuted,isSpeakerMuted:n.isSpeakerMuted,setMicMuted:n.setMicMuted,setSpeakerMuted:n.setSpeakerMuted,isMoodDetectionAvailable:n.isMoodDetectionAvailable,isMoodDetectionOn:n.isMoodDetectionOn,setMoodDetection:n.setMoodDetection,isPushToTalk:n.isPushToTalk,isTalking:n.isTalking,startTalking:n.startTalking,stopTalking:n.stopTalking,on:n.on,off:n.off,start:n.start,speakText:n?.speakText,speakAudio:n?.speakAudio,play:n?.play,stop:n.stop,interrupt:n.interrupt,stopSpeaking:n.stopSpeaking,avatarId:n.avatarId,error:n.error,notice:n?.notice,health:t,transcript:e,controls:n?.controls,addLiveContext:n?.addLiveContext,notify:n?.notify,readPage:n?.readPage,registerAction:n?.registerAction,triggerAction:n?.triggerAction,setLipSyncTuning:n?.setLipSyncTuning,availableActions:n?.availableActions}}function ft(n,{insertAt:e}={}){if(!n||typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",e==="top"&&t.firstChild?t.insertBefore(r,t.firstChild):t.appendChild(r),r.styleSheet?r.styleSheet.cssText=n:r.appendChild(document.createTextNode(n));}ft(`.avatar-controls-root{position:absolute;bottom:10px;display:flex;align-items:center;justify-content:center;gap:12px;pointer-events:none}.avatar-controls-button{pointer-events:auto;width:56px;height:56px;border-radius:50%;display:flex;align-items:center;justify-content:center;border:1px solid rgba(255,255,255,.2);cursor:pointer;color:#fff;backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);transition:transform .2s ease,box-shadow .2s ease,background-color .2s ease}.avatar-controls-button:active{transform:scale(.95)}.avatar-controls-call{background-color:#059669eb;box-shadow:0 4px 12px #00000026}.avatar-controls-call:hover{transform:scale(1.05);background-color:#10b981;box-shadow:0 6px 18px #0003}.avatar-controls-hangup{background-color:#e11d48eb;box-shadow:0 4px 12px #00000026}.avatar-controls-hangup:hover{transform:scale(1.05);background-color:#f43f5e;box-shadow:0 6px 18px #0003}.avatar-controls-mute{background-color:#1f29378c;box-shadow:0 4px 12px #00000026}.avatar-controls-mute:hover{transform:scale(1.05);background-color:#374151b3;box-shadow:0 6px 18px #0003}.avatar-controls-muted{background-color:#e11d48d9}.avatar-controls-muted:hover{background-color:#f43f5e}.avatar-controls-stop-speaking{background-color:#d97706e6;box-shadow:0 4px 12px #00000026}.avatar-controls-stop-speaking:hover{transform:scale(1.05);background-color:#f59e0b;box-shadow:0 6px 18px #0003}.avatar-controls-connecting{background-color:#6b7280;cursor:default}.avatar-controls-connecting:hover{transform:none;box-shadow:0 10px 25px #0006;background-color:#6b7280}@keyframes avatar-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.avatar-controls-spinner{animation:avatar-spin .9s linear infinite}
|
|
30
|
+
`);ft(`.avatar-ptt-root{position:absolute;bottom:10px;display:flex;align-items:center;justify-content:center;gap:10px;pointer-events:none}.avatar-ptt-secondary{pointer-events:auto;width:44px;height:44px;border-radius:50%;display:flex;align-items:center;justify-content:center;border:1px solid rgba(255,255,255,.14);background-color:#18181b8c;color:#fff;cursor:pointer;backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);transition:transform .18s cubic-bezier(.34,1.4,.64,1),background-color .18s ease,border-color .18s ease}.avatar-ptt-secondary:hover{transform:scale(1.06);background-color:#27272ab8}.avatar-ptt-secondary:active{transform:scale(.94)}.avatar-ptt-secondary-off{background-color:#e11d48d1;border-color:#ffffff38}.avatar-ptt-hangup:hover{background-color:#e11d48d9;border-color:#ffffff3d}.avatar-ptt-connect{pointer-events:auto;height:48px;padding:0 22px;border-radius:999px;display:flex;align-items:center;gap:9px;border:1px solid rgba(255,255,255,.18);background:linear-gradient(180deg,#10b981,#059669);color:#fff;font:600 14px/1 system-ui,-apple-system,Segoe UI,sans-serif;letter-spacing:.01em;cursor:pointer;box-shadow:0 6px 20px #05966959;transition:transform .18s cubic-bezier(.34,1.4,.64,1),box-shadow .18s ease,filter .18s ease}.avatar-ptt-connect:hover:not(:disabled){transform:translateY(-1px) scale(1.02);box-shadow:0 10px 26px #0596696b}.avatar-ptt-connect:active:not(:disabled){transform:scale(.97)}.avatar-ptt-connect:disabled{cursor:default;filter:grayscale(.7);opacity:.55;box-shadow:none}.avatar-ptt-button{pointer-events:auto;position:relative;height:52px;min-width:178px;padding:0;border:none;background:none;cursor:pointer;-webkit-tap-highlight-color:transparent;touch-action:none;user-select:none;-webkit-user-select:none}.avatar-ptt-face{position:relative;z-index:1;height:100%;padding:0 26px;border-radius:999px;display:flex;align-items:center;justify-content:center;gap:10px;border:1px solid rgba(255,255,255,.16);background:linear-gradient(180deg,#27272ad1,#18181be0);color:#ffffffeb;font:600 14.5px/1 system-ui,-apple-system,Segoe UI,sans-serif;letter-spacing:.01em;white-space:nowrap;backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px);box-shadow:0 8px 24px #00000047,inset 0 1px #ffffff14;transition:transform .22s cubic-bezier(.34,1.4,.64,1),background .22s ease,border-color .22s ease,box-shadow .22s ease,color .22s ease}.avatar-ptt-button:hover .avatar-ptt-face{transform:translateY(-1px);border-color:#ffffff42}.avatar-ptt-holding .avatar-ptt-face{transform:scale(1.04);border-color:#ffffff57;background:linear-gradient(180deg,#6366f1,#4f46e5);color:#fff;box-shadow:0 10px 30px #4f46e573,inset 0 1px #ffffff38}.avatar-ptt-icon{flex:none;opacity:.8;transition:opacity .22s ease,transform .22s cubic-bezier(.34,1.4,.64,1)}.avatar-ptt-holding .avatar-ptt-icon{opacity:1;transform:scale(1.12)}.avatar-ptt-label{display:inline-block;animation:avatar-ptt-label-in .26s cubic-bezier(.22,1,.36,1)}@keyframes avatar-ptt-label-in{0%{opacity:0;transform:translateY(5px)}to{opacity:1;transform:translateY(0)}}.avatar-ptt-halo{position:absolute;inset:-3px;border-radius:999px;background:#6366f1;opacity:0;transform:scale(.96);transition:opacity .3s ease,transform .3s ease}.avatar-ptt-holding .avatar-ptt-halo{animation:avatar-ptt-pulse 1.6s cubic-bezier(.25,.6,.35,1) infinite}@keyframes avatar-ptt-pulse{0%{opacity:.42;transform:scale(.98)}70%{opacity:0;transform:scale(1.14)}to{opacity:0;transform:scale(1.14)}}.avatar-ptt-button:disabled{cursor:default}.avatar-ptt-button:disabled .avatar-ptt-face{opacity:.5}@media(prefers-reduced-motion:reduce){.avatar-ptt-face,.avatar-ptt-icon,.avatar-ptt-secondary,.avatar-ptt-connect{transition-duration:.01ms}.avatar-ptt-holding .avatar-ptt-halo,.avatar-ptt-label{animation:none}.avatar-ptt-holding .avatar-ptt-halo{opacity:.3}}
|
|
31
|
+
`);ft(`.avatar-shell-root{position:relative;width:100%;height:100%;overflow:hidden;border-radius:inherit}.connectivity-dot{position:absolute;top:10px;right:25px;width:12px;height:12px;border-radius:50%;border:2px solid white;box-shadow:0 0 4px #0000004d;z-index:10;transition:background-color .3s ease}.connectivity-dot.connected{background-color:#4caf50}.connectivity-dot.disconnected{background-color:#f44336}
|
|
32
|
+
`);ft(`.avatar-root{position:relative;width:100%;height:100%}.avatar-connecting-overlay{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;container-type:size;pointer-events:none;z-index:21;animation:avatar-connecting-in .24s ease-out both}@keyframes avatar-connecting-in{0%{opacity:0}to{opacity:1}}@media(prefers-reduced-motion:reduce){.avatar-connecting-overlay{animation:none}}.avatar-controls{position:absolute;left:50%;bottom:12px;transform:translate(-50%);z-index:10;display:flex;align-items:center;justify-content:center}
|
|
33
|
+
`);ft(`.avatar-captions{position:absolute;z-index:12;display:flex;flex-direction:column;justify-content:flex-end;gap:6px;width:min(620px,calc(100% - 32px));--avatar-captions-max-lines: 2;--avatar-captions-text-line: 21px;--avatar-captions-pill-padding: 14px;max-height:calc(var(--avatar-captions-max-lines) * var(--avatar-captions-text-line) + var(--avatar-captions-pill-padding));overflow:hidden;border-radius:12px;pointer-events:none;transition:opacity .5s ease}.avatar-captions--top-left,.avatar-captions--bottom-left{left:16px;align-items:flex-start}.avatar-captions--top-right,.avatar-captions--bottom-right{right:16px;align-items:flex-end}.avatar-captions--top-center,.avatar-captions--bottom-center{left:50%;transform:translate(-50%);align-items:center}.avatar-captions--top-left,.avatar-captions--top-center,.avatar-captions--top-right{top:16px}.avatar-captions--bottom-left,.avatar-captions--bottom-center,.avatar-captions--bottom-right{bottom:16px}.avatar-captions--top-left .avatar-captions-line,.avatar-captions--bottom-left .avatar-captions-line{justify-content:flex-start;text-align:left}.avatar-captions--top-right .avatar-captions-line,.avatar-captions--bottom-right .avatar-captions-line{justify-content:flex-end;text-align:right}.avatar-captions--raised{bottom:72px}.avatar-captions--hidden{opacity:0}.avatar-captions-line{display:flex;flex-wrap:wrap;align-items:baseline;justify-content:center;gap:3px 6px;max-width:100%;margin:0;padding:7px 12px;border-radius:12px;background:#0c0c0ea8;backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);color:#fff;font-family:system-ui,-apple-system,Segoe UI,sans-serif;font-size:15px;font-weight:500;line-height:1.4;letter-spacing:.01em;text-align:center;animation:avatar-captions-line-in .24s ease-out both}.avatar-captions-line--past{opacity:.45;font-size:13.5px}.avatar-captions-tag{padding:1px 7px;border-radius:999px;background:#ffffff29;font-size:10.5px;font-weight:600;letter-spacing:.06em;text-transform:uppercase}.avatar-captions-word{display:inline-block;animation:avatar-captions-word-in .26s cubic-bezier(.2,.8,.2,1) both}.avatar-captions-word--interim{opacity:.82}@keyframes avatar-captions-line-in{0%{opacity:0;transform:translateY(6px)}to{opacity:1;transform:translateY(0)}}@keyframes avatar-captions-word-in{0%{opacity:0;transform:translateY(4px);filter:blur(2px)}to{opacity:1;transform:translateY(0);filter:blur(0)}}@media(prefers-reduced-motion:reduce){.avatar-captions-line,.avatar-captions-word{animation:none}}
|
|
34
|
+
`);ft(`.avatar-status-banner{position:absolute;z-index:13;display:flex;align-items:center;gap:9px;max-width:min(360px,calc(100% - 32px));padding:8px 13px 8px 11px;border-radius:999px;background:#0c0c0eb8;backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);box-shadow:0 4px 16px #00000047;color:#fff;font-family:system-ui,-apple-system,Segoe UI,sans-serif;pointer-events:none;animation:avatar-status-banner-in .24s ease-out both}.avatar-status-banner--top-left,.avatar-status-banner--bottom-left{left:16px}.avatar-status-banner--top-right,.avatar-status-banner--bottom-right{right:16px}.avatar-status-banner--top-left,.avatar-status-banner--top-right{top:16px}.avatar-status-banner--bottom-left,.avatar-status-banner--bottom-right{bottom:28px}.avatar-status-banner--raised{bottom:80px}.avatar-status-banner-dot{flex:none;width:9px;height:9px;border-radius:50%;background:#f5b53d;box-shadow:0 0 #f5b53d8c;animation:avatar-status-banner-pulse 1.8s ease-out infinite}.avatar-status-banner--failed .avatar-status-banner-dot{background:#f0533f;box-shadow:0 0 #f0533f8c;animation-duration:1.2s}.avatar-status-banner-text{display:flex;flex-direction:column;gap:1px;min-width:0}.avatar-status-banner-title{font-size:13px;font-weight:600;line-height:1.3;letter-spacing:.005em}.avatar-status-banner-detail{font-size:11.5px;font-weight:450;line-height:1.3;color:#ffffffad}@keyframes avatar-status-banner-in{0%{opacity:0;transform:translateY(6px)}to{opacity:1;transform:translateY(0)}}@keyframes avatar-status-banner-pulse{0%{box-shadow:0 0 #f5b53d80}70%,to{box-shadow:0 0 0 7px #f5b53d00}}@media(prefers-reduced-motion:reduce){.avatar-status-banner,.avatar-status-banner-dot{animation:none}}
|
|
35
|
+
`);ft(`.avatar-thinking-indicator{position:absolute;z-index:11;display:flex;align-items:center;gap:6px;padding:9px 13px;border-radius:999px;background:#0c0c0ea8;backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);pointer-events:none;animation:avatar-thinking-in .2s ease-out both}.avatar-thinking-indicator--top-left,.avatar-thinking-indicator--bottom-left{left:16px}.avatar-thinking-indicator--top-right,.avatar-thinking-indicator--bottom-right{right:16px}.avatar-thinking-indicator--top-center,.avatar-thinking-indicator--bottom-center{left:50%;transform:translate(-50%)}.avatar-thinking-indicator--top-left,.avatar-thinking-indicator--top-center,.avatar-thinking-indicator--top-right{top:16px}.avatar-thinking-indicator--bottom-left,.avatar-thinking-indicator--bottom-center,.avatar-thinking-indicator--bottom-right{bottom:16px}.avatar-thinking-indicator--raised{bottom:72px}.avatar-thinking-indicator-dot{width:7px;height:7px;border-radius:50%;background:#ffffffd9;animation:avatar-thinking-bounce 1.2s ease-in-out infinite}.avatar-thinking-indicator-dot:nth-child(2){animation-delay:.16s}.avatar-thinking-indicator-dot:nth-child(3){animation-delay:.32s}@keyframes avatar-thinking-bounce{0%,60%,to{transform:translateY(0);opacity:.5}30%{transform:translateY(-4px);opacity:1}}@keyframes avatar-thinking-in{0%{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}.avatar-thinking-indicator--top-center,.avatar-thinking-indicator--bottom-center{animation:avatar-thinking-fade .2s ease-out both}@keyframes avatar-thinking-fade{0%{opacity:0}to{opacity:1}}@media(prefers-reduced-motion:reduce){.avatar-thinking-indicator{animation:none}.avatar-thinking-indicator-dot{animation:avatar-thinking-pulse 1.4s ease-in-out infinite}.avatar-thinking-indicator-dot:nth-child(2){animation-delay:.2s}.avatar-thinking-indicator-dot:nth-child(3){animation-delay:.4s}}@keyframes avatar-thinking-pulse{0%,to{opacity:.4}50%{opacity:1}}
|
|
36
|
+
`);ft(`.rive-renderer-root{position:relative;width:100%;height:100%;min-height:0;overflow:hidden;border-radius:inherit}.rive-renderer-canvasWrapper{position:absolute;inset:0;width:100%;height:100%}.rive-renderer-canvas{width:100%;height:100%}.rive-renderer-canvas>canvas{display:block;width:100%!important;height:100%!important}.rive-renderer-surface{position:absolute;inset:0}.rive-renderer-hold{position:absolute;inset:0;width:100%;height:100%;pointer-events:none;z-index:1}.rive-renderer-hold[hidden]{display:none}.rive-renderer-loader{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;container-type:size;z-index:20}.rive-renderer-error{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;background:#0000008c;z-index:20;color:#ffffffb3}.rive-renderer-error-text{font-size:13px;font-family:system-ui,sans-serif;letter-spacing:.01em}
|
|
37
|
+
`);ft(`.avatar-camera-preview{position:absolute;z-index:20;width:22%;min-width:96px;max-width:180px;aspect-ratio:3 / 4;border-radius:12px;overflow:hidden;background:#000;box-shadow:0 4px 16px #00000059;border:1px solid rgba(255,255,255,.18)}.avatar-camera-preview.top-left{top:12px;left:12px}.avatar-camera-preview.top-right{top:12px;right:12px}.avatar-camera-preview.bottom-left{bottom:12px;left:12px}.avatar-camera-preview.bottom-right{bottom:12px;right:12px}.avatar-camera-preview.stage{--af-camera-stage-inset: 10px;--af-camera-stage-radius: 18px;inset:var(--af-camera-stage-inset);width:auto;min-width:0;max-width:none;aspect-ratio:auto;border:none;border-radius:var(--af-camera-stage-radius);background:#0d0f16;box-shadow:0 1px 2px #10122024,0 14px 34px -14px #10122080,inset 0 0 0 1px #ffffff29;z-index:1;animation:avatar-camera-stage-in .32s cubic-bezier(.2,.8,.2,1) backwards}@keyframes avatar-camera-stage-in{0%{opacity:0;transform:scale(1.015)}to{opacity:1;transform:none}}.avatar-camera-preview.stage:after{content:"";position:absolute;inset:0;border-radius:inherit;pointer-events:none;background:radial-gradient(125% 95% at 50% 45%,transparent 52%,rgba(10,12,20,.3) 100%),linear-gradient(to top,rgba(8,10,18,.45),transparent 30%)}.avatar-camera-preview.stage .avatar-camera-preview-actions{top:0;bottom:auto;z-index:2;padding:12px;background:linear-gradient(to bottom,#080a126b,#080a1200)}.avatar-camera-preview.stage .avatar-camera-preview-btn{width:36px;height:36px;background:#ffffff29;box-shadow:inset 0 0 0 1px #ffffff38;backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px)}.avatar-camera-preview.stage .avatar-camera-preview-btn:hover{background:#ffffff4d}.avatar-camera-preview.stage .avatar-camera-preview-off{gap:10px;font-size:14px;background:#0d0f16}.avatar-camera-preview.swappable,.avatar-pip-frame.swappable{cursor:pointer;transition:transform .18s ease,box-shadow .18s ease}.avatar-camera-preview.swappable:hover,.avatar-pip-frame.swappable:hover{transform:scale(1.03)}.avatar-camera-preview.swappable:focus-visible,.avatar-pip-frame.swappable:focus-visible{outline:2px solid #ffffff;outline-offset:2px}.avatar-pip-swap-hint{position:absolute;top:6px;right:6px;z-index:3;display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;border-radius:50%;color:#fff;background:#0c0e1680;backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px);opacity:0;transition:opacity .15s ease;pointer-events:none}.swappable:hover .avatar-pip-swap-hint,.swappable:focus-visible .avatar-pip-swap-hint{opacity:1}@media(hover:none){.avatar-pip-swap-hint{opacity:1}.avatar-camera-preview.swappable:hover,.avatar-pip-frame.swappable:hover{transform:none}}.avatar-stage-layer{position:absolute;inset:0}.avatar-pip-frame{position:absolute;z-index:20;width:26%;min-width:104px;max-width:200px;aspect-ratio:3 / 4;border:none;border-radius:16px;overflow:hidden;background:radial-gradient(118% 76% at 50% 6%,rgba(186,207,243,.42),transparent 62%),linear-gradient(to bottom,#fff,#eaeef9);box-shadow:0 1px 2px #10122029,0 16px 34px -14px #1012208c,inset 0 0 0 1px #ffffffbf;animation:avatar-pip-frame-in .32s cubic-bezier(.2,.8,.2,1) backwards}@keyframes avatar-pip-frame-in{0%{opacity:0;transform:translateY(6px) scale(.96)}to{opacity:1;transform:none}}.avatar-pip-frame.top-left{top:20px;left:20px}.avatar-pip-frame.top-right{top:20px;right:20px}.avatar-pip-frame.bottom-left{bottom:20px;left:20px}.avatar-pip-frame.bottom-right{bottom:20px;right:20px}@media(prefers-reduced-motion:reduce){.avatar-camera-preview.stage,.avatar-pip-frame{animation:none}}.avatar-camera-preview-video{width:100%;height:100%;object-fit:cover;display:block}.avatar-camera-preview-video.mirrored{transform:scaleX(-1)}.avatar-camera-preview-off{width:100%;height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;color:#ffffff8c;background:#1b1b1f;font-size:11px;font-family:inherit;user-select:none}.avatar-camera-preview-actions{position:absolute;left:0;right:0;bottom:0;display:flex;align-items:center;justify-content:center;gap:8px;padding:6px;background:linear-gradient(to top,#0000008c,#0000);opacity:0;transition:opacity .15s ease}.avatar-camera-preview:hover .avatar-camera-preview-actions,.avatar-camera-preview:focus-within .avatar-camera-preview-actions,.avatar-camera-preview.video-off .avatar-camera-preview-actions{opacity:1}@media(hover:none){.avatar-camera-preview-actions{opacity:1}}.avatar-camera-preview-btn{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border:none;border-radius:50%;cursor:pointer;color:#fff;background:#ffffff2e;backdrop-filter:blur(4px);transition:background .15s ease}.avatar-camera-preview-btn:hover{background:#ffffff52}.avatar-camera-preview-btn.off{background:#d93b3b}.avatar-camera-preview-btn.off:hover{background:#e85555}.avatar-camera-preview-btn:focus-visible{outline:2px solid #fff;outline-offset:2px}.avatar-camera-preview-mood{display:inline-flex;align-items:center;justify-content:center;gap:8px;width:28px;height:28px;padding:0;border:none;border-radius:999px;cursor:pointer;color:#ffffffb3;background:#ffffff2e;backdrop-filter:blur(4px);font:inherit;transition:background .15s ease,color .15s ease}.avatar-camera-preview-mood:hover{background:#ffffff52}.avatar-camera-preview-mood.on{color:#fff;background:#2fa86bd9}.avatar-camera-preview-mood.on:hover{background:#3aba79eb}.avatar-camera-preview-mood:focus-visible{outline:2px solid #fff;outline-offset:2px}.avatar-camera-preview-mood-label,.avatar-camera-preview-mood-track{display:none}.avatar-camera-preview.stage .avatar-camera-preview-mood{width:auto;height:36px;padding:0 10px 0 12px;color:#fff;background:#ffffff29;box-shadow:inset 0 0 0 1px #ffffff38;backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px)}.avatar-camera-preview.stage .avatar-camera-preview-mood:hover{background:#ffffff4d}.avatar-camera-preview.stage .avatar-camera-preview-mood-label{display:inline;font-size:13px;font-weight:500;white-space:nowrap}.avatar-camera-preview.stage .avatar-camera-preview-mood-track{position:relative;display:inline-block;width:28px;height:16px;border-radius:999px;background:#ffffff47;transition:background .15s ease}.avatar-camera-preview.stage .avatar-camera-preview-mood.on .avatar-camera-preview-mood-track{background:#2fa86b}.avatar-camera-preview-mood-knob{position:absolute;top:2px;left:2px;width:12px;height:12px;border-radius:50%;background:#fff;transition:transform .15s ease}.avatar-camera-preview-mood.on .avatar-camera-preview-mood-knob{transform:translate(12px)}@media(prefers-reduced-motion:reduce){.avatar-camera-preview-mood-knob{transition:none}}
|
|
38
|
+
`);ft(`.avatar-screen-share{position:absolute;z-index:14;--avatar-screen-share-x: 0;--avatar-screen-share-from: -6px;transform:translate(var(--avatar-screen-share-x));display:flex;align-items:center;gap:8px;max-width:calc(100% - 32px);padding:6px;border-radius:999px;background:#0c0c0ec7;backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);box-shadow:0 4px 16px #00000047;color:#fff;font-family:system-ui,-apple-system,Segoe UI,sans-serif;font-size:13px;white-space:nowrap;animation:avatar-screen-share-in .22s ease-out both}.avatar-screen-share.live{padding:6px 6px 6px 12px}.avatar-screen-share--top-left,.avatar-screen-share--bottom-left{left:16px}.avatar-screen-share--top-right,.avatar-screen-share--bottom-right{right:16px}.avatar-screen-share--top-center,.avatar-screen-share--bottom-center{left:50%;--avatar-screen-share-x: -50%}.avatar-screen-share--top-left,.avatar-screen-share--top-center,.avatar-screen-share--top-right{top:16px}.avatar-screen-share--bottom-left,.avatar-screen-share--bottom-center,.avatar-screen-share--bottom-right{bottom:16px;--avatar-screen-share-from: 6px}.avatar-screen-share--raised{bottom:72px}@keyframes avatar-screen-share-in{0%{opacity:0;transform:translate(var(--avatar-screen-share-x),var(--avatar-screen-share-from))}to{opacity:1;transform:translate(var(--avatar-screen-share-x))}}.avatar-screen-share-primary,.avatar-screen-share-secondary{display:inline-flex;align-items:center;gap:6px;padding:7px 13px;border:none;border-radius:999px;font:inherit;font-weight:600;cursor:pointer;transition:background .15s ease}.avatar-screen-share-primary{color:#0d0f16;background:#fff}.avatar-screen-share-primary:hover{background:#e8eaf0}.avatar-screen-share-secondary{color:#fff;background:#ffffff29}.avatar-screen-share-secondary:hover{background:#ffffff47}.avatar-screen-share-primary:focus-visible,.avatar-screen-share-secondary:focus-visible{outline:2px solid #fff;outline-offset:2px}.avatar-screen-share-dot{width:8px;height:8px;border-radius:50%;background:#d93b3b;animation:avatar-screen-share-pulse 1.6s ease-in-out infinite}@keyframes avatar-screen-share-pulse{50%{opacity:.35}}@media(prefers-reduced-motion:reduce){.avatar-screen-share,.avatar-screen-share-dot{animation:none}}
|
|
39
|
+
`);ft(`:where(.af-loader,.rive-renderer-loader,.avatar-connecting-overlay){--af-loader-1: #e3e9f7;--af-loader-2: #cfdaf2;--af-loader-3: #b8c7e9;--af-loader-4: #90a6da;--af-loader-ink: #47506b;--af-loader-avatar-blur: 10px}.rive-renderer-loader,.avatar-connecting-overlay{overflow:hidden}.rive-renderer-canvasWrapper{transition:filter .45s ease}.rive-renderer-root--loading .rive-renderer-canvasWrapper,.avatar-stage-loading .rive-renderer-canvasWrapper{filter:blur(var(--af-loader-avatar-blur))}.rive-renderer-loader:before,.avatar-connecting-overlay:before{content:"";position:absolute;top:50%;left:50%;width:76%;aspect-ratio:1;border-radius:50%;background:radial-gradient(40% 40% at 32% 28%,var(--af-loader-3),transparent 70%),radial-gradient(42% 42% at 70% 30%,var(--af-loader-2),transparent 70%),radial-gradient(46% 46% at 66% 74%,var(--af-loader-4),transparent 72%),radial-gradient(44% 44% at 30% 70%,var(--af-loader-1),transparent 72%);filter:blur(26px);opacity:.8;transform:translate(-50%,-50%);animation:af-loader-aura 9s linear infinite;pointer-events:none}@supports (width: 1cqmin){.rive-renderer-loader:before,.avatar-connecting-overlay:before{width:var(--af-loader-aura-size, 76cqmin);filter:blur(clamp(7px,7cqmin,24px))}}@keyframes af-loader-aura{0%{transform:translate(-50%,-50%) rotate(0) scale(1)}50%{transform:translate(-50%,-50%) rotate(180deg) scale(1.06)}to{transform:translate(-50%,-50%) rotate(360deg) scale(1)}}.af-loader{position:relative;display:flex;align-items:center;justify-content:center;width:7em;height:7em;font-family:inherit;font-size:15px;color:var(--af-loader-ink);user-select:none}@supports (width: 1cqmin){.af-loader{font-size:clamp(6px,11cqmin,15px)}}.af-loader__orb{position:absolute;inset:0;border-radius:50%;filter:blur(2px);animation:af-loader-rotate 3s linear infinite}@keyframes af-loader-rotate{0%{transform:rotate(90deg);box-shadow:0 .6em 1.25em #fff inset,0 1.25em 1.9em 0 var(--af-loader-2) inset,0 3.75em 3.75em 0 var(--af-loader-4) inset}33%{transform:rotate(210deg);box-shadow:0 .6em 1.25em #fff inset,0 1.25em 1em 0 var(--af-loader-1) inset,0 3em 3.75em 0 var(--af-loader-3) inset}66%{transform:rotate(330deg);box-shadow:0 .6em 1.25em #fff inset,0 1.25em .6em 0 var(--af-loader-3) inset,0 2.5em 3.75em 0 var(--af-loader-4) inset}to{transform:rotate(450deg);box-shadow:0 .6em 1.25em #fff inset,0 1.25em 1.9em 0 var(--af-loader-2) inset,0 3.75em 3.75em 0 var(--af-loader-4) inset}}.af-loader__letters{position:relative;z-index:1;display:flex;font-size:.85em;font-weight:600;letter-spacing:.02em}.af-loader__letter{display:inline-block;opacity:.4;animation:af-loader-letter 2s infinite}@keyframes af-loader-letter{0%,to{opacity:.4;transform:translateY(0)}20%{opacity:1;transform:scale(1.15)}40%{opacity:.7;transform:translateY(0)}}@container (max-width: 150px){.af-loader__letters{display:none}}@media(prefers-reduced-motion:reduce){.rive-renderer-loader:before,.avatar-connecting-overlay:before{animation:none}.af-loader__orb{animation-duration:9s}.af-loader__letter{animation:none;opacity:.75}}
|
|
40
|
+
`);ft(`.af-widget{position:fixed;width:var(--af-widget-w);height:var(--af-widget-h);transition:width .32s cubic-bezier(.2,.8,.2,1),height .32s cubic-bezier(.2,.8,.2,1)}.af-widget--bottom-right{right:var(--af-widget-offset-x);bottom:var(--af-widget-offset-y)}.af-widget--bottom-left{left:var(--af-widget-offset-x);bottom:var(--af-widget-offset-y)}.af-widget--top-right{right:var(--af-widget-offset-x);top:var(--af-widget-offset-y)}.af-widget--top-left{left:var(--af-widget-offset-x);top:var(--af-widget-offset-y)}.af-widget--sheet{inset:0}.af-widget--free{left:var(--af-widget-left);top:var(--af-widget-top);right:auto;bottom:auto;transition:width .32s cubic-bezier(.2,.8,.2,1),height .32s cubic-bezier(.2,.8,.2,1),left .32s cubic-bezier(.2,.8,.2,1),top .32s cubic-bezier(.2,.8,.2,1)}.af-widget--dragging,.af-widget--dragging .af-widget__frame,.af-widget--gliding,.af-widget--gliding .af-widget__frame{transition:none}.af-widget--sheet.af-widget--free{inset:0}.af-widget{--af-widget-bounce-lift: -12px}.af-widget--expanded{--af-widget-bounce-lift: -7px}@keyframes af-widget-bounce{0%{transform:translateZ(0);animation-timing-function:cubic-bezier(.22,.68,.36,1)}22%{transform:translate3d(0,var(--af-widget-bounce-lift),0);animation-timing-function:cubic-bezier(.6,0,.85,.35)}40%{transform:translateZ(0);animation-timing-function:cubic-bezier(.22,.68,.36,1)}52%{transform:translate3d(0,calc(var(--af-widget-bounce-lift) * .42),0);animation-timing-function:cubic-bezier(.6,0,.85,.35)}62%{transform:translateZ(0)}to{transform:translateZ(0)}}.af-widget--bouncing .af-widget__frame{animation:af-widget-bounce 1.4s;animation-iteration-count:var(--af-widget-bounce-count, 1);will-change:transform}.af-widget--draggable.af-widget--collapsed .af-widget__launcher,.af-widget--draggable.af-widget--expanded:not(.af-widget--sheet) .af-widget__header{cursor:grab;touch-action:none;user-select:none}.af-widget--dragging .af-widget__launcher,.af-widget--dragging .af-widget__header{cursor:grabbing}.af-widget__frame{position:relative;width:100%;height:100%;overflow:hidden;border-radius:var(--af-widget-radius);background:linear-gradient(to bottom,color-mix(in srgb,var(--af-widget-bg) 82%,#fff) 0%,var(--af-widget-bg) 58%,color-mix(in srgb,var(--af-widget-bg) 92%,var(--af-widget-fg)) 100%);box-shadow:0 0 0 1px color-mix(in srgb,var(--af-widget-fg) 8%,transparent),inset 0 1px color-mix(in srgb,#fff 60%,transparent),0 1px 2px #0000000a,0 10px 28px -10px #00000029,0 34px 70px -26px #0000004d;transition:background .22s ease,border-radius .32s cubic-bezier(.2,.8,.2,1),box-shadow .32s ease}@supports not (color: color-mix(in srgb,red 50%,blue)){.af-widget__frame{background:var(--af-widget-bg)}}.af-widget--expanded .af-widget__frame:before{content:"";position:absolute;inset:0;background:radial-gradient(62% 46% at 50% 40%,color-mix(in srgb,#fff 72%,transparent),transparent 72%);opacity:.7;transition:opacity .6s ease;pointer-events:none}.af-widget--expanded.af-widget--speaking .af-widget__frame:before{opacity:1}.af-widget--expanded .af-widget__frame:after{content:"";position:absolute;left:50%;bottom:9%;width:46%;height:26px;transform:translate(-50%);border-radius:50%;background:radial-gradient(closest-side,color-mix(in srgb,var(--af-widget-fg) 17%,transparent),transparent);pointer-events:none}.af-widget--collapsed .af-widget__frame{background:transparent;box-shadow:none}.af-widget--collapsed .af-widget__frame{scale:calc(1 + var(--af-widget-lift, 0))}.af-widget__stage{position:absolute;inset:0;transition:opacity .16s ease}.af-widget--expanded .af-widget__stage .rive-renderer-canvasWrapper{inset:calc((1 - var(--af-widget-avatar-scale)) * 50%);width:auto;height:auto}.af-widget--expanded .af-widget__stage .rive-renderer-loader,.af-widget--expanded .af-widget__stage .avatar-connecting-overlay{--af-loader-aura-size: calc(76cqmin * var(--af-widget-avatar-scale))}.af-widget--sheet .af-widget__stage .rive-renderer-canvasWrapper{inset:0;width:100%;height:100%}.af-widget--sheet .af-widget__stage .rive-renderer-loader,.af-widget--sheet .af-widget__stage .avatar-connecting-overlay{--af-loader-aura-size: 76cqmin}.af-widget--settling .af-widget__stage{opacity:0}.af-widget__settle{position:absolute;inset:0;display:grid;place-items:center;z-index:15;pointer-events:none;animation:af-widget-chrome-in .16s ease-out both}.af-widget__settle-spinner{width:26px;height:26px;border-radius:50%;border:2px solid var(--af-widget-scrim);border-top-color:var(--af-widget-fg);animation:af-widget-spin .85s linear infinite}@keyframes af-widget-spin{to{transform:rotate(360deg)}}.af-widget--collapsed .af-widget__stage{pointer-events:none}.af-widget--collapsed .avatar-captions,.af-widget--collapsed .avatar-status-banner,.af-widget--collapsed .avatar-thinking-indicator,.af-widget--collapsed .avatar-controls,.af-widget--collapsed .connectivity-dot{display:none}.af-widget__launcher{position:absolute;inset:0;padding:0;border:0;border-radius:inherit;background:transparent;cursor:pointer;z-index:14;transition:transform .22s cubic-bezier(.2,.8,.2,1)}.af-widget--collapsed .af-widget__frame:hover .af-widget__launcher{transform:translateY(-2px) scale(1.04)}.af-widget__launcher:active{transform:scale(.96)}.af-widget--collapsed .af-widget__frame:before{content:"";position:absolute;inset:-18%;border-radius:50%;background:radial-gradient(closest-side,color-mix(in srgb,var(--af-widget-accent) 34%,transparent),transparent);opacity:0;transition:opacity .26s ease;pointer-events:none}.af-widget--collapsed .af-widget__frame:hover:before,.af-widget--live.af-widget--collapsed .af-widget__frame:before{opacity:1}.af-widget__launcher:focus-visible{outline:2px solid var(--af-widget-accent);outline-offset:3px}.af-widget__ring{position:absolute;inset:-3px;border-radius:50%;border:2px solid var(--af-widget-accent);animation:af-widget-pulse 2s ease-in-out infinite;pointer-events:none}.af-widget__timer{position:absolute;left:50%;bottom:-7px;transform:translate(-50%);padding:1px 7px;border-radius:999px;background:#0c0c0edb;color:#fff;font:600 10px/1.5 system-ui,sans-serif;font-variant-numeric:tabular-nums;letter-spacing:.02em}@keyframes af-widget-pulse{0%,to{opacity:.55;transform:scale(1)}50%{opacity:1;transform:scale(1.06)}}.af-widget__chrome{position:absolute;inset:0;display:flex;flex-direction:column;justify-content:space-between;pointer-events:none;z-index:16;animation:af-widget-chrome-in .22s ease-out 90ms both}.af-widget__header{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:14px 14px 0;pointer-events:auto}.af-widget__title{color:var(--af-widget-fg);font:600 14px/1.3 system-ui,-apple-system,Segoe UI,sans-serif;letter-spacing:-.015em}.af-widget__status,.af-widget__collapse{background:color-mix(in srgb,var(--af-widget-bg) 62%,transparent);backdrop-filter:blur(16px) saturate(150%);-webkit-backdrop-filter:blur(16px) saturate(150%);box-shadow:0 0 0 1px color-mix(in srgb,var(--af-widget-fg) 8%,transparent),0 2px 8px -4px #00000024}.af-widget__status{display:inline-flex;align-items:center;gap:7px;margin-right:auto;height:28px;padding:0 11px 0 10px;border-radius:999px;color:var(--af-widget-fg);font:600 12px/1 system-ui,-apple-system,Segoe UI,sans-serif;font-variant-numeric:tabular-nums;letter-spacing:.01em}.af-widget__title+.af-widget__status{margin-left:8px}.af-widget__status-dot{position:relative;width:7px;height:7px;border-radius:50%;background:currentColor;opacity:.45;animation:af-widget-blink 1.4s ease-in-out infinite}.af-widget__status--live .af-widget__status-dot{background:var(--af-widget-live);opacity:1;animation:none}.af-widget__status--live .af-widget__status-dot:after{content:"";position:absolute;inset:0;border-radius:50%;background:var(--af-widget-live);animation:af-widget-ripple 2.2s ease-out infinite}@keyframes af-widget-ripple{0%{transform:scale(1);opacity:.55}to{transform:scale(3);opacity:0}}@keyframes af-widget-blink{0%,to{opacity:.25}50%{opacity:.75}}.af-widget__collapse{flex:none;display:grid;place-items:center;width:32px;height:32px;margin-left:auto;padding:0;border:0;border-radius:50%;color:var(--af-widget-fg);cursor:pointer;transition:background .16s ease,transform .16s ease}.af-widget__collapse:hover{background:color-mix(in srgb,var(--af-widget-bg) 86%,var(--af-widget-fg))}.af-widget__collapse:active{transform:scale(.94)}.af-widget__collapse:focus-visible{outline:2px solid var(--af-widget-fg);outline-offset:2px}.af-widget__composer{padding:36px 14px 16px;background:linear-gradient(to top,color-mix(in srgb,var(--af-widget-bg) 78%,transparent),transparent);pointer-events:auto}.af-widget--callbar .avatar-controls,.af-widget--callbar.af-widget--expanded .connectivity-dot{display:none}.af-widget--callbar.af-widget--expanded .af-widget__frame:after,.af-widget--callbar .af-loader__letters{display:none}.af-widget--callbar .avatar-captions--bottom-left,.af-widget--callbar .avatar-captions--bottom-center,.af-widget--callbar .avatar-captions--bottom-right,.af-widget--callbar .avatar-status-banner--bottom-left,.af-widget--callbar .avatar-status-banner--bottom-right,.af-widget--callbar .avatar-thinking-indicator--bottom-left,.af-widget--callbar .avatar-thinking-indicator--bottom-center,.af-widget--callbar .avatar-thinking-indicator--bottom-right,.af-widget--callbar .avatar-screen-share--bottom-left,.af-widget--callbar .avatar-screen-share--bottom-center,.af-widget--callbar .avatar-screen-share--bottom-right{bottom:88px}.af-widget__callbar{display:flex;align-items:center;justify-content:center;gap:10px;width:fit-content;margin:0 auto;padding:7px;border-radius:999px;background:#141418cc;backdrop-filter:blur(20px) saturate(160%);-webkit-backdrop-filter:blur(20px) saturate(160%);box-shadow:inset 0 0 0 1px #ffffff14,inset 0 1px #ffffff1a,0 14px 34px -14px #0000008c}.af-widget__help{max-width:260px;margin:0 auto 10px;padding:8px 12px;border-radius:12px;background:#141418d1;color:#fff;font:500 12.5px/1.4 system-ui,-apple-system,Segoe UI,sans-serif;text-align:center;text-wrap:pretty}.af-widget__callbar--idle{padding:0;background:none;backdrop-filter:none;-webkit-backdrop-filter:none;box-shadow:none}.af-widget__callbar-button,.af-widget__call{border:0;cursor:pointer;transition:background .16s ease,color .16s ease,transform .16s ease,opacity .16s ease,box-shadow .16s ease}.af-widget__callbar-button{flex:none;display:grid;place-items:center;width:46px;height:46px;padding:0;border-radius:50%;background:#ffffff1a;color:#fff}.af-widget__callbar-button:hover:not(:disabled){background:#ffffff2e}.af-widget__callbar-button[aria-pressed=true]{background:#fff;color:#141418}.af-widget__call{display:inline-flex;align-items:center;justify-content:center;gap:9px;color:#fff;font:600 14.5px/1 system-ui,-apple-system,Segoe UI,sans-serif;letter-spacing:-.005em}.af-widget__call--start{height:50px;padding:0 26px 0 22px;border-radius:999px;background:var(--af-widget-fg);color:var(--af-widget-bg);box-shadow:inset 0 1px #ffffff24,0 1px 2px #0000001f,0 12px 26px -12px #00000080}.af-widget__call--start:hover:not(:disabled){transform:translateY(-1px);box-shadow:inset 0 1px #ffffff24,0 1px 2px #0000001f,0 16px 30px -12px #0000008c}.af-widget__call--end{width:58px;height:46px;border-radius:999px;background:#ef4444}.af-widget__call--end:hover{background:#f05252}.af-widget__callbar-button:active:not(:disabled),.af-widget__call:active:not(:disabled){transform:scale(.95)}.af-widget__callbar-button:disabled,.af-widget__call:disabled{opacity:.4;cursor:default}.af-widget__callbar-button:focus-visible,.af-widget__call:focus-visible{outline:2px solid #fff;outline-offset:2px}.af-widget__call--start:focus-visible{outline-color:var(--af-widget-fg)}@keyframes af-widget-chrome-in{0%{opacity:0}to{opacity:1}}.af-widget--framed.af-widget--expanded .af-widget__frame{box-shadow:0 0 0 1px color-mix(in srgb,var(--af-widget-fg) 8%,transparent),inset 0 1px color-mix(in srgb,#fff 60%,transparent),0 1px 2px #0000000d,0 10px 22px -8px #00000038}@media(prefers-reduced-motion:reduce){.af-widget,.af-widget__frame,.af-widget__stage,.af-widget__launcher,.af-widget__callbar-button,.af-widget__call{transition:none}.af-widget__chrome,.af-widget__settle,.af-widget__status-dot,.af-widget__status-dot:after,.af-widget--bouncing .af-widget__frame{animation:none}.af-widget--bouncing .af-widget__frame{will-change:auto}.af-widget--collapsed .af-widget__frame:hover .af-widget__launcher{transform:none}.af-widget__ring{animation:af-widget-ring-fade 2s ease-in-out infinite}}@keyframes af-widget-ring-fade{0%,to{opacity:.5}50%{opacity:1}}
|
|
41
|
+
`);ft(`.af-tour-layer{position:fixed;inset:0;pointer-events:none;z-index:2147483001}.af-tour-layer--marks{z-index:2147483000;mix-blend-mode:multiply}.af-tour-arrow{position:absolute;top:0;left:0;width:40px;height:40px;transform-origin:center}.af-tour-arrow__badge{display:flex;align-items:center;justify-content:center;width:100%;height:100%;border-radius:50%;background:var(--af-pointer-bg, #0e0e10);color:var(--af-pointer-fg, #ffffff);box-shadow:0 2px 4px #09090b1f,0 8px 20px -6px #09090b66;animation:af-tour-arrow-in .2s ease-out both}.af-tour-arrow__badge--out{animation:af-tour-arrow-out .15s ease-in both}.af-tour-arrow__glyph{display:block;animation:af-tour-arrow-nudge 1.4s ease-in-out .2s infinite}.af-tour-mark{position:absolute;border-radius:4px;background:var(--af-highlight-color, #fef08a);transform-origin:left center;animation-name:af-tour-mark-in;animation-duration:.8s;animation-fill-mode:both;animation-timing-function:cubic-bezier(.3,1.25,.6,1)}@supports (animation-timing-function: linear(0,1)){.af-tour-mark{animation-timing-function:linear(0,.047,.161,.306,.458,.601,.726,.828,.907,.965,1.005,1.029,1.042,1.046,1.045,1.04,1.033,1.026,1.02,1.014,1.009,1.005,1.002,1,1)}}.af-tour-mark--strong{background:var(--af-highlight-strong-color, #facc15)}.af-tour-mark--out{animation:af-tour-mark-out .22s ease-in both}::highlight(af-tour-ink){color:var(--af-highlight-ink, #171717)}::highlight(af-tour-ink-strong){color:var(--af-highlight-strong-ink, #0a0a0a);text-shadow:.35px 0 0 var(--af-highlight-strong-ink, #0a0a0a)}@keyframes af-tour-arrow-in{0%{opacity:0;transform:scale(.5)}to{opacity:1;transform:none}}@keyframes af-tour-arrow-out{0%{opacity:1;transform:none}to{opacity:0;transform:scale(.5)}}@keyframes af-tour-arrow-nudge{0%,to{transform:translateY(0)}50%{transform:translateY(-3px)}}@keyframes af-tour-mark-in{0%{transform:scaleX(0)}to{transform:scaleX(1)}}@keyframes af-tour-mark-out{0%{opacity:1}to{opacity:0}}.af-widget__pill{position:absolute;bottom:50%;display:flex;align-items:center;gap:4px;animation:af-pill-pop .42s cubic-bezier(.34,1.35,.5,1) both}.af-widget--bottom-right .af-widget__pill,.af-widget--top-right .af-widget__pill{right:calc(100% + 10px);transform:translateY(50%);transform-origin:right center}.af-widget--bottom-left .af-widget__pill,.af-widget--top-left .af-widget__pill{left:calc(100% + 10px);transform:translateY(50%);transform-origin:left center}.af-widget__pill-glow{position:absolute;inset:-8px;border-radius:999px;background:var(--af-pill-glow, rgba(158, 74, 50, .15));filter:blur(16px);pointer-events:none;animation:af-pill-drift 6s ease-in-out infinite}.af-widget__pill-button{position:relative;display:flex;align-items:center;justify-content:center;width:40px;height:40px;padding:0;overflow:hidden;border:1px solid var(--af-pill-border, rgba(228, 228, 231, .8));border-radius:999px;background:var(--af-pill-bg, rgba(255, 255, 255, .95));color:var(--af-pill-fg, #18181b);font:500 12px/1 system-ui,-apple-system,sans-serif;white-space:nowrap;cursor:pointer;backdrop-filter:blur(8px);box-shadow:0 2px 5px #09090b0f,0 14px 28px -16px #09090b66;transition:width .52s cubic-bezier(.22,1,.36,1)}.af-widget__pill-button--open{width:var(--af-pill-open-width, 148px)}.af-widget__pill-button:focus-visible{outline:2px solid #0e0e10;outline-offset:2px}.af-widget__pill-dots,.af-widget__pill-text{transition:opacity .26s ease-out,filter .26s ease-out,transform .26s ease-out}.af-widget__pill-dots{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;gap:3px;transition-delay:.2s}.af-widget__pill-dots span{width:4px;height:4px;border-radius:50%;background:var(--af-pill-dots, #a1a1aa);animation:af-pill-dot 1.2s ease-in-out infinite}.af-widget__pill-dots span:nth-child(2){animation-delay:.15s}.af-widget__pill-dots span:nth-child(3){animation-delay:.3s}.af-widget__pill-button--open .af-widget__pill-dots{opacity:0;filter:blur(3px);transform:scale(.9);transition-delay:0ms}.af-widget__pill-text{padding:0 16px;opacity:0;filter:blur(3px);transform:scale(.95)}.af-widget__pill-button--open .af-widget__pill-text{opacity:1;filter:none;transform:none;transition-delay:.2s}.af-widget__pill-close{position:absolute;top:-6px;right:-6px;display:flex;align-items:center;justify-content:center;width:16px;height:16px;padding:0;border:1px solid #e4e4e7;border-radius:50%;background:#fff;color:#a1a1aa;font-size:10px;line-height:1;cursor:pointer;opacity:0;box-shadow:0 1px 2px #09090b14;transition:opacity .16s ease-out}.af-widget__pill:hover .af-widget__pill-close,.af-widget__pill-close:focus-visible{opacity:1}.af-widget__pill-close:hover{color:#3f3f46}@keyframes af-pill-pop{0%{opacity:0;scale:.5}to{opacity:1;scale:1}}@keyframes af-pill-drift{0%,to{transform:translateZ(0) scale(1)}50%{transform:translate3d(4px,-4px,0) scale(1.08)}}@keyframes af-pill-dot{0%,80%,to{opacity:.35;transform:translateY(0)}40%{opacity:1;transform:translateY(-2px)}}@media(prefers-reduced-motion:reduce){.af-tour-arrow__badge,.af-tour-arrow__glyph,.af-tour-mark,.af-widget__pill,.af-widget__pill-glow,.af-widget__pill-dots span{animation:none}}
|
|
42
|
+
`);var h0=({children:n,className:e,style:t})=>jsx("div",{className:`avatar-shell-root ${e??""}`,style:t,children:n}),wp=h0;var io=vi(eo());var Sp="EnhancedLipSync",ec=100,g0=.55,v0=.35,A0=.45,b0=.4,Va=.04,y0=60,_0=2,Ep=64,Wa=class{constructor(){this.rive=null;this.clock=null;this.visemes=[];this.rafId=null;this.running=false;this.currentValues=new Map;this.inputs=new Map;this.silenceInput=null;this.jawOpen=0;this.lastActiveTime=pn;this.lastTickTime=0;this.tuning=new xn;this.tick=()=>{if(!this.running||!this.clock)return;let e=performance.now(),t=this.lastTickTime?Math.min((e-this.lastTickTime)/(1e3/y0),this.tuning.maxStepFrames):1;this.lastTickTime=e;let r=t*this.tuning.speed,o=this.clock.getAlignmentTime(),s=new Map,u=false,p=1/0;for(let S of this.visemes){let C=S.start-Va,I=S.end+Va;if(p===1/0&&S.start>o&&S.visemeId!==0&&(p=S.start-o),o<C||o>I)continue;let L=S.end-S.start,B=Math.min(.06,L*.45),W=1;if(o<S.start+B?W=(o-C)/(B+Va):o>S.end-B&&(W=(I-o)/(B+Va)),W=Math.max(0,Math.min(1,W)),W>0&&S.visemeId!==0){u=true;let Q=s.get(S.visemeId)||0;s.set(S.visemeId,Math.max(Q,W));}}let h=0;for(let S of s.values())h+=S;if(h>1)for(let[S,C]of s)s.set(S,C/h);u&&(this.lastActiveTime=o);let y=o-this.lastActiveTime<this.tuning.holdSec?1:0,b=y>this.jawOpen?g0:v0,m=r*this.tuning.jawSpeed;this.jawOpen+=(y-this.jawOpen)*(1-Math.pow(1-b,m)),this.jawOpen<.01&&(this.jawOpen=0);for(let[S,C]of this.currentValues){let I=s.get(S)||0,B=Math.min(ec,I*this.jawOpen*ec*this.tuning.openness)-C,W=B>0?A0:b0,Q=C+B*(1-Math.pow(1-W,r));this.currentValues.set(S,Q);let Z=this.inputs.get(S);Z&&(Z.value=Math.round(Q));}if(this.silenceInput){let S=Math.min(o-this.lastActiveTime,p),C=this.tuning.holdSec,I=Math.min(1,Math.max(0,(S-C)/(yi-C))),L=this.tuning.rest+I*(ec-this.tuning.rest);this.silenceInput.value=Math.round((1-this.jawOpen)*L);}this.rafId=requestAnimationFrame(this.tick);};}initialize(e,t,r,o){this.clock=t,o&&(this.tuning=o),this.currentValues.clear(),this.jawOpen=0,this.visemes=[],this.lastTickTime=0,this.retarget(e,r);}retarget(e,t){if(this.rive=e,this.inputs.clear(),this.silenceInput=null,!e)return;let{name:r,inputs:o}=mn(e,t);for(let s of o){let u=hr(s.name);if(u!==null){if(u===0){this.silenceInput=s,s.value=0;continue}this.inputs.set(u,s),this.currentValues.has(u)||this.currentValues.set(u,0),s.value=Math.round(this.currentValues.get(u)??0);}}this.inputs.size===0?E.error(Sp,"no viseme inputs on the rig \u2014 lip-sync will not move",{requestedStateMachine:t??"(unset)",resolvedStateMachine:r,artboardStateMachines:e.stateMachineNames,inputNames:o.map(s=>s.name)}):E.debug(Sp,"bound to rig",{stateMachine:r,visemeIds:[...this.inputs.keys()].sort((s,u)=>s-u),silenceInputFound:!!this.silenceInput});}detach(){this.retarget(null);}appendVisemes(e){this.visemes.push(...e),this.visemes.sort((t,r)=>t.start-r.start),this.pruneSpentVisemes();}clearVisemes(){this.visemes=[],this.lastActiveTime=pn;}pruneSpentVisemes(){if(this.visemes.length<=Ep||!this.clock||!this.clock.isLive())return;let e=this.clock.getAlignmentTime()-_0;if(e<=0)return;let t=0;for(;t<this.visemes.length&&this.visemes[t].end<e;)t++;t=Math.min(t,this.visemes.length-Ep),t>0&&this.visemes.splice(0,t);}start(){this.running||(this.running=true,this.lastTickTime=0,this.tick());}stop(){if(this.running){this.running=false,this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null);for(let e of this.inputs.values())try{e.value=0;}catch{}if(this.silenceInput)try{this.silenceInput.value=this.tuning.rest;}catch{}this.visemes=[],this.inputs.clear(),this.currentValues.clear(),this.silenceInput=null,this.rive=null,this.clock=null,this.lastTickTime=0;}}forceSilence(){this.lastActiveTime=pn,this.jawOpen=0;for(let[e,t]of this.inputs)t.value=0,this.currentValues.set(e,0);this.silenceInput&&(this.silenceInput.value=this.tuning.rest);}};var Ha=100,w0=.55,S0=.35,E0=.45,M0=.4,Ga=.04,Mp=0,T0=0,k0=60,C0=2,Tp=64,an="DataBindingLipSync",Ar=class{constructor(){this.vmInstance=null;this.clock=null;this.visemes=[];this.rafId=null;this.running=false;this.numberProps=new Map;this.currentValues=new Map;this.silenceProp=null;this.formatName=e=>`${e}`;this.jawOpen=0;this.lastActiveTime=pn;this.lastTickTime=0;this.lastTickLogTime=0;this.silencing=false;this.tuning=new xn;this.tick=()=>{if(!this.running||!this.clock)return;let e=performance.now(),t=this.lastTickTime?Math.min((e-this.lastTickTime)/(1e3/k0),this.tuning.maxStepFrames):1;this.lastTickTime=e;let r=t*this.tuning.speed,o=this.clock.getAlignmentTime(),s=new Map,u=false;for(let S of this.visemes){let C=S.start-Ga,I=S.end+Ga;if(o<C||o>I)continue;let L=S.end-S.start,B=Math.min(.06,L*.45),W=1;if(o<S.start+B?W=(o-C)/(B+Ga):o>S.end-B&&(W=(I-o)/(B+Ga)),W=Math.max(0,Math.min(1,W)),W>0&&S.visemeId!==0){u=true;let Q=s.get(S.visemeId)??0;s.set(S.visemeId,Math.max(Q,W));}}let p=0;for(let S of s.values())p+=S;if(p>1)for(let[S,C]of s)s.set(S,C/p);u&&(this.lastActiveTime=o);let h=o-this.lastActiveTime<this.tuning.holdSec,A=0;if(!h){for(let S of this.visemes)if(S.start>o&&S.visemeId!==0){let C=S.start-o;C<Mp&&(A=T0*(1-C/Mp));break}}let y=h?1:A,b=y>this.jawOpen?w0:S0,m=r*this.tuning.jawSpeed;this.jawOpen+=(y-this.jawOpen)*(1-Math.pow(1-b,m)),this.jawOpen<.01&&(this.jawOpen=0),this.silencing&&this.jawOpen===0&&(this.silencing=false,E.debug(an,"tick: silence complete"));for(let[S,C]of this.numberProps){let I=s.get(S)??0,L=Math.min(Ha,I*this.jawOpen*Ha*this.tuning.openness),B=this.currentValues.get(S)??0,W=L-B,Q=W>0?E0:M0,Z=B+W*(1-Math.pow(1-Q,r)),$=Math.round(Z);if(this.currentValues.set(S,Z),!!C)try{C.value=$;}catch(oe){E.error(an,`tick: failed writing visemeId=${S} value=${$}`,oe);}}try{if(this.silenceProp){let S=Ha;if(!this.silencing){let C=o-this.lastActiveTime,I=1/0;for(let Q of this.visemes)if(Q.start>o&&Q.visemeId!==0){I=Q.start-o;break}let L=Math.min(C,I),B=this.tuning.holdSec,W=Math.min(1,Math.max(0,(L-B)/(yi-B)));S=this.tuning.rest+W*(Ha-this.tuning.rest);}this.silenceProp.value=Math.round((1-this.jawOpen)*S);}}catch(S){E.error(an,"tick: failed writing silence prop",S);}this.rafId=requestAnimationFrame(this.tick);};}initialize(e,t,r){this.clock=t,r&&(this.tuning=r);let o=t.getAlignmentTime();this.jawOpen=o>.05?1:0,this.lastActiveTime=this.jawOpen>0?o:pn,this.visemes=[],this.numberProps.clear(),this.currentValues.clear(),this.lastTickTime=0,this.lastTickLogTime=0,this.silencing=false,this.retarget(e),E.debug(an,"initialize",{initialT:o.toFixed(3),jawPreWarmed:this.jawOpen>0});try{this.silenceProp&&(this.silenceProp.value=this.tuning.rest);}catch(s){E.error(an,"initialize: failed to set silence prop to rest",s);}this.prepareSpeech();}retarget(e){if(this.vmInstance=e,this.silenceProp=null,!e){for(let o of this.numberProps.keys())this.numberProps.set(o,null);return}let{format:t,shape:r}=qi(o=>{try{return e.number(o)!==null}catch{return !1}});this.formatName=t;for(let o of this.numberProps.keys())this.numberProps.set(o,e.number(this.formatName(o)));this.silenceProp=e.number(this.formatName(0)),E.debug(an,"bound to rig",{viewModelName:e.viewModelName??"unknown",visemeNameShape:r,silencePropFound:!!this.silenceProp,trackedIds:this.numberProps.size});}detach(){this.retarget(null);}prepareSpeech(){this.silencing=false;}appendVisemes(e){for(let t of e)if(t.visemeId!==0&&!this.numberProps.has(t.visemeId)){let r=this.vmInstance?.number(this.formatName(t.visemeId))??null;this.numberProps.set(t.visemeId,r),this.currentValues.set(t.visemeId,0);try{r&&(r.value=0);}catch{}}this.visemes.push(...e),this.visemes.sort((t,r)=>t.start-r.start),this.pruneSpentVisemes(),E.debug(an,"appendVisemes",{newCount:e.length,totalVisemes:this.visemes.length,trackedIds:Array.from(this.numberProps.keys()),nullProps:Array.from(this.numberProps.entries()).filter(([,t])=>!t).map(([t])=>t)});}clearVisemes(){this.visemes=[],this.lastActiveTime=pn;}pruneSpentVisemes(){if(this.visemes.length<=Tp||!this.clock||!this.clock.isLive())return;let e=this.clock.getAlignmentTime()-C0;if(e<=0)return;let t=0;for(;t<this.visemes.length&&this.visemes[t].end<e;)t++;t=Math.min(t,this.visemes.length-Tp),t>0&&this.visemes.splice(0,t);}start(){this.running||(this.running=true,this.lastTickTime=0,this.prepareSpeech(),E.debug(an,"start"),this.tick());}stop(){if(this.running){this.running=false,E.debug(an,"stop"),this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null);for(let e of this.numberProps.values())try{e&&(e.value=0);}catch{}try{this.silenceProp&&(this.silenceProp.value=this.tuning.rest);}catch{}this.visemes=[],this.numberProps.clear(),this.currentValues.clear(),this.silenceProp=null,this.vmInstance=null,this.clock=null,this.lastTickTime=0,this.silencing=false;}}interrupt(){if(this.running){this.running=false,E.debug(an,"interrupt"),this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null);for(let e of this.numberProps.values())try{e&&(e.value=0);}catch{}try{this.silenceProp&&(this.silenceProp.value=this.tuning.rest);}catch{}this.visemes=[],this.numberProps.clear(),this.currentValues.clear(),this.silenceProp=null,this.vmInstance=null,this.clock=null,this.lastTickTime=0,this.silencing=false;}}forceSilence(){this.lastActiveTime=pn,this.silencing=true,E.debug(an,"forceSilence \u2014 jaw decaying naturally");}};var tc=25,x0=.8,R0=.003,P0=300,kp=.7,ja=class{constructor(e,t){this.alignmentBaseCtxTime=null;this.scheduleCursor=0;this.timeline=new Ki;this.decodedQueue=[];this.activeSources=new Set;this.pendingDecodes=0;this.schedulerTimer=null;this.interrupted=false;this.drainTimer=null;this.muted=false;this.paused=false;this.ownsContext=!t,this.ctx=t??new AudioContext,this.gain=this.ctx.createGain(),this.gain.gain.value=kp,this.analyser=this.ctx.createAnalyser(),this.analyser.fftSize=512,this.analyserBuf=new Float32Array(this.analyser.fftSize),this.gain.connect(this.analyser),this.analyser.connect(this.ctx.destination),this.onEnded=e,this.warm(),this.startScheduler();}warm(){try{this.ctx.state==="suspended"&&this.ctx.resume().catch(()=>{});let e=this.ctx.createBuffer(1,1,this.ctx.sampleRate),t=this.ctx.createBufferSource();t.buffer=e,t.connect(this.ctx.destination),t.start();}catch{}}setMuted(e){if(this.muted=e,this.ctx.state==="closed")return;let t=e?0:kp,r=this.ctx.currentTime;try{this.gain.gain.cancelScheduledValues(r),this.gain.gain.setValueAtTime(this.gain.gain.value,r),this.gain.gain.linearRampToValueAtTime(t,r+.02);}catch{this.gain.gain.value=t;}}isMuted(){return this.muted}playBeep(){if(this.ctx.state!=="closed")try{let e=this.ctx.currentTime,t=this.ctx.createOscillator(),r=this.ctx.createGain();t.frequency.value=cl,r.gain.setValueAtTime(0,e),r.gain.linearRampToValueAtTime(Yo,e+Ko),r.gain.setValueAtTime(Yo,e+_i-Ko),r.gain.linearRampToValueAtTime(0,e+_i),t.connect(r),r.connect(this.gain),t.onended=()=>r.disconnect(),t.start(e),t.stop(e+_i);}catch(e){E.warn("TtsPlayer","beep failed",{err:e});}}enqueueChunk(e,t){if(this.drainTimer&&(clearTimeout(this.drainTimer),this.drainTimer=null),this.ctx.state!=="closed"){this.pendingDecodes++;try{this.decodeBase64(e).then(r=>{this.ctx.state!=="closed"&&(this.decodedQueue.push({buffer:r,alignmentStart:t}),this.decodedQueue.sort((o,s)=>o.alignmentStart-s.alignmentStart));}).catch(()=>{}).finally(()=>this.settleDecode());}catch{this.settleDecode();}}}enqueueSequentialChunk(e){this.drainTimer&&(clearTimeout(this.drainTimer),this.drainTimer=null),this.ctx.state!=="closed"&&(this.pendingDecodes++,this.decodeBase64(e).then(t=>{this.ctx.state!=="closed"&&this.decodedQueue.push({buffer:t,alignmentStart:1/0});}).catch(()=>{}).finally(()=>this.settleDecode()));}settleDecode(){this.pendingDecodes>0&&this.pendingDecodes--,this.maybeArmDrain();}hasPendingAudio(){return this.activeSources.size>0||this.decodedQueue.length>0||this.pendingDecodes>0}maybeArmDrain(){this.interrupted||this.hasPendingAudio()||(this.drainTimer&&clearTimeout(this.drainTimer),this.drainTimer=window.setTimeout(()=>{this.drainTimer=null,!this.interrupted&&!this.hasPendingAudio()&&this.onEnded?.();},P0));}async decodeBase64(e){let t=atob(e),r=new Uint8Array(t.length);for(let o=0;o<t.length;o++)r[o]=t.charCodeAt(o);return this.ctx.decodeAudioData(r.buffer)}startScheduler(){let e=()=>{if(this.interrupted||this.ctx.state==="closed")return;if(this.paused){this.schedulerTimer=window.setTimeout(e,tc);return}let t=this.ctx.currentTime,r=false,o=false;if(this.alignmentBaseCtxTime===null){let s=this.decodedQueue[0];if(!s){this.schedulerTimer=window.setTimeout(e,tc);return}let u=s.alignmentStart===1/0?0:s.alignmentStart;this.alignmentBaseCtxTime=t+.1-u,this.scheduleCursor=t+.1,r=true,E.debug("TtsPlayer","alignment clock anchored",{headStart:u,bufferDuration:s.buffer.duration,outputLatency:this.ctx.outputLatency??null,baseLatency:this.ctx.baseLatency??null,queuedChunks:this.decodedQueue.length,ctxState:this.ctx.state});}for(;this.decodedQueue.length>0&&(this.decodedQueue[0].alignmentStart===1/0||this.alignmentBaseCtxTime+this.decodedQueue[0].alignmentStart<t+x0);){let{buffer:s,alignmentStart:u}=this.decodedQueue.shift(),p;u===1/0?p=this.scheduleCursor:(p=this.alignmentBaseCtxTime+u,p<t+.02&&this.activeSources.size===0&&(this.scheduleCursor>0&&t-this.scheduleCursor<1&&E.warn("TtsPlayer","Playback stalled, realigning",{lateBySec:Number((t-p).toFixed(3))}),this.alignmentBaseCtxTime=t+.1-u,p=this.alignmentBaseCtxTime+u,r=true,this.timeline.reanchor()),Math.abs(p-this.scheduleCursor)<.1?p=this.scheduleCursor:p=Math.max(p,this.scheduleCursor)),this.timeline.schedule(p,s.duration,u===1/0?void 0:u),E.debug("TtsPlayer","chunk placed",{alignmentStart:u===1/0?null:u,startAt:Number(p.toFixed(3)),movedBySec:u===1/0?null:Number((p-(this.alignmentBaseCtxTime+u)).toFixed(3)),bufferDuration:Number(s.duration.toFixed(3))});let h=this.ctx.createBufferSource();h.buffer=s;let A=this.ctx.createGain();if(h.connect(A),A.connect(this.gain),p>this.scheduleCursor+.001){let y=Math.min(R0,s.duration/2);A.gain.setValueAtTime(0,p),A.gain.linearRampToValueAtTime(1,p+y);}else A.gain.setValueAtTime(1,p);h.start(p),this.scheduleCursor=p+s.duration,this.activeSources.add(h),o=true,h.onended=()=>{this.activeSources.delete(h),this.activeSources.size===0&&this.emitTimeline(),this.maybeArmDrain();};}(r||o)&&this.emitTimeline(),this.schedulerTimer=window.setTimeout(e,tc);};e();}getAlignmentTime(){return this.timeline.timeAt(this.ctx.currentTime-(this.ctx.outputLatency||0))}getPlayableAlignmentTime(){return this.timeline.playableTime()}getOutputLevel(){if(this.ctx.state==="closed")return 0;try{this.analyser.getFloatTimeDomainData(this.analyserBuf);}catch{return 0}let e=0;for(let t=0;t<this.analyserBuf.length;t++)e+=this.analyserBuf[t]*this.analyserBuf[t];return Math.sqrt(e/this.analyserBuf.length)}isAudioActive(){return this.activeSources.size>0||this.decodedQueue.length>0}isPlaybackScheduled(){return this.activeSources.size>0}pause(){this.paused||this.interrupted||this.ctx.state!=="closed"&&(this.paused=true,this.emitTimeline(),this.ctx.suspend().catch(()=>{}).then(()=>this.emitTimeline()));}isPaused(){return this.paused}resume(){this.paused&&this.ctx.state!=="closed"&&(this.paused=false,this.ctx.resume().catch(()=>{}).then(()=>this.emitTimeline()));}interrupt(){this.interrupted=true,this.paused=false,this.drainTimer&&(clearTimeout(this.drainTimer),this.drainTimer=null);for(let e of this.activeSources)try{e.stop();}catch{}this.activeSources.clear(),this.decodedQueue.length=0,this.pendingDecodes=0,this.alignmentBaseCtxTime=null,this.scheduleCursor=0,this.timeline.reset(),this.schedulerTimer&&(clearTimeout(this.schedulerTimer),this.schedulerTimer=null),this.emitTimeline();}emitTimeline(){try{this.onTimeline?.();}catch{}}destroy(){let e=this.paused;this.interrupt();try{this.gain.disconnect(),this.analyser.disconnect();}catch{}if(this.ownsContext){try{this.ctx.state!=="closed"&&this.ctx.close().catch(()=>{});}catch{}return}(e||this.ctx.state==="suspended")&&this.ctx.resume().catch(()=>{});}};var I0=({label:n="Connecting",className:e,style:t})=>jsxs("div",{className:`af-loader ${e??""}`,style:t,role:"status","aria-live":"polite","aria-label":`${n}\u2026`,children:[jsx("span",{className:"af-loader__orb","aria-hidden":"true"}),jsx("span",{className:"af-loader__letters","aria-hidden":"true",children:Array.from(n).map((r,o)=>jsx("span",{className:"af-loader__letter",style:{animationDelay:`${o*.1}s`},children:r.trim()===""?"\xA0":r},`${r}-${o}`))})]}),to=I0;var zp=vi(ic());var Bp=vi(ic());var uy=6e4,dy=3,Ka="Renderer",Fp=false,Zn=0,ro="live",oc=0,no=[],Up=new Set,ac=new WeakMap,sc=new WeakMap,lc=new Set,cc=new Set,uc=()=>{for(let n of lc)n();},dc=n=>{for(let e of cc)try{e(n);}catch(t){E.error(Ka,"renderer event listener threw",t);}},fy=(n,e)=>!n.isConnected&&n.width===1&&n.height===1&&typeof e=="object"&&e!==null&&"renderViaOffscreenBackBuffer"in e,py=()=>{let n=Bp.RuntimeLoader;return typeof n.isLoading!="boolean"||!("runtime"in n)?false:(n.runtime=void 0,n.isLoading=false,true)},hy=n=>{for(;no.length>0&&n-no[0]>uy;)no.shift();return no.length>=dy?false:(no.push(n),true)},my=n=>{if(!Up.delete(n)||ro==="unrecoverable")return;let e=`${n.width}x${n.height}`;oc=performance.now(),E.event(Ka,"shared context lost",{generation:Zn,surface:e}),dc({type:"lost",generation:Zn,surface:e});let t=hy(oc)?py()?null:"runtime-unsupported":"loss-storm";if(t){E.error(Ka,"shared context unrecoverable",{generation:Zn,reason:t}),ro="unrecoverable",dc({type:"unrecoverable",generation:Zn,reason:t}),uc();return}Zn+=1,ro="recovering",uc();},gy=(n,e)=>{if(ac.set(n,e),Up.add(n),n.addEventListener("webglcontextlost",()=>my(n),{once:true}),ro!=="recovering")return;let t=Math.round(performance.now()-oc);E.event(Ka,"shared context rebuilt",{generation:Zn,recoveryMs:t}),ro="live",dc({type:"recovered",generation:Zn,recoveryMs:t}),uc();};function qa(){if(Fp||typeof HTMLCanvasElement>"u")return;Fp=true;let n=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=function(t,r){let o=n.call(this,t,r);return t==="webgl2"&&o&&!ac.has(this)&&fy(this,r)&&gy(this,o),o};let e=CanvasRenderingContext2D.prototype.drawImage;CanvasRenderingContext2D.prototype.drawImage=function(...t){let r=t[0],o=r instanceof HTMLCanvasElement?ac.get(r):void 0;o?.isContextLost()||(o&&sc.set(this.canvas,(sc.get(this.canvas)??0)+1),e.apply(this,t));};}var Vp=()=>Zn;var Wp=n=>sc.get(n)??0;function Hp(n){return lc.add(n),()=>{lc.delete(n);}}function Xa(n){return cc.add(n),()=>{cc.delete(n);}}var vy=({src:n,artboard:e,stateMachine:t,autoBind:r,layout:o,onReady:s,onLoadError:u})=>{useEffect(()=>qa(),[]);let p=useRef(s);p.current=s;let h=useRef(u);h.current=u;let{rive:A,RiveComponent:y}=(0, zp.useRive)({src:n,autoplay:true,autoBind:r,useOffscreenRenderer:true,layout:o,...e&&{artboard:e},...t&&{stateMachines:t},onLoadError:b=>h.current(b instanceof Error?b:new Error("Rive load failed"))});return useEffect(()=>{A&&p.current(A);},[A]),jsx(y,{className:"rive-renderer-canvas"})},Yp=vy;var fc=(n,e,t)=>{for(let r of e){for(let[o,s]of Object.entries(r.properties))try{if(typeof s=="boolean"){let u=n.boolean(o);u?(u.value=s,t&&E.debug("Renderer",`data-binding: set ${r.name}.${o} = ${s} (boolean)`)):t&&E.error("Renderer",`data-binding: boolean prop "${o}" not found on ${r.name}`);}else if(typeof s=="number"){let u=n.number(o);if(u)u.value=s,t&&E.debug("Renderer",`data-binding: set ${r.name}.${o} = ${s} (number)`);else {let p=n.color(o);p?(p.value=s,t&&E.debug("Renderer",`data-binding: set ${r.name}.${o} = ${s} (color)`)):t&&E.error("Renderer",`data-binding: prop "${o}" not found as number or color on ${r.name}`);}}else if(typeof s=="string"){let u=n.string(o);if(u)u.value=s,t&&E.debug("Renderer",`data-binding: set ${r.name}.${o} = ${s} (string)`);else {let p=n.enum(o);p?(p.value=s,t&&E.debug("Renderer",`data-binding: set ${r.name}.${o} = ${s} (enum)`)):t&&E.error("Renderer",`data-binding: prop "${o}" not found as string or enum on ${r.name}`);}}}catch(u){t&&E.error("Renderer",`data-binding: exception setting ${r.name}.${o}`,u);}t&&E.debug("Renderer","data-binding: appearance overrides applied",{name:r.name});}};function Kp(){return useSyncExternalStore(Hp,Vp,()=>0)}var _y=3,wy=250,Sy=(n,e)=>{let t=n?.querySelector("canvas"),r=e?.getContext("2d");return !t||!e||!r||!t.width||!t.height?false:(e.width=t.width,e.height=t.height,r.drawImage(t,0,0),e.hidden=false,true)},Ey=n=>{n&&(n.hidden=true,n.width=0,n.height=0);};function Xp(n,e,t){let r=useRef(false);useEffect(()=>(qa(),Xa(o=>{o.type!=="lost"||r.current||(r.current=Sy(n.current,e.current));})),[n,e]),useEffect(()=>{if(!t||!r.current)return;let o=_y,s=-1,u=0,p=requestAnimationFrame(function h(A){let y=n.current?.querySelector("canvas"),b=y?Wp(y):0;b>s&&(s>=0&&(o-=1),b>0&&!u&&(u=A),s=b);let m=u>0&&A-u>=wy;if(o>0&&!m){p=requestAnimationFrame(h);return}Ey(e.current),r.current=false;});return ()=>cancelAnimationFrame(p)},[t,n,e]);}var Ty=120,ky=8,Qp=()=>jsx("div",{className:"rive-renderer-loader",children:jsx(to,{label:"Loading"})}),$p=()=>jsxs("div",{className:"rive-renderer-error",children:[jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"8",r:"3.5"}),jsx("path",{d:"M5 20c0-3.9 3.1-7 7-7s7 3.1 7 7"}),jsx("line",{x1:"17",y1:"17",x2:"21",y2:"21"}),jsx("line",{x1:"21",y1:"17",x2:"17",y2:"21"})]}),jsx("span",{className:"rive-renderer-error-text",children:"Avatar unavailable"})]}),Cy=({lastResponse:n,onPlaybackEnd:e,className:t,style:r,onRiveReady:o,onRiveError:s,resetToken:u,avatarConfig:p,error:h,loader:A,errorFallback:y,shouldArmTalking:b,isConnected:m,userActivity:S,userAttending:C,isThinking:I,thinkingSignal:L,gestureQueue:B,gestureSignal:W,onAvatarClick:Q,lipSyncTuning:Z,visualState:$,onSpeechClock:oe,speakerMuted:J,onRegisterPlaybackControls:H,getAudioContext:de,createSpeechPlayer:te,fit:xe,environment:Se,rigActivity:ue})=>{let Ie=Se==="meeting",[ae,G]=useState(false),[z,P]=useState(false),[N,U]=useState(null),q=Kp(),se=xe?{...p?.rive?.layout||{},fit:xe}:p?.rive?.layout||null,Re=Fa(se,p?.rive?.watermark),Pe=Number(p?.lipSync?.visemeMs)||40,we=(p?.pipelineMode??"input")==="data-binding",ve=useRef(o);ve.current=o;let De=useRef(s);De.current=s;let Xe=useCallback(Y=>{U(Y),G(true),ve.current?.();},[]),qe=useCallback(Y=>{E.error("Renderer","Failed to load Avatar file",Y),P(true),De.current?.(Y);},[]),ee=useRef(null),fe=useRef(null),Fe=useRef(null);Xp(fe,Fe,N);let ye=useRef(null),pe=useRef(null),Ue=useRef(te??((Y,Ae)=>new ja(Y,Ae))),We=useRef([]),Ve=useRef(null),rt=useRef(0),st=useRef(0),et=useRef(null),tt=useRef(null),He=useRef(Y=>`${Y}`),le=useRef(false);le.current=!!b;let g=useRef(false);g.current=!!m,useEffect(()=>{pe.current?.setMuted(!!J);},[J]);let l=$==="expired",f=useRef(false);f.current=l;let w=useRef(oe);w.current=oe;let T=useCallback(Y=>{w.current?.(Y);},[]),R=useRef(de);R.current=de;let V=useRef(H);V.current=H,useEffect(()=>{let Y={pause:()=>pe.current?.pause(),resume:()=>pe.current?.resume(),getOutputLevel:()=>pe.current?.getOutputLevel()??0,hasPendingAudio:()=>pe.current?.hasPendingAudio()??false,reset:()=>{fn(),ye.current instanceof Ar?ye.current.interrupt():ye.current?.stop(),ye.current=null,pe.current?.destroy(),pe.current=null,T(null),rt.current=0,et.current=null,vt();}};return V.current?.(Y),()=>V.current?.(null)},[]);let re=useRef(null);re.current=N??null;let ke=useRef(void 0);ke.current=p?.rive?.stateMachine;let ie=useRef(we);ie.current=we,useEffect(()=>Xa(Y=>{Y.type==="lost"&&(ue?.detach(),ye.current?.detach(),re.current?.stopRendering(),re.current=null,tt.current=null,U(null));}),[ue]);let _e=useCallback((Y,Ae)=>{try{if(ie.current){let Je=tt.current,St=typeof Ae=="boolean"?Je?.boolean(Y):Je?.number(Y);return St?(St.value=Ae,!0):!1}let Te=re.current;if(!Te)return !1;let Be=mn(Te,ke.current).inputs.find(Je=>Je.name===Y);return Be?(Be.value=Ae,!0):!1}catch{return false}},[]),nt=useCallback((Y,Ae)=>{let Te=_e(Y,Ae);return (ie.current?tt.current:re.current)&&ue?.reportWrite(Y,Ae,Te),Te},[_e,ue]),Qe=useRef(null),Ge=useCallback(()=>(Qe.current||(Qe.current=new zi(nt)),Qe.current),[nt]),gt=useRef(null),Tt=useRef({has:()=>false,fire:()=>{}}),Ye=useCallback(()=>(gt.current||(gt.current=new ji((Y,Ae)=>Ge().setMode(Y,Ae),{},Y=>Ge().cycle(Y),Y=>Ge().has(Y),{has:Y=>Tt.current.has(Y),fire:Y=>Tt.current.fire(Y)})),gt.current),[Ge]),kt=useCallback(()=>{Ye().busy(),Ge().setMode("talking");},[Ye,Ge]),vt=useCallback(()=>{Ye().rest(g.current);},[Ye]),At=useCallback(Y=>Y==="talking"?kt():Ye().resume(g.current),[kt,Ye]);useEffect(()=>()=>gt.current?.dispose(),[]);let Me=p?.performance??null,dn=useRef(null);useEffect(()=>{if(dn.current===Me||(dn.current=Me,Ge().setPolicy(Me),!Me))return;let Y=Ye();Y.configure(Me),Y.current==="busy"?Ge().setMode("talking"):Y.resume(g.current);},[Me,Ge,Ye]),useEffect(()=>{L&&Ye().think();},[L,Ye]),useEffect(()=>{I||Ye().stopThinking();},[I,Ye]),useEffect(()=>{S&&Ye().userActivity();},[S,Ye]),useEffect(()=>{Ye().setAttending(!!C);},[C,Ye]);let Gt=useCallback(()=>g.current?"listening":"idle",[]),x=useCallback(()=>pe.current?.isAudioActive()||le.current?"talking":Gt(),[Gt]);useEffect(()=>{if(!N||!ae||!p||!we)return;E.debug("Renderer","data-binding: init start",{viewModelCount:N.viewModelCount,autoBindInstance:!!N.viewModelInstance});let Y=N.viewModelInstance;if(!Y){E.error("Renderer","data-binding: rive.viewModelInstance is null after autoBind \u2014 check the .riv file has a ViewModel");return}tt.current=Y;let{format:Ae,shape:Te,matched:Be}=qi(Ke=>{try{return Y.number(Ke)!==null}catch{return !1}});He.current=Ae,Be?E.debug("Renderer","data-binding: viseme naming detected",{shape:Te}):E.error("Renderer","data-binding: no viseme props found on the rig \u2014 lip-sync will not move");let Je=x();Je==="talking"&&E.debug("Renderer","data-binding: VM bound mid-turn \u2014 entering talking"),At(Je);let St=p.rive.viewModel??[];fc(Y,St,true);let $e=requestAnimationFrame(()=>fc(Y,St,false));return ()=>cancelAnimationFrame($e)},[N,ae,p,we]),useEffect(()=>{!N||!ae||we||At(x());},[N,ae,we,At,x]),useEffect(()=>{if(!N||!ae||!p)return;let Y=p.rive.watermark?1:0;try{if(we){let Ae=N.viewModelInstance?.number(va);Ae&&(Ae.value=Y);}else {let{inputs:Ae}=mn(N,p.rive?.stateMachine),Te=Ae.find(Be=>Be.name===va);Te&&(Te.value=Y);}}catch(Ae){E.error("Renderer","failed to set Watermark_opacity",Ae);}},[N,ae,p,we]),useEffect(()=>{if(!N||!ae)return;let Y=ye.current;Y instanceof Ar?Y.retarget(tt.current):Y&&Y.retarget(N,p?.rive?.stateMachine),Qe.current?.reapply();},[N,ae]);let Zt=p?.rive?.stateMachine;useEffect(()=>{if(!N||!ae||!ue)return;let Y=we?"data-binding":"input",Ae=requestAnimationFrame(()=>{Ae=requestAnimationFrame(()=>ue.attach({rive:N,binding:Y,stateMachine:Zt}));});return ()=>{cancelAnimationFrame(Ae),ue.detach();}},[N,ae,we,Zt,ue]),useEffect(()=>{b&&(kt(),E.debug("Renderer","arming talking branch ahead of audio"));},[b,kt]),useEffect(()=>{pe.current?.isAudioActive()||m&&le.current||(m?Ye().connect():vt());},[m,vt,Ye]);let Dn=useCallback(Y=>{let Ae=re.current;if(!Ae)return;let{input:Te,type:Be,value:Je,binding:St,resetMs:$e}=Yi(Y,p?.rive?.gestures,we);E.debug("Renderer","gesture: firing",{name:Y,input:Te,type:Be,binding:St}),ue?.reportGesture(Y,Te);try{if(St==="data-binding"){let Ke=tt.current;if(!Ke)return;if(Be==="trigger")Ke.trigger(Te)?.trigger();else if(Be==="boolean"){let lt=Ke.boolean(Te);lt&&(lt.value=Je!==0,$e&&setTimeout(()=>{let ct=tt.current?.boolean(Te);ct&&(ct.value=!1);},$e));}else {let lt=Ke.number(Te);lt&&(lt.value=Je);}}else {let{name:Ke,inputs:lt}=mn(Ae,p?.rive?.stateMachine),ct=lt.find(it=>it.name===Te);if(!ct)return;Be==="trigger"?(ct.fire(),ue?.reportTrigger(Te)):Be==="boolean"?(ct.value=Je!==0,$e&&setTimeout(()=>{let it=(Ke?re.current?.stateMachineInputs(Ke):null)?.find(Pt=>Pt.name===Te);it&&(it.value=!1);},$e)):ct.value=Je;}}catch(Ke){E.error("Renderer",`gesture: failed to fire "${Y}"`,Ke);}},[p,we,ue]),jt=useCallback(Y=>{let Ae=re.current;if(!Ae)return false;let{input:Te,type:Be,binding:Je}=Yi(Y,p?.rive?.gestures,we);if(Be!=="trigger")return false;try{if(Je==="data-binding")return !!tt.current?.trigger(Te);let{inputs:St}=mn(Ae,p?.rive?.stateMachine);return St.some($e=>$e.name===Te)}catch{return false}},[p,we]);Tt.current={has:jt,fire:Dn};let fn=useCallback(()=>{for(let Y of We.current)Y();We.current=[];},[]),me=useCallback(Y=>{let{name:Ae,atMs:Te,speechless:Be}=Y,Je=()=>{Y.beep?pe.current?.playBeep():Dn(Ae);};if(Te==null){E.debug("Renderer","gesture: scheduling",{name:Ae,mode:"immediate"}),Je();return}let St=!!pe.current?.isAudioActive(),$e=Be==null?St:!Be;E.debug("Renderer","gesture: scheduling",{name:Ae,atMs:Te,speechless:Be,audioActive:St,mode:$e?"alignment":"delay"});let Ke={cancel:()=>{}},lt=()=>{We.current=We.current.filter(ct=>ct!==Ke.cancel);};if($e){let ct=Te/1e3,it=requestAnimationFrame(function Pt(){let _n=pe.current;if(_n){if(_n.getAlignmentTime()>=ct){E.debug("Renderer","gesture: firing (alignment reached)",{name:Ae,atMs:Te,alignmentMs:Math.round(_n.getAlignmentTime()*1e3)}),lt(),Je();return}it=requestAnimationFrame(Pt);}});Ke.cancel=()=>cancelAnimationFrame(it);}else {let ct=window.setTimeout(()=>{E.debug("Renderer","gesture: firing (delay elapsed)",{name:Ae,atMs:Te}),lt(),Je();},Te);Ke.cancel=()=>clearTimeout(ct);}We.current.push(Ke.cancel);},[Dn]);useEffect(()=>{if(!N||!ae)return;let Y=B?.current;if(!Y||Y.length===0)return;let Ae=Y.splice(0,Y.length);for(let Te of Ae)me(Te);},[W,N,ae,B,me]),useEffect(()=>fn,[fn]);let zt=useCallback(()=>{let Y=pe.current;if(!Y)return Xs;let Ae=Z?.offsetSec??0;return Math.min(Y.getAlignmentTime()+Ae,Y.getPlayableAlignmentTime()+Ae+.5)},[Z]),Fn=useCallback(()=>!!pe.current?.isPlaybackScheduled(),[]),rr=useCallback(async()=>{if(!ae||!n)return;let{audioChunks:Y,alignments:Ae,sessionId:Te,jobId:Be,chunkOffset:Je}=n;if(kt(),et.current!==Be&&(et.current!==null&&(ye.current?.clearVisemes(),ye.current instanceof Ar&&ye.current.prepareSpeech()),rt.current=0),et.current=Be,Ve.current!==Te&&(E.debug("Renderer","new epoch \u2192 reset audio + lipsync"),ye.current?.stop(),ye.current=null,pe.current?.destroy(),pe.current=null,T(null),Ve.current=Te,rt.current=0),!ye.current||!pe.current){ye.current&&(ye.current.stop(),ye.current=null),E.debug("Renderer","init audio + lipsync"),pe.current||(pe.current=Ue.current(()=>{let Ke=e?.()===true;ye.current?.clearVisemes(),ye.current?.forceSilence(),Ke&&g.current?Ye().restThinking():vt();},R.current?.()??null),pe.current.setMuted(!!J),T(()=>pe.current?.isPlaybackScheduled()?pe.current.getAlignmentTime():null));let $e=p?.pipelineMode??"input";if(E.debug("Renderer","engine selection",{pipelineMode:$e,lipSyncVmReady:!!tt.current}),$e==="data-binding"){let Ke=tt.current;if(!Ke&&N){E.error("Renderer","data-binding: lip-sync ViewModel not initialized \u2014 was bindViewModelInstance called before first speak?");return}let lt=new Ar;lt.initialize(Ke,{getAlignmentTime:zt,isLive:Fn},Z),ye.current=lt;}else {let Ke=new Wa;Ke.initialize(N,{getAlignmentTime:zt,isLive:Fn},p?.rive?.stateMachine,Z),ye.current=Ke;}ye.current.start();}Je>rt.current&&E.error("Renderer","gap in TTS chunks \u2014 a speak batch was dropped",{expected:rt.current,got:Je,jobId:Be});let St=Math.max(0,rt.current-Je);for(let $e=St;$e<Y.length;$e++){let Ke=Y[$e],lt=Ae[$e];if(rt.current=Je+$e+1,!Ke)continue;if(!lt){pe.current.enqueueSequentialChunk(Ke),E.debug("Renderer","appended sequential (no-alignment) chunk",{index:Je+$e});continue}let ct=lt.character_start_times_seconds[0]??0,it=n.visemes?.[$e]??Xo(lt,Pe);if(pe.current.enqueueChunk(Ke,ct),ye.current.appendVisemes(it),E.debug("Renderer","appended chunk",{alignmentStart:ct,firstViseme:it[0],lastViseme:it[it.length-1],alignmentNow:pe.current.getAlignmentTime()}),n.isGreeting){let Pt=lt.character_end_times_seconds;E.event("Renderer","greeting chunk queued",{chunkIndex:Je+$e,totalChunks:Y.length,alignmentStart:ct,alignmentSpan:Pt?.[Pt.length-1]??null,chars:lt.characters?.length??0,visemeCount:it.length,firstVisemeStart:it[0]?.start??null,clockAtQueue:pe.current.getAlignmentTime()});}}},[n,N,ae,e,Pe,p,we,kt,vt,Ye,T,zt,Fn,Z]),Kt=()=>{fn(),ye.current?.stop(),ye.current=null,pe?.current?.destroy(),pe.current=null,T(null),Qe.current?.stop(),Ve.current=null,rt.current=0,et.current=null,vt();};useEffect(()=>{if(!N)return;let Y=()=>{N&&(N.layout=Fa(se,p?.rive?.watermark),N.resetArtboardSize?.());};return N.on(io.EventType.Load,Y),N?.isPlaying&&Y(),()=>{N.off(io.EventType.Load,Y);}},[N]),useEffect(()=>{if(!N)return;let Y=Ae=>{if(Array.isArray(Ae.data))for(let Te of Ae.data)typeof Te=="string"&&Ye().rigEntered(Te);};return N.on(io.EventType.StateChange,Y),()=>N.off(io.EventType.StateChange,Y)},[N,Ye]),useEffect(()=>{N&&(N.layout=Fa(se,p?.rive?.watermark));},[N,xe,p]),useEffect(()=>{let Y=ee.current;if(!Y||!N)return;let Ae=0,Te=null,Be=()=>{let $e=Y.querySelector(".rive-renderer-canvas > canvas");if(!$e)return;let Ke=$e.clientWidth;if(!Ke)return;let lt=$e.getBoundingClientRect(),ct=lt.width/Ke;if(!ct||!isFinite(ct))return;let Pt=(Ie?1:window.devicePixelRatio||1)/ct;$e.width===Math.trunc(Pt*lt.width)&&$e.height===Math.trunc(Pt*lt.height)||N.resizeDrawingSurfaceToCanvas?.(Pt);},Je=()=>{Te&&clearTimeout(Te),Te=setTimeout(()=>{cancelAnimationFrame(Ae),Ae=requestAnimationFrame(Be);},Ty);},St=new ResizeObserver(Je);return St.observe(Y),Ae=requestAnimationFrame(Be),()=>{Te&&clearTimeout(Te),cancelAnimationFrame(Ae),St.disconnect();}},[N,Ie]),useEffect(()=>{if(n&&ae&&rr(),!n&&N){if((p?.pipelineMode??"input")==="data-binding"){let Ae=tt.current;if(Ae){for(let Te=1;Te<=21;Te++)try{let Be=Ae.number(He.current(Te));Be&&(Be.value=0);}catch{}try{let Te=Ae.number(He.current(0));Te&&(Te.value=100);}catch{}}}else {let{inputs:Ae}=mn(N,p?.rive?.stateMachine);Ae.forEach(Te=>{let Be=hr(Te.name);Be!==null&&(Te.value=Be===0?100:0);});}f.current||(le.current?kt():vt());}},[N,ae,n,rr,p,b]),useEffect(()=>()=>{try{Kt();}catch(Y){E.error("Renderer","Reset failed",Y);}},[]),useEffect(()=>{u!==st.current&&(st.current=u,Kt());},[u]);let bn=useRef(null);if(!p)return jsx("div",{className:`rive-renderer-root ${h?.fatal?"":"rive-renderer-root--loading"} ${t??""}`,style:r,children:h?.fatal?y??jsx($p,{}):A??jsx(Qp,{})});let Er=Q&&ae?{onPointerDown:Y=>{bn.current={x:Y.clientX,y:Y.clientY};},onClick:Y=>{let Ae=bn.current;bn.current=null,!(!Ae||Math.hypot(Y.clientX-Ae.x,Y.clientY-Ae.y)>ky)&&Q();}}:null,yn=!z&&!ae,Bn=z?y??jsx($p,{}):yn?A??jsx(Qp,{}):null;return jsxs("div",{className:`rive-renderer-root ${yn?"rive-renderer-root--loading":""} ${t??""}`,style:{...r,...l?{filter:"grayscale(1)",transition:"filter 600ms ease"}:null},children:[jsxs("div",{className:"rive-renderer-canvasWrapper",ref:ee,...Er,children:[jsx("div",{className:"rive-renderer-surface",ref:fe,children:jsx(Yp,{src:p.rive?.src,artboard:p.rive?.artboard,stateMachine:p.rive?.stateMachine,autoBind:we,layout:Re,onReady:Xe,onLoadError:qe},q)}),jsx("canvas",{ref:Fe,className:"rive-renderer-hold",hidden:true,"aria-hidden":"true"})]}),Bn]})},Jp=memo(Cy);var Iy=.08,Ly=6e3,th=n=>n.speaker==="avatar"&&!n.isFinal&&n.words.some(e=>e.end>0),Oy=({store:n,speechClockRef:e,position:t="bottom-center",controlsVisible:r,className:o,style:s})=>{let u=useSyncExternalStore(n.subscribe,n.getSnapshot,n.getServerSnapshot),p=r&&t.startsWith("bottom"),h=u.slice(-2),A=h.find(th)??null,[y,b]=useState(0),[m,S]=useState(false),C=useRef(null);C.current=A,useEffect(()=>{if(!A)return;b(0);let L=0,B=()=>{let W=C.current,Q=e.current?.();if(W&&Q!=null){let Z=Jo(W,Q+Iy);b($=>Z>$?Z:$);}L=requestAnimationFrame(B);};return L=requestAnimationFrame(B),()=>cancelAnimationFrame(L)},[A?.id,e]),useEffect(()=>{if(S(false),!u[u.length-1]?.isFinal)return;let B=setTimeout(()=>S(true),Ly);return ()=>clearTimeout(B)},[u]);let I=h.map(L=>({entry:L,wordCount:th(L)?Math.min(y,L.words.length):L.words.length})).filter(L=>L.wordCount>0);return I.length?jsx("div",{className:["avatar-captions",`avatar-captions--${t}`,p?"avatar-captions--raised":"",m?"avatar-captions--hidden":"",o??""].filter(Boolean).join(" "),style:s,role:"log","aria-live":"polite",children:I.map(({entry:L,wordCount:B},W)=>jsxs("p",{className:`avatar-captions-line avatar-captions-line--${L.speaker} ${W===I.length-1?"":"avatar-captions-line--past"}`,children:[L.speaker==="user"&&jsx("span",{className:"avatar-captions-tag",children:"You"}),L.words.slice(0,B).map((Q,Z)=>jsx("span",{className:`avatar-captions-word ${L.isFinal?"":"avatar-captions-word--interim"}`,children:Q.text},`${Z}-${Q.text}`))]},L.id))}):null},nh=Oy;var Fy={network:{title:"Your connection is unstable",detail:"Check your internet \u2014 audio may drop until it recovers."},device:{title:"Your device is struggling to keep up",detail:"Closing other tabs or apps should help."},service:{title:"Responses are running slow",detail:"It's on our side \u2014 replies may lag for a bit."}},By=({store:n,position:e="bottom-left",controlsVisible:t,className:r,style:o})=>{let u=useSyncExternalStore(n.subscribe,n.getSnapshot,n.getServerSnapshot).concern;if(!u||u.state!=="degraded")return null;let p=Fy[u.scope],h=t&&e.startsWith("bottom");return jsxs("div",{className:["avatar-status-banner",`avatar-status-banner--${e}`,`avatar-status-banner--${u.state}`,h?"avatar-status-banner--raised":"",r??""].filter(Boolean).join(" "),style:o,role:"status","aria-live":"polite",children:[jsx("span",{className:"avatar-status-banner-dot","aria-hidden":"true"}),jsxs("span",{className:"avatar-status-banner-text",children:[jsx("span",{className:"avatar-status-banner-title",children:p.title}),jsx("span",{className:"avatar-status-banner-detail",children:p.detail})]})]})},ih=By;var Uy=({visible:n,position:e="top-left",controlsVisible:t,className:r,style:o})=>{if(!n)return null;let s=t&&e.startsWith("bottom");return jsxs("div",{className:["avatar-thinking-indicator",`avatar-thinking-indicator--${e}`,s?"avatar-thinking-indicator--raised":"",r??""].filter(Boolean).join(" "),style:o,role:"status","aria-live":"polite","aria-label":"The avatar is thinking",children:[jsx("span",{className:"avatar-thinking-indicator-dot"}),jsx("span",{className:"avatar-thinking-indicator-dot"}),jsx("span",{className:"avatar-thinking-indicator-dot"})]})},oh=Uy;var ao=({size:n=22,children:e})=>jsx("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e}),$a=({muted:n,size:e})=>jsxs(ao,{size:e,children:[jsx("path",{d:"M12 1a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"}),jsx("path",{d:"M19 10v1a7 7 0 0 1-14 0v-1"}),jsx("line",{x1:"12",y1:"18",x2:"12",y2:"22"}),n&&jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"})]}),Ja=({muted:n,size:e})=>jsxs(ao,{size:e,children:[jsx("path",{d:"M11 5 6 9H2v6h4l5 4V5z"}),n?jsxs(Fragment,{children:[jsx("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),jsx("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]}):jsxs(Fragment,{children:[jsx("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]})]}),sh=({size:n})=>jsx(ao,{size:n,children:jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})}),Za=({size:n})=>jsx(ao,{size:n,children:jsx("path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"})}),es=({size:n})=>jsxs(ao,{size:n,children:[jsx("path",{d:"M10.68 13.31a16 16 0 0 0 3.41 2.6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7 2 2 0 0 1 1.72 2v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.42 19.42 0 0 1-3.33-2.67m-2.67-3.34a19.79 19.79 0 0 1-3.07-8.63A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91"}),jsx("line",{x1:"23",y1:"1",x2:"1",y2:"23"})]});var Wy=({isIdle:n,start:e,stop:t,className:r="",avatarReady:o,isMicMuted:s,isSpeakerMuted:u,setMicMuted:p,setSpeakerMuted:h,showStopSpeaking:A,isSpeaking:y,stopSpeaking:b})=>jsx("div",{className:`avatar-controls-root ${r}`,children:n?jsx("button",{type:"button",onClick:e,className:"avatar-controls-button avatar-controls-call","aria-label":"Start call",disabled:!o,children:jsx(Za,{})}):jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:()=>p(!s),className:`avatar-controls-button avatar-controls-mute${s?" avatar-controls-muted":""}`,"aria-label":s?"Unmute microphone":"Mute microphone","aria-pressed":s,children:jsx($a,{muted:s})}),jsx("button",{type:"button",onClick:()=>h(!u),className:`avatar-controls-button avatar-controls-mute${u?" avatar-controls-muted":""}`,"aria-label":u?"Unmute avatar audio":"Mute avatar audio","aria-pressed":u,children:jsx(Ja,{muted:u})}),A&&y&&jsx("button",{type:"button",onClick:b,className:"avatar-controls-button avatar-controls-stop-speaking","aria-label":"Stop the avatar from speaking",children:jsx(sh,{})}),jsx("button",{type:"button",onClick:t,className:"avatar-controls-button avatar-controls-hangup","aria-label":"End call",children:jsx(es,{})})]})}),lh=Wy;var Yy=n=>{let e=n;if(!e?.tagName)return false;let t=e.tagName.toLowerCase();return t==="input"||t==="textarea"||e.isContentEditable},Ky=({isTalking:n,isSpeaking:e,startTalking:t,stopTalking:r,spacebar:o,disabled:s=false})=>{let u=useRef({isTalking:n,startTalking:t,stopTalking:r,disabled:s});u.current={isTalking:n,startTalking:t,stopTalking:r,disabled:s};let p=n?"Listening":e?"Hold to interrupt":"Hold to talk",h=useCallback(y=>{s||y.button!==0||(y.currentTarget.setPointerCapture?.(y.pointerId),t());},[s,t]),A=useCallback(()=>r(),[r]);return useEffect(()=>{if(!o)return;let y=S=>{S.code!=="Space"||S.repeat||Yy(S.target)||u.current.disabled||(S.preventDefault(),u.current.startTalking());},b=S=>{S.code!=="Space"||!u.current.isTalking||(S.preventDefault(),u.current.stopTalking());},m=()=>{u.current.isTalking&&u.current.stopTalking();};return window.addEventListener("keydown",y),window.addEventListener("keyup",b),window.addEventListener("blur",m),()=>{window.removeEventListener("keydown",y),window.removeEventListener("keyup",b),window.removeEventListener("blur",m);}},[o]),jsxs("button",{type:"button",className:`avatar-ptt-button${n?" avatar-ptt-holding":""}`,disabled:s,"aria-label":p,"aria-pressed":n,onPointerDown:h,onPointerUp:A,onPointerCancel:A,onContextMenu:y=>y.preventDefault(),children:[jsx("span",{className:"avatar-ptt-halo","aria-hidden":"true"}),jsxs("span",{className:"avatar-ptt-face",children:[jsxs("svg",{className:"avatar-ptt-icon",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[jsx("path",{d:"M12 1a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"}),jsx("path",{d:"M19 10v1a7 7 0 0 1-14 0v-1"}),jsx("line",{x1:"12",y1:"18",x2:"12",y2:"22"})]}),jsx("span",{className:"avatar-ptt-label",children:p},p)]})]})},uh=Ky;var qy=({muted:n})=>jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M11 5 6 9H2v6h4l5 4V5z"}),n?jsxs(Fragment,{children:[jsx("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),jsx("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]}):jsxs(Fragment,{children:[jsx("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]})]}),Xy=({isIdle:n,start:e,stop:t,className:r="",avatarReady:o,isSpeakerMuted:s,setSpeakerMuted:u,isTalking:p,isSpeaking:h,startTalking:A,stopTalking:y,spacebar:b})=>n?jsx("div",{className:`avatar-ptt-root ${r}`,children:jsxs("button",{type:"button",onClick:e,className:"avatar-ptt-connect","aria-label":"Start call",disabled:!o,children:[jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:jsx("path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"})}),jsx("span",{children:"Connect"})]})}):jsxs("div",{className:`avatar-ptt-root ${r}`,children:[jsx("button",{type:"button",onClick:()=>u(!s),className:`avatar-ptt-secondary${s?" avatar-ptt-secondary-off":""}`,"aria-label":s?"Unmute avatar audio":"Mute avatar audio","aria-pressed":s,children:jsx(qy,{muted:s})}),jsx(uh,{isTalking:p,isSpeaking:h,startTalking:A,stopTalking:y,spacebar:b}),jsx("button",{type:"button",onClick:t,className:"avatar-ptt-secondary avatar-ptt-hangup","aria-label":"End call",children:jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M10.68 13.31a16 16 0 0 0 3.41 2.6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7 2 2 0 0 1 1.72 2v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.42 19.42 0 0 1-3.33-2.67m-2.67-3.34a19.79 19.79 0 0 1-3.07-8.63A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91"}),jsx("line",{x1:"23",y1:"1",x2:"1",y2:"23"})]})})]}),fh=Xy;var Ac=()=>jsx("span",{className:"avatar-pip-swap-hint","aria-hidden":"true",children:jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",children:jsx("path",{d:"M4 10V4h6M20 14v6h-6",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})})}),ph=()=>jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[jsx("path",{d:"M16 10.5V8a2 2 0 0 0-2-2H6.5M3 6.5V16a2 2 0 0 0 2 2h9M16 13.5l5 3.5V7l-5 3.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),jsx("path",{d:"M3 3l18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),Jy=()=>jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[jsx("rect",{x:"3",y:"6",width:"13",height:"12",rx:"2",stroke:"currentColor",strokeWidth:"2"}),jsx("path",{d:"M16 13.5l5 3.5V7l-5 3.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),Zy=({on:n})=>jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2"}),jsx("path",{d:"M8.5 14.5c.9 1.2 2.1 1.8 3.5 1.8s2.6-.6 3.5-1.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),jsx("path",{d:"M9 9.5h.01M15 9.5h.01",stroke:"currentColor",strokeWidth:"2.6",strokeLinecap:"round"}),!n&&jsx("path",{d:"M3 3l18 18",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),e_=({on:n,toggle:e})=>jsxs("button",{type:"button",role:"switch","aria-checked":n,"aria-label":"Detect mood",title:n?"Detect mood: on":"Detect mood: off",className:`avatar-camera-preview-mood${n?" on":""}`,onClick:e,children:[jsx(Zy,{on:n}),jsx("span",{className:"avatar-camera-preview-mood-label",children:"Detect mood"}),jsx("span",{className:"avatar-camera-preview-mood-track","aria-hidden":"true",children:jsx("span",{className:"avatar-camera-preview-mood-knob"})})]}),t_=({sessionOpen:n,stream:e,mirrored:t=true,corner:r="bottom-right",variant:o="corner",onSwap:s,onToggleVideo:u,onFlip:p,mood:h})=>{let A=useRef(null),y=e!==null;return useEffect(()=>{let b=A.current;b&&(b.srcObject=e,e&&b.play().catch(()=>{}));},[e]),n?jsxs("div",{className:`avatar-camera-preview ${o==="stage"?"stage":r}${y?"":" video-off"}${s?" swappable":""}`,...s&&{role:"button",tabIndex:0,"aria-label":"Show camera full size",onClick:s,onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),s());}},children:[y?jsx("video",{ref:A,className:`avatar-camera-preview-video${t?" mirrored":""}`,playsInline:true,muted:true,autoPlay:true}):jsxs("div",{className:"avatar-camera-preview-off","aria-label":"Video off",children:[jsx(ph,{}),jsx("span",{children:"Video off"})]}),s&&jsx(Ac,{}),jsxs("div",{className:"avatar-camera-preview-actions",onClick:b=>b.stopPropagation(),children:[h&&y&&jsx(e_,{on:h.on,toggle:h.toggle}),p&&y&&jsx("button",{type:"button",className:"avatar-camera-preview-btn",onClick:p,title:"Switch camera","aria-label":"Switch camera",children:jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[jsx("path",{d:"M4 8a6 6 0 0 1 10-4.5M20 16a6 6 0 0 1-10 4.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),jsx("path",{d:"M4 4v4h4M20 20v-4h-4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),u&&jsx("button",{type:"button",className:`avatar-camera-preview-btn${y?"":" off"}`,onClick:u,title:y?"Turn off video":"Turn on video","aria-label":y?"Turn off video":"Turn on video","aria-pressed":!y,children:y?jsx(ph,{}):jsx(Jy,{})})]})]}):null},hh=t_;var n_=()=>jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[jsx("rect",{x:"3",y:"4",width:"18",height:"12",rx:"2",stroke:"currentColor",strokeWidth:"2"}),jsx("path",{d:"M8 20h8M12 16v4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]}),r_=({phase:n,onShare:e,onDismiss:t,onStop:r,position:o="top-center",controlsVisible:s,className:u,style:p})=>{if(n!=="awaiting_click"&&n!=="live")return null;let h=s&&o.startsWith("bottom"),A=["avatar-screen-share",`avatar-screen-share--${o}`,n==="live"?"live":"",h?"avatar-screen-share--raised":"",u??""].filter(Boolean).join(" ");return n==="awaiting_click"?jsxs("div",{className:A,style:p,role:"group","aria-label":"Screen sharing request",children:[jsxs("button",{type:"button",className:"avatar-screen-share-primary",onClick:e,children:[jsx(n_,{}),"Share your screen"]}),jsx("button",{type:"button",className:"avatar-screen-share-secondary",onClick:t,children:"Not now"})]}):jsxs("div",{className:A,style:p,role:"status",children:[jsx("span",{className:"avatar-screen-share-dot","aria-hidden":"true"}),jsx("span",{children:"Sharing your screen"}),jsx("button",{type:"button",className:"avatar-screen-share-secondary",onClick:r,children:"Stop"})]})},mh=r_;var a_=n=>{let e=Ut(),r=e?.controls?.enabled!==false&&e.mode==="call",o=e?._camera?.sessionOpen??false,s=!!n?.usePictureInPicture&&o,[u,p]=useState(true);useEffect(()=>{o&&p(true);},[o]);let h=s&&u,A=useCallback(()=>p(true),[]),y=useCallback(()=>p(false),[]),b=e?._environment!=="meeting",m=b&&!!e?.isConnecting&&!!e?._avatarConfig,S=[h?`avatar-pip-frame swappable ${n?.pictureInPictureCorner??"bottom-right"}`:"avatar-stage-layer",m?"avatar-stage-loading":""].filter(Boolean).join(" "),C=jsx(Jp,{lastResponse:e?._currentJob,onPlaybackEnd:e?._onPlaybackEnd,avatarConfig:e?._avatarConfig||null,fit:n?.fit,error:e?.error,className:n?.className,style:n?.style,onRiveReady:e?._onRiveReady,onRiveError:e?._onRiveError,resetToken:e?._resetToken,shouldArmTalking:e?._shouldArmTalking,isConnected:e?.isConnected,userActivity:e?._userActivity,userAttending:e?.isTalking,isThinking:e?.isThinking,thinkingSignal:e?._thinkingSignal,gestureQueue:e?._gestureQueue,gestureSignal:e?._gestureSignal,onAvatarClick:h||!b?void 0:e?._avatarClicked,lipSyncTuning:e?._lipSyncTuning,visualState:e?._visualState,onSpeechClock:e?._registerSpeechClock,onRegisterPlaybackControls:e?._registerPlaybackControls,getAudioContext:e?._getAudioContext,createSpeechPlayer:e?._createSpeechPlayer,speakerMuted:e?._speakerMuted,rigActivity:e?._rigActivity,loader:n?.loader,errorFallback:n?.errorFallback,environment:e?._environment},e?._riveKey);return jsxs(wp,{children:[(s||!n?.hideCameraPreview)&&jsx(hh,{sessionOpen:o,stream:e?._camera?.stream??null,mirrored:e?._camera?.facing!=="environment",corner:n?.cameraPreviewCorner??"bottom-right",variant:h?"stage":"corner",onSwap:s&&!h?A:void 0,onToggleVideo:e?._camera?.toggleVideo,onFlip:e?._camera?.flip,mood:e?._camera?.mood}),jsxs("div",{className:S,...h&&{role:"button",tabIndex:0,"aria-label":"Show avatar full size",onClick:y,onKeyDown:I=>{(I.key==="Enter"||I.key===" ")&&(I.preventDefault(),y());}},children:[C,h&&jsx(Ac,{})]}),e?._captionsEnabled&&jsx(nh,{store:e._transcriptStore,speechClockRef:e._speechClockRef,position:e._captionPosition,controlsVisible:r,className:n?.captionClassName,style:n?.captionStyle}),e?._statusBannerEnabled&&jsx(ih,{store:e._healthStore,position:e._statusBannerPosition,controlsVisible:r,className:n?.statusBannerClassName,style:n?.statusBannerStyle}),e?._thinkingIndicatorEnabled&&jsx(oh,{visible:!!e?.isResponseSlow,position:e._thinkingIndicatorPosition,controlsVisible:r,className:n?.thinkingIndicatorClassName,style:n?.thinkingIndicatorStyle}),e?._screen&&jsx(mh,{phase:e._screen.phase,onShare:e._screen.share,onDismiss:e._screen.dismiss,onStop:e._screen.stop,position:e._screenSharePosition,controlsVisible:r,className:n?.screenShareClassName,style:n?.screenShareStyle}),e._mode!=="player"&&b&&jsx("div",{className:`connectivity-dot ${e.isConnected?"connected":"disconnected"}`,title:e.isConnected?"Connected to Server":"Disconnected"}),m&&jsx("div",{className:"avatar-connecting-overlay",children:n?.loader??jsx(to,{label:"Connecting"})}),r&&e?.isPushToTalk&&jsx(fh,{className:"avatar-controls",isIdle:e?.isIdle,start:e?.start,stop:e?.stop,avatarReady:e?.isReady,isSpeakerMuted:e?.isSpeakerMuted,setSpeakerMuted:e?.setSpeakerMuted,isTalking:e?.isTalking,isSpeaking:e?.isSpeaking,startTalking:e?.startTalking,stopTalking:e?.stopTalking,spacebar:e?._spacebarToTalk}),r&&!e?.isPushToTalk&&jsx(lh,{className:"avatar-controls",isIdle:e?.isIdle,start:e?.start,stop:e?.stop,avatarReady:e?.isReady,isMicMuted:e?.isMicMuted,isSpeakerMuted:e?.isSpeakerMuted,setMicMuted:e?.setMicMuted,setSpeakerMuted:e?.setSpeakerMuted,showStopSpeaking:e?.controls?.stopSpeaking===true,isSpeaking:e?.isSpeaking,stopSpeaking:e?.stopSpeaking})]})},bc=a_;var Ah="data-af-pointed",lo=new WeakMap,ns=n=>{lo.set(n,(lo.get(n)??0)+1),n.setAttribute(Ah,"");let e=false;return ()=>{if(e)return;e=true;let t=(lo.get(n)??1)-1;if(t>0){lo.set(n,t);return}lo.delete(n),n.removeAttribute(Ah);}};var bh=["transitionrun","animationstart"],yh=["transitionend","transitioncancel","animationend","animationcancel"],rs=(n,e)=>{let t=0,r=performance.now()+1e3,o=0,s=0,u=()=>{t=0,e();let S=performance.now();(S<r||S<s)&&(t=requestAnimationFrame(u));},p=()=>{t||(t=requestAnimationFrame(u));},h=()=>{r=Math.max(r,performance.now()+120),p();},A=S=>S.target instanceof Node&&S.target.contains(n),y=S=>{A(S)&&(o+=1,s=performance.now()+1e3,p());},b=S=>{A(S)&&(o=Math.max(0,o-1),o===0&&(s=0),p());};e(),t=requestAnimationFrame(u),window.addEventListener("scroll",h,{capture:true,passive:true}),bh.forEach(S=>document.addEventListener(S,y,{capture:true,passive:true})),yh.forEach(S=>document.addEventListener(S,b,{capture:true,passive:true})),window.addEventListener("resize",p,{passive:true});let m=typeof ResizeObserver=="function"?new ResizeObserver(p):null;return m?.observe(n),()=>{t&&cancelAnimationFrame(t),window.removeEventListener("scroll",h,{capture:true}),window.removeEventListener("resize",p),bh.forEach(S=>document.removeEventListener(S,y,{capture:true})),yh.forEach(S=>document.removeEventListener(S,b,{capture:true})),m?.disconnect();}};var s_={min:4,max:16},l_={min:2,max:8},_c=50,_h=(n,e)=>Math.min(e.max,Math.max(e.min,n)),Eh=n=>{let e=parseFloat(getComputedStyle(n).fontSize)||16;return {x:_h(e*.3,s_),y:_h(e*.12,l_)}},wc=220,c_=4,Mh="af-tour-ink",Th="af-tour-ink-strong",is="af-tour-ink-behind",wh="af-tour-behind-style",u_="#fef08a",d_="#facc15",f_="#171717",p_="#ffffff",h_=.179,m_=.4,tr,kh=n=>{if(tr??(tr=document.createElement("canvas").getContext("2d",{willReadFrequently:true})),!tr)return null;let e="#010203";if(tr.fillStyle=e,tr.fillStyle=n,tr.fillStyle===e&&n.trim().toLowerCase()!==e)return null;tr.clearRect(0,0,1,1),tr.fillRect(0,0,1,1);let[t,r,o,s]=tr.getImageData(0,0,1,1).data;if(s<128)return null;let u=p=>Math.round(p*(s/255)+255*(1-s/255));return [u(t),u(r),u(o)]},Sh=([n,e,t])=>{let r=o=>{let s=o/255;return s<=.04045?s/12.92:((s+.055)/1.055)**2.4};return .2126*r(n)+.7152*r(e)+.0722*r(t)},g_=(n,e)=>n.map(t=>Math.round(t+(255-t)*e/100)),v_=n=>{let e=document.createTreeWalker(n,NodeFilter.SHOW_TEXT);for(let t=e.nextNode();t;t=e.nextNode())if(t.nodeValue?.trim()&&t.parentElement)return kh(getComputedStyle(t.parentElement).color);return null},Ch=()=>typeof CSS<"u"&&!!CSS.highlights&&typeof Highlight=="function",xh=(n,e,t)=>{if(!Ch())return {behind:false};let r=kh(t??(e?d_:u_));if(!r)return {behind:false};let o=t&&!e?g_(r,_c):r,s=Sh(o)>h_,u=v_(n),p=!!u&&Sh(u)>m_;return s&&!p?{behind:false}:{behind:true,background:`rgb(${o.join(" ")})`,ink:s?f_:p_}},Rh=(n,e)=>{let t=document.getElementById(wh);t||(t=document.createElement("style"),t.id=wh,document.head.appendChild(t));let r=e?`;text-shadow:.35px 0 0 ${n.ink}`:"";t.textContent=`::highlight(${is}){background-color:${n.background};color:${n.ink}${r}}`;},yc=Math.sqrt(51),A_=n=>{let e=n/1e3;return 1-Math.exp(-7*e)*(Math.cos(yc*e)+7/yc*Math.sin(yc*e))},b_=n=>{for(let e=0;e<800;e+=4)if(A_(e)>=n)return e;return 800},Sc=n=>{let e=document.createRange();e.selectNodeContents(n);let t=[];for(let r of Array.from(e.getClientRects())){if(r.width<1||r.height<1)continue;let o=t.find(u=>Math.abs(u.top-r.top)<c_);if(!o){t.push({left:r.left,top:r.top,width:r.width,height:r.height});continue}let s=Math.max(o.left+o.width,r.right);o.left=Math.min(o.left,r.left),o.width=s-o.left,o.height=Math.max(o.height,r.height);}return t},Ph=(n,e)=>n.length===e.length&&n.every((t,r)=>Math.abs(t.left-e[r].left)<.5&&Math.abs(t.top-e[r].top)<.5&&Math.abs(t.width-e[r].width)<.5),y_=(n,e)=>{let t=0;return n.forEach((r,o)=>{Math.abs(r.top-e)<Math.abs(n[t].top-e)&&(t=o);}),t},__=(n,e)=>{let t=[],r=document.createTreeWalker(n,NodeFilter.SHOW_TEXT);for(let o=r.nextNode();o;o=r.nextNode()){let s=o.nodeValue??"",u=e?/\S+\s*/g:/\S+/g;for(let p=u.exec(s);p;p=u.exec(s)){let h=document.createRange();h.setStart(o,p.index),h.setEnd(o,p.index+p[0].length),t.push(h);}}return t},Ih=(n,e,t)=>{if(!Ch()||!e.length)return ()=>{};let r=CSS.highlights,o=r.get(t)??new Highlight;r.set(t,o);let s=[],u=__(n,t===is).map(p=>{let h=p.getBoundingClientRect(),A=y_(e,h.top),y=(h.left+h.width/2-e[A].left)/e[A].width,b=A*200+b_(Math.min(1,Math.max(0,y)));return setTimeout(()=>{o.add(p),s.push(p);},b)});return ()=>{u.forEach(clearTimeout),s.forEach(p=>o.delete(p)),o.size===0&&r.get(t)===o&&r.delete(t);}};var M_=({target:n,strong:e=false,color:t,leaving:r=false})=>{let[o,s]=useState([]),u=useMemo(()=>Eh(n),[n]),p=useMemo(()=>xh(n,e,t),[n,e,t]),h=t?{"--af-highlight-strong-color":t,"--af-highlight-color":`color-mix(in srgb, ${t} ${100-_c}%, white)`}:void 0;useEffect(()=>{let y=[];return rs(n,()=>{let b=Sc(n);Ph(y,b)||(y=b,s(b));})},[n]),useEffect(()=>{if(!r)return ns(n)},[n,r]);let A=o.length>0;return useEffect(()=>{if(r||!A)return;p.behind&&Rh(p,e);let y=p.behind?is:e?Th:Mh;return Ih(n,Sc(n),y)},[n,e,r,A,p]),typeof document>"u"?null:createPortal(jsx("div",{className:"af-tour-layer af-tour-layer--marks",style:h,"aria-hidden":"true",children:!p.behind&&o.map((y,b)=>jsx("span",{className:`af-tour-mark${e?" af-tour-mark--strong":""}${r?" af-tour-mark--out":""}`,style:{left:y.left-u.x,top:y.top-u.y,width:y.width+u.x*2,height:y.height+u.y*2,animationDelay:r?void 0:`${b*200}ms`}},b))}),document.body)},Nh=M_;var as=".af-widget, .af-tour-layer",T_="h1, h2, h3, h4, h5, h6, button, a, [role=button], label, li, p";var kc=n=>n.toLowerCase().replace(/\s+/g," ").trim(),Mc=n=>{if(n.closest(as)||n.closest("[aria-hidden='true'], [hidden]"))return false;let e=n.getBoundingClientRect();if(e.width<2||e.height<2)return false;let t=n.checkVisibility;return typeof t=="function"?t.call(n,{visibilityProperty:true}):true},Fh=n=>kc(n.innerText??n.textContent??""),Tc=n=>{let e=document.createRange();e.selectNodeContents(n);let t=e.getBoundingClientRect();return t.width>=2&&t.height>=2?t:n.getBoundingClientRect()},os=n=>n.width*n.height;var yr=n=>{let e=n.getBoundingClientRect(),t=Tc(n);return os(e)<=os(t)*4?e:t},k_=(n,e,t)=>{let r=n;for(;r.parentElement&&r.parentElement!==t;){let o=r.parentElement;if(Fh(o).length>e.length+40||os(Tc(o))>os(Tc(r))*4)break;r=o;}return r},C_=(n,e)=>{let t=kc(n);return t===e?3:t.startsWith(e)?2:t.includes(e)?1:0},x_="h1, h2, h3, h4, h5, h6, [role=heading]",Bh=(n,e)=>{if(typeof document>"u"||!document.body)return null;let t=kc(n);if(!t)return null;let r=e?.(n);if(r&&Mc(r.element)){if(!r.isSection)return r.element;let o=s=>Array.from(r.element.querySelectorAll(s)).find(Mc);return Dh(r.element,t)??o(x_)??o("p")??r.element}return Dh(document.body,t)},Dh=(n,e)=>{let t=null,r=0,o=false,s=(p,h,A=false)=>{if(!p)return;let y=C_(h,e);y<=r||!Mc(p)||(t=p,r=y,o=A);},u=document.createTreeWalker(n,NodeFilter.SHOW_TEXT);for(let p=u.nextNode();p&&r<3;p=u.nextNode())s(p.parentElement,p.textContent??"");for(let p of Array.from(n.querySelectorAll(T_))){if(r===3)break;s(p,Fh(p));}for(let p of Array.from(n.querySelectorAll("[aria-label], img[alt]"))){if(r===3)break;let h=p.getAttribute("aria-label");s(p,h??p.getAttribute("alt")??"",h!==null);}return t?o?t:k_(t,e,n):null};var R_="button, a[href], input, select, textarea, [role=button]",P_=8,Cc=(n,e)=>n.left<e.left+e.width&&e.left<n.left+n.width&&n.top<e.top+e.height&&e.top<n.top+n.height,co=(n,e)=>({left:n.left-e,top:n.top-e,width:n.width+e*2,height:n.height+e*2}),ss=n=>{if(typeof document>"u"||!document.body)return [];let e=[],t=s=>{s.width>0&&s.height>0&&Cc(s,n)&&e.push(s);},r=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT),o=document.createRange();for(let s=r.nextNode();s;s=r.nextNode()){let u=s.parentElement;!u||!s.nodeValue?.trim()||u.closest(as)||Cc(u.getBoundingClientRect(),n)&&(o.selectNodeContents(s),Array.from(o.getClientRects()).forEach(t));}for(let s of Array.from(document.querySelectorAll(R_)))s.closest(as)||t(s.getBoundingClientRect());return e},ls=(n,e)=>{let t=co(n,P_);return e.some(r=>Cc(r,t))};var Jt=40,cn=14,Vh=150,N_={right:-90,left:90,below:0,above:180},D_=(n,e,t)=>{let r=Math.min(Math.max(n,t.left),t.right),o=Math.min(Math.max(e,t.top),t.bottom);return Math.atan2(o-e,r-n)*180/Math.PI+90},F_=(n,e)=>{let t=n.top+n.height/2-Jt/2,o=[n.right+cn,n.left-cn-Jt].map(u=>({left:u,top:t,width:Jt,height:Jt})).filter(u=>u.left>=cn&&u.left+u.width<=window.innerWidth-cn),s=o.find(u=>!ls(u,ss(co(u,16))))??o[0];return s?{x:s.left,y:t,deg:D_(s.left+Jt/2,t+Jt/2,e)}:null},B_=(n,e)=>{let t=n.left+n.width/2-Jt/2,r=n.top+n.height/2-Jt/2,o=N_[e];return e==="right"?{x:n.right+cn,y:r,deg:o}:e==="left"?{x:n.left-cn-Jt,y:r,deg:o}:e==="below"?{x:t,y:n.bottom+cn,deg:o}:{x:t,y:n.top-cn-Jt,deg:o}},U_=({target:n,side:e,avatar:t,leaving:r=false})=>{let o=useRef(null),s=useRef(t);return s.current=t,useLayoutEffect(()=>{let u=null;return rs(n,()=>{let p=o.current;if(!p)return;let h=yr(n);if(!u){let b=e==="above"||e==="below"?s.current():null,m=(b&&F_(b,h))??B_(h,e);u={x:m.x-h.left,y:m.y-h.top,deg:m.deg};}let A=h.left+u.x,y=h.top+u.y;p.style.transform=`translate(${A}px, ${y}px) rotate(${u.deg}deg)`;})},[n,e]),useEffect(()=>{if(!r)return ns(n)},[n,r]),typeof document>"u"?null:createPortal(jsx("div",{className:"af-tour-layer","aria-hidden":"true",children:jsx("div",{ref:o,className:"af-tour-arrow",children:jsx("div",{className:`af-tour-arrow__badge${r?" af-tour-arrow__badge--out":""}`,children:jsxs("svg",{className:"af-tour-arrow__glyph",viewBox:"0 0 24 24",width:22,height:22,fill:"none",stroke:"currentColor",strokeWidth:2.25,strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),jsx("polyline",{points:"5 12 12 5 19 12"})]})})})}),document.body)},Wh=U_;var xc=(n,e)=>{let[t,r]=useState(n?{value:n,leaving:false}:null);return useEffect(()=>{if(n){r({value:n,leaving:false});return}r(s=>s?{...s,leaving:true}:null);let o=setTimeout(()=>r(null),e);return ()=>clearTimeout(o)},[n,e]),t};var Hh=(n,e)=>n==="start"?e.margin:n==="end"?e.viewport-e.size-e.margin:(e.viewport-e.size)/2,G_={"top-left":"start","middle-left":"start","bottom-left":"start","top-center":"center",center:"center","bottom-center":"center","top-right":"end","middle-right":"end","bottom-right":"end"},j_={"top-left":"start","top-center":"start","top-right":"start","middle-left":"center",center:"center","middle-right":"center","bottom-left":"end","bottom-center":"end","bottom-right":"end"},fo=(n,e,t,r)=>({x:Hh(G_[n],{size:e.w,viewport:t.w,margin:r.x}),y:Hh(j_[n],{size:e.h,viewport:t.h,margin:r.y})}),Rc=(n,e,t)=>{if(!n)return e;let r=n.percent?t*n.value/100:n.value;return n.relative?e+r:r};var z_=n=>n.top>=96&&n.bottom<=window.innerHeight-96,Y_=n=>new Promise(e=>{let t=Number.NaN,r=0,o=0,s=()=>{clearTimeout(u),cancelAnimationFrame(o),e();},u=setTimeout(s,1600),p=()=>{let h=n.getBoundingClientRect().top;r=Math.abs(h-t)<.5?r+1:0,t=h,r>=5?s():o=requestAnimationFrame(p);};o=requestAnimationFrame(p);}),Gh=async n=>{let e=n.getBoundingClientRect();if(z_(e))return;let t=e.height<=window.innerHeight-192;n.scrollIntoView({behavior:"smooth",block:t?"center":"start"}),await Y_(n);};var K_=.15,q_=450,X_=1200,Q_=15e3,zh={x:Jt+cn*2,y:cn*2},$_="tour.play",J_=n=>{try{if(n==="session")return sessionStorage;if(n==="visitor"||n===void 0)return localStorage}catch{}return null},Z_=n=>new Promise(e=>setTimeout(e,n)),Yh=(n,e,t,r)=>{let o=n?.closing??ua,s=useMemo(()=>da(n?.steps,o),[n?.steps,o]),u=s.steps.length>0,p=!u&&n?.generate===true,h=n?.greeting===false,A=u?`af-tour:${kl(s)}`:r?.seenKey??`af-tour:auto:${typeof window>"u"?"":window.location.pathname}`,y=useMemo(()=>J_(n?.once),[n?.once]),b=useCallback(()=>{try{return !!y?.getItem(A)}catch{return false}},[y,A]),[m,S]=useState("idle"),[C,I]=useState(b),[L,B]=useState(null),[W,Q]=useState(null);useEffect(()=>I(b()),[b]);let Z=useRef({avatar:e,mover:t,compiled:s,closing:o,page:r});Z.current={avatar:e,mover:t,compiled:s,closing:o,page:r};let $=useRef(null),oe=useRef(0),J=useRef(null),H=useRef(null),de=useRef(null),te=useCallback(()=>{if(I(true),n?.once!==false)try{y?.setItem(A,"1");}catch{}},[y,A,n?.once]),xe=useCallback(()=>{let{mover:ee}=Z.current;ee.returnTo(J.current,ee.dockPoint());},[]),Se=()=>{oe.current+=1,H.current=null,B(null),Q(null),Z.current.page?.clear();},ue=()=>{let ee=Z.current.page;ee?ee.scrollTop():window.scrollTo({top:0,behavior:"smooth"});},Ie=async(ee,fe,Fe)=>{let ye=(Ue,We)=>E.warn("Tour","Tour target not found on the page",{action:Ue,target:We});fe.scroll&&!await ee.scroll(fe.scroll)&&ye("scroll",fe.scroll);let pe=fe.move;if(pe?.kind==="home")xe();else if(pe?.kind==="spot")N(pe.spot);else if(pe){if(!Fe())return;let Ue=await ee.scroll(pe.target);Ue?Fe()&&P(Ue,pe.kind==="point"?zh:void 0,pe.from,null,()=>{}):ye(pe.kind,pe.target);}if(fe.highlight&&Fe()){let{target:Ue,strong:We}=fe.highlight;await ee.mark(Ue,We)||ye("highlight",Ue);}},ae=useCallback(()=>{$.current&&($.current.cancelled=true,$.current=null,de.current=null,Se(),xe(),S("done"));},[xe]),G=()=>{let ee=Z.current.mover.rootRef.current?.getBoundingClientRect();return ee?{w:ee.width,h:ee.height}:null},z=ee=>{let fe=Z.current.mover.rootRef.current?.getBoundingClientRect();if(!fe)return;let Fe=yr(ee);H.current={element:ee,dx:fe.left-Fe.left,dy:fe.top-Fe.top};},P=(ee,fe,Fe,ye,pe)=>{let Ue=G();if(!Ue)return;let{offset:We,moveTo:Ve,viewport:rt}=Z.current.mover,st=Math.max(Ue.w,Ue.h)+(typeof fe=="object"?fe.x:fe??0)+32,et=ye?ss(co(yr(ye),st)):null,tt=xl(ee,Ue,rt(),{margin:Math.min(We.x,We.y),gap:fe,prefer:Fe,blocked:et?He=>ls(He,et):void 0});Ve(tt.left,tt.top,()=>pe(tt.side));},N=ee=>{let fe=G();if(!fe)return;let{offset:Fe,moveTo:ye,viewport:pe}=Z.current.mover,Ue=fo(ee,fe,pe(),Fe);ye(Ue.x,Ue.y);},U=(ee,fe)=>{let Fe=Bh(fe,Da.elementNamed);return Fe||E.warn("Tour","Tour target not found on the page",{action:ee,target:fe}),Fe},q=async(ee,fe)=>(await Gh(ee),!fe.cancelled),se=useCallback(async(ee,fe)=>{let{avatar:Fe}=Z.current;Se();let ye=oe.current,pe=()=>!fe.cancelled&&oe.current===ye;ee.gesture&&Fe.triggerAction?.(ee.gesture),ee.scrollTop&&ue();let Ue=Z.current.page;if(Ue){await Ie(Ue,ee,pe);return}if(ee.scroll){let Ve=U("scroll",ee.scroll);if(Ve&&!await q(Ve,fe)||!pe())return}let We=ee.move;if(We?.kind==="home")xe();else if(We?.kind==="spot")N(We.spot);else if(We){let Ve=U(We.kind,We.target);if(Ve){if(!await q(Ve,fe)||!pe())return;let rt=We.kind==="point";P(yr(Ve),rt?zh:void 0,We.from,Ve,st=>{pe()&&(z(Ve),rt&&B({target:Ve,side:st,step:ye}));});}}if(ee.highlight){let Ve=U("highlight",ee.highlight.target);if(Ve&&!We&&!ee.scroll&&(!await q(Ve,fe)||!pe()))return;Ve&&Q({...ee.highlight,element:Ve,step:ye});}},[xe]),Re=useCallback(async(ee,fe)=>{let{avatar:Fe}=Z.current,{words:ye,steps:pe,text:Ue}=fe,[We,...Ve]=pe;if(We&&await se(We,ee),await Z_(q_),ee.cancelled)return;let rt=new Bi,st=ye.map(()=>null),et=Fe._onSpeechJob(l=>{rt.add(l),st=Cl(ye,rt.words);});Fe.notify?.({name:$_,say:Ue,policy:"queue"}),S("playing");let tt=performance.now(),He=0,le=null,g=null;await new Promise(l=>{let f=()=>{if(ee.cancelled)return l();let w=Z.current.avatar._speechClockRef.current?.()??null,T=performance.now();for(w!==null?(le??(le=T),g=null):le!==null&&(g??(g=T));He<Ve.length;){let re=st[Ve[He].wordIndex];if(re===null||w===null||w<re-K_)break;E.debug("Tour","Step",{step:He+1,at:re,clock:w}),se(Ve[He++],ee);}let R=g!==null&&T-g>=X_,V=le===null&&T-tt>=Q_;if(V&&E.warn("Tour","Tour line was never heard \u2014 standing down"),R||V)return l();requestAnimationFrame(f);};requestAnimationFrame(f);}),et(),!ee.cancelled&&He<Ve.length&&(E.warn("Tour","Speech ended before some steps were matched to it",{unmatched:Ve.length-He,of:Ve.length}),Se(),ue(),xe());},[se,xe]),Pe=useCallback(async ee=>{let{compiled:fe,closing:Fe}=Z.current;if(fe.steps.length)return fe;let ye=await de.current;if(ee.cancelled)return null;let pe=da(ye??[],Fe);return pe.steps.length||E.warn("Tour","No tour could be written for this page"),pe.steps.length?pe:null},[]),we=useCallback(()=>{let ee=$.current;ee&&(S("playing"),(async()=>{let fe=await Pe(ee),Fe=false;fe&&fe.text.length>ca?E.warn("Tour","Tour is too long to speak as one line",{chars:fe.text.length,max:ca}):fe&&!ee.cancelled&&(await Re(ee,fe),Fe=true),$.current===ee&&(Fe||xe(),ee.cancelled=true,$.current=null,de.current=null,Se(),S("done"));})());},[Pe,Re,xe]),ve=useCallback(()=>{if(!$.current)return;let ee=m==="playing";ae(),ee&&Z.current.avatar.stopSpeaking?.();},[ae,m]),De=(u||p)&&!C&&m==="idle",Xe=useCallback(()=>{if($.current)return;te(),$.current={cancelled:false},J.current=Z.current.mover.placement,S("starting");let{avatar:ee}=Z.current;!ee.isConnected&&ee.isIdle&&(h&&ee._skipNextGreeting(),ee.start());},[te,h]);useEffect(()=>{if(m==="idle"||m==="done")return;let ee=0,fe=()=>{ee=0;let ye=H.current;if(!ye)return;let pe=yr(ye.element);Z.current.mover.followTo(pe.left+ye.dx,pe.top+ye.dy);},Fe=()=>{H.current&&!ee&&(ee=requestAnimationFrame(fe));};return window.addEventListener("scroll",Fe,{capture:true,passive:true}),()=>{window.removeEventListener("scroll",Fe,{capture:true}),ee&&cancelAnimationFrame(ee);}},[m]),useEffect(()=>{let ee=$.current;m!=="starting"||!e.isConnected||!ee||(!Z.current.compiled.steps.length&&!de.current&&(de.current=Z.current.avatar._requestTour()),se({wordIndex:0,move:{kind:"spot",spot:"center"}},ee));},[m,e.isConnected,se]),useEffect(()=>{m!=="starting"||!e.isConnected||!e.isListening||we();},[m,e.isConnected,e.isListening,we]),useEffect(()=>{let ee=()=>{$.current&&ae();};return e.on("interrupt",ee),e.on("stop",ee),()=>{e.off("interrupt",ee),e.off("stop",ee);}},[e.on,e.off,ae]);let qe=useRef(false);return useEffect(()=>{if(m!=="starting"){qe.current=false;return}e.isConnecting?qe.current=true:e.isIdle&&qe.current&&ae();},[m,e.isIdle,e.isConnecting,ae]),useEffect(()=>()=>{$.current&&($.current.cancelled=true);},[]),{state:m,pointer:L,mark:W,pending:De,start:Xe,stop:ve,markSeen:te}};var ew=n=>{let e=Math.floor(n/60),t=n%60;return `${e}:${String(t).padStart(2,"0")}`},tw=({expanded:n,live:e,elapsed:t,label:r,onOpen:o,dragHandlers:s})=>n?null:jsxs("button",{type:"button",className:`af-widget__launcher${e?" af-widget__launcher--live":""}`,onClick:o,...s,"aria-label":r,children:[e&&jsx("span",{className:"af-widget__ring","aria-hidden":"true"}),e&&t!==null&&jsx("span",{className:"af-widget__timer",children:ew(t)})]}),qh=tw;var sw=2400,lw=3400,cw=2,Qh="af-widget-teaser-dismissed",uw=()=>{try{return !!sessionStorage.getItem(Qh)}catch{return false}},$h=n=>{let e=!!n?.text?.trim(),t=n?.delayMs??Bt.teaserDelayMs,[r,o]=useState(false),[s,u]=useState(uw);useEffect(()=>{if(!e||s)return;let h=setTimeout(()=>o(true),t);return ()=>clearTimeout(h)},[e,s,t]);let p=useCallback(()=>{u(true);try{sessionStorage.setItem(Qh,"1");}catch{}},[]);return useMemo(()=>({visible:e&&r&&!s,dismiss:p}),[e,r,s,p])},dw=()=>typeof window<"u"&&!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,fw=({text:n,onAccept:e,onDismiss:t})=>{let r=dw(),[o,s]=useState(r),[u,p]=useState(null),h=useRef(null);return useLayoutEffect(()=>{let A=h.current?.scrollWidth;A&&p(A+cw);},[n]),useEffect(()=>{if(r)return;let A=setTimeout(()=>s(y=>!y),o?lw:sw);return ()=>clearTimeout(A)},[o,r]),jsxs("div",{className:"af-widget__pill",children:[jsx("span",{className:"af-widget__pill-glow","aria-hidden":"true"}),jsxs("button",{type:"button",className:`af-widget__pill-button${o?" af-widget__pill-button--open":""}`,style:u?{"--af-pill-open-width":`${u}px`}:void 0,onClick:A=>{A.stopPropagation(),e();},"aria-label":n,children:[jsxs("span",{className:"af-widget__pill-dots","aria-hidden":"true",children:[jsx("span",{}),jsx("span",{}),jsx("span",{})]}),jsx("span",{ref:h,className:"af-widget__pill-text",children:n})]}),jsx("button",{type:"button",className:"af-widget__pill-close","aria-label":"Dismiss",onClick:A=>{A.stopPropagation(),t();},children:"\xD7"})]})},Jh=fw;var Zh=n=>{if(!n?.fatal)return null;if(n.code==="MIC_PERMISSION_DENIED")switch(ia(n)){case "NotFoundError":case "OverconstrainedError":return "No microphone found. Connect a microphone to talk to the avatar.";case "NotReadableError":case "AbortError":return "Your microphone is in use by another app. Close it, then try again.";default:return "Microphone access is blocked. Allow the microphone for this site in your browser, then try again."}return n.code==="CONNECTION_FAILED"||n.code==="UNKNOWN"?"The call couldn't connect. Check your internet connection, then try again.":null};var pw=()=>{let n=Ut();if(n.isIdle){let t=Zh(n.error);return jsxs(Fragment,{children:[t&&jsx("p",{className:"af-widget__help",role:"alert",children:t}),jsx("div",{className:"af-widget__callbar af-widget__callbar--idle",children:jsxs("button",{type:"button",className:"af-widget__call af-widget__call--start",onClick:n.start,disabled:!n.isReady,children:[jsx(Za,{size:18}),jsx("span",{children:t?"Try again":"Start talking"})]})})]})}let e=!!n.isConnected;return jsxs("div",{className:"af-widget__callbar",role:"toolbar","aria-label":"Call controls",children:[jsx("button",{type:"button",className:"af-widget__callbar-button",onClick:()=>n.setMicMuted(!n.isMicMuted),"aria-label":n.isMicMuted?"Unmute microphone":"Mute microphone","aria-pressed":n.isMicMuted,disabled:!e,children:jsx($a,{muted:n.isMicMuted,size:20})}),jsx("button",{type:"button",className:"af-widget__callbar-button",onClick:()=>n.setSpeakerMuted(!n.isSpeakerMuted),"aria-label":n.isSpeakerMuted?"Unmute avatar audio":"Mute avatar audio","aria-pressed":n.isSpeakerMuted,disabled:!e,children:jsx(Ja,{muted:n.isSpeakerMuted,size:20})}),jsx("button",{type:"button",className:"af-widget__call af-widget__call--end",onClick:n.stop,"aria-label":e?"End call":"Cancel",title:e?"End call":"Cancel",children:jsx(es,{size:20})})]})},em=pw;var mw=n=>`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`,gw=({expanded:n,title:e,live:t,connecting:r,elapsed:o,onCollapse:s,composer:u,dragHandlers:p})=>n?jsxs("div",{className:"af-widget__chrome",children:[jsxs("header",{className:"af-widget__header",...p,children:[e&&jsx("span",{className:"af-widget__title",children:e}),(t||r)&&jsxs("span",{className:`af-widget__status${t?" af-widget__status--live":""}`,role:"status",children:[jsx("span",{className:"af-widget__status-dot","aria-hidden":"true"}),t?o!=null?mw(o):"Live":"Connecting"]}),jsx("button",{type:"button",className:"af-widget__collapse",onClick:s,"aria-label":t?"Minimise \u2014 the call continues":"Close",children:jsx("svg",{viewBox:"0 0 16 16",width:"16",height:"16","aria-hidden":"true",children:jsx("path",{d:"M4 6.5l4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),u&&jsx("div",{className:"af-widget__composer",children:u})]}):null,tm=gw;var im=(n,e,t)=>Math.min(Math.max(n,e),Math.max(e,t)),om=(n,e,t,r,o)=>({left:im(n.fromRight?n.x-e:n.x,o.x,r.w-e-o.x),top:im(n.fromBottom?n.y-t:n.y,o.y,r.h-t-o.y)}),am=(n,e,t,r,o)=>{let s=useMemo(()=>Hr(n),[n]),u=useCallback(()=>typeof window>"u"?{w:1280,h:800}:{w:window.innerWidth,h:window.innerHeight},[]),[p,h]=useState(u),A=o??p;useEffect(()=>{if(typeof window>"u")return;let S=()=>h(u());return window.addEventListener("resize",S),window.addEventListener("orientationchange",S),()=>{window.removeEventListener("resize",S),window.removeEventListener("orientationchange",S);}},[u]);let y=A.w<Bt.mobileBreakpointPx,b=e&&y&&s.mobile==="sheet",m=useMemo(()=>{if(!e){let W=s.bubbleSize,Q=r?om(r,W,W,A,s.offset):null;return {w:W,h:W,position:s.position,sheet:false,left:Q?Q.left:null,top:Q?Q.top:null}}if(b)return {w:A.w,h:A.h,position:s.position,sheet:true,left:null,top:null};let S=Math.max(240,A.w-s.offset.x*2),C=Math.max(320,A.h-s.offset.y*2),I=Math.min(s.panel.w,S),L=Math.min(s.panel.h,C),B=r?om(r,I,L,A,s.offset):null;return {w:I,h:L,position:s.position,sheet:false,left:B?B.left:null,top:B?B.top:null}},[e,b,s,A,r]);return useEffect(()=>{t?.(m);},[m,t]),{box:m,isMobile:y}};var sm=4,lm=.995,Dc=lm/(1-lm),dm=100,yw=70,_w=.05,ww=120,Fc=1,Sw=64,Ew=480,Mw=1100,Tw=.55,kw=.06,Cw=n=>n<.5?4*n*n*n:1-Math.pow(-2*n+2,3)/2,Ln=(n,e,t)=>Math.min(Math.max(n,e),Math.max(e,t)),cm=n=>({fromRight:n.endsWith("right"),fromBottom:n.startsWith("bottom")}),Sr=(n,e,t,r)=>({...n,x:n.fromRight?e+r.w:e,y:n.fromBottom?t+r.h:t}),um=()=>typeof window<"u"&&!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,xw=(n,e)=>{let t=n[n.length-1];if(!t||e-t.t>yw)return {x:0,y:0};let r=n.find(s=>t.t-s.t<=dm)??n[0],o=t.t-r.t;return o<=0?{x:0,y:0}:{x:(t.x-r.x)/o,y:(t.y-r.y)/o}},fm=(n,e,t,r,o)=>{let s=useMemo(()=>({viewport:()=>({w:window.innerWidth,h:window.innerHeight}),boxRect:()=>n.current?.getBoundingClientRect()??null,pointer:G=>({x:G.clientX,y:G.clientY})}),[n]),u=o??s,[p,h]=useState(null),[A,y]=useState(false),[b,m]=useState(false),S=useRef(false),C=useRef(null),I=useRef(null),L=useRef(null),B=useRef({px:0,py:0,x:0,y:0,w:0,h:0}),W=useRef([]),Q=useRef(null),Z=useRef(cm(t));useEffect(()=>{p||(Z.current=cm(t));},[p,t]);let $=useCallback(G=>n.current?.style.setProperty("--af-widget-lift",`${G}`),[n]),oe=useCallback(()=>{Q.current!==null&&(cancelAnimationFrame(Q.current),Q.current=null,$(0),m(false));},[$]),J=useCallback((G,z,P,N,U)=>{let q=Math.hypot(z.x-G.x,z.y-G.y),se=Ln(q*Tw,Ew,Mw),Re=performance.now();m(true);let Pe=we=>{let ve=Math.min(1,(we-Re)/se),De=Cw(ve);if(h(Sr(N,G.x+(z.x-G.x)*De,G.y+(z.y-G.y)*De,P)),$(Math.sin(Math.PI*ve)*kw),ve>=1){Q.current=null,m(false),U?.();return}Q.current=requestAnimationFrame(Pe);};Q.current=requestAnimationFrame(Pe);},[$]),H=useCallback((G,z,P,N,U)=>{let q={...G},se=performance.now();m(true);let Re=Pe=>{let we=Math.min(Pe-se,Sw);se=Pe;let ve=1-Math.exp(-we/Dc);q={x:q.x+(z.x-q.x)*ve,y:q.y+(z.y-q.y)*ve};let De=Math.hypot(z.x-q.x,z.y-q.y)<Fc,Xe=De?z:q;if(h(Sr(N,Xe.x,Xe.y,P)),De){Q.current=null,m(false),U?.();return}Q.current=requestAnimationFrame(Re);};Q.current=requestAnimationFrame(Re);},[]),de=useCallback(()=>{L.current?.();let G=C.current;if(G===null)return;C.current=null;let z=I.current;I.current=null,z?.hasPointerCapture?.(G)&&z.releasePointerCapture(G),y(false);let P=S.current?u.boxRect():null;if(!P)return;let N={w:P.width,h:P.height},U=u.viewport(),q=um(),se=U.w-N.w-r.x,Re=U.h-N.h-r.y,Pe=q?{x:0,y:0}:xw(W.current,performance.now()),we={x:Ln(P.left+Pe.x*Dc,r.x,se),y:Ln(P.top+Pe.y*Dc,r.y,Re)};if(Math.hypot(Pe.x,Pe.y)>=_w){let Xe={x:we.x+N.w/2>U.w/2?se:r.x,y:we.y+N.h/2>U.h/2?Re:r.y};Math.hypot(Xe.x-we.x,Xe.y-we.y)<ww&&(we=Xe);}let ve={fromRight:we.x+N.w/2>U.w/2,fromBottom:we.y+N.h/2>U.h/2};Z.current=ve;let De=Math.hypot(we.x-P.left,we.y-P.top)<Fc;if(q||De){h(Sr(ve,we.x,we.y,N));return}H({x:P.left,y:P.top},we,N,ve);},[u,r.x,r.y,H]),te=useCallback((G,z,P)=>{let N=u.boxRect();if(!N)return;oe();let U={w:N.width,h:N.height},q=u.viewport(),se=Math.max(r.x,q.w-U.w-r.x),Re=Math.max(r.y,q.h-U.h-r.y),Pe={x:Ln(G,r.x,se),y:Ln(z,r.y,Re)},we={fromRight:Pe.x+U.w/2>q.w/2,fromBottom:Pe.y+U.h/2>q.h/2};if(Z.current=we,Math.hypot(Pe.x-N.left,Pe.y-N.top)<Fc||um()){h(Sr(we,Pe.x,Pe.y,U)),P?.();return}J({x:N.left,y:N.top},Pe,U,we,P);},[u,r.x,r.y,J,oe]),xe=useCallback((G,z)=>{let P=u.boxRect();P&&(oe(),h(Sr(Z.current,G,z,{w:P.width,h:P.height})));},[u,oe]),Se=useCallback((G,z)=>{let P=u.boxRect();if(!P)return;let N=G?{x:G.fromRight?G.x-P.width:G.x,y:G.fromBottom?G.y-P.height:G.y}:z;te(N.x,N.y,()=>h(G));},[u,te]),ue=useCallback(G=>{let z=C.current;if(z===null||G.pointerId!==z)return;if(G.buttons===0&&G.pointerType!=="touch"){de();return}let{px:P,py:N,x:U,y:q,w:se,h:Re}=B.current,Pe=u.pointer(G),we=Pe.x-P,ve=Pe.y-N;if(!S.current&&Math.abs(we)<sm&&Math.abs(ve)<sm)return;S.current||(S.current=true,y(true),I.current?.isConnected&&I.current.setPointerCapture(z));let De=u.viewport(),Xe=Ln(U+we,r.x,De.w-se-r.x),qe=Ln(q+ve,r.y,De.h-Re-r.y),ee=W.current,fe=performance.now();for(ee.push({x:Xe,y:qe,t:fe});ee.length>2&&fe-ee[0].t>dm;)ee.shift();h(Sr(Z.current,Xe,qe,{w:se,h:Re}));},[u,r.x,r.y,de]),Ie=useCallback(G=>{if(!e||G.button!==0)return;de(),oe();let z=u.boxRect();if(!z)return;let P=u.pointer(G);B.current={px:P.x,py:P.y,x:z.left,y:z.top,w:z.width,h:z.height},W.current=[],S.current=false,C.current=G.pointerId,I.current=G.currentTarget;let N=U=>{U.pointerId===C.current&&de();};window.addEventListener("pointermove",ue),window.addEventListener("pointerup",N),window.addEventListener("pointercancel",N),L.current=()=>{L.current=null,window.removeEventListener("pointermove",ue),window.removeEventListener("pointerup",N),window.removeEventListener("pointercancel",N);};},[e,u,oe,de,ue]),ae=useCallback(()=>{let G=S.current;return S.current=false,G},[]);return useEffect(()=>()=>{L.current?.(),oe();},[oe]),useEffect(()=>{if(typeof window>"u")return;let G=()=>{let z=u.boxRect();if(!z)return;oe();let{width:P,height:N}=z,U=u.viewport();h(q=>q&&Sr(q,Ln(q.fromRight?q.x-P:q.x,r.x,U.w-P-r.x),Ln(q.fromBottom?q.y-N:q.y,r.y,U.h-N-r.y),{w:P,h:N}));};return window.addEventListener("resize",G),window.addEventListener("orientationchange",G),()=>{window.removeEventListener("resize",G),window.removeEventListener("orientationchange",G);}},[u,r.x,r.y,oe]),{placement:p,dragging:A,gliding:b,consumeDragClick:ae,moveTo:te,followTo:xe,returnTo:Se,handlers:{onPointerDown:Ie}}};var Iw=500,Lw=12,Ow=24,Nw=n=>`${n.fromBottom?"bottom":"top"}-${n.fromRight?"right":"left"}`,Dw=n=>{let e={fg:"#16181d",scrim:"rgba(16, 24, 32, 0.08)"},t={fg:"#ffffff",scrim:"rgba(255, 255, 255, 0.16)"},r=n.trim().replace(/^#/,""),o=r.length===3?r.split("").map(p=>p+p).join(""):r;if(!/^[0-9a-f]{6}$/i.test(o))return e;let s=p=>{let h=parseInt(o.slice(p,p+2),16)/255;return h<=.04045?h/12.92:((h+.055)/1.055)**2.4};return .2126*s(0)+.7152*s(2)+.0722*s(4)>.45?e:t},Fw=({appearance:n,title:e,launcherLabel:t="Talk to the assistant",composer:r,open:o,onOpenChange:s,autoStart:u=true,onResize:p,onStageChange:h,usePictureInPicture:A,hostViewport:y,framed:b=false,tour:m,tourPage:S,className:C,style:I})=>{let L=Ut();L._setMountSurface("widget");let B=Ua(),[W,Q]=useState(null),Z=useRef(null),$=o!==void 0,oe=$?o:B.isOpen,[J,H]=useState(false),[de,te]=useState(null),xe=useRef(true);useEffect(()=>{if(xe.current){xe.current=false;return}H(true);let le=setTimeout(()=>H(false),Iw);return ()=>clearTimeout(le)},[oe]),useEffect(()=>{$&&B.setOpen(o);},[$,o,B]);let Se=useCallback(le=>{$||B.setOpen(le),s?.(le);},[$,B,s]),ue=Hr(n),Ie=useRef(null),ae=useRef(null),G=useRef(y),z=useMemo(()=>b?{viewport:()=>G.current??{w:window.innerWidth,h:window.innerHeight},boxRect:()=>ae.current,pointer:le=>({x:le.screenX,y:le.screenY})}:void 0,[b]),P=fm(Ie,ue.draggable,ue.position,ue.offset,z),N=b&&P.placement?Nw(P.placement):ue.position,U=b?oe?Ow:Lw:void 0,q=useCallback(le=>p?.(b?{...le,position:N,gutter:U}:le),[p,b,N,U]),{box:se}=am(n,oe,q,P.placement,y);useLayoutEffect(()=>{if(G.current=y,!b||!y){ae.current=null;return}let le=ue.position.endsWith("right"),g=ue.position.startsWith("bottom");ae.current={left:se.left??(le?y.w-se.w-ue.offset.x:ue.offset.x),top:se.top??(g?y.h-se.h-ue.offset.y:ue.offset.y),width:se.w,height:se.h};},[b,y,se,ue.position,ue.offset.x,ue.offset.y]);let Re=Dw(ue.panelBackground),Pe=useCallback(()=>b&&G.current||{w:window.innerWidth,h:window.innerHeight},[b]),we=useCallback(()=>{let le=Ie.current?.getBoundingClientRect(),g=le?{w:le.width,h:le.height}:{w:0,h:0};return fo(ue.position,g,Pe(),ue.offset)},[ue.position,ue.offset,Pe]),ve=Yh(m,L,{rootRef:Ie,placement:P.placement,offset:ue.offset,dockPoint:we,moveTo:P.moveTo,followTo:P.followTo,returnTo:P.returnTo,viewport:Pe},S);useEffect(()=>{B.setTourState(ve.state);},[ve.state,B]),useEffect(()=>(B.tourControlsRef.current={start:ve.start,stop:ve.stop},()=>{B.tourControlsRef.current=null;}),[ve.start,ve.stop,B.tourControlsRef]);let De=!!L.isConnected,Xe=!!L.isConnecting,qe=L.notice?"ended":De?"live":Xe?"connecting":oe?"expanded":"dormant";useEffect(()=>{B.setStage(qe),h?.(qe);},[qe,h,B]),useEffect(()=>L._onWidgetCommand((le,g)=>{if(le.kind==="stage")Se(le.open);else if(le.kind==="effect")te(le.effect==="bounce"?le.times:null);else if(y){L._reportWidgetStatus(g,"unsupported");return}else {let l=Ie.current?.getBoundingClientRect(),f={w:window.innerWidth,h:window.innerHeight};if(l){let w={w:l.width,h:l.height},T=le.kind==="spot"?fo(le.spot,w,f,ue.offset):{x:Rc(le.x,l.left,f.w),y:Rc(le.y,l.top,f.h)};P.moveTo(T.x,T.y);}}L._reportWidgetStatus(g,"ok");}),[L,Se,P,ue.offset,y]),useEffect(()=>{(!De||L.notice)&&te(null);},[De,L.notice]),useEffect(()=>{if(!De){Z.current=null,Q(null);return}Z.current??(Z.current=Date.now());let le=()=>Q(Math.floor((Date.now()-(Z.current??0))/1e3));le();let g=setInterval(le,1e3);return ()=>clearInterval(g)},[De]);let ee=useRef(false);useEffect(()=>{if(De){ee.current=true;return}ee.current&&(ee.current=false,Se(false));},[De,Se]);let fe=useCallback(()=>{if(ve.pending){ve.start();return}Se(true),u&&L.isIdle&&L.start();},[u,L,Se,ve]),Fe=useCallback(()=>{P.consumeDragClick()||fe();},[fe,P]),ye=xc(ve.pointer,Vh),pe=useCallback(()=>Ie.current?.getBoundingClientRect()??null,[]),Ue=xc(ve.mark,wc),We=$h(n?.teaser),Ve=We.visible&&!oe&&!!L.isIdle,rt=useCallback(()=>{We.dismiss(),ve.pending&&ve.markSeen();},[We,ve]),st=useCallback(()=>{P.consumeDragClick()||Se(false);},[Se,P]),et=ue.draggable&&!se.sheet?P.handlers:void 0,tt=r===void 0&&L.mode==="call"&&!L.isPushToTalk,He=["af-widget",`af-widget--${N}`,oe?"af-widget--expanded":"af-widget--collapsed",J?"af-widget--settling":"",L.isSpeaking?"af-widget--speaking":"",se.sheet?"af-widget--sheet":"",!b&&se.left!==null?"af-widget--free":"",P.dragging?"af-widget--dragging":"",P.gliding?"af-widget--gliding":"",de!==null?"af-widget--bouncing":"",ue.draggable?"af-widget--draggable":"",De?"af-widget--live":"",tt?"af-widget--callbar":"",b?"af-widget--framed":"",C??""].filter(Boolean).join(" ");return jsxs("div",{ref:Ie,className:He,style:{"--af-widget-w":`${se.w}px`,"--af-widget-h":`${se.h}px`,"--af-widget-left":!b&&se.left!==null?`${se.left}px`:void 0,"--af-widget-top":!b&&se.top!==null?`${se.top}px`:void 0,"--af-widget-offset-x":`${se.sheet?0:U??ue.offset.x}px`,"--af-widget-offset-y":`${se.sheet?0:U??ue.offset.y}px`,"--af-widget-radius":se.sheet?"0px":oe?"24px":`${ue.bubbleSize/2}px`,"--af-widget-accent":ue.accent??"#ffffff","--af-widget-live":ue.accent??"#16a34a","--af-widget-bg":ue.panelBackground,"--af-widget-fg":Re.fg,"--af-widget-scrim":Re.scrim,"--af-widget-avatar-scale":`${ue.avatarScale}`,"--af-widget-bounce-count":de===null?void 0:de==="forever"?"infinite":`${de}`,zIndex:ue.zIndex,...I},children:[jsxs("div",{className:"af-widget__frame",onAnimationEnd:le=>{le.animationName==="af-widget-bounce"&&te(null);},children:[jsx("div",{className:"af-widget__stage",children:jsx(bc,{fit:oe?"contain":void 0,usePictureInPicture:oe&&A})}),J&&jsx("div",{className:"af-widget__settle","aria-hidden":"true",children:jsx("span",{className:"af-widget__settle-spinner"})}),jsx(tm,{expanded:oe,title:e,live:De,connecting:Xe,elapsed:W,onCollapse:st,composer:tt?jsx(em,{}):r,dragHandlers:et}),jsx(qh,{expanded:oe,live:De,elapsed:W,label:t,onOpen:Fe,dragHandlers:et})]}),Ve&&n?.teaser&&jsx(Jh,{text:n.teaser.text,onAccept:fe,onDismiss:rt}),Ue&&jsx(Nh,{target:Ue.value.element,strong:Ue.value.strong,color:m?.highlightColor,leaving:Ue.leaving},`mark-${Ue.value.step}`),ye&&jsx(Wh,{target:ye.value.target,side:ye.value.side,avatar:pe,leaving:ye.leaving},`arrow-${ye.value.step}`)]})},Bw=Fw;function Vw(){let n=Ut(),e=Ua(),t=useCallback(()=>e.setOpen(true),[e]),r=useCallback(()=>e.setOpen(false),[e]),o=useCallback(()=>e.setOpen(!e.isOpen),[e]),s=useCallback(()=>{e.setOpen(true),n.isIdle&&n.start();},[e,n]),u=useCallback(()=>e.tourControlsRef.current?.start(),[e]),p=useCallback(()=>e.tourControlsRef.current?.stop(),[e]);return useMemo(()=>({isOpen:e.isOpen,stage:e.stage,open:t,close:r,toggle:o,openAndStart:s,tourState:e.tourState,startTour:u,stopTour:p}),[e.isOpen,e.stage,e.tourState,t,r,o,s,u,p])}var Uc="avatarfactory",Ww=1;var Hw=new Set(["host.info","context.set","context.event","cmd.open","cmd.close","cmd.start","cmd.stop","cmd.destroy","action.set","action.result","action.ui","action.check_result","page.result","page.changed","tour.result"]),Gw=new Set(["ready","resize","state","event","beacon","action.run","action.flow","action.check","page.call","tour.do"]),hm=(n,e)=>({ns:Uc,v:1,deployId:n,...e}),jw=(n,e)=>{if(n.origin!==e.origin||e.source!==void 0&&n.source!==e.source)return null;let t=n.data;return !t||typeof t!="object"||t.ns!==Uc||t.v!==1||t.deployId!==e.deployId||typeof t.type!="string"||!(e.direction==="from-loader"?Hw:Gw).has(t.type)?null:t},zw=(n,e,t,r)=>{n.postMessage(hm(t,r),e);};function qw(n,e){let{on:t,off:r}=Ut(),o=useRef(e);o.current=e,useEffect(()=>{let s=((...u)=>{o.current(...u);});return t(n,s),()=>r(n,s)},[t,r,n]);}function $w(n){let{registerAction:e}=Ut(),t=useRef(n);t.current=n;let r=typeof n.check=="function",o=JSON.stringify([n.name,n.description,n.params??null,n.kind??null,n.ui??null,r]);useEffect(()=>{if(!e)return;let{name:s,description:u,params:p,kind:h,ui:A}=t.current;return e({name:s,description:u,params:p,...h!==void 0&&{kind:h},...A!==void 0&&{ui:A},...r&&{check:(y,b,m)=>t.current.check(y,b,m)},handler:(y,b)=>t.current.handler(y,b)})},[e,o]);}function Zw(n){let{_actionFlowStore:e,_sendActionUi:t}=Ut(),r=useSyncExternalStore(e.subscribe,e.getSnapshot,e.getServerSnapshot),o=r&&(!n||r.name===n)?r:null,s=useCallback(h=>t("input",h,n),[t,n]),u=useCallback(()=>t("confirm"),[t]),p=useCallback(()=>t("cancel"),[t]);return {flow:o,input:s,confirm:u,cancel:p}}var kR=_p;export{bc as Avatar,to as AvatarConnectingLoader,p0 as AvatarProvider,Bw as AvatarWidget,Uc as BRIDGE_NAMESPACE,Ww as BRIDGE_VERSION,Ri as PaintPhase,xi as SessionPhase,Pi as TurnPhase,Bt as WIDGET_DEFAULTS,hm as buildEnvelope,jw as parseBridgeMessage,zw as postBridgeMessage,Hr as resolveWidgetAppearance,kR as useAvatar,$w as useAvatarAction,Zw as useAvatarActionFlow,qw as useAvatarEvent,Vw as useAvatarWidget};
|