phaser4-rex-plugins
Version:
1 lines • 171 kB
JavaScript
var t,e;t=void 0,e=function(){var t=!1;!function(e){if(!t){void 0===e&&(e=0);var i=Phaser.VERSION.split("."),s=parseInt(i[0]);if(4===s){var r=parseInt(i[1]);r<e&&console.error(`Minimum supported version : ${s}.${r}`)}else console.error(`Can't supported version : ${s}`);t=!0}}();const e=Phaser.GameObjects.Extern;class i extends e{}const s=Phaser.GameObjects.Components;Phaser.Class.mixin(i,[s.AlphaSingle,s.ComputedSize,s.GetBounds]);class r{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(t){this._size>=this._capacity&&this.prepareCapacity(0==this._capacity?r.s_defaultSize:2*this._capacity),this._ptr[this._size++]=t}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 i=this._size;i<t;i++)this._ptr[i]="function"==typeof e?JSON.parse(JSON.stringify(new e)):e;else for(let i=this._size;i<t;i++)this._ptr[i]=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 t=0;t<o;t++)this._ptr.splice(s+t,0,null);for(let t=r;t<a;t++,s++)this._ptr[s]=e._vector._ptr[t];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;return e<0||this._size<=e?t:(this._ptr.splice(e,1),--this._size,new a(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 a(this,0)}end(){return new a(this,this._size)}getOffset(t){const e=new r;return e._ptr=this.get(t),e._size=this.get(t).length,e._capacity=this.get(t).length,e}}r.s_defaultSize=10;let a=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 n,o,l,u,h,g,d;!function(t){t.csmVector=r,t.iterator=a}(n||(n={}));class c{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}}!function(t){t.csmString=c}(o||(o={}));class _{getString(){return this._id}constructor(t){this._id="string"!=typeof t?t:new c(t)}isEqual(t){return"string"==typeof t?this._id.isEqual(t):t instanceof c?this._id.isEqual(t.s):t instanceof _&&this._id.isEqual(t._id.s)}isNotEqual(t){return"string"==typeof t?!this._id.isEqual(t):t instanceof c?!this._id.isEqual(t.s):t instanceof _&&!this._id.isEqual(t._id.s)}}!function(t){t.CubismId=_}(l||(l={}));class m{constructor(){this._ids=new r}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=new _(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}}!function(t){t.CubismIdManager=m}(u||(u={}));class p{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 i=0;i<4;++i)for(let r=0;r<4;++r)for(let a=0;a<4;++a)s[r+4*i]+=t[a+4*i]*e[r+4*a];for(let t=0;t<16;++t)i[t]=s[t]}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]);p.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]);p.multiply(i,this._tr,this._tr)}scale(t,e){this._tr[0]=t,this._tr[5]=e}multiplyByMatrix(t){p.multiply(t.getArray(),this._tr,this._tr)}clone(){const t=new p;for(let e=0;e<this._tr.length;e++)t._tr[e]=this._tr[e];return t}}!function(t){t.CubismMatrix44=p}(h||(h={}));class y{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))}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 f,this._useHighPrecisionMask=!1,this._mvpMatrix4x4=new p,this._mvpMatrix4x4.loadIdentity()}}!function(t){t[t.CubismBlendMode_Normal=0]="CubismBlendMode_Normal",t[t.CubismBlendMode_Additive=1]="CubismBlendMode_Additive",t[t.CubismBlendMode_Multiplicative=2]="CubismBlendMode_Multiplicative"}(g||(g={}));class f{constructor(t=1,e=1,i=1,s=1){this.R=t,this.G=e,this.B=i,this.A=s}}!function(t){t.CubismBlendMode=g,t.CubismRenderer=y,t.CubismTextureColor=f}(d||(d={}));class x{static parseJsonObject(t,e){return Object.keys(t).forEach((i=>{if("boolean"==typeof t[i]){const s=Boolean(t[i]);e.put(i,new M(s))}else if("string"==typeof t[i]){const s=String(t[i]);e.put(i,new v(s))}else if("number"==typeof t[i]){const s=Number(t[i]);e.put(i,new B(s))}else t[i]instanceof Array?e.put(i,x.parseJsonArray(t[i])):t[i]instanceof Object?e.put(i,x.parseJsonObject(t[i],new I)):null==t[i]?e.put(i,new V):e.put(i,t[i])})),e}static parseJsonArray(t){const e=new w;return Object.keys(t).forEach((i=>{if("number"==typeof Number(i))if("boolean"==typeof t[i]){const s=Boolean(t[i]);e.add(new M(s))}else if("string"==typeof t[i]){const s=String(t[i]);e.add(new v(s))}else if("number"==typeof t[i]){const s=Number(t[i]);e.add(new B(s))}else t[i]instanceof Array?e.add(this.parseJsonArray(t[i])):t[i]instanceof Object?e.add(this.parseJsonObject(t[i],new I)):null==t[i]?e.add(new V):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 I));else if(null==t[i])e.add(new V);else{const s=Array(t[i]);for(let t=0;t<s.length;t++)e.add(s[t])}})),e}}const S="Error: type mismatch";let C=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 r){return t}getMap(t){return t}getValueByIndex(e){return t.errorValue.setErrorNotForClientCall(S)}getValueByString(e){return t.nullValue.setErrorNotForClientCall(S)}getKeys(){return t.s_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 b.errorValue}static staticInitializeNotForClientCall(){M.trueValue=new M(!0),M.falseValue=new M(!1),t.errorValue=new b("ERROR",!0),t.nullValue=new V,t.s_dummyKeys=new r}static staticReleaseNotForClientCall(){M.trueValue=null,M.falseValue=null,t.errorValue=null,t.nullValue=null,t.s_dummyKeys=null}};class P{constructor(t,e){this._parseCallback=x.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 P;return i.parseBytes(t,e,i._parseCallback)?i:(P.delete(i),null)}static delete(t){}getRoot(){return this._root}static arrayBufferToString(t){const e=new Uint8Array(t);let i="";for(let t=0,s=e.length;t<s;++t)i+="%"+this.pad(e[t].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=P.arrayBufferToString(t);if(this._root=null==i?this.parseValue(r,e,0,s):i(JSON.parse(r),new I),this._error){let t="\0";return t="Json parse error : @line "+(this._lineCount+1)+"\n",this._root=new v(t),Y("{0}",this._root.getRawString()),!1}return null!=this._root||(this._root=new b(new c(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=T(t.slice(n),e),s[0]=t.indexOf(e[0]),new B(r)}case'"':return new v(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 V,s[0]=n+4):this._error="parse null",a;case"t":return n+3<e?(a=M.trueValue,s[0]=n+4):this._error="parse true",a;case"f":return n+4<e?(a=M.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;let r,a,n=i;const o=new c("");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;const r=new I;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;let r,a=new w,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 B extends C{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 M extends C{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 v extends C{constructor(t){super(),"string"==typeof t&&(this._stringBuffer=t),t instanceof c&&(this._stringBuffer=t.s)}isString(){return!0}getString(t,e){return this._stringBuffer}equals(t){return"string"==typeof t?this._stringBuffer==t:t instanceof c&&this._stringBuffer==t.s}}class b extends v{isStatic(){return this._isStatic}setErrorNotForClientCall(t){return this._stringBuffer=t,this}constructor(t,e){super(t),this._isStatic=e}isError(){return!0}}class V extends C{isNull(){return!0}getString(t,e){return this._stringBuffer}isStatic(){return!0}setErrorNotForClientCall(t){return this._stringBuffer=t,b.nullValue}constructor(){super(),this._stringBuffer="NullValue"}}class w extends C{constructor(){super(),this._array=new r}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 C.errorValue.setErrorNotForClientCall("Error: index out of bounds");const e=this._array.at(t);return null==e?C.nullValue:e}getValueByString(t){return C.errorValue.setErrorNotForClientCall(S)}getString(t,e){const i=e+"[\n";for(let t=this._array.begin();t.notEqual(this._array.end());t.increment()){const i=t.ptr();this._stringBuffer+=e+""+i.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 I extends C{constructor(){super(),this._map=new et}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 c){const e=this._map.getValue(t.s);return null==e?C.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?C.nullValue:e.ptr().second;return C.nullValue}getValueByIndex(t){return C.errorValue.setErrorNotForClientCall(S)}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 r;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 F;function T(t,e){let i=0;for(let e=1;;e++){const s=t.slice(e-1,e);if("e"==s||"-"==s||"E"==s)continue;const r=t.substring(0,e),a=Number(r);if(isNaN(a))break;i=e}let s=parseFloat(t);return isNaN(s)&&(s=NaN),e[0]=t.slice(i),s}!function(t){t.CubismJson=P,t.JsonArray=w,t.JsonBoolean=M,t.JsonError=b,t.JsonFloat=B,t.JsonMap=I,t.JsonNullvalue=V,t.JsonString=v,t.Value=C}(F||(F={}));let R=!1,E=!1,A=null,L=null;const D=Object.freeze({vertexOffset:0,vertexStep:2});function k(t){t&&(t=void 0)}class O{static startUp(t=null){if(R)return Y("CubismFramework.startUp() is already done."),R;if(A=t,null!=A&&Live2DCubismCore.Logging.csmSetLogFunction(A.logFunction),R=!0,R){const t=Live2DCubismCore.Version.csmGetVersion(),e=(16711680&t)>>16,i=65535&t,s=t;Y("Live2D Cubism Core version: {0}.{1}.{2} ({3})",("00"+((4278190080&t)>>24)).slice(-2),("00"+e).slice(-2),("0000"+i).slice(-4),s)}return Y("CubismFramework.startUp() is complete."),R}static cleanUp(){R=!1,E=!1,A=null,L=null}static initialize(t=0){G(R),R?E?q("CubismFramework.initialize() skipped, already initialized."):(C.staticInitializeNotForClientCall(),L=new m,Live2DCubismCore.Memory.initializeAmountOfMemory(t),E=!0,Y("CubismFramework.initialize() is complete.")):q("CubismFramework is not started.")}static dispose(){G(R),R?E?(C.staticReleaseNotForClientCall(),L.release(),L=null,y.staticRelease(),E=!1,Y("CubismFramework.dispose() is complete.")):q("CubismFramework.dispose() skipped, not initialized."):q("CubismFramework is not started.")}static isStarted(){return R}static isInitialized(){return E}static coreLogFunction(t){Live2DCubismCore.Logging.csmGetLogFunction()&&Live2DCubismCore.Logging.csmGetLogFunction()(t)}static getLoggingLevel(){return null!=A?A.loggingLevel:U.LogLevel_Off}static getIdManager(){return L}constructor(){}}class N{}var U,z;!function(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"}(U||(U={})),function(t){t.Constant=D,t.csmDelete=k,t.CubismFramework=O}(z||(z={}));const j=(t,e,i)=>{((t,e,i)=>{W.print(t,"[CSM]"+e,i)})(t,e+"\n",i)},G=t=>{console.assert(t)};let X,Y,q,H;X=(t,...e)=>{j(U.LogLevel_Debug,"[D]"+t,e)},Y=(t,...e)=>{j(U.LogLevel_Info,"[I]"+t,e)},q=(t,...e)=>{j(U.LogLevel_Warning,"[W]"+t,e)},H=(t,...e)=>{j(U.LogLevel_Error,"[E]"+t,e)};class W{static print(t,e,i){if(t<O.getLoggingLevel())return;const s=O.coreLogFunction;s&&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 $,J,Z,K,Q;!function(t){t.CubismDebug=W}($||($={}));class tt{constructor(t,e){this.first=null==t?null:t,this.second=null==e?null:e}}class et{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){this.prepareCapacity(this._size+1,!1),this._keyValues[this._size]=new tt(t),this._size+=1}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 e=0;e<this._size;e++)if(this._keyValues[e].first==t){i=e;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(t,e){t>this._keyValues.length&&(0==this._keyValues.length?(!e&&t<et.DefaultSize&&(t=et.DefaultSize),this._keyValues.length=t):(!e&&t<2*this._keyValues.length&&(t=2*this._keyValues.length),this._keyValues.length=t))}begin(){return new it(this,0)}end(){return new it(this,this._size)}erase(t){const e=t._index;return e<0||this._size<=e?t:(this._keyValues.splice(e,1),--this._size,new it(this,e))}dumpAsInt(){for(let t=0;t<this._size;t++)X("{0} ,",this._keyValues[t]),X("\n")}}et.DefaultSize=10;class it{constructor(t,e){this._map=null!=t?t:new et,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 it(this._map,this._index++)}decrement(){const t=new it(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}}!function(t){t.csmMap=et,t.csmPair=tt,t.iterator=it}(J||(J={}));class st{static create(){return new st}static delete(t){}setParameters(t){this._breathParameters=t}getParameters(){return this._breathParameters}updateParameters(t,e){this._currentTime+=e;const i=2*this._currentTime*3.14159;for(let e=0;e<this._breathParameters.getSize();++e){const s=this._breathParameters.at(e);t.addParameterValueById(s.parameterId,s.offset+s.peak*Math.sin(i/s.cycle),s.weight)}}constructor(){this._currentTime=0}}class rt{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}}!function(t){t.BreathParameterData=rt,t.CubismBreath=st}(Z||(Z={}));class at{static create(t=null){return new at(t)}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(t,e){let i;this._userTimeSeconds+=e;let s=0;switch(this._blinkingState){case K.EyeState_Closing:s=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._closingSeconds,s>=1&&(s=1,this._blinkingState=K.EyeState_Closed,this._stateStartTimeSeconds=this._userTimeSeconds),i=1-s;break;case K.EyeState_Closed:s=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._closedSeconds,s>=1&&(this._blinkingState=K.EyeState_Opening,this._stateStartTimeSeconds=this._userTimeSeconds),i=0;break;case K.EyeState_Opening:s=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._openingSeconds,s>=1&&(s=1,this._blinkingState=K.EyeState_Interval,this._nextBlinkingTime=this.determinNextBlinkingTiming()),i=s;break;case K.EyeState_Interval:this._nextBlinkingTime<this._userTimeSeconds&&(this._blinkingState=K.EyeState_Closing,this._stateStartTimeSeconds=this._userTimeSeconds),i=1;break;case K.EyeState_First:default:this._blinkingState=K.EyeState_Interval,this._nextBlinkingTime=this.determinNextBlinkingTiming(),i=1}at.CloseIfZero||(i=-i);for(let e=0;e<this._parameterIds.getSize();++e)t.setParameterValueById(this._parameterIds.at(e),i)}constructor(t){if(this._blinkingState=K.EyeState_First,this._nextBlinkingTime=0,this._stateStartTimeSeconds=0,this._blinkingIntervalSeconds=4,this._closingSeconds=.1,this._closedSeconds=.05,this._openingSeconds=.15,this._userTimeSeconds=0,this._parameterIds=new r,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)}}at.CloseIfZero=!0,function(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"}(K||(K={})),function(t){t.CubismEyeBlink=at,t.EyeState=K}(Q||(Q={}));const nt="FadeInTime",ot="Link";class lt{static create(t,e){const i=new lt,s=P.create(t,e),r=s.getRoot();r.getValueByString(nt).isNull()||(i._fadeTimeSeconds=r.getValueByString(nt).toFloat(.5),i._fadeTimeSeconds<=0&&(i._fadeTimeSeconds=.5));const a=r.getValueByString("Groups"),n=a.getSize();for(let t=0;t<n;++t){const e=a.getValueByIndex(t),s=e.getSize();let r=0;for(let t=0;t<s;++t){const s=e.getValueByIndex(t),a=new ut,n=O.getIdManager().getId(s.getValueByString("Id").getRawString());if(a.partId=n,!s.getValueByString(ot).isNull()){const t=s.getValueByString(ot),e=t.getSize();for(let i=0;i<e;++i){const e=new ut,s=O.getIdManager().getId(t.getValueByIndex(i).getString());e.partId=s,a.link.pushBack(e)}}i._partGroups.pushBack(a.clone()),++r}i._partGroupCounts.pushBack(r)}return P.delete(s),i}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 n=i;n<i+s;++n){const i=this._partGroups.at(n).partIndex,s=this._partGroups.at(n).parameterIndex;if(t.getParameterValueByIndex(s)>.001){if(r>=0)break;r=n,a=t.getPartOpacityByIndex(i),a+=e/this._fadeTimeSeconds,a>1&&(a=1)}}r<0&&(r=0,a=1);for(let e=i;e<i+s;++e){const i=this._partGroups.at(e).partIndex;if(r==e)t.setPartOpacityByIndex(i,a);else{let e,s=t.getPartOpacityByIndex(i);e=a<n?-.5*a/n+1:(1-a)*n/.5,(1-e)*(1-a)>.15&&(e=1-.15/(1-a)),s>e&&(s=e),t.setPartOpacityByIndex(i,s)}}}constructor(){this._fadeTimeSeconds=.5,this._lastModel=null,this._partGroups=new r,this._partGroupCounts=new r}}class ut{constructor(t){if(this.parameterIndex=0,this.partIndex=0,this.link=new r,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 ut;t.partId=this.partId,t.parameterIndex=this.parameterIndex,t.partIndex=this.partIndex,t.link=new r;for(let e=this.link.begin();e.notEqual(this.link.end());e.increment())t.link.pushBack(e.ptr().clone());return t}}var ht,gt,dt,ct,_t,mt;!function(t){t.CubismPose=lt,t.PartData=ut}(ht||(ht={}));class pt extends p{constructor(t,e){super(),this._width=void 0!==t?t:0,this._height=void 0!==e?e:0,this.setHeight(2)}setWidth(t){const e=t/this._width,i=e;this.scale(e,i)}setHeight(t){const e=t/this._height,i=e;this.scale(e,i)}setPosition(t,e){this.translate(t,e)}setCenterPosition(t,e){this.centerX(t),this.centerY(e)}top(t){this.setY(t)}bottom(t){const e=this._height*this.getScaleY();this.translateY(t-e)}left(t){this.setX(t)}right(t){const e=this._width*this.getScaleX();this.translateX(t-e)}centerX(t){const e=this._width*this.getScaleX();this.translateX(t-e/2)}setX(t){this.translateX(t)}centerY(t){const e=this._height*this.getScaleY();this.translateY(t-e/2)}setY(t){this.translateY(t)}setupFromLayout(t){for(const e=t.begin();e.notEqual(t.end());e.preIncrement()){const t=e.ptr().first,i=e.ptr().second;"width"==t?this.setWidth(i):"height"==t&&this.setHeight(i)}for(const e=t.begin();e.notEqual(t.end());e.preIncrement()){const t=e.ptr().first,i=e.ptr().second;"x"==t?this.setX(i):"y"==t?this.setY(i):"center_x"==t?this.centerX(i):"center_y"==t?this.centerY(i):"top"==t?this.top(i):"bottom"==t?this.bottom(i):"left"==t?this.left(i):"right"==t&&this.right(i)}}}!function(t){t.CubismModelMatrix=pt}(gt||(gt={}));class yt{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 yt(0,0);return e.x=this.x+t.x,e.y=this.y+t.y,e}substract(t){const e=new yt(0,0);return e.x=this.x-t.x,e.y=this.y-t.y,e}multiply(t){const e=new yt(0,0);return e.x=this.x*t.x,e.y=this.y*t.y,e}multiplyByScaler(t){return this.multiply(new yt(t,t))}division(t){const e=new yt(0,0);return e.x=this.x/t.x,e.y=this.y/t.y,e}divisionByScalar(t){return this.division(new yt(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)}}!function(t){t.CubismVector2=yt}(dt||(dt={}));class ft{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 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 yt;return e.x=this.sin(t),e.y=this.cos(t),e}static quadraticEquation(t,e,i){return this.abs(t)<ft.Epsilon?this.abs(e)<ft.Epsilon?-i:-i/e:-(e+this.sqrt(e*e-4*t*i))/(2*t)}static cardanoAlgorithmForBezier(t,e,i,s){if(this.sqrt(t)<ft.Epsilon)return this.range(this.quadraticEquation(e,i,s),0,1);const r=e/t,a=i/t,n=(3*a-r*r)/3,o=n/3,l=(2*r*r*r-9*r*a+s/t*27)/27,u=l/2,h=u*u+o*o*o,g=.5,d=.51;if(h<0){const t=-n/3,e=t*t*t,i=this.sqrt(e),s=-l/(2*i),a=this.range(s,-1,1),o=Math.acos(a),u=2*this.cbrt(i),h=u*this.cos(o/3)-r/3;if(this.abs(h-g)<d)return this.range(h,0,1);const c=u*this.cos((o+2*Math.PI)/3)-r/3;if(this.abs(c-g)<d)return this.range(c,0,1);const _=u*this.cos((o+4*Math.PI)/3)-r/3;return this.range(_,0,1)}if(0==h){let t;t=u<0?this.cbrt(-u):-this.cbrt(u);const e=2*t-r/3;if(this.abs(e-g)<d)return this.range(e,0,1);const i=-t-r/3;return this.range(i,0,1)}const c=this.sqrt(h),_=this.cbrt(c-u)-this.cbrt(c+u)-r/3;return this.range(_,0,1)}constructor(){}}ft.Epsilon=1e-5,function(t){t.CubismMath=ft}(ct||(ct={}));class xt{constructor(){this._faceTargetX=0,this._faceTargetY=0,this._faceX=0,this._faceY=0,this._faceVX=0,this._faceVY=0,this._lastTimeSeconds=0,this._userTimeSeconds=0}update(t){this._userTimeSeconds+=t;const e=4/30;if(0==this._lastTimeSeconds)return void(this._lastTimeSeconds=this._userTimeSeconds);const i=30*(this._userTimeSeconds-this._lastTimeSeconds);this._lastTimeSeconds=this._userTimeSeconds;const s=i*e/4.5,r=this._faceTargetX-this._faceX,a=this._faceTargetY-this._faceY;if(ft.abs(r)<=.01&&ft.abs(a)<=.01)return;const n=ft.sqrt(r*r+a*a),o=e*a/n;let l=e*r/n-this._faceVX,u=o-this._faceVY;const h=ft.sqrt(l*l+u*u);(h<-s||h>s)&&(l*=s/h,u*=s/h),this._faceVX+=l,this._faceVY+=u;{const t=.5*(ft.sqrt(s*s+16*s*n-8*s*n)-s),e=ft.sqrt(this._faceVX*this._faceVX+this._faceVY*this._faceVY);e>t&&(this._faceVX*=t/e,this._faceVY*=t/e)}this._faceX+=this._faceVX,this._faceY+=this._faceVY}getX(){return this._faceX}getY(){return this._faceY}set(t,e){this._faceTargetX=t,this._faceTargetY=e}}!function(t){t.CubismTargetPoint=xt}(_t||(_t={}));class St{static delete(t){t.release(),t=null}constructor(){this.setFinishedMotionHandler=t=>this._onFinishedMotion=t,this.getFinishedMotionHandler=()=>this._onFinishedMotion,this._fadeInSeconds=-1,this._fadeOutSeconds=-1,this._weight=1,this._offsetSeconds=0,this._firedEventValues=new r}release(){this._weight=0}updateParameters(t,e,i){if(!e.isAvailable()||e.isFinished())return;if(!e.isStarted()){e.setIsStarted(!0),e.setStartTime(i-this._offsetSeconds),e.setFadeInStartTime(i);const t=this.getDuration();e.getEndTime()<0&&e.setEndTime(t<=0?-1:e.getStartTime()+t)}let s=this._weight;s=s*(0==this._fadeInSeconds?1:ft.getEasingSine((i-e.getFadeInStartTime())/this._fadeInSeconds))*(0==this._fadeOutSeconds||e.getEndTime()<0?1:ft.getEasingSine((e.getEndTime()-i)/this._fadeOutSeconds)),e.setState(i,s),G(0<=s&&s<=1),this.doUpdateParameters(t,i,s,e),e.getEndTime()>0&&e.getEndTime()<i&&e.setIsFinished(!0)}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}getFiredEvent(t,e){return this._firedEventValues}isExistModelOpacity(){return!1}getModelOpacityIndex(){return-1}getModelOpacityId(t){return null}getModelOpacityValue(){return 1}}!function(t){t.ACubismMotion=St}(mt||(mt={}));const Ct="Parameters",Pt="Blend";class Bt extends St{static create(t,e){const i=new Bt;return i.parse(t,e),i}doUpdateParameters(t,e,i,s){for(let e=0;e<this._parameters.getSize();++e){const s=this._parameters.at(e);switch(s.blendType){case Mt.ExpressionBlendType_Add:t.addParameterValueById(s.parameterId,s.value,i);break;case Mt.ExpressionBlendType_Multiply:t.multiplyParameterValueById(s.parameterId,s.value,i);break;case Mt.ExpressionBlendType_Overwrite:t.setParameterValueById(s.parameterId,s.value,i)}}}parse(t,e){const i=P.create(t,e),s=i.getRoot();this.setFadeInTime(s.getValueByString("FadeInTime").toFloat(1)),this.setFadeOutTime(s.getValueByString("FadeOutTime").toFloat(1));const r=s.getValueByString(Ct).getSize();this._parameters.prepareCapacity(r);for(let t=0;t<r;++t){const e=s.getValueByString(Ct).getValueByIndex(t),i=O.getIdManager().getId(e.getValueByString("Id").getRawString()),r=e.getValueByString("Value").toFloat();let a;a=e.getValueByString(Pt).isNull()||"Add"==e.getValueByString(Pt).getString()?Mt.ExpressionBlendType_Add:"Multiply"==e.getValueByString(Pt).getString()?Mt.ExpressionBlendType_Multiply:"Overwrite"==e.getValueByString(Pt).getString()?Mt.ExpressionBlendType_Overwrite:Mt.ExpressionBlendType_Add;const n=new It;n.parameterId=i,n.blendType=a,n.value=r,this._parameters.pushBack(n)}P.delete(i)}constructor(){super(),this._parameters=new r}}var Mt,vt,bt,Vt,wt;!function(t){t[t.ExpressionBlendType_Add=0]="ExpressionBlendType_Add",t[t.ExpressionBlendType_Multiply=1]="ExpressionBlendType_Multiply",t[t.ExpressionBlendType_Overwrite=2]="ExpressionBlendType_Overwrite"}(Mt||(Mt={}));class It{}!function(t){t.CubismExpressionMotion=Bt,t.ExpressionBlendType=Mt,t.ExpressionParameter=It}(vt||(vt={})),function(t){t[t.CubismMotionCurveTarget_Model=0]="CubismMotionCurveTarget_Model",t[t.CubismMotionCurveTarget_Parameter=1]="CubismMotionCurveTarget_Parameter",t[t.CubismMotionCurveTarget_PartOpacity=2]="CubismMotionCurveTarget_PartOpacity"}(bt||(bt={})),function(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"}(Vt||(Vt={}));class Ft{constructor(){this.time=0,this.value=0}}class Tt{constructor(){this.evaluate=null,this.basePointIndex=0,this.segmentType=0}}class Rt{constructor(){this.type=bt.CubismMotionCurveTarget_Model,this.segmentCount=0,this.baseSegmentIndex=0,this.fadeInTime=0,this.fadeOutTime=0}}class Et{constructor(){this.fireTime=0}}class At{constructor(){this.duration=0,this.loop=!1,this.curveCount=0,this.eventCount=0,this.fps=0,this.curves=new r,this.segments=new r,this.points=new r,this.events=new r}}!function(t){t.CubismMotionCurve=Rt,t.CubismMotionCurveTarget=bt,t.CubismMotionData=At,t.CubismMotionEvent=Et,t.CubismMotionPoint=Ft,t.CubismMotionSegment=Tt,t.CubismMotionSegmentType=Vt}(wt||(wt={}));const Lt="Meta",Dt="Curves",kt="FadeInTime",Ot="FadeOutTime",Nt="Segments",Ut="UserData";class zt{constructor(t,e){this._json=P.create(t,e)}release(){P.delete(this._json)}getMotionDuration(){return this._json.getRoot().getValueByString(Lt).getValueByString("Duration").toFloat()}isMotionLoop(){return this._json.getRoot().getValueByString(Lt).getValueByString("Loop").toBoolean()}getEvaluationOptionFlag(t){return jt.EvaluationOptionFlag_AreBeziersRistricted==t&&this._json.getRoot().getValueByString(Lt).getValueByString("AreBeziersRestricted").toBoolean()}getMotionCurveCount(){return this._json.getRoot().getValueByString(Lt).getValueByString("CurveCount").toInt()}getMotionFps(){return this._json.getRoot().getValueByString(Lt).getValueByString("Fps").toFloat()}getMotionTotalSegmentCount(){return this._json.getRoot().getValueByString(Lt).getValueByString("TotalSegmentCount").toInt()}getMotionTotalPointCount(){return this._json.getRoot().getValueByString(Lt).getValueByString("TotalPointCount").toInt()}isExistMotionFadeInTime(){return!this._json.getRoot().getValueByString(Lt).getValueByString(kt).isNull()}isExistMotionFadeOutTime(){return!this._json.getRoot().getValueByString(Lt).getValueByString(Ot).isNull()}getMotionFadeInTime(){return this._json.getRoot().getValueByString(Lt).getValueByString(kt).toFloat()}getMotionFadeOutTime(){return this._json.getRoot().getValueByString(Lt).getValueByString(Ot).toFloat()}getMotionCurveTarget(t){return this._json.getRoot().getValueByString(Dt).getValueByIndex(t).getValueByString("Target").getRawString()}getMotionCurveId(t){return O.getIdManager().getId(this._json.getRoot().getValueByString(Dt).getValueByIndex(t).getValueByString("Id").getRawString())}isExistMotionCurveFadeInTime(t){return!this._json.getRoot().getValueByString(Dt).getValueByIndex(t).getValueByString(kt).isNull()}isExistMotionCurveFadeOutTime(t){return!this._json.getRoot().getValueByString(Dt).getValueByIndex(t).getValueByString(Ot).isNull()}getMotionCurveFadeInTime(t){return this._json.getRoot().getValueByString(Dt).getValueByIndex(t).getValueByString(kt).toFloat()}getMotionCurveFadeOutTime(t){return this._json.getRoot().getValueByString(Dt).getValueByIndex(t).getValueByString(Ot).toFloat()}getMotionCurveSegmentCount(t){return this._json.getRoot().getValueByString(Dt).getValueByIndex(t).getValueByString(Nt).getVector().getSize()}getMotionCurveSegment(t,e){return this._json.getRoot().getValueByString(Dt).getValueByIndex(t).getValueByString(Nt).getValueByIndex(e).toFloat()}getEventCount(){return this._json.getRoot().getValueByString(Lt).getValueByString("UserDataCount").toInt()}getTotalEventValueSize(){return this._json.getRoot().getValueByString(Lt).getValueByString("TotalUserDataSize").toInt()}getEventTime(t){return this._json.getRoot().getValueByString(Ut).getValueByIndex(t).getValueByString("Time").toFloat()}getEventValue(t){return new c(this._json.getRoot().getValueByString(Ut).getValueByIndex(t).getValueByString("Value").getRawString())}}var jt,Gt;!function(t){t[t.EvaluationOptionFlag_AreBeziersRistricted=0]="EvaluationOptionFlag_AreBeziersRistricted"}(jt||(jt={})),function(t){t.CubismMotionJson=zt}(Gt||(Gt={}));const Xt="Opacity";function Yt(t,e,i){const s=new Ft;return s.time=t.time+(e.time-t.time)*i,s.value=t.value+(e.value-t.value)*i,s}function qt(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 Ht(t,e){let i=(e-t[0].time)/(t[3].time-t[0].time);i<0&&(i=0);const s=Yt(t[0],t[1],i),r=Yt(t[1],t[2],i),a=Yt(t[2],t[3],i),n=Yt(s,r,i),o=Yt(r,a,i);return Yt(n,o,i).value}function Wt(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,g=ft.cardanoAlgorithmForBezier(o,l,u,h),d=Yt(t[0],t[1],g),c=Yt(t[1],t[2],g),_=Yt(t[2],t[3],g),m=Yt(d,c,g),p=Yt(c,_,g);return Yt(m,p,g).value}function $t(t,e){return t[0].value}function Jt(t,e){return t[1].value}function Zt(t,e,i){const s=t.curves.at(e);let r=-1;const a=s.baseSegmentIndex+s.segmentCount;let n=0;for(let e=s.baseSegmentIndex;e<a;++e)if(n=t.segments.at(e).basePointIndex+(t.segments.at(e).segmentType==Vt.CubismMotionSegmentType_Bezier?3:1),t.points.at(n).time>i){r=e;break}if(-1==r)return t.points.at(n).value;const o=t.segments.at(r);return o.evaluate(t.points.get(o.basePointIndex),i)}class Kt extends St{static create(t,e,i){const s=new Kt;return s.parse(t,e),s._sourceFrameRate=s._motionData.fps,s._loopDurationSeconds=s._motionData.duration,s._onFinishedMotion=i,s}doUpdateParameters(t,e,i,s){null==this._modelCurveIdEyeBlink&&(this._modelCurveIdEyeBlink=O.getIdManager().getId("EyeBlink")),null==this._modelCurveIdLipSync&&(this._modelCurveIdLipSync=O.getIdManager().getId("LipSync")),null==this._modelCurveIdOpacity&&(this._modelCurveIdOpacity=O.getIdManager().getId(Xt));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&&X("too many eye blink targets : {0}",this._eyeBlinkParameterIds.getSize()),this._lipSyncParameterIds.getSize()>o&&X("too many lip sync targets : {0}",this._lipSyncParameterIds.getSize());const h=this._fadeInSeconds<=0?1:ft.getEasingSine((e-s.getFadeInStartTime())/this._fadeInSeconds),g=this._fadeOutSeconds<=0||s.getEndTime()<0?1:ft.getEasingSine((s.getEndTime()-e)/this._fadeOutSeconds);let d,c,_,m=r;if(this._isLoop)for(;m>this._motionData.duration;)m-=this._motionData.duration;const p=this._motionData.curves;for(c=0;c<this._motionData.curveCount&&p.at(c).type==bt.CubismMotionCurveTarget_Model;++c)d=Zt(this._motionData,c,m),p.at(c).id==this._modelCurveIdEyeBlink?n=d:p.at(c).id==this._modelCurveIdLipSync?a=d:p.at(c).id==this._modelCurveIdOpacity&&(this._modelOpacity=d,t.setModelOapcity(this.getModelOpacityValue()));for(;c<this._motionData.curveCount&&p.at(c).type==bt.CubismMotionCurveTarget_Parameter;++c){if(_=t.getParameterIndex(p.at(c).id),-1==_)continue;const r=t.getParameterValueByIndex(_);if(d=Zt(this._motionData,c,m),n!=Number.MAX_VALUE)for(let t=0;t<this._eyeBlinkParameterIds.getSize()&&t<o;++t)if(this._eyeBlinkParameterIds.at(t)==p.at(c).id){d*=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)==p.at(c).id){d+=a,l|=1<<t;break}let y;if(p.at(c).fadeInTime<0&&p.at(c).fadeOutTime<0)y=r+(d-r)*i;else{let t,i;t=p.at(c).fadeInTime<0?h:0==p.at(c).fadeInTime?1:ft.getEasingSine((e-s.getFadeInStartTime())/p.at(c).fadeInTime),i=p.at(c).fadeOutTime<0?g:0==p.at(c).fadeOutTime||s.getEndTime()<0?1:ft.getEasingSine((s.getEndTime()-e)/p.at(c).fadeOutTime),y=r+(d-r)*(this._weight*t*i)}t.setParameterValueByIndex(_,y,1)}if(n!=Number.MAX_VALUE)for(let e=0;e<this._eyeBlinkParameterIds.getSize()&&e<o;++e){const s=t.getParameterValueById(this._eyeBlinkParameterIds.at(e));if(u>>e&1)continue;const r=s+(n-s)*i;t.setParameterValueById(this._eyeBlinkParameterIds.at(e),r)}if(a!=Number.MAX_VALUE)for(let e=0;e<this._lipSyncParameterIds.getSize()&&e<o;++e){const s=t.getParameterValueById(this._lipSyncParameterIds.at(e));if(l>>e&1)continue;const r=s+(a-s)*i;t.setParameterValueById(this._lipSyncParameterIds.at(e),r)}for(;c<this._motionData.curveCount&&p.at(c).type==bt.CubismMotionCurveTarget_PartOpacity;++c)_=t.getParameterIndex(p.at(c).id),-1!=_&&(d=Zt(this._motionData,c,m),t.setParameterValueByIndex(_,d));r>=this._motionData.duration&&(this._isLoop?(s.setStartTime(e),this._isLoopFadeIn&&s.setFadeInStartTime(e)):(this._onFinishedMotion&&this._onFinishedMotion(this),s.setIsFinished(!0))),this._lastWeight=i}setIsLoop(t){this._isLoop=t}isLoop(){return this._isLoop}setIsLoopFadeIn(t){this._isLoopFadeIn=t}isLoopFadeIn(){return this._isLoopFadeIn}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}constructor(){super(),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}release(){this._motionData=void 0,this._motionData=null}parse(t,e){this._motionData=new At;let i=new zt(t,e);this._motionData.duration=i.getMotionDuration(),this._motionData.loop=i.isMotionLoop(),this._motionData.curveCount=i.getMotionCurveCount(),this._motionData.fps=i.getMotionFps(),this._motionData.eventCount=i.getEventCount();const s=i.getEvaluationOptionFlag(jt.EvaluationOptionFlag_AreBeziersRistricted);i.isExistMotionFadeInTime()?this._fadeInSeconds=i.getMotionFadeInTime()<0?1:i.getMotionFadeInTime():this._fadeInSeconds=1,i.isExistMotionFadeOutTime()?this._fadeOutSeconds=i.getMotionFadeOutTime()<0?1:i.getMotionFadeOutTime():this._fadeOutSeconds=1,this._motionData.curves.updateSize(this._motionData.curveCount,Rt,!0),this._motionData.segments.updateSize(i.getMotionTotalSegmentCount(),Tt,!0),this._motionData.points.updateSize(i.getMotionTotalPointCount(),Ft,!0),this._motionData.events.updateSize(this._motionData.eventCount,Et,!0);let r=0,a=0;for(let t=0;t<this._motionData.curveCount;++t){"Model"==i.getMotionCurveTarget(t)?this._motionData.curves.at(t).type=bt.CubismMotionCurveTarget_Model:"Parameter"==i.getMotionCurveTarget(t)?this._motionData.curves.at(t).type=bt.CubismMotionCurveTarget_Parameter:"PartOpacity"==i.getMotionCurveTarget(t)?this._motionData.curves.at(t).type=bt.CubismMotionCurveTarget_PartOpacity:q('Warning : Unable to get segment type from Curve! The number of "CurveCount" may be incorrect!'),this._motionData.curves.at(t).id=i.getMotionCurveId(t),this._motionData.curves.at(t).baseSegmentIndex=a,this._motionData.curves.at(t).fadeInTime=i.isExistMotionCurveFadeInTime(t)?i.getMotionCurveFadeInTime(t):-1,this._motionData.curves.at(t).fadeOutTime=i.isExistMotionCurveFadeOutTime(t)?i.getMotionCurveFadeOutTime(t):-1;for(let e=0;e<i.getMotionCurveSegmentCount(t);){switch(0==e?(this._motionData.segments.at(a).basePointIndex=r,this._motionData.points.at(r).time=i.getMotionCurveSegment(t,e),this._motionData.points.at(r).value=i.getMotionCurveSegment(t,e+1),r+=1,e+=2):this._motionData.segments.at(a).basePointIndex=r-1,i.getMotionCurveSegment(t,e)){case Vt.CubismMotionSegmentType_Linear:this._motionData.segments.at(a).segmentType=Vt.CubismMotionSegmentType_Linear,this._motionData.segments.at(a).evaluate=qt,this._motionData.points.at(r).time=i.getMotionCurveSegment(t,e+1),this._motionData.points.at(r).value=i.getMotionCurveSegment(t,e+2),r+=1,e+=3;break;case Vt.CubismMotionSegmentType_Bezier:this._motionData.segments.at(a).segmentType=Vt.CubismMotionSegmentType_Bezier,this._motionData.segments.at(a).evaluate=s?Ht:Wt,this._motionData.points.at(r).time=i.getMotionCurveSegment(t,e+1),this._motionData.points.at(r).value=i.getMotionCurveSegment(t,e+2),this._motionData.points.at(r+1).time=i.getMotionCurveSegment(t,e+3),this._motionData.points.at(r+1).value=i.getMotionCurveSegment(t,e+4),this._motionData.points.at(r+2).time=i.getMotionCurveSegment(t,e+5),this._motionData.points.at(r+2).value=i.getMotionCurveSegment(t,e+6),r+=3,e+=7;break;case Vt.CubismMotionSegmentType_Stepped:this._motionData.segments.at(a).segmentType=Vt.CubismMotionSegmentType_Stepped,this._motionData.segments.at(a).evaluate=$t,this._motionData.points.at(r).time=i.getMotionCurveSegment(t,e+1),this._motionData.points.at(r).value=i.getMotionCurveSegment(t,e+2),r+=1,e+=3;break;case Vt.CubismMotionSegmentType_InverseStepped:this._motionData.segments.at(a).segmentType=Vt.CubismMotionSegmentType_InverseStepped,this._motionData.segments.at(a).evaluate=Jt,this._motionData.points.at(r).time=i.getMotionCurveSegment(t,e+1),this._motionData.points.at(r).value=i.getMotionCurveSegment(t,e+2),r+=1,e+=3;break;default:G(0)}++this._motionData.curves.at(t).segmentCount,++a}}for(let t=0;t<i.getEventCount();++t)this._motionData.events.at(t).fireTime=i.getEventTime(t),this._motionData.events.at(t).value=i.getEventValue(t);i.release(),i=void 0,i=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 c(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==bt.CubismMotionCurveTarget_Model&&0==e.id.getString().s.localeCompare(Xt))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==bt.CubismMotionCurveTarget_Model&&0==e.id.getString().s.localeCompare(Xt))return t}return-1}getModelOpacityId(t){if(-1!=t){const e=this._motionData.curves.at(t);if(e.type==bt.CubismMotionCurveTarget_Model&&0==e.id.getString().s.localeCompare(Xt))return O.getIdManager().getId(e.id.getString().s)}return null}getModelOpacityValue(){return this._modelOpac