n?o:n,s=a>s?a:s,o=t[6],a=t[7],e=on?o:n,s=a>s?a:s,this.minX=e,this.minY=i,this.maxX=n,this.maxY=s},r.prototype.addFrame=function(t,e,i,n,s){this.addFrameMatrix(t.worldTransform,e,i,n,s)},r.prototype.addFrameMatrix=function(t,e,i,n,s){var o=t.a,a=t.b,l=t.c,u=t.d,c=t.tx,h=t.ty,p=this.minX,f=this.minY,y=this.maxX,g=this.maxY,d=o*e+l*i+c,m=a*e+u*i+h;p=dy?d:y,g=m>g?m:g,d=o*n+l*i+c,m=a*n+u*i+h,p=d
y?d:y,g=m>g?m:g,d=o*e+l*s+c,m=a*e+u*s+h,p=d
y?d:y,g=m>g?m:g,d=o*n+l*s+c,m=a*n+u*s+h,p=d
y?d:y,g=m>g?m:g,this.minX=p,this.minY=f,this.maxX=y,this.maxY=g},r.prototype.addVertexData=function(t,e,i){for(var n=this.minX,s=this.minY,o=this.maxX,a=this.maxY,l=e;lo?u:o,a=c>a?c:a}this.minX=n,this.minY=s,this.maxX=o,this.maxY=a},r.prototype.addVertices=function(t,e,i,n){this.addVerticesMatrix(t.worldTransform,e,i,n)},r.prototype.addVerticesMatrix=function(t,e,i,n,s,o){s===void 0&&(s=0),o===void 0&&(o=s);for(var a=t.a,l=t.b,u=t.c,c=t.d,h=t.tx,p=t.ty,f=this.minX,y=this.minY,g=this.maxX,d=this.maxY,m=i;mn?t.maxX:n,this.maxY=t.maxY>s?t.maxY:s},r.prototype.addBoundsMask=function(t,e){var i=t.minX>e.minX?t.minX:e.minX,n=t.minY>e.minY?t.minY:e.minY,s=t.maxXu?s:u,this.maxY=o>c?o:c}},r.prototype.addBoundsMatrix=function(t,e){this.addFrameMatrix(e,t.minX,t.minY,t.maxX,t.maxY)},r.prototype.addBoundsArea=function(t,e){var i=t.minX>e.x?t.minX:e.x,n=t.minY>e.y?t.minY:e.y,s=t.maxXu?s:u,this.maxY=o>c?o:c}},r.prototype.pad=function(t,e){t===void 0&&(t=0),e===void 0&&(e=t),this.isEmpty()||(this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e)},r.prototype.addFramePad=function(t,e,i,n,s,o){t-=s,e-=o,i+=s,n+=o,this.minX=this.minXi?this.maxX:i,this.minY=this.minYn?this.maxY:n},r}();/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
@@ -556,32 +556,32 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
-***************************************************************************** */var pc=function(r,t){return pc=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var n in i)i.hasOwnProperty(n)&&(e[n]=i[n])},pc(r,t)};function $h(r,t){pc(r,t);function e(){this.constructor=r}r.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var Go=function(r){$h(t,r);function t(){var e=r.call(this)||this;return e.tempDisplayObjectParent=null,e.transform=new Bg,e.alpha=1,e.visible=!0,e.renderable=!0,e.cullable=!1,e.cullArea=null,e.parent=null,e.worldAlpha=1,e._lastSortedIndex=0,e._zIndex=0,e.filterArea=null,e.filters=null,e._enabledFilters=null,e._bounds=new $d,e._localBounds=null,e._boundsID=0,e._boundsRect=null,e._localBoundsRect=null,e._mask=null,e._maskRefCount=0,e._destroyed=!1,e.isSprite=!1,e.isMask=!1,e}return t.mixin=function(e){for(var i=Object.keys(e),n=0;n1)for(var s=0;sthis.children.length)throw new Error(e+"addChildAt: The index "+i+" supplied is out of bounds "+this.children.length);return e.parent&&e.parent.removeChild(e),e.parent=this,this.sortDirty=!0,e.transform._parentID=-1,this.children.splice(i,0,e),this._boundsID++,this.onChildrenChange(i),e.emit("added",this),this.emit("childAdded",e,this,i),e},t.prototype.swapChildren=function(e,i){if(e!==i){var n=this.getChildIndex(e),s=this.getChildIndex(i);this.children[n]=i,this.children[s]=e,this.onChildrenChange(n=this.children.length)throw new Error("The index "+i+" supplied is out of bounds "+this.children.length);var n=this.getChildIndex(e);Ba(this.children,n,1),this.children.splice(i,0,e),this.onChildrenChange(i)},t.prototype.getChildAt=function(e){if(e<0||e>=this.children.length)throw new Error("getChildAt: Index ("+e+") does not exist.");return this.children[e]},t.prototype.removeChild=function(){for(var e=arguments,i=[],n=0;n1)for(var s=0;s0&&o<=s){a=this.children.splice(n,o);for(var l=0;l1&&this.children.sort(R1),this.sortDirty=!1},t.prototype.updateTransform=function(){this.sortableChildren&&this.sortDirty&&this.sortChildren(),this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha;for(var e=0,i=this.children.length;e0&&i.height>0){var n,s;if(this.cullArea?(n=this.cullArea,s=this.worldTransform):this._render!==t.prototype._render&&(n=this.getBounds(!0)),n&&i.intersects(n,s))this._render(e);else if(this.cullArea)return;for(var o=0,a=this.children.length;o1)for(var s=0;sthis.children.length)throw new Error(e+"addChildAt: The index "+i+" supplied is out of bounds "+this.children.length);return e.parent&&e.parent.removeChild(e),e.parent=this,this.sortDirty=!0,e.transform._parentID=-1,this.children.splice(i,0,e),this._boundsID++,this.onChildrenChange(i),e.emit("added",this),this.emit("childAdded",e,this,i),e},t.prototype.swapChildren=function(e,i){if(e!==i){var n=this.getChildIndex(e),s=this.getChildIndex(i);this.children[n]=i,this.children[s]=e,this.onChildrenChange(n=this.children.length)throw new Error("The index "+i+" supplied is out of bounds "+this.children.length);var n=this.getChildIndex(e);za(this.children,n,1),this.children.splice(i,0,e),this.onChildrenChange(i)},t.prototype.getChildAt=function(e){if(e<0||e>=this.children.length)throw new Error("getChildAt: Index ("+e+") does not exist.");return this.children[e]},t.prototype.removeChild=function(){for(var e=arguments,i=[],n=0;n1)for(var s=0;s0&&o<=s){a=this.children.splice(n,o);for(var l=0;l1&&this.children.sort(G1),this.sortDirty=!1},t.prototype.updateTransform=function(){this.sortableChildren&&this.sortDirty&&this.sortChildren(),this._boundsID++,this.transform.updateTransform(this.parent.transform),this.worldAlpha=this.alpha*this.parent.worldAlpha;for(var e=0,i=this.children.length;e0&&i.height>0){var n,s;if(this.cullArea?(n=this.cullArea,s=this.worldTransform):this._render!==t.prototype._render&&(n=this.getBounds(!0)),n&&i.intersects(n,s))this._render(e);else if(this.cullArea)return;for(var o=0,a=this.children.length;onew Promise((i,n)=>{var s=l=>{try{a(e.next(l))}catch(u){n(u)}},o=l=>{try{a(e.throw(l))}catch(u){n(u)}},a=l=>l.done?i(l.value):Promise.resolve(l.value).then(s,o);a((e=e.apply(r,t)).next())});class Vh{constructor(){this._breathParameters=[],this._currentTime=0}static create(){return new Vh}setParameters(t){this._breathParameters=t}getParameters(){return this._breathParameters}updateParameters(t,e){this._currentTime+=e;const i=this._currentTime*2*3.14159;for(let n=0;n=1&&(i=1,this._blinkingState=Rr.EyeState_Closed,this._stateStartTimeSeconds=this._userTimeSeconds),e=1-i;break;case Rr.EyeState_Closed:i=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._closedSeconds,i>=1&&(this._blinkingState=Rr.EyeState_Opening,this._stateStartTimeSeconds=this._userTimeSeconds),e=0;break;case Rr.EyeState_Opening:i=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._openingSeconds,i>=1&&(i=1,this._blinkingState=Rr.EyeState_Interval,this._nextBlinkingTime=this.determinNextBlinkingTiming()),e=i;break;case Rr.EyeState_Interval:this._nextBlinkingTime(r[r.EyeState_First=0]="EyeState_First",r[r.EyeState_Interval=1]="EyeState_Interval",r[r.EyeState_Closing=2]="EyeState_Closing",r[r.EyeState_Closed=3]="EyeState_Closed",r[r.EyeState_Opening=4]="EyeState_Opening",r))(Rr||{});const B1=.001,Vd=.5;class Gh{static create(t){const e=new Gh;typeof t.FadeInTime=="number"&&(e._fadeTimeSeconds=t.FadeInTime,e._fadeTimeSeconds<=0&&(e._fadeTimeSeconds=Vd));const i=t.Groups,n=i.length;for(let s=0;sB1){if(s>=0)break;s=u,o=t.getPartOpacityByIndex(c),o+=e/this._fadeTimeSeconds,o>1&&(o=1)}}s<0&&(s=0,o=1);for(let u=i;ul&&(p=1-l/(1-o)),h>p&&(h=p),t.setPartOpacityByIndex(c,h)}}}constructor(){this._fadeTimeSeconds=Vd,this._lastModel=void 0,this._partGroups=[],this._partGroupCounts=[]}}class il{constructor(t){this.parameterIndex=0,this.partIndex=0,this.partId="",this.link=[],t!=null&&this.assignment(t)}assignment(t){return this.partId=t.partId,this.link=t.link.map(e=>e.clone()),this}initialize(t){this.parameterIndex=t.getParameterIndex(this.partId),this.partIndex=t.getPartIndex(this.partId),t.setParameterValueByIndex(this.parameterIndex,1)}clone(){const t=new il;return t.partId=this.partId,t.parameterIndex=this.parameterIndex,t.partIndex=this.partIndex,t.link=this.link.map(e=>e.clone()),t}}class te{constructor(t,e){this.x=t||0,this.y=e||0}add(t){const e=new te(0,0);return e.x=this.x+t.x,e.y=this.y+t.y,e}substract(t){const e=new te(0,0);return e.x=this.x-t.x,e.y=this.y-t.y,e}multiply(t){const e=new te(0,0);return e.x=this.x*t.x,e.y=this.y*t.y,e}multiplyByScaler(t){return this.multiply(new te(t,t))}division(t){const e=new te(0,0);return e.x=this.x/t.x,e.y=this.y/t.y,e}divisionByScalar(t){return this.division(new te(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)}}const ka=class{static range(r,t,e){return re&&(r=e),r}static sin(r){return Math.sin(r)}static cos(r){return Math.cos(r)}static abs(r){return Math.abs(r)}static sqrt(r){return Math.sqrt(r)}static cbrt(r){if(r===0)return r;let t=r;const e=t<0;e&&(t=-t);let i;return t===1/0?i=1/0:(i=Math.exp(Math.log(t)/3),i=(t/(i*i)+2*i)/3),e?-i:i}static getEasingSine(r){return r<0?0:r>1?1:.5-.5*this.cos(r*Math.PI)}static max(r,t){return r>t?r:t}static min(r,t){return r>t?t:r}static degreesToRadian(r){return r/180*Math.PI}static radianToDegrees(r){return r*180/Math.PI}static directionToRadian(r,t){const e=Math.atan2(t.y,t.x),i=Math.atan2(r.y,r.x);let n=e-i;for(;n<-Math.PI;)n+=Math.PI*2;for(;n>Math.PI;)n-=Math.PI*2;return n}static directionToDegrees(r,t){const e=this.directionToRadian(r,t);let i=this.radianToDegrees(e);return t.x-r.x>0&&(i=-i),i}static radianToDirection(r){const t=new te;return t.x=this.sin(r),t.y=this.cos(r),t}static quadraticEquation(r,t,e){return this.abs(r)1&&(t=1),e<0?e=0:e>1&&(e=1),i<0?i=0:i>1&&(i=1),n<0?n=0:n>1&&(n=1),this._modelColor.R=t,this._modelColor.G=e,this._modelColor.B=i,this._modelColor.A=n}getModelColor(){return Object.assign({},this._modelColor)}setIsPremultipliedAlpha(t){this._isPremultipliedAlpha=t}isPremultipliedAlpha(){return this._isPremultipliedAlpha}setIsCulling(t){this._isCulling=t}isCulling(){return this._isCulling}setAnisotropy(t){this._anisortopy=t}getAnisotropy(){return this._anisortopy}getModel(){return this._model}constructor(){this._isCulling=!1,this._isPremultipliedAlpha=!1,this._anisortopy=0,this._modelColor=new bo,this._mvpMatrix4x4=new $r,this._mvpMatrix4x4.loadIdentity()}}var cn=(r=>(r[r.CubismBlendMode_Normal=0]="CubismBlendMode_Normal",r[r.CubismBlendMode_Additive=1]="CubismBlendMode_Additive",r[r.CubismBlendMode_Multiplicative=2]="CubismBlendMode_Multiplicative",r))(cn||{});class bo{constructor(){this.R=1,this.G=1,this.B=1,this.A=1}}let oi=!1,ms=!1,ys;const ku={vertexOffset:0,vertexStep:2};class Wo{static startUp(t){if(oi)return mo("CubismFramework.startUp() is already done."),oi;if(Live2DCubismCore._isStarted)return oi=!0,!0;if(Live2DCubismCore._isStarted=!0,ys=t,ys&&Live2DCubismCore.Logging.csmSetLogFunction(ys.logFunction),oi=!0,oi){const e=Live2DCubismCore.Version.csmGetVersion(),i=(e&4278190080)>>24,n=(e&16711680)>>16,s=e&65535,o=e;mo("Live2D Cubism Core version: {0}.{1}.{2} ({3})",("00"+i).slice(-2),("00"+n).slice(-2),("0000"+s).slice(-4),o)}return mo("CubismFramework.startUp() is complete."),oi}static cleanUp(){oi=!1,ms=!1,ys=void 0}static initialize(){if(!oi){wo("CubismFramework is not started.");return}if(ms){wo("CubismFramework.initialize() skipped, already initialized.");return}ms=!0,mo("CubismFramework.initialize() is complete.")}static dispose(){if(!oi){wo("CubismFramework is not started.");return}if(!ms){wo("CubismFramework.dispose() skipped, not initialized.");return}Wh.staticRelease(),ms=!1,mo("CubismFramework.dispose() is complete.")}static isStarted(){return oi}static isInitialized(){return ms}static coreLogFunction(t){Live2DCubismCore.Logging.csmGetLogFunction()&&Live2DCubismCore.Logging.csmGetLogFunction()(t)}static getLoggingLevel(){return ys!=null?ys.loggingLevel:ls.LogLevel_Off}constructor(){}}var ls=(r=>(r[r.LogLevel_Verbose=0]="LogLevel_Verbose",r[r.LogLevel_Debug=1]="LogLevel_Debug",r[r.LogLevel_Info=2]="LogLevel_Info",r[r.LogLevel_Warning=3]="LogLevel_Warning",r[r.LogLevel_Error=4]="LogLevel_Error",r[r.LogLevel_Off=5]="LogLevel_Off",r))(ls||{});const Fa=()=>{};function Gd(r,...t){Kl.print(ls.LogLevel_Debug,"[CSM][D]"+r+`
-`,t)}function mo(r,...t){Kl.print(ls.LogLevel_Info,"[CSM][I]"+r+`
-`,t)}function wo(r,...t){Kl.print(ls.LogLevel_Warning,"[CSM][W]"+r+`
-`,t)}function bs(r,...t){Kl.print(ls.LogLevel_Error,"[CSM][E]"+r+`
-`,t)}class Kl{static print(t,e,i){if(ti[a]);n(s)}static dumpBytes(t,e,i){for(let n=0;n0?this.print(t,`
+ */var W1=function(){function r(){}return r.init=function(t){var e=this;Object.defineProperty(this,"resizeTo",{set:function(i){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=i,i&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get:function(){return this._resizeTo}}),this.queueResize=function(){e._resizeTo&&(e.cancelResize(),e._resizeId=requestAnimationFrame(function(){return e.resize()}))},this.cancelResize=function(){e._resizeId&&(cancelAnimationFrame(e._resizeId),e._resizeId=null)},this.resize=function(){if(e._resizeTo){e.cancelResize();var i,n;if(e._resizeTo===globalThis.window)i=globalThis.innerWidth,n=globalThis.innerHeight;else{var s=e._resizeTo,o=s.clientWidth,a=s.clientHeight;i=o,n=a}e.renderer.resize(i,n)}},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null},r.destroy=function(){globalThis.removeEventListener("resize",this.queueResize),this.cancelResize(),this.cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null},r.extension=Hr.Application,r}(),H1=function(){function r(t){var e=this;this.stage=new nl,t=Object.assign({forceCanvas:!1},t),this.renderer=D1(t),r._plugins.forEach(function(i){i.init.call(e,t)})}return r.registerPlugin=function(t){ts("6.5.0","Application.registerPlugin() is deprecated, use extensions.add()"),la.add({type:Hr.Application,ref:t})},r.prototype.render=function(){this.renderer.render(this.stage)},Object.defineProperty(r.prototype,"view",{get:function(){return this.renderer.view},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"screen",{get:function(){return this.renderer.screen},enumerable:!1,configurable:!0}),r.prototype.destroy=function(t,e){var i=this,n=r._plugins.slice(0);n.reverse(),n.forEach(function(s){s.destroy.call(i)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null},r._plugins=[],r}();la.handleByList(Hr.Application,H1._plugins);la.add(W1);var Mn=Math.pow,Fe=(r,t,e)=>new Promise((i,n)=>{var s=l=>{try{a(e.next(l))}catch(u){n(u)}},o=l=>{try{a(e.throw(l))}catch(u){n(u)}},a=l=>l.done?i(l.value):Promise.resolve(l.value).then(s,o);a((e=e.apply(r,t)).next())});class Hh{constructor(){this._breathParameters=[],this._currentTime=0}static create(){return new Hh}setParameters(t){this._breathParameters=t}getParameters(){return this._breathParameters}updateParameters(t,e){this._currentTime+=e;const i=this._currentTime*2*3.14159;for(let n=0;n=1&&(i=1,this._blinkingState=Nr.EyeState_Closed,this._stateStartTimeSeconds=this._userTimeSeconds),e=1-i;break;case Nr.EyeState_Closed:i=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._closedSeconds,i>=1&&(this._blinkingState=Nr.EyeState_Opening,this._stateStartTimeSeconds=this._userTimeSeconds),e=0;break;case Nr.EyeState_Opening:i=(this._userTimeSeconds-this._stateStartTimeSeconds)/this._openingSeconds,i>=1&&(i=1,this._blinkingState=Nr.EyeState_Interval,this._nextBlinkingTime=this.determinNextBlinkingTiming()),e=i;break;case Nr.EyeState_Interval:this._nextBlinkingTime(r[r.EyeState_First=0]="EyeState_First",r[r.EyeState_Interval=1]="EyeState_Interval",r[r.EyeState_Closing=2]="EyeState_Closing",r[r.EyeState_Closed=3]="EyeState_Closed",r[r.EyeState_Opening=4]="EyeState_Opening",r))(Nr||{});const Y1=.001,Wd=.5;class Yh{static create(t){const e=new Yh;typeof t.FadeInTime=="number"&&(e._fadeTimeSeconds=t.FadeInTime,e._fadeTimeSeconds<=0&&(e._fadeTimeSeconds=Wd));const i=t.Groups,n=i.length;for(let s=0;sY1){if(s>=0)break;s=u,o=t.getPartOpacityByIndex(c),o+=e/this._fadeTimeSeconds,o>1&&(o=1)}}s<0&&(s=0,o=1);for(let u=i;ul&&(p=1-l/(1-o)),h>p&&(h=p),t.setPartOpacityByIndex(c,h)}}}constructor(){this._fadeTimeSeconds=Wd,this._lastModel=void 0,this._partGroups=[],this._partGroupCounts=[]}}class sl{constructor(t){this.parameterIndex=0,this.partIndex=0,this.partId="",this.link=[],t!=null&&this.assignment(t)}assignment(t){return this.partId=t.partId,this.link=t.link.map(e=>e.clone()),this}initialize(t){this.parameterIndex=t.getParameterIndex(this.partId),this.partIndex=t.getPartIndex(this.partId),t.setParameterValueByIndex(this.parameterIndex,1)}clone(){const t=new sl;return t.partId=this.partId,t.parameterIndex=this.parameterIndex,t.partIndex=this.partIndex,t.link=this.link.map(e=>e.clone()),t}}class te{constructor(t,e){this.x=t||0,this.y=e||0}add(t){const e=new te(0,0);return e.x=this.x+t.x,e.y=this.y+t.y,e}substract(t){const e=new te(0,0);return e.x=this.x-t.x,e.y=this.y-t.y,e}multiply(t){const e=new te(0,0);return e.x=this.x*t.x,e.y=this.y*t.y,e}multiplyByScaler(t){return this.multiply(new te(t,t))}division(t){const e=new te(0,0);return e.x=this.x/t.x,e.y=this.y/t.y,e}divisionByScalar(t){return this.division(new te(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)}}const ja=class{static range(r,t,e){return re&&(r=e),r}static sin(r){return Math.sin(r)}static cos(r){return Math.cos(r)}static abs(r){return Math.abs(r)}static sqrt(r){return Math.sqrt(r)}static cbrt(r){if(r===0)return r;let t=r;const e=t<0;e&&(t=-t);let i;return t===1/0?i=1/0:(i=Math.exp(Math.log(t)/3),i=(t/(i*i)+2*i)/3),e?-i:i}static getEasingSine(r){return r<0?0:r>1?1:.5-.5*this.cos(r*Math.PI)}static max(r,t){return r>t?r:t}static min(r,t){return r>t?t:r}static degreesToRadian(r){return r/180*Math.PI}static radianToDegrees(r){return r*180/Math.PI}static directionToRadian(r,t){const e=Math.atan2(t.y,t.x),i=Math.atan2(r.y,r.x);let n=e-i;for(;n<-Math.PI;)n+=Math.PI*2;for(;n>Math.PI;)n-=Math.PI*2;return n}static directionToDegrees(r,t){const e=this.directionToRadian(r,t);let i=this.radianToDegrees(e);return t.x-r.x>0&&(i=-i),i}static radianToDirection(r){const t=new te;return t.x=this.sin(r),t.y=this.cos(r),t}static quadraticEquation(r,t,e){return this.abs(r)1&&(t=1),e<0?e=0:e>1&&(e=1),i<0?i=0:i>1&&(i=1),n<0?n=0:n>1&&(n=1),this._modelColor.R=t,this._modelColor.G=e,this._modelColor.B=i,this._modelColor.A=n}getModelColor(){return Object.assign({},this._modelColor)}setIsPremultipliedAlpha(t){this._isPremultipliedAlpha=t}isPremultipliedAlpha(){return this._isPremultipliedAlpha}setIsCulling(t){this._isCulling=t}isCulling(){return this._isCulling}setAnisotropy(t){this._anisortopy=t}getAnisotropy(){return this._anisortopy}getModel(){return this._model}constructor(){this._isCulling=!1,this._isPremultipliedAlpha=!1,this._anisortopy=0,this._modelColor=new So,this._mvpMatrix4x4=new $r,this._mvpMatrix4x4.loadIdentity()}}var fn=(r=>(r[r.CubismBlendMode_Normal=0]="CubismBlendMode_Normal",r[r.CubismBlendMode_Additive=1]="CubismBlendMode_Additive",r[r.CubismBlendMode_Multiplicative=2]="CubismBlendMode_Multiplicative",r))(fn||{});class So{constructor(){this.R=1,this.G=1,this.B=1,this.A=1}}let ai=!1,gs=!1,vs;const ju={vertexOffset:0,vertexStep:2};class Xo{static startUp(t){if(ai)return vo("CubismFramework.startUp() is already done."),ai;if(Live2DCubismCore._isStarted)return ai=!0,!0;if(Live2DCubismCore._isStarted=!0,vs=t,vs&&Live2DCubismCore.Logging.csmSetLogFunction(vs.logFunction),ai=!0,ai){const e=Live2DCubismCore.Version.csmGetVersion(),i=(e&4278190080)>>24,n=(e&16711680)>>16,s=e&65535,o=e;vo("Live2D Cubism Core version: {0}.{1}.{2} ({3})",("00"+i).slice(-2),("00"+n).slice(-2),("0000"+s).slice(-4),o)}return vo("CubismFramework.startUp() is complete."),ai}static cleanUp(){ai=!1,gs=!1,vs=void 0}static initialize(){if(!ai){To("CubismFramework is not started.");return}if(gs){To("CubismFramework.initialize() skipped, already initialized.");return}gs=!0,vo("CubismFramework.initialize() is complete.")}static dispose(){if(!ai){To("CubismFramework is not started.");return}if(!gs){To("CubismFramework.dispose() skipped, not initialized.");return}Xh.staticRelease(),gs=!1,vo("CubismFramework.dispose() is complete.")}static isStarted(){return ai}static isInitialized(){return gs}static coreLogFunction(t){Live2DCubismCore.Logging.csmGetLogFunction()&&Live2DCubismCore.Logging.csmGetLogFunction()(t)}static getLoggingLevel(){return vs!=null?vs.loggingLevel:cs.LogLevel_Off}constructor(){}}var cs=(r=>(r[r.LogLevel_Verbose=0]="LogLevel_Verbose",r[r.LogLevel_Debug=1]="LogLevel_Debug",r[r.LogLevel_Info=2]="LogLevel_Info",r[r.LogLevel_Warning=3]="LogLevel_Warning",r[r.LogLevel_Error=4]="LogLevel_Error",r[r.LogLevel_Off=5]="LogLevel_Off",r))(cs||{});const Da=()=>{};function Hd(r,...t){Jl.print(cs.LogLevel_Debug,"[CSM][D]"+r+`
+`,t)}function vo(r,...t){Jl.print(cs.LogLevel_Info,"[CSM][I]"+r+`
+`,t)}function To(r,...t){Jl.print(cs.LogLevel_Warning,"[CSM][W]"+r+`
+`,t)}function xs(r,...t){Jl.print(cs.LogLevel_Error,"[CSM][E]"+r+`
+`,t)}class Jl{static print(t,e,i){if(ti[a]);n(s)}static dumpBytes(t,e,i){for(let n=0;n0?this.print(t,`
`):n%8==0&&n>0&&this.print(t," "),this.print(t,"{0} ",[e[n]&255]);this.print(t,`
-`)}constructor(){}}class k1{update(){this._model.update(),this._model.drawables.resetDynamicFlags()}getCanvasWidth(){return this._model==null?0:this._model.canvasinfo.CanvasWidth/this._model.canvasinfo.PixelsPerUnit}getCanvasHeight(){return this._model==null?0:this._model.canvasinfo.CanvasHeight/this._model.canvasinfo.PixelsPerUnit}saveParameters(){const t=this._model.parameters.count,e=this._savedParameters.length;for(let i=0;ie&&(e=this._model.parameters.minimumValues[t]),this._parameterValues[t]=i==1?e:this._parameterValues[t]=this._parameterValues[t]*(1-i)+e*i}setParameterValueById(t,e,i=1){const n=this.getParameterIndex(t);this.setParameterValueByIndex(n,e,i)}addParameterValueByIndex(t,e,i=1){this.setParameterValueByIndex(t,this.getParameterValueByIndex(t)+e*i)}addParameterValueById(t,e,i=1){const n=this.getParameterIndex(t);this.addParameterValueByIndex(n,e,i)}multiplyParameterValueById(t,e,i=1){const n=this.getParameterIndex(t);this.multiplyParameterValueByIndex(n,e,i)}multiplyParameterValueByIndex(t,e,i=1){this.setParameterValueByIndex(t,this.getParameterValueByIndex(t)*(1+(e-1)*i))}getDrawableIds(){return this._drawableIds.slice()}getDrawableIndex(t){const e=this._model.drawables.count;for(let i=0;ie&&(t=e);for(let i=0;i0&&e.getEndTime()(r[r.ExpressionBlendType_Add=0]="ExpressionBlendType_Add",r[r.ExpressionBlendType_Multiply=1]="ExpressionBlendType_Multiply",r[r.ExpressionBlendType_Overwrite=2]="ExpressionBlendType_Overwrite",r))(Bn||{}),Ho;(r=>{r.supportMoreMaskDivisions=!0,r.setOpacityFromMotion=!1})(Ho||(Ho={}));var kn=(r=>(r[r.CubismMotionCurveTarget_Model=0]="CubismMotionCurveTarget_Model",r[r.CubismMotionCurveTarget_Parameter=1]="CubismMotionCurveTarget_Parameter",r[r.CubismMotionCurveTarget_PartOpacity=2]="CubismMotionCurveTarget_PartOpacity",r))(kn||{}),li=(r=>(r[r.CubismMotionSegmentType_Linear=0]="CubismMotionSegmentType_Linear",r[r.CubismMotionSegmentType_Bezier=1]="CubismMotionSegmentType_Bezier",r[r.CubismMotionSegmentType_Stepped=2]="CubismMotionSegmentType_Stepped",r[r.CubismMotionSegmentType_InverseStepped=3]="CubismMotionSegmentType_InverseStepped",r))(li||{});class nn{constructor(t=0,e=0){this.time=t,this.value=e}}class U1{constructor(){this.basePointIndex=0,this.segmentType=0}}class z1{constructor(){this.id="",this.type=0,this.segmentCount=0,this.baseSegmentIndex=0,this.fadeInTime=0,this.fadeOutTime=0}}class j1{constructor(){this.fireTime=0,this.value=""}}class $1{constructor(){this.duration=0,this.loop=!1,this.curveCount=0,this.eventCount=0,this.fps=0,this.curves=[],this.segments=[],this.points=[],this.events=[]}}class ev{constructor(t){this._json=t}release(){this._json=void 0}getMotionDuration(){return this._json.Meta.Duration}isMotionLoop(){return this._json.Meta.Loop||!1}getEvaluationOptionFlag(t){return Yh.EvaluationOptionFlag_AreBeziersRistricted==t?!!this._json.Meta.AreBeziersRestricted:!1}getMotionCurveCount(){return this._json.Meta.CurveCount}getMotionFps(){return this._json.Meta.Fps}getMotionTotalSegmentCount(){return this._json.Meta.TotalSegmentCount}getMotionTotalPointCount(){return this._json.Meta.TotalPointCount}getMotionFadeInTime(){return this._json.Meta.FadeInTime}getMotionFadeOutTime(){return this._json.Meta.FadeOutTime}getMotionCurveTarget(t){return this._json.Curves[t].Target}getMotionCurveId(t){return this._json.Curves[t].Id}getMotionCurveFadeInTime(t){return this._json.Curves[t].FadeInTime}getMotionCurveFadeOutTime(t){return this._json.Curves[t].FadeOutTime}getMotionCurveSegmentCount(t){return this._json.Curves[t].Segments.length}getMotionCurveSegment(t,e){return this._json.Curves[t].Segments[e]}getEventCount(){return this._json.Meta.UserDataCount||0}getTotalEventValueSize(){return this._json.Meta.TotalUserDataSize}getEventTime(t){return this._json.UserData[t].Time}getEventValue(t){return this._json.UserData[t].Value}}var Yh=(r=>(r[r.EvaluationOptionFlag_AreBeziersRistricted=0]="EvaluationOptionFlag_AreBeziersRistricted",r))(Yh||{});const V1="EyeBlink",G1="LipSync",W1="Model",H1="Parameter",X1="PartOpacity",Y1=!1;function Ur(r,t,e){const i=new nn;return i.time=r.time+(t.time-r.time)*e,i.value=r.value+(t.value-r.value)*e,i}function q1(r,t){let e=(t-r[0].time)/(r[1].time-r[0].time);return e<0&&(e=0),r[0].value+(r[1].value-r[0].value)*e}function Q1(r,t){let e=(t-r[0].time)/(r[3].time-r[0].time);e<0&&(e=0);const i=Ur(r[0],r[1],e),n=Ur(r[1],r[2],e),s=Ur(r[2],r[3],e),o=Ur(i,n,e),a=Ur(n,s,e);return Ur(o,a,e).value}function K1(r,t){const e=t,i=r[0].time,n=r[3].time,s=r[1].time,o=r[2].time,a=n-3*o+3*s-i,l=3*o-6*s+3*i,u=3*s-3*i,c=i-e,h=Te.cardanoAlgorithmForBezier(a,l,u,c),p=Ur(r[0],r[1],h),f=Ur(r[1],r[2],h),y=Ur(r[2],r[3],h),g=Ur(p,f,h),d=Ur(f,y,h);return Ur(g,d,h).value}function Z1(r,t){return r[0].value}function J1(r,t){return r[1].value}function Uu(r,t,e){const i=r.curves[t];let n=-1;const s=i.baseSegmentIndex+i.segmentCount;let o=0;for(let l=i.baseSegmentIndex;le){n=l;break}if(n==-1)return r.points[o].value;const a=r.segments[n];return a.evaluate(r.points.slice(a.basePointIndex),e)}class qh extends tv{constructor(){super(),this._eyeBlinkParameterIds=[],this._lipSyncParameterIds=[],this._sourceFrameRate=30,this._loopDurationSeconds=-1,this._isLoop=!1,this._isLoopFadeIn=!0,this._lastWeight=0}static create(t,e){const i=new qh;return i.parse(t),i._sourceFrameRate=i._motionData.fps,i._loopDurationSeconds=i._motionData.duration,i._onFinishedMotion=e,i}doUpdateParameters(t,e,i,n){this._modelCurveIdEyeBlink==null&&(this._modelCurveIdEyeBlink=V1),this._modelCurveIdLipSync==null&&(this._modelCurveIdLipSync=G1);let s=e-n.getStartTime();s<0&&(s=0);let o=Number.MAX_VALUE,a=Number.MAX_VALUE;const l=64;let u=0,c=0;this._eyeBlinkParameterIds.length>l&&Gd("too many eye blink targets : {0}",this._eyeBlinkParameterIds.length),this._lipSyncParameterIds.length>l&&Gd("too many lip sync targets : {0}",this._lipSyncParameterIds.length);const h=this._fadeInSeconds<=0?1:Te.getEasingSine((e-n.getFadeInStartTime())/this._fadeInSeconds),p=this._fadeOutSeconds<=0||n.getEndTime()<0?1:Te.getEasingSine((n.getEndTime()-e)/this._fadeOutSeconds);let f,y,g,d=s;if(this._isLoop)for(;d>this._motionData.duration;)d-=this._motionData.duration;const m=this._motionData.curves;for(y=0;y>_&1)continue;const E=S+(a-S)*i;t.setParameterValueById(this._eyeBlinkParameterIds[_],E)}if(o!=Number.MAX_VALUE)for(let _=0;_>_&1)continue;const E=S+(o-S)*i;t.setParameterValueById(this._lipSyncParameterIds[_],E)}}for(;y=this._motionData.duration&&(this._isLoop?(n.setStartTime(e),this._isLoopFadeIn&&n.setFadeInStartTime(e)):(this._onFinishedMotion&&this._onFinishedMotion(this),n.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 n=0;nnew z1),this._motionData.segments=Array.from({length:e.getMotionTotalSegmentCount()}).map(()=>new U1),this._motionData.events=Array.from({length:this._motionData.eventCount}).map(()=>new j1),this._motionData.points=[];let o=0,a=0;for(let l=0;lt&&this._motionData.events[i].fireTime<=e&&this._firedEventValues.push(this._motionData.events[i].value);return this._firedEventValues}}class tT{constructor(){this._autoDelete=!1,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&&this._motion.release()}setFadeOut(t){this._fadeOutSeconds=t,this._isTriggeredFadeOut=!0}startFadeOut(t,e){const i=e+t;this._isTriggeredFadeOut=!0,(this._endTimeSeconds<0||ie!=null&&e._motionQueueEntryHandle==t)}setEventCallback(t,e=null){this._eventCallBack=t,this._eventCustomData=e}doUpdateMotion(t,e){let i=!1,n=0;for(;n(r[r.CubismPhysicsTargetType_Parameter=0]="CubismPhysicsTargetType_Parameter",r))(yc||{}),Un=(r=>(r[r.CubismPhysicsSource_X=0]="CubismPhysicsSource_X",r[r.CubismPhysicsSource_Y=1]="CubismPhysicsSource_Y",r[r.CubismPhysicsSource_Angle=2]="CubismPhysicsSource_Angle",r))(Un||{});class rT{constructor(){this.initialPosition=new te(0,0),this.position=new te(0,0),this.lastPosition=new te(0,0),this.lastGravity=new te(0,0),this.force=new te(0,0),this.velocity=new te(0,0)}}class iT{constructor(){this.normalizationPosition={},this.normalizationAngle={}}}class nT{constructor(){this.source={}}}class sT{constructor(){this.destination={},this.translationScale=new te(0,0)}}class oT{constructor(){this.settings=[],this.inputs=[],this.outputs=[],this.particles=[],this.gravity=new te(0,0),this.wind=new te(0,0)}}class aT{constructor(t){this._json=t}release(){this._json=void 0}getGravity(){const t=new te(0,0);return t.x=this._json.Meta.EffectiveForces.Gravity.X,t.y=this._json.Meta.EffectiveForces.Gravity.Y,t}getWind(){const t=new te(0,0);return t.x=this._json.Meta.EffectiveForces.Wind.X,t.y=this._json.Meta.EffectiveForces.Wind.Y,t}getSubRigCount(){return this._json.Meta.PhysicsSettingCount}getTotalInputCount(){return this._json.Meta.TotalInputCount}getTotalOutputCount(){return this._json.Meta.TotalOutputCount}getVertexCount(){return this._json.Meta.VertexCount}getNormalizationPositionMinimumValue(t){return this._json.PhysicsSettings[t].Normalization.Position.Minimum}getNormalizationPositionMaximumValue(t){return this._json.PhysicsSettings[t].Normalization.Position.Maximum}getNormalizationPositionDefaultValue(t){return this._json.PhysicsSettings[t].Normalization.Position.Default}getNormalizationAngleMinimumValue(t){return this._json.PhysicsSettings[t].Normalization.Angle.Minimum}getNormalizationAngleMaximumValue(t){return this._json.PhysicsSettings[t].Normalization.Angle.Maximum}getNormalizationAngleDefaultValue(t){return this._json.PhysicsSettings[t].Normalization.Angle.Default}getInputCount(t){return this._json.PhysicsSettings[t].Input.length}getInputWeight(t,e){return this._json.PhysicsSettings[t].Input[e].Weight}getInputReflect(t,e){return this._json.PhysicsSettings[t].Input[e].Reflect}getInputType(t,e){return this._json.PhysicsSettings[t].Input[e].Type}getInputSourceId(t,e){return this._json.PhysicsSettings[t].Input[e].Source.Id}getOutputCount(t){return this._json.PhysicsSettings[t].Output.length}getOutputVertexIndex(t,e){return this._json.PhysicsSettings[t].Output[e].VertexIndex}getOutputAngleScale(t,e){return this._json.PhysicsSettings[t].Output[e].Scale}getOutputWeight(t,e){return this._json.PhysicsSettings[t].Output[e].Weight}getOutputDestinationId(t,e){return this._json.PhysicsSettings[t].Output[e].Destination.Id}getOutputType(t,e){return this._json.PhysicsSettings[t].Output[e].Type}getOutputReflect(t,e){return this._json.PhysicsSettings[t].Output[e].Reflect}getParticleCount(t){return this._json.PhysicsSettings[t].Vertices.length}getParticleMobility(t,e){return this._json.PhysicsSettings[t].Vertices[e].Mobility}getParticleDelay(t,e){return this._json.PhysicsSettings[t].Vertices[e].Delay}getParticleAcceleration(t,e){return this._json.PhysicsSettings[t].Vertices[e].Acceleration}getParticleRadius(t,e){return this._json.PhysicsSettings[t].Vertices[e].Radius}getParticlePosition(t,e){const i=new te(0,0);return i.x=this._json.PhysicsSettings[t].Vertices[e].Position.X,i.y=this._json.PhysicsSettings[t].Vertices[e].Position.Y,i}}const Hd="X",Xd="Y",Yd="Angle",lT=5,iv=100,uT=.001;class Qh{static create(t){const e=new Qh;return e.parse(t),e._physicsRig.gravity.y=0,e}evaluate(t,e){let i,n,s,o;const a=new te;let l,u,c,h,p,f,y,g;p=t.getModel().parameters.values,f=t.getModel().parameters.maximumValues,y=t.getModel().parameters.minimumValues,g=t.getModel().parameters.defaultValues;for(let d=0;d=l.particleCount)break;c[m].destinationParameterIndex==-1&&(c[m].destinationParameterIndex=t.getParameterIndex(c[m].destination.id));const S=new te;S.x=h[_].position.x-h[_-1].position.x,S.y=h[_].position.y-h[_-1].position.y,o=c[m].getValue(S,h,_,c[m].reflect,this._options.gravity);const E=c[m].destinationParameterIndex,b=!Float32Array.prototype.slice&&"subarray"in Float32Array.prototype?JSON.parse(JSON.stringify(p.subarray(E))):p.slice(E);ST(b,y[E],f[E],o,c[m]);for(let F=E,x=0;F=2?n=t[e-1].position.substract(t[e-2].position):n=n.multiplyByScaler(-1),s=Te.directionToRadian(n,r),i&&(s*=-1),s}function gT(r,t){return Math.abs(Math.max(r,t)-Math.min(r,t))}function vT(r,t){return Math.min(r,t)+gT(r,t)/2}function _T(r,t){return r.x}function bT(r,t){return r.y}function wT(r,t){return t}function xT(r,t,e,i,n,s,o,a){let l,u,c,h,p=new te(0,0),f=new te(0,0),y=new te(0,0),g=new te(0,0);r[0].position=new te(e.x,e.y),l=Te.degreesToRadian(i),h=Te.radianToDirection(l),h.normalize();for(let d=1;de&&(o>n.valueExceededMaximum&&(n.valueExceededMaximum=o),o=e),a=n.weight/iv,a>=1||(o=r[0]*(1-a)+o*a),r[0]=o}function Kh(r,t,e,i,n,s,o,a){let l=0;const u=Te.max(e,t);ur&&(r=c);const h=Te.min(n,s),p=Te.max(n,s),f=o,y=vT(c,u),g=r-y;switch(Math.sign(g)){case 1:{const d=p-f,m=u-y;m!=0&&(l=g*(d/m),l+=f);break}case-1:{const d=h-f,m=c-y;m!=0&&(l=g*(d/m),l+=f);break}case 0:{l=f;break}}return a?l:l*-1}class gc{constructor(t=0,e=0,i=0,n=0){this.x=t,this.y=e,this.width=i,this.height=n}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+=t*2,this.height+=e*2}}const zu=4,TT=10;let Pn,xo,vc;class ju{getChannelFlagAsColor(t){return this._channelColors[t]}getMaskRenderTexture(){let t=0;if(this._maskTexture&&this._maskTexture.texture!=0&&(this._maskTexture.frameNo=this._currentFrameNo,t=this._maskTexture.texture),t==0){const e=this._clippingMaskBufferSize;this._colorBuffer=this.gl.createTexture(),this.gl.bindTexture(this.gl.TEXTURE_2D,this._colorBuffer),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,e,e,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),t=this.gl.createFramebuffer(),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,t),this.gl.framebufferTexture2D(this.gl.FRAMEBUFFER,this.gl.COLOR_ATTACHMENT0,this.gl.TEXTURE_2D,this._colorBuffer,0),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,vc),this._maskTexture=new IT(this._currentFrameNo,t)}return t}setGL(t){this.gl=t}calcClippedDrawTotalBounds(t,e){let i=Number.MAX_VALUE,n=Number.MAX_VALUE,s=Number.MIN_VALUE,o=Number.MIN_VALUE;const a=e._clippedDrawableIndexList.length;for(let l=0;ly&&(y=_),Sg&&(g=S)}if(p!=Number.MAX_VALUE)if(ps&&(s=y),g>o&&(o=g),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 m=s-i,_=o-n;e._allClippedDrawRect.x=i,e._allClippedDrawRect.y=n,e._allClippedDrawRect.width=m,e._allClippedDrawRect.height=_}}}constructor(){this._maskRenderTexture=null,this._colorBuffer=null,this._currentFrameNo=0,this._clippingMaskBufferSize=256,this._clippingContextListForMask=[],this._clippingContextListForDraw=[],this._channelColors=[],this._tmpBoundsOnModel=new gc,this._tmpMatrix=new $r,this._tmpMatrixForMask=new $r,this._tmpMatrixForDraw=new $r;let t=new bo;t.R=1,t.G=0,t.B=0,t.A=0,this._channelColors.push(t),t=new bo,t.R=0,t.G=1,t.B=0,t.A=0,this._channelColors.push(t),t=new bo,t.R=0,t.G=0,t.B=1,t.A=0,this._channelColors.push(t),t=new bo,t.R=0,t.G=0,t.B=0,t.A=1,this._channelColors.push(t)}release(){var t,e,i;const n=this;for(let s=0;s0){this.gl.viewport(0,0,this._clippingMaskBufferSize,this._clippingMaskBufferSize),this._maskRenderTexture=this.getMaskRenderTexture(),e.getMvpMatrix(),e.preDraw(),this.setupLayoutBounds(i),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._maskRenderTexture),this.gl.clearColor(1,1,1,1),this.gl.clear(this.gl.COLOR_BUFFER_BIT);for(let n=0;n(r[r.ShaderNames_SetupMask=0]="ShaderNames_SetupMask",r[r.ShaderNames_NormalPremultipliedAlpha=1]="ShaderNames_NormalPremultipliedAlpha",r[r.ShaderNames_NormalMaskedPremultipliedAlpha=2]="ShaderNames_NormalMaskedPremultipliedAlpha",r[r.ShaderNames_NomralMaskedInvertedPremultipliedAlpha=3]="ShaderNames_NomralMaskedInvertedPremultipliedAlpha",r[r.ShaderNames_AddPremultipliedAlpha=4]="ShaderNames_AddPremultipliedAlpha",r[r.ShaderNames_AddMaskedPremultipliedAlpha=5]="ShaderNames_AddMaskedPremultipliedAlpha",r[r.ShaderNames_AddMaskedPremultipliedAlphaInverted=6]="ShaderNames_AddMaskedPremultipliedAlphaInverted",r[r.ShaderNames_MultPremultipliedAlpha=7]="ShaderNames_MultPremultipliedAlpha",r[r.ShaderNames_MultMaskedPremultipliedAlpha=8]="ShaderNames_MultMaskedPremultipliedAlpha",r[r.ShaderNames_MultMaskedPremultipliedAlphaInverted=9]="ShaderNames_MultMaskedPremultipliedAlphaInverted",r))(So||{});const CT="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;}",AT="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;}",OT="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;}",qd="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;}",FT="precision mediump float;varying vec2 v_texCoord;uniform vec4 u_baseColor;uniform sampler2D s_texture0;void main(){ gl_FragColor = texture2D(s_texture0 , v_texCoord) * u_baseColor;}",PT="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;void main(){ vec4 col_formask = texture2D(s_texture0 , v_texCoord) * 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;}",MT="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;void main(){vec4 col_formask = texture2D(s_texture0, v_texCoord) * 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;}";class nv extends Wh{constructor(){super(),this._clippingContextBufferForMask=null,this._clippingContextBufferForDraw=null,this._clippingManager=new ju,this.firstDraw=!0,this._textures={},this._sortedDrawableIndexList=[],this._bufferData={vertex:null,uv:null,index:null}}initialize(t){t.isUsingMasking()&&(this._clippingManager=new ju,this._clippingManager.initialize(t,t.getDrawableCount(),t.getDrawableMasks(),t.getDrawableMaskCounts()));for(let e=t.getDrawableCount()-1;e>=0;e--)this._sortedDrawableIndexList[e]=0;super.initialize(t)}bindTexture(t,e){this._textures[t]=e}getBindedTextures(){return this._textures}setClippingMaskBufferSize(t){this._clippingManager.release(),this._clippingManager=new ju,this._clippingManager.setClippingMaskBufferSize(t),this._clippingManager.initialize(this.getModel(),this.getModel().getDrawableCount(),this.getModel().getDrawableMasks(),this.getModel().getDrawableMaskCounts())}getClippingMaskBufferSize(){return this._clippingManager.getClippingMaskBufferSize()}release(){var t,e,i;const n=this;this._clippingManager.release(),n._clippingManager=void 0,(t=this.gl)==null||t.deleteBuffer(this._bufferData.vertex),this._bufferData.vertex=null,(e=this.gl)==null||e.deleteBuffer(this._bufferData.uv),this._bufferData.uv=null,(i=this.gl)==null||i.deleteBuffer(this._bufferData.index),this._bufferData.index=null,n._bufferData=void 0,n._textures=void 0}doDrawModel(){this.preDraw(),this._clippingManager!=null&&this._clippingManager.setupClippingContext(this.getModel(),this);const t=this.getModel().getDrawableCount(),e=this.getModel().getDrawableRenderOrders();for(let i=0;i{nv.doStaticRelease()};class sv{constructor(t){this.groups=t.Groups,this.hitAreas=t.HitAreas,this.layout=t.Layout,this.moc=t.FileReferences.Moc,this.expressions=t.FileReferences.Expressions,this.motions=t.FileReferences.Motions,this.textures=t.FileReferences.Textures,this.physics=t.FileReferences.Physics,this.pose=t.FileReferences.Pose}getEyeBlinkParameters(){var t,e;return(e=(t=this.groups)==null?void 0:t.find(i=>i.Name==="EyeBlink"))==null?void 0:e.Ids}getLipSyncParameters(){var t,e;return(e=(t=this.groups)==null?void 0:t.find(i=>i.Name==="LipSync"))==null?void 0:e.Ids}}const DT="ParamAngleX",RT="ParamAngleY",NT="ParamAngleZ",LT="ParamEyeBallX",BT="ParamEyeBallY",kT="ParamBodyAngleX",UT="ParamBreath",Qd=2,Kd=2;var wr;(r=>{r.LOG_LEVEL_VERBOSE=0,r.LOG_LEVEL_WARNING=1,r.LOG_LEVEL_ERROR=2,r.LOG_LEVEL_NONE=999,r.logLevel=r.LOG_LEVEL_WARNING,r.sound=!0,r.motionSync=!0,r.motionFadingDuration=500,r.idleMotionFadingDuration=2e3,r.expressionFadingDuration=500,r.preserveExpressionOnMotion=!0,r.cubism4=Ho})(wr||(wr={}));const be={log(r,...t){wr.logLevel<=wr.LOG_LEVEL_VERBOSE&&console.log(`[${r}]`,...t)},warn(r,...t){wr.logLevel<=wr.LOG_LEVEL_WARNING&&console.warn(`[${r}]`,...t)},error(r,...t){wr.logLevel<=wr.LOG_LEVEL_ERROR&&console.error(`[${r}]`,...t)}};function Zd(r,t,e){return re?e:r}function ov(r,t){t.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(i=>{i!=="constructor"&&Object.defineProperty(r.prototype,i,Object.getOwnPropertyDescriptor(e.prototype,i))})})}function zT(r){let t=r.lastIndexOf("/");return t!=-1&&(r=r.slice(0,t)),t=r.lastIndexOf("/"),t!==-1&&(r=r.slice(t+1)),r}function jT(r,t){const e=r.indexOf(t);e!==-1&&r.splice(e,1)}class av extends bn{constructor(t,e){super(),this.expressions=[],this.reserveExpressionIndex=-1,this.destroyed=!1,this.settings=t,this.tag=`ExpressionManager(${t.name})`}init(){this.defaultExpression=this.createExpression({},void 0),this.currentExpression=this.defaultExpression,this.stopAllExpressions()}loadExpression(t){return Fe(this,null,function*(){if(!this.definitions[t]){be.warn(this.tag,`Undefined expression at [${t}]`);return}if(this.expressions[t]===null){be.warn(this.tag,`Cannot set expression at [${t}] because it's already failed in loading.`);return}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 Fe(this,null,function*(){if(this.definitions.length){const t=[];for(let e=0;e-1&&tu&&(o*=u/l,a*=u/l),this.vx+=o,this.vy+=a;const c=Math.sqrt(Fn(this.vx,2)+Fn(this.vy,2)),h=.5*(Math.sqrt(Fn(u,2)+8*u*n)-u);c>h&&(this.vx*=h/c,this.vy*=h/c),this.x+=this.vx,this.y+=this.vy}}class Zh{constructor(t){this.json=t;let e=t.url;if(typeof e!="string")throw new TypeError("The `url` field in settings JSON must be defined as a string.");this.url=e,this.name=zT(this.url)}resolveURL(t){return Ql.resolve(this.url,t)}replaceFiles(t){this.moc=t(this.moc,"moc"),this.pose!==void 0&&(this.pose=t(this.pose,"pose")),this.physics!==void 0&&(this.physics=t(this.physics,"physics"));for(let e=0;e(t.push(e),e)),t}validateFiles(t){const e=(s,o)=>{const a=this.resolveURL(s);if(!t.includes(a)){if(o)throw new Error(`File "${s}" is defined in settings, but doesn't exist in given files`);return!1}return!0};return[this.moc,...this.textures].forEach(s=>e(s,!0)),this.getDefinedFiles().filter(s=>e(s,!1))}}var _c=(r=>(r[r.NONE=0]="NONE",r[r.IDLE=1]="IDLE",r[r.NORMAL=2]="NORMAL",r[r.FORCE=3]="FORCE",r))(_c||{});class WT{constructor(){this.debug=!1,this.currentPriority=0,this.reservePriority=0}reserve(t,e,i){if(i<=0)return be.log(this.tag,"Cannot start a motion with MotionPriority.NONE."),!1;if(t===this.currentGroup&&e===this.currentIndex)return be.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 be.log(this.tag,"Motion is already reserved.",this.dump(t,e)),!1;if(i===1){if(this.currentPriority!==0)return be.log(this.tag,"Cannot start idle motion because another motion is playing.",this.dump(t,e)),!1;if(this.reservedIdleGroup!==void 0)return be.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 be.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 be.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,n){if(n===1){if(this.setReservedIdle(void 0,void 0),this.currentPriority!==0)return be.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 be.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,n),!0):!1}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 this.currentGroup===void 0&&this.reservedIdleGroup===void 0}shouldOverrideExpression(){return!wr.preserveExpressionOnMotion&&this.currentPriority>1}dump(t,e){if(this.debug){const i=["currentPriority","reservePriority","currentGroup","currentIndex","reservedGroup","reservedIndex","reservedIdleGroup","reservedIdleIndex"];return`
+`)}constructor(){}}class X1{update(){this._model.update(),this._model.drawables.resetDynamicFlags()}getCanvasWidth(){return this._model==null?0:this._model.canvasinfo.CanvasWidth/this._model.canvasinfo.PixelsPerUnit}getCanvasHeight(){return this._model==null?0:this._model.canvasinfo.CanvasHeight/this._model.canvasinfo.PixelsPerUnit}saveParameters(){const t=this._model.parameters.count,e=this._savedParameters.length;for(let i=0;ie&&(e=this._model.parameters.minimumValues[t]),this._parameterValues[t]=i==1?e:this._parameterValues[t]=this._parameterValues[t]*(1-i)+e*i}setParameterValueById(t,e,i=1){const n=this.getParameterIndex(t);this.setParameterValueByIndex(n,e,i)}addParameterValueByIndex(t,e,i=1){this.setParameterValueByIndex(t,this.getParameterValueByIndex(t)+e*i)}addParameterValueById(t,e,i=1){const n=this.getParameterIndex(t);this.addParameterValueByIndex(n,e,i)}multiplyParameterValueById(t,e,i=1){const n=this.getParameterIndex(t);this.multiplyParameterValueByIndex(n,e,i)}multiplyParameterValueByIndex(t,e,i=1){this.setParameterValueByIndex(t,this.getParameterValueByIndex(t)*(1+(e-1)*i))}getDrawableIds(){return this._drawableIds.slice()}getDrawableIndex(t){const e=this._model.drawables.count;for(let i=0;ie&&(t=e);for(let i=0;i0&&e.getEndTime()(r[r.ExpressionBlendType_Add=0]="ExpressionBlendType_Add",r[r.ExpressionBlendType_Multiply=1]="ExpressionBlendType_Multiply",r[r.ExpressionBlendType_Overwrite=2]="ExpressionBlendType_Overwrite",r))(Un||{}),qo;(r=>{r.supportMoreMaskDivisions=!0,r.setOpacityFromMotion=!1})(qo||(qo={}));var zn=(r=>(r[r.CubismMotionCurveTarget_Model=0]="CubismMotionCurveTarget_Model",r[r.CubismMotionCurveTarget_Parameter=1]="CubismMotionCurveTarget_Parameter",r[r.CubismMotionCurveTarget_PartOpacity=2]="CubismMotionCurveTarget_PartOpacity",r))(zn||{}),ui=(r=>(r[r.CubismMotionSegmentType_Linear=0]="CubismMotionSegmentType_Linear",r[r.CubismMotionSegmentType_Bezier=1]="CubismMotionSegmentType_Bezier",r[r.CubismMotionSegmentType_Stepped=2]="CubismMotionSegmentType_Stepped",r[r.CubismMotionSegmentType_InverseStepped=3]="CubismMotionSegmentType_InverseStepped",r))(ui||{});class sn{constructor(t=0,e=0){this.time=t,this.value=e}}class q1{constructor(){this.basePointIndex=0,this.segmentType=0}}class Q1{constructor(){this.id="",this.type=0,this.segmentCount=0,this.baseSegmentIndex=0,this.fadeInTime=0,this.fadeOutTime=0}}class K1{constructor(){this.fireTime=0,this.value=""}}class Z1{constructor(){this.duration=0,this.loop=!1,this.curveCount=0,this.eventCount=0,this.fps=0,this.curves=[],this.segments=[],this.points=[],this.events=[]}}class av{constructor(t){this._json=t}release(){this._json=void 0}getMotionDuration(){return this._json.Meta.Duration}isMotionLoop(){return this._json.Meta.Loop||!1}getEvaluationOptionFlag(t){return Kh.EvaluationOptionFlag_AreBeziersRistricted==t?!!this._json.Meta.AreBeziersRestricted:!1}getMotionCurveCount(){return this._json.Meta.CurveCount}getMotionFps(){return this._json.Meta.Fps}getMotionTotalSegmentCount(){return this._json.Meta.TotalSegmentCount}getMotionTotalPointCount(){return this._json.Meta.TotalPointCount}getMotionFadeInTime(){return this._json.Meta.FadeInTime}getMotionFadeOutTime(){return this._json.Meta.FadeOutTime}getMotionCurveTarget(t){return this._json.Curves[t].Target}getMotionCurveId(t){return this._json.Curves[t].Id}getMotionCurveFadeInTime(t){return this._json.Curves[t].FadeInTime}getMotionCurveFadeOutTime(t){return this._json.Curves[t].FadeOutTime}getMotionCurveSegmentCount(t){return this._json.Curves[t].Segments.length}getMotionCurveSegment(t,e){return this._json.Curves[t].Segments[e]}getEventCount(){return this._json.Meta.UserDataCount||0}getTotalEventValueSize(){return this._json.Meta.TotalUserDataSize}getEventTime(t){return this._json.UserData[t].Time}getEventValue(t){return this._json.UserData[t].Value}}var Kh=(r=>(r[r.EvaluationOptionFlag_AreBeziersRistricted=0]="EvaluationOptionFlag_AreBeziersRistricted",r))(Kh||{});const J1="EyeBlink",tT="LipSync",eT="Model",rT="Parameter",iT="PartOpacity",nT=!1;function Ur(r,t,e){const i=new sn;return i.time=r.time+(t.time-r.time)*e,i.value=r.value+(t.value-r.value)*e,i}function sT(r,t){let e=(t-r[0].time)/(r[1].time-r[0].time);return e<0&&(e=0),r[0].value+(r[1].value-r[0].value)*e}function oT(r,t){let e=(t-r[0].time)/(r[3].time-r[0].time);e<0&&(e=0);const i=Ur(r[0],r[1],e),n=Ur(r[1],r[2],e),s=Ur(r[2],r[3],e),o=Ur(i,n,e),a=Ur(n,s,e);return Ur(o,a,e).value}function aT(r,t){const e=t,i=r[0].time,n=r[3].time,s=r[1].time,o=r[2].time,a=n-3*o+3*s-i,l=3*o-6*s+3*i,u=3*s-3*i,c=i-e,h=Te.cardanoAlgorithmForBezier(a,l,u,c),p=Ur(r[0],r[1],h),f=Ur(r[1],r[2],h),y=Ur(r[2],r[3],h),g=Ur(p,f,h),d=Ur(f,y,h);return Ur(g,d,h).value}function lT(r,t){return r[0].value}function uT(r,t){return r[1].value}function $u(r,t,e){const i=r.curves[t];let n=-1;const s=i.baseSegmentIndex+i.segmentCount;let o=0;for(let l=i.baseSegmentIndex;le){n=l;break}if(n==-1)return r.points[o].value;const a=r.segments[n];return a.evaluate(r.points.slice(a.basePointIndex),e)}class Zh extends ov{constructor(){super(),this._eyeBlinkParameterIds=[],this._lipSyncParameterIds=[],this._sourceFrameRate=30,this._loopDurationSeconds=-1,this._isLoop=!1,this._isLoopFadeIn=!0,this._lastWeight=0}static create(t,e){const i=new Zh;return i.parse(t),i._sourceFrameRate=i._motionData.fps,i._loopDurationSeconds=i._motionData.duration,i._onFinishedMotion=e,i}doUpdateParameters(t,e,i,n){this._modelCurveIdEyeBlink==null&&(this._modelCurveIdEyeBlink=J1),this._modelCurveIdLipSync==null&&(this._modelCurveIdLipSync=tT);let s=e-n.getStartTime();s<0&&(s=0);let o=Number.MAX_VALUE,a=Number.MAX_VALUE;const l=64;let u=0,c=0;this._eyeBlinkParameterIds.length>l&&Hd("too many eye blink targets : {0}",this._eyeBlinkParameterIds.length),this._lipSyncParameterIds.length>l&&Hd("too many lip sync targets : {0}",this._lipSyncParameterIds.length);const h=this._fadeInSeconds<=0?1:Te.getEasingSine((e-n.getFadeInStartTime())/this._fadeInSeconds),p=this._fadeOutSeconds<=0||n.getEndTime()<0?1:Te.getEasingSine((n.getEndTime()-e)/this._fadeOutSeconds);let f,y,g,d=s;if(this._isLoop)for(;d>this._motionData.duration;)d-=this._motionData.duration;const m=this._motionData.curves;for(y=0;y>_&1)continue;const E=S+(a-S)*i;t.setParameterValueById(this._eyeBlinkParameterIds[_],E)}if(o!=Number.MAX_VALUE)for(let _=0;_>_&1)continue;const E=S+(o-S)*i;t.setParameterValueById(this._lipSyncParameterIds[_],E)}}for(;y=this._motionData.duration&&(this._isLoop?(n.setStartTime(e),this._isLoopFadeIn&&n.setFadeInStartTime(e)):(this._onFinishedMotion&&this._onFinishedMotion(this),n.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 n=0;nnew Q1),this._motionData.segments=Array.from({length:e.getMotionTotalSegmentCount()}).map(()=>new q1),this._motionData.events=Array.from({length:this._motionData.eventCount}).map(()=>new K1),this._motionData.points=[];let o=0,a=0;for(let l=0;lt&&this._motionData.events[i].fireTime<=e&&this._firedEventValues.push(this._motionData.events[i].value);return this._firedEventValues}}class cT{constructor(){this._autoDelete=!1,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&&this._motion.release()}setFadeOut(t){this._fadeOutSeconds=t,this._isTriggeredFadeOut=!0}startFadeOut(t,e){const i=e+t;this._isTriggeredFadeOut=!0,(this._endTimeSeconds<0||ie!=null&&e._motionQueueEntryHandle==t)}setEventCallback(t,e=null){this._eventCallBack=t,this._eventCustomData=e}doUpdateMotion(t,e){let i=!1,n=0;for(;n(r[r.CubismPhysicsTargetType_Parameter=0]="CubismPhysicsTargetType_Parameter",r))(_c||{}),jn=(r=>(r[r.CubismPhysicsSource_X=0]="CubismPhysicsSource_X",r[r.CubismPhysicsSource_Y=1]="CubismPhysicsSource_Y",r[r.CubismPhysicsSource_Angle=2]="CubismPhysicsSource_Angle",r))(jn||{});class fT{constructor(){this.initialPosition=new te(0,0),this.position=new te(0,0),this.lastPosition=new te(0,0),this.lastGravity=new te(0,0),this.force=new te(0,0),this.velocity=new te(0,0)}}class dT{constructor(){this.normalizationPosition={},this.normalizationAngle={}}}class pT{constructor(){this.source={}}}class mT{constructor(){this.destination={},this.translationScale=new te(0,0)}}class yT{constructor(){this.settings=[],this.inputs=[],this.outputs=[],this.particles=[],this.gravity=new te(0,0),this.wind=new te(0,0)}}class gT{constructor(t){this._json=t}release(){this._json=void 0}getGravity(){const t=new te(0,0);return t.x=this._json.Meta.EffectiveForces.Gravity.X,t.y=this._json.Meta.EffectiveForces.Gravity.Y,t}getWind(){const t=new te(0,0);return t.x=this._json.Meta.EffectiveForces.Wind.X,t.y=this._json.Meta.EffectiveForces.Wind.Y,t}getSubRigCount(){return this._json.Meta.PhysicsSettingCount}getTotalInputCount(){return this._json.Meta.TotalInputCount}getTotalOutputCount(){return this._json.Meta.TotalOutputCount}getVertexCount(){return this._json.Meta.VertexCount}getNormalizationPositionMinimumValue(t){return this._json.PhysicsSettings[t].Normalization.Position.Minimum}getNormalizationPositionMaximumValue(t){return this._json.PhysicsSettings[t].Normalization.Position.Maximum}getNormalizationPositionDefaultValue(t){return this._json.PhysicsSettings[t].Normalization.Position.Default}getNormalizationAngleMinimumValue(t){return this._json.PhysicsSettings[t].Normalization.Angle.Minimum}getNormalizationAngleMaximumValue(t){return this._json.PhysicsSettings[t].Normalization.Angle.Maximum}getNormalizationAngleDefaultValue(t){return this._json.PhysicsSettings[t].Normalization.Angle.Default}getInputCount(t){return this._json.PhysicsSettings[t].Input.length}getInputWeight(t,e){return this._json.PhysicsSettings[t].Input[e].Weight}getInputReflect(t,e){return this._json.PhysicsSettings[t].Input[e].Reflect}getInputType(t,e){return this._json.PhysicsSettings[t].Input[e].Type}getInputSourceId(t,e){return this._json.PhysicsSettings[t].Input[e].Source.Id}getOutputCount(t){return this._json.PhysicsSettings[t].Output.length}getOutputVertexIndex(t,e){return this._json.PhysicsSettings[t].Output[e].VertexIndex}getOutputAngleScale(t,e){return this._json.PhysicsSettings[t].Output[e].Scale}getOutputWeight(t,e){return this._json.PhysicsSettings[t].Output[e].Weight}getOutputDestinationId(t,e){return this._json.PhysicsSettings[t].Output[e].Destination.Id}getOutputType(t,e){return this._json.PhysicsSettings[t].Output[e].Type}getOutputReflect(t,e){return this._json.PhysicsSettings[t].Output[e].Reflect}getParticleCount(t){return this._json.PhysicsSettings[t].Vertices.length}getParticleMobility(t,e){return this._json.PhysicsSettings[t].Vertices[e].Mobility}getParticleDelay(t,e){return this._json.PhysicsSettings[t].Vertices[e].Delay}getParticleAcceleration(t,e){return this._json.PhysicsSettings[t].Vertices[e].Acceleration}getParticleRadius(t,e){return this._json.PhysicsSettings[t].Vertices[e].Radius}getParticlePosition(t,e){const i=new te(0,0);return i.x=this._json.PhysicsSettings[t].Vertices[e].Position.X,i.y=this._json.PhysicsSettings[t].Vertices[e].Position.Y,i}}const Xd="X",qd="Y",Qd="Angle",vT=5,uv=100,_T=.001;class Jh{static create(t){const e=new Jh;return e.parse(t),e._physicsRig.gravity.y=0,e}evaluate(t,e){let i,n,s,o;const a=new te;let l,u,c,h,p,f,y,g;p=t.getModel().parameters.values,f=t.getModel().parameters.maximumValues,y=t.getModel().parameters.minimumValues,g=t.getModel().parameters.defaultValues;for(let d=0;d=l.particleCount)break;c[m].destinationParameterIndex==-1&&(c[m].destinationParameterIndex=t.getParameterIndex(c[m].destination.id));const S=new te;S.x=h[_].position.x-h[_-1].position.x,S.y=h[_].position.y-h[_-1].position.y,o=c[m].getValue(S,h,_,c[m].reflect,this._options.gravity);const E=c[m].destinationParameterIndex,b=!Float32Array.prototype.slice&&"subarray"in Float32Array.prototype?JSON.parse(JSON.stringify(p.subarray(E))):p.slice(E);DT(b,y[E],f[E],o,c[m]);for(let F=E,x=0;F=2?n=t[e-1].position.substract(t[e-2].position):n=n.multiplyByScaler(-1),s=Te.directionToRadian(n,r),i&&(s*=-1),s}function CT(r,t){return Math.abs(Math.max(r,t)-Math.min(r,t))}function AT(r,t){return Math.min(r,t)+CT(r,t)/2}function OT(r,t){return r.x}function FT(r,t){return r.y}function PT(r,t){return t}function MT(r,t,e,i,n,s,o,a){let l,u,c,h,p=new te(0,0),f=new te(0,0),y=new te(0,0),g=new te(0,0);r[0].position=new te(e.x,e.y),l=Te.degreesToRadian(i),h=Te.radianToDirection(l),h.normalize();for(let d=1;de&&(o>n.valueExceededMaximum&&(n.valueExceededMaximum=o),o=e),a=n.weight/uv,a>=1||(o=r[0]*(1-a)+o*a),r[0]=o}function tf(r,t,e,i,n,s,o,a){let l=0;const u=Te.max(e,t);ur&&(r=c);const h=Te.min(n,s),p=Te.max(n,s),f=o,y=AT(c,u),g=r-y;switch(Math.sign(g)){case 1:{const d=p-f,m=u-y;m!=0&&(l=g*(d/m),l+=f);break}case-1:{const d=h-f,m=c-y;m!=0&&(l=g*(d/m),l+=f);break}case 0:{l=f;break}}return a?l:l*-1}class bc{constructor(t=0,e=0,i=0,n=0){this.x=t,this.y=e,this.width=i,this.height=n}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+=t*2,this.height+=e*2}}const Vu=4,RT=10;let Dn,Io,wc;class Gu{getChannelFlagAsColor(t){return this._channelColors[t]}getMaskRenderTexture(){let t=0;if(this._maskTexture&&this._maskTexture.texture!=0&&(this._maskTexture.frameNo=this._currentFrameNo,t=this._maskTexture.texture),t==0){const e=this._clippingMaskBufferSize;this._colorBuffer=this.gl.createTexture(),this.gl.bindTexture(this.gl.TEXTURE_2D,this._colorBuffer),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,e,e,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),t=this.gl.createFramebuffer(),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,t),this.gl.framebufferTexture2D(this.gl.FRAMEBUFFER,this.gl.COLOR_ATTACHMENT0,this.gl.TEXTURE_2D,this._colorBuffer,0),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,wc),this._maskTexture=new NT(this._currentFrameNo,t)}return t}setGL(t){this.gl=t}calcClippedDrawTotalBounds(t,e){let i=Number.MAX_VALUE,n=Number.MAX_VALUE,s=Number.MIN_VALUE,o=Number.MIN_VALUE;const a=e._clippedDrawableIndexList.length;for(let l=0;ly&&(y=_),Sg&&(g=S)}if(p!=Number.MAX_VALUE)if(ps&&(s=y),g>o&&(o=g),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 m=s-i,_=o-n;e._allClippedDrawRect.x=i,e._allClippedDrawRect.y=n,e._allClippedDrawRect.width=m,e._allClippedDrawRect.height=_}}}constructor(){this._maskRenderTexture=null,this._colorBuffer=null,this._currentFrameNo=0,this._clippingMaskBufferSize=256,this._clippingContextListForMask=[],this._clippingContextListForDraw=[],this._channelColors=[],this._tmpBoundsOnModel=new bc,this._tmpMatrix=new $r,this._tmpMatrixForMask=new $r,this._tmpMatrixForDraw=new $r;let t=new So;t.R=1,t.G=0,t.B=0,t.A=0,this._channelColors.push(t),t=new So,t.R=0,t.G=1,t.B=0,t.A=0,this._channelColors.push(t),t=new So,t.R=0,t.G=0,t.B=1,t.A=0,this._channelColors.push(t),t=new So,t.R=0,t.G=0,t.B=0,t.A=1,this._channelColors.push(t)}release(){var t,e,i;const n=this;for(let s=0;s0){this.gl.viewport(0,0,this._clippingMaskBufferSize,this._clippingMaskBufferSize),this._maskRenderTexture=this.getMaskRenderTexture(),e.getMvpMatrix(),e.preDraw(),this.setupLayoutBounds(i),this.gl.bindFramebuffer(this.gl.FRAMEBUFFER,this._maskRenderTexture),this.gl.clearColor(1,1,1,1),this.gl.clear(this.gl.COLOR_BUFFER_BIT);for(let n=0;n(r[r.ShaderNames_SetupMask=0]="ShaderNames_SetupMask",r[r.ShaderNames_NormalPremultipliedAlpha=1]="ShaderNames_NormalPremultipliedAlpha",r[r.ShaderNames_NormalMaskedPremultipliedAlpha=2]="ShaderNames_NormalMaskedPremultipliedAlpha",r[r.ShaderNames_NomralMaskedInvertedPremultipliedAlpha=3]="ShaderNames_NomralMaskedInvertedPremultipliedAlpha",r[r.ShaderNames_AddPremultipliedAlpha=4]="ShaderNames_AddPremultipliedAlpha",r[r.ShaderNames_AddMaskedPremultipliedAlpha=5]="ShaderNames_AddMaskedPremultipliedAlpha",r[r.ShaderNames_AddMaskedPremultipliedAlphaInverted=6]="ShaderNames_AddMaskedPremultipliedAlphaInverted",r[r.ShaderNames_MultPremultipliedAlpha=7]="ShaderNames_MultPremultipliedAlpha",r[r.ShaderNames_MultMaskedPremultipliedAlpha=8]="ShaderNames_MultMaskedPremultipliedAlpha",r[r.ShaderNames_MultMaskedPremultipliedAlphaInverted=9]="ShaderNames_MultMaskedPremultipliedAlphaInverted",r))(Eo||{});const BT="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;}",kT="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;}",UT="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;}",Kd="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;}",zT="precision mediump float;varying vec2 v_texCoord;uniform vec4 u_baseColor;uniform sampler2D s_texture0;void main(){ gl_FragColor = texture2D(s_texture0 , v_texCoord) * u_baseColor;}",jT="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;void main(){ vec4 col_formask = texture2D(s_texture0 , v_texCoord) * 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;}",$T="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;void main(){vec4 col_formask = texture2D(s_texture0, v_texCoord) * 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;}";class cv extends Xh{constructor(){super(),this._clippingContextBufferForMask=null,this._clippingContextBufferForDraw=null,this._clippingManager=new Gu,this.firstDraw=!0,this._textures={},this._sortedDrawableIndexList=[],this._bufferData={vertex:null,uv:null,index:null}}initialize(t){t.isUsingMasking()&&(this._clippingManager=new Gu,this._clippingManager.initialize(t,t.getDrawableCount(),t.getDrawableMasks(),t.getDrawableMaskCounts()));for(let e=t.getDrawableCount()-1;e>=0;e--)this._sortedDrawableIndexList[e]=0;super.initialize(t)}bindTexture(t,e){this._textures[t]=e}getBindedTextures(){return this._textures}setClippingMaskBufferSize(t){this._clippingManager.release(),this._clippingManager=new Gu,this._clippingManager.setClippingMaskBufferSize(t),this._clippingManager.initialize(this.getModel(),this.getModel().getDrawableCount(),this.getModel().getDrawableMasks(),this.getModel().getDrawableMaskCounts())}getClippingMaskBufferSize(){return this._clippingManager.getClippingMaskBufferSize()}release(){var t,e,i;const n=this;this._clippingManager.release(),n._clippingManager=void 0,(t=this.gl)==null||t.deleteBuffer(this._bufferData.vertex),this._bufferData.vertex=null,(e=this.gl)==null||e.deleteBuffer(this._bufferData.uv),this._bufferData.uv=null,(i=this.gl)==null||i.deleteBuffer(this._bufferData.index),this._bufferData.index=null,n._bufferData=void 0,n._textures=void 0}doDrawModel(){this.preDraw(),this._clippingManager!=null&&this._clippingManager.setupClippingContext(this.getModel(),this);const t=this.getModel().getDrawableCount(),e=this.getModel().getDrawableRenderOrders();for(let i=0;i{cv.doStaticRelease()};class hv{constructor(t){this.groups=t.Groups,this.hitAreas=t.HitAreas,this.layout=t.Layout,this.moc=t.FileReferences.Moc,this.expressions=t.FileReferences.Expressions,this.motions=t.FileReferences.Motions,this.textures=t.FileReferences.Textures,this.physics=t.FileReferences.Physics,this.pose=t.FileReferences.Pose}getEyeBlinkParameters(){var t,e;return(e=(t=this.groups)==null?void 0:t.find(i=>i.Name==="EyeBlink"))==null?void 0:e.Ids}getLipSyncParameters(){var t,e;return(e=(t=this.groups)==null?void 0:t.find(i=>i.Name==="LipSync"))==null?void 0:e.Ids}}const VT="ParamAngleX",GT="ParamAngleY",WT="ParamAngleZ",HT="ParamEyeBallX",YT="ParamEyeBallY",XT="ParamBodyAngleX",qT="ParamBreath",Zd=2,Jd=2;var xr;(r=>{r.LOG_LEVEL_VERBOSE=0,r.LOG_LEVEL_WARNING=1,r.LOG_LEVEL_ERROR=2,r.LOG_LEVEL_NONE=999,r.logLevel=r.LOG_LEVEL_WARNING,r.sound=!0,r.motionSync=!0,r.motionFadingDuration=500,r.idleMotionFadingDuration=2e3,r.expressionFadingDuration=500,r.preserveExpressionOnMotion=!0,r.cubism4=qo})(xr||(xr={}));const be={log(r,...t){xr.logLevel<=xr.LOG_LEVEL_VERBOSE&&console.log(`[${r}]`,...t)},warn(r,...t){xr.logLevel<=xr.LOG_LEVEL_WARNING&&console.warn(`[${r}]`,...t)},error(r,...t){xr.logLevel<=xr.LOG_LEVEL_ERROR&&console.error(`[${r}]`,...t)}};function tp(r,t,e){return re?e:r}function fv(r,t){t.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(i=>{i!=="constructor"&&Object.defineProperty(r.prototype,i,Object.getOwnPropertyDescriptor(e.prototype,i))})})}function QT(r){let t=r.lastIndexOf("/");return t!=-1&&(r=r.slice(0,t)),t=r.lastIndexOf("/"),t!==-1&&(r=r.slice(t+1)),r}function KT(r,t){const e=r.indexOf(t);e!==-1&&r.splice(e,1)}class dv extends xn{constructor(t,e){super(),this.expressions=[],this.reserveExpressionIndex=-1,this.destroyed=!1,this.settings=t,this.tag=`ExpressionManager(${t.name})`}init(){this.defaultExpression=this.createExpression({},void 0),this.currentExpression=this.defaultExpression,this.stopAllExpressions()}loadExpression(t){return Fe(this,null,function*(){if(!this.definitions[t]){be.warn(this.tag,`Undefined expression at [${t}]`);return}if(this.expressions[t]===null){be.warn(this.tag,`Cannot set expression at [${t}] because it's already failed in loading.`);return}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 Fe(this,null,function*(){if(this.definitions.length){const t=[];for(let e=0;e-1&&tu&&(o*=u/l,a*=u/l),this.vx+=o,this.vy+=a;const c=Math.sqrt(Mn(this.vx,2)+Mn(this.vy,2)),h=.5*(Math.sqrt(Mn(u,2)+8*u*n)-u);c>h&&(this.vx*=h/c,this.vy*=h/c),this.x+=this.vx,this.y+=this.vy}}class ef{constructor(t){this.json=t;let e=t.url;if(typeof e!="string")throw new TypeError("The `url` field in settings JSON must be defined as a string.");this.url=e,this.name=QT(this.url)}resolveURL(t){return Zl.resolve(this.url,t)}replaceFiles(t){this.moc=t(this.moc,"moc"),this.pose!==void 0&&(this.pose=t(this.pose,"pose")),this.physics!==void 0&&(this.physics=t(this.physics,"physics"));for(let e=0;e(t.push(e),e)),t}validateFiles(t){const e=(s,o)=>{const a=this.resolveURL(s);if(!t.includes(a)){if(o)throw new Error(`File "${s}" is defined in settings, but doesn't exist in given files`);return!1}return!0};return[this.moc,...this.textures].forEach(s=>e(s,!0)),this.getDefinedFiles().filter(s=>e(s,!1))}}var xc=(r=>(r[r.NONE=0]="NONE",r[r.IDLE=1]="IDLE",r[r.NORMAL=2]="NORMAL",r[r.FORCE=3]="FORCE",r))(xc||{});class eI{constructor(){this.debug=!1,this.currentPriority=0,this.reservePriority=0}reserve(t,e,i){if(i<=0)return be.log(this.tag,"Cannot start a motion with MotionPriority.NONE."),!1;if(t===this.currentGroup&&e===this.currentIndex)return be.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 be.log(this.tag,"Motion is already reserved.",this.dump(t,e)),!1;if(i===1){if(this.currentPriority!==0)return be.log(this.tag,"Cannot start idle motion because another motion is playing.",this.dump(t,e)),!1;if(this.reservedIdleGroup!==void 0)return be.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 be.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 be.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,n){if(n===1){if(this.setReservedIdle(void 0,void 0),this.currentPriority!==0)return be.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 be.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,n),!0):!1}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 this.currentGroup===void 0&&this.reservedIdleGroup===void 0}shouldOverrideExpression(){return!xr.preserveExpressionOnMotion&&this.currentPriority>1}dump(t,e){if(this.debug){const i=["currentPriority","reservePriority","currentGroup","currentIndex","reservedGroup","reservedIndex","reservedIdleGroup","reservedIdleIndex"];return`
group = "${t}", index = ${e}
`+i.map(n=>"["+n+"] "+this[n]).join(`
-`)}return""}}const HT="SoundManager",XT=.5;class Gn{static get volume(){return this._volume}static set volume(t){this._volume=(t>1?1:t<0?0:t)||0,this.audios.forEach(e=>e.volume=this._volume)}static add(t,e,i){const n=new Audio(t);return n.volume=this._volume,n.preload="auto",n.addEventListener("ended",()=>{this.dispose(n),e==null||e()}),n.addEventListener("error",s=>{this.dispose(n),be.warn(HT,`Error occurred on "${t}"`,s.error),i==null||i(s.error)}),this.audios.push(n),n}static play(t){return new Promise((e,i)=>{var n;(n=t.play())==null||n.catch(s=>{t.dispatchEvent(new ErrorEvent("error",{error:s})),i(s)}),t.readyState===t.HAVE_ENOUGH_DATA?e():t.addEventListener("canplaythrough",e)})}static dispose(t){t.pause(),t.removeAttribute("src"),jT(this.audios,t)}static destroy(){for(let t=this.audios.length-1;t>=0;t--)this.dispose(this.audios[t])}}Gn.audios=[];Gn._volume=XT;class Jh extends bn{constructor(t,e){super(),this.motionGroups={},this.state=new WT,this.playing=!1,this.destroyed=!1,this.settings=t,this.tag=`MotionManager(${t.name})`,this.state.tag=this.tag}init(t){t!=null&&t.idleMotionGroup&&(this.groups.idle=t.idleMotionGroup),this.setupMotions(t),this.stopAllMotions()}setupMotions(t){for(const i of Object.keys(this.definitions))this.motionGroups[i]=[];let e;switch(t==null?void 0:t.motionPreload){case"NONE":return;case"ALL":e=Object.keys(this.definitions);break;case"IDLE":default:e=[this.groups.idle];break}for(const i of e)if(this.definitions[i])for(let n=0;nthis.currentAudio=void 0,()=>this.currentAudio=void 0),this.currentAudio=l}catch(h){be.warn(this.tag,"Failed to create audio",c,h)}}const u=yield this.loadMotion(i,n);if(l){const c=Gn.play(l).catch(h=>be.warn(this.tag,"Failed to play audio",l.src,h));wr.motionSync&&(yield c)}return this.state.start(u,i,n,s)?(be.log(this.tag,"Start motion:",this.getMotionName(a)),this.emit("motionStart",i,n,l),this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),this.playing=!0,this._startMotion(u),!0):(l&&(Gn.dispose(l),this.currentAudio=void 0),!1)})}startRandomMotion(t,e){return Fe(this,null,function*(){const i=this.definitions[t];if(i!=null&&i.length){const n=[];for(let s=0;se.index>=0);for(const e of t)this.hitAreas[e.name]=e}hitTest(t,e){return Object.keys(this.hitAreas).filter(i=>this.isHit(i,t,e))}isHit(t,e,i){if(!this.hitAreas[t])return!1;const n=this.hitAreas[t].index,s=this.getDrawableBounds(n,YT);return s.x<=e&&e<=s.x+s.width&&s.y<=i&&i<=s.y+s.height}getDrawableBounds(t,e){const i=this.getDrawableVertices(t);let n=i[0],s=i[0],o=i[1],a=i[1];for(let l=0;l{(s.status===200||s.status===0)&&s.response?i(s.response):s.onerror()},s.onerror=()=>{be.warn(QT,`Failed to load resource as ${s.responseType} (Status ${s.status}): ${t}`),n(new tp("Network error.",t,s.status))},s.onabort=()=>n(new tp("Aborted.",t,s.status,!0)),s.onloadend=()=>{var o;nr.allXhrSet.delete(s),r&&((o=nr.xhrMap.get(r))==null||o.delete(s))},s}static cancelXHRs(){var r;(r=nr.xhrMap.get(this))==null||r.forEach(t=>{t.abort(),nr.allXhrSet.delete(t)}),nr.xhrMap.delete(this)}static release(){nr.allXhrSet.forEach(r=>r.abort()),nr.allXhrSet.clear(),nr.xhrMap=new WeakMap}};let Zl=nr;Zl.xhrMap=new WeakMap;Zl.allXhrSet=new Set;Zl.loader=(r,t)=>new Promise((e,i)=>{nr.createXHR(r.target,r.settings?r.settings.resolveURL(r.url):r.url,r.type,s=>{r.result=s,e()},i).send()});function lv(r,t){let e=-1;return i(0);function i(n,s){if(s)return Promise.reject(s);if(n<=e)return Promise.reject(new Error("next() called multiple times"));e=n;const o=r[n];if(!o)return Promise.resolve();try{return Promise.resolve(o(t,i.bind(null,n+1)))}catch(a){return Promise.reject(a)}}}class dn{static load(t){return lv(this.middlewares,t).then(()=>t.result)}}dn.middlewares=[Zl.loader];function KT(r,t={}){var e;const i={resourceOptions:{crossorigin:t.crossOrigin}};if(Zn.fromURL)return Zn.fromURL(r,i).catch(o=>{if(o instanceof Error)throw o;const a=new Error("Texture loading error");throw a.event=o,a});i.resourceOptions.autoLoad=!1;const n=Zn.from(r,i);if(n.baseTexture.valid)return Promise.resolve(n);const s=n.baseTexture.resource;return(e=s._live2d_load)!=null||(s._live2d_load=new Promise((o,a)=>{const l=u=>{s.source.removeEventListener("error",l);const c=new Error("Texture loading error");c.event=u,a(c)};s.source.addEventListener("error",l),s.load().then(()=>o(n)).catch(l)})),s._live2d_load}const ep="Live2DFactory",uv=(r,t)=>Fe(void 0,null,function*(){if(typeof r.source=="string"){const e=yield dn.load({url:r.source,type:"json",target:r.live2dModel});e.url=r.source,r.source=e,r.live2dModel.emit("settingsJSONLoaded",e)}return t()}),cv=(r,t)=>Fe(void 0,null,function*(){if(r.source instanceof Zh)return r.settings=r.source,t();if(typeof r.source=="object"){const e=Re.findRuntime(r.source);if(e){const i=e.createModelSettings(r.source);return r.settings=i,r.live2dModel.emit("settingsLoaded",i),t()}}throw new TypeError("Unknown settings format.")}),hv=(r,t)=>{if(r.settings){const e=Re.findRuntime(r.settings);if(e)return e.ready().then(t)}return t()},fv=(r,t)=>Fe(void 0,null,function*(){yield t();const e=r.internalModel;if(e){const i=r.settings,n=Re.findRuntime(i);if(n){const s=[];i.pose&&s.push(dn.load({settings:i,url:i.pose,type:"json",target:e}).then(o=>{e.pose=n.createPose(e.coreModel,o),r.live2dModel.emit("poseLoaded",e.pose)}).catch(o=>{r.live2dModel.emit("poseLoadError",o),be.warn(ep,"Failed to load pose.",o)})),i.physics&&s.push(dn.load({settings:i,url:i.physics,type:"json",target:e}).then(o=>{e.physics=n.createPhysics(e.coreModel,o),r.live2dModel.emit("physicsLoaded",e.physics)}).catch(o=>{r.live2dModel.emit("physicsLoadError",o),be.warn(ep,"Failed to load physics.",o)})),s.length&&(yield Promise.all(s))}}}),dv=(r,t)=>Fe(void 0,null,function*(){if(r.settings){const e=r.live2dModel,i=r.settings.textures.map(n=>{const s=r.settings.resolveURL(n);return KT(s,{crossOrigin:r.options.crossOrigin})});if(yield t(),r.internalModel)e.internalModel=r.internalModel,e.emit("modelLoaded",r.internalModel);else throw new TypeError("Missing internal model.");e.textures=yield Promise.all(i),e.emit("textureLoaded",e.textures)}else throw new TypeError("Missing settings.")}),pv=(r,t)=>Fe(void 0,null,function*(){const e=r.settings;if(e instanceof Zh){const i=Re.findRuntime(e);if(!i)throw new TypeError("Unknown model settings.");const n=yield dn.load({settings:e,url:e.moc,type:"arraybuffer",target:r.live2dModel});if(!i.isValidMoc(n))throw new Error("Invalid moc data");const s=i.createCoreModel(n);return r.internalModel=i.createInternalModel(s,e,r.options),t()}throw new TypeError("Missing settings.")}),Ye=class{static registerRuntime(r){Ye.runtimes.push(r),Ye.runtimes.sort((t,e)=>e.version-t.version)}static findRuntime(r){for(const t of Ye.runtimes)if(t.test(r))return t}static setupLive2DModel(r,t,e){return Fe(this,null,function*(){const i=new Promise(o=>r.once("textureLoaded",o)),n=new Promise(o=>r.once("modelLoaded",o)),s=Promise.all([i,n]).then(()=>r.emit("ready"));yield lv(Ye.live2DModelMiddlewares,{live2dModel:r,source:t,options:e||{}}),yield s,r.emit("load")})}static loadMotion(r,t,e){var i,n;const s=o=>r.emit("motionLoadError",t,e,o);try{const o=(i=r.definitions[t])==null?void 0:i[e];if(!o)return Promise.resolve(void 0);r.listeners("destroy").includes(Ye.releaseTasks)||r.once("destroy",Ye.releaseTasks);let a=Ye.motionTasksMap.get(r);a||(a={},Ye.motionTasksMap.set(r,a));let l=a[t];l||(l=[],a[t]=l);const u=r.getMotionFile(o);return(n=l[e])!=null||(l[e]=dn.load({url:u,settings:r.settings,type:r.motionDataType,target:r}).then(c=>{var h;const p=(h=Ye.motionTasksMap.get(r))==null?void 0:h[t];p&&delete p[e];const f=r.createMotion(c,t,o);return r.emit("motionLoaded",t,e,f),f}).catch(c=>{be.warn(r.tag,`Failed to load motion: ${u}
+`)}return""}}const rI="SoundManager",iI=.5;class Hn{static get volume(){return this._volume}static set volume(t){this._volume=(t>1?1:t<0?0:t)||0,this.audios.forEach(e=>e.volume=this._volume)}static add(t,e,i){const n=new Audio(t);return n.volume=this._volume,n.preload="auto",n.addEventListener("ended",()=>{this.dispose(n),e==null||e()}),n.addEventListener("error",s=>{this.dispose(n),be.warn(rI,`Error occurred on "${t}"`,s.error),i==null||i(s.error)}),this.audios.push(n),n}static play(t){return new Promise((e,i)=>{var n;(n=t.play())==null||n.catch(s=>{t.dispatchEvent(new ErrorEvent("error",{error:s})),i(s)}),t.readyState===t.HAVE_ENOUGH_DATA?e():t.addEventListener("canplaythrough",e)})}static dispose(t){t.pause(),t.removeAttribute("src"),KT(this.audios,t)}static destroy(){for(let t=this.audios.length-1;t>=0;t--)this.dispose(this.audios[t])}}Hn.audios=[];Hn._volume=iI;class rf extends xn{constructor(t,e){super(),this.motionGroups={},this.state=new eI,this.playing=!1,this.destroyed=!1,this.settings=t,this.tag=`MotionManager(${t.name})`,this.state.tag=this.tag}init(t){t!=null&&t.idleMotionGroup&&(this.groups.idle=t.idleMotionGroup),this.setupMotions(t),this.stopAllMotions()}setupMotions(t){for(const i of Object.keys(this.definitions))this.motionGroups[i]=[];let e;switch(t==null?void 0:t.motionPreload){case"NONE":return;case"ALL":e=Object.keys(this.definitions);break;case"IDLE":default:e=[this.groups.idle];break}for(const i of e)if(this.definitions[i])for(let n=0;nthis.currentAudio=void 0,()=>this.currentAudio=void 0),this.currentAudio=l}catch(h){be.warn(this.tag,"Failed to create audio",c,h)}}const u=yield this.loadMotion(i,n);if(l){const c=Hn.play(l).catch(h=>be.warn(this.tag,"Failed to play audio",l.src,h));xr.motionSync&&(yield c)}return this.state.start(u,i,n,s)?(be.log(this.tag,"Start motion:",this.getMotionName(a)),this.emit("motionStart",i,n,l),this.state.shouldOverrideExpression()&&this.expressionManager&&this.expressionManager.resetExpression(),this.playing=!0,this._startMotion(u),!0):(l&&(Hn.dispose(l),this.currentAudio=void 0),!1)})}startRandomMotion(t,e){return Fe(this,null,function*(){const i=this.definitions[t];if(i!=null&&i.length){const n=[];for(let s=0;se.index>=0);for(const e of t)this.hitAreas[e.name]=e}hitTest(t,e){return Object.keys(this.hitAreas).filter(i=>this.isHit(i,t,e))}isHit(t,e,i){if(!this.hitAreas[t])return!1;const n=this.hitAreas[t].index,s=this.getDrawableBounds(n,nI);return s.x<=e&&e<=s.x+s.width&&s.y<=i&&i<=s.y+s.height}getDrawableBounds(t,e){const i=this.getDrawableVertices(t);let n=i[0],s=i[0],o=i[1],a=i[1];for(let l=0;l{(s.status===200||s.status===0)&&s.response?i(s.response):s.onerror()},s.onerror=()=>{be.warn(oI,`Failed to load resource as ${s.responseType} (Status ${s.status}): ${t}`),n(new rp("Network error.",t,s.status))},s.onabort=()=>n(new rp("Aborted.",t,s.status,!0)),s.onloadend=()=>{var o;nr.allXhrSet.delete(s),r&&((o=nr.xhrMap.get(r))==null||o.delete(s))},s}static cancelXHRs(){var r;(r=nr.xhrMap.get(this))==null||r.forEach(t=>{t.abort(),nr.allXhrSet.delete(t)}),nr.xhrMap.delete(this)}static release(){nr.allXhrSet.forEach(r=>r.abort()),nr.allXhrSet.clear(),nr.xhrMap=new WeakMap}};let tu=nr;tu.xhrMap=new WeakMap;tu.allXhrSet=new Set;tu.loader=(r,t)=>new Promise((e,i)=>{nr.createXHR(r.target,r.settings?r.settings.resolveURL(r.url):r.url,r.type,s=>{r.result=s,e()},i).send()});function pv(r,t){let e=-1;return i(0);function i(n,s){if(s)return Promise.reject(s);if(n<=e)return Promise.reject(new Error("next() called multiple times"));e=n;const o=r[n];if(!o)return Promise.resolve();try{return Promise.resolve(o(t,i.bind(null,n+1)))}catch(a){return Promise.reject(a)}}}class mn{static load(t){return pv(this.middlewares,t).then(()=>t.result)}}mn.middlewares=[tu.loader];function aI(r,t={}){var e;const i={resourceOptions:{crossorigin:t.crossOrigin}};if(es.fromURL)return es.fromURL(r,i).catch(o=>{if(o instanceof Error)throw o;const a=new Error("Texture loading error");throw a.event=o,a});i.resourceOptions.autoLoad=!1;const n=es.from(r,i);if(n.baseTexture.valid)return Promise.resolve(n);const s=n.baseTexture.resource;return(e=s._live2d_load)!=null||(s._live2d_load=new Promise((o,a)=>{const l=u=>{s.source.removeEventListener("error",l);const c=new Error("Texture loading error");c.event=u,a(c)};s.source.addEventListener("error",l),s.load().then(()=>o(n)).catch(l)})),s._live2d_load}const ip="Live2DFactory",mv=(r,t)=>Fe(void 0,null,function*(){if(typeof r.source=="string"){const e=yield mn.load({url:r.source,type:"json",target:r.live2dModel});e.url=r.source,r.source=e,r.live2dModel.emit("settingsJSONLoaded",e)}return t()}),yv=(r,t)=>Fe(void 0,null,function*(){if(r.source instanceof ef)return r.settings=r.source,t();if(typeof r.source=="object"){const e=Re.findRuntime(r.source);if(e){const i=e.createModelSettings(r.source);return r.settings=i,r.live2dModel.emit("settingsLoaded",i),t()}}throw new TypeError("Unknown settings format.")}),gv=(r,t)=>{if(r.settings){const e=Re.findRuntime(r.settings);if(e)return e.ready().then(t)}return t()},vv=(r,t)=>Fe(void 0,null,function*(){yield t();const e=r.internalModel;if(e){const i=r.settings,n=Re.findRuntime(i);if(n){const s=[];i.pose&&s.push(mn.load({settings:i,url:i.pose,type:"json",target:e}).then(o=>{e.pose=n.createPose(e.coreModel,o),r.live2dModel.emit("poseLoaded",e.pose)}).catch(o=>{r.live2dModel.emit("poseLoadError",o),be.warn(ip,"Failed to load pose.",o)})),i.physics&&s.push(mn.load({settings:i,url:i.physics,type:"json",target:e}).then(o=>{e.physics=n.createPhysics(e.coreModel,o),r.live2dModel.emit("physicsLoaded",e.physics)}).catch(o=>{r.live2dModel.emit("physicsLoadError",o),be.warn(ip,"Failed to load physics.",o)})),s.length&&(yield Promise.all(s))}}}),_v=(r,t)=>Fe(void 0,null,function*(){if(r.settings){const e=r.live2dModel,i=r.settings.textures.map(n=>{const s=r.settings.resolveURL(n);return aI(s,{crossOrigin:r.options.crossOrigin})});if(yield t(),r.internalModel)e.internalModel=r.internalModel,e.emit("modelLoaded",r.internalModel);else throw new TypeError("Missing internal model.");e.textures=yield Promise.all(i),e.emit("textureLoaded",e.textures)}else throw new TypeError("Missing settings.")}),bv=(r,t)=>Fe(void 0,null,function*(){const e=r.settings;if(e instanceof ef){const i=Re.findRuntime(e);if(!i)throw new TypeError("Unknown model settings.");const n=yield mn.load({settings:e,url:e.moc,type:"arraybuffer",target:r.live2dModel});if(!i.isValidMoc(n))throw new Error("Invalid moc data");const s=i.createCoreModel(n);return r.internalModel=i.createInternalModel(s,e,r.options),t()}throw new TypeError("Missing settings.")}),Xe=class{static registerRuntime(r){Xe.runtimes.push(r),Xe.runtimes.sort((t,e)=>e.version-t.version)}static findRuntime(r){for(const t of Xe.runtimes)if(t.test(r))return t}static setupLive2DModel(r,t,e){return Fe(this,null,function*(){const i=new Promise(o=>r.once("textureLoaded",o)),n=new Promise(o=>r.once("modelLoaded",o)),s=Promise.all([i,n]).then(()=>r.emit("ready"));yield pv(Xe.live2DModelMiddlewares,{live2dModel:r,source:t,options:e||{}}),yield s,r.emit("load")})}static loadMotion(r,t,e){var i,n;const s=o=>r.emit("motionLoadError",t,e,o);try{const o=(i=r.definitions[t])==null?void 0:i[e];if(!o)return Promise.resolve(void 0);r.listeners("destroy").includes(Xe.releaseTasks)||r.once("destroy",Xe.releaseTasks);let a=Xe.motionTasksMap.get(r);a||(a={},Xe.motionTasksMap.set(r,a));let l=a[t];l||(l=[],a[t]=l);const u=r.getMotionFile(o);return(n=l[e])!=null||(l[e]=mn.load({url:u,settings:r.settings,type:r.motionDataType,target:r}).then(c=>{var h;const p=(h=Xe.motionTasksMap.get(r))==null?void 0:h[t];p&&delete p[e];const f=r.createMotion(c,t,o);return r.emit("motionLoaded",t,e,f),f}).catch(c=>{be.warn(r.tag,`Failed to load motion: ${u}
`,c),s(c)})),l[e]}catch(o){be.warn(r.tag,`Failed to load motion at "${t}"[${e}]
-`,o),s(o)}return Promise.resolve(void 0)}static loadExpression(r,t){var e;const i=n=>r.emit("expressionLoadError",t,n);try{const n=r.definitions[t];if(!n)return Promise.resolve(void 0);r.listeners("destroy").includes(Ye.releaseTasks)||r.once("destroy",Ye.releaseTasks);let s=Ye.expressionTasksMap.get(r);s||(s=[],Ye.expressionTasksMap.set(r,s));const o=r.getExpressionFile(n);return(e=s[t])!=null||(s[t]=dn.load({url:o,settings:r.settings,type:"json",target:r}).then(a=>{const l=Ye.expressionTasksMap.get(r);l&&delete l[t];const u=r.createExpression(a,n);return r.emit("expressionLoaded",t,u),u}).catch(a=>{be.warn(r.tag,`Failed to load expression: ${o}
+`,o),s(o)}return Promise.resolve(void 0)}static loadExpression(r,t){var e;const i=n=>r.emit("expressionLoadError",t,n);try{const n=r.definitions[t];if(!n)return Promise.resolve(void 0);r.listeners("destroy").includes(Xe.releaseTasks)||r.once("destroy",Xe.releaseTasks);let s=Xe.expressionTasksMap.get(r);s||(s=[],Xe.expressionTasksMap.set(r,s));const o=r.getExpressionFile(n);return(e=s[t])!=null||(s[t]=mn.load({url:o,settings:r.settings,type:"json",target:r}).then(a=>{const l=Xe.expressionTasksMap.get(r);l&&delete l[t];const u=r.createExpression(a,n);return r.emit("expressionLoaded",t,u),u}).catch(a=>{be.warn(r.tag,`Failed to load expression: ${o}
`,a),i(a)})),s[t]}catch(n){be.warn(r.tag,`Failed to load expression at [${t}]
-`,n),i(n)}return Promise.resolve(void 0)}static releaseTasks(){this instanceof Jh?Ye.motionTasksMap.delete(this):Ye.expressionTasksMap.delete(this)}};let Re=Ye;Re.runtimes=[];Re.urlToJSON=uv;Re.jsonToSettings=cv;Re.waitUntilReady=hv;Re.setupOptionals=fv;Re.setupEssentials=dv;Re.createInternalModel=pv;Re.live2DModelMiddlewares=[uv,cv,hv,fv,dv,pv];Re.motionTasksMap=new WeakMap;Re.expressionTasksMap=new WeakMap;Jh.prototype._loadMotion=function(r,t){return Re.loadMotion(this,r,t)};av.prototype._loadExpression=function(r){return Re.loadExpression(this,r)};class ZT{constructor(){this._autoInteract=!1}get autoInteract(){return this._autoInteract}set autoInteract(t){t!==this._autoInteract&&(t?this.on("pointertap",rp,this):this.off("pointertap",rp,this),this._autoInteract=t)}registerInteraction(t){t!==this.interactionManager&&(this.unregisterInteraction(),this._autoInteract&&t&&(this.interactionManager=t,t.on("pointermove",ip,this)))}unregisterInteraction(){var t;this.interactionManager&&((t=this.interactionManager)==null||t.off("pointermove",ip,this),this.interactionManager=void 0)}}function rp(r){this.tap(r.data.global.x,r.data.global.y)}function ip(r){this.focus(r.data.global.x,r.data.global.y)}class JT extends Bg{}const Dr=new Ee,tI=new Ze;let tn;class eI extends rl{constructor(t){super(),this.tag="Live2DModel(uninitialized)",this.textures=[],this.transform=new JT,this.anchor=new Rs(this.onAnchorChange,this,0,0),this.glContextID=-1,this.elapsedTime=performance.now(),this.deltaTime=0,this._autoUpdate=!1,this.once("modelLoaded",()=>this.init(t))}static from(t,e){const i=new this(e);return Re.setupLive2DModel(i,t,e).then(()=>i)}static fromSync(t,e){const i=new this(e);return Re.setupLive2DModel(i,t,e).then(e==null?void 0:e.onLoad).catch(e==null?void 0:e.onError),i}static registerTicker(t){tn=t}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){var e;tn||(tn=(e=window.PIXI)==null?void 0:e.Ticker),t?this._destroyed||(tn?(tn.shared.add(this.onTickerUpdate,this),this._autoUpdate=!0):be.warn(this.tag,"No Ticker registered, please call Live2DModel.registerTicker(Ticker).")):(tn==null||tn.shared.remove(this.onTickerUpdate,this),this._autoUpdate=!1)}init(t){this.tag=`Live2DModel(${this.internalModel.settings.name})`;const e=Object.assign({autoUpdate:!0,autoInteract:!0},t);e.autoInteract&&(this.interactive=!0),this.autoInteract=e.autoInteract,this.autoUpdate=e.autoUpdate}onAnchorChange(){this.pivot.set(this.anchor.x*this.internalModel.width,this.anchor.y*this.internalModel.height)}motion(t,e,i){return e===void 0?this.internalModel.motionManager.startRandomMotion(t,i):this.internalModel.motionManager.startMotion(t,e,i)}expression(t){return this.internalModel.motionManager.expressionManager?t===void 0?this.internalModel.motionManager.expressionManager.setRandomExpression():this.internalModel.motionManager.expressionManager.setExpression(t):Promise.resolve(!1)}focus(t,e,i=!1){Dr.x=t,Dr.y=e,this.toModelPosition(Dr,Dr,!0);let n=Dr.x/this.internalModel.originalWidth*2-1,s=Dr.y/this.internalModel.originalHeight*2-1,o=Math.atan2(s,n);this.internalModel.focusController.focus(Math.cos(o),-Math.sin(o),i)}tap(t,e){const i=this.hitTest(t,e);i.length&&(be.log(this.tag,"Hit",i),this.emit("hit",i))}hitTest(t,e){return Dr.x=t,Dr.y=e,this.toModelPosition(Dr,Dr),this.internalModel.hitTest(Dr.x,Dr.y)}toModelPosition(t,e=t.clone(),i){return i||(this._recursivePostUpdateTransform(),this.parent?this.displayObjectUpdateTransform():(this.parent=this._tempDisplayObjectParent,this.displayObjectUpdateTransform(),this.parent=null)),this.transform.worldTransform.applyInverse(t,e),this.internalModel.localTransform.applyInverse(e,e),e}containsPoint(t){return this.getBounds(!0).contains(t.x,t.y)}_calculateBounds(){this._bounds.addFrame(this.transform,0,0,this.internalModel.width,this.internalModel.height)}onTickerUpdate(){this.update(tn.shared.deltaMS)}update(t){this.deltaTime+=t,this.elapsedTime+=t}_render(t){this.registerInteraction(t.plugins.interaction),t.batch.reset(),t.geometry.reset(),t.shader.reset(),t.state.reset();let e=!1;this.glContextID!==t.CONTEXT_UID&&(this.glContextID=t.CONTEXT_UID,this.internalModel.updateWebGLContext(t.gl,this.glContextID),e=!0);for(let s=0;s