pixi-live2d-display-advanced 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cubism2.es.js +1 -2
- package/dist/cubism2.js +1 -2
- package/dist/cubism2.min.js +1 -1
- package/dist/cubism4.es.js +1 -2
- package/dist/cubism4.js +1 -2
- package/dist/cubism4.min.js +1 -1
- package/dist/index.es.js +1 -2
- package/dist/index.js +1 -2
- package/dist/index.min.js +1 -1
- package/package.json +95 -95
- package/types/index.d.ts +0 -2
package/dist/cubism2.es.js
CHANGED
|
@@ -78,7 +78,7 @@ const config = {
|
|
|
78
78
|
preserveExpressionOnMotion: true,
|
|
79
79
|
cubism4: CubismConfig
|
|
80
80
|
};
|
|
81
|
-
const VERSION = "v0.5.
|
|
81
|
+
const VERSION = "v0.5.2";
|
|
82
82
|
const logger = {
|
|
83
83
|
log(tag, ...messages) {
|
|
84
84
|
if (config.logLevel <= config.LOG_LEVEL_VERBOSE) {
|
|
@@ -3730,7 +3730,6 @@ class SoundManager {
|
|
|
3730
3730
|
if (!(audio.media instanceof webaudio.WebAudioMedia)) {
|
|
3731
3731
|
reject(new Error(`Error: ${file} is not WebAudioMedia`));
|
|
3732
3732
|
}
|
|
3733
|
-
debugger;
|
|
3734
3733
|
resolve(audio);
|
|
3735
3734
|
}
|
|
3736
3735
|
});
|
package/dist/cubism2.js
CHANGED
|
@@ -79,7 +79,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
79
79
|
preserveExpressionOnMotion: true,
|
|
80
80
|
cubism4: CubismConfig
|
|
81
81
|
};
|
|
82
|
-
const VERSION = "v0.5.
|
|
82
|
+
const VERSION = "v0.5.2";
|
|
83
83
|
const logger = {
|
|
84
84
|
log(tag, ...messages) {
|
|
85
85
|
if (config.logLevel <= config.LOG_LEVEL_VERBOSE) {
|
|
@@ -3731,7 +3731,6 @@ var __async = (__this, __arguments, generator) => {
|
|
|
3731
3731
|
if (!(audio.media instanceof sound.webaudio.WebAudioMedia)) {
|
|
3732
3732
|
reject(new Error(`Error: ${file} is not WebAudioMedia`));
|
|
3733
3733
|
}
|
|
3734
|
-
debugger;
|
|
3735
3734
|
resolve(audio);
|
|
3736
3735
|
}
|
|
3737
3736
|
});
|
package/dist/cubism2.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@pixi/core"),require("@pixi/sound"),require("@pixi/display")):"function"==typeof define&&define.amd?define(["exports","@pixi/core","@pixi/sound","@pixi/display"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).PIXI=t.PIXI||{},t.PIXI.live2d=t.PIXI.live2d||{}),t.PIXI,t.PIXI,t.PIXI)}(this,(function(t,e,r,o){"use strict";var n=Object.defineProperty,i=Math.pow,s=(t,e,r)=>((t,e,r)=>e in t?n(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r)(t,"symbol"!=typeof e?e+"":e,r),a=(t,e,r)=>new Promise(((o,n)=>{var i=t=>{try{a(r.next(t))}catch(e){n(e)}},s=t=>{try{a(r.throw(t))}catch(e){n(e)}},a=t=>t.done?o(t.value):Promise.resolve(t.value).then(i,s);a((r=r.apply(t,e)).next())}));var l,u;(u=l||(l={})).supportMoreMaskDivisions=!0,u.setOpacityFromMotion=!1;const h={LOG_LEVEL_VERBOSE:0,LOG_LEVEL_WARNING:1,LOG_LEVEL_ERROR:2,LOG_LEVEL_NONE:999,logLevel:1,sound:!0,fftSize:512,motionSync:!0,motionFadingDuration:500,idleMotionFadingDuration:2e3,expressionFadingDuration:500,preserveExpressionOnMotion:!0,cubism4:l},c={log(t,...e){h.logLevel<=h.LOG_LEVEL_VERBOSE&&console.log(`[${t}]`,...e)},warn(t,...e){h.logLevel<=h.LOG_LEVEL_WARNING&&console.warn(`[${t}]`,...e)},error(t,...e){h.logLevel<=h.LOG_LEVEL_ERROR&&console.error(`[${t}]`,...e)}};function p(t,e,r){return t<e?e:t>r?r:t}function d(t,e){return Math.random()*(e-t)+t}function f(t,e,r,o,n){const i=e[o];null!==i&&typeof i===t&&(r[n]=i)}function y(t,e,r,o,n){const i=e[o];Array.isArray(i)&&(r[n]=i.filter((e=>null!==e&&typeof e===t)))}function m(t){let e=t.lastIndexOf("/");return-1!=e&&(t=t.slice(0,e)),e=t.lastIndexOf("/"),-1!==e&&(t=t.slice(e+1)),t}function g(t,e){const r=t.indexOf(e);-1!==r&&t.splice(r,1)}class v extends e.utils.EventEmitter{constructor(t,e){super(),s(this,"tag"),s(this,"settings"),s(this,"expressions",[]),s(this,"defaultExpression"),s(this,"currentExpression"),s(this,"reserveExpressionIndex",-1),s(this,"destroyed",!1),this.settings=t,this.tag=`ExpressionManager(${t.name})`}init(){this.defaultExpression=this.createExpression({},void 0),this.currentExpression=this.defaultExpression,this.stopAllExpressions()}loadExpression(t){return a(this,null,(function*(){if(!this.definitions[t])return void c.warn(this.tag,`Undefined expression at [${t}]`);if(null===this.expressions[t])return void c.warn(this.tag,`Cannot set expression at [${t}] because it's already failed in loading.`);if(this.expressions[t])return this.expressions[t];const e=yield this._loadExpression(t);return this.expressions[t]=e,e}))}_loadExpression(t){throw new Error("Not implemented.")}setRandomExpression(){return a(this,null,(function*(){if(this.definitions.length){const t=[];for(let e=0;e<this.definitions.length;e++)null!==this.expressions[e]&&this.expressions[e]!==this.currentExpression&&e!==this.reserveExpressionIndex&&t.push(e);if(t.length){const e=Math.floor(Math.random()*t.length);return this.setExpression(e)}}return!1}))}resetExpression(){this._setExpression(this.defaultExpression)}restoreExpression(){this._setExpression(this.currentExpression)}setExpression(t){return a(this,null,(function*(){if("number"!=typeof t&&(t=this.getExpressionIndex(t)),!(t>-1&&t<this.definitions.length))return!1;if(t===this.expressions.indexOf(this.currentExpression))return!1;this.reserveExpressionIndex=t;const e=yield this.loadExpression(t);return!(!e||this.reserveExpressionIndex!==t)&&(this.reserveExpressionIndex=-1,this.currentExpression=e,this._setExpression(e),!0)}))}update(t,e){return!this.isFinished()&&this.updateParameters(t,e)}destroy(){this.destroyed=!0,this.emit("destroy");this.definitions=void 0,this.expressions=void 0}}const b=40/7.5,x=1/150;class M{constructor(){s(this,"targetX",0),s(this,"targetY",0),s(this,"x",0),s(this,"y",0),s(this,"vx",0),s(this,"vy",0)}focus(t,e,r=!1){this.targetX=p(t,-1,1),this.targetY=p(e,-1,1),r&&(this.x=this.targetX,this.y=this.targetY)}update(t){const e=this.targetX-this.x,r=this.targetY-this.y;if(Math.abs(e)<.01&&Math.abs(r)<.01)return;const o=Math.sqrt(i(e,2)+i(r,2)),n=b/(1e3/t);let s=n*(e/o)-this.vx,a=n*(r/o)-this.vy;const l=Math.sqrt(i(s,2)+i(a,2)),u=n*x*t;l>u&&(s*=u/l,a*=u/l),this.vx+=s,this.vy+=a;const h=Math.sqrt(i(this.vx,2)+i(this.vy,2)),c=.5*(Math.sqrt(i(u,2)+8*u*o)-u);h>c&&(this.vx*=c/h,this.vy*=c/h),this.x+=this.vx,this.y+=this.vy}}var w="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function P(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function E(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if("function"==typeof e){var r=function t(){return this instanceof t?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach((function(e){var o=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(r,e,o.get?o:{enumerable:!0,get:function(){return t[e]}})})),r}var A,O,I,S,j,F,_,T,L,R,D,k,C,N,U,G,q,H,W,B,$,X,z,V,Y,K,J,Q,Z,tt={},et={exports:{}},rt=et.exports;function ot(){return I?O:(I=1,O=Error)}function nt(){return j?S:(j=1,S=EvalError)}function it(){return _?F:(_=1,F=RangeError)}function st(){return L?T:(L=1,T=ReferenceError)}function at(){return D?R:(D=1,R=SyntaxError)}function lt(){return C?k:(C=1,k=TypeError)}function ut(){return U?N:(U=1,N=URIError)}function ht(){if(W)return H;W=1;var t="undefined"!=typeof Symbol&&Symbol,e=q?G:(q=1,G=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var t={},e=Symbol("test"),r=Object(e);if("string"==typeof e)return!1;if("[object Symbol]"!==Object.prototype.toString.call(e))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(e in t[e]=42,t)return!1;if("function"==typeof Object.keys&&0!==Object.keys(t).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(t).length)return!1;var o=Object.getOwnPropertySymbols(t);if(1!==o.length||o[0]!==e)return!1;if(!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var n=Object.getOwnPropertyDescriptor(t,e);if(42!==n.value||!0!==n.enumerable)return!1}return!0});return H=function(){return"function"==typeof t&&("function"==typeof Symbol&&("symbol"==typeof t("foo")&&("symbol"==typeof Symbol("bar")&&e())))}}function ct(){if($)return B;$=1;var t={__proto__:null,foo:{}},e=Object;return B=function(){return{__proto__:t}.foo===t.foo&&!(t instanceof e)}}function pt(){if(Y)return V;Y=1;var t=function(){if(z)return X;z=1;var t=Object.prototype.toString,e=Math.max,r=function(t,e){for(var r=[],o=0;o<t.length;o+=1)r[o]=t[o];for(var n=0;n<e.length;n+=1)r[n+t.length]=e[n];return r};return X=function(o){var n=this;if("function"!=typeof n||"[object Function]"!==t.apply(n))throw new TypeError("Function.prototype.bind called on incompatible "+n);for(var i,s=function(t,e){for(var r=[],o=1,n=0;o<t.length;o+=1,n+=1)r[n]=t[o];return r}(arguments),a=e(0,n.length-s.length),l=[],u=0;u<a;u++)l[u]="$"+u;if(i=Function("binder","return function ("+function(t,e){for(var r="",o=0;o<t.length;o+=1)r+=t[o],o+1<t.length&&(r+=e);return r}(l,",")+"){ return binder.apply(this,arguments); }")((function(){if(this instanceof i){var t=n.apply(this,r(s,arguments));return Object(t)===t?t:this}return n.apply(o,r(s,arguments))})),n.prototype){var h=function(){};h.prototype=n.prototype,i.prototype=new h,h.prototype=null}return i},X}();return V=Function.prototype.bind||t}function dt(){if(J)return K;J=1;var t=Function.prototype.call,e=Object.prototype.hasOwnProperty,r=pt();return K=r.call(t,e)}function ft(){if(Z)return Q;var t;Z=1;var e=ot(),r=nt(),o=it(),n=st(),i=at(),s=lt(),a=ut(),l=Function,u=function(t){try{return l('"use strict"; return ('+t+").constructor;")()}catch(e){}},h=Object.getOwnPropertyDescriptor;if(h)try{h({},"")}catch(T){h=null}var c=function(){throw new s},p=h?function(){try{return c}catch(t){try{return h(arguments,"callee").get}catch(e){return c}}}():c,d=ht()(),f=ct()(),y=Object.getPrototypeOf||(f?function(t){return t.__proto__}:null),m={},g="undefined"!=typeof Uint8Array&&y?y(Uint8Array):t,v={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?t:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?t:ArrayBuffer,"%ArrayIteratorPrototype%":d&&y?y([][Symbol.iterator]()):t,"%AsyncFromSyncIteratorPrototype%":t,"%AsyncFunction%":m,"%AsyncGenerator%":m,"%AsyncGeneratorFunction%":m,"%AsyncIteratorPrototype%":m,"%Atomics%":"undefined"==typeof Atomics?t:Atomics,"%BigInt%":"undefined"==typeof BigInt?t:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?t:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?t:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?t:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":e,"%eval%":eval,"%EvalError%":r,"%Float32Array%":"undefined"==typeof Float32Array?t:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?t:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?t:FinalizationRegistry,"%Function%":l,"%GeneratorFunction%":m,"%Int8Array%":"undefined"==typeof Int8Array?t:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?t:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?t:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":d&&y?y(y([][Symbol.iterator]())):t,"%JSON%":"object"==typeof JSON?JSON:t,"%Map%":"undefined"==typeof Map?t:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&d&&y?y((new Map)[Symbol.iterator]()):t,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?t:Promise,"%Proxy%":"undefined"==typeof Proxy?t:Proxy,"%RangeError%":o,"%ReferenceError%":n,"%Reflect%":"undefined"==typeof Reflect?t:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?t:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&d&&y?y((new Set)[Symbol.iterator]()):t,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?t:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":d&&y?y(""[Symbol.iterator]()):t,"%Symbol%":d?Symbol:t,"%SyntaxError%":i,"%ThrowTypeError%":p,"%TypedArray%":g,"%TypeError%":s,"%Uint8Array%":"undefined"==typeof Uint8Array?t:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?t:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?t:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?t:Uint32Array,"%URIError%":a,"%WeakMap%":"undefined"==typeof WeakMap?t:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?t:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?t:WeakSet};if(y)try{null.error}catch(T){var b=y(y(T));v["%Error.prototype%"]=b}var x=function t(e){var r;if("%AsyncFunction%"===e)r=u("async function () {}");else if("%GeneratorFunction%"===e)r=u("function* () {}");else if("%AsyncGeneratorFunction%"===e)r=u("async function* () {}");else if("%AsyncGenerator%"===e){var o=t("%AsyncGeneratorFunction%");o&&(r=o.prototype)}else if("%AsyncIteratorPrototype%"===e){var n=t("%AsyncGenerator%");n&&y&&(r=y(n.prototype))}return v[e]=r,r},M={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},w=pt(),P=dt(),E=w.call(Function.call,Array.prototype.concat),A=w.call(Function.apply,Array.prototype.splice),O=w.call(Function.call,String.prototype.replace),I=w.call(Function.call,String.prototype.slice),S=w.call(Function.call,RegExp.prototype.exec),j=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,F=/\\(\\)?/g,_=function(t,e){var r,o=t;if(P(M,o)&&(o="%"+(r=M[o])[0]+"%"),P(v,o)){var n=v[o];if(n===m&&(n=x(o)),void 0===n&&!e)throw new s("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:r,name:o,value:n}}throw new i("intrinsic "+t+" does not exist!")};return Q=function(t,e){if("string"!=typeof t||0===t.length)throw new s("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof e)throw new s('"allowMissing" argument must be a boolean');if(null===S(/^%?[^%]*%?$/,t))throw new i("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=function(t){var e=I(t,0,1),r=I(t,-1);if("%"===e&&"%"!==r)throw new i("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==e)throw new i("invalid intrinsic syntax, expected opening `%`");var o=[];return O(t,j,(function(t,e,r,n){o[o.length]=r?O(n,F,"$1"):e||t})),o}(t),o=r.length>0?r[0]:"",n=_("%"+o+"%",e),a=n.name,l=n.value,u=!1,c=n.alias;c&&(o=c[0],A(r,E([0,1],c)));for(var p=1,d=!0;p<r.length;p+=1){var f=r[p],y=I(f,0,1),m=I(f,-1);if(('"'===y||"'"===y||"`"===y||'"'===m||"'"===m||"`"===m)&&y!==m)throw new i("property names with quotes must have matching quotes");if("constructor"!==f&&d||(u=!0),P(v,a="%"+(o+="."+f)+"%"))l=v[a];else if(null!=l){if(!(f in l)){if(!e)throw new s("base intrinsic for "+t+" exists, but the property is not available.");return}if(h&&p+1>=r.length){var g=h(l,f);l=(d=!!g)&&"get"in g&&!("originalValue"in g.get)?g.get:l[f]}else d=P(l,f),l=l[f];d&&!u&&(v[a]=l)}}return l},Q}var yt,mt,gt,vt,bt,xt,Mt,wt,Pt,Et,At,Ot,It,St={exports:{}};function jt(){if(mt)return yt;mt=1;var t=ft()("%Object.defineProperty%",!0)||!1;if(t)try{t({},"a",{value:1})}catch(e){t=!1}return yt=t}function Ft(){if(vt)return gt;vt=1;var t=ft()("%Object.getOwnPropertyDescriptor%",!0);if(t)try{t([],"length")}catch(e){t=null}return gt=t}function _t(){if(xt)return bt;xt=1;var t=jt(),e=at(),r=lt(),o=Ft();return bt=function(n,i,s){if(!n||"object"!=typeof n&&"function"!=typeof n)throw new r("`obj` must be an object or a function`");if("string"!=typeof i&&"symbol"!=typeof i)throw new r("`property` must be a string or a symbol`");if(arguments.length>3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new r("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new r("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new r("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new r("`loose`, if provided, must be a boolean");var a=arguments.length>3?arguments[3]:null,l=arguments.length>4?arguments[4]:null,u=arguments.length>5?arguments[5]:null,h=arguments.length>6&&arguments[6],c=!!o&&o(n,i);if(t)t(n,i,{configurable:null===u&&c?c.configurable:!u,enumerable:null===a&&c?c.enumerable:!a,value:s,writable:null===l&&c?c.writable:!l});else{if(!h&&(a||l||u))throw new e("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");n[i]=s}},bt}function Tt(){if(wt)return Mt;wt=1;var t=jt(),e=function(){return!!t};return e.hasArrayLengthDefineBug=function(){if(!t)return null;try{return 1!==t([],"length",{value:1}).length}catch(e){return!0}},Mt=e}function Lt(){if(Et)return Pt;Et=1;var t=ft(),e=_t(),r=Tt()(),o=Ft(),n=lt(),i=t("%Math.floor%");return Pt=function(t,s){if("function"!=typeof t)throw new n("`fn` is not a function");if("number"!=typeof s||s<0||s>4294967295||i(s)!==s)throw new n("`length` must be a positive 32-bit integer");var a=arguments.length>2&&!!arguments[2],l=!0,u=!0;if("length"in t&&o){var h=o(t,"length");h&&!h.configurable&&(l=!1),h&&!h.writable&&(u=!1)}return(l||u||!a)&&(r?e(t,"length",s,!0,!0):e(t,"length",s)),t},Pt}function Rt(){if(It)return Ot;It=1;var t=ft(),e=(At||(At=1,function(t){var e=pt(),r=ft(),o=Lt(),n=lt(),i=r("%Function.prototype.apply%"),s=r("%Function.prototype.call%"),a=r("%Reflect.apply%",!0)||e.call(s,i),l=jt(),u=r("%Math.max%");t.exports=function(t){if("function"!=typeof t)throw new n("a function is required");var r=a(e,s,arguments);return o(r,1+u(0,t.length-(arguments.length-1)),!0)};var h=function(){return a(e,i,arguments)};l?l(t.exports,"apply",{value:h}):t.exports.apply=h}(St)),St.exports),r=e(t("String.prototype.indexOf"));return Ot=function(o,n){var i=t(o,!!n);return"function"==typeof i&&r(o,".prototype.")>-1?e(i):i}}const Dt=E(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var kt,Ct,Nt,Ut,Gt,qt,Ht,Wt,Bt,$t,Xt,zt,Vt,Yt,Kt;function Jt(){if(Ct)return kt;Ct=1;var t="function"==typeof Map&&Map.prototype,e=Object.getOwnPropertyDescriptor&&t?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,r=t&&e&&"function"==typeof e.get?e.get:null,o=t&&Map.prototype.forEach,n="function"==typeof Set&&Set.prototype,i=Object.getOwnPropertyDescriptor&&n?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,s=n&&i&&"function"==typeof i.get?i.get:null,a=n&&Set.prototype.forEach,l="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,u="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,h="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,c=Boolean.prototype.valueOf,p=Object.prototype.toString,d=Function.prototype.toString,f=String.prototype.match,y=String.prototype.slice,m=String.prototype.replace,g=String.prototype.toUpperCase,v=String.prototype.toLowerCase,b=RegExp.prototype.test,x=Array.prototype.concat,M=Array.prototype.join,P=Array.prototype.slice,E=Math.floor,A="function"==typeof BigInt?BigInt.prototype.valueOf:null,O=Object.getOwnPropertySymbols,I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,S="function"==typeof Symbol&&"object"==typeof Symbol.iterator,j="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===S||"symbol")?Symbol.toStringTag:null,F=Object.prototype.propertyIsEnumerable,_=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(t){return t.__proto__}:null);function T(t,e){if(t===1/0||t===-1/0||t!=t||t&&t>-1e3&&t<1e3||b.call(/e/,e))return e;var r=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof t){var o=t<0?-E(-t):E(t);if(o!==t){var n=String(o),i=y.call(e,n.length+1);return m.call(n,r,"$&_")+"."+m.call(m.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return m.call(e,r,"$&_")}var L=Dt,R=L.custom,D=G(R)?R:null;function k(t,e,r){var o="double"===(r.quoteStyle||e)?'"':"'";return o+t+o}function C(t){return m.call(String(t),/"/g,""")}function N(t){return!("[object Array]"!==W(t)||j&&"object"==typeof t&&j in t)}function U(t){return!("[object RegExp]"!==W(t)||j&&"object"==typeof t&&j in t)}function G(t){if(S)return t&&"object"==typeof t&&t instanceof Symbol;if("symbol"==typeof t)return!0;if(!t||"object"!=typeof t||!I)return!1;try{return I.call(t),!0}catch(e){}return!1}kt=function t(e,n,i,p){var g=n||{};if(H(g,"quoteStyle")&&"single"!==g.quoteStyle&&"double"!==g.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(H(g,"maxStringLength")&&("number"==typeof g.maxStringLength?g.maxStringLength<0&&g.maxStringLength!==1/0:null!==g.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var b=!H(g,"customInspect")||g.customInspect;if("boolean"!=typeof b&&"symbol"!==b)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(H(g,"indent")&&null!==g.indent&&"\t"!==g.indent&&!(parseInt(g.indent,10)===g.indent&&g.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(H(g,"numericSeparator")&&"boolean"!=typeof g.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var E=g.numericSeparator;if(void 0===e)return"undefined";if(null===e)return"null";if("boolean"==typeof e)return e?"true":"false";if("string"==typeof e)return $(e,g);if("number"==typeof e){if(0===e)return 1/0/e>0?"0":"-0";var O=String(e);return E?T(e,O):O}if("bigint"==typeof e){var R=String(e)+"n";return E?T(e,R):R}var q=void 0===g.depth?5:g.depth;if(void 0===i&&(i=0),i>=q&&q>0&&"object"==typeof e)return N(e)?"[Array]":"[Object]";var X=function(t,e){var r;if("\t"===t.indent)r="\t";else{if(!("number"==typeof t.indent&&t.indent>0))return null;r=M.call(Array(t.indent+1)," ")}return{base:r,prev:M.call(Array(e+1),r)}}(g,i);if(void 0===p)p=[];else if(B(p,e)>=0)return"[Circular]";function Q(e,r,o){if(r&&(p=P.call(p)).push(r),o){var n={depth:g.depth};return H(g,"quoteStyle")&&(n.quoteStyle=g.quoteStyle),t(e,n,i+1,p)}return t(e,g,i+1,p)}if("function"==typeof e&&!U(e)){var Z=function(t){if(t.name)return t.name;var e=f.call(d.call(t),/^function\s*([\w$]+)/);if(e)return e[1];return null}(e),tt=J(e,Q);return"[Function"+(Z?": "+Z:" (anonymous)")+"]"+(tt.length>0?" { "+M.call(tt,", ")+" }":"")}if(G(e)){var et=S?m.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):I.call(e);return"object"!=typeof e||S?et:z(et)}if(function(t){if(!t||"object"!=typeof t)return!1;if("undefined"!=typeof HTMLElement&&t instanceof HTMLElement)return!0;return"string"==typeof t.nodeName&&"function"==typeof t.getAttribute}(e)){for(var rt="<"+v.call(String(e.nodeName)),ot=e.attributes||[],nt=0;nt<ot.length;nt++)rt+=" "+ot[nt].name+"="+k(C(ot[nt].value),"double",g);return rt+=">",e.childNodes&&e.childNodes.length&&(rt+="..."),rt+="</"+v.call(String(e.nodeName))+">"}if(N(e)){if(0===e.length)return"[]";var it=J(e,Q);return X&&!function(t){for(var e=0;e<t.length;e++)if(B(t[e],"\n")>=0)return!1;return!0}(it)?"["+K(it,X)+"]":"[ "+M.call(it,", ")+" ]"}if(function(t){return!("[object Error]"!==W(t)||j&&"object"==typeof t&&j in t)}(e)){var st=J(e,Q);return"cause"in Error.prototype||!("cause"in e)||F.call(e,"cause")?0===st.length?"["+String(e)+"]":"{ ["+String(e)+"] "+M.call(st,", ")+" }":"{ ["+String(e)+"] "+M.call(x.call("[cause]: "+Q(e.cause),st),", ")+" }"}if("object"==typeof e&&b){if(D&&"function"==typeof e[D]&&L)return L(e,{depth:q-i});if("symbol"!==b&&"function"==typeof e.inspect)return e.inspect()}if(function(t){if(!r||!t||"object"!=typeof t)return!1;try{r.call(t);try{s.call(t)}catch(rt){return!0}return t instanceof Map}catch(e){}return!1}(e)){var at=[];return o&&o.call(e,(function(t,r){at.push(Q(r,e,!0)+" => "+Q(t,e))})),Y("Map",r.call(e),at,X)}if(function(t){if(!s||!t||"object"!=typeof t)return!1;try{s.call(t);try{r.call(t)}catch(e){return!0}return t instanceof Set}catch(o){}return!1}(e)){var lt=[];return a&&a.call(e,(function(t){lt.push(Q(t,e))})),Y("Set",s.call(e),lt,X)}if(function(t){if(!l||!t||"object"!=typeof t)return!1;try{l.call(t,l);try{u.call(t,u)}catch(rt){return!0}return t instanceof WeakMap}catch(e){}return!1}(e))return V("WeakMap");if(function(t){if(!u||!t||"object"!=typeof t)return!1;try{u.call(t,u);try{l.call(t,l)}catch(rt){return!0}return t instanceof WeakSet}catch(e){}return!1}(e))return V("WeakSet");if(function(t){if(!h||!t||"object"!=typeof t)return!1;try{return h.call(t),!0}catch(e){}return!1}(e))return V("WeakRef");if(function(t){return!("[object Number]"!==W(t)||j&&"object"==typeof t&&j in t)}(e))return z(Q(Number(e)));if(function(t){if(!t||"object"!=typeof t||!A)return!1;try{return A.call(t),!0}catch(e){}return!1}(e))return z(Q(A.call(e)));if(function(t){return!("[object Boolean]"!==W(t)||j&&"object"==typeof t&&j in t)}(e))return z(c.call(e));if(function(t){return!("[object String]"!==W(t)||j&&"object"==typeof t&&j in t)}(e))return z(Q(String(e)));if("undefined"!=typeof window&&e===window)return"{ [object Window] }";if(e===w)return"{ [object globalThis] }";if(!function(t){return!("[object Date]"!==W(t)||j&&"object"==typeof t&&j in t)}(e)&&!U(e)){var ut=J(e,Q),ht=_?_(e)===Object.prototype:e instanceof Object||e.constructor===Object,ct=e instanceof Object?"":"null prototype",pt=!ht&&j&&Object(e)===e&&j in e?y.call(W(e),8,-1):ct?"Object":"",dt=(ht||"function"!=typeof e.constructor?"":e.constructor.name?e.constructor.name+" ":"")+(pt||ct?"["+M.call(x.call([],pt||[],ct||[]),": ")+"] ":"");return 0===ut.length?dt+"{}":X?dt+"{"+K(ut,X)+"}":dt+"{ "+M.call(ut,", ")+" }"}return String(e)};var q=Object.prototype.hasOwnProperty||function(t){return t in this};function H(t,e){return q.call(t,e)}function W(t){return p.call(t)}function B(t,e){if(t.indexOf)return t.indexOf(e);for(var r=0,o=t.length;r<o;r++)if(t[r]===e)return r;return-1}function $(t,e){if(t.length>e.maxStringLength){var r=t.length-e.maxStringLength,o="... "+r+" more character"+(r>1?"s":"");return $(y.call(t,0,e.maxStringLength),e)+o}return k(m.call(m.call(t,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,X),"single",e)}function X(t){var e=t.charCodeAt(0),r={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return r?"\\"+r:"\\x"+(e<16?"0":"")+g.call(e.toString(16))}function z(t){return"Object("+t+")"}function V(t){return t+" { ? }"}function Y(t,e,r,o){return t+" ("+e+") {"+(o?K(r,o):M.call(r,", "))+"}"}function K(t,e){if(0===t.length)return"";var r="\n"+e.prev+e.base;return r+M.call(t,","+r)+"\n"+e.prev}function J(t,e){var r=N(t),o=[];if(r){o.length=t.length;for(var n=0;n<t.length;n++)o[n]=H(t,n)?e(t[n],t):""}var i,s="function"==typeof O?O(t):[];if(S){i={};for(var a=0;a<s.length;a++)i["$"+s[a]]=s[a]}for(var l in t)H(t,l)&&(r&&String(Number(l))===l&&l<t.length||S&&i["$"+l]instanceof Symbol||(b.call(/[^\w$]/,l)?o.push(e(l,t)+": "+e(t[l],t)):o.push(l+": "+e(t[l],t))));if("function"==typeof O)for(var u=0;u<s.length;u++)F.call(t,s[u])&&o.push("["+e(s[u])+"]: "+e(t[s[u]],t));return o}return kt}function Qt(){if(Ut)return Nt;Ut=1;var t=ft(),e=Rt(),r=Jt(),o=lt(),n=t("%WeakMap%",!0),i=t("%Map%",!0),s=e("WeakMap.prototype.get",!0),a=e("WeakMap.prototype.set",!0),l=e("WeakMap.prototype.has",!0),u=e("Map.prototype.get",!0),h=e("Map.prototype.set",!0),c=e("Map.prototype.has",!0),p=function(t,e){for(var r,o=t;null!==(r=o.next);o=r)if(r.key===e)return o.next=r.next,r.next=t.next,t.next=r,r};return Nt=function(){var t,e,d,f={assert:function(t){if(!f.has(t))throw new o("Side channel does not contain "+r(t))},get:function(r){if(n&&r&&("object"==typeof r||"function"==typeof r)){if(t)return s(t,r)}else if(i){if(e)return u(e,r)}else if(d)return function(t,e){var r=p(t,e);return r&&r.value}(d,r)},has:function(r){if(n&&r&&("object"==typeof r||"function"==typeof r)){if(t)return l(t,r)}else if(i){if(e)return c(e,r)}else if(d)return function(t,e){return!!p(t,e)}(d,r);return!1},set:function(r,o){n&&r&&("object"==typeof r||"function"==typeof r)?(t||(t=new n),a(t,r,o)):i?(e||(e=new i),h(e,r,o)):(d||(d={key:{},next:null}),function(t,e,r){var o=p(t,e);o?o.value=r:t.next={key:e,next:t.next,value:r}}(d,r,o))}};return f}}function Zt(){if(qt)return Gt;qt=1;var t=String.prototype.replace,e=/%20/g,r="RFC3986";return Gt={default:r,formatters:{RFC1738:function(r){return t.call(r,e,"+")},RFC3986:function(t){return String(t)}},RFC1738:"RFC1738",RFC3986:r}}function te(){if(Wt)return Ht;Wt=1;var t=Zt(),e=Object.prototype.hasOwnProperty,r=Array.isArray,o=function(){for(var t=[],e=0;e<256;++e)t.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return t}(),n=function(t,e){for(var r=e&&e.plainObjects?Object.create(null):{},o=0;o<t.length;++o)void 0!==t[o]&&(r[o]=t[o]);return r},i=1024;return Ht={arrayToObject:n,assign:function(t,e){return Object.keys(e).reduce((function(t,r){return t[r]=e[r],t}),t)},combine:function(t,e){return[].concat(t,e)},compact:function(t){for(var e=[{obj:{o:t},prop:"o"}],o=[],n=0;n<e.length;++n)for(var i=e[n],s=i.obj[i.prop],a=Object.keys(s),l=0;l<a.length;++l){var u=a[l],h=s[u];"object"==typeof h&&null!==h&&-1===o.indexOf(h)&&(e.push({obj:s,prop:u}),o.push(h))}return function(t){for(;t.length>1;){var e=t.pop(),o=e.obj[e.prop];if(r(o)){for(var n=[],i=0;i<o.length;++i)void 0!==o[i]&&n.push(o[i]);e.obj[e.prop]=n}}}(e),t},decode:function(t,e,r){var o=t.replace(/\+/g," ");if("iso-8859-1"===r)return o.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(o)}catch(n){return o}},encode:function(e,r,n,s,a){if(0===e.length)return e;var l=e;if("symbol"==typeof e?l=Symbol.prototype.toString.call(e):"string"!=typeof e&&(l=String(e)),"iso-8859-1"===n)return escape(l).replace(/%u[0-9a-f]{4}/gi,(function(t){return"%26%23"+parseInt(t.slice(2),16)+"%3B"}));for(var u="",h=0;h<l.length;h+=i){for(var c=l.length>=i?l.slice(h,h+i):l,p=[],d=0;d<c.length;++d){var f=c.charCodeAt(d);45===f||46===f||95===f||126===f||f>=48&&f<=57||f>=65&&f<=90||f>=97&&f<=122||a===t.RFC1738&&(40===f||41===f)?p[p.length]=c.charAt(d):f<128?p[p.length]=o[f]:f<2048?p[p.length]=o[192|f>>6]+o[128|63&f]:f<55296||f>=57344?p[p.length]=o[224|f>>12]+o[128|f>>6&63]+o[128|63&f]:(d+=1,f=65536+((1023&f)<<10|1023&c.charCodeAt(d)),p[p.length]=o[240|f>>18]+o[128|f>>12&63]+o[128|f>>6&63]+o[128|63&f])}u+=p.join("")}return u},isBuffer:function(t){return!(!t||"object"!=typeof t)&&!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},isRegExp:function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},maybeMap:function(t,e){if(r(t)){for(var o=[],n=0;n<t.length;n+=1)o.push(e(t[n]));return o}return e(t)},merge:function t(o,i,s){if(!i)return o;if("object"!=typeof i){if(r(o))o.push(i);else{if(!o||"object"!=typeof o)return[o,i];(s&&(s.plainObjects||s.allowPrototypes)||!e.call(Object.prototype,i))&&(o[i]=!0)}return o}if(!o||"object"!=typeof o)return[o].concat(i);var a=o;return r(o)&&!r(i)&&(a=n(o,s)),r(o)&&r(i)?(i.forEach((function(r,n){if(e.call(o,n)){var i=o[n];i&&"object"==typeof i&&r&&"object"==typeof r?o[n]=t(i,r,s):o.push(r)}else o[n]=r})),o):Object.keys(i).reduce((function(r,o){var n=i[o];return e.call(r,o)?r[o]=t(r[o],n,s):r[o]=n,r}),a)}}}function ee(){if($t)return Bt;$t=1;var t=Qt(),e=te(),r=Zt(),o=Object.prototype.hasOwnProperty,n={brackets:function(t){return t+"[]"},comma:"comma",indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},i=Array.isArray,s=Array.prototype.push,a=function(t,e){s.apply(t,i(e)?e:[e])},l=Date.prototype.toISOString,u=r.default,h={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:e.encode,encodeValuesOnly:!1,format:u,formatter:r.formatters[u],indices:!1,serializeDate:function(t){return l.call(t)},skipNulls:!1,strictNullHandling:!1},c={},p=function r(o,n,s,l,u,p,d,f,y,m,g,v,b,x,M,w,P,E){for(var A,O=o,I=E,S=0,j=!1;void 0!==(I=I.get(c))&&!j;){var F=I.get(o);if(S+=1,void 0!==F){if(F===S)throw new RangeError("Cyclic object value");j=!0}void 0===I.get(c)&&(S=0)}if("function"==typeof m?O=m(n,O):O instanceof Date?O=b(O):"comma"===s&&i(O)&&(O=e.maybeMap(O,(function(t){return t instanceof Date?b(t):t}))),null===O){if(p)return y&&!w?y(n,h.encoder,P,"key",x):n;O=""}if("string"==typeof(A=O)||"number"==typeof A||"boolean"==typeof A||"symbol"==typeof A||"bigint"==typeof A||e.isBuffer(O))return y?[M(w?n:y(n,h.encoder,P,"key",x))+"="+M(y(O,h.encoder,P,"value",x))]:[M(n)+"="+M(String(O))];var _,T=[];if(void 0===O)return T;if("comma"===s&&i(O))w&&y&&(O=e.maybeMap(O,y)),_=[{value:O.length>0?O.join(",")||null:void 0}];else if(i(m))_=m;else{var L=Object.keys(O);_=g?L.sort(g):L}var R=f?n.replace(/\./g,"%2E"):n,D=l&&i(O)&&1===O.length?R+"[]":R;if(u&&i(O)&&0===O.length)return D+"[]";for(var k=0;k<_.length;++k){var C=_[k],N="object"==typeof C&&void 0!==C.value?C.value:O[C];if(!d||null!==N){var U=v&&f?C.replace(/\./g,"%2E"):C,G=i(O)?"function"==typeof s?s(D,U):D:D+(v?"."+U:"["+U+"]");E.set(o,S);var q=t();q.set(c,E),a(T,r(N,G,s,l,u,p,d,f,"comma"===s&&w&&i(O)?null:y,m,g,v,b,x,M,w,P,q))}}return T};return Bt=function(e,s){var l,u=e,c=function(t){if(!t)return h;if(void 0!==t.allowEmptyArrays&&"boolean"!=typeof t.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==t.encodeDotInKeys&&"boolean"!=typeof t.encodeDotInKeys)throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==t.encoder&&void 0!==t.encoder&&"function"!=typeof t.encoder)throw new TypeError("Encoder has to be a function.");var e=t.charset||h.charset;if(void 0!==t.charset&&"utf-8"!==t.charset&&"iso-8859-1"!==t.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var s=r.default;if(void 0!==t.format){if(!o.call(r.formatters,t.format))throw new TypeError("Unknown format option provided.");s=t.format}var a,l=r.formatters[s],u=h.filter;if(("function"==typeof t.filter||i(t.filter))&&(u=t.filter),a=t.arrayFormat in n?t.arrayFormat:"indices"in t?t.indices?"indices":"repeat":h.arrayFormat,"commaRoundTrip"in t&&"boolean"!=typeof t.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var c=void 0===t.allowDots?!0===t.encodeDotInKeys||h.allowDots:!!t.allowDots;return{addQueryPrefix:"boolean"==typeof t.addQueryPrefix?t.addQueryPrefix:h.addQueryPrefix,allowDots:c,allowEmptyArrays:"boolean"==typeof t.allowEmptyArrays?!!t.allowEmptyArrays:h.allowEmptyArrays,arrayFormat:a,charset:e,charsetSentinel:"boolean"==typeof t.charsetSentinel?t.charsetSentinel:h.charsetSentinel,commaRoundTrip:t.commaRoundTrip,delimiter:void 0===t.delimiter?h.delimiter:t.delimiter,encode:"boolean"==typeof t.encode?t.encode:h.encode,encodeDotInKeys:"boolean"==typeof t.encodeDotInKeys?t.encodeDotInKeys:h.encodeDotInKeys,encoder:"function"==typeof t.encoder?t.encoder:h.encoder,encodeValuesOnly:"boolean"==typeof t.encodeValuesOnly?t.encodeValuesOnly:h.encodeValuesOnly,filter:u,format:s,formatter:l,serializeDate:"function"==typeof t.serializeDate?t.serializeDate:h.serializeDate,skipNulls:"boolean"==typeof t.skipNulls?t.skipNulls:h.skipNulls,sort:"function"==typeof t.sort?t.sort:null,strictNullHandling:"boolean"==typeof t.strictNullHandling?t.strictNullHandling:h.strictNullHandling}}(s);"function"==typeof c.filter?u=(0,c.filter)("",u):i(c.filter)&&(l=c.filter);var d=[];if("object"!=typeof u||null===u)return"";var f=n[c.arrayFormat],y="comma"===f&&c.commaRoundTrip;l||(l=Object.keys(u)),c.sort&&l.sort(c.sort);for(var m=t(),g=0;g<l.length;++g){var v=l[g];c.skipNulls&&null===u[v]||a(d,p(u[v],v,f,y,c.allowEmptyArrays,c.strictNullHandling,c.skipNulls,c.encodeDotInKeys,c.encode?c.encoder:null,c.filter,c.sort,c.allowDots,c.serializeDate,c.format,c.formatter,c.encodeValuesOnly,c.charset,m))}var b=d.join(c.delimiter),x=!0===c.addQueryPrefix?"?":"";return c.charsetSentinel&&("iso-8859-1"===c.charset?x+="utf8=%26%2310003%3B&":x+="utf8=%E2%9C%93&"),b.length>0?x+b:""}}function re(){if(zt)return Xt;zt=1;var t=te(),e=Object.prototype.hasOwnProperty,r=Array.isArray,o={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:t.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},n=function(t){return t.replace(/&#(\d+);/g,(function(t,e){return String.fromCharCode(parseInt(e,10))}))},i=function(t,e){return t&&"string"==typeof t&&e.comma&&t.indexOf(",")>-1?t.split(","):t},s=function(t,r,o,n){if(t){var s=o.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,a=/(\[[^[\]]*])/g,l=o.depth>0&&/(\[[^[\]]*])/.exec(s),u=l?s.slice(0,l.index):s,h=[];if(u){if(!o.plainObjects&&e.call(Object.prototype,u)&&!o.allowPrototypes)return;h.push(u)}for(var c=0;o.depth>0&&null!==(l=a.exec(s))&&c<o.depth;){if(c+=1,!o.plainObjects&&e.call(Object.prototype,l[1].slice(1,-1))&&!o.allowPrototypes)return;h.push(l[1])}return l&&h.push("["+s.slice(l.index)+"]"),function(t,e,r,o){for(var n=o?e:i(e,r),s=t.length-1;s>=0;--s){var a,l=t[s];if("[]"===l&&r.parseArrays)a=r.allowEmptyArrays&&""===n?[]:[].concat(n);else{a=r.plainObjects?Object.create(null):{};var u="["===l.charAt(0)&&"]"===l.charAt(l.length-1)?l.slice(1,-1):l,h=r.decodeDotInKeys?u.replace(/%2E/g,"."):u,c=parseInt(h,10);r.parseArrays||""!==h?!isNaN(c)&&l!==h&&String(c)===h&&c>=0&&r.parseArrays&&c<=r.arrayLimit?(a=[])[c]=n:"__proto__"!==h&&(a[h]=n):a={0:n}}n=a}return n}(h,r,o,n)}};return Xt=function(a,l){var u=function(e){if(!e)return o;if(void 0!==e.allowEmptyArrays&&"boolean"!=typeof e.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==e.decodeDotInKeys&&"boolean"!=typeof e.decodeDotInKeys)throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var r=void 0===e.charset?o.charset:e.charset,n=void 0===e.duplicates?o.duplicates:e.duplicates;if("combine"!==n&&"first"!==n&&"last"!==n)throw new TypeError("The duplicates option must be either combine, first, or last");return{allowDots:void 0===e.allowDots?!0===e.decodeDotInKeys||o.allowDots:!!e.allowDots,allowEmptyArrays:"boolean"==typeof e.allowEmptyArrays?!!e.allowEmptyArrays:o.allowEmptyArrays,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:o.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:o.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:o.arrayLimit,charset:r,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:o.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:o.comma,decodeDotInKeys:"boolean"==typeof e.decodeDotInKeys?e.decodeDotInKeys:o.decodeDotInKeys,decoder:"function"==typeof e.decoder?e.decoder:o.decoder,delimiter:"string"==typeof e.delimiter||t.isRegExp(e.delimiter)?e.delimiter:o.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:o.depth,duplicates:n,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:o.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:o.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:o.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:o.strictNullHandling}}(l);if(""===a||null==a)return u.plainObjects?Object.create(null):{};for(var h="string"==typeof a?function(s,a){var l,u={__proto__:null},h=a.ignoreQueryPrefix?s.replace(/^\?/,""):s,c=a.parameterLimit===1/0?void 0:a.parameterLimit,p=h.split(a.delimiter,c),d=-1,f=a.charset;if(a.charsetSentinel)for(l=0;l<p.length;++l)0===p[l].indexOf("utf8=")&&("utf8=%E2%9C%93"===p[l]?f="utf-8":"utf8=%26%2310003%3B"===p[l]&&(f="iso-8859-1"),d=l,l=p.length);for(l=0;l<p.length;++l)if(l!==d){var y,m,g=p[l],v=g.indexOf("]="),b=-1===v?g.indexOf("="):v+1;-1===b?(y=a.decoder(g,o.decoder,f,"key"),m=a.strictNullHandling?null:""):(y=a.decoder(g.slice(0,b),o.decoder,f,"key"),m=t.maybeMap(i(g.slice(b+1),a),(function(t){return a.decoder(t,o.decoder,f,"value")}))),m&&a.interpretNumericEntities&&"iso-8859-1"===f&&(m=n(m)),g.indexOf("[]=")>-1&&(m=r(m)?[m]:m);var x=e.call(u,y);x&&"combine"===a.duplicates?u[y]=t.combine(u[y],m):x&&"last"!==a.duplicates||(u[y]=m)}return u}(a,u):a,c=u.plainObjects?Object.create(null):{},p=Object.keys(h),d=0;d<p.length;++d){var f=p[d],y=s(f,h[f],u,"string"==typeof a);c=t.merge(c,y,u)}return!0===u.allowSparse?c:t.compact(c)}}function oe(){if(Yt)return Vt;Yt=1;var t=ee(),e=re();return Vt={formats:Zt(),parse:e,stringify:t}}const ne=P(function(){if(Kt)return tt;Kt=1;var t,e,r=(A||(A=1,t=et,e=et.exports,function(r){var o=e&&!e.nodeType&&e,n=t&&!t.nodeType&&t,i="object"==typeof w&&w;i.global!==i&&i.window!==i&&i.self!==i||(r=i);var s,a,l=2147483647,u=36,h=1,c=26,p=38,d=700,f=72,y=128,m="-",g=/^xn--/,v=/[^\x20-\x7E]/,b=/[\x2E\u3002\uFF0E\uFF61]/g,x={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},M=u-h,P=Math.floor,E=String.fromCharCode;function A(t){throw new RangeError(x[t])}function O(t,e){for(var r=t.length,o=[];r--;)o[r]=e(t[r]);return o}function I(t,e){var r=t.split("@"),o="";return r.length>1&&(o=r[0]+"@",t=r[1]),o+O((t=t.replace(b,".")).split("."),e).join(".")}function S(t){for(var e,r,o=[],n=0,i=t.length;n<i;)(e=t.charCodeAt(n++))>=55296&&e<=56319&&n<i?56320==(64512&(r=t.charCodeAt(n++)))?o.push(((1023&e)<<10)+(1023&r)+65536):(o.push(e),n--):o.push(e);return o}function j(t){return O(t,(function(t){var e="";return t>65535&&(e+=E((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+E(t)})).join("")}function F(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function _(t,e,r){var o=0;for(t=r?P(t/d):t>>1,t+=P(t/e);t>M*c>>1;o+=u)t=P(t/M);return P(o+(M+1)*t/(t+p))}function T(t){var e,r,o,n,i,s,a,p,d,g,v,b=[],x=t.length,M=0,w=y,E=f;for((r=t.lastIndexOf(m))<0&&(r=0),o=0;o<r;++o)t.charCodeAt(o)>=128&&A("not-basic"),b.push(t.charCodeAt(o));for(n=r>0?r+1:0;n<x;){for(i=M,s=1,a=u;n>=x&&A("invalid-input"),((p=(v=t.charCodeAt(n++))-48<10?v-22:v-65<26?v-65:v-97<26?v-97:u)>=u||p>P((l-M)/s))&&A("overflow"),M+=p*s,!(p<(d=a<=E?h:a>=E+c?c:a-E));a+=u)s>P(l/(g=u-d))&&A("overflow"),s*=g;E=_(M-i,e=b.length+1,0==i),P(M/e)>l-w&&A("overflow"),w+=P(M/e),M%=e,b.splice(M++,0,w)}return j(b)}function L(t){var e,r,o,n,i,s,a,p,d,g,v,b,x,M,w,O=[];for(b=(t=S(t)).length,e=y,r=0,i=f,s=0;s<b;++s)(v=t[s])<128&&O.push(E(v));for(o=n=O.length,n&&O.push(m);o<b;){for(a=l,s=0;s<b;++s)(v=t[s])>=e&&v<a&&(a=v);for(a-e>P((l-r)/(x=o+1))&&A("overflow"),r+=(a-e)*x,e=a,s=0;s<b;++s)if((v=t[s])<e&&++r>l&&A("overflow"),v==e){for(p=r,d=u;!(p<(g=d<=i?h:d>=i+c?c:d-i));d+=u)w=p-g,M=u-g,O.push(E(F(g+w%M,0))),p=P(w/M);O.push(E(F(p,0))),i=_(r,x,o==n),r=0,++o}++r,++e}return O.join("")}if(s={version:"1.4.1",ucs2:{decode:S,encode:j},decode:T,encode:L,toASCII:function(t){return I(t,(function(t){return v.test(t)?"xn--"+L(t):t}))},toUnicode:function(t){return I(t,(function(t){return g.test(t)?T(t.slice(4).toLowerCase()):t}))}},o&&n)if(t.exports==o)n.exports=s;else for(a in s)s.hasOwnProperty(a)&&(o[a]=s[a]);else r.punycode=s}(rt)),et.exports);function o(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var n=/^([a-z0-9.+-]+:)/i,i=/:[0-9]*$/,s=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,a=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),l=["'"].concat(a),u=["%","/","?",";","#"].concat(l),h=["/","?","#"],c=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,d={javascript:!0,"javascript:":!0},f={javascript:!0,"javascript:":!0},y={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},m=oe();function g(t,e,r){if(t&&"object"==typeof t&&t instanceof o)return t;var n=new o;return n.parse(t,e,r),n}return o.prototype.parse=function(t,e,o){if("string"!=typeof t)throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var i=t.indexOf("?"),a=-1!==i&&i<t.indexOf("#")?"?":"#",g=t.split(a);g[0]=g[0].replace(/\\/g,"/");var v=t=g.join(a);if(v=v.trim(),!o&&1===t.split("#").length){var b=s.exec(v);if(b)return this.path=v,this.href=v,this.pathname=b[1],b[2]?(this.search=b[2],this.query=e?m.parse(this.search.substr(1)):this.search.substr(1)):e&&(this.search="",this.query={}),this}var x=n.exec(v);if(x){var M=(x=x[0]).toLowerCase();this.protocol=M,v=v.substr(x.length)}if(o||x||v.match(/^\/\/[^@/]+@[^@/]+/)){var w="//"===v.substr(0,2);!w||x&&f[x]||(v=v.substr(2),this.slashes=!0)}if(!f[x]&&(w||x&&!y[x])){for(var P,E,A=-1,O=0;O<h.length;O++){-1!==(I=v.indexOf(h[O]))&&(-1===A||I<A)&&(A=I)}-1!==(E=-1===A?v.lastIndexOf("@"):v.lastIndexOf("@",A))&&(P=v.slice(0,E),v=v.slice(E+1),this.auth=decodeURIComponent(P)),A=-1;for(O=0;O<u.length;O++){var I;-1!==(I=v.indexOf(u[O]))&&(-1===A||I<A)&&(A=I)}-1===A&&(A=v.length),this.host=v.slice(0,A),v=v.slice(A),this.parseHost(),this.hostname=this.hostname||"";var S="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!S)for(var j=this.hostname.split(/\./),F=(O=0,j.length);O<F;O++){var _=j[O];if(_&&!_.match(c)){for(var T="",L=0,R=_.length;L<R;L++)_.charCodeAt(L)>127?T+="x":T+=_[L];if(!T.match(c)){var D=j.slice(0,O),k=j.slice(O+1),C=_.match(p);C&&(D.push(C[1]),k.unshift(C[2])),k.length&&(v="/"+k.join(".")+v),this.hostname=D.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),S||(this.hostname=r.toASCII(this.hostname));var N=this.port?":"+this.port:"",U=this.hostname||"";this.host=U+N,this.href+=this.host,S&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==v[0]&&(v="/"+v))}if(!d[M])for(O=0,F=l.length;O<F;O++){var G=l[O];if(-1!==v.indexOf(G)){var q=encodeURIComponent(G);q===G&&(q=escape(G)),v=v.split(G).join(q)}}var H=v.indexOf("#");-1!==H&&(this.hash=v.substr(H),v=v.slice(0,H));var W=v.indexOf("?");if(-1!==W?(this.search=v.substr(W),this.query=v.substr(W+1),e&&(this.query=m.parse(this.query)),v=v.slice(0,W)):e&&(this.search="",this.query={}),v&&(this.pathname=v),y[M]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){N=this.pathname||"";var B=this.search||"";this.path=N+B}return this.href=this.format(),this},o.prototype.format=function(){var t=this.auth||"";t&&(t=(t=encodeURIComponent(t)).replace(/%3A/i,":"),t+="@");var e=this.protocol||"",r=this.pathname||"",o=this.hash||"",n=!1,i="";this.host?n=t+this.host:this.hostname&&(n=t+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(n+=":"+this.port)),this.query&&"object"==typeof this.query&&Object.keys(this.query).length&&(i=m.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var s=this.search||i&&"?"+i||"";return e&&":"!==e.substr(-1)&&(e+=":"),this.slashes||(!e||y[e])&&!1!==n?(n="//"+(n||""),r&&"/"!==r.charAt(0)&&(r="/"+r)):n||(n=""),o&&"#"!==o.charAt(0)&&(o="#"+o),s&&"?"!==s.charAt(0)&&(s="?"+s),e+n+(r=r.replace(/[?#]/g,(function(t){return encodeURIComponent(t)})))+(s=s.replace("#","%23"))+o},o.prototype.resolve=function(t){return this.resolveObject(g(t,!1,!0)).format()},o.prototype.resolveObject=function(t){if("string"==typeof t){var e=new o;e.parse(t,!1,!0),t=e}for(var r=new o,n=Object.keys(this),i=0;i<n.length;i++){var s=n[i];r[s]=this[s]}if(r.hash=t.hash,""===t.href)return r.href=r.format(),r;if(t.slashes&&!t.protocol){for(var a=Object.keys(t),l=0;l<a.length;l++){var u=a[l];"protocol"!==u&&(r[u]=t[u])}return y[r.protocol]&&r.hostname&&!r.pathname&&(r.pathname="/",r.path=r.pathname),r.href=r.format(),r}if(t.protocol&&t.protocol!==r.protocol){if(!y[t.protocol]){for(var h=Object.keys(t),c=0;c<h.length;c++){var p=h[c];r[p]=t[p]}return r.href=r.format(),r}if(r.protocol=t.protocol,t.host||f[t.protocol])r.pathname=t.pathname;else{for(var d=(t.pathname||"").split("/");d.length&&!(t.host=d.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==d[0]&&d.unshift(""),d.length<2&&d.unshift(""),r.pathname=d.join("/")}if(r.search=t.search,r.query=t.query,r.host=t.host||"",r.auth=t.auth,r.hostname=t.hostname||t.host,r.port=t.port,r.pathname||r.search){var m=r.pathname||"",g=r.search||"";r.path=m+g}return r.slashes=r.slashes||t.slashes,r.href=r.format(),r}var v=r.pathname&&"/"===r.pathname.charAt(0),b=t.host||t.pathname&&"/"===t.pathname.charAt(0),x=b||v||r.host&&t.pathname,M=x,w=r.pathname&&r.pathname.split("/")||[],P=(d=t.pathname&&t.pathname.split("/")||[],r.protocol&&!y[r.protocol]);if(P&&(r.hostname="",r.port=null,r.host&&(""===w[0]?w[0]=r.host:w.unshift(r.host)),r.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===d[0]?d[0]=t.host:d.unshift(t.host)),t.host=null),x=x&&(""===d[0]||""===w[0])),b)r.host=t.host||""===t.host?t.host:r.host,r.hostname=t.hostname||""===t.hostname?t.hostname:r.hostname,r.search=t.search,r.query=t.query,w=d;else if(d.length)w||(w=[]),w.pop(),w=w.concat(d),r.search=t.search,r.query=t.query;else if(null!=t.search){if(P)r.host=w.shift(),r.hostname=r.host,(S=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=S.shift(),r.hostname=S.shift(),r.host=r.hostname);return r.search=t.search,r.query=t.query,null===r.pathname&&null===r.search||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!w.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var E=w.slice(-1)[0],A=(r.host||t.host||w.length>1)&&("."===E||".."===E)||""===E,O=0,I=w.length;I>=0;I--)"."===(E=w[I])?w.splice(I,1):".."===E?(w.splice(I,1),O++):O&&(w.splice(I,1),O--);if(!x&&!M)for(;O--;O)w.unshift("..");!x||""===w[0]||w[0]&&"/"===w[0].charAt(0)||w.unshift(""),A&&"/"!==w.join("/").substr(-1)&&w.push("");var S,j=""===w[0]||w[0]&&"/"===w[0].charAt(0);P&&(r.hostname=j?"":w.length?w.shift():"",r.host=r.hostname,(S=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=S.shift(),r.hostname=S.shift(),r.host=r.hostname));return(x=x||r.host&&w.length)&&!j&&w.unshift(""),w.length>0?r.pathname=w.join("/"):(r.pathname=null,r.path=null),null===r.pathname&&null===r.search||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var t=this.host,e=i.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)},tt.parse=g,tt.resolve=function(t,e){return g(t,!1,!0).resolve(e)},tt.resolveObject=function(t,e){return t?g(t,!1,!0).resolveObject(e):e},tt.format=function(t){return"string"==typeof t&&(t=g(t)),t instanceof o?t.format():o.prototype.format.call(t)},tt.Url=o,tt}());class ie{constructor(t){s(this,"json"),s(this,"name"),s(this,"url"),s(this,"pose"),s(this,"physics"),this.json=t;const e=t.url;if("string"!=typeof e)throw new TypeError("The `url` field in settings JSON must be defined as a string.");this.url=e,this.name=m(this.url)}resolveURL(t){return ne.resolve(this.url,t)}replaceFiles(t){this.moc=t(this.moc,"moc"),void 0!==this.pose&&(this.pose=t(this.pose,"pose")),void 0!==this.physics&&(this.physics=t(this.physics,"physics"));for(let e=0;e<this.textures.length;e++)this.textures[e]=t(this.textures[e],`textures[${e}]`)}getDefinedFiles(){const t=[];return this.replaceFiles((e=>(t.push(e),e))),t}validateFiles(t){const e=(e,r)=>{const o=this.resolveURL(e);if(!t.includes(o)){if(r)throw new Error(`File "${e}" is defined in settings, but doesn't exist in given files`);return!1}return!0};[this.moc,...this.textures].forEach((t=>e(t,!0)));return this.getDefinedFiles().filter((t=>e(t,!1)))}}var se=(t=>(t[t.NONE=0]="NONE",t[t.IDLE=1]="IDLE",t[t.NORMAL=2]="NORMAL",t[t.FORCE=3]="FORCE",t))(se||{});class ae{constructor(){s(this,"tag"),s(this,"debug",!1),s(this,"currentPriority",0),s(this,"reservePriority",0),s(this,"currentGroup"),s(this,"currentIndex"),s(this,"reservedGroup"),s(this,"reservedIndex"),s(this,"reservedIdleGroup"),s(this,"reservedIdleIndex")}reserve(t,e,r){if(r<=0)return c.log(this.tag,"Cannot start a motion with MotionPriority.NONE."),!1;if(t===this.currentGroup&&e===this.currentIndex)return c.log(this.tag,"Motion is already playing.",this.dump(t,e)),!1;if(t===this.reservedGroup&&e===this.reservedIndex||t===this.reservedIdleGroup&&e===this.reservedIdleIndex)return c.log(this.tag,"Motion is already reserved.",this.dump(t,e)),!1;if(1===r){if(0!==this.currentPriority)return c.log(this.tag,"Cannot start idle motion because another motion is playing.",this.dump(t,e)),!1;if(void 0!==this.reservedIdleGroup)return c.log(this.tag,"Cannot start idle motion because another idle motion has reserved.",this.dump(t,e)),!1;this.setReservedIdle(t,e)}else{if(r<3){if(r<=this.currentPriority)return c.log(this.tag,"Cannot start motion because another motion is playing as an equivalent or higher priority.",this.dump(t,e)),!1;if(r<=this.reservePriority)return c.log(this.tag,"Cannot start motion because another motion has reserved as an equivalent or higher priority.",this.dump(t,e)),!1}this.setReserved(t,e,r)}return!0}start(t,e,r,o){if(1===o){if(this.setReservedIdle(void 0,void 0),0!==this.currentPriority)return c.log(this.tag,"Cannot start idle motion because another motion is playing.",this.dump(e,r)),!1}else{if(e!==this.reservedGroup||r!==this.reservedIndex)return c.log(this.tag,"Cannot start motion because another motion has taken the place.",this.dump(e,r)),!1;this.setReserved(void 0,void 0,0)}return!!t&&(this.setCurrent(e,r,o),!0)}complete(){this.setCurrent(void 0,void 0,0)}setCurrent(t,e,r){this.currentPriority=r,this.currentGroup=t,this.currentIndex=e}setReserved(t,e,r){this.reservePriority=r,this.reservedGroup=t,this.reservedIndex=e}setReservedIdle(t,e){this.reservedIdleGroup=t,this.reservedIdleIndex=e}isActive(t,e){return t===this.currentGroup&&e===this.currentIndex||t===this.reservedGroup&&e===this.reservedIndex||t===this.reservedIdleGroup&&e===this.reservedIdleIndex}reset(){this.setCurrent(void 0,void 0,0),this.setReserved(void 0,void 0,0),this.setReservedIdle(void 0,void 0)}shouldRequestIdleMotion(){return void 0===this.currentGroup&&void 0===this.reservedIdleGroup}shouldOverrideExpression(){return!h.preserveExpressionOnMotion&&this.currentPriority>1}dump(t,e){if(this.debug){return`\n<Requested> group = "${t}", index = ${e}\n`+["currentPriority","reservePriority","currentGroup","currentIndex","reservedGroup","reservedIndex","reservedIdleGroup","reservedIdleIndex"].map((t=>"["+t+"] "+this[t])).join("\n")}return""}}const le=.5;class ue{static get volume(){return this._volume}static set volume(t){this._volume=(t>1?1:t<0?0:t)||0,this.audios.forEach((t=>t.volume=this._volume))}static add(t,e,o){return a(this,null,(function*(){try{const o=new Promise(((o,n)=>{const i=r.Sound.from({url:t,volume:this._volume,preload:!0,complete:()=>{this.dispose(i),null==e||e()},loaded:()=>{i.media instanceof r.webaudio.WebAudioMedia||n(new Error(`Error: ${t} is not WebAudioMedia`)),o(i)}})}));return yield o}catch(n){return c.warn("SoundManager",`Error occurred on "${t}"`,n),null==o||o(n),null}}))}static play(t){t.play()}static addAnalyzer(t,e){const r=t.media,o=e.createBufferSource();o.buffer=r.buffer;const n=e.createAnalyser();return n.fftSize=h.fftSize,n.minDecibels=-90,n.maxDecibels=-10,n.smoothingTimeConstant=.85,o.connect(n),o.start(0),n.connect(e.destination),this.analysers.push(n),n}static analyze(t){if(!t)return parseFloat(Math.random().toFixed(1));const e=new Float32Array(t.fftSize);t.getFloatTimeDomainData(e);let r=0;for(let a=0;a<e.length;a++)r+=i(e[a],2);const o=Math.sqrt(r/e.length),n=20*Math.log10(o||i(10,-5)),s=Math.min(Math.max((n-t.minDecibels)/(t.maxDecibels-t.minDecibels),0),1);return parseFloat(s.toFixed(1))}static dispose(t){t.pause(),g(this.audios,t)}static destroy(){for(let t=this.contexts.length-1;t>=0;t--)setTimeout((()=>this.contexts[t].close()));for(let t=this.audios.length-1;t>=0;t--)this.dispose(this.audios[t])}}s(ue,"audios",[]),s(ue,"analysers",[]),s(ue,"contexts",[]),s(ue,"_volume",le);var he=(t=>(t.ALL="ALL",t.IDLE="IDLE",t.NONE="NONE",t))(he||{});class ce extends e.utils.EventEmitter{constructor(t){super(),s(this,"tag"),s(this,"settings"),s(this,"motionGroups",{}),s(this,"state",new ae),s(this,"currentAudio"),s(this,"currentAnalyzer"),s(this,"currentContext"),s(this,"playing",!1),s(this,"destroyed",!1),s(this,"parent"),this.settings=t.settings,this.tag=`MotionManager(${this.settings.name})`,this.state.tag=this.tag,this.parent=t}init(t){(null==t?void 0:t.idleMotionGroup)&&(this.groups.idle=t.idleMotionGroup),this.setupMotions(t),this.stopAllMotions()}setupMotions(t){for(const r of Object.keys(this.definitions))this.motionGroups[r]=[];let e;switch(null==t?void 0:t.motionPreload){case"NONE":return;case"ALL":e=Object.keys(this.definitions);break;default:e=[this.groups.idle]}for(const r of e)if(this.definitions[r])for(let t=0;t<this.definitions[r].length;t++)this.loadMotion(r,t).then()}loadMotion(t,e){return a(this,null,(function*(){var r;if(!(null==(r=this.definitions[t])?void 0:r[e]))return void c.warn(this.tag,`Undefined motion at "${t}"[${e}]`);if(null===this.motionGroups[t][e])return void c.warn(this.tag,`Cannot start motion at "${t}"[${e}] because it's already failed in loading.`);if(this.motionGroups[t][e])return this.motionGroups[t][e];const o=yield this._loadMotion(t,e);return this.destroyed?void 0:(this.motionGroups[t][e]=null!=o?o:null,o)}))}_loadMotion(t,e){throw new Error("Not implemented.")}initializeAudio(t,e){this.currentAudio=t,ue.volume=e,this.currentContext=t.context.audioContext,this.currentAnalyzer=ue.addAnalyzer(this.currentAudio,this.currentContext)}speak(t){return a(this,arguments,(function*(t,{volume:e=.5,expression:r,resetExpression:o=!0,onFinish:n,onError:i}={}){if(!h.sound)return!1;let s,a;if(this.currentAudio&&this.currentAudio.isPlaying)return!1;const l=t&&t.startsWith("data:");if(t&&!l){const e=document.createElement("a");e.href=t,a=t=e.href}else a="data:audio/";const u=t;if(u)try{s=yield ue.add(u,((t=this)=>{c.warn(this.tag,"Audio finished playing"),null==n||n(),o&&r&&t.expressionManager&&t.expressionManager.resetExpression(),t.currentAudio=void 0}),((t,e=this)=>{c.error(this.tag,"Error during audio playback:",t),null==i||i(t),o&&r&&e.expressionManager&&e.expressionManager.resetExpression(),e.currentAudio=void 0})),this.initializeAudio(s,e)}catch(p){return c.warn(this.tag,"Failed to create audio",a,p),!1}if(s){let t=!0;try{h.motionSync&&ue.play(s)}catch(p){c.warn(this.tag,"Failed to play audio",s.url,p),t=!1}if(!t)return!1}return this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),r&&this.expressionManager&&(yield this.expressionManager.setExpression(r)),this.playing=!0,!0}))}startMotion(t,e){return a(this,arguments,(function*(t,e,r=se.NORMAL,{sound:o,volume:n=.5,expression:i,resetExpression:s=!0,onFinish:a,onError:l,ignoreParamIds:u=[]}={}){var p;if(!this.state.reserve(t,e,r))return!1;if(this.currentAudio&&this.currentAudio.isPlaying&&r!=se.FORCE)return!1;const d=null==(p=this.definitions[t])?void 0:p[e];if(!d)return!1;let f,y;this.currentAudio&&ue.dispose(this.currentAudio);const m=o&&o.startsWith("data:");if(o&&!m){const t=document.createElement("a");t.href=o,y=o=t.href}else y=this.getSoundFile(d),y&&(y=this.settings.resolveURL(y));const g=y;if(g)try{f=yield ue.add(g,((t=this)=>{null==a||a(),s&&i&&t.expressionManager&&t.expressionManager.resetExpression(),t.currentAudio=void 0}),((t,e=this)=>{c.error(this.tag,"Error during audio playback:",t),null==l||l(t),s&&i&&e.expressionManager&&e.expressionManager.resetExpression(),e.currentAudio=void 0})),this.initializeAudio(f,n)}catch(b){c.warn(this.tag,"Failed to create audio",y,b)}const v=yield this.loadMotion(t,e);if(f&&h.motionSync)try{ue.play(f)}catch(b){c.warn(this.tag,"Failed to play audio",f.url,b)}return this.state.start(v,t,e,r)?(this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),c.log(this.tag,"Start motion:",this.getMotionName(d)),this.emit("motionStart",t,e,f),i&&this.expressionManager&&this.state.shouldOverrideExpression()&&(yield this.expressionManager.setExpression(i)),this.playing=!0,this._startMotion(v,void 0,u),!0):(f&&(ue.dispose(f),this.currentAudio=void 0),!1)}))}startRandomMotion(t,e){return a(this,arguments,(function*(t,e,{sound:r,volume:o=.5,expression:n,resetExpression:i=!0,onFinish:s,onError:a}={}){const l=this.definitions[t];if(null==l?void 0:l.length){const u=[];for(let e=0;e<l.length;e++)null===this.motionGroups[t][e]||this.state.isActive(t,e)||u.push(e);if(u.length){const l=u[Math.floor(Math.random()*u.length)];return this.startMotion(t,l,e,{sound:r,volume:o,expression:n,resetExpression:i,onFinish:s,onError:a})}}return!1}))}stopSpeaking(){this.currentAudio&&(ue.dispose(this.currentAudio),this.currentAudio=void 0)}stopAllMotions(){this._stopAllMotions(),this.state.reset(),this.stopSpeaking()}update(t,e){var r;return this.isFinished()&&(this.playing&&(this.playing=!1,this.emit("motionFinish")),this.state.shouldOverrideExpression()&&(null==(r=this.expressionManager)||r.restoreExpression()),this.state.complete(),this.state.shouldRequestIdleMotion()&&this.startRandomMotion(this.groups.idle,se.IDLE)),this.updateParameters(t,e)}mouthSync(){return this.currentAnalyzer?ue.analyze(this.currentAnalyzer):0}destroy(){var t;this.destroyed=!0,this.emit("destroy"),this.stopAllMotions(),null==(t=this.expressionManager)||t.destroy();this.definitions=void 0,this.motionGroups=void 0}getMotionAndApplyExpression(t,e,r){return a(this,null,(function*(){var o;if(!this.state.reserve(t,e,se.FORCE))return null;const n=null==(o=this.definitions[t])?void 0:o[e];if(!n)return null;this.currentAudio&&ue.dispose(this.currentAudio);const i=yield this.loadMotion(t,e);return this.state.start(i,t,e,se.FORCE)?(this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),c.log(this.tag,"Start motion:",this.getMotionName(n)),this.emit("motionStart",t,e,void 0),r&&this.expressionManager&&this.state.shouldOverrideExpression()&&(yield this.expressionManager.setExpression(r)),i):null}))}}const pe={x:0,y:0,width:0,height:0};class de extends e.utils.EventEmitter{constructor(){super(...arguments),s(this,"focusController",new M),s(this,"pose"),s(this,"physics"),s(this,"originalWidth",0),s(this,"originalHeight",0),s(this,"width",0),s(this,"height",0),s(this,"localTransform",new e.Matrix),s(this,"drawingMatrix",new e.Matrix),s(this,"hitAreas",{}),s(this,"textureFlipY",!1),s(this,"viewport",[0,0,0,0]),s(this,"destroyed",!1)}init(){this.setupLayout(),this.setupHitAreas()}setupLayout(){const t=this,e=this.getSize();t.originalWidth=e[0],t.originalHeight=e[1];const r=Object.assign({width:2,height:2},this.getLayout());this.localTransform.scale(r.width/2,r.height/2),t.width=this.originalWidth*this.localTransform.a,t.height=this.originalHeight*this.localTransform.d;const o=void 0!==r.x&&r.x-r.width/2||void 0!==r.centerX&&r.centerX||void 0!==r.left&&r.left-r.width/2||void 0!==r.right&&r.right+r.width/2||0,n=void 0!==r.y&&r.y-r.height/2||void 0!==r.centerY&&r.centerY||void 0!==r.top&&r.top-r.height/2||void 0!==r.bottom&&r.bottom+r.height/2||0;this.localTransform.translate(this.width*o,-this.height*n)}setupHitAreas(){const t=this.getHitAreaDefs().filter((t=>t.index>=0));for(const e of t)this.hitAreas[e.name]=e}hitTest(t,e){return Object.keys(this.hitAreas).filter((r=>this.isHit(r,t,e)))}isHit(t,e,r){if(!this.hitAreas[t])return!1;const o=this.hitAreas[t].index,n=this.getDrawableBounds(o,pe);return n.x<=e&&e<=n.x+n.width&&n.y<=r&&r<=n.y+n.height}getDrawableBounds(t,e){const r=this.getDrawableVertices(t);let o=r[0],n=r[0],i=r[1],s=r[1];for(let a=0;a<r.length;a+=2){const t=r[a],e=r[a+1];o=Math.min(t,o),n=Math.max(t,n),i=Math.min(e,i),s=Math.max(e,s)}return null!=e||(e={}),e.x=o,e.y=i,e.width=n-o,e.height=s-i,e}updateTransform(t){this.drawingMatrix.copyFrom(t).append(this.localTransform)}update(t,e){this.focusController.update(t)}destroy(){this.destroyed=!0,this.emit("destroy"),this.motionManager.destroy(),this.motionManager=void 0,this.parallelMotionManager.forEach((t=>t.destroy())),this.parallelMotionManager=[]}updateMotions(t,e){this.emit("beforeMotionUpdate");const r=this.motionManager.update(t,e),o=this.parallelMotionManager.map((r=>r.update(t,e))),n=r||o.reduce(((t,e)=>t||e),!1);return this.emit("afterMotionUpdate"),n}}class fe extends Error{constructor(t,e,r,o=!1){super(t),this.url=e,this.status=r,this.aborted=o}}const ye=class t{static createXHR(e,r,o,n,i){const s=new XMLHttpRequest;if(t.allXhrSet.add(s),e){let r=t.xhrMap.get(e);r?r.add(s):(r=new Set([s]),t.xhrMap.set(e,r)),e.listeners("destroy").includes(t.cancelXHRs)||e.once("destroy",t.cancelXHRs)}return s.open("GET",r),s.responseType=o,s.onload=()=>{200!==s.status&&0!==s.status||!s.response?s.onerror():n(s.response)},s.onerror=()=>{c.warn("XHRLoader",`Failed to load resource as ${s.responseType} (Status ${s.status}): ${r}`),i(new fe("Network error.",r,s.status))},s.onabort=()=>i(new fe("Aborted.",r,s.status,!0)),s.onloadend=()=>{var r;t.allXhrSet.delete(s),e&&(null==(r=t.xhrMap.get(e))||r.delete(s))},s}static cancelXHRs(){var e;null==(e=t.xhrMap.get(this))||e.forEach((e=>{e.abort(),t.allXhrSet.delete(e)})),t.xhrMap.delete(this)}static release(){t.allXhrSet.forEach((t=>t.abort())),t.allXhrSet.clear(),t.xhrMap=new WeakMap}};s(ye,"xhrMap",new WeakMap),s(ye,"allXhrSet",new Set),s(ye,"loader",((t,e)=>new Promise(((e,r)=>{ye.createXHR(t.target,t.settings?t.settings.resolveURL(t.url):t.url,t.type,(r=>{t.result=r,e()}),r).send()}))));let me=ye;function ge(t,e){let r=-1;return function o(n,i){if(i)return Promise.reject(i);if(n<=r)return Promise.reject(new Error("next() called multiple times"));r=n;const s=t[n];if(!s)return Promise.resolve();try{return Promise.resolve(s(e,o.bind(null,n+1)))}catch(a){return Promise.reject(a)}}(0)}class ve{static load(t){return ge(this.middlewares,t).then((()=>t.result))}}function be(){}s(ve,"middlewares",[me.loader]);const xe="Live2DFactory",Me=(t,e)=>a(null,null,(function*(){if("string"==typeof t.source){const e=yield ve.load({url:t.source,type:"json",target:t.live2dModel});e.url=t.source,t.source=e,t.live2dModel.emit("settingsJSONLoaded",e)}return e()})),we=(t,e)=>a(null,null,(function*(){if(t.source instanceof ie)return t.settings=t.source,e();if("object"==typeof t.source){const r=Te.findRuntime(t.source);if(r){const o=r.createModelSettings(t.source);return t.settings=o,t.live2dModel.emit("settingsLoaded",o),e()}}throw new TypeError("Unknown settings format.")})),Pe=(t,e)=>{if(t.settings){const r=Te.findRuntime(t.settings);if(r)return r.ready().then(e)}return e()},Ee=(t,e)=>a(null,null,(function*(){yield e();const r=t.internalModel;if(r){const e=t.settings,o=Te.findRuntime(e);if(o){const n=[];e.pose&&n.push(ve.load({settings:e,url:e.pose,type:"json",target:r}).then((e=>{r.pose=o.createPose(r.coreModel,e),t.live2dModel.emit("poseLoaded",r.pose)})).catch((e=>{t.live2dModel.emit("poseLoadError",e),c.warn(xe,"Failed to load pose.",e)}))),e.physics&&n.push(ve.load({settings:e,url:e.physics,type:"json",target:r}).then((e=>{r.physics=o.createPhysics(r.coreModel,e),t.live2dModel.emit("physicsLoaded",r.physics)})).catch((e=>{t.live2dModel.emit("physicsLoadError",e),c.warn(xe,"Failed to load physics.",e)}))),n.length&&(yield Promise.all(n))}}})),Ae=(t,r)=>a(null,null,(function*(){if(!t.settings)throw new TypeError("Missing settings.");{const o=t.live2dModel,n=Promise.all(t.settings.textures.map((r=>function(t,r={}){const o={resourceOptions:{crossorigin:r.crossOrigin}};if(e.Texture.fromURL)return e.Texture.fromURL(t,o).catch((t=>{if(t instanceof Error)throw t;const e=new Error("Texture loading error");throw e.event=t,e}));o.resourceOptions.autoLoad=!1;const n=e.Texture.from(t,o);if(n.baseTexture.valid)return Promise.resolve(n);const i=n.baseTexture.resource;return null!=i._live2d_load||(i._live2d_load=new Promise(((t,e)=>{const r=t=>{i.source.removeEventListener("error",r);const o=new Error("Texture loading error");o.event=t,e(o)};i.source.addEventListener("error",r),i.load().then((()=>t(n))).catch(r)}))),i._live2d_load}(t.settings.resolveURL(r),{crossOrigin:t.options.crossOrigin}))));if(n.catch(be),yield r(),!t.internalModel)throw new TypeError("Missing internal model.");o.internalModel=t.internalModel,o.emit("modelLoaded",t.internalModel),o.textures=yield n,o.emit("textureLoaded",o.textures)}})),Oe=(t,e)=>a(null,null,(function*(){const r=t.settings;if(r instanceof ie){const o=Te.findRuntime(r);if(!o)throw new TypeError("Unknown model settings.");const n=yield ve.load({settings:r,url:r.moc,type:"arraybuffer",target:t.live2dModel});if(!o.isValidMoc(n))throw new Error("Invalid moc data");const i=o.createCoreModel(n);return t.internalModel=o.createInternalModel(i,r,t.options),e()}throw new TypeError("Missing settings.")})),Ie=class t{static unzip(e,r){return a(this,null,(function*(){const o=yield t.getFilePaths(e),n=[];for(const t of r.getDefinedFiles()){const e=decodeURI(ne.resolve(r.url,t));o.includes(e)&&n.push(e)}const i=yield t.getFiles(e,n);for(let t=0;t<i.length;t++){const e=n[t],r=i[t];Object.defineProperty(r,"webkitRelativePath",{value:e})}return i}))}static createSettings(e){return a(this,null,(function*(){const r=(yield t.getFilePaths(e)).find((t=>t.endsWith("model.json")||t.endsWith("model3.json")));if(!r)throw new Error("Settings file not found");const o=yield t.readText(e,r);if(!o)throw new Error("Empty settings file: "+r);const n=JSON.parse(o);n.url=r;const i=t.live2dFactory.findRuntime(n);if(!i)throw new Error("Unknown settings JSON");return i.createModelSettings(n)}))}static zipReader(t,e){return a(this,null,(function*(){throw new Error("Not implemented")}))}static getFilePaths(t){return a(this,null,(function*(){throw new Error("Not implemented")}))}static getFiles(t,e){return a(this,null,(function*(){throw new Error("Not implemented")}))}static readText(t,e){return a(this,null,(function*(){throw new Error("Not implemented")}))}static releaseReader(t){}};s(Ie,"live2dFactory"),s(Ie,"ZIP_PROTOCOL","zip://"),s(Ie,"uid",0),s(Ie,"factory",((t,e)=>a(null,null,(function*(){const r=t.source;let o,n,i;if("string"==typeof r&&(r.endsWith(".zip")||r.startsWith(Ie.ZIP_PROTOCOL))?(o=r.startsWith(Ie.ZIP_PROTOCOL)?r.slice(Ie.ZIP_PROTOCOL.length):r,n=yield ve.load({url:o,type:"blob",target:t.live2dModel})):Array.isArray(r)&&1===r.length&&r[0]instanceof File&&r[0].name.endsWith(".zip")&&(n=r[0],o=URL.createObjectURL(n),i=r.settings),n){if(!n.size)throw new Error("Empty zip file");const e=yield Ie.zipReader(n,o);i||(i=yield Ie.createSettings(e)),i._objectURL=Ie.ZIP_PROTOCOL+Ie.uid+"/"+i.url;const r=yield Ie.unzip(e,i);r.settings=i,t.source=r,o.startsWith("blob:")&&t.live2dModel.once("modelLoaded",(t=>{t.once("destroy",(function(){URL.revokeObjectURL(o)}))})),Ie.releaseReader(e)}return e()}))));let Se=Ie;const je=class t{static resolveURL(e,r){var o;const n=null==(o=t.filesMap[e])?void 0:o[r];if(void 0===n)throw new Error("Cannot find this file from uploaded files: "+r);return n}static upload(e,r){return a(this,null,(function*(){const o={};for(const t of r.getDefinedFiles()){const n=decodeURI(ne.resolve(r.url,t)),i=e.find((t=>t.webkitRelativePath===n));i&&(o[t]=URL.createObjectURL(i))}t.filesMap[r._objectURL]=o}))}static createSettings(e){return a(this,null,(function*(){const r=e.find((t=>t.name.endsWith("model.json")||t.name.endsWith("model3.json")));if(!r)throw new TypeError("Settings file not found");const o=yield t.readText(r),n=JSON.parse(o);n.url=r.webkitRelativePath;const i=Te.findRuntime(n);if(!i)throw new Error("Unknown settings JSON");const s=i.createModelSettings(n);return s._objectURL=URL.createObjectURL(r),s}))}static readText(t){return a(this,null,(function*(){return new Promise(((e,r)=>{const o=new FileReader;o.onload=()=>e(o.result),o.onerror=r,o.readAsText(t,"utf8")}))}))}};s(je,"live2dFactory"),s(je,"filesMap",{}),s(je,"factory",((t,e)=>a(null,null,(function*(){if(Array.isArray(t.source)&&t.source[0]instanceof File){const e=t.source;let r=e.settings;if(r){if(!r._objectURL)throw new Error('"_objectURL" must be specified in ModelSettings')}else r=yield je.createSettings(e);r.validateFiles(e.map((t=>encodeURI(t.webkitRelativePath)))),yield je.upload(e,r),r.resolveURL=function(t){return je.resolveURL(this._objectURL,t)},t.source=r,t.live2dModel.once("modelLoaded",(t=>{t.once("destroy",(function(){const t=this.settings._objectURL;if(URL.revokeObjectURL(t),je.filesMap[t])for(const e of Object.values(je.filesMap[t]))URL.revokeObjectURL(e);delete je.filesMap[t]}))}))}return e()}))));let Fe=je;const _e=class t{static registerRuntime(e){t.runtimes.push(e),t.runtimes.sort(((t,e)=>e.version-t.version))}static findRuntime(e){for(const r of t.runtimes)if(r.test(e))return r}static setupLive2DModel(e,r,o){return a(this,null,(function*(){const n=new Promise((t=>e.once("textureLoaded",t))),i=new Promise((t=>e.once("modelLoaded",t))),s=Promise.all([n,i]).then((()=>e.emit("ready")));yield ge(t.live2DModelMiddlewares,{live2dModel:e,source:r,options:o||{}}),yield s,e.emit("load")}))}static loadMotion(e,r,o){var n;const i=t=>e.emit("motionLoadError",r,o,t);try{const s=null==(n=e.definitions[r])?void 0:n[o];if(!s)return Promise.resolve(void 0);e.listeners("destroy").includes(t.releaseTasks)||e.once("destroy",t.releaseTasks);let a=t.motionTasksMap.get(e);a||(a={},t.motionTasksMap.set(e,a));let l=a[r];l||(l=[],a[r]=l);const u=e.getMotionFile(s);return null!=l[o]||(l[o]=ve.load({url:u,settings:e.settings,type:e.motionDataType,target:e}).then((n=>{var i;const a=null==(i=t.motionTasksMap.get(e))?void 0:i[r];a&&delete a[o];const l=e.createMotion(n,r,s);return e.emit("motionLoaded",r,o,l),l})).catch((t=>{c.warn(e.tag,`Failed to load motion: ${u}\n`,t),i(t)}))),l[o]}catch(s){c.warn(e.tag,`Failed to load motion at "${r}"[${o}]\n`,s),i(s)}return Promise.resolve(void 0)}static loadExpression(e,r){const o=t=>e.emit("expressionLoadError",r,t);try{const n=e.definitions[r];if(!n)return Promise.resolve(void 0);e.listeners("destroy").includes(t.releaseTasks)||e.once("destroy",t.releaseTasks);let i=t.expressionTasksMap.get(e);i||(i=[],t.expressionTasksMap.set(e,i));const s=e.getExpressionFile(n);return null!=i[r]||(i[r]=ve.load({url:s,settings:e.settings,type:"json",target:e}).then((o=>{const i=t.expressionTasksMap.get(e);i&&delete i[r];const s=e.createExpression(o,n);return e.emit("expressionLoaded",r,s),s})).catch((t=>{c.warn(e.tag,`Failed to load expression: ${s}\n`,t),o(t)}))),i[r]}catch(n){c.warn(e.tag,`Failed to load expression at [${r}]\n`,n),o(n)}return Promise.resolve(void 0)}static releaseTasks(){this instanceof ce?t.motionTasksMap.delete(this):t.expressionTasksMap.delete(this)}};s(_e,"runtimes",[]),s(_e,"urlToJSON",Me),s(_e,"jsonToSettings",we),s(_e,"waitUntilReady",Pe),s(_e,"setupOptionals",Ee),s(_e,"setupEssentials",Ae),s(_e,"createInternalModel",Oe),s(_e,"live2DModelMiddlewares",[Se.factory,Fe.factory,Me,we,Pe,Ee,Ae,Oe]),s(_e,"motionTasksMap",new WeakMap),s(_e,"expressionTasksMap",new WeakMap);let Te=_e;ce.prototype._loadMotion=function(t,e){return Te.loadMotion(this,t,e)},v.prototype._loadExpression=function(t){return Te.loadExpression(this,t)},Fe.live2dFactory=Te,Se.live2dFactory=Te;const Le=class t{constructor(e,{autoUpdate:r=!0,autoHitTest:o=!0,autoFocus:n=!0,autoInteract:i,ticker:a}={}){s(this,"model"),s(this,"destroyed",!1),s(this,"_ticker"),s(this,"_autoUpdate",!1),s(this,"_autoHitTest",!1),s(this,"_autoFocus",!1),a||(t.defaultTicker?a=t.defaultTicker:"undefined"!=typeof PIXI&&(a=PIXI.Ticker.shared)),void 0!==i&&(o=i,n=i,c.warn(e.tag,"options.autoInteract is deprecated since v0.5.0, use autoHitTest and autoFocus instead.")),this.model=e,this.ticker=a,this.autoUpdate=r,this.autoHitTest=o,this.autoFocus=n,(o||n)&&(this.model.eventMode="static")}get ticker(){return this._ticker}set ticker(t){var e;this._ticker&&this._ticker.remove(De,this),this._ticker=t,this._autoUpdate&&(null==(e=this._ticker)||e.add(De,this))}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){var e;this.destroyed||(t?this._ticker?(this._ticker.add(De,this),this._autoUpdate=!0):c.warn(this.model.tag,"No Ticker to be used for automatic updates. Either set option.ticker when creating Live2DModel, or expose PIXI to global scope (window.PIXI = PIXI)."):(null==(e=this._ticker)||e.remove(De,this),this._autoUpdate=!1))}get autoHitTest(){return this._autoHitTest}set autoHitTest(t){t!==this.autoHitTest&&(t?this.model.on("pointertap",ke,this):this.model.off("pointertap",ke,this),this._autoHitTest=t)}get autoFocus(){return this._autoFocus}set autoFocus(t){t!==this.autoFocus&&(t?this.model.on("globalpointermove",Ce,this):this.model.off("globalpointermove",Ce,this),this._autoFocus=t)}get autoInteract(){return this._autoHitTest&&this._autoFocus}set autoInteract(t){this.autoHitTest=t,this.autoFocus=t}onTickerUpdate(){const t=this.ticker.deltaMS;this.model.update(t)}onTap(t){this.model.tap(t.global.x,t.global.y)}onPointerMove(t){this.model.focus(t.global.x,t.global.y)}destroy(){this.autoFocus=!1,this.autoHitTest=!1,this.autoUpdate=!1,this.ticker=void 0,this.destroyed=!0}};s(Le,"defaultTicker");let Re=Le;function De(){this.onTickerUpdate()}function ke(t){this.onTap(t)}function Ce(t){this.onPointerMove(t)}class Ne extends e.Transform{}const Ue=new e.Point,Ge=new e.Matrix;class qe extends o.Container{constructor(t){super(),s(this,"tag","Live2DModel(uninitialized)"),s(this,"internalModel"),s(this,"textures",[]),s(this,"transform",new Ne),s(this,"anchor",new e.ObservablePoint(this.onAnchorChange,this,0,0)),s(this,"glContextID",-1),s(this,"elapsedTime",0),s(this,"deltaTime",0),s(this,"automator"),this.automator=new Re(this,t),this.once("modelLoaded",(()=>this.initializeOnModelLoad(t)))}static from(t,e){return a(this,null,(function*(){const r=new this(e);return yield Te.setupLive2DModel(r,t,e),r}))}static fromSync(t,e){const r=new this(e);return Te.setupLive2DModel(r,t,e).then(null==e?void 0:e.onLoad).catch(null==e?void 0:e.onError),r}static registerTicker(t){Re.defaultTicker=t.shared}initializeOnModelLoad(t){this.tag=`Live2DModel(${this.internalModel.settings.name})`}onAnchorChange(){this.pivot.set(this.anchor.x*this.internalModel.width,this.anchor.y*this.internalModel.height)}motion(t,e,r){return a(this,arguments,(function*(t,e,r,{sound:o,volume:n=.5,expression:i,resetExpression:s=!0,onFinish:a,onError:l}={}){return void 0===e?this.internalModel.motionManager.startRandomMotion(t,r,{sound:o,volume:n,expression:i,resetExpression:s,onFinish:a,onError:l}):this.internalModel.motionManager.startMotion(t,e,r,{sound:o,volume:n,expression:i,resetExpression:s,onFinish:a,onError:l})}))}motionLastFrame(t,e){return a(this,arguments,(function*(t,e,{expression:r}={}){return this.internalModel.motionManager.motionLastFrame(t,e,{expression:r})}))}parallelMotion(t){return a(this,null,(function*(){this.internalModel.extendParallelMotionManager(t.length);const e=t.map(((t,e)=>this.internalModel.parallelMotionManager[e].startMotion(t.group,t.index,t.priority))),r=[];for(const t of e)r.push(yield t);return r}))}parallelLastFrame(t){return a(this,null,(function*(){this.internalModel.extendParallelMotionManager(t.length);const e=t.map(((t,e)=>this.internalModel.parallelMotionManager[e].playMotionLastFrame(t.group,t.index))),r=[];for(const t of e)r.push(yield t);return r}))}stopMotions(){return this.internalModel.motionManager.stopAllMotions()}speak(t,{volume:e=.5,expression:r,resetExpression:o=!0,onFinish:n,onError:i}={}){return this.internalModel.motionManager.speak(t,{volume:e,expression:r,resetExpression:o,onFinish:n,onError:i})}stopSpeaking(){return this.internalModel.motionManager.stopSpeaking()}expression(t){return this.internalModel.motionManager.expressionManager?void 0===t?this.internalModel.motionManager.expressionManager.setRandomExpression():this.internalModel.motionManager.expressionManager.setExpression(t):Promise.resolve(!1)}focus(t,e,r=!1){Ue.x=t,Ue.y=e,this.toModelPosition(Ue,Ue,!0);const o=Ue.x/this.internalModel.originalWidth*2-1,n=Ue.y/this.internalModel.originalHeight*2-1,i=Math.atan2(n,o);this.internalModel.focusController.focus(Math.cos(i),-Math.sin(i),r)}tap(t,e){const r=this.hitTest(t,e);r.length&&(c.log(this.tag,"Hit",r),this.emit("hit",r))}hitTest(t,e){return Ue.x=t,Ue.y=e,this.toModelPosition(Ue,Ue),this.internalModel.hitTest(Ue.x,Ue.y)}toModelPosition(t,e=t.clone(),r){return r||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.transform.worldTransform.applyInverse(t,e),this.internalModel.localTransform.applyInverse(e,e),e}containsPoint(t){return this.getBounds(!0).contains(t.x,t.y)}_calculateBounds(){this._bounds.addFrame(this.transform,0,0,this.internalModel.width,this.internalModel.height)}update(t){this.deltaTime+=t,this.elapsedTime+=t}_render(t){t.batch.reset(),t.geometry.reset(),t.shader.reset(),t.state.reset();let e=!1;this.glContextID!==t.CONTEXT_UID&&(this.glContextID=t.CONTEXT_UID,this.internalModel.updateWebGLContext(t.gl,this.glContextID),e=!0);for(let n=0;n<this.textures.length;n++){const r=this.textures[n];r.valid&&(!e&&r.baseTexture._glTextures[this.glContextID]||(t.gl.pixelStorei(WebGLRenderingContext.UNPACK_FLIP_Y_WEBGL,this.internalModel.textureFlipY),t.texture.bind(r.baseTexture,0)),this.internalModel.bindTexture(n,r.baseTexture._glTextures[this.glContextID].texture),r.baseTexture.touched=t.textureGC.count)}const r=t.framebuffer.viewport;this.internalModel.viewport=[r.x,r.y,r.width,r.height],this.deltaTime&&(this.internalModel.update(this.deltaTime,this.elapsedTime),this.deltaTime=0);const o=Ge.copyFrom(t.globalUniforms.uniforms.projectionMatrix).append(this.worldTransform);this.internalModel.updateTransform(o),this.internalModel.draw(t.gl),t.state.reset(),t.texture.reset()}destroy(t){this.emit("destroy"),(null==t?void 0:t.texture)&&this.textures.forEach((e=>e.destroy(t.baseTexture))),this.automator.destroy(),this.internalModel.destroy(),super.destroy(t)}}if(!window.Live2D)throw new Error("Could not find Cubism 2 runtime. This plugin requires live2d.min.js to be loaded.");const He=Live2DMotion.prototype.updateParam;Live2DMotion.prototype.updateParam=function(t,e){He.call(this,t,e),e.isFinished()&&this.onFinishHandler&&(this.onFinishHandler(this),delete this.onFinishHandler)};class We extends AMotion{constructor(t){super(),s(this,"params",[]),this.setFadeIn(t.fade_in>0?t.fade_in:h.expressionFadingDuration),this.setFadeOut(t.fade_out>0?t.fade_out:h.expressionFadingDuration),Array.isArray(t.params)&&t.params.forEach((t=>{const e=t.calc||"add";if("add"===e){const e=t.def||0;t.val-=e}else if("mult"===e){const e=t.def||1;t.val/=e}this.params.push({calc:e,val:t.val,id:t.id})}))}updateParamExe(t,e,r,o){this.params.forEach((e=>{t.setParamFloat(e.id,e.val*r)}))}}class Be extends v{constructor(t,e){var r;super(t,e),s(this,"queueManager",new MotionQueueManager),s(this,"definitions"),this.definitions=null!=(r=this.settings.expressions)?r:[],this.init()}isFinished(){return this.queueManager.isFinished()}getExpressionIndex(t){return this.definitions.findIndex((e=>e.name===t))}getExpressionFile(t){return t.file}createExpression(t,e){return new We(t)}_setExpression(t){return this.queueManager.startMotion(t)}stopAllExpressions(){this.queueManager.stopAllMotions()}updateParameters(t,e){return this.queueManager.updateParam(t)}}function $e(t,e,r){const o=r.getDurationMSec(),n=t.startMotion(r,!0),i=t.motions.find((t=>t&&t._$sr===n));return!!i&&(r.updateParamExe(e.coreModel,o,1,i),!0)}class Xe extends ce{constructor(t){super(t),s(this,"definitions"),s(this,"groups",{idle:"idle"}),s(this,"motionDataType","arraybuffer"),s(this,"queueManager",new MotionQueueManager),s(this,"lipSyncIds"),s(this,"expressionManager"),this.definitions=this.settings.motions,this.init(t.options),this.lipSyncIds=["PARAM_MOUTH_OPEN_Y"]}init(t){super.init(t),this.settings.expressions&&(this.expressionManager=new Be(this.settings,t))}isFinished(){return this.queueManager.isFinished()}createMotion(t,e,r){const o=Live2DMotion.loadMotion(t),n=e===this.groups.idle?h.idleMotionFadingDuration:h.motionFadingDuration;return o.setFadeIn(r.fade_in>0?r.fade_in:n),o.setFadeOut(r.fade_out>0?r.fade_out:n),o}getMotionFile(t){return t.file}getMotionName(t){return t.file}getSoundFile(t){return t.sound}_startMotion(t,e,r){return t.onFinishHandler=e,r&&r.length>0&&(t.motions=t.motions.filter((t=>!r.includes(t._$4P)))),this.queueManager.stopAllMotions(),this.queueManager.startMotion(t)}_stopAllMotions(){this.queueManager.stopAllMotions()}updateParameters(t,e){return this.queueManager.updateParam(t)}destroy(){super.destroy(),this.queueManager=void 0}motionLastFrame(t,e){return a(this,arguments,(function*(t,e,{expression:r}={}){const o=yield this.getMotionAndApplyExpression(t,e,r);return!!o&&(this.playing=!0,$e(this.queueManager,this.parent,o),this.playing=!1,!0)}))}}class ze extends e.utils.EventEmitter{constructor(t){super(),s(this,"tag"),s(this,"manager"),s(this,"settings"),s(this,"state",new ae),s(this,"playing",!1),s(this,"destroyed",!1),s(this,"parent"),this.settings=t.settings,this.tag=`ParallelMotionManager(${this.settings.name})`,this.state.tag=this.tag,this.manager=t.motionManager,this.parent=t}startMotion(t,e){return a(this,arguments,(function*(t,e,r=se.NORMAL,o=[]){var n;if(!this.state.reserve(t,e,r))return!1;const i=null==(n=this.manager.definitions[t])?void 0:n[e];if(!i)return!1;const s=yield this.manager.loadMotion(t,e);return!!this.state.start(s,t,e,r)&&(c.log(this.tag,"Start motion:",this.getMotionName(i)),this.emit("motionStart",t,e,void 0),this.playing=!0,this._startMotion(s,void 0,o),!0)}))}startRandomMotion(t,e){return a(this,null,(function*(){const r=this.manager.definitions[t];if(null==r?void 0:r.length){const o=[];for(let e=0;e<r.length;e++)null===this.manager.motionGroups[t][e]||this.state.isActive(t,e)||o.push(e);if(o.length){const r=o[Math.floor(Math.random()*o.length)];return this.startMotion(t,r,e)}}return!1}))}stopAllMotions(){this._stopAllMotions(),this.state.reset()}update(t,e){return this.isFinished()&&(this.playing&&(this.playing=!1,this.emit("motionFinish")),this.state.complete()),this.updateParameters(t,e)}destroy(){this.destroyed=!0,this.emit("destroy"),this.stopAllMotions()}}class Ve extends ze{constructor(t){super(t),s(this,"queueManager",new MotionQueueManager)}isFinished(){return this.queueManager.isFinished()}getMotionName(t){return t.file}_startMotion(t,e,r){return t.onFinishHandler=e,r&&r.length>0&&(t.motions=t.motions.filter((t=>!r.includes(t._$4P)))),this.queueManager.stopAllMotions(),this.queueManager.startMotion(t)}_stopAllMotions(){this.queueManager.stopAllMotions()}updateParameters(t,e){return this.queueManager.updateParam(t)}destroy(){super.destroy(),this.queueManager=void 0}playMotionLastFrame(t,e){return a(this,null,(function*(){var r;if(!this.state.reserve(t,e,se.FORCE))return!1;const o=null==(r=this.manager.definitions[t])?void 0:r[e];if(!o)return!1;const n=yield this.manager.loadMotion(t,e);return!!this.state.start(n,t,e,se.FORCE)&&(c.log(this.tag,"Start motion:",this.getMotionName(o)),this.queueManager.stopAllMotions(),this.emit("motionStart",t,e,void 0),this.playing=!0,!!$e(this.queueManager,this.parent,n)&&(this.playing=!1,!0))}))}}class Ye{constructor(t){s(this,"leftParam"),s(this,"rightParam"),s(this,"blinkInterval",4e3),s(this,"closingDuration",100),s(this,"closedDuration",50),s(this,"openingDuration",150),s(this,"eyeState",0),s(this,"eyeParamValue",1),s(this,"closedTimer",0),s(this,"nextBlinkTimeLeft",this.blinkInterval),this.coreModel=t,this.leftParam=t.getParamIndex("PARAM_EYE_L_OPEN"),this.rightParam=t.getParamIndex("PARAM_EYE_R_OPEN")}setEyeParams(t){this.eyeParamValue=p(t,0,1),this.coreModel.setParamFloat(this.leftParam,this.eyeParamValue),this.coreModel.setParamFloat(this.rightParam,this.eyeParamValue)}update(t){switch(this.eyeState){case 0:this.nextBlinkTimeLeft-=t,this.nextBlinkTimeLeft<0&&(this.eyeState=1,this.nextBlinkTimeLeft=this.blinkInterval+this.closingDuration+this.closedDuration+this.openingDuration+d(0,2e3));break;case 1:this.setEyeParams(this.eyeParamValue+t/this.closingDuration),this.eyeParamValue<=0&&(this.eyeState=2,this.closedTimer=0);break;case 2:this.closedTimer+=t,this.closedTimer>=this.closedDuration&&(this.eyeState=3);break;case 3:this.setEyeParams(this.eyeParamValue+t/this.openingDuration),this.eyeParamValue>=1&&(this.eyeState=0)}}}const Ke=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);class Je extends de{constructor(t,e,r){super(),s(this,"settings"),s(this,"options"),s(this,"coreModel"),s(this,"motionManager"),s(this,"parallelMotionManager"),s(this,"eyeBlink"),s(this,"eyeballXParamIndex"),s(this,"eyeballYParamIndex"),s(this,"angleXParamIndex"),s(this,"angleYParamIndex"),s(this,"angleZParamIndex"),s(this,"bodyAngleXParamIndex"),s(this,"breathParamIndex"),s(this,"textureFlipY",!0),s(this,"lipSync",!0),s(this,"drawDataCount",0),s(this,"disableCulling",!1),s(this,"hasDrawn",!1),this.coreModel=t,this.settings=e,this.options=Object.assign({},{breathDepth:1},r),this.motionManager=new Xe(this),this.parallelMotionManager=[],this.eyeBlink=new Ye(t),this.eyeballXParamIndex=t.getParamIndex("PARAM_EYE_BALL_X"),this.eyeballYParamIndex=t.getParamIndex("PARAM_EYE_BALL_Y"),this.angleXParamIndex=t.getParamIndex("PARAM_ANGLE_X"),this.angleYParamIndex=t.getParamIndex("PARAM_ANGLE_Y"),this.angleZParamIndex=t.getParamIndex("PARAM_ANGLE_Z"),this.bodyAngleXParamIndex=t.getParamIndex("PARAM_BODY_ANGLE_X"),this.breathParamIndex=t.getParamIndex("PARAM_BREATH"),this.init()}init(){super.init(),this.settings.initParams&&this.settings.initParams.forEach((({id:t,value:e})=>this.coreModel.setParamFloat(t,e))),this.settings.initOpacities&&this.settings.initOpacities.forEach((({id:t,value:e})=>this.coreModel.setPartsOpacity(t,e))),this.coreModel.saveParam();const t=this.coreModel.getModelContext()._$aS;(null==t?void 0:t.length)&&(this.drawDataCount=t.length);let e=this.coreModel.drawParamWebGL.culling;Object.defineProperty(this.coreModel.drawParamWebGL,"culling",{set:t=>e=t,get:()=>!this.disableCulling&&e});const r=this.coreModel.getModelContext().clipManager,o=r.setupClip;r.setupClip=(t,e)=>{o.call(r,t,e),e.gl.viewport(...this.viewport)}}getSize(){return[this.coreModel.getCanvasWidth(),this.coreModel.getCanvasHeight()]}getLayout(){const t={};if(this.settings.layout)for(const[e,r]of Object.entries(this.settings.layout)){let o=e;"center_x"===e?o="centerX":"center_y"===e&&(o="centerY"),t[o]=r}return t}updateWebGLContext(t,e){const r=this.coreModel.drawParamWebGL;r.firstDraw=!0,r.setGL(t),r.glno=e;for(const[i,s]of Object.entries(r))s instanceof WebGLBuffer&&(r[i]=null);const o=this.coreModel.getModelContext().clipManager;o.curFrameNo=e;const n=t.getParameter(t.FRAMEBUFFER_BINDING);o.getMaskRenderTexture(),t.bindFramebuffer(t.FRAMEBUFFER,n)}bindTexture(t,e){this.coreModel.setTexture(t,e)}getHitAreaDefs(){var t;return(null==(t=this.settings.hitAreas)?void 0:t.map((t=>({id:t.id,name:t.name,index:this.coreModel.getDrawDataIndex(t.id)}))))||[]}getDrawableIDs(){const t=this.coreModel.getModelContext(),e=[];for(let r=0;r<this.drawDataCount;r++){const o=t.getDrawData(r);o&&e.push(o.getDrawDataID().id)}return e}getDrawableIndex(t){return this.coreModel.getDrawDataIndex(t)}getDrawableVertices(t){if("string"==typeof t&&-1===(t=this.coreModel.getDrawDataIndex(t)))throw new TypeError("Unable to find drawable ID: "+t);return this.coreModel.getTransformedPoints(t).slice()}hitTest(t,e){return this.hasDrawn||c.warn("Trying to hit-test a Cubism 2 model that has not been rendered yet. The result will always be empty since the draw data is not ready."),super.hitTest(t,e)}update(t,e){var r,o,n,i;super.update(t,e);const s=this.coreModel,a=this.updateMotions(s,e);if(s.saveParam(),null==(r=this.motionManager.expressionManager)||r.update(s,e),a||null==(o=this.eyeBlink)||o.update(t),this.updateFocus(),this.updateNaturalMovements(t,e),this.lipSync&&this.motionManager.currentAudio){let t=this.motionManager.mouthSync(),e=0;const r=1,o=.4;t>0&&(e=.4),t=Math.pow(t,o),t=p(t,e,r);for(let n=0;n<this.motionManager.lipSyncIds.length;++n)this.coreModel.setParamFloat(this.coreModel.getParamIndex(this.motionManager.lipSyncIds[n]),t)}null==(n=this.physics)||n.update(e),null==(i=this.pose)||i.update(t),this.emit("beforeModelUpdate"),s.update(),s.loadParam()}updateFocus(){this.coreModel.addToParamFloat(this.eyeballXParamIndex,this.focusController.x),this.coreModel.addToParamFloat(this.eyeballYParamIndex,this.focusController.y),this.coreModel.addToParamFloat(this.angleXParamIndex,30*this.focusController.x),this.coreModel.addToParamFloat(this.angleYParamIndex,30*this.focusController.y),this.coreModel.addToParamFloat(this.angleZParamIndex,this.focusController.x*this.focusController.y*-30),this.coreModel.addToParamFloat(this.bodyAngleXParamIndex,10*this.focusController.x)}updateNaturalMovements(t,e){const r=e/1e3*2*Math.PI;this.coreModel.addToParamFloat(this.angleXParamIndex,15*this.options.breathDepth*Math.sin(r/6.5345)*.5),this.coreModel.addToParamFloat(this.angleYParamIndex,8*this.options.breathDepth*Math.sin(r/3.5345)*.5),this.coreModel.addToParamFloat(this.angleZParamIndex,10*this.options.breathDepth*Math.sin(r/5.5345)*.5),this.coreModel.addToParamFloat(this.bodyAngleXParamIndex,4*this.options.breathDepth*Math.sin(r/15.5345)*.5),this.coreModel.setParamFloat(this.breathParamIndex,.5+.5*Math.sin(r/3.2345))}draw(t){const e=this.disableCulling;t.getParameter(t.FRAMEBUFFER_BINDING)&&(this.disableCulling=!0);const r=this.drawingMatrix;Ke[0]=r.a,Ke[1]=r.b,Ke[4]=r.c,Ke[5]=r.d,Ke[12]=r.tx,Ke[13]=r.ty,this.coreModel.setMatrix(Ke),this.coreModel.draw(),this.hasDrawn=!0,this.disableCulling=e}extendParallelMotionManager(t){for(;this.parallelMotionManager.length<t;)this.parallelMotionManager.push(new Ve(this))}destroy(){super.destroy(),this.coreModel=void 0}}class Qe extends ie{constructor(t){if(super(t),s(this,"moc"),s(this,"textures"),s(this,"layout"),s(this,"hitAreas"),s(this,"initParams"),s(this,"initOpacities"),s(this,"expressions"),s(this,"motions",{}),!Qe.isValidJSON(t))throw new TypeError("Invalid JSON.");this.moc=t.model,y("string",t,this,"textures","textures"),this.copy(t)}static isValidJSON(t){var e;return!!t&&"string"==typeof t.model&&(null==(e=t.textures)?void 0:e.length)>0&&t.textures.every((t=>"string"==typeof t))}copy(t){f("string",t,this,"name","name"),f("string",t,this,"pose","pose"),f("string",t,this,"physics","physics"),f("object",t,this,"layout","layout"),f("object",t,this,"motions","motions"),y("object",t,this,"hit_areas","hitAreas"),y("object",t,this,"expressions","expressions"),y("object",t,this,"init_params","initParams"),y("object",t,this,"init_opacities","initOpacities")}replaceFiles(t){super.replaceFiles(t);for(const[e,r]of Object.entries(this.motions))for(let o=0;o<r.length;o++)r[o].file=t(r[o].file,`motions.${e}[${o}].file`),void 0!==r[o].sound&&(r[o].sound=t(r[o].sound,`motions.${e}[${o}].sound`));if(this.expressions)for(let e=0;e<this.expressions.length;e++)this.expressions[e].file=t(this.expressions[e].file,`expressions[${e}].file`)}}const Ze={x:PhysicsHair.Src.SRC_TO_X,y:PhysicsHair.Src.SRC_TO_Y,angle:PhysicsHair.Src.SRC_TO_G_ANGLE},tr={x:PhysicsHair.Src.SRC_TO_X,y:PhysicsHair.Src.SRC_TO_Y,angle:PhysicsHair.Src.SRC_TO_G_ANGLE};class er{constructor(t,e){s(this,"physicsHairs",[]),this.coreModel=t,e.physics_hair&&(this.physicsHairs=e.physics_hair.map((t=>{const e=new PhysicsHair;return e.setup(t.setup.length,t.setup.regist,t.setup.mass),t.src.forEach((({id:t,ptype:r,scale:o,weight:n})=>{const i=Ze[r];i&&e.addSrcParam(i,t,o,n)})),t.targets.forEach((({id:t,ptype:r,scale:o,weight:n})=>{const i=tr[r];i&&e.addTargetParam(i,t,o,n)})),e})))}update(t){this.physicsHairs.forEach((e=>e.update(this.coreModel,t)))}}class rr{constructor(t){s(this,"paramIndex",-1),s(this,"partsIndex",-1),s(this,"link",[]),this.id=t}initIndex(t){this.paramIndex=t.getParamIndex("VISIBLE:"+this.id),this.partsIndex=t.getPartsDataIndex(PartsDataID.getID(this.id)),t.setParamFloat(this.paramIndex,1)}}class or{constructor(t,e){s(this,"opacityAnimDuration",500),s(this,"partsGroups",[]),this.coreModel=t,e.parts_visible&&(this.partsGroups=e.parts_visible.map((({group:t})=>t.map((({id:t,link:e})=>{const r=new rr(t);return e&&(r.link=e.map((t=>new rr(t)))),r})))),this.init())}init(){this.partsGroups.forEach((t=>{t.forEach((t=>{if(t.initIndex(this.coreModel),t.paramIndex>=0){const e=0!==this.coreModel.getParamFloat(t.paramIndex);this.coreModel.setPartsOpacity(t.partsIndex,e?1:0),this.coreModel.setParamFloat(t.paramIndex,e?1:0),t.link.length>0&&t.link.forEach((t=>t.initIndex(this.coreModel)))}}))}))}normalizePartsOpacityGroup(t,e){const r=this.coreModel,o=.5;let n=1,i=t.findIndex((({paramIndex:t,partsIndex:e})=>e>=0&&0!==r.getParamFloat(t)));if(i>=0){const o=r.getPartsOpacity(t[i].partsIndex);n=p(o+e/this.opacityAnimDuration,0,1)}else i=0,n=1;t.forEach((({partsIndex:t},e)=>{if(t>=0)if(i==e)r.setPartsOpacity(t,n);else{let e,i=r.getPartsOpacity(t);e=n<o?-.5*n/o+1:(1-n)*o/.5;(1-e)*(1-n)>.15&&(e=1-.15/(1-n)),i>e&&(i=e),r.setPartsOpacity(t,i)}}))}copyOpacity(t){const e=this.coreModel;t.forEach((({partsIndex:t,link:r})=>{if(t>=0&&r){const o=e.getPartsOpacity(t);r.forEach((({partsIndex:t})=>{t>=0&&e.setPartsOpacity(t,o)}))}}))}update(t){this.partsGroups.forEach((e=>{this.normalizePartsOpacityGroup(e,t),this.copyOpacity(e)}))}}Te.registerRuntime({version:2,test:t=>t instanceof Qe||Qe.isValidJSON(t),ready:()=>Promise.resolve(),isValidMoc(t){if(t.byteLength<3)return!1;const e=new Int8Array(t,0,3);return"moc"===String.fromCharCode(...e)},createModelSettings:t=>new Qe(t),createCoreModel(t){const e=Live2DModelWebGL.loadModel(t),r=Live2D.getError();if(r)throw r;return e},createInternalModel:(t,e,r)=>new Je(t,e,r),createPose:(t,e)=>new or(t,e),createPhysics:(t,e)=>new er(t,e)}),t.Cubism2ExpressionManager=Be,t.Cubism2InternalModel=Je,t.Cubism2ModelSettings=Qe,t.Cubism2MotionManager=Xe,t.Cubism2ParallelMotionManager=Ve,t.ExpressionManager=v,t.FileLoader=Fe,t.FocusController=M,t.InternalModel=de,t.LOGICAL_HEIGHT=2,t.LOGICAL_WIDTH=2,t.Live2DExpression=We,t.Live2DEyeBlink=Ye,t.Live2DFactory=Te,t.Live2DLoader=ve,t.Live2DModel=qe,t.Live2DPhysics=er,t.Live2DPose=or,t.Live2DTransform=Ne,t.ModelSettings=ie,t.MotionManager=ce,t.MotionPreloadStrategy=he,t.MotionPriority=se,t.MotionState=ae,t.SoundManager=ue,t.VERSION="v0.5.0",t.VOLUME=le,t.XHRLoader=me,t.ZipLoader=Se,t.applyMixins=function(t,e){e.forEach((e=>{Object.getOwnPropertyNames(e.prototype).forEach((r=>{"constructor"!==r&&Object.defineProperty(t.prototype,r,Object.getOwnPropertyDescriptor(e.prototype,r))}))}))},t.clamp=p,t.config=h,t.copyArray=y,t.copyProperty=f,t.folderName=m,t.logger=c,t.rand=d,t.remove=g,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@pixi/core"),require("@pixi/sound"),require("@pixi/display")):"function"==typeof define&&define.amd?define(["exports","@pixi/core","@pixi/sound","@pixi/display"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).PIXI=t.PIXI||{},t.PIXI.live2d=t.PIXI.live2d||{}),t.PIXI,t.PIXI,t.PIXI)}(this,(function(t,e,r,o){"use strict";var n=Object.defineProperty,i=Math.pow,s=(t,e,r)=>((t,e,r)=>e in t?n(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r)(t,"symbol"!=typeof e?e+"":e,r),a=(t,e,r)=>new Promise(((o,n)=>{var i=t=>{try{a(r.next(t))}catch(e){n(e)}},s=t=>{try{a(r.throw(t))}catch(e){n(e)}},a=t=>t.done?o(t.value):Promise.resolve(t.value).then(i,s);a((r=r.apply(t,e)).next())}));var l,u;(u=l||(l={})).supportMoreMaskDivisions=!0,u.setOpacityFromMotion=!1;const h={LOG_LEVEL_VERBOSE:0,LOG_LEVEL_WARNING:1,LOG_LEVEL_ERROR:2,LOG_LEVEL_NONE:999,logLevel:1,sound:!0,fftSize:512,motionSync:!0,motionFadingDuration:500,idleMotionFadingDuration:2e3,expressionFadingDuration:500,preserveExpressionOnMotion:!0,cubism4:l},c={log(t,...e){h.logLevel<=h.LOG_LEVEL_VERBOSE&&console.log(`[${t}]`,...e)},warn(t,...e){h.logLevel<=h.LOG_LEVEL_WARNING&&console.warn(`[${t}]`,...e)},error(t,...e){h.logLevel<=h.LOG_LEVEL_ERROR&&console.error(`[${t}]`,...e)}};function p(t,e,r){return t<e?e:t>r?r:t}function d(t,e){return Math.random()*(e-t)+t}function f(t,e,r,o,n){const i=e[o];null!==i&&typeof i===t&&(r[n]=i)}function y(t,e,r,o,n){const i=e[o];Array.isArray(i)&&(r[n]=i.filter((e=>null!==e&&typeof e===t)))}function m(t){let e=t.lastIndexOf("/");return-1!=e&&(t=t.slice(0,e)),e=t.lastIndexOf("/"),-1!==e&&(t=t.slice(e+1)),t}function g(t,e){const r=t.indexOf(e);-1!==r&&t.splice(r,1)}class v extends e.utils.EventEmitter{constructor(t,e){super(),s(this,"tag"),s(this,"settings"),s(this,"expressions",[]),s(this,"defaultExpression"),s(this,"currentExpression"),s(this,"reserveExpressionIndex",-1),s(this,"destroyed",!1),this.settings=t,this.tag=`ExpressionManager(${t.name})`}init(){this.defaultExpression=this.createExpression({},void 0),this.currentExpression=this.defaultExpression,this.stopAllExpressions()}loadExpression(t){return a(this,null,(function*(){if(!this.definitions[t])return void c.warn(this.tag,`Undefined expression at [${t}]`);if(null===this.expressions[t])return void c.warn(this.tag,`Cannot set expression at [${t}] because it's already failed in loading.`);if(this.expressions[t])return this.expressions[t];const e=yield this._loadExpression(t);return this.expressions[t]=e,e}))}_loadExpression(t){throw new Error("Not implemented.")}setRandomExpression(){return a(this,null,(function*(){if(this.definitions.length){const t=[];for(let e=0;e<this.definitions.length;e++)null!==this.expressions[e]&&this.expressions[e]!==this.currentExpression&&e!==this.reserveExpressionIndex&&t.push(e);if(t.length){const e=Math.floor(Math.random()*t.length);return this.setExpression(e)}}return!1}))}resetExpression(){this._setExpression(this.defaultExpression)}restoreExpression(){this._setExpression(this.currentExpression)}setExpression(t){return a(this,null,(function*(){if("number"!=typeof t&&(t=this.getExpressionIndex(t)),!(t>-1&&t<this.definitions.length))return!1;if(t===this.expressions.indexOf(this.currentExpression))return!1;this.reserveExpressionIndex=t;const e=yield this.loadExpression(t);return!(!e||this.reserveExpressionIndex!==t)&&(this.reserveExpressionIndex=-1,this.currentExpression=e,this._setExpression(e),!0)}))}update(t,e){return!this.isFinished()&&this.updateParameters(t,e)}destroy(){this.destroyed=!0,this.emit("destroy");this.definitions=void 0,this.expressions=void 0}}const b=40/7.5,x=1/150;class M{constructor(){s(this,"targetX",0),s(this,"targetY",0),s(this,"x",0),s(this,"y",0),s(this,"vx",0),s(this,"vy",0)}focus(t,e,r=!1){this.targetX=p(t,-1,1),this.targetY=p(e,-1,1),r&&(this.x=this.targetX,this.y=this.targetY)}update(t){const e=this.targetX-this.x,r=this.targetY-this.y;if(Math.abs(e)<.01&&Math.abs(r)<.01)return;const o=Math.sqrt(i(e,2)+i(r,2)),n=b/(1e3/t);let s=n*(e/o)-this.vx,a=n*(r/o)-this.vy;const l=Math.sqrt(i(s,2)+i(a,2)),u=n*x*t;l>u&&(s*=u/l,a*=u/l),this.vx+=s,this.vy+=a;const h=Math.sqrt(i(this.vx,2)+i(this.vy,2)),c=.5*(Math.sqrt(i(u,2)+8*u*o)-u);h>c&&(this.vx*=c/h,this.vy*=c/h),this.x+=this.vx,this.y+=this.vy}}var w="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function P(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function E(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if("function"==typeof e){var r=function t(){return this instanceof t?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach((function(e){var o=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(r,e,o.get?o:{enumerable:!0,get:function(){return t[e]}})})),r}var A,O,I,S,j,F,_,T,L,R,D,k,C,N,U,G,q,H,W,B,$,X,z,V,Y,K,J,Q,Z,tt={},et={exports:{}},rt=et.exports;function ot(){return I?O:(I=1,O=Error)}function nt(){return j?S:(j=1,S=EvalError)}function it(){return _?F:(_=1,F=RangeError)}function st(){return L?T:(L=1,T=ReferenceError)}function at(){return D?R:(D=1,R=SyntaxError)}function lt(){return C?k:(C=1,k=TypeError)}function ut(){return U?N:(U=1,N=URIError)}function ht(){if(W)return H;W=1;var t="undefined"!=typeof Symbol&&Symbol,e=q?G:(q=1,G=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var t={},e=Symbol("test"),r=Object(e);if("string"==typeof e)return!1;if("[object Symbol]"!==Object.prototype.toString.call(e))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(e in t[e]=42,t)return!1;if("function"==typeof Object.keys&&0!==Object.keys(t).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(t).length)return!1;var o=Object.getOwnPropertySymbols(t);if(1!==o.length||o[0]!==e)return!1;if(!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var n=Object.getOwnPropertyDescriptor(t,e);if(42!==n.value||!0!==n.enumerable)return!1}return!0});return H=function(){return"function"==typeof t&&("function"==typeof Symbol&&("symbol"==typeof t("foo")&&("symbol"==typeof Symbol("bar")&&e())))}}function ct(){if($)return B;$=1;var t={__proto__:null,foo:{}},e=Object;return B=function(){return{__proto__:t}.foo===t.foo&&!(t instanceof e)}}function pt(){if(Y)return V;Y=1;var t=function(){if(z)return X;z=1;var t=Object.prototype.toString,e=Math.max,r=function(t,e){for(var r=[],o=0;o<t.length;o+=1)r[o]=t[o];for(var n=0;n<e.length;n+=1)r[n+t.length]=e[n];return r};return X=function(o){var n=this;if("function"!=typeof n||"[object Function]"!==t.apply(n))throw new TypeError("Function.prototype.bind called on incompatible "+n);for(var i,s=function(t,e){for(var r=[],o=1,n=0;o<t.length;o+=1,n+=1)r[n]=t[o];return r}(arguments),a=e(0,n.length-s.length),l=[],u=0;u<a;u++)l[u]="$"+u;if(i=Function("binder","return function ("+function(t,e){for(var r="",o=0;o<t.length;o+=1)r+=t[o],o+1<t.length&&(r+=e);return r}(l,",")+"){ return binder.apply(this,arguments); }")((function(){if(this instanceof i){var t=n.apply(this,r(s,arguments));return Object(t)===t?t:this}return n.apply(o,r(s,arguments))})),n.prototype){var h=function(){};h.prototype=n.prototype,i.prototype=new h,h.prototype=null}return i},X}();return V=Function.prototype.bind||t}function dt(){if(J)return K;J=1;var t=Function.prototype.call,e=Object.prototype.hasOwnProperty,r=pt();return K=r.call(t,e)}function ft(){if(Z)return Q;var t;Z=1;var e=ot(),r=nt(),o=it(),n=st(),i=at(),s=lt(),a=ut(),l=Function,u=function(t){try{return l('"use strict"; return ('+t+").constructor;")()}catch(e){}},h=Object.getOwnPropertyDescriptor;if(h)try{h({},"")}catch(T){h=null}var c=function(){throw new s},p=h?function(){try{return c}catch(t){try{return h(arguments,"callee").get}catch(e){return c}}}():c,d=ht()(),f=ct()(),y=Object.getPrototypeOf||(f?function(t){return t.__proto__}:null),m={},g="undefined"!=typeof Uint8Array&&y?y(Uint8Array):t,v={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?t:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?t:ArrayBuffer,"%ArrayIteratorPrototype%":d&&y?y([][Symbol.iterator]()):t,"%AsyncFromSyncIteratorPrototype%":t,"%AsyncFunction%":m,"%AsyncGenerator%":m,"%AsyncGeneratorFunction%":m,"%AsyncIteratorPrototype%":m,"%Atomics%":"undefined"==typeof Atomics?t:Atomics,"%BigInt%":"undefined"==typeof BigInt?t:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?t:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?t:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?t:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":e,"%eval%":eval,"%EvalError%":r,"%Float32Array%":"undefined"==typeof Float32Array?t:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?t:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?t:FinalizationRegistry,"%Function%":l,"%GeneratorFunction%":m,"%Int8Array%":"undefined"==typeof Int8Array?t:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?t:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?t:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":d&&y?y(y([][Symbol.iterator]())):t,"%JSON%":"object"==typeof JSON?JSON:t,"%Map%":"undefined"==typeof Map?t:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&d&&y?y((new Map)[Symbol.iterator]()):t,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?t:Promise,"%Proxy%":"undefined"==typeof Proxy?t:Proxy,"%RangeError%":o,"%ReferenceError%":n,"%Reflect%":"undefined"==typeof Reflect?t:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?t:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&d&&y?y((new Set)[Symbol.iterator]()):t,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?t:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":d&&y?y(""[Symbol.iterator]()):t,"%Symbol%":d?Symbol:t,"%SyntaxError%":i,"%ThrowTypeError%":p,"%TypedArray%":g,"%TypeError%":s,"%Uint8Array%":"undefined"==typeof Uint8Array?t:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?t:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?t:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?t:Uint32Array,"%URIError%":a,"%WeakMap%":"undefined"==typeof WeakMap?t:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?t:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?t:WeakSet};if(y)try{null.error}catch(T){var b=y(y(T));v["%Error.prototype%"]=b}var x=function t(e){var r;if("%AsyncFunction%"===e)r=u("async function () {}");else if("%GeneratorFunction%"===e)r=u("function* () {}");else if("%AsyncGeneratorFunction%"===e)r=u("async function* () {}");else if("%AsyncGenerator%"===e){var o=t("%AsyncGeneratorFunction%");o&&(r=o.prototype)}else if("%AsyncIteratorPrototype%"===e){var n=t("%AsyncGenerator%");n&&y&&(r=y(n.prototype))}return v[e]=r,r},M={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},w=pt(),P=dt(),E=w.call(Function.call,Array.prototype.concat),A=w.call(Function.apply,Array.prototype.splice),O=w.call(Function.call,String.prototype.replace),I=w.call(Function.call,String.prototype.slice),S=w.call(Function.call,RegExp.prototype.exec),j=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,F=/\\(\\)?/g,_=function(t,e){var r,o=t;if(P(M,o)&&(o="%"+(r=M[o])[0]+"%"),P(v,o)){var n=v[o];if(n===m&&(n=x(o)),void 0===n&&!e)throw new s("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:r,name:o,value:n}}throw new i("intrinsic "+t+" does not exist!")};return Q=function(t,e){if("string"!=typeof t||0===t.length)throw new s("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof e)throw new s('"allowMissing" argument must be a boolean');if(null===S(/^%?[^%]*%?$/,t))throw new i("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=function(t){var e=I(t,0,1),r=I(t,-1);if("%"===e&&"%"!==r)throw new i("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==e)throw new i("invalid intrinsic syntax, expected opening `%`");var o=[];return O(t,j,(function(t,e,r,n){o[o.length]=r?O(n,F,"$1"):e||t})),o}(t),o=r.length>0?r[0]:"",n=_("%"+o+"%",e),a=n.name,l=n.value,u=!1,c=n.alias;c&&(o=c[0],A(r,E([0,1],c)));for(var p=1,d=!0;p<r.length;p+=1){var f=r[p],y=I(f,0,1),m=I(f,-1);if(('"'===y||"'"===y||"`"===y||'"'===m||"'"===m||"`"===m)&&y!==m)throw new i("property names with quotes must have matching quotes");if("constructor"!==f&&d||(u=!0),P(v,a="%"+(o+="."+f)+"%"))l=v[a];else if(null!=l){if(!(f in l)){if(!e)throw new s("base intrinsic for "+t+" exists, but the property is not available.");return}if(h&&p+1>=r.length){var g=h(l,f);l=(d=!!g)&&"get"in g&&!("originalValue"in g.get)?g.get:l[f]}else d=P(l,f),l=l[f];d&&!u&&(v[a]=l)}}return l},Q}var yt,mt,gt,vt,bt,xt,Mt,wt,Pt,Et,At,Ot,It,St={exports:{}};function jt(){if(mt)return yt;mt=1;var t=ft()("%Object.defineProperty%",!0)||!1;if(t)try{t({},"a",{value:1})}catch(e){t=!1}return yt=t}function Ft(){if(vt)return gt;vt=1;var t=ft()("%Object.getOwnPropertyDescriptor%",!0);if(t)try{t([],"length")}catch(e){t=null}return gt=t}function _t(){if(xt)return bt;xt=1;var t=jt(),e=at(),r=lt(),o=Ft();return bt=function(n,i,s){if(!n||"object"!=typeof n&&"function"!=typeof n)throw new r("`obj` must be an object or a function`");if("string"!=typeof i&&"symbol"!=typeof i)throw new r("`property` must be a string or a symbol`");if(arguments.length>3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new r("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new r("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new r("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new r("`loose`, if provided, must be a boolean");var a=arguments.length>3?arguments[3]:null,l=arguments.length>4?arguments[4]:null,u=arguments.length>5?arguments[5]:null,h=arguments.length>6&&arguments[6],c=!!o&&o(n,i);if(t)t(n,i,{configurable:null===u&&c?c.configurable:!u,enumerable:null===a&&c?c.enumerable:!a,value:s,writable:null===l&&c?c.writable:!l});else{if(!h&&(a||l||u))throw new e("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");n[i]=s}},bt}function Tt(){if(wt)return Mt;wt=1;var t=jt(),e=function(){return!!t};return e.hasArrayLengthDefineBug=function(){if(!t)return null;try{return 1!==t([],"length",{value:1}).length}catch(e){return!0}},Mt=e}function Lt(){if(Et)return Pt;Et=1;var t=ft(),e=_t(),r=Tt()(),o=Ft(),n=lt(),i=t("%Math.floor%");return Pt=function(t,s){if("function"!=typeof t)throw new n("`fn` is not a function");if("number"!=typeof s||s<0||s>4294967295||i(s)!==s)throw new n("`length` must be a positive 32-bit integer");var a=arguments.length>2&&!!arguments[2],l=!0,u=!0;if("length"in t&&o){var h=o(t,"length");h&&!h.configurable&&(l=!1),h&&!h.writable&&(u=!1)}return(l||u||!a)&&(r?e(t,"length",s,!0,!0):e(t,"length",s)),t},Pt}function Rt(){if(It)return Ot;It=1;var t=ft(),e=(At||(At=1,function(t){var e=pt(),r=ft(),o=Lt(),n=lt(),i=r("%Function.prototype.apply%"),s=r("%Function.prototype.call%"),a=r("%Reflect.apply%",!0)||e.call(s,i),l=jt(),u=r("%Math.max%");t.exports=function(t){if("function"!=typeof t)throw new n("a function is required");var r=a(e,s,arguments);return o(r,1+u(0,t.length-(arguments.length-1)),!0)};var h=function(){return a(e,i,arguments)};l?l(t.exports,"apply",{value:h}):t.exports.apply=h}(St)),St.exports),r=e(t("String.prototype.indexOf"));return Ot=function(o,n){var i=t(o,!!n);return"function"==typeof i&&r(o,".prototype.")>-1?e(i):i}}const Dt=E(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var kt,Ct,Nt,Ut,Gt,qt,Ht,Wt,Bt,$t,Xt,zt,Vt,Yt,Kt;function Jt(){if(Ct)return kt;Ct=1;var t="function"==typeof Map&&Map.prototype,e=Object.getOwnPropertyDescriptor&&t?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,r=t&&e&&"function"==typeof e.get?e.get:null,o=t&&Map.prototype.forEach,n="function"==typeof Set&&Set.prototype,i=Object.getOwnPropertyDescriptor&&n?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,s=n&&i&&"function"==typeof i.get?i.get:null,a=n&&Set.prototype.forEach,l="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,u="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,h="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,c=Boolean.prototype.valueOf,p=Object.prototype.toString,d=Function.prototype.toString,f=String.prototype.match,y=String.prototype.slice,m=String.prototype.replace,g=String.prototype.toUpperCase,v=String.prototype.toLowerCase,b=RegExp.prototype.test,x=Array.prototype.concat,M=Array.prototype.join,P=Array.prototype.slice,E=Math.floor,A="function"==typeof BigInt?BigInt.prototype.valueOf:null,O=Object.getOwnPropertySymbols,I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,S="function"==typeof Symbol&&"object"==typeof Symbol.iterator,j="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===S||"symbol")?Symbol.toStringTag:null,F=Object.prototype.propertyIsEnumerable,_=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(t){return t.__proto__}:null);function T(t,e){if(t===1/0||t===-1/0||t!=t||t&&t>-1e3&&t<1e3||b.call(/e/,e))return e;var r=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof t){var o=t<0?-E(-t):E(t);if(o!==t){var n=String(o),i=y.call(e,n.length+1);return m.call(n,r,"$&_")+"."+m.call(m.call(i,/([0-9]{3})/g,"$&_"),/_$/,"")}}return m.call(e,r,"$&_")}var L=Dt,R=L.custom,D=G(R)?R:null;function k(t,e,r){var o="double"===(r.quoteStyle||e)?'"':"'";return o+t+o}function C(t){return m.call(String(t),/"/g,""")}function N(t){return!("[object Array]"!==W(t)||j&&"object"==typeof t&&j in t)}function U(t){return!("[object RegExp]"!==W(t)||j&&"object"==typeof t&&j in t)}function G(t){if(S)return t&&"object"==typeof t&&t instanceof Symbol;if("symbol"==typeof t)return!0;if(!t||"object"!=typeof t||!I)return!1;try{return I.call(t),!0}catch(e){}return!1}kt=function t(e,n,i,p){var g=n||{};if(H(g,"quoteStyle")&&"single"!==g.quoteStyle&&"double"!==g.quoteStyle)throw new TypeError('option "quoteStyle" must be "single" or "double"');if(H(g,"maxStringLength")&&("number"==typeof g.maxStringLength?g.maxStringLength<0&&g.maxStringLength!==1/0:null!==g.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var b=!H(g,"customInspect")||g.customInspect;if("boolean"!=typeof b&&"symbol"!==b)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(H(g,"indent")&&null!==g.indent&&"\t"!==g.indent&&!(parseInt(g.indent,10)===g.indent&&g.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(H(g,"numericSeparator")&&"boolean"!=typeof g.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var E=g.numericSeparator;if(void 0===e)return"undefined";if(null===e)return"null";if("boolean"==typeof e)return e?"true":"false";if("string"==typeof e)return $(e,g);if("number"==typeof e){if(0===e)return 1/0/e>0?"0":"-0";var O=String(e);return E?T(e,O):O}if("bigint"==typeof e){var R=String(e)+"n";return E?T(e,R):R}var q=void 0===g.depth?5:g.depth;if(void 0===i&&(i=0),i>=q&&q>0&&"object"==typeof e)return N(e)?"[Array]":"[Object]";var X=function(t,e){var r;if("\t"===t.indent)r="\t";else{if(!("number"==typeof t.indent&&t.indent>0))return null;r=M.call(Array(t.indent+1)," ")}return{base:r,prev:M.call(Array(e+1),r)}}(g,i);if(void 0===p)p=[];else if(B(p,e)>=0)return"[Circular]";function Q(e,r,o){if(r&&(p=P.call(p)).push(r),o){var n={depth:g.depth};return H(g,"quoteStyle")&&(n.quoteStyle=g.quoteStyle),t(e,n,i+1,p)}return t(e,g,i+1,p)}if("function"==typeof e&&!U(e)){var Z=function(t){if(t.name)return t.name;var e=f.call(d.call(t),/^function\s*([\w$]+)/);if(e)return e[1];return null}(e),tt=J(e,Q);return"[Function"+(Z?": "+Z:" (anonymous)")+"]"+(tt.length>0?" { "+M.call(tt,", ")+" }":"")}if(G(e)){var et=S?m.call(String(e),/^(Symbol\(.*\))_[^)]*$/,"$1"):I.call(e);return"object"!=typeof e||S?et:z(et)}if(function(t){if(!t||"object"!=typeof t)return!1;if("undefined"!=typeof HTMLElement&&t instanceof HTMLElement)return!0;return"string"==typeof t.nodeName&&"function"==typeof t.getAttribute}(e)){for(var rt="<"+v.call(String(e.nodeName)),ot=e.attributes||[],nt=0;nt<ot.length;nt++)rt+=" "+ot[nt].name+"="+k(C(ot[nt].value),"double",g);return rt+=">",e.childNodes&&e.childNodes.length&&(rt+="..."),rt+="</"+v.call(String(e.nodeName))+">"}if(N(e)){if(0===e.length)return"[]";var it=J(e,Q);return X&&!function(t){for(var e=0;e<t.length;e++)if(B(t[e],"\n")>=0)return!1;return!0}(it)?"["+K(it,X)+"]":"[ "+M.call(it,", ")+" ]"}if(function(t){return!("[object Error]"!==W(t)||j&&"object"==typeof t&&j in t)}(e)){var st=J(e,Q);return"cause"in Error.prototype||!("cause"in e)||F.call(e,"cause")?0===st.length?"["+String(e)+"]":"{ ["+String(e)+"] "+M.call(st,", ")+" }":"{ ["+String(e)+"] "+M.call(x.call("[cause]: "+Q(e.cause),st),", ")+" }"}if("object"==typeof e&&b){if(D&&"function"==typeof e[D]&&L)return L(e,{depth:q-i});if("symbol"!==b&&"function"==typeof e.inspect)return e.inspect()}if(function(t){if(!r||!t||"object"!=typeof t)return!1;try{r.call(t);try{s.call(t)}catch(rt){return!0}return t instanceof Map}catch(e){}return!1}(e)){var at=[];return o&&o.call(e,(function(t,r){at.push(Q(r,e,!0)+" => "+Q(t,e))})),Y("Map",r.call(e),at,X)}if(function(t){if(!s||!t||"object"!=typeof t)return!1;try{s.call(t);try{r.call(t)}catch(e){return!0}return t instanceof Set}catch(o){}return!1}(e)){var lt=[];return a&&a.call(e,(function(t){lt.push(Q(t,e))})),Y("Set",s.call(e),lt,X)}if(function(t){if(!l||!t||"object"!=typeof t)return!1;try{l.call(t,l);try{u.call(t,u)}catch(rt){return!0}return t instanceof WeakMap}catch(e){}return!1}(e))return V("WeakMap");if(function(t){if(!u||!t||"object"!=typeof t)return!1;try{u.call(t,u);try{l.call(t,l)}catch(rt){return!0}return t instanceof WeakSet}catch(e){}return!1}(e))return V("WeakSet");if(function(t){if(!h||!t||"object"!=typeof t)return!1;try{return h.call(t),!0}catch(e){}return!1}(e))return V("WeakRef");if(function(t){return!("[object Number]"!==W(t)||j&&"object"==typeof t&&j in t)}(e))return z(Q(Number(e)));if(function(t){if(!t||"object"!=typeof t||!A)return!1;try{return A.call(t),!0}catch(e){}return!1}(e))return z(Q(A.call(e)));if(function(t){return!("[object Boolean]"!==W(t)||j&&"object"==typeof t&&j in t)}(e))return z(c.call(e));if(function(t){return!("[object String]"!==W(t)||j&&"object"==typeof t&&j in t)}(e))return z(Q(String(e)));if("undefined"!=typeof window&&e===window)return"{ [object Window] }";if(e===w)return"{ [object globalThis] }";if(!function(t){return!("[object Date]"!==W(t)||j&&"object"==typeof t&&j in t)}(e)&&!U(e)){var ut=J(e,Q),ht=_?_(e)===Object.prototype:e instanceof Object||e.constructor===Object,ct=e instanceof Object?"":"null prototype",pt=!ht&&j&&Object(e)===e&&j in e?y.call(W(e),8,-1):ct?"Object":"",dt=(ht||"function"!=typeof e.constructor?"":e.constructor.name?e.constructor.name+" ":"")+(pt||ct?"["+M.call(x.call([],pt||[],ct||[]),": ")+"] ":"");return 0===ut.length?dt+"{}":X?dt+"{"+K(ut,X)+"}":dt+"{ "+M.call(ut,", ")+" }"}return String(e)};var q=Object.prototype.hasOwnProperty||function(t){return t in this};function H(t,e){return q.call(t,e)}function W(t){return p.call(t)}function B(t,e){if(t.indexOf)return t.indexOf(e);for(var r=0,o=t.length;r<o;r++)if(t[r]===e)return r;return-1}function $(t,e){if(t.length>e.maxStringLength){var r=t.length-e.maxStringLength,o="... "+r+" more character"+(r>1?"s":"");return $(y.call(t,0,e.maxStringLength),e)+o}return k(m.call(m.call(t,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,X),"single",e)}function X(t){var e=t.charCodeAt(0),r={8:"b",9:"t",10:"n",12:"f",13:"r"}[e];return r?"\\"+r:"\\x"+(e<16?"0":"")+g.call(e.toString(16))}function z(t){return"Object("+t+")"}function V(t){return t+" { ? }"}function Y(t,e,r,o){return t+" ("+e+") {"+(o?K(r,o):M.call(r,", "))+"}"}function K(t,e){if(0===t.length)return"";var r="\n"+e.prev+e.base;return r+M.call(t,","+r)+"\n"+e.prev}function J(t,e){var r=N(t),o=[];if(r){o.length=t.length;for(var n=0;n<t.length;n++)o[n]=H(t,n)?e(t[n],t):""}var i,s="function"==typeof O?O(t):[];if(S){i={};for(var a=0;a<s.length;a++)i["$"+s[a]]=s[a]}for(var l in t)H(t,l)&&(r&&String(Number(l))===l&&l<t.length||S&&i["$"+l]instanceof Symbol||(b.call(/[^\w$]/,l)?o.push(e(l,t)+": "+e(t[l],t)):o.push(l+": "+e(t[l],t))));if("function"==typeof O)for(var u=0;u<s.length;u++)F.call(t,s[u])&&o.push("["+e(s[u])+"]: "+e(t[s[u]],t));return o}return kt}function Qt(){if(Ut)return Nt;Ut=1;var t=ft(),e=Rt(),r=Jt(),o=lt(),n=t("%WeakMap%",!0),i=t("%Map%",!0),s=e("WeakMap.prototype.get",!0),a=e("WeakMap.prototype.set",!0),l=e("WeakMap.prototype.has",!0),u=e("Map.prototype.get",!0),h=e("Map.prototype.set",!0),c=e("Map.prototype.has",!0),p=function(t,e){for(var r,o=t;null!==(r=o.next);o=r)if(r.key===e)return o.next=r.next,r.next=t.next,t.next=r,r};return Nt=function(){var t,e,d,f={assert:function(t){if(!f.has(t))throw new o("Side channel does not contain "+r(t))},get:function(r){if(n&&r&&("object"==typeof r||"function"==typeof r)){if(t)return s(t,r)}else if(i){if(e)return u(e,r)}else if(d)return function(t,e){var r=p(t,e);return r&&r.value}(d,r)},has:function(r){if(n&&r&&("object"==typeof r||"function"==typeof r)){if(t)return l(t,r)}else if(i){if(e)return c(e,r)}else if(d)return function(t,e){return!!p(t,e)}(d,r);return!1},set:function(r,o){n&&r&&("object"==typeof r||"function"==typeof r)?(t||(t=new n),a(t,r,o)):i?(e||(e=new i),h(e,r,o)):(d||(d={key:{},next:null}),function(t,e,r){var o=p(t,e);o?o.value=r:t.next={key:e,next:t.next,value:r}}(d,r,o))}};return f}}function Zt(){if(qt)return Gt;qt=1;var t=String.prototype.replace,e=/%20/g,r="RFC3986";return Gt={default:r,formatters:{RFC1738:function(r){return t.call(r,e,"+")},RFC3986:function(t){return String(t)}},RFC1738:"RFC1738",RFC3986:r}}function te(){if(Wt)return Ht;Wt=1;var t=Zt(),e=Object.prototype.hasOwnProperty,r=Array.isArray,o=function(){for(var t=[],e=0;e<256;++e)t.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return t}(),n=function(t,e){for(var r=e&&e.plainObjects?Object.create(null):{},o=0;o<t.length;++o)void 0!==t[o]&&(r[o]=t[o]);return r},i=1024;return Ht={arrayToObject:n,assign:function(t,e){return Object.keys(e).reduce((function(t,r){return t[r]=e[r],t}),t)},combine:function(t,e){return[].concat(t,e)},compact:function(t){for(var e=[{obj:{o:t},prop:"o"}],o=[],n=0;n<e.length;++n)for(var i=e[n],s=i.obj[i.prop],a=Object.keys(s),l=0;l<a.length;++l){var u=a[l],h=s[u];"object"==typeof h&&null!==h&&-1===o.indexOf(h)&&(e.push({obj:s,prop:u}),o.push(h))}return function(t){for(;t.length>1;){var e=t.pop(),o=e.obj[e.prop];if(r(o)){for(var n=[],i=0;i<o.length;++i)void 0!==o[i]&&n.push(o[i]);e.obj[e.prop]=n}}}(e),t},decode:function(t,e,r){var o=t.replace(/\+/g," ");if("iso-8859-1"===r)return o.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(o)}catch(n){return o}},encode:function(e,r,n,s,a){if(0===e.length)return e;var l=e;if("symbol"==typeof e?l=Symbol.prototype.toString.call(e):"string"!=typeof e&&(l=String(e)),"iso-8859-1"===n)return escape(l).replace(/%u[0-9a-f]{4}/gi,(function(t){return"%26%23"+parseInt(t.slice(2),16)+"%3B"}));for(var u="",h=0;h<l.length;h+=i){for(var c=l.length>=i?l.slice(h,h+i):l,p=[],d=0;d<c.length;++d){var f=c.charCodeAt(d);45===f||46===f||95===f||126===f||f>=48&&f<=57||f>=65&&f<=90||f>=97&&f<=122||a===t.RFC1738&&(40===f||41===f)?p[p.length]=c.charAt(d):f<128?p[p.length]=o[f]:f<2048?p[p.length]=o[192|f>>6]+o[128|63&f]:f<55296||f>=57344?p[p.length]=o[224|f>>12]+o[128|f>>6&63]+o[128|63&f]:(d+=1,f=65536+((1023&f)<<10|1023&c.charCodeAt(d)),p[p.length]=o[240|f>>18]+o[128|f>>12&63]+o[128|f>>6&63]+o[128|63&f])}u+=p.join("")}return u},isBuffer:function(t){return!(!t||"object"!=typeof t)&&!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},isRegExp:function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},maybeMap:function(t,e){if(r(t)){for(var o=[],n=0;n<t.length;n+=1)o.push(e(t[n]));return o}return e(t)},merge:function t(o,i,s){if(!i)return o;if("object"!=typeof i){if(r(o))o.push(i);else{if(!o||"object"!=typeof o)return[o,i];(s&&(s.plainObjects||s.allowPrototypes)||!e.call(Object.prototype,i))&&(o[i]=!0)}return o}if(!o||"object"!=typeof o)return[o].concat(i);var a=o;return r(o)&&!r(i)&&(a=n(o,s)),r(o)&&r(i)?(i.forEach((function(r,n){if(e.call(o,n)){var i=o[n];i&&"object"==typeof i&&r&&"object"==typeof r?o[n]=t(i,r,s):o.push(r)}else o[n]=r})),o):Object.keys(i).reduce((function(r,o){var n=i[o];return e.call(r,o)?r[o]=t(r[o],n,s):r[o]=n,r}),a)}}}function ee(){if($t)return Bt;$t=1;var t=Qt(),e=te(),r=Zt(),o=Object.prototype.hasOwnProperty,n={brackets:function(t){return t+"[]"},comma:"comma",indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},i=Array.isArray,s=Array.prototype.push,a=function(t,e){s.apply(t,i(e)?e:[e])},l=Date.prototype.toISOString,u=r.default,h={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:e.encode,encodeValuesOnly:!1,format:u,formatter:r.formatters[u],indices:!1,serializeDate:function(t){return l.call(t)},skipNulls:!1,strictNullHandling:!1},c={},p=function r(o,n,s,l,u,p,d,f,y,m,g,v,b,x,M,w,P,E){for(var A,O=o,I=E,S=0,j=!1;void 0!==(I=I.get(c))&&!j;){var F=I.get(o);if(S+=1,void 0!==F){if(F===S)throw new RangeError("Cyclic object value");j=!0}void 0===I.get(c)&&(S=0)}if("function"==typeof m?O=m(n,O):O instanceof Date?O=b(O):"comma"===s&&i(O)&&(O=e.maybeMap(O,(function(t){return t instanceof Date?b(t):t}))),null===O){if(p)return y&&!w?y(n,h.encoder,P,"key",x):n;O=""}if("string"==typeof(A=O)||"number"==typeof A||"boolean"==typeof A||"symbol"==typeof A||"bigint"==typeof A||e.isBuffer(O))return y?[M(w?n:y(n,h.encoder,P,"key",x))+"="+M(y(O,h.encoder,P,"value",x))]:[M(n)+"="+M(String(O))];var _,T=[];if(void 0===O)return T;if("comma"===s&&i(O))w&&y&&(O=e.maybeMap(O,y)),_=[{value:O.length>0?O.join(",")||null:void 0}];else if(i(m))_=m;else{var L=Object.keys(O);_=g?L.sort(g):L}var R=f?n.replace(/\./g,"%2E"):n,D=l&&i(O)&&1===O.length?R+"[]":R;if(u&&i(O)&&0===O.length)return D+"[]";for(var k=0;k<_.length;++k){var C=_[k],N="object"==typeof C&&void 0!==C.value?C.value:O[C];if(!d||null!==N){var U=v&&f?C.replace(/\./g,"%2E"):C,G=i(O)?"function"==typeof s?s(D,U):D:D+(v?"."+U:"["+U+"]");E.set(o,S);var q=t();q.set(c,E),a(T,r(N,G,s,l,u,p,d,f,"comma"===s&&w&&i(O)?null:y,m,g,v,b,x,M,w,P,q))}}return T};return Bt=function(e,s){var l,u=e,c=function(t){if(!t)return h;if(void 0!==t.allowEmptyArrays&&"boolean"!=typeof t.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==t.encodeDotInKeys&&"boolean"!=typeof t.encodeDotInKeys)throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==t.encoder&&void 0!==t.encoder&&"function"!=typeof t.encoder)throw new TypeError("Encoder has to be a function.");var e=t.charset||h.charset;if(void 0!==t.charset&&"utf-8"!==t.charset&&"iso-8859-1"!==t.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var s=r.default;if(void 0!==t.format){if(!o.call(r.formatters,t.format))throw new TypeError("Unknown format option provided.");s=t.format}var a,l=r.formatters[s],u=h.filter;if(("function"==typeof t.filter||i(t.filter))&&(u=t.filter),a=t.arrayFormat in n?t.arrayFormat:"indices"in t?t.indices?"indices":"repeat":h.arrayFormat,"commaRoundTrip"in t&&"boolean"!=typeof t.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");var c=void 0===t.allowDots?!0===t.encodeDotInKeys||h.allowDots:!!t.allowDots;return{addQueryPrefix:"boolean"==typeof t.addQueryPrefix?t.addQueryPrefix:h.addQueryPrefix,allowDots:c,allowEmptyArrays:"boolean"==typeof t.allowEmptyArrays?!!t.allowEmptyArrays:h.allowEmptyArrays,arrayFormat:a,charset:e,charsetSentinel:"boolean"==typeof t.charsetSentinel?t.charsetSentinel:h.charsetSentinel,commaRoundTrip:t.commaRoundTrip,delimiter:void 0===t.delimiter?h.delimiter:t.delimiter,encode:"boolean"==typeof t.encode?t.encode:h.encode,encodeDotInKeys:"boolean"==typeof t.encodeDotInKeys?t.encodeDotInKeys:h.encodeDotInKeys,encoder:"function"==typeof t.encoder?t.encoder:h.encoder,encodeValuesOnly:"boolean"==typeof t.encodeValuesOnly?t.encodeValuesOnly:h.encodeValuesOnly,filter:u,format:s,formatter:l,serializeDate:"function"==typeof t.serializeDate?t.serializeDate:h.serializeDate,skipNulls:"boolean"==typeof t.skipNulls?t.skipNulls:h.skipNulls,sort:"function"==typeof t.sort?t.sort:null,strictNullHandling:"boolean"==typeof t.strictNullHandling?t.strictNullHandling:h.strictNullHandling}}(s);"function"==typeof c.filter?u=(0,c.filter)("",u):i(c.filter)&&(l=c.filter);var d=[];if("object"!=typeof u||null===u)return"";var f=n[c.arrayFormat],y="comma"===f&&c.commaRoundTrip;l||(l=Object.keys(u)),c.sort&&l.sort(c.sort);for(var m=t(),g=0;g<l.length;++g){var v=l[g];c.skipNulls&&null===u[v]||a(d,p(u[v],v,f,y,c.allowEmptyArrays,c.strictNullHandling,c.skipNulls,c.encodeDotInKeys,c.encode?c.encoder:null,c.filter,c.sort,c.allowDots,c.serializeDate,c.format,c.formatter,c.encodeValuesOnly,c.charset,m))}var b=d.join(c.delimiter),x=!0===c.addQueryPrefix?"?":"";return c.charsetSentinel&&("iso-8859-1"===c.charset?x+="utf8=%26%2310003%3B&":x+="utf8=%E2%9C%93&"),b.length>0?x+b:""}}function re(){if(zt)return Xt;zt=1;var t=te(),e=Object.prototype.hasOwnProperty,r=Array.isArray,o={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:t.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},n=function(t){return t.replace(/&#(\d+);/g,(function(t,e){return String.fromCharCode(parseInt(e,10))}))},i=function(t,e){return t&&"string"==typeof t&&e.comma&&t.indexOf(",")>-1?t.split(","):t},s=function(t,r,o,n){if(t){var s=o.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,a=/(\[[^[\]]*])/g,l=o.depth>0&&/(\[[^[\]]*])/.exec(s),u=l?s.slice(0,l.index):s,h=[];if(u){if(!o.plainObjects&&e.call(Object.prototype,u)&&!o.allowPrototypes)return;h.push(u)}for(var c=0;o.depth>0&&null!==(l=a.exec(s))&&c<o.depth;){if(c+=1,!o.plainObjects&&e.call(Object.prototype,l[1].slice(1,-1))&&!o.allowPrototypes)return;h.push(l[1])}return l&&h.push("["+s.slice(l.index)+"]"),function(t,e,r,o){for(var n=o?e:i(e,r),s=t.length-1;s>=0;--s){var a,l=t[s];if("[]"===l&&r.parseArrays)a=r.allowEmptyArrays&&""===n?[]:[].concat(n);else{a=r.plainObjects?Object.create(null):{};var u="["===l.charAt(0)&&"]"===l.charAt(l.length-1)?l.slice(1,-1):l,h=r.decodeDotInKeys?u.replace(/%2E/g,"."):u,c=parseInt(h,10);r.parseArrays||""!==h?!isNaN(c)&&l!==h&&String(c)===h&&c>=0&&r.parseArrays&&c<=r.arrayLimit?(a=[])[c]=n:"__proto__"!==h&&(a[h]=n):a={0:n}}n=a}return n}(h,r,o,n)}};return Xt=function(a,l){var u=function(e){if(!e)return o;if(void 0!==e.allowEmptyArrays&&"boolean"!=typeof e.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==e.decodeDotInKeys&&"boolean"!=typeof e.decodeDotInKeys)throw new TypeError("`decodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==e.decoder&&void 0!==e.decoder&&"function"!=typeof e.decoder)throw new TypeError("Decoder has to be a function.");if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var r=void 0===e.charset?o.charset:e.charset,n=void 0===e.duplicates?o.duplicates:e.duplicates;if("combine"!==n&&"first"!==n&&"last"!==n)throw new TypeError("The duplicates option must be either combine, first, or last");return{allowDots:void 0===e.allowDots?!0===e.decodeDotInKeys||o.allowDots:!!e.allowDots,allowEmptyArrays:"boolean"==typeof e.allowEmptyArrays?!!e.allowEmptyArrays:o.allowEmptyArrays,allowPrototypes:"boolean"==typeof e.allowPrototypes?e.allowPrototypes:o.allowPrototypes,allowSparse:"boolean"==typeof e.allowSparse?e.allowSparse:o.allowSparse,arrayLimit:"number"==typeof e.arrayLimit?e.arrayLimit:o.arrayLimit,charset:r,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:o.charsetSentinel,comma:"boolean"==typeof e.comma?e.comma:o.comma,decodeDotInKeys:"boolean"==typeof e.decodeDotInKeys?e.decodeDotInKeys:o.decodeDotInKeys,decoder:"function"==typeof e.decoder?e.decoder:o.decoder,delimiter:"string"==typeof e.delimiter||t.isRegExp(e.delimiter)?e.delimiter:o.delimiter,depth:"number"==typeof e.depth||!1===e.depth?+e.depth:o.depth,duplicates:n,ignoreQueryPrefix:!0===e.ignoreQueryPrefix,interpretNumericEntities:"boolean"==typeof e.interpretNumericEntities?e.interpretNumericEntities:o.interpretNumericEntities,parameterLimit:"number"==typeof e.parameterLimit?e.parameterLimit:o.parameterLimit,parseArrays:!1!==e.parseArrays,plainObjects:"boolean"==typeof e.plainObjects?e.plainObjects:o.plainObjects,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:o.strictNullHandling}}(l);if(""===a||null==a)return u.plainObjects?Object.create(null):{};for(var h="string"==typeof a?function(s,a){var l,u={__proto__:null},h=a.ignoreQueryPrefix?s.replace(/^\?/,""):s,c=a.parameterLimit===1/0?void 0:a.parameterLimit,p=h.split(a.delimiter,c),d=-1,f=a.charset;if(a.charsetSentinel)for(l=0;l<p.length;++l)0===p[l].indexOf("utf8=")&&("utf8=%E2%9C%93"===p[l]?f="utf-8":"utf8=%26%2310003%3B"===p[l]&&(f="iso-8859-1"),d=l,l=p.length);for(l=0;l<p.length;++l)if(l!==d){var y,m,g=p[l],v=g.indexOf("]="),b=-1===v?g.indexOf("="):v+1;-1===b?(y=a.decoder(g,o.decoder,f,"key"),m=a.strictNullHandling?null:""):(y=a.decoder(g.slice(0,b),o.decoder,f,"key"),m=t.maybeMap(i(g.slice(b+1),a),(function(t){return a.decoder(t,o.decoder,f,"value")}))),m&&a.interpretNumericEntities&&"iso-8859-1"===f&&(m=n(m)),g.indexOf("[]=")>-1&&(m=r(m)?[m]:m);var x=e.call(u,y);x&&"combine"===a.duplicates?u[y]=t.combine(u[y],m):x&&"last"!==a.duplicates||(u[y]=m)}return u}(a,u):a,c=u.plainObjects?Object.create(null):{},p=Object.keys(h),d=0;d<p.length;++d){var f=p[d],y=s(f,h[f],u,"string"==typeof a);c=t.merge(c,y,u)}return!0===u.allowSparse?c:t.compact(c)}}function oe(){if(Yt)return Vt;Yt=1;var t=ee(),e=re();return Vt={formats:Zt(),parse:e,stringify:t}}const ne=P(function(){if(Kt)return tt;Kt=1;var t,e,r=(A||(A=1,t=et,e=et.exports,function(r){var o=e&&!e.nodeType&&e,n=t&&!t.nodeType&&t,i="object"==typeof w&&w;i.global!==i&&i.window!==i&&i.self!==i||(r=i);var s,a,l=2147483647,u=36,h=1,c=26,p=38,d=700,f=72,y=128,m="-",g=/^xn--/,v=/[^\x20-\x7E]/,b=/[\x2E\u3002\uFF0E\uFF61]/g,x={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},M=u-h,P=Math.floor,E=String.fromCharCode;function A(t){throw new RangeError(x[t])}function O(t,e){for(var r=t.length,o=[];r--;)o[r]=e(t[r]);return o}function I(t,e){var r=t.split("@"),o="";return r.length>1&&(o=r[0]+"@",t=r[1]),o+O((t=t.replace(b,".")).split("."),e).join(".")}function S(t){for(var e,r,o=[],n=0,i=t.length;n<i;)(e=t.charCodeAt(n++))>=55296&&e<=56319&&n<i?56320==(64512&(r=t.charCodeAt(n++)))?o.push(((1023&e)<<10)+(1023&r)+65536):(o.push(e),n--):o.push(e);return o}function j(t){return O(t,(function(t){var e="";return t>65535&&(e+=E((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+E(t)})).join("")}function F(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function _(t,e,r){var o=0;for(t=r?P(t/d):t>>1,t+=P(t/e);t>M*c>>1;o+=u)t=P(t/M);return P(o+(M+1)*t/(t+p))}function T(t){var e,r,o,n,i,s,a,p,d,g,v,b=[],x=t.length,M=0,w=y,E=f;for((r=t.lastIndexOf(m))<0&&(r=0),o=0;o<r;++o)t.charCodeAt(o)>=128&&A("not-basic"),b.push(t.charCodeAt(o));for(n=r>0?r+1:0;n<x;){for(i=M,s=1,a=u;n>=x&&A("invalid-input"),((p=(v=t.charCodeAt(n++))-48<10?v-22:v-65<26?v-65:v-97<26?v-97:u)>=u||p>P((l-M)/s))&&A("overflow"),M+=p*s,!(p<(d=a<=E?h:a>=E+c?c:a-E));a+=u)s>P(l/(g=u-d))&&A("overflow"),s*=g;E=_(M-i,e=b.length+1,0==i),P(M/e)>l-w&&A("overflow"),w+=P(M/e),M%=e,b.splice(M++,0,w)}return j(b)}function L(t){var e,r,o,n,i,s,a,p,d,g,v,b,x,M,w,O=[];for(b=(t=S(t)).length,e=y,r=0,i=f,s=0;s<b;++s)(v=t[s])<128&&O.push(E(v));for(o=n=O.length,n&&O.push(m);o<b;){for(a=l,s=0;s<b;++s)(v=t[s])>=e&&v<a&&(a=v);for(a-e>P((l-r)/(x=o+1))&&A("overflow"),r+=(a-e)*x,e=a,s=0;s<b;++s)if((v=t[s])<e&&++r>l&&A("overflow"),v==e){for(p=r,d=u;!(p<(g=d<=i?h:d>=i+c?c:d-i));d+=u)w=p-g,M=u-g,O.push(E(F(g+w%M,0))),p=P(w/M);O.push(E(F(p,0))),i=_(r,x,o==n),r=0,++o}++r,++e}return O.join("")}if(s={version:"1.4.1",ucs2:{decode:S,encode:j},decode:T,encode:L,toASCII:function(t){return I(t,(function(t){return v.test(t)?"xn--"+L(t):t}))},toUnicode:function(t){return I(t,(function(t){return g.test(t)?T(t.slice(4).toLowerCase()):t}))}},o&&n)if(t.exports==o)n.exports=s;else for(a in s)s.hasOwnProperty(a)&&(o[a]=s[a]);else r.punycode=s}(rt)),et.exports);function o(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var n=/^([a-z0-9.+-]+:)/i,i=/:[0-9]*$/,s=/^(\/\/?(?!\/)[^?\s]*)(\?[^\s]*)?$/,a=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),l=["'"].concat(a),u=["%","/","?",";","#"].concat(l),h=["/","?","#"],c=/^[+a-z0-9A-Z_-]{0,63}$/,p=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,d={javascript:!0,"javascript:":!0},f={javascript:!0,"javascript:":!0},y={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},m=oe();function g(t,e,r){if(t&&"object"==typeof t&&t instanceof o)return t;var n=new o;return n.parse(t,e,r),n}return o.prototype.parse=function(t,e,o){if("string"!=typeof t)throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var i=t.indexOf("?"),a=-1!==i&&i<t.indexOf("#")?"?":"#",g=t.split(a);g[0]=g[0].replace(/\\/g,"/");var v=t=g.join(a);if(v=v.trim(),!o&&1===t.split("#").length){var b=s.exec(v);if(b)return this.path=v,this.href=v,this.pathname=b[1],b[2]?(this.search=b[2],this.query=e?m.parse(this.search.substr(1)):this.search.substr(1)):e&&(this.search="",this.query={}),this}var x=n.exec(v);if(x){var M=(x=x[0]).toLowerCase();this.protocol=M,v=v.substr(x.length)}if(o||x||v.match(/^\/\/[^@/]+@[^@/]+/)){var w="//"===v.substr(0,2);!w||x&&f[x]||(v=v.substr(2),this.slashes=!0)}if(!f[x]&&(w||x&&!y[x])){for(var P,E,A=-1,O=0;O<h.length;O++){-1!==(I=v.indexOf(h[O]))&&(-1===A||I<A)&&(A=I)}-1!==(E=-1===A?v.lastIndexOf("@"):v.lastIndexOf("@",A))&&(P=v.slice(0,E),v=v.slice(E+1),this.auth=decodeURIComponent(P)),A=-1;for(O=0;O<u.length;O++){var I;-1!==(I=v.indexOf(u[O]))&&(-1===A||I<A)&&(A=I)}-1===A&&(A=v.length),this.host=v.slice(0,A),v=v.slice(A),this.parseHost(),this.hostname=this.hostname||"";var S="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!S)for(var j=this.hostname.split(/\./),F=(O=0,j.length);O<F;O++){var _=j[O];if(_&&!_.match(c)){for(var T="",L=0,R=_.length;L<R;L++)_.charCodeAt(L)>127?T+="x":T+=_[L];if(!T.match(c)){var D=j.slice(0,O),k=j.slice(O+1),C=_.match(p);C&&(D.push(C[1]),k.unshift(C[2])),k.length&&(v="/"+k.join(".")+v),this.hostname=D.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),S||(this.hostname=r.toASCII(this.hostname));var N=this.port?":"+this.port:"",U=this.hostname||"";this.host=U+N,this.href+=this.host,S&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==v[0]&&(v="/"+v))}if(!d[M])for(O=0,F=l.length;O<F;O++){var G=l[O];if(-1!==v.indexOf(G)){var q=encodeURIComponent(G);q===G&&(q=escape(G)),v=v.split(G).join(q)}}var H=v.indexOf("#");-1!==H&&(this.hash=v.substr(H),v=v.slice(0,H));var W=v.indexOf("?");if(-1!==W?(this.search=v.substr(W),this.query=v.substr(W+1),e&&(this.query=m.parse(this.query)),v=v.slice(0,W)):e&&(this.search="",this.query={}),v&&(this.pathname=v),y[M]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){N=this.pathname||"";var B=this.search||"";this.path=N+B}return this.href=this.format(),this},o.prototype.format=function(){var t=this.auth||"";t&&(t=(t=encodeURIComponent(t)).replace(/%3A/i,":"),t+="@");var e=this.protocol||"",r=this.pathname||"",o=this.hash||"",n=!1,i="";this.host?n=t+this.host:this.hostname&&(n=t+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(n+=":"+this.port)),this.query&&"object"==typeof this.query&&Object.keys(this.query).length&&(i=m.stringify(this.query,{arrayFormat:"repeat",addQueryPrefix:!1}));var s=this.search||i&&"?"+i||"";return e&&":"!==e.substr(-1)&&(e+=":"),this.slashes||(!e||y[e])&&!1!==n?(n="//"+(n||""),r&&"/"!==r.charAt(0)&&(r="/"+r)):n||(n=""),o&&"#"!==o.charAt(0)&&(o="#"+o),s&&"?"!==s.charAt(0)&&(s="?"+s),e+n+(r=r.replace(/[?#]/g,(function(t){return encodeURIComponent(t)})))+(s=s.replace("#","%23"))+o},o.prototype.resolve=function(t){return this.resolveObject(g(t,!1,!0)).format()},o.prototype.resolveObject=function(t){if("string"==typeof t){var e=new o;e.parse(t,!1,!0),t=e}for(var r=new o,n=Object.keys(this),i=0;i<n.length;i++){var s=n[i];r[s]=this[s]}if(r.hash=t.hash,""===t.href)return r.href=r.format(),r;if(t.slashes&&!t.protocol){for(var a=Object.keys(t),l=0;l<a.length;l++){var u=a[l];"protocol"!==u&&(r[u]=t[u])}return y[r.protocol]&&r.hostname&&!r.pathname&&(r.pathname="/",r.path=r.pathname),r.href=r.format(),r}if(t.protocol&&t.protocol!==r.protocol){if(!y[t.protocol]){for(var h=Object.keys(t),c=0;c<h.length;c++){var p=h[c];r[p]=t[p]}return r.href=r.format(),r}if(r.protocol=t.protocol,t.host||f[t.protocol])r.pathname=t.pathname;else{for(var d=(t.pathname||"").split("/");d.length&&!(t.host=d.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==d[0]&&d.unshift(""),d.length<2&&d.unshift(""),r.pathname=d.join("/")}if(r.search=t.search,r.query=t.query,r.host=t.host||"",r.auth=t.auth,r.hostname=t.hostname||t.host,r.port=t.port,r.pathname||r.search){var m=r.pathname||"",g=r.search||"";r.path=m+g}return r.slashes=r.slashes||t.slashes,r.href=r.format(),r}var v=r.pathname&&"/"===r.pathname.charAt(0),b=t.host||t.pathname&&"/"===t.pathname.charAt(0),x=b||v||r.host&&t.pathname,M=x,w=r.pathname&&r.pathname.split("/")||[],P=(d=t.pathname&&t.pathname.split("/")||[],r.protocol&&!y[r.protocol]);if(P&&(r.hostname="",r.port=null,r.host&&(""===w[0]?w[0]=r.host:w.unshift(r.host)),r.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===d[0]?d[0]=t.host:d.unshift(t.host)),t.host=null),x=x&&(""===d[0]||""===w[0])),b)r.host=t.host||""===t.host?t.host:r.host,r.hostname=t.hostname||""===t.hostname?t.hostname:r.hostname,r.search=t.search,r.query=t.query,w=d;else if(d.length)w||(w=[]),w.pop(),w=w.concat(d),r.search=t.search,r.query=t.query;else if(null!=t.search){if(P)r.host=w.shift(),r.hostname=r.host,(S=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=S.shift(),r.hostname=S.shift(),r.host=r.hostname);return r.search=t.search,r.query=t.query,null===r.pathname&&null===r.search||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r}if(!w.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var E=w.slice(-1)[0],A=(r.host||t.host||w.length>1)&&("."===E||".."===E)||""===E,O=0,I=w.length;I>=0;I--)"."===(E=w[I])?w.splice(I,1):".."===E?(w.splice(I,1),O++):O&&(w.splice(I,1),O--);if(!x&&!M)for(;O--;O)w.unshift("..");!x||""===w[0]||w[0]&&"/"===w[0].charAt(0)||w.unshift(""),A&&"/"!==w.join("/").substr(-1)&&w.push("");var S,j=""===w[0]||w[0]&&"/"===w[0].charAt(0);P&&(r.hostname=j?"":w.length?w.shift():"",r.host=r.hostname,(S=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=S.shift(),r.hostname=S.shift(),r.host=r.hostname));return(x=x||r.host&&w.length)&&!j&&w.unshift(""),w.length>0?r.pathname=w.join("/"):(r.pathname=null,r.path=null),null===r.pathname&&null===r.search||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},o.prototype.parseHost=function(){var t=this.host,e=i.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)},tt.parse=g,tt.resolve=function(t,e){return g(t,!1,!0).resolve(e)},tt.resolveObject=function(t,e){return t?g(t,!1,!0).resolveObject(e):e},tt.format=function(t){return"string"==typeof t&&(t=g(t)),t instanceof o?t.format():o.prototype.format.call(t)},tt.Url=o,tt}());class ie{constructor(t){s(this,"json"),s(this,"name"),s(this,"url"),s(this,"pose"),s(this,"physics"),this.json=t;const e=t.url;if("string"!=typeof e)throw new TypeError("The `url` field in settings JSON must be defined as a string.");this.url=e,this.name=m(this.url)}resolveURL(t){return ne.resolve(this.url,t)}replaceFiles(t){this.moc=t(this.moc,"moc"),void 0!==this.pose&&(this.pose=t(this.pose,"pose")),void 0!==this.physics&&(this.physics=t(this.physics,"physics"));for(let e=0;e<this.textures.length;e++)this.textures[e]=t(this.textures[e],`textures[${e}]`)}getDefinedFiles(){const t=[];return this.replaceFiles((e=>(t.push(e),e))),t}validateFiles(t){const e=(e,r)=>{const o=this.resolveURL(e);if(!t.includes(o)){if(r)throw new Error(`File "${e}" is defined in settings, but doesn't exist in given files`);return!1}return!0};[this.moc,...this.textures].forEach((t=>e(t,!0)));return this.getDefinedFiles().filter((t=>e(t,!1)))}}var se=(t=>(t[t.NONE=0]="NONE",t[t.IDLE=1]="IDLE",t[t.NORMAL=2]="NORMAL",t[t.FORCE=3]="FORCE",t))(se||{});class ae{constructor(){s(this,"tag"),s(this,"debug",!1),s(this,"currentPriority",0),s(this,"reservePriority",0),s(this,"currentGroup"),s(this,"currentIndex"),s(this,"reservedGroup"),s(this,"reservedIndex"),s(this,"reservedIdleGroup"),s(this,"reservedIdleIndex")}reserve(t,e,r){if(r<=0)return c.log(this.tag,"Cannot start a motion with MotionPriority.NONE."),!1;if(t===this.currentGroup&&e===this.currentIndex)return c.log(this.tag,"Motion is already playing.",this.dump(t,e)),!1;if(t===this.reservedGroup&&e===this.reservedIndex||t===this.reservedIdleGroup&&e===this.reservedIdleIndex)return c.log(this.tag,"Motion is already reserved.",this.dump(t,e)),!1;if(1===r){if(0!==this.currentPriority)return c.log(this.tag,"Cannot start idle motion because another motion is playing.",this.dump(t,e)),!1;if(void 0!==this.reservedIdleGroup)return c.log(this.tag,"Cannot start idle motion because another idle motion has reserved.",this.dump(t,e)),!1;this.setReservedIdle(t,e)}else{if(r<3){if(r<=this.currentPriority)return c.log(this.tag,"Cannot start motion because another motion is playing as an equivalent or higher priority.",this.dump(t,e)),!1;if(r<=this.reservePriority)return c.log(this.tag,"Cannot start motion because another motion has reserved as an equivalent or higher priority.",this.dump(t,e)),!1}this.setReserved(t,e,r)}return!0}start(t,e,r,o){if(1===o){if(this.setReservedIdle(void 0,void 0),0!==this.currentPriority)return c.log(this.tag,"Cannot start idle motion because another motion is playing.",this.dump(e,r)),!1}else{if(e!==this.reservedGroup||r!==this.reservedIndex)return c.log(this.tag,"Cannot start motion because another motion has taken the place.",this.dump(e,r)),!1;this.setReserved(void 0,void 0,0)}return!!t&&(this.setCurrent(e,r,o),!0)}complete(){this.setCurrent(void 0,void 0,0)}setCurrent(t,e,r){this.currentPriority=r,this.currentGroup=t,this.currentIndex=e}setReserved(t,e,r){this.reservePriority=r,this.reservedGroup=t,this.reservedIndex=e}setReservedIdle(t,e){this.reservedIdleGroup=t,this.reservedIdleIndex=e}isActive(t,e){return t===this.currentGroup&&e===this.currentIndex||t===this.reservedGroup&&e===this.reservedIndex||t===this.reservedIdleGroup&&e===this.reservedIdleIndex}reset(){this.setCurrent(void 0,void 0,0),this.setReserved(void 0,void 0,0),this.setReservedIdle(void 0,void 0)}shouldRequestIdleMotion(){return void 0===this.currentGroup&&void 0===this.reservedIdleGroup}shouldOverrideExpression(){return!h.preserveExpressionOnMotion&&this.currentPriority>1}dump(t,e){if(this.debug){return`\n<Requested> group = "${t}", index = ${e}\n`+["currentPriority","reservePriority","currentGroup","currentIndex","reservedGroup","reservedIndex","reservedIdleGroup","reservedIdleIndex"].map((t=>"["+t+"] "+this[t])).join("\n")}return""}}const le=.5;class ue{static get volume(){return this._volume}static set volume(t){this._volume=(t>1?1:t<0?0:t)||0,this.audios.forEach((t=>t.volume=this._volume))}static add(t,e,o){return a(this,null,(function*(){try{const o=new Promise(((o,n)=>{const i=r.Sound.from({url:t,volume:this._volume,preload:!0,complete:()=>{this.dispose(i),null==e||e()},loaded:()=>{i.media instanceof r.webaudio.WebAudioMedia||n(new Error(`Error: ${t} is not WebAudioMedia`)),o(i)}})}));return yield o}catch(n){return c.warn("SoundManager",`Error occurred on "${t}"`,n),null==o||o(n),null}}))}static play(t){t.play()}static addAnalyzer(t,e){const r=t.media,o=e.createBufferSource();o.buffer=r.buffer;const n=e.createAnalyser();return n.fftSize=h.fftSize,n.minDecibels=-90,n.maxDecibels=-10,n.smoothingTimeConstant=.85,o.connect(n),o.start(0),n.connect(e.destination),this.analysers.push(n),n}static analyze(t){if(!t)return parseFloat(Math.random().toFixed(1));const e=new Float32Array(t.fftSize);t.getFloatTimeDomainData(e);let r=0;for(let a=0;a<e.length;a++)r+=i(e[a],2);const o=Math.sqrt(r/e.length),n=20*Math.log10(o||i(10,-5)),s=Math.min(Math.max((n-t.minDecibels)/(t.maxDecibels-t.minDecibels),0),1);return parseFloat(s.toFixed(1))}static dispose(t){t.pause(),g(this.audios,t)}static destroy(){for(let t=this.contexts.length-1;t>=0;t--)setTimeout((()=>this.contexts[t].close()));for(let t=this.audios.length-1;t>=0;t--)this.dispose(this.audios[t])}}s(ue,"audios",[]),s(ue,"analysers",[]),s(ue,"contexts",[]),s(ue,"_volume",le);var he=(t=>(t.ALL="ALL",t.IDLE="IDLE",t.NONE="NONE",t))(he||{});class ce extends e.utils.EventEmitter{constructor(t){super(),s(this,"tag"),s(this,"settings"),s(this,"motionGroups",{}),s(this,"state",new ae),s(this,"currentAudio"),s(this,"currentAnalyzer"),s(this,"currentContext"),s(this,"playing",!1),s(this,"destroyed",!1),s(this,"parent"),this.settings=t.settings,this.tag=`MotionManager(${this.settings.name})`,this.state.tag=this.tag,this.parent=t}init(t){(null==t?void 0:t.idleMotionGroup)&&(this.groups.idle=t.idleMotionGroup),this.setupMotions(t),this.stopAllMotions()}setupMotions(t){for(const r of Object.keys(this.definitions))this.motionGroups[r]=[];let e;switch(null==t?void 0:t.motionPreload){case"NONE":return;case"ALL":e=Object.keys(this.definitions);break;default:e=[this.groups.idle]}for(const r of e)if(this.definitions[r])for(let t=0;t<this.definitions[r].length;t++)this.loadMotion(r,t).then()}loadMotion(t,e){return a(this,null,(function*(){var r;if(!(null==(r=this.definitions[t])?void 0:r[e]))return void c.warn(this.tag,`Undefined motion at "${t}"[${e}]`);if(null===this.motionGroups[t][e])return void c.warn(this.tag,`Cannot start motion at "${t}"[${e}] because it's already failed in loading.`);if(this.motionGroups[t][e])return this.motionGroups[t][e];const o=yield this._loadMotion(t,e);return this.destroyed?void 0:(this.motionGroups[t][e]=null!=o?o:null,o)}))}_loadMotion(t,e){throw new Error("Not implemented.")}initializeAudio(t,e){this.currentAudio=t,ue.volume=e,this.currentContext=t.context.audioContext,this.currentAnalyzer=ue.addAnalyzer(this.currentAudio,this.currentContext)}speak(t){return a(this,arguments,(function*(t,{volume:e=.5,expression:r,resetExpression:o=!0,onFinish:n,onError:i}={}){if(!h.sound)return!1;let s,a;if(this.currentAudio&&this.currentAudio.isPlaying)return!1;const l=t&&t.startsWith("data:");if(t&&!l){const e=document.createElement("a");e.href=t,a=t=e.href}else a="data:audio/";const u=t;if(u)try{s=yield ue.add(u,((t=this)=>{c.warn(this.tag,"Audio finished playing"),null==n||n(),o&&r&&t.expressionManager&&t.expressionManager.resetExpression(),t.currentAudio=void 0}),((t,e=this)=>{c.error(this.tag,"Error during audio playback:",t),null==i||i(t),o&&r&&e.expressionManager&&e.expressionManager.resetExpression(),e.currentAudio=void 0})),this.initializeAudio(s,e)}catch(p){return c.warn(this.tag,"Failed to create audio",a,p),!1}if(s){let t=!0;try{h.motionSync&&ue.play(s)}catch(p){c.warn(this.tag,"Failed to play audio",s.url,p),t=!1}if(!t)return!1}return this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),r&&this.expressionManager&&(yield this.expressionManager.setExpression(r)),this.playing=!0,!0}))}startMotion(t,e){return a(this,arguments,(function*(t,e,r=se.NORMAL,{sound:o,volume:n=.5,expression:i,resetExpression:s=!0,onFinish:a,onError:l,ignoreParamIds:u=[]}={}){var p;if(!this.state.reserve(t,e,r))return!1;if(this.currentAudio&&this.currentAudio.isPlaying&&r!=se.FORCE)return!1;const d=null==(p=this.definitions[t])?void 0:p[e];if(!d)return!1;let f,y;this.currentAudio&&ue.dispose(this.currentAudio);const m=o&&o.startsWith("data:");if(o&&!m){const t=document.createElement("a");t.href=o,y=o=t.href}else y=this.getSoundFile(d),y&&(y=this.settings.resolveURL(y));const g=y;if(g)try{f=yield ue.add(g,((t=this)=>{null==a||a(),s&&i&&t.expressionManager&&t.expressionManager.resetExpression(),t.currentAudio=void 0}),((t,e=this)=>{c.error(this.tag,"Error during audio playback:",t),null==l||l(t),s&&i&&e.expressionManager&&e.expressionManager.resetExpression(),e.currentAudio=void 0})),this.initializeAudio(f,n)}catch(b){c.warn(this.tag,"Failed to create audio",y,b)}const v=yield this.loadMotion(t,e);if(f&&h.motionSync)try{ue.play(f)}catch(b){c.warn(this.tag,"Failed to play audio",f.url,b)}return this.state.start(v,t,e,r)?(this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),c.log(this.tag,"Start motion:",this.getMotionName(d)),this.emit("motionStart",t,e,f),i&&this.expressionManager&&this.state.shouldOverrideExpression()&&(yield this.expressionManager.setExpression(i)),this.playing=!0,this._startMotion(v,void 0,u),!0):(f&&(ue.dispose(f),this.currentAudio=void 0),!1)}))}startRandomMotion(t,e){return a(this,arguments,(function*(t,e,{sound:r,volume:o=.5,expression:n,resetExpression:i=!0,onFinish:s,onError:a}={}){const l=this.definitions[t];if(null==l?void 0:l.length){const u=[];for(let e=0;e<l.length;e++)null===this.motionGroups[t][e]||this.state.isActive(t,e)||u.push(e);if(u.length){const l=u[Math.floor(Math.random()*u.length)];return this.startMotion(t,l,e,{sound:r,volume:o,expression:n,resetExpression:i,onFinish:s,onError:a})}}return!1}))}stopSpeaking(){this.currentAudio&&(ue.dispose(this.currentAudio),this.currentAudio=void 0)}stopAllMotions(){this._stopAllMotions(),this.state.reset(),this.stopSpeaking()}update(t,e){var r;return this.isFinished()&&(this.playing&&(this.playing=!1,this.emit("motionFinish")),this.state.shouldOverrideExpression()&&(null==(r=this.expressionManager)||r.restoreExpression()),this.state.complete(),this.state.shouldRequestIdleMotion()&&this.startRandomMotion(this.groups.idle,se.IDLE)),this.updateParameters(t,e)}mouthSync(){return this.currentAnalyzer?ue.analyze(this.currentAnalyzer):0}destroy(){var t;this.destroyed=!0,this.emit("destroy"),this.stopAllMotions(),null==(t=this.expressionManager)||t.destroy();this.definitions=void 0,this.motionGroups=void 0}getMotionAndApplyExpression(t,e,r){return a(this,null,(function*(){var o;if(!this.state.reserve(t,e,se.FORCE))return null;const n=null==(o=this.definitions[t])?void 0:o[e];if(!n)return null;this.currentAudio&&ue.dispose(this.currentAudio);const i=yield this.loadMotion(t,e);return this.state.start(i,t,e,se.FORCE)?(this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),c.log(this.tag,"Start motion:",this.getMotionName(n)),this.emit("motionStart",t,e,void 0),r&&this.expressionManager&&this.state.shouldOverrideExpression()&&(yield this.expressionManager.setExpression(r)),i):null}))}}const pe={x:0,y:0,width:0,height:0};class de extends e.utils.EventEmitter{constructor(){super(...arguments),s(this,"focusController",new M),s(this,"pose"),s(this,"physics"),s(this,"originalWidth",0),s(this,"originalHeight",0),s(this,"width",0),s(this,"height",0),s(this,"localTransform",new e.Matrix),s(this,"drawingMatrix",new e.Matrix),s(this,"hitAreas",{}),s(this,"textureFlipY",!1),s(this,"viewport",[0,0,0,0]),s(this,"destroyed",!1)}init(){this.setupLayout(),this.setupHitAreas()}setupLayout(){const t=this,e=this.getSize();t.originalWidth=e[0],t.originalHeight=e[1];const r=Object.assign({width:2,height:2},this.getLayout());this.localTransform.scale(r.width/2,r.height/2),t.width=this.originalWidth*this.localTransform.a,t.height=this.originalHeight*this.localTransform.d;const o=void 0!==r.x&&r.x-r.width/2||void 0!==r.centerX&&r.centerX||void 0!==r.left&&r.left-r.width/2||void 0!==r.right&&r.right+r.width/2||0,n=void 0!==r.y&&r.y-r.height/2||void 0!==r.centerY&&r.centerY||void 0!==r.top&&r.top-r.height/2||void 0!==r.bottom&&r.bottom+r.height/2||0;this.localTransform.translate(this.width*o,-this.height*n)}setupHitAreas(){const t=this.getHitAreaDefs().filter((t=>t.index>=0));for(const e of t)this.hitAreas[e.name]=e}hitTest(t,e){return Object.keys(this.hitAreas).filter((r=>this.isHit(r,t,e)))}isHit(t,e,r){if(!this.hitAreas[t])return!1;const o=this.hitAreas[t].index,n=this.getDrawableBounds(o,pe);return n.x<=e&&e<=n.x+n.width&&n.y<=r&&r<=n.y+n.height}getDrawableBounds(t,e){const r=this.getDrawableVertices(t);let o=r[0],n=r[0],i=r[1],s=r[1];for(let a=0;a<r.length;a+=2){const t=r[a],e=r[a+1];o=Math.min(t,o),n=Math.max(t,n),i=Math.min(e,i),s=Math.max(e,s)}return null!=e||(e={}),e.x=o,e.y=i,e.width=n-o,e.height=s-i,e}updateTransform(t){this.drawingMatrix.copyFrom(t).append(this.localTransform)}update(t,e){this.focusController.update(t)}destroy(){this.destroyed=!0,this.emit("destroy"),this.motionManager.destroy(),this.motionManager=void 0,this.parallelMotionManager.forEach((t=>t.destroy())),this.parallelMotionManager=[]}updateMotions(t,e){this.emit("beforeMotionUpdate");const r=this.motionManager.update(t,e),o=this.parallelMotionManager.map((r=>r.update(t,e))),n=r||o.reduce(((t,e)=>t||e),!1);return this.emit("afterMotionUpdate"),n}}class fe extends Error{constructor(t,e,r,o=!1){super(t),this.url=e,this.status=r,this.aborted=o}}const ye=class t{static createXHR(e,r,o,n,i){const s=new XMLHttpRequest;if(t.allXhrSet.add(s),e){let r=t.xhrMap.get(e);r?r.add(s):(r=new Set([s]),t.xhrMap.set(e,r)),e.listeners("destroy").includes(t.cancelXHRs)||e.once("destroy",t.cancelXHRs)}return s.open("GET",r),s.responseType=o,s.onload=()=>{200!==s.status&&0!==s.status||!s.response?s.onerror():n(s.response)},s.onerror=()=>{c.warn("XHRLoader",`Failed to load resource as ${s.responseType} (Status ${s.status}): ${r}`),i(new fe("Network error.",r,s.status))},s.onabort=()=>i(new fe("Aborted.",r,s.status,!0)),s.onloadend=()=>{var r;t.allXhrSet.delete(s),e&&(null==(r=t.xhrMap.get(e))||r.delete(s))},s}static cancelXHRs(){var e;null==(e=t.xhrMap.get(this))||e.forEach((e=>{e.abort(),t.allXhrSet.delete(e)})),t.xhrMap.delete(this)}static release(){t.allXhrSet.forEach((t=>t.abort())),t.allXhrSet.clear(),t.xhrMap=new WeakMap}};s(ye,"xhrMap",new WeakMap),s(ye,"allXhrSet",new Set),s(ye,"loader",((t,e)=>new Promise(((e,r)=>{ye.createXHR(t.target,t.settings?t.settings.resolveURL(t.url):t.url,t.type,(r=>{t.result=r,e()}),r).send()}))));let me=ye;function ge(t,e){let r=-1;return function o(n,i){if(i)return Promise.reject(i);if(n<=r)return Promise.reject(new Error("next() called multiple times"));r=n;const s=t[n];if(!s)return Promise.resolve();try{return Promise.resolve(s(e,o.bind(null,n+1)))}catch(a){return Promise.reject(a)}}(0)}class ve{static load(t){return ge(this.middlewares,t).then((()=>t.result))}}function be(){}s(ve,"middlewares",[me.loader]);const xe="Live2DFactory",Me=(t,e)=>a(null,null,(function*(){if("string"==typeof t.source){const e=yield ve.load({url:t.source,type:"json",target:t.live2dModel});e.url=t.source,t.source=e,t.live2dModel.emit("settingsJSONLoaded",e)}return e()})),we=(t,e)=>a(null,null,(function*(){if(t.source instanceof ie)return t.settings=t.source,e();if("object"==typeof t.source){const r=Te.findRuntime(t.source);if(r){const o=r.createModelSettings(t.source);return t.settings=o,t.live2dModel.emit("settingsLoaded",o),e()}}throw new TypeError("Unknown settings format.")})),Pe=(t,e)=>{if(t.settings){const r=Te.findRuntime(t.settings);if(r)return r.ready().then(e)}return e()},Ee=(t,e)=>a(null,null,(function*(){yield e();const r=t.internalModel;if(r){const e=t.settings,o=Te.findRuntime(e);if(o){const n=[];e.pose&&n.push(ve.load({settings:e,url:e.pose,type:"json",target:r}).then((e=>{r.pose=o.createPose(r.coreModel,e),t.live2dModel.emit("poseLoaded",r.pose)})).catch((e=>{t.live2dModel.emit("poseLoadError",e),c.warn(xe,"Failed to load pose.",e)}))),e.physics&&n.push(ve.load({settings:e,url:e.physics,type:"json",target:r}).then((e=>{r.physics=o.createPhysics(r.coreModel,e),t.live2dModel.emit("physicsLoaded",r.physics)})).catch((e=>{t.live2dModel.emit("physicsLoadError",e),c.warn(xe,"Failed to load physics.",e)}))),n.length&&(yield Promise.all(n))}}})),Ae=(t,r)=>a(null,null,(function*(){if(!t.settings)throw new TypeError("Missing settings.");{const o=t.live2dModel,n=Promise.all(t.settings.textures.map((r=>function(t,r={}){const o={resourceOptions:{crossorigin:r.crossOrigin}};if(e.Texture.fromURL)return e.Texture.fromURL(t,o).catch((t=>{if(t instanceof Error)throw t;const e=new Error("Texture loading error");throw e.event=t,e}));o.resourceOptions.autoLoad=!1;const n=e.Texture.from(t,o);if(n.baseTexture.valid)return Promise.resolve(n);const i=n.baseTexture.resource;return null!=i._live2d_load||(i._live2d_load=new Promise(((t,e)=>{const r=t=>{i.source.removeEventListener("error",r);const o=new Error("Texture loading error");o.event=t,e(o)};i.source.addEventListener("error",r),i.load().then((()=>t(n))).catch(r)}))),i._live2d_load}(t.settings.resolveURL(r),{crossOrigin:t.options.crossOrigin}))));if(n.catch(be),yield r(),!t.internalModel)throw new TypeError("Missing internal model.");o.internalModel=t.internalModel,o.emit("modelLoaded",t.internalModel),o.textures=yield n,o.emit("textureLoaded",o.textures)}})),Oe=(t,e)=>a(null,null,(function*(){const r=t.settings;if(r instanceof ie){const o=Te.findRuntime(r);if(!o)throw new TypeError("Unknown model settings.");const n=yield ve.load({settings:r,url:r.moc,type:"arraybuffer",target:t.live2dModel});if(!o.isValidMoc(n))throw new Error("Invalid moc data");const i=o.createCoreModel(n);return t.internalModel=o.createInternalModel(i,r,t.options),e()}throw new TypeError("Missing settings.")})),Ie=class t{static unzip(e,r){return a(this,null,(function*(){const o=yield t.getFilePaths(e),n=[];for(const t of r.getDefinedFiles()){const e=decodeURI(ne.resolve(r.url,t));o.includes(e)&&n.push(e)}const i=yield t.getFiles(e,n);for(let t=0;t<i.length;t++){const e=n[t],r=i[t];Object.defineProperty(r,"webkitRelativePath",{value:e})}return i}))}static createSettings(e){return a(this,null,(function*(){const r=(yield t.getFilePaths(e)).find((t=>t.endsWith("model.json")||t.endsWith("model3.json")));if(!r)throw new Error("Settings file not found");const o=yield t.readText(e,r);if(!o)throw new Error("Empty settings file: "+r);const n=JSON.parse(o);n.url=r;const i=t.live2dFactory.findRuntime(n);if(!i)throw new Error("Unknown settings JSON");return i.createModelSettings(n)}))}static zipReader(t,e){return a(this,null,(function*(){throw new Error("Not implemented")}))}static getFilePaths(t){return a(this,null,(function*(){throw new Error("Not implemented")}))}static getFiles(t,e){return a(this,null,(function*(){throw new Error("Not implemented")}))}static readText(t,e){return a(this,null,(function*(){throw new Error("Not implemented")}))}static releaseReader(t){}};s(Ie,"live2dFactory"),s(Ie,"ZIP_PROTOCOL","zip://"),s(Ie,"uid",0),s(Ie,"factory",((t,e)=>a(null,null,(function*(){const r=t.source;let o,n,i;if("string"==typeof r&&(r.endsWith(".zip")||r.startsWith(Ie.ZIP_PROTOCOL))?(o=r.startsWith(Ie.ZIP_PROTOCOL)?r.slice(Ie.ZIP_PROTOCOL.length):r,n=yield ve.load({url:o,type:"blob",target:t.live2dModel})):Array.isArray(r)&&1===r.length&&r[0]instanceof File&&r[0].name.endsWith(".zip")&&(n=r[0],o=URL.createObjectURL(n),i=r.settings),n){if(!n.size)throw new Error("Empty zip file");const e=yield Ie.zipReader(n,o);i||(i=yield Ie.createSettings(e)),i._objectURL=Ie.ZIP_PROTOCOL+Ie.uid+"/"+i.url;const r=yield Ie.unzip(e,i);r.settings=i,t.source=r,o.startsWith("blob:")&&t.live2dModel.once("modelLoaded",(t=>{t.once("destroy",(function(){URL.revokeObjectURL(o)}))})),Ie.releaseReader(e)}return e()}))));let Se=Ie;const je=class t{static resolveURL(e,r){var o;const n=null==(o=t.filesMap[e])?void 0:o[r];if(void 0===n)throw new Error("Cannot find this file from uploaded files: "+r);return n}static upload(e,r){return a(this,null,(function*(){const o={};for(const t of r.getDefinedFiles()){const n=decodeURI(ne.resolve(r.url,t)),i=e.find((t=>t.webkitRelativePath===n));i&&(o[t]=URL.createObjectURL(i))}t.filesMap[r._objectURL]=o}))}static createSettings(e){return a(this,null,(function*(){const r=e.find((t=>t.name.endsWith("model.json")||t.name.endsWith("model3.json")));if(!r)throw new TypeError("Settings file not found");const o=yield t.readText(r),n=JSON.parse(o);n.url=r.webkitRelativePath;const i=Te.findRuntime(n);if(!i)throw new Error("Unknown settings JSON");const s=i.createModelSettings(n);return s._objectURL=URL.createObjectURL(r),s}))}static readText(t){return a(this,null,(function*(){return new Promise(((e,r)=>{const o=new FileReader;o.onload=()=>e(o.result),o.onerror=r,o.readAsText(t,"utf8")}))}))}};s(je,"live2dFactory"),s(je,"filesMap",{}),s(je,"factory",((t,e)=>a(null,null,(function*(){if(Array.isArray(t.source)&&t.source[0]instanceof File){const e=t.source;let r=e.settings;if(r){if(!r._objectURL)throw new Error('"_objectURL" must be specified in ModelSettings')}else r=yield je.createSettings(e);r.validateFiles(e.map((t=>encodeURI(t.webkitRelativePath)))),yield je.upload(e,r),r.resolveURL=function(t){return je.resolveURL(this._objectURL,t)},t.source=r,t.live2dModel.once("modelLoaded",(t=>{t.once("destroy",(function(){const t=this.settings._objectURL;if(URL.revokeObjectURL(t),je.filesMap[t])for(const e of Object.values(je.filesMap[t]))URL.revokeObjectURL(e);delete je.filesMap[t]}))}))}return e()}))));let Fe=je;const _e=class t{static registerRuntime(e){t.runtimes.push(e),t.runtimes.sort(((t,e)=>e.version-t.version))}static findRuntime(e){for(const r of t.runtimes)if(r.test(e))return r}static setupLive2DModel(e,r,o){return a(this,null,(function*(){const n=new Promise((t=>e.once("textureLoaded",t))),i=new Promise((t=>e.once("modelLoaded",t))),s=Promise.all([n,i]).then((()=>e.emit("ready")));yield ge(t.live2DModelMiddlewares,{live2dModel:e,source:r,options:o||{}}),yield s,e.emit("load")}))}static loadMotion(e,r,o){var n;const i=t=>e.emit("motionLoadError",r,o,t);try{const s=null==(n=e.definitions[r])?void 0:n[o];if(!s)return Promise.resolve(void 0);e.listeners("destroy").includes(t.releaseTasks)||e.once("destroy",t.releaseTasks);let a=t.motionTasksMap.get(e);a||(a={},t.motionTasksMap.set(e,a));let l=a[r];l||(l=[],a[r]=l);const u=e.getMotionFile(s);return null!=l[o]||(l[o]=ve.load({url:u,settings:e.settings,type:e.motionDataType,target:e}).then((n=>{var i;const a=null==(i=t.motionTasksMap.get(e))?void 0:i[r];a&&delete a[o];const l=e.createMotion(n,r,s);return e.emit("motionLoaded",r,o,l),l})).catch((t=>{c.warn(e.tag,`Failed to load motion: ${u}\n`,t),i(t)}))),l[o]}catch(s){c.warn(e.tag,`Failed to load motion at "${r}"[${o}]\n`,s),i(s)}return Promise.resolve(void 0)}static loadExpression(e,r){const o=t=>e.emit("expressionLoadError",r,t);try{const n=e.definitions[r];if(!n)return Promise.resolve(void 0);e.listeners("destroy").includes(t.releaseTasks)||e.once("destroy",t.releaseTasks);let i=t.expressionTasksMap.get(e);i||(i=[],t.expressionTasksMap.set(e,i));const s=e.getExpressionFile(n);return null!=i[r]||(i[r]=ve.load({url:s,settings:e.settings,type:"json",target:e}).then((o=>{const i=t.expressionTasksMap.get(e);i&&delete i[r];const s=e.createExpression(o,n);return e.emit("expressionLoaded",r,s),s})).catch((t=>{c.warn(e.tag,`Failed to load expression: ${s}\n`,t),o(t)}))),i[r]}catch(n){c.warn(e.tag,`Failed to load expression at [${r}]\n`,n),o(n)}return Promise.resolve(void 0)}static releaseTasks(){this instanceof ce?t.motionTasksMap.delete(this):t.expressionTasksMap.delete(this)}};s(_e,"runtimes",[]),s(_e,"urlToJSON",Me),s(_e,"jsonToSettings",we),s(_e,"waitUntilReady",Pe),s(_e,"setupOptionals",Ee),s(_e,"setupEssentials",Ae),s(_e,"createInternalModel",Oe),s(_e,"live2DModelMiddlewares",[Se.factory,Fe.factory,Me,we,Pe,Ee,Ae,Oe]),s(_e,"motionTasksMap",new WeakMap),s(_e,"expressionTasksMap",new WeakMap);let Te=_e;ce.prototype._loadMotion=function(t,e){return Te.loadMotion(this,t,e)},v.prototype._loadExpression=function(t){return Te.loadExpression(this,t)},Fe.live2dFactory=Te,Se.live2dFactory=Te;const Le=class t{constructor(e,{autoUpdate:r=!0,autoHitTest:o=!0,autoFocus:n=!0,autoInteract:i,ticker:a}={}){s(this,"model"),s(this,"destroyed",!1),s(this,"_ticker"),s(this,"_autoUpdate",!1),s(this,"_autoHitTest",!1),s(this,"_autoFocus",!1),a||(t.defaultTicker?a=t.defaultTicker:"undefined"!=typeof PIXI&&(a=PIXI.Ticker.shared)),void 0!==i&&(o=i,n=i,c.warn(e.tag,"options.autoInteract is deprecated since v0.5.0, use autoHitTest and autoFocus instead.")),this.model=e,this.ticker=a,this.autoUpdate=r,this.autoHitTest=o,this.autoFocus=n,(o||n)&&(this.model.eventMode="static")}get ticker(){return this._ticker}set ticker(t){var e;this._ticker&&this._ticker.remove(De,this),this._ticker=t,this._autoUpdate&&(null==(e=this._ticker)||e.add(De,this))}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){var e;this.destroyed||(t?this._ticker?(this._ticker.add(De,this),this._autoUpdate=!0):c.warn(this.model.tag,"No Ticker to be used for automatic updates. Either set option.ticker when creating Live2DModel, or expose PIXI to global scope (window.PIXI = PIXI)."):(null==(e=this._ticker)||e.remove(De,this),this._autoUpdate=!1))}get autoHitTest(){return this._autoHitTest}set autoHitTest(t){t!==this.autoHitTest&&(t?this.model.on("pointertap",ke,this):this.model.off("pointertap",ke,this),this._autoHitTest=t)}get autoFocus(){return this._autoFocus}set autoFocus(t){t!==this.autoFocus&&(t?this.model.on("globalpointermove",Ce,this):this.model.off("globalpointermove",Ce,this),this._autoFocus=t)}get autoInteract(){return this._autoHitTest&&this._autoFocus}set autoInteract(t){this.autoHitTest=t,this.autoFocus=t}onTickerUpdate(){const t=this.ticker.deltaMS;this.model.update(t)}onTap(t){this.model.tap(t.global.x,t.global.y)}onPointerMove(t){this.model.focus(t.global.x,t.global.y)}destroy(){this.autoFocus=!1,this.autoHitTest=!1,this.autoUpdate=!1,this.ticker=void 0,this.destroyed=!0}};s(Le,"defaultTicker");let Re=Le;function De(){this.onTickerUpdate()}function ke(t){this.onTap(t)}function Ce(t){this.onPointerMove(t)}class Ne extends e.Transform{}const Ue=new e.Point,Ge=new e.Matrix;class qe extends o.Container{constructor(t){super(),s(this,"tag","Live2DModel(uninitialized)"),s(this,"internalModel"),s(this,"textures",[]),s(this,"transform",new Ne),s(this,"anchor",new e.ObservablePoint(this.onAnchorChange,this,0,0)),s(this,"glContextID",-1),s(this,"elapsedTime",0),s(this,"deltaTime",0),s(this,"automator"),this.automator=new Re(this,t),this.once("modelLoaded",(()=>this.initializeOnModelLoad(t)))}static from(t,e){return a(this,null,(function*(){const r=new this(e);return yield Te.setupLive2DModel(r,t,e),r}))}static fromSync(t,e){const r=new this(e);return Te.setupLive2DModel(r,t,e).then(null==e?void 0:e.onLoad).catch(null==e?void 0:e.onError),r}static registerTicker(t){Re.defaultTicker=t.shared}initializeOnModelLoad(t){this.tag=`Live2DModel(${this.internalModel.settings.name})`}onAnchorChange(){this.pivot.set(this.anchor.x*this.internalModel.width,this.anchor.y*this.internalModel.height)}motion(t,e,r){return a(this,arguments,(function*(t,e,r,{sound:o,volume:n=.5,expression:i,resetExpression:s=!0,onFinish:a,onError:l}={}){return void 0===e?this.internalModel.motionManager.startRandomMotion(t,r,{sound:o,volume:n,expression:i,resetExpression:s,onFinish:a,onError:l}):this.internalModel.motionManager.startMotion(t,e,r,{sound:o,volume:n,expression:i,resetExpression:s,onFinish:a,onError:l})}))}motionLastFrame(t,e){return a(this,arguments,(function*(t,e,{expression:r}={}){return this.internalModel.motionManager.motionLastFrame(t,e,{expression:r})}))}parallelMotion(t){return a(this,null,(function*(){this.internalModel.extendParallelMotionManager(t.length);const e=t.map(((t,e)=>this.internalModel.parallelMotionManager[e].startMotion(t.group,t.index,t.priority))),r=[];for(const t of e)r.push(yield t);return r}))}parallelLastFrame(t){return a(this,null,(function*(){this.internalModel.extendParallelMotionManager(t.length);const e=t.map(((t,e)=>this.internalModel.parallelMotionManager[e].playMotionLastFrame(t.group,t.index))),r=[];for(const t of e)r.push(yield t);return r}))}stopMotions(){return this.internalModel.motionManager.stopAllMotions()}speak(t,{volume:e=.5,expression:r,resetExpression:o=!0,onFinish:n,onError:i}={}){return this.internalModel.motionManager.speak(t,{volume:e,expression:r,resetExpression:o,onFinish:n,onError:i})}stopSpeaking(){return this.internalModel.motionManager.stopSpeaking()}expression(t){return this.internalModel.motionManager.expressionManager?void 0===t?this.internalModel.motionManager.expressionManager.setRandomExpression():this.internalModel.motionManager.expressionManager.setExpression(t):Promise.resolve(!1)}focus(t,e,r=!1){Ue.x=t,Ue.y=e,this.toModelPosition(Ue,Ue,!0);const o=Ue.x/this.internalModel.originalWidth*2-1,n=Ue.y/this.internalModel.originalHeight*2-1,i=Math.atan2(n,o);this.internalModel.focusController.focus(Math.cos(i),-Math.sin(i),r)}tap(t,e){const r=this.hitTest(t,e);r.length&&(c.log(this.tag,"Hit",r),this.emit("hit",r))}hitTest(t,e){return Ue.x=t,Ue.y=e,this.toModelPosition(Ue,Ue),this.internalModel.hitTest(Ue.x,Ue.y)}toModelPosition(t,e=t.clone(),r){return r||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.transform.worldTransform.applyInverse(t,e),this.internalModel.localTransform.applyInverse(e,e),e}containsPoint(t){return this.getBounds(!0).contains(t.x,t.y)}_calculateBounds(){this._bounds.addFrame(this.transform,0,0,this.internalModel.width,this.internalModel.height)}update(t){this.deltaTime+=t,this.elapsedTime+=t}_render(t){t.batch.reset(),t.geometry.reset(),t.shader.reset(),t.state.reset();let e=!1;this.glContextID!==t.CONTEXT_UID&&(this.glContextID=t.CONTEXT_UID,this.internalModel.updateWebGLContext(t.gl,this.glContextID),e=!0);for(let n=0;n<this.textures.length;n++){const r=this.textures[n];r.valid&&(!e&&r.baseTexture._glTextures[this.glContextID]||(t.gl.pixelStorei(WebGLRenderingContext.UNPACK_FLIP_Y_WEBGL,this.internalModel.textureFlipY),t.texture.bind(r.baseTexture,0)),this.internalModel.bindTexture(n,r.baseTexture._glTextures[this.glContextID].texture),r.baseTexture.touched=t.textureGC.count)}const r=t.framebuffer.viewport;this.internalModel.viewport=[r.x,r.y,r.width,r.height],this.deltaTime&&(this.internalModel.update(this.deltaTime,this.elapsedTime),this.deltaTime=0);const o=Ge.copyFrom(t.globalUniforms.uniforms.projectionMatrix).append(this.worldTransform);this.internalModel.updateTransform(o),this.internalModel.draw(t.gl),t.state.reset(),t.texture.reset()}destroy(t){this.emit("destroy"),(null==t?void 0:t.texture)&&this.textures.forEach((e=>e.destroy(t.baseTexture))),this.automator.destroy(),this.internalModel.destroy(),super.destroy(t)}}if(!window.Live2D)throw new Error("Could not find Cubism 2 runtime. This plugin requires live2d.min.js to be loaded.");const He=Live2DMotion.prototype.updateParam;Live2DMotion.prototype.updateParam=function(t,e){He.call(this,t,e),e.isFinished()&&this.onFinishHandler&&(this.onFinishHandler(this),delete this.onFinishHandler)};class We extends AMotion{constructor(t){super(),s(this,"params",[]),this.setFadeIn(t.fade_in>0?t.fade_in:h.expressionFadingDuration),this.setFadeOut(t.fade_out>0?t.fade_out:h.expressionFadingDuration),Array.isArray(t.params)&&t.params.forEach((t=>{const e=t.calc||"add";if("add"===e){const e=t.def||0;t.val-=e}else if("mult"===e){const e=t.def||1;t.val/=e}this.params.push({calc:e,val:t.val,id:t.id})}))}updateParamExe(t,e,r,o){this.params.forEach((e=>{t.setParamFloat(e.id,e.val*r)}))}}class Be extends v{constructor(t,e){var r;super(t,e),s(this,"queueManager",new MotionQueueManager),s(this,"definitions"),this.definitions=null!=(r=this.settings.expressions)?r:[],this.init()}isFinished(){return this.queueManager.isFinished()}getExpressionIndex(t){return this.definitions.findIndex((e=>e.name===t))}getExpressionFile(t){return t.file}createExpression(t,e){return new We(t)}_setExpression(t){return this.queueManager.startMotion(t)}stopAllExpressions(){this.queueManager.stopAllMotions()}updateParameters(t,e){return this.queueManager.updateParam(t)}}function $e(t,e,r){const o=r.getDurationMSec(),n=t.startMotion(r,!0),i=t.motions.find((t=>t&&t._$sr===n));return!!i&&(r.updateParamExe(e.coreModel,o,1,i),!0)}class Xe extends ce{constructor(t){super(t),s(this,"definitions"),s(this,"groups",{idle:"idle"}),s(this,"motionDataType","arraybuffer"),s(this,"queueManager",new MotionQueueManager),s(this,"lipSyncIds"),s(this,"expressionManager"),this.definitions=this.settings.motions,this.init(t.options),this.lipSyncIds=["PARAM_MOUTH_OPEN_Y"]}init(t){super.init(t),this.settings.expressions&&(this.expressionManager=new Be(this.settings,t))}isFinished(){return this.queueManager.isFinished()}createMotion(t,e,r){const o=Live2DMotion.loadMotion(t),n=e===this.groups.idle?h.idleMotionFadingDuration:h.motionFadingDuration;return o.setFadeIn(r.fade_in>0?r.fade_in:n),o.setFadeOut(r.fade_out>0?r.fade_out:n),o}getMotionFile(t){return t.file}getMotionName(t){return t.file}getSoundFile(t){return t.sound}_startMotion(t,e,r){return t.onFinishHandler=e,r&&r.length>0&&(t.motions=t.motions.filter((t=>!r.includes(t._$4P)))),this.queueManager.stopAllMotions(),this.queueManager.startMotion(t)}_stopAllMotions(){this.queueManager.stopAllMotions()}updateParameters(t,e){return this.queueManager.updateParam(t)}destroy(){super.destroy(),this.queueManager=void 0}motionLastFrame(t,e){return a(this,arguments,(function*(t,e,{expression:r}={}){const o=yield this.getMotionAndApplyExpression(t,e,r);return!!o&&(this.playing=!0,$e(this.queueManager,this.parent,o),this.playing=!1,!0)}))}}class ze extends e.utils.EventEmitter{constructor(t){super(),s(this,"tag"),s(this,"manager"),s(this,"settings"),s(this,"state",new ae),s(this,"playing",!1),s(this,"destroyed",!1),s(this,"parent"),this.settings=t.settings,this.tag=`ParallelMotionManager(${this.settings.name})`,this.state.tag=this.tag,this.manager=t.motionManager,this.parent=t}startMotion(t,e){return a(this,arguments,(function*(t,e,r=se.NORMAL,o=[]){var n;if(!this.state.reserve(t,e,r))return!1;const i=null==(n=this.manager.definitions[t])?void 0:n[e];if(!i)return!1;const s=yield this.manager.loadMotion(t,e);return!!this.state.start(s,t,e,r)&&(c.log(this.tag,"Start motion:",this.getMotionName(i)),this.emit("motionStart",t,e,void 0),this.playing=!0,this._startMotion(s,void 0,o),!0)}))}startRandomMotion(t,e){return a(this,null,(function*(){const r=this.manager.definitions[t];if(null==r?void 0:r.length){const o=[];for(let e=0;e<r.length;e++)null===this.manager.motionGroups[t][e]||this.state.isActive(t,e)||o.push(e);if(o.length){const r=o[Math.floor(Math.random()*o.length)];return this.startMotion(t,r,e)}}return!1}))}stopAllMotions(){this._stopAllMotions(),this.state.reset()}update(t,e){return this.isFinished()&&(this.playing&&(this.playing=!1,this.emit("motionFinish")),this.state.complete()),this.updateParameters(t,e)}destroy(){this.destroyed=!0,this.emit("destroy"),this.stopAllMotions()}}class Ve extends ze{constructor(t){super(t),s(this,"queueManager",new MotionQueueManager)}isFinished(){return this.queueManager.isFinished()}getMotionName(t){return t.file}_startMotion(t,e,r){return t.onFinishHandler=e,r&&r.length>0&&(t.motions=t.motions.filter((t=>!r.includes(t._$4P)))),this.queueManager.stopAllMotions(),this.queueManager.startMotion(t)}_stopAllMotions(){this.queueManager.stopAllMotions()}updateParameters(t,e){return this.queueManager.updateParam(t)}destroy(){super.destroy(),this.queueManager=void 0}playMotionLastFrame(t,e){return a(this,null,(function*(){var r;if(!this.state.reserve(t,e,se.FORCE))return!1;const o=null==(r=this.manager.definitions[t])?void 0:r[e];if(!o)return!1;const n=yield this.manager.loadMotion(t,e);return!!this.state.start(n,t,e,se.FORCE)&&(c.log(this.tag,"Start motion:",this.getMotionName(o)),this.queueManager.stopAllMotions(),this.emit("motionStart",t,e,void 0),this.playing=!0,!!$e(this.queueManager,this.parent,n)&&(this.playing=!1,!0))}))}}class Ye{constructor(t){s(this,"leftParam"),s(this,"rightParam"),s(this,"blinkInterval",4e3),s(this,"closingDuration",100),s(this,"closedDuration",50),s(this,"openingDuration",150),s(this,"eyeState",0),s(this,"eyeParamValue",1),s(this,"closedTimer",0),s(this,"nextBlinkTimeLeft",this.blinkInterval),this.coreModel=t,this.leftParam=t.getParamIndex("PARAM_EYE_L_OPEN"),this.rightParam=t.getParamIndex("PARAM_EYE_R_OPEN")}setEyeParams(t){this.eyeParamValue=p(t,0,1),this.coreModel.setParamFloat(this.leftParam,this.eyeParamValue),this.coreModel.setParamFloat(this.rightParam,this.eyeParamValue)}update(t){switch(this.eyeState){case 0:this.nextBlinkTimeLeft-=t,this.nextBlinkTimeLeft<0&&(this.eyeState=1,this.nextBlinkTimeLeft=this.blinkInterval+this.closingDuration+this.closedDuration+this.openingDuration+d(0,2e3));break;case 1:this.setEyeParams(this.eyeParamValue+t/this.closingDuration),this.eyeParamValue<=0&&(this.eyeState=2,this.closedTimer=0);break;case 2:this.closedTimer+=t,this.closedTimer>=this.closedDuration&&(this.eyeState=3);break;case 3:this.setEyeParams(this.eyeParamValue+t/this.openingDuration),this.eyeParamValue>=1&&(this.eyeState=0)}}}const Ke=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);class Je extends de{constructor(t,e,r){super(),s(this,"settings"),s(this,"options"),s(this,"coreModel"),s(this,"motionManager"),s(this,"parallelMotionManager"),s(this,"eyeBlink"),s(this,"eyeballXParamIndex"),s(this,"eyeballYParamIndex"),s(this,"angleXParamIndex"),s(this,"angleYParamIndex"),s(this,"angleZParamIndex"),s(this,"bodyAngleXParamIndex"),s(this,"breathParamIndex"),s(this,"textureFlipY",!0),s(this,"lipSync",!0),s(this,"drawDataCount",0),s(this,"disableCulling",!1),s(this,"hasDrawn",!1),this.coreModel=t,this.settings=e,this.options=Object.assign({},{breathDepth:1},r),this.motionManager=new Xe(this),this.parallelMotionManager=[],this.eyeBlink=new Ye(t),this.eyeballXParamIndex=t.getParamIndex("PARAM_EYE_BALL_X"),this.eyeballYParamIndex=t.getParamIndex("PARAM_EYE_BALL_Y"),this.angleXParamIndex=t.getParamIndex("PARAM_ANGLE_X"),this.angleYParamIndex=t.getParamIndex("PARAM_ANGLE_Y"),this.angleZParamIndex=t.getParamIndex("PARAM_ANGLE_Z"),this.bodyAngleXParamIndex=t.getParamIndex("PARAM_BODY_ANGLE_X"),this.breathParamIndex=t.getParamIndex("PARAM_BREATH"),this.init()}init(){super.init(),this.settings.initParams&&this.settings.initParams.forEach((({id:t,value:e})=>this.coreModel.setParamFloat(t,e))),this.settings.initOpacities&&this.settings.initOpacities.forEach((({id:t,value:e})=>this.coreModel.setPartsOpacity(t,e))),this.coreModel.saveParam();const t=this.coreModel.getModelContext()._$aS;(null==t?void 0:t.length)&&(this.drawDataCount=t.length);let e=this.coreModel.drawParamWebGL.culling;Object.defineProperty(this.coreModel.drawParamWebGL,"culling",{set:t=>e=t,get:()=>!this.disableCulling&&e});const r=this.coreModel.getModelContext().clipManager,o=r.setupClip;r.setupClip=(t,e)=>{o.call(r,t,e),e.gl.viewport(...this.viewport)}}getSize(){return[this.coreModel.getCanvasWidth(),this.coreModel.getCanvasHeight()]}getLayout(){const t={};if(this.settings.layout)for(const[e,r]of Object.entries(this.settings.layout)){let o=e;"center_x"===e?o="centerX":"center_y"===e&&(o="centerY"),t[o]=r}return t}updateWebGLContext(t,e){const r=this.coreModel.drawParamWebGL;r.firstDraw=!0,r.setGL(t),r.glno=e;for(const[i,s]of Object.entries(r))s instanceof WebGLBuffer&&(r[i]=null);const o=this.coreModel.getModelContext().clipManager;o.curFrameNo=e;const n=t.getParameter(t.FRAMEBUFFER_BINDING);o.getMaskRenderTexture(),t.bindFramebuffer(t.FRAMEBUFFER,n)}bindTexture(t,e){this.coreModel.setTexture(t,e)}getHitAreaDefs(){var t;return(null==(t=this.settings.hitAreas)?void 0:t.map((t=>({id:t.id,name:t.name,index:this.coreModel.getDrawDataIndex(t.id)}))))||[]}getDrawableIDs(){const t=this.coreModel.getModelContext(),e=[];for(let r=0;r<this.drawDataCount;r++){const o=t.getDrawData(r);o&&e.push(o.getDrawDataID().id)}return e}getDrawableIndex(t){return this.coreModel.getDrawDataIndex(t)}getDrawableVertices(t){if("string"==typeof t&&-1===(t=this.coreModel.getDrawDataIndex(t)))throw new TypeError("Unable to find drawable ID: "+t);return this.coreModel.getTransformedPoints(t).slice()}hitTest(t,e){return this.hasDrawn||c.warn("Trying to hit-test a Cubism 2 model that has not been rendered yet. The result will always be empty since the draw data is not ready."),super.hitTest(t,e)}update(t,e){var r,o,n,i;super.update(t,e);const s=this.coreModel,a=this.updateMotions(s,e);if(s.saveParam(),null==(r=this.motionManager.expressionManager)||r.update(s,e),a||null==(o=this.eyeBlink)||o.update(t),this.updateFocus(),this.updateNaturalMovements(t,e),this.lipSync&&this.motionManager.currentAudio){let t=this.motionManager.mouthSync(),e=0;const r=1,o=.4;t>0&&(e=.4),t=Math.pow(t,o),t=p(t,e,r);for(let n=0;n<this.motionManager.lipSyncIds.length;++n)this.coreModel.setParamFloat(this.coreModel.getParamIndex(this.motionManager.lipSyncIds[n]),t)}null==(n=this.physics)||n.update(e),null==(i=this.pose)||i.update(t),this.emit("beforeModelUpdate"),s.update(),s.loadParam()}updateFocus(){this.coreModel.addToParamFloat(this.eyeballXParamIndex,this.focusController.x),this.coreModel.addToParamFloat(this.eyeballYParamIndex,this.focusController.y),this.coreModel.addToParamFloat(this.angleXParamIndex,30*this.focusController.x),this.coreModel.addToParamFloat(this.angleYParamIndex,30*this.focusController.y),this.coreModel.addToParamFloat(this.angleZParamIndex,this.focusController.x*this.focusController.y*-30),this.coreModel.addToParamFloat(this.bodyAngleXParamIndex,10*this.focusController.x)}updateNaturalMovements(t,e){const r=e/1e3*2*Math.PI;this.coreModel.addToParamFloat(this.angleXParamIndex,15*this.options.breathDepth*Math.sin(r/6.5345)*.5),this.coreModel.addToParamFloat(this.angleYParamIndex,8*this.options.breathDepth*Math.sin(r/3.5345)*.5),this.coreModel.addToParamFloat(this.angleZParamIndex,10*this.options.breathDepth*Math.sin(r/5.5345)*.5),this.coreModel.addToParamFloat(this.bodyAngleXParamIndex,4*this.options.breathDepth*Math.sin(r/15.5345)*.5),this.coreModel.setParamFloat(this.breathParamIndex,.5+.5*Math.sin(r/3.2345))}draw(t){const e=this.disableCulling;t.getParameter(t.FRAMEBUFFER_BINDING)&&(this.disableCulling=!0);const r=this.drawingMatrix;Ke[0]=r.a,Ke[1]=r.b,Ke[4]=r.c,Ke[5]=r.d,Ke[12]=r.tx,Ke[13]=r.ty,this.coreModel.setMatrix(Ke),this.coreModel.draw(),this.hasDrawn=!0,this.disableCulling=e}extendParallelMotionManager(t){for(;this.parallelMotionManager.length<t;)this.parallelMotionManager.push(new Ve(this))}destroy(){super.destroy(),this.coreModel=void 0}}class Qe extends ie{constructor(t){if(super(t),s(this,"moc"),s(this,"textures"),s(this,"layout"),s(this,"hitAreas"),s(this,"initParams"),s(this,"initOpacities"),s(this,"expressions"),s(this,"motions",{}),!Qe.isValidJSON(t))throw new TypeError("Invalid JSON.");this.moc=t.model,y("string",t,this,"textures","textures"),this.copy(t)}static isValidJSON(t){var e;return!!t&&"string"==typeof t.model&&(null==(e=t.textures)?void 0:e.length)>0&&t.textures.every((t=>"string"==typeof t))}copy(t){f("string",t,this,"name","name"),f("string",t,this,"pose","pose"),f("string",t,this,"physics","physics"),f("object",t,this,"layout","layout"),f("object",t,this,"motions","motions"),y("object",t,this,"hit_areas","hitAreas"),y("object",t,this,"expressions","expressions"),y("object",t,this,"init_params","initParams"),y("object",t,this,"init_opacities","initOpacities")}replaceFiles(t){super.replaceFiles(t);for(const[e,r]of Object.entries(this.motions))for(let o=0;o<r.length;o++)r[o].file=t(r[o].file,`motions.${e}[${o}].file`),void 0!==r[o].sound&&(r[o].sound=t(r[o].sound,`motions.${e}[${o}].sound`));if(this.expressions)for(let e=0;e<this.expressions.length;e++)this.expressions[e].file=t(this.expressions[e].file,`expressions[${e}].file`)}}const Ze={x:PhysicsHair.Src.SRC_TO_X,y:PhysicsHair.Src.SRC_TO_Y,angle:PhysicsHair.Src.SRC_TO_G_ANGLE},tr={x:PhysicsHair.Src.SRC_TO_X,y:PhysicsHair.Src.SRC_TO_Y,angle:PhysicsHair.Src.SRC_TO_G_ANGLE};class er{constructor(t,e){s(this,"physicsHairs",[]),this.coreModel=t,e.physics_hair&&(this.physicsHairs=e.physics_hair.map((t=>{const e=new PhysicsHair;return e.setup(t.setup.length,t.setup.regist,t.setup.mass),t.src.forEach((({id:t,ptype:r,scale:o,weight:n})=>{const i=Ze[r];i&&e.addSrcParam(i,t,o,n)})),t.targets.forEach((({id:t,ptype:r,scale:o,weight:n})=>{const i=tr[r];i&&e.addTargetParam(i,t,o,n)})),e})))}update(t){this.physicsHairs.forEach((e=>e.update(this.coreModel,t)))}}class rr{constructor(t){s(this,"paramIndex",-1),s(this,"partsIndex",-1),s(this,"link",[]),this.id=t}initIndex(t){this.paramIndex=t.getParamIndex("VISIBLE:"+this.id),this.partsIndex=t.getPartsDataIndex(PartsDataID.getID(this.id)),t.setParamFloat(this.paramIndex,1)}}class or{constructor(t,e){s(this,"opacityAnimDuration",500),s(this,"partsGroups",[]),this.coreModel=t,e.parts_visible&&(this.partsGroups=e.parts_visible.map((({group:t})=>t.map((({id:t,link:e})=>{const r=new rr(t);return e&&(r.link=e.map((t=>new rr(t)))),r})))),this.init())}init(){this.partsGroups.forEach((t=>{t.forEach((t=>{if(t.initIndex(this.coreModel),t.paramIndex>=0){const e=0!==this.coreModel.getParamFloat(t.paramIndex);this.coreModel.setPartsOpacity(t.partsIndex,e?1:0),this.coreModel.setParamFloat(t.paramIndex,e?1:0),t.link.length>0&&t.link.forEach((t=>t.initIndex(this.coreModel)))}}))}))}normalizePartsOpacityGroup(t,e){const r=this.coreModel,o=.5;let n=1,i=t.findIndex((({paramIndex:t,partsIndex:e})=>e>=0&&0!==r.getParamFloat(t)));if(i>=0){const o=r.getPartsOpacity(t[i].partsIndex);n=p(o+e/this.opacityAnimDuration,0,1)}else i=0,n=1;t.forEach((({partsIndex:t},e)=>{if(t>=0)if(i==e)r.setPartsOpacity(t,n);else{let e,i=r.getPartsOpacity(t);e=n<o?-.5*n/o+1:(1-n)*o/.5;(1-e)*(1-n)>.15&&(e=1-.15/(1-n)),i>e&&(i=e),r.setPartsOpacity(t,i)}}))}copyOpacity(t){const e=this.coreModel;t.forEach((({partsIndex:t,link:r})=>{if(t>=0&&r){const o=e.getPartsOpacity(t);r.forEach((({partsIndex:t})=>{t>=0&&e.setPartsOpacity(t,o)}))}}))}update(t){this.partsGroups.forEach((e=>{this.normalizePartsOpacityGroup(e,t),this.copyOpacity(e)}))}}Te.registerRuntime({version:2,test:t=>t instanceof Qe||Qe.isValidJSON(t),ready:()=>Promise.resolve(),isValidMoc(t){if(t.byteLength<3)return!1;const e=new Int8Array(t,0,3);return"moc"===String.fromCharCode(...e)},createModelSettings:t=>new Qe(t),createCoreModel(t){const e=Live2DModelWebGL.loadModel(t),r=Live2D.getError();if(r)throw r;return e},createInternalModel:(t,e,r)=>new Je(t,e,r),createPose:(t,e)=>new or(t,e),createPhysics:(t,e)=>new er(t,e)}),t.Cubism2ExpressionManager=Be,t.Cubism2InternalModel=Je,t.Cubism2ModelSettings=Qe,t.Cubism2MotionManager=Xe,t.Cubism2ParallelMotionManager=Ve,t.ExpressionManager=v,t.FileLoader=Fe,t.FocusController=M,t.InternalModel=de,t.LOGICAL_HEIGHT=2,t.LOGICAL_WIDTH=2,t.Live2DExpression=We,t.Live2DEyeBlink=Ye,t.Live2DFactory=Te,t.Live2DLoader=ve,t.Live2DModel=qe,t.Live2DPhysics=er,t.Live2DPose=or,t.Live2DTransform=Ne,t.ModelSettings=ie,t.MotionManager=ce,t.MotionPreloadStrategy=he,t.MotionPriority=se,t.MotionState=ae,t.SoundManager=ue,t.VERSION="v0.5.2",t.VOLUME=le,t.XHRLoader=me,t.ZipLoader=Se,t.applyMixins=function(t,e){e.forEach((e=>{Object.getOwnPropertyNames(e.prototype).forEach((r=>{"constructor"!==r&&Object.defineProperty(t.prototype,r,Object.getOwnPropertyDescriptor(e.prototype,r))}))}))},t.clamp=p,t.config=h,t.copyArray=y,t.copyProperty=f,t.folderName=m,t.logger=c,t.rand=d,t.remove=g,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}));
|
package/dist/cubism4.es.js
CHANGED
|
@@ -7753,7 +7753,7 @@ const config = {
|
|
|
7753
7753
|
preserveExpressionOnMotion: true,
|
|
7754
7754
|
cubism4: CubismConfig
|
|
7755
7755
|
};
|
|
7756
|
-
const VERSION = "v0.5.
|
|
7756
|
+
const VERSION = "v0.5.2";
|
|
7757
7757
|
const logger = {
|
|
7758
7758
|
log(tag, ...messages) {
|
|
7759
7759
|
if (config.logLevel <= config.LOG_LEVEL_VERBOSE) {
|
|
@@ -11405,7 +11405,6 @@ class SoundManager {
|
|
|
11405
11405
|
if (!(audio.media instanceof webaudio.WebAudioMedia)) {
|
|
11406
11406
|
reject(new Error(`Error: ${file} is not WebAudioMedia`));
|
|
11407
11407
|
}
|
|
11408
|
-
debugger;
|
|
11409
11408
|
resolve(audio);
|
|
11410
11409
|
}
|
|
11411
11410
|
});
|