untitled-pixi-live2d-engine 1.0.1 → 1.0.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.
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("pixi.js"),require("@pixi/sound")):"function"==typeof define&&define.amd?define(["exports","pixi.js","@pixi/sound"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).PIXI=t.PIXI||{},t.PIXI.live2d=t.PIXI.live2d||{}),t.PIXI,t.PIXI)}(this,function(t,e,i){"use strict";var s=Object.defineProperty,r=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable,o=Math.pow,l=(t,e,i)=>e in t?s(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,u=(t,e,i)=>l(t,"symbol"!=typeof e?e+"":e,i),h=(t,e,i)=>new Promise((s,r)=>{var a=t=>{try{o(i.next(t))}catch(e){r(e)}},n=t=>{try{o(i.throw(t))}catch(e){r(e)}},o=t=>t.done?s(t.value):Promise.resolve(t.value).then(a,n);o((i=i.apply(t,e)).next())});const d=class t{constructor(t=0){t<1?(this._ptr=[],this._capacity=0,this._size=0):(this._ptr=new Array(t),this._capacity=t,this._size=0)}at(t){return this._ptr[t]}set(t,e){this._ptr[t]=e}get(t=0){const e=new Array;for(let i=t;i<this._size;i++)e.push(this._ptr[i]);return e}pushBack(e){this._size>=this._capacity&&this.prepareCapacity(0==this._capacity?t.DefaultSize:2*this._capacity),this._ptr[this._size++]=e}clear(){this._ptr.length=0,this._size=0}getSize(){return this._size}assign(t,e){this._size<t&&this.prepareCapacity(t);for(let i=0;i<t;i++)this._ptr[i]=e;this._size=t}resize(t,e=null){this.updateSize(t,e,!0)}updateSize(t,e=null,i=!0){if(this._size<t)if(this.prepareCapacity(t),i)for(let s=this._size;s<t;s++)this._ptr[s]="function"==typeof e?JSON.parse(JSON.stringify(new e)):e;else for(let s=this._size;s<t;s++)this._ptr[s]=e;else{const e=this._size-t;this._ptr.splice(this._size-e,e)}this._size=t}insert(t,e,i){let s=t._index;const r=e._index,a=i._index,n=a-r;this.prepareCapacity(this._size+n);const o=this._size-s;if(o>0)for(let l=0;l<o;l++)this._ptr.splice(s+l,0,null);for(let l=r;l<a;l++,s++)this._ptr[s]=e._vector._ptr[l];this._size=this._size+n}remove(t){return!(t<0||this._size<=t)&&(this._ptr.splice(t,1),--this._size,!0)}erase(t){const e=t._index;if(e<0||this._size<=e)return t;this._ptr.splice(e,1),--this._size;return new c(this,e)}prepareCapacity(t){t>this._capacity&&(0==this._capacity?(this._ptr=new Array(t),this._capacity=t):(this._ptr.length=t,this._capacity=t))}begin(){return 0==this._size?this.end():new c(this,0)}end(){return new c(this,this._size)}getOffset(e){const i=new t;return i._ptr=this.get(e),i._size=this.get(e).length,i._capacity=this.get(e).length,i}};d.DefaultSize=10;let g=d,c=class t{constructor(t,e){this._vector=null!=t?t:null,this._index=null!=e?e:0}set(t){return this._index=t._index,this._vector=t._vector,this}preIncrement(){return++this._index,this}preDecrement(){return--this._index,this}increment(){return new t(this._vector,this._index++)}decrement(){return new t(this._vector,this._index--)}ptr(){return this._vector._ptr[this._index]}substitution(t){return this._index=t._index,this._vector=t._vector,this}notEqual(t){return this._index!=t._index||this._vector!=t._vector}};var m,p,_,f,y,x,C;(p=m||(m={})).csmVector=g,p.iterator=c;class S{append(t,e){return this.s+=void 0!==e?t.substr(0,e):t,this}expansion(t,e){for(let i=0;i<t;i++)this.append(e);return this}getBytes(){return encodeURIComponent(this.s).replace(/%../g,"x").length}getLength(){return this.s.length}isLess(t){return this.s<t.s}isGreat(t){return this.s>t.s}isEqual(t){return this.s==t}isEmpty(){return 0==this.s.length}constructor(t){this.s=t}}(t=>{t.csmString=S})(_||(_={}));class M{static createIdInternal(t){return new M(t)}getString(){return this._id}isEqual(t){return"string"==typeof t?this._id.isEqual(t):t instanceof S?this._id.isEqual(t.s):t instanceof M&&this._id.isEqual(t._id.s)}isNotEqual(t){return"string"==typeof t?!this._id.isEqual(t):t instanceof S?!this._id.isEqual(t.s):t instanceof M&&!this._id.isEqual(t._id.s)}constructor(t){this._id="string"!=typeof t?t:new S(t)}}(t=>{t.CubismId=M})(f||(f={}));class v{constructor(){this._ids=new g}release(){for(let t=0;t<this._ids.getSize();++t)this._ids.set(t,void 0);this._ids=null}registerIds(t){for(let e=0;e<t.length;e++)this.registerId(t[e])}registerId(t){let e=null;return"string"!=typeof t?this.registerId(t.s):(null!=(e=this.findId(t))||(e=M.createIdInternal(t),this._ids.pushBack(e)),e)}getId(t){return this.registerId(t)}isExist(t){return"string"==typeof t?null!=this.findId(t):this.isExist(t.s)}findId(t){for(let e=0;e<this._ids.getSize();++e)if(this._ids.at(e).getString().isEqual(t))return this._ids.at(e);return null}}(t=>{t.CubismIdManager=v})(y||(y={}));class b{constructor(){this._tr=new Float32Array(16),this.loadIdentity()}static multiply(t,e,i){const s=new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);for(let r=0;r<4;++r)for(let i=0;i<4;++i)for(let a=0;a<4;++a)s[i+4*r]+=t[a+4*r]*e[i+4*a];for(let r=0;r<16;++r)i[r]=s[r]}loadIdentity(){const t=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);this.setMatrix(t)}setMatrix(t){for(let e=0;e<16;++e)this._tr[e]=t[e]}getArray(){return this._tr}getScaleX(){return this._tr[0]}getScaleY(){return this._tr[5]}getTranslateX(){return this._tr[12]}getTranslateY(){return this._tr[13]}transformX(t){return this._tr[0]*t+this._tr[12]}transformY(t){return this._tr[5]*t+this._tr[13]}invertTransformX(t){return(t-this._tr[12])/this._tr[0]}invertTransformY(t){return(t-this._tr[13])/this._tr[5]}translateRelative(t,e){const i=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,t,e,0,1]);b.multiply(i,this._tr,this._tr)}translate(t,e){this._tr[12]=t,this._tr[13]=e}translateX(t){this._tr[12]=t}translateY(t){this._tr[13]=t}scaleRelative(t,e){const i=new Float32Array([t,0,0,0,0,e,0,0,0,0,1,0,0,0,0,1]);b.multiply(i,this._tr,this._tr)}scale(t,e){this._tr[0]=t,this._tr[5]=e}multiplyByMatrix(t){b.multiply(t.getArray(),this._tr,this._tr)}clone(){const t=new b;for(let e=0;e<this._tr.length;e++)t._tr[e]=this._tr[e];return t}}(t=>{t.CubismMatrix44=b})(x||(x={}));class P{constructor(t,e,i,s){this.x=t,this.y=e,this.width=i,this.height=s}getCenterX(){return this.x+.5*this.width}getCenterY(){return this.y+.5*this.height}getRight(){return this.x+this.width}getBottom(){return this.y+this.height}setRect(t){this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height}expand(t,e){this.x-=t,this.y-=e,this.width+=2*t,this.height+=2*e}}(t=>{t.csmRect=P})(C||(C={}));class B{static create(){return null}static delete(t){}initialize(t){this._model=t}drawModel(){null!=this.getModel()&&(this.saveProfile(),this.doDrawModel(),this.restoreProfile())}setMvpMatrix(t){this._mvpMatrix4x4.setMatrix(t.getArray())}getMvpMatrix(){return this._mvpMatrix4x4}setModelColor(t,e,i,s){t<0?t=0:t>1&&(t=1),e<0?e=0:e>1&&(e=1),i<0?i=0:i>1&&(i=1),s<0?s=0:s>1&&(s=1),this._modelColor.r=t,this._modelColor.g=e,this._modelColor.b=i,this._modelColor.a=s}getModelColor(){return JSON.parse(JSON.stringify(this._modelColor))}getModelColorWithOpacity(t){const e=this.getModelColor();return e.a*=t,this.isPremultipliedAlpha()&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),e}setIsPremultipliedAlpha(t){this._isPremultipliedAlpha=t}isPremultipliedAlpha(){return this._isPremultipliedAlpha}setIsCulling(t){this._isCulling=t}isCulling(){return this._isCulling}setAnisotropy(t){this._anisotropy=t}getAnisotropy(){return this._anisotropy}getModel(){return this._model}useHighPrecisionMask(t){this._useHighPrecisionMask=t}isUsingHighPrecisionMask(){return this._useHighPrecisionMask}constructor(){this._isCulling=!1,this._isPremultipliedAlpha=!1,this._anisotropy=0,this._model=null,this._modelColor=new I,this._useHighPrecisionMask=!1,this._mvpMatrix4x4=new b,this._mvpMatrix4x4.loadIdentity()}}var w,F=(t=>(t[t.CubismBlendMode_Normal=0]="CubismBlendMode_Normal",t[t.CubismBlendMode_Additive=1]="CubismBlendMode_Additive",t[t.CubismBlendMode_Multiplicative=2]="CubismBlendMode_Multiplicative",t))(F||{});class I{constructor(t=1,e=1,i=1,s=1){this.r=t,this.g=e,this.b=i,this.a=s}}class E{constructor(t,e){this._clippingIdList=t,this._clippingIdCount=e,this._allClippedDrawRect=new P,this._layoutBounds=new P,this._clippedDrawableIndexList=[],this._matrixForMask=new b,this._matrixForDraw=new b,this._bufferIndex=0}release(){null!=this._layoutBounds&&(this._layoutBounds=null),null!=this._allClippedDrawRect&&(this._allClippedDrawRect=null),null!=this._clippedDrawableIndexList&&(this._clippedDrawableIndexList=null)}addClippedDrawable(t){this._clippedDrawableIndexList.push(t)}}(t=>{t.CubismBlendMode=F,t.CubismRenderer=B,t.CubismTextureColor=I})(w||(w={}));const V=Object.freeze(Object.defineProperty({__proto__:null,CSM_LOG_LEVEL:0,CSM_LOG_LEVEL_DEBUG:1,CSM_LOG_LEVEL_ERROR:4,CSM_LOG_LEVEL_INFO:2,CSM_LOG_LEVEL_OFF:5,CSM_LOG_LEVEL_VERBOSE:0,CSM_LOG_LEVEL_WARNING:3},Symbol.toStringTag,{value:"Module"})),R=(t,e,i)=>{((t,e,i)=>{k.print(t,"[CSM]"+e,i)})(t,e+"\n",i)},L=t=>{console.assert(t)};let T,A,D,O;T=(t,...e)=>{R(dt.LogLevel_Debug,"[D]"+t,e)},A=(t,...e)=>{R(dt.LogLevel_Info,"[I]"+t,e)},D=(t,...e)=>{R(dt.LogLevel_Warning,"[W]"+t,e)},O=(t,...e)=>{R(dt.LogLevel_Error,"[E]"+t,e)};class k{static print(t,e,i){if(t<ht.getLoggingLevel())return;const s=ht.coreLogFunction;if(!s)return;s(e.replace(/\{(\d+)\}/g,(t,e)=>i[e]))}static dumpBytes(t,e,i){for(let s=0;s<i;s++)s%16==0&&s>0?this.print(t,"\n"):s%8==0&&s>0&&this.print(t," "),this.print(t,"{0} ",[255&e[s]]);this.print(t,"\n")}constructor(){}}var N;(t=>{t.CubismDebug=k})(N||(N={}));class U{constructor(t,e){this.first=null==t?null:t,this.second=null==e?null:e}}const z=class t{constructor(t){null!=t?t<1?(this._keyValues=[],this._dummyValue=null,this._size=0):(this._keyValues=new Array(t),this._size=t):(this._keyValues=[],this._dummyValue=null,this._size=0)}release(){this.clear()}appendKey(t){let e=-1;for(let i=0;i<this._size;i++)if(this._keyValues[i].first==t){e=i;break}-1==e?(this.prepareCapacity(this._size+1,!1),this._keyValues[this._size]=new U(t),this._size+=1):D("The key `{0}` is already append.",t)}getValue(t){let e=-1;for(let i=0;i<this._size;i++)if(this._keyValues[i].first==t){e=i;break}return e>=0?this._keyValues[e].second:(this.appendKey(t),this._keyValues[this._size-1].second)}setValue(t,e){let i=-1;for(let s=0;s<this._size;s++)if(this._keyValues[s].first==t){i=s;break}i>=0?this._keyValues[i].second=e:(this.appendKey(t),this._keyValues[this._size-1].second=e)}isExist(t){for(let e=0;e<this._size;e++)if(this._keyValues[e].first==t)return!0;return!1}clear(){this._keyValues=void 0,this._keyValues=null,this._keyValues=[],this._size=0}getSize(){return this._size}prepareCapacity(e,i){e>this._keyValues.length&&(0==this._keyValues.length?(!i&&e<t.DefaultSize&&(e=t.DefaultSize),this._keyValues.length=e):(!i&&e<2*this._keyValues.length&&(e=2*this._keyValues.length),this._keyValues.length=e))}begin(){return new G(this,0)}end(){return new G(this,this._size)}erase(t){const e=t._index;if(e<0||this._size<=e)return t;this._keyValues.splice(e,1),--this._size;return new G(this,e)}dumpAsInt(){for(let t=0;t<this._size;t++)T("{0} ,",this._keyValues[t]),T("\n")}};z.DefaultSize=10;let j=z;class G{constructor(t,e){this._map=null!=t?t:new j,this._index=null!=e?e:0}set(t){return this._index=t._index,this._map=t._map,this}preIncrement(){return++this._index,this}preDecrement(){return--this._index,this}increment(){return new G(this._map,this._index++)}decrement(){const t=new G(this._map,this._index);return this._map=t._map,this._index=t._index,this}ptr(){return this._map._keyValues[this._index]}notEqual(t){return this._index!=t._index||this._map!=t._map}}var X;(t=>{t.csmMap=j,t.csmPair=U,t.iterator=G})(X||(X={}));class H{static parseJsonObject(t,e){return Object.keys(t).forEach(i=>{if("boolean"==typeof t[i]){const s=Boolean(t[i]);e.put(i,new $(s))}else if("string"==typeof t[i]){const s=String(t[i]);e.put(i,new Z(s))}else if("number"==typeof t[i]){const s=Number(t[i]);e.put(i,new J(s))}else t[i]instanceof Array?e.put(i,H.parseJsonArray(t[i])):t[i]instanceof Object?e.put(i,H.parseJsonObject(t[i],new et)):null==t[i]?e.put(i,new Q):e.put(i,t[i])}),e}static parseJsonArray(t){const e=new tt;return Object.keys(t).forEach(i=>{if("number"==typeof Number(i))if("boolean"==typeof t[i]){const s=Boolean(t[i]);e.add(new $(s))}else if("string"==typeof t[i]){const s=String(t[i]);e.add(new Z(s))}else if("number"==typeof t[i]){const s=Number(t[i]);e.add(new J(s))}else t[i]instanceof Array?e.add(this.parseJsonArray(t[i])):t[i]instanceof Object?e.add(this.parseJsonObject(t[i],new et)):null==t[i]?e.add(new Q):e.add(t[i]);else if(t[i]instanceof Array)e.add(this.parseJsonArray(t[i]));else if(t[i]instanceof Object)e.add(this.parseJsonObject(t[i],new et));else if(null==t[i])e.add(new Q);else{const s=Array(t[i]);for(let t=0;t<s.length;t++)e.add(s[t])}}),e}}const q="Error: type mismatch";let W=class t{constructor(){}getRawString(t,e){return this.getString(t,e)}toInt(t=0){return t}toFloat(t=0){return t}toBoolean(t=!1){return t}getSize(){return 0}getArray(t=null){return t}getVector(t=new g){return t}getMap(t){return t}getValueByIndex(e){return t.errorValue.setErrorNotForClientCall(q)}getValueByString(e){return t.nullValue.setErrorNotForClientCall(q)}getKeys(){return t.dummyKeys}isError(){return!1}isNull(){return!1}isBool(){return!1}isFloat(){return!1}isString(){return!1}isArray(){return!1}isMap(){return!1}equals(t){return!1}isStatic(){return!1}setErrorNotForClientCall(t){return K.errorValue}static staticInitializeNotForClientCall(){$.trueValue=new $(!0),$.falseValue=new $(!1),t.errorValue=new K("ERROR",!0),t.nullValue=new Q,t.dummyKeys=new g}static staticReleaseNotForClientCall(){$.trueValue=null,$.falseValue=null,t.errorValue=null,t.nullValue=null,t.dummyKeys=null}};class Y{constructor(t,e){this._parseCallback=H.parseJsonObject,this._error=null,this._lineCount=0,this._root=null,null!=t&&this.parseBytes(t,e,this._parseCallback)}static create(t,e){const i=new Y;return i.parseBytes(t,e,i._parseCallback)?i:(Y.delete(i),null)}static delete(t){}getRoot(){return this._root}static arrayBufferToString(t){const e=new Uint8Array(t);let i="";for(let s=0,r=e.length;s<r;++s)i+="%"+this.pad(e[s].toString(16));return i=decodeURIComponent(i),i}static pad(t){return t.length<2?"0"+t:t}parseBytes(t,e,i){const s=new Array(1),r=Y.arrayBufferToString(t);if(this._root=null==i?this.parseValue(r,e,0,s):i(JSON.parse(r),new et),this._error){let t="\0";return t="Json parse error : @line "+(this._lineCount+1)+"\n",this._root=new Z(t),A("{0}",this._root.getRawString()),!1}return null!=this._root||(this._root=new K(new S(this._error),!1),!1)}getParseError(){return this._error}checkEndOfFile(){return this._root.getArray()[1].equals("EOF")}parseValue(t,e,i,s){if(this._error)return null;let r,a=null,n=i;for(;n<e;n++){switch(t[n]){case"-":case".":case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{const e=new Array(1);return r=st(t.slice(n),e),s[0]=t.indexOf(e[0]),new J(r)}case'"':return new Z(this.parseString(t,e,n+1,s));case"[":return a=this.parseArray(t,e,n+1,s),a;case"{":return a=this.parseObject(t,e,n+1,s),a;case"n":return n+3<e?(a=new Q,s[0]=n+4):this._error="parse null",a;case"t":return n+3<e?(a=$.trueValue,s[0]=n+4):this._error="parse true",a;case"f":return n+4<e?(a=$.falseValue,s[0]=n+5):this._error="illegal ',' position",a;case",":return this._error="illegal ',' position",null;case"]":return s[0]=n,null;case"\n":this._lineCount++}}return this._error="illegal end of value",null}parseString(t,e,i,s){if(this._error)return null;if(!t)return this._error="string is null",null;let r,a,n=i;const o=new S("");let l=i;for(;n<e;n++)switch(r=t[n],r){case'"':return s[0]=n+1,o.append(t.slice(l),n-l),o.s;case"//":if(n++,n-1>l&&o.append(t.slice(l),n-l),l=n+1,n<e)switch(a=t[n],a){case"\\":o.expansion(1,"\\");break;case'"':o.expansion(1,'"');break;case"/":o.expansion(1,"/");break;case"b":o.expansion(1,"\b");break;case"f":o.expansion(1,"\f");break;case"n":o.expansion(1,"\n");break;case"r":o.expansion(1,"\r");break;case"t":o.expansion(1,"\t");break;case"u":this._error="parse string/unicord escape not supported"}else this._error="parse string/escape error"}return this._error="parse string/illegal end",null}parseObject(t,e,i,s){if(this._error)return null;if(!t)return this._error="buffer is null",null;const r=new et;let a="",n=i,o="";const l=Array(1);let u=!1;for(;n<e;n++){t:for(;n<e;n++)switch(o=t[n],o){case'"':if(a=this.parseString(t,e,n+1,l),this._error)return null;n=l[0],u=!0;break t;case"}":return s[0]=n+1,r;case":":this._error="illegal ':' position";break;case"\n":this._lineCount++}if(!u)return this._error="key not found",null;u=!1;t:for(;n<e;n++)switch(o=t[n],o){case":":u=!0,n++;break t;case"}":this._error="illegal '}' position";break;case"\n":this._lineCount++}if(!u)return this._error="':' not found",null;const i=this.parseValue(t,e,n,l);if(this._error)return null;n=l[0],r.put(a,i);t:for(;n<e;n++)switch(o=t[n],o){case",":break t;case"}":return s[0]=n+1,r;case"\n":this._lineCount++}}return this._error="illegal end of perseObject",null}parseArray(t,e,i,s){if(this._error)return null;if(!t)return this._error="buffer is null",null;let r,a=new tt,n=i;const o=new Array(1);for(;n<e;n++){const i=this.parseValue(t,e,n,o);if(this._error)return null;n=o[0],i&&a.add(i);t:for(;n<e;n++)switch(r=t[n],r){case",":break t;case"]":return s[0]=n+1,a;case"\n":++this._lineCount}}return a=void 0,this._error="illegal end of parseObject",null}}class J extends W{constructor(t){super(),this._value=t}isFloat(){return!0}getString(t,e){return this._value=parseFloat("\0"),this._stringBuffer="\0",this._stringBuffer}toInt(t=0){return parseInt(this._value.toString())}toFloat(t=0){return this._value}equals(t){return"number"==typeof t&&(!Math.round(t)&&t==this._value)}}class $ extends W{isBool(){return!0}toBoolean(t=!1){return this._boolValue}getString(t,e){return this._stringBuffer=this._boolValue?"true":"false",this._stringBuffer}equals(t){return"boolean"==typeof t&&t==this._boolValue}isStatic(){return!0}constructor(t){super(),this._boolValue=t}}class Z extends W{constructor(t){super(),"string"==typeof t&&(this._stringBuffer=t),t instanceof S&&(this._stringBuffer=t.s)}isString(){return!0}getString(t,e){return this._stringBuffer}equals(t){return"string"==typeof t?this._stringBuffer==t:t instanceof S&&this._stringBuffer==t.s}}class K extends Z{isStatic(){return this._isStatic}setErrorNotForClientCall(t){return this._stringBuffer=t,this}constructor(t,e){super(t),this._isStatic=e}isError(){return!0}}class Q extends W{isNull(){return!0}getString(t,e){return this._stringBuffer}isStatic(){return!0}setErrorNotForClientCall(t){return this._stringBuffer=t,K.nullValue}constructor(){super(),this._stringBuffer="NullValue"}}class tt extends W{constructor(){super(),this._array=new g}release(){for(let t=this._array.begin();t.notEqual(this._array.end());t.preIncrement()){let e=t.ptr();e&&!e.isStatic()&&(e=void 0,e=null)}}isArray(){return!0}getValueByIndex(t){if(t<0||this._array.getSize()<=t)return W.errorValue.setErrorNotForClientCall("Error: index out of bounds");const e=this._array.at(t);return null==e?W.nullValue:e}getValueByString(t){return W.errorValue.setErrorNotForClientCall(q)}getString(t,e){const i=e+"[\n";for(let s=this._array.begin();s.notEqual(this._array.end());s.increment()){const t=s.ptr();this._stringBuffer+=e+""+t.getString(e+" ")+"\n"}return this._stringBuffer=i+e+"]\n",this._stringBuffer}add(t){this._array.pushBack(t)}getVector(t=null){return this._array}getSize(){return this._array.getSize()}}class et extends W{constructor(){super(),this._map=new j}release(){const t=this._map.begin();for(;t.notEqual(this._map.end());){let e=t.ptr().second;e&&!e.isStatic()&&(e=void 0,e=null),t.preIncrement()}}isMap(){return!0}getValueByString(t){if(t instanceof S){const e=this._map.getValue(t.s);return null==e?W.nullValue:e}for(let e=this._map.begin();e.notEqual(this._map.end());e.preIncrement())if(e.ptr().first==t)return null==e.ptr().second?W.nullValue:e.ptr().second;return W.nullValue}getValueByIndex(t){return W.errorValue.setErrorNotForClientCall(q)}getString(t,e){this._stringBuffer=e+"{\n";const i=this._map.begin();for(;i.notEqual(this._map.end());){const t=i.ptr().first,s=i.ptr().second;this._stringBuffer+=e+" "+t+" : "+s.getString(e+" ")+" \n",i.preIncrement()}return this._stringBuffer+=e+"}\n",this._stringBuffer}getMap(t){return this._map}put(t,e){this._map.setValue(t,e)}getKeys(){if(!this._keys){this._keys=new g;const t=this._map.begin();for(;t.notEqual(this._map.end());){const e=t.ptr().first;this._keys.pushBack(e),t.preIncrement()}}return this._keys}getSize(){return this._keys.getSize()}}var it;function st(t,e){let i=0;for(let r=1;;r++){const e=t.slice(r-1,r);if("e"==e||"-"==e||"E"==e)continue;const s=t.substring(0,r),a=Number(s);if(isNaN(a))break;i=r}let s=parseFloat(t);return isNaN(s)&&(s=NaN),e[0]=t.slice(i),s}(t=>{t.CubismJson=Y,t.JsonArray=tt,t.JsonBoolean=$,t.JsonError=K,t.JsonFloat=J,t.JsonMap=et,t.JsonNullvalue=Q,t.JsonString=Z,t.Value=W})(it||(it={}));let rt=!1,at=!1,nt=null,ot=null;const lt=Object.freeze({vertexOffset:0,vertexStep:2});function ut(t){t&&(t=void 0)}class ht{static startUp(t=null){if(rt)return A("CubismFramework.startUp() is already done."),rt;if(nt=t,null!=nt&&Live2DCubismCore.Logging.csmSetLogFunction(nt.logFunction),rt=!0,rt){const t=Live2DCubismCore.Version.csmGetVersion(),e=(16711680&t)>>16,i=65535&t,s=t;A("Live2D Cubism Core version: {0}.{1}.{2} ({3})",("00"+((4278190080&t)>>24)).slice(-2),("00"+e).slice(-2),("0000"+i).slice(-4),s)}return A("CubismFramework.startUp() is complete."),rt}static cleanUp(){rt=!1,at=!1,nt=null,ot=null}static initialize(t=0){L(rt),rt?at?D("CubismFramework.initialize() skipped, already initialized."):(W.staticInitializeNotForClientCall(),ot=new v,Live2DCubismCore.Memory.initializeAmountOfMemory(t),at=!0,A("CubismFramework.initialize() is complete.")):D("CubismFramework is not started.")}static dispose(){L(rt),rt?at?(W.staticReleaseNotForClientCall(),ot.release(),ot=null,B.staticRelease(),at=!1,A("CubismFramework.dispose() is complete.")):D("CubismFramework.dispose() skipped, not initialized."):D("CubismFramework is not started.")}static isStarted(){return rt}static isInitialized(){return at}static coreLogFunction(t){Live2DCubismCore.Logging.csmGetLogFunction()&&Live2DCubismCore.Logging.csmGetLogFunction()(t)}static getLoggingLevel(){return null!=nt?nt.loggingLevel:5}static getIdManager(){return ot}constructor(){}}var dt=(t=>(t[t.LogLevel_Verbose=0]="LogLevel_Verbose",t[t.LogLevel_Debug=1]="LogLevel_Debug",t[t.LogLevel_Info=2]="LogLevel_Info",t[t.LogLevel_Warning=3]="LogLevel_Warning",t[t.LogLevel_Error=4]="LogLevel_Error",t[t.LogLevel_Off=5]="LogLevel_Off",t))(dt||{});t.Live2DCubismFramework=void 0,(t=>{t.Constant=lt,t.csmDelete=ut,t.CubismFramework=ht})(t.Live2DCubismFramework||(t.Live2DCubismFramework={}));const gt={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,cubism:V},ct={log(t,...e){gt.logLevel<=gt.LOG_LEVEL_VERBOSE&&console.log(`[${t}]`,...e)},warn(t,...e){gt.logLevel<=gt.LOG_LEVEL_WARNING&&console.warn(`[${t}]`,...e)},error(t,...e){gt.logLevel<=gt.LOG_LEVEL_ERROR&&console.error(`[${t}]`,...e)}};function mt(t,e,i){return t<e?e:t>i?i:t}function pt(t){return 1024*t*1024}function _t(t,e,i,s,r){const a=e[s];null!==a&&typeof a===t&&(i[r]=a)}function ft(t,e,i,s,r){const a=e[s];Array.isArray(a)&&(i[r]=a.filter(e=>null!==e&&typeof e===t))}function yt(t,e){e.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(i=>{"constructor"!==i&&Object.defineProperty(t.prototype,i,Object.getOwnPropertyDescriptor(e.prototype,i))})})}function xt(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 Ct(t,e){const i=t.indexOf(e);-1!==i&&t.splice(i,1)}const St=/^[a-zA-Z][a-zA-Z0-9+.-]*:/;function Mt(t,e){if(!e)return t;if(St.test(e))return e;if(e.startsWith("/"))return St.test(t)?new URL(e,t).toString():e;if(St.test(t))return new URL(e,t).toString();const i="http://example.com",s=t.startsWith("/")?i+t:`${i}/${t}`,r=new URL(e,s);let a=r.pathname+r.search+r.hash;return!t.startsWith("/")&&a.startsWith("/")&&(a=a.slice(1)),a}class vt extends e.EventEmitter{constructor(t,e){super(),u(this,"expressionDataType","json"),u(this,"tag"),u(this,"settings"),u(this,"expressions",[]),u(this,"defaultExpression"),u(this,"currentExpression"),u(this,"reserveExpressionIndex",-1),u(this,"destroyed",!1),this.settings=t,this.tag=`ExpressionManager(${t.name})`}init(){this.defaultExpression=this.createDefaultExpression(),this.currentExpression=this.defaultExpression,this.stopAllExpressions()}createDefaultExpression(){return this.createExpression({},void 0)}loadExpression(t){return h(this,null,function*(){if(!this.definitions[t])return void ct.warn(this.tag,`Undefined expression at [${t}]`);if(null===this.expressions[t])return void ct.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 h(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 h(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 bt=40/7.5,Pt=1/150;class Bt{constructor(){u(this,"targetX",0),u(this,"targetY",0),u(this,"x",0),u(this,"y",0),u(this,"vx",0),u(this,"vy",0)}focus(t,e,i=!1){this.targetX=mt(t,-1,1),this.targetY=mt(e,-1,1),i&&(this.x=this.targetX,this.y=this.targetY)}update(t){const e=this.targetX-this.x,i=this.targetY-this.y;if(Math.abs(e)<.01&&Math.abs(i)<.01)return;const s=Math.sqrt(o(e,2)+o(i,2)),r=bt/(1e3/t);let a=r*(e/s)-this.vx,n=r*(i/s)-this.vy;const l=Math.sqrt(o(a,2)+o(n,2)),u=r*Pt*t;l>u&&(a*=u/l,n*=u/l),this.vx+=a,this.vy+=n;const h=Math.sqrt(o(this.vx,2)+o(this.vy,2)),d=.5*(Math.sqrt(o(u,2)+8*u*s)-u);h>d&&(this.vx*=d/h,this.vy*=d/h),this.x+=this.vx,this.y+=this.vy}}class wt{constructor(t){u(this,"json"),u(this,"name"),u(this,"url"),u(this,"pose"),u(this,"physics"),this.json=t,this.url=t.url,this.name=xt(this.url)}normalizeName(){this.name&&"name"!==this.name.toLowerCase()||(this.name=xt(this.url))}setModelName(...t){for(const e of t){const t="string"==typeof e?e.trim():"";if(t&&"name"!==t.toLowerCase())return void(this.name=t)}this.normalizeName()}getFileStem(t){if(!t)return;const e=t.split(/[/\\]/).filter(Boolean).pop();return null==e?void 0:e.replace(/\.[^.]+$/,"")}resolveURL(t){return Mt(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,i)=>{const s=this.resolveURL(e);if(!t.includes(s)){if(i)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 Ft=(t=>(t[t.NONE=0]="NONE",t[t.IDLE=1]="IDLE",t[t.NORMAL=2]="NORMAL",t[t.FORCE=3]="FORCE",t))(Ft||{});class It{constructor(){u(this,"tag"),u(this,"debug",!1),u(this,"currentPriority",0),u(this,"reservePriority",0),u(this,"currentGroup"),u(this,"currentIndex"),u(this,"reservedGroup"),u(this,"reservedIndex"),u(this,"reservedIdleGroup"),u(this,"reservedIdleIndex")}reserve(t,e,i){if(i<=0)return ct.log(this.tag,"Cannot start a motion with MotionPriority.NONE."),!1;if(t===this.currentGroup&&e===this.currentIndex)return ct.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 ct.log(this.tag,"Motion is already reserved.",this.dump(t,e)),!1;if(1===i){if(0!==this.currentPriority)return ct.log(this.tag,"Cannot start idle motion because another motion is playing.",this.dump(t,e)),!1;if(void 0!==this.reservedIdleGroup)return ct.log(this.tag,"Cannot start idle motion because another idle motion has reserved.",this.dump(t,e)),!1;this.setReservedIdle(t,e)}else{if(i<3){if(i<=this.currentPriority)return ct.log(this.tag,"Cannot start motion because another motion is playing as an equivalent or higher priority.",this.dump(t,e)),!1;if(i<=this.reservePriority)return ct.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,i)}return!0}start(t,e,i,s){if(1===s){if(this.setReservedIdle(void 0,void 0),0!==this.currentPriority)return ct.log(this.tag,"Cannot start idle motion because another motion is playing.",this.dump(e,i)),!1}else{if(e!==this.reservedGroup||i!==this.reservedIndex)return ct.log(this.tag,"Cannot start motion because another motion has taken the place.",this.dump(e,i)),!1;this.setReserved(void 0,void 0,0)}return!!t&&(this.setCurrent(e,i,s),!0)}complete(){this.setCurrent(void 0,void 0,0)}setCurrent(t,e,i){this.currentPriority=i,this.currentGroup=t,this.currentIndex=e}setReserved(t,e,i){this.reservePriority=i,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!gt.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 Et="SoundManager",Vt=.5;i.sound.disableAutoPause=!0;class Rt{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){return h(this,null,function*(){try{const e=new Promise((e,s)=>{const r=i.Sound.from({url:t,volume:this._volume,preload:!0,loaded:()=>{r.media instanceof i.webaudio.WebAudioMedia||s(new Error(`Error: ${t} is not WebAudioMedia`)),e(r)}})});return yield e}catch(s){return ct.warn(Et,`Error occurred on "${t}"`,s),null==e||e(s),null}})}static play(t,e){t.play({singleInstance:!0,complete:()=>{null==e||e(),t.destroy()}})}static addAnalyzer(t,e){const i=t.media,s=e.createBufferSource();s.buffer=i.buffer;const r=e.createAnalyser();return r.fftSize=gt.fftSize,r.minDecibels=-90,r.maxDecibels=-10,r.smoothingTimeConstant=.85,s.connect(r),s.start(0),this.analysers.push(r),r}static analyze(t){if(!t)return parseFloat(Math.random().toFixed(1));const e=new Float32Array(t.fftSize);t.getFloatTimeDomainData(e);let i=0;for(let n=0;n<e.length;n++)i+=o(e[n],2);const s=Math.sqrt(i/e.length),r=20*Math.log10(s||o(10,-5)),a=Math.min(Math.max((r-t.minDecibels)/(t.maxDecibels-t.minDecibels),0),1);return parseFloat(a.toFixed(1))}static dispose(t){t.pause(),Ct(this.audios,t)}static destroy(){for(let t=this.contexts.length-1;t>=0;t--){const e=this.contexts[t];null==e||e.close().catch(t=>{ct.warn(Et,"Failed to close AudioContext.",t)})}for(let t=this.audios.length-1;t>=0;t--)this.dispose(this.audios[t])}}u(Rt,"audios",[]),u(Rt,"analysers",[]),u(Rt,"contexts",[]),u(Rt,"_volume",Vt);var Lt=(t=>(t.ALL="ALL",t.IDLE="IDLE",t.NONE="NONE",t))(Lt||{});class Tt extends e.EventEmitter{constructor(t){super(),u(this,"tag"),u(this,"settings"),u(this,"motionGroups",{}),u(this,"state",new It),u(this,"currentAudio"),u(this,"currentAnalyzer"),u(this,"currentContext"),u(this,"playing",!1),u(this,"destroyed",!1),u(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){if(!this.definitions)return void ct.warn(this.tag,"Motion definitions are not initialized.");for(const i of Object.keys(this.definitions))this.motionGroups[i]=[];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 i of e){const t=this.definitions[i];if(t)for(let e=0;e<t.length;e++)this.loadMotion(i,e)}}loadMotion(t,e){return h(this,null,function*(){var i,s;if(this.destroyed)return;if(!this.getMotionDefinition(t,e))return;const r=null!=(s=(i=this.motionGroups)[t])?s:i[t]=[];if(null===r[e])return void ct.warn(this.tag,`Cannot start motion at "${t}"[${e}] because it's already failed in loading.`);if(r[e])return r[e];const a=yield this._loadMotion(t,e);return this.destroyed?void 0:(r[e]=null!=a?a:null,a)})}_loadMotion(t,e){throw new Error("Not implemented.")}initializeAudio(t,e){this.currentAudio=t,Rt.volume=e,this.currentContext=t.context.audioContext,this.currentAnalyzer=Rt.addAnalyzer(this.currentAudio,this.currentContext)}speak(t){return h(this,arguments,function*(t,{volume:e=.5,expression:i,resetExpression:s=!0,onFinish:r,onError:a}={}){if(!gt.sound)return!1;let n,o;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,o=t=e.href}else o="data:audio/";const u=t;if(u)try{n=yield Rt.add(u,(t,e=this)=>{ct.error(this.tag,"Error during audio playback:",t),null==a||a(t),s&&i&&e.expressionManager&&e.expressionManager.resetExpression(),e.currentAudio=void 0}),this.initializeAudio(n,e)}catch(h){return ct.warn(this.tag,"Failed to create audio",o,h),!1}if(n){let t=!0;try{gt.motionSync&&Rt.play(n,()=>{null==r||r(),s&&i&&this.expressionManager&&this.expressionManager.resetExpression(),this.currentAudio=void 0})}catch(h){ct.warn(this.tag,"Failed to play audio",n.url,h),t=!1}if(!t)return!1}return this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),i&&this.expressionManager&&(yield this.expressionManager.setExpression(i)),this.playing=!0,!0})}startMotion(t,e){return h(this,arguments,function*(t,e,i=Ft.NORMAL,{sound:s,volume:r=.5,expression:a,resetExpression:n=!0,onFinish:o,onError:l,ignoreParamIds:u=[]}={}){if(this.destroyed)return!1;if(!this.state.reserve(t,e,i))return!1;if(this.currentAudio&&this.currentAudio.isPlaying&&i!=Ft.FORCE)return!1;const h=this.getMotionDefinition(t,e);if(!h)return!1;let d,g;this.currentAudio&&Rt.dispose(this.currentAudio);const c=s&&s.startsWith("data:");if(s&&!c){const t=document.createElement("a");t.href=s,g=s=t.href}else g=this.getSoundFile(h),g&&(g=this.settings.resolveURL(g));const m=g;if(m)try{d=yield Rt.add(m,(t,e=this)=>{ct.error(this.tag,"Error during audio playback:",t),null==l||l(t),n&&a&&e.expressionManager&&e.expressionManager.resetExpression(),e.currentAudio=void 0}),this.initializeAudio(d,r)}catch(_){ct.warn(this.tag,"Failed to create audio",g,_)}const p=yield this.loadMotion(t,e);if(d&&gt.motionSync)try{Rt.play(d,(t=this)=>{null==o||o(),n&&a&&t.expressionManager&&t.expressionManager.resetExpression(),t.currentAudio=void 0})}catch(_){ct.warn(this.tag,"Failed to play audio",d.url,_)}return this.state.start(p,t,e,i)?(this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),ct.log(this.tag,"Start motion:",this.getMotionName(h)),this.emit("motionStart",t,e,d),a&&this.expressionManager&&this.state.shouldOverrideExpression()&&(yield this.expressionManager.setExpression(a)),this.playing=!0,p&&this._startMotion(p,void 0,u),!0):(d&&(Rt.dispose(d),this.currentAudio=void 0),!1)})}startRandomMotion(t,e){return h(this,arguments,function*(t,e,{sound:i,volume:s=.5,expression:r,resetExpression:a=!0,onFinish:n,onError:o}={}){var l,u;if(this.destroyed)return!1;const h=null==(l=this.definitions)?void 0:l[t];if(null==h?void 0:h.length){const l=[],d=null!=(u=this.motionGroups[t])?u:[];for(let e=0;e<h.length;e++)null===d[e]||this.state.isActive(t,e)||l.push(e);if(l.length){const u=l[Math.floor(Math.random()*l.length)];return this.startMotion(t,u,e,{sound:i,volume:s,expression:r,resetExpression:a,onFinish:n,onError:o})}}return!1})}stopSpeaking(){this.currentAudio&&(Rt.dispose(this.currentAudio),this.currentAudio=void 0)}stopAllMotions(){this._stopAllMotions(),this.state.reset(),this.stopSpeaking()}update(t,e){var i;return this.isFinished()&&(this.playing&&(this.playing=!1,this.emit("motionFinish")),this.state.shouldOverrideExpression()&&(null==(i=this.expressionManager)||i.restoreExpression()),this.state.complete(),this.state.shouldRequestIdleMotion()&&this.startRandomMotion(this.groups.idle,Ft.IDLE)),this.updateParameters(t,e)}mouthSync(){return this.currentAnalyzer?Rt.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,i){return h(this,null,function*(){if(this.destroyed)return null;if(!this.state.reserve(t,e,Ft.FORCE))return null;const s=this.getMotionDefinition(t,e);if(!s)return null;this.currentAudio&&Rt.dispose(this.currentAudio);const r=yield this.loadMotion(t,e);return this.state.start(r,t,e,Ft.FORCE)?(this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),ct.log(this.tag,"Start motion:",this.getMotionName(s)),this.emit("motionStart",t,e,void 0),i&&this.expressionManager&&this.state.shouldOverrideExpression()&&(yield this.expressionManager.setExpression(i)),r):null})}getMotionDefinition(t,e){var i,s;const r=null==(s=null==(i=this.definitions)?void 0:i[t])?void 0:s[e];return r||ct.warn(this.tag,`Undefined motion at "${t}"[${e}]`),r}}function At(t,e){if(!Array.isArray(t))return[];const i=[];for(const s of t){if(!s||"object"!=typeof s)continue;const t=s,r="string"==typeof t.id?t.id:"string"==typeof t.Id?t.Id:void 0,a="string"==typeof t.name?t.name:"string"==typeof t.Name?t.Name:void 0;r&&a&&i.push({id:r,name:a,index:e(r)})}return i}const Dt={x:0,y:0,width:0,height:0};class Ot extends e.EventEmitter{constructor(){super(...arguments),u(this,"focusController",new Bt),u(this,"pose"),u(this,"physics"),u(this,"originalWidth",0),u(this,"originalHeight",0),u(this,"width",0),u(this,"height",0),u(this,"localTransform",new e.Matrix),u(this,"drawingMatrix",new e.Matrix),u(this,"hitAreas",{}),u(this,"textureFlipY",!1),u(this,"viewport",[0,0,0,0]),u(this,"destroyed",!1)}init(){this.setupLayout(),this.setupHitAreas()}setupLayout(){const t=this,e=this.getSize();t.originalWidth=e[0],t.originalHeight=e[1];const i=Object.assign({width:2,height:2},this.getLayout());this.localTransform.scale(i.width/2,i.height/2),t.width=this.originalWidth*this.localTransform.a,t.height=this.originalHeight*this.localTransform.d;const s=void 0!==i.x&&i.x-i.width/2||void 0!==i.centerX&&i.centerX||void 0!==i.left&&i.left-i.width/2||void 0!==i.right&&i.right+i.width/2||0,r=void 0!==i.y&&i.y-i.height/2||void 0!==i.centerY&&i.centerY||void 0!==i.top&&i.top-i.height/2||void 0!==i.bottom&&i.bottom+i.height/2||0;this.localTransform.translate(this.width*s,-this.height*r)}setupHitAreas(){const t=this.getHitAreaDefs();this.hitAreas={};for(const e of t)e.name&&(this.hitAreas[e.name]=e)}hitTest(t,e){return Object.keys(this.hitAreas).filter(i=>this.isHit(i,t,e))}isHit(t,e,i){const s=this.hitAreas[t];if(!s)return!1;let r=s.index;if(r<0){if(!s.id)return!1;if(r=this.getDrawableIndex(s.id),r<0)return!1;s.index=r}const a=this.getDrawableBounds(r,Dt);return a.x<=e&&e<=a.x+a.width&&a.y<=i&&i<=a.y+a.height}getDrawableBounds(t,e){const i=this.getDrawableVertices(t);let s=i[0],r=i[0],a=i[1],n=i[1];for(let o=0;o<i.length;o+=2){const t=i[o],e=i[o+1];s=Math.min(t,s),r=Math.max(t,r),a=Math.min(e,a),n=Math.max(e,n)}return null!=e||(e={}),e.x=s,e.y=a,e.width=r-s,e.height=n-a,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 i=this.motionManager.update(t,e),s=this.parallelMotionManager.map(i=>i.update(t,e)),r=i||s.reduce((t,e)=>t||e,!1);return this.emit("afterMotionUpdate"),r}}class kt extends Error{constructor(t,e,i,s=!1){super(t),this.url=e,this.status=i,this.aborted=s}}const Nt=class t{static createXHR(e,i,s,r,a){const n=new XMLHttpRequest;if(t.allXhrSet.add(n),e){let i=t.xhrMap.get(e);i?i.add(n):(i=new Set([n]),t.xhrMap.set(e,i))}return n.open("GET",i),n.responseType=s,n.onload=()=>{var t;200!==n.status&&0!==n.status||!n.response?null==(t=n.onerror)||t.call(n,new ProgressEvent("error")):r(n.response)},n.onerror=()=>{ct.warn("XHRLoader",`Failed to load resource as ${n.responseType} (Status ${n.status}): ${i}`),a(new kt("Network error.",i,n.status))},n.onabort=()=>a(new kt("Aborted.",i,n.status,!0)),n.onloadend=()=>{var i;t.allXhrSet.delete(n),e&&(null==(i=t.xhrMap.get(e))||i.delete(n))},n}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}};u(Nt,"xhrMap",new WeakMap),u(Nt,"allXhrSet",new Set),u(Nt,"loader",t=>new Promise((e,i)=>{const s=t.target,r=t.target&&"function"==typeof Nt.cancelXHRs?Nt.cancelXHRs.bind(t.target):void 0,a=Nt.createXHR(t.target,t.settings?t.settings.resolveURL(t.url):t.url,t.type,i=>{t.result=i,e()},i);if(t.target&&r&&"function"==typeof s.listeners&&"function"==typeof s.once){const t=s.listeners("destroy");Array.isArray(t)&&t.includes(r)||s.once("destroy",r)}a.send()}));let Ut=Nt;function zt(t,e){let i=-1;return function s(r,a){if(a)return Promise.reject(a);if(r<=i)return Promise.reject(new Error("next() called multiple times"));i=r;const n=t[r];if(!n)return Promise.resolve();try{return Promise.resolve(n(e,s.bind(null,r+1)))}catch(o){const t=o instanceof Error?o:new Error(String(o));return Promise.reject(t)}}(0)}class jt{static load(t){return h(this,null,function*(){return yield zt(this.middlewares,t),t.result})}}u(jt,"middlewares",[Ut.loader]);class Gt extends wt{constructor(t){if(super(t),u(this,"moc"),u(this,"textures"),u(this,"layout"),u(this,"hitAreas"),u(this,"initParams"),u(this,"initOpacities"),u(this,"expressions"),u(this,"motions",{}),!Gt.isValidJSON(t))throw new TypeError("Invalid JSON.");this.moc=t.model,ft("string",t,this,"textures","textures"),this.copy(t)}static isValidJSON(t){if(!t||"object"!=typeof t)return!1;const e=!!Array.isArray(t.textures)&&t.textures.every(t=>"string"==typeof t);return"string"==typeof t.model&&e}copy(t){_t("string",t,this,"name","name"),_t("string",t,this,"pose","pose"),_t("string",t,this,"physics","physics"),_t("object",t,this,"layout","layout"),_t("object",t,this,"motions","motions"),ft("object",t,this,"hit_areas","hitAreas"),ft("object",t,this,"expressions","expressions"),ft("object",t,this,"init_params","initParams"),ft("object",t,this,"init_opacities","initOpacities");const e=this.getFileStem(this.moc);this.setModelName(this.name,e)}replaceFiles(t){super.replaceFiles(t);for(const[e,i]of Object.entries(this.motions))for(let s=0;s<i.length;s++)i[s].file=t(i[s].file,`motions.${e}[${s}].file`),void 0!==i[s].sound&&(i[s].sound=t(i[s].sound,`motions.${e}[${s}].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`)}}function Xt(){}const Ht="Live2DFactory",qt=(t,e)=>h(null,null,function*(){if("string"==typeof t.source){const e=yield jt.load({url:t.source,type:"json",target:t.live2dModel});e.url="string"==typeof e.url?e.url:t.source,t.source=e,t.live2dModel.emit("settingsJSONLoaded",e)}return e()}),Wt=(t,e)=>h(null,null,function*(){if(t.source instanceof wt)return t.settings=t.source,e();if("object"==typeof t.source){const i=se.findRuntime(t.source);if(i){const s=i.createModelSettings(t.source);return t.settings=s,t.live2dModel.emit("settingsLoaded",s),e()}}throw new TypeError("Unknown settings format.")}),Yt=(t,e)=>{if(t.settings){const i=se.findRuntime(t.settings);if(i)return i.ready().then(()=>e())}return e()},Jt=(t,e)=>h(null,null,function*(){yield e();const i=t.internalModel;if(i){const e=t.settings,s=se.findRuntime(e);if(s){const r=[],a=e instanceof Gt?"json":"arraybuffer";e.pose&&r.push(jt.load({settings:e,url:e.pose,type:a,target:i}).then(e=>{i.pose=s.createPose(i.coreModel,e),t.live2dModel.emit("poseLoaded",i.pose)}).catch(e=>{t.live2dModel.emit("poseLoadError",e),ct.warn(Ht,"Failed to load pose.",e)})),e.physics&&r.push(jt.load({settings:e,url:e.physics,type:a,target:i}).then(e=>{i.physics=s.createPhysics(i.coreModel,e),t.live2dModel.emit("physicsLoaded",i.physics)}).catch(e=>{t.live2dModel.emit("physicsLoadError",e),ct.warn(Ht,"Failed to load physics.",e)})),r.length&&(yield Promise.all(r))}}}),$t=(t,i)=>h(null,null,function*(){if(!t.settings)throw new TypeError("Missing settings.");{const s=t.live2dModel,r={crossOrigin:t.options.crossOrigin};t.settings instanceof Gt&&(r.preferCreateImageBitmap=!1);const a=Promise.all(t.settings.textures.map(i=>function(t,i={}){const s=e.loadTextures.config,r=null==s?void 0:s.crossOrigin,a=null==s?void 0:s.preferCreateImageBitmap,n=null==s?void 0:s.preferWorkers;return void 0!==i.crossOrigin&&s&&(s.crossOrigin=i.crossOrigin),!1===i.preferCreateImageBitmap&&s&&(s.preferCreateImageBitmap=!1,s.preferWorkers=!1),e.Assets.load(t).catch(t=>{if(t instanceof Error)throw t;throw new Error("Texture loading error",{cause:t})}).finally(()=>{s&&(s.crossOrigin=null!=r?r:s.crossOrigin,!1===i.preferCreateImageBitmap&&(s.preferCreateImageBitmap=null!=a?a:s.preferCreateImageBitmap,s.preferWorkers=null!=n?n:s.preferWorkers))})}(t.settings.resolveURL(i),r)));if(a.catch(Xt),yield i(),!t.internalModel)throw new TypeError("Missing internal model.");s.internalModel=t.internalModel,s.emit("modelLoaded",t.internalModel),s.textures=yield a,s.emit("textureLoaded",s.textures)}}),Zt=(t,e)=>h(null,null,function*(){const i=t.settings;if(i instanceof wt){const s=se.findRuntime(i);if(!s)throw new TypeError("Unknown model settings.");const r=yield jt.load({settings:i,url:i.moc,type:"arraybuffer",target:t.live2dModel});if(!s.isValidMoc(r))throw new Error("Invalid moc data");const a=s.createCoreModel(r);return t.internalModel=s.createInternalModel(a,i,t.options),e()}throw new TypeError("Missing settings.")}),Kt=class t{static unzip(e,i){return h(this,null,function*(){const s=yield t.getFilePaths(e),r=[];for(const t of i.getDefinedFiles()){const e=decodeURI(Mt(i.url,t));s.includes(e)&&r.push(e)}const a=yield t.getFiles(e,r);for(let t=0;t<a.length;t++){const e=r[t],i=a[t];Object.defineProperty(i,"webkitRelativePath",{value:e})}return a})}static createSettings(e){return h(this,null,function*(){const i=(yield t.getFilePaths(e)).find(t=>t.endsWith("model.json")||t.endsWith("model3.json"));if(!i)throw new Error("Settings file not found");const s=yield t.readText(e,i);if(!s)throw new Error("Empty settings file: "+i);const r=JSON.parse(s);r.url=i;const a=t.live2dFactory.findRuntime(r);if(!a)throw new Error("Unknown settings JSON");return a.createModelSettings(r)})}static zipReader(t,e){return Promise.reject(new Error("Not implemented"))}static getFilePaths(t){return Promise.reject(new Error("Not implemented"))}static getFiles(t,e){return Promise.reject(new Error("Not implemented"))}static readText(t,e){return Promise.reject(new Error("Not implemented"))}static releaseReader(t){}};u(Kt,"live2dFactory"),u(Kt,"ZIP_PROTOCOL","zip://"),u(Kt,"uid",0),u(Kt,"factory",(t,e)=>h(null,null,function*(){const i=t.source;let s,r,a;if("string"==typeof i&&(i.endsWith(".zip")||i.startsWith(Kt.ZIP_PROTOCOL))?(s=i.startsWith(Kt.ZIP_PROTOCOL)?i.slice(Kt.ZIP_PROTOCOL.length):i,r=yield jt.load({url:s,type:"blob",target:t.live2dModel})):Array.isArray(i)&&1===i.length&&i[0]instanceof File&&i[0].name.endsWith(".zip")&&(r=i[0],s=URL.createObjectURL(r),a=i.settings),r){if(!r.size)throw new Error("Empty zip file");const e=yield Kt.zipReader(r,s);a||(a=yield Kt.createSettings(e)),a._objectURL=Kt.ZIP_PROTOCOL+Kt.uid+"/"+a.url;const i=yield Kt.unzip(e,a);i.settings=a,t.source=i,s.startsWith("blob:")&&t.live2dModel.once("modelLoaded",t=>{t.once("destroy",function(){URL.revokeObjectURL(s)})}),Kt.releaseReader(e)}return e()}));let Qt=Kt;const te=class t{static resolveURL(e,i){var s;const r=null==(s=t.filesMap[e])?void 0:s[i];if(void 0===r)throw new Error("Cannot find this file from uploaded files: "+i);return r}static upload(e,i){const s={};for(const t of i.getDefinedFiles()){const r=decodeURI(Mt(i.url,t)),a=e.find(t=>t.webkitRelativePath===r);a&&(s[t]=URL.createObjectURL(a))}t.filesMap[i._objectURL]=s}static createSettings(e){return h(this,null,function*(){const i=e.find(t=>t.name.endsWith("model.json")||t.name.endsWith("model3.json"));if(!i)throw new TypeError("Settings file not found");const s=yield t.readText(i),r=JSON.parse(s);r.url=i.webkitRelativePath;const a=se.findRuntime(r);if(!a)throw new Error("Unknown settings JSON");const n=a.createModelSettings(r);return n._objectURL=URL.createObjectURL(i),n})}static readText(t){return h(this,null,function*(){return new Promise((e,i)=>{const s=new FileReader;s.onload=()=>e(s.result),s.onerror=i,s.readAsText(t,"utf8")})})}};u(te,"live2dFactory"),u(te,"filesMap",{}),u(te,"factory",(t,e)=>h(null,null,function*(){if(Array.isArray(t.source)&&t.source[0]instanceof File){const e=t.source;let i=e.settings;if(i){if(!i._objectURL)throw new Error('"_objectURL" must be specified in ModelSettings')}else i=yield te.createSettings(e);i.validateFiles(e.map(t=>encodeURI(t.webkitRelativePath))),te.upload(e,i),i.resolveURL=function(t){return te.resolveURL(this._objectURL,t)},t.source=i,t.live2dModel.once("modelLoaded",t=>{t.once("destroy",function(){const t=this.settings._objectURL;if(URL.revokeObjectURL(t),te.filesMap[t])for(const e of Object.values(te.filesMap[t]))URL.revokeObjectURL(e);delete te.filesMap[t]})})}return e()}));let ee=te;const ie=class t{static registerRuntime(e){t.runtimes.push(e),t.runtimes.sort((t,e)=>e.version-t.version)}static findRuntime(e){for(const i of t.runtimes)if(i.test(e))return i}static setupLive2DModel(e,i,s){return h(this,null,function*(){const r=new Promise(t=>e.once("textureLoaded",t)),a=new Promise(t=>e.once("modelLoaded",t)),n=Promise.all([r,a]).then(()=>e.emit("ready"));yield zt(t.live2DModelMiddlewares,{live2dModel:e,source:i,options:s||{}}),yield n,e.emit("load")})}static loadMotion(e,i,s){var r;const a=t=>e.emit("motionLoadError",i,s,t);try{const n=null==(r=e.definitions[i])?void 0:r[s];if(!n)return Promise.resolve(void 0);e.once("destroy",()=>t.releaseMotionTasks(e));let o=t.motionTasksMap.get(e);o||(o={},t.motionTasksMap.set(e,o));let l=o[i];l||(l=[],o[i]=l);const u=e.getMotionFile(n);return null!=l[s]||(l[s]=jt.load({url:u,settings:e.settings,type:e.motionDataType,target:e}).then(r=>{var a;const o=null==(a=t.motionTasksMap.get(e))?void 0:a[i];o&&(o[s]=void 0);const l=r,u=e.createMotion(l,i,n);return e.emit("motionLoaded",i,s,u),u}).catch(t=>{ct.warn(e.tag,`Failed to load motion: ${u}\n`,t),a(t)})),l[s]}catch(n){ct.warn(e.tag,`Failed to load motion at "${i}"[${s}]\n`,n),a(n)}return Promise.resolve(void 0)}static loadExpression(e,i){var s;const r=t=>e.emit("expressionLoadError",i,t);try{const a=e.definitions[i];if(!a)return Promise.resolve(void 0);e.once("destroy",()=>t.releaseExpressionTasks(e));let n=t.expressionTasksMap.get(e);n||(n=[],t.expressionTasksMap.set(e,n));const o=e.getExpressionFile(a),l=null!=(s=e.expressionDataType)?s:"json";return null!=n[i]||(n[i]=jt.load({url:o,settings:e.settings,type:l,target:e}).then(s=>{const r=t.expressionTasksMap.get(e);r&&(r[i]=void 0);const n=s,o=e.createExpression(n,a);return e.emit("expressionLoaded",i,o),o}).catch(t=>{ct.warn(e.tag,`Failed to load expression: ${o}\n`,t),r(t)})),n[i]}catch(a){ct.warn(e.tag,`Failed to load expression at [${i}]\n`,a),r(a)}return Promise.resolve(void 0)}static releaseMotionTasks(e){t.motionTasksMap.delete(e)}static releaseExpressionTasks(e){t.expressionTasksMap.delete(e)}};u(ie,"runtimes",[]),u(ie,"urlToJSON",qt),u(ie,"jsonToSettings",Wt),u(ie,"waitUntilReady",Yt),u(ie,"setupOptionals",Jt),u(ie,"setupEssentials",$t),u(ie,"createInternalModel",Zt),u(ie,"live2DModelMiddlewares",[Qt.factory,ee.factory,qt,Wt,Yt,Jt,$t,Zt]),u(ie,"motionTasksMap",new WeakMap),u(ie,"expressionTasksMap",new WeakMap);let se=ie;Tt.prototype._loadMotion=function(t,e){return se.loadMotion(this,t,e)},vt.prototype._loadExpression=function(t){return se.loadExpression(this,t)},ee.live2dFactory=se,Qt.live2dFactory=se;const re=class t{constructor(i,{autoUpdate:s=!0,autoHitTest:r=!0,autoFocus:a=!0,autoInteract:n,ticker:o}={}){var l;u(this,"model"),u(this,"destroyed",!1),u(this,"_ticker"),u(this,"_autoUpdate",!1),u(this,"_autoHitTest",!1),u(this,"_autoFocus",!1),null!=o||(o=null!=(l=t.defaultTicker)?l:"undefined"!=typeof PIXI?PIXI.Ticker.shared:e.Ticker.shared),void 0!==n&&(r=n,a=n,ct.warn(i.tag,"options.autoInteract is deprecated since v0.5.0, use autoHitTest and autoFocus instead.")),this.model=i,this.ticker=o,this.autoUpdate=s,this.autoHitTest=r,this.autoFocus=a,(r||a)&&(this.model.eventMode="static")}get ticker(){return this._ticker}set ticker(t){var e,i;this._ticker&&this._ticker.remove(ne,this),this._ticker=t,this._autoUpdate&&(null==(e=this._ticker)||e.add(ne,this),null==(i=this._ticker)||i.start())}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){var e;this.destroyed||(t?this._ticker?(this._ticker.add(ne,this),this._autoUpdate=!0):ct.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(ne,this),this._autoUpdate=!1))}get autoHitTest(){return this._autoHitTest}set autoHitTest(t){t!==this.autoHitTest&&(t?this.model.on("pointertap",oe,this):this.model.off("pointertap",oe,this),this._autoHitTest=t)}get autoFocus(){return this._autoFocus}set autoFocus(t){t!==this.autoFocus&&(t?(this.model.on("globalpointermove",le,this),this.model.on("pointermove",le,this)):(this.model.off("globalpointermove",le,this),this.model.off("pointermove",le,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}};u(re,"defaultTicker");let ae=re;function ne(){this.onTickerUpdate()}function oe(t){this.onTap(t)}function le(t){this.onPointerMove(t)}class ue extends e.Transform{}const he=new e.Point,de=new e.Matrix,ge=new e.Matrix,ce={x:0,y:0,width:0,height:0},me=new e.Bounds;class pe{constructor(t){this.renderer=t}execute(t){!t.visible||t.alpha<=0||t.renderLive2D(this.renderer)}updateRenderable(){}destroy(){}}class _e extends e.Container{constructor(t){super(),u(this,"renderPipeId","live2d"),u(this,"tag","Live2DModel(uninitialized)"),u(this,"internalModel"),u(this,"textures",[]),u(this,"transform",new ue),u(this,"anchor"),u(this,"_bounds",new e.Bounds),u(this,"_boundsDirty",!0),u(this,"_boundsRetryAfterDraw",!1),u(this,"gl",null),u(this,"elapsedTime",0),u(this,"deltaTime",0),u(this,"automator"),u(this,"currentGlId",0),u(this,"renderLive2D",t=>{var i,s,r,a,n;if(!(t instanceof e.WebGLRenderer))throw new Error("Renderer is not supported");t.geometry.resetState(),t.shader.resetState(),t.texture.resetState();let o=!1;this.gl!==t.gl&&(this.gl=t.gl,this.internalModel.updateWebGLContext(t.gl,this.generateUID()),o=!0);for(let e=0;e<this.textures.length;e++){const i=this.textures[e],s=Boolean(i.source._gpuData[t.uid]);!o&&s||(t.gl.pixelStorei(WebGLRenderingContext.UNPACK_FLIP_Y_WEBGL,this.internalModel.textureFlipY),t.texture.bind(i,0)),this.internalModel.bindTexture(e,t.texture.getGlSource(i.source).texture)}const l=t.renderTarget.viewport,u=t.renderTarget.renderTarget;let h=l.y;if(null==u?void 0:u.isRoot){h=u.colorTexture.source.pixelHeight-l.height-l.y}this.internalModel.viewport=[l.x,h,l.width,l.height];const d=this.deltaTime;this.deltaTime=0,d&&this.internalModel.update(d,this.elapsedTime);const{projectionMatrix:g,offset:c}=t.globalUniforms.globalUniformData,m=ge.copyFrom(this.worldTransform);m.tx-=null!=(i=null==c?void 0:c.x)?i:0,m.ty-=null!=(s=null==c?void 0:c.y)?s:0;const p=de.copyFrom(g).append(m);this.internalModel.updateTransform(p),this.internalModel.draw(t.gl),this._boundsRetryAfterDraw&&this.updateDrawableBounds(),t.state.resetState(),t.texture.resetState();const _=null==(r=t.renderTarget)?void 0:r.defaultClearColor,f=null==(n=null==(a=t.renderTarget)?void 0:a.adaptor)?void 0:n._clearColorCache;_&&(t.gl.clearColor(_[0],_[1],_[2],_[3]),f&&(f[0]=_[0],f[1]=_[1],f[2]=_[2],f[3]=_[3]))}),this.anchor=new e.ObservablePoint({_onUpdate:()=>this.onAnchorChange()},0,0),this.automator=new ae(this,t),this.once("modelLoaded",()=>this.initializeOnModelLoad(t))}get isRenderable(){return!0}get canBundle(){return!1}static from(t,e){return h(this,null,function*(){const i=new this(e);return yield se.setupLive2DModel(i,t,e),i})}static fromSync(t,e){const i=new this(e);return se.setupLive2DModel(i,t,e).then(()=>{var t;return null==(t=null==e?void 0:e.onLoad)?void 0:t.call(e)}).catch(t=>{var i;return null==(i=null==e?void 0:e.onError)?void 0:i.call(e,t)}),i}static registerTicker(t){ae.defaultTicker=t.shared}get bounds(){return this.internalModel?(this._boundsDirty&&this.updateDrawableBounds(),this._bounds):(this._bounds.set(0,0,0,0),this._bounds)}updateDrawableBounds(){if(!this.internalModel)return this._bounds.set(0,0,0,0),void(this._boundsDirty=!1);const t=this.internalModel.getDrawableIDs();me.clear();for(let i=0;i<t.length;i++){const s=t[i],r=this.internalModel.getDrawableIndex(s);if(r<0)continue;const a=this.internalModel.getDrawableBounds(r,ce);Number.isFinite(a.x)&&Number.isFinite(a.y)&&Number.isFinite(a.width)&&Number.isFinite(a.height)&&me.addFrame(a.x,a.y,a.x+a.width,a.y+a.height,e.Matrix.IDENTITY)}if(this._bounds.clear(),me.isValid&&me.isPositive)this._bounds.addFrame(me.minX,me.minY,me.maxX,me.maxY,this.internalModel.localTransform),this._boundsRetryAfterDraw=!1;else{const t=this.internalModel.originalWidth||this.internalModel.width,e=this.internalModel.originalHeight||this.internalModel.height;this._bounds.addFrame(0,0,t,e,this.internalModel.localTransform),this._boundsRetryAfterDraw=!0}this._boundsDirty=!1}generateUID(){return++this.currentGlId}collectRenderables(t,e,i){var s,r,a,n;if(this.parentRenderLayer&&this.parentRenderLayer!==i)return;if(this.globalDisplayStatus<7)return;if(!this.includeInBuild)return;this.sortableChildren&&this.sortChildren(),function(t){const e=t;e.renderPipes.live2d||(e.renderPipes.live2d=new pe(t))}(e);const o=e.renderPipes,l=()=>{var e,i;null==(i=null==(e=o.batch)?void 0:e.break)||i.call(e,t),t.add(this)},u=()=>{const s=this.children,r=s.length;for(let a=0;a<r;a++)s[a].collectRenderables(t,e,i)},h=this.effects;if(h){for(let e=0;e<h.length;e++){const i=h[e],a=i.filters;if(a)for(const t of a)t&&"number"==typeof t.resolution&&1===t.resolution&&(t.resolution="inherit");null==(r=null==(s=o[i.pipe])?void 0:s.push)||r.call(s,i,this,t)}l(),u();for(let e=h.length-1;e>=0;e--){const i=h[e];null==(n=null==(a=o[i.pipe])?void 0:a.pop)||n.call(a,i,this,t)}}else l(),u()}initializeOnModelLoad(t){this.tag=`Live2DModel(${this.internalModel.settings.name})`,this.onAnchorChange(),this.updateDrawableBounds()}onAnchorChange(){this.internalModel&&this.pivot&&this.pivot.set(this.anchor.x*this.internalModel.width,this.anchor.y*this.internalModel.height)}motion(t,e,i){return h(this,arguments,function*(t,e,i,{sound:s,volume:r=.5,expression:a,resetExpression:n=!0,onFinish:o,onError:l}={}){return void 0===e?this.internalModel.motionManager.startRandomMotion(t,i,{sound:s,volume:r,expression:a,resetExpression:n,onFinish:o,onError:l}):this.internalModel.motionManager.startMotion(t,e,i,{sound:s,volume:r,expression:a,resetExpression:n,onFinish:o,onError:l})})}motionLastFrame(t,e){return h(this,arguments,function*(t,e,{expression:i}={}){return this.internalModel.motionManager.motionLastFrame(t,e,{expression:i})})}parallelMotion(t){return h(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)),i=[];for(const t of e)i.push(yield t);return i})}parallelLastFrame(t){return h(this,null,function*(){this.internalModel.extendParallelMotionManager(t.length);const e=t.map((t,e)=>this.internalModel.parallelMotionManager[e].playMotionLastFrame(t.group,t.index)),i=[];for(const t of e)i.push(yield t);return i})}stopMotions(){return this.internalModel.motionManager.stopAllMotions()}speak(t,{volume:e=.5,expression:i,resetExpression:s=!0,onFinish:r,onError:a}={}){return this.internalModel.motionManager.speak(t,{volume:e,expression:i,resetExpression:s,onFinish:r,onError:a})}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,i=!1){he.x=t,he.y=e,this.toModelPosition(he,he,!0);const s=he.x/this.internalModel.originalWidth*2-1,r=he.y/this.internalModel.originalHeight*2-1,a=Math.atan2(r,s);this.internalModel.focusController.focus(Math.cos(a),-Math.sin(a),i)}tap(t,e){const i=this.hitTest(t,e);i.length&&this.emit("hit",i)}hitTest(t,e){return he.x=t,he.y=e,this.toModelPosition(he,he),this.internalModel.hitTest(he.x,he.y)}toModelPosition(t,e=t.clone(),i){return i||this.updateLocalTransform(),this.toLocal(t,void 0,e,i),this.internalModel.localTransform.applyInverse(e,e),e}containsPoint(t){return this.bounds.containsPoint(t.x,t.y)}_calculateBounds(){if(!this.internalModel)return void this.getBounds().set(0,0,0,0);const t=this.internalModel.width,e=this.internalModel.height;this.getBounds().addFrame(0,0,t,e,this.transform.matrix)}update(t){this.deltaTime+=t,this.elapsedTime+=t}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("undefined"==typeof window||void 0===window.Live2DCubismCore)throw new Error("Could not find Cubism runtime. This plugin requires live2dcubismcore.js to be loaded.");class fe{constructor(t,e){this.x=t,this.y=e,this.x=null==t?0:t,this.y=null==e?0:e}add(t){const e=new fe(0,0);return e.x=this.x+t.x,e.y=this.y+t.y,e}substract(t){const e=new fe(0,0);return e.x=this.x-t.x,e.y=this.y-t.y,e}multiply(t){const e=new fe(0,0);return e.x=this.x*t.x,e.y=this.y*t.y,e}multiplyByScaler(t){return this.multiply(new fe(t,t))}division(t){const e=new fe(0,0);return e.x=this.x/t.x,e.y=this.y/t.y,e}divisionByScalar(t){return this.division(new fe(t,t))}getLength(){return Math.sqrt(this.x*this.x+this.y*this.y)}getDistanceWith(t){return Math.sqrt((this.x-t.x)*(this.x-t.x)+(this.y-t.y)*(this.y-t.y))}dot(t){return this.x*t.x+this.y*t.y}normalize(){const t=Math.pow(this.x*this.x+this.y*this.y,.5);this.x=this.x/t,this.y=this.y/t}isEqual(t){return this.x==t.x&&this.y==t.y}isNotEqual(t){return!this.isEqual(t)}}var ye;(t=>{t.CubismVector2=fe})(ye||(ye={}));const xe=class t{static range(t,e,i){return t<e?t=e:t>i&&(t=i),t}static sin(t){return Math.sin(t)}static cos(t){return Math.cos(t)}static abs(t){return Math.abs(t)}static sqrt(t){return Math.sqrt(t)}static cbrt(t){if(0===t)return t;let e=t;const i=e<0;let s;return i&&(e=-e),e===1/0?s=1/0:(s=Math.exp(Math.log(e)/3),s=(e/(s*s)+2*s)/3),i?-s:s}static getEasingSine(t){return t<0?0:t>1?1:.5-.5*this.cos(t*Math.PI)}static max(t,e){return t>e?t:e}static min(t,e){return t>e?e:t}static clamp(t,e,i){return t<e?e:i<t?i:t}static degreesToRadian(t){return t/180*Math.PI}static radianToDegrees(t){return 180*t/Math.PI}static directionToRadian(t,e){let i=Math.atan2(e.y,e.x)-Math.atan2(t.y,t.x);for(;i<-Math.PI;)i+=2*Math.PI;for(;i>Math.PI;)i-=2*Math.PI;return i}static directionToDegrees(t,e){const i=this.directionToRadian(t,e);let s=this.radianToDegrees(i);return e.x-t.x>0&&(s=-s),s}static radianToDirection(t){const e=new fe;return e.x=this.sin(t),e.y=this.cos(t),e}static quadraticEquation(e,i,s){return this.abs(e)<t.Epsilon?this.abs(i)<t.Epsilon?-s:-s/i:-(i+this.sqrt(i*i-4*e*s))/(2*e)}static cardanoAlgorithmForBezier(e,i,s,r){if(this.abs(e)<t.Epsilon)return this.range(this.quadraticEquation(i,s,r),0,1);const a=i/e,n=s/e,o=(3*n-a*a)/3,l=o/3,u=(2*a*a*a-9*a*n+27*(r/e))/27,h=u/2,d=h*h+l*l*l,g=.5,c=.51;if(d<0){const t=-o/3,e=t*t*t,i=this.sqrt(e),s=-u/(2*i),r=this.range(s,-1,1),n=Math.acos(r),l=2*this.cbrt(i),h=l*this.cos(n/3)-a/3;if(this.abs(h-g)<c)return this.range(h,0,1);const d=l*this.cos((n+2*Math.PI)/3)-a/3;if(this.abs(d-g)<c)return this.range(d,0,1);const m=l*this.cos((n+4*Math.PI)/3)-a/3;return this.range(m,0,1)}if(0==d){let t;t=h<0?this.cbrt(-h):-this.cbrt(h);const e=2*t-a/3;if(this.abs(e-g)<c)return this.range(e,0,1);const i=-t-a/3;return this.range(i,0,1)}const m=this.sqrt(d),p=this.cbrt(m-h)-this.cbrt(m+h)-a/3;return this.range(p,0,1)}static mod(t,e){if(!isFinite(t)||0===e||isNaN(t)||isNaN(e))return console.warn(`divided: ${t}, divisor: ${e} mod() returns 'NaN'.`),NaN;const i=Math.abs(t),s=Math.abs(e);let r=i-Math.floor(i/s)*s;return r*=Math.sign(t),r}constructor(){}};xe.Epsilon=1e-5;let Ce=xe;var Se,Me;(t=>{t.CubismMath=Ce})(Se||(Se={}));class ve{constructor(){this.setBeganMotionHandler=t=>this._onBeganMotion=t,this.getBeganMotionHandler=()=>this._onBeganMotion,this.setFinishedMotionHandler=t=>this._onFinishedMotion=t,this.getFinishedMotionHandler=()=>this._onFinishedMotion,this._fadeInSeconds=-1,this._fadeOutSeconds=-1,this._weight=1,this._offsetSeconds=0,this._isLoop=!1,this._isLoopFadeIn=!0,this._previousLoopState=this._isLoop,this._firedEventValues=new g}static delete(t){t.release(),t=null}release(){this._weight=0}updateParameters(t,e,i){if(!e.isAvailable()||e.isFinished())return;this.setupMotionQueueEntry(e,i);const s=this.updateFadeWeight(e,i);this.doUpdateParameters(t,i,s,e),e.getEndTime()>0&&e.getEndTime()<i&&e.setIsFinished(!0)}setupMotionQueueEntry(t,e){null==t||t.isStarted()||t.isAvailable()&&(t.setIsStarted(!0),t.setStartTime(e-this._offsetSeconds),t.setFadeInStartTime(e),t.getEndTime()<0&&this.adjustEndTime(t),t._motion._onBeganMotion&&t._motion._onBeganMotion(t._motion))}updateFadeWeight(t,e){null==t&&k.print(dt.LogLevel_Error,"motionQueueEntry is null.");let i=this._weight;return i=i*(0==this._fadeInSeconds?1:Ce.getEasingSine((e-t.getFadeInStartTime())/this._fadeInSeconds))*(0==this._fadeOutSeconds||t.getEndTime()<0?1:Ce.getEasingSine((t.getEndTime()-e)/this._fadeOutSeconds)),t.setState(e,i),L(0<=i&&i<=1),i}setFadeInTime(t){this._fadeInSeconds=t}setFadeOutTime(t){this._fadeOutSeconds=t}getFadeOutTime(){return this._fadeOutSeconds}getFadeInTime(){return this._fadeInSeconds}setWeight(t){this._weight=t}getWeight(){return this._weight}getDuration(){return-1}getLoopDuration(){return-1}setOffsetTime(t){this._offsetSeconds=t}setLoop(t){this._isLoop=t}getLoop(){return this._isLoop}setLoopFadeIn(t){this._isLoopFadeIn=t}getLoopFadeIn(){return this._isLoopFadeIn}getFiredEvent(t,e){return this._firedEventValues}isExistModelOpacity(){return!1}getModelOpacityIndex(){return-1}getModelOpacityId(t){return null}getModelOpacityValue(){return 1}adjustEndTime(t){const e=this.getDuration(),i=e<=0?-1:t.getStartTime()+e;t.setEndTime(i)}}(t=>{t.ACubismMotion=ve})(Me||(Me={}));const be="Parameters",Pe="Blend",Be=class t extends ve{static create(e,i){const s=new t;return s.parse(e,i),s}doUpdateParameters(t,e,i,s){for(let r=0;r<this._parameters.getSize();++r){const e=this._parameters.at(r);switch(e.blendType){case 0:t.addParameterValueById(e.parameterId,e.value,i);break;case 1:t.multiplyParameterValueById(e.parameterId,e.value,i);break;case 2:t.setParameterValueById(e.parameterId,e.value,i)}}}calculateExpressionParameters(e,i,s,r,a,n){if(null!=s&&null!=r&&s.isAvailable()){this._fadeWeight=this.updateFadeWeight(s,i);for(let i=0;i<r.getSize();++i){const s=r.at(i);if(null==s.parameterId)continue;const o=s.overwriteValue=e.getParameterValueById(s.parameterId),l=this.getExpressionParameters();let u=-1;for(let t=0;t<l.getSize();++t)if(s.parameterId==l.at(t).parameterId){u=t;break}if(u<0){0==a?(s.additiveValue=t.DefaultAdditiveValue,s.multiplyValue=t.DefaultMultiplyValue,s.overwriteValue=o):(s.additiveValue=this.calculateValue(s.additiveValue,t.DefaultAdditiveValue,n),s.multiplyValue=this.calculateValue(s.multiplyValue,t.DefaultMultiplyValue,n),s.overwriteValue=this.calculateValue(s.overwriteValue,o,n));continue}const h=l.at(u).value;let d,g,c;switch(l.at(u).blendType){case 0:d=h,g=t.DefaultMultiplyValue,c=o;break;case 1:d=t.DefaultAdditiveValue,g=h,c=o;break;case 2:d=t.DefaultAdditiveValue,g=t.DefaultMultiplyValue,c=h;break;default:return}0==a?(s.additiveValue=d,s.multiplyValue=g,s.overwriteValue=c):(s.additiveValue=s.additiveValue*(1-n)+d*n,s.multiplyValue=s.multiplyValue*(1-n)+g*n,s.overwriteValue=s.overwriteValue*(1-n)+c*n)}}}getExpressionParameters(){return this._parameters}getFadeWeight(){return this._fadeWeight}parse(t,e){const i=Y.create(t,e);if(!i)return;const s=i.getRoot();this.setFadeInTime(s.getValueByString("FadeInTime").toFloat(1)),this.setFadeOutTime(s.getValueByString("FadeOutTime").toFloat(1));const r=s.getValueByString(be).getSize();this._parameters.prepareCapacity(r);for(let a=0;a<r;++a){const t=s.getValueByString(be).getValueByIndex(a),e=ht.getIdManager().getId(t.getValueByString("Id").getRawString()),i=t.getValueByString("Value").toFloat();let r;r=t.getValueByString(Pe).isNull()||"Add"==t.getValueByString(Pe).getString()?0:"Multiply"==t.getValueByString(Pe).getString()?1:"Overwrite"==t.getValueByString(Pe).getString()?2:0;const n=new Ve;n.parameterId=e,n.blendType=r,n.value=i,this._parameters.pushBack(n)}Y.delete(i)}calculateValue(t,e,i){return t*(1-i)+e*i}constructor(){super(),this._parameters=new g,this._fadeWeight=0}};Be.DefaultAdditiveValue=0,Be.DefaultMultiplyValue=1;let we=Be;var Fe,Ie,Ee=(t=>(t[t.Additive=0]="Additive",t[t.Multiply=1]="Multiply",t[t.Overwrite=2]="Overwrite",t))(Ee||{});class Ve{}(t=>{t.CubismExpressionMotion=we,t.ExpressionBlendType=Ee,t.ExpressionParameter=Ve})(Fe||(Fe={}));class Re{constructor(){this._autoDelete=!1,this._motion=null,this._available=!0,this._finished=!1,this._started=!1,this._startTimeSeconds=-1,this._fadeInStartTimeSeconds=0,this._endTimeSeconds=-1,this._stateTimeSeconds=0,this._stateWeight=0,this._lastEventCheckSeconds=0,this._motionQueueEntryHandle=this,this._fadeOutSeconds=0,this._isTriggeredFadeOut=!1}release(){this._autoDelete&&this._motion&&ve.delete(this._motion)}setFadeOut(t){this._fadeOutSeconds=t,this._isTriggeredFadeOut=!0}startFadeOut(t,e){const i=e+t;this._isTriggeredFadeOut=!0,(this._endTimeSeconds<0||i<this._endTimeSeconds)&&(this._endTimeSeconds=i)}isFinished(){return this._finished}isStarted(){return this._started}getStartTime(){return this._startTimeSeconds}getFadeInStartTime(){return this._fadeInStartTimeSeconds}getEndTime(){return this._endTimeSeconds}setStartTime(t){this._startTimeSeconds=t}setFadeInStartTime(t){this._fadeInStartTimeSeconds=t}setEndTime(t){this._endTimeSeconds=t}setIsFinished(t){this._finished=t}setIsStarted(t){this._started=t}isAvailable(){return this._available}setIsAvailable(t){this._available=t}setState(t,e){this._stateTimeSeconds=t,this._stateWeight=e}getStateTime(){return this._stateTimeSeconds}getStateWeight(){return this._stateWeight}getLastCheckEventSeconds(){return this._lastEventCheckSeconds}setLastCheckEventSeconds(t){this._lastEventCheckSeconds=t}isTriggeredFadeOut(){return this._isTriggeredFadeOut}getFadeOutSeconds(){return this._fadeOutSeconds}getCubismMotion(){return this._motion}}(t=>{t.CubismMotionQueueEntry=Re})(Ie||(Ie={}));class Le{constructor(){this._userTimeSeconds=0,this._eventCallBack=null,this._eventCustomData=null,this._motions=new g}release(){for(let t=0;t<this._motions.getSize();++t)this._motions.at(t)&&(this._motions.at(t).release(),this._motions.set(t,null));this._motions=null}startMotion(t,e,i){if(null==t)return Te;let s=null;for(let r=0;r<this._motions.getSize();++r)s=this._motions.at(r),null!=s&&s.setFadeOut(s._motion.getFadeOutTime());return s=new Re,s._autoDelete=e,s._motion=t,this._motions.pushBack(s),s._motionQueueEntryHandle}isFinished(){for(let t=this._motions.begin();t.notEqual(this._motions.end());){let e=t.ptr();if(null==e){t=this._motions.erase(t);continue}if(null!=e._motion){if(!e.isFinished())return!1;t.preIncrement()}else e.release(),e=null,t=this._motions.erase(t)}return!0}isFinishedByHandle(t){for(let e=this._motions.begin();e.notEqual(this._motions.end());e.increment()){const i=e.ptr();if(null!=i&&(i._motionQueueEntryHandle==t&&!i.isFinished()))return!1}return!0}stopAllMotions(){for(let t=this._motions.begin();t.notEqual(this._motions.end());){let e=t.ptr();null!=e?(e.release(),e=null,t=this._motions.erase(t)):t=this._motions.erase(t)}}getCubismMotionQueueEntries(){return this._motions}getCubismMotionQueueEntry(t){for(let e=this._motions.begin();e.notEqual(this._motions.end());e.preIncrement()){const i=e.ptr();if(null!=i&&i._motionQueueEntryHandle==t)return i}return null}setEventCallback(t,e=null){this._eventCallBack=t,this._eventCustomData=e}doUpdateMotion(t,e){let i=!1;for(let s=this._motions.begin();s.notEqual(this._motions.end());){let r=s.ptr();if(null==r){s=this._motions.erase(s);continue}const a=r._motion;if(null==a){r.release(),r=null,s=this._motions.erase(s);continue}a.updateParameters(t,r,e),i=!0;const n=a.getFiredEvent(r.getLastCheckEventSeconds()-r.getStartTime(),e-r.getStartTime());for(let t=0;t<n.getSize();++t)this._eventCallBack(this,n.at(t),this._eventCustomData);r.setLastCheckEventSeconds(e),r.isFinished()?(r.release(),r=null,s=this._motions.erase(s)):(r.isTriggeredFadeOut()&&r.startFadeOut(r.getFadeOutSeconds(),e),s.preIncrement())}return i}}const Te=-1;var Ae;(t=>{t.CubismMotionQueueManager=Le,t.InvalidMotionQueueEntryHandleValue=Te})(Ae||(Ae={}));class De extends vt{constructor(t,e){var i,s;super(t,e),u(this,"expressionDataType","arraybuffer"),u(this,"queueManager",new Le),u(this,"definitions"),this.definitions=null!=(s=null==(i=t.expressions)?void 0:i.filter(t=>!!t&&"string"==typeof t.File))?s:[],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 we.create(t,t.byteLength)}_setExpression(t){return this.queueManager.startMotion(t,!1)}stopAllExpressions(){this.queueManager.stopAllMotions()}updateParameters(t,e){return this.queueManager.doUpdateMotion(t,e)}createDefaultExpression(){const t=(new TextEncoder).encode(JSON.stringify({FadeInTime:0,FadeOutTime:0,Parameters:[]})).buffer;return we.create(t,t.byteLength)}}var Oe,ke=(t=>(t[t.CubismMotionCurveTarget_Model=0]="CubismMotionCurveTarget_Model",t[t.CubismMotionCurveTarget_Parameter=1]="CubismMotionCurveTarget_Parameter",t[t.CubismMotionCurveTarget_PartOpacity=2]="CubismMotionCurveTarget_PartOpacity",t))(ke||{}),Ne=(t=>(t[t.CubismMotionSegmentType_Linear=0]="CubismMotionSegmentType_Linear",t[t.CubismMotionSegmentType_Bezier=1]="CubismMotionSegmentType_Bezier",t[t.CubismMotionSegmentType_Stepped=2]="CubismMotionSegmentType_Stepped",t[t.CubismMotionSegmentType_InverseStepped=3]="CubismMotionSegmentType_InverseStepped",t))(Ne||{});class Ue{constructor(){this.time=0,this.value=0}}class ze{constructor(){this.evaluate=null,this.basePointIndex=0,this.segmentType=0}}class je{constructor(){this.type=0,this.segmentCount=0,this.baseSegmentIndex=0,this.fadeInTime=0,this.fadeOutTime=0}}class Ge{constructor(){this.fireTime=0}}class Xe{constructor(){this.duration=0,this.loop=!1,this.curveCount=0,this.eventCount=0,this.fps=0,this.curves=new g,this.segments=new g,this.points=new g,this.events=new g}}(t=>{t.CubismMotionCurve=je,t.CubismMotionCurveTarget=ke,t.CubismMotionData=Xe,t.CubismMotionEvent=Ge,t.CubismMotionPoint=Ue,t.CubismMotionSegment=ze,t.CubismMotionSegmentType=Ne})(Oe||(Oe={}));const He="Meta",qe="Curves",We="FadeInTime",Ye="FadeOutTime",Je="Segments",$e="UserData";class Ze{constructor(t,e){this._json=Y.create(t,e)}release(){Y.delete(this._json)}getMotionDuration(){return this._json.getRoot().getValueByString(He).getValueByString("Duration").toFloat()}isMotionLoop(){return this._json.getRoot().getValueByString(He).getValueByString("Loop").toBoolean()}hasConsistency(){let t=!0;if(!this._json||!this._json.getRoot())return!1;const e=this._json.getRoot().getValueByString(qe).getVector().getSize();let i=0,s=0;for(let r=0;r<e;++r)for(let t=0;t<this.getMotionCurveSegmentCount(r);){0==t&&(s+=1,t+=2);switch(this.getMotionCurveSegment(r,t)){case Ne.CubismMotionSegmentType_Linear:s+=1,t+=3;break;case Ne.CubismMotionSegmentType_Bezier:s+=3,t+=7;break;case Ne.CubismMotionSegmentType_Stepped:case Ne.CubismMotionSegmentType_InverseStepped:s+=1,t+=3;break;default:L(0)}++i}return e!=this.getMotionCurveCount()&&(D("The number of curves does not match the metadata."),t=!1),i!=this.getMotionTotalSegmentCount()&&(D("The number of segment does not match the metadata."),t=!1),s!=this.getMotionTotalPointCount()&&(D("The number of point does not match the metadata."),t=!1),t}getEvaluationOptionFlag(t){return 0==t&&this._json.getRoot().getValueByString(He).getValueByString("AreBeziersRestricted").toBoolean()}getMotionCurveCount(){return this._json.getRoot().getValueByString(He).getValueByString("CurveCount").toInt()}getMotionFps(){return this._json.getRoot().getValueByString(He).getValueByString("Fps").toFloat()}getMotionTotalSegmentCount(){return this._json.getRoot().getValueByString(He).getValueByString("TotalSegmentCount").toInt()}getMotionTotalPointCount(){return this._json.getRoot().getValueByString(He).getValueByString("TotalPointCount").toInt()}isExistMotionFadeInTime(){return!this._json.getRoot().getValueByString(He).getValueByString(We).isNull()}isExistMotionFadeOutTime(){return!this._json.getRoot().getValueByString(He).getValueByString(Ye).isNull()}getMotionFadeInTime(){return this._json.getRoot().getValueByString(He).getValueByString(We).toFloat()}getMotionFadeOutTime(){return this._json.getRoot().getValueByString(He).getValueByString(Ye).toFloat()}getMotionCurveTarget(t){return this._json.getRoot().getValueByString(qe).getValueByIndex(t).getValueByString("Target").getRawString()}getMotionCurveId(t){return ht.getIdManager().getId(this._json.getRoot().getValueByString(qe).getValueByIndex(t).getValueByString("Id").getRawString())}isExistMotionCurveFadeInTime(t){return!this._json.getRoot().getValueByString(qe).getValueByIndex(t).getValueByString(We).isNull()}isExistMotionCurveFadeOutTime(t){return!this._json.getRoot().getValueByString(qe).getValueByIndex(t).getValueByString(Ye).isNull()}getMotionCurveFadeInTime(t){return this._json.getRoot().getValueByString(qe).getValueByIndex(t).getValueByString(We).toFloat()}getMotionCurveFadeOutTime(t){return this._json.getRoot().getValueByString(qe).getValueByIndex(t).getValueByString(Ye).toFloat()}getMotionCurveSegmentCount(t){return this._json.getRoot().getValueByString(qe).getValueByIndex(t).getValueByString(Je).getVector().getSize()}getMotionCurveSegment(t,e){return this._json.getRoot().getValueByString(qe).getValueByIndex(t).getValueByString(Je).getValueByIndex(e).toFloat()}getEventCount(){return this._json.getRoot().getValueByString(He).getValueByString("UserDataCount").toInt()}getTotalEventValueSize(){return this._json.getRoot().getValueByString(He).getValueByString("TotalUserDataSize").toInt()}getEventTime(t){return this._json.getRoot().getValueByString($e).getValueByIndex(t).getValueByString("Time").toFloat()}getEventValue(t){return new S(this._json.getRoot().getValueByString($e).getValueByIndex(t).getValueByString("Value").getRawString())}}var Ke,Qe=(t=>(t[t.EvaluationOptionFlag_AreBeziersRistricted=0]="EvaluationOptionFlag_AreBeziersRistricted",t))(Qe||{});(t=>{t.CubismMotionJson=Ze})(Ke||(Ke={}));const ti="Opacity";function ei(t,e,i){const s=new Ue;return s.time=t.time+(e.time-t.time)*i,s.value=t.value+(e.value-t.value)*i,s}function ii(t,e){let i=(e-t[0].time)/(t[1].time-t[0].time);return i<0&&(i=0),t[0].value+(t[1].value-t[0].value)*i}function si(t,e){let i=(e-t[0].time)/(t[3].time-t[0].time);i<0&&(i=0);const s=ei(t[0],t[1],i),r=ei(t[1],t[2],i),a=ei(t[2],t[3],i),n=ei(s,r,i),o=ei(r,a,i);return ei(n,o,i).value}function ri(t,e){const i=e,s=t[0].time,r=t[3].time,a=t[1].time,n=t[2].time,o=r-3*n+3*a-s,l=3*n-6*a+3*s,u=3*a-3*s,h=s-i,d=Ce.cardanoAlgorithmForBezier(o,l,u,h),g=ei(t[0],t[1],d),c=ei(t[1],t[2],d),m=ei(t[2],t[3],d),p=ei(g,c,d),_=ei(c,m,d);return ei(p,_,d).value}function ai(t,e){return t[0].value}function ni(t,e){return t[1].value}function oi(t,e,i,s,r){const a=t.curves.at(e);let n=-1;const o=a.baseSegmentIndex+a.segmentCount;let l=0;for(let h=a.baseSegmentIndex;h<o;++h)if(l=t.segments.at(h).basePointIndex+(t.segments.at(h).segmentType==Ne.CubismMotionSegmentType_Bezier?3:1),t.points.at(l).time>i){n=h;break}if(-1==n)return s&&i<r?function(t,e,i,s,r,a){const n=[new Ue,new Ue];{const e=t.points.at(s);n[0].time=e.time,n[0].value=e.value}{const e=t.points.at(i);n[1].time=a,n[1].value=e.value}switch(t.segments.at(e).segmentType){case Ne.CubismMotionSegmentType_Linear:case Ne.CubismMotionSegmentType_Bezier:default:return ii(n,r);case Ne.CubismMotionSegmentType_Stepped:return ai(n);case Ne.CubismMotionSegmentType_InverseStepped:return ni(n)}}(t,o-1,t.segments.at(a.baseSegmentIndex).basePointIndex,l,i,r):t.points.at(l).value;const u=t.segments.at(n);return u.evaluate(t.points.get(u.basePointIndex),i)}class li extends ve{constructor(){super(),this._motionBehavior=1,this._sourceFrameRate=30,this._loopDurationSeconds=-1,this._isLoop=!1,this._isLoopFadeIn=!0,this._lastWeight=0,this._motionData=null,this._modelCurveIdEyeBlink=null,this._modelCurveIdLipSync=null,this._modelCurveIdOpacity=null,this._eyeBlinkParameterIds=null,this._lipSyncParameterIds=null,this._modelOpacity=1,this._debugMode=!1}static create(t,e,i,s,r=!1){const a=new li;return a.parse(t,e,r),a._motionData?(a._sourceFrameRate=a._motionData.fps,a._loopDurationSeconds=a._motionData.duration,a._onFinishedMotion=i,a._onBeganMotion=s,a):(ut(a),null)}doUpdateParameters(t,e,i,s){null==this._modelCurveIdEyeBlink&&(this._modelCurveIdEyeBlink=ht.getIdManager().getId("EyeBlink")),null==this._modelCurveIdLipSync&&(this._modelCurveIdLipSync=ht.getIdManager().getId("LipSync")),null==this._modelCurveIdOpacity&&(this._modelCurveIdOpacity=ht.getIdManager().getId(ti)),1===this._motionBehavior&&this._previousLoopState!==this._isLoop&&(this.adjustEndTime(s),this._previousLoopState=this._isLoop);let r=e-s.getStartTime();r<0&&(r=0);let a=Number.MAX_VALUE,n=Number.MAX_VALUE;const o=64;let l=0,u=0;this._eyeBlinkParameterIds.getSize()>o&&T("too many eye blink targets : {0}",this._eyeBlinkParameterIds.getSize()),this._lipSyncParameterIds.getSize()>o&&T("too many lip sync targets : {0}",this._lipSyncParameterIds.getSize());const h=this._fadeInSeconds<=0?1:Ce.getEasingSine((e-s.getFadeInStartTime())/this._fadeInSeconds),d=this._fadeOutSeconds<=0||s.getEndTime()<0?1:Ce.getEasingSine((s.getEndTime()-e)/this._fadeOutSeconds);let g,c,m,p=r,_=this._motionData.duration;const f=1===this._motionBehavior&&this._isLoop;if(this._isLoop)for(1===this._motionBehavior&&(_+=1/this._motionData.fps);p>_;)p-=_;const y=this._motionData.curves;for(c=0;c<this._motionData.curveCount&&y.at(c).type==ke.CubismMotionCurveTarget_Model;++c)g=oi(this._motionData,c,p,f,_),y.at(c).id==this._modelCurveIdEyeBlink?n=g:y.at(c).id==this._modelCurveIdLipSync?a=g:y.at(c).id==this._modelCurveIdOpacity&&(this._modelOpacity=g,t.setModelOapcity(this.getModelOpacityValue()));for(;c<this._motionData.curveCount&&y.at(c).type==ke.CubismMotionCurveTarget_Parameter;++c){if(m=t.getParameterIndex(y.at(c).id),-1==m)continue;const r=t.getParameterValueByIndex(m);if(g=oi(this._motionData,c,p,f,_),n!=Number.MAX_VALUE)for(let t=0;t<this._eyeBlinkParameterIds.getSize()&&t<o;++t)if(this._eyeBlinkParameterIds.at(t)==y.at(c).id){g*=n,u|=1<<t;break}if(a!=Number.MAX_VALUE)for(let t=0;t<this._lipSyncParameterIds.getSize()&&t<o;++t)if(this._lipSyncParameterIds.at(t)==y.at(c).id){g+=a,l|=1<<t;break}let x;if(t.isRepeat(m)&&(g=t.getParameterRepeatValue(m,g)),y.at(c).fadeInTime<0&&y.at(c).fadeOutTime<0)x=r+(g-r)*i;else{let t,i;t=y.at(c).fadeInTime<0?h:0==y.at(c).fadeInTime?1:Ce.getEasingSine((e-s.getFadeInStartTime())/y.at(c).fadeInTime),i=y.at(c).fadeOutTime<0?d:0==y.at(c).fadeOutTime||s.getEndTime()<0?1:Ce.getEasingSine((s.getEndTime()-e)/y.at(c).fadeOutTime);x=r+(g-r)*(this._weight*t*i)}t.setParameterValueByIndex(m,x,1)}if(n!=Number.MAX_VALUE)for(let x=0;x<this._eyeBlinkParameterIds.getSize()&&x<o;++x){const e=t.getParameterValueById(this._eyeBlinkParameterIds.at(x));if(u>>x&1)continue;const s=e+(n-e)*i;t.setParameterValueById(this._eyeBlinkParameterIds.at(x),s)}if(a!=Number.MAX_VALUE)for(let x=0;x<this._lipSyncParameterIds.getSize()&&x<o;++x){const e=t.getParameterValueById(this._lipSyncParameterIds.at(x));if(l>>x&1)continue;const s=e+(a-e)*i;t.setParameterValueById(this._lipSyncParameterIds.at(x),s)}for(;c<this._motionData.curveCount&&y.at(c).type==ke.CubismMotionCurveTarget_PartOpacity;++c)m=t.getParameterIndex(y.at(c).id),-1!=m&&(g=oi(this._motionData,c,p,f,_),t.setParameterValueByIndex(m,g));r>=_&&(this._isLoop?this.updateForNextLoop(s,e,p):(this._onFinishedMotion&&this._onFinishedMotion(this),s.setIsFinished(!0))),this._lastWeight=i}setIsLoop(t){D("setIsLoop() is a deprecated function. Please use setLoop()."),this._isLoop=t}isLoop(){return D("isLoop() is a deprecated function. Please use getLoop()."),this._isLoop}setIsLoopFadeIn(t){D("setIsLoopFadeIn() is a deprecated function. Please use setLoopFadeIn()."),this._isLoopFadeIn=t}isLoopFadeIn(){return D("isLoopFadeIn() is a deprecated function. Please use getLoopFadeIn()."),this._isLoopFadeIn}setMotionBehavior(t){this._motionBehavior=t}getMotionBehavior(){return this._motionBehavior}getDuration(){return this._isLoop?-1:this._loopDurationSeconds}getLoopDuration(){return this._loopDurationSeconds}setParameterFadeInTime(t,e){const i=this._motionData.curves;for(let s=0;s<this._motionData.curveCount;++s)if(t==i.at(s).id)return void(i.at(s).fadeInTime=e)}setParameterFadeOutTime(t,e){const i=this._motionData.curves;for(let s=0;s<this._motionData.curveCount;++s)if(t==i.at(s).id)return void(i.at(s).fadeOutTime=e)}getParameterFadeInTime(t){const e=this._motionData.curves;for(let i=0;i<this._motionData.curveCount;++i)if(t==e.at(i).id)return e.at(i).fadeInTime;return-1}getParameterFadeOutTime(t){const e=this._motionData.curves;for(let i=0;i<this._motionData.curveCount;++i)if(t==e.at(i).id)return e.at(i).fadeOutTime;return-1}setEffectIds(t,e){this._eyeBlinkParameterIds=t,this._lipSyncParameterIds=e}release(){this._motionData=void 0,this._motionData=null}updateForNextLoop(t,e,i){switch(this._motionBehavior){case 1:default:t.setStartTime(e-i),this._isLoopFadeIn&&t.setFadeInStartTime(e-i),null!=this._onFinishedMotion&&this._onFinishedMotion(this);break;case 0:t.setStartTime(e),this._isLoopFadeIn&&t.setFadeInStartTime(e)}}parse(t,e,i=!1){let s=new Ze(t,e);if(!s)return s.release(),void(s=void 0);if(i){if(!s.hasConsistency())return s.release(),void O("Inconsistent motion3.json.")}this._motionData=new Xe,this._motionData.duration=s.getMotionDuration(),this._motionData.loop=s.isMotionLoop(),this._motionData.curveCount=s.getMotionCurveCount(),this._motionData.fps=s.getMotionFps(),this._motionData.eventCount=s.getEventCount();const r=s.getEvaluationOptionFlag(Qe.EvaluationOptionFlag_AreBeziersRistricted);s.isExistMotionFadeInTime()?this._fadeInSeconds=s.getMotionFadeInTime()<0?1:s.getMotionFadeInTime():this._fadeInSeconds=1,s.isExistMotionFadeOutTime()?this._fadeOutSeconds=s.getMotionFadeOutTime()<0?1:s.getMotionFadeOutTime():this._fadeOutSeconds=1,this._motionData.curves.updateSize(this._motionData.curveCount,je,!0),this._motionData.segments.updateSize(s.getMotionTotalSegmentCount(),ze,!0),this._motionData.points.updateSize(s.getMotionTotalPointCount(),Ue,!0),this._motionData.events.updateSize(this._motionData.eventCount,Ge,!0);let a=0,n=0;for(let o=0;o<this._motionData.curveCount;++o){"Model"==s.getMotionCurveTarget(o)?this._motionData.curves.at(o).type=ke.CubismMotionCurveTarget_Model:"Parameter"==s.getMotionCurveTarget(o)?this._motionData.curves.at(o).type=ke.CubismMotionCurveTarget_Parameter:"PartOpacity"==s.getMotionCurveTarget(o)?this._motionData.curves.at(o).type=ke.CubismMotionCurveTarget_PartOpacity:D('Warning : Unable to get segment type from Curve! The number of "CurveCount" may be incorrect!'),this._motionData.curves.at(o).id=s.getMotionCurveId(o),this._motionData.curves.at(o).baseSegmentIndex=n,this._motionData.curves.at(o).fadeInTime=s.isExistMotionCurveFadeInTime(o)?s.getMotionCurveFadeInTime(o):-1,this._motionData.curves.at(o).fadeOutTime=s.isExistMotionCurveFadeOutTime(o)?s.getMotionCurveFadeOutTime(o):-1;for(let t=0;t<s.getMotionCurveSegmentCount(o);){0==t?(this._motionData.segments.at(n).basePointIndex=a,this._motionData.points.at(a).time=s.getMotionCurveSegment(o,t),this._motionData.points.at(a).value=s.getMotionCurveSegment(o,t+1),a+=1,t+=2):this._motionData.segments.at(n).basePointIndex=a-1;switch(s.getMotionCurveSegment(o,t)){case Ne.CubismMotionSegmentType_Linear:this._motionData.segments.at(n).segmentType=Ne.CubismMotionSegmentType_Linear,this._motionData.segments.at(n).evaluate=ii,this._motionData.points.at(a).time=s.getMotionCurveSegment(o,t+1),this._motionData.points.at(a).value=s.getMotionCurveSegment(o,t+2),a+=1,t+=3;break;case Ne.CubismMotionSegmentType_Bezier:this._motionData.segments.at(n).segmentType=Ne.CubismMotionSegmentType_Bezier,this._motionData.segments.at(n).evaluate=r?si:ri,this._motionData.points.at(a).time=s.getMotionCurveSegment(o,t+1),this._motionData.points.at(a).value=s.getMotionCurveSegment(o,t+2),this._motionData.points.at(a+1).time=s.getMotionCurveSegment(o,t+3),this._motionData.points.at(a+1).value=s.getMotionCurveSegment(o,t+4),this._motionData.points.at(a+2).time=s.getMotionCurveSegment(o,t+5),this._motionData.points.at(a+2).value=s.getMotionCurveSegment(o,t+6),a+=3,t+=7;break;case Ne.CubismMotionSegmentType_Stepped:this._motionData.segments.at(n).segmentType=Ne.CubismMotionSegmentType_Stepped,this._motionData.segments.at(n).evaluate=ai,this._motionData.points.at(a).time=s.getMotionCurveSegment(o,t+1),this._motionData.points.at(a).value=s.getMotionCurveSegment(o,t+2),a+=1,t+=3;break;case Ne.CubismMotionSegmentType_InverseStepped:this._motionData.segments.at(n).segmentType=Ne.CubismMotionSegmentType_InverseStepped,this._motionData.segments.at(n).evaluate=ni,this._motionData.points.at(a).time=s.getMotionCurveSegment(o,t+1),this._motionData.points.at(a).value=s.getMotionCurveSegment(o,t+2),a+=1,t+=3;break;default:L(0)}++this._motionData.curves.at(o).segmentCount,++n}}for(let o=0;o<s.getEventCount();++o)this._motionData.events.at(o).fireTime=s.getEventTime(o),this._motionData.events.at(o).value=s.getEventValue(o);s.release(),s=void 0,s=null}getFiredEvent(t,e){this._firedEventValues.updateSize(0);for(let i=0;i<this._motionData.eventCount;++i)this._motionData.events.at(i).fireTime>t&&this._motionData.events.at(i).fireTime<=e&&this._firedEventValues.pushBack(new S(this._motionData.events.at(i).value.s));return this._firedEventValues}isExistModelOpacity(){for(let t=0;t<this._motionData.curveCount;t++){const e=this._motionData.curves.at(t);if(e.type==ke.CubismMotionCurveTarget_Model&&0==e.id.getString().s.localeCompare(ti))return!0}return!1}getModelOpacityIndex(){if(this.isExistModelOpacity())for(let t=0;t<this._motionData.curveCount;t++){const e=this._motionData.curves.at(t);if(e.type==ke.CubismMotionCurveTarget_Model&&0==e.id.getString().s.localeCompare(ti))return t}return-1}getModelOpacityId(t){if(-1!=t){const e=this._motionData.curves.at(t);if(e.type==ke.CubismMotionCurveTarget_Model&&0==e.id.getString().s.localeCompare(ti))return ht.getIdManager().getId(e.id.getString().s)}return null}getModelOpacityValue(){return this._modelOpacity}setDebugMode(t){this._debugMode=t}}var ui;function hi(t,e,i){const s=t.startMotion(i,!1),r=t.getCubismMotionQueueEntry(s);if(!r)return!1;r.setStartTime(0),r.setFadeInStartTime(0);const a=i.getDuration(),n=r.getStartTime()+a;return i.doUpdateParameters(e.coreModel,n,1,r),r.setIsFinished(!0),!0}(t=>{t.CubismMotion=li})(ui||(ui={}));class di extends Tt{constructor(t){var e;super(t),u(this,"definitions"),u(this,"groups",{idle:"Idle"}),u(this,"motionDataType","arraybuffer"),u(this,"queueManager",new Le),u(this,"expressionManager"),u(this,"eyeBlinkIds"),u(this,"lipSyncIds",["ParamMouthOpenY"]),this.definitions=null!=(e=t.settings.motions)?e:{},this.eyeBlinkIds=t.settings.getEyeBlinkParameters()||[];const i=t.settings.getLipSyncParameters();(null==i?void 0:i.length)&&(this.lipSyncIds=i),this.init(t.options)}init(t){super.init(t),this.settings.expressions&&(this.expressionManager=new De(this.settings,t)),this.queueManager.setEventCallback((t,e)=>{const i="string"==typeof e?e:"number"==typeof e?String(e):e&&"object"==typeof e?e.s:"undefined";this.emit("motion:"+i)})}isFinished(){return this.queueManager.isFinished()}_startMotion(t,e,i){if(t.setFinishedMotionHandler(e),i&&i.length>0){const e=t._motionData.curves,s=function(t){if(gi(t))return new g;return[]}(e),r=ci(e);for(let t=0;t<r;t++){const r=mi(e,t);if(!r)continue;const a=pi(r);a&&i.includes(a)||_i(s,r)}t._motionData.curves=s,t._motionData.curveCount=ci(s)}return this.queueManager.stopAllMotions(),this.queueManager.startMotion(t,!1)}_stopAllMotions(){this.queueManager.stopAllMotions()}createMotion(t,e,i){const s=!!this.parent.options.checkMotionConsistency,r=li.create(t,t.byteLength,void 0,void 0,s),a=new Ze(t,t.byteLength),n=(e===this.groups.idle?gt.idleMotionFadingDuration:gt.motionFadingDuration)/1e3;return void 0===a.getMotionFadeInTime()&&r.setFadeInTime(i.FadeInTime>0?i.FadeInTime:n),void 0===a.getMotionFadeOutTime()&&r.setFadeOutTime(i.FadeOutTime>0?i.FadeOutTime:n),r.setEffectIds(this.createIdVector(this.eyeBlinkIds),this.createIdVector(this.lipSyncIds)),r}getMotionFile(t){return t.File}getMotionName(t){return t.File}getSoundFile(t){return t.Sound}updateParameters(t,e){return this.queueManager.doUpdateMotion(t,e)}destroy(){super.destroy(),this.queueManager.release(),this.queueManager=void 0}motionLastFrame(t,e){return h(this,arguments,function*(t,e,{expression:i}={}){const s=yield this.getMotionAndApplyExpression(t,e,i);return!!s&&(this.playing=!0,hi(this.queueManager,this.parent,s),this.playing=!1,!0)})}createIdVector(t){const e=new g,i=ht.getIdManager();for(const s of t)e.pushBack(i.getId(s));return e}}function gi(t){return"function"==typeof t.pushBack}function ci(t){return gi(t)?t.getSize():t.length}function mi(t,e){return gi(t)?t.at(e):t[e]}function pi(t){if(!t||"object"!=typeof t)return;const e=t.id;return"string"==typeof e?e:e&&"function"==typeof e.getString?e.getString().s:void 0}function _i(t,e){gi(t)?t.pushBack(e):t.push(e)}class fi extends e.EventEmitter{constructor(t){super(),u(this,"tag"),u(this,"manager"),u(this,"settings"),u(this,"state",new It),u(this,"playing",!1),u(this,"destroyed",!1),u(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 h(this,arguments,function*(t,e,i=Ft.NORMAL,s=[]){var r;if(!this.state.reserve(t,e,i))return!1;const a=null==(r=this.manager.definitions[t])?void 0:r[e];if(!a)return!1;const n=yield this.manager.loadMotion(t,e);return!!this.state.start(n,t,e,i)&&(ct.log(this.tag,"Start motion:",this.getMotionName(a)),this.emit("motionStart",t,e,void 0),this.playing=!0,this._startMotion(n,void 0,s),!0)})}startRandomMotion(t,e){return h(this,null,function*(){var i;const s=this.manager.definitions[t];if(null==s?void 0:s.length){const r=[],a=null!=(i=this.manager.motionGroups[t])?i:[];for(let e=0;e<s.length;e++)null===a[e]||this.state.isActive(t,e)||r.push(e);if(r.length){const i=r[Math.floor(Math.random()*r.length)];return this.startMotion(t,i,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 yi extends fi{constructor(t){super(t),u(this,"queueManager",new Le),this.init()}init(){this.queueManager.setEventCallback((t,e)=>{const i="string"==typeof e?e:"number"==typeof e?String(e):e&&"object"==typeof e?e.s:"undefined";this.emit("motion:"+i)})}isFinished(){return this.queueManager.isFinished()}_startMotion(t,e,i){if(t.setFinishedMotionHandler(e),i&&i.length>0){const e=t._motionData.curves,s=function(t){if(xi(t))return new g;return[]}(e),r=Ci(e);for(let t=0;t<r;t++){const r=Si(e,t);if(!r)continue;const a=Mi(r);a&&i.includes(a)||vi(s,r)}t._motionData.curves=s,t._motionData.curveCount=Ci(s)}return this.queueManager.stopAllMotions(),this.queueManager.startMotion(t,!1)}_stopAllMotions(){this.queueManager.stopAllMotions()}updateParameters(t,e){return this.queueManager.doUpdateMotion(t,e)}getMotionName(t){return t.File}destroy(){super.destroy(),this.queueManager.release(),this.queueManager=void 0}playMotionLastFrame(t,e){return h(this,null,function*(){var i;if(!this.state.reserve(t,e,Ft.FORCE))return!1;const s=null==(i=this.manager.definitions[t])?void 0:i[e];if(!s)return!1;const r=yield this.manager.loadMotion(t,e);return!!this.state.start(r,t,e,Ft.FORCE)&&(ct.log(this.tag,"Start motion:",this.getMotionName(s)),this.emit("motionStart",t,e,void 0),this.playing=!0,this.queueManager.stopAllMotions(),hi(this.queueManager,this.parent,r)?(this.playing=!1,!0):(this.playing=!1,!1))})}}function xi(t){return"function"==typeof t.pushBack}function Ci(t){return xi(t)?t.getSize():t.length}function Si(t,e){return xi(t)?t.at(e):t[e]}function Mi(t){if(!t||"object"!=typeof t)return;const e=t.id;return"string"==typeof e?e:e&&"function"==typeof e.getString?e.getString().s:void 0}function vi(t,e){xi(t)?t.pushBack(e):t.push(e)}const bi=Object.freeze({HitAreaPrefix:"HitArea",HitAreaHead:"Head",HitAreaBody:"Body",PartsIdCore:"Parts01Core",PartsArmPrefix:"Parts01Arm_",PartsArmLPrefix:"Parts01ArmL_",PartsArmRPrefix:"Parts01ArmR_",ParamAngleX:"ParamAngleX",ParamAngleY:"ParamAngleY",ParamAngleZ:"ParamAngleZ",ParamEyeLOpen:"ParamEyeLOpen",ParamEyeLSmile:"ParamEyeLSmile",ParamEyeROpen:"ParamEyeROpen",ParamEyeRSmile:"ParamEyeRSmile",ParamEyeBallX:"ParamEyeBallX",ParamEyeBallY:"ParamEyeBallY",ParamEyeBallForm:"ParamEyeBallForm",ParamBrowLY:"ParamBrowLY",ParamBrowRY:"ParamBrowRY",ParamBrowLX:"ParamBrowLX",ParamBrowRX:"ParamBrowRX",ParamBrowLAngle:"ParamBrowLAngle",ParamBrowRAngle:"ParamBrowRAngle",ParamBrowLForm:"ParamBrowLForm",ParamBrowRForm:"ParamBrowRForm",ParamMouthForm:"ParamMouthForm",ParamMouthOpenY:"ParamMouthOpenY",ParamCheek:"ParamCheek",ParamBodyAngleX:"ParamBodyAngleX",ParamBodyAngleY:"ParamBodyAngleY",ParamBodyAngleZ:"ParamBodyAngleZ",ParamBreath:"ParamBreath",ParamArmLA:"ParamArmLA",ParamArmRA:"ParamArmRA",ParamArmLB:"ParamArmLB",ParamArmRB:"ParamArmRB",ParamHandL:"ParamHandL",ParamHandR:"ParamHandR",ParamHairFront:"ParamHairFront",ParamHairSide:"ParamHairSide",ParamHairBack:"ParamHairBack",ParamHairFluffy:"ParamHairFluffy",ParamShoulderY:"ParamShoulderY",ParamBustX:"ParamBustX",ParamBustY:"ParamBustY",ParamBaseX:"ParamBaseX",ParamBaseY:"ParamBaseY",ParamNONE:"NONE:"});var Pi,Bi;(t=>{t.HitAreaBody=bi.HitAreaBody,t.HitAreaHead=bi.HitAreaHead,t.HitAreaPrefix=bi.HitAreaPrefix,t.ParamAngleX=bi.ParamAngleX,t.ParamAngleY=bi.ParamAngleY,t.ParamAngleZ=bi.ParamAngleZ,t.ParamArmLA=bi.ParamArmLA,t.ParamArmLB=bi.ParamArmLB,t.ParamArmRA=bi.ParamArmRA,t.ParamArmRB=bi.ParamArmRB,t.ParamBaseX=bi.ParamBaseX,t.ParamBaseY=bi.ParamBaseY,t.ParamBodyAngleX=bi.ParamBodyAngleX,t.ParamBodyAngleY=bi.ParamBodyAngleY,t.ParamBodyAngleZ=bi.ParamBodyAngleZ,t.ParamBreath=bi.ParamBreath,t.ParamBrowLAngle=bi.ParamBrowLAngle,t.ParamBrowLForm=bi.ParamBrowLForm,t.ParamBrowLX=bi.ParamBrowLX,t.ParamBrowLY=bi.ParamBrowLY,t.ParamBrowRAngle=bi.ParamBrowRAngle,t.ParamBrowRForm=bi.ParamBrowRForm,t.ParamBrowRX=bi.ParamBrowRX,t.ParamBrowRY=bi.ParamBrowRY,t.ParamBustX=bi.ParamBustX,t.ParamBustY=bi.ParamBustY,t.ParamCheek=bi.ParamCheek,t.ParamEyeBallForm=bi.ParamEyeBallForm,t.ParamEyeBallX=bi.ParamEyeBallX,t.ParamEyeBallY=bi.ParamEyeBallY,t.ParamEyeLOpen=bi.ParamEyeLOpen,t.ParamEyeLSmile=bi.ParamEyeLSmile,t.ParamEyeROpen=bi.ParamEyeROpen,t.ParamEyeRSmile=bi.ParamEyeRSmile,t.ParamHairBack=bi.ParamHairBack,t.ParamHairFluffy=bi.ParamHairFluffy,t.ParamHairFront=bi.ParamHairFront,t.ParamHairSide=bi.ParamHairSide,t.ParamHandL=bi.ParamHandL,t.ParamHandR=bi.ParamHandR,t.ParamMouthForm=bi.ParamMouthForm,t.ParamMouthOpenY=bi.ParamMouthOpenY,t.ParamNONE=bi.ParamNONE,t.ParamShoulderY=bi.ParamShoulderY,t.PartsArmLPrefix=bi.PartsArmLPrefix,t.PartsArmPrefix=bi.PartsArmPrefix,t.PartsArmRPrefix=bi.PartsArmRPrefix,t.PartsIdCore=bi.PartsIdCore})(Pi||(Pi={}));class wi{static create(){return new wi}static delete(t){}setParameters(t){this._breathParameters=t}getParameters(){return this._breathParameters}updateParameters(t,e){this._currentTime+=e;const i=2*this._currentTime*Math.PI;for(let s=0;s<this._breathParameters.getSize();++s){const e=this._breathParameters.at(s);t.addParameterValueById(e.parameterId,e.offset+e.peak*Math.sin(i/e.cycle),e.weight)}}constructor(){this._currentTime=0}}class Fi{constructor(t,e,i,s,r){this.parameterId=null==t?null:t,this.offset=null==e?0:e,this.peak=null==i?0:i,this.cycle=null==s?0:s,this.weight=null==r?0:r}}(t=>{t.BreathParameterData=Fi,t.CubismBreath=wi})(Bi||(Bi={}));const Ii=class t{static create(e=null){return new t(e)}static delete(t){}setBlinkingInterval(t){this._blinkingIntervalSeconds=t}setBlinkingSetting(t,e,i){this._closingSeconds=t,this._closedSeconds=e,this._openingSeconds=i}setParameterIds(t){this._parameterIds=t}getParameterIds(){return this._parameterIds}updateParameters(e,i){let s;this._userTimeSeconds+=i;let r=0;switch(this._blinkingState){case 2:r=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._closingSeconds,r>=1&&(r=1,this._blinkingState=3,this._stateStartTimeSeconds=this._userTimeSeconds),s=1-r;break;case 3:r=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._closedSeconds,r>=1&&(this._blinkingState=4,this._stateStartTimeSeconds=this._userTimeSeconds),s=0;break;case 4:r=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._openingSeconds,r>=1&&(r=1,this._blinkingState=1,this._nextBlinkingTime=this.determinNextBlinkingTiming()),s=r;break;case 1:this._nextBlinkingTime<this._userTimeSeconds&&(this._blinkingState=2,this._stateStartTimeSeconds=this._userTimeSeconds),s=1;break;default:this._blinkingState=1,this._nextBlinkingTime=this.determinNextBlinkingTiming(),s=1}t.CloseIfZero||(s=-s);for(let t=0;t<this._parameterIds.getSize();++t)e.setParameterValueById(this._parameterIds.at(t),s)}constructor(t){if(this._blinkingState=0,this._nextBlinkingTime=0,this._stateStartTimeSeconds=0,this._blinkingIntervalSeconds=4,this._closingSeconds=.1,this._closedSeconds=.05,this._openingSeconds=.15,this._userTimeSeconds=0,this._parameterIds=new g,null!=t)for(let e=0;e<t.getEyeBlinkParameterCount();++e)this._parameterIds.pushBack(t.getEyeBlinkParameterId(e))}determinNextBlinkingTiming(){const t=Math.random();return this._userTimeSeconds+t*(2*this._blinkingIntervalSeconds-1)}};Ii.CloseIfZero=!0;let Ei=Ii;var Vi,Ri=(t=>(t[t.EyeState_First=0]="EyeState_First",t[t.EyeState_Interval=1]="EyeState_Interval",t[t.EyeState_Closing=2]="EyeState_Closing",t[t.EyeState_Closed=3]="EyeState_Closed",t[t.EyeState_Opening=4]="EyeState_Opening",t))(Ri||{});(t=>{t.CubismEyeBlink=Ei,t.EyeState=Ri})(Vi||(Vi={}));class Li{constructor(t){this._renderTextureCount=0,this._clippingMaskBufferSize=256,this._clippingContextListForMask=new g,this._clippingContextListForDraw=new g,this._channelColors=new g,this._tmpBoundsOnModel=new P,this._tmpMatrix=new b,this._tmpMatrixForMask=new b,this._tmpMatrixForDraw=new b,this._clippingContexttConstructor=t;let e=new I;e.r=1,e.g=0,e.b=0,e.a=0,this._channelColors.pushBack(e),e=new I,e.r=0,e.g=1,e.b=0,e.a=0,this._channelColors.pushBack(e),e=new I,e.r=0,e.g=0,e.b=1,e.a=0,this._channelColors.pushBack(e),e=new I,e.r=0,e.g=0,e.b=0,e.a=1,this._channelColors.pushBack(e)}release(){for(let t=0;t<this._clippingContextListForMask.getSize();t++)this._clippingContextListForMask.at(t)&&(this._clippingContextListForMask.at(t).release(),this._clippingContextListForMask.set(t,void 0)),this._clippingContextListForMask.set(t,null);this._clippingContextListForMask=null;for(let t=0;t<this._clippingContextListForDraw.getSize();t++)this._clippingContextListForDraw.set(t,null);this._clippingContextListForDraw=null;for(let t=0;t<this._channelColors.getSize();t++)this._channelColors.set(t,null);this._channelColors=null,null!=this._clearedFrameBufferFlags&&this._clearedFrameBufferFlags.clear(),this._clearedFrameBufferFlags=null}initialize(t,e){e%1!=0&&(D("The number of render textures must be specified as an integer. The decimal point is rounded down and corrected to an integer."),e=~~e),e<1&&D("The number of render textures must be an integer greater than or equal to 1. Set the number of render textures to 1."),this._renderTextureCount=e<1?1:e,this._clearedFrameBufferFlags=new g(this._renderTextureCount);for(let i=0;i<t.getDrawableCount();i++){if(t.getDrawableMaskCounts()[i]<=0){this._clippingContextListForDraw.pushBack(null);continue}let e=this.findSameClip(t.getDrawableMasks()[i],t.getDrawableMaskCounts()[i]);null==e&&(e=new this._clippingContexttConstructor(this,t.getDrawableMasks()[i],t.getDrawableMaskCounts()[i]),this._clippingContextListForMask.pushBack(e)),e.addClippedDrawable(i),this._clippingContextListForDraw.pushBack(e)}}findSameClip(t,e){for(let i=0;i<this._clippingContextListForMask.getSize();i++){const s=this._clippingContextListForMask.at(i),r=s._clippingIdCount;if(r!=e)continue;let a=0;for(let e=0;e<r;e++){const i=s._clippingIdList[e];for(let e=0;e<r;e++)if(t[e]==i){a++;break}}if(a==r)return s}return null}setupMatrixForHighPrecision(t,e){let i=0;for(let s=0;s<this._clippingContextListForMask.getSize();s++){const e=this._clippingContextListForMask.at(s);this.calcClippedDrawTotalBounds(t,e),e._isUsing&&i++}if(i>0){if(this.setupLayoutBounds(0),this._clearedFrameBufferFlags.getSize()!=this._renderTextureCount){this._clearedFrameBufferFlags.clear();for(let t=0;t<this._renderTextureCount;t++)this._clearedFrameBufferFlags.pushBack(!1)}else for(let t=0;t<this._renderTextureCount;t++)this._clearedFrameBufferFlags.set(t,!1);for(let i=0;i<this._clippingContextListForMask.getSize();i++){const s=this._clippingContextListForMask.at(i),r=s._allClippedDrawRect,a=s._layoutBounds,n=.05;let o=0,l=0;const u=t.getPixelsPerUnit(),h=s.getClippingManager().getClippingMaskBufferSize(),d=a.width*h,g=a.height*h;this._tmpBoundsOnModel.setRect(r),this._tmpBoundsOnModel.width*u>d?(this._tmpBoundsOnModel.expand(r.width*n,0),o=a.width/this._tmpBoundsOnModel.width):o=u/d,this._tmpBoundsOnModel.height*u>g?(this._tmpBoundsOnModel.expand(0,r.height*n),l=a.height/this._tmpBoundsOnModel.height):l=u/g,this.createMatrixForMask(e,a,o,l),s._matrixForMask.setMatrix(this._tmpMatrixForMask.getArray()),s._matrixForDraw.setMatrix(this._tmpMatrixForDraw.getArray())}}}createMatrixForMask(t,e,i,s){this._tmpMatrix.loadIdentity(),this._tmpMatrix.translateRelative(-1,-1),this._tmpMatrix.scaleRelative(2,2),this._tmpMatrix.translateRelative(e.x,e.y),this._tmpMatrix.scaleRelative(i,s),this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x,-this._tmpBoundsOnModel.y),this._tmpMatrixForMask.setMatrix(this._tmpMatrix.getArray()),this._tmpMatrix.loadIdentity(),this._tmpMatrix.translateRelative(e.x,e.y*(t?-1:1)),this._tmpMatrix.scaleRelative(i,s*(t?-1:1)),this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x,-this._tmpBoundsOnModel.y),this._tmpMatrixForDraw.setMatrix(this._tmpMatrix.getArray())}setupLayoutBounds(t){const e=this._renderTextureCount<=1?36:32*this._renderTextureCount;if(t<=0||t>e){t>e&&O("not supported mask count : {0}\n[Details] render texture count : {1}, mask count : {2}",t-e,this._renderTextureCount,t);for(let t=0;t<this._clippingContextListForMask.getSize();t++){const e=this._clippingContextListForMask.at(t);e._layoutChannelIndex=0,e._layoutBounds.x=0,e._layoutBounds.y=0,e._layoutBounds.width=1,e._layoutBounds.height=1,e._bufferIndex=0}return}const i=this._renderTextureCount<=1?9:8;let s=t/this._renderTextureCount;const r=t%this._renderTextureCount;s=Math.ceil(s);let a=s/4;const n=s%4;a=~~a;let o=0;for(let l=0;l<this._renderTextureCount;l++)for(let s=0;s<4;s++){let u=a+(s<n?1:0);if(s==n+(a<1?-1:0)&&r>0&&(u-=l<r?0:1),0==u);else if(1==u){const t=this._clippingContextListForMask.at(o++);t._layoutChannelIndex=s,t._layoutBounds.x=0,t._layoutBounds.y=0,t._layoutBounds.width=1,t._layoutBounds.height=1,t._bufferIndex=l}else if(2==u)for(let t=0;t<u;t++){let e=t%2;e=~~e;const i=this._clippingContextListForMask.at(o++);i._layoutChannelIndex=s,i._layoutBounds.x=.5*e,i._layoutBounds.y=0,i._layoutBounds.width=.5,i._layoutBounds.height=1,i._bufferIndex=l}else if(u<=4)for(let t=0;t<u;t++){let e=t%2,i=t/2;e=~~e,i=~~i;const r=this._clippingContextListForMask.at(o++);r._layoutChannelIndex=s,r._layoutBounds.x=.5*e,r._layoutBounds.y=.5*i,r._layoutBounds.width=.5,r._layoutBounds.height=.5,r._bufferIndex=l}else if(u<=i)for(let t=0;t<u;t++){let e=t%3,i=t/3;e=~~e,i=~~i;const r=this._clippingContextListForMask.at(o++);r._layoutChannelIndex=s,r._layoutBounds.x=e/3,r._layoutBounds.y=i/3,r._layoutBounds.width=1/3,r._layoutBounds.height=1/3,r._bufferIndex=l}else{O("not supported mask count : {0}\n[Details] render texture count : {1}, mask count : {2}",t-e,this._renderTextureCount,t);for(let t=0;t<u;t++){const t=this._clippingContextListForMask.at(o++);t._layoutChannelIndex=0,t._layoutBounds.x=0,t._layoutBounds.y=0,t._layoutBounds.width=1,t._layoutBounds.height=1,t._bufferIndex=0}}}}calcClippedDrawTotalBounds(t,e){let i=Number.MAX_VALUE,s=Number.MAX_VALUE,r=Number.MIN_VALUE,a=Number.MIN_VALUE;const n=e._clippedDrawableIndexList.length;for(let o=0;o<n;o++){const n=e._clippedDrawableIndexList[o],l=t.getDrawableVertexCount(n),u=t.getDrawableVertices(n);let h=Number.MAX_VALUE,d=Number.MAX_VALUE,g=-Number.MAX_VALUE,c=-Number.MAX_VALUE;const m=l*lt.vertexStep;for(let t=lt.vertexOffset;t<m;t+=lt.vertexStep){const e=u[t],i=u[t+1];e<h&&(h=e),e>g&&(g=e),i<d&&(d=i),i>c&&(c=i)}if(h!=Number.MAX_VALUE)if(h<i&&(i=h),d<s&&(s=d),g>r&&(r=g),c>a&&(a=c),i==Number.MAX_VALUE)e._allClippedDrawRect.x=0,e._allClippedDrawRect.y=0,e._allClippedDrawRect.width=0,e._allClippedDrawRect.height=0,e._isUsing=!1;else{e._isUsing=!0;const t=r-i,n=a-s;e._allClippedDrawRect.x=i,e._allClippedDrawRect.y=s,e._allClippedDrawRect.width=t,e._allClippedDrawRect.height=n}}}getClippingContextListForDraw(){return this._clippingContextListForDraw}getClippingMaskBufferSize(){return this._clippingMaskBufferSize}getRenderTextureCount(){return this._renderTextureCount}getChannelFlagAsColor(t){return this._channelColors.at(t)}setClippingMaskBufferSize(t){this._clippingMaskBufferSize=t}}let Ti;class Ai{constructor(){this._shaderSets=new g}release(){this.releaseShaderProgram()}setupShaderProgramForDraw(t,e,i){let s,r,a,n;t.isPremultipliedAlpha()||O("NoPremultipliedAlpha is not allowed"),0==this._shaderSets.getSize()&&this.generateShaders();const o=null!=t.getClippingContextBufferForDraw(),l=e.getDrawableInvertedMaskBit(i),u=o?l?2:1:0;let h;switch(e.getDrawableBlendMode(i)){case F.CubismBlendMode_Normal:default:h=this._shaderSets.at(1+u),s=this.gl.ONE,r=this.gl.ONE_MINUS_SRC_ALPHA,a=this.gl.ONE,n=this.gl.ONE_MINUS_SRC_ALPHA;break;case F.CubismBlendMode_Additive:h=this._shaderSets.at(4+u),s=this.gl.ONE,r=this.gl.ONE,a=this.gl.ZERO,n=this.gl.ONE;break;case F.CubismBlendMode_Multiplicative:h=this._shaderSets.at(7+u),s=this.gl.DST_COLOR,r=this.gl.ONE_MINUS_SRC_ALPHA,a=this.gl.ZERO,n=this.gl.ONE}this.gl.useProgram(h.shaderProgram),null==t._bufferData.vertex&&(t._bufferData.vertex=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,t._bufferData.vertex);const d=e.getDrawableVertices(i);this.gl.bufferData(this.gl.ARRAY_BUFFER,d,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(h.attributePositionLocation),this.gl.vertexAttribPointer(h.attributePositionLocation,2,this.gl.FLOAT,!1,0,0),null==t._bufferData.uv&&(t._bufferData.uv=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,t._bufferData.uv);const g=e.getDrawableVertexUvs(i);if(this.gl.bufferData(this.gl.ARRAY_BUFFER,g,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(h.attributeTexCoordLocation),this.gl.vertexAttribPointer(h.attributeTexCoordLocation,2,this.gl.FLOAT,!1,0,0),o){this.gl.activeTexture(this.gl.TEXTURE1);const e=t.getClippingContextBufferForDraw().getClippingManager().getColorBuffer().at(t.getClippingContextBufferForDraw()._bufferIndex);this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.uniform1i(h.samplerTexture1Location,1),this.gl.uniformMatrix4fv(h.uniformClipMatrixLocation,!1,t.getClippingContextBufferForDraw()._matrixForDraw.getArray());const i=t.getClippingContextBufferForDraw()._layoutChannelIndex,s=t.getClippingContextBufferForDraw().getClippingManager().getChannelFlagAsColor(i);this.gl.uniform4f(h.uniformChannelFlagLocation,s.r,s.g,s.b,s.a)}const c=e.getDrawableTextureIndex(i),m=t.getBindedTextures().getValue(c);this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,m),this.gl.uniform1i(h.samplerTexture0Location,0);const p=t.getMvpMatrix();this.gl.uniformMatrix4fv(h.uniformMatrixLocation,!1,p.getArray());const _=t.getModelColorWithOpacity(e.getDrawableOpacity(i)),f=e.getMultiplyColor(i),y=e.getScreenColor(i);this.gl.uniform4f(h.uniformBaseColorLocation,_.r,_.g,_.b,_.a),this.gl.uniform4f(h.uniformMultiplyColorLocation,f.r,f.g,f.b,f.a),this.gl.uniform4f(h.uniformScreenColorLocation,y.r,y.g,y.b,y.a),null==t._bufferData.index&&(t._bufferData.index=this.gl.createBuffer());const x=e.getDrawableVertexIndices(i);this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,t._bufferData.index),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,x,this.gl.DYNAMIC_DRAW),this.gl.blendFuncSeparate(s,r,a,n)}setupShaderProgramForMask(t,e,i){t.isPremultipliedAlpha()||O("NoPremultipliedAlpha is not allowed"),0==this._shaderSets.getSize()&&this.generateShaders();const s=this._shaderSets.at(0);this.gl.useProgram(s.shaderProgram),null==t._bufferData.vertex&&(t._bufferData.vertex=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,t._bufferData.vertex);const r=e.getDrawableVertices(i);this.gl.bufferData(this.gl.ARRAY_BUFFER,r,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(s.attributePositionLocation),this.gl.vertexAttribPointer(s.attributePositionLocation,2,this.gl.FLOAT,!1,0,0),null==t._bufferData.uv&&(t._bufferData.uv=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,t._bufferData.uv);const a=e.getDrawableTextureIndex(i),n=t.getBindedTextures().getValue(a);this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,n),this.gl.uniform1i(s.samplerTexture0Location,0),null==t._bufferData.uv&&(t._bufferData.uv=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,t._bufferData.uv);const o=e.getDrawableVertexUvs(i);this.gl.bufferData(this.gl.ARRAY_BUFFER,o,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(s.attributeTexCoordLocation),this.gl.vertexAttribPointer(s.attributeTexCoordLocation,2,this.gl.FLOAT,!1,0,0),t.getClippingContextBufferForMask();const l=t.getClippingContextBufferForMask()._layoutChannelIndex,u=t.getClippingContextBufferForMask().getClippingManager().getChannelFlagAsColor(l);this.gl.uniform4f(s.uniformChannelFlagLocation,u.r,u.g,u.b,u.a),this.gl.uniformMatrix4fv(s.uniformClipMatrixLocation,!1,t.getClippingContextBufferForMask()._matrixForMask.getArray());const h=t.getClippingContextBufferForMask()._layoutBounds;this.gl.uniform4f(s.uniformBaseColorLocation,2*h.x-1,2*h.y-1,2*h.getRight()-1,2*h.getBottom()-1);const d=e.getMultiplyColor(i),g=e.getScreenColor(i);this.gl.uniform4f(s.uniformMultiplyColorLocation,d.r,d.g,d.b,d.a),this.gl.uniform4f(s.uniformScreenColorLocation,g.r,g.g,g.b,g.a);const c=this.gl.ZERO,m=this.gl.ONE_MINUS_SRC_COLOR,p=this.gl.ZERO,_=this.gl.ONE_MINUS_SRC_ALPHA;null==t._bufferData.index&&(t._bufferData.index=this.gl.createBuffer());const f=e.getDrawableVertexIndices(i);this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,t._bufferData.index),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,f,this.gl.DYNAMIC_DRAW),this.gl.blendFuncSeparate(c,m,p,_)}releaseShaderProgram(){for(let t=0;t<this._shaderSets.getSize();t++)this.gl.deleteProgram(this._shaderSets.at(t).shaderProgram),this._shaderSets.at(t).shaderProgram=0,this._shaderSets.set(t,void 0),this._shaderSets.set(t,null)}generateShaders(){for(let t=0;t<10;t++)this._shaderSets.pushBack(new Oi);this._shaderSets.at(0).shaderProgram=this.loadShaderProgram(Ni,Ui),this._shaderSets.at(1).shaderProgram=this.loadShaderProgram(zi,Gi),this._shaderSets.at(2).shaderProgram=this.loadShaderProgram(ji,Xi),this._shaderSets.at(3).shaderProgram=this.loadShaderProgram(ji,Hi),this._shaderSets.at(4).shaderProgram=this._shaderSets.at(1).shaderProgram,this._shaderSets.at(5).shaderProgram=this._shaderSets.at(2).shaderProgram,this._shaderSets.at(6).shaderProgram=this._shaderSets.at(3).shaderProgram,this._shaderSets.at(7).shaderProgram=this._shaderSets.at(1).shaderProgram,this._shaderSets.at(8).shaderProgram=this._shaderSets.at(2).shaderProgram,this._shaderSets.at(9).shaderProgram=this._shaderSets.at(3).shaderProgram,this._shaderSets.at(0).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(0).shaderProgram,"a_position"),this._shaderSets.at(0).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(0).shaderProgram,"a_texCoord"),this._shaderSets.at(0).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(0).shaderProgram,"s_texture0"),this._shaderSets.at(0).uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(0).shaderProgram,"u_clipMatrix"),this._shaderSets.at(0).uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets.at(0).shaderProgram,"u_channelFlag"),this._shaderSets.at(0).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(0).shaderProgram,"u_baseColor"),this._shaderSets.at(0).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(0).shaderProgram,"u_multiplyColor"),this._shaderSets.at(0).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(0).shaderProgram,"u_screenColor"),this._shaderSets.at(1).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(1).shaderProgram,"a_position"),this._shaderSets.at(1).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(1).shaderProgram,"a_texCoord"),this._shaderSets.at(1).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(1).shaderProgram,"s_texture0"),this._shaderSets.at(1).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(1).shaderProgram,"u_matrix"),this._shaderSets.at(1).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(1).shaderProgram,"u_baseColor"),this._shaderSets.at(1).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(1).shaderProgram,"u_multiplyColor"),this._shaderSets.at(1).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(1).shaderProgram,"u_screenColor"),this._shaderSets.at(2).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(2).shaderProgram,"a_position"),this._shaderSets.at(2).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(2).shaderProgram,"a_texCoord"),this._shaderSets.at(2).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(2).shaderProgram,"s_texture0"),this._shaderSets.at(2).samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets.at(2).shaderProgram,"s_texture1"),this._shaderSets.at(2).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(2).shaderProgram,"u_matrix"),this._shaderSets.at(2).uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(2).shaderProgram,"u_clipMatrix"),this._shaderSets.at(2).uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets.at(2).shaderProgram,"u_channelFlag"),this._shaderSets.at(2).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(2).shaderProgram,"u_baseColor"),this._shaderSets.at(2).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(2).shaderProgram,"u_multiplyColor"),this._shaderSets.at(2).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(2).shaderProgram,"u_screenColor"),this._shaderSets.at(3).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(3).shaderProgram,"a_position"),this._shaderSets.at(3).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(3).shaderProgram,"a_texCoord"),this._shaderSets.at(3).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(3).shaderProgram,"s_texture0"),this._shaderSets.at(3).samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets.at(3).shaderProgram,"s_texture1"),this._shaderSets.at(3).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(3).shaderProgram,"u_matrix"),this._shaderSets.at(3).uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(3).shaderProgram,"u_clipMatrix"),this._shaderSets.at(3).uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets.at(3).shaderProgram,"u_channelFlag"),this._shaderSets.at(3).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(3).shaderProgram,"u_baseColor"),this._shaderSets.at(3).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(3).shaderProgram,"u_multiplyColor"),this._shaderSets.at(3).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(3).shaderProgram,"u_screenColor"),this._shaderSets.at(4).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(4).shaderProgram,"a_position"),this._shaderSets.at(4).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(4).shaderProgram,"a_texCoord"),this._shaderSets.at(4).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(4).shaderProgram,"s_texture0"),this._shaderSets.at(4).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(4).shaderProgram,"u_matrix"),this._shaderSets.at(4).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(4).shaderProgram,"u_baseColor"),this._shaderSets.at(4).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(4).shaderProgram,"u_multiplyColor"),this._shaderSets.at(4).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(4).shaderProgram,"u_screenColor"),this._shaderSets.at(5).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(5).shaderProgram,"a_position"),this._shaderSets.at(5).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(5).shaderProgram,"a_texCoord"),this._shaderSets.at(5).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(5).shaderProgram,"s_texture0"),this._shaderSets.at(5).samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets.at(5).shaderProgram,"s_texture1"),this._shaderSets.at(5).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(5).shaderProgram,"u_matrix"),this._shaderSets.at(5).uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(5).shaderProgram,"u_clipMatrix"),this._shaderSets.at(5).uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets.at(5).shaderProgram,"u_channelFlag"),this._shaderSets.at(5).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(5).shaderProgram,"u_baseColor"),this._shaderSets.at(5).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(5).shaderProgram,"u_multiplyColor"),this._shaderSets.at(5).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(5).shaderProgram,"u_screenColor"),this._shaderSets.at(6).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(6).shaderProgram,"a_position"),this._shaderSets.at(6).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(6).shaderProgram,"a_texCoord"),this._shaderSets.at(6).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(6).shaderProgram,"s_texture0"),this._shaderSets.at(6).samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets.at(6).shaderProgram,"s_texture1"),this._shaderSets.at(6).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(6).shaderProgram,"u_matrix"),this._shaderSets.at(6).uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(6).shaderProgram,"u_clipMatrix"),this._shaderSets.at(6).uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets.at(6).shaderProgram,"u_channelFlag"),this._shaderSets.at(6).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(6).shaderProgram,"u_baseColor"),this._shaderSets.at(6).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(6).shaderProgram,"u_multiplyColor"),this._shaderSets.at(6).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(6).shaderProgram,"u_screenColor"),this._shaderSets.at(7).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(7).shaderProgram,"a_position"),this._shaderSets.at(7).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(7).shaderProgram,"a_texCoord"),this._shaderSets.at(7).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(7).shaderProgram,"s_texture0"),this._shaderSets.at(7).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(7).shaderProgram,"u_matrix"),this._shaderSets.at(7).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(7).shaderProgram,"u_baseColor"),this._shaderSets.at(7).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(7).shaderProgram,"u_multiplyColor"),this._shaderSets.at(7).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(7).shaderProgram,"u_screenColor"),this._shaderSets.at(8).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(8).shaderProgram,"a_position"),this._shaderSets.at(8).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(8).shaderProgram,"a_texCoord"),this._shaderSets.at(8).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(8).shaderProgram,"s_texture0"),this._shaderSets.at(8).samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets.at(8).shaderProgram,"s_texture1"),this._shaderSets.at(8).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(8).shaderProgram,"u_matrix"),this._shaderSets.at(8).uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(8).shaderProgram,"u_clipMatrix"),this._shaderSets.at(8).uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets.at(8).shaderProgram,"u_channelFlag"),this._shaderSets.at(8).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(8).shaderProgram,"u_baseColor"),this._shaderSets.at(8).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(8).shaderProgram,"u_multiplyColor"),this._shaderSets.at(8).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(8).shaderProgram,"u_screenColor"),this._shaderSets.at(9).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(9).shaderProgram,"a_position"),this._shaderSets.at(9).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(9).shaderProgram,"a_texCoord"),this._shaderSets.at(9).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(9).shaderProgram,"s_texture0"),this._shaderSets.at(9).samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets.at(9).shaderProgram,"s_texture1"),this._shaderSets.at(9).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(9).shaderProgram,"u_matrix"),this._shaderSets.at(9).uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(9).shaderProgram,"u_clipMatrix"),this._shaderSets.at(9).uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets.at(9).shaderProgram,"u_channelFlag"),this._shaderSets.at(9).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(9).shaderProgram,"u_baseColor"),this._shaderSets.at(9).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(9).shaderProgram,"u_multiplyColor"),this._shaderSets.at(9).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(9).shaderProgram,"u_screenColor")}loadShaderProgram(t,e){let i=this.gl.createProgram(),s=this.compileShaderSource(this.gl.VERTEX_SHADER,t);if(!s)return O("Vertex shader compile error!"),0;let r=this.compileShaderSource(this.gl.FRAGMENT_SHADER,e);if(!r)return O("Vertex shader compile error!"),0;this.gl.attachShader(i,s),this.gl.attachShader(i,r),this.gl.linkProgram(i);return this.gl.getProgramParameter(i,this.gl.LINK_STATUS)?(this.gl.deleteShader(s),this.gl.deleteShader(r),i):(O("Failed to link program: {0}",i),this.gl.deleteShader(s),s=0,this.gl.deleteShader(r),r=0,i&&(this.gl.deleteProgram(i),i=0),0)}compileShaderSource(t,e){const i=e,s=this.gl.createShader(t);if(this.gl.shaderSource(s,i),this.gl.compileShader(s),!s){const t=this.gl.getShaderInfoLog(s);O("Shader compile log: {0} ",t)}return this.gl.getShaderParameter(s,this.gl.COMPILE_STATUS)?s:(this.gl.deleteShader(s),null)}setGl(t){this.gl=t}}class Di{static getInstance(){return null==Ti&&(Ti=new Di),Ti}static deleteInstance(){Ti&&(Ti.release(),Ti=null)}constructor(){this._shaderMap=new j}release(){for(const t=this._shaderMap.begin();t.notEqual(this._shaderMap.end());t.preIncrement())t.ptr().second.release();this._shaderMap.clear()}getShader(t){return this._shaderMap.getValue(t)}setGlContext(t){if(!this._shaderMap.isExist(t)){const e=new Ai;e.setGl(t),this._shaderMap.setValue(t,e)}}}class Oi{}var ki=(t=>(t[t.ShaderNames_SetupMask=0]="ShaderNames_SetupMask",t[t.ShaderNames_NormalPremultipliedAlpha=1]="ShaderNames_NormalPremultipliedAlpha",t[t.ShaderNames_NormalMaskedPremultipliedAlpha=2]="ShaderNames_NormalMaskedPremultipliedAlpha",t[t.ShaderNames_NomralMaskedInvertedPremultipliedAlpha=3]="ShaderNames_NomralMaskedInvertedPremultipliedAlpha",t[t.ShaderNames_AddPremultipliedAlpha=4]="ShaderNames_AddPremultipliedAlpha",t[t.ShaderNames_AddMaskedPremultipliedAlpha=5]="ShaderNames_AddMaskedPremultipliedAlpha",t[t.ShaderNames_AddMaskedPremultipliedAlphaInverted=6]="ShaderNames_AddMaskedPremultipliedAlphaInverted",t[t.ShaderNames_MultPremultipliedAlpha=7]="ShaderNames_MultPremultipliedAlpha",t[t.ShaderNames_MultMaskedPremultipliedAlpha=8]="ShaderNames_MultMaskedPremultipliedAlpha",t[t.ShaderNames_MultMaskedPremultipliedAlphaInverted=9]="ShaderNames_MultMaskedPremultipliedAlphaInverted",t))(ki||{});const Ni="attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;varying vec4 v_myPos;uniform mat4 u_clipMatrix;void main(){ gl_Position = u_clipMatrix * a_position; v_myPos = u_clipMatrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}",Ui="precision mediump float;varying vec2 v_texCoord;varying vec4 v_myPos;uniform vec4 u_baseColor;uniform vec4 u_channelFlag;uniform sampler2D s_texture0;void main(){ float isInside = step(u_baseColor.x, v_myPos.x/v_myPos.w) * step(u_baseColor.y, v_myPos.y/v_myPos.w) * step(v_myPos.x/v_myPos.w, u_baseColor.z) * step(v_myPos.y/v_myPos.w, u_baseColor.w); gl_FragColor = u_channelFlag * texture2D(s_texture0, v_texCoord).a * isInside;}",zi="attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;uniform mat4 u_matrix;void main(){ gl_Position = u_matrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}",ji="attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform mat4 u_matrix;uniform mat4 u_clipMatrix;void main(){ gl_Position = u_matrix * a_position; v_clipPos = u_clipMatrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}",Gi="precision mediump float;varying vec2 v_texCoord;uniform vec4 u_baseColor;uniform sampler2D s_texture0;uniform vec4 u_multiplyColor;uniform vec4 u_screenColor;void main(){ vec4 texColor = texture2D(s_texture0, v_texCoord); texColor.rgb = texColor.rgb * u_multiplyColor.rgb; texColor.rgb = (texColor.rgb + u_screenColor.rgb * texColor.a) - (texColor.rgb * u_screenColor.rgb); vec4 color = texColor * u_baseColor; gl_FragColor = vec4(color.rgb, color.a);}",Xi="precision mediump float;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform vec4 u_baseColor;uniform vec4 u_channelFlag;uniform sampler2D s_texture0;uniform sampler2D s_texture1;uniform vec4 u_multiplyColor;uniform vec4 u_screenColor;void main(){ vec4 texColor = texture2D(s_texture0, v_texCoord); texColor.rgb = texColor.rgb * u_multiplyColor.rgb; texColor.rgb = (texColor.rgb + u_screenColor.rgb * texColor.a) - (texColor.rgb * u_screenColor.rgb); vec4 col_formask = texColor * u_baseColor; vec4 clipMask = (1.0 - texture2D(s_texture1, v_clipPos.xy / v_clipPos.w)) * u_channelFlag; float maskVal = clipMask.r + clipMask.g + clipMask.b + clipMask.a; col_formask = col_formask * maskVal; gl_FragColor = col_formask;}",Hi="precision mediump float;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform sampler2D s_texture0;uniform sampler2D s_texture1;uniform vec4 u_channelFlag;uniform vec4 u_baseColor;uniform vec4 u_multiplyColor;uniform vec4 u_screenColor;void main(){ vec4 texColor = texture2D(s_texture0, v_texCoord); texColor.rgb = texColor.rgb * u_multiplyColor.rgb; texColor.rgb = (texColor.rgb + u_screenColor.rgb * texColor.a) - (texColor.rgb * u_screenColor.rgb); vec4 col_formask = texColor * u_baseColor; vec4 clipMask = (1.0 - texture2D(s_texture1, v_clipPos.xy / v_clipPos.w)) * u_channelFlag; float maskVal = clipMask.r + clipMask.g + clipMask.b + clipMask.a; col_formask = col_formask * (1.0 - maskVal); gl_FragColor = col_formask;}";var qi;let Wi,Yi;(t=>{t.CubismShaderSet=Oi,t.CubismShader_WebGL=Ai,t.CubismShaderManager_WebGL=Di,t.ShaderNames=ki})(qi||(qi={}));class Ji extends Li{getMaskRenderTexture(){if(this._maskTexture&&null!=this._maskTexture.textures)this._maskTexture.frameNo=this._currentFrameNo;else{null!=this._maskRenderTextures&&this._maskRenderTextures.clear(),this._maskRenderTextures=new g,null!=this._maskColorBuffers&&this._maskColorBuffers.clear(),this._maskColorBuffers=new g;const t=this._clippingMaskBufferSize;for(let e=0;e<this._renderTextureCount;e++)this._maskColorBuffers.pushBack(this.gl.createTexture()),this.gl.bindTexture(this.gl.TEXTURE_2D,this._maskColorBuffers.at(e)),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,t,t,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,null),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.gl.bindTexture(this.gl.TEXTURE_2D,null),this._maskRenderTextures.pushBack(this.gl.createFramebuffer()),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._maskRenderTextures.at(e)),this.gl.framebufferTexture2D(this.gl.FRAMEBUFFER,this.gl.COLOR_ATTACHMENT0,this.gl.TEXTURE_2D,this._maskColorBuffers.at(e),0);this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,Yi),this._maskTexture=new $i(this._currentFrameNo,this._maskRenderTextures)}return this._maskTexture.textures}setGL(t){this.gl=t}constructor(){super(Zi)}setupClippingContext(t,e){this._currentFrameNo++;let i=0;for(let s=0;s<this._clippingContextListForMask.getSize();s++){const e=this._clippingContextListForMask.at(s);this.calcClippedDrawTotalBounds(t,e),e._isUsing&&i++}if(i>0){this.gl.viewport(0,0,this._clippingMaskBufferSize,this._clippingMaskBufferSize),this._currentMaskRenderTexture=this.getMaskRenderTexture().at(0),e.preDraw(),this.setupLayoutBounds(i),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._currentMaskRenderTexture),this._clearedFrameBufferFlags.getSize()!=this._renderTextureCount&&(this._clearedFrameBufferFlags.clear(),this._clearedFrameBufferFlags=new g(this._renderTextureCount));for(let t=0;t<this._clearedFrameBufferFlags.getSize();t++)this._clearedFrameBufferFlags.set(t,!1);for(let i=0;i<this._clippingContextListForMask.getSize();i++){const s=this._clippingContextListForMask.at(i),r=s._allClippedDrawRect,a=s._layoutBounds,n=.05;let o=0,l=0;const u=this.getMaskRenderTexture().at(s._bufferIndex);this._currentMaskRenderTexture!=u&&(this._currentMaskRenderTexture=u,e.preDraw(),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._currentMaskRenderTexture)),this._tmpBoundsOnModel.setRect(r),this._tmpBoundsOnModel.expand(r.width*n,r.height*n),o=a.width/this._tmpBoundsOnModel.width,l=a.height/this._tmpBoundsOnModel.height,this._tmpMatrix.loadIdentity(),this._tmpMatrix.translateRelative(-1,-1),this._tmpMatrix.scaleRelative(2,2),this._tmpMatrix.translateRelative(a.x,a.y),this._tmpMatrix.scaleRelative(o,l),this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x,-this._tmpBoundsOnModel.y),this._tmpMatrixForMask.setMatrix(this._tmpMatrix.getArray()),this._tmpMatrix.loadIdentity(),this._tmpMatrix.translateRelative(a.x,a.y),this._tmpMatrix.scaleRelative(o,l),this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x,-this._tmpBoundsOnModel.y),this._tmpMatrixForDraw.setMatrix(this._tmpMatrix.getArray()),s._matrixForMask.setMatrix(this._tmpMatrixForMask.getArray()),s._matrixForDraw.setMatrix(this._tmpMatrixForDraw.getArray());const h=s._clippingIdCount;for(let i=0;i<h;i++){const r=s._clippingIdList[i];t.getDrawableDynamicFlagVertexPositionsDidChange(r)&&(e.setIsCulling(0!=t.getDrawableCulling(r)),this._clearedFrameBufferFlags.at(s._bufferIndex)||(this.gl.clearColor(1,1,1,1),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this._clearedFrameBufferFlags.set(s._bufferIndex,!0)),e.setClippingContextBufferForMask(s),e.drawMeshWebGL(t,r))}}this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,Yi),e.setClippingContextBufferForMask(null),this.gl.viewport(Wi[0],Wi[1],Wi[2],Wi[3])}}getColorBuffer(){return this._maskColorBuffers}getClippingMaskCount(){return this._clippingContextListForMask.getSize()}}class $i{constructor(t,e){this.frameNo=t,this.textures=e}}class Zi extends E{constructor(t,e,i){super(e,i),this._owner=t}getClippingManager(){return this._owner}setGl(t){this._owner.setGL(t)}}class Ki{setGlEnable(t,e){e?this.gl.enable(t):this.gl.disable(t)}setGlEnableVertexAttribArray(t,e){e?this.gl.enableVertexAttribArray(t):this.gl.disableVertexAttribArray(t)}save(){null!=this.gl?(this._lastArrayBufferBinding=this.gl.getParameter(this.gl.ARRAY_BUFFER_BINDING),this._lastElementArrayBufferBinding=this.gl.getParameter(this.gl.ELEMENT_ARRAY_BUFFER_BINDING),this._lastProgram=this.gl.getParameter(this.gl.CURRENT_PROGRAM),this._lastActiveTexture=this.gl.getParameter(this.gl.ACTIVE_TEXTURE),this.gl.activeTexture(this.gl.TEXTURE1),this._lastTexture1Binding2D=this.gl.getParameter(this.gl.TEXTURE_BINDING_2D),this.gl.activeTexture(this.gl.TEXTURE0),this._lastTexture0Binding2D=this.gl.getParameter(this.gl.TEXTURE_BINDING_2D),this._lastVertexAttribArrayEnabled[0]=this.gl.getVertexAttrib(0,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastVertexAttribArrayEnabled[1]=this.gl.getVertexAttrib(1,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastVertexAttribArrayEnabled[2]=this.gl.getVertexAttrib(2,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastVertexAttribArrayEnabled[3]=this.gl.getVertexAttrib(3,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastScissorTest=this.gl.isEnabled(this.gl.SCISSOR_TEST),this._lastStencilTest=this.gl.isEnabled(this.gl.STENCIL_TEST),this._lastDepthTest=this.gl.isEnabled(this.gl.DEPTH_TEST),this._lastCullFace=this.gl.isEnabled(this.gl.CULL_FACE),this._lastBlend=this.gl.isEnabled(this.gl.BLEND),this._lastFrontFace=this.gl.getParameter(this.gl.FRONT_FACE),this._lastColorMask=this.gl.getParameter(this.gl.COLOR_WRITEMASK),this._lastBlending[0]=this.gl.getParameter(this.gl.BLEND_SRC_RGB),this._lastBlending[1]=this.gl.getParameter(this.gl.BLEND_DST_RGB),this._lastBlending[2]=this.gl.getParameter(this.gl.BLEND_SRC_ALPHA),this._lastBlending[3]=this.gl.getParameter(this.gl.BLEND_DST_ALPHA),this._lastFBO=this.gl.getParameter(this.gl.FRAMEBUFFER_BINDING),this._lastViewport=this.gl.getParameter(this.gl.VIEWPORT)):O("'gl' is null. WebGLRenderingContext is required.\nPlease call 'CubimRenderer_WebGL.startUp' function.")}restore(){null!=this.gl?(this.gl.useProgram(this._lastProgram),this.setGlEnableVertexAttribArray(0,this._lastVertexAttribArrayEnabled[0]),this.setGlEnableVertexAttribArray(1,this._lastVertexAttribArrayEnabled[1]),this.setGlEnableVertexAttribArray(2,this._lastVertexAttribArrayEnabled[2]),this.setGlEnableVertexAttribArray(3,this._lastVertexAttribArrayEnabled[3]),this.setGlEnable(this.gl.SCISSOR_TEST,this._lastScissorTest),this.setGlEnable(this.gl.STENCIL_TEST,this._lastStencilTest),this.setGlEnable(this.gl.DEPTH_TEST,this._lastDepthTest),this.setGlEnable(this.gl.CULL_FACE,this._lastCullFace),this.setGlEnable(this.gl.BLEND,this._lastBlend),this.gl.frontFace(this._lastFrontFace),this.gl.colorMask(this._lastColorMask[0],this._lastColorMask[1],this._lastColorMask[2],this._lastColorMask[3]),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this._lastArrayBufferBinding),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this._lastElementArrayBufferBinding),this.gl.activeTexture(this.gl.TEXTURE1),this.gl.bindTexture(this.gl.TEXTURE_2D,this._lastTexture1Binding2D),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,this._lastTexture0Binding2D),this.gl.activeTexture(this._lastActiveTexture),this.gl.blendFuncSeparate(this._lastBlending[0],this._lastBlending[1],this._lastBlending[2],this._lastBlending[3])):O("'gl' is null. WebGLRenderingContext is required.\nPlease call 'CubimRenderer_WebGL.startUp' function.")}setGl(t){this.gl=t}constructor(){this._lastVertexAttribArrayEnabled=new Array(4),this._lastColorMask=new Array(4),this._lastBlending=new Array(4),this._lastViewport=new Array(4)}}class Qi extends B{initialize(t,e=1){t.isUsingMasking()&&(this._clippingManager=new Ji,this._clippingManager.initialize(t,e)),this._sortedDrawableIndexList.resize(t.getDrawableCount(),0),super.initialize(t)}bindTexture(t,e){this._textures.setValue(t,e)}getBindedTextures(){return this._textures}setClippingMaskBufferSize(t){if(!this._model.isUsingMasking())return;const e=this._clippingManager.getRenderTextureCount();this._clippingManager.release(),this._clippingManager=void 0,this._clippingManager=null,this._clippingManager=new Ji,this._clippingManager.setClippingMaskBufferSize(t),this._clippingManager.initialize(this.getModel(),e)}getClippingMaskBufferSize(){return this._model.isUsingMasking()?this._clippingManager.getClippingMaskBufferSize():-1}getRenderTextureCount(){return this._model.isUsingMasking()?this._clippingManager.getRenderTextureCount():-1}constructor(){super(),this._clippingContextBufferForMask=null,this._clippingContextBufferForDraw=null,this._rendererProfile=new Ki,this.firstDraw=!0,this._textures=new j,this._sortedDrawableIndexList=new g,this._bufferData={vertex:WebGLBuffer=null,uv:WebGLBuffer=null,index:WebGLBuffer=null},this._textures.prepareCapacity(32,!0)}release(){this._clippingManager&&(this._clippingManager.release(),this._clippingManager=void 0,this._clippingManager=null),null!=this.gl&&(this.gl.deleteBuffer(this._bufferData.vertex),this._bufferData.vertex=null,this.gl.deleteBuffer(this._bufferData.uv),this._bufferData.uv=null,this.gl.deleteBuffer(this._bufferData.index),this._bufferData.index=null,this._bufferData=null,this._textures=null)}doDrawModel(){if(null==this.gl)return void O("'gl' is null. WebGLRenderingContext is required.\nPlease call 'CubimRenderer_WebGL.startUp' function.");null!=this._clippingManager&&(this.preDraw(),this.isUsingHighPrecisionMask()?this._clippingManager.setupMatrixForHighPrecision(this.getModel(),!1):this._clippingManager.setupClippingContext(this.getModel(),this)),this.preDraw();const t=this.getModel().getDrawableCount(),e=this.getModel().getDrawableRenderOrders();for(let i=0;i<t;++i){const t=e[i];this._sortedDrawableIndexList.set(t,i)}for(let i=0;i<t;++i){const t=this._sortedDrawableIndexList.at(i);if(!this.getModel().getDrawableDynamicFlagIsVisible(t))continue;const e=null!=this._clippingManager?this._clippingManager.getClippingContextListForDraw().at(t):null;if(null!=e&&this.isUsingHighPrecisionMask()){e._isUsing&&(this.gl.viewport(0,0,this._clippingManager.getClippingMaskBufferSize(),this._clippingManager.getClippingMaskBufferSize()),this.preDraw(),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,e.getClippingManager().getMaskRenderTexture().at(e._bufferIndex)),this.gl.clearColor(1,1,1,1),this.gl.clear(this.gl.COLOR_BUFFER_BIT));{const t=e._clippingIdCount;for(let i=0;i<t;i++){const t=e._clippingIdList[i];this._model.getDrawableDynamicFlagVertexPositionsDidChange(t)&&(this.setIsCulling(0!=this._model.getDrawableCulling(t)),this.setClippingContextBufferForMask(e),this.drawMeshWebGL(this._model,t))}}this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,Yi),this.setClippingContextBufferForMask(null),this.gl.viewport(Wi[0],Wi[1],Wi[2],Wi[3]),this.preDraw()}this.setClippingContextBufferForDraw(e),this.setIsCulling(this.getModel().getDrawableCulling(t)),this.drawMeshWebGL(this._model,t)}}drawMeshWebGL(t,e){this.isCulling()?this.gl.enable(this.gl.CULL_FACE):this.gl.disable(this.gl.CULL_FACE),this.gl.frontFace(this.gl.CCW),this.isGeneratingMask()?Di.getInstance().getShader(this.gl).setupShaderProgramForMask(this,t,e):Di.getInstance().getShader(this.gl).setupShaderProgramForDraw(this,t,e);{const i=t.getDrawableVertexIndexCount(e);this.gl.drawElements(this.gl.TRIANGLES,i,this.gl.UNSIGNED_SHORT,0)}this.gl.useProgram(null),this.setClippingContextBufferForDraw(null),this.setClippingContextBufferForMask(null)}saveProfile(){this._rendererProfile.save()}restoreProfile(){this._rendererProfile.restore()}static doStaticRelease(){Di.deleteInstance()}setRenderState(t,e){Yi=t,Wi=e}preDraw(){if(this.firstDraw&&(this.firstDraw=!1),this.gl.disable(this.gl.SCISSOR_TEST),this.gl.disable(this.gl.STENCIL_TEST),this.gl.disable(this.gl.DEPTH_TEST),this.gl.frontFace(this.gl.CW),this.gl.enable(this.gl.BLEND),this.gl.colorMask(!0,!0,!0,!0),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,null),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,null),this.getAnisotropy()>0&&this._extension)for(let t=0;t<this._textures.getSize();++t)this.gl.bindTexture(this.gl.TEXTURE_2D,this._textures.getValue(t)),this.gl.texParameterf(this.gl.TEXTURE_2D,this._extension.TEXTURE_MAX_ANISOTROPY_EXT,this.getAnisotropy())}setClippingContextBufferForMask(t){this._clippingContextBufferForMask=t}getClippingContextBufferForMask(){return this._clippingContextBufferForMask}setClippingContextBufferForDraw(t){this._clippingContextBufferForDraw=t}getClippingContextBufferForDraw(){return this._clippingContextBufferForDraw}isGeneratingMask(){return null!=this.getClippingContextBufferForMask()}startUp(t){this.gl=t,this._clippingManager&&this._clippingManager.setGL(t),Di.getInstance().setGlContext(t),this._rendererProfile.setGl(t),this._extension=this.gl.getExtension("EXT_texture_filter_anisotropic")||this.gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||this.gl.getExtension("MOZ_EXT_texture_filter_anisotropic")}}var ts;B.staticRelease=()=>{Qi.doStaticRelease()},(t=>{t.CubismClippingContext=Zi,t.CubismClippingManager_WebGL=Ji,t.CubismRenderTextureResource=$i,t.CubismRenderer_WebGL=Qi})(ts||(ts={}));const es=new b;class is extends Ot{constructor(t,i,s){super(),u(this,"settings"),u(this,"options"),u(this,"coreModel"),u(this,"motionManager"),u(this,"parallelMotionManager"),u(this,"lipSync",!0),u(this,"breath",wi.create()),u(this,"eyeBlink"),u(this,"renderer",new Qi),u(this,"idManager"),u(this,"idParamAngleX"),u(this,"idParamAngleY"),u(this,"idParamAngleZ"),u(this,"idParamEyeBallX"),u(this,"idParamEyeBallY"),u(this,"idParamBodyAngleX"),u(this,"idParamBreath"),u(this,"idParamMouthForm"),u(this,"pixelsPerUnit",1),u(this,"modelTransform",new e.Matrix),this.coreModel=t,this.settings=i,this.options=Object.assign({},{breathDepth:1,lipSyncGain:1.5,lipSyncWeight:.4},s),this.idManager=ht.getIdManager(),this.idParamAngleX=this.getIdSafe(bi.ParamAngleX),this.idParamAngleY=this.getIdSafe(bi.ParamAngleY),this.idParamAngleZ=this.getIdSafe(bi.ParamAngleZ),this.idParamEyeBallX=this.getIdSafe(bi.ParamEyeBallX),this.idParamEyeBallY=this.getIdSafe(bi.ParamEyeBallY),this.idParamBodyAngleX=this.getIdSafe(bi.ParamBodyAngleX),this.idParamBreath=this.getIdSafe(bi.ParamBreath),this.idParamMouthForm=this.getIdSafe(bi.ParamMouthForm),this.motionManager=new di(this),this.parallelMotionManager=[],this.init()}init(){var t;super.init();const e=this.settings.getEyeBlinkParameters();if(e.length)if(this.isCubismModelSetting(this.settings))this.eyeBlink=Ei.create(this.settings);else{const i=new g;for(const t of e)i.pushBack(this.idManager.getId(t));const s=Ei.create();null==(t=s.setParameterIds)||t.call(s,i),this.eyeBlink=s}const i=new g;i.pushBack(new Fi(this.idParamAngleX,0,15*this.options.breathDepth,6.5345,.5)),i.pushBack(new Fi(this.idParamAngleY,0,8*this.options.breathDepth,3.5345,.5)),i.pushBack(new Fi(this.idParamAngleZ,0,10*this.options.breathDepth,5.5345,.5)),i.pushBack(new Fi(this.idParamBodyAngleX,0,4*this.options.breathDepth,15.5345,.5)),i.pushBack(new Fi(this.idParamBreath,0,.5,3.2345,.5)),this.breath.setParameters(i),this.renderer.initialize(this.coreModel),this.renderer.setIsPremultipliedAlpha(!0)}getIdSafe(t){return this.idManager.getId(null!=t?t:"")}getSize(){return[this.coreModel.getModel().canvasinfo.CanvasWidth,this.coreModel.getModel().canvasinfo.CanvasHeight]}getLayout(){const t={},e=this.settings.layout;if(e)for(const[i,s]of Object.entries(e)){t[i.charAt(0).toLowerCase()+i.slice(1)]=s}return t}setupLayout(){super.setupLayout(),this.pixelsPerUnit=this.coreModel.getModel().canvasinfo.PixelsPerUnit,this.modelTransform.scale(this.pixelsPerUnit,this.pixelsPerUnit).translate(this.originalWidth/2,this.originalHeight/2)}updateWebGLContext(t,e){this.renderer.firstDraw=!0,this.renderer._bufferData={vertex:null,uv:null,index:null},this.renderer.startUp(t),this.renderer._clippingManager&&(this.renderer._clippingManager._currentFrameNo=e),Di.getInstance().setGlContext(t)}bindTexture(t,e){this.renderer.bindTexture(t,e)}getHitAreaDefs(){var t,e,i;const s=this.settings.json;return At(null!=(i=null!=(e=null!=(t=this.settings.hitAreas)?t:s.HitAreas)?e:s.hitAreas)?i:s.hit_areas,t=>this.coreModel.getDrawableIndex(this.idManager.getId(t)))}getDrawableIDs(){const t=this.coreModel.getDrawableCount(),e=[];for(let i=0;i<t;i++)e.push(this.coreModel.getDrawableId(i).getString().s);return e}getDrawableIndex(t){return this.coreModel.getDrawableIndex(this.idManager.getId(t))}getDrawableVertices(t){if("string"==typeof t){const e=t;if(-1===(t=this.getDrawableIndex(e)))throw new TypeError("Unable to find drawable ID: "+e)}const e=this.coreModel.getDrawableVertices(t).slice();for(let i=0;i<e.length;i+=2)e[i]=e[i]*this.pixelsPerUnit+this.originalWidth/2,e[i+1]=-e[i+1]*this.pixelsPerUnit+this.originalHeight/2;return e}updateTransform(t){this.drawingMatrix.copyFrom(this.modelTransform).prepend(this.localTransform).prepend(t)}update(t,e){var i,s,r,a,n;super.update(t,e),t/=1e3,e/=1e3;const o=this.coreModel,l=this.updateMotions(o,e);if(o.saveParameters(),null==(i=this.motionManager.expressionManager)||i.update(o,e),l||null==(r=null==(s=this.eyeBlink)?void 0:s.updateParameters)||r.call(s,o,t),this.updateFocus(),this.updateNaturalMovements(1e3*t,1e3*e),this.lipSync&&this.motionManager.currentAudio){let t=this.motionManager.mouthSync()*this.options.lipSyncGain;t=Math.pow(t,1.15);t=mt(t,t>0?.1:0,1),this.motionManager.lipSyncIds.forEach(e=>{o.addParameterValueById(this.getIdSafe(e),t,this.options.lipSyncWeight)})}null==(a=this.physics)||a.evaluate(o,t),null==(n=this.pose)||n.updateParameters(o,t),this.emit("beforeModelUpdate"),o.update(),o.loadParameters()}updateFocus(){this.coreModel.addParameterValueById(this.idParamEyeBallX,this.focusController.x),this.coreModel.addParameterValueById(this.idParamEyeBallY,this.focusController.y),this.coreModel.addParameterValueById(this.idParamAngleX,30*this.focusController.x),this.coreModel.addParameterValueById(this.idParamAngleY,30*this.focusController.y),this.coreModel.addParameterValueById(this.idParamAngleZ,this.focusController.x*this.focusController.y*-30),this.coreModel.addParameterValueById(this.idParamBodyAngleX,10*this.focusController.x)}updateFacialEmotion(t){this.coreModel.addParameterValueById(this.idParamMouthForm,t)}updateNaturalMovements(t,e){var i;null==(i=this.breath)||i.updateParameters(this.coreModel,t/1e3)}draw(t){const e=this.drawingMatrix,i=es.getArray();i[0]=e.a,i[1]=e.b,i[4]=-e.c,i[5]=-e.d,i[12]=e.tx,i[13]=e.ty,this.renderer.setMvpMatrix(es);const s=t.getParameter(t.FRAMEBUFFER_BINDING);this.renderer.setRenderState(s,this.viewport),this.renderer.drawModel()}extendParallelMotionManager(t){for(;this.parallelMotionManager.length<t;)this.parallelMotionManager.push(new yi(this))}destroy(){super.destroy(),this.renderer.release(),this.coreModel.release(),this.renderer=void 0,this.coreModel=void 0}isCubismModelSetting(t){return"function"==typeof t.getEyeBlinkParameterCount&&"function"==typeof t.getEyeBlinkParameterId}}class ss{}var rs;(t=>{t.ICubismModelSetting=ss})(rs||(rs={}));var as,ns=(t=>(t[t.FrequestNode_Groups=0]="FrequestNode_Groups",t[t.FrequestNode_Moc=1]="FrequestNode_Moc",t[t.FrequestNode_Motions=2]="FrequestNode_Motions",t[t.FrequestNode_Expressions=3]="FrequestNode_Expressions",t[t.FrequestNode_Textures=4]="FrequestNode_Textures",t[t.FrequestNode_Physics=5]="FrequestNode_Physics",t[t.FrequestNode_Pose=6]="FrequestNode_Pose",t[t.FrequestNode_HitAreas=7]="FrequestNode_HitAreas",t))(ns||{});class os extends ss{constructor(t,e){super(),this.version="Version",this.fileReferences="FileReferences",this.groups="Groups",this.layout="Layout",this.hitAreas="HitAreas",this.moc="Moc",this.textures="Textures",this.physics="Physics",this.pose="Pose",this.expressions="Expressions",this.motions="Motions",this.userData="UserData",this.name="Name",this.filePath="File",this.id="Id",this.ids="Ids",this.target="Target",this.idle="Idle",this.tapBody="TapBody",this.pinchIn="PinchIn",this.pinchOut="PinchOut",this.shake="Shake",this.flickHead="FlickHead",this.parameter="Parameter",this.soundPath="Sound",this.fadeInTime="FadeInTime",this.fadeOutTime="FadeOutTime",this.centerX="CenterX",this.centerY="CenterY",this.x="X",this.y="Y",this.width="Width",this.height="Height",this.lipSync="LipSync",this.eyeBlink="EyeBlink",this.initParameter="init_param",this.initPartsVisible="init_parts_visible",this.val="val",this._json=Y.create(t,e),this.getJson()&&(this._jsonValue=new g,this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.groups)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.moc)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.motions)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.expressions)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.textures)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.physics)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.pose)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.hitAreas)))}release(){Y.delete(this._json),this._jsonValue=null}getJson(){return this._json}getModelFileName(){return this.isExistModelFile()?this._jsonValue.at(1).getRawString():""}getTextureCount(){return this.isExistTextureFiles()?this._jsonValue.at(4).getSize():0}getTextureDirectory(){const t=this._jsonValue.at(4).getValueByIndex(0).getRawString().split("/"),e=t.length-1;let i="";for(let s=0;s<e;s++)i+=t[s],s<e-1&&(i+="/");return i}getTextureFileName(t){return this._jsonValue.at(4).getValueByIndex(t).getRawString()}getHitAreasCount(){return this.isExistHitAreas()?this._jsonValue.at(7).getSize():0}getHitAreaId(t){return ht.getIdManager().getId(this._jsonValue.at(7).getValueByIndex(t).getValueByString(this.id).getRawString())}getHitAreaName(t){return this._jsonValue.at(7).getValueByIndex(t).getValueByString(this.name).getRawString()}getPhysicsFileName(){return this.isExistPhysicsFile()?this._jsonValue.at(5).getRawString():""}getPoseFileName(){return this.isExistPoseFile()?this._jsonValue.at(6).getRawString():""}getExpressionCount(){return this.isExistExpressionFile()?this._jsonValue.at(3).getSize():0}getExpressionName(t){return this._jsonValue.at(3).getValueByIndex(t).getValueByString(this.name).getRawString()}getExpressionFileName(t){return this._jsonValue.at(3).getValueByIndex(t).getValueByString(this.filePath).getRawString()}getMotionGroupCount(){return this.isExistMotionGroups()?this._jsonValue.at(2).getKeys().getSize():0}getMotionGroupName(t){return this.isExistMotionGroups()?this._jsonValue.at(2).getKeys().at(t):null}getMotionCount(t){return this.isExistMotionGroupName(t)?this._jsonValue.at(2).getValueByString(t).getSize():0}getMotionFileName(t,e){return this.isExistMotionGroupName(t)?this._jsonValue.at(2).getValueByString(t).getValueByIndex(e).getValueByString(this.filePath).getRawString():""}getMotionSoundFileName(t,e){return this.isExistMotionSoundFile(t,e)?this._jsonValue.at(2).getValueByString(t).getValueByIndex(e).getValueByString(this.soundPath).getRawString():""}getMotionFadeInTimeValue(t,e){return this.isExistMotionFadeIn(t,e)?this._jsonValue.at(2).getValueByString(t).getValueByIndex(e).getValueByString(this.fadeInTime).toFloat():-1}getMotionFadeOutTimeValue(t,e){return this.isExistMotionFadeOut(t,e)?this._jsonValue.at(2).getValueByString(t).getValueByIndex(e).getValueByString(this.fadeOutTime).toFloat():-1}getUserDataFile(){return this.isExistUserDataFile()?this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.userData).getRawString():""}getLayoutMap(t){const e=this.getJson().getRoot().getValueByString(this.layout).getMap();if(null==e)return!1;let i=!1;for(const s=e.begin();s.notEqual(e.end());s.preIncrement())t.setValue(s.ptr().first,s.ptr().second.toFloat()),i=!0;return i}getEyeBlinkParameterCount(){if(!this.isExistEyeBlinkParameters())return 0;let t=0;for(let e=0;e<this._jsonValue.at(0).getSize();e++){const i=this._jsonValue.at(0).getValueByIndex(e);if(!i.isNull()&&!i.isError()&&i.getValueByString(this.name).getRawString()==this.eyeBlink){t=i.getValueByString(this.ids).getVector().getSize();break}}return t}getEyeBlinkParameterId(t){if(!this.isExistEyeBlinkParameters())return null;for(let e=0;e<this._jsonValue.at(0).getSize();e++){const i=this._jsonValue.at(0).getValueByIndex(e);if(!i.isNull()&&!i.isError()&&i.getValueByString(this.name).getRawString()==this.eyeBlink)return ht.getIdManager().getId(i.getValueByString(this.ids).getValueByIndex(t).getRawString())}return null}getLipSyncParameterCount(){if(!this.isExistLipSyncParameters())return 0;let t=0;for(let e=0;e<this._jsonValue.at(0).getSize();e++){const i=this._jsonValue.at(0).getValueByIndex(e);if(!i.isNull()&&!i.isError()&&i.getValueByString(this.name).getRawString()==this.lipSync){t=i.getValueByString(this.ids).getVector().getSize();break}}return t}getLipSyncParameterId(t){if(!this.isExistLipSyncParameters())return null;for(let e=0;e<this._jsonValue.at(0).getSize();e++){const i=this._jsonValue.at(0).getValueByIndex(e);if(!i.isNull()&&!i.isError()&&i.getValueByString(this.name).getRawString()==this.lipSync)return ht.getIdManager().getId(i.getValueByString(this.ids).getValueByIndex(t).getRawString())}return null}isExistModelFile(){const t=this._jsonValue.at(1);return!t.isNull()&&!t.isError()}isExistTextureFiles(){const t=this._jsonValue.at(4);return!t.isNull()&&!t.isError()}isExistHitAreas(){const t=this._jsonValue.at(7);return!t.isNull()&&!t.isError()}isExistPhysicsFile(){const t=this._jsonValue.at(5);return!t.isNull()&&!t.isError()}isExistPoseFile(){const t=this._jsonValue.at(6);return!t.isNull()&&!t.isError()}isExistExpressionFile(){const t=this._jsonValue.at(3);return!t.isNull()&&!t.isError()}isExistMotionGroups(){const t=this._jsonValue.at(2);return!t.isNull()&&!t.isError()}isExistMotionGroupName(t){const e=this._jsonValue.at(2).getValueByString(t);return!e.isNull()&&!e.isError()}isExistMotionSoundFile(t,e){const i=this._jsonValue.at(2).getValueByString(t).getValueByIndex(e).getValueByString(this.soundPath);return!i.isNull()&&!i.isError()}isExistMotionFadeIn(t,e){const i=this._jsonValue.at(2).getValueByString(t).getValueByIndex(e).getValueByString(this.fadeInTime);return!i.isNull()&&!i.isError()}isExistMotionFadeOut(t,e){const i=this._jsonValue.at(2).getValueByString(t).getValueByIndex(e).getValueByString(this.fadeOutTime);return!i.isNull()&&!i.isError()}isExistUserDataFile(){const t=this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.userData);return!t.isNull()&&!t.isError()}isExistEyeBlinkParameters(){if(this._jsonValue.at(0).isNull()||this._jsonValue.at(0).isError())return!1;for(let t=0;t<this._jsonValue.at(0).getSize();++t)if(this._jsonValue.at(0).getValueByIndex(t).getValueByString(this.name).getRawString()==this.eyeBlink)return!0;return!1}isExistLipSyncParameters(){if(this._jsonValue.at(0).isNull()||this._jsonValue.at(0).isError())return!1;for(let t=0;t<this._jsonValue.at(0).getSize();++t)if(this._jsonValue.at(0).getValueByIndex(t).getValueByString(this.name).getRawString()==this.lipSync)return!0;return!1}}(t=>{t.CubismModelSettingJson=os,t.FrequestNode=ns})(as||(as={}));class ls extends wt{constructor(t){var e,i;if(super(t),u(this,"moc"),u(this,"textures"),u(this,"layout"),u(this,"hitAreas"),u(this,"expressions"),u(this,"motions"),!ls.isValidJSON(t))throw new TypeError("Invalid JSON.");const s=(new TextEncoder).encode(JSON.stringify(t)).buffer;Object.assign(this,new os(s,s.byteLength)),this.moc=t.FileReferences.Moc,this.textures=[...t.FileReferences.Textures],this.pose=t.FileReferences.Pose,this.physics=t.FileReferences.Physics,this.expressions=null==(e=t.FileReferences.Expressions)?void 0:e.filter(t=>!!t&&"string"==typeof t.File),this.motions=null!=(i=t.FileReferences.Motions)?i:t.Motions,this.layout=t.Layout,this.hitAreas=t.HitAreas;const r=this.getFileStem(this.moc);this.setModelName(r,this.name)}static isValidJSON(t){if(!t||"object"!=typeof t)return!1;const e=t.FileReferences;if(!e||"object"!=typeof e||"string"!=typeof e.Moc)return!1;const i=e.Textures;if(!Array.isArray(i)||0===i.length)return!1;if(!i.every(t=>"string"==typeof t))return!1;const s=e.Expressions;return!(void 0!==s&&(!Array.isArray(s)||s.some(t=>!(t=>!!t&&"string"==typeof t.File)(t))))}replaceFiles(t){if(super.replaceFiles(t),this.motions)for(const[e,i]of Object.entries(this.motions))for(let s=0;s<i.length;s++){const r=i[s];(null==r?void 0:r.File)&&(r.File=t(r.File,`motions.${e}[${s}].File`),r.Sound&&(r.Sound=t(r.Sound,`motions.${e}[${s}].Sound`)))}if(this.expressions)for(let e=0;e<this.expressions.length;e++){const i=this.expressions[e];(null==i?void 0:i.File)&&(i.File=t(i.File,`expressions[${e}].File`))}}getEyeBlinkParameters(){var t,e,i;const s=[],r=null!=(e=null==(t=this.getEyeBlinkParameterCount)?void 0:t.call(this))?e:0;if(r>0)for(let a=0;a<r;a++){const t=null==(i=this.getEyeBlinkParameterId)?void 0:i.call(this,a);(null==t?void 0:t.getString)&&s.push(t.getString().s)}else if(Array.isArray(this.json.Groups)){const t=this.json.Groups;for(const e of t)if("EyeBlink"===(null==e?void 0:e.Name)&&Array.isArray(e.Ids))for(const t of e.Ids)"string"==typeof t?s.push(t):(null==t?void 0:t.Id)&&s.push(t.Id)}return s}getLipSyncParameters(){var t,e,i;const s=[],r=null!=(e=null==(t=this.getLipSyncParameterCount)?void 0:t.call(this))?e:0;if(r>0)for(let a=0;a<r;a++){const t=null==(i=this.getLipSyncParameterId)?void 0:i.call(this,a);(null==t?void 0:t.getString)&&s.push(t.getString().s)}else if(Array.isArray(this.json.Groups)){const t=this.json.Groups;for(const e of t)if("LipSync"===(null==e?void 0:e.Name)&&Array.isArray(e.Ids))for(const t of e.Ids)"string"==typeof t?s.push(t):(null==t?void 0:t.Id)&&s.push(t.Id)}return s}}let us;yt(ls,[os]);let hs=20,ds=16;function gs(t={}){null!=t.memorySizeMB&&(ds=t.memorySizeMB)}function cs(){return ht.isStarted()?Promise.resolve():(null!=us||(us=new Promise((t,e)=>{!function i(){try{ms(),t()}catch(s){if(hs--,hs<0)return void e(new Error("Failed to start up Cubism framework.",{cause:s}));ct.log("Cubism","Startup failed, retrying 10ms later..."),setTimeout(i,10)}}()})),us)}function ms(t,e){const i=((t,e)=>{for(var i in e||(e={}))a.call(e,i)&&l(t,i,e[i]);if(r)for(var i of r(e))n.call(e,i)&&l(t,i,e[i]);return t})({logFunction:console.log,loggingLevel:dt.LogLevel_Verbose},t),s=null!=e?e:ds;ht.startUp(i),ht.initialize(pt(s))}const ps="FadeInTime",_s="Link";class fs{static create(t,e){const i=Y.create(t,e);if(!i)return null;const s=new fs,r=i.getRoot();r.getValueByString(ps).isNull()||(s._fadeTimeSeconds=r.getValueByString(ps).toFloat(.5),s._fadeTimeSeconds<0&&(s._fadeTimeSeconds=.5));const a=r.getValueByString("Groups"),n=a.getSize();for(let o=0;o<n;++o){const t=a.getValueByIndex(o),e=t.getSize();let i=0;for(let r=0;r<e;++r){const e=t.getValueByIndex(r),a=new ys,n=ht.getIdManager().getId(e.getValueByString("Id").getRawString());if(a.partId=n,!e.getValueByString(_s).isNull()){const t=e.getValueByString(_s),i=t.getSize();for(let e=0;e<i;++e){const i=new ys,s=ht.getIdManager().getId(t.getValueByIndex(e).getString());i.partId=s,a.link.pushBack(i)}}s._partGroups.pushBack(a.clone()),++i}s._partGroupCounts.pushBack(i)}return Y.delete(i),s}static delete(t){}updateParameters(t,e){t!=this._lastModel&&this.reset(t),this._lastModel=t,e<0&&(e=0);let i=0;for(let s=0;s<this._partGroupCounts.getSize();s++){const r=this._partGroupCounts.at(s);this.doFade(t,e,i,r),i+=r}this.copyPartOpacities(t)}reset(t){let e=0;for(let i=0;i<this._partGroupCounts.getSize();++i){const s=this._partGroupCounts.at(i);for(let i=e;i<e+s;++i){this._partGroups.at(i).initialize(t);const s=this._partGroups.at(i).partIndex,r=this._partGroups.at(i).parameterIndex;if(!(s<0)){t.setPartOpacityByIndex(s,i==e?1:0),t.setParameterValueByIndex(r,i==e?1:0);for(let e=0;e<this._partGroups.at(i).link.getSize();++e)this._partGroups.at(i).link.at(e).initialize(t)}}e+=s}}copyPartOpacities(t){for(let e=0;e<this._partGroups.getSize();++e){const i=this._partGroups.at(e);if(0==i.link.getSize())continue;const s=this._partGroups.at(e).partIndex,r=t.getPartOpacityByIndex(s);for(let e=0;e<i.link.getSize();++e){const s=i.link.at(e).partIndex;s<0||t.setPartOpacityByIndex(s,r)}}}doFade(t,e,i,s){let r=-1,a=1;const n=.5;for(let o=i;o<i+s;++o){const i=this._partGroups.at(o).partIndex,s=this._partGroups.at(o).parameterIndex;if(t.getParameterValueByIndex(s)>.001){if(r>=0)break;if(r=o,0==this._fadeTimeSeconds){a=1;continue}a=t.getPartOpacityByIndex(i),a+=e/this._fadeTimeSeconds,a>1&&(a=1)}}r<0&&(r=0,a=1);for(let o=i;o<i+s;++o){const e=this._partGroups.at(o).partIndex;if(r==o)t.setPartOpacityByIndex(e,a);else{let i,s=t.getPartOpacityByIndex(e);i=a<n?-.5*a/n+1:(1-a)*n/.5;(1-i)*(1-a)>.15&&(i=1-.15/(1-a)),s>i&&(s=i),t.setPartOpacityByIndex(e,s)}}}constructor(){this._fadeTimeSeconds=.5,this._lastModel=null,this._partGroups=new g,this._partGroupCounts=new g}}class ys{constructor(t){if(this.parameterIndex=0,this.partIndex=0,this.link=new g,null!=t){this.partId=t.partId;for(const e=t.link.begin();e.notEqual(t.link.end());e.preIncrement())this.link.pushBack(e.ptr().clone())}}assignment(t){this.partId=t.partId;for(const e=t.link.begin();e.notEqual(t.link.end());e.preIncrement())this.link.pushBack(e.ptr().clone());return this}initialize(t){this.parameterIndex=t.getParameterIndex(this.partId),this.partIndex=t.getPartIndex(this.partId),t.setParameterValueByIndex(this.parameterIndex,1)}clone(){const t=new ys;t.partId=this.partId,t.parameterIndex=this.parameterIndex,t.partIndex=this.partIndex,t.link=new g;for(let e=this.link.begin();e.notEqual(this.link.end());e.increment())t.link.pushBack(e.ptr().clone());return t}}var xs,Cs,Ss;(t=>{t.CubismPose=fs,t.PartData=ys})(xs||(xs={}));class Ms{constructor(t=!1,e=!1){this.isOverridden=t,this.isParameterRepeated=e}}class vs{constructor(t=!1,e=new I){this.isOverridden=t,this.color=e}get isOverwritten(){return this.isOverridden}}class bs{constructor(t=!1,e=new I){this.isOverridden=t,this.color=e}get isOverwritten(){return this.isOverridden}}class Ps{constructor(t=!1,e=!1){this.isOverridden=t,this.isCulling=e}get isOverwritten(){return this.isOverridden}}class Bs{update(){this._model.update(),this._model.drawables.resetDynamicFlags()}getPixelsPerUnit(){return null==this._model?0:this._model.canvasinfo.PixelsPerUnit}getCanvasWidth(){return null==this._model?0:this._model.canvasinfo.CanvasWidth/this._model.canvasinfo.PixelsPerUnit}getCanvasHeight(){return null==this._model?0:this._model.canvasinfo.CanvasHeight/this._model.canvasinfo.PixelsPerUnit}saveParameters(){const t=this._model.parameters.count,e=this._savedParameters.getSize();for(let i=0;i<t;++i)i<e?this._savedParameters.set(i,this._parameterValues[i]):this._savedParameters.pushBack(this._parameterValues[i])}getMultiplyColor(t){if(this.getOverrideFlagForModelMultiplyColors()||this.getOverrideFlagForDrawableMultiplyColors(t))return this._userMultiplyColors.at(t).color;return this.getDrawableMultiplyColor(t)}getScreenColor(t){if(this.getOverrideFlagForModelScreenColors()||this.getOverrideFlagForDrawableScreenColors(t))return this._userScreenColors.at(t).color;return this.getDrawableScreenColor(t)}setMultiplyColorByTextureColor(t,e){this.setMultiplyColorByRGBA(t,e.r,e.g,e.b,e.a)}setMultiplyColorByRGBA(t,e,i,s,r=1){this._userMultiplyColors.at(t).color.r=e,this._userMultiplyColors.at(t).color.g=i,this._userMultiplyColors.at(t).color.b=s,this._userMultiplyColors.at(t).color.a=r}setScreenColorByTextureColor(t,e){this.setScreenColorByRGBA(t,e.r,e.g,e.b,e.a)}setScreenColorByRGBA(t,e,i,s,r=1){this._userScreenColors.at(t).color.r=e,this._userScreenColors.at(t).color.g=i,this._userScreenColors.at(t).color.b=s,this._userScreenColors.at(t).color.a=r}getPartMultiplyColor(t){return this._userPartMultiplyColors.at(t).color}getPartScreenColor(t){return this._userPartScreenColors.at(t).color}setPartColor(t,e,i,s,r,a,n){if(a.at(t).color.r=e,a.at(t).color.g=i,a.at(t).color.b=s,a.at(t).color.a=r,a.at(t).isOverridden)for(let o=0;o<this._partChildDrawables.at(t).getSize();++o){const a=this._partChildDrawables.at(t).at(o);n.at(a).color.r=e,n.at(a).color.g=i,n.at(a).color.b=s,n.at(a).color.a=r}}setPartMultiplyColorByTextureColor(t,e){this.setPartMultiplyColorByRGBA(t,e.r,e.g,e.b,e.a)}setPartMultiplyColorByRGBA(t,e,i,s,r){this.setPartColor(t,e,i,s,r,this._userPartMultiplyColors,this._userMultiplyColors)}setPartScreenColorByTextureColor(t,e){this.setPartScreenColorByRGBA(t,e.r,e.g,e.b,e.a)}setPartScreenColorByRGBA(t,e,i,s,r){this.setPartColor(t,e,i,s,r,this._userPartScreenColors,this._userScreenColors)}getOverrideFlagForModelParameterRepeat(){return this._isOverriddenParameterRepeat}setOverrideFlagForModelParameterRepeat(t){this._isOverriddenParameterRepeat=t}getOverrideFlagForParameterRepeat(t){return this._userParameterRepeatDataList.at(t).isOverridden}setOverrideFlagForParameterRepeat(t,e){this._userParameterRepeatDataList.at(t).isOverridden=e}getRepeatFlagForParameterRepeat(t){return this._userParameterRepeatDataList.at(t).isParameterRepeated}setRepeatFlagForParameterRepeat(t,e){this._userParameterRepeatDataList.at(t).isParameterRepeated=e}getOverwriteFlagForModelMultiplyColors(){return D("getOverwriteFlagForModelMultiplyColors() is a deprecated function. Please use getOverrideFlagForModelMultiplyColors()."),this.getOverrideFlagForModelMultiplyColors()}getOverrideFlagForModelMultiplyColors(){return this._isOverriddenModelMultiplyColors}getOverwriteFlagForModelScreenColors(){return D("getOverwriteFlagForModelScreenColors() is a deprecated function. Please use getOverrideFlagForModelScreenColors()."),this.getOverrideFlagForModelScreenColors()}getOverrideFlagForModelScreenColors(){return this._isOverriddenModelScreenColors}setOverwriteFlagForModelMultiplyColors(t){D("setOverwriteFlagForModelMultiplyColors(value: boolean) is a deprecated function. Please use setOverrideFlagForModelMultiplyColors(value: boolean)."),this.setOverrideFlagForModelMultiplyColors(t)}setOverrideFlagForModelMultiplyColors(t){this._isOverriddenModelMultiplyColors=t}setOverwriteFlagForModelScreenColors(t){D("setOverwriteFlagForModelScreenColors(value: boolean) is a deprecated function. Please use setOverrideFlagForModelScreenColors(value: boolean)."),this.setOverrideFlagForModelScreenColors(t)}setOverrideFlagForModelScreenColors(t){this._isOverriddenModelScreenColors=t}getOverwriteFlagForDrawableMultiplyColors(t){return D("getOverwriteFlagForDrawableMultiplyColors(drawableindex: number) is a deprecated function. Please use getOverrideFlagForDrawableMultiplyColors(drawableindex: number)."),this.getOverrideFlagForDrawableMultiplyColors(t)}getOverrideFlagForDrawableMultiplyColors(t){return this._userMultiplyColors.at(t).isOverridden}getOverwriteFlagForDrawableScreenColors(t){return D("getOverwriteFlagForDrawableScreenColors(drawableindex: number) is a deprecated function. Please use getOverrideFlagForDrawableScreenColors(drawableindex: number)."),this.getOverrideFlagForDrawableScreenColors(t)}getOverrideFlagForDrawableScreenColors(t){return this._userScreenColors.at(t).isOverridden}setOverwriteFlagForDrawableMultiplyColors(t,e){D("setOverwriteFlagForDrawableMultiplyColors(drawableindex: number, value: boolean) is a deprecated function. Please use setOverrideFlagForDrawableMultiplyColors(drawableindex: number, value: boolean)."),this.setOverrideFlagForDrawableMultiplyColors(t,e)}setOverrideFlagForDrawableMultiplyColors(t,e){this._userMultiplyColors.at(t).isOverridden=e}setOverwriteFlagForDrawableScreenColors(t,e){D("setOverwriteFlagForDrawableScreenColors(drawableindex: number, value: boolean) is a deprecated function. Please use setOverrideFlagForDrawableScreenColors(drawableindex: number, value: boolean)."),this.setOverrideFlagForDrawableScreenColors(t,e)}setOverrideFlagForDrawableScreenColors(t,e){this._userScreenColors.at(t).isOverridden=e}getOverwriteColorForPartMultiplyColors(t){return D("getOverwriteColorForPartMultiplyColors(partIndex: number) is a deprecated function. Please use getOverrideColorForPartMultiplyColors(partIndex: number)."),this.getOverrideColorForPartMultiplyColors(t)}getOverrideColorForPartMultiplyColors(t){return this._userPartMultiplyColors.at(t).isOverridden}getOverwriteColorForPartScreenColors(t){return D("getOverwriteColorForPartScreenColors(partIndex: number) is a deprecated function. Please use getOverrideColorForPartScreenColors(partIndex: number)."),this.getOverrideColorForPartScreenColors(t)}getOverrideColorForPartScreenColors(t){return this._userPartScreenColors.at(t).isOverridden}setOverwriteColorForPartColors(t,e,i,s){D("setOverwriteColorForPartColors(partIndex: number, value: boolean, partColors: csmVector<PartColorData>, drawableColors: csmVector<DrawableColorData>) is a deprecated function. Please use setOverrideColorForPartColors(partIndex: number, value: boolean, partColors: csmVector<PartColorData>, drawableColors: csmVector<DrawableColorData>)."),this.setOverrideColorForPartColors(t,e,i,s)}setOverrideColorForPartColors(t,e,i,s){i.at(t).isOverridden=e;for(let r=0;r<this._partChildDrawables.at(t).getSize();++r){const a=this._partChildDrawables.at(t).at(r);s.at(a).isOverridden=e,e&&(s.at(a).color.r=i.at(t).color.r,s.at(a).color.g=i.at(t).color.g,s.at(a).color.b=i.at(t).color.b,s.at(a).color.a=i.at(t).color.a)}}setOverwriteColorForPartMultiplyColors(t,e){D("setOverwriteColorForPartMultiplyColors(partIndex: number, value: boolean) is a deprecated function. Please use setOverrideColorForPartMultiplyColors(partIndex: number, value: boolean)."),this.setOverrideColorForPartMultiplyColors(t,e)}setOverrideColorForPartMultiplyColors(t,e){this._userPartMultiplyColors.at(t).isOverridden=e,this.setOverrideColorForPartColors(t,e,this._userPartMultiplyColors,this._userMultiplyColors)}setOverwriteColorForPartScreenColors(t,e){D("setOverwriteColorForPartScreenColors(partIndex: number, value: boolean) is a deprecated function. Please use setOverrideColorForPartScreenColors(partIndex: number, value: boolean)."),this.setOverrideColorForPartScreenColors(t,e)}setOverrideColorForPartScreenColors(t,e){this._userPartScreenColors.at(t).isOverridden=e,this.setOverrideColorForPartColors(t,e,this._userPartScreenColors,this._userScreenColors)}getDrawableCulling(t){if(this.getOverrideFlagForModelCullings()||this.getOverrideFlagForDrawableCullings(t))return this._userCullings.at(t).isCulling;const e=this._model.drawables.constantFlags;return!Live2DCubismCore.Utils.hasIsDoubleSidedBit(e[t])}setDrawableCulling(t,e){this._userCullings.at(t).isCulling=e}getOverwriteFlagForModelCullings(){return D("getOverwriteFlagForModelCullings() is a deprecated function. Please use getOverrideFlagForModelCullings()."),this.getOverrideFlagForModelCullings()}getOverrideFlagForModelCullings(){return this._isOverriddenCullings}setOverwriteFlagForModelCullings(t){D("setOverwriteFlagForModelCullings(isOverriddenCullings: boolean) is a deprecated function. Please use setOverrideFlagForModelCullings(isOverriddenCullings: boolean)."),this.setOverrideFlagForModelCullings(t)}setOverrideFlagForModelCullings(t){this._isOverriddenCullings=t}getOverwriteFlagForDrawableCullings(t){return D("getOverwriteFlagForDrawableCullings(drawableIndex: number) is a deprecated function. Please use getOverrideFlagForDrawableCullings(drawableIndex: number)."),this.getOverrideFlagForDrawableCullings(t)}getOverrideFlagForDrawableCullings(t){return this._userCullings.at(t).isOverridden}setOverwriteFlagForDrawableCullings(t,e){D("setOverwriteFlagForDrawableCullings(drawableIndex: number, isOverriddenCullings: boolean) is a deprecated function. Please use setOverrideFlagForDrawableCullings(drawableIndex: number, isOverriddenCullings: boolean)."),this.setOverrideFlagForDrawableCullings(t,e)}setOverrideFlagForDrawableCullings(t,e){this._userCullings.at(t).isOverridden=e}getModelOapcity(){return this._modelOpacity}setModelOapcity(t){this._modelOpacity=t}getModel(){return this._model}getPartIndex(t){let e;const i=this._model.parts.count;for(e=0;e<i;++e)if(t==this._partIds.at(e))return e;return this._notExistPartId.isExist(t)?this._notExistPartId.getValue(t):(e=i+this._notExistPartId.getSize(),this._notExistPartId.setValue(t,e),this._notExistPartOpacities.appendKey(e),e)}getPartId(t){const e=this._model.parts.ids[t];return ht.getIdManager().getId(e)}getPartCount(){return this._model.parts.count}getPartParentPartIndices(){return this._model.parts.parentIndices}setPartOpacityByIndex(t,e){this._notExistPartOpacities.isExist(t)?this._notExistPartOpacities.setValue(t,e):(L(0<=t&&t<this.getPartCount()),this._partOpacities[t]=e)}setPartOpacityById(t,e){const i=this.getPartIndex(t);i<0||this.setPartOpacityByIndex(i,e)}getPartOpacityByIndex(t){return this._notExistPartOpacities.isExist(t)?this._notExistPartOpacities.getValue(t):(L(0<=t&&t<this.getPartCount()),this._partOpacities[t])}getPartOpacityById(t){const e=this.getPartIndex(t);return e<0?0:this.getPartOpacityByIndex(e)}getParameterIndex(t){let e;const i=this._model.parameters.count;for(e=0;e<i;++e)if(t==this._parameterIds.at(e))return e;return this._notExistParameterId.isExist(t)?this._notExistParameterId.getValue(t):(e=this._model.parameters.count+this._notExistParameterId.getSize(),this._notExistParameterId.setValue(t,e),this._notExistParameterValues.appendKey(e),e)}getParameterCount(){return this._model.parameters.count}getParameterType(t){return this._model.parameters.types[t]}getParameterMaximumValue(t){return this._model.parameters.maximumValues[t]}getParameterMinimumValue(t){return this._model.parameters.minimumValues[t]}getParameterDefaultValue(t){return this._model.parameters.defaultValues[t]}getParameterId(t){return ht.getIdManager().getId(this._model.parameters.ids[t])}getParameterValueByIndex(t){return this._notExistParameterValues.isExist(t)?this._notExistParameterValues.getValue(t):(L(0<=t&&t<this.getParameterCount()),this._parameterValues[t])}getParameterValueById(t){const e=this.getParameterIndex(t);return this.getParameterValueByIndex(e)}setParameterValueByIndex(t,e,i=1){this._notExistParameterValues.isExist(t)?this._notExistParameterValues.setValue(t,1==i?e:this._notExistParameterValues.getValue(t)*(1-i)+e*i):(L(0<=t&&t<this.getParameterCount()),e=this.isRepeat(t)?this.getParameterRepeatValue(t,e):this.getParameterClampValue(t,e),this._parameterValues[t]=1==i?e:this._parameterValues[t]=this._parameterValues[t]*(1-i)+e*i)}setParameterValueById(t,e,i=1){const s=this.getParameterIndex(t);this.setParameterValueByIndex(s,e,i)}addParameterValueByIndex(t,e,i=1){this.setParameterValueByIndex(t,this.getParameterValueByIndex(t)+e*i)}addParameterValueById(t,e,i=1){const s=this.getParameterIndex(t);this.addParameterValueByIndex(s,e,i)}isRepeat(t){if(this._notExistParameterValues.isExist(t))return!1;let e;return L(0<=t&&t<this.getParameterCount()),e=this._isOverriddenParameterRepeat||this._userParameterRepeatDataList.at(t).isOverridden?this._userParameterRepeatDataList.at(t).isParameterRepeated:0!=this._model.parameters.repeats[t],e}getParameterRepeatValue(t,e){if(this._notExistParameterValues.isExist(t))return e;L(0<=t&&t<this.getParameterCount());const i=this._model.parameters.maximumValues[t],s=this._model.parameters.minimumValues[t],r=i-s;if(i<e){const t=Ce.mod(e-i,r);e=Number.isNaN(t)?i:s+t}if(e<s){const t=Ce.mod(s-e,r);e=Number.isNaN(t)?s:i-t}return e}getParameterClampValue(t,e){if(this._notExistParameterValues.isExist(t))return e;L(0<=t&&t<this.getParameterCount());const i=this._model.parameters.maximumValues[t],s=this._model.parameters.minimumValues[t];return Ce.clamp(e,s,i)}getParameterRepeats(t){return 0!=this._model.parameters.repeats[t]}multiplyParameterValueById(t,e,i=1){const s=this.getParameterIndex(t);this.multiplyParameterValueByIndex(s,e,i)}multiplyParameterValueByIndex(t,e,i=1){this.setParameterValueByIndex(t,this.getParameterValueByIndex(t)*(1+(e-1)*i))}getDrawableIndex(t){const e=this._model.drawables.count;for(let i=0;i<e;++i)if(this._drawableIds.at(i)==t)return i;return-1}getDrawableCount(){return this._model.drawables.count}getDrawableId(t){const e=this._model.drawables.ids;return ht.getIdManager().getId(e[t])}getDrawableRenderOrders(){return this._model.drawables.renderOrders}getDrawableTextureIndices(t){return this.getDrawableTextureIndex(t)}getDrawableTextureIndex(t){return this._model.drawables.textureIndices[t]}getDrawableDynamicFlagVertexPositionsDidChange(t){const e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasVertexPositionsDidChangeBit(e[t])}getDrawableVertexIndexCount(t){return this._model.drawables.indexCounts[t]}getDrawableVertexCount(t){return this._model.drawables.vertexCounts[t]}getDrawableVertices(t){return this.getDrawableVertexPositions(t)}getDrawableVertexIndices(t){return this._model.drawables.indices[t]}getDrawableVertexPositions(t){return this._model.drawables.vertexPositions[t]}getDrawableVertexUvs(t){return this._model.drawables.vertexUvs[t]}getDrawableOpacity(t){return this._model.drawables.opacities[t]}getDrawableMultiplyColor(t){const e=this._model.drawables.multiplyColors,i=4*t,s=new I;return s.r=e[i],s.g=e[i+1],s.b=e[i+2],s.a=e[i+3],s}getDrawableScreenColor(t){const e=this._model.drawables.screenColors,i=4*t,s=new I;return s.r=e[i],s.g=e[i+1],s.b=e[i+2],s.a=e[i+3],s}getDrawableParentPartIndex(t){return this._model.drawables.parentPartIndices[t]}getDrawableBlendMode(t){const e=this._model.drawables.constantFlags;return Live2DCubismCore.Utils.hasBlendAdditiveBit(e[t])?F.CubismBlendMode_Additive:Live2DCubismCore.Utils.hasBlendMultiplicativeBit(e[t])?F.CubismBlendMode_Multiplicative:F.CubismBlendMode_Normal}getDrawableInvertedMaskBit(t){const e=this._model.drawables.constantFlags;return Live2DCubismCore.Utils.hasIsInvertedMaskBit(e[t])}getDrawableMasks(){return this._model.drawables.masks}getDrawableMaskCounts(){return this._model.drawables.maskCounts}isUsingMasking(){for(let t=0;t<this._model.drawables.count;++t)if(!(this._model.drawables.maskCounts[t]<=0))return!0;return!1}getDrawableDynamicFlagIsVisible(t){const e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasIsVisibleBit(e[t])}getDrawableDynamicFlagVisibilityDidChange(t){const e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasVisibilityDidChangeBit(e[t])}getDrawableDynamicFlagOpacityDidChange(t){const e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasOpacityDidChangeBit(e[t])}getDrawableDynamicFlagRenderOrderDidChange(t){const e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasRenderOrderDidChangeBit(e[t])}getDrawableDynamicFlagBlendColorDidChange(t){const e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasBlendColorDidChangeBit(e[t])}loadParameters(){let t=this._model.parameters.count;const e=this._savedParameters.getSize();t>e&&(t=e);for(let i=0;i<t;++i)this._parameterValues[i]=this._savedParameters.at(i)}initialize(){L(this._model),this._parameterValues=this._model.parameters.values,this._partOpacities=this._model.parts.opacities,this._parameterMaximumValues=this._model.parameters.maximumValues,this._parameterMinimumValues=this._model.parameters.minimumValues;{const t=this._model.parameters.ids,e=this._model.parameters.count;this._parameterIds.prepareCapacity(e),this._userParameterRepeatDataList.prepareCapacity(e);for(let i=0;i<e;++i)this._parameterIds.pushBack(ht.getIdManager().getId(t[i])),this._userParameterRepeatDataList.pushBack(new Ms(!1,!1))}const t=this._model.parts.count;{const e=this._model.parts.ids;this._partIds.prepareCapacity(t);for(let i=0;i<t;++i)this._partIds.pushBack(ht.getIdManager().getId(e[i]));this._userPartMultiplyColors.prepareCapacity(t),this._userPartScreenColors.prepareCapacity(t),this._partChildDrawables.prepareCapacity(t)}{const e=this._model.drawables.ids,i=this._model.drawables.count;this._userMultiplyColors.prepareCapacity(i),this._userScreenColors.prepareCapacity(i),this._userCullings.prepareCapacity(i);const s=new Ps(!1,!1);for(let r=0;r<t;++r){const t=new I(1,1,1,1),e=new I(0,0,0,1),s=new bs(!1,t),a=new bs(!1,e);this._userPartMultiplyColors.pushBack(s),this._userPartScreenColors.pushBack(a),this._partChildDrawables.pushBack(new g),this._partChildDrawables.at(r).prepareCapacity(i)}for(let t=0;t<i;++t){const i=new I(1,1,1,1),r=new I(0,0,0,1),a=new vs(!1,i),n=new vs(!1,r);this._drawableIds.pushBack(ht.getIdManager().getId(e[t])),this._userMultiplyColors.pushBack(a),this._userScreenColors.pushBack(n),this._userCullings.pushBack(s);const o=this.getDrawableParentPartIndex(t);o>=0&&this._partChildDrawables.at(o).pushBack(t)}}}constructor(t){this._model=t,this._parameterValues=null,this._parameterMaximumValues=null,this._parameterMinimumValues=null,this._partOpacities=null,this._savedParameters=new g,this._parameterIds=new g,this._drawableIds=new g,this._partIds=new g,this._isOverriddenParameterRepeat=!0,this._isOverriddenModelMultiplyColors=!1,this._isOverriddenModelScreenColors=!1,this._isOverriddenCullings=!1,this._modelOpacity=1,this._userParameterRepeatDataList=new g,this._userMultiplyColors=new g,this._userScreenColors=new g,this._userCullings=new g,this._userPartMultiplyColors=new g,this._userPartScreenColors=new g,this._partChildDrawables=new g,this._notExistPartId=new j,this._notExistParameterId=new j,this._notExistParameterValues=new j,this._notExistPartOpacities=new j}release(){this._model.release(),this._model=null}}(t=>{t.CubismModel=Bs})(Cs||(Cs={}));class ws{static create(t,e){let i=null;if(e){if(!this.hasMocConsistency(t))return O("Inconsistent MOC3."),i}const s=Live2DCubismCore.Moc.fromArrayBuffer(t);return s&&(i=new ws(s),i._mocVersion=Live2DCubismCore.Version.csmGetMocVersion(s,t)),i}static delete(t){t._moc._release(),t._moc=null,t=null}createModel(){let t=null;const e=Live2DCubismCore.Model.fromMoc(this._moc);return e&&(t=new Bs(e),t.initialize(),++this._modelCount),t}deleteModel(t){null!=t&&(t.release(),t=null,--this._modelCount)}constructor(t){this._moc=t,this._modelCount=0,this._mocVersion=0}release(){L(0==this._modelCount),this._moc._release(),this._moc=null}getLatestMocVersion(){return Live2DCubismCore.Version.csmGetLatestMocVersion()}getMocVersion(){return this._mocVersion}static hasMocConsistency(t){return 1===Live2DCubismCore.Moc.prototype.hasMocConsistency(t)}}(t=>{t.CubismMoc=ws})(Ss||(Ss={}));var Fs,Is=(t=>(t[t.CubismPhysicsTargetType_Parameter=0]="CubismPhysicsTargetType_Parameter",t))(Is||{}),Es=(t=>(t[t.CubismPhysicsSource_X=0]="CubismPhysicsSource_X",t[t.CubismPhysicsSource_Y=1]="CubismPhysicsSource_Y",t[t.CubismPhysicsSource_Angle=2]="CubismPhysicsSource_Angle",t))(Es||{});class Vs{constructor(){this.gravity=new fe(0,0),this.wind=new fe(0,0)}}class Rs{}class Ls{}class Ts{constructor(){this.initialPosition=new fe(0,0),this.position=new fe(0,0),this.lastPosition=new fe(0,0),this.lastGravity=new fe(0,0),this.force=new fe(0,0),this.velocity=new fe(0,0)}}class As{constructor(){this.normalizationPosition=new Ls,this.normalizationAngle=new Ls}}class Ds{constructor(){this.source=new Rs}}class Os{constructor(){this.destination=new Rs,this.translationScale=new fe(0,0)}}class ks{constructor(){this.settings=new g,this.inputs=new g,this.outputs=new g,this.particles=new g,this.gravity=new fe(0,0),this.wind=new fe(0,0),this.fps=0}}(t=>{t.CubismPhysicsInput=Ds,t.CubismPhysicsNormalization=Ls,t.CubismPhysicsOutput=Os,t.CubismPhysicsParameter=Rs,t.CubismPhysicsParticle=Ts,t.CubismPhysicsRig=ks,t.CubismPhysicsSource=Es,t.CubismPhysicsSubRig=As,t.CubismPhysicsTargetType=Is,t.PhysicsJsonEffectiveForces=Vs})(Fs||(Fs={}));const Ns="Position",Us="Angle",zs="Type",js="Meta",Gs="EffectiveForces",Xs="Gravity",Hs="Wind",qs="PhysicsSettings",Ws="Normalization",Ys="Minimum",Js="Maximum",$s="Default",Zs="Reflect",Ks="Weight",Qs="Input",tr="Output",er="Vertices";class ir{constructor(t,e){this._json=Y.create(t,e)}release(){Y.delete(this._json)}getGravity(){const t=new fe(0,0);return t.x=this._json.getRoot().getValueByString(js).getValueByString(Gs).getValueByString(Xs).getValueByString("X").toFloat(),t.y=this._json.getRoot().getValueByString(js).getValueByString(Gs).getValueByString(Xs).getValueByString("Y").toFloat(),t}getWind(){const t=new fe(0,0);return t.x=this._json.getRoot().getValueByString(js).getValueByString(Gs).getValueByString(Hs).getValueByString("X").toFloat(),t.y=this._json.getRoot().getValueByString(js).getValueByString(Gs).getValueByString(Hs).getValueByString("Y").toFloat(),t}getFps(){return this._json.getRoot().getValueByString(js).getValueByString("Fps").toFloat(0)}getSubRigCount(){return this._json.getRoot().getValueByString(js).getValueByString("PhysicsSettingCount").toInt()}getTotalInputCount(){return this._json.getRoot().getValueByString(js).getValueByString("TotalInputCount").toInt()}getTotalOutputCount(){return this._json.getRoot().getValueByString(js).getValueByString("TotalOutputCount").toInt()}getVertexCount(){return this._json.getRoot().getValueByString(js).getValueByString("VertexCount").toInt()}getNormalizationPositionMinimumValue(t){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(Ws).getValueByString(Ns).getValueByString(Ys).toFloat()}getNormalizationPositionMaximumValue(t){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(Ws).getValueByString(Ns).getValueByString(Js).toFloat()}getNormalizationPositionDefaultValue(t){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(Ws).getValueByString(Ns).getValueByString($s).toFloat()}getNormalizationAngleMinimumValue(t){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(Ws).getValueByString(Us).getValueByString(Ys).toFloat()}getNormalizationAngleMaximumValue(t){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(Ws).getValueByString(Us).getValueByString(Js).toFloat()}getNormalizationAngleDefaultValue(t){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(Ws).getValueByString(Us).getValueByString($s).toFloat()}getInputCount(t){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(Qs).getVector().getSize()}getInputWeight(t,e){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(Qs).getValueByIndex(e).getValueByString(Ks).toFloat()}getInputReflect(t,e){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(Qs).getValueByIndex(e).getValueByString(Zs).toBoolean()}getInputType(t,e){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(Qs).getValueByIndex(e).getValueByString(zs).getRawString()}getInputSourceId(t,e){return ht.getIdManager().getId(this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(Qs).getValueByIndex(e).getValueByString("Source").getValueByString("Id").getRawString())}getOutputCount(t){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(tr).getVector().getSize()}getOutputVertexIndex(t,e){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(tr).getValueByIndex(e).getValueByString("VertexIndex").toInt()}getOutputAngleScale(t,e){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(tr).getValueByIndex(e).getValueByString("Scale").toFloat()}getOutputWeight(t,e){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(tr).getValueByIndex(e).getValueByString(Ks).toFloat()}getOutputDestinationId(t,e){return ht.getIdManager().getId(this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(tr).getValueByIndex(e).getValueByString("Destination").getValueByString("Id").getRawString())}getOutputType(t,e){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(tr).getValueByIndex(e).getValueByString(zs).getRawString()}getOutputReflect(t,e){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(tr).getValueByIndex(e).getValueByString(Zs).toBoolean()}getParticleCount(t){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(er).getVector().getSize()}getParticleMobility(t,e){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(er).getValueByIndex(e).getValueByString("Mobility").toFloat()}getParticleDelay(t,e){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(er).getValueByIndex(e).getValueByString("Delay").toFloat()}getParticleAcceleration(t,e){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(er).getValueByIndex(e).getValueByString("Acceleration").toFloat()}getParticleRadius(t,e){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(er).getValueByIndex(e).getValueByString("Radius").toFloat()}getParticlePosition(t,e){const i=new fe(0,0);return i.x=this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(er).getValueByIndex(e).getValueByString(Ns).getValueByString("X").toFloat(),i.y=this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(er).getValueByIndex(e).getValueByString(Ns).getValueByString("Y").toFloat(),i}}var sr;(t=>{t.CubismPhysicsJson=ir})(sr||(sr={}));const rr="Angle";class ar{static create(t,e){const i=new ar;return i.parse(t,e),i._physicsRig.gravity.y=0,i}static delete(t){null!=t&&(t.release(),t=null)}parse(t,e){this._physicsRig=new ks;let i=new ir(t,e);this._physicsRig.gravity=i.getGravity(),this._physicsRig.wind=i.getWind(),this._physicsRig.subRigCount=i.getSubRigCount(),this._physicsRig.fps=i.getFps(),this._physicsRig.settings.updateSize(this._physicsRig.subRigCount,As,!0),this._physicsRig.inputs.updateSize(i.getTotalInputCount(),Ds,!0),this._physicsRig.outputs.updateSize(i.getTotalOutputCount(),Os,!0),this._physicsRig.particles.updateSize(i.getVertexCount(),Ts,!0),this._currentRigOutputs.clear(),this._previousRigOutputs.clear();let s=0,r=0,a=0;for(let n=0;n<this._physicsRig.settings.getSize();++n){this._physicsRig.settings.at(n).normalizationPosition.minimum=i.getNormalizationPositionMinimumValue(n),this._physicsRig.settings.at(n).normalizationPosition.maximum=i.getNormalizationPositionMaximumValue(n),this._physicsRig.settings.at(n).normalizationPosition.defalut=i.getNormalizationPositionDefaultValue(n),this._physicsRig.settings.at(n).normalizationAngle.minimum=i.getNormalizationAngleMinimumValue(n),this._physicsRig.settings.at(n).normalizationAngle.maximum=i.getNormalizationAngleMaximumValue(n),this._physicsRig.settings.at(n).normalizationAngle.defalut=i.getNormalizationAngleDefaultValue(n),this._physicsRig.settings.at(n).inputCount=i.getInputCount(n),this._physicsRig.settings.at(n).baseInputIndex=s;for(let r=0;r<this._physicsRig.settings.at(n).inputCount;++r)this._physicsRig.inputs.at(s+r).sourceParameterIndex=-1,this._physicsRig.inputs.at(s+r).weight=i.getInputWeight(n,r),this._physicsRig.inputs.at(s+r).reflect=i.getInputReflect(n,r),"X"==i.getInputType(n,r)?(this._physicsRig.inputs.at(s+r).type=Es.CubismPhysicsSource_X,this._physicsRig.inputs.at(s+r).getNormalizedParameterValue=lr):"Y"==i.getInputType(n,r)?(this._physicsRig.inputs.at(s+r).type=Es.CubismPhysicsSource_Y,this._physicsRig.inputs.at(s+r).getNormalizedParameterValue=ur):i.getInputType(n,r)==rr&&(this._physicsRig.inputs.at(s+r).type=Es.CubismPhysicsSource_Angle,this._physicsRig.inputs.at(s+r).getNormalizedParameterValue=hr),this._physicsRig.inputs.at(s+r).source.targetType=Is.CubismPhysicsTargetType_Parameter,this._physicsRig.inputs.at(s+r).source.id=i.getInputSourceId(n,r);s+=this._physicsRig.settings.at(n).inputCount,this._physicsRig.settings.at(n).outputCount=i.getOutputCount(n),this._physicsRig.settings.at(n).baseOutputIndex=r;const t=new or;t.outputs.resize(this._physicsRig.settings.at(n).outputCount);const e=new or;e.outputs.resize(this._physicsRig.settings.at(n).outputCount);for(let s=0;s<this._physicsRig.settings.at(n).outputCount;++s)t.outputs.set(s,0),e.outputs.set(s,0),this._physicsRig.outputs.at(r+s).destinationParameterIndex=-1,this._physicsRig.outputs.at(r+s).vertexIndex=i.getOutputVertexIndex(n,s),this._physicsRig.outputs.at(r+s).angleScale=i.getOutputAngleScale(n,s),this._physicsRig.outputs.at(r+s).weight=i.getOutputWeight(n,s),this._physicsRig.outputs.at(r+s).destination.targetType=Is.CubismPhysicsTargetType_Parameter,this._physicsRig.outputs.at(r+s).destination.id=i.getOutputDestinationId(n,s),"X"==i.getOutputType(n,s)?(this._physicsRig.outputs.at(r+s).type=Es.CubismPhysicsSource_X,this._physicsRig.outputs.at(r+s).getValue=dr,this._physicsRig.outputs.at(r+s).getScale=pr):"Y"==i.getOutputType(n,s)?(this._physicsRig.outputs.at(r+s).type=Es.CubismPhysicsSource_Y,this._physicsRig.outputs.at(r+s).getValue=gr,this._physicsRig.outputs.at(r+s).getScale=_r):i.getOutputType(n,s)==rr&&(this._physicsRig.outputs.at(r+s).type=Es.CubismPhysicsSource_Angle,this._physicsRig.outputs.at(r+s).getValue=cr,this._physicsRig.outputs.at(r+s).getScale=fr),this._physicsRig.outputs.at(r+s).reflect=i.getOutputReflect(n,s);this._currentRigOutputs.pushBack(t),this._previousRigOutputs.pushBack(e),r+=this._physicsRig.settings.at(n).outputCount,this._physicsRig.settings.at(n).particleCount=i.getParticleCount(n),this._physicsRig.settings.at(n).baseParticleIndex=a;for(let s=0;s<this._physicsRig.settings.at(n).particleCount;++s)this._physicsRig.particles.at(a+s).mobility=i.getParticleMobility(n,s),this._physicsRig.particles.at(a+s).delay=i.getParticleDelay(n,s),this._physicsRig.particles.at(a+s).acceleration=i.getParticleAcceleration(n,s),this._physicsRig.particles.at(a+s).radius=i.getParticleRadius(n,s),this._physicsRig.particles.at(a+s).position=i.getParticlePosition(n,s);a+=this._physicsRig.settings.at(n).particleCount}this.initialize(),i.release(),i=void 0,i=null}stabilization(t){var e,i,s,r;let a,n,o,l;const u=new fe;let h,d,g,c;const m=t.getModel().parameters.values,p=t.getModel().parameters.maximumValues,_=t.getModel().parameters.minimumValues,f=t.getModel().parameters.defaultValues;(null!=(i=null==(e=this._parameterCaches)?void 0:e.length)?i:0)<t.getParameterCount()&&(this._parameterCaches=new Float32Array(t.getParameterCount())),(null!=(r=null==(s=this._parameterInputCaches)?void 0:s.length)?r:0)<t.getParameterCount()&&(this._parameterInputCaches=new Float32Array(t.getParameterCount()));for(let y=0;y<t.getParameterCount();++y)this._parameterCaches[y]=m[y],this._parameterInputCaches[y]=m[y];for(let y=0;y<this._physicsRig.subRigCount;++y){a={angle:0},u.x=0,u.y=0,h=this._physicsRig.settings.at(y),d=this._physicsRig.inputs.get(h.baseInputIndex),g=this._physicsRig.outputs.get(h.baseOutputIndex),c=this._physicsRig.particles.get(h.baseParticleIndex);for(let e=0;e<h.inputCount;++e)n=d[e].weight/100,-1==d[e].sourceParameterIndex&&(d[e].sourceParameterIndex=t.getParameterIndex(d[e].source.id)),d[e].getNormalizedParameterValue(u,a,m[d[e].sourceParameterIndex],_[d[e].sourceParameterIndex],p[d[e].sourceParameterIndex],f[d[e].sourceParameterIndex],h.normalizationPosition,h.normalizationAngle,d[e].reflect,n),this._parameterCaches[d[e].sourceParameterIndex]=m[d[e].sourceParameterIndex];o=Ce.degreesToRadian(-a.angle),u.x=u.x*Ce.cos(o)-u.y*Ce.sin(o),u.y=u.x*Ce.sin(o)+u.y*Ce.cos(o),xr(c,h.particleCount,u,a.angle,this._options.wind,.001*h.normalizationPosition.maximum);for(let e=0;e<h.outputCount;++e){const i=g[e].vertexIndex;if(-1==g[e].destinationParameterIndex&&(g[e].destinationParameterIndex=t.getParameterIndex(g[e].destination.id)),i<1||i>=h.particleCount)continue;let s=new fe;s=c[i].position.substract(c[i-1].position),l=g[e].getValue(s,c,i,g[e].reflect,this._options.gravity),this._currentRigOutputs.at(y).outputs.set(e,l),this._previousRigOutputs.at(y).outputs.set(e,l);const r=g[e].destinationParameterIndex,a=!Float32Array.prototype.slice&&"subarray"in Float32Array.prototype?JSON.parse(JSON.stringify(m.subarray(r))):m.slice(r);Cr(a,_[r],p[r],l,g[e]);for(let t=r,e=0;t<this._parameterCaches.length;t++,e++)m[t]=this._parameterCaches[t]=a[e]}}}evaluate(t,e){var i,s,r,a;let n,o,l,u;const h=new fe;let d,g,c,m;if(0>=e)return;const p=t.getModel().parameters.values,_=t.getModel().parameters.maximumValues,f=t.getModel().parameters.minimumValues,y=t.getModel().parameters.defaultValues;let x;if(this._currentRemainTime+=e,this._currentRemainTime>5&&(this._currentRemainTime=0),(null!=(s=null==(i=this._parameterCaches)?void 0:i.length)?s:0)<t.getParameterCount()&&(this._parameterCaches=new Float32Array(t.getParameterCount())),(null!=(a=null==(r=this._parameterInputCaches)?void 0:r.length)?a:0)<t.getParameterCount()){this._parameterInputCaches=new Float32Array(t.getParameterCount());for(let e=0;e<t.getParameterCount();++e)this._parameterInputCaches[e]=p[e]}for(x=this._physicsRig.fps>0?1/this._physicsRig.fps:e;this._currentRemainTime>=x;){for(let t=0;t<this._physicsRig.subRigCount;++t){d=this._physicsRig.settings.at(t),c=this._physicsRig.outputs.get(d.baseOutputIndex);for(let e=0;e<d.outputCount;++e)this._previousRigOutputs.at(t).outputs.set(e,this._currentRigOutputs.at(t).outputs.at(e))}const e=x/this._currentRemainTime;for(let i=0;i<t.getParameterCount();++i)this._parameterCaches[i]=this._parameterInputCaches[i]*(1-e)+p[i]*e,this._parameterInputCaches[i]=this._parameterCaches[i];for(let i=0;i<this._physicsRig.subRigCount;++i){n={angle:0},h.x=0,h.y=0,d=this._physicsRig.settings.at(i),g=this._physicsRig.inputs.get(d.baseInputIndex),c=this._physicsRig.outputs.get(d.baseOutputIndex),m=this._physicsRig.particles.get(d.baseParticleIndex);for(let e=0;e<d.inputCount;++e)o=g[e].weight/100,-1==g[e].sourceParameterIndex&&(g[e].sourceParameterIndex=t.getParameterIndex(g[e].source.id)),g[e].getNormalizedParameterValue(h,n,this._parameterCaches[g[e].sourceParameterIndex],f[g[e].sourceParameterIndex],_[g[e].sourceParameterIndex],y[g[e].sourceParameterIndex],d.normalizationPosition,d.normalizationAngle,g[e].reflect,o);l=Ce.degreesToRadian(-n.angle),h.x=h.x*Ce.cos(l)-h.y*Ce.sin(l),h.y=h.x*Ce.sin(l)+h.y*Ce.cos(l),yr(m,d.particleCount,h,n.angle,this._options.wind,.001*d.normalizationPosition.maximum,x,5);for(let e=0;e<d.outputCount;++e){const s=c[e].vertexIndex;if(-1==c[e].destinationParameterIndex&&(c[e].destinationParameterIndex=t.getParameterIndex(c[e].destination.id)),s<1||s>=d.particleCount)continue;const r=new fe;r.x=m[s].position.x-m[s-1].position.x,r.y=m[s].position.y-m[s-1].position.y,u=c[e].getValue(r,m,s,c[e].reflect,this._options.gravity),this._currentRigOutputs.at(i).outputs.set(e,u);const a=c[e].destinationParameterIndex,n=!Float32Array.prototype.slice&&"subarray"in Float32Array.prototype?JSON.parse(JSON.stringify(this._parameterCaches.subarray(a))):this._parameterCaches.slice(a);Cr(n,f[a],_[a],u,c[e]);for(let t=a,e=0;t<this._parameterCaches.length;t++,e++)this._parameterCaches[t]=n[e]}}this._currentRemainTime-=x}const C=this._currentRemainTime/x;this.interpolate(t,C)}interpolate(t,e){let i,s;const r=t.getModel().parameters.values,a=t.getModel().parameters.maximumValues,n=t.getModel().parameters.minimumValues;for(let o=0;o<this._physicsRig.subRigCount;++o){s=this._physicsRig.settings.at(o),i=this._physicsRig.outputs.get(s.baseOutputIndex);for(let t=0;t<s.outputCount;++t){if(-1==i[t].destinationParameterIndex)continue;const s=i[t].destinationParameterIndex,l=!Float32Array.prototype.slice&&"subarray"in Float32Array.prototype?JSON.parse(JSON.stringify(r.subarray(s))):r.slice(s);Cr(l,n[s],a[s],this._previousRigOutputs.at(o).outputs.at(t)*(1-e)+this._currentRigOutputs.at(o).outputs.at(t)*e,i[t]);for(let t=s,e=0;t<r.length;t++,e++)r[t]=l[e]}}}setOptions(t){this._options=t}getOption(){return this._options}constructor(){this._physicsRig=null,this._options=new nr,this._options.gravity.y=-1,this._options.gravity.x=0,this._options.wind.x=0,this._options.wind.y=0,this._currentRigOutputs=new g,this._previousRigOutputs=new g,this._currentRemainTime=0,this._parameterCaches=null,this._parameterInputCaches=null}release(){this._physicsRig=void 0,this._physicsRig=null}initialize(){let t,e,i;for(let s=0;s<this._physicsRig.subRigCount;++s){e=this._physicsRig.settings.at(s),t=this._physicsRig.particles.get(e.baseParticleIndex),t[0].initialPosition=new fe(0,0),t[0].lastPosition=new fe(t[0].initialPosition.x,t[0].initialPosition.y),t[0].lastGravity=new fe(0,-1),t[0].lastGravity.y*=-1,t[0].velocity=new fe(0,0),t[0].force=new fe(0,0);for(let s=1;s<e.particleCount;++s)i=new fe(0,0),i.y=t[s].radius,t[s].initialPosition=new fe(t[s-1].initialPosition.x+i.x,t[s-1].initialPosition.y+i.y),t[s].position=new fe(t[s].initialPosition.x,t[s].initialPosition.y),t[s].lastPosition=new fe(t[s].initialPosition.x,t[s].initialPosition.y),t[s].lastGravity=new fe(0,-1),t[s].lastGravity.y*=-1,t[s].velocity=new fe(0,0),t[s].force=new fe(0,0)}}}class nr{constructor(){this.gravity=new fe(0,0),this.wind=new fe(0,0)}}class or{constructor(){this.outputs=new g(0)}}function lr(t,e,i,s,r,a,n,o,l,u){t.x+=Sr(i,s,r,a,n.minimum,n.maximum,n.defalut,l)*u}function ur(t,e,i,s,r,a,n,o,l,u){t.y+=Sr(i,s,r,a,n.minimum,n.maximum,n.defalut,l)*u}function hr(t,e,i,s,r,a,n,o,l,u){e.angle+=Sr(i,s,r,a,o.minimum,o.maximum,o.defalut,l)*u}function dr(t,e,i,s,r){let a=t.x;return s&&(a*=-1),a}function gr(t,e,i,s,r){let a=t.y;return s&&(a*=-1),a}function cr(t,e,i,s,r){let a;return r=i>=2?e[i-1].position.substract(e[i-2].position):r.multiplyByScaler(-1),a=Ce.directionToRadian(r,t),s&&(a*=-1),a}function mr(t,e){return Ce.min(t,e)+function(t,e){const i=Ce.max(t,e),s=Ce.min(t,e);return Ce.abs(i-s)}(t,e)/2}function pr(t,e){return JSON.parse(JSON.stringify(t.x))}function _r(t,e){return JSON.parse(JSON.stringify(t.y))}function fr(t,e){return JSON.parse(JSON.stringify(e))}function yr(t,e,i,s,r,a,n,o){let l,u,h=new fe(0,0),d=new fe(0,0),g=new fe(0,0),c=new fe(0,0);t[0].position=new fe(i.x,i.y);const m=Ce.degreesToRadian(s),p=Ce.radianToDirection(m);p.normalize();for(let _=1;_<e;++_)t[_].force=p.multiplyByScaler(t[_].acceleration).add(r),t[_].lastPosition=new fe(t[_].position.x,t[_].position.y),l=t[_].delay*n*30,h=t[_].position.substract(t[_-1].position),u=Ce.directionToRadian(t[_].lastGravity,p)/o,h.x=Ce.cos(u)*h.x-h.y*Ce.sin(u),h.y=Ce.sin(u)*h.x+h.y*Ce.cos(u),t[_].position=t[_-1].position.add(h),d=t[_].velocity.multiplyByScaler(l),g=t[_].force.multiplyByScaler(l).multiplyByScaler(l),t[_].position=t[_].position.add(d).add(g),c=t[_].position.substract(t[_-1].position),c.normalize(),t[_].position=t[_-1].position.add(c.multiplyByScaler(t[_].radius)),Ce.abs(t[_].position.x)<a&&(t[_].position.x=0),0!=l&&(t[_].velocity=t[_].position.substract(t[_].lastPosition),t[_].velocity=t[_].velocity.divisionByScalar(l),t[_].velocity=t[_].velocity.multiplyByScaler(t[_].mobility)),t[_].force=new fe(0,0),t[_].lastGravity=new fe(p.x,p.y)}function xr(t,e,i,s,r,a){let n=new fe(0,0);t[0].position=new fe(i.x,i.y);const o=Ce.degreesToRadian(s),l=Ce.radianToDirection(o);l.normalize();for(let u=1;u<e;++u)t[u].force=l.multiplyByScaler(t[u].acceleration).add(r),t[u].lastPosition=new fe(t[u].position.x,t[u].position.y),t[u].velocity=new fe(0,0),n=t[u].force,n.normalize(),n=n.multiplyByScaler(t[u].radius),t[u].position=t[u-1].position.add(n),Ce.abs(t[u].position.x)<a&&(t[u].position.x=0),t[u].force=new fe(0,0),t[u].lastGravity=new fe(l.x,l.y)}function Cr(t,e,i,s,r){let a;a=s*r.getScale(r.translationScale,r.angleScale),a<e?(a<r.valueBelowMinimum&&(r.valueBelowMinimum=a),a=e):a>i&&(a>r.valueExceededMaximum&&(r.valueExceededMaximum=a),a=i);const n=r.weight/100;n>=1||(a=t[0]*(1-n)+a*n),t[0]=a}function Sr(t,e,i,s,r,a,n,o){let l=0;const u=Ce.max(i,e);u<t&&(t=u);const h=Ce.min(i,e);h>t&&(t=h);const d=Ce.min(r,a),g=Ce.max(r,a),c=n,m=mr(h,u),p=t-m;switch(function(t){let e=0;return t>0?e=1:t<0&&(e=-1),e}(p)){case 1:{const t=u-m;0!=t&&(l=p*((g-c)/t),l+=c);break}case-1:{const t=h-m;0!=t&&(l=p*((d-c)/t),l+=c);break}case 0:l=c}return o?l:-1*l}var Mr;function vr(){var t;null==(t=this.__moc)||t.release()}(t=>{t.CubismPhysics=ar,t.Options=nr})(Mr||(Mr={})),se.registerRuntime({version:4,ready:cs,test:t=>t instanceof ls||ls.isValidJSON(t),isValidMoc(t){if(t.byteLength<4)return!1;const e=new Int8Array(t,0,4);return"MOC3"===String.fromCharCode(...e)},createModelSettings:t=>new ls(t),createCoreModel(t,e){const i=ws.create(t,!!(null==e?void 0:e.checkMocConsistency));try{const t=i.createModel();return t.__moc=i,t}catch(s){try{i.release()}catch(r){ct.warn("CubismFactory","Failed to release moc after core model creation failed.",r)}throw s}},createInternalModel(t,e,i){const s=new is(t,e,i),r=t;return r.__moc&&(s.__moc=r.__moc,delete r.__moc,s.once("destroy",vr)),s},createPhysics(t,e){if(!(e instanceof ArrayBuffer))throw new TypeError("Cubism physics data must be an ArrayBuffer.");return ar.create(e,e.byteLength)},createPose(t,e){if(!(e instanceof ArrayBuffer))throw new TypeError("Cubism pose data must be an ArrayBuffer.");return fs.create(e,e.byteLength)}}),t.Constant=lt,t.CubismExpressionManager=De,t.CubismFramework=ht,t.CubismInternalModel=is,t.CubismModelSettings=ls,t.CubismMotionManager=di,t.CubismParallelMotionManager=yi,t.ExpressionManager=vt,t.FileLoader=ee,t.FocusController=Bt,t.InternalModel=Ot,t.LOGICAL_HEIGHT=2,t.LOGICAL_WIDTH=2,t.Live2DFactory=se,t.Live2DLoader=jt,t.Live2DModel=_e,t.Live2DTransform=ue,t.LogLevel=dt,t.MBToByte=pt,t.ModelSettings=wt,t.MotionManager=Tt,t.MotionPreloadStrategy=Lt,t.MotionPriority=Ft,t.MotionState=It,t.Option=class{},t.SoundManager=Rt,t.VERSION="1.0.1",t.VOLUME=Vt,t.XHRLoader=Ut,t.ZipLoader=Qt,t.applyMixins=yt,t.clamp=mt,t.config=gt,t.configureCubismSDK=gs,t.copyArray=ft,t.copyProperty=_t,t.csmDelete=ut,t.cubismReady=cs,t.folderName=xt,t.logger=ct,t.normalizeHitAreaDefs=At,t.rand=function(t,e){return Math.random()*(e-t)+t},t.reconfigureCubismSDK=function(t={}){gs(t),ht.isInitialized()&&ht.dispose(),ht.isStarted()&&ht.cleanUp(),ms(void 0,t.memorySizeMB)},t.remove=Ct,t.resolveURL=Mt,t.startUpCubism=ms,t.strtod=st,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("pixi.js"),require("@pixi/sound")):"function"==typeof define&&define.amd?define(["exports","pixi.js","@pixi/sound"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).PIXI=t.PIXI||{},t.PIXI.live2d=t.PIXI.live2d||{}),t.PIXI,t.PIXI)}(this,function(t,e,i){"use strict";var s=Object.defineProperty,r=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable,o=Math.pow,l=(t,e,i)=>e in t?s(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,u=(t,e,i)=>l(t,"symbol"!=typeof e?e+"":e,i),h=(t,e,i)=>new Promise((s,r)=>{var a=t=>{try{o(i.next(t))}catch(e){r(e)}},n=t=>{try{o(i.throw(t))}catch(e){r(e)}},o=t=>t.done?s(t.value):Promise.resolve(t.value).then(a,n);o((i=i.apply(t,e)).next())});const d=class t{constructor(t=0){t<1?(this._ptr=[],this._capacity=0,this._size=0):(this._ptr=new Array(t),this._capacity=t,this._size=0)}at(t){return this._ptr[t]}set(t,e){this._ptr[t]=e}get(t=0){const e=new Array;for(let i=t;i<this._size;i++)e.push(this._ptr[i]);return e}pushBack(e){this._size>=this._capacity&&this.prepareCapacity(0==this._capacity?t.DefaultSize:2*this._capacity),this._ptr[this._size++]=e}clear(){this._ptr.length=0,this._size=0}getSize(){return this._size}assign(t,e){this._size<t&&this.prepareCapacity(t);for(let i=0;i<t;i++)this._ptr[i]=e;this._size=t}resize(t,e=null){this.updateSize(t,e,!0)}updateSize(t,e=null,i=!0){if(this._size<t)if(this.prepareCapacity(t),i)for(let s=this._size;s<t;s++)this._ptr[s]="function"==typeof e?JSON.parse(JSON.stringify(new e)):e;else for(let s=this._size;s<t;s++)this._ptr[s]=e;else{const e=this._size-t;this._ptr.splice(this._size-e,e)}this._size=t}insert(t,e,i){let s=t._index;const r=e._index,a=i._index,n=a-r;this.prepareCapacity(this._size+n);const o=this._size-s;if(o>0)for(let l=0;l<o;l++)this._ptr.splice(s+l,0,null);for(let l=r;l<a;l++,s++)this._ptr[s]=e._vector._ptr[l];this._size=this._size+n}remove(t){return!(t<0||this._size<=t)&&(this._ptr.splice(t,1),--this._size,!0)}erase(t){const e=t._index;if(e<0||this._size<=e)return t;this._ptr.splice(e,1),--this._size;return new c(this,e)}prepareCapacity(t){t>this._capacity&&(0==this._capacity?(this._ptr=new Array(t),this._capacity=t):(this._ptr.length=t,this._capacity=t))}begin(){return 0==this._size?this.end():new c(this,0)}end(){return new c(this,this._size)}getOffset(e){const i=new t;return i._ptr=this.get(e),i._size=this.get(e).length,i._capacity=this.get(e).length,i}};d.DefaultSize=10;let g=d,c=class t{constructor(t,e){this._vector=null!=t?t:null,this._index=null!=e?e:0}set(t){return this._index=t._index,this._vector=t._vector,this}preIncrement(){return++this._index,this}preDecrement(){return--this._index,this}increment(){return new t(this._vector,this._index++)}decrement(){return new t(this._vector,this._index--)}ptr(){return this._vector._ptr[this._index]}substitution(t){return this._index=t._index,this._vector=t._vector,this}notEqual(t){return this._index!=t._index||this._vector!=t._vector}};var m,p,_,f,y,x,C;(p=m||(m={})).csmVector=g,p.iterator=c;class S{append(t,e){return this.s+=void 0!==e?t.substr(0,e):t,this}expansion(t,e){for(let i=0;i<t;i++)this.append(e);return this}getBytes(){return encodeURIComponent(this.s).replace(/%../g,"x").length}getLength(){return this.s.length}isLess(t){return this.s<t.s}isGreat(t){return this.s>t.s}isEqual(t){return this.s==t}isEmpty(){return 0==this.s.length}constructor(t){this.s=t}}(t=>{t.csmString=S})(_||(_={}));class M{static createIdInternal(t){return new M(t)}getString(){return this._id}isEqual(t){return"string"==typeof t?this._id.isEqual(t):t instanceof S?this._id.isEqual(t.s):t instanceof M&&this._id.isEqual(t._id.s)}isNotEqual(t){return"string"==typeof t?!this._id.isEqual(t):t instanceof S?!this._id.isEqual(t.s):t instanceof M&&!this._id.isEqual(t._id.s)}constructor(t){this._id="string"!=typeof t?t:new S(t)}}(t=>{t.CubismId=M})(f||(f={}));class v{constructor(){this._ids=new g}release(){for(let t=0;t<this._ids.getSize();++t)this._ids.set(t,void 0);this._ids=null}registerIds(t){for(let e=0;e<t.length;e++)this.registerId(t[e])}registerId(t){let e=null;return"string"!=typeof t?this.registerId(t.s):(null!=(e=this.findId(t))||(e=M.createIdInternal(t),this._ids.pushBack(e)),e)}getId(t){return this.registerId(t)}isExist(t){return"string"==typeof t?null!=this.findId(t):this.isExist(t.s)}findId(t){for(let e=0;e<this._ids.getSize();++e)if(this._ids.at(e).getString().isEqual(t))return this._ids.at(e);return null}}(t=>{t.CubismIdManager=v})(y||(y={}));class b{constructor(){this._tr=new Float32Array(16),this.loadIdentity()}static multiply(t,e,i){const s=new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);for(let r=0;r<4;++r)for(let i=0;i<4;++i)for(let a=0;a<4;++a)s[i+4*r]+=t[a+4*r]*e[i+4*a];for(let r=0;r<16;++r)i[r]=s[r]}loadIdentity(){const t=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);this.setMatrix(t)}setMatrix(t){for(let e=0;e<16;++e)this._tr[e]=t[e]}getArray(){return this._tr}getScaleX(){return this._tr[0]}getScaleY(){return this._tr[5]}getTranslateX(){return this._tr[12]}getTranslateY(){return this._tr[13]}transformX(t){return this._tr[0]*t+this._tr[12]}transformY(t){return this._tr[5]*t+this._tr[13]}invertTransformX(t){return(t-this._tr[12])/this._tr[0]}invertTransformY(t){return(t-this._tr[13])/this._tr[5]}translateRelative(t,e){const i=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,t,e,0,1]);b.multiply(i,this._tr,this._tr)}translate(t,e){this._tr[12]=t,this._tr[13]=e}translateX(t){this._tr[12]=t}translateY(t){this._tr[13]=t}scaleRelative(t,e){const i=new Float32Array([t,0,0,0,0,e,0,0,0,0,1,0,0,0,0,1]);b.multiply(i,this._tr,this._tr)}scale(t,e){this._tr[0]=t,this._tr[5]=e}multiplyByMatrix(t){b.multiply(t.getArray(),this._tr,this._tr)}clone(){const t=new b;for(let e=0;e<this._tr.length;e++)t._tr[e]=this._tr[e];return t}}(t=>{t.CubismMatrix44=b})(x||(x={}));class P{constructor(t,e,i,s){this.x=t,this.y=e,this.width=i,this.height=s}getCenterX(){return this.x+.5*this.width}getCenterY(){return this.y+.5*this.height}getRight(){return this.x+this.width}getBottom(){return this.y+this.height}setRect(t){this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height}expand(t,e){this.x-=t,this.y-=e,this.width+=2*t,this.height+=2*e}}(t=>{t.csmRect=P})(C||(C={}));class B{static create(){return null}static delete(t){}initialize(t){this._model=t}drawModel(){null!=this.getModel()&&(this.saveProfile(),this.doDrawModel(),this.restoreProfile())}setMvpMatrix(t){this._mvpMatrix4x4.setMatrix(t.getArray())}getMvpMatrix(){return this._mvpMatrix4x4}setModelColor(t,e,i,s){t<0?t=0:t>1&&(t=1),e<0?e=0:e>1&&(e=1),i<0?i=0:i>1&&(i=1),s<0?s=0:s>1&&(s=1),this._modelColor.r=t,this._modelColor.g=e,this._modelColor.b=i,this._modelColor.a=s}getModelColor(){return JSON.parse(JSON.stringify(this._modelColor))}getModelColorWithOpacity(t){const e=this.getModelColor();return e.a*=t,this.isPremultipliedAlpha()&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),e}setIsPremultipliedAlpha(t){this._isPremultipliedAlpha=t}isPremultipliedAlpha(){return this._isPremultipliedAlpha}setIsCulling(t){this._isCulling=t}isCulling(){return this._isCulling}setAnisotropy(t){this._anisotropy=t}getAnisotropy(){return this._anisotropy}getModel(){return this._model}useHighPrecisionMask(t){this._useHighPrecisionMask=t}isUsingHighPrecisionMask(){return this._useHighPrecisionMask}constructor(){this._isCulling=!1,this._isPremultipliedAlpha=!1,this._anisotropy=0,this._model=null,this._modelColor=new I,this._useHighPrecisionMask=!1,this._mvpMatrix4x4=new b,this._mvpMatrix4x4.loadIdentity()}}var w,F=(t=>(t[t.CubismBlendMode_Normal=0]="CubismBlendMode_Normal",t[t.CubismBlendMode_Additive=1]="CubismBlendMode_Additive",t[t.CubismBlendMode_Multiplicative=2]="CubismBlendMode_Multiplicative",t))(F||{});class I{constructor(t=1,e=1,i=1,s=1){this.r=t,this.g=e,this.b=i,this.a=s}}class E{constructor(t,e){this._clippingIdList=t,this._clippingIdCount=e,this._allClippedDrawRect=new P,this._layoutBounds=new P,this._clippedDrawableIndexList=[],this._matrixForMask=new b,this._matrixForDraw=new b,this._bufferIndex=0}release(){null!=this._layoutBounds&&(this._layoutBounds=null),null!=this._allClippedDrawRect&&(this._allClippedDrawRect=null),null!=this._clippedDrawableIndexList&&(this._clippedDrawableIndexList=null)}addClippedDrawable(t){this._clippedDrawableIndexList.push(t)}}(t=>{t.CubismBlendMode=F,t.CubismRenderer=B,t.CubismTextureColor=I})(w||(w={}));const V=Object.freeze(Object.defineProperty({__proto__:null,CSM_LOG_LEVEL:0,CSM_LOG_LEVEL_DEBUG:1,CSM_LOG_LEVEL_ERROR:4,CSM_LOG_LEVEL_INFO:2,CSM_LOG_LEVEL_OFF:5,CSM_LOG_LEVEL_VERBOSE:0,CSM_LOG_LEVEL_WARNING:3},Symbol.toStringTag,{value:"Module"})),R=(t,e,i)=>{((t,e,i)=>{k.print(t,"[CSM]"+e,i)})(t,e+"\n",i)},L=t=>{console.assert(t)};let T,A,D,O;T=(t,...e)=>{R(dt.LogLevel_Debug,"[D]"+t,e)},A=(t,...e)=>{R(dt.LogLevel_Info,"[I]"+t,e)},D=(t,...e)=>{R(dt.LogLevel_Warning,"[W]"+t,e)},O=(t,...e)=>{R(dt.LogLevel_Error,"[E]"+t,e)};class k{static print(t,e,i){if(t<ht.getLoggingLevel())return;const s=ht.coreLogFunction;if(!s)return;s(e.replace(/\{(\d+)\}/g,(t,e)=>i[e]))}static dumpBytes(t,e,i){for(let s=0;s<i;s++)s%16==0&&s>0?this.print(t,"\n"):s%8==0&&s>0&&this.print(t," "),this.print(t,"{0} ",[255&e[s]]);this.print(t,"\n")}constructor(){}}var N;(t=>{t.CubismDebug=k})(N||(N={}));class U{constructor(t,e){this.first=null==t?null:t,this.second=null==e?null:e}}const z=class t{constructor(t){null!=t?t<1?(this._keyValues=[],this._dummyValue=null,this._size=0):(this._keyValues=new Array(t),this._size=t):(this._keyValues=[],this._dummyValue=null,this._size=0)}release(){this.clear()}appendKey(t){let e=-1;for(let i=0;i<this._size;i++)if(this._keyValues[i].first==t){e=i;break}-1==e?(this.prepareCapacity(this._size+1,!1),this._keyValues[this._size]=new U(t),this._size+=1):D("The key `{0}` is already append.",t)}getValue(t){let e=-1;for(let i=0;i<this._size;i++)if(this._keyValues[i].first==t){e=i;break}return e>=0?this._keyValues[e].second:(this.appendKey(t),this._keyValues[this._size-1].second)}setValue(t,e){let i=-1;for(let s=0;s<this._size;s++)if(this._keyValues[s].first==t){i=s;break}i>=0?this._keyValues[i].second=e:(this.appendKey(t),this._keyValues[this._size-1].second=e)}isExist(t){for(let e=0;e<this._size;e++)if(this._keyValues[e].first==t)return!0;return!1}clear(){this._keyValues=void 0,this._keyValues=null,this._keyValues=[],this._size=0}getSize(){return this._size}prepareCapacity(e,i){e>this._keyValues.length&&(0==this._keyValues.length?(!i&&e<t.DefaultSize&&(e=t.DefaultSize),this._keyValues.length=e):(!i&&e<2*this._keyValues.length&&(e=2*this._keyValues.length),this._keyValues.length=e))}begin(){return new G(this,0)}end(){return new G(this,this._size)}erase(t){const e=t._index;if(e<0||this._size<=e)return t;this._keyValues.splice(e,1),--this._size;return new G(this,e)}dumpAsInt(){for(let t=0;t<this._size;t++)T("{0} ,",this._keyValues[t]),T("\n")}};z.DefaultSize=10;let j=z;class G{constructor(t,e){this._map=null!=t?t:new j,this._index=null!=e?e:0}set(t){return this._index=t._index,this._map=t._map,this}preIncrement(){return++this._index,this}preDecrement(){return--this._index,this}increment(){return new G(this._map,this._index++)}decrement(){const t=new G(this._map,this._index);return this._map=t._map,this._index=t._index,this}ptr(){return this._map._keyValues[this._index]}notEqual(t){return this._index!=t._index||this._map!=t._map}}var X;(t=>{t.csmMap=j,t.csmPair=U,t.iterator=G})(X||(X={}));class H{static parseJsonObject(t,e){return Object.keys(t).forEach(i=>{if("boolean"==typeof t[i]){const s=Boolean(t[i]);e.put(i,new $(s))}else if("string"==typeof t[i]){const s=String(t[i]);e.put(i,new Z(s))}else if("number"==typeof t[i]){const s=Number(t[i]);e.put(i,new J(s))}else t[i]instanceof Array?e.put(i,H.parseJsonArray(t[i])):t[i]instanceof Object?e.put(i,H.parseJsonObject(t[i],new et)):null==t[i]?e.put(i,new Q):e.put(i,t[i])}),e}static parseJsonArray(t){const e=new tt;return Object.keys(t).forEach(i=>{if("number"==typeof Number(i))if("boolean"==typeof t[i]){const s=Boolean(t[i]);e.add(new $(s))}else if("string"==typeof t[i]){const s=String(t[i]);e.add(new Z(s))}else if("number"==typeof t[i]){const s=Number(t[i]);e.add(new J(s))}else t[i]instanceof Array?e.add(this.parseJsonArray(t[i])):t[i]instanceof Object?e.add(this.parseJsonObject(t[i],new et)):null==t[i]?e.add(new Q):e.add(t[i]);else if(t[i]instanceof Array)e.add(this.parseJsonArray(t[i]));else if(t[i]instanceof Object)e.add(this.parseJsonObject(t[i],new et));else if(null==t[i])e.add(new Q);else{const s=Array(t[i]);for(let t=0;t<s.length;t++)e.add(s[t])}}),e}}const q="Error: type mismatch";let W=class t{constructor(){}getRawString(t,e){return this.getString(t,e)}toInt(t=0){return t}toFloat(t=0){return t}toBoolean(t=!1){return t}getSize(){return 0}getArray(t=null){return t}getVector(t=new g){return t}getMap(t){return t}getValueByIndex(e){return t.errorValue.setErrorNotForClientCall(q)}getValueByString(e){return t.nullValue.setErrorNotForClientCall(q)}getKeys(){return t.dummyKeys}isError(){return!1}isNull(){return!1}isBool(){return!1}isFloat(){return!1}isString(){return!1}isArray(){return!1}isMap(){return!1}equals(t){return!1}isStatic(){return!1}setErrorNotForClientCall(t){return K.errorValue}static staticInitializeNotForClientCall(){$.trueValue=new $(!0),$.falseValue=new $(!1),t.errorValue=new K("ERROR",!0),t.nullValue=new Q,t.dummyKeys=new g}static staticReleaseNotForClientCall(){$.trueValue=null,$.falseValue=null,t.errorValue=null,t.nullValue=null,t.dummyKeys=null}};class Y{constructor(t,e){this._parseCallback=H.parseJsonObject,this._error=null,this._lineCount=0,this._root=null,null!=t&&this.parseBytes(t,e,this._parseCallback)}static create(t,e){const i=new Y;return i.parseBytes(t,e,i._parseCallback)?i:(Y.delete(i),null)}static delete(t){}getRoot(){return this._root}static arrayBufferToString(t){const e=new Uint8Array(t);let i="";for(let s=0,r=e.length;s<r;++s)i+="%"+this.pad(e[s].toString(16));return i=decodeURIComponent(i),i}static pad(t){return t.length<2?"0"+t:t}parseBytes(t,e,i){const s=new Array(1),r=Y.arrayBufferToString(t);if(this._root=null==i?this.parseValue(r,e,0,s):i(JSON.parse(r),new et),this._error){let t="\0";return t="Json parse error : @line "+(this._lineCount+1)+"\n",this._root=new Z(t),A("{0}",this._root.getRawString()),!1}return null!=this._root||(this._root=new K(new S(this._error),!1),!1)}getParseError(){return this._error}checkEndOfFile(){return this._root.getArray()[1].equals("EOF")}parseValue(t,e,i,s){if(this._error)return null;let r,a=null,n=i;for(;n<e;n++){switch(t[n]){case"-":case".":case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{const e=new Array(1);return r=st(t.slice(n),e),s[0]=t.indexOf(e[0]),new J(r)}case'"':return new Z(this.parseString(t,e,n+1,s));case"[":return a=this.parseArray(t,e,n+1,s),a;case"{":return a=this.parseObject(t,e,n+1,s),a;case"n":return n+3<e?(a=new Q,s[0]=n+4):this._error="parse null",a;case"t":return n+3<e?(a=$.trueValue,s[0]=n+4):this._error="parse true",a;case"f":return n+4<e?(a=$.falseValue,s[0]=n+5):this._error="illegal ',' position",a;case",":return this._error="illegal ',' position",null;case"]":return s[0]=n,null;case"\n":this._lineCount++}}return this._error="illegal end of value",null}parseString(t,e,i,s){if(this._error)return null;if(!t)return this._error="string is null",null;let r,a,n=i;const o=new S("");let l=i;for(;n<e;n++)switch(r=t[n],r){case'"':return s[0]=n+1,o.append(t.slice(l),n-l),o.s;case"//":if(n++,n-1>l&&o.append(t.slice(l),n-l),l=n+1,n<e)switch(a=t[n],a){case"\\":o.expansion(1,"\\");break;case'"':o.expansion(1,'"');break;case"/":o.expansion(1,"/");break;case"b":o.expansion(1,"\b");break;case"f":o.expansion(1,"\f");break;case"n":o.expansion(1,"\n");break;case"r":o.expansion(1,"\r");break;case"t":o.expansion(1,"\t");break;case"u":this._error="parse string/unicord escape not supported"}else this._error="parse string/escape error"}return this._error="parse string/illegal end",null}parseObject(t,e,i,s){if(this._error)return null;if(!t)return this._error="buffer is null",null;const r=new et;let a="",n=i,o="";const l=Array(1);let u=!1;for(;n<e;n++){t:for(;n<e;n++)switch(o=t[n],o){case'"':if(a=this.parseString(t,e,n+1,l),this._error)return null;n=l[0],u=!0;break t;case"}":return s[0]=n+1,r;case":":this._error="illegal ':' position";break;case"\n":this._lineCount++}if(!u)return this._error="key not found",null;u=!1;t:for(;n<e;n++)switch(o=t[n],o){case":":u=!0,n++;break t;case"}":this._error="illegal '}' position";break;case"\n":this._lineCount++}if(!u)return this._error="':' not found",null;const i=this.parseValue(t,e,n,l);if(this._error)return null;n=l[0],r.put(a,i);t:for(;n<e;n++)switch(o=t[n],o){case",":break t;case"}":return s[0]=n+1,r;case"\n":this._lineCount++}}return this._error="illegal end of perseObject",null}parseArray(t,e,i,s){if(this._error)return null;if(!t)return this._error="buffer is null",null;let r,a=new tt,n=i;const o=new Array(1);for(;n<e;n++){const i=this.parseValue(t,e,n,o);if(this._error)return null;n=o[0],i&&a.add(i);t:for(;n<e;n++)switch(r=t[n],r){case",":break t;case"]":return s[0]=n+1,a;case"\n":++this._lineCount}}return a=void 0,this._error="illegal end of parseObject",null}}class J extends W{constructor(t){super(),this._value=t}isFloat(){return!0}getString(t,e){return this._value=parseFloat("\0"),this._stringBuffer="\0",this._stringBuffer}toInt(t=0){return parseInt(this._value.toString())}toFloat(t=0){return this._value}equals(t){return"number"==typeof t&&(!Math.round(t)&&t==this._value)}}class $ extends W{isBool(){return!0}toBoolean(t=!1){return this._boolValue}getString(t,e){return this._stringBuffer=this._boolValue?"true":"false",this._stringBuffer}equals(t){return"boolean"==typeof t&&t==this._boolValue}isStatic(){return!0}constructor(t){super(),this._boolValue=t}}class Z extends W{constructor(t){super(),"string"==typeof t&&(this._stringBuffer=t),t instanceof S&&(this._stringBuffer=t.s)}isString(){return!0}getString(t,e){return this._stringBuffer}equals(t){return"string"==typeof t?this._stringBuffer==t:t instanceof S&&this._stringBuffer==t.s}}class K extends Z{isStatic(){return this._isStatic}setErrorNotForClientCall(t){return this._stringBuffer=t,this}constructor(t,e){super(t),this._isStatic=e}isError(){return!0}}class Q extends W{isNull(){return!0}getString(t,e){return this._stringBuffer}isStatic(){return!0}setErrorNotForClientCall(t){return this._stringBuffer=t,K.nullValue}constructor(){super(),this._stringBuffer="NullValue"}}class tt extends W{constructor(){super(),this._array=new g}release(){for(let t=this._array.begin();t.notEqual(this._array.end());t.preIncrement()){let e=t.ptr();e&&!e.isStatic()&&(e=void 0,e=null)}}isArray(){return!0}getValueByIndex(t){if(t<0||this._array.getSize()<=t)return W.errorValue.setErrorNotForClientCall("Error: index out of bounds");const e=this._array.at(t);return null==e?W.nullValue:e}getValueByString(t){return W.errorValue.setErrorNotForClientCall(q)}getString(t,e){const i=e+"[\n";for(let s=this._array.begin();s.notEqual(this._array.end());s.increment()){const t=s.ptr();this._stringBuffer+=e+""+t.getString(e+" ")+"\n"}return this._stringBuffer=i+e+"]\n",this._stringBuffer}add(t){this._array.pushBack(t)}getVector(t=null){return this._array}getSize(){return this._array.getSize()}}class et extends W{constructor(){super(),this._map=new j}release(){const t=this._map.begin();for(;t.notEqual(this._map.end());){let e=t.ptr().second;e&&!e.isStatic()&&(e=void 0,e=null),t.preIncrement()}}isMap(){return!0}getValueByString(t){if(t instanceof S){const e=this._map.getValue(t.s);return null==e?W.nullValue:e}for(let e=this._map.begin();e.notEqual(this._map.end());e.preIncrement())if(e.ptr().first==t)return null==e.ptr().second?W.nullValue:e.ptr().second;return W.nullValue}getValueByIndex(t){return W.errorValue.setErrorNotForClientCall(q)}getString(t,e){this._stringBuffer=e+"{\n";const i=this._map.begin();for(;i.notEqual(this._map.end());){const t=i.ptr().first,s=i.ptr().second;this._stringBuffer+=e+" "+t+" : "+s.getString(e+" ")+" \n",i.preIncrement()}return this._stringBuffer+=e+"}\n",this._stringBuffer}getMap(t){return this._map}put(t,e){this._map.setValue(t,e)}getKeys(){if(!this._keys){this._keys=new g;const t=this._map.begin();for(;t.notEqual(this._map.end());){const e=t.ptr().first;this._keys.pushBack(e),t.preIncrement()}}return this._keys}getSize(){return this._keys.getSize()}}var it;function st(t,e){let i=0;for(let r=1;;r++){const e=t.slice(r-1,r);if("e"==e||"-"==e||"E"==e)continue;const s=t.substring(0,r),a=Number(s);if(isNaN(a))break;i=r}let s=parseFloat(t);return isNaN(s)&&(s=NaN),e[0]=t.slice(i),s}(t=>{t.CubismJson=Y,t.JsonArray=tt,t.JsonBoolean=$,t.JsonError=K,t.JsonFloat=J,t.JsonMap=et,t.JsonNullvalue=Q,t.JsonString=Z,t.Value=W})(it||(it={}));let rt=!1,at=!1,nt=null,ot=null;const lt=Object.freeze({vertexOffset:0,vertexStep:2});function ut(t){t&&(t=void 0)}class ht{static startUp(t=null){if(rt)return A("CubismFramework.startUp() is already done."),rt;if(nt=t,null!=nt&&Live2DCubismCore.Logging.csmSetLogFunction(nt.logFunction),rt=!0,rt){const t=Live2DCubismCore.Version.csmGetVersion(),e=(16711680&t)>>16,i=65535&t,s=t;A("Live2D Cubism Core version: {0}.{1}.{2} ({3})",("00"+((4278190080&t)>>24)).slice(-2),("00"+e).slice(-2),("0000"+i).slice(-4),s)}return A("CubismFramework.startUp() is complete."),rt}static cleanUp(){rt=!1,at=!1,nt=null,ot=null}static initialize(t=0){L(rt),rt?at?D("CubismFramework.initialize() skipped, already initialized."):(W.staticInitializeNotForClientCall(),ot=new v,Live2DCubismCore.Memory.initializeAmountOfMemory(t),at=!0,A("CubismFramework.initialize() is complete.")):D("CubismFramework is not started.")}static dispose(){L(rt),rt?at?(W.staticReleaseNotForClientCall(),ot.release(),ot=null,B.staticRelease(),at=!1,A("CubismFramework.dispose() is complete.")):D("CubismFramework.dispose() skipped, not initialized."):D("CubismFramework is not started.")}static isStarted(){return rt}static isInitialized(){return at}static coreLogFunction(t){Live2DCubismCore.Logging.csmGetLogFunction()&&Live2DCubismCore.Logging.csmGetLogFunction()(t)}static getLoggingLevel(){return null!=nt?nt.loggingLevel:5}static getIdManager(){return ot}constructor(){}}var dt=(t=>(t[t.LogLevel_Verbose=0]="LogLevel_Verbose",t[t.LogLevel_Debug=1]="LogLevel_Debug",t[t.LogLevel_Info=2]="LogLevel_Info",t[t.LogLevel_Warning=3]="LogLevel_Warning",t[t.LogLevel_Error=4]="LogLevel_Error",t[t.LogLevel_Off=5]="LogLevel_Off",t))(dt||{});t.Live2DCubismFramework=void 0,(t=>{t.Constant=lt,t.csmDelete=ut,t.CubismFramework=ht})(t.Live2DCubismFramework||(t.Live2DCubismFramework={}));const gt={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,cubism:V},ct={log(t,...e){gt.logLevel<=gt.LOG_LEVEL_VERBOSE&&console.log(`[${t}]`,...e)},warn(t,...e){gt.logLevel<=gt.LOG_LEVEL_WARNING&&console.warn(`[${t}]`,...e)},error(t,...e){gt.logLevel<=gt.LOG_LEVEL_ERROR&&console.error(`[${t}]`,...e)}};function mt(t,e,i){return t<e?e:t>i?i:t}function pt(t){return 1024*t*1024}function _t(t,e,i,s,r){const a=e[s];null!==a&&typeof a===t&&(i[r]=a)}function ft(t,e,i,s,r){const a=e[s];Array.isArray(a)&&(i[r]=a.filter(e=>null!==e&&typeof e===t))}function yt(t,e){e.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(i=>{"constructor"!==i&&Object.defineProperty(t.prototype,i,Object.getOwnPropertyDescriptor(e.prototype,i))})})}function xt(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 Ct(t,e){const i=t.indexOf(e);-1!==i&&t.splice(i,1)}const St=/^[a-zA-Z][a-zA-Z0-9+.-]*:/;function Mt(t,e){if(!e)return t;if(St.test(e))return e;if(e.startsWith("/"))return St.test(t)?new URL(e,t).toString():e;if(St.test(t))return new URL(e,t).toString();const i="http://example.com",s=t.startsWith("/")?i+t:`${i}/${t}`,r=new URL(e,s);let a=r.pathname+r.search+r.hash;return!t.startsWith("/")&&a.startsWith("/")&&(a=a.slice(1)),a}class vt extends e.EventEmitter{constructor(t,e){super(),u(this,"expressionDataType","json"),u(this,"tag"),u(this,"settings"),u(this,"expressions",[]),u(this,"defaultExpression"),u(this,"currentExpression"),u(this,"reserveExpressionIndex",-1),u(this,"destroyed",!1),this.settings=t,this.tag=`ExpressionManager(${t.name})`}init(){this.defaultExpression=this.createDefaultExpression(),this.currentExpression=this.defaultExpression,this.stopAllExpressions()}createDefaultExpression(){return this.createExpression({},void 0)}loadExpression(t){return h(this,null,function*(){if(!this.definitions[t])return void ct.warn(this.tag,`Undefined expression at [${t}]`);if(null===this.expressions[t])return void ct.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 h(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 h(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 bt=40/7.5,Pt=1/150;class Bt{constructor(){u(this,"targetX",0),u(this,"targetY",0),u(this,"x",0),u(this,"y",0),u(this,"vx",0),u(this,"vy",0)}focus(t,e,i=!1){this.targetX=mt(t,-1,1),this.targetY=mt(e,-1,1),i&&(this.x=this.targetX,this.y=this.targetY)}update(t){const e=this.targetX-this.x,i=this.targetY-this.y;if(Math.abs(e)<.01&&Math.abs(i)<.01)return;const s=Math.sqrt(o(e,2)+o(i,2)),r=bt/(1e3/t);let a=r*(e/s)-this.vx,n=r*(i/s)-this.vy;const l=Math.sqrt(o(a,2)+o(n,2)),u=r*Pt*t;l>u&&(a*=u/l,n*=u/l),this.vx+=a,this.vy+=n;const h=Math.sqrt(o(this.vx,2)+o(this.vy,2)),d=.5*(Math.sqrt(o(u,2)+8*u*s)-u);h>d&&(this.vx*=d/h,this.vy*=d/h),this.x+=this.vx,this.y+=this.vy}}class wt{constructor(t){u(this,"json"),u(this,"name"),u(this,"url"),u(this,"pose"),u(this,"physics"),this.json=t,this.url=t.url,this.name=xt(this.url)}normalizeName(){this.name&&"name"!==this.name.toLowerCase()||(this.name=xt(this.url))}setModelName(...t){for(const e of t){const t="string"==typeof e?e.trim():"";if(t&&"name"!==t.toLowerCase())return void(this.name=t)}this.normalizeName()}getFileStem(t){if(!t)return;const e=t.split(/[/\\]/).filter(Boolean).pop();return null==e?void 0:e.replace(/\.[^.]+$/,"")}resolveURL(t){return Mt(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,i)=>{const s=this.resolveURL(e);if(!t.includes(s)){if(i)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 Ft=(t=>(t[t.NONE=0]="NONE",t[t.IDLE=1]="IDLE",t[t.NORMAL=2]="NORMAL",t[t.FORCE=3]="FORCE",t))(Ft||{});class It{constructor(){u(this,"tag"),u(this,"debug",!1),u(this,"currentPriority",0),u(this,"reservePriority",0),u(this,"currentGroup"),u(this,"currentIndex"),u(this,"reservedGroup"),u(this,"reservedIndex"),u(this,"reservedIdleGroup"),u(this,"reservedIdleIndex")}reserve(t,e,i){if(i<=0)return ct.log(this.tag,"Cannot start a motion with MotionPriority.NONE."),!1;if(t===this.currentGroup&&e===this.currentIndex)return ct.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 ct.log(this.tag,"Motion is already reserved.",this.dump(t,e)),!1;if(1===i){if(0!==this.currentPriority)return ct.log(this.tag,"Cannot start idle motion because another motion is playing.",this.dump(t,e)),!1;if(void 0!==this.reservedIdleGroup)return ct.log(this.tag,"Cannot start idle motion because another idle motion has reserved.",this.dump(t,e)),!1;this.setReservedIdle(t,e)}else{if(i<3){if(i<=this.currentPriority)return ct.log(this.tag,"Cannot start motion because another motion is playing as an equivalent or higher priority.",this.dump(t,e)),!1;if(i<=this.reservePriority)return ct.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,i)}return!0}start(t,e,i,s){if(1===s){if(this.setReservedIdle(void 0,void 0),0!==this.currentPriority)return ct.log(this.tag,"Cannot start idle motion because another motion is playing.",this.dump(e,i)),!1}else{if(e!==this.reservedGroup||i!==this.reservedIndex)return ct.log(this.tag,"Cannot start motion because another motion has taken the place.",this.dump(e,i)),!1;this.setReserved(void 0,void 0,0)}return!!t&&(this.setCurrent(e,i,s),!0)}complete(){this.setCurrent(void 0,void 0,0)}setCurrent(t,e,i){this.currentPriority=i,this.currentGroup=t,this.currentIndex=e}setReserved(t,e,i){this.reservePriority=i,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!gt.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 Et="SoundManager",Vt=.5;i.sound.disableAutoPause=!0;class Rt{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){return h(this,null,function*(){try{const e=new Promise((e,s)=>{const r=i.Sound.from({url:t,volume:this._volume,preload:!0,loaded:()=>{r.media instanceof i.webaudio.WebAudioMedia||s(new Error(`Error: ${t} is not WebAudioMedia`)),e(r)}})});return yield e}catch(s){return ct.warn(Et,`Error occurred on "${t}"`,s),null==e||e(s),null}})}static play(t,e){t.play({singleInstance:!0,complete:()=>{null==e||e(),t.destroy()}})}static addAnalyzer(t,e){const i=t.media,s=e.createBufferSource();s.buffer=i.buffer;const r=e.createAnalyser();return r.fftSize=gt.fftSize,r.minDecibels=-90,r.maxDecibels=-10,r.smoothingTimeConstant=.85,s.connect(r),s.start(0),this.analysers.push(r),r}static analyze(t){if(!t)return parseFloat(Math.random().toFixed(1));const e=new Float32Array(t.fftSize);t.getFloatTimeDomainData(e);let i=0;for(let n=0;n<e.length;n++)i+=o(e[n],2);const s=Math.sqrt(i/e.length),r=20*Math.log10(s||o(10,-5)),a=Math.min(Math.max((r-t.minDecibels)/(t.maxDecibels-t.minDecibels),0),1);return parseFloat(a.toFixed(1))}static dispose(t){t.pause(),Ct(this.audios,t)}static destroy(){for(let t=this.contexts.length-1;t>=0;t--){const e=this.contexts[t];null==e||e.close().catch(t=>{ct.warn(Et,"Failed to close AudioContext.",t)})}for(let t=this.audios.length-1;t>=0;t--)this.dispose(this.audios[t])}}u(Rt,"audios",[]),u(Rt,"analysers",[]),u(Rt,"contexts",[]),u(Rt,"_volume",Vt);var Lt=(t=>(t.ALL="ALL",t.IDLE="IDLE",t.NONE="NONE",t))(Lt||{});class Tt extends e.EventEmitter{constructor(t){super(),u(this,"tag"),u(this,"settings"),u(this,"motionGroups",{}),u(this,"state",new It),u(this,"currentAudio"),u(this,"currentAnalyzer"),u(this,"currentContext"),u(this,"playing",!1),u(this,"destroyed",!1),u(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){if(!this.definitions)return void ct.warn(this.tag,"Motion definitions are not initialized.");for(const i of Object.keys(this.definitions))this.motionGroups[i]=[];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 i of e){const t=this.definitions[i];if(t)for(let e=0;e<t.length;e++)this.loadMotion(i,e)}}loadMotion(t,e){return h(this,null,function*(){var i,s;if(this.destroyed)return;if(!this.getMotionDefinition(t,e))return;const r=null!=(s=(i=this.motionGroups)[t])?s:i[t]=[];if(null===r[e])return void ct.warn(this.tag,`Cannot start motion at "${t}"[${e}] because it's already failed in loading.`);if(r[e])return r[e];const a=yield this._loadMotion(t,e);return this.destroyed?void 0:(r[e]=null!=a?a:null,a)})}_loadMotion(t,e){throw new Error("Not implemented.")}initializeAudio(t,e){this.currentAudio=t,Rt.volume=e,this.currentContext=t.context.audioContext,this.currentAnalyzer=Rt.addAnalyzer(this.currentAudio,this.currentContext)}speak(t){return h(this,arguments,function*(t,{volume:e=.5,expression:i,resetExpression:s=!0,onFinish:r,onError:a}={}){if(!gt.sound)return!1;let n,o;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,o=t=e.href}else o="data:audio/";const u=t;if(u)try{n=yield Rt.add(u,(t,e=this)=>{ct.error(this.tag,"Error during audio playback:",t),null==a||a(t),s&&i&&e.expressionManager&&e.expressionManager.resetExpression(),e.currentAudio=void 0}),this.initializeAudio(n,e)}catch(h){return ct.warn(this.tag,"Failed to create audio",o,h),!1}if(n){let t=!0;try{gt.motionSync&&Rt.play(n,()=>{null==r||r(),s&&i&&this.expressionManager&&this.expressionManager.resetExpression(),this.currentAudio=void 0})}catch(h){ct.warn(this.tag,"Failed to play audio",n.url,h),t=!1}if(!t)return!1}return this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),i&&this.expressionManager&&(yield this.expressionManager.setExpression(i)),this.playing=!0,!0})}startMotion(t,e){return h(this,arguments,function*(t,e,i=Ft.NORMAL,{sound:s,volume:r=.5,expression:a,resetExpression:n=!0,onFinish:o,onError:l,ignoreParamIds:u=[]}={}){if(this.destroyed)return!1;if(!this.state.reserve(t,e,i))return!1;if(this.currentAudio&&this.currentAudio.isPlaying&&i!=Ft.FORCE)return!1;const h=this.getMotionDefinition(t,e);if(!h)return!1;let d,g;this.currentAudio&&Rt.dispose(this.currentAudio);const c=s&&s.startsWith("data:");if(s&&!c){const t=document.createElement("a");t.href=s,g=s=t.href}else g=this.getSoundFile(h),g&&(g=this.settings.resolveURL(g));const m=g;if(m)try{d=yield Rt.add(m,(t,e=this)=>{ct.error(this.tag,"Error during audio playback:",t),null==l||l(t),n&&a&&e.expressionManager&&e.expressionManager.resetExpression(),e.currentAudio=void 0}),this.initializeAudio(d,r)}catch(_){ct.warn(this.tag,"Failed to create audio",g,_)}const p=yield this.loadMotion(t,e);if(d&&gt.motionSync)try{Rt.play(d,(t=this)=>{null==o||o(),n&&a&&t.expressionManager&&t.expressionManager.resetExpression(),t.currentAudio=void 0})}catch(_){ct.warn(this.tag,"Failed to play audio",d.url,_)}return this.state.start(p,t,e,i)?(this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),ct.log(this.tag,"Start motion:",this.getMotionName(h)),this.emit("motionStart",t,e,d),a&&this.expressionManager&&this.state.shouldOverrideExpression()&&(yield this.expressionManager.setExpression(a)),this.playing=!0,p&&this._startMotion(p,void 0,u),!0):(d&&(Rt.dispose(d),this.currentAudio=void 0),!1)})}startRandomMotion(t,e){return h(this,arguments,function*(t,e,{sound:i,volume:s=.5,expression:r,resetExpression:a=!0,onFinish:n,onError:o}={}){var l,u;if(this.destroyed)return!1;const h=null==(l=this.definitions)?void 0:l[t];if(null==h?void 0:h.length){const l=[],d=null!=(u=this.motionGroups[t])?u:[];for(let e=0;e<h.length;e++)null===d[e]||this.state.isActive(t,e)||l.push(e);if(l.length){const u=l[Math.floor(Math.random()*l.length)];return this.startMotion(t,u,e,{sound:i,volume:s,expression:r,resetExpression:a,onFinish:n,onError:o})}}return!1})}stopSpeaking(){this.currentAudio&&(Rt.dispose(this.currentAudio),this.currentAudio=void 0)}stopAllMotions(){this._stopAllMotions(),this.state.reset(),this.stopSpeaking()}update(t,e){var i;return this.isFinished()&&(this.playing&&(this.playing=!1,this.emit("motionFinish")),this.state.shouldOverrideExpression()&&(null==(i=this.expressionManager)||i.restoreExpression()),this.state.complete(),this.state.shouldRequestIdleMotion()&&this.startRandomMotion(this.groups.idle,Ft.IDLE)),this.updateParameters(t,e)}mouthSync(){return this.currentAnalyzer?Rt.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,i){return h(this,null,function*(){if(this.destroyed)return null;if(!this.state.reserve(t,e,Ft.FORCE))return null;const s=this.getMotionDefinition(t,e);if(!s)return null;this.currentAudio&&Rt.dispose(this.currentAudio);const r=yield this.loadMotion(t,e);return this.state.start(r,t,e,Ft.FORCE)?(this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),ct.log(this.tag,"Start motion:",this.getMotionName(s)),this.emit("motionStart",t,e,void 0),i&&this.expressionManager&&this.state.shouldOverrideExpression()&&(yield this.expressionManager.setExpression(i)),r):null})}getMotionDefinition(t,e){var i,s;const r=null==(s=null==(i=this.definitions)?void 0:i[t])?void 0:s[e];return r||ct.warn(this.tag,`Undefined motion at "${t}"[${e}]`),r}}function At(t,e){if(!Array.isArray(t))return[];const i=[];for(const s of t){if(!s||"object"!=typeof s)continue;const t=s,r="string"==typeof t.id?t.id:"string"==typeof t.Id?t.Id:void 0,a="string"==typeof t.name?t.name:"string"==typeof t.Name?t.Name:void 0;r&&a&&i.push({id:r,name:a,index:e(r)})}return i}const Dt={x:0,y:0,width:0,height:0};class Ot extends e.EventEmitter{constructor(){super(...arguments),u(this,"focusController",new Bt),u(this,"pose"),u(this,"physics"),u(this,"originalWidth",0),u(this,"originalHeight",0),u(this,"width",0),u(this,"height",0),u(this,"localTransform",new e.Matrix),u(this,"drawingMatrix",new e.Matrix),u(this,"hitAreas",{}),u(this,"textureFlipY",!1),u(this,"viewport",[0,0,0,0]),u(this,"destroyed",!1)}init(){this.setupLayout(),this.setupHitAreas()}setupLayout(){const t=this,e=this.getSize();t.originalWidth=e[0],t.originalHeight=e[1];const i=Object.assign({width:2,height:2},this.getLayout());this.localTransform.scale(i.width/2,i.height/2),t.width=this.originalWidth*this.localTransform.a,t.height=this.originalHeight*this.localTransform.d;const s=void 0!==i.x&&i.x-i.width/2||void 0!==i.centerX&&i.centerX||void 0!==i.left&&i.left-i.width/2||void 0!==i.right&&i.right+i.width/2||0,r=void 0!==i.y&&i.y-i.height/2||void 0!==i.centerY&&i.centerY||void 0!==i.top&&i.top-i.height/2||void 0!==i.bottom&&i.bottom+i.height/2||0;this.localTransform.translate(this.width*s,-this.height*r)}setupHitAreas(){const t=this.getHitAreaDefs();this.hitAreas={};for(const e of t)e.name&&(this.hitAreas[e.name]=e)}hitTest(t,e){return Object.keys(this.hitAreas).filter(i=>this.isHit(i,t,e))}isHit(t,e,i){const s=this.hitAreas[t];if(!s)return!1;let r=s.index;if(r<0){if(!s.id)return!1;if(r=this.getDrawableIndex(s.id),r<0)return!1;s.index=r}const a=this.getDrawableBounds(r,Dt);return a.x<=e&&e<=a.x+a.width&&a.y<=i&&i<=a.y+a.height}getDrawableBounds(t,e){const i=this.getDrawableVertices(t);let s=i[0],r=i[0],a=i[1],n=i[1];for(let o=0;o<i.length;o+=2){const t=i[o],e=i[o+1];s=Math.min(t,s),r=Math.max(t,r),a=Math.min(e,a),n=Math.max(e,n)}return null!=e||(e={}),e.x=s,e.y=a,e.width=r-s,e.height=n-a,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 i=this.motionManager.update(t,e),s=this.parallelMotionManager.map(i=>i.update(t,e)),r=i||s.reduce((t,e)=>t||e,!1);return this.emit("afterMotionUpdate"),r}}class kt extends Error{constructor(t,e,i,s=!1){super(t),this.url=e,this.status=i,this.aborted=s}}const Nt=class t{static createXHR(e,i,s,r,a){const n=new XMLHttpRequest;if(t.allXhrSet.add(n),e){let i=t.xhrMap.get(e);i?i.add(n):(i=new Set([n]),t.xhrMap.set(e,i))}return n.open("GET",i),n.responseType=s,n.onload=()=>{var t;200!==n.status&&0!==n.status||!n.response?null==(t=n.onerror)||t.call(n,new ProgressEvent("error")):r(n.response)},n.onerror=()=>{ct.warn("XHRLoader",`Failed to load resource as ${n.responseType} (Status ${n.status}): ${i}`),a(new kt("Network error.",i,n.status))},n.onabort=()=>a(new kt("Aborted.",i,n.status,!0)),n.onloadend=()=>{var i;t.allXhrSet.delete(n),e&&(null==(i=t.xhrMap.get(e))||i.delete(n))},n}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}};u(Nt,"xhrMap",new WeakMap),u(Nt,"allXhrSet",new Set),u(Nt,"loader",t=>new Promise((e,i)=>{const s=t.target,r=t.target&&"function"==typeof Nt.cancelXHRs?Nt.cancelXHRs.bind(t.target):void 0,a=Nt.createXHR(t.target,t.settings?t.settings.resolveURL(t.url):t.url,t.type,i=>{t.result=i,e()},i);if(t.target&&r&&"function"==typeof s.listeners&&"function"==typeof s.once){const t=s.listeners("destroy");Array.isArray(t)&&t.includes(r)||s.once("destroy",r)}a.send()}));let Ut=Nt;function zt(t,e){let i=-1;return function s(r,a){if(a)return Promise.reject(a);if(r<=i)return Promise.reject(new Error("next() called multiple times"));i=r;const n=t[r];if(!n)return Promise.resolve();try{return Promise.resolve(n(e,s.bind(null,r+1)))}catch(o){const t=o instanceof Error?o:new Error(String(o));return Promise.reject(t)}}(0)}class jt{static load(t){return h(this,null,function*(){return yield zt(this.middlewares,t),t.result})}}u(jt,"middlewares",[Ut.loader]);class Gt extends wt{constructor(t){if(super(t),u(this,"moc"),u(this,"textures"),u(this,"layout"),u(this,"hitAreas"),u(this,"initParams"),u(this,"initOpacities"),u(this,"expressions"),u(this,"motions",{}),!Gt.isValidJSON(t))throw new TypeError("Invalid JSON.");this.moc=t.model,ft("string",t,this,"textures","textures"),this.copy(t)}static isValidJSON(t){if(!t||"object"!=typeof t)return!1;const e=!!Array.isArray(t.textures)&&t.textures.every(t=>"string"==typeof t);return"string"==typeof t.model&&e}copy(t){_t("string",t,this,"name","name"),_t("string",t,this,"pose","pose"),_t("string",t,this,"physics","physics"),_t("object",t,this,"layout","layout"),_t("object",t,this,"motions","motions"),ft("object",t,this,"hit_areas","hitAreas"),ft("object",t,this,"expressions","expressions"),ft("object",t,this,"init_params","initParams"),ft("object",t,this,"init_opacities","initOpacities");const e=this.getFileStem(this.moc);this.setModelName(this.name,e)}replaceFiles(t){super.replaceFiles(t);for(const[e,i]of Object.entries(this.motions))for(let s=0;s<i.length;s++)i[s].file=t(i[s].file,`motions.${e}[${s}].file`),void 0!==i[s].sound&&(i[s].sound=t(i[s].sound,`motions.${e}[${s}].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`)}}function Xt(){}const Ht="Live2DFactory",qt=(t,e)=>h(null,null,function*(){if("string"==typeof t.source){const e=yield jt.load({url:t.source,type:"json",target:t.live2dModel});e.url="string"==typeof e.url?e.url:t.source,t.source=e,t.live2dModel.emit("settingsJSONLoaded",e)}return e()}),Wt=(t,e)=>h(null,null,function*(){if(t.source instanceof wt)return t.settings=t.source,e();if("object"==typeof t.source){const i=se.findRuntime(t.source);if(i){const s=i.createModelSettings(t.source);return t.settings=s,t.live2dModel.emit("settingsLoaded",s),e()}}const i=t.source&&"string"==typeof t.source.url?t.source.url:void 0,s=se.runtimes.map(t=>t.version).join(", ");if(0===se.runtimes.length)throw new TypeError(["Unknown settings format: no Live2D runtimes registered.",'Import a published runtime entry before loading models (e.g. "<package>/cubism" for Cubism 3/4/5, "<package>/cubism-legacy" for Cubism 2).',i?`Settings URL: ${i}`:void 0].filter(Boolean).join("\n"));const r=(()=>{try{if(!t.source||"object"!=typeof t.source||Array.isArray(t.source))return;return Object.keys(t.source).slice(0,30).join(", ")}catch(e){return}})();throw new TypeError(["Unknown settings format: no matching runtime found for the loaded settings JSON.",s?`Registered runtimes (versions): ${s}`:void 0,r?`Settings JSON keys: ${r}`:void 0,i?`Settings URL: ${i}`:void 0].filter(Boolean).join("\n"))}),Yt=(t,e)=>{if(t.settings){const i=se.findRuntime(t.settings);if(i)return i.ready().then(()=>e())}return e()},Jt=(t,e)=>h(null,null,function*(){yield e();const i=t.internalModel;if(i){const e=t.settings,s=se.findRuntime(e);if(s){const r=[],a=e instanceof Gt?"json":"arraybuffer";e.pose&&r.push(jt.load({settings:e,url:e.pose,type:a,target:i}).then(e=>{i.pose=s.createPose(i.coreModel,e),t.live2dModel.emit("poseLoaded",i.pose)}).catch(e=>{t.live2dModel.emit("poseLoadError",e),ct.warn(Ht,"Failed to load pose.",e)})),e.physics&&r.push(jt.load({settings:e,url:e.physics,type:a,target:i}).then(e=>{i.physics=s.createPhysics(i.coreModel,e),t.live2dModel.emit("physicsLoaded",i.physics)}).catch(e=>{t.live2dModel.emit("physicsLoadError",e),ct.warn(Ht,"Failed to load physics.",e)})),r.length&&(yield Promise.all(r))}}}),$t=(t,i)=>h(null,null,function*(){if(!t.settings)throw new TypeError("Missing settings.");{const s=t.live2dModel,r={crossOrigin:t.options.crossOrigin};t.settings instanceof Gt&&(r.preferCreateImageBitmap=!1);const a=Promise.all(t.settings.textures.map(i=>function(t,i={}){const s=e.loadTextures.config,r=null==s?void 0:s.crossOrigin,a=null==s?void 0:s.preferCreateImageBitmap,n=null==s?void 0:s.preferWorkers;return void 0!==i.crossOrigin&&s&&(s.crossOrigin=i.crossOrigin),!1===i.preferCreateImageBitmap&&s&&(s.preferCreateImageBitmap=!1,s.preferWorkers=!1),e.Assets.load(t).catch(t=>{if(t instanceof Error)throw t;throw new Error("Texture loading error",{cause:t})}).finally(()=>{s&&(s.crossOrigin=null!=r?r:s.crossOrigin,!1===i.preferCreateImageBitmap&&(s.preferCreateImageBitmap=null!=a?a:s.preferCreateImageBitmap,s.preferWorkers=null!=n?n:s.preferWorkers))})}(t.settings.resolveURL(i),r)));if(a.catch(Xt),yield i(),!t.internalModel)throw new TypeError("Missing internal model.");s.internalModel=t.internalModel,s.emit("modelLoaded",t.internalModel),s.textures=yield a,s.emit("textureLoaded",s.textures)}}),Zt=(t,e)=>h(null,null,function*(){const i=t.settings;if(i instanceof wt){const s=se.findRuntime(i);if(!s)throw new TypeError("Unknown model settings.");const r=yield jt.load({settings:i,url:i.moc,type:"arraybuffer",target:t.live2dModel});if(!s.isValidMoc(r))throw new Error("Invalid moc data");const a=s.createCoreModel(r);return t.internalModel=s.createInternalModel(a,i,t.options),e()}throw new TypeError("Missing settings.")}),Kt=class t{static unzip(e,i){return h(this,null,function*(){const s=yield t.getFilePaths(e),r=[];for(const t of i.getDefinedFiles()){const e=decodeURI(Mt(i.url,t));s.includes(e)&&r.push(e)}const a=yield t.getFiles(e,r);for(let t=0;t<a.length;t++){const e=r[t],i=a[t];Object.defineProperty(i,"webkitRelativePath",{value:e})}return a})}static createSettings(e){return h(this,null,function*(){const i=(yield t.getFilePaths(e)).find(t=>t.endsWith("model.json")||t.endsWith("model3.json"));if(!i)throw new Error("Settings file not found");const s=yield t.readText(e,i);if(!s)throw new Error("Empty settings file: "+i);const r=JSON.parse(s);r.url=i;const a=t.live2dFactory.findRuntime(r);if(!a)throw new Error("Unknown settings JSON");return a.createModelSettings(r)})}static zipReader(t,e){return Promise.reject(new Error("Not implemented"))}static getFilePaths(t){return Promise.reject(new Error("Not implemented"))}static getFiles(t,e){return Promise.reject(new Error("Not implemented"))}static readText(t,e){return Promise.reject(new Error("Not implemented"))}static releaseReader(t){}};u(Kt,"live2dFactory"),u(Kt,"ZIP_PROTOCOL","zip://"),u(Kt,"uid",0),u(Kt,"factory",(t,e)=>h(null,null,function*(){const i=t.source;let s,r,a;if("string"==typeof i&&(i.endsWith(".zip")||i.startsWith(Kt.ZIP_PROTOCOL))?(s=i.startsWith(Kt.ZIP_PROTOCOL)?i.slice(Kt.ZIP_PROTOCOL.length):i,r=yield jt.load({url:s,type:"blob",target:t.live2dModel})):Array.isArray(i)&&1===i.length&&i[0]instanceof File&&i[0].name.endsWith(".zip")&&(r=i[0],s=URL.createObjectURL(r),a=i.settings),r){if(!r.size)throw new Error("Empty zip file");const e=yield Kt.zipReader(r,s);a||(a=yield Kt.createSettings(e)),a._objectURL=Kt.ZIP_PROTOCOL+Kt.uid+"/"+a.url;const i=yield Kt.unzip(e,a);i.settings=a,t.source=i,s.startsWith("blob:")&&t.live2dModel.once("modelLoaded",t=>{t.once("destroy",function(){URL.revokeObjectURL(s)})}),Kt.releaseReader(e)}return e()}));let Qt=Kt;const te=class t{static resolveURL(e,i){var s;const r=null==(s=t.filesMap[e])?void 0:s[i];if(void 0===r)throw new Error("Cannot find this file from uploaded files: "+i);return r}static upload(e,i){const s={};for(const t of i.getDefinedFiles()){const r=decodeURI(Mt(i.url,t)),a=e.find(t=>t.webkitRelativePath===r);a&&(s[t]=URL.createObjectURL(a))}t.filesMap[i._objectURL]=s}static createSettings(e){return h(this,null,function*(){const i=e.find(t=>t.name.endsWith("model.json")||t.name.endsWith("model3.json"));if(!i)throw new TypeError("Settings file not found");const s=yield t.readText(i),r=JSON.parse(s);r.url=i.webkitRelativePath;const a=se.findRuntime(r);if(!a)throw new Error("Unknown settings JSON");const n=a.createModelSettings(r);return n._objectURL=URL.createObjectURL(i),n})}static readText(t){return h(this,null,function*(){return new Promise((e,i)=>{const s=new FileReader;s.onload=()=>e(s.result),s.onerror=i,s.readAsText(t,"utf8")})})}};u(te,"live2dFactory"),u(te,"filesMap",{}),u(te,"factory",(t,e)=>h(null,null,function*(){if(Array.isArray(t.source)&&t.source[0]instanceof File){const e=t.source;let i=e.settings;if(i){if(!i._objectURL)throw new Error('"_objectURL" must be specified in ModelSettings')}else i=yield te.createSettings(e);i.validateFiles(e.map(t=>encodeURI(t.webkitRelativePath))),te.upload(e,i),i.resolveURL=function(t){return te.resolveURL(this._objectURL,t)},t.source=i,t.live2dModel.once("modelLoaded",t=>{t.once("destroy",function(){const t=this.settings._objectURL;if(URL.revokeObjectURL(t),te.filesMap[t])for(const e of Object.values(te.filesMap[t]))URL.revokeObjectURL(e);delete te.filesMap[t]})})}return e()}));let ee=te;const ie=class t{static registerRuntime(e){t.runtimes.push(e),t.runtimes.sort((t,e)=>e.version-t.version)}static findRuntime(e){for(const i of t.runtimes)if(i.test(e))return i}static setupLive2DModel(e,i,s){return h(this,null,function*(){const r=new Promise(t=>e.once("textureLoaded",t)),a=new Promise(t=>e.once("modelLoaded",t)),n=Promise.all([r,a]).then(()=>e.emit("ready"));yield zt(t.live2DModelMiddlewares,{live2dModel:e,source:i,options:s||{}}),yield n,e.emit("load")})}static loadMotion(e,i,s){var r;const a=t=>e.emit("motionLoadError",i,s,t);try{const n=null==(r=e.definitions[i])?void 0:r[s];if(!n)return Promise.resolve(void 0);e.once("destroy",()=>t.releaseMotionTasks(e));let o=t.motionTasksMap.get(e);o||(o={},t.motionTasksMap.set(e,o));let l=o[i];l||(l=[],o[i]=l);const u=e.getMotionFile(n);return null!=l[s]||(l[s]=jt.load({url:u,settings:e.settings,type:e.motionDataType,target:e}).then(r=>{var a;const o=null==(a=t.motionTasksMap.get(e))?void 0:a[i];o&&(o[s]=void 0);const l=r,u=e.createMotion(l,i,n);return e.emit("motionLoaded",i,s,u),u}).catch(t=>{ct.warn(e.tag,`Failed to load motion: ${u}\n`,t),a(t)})),l[s]}catch(n){ct.warn(e.tag,`Failed to load motion at "${i}"[${s}]\n`,n),a(n)}return Promise.resolve(void 0)}static loadExpression(e,i){var s;const r=t=>e.emit("expressionLoadError",i,t);try{const a=e.definitions[i];if(!a)return Promise.resolve(void 0);e.once("destroy",()=>t.releaseExpressionTasks(e));let n=t.expressionTasksMap.get(e);n||(n=[],t.expressionTasksMap.set(e,n));const o=e.getExpressionFile(a),l=null!=(s=e.expressionDataType)?s:"json";return null!=n[i]||(n[i]=jt.load({url:o,settings:e.settings,type:l,target:e}).then(s=>{const r=t.expressionTasksMap.get(e);r&&(r[i]=void 0);const n=s,o=e.createExpression(n,a);return e.emit("expressionLoaded",i,o),o}).catch(t=>{ct.warn(e.tag,`Failed to load expression: ${o}\n`,t),r(t)})),n[i]}catch(a){ct.warn(e.tag,`Failed to load expression at [${i}]\n`,a),r(a)}return Promise.resolve(void 0)}static releaseMotionTasks(e){t.motionTasksMap.delete(e)}static releaseExpressionTasks(e){t.expressionTasksMap.delete(e)}};u(ie,"runtimes",[]),u(ie,"urlToJSON",qt),u(ie,"jsonToSettings",Wt),u(ie,"waitUntilReady",Yt),u(ie,"setupOptionals",Jt),u(ie,"setupEssentials",$t),u(ie,"createInternalModel",Zt),u(ie,"live2DModelMiddlewares",[Qt.factory,ee.factory,qt,Wt,Yt,Jt,$t,Zt]),u(ie,"motionTasksMap",new WeakMap),u(ie,"expressionTasksMap",new WeakMap);let se=ie;Tt.prototype._loadMotion=function(t,e){return se.loadMotion(this,t,e)},vt.prototype._loadExpression=function(t){return se.loadExpression(this,t)},ee.live2dFactory=se,Qt.live2dFactory=se;const re=class t{constructor(i,{autoUpdate:s=!0,autoHitTest:r=!0,autoFocus:a=!0,autoInteract:n,ticker:o}={}){var l;u(this,"model"),u(this,"destroyed",!1),u(this,"_ticker"),u(this,"_autoUpdate",!1),u(this,"_autoHitTest",!1),u(this,"_autoFocus",!1),null!=o||(o=null!=(l=t.defaultTicker)?l:"undefined"!=typeof PIXI?PIXI.Ticker.shared:e.Ticker.shared),void 0!==n&&(r=n,a=n,ct.warn(i.tag,"options.autoInteract is deprecated since v0.5.0, use autoHitTest and autoFocus instead.")),this.model=i,this.ticker=o,this.autoUpdate=s,this.autoHitTest=r,this.autoFocus=a,(r||a)&&(this.model.eventMode="static")}get ticker(){return this._ticker}set ticker(t){var e,i;this._ticker&&this._ticker.remove(ne,this),this._ticker=t,this._autoUpdate&&(null==(e=this._ticker)||e.add(ne,this),null==(i=this._ticker)||i.start())}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){var e;this.destroyed||(t?this._ticker?(this._ticker.add(ne,this),this._autoUpdate=!0):ct.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(ne,this),this._autoUpdate=!1))}get autoHitTest(){return this._autoHitTest}set autoHitTest(t){t!==this.autoHitTest&&(t?this.model.on("pointertap",oe,this):this.model.off("pointertap",oe,this),this._autoHitTest=t)}get autoFocus(){return this._autoFocus}set autoFocus(t){t!==this.autoFocus&&(t?(this.model.on("globalpointermove",le,this),this.model.on("pointermove",le,this)):(this.model.off("globalpointermove",le,this),this.model.off("pointermove",le,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}};u(re,"defaultTicker");let ae=re;function ne(){this.onTickerUpdate()}function oe(t){this.onTap(t)}function le(t){this.onPointerMove(t)}class ue extends e.Transform{}const he=new e.Point,de=new e.Matrix,ge=new e.Matrix,ce={x:0,y:0,width:0,height:0},me=new e.Bounds;class pe{constructor(t){this.renderer=t}execute(t){!t.visible||t.alpha<=0||t.renderLive2D(this.renderer)}updateRenderable(){}destroy(){}}class _e extends e.Container{constructor(t){super(),u(this,"renderPipeId","live2d"),u(this,"tag","Live2DModel(uninitialized)"),u(this,"internalModel"),u(this,"textures",[]),u(this,"transform",new ue),u(this,"anchor"),u(this,"_bounds",new e.Bounds),u(this,"_boundsDirty",!0),u(this,"_boundsRetryAfterDraw",!1),u(this,"gl",null),u(this,"elapsedTime",0),u(this,"deltaTime",0),u(this,"automator"),u(this,"currentGlId",0),u(this,"renderLive2D",t=>{var i,s,r,a,n;if(!(t instanceof e.WebGLRenderer))throw new Error("Renderer is not supported");t.geometry.resetState(),t.shader.resetState(),t.texture.resetState();let o=!1;this.gl!==t.gl&&(this.gl=t.gl,this.internalModel.updateWebGLContext(t.gl,this.generateUID()),o=!0);for(let e=0;e<this.textures.length;e++){const i=this.textures[e],s=Boolean(i.source._gpuData[t.uid]);!o&&s||(t.gl.pixelStorei(WebGLRenderingContext.UNPACK_FLIP_Y_WEBGL,this.internalModel.textureFlipY),t.texture.bind(i,0)),this.internalModel.bindTexture(e,t.texture.getGlSource(i.source).texture)}const l=t.renderTarget.viewport,u=t.renderTarget.renderTarget;let h=l.y;if(null==u?void 0:u.isRoot){h=u.colorTexture.source.pixelHeight-l.height-l.y}this.internalModel.viewport=[l.x,h,l.width,l.height];const d=this.deltaTime;this.deltaTime=0,d&&this.internalModel.update(d,this.elapsedTime);const{projectionMatrix:g,offset:c}=t.globalUniforms.globalUniformData,m=ge.copyFrom(this.worldTransform);m.tx-=null!=(i=null==c?void 0:c.x)?i:0,m.ty-=null!=(s=null==c?void 0:c.y)?s:0;const p=de.copyFrom(g).append(m);this.internalModel.updateTransform(p),this.internalModel.draw(t.gl),this._boundsRetryAfterDraw&&this.updateDrawableBounds(),t.state.resetState(),t.texture.resetState();const _=null==(r=t.renderTarget)?void 0:r.defaultClearColor,f=null==(n=null==(a=t.renderTarget)?void 0:a.adaptor)?void 0:n._clearColorCache;_&&(t.gl.clearColor(_[0],_[1],_[2],_[3]),f&&(f[0]=_[0],f[1]=_[1],f[2]=_[2],f[3]=_[3]))}),this.anchor=new e.ObservablePoint({_onUpdate:()=>this.onAnchorChange()},0,0),this.automator=new ae(this,t),this.once("modelLoaded",()=>this.initializeOnModelLoad(t))}get isRenderable(){return!0}get canBundle(){return!1}static from(t,e){return h(this,null,function*(){const i=new this(e);return yield se.setupLive2DModel(i,t,e),i})}static fromSync(t,e){const i=new this(e);return se.setupLive2DModel(i,t,e).then(()=>{var t;return null==(t=null==e?void 0:e.onLoad)?void 0:t.call(e)}).catch(t=>{var i;return null==(i=null==e?void 0:e.onError)?void 0:i.call(e,t)}),i}static registerTicker(t){ae.defaultTicker=t.shared}get bounds(){return this.internalModel?(this._boundsDirty&&this.updateDrawableBounds(),this._bounds):(this._bounds.set(0,0,0,0),this._bounds)}updateDrawableBounds(){if(!this.internalModel)return this._bounds.set(0,0,0,0),void(this._boundsDirty=!1);const t=this.internalModel.getDrawableIDs();me.clear();for(let i=0;i<t.length;i++){const s=t[i],r=this.internalModel.getDrawableIndex(s);if(r<0)continue;const a=this.internalModel.getDrawableBounds(r,ce);Number.isFinite(a.x)&&Number.isFinite(a.y)&&Number.isFinite(a.width)&&Number.isFinite(a.height)&&me.addFrame(a.x,a.y,a.x+a.width,a.y+a.height,e.Matrix.IDENTITY)}if(this._bounds.clear(),me.isValid&&me.isPositive)this._bounds.addFrame(me.minX,me.minY,me.maxX,me.maxY,this.internalModel.localTransform),this._boundsRetryAfterDraw=!1;else{const t=this.internalModel.originalWidth||this.internalModel.width,e=this.internalModel.originalHeight||this.internalModel.height;this._bounds.addFrame(0,0,t,e,this.internalModel.localTransform),this._boundsRetryAfterDraw=!0}this._boundsDirty=!1}generateUID(){return++this.currentGlId}collectRenderables(t,e,i){var s,r,a,n;if(this.parentRenderLayer&&this.parentRenderLayer!==i)return;if(this.globalDisplayStatus<7)return;if(!this.includeInBuild)return;this.sortableChildren&&this.sortChildren(),function(t){const e=t;e.renderPipes.live2d||(e.renderPipes.live2d=new pe(t))}(e);const o=e.renderPipes,l=()=>{var e,i;null==(i=null==(e=o.batch)?void 0:e.break)||i.call(e,t),t.add(this)},u=()=>{const s=this.children,r=s.length;for(let a=0;a<r;a++)s[a].collectRenderables(t,e,i)},h=this.effects;if(h){for(let e=0;e<h.length;e++){const i=h[e],a=i.filters;if(a)for(const t of a)t&&"number"==typeof t.resolution&&1===t.resolution&&(t.resolution="inherit");null==(r=null==(s=o[i.pipe])?void 0:s.push)||r.call(s,i,this,t)}l(),u();for(let e=h.length-1;e>=0;e--){const i=h[e];null==(n=null==(a=o[i.pipe])?void 0:a.pop)||n.call(a,i,this,t)}}else l(),u()}initializeOnModelLoad(t){this.tag=`Live2DModel(${this.internalModel.settings.name})`,this.onAnchorChange(),this.updateDrawableBounds()}onAnchorChange(){this.internalModel&&this.pivot&&this.pivot.set(this.anchor.x*this.internalModel.width,this.anchor.y*this.internalModel.height)}motion(t,e,i){return h(this,arguments,function*(t,e,i,{sound:s,volume:r=.5,expression:a,resetExpression:n=!0,onFinish:o,onError:l}={}){return void 0===e?this.internalModel.motionManager.startRandomMotion(t,i,{sound:s,volume:r,expression:a,resetExpression:n,onFinish:o,onError:l}):this.internalModel.motionManager.startMotion(t,e,i,{sound:s,volume:r,expression:a,resetExpression:n,onFinish:o,onError:l})})}motionLastFrame(t,e){return h(this,arguments,function*(t,e,{expression:i}={}){return this.internalModel.motionManager.motionLastFrame(t,e,{expression:i})})}parallelMotion(t){return h(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)),i=[];for(const t of e)i.push(yield t);return i})}parallelLastFrame(t){return h(this,null,function*(){this.internalModel.extendParallelMotionManager(t.length);const e=t.map((t,e)=>this.internalModel.parallelMotionManager[e].playMotionLastFrame(t.group,t.index)),i=[];for(const t of e)i.push(yield t);return i})}stopMotions(){return this.internalModel.motionManager.stopAllMotions()}speak(t,{volume:e=.5,expression:i,resetExpression:s=!0,onFinish:r,onError:a}={}){return this.internalModel.motionManager.speak(t,{volume:e,expression:i,resetExpression:s,onFinish:r,onError:a})}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,i=!1){he.x=t,he.y=e,this.toModelPosition(he,he,!0);const s=he.x/this.internalModel.originalWidth*2-1,r=he.y/this.internalModel.originalHeight*2-1,a=Math.atan2(r,s);this.internalModel.focusController.focus(Math.cos(a),-Math.sin(a),i)}tap(t,e){const i=this.hitTest(t,e);i.length&&this.emit("hit",i)}hitTest(t,e){return he.x=t,he.y=e,this.toModelPosition(he,he),this.internalModel.hitTest(he.x,he.y)}toModelPosition(t,e=t.clone(),i){return i||this.updateLocalTransform(),this.toLocal(t,void 0,e,i),this.internalModel.localTransform.applyInverse(e,e),e}containsPoint(t){return this.bounds.containsPoint(t.x,t.y)}_calculateBounds(){if(!this.internalModel)return void this.getBounds().set(0,0,0,0);const t=this.internalModel.width,e=this.internalModel.height;this.getBounds().addFrame(0,0,t,e,this.transform.matrix)}update(t){this.deltaTime+=t,this.elapsedTime+=t}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("undefined"==typeof window||void 0===window.Live2DCubismCore)throw new Error("Could not find Cubism runtime. This plugin requires live2dcubismcore.js to be loaded.");class fe{constructor(t,e){this.x=t,this.y=e,this.x=null==t?0:t,this.y=null==e?0:e}add(t){const e=new fe(0,0);return e.x=this.x+t.x,e.y=this.y+t.y,e}substract(t){const e=new fe(0,0);return e.x=this.x-t.x,e.y=this.y-t.y,e}multiply(t){const e=new fe(0,0);return e.x=this.x*t.x,e.y=this.y*t.y,e}multiplyByScaler(t){return this.multiply(new fe(t,t))}division(t){const e=new fe(0,0);return e.x=this.x/t.x,e.y=this.y/t.y,e}divisionByScalar(t){return this.division(new fe(t,t))}getLength(){return Math.sqrt(this.x*this.x+this.y*this.y)}getDistanceWith(t){return Math.sqrt((this.x-t.x)*(this.x-t.x)+(this.y-t.y)*(this.y-t.y))}dot(t){return this.x*t.x+this.y*t.y}normalize(){const t=Math.pow(this.x*this.x+this.y*this.y,.5);this.x=this.x/t,this.y=this.y/t}isEqual(t){return this.x==t.x&&this.y==t.y}isNotEqual(t){return!this.isEqual(t)}}var ye;(t=>{t.CubismVector2=fe})(ye||(ye={}));const xe=class t{static range(t,e,i){return t<e?t=e:t>i&&(t=i),t}static sin(t){return Math.sin(t)}static cos(t){return Math.cos(t)}static abs(t){return Math.abs(t)}static sqrt(t){return Math.sqrt(t)}static cbrt(t){if(0===t)return t;let e=t;const i=e<0;let s;return i&&(e=-e),e===1/0?s=1/0:(s=Math.exp(Math.log(e)/3),s=(e/(s*s)+2*s)/3),i?-s:s}static getEasingSine(t){return t<0?0:t>1?1:.5-.5*this.cos(t*Math.PI)}static max(t,e){return t>e?t:e}static min(t,e){return t>e?e:t}static clamp(t,e,i){return t<e?e:i<t?i:t}static degreesToRadian(t){return t/180*Math.PI}static radianToDegrees(t){return 180*t/Math.PI}static directionToRadian(t,e){let i=Math.atan2(e.y,e.x)-Math.atan2(t.y,t.x);for(;i<-Math.PI;)i+=2*Math.PI;for(;i>Math.PI;)i-=2*Math.PI;return i}static directionToDegrees(t,e){const i=this.directionToRadian(t,e);let s=this.radianToDegrees(i);return e.x-t.x>0&&(s=-s),s}static radianToDirection(t){const e=new fe;return e.x=this.sin(t),e.y=this.cos(t),e}static quadraticEquation(e,i,s){return this.abs(e)<t.Epsilon?this.abs(i)<t.Epsilon?-s:-s/i:-(i+this.sqrt(i*i-4*e*s))/(2*e)}static cardanoAlgorithmForBezier(e,i,s,r){if(this.abs(e)<t.Epsilon)return this.range(this.quadraticEquation(i,s,r),0,1);const a=i/e,n=s/e,o=(3*n-a*a)/3,l=o/3,u=(2*a*a*a-9*a*n+27*(r/e))/27,h=u/2,d=h*h+l*l*l,g=.5,c=.51;if(d<0){const t=-o/3,e=t*t*t,i=this.sqrt(e),s=-u/(2*i),r=this.range(s,-1,1),n=Math.acos(r),l=2*this.cbrt(i),h=l*this.cos(n/3)-a/3;if(this.abs(h-g)<c)return this.range(h,0,1);const d=l*this.cos((n+2*Math.PI)/3)-a/3;if(this.abs(d-g)<c)return this.range(d,0,1);const m=l*this.cos((n+4*Math.PI)/3)-a/3;return this.range(m,0,1)}if(0==d){let t;t=h<0?this.cbrt(-h):-this.cbrt(h);const e=2*t-a/3;if(this.abs(e-g)<c)return this.range(e,0,1);const i=-t-a/3;return this.range(i,0,1)}const m=this.sqrt(d),p=this.cbrt(m-h)-this.cbrt(m+h)-a/3;return this.range(p,0,1)}static mod(t,e){if(!isFinite(t)||0===e||isNaN(t)||isNaN(e))return console.warn(`divided: ${t}, divisor: ${e} mod() returns 'NaN'.`),NaN;const i=Math.abs(t),s=Math.abs(e);let r=i-Math.floor(i/s)*s;return r*=Math.sign(t),r}constructor(){}};xe.Epsilon=1e-5;let Ce=xe;var Se,Me;(t=>{t.CubismMath=Ce})(Se||(Se={}));class ve{constructor(){this.setBeganMotionHandler=t=>this._onBeganMotion=t,this.getBeganMotionHandler=()=>this._onBeganMotion,this.setFinishedMotionHandler=t=>this._onFinishedMotion=t,this.getFinishedMotionHandler=()=>this._onFinishedMotion,this._fadeInSeconds=-1,this._fadeOutSeconds=-1,this._weight=1,this._offsetSeconds=0,this._isLoop=!1,this._isLoopFadeIn=!0,this._previousLoopState=this._isLoop,this._firedEventValues=new g}static delete(t){t.release(),t=null}release(){this._weight=0}updateParameters(t,e,i){if(!e.isAvailable()||e.isFinished())return;this.setupMotionQueueEntry(e,i);const s=this.updateFadeWeight(e,i);this.doUpdateParameters(t,i,s,e),e.getEndTime()>0&&e.getEndTime()<i&&e.setIsFinished(!0)}setupMotionQueueEntry(t,e){null==t||t.isStarted()||t.isAvailable()&&(t.setIsStarted(!0),t.setStartTime(e-this._offsetSeconds),t.setFadeInStartTime(e),t.getEndTime()<0&&this.adjustEndTime(t),t._motion._onBeganMotion&&t._motion._onBeganMotion(t._motion))}updateFadeWeight(t,e){null==t&&k.print(dt.LogLevel_Error,"motionQueueEntry is null.");let i=this._weight;return i=i*(0==this._fadeInSeconds?1:Ce.getEasingSine((e-t.getFadeInStartTime())/this._fadeInSeconds))*(0==this._fadeOutSeconds||t.getEndTime()<0?1:Ce.getEasingSine((t.getEndTime()-e)/this._fadeOutSeconds)),t.setState(e,i),L(0<=i&&i<=1),i}setFadeInTime(t){this._fadeInSeconds=t}setFadeOutTime(t){this._fadeOutSeconds=t}getFadeOutTime(){return this._fadeOutSeconds}getFadeInTime(){return this._fadeInSeconds}setWeight(t){this._weight=t}getWeight(){return this._weight}getDuration(){return-1}getLoopDuration(){return-1}setOffsetTime(t){this._offsetSeconds=t}setLoop(t){this._isLoop=t}getLoop(){return this._isLoop}setLoopFadeIn(t){this._isLoopFadeIn=t}getLoopFadeIn(){return this._isLoopFadeIn}getFiredEvent(t,e){return this._firedEventValues}isExistModelOpacity(){return!1}getModelOpacityIndex(){return-1}getModelOpacityId(t){return null}getModelOpacityValue(){return 1}adjustEndTime(t){const e=this.getDuration(),i=e<=0?-1:t.getStartTime()+e;t.setEndTime(i)}}(t=>{t.ACubismMotion=ve})(Me||(Me={}));const be="Parameters",Pe="Blend",Be=class t extends ve{static create(e,i){const s=new t;return s.parse(e,i),s}doUpdateParameters(t,e,i,s){for(let r=0;r<this._parameters.getSize();++r){const e=this._parameters.at(r);switch(e.blendType){case 0:t.addParameterValueById(e.parameterId,e.value,i);break;case 1:t.multiplyParameterValueById(e.parameterId,e.value,i);break;case 2:t.setParameterValueById(e.parameterId,e.value,i)}}}calculateExpressionParameters(e,i,s,r,a,n){if(null!=s&&null!=r&&s.isAvailable()){this._fadeWeight=this.updateFadeWeight(s,i);for(let i=0;i<r.getSize();++i){const s=r.at(i);if(null==s.parameterId)continue;const o=s.overwriteValue=e.getParameterValueById(s.parameterId),l=this.getExpressionParameters();let u=-1;for(let t=0;t<l.getSize();++t)if(s.parameterId==l.at(t).parameterId){u=t;break}if(u<0){0==a?(s.additiveValue=t.DefaultAdditiveValue,s.multiplyValue=t.DefaultMultiplyValue,s.overwriteValue=o):(s.additiveValue=this.calculateValue(s.additiveValue,t.DefaultAdditiveValue,n),s.multiplyValue=this.calculateValue(s.multiplyValue,t.DefaultMultiplyValue,n),s.overwriteValue=this.calculateValue(s.overwriteValue,o,n));continue}const h=l.at(u).value;let d,g,c;switch(l.at(u).blendType){case 0:d=h,g=t.DefaultMultiplyValue,c=o;break;case 1:d=t.DefaultAdditiveValue,g=h,c=o;break;case 2:d=t.DefaultAdditiveValue,g=t.DefaultMultiplyValue,c=h;break;default:return}0==a?(s.additiveValue=d,s.multiplyValue=g,s.overwriteValue=c):(s.additiveValue=s.additiveValue*(1-n)+d*n,s.multiplyValue=s.multiplyValue*(1-n)+g*n,s.overwriteValue=s.overwriteValue*(1-n)+c*n)}}}getExpressionParameters(){return this._parameters}getFadeWeight(){return this._fadeWeight}parse(t,e){const i=Y.create(t,e);if(!i)return;const s=i.getRoot();this.setFadeInTime(s.getValueByString("FadeInTime").toFloat(1)),this.setFadeOutTime(s.getValueByString("FadeOutTime").toFloat(1));const r=s.getValueByString(be).getSize();this._parameters.prepareCapacity(r);for(let a=0;a<r;++a){const t=s.getValueByString(be).getValueByIndex(a),e=ht.getIdManager().getId(t.getValueByString("Id").getRawString()),i=t.getValueByString("Value").toFloat();let r;r=t.getValueByString(Pe).isNull()||"Add"==t.getValueByString(Pe).getString()?0:"Multiply"==t.getValueByString(Pe).getString()?1:"Overwrite"==t.getValueByString(Pe).getString()?2:0;const n=new Ve;n.parameterId=e,n.blendType=r,n.value=i,this._parameters.pushBack(n)}Y.delete(i)}calculateValue(t,e,i){return t*(1-i)+e*i}constructor(){super(),this._parameters=new g,this._fadeWeight=0}};Be.DefaultAdditiveValue=0,Be.DefaultMultiplyValue=1;let we=Be;var Fe,Ie,Ee=(t=>(t[t.Additive=0]="Additive",t[t.Multiply=1]="Multiply",t[t.Overwrite=2]="Overwrite",t))(Ee||{});class Ve{}(t=>{t.CubismExpressionMotion=we,t.ExpressionBlendType=Ee,t.ExpressionParameter=Ve})(Fe||(Fe={}));class Re{constructor(){this._autoDelete=!1,this._motion=null,this._available=!0,this._finished=!1,this._started=!1,this._startTimeSeconds=-1,this._fadeInStartTimeSeconds=0,this._endTimeSeconds=-1,this._stateTimeSeconds=0,this._stateWeight=0,this._lastEventCheckSeconds=0,this._motionQueueEntryHandle=this,this._fadeOutSeconds=0,this._isTriggeredFadeOut=!1}release(){this._autoDelete&&this._motion&&ve.delete(this._motion)}setFadeOut(t){this._fadeOutSeconds=t,this._isTriggeredFadeOut=!0}startFadeOut(t,e){const i=e+t;this._isTriggeredFadeOut=!0,(this._endTimeSeconds<0||i<this._endTimeSeconds)&&(this._endTimeSeconds=i)}isFinished(){return this._finished}isStarted(){return this._started}getStartTime(){return this._startTimeSeconds}getFadeInStartTime(){return this._fadeInStartTimeSeconds}getEndTime(){return this._endTimeSeconds}setStartTime(t){this._startTimeSeconds=t}setFadeInStartTime(t){this._fadeInStartTimeSeconds=t}setEndTime(t){this._endTimeSeconds=t}setIsFinished(t){this._finished=t}setIsStarted(t){this._started=t}isAvailable(){return this._available}setIsAvailable(t){this._available=t}setState(t,e){this._stateTimeSeconds=t,this._stateWeight=e}getStateTime(){return this._stateTimeSeconds}getStateWeight(){return this._stateWeight}getLastCheckEventSeconds(){return this._lastEventCheckSeconds}setLastCheckEventSeconds(t){this._lastEventCheckSeconds=t}isTriggeredFadeOut(){return this._isTriggeredFadeOut}getFadeOutSeconds(){return this._fadeOutSeconds}getCubismMotion(){return this._motion}}(t=>{t.CubismMotionQueueEntry=Re})(Ie||(Ie={}));class Le{constructor(){this._userTimeSeconds=0,this._eventCallBack=null,this._eventCustomData=null,this._motions=new g}release(){for(let t=0;t<this._motions.getSize();++t)this._motions.at(t)&&(this._motions.at(t).release(),this._motions.set(t,null));this._motions=null}startMotion(t,e,i){if(null==t)return Te;let s=null;for(let r=0;r<this._motions.getSize();++r)s=this._motions.at(r),null!=s&&s.setFadeOut(s._motion.getFadeOutTime());return s=new Re,s._autoDelete=e,s._motion=t,this._motions.pushBack(s),s._motionQueueEntryHandle}isFinished(){for(let t=this._motions.begin();t.notEqual(this._motions.end());){let e=t.ptr();if(null==e){t=this._motions.erase(t);continue}if(null!=e._motion){if(!e.isFinished())return!1;t.preIncrement()}else e.release(),e=null,t=this._motions.erase(t)}return!0}isFinishedByHandle(t){for(let e=this._motions.begin();e.notEqual(this._motions.end());e.increment()){const i=e.ptr();if(null!=i&&(i._motionQueueEntryHandle==t&&!i.isFinished()))return!1}return!0}stopAllMotions(){for(let t=this._motions.begin();t.notEqual(this._motions.end());){let e=t.ptr();null!=e?(e.release(),e=null,t=this._motions.erase(t)):t=this._motions.erase(t)}}getCubismMotionQueueEntries(){return this._motions}getCubismMotionQueueEntry(t){for(let e=this._motions.begin();e.notEqual(this._motions.end());e.preIncrement()){const i=e.ptr();if(null!=i&&i._motionQueueEntryHandle==t)return i}return null}setEventCallback(t,e=null){this._eventCallBack=t,this._eventCustomData=e}doUpdateMotion(t,e){let i=!1;for(let s=this._motions.begin();s.notEqual(this._motions.end());){let r=s.ptr();if(null==r){s=this._motions.erase(s);continue}const a=r._motion;if(null==a){r.release(),r=null,s=this._motions.erase(s);continue}a.updateParameters(t,r,e),i=!0;const n=a.getFiredEvent(r.getLastCheckEventSeconds()-r.getStartTime(),e-r.getStartTime());for(let t=0;t<n.getSize();++t)this._eventCallBack(this,n.at(t),this._eventCustomData);r.setLastCheckEventSeconds(e),r.isFinished()?(r.release(),r=null,s=this._motions.erase(s)):(r.isTriggeredFadeOut()&&r.startFadeOut(r.getFadeOutSeconds(),e),s.preIncrement())}return i}}const Te=-1;var Ae;(t=>{t.CubismMotionQueueManager=Le,t.InvalidMotionQueueEntryHandleValue=Te})(Ae||(Ae={}));class De extends vt{constructor(t,e){var i,s;super(t,e),u(this,"expressionDataType","arraybuffer"),u(this,"queueManager",new Le),u(this,"definitions"),this.definitions=null!=(s=null==(i=t.expressions)?void 0:i.filter(t=>!!t&&"string"==typeof t.File))?s:[],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 we.create(t,t.byteLength)}_setExpression(t){return this.queueManager.startMotion(t,!1)}stopAllExpressions(){this.queueManager.stopAllMotions()}updateParameters(t,e){return this.queueManager.doUpdateMotion(t,e)}createDefaultExpression(){const t=(new TextEncoder).encode(JSON.stringify({FadeInTime:0,FadeOutTime:0,Parameters:[]})).buffer;return we.create(t,t.byteLength)}}var Oe,ke=(t=>(t[t.CubismMotionCurveTarget_Model=0]="CubismMotionCurveTarget_Model",t[t.CubismMotionCurveTarget_Parameter=1]="CubismMotionCurveTarget_Parameter",t[t.CubismMotionCurveTarget_PartOpacity=2]="CubismMotionCurveTarget_PartOpacity",t))(ke||{}),Ne=(t=>(t[t.CubismMotionSegmentType_Linear=0]="CubismMotionSegmentType_Linear",t[t.CubismMotionSegmentType_Bezier=1]="CubismMotionSegmentType_Bezier",t[t.CubismMotionSegmentType_Stepped=2]="CubismMotionSegmentType_Stepped",t[t.CubismMotionSegmentType_InverseStepped=3]="CubismMotionSegmentType_InverseStepped",t))(Ne||{});class Ue{constructor(){this.time=0,this.value=0}}class ze{constructor(){this.evaluate=null,this.basePointIndex=0,this.segmentType=0}}class je{constructor(){this.type=0,this.segmentCount=0,this.baseSegmentIndex=0,this.fadeInTime=0,this.fadeOutTime=0}}class Ge{constructor(){this.fireTime=0}}class Xe{constructor(){this.duration=0,this.loop=!1,this.curveCount=0,this.eventCount=0,this.fps=0,this.curves=new g,this.segments=new g,this.points=new g,this.events=new g}}(t=>{t.CubismMotionCurve=je,t.CubismMotionCurveTarget=ke,t.CubismMotionData=Xe,t.CubismMotionEvent=Ge,t.CubismMotionPoint=Ue,t.CubismMotionSegment=ze,t.CubismMotionSegmentType=Ne})(Oe||(Oe={}));const He="Meta",qe="Curves",We="FadeInTime",Ye="FadeOutTime",Je="Segments",$e="UserData";class Ze{constructor(t,e){this._json=Y.create(t,e)}release(){Y.delete(this._json)}getMotionDuration(){return this._json.getRoot().getValueByString(He).getValueByString("Duration").toFloat()}isMotionLoop(){return this._json.getRoot().getValueByString(He).getValueByString("Loop").toBoolean()}hasConsistency(){let t=!0;if(!this._json||!this._json.getRoot())return!1;const e=this._json.getRoot().getValueByString(qe).getVector().getSize();let i=0,s=0;for(let r=0;r<e;++r)for(let t=0;t<this.getMotionCurveSegmentCount(r);){0==t&&(s+=1,t+=2);switch(this.getMotionCurveSegment(r,t)){case Ne.CubismMotionSegmentType_Linear:s+=1,t+=3;break;case Ne.CubismMotionSegmentType_Bezier:s+=3,t+=7;break;case Ne.CubismMotionSegmentType_Stepped:case Ne.CubismMotionSegmentType_InverseStepped:s+=1,t+=3;break;default:L(0)}++i}return e!=this.getMotionCurveCount()&&(D("The number of curves does not match the metadata."),t=!1),i!=this.getMotionTotalSegmentCount()&&(D("The number of segment does not match the metadata."),t=!1),s!=this.getMotionTotalPointCount()&&(D("The number of point does not match the metadata."),t=!1),t}getEvaluationOptionFlag(t){return 0==t&&this._json.getRoot().getValueByString(He).getValueByString("AreBeziersRestricted").toBoolean()}getMotionCurveCount(){return this._json.getRoot().getValueByString(He).getValueByString("CurveCount").toInt()}getMotionFps(){return this._json.getRoot().getValueByString(He).getValueByString("Fps").toFloat()}getMotionTotalSegmentCount(){return this._json.getRoot().getValueByString(He).getValueByString("TotalSegmentCount").toInt()}getMotionTotalPointCount(){return this._json.getRoot().getValueByString(He).getValueByString("TotalPointCount").toInt()}isExistMotionFadeInTime(){return!this._json.getRoot().getValueByString(He).getValueByString(We).isNull()}isExistMotionFadeOutTime(){return!this._json.getRoot().getValueByString(He).getValueByString(Ye).isNull()}getMotionFadeInTime(){return this._json.getRoot().getValueByString(He).getValueByString(We).toFloat()}getMotionFadeOutTime(){return this._json.getRoot().getValueByString(He).getValueByString(Ye).toFloat()}getMotionCurveTarget(t){return this._json.getRoot().getValueByString(qe).getValueByIndex(t).getValueByString("Target").getRawString()}getMotionCurveId(t){return ht.getIdManager().getId(this._json.getRoot().getValueByString(qe).getValueByIndex(t).getValueByString("Id").getRawString())}isExistMotionCurveFadeInTime(t){return!this._json.getRoot().getValueByString(qe).getValueByIndex(t).getValueByString(We).isNull()}isExistMotionCurveFadeOutTime(t){return!this._json.getRoot().getValueByString(qe).getValueByIndex(t).getValueByString(Ye).isNull()}getMotionCurveFadeInTime(t){return this._json.getRoot().getValueByString(qe).getValueByIndex(t).getValueByString(We).toFloat()}getMotionCurveFadeOutTime(t){return this._json.getRoot().getValueByString(qe).getValueByIndex(t).getValueByString(Ye).toFloat()}getMotionCurveSegmentCount(t){return this._json.getRoot().getValueByString(qe).getValueByIndex(t).getValueByString(Je).getVector().getSize()}getMotionCurveSegment(t,e){return this._json.getRoot().getValueByString(qe).getValueByIndex(t).getValueByString(Je).getValueByIndex(e).toFloat()}getEventCount(){return this._json.getRoot().getValueByString(He).getValueByString("UserDataCount").toInt()}getTotalEventValueSize(){return this._json.getRoot().getValueByString(He).getValueByString("TotalUserDataSize").toInt()}getEventTime(t){return this._json.getRoot().getValueByString($e).getValueByIndex(t).getValueByString("Time").toFloat()}getEventValue(t){return new S(this._json.getRoot().getValueByString($e).getValueByIndex(t).getValueByString("Value").getRawString())}}var Ke,Qe=(t=>(t[t.EvaluationOptionFlag_AreBeziersRistricted=0]="EvaluationOptionFlag_AreBeziersRistricted",t))(Qe||{});(t=>{t.CubismMotionJson=Ze})(Ke||(Ke={}));const ti="Opacity";function ei(t,e,i){const s=new Ue;return s.time=t.time+(e.time-t.time)*i,s.value=t.value+(e.value-t.value)*i,s}function ii(t,e){let i=(e-t[0].time)/(t[1].time-t[0].time);return i<0&&(i=0),t[0].value+(t[1].value-t[0].value)*i}function si(t,e){let i=(e-t[0].time)/(t[3].time-t[0].time);i<0&&(i=0);const s=ei(t[0],t[1],i),r=ei(t[1],t[2],i),a=ei(t[2],t[3],i),n=ei(s,r,i),o=ei(r,a,i);return ei(n,o,i).value}function ri(t,e){const i=e,s=t[0].time,r=t[3].time,a=t[1].time,n=t[2].time,o=r-3*n+3*a-s,l=3*n-6*a+3*s,u=3*a-3*s,h=s-i,d=Ce.cardanoAlgorithmForBezier(o,l,u,h),g=ei(t[0],t[1],d),c=ei(t[1],t[2],d),m=ei(t[2],t[3],d),p=ei(g,c,d),_=ei(c,m,d);return ei(p,_,d).value}function ai(t,e){return t[0].value}function ni(t,e){return t[1].value}function oi(t,e,i,s,r){const a=t.curves.at(e);let n=-1;const o=a.baseSegmentIndex+a.segmentCount;let l=0;for(let h=a.baseSegmentIndex;h<o;++h)if(l=t.segments.at(h).basePointIndex+(t.segments.at(h).segmentType==Ne.CubismMotionSegmentType_Bezier?3:1),t.points.at(l).time>i){n=h;break}if(-1==n)return s&&i<r?function(t,e,i,s,r,a){const n=[new Ue,new Ue];{const e=t.points.at(s);n[0].time=e.time,n[0].value=e.value}{const e=t.points.at(i);n[1].time=a,n[1].value=e.value}switch(t.segments.at(e).segmentType){case Ne.CubismMotionSegmentType_Linear:case Ne.CubismMotionSegmentType_Bezier:default:return ii(n,r);case Ne.CubismMotionSegmentType_Stepped:return ai(n);case Ne.CubismMotionSegmentType_InverseStepped:return ni(n)}}(t,o-1,t.segments.at(a.baseSegmentIndex).basePointIndex,l,i,r):t.points.at(l).value;const u=t.segments.at(n);return u.evaluate(t.points.get(u.basePointIndex),i)}class li extends ve{constructor(){super(),this._motionBehavior=1,this._sourceFrameRate=30,this._loopDurationSeconds=-1,this._isLoop=!1,this._isLoopFadeIn=!0,this._lastWeight=0,this._motionData=null,this._modelCurveIdEyeBlink=null,this._modelCurveIdLipSync=null,this._modelCurveIdOpacity=null,this._eyeBlinkParameterIds=null,this._lipSyncParameterIds=null,this._modelOpacity=1,this._debugMode=!1}static create(t,e,i,s,r=!1){const a=new li;return a.parse(t,e,r),a._motionData?(a._sourceFrameRate=a._motionData.fps,a._loopDurationSeconds=a._motionData.duration,a._onFinishedMotion=i,a._onBeganMotion=s,a):(ut(a),null)}doUpdateParameters(t,e,i,s){null==this._modelCurveIdEyeBlink&&(this._modelCurveIdEyeBlink=ht.getIdManager().getId("EyeBlink")),null==this._modelCurveIdLipSync&&(this._modelCurveIdLipSync=ht.getIdManager().getId("LipSync")),null==this._modelCurveIdOpacity&&(this._modelCurveIdOpacity=ht.getIdManager().getId(ti)),1===this._motionBehavior&&this._previousLoopState!==this._isLoop&&(this.adjustEndTime(s),this._previousLoopState=this._isLoop);let r=e-s.getStartTime();r<0&&(r=0);let a=Number.MAX_VALUE,n=Number.MAX_VALUE;const o=64;let l=0,u=0;this._eyeBlinkParameterIds.getSize()>o&&T("too many eye blink targets : {0}",this._eyeBlinkParameterIds.getSize()),this._lipSyncParameterIds.getSize()>o&&T("too many lip sync targets : {0}",this._lipSyncParameterIds.getSize());const h=this._fadeInSeconds<=0?1:Ce.getEasingSine((e-s.getFadeInStartTime())/this._fadeInSeconds),d=this._fadeOutSeconds<=0||s.getEndTime()<0?1:Ce.getEasingSine((s.getEndTime()-e)/this._fadeOutSeconds);let g,c,m,p=r,_=this._motionData.duration;const f=1===this._motionBehavior&&this._isLoop;if(this._isLoop)for(1===this._motionBehavior&&(_+=1/this._motionData.fps);p>_;)p-=_;const y=this._motionData.curves;for(c=0;c<this._motionData.curveCount&&y.at(c).type==ke.CubismMotionCurveTarget_Model;++c)g=oi(this._motionData,c,p,f,_),y.at(c).id==this._modelCurveIdEyeBlink?n=g:y.at(c).id==this._modelCurveIdLipSync?a=g:y.at(c).id==this._modelCurveIdOpacity&&(this._modelOpacity=g,t.setModelOapcity(this.getModelOpacityValue()));for(;c<this._motionData.curveCount&&y.at(c).type==ke.CubismMotionCurveTarget_Parameter;++c){if(m=t.getParameterIndex(y.at(c).id),-1==m)continue;const r=t.getParameterValueByIndex(m);if(g=oi(this._motionData,c,p,f,_),n!=Number.MAX_VALUE)for(let t=0;t<this._eyeBlinkParameterIds.getSize()&&t<o;++t)if(this._eyeBlinkParameterIds.at(t)==y.at(c).id){g*=n,u|=1<<t;break}if(a!=Number.MAX_VALUE)for(let t=0;t<this._lipSyncParameterIds.getSize()&&t<o;++t)if(this._lipSyncParameterIds.at(t)==y.at(c).id){g+=a,l|=1<<t;break}let x;if(t.isRepeat(m)&&(g=t.getParameterRepeatValue(m,g)),y.at(c).fadeInTime<0&&y.at(c).fadeOutTime<0)x=r+(g-r)*i;else{let t,i;t=y.at(c).fadeInTime<0?h:0==y.at(c).fadeInTime?1:Ce.getEasingSine((e-s.getFadeInStartTime())/y.at(c).fadeInTime),i=y.at(c).fadeOutTime<0?d:0==y.at(c).fadeOutTime||s.getEndTime()<0?1:Ce.getEasingSine((s.getEndTime()-e)/y.at(c).fadeOutTime);x=r+(g-r)*(this._weight*t*i)}t.setParameterValueByIndex(m,x,1)}if(n!=Number.MAX_VALUE)for(let x=0;x<this._eyeBlinkParameterIds.getSize()&&x<o;++x){const e=t.getParameterValueById(this._eyeBlinkParameterIds.at(x));if(u>>x&1)continue;const s=e+(n-e)*i;t.setParameterValueById(this._eyeBlinkParameterIds.at(x),s)}if(a!=Number.MAX_VALUE)for(let x=0;x<this._lipSyncParameterIds.getSize()&&x<o;++x){const e=t.getParameterValueById(this._lipSyncParameterIds.at(x));if(l>>x&1)continue;const s=e+(a-e)*i;t.setParameterValueById(this._lipSyncParameterIds.at(x),s)}for(;c<this._motionData.curveCount&&y.at(c).type==ke.CubismMotionCurveTarget_PartOpacity;++c)m=t.getParameterIndex(y.at(c).id),-1!=m&&(g=oi(this._motionData,c,p,f,_),t.setParameterValueByIndex(m,g));r>=_&&(this._isLoop?this.updateForNextLoop(s,e,p):(this._onFinishedMotion&&this._onFinishedMotion(this),s.setIsFinished(!0))),this._lastWeight=i}setIsLoop(t){D("setIsLoop() is a deprecated function. Please use setLoop()."),this._isLoop=t}isLoop(){return D("isLoop() is a deprecated function. Please use getLoop()."),this._isLoop}setIsLoopFadeIn(t){D("setIsLoopFadeIn() is a deprecated function. Please use setLoopFadeIn()."),this._isLoopFadeIn=t}isLoopFadeIn(){return D("isLoopFadeIn() is a deprecated function. Please use getLoopFadeIn()."),this._isLoopFadeIn}setMotionBehavior(t){this._motionBehavior=t}getMotionBehavior(){return this._motionBehavior}getDuration(){return this._isLoop?-1:this._loopDurationSeconds}getLoopDuration(){return this._loopDurationSeconds}setParameterFadeInTime(t,e){const i=this._motionData.curves;for(let s=0;s<this._motionData.curveCount;++s)if(t==i.at(s).id)return void(i.at(s).fadeInTime=e)}setParameterFadeOutTime(t,e){const i=this._motionData.curves;for(let s=0;s<this._motionData.curveCount;++s)if(t==i.at(s).id)return void(i.at(s).fadeOutTime=e)}getParameterFadeInTime(t){const e=this._motionData.curves;for(let i=0;i<this._motionData.curveCount;++i)if(t==e.at(i).id)return e.at(i).fadeInTime;return-1}getParameterFadeOutTime(t){const e=this._motionData.curves;for(let i=0;i<this._motionData.curveCount;++i)if(t==e.at(i).id)return e.at(i).fadeOutTime;return-1}setEffectIds(t,e){this._eyeBlinkParameterIds=t,this._lipSyncParameterIds=e}release(){this._motionData=void 0,this._motionData=null}updateForNextLoop(t,e,i){switch(this._motionBehavior){case 1:default:t.setStartTime(e-i),this._isLoopFadeIn&&t.setFadeInStartTime(e-i),null!=this._onFinishedMotion&&this._onFinishedMotion(this);break;case 0:t.setStartTime(e),this._isLoopFadeIn&&t.setFadeInStartTime(e)}}parse(t,e,i=!1){let s=new Ze(t,e);if(!s)return s.release(),void(s=void 0);if(i){if(!s.hasConsistency())return s.release(),void O("Inconsistent motion3.json.")}this._motionData=new Xe,this._motionData.duration=s.getMotionDuration(),this._motionData.loop=s.isMotionLoop(),this._motionData.curveCount=s.getMotionCurveCount(),this._motionData.fps=s.getMotionFps(),this._motionData.eventCount=s.getEventCount();const r=s.getEvaluationOptionFlag(Qe.EvaluationOptionFlag_AreBeziersRistricted);s.isExistMotionFadeInTime()?this._fadeInSeconds=s.getMotionFadeInTime()<0?1:s.getMotionFadeInTime():this._fadeInSeconds=1,s.isExistMotionFadeOutTime()?this._fadeOutSeconds=s.getMotionFadeOutTime()<0?1:s.getMotionFadeOutTime():this._fadeOutSeconds=1,this._motionData.curves.updateSize(this._motionData.curveCount,je,!0),this._motionData.segments.updateSize(s.getMotionTotalSegmentCount(),ze,!0),this._motionData.points.updateSize(s.getMotionTotalPointCount(),Ue,!0),this._motionData.events.updateSize(this._motionData.eventCount,Ge,!0);let a=0,n=0;for(let o=0;o<this._motionData.curveCount;++o){"Model"==s.getMotionCurveTarget(o)?this._motionData.curves.at(o).type=ke.CubismMotionCurveTarget_Model:"Parameter"==s.getMotionCurveTarget(o)?this._motionData.curves.at(o).type=ke.CubismMotionCurveTarget_Parameter:"PartOpacity"==s.getMotionCurveTarget(o)?this._motionData.curves.at(o).type=ke.CubismMotionCurveTarget_PartOpacity:D('Warning : Unable to get segment type from Curve! The number of "CurveCount" may be incorrect!'),this._motionData.curves.at(o).id=s.getMotionCurveId(o),this._motionData.curves.at(o).baseSegmentIndex=n,this._motionData.curves.at(o).fadeInTime=s.isExistMotionCurveFadeInTime(o)?s.getMotionCurveFadeInTime(o):-1,this._motionData.curves.at(o).fadeOutTime=s.isExistMotionCurveFadeOutTime(o)?s.getMotionCurveFadeOutTime(o):-1;for(let t=0;t<s.getMotionCurveSegmentCount(o);){0==t?(this._motionData.segments.at(n).basePointIndex=a,this._motionData.points.at(a).time=s.getMotionCurveSegment(o,t),this._motionData.points.at(a).value=s.getMotionCurveSegment(o,t+1),a+=1,t+=2):this._motionData.segments.at(n).basePointIndex=a-1;switch(s.getMotionCurveSegment(o,t)){case Ne.CubismMotionSegmentType_Linear:this._motionData.segments.at(n).segmentType=Ne.CubismMotionSegmentType_Linear,this._motionData.segments.at(n).evaluate=ii,this._motionData.points.at(a).time=s.getMotionCurveSegment(o,t+1),this._motionData.points.at(a).value=s.getMotionCurveSegment(o,t+2),a+=1,t+=3;break;case Ne.CubismMotionSegmentType_Bezier:this._motionData.segments.at(n).segmentType=Ne.CubismMotionSegmentType_Bezier,this._motionData.segments.at(n).evaluate=r?si:ri,this._motionData.points.at(a).time=s.getMotionCurveSegment(o,t+1),this._motionData.points.at(a).value=s.getMotionCurveSegment(o,t+2),this._motionData.points.at(a+1).time=s.getMotionCurveSegment(o,t+3),this._motionData.points.at(a+1).value=s.getMotionCurveSegment(o,t+4),this._motionData.points.at(a+2).time=s.getMotionCurveSegment(o,t+5),this._motionData.points.at(a+2).value=s.getMotionCurveSegment(o,t+6),a+=3,t+=7;break;case Ne.CubismMotionSegmentType_Stepped:this._motionData.segments.at(n).segmentType=Ne.CubismMotionSegmentType_Stepped,this._motionData.segments.at(n).evaluate=ai,this._motionData.points.at(a).time=s.getMotionCurveSegment(o,t+1),this._motionData.points.at(a).value=s.getMotionCurveSegment(o,t+2),a+=1,t+=3;break;case Ne.CubismMotionSegmentType_InverseStepped:this._motionData.segments.at(n).segmentType=Ne.CubismMotionSegmentType_InverseStepped,this._motionData.segments.at(n).evaluate=ni,this._motionData.points.at(a).time=s.getMotionCurveSegment(o,t+1),this._motionData.points.at(a).value=s.getMotionCurveSegment(o,t+2),a+=1,t+=3;break;default:L(0)}++this._motionData.curves.at(o).segmentCount,++n}}for(let o=0;o<s.getEventCount();++o)this._motionData.events.at(o).fireTime=s.getEventTime(o),this._motionData.events.at(o).value=s.getEventValue(o);s.release(),s=void 0,s=null}getFiredEvent(t,e){this._firedEventValues.updateSize(0);for(let i=0;i<this._motionData.eventCount;++i)this._motionData.events.at(i).fireTime>t&&this._motionData.events.at(i).fireTime<=e&&this._firedEventValues.pushBack(new S(this._motionData.events.at(i).value.s));return this._firedEventValues}isExistModelOpacity(){for(let t=0;t<this._motionData.curveCount;t++){const e=this._motionData.curves.at(t);if(e.type==ke.CubismMotionCurveTarget_Model&&0==e.id.getString().s.localeCompare(ti))return!0}return!1}getModelOpacityIndex(){if(this.isExistModelOpacity())for(let t=0;t<this._motionData.curveCount;t++){const e=this._motionData.curves.at(t);if(e.type==ke.CubismMotionCurveTarget_Model&&0==e.id.getString().s.localeCompare(ti))return t}return-1}getModelOpacityId(t){if(-1!=t){const e=this._motionData.curves.at(t);if(e.type==ke.CubismMotionCurveTarget_Model&&0==e.id.getString().s.localeCompare(ti))return ht.getIdManager().getId(e.id.getString().s)}return null}getModelOpacityValue(){return this._modelOpacity}setDebugMode(t){this._debugMode=t}}var ui;function hi(t,e,i){const s=t.startMotion(i,!1),r=t.getCubismMotionQueueEntry(s);if(!r)return!1;r.setStartTime(0),r.setFadeInStartTime(0);const a=i.getDuration(),n=r.getStartTime()+a;return i.doUpdateParameters(e.coreModel,n,1,r),r.setIsFinished(!0),!0}(t=>{t.CubismMotion=li})(ui||(ui={}));class di extends Tt{constructor(t){var e;super(t),u(this,"definitions"),u(this,"groups",{idle:"Idle"}),u(this,"motionDataType","arraybuffer"),u(this,"queueManager",new Le),u(this,"expressionManager"),u(this,"eyeBlinkIds"),u(this,"lipSyncIds",["ParamMouthOpenY"]),this.definitions=null!=(e=t.settings.motions)?e:{},this.eyeBlinkIds=t.settings.getEyeBlinkParameters()||[];const i=t.settings.getLipSyncParameters();(null==i?void 0:i.length)&&(this.lipSyncIds=i),this.init(t.options)}init(t){super.init(t),this.settings.expressions&&(this.expressionManager=new De(this.settings,t)),this.queueManager.setEventCallback((t,e)=>{const i="string"==typeof e?e:"number"==typeof e?String(e):e&&"object"==typeof e?e.s:"undefined";this.emit("motion:"+i)})}isFinished(){return this.queueManager.isFinished()}_startMotion(t,e,i){if(t.setFinishedMotionHandler(e),i&&i.length>0){const e=t._motionData.curves,s=function(t){if(gi(t))return new g;return[]}(e),r=ci(e);for(let t=0;t<r;t++){const r=mi(e,t);if(!r)continue;const a=pi(r);a&&i.includes(a)||_i(s,r)}t._motionData.curves=s,t._motionData.curveCount=ci(s)}return this.queueManager.stopAllMotions(),this.queueManager.startMotion(t,!1)}_stopAllMotions(){this.queueManager.stopAllMotions()}createMotion(t,e,i){const s=!!this.parent.options.checkMotionConsistency,r=li.create(t,t.byteLength,void 0,void 0,s),a=new Ze(t,t.byteLength),n=(e===this.groups.idle?gt.idleMotionFadingDuration:gt.motionFadingDuration)/1e3;return void 0===a.getMotionFadeInTime()&&r.setFadeInTime(i.FadeInTime>0?i.FadeInTime:n),void 0===a.getMotionFadeOutTime()&&r.setFadeOutTime(i.FadeOutTime>0?i.FadeOutTime:n),r.setEffectIds(this.createIdVector(this.eyeBlinkIds),this.createIdVector(this.lipSyncIds)),r}getMotionFile(t){return t.File}getMotionName(t){return t.File}getSoundFile(t){return t.Sound}updateParameters(t,e){return this.queueManager.doUpdateMotion(t,e)}destroy(){super.destroy(),this.queueManager.release(),this.queueManager=void 0}motionLastFrame(t,e){return h(this,arguments,function*(t,e,{expression:i}={}){const s=yield this.getMotionAndApplyExpression(t,e,i);return!!s&&(this.playing=!0,hi(this.queueManager,this.parent,s),this.playing=!1,!0)})}createIdVector(t){const e=new g,i=ht.getIdManager();for(const s of t)e.pushBack(i.getId(s));return e}}function gi(t){return"function"==typeof t.pushBack}function ci(t){return gi(t)?t.getSize():t.length}function mi(t,e){return gi(t)?t.at(e):t[e]}function pi(t){if(!t||"object"!=typeof t)return;const e=t.id;return"string"==typeof e?e:e&&"function"==typeof e.getString?e.getString().s:void 0}function _i(t,e){gi(t)?t.pushBack(e):t.push(e)}class fi extends e.EventEmitter{constructor(t){super(),u(this,"tag"),u(this,"manager"),u(this,"settings"),u(this,"state",new It),u(this,"playing",!1),u(this,"destroyed",!1),u(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 h(this,arguments,function*(t,e,i=Ft.NORMAL,s=[]){var r;if(!this.state.reserve(t,e,i))return!1;const a=null==(r=this.manager.definitions[t])?void 0:r[e];if(!a)return!1;const n=yield this.manager.loadMotion(t,e);return!!this.state.start(n,t,e,i)&&(ct.log(this.tag,"Start motion:",this.getMotionName(a)),this.emit("motionStart",t,e,void 0),this.playing=!0,this._startMotion(n,void 0,s),!0)})}startRandomMotion(t,e){return h(this,null,function*(){var i;const s=this.manager.definitions[t];if(null==s?void 0:s.length){const r=[],a=null!=(i=this.manager.motionGroups[t])?i:[];for(let e=0;e<s.length;e++)null===a[e]||this.state.isActive(t,e)||r.push(e);if(r.length){const i=r[Math.floor(Math.random()*r.length)];return this.startMotion(t,i,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 yi extends fi{constructor(t){super(t),u(this,"queueManager",new Le),this.init()}init(){this.queueManager.setEventCallback((t,e)=>{const i="string"==typeof e?e:"number"==typeof e?String(e):e&&"object"==typeof e?e.s:"undefined";this.emit("motion:"+i)})}isFinished(){return this.queueManager.isFinished()}_startMotion(t,e,i){if(t.setFinishedMotionHandler(e),i&&i.length>0){const e=t._motionData.curves,s=function(t){if(xi(t))return new g;return[]}(e),r=Ci(e);for(let t=0;t<r;t++){const r=Si(e,t);if(!r)continue;const a=Mi(r);a&&i.includes(a)||vi(s,r)}t._motionData.curves=s,t._motionData.curveCount=Ci(s)}return this.queueManager.stopAllMotions(),this.queueManager.startMotion(t,!1)}_stopAllMotions(){this.queueManager.stopAllMotions()}updateParameters(t,e){return this.queueManager.doUpdateMotion(t,e)}getMotionName(t){return t.File}destroy(){super.destroy(),this.queueManager.release(),this.queueManager=void 0}playMotionLastFrame(t,e){return h(this,null,function*(){var i;if(!this.state.reserve(t,e,Ft.FORCE))return!1;const s=null==(i=this.manager.definitions[t])?void 0:i[e];if(!s)return!1;const r=yield this.manager.loadMotion(t,e);return!!this.state.start(r,t,e,Ft.FORCE)&&(ct.log(this.tag,"Start motion:",this.getMotionName(s)),this.emit("motionStart",t,e,void 0),this.playing=!0,this.queueManager.stopAllMotions(),hi(this.queueManager,this.parent,r)?(this.playing=!1,!0):(this.playing=!1,!1))})}}function xi(t){return"function"==typeof t.pushBack}function Ci(t){return xi(t)?t.getSize():t.length}function Si(t,e){return xi(t)?t.at(e):t[e]}function Mi(t){if(!t||"object"!=typeof t)return;const e=t.id;return"string"==typeof e?e:e&&"function"==typeof e.getString?e.getString().s:void 0}function vi(t,e){xi(t)?t.pushBack(e):t.push(e)}const bi=Object.freeze({HitAreaPrefix:"HitArea",HitAreaHead:"Head",HitAreaBody:"Body",PartsIdCore:"Parts01Core",PartsArmPrefix:"Parts01Arm_",PartsArmLPrefix:"Parts01ArmL_",PartsArmRPrefix:"Parts01ArmR_",ParamAngleX:"ParamAngleX",ParamAngleY:"ParamAngleY",ParamAngleZ:"ParamAngleZ",ParamEyeLOpen:"ParamEyeLOpen",ParamEyeLSmile:"ParamEyeLSmile",ParamEyeROpen:"ParamEyeROpen",ParamEyeRSmile:"ParamEyeRSmile",ParamEyeBallX:"ParamEyeBallX",ParamEyeBallY:"ParamEyeBallY",ParamEyeBallForm:"ParamEyeBallForm",ParamBrowLY:"ParamBrowLY",ParamBrowRY:"ParamBrowRY",ParamBrowLX:"ParamBrowLX",ParamBrowRX:"ParamBrowRX",ParamBrowLAngle:"ParamBrowLAngle",ParamBrowRAngle:"ParamBrowRAngle",ParamBrowLForm:"ParamBrowLForm",ParamBrowRForm:"ParamBrowRForm",ParamMouthForm:"ParamMouthForm",ParamMouthOpenY:"ParamMouthOpenY",ParamCheek:"ParamCheek",ParamBodyAngleX:"ParamBodyAngleX",ParamBodyAngleY:"ParamBodyAngleY",ParamBodyAngleZ:"ParamBodyAngleZ",ParamBreath:"ParamBreath",ParamArmLA:"ParamArmLA",ParamArmRA:"ParamArmRA",ParamArmLB:"ParamArmLB",ParamArmRB:"ParamArmRB",ParamHandL:"ParamHandL",ParamHandR:"ParamHandR",ParamHairFront:"ParamHairFront",ParamHairSide:"ParamHairSide",ParamHairBack:"ParamHairBack",ParamHairFluffy:"ParamHairFluffy",ParamShoulderY:"ParamShoulderY",ParamBustX:"ParamBustX",ParamBustY:"ParamBustY",ParamBaseX:"ParamBaseX",ParamBaseY:"ParamBaseY",ParamNONE:"NONE:"});var Pi,Bi;(t=>{t.HitAreaBody=bi.HitAreaBody,t.HitAreaHead=bi.HitAreaHead,t.HitAreaPrefix=bi.HitAreaPrefix,t.ParamAngleX=bi.ParamAngleX,t.ParamAngleY=bi.ParamAngleY,t.ParamAngleZ=bi.ParamAngleZ,t.ParamArmLA=bi.ParamArmLA,t.ParamArmLB=bi.ParamArmLB,t.ParamArmRA=bi.ParamArmRA,t.ParamArmRB=bi.ParamArmRB,t.ParamBaseX=bi.ParamBaseX,t.ParamBaseY=bi.ParamBaseY,t.ParamBodyAngleX=bi.ParamBodyAngleX,t.ParamBodyAngleY=bi.ParamBodyAngleY,t.ParamBodyAngleZ=bi.ParamBodyAngleZ,t.ParamBreath=bi.ParamBreath,t.ParamBrowLAngle=bi.ParamBrowLAngle,t.ParamBrowLForm=bi.ParamBrowLForm,t.ParamBrowLX=bi.ParamBrowLX,t.ParamBrowLY=bi.ParamBrowLY,t.ParamBrowRAngle=bi.ParamBrowRAngle,t.ParamBrowRForm=bi.ParamBrowRForm,t.ParamBrowRX=bi.ParamBrowRX,t.ParamBrowRY=bi.ParamBrowRY,t.ParamBustX=bi.ParamBustX,t.ParamBustY=bi.ParamBustY,t.ParamCheek=bi.ParamCheek,t.ParamEyeBallForm=bi.ParamEyeBallForm,t.ParamEyeBallX=bi.ParamEyeBallX,t.ParamEyeBallY=bi.ParamEyeBallY,t.ParamEyeLOpen=bi.ParamEyeLOpen,t.ParamEyeLSmile=bi.ParamEyeLSmile,t.ParamEyeROpen=bi.ParamEyeROpen,t.ParamEyeRSmile=bi.ParamEyeRSmile,t.ParamHairBack=bi.ParamHairBack,t.ParamHairFluffy=bi.ParamHairFluffy,t.ParamHairFront=bi.ParamHairFront,t.ParamHairSide=bi.ParamHairSide,t.ParamHandL=bi.ParamHandL,t.ParamHandR=bi.ParamHandR,t.ParamMouthForm=bi.ParamMouthForm,t.ParamMouthOpenY=bi.ParamMouthOpenY,t.ParamNONE=bi.ParamNONE,t.ParamShoulderY=bi.ParamShoulderY,t.PartsArmLPrefix=bi.PartsArmLPrefix,t.PartsArmPrefix=bi.PartsArmPrefix,t.PartsArmRPrefix=bi.PartsArmRPrefix,t.PartsIdCore=bi.PartsIdCore})(Pi||(Pi={}));class wi{static create(){return new wi}static delete(t){}setParameters(t){this._breathParameters=t}getParameters(){return this._breathParameters}updateParameters(t,e){this._currentTime+=e;const i=2*this._currentTime*Math.PI;for(let s=0;s<this._breathParameters.getSize();++s){const e=this._breathParameters.at(s);t.addParameterValueById(e.parameterId,e.offset+e.peak*Math.sin(i/e.cycle),e.weight)}}constructor(){this._currentTime=0}}class Fi{constructor(t,e,i,s,r){this.parameterId=null==t?null:t,this.offset=null==e?0:e,this.peak=null==i?0:i,this.cycle=null==s?0:s,this.weight=null==r?0:r}}(t=>{t.BreathParameterData=Fi,t.CubismBreath=wi})(Bi||(Bi={}));const Ii=class t{static create(e=null){return new t(e)}static delete(t){}setBlinkingInterval(t){this._blinkingIntervalSeconds=t}setBlinkingSetting(t,e,i){this._closingSeconds=t,this._closedSeconds=e,this._openingSeconds=i}setParameterIds(t){this._parameterIds=t}getParameterIds(){return this._parameterIds}updateParameters(e,i){let s;this._userTimeSeconds+=i;let r=0;switch(this._blinkingState){case 2:r=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._closingSeconds,r>=1&&(r=1,this._blinkingState=3,this._stateStartTimeSeconds=this._userTimeSeconds),s=1-r;break;case 3:r=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._closedSeconds,r>=1&&(this._blinkingState=4,this._stateStartTimeSeconds=this._userTimeSeconds),s=0;break;case 4:r=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._openingSeconds,r>=1&&(r=1,this._blinkingState=1,this._nextBlinkingTime=this.determinNextBlinkingTiming()),s=r;break;case 1:this._nextBlinkingTime<this._userTimeSeconds&&(this._blinkingState=2,this._stateStartTimeSeconds=this._userTimeSeconds),s=1;break;default:this._blinkingState=1,this._nextBlinkingTime=this.determinNextBlinkingTiming(),s=1}t.CloseIfZero||(s=-s);for(let t=0;t<this._parameterIds.getSize();++t)e.setParameterValueById(this._parameterIds.at(t),s)}constructor(t){if(this._blinkingState=0,this._nextBlinkingTime=0,this._stateStartTimeSeconds=0,this._blinkingIntervalSeconds=4,this._closingSeconds=.1,this._closedSeconds=.05,this._openingSeconds=.15,this._userTimeSeconds=0,this._parameterIds=new g,null!=t)for(let e=0;e<t.getEyeBlinkParameterCount();++e)this._parameterIds.pushBack(t.getEyeBlinkParameterId(e))}determinNextBlinkingTiming(){const t=Math.random();return this._userTimeSeconds+t*(2*this._blinkingIntervalSeconds-1)}};Ii.CloseIfZero=!0;let Ei=Ii;var Vi,Ri=(t=>(t[t.EyeState_First=0]="EyeState_First",t[t.EyeState_Interval=1]="EyeState_Interval",t[t.EyeState_Closing=2]="EyeState_Closing",t[t.EyeState_Closed=3]="EyeState_Closed",t[t.EyeState_Opening=4]="EyeState_Opening",t))(Ri||{});(t=>{t.CubismEyeBlink=Ei,t.EyeState=Ri})(Vi||(Vi={}));class Li{constructor(t){this._renderTextureCount=0,this._clippingMaskBufferSize=256,this._clippingContextListForMask=new g,this._clippingContextListForDraw=new g,this._channelColors=new g,this._tmpBoundsOnModel=new P,this._tmpMatrix=new b,this._tmpMatrixForMask=new b,this._tmpMatrixForDraw=new b,this._clippingContexttConstructor=t;let e=new I;e.r=1,e.g=0,e.b=0,e.a=0,this._channelColors.pushBack(e),e=new I,e.r=0,e.g=1,e.b=0,e.a=0,this._channelColors.pushBack(e),e=new I,e.r=0,e.g=0,e.b=1,e.a=0,this._channelColors.pushBack(e),e=new I,e.r=0,e.g=0,e.b=0,e.a=1,this._channelColors.pushBack(e)}release(){for(let t=0;t<this._clippingContextListForMask.getSize();t++)this._clippingContextListForMask.at(t)&&(this._clippingContextListForMask.at(t).release(),this._clippingContextListForMask.set(t,void 0)),this._clippingContextListForMask.set(t,null);this._clippingContextListForMask=null;for(let t=0;t<this._clippingContextListForDraw.getSize();t++)this._clippingContextListForDraw.set(t,null);this._clippingContextListForDraw=null;for(let t=0;t<this._channelColors.getSize();t++)this._channelColors.set(t,null);this._channelColors=null,null!=this._clearedFrameBufferFlags&&this._clearedFrameBufferFlags.clear(),this._clearedFrameBufferFlags=null}initialize(t,e){e%1!=0&&(D("The number of render textures must be specified as an integer. The decimal point is rounded down and corrected to an integer."),e=~~e),e<1&&D("The number of render textures must be an integer greater than or equal to 1. Set the number of render textures to 1."),this._renderTextureCount=e<1?1:e,this._clearedFrameBufferFlags=new g(this._renderTextureCount);for(let i=0;i<t.getDrawableCount();i++){if(t.getDrawableMaskCounts()[i]<=0){this._clippingContextListForDraw.pushBack(null);continue}let e=this.findSameClip(t.getDrawableMasks()[i],t.getDrawableMaskCounts()[i]);null==e&&(e=new this._clippingContexttConstructor(this,t.getDrawableMasks()[i],t.getDrawableMaskCounts()[i]),this._clippingContextListForMask.pushBack(e)),e.addClippedDrawable(i),this._clippingContextListForDraw.pushBack(e)}}findSameClip(t,e){for(let i=0;i<this._clippingContextListForMask.getSize();i++){const s=this._clippingContextListForMask.at(i),r=s._clippingIdCount;if(r!=e)continue;let a=0;for(let e=0;e<r;e++){const i=s._clippingIdList[e];for(let e=0;e<r;e++)if(t[e]==i){a++;break}}if(a==r)return s}return null}setupMatrixForHighPrecision(t,e){let i=0;for(let s=0;s<this._clippingContextListForMask.getSize();s++){const e=this._clippingContextListForMask.at(s);this.calcClippedDrawTotalBounds(t,e),e._isUsing&&i++}if(i>0){if(this.setupLayoutBounds(0),this._clearedFrameBufferFlags.getSize()!=this._renderTextureCount){this._clearedFrameBufferFlags.clear();for(let t=0;t<this._renderTextureCount;t++)this._clearedFrameBufferFlags.pushBack(!1)}else for(let t=0;t<this._renderTextureCount;t++)this._clearedFrameBufferFlags.set(t,!1);for(let i=0;i<this._clippingContextListForMask.getSize();i++){const s=this._clippingContextListForMask.at(i),r=s._allClippedDrawRect,a=s._layoutBounds,n=.05;let o=0,l=0;const u=t.getPixelsPerUnit(),h=s.getClippingManager().getClippingMaskBufferSize(),d=a.width*h,g=a.height*h;this._tmpBoundsOnModel.setRect(r),this._tmpBoundsOnModel.width*u>d?(this._tmpBoundsOnModel.expand(r.width*n,0),o=a.width/this._tmpBoundsOnModel.width):o=u/d,this._tmpBoundsOnModel.height*u>g?(this._tmpBoundsOnModel.expand(0,r.height*n),l=a.height/this._tmpBoundsOnModel.height):l=u/g,this.createMatrixForMask(e,a,o,l),s._matrixForMask.setMatrix(this._tmpMatrixForMask.getArray()),s._matrixForDraw.setMatrix(this._tmpMatrixForDraw.getArray())}}}createMatrixForMask(t,e,i,s){this._tmpMatrix.loadIdentity(),this._tmpMatrix.translateRelative(-1,-1),this._tmpMatrix.scaleRelative(2,2),this._tmpMatrix.translateRelative(e.x,e.y),this._tmpMatrix.scaleRelative(i,s),this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x,-this._tmpBoundsOnModel.y),this._tmpMatrixForMask.setMatrix(this._tmpMatrix.getArray()),this._tmpMatrix.loadIdentity(),this._tmpMatrix.translateRelative(e.x,e.y*(t?-1:1)),this._tmpMatrix.scaleRelative(i,s*(t?-1:1)),this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x,-this._tmpBoundsOnModel.y),this._tmpMatrixForDraw.setMatrix(this._tmpMatrix.getArray())}setupLayoutBounds(t){const e=this._renderTextureCount<=1?36:32*this._renderTextureCount;if(t<=0||t>e){t>e&&O("not supported mask count : {0}\n[Details] render texture count : {1}, mask count : {2}",t-e,this._renderTextureCount,t);for(let t=0;t<this._clippingContextListForMask.getSize();t++){const e=this._clippingContextListForMask.at(t);e._layoutChannelIndex=0,e._layoutBounds.x=0,e._layoutBounds.y=0,e._layoutBounds.width=1,e._layoutBounds.height=1,e._bufferIndex=0}return}const i=this._renderTextureCount<=1?9:8;let s=t/this._renderTextureCount;const r=t%this._renderTextureCount;s=Math.ceil(s);let a=s/4;const n=s%4;a=~~a;let o=0;for(let l=0;l<this._renderTextureCount;l++)for(let s=0;s<4;s++){let u=a+(s<n?1:0);if(s==n+(a<1?-1:0)&&r>0&&(u-=l<r?0:1),0==u);else if(1==u){const t=this._clippingContextListForMask.at(o++);t._layoutChannelIndex=s,t._layoutBounds.x=0,t._layoutBounds.y=0,t._layoutBounds.width=1,t._layoutBounds.height=1,t._bufferIndex=l}else if(2==u)for(let t=0;t<u;t++){let e=t%2;e=~~e;const i=this._clippingContextListForMask.at(o++);i._layoutChannelIndex=s,i._layoutBounds.x=.5*e,i._layoutBounds.y=0,i._layoutBounds.width=.5,i._layoutBounds.height=1,i._bufferIndex=l}else if(u<=4)for(let t=0;t<u;t++){let e=t%2,i=t/2;e=~~e,i=~~i;const r=this._clippingContextListForMask.at(o++);r._layoutChannelIndex=s,r._layoutBounds.x=.5*e,r._layoutBounds.y=.5*i,r._layoutBounds.width=.5,r._layoutBounds.height=.5,r._bufferIndex=l}else if(u<=i)for(let t=0;t<u;t++){let e=t%3,i=t/3;e=~~e,i=~~i;const r=this._clippingContextListForMask.at(o++);r._layoutChannelIndex=s,r._layoutBounds.x=e/3,r._layoutBounds.y=i/3,r._layoutBounds.width=1/3,r._layoutBounds.height=1/3,r._bufferIndex=l}else{O("not supported mask count : {0}\n[Details] render texture count : {1}, mask count : {2}",t-e,this._renderTextureCount,t);for(let t=0;t<u;t++){const t=this._clippingContextListForMask.at(o++);t._layoutChannelIndex=0,t._layoutBounds.x=0,t._layoutBounds.y=0,t._layoutBounds.width=1,t._layoutBounds.height=1,t._bufferIndex=0}}}}calcClippedDrawTotalBounds(t,e){let i=Number.MAX_VALUE,s=Number.MAX_VALUE,r=Number.MIN_VALUE,a=Number.MIN_VALUE;const n=e._clippedDrawableIndexList.length;for(let o=0;o<n;o++){const n=e._clippedDrawableIndexList[o],l=t.getDrawableVertexCount(n),u=t.getDrawableVertices(n);let h=Number.MAX_VALUE,d=Number.MAX_VALUE,g=-Number.MAX_VALUE,c=-Number.MAX_VALUE;const m=l*lt.vertexStep;for(let t=lt.vertexOffset;t<m;t+=lt.vertexStep){const e=u[t],i=u[t+1];e<h&&(h=e),e>g&&(g=e),i<d&&(d=i),i>c&&(c=i)}if(h!=Number.MAX_VALUE)if(h<i&&(i=h),d<s&&(s=d),g>r&&(r=g),c>a&&(a=c),i==Number.MAX_VALUE)e._allClippedDrawRect.x=0,e._allClippedDrawRect.y=0,e._allClippedDrawRect.width=0,e._allClippedDrawRect.height=0,e._isUsing=!1;else{e._isUsing=!0;const t=r-i,n=a-s;e._allClippedDrawRect.x=i,e._allClippedDrawRect.y=s,e._allClippedDrawRect.width=t,e._allClippedDrawRect.height=n}}}getClippingContextListForDraw(){return this._clippingContextListForDraw}getClippingMaskBufferSize(){return this._clippingMaskBufferSize}getRenderTextureCount(){return this._renderTextureCount}getChannelFlagAsColor(t){return this._channelColors.at(t)}setClippingMaskBufferSize(t){this._clippingMaskBufferSize=t}}let Ti;class Ai{constructor(){this._shaderSets=new g}release(){this.releaseShaderProgram()}setupShaderProgramForDraw(t,e,i){let s,r,a,n;t.isPremultipliedAlpha()||O("NoPremultipliedAlpha is not allowed"),0==this._shaderSets.getSize()&&this.generateShaders();const o=null!=t.getClippingContextBufferForDraw(),l=e.getDrawableInvertedMaskBit(i),u=o?l?2:1:0;let h;switch(e.getDrawableBlendMode(i)){case F.CubismBlendMode_Normal:default:h=this._shaderSets.at(1+u),s=this.gl.ONE,r=this.gl.ONE_MINUS_SRC_ALPHA,a=this.gl.ONE,n=this.gl.ONE_MINUS_SRC_ALPHA;break;case F.CubismBlendMode_Additive:h=this._shaderSets.at(4+u),s=this.gl.ONE,r=this.gl.ONE,a=this.gl.ZERO,n=this.gl.ONE;break;case F.CubismBlendMode_Multiplicative:h=this._shaderSets.at(7+u),s=this.gl.DST_COLOR,r=this.gl.ONE_MINUS_SRC_ALPHA,a=this.gl.ZERO,n=this.gl.ONE}this.gl.useProgram(h.shaderProgram),null==t._bufferData.vertex&&(t._bufferData.vertex=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,t._bufferData.vertex);const d=e.getDrawableVertices(i);this.gl.bufferData(this.gl.ARRAY_BUFFER,d,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(h.attributePositionLocation),this.gl.vertexAttribPointer(h.attributePositionLocation,2,this.gl.FLOAT,!1,0,0),null==t._bufferData.uv&&(t._bufferData.uv=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,t._bufferData.uv);const g=e.getDrawableVertexUvs(i);if(this.gl.bufferData(this.gl.ARRAY_BUFFER,g,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(h.attributeTexCoordLocation),this.gl.vertexAttribPointer(h.attributeTexCoordLocation,2,this.gl.FLOAT,!1,0,0),o){this.gl.activeTexture(this.gl.TEXTURE1);const e=t.getClippingContextBufferForDraw().getClippingManager().getColorBuffer().at(t.getClippingContextBufferForDraw()._bufferIndex);this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.uniform1i(h.samplerTexture1Location,1),this.gl.uniformMatrix4fv(h.uniformClipMatrixLocation,!1,t.getClippingContextBufferForDraw()._matrixForDraw.getArray());const i=t.getClippingContextBufferForDraw()._layoutChannelIndex,s=t.getClippingContextBufferForDraw().getClippingManager().getChannelFlagAsColor(i);this.gl.uniform4f(h.uniformChannelFlagLocation,s.r,s.g,s.b,s.a)}const c=e.getDrawableTextureIndex(i),m=t.getBindedTextures().getValue(c);this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,m),this.gl.uniform1i(h.samplerTexture0Location,0);const p=t.getMvpMatrix();this.gl.uniformMatrix4fv(h.uniformMatrixLocation,!1,p.getArray());const _=t.getModelColorWithOpacity(e.getDrawableOpacity(i)),f=e.getMultiplyColor(i),y=e.getScreenColor(i);this.gl.uniform4f(h.uniformBaseColorLocation,_.r,_.g,_.b,_.a),this.gl.uniform4f(h.uniformMultiplyColorLocation,f.r,f.g,f.b,f.a),this.gl.uniform4f(h.uniformScreenColorLocation,y.r,y.g,y.b,y.a),null==t._bufferData.index&&(t._bufferData.index=this.gl.createBuffer());const x=e.getDrawableVertexIndices(i);this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,t._bufferData.index),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,x,this.gl.DYNAMIC_DRAW),this.gl.blendFuncSeparate(s,r,a,n)}setupShaderProgramForMask(t,e,i){t.isPremultipliedAlpha()||O("NoPremultipliedAlpha is not allowed"),0==this._shaderSets.getSize()&&this.generateShaders();const s=this._shaderSets.at(0);this.gl.useProgram(s.shaderProgram),null==t._bufferData.vertex&&(t._bufferData.vertex=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,t._bufferData.vertex);const r=e.getDrawableVertices(i);this.gl.bufferData(this.gl.ARRAY_BUFFER,r,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(s.attributePositionLocation),this.gl.vertexAttribPointer(s.attributePositionLocation,2,this.gl.FLOAT,!1,0,0),null==t._bufferData.uv&&(t._bufferData.uv=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,t._bufferData.uv);const a=e.getDrawableTextureIndex(i),n=t.getBindedTextures().getValue(a);this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,n),this.gl.uniform1i(s.samplerTexture0Location,0),null==t._bufferData.uv&&(t._bufferData.uv=this.gl.createBuffer()),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,t._bufferData.uv);const o=e.getDrawableVertexUvs(i);this.gl.bufferData(this.gl.ARRAY_BUFFER,o,this.gl.DYNAMIC_DRAW),this.gl.enableVertexAttribArray(s.attributeTexCoordLocation),this.gl.vertexAttribPointer(s.attributeTexCoordLocation,2,this.gl.FLOAT,!1,0,0),t.getClippingContextBufferForMask();const l=t.getClippingContextBufferForMask()._layoutChannelIndex,u=t.getClippingContextBufferForMask().getClippingManager().getChannelFlagAsColor(l);this.gl.uniform4f(s.uniformChannelFlagLocation,u.r,u.g,u.b,u.a),this.gl.uniformMatrix4fv(s.uniformClipMatrixLocation,!1,t.getClippingContextBufferForMask()._matrixForMask.getArray());const h=t.getClippingContextBufferForMask()._layoutBounds;this.gl.uniform4f(s.uniformBaseColorLocation,2*h.x-1,2*h.y-1,2*h.getRight()-1,2*h.getBottom()-1);const d=e.getMultiplyColor(i),g=e.getScreenColor(i);this.gl.uniform4f(s.uniformMultiplyColorLocation,d.r,d.g,d.b,d.a),this.gl.uniform4f(s.uniformScreenColorLocation,g.r,g.g,g.b,g.a);const c=this.gl.ZERO,m=this.gl.ONE_MINUS_SRC_COLOR,p=this.gl.ZERO,_=this.gl.ONE_MINUS_SRC_ALPHA;null==t._bufferData.index&&(t._bufferData.index=this.gl.createBuffer());const f=e.getDrawableVertexIndices(i);this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,t._bufferData.index),this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,f,this.gl.DYNAMIC_DRAW),this.gl.blendFuncSeparate(c,m,p,_)}releaseShaderProgram(){for(let t=0;t<this._shaderSets.getSize();t++)this.gl.deleteProgram(this._shaderSets.at(t).shaderProgram),this._shaderSets.at(t).shaderProgram=0,this._shaderSets.set(t,void 0),this._shaderSets.set(t,null)}generateShaders(){for(let t=0;t<10;t++)this._shaderSets.pushBack(new Oi);this._shaderSets.at(0).shaderProgram=this.loadShaderProgram(Ni,Ui),this._shaderSets.at(1).shaderProgram=this.loadShaderProgram(zi,Gi),this._shaderSets.at(2).shaderProgram=this.loadShaderProgram(ji,Xi),this._shaderSets.at(3).shaderProgram=this.loadShaderProgram(ji,Hi),this._shaderSets.at(4).shaderProgram=this._shaderSets.at(1).shaderProgram,this._shaderSets.at(5).shaderProgram=this._shaderSets.at(2).shaderProgram,this._shaderSets.at(6).shaderProgram=this._shaderSets.at(3).shaderProgram,this._shaderSets.at(7).shaderProgram=this._shaderSets.at(1).shaderProgram,this._shaderSets.at(8).shaderProgram=this._shaderSets.at(2).shaderProgram,this._shaderSets.at(9).shaderProgram=this._shaderSets.at(3).shaderProgram,this._shaderSets.at(0).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(0).shaderProgram,"a_position"),this._shaderSets.at(0).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(0).shaderProgram,"a_texCoord"),this._shaderSets.at(0).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(0).shaderProgram,"s_texture0"),this._shaderSets.at(0).uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(0).shaderProgram,"u_clipMatrix"),this._shaderSets.at(0).uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets.at(0).shaderProgram,"u_channelFlag"),this._shaderSets.at(0).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(0).shaderProgram,"u_baseColor"),this._shaderSets.at(0).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(0).shaderProgram,"u_multiplyColor"),this._shaderSets.at(0).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(0).shaderProgram,"u_screenColor"),this._shaderSets.at(1).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(1).shaderProgram,"a_position"),this._shaderSets.at(1).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(1).shaderProgram,"a_texCoord"),this._shaderSets.at(1).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(1).shaderProgram,"s_texture0"),this._shaderSets.at(1).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(1).shaderProgram,"u_matrix"),this._shaderSets.at(1).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(1).shaderProgram,"u_baseColor"),this._shaderSets.at(1).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(1).shaderProgram,"u_multiplyColor"),this._shaderSets.at(1).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(1).shaderProgram,"u_screenColor"),this._shaderSets.at(2).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(2).shaderProgram,"a_position"),this._shaderSets.at(2).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(2).shaderProgram,"a_texCoord"),this._shaderSets.at(2).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(2).shaderProgram,"s_texture0"),this._shaderSets.at(2).samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets.at(2).shaderProgram,"s_texture1"),this._shaderSets.at(2).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(2).shaderProgram,"u_matrix"),this._shaderSets.at(2).uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(2).shaderProgram,"u_clipMatrix"),this._shaderSets.at(2).uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets.at(2).shaderProgram,"u_channelFlag"),this._shaderSets.at(2).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(2).shaderProgram,"u_baseColor"),this._shaderSets.at(2).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(2).shaderProgram,"u_multiplyColor"),this._shaderSets.at(2).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(2).shaderProgram,"u_screenColor"),this._shaderSets.at(3).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(3).shaderProgram,"a_position"),this._shaderSets.at(3).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(3).shaderProgram,"a_texCoord"),this._shaderSets.at(3).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(3).shaderProgram,"s_texture0"),this._shaderSets.at(3).samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets.at(3).shaderProgram,"s_texture1"),this._shaderSets.at(3).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(3).shaderProgram,"u_matrix"),this._shaderSets.at(3).uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(3).shaderProgram,"u_clipMatrix"),this._shaderSets.at(3).uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets.at(3).shaderProgram,"u_channelFlag"),this._shaderSets.at(3).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(3).shaderProgram,"u_baseColor"),this._shaderSets.at(3).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(3).shaderProgram,"u_multiplyColor"),this._shaderSets.at(3).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(3).shaderProgram,"u_screenColor"),this._shaderSets.at(4).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(4).shaderProgram,"a_position"),this._shaderSets.at(4).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(4).shaderProgram,"a_texCoord"),this._shaderSets.at(4).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(4).shaderProgram,"s_texture0"),this._shaderSets.at(4).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(4).shaderProgram,"u_matrix"),this._shaderSets.at(4).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(4).shaderProgram,"u_baseColor"),this._shaderSets.at(4).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(4).shaderProgram,"u_multiplyColor"),this._shaderSets.at(4).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(4).shaderProgram,"u_screenColor"),this._shaderSets.at(5).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(5).shaderProgram,"a_position"),this._shaderSets.at(5).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(5).shaderProgram,"a_texCoord"),this._shaderSets.at(5).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(5).shaderProgram,"s_texture0"),this._shaderSets.at(5).samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets.at(5).shaderProgram,"s_texture1"),this._shaderSets.at(5).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(5).shaderProgram,"u_matrix"),this._shaderSets.at(5).uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(5).shaderProgram,"u_clipMatrix"),this._shaderSets.at(5).uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets.at(5).shaderProgram,"u_channelFlag"),this._shaderSets.at(5).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(5).shaderProgram,"u_baseColor"),this._shaderSets.at(5).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(5).shaderProgram,"u_multiplyColor"),this._shaderSets.at(5).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(5).shaderProgram,"u_screenColor"),this._shaderSets.at(6).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(6).shaderProgram,"a_position"),this._shaderSets.at(6).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(6).shaderProgram,"a_texCoord"),this._shaderSets.at(6).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(6).shaderProgram,"s_texture0"),this._shaderSets.at(6).samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets.at(6).shaderProgram,"s_texture1"),this._shaderSets.at(6).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(6).shaderProgram,"u_matrix"),this._shaderSets.at(6).uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(6).shaderProgram,"u_clipMatrix"),this._shaderSets.at(6).uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets.at(6).shaderProgram,"u_channelFlag"),this._shaderSets.at(6).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(6).shaderProgram,"u_baseColor"),this._shaderSets.at(6).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(6).shaderProgram,"u_multiplyColor"),this._shaderSets.at(6).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(6).shaderProgram,"u_screenColor"),this._shaderSets.at(7).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(7).shaderProgram,"a_position"),this._shaderSets.at(7).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(7).shaderProgram,"a_texCoord"),this._shaderSets.at(7).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(7).shaderProgram,"s_texture0"),this._shaderSets.at(7).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(7).shaderProgram,"u_matrix"),this._shaderSets.at(7).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(7).shaderProgram,"u_baseColor"),this._shaderSets.at(7).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(7).shaderProgram,"u_multiplyColor"),this._shaderSets.at(7).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(7).shaderProgram,"u_screenColor"),this._shaderSets.at(8).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(8).shaderProgram,"a_position"),this._shaderSets.at(8).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(8).shaderProgram,"a_texCoord"),this._shaderSets.at(8).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(8).shaderProgram,"s_texture0"),this._shaderSets.at(8).samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets.at(8).shaderProgram,"s_texture1"),this._shaderSets.at(8).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(8).shaderProgram,"u_matrix"),this._shaderSets.at(8).uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(8).shaderProgram,"u_clipMatrix"),this._shaderSets.at(8).uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets.at(8).shaderProgram,"u_channelFlag"),this._shaderSets.at(8).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(8).shaderProgram,"u_baseColor"),this._shaderSets.at(8).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(8).shaderProgram,"u_multiplyColor"),this._shaderSets.at(8).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(8).shaderProgram,"u_screenColor"),this._shaderSets.at(9).attributePositionLocation=this.gl.getAttribLocation(this._shaderSets.at(9).shaderProgram,"a_position"),this._shaderSets.at(9).attributeTexCoordLocation=this.gl.getAttribLocation(this._shaderSets.at(9).shaderProgram,"a_texCoord"),this._shaderSets.at(9).samplerTexture0Location=this.gl.getUniformLocation(this._shaderSets.at(9).shaderProgram,"s_texture0"),this._shaderSets.at(9).samplerTexture1Location=this.gl.getUniformLocation(this._shaderSets.at(9).shaderProgram,"s_texture1"),this._shaderSets.at(9).uniformMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(9).shaderProgram,"u_matrix"),this._shaderSets.at(9).uniformClipMatrixLocation=this.gl.getUniformLocation(this._shaderSets.at(9).shaderProgram,"u_clipMatrix"),this._shaderSets.at(9).uniformChannelFlagLocation=this.gl.getUniformLocation(this._shaderSets.at(9).shaderProgram,"u_channelFlag"),this._shaderSets.at(9).uniformBaseColorLocation=this.gl.getUniformLocation(this._shaderSets.at(9).shaderProgram,"u_baseColor"),this._shaderSets.at(9).uniformMultiplyColorLocation=this.gl.getUniformLocation(this._shaderSets.at(9).shaderProgram,"u_multiplyColor"),this._shaderSets.at(9).uniformScreenColorLocation=this.gl.getUniformLocation(this._shaderSets.at(9).shaderProgram,"u_screenColor")}loadShaderProgram(t,e){let i=this.gl.createProgram(),s=this.compileShaderSource(this.gl.VERTEX_SHADER,t);if(!s)return O("Vertex shader compile error!"),0;let r=this.compileShaderSource(this.gl.FRAGMENT_SHADER,e);if(!r)return O("Vertex shader compile error!"),0;this.gl.attachShader(i,s),this.gl.attachShader(i,r),this.gl.linkProgram(i);return this.gl.getProgramParameter(i,this.gl.LINK_STATUS)?(this.gl.deleteShader(s),this.gl.deleteShader(r),i):(O("Failed to link program: {0}",i),this.gl.deleteShader(s),s=0,this.gl.deleteShader(r),r=0,i&&(this.gl.deleteProgram(i),i=0),0)}compileShaderSource(t,e){const i=e,s=this.gl.createShader(t);if(this.gl.shaderSource(s,i),this.gl.compileShader(s),!s){const t=this.gl.getShaderInfoLog(s);O("Shader compile log: {0} ",t)}return this.gl.getShaderParameter(s,this.gl.COMPILE_STATUS)?s:(this.gl.deleteShader(s),null)}setGl(t){this.gl=t}}class Di{static getInstance(){return null==Ti&&(Ti=new Di),Ti}static deleteInstance(){Ti&&(Ti.release(),Ti=null)}constructor(){this._shaderMap=new j}release(){for(const t=this._shaderMap.begin();t.notEqual(this._shaderMap.end());t.preIncrement())t.ptr().second.release();this._shaderMap.clear()}getShader(t){return this._shaderMap.getValue(t)}setGlContext(t){if(!this._shaderMap.isExist(t)){const e=new Ai;e.setGl(t),this._shaderMap.setValue(t,e)}}}class Oi{}var ki=(t=>(t[t.ShaderNames_SetupMask=0]="ShaderNames_SetupMask",t[t.ShaderNames_NormalPremultipliedAlpha=1]="ShaderNames_NormalPremultipliedAlpha",t[t.ShaderNames_NormalMaskedPremultipliedAlpha=2]="ShaderNames_NormalMaskedPremultipliedAlpha",t[t.ShaderNames_NomralMaskedInvertedPremultipliedAlpha=3]="ShaderNames_NomralMaskedInvertedPremultipliedAlpha",t[t.ShaderNames_AddPremultipliedAlpha=4]="ShaderNames_AddPremultipliedAlpha",t[t.ShaderNames_AddMaskedPremultipliedAlpha=5]="ShaderNames_AddMaskedPremultipliedAlpha",t[t.ShaderNames_AddMaskedPremultipliedAlphaInverted=6]="ShaderNames_AddMaskedPremultipliedAlphaInverted",t[t.ShaderNames_MultPremultipliedAlpha=7]="ShaderNames_MultPremultipliedAlpha",t[t.ShaderNames_MultMaskedPremultipliedAlpha=8]="ShaderNames_MultMaskedPremultipliedAlpha",t[t.ShaderNames_MultMaskedPremultipliedAlphaInverted=9]="ShaderNames_MultMaskedPremultipliedAlphaInverted",t))(ki||{});const Ni="attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;varying vec4 v_myPos;uniform mat4 u_clipMatrix;void main(){ gl_Position = u_clipMatrix * a_position; v_myPos = u_clipMatrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}",Ui="precision mediump float;varying vec2 v_texCoord;varying vec4 v_myPos;uniform vec4 u_baseColor;uniform vec4 u_channelFlag;uniform sampler2D s_texture0;void main(){ float isInside = step(u_baseColor.x, v_myPos.x/v_myPos.w) * step(u_baseColor.y, v_myPos.y/v_myPos.w) * step(v_myPos.x/v_myPos.w, u_baseColor.z) * step(v_myPos.y/v_myPos.w, u_baseColor.w); gl_FragColor = u_channelFlag * texture2D(s_texture0, v_texCoord).a * isInside;}",zi="attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;uniform mat4 u_matrix;void main(){ gl_Position = u_matrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}",ji="attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform mat4 u_matrix;uniform mat4 u_clipMatrix;void main(){ gl_Position = u_matrix * a_position; v_clipPos = u_clipMatrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}",Gi="precision mediump float;varying vec2 v_texCoord;uniform vec4 u_baseColor;uniform sampler2D s_texture0;uniform vec4 u_multiplyColor;uniform vec4 u_screenColor;void main(){ vec4 texColor = texture2D(s_texture0, v_texCoord); texColor.rgb = texColor.rgb * u_multiplyColor.rgb; texColor.rgb = (texColor.rgb + u_screenColor.rgb * texColor.a) - (texColor.rgb * u_screenColor.rgb); vec4 color = texColor * u_baseColor; gl_FragColor = vec4(color.rgb, color.a);}",Xi="precision mediump float;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform vec4 u_baseColor;uniform vec4 u_channelFlag;uniform sampler2D s_texture0;uniform sampler2D s_texture1;uniform vec4 u_multiplyColor;uniform vec4 u_screenColor;void main(){ vec4 texColor = texture2D(s_texture0, v_texCoord); texColor.rgb = texColor.rgb * u_multiplyColor.rgb; texColor.rgb = (texColor.rgb + u_screenColor.rgb * texColor.a) - (texColor.rgb * u_screenColor.rgb); vec4 col_formask = texColor * u_baseColor; vec4 clipMask = (1.0 - texture2D(s_texture1, v_clipPos.xy / v_clipPos.w)) * u_channelFlag; float maskVal = clipMask.r + clipMask.g + clipMask.b + clipMask.a; col_formask = col_formask * maskVal; gl_FragColor = col_formask;}",Hi="precision mediump float;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform sampler2D s_texture0;uniform sampler2D s_texture1;uniform vec4 u_channelFlag;uniform vec4 u_baseColor;uniform vec4 u_multiplyColor;uniform vec4 u_screenColor;void main(){ vec4 texColor = texture2D(s_texture0, v_texCoord); texColor.rgb = texColor.rgb * u_multiplyColor.rgb; texColor.rgb = (texColor.rgb + u_screenColor.rgb * texColor.a) - (texColor.rgb * u_screenColor.rgb); vec4 col_formask = texColor * u_baseColor; vec4 clipMask = (1.0 - texture2D(s_texture1, v_clipPos.xy / v_clipPos.w)) * u_channelFlag; float maskVal = clipMask.r + clipMask.g + clipMask.b + clipMask.a; col_formask = col_formask * (1.0 - maskVal); gl_FragColor = col_formask;}";var qi;let Wi,Yi;(t=>{t.CubismShaderSet=Oi,t.CubismShader_WebGL=Ai,t.CubismShaderManager_WebGL=Di,t.ShaderNames=ki})(qi||(qi={}));class Ji extends Li{getMaskRenderTexture(){if(this._maskTexture&&null!=this._maskTexture.textures)this._maskTexture.frameNo=this._currentFrameNo;else{null!=this._maskRenderTextures&&this._maskRenderTextures.clear(),this._maskRenderTextures=new g,null!=this._maskColorBuffers&&this._maskColorBuffers.clear(),this._maskColorBuffers=new g;const t=this._clippingMaskBufferSize;for(let e=0;e<this._renderTextureCount;e++)this._maskColorBuffers.pushBack(this.gl.createTexture()),this.gl.bindTexture(this.gl.TEXTURE_2D,this._maskColorBuffers.at(e)),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,t,t,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,null),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),this.gl.bindTexture(this.gl.TEXTURE_2D,null),this._maskRenderTextures.pushBack(this.gl.createFramebuffer()),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._maskRenderTextures.at(e)),this.gl.framebufferTexture2D(this.gl.FRAMEBUFFER,this.gl.COLOR_ATTACHMENT0,this.gl.TEXTURE_2D,this._maskColorBuffers.at(e),0);this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,Yi),this._maskTexture=new $i(this._currentFrameNo,this._maskRenderTextures)}return this._maskTexture.textures}setGL(t){this.gl=t}constructor(){super(Zi)}setupClippingContext(t,e){this._currentFrameNo++;let i=0;for(let s=0;s<this._clippingContextListForMask.getSize();s++){const e=this._clippingContextListForMask.at(s);this.calcClippedDrawTotalBounds(t,e),e._isUsing&&i++}if(i>0){this.gl.viewport(0,0,this._clippingMaskBufferSize,this._clippingMaskBufferSize),this._currentMaskRenderTexture=this.getMaskRenderTexture().at(0),e.preDraw(),this.setupLayoutBounds(i),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._currentMaskRenderTexture),this._clearedFrameBufferFlags.getSize()!=this._renderTextureCount&&(this._clearedFrameBufferFlags.clear(),this._clearedFrameBufferFlags=new g(this._renderTextureCount));for(let t=0;t<this._clearedFrameBufferFlags.getSize();t++)this._clearedFrameBufferFlags.set(t,!1);for(let i=0;i<this._clippingContextListForMask.getSize();i++){const s=this._clippingContextListForMask.at(i),r=s._allClippedDrawRect,a=s._layoutBounds,n=.05;let o=0,l=0;const u=this.getMaskRenderTexture().at(s._bufferIndex);this._currentMaskRenderTexture!=u&&(this._currentMaskRenderTexture=u,e.preDraw(),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._currentMaskRenderTexture)),this._tmpBoundsOnModel.setRect(r),this._tmpBoundsOnModel.expand(r.width*n,r.height*n),o=a.width/this._tmpBoundsOnModel.width,l=a.height/this._tmpBoundsOnModel.height,this._tmpMatrix.loadIdentity(),this._tmpMatrix.translateRelative(-1,-1),this._tmpMatrix.scaleRelative(2,2),this._tmpMatrix.translateRelative(a.x,a.y),this._tmpMatrix.scaleRelative(o,l),this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x,-this._tmpBoundsOnModel.y),this._tmpMatrixForMask.setMatrix(this._tmpMatrix.getArray()),this._tmpMatrix.loadIdentity(),this._tmpMatrix.translateRelative(a.x,a.y),this._tmpMatrix.scaleRelative(o,l),this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x,-this._tmpBoundsOnModel.y),this._tmpMatrixForDraw.setMatrix(this._tmpMatrix.getArray()),s._matrixForMask.setMatrix(this._tmpMatrixForMask.getArray()),s._matrixForDraw.setMatrix(this._tmpMatrixForDraw.getArray());const h=s._clippingIdCount;for(let i=0;i<h;i++){const r=s._clippingIdList[i];t.getDrawableDynamicFlagVertexPositionsDidChange(r)&&(e.setIsCulling(0!=t.getDrawableCulling(r)),this._clearedFrameBufferFlags.at(s._bufferIndex)||(this.gl.clearColor(1,1,1,1),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this._clearedFrameBufferFlags.set(s._bufferIndex,!0)),e.setClippingContextBufferForMask(s),e.drawMeshWebGL(t,r))}}this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,Yi),e.setClippingContextBufferForMask(null),this.gl.viewport(Wi[0],Wi[1],Wi[2],Wi[3])}}getColorBuffer(){return this._maskColorBuffers}getClippingMaskCount(){return this._clippingContextListForMask.getSize()}}class $i{constructor(t,e){this.frameNo=t,this.textures=e}}class Zi extends E{constructor(t,e,i){super(e,i),this._owner=t}getClippingManager(){return this._owner}setGl(t){this._owner.setGL(t)}}class Ki{setGlEnable(t,e){e?this.gl.enable(t):this.gl.disable(t)}setGlEnableVertexAttribArray(t,e){e?this.gl.enableVertexAttribArray(t):this.gl.disableVertexAttribArray(t)}save(){null!=this.gl?(this._lastArrayBufferBinding=this.gl.getParameter(this.gl.ARRAY_BUFFER_BINDING),this._lastElementArrayBufferBinding=this.gl.getParameter(this.gl.ELEMENT_ARRAY_BUFFER_BINDING),this._lastProgram=this.gl.getParameter(this.gl.CURRENT_PROGRAM),this._lastActiveTexture=this.gl.getParameter(this.gl.ACTIVE_TEXTURE),this.gl.activeTexture(this.gl.TEXTURE1),this._lastTexture1Binding2D=this.gl.getParameter(this.gl.TEXTURE_BINDING_2D),this.gl.activeTexture(this.gl.TEXTURE0),this._lastTexture0Binding2D=this.gl.getParameter(this.gl.TEXTURE_BINDING_2D),this._lastVertexAttribArrayEnabled[0]=this.gl.getVertexAttrib(0,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastVertexAttribArrayEnabled[1]=this.gl.getVertexAttrib(1,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastVertexAttribArrayEnabled[2]=this.gl.getVertexAttrib(2,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastVertexAttribArrayEnabled[3]=this.gl.getVertexAttrib(3,this.gl.VERTEX_ATTRIB_ARRAY_ENABLED),this._lastScissorTest=this.gl.isEnabled(this.gl.SCISSOR_TEST),this._lastStencilTest=this.gl.isEnabled(this.gl.STENCIL_TEST),this._lastDepthTest=this.gl.isEnabled(this.gl.DEPTH_TEST),this._lastCullFace=this.gl.isEnabled(this.gl.CULL_FACE),this._lastBlend=this.gl.isEnabled(this.gl.BLEND),this._lastFrontFace=this.gl.getParameter(this.gl.FRONT_FACE),this._lastColorMask=this.gl.getParameter(this.gl.COLOR_WRITEMASK),this._lastBlending[0]=this.gl.getParameter(this.gl.BLEND_SRC_RGB),this._lastBlending[1]=this.gl.getParameter(this.gl.BLEND_DST_RGB),this._lastBlending[2]=this.gl.getParameter(this.gl.BLEND_SRC_ALPHA),this._lastBlending[3]=this.gl.getParameter(this.gl.BLEND_DST_ALPHA),this._lastFBO=this.gl.getParameter(this.gl.FRAMEBUFFER_BINDING),this._lastViewport=this.gl.getParameter(this.gl.VIEWPORT)):O("'gl' is null. WebGLRenderingContext is required.\nPlease call 'CubimRenderer_WebGL.startUp' function.")}restore(){null!=this.gl?(this.gl.useProgram(this._lastProgram),this.setGlEnableVertexAttribArray(0,this._lastVertexAttribArrayEnabled[0]),this.setGlEnableVertexAttribArray(1,this._lastVertexAttribArrayEnabled[1]),this.setGlEnableVertexAttribArray(2,this._lastVertexAttribArrayEnabled[2]),this.setGlEnableVertexAttribArray(3,this._lastVertexAttribArrayEnabled[3]),this.setGlEnable(this.gl.SCISSOR_TEST,this._lastScissorTest),this.setGlEnable(this.gl.STENCIL_TEST,this._lastStencilTest),this.setGlEnable(this.gl.DEPTH_TEST,this._lastDepthTest),this.setGlEnable(this.gl.CULL_FACE,this._lastCullFace),this.setGlEnable(this.gl.BLEND,this._lastBlend),this.gl.frontFace(this._lastFrontFace),this.gl.colorMask(this._lastColorMask[0],this._lastColorMask[1],this._lastColorMask[2],this._lastColorMask[3]),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this._lastArrayBufferBinding),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this._lastElementArrayBufferBinding),this.gl.activeTexture(this.gl.TEXTURE1),this.gl.bindTexture(this.gl.TEXTURE_2D,this._lastTexture1Binding2D),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,this._lastTexture0Binding2D),this.gl.activeTexture(this._lastActiveTexture),this.gl.blendFuncSeparate(this._lastBlending[0],this._lastBlending[1],this._lastBlending[2],this._lastBlending[3])):O("'gl' is null. WebGLRenderingContext is required.\nPlease call 'CubimRenderer_WebGL.startUp' function.")}setGl(t){this.gl=t}constructor(){this._lastVertexAttribArrayEnabled=new Array(4),this._lastColorMask=new Array(4),this._lastBlending=new Array(4),this._lastViewport=new Array(4)}}class Qi extends B{initialize(t,e=1){t.isUsingMasking()&&(this._clippingManager=new Ji,this._clippingManager.initialize(t,e)),this._sortedDrawableIndexList.resize(t.getDrawableCount(),0),super.initialize(t)}bindTexture(t,e){this._textures.setValue(t,e)}getBindedTextures(){return this._textures}setClippingMaskBufferSize(t){if(!this._model.isUsingMasking())return;const e=this._clippingManager.getRenderTextureCount();this._clippingManager.release(),this._clippingManager=void 0,this._clippingManager=null,this._clippingManager=new Ji,this._clippingManager.setClippingMaskBufferSize(t),this._clippingManager.initialize(this.getModel(),e)}getClippingMaskBufferSize(){return this._model.isUsingMasking()?this._clippingManager.getClippingMaskBufferSize():-1}getRenderTextureCount(){return this._model.isUsingMasking()?this._clippingManager.getRenderTextureCount():-1}constructor(){super(),this._clippingContextBufferForMask=null,this._clippingContextBufferForDraw=null,this._rendererProfile=new Ki,this.firstDraw=!0,this._textures=new j,this._sortedDrawableIndexList=new g,this._bufferData={vertex:WebGLBuffer=null,uv:WebGLBuffer=null,index:WebGLBuffer=null},this._textures.prepareCapacity(32,!0)}release(){this._clippingManager&&(this._clippingManager.release(),this._clippingManager=void 0,this._clippingManager=null),null!=this.gl&&(this.gl.deleteBuffer(this._bufferData.vertex),this._bufferData.vertex=null,this.gl.deleteBuffer(this._bufferData.uv),this._bufferData.uv=null,this.gl.deleteBuffer(this._bufferData.index),this._bufferData.index=null,this._bufferData=null,this._textures=null)}doDrawModel(){if(null==this.gl)return void O("'gl' is null. WebGLRenderingContext is required.\nPlease call 'CubimRenderer_WebGL.startUp' function.");null!=this._clippingManager&&(this.preDraw(),this.isUsingHighPrecisionMask()?this._clippingManager.setupMatrixForHighPrecision(this.getModel(),!1):this._clippingManager.setupClippingContext(this.getModel(),this)),this.preDraw();const t=this.getModel().getDrawableCount(),e=this.getModel().getDrawableRenderOrders();for(let i=0;i<t;++i){const t=e[i];this._sortedDrawableIndexList.set(t,i)}for(let i=0;i<t;++i){const t=this._sortedDrawableIndexList.at(i);if(!this.getModel().getDrawableDynamicFlagIsVisible(t))continue;const e=null!=this._clippingManager?this._clippingManager.getClippingContextListForDraw().at(t):null;if(null!=e&&this.isUsingHighPrecisionMask()){e._isUsing&&(this.gl.viewport(0,0,this._clippingManager.getClippingMaskBufferSize(),this._clippingManager.getClippingMaskBufferSize()),this.preDraw(),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,e.getClippingManager().getMaskRenderTexture().at(e._bufferIndex)),this.gl.clearColor(1,1,1,1),this.gl.clear(this.gl.COLOR_BUFFER_BIT));{const t=e._clippingIdCount;for(let i=0;i<t;i++){const t=e._clippingIdList[i];this._model.getDrawableDynamicFlagVertexPositionsDidChange(t)&&(this.setIsCulling(0!=this._model.getDrawableCulling(t)),this.setClippingContextBufferForMask(e),this.drawMeshWebGL(this._model,t))}}this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,Yi),this.setClippingContextBufferForMask(null),this.gl.viewport(Wi[0],Wi[1],Wi[2],Wi[3]),this.preDraw()}this.setClippingContextBufferForDraw(e),this.setIsCulling(this.getModel().getDrawableCulling(t)),this.drawMeshWebGL(this._model,t)}}drawMeshWebGL(t,e){this.isCulling()?this.gl.enable(this.gl.CULL_FACE):this.gl.disable(this.gl.CULL_FACE),this.gl.frontFace(this.gl.CCW),this.isGeneratingMask()?Di.getInstance().getShader(this.gl).setupShaderProgramForMask(this,t,e):Di.getInstance().getShader(this.gl).setupShaderProgramForDraw(this,t,e);{const i=t.getDrawableVertexIndexCount(e);this.gl.drawElements(this.gl.TRIANGLES,i,this.gl.UNSIGNED_SHORT,0)}this.gl.useProgram(null),this.setClippingContextBufferForDraw(null),this.setClippingContextBufferForMask(null)}saveProfile(){this._rendererProfile.save()}restoreProfile(){this._rendererProfile.restore()}static doStaticRelease(){Di.deleteInstance()}setRenderState(t,e){Yi=t,Wi=e}preDraw(){if(this.firstDraw&&(this.firstDraw=!1),this.gl.disable(this.gl.SCISSOR_TEST),this.gl.disable(this.gl.STENCIL_TEST),this.gl.disable(this.gl.DEPTH_TEST),this.gl.frontFace(this.gl.CW),this.gl.enable(this.gl.BLEND),this.gl.colorMask(!0,!0,!0,!0),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,null),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,null),this.getAnisotropy()>0&&this._extension)for(let t=0;t<this._textures.getSize();++t)this.gl.bindTexture(this.gl.TEXTURE_2D,this._textures.getValue(t)),this.gl.texParameterf(this.gl.TEXTURE_2D,this._extension.TEXTURE_MAX_ANISOTROPY_EXT,this.getAnisotropy())}setClippingContextBufferForMask(t){this._clippingContextBufferForMask=t}getClippingContextBufferForMask(){return this._clippingContextBufferForMask}setClippingContextBufferForDraw(t){this._clippingContextBufferForDraw=t}getClippingContextBufferForDraw(){return this._clippingContextBufferForDraw}isGeneratingMask(){return null!=this.getClippingContextBufferForMask()}startUp(t){this.gl=t,this._clippingManager&&this._clippingManager.setGL(t),Di.getInstance().setGlContext(t),this._rendererProfile.setGl(t),this._extension=this.gl.getExtension("EXT_texture_filter_anisotropic")||this.gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||this.gl.getExtension("MOZ_EXT_texture_filter_anisotropic")}}var ts;B.staticRelease=()=>{Qi.doStaticRelease()},(t=>{t.CubismClippingContext=Zi,t.CubismClippingManager_WebGL=Ji,t.CubismRenderTextureResource=$i,t.CubismRenderer_WebGL=Qi})(ts||(ts={}));const es=new b;class is extends Ot{constructor(t,i,s){super(),u(this,"settings"),u(this,"options"),u(this,"coreModel"),u(this,"motionManager"),u(this,"parallelMotionManager"),u(this,"lipSync",!0),u(this,"breath",wi.create()),u(this,"eyeBlink"),u(this,"renderer",new Qi),u(this,"idManager"),u(this,"idParamAngleX"),u(this,"idParamAngleY"),u(this,"idParamAngleZ"),u(this,"idParamEyeBallX"),u(this,"idParamEyeBallY"),u(this,"idParamBodyAngleX"),u(this,"idParamBreath"),u(this,"idParamMouthForm"),u(this,"pixelsPerUnit",1),u(this,"modelTransform",new e.Matrix),this.coreModel=t,this.settings=i,this.options=Object.assign({},{breathDepth:1,lipSyncGain:1.5,lipSyncWeight:.4},s),this.idManager=ht.getIdManager(),this.idParamAngleX=this.getIdSafe(bi.ParamAngleX),this.idParamAngleY=this.getIdSafe(bi.ParamAngleY),this.idParamAngleZ=this.getIdSafe(bi.ParamAngleZ),this.idParamEyeBallX=this.getIdSafe(bi.ParamEyeBallX),this.idParamEyeBallY=this.getIdSafe(bi.ParamEyeBallY),this.idParamBodyAngleX=this.getIdSafe(bi.ParamBodyAngleX),this.idParamBreath=this.getIdSafe(bi.ParamBreath),this.idParamMouthForm=this.getIdSafe(bi.ParamMouthForm),this.motionManager=new di(this),this.parallelMotionManager=[],this.init()}init(){var t;super.init();const e=this.settings.getEyeBlinkParameters();if(e.length)if(this.isCubismModelSetting(this.settings))this.eyeBlink=Ei.create(this.settings);else{const i=new g;for(const t of e)i.pushBack(this.idManager.getId(t));const s=Ei.create();null==(t=s.setParameterIds)||t.call(s,i),this.eyeBlink=s}const i=new g;i.pushBack(new Fi(this.idParamAngleX,0,15*this.options.breathDepth,6.5345,.5)),i.pushBack(new Fi(this.idParamAngleY,0,8*this.options.breathDepth,3.5345,.5)),i.pushBack(new Fi(this.idParamAngleZ,0,10*this.options.breathDepth,5.5345,.5)),i.pushBack(new Fi(this.idParamBodyAngleX,0,4*this.options.breathDepth,15.5345,.5)),i.pushBack(new Fi(this.idParamBreath,0,.5,3.2345,.5)),this.breath.setParameters(i),this.renderer.initialize(this.coreModel,function(t){var e;if(!t.isUsingMasking())return 1;const i=t.getDrawableMaskCounts(),s=t.getDrawableMasks(),r=new Set;for(let n=0;n<t.getDrawableCount();n++){const t=i[n];if(!t||t<=0)continue;const a=Array.from(null!=(e=s[n])?e:[]).slice(0,t).sort((t,e)=>t-e).join(",");r.add(a)}const a=r.size;return a<=36?1:Math.ceil(a/32)}(this.coreModel)),this.renderer.setIsPremultipliedAlpha(!0)}getIdSafe(t){return this.idManager.getId(null!=t?t:"")}getSize(){return[this.coreModel.getModel().canvasinfo.CanvasWidth,this.coreModel.getModel().canvasinfo.CanvasHeight]}getLayout(){const t={},e=this.settings.layout;if(e)for(const[i,s]of Object.entries(e)){t[i.charAt(0).toLowerCase()+i.slice(1)]=s}return t}setupLayout(){super.setupLayout(),this.pixelsPerUnit=this.coreModel.getModel().canvasinfo.PixelsPerUnit,this.modelTransform.scale(this.pixelsPerUnit,this.pixelsPerUnit).translate(this.originalWidth/2,this.originalHeight/2)}updateWebGLContext(t,e){this.renderer.firstDraw=!0,this.renderer._bufferData={vertex:null,uv:null,index:null},this.renderer.startUp(t),this.renderer._clippingManager&&(this.renderer._clippingManager._currentFrameNo=e),Di.getInstance().setGlContext(t)}bindTexture(t,e){this.renderer.bindTexture(t,e)}getHitAreaDefs(){var t,e,i;const s=this.settings.json;return At(null!=(i=null!=(e=null!=(t=this.settings.hitAreas)?t:s.HitAreas)?e:s.hitAreas)?i:s.hit_areas,t=>this.coreModel.getDrawableIndex(this.idManager.getId(t)))}getDrawableIDs(){const t=this.coreModel.getDrawableCount(),e=[];for(let i=0;i<t;i++)e.push(this.coreModel.getDrawableId(i).getString().s);return e}getDrawableIndex(t){return this.coreModel.getDrawableIndex(this.idManager.getId(t))}getDrawableVertices(t){if("string"==typeof t){const e=t;if(-1===(t=this.getDrawableIndex(e)))throw new TypeError("Unable to find drawable ID: "+e)}const e=this.coreModel.getDrawableVertices(t).slice();for(let i=0;i<e.length;i+=2)e[i]=e[i]*this.pixelsPerUnit+this.originalWidth/2,e[i+1]=-e[i+1]*this.pixelsPerUnit+this.originalHeight/2;return e}updateTransform(t){this.drawingMatrix.copyFrom(this.modelTransform).prepend(this.localTransform).prepend(t)}update(t,e){var i,s,r,a,n;super.update(t,e),t/=1e3,e/=1e3;const o=this.coreModel,l=this.updateMotions(o,e);if(o.saveParameters(),null==(i=this.motionManager.expressionManager)||i.update(o,e),l||null==(r=null==(s=this.eyeBlink)?void 0:s.updateParameters)||r.call(s,o,t),this.updateFocus(),this.updateNaturalMovements(1e3*t,1e3*e),this.lipSync&&this.motionManager.currentAudio){let t=this.motionManager.mouthSync()*this.options.lipSyncGain;t=Math.pow(t,1.15);t=mt(t,t>0?.1:0,1),this.motionManager.lipSyncIds.forEach(e=>{o.addParameterValueById(this.getIdSafe(e),t,this.options.lipSyncWeight)})}null==(a=this.physics)||a.evaluate(o,t),null==(n=this.pose)||n.updateParameters(o,t),this.emit("beforeModelUpdate"),o.update(),o.loadParameters()}updateFocus(){this.coreModel.addParameterValueById(this.idParamEyeBallX,this.focusController.x),this.coreModel.addParameterValueById(this.idParamEyeBallY,this.focusController.y),this.coreModel.addParameterValueById(this.idParamAngleX,30*this.focusController.x),this.coreModel.addParameterValueById(this.idParamAngleY,30*this.focusController.y),this.coreModel.addParameterValueById(this.idParamAngleZ,this.focusController.x*this.focusController.y*-30),this.coreModel.addParameterValueById(this.idParamBodyAngleX,10*this.focusController.x)}updateFacialEmotion(t){this.coreModel.addParameterValueById(this.idParamMouthForm,t)}updateNaturalMovements(t,e){var i;null==(i=this.breath)||i.updateParameters(this.coreModel,t/1e3)}draw(t){const e=this.drawingMatrix,i=es.getArray();i[0]=e.a,i[1]=e.b,i[4]=-e.c,i[5]=-e.d,i[12]=e.tx,i[13]=e.ty,this.renderer.setMvpMatrix(es);const s=t.getParameter(t.FRAMEBUFFER_BINDING);this.renderer.setRenderState(s,this.viewport),this.renderer.drawModel()}extendParallelMotionManager(t){for(;this.parallelMotionManager.length<t;)this.parallelMotionManager.push(new yi(this))}destroy(){super.destroy(),this.renderer.release(),this.coreModel.release(),this.renderer=void 0,this.coreModel=void 0}isCubismModelSetting(t){return"function"==typeof t.getEyeBlinkParameterCount&&"function"==typeof t.getEyeBlinkParameterId}}class ss{}var rs;(t=>{t.ICubismModelSetting=ss})(rs||(rs={}));var as,ns=(t=>(t[t.FrequestNode_Groups=0]="FrequestNode_Groups",t[t.FrequestNode_Moc=1]="FrequestNode_Moc",t[t.FrequestNode_Motions=2]="FrequestNode_Motions",t[t.FrequestNode_Expressions=3]="FrequestNode_Expressions",t[t.FrequestNode_Textures=4]="FrequestNode_Textures",t[t.FrequestNode_Physics=5]="FrequestNode_Physics",t[t.FrequestNode_Pose=6]="FrequestNode_Pose",t[t.FrequestNode_HitAreas=7]="FrequestNode_HitAreas",t))(ns||{});class os extends ss{constructor(t,e){super(),this.version="Version",this.fileReferences="FileReferences",this.groups="Groups",this.layout="Layout",this.hitAreas="HitAreas",this.moc="Moc",this.textures="Textures",this.physics="Physics",this.pose="Pose",this.expressions="Expressions",this.motions="Motions",this.userData="UserData",this.name="Name",this.filePath="File",this.id="Id",this.ids="Ids",this.target="Target",this.idle="Idle",this.tapBody="TapBody",this.pinchIn="PinchIn",this.pinchOut="PinchOut",this.shake="Shake",this.flickHead="FlickHead",this.parameter="Parameter",this.soundPath="Sound",this.fadeInTime="FadeInTime",this.fadeOutTime="FadeOutTime",this.centerX="CenterX",this.centerY="CenterY",this.x="X",this.y="Y",this.width="Width",this.height="Height",this.lipSync="LipSync",this.eyeBlink="EyeBlink",this.initParameter="init_param",this.initPartsVisible="init_parts_visible",this.val="val",this._json=Y.create(t,e),this.getJson()&&(this._jsonValue=new g,this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.groups)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.moc)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.motions)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.expressions)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.textures)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.physics)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.pose)),this._jsonValue.pushBack(this.getJson().getRoot().getValueByString(this.hitAreas)))}release(){Y.delete(this._json),this._jsonValue=null}getJson(){return this._json}getModelFileName(){return this.isExistModelFile()?this._jsonValue.at(1).getRawString():""}getTextureCount(){return this.isExistTextureFiles()?this._jsonValue.at(4).getSize():0}getTextureDirectory(){const t=this._jsonValue.at(4).getValueByIndex(0).getRawString().split("/"),e=t.length-1;let i="";for(let s=0;s<e;s++)i+=t[s],s<e-1&&(i+="/");return i}getTextureFileName(t){return this._jsonValue.at(4).getValueByIndex(t).getRawString()}getHitAreasCount(){return this.isExistHitAreas()?this._jsonValue.at(7).getSize():0}getHitAreaId(t){return ht.getIdManager().getId(this._jsonValue.at(7).getValueByIndex(t).getValueByString(this.id).getRawString())}getHitAreaName(t){return this._jsonValue.at(7).getValueByIndex(t).getValueByString(this.name).getRawString()}getPhysicsFileName(){return this.isExistPhysicsFile()?this._jsonValue.at(5).getRawString():""}getPoseFileName(){return this.isExistPoseFile()?this._jsonValue.at(6).getRawString():""}getExpressionCount(){return this.isExistExpressionFile()?this._jsonValue.at(3).getSize():0}getExpressionName(t){return this._jsonValue.at(3).getValueByIndex(t).getValueByString(this.name).getRawString()}getExpressionFileName(t){return this._jsonValue.at(3).getValueByIndex(t).getValueByString(this.filePath).getRawString()}getMotionGroupCount(){return this.isExistMotionGroups()?this._jsonValue.at(2).getKeys().getSize():0}getMotionGroupName(t){return this.isExistMotionGroups()?this._jsonValue.at(2).getKeys().at(t):null}getMotionCount(t){return this.isExistMotionGroupName(t)?this._jsonValue.at(2).getValueByString(t).getSize():0}getMotionFileName(t,e){return this.isExistMotionGroupName(t)?this._jsonValue.at(2).getValueByString(t).getValueByIndex(e).getValueByString(this.filePath).getRawString():""}getMotionSoundFileName(t,e){return this.isExistMotionSoundFile(t,e)?this._jsonValue.at(2).getValueByString(t).getValueByIndex(e).getValueByString(this.soundPath).getRawString():""}getMotionFadeInTimeValue(t,e){return this.isExistMotionFadeIn(t,e)?this._jsonValue.at(2).getValueByString(t).getValueByIndex(e).getValueByString(this.fadeInTime).toFloat():-1}getMotionFadeOutTimeValue(t,e){return this.isExistMotionFadeOut(t,e)?this._jsonValue.at(2).getValueByString(t).getValueByIndex(e).getValueByString(this.fadeOutTime).toFloat():-1}getUserDataFile(){return this.isExistUserDataFile()?this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.userData).getRawString():""}getLayoutMap(t){const e=this.getJson().getRoot().getValueByString(this.layout).getMap();if(null==e)return!1;let i=!1;for(const s=e.begin();s.notEqual(e.end());s.preIncrement())t.setValue(s.ptr().first,s.ptr().second.toFloat()),i=!0;return i}getEyeBlinkParameterCount(){if(!this.isExistEyeBlinkParameters())return 0;let t=0;for(let e=0;e<this._jsonValue.at(0).getSize();e++){const i=this._jsonValue.at(0).getValueByIndex(e);if(!i.isNull()&&!i.isError()&&i.getValueByString(this.name).getRawString()==this.eyeBlink){t=i.getValueByString(this.ids).getVector().getSize();break}}return t}getEyeBlinkParameterId(t){if(!this.isExistEyeBlinkParameters())return null;for(let e=0;e<this._jsonValue.at(0).getSize();e++){const i=this._jsonValue.at(0).getValueByIndex(e);if(!i.isNull()&&!i.isError()&&i.getValueByString(this.name).getRawString()==this.eyeBlink)return ht.getIdManager().getId(i.getValueByString(this.ids).getValueByIndex(t).getRawString())}return null}getLipSyncParameterCount(){if(!this.isExistLipSyncParameters())return 0;let t=0;for(let e=0;e<this._jsonValue.at(0).getSize();e++){const i=this._jsonValue.at(0).getValueByIndex(e);if(!i.isNull()&&!i.isError()&&i.getValueByString(this.name).getRawString()==this.lipSync){t=i.getValueByString(this.ids).getVector().getSize();break}}return t}getLipSyncParameterId(t){if(!this.isExistLipSyncParameters())return null;for(let e=0;e<this._jsonValue.at(0).getSize();e++){const i=this._jsonValue.at(0).getValueByIndex(e);if(!i.isNull()&&!i.isError()&&i.getValueByString(this.name).getRawString()==this.lipSync)return ht.getIdManager().getId(i.getValueByString(this.ids).getValueByIndex(t).getRawString())}return null}isExistModelFile(){const t=this._jsonValue.at(1);return!t.isNull()&&!t.isError()}isExistTextureFiles(){const t=this._jsonValue.at(4);return!t.isNull()&&!t.isError()}isExistHitAreas(){const t=this._jsonValue.at(7);return!t.isNull()&&!t.isError()}isExistPhysicsFile(){const t=this._jsonValue.at(5);return!t.isNull()&&!t.isError()}isExistPoseFile(){const t=this._jsonValue.at(6);return!t.isNull()&&!t.isError()}isExistExpressionFile(){const t=this._jsonValue.at(3);return!t.isNull()&&!t.isError()}isExistMotionGroups(){const t=this._jsonValue.at(2);return!t.isNull()&&!t.isError()}isExistMotionGroupName(t){const e=this._jsonValue.at(2).getValueByString(t);return!e.isNull()&&!e.isError()}isExistMotionSoundFile(t,e){const i=this._jsonValue.at(2).getValueByString(t).getValueByIndex(e).getValueByString(this.soundPath);return!i.isNull()&&!i.isError()}isExistMotionFadeIn(t,e){const i=this._jsonValue.at(2).getValueByString(t).getValueByIndex(e).getValueByString(this.fadeInTime);return!i.isNull()&&!i.isError()}isExistMotionFadeOut(t,e){const i=this._jsonValue.at(2).getValueByString(t).getValueByIndex(e).getValueByString(this.fadeOutTime);return!i.isNull()&&!i.isError()}isExistUserDataFile(){const t=this.getJson().getRoot().getValueByString(this.fileReferences).getValueByString(this.userData);return!t.isNull()&&!t.isError()}isExistEyeBlinkParameters(){if(this._jsonValue.at(0).isNull()||this._jsonValue.at(0).isError())return!1;for(let t=0;t<this._jsonValue.at(0).getSize();++t)if(this._jsonValue.at(0).getValueByIndex(t).getValueByString(this.name).getRawString()==this.eyeBlink)return!0;return!1}isExistLipSyncParameters(){if(this._jsonValue.at(0).isNull()||this._jsonValue.at(0).isError())return!1;for(let t=0;t<this._jsonValue.at(0).getSize();++t)if(this._jsonValue.at(0).getValueByIndex(t).getValueByString(this.name).getRawString()==this.lipSync)return!0;return!1}}(t=>{t.CubismModelSettingJson=os,t.FrequestNode=ns})(as||(as={}));class ls extends wt{constructor(t){var e,i;if(super(t),u(this,"moc"),u(this,"textures"),u(this,"layout"),u(this,"hitAreas"),u(this,"expressions"),u(this,"motions"),!ls.isValidJSON(t))throw new TypeError("Invalid JSON.");const s=(new TextEncoder).encode(JSON.stringify(t)).buffer;Object.assign(this,new os(s,s.byteLength)),this.moc=t.FileReferences.Moc,this.textures=[...t.FileReferences.Textures],this.pose=t.FileReferences.Pose,this.physics=t.FileReferences.Physics,this.expressions=null==(e=t.FileReferences.Expressions)?void 0:e.filter(t=>!!t&&"string"==typeof t.File),this.motions=null!=(i=t.FileReferences.Motions)?i:t.Motions,this.layout=t.Layout,this.hitAreas=t.HitAreas;const r=this.getFileStem(this.moc);this.setModelName(r,this.name)}static isValidJSON(t){if(!t||"object"!=typeof t)return!1;const e=t.FileReferences;if(!e||"object"!=typeof e||"string"!=typeof e.Moc)return!1;const i=e.Textures;if(!Array.isArray(i)||0===i.length)return!1;if(!i.every(t=>"string"==typeof t))return!1;const s=e.Expressions;return!(void 0!==s&&(!Array.isArray(s)||s.some(t=>!(t=>!!t&&"string"==typeof t.File)(t))))}replaceFiles(t){if(super.replaceFiles(t),this.motions)for(const[e,i]of Object.entries(this.motions))for(let s=0;s<i.length;s++){const r=i[s];(null==r?void 0:r.File)&&(r.File=t(r.File,`motions.${e}[${s}].File`),r.Sound&&(r.Sound=t(r.Sound,`motions.${e}[${s}].Sound`)))}if(this.expressions)for(let e=0;e<this.expressions.length;e++){const i=this.expressions[e];(null==i?void 0:i.File)&&(i.File=t(i.File,`expressions[${e}].File`))}}getEyeBlinkParameters(){var t,e,i;const s=[],r=null!=(e=null==(t=this.getEyeBlinkParameterCount)?void 0:t.call(this))?e:0;if(r>0)for(let a=0;a<r;a++){const t=null==(i=this.getEyeBlinkParameterId)?void 0:i.call(this,a);(null==t?void 0:t.getString)&&s.push(t.getString().s)}else if(Array.isArray(this.json.Groups)){const t=this.json.Groups;for(const e of t)if("EyeBlink"===(null==e?void 0:e.Name)&&Array.isArray(e.Ids))for(const t of e.Ids)"string"==typeof t?s.push(t):(null==t?void 0:t.Id)&&s.push(t.Id)}return s}getLipSyncParameters(){var t,e,i;const s=[],r=null!=(e=null==(t=this.getLipSyncParameterCount)?void 0:t.call(this))?e:0;if(r>0)for(let a=0;a<r;a++){const t=null==(i=this.getLipSyncParameterId)?void 0:i.call(this,a);(null==t?void 0:t.getString)&&s.push(t.getString().s)}else if(Array.isArray(this.json.Groups)){const t=this.json.Groups;for(const e of t)if("LipSync"===(null==e?void 0:e.Name)&&Array.isArray(e.Ids))for(const t of e.Ids)"string"==typeof t?s.push(t):(null==t?void 0:t.Id)&&s.push(t.Id)}return s}}let us;yt(ls,[os]);let hs=20,ds=16;function gs(t={}){null!=t.memorySizeMB&&(ds=t.memorySizeMB)}function cs(){return ht.isStarted()?Promise.resolve():(null!=us||(us=new Promise((t,e)=>{!function i(){try{ms(),t()}catch(s){if(hs--,hs<0)return void e(new Error("Failed to start up Cubism framework.",{cause:s}));ct.log("Cubism","Startup failed, retrying 10ms later..."),setTimeout(i,10)}}()})),us)}function ms(t,e){const i=((t,e)=>{for(var i in e||(e={}))a.call(e,i)&&l(t,i,e[i]);if(r)for(var i of r(e))n.call(e,i)&&l(t,i,e[i]);return t})({logFunction:console.log,loggingLevel:dt.LogLevel_Verbose},t),s=null!=e?e:ds;ht.startUp(i),ht.initialize(pt(s))}const ps="FadeInTime",_s="Link";class fs{static create(t,e){const i=Y.create(t,e);if(!i)return null;const s=new fs,r=i.getRoot();r.getValueByString(ps).isNull()||(s._fadeTimeSeconds=r.getValueByString(ps).toFloat(.5),s._fadeTimeSeconds<0&&(s._fadeTimeSeconds=.5));const a=r.getValueByString("Groups"),n=a.getSize();for(let o=0;o<n;++o){const t=a.getValueByIndex(o),e=t.getSize();let i=0;for(let r=0;r<e;++r){const e=t.getValueByIndex(r),a=new ys,n=ht.getIdManager().getId(e.getValueByString("Id").getRawString());if(a.partId=n,!e.getValueByString(_s).isNull()){const t=e.getValueByString(_s),i=t.getSize();for(let e=0;e<i;++e){const i=new ys,s=ht.getIdManager().getId(t.getValueByIndex(e).getString());i.partId=s,a.link.pushBack(i)}}s._partGroups.pushBack(a.clone()),++i}s._partGroupCounts.pushBack(i)}return Y.delete(i),s}static delete(t){}updateParameters(t,e){t!=this._lastModel&&this.reset(t),this._lastModel=t,e<0&&(e=0);let i=0;for(let s=0;s<this._partGroupCounts.getSize();s++){const r=this._partGroupCounts.at(s);this.doFade(t,e,i,r),i+=r}this.copyPartOpacities(t)}reset(t){let e=0;for(let i=0;i<this._partGroupCounts.getSize();++i){const s=this._partGroupCounts.at(i);for(let i=e;i<e+s;++i){this._partGroups.at(i).initialize(t);const s=this._partGroups.at(i).partIndex,r=this._partGroups.at(i).parameterIndex;if(!(s<0)){t.setPartOpacityByIndex(s,i==e?1:0),t.setParameterValueByIndex(r,i==e?1:0);for(let e=0;e<this._partGroups.at(i).link.getSize();++e)this._partGroups.at(i).link.at(e).initialize(t)}}e+=s}}copyPartOpacities(t){for(let e=0;e<this._partGroups.getSize();++e){const i=this._partGroups.at(e);if(0==i.link.getSize())continue;const s=this._partGroups.at(e).partIndex,r=t.getPartOpacityByIndex(s);for(let e=0;e<i.link.getSize();++e){const s=i.link.at(e).partIndex;s<0||t.setPartOpacityByIndex(s,r)}}}doFade(t,e,i,s){let r=-1,a=1;const n=.5;for(let o=i;o<i+s;++o){const i=this._partGroups.at(o).partIndex,s=this._partGroups.at(o).parameterIndex;if(t.getParameterValueByIndex(s)>.001){if(r>=0)break;if(r=o,0==this._fadeTimeSeconds){a=1;continue}a=t.getPartOpacityByIndex(i),a+=e/this._fadeTimeSeconds,a>1&&(a=1)}}r<0&&(r=0,a=1);for(let o=i;o<i+s;++o){const e=this._partGroups.at(o).partIndex;if(r==o)t.setPartOpacityByIndex(e,a);else{let i,s=t.getPartOpacityByIndex(e);i=a<n?-.5*a/n+1:(1-a)*n/.5;(1-i)*(1-a)>.15&&(i=1-.15/(1-a)),s>i&&(s=i),t.setPartOpacityByIndex(e,s)}}}constructor(){this._fadeTimeSeconds=.5,this._lastModel=null,this._partGroups=new g,this._partGroupCounts=new g}}class ys{constructor(t){if(this.parameterIndex=0,this.partIndex=0,this.link=new g,null!=t){this.partId=t.partId;for(const e=t.link.begin();e.notEqual(t.link.end());e.preIncrement())this.link.pushBack(e.ptr().clone())}}assignment(t){this.partId=t.partId;for(const e=t.link.begin();e.notEqual(t.link.end());e.preIncrement())this.link.pushBack(e.ptr().clone());return this}initialize(t){this.parameterIndex=t.getParameterIndex(this.partId),this.partIndex=t.getPartIndex(this.partId),t.setParameterValueByIndex(this.parameterIndex,1)}clone(){const t=new ys;t.partId=this.partId,t.parameterIndex=this.parameterIndex,t.partIndex=this.partIndex,t.link=new g;for(let e=this.link.begin();e.notEqual(this.link.end());e.increment())t.link.pushBack(e.ptr().clone());return t}}var xs,Cs,Ss;(t=>{t.CubismPose=fs,t.PartData=ys})(xs||(xs={}));class Ms{constructor(t=!1,e=!1){this.isOverridden=t,this.isParameterRepeated=e}}class vs{constructor(t=!1,e=new I){this.isOverridden=t,this.color=e}get isOverwritten(){return this.isOverridden}}class bs{constructor(t=!1,e=new I){this.isOverridden=t,this.color=e}get isOverwritten(){return this.isOverridden}}class Ps{constructor(t=!1,e=!1){this.isOverridden=t,this.isCulling=e}get isOverwritten(){return this.isOverridden}}class Bs{update(){this._model.update(),this._model.drawables.resetDynamicFlags()}getPixelsPerUnit(){return null==this._model?0:this._model.canvasinfo.PixelsPerUnit}getCanvasWidth(){return null==this._model?0:this._model.canvasinfo.CanvasWidth/this._model.canvasinfo.PixelsPerUnit}getCanvasHeight(){return null==this._model?0:this._model.canvasinfo.CanvasHeight/this._model.canvasinfo.PixelsPerUnit}saveParameters(){const t=this._model.parameters.count,e=this._savedParameters.getSize();for(let i=0;i<t;++i)i<e?this._savedParameters.set(i,this._parameterValues[i]):this._savedParameters.pushBack(this._parameterValues[i])}getMultiplyColor(t){if(this.getOverrideFlagForModelMultiplyColors()||this.getOverrideFlagForDrawableMultiplyColors(t))return this._userMultiplyColors.at(t).color;return this.getDrawableMultiplyColor(t)}getScreenColor(t){if(this.getOverrideFlagForModelScreenColors()||this.getOverrideFlagForDrawableScreenColors(t))return this._userScreenColors.at(t).color;return this.getDrawableScreenColor(t)}setMultiplyColorByTextureColor(t,e){this.setMultiplyColorByRGBA(t,e.r,e.g,e.b,e.a)}setMultiplyColorByRGBA(t,e,i,s,r=1){this._userMultiplyColors.at(t).color.r=e,this._userMultiplyColors.at(t).color.g=i,this._userMultiplyColors.at(t).color.b=s,this._userMultiplyColors.at(t).color.a=r}setScreenColorByTextureColor(t,e){this.setScreenColorByRGBA(t,e.r,e.g,e.b,e.a)}setScreenColorByRGBA(t,e,i,s,r=1){this._userScreenColors.at(t).color.r=e,this._userScreenColors.at(t).color.g=i,this._userScreenColors.at(t).color.b=s,this._userScreenColors.at(t).color.a=r}getPartMultiplyColor(t){return this._userPartMultiplyColors.at(t).color}getPartScreenColor(t){return this._userPartScreenColors.at(t).color}setPartColor(t,e,i,s,r,a,n){if(a.at(t).color.r=e,a.at(t).color.g=i,a.at(t).color.b=s,a.at(t).color.a=r,a.at(t).isOverridden)for(let o=0;o<this._partChildDrawables.at(t).getSize();++o){const a=this._partChildDrawables.at(t).at(o);n.at(a).color.r=e,n.at(a).color.g=i,n.at(a).color.b=s,n.at(a).color.a=r}}setPartMultiplyColorByTextureColor(t,e){this.setPartMultiplyColorByRGBA(t,e.r,e.g,e.b,e.a)}setPartMultiplyColorByRGBA(t,e,i,s,r){this.setPartColor(t,e,i,s,r,this._userPartMultiplyColors,this._userMultiplyColors)}setPartScreenColorByTextureColor(t,e){this.setPartScreenColorByRGBA(t,e.r,e.g,e.b,e.a)}setPartScreenColorByRGBA(t,e,i,s,r){this.setPartColor(t,e,i,s,r,this._userPartScreenColors,this._userScreenColors)}getOverrideFlagForModelParameterRepeat(){return this._isOverriddenParameterRepeat}setOverrideFlagForModelParameterRepeat(t){this._isOverriddenParameterRepeat=t}getOverrideFlagForParameterRepeat(t){return this._userParameterRepeatDataList.at(t).isOverridden}setOverrideFlagForParameterRepeat(t,e){this._userParameterRepeatDataList.at(t).isOverridden=e}getRepeatFlagForParameterRepeat(t){return this._userParameterRepeatDataList.at(t).isParameterRepeated}setRepeatFlagForParameterRepeat(t,e){this._userParameterRepeatDataList.at(t).isParameterRepeated=e}getOverwriteFlagForModelMultiplyColors(){return D("getOverwriteFlagForModelMultiplyColors() is a deprecated function. Please use getOverrideFlagForModelMultiplyColors()."),this.getOverrideFlagForModelMultiplyColors()}getOverrideFlagForModelMultiplyColors(){return this._isOverriddenModelMultiplyColors}getOverwriteFlagForModelScreenColors(){return D("getOverwriteFlagForModelScreenColors() is a deprecated function. Please use getOverrideFlagForModelScreenColors()."),this.getOverrideFlagForModelScreenColors()}getOverrideFlagForModelScreenColors(){return this._isOverriddenModelScreenColors}setOverwriteFlagForModelMultiplyColors(t){D("setOverwriteFlagForModelMultiplyColors(value: boolean) is a deprecated function. Please use setOverrideFlagForModelMultiplyColors(value: boolean)."),this.setOverrideFlagForModelMultiplyColors(t)}setOverrideFlagForModelMultiplyColors(t){this._isOverriddenModelMultiplyColors=t}setOverwriteFlagForModelScreenColors(t){D("setOverwriteFlagForModelScreenColors(value: boolean) is a deprecated function. Please use setOverrideFlagForModelScreenColors(value: boolean)."),this.setOverrideFlagForModelScreenColors(t)}setOverrideFlagForModelScreenColors(t){this._isOverriddenModelScreenColors=t}getOverwriteFlagForDrawableMultiplyColors(t){return D("getOverwriteFlagForDrawableMultiplyColors(drawableindex: number) is a deprecated function. Please use getOverrideFlagForDrawableMultiplyColors(drawableindex: number)."),this.getOverrideFlagForDrawableMultiplyColors(t)}getOverrideFlagForDrawableMultiplyColors(t){return this._userMultiplyColors.at(t).isOverridden}getOverwriteFlagForDrawableScreenColors(t){return D("getOverwriteFlagForDrawableScreenColors(drawableindex: number) is a deprecated function. Please use getOverrideFlagForDrawableScreenColors(drawableindex: number)."),this.getOverrideFlagForDrawableScreenColors(t)}getOverrideFlagForDrawableScreenColors(t){return this._userScreenColors.at(t).isOverridden}setOverwriteFlagForDrawableMultiplyColors(t,e){D("setOverwriteFlagForDrawableMultiplyColors(drawableindex: number, value: boolean) is a deprecated function. Please use setOverrideFlagForDrawableMultiplyColors(drawableindex: number, value: boolean)."),this.setOverrideFlagForDrawableMultiplyColors(t,e)}setOverrideFlagForDrawableMultiplyColors(t,e){this._userMultiplyColors.at(t).isOverridden=e}setOverwriteFlagForDrawableScreenColors(t,e){D("setOverwriteFlagForDrawableScreenColors(drawableindex: number, value: boolean) is a deprecated function. Please use setOverrideFlagForDrawableScreenColors(drawableindex: number, value: boolean)."),this.setOverrideFlagForDrawableScreenColors(t,e)}setOverrideFlagForDrawableScreenColors(t,e){this._userScreenColors.at(t).isOverridden=e}getOverwriteColorForPartMultiplyColors(t){return D("getOverwriteColorForPartMultiplyColors(partIndex: number) is a deprecated function. Please use getOverrideColorForPartMultiplyColors(partIndex: number)."),this.getOverrideColorForPartMultiplyColors(t)}getOverrideColorForPartMultiplyColors(t){return this._userPartMultiplyColors.at(t).isOverridden}getOverwriteColorForPartScreenColors(t){return D("getOverwriteColorForPartScreenColors(partIndex: number) is a deprecated function. Please use getOverrideColorForPartScreenColors(partIndex: number)."),this.getOverrideColorForPartScreenColors(t)}getOverrideColorForPartScreenColors(t){return this._userPartScreenColors.at(t).isOverridden}setOverwriteColorForPartColors(t,e,i,s){D("setOverwriteColorForPartColors(partIndex: number, value: boolean, partColors: csmVector<PartColorData>, drawableColors: csmVector<DrawableColorData>) is a deprecated function. Please use setOverrideColorForPartColors(partIndex: number, value: boolean, partColors: csmVector<PartColorData>, drawableColors: csmVector<DrawableColorData>)."),this.setOverrideColorForPartColors(t,e,i,s)}setOverrideColorForPartColors(t,e,i,s){i.at(t).isOverridden=e;for(let r=0;r<this._partChildDrawables.at(t).getSize();++r){const a=this._partChildDrawables.at(t).at(r);s.at(a).isOverridden=e,e&&(s.at(a).color.r=i.at(t).color.r,s.at(a).color.g=i.at(t).color.g,s.at(a).color.b=i.at(t).color.b,s.at(a).color.a=i.at(t).color.a)}}setOverwriteColorForPartMultiplyColors(t,e){D("setOverwriteColorForPartMultiplyColors(partIndex: number, value: boolean) is a deprecated function. Please use setOverrideColorForPartMultiplyColors(partIndex: number, value: boolean)."),this.setOverrideColorForPartMultiplyColors(t,e)}setOverrideColorForPartMultiplyColors(t,e){this._userPartMultiplyColors.at(t).isOverridden=e,this.setOverrideColorForPartColors(t,e,this._userPartMultiplyColors,this._userMultiplyColors)}setOverwriteColorForPartScreenColors(t,e){D("setOverwriteColorForPartScreenColors(partIndex: number, value: boolean) is a deprecated function. Please use setOverrideColorForPartScreenColors(partIndex: number, value: boolean)."),this.setOverrideColorForPartScreenColors(t,e)}setOverrideColorForPartScreenColors(t,e){this._userPartScreenColors.at(t).isOverridden=e,this.setOverrideColorForPartColors(t,e,this._userPartScreenColors,this._userScreenColors)}getDrawableCulling(t){if(this.getOverrideFlagForModelCullings()||this.getOverrideFlagForDrawableCullings(t))return this._userCullings.at(t).isCulling;const e=this._model.drawables.constantFlags;return!Live2DCubismCore.Utils.hasIsDoubleSidedBit(e[t])}setDrawableCulling(t,e){this._userCullings.at(t).isCulling=e}getOverwriteFlagForModelCullings(){return D("getOverwriteFlagForModelCullings() is a deprecated function. Please use getOverrideFlagForModelCullings()."),this.getOverrideFlagForModelCullings()}getOverrideFlagForModelCullings(){return this._isOverriddenCullings}setOverwriteFlagForModelCullings(t){D("setOverwriteFlagForModelCullings(isOverriddenCullings: boolean) is a deprecated function. Please use setOverrideFlagForModelCullings(isOverriddenCullings: boolean)."),this.setOverrideFlagForModelCullings(t)}setOverrideFlagForModelCullings(t){this._isOverriddenCullings=t}getOverwriteFlagForDrawableCullings(t){return D("getOverwriteFlagForDrawableCullings(drawableIndex: number) is a deprecated function. Please use getOverrideFlagForDrawableCullings(drawableIndex: number)."),this.getOverrideFlagForDrawableCullings(t)}getOverrideFlagForDrawableCullings(t){return this._userCullings.at(t).isOverridden}setOverwriteFlagForDrawableCullings(t,e){D("setOverwriteFlagForDrawableCullings(drawableIndex: number, isOverriddenCullings: boolean) is a deprecated function. Please use setOverrideFlagForDrawableCullings(drawableIndex: number, isOverriddenCullings: boolean)."),this.setOverrideFlagForDrawableCullings(t,e)}setOverrideFlagForDrawableCullings(t,e){this._userCullings.at(t).isOverridden=e}getModelOapcity(){return this._modelOpacity}setModelOapcity(t){this._modelOpacity=t}getModel(){return this._model}getPartIndex(t){let e;const i=this._model.parts.count;for(e=0;e<i;++e)if(t==this._partIds.at(e))return e;return this._notExistPartId.isExist(t)?this._notExistPartId.getValue(t):(e=i+this._notExistPartId.getSize(),this._notExistPartId.setValue(t,e),this._notExistPartOpacities.appendKey(e),e)}getPartId(t){const e=this._model.parts.ids[t];return ht.getIdManager().getId(e)}getPartCount(){return this._model.parts.count}getPartParentPartIndices(){return this._model.parts.parentIndices}setPartOpacityByIndex(t,e){this._notExistPartOpacities.isExist(t)?this._notExistPartOpacities.setValue(t,e):(L(0<=t&&t<this.getPartCount()),this._partOpacities[t]=e)}setPartOpacityById(t,e){const i=this.getPartIndex(t);i<0||this.setPartOpacityByIndex(i,e)}getPartOpacityByIndex(t){return this._notExistPartOpacities.isExist(t)?this._notExistPartOpacities.getValue(t):(L(0<=t&&t<this.getPartCount()),this._partOpacities[t])}getPartOpacityById(t){const e=this.getPartIndex(t);return e<0?0:this.getPartOpacityByIndex(e)}getParameterIndex(t){let e;const i=this._model.parameters.count;for(e=0;e<i;++e)if(t==this._parameterIds.at(e))return e;return this._notExistParameterId.isExist(t)?this._notExistParameterId.getValue(t):(e=this._model.parameters.count+this._notExistParameterId.getSize(),this._notExistParameterId.setValue(t,e),this._notExistParameterValues.appendKey(e),e)}getParameterCount(){return this._model.parameters.count}getParameterType(t){return this._model.parameters.types[t]}getParameterMaximumValue(t){return this._model.parameters.maximumValues[t]}getParameterMinimumValue(t){return this._model.parameters.minimumValues[t]}getParameterDefaultValue(t){return this._model.parameters.defaultValues[t]}getParameterId(t){return ht.getIdManager().getId(this._model.parameters.ids[t])}getParameterValueByIndex(t){return this._notExistParameterValues.isExist(t)?this._notExistParameterValues.getValue(t):(L(0<=t&&t<this.getParameterCount()),this._parameterValues[t])}getParameterValueById(t){const e=this.getParameterIndex(t);return this.getParameterValueByIndex(e)}setParameterValueByIndex(t,e,i=1){this._notExistParameterValues.isExist(t)?this._notExistParameterValues.setValue(t,1==i?e:this._notExistParameterValues.getValue(t)*(1-i)+e*i):(L(0<=t&&t<this.getParameterCount()),e=this.isRepeat(t)?this.getParameterRepeatValue(t,e):this.getParameterClampValue(t,e),this._parameterValues[t]=1==i?e:this._parameterValues[t]=this._parameterValues[t]*(1-i)+e*i)}setParameterValueById(t,e,i=1){const s=this.getParameterIndex(t);this.setParameterValueByIndex(s,e,i)}addParameterValueByIndex(t,e,i=1){this.setParameterValueByIndex(t,this.getParameterValueByIndex(t)+e*i)}addParameterValueById(t,e,i=1){const s=this.getParameterIndex(t);this.addParameterValueByIndex(s,e,i)}isRepeat(t){if(this._notExistParameterValues.isExist(t))return!1;let e;return L(0<=t&&t<this.getParameterCount()),e=this._isOverriddenParameterRepeat||this._userParameterRepeatDataList.at(t).isOverridden?this._userParameterRepeatDataList.at(t).isParameterRepeated:0!=this._model.parameters.repeats[t],e}getParameterRepeatValue(t,e){if(this._notExistParameterValues.isExist(t))return e;L(0<=t&&t<this.getParameterCount());const i=this._model.parameters.maximumValues[t],s=this._model.parameters.minimumValues[t],r=i-s;if(i<e){const t=Ce.mod(e-i,r);e=Number.isNaN(t)?i:s+t}if(e<s){const t=Ce.mod(s-e,r);e=Number.isNaN(t)?s:i-t}return e}getParameterClampValue(t,e){if(this._notExistParameterValues.isExist(t))return e;L(0<=t&&t<this.getParameterCount());const i=this._model.parameters.maximumValues[t],s=this._model.parameters.minimumValues[t];return Ce.clamp(e,s,i)}getParameterRepeats(t){return 0!=this._model.parameters.repeats[t]}multiplyParameterValueById(t,e,i=1){const s=this.getParameterIndex(t);this.multiplyParameterValueByIndex(s,e,i)}multiplyParameterValueByIndex(t,e,i=1){this.setParameterValueByIndex(t,this.getParameterValueByIndex(t)*(1+(e-1)*i))}getDrawableIndex(t){const e=this._model.drawables.count;for(let i=0;i<e;++i)if(this._drawableIds.at(i)==t)return i;return-1}getDrawableCount(){return this._model.drawables.count}getDrawableId(t){const e=this._model.drawables.ids;return ht.getIdManager().getId(e[t])}getDrawableRenderOrders(){return this._model.drawables.renderOrders}getDrawableTextureIndices(t){return this.getDrawableTextureIndex(t)}getDrawableTextureIndex(t){return this._model.drawables.textureIndices[t]}getDrawableDynamicFlagVertexPositionsDidChange(t){const e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasVertexPositionsDidChangeBit(e[t])}getDrawableVertexIndexCount(t){return this._model.drawables.indexCounts[t]}getDrawableVertexCount(t){return this._model.drawables.vertexCounts[t]}getDrawableVertices(t){return this.getDrawableVertexPositions(t)}getDrawableVertexIndices(t){return this._model.drawables.indices[t]}getDrawableVertexPositions(t){return this._model.drawables.vertexPositions[t]}getDrawableVertexUvs(t){return this._model.drawables.vertexUvs[t]}getDrawableOpacity(t){return this._model.drawables.opacities[t]}getDrawableMultiplyColor(t){const e=this._model.drawables.multiplyColors,i=4*t,s=new I;return s.r=e[i],s.g=e[i+1],s.b=e[i+2],s.a=e[i+3],s}getDrawableScreenColor(t){const e=this._model.drawables.screenColors,i=4*t,s=new I;return s.r=e[i],s.g=e[i+1],s.b=e[i+2],s.a=e[i+3],s}getDrawableParentPartIndex(t){return this._model.drawables.parentPartIndices[t]}getDrawableBlendMode(t){const e=this._model.drawables.constantFlags;return Live2DCubismCore.Utils.hasBlendAdditiveBit(e[t])?F.CubismBlendMode_Additive:Live2DCubismCore.Utils.hasBlendMultiplicativeBit(e[t])?F.CubismBlendMode_Multiplicative:F.CubismBlendMode_Normal}getDrawableInvertedMaskBit(t){const e=this._model.drawables.constantFlags;return Live2DCubismCore.Utils.hasIsInvertedMaskBit(e[t])}getDrawableMasks(){return this._model.drawables.masks}getDrawableMaskCounts(){return this._model.drawables.maskCounts}isUsingMasking(){for(let t=0;t<this._model.drawables.count;++t)if(!(this._model.drawables.maskCounts[t]<=0))return!0;return!1}getDrawableDynamicFlagIsVisible(t){const e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasIsVisibleBit(e[t])}getDrawableDynamicFlagVisibilityDidChange(t){const e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasVisibilityDidChangeBit(e[t])}getDrawableDynamicFlagOpacityDidChange(t){const e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasOpacityDidChangeBit(e[t])}getDrawableDynamicFlagRenderOrderDidChange(t){const e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasRenderOrderDidChangeBit(e[t])}getDrawableDynamicFlagBlendColorDidChange(t){const e=this._model.drawables.dynamicFlags;return Live2DCubismCore.Utils.hasBlendColorDidChangeBit(e[t])}loadParameters(){let t=this._model.parameters.count;const e=this._savedParameters.getSize();t>e&&(t=e);for(let i=0;i<t;++i)this._parameterValues[i]=this._savedParameters.at(i)}initialize(){L(this._model),this._parameterValues=this._model.parameters.values,this._partOpacities=this._model.parts.opacities,this._parameterMaximumValues=this._model.parameters.maximumValues,this._parameterMinimumValues=this._model.parameters.minimumValues;{const t=this._model.parameters.ids,e=this._model.parameters.count;this._parameterIds.prepareCapacity(e),this._userParameterRepeatDataList.prepareCapacity(e);for(let i=0;i<e;++i)this._parameterIds.pushBack(ht.getIdManager().getId(t[i])),this._userParameterRepeatDataList.pushBack(new Ms(!1,!1))}const t=this._model.parts.count;{const e=this._model.parts.ids;this._partIds.prepareCapacity(t);for(let i=0;i<t;++i)this._partIds.pushBack(ht.getIdManager().getId(e[i]));this._userPartMultiplyColors.prepareCapacity(t),this._userPartScreenColors.prepareCapacity(t),this._partChildDrawables.prepareCapacity(t)}{const e=this._model.drawables.ids,i=this._model.drawables.count;this._userMultiplyColors.prepareCapacity(i),this._userScreenColors.prepareCapacity(i),this._userCullings.prepareCapacity(i);const s=new Ps(!1,!1);for(let r=0;r<t;++r){const t=new I(1,1,1,1),e=new I(0,0,0,1),s=new bs(!1,t),a=new bs(!1,e);this._userPartMultiplyColors.pushBack(s),this._userPartScreenColors.pushBack(a),this._partChildDrawables.pushBack(new g),this._partChildDrawables.at(r).prepareCapacity(i)}for(let t=0;t<i;++t){const i=new I(1,1,1,1),r=new I(0,0,0,1),a=new vs(!1,i),n=new vs(!1,r);this._drawableIds.pushBack(ht.getIdManager().getId(e[t])),this._userMultiplyColors.pushBack(a),this._userScreenColors.pushBack(n),this._userCullings.pushBack(s);const o=this.getDrawableParentPartIndex(t);o>=0&&this._partChildDrawables.at(o).pushBack(t)}}}constructor(t){this._model=t,this._parameterValues=null,this._parameterMaximumValues=null,this._parameterMinimumValues=null,this._partOpacities=null,this._savedParameters=new g,this._parameterIds=new g,this._drawableIds=new g,this._partIds=new g,this._isOverriddenParameterRepeat=!0,this._isOverriddenModelMultiplyColors=!1,this._isOverriddenModelScreenColors=!1,this._isOverriddenCullings=!1,this._modelOpacity=1,this._userParameterRepeatDataList=new g,this._userMultiplyColors=new g,this._userScreenColors=new g,this._userCullings=new g,this._userPartMultiplyColors=new g,this._userPartScreenColors=new g,this._partChildDrawables=new g,this._notExistPartId=new j,this._notExistParameterId=new j,this._notExistParameterValues=new j,this._notExistPartOpacities=new j}release(){this._model.release(),this._model=null}}(t=>{t.CubismModel=Bs})(Cs||(Cs={}));class ws{static create(t,e){let i=null;if(e){if(!this.hasMocConsistency(t))return O("Inconsistent MOC3."),i}const s=Live2DCubismCore.Moc.fromArrayBuffer(t);return s&&(i=new ws(s),i._mocVersion=Live2DCubismCore.Version.csmGetMocVersion(s,t)),i}static delete(t){t._moc._release(),t._moc=null,t=null}createModel(){let t=null;const e=Live2DCubismCore.Model.fromMoc(this._moc);return e&&(t=new Bs(e),t.initialize(),++this._modelCount),t}deleteModel(t){null!=t&&(t.release(),t=null,--this._modelCount)}constructor(t){this._moc=t,this._modelCount=0,this._mocVersion=0}release(){L(0==this._modelCount),this._moc._release(),this._moc=null}getLatestMocVersion(){return Live2DCubismCore.Version.csmGetLatestMocVersion()}getMocVersion(){return this._mocVersion}static hasMocConsistency(t){return 1===Live2DCubismCore.Moc.prototype.hasMocConsistency(t)}}(t=>{t.CubismMoc=ws})(Ss||(Ss={}));var Fs,Is=(t=>(t[t.CubismPhysicsTargetType_Parameter=0]="CubismPhysicsTargetType_Parameter",t))(Is||{}),Es=(t=>(t[t.CubismPhysicsSource_X=0]="CubismPhysicsSource_X",t[t.CubismPhysicsSource_Y=1]="CubismPhysicsSource_Y",t[t.CubismPhysicsSource_Angle=2]="CubismPhysicsSource_Angle",t))(Es||{});class Vs{constructor(){this.gravity=new fe(0,0),this.wind=new fe(0,0)}}class Rs{}class Ls{}class Ts{constructor(){this.initialPosition=new fe(0,0),this.position=new fe(0,0),this.lastPosition=new fe(0,0),this.lastGravity=new fe(0,0),this.force=new fe(0,0),this.velocity=new fe(0,0)}}class As{constructor(){this.normalizationPosition=new Ls,this.normalizationAngle=new Ls}}class Ds{constructor(){this.source=new Rs}}class Os{constructor(){this.destination=new Rs,this.translationScale=new fe(0,0)}}class ks{constructor(){this.settings=new g,this.inputs=new g,this.outputs=new g,this.particles=new g,this.gravity=new fe(0,0),this.wind=new fe(0,0),this.fps=0}}(t=>{t.CubismPhysicsInput=Ds,t.CubismPhysicsNormalization=Ls,t.CubismPhysicsOutput=Os,t.CubismPhysicsParameter=Rs,t.CubismPhysicsParticle=Ts,t.CubismPhysicsRig=ks,t.CubismPhysicsSource=Es,t.CubismPhysicsSubRig=As,t.CubismPhysicsTargetType=Is,t.PhysicsJsonEffectiveForces=Vs})(Fs||(Fs={}));const Ns="Position",Us="Angle",zs="Type",js="Meta",Gs="EffectiveForces",Xs="Gravity",Hs="Wind",qs="PhysicsSettings",Ws="Normalization",Ys="Minimum",Js="Maximum",$s="Default",Zs="Reflect",Ks="Weight",Qs="Input",tr="Output",er="Vertices";class ir{constructor(t,e){this._json=Y.create(t,e)}release(){Y.delete(this._json)}getGravity(){const t=new fe(0,0);return t.x=this._json.getRoot().getValueByString(js).getValueByString(Gs).getValueByString(Xs).getValueByString("X").toFloat(),t.y=this._json.getRoot().getValueByString(js).getValueByString(Gs).getValueByString(Xs).getValueByString("Y").toFloat(),t}getWind(){const t=new fe(0,0);return t.x=this._json.getRoot().getValueByString(js).getValueByString(Gs).getValueByString(Hs).getValueByString("X").toFloat(),t.y=this._json.getRoot().getValueByString(js).getValueByString(Gs).getValueByString(Hs).getValueByString("Y").toFloat(),t}getFps(){return this._json.getRoot().getValueByString(js).getValueByString("Fps").toFloat(0)}getSubRigCount(){return this._json.getRoot().getValueByString(js).getValueByString("PhysicsSettingCount").toInt()}getTotalInputCount(){return this._json.getRoot().getValueByString(js).getValueByString("TotalInputCount").toInt()}getTotalOutputCount(){return this._json.getRoot().getValueByString(js).getValueByString("TotalOutputCount").toInt()}getVertexCount(){return this._json.getRoot().getValueByString(js).getValueByString("VertexCount").toInt()}getNormalizationPositionMinimumValue(t){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(Ws).getValueByString(Ns).getValueByString(Ys).toFloat()}getNormalizationPositionMaximumValue(t){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(Ws).getValueByString(Ns).getValueByString(Js).toFloat()}getNormalizationPositionDefaultValue(t){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(Ws).getValueByString(Ns).getValueByString($s).toFloat()}getNormalizationAngleMinimumValue(t){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(Ws).getValueByString(Us).getValueByString(Ys).toFloat()}getNormalizationAngleMaximumValue(t){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(Ws).getValueByString(Us).getValueByString(Js).toFloat()}getNormalizationAngleDefaultValue(t){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(Ws).getValueByString(Us).getValueByString($s).toFloat()}getInputCount(t){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(Qs).getVector().getSize()}getInputWeight(t,e){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(Qs).getValueByIndex(e).getValueByString(Ks).toFloat()}getInputReflect(t,e){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(Qs).getValueByIndex(e).getValueByString(Zs).toBoolean()}getInputType(t,e){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(Qs).getValueByIndex(e).getValueByString(zs).getRawString()}getInputSourceId(t,e){return ht.getIdManager().getId(this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(Qs).getValueByIndex(e).getValueByString("Source").getValueByString("Id").getRawString())}getOutputCount(t){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(tr).getVector().getSize()}getOutputVertexIndex(t,e){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(tr).getValueByIndex(e).getValueByString("VertexIndex").toInt()}getOutputAngleScale(t,e){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(tr).getValueByIndex(e).getValueByString("Scale").toFloat()}getOutputWeight(t,e){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(tr).getValueByIndex(e).getValueByString(Ks).toFloat()}getOutputDestinationId(t,e){return ht.getIdManager().getId(this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(tr).getValueByIndex(e).getValueByString("Destination").getValueByString("Id").getRawString())}getOutputType(t,e){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(tr).getValueByIndex(e).getValueByString(zs).getRawString()}getOutputReflect(t,e){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(tr).getValueByIndex(e).getValueByString(Zs).toBoolean()}getParticleCount(t){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(er).getVector().getSize()}getParticleMobility(t,e){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(er).getValueByIndex(e).getValueByString("Mobility").toFloat()}getParticleDelay(t,e){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(er).getValueByIndex(e).getValueByString("Delay").toFloat()}getParticleAcceleration(t,e){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(er).getValueByIndex(e).getValueByString("Acceleration").toFloat()}getParticleRadius(t,e){return this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(er).getValueByIndex(e).getValueByString("Radius").toFloat()}getParticlePosition(t,e){const i=new fe(0,0);return i.x=this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(er).getValueByIndex(e).getValueByString(Ns).getValueByString("X").toFloat(),i.y=this._json.getRoot().getValueByString(qs).getValueByIndex(t).getValueByString(er).getValueByIndex(e).getValueByString(Ns).getValueByString("Y").toFloat(),i}}var sr;(t=>{t.CubismPhysicsJson=ir})(sr||(sr={}));const rr="Angle";class ar{static create(t,e){const i=new ar;return i.parse(t,e),i._physicsRig.gravity.y=0,i}static delete(t){null!=t&&(t.release(),t=null)}parse(t,e){this._physicsRig=new ks;let i=new ir(t,e);this._physicsRig.gravity=i.getGravity(),this._physicsRig.wind=i.getWind(),this._physicsRig.subRigCount=i.getSubRigCount(),this._physicsRig.fps=i.getFps(),this._physicsRig.settings.updateSize(this._physicsRig.subRigCount,As,!0),this._physicsRig.inputs.updateSize(i.getTotalInputCount(),Ds,!0),this._physicsRig.outputs.updateSize(i.getTotalOutputCount(),Os,!0),this._physicsRig.particles.updateSize(i.getVertexCount(),Ts,!0),this._currentRigOutputs.clear(),this._previousRigOutputs.clear();let s=0,r=0,a=0;for(let n=0;n<this._physicsRig.settings.getSize();++n){this._physicsRig.settings.at(n).normalizationPosition.minimum=i.getNormalizationPositionMinimumValue(n),this._physicsRig.settings.at(n).normalizationPosition.maximum=i.getNormalizationPositionMaximumValue(n),this._physicsRig.settings.at(n).normalizationPosition.defalut=i.getNormalizationPositionDefaultValue(n),this._physicsRig.settings.at(n).normalizationAngle.minimum=i.getNormalizationAngleMinimumValue(n),this._physicsRig.settings.at(n).normalizationAngle.maximum=i.getNormalizationAngleMaximumValue(n),this._physicsRig.settings.at(n).normalizationAngle.defalut=i.getNormalizationAngleDefaultValue(n),this._physicsRig.settings.at(n).inputCount=i.getInputCount(n),this._physicsRig.settings.at(n).baseInputIndex=s;for(let r=0;r<this._physicsRig.settings.at(n).inputCount;++r)this._physicsRig.inputs.at(s+r).sourceParameterIndex=-1,this._physicsRig.inputs.at(s+r).weight=i.getInputWeight(n,r),this._physicsRig.inputs.at(s+r).reflect=i.getInputReflect(n,r),"X"==i.getInputType(n,r)?(this._physicsRig.inputs.at(s+r).type=Es.CubismPhysicsSource_X,this._physicsRig.inputs.at(s+r).getNormalizedParameterValue=lr):"Y"==i.getInputType(n,r)?(this._physicsRig.inputs.at(s+r).type=Es.CubismPhysicsSource_Y,this._physicsRig.inputs.at(s+r).getNormalizedParameterValue=ur):i.getInputType(n,r)==rr&&(this._physicsRig.inputs.at(s+r).type=Es.CubismPhysicsSource_Angle,this._physicsRig.inputs.at(s+r).getNormalizedParameterValue=hr),this._physicsRig.inputs.at(s+r).source.targetType=Is.CubismPhysicsTargetType_Parameter,this._physicsRig.inputs.at(s+r).source.id=i.getInputSourceId(n,r);s+=this._physicsRig.settings.at(n).inputCount,this._physicsRig.settings.at(n).outputCount=i.getOutputCount(n),this._physicsRig.settings.at(n).baseOutputIndex=r;const t=new or;t.outputs.resize(this._physicsRig.settings.at(n).outputCount);const e=new or;e.outputs.resize(this._physicsRig.settings.at(n).outputCount);for(let s=0;s<this._physicsRig.settings.at(n).outputCount;++s)t.outputs.set(s,0),e.outputs.set(s,0),this._physicsRig.outputs.at(r+s).destinationParameterIndex=-1,this._physicsRig.outputs.at(r+s).vertexIndex=i.getOutputVertexIndex(n,s),this._physicsRig.outputs.at(r+s).angleScale=i.getOutputAngleScale(n,s),this._physicsRig.outputs.at(r+s).weight=i.getOutputWeight(n,s),this._physicsRig.outputs.at(r+s).destination.targetType=Is.CubismPhysicsTargetType_Parameter,this._physicsRig.outputs.at(r+s).destination.id=i.getOutputDestinationId(n,s),"X"==i.getOutputType(n,s)?(this._physicsRig.outputs.at(r+s).type=Es.CubismPhysicsSource_X,this._physicsRig.outputs.at(r+s).getValue=dr,this._physicsRig.outputs.at(r+s).getScale=pr):"Y"==i.getOutputType(n,s)?(this._physicsRig.outputs.at(r+s).type=Es.CubismPhysicsSource_Y,this._physicsRig.outputs.at(r+s).getValue=gr,this._physicsRig.outputs.at(r+s).getScale=_r):i.getOutputType(n,s)==rr&&(this._physicsRig.outputs.at(r+s).type=Es.CubismPhysicsSource_Angle,this._physicsRig.outputs.at(r+s).getValue=cr,this._physicsRig.outputs.at(r+s).getScale=fr),this._physicsRig.outputs.at(r+s).reflect=i.getOutputReflect(n,s);this._currentRigOutputs.pushBack(t),this._previousRigOutputs.pushBack(e),r+=this._physicsRig.settings.at(n).outputCount,this._physicsRig.settings.at(n).particleCount=i.getParticleCount(n),this._physicsRig.settings.at(n).baseParticleIndex=a;for(let s=0;s<this._physicsRig.settings.at(n).particleCount;++s)this._physicsRig.particles.at(a+s).mobility=i.getParticleMobility(n,s),this._physicsRig.particles.at(a+s).delay=i.getParticleDelay(n,s),this._physicsRig.particles.at(a+s).acceleration=i.getParticleAcceleration(n,s),this._physicsRig.particles.at(a+s).radius=i.getParticleRadius(n,s),this._physicsRig.particles.at(a+s).position=i.getParticlePosition(n,s);a+=this._physicsRig.settings.at(n).particleCount}this.initialize(),i.release(),i=void 0,i=null}stabilization(t){var e,i,s,r;let a,n,o,l;const u=new fe;let h,d,g,c;const m=t.getModel().parameters.values,p=t.getModel().parameters.maximumValues,_=t.getModel().parameters.minimumValues,f=t.getModel().parameters.defaultValues;(null!=(i=null==(e=this._parameterCaches)?void 0:e.length)?i:0)<t.getParameterCount()&&(this._parameterCaches=new Float32Array(t.getParameterCount())),(null!=(r=null==(s=this._parameterInputCaches)?void 0:s.length)?r:0)<t.getParameterCount()&&(this._parameterInputCaches=new Float32Array(t.getParameterCount()));for(let y=0;y<t.getParameterCount();++y)this._parameterCaches[y]=m[y],this._parameterInputCaches[y]=m[y];for(let y=0;y<this._physicsRig.subRigCount;++y){a={angle:0},u.x=0,u.y=0,h=this._physicsRig.settings.at(y),d=this._physicsRig.inputs.get(h.baseInputIndex),g=this._physicsRig.outputs.get(h.baseOutputIndex),c=this._physicsRig.particles.get(h.baseParticleIndex);for(let e=0;e<h.inputCount;++e)n=d[e].weight/100,-1==d[e].sourceParameterIndex&&(d[e].sourceParameterIndex=t.getParameterIndex(d[e].source.id)),d[e].getNormalizedParameterValue(u,a,m[d[e].sourceParameterIndex],_[d[e].sourceParameterIndex],p[d[e].sourceParameterIndex],f[d[e].sourceParameterIndex],h.normalizationPosition,h.normalizationAngle,d[e].reflect,n),this._parameterCaches[d[e].sourceParameterIndex]=m[d[e].sourceParameterIndex];o=Ce.degreesToRadian(-a.angle),u.x=u.x*Ce.cos(o)-u.y*Ce.sin(o),u.y=u.x*Ce.sin(o)+u.y*Ce.cos(o),xr(c,h.particleCount,u,a.angle,this._options.wind,.001*h.normalizationPosition.maximum);for(let e=0;e<h.outputCount;++e){const i=g[e].vertexIndex;if(-1==g[e].destinationParameterIndex&&(g[e].destinationParameterIndex=t.getParameterIndex(g[e].destination.id)),i<1||i>=h.particleCount)continue;let s=new fe;s=c[i].position.substract(c[i-1].position),l=g[e].getValue(s,c,i,g[e].reflect,this._options.gravity),this._currentRigOutputs.at(y).outputs.set(e,l),this._previousRigOutputs.at(y).outputs.set(e,l);const r=g[e].destinationParameterIndex,a=!Float32Array.prototype.slice&&"subarray"in Float32Array.prototype?JSON.parse(JSON.stringify(m.subarray(r))):m.slice(r);Cr(a,_[r],p[r],l,g[e]);for(let t=r,e=0;t<this._parameterCaches.length;t++,e++)m[t]=this._parameterCaches[t]=a[e]}}}evaluate(t,e){var i,s,r,a;let n,o,l,u;const h=new fe;let d,g,c,m;if(0>=e)return;const p=t.getModel().parameters.values,_=t.getModel().parameters.maximumValues,f=t.getModel().parameters.minimumValues,y=t.getModel().parameters.defaultValues;let x;if(this._currentRemainTime+=e,this._currentRemainTime>5&&(this._currentRemainTime=0),(null!=(s=null==(i=this._parameterCaches)?void 0:i.length)?s:0)<t.getParameterCount()&&(this._parameterCaches=new Float32Array(t.getParameterCount())),(null!=(a=null==(r=this._parameterInputCaches)?void 0:r.length)?a:0)<t.getParameterCount()){this._parameterInputCaches=new Float32Array(t.getParameterCount());for(let e=0;e<t.getParameterCount();++e)this._parameterInputCaches[e]=p[e]}for(x=this._physicsRig.fps>0?1/this._physicsRig.fps:e;this._currentRemainTime>=x;){for(let t=0;t<this._physicsRig.subRigCount;++t){d=this._physicsRig.settings.at(t),c=this._physicsRig.outputs.get(d.baseOutputIndex);for(let e=0;e<d.outputCount;++e)this._previousRigOutputs.at(t).outputs.set(e,this._currentRigOutputs.at(t).outputs.at(e))}const e=x/this._currentRemainTime;for(let i=0;i<t.getParameterCount();++i)this._parameterCaches[i]=this._parameterInputCaches[i]*(1-e)+p[i]*e,this._parameterInputCaches[i]=this._parameterCaches[i];for(let i=0;i<this._physicsRig.subRigCount;++i){n={angle:0},h.x=0,h.y=0,d=this._physicsRig.settings.at(i),g=this._physicsRig.inputs.get(d.baseInputIndex),c=this._physicsRig.outputs.get(d.baseOutputIndex),m=this._physicsRig.particles.get(d.baseParticleIndex);for(let e=0;e<d.inputCount;++e)o=g[e].weight/100,-1==g[e].sourceParameterIndex&&(g[e].sourceParameterIndex=t.getParameterIndex(g[e].source.id)),g[e].getNormalizedParameterValue(h,n,this._parameterCaches[g[e].sourceParameterIndex],f[g[e].sourceParameterIndex],_[g[e].sourceParameterIndex],y[g[e].sourceParameterIndex],d.normalizationPosition,d.normalizationAngle,g[e].reflect,o);l=Ce.degreesToRadian(-n.angle),h.x=h.x*Ce.cos(l)-h.y*Ce.sin(l),h.y=h.x*Ce.sin(l)+h.y*Ce.cos(l),yr(m,d.particleCount,h,n.angle,this._options.wind,.001*d.normalizationPosition.maximum,x,5);for(let e=0;e<d.outputCount;++e){const s=c[e].vertexIndex;if(-1==c[e].destinationParameterIndex&&(c[e].destinationParameterIndex=t.getParameterIndex(c[e].destination.id)),s<1||s>=d.particleCount)continue;const r=new fe;r.x=m[s].position.x-m[s-1].position.x,r.y=m[s].position.y-m[s-1].position.y,u=c[e].getValue(r,m,s,c[e].reflect,this._options.gravity),this._currentRigOutputs.at(i).outputs.set(e,u);const a=c[e].destinationParameterIndex,n=!Float32Array.prototype.slice&&"subarray"in Float32Array.prototype?JSON.parse(JSON.stringify(this._parameterCaches.subarray(a))):this._parameterCaches.slice(a);Cr(n,f[a],_[a],u,c[e]);for(let t=a,e=0;t<this._parameterCaches.length;t++,e++)this._parameterCaches[t]=n[e]}}this._currentRemainTime-=x}const C=this._currentRemainTime/x;this.interpolate(t,C)}interpolate(t,e){let i,s;const r=t.getModel().parameters.values,a=t.getModel().parameters.maximumValues,n=t.getModel().parameters.minimumValues;for(let o=0;o<this._physicsRig.subRigCount;++o){s=this._physicsRig.settings.at(o),i=this._physicsRig.outputs.get(s.baseOutputIndex);for(let t=0;t<s.outputCount;++t){if(-1==i[t].destinationParameterIndex)continue;const s=i[t].destinationParameterIndex,l=!Float32Array.prototype.slice&&"subarray"in Float32Array.prototype?JSON.parse(JSON.stringify(r.subarray(s))):r.slice(s);Cr(l,n[s],a[s],this._previousRigOutputs.at(o).outputs.at(t)*(1-e)+this._currentRigOutputs.at(o).outputs.at(t)*e,i[t]);for(let t=s,e=0;t<r.length;t++,e++)r[t]=l[e]}}}setOptions(t){this._options=t}getOption(){return this._options}constructor(){this._physicsRig=null,this._options=new nr,this._options.gravity.y=-1,this._options.gravity.x=0,this._options.wind.x=0,this._options.wind.y=0,this._currentRigOutputs=new g,this._previousRigOutputs=new g,this._currentRemainTime=0,this._parameterCaches=null,this._parameterInputCaches=null}release(){this._physicsRig=void 0,this._physicsRig=null}initialize(){let t,e,i;for(let s=0;s<this._physicsRig.subRigCount;++s){e=this._physicsRig.settings.at(s),t=this._physicsRig.particles.get(e.baseParticleIndex),t[0].initialPosition=new fe(0,0),t[0].lastPosition=new fe(t[0].initialPosition.x,t[0].initialPosition.y),t[0].lastGravity=new fe(0,-1),t[0].lastGravity.y*=-1,t[0].velocity=new fe(0,0),t[0].force=new fe(0,0);for(let s=1;s<e.particleCount;++s)i=new fe(0,0),i.y=t[s].radius,t[s].initialPosition=new fe(t[s-1].initialPosition.x+i.x,t[s-1].initialPosition.y+i.y),t[s].position=new fe(t[s].initialPosition.x,t[s].initialPosition.y),t[s].lastPosition=new fe(t[s].initialPosition.x,t[s].initialPosition.y),t[s].lastGravity=new fe(0,-1),t[s].lastGravity.y*=-1,t[s].velocity=new fe(0,0),t[s].force=new fe(0,0)}}}class nr{constructor(){this.gravity=new fe(0,0),this.wind=new fe(0,0)}}class or{constructor(){this.outputs=new g(0)}}function lr(t,e,i,s,r,a,n,o,l,u){t.x+=Sr(i,s,r,a,n.minimum,n.maximum,n.defalut,l)*u}function ur(t,e,i,s,r,a,n,o,l,u){t.y+=Sr(i,s,r,a,n.minimum,n.maximum,n.defalut,l)*u}function hr(t,e,i,s,r,a,n,o,l,u){e.angle+=Sr(i,s,r,a,o.minimum,o.maximum,o.defalut,l)*u}function dr(t,e,i,s,r){let a=t.x;return s&&(a*=-1),a}function gr(t,e,i,s,r){let a=t.y;return s&&(a*=-1),a}function cr(t,e,i,s,r){let a;return r=i>=2?e[i-1].position.substract(e[i-2].position):r.multiplyByScaler(-1),a=Ce.directionToRadian(r,t),s&&(a*=-1),a}function mr(t,e){return Ce.min(t,e)+function(t,e){const i=Ce.max(t,e),s=Ce.min(t,e);return Ce.abs(i-s)}(t,e)/2}function pr(t,e){return JSON.parse(JSON.stringify(t.x))}function _r(t,e){return JSON.parse(JSON.stringify(t.y))}function fr(t,e){return JSON.parse(JSON.stringify(e))}function yr(t,e,i,s,r,a,n,o){let l,u,h=new fe(0,0),d=new fe(0,0),g=new fe(0,0),c=new fe(0,0);t[0].position=new fe(i.x,i.y);const m=Ce.degreesToRadian(s),p=Ce.radianToDirection(m);p.normalize();for(let _=1;_<e;++_)t[_].force=p.multiplyByScaler(t[_].acceleration).add(r),t[_].lastPosition=new fe(t[_].position.x,t[_].position.y),l=t[_].delay*n*30,h=t[_].position.substract(t[_-1].position),u=Ce.directionToRadian(t[_].lastGravity,p)/o,h.x=Ce.cos(u)*h.x-h.y*Ce.sin(u),h.y=Ce.sin(u)*h.x+h.y*Ce.cos(u),t[_].position=t[_-1].position.add(h),d=t[_].velocity.multiplyByScaler(l),g=t[_].force.multiplyByScaler(l).multiplyByScaler(l),t[_].position=t[_].position.add(d).add(g),c=t[_].position.substract(t[_-1].position),c.normalize(),t[_].position=t[_-1].position.add(c.multiplyByScaler(t[_].radius)),Ce.abs(t[_].position.x)<a&&(t[_].position.x=0),0!=l&&(t[_].velocity=t[_].position.substract(t[_].lastPosition),t[_].velocity=t[_].velocity.divisionByScalar(l),t[_].velocity=t[_].velocity.multiplyByScaler(t[_].mobility)),t[_].force=new fe(0,0),t[_].lastGravity=new fe(p.x,p.y)}function xr(t,e,i,s,r,a){let n=new fe(0,0);t[0].position=new fe(i.x,i.y);const o=Ce.degreesToRadian(s),l=Ce.radianToDirection(o);l.normalize();for(let u=1;u<e;++u)t[u].force=l.multiplyByScaler(t[u].acceleration).add(r),t[u].lastPosition=new fe(t[u].position.x,t[u].position.y),t[u].velocity=new fe(0,0),n=t[u].force,n.normalize(),n=n.multiplyByScaler(t[u].radius),t[u].position=t[u-1].position.add(n),Ce.abs(t[u].position.x)<a&&(t[u].position.x=0),t[u].force=new fe(0,0),t[u].lastGravity=new fe(l.x,l.y)}function Cr(t,e,i,s,r){let a;a=s*r.getScale(r.translationScale,r.angleScale),a<e?(a<r.valueBelowMinimum&&(r.valueBelowMinimum=a),a=e):a>i&&(a>r.valueExceededMaximum&&(r.valueExceededMaximum=a),a=i);const n=r.weight/100;n>=1||(a=t[0]*(1-n)+a*n),t[0]=a}function Sr(t,e,i,s,r,a,n,o){let l=0;const u=Ce.max(i,e);u<t&&(t=u);const h=Ce.min(i,e);h>t&&(t=h);const d=Ce.min(r,a),g=Ce.max(r,a),c=n,m=mr(h,u),p=t-m;switch(function(t){let e=0;return t>0?e=1:t<0&&(e=-1),e}(p)){case 1:{const t=u-m;0!=t&&(l=p*((g-c)/t),l+=c);break}case-1:{const t=h-m;0!=t&&(l=p*((d-c)/t),l+=c);break}case 0:l=c}return o?l:-1*l}var Mr;function vr(){var t;null==(t=this.__moc)||t.release()}(t=>{t.CubismPhysics=ar,t.Options=nr})(Mr||(Mr={})),se.registerRuntime({version:4,ready:cs,test:t=>t instanceof ls||ls.isValidJSON(t),isValidMoc(t){if(t.byteLength<4)return!1;const e=new Int8Array(t,0,4);return"MOC3"===String.fromCharCode(...e)},createModelSettings:t=>new ls(t),createCoreModel(t,e){const i=ws.create(t,!!(null==e?void 0:e.checkMocConsistency));try{const t=i.createModel();return t.__moc=i,t}catch(s){try{i.release()}catch(r){ct.warn("CubismFactory","Failed to release moc after core model creation failed.",r)}throw s}},createInternalModel(t,e,i){const s=new is(t,e,i),r=t;return r.__moc&&(s.__moc=r.__moc,delete r.__moc,s.once("destroy",vr)),s},createPhysics(t,e){if(!(e instanceof ArrayBuffer))throw new TypeError("Cubism physics data must be an ArrayBuffer.");return ar.create(e,e.byteLength)},createPose(t,e){if(!(e instanceof ArrayBuffer))throw new TypeError("Cubism pose data must be an ArrayBuffer.");return fs.create(e,e.byteLength)}}),t.Constant=lt,t.CubismExpressionManager=De,t.CubismFramework=ht,t.CubismInternalModel=is,t.CubismModelSettings=ls,t.CubismMotionManager=di,t.CubismParallelMotionManager=yi,t.ExpressionManager=vt,t.FileLoader=ee,t.FocusController=Bt,t.InternalModel=Ot,t.LOGICAL_HEIGHT=2,t.LOGICAL_WIDTH=2,t.Live2DFactory=se,t.Live2DLoader=jt,t.Live2DModel=_e,t.Live2DTransform=ue,t.LogLevel=dt,t.MBToByte=pt,t.ModelSettings=wt,t.MotionManager=Tt,t.MotionPreloadStrategy=Lt,t.MotionPriority=Ft,t.MotionState=It,t.Option=class{},t.SoundManager=Rt,t.VERSION="1.0.2",t.VOLUME=Vt,t.XHRLoader=Ut,t.ZipLoader=Qt,t.applyMixins=yt,t.clamp=mt,t.config=gt,t.configureCubismSDK=gs,t.copyArray=ft,t.copyProperty=_t,t.csmDelete=ut,t.cubismReady=cs,t.folderName=xt,t.logger=ct,t.normalizeHitAreaDefs=At,t.rand=function(t,e){return Math.random()*(e-t)+t},t.reconfigureCubismSDK=function(t={}){gs(t),ht.isInitialized()&&ht.dispose(),ht.isStarted()&&ht.cleanUp(),ms(void 0,t.memorySizeMB)},t.remove=Ct,t.resolveURL=Mt,t.startUpCubism=ms,t.strtod=st,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});